mbox series

[v1,0/5] PCI: Drop duplicated tracking of a pci_dev's bound driver

Message ID 20210729203740.1377045-1-u.kleine-koenig@pengutronix.de
Headers show
Series PCI: Drop duplicated tracking of a pci_dev's bound driver | expand

Message

Uwe Kleine-König July 29, 2021, 8:37 p.m. UTC
Hello,

struct pci_dev tracks the bound pci driver twice. This series is about
removing this duplication.

The first two patches are just cleanups. The third patch introduces a
wrapper that abstracts access to struct pci_dev->driver. In the next
patch (hopefully) all users are converted to use the new wrapper and
finally the fifth patch removes the duplication.

Note this series is only build tested (allmodconfig on several
architectures).

I'm open to restructure this series if this simplifies things. E.g. the
use of the new wrapper in drivers/pci could be squashed into the patch
introducing the wrapper. Patch 4 could be split by maintainer tree or
squashed into patch 3 completely.

Best regards
Uwe

Uwe Kleine-König (5):
  PCI: Simplify pci_device_remove()
  PCI: Drop useless check from pci_device_probe()
  PCI: Provide wrapper to access a pci_dev's bound driver
  PCI: Adapt all code locations to not use struct pci_dev::driver
    directly
  PCI: Drop duplicated tracking of a pci_dev's bound driver

 arch/powerpc/include/asm/ppc-pci.h            |  3 +-
 arch/powerpc/kernel/eeh_driver.c              | 12 +++--
 arch/x86/events/intel/uncore.c                |  2 +-
 arch/x86/kernel/probe_roms.c                  |  2 +-
 drivers/bcma/host_pci.c                       |  6 ++-
 drivers/crypto/hisilicon/qm.c                 |  2 +-
 drivers/crypto/qat/qat_common/adf_aer.c       |  2 +-
 drivers/message/fusion/mptbase.c              |  4 +-
 drivers/misc/cxl/guest.c                      | 21 ++++----
 drivers/misc/cxl/pci.c                        | 25 ++++++----
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    |  3 +-
 .../ethernet/marvell/prestera/prestera_pci.c  |  2 +-
 drivers/net/ethernet/mellanox/mlxsw/pci.c     |  2 +-
 .../ethernet/netronome/nfp/nfp_net_ethtool.c  |  2 +-
 drivers/pci/iov.c                             | 23 +++++----
 drivers/pci/pci-driver.c                      | 48 +++++++++----------
 drivers/pci/pci.c                             | 10 ++--
 drivers/pci/pcie/err.c                        | 35 +++++++-------
 drivers/pci/xen-pcifront.c                    |  4 +-
 drivers/ssb/pcihost_wrapper.c                 |  7 ++-
 drivers/usb/host/xhci-pci.c                   |  3 +-
 include/linux/pci.h                           |  2 +-
 22 files changed, 121 insertions(+), 99 deletions(-)


base-commit: 2734d6c1b1a089fb593ef6a23d4b70903526fe0c

Comments

Greg Kroah-Hartman July 30, 2021, 5:14 a.m. UTC | #1
On Thu, Jul 29, 2021 at 10:37:35PM +0200, Uwe Kleine-König wrote:
> Hello,

> 

> struct pci_dev tracks the bound pci driver twice. This series is about

> removing this duplication.

> 

> The first two patches are just cleanups. The third patch introduces a

> wrapper that abstracts access to struct pci_dev->driver. In the next

> patch (hopefully) all users are converted to use the new wrapper and

> finally the fifth patch removes the duplication.

> 

> Note this series is only build tested (allmodconfig on several

> architectures).

> 

> I'm open to restructure this series if this simplifies things. E.g. the

> use of the new wrapper in drivers/pci could be squashed into the patch

> introducing the wrapper. Patch 4 could be split by maintainer tree or

> squashed into patch 3 completely.

> 

> Best regards

> Uwe

> 

> Uwe Kleine-König (5):

>   PCI: Simplify pci_device_remove()

>   PCI: Drop useless check from pci_device_probe()

>   PCI: Provide wrapper to access a pci_dev's bound driver

>   PCI: Adapt all code locations to not use struct pci_dev::driver

>     directly

>   PCI: Drop duplicated tracking of a pci_dev's bound driver


Other than my objection to patch 5/5 lack of changelog, looks sane to
me:

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Andy Shevchenko July 30, 2021, 8:06 a.m. UTC | #2
On Thu, Jul 29, 2021 at 10:37:35PM +0200, Uwe Kleine-König wrote:
> Hello,

> 

> struct pci_dev tracks the bound pci driver twice. This series is about

> removing this duplication.

> 

> The first two patches are just cleanups. The third patch introduces a

> wrapper that abstracts access to struct pci_dev->driver. In the next

> patch (hopefully) all users are converted to use the new wrapper and

> finally the fifth patch removes the duplication.

> 

> Note this series is only build tested (allmodconfig on several

> architectures).

> 

> I'm open to restructure this series if this simplifies things. E.g. the

> use of the new wrapper in drivers/pci could be squashed into the patch

> introducing the wrapper. Patch 4 could be split by maintainer tree or

> squashed into patch 3 completely.


I see only patch 4 and this cover letter...

-- 
With Best Regards,
Andy Shevchenko
Boris Ostrovsky July 30, 2021, 8:37 p.m. UTC | #3
On 7/29/21 4:37 PM, Uwe Kleine-König wrote:

> --- a/drivers/pci/xen-pcifront.c

> +++ b/drivers/pci/xen-pcifront.c

> @@ -599,12 +599,12 @@ static pci_ers_result_t pcifront_common_process(int cmd,

>  	result = PCI_ERS_RESULT_NONE;

>  

>  	pcidev = pci_get_domain_bus_and_slot(domain, bus, devfn);

> -	if (!pcidev || !pcidev->driver) {

> +	pdrv = pci_driver_of_dev(pcidev);

> +	if (!pcidev || !pdrv) {



If pcidev is NULL we are dead by the time we reach 'if' statement.


-boris



>  		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");

>  		pci_dev_put(pcidev);

>  		return result;

>  	}

> -	pdrv = pcidev->driver;

>
Boris Ostrovsky Aug. 2, 2021, 1:06 p.m. UTC | #4
On 7/31/21 8:08 AM, Uwe Kleine-König wrote:
> Hello Boris,
>
> On Fri, Jul 30, 2021 at 04:37:31PM -0400, Boris Ostrovsky wrote:
>> On 7/29/21 4:37 PM, Uwe Kleine-König wrote:
>>> --- a/drivers/pci/xen-pcifront.c
>>> +++ b/drivers/pci/xen-pcifront.c
>>> @@ -599,12 +599,12 @@ static pci_ers_result_t pcifront_common_process(int cmd,
>>>  	result = PCI_ERS_RESULT_NONE;
>>>  
>>>  	pcidev = pci_get_domain_bus_and_slot(domain, bus, devfn);
>>> -	if (!pcidev || !pcidev->driver) {
>>> +	pdrv = pci_driver_of_dev(pcidev);
>>> +	if (!pcidev || !pdrv) {
>> If pcidev is NULL we are dead by the time we reach 'if' statement.
> Oh, you're right. So this needs something like:
>
> 	if (!pcidev || !(pdrv = pci_driver_of_dev(pcidev)))


Sure, that's fine. And while at it please also drop 'if (pdrv)' check below (it's not directly related to your change but is more noticeable now so since you are in that function anyway I'd appreciate if you could do that).


Thanks.

-boris


>
> or repeating the call to pci_driver_of_dev for each previous usage of
> pdev->driver.
>
> If there are no other preferences I'd got with the first approach for
> v2.
>
> Best regards and thanks for catching,
> Uwe
>