From nobody Mon Nov 25 13:46:17 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 4CA218460; Sat, 26 Oct 2024 00:47:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729903622; cv=none; b=Eq5/1pzYNzBYo93p7gEQU7SKByQ2Q7jnNJfU7I/7dPYE/tSp8nCA75cXgGC2KaKNxgVAN+EHqpkjp5YEBrN0Zi04O7mGqCVmHsKCuKxjiAWbAGOyBWW4L/+Mkugf3O2KBPgtgLbsWjWsMVfEV1loKAg+OU5fCc57ksljNiALVys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729903622; c=relaxed/simple; bh=PlYWMyblOiHnSgikBnvQ88kKKoxtE5z9I5CsWUz8/T4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t3niL0hXCBCBXIQOeNBF1uwNZpY/saRh+qJFUNC64MQrDDOHbRQRoMRzjCJU13cKi9hYRK2FDzyG7p2nBUzIgpIKW0R04GYh0m7Oy/WB23F7g5H6/HTx4qNMtusJ/+bE0BpRUEKOHCRAzhBB5dyA875oFMrLiJ0Jaq5YQc7NgQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=T1T+yCl/; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T1T+yCl/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729903621; x=1761439621; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=PlYWMyblOiHnSgikBnvQ88kKKoxtE5z9I5CsWUz8/T4=; b=T1T+yCl/xBZoovKIK4my9W/5eQ2KvSOIRp340IvPPotGhsZHjvdvCVG4 El8aS03e1t7o37jDrA97zNbM/RKQ9E1HgkNrWKgYJiBKTjXxtyknec3io QPiQyGp2aI9UG0tpEWnbiQ03oFkMNRpA9J6LKDgDwnbqhE0LnxMpPmdVz P7zUmuMuxIoO3iAXnzSQVxuiB48mlw+nAQ2A8lPYA8mdIkW36oUuCGWjN AlT1C2Q48gthJXysyluJ/UlAHtE0bZHdqicnZMTgsupnJCqiA/yDQkWGZ i3VYbwjCWQ/PvK0JlMoCUDqUP6UuCj70/apU7s55Dp3NoxNfYuNXLpVup g==; X-CSE-ConnectionGUID: qW2pbiv+S7CYxGpUbUFVJQ== X-CSE-MsgGUID: en6anB/CQDm0m42eSkSUpQ== X-IronPort-AV: E=McAfee;i="6700,10204,11236"; a="40974439" X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="40974439" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 17:47:00 -0700 X-CSE-ConnectionGUID: xcKdkoOFRIye+sBeFjUGYA== X-CSE-MsgGUID: OcSpOJWyQEmU40v8m+QD9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="85851634" Received: from kinlongk-mobl1.amr.corp.intel.com (HELO localhost) ([10.125.111.138]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 17:46:58 -0700 From: Ira Weiny Date: Fri, 25 Oct 2024 19:46:53 -0500 Subject: [PATCH v2 1/4] test printf: Add very basic struct resource tests Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241025-cxl-pra-v2-1-123a825daba2@intel.com> References: <20241025-cxl-pra-v2-0-123a825daba2@intel.com> In-Reply-To: <20241025-cxl-pra-v2-0-123a825daba2@intel.com> To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Jonathan Corbet , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Dan Williams Cc: Fan Ni , Bagas Sanjaya , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-cxl@vger.kernel.org, Ira Weiny , Jonathan Cameron X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729903614; l=2082; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=PlYWMyblOiHnSgikBnvQ88kKKoxtE5z9I5CsWUz8/T4=; b=pw+sEZIjeqU+2KmsBFBUSsBdzAFWdts1IDd2AJ6Qf8EOxKWB4ELnYEn6Kpywmb9828ErTYOpt Uu4TB4ptCZ8D3pdw+160uW0hHvlmJBwch7yWgN/yEZxkgPHZypwEYfM X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= The printf tests for struct resource were stubbed out. struct range printing will leverage the struct resource implementation. To prevent regression add some basic sanity tests for struct resource. Reviewed-by: Andy Shevchenko Reviewed-by: Jonathan Cameron Reviewed-by: Fan Ni Tested-by: Fan Ni Acked-by: Petr Mladek Link: https://patch.msgid.link/20241007-dcd-type2-upstream-v4-1-c261ee6eede= d@intel.com Tested-by: Petr Mladek Signed-off-by: Ira Weiny --- lib/test_printf.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/test_printf.c b/lib/test_printf.c index 8448b6d02bd9..5afdf5efc627 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -386,6 +386,50 @@ kernel_ptr(void) static void __init struct_resource(void) { + struct resource test_resource =3D { + .start =3D 0xc0ffee00, + .end =3D 0xc0ffee00, + .flags =3D IORESOURCE_MEM, + }; + + test("[mem 0xc0ffee00 flags 0x200]", + "%pr", &test_resource); + + test_resource =3D (struct resource) { + .start =3D 0xc0ffee, + .end =3D 0xba5eba11, + .flags =3D IORESOURCE_MEM, + }; + test("[mem 0x00c0ffee-0xba5eba11 flags 0x200]", + "%pr", &test_resource); + + test_resource =3D (struct resource) { + .start =3D 0xba5eba11, + .end =3D 0xc0ffee, + .flags =3D IORESOURCE_MEM, + }; + test("[mem 0xba5eba11-0x00c0ffee flags 0x200]", + "%pr", &test_resource); + + test_resource =3D (struct resource) { + .start =3D 0xba5eba11, + .end =3D 0xba5eca11, + .flags =3D IORESOURCE_MEM, + }; + + test("[mem 0xba5eba11-0xba5eca11 flags 0x200]", + "%pr", &test_resource); + + test_resource =3D (struct resource) { + .start =3D 0xba11, + .end =3D 0xca10, + .flags =3D IORESOURCE_IO | + IORESOURCE_DISABLED | + IORESOURCE_UNSET, + }; + + test("[io size 0x1000 disabled]", + "%pR", &test_resource); } =20 static void __init --=20 2.47.0 From nobody Mon Nov 25 13:46:17 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 E512512E7F; Sat, 26 Oct 2024 00:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729903625; cv=none; b=ikyhjHOxcmegKp1b+0pzLHOasXQYUuPQ7hf29hWTHNawIDb3eyM3DtpRaQmheHdvryoT29GSMMkvn0hr8kg1IJ59HHny2ChqOezM6JaSkkqNrPVdZXNQZPgt6fKMSojU3fNPPoA1Y+sOjb3Yq9rBxlsbLMKFTPrjjif+9viigjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729903625; c=relaxed/simple; bh=2Vnmkz1SVO7/e2yim2K6ewALI0lceemicbolVGaUX/8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V9WnySEeS/NeTmPkS36qnOJLtf5C4yeZ1V9C7N9Hu8QWyHgsrnswohv66QhCFzIKqlklzt0DFfMh1OtHfbKTB1driBoeW4ufVP5EVo1oy2LirGiTNMDJ+dl9at86KsSIH1WMmWQdg1f+QRNP6TyeJabk6UHi2ag0Yb+spKEPFho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Qr2uKx8g; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Qr2uKx8g" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729903624; x=1761439624; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=2Vnmkz1SVO7/e2yim2K6ewALI0lceemicbolVGaUX/8=; b=Qr2uKx8ghGRRXVZGEOpYqzAiIJyArYuKAvh6mHDNn93WiVFkvBg7M71L zhLOs6WhEay82c/KWJljyHHm2vQe/t9y495s0tKcEi+VokGLNjsnE0AhH UFUAMTAsZ/afCXyRduIzJGQVNhpJj+0hfnMzF8+slvCJVGUV1RwDFVS4e gNxZyix4JEW+uipBmGynCE8AN4j7Ge/VVPXctbArbq2pcDXIv6tCvjUHI Kck2StUIy6HRUsSeItN2z3jNg0ETpercbjoJ1onJU/JppbaH4OTn7ZRek U1+SJ28TDxtHvFrPSrvDlCW1Gy/s9q5rf/dM5yI40MIwBckbnOtuwkNsO Q==; X-CSE-ConnectionGUID: f9UevKL1QU2nhdwdreRewQ== X-CSE-MsgGUID: lrYfoBLoRN6hA0LN82MizQ== X-IronPort-AV: E=McAfee;i="6700,10204,11236"; a="40974450" X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="40974450" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 17:47:03 -0700 X-CSE-ConnectionGUID: xl/wdLdIRXyUTyqjfrQ0DA== X-CSE-MsgGUID: ISoRcsRATpq4RTb5cusLxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="85851646" Received: from kinlongk-mobl1.amr.corp.intel.com (HELO localhost) ([10.125.111.138]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 17:47:00 -0700 From: Ira Weiny Date: Fri, 25 Oct 2024 19:46:54 -0500 Subject: [PATCH v2 2/4] Documentation/printf: struct resource add start == end special case Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241025-cxl-pra-v2-2-123a825daba2@intel.com> References: <20241025-cxl-pra-v2-0-123a825daba2@intel.com> In-Reply-To: <20241025-cxl-pra-v2-0-123a825daba2@intel.com> To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Jonathan Corbet , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Dan Williams Cc: Fan Ni , Bagas Sanjaya , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-cxl@vger.kernel.org, Ira Weiny X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729903614; l=1292; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=2Vnmkz1SVO7/e2yim2K6ewALI0lceemicbolVGaUX/8=; b=kvjyerXc+lKQyyaaeUCwbbNoLJuzUXi/BXXCKxLDSJzoecD/Ry6z+EZzxbysUBqRCaALtcW0P ETNfQBtuy44Bq8UX0Lk/N4Szdu6e9MvU81rxbSOICM+xXLVSYUh/IqV X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= The code when printing a struct resource will check for start =3D=3D end and only print the start value. Document this special case. Suggested-by: Petr Mladek Signed-off-by: Ira Weiny Reviewed-by: Andy Shevchenko Reviewed-by: Jonathan Cameron Reviewed-by: Petr Mladek --- Documentation/core-api/printk-formats.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core= -api/printk-formats.rst index 14e093da3ccd..552f51046cf3 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst @@ -209,12 +209,17 @@ Struct Resources :: =20 %pr [mem 0x60000000-0x6fffffff flags 0x2200] or + [mem 0x60000000 flags 0x2200] or [mem 0x0000000060000000-0x000000006fffffff flags 0x2200] + [mem 0x0000000060000000 flags 0x2200] %pR [mem 0x60000000-0x6fffffff pref] or + [mem 0x60000000 pref] or [mem 0x0000000060000000-0x000000006fffffff pref] + [mem 0x0000000060000000 pref] =20 For printing struct resources. The ``R`` and ``r`` specifiers result in a -printed resource with (R) or without (r) a decoded flags member. +printed resource with (R) or without (r) a decoded flags member. If start= is +equal to end only print the start value. =20 Passed by reference. =20 --=20 2.47.0 From nobody Mon Nov 25 13:46:17 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 356FE18AEA; Sat, 26 Oct 2024 00:47:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729903627; cv=none; b=FQz+WctL/wNZkUrq/Wj7CblbbyLGsrdZsCMwTZmXmbec0i6xW0jioAvr82I16GwcLyY+/Nv00nhX0tO5/y3el0O8mOG1YWcvVhmTBa33OkgV619Y/ESErpXww4uTpJKCCQqLN7bXRHaPCVYnb7MY4ijf8vOn0cbIF/pEOkRcubo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729903627; c=relaxed/simple; bh=CYq5HpgIrQv2pGkd8rxDhLdRv/q0A6ZcvsaZcaUGFaw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e9q419BFosoA7/qD8+SGxBPdtS1DymZkksAuVLYqN0aodxr5xs/YyI6huRw6q0JS2lWK6FMnhJLUyvMFsMIKBz0A8OieW7IalO70MreymMFjruPQuHjZb5qK6bK8jN6J6FY599F/tV6XK8MhpfEjvF9eg5m50AlelIcy//UTmV0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=h54q4A59; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="h54q4A59" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729903626; x=1761439626; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=CYq5HpgIrQv2pGkd8rxDhLdRv/q0A6ZcvsaZcaUGFaw=; b=h54q4A593C+OFNoFD0W9HLPGxWoWVLRluTB6xcnS/8XjH4q2s5aiZsGg TAPr5kVZXLfz/BY1v8D+2Pg/5N78Isf3HuX8hZtpnUX0FWlfff3E+l0cX JfHsFl/un3qm4QlXXPduSOhDI3u5v5X9XkX70qGO09D7vIBBYCUUOK3rZ 1n3VEHd06ENoiGCQnCCMK4HuMDkNrfz1dMwHIApSxTZW+ukamFaexZrdJ fTQcnJdGmiw42r/EsDT2cIKPqTHbvBcUzBcCX0kXtGnwZ/YILMCLzckvr LWd5gbmydsmHlGdrTVyRPK90erz6XIXvH79d+VrbXAc/PmnN8K9XV3QsW A==; X-CSE-ConnectionGUID: jdlQAYs1QkuTzxBJeaipeQ== X-CSE-MsgGUID: AZFgT++pS5KgJDYOx2G0Yg== X-IronPort-AV: E=McAfee;i="6700,10204,11236"; a="40974461" X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="40974461" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 17:47:06 -0700 X-CSE-ConnectionGUID: +Z8cFED7S1+gWJ+riMfkIA== X-CSE-MsgGUID: 8udnAxQWSZevHBquho7C4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="85851651" Received: from kinlongk-mobl1.amr.corp.intel.com (HELO localhost) ([10.125.111.138]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 17:47:03 -0700 From: Ira Weiny Date: Fri, 25 Oct 2024 19:46:55 -0500 Subject: [PATCH v2 3/4] printf: Add print format (%pra) for struct range Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241025-cxl-pra-v2-3-123a825daba2@intel.com> References: <20241025-cxl-pra-v2-0-123a825daba2@intel.com> In-Reply-To: <20241025-cxl-pra-v2-0-123a825daba2@intel.com> To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Jonathan Corbet , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Dan Williams Cc: Fan Ni , Bagas Sanjaya , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-cxl@vger.kernel.org, Ira Weiny X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729903614; l=7399; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=CYq5HpgIrQv2pGkd8rxDhLdRv/q0A6ZcvsaZcaUGFaw=; b=qtz3hNzMow+Lxg8+EBPNFkW8H1wSBMiDCfDPxA7SWkZi+JcaX/4JoxhIyYEG8Ew9KKhBkbJdu iW4Y5tcS1j2Ct2LZ4yrFkw11qBURMPQktH0Y93ZsikzBwYCH+cc9/QV X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= The use of struct range in the CXL subsystem is growing. In particular, the addition of Dynamic Capacity devices uses struct range in a number of places which are reported in debug and error messages. To wit requiring the printing of the start/end fields in each print became cumbersome. Dan Williams mentions in [1] that it might be time to have a print specifier for struct range similar to struct resource A few alternatives were considered including '%par', '%r', and '%pn'. %pra follows that struct range is similar to struct resource (%p[rR]) but needs to be different. Based on discussions with Petr and Andy '%pra' was chosen.[2] Andy also suggested to keep the range prints similar to struct resource though combined code. Add hex_range() to handle printing for both pointer types. Finally introduce DEFINE_RANGE() as a parallel to DEFINE_RES_*() and use it in the tests. Cc: Jonathan Corbet (maintainer:DOCUMENTATION) Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org (open list) Link: https://lore.kernel.org/all/663922b475e50_d54d72945b@dwillia2-xfh.jf.= intel.com.notmuch/ [1] Link: https://lore.kernel.org/all/66cea3bf3332f_f937b29424@iweiny-mobl.notm= uch/ [2] Suggested-by: "Dan Williams" Signed-off-by: Ira Weiny Reviewed-by: Andy Shevchenko --- Changes: [Andy: s/resource_and_range/resource_or_range/] --- Documentation/core-api/printk-formats.rst | 13 +++++++ include/linux/range.h | 6 ++++ lib/test_printf.c | 17 +++++++++ lib/vsprintf.c | 57 +++++++++++++++++++++++++++= ---- 4 files changed, 87 insertions(+), 6 deletions(-) diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core= -api/printk-formats.rst index 552f51046cf3..ecccc0473da9 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst @@ -236,6 +236,19 @@ width of the CPU data path. =20 Passed by reference. =20 +Struct Range +------------ + +:: + + %pra [range 0x0000000060000000-0x000000006fffffff] or + [range 0x0000000060000000] + +For printing struct range. struct range holds an arbitrary range of u64 +values. If start is equal to end only print the start value. + +Passed by reference. + DMA address types dma_addr_t ---------------------------- =20 diff --git a/include/linux/range.h b/include/linux/range.h index 6ad0b73cb7ad..1358d4b1807a 100644 --- a/include/linux/range.h +++ b/include/linux/range.h @@ -31,4 +31,10 @@ int clean_sort_range(struct range *range, int az); =20 void sort_range(struct range *range, int nr_range); =20 +#define DEFINE_RANGE(_start, _end) \ +(struct range) { \ + .start =3D (_start), \ + .end =3D (_end), \ + } + #endif diff --git a/lib/test_printf.c b/lib/test_printf.c index 5afdf5efc627..59dbe4f9a4cb 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -432,6 +432,22 @@ struct_resource(void) "%pR", &test_resource); } =20 +static void __init +struct_range(void) +{ + struct range test_range =3D DEFINE_RANGE(0xc0ffee00ba5eba11, + 0xc0ffee00ba5eba11); + test("[range 0xc0ffee00ba5eba11]", "%pra", &test_range); + + test_range =3D DEFINE_RANGE(0xc0ffee, 0xba5eba11); + test("[range 0x0000000000c0ffee-0x00000000ba5eba11]", + "%pra", &test_range); + + test_range =3D DEFINE_RANGE(0xba5eba11, 0xc0ffee); + test("[range 0x00000000ba5eba11-0x0000000000c0ffee]", + "%pra", &test_range); +} + static void __init addr(void) { @@ -807,6 +823,7 @@ test_pointer(void) symbol_ptr(); kernel_ptr(); struct_resource(); + struct_range(); addr(); escaped_str(); hex_string(); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 09f022ba1c05..9e76350bd77d 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1039,6 +1039,20 @@ static const struct printf_spec default_dec04_spec = =3D { .flags =3D ZEROPAD, }; =20 +static noinline_for_stack +char *hex_range(char *buf, char *end, u64 start_val, u64 end_val, + struct printf_spec spec) +{ + buf =3D number(buf, end, start_val, spec); + if (start_val =3D=3D end_val) + return buf; + + if (buf < end) + *buf =3D '-'; + ++buf; + return number(buf, end, end_val, spec); +} + static noinline_for_stack char *resource_string(char *buf, char *end, struct resource *res, struct printf_spec spec, const char *fmt) @@ -1115,11 +1129,7 @@ char *resource_string(char *buf, char *end, struct r= esource *res, p =3D string_nocheck(p, pend, "size ", str_spec); p =3D number(p, pend, resource_size(res), *specp); } else { - p =3D number(p, pend, res->start, *specp); - if (res->start !=3D res->end) { - *p++ =3D '-'; - p =3D number(p, pend, res->end, *specp); - } + p =3D hex_range(p, pend, res->start, res->end, *specp); } if (decode) { if (res->flags & IORESOURCE_MEM_64) @@ -1140,6 +1150,31 @@ char *resource_string(char *buf, char *end, struct r= esource *res, return string_nocheck(buf, end, sym, spec); } =20 +static noinline_for_stack +char *range_string(char *buf, char *end, const struct range *range, + struct printf_spec spec, const char *fmt) +{ + char sym[sizeof("[range 0x0123456789abcdef-0x0123456789abcdef]")]; + char *p =3D sym, *pend =3D sym + sizeof(sym); + + struct printf_spec range_spec =3D { + .field_width =3D 2 + 2 * sizeof(range->start), /* 0x + 2 * 8 */ + .flags =3D SPECIAL | SMALL | ZEROPAD, + .base =3D 16, + .precision =3D -1, + }; + + if (check_pointer(&buf, end, range, spec)) + return buf; + + p =3D string_nocheck(p, pend, "[range ", default_str_spec); + p =3D hex_range(p, pend, range->start, range->end, range_spec); + *p++ =3D ']'; + *p =3D '\0'; + + return string_nocheck(buf, end, sym, spec); +} + static noinline_for_stack char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, const char *fmt) @@ -2229,6 +2264,15 @@ char *fwnode_string(char *buf, char *end, struct fwn= ode_handle *fwnode, return widen_string(buf, buf - buf_start, end, spec); } =20 +static noinline_for_stack +char *resource_or_range(const char *fmt, char *buf, char *end, void *ptr, + struct printf_spec spec) +{ + if (*fmt =3D=3D 'r' && fmt[1] =3D=3D 'a') + return range_string(buf, end, ptr, spec, fmt); + return resource_string(buf, end, ptr, spec, fmt); +} + int __init no_hash_pointers_enable(char *str) { if (no_hash_pointers) @@ -2277,6 +2321,7 @@ char *rust_fmt_argument(char *buf, char *end, void *p= tr); * - 'Bb' as above with module build ID (for use in backtraces) * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref] * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201] + * - 'ra' For struct ranges, e.g., [range 0x0000000000000000 - 0x000000000= 00000ff] * - 'b[l]' For a bitmap, the number of bits is determined by the field * width which must be explicitly specified either as part of the * format string '%32b[l]' or through '%*b[l]', [l] selects @@ -2401,7 +2446,7 @@ char *pointer(const char *fmt, char *buf, char *end, = void *ptr, return symbol_string(buf, end, ptr, spec, fmt); case 'R': case 'r': - return resource_string(buf, end, ptr, spec, fmt); + return resource_or_range(fmt, buf, end, ptr, spec); case 'h': return hex_string(buf, end, ptr, spec, fmt); case 'b': --=20 2.47.0 From nobody Mon Nov 25 13:46:17 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 D645A1805E; Sat, 26 Oct 2024 00:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729903630; cv=none; b=HzM8SWtN+wueJAFFR/wgQO0yKfsdEPO0ZCmkGLZ6w/3ljxkLN4OtalfMX1Z1JDfrM932Ci78CkCIQ5VaTHyMLLTeWDOBGvHDwBQspsxu/KAilqEBfdnzk0z0uw1zgcliSXeA/yYIfmimZrXNlJ3gB97VUxO5wPSuLEBGqlT1Orc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729903630; c=relaxed/simple; bh=yxBEWdpHaV6bcSUejItXoVU+ob4Ni/SGYV+LJ2p6dCE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FFJFo/H1dKVToEVmHT2ZtC52HhGDzjsQtlq5h9QuXBYxULP/0oaE5M5uhmkFNTYAu0FcX02aYLYLdhXVYL7CiEsp3qcPue4swhyerZxxERf8O18wIBN5tw8kZka5FABB/L4GT/VVCoR4J/q+cw21oncsQqxyfbZR7sJgd/jFdzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Zcfq3NoE; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Zcfq3NoE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729903629; x=1761439629; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=yxBEWdpHaV6bcSUejItXoVU+ob4Ni/SGYV+LJ2p6dCE=; b=Zcfq3NoE0J+zLJnqlrm8OV7Xm+eDiNfNZeEZD01vaT54dMGV4beqjPIE ll6dnE7y6NLTF/SLhIo87nMdaj9+vSPvc0g6egz9s1sghK1o5Y/Ux9+fE 2p53mgjuJHtkEH55KIV4w5AP3x8Fb9pFNztjzxW8AXglN+lcLhZClVt3S jDv5gIlRLRjrj94pdKSMsX9JEC/BHP1s2DwhkiZjdiYeaPbyP+KXiN1Gn AVyi3vDlSqMeEYl4m25zGeLINzhVHrj3ZYJv9watY4za9k2/8NP5UekDm Z4cDTgZpneGE2kcwIQEyIvpNsRkxef86iKibokGcToRx/C2hqiL+87Mw8 g==; X-CSE-ConnectionGUID: lxKWPCLQSUeTx43MeKs2bg== X-CSE-MsgGUID: o8zGigyJTICqQzlfvw+gfg== X-IronPort-AV: E=McAfee;i="6700,10204,11236"; a="40974473" X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="40974473" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 17:47:08 -0700 X-CSE-ConnectionGUID: 5uLdAEvPT6au9dmIRrD+jA== X-CSE-MsgGUID: AR5ymz5LROiBOT7S3qAlTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="85851658" Received: from kinlongk-mobl1.amr.corp.intel.com (HELO localhost) ([10.125.111.138]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 17:47:06 -0700 From: Ira Weiny Date: Fri, 25 Oct 2024 19:46:56 -0500 Subject: [PATCH v2 4/4] cxl/cdat: Use %pra for dpa range outputs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241025-cxl-pra-v2-4-123a825daba2@intel.com> References: <20241025-cxl-pra-v2-0-123a825daba2@intel.com> In-Reply-To: <20241025-cxl-pra-v2-0-123a825daba2@intel.com> To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Jonathan Corbet , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Dan Williams Cc: Fan Ni , Bagas Sanjaya , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-cxl@vger.kernel.org, Ira Weiny X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729903614; l=1497; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=yxBEWdpHaV6bcSUejItXoVU+ob4Ni/SGYV+LJ2p6dCE=; b=AdvYAt7HP7Phb77jMxIC63bIRrVcMNTgBmLTw6viyhQkS5JB8emh4NT8CovuO2TcKoEgYN7Ie 4bEEH+YcjRODfngW74iQXLPZKDNpwKlCZgQp3BhNZlDYzt6z1bDlUoB X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= Now that there is a printf specifier for struct range use it to enhance the debug output of CDAT data. Reviewed-by: Alison Schofield Signed-off-by: Ira Weiny --- drivers/cxl/core/cdat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/cxl/core/cdat.c b/drivers/cxl/core/cdat.c index ef1621d40f05..438869df241a 100644 --- a/drivers/cxl/core/cdat.c +++ b/drivers/cxl/core/cdat.c @@ -247,8 +247,8 @@ static void update_perf_entry(struct device *dev, struc= t dsmas_entry *dent, dpa_perf->dpa_range =3D dent->dpa_range; dpa_perf->qos_class =3D dent->qos_class; dev_dbg(dev, - "DSMAS: dpa: %#llx qos: %d read_bw: %d write_bw %d read_lat: %d write_la= t: %d\n", - dent->dpa_range.start, dpa_perf->qos_class, + "DSMAS: dpa: %pra qos: %d read_bw: %d write_bw %d read_lat: %d write_lat= : %d\n", + &dent->dpa_range, dpa_perf->qos_class, dent->coord[ACCESS_COORDINATE_CPU].read_bandwidth, dent->coord[ACCESS_COORDINATE_CPU].write_bandwidth, dent->coord[ACCESS_COORDINATE_CPU].read_latency, @@ -279,8 +279,8 @@ static void cxl_memdev_set_qos_class(struct cxl_dev_sta= te *cxlds, range_contains(&pmem_range, &dent->dpa_range)) update_perf_entry(dev, dent, &mds->pmem_perf); else - dev_dbg(dev, "no partition for dsmas dpa: %#llx\n", - dent->dpa_range.start); + dev_dbg(dev, "no partition for dsmas dpa: %pra\n", + &dent->dpa_range); } } =20 --=20 2.47.0