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

Re: [PATCH v2 13/17] xen:arm: Implement pci access functions


  • To: Julien Grall <julien@xxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Thu, 23 Sep 2021 15:19:11 +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=CE6xfdgEbdAmnNOTa4mvdWHE85o6Ets6LCElyMVzqmI=; b=ixoCFCj4MrdtZCCcLMQ0bk1IIpUh8X3gTGCpYI9U9uS4nPfe5hDkw6YIRA5l6IRLwMrao15xp25hzjzQEAxHGbVSUAynMO7B18kxSeoK0RsByQ+WPnqJNYQ3E45sNDx1M9lAgi6SPP36tx4E5apcu3KNxAeIj/JhlqSSlJsnsEbiuVM+eUqZ4BhAbvLZUnujv11cTLADl7L8r34nflbI8xhF6U8nulbRQIjzIW2EP+S+IOffGXm7AIUQ1CPTmgI90z6J9XKoR2KtbLeStPrrJVFB0ck/7hBTbi7M1oZXBzMSj289EojiOAZZyK7SvmCKX3jTMipRRFRe/pvLx3sXMQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GwI/NQJ4EtjRxkkENbLLwO+Ekd8/EkAYBiIFWsG9nr3QdJQVEviupLb0TIMwzMglC+ufMuH0egpmr8QEHdr/fLXD1tbUKTOvENW52K+W56iPrsFNFTPUCLipCSGcNrlGiCMRaZErE7pbRVyKOuurehQPu6NjTahwLBx/ctV/0qMbX9+NnKkA5RX/257yqFDcGaepXIwOB7FMFh+WtB1rdW2Quhw2PxzyJvjf6nRi2p72JvOEttNLfIgs9gDw7QdYcWskYk5EgrPF9Bb1WkHUQxYUa6ROoRwVRr9O8Tb1XpTr2oE7+7RZPkc0V2q989nTq6wvYvE0xF3YibS9+h5B+w==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Andre Przywara <Andre.Przywara@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 23 Sep 2021 15:19:33 +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: AQHXr6aktO5EpOLLjku5HahQRSHFEauw5LyAgABvjQCAAGkgAA==
  • Thread-topic: [PATCH v2 13/17] xen:arm: Implement pci access functions

Hi Julien,

> On 23 Sep 2021, at 10:02 am, Julien Grall <julien@xxxxxxx> wrote:
> 
> Hi Stefano,
> 
> On 23/09/2021 07:23, Stefano Stabellini wrote:
>> Subject should have xen/arm
>> On Wed, 22 Sep 2021, Rahul Singh wrote:
>>> Implement generic pci access functions to read/write the configuration
>>> space.
>>> 
>>> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
>>> ---
>>> Change in v2: Fixed comments
>>> ---
>>>  xen/arch/arm/pci/pci-access.c      | 58 ++++++++++++++++++++++++++++++
>>>  xen/arch/arm/pci/pci-host-common.c | 19 ++++++++++
>>>  xen/include/asm-arm/pci.h          |  2 ++
>>>  3 files changed, 79 insertions(+)
>>> 
>>> diff --git a/xen/arch/arm/pci/pci-access.c b/xen/arch/arm/pci/pci-access.c
>>> index 04fe9fbf92..45500cec2a 100644
>>> --- a/xen/arch/arm/pci/pci-access.c
>>> +++ b/xen/arch/arm/pci/pci-access.c
>>> @@ -16,6 +16,7 @@
>>>  #include <asm/io.h>
>>>    #define INVALID_VALUE (~0U)
>>> +#define PCI_ERR_VALUE(len) GENMASK(0, len * 8)
>>>    int pci_generic_config_read(struct pci_host_bridge *bridge, uint32_t 
>>> sbdf,
>>>                              uint32_t reg, uint32_t len, uint32_t *value)
>>> @@ -72,6 +73,63 @@ int pci_generic_config_write(struct pci_host_bridge 
>>> *bridge, uint32_t sbdf,
>>>      return 0;
>>>  }
>>>  +static uint32_t pci_config_read(pci_sbdf_t sbdf, unsigned int reg,
>>> +                                unsigned int len)
>>> +{
>>> +    uint32_t val = PCI_ERR_VALUE(len);
>>> +
>> No blank line
>>> +    struct pci_host_bridge *bridge = pci_find_host_bridge(sbdf.seg, 
>>> sbdf.bus);
>>> +
>>> +    if ( unlikely(!bridge) )
>>> +        return val;
>>> +
>>> +    if ( unlikely(!bridge->ops->read) )
>>> +        return val;
>>> +
>>> +    bridge->ops->read(bridge, (uint32_t) sbdf.sbdf, reg, len, &val);
>> The more I look at these casts the less I like them :-D
> 
> I really dislike them. This is kind of defeating the purpose of trying to be 
> more typesafe.
> 
>> One idea is to move the definition of pci_sbdf_t somewhere else
>> entirely, for instance xen/include/xen/types.h, then we can use
>> pci_sbdf_t everywhere
> 
> AFAIU, the problem is the prototype helpers are defined in asm/pci.h which is 
> included by xen/pci.h before defining sbdf_t. Is it correct?
> 
> If so there are two options:
>  1) define sbdf_t and then include asm/pci.h.
>  2) Name the union and then pre-declare it.
> 
> Option 1 is probably nicer is we have more types in the future that are used 
> by arch specific but defined in the common headers. We have a few places that 
> uses this approach.
> 

Thanks for the pointer I will fix this in next version.

Regards,
Rahul
> Cheers,
> 
> -- 
> Julien Grall




 


Rackspace

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