From: Niklas Cassel <Niklas.Cassel@wdc.com>
To: Frank Li <Frank.li@nxp.com>
Cc: "Manivannan Sadhasivam" <mani@kernel.org>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Gustavo Pimentel" <gustavo.pimentel@synopsys.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Jon Mason" <jdmason@kudzu.us>,
"open list:PCI DRIVER FOR SYNOPSYS DESIGNWARE"
<linux-pci@vger.kernel.org>,
"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] PCI: dwc: Fix BAR0 wrong map to iATU6 after root complex reinit endpoint
Date: Mon, 4 Mar 2024 21:04:30 +0000 [thread overview]
Message-ID: <ZeY3XqgUf84qAMCL@fedora> (raw)
In-Reply-To: <ZeYdV3xMWa0nbz3k@lizhi-Precision-Tower-5810>
On Mon, Mar 04, 2024 at 02:13:27PM -0500, Frank Li wrote:
> >
> > Niklas's initial suggestion of keeping u8 for the array and 0 as the unallocated
> > placeholder sounds good to me. Please use that instead.
> >
>
> It is impossible to keep u8, because 255 + 1 will 0 for u8. Previously
> Niklas's initial suggestion have not consider this condition. If u8 have to
> change to u16 or s16 anyways, I prefer use -1 as free.
Well, to be fair, my suggestion was:
"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."
But we have this define:
drivers/pci/controller/dwc/pcie-designware.h:#define MAX_IATU_IN 256
(Even if it isn't used anywhere.)
But as ridiculous as it may seem to support that many inbound ranges,
that is the max number of windows supported by the hardware, so why
not just let the driver support the max supported by the hardware?
We are talking about:
struct dw_pcie_ep {
...
u8 bar_to_atu[PCI_STD_NUM_BARS];
...
}
where PCI_STD_NUM_BARS == 6.
And where struct dw_pcie_ep is kzalloced for what I assume is all drivers.
So I'm actually for your idea of changing it to u16, or even unsigned int.
If the code is simplified if we use a u16 or unsigned int (because we don't
need any weird if (val < MAX_IATU_IN - 1) check), then I'm all for it.
What I personally don't like with your patch in $subject,
was that you changed both dw_pcie_ep_clear_bar() to set the "clear value"
to -1, but you also need a
memset(ep->bar_to_atu, -1, sizeof(ep->bar_to_atu)); in dw_pcie_ep_init().
I much prefer to have 0 as the default/unused value, because it will
automatically get set when you do kzalloc().
Seeing a memset -1 just looks a bit hackish to be, but I realize that
it is personal preference.
If it is super important to save 8 bytes from the heap, then I would
even prefer changing the MAX_IATU_IN 256 to something smaller, like
127 or whatever, just as long as we don't need that extra memset -1 :)
Kind regards,
Niklas
next prev parent reply other threads:[~2024-03-04 21:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 4:48 [PATCH 1/1] PCI: dwc: Fix BAR0 wrong map to iATU6 after root complex reinit endpoint Frank Li
2023-12-19 4:48 ` Frank Li
2023-12-19 10:07 ` Niklas Cassel
2023-12-19 14:20 ` Frank Li
2023-12-19 14:38 ` Niklas Cassel
2024-01-09 13:52 ` Niklas Cassel
2024-01-09 15:04 ` Frank Li
2024-01-24 17:10 ` Frank Li
2024-01-30 6:29 ` Manivannan Sadhasivam
2024-02-29 12:03 ` Niklas Cassel
2024-02-29 20:13 ` Frank Li
2024-03-04 8:48 ` Manivannan Sadhasivam
2024-03-04 16:47 ` Frank Li
2024-03-04 18:10 ` Manivannan Sadhasivam
2024-03-04 19:13 ` Frank Li
2024-03-04 21:04 ` Niklas Cassel [this message]
2024-03-04 21:17 ` Frank Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZeY3XqgUf84qAMCL@fedora \
--to=niklas.cassel@wdc.com \
--cc=Frank.li@nxp.com \
--cc=bhelgaas@google.com \
--cc=gustavo.pimentel@synopsys.com \
--cc=imx@lists.linux.dev \
--cc=jdmason@kudzu.us \
--cc=jingoohan1@gmail.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox