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

Re: [PATCH 09/10] vpci/rcar: Implement vPCI.update_bar_header callback


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Oleksandr Andrushchenko <andr2000@xxxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Fri, 13 Nov 2020 06:50:18 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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:X-MS-Exchange-SenderADCheck; bh=nALvFPR8B4d8Ubr7h2k4RBjlh2sdoAQ43oBFYpF56eM=; b=LZvBO6GyF+nkNbknmxg7g0tOgNx3MMRURwuMAbN9zIRqVEyplhr+Gc4pFpXa2qnhFfn4wvEOPGBWUQ7BZZKMwk2V+l9htnovpwqglQg3tKAVHRk2XHF3XL0RL5+/xpN0VbcWB7wYnVKGmhrhDpZm6pj5lkZls0rgJ5h9vBwS0MhJkS81n2Zg9lx/f/YywVBhxaw/bayZVg6mRWSpUG6cBbumPY94UEfx1bB8BvteZerCu0uiRiMESYSQm0un/uSUbGsv9MH6UHr4/Qk9t9mZfgOItOKnfz56Rp0xQ5wU9ZTJf6CAol+elzXi/V8CemAFcPRB4XgHDkAxlfkgpfeoIg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jwA+V55PlRh2rNPqzpQe+43G/Vwk8kZAeF4+y5UnPtqy+i/o8memuf09v3Q4hah2mAkAA3o5qfenklvwmLhD3yp+nSNFdKN3d8CnQSYyZ1Jd0XASQkLTI9n3NvY/oaMBgyFw62DazD68FZww8H3IoIjZMZZ4vOaNJsJafotJJfDfzag0MM0ijwZ7O9aQ5KkyZQ0TYYxKQJ5FaOkWRA6tqzJBhxRGrTULXh4SVOVbEdDwvRrbd0NQxESjjpPgACkAjpHRZYXEVx3Azpdr0nVAp66WvFJejFHwwb50uFsqSS4TeVCQfljAeNuy77Jq3SgtW67Ozc58L/0tup/4RsaKzA==
  • Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=epam.com;
  • Cc: "Rahul.Singh@xxxxxxx" <Rahul.Singh@xxxxxxx>, "Bertrand.Marquis@xxxxxxx" <Bertrand.Marquis@xxxxxxx>, "julien.grall@xxxxxxx" <julien.grall@xxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "iwj@xxxxxxxxxxxxxx" <iwj@xxxxxxxxxxxxxx>, "wl@xxxxxxx" <wl@xxxxxxx>
  • Delivery-date: Fri, 13 Nov 2020 06:50:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWtpbzTvJ5qBS+Xk6vR5/qsR0EDanESDwAgAFdFAA=
  • Thread-topic: [PATCH 09/10] vpci/rcar: Implement vPCI.update_bar_header callback

On 11/12/20 12:00 PM, Roger Pau Monné wrote:
> On Mon, Nov 09, 2020 at 02:50:30PM +0200, Oleksandr Andrushchenko wrote:
>> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
>>
>> Update hardware domain's BAR header as R-Car Gen3 is a non-ECAM host
>> controller, so vPCI MMIO handlers do not work for it in hwdom.
>>
>> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
>> ---
>>   xen/arch/arm/pci/pci-host-rcar-gen3.c | 69 +++++++++++++++++++++++++++
>>   1 file changed, 69 insertions(+)
>>
>> diff --git a/xen/arch/arm/pci/pci-host-rcar-gen3.c 
>> b/xen/arch/arm/pci/pci-host-rcar-gen3.c
>> index ec14bb29a38b..353ac2bfd6e6 100644
>> --- a/xen/arch/arm/pci/pci-host-rcar-gen3.c
>> +++ b/xen/arch/arm/pci/pci-host-rcar-gen3.c
>> @@ -23,6 +23,7 @@
>>   #include <xen/pci.h>
>>   #include <asm/pci.h>
>>   #include <xen/vmap.h>
>> +#include <xen/vpci.h>
>>   
>>   /* Error values that may be returned by PCI functions */
>>   #define PCIBIOS_SUCCESSFUL         0x00
>> @@ -307,12 +308,80 @@ int pci_rcar_gen3_config_write(struct pci_host_bridge 
>> *bridge, uint32_t _sbdf,
>>       return ret;
>>   }
>>   
>> +static void pci_rcar_gen3_hwbar_init(const struct pci_dev *pdev,
>> +                                     struct vpci_header *header)
>> +
>> +{
>> +    static bool once = true;
>> +    struct vpci_bar *bars = header->bars;
>> +    unsigned int num_bars;
>> +    int i;
> unsigned.
ok
>
>> +
>> +    /* Run only once. */
>> +    if (!once)
> Missing spaces.
ok
>
>> +        return;
>> +    once = false;
>> +
>> +    printk("\n\n ------------------------ %s -------------------\n", 
>> __func__);
>> +    switch ( pci_conf_read8(pdev->sbdf, PCI_HEADER_TYPE) & 0x7f )
>> +    {
>> +    case PCI_HEADER_TYPE_NORMAL:
>> +        num_bars = PCI_HEADER_NORMAL_NR_BARS;
>> +        break;
>> +
>> +    case PCI_HEADER_TYPE_BRIDGE:
>> +        num_bars = PCI_HEADER_BRIDGE_NR_BARS;
>> +        break;
>> +
>> +    default:
>> +        return;
>> +    }
>> +
>> +    for ( i = 0; i < num_bars; i++ )
>> +    {
>> +        uint8_t reg = PCI_BASE_ADDRESS_0 + i * 4;
>> +
>> +        if ( bars[i].type == VPCI_BAR_MEM64_HI )
>> +        {
>> +            /*
>> +             * Skip hi part of the 64-bit register: it is read
>> +             * together with the lower part.
>> +             */
>> +            continue;
>> +        }
>> +
>> +        if ( bars[i].type == VPCI_BAR_IO )
>> +        {
>> +            /* Skip IO. */
>> +            continue;
>> +        }
>> +
>> +        if ( bars[i].type == VPCI_BAR_MEM64_LO )
>> +        {
>> +            /* Read both hi and lo parts of the 64-bit BAR. */
>> +            bars[i].addr =
>> +                (uint64_t)pci_conf_read32(pdev->sbdf, reg + 4) << 32 |
>> +                pci_conf_read32(pdev->sbdf, reg);
>> +        }
>> +        else if ( bars[i].type == VPCI_BAR_MEM32 )
>> +        {
>> +            bars[i].addr = pci_conf_read32(pdev->sbdf, reg);
>> +        }
>> +        else
>> +        {
>> +            /* Expansion ROM? */
>> +            continue;
>> +        }
> Wouldn't this be much simpler as:
Yes, seems to be simpler, thank you
>
> bars[i].addr = 0;
> switch ( bars[i].type )
> {
> case VPCI_BAR_MEM64_HI:
>      bars[i].addr = (uint64_t)pci_conf_read32(pdev->sbdf, reg + 4) << 32;
>      /+ fallthrough. */
> case VPCI_BAR_MEM64_LO:
>       bars[i].addr |= pci_conf_read32(pdev->sbdf, reg);
>       break;
>
> default:
>      break;
> }
>
> I also wonder why you only care about the address but not the size of
> the BAR.
Yes, size needs to be updated as well, even for RFC
>
> Thanks, Roger.

Thank you,

Oleksandr

 


Rackspace

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