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-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 7 Aug 2021 11:26:45 +0200
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Bjorn Helgaas <helgaas@...nel.org>
Cc:     Mark Rutland <mark.rutland@....com>,
        Giovanni Cabiddu <giovanni.cabiddu@...el.com>,
        Rafał Miłecki <zajec5@...il.com>,
        Peter Zijlstra <peterz@...radead.org>,
        linux-pci@...r.kernel.org, Alexander Duyck <alexanderduyck@...com>,
        Russell Currey <ruscur@...sell.cc>, x86@...nel.org,
        oss-drivers@...igine.com, netdev@...r.kernel.org,
        Paul Mackerras <paulus@...ba.org>,
        "H. Peter Anvin" <hpa@...or.com>, Jiri Olsa <jolsa@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Taras Chornyi <tchornyi@...vell.com>,
        Stefano Stabellini <sstabellini@...nel.org>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        linux-scsi@...r.kernel.org, Michael Ellerman <mpe@...erman.id.au>,
        Sathya Prakash <sathya.prakash@...adcom.com>,
        qat-linux@...el.com,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Ingo Molnar <mingo@...hat.com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Jakub Kicinski <kuba@...nel.org>,
        Yisen Zhuang <yisen.zhuang@...wei.com>,
        Suganath Prabu Subramani 
        <suganath-prabu.subramani@...adcom.com>,
        Fiona Trahe <fiona.trahe@...el.com>,
        Oliver O'Halloran <oohall@...il.com>,
        Andrew Donnellan <ajd@...ux.ibm.com>,
        Mathias Nyman <mathias.nyman@...el.com>,
        Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
        Ido Schimmel <idosch@...dia.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Frederic Barrat <fbarrat@...ux.ibm.com>,
        Borislav Petkov <bp@...en8.de>, Michael Buesch <m@...s.ch>,
        Jiri Pirko <jiri@...dia.com>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Boris Ostrovsky <boris.ostrovsky@...cle.com>,
        Andy Shevchenko <andriy.shevchenko@...el.com>,
        Juergen Gross <jgross@...e.com>,
        Salil Mehta <salil.mehta@...wei.com>,
        Sreekanth Reddy <sreekanth.reddy@...adcom.com>,
        xen-devel@...ts.xenproject.org, Vadym Kochan <vkochan@...vell.com>,
        MPT-FusionLinux.pdl@...adcom.com, linux-usb@...r.kernel.org,
        linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-perf-users@...r.kernel.org,
        Zhou Wang <wangzhou1@...ilicon.com>,
        Arnd Bergmann <arnd@...db.de>, linux-crypto@...r.kernel.org,
        kernel@...gutronix.de,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Simon Horman <simon.horman@...igine.com>,
        Wojciech Ziemba <wojciech.ziemba@...el.com>,
        linuxppc-dev@...ts.ozlabs.org,
        "David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH v2 0/6] PCI: Drop duplicated tracking of a pci_dev's
 bound driver

On Fri, Aug 06, 2021 at 04:24:52PM -0500, Bjorn Helgaas wrote:
> On Fri, Aug 06, 2021 at 08:46:23AM +0200, Uwe Kleine-König wrote:
> > On Thu, Aug 05, 2021 at 06:42:34PM -0500, Bjorn Helgaas wrote:
> 
> > > I looked at all the bus_type.probe() methods, it looks like pci_dev is
> > > not the only offender here.  At least the following also have a driver
> > > pointer in the device struct:
> > > 
> > >   parisc_device.driver
> > >   acpi_device.driver
> > >   dio_dev.driver
> > >   hid_device.driver
> > >   pci_dev.driver
> > >   pnp_dev.driver
> > >   rio_dev.driver
> > >   zorro_dev.driver
> > 
> > Right, when I converted zorro_dev it was pointed out that the code was
> > copied from pci and the latter has the same construct. :-)
> > See
> > https://lore.kernel.org/r/20210730191035.1455248-5-u.kleine-koenig@pengutronix.de
> > for the patch, I don't find where pci was pointed out, maybe it was on
> > irc only.
> 
> Oh, thanks!  I looked to see if you'd done something similar
> elsewhere, but I missed this one.
> 
> > > Looking through the places that care about pci_dev.driver (the ones
> > > updated by patch 5/6), many of them are ... a little dubious to begin
> > > with.  A few need the "struct pci_error_handlers *err_handler"
> > > pointer, so that's probably legitimate.  But many just need a name,
> > > and should probably be using dev_driver_string() instead.
> > 
> > Yeah, I considered adding a function to get the driver name from a
> > pci_dev and a function to get the error handlers. Maybe it's an idea to
> > introduce these two and then use to_pci_driver(pdev->dev.driver) for the
> > few remaining users? Maybe doing that on top of my current series makes
> > sense to have a clean switch from pdev->driver to pdev->dev.driver?!
> 
> I'd propose using dev_driver_string() for these places:
> 
>   eeh_driver_name() (could change callers to use dev_driver_string())
>   bcma_host_pci_probe()
>   qm_alloc_uacce()
>   hns3_get_drvinfo()
>   prestera_pci_probe()
>   mlxsw_pci_probe()
>   nfp_get_drvinfo()
>   ssb_pcihost_probe()

So the idea is:

	PCI: Simplify pci_device_remove()
	PCI: Drop useless check from pci_device_probe()
	xen/pci: Drop some checks that are always true

are kept as is as preparation. (Do you want to take them from this v2,
or should I include them again in v3?)

Then convert the list of functions above to use dev_driver_string() in a
4th patch.

> The use in mpt_device_driver_register() looks unnecessary: it's only
> to get a struct pci_device_id *, which is passed to ->probe()
> functions that don't need it.

This is patch #5.

> The use in adf_enable_aer() looks wrong: it sets the err_handler
> pointer in one of the adf_driver structs.  I think those structs
> should be basically immutable, and the drivers that call
> adf_enable_aer() from their .probe() methods should set
> ".err_handler = &adf_err_handler" in their static adf_driver
> definitions instead.

I don't understand that one without some research, probably this yields
at least one patch.

> I think that basically leaves these:
> 
>   uncore_pci_probe()     # .id_table, custom driver "registration"
>   match_id()             # .id_table, arch/x86/kernel/probe_roms.c
>   xhci_pci_quirks()      # .id_table
>   pci_error_handlers()   # roll-your-own AER handling, drivers/misc/cxl/guest.c
> 
> I think it would be fine to use to_pci_driver(pdev->dev.driver) for
> these few.

Converting these will be patch 7 then and patch 8 can then drop the
duplicated handling.

Sounds reasonable?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ