[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e7atdf4hszeijz3pyt3deegl7tye5fjvvpe2klc5kg7m4okenu@habv7c2ys4zk>
Date: Thu, 8 Jan 2026 10:42:05 +0900
From: Koichiro Den <den@...inux.co.jp>
To: Niklas Cassel <cassel@...nel.org>
Cc: jingoohan1@...il.com, mani@...nel.org, lpieralisi@...nel.org,
kwilczynski@...nel.org, robh@...nel.org, bhelgaas@...gle.com, Frank.Li@....com,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] PCI: dwc: ep: Support BAR subrange inbound
mapping via address-match iATU
On Wed, Jan 07, 2026 at 03:27:28PM +0100, Niklas Cassel wrote:
> Hello Koichiro,
>
>
> I like this design way more, where you have a one-shot (all-or-nothing)
> submap programming to avoid leaving half-programmed BAR state.
>
>
> On Wed, Jan 07, 2026 at 01:13:58PM +0900, Koichiro Den wrote:
> > +/* Address Match Mode IB iATU mapping */
> > +static int dw_pcie_ep_ib_atu_addr(struct dw_pcie_ep *ep, u8 func_no, int type,
> > + const struct pci_epf_bar *epf_bar)
> > +{
> > + struct pci_epf_bar_submap *submap = epf_bar->submap;
> > + struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > + enum pci_barno bar = epf_bar->barno;
> > + struct device *dev = pci->dev;
> > + u64 pci_addr, parent_bus_addr;
> > + struct dw_pcie_ib_map *new;
> > + u64 size, off, base;
> > + unsigned long flags;
> > + int free_win, ret;
> > + unsigned int i;
> > +
> > + if (!epf_bar->num_submap || !submap || !epf_bar->size)
> > + return -EINVAL;
> > +
> > + /* Work on a sorted copy */
> > + struct pci_epf_bar_submap *smap __free(kfree) = kcalloc(
> > + epf_bar->num_submap, sizeof(*smap), GFP_KERNEL);
> > + if (!smap)
> > + return -ENOMEM;
> > +
> > + memcpy(smap, submap, epf_bar->num_submap * sizeof(*smap));
> > + sort(smap, epf_bar->num_submap, sizeof(*smap),
> > + dw_pcie_ep_submap_offset_cmp, NULL);
>
> My only comment is that:
>
> Why not simply let dw_pcie_ep_validate_submap() return an error if the
> caller of dw_pcie_ep_set_bar() did not provide a submap with offsets in
> ascending order (i.e. sorted).
>
> Performing an unconditional sort of the submap here looks a bit out of
> place, IMO.
There wasn't a strong reason to sort the submap here, it was just to make
things easier for callers. That said, given the one-shot (all-or-nothing)
design, the caller is expected to know the complete layout at the time of
invocation, so requring the submap to be sorted is not a strong constraint.
I'll respin this accordingly and send a v3. Thank you for the feedback.
Koichiro
>
>
> > +
> > + ret = dw_pcie_ep_validate_submap(ep, smap, epf_bar->num_submap, epf_bar->size);
> > + if (ret)
> > + return ret;
>
>
> Kind regards,
> Niklas
Powered by blists - more mailing lists