mbox series

[0/5] Add the pci_get_base_class() helper and use it

Message ID 20230825062714.6325-1-sui.jingfeng@linux.dev (mailing list archive)
Headers show
Series Add the pci_get_base_class() helper and use it | expand

Message

Sui Jingfeng Aug. 25, 2023, 6:27 a.m. UTC
From: Sui Jingfeng <suijingfeng@loongson.cn>

There is no function that can be used to get all PCI(e) devices in a
system by matching against its the PCI base class code only, while keep
the sub-class code and the programming interface ignored. Therefore, add
the pci_get_base_class() function to suit the need.

For example, if an application want to process all PCI(e) display devices
in a system, it can achieve such goal by writing the code as following:

    pdev = NULL;
    do {
        pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev);
        if (!pdev)
            break;

        do_something_for_pci_display_device(pdev);
    } while (1);

Sui Jingfeng (5):
  PCI: Add the pci_get_base_class() helper
  ALSA: hda/intel: Use pci_get_base_class() to reduce duplicated code
  drm/nouveau: Use pci_get_base_class() to reduce duplicated code
  drm/amdgpu: Use pci_get_base_class() to reduce duplicated code
  drm/radeon: Use pci_get_base_class() to reduce duplicated code

 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 11 +++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 20 ++++-----------
 drivers/gpu/drm/nouveau/nouveau_acpi.c   | 11 +++------
 drivers/gpu/drm/radeon/radeon_bios.c     | 20 ++++-----------
 drivers/pci/search.c                     | 31 ++++++++++++++++++++++++
 include/linux/pci.h                      |  5 ++++
 sound/pci/hda/hda_intel.c                | 16 ++++--------
 7 files changed, 59 insertions(+), 55 deletions(-)

Comments

Alex Deucher Aug. 25, 2023, 1:18 p.m. UTC | #1
[Public]

> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Sui
> Jingfeng
> Sent: Friday, August 25, 2023 2:27 AM
> To: Bjorn Helgaas <bhelgaas@google.com>
> Cc: alsa-devel@alsa-project.org; Sui Jingfeng <suijingfeng@loongson.cn>;
> nouveau@lists.freedesktop.org; linux-kernel@vger.kernel.org; dri-
> devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; linux-
> pci@vger.kernel.org
> Subject: [PATCH 0/5] Add the pci_get_base_class() helper and use it
>
> From: Sui Jingfeng <suijingfeng@loongson.cn>
>
> There is no function that can be used to get all PCI(e) devices in a system by
> matching against its the PCI base class code only, while keep the sub-class code
> and the programming interface ignored. Therefore, add the
> pci_get_base_class() function to suit the need.
>
> For example, if an application want to process all PCI(e) display devices in a
> system, it can achieve such goal by writing the code as following:
>
>     pdev = NULL;
>     do {
>         pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev);
>         if (!pdev)
>             break;
>
>         do_something_for_pci_display_device(pdev);
>     } while (1);
>
> Sui Jingfeng (5):
>   PCI: Add the pci_get_base_class() helper
>   ALSA: hda/intel: Use pci_get_base_class() to reduce duplicated code
>   drm/nouveau: Use pci_get_base_class() to reduce duplicated code
>   drm/amdgpu: Use pci_get_base_class() to reduce duplicated code
>   drm/radeon: Use pci_get_base_class() to reduce duplicated code
>

Series is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

>  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 11 +++------
> drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 20 ++++-----------
>  drivers/gpu/drm/nouveau/nouveau_acpi.c   | 11 +++------
>  drivers/gpu/drm/radeon/radeon_bios.c     | 20 ++++-----------
>  drivers/pci/search.c                     | 31 ++++++++++++++++++++++++
>  include/linux/pci.h                      |  5 ++++
>  sound/pci/hda/hda_intel.c                | 16 ++++--------
>  7 files changed, 59 insertions(+), 55 deletions(-)
>
> --
> 2.34.1
Sui Jingfeng Sept. 20, 2023, 2:46 a.m. UTC | #2
Hi,


On 2023/8/25 21:18, Deucher, Alexander wrote:
> [Public]
>
>> -----Original Message-----
>> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Sui
>> Jingfeng
>> Sent: Friday, August 25, 2023 2:27 AM
>> To: Bjorn Helgaas <bhelgaas@google.com>
>> Cc: alsa-devel@alsa-project.org; Sui Jingfeng <suijingfeng@loongson.cn>;
>> nouveau@lists.freedesktop.org; linux-kernel@vger.kernel.org; dri-
>> devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; linux-
>> pci@vger.kernel.org
>> Subject: [PATCH 0/5] Add the pci_get_base_class() helper and use it
>>
>> From: Sui Jingfeng <suijingfeng@loongson.cn>
>>
>> There is no function that can be used to get all PCI(e) devices in a system by
>> matching against its the PCI base class code only, while keep the sub-class code
>> and the programming interface ignored. Therefore, add the
>> pci_get_base_class() function to suit the need.
>>
>> For example, if an application want to process all PCI(e) display devices in a
>> system, it can achieve such goal by writing the code as following:
>>
>>      pdev = NULL;
>>      do {
>>          pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev);
>>          if (!pdev)
>>              break;
>>
>>          do_something_for_pci_display_device(pdev);
>>      } while (1);
>>
>> Sui Jingfeng (5):
>>    PCI: Add the pci_get_base_class() helper
>>    ALSA: hda/intel: Use pci_get_base_class() to reduce duplicated code
>>    drm/nouveau: Use pci_get_base_class() to reduce duplicated code
>>    drm/amdgpu: Use pci_get_base_class() to reduce duplicated code
>>    drm/radeon: Use pci_get_base_class() to reduce duplicated code
>>
> Series is:
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

Thanks a lot.


What to do next then?

By the way, Bjorn, what's your opinion?
I'm ask because I don't know what to do next with this series.

As they belong to different system of Linux kernel,
the rest of patch (0002 ~ 0005) depend on the first one.

I think, merge the 0001-patch firstly, then wait it arrive at drm-misc, alsa branch.
Or, to do something else?
Bjorn Helgaas Sept. 28, 2023, 9:56 p.m. UTC | #3
On Fri, Aug 25, 2023 at 02:27:09PM +0800, Sui Jingfeng wrote:
> From: Sui Jingfeng <suijingfeng@loongson.cn>
> 
> There is no function that can be used to get all PCI(e) devices in a
> system by matching against its the PCI base class code only, while keep
> the sub-class code and the programming interface ignored. Therefore, add
> the pci_get_base_class() function to suit the need.
> 
> For example, if an application want to process all PCI(e) display devices
> in a system, it can achieve such goal by writing the code as following:
> 
>     pdev = NULL;
>     do {
>         pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev);
>         if (!pdev)
>             break;
> 
>         do_something_for_pci_display_device(pdev);
>     } while (1);
> 
> Sui Jingfeng (5):
>   PCI: Add the pci_get_base_class() helper
>   ALSA: hda/intel: Use pci_get_base_class() to reduce duplicated code
>   drm/nouveau: Use pci_get_base_class() to reduce duplicated code
>   drm/amdgpu: Use pci_get_base_class() to reduce duplicated code
>   drm/radeon: Use pci_get_base_class() to reduce duplicated code
> 
>  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 11 +++------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 20 ++++-----------
>  drivers/gpu/drm/nouveau/nouveau_acpi.c   | 11 +++------
>  drivers/gpu/drm/radeon/radeon_bios.c     | 20 ++++-----------
>  drivers/pci/search.c                     | 31 ++++++++++++++++++++++++
>  include/linux/pci.h                      |  5 ++++
>  sound/pci/hda/hda_intel.c                | 16 ++++--------
>  7 files changed, 59 insertions(+), 55 deletions(-)

Applied to pci/enumeration for v6.7, thanks.