From nobody Sun Dec 28 21:15:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4255AC4167B for ; Tue, 5 Dec 2023 17:11:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345508AbjLERLo (ORCPT ); Tue, 5 Dec 2023 12:11:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345596AbjLERLd (ORCPT ); Tue, 5 Dec 2023 12:11:33 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E46FA1B9 for ; Tue, 5 Dec 2023 09:11:30 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39FA3C433CA; Tue, 5 Dec 2023 17:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701796290; bh=XxBZyK07KrgM9wDgcJEblAD+Kh9xWEHLc4pprnPshOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z36Lfk2HmhOkj5nd6uCN1uyoh/7RC9NtyAJ+Uo/2VK4mg/Aj9qPyNsjfcZWicXI63 whNMh/LZCNjDbJ7LtHU721/tkwZKKLuNpTUzspk67JOvuZsmgocNDKkHXY0pSxEker 2NYHghXrWQvNmAFlgZBx0P1wqbYsLL4XvIOGjRA+mxVkSS8oLaG7M9Zs8DinGEQ9NI olUz++XOWitm2m/h7acmuqRnFEzWb5viu3+PEdtMHjKpOv9A9JSO74MZho5PlbwWPL jPKfV8HnTc2aJNQ4X/xDRmnObVkHEnmH9fYEgi2mOkmqo5qgcT/zAByEKQGq/KG1Rv nwK06OvP9pKPA== From: Bjorn Helgaas To: linux-pci@vger.kernel.org Cc: Puranjay Mohan , linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH 3/7] PCI: Use resource names in PCI log messages Date: Tue, 5 Dec 2023 11:11:15 -0600 Message-Id: <20231205171119.680358-4-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231205171119.680358-1-helgaas@kernel.org> References: <20231205171119.680358-1-helgaas@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Puranjay Mohan Use the pci_resource_name() to get the name of the resource and use it while printing log messages. [bhelgaas: rename to match struct resource * names, also use names in other BAR messages] Link: https://lore.kernel.org/r/20211106112606.192563-3-puranjay12@gmail.com Signed-off-by: Puranjay Mohan Signed-off-by: Bjorn Helgaas --- drivers/pci/iov.c | 7 ++-- drivers/pci/pci.c | 25 +++++++------- drivers/pci/probe.c | 26 +++++++-------- drivers/pci/quirks.c | 15 ++++++--- drivers/pci/setup-bus.c | 30 +++++++++++------ drivers/pci/setup-res.c | 72 +++++++++++++++++++++++------------------ 6 files changed, 103 insertions(+), 72 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 25dbe85c4217..aaa33e8dc4c9 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -745,6 +745,7 @@ static int sriov_init(struct pci_dev *dev, int pos) u16 ctrl, total; struct pci_sriov *iov; struct resource *res; + const char *res_name; struct pci_dev *pdev; =20 pci_read_config_word(dev, pos + PCI_SRIOV_CTRL, &ctrl); @@ -785,6 +786,8 @@ static int sriov_init(struct pci_dev *dev, int pos) nres =3D 0; for (i =3D 0; i < PCI_SRIOV_NUM_BARS; i++) { res =3D &dev->resource[i + PCI_IOV_RESOURCES]; + res_name =3D pci_resource_name(dev, i + PCI_IOV_RESOURCES); + /* * If it is already FIXED, don't change it, something * (perhaps EA or header fixups) wants it this way. @@ -802,8 +805,8 @@ static int sriov_init(struct pci_dev *dev, int pos) } iov->barsz[i] =3D resource_size(res); res->end =3D res->start + resource_size(res) * total - 1; - pci_info(dev, "VF(n) BAR%d space: %pR (contains BAR%d for %d VFs)\n", - i, res, i, total); + pci_info(dev, "%s %pR: contains BAR %d for %d VFs\n", + res_name, res, i, total); i +=3D bar64; nres++; } diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index af36a0bf3e42..e62c17a8859d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3350,6 +3350,7 @@ static struct resource *pci_ea_get_resource(struct pc= i_dev *dev, u8 bei, static int pci_ea_read(struct pci_dev *dev, int offset) { struct resource *res; + const char *res_name; int ent_size, ent_offset =3D offset; resource_size_t start, end; unsigned long flags; @@ -3379,6 +3380,7 @@ static int pci_ea_read(struct pci_dev *dev, int offse= t) goto out; =20 res =3D pci_ea_get_resource(dev, bei, prop); + res_name =3D pci_resource_name(dev, bei); if (!res) { pci_err(dev, "Unsupported EA entry BEI: %u\n", bei); goto out; @@ -3452,16 +3454,16 @@ static int pci_ea_read(struct pci_dev *dev, int off= set) res->flags =3D flags; =20 if (bei <=3D PCI_EA_BEI_BAR5) - pci_info(dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\= n", - bei, res, prop); + pci_info(dev, "%s %pR: from Enhanced Allocation, properties %#02x\n", + res_name, res, prop); else if (bei =3D=3D PCI_EA_BEI_ROM) - pci_info(dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n", - res, prop); + pci_info(dev, "%s %pR: from Enhanced Allocation, properties %#02x\n", + res_name, res, prop); else if (bei >=3D PCI_EA_BEI_VF_BAR0 && bei <=3D PCI_EA_BEI_VF_BAR5) - pci_info(dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02= x)\n", - bei - PCI_EA_BEI_VF_BAR0, res, prop); + pci_info(dev, "%s %pR: from Enhanced Allocation, properties %#02x\n", + res_name, res, prop); else - pci_info(dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#0= 2x)\n", + pci_info(dev, "BEI %d %pR: from Enhanced Allocation, properties %#02x\n", bei, res, prop); =20 out: @@ -6749,14 +6751,15 @@ static void pci_request_resource_alignment(struct p= ci_dev *dev, int bar, resource_size_t align, bool resize) { struct resource *r =3D &dev->resource[bar]; + const char *r_name =3D pci_resource_name(dev, bar); resource_size_t size; =20 if (!(r->flags & IORESOURCE_MEM)) return; =20 if (r->flags & IORESOURCE_PCI_FIXED) { - pci_info(dev, "BAR%d %pR: ignoring requested alignment %#llx\n", - bar, r, (unsigned long long)align); + pci_info(dev, "%s %pR: ignoring requested alignment %#llx\n", + r_name, r, (unsigned long long)align); return; } =20 @@ -6792,8 +6795,8 @@ static void pci_request_resource_alignment(struct pci= _dev *dev, int bar, * devices and we use the second. */ =20 - pci_info(dev, "BAR%d %pR: requesting alignment to %#llx\n", - bar, r, (unsigned long long)align); + pci_info(dev, "%s %pR: requesting alignment to %#llx\n", + r_name, r, (unsigned long long)align); =20 if (resize) { r->start =3D 0; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 1dbc06f0305c..f6ec79b6a037 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -180,6 +180,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_t= ype type, u64 l64, sz64, mask64; u16 orig_cmd; struct pci_bus_region region, inverted_region; + const char *res_name =3D pci_resource_name(dev, res - dev->resource); =20 mask =3D type ? PCI_ROM_ADDRESS_MASK : ~0; =20 @@ -254,8 +255,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_t= ype type, =20 sz64 =3D pci_size(l64, sz64, mask64); if (!sz64) { - pci_info(dev, FW_BUG "reg 0x%x: invalid BAR (can't size)\n", - pos); + pci_info(dev, FW_BUG "%s: invalid; can't size\n", res_name); goto fail; } =20 @@ -265,8 +265,8 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_t= ype type, res->flags |=3D IORESOURCE_UNSET | IORESOURCE_DISABLED; res->start =3D 0; res->end =3D 0; - pci_err(dev, "reg 0x%x: can't handle BAR larger than 4GB (size %#010llx= )\n", - pos, (unsigned long long)sz64); + pci_err(dev, "%s: can't handle BAR larger than 4GB (size %#010llx)\n", + res_name, (unsigned long long)sz64); goto out; } =20 @@ -275,8 +275,8 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_t= ype type, res->flags |=3D IORESOURCE_UNSET; res->start =3D 0; res->end =3D sz64 - 1; - pci_info(dev, "reg 0x%x: can't handle BAR above 4GB (bus address %#010l= lx)\n", - pos, (unsigned long long)l64); + pci_info(dev, "%s: can't handle BAR above 4GB (bus address %#010llx)\n", + res_name, (unsigned long long)l64); goto out; } } @@ -302,8 +302,8 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_t= ype type, res->flags |=3D IORESOURCE_UNSET; res->start =3D 0; res->end =3D region.end - region.start; - pci_info(dev, "reg 0x%x: initial BAR value %#010llx invalid\n", - pos, (unsigned long long)region.start); + pci_info(dev, "%s: initial BAR value %#010llx invalid\n", + res_name, (unsigned long long)region.start); } =20 goto out; @@ -313,7 +313,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_t= ype type, res->flags =3D 0; out: if (res->flags) - pci_info(dev, "reg 0x%x: %pR\n", pos, res); + pci_info(dev, "%s %pR\n", res_name, res); =20 return (res->flags & IORESOURCE_MEM_64) ? 1 : 0; } @@ -1967,14 +1967,14 @@ int pci_setup_device(struct pci_dev *dev) res =3D &dev->resource[0]; res->flags =3D LEGACY_IO_RESOURCE; pcibios_bus_to_resource(dev->bus, res, ®ion); - pci_info(dev, "legacy IDE quirk: reg 0x10: %pR\n", + pci_info(dev, "BAR 0 %pR: legacy IDE quirk\n", res); region.start =3D 0x3F6; region.end =3D 0x3F6; res =3D &dev->resource[1]; res->flags =3D LEGACY_IO_RESOURCE; pcibios_bus_to_resource(dev->bus, res, ®ion); - pci_info(dev, "legacy IDE quirk: reg 0x14: %pR\n", + pci_info(dev, "BAR 1 %pR: legacy IDE quirk\n", res); } if ((progif & 4) =3D=3D 0) { @@ -1983,14 +1983,14 @@ int pci_setup_device(struct pci_dev *dev) res =3D &dev->resource[2]; res->flags =3D LEGACY_IO_RESOURCE; pcibios_bus_to_resource(dev->bus, res, ®ion); - pci_info(dev, "legacy IDE quirk: reg 0x18: %pR\n", + pci_info(dev, "BAR 2 %pR: legacy IDE quirk\n", res); region.start =3D 0x376; region.end =3D 0x376; res =3D &dev->resource[3]; res->flags =3D LEGACY_IO_RESOURCE; pcibios_bus_to_resource(dev->bus, res, ®ion); - pci_info(dev, "legacy IDE quirk: reg 0x1c: %pR\n", + pci_info(dev, "BAR 3 %pR: legacy IDE quirk\n", res); } } diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index ea476252280a..905ff3def1bf 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -570,13 +570,14 @@ static void quirk_extend_bar_to_page(struct pci_dev *= dev) =20 for (i =3D 0; i < PCI_STD_NUM_BARS; i++) { struct resource *r =3D &dev->resource[i]; + const char *r_name =3D pci_resource_name(dev, i); =20 if (r->flags & IORESOURCE_MEM && resource_size(r) < PAGE_SIZE) { r->end =3D PAGE_SIZE - 1; r->start =3D 0; r->flags |=3D IORESOURCE_UNSET; - pci_info(dev, "expanded BAR %d to page size: %pR\n", - i, r); + pci_info(dev, "%s %pR: expanded to page size\n", + r_name, r); } } } @@ -605,6 +606,7 @@ static void quirk_io(struct pci_dev *dev, int pos, unsi= gned int size, u32 region; struct pci_bus_region bus_region; struct resource *res =3D dev->resource + pos; + const char *res_name =3D pci_resource_name(dev, pos); =20 pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + (pos << 2), ®ion); =20 @@ -622,8 +624,7 @@ static void quirk_io(struct pci_dev *dev, int pos, unsi= gned int size, bus_region.end =3D region + size - 1; pcibios_bus_to_resource(dev->bus, res, &bus_region); =20 - pci_info(dev, FW_BUG "%s quirk: reg 0x%x: %pR\n", - name, PCI_BASE_ADDRESS_0 + (pos << 2), res); + pci_info(dev, FW_BUG "%s %pR: %s quirk\n", res_name, res, name); } =20 /* @@ -670,6 +671,12 @@ static void quirk_io_region(struct pci_dev *dev, int p= ort, bus_region.end =3D region + size - 1; pcibios_bus_to_resource(dev->bus, res, &bus_region); =20 + /* + * "res" is typically a bridge window resource that's not being + * used for a bridge window, so it's just a place to stash this + * non-standard resource. Printing "nr" or pci_resource_name() of + * it doesn't really make sense. + */ if (!pci_claim_resource(dev, nr)) pci_info(dev, "quirk: %pR claimed by %s\n", res, name); } diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index fd74f1c99dba..909e6a7c3cc3 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -213,6 +213,7 @@ static void reassign_resources_sorted(struct list_head = *realloc_head, struct list_head *head) { struct resource *res; + const char *res_name; struct pci_dev_resource *add_res, *tmp; struct pci_dev_resource *dev_res; resource_size_t add_size, align; @@ -222,6 +223,7 @@ static void reassign_resources_sorted(struct list_head = *realloc_head, bool found_match =3D false; =20 res =3D add_res->res; + /* Skip resource that has been reset */ if (!res->flags) goto out; @@ -237,6 +239,7 @@ static void reassign_resources_sorted(struct list_head = *realloc_head, continue; =20 idx =3D res - &add_res->dev->resource[0]; + res_name =3D pci_resource_name(add_res->dev, idx); add_size =3D add_res->add_size; align =3D add_res->min_align; if (!resource_size(res)) { @@ -249,9 +252,9 @@ static void reassign_resources_sorted(struct list_head = *realloc_head, (IORESOURCE_STARTALIGN|IORESOURCE_SIZEALIGN); if (pci_reassign_resource(add_res->dev, idx, add_size, align)) - pci_info(add_res->dev, "failed to add %llx res[%d]=3D%pR\n", - (unsigned long long) add_size, idx, - res); + pci_info(add_res->dev, "%s %pR: failed to add %llx\n", + res_name, res, + (unsigned long long) add_size); } out: list_del(&add_res->list); @@ -571,6 +574,7 @@ EXPORT_SYMBOL(pci_setup_cardbus); static void pci_setup_bridge_io(struct pci_dev *bridge) { struct resource *res; + const char *res_name; struct pci_bus_region region; unsigned long io_mask; u8 io_base_lo, io_limit_lo; @@ -583,6 +587,7 @@ static void pci_setup_bridge_io(struct pci_dev *bridge) =20 /* Set up the top and bottom of the PCI I/O segment for this bus */ res =3D &bridge->resource[PCI_BRIDGE_IO_WINDOW]; + res_name =3D pci_resource_name(bridge, PCI_BRIDGE_IO_WINDOW); pcibios_resource_to_bus(bridge->bus, ®ion, res); if (res->flags & IORESOURCE_IO) { pci_read_config_word(bridge, PCI_IO_BASE, &l); @@ -591,7 +596,7 @@ static void pci_setup_bridge_io(struct pci_dev *bridge) l =3D ((u16) io_limit_lo << 8) | io_base_lo; /* Set up upper 16 bits of I/O base/limit */ io_upper16 =3D (region.end & 0xffff0000) | (region.start >> 16); - pci_info(bridge, " bridge window %pR\n", res); + pci_info(bridge, " %s %pR\n", res_name, res); } else { /* Clear upper 16 bits of I/O base/limit */ io_upper16 =3D 0; @@ -608,16 +613,18 @@ static void pci_setup_bridge_io(struct pci_dev *bridg= e) static void pci_setup_bridge_mmio(struct pci_dev *bridge) { struct resource *res; + const char *res_name; struct pci_bus_region region; u32 l; =20 /* Set up the top and bottom of the PCI Memory segment for this bus */ res =3D &bridge->resource[PCI_BRIDGE_MEM_WINDOW]; + res_name =3D pci_resource_name(bridge, PCI_BRIDGE_MEM_WINDOW); pcibios_resource_to_bus(bridge->bus, ®ion, res); if (res->flags & IORESOURCE_MEM) { l =3D (region.start >> 16) & 0xfff0; l |=3D region.end & 0xfff00000; - pci_info(bridge, " bridge window %pR\n", res); + pci_info(bridge, " %s %pR\n", res_name, res); } else { l =3D 0x0000fff0; } @@ -627,6 +634,7 @@ static void pci_setup_bridge_mmio(struct pci_dev *bridg= e) static void pci_setup_bridge_mmio_pref(struct pci_dev *bridge) { struct resource *res; + const char *res_name; struct pci_bus_region region; u32 l, bu, lu; =20 @@ -640,6 +648,7 @@ static void pci_setup_bridge_mmio_pref(struct pci_dev *= bridge) /* Set up PREF base/limit */ bu =3D lu =3D 0; res =3D &bridge->resource[PCI_BRIDGE_PREF_MEM_WINDOW]; + res_name =3D pci_resource_name(bridge, PCI_BRIDGE_PREF_MEM_WINDOW); pcibios_resource_to_bus(bridge->bus, ®ion, res); if (res->flags & IORESOURCE_PREFETCH) { l =3D (region.start >> 16) & 0xfff0; @@ -648,7 +657,7 @@ static void pci_setup_bridge_mmio_pref(struct pci_dev *= bridge) bu =3D upper_32_bits(region.start); lu =3D upper_32_bits(region.end); } - pci_info(bridge, " bridge window %pR\n", res); + pci_info(bridge, " %s %pR\n", res_name, res); } else { l =3D 0x0000fff0; } @@ -1013,6 +1022,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigne= d long mask, int i; =20 pci_dev_for_each_resource(dev, r, i) { + const char *r_name =3D pci_resource_name(dev, i); resource_size_t r_size; =20 if (r->parent || (r->flags & IORESOURCE_PCI_FIXED) || @@ -1043,8 +1053,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigne= d long mask, if (order < 0) order =3D 0; if (order >=3D ARRAY_SIZE(aligns)) { - pci_warn(dev, "disabling BAR %d: %pR (bad alignment %#llx)\n", - i, r, (unsigned long long) align); + pci_warn(dev, "%s %pR: disabling; bad alignment %#llx\n", + r_name, r, (unsigned long long) align); r->flags =3D 0; continue; } @@ -2235,6 +2245,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bri= dge, unsigned long type) for (i =3D PCI_BRIDGE_RESOURCES; i < PCI_BRIDGE_RESOURCE_END; i++) { struct resource *res =3D &bridge->resource[i]; + const char *res_name =3D pci_resource_name(bridge, i); =20 if ((res->flags ^ type) & PCI_RES_TYPE_MASK) continue; @@ -2247,8 +2258,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bri= dge, unsigned long type) if (ret) goto cleanup; =20 - pci_info(bridge, "BAR %d: releasing %pR\n", - i, res); + pci_info(bridge, "%s %pR: releasing\n", res_name, res); =20 if (res->parent) release_resource(res); diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index ceaa69491f5e..c6d933ddfd46 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -30,6 +30,7 @@ static void pci_std_update_resource(struct pci_dev *dev, = int resno) u32 new, check, mask; int reg; struct resource *res =3D dev->resource + resno; + const char *res_name =3D pci_resource_name(dev, resno); =20 /* Per SR-IOV spec 3.4.1.11, VF BARs are RO zero */ if (dev->is_virtfn) @@ -104,8 +105,8 @@ static void pci_std_update_resource(struct pci_dev *dev= , int resno) pci_read_config_dword(dev, reg, &check); =20 if ((new ^ check) & mask) { - pci_err(dev, "BAR %d: error updating (%#010x !=3D %#010x)\n", - resno, new, check); + pci_err(dev, "%s: error updating (%#010x !=3D %#010x)\n", + res_name, new, check); } =20 if (res->flags & IORESOURCE_MEM_64) { @@ -113,8 +114,8 @@ static void pci_std_update_resource(struct pci_dev *dev= , int resno) pci_write_config_dword(dev, reg + 4, new); pci_read_config_dword(dev, reg + 4, &check); if (check !=3D new) { - pci_err(dev, "BAR %d: error updating (high %#010x !=3D %#010x)\n", - resno, new, check); + pci_err(dev, "%s: error updating (high %#010x !=3D %#010x)\n", + res_name, new, check); } } =20 @@ -135,11 +136,12 @@ void pci_update_resource(struct pci_dev *dev, int res= no) int pci_claim_resource(struct pci_dev *dev, int resource) { struct resource *res =3D &dev->resource[resource]; + const char *res_name =3D pci_resource_name(dev, resource); struct resource *root, *conflict; =20 if (res->flags & IORESOURCE_UNSET) { - pci_info(dev, "can't claim BAR %d %pR: no address assigned\n", - resource, res); + pci_info(dev, "%s %pR: can't claim; no address assigned\n", + res_name, res); return -EINVAL; } =20 @@ -153,16 +155,16 @@ int pci_claim_resource(struct pci_dev *dev, int resou= rce) =20 root =3D pci_find_parent_resource(dev, res); if (!root) { - pci_info(dev, "can't claim BAR %d %pR: no compatible bridge window\n", - resource, res); + pci_info(dev, "%s %pR: can't claim; no compatible bridge window\n", + res_name, res); res->flags |=3D IORESOURCE_UNSET; return -EINVAL; } =20 conflict =3D request_resource_conflict(root, res); if (conflict) { - pci_info(dev, "can't claim BAR %d %pR: address conflict with %s %pR\n", - resource, res, conflict->name, conflict); + pci_info(dev, "%s %pR: can't claim; address conflict with %s %pR\n", + res_name, res, conflict->name, conflict); res->flags |=3D IORESOURCE_UNSET; return -EBUSY; } @@ -201,6 +203,7 @@ static int pci_revert_fw_address(struct resource *res, = struct pci_dev *dev, { struct resource *root, *conflict; resource_size_t fw_addr, start, end; + const char *res_name =3D pci_resource_name(dev, resno); =20 fw_addr =3D pcibios_retrieve_fw_addr(dev, resno); if (!fw_addr) @@ -231,12 +234,11 @@ static int pci_revert_fw_address(struct resource *res= , struct pci_dev *dev, root =3D &iomem_resource; } =20 - pci_info(dev, "BAR %d: trying firmware assignment %pR\n", - resno, res); + pci_info(dev, "%s: trying firmware assignment %pR\n", res_name, res); conflict =3D request_resource_conflict(root, res); if (conflict) { - pci_info(dev, "BAR %d: %pR conflicts with %s %pR\n", - resno, res, conflict->name, conflict); + pci_info(dev, "%s %pR: conflicts with %s %pR\n", res_name, res, + conflict->name, conflict); res->start =3D start; res->end =3D end; res->flags |=3D IORESOURCE_UNSET; @@ -325,6 +327,7 @@ static int _pci_assign_resource(struct pci_dev *dev, in= t resno, int pci_assign_resource(struct pci_dev *dev, int resno) { struct resource *res =3D dev->resource + resno; + const char *res_name =3D pci_resource_name(dev, resno); resource_size_t align, size; int ret; =20 @@ -334,8 +337,8 @@ int pci_assign_resource(struct pci_dev *dev, int resno) res->flags |=3D IORESOURCE_UNSET; align =3D pci_resource_alignment(dev, res); if (!align) { - pci_info(dev, "BAR %d: can't assign %pR (bogus alignment)\n", - resno, res); + pci_info(dev, "%s %pR: can't assign; bogus alignment\n", + res_name, res); return -EINVAL; } =20 @@ -348,18 +351,18 @@ int pci_assign_resource(struct pci_dev *dev, int resn= o) * working, which is better than just leaving it disabled. */ if (ret < 0) { - pci_info(dev, "BAR %d: no space for %pR\n", resno, res); + pci_info(dev, "%s %pR: can't assign; no space\n", res_name, res); ret =3D pci_revert_fw_address(res, dev, resno, size); } =20 if (ret < 0) { - pci_info(dev, "BAR %d: failed to assign %pR\n", resno, res); + pci_info(dev, "%s %pR: failed to assign\n", res_name, res); return ret; } =20 res->flags &=3D ~IORESOURCE_UNSET; res->flags &=3D ~IORESOURCE_STARTALIGN; - pci_info(dev, "BAR %d: assigned %pR\n", resno, res); + pci_info(dev, "%s %pR: assigned\n", res_name, res); if (resno < PCI_BRIDGE_RESOURCES) pci_update_resource(dev, resno); =20 @@ -367,10 +370,11 @@ int pci_assign_resource(struct pci_dev *dev, int resn= o) } EXPORT_SYMBOL(pci_assign_resource); =20 -int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t = addsize, - resource_size_t min_align) +int pci_reassign_resource(struct pci_dev *dev, int resno, + resource_size_t addsize, resource_size_t min_align) { struct resource *res =3D dev->resource + resno; + const char *res_name =3D pci_resource_name(dev, resno); unsigned long flags; resource_size_t new_size; int ret; @@ -381,8 +385,8 @@ int pci_reassign_resource(struct pci_dev *dev, int resn= o, resource_size_t addsiz flags =3D res->flags; res->flags |=3D IORESOURCE_UNSET; if (!res->parent) { - pci_info(dev, "BAR %d: can't reassign an unassigned resource %pR\n", - resno, res); + pci_info(dev, "%s %pR: can't reassign; unassigned resource\n", + res_name, res); return -EINVAL; } =20 @@ -391,15 +395,15 @@ int pci_reassign_resource(struct pci_dev *dev, int re= sno, resource_size_t addsiz ret =3D _pci_assign_resource(dev, resno, new_size, min_align); if (ret) { res->flags =3D flags; - pci_info(dev, "BAR %d: %pR (failed to expand by %#llx)\n", - resno, res, (unsigned long long) addsize); + pci_info(dev, "%s %pR: failed to expand by %#llx\n", + res_name, res, (unsigned long long) addsize); return ret; } =20 res->flags &=3D ~IORESOURCE_UNSET; res->flags &=3D ~IORESOURCE_STARTALIGN; - pci_info(dev, "BAR %d: reassigned %pR (expanded by %#llx)\n", - resno, res, (unsigned long long) addsize); + pci_info(dev, "%s %pR: reassigned; expanded by %#llx\n", + res_name, res, (unsigned long long) addsize); if (resno < PCI_BRIDGE_RESOURCES) pci_update_resource(dev, resno); =20 @@ -409,8 +413,9 @@ int pci_reassign_resource(struct pci_dev *dev, int resn= o, resource_size_t addsiz void pci_release_resource(struct pci_dev *dev, int resno) { struct resource *res =3D dev->resource + resno; + const char *res_name =3D pci_resource_name(dev, resno); =20 - pci_info(dev, "BAR %d: releasing %pR\n", resno, res); + pci_info(dev, "%s %pR: releasing\n", res_name, res); =20 if (!res->parent) return; @@ -480,6 +485,7 @@ int pci_enable_resources(struct pci_dev *dev, int mask) u16 cmd, old_cmd; int i; struct resource *r; + const char *r_name; =20 pci_read_config_word(dev, PCI_COMMAND, &cmd); old_cmd =3D cmd; @@ -488,6 +494,8 @@ int pci_enable_resources(struct pci_dev *dev, int mask) if (!(mask & (1 << i))) continue; =20 + r_name =3D pci_resource_name(dev, i); + if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) continue; if ((i =3D=3D PCI_ROM_RESOURCE) && @@ -495,14 +503,14 @@ int pci_enable_resources(struct pci_dev *dev, int mas= k) continue; =20 if (r->flags & IORESOURCE_UNSET) { - pci_err(dev, "can't enable device: BAR %d %pR not assigned\n", - i, r); + pci_err(dev, "%s %pR: not assigned; can't enable device\n", + r_name, r); return -EINVAL; } =20 if (!r->parent) { - pci_err(dev, "can't enable device: BAR %d %pR not claimed\n", - i, r); + pci_err(dev, "%s %pR: not claimed; can't enable device\n", + r_name, r); return -EINVAL; } =20 --=20 2.34.1