Re: [PATCH v5 1/2] platform/x86: p2sb: Allow p2sb_bar() calls during PCI device probe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 05, 2024 / 09:44, Lukas Wunner wrote:
> On Fri, Jan 05, 2024 at 08:18:05AM +0000, Shinichiro Kawasaki wrote:
> > --- a/drivers/platform/x86/p2sb.c
> > +++ b/drivers/platform/x86/p2sb.c
> > @@ -150,6 +153,14 @@ static int p2sb_cache_resources(void)
> >  	if (!bus)
> >  		return -ENODEV;
> >  
> > +	/*
> > +	 * When a device with same devfn exists and it is not P2SB, do not
> > +	 * touch it.
> > +	 */
> > +	pci_bus_read_config_dword(bus, devfn_p2sb, PCI_CLASS_REVISION, &class);
> > +	if (!PCI_POSSIBLE_ERROR(class) && class >> 8 != P2SB_CLASS_CODE)
> > +		return -ENODEV;
> > +
> 
> The function should probably return if PCI_POSSIBLE_ERROR() is true.

At this point, the P2SB device can be still hidden and PCI_POSSIBLE_ERROR() can
be true. In that case, the function should not return.

> Also I think you can use PCI_CLASS_MEMORY_OTHER, so how about:
> 
> 	if (PCI_POSSIBLE_ERROR(class) || class >> 16 != PCI_CLASS_MEMORY_OTHER)
> 		return -ENODEV;
> 
> Can alternatively use "class >> 8 != PCI_CLASS_MEMORY_OTHER << 8" if you
> want to ensure the lowest byte is 0x00.

Thanks, it looks the better to use PCI_CLASS_MEMORY_OTHER. Will reflect it when
I create the formal fix patch.




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux