From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Stewart Hildebrand <stewart.hildebrand@amd.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Philipp Stanner <pstanner@redhat.com>,
x86@kernel.org, linux-pci@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 1/8] x86/PCI: Improve code readability
Date: Thu, 8 Aug 2024 11:55:02 +0300 (EEST) [thread overview]
Message-ID: <971d8fda-5317-7481-d435-35bf1faae115@linux.intel.com> (raw)
In-Reply-To: <20240807151723.613742-2-stewart.hildebrand@amd.com>
[-- Attachment #1: Type: text/plain, Size: 2507 bytes --]
On Wed, 7 Aug 2024, Stewart Hildebrand wrote:
> The indentation in pcibios_allocate_dev_resources() is unusually deep.
> Improve that by moving some of its code to a new function,
> alloc_resource().
>
> Take the opportunity to remove redundant information from dev_dbg().
>
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
> ---
> v2->v3:
> * new subject (was: "x86/PCI: Move some logic to new function")
> * reword commit message (thanks Philipp)
>
> v1->v2:
> * new patch
> ---
> arch/x86/pci/i386.c | 38 +++++++++++++++++++++-----------------
> 1 file changed, 21 insertions(+), 17 deletions(-)
>
> diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
> index f2f4a5d50b27..3abd55902dbc 100644
> --- a/arch/x86/pci/i386.c
> +++ b/arch/x86/pci/i386.c
> @@ -246,6 +246,25 @@ struct pci_check_idx_range {
> int end;
> };
>
> +static void alloc_resource(struct pci_dev *dev, int idx, int pass)
> +{
> + struct resource *r = &dev->resource[idx];
> +
> + dev_dbg(&dev->dev, "BAR %d: reserving %pr (p=%d)\n", idx, r, pass);
> +
> + if (pci_claim_resource(dev, idx) < 0) {
> + if (r->flags & IORESOURCE_PCI_FIXED) {
> + dev_info(&dev->dev, "BAR %d %pR is immovable\n",
> + idx, r);
> + } else {
> + /* We'll assign a new address later */
> + pcibios_save_fw_addr(dev, idx, r->start);
> + r->end -= r->start;
> + r->start = 0;
> + }
> + }
> +}
> +
> static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
> {
> int idx, disabled, i;
> @@ -271,23 +290,8 @@ static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
> disabled = !(command & PCI_COMMAND_IO);
> else
> disabled = !(command & PCI_COMMAND_MEMORY);
> - if (pass == disabled) {
> - dev_dbg(&dev->dev,
> - "BAR %d: reserving %pr (d=%d, p=%d)\n",
> - idx, r, disabled, pass);
> - if (pci_claim_resource(dev, idx) < 0) {
> - if (r->flags & IORESOURCE_PCI_FIXED) {
> - dev_info(&dev->dev, "BAR %d %pR is immovable\n",
> - idx, r);
> - } else {
> - /* We'll assign a new address later */
> - pcibios_save_fw_addr(dev,
> - idx, r->start);
> - r->end -= r->start;
> - r->start = 0;
> - }
> - }
> - }
> + if (pass == disabled)
> + alloc_resource(dev, idx, pass);
> }
> if (!pass) {
> r = &dev->resource[PCI_ROM_RESOURCE];
>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
next prev parent reply other threads:[~2024-08-08 8:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 15:17 [PATCH v3 0/8] PCI: Align small BARs Stewart Hildebrand
2024-08-07 15:17 ` [PATCH v3 1/8] x86/PCI: Improve code readability Stewart Hildebrand
2024-08-08 8:55 ` Ilpo Järvinen [this message]
2024-08-07 15:17 ` [PATCH v3 2/8] PCI: Don't unnecessarily disable memory decoding Stewart Hildebrand
2024-08-07 15:17 ` [PATCH v3 3/8] PCI: Restore resource alignment Stewart Hildebrand
2024-08-08 19:28 ` Bjorn Helgaas
2024-08-08 20:28 ` Stewart Hildebrand
2024-08-08 21:54 ` Bjorn Helgaas
2024-08-14 18:12 ` Stewart Hildebrand
2024-08-07 15:17 ` [PATCH v3 4/8] PCI: Restore memory decoding after reallocation Stewart Hildebrand
2024-08-08 19:37 ` Bjorn Helgaas
2024-08-14 18:31 ` Stewart Hildebrand
2024-08-07 15:17 ` [PATCH v3 5/8] x86/PCI: Preserve IORESOURCE_STARTALIGN alignment Stewart Hildebrand
2024-08-08 20:10 ` Bjorn Helgaas
2024-08-07 15:17 ` [PATCH v3 6/8] powerpc/pci: " Stewart Hildebrand
2024-08-07 15:17 ` [PATCH v3 7/8] PCI: Don't reassign resources that are already aligned Stewart Hildebrand
2024-08-07 15:17 ` [PATCH v3 8/8] PCI: Align small BARs Stewart Hildebrand
2024-08-08 21:53 ` Bjorn Helgaas
2024-08-14 13:55 ` Stewart Hildebrand
2024-08-14 22:05 ` Bjorn Helgaas
2024-08-07 15:42 ` [PATCH v3 0/8] " Arnd Bergmann
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=971d8fda-5317-7481-d435-35bf1faae115@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pstanner@redhat.com \
--cc=stewart.hildebrand@amd.com \
--cc=tglx@linutronix.de \
--cc=x86@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