linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-pci@vger.kernel.org,
	"Alexander Duyck" <alexanderduyck@fb.com>,
	oss-drivers@corigine.com, "Oliver O'Halloran" <oohall@gmail.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"Ido Schimmel" <idosch@nvidia.com>,
	"Rafał Miłecki" <zajec5@gmail.com>,
	"Jesse Brandeburg" <jesse.brandeburg@intel.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Yisen Zhuang" <yisen.zhuang@huawei.com>,
	"Uwe Kleine-König" <uwe@kleine-koenig.org>,
	"Vadym Kochan" <vkochan@marvell.com>,
	"Michael Buesch" <m@bues.ch>, "Jiri Pirko" <jiri@nvidia.com>,
	"Salil Mehta" <salil.mehta@huawei.com>,
	netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Taras Chornyi" <tchornyi@marvell.com>,
	"Zhou Wang" <wangzhou1@hisilicon.com>,
	linux-crypto@vger.kernel.org, kernel@pengutronix.de,
	"Simon Horman" <simon.horman@corigine.com>,
	"Paul Mackerras" <paulus@samba.org>,
	linuxppc-dev@lists.ozlabs.org,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH v4 4/8] PCI: replace pci_dev::driver usage that gets the driver name
Date: Tue, 28 Sep 2021 21:29:36 +0200	[thread overview]
Message-ID: <20210928192936.w5umyzivi4hs6q3r@pengutronix.de> (raw)
In-Reply-To: <20210928171759.GA704204@bhelgaas>

[-- Attachment #1: Type: text/plain, Size: 4812 bytes --]

Hello,

On Tue, Sep 28, 2021 at 12:17:59PM -0500, Bjorn Helgaas wrote:
> [+to Oliver, Russell for eeh_driver_name() question below]
> 
> On Mon, Sep 27, 2021 at 10:43:22PM +0200, Uwe Kleine-König wrote:
> > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > 
> > struct pci_dev::driver holds (apart from a constant offset) the same
> > data as struct pci_dev::dev->driver. With the goal to remove struct
> > pci_dev::driver to get rid of data duplication replace getting the
> > driver name by dev_driver_string() which implicitly makes use of struct
> > pci_dev::dev->driver.
> 
> When you repost to fix the build issue, can you capitalize the subject
> line to match the other?

Yes, sure.

> Also, would you mind using "pci_dev.driver" instead of
> "pci_dev::driver"?  AFAIK, the "::" operator is not actually part of
> C, so I think it's more confusing than useful.

pci_dev.driver doesn't work either in C because pci_dev is a type and
not a variable. This is probably subjective, but for me pci_dev.driver
looks definitively stranger than pci_dev::driver. And :: is at least not
unseen in the kernel commit logs. (git log --grep=::)
But if you insist I can change to .

> > diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h
> > index 2b9edbf6e929..e8f1795a2acf 100644
> > --- a/arch/powerpc/include/asm/ppc-pci.h
> > +++ b/arch/powerpc/include/asm/ppc-pci.h
> > @@ -57,7 +57,14 @@ void eeh_sysfs_remove_device(struct pci_dev *pdev);
> >  
> >  static inline const char *eeh_driver_name(struct pci_dev *pdev)
> >  {
> > -	return (pdev && pdev->driver) ? pdev->driver->name : "<null>";
> > +	if (pdev) {
> > +		const char *drvstr = dev_driver_string(&pdev->dev);
> > +
> > +		if (strcmp(drvstr, ""))
> > +			return drvstr;
> > +	}
> > +
> > +	return "<null>";
> 
> Can we just do this?
> 
>   if (pdev)
>     return dev_driver_string(&pdev->dev);
> 
>   return "<null>";

Works for me, too. It behaves a bit differerently than my suggestion
(which nearly behaves identical to the status quo), but only in some
degenerated cases.

> I think it's more complicated than it's worth to include a strcmp().
> It's possible this will change those error messages about "Might be
> infinite loop in %s driver", but that doesn't seem like a huge deal.
> 
> I moved Oliver to "to:" and added Russell in case they object.
> 
> >  }
> >  
> >  #endif /* CONFIG_EEH */
> > diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
> > index 69c10a7b7c61..0973022d4b13 100644
> > --- a/drivers/bcma/host_pci.c
> > +++ b/drivers/bcma/host_pci.c
> > @@ -175,9 +175,10 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
> >  	if (err)
> >  		goto err_kfree_bus;
> >  
> > -	name = dev_name(&dev->dev);
> > -	if (dev->driver && dev->driver->name)
> > -		name = dev->driver->name;
> > +	name = dev_driver_string(&dev->dev);
> > +	if (!strcmp(name, ""))
> > +		name = dev_name(&dev->dev);
> >  	err = pci_request_regions(dev, name);
> 
> Again seems more complicated than it's worth to me.  This is in the
> driver's .probe() method, so really_probe() has already set
> "dev->driver = drv", which means dev->driver is always set to
> &bcma_pci_bridge_driver here, and bcma_pci_bridge_driver.name is
> always "bcma-pci-bridge".
> 
> Almost all callers of pci_request_regions() just hardcode the driver
> name or use a DRV_NAME #define
> 
> So I think we should just do:
> 
>   err = pci_request_regions(dev, "bcma-pci-bridge");

Yes, looks right. I'd put this in a separate patch.

> >  	if (err)
> >  		goto err_pci_disable;
> > [...]
> > diff --git a/drivers/ssb/pcihost_wrapper.c b/drivers/ssb/pcihost_wrapper.c
> > index 410215c16920..4938ed5cfae5 100644
> > --- a/drivers/ssb/pcihost_wrapper.c
> > +++ b/drivers/ssb/pcihost_wrapper.c
> > @@ -78,9 +78,11 @@ static int ssb_pcihost_probe(struct pci_dev *dev,
> >  	err = pci_enable_device(dev);
> >  	if (err)
> >  		goto err_kfree_ssb;
> > -	name = dev_name(&dev->dev);
> > -	if (dev->driver && dev->driver->name)
> > -		name = dev->driver->name;
> > +
> > +	name = dev_driver_string(&dev->dev);
> > +	if (*name == '\0')
> > +		name = dev_name(&dev->dev);
> > +
> >  	err = pci_request_regions(dev, name);
> 
> Also seems like more trouble than it's worth.  This one is a little
> strange but is always called for either b43_pci_bridge_driver or
> b44_pci_driver, both of which have .name set, so I think we should
> simply do:
> 
>   err = pci_request_regions(dev, dev_driver_string(&dev->dev));

yes, agreed, too.

Best regards
Uwe

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-09-28 19:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 20:43 [PATCH v4 0/8] PCI: Drop duplicated tracking of a pci_dev's bound driver Uwe Kleine-König
2021-09-27 20:43 ` [PATCH v4 4/8] PCI: replace pci_dev::driver usage that gets the driver name Uwe Kleine-König
2021-09-28  8:28   ` Kalle Valo
2021-09-28 10:01   ` Simon Horman
2021-09-28 10:31     ` Uwe Kleine-König
2021-09-29  8:05       ` Simon Horman
2021-09-29  9:04         ` Uwe Kleine-König
2021-09-28 17:17   ` Bjorn Helgaas
2021-09-28 19:29     ` Uwe Kleine-König [this message]
2021-09-28 20:08       ` Bjorn Helgaas
2021-09-27 20:43 ` [PATCH v4 7/8] PCI: Replace pci_dev::driver usage by pci_dev::dev.driver Uwe Kleine-König
2021-09-27 20:59 ` [PATCH v4 0/8] PCI: Drop duplicated tracking of a pci_dev's bound driver Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210928192936.w5umyzivi4hs6q3r@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=alexanderduyck@fb.com \
    --cc=davem@davemloft.net \
    --cc=helgaas@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=idosch@nvidia.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=jiri@nvidia.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=m@bues.ch \
    --cc=netdev@vger.kernel.org \
    --cc=oohall@gmail.com \
    --cc=oss-drivers@corigine.com \
    --cc=paulus@samba.org \
    --cc=salil.mehta@huawei.com \
    --cc=simon.horman@corigine.com \
    --cc=tchornyi@marvell.com \
    --cc=uwe@kleine-koenig.org \
    --cc=vkochan@marvell.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=yisen.zhuang@huawei.com \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).