From: Bjorn Helgaas <helgaas@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: marek.vasut+renesas@gmail.com, yoshihiro.shimoda.uh@renesas.com,
lpieralisi@kernel.org, robh@kernel.org, kw@linux.com,
bhelgaas@google.com, linux-renesas-soc@vger.kernel.org,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org,
Jingoo Han <jingoohan1@gmail.com>,
Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
Serge Semin <Sergey.Semin@baikalelectronics.ru>
Subject: Re: [PATCH] PCI: rcar-ep: Simplify bitmap allocation.
Date: Thu, 23 Jun 2022 12:04:47 -0500 [thread overview]
Message-ID: <20220623170447.GA1458028@bhelgaas> (raw)
In-Reply-To: <0fd98d56871f6f08ca82dcc76bfa2052368a8926.1655814557.git.christophe.jaillet@wanadoo.fr>
[+cc Jingoo, Gustavo, Serge, in case dwc should do something similar]
On Tue, Jun 21, 2022 at 02:31:46PM +0200, Christophe JAILLET wrote:
> MAX_NR_INBOUND_MAPS is small (i.e. 6), so there is no real point in
> dynamic allocation for a bitmap of this size.
> Moreover, it is linked with the use of the 'bar_to_atu' field which is
> already statically declared.
>
> Declare it statically instead.
>
> This saves some LoC, reduces the size of the module and saves a few bytes
> of memory at run-time.
>
> Before: (gcc 11.2.0 / allyesconfig)
> text data bss dec hex filename
> 11514 5232 0 16746 416a drivers/pci/controller/pcie-rcar-ep.o
>
> After: (gcc 11.2.0 / allyesconfig)
> text data bss dec hex filename
> 11183 5064 0 16247 3f77 drivers/pci/controller/pcie-rcar-ep.o
>
>
> Also replace the mostly useless 'num_ib_windows' and use
> MAX_NR_INBOUND_MAPS directly instead.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Looking for an ack from Marek or Yoshihiro here ...
I'm guessing struct dw_pcie.ib_window_map and .ob_window_map are
probably similar, though the limit is not hard-coded as it is for
rcar-ep.
> ---
> drivers/pci/controller/pcie-rcar-ep.c | 17 ++++-------------
> 1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-rcar-ep.c b/drivers/pci/controller/pcie-rcar-ep.c
> index f9682df1da61..64682876e93e 100644
> --- a/drivers/pci/controller/pcie-rcar-ep.c
> +++ b/drivers/pci/controller/pcie-rcar-ep.c
> @@ -25,8 +25,7 @@ struct rcar_pcie_endpoint {
> struct pci_epc_mem_window *ob_window;
> u8 max_functions;
> unsigned int bar_to_atu[MAX_NR_INBOUND_MAPS];
> - unsigned long *ib_window_map;
> - u32 num_ib_windows;
> + DECLARE_BITMAP(ib_window_map, MAX_NR_INBOUND_MAPS);
> u32 num_ob_windows;
> };
>
> @@ -205,8 +204,8 @@ static int rcar_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
> int idx;
> int err;
>
> - idx = find_first_zero_bit(ep->ib_window_map, ep->num_ib_windows);
> - if (idx >= ep->num_ib_windows) {
> + idx = find_first_zero_bit(ep->ib_window_map, MAX_NR_INBOUND_MAPS);
> + if (idx >= MAX_NR_INBOUND_MAPS) {
> dev_err(pcie->dev, "no free inbound window\n");
> return -EINVAL;
> }
> @@ -502,15 +501,7 @@ static int rcar_pcie_ep_probe(struct platform_device *pdev)
> goto err_pm_put;
> }
>
> - ep->num_ib_windows = MAX_NR_INBOUND_MAPS;
> - ep->ib_window_map =
> - devm_kcalloc(dev, BITS_TO_LONGS(ep->num_ib_windows),
> - sizeof(long), GFP_KERNEL);
> - if (!ep->ib_window_map) {
> - err = -ENOMEM;
> - dev_err(dev, "failed to allocate memory for inbound map\n");
> - goto err_pm_put;
> - }
> + bitmap_zero(ep->ib_window_map, MAX_NR_INBOUND_MAPS);
>
> ep->ob_mapped_addr = devm_kcalloc(dev, ep->num_ob_windows,
> sizeof(*ep->ob_mapped_addr),
> --
> 2.32.0
>
prev parent reply other threads:[~2022-06-23 17:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 12:31 [PATCH] PCI: rcar-ep: Simplify bitmap allocation Christophe JAILLET
2022-06-23 17:04 ` Bjorn Helgaas [this message]
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=20220623170447.GA1458028@bhelgaas \
--to=helgaas@kernel.org \
--cc=Sergey.Semin@baikalelectronics.ru \
--cc=bhelgaas@google.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=gustavo.pimentel@synopsys.com \
--cc=jingoohan1@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=marek.vasut+renesas@gmail.com \
--cc=robh@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.com \
/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;
as well as URLs for NNTP newsgroup(s).