[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 06/14] xen/arm: Add support for PCI ecam operations


  • To: Julien Grall <julien@xxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Tue, 14 Sep 2021 08:13:42 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=A1eAOtC3pk2epVyElQaImZ6r7HoGTFqWbmPybf/bh2M=; b=hRaMCsgl1CONssp2u+y2Swiz0G6B2sGbT1WDaL54VNS4sock3LJJgsHjsAyS4XjOw/OhTPZGq+F72M8ae6GJX2zh7bycWimGS1DwyB65Ep4KjpHJQmstnHz5cqT+xBx0S4UyEYNTd0LZ3tHVGFPO6jn0+LDIi/+2ZjBkkeGp2Fy9ss1vqdMCqKs4CVSfZV52mxNbZulLQYx76uH3DnkzXaQqlXim4DoD03K+b3IdPR4uK7iiwFEWk3ZG9zuX1yiTzS9CQAS6EISFNWLt4EcZAcJmlYwx1YVzfKIWuREhnJcqCY1eu8RjaO1l9g8b9YzWznyf54PWp6/lXx4hcAoMNg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rvt6BTXOY+B8/YOTsjq2x34GU7l0FMw/uH4BJEAyX2majIedFZZ2XuGk32p9VylnblZKL0NoM4MAvQ4M3NpndMbe5NvPu/yQsR/34ZXhtC1lOAVaVKxFK+hrHe7QsI3ht4BXjQuzNRbGqXVu/B/MhQIxlt5//bpDuoEB741NLfa1vO1dPkSeM9fhEwWWBa0YPv1B8Zx1xBqApRv9lHxUi2Zc9B+TNxFTpTOGAeC6qYRbfwdq2ql17gzJV/IkBJ8c+JeNKxNT5E0CuZdhY2CPRY6EaNiK+JgN5Ptqz3r/1ZHFVIV58dwgnka3BLMr70098NbrczwQjC3E1MEr1nlM4A==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 14 Sep 2021 08:14:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHXlPK6hMBa2cV9wU+RB+r01dTauqubssEAgAekNIA=
  • Thread-topic: [PATCH v1 06/14] xen/arm: Add support for PCI ecam operations

Hi Julien,

> On 9 Sep 2021, at 12:32 pm, Julien Grall <julien@xxxxxxx> wrote:
> 
> Hi Rahul,
> 
> On 19/08/2021 13:02, Rahul Singh wrote:
>> Add support for PCI ecam operations to access the PCI
>> configuration space.
>> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
>> ---
>>  xen/arch/arm/pci/Makefile           |  1 +
>>  xen/arch/arm/pci/ecam.c             | 63 +++++++++++++++++++++++++++++
>>  xen/arch/arm/pci/pci-access.c       | 53 ++++++++++++++++++++++++
>>  xen/arch/arm/pci/pci-host-common.c  | 13 +++++-
>>  xen/arch/arm/pci/pci-host-generic.c |  8 +++-
>>  xen/include/asm-arm/pci.h           | 32 +++++++++++++++
>>  6 files changed, 167 insertions(+), 3 deletions(-)
>>  create mode 100644 xen/arch/arm/pci/ecam.c
>> diff --git a/xen/arch/arm/pci/Makefile b/xen/arch/arm/pci/Makefile
>> index f3d97f859e..6f32fbbe67 100644
>> --- a/xen/arch/arm/pci/Makefile
>> +++ b/xen/arch/arm/pci/Makefile
>> @@ -2,3 +2,4 @@ obj-y += pci.o
>>  obj-y += pci-access.o
>>  obj-y += pci-host-generic.o
>>  obj-y += pci-host-common.o
>> +obj-y += ecam.o
>> diff --git a/xen/arch/arm/pci/ecam.c b/xen/arch/arm/pci/ecam.c
>> new file mode 100644
>> index 0000000000..91c691b41f
>> --- /dev/null
>> +++ b/xen/arch/arm/pci/ecam.c
>> @@ -0,0 +1,63 @@
>> +/*
>> + * Copyright (C) 2021 Arm Ltd.
>> + *
>> + * Based on Linux drivers/pci/ecam.c
>> + * Copyright 2016 Broadcom
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#include <xen/pci.h>
>> +#include <xen/sched.h>
>> +
>> +/*
>> + * Function to implement the pci_ops ->map_bus method.
>> + */
>> +void __iomem *pci_ecam_map_bus(struct pci_host_bridge *bridge,
>> +                                      uint32_t sbdf, uint32_t where)
>> +{
>> +    const struct pci_config_window *cfg = bridge->sysdata;
>> +    unsigned int devfn_shift = cfg->ops->bus_shift - 8;
>> +    void __iomem *base;
>> +
>> +    pci_sbdf_t sbdf_t = (pci_sbdf_t) sbdf ;
> 
> AFAICT, pci_sbdf is an union between a 32-bit and a structure. So please 
> don't use the cast and use the 32-bit field to assign the value.
> 
> Also, there is an extra space before ';'.

Ok. As per your below comment I will remove the sbdf_t completely.
> 
> 
>> +    unsigned int busn = sbdf_t.bus;
>> +
>> +    if ( busn < cfg->busn_start || busn > cfg->busn_end )
>> +        return NULL;
>> +
>> +    busn -= cfg->busn_start;
>> +    base = cfg->win + (busn << cfg->ops->bus_shift);
>> +
>> +    return base + (PCI_DEVFN(sbdf_t.dev, sbdf_t.fn) << devfn_shift) + where;
> 
> How about using PCI_DEVFN2(sbdf)? This would allow you to drop the use of 
> sbdf_t completely (sbdf_t.bus could be replaced with PCI_BUS(sdbf)).
Make sense. I will modify as per your request.
> 
>> +}
>> +
>> +/* ECAM ops */
>> +const struct pci_ecam_ops pci_generic_ecam_ops = {
>> +    .bus_shift  = 20,
>> +    .pci_ops    = {
>> +        .map_bus                = pci_ecam_map_bus,
>> +        .read                   = pci_generic_config_read,
>> +        .write                  = pci_generic_config_write,
>> +    }
>> +};
>> +
>> +/*
>> + * Local variables:
>> + * mode: C
>> + * c-file-style: "BSD"
>> + * c-basic-offset: 4
>> + * tab-width: 4
>> + * indent-tabs-mode: nil
>> + * End:
>> + */
>> diff --git a/xen/arch/arm/pci/pci-access.c b/xen/arch/arm/pci/pci-access.c
>> index b938047c03..f39f6a3a38 100644
>> --- a/xen/arch/arm/pci/pci-access.c
>> +++ b/xen/arch/arm/pci/pci-access.c
>> @@ -15,6 +15,59 @@
>>   */
>>    #include <xen/pci.h>
>> +#include <asm/io.h>
>> +
>> +int pci_generic_config_read(struct pci_host_bridge *bridge, uint32_t sbdf,
>> +                            uint32_t reg, uint32_t len, uint32_t *value)
>> +{
>> +    void __iomem *addr = bridge->ops->map_bus(bridge, sbdf, reg);
> 
> Please add a newline here.

Ack. 
> 
>> +    if (!addr) {
> 
> You seem to use a mix of Xen and Linux coding style. If the file contains 
> mostly Xen code, then we should use the former.

Ok. I will fix the coding style in next version.
 
Regards,
Rahul


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.