[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240304181005.GF31079@thinkpad>
Date: Mon, 4 Mar 2024 23:40:05 +0530
From: Manivannan Sadhasivam <mani@...nel.org>
To: Frank Li <Frank.li@....com>
Cc: Manivannan Sadhasivam <mani@...nel.org>,
Niklas Cassel <Niklas.Cassel@....com>,
"imx@...ts.linux.dev" <imx@...ts.linux.dev>,
Jingoo Han <jingoohan1@...il.com>,
Gustavo Pimentel <gustavo.pimentel@...opsys.com>,
Lorenzo Pieralisi <lpieralisi@...nel.org>,
Krzysztof Wilczyński <kw@...ux.com>,
Rob Herring <robh@...nel.org>, Bjorn Helgaas <bhelgaas@...gle.com>,
Jon Mason <jdmason@...zu.us>,
"open list:PCI DRIVER FOR SYNOPSYS DESIGNWARE" <linux-pci@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] PCI: dwc: Fix BAR0 wrong map to iATU6 after root
complex reinit endpoint
On Mon, Mar 04, 2024 at 11:47:36AM -0500, Frank Li wrote:
> On Mon, Mar 04, 2024 at 02:18:41PM +0530, Manivannan Sadhasivam wrote:
> > On Tue, Dec 19, 2023 at 02:38:34PM +0000, Niklas Cassel wrote:
> > > On Tue, Dec 19, 2023 at 09:20:21AM -0500, Frank Li wrote:
> > > > On Tue, Dec 19, 2023 at 10:07:14AM +0000, Niklas Cassel wrote:
> > > > > On Mon, Dec 18, 2023 at 11:48:43PM -0500, Frank Li wrote:
> > > > > > dw_pcie_ep_inbound_atu()
> > > > > > {
> > > > > > ...
> > > > > > if (!ep->bar_to_atu[bar])
> > > > > > free_win = find_first_zero_bit(ep->ib_window_map, pci->num_ib_windows);
> > > > > > else
> > > > > > free_win = ep->bar_to_atu[bar];
> > > > > > ...
> > > > > > }
> > > > > >
> > > > > > The atu index 0 is valid case for atu number. The find_first_zero_bit()
> > > > > > will return 6 when second time call into this function if atu is 0. Suppose
> > > > > > it should use branch 'free_win = ep->bar_to_atu[bar]'.
> > > > > >
> > > > > > Change 'bar_to_atu' to s8. Initialize bar_to_atu as -1 to indicate it have
> > > > > > not allocate atu to the bar.
> > > > > >
> > > > > > Reported-by: Niklas Cassel <Niklas.Cassel@....com>
> > > > > > Close: https://lore.kernel.org/linux-pci/ZXt2A+Fusfz3luQV@x1-carbon/T/#u
> > > > > > Fixes: 4284c88fff0e ("PCI: designware-ep: Allow pci_epc_set_bar() update inbound map address")
> > > > > > Signed-off-by: Frank Li <Frank.Li@....com>
> > > > > > ---
> > > > > >
> > > > > > Notes:
> > > > > > @Niklas:
> > > > > > I have not test your case. I should be equal to previous's fix in
> > > > > > mail list.
> > > > >
> > > > > Hello Frank,
> > > > >
> > > > > Thank you for sending a proper fix for this!
> > > > >
> > > > > Personally, I slightly prefer your fix that saves the iatu index + 1, and
> > > > > keeps 0 to mean unused. That way, you don't need the memset, and you don't
> > > > > need to change the type to signed, but either way is fine by me, so:
> > > >
> > > > index + 1 don't match hardware iATU index. It will be confused because
> > > > other parts is 0 based.
> > > >
> > > > So I choose "-1" as free iATU.
> > >
> > > A s8 can hold a max value of 127.
> > > CX_ATU_NUM_OUTBOUND_REGIONS seems to be 0-255.
> > >
> > > Since the DWC code can be synthesized with 256 iATUs,
> > > your code will not work on systems with 128 or more iATUs.
> > >
> > > If we continue to use a u8, and offset the saved value by one,
> > > we will at least be able to support 255-1 == 254 iATUs.
> > >
> >
> > Agree. I cannot suggest a better alternative. So let's go with this. But please
> > add a comment before bar_to_atu assignment to make it clear. Like,
> >
> > /*
> > * Always increment free_win before assignment, since value 0 is used to
> > * identify unallocated mapping.
> > */
> > ep->bar_to_atu[bar] = free_win + 1;
>
> This patch already change to use "-1" as free. Only issue for this patch is
> that use 's16' instead of 's8' becasue max ATU number is 255.
>
Niklas's initial suggestion of keeping u8 for the array and 0 as the unallocated
placeholder sounds good to me. Please use that instead.
Even though iATU window index starts from 0, the comment I suggested will
clarify what this bar_to_atu[] does.
- Mani
--
மணிவண்ணன் சதாசிவம்
Powered by blists - more mailing lists