lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de>
Date:   Mon,  4 Oct 2021 14:59:24 +0200
From:   Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>
To:     Bjorn Helgaas <helgaas@...nel.org>
Cc:     linux-pci@...r.kernel.org, kernel@...gutronix.de,
        Alexander Duyck <alexanderduyck@...com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Andrew Donnellan <ajd@...ux.ibm.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Arnd Bergmann <arnd@...db.de>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Borislav Petkov <bp@...en8.de>,
        Boris Ostrovsky <boris.ostrovsky@...cle.com>,
        "David S. Miller" <davem@...emloft.net>,
        Fiona Trahe <fiona.trahe@...el.com>,
        Frederic Barrat <fbarrat@...ux.ibm.com>,
        Giovanni Cabiddu <giovanni.cabiddu@...el.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        "H. Peter Anvin" <hpa@...or.com>, Ido Schimmel <idosch@...dia.com>,
        Ingo Molnar <mingo@...hat.com>, Jack Xu <jack.xu@...el.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Jesse Brandeburg <jesse.brandeburg@...el.com>,
        Jiri Olsa <jolsa@...hat.com>, Jiri Pirko <jiri@...dia.com>,
        Juergen Gross <jgross@...e.com>,
        Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
        Marco Chiappero <marco.chiappero@...el.com>,
        Mark Rutland <mark.rutland@....com>,
        Mathias Nyman <mathias.nyman@...el.com>,
        Michael Buesch <m@...s.ch>,
        Michael Ellerman <mpe@...erman.id.au>,
        Namhyung Kim <namhyung@...nel.org>,
        "Oliver O'Halloran" <oohall@...il.com>,
        Paul Mackerras <paulus@...ba.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Rafał Miłecki <zajec5@...il.com>,
        Russell Currey <ruscur@...sell.cc>,
        Salil Mehta <salil.mehta@...wei.com>,
        Sathya Prakash <sathya.prakash@...adcom.com>,
        Simon Horman <simon.horman@...igine.com>,
        Sreekanth Reddy <sreekanth.reddy@...adcom.com>,
        Stefano Stabellini <sstabellini@...nel.org>,
        Suganath Prabu Subramani 
        <suganath-prabu.subramani@...adcom.com>,
        Taras Chornyi <tchornyi@...vell.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Tomaszx Kowalik <tomaszx.kowalik@...el.com>,
        Vadym Kochan <vkochan@...vell.com>,
        Wojciech Ziemba <wojciech.ziemba@...el.com>,
        Yisen Zhuang <yisen.zhuang@...wei.com>,
        Zhou Wang <wangzhou1@...ilicon.com>,
        linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-perf-users@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
        linux-scsi@...r.kernel.org, linux-usb@...r.kernel.org,
        linux-wireless@...r.kernel.org, MPT-FusionLinux.pdl@...adcom.com,
        netdev@...r.kernel.org, oss-drivers@...igine.com,
        qat-linux@...el.com, x86@...nel.org, xen-devel@...ts.xenproject.org
Subject: [PATCH v6 00/11] PCI: Drop duplicated tracking of a pci_dev's bound driver

Hello,

this is v6 of the quest to drop the "driver" member from struct pci_dev
which tracks the same data (apart from a constant offset) as dev.driver.

Changes since v5:
 - Some Acks added
 - Some fixes in "PCI: Replace pci_dev::driver usage by
   pci_dev::dev.driver" to properly handle that
   to_pci_driver(X) is wrong if X is NULL.
   This should fix the problem reported by Ido Schimmel.

Full range diff below.

This patch stack survived an allmodconfig build on arm64, m68k, powerpc,
riscv, s390, sparc64 and x86_64 on top of v5.15-rc3.

Best regards
Uwe

Uwe Kleine-König (11):
  PCI: Simplify pci_device_remove()
  PCI: Drop useless check from pci_device_probe()
  xen/pci: Drop some checks that are always true
  bcma: simplify reference to the driver's name
  powerpc/eeh: Don't use driver member of struct pci_dev and further
    cleanups
  ssb: Simplify determination of driver name
  PCI: Replace pci_dev::driver usage that gets the driver name
  scsi: message: fusion: Remove unused parameter of mpt_pci driver's
    probe()
  crypto: qat - simplify adf_enable_aer()
  PCI: Replace pci_dev::driver usage by pci_dev::dev.driver
  PCI: Drop duplicated tracking of a pci_dev's bound driver

 arch/powerpc/include/asm/ppc-pci.h            |  5 -
 arch/powerpc/kernel/eeh.c                     |  8 ++
 arch/powerpc/kernel/eeh_driver.c              | 10 +-
 arch/x86/events/intel/uncore.c                |  2 +-
 arch/x86/kernel/probe_roms.c                  | 10 +-
 drivers/bcma/host_pci.c                       |  6 +-
 drivers/crypto/hisilicon/qm.c                 |  2 +-
 drivers/crypto/qat/qat_4xxx/adf_drv.c         |  7 +-
 drivers/crypto/qat/qat_c3xxx/adf_drv.c        |  7 +-
 drivers/crypto/qat/qat_c62x/adf_drv.c         |  7 +-
 drivers/crypto/qat/qat_common/adf_aer.c       | 10 +-
 .../crypto/qat/qat_common/adf_common_drv.h    |  3 +-
 drivers/crypto/qat/qat_dh895xcc/adf_drv.c     |  7 +-
 drivers/message/fusion/mptbase.c              |  7 +-
 drivers/message/fusion/mptbase.h              |  2 +-
 drivers/message/fusion/mptctl.c               |  4 +-
 drivers/message/fusion/mptlan.c               |  2 +-
 drivers/misc/cxl/guest.c                      | 24 +++--
 drivers/misc/cxl/pci.c                        | 30 +++---
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    |  2 +-
 .../ethernet/marvell/prestera/prestera_pci.c  |  2 +-
 drivers/net/ethernet/mellanox/mlxsw/pci.c     |  2 +-
 .../ethernet/netronome/nfp/nfp_net_ethtool.c  |  3 +-
 drivers/pci/iov.c                             | 33 +++++--
 drivers/pci/pci-driver.c                      | 96 ++++++++++---------
 drivers/pci/pci.c                             |  4 +-
 drivers/pci/pcie/err.c                        | 36 +++----
 drivers/pci/xen-pcifront.c                    | 63 ++++++------
 drivers/ssb/pcihost_wrapper.c                 |  6 +-
 drivers/usb/host/xhci-pci.c                   |  2 +-
 include/linux/pci.h                           |  1 -
 31 files changed, 208 insertions(+), 195 deletions(-)

Range-diff against v5:
 -:  ------------ >  1:  c2b53ab26a6b PCI: Simplify pci_device_remove()
 -:  ------------ >  2:  2c733e1d5186 PCI: Drop useless check from pci_device_probe()
 -:  ------------ >  3:  547ca5a7aa16 xen/pci: Drop some checks that are always true
 -:  ------------ >  4:  40eb07353844 bcma: simplify reference to the driver's name
 -:  ------------ >  5:  bab59c1dff6d powerpc/eeh: Don't use driver member of struct pci_dev and further cleanups
 1:  abd70de9782d !  6:  92f4d61bbac3 ssb: Simplify determination of driver name
    @@ Commit message
         This has the upside of not requiring the driver member of struct pci_dev
         which is about to be removed and being simpler.
     
    +    Acked-by: Michael Büsch <m@...s.ch>
         Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
     
      ## drivers/ssb/pcihost_wrapper.c ##
 2:  735845bd26b9 !  7:  6303f03ab2aa PCI: Replace pci_dev::driver usage that gets the driver name
    @@ Commit message
         driver name by dev_driver_string() which implicitly makes use of struct
         pci_dev::dev->driver.
     
    +    Acked-by: Simon Horman <simon.horman@...igine.com> (for NFP)
         Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
     
      ## drivers/crypto/hisilicon/qm.c ##
 3:  1e58019165b9 =  8:  658a6c00ec96 scsi: message: fusion: Remove unused parameter of mpt_pci driver's probe()
 4:  dea72a470141 =  9:  aceaf5321603 crypto: qat - simplify adf_enable_aer()
 5:  b4165dda38ea ! 10:  80648d999985 PCI: Replace pci_dev::driver usage by pci_dev::dev.driver
    @@ arch/x86/kernel/probe_roms.c: static struct resource video_rom_resource = {
      static bool match_id(struct pci_dev *pdev, unsigned short vendor, unsigned short device)
      {
     -	struct pci_driver *drv = pdev->driver;
    -+	struct pci_driver *drv = to_pci_driver(pdev->dev.driver);
      	const struct pci_device_id *id;
      
      	if (pdev->vendor == vendor && pdev->device == device)
    + 		return true;
    + 
    +-	for (id = drv ? drv->id_table : NULL; id && id->vendor; id++)
    +-		if (id->vendor == vendor && id->device == device)
    +-			break;
    ++	if (pdev->dev.driver) {
    ++		struct pci_driver *drv = to_pci_driver(pdev->dev.driver);
    ++		for (id = drv->id_table; id && id->vendor; id++)
    ++			if (id->vendor == vendor && id->device == device)
    ++				break;
    ++	}
    + 
    + 	return id && id->vendor;
    + }
     
      ## drivers/misc/cxl/guest.c ##
     @@ drivers/misc/cxl/guest.c: static void pci_error_handlers(struct cxl_afu *afu,
    @@ drivers/pci/iov.c: static ssize_t sriov_vf_total_msix_show(struct device *dev,
      
      	device_lock(dev);
     -	if (!pdev->driver || !pdev->driver->sriov_get_vf_total_msix)
    -+	pdrv = to_pci_driver(dev->driver);
    -+	if (!pdrv || !pdrv->sriov_get_vf_total_msix)
    ++	if (!dev->driver)
      		goto unlock;
      
     -	vf_total_msix = pdev->driver->sriov_get_vf_total_msix(pdev);
    ++	pdrv = to_pci_driver(dev->driver);
    ++	if (!pdrv->sriov_get_vf_total_msix)
    ++		goto unlock;
    ++
     +	vf_total_msix = pdrv->sriov_get_vf_total_msix(pdev);
      unlock:
      	device_unlock(dev);
    @@ drivers/pci/iov.c: static ssize_t sriov_vf_msix_count_store(struct device *dev,
      
      	device_lock(&pdev->dev);
     -	if (!pdev->driver || !pdev->driver->sriov_set_msix_vec_count) {
    ++	if (!pdev->dev.driver) {
    ++		ret = -EOPNOTSUPP;
    ++		goto err_pdev;
    ++	}
    ++
     +	pdrv = to_pci_driver(pdev->dev.driver);
    -+	if (!pdrv || !pdrv->sriov_set_msix_vec_count) {
    ++	if (!pdrv->sriov_set_msix_vec_count) {
      		ret = -EOPNOTSUPP;
      		goto err_pdev;
      	}
    @@ drivers/pci/pci-driver.c: static void pci_device_remove(struct device *dev)
      {
      	struct pci_dev *pci_dev = to_pci_dev(dev);
     -	struct pci_driver *drv = pci_dev->driver;
    -+	struct pci_driver *drv = to_pci_driver(pci_dev->dev.driver);
      
      	pm_runtime_resume(dev);
      
    +-	if (drv && drv->shutdown)
    +-		drv->shutdown(pci_dev);
    ++	if (pci_dev->dev.driver) {
    ++		struct pci_driver *drv = to_pci_driver(pci_dev->dev.driver);
    ++
    ++		if (drv->shutdown)
    ++			drv->shutdown(pci_dev);
    ++	}
    + 
    + 	/*
    + 	 * If this is a kexec reboot, turn off Bus Master bit on the
     @@ drivers/pci/pci-driver.c: static int pci_pm_reenable_device(struct pci_dev *pci_dev)
      static int pci_legacy_suspend(struct device *dev, pm_message_t state)
      {
      	struct pci_dev *pci_dev = to_pci_dev(dev);
     -	struct pci_driver *drv = pci_dev->driver;
    -+	struct pci_driver *drv = to_pci_driver(dev->driver);
      
    - 	if (drv && drv->suspend) {
    - 		pci_power_t prev = pci_dev->current_state;
    +-	if (drv && drv->suspend) {
    +-		pci_power_t prev = pci_dev->current_state;
    +-		int error;
    ++	if (dev->driver) {
    ++		struct pci_driver *drv = to_pci_driver(dev->driver);
    + 
    +-		error = drv->suspend(pci_dev, state);
    +-		suspend_report_result(drv->suspend, error);
    +-		if (error)
    +-			return error;
    ++		if (drv->suspend) {
    ++			pci_power_t prev = pci_dev->current_state;
    ++			int error;
    + 
    +-		if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
    +-		    && pci_dev->current_state != PCI_UNKNOWN) {
    +-			pci_WARN_ONCE(pci_dev, pci_dev->current_state != prev,
    +-				      "PCI PM: Device state not saved by %pS\n",
    +-				      drv->suspend);
    ++			error = drv->suspend(pci_dev, state);
    ++			suspend_report_result(drv->suspend, error);
    ++			if (error)
    ++				return error;
    ++
    ++			if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
    ++			    && pci_dev->current_state != PCI_UNKNOWN) {
    ++				pci_WARN_ONCE(pci_dev, pci_dev->current_state != prev,
    ++					      "PCI PM: Device state not saved by %pS\n",
    ++					      drv->suspend);
    ++			}
    + 		}
    + 	}
    + 
     @@ drivers/pci/pci-driver.c: static int pci_legacy_suspend_late(struct device *dev, pm_message_t state)
      static int pci_legacy_resume(struct device *dev)
      {
      	struct pci_dev *pci_dev = to_pci_dev(dev);
     -	struct pci_driver *drv = pci_dev->driver;
    -+	struct pci_driver *drv = to_pci_driver(pci_dev->dev.driver);
      
      	pci_fixup_device(pci_fixup_resume, pci_dev);
      
    +-	return drv && drv->resume ?
    +-			drv->resume(pci_dev) : pci_pm_reenable_device(pci_dev);
    ++	if (pci_dev->dev.driver) {
    ++		struct pci_driver *drv = to_pci_driver(pci_dev->dev.driver);
    ++
    ++		if (drv->resume)
    ++			return drv->resume(pci_dev);
    ++	}
    ++
    ++	return pci_pm_reenable_device(pci_dev);
    + }
    + 
    + /* Auxiliary functions used by the new power management framework */
     @@ drivers/pci/pci-driver.c: static void pci_pm_default_suspend(struct pci_dev *pci_dev)
      
      static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
      {
     -	struct pci_driver *drv = pci_dev->driver;
    -+	struct pci_driver *drv = to_pci_driver(pci_dev->dev.driver);
    - 	bool ret = drv && (drv->suspend || drv->resume);
    +-	bool ret = drv && (drv->suspend || drv->resume);
    ++	struct pci_driver *drv;
    ++	bool ret;
    ++
    ++	if (!pci_dev->dev.driver)
    ++		return false;
    ++
    ++	drv = to_pci_driver(pci_dev->dev.driver);
    ++	ret = drv && (drv->suspend || drv->resume);
      
      	/*
    + 	 * Legacy PM support is used by default, so warn if the new framework is
     @@ drivers/pci/pci-driver.c: static int pci_pm_runtime_suspend(struct device *dev)
      	int error;
      
 6:  d93a138bd7ab = 11:  2686d69bca17 PCI: Drop duplicated tracking of a pci_dev's bound driver

base-commit: 5816b3e6577eaa676ceb00a848f0fd65fe2adc29
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ