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

Re: [PATCH v2 09/17] xen/arm: Add support for PCI init to initialize the PCI driver.


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Thu, 23 Sep 2021 14:53:28 +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=ElhrFnB5ab2oZRXsVLBHtVJqO97uKi/ogzrBE4TU2+w=; b=O0b89N6PrZnwjIartnjIGXbRZsIVQoP95iqfGIedjwggMSPM6jgWf97SdySqIvKFDMkNsTQezp5hW7Bt5P+kiGCiyWaVE5Sues39IOlOjoUZwxGMsrsPcZTeFuFUHbiIGVcxrWggb0T9j9hZ5x5rtnWh7x/Z5MsDHxUZP5U3g3fmO2+MR1SoCJkTFBLMrwfSx+waa4qtOK04s54l8KpL5YuCR1pKZxFr2J2YzxAZGDQLgf2LhUBBJRAAevlpBaPtUUrgoabVpNBhwLAxAdHe/ZQI8/6bz0TFE4EPkGRoFczvmqYv5zBddPSljzmRZbNtwEtDg4uwUdZQQzDsHglqKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YZg3Q4o6eshRLEp1G5yI8Yf5v9vOsRSKHNX7NbJgH93A1RreL8HTWgvxwlzVVVyBvOAxECwib45tO6BvBy8MX3dwTrj4I3++gpJNMHf1S8+gjRrJJGSX63uiPHvRyMA9PtAQx6Y+kbvEJVlJY2WosQgPg91FIpYZlC2MHOl+PcuVbqMlbBA9eH/ckn5oF33MpQGYUKFSobpNURyyihHc3BINmFCgMn1IsD+wvNeLUMQVYV12ODd+cRjkphzN5v7dJ+NS4C8Bpt5Kv2OlAFB8FDd7xmCbWF5fF3blahNmMN+DiGPxXeUcd+dY+KnUfJ0s2kFpFsFgRaN+EqE/QbP6Rw==
  • Authentication-results-original: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=arm.com;
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Andre Przywara <Andre.Przywara@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 23 Sep 2021 14:53:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHXr6Z0kesRmMgn3UWCiz/08WLEoauwvZ2AgAD4nYA=
  • Thread-topic: [PATCH v2 09/17] xen/arm: Add support for PCI init to initialize the PCI driver.

Hi Stefano,

> On 23 Sep 2021, at 1:03 am, Stefano Stabellini <sstabellini@xxxxxxxxxx> wrote:
> 
> On Wed, 22 Sep 2021, Rahul Singh wrote:
>> pci_init(..) will be called during xen startup to initialize and probe
>> the PCI host-bridge driver.
>> 
>> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
>> ---
>> Change in v2:
>> - ACPI init function to return int
>> - pci_segments_init() called before dt/acpi init
>> ---
>> xen/arch/arm/pci/pci.c       | 54 ++++++++++++++++++++++++++++++++++++
>> xen/include/asm-arm/device.h |  1 +
>> 2 files changed, 55 insertions(+)
>> 
>> diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c
>> index a7a7bc3213..71fa532842 100644
>> --- a/xen/arch/arm/pci/pci.c
>> +++ b/xen/arch/arm/pci/pci.c
>> @@ -12,6 +12,10 @@
>>  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>>  */
>> 
>> +#include <xen/acpi.h>
>> +#include <xen/device_tree.h>
>> +#include <xen/errno.h>
>> +#include <xen/init.h>
>> #include <xen/pci.h>
>> 
>> /*
>> @@ -22,6 +26,56 @@ int arch_pci_clean_pirqs(struct domain *d)
>>     return 0;
>> }
>> 
>> +static int __init dt_pci_init(void)
>> +{
>> +    struct dt_device_node *np;
>> +    int rc;
>> +
>> +    dt_for_each_device_node(dt_host, np)
>> +    {
>> +        rc = device_init(np, DEVICE_PCI, NULL);
>> +        if( !rc )
>> +            continue;
> 
> This is a NIT, so feel free to code it as you prefer, but I would write
> it as follows for simplicity:
> 
> 
> /* comment about EBADF and ENODEV */
> if ( !rc || rc == -EBADF || rc == -ENODEV )
>    continue;
> return rc;

Ack. 
> 
> 
>> +        /*
>> +         * Ignore the following error codes:
>> +         *   - EBADF: Indicate the current is not an pci
>                                             ^ device ^a   ^ device

Ac.
> 
> 
>> +         *   - ENODEV: The pci device is not present or cannot be used by
>> +         *     Xen.
>> +         */
>> +        else if ( rc != -EBADF && rc != -ENODEV )
>> +        {
>> +            printk(XENLOG_ERR "No driver found in XEN or driver init 
>> error.\n");
>> +            return rc;
>> +        }
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>> +#ifdef CONFIG_ACPI
>> +static int __init acpi_pci_init(void)
>> +{
>> +    printk(XENLOG_ERR "ACPI pci init not supported \n");
>> +    return 0;
> 
> Should return ENOSYS or EOPNOTSUPP?

I think EOPNOTSUPP is right choice.

Regards,
Rahul

> 
> 
>> +}
>> +#else
>> +static inline int __init acpi_pci_init(void)
> 
> Not sure I would inline it but OK either way
> 
> 
>> +{
>> +    return -EINVAL;
>> +}
>> +#endif
>> +
>> +static int __init pci_init(void)
>> +{
>> +    pci_segments_init();
>> +
>> +    if ( acpi_disabled )
>> +        return dt_pci_init();
>> +    else
>> +        return acpi_pci_init();
>> +}
>> +__initcall(pci_init);
>> +
>> /*
>>  * Local variables:
>>  * mode: C
>> diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h
>> index ee7cff2d44..5ecd5e7bd1 100644
>> --- a/xen/include/asm-arm/device.h
>> +++ b/xen/include/asm-arm/device.h
>> @@ -34,6 +34,7 @@ enum device_class
>>     DEVICE_SERIAL,
>>     DEVICE_IOMMU,
>>     DEVICE_GIC,
>> +    DEVICE_PCI,
>>     /* Use for error */
>>     DEVICE_UNKNOWN,
>> };
>> -- 
>> 2.17.1




 


Rackspace

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