diff mbox

[30/30] PCI: remove pci_get_bus_and_slot() function

Message ID 1511328675-21981-31-git-send-email-okaya@codeaurora.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sinan Kaya Nov. 22, 2017, 5:31 a.m. UTC
pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as
where a PCI device is present. This restricts the device drivers to be
reused for other domain numbers.

Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't
extract the domain number. Other places, use the actual domain number from
the device.

Now that all users of pci_get_bus_and_slot() switched to
pci_get_domain_bus_and_slot(), it is now safe to remove this function.

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 include/linux/pci.h | 8 --------
 1 file changed, 8 deletions(-)

Comments

Greg KH Nov. 22, 2017, 7:51 a.m. UTC | #1
On Wed, Nov 22, 2017 at 12:08:45AM -0600, Timur Tabi wrote:
> On 11/21/17 11:55 PM, Sinan Kaya wrote:
> > For places where domain number information is available, I extracted domain number
> > and added into pci_get_domain_bus_and_slot() call such as xen or bn drivers.
> 
> My suggestion is that you restrict your first patch set to only these
> patches.
> 
> > The assumption at this point is for pci_get_bus_and_slot() usages to be caught
> > in code-review.
> 
> How about this:
> 
> static inline struct pci_dev * __deprecated pci_get_bus_and_slot(unsigned
> int bus,
> 						   unsigned int devfn)
> {
> 	return pci_get_domain_bus_and_slot(0, bus, devfn);
> }

Ick, no, why?  What is wrong with removing this function as is?  Don't
mark something as __depreciated if there are no in-kernel users, just
delete it and move on.

If you have out-of-tree drivers, then yes, they can make a wrapper for
this function like this if they really feel the need, or they can get
their code merged :)

thanks,

greg k-h
Timur Tabi Nov. 22, 2017, 2:42 p.m. UTC | #2
On 11/22/17 1:51 AM, Greg KH wrote:
> Ick, no, why?  What is wrong with removing this function as is?  Don't
> mark something as __depreciated if there are no in-kernel users, just
> delete it and move on.
> 
> If you have out-of-tree drivers, then yes, they can make a wrapper for
> this function like this if they really feel the need, or they can get
> their code merged:)

Sorry, I guess I should have been clearer.  My suggestion was to fix 
some of the drivers where the domain can be determined, and for the 
rest, just mark the old function as deprecated.

If that's still a terrible idea, well, okay.  I'm just unsure that 
simply hard-coding a 0 for the domain for some drivers is really a 
solution.  Don't we really want all drivers to properly support all domains?
Greg KH Nov. 22, 2017, 2:49 p.m. UTC | #3
On Wed, Nov 22, 2017 at 08:42:35AM -0600, Timur Tabi wrote:
> On 11/22/17 1:51 AM, Greg KH wrote:
> > Ick, no, why?  What is wrong with removing this function as is?  Don't
> > mark something as __depreciated if there are no in-kernel users, just
> > delete it and move on.
> > 
> > If you have out-of-tree drivers, then yes, they can make a wrapper for
> > this function like this if they really feel the need, or they can get
> > their code merged:)
> 
> Sorry, I guess I should have been clearer.  My suggestion was to fix some of
> the drivers where the domain can be determined, and for the rest, just mark
> the old function as deprecated.

So the build now gets warnings?  That's annoying, and then someone else
will have to make the exact same patches that were created here?

> If that's still a terrible idea, well, okay.  I'm just unsure that simply
> hard-coding a 0 for the domain for some drivers is really a solution.  Don't
> we really want all drivers to properly support all domains?

I bet all of those drivers don't care because they are running only in
systems with 1 domain, otherwise they would be broken today, right?  But
really, it shouldn't be that hard to get to the "real" PCI device to
provide the correct pointer to the domain for most of these, as I
pointed out in one patch review already.

thanks,

greg k-h
Sinan Kaya Nov. 22, 2017, 3:18 p.m. UTC | #4
On 11/22/2017 9:49 AM, Greg KH wrote:
>>> If you have out-of-tree drivers, then yes, they can make a wrapper for
>>> this function like this if they really feel the need, or they can get
>>> their code merged:)
>> Sorry, I guess I should have been clearer.  My suggestion was to fix some of
>> the drivers where the domain can be determined, and for the rest, just mark
>> the old function as deprecated.
> So the build now gets warnings?  That's annoying, and then someone else
> will have to make the exact same patches that were created here?
> 
>> If that's still a terrible idea, well, okay.  I'm just unsure that simply
>> hard-coding a 0 for the domain for some drivers is really a solution.  Don't
>> we really want all drivers to properly support all domains?
> I bet all of those drivers don't care because they are running only in
> systems with 1 domain, otherwise they would be broken today, right?  But
> really, it shouldn't be that hard to get to the "real" PCI device to
> provide the correct pointer to the domain for most of these, as I
> pointed out in one patch review already.

I agree. Point is 95% drivers do support multiple segments. These are the
exceptions. 

We should try to fix them as much as we can. (I'll take a look at Greg's
suggestion)

In the end, this API is a backdoor and workarounds the proper APIs and
usual practices like carrying struct pci_dev pointer.

I'm trying to shoot that API in the foot so that a developer thinks twice
before putting number 0 there.
diff mbox

Patch

diff --git a/include/linux/pci.h b/include/linux/pci.h
index d16a7c0..8c1b650 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -957,11 +957,6 @@  struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
 struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
 struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 					    unsigned int devfn);
-static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
-						   unsigned int devfn)
-{
-	return pci_get_domain_bus_and_slot(0, bus, devfn);
-}
 struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
 int pci_dev_present(const struct pci_device_id *ids);
 
@@ -1676,9 +1671,6 @@  static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
 						unsigned int devfn)
 { return NULL; }
-static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
-						unsigned int devfn)
-{ return NULL; }
 
 static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
 static inline struct pci_dev *pci_dev_get(struct pci_dev *dev) { return NULL; }