linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Read ID & Pointer from PCI Capabilities List in 1 call
@ 2015-04-02 21:10 Sean O. Stalley
  2015-04-09 22:12 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Sean O. Stalley @ 2015-04-02 21:10 UTC (permalink / raw)
  To: bhelgaas, linux-pci, linux-kernel; +Cc: Sean O. Stalley

Reading both fields at the same time lets us parse the
list with half the number of configspace reads.

Signed-off-by: Sean O. Stalley <sean.stalley@intel.com>
---
 drivers/pci/pci.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5e3c8e9..db7f3d6 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -145,19 +145,22 @@ static int __pci_find_next_cap_ttl(struct pci_bus *bus, unsigned int devfn,
 				   u8 pos, int cap, int *ttl)
 {
 	u8 id;
+	u16 ent;
+
+	pci_bus_read_config_byte(bus, devfn, pos, &pos);
 
 	while ((*ttl)--) {
-		pci_bus_read_config_byte(bus, devfn, pos, &pos);
 		if (pos < 0x40)
 			break;
 		pos &= ~3;
-		pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID,
-					 &id);
+		pci_bus_read_config_word(bus, devfn, pos, &ent);
+
+		id = ent & 0xff;
 		if (id == 0xff)
 			break;
 		if (id == cap)
 			return pos;
-		pos += PCI_CAP_LIST_NEXT;
+		pos = (ent >> 8);
 	}
 	return 0;
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Read ID & Pointer from PCI Capabilities List in 1 call
  2015-04-02 21:10 [PATCH] Read ID & Pointer from PCI Capabilities List in 1 call Sean O. Stalley
@ 2015-04-09 22:12 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2015-04-09 22:12 UTC (permalink / raw)
  To: Sean O. Stalley; +Cc: linux-pci, linux-kernel

On Thu, Apr 02, 2015 at 02:10:19PM -0700, Sean O. Stalley wrote:
> Reading both fields at the same time lets us parse the
> list with half the number of configspace reads.
> 
> Signed-off-by: Sean O. Stalley <sean.stalley@intel.com>

Applied to pci/misc for v4.1, thanks Sean!

> ---
>  drivers/pci/pci.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 5e3c8e9..db7f3d6 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -145,19 +145,22 @@ static int __pci_find_next_cap_ttl(struct pci_bus *bus, unsigned int devfn,
>  				   u8 pos, int cap, int *ttl)
>  {
>  	u8 id;
> +	u16 ent;
> +
> +	pci_bus_read_config_byte(bus, devfn, pos, &pos);
>  
>  	while ((*ttl)--) {
> -		pci_bus_read_config_byte(bus, devfn, pos, &pos);
>  		if (pos < 0x40)
>  			break;
>  		pos &= ~3;
> -		pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID,
> -					 &id);
> +		pci_bus_read_config_word(bus, devfn, pos, &ent);
> +
> +		id = ent & 0xff;
>  		if (id == 0xff)
>  			break;
>  		if (id == cap)
>  			return pos;
> -		pos += PCI_CAP_LIST_NEXT;
> +		pos = (ent >> 8);
>  	}
>  	return 0;
>  }
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-09 22:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-02 21:10 [PATCH] Read ID & Pointer from PCI Capabilities List in 1 call Sean O. Stalley
2015-04-09 22:12 ` Bjorn Helgaas

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).