public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pci-e: ignore unknown capability and continue searching
@ 2008-09-30  4:29 Zhang, Yanmin
  2008-10-03  8:21 ` Zhang, Yanmin
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang, Yanmin @ 2008-09-30  4:29 UTC (permalink / raw)
  To: Greg KH, jbarnes; +Cc: LKML, czernecki

Subject: pci-e: ignore unknown capability and continue searching
From: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>


Tomasz reported AER driver couldn't work on his machine. With the output
of "lcpsi -vvv", I found the root port's extended capabilities are
         Capabilities: [100] Unknown (11)
         Capabilities: [150] Advanced Error Reporting
         Capabilities: [190] Unknown (13)
Such Unknown capability is not expected. During pci-e initialization,function
get_port_device_capability just returns if it hits an unknown capability when
searching the AER capability.

I worked out a patch against 2.6.27-rc7. When hitting an unkown capability,
function get_port_device_capability continues the searching.

Tomasz tested it and the patch does work well.

Signed-off-by Zhang Yanmin <yanmin.zhang@linux.intel.com>
Reported-by Tomasz Czernecki <czernecki@gmail.com>

---

--- linux-2.6.27-rc7/drivers/pci/pcie/portdrv_core.c	2008-09-27 09:35:32.000000000 +0800
+++ linux-2.6.27-rc7_aer/drivers/pci/pcie/portdrv_core.c	2008-09-27 10:10:39.000000000 +0800
@@ -195,23 +195,25 @@ static int get_port_device_capability(st
 	/* PME Capable - root port capability */
 	if (((reg16 >> 4) & PORT_TYPE_MASK) == PCIE_RC_PORT)
 		services |= PCIE_PORT_SERVICE_PME;
-	
+
 	pos = PCI_CFG_SPACE_SIZE;
 	while (pos) {
-		pci_read_config_dword(dev, pos, &reg32);
-		switch (reg32 & 0xffff) {
+		if (pci_read_config_dword(dev, pos, &reg32))
+			break;
+
+		/* some broken boards return ~0 */
+		if (reg32 == 0xffffffff)
+			break;
+
+		switch (PCI_EXT_CAP_ID(reg32)) {
 		case PCI_EXT_CAP_ID_ERR:
 			services |= PCIE_PORT_SERVICE_AER;
-			pos = reg32 >> 20;
 			break;
 		case PCI_EXT_CAP_ID_VC:
 			services |= PCIE_PORT_SERVICE_VC;
-			pos = reg32 >> 20;
-			break;
-		default:
-			pos = 0;
 			break;
 		}
+		pos = PCI_EXT_CAP_NEXT(reg32);
 	}
 
 	return services;




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

* Re: [PATCH] pci-e: ignore unknown capability and continue searching
  2008-09-30  4:29 [PATCH] pci-e: ignore unknown capability and continue searching Zhang, Yanmin
@ 2008-10-03  8:21 ` Zhang, Yanmin
  2008-10-03 15:34   ` Jesse Barnes
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang, Yanmin @ 2008-10-03  8:21 UTC (permalink / raw)
  To: Greg KH; +Cc: jbarnes, LKML, czernecki

Greg, Jesse,

Is there any issue with the patch? Tomasz need kernel to have the patch to work
on his machine.

Thanks,
Yanmin

On Tue, 2008-09-30 at 12:29 +0800, Zhang, Yanmin wrote:
> Subject: pci-e: ignore unknown capability and continue searching
> From: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>
> 
> 
> Tomasz reported AER driver couldn't work on his machine. With the output
> of "lcpsi -vvv", I found the root port's extended capabilities are
>          Capabilities: [100] Unknown (11)
>          Capabilities: [150] Advanced Error Reporting
>          Capabilities: [190] Unknown (13)
> Such Unknown capability is not expected. During pci-e initialization,function
> get_port_device_capability just returns if it hits an unknown capability when
> searching the AER capability.
> 
> I worked out a patch against 2.6.27-rc7. When hitting an unkown capability,
> function get_port_device_capability continues the searching.
> 
> Tomasz tested it and the patch does work well.
> 
> Signed-off-by Zhang Yanmin <yanmin.zhang@linux.intel.com>
> Reported-by Tomasz Czernecki <czernecki@gmail.com>
> 
> ---
> 
> --- linux-2.6.27-rc7/drivers/pci/pcie/portdrv_core.c	2008-09-27 09:35:32.000000000 +0800
> +++ linux-2.6.27-rc7_aer/drivers/pci/pcie/portdrv_core.c	2008-09-27 10:10:39.000000000 +0800
> @@ -195,23 +195,25 @@ static int get_port_device_capability(st
>  	/* PME Capable - root port capability */
>  	if (((reg16 >> 4) & PORT_TYPE_MASK) == PCIE_RC_PORT)
>  		services |= PCIE_PORT_SERVICE_PME;
> -	
> +
>  	pos = PCI_CFG_SPACE_SIZE;
>  	while (pos) {
> -		pci_read_config_dword(dev, pos, &reg32);
> -		switch (reg32 & 0xffff) {
> +		if (pci_read_config_dword(dev, pos, &reg32))
> +			break;
> +
> +		/* some broken boards return ~0 */
> +		if (reg32 == 0xffffffff)
> +			break;
> +
> +		switch (PCI_EXT_CAP_ID(reg32)) {
>  		case PCI_EXT_CAP_ID_ERR:
>  			services |= PCIE_PORT_SERVICE_AER;
> -			pos = reg32 >> 20;
>  			break;
>  		case PCI_EXT_CAP_ID_VC:
>  			services |= PCIE_PORT_SERVICE_VC;
> -			pos = reg32 >> 20;
> -			break;
> -		default:
> -			pos = 0;
>  			break;
>  		}
> +		pos = PCI_EXT_CAP_NEXT(reg32);
>  	}
>  
>  	return services;
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


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

* Re: [PATCH] pci-e: ignore unknown capability and continue searching
  2008-10-03  8:21 ` Zhang, Yanmin
@ 2008-10-03 15:34   ` Jesse Barnes
  2008-10-06  2:02     ` Zhang, Yanmin
  0 siblings, 1 reply; 4+ messages in thread
From: Jesse Barnes @ 2008-10-03 15:34 UTC (permalink / raw)
  To: Zhang, Yanmin; +Cc: Greg KH, LKML, czernecki, linux-pci

I'd rather get rid of this function altogether.  Can you check out my "use 
pci_find_ext_capability everywhere" patch and see if you can do something 
similar for the port driver?  I mainly just want to avoid having duplicated 
find_capability code everywhere...

Thanks,
Jesse

On Friday, October 3, 2008 1:21 am Zhang, Yanmin wrote:
> Greg, Jesse,
>
> Is there any issue with the patch? Tomasz need kernel to have the patch to
> work on his machine.
>
> Thanks,
> Yanmin
>
> On Tue, 2008-09-30 at 12:29 +0800, Zhang, Yanmin wrote:
> > Subject: pci-e: ignore unknown capability and continue searching
> > From: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>
> >
> >
> > Tomasz reported AER driver couldn't work on his machine. With the output
> > of "lcpsi -vvv", I found the root port's extended capabilities are
> >          Capabilities: [100] Unknown (11)
> >          Capabilities: [150] Advanced Error Reporting
> >          Capabilities: [190] Unknown (13)
> > Such Unknown capability is not expected. During pci-e
> > initialization,function get_port_device_capability just returns if it
> > hits an unknown capability when searching the AER capability.
> >
> > I worked out a patch against 2.6.27-rc7. When hitting an unkown
> > capability, function get_port_device_capability continues the searching.
> >
> > Tomasz tested it and the patch does work well.
> >
> > Signed-off-by Zhang Yanmin <yanmin.zhang@linux.intel.com>
> > Reported-by Tomasz Czernecki <czernecki@gmail.com>
> >
> > ---
> >
> > --- linux-2.6.27-rc7/drivers/pci/pcie/portdrv_core.c	2008-09-27
> > 09:35:32.000000000 +0800 +++
> > linux-2.6.27-rc7_aer/drivers/pci/pcie/portdrv_core.c	2008-09-27
> > 10:10:39.000000000 +0800 @@ -195,23 +195,25 @@ static int
> > get_port_device_capability(st
> >  	/* PME Capable - root port capability */
> >  	if (((reg16 >> 4) & PORT_TYPE_MASK) == PCIE_RC_PORT)
> >  		services |= PCIE_PORT_SERVICE_PME;
> > -
> > +
> >  	pos = PCI_CFG_SPACE_SIZE;
> >  	while (pos) {
> > -		pci_read_config_dword(dev, pos, &reg32);
> > -		switch (reg32 & 0xffff) {
> > +		if (pci_read_config_dword(dev, pos, &reg32))
> > +			break;
> > +
> > +		/* some broken boards return ~0 */
> > +		if (reg32 == 0xffffffff)
> > +			break;
> > +
> > +		switch (PCI_EXT_CAP_ID(reg32)) {
> >  		case PCI_EXT_CAP_ID_ERR:
> >  			services |= PCIE_PORT_SERVICE_AER;
> > -			pos = reg32 >> 20;
> >  			break;
> >  		case PCI_EXT_CAP_ID_VC:
> >  			services |= PCIE_PORT_SERVICE_VC;
> > -			pos = reg32 >> 20;
> > -			break;
> > -		default:
> > -			pos = 0;
> >  			break;
> >  		}
> > +		pos = PCI_EXT_CAP_NEXT(reg32);
> >  	}
> >
> >  	return services;
> >
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel"
> > in the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/



-- 
Jesse Barnes, Intel Open Source Technology Center

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

* Re: [PATCH] pci-e: ignore unknown capability and continue searching
  2008-10-03 15:34   ` Jesse Barnes
@ 2008-10-06  2:02     ` Zhang, Yanmin
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang, Yanmin @ 2008-10-06  2:02 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: Greg KH, LKML, czernecki, linux-pci


On Fri, 2008-10-03 at 08:34 -0700, Jesse Barnes wrote:
> I'd rather get rid of this function altogether.  Can you check out my "use 
> pci_find_ext_capability everywhere" patch and see if you can do something 
> similar for the port driver?
Jesse,

I did a quick check. If applying the patches from you and Matthew, port driver
has no its own version of find capability.

Yanmin 

>   I mainly just want to avoid having duplicated 
> find_capability code everywhere...
> 
> Thanks,
> Jesse
> 
> On Friday, October 3, 2008 1:21 am Zhang, Yanmin wrote:
> > Greg, Jesse,
> >
> > Is there any issue with the patch? Tomasz need kernel to have the patch to
> > work on his machine.
> >
> > Thanks,
> > Yanmin
> >
> > On Tue, 2008-09-30 at 12:29 +0800, Zhang, Yanmin wrote:
> > > Subject: pci-e: ignore unknown capability and continue searching
> > > From: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>
> > >
> > >
> > > Tomasz reported AER driver couldn't work on his machine. With the output
> > > of "lcpsi -vvv", I found the root port's extended capabilities are
> > >          Capabilities: [100] Unknown (11)
> > >          Capabilities: [150] Advanced Error Reporting
> > >          Capabilities: [190] Unknown (13)
> > > Such Unknown capability is not expected. During pci-e
> > > initialization,function get_port_device_capability just returns if it
> > > hits an unknown capability when searching the AER capability.
> > >
> > > I worked out a patch against 2.6.27-rc7. When hitting an unkown
> > > capability, function get_port_device_capability continues the searching.
> > >
> > > Tomasz tested it and the patch does work well.
> > >
> > > Signed-off-by Zhang Yanmin <yanmin.zhang@linux.intel.com>
> > > Reported-by Tomasz Czernecki <czernecki@gmail.com>
> > >
> > > ---
> > >
> > > --- linux-2.6.27-rc7/drivers/pci/pcie/portdrv_core.c	2008-09-27
> > > 09:35:32.000000000 +0800 +++
> > > linux-2.6.27-rc7_aer/drivers/pci/pcie/portdrv_core.c	2008-09-27
> > > 10:10:39.000000000 +0800 @@ -195,23 +195,25 @@ static int
> > > get_port_device_capability(st
> > >  	/* PME Capable - root port capability */
> > >  	if (((reg16 >> 4) & PORT_TYPE_MASK) == PCIE_RC_PORT)
> > >  		services |= PCIE_PORT_SERVICE_PME;
> > > -
> > > +
> > >  	pos = PCI_CFG_SPACE_SIZE;
> > >  	while (pos) {
> > > -		pci_read_config_dword(dev, pos, &reg32);
> > > -		switch (reg32 & 0xffff) {
> > > +		if (pci_read_config_dword(dev, pos, &reg32))
> > > +			break;
> > > +
> > > +		/* some broken boards return ~0 */
> > > +		if (reg32 == 0xffffffff)
> > > +			break;
> > > +
> > > +		switch (PCI_EXT_CAP_ID(reg32)) {
> > >  		case PCI_EXT_CAP_ID_ERR:
> > >  			services |= PCIE_PORT_SERVICE_AER;
> > > -			pos = reg32 >> 20;
> > >  			break;
> > >  		case PCI_EXT_CAP_ID_VC:
> > >  			services |= PCIE_PORT_SERVICE_VC;
> > > -			pos = reg32 >> 20;
> > > -			break;
> > > -		default:
> > > -			pos = 0;
> > >  			break;
> > >  		}
> > > +		pos = PCI_EXT_CAP_NEXT(reg32);
> > >  	}
> > >
> > >  	return services;
> > >
> > >
> > >
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe linux-kernel"
> > > in the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > > Please read the FAQ at  http://www.tux.org/lkml/
> 
> 
> 


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

end of thread, other threads:[~2008-10-06  2:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-30  4:29 [PATCH] pci-e: ignore unknown capability and continue searching Zhang, Yanmin
2008-10-03  8:21 ` Zhang, Yanmin
2008-10-03 15:34   ` Jesse Barnes
2008-10-06  2:02     ` Zhang, Yanmin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox