From: Bjorn Helgaas <helgaas@kernel.org>
To: Nirmoy Das <nirmoy.das@amd.com>
Cc: bhelgaas@google.com, ckoenig.leichtzumerken@gmail.com,
linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org,
devspam@moreofthesa.me.uk,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH 2/4] PCI: Add pci_rebar_bytes_to_size()
Date: Thu, 7 Jan 2021 15:17:57 -0600 [thread overview]
Message-ID: <20210107211757.GA1391831@bjorn-Precision-5520> (raw)
In-Reply-To: <20210107175017.15893-3-nirmoy.das@amd.com>
On Thu, Jan 07, 2021 at 06:50:15PM +0100, Nirmoy Das wrote:
> Users of pci_resize_resource() need a way to calculate bar size
> from desired bytes. Add a helper function and export it so that
> modular drivers can use it.
s/bar/BAR/
> Signed-off-by: Darren Salt <devspam@moreofthesa.me.uk>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> drivers/pci/pci.c | 2 +-
> include/linux/pci.h | 6 ++++++
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index ef80ed451415..16216186b51c 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -1648,7 +1648,7 @@ static void pci_restore_rebar_state(struct pci_dev *pdev)
> pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
> bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX;
> res = pdev->resource + bar_idx;
> - size = ilog2(resource_size(res)) - 20;
> + size = pci_rebar_bytes_to_size(resource_size(res));
> ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
> ctrl |= size << PCI_REBAR_CTRL_BAR_SHIFT;
> pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 9999040cfad9..77fed01523e0 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1226,6 +1226,12 @@ void pci_update_resource(struct pci_dev *dev, int resno);
> int __must_check pci_assign_resource(struct pci_dev *dev, int i);
> int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align);
> void pci_release_resource(struct pci_dev *dev, int resno);
> +static inline int pci_rebar_bytes_to_size(u64 bytes)
> +{
> + bytes = roundup_pow_of_two(bytes);
> + return max(ilog2(bytes), 20) - 20;
This isn't returning a "size", is it? It looks like it's returning
the log2 of the number of MB the BAR will be, i.e., the encoding used
by the Resizable BAR Control register "BAR Size" field. Needs a brief
comment to that effect and/or a different function name.
> +}
> +
> u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar);
> int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size);
> int pci_select_bars(struct pci_dev *dev, unsigned long flags);
> --
> 2.29.2
>
next prev parent reply other threads:[~2021-01-07 21:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-07 17:50 [PATCH 0/4] A PCI quirk for resizable BAR 0 on Navi10 Nirmoy Das
2021-01-07 17:50 ` [PATCH 1/4] PCI: Export pci_rebar_get_possible_sizes() Nirmoy Das
2021-01-07 21:18 ` Bjorn Helgaas
2021-01-07 17:50 ` [PATCH 2/4] PCI: Add pci_rebar_bytes_to_size() Nirmoy Das
2021-01-07 21:17 ` Bjorn Helgaas [this message]
2021-01-07 23:31 ` Darren Salt
2021-01-08 1:01 ` Bjorn Helgaas
2021-01-07 17:50 ` [PATCH 3/4] drm/amdgpu: Resize BAR0 to the maximum available size, even if it doesn't cover VRAM Nirmoy Das
2021-01-07 17:50 ` [PATCH 4/4] PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse Nirmoy Das
2021-01-07 21:32 ` Bjorn Helgaas
2021-01-07 20:25 ` Christian König
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=20210107211757.GA1391831@bjorn-Precision-5520 \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=devspam@moreofthesa.me.uk \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-pci@vger.kernel.org \
--cc=nirmoy.das@amd.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