From nobody Tue Sep 29 10:32:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 832E63932E9; Sat, 8 Aug 2026 17:23:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786209807; cv=none; b=shZo0F7i6yCs0uj9xrd2m9b62AzgHq9pnXUd43eMlUiLFqFjhMQWV75SXOtEuPQw5+6dE9UbO/QxQ7q1HOCof0ScvOeRUsnoC/SUYQu4uTVMkE2aCT+mITzHNIoXnnV7WPCLb1lEf5slcsv70hgkxgaix82Pp+ZdTrsw2IZQlF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786209807; c=relaxed/simple; bh=CX5XRKbAZjYc1jyK0tQnRaJDeiwcvDb7zn2MIqat44w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GfnnO4jRm+FtOy1XIvBDpiolaLQ7+flGHyRuke//UFlbUQxyMqozs5NoXARoSAIVbdgq/P7oqhqvE4QFIYZcBhdLbH91AXQRuZf8idmtrM+nIednTmyt7KQdFzRmw1ZbXJlG8alaVxEVBSSIrv3T5728JZTdru0wxmGz6PKegUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cHLQAhv9; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cHLQAhv9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F25591F00A3A; Sat, 8 Aug 2026 17:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786209806; bh=xufkNp1CDQZpQeRj9PlItChnbosE5797ESelEugb/rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cHLQAhv9mEdH04cRRL2pBJhrCTM+VmNAYobRq/ARKy30vLipKOLQHXA4cTSC3vWxA IMsJBJyy30GTIW4C9eFBqP8qh4TGOpuY1xIPdnHIQMNNmxw40Ut+rHi4RIFeoLMHeY 7RKtNUPh0l6fmA6iZE5L9vDVLdqKHaeMH3Autq5AXMCbeViyXb9jY+iCqZyJc17ZtP YmreYdOzaoIrtHOhw16+DIFjtr3C9eE/KVmZ1cgAtG3VOQdwy6JoF9l9ZREXU1UdF8 011K0P+kR2ds0fydAigokcdjaD1aQtHM2V/A2w81FjGWBrg9p6Ue30kFjqR23gmlc3 dary/HZ/YeKLw== From: Bjorn Helgaas To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Andrew Morton , Petr Mladek , Steven Rostedt Cc: Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH v1 1/2] vsprintf: Add %pR human-readable size Date: Sat, 8 Aug 2026 12:23:07 -0500 Message-ID: <20260808172308.282591-2-bhelgaas@google.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260808172308.282591-1-bhelgaas@google.com> References: <20260808172308.282591-1-bhelgaas@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Include human-readable size when printing struct resource memory ranges (not including DMA, bus number, or I/O port ranges) with the %pR format to make it easier to read, e.g., - pci 0000:00:02.0: BAR 0 [mem 0xfea80000-0xfea9ffff] + pci 0000:00:02.0: BAR 0 [mem 0xfea80000-0xfea9ffff (128 KiB)] Signed-off-by: Bjorn Helgaas --- lib/vsprintf.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 2bc6ef483576..c49044b6dbee 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1094,15 +1094,17 @@ char *resource_string(char *buf, char *end, struct = resource *res, /* 32-bit res (sizeof=3D=3D4): 10 chars in dec, 10 in hex ("0x" + 8) * 64-bit res (sizeof=3D=3D8): 20 chars in dec, 18 in hex ("0x" + 16) */ #define RSRC_BUF_SIZE ((2 * sizeof(resource_size_t)) + 4) +#define RSRC_STR_SIZE sizeof(" (xxxx.xxx MiB)") #define FLAG_BUF_SIZE (2 * sizeof(res->flags)) -#define DECODED_BUF_SIZE sizeof("[mem - 64bit pref window disabled]") -#define RAW_BUF_SIZE sizeof("[mem - flags 0x]") - char sym[MAX(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, - 2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; +#define DECODED_BUF_SIZE sizeof("[mem - () 64bit pref window disabled]") +#define RAW_BUF_SIZE sizeof("[mem - () flags 0x]") + char sym[MAX(2*RSRC_BUF_SIZE + RSRC_STR_SIZE + DECODED_BUF_SIZE, + 2*RSRC_BUF_SIZE + RSRC_STR_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; =20 char *p =3D sym, *pend =3D sym + sizeof(sym); bool decode =3D fmt[0] =3D=3D 'R'; const struct printf_spec *specp; + char size_buf[32]; =20 if (check_pointer(&buf, end, res, spec)) return buf; @@ -1134,6 +1136,14 @@ char *resource_string(char *buf, char *end, struct r= esource *res, } else { p =3D hex_range(p, pend, res->start, res->end, *specp); } + if (res->flags & IORESOURCE_MEM) { + *p++ =3D ' '; + *p++ =3D '('; + string_get_size(resource_size(res), 1, STRING_UNITS_2, + size_buf, sizeof(size_buf)); + p =3D string_nocheck(p, pend, size_buf, str_spec); + *p++ =3D ')'; + } if (decode) { if (res->flags & IORESOURCE_MEM_64) p =3D string_nocheck(p, pend, " 64bit", str_spec); --=20 2.53.0 From nobody Tue Sep 29 10:32:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C852838886B; Sat, 8 Aug 2026 17:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786209810; cv=none; b=btR/RWOpfzzklg/6TJS7+qzqifdKuKfHwiYhDtjTOQkWt/KsGeqbRVGNOwGT7I8BNrdSyseRt0JeNBZAz5sEMoUoNh/DhXJrzC3Q7paagG+3OANdNXmf+gJHdfMf/dwsh3IlfiEKeEJOMzQ8VIwHFSjYMx1q3chcLDU5URKOoVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786209810; c=relaxed/simple; bh=9OpaR2ckBZXsvul8369uSCurJD7EwbXqiDo9rO/qpqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RbBfGeivJYm1uJ75FgGGuDHcBP2FemyITvVFvykPDt3RFlGEPg1gbZedxuyZozblcuyaYqZ6l6Y6DONg/9xss4r1aEqiiqvThz1ju1QBU2Jq3EbuHiXks/lZeZBwEbmZV//1sKjMsmd277OeO4RjqhoW1IieirOFBhJ2pxw4lIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jcKYkOh3; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jcKYkOh3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 617AA1F000E9; Sat, 8 Aug 2026 17:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786209807; bh=PQ6ooHZ0Khu8tEZ6nW9lPnqMSnhrOYZdbSDHSYNbj98=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jcKYkOh3/D37o7ep2Fo7xjJJEwFhpPwGCDWoTqflnyVgY1qu2f4mu47PBl9UG8QEV LGrqEfuqnysv7UEbqHFGdOX5eLyc0PvbEvnmCyiNVJmgDAYgBduhMUmHulwpW7n8Kb r609JcfQraNCO6kqyRoBiS+aAu2qn9JuDWucEv+gLUMb2kvjVnMJLLGBUUvq3YpYAR QOcjq5Ewjs6MC4PwB2ZFiBUK4A5tnOGwWC3N2N6Fc4DNsgqg2e/IR6/NIoQ+XYlWqa qpxhavOiabarSb0jJeKrR2cXBNPfa04yrp7jyEzKovjvZ5JyOuvncE99dgmFzTqkMR erXXZE0Jk4tzw== From: Bjorn Helgaas To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Andrew Morton , Petr Mladek , Steven Rostedt Cc: Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH v1 2/2] PCI: Include human-readable sizes in resource assignment messages Date: Sat, 8 Aug 2026 12:23:08 -0500 Message-ID: <20260808172308.282591-3-bhelgaas@google.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260808172308.282591-1-bhelgaas@google.com> References: <20260808172308.282591-1-bhelgaas@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Include human-readable sizes, e.g., "16.0 MiB", in addition to the hex "0x1000000" size, in resource-related messages. Also consistently include the "0x" prefix. Signed-off-by: Bjorn Helgaas --- drivers/pci/setup-bus.c | 46 +++++++++++++++++++++++++++++------------ drivers/pci/setup-res.c | 11 ++++++---- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index c0a949f2c995..4f62ba6f4d7f 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "pci.h" =20 @@ -427,6 +428,7 @@ static void reassign_resources_sorted(struct list_head = *realloc_head, struct resource *res; const char *res_name; resource_size_t add_size, align; + char size_buf[32]; int idx; =20 list_for_each_entry_safe(add_res, tmp, realloc_head, list) { @@ -460,10 +462,14 @@ static void reassign_resources_sorted(struct list_hea= d *realloc_head, } else if (add_size > 0 || !IS_ALIGNED(res->start, align)) { res->flags |=3D add_res->flags & (IORESOURCE_STARTALIGN|IORESOURCE_SIZEALIGN); - if (pci_reassign_resource(dev, idx, add_size, align)) - pci_info(dev, "%s %pR: failed to add optional %llx\n", + if (pci_reassign_resource(dev, idx, add_size, align)) { + string_get_size(add_size, 1, STRING_UNITS_2, + size_buf, sizeof(size_buf)); + pci_info(dev, "%s %pR: failed to add optional %#llx (%s)\n", res_name, res, - (unsigned long long) add_size); + (unsigned long long) add_size, + size_buf); + } } out: list_del(&add_res->list); @@ -1076,6 +1082,7 @@ static void pbus_size_io(struct pci_bus *bus, resourc= e_size_t add_size, resource_size_t size =3D 0, size0 =3D 0, size1 =3D 0; resource_size_t children_add_size =3D 0; resource_size_t min_align, align; + char size_buf[32]; =20 if (!b_res) return; @@ -1138,11 +1145,14 @@ static void pbus_size_io(struct pci_bus *bus, resou= rce_size_t add_size, b_res->flags |=3D IORESOURCE_STARTALIGN; if (bus->self && size1 > size0 && realloc_head) { b_res->flags &=3D ~IORESOURCE_DISABLED; + add_size =3D size1 - size0; pci_dev_res_add_to_list(realloc_head, bus->self, b_res, - size1 - size0, min_align); - pci_info(bus->self, "bridge window %pR to %pR add_size %llx\n", + add_size, min_align); + string_get_size(add_size, 1, STRING_UNITS_2, + size_buf, sizeof(size_buf)); + pci_info(bus->self, "bridge window %pR to %pR add_size %#llx (%s)\n", b_res, &bus->busn_res, - (unsigned long long) size1 - size0); + (unsigned long long) add_size, size_buf); } } =20 @@ -1284,6 +1294,7 @@ static void pbus_size_mem(struct pci_bus *bus, struct= resource *b_res, resource_size_t aligns[28] =3D {}; /* Alignments from 1MB to 128TB */ int order, max_order; resource_size_t children_add_size =3D 0; + char size_buf[32], align_buf[32]; resource_size_t add_align =3D 0; =20 if (!b_res) @@ -1378,10 +1389,14 @@ static void pbus_size_mem(struct pci_bus *bus, stru= ct resource *b_res, add_size =3D size1 > size0 ? size1 - size0 : 0; pci_dev_res_add_to_list(realloc_head, bus->self, b_res, add_size, add_align); - pci_info(bus->self, "bridge window %pR to %pR add_size %llx add_align %l= lx\n", + string_get_size(add_size, 1, STRING_UNITS_2, size_buf, + sizeof(size_buf)); + string_get_size(add_align, 1, STRING_UNITS_2, align_buf, + sizeof(align_buf)); + pci_info(bus->self, "bridge window %pR to %pR add_size %#llx (%s) add_al= ign %#llx (%s)\n", b_res, &bus->busn_res, - (unsigned long long) add_size, - (unsigned long long) add_align); + (unsigned long long) add_size, size_buf, + (unsigned long long) add_align, align_buf); } } =20 @@ -1857,6 +1872,7 @@ static void adjust_bridge_window(struct pci_dev *brid= ge, struct resource *res, { resource_size_t add_size, size =3D resource_size(res); struct pci_dev_resource *dev_res; + char size_buf[32]; =20 if (resource_assigned(res)) return; @@ -1866,8 +1882,10 @@ static void adjust_bridge_window(struct pci_dev *bri= dge, struct resource *res, =20 if (new_size > size) { add_size =3D new_size - size; - pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, - &add_size); + string_get_size(add_size, 1, STRING_UNITS_2, + size_buf, sizeof(size_buf)); + pci_dbg(bridge, "bridge window %pR extended by %pa (%s)\n", res, + &add_size, size_buf); } else if (new_size < size) { int idx =3D pci_resource_num(bridge, res); =20 @@ -1900,8 +1918,10 @@ static void adjust_bridge_window(struct pci_dev *bri= dge, struct resource *res, add_size =3D size - new_size; if (add_size < dev_res->add_size) { dev_res->add_size -=3D add_size; - pci_dbg(bridge, "bridge window %pR optional size shrunken by %pa\n", - res, &add_size); + string_get_size(add_size, 1, STRING_UNITS_2, + size_buf, sizeof(size_buf)); + pci_dbg(bridge, "bridge window %pR optional size shrunken by %pa (%s)\n= ", + res, &add_size, size_buf); } else { pci_dbg(bridge, "bridge window %pR optional size removed\n", res); diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 376f09630a4a..707c405000b8 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "pci.h" =20 static void pci_std_update_resource(struct pci_dev *dev, int resno) @@ -431,6 +432,7 @@ int pci_reassign_resource(struct pci_dev *dev, int resn= o, const char *res_name =3D pci_resource_name(dev, resno); unsigned long flags; resource_size_t new_size; + char size_buf[32]; int ret; =20 if (res->flags & IORESOURCE_PCI_FIXED) @@ -444,19 +446,20 @@ int pci_reassign_resource(struct pci_dev *dev, int re= sno, return -EINVAL; } =20 + string_get_size(addsize, 1, STRING_UNITS_2, size_buf, sizeof(size_buf)); new_size =3D resource_size(res) + addsize; ret =3D _pci_assign_resource(dev, resno, new_size, min_align); if (ret) { res->flags =3D flags; - pci_info(dev, "%s %pR: failed to expand by %#llx\n", - res_name, res, (unsigned long long) addsize); + pci_info(dev, "%s %pR: failed to expand by %#llx (%s)\n", + res_name, res, (unsigned long long) addsize, size_buf); return ret; } =20 res->flags &=3D ~IORESOURCE_UNSET; res->flags &=3D ~IORESOURCE_STARTALIGN; - pci_info(dev, "%s %pR: reassigned; expanded by %#llx\n", - res_name, res, (unsigned long long) addsize); + pci_info(dev, "%s %pR: reassigned; expanded by %#llx (%s)\n", + res_name, res, (unsigned long long) addsize, size_buf); if (resno < PCI_BRIDGE_RESOURCES) pci_update_resource(dev, resno); =20 --=20 2.53.0