Re: [PATCH v3 1/9] PCI: endpoint: pci-epf-test: Fix incorrect loop increment

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

 



On Fri, Mar 15, 2024 at 10:50:45AM +0530, Manivannan Sadhasivam wrote:
> On Wed, Mar 13, 2024 at 11:57:53AM +0100, Niklas Cassel wrote:
> > pci_epf_test_alloc_space() currently skips the BAR succeeding a 64-bit BAR
> > if the 64-bit flag is set, before calling pci_epf_alloc_space().
> > 
> > However, pci_epf_alloc_space() will set the 64-bit flag if we request an
> > allocation of 4 GB or larger, even if it wasn't set before the allocation.
> > 
> 
> Max BAR size is 1MB currently, so I believe you are adding the check just for
> the sake of correctness. If so, please mention it explicitly.

The BAR size defined in:
static size_t bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 };
will only be used if the BAR is not fixed size.
(A fixed BAR size will override the size in static size_t bar_size[])

So a platform could have a fixed size BAR of e.g. 4GB.

Although, you could argue that if a platform has a fixed BAR size of 4GB,
they should have also marked the BAR as "only 64-bit".
(Considering that the largest size supported by a 32-bit BAR is 2GB.)

I will drop this patch in V4.


Kind regards,
Niklas


> 
> - Mani
> 
> > Thus, we need to check the flag also after pci_epf_alloc_space().
> > 
> > Signed-off-by: Niklas Cassel <cassel@xxxxxxxxxx>
> > ---
> >  drivers/pci/endpoint/functions/pci-epf-test.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> > index cd4ffb39dcdc..01ba088849cc 100644
> > --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> > +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> > @@ -865,6 +865,12 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf)
> >  			dev_err(dev, "Failed to allocate space for BAR%d\n",
> >  				bar);
> >  		epf_test->reg[bar] = base;
> > +
> > +		/*
> > +		 * pci_epf_alloc_space() might have given us a 64-bit BAR,
> > +		 * if we requested a size larger than 4 GB.
> > +		 */
> > +		add = (epf_bar->flags & PCI_BASE_ADDRESS_MEM_TYPE_64) ? 2 : 1;
> >  	}
> >  
> >  	return 0;
> > -- 
> > 2.44.0
> > 
> 
> -- 
> மணிவண்ணன் சதாசிவம்




[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