From patchwork Wed Feb 28 00:00:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 207658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3125063dyb; Tue, 27 Feb 2024 20:07:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVgXiS1q7g7tFqk5UMR/2MdvRAtkN6W3msdE73h5iwHCEckoVkIYOu0v7Kzbq4hi70zgyqi3gdtNNxKPXgCrj/GnAge6A== X-Google-Smtp-Source: AGHT+IF7kxLFTHqu9TxdiZ+C898lagylRCZAcbm3BjnHJFQONzShTm5VAddZ5I5c9/KJ8iXPlgdm X-Received: by 2002:a05:6512:1156:b0:512:b426:53e8 with SMTP id m22-20020a056512115600b00512b42653e8mr9475781lfg.30.1709093239798; Tue, 27 Feb 2024 20:07:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709093239; cv=pass; d=google.com; s=arc-20160816; b=FksulMnJuJItf6rSxql9krDKKNEqV4C649Fjo5lnxk/zQTjTEnqrYpf83Z0PY6YkQL 2F7QhyeqStSDcJso8sUPjTyPzEaLkY4RfbLk0Ohd8I18jMxhSz915a3zh//FKdj7x2ld Kqur+0misTs9qhBaVspSASGDs98blxGx4GUr2JR20kQdm9ljizsCEQ1n2ooU312HgoeS 1e3JDrAdzzh/SeExbubE6nplgALfX5ZzKf+UcSchvPcjqWamOnfZoNLZ7boYI6eF2O1B Jhyl4BrQKYDvcahJe7nYGGipQ8JUPv8MEiBvcWT1XvKrz5ijLwa2gqje3NEQjvEceZ8c t1BQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=XjThLvc0bEs0bLv81qQ4QgPb0qI9It17bTsCyGqXnrI=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=cKPwHgKgzVktJAKjJxxnkSautTTty8VhSpLsbee1v9/b5gpSGW/4v5Sq2G5iEyqBI4 HHBZyM7aTP40y7joqTpdd2cCUeiJ56Igyi9l8/BU17hkR1o1kveaQ+eSgSX/qFglqhag 5rt32Gw9NzYfJjOmezONTuy8RwB7tVRGQ+EEd+UlXa6Uld+C96AQVw13flyUNjXb/3g7 s5h4W/kzOw2UxSoDyEAz/S308Iqzl9vZcvrMAhEqDoHfv7xhslpeQmH47Xn71yp3KOjg udDwVXuaejClSqa9dWnU2aZorBvc5obRqKRVWFtQ63DcXmuevWxCKZyFUbKWhra6JYzV Y/KQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IDvdmSUR; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84245-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84245-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kh6-20020a170906f80600b00a3e71ba9290si1292918ejb.216.2024.02.27.20.07.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 20:07:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84245-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IDvdmSUR; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84245-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84245-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C1C731F24866 for ; Wed, 28 Feb 2024 00:01:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74E532C19D; Wed, 28 Feb 2024 00:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IDvdmSUR" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 18C7D381CB; Wed, 28 Feb 2024 00:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078420; cv=none; b=QuBcEpiFD30RnlzT1Y/+XM3Gcw0RA9r/qypnRmnwIn0Tm7rcDkwMcDAwE8s8F6hE1IkD8TNuKnD5Ee8tBF6nc4WGyVOb/JQQacrRH3TpAT74mMBHVT6N6SRmUMylKTMQTqhbRO6HGvOqOMyc2MOQrtKwLCydzWbqP8c4mWR5xag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078420; c=relaxed/simple; bh=kTuJBiH0He/AE/VlrZQG9PWPYUT9ap2kxnqVhwAzT6Q=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Mc3YEn38TDYJ5ACJ1l6HATF+cMnTi+eERJ+R3J92K/LGCoWZUgt7VCUOc7JzEjacxliX5NARoaYKqa6phbu6K9LhXlz3qpG0oMpyHL+e7C5NWiZ7ApRqqKo72FCXng/24POrzfo6ryo0L43TEhD92RIE/7ofZz7eUkt58zQmcew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IDvdmSUR; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709078418; x=1740614418; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=kTuJBiH0He/AE/VlrZQG9PWPYUT9ap2kxnqVhwAzT6Q=; b=IDvdmSUR6kYU4pmPzIpQ9Gf1uab5TOsbW/ZI7gDVahact8+EfyDDokgr xYCMBYhxgQ9EO352jB1riDdxdR1dVThVDlDFdSoI5tqNAOer+ijxKU+Iw cnlzSd2/fWayDHJCClDuFq4+JVaeKKwO14Wz0x/LmxlvWGigROUqt2F/l tY/LWcx0IX6M8MZ097eVa/kxo9RJGpPtwdP0wHuqUjYn7Qf2ik8a2Lbyl 7Tr/EUnPYWEj9dcFXx7XvKvXmlEzt+DafWJk/9t6j8sMApH3fURHmKP0h okB+sq+19R/cIuvFS1ATR8ARJEwRciZ/8zC3sphD6m9Aloa9LzpPJX8XR g==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="25919833" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="25919833" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7439162" Received: from linux.intel.com ([10.54.29.200]) by fmviesa006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:17 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id 71BFC580B9A; Tue, 27 Feb 2024 16:00:16 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 1/9] platform/x86/intel/sdsi: Set message size during writes Date: Tue, 27 Feb 2024 16:00:08 -0800 Message-Id: <20240228000016.1685518-2-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792113100217844138 X-GMAIL-MSGID: 1792114152570583488 New mailbox commands will support sending multi packet writes and updated firmware now requires that the message size be written for all commands along with the packet size. Since the driver doesn't perform writes larger than the packet size, set the message size to the same value. Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V2 - no changes drivers/platform/x86/intel/sdsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c index 556e7c6dbb05..a70c071de6e2 100644 --- a/drivers/platform/x86/intel/sdsi.c +++ b/drivers/platform/x86/intel/sdsi.c @@ -252,6 +252,7 @@ static int sdsi_mbox_cmd_write(struct sdsi_priv *priv, struct sdsi_mbox_info *in FIELD_PREP(CTRL_SOM, 1) | FIELD_PREP(CTRL_RUN_BUSY, 1) | FIELD_PREP(CTRL_READ_WRITE, 1) | + FIELD_PREP(CTRL_MSG_SIZE, info->size) | FIELD_PREP(CTRL_PACKET_SIZE, info->size); writeq(control, priv->control_addr); From patchwork Wed Feb 28 00:00:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 207591 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3078998dyb; Tue, 27 Feb 2024 17:46:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXSQFz2NAw4o16aD0Zik9d5ynwJ6ALYTbuCYRxcbd++OzeS7Ld3z+W0hIlyY6tt5kWKq57I02is1ywi0q/OrOnXZwchVA== X-Google-Smtp-Source: AGHT+IEVITwSqK8I60Y31yjdImK1Z4vUlYYjh40pLS1J2BamX/MbgFjoDANYo0w+UADNX20X2vFv X-Received: by 2002:a2e:99d5:0:b0:2d0:b758:93a5 with SMTP id l21-20020a2e99d5000000b002d0b75893a5mr6916794ljj.18.1709084805610; Tue, 27 Feb 2024 17:46:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709084805; cv=pass; d=google.com; s=arc-20160816; b=y/cbDw15KEo7MzbZeYATlHCQbYil4aCzkCtmLmFFq3/4RXTshqKM/oGY1OjaLJBuuh Kb4NcqGK7+l9aTxqq8EIGZt+DwrkKDiqgnE8e/DoiEG/4mKpt98Xb/6+0zmXpAAcooYq wxnCNJvPshfPwD8Xzn1np1/UpA59iGmShHalZZvL1jd4oRf0FcOfDuDW2EB51H12hv4V 70nXjTZz3eOh7R9VFXLICu3R1Lni0w6Y+jDx3mDhO7rM2oBVGxMl4yNrFZCVJ97rBWnW J1AiqNba70bbh8bepnS2SSvzxAXBCDcqxZJiqWkh2eU1HpAPq3DY/MFwuh8yeWT67aSM TD4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=zRTLjsYwJzvI1s2Bp9S11TzSO+Nrwdmn+sIRJ1u8UyE=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=dJ+6xsBSoRTP8gXOZjyFdPz9HPUALCwAqWRwGWH8mS5pdquKni08oSTbmx8JzlSMnS BTrERSx0BkLQsOa+1ox0+vXX3AxxDdyD6w5uYOEYe+2AK8Tvsf4CUbbPDFoIkMeHN9TU BbjHFlhXSjGPwcSz284Xo262FwP7Z3yaBoIEQfcdKvA4tOPUa55uPuozP6WEkI2QH9Qq wDXoM9ozmA9YtXbXhsycffEIkA68VTGHyLL+lyiPjgQeZGXTDGwi1oSl/3/Dw0hLjPlr Q2bHI1z3FJRZRq6X3Yrk1MXPVkmIaKdpLH/dKz/GeWq3fIlU5PTzrF2Vbxetw1ZC714s ffLg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IgWxomVA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84244-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84244-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x23-20020a50d617000000b005664864e5e7si788419edi.641.2024.02.27.17.46.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 17:46:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84244-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IgWxomVA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84244-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84244-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 70F741F243B2 for ; Wed, 28 Feb 2024 00:01:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74E9D2C1A2; Wed, 28 Feb 2024 00:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IgWxomVA" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 1E7EF3838A; Wed, 28 Feb 2024 00:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078420; cv=none; b=XRMylcBt3OuCWdSyhXjH6PcKoAWiGMatGXdM/V9rHAST7BT3e5rULl4m+lQ1JZdfgz+iXCAMiWwWx/WI9KUoBLVIWIu8wUDCV/hU4fxgMzZ+r2uGoMAuYryReb9eGDv2u80oxuMIibm1XRjWvRIAcGO3cCW9hN6soTDhuAgv7Ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078420; c=relaxed/simple; bh=tbwiqecWv333Dv92Qlp888aKfOTOHtcWbrck4ee1Idk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kDrFx9ilh3ueYD2we/TWQsX76MbCR4YNLJIJb+v1RXfDJ7ykBCL8B2yPLFQqospuBcDig8gVrs+UdBE/kbv32Y9MFNDaUoRVJHBSV3u79A9uBc4JDma2AVa5ozl5+f6gKY4sws2xyCpl1stLqEYWdu4oWCsadLrPRm6NIXc/6fk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IgWxomVA; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709078418; x=1740614418; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=tbwiqecWv333Dv92Qlp888aKfOTOHtcWbrck4ee1Idk=; b=IgWxomVA9fj3D7qjH0m+t8Bx7s7mtjbs5BPvr0NU1cLzweckt0XCfznt uIKiwPqxuDrb/c8RCadjIiFDUpNt+YnY+vid2R8vtX9s941KjxU2o2LNX XdttJJt5VADq8q8QECDcrPn2wMV0eIOidHnm+7bYZSN82ByANYDrbtOp0 HCSo+h1bdr7jumr1RvmLApHsz4w2czrljefzPLCY43BoM4CHwO33URepg WeEccyMNdhkTP5Mgtaie8Rm3f1daSWScm8LvnWkqq5LJFiB488tsXEZ0F H+V1N/NZ41xOMyk5b5BHvz+VBwRhLRsoH5HuhEJ9/YkXXD0/QrrSuu7u7 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14604935" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="14604935" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7176939" Received: from linux.intel.com ([10.54.29.200]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:17 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id A789B580D7F; Tue, 27 Feb 2024 16:00:16 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 2/9] platform/x86/intel/sdsi: Combine read and write mailbox flows Date: Tue, 27 Feb 2024 16:00:09 -0800 Message-Id: <20240228000016.1685518-3-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792105309141129789 X-GMAIL-MSGID: 1792105309141129789 The current mailbox commands are either read-only or write-only and the flow is different for each. New commands will need to send and receive data. In preparation for these commands, create a common polling function to handle sending data and receiving in the same transaction. Signed-off-by: David E. Box Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Ilpo Järvinen --- V2 - In sdsi_cmd_read() remove unnecessary check for non-zero packet_size in do loop since the loop is exited earlier when packet_size is zero. drivers/platform/x86/intel/sdsi.c | 79 +++++++++++++++++-------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c index a70c071de6e2..d80c2dc0ce71 100644 --- a/drivers/platform/x86/intel/sdsi.c +++ b/drivers/platform/x86/intel/sdsi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -156,8 +157,8 @@ static int sdsi_status_to_errno(u32 status) } } -static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *info, - size_t *data_size) +static int sdsi_mbox_poll(struct sdsi_priv *priv, struct sdsi_mbox_info *info, + size_t *data_size) { struct device *dev = priv->dev; u32 total, loop, eom, status, message_size; @@ -166,18 +167,10 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf lockdep_assert_held(&priv->mb_lock); - /* Format and send the read command */ - control = FIELD_PREP(CTRL_EOM, 1) | - FIELD_PREP(CTRL_SOM, 1) | - FIELD_PREP(CTRL_RUN_BUSY, 1) | - FIELD_PREP(CTRL_PACKET_SIZE, info->size); - writeq(control, priv->control_addr); - /* For reads, data sizes that are larger than the mailbox size are read in packets. */ total = 0; loop = 0; do { - void *buf = info->buffer + (SDSI_SIZE_MAILBOX * loop); u32 packet_size; /* Poll on ready bit */ @@ -195,6 +188,11 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf if (ret) break; + if (!packet_size) { + sdsi_complete_transaction(priv); + break; + } + /* Only the last packet can be less than the mailbox size. */ if (!eom && packet_size != SDSI_SIZE_MAILBOX) { dev_err(dev, "Invalid packet size\n"); @@ -208,9 +206,13 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf break; } - sdsi_memcpy64_fromio(buf, priv->mbox_addr, round_up(packet_size, SDSI_SIZE_CMD)); + if (info->buffer) { + void *buf = info->buffer + array_size(SDSI_SIZE_MAILBOX, loop); - total += packet_size; + sdsi_memcpy64_fromio(buf, priv->mbox_addr, + round_up(packet_size, SDSI_SIZE_CMD)); + total += packet_size; + } sdsi_complete_transaction(priv); } while (!eom && ++loop < MBOX_MAX_PACKETS); @@ -230,16 +232,33 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf dev_warn(dev, "Read count %u differs from expected count %u\n", total, message_size); - *data_size = total; + if (data_size) + *data_size = total; return 0; } -static int sdsi_mbox_cmd_write(struct sdsi_priv *priv, struct sdsi_mbox_info *info) +static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *info, + size_t *data_size) +{ + u64 control; + + lockdep_assert_held(&priv->mb_lock); + + /* Format and send the read command */ + control = FIELD_PREP(CTRL_EOM, 1) | + FIELD_PREP(CTRL_SOM, 1) | + FIELD_PREP(CTRL_RUN_BUSY, 1) | + FIELD_PREP(CTRL_PACKET_SIZE, info->size); + writeq(control, priv->control_addr); + + return sdsi_mbox_poll(priv, info, data_size); +} + +static int sdsi_mbox_cmd_write(struct sdsi_priv *priv, struct sdsi_mbox_info *info, + size_t *data_size) { u64 control; - u32 status; - int ret; lockdep_assert_held(&priv->mb_lock); @@ -256,20 +275,7 @@ static int sdsi_mbox_cmd_write(struct sdsi_priv *priv, struct sdsi_mbox_info *in FIELD_PREP(CTRL_PACKET_SIZE, info->size); writeq(control, priv->control_addr); - /* Poll on ready bit */ - ret = readq_poll_timeout(priv->control_addr, control, control & CTRL_READY, - MBOX_POLLING_PERIOD_US, MBOX_TIMEOUT_US); - - if (ret) - goto release_mbox; - - status = FIELD_GET(CTRL_STATUS, control); - ret = sdsi_status_to_errno(status); - -release_mbox: - sdsi_complete_transaction(priv); - - return ret; + return sdsi_mbox_poll(priv, info, data_size); } static int sdsi_mbox_acquire(struct sdsi_priv *priv, struct sdsi_mbox_info *info) @@ -313,7 +319,8 @@ static int sdsi_mbox_acquire(struct sdsi_priv *priv, struct sdsi_mbox_info *info return ret; } -static int sdsi_mbox_write(struct sdsi_priv *priv, struct sdsi_mbox_info *info) +static int sdsi_mbox_write(struct sdsi_priv *priv, struct sdsi_mbox_info *info, + size_t *data_size) { int ret; @@ -323,7 +330,7 @@ static int sdsi_mbox_write(struct sdsi_priv *priv, struct sdsi_mbox_info *info) if (ret) return ret; - return sdsi_mbox_cmd_write(priv, info); + return sdsi_mbox_cmd_write(priv, info, data_size); } static int sdsi_mbox_read(struct sdsi_priv *priv, struct sdsi_mbox_info *info, size_t *data_size) @@ -342,7 +349,7 @@ static int sdsi_mbox_read(struct sdsi_priv *priv, struct sdsi_mbox_info *info, s static ssize_t sdsi_provision(struct sdsi_priv *priv, char *buf, size_t count, enum sdsi_command command) { - struct sdsi_mbox_info info; + struct sdsi_mbox_info info = {}; int ret; if (count > (SDSI_SIZE_WRITE_MSG - SDSI_SIZE_CMD)) @@ -364,7 +371,9 @@ static ssize_t sdsi_provision(struct sdsi_priv *priv, char *buf, size_t count, ret = mutex_lock_interruptible(&priv->mb_lock); if (ret) goto free_payload; - ret = sdsi_mbox_write(priv, &info); + + ret = sdsi_mbox_write(priv, &info, NULL); + mutex_unlock(&priv->mb_lock); free_payload: @@ -408,7 +417,7 @@ static ssize_t certificate_read(u64 command, struct sdsi_priv *priv, char *buf, loff_t off, size_t count) { - struct sdsi_mbox_info info; + struct sdsi_mbox_info info = {}; size_t size; int ret; From patchwork Wed Feb 28 00:00:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 207656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3122630dyb; Tue, 27 Feb 2024 20:00:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6l00U14MKv+IfH4m0BP0DWWHYqDZXo8dzS1Cp/NSLoYIS9rxX7NMer508AH0xXgDzKoTxA79nL+WodQDQAHqKofXsJg== X-Google-Smtp-Source: AGHT+IEx+YYSVsWaSAwLz8sylZ9DhwVlEgNdiG5itCLrqKAm9uUj2nqoMOf4EtuopeITGu4y3V+3 X-Received: by 2002:a05:6358:292a:b0:17b:672a:4de3 with SMTP id y42-20020a056358292a00b0017b672a4de3mr13982313rwb.0.1709092840926; Tue, 27 Feb 2024 20:00:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709092840; cv=pass; d=google.com; s=arc-20160816; b=lTJvfULrvRyqyxGE5ns3UNgOoIGMzhP7m4CM30asjjVgwm9siWOf9VLwUYaOcUwodX uhI2r5tPDJ5Cjv3NI0Zj1WXPFhz2Z1j2THh9C8j5FZoAyaWZWSv18M87DvhOJSSF8aTl xQ+Q4tgXqx9q1T7+Z2oYhxxadgSzvF0wea3nQRSwFy3losfOxoQfPutArtQ6OuWrqQeE 8a+Eo8HZe1Pti1ai7e1xbF8tliyICb6dDCdTXL48Fw1dZGtUq8XQTwQ2dkbK1eus4/LE VcU63JByOAGQpt8PDIohC2PazKRK9L+qA+XvEjN1eanrtZgNlFh6vVlOKnG5eWThkZdi kaeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=2seSwZ5UfL6cWXX5apWHQ8Rll6Uk4Y1qyEy1olnGjqA=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=M+1oLHCORpVNfABmf8B5H+StBohJsHSDVY6NXszutTfc193nPSHwJCQiLRQlVSIovG E3s969xB1abI/hkzBxwliMj7OLsrN247XXLSwCpQfQ422Xi18XmHVPvyZbDBQf/ip2Sj kSOPjgYox9gekbSYcGh+Y9us+wZl5MYVypfoiWrWHM9NELpQH34MWdcmZxZ4GhHjgggm eAq81pqF4//Mx4PxAxAWG21RF2UfkpfqrvvlqCf29+PUDCN+ycPjWfn9RtmVN9MCKUV/ geCQi2DRq9CcsyFbNvC+Y7l0h83Ep3m8ZdS59Oy7jW8lsgEODC3m6vpCRKIcas56y9yn qp6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WILPckTW; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84246-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84246-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n17-20020a634d51000000b005d91365dedasi6664502pgl.613.2024.02.27.20.00.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 20:00:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84246-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WILPckTW; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84246-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84246-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6F81BB2A08D for ; Wed, 28 Feb 2024 00:02:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FB50339A8; Wed, 28 Feb 2024 00:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WILPckTW" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 9CF22364; Wed, 28 Feb 2024 00:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078421; cv=none; b=a7LP5QPfAMJGwSArDZH1nl0KOFSq5DZJJd4aSPLBUt6NDvH6xq9JtzDENYEPZA8wI1N1OFi2ctbVfoh4ogXsOzSq0Xe11KZ7cRqzaP8T6hK5/wEOj821i5h8tcNBvc7Sk0c0aY8Hwcovt+ukERcGegVP5R31abxkmfZM4FWRNj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078421; c=relaxed/simple; bh=Cjids9Y5fgG2A+arpd84T9h3UMgARRlLtTbh6HeGD1E=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fbkEQWP4A3vjoepFOcYwLuaxVHVojv7JzWP5b2GHhRVGfcvF0GFlrt8gKBYTNYqq2mMTRpQMt2Nf97vAitj1VrcyHEjuuLiLqOfxHCpc2Oft7TRhcdp5/eFeasAJkBD2M3CQyCvcAdg65NXsVH9vdoX+xFC4DII2AmKTAzvUVIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WILPckTW; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709078420; x=1740614420; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Cjids9Y5fgG2A+arpd84T9h3UMgARRlLtTbh6HeGD1E=; b=WILPckTWAqOQTDXh4nWq56bwd7ShdkPP7fXKWTvWL+9ASN93Un5i6iJ3 ZNqH2qszStxHmYISDEaRBdiVxOvQX7cwQiDWwd8UMHdReGJibT96OO6cf Ezw1GJLCFt8hmaOmxCEZlNzOsKq5Ndjht2uB9AePm0QbHdshduZOVF71s 9OEWwLP6Ap9eCqM19mkmF2DdQvLzRWiy14w5ZRikHV26B5vnIypkdXkdm U3+s8hAAKK970RIte1aVYeqdVuwI0e653fX1JZQoszAF+puoAybm3D0OK aiOt40iVmBr6jrfP95LaQL4q5gF0HEPYKq+GlJ20GmVOVPXCCykGz19PH Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14604937" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="14604937" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7176940" Received: from linux.intel.com ([10.54.29.200]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:17 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id D44BF580D7F; Tue, 27 Feb 2024 16:00:16 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 3/9] platform/x86/intel/sdsi: Add in-band BIOS lock support Date: Tue, 27 Feb 2024 16:00:10 -0800 Message-Id: <20240228000016.1685518-4-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792113734694685054 X-GMAIL-MSGID: 1792113734694685054 From: Kuppuswamy Sathyanarayanan As per SDSi in-band interface specification, sec titled "BIOS lock for in-band provisioning", when IB_LOCK bit is set in control qword, the SDSI agent is only allowed to perform the read flow, but not allowed to provision license blob or license key. So add check for it in sdsi_provision(). Signed-off-by: Kuppuswamy Sathyanarayanan Signed-off-by: David E. Box --- V2 - Move sdsi_ib_locked() check after overflow check drivers/platform/x86/intel/sdsi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c index d80c2dc0ce71..bb3eaf5eb382 100644 --- a/drivers/platform/x86/intel/sdsi.c +++ b/drivers/platform/x86/intel/sdsi.c @@ -67,6 +67,7 @@ #define CTRL_OWNER GENMASK(5, 4) #define CTRL_COMPLETE BIT(6) #define CTRL_READY BIT(7) +#define CTRL_INBAND_LOCK BIT(32) #define CTRL_STATUS GENMASK(15, 8) #define CTRL_PACKET_SIZE GENMASK(31, 16) #define CTRL_MSG_SIZE GENMASK(63, 48) @@ -346,6 +347,11 @@ static int sdsi_mbox_read(struct sdsi_priv *priv, struct sdsi_mbox_info *info, s return sdsi_mbox_cmd_read(priv, info, data_size); } +static bool sdsi_ib_locked(struct sdsi_priv *priv) +{ + return !!FIELD_GET(CTRL_INBAND_LOCK, readq(priv->control_addr)); +} + static ssize_t sdsi_provision(struct sdsi_priv *priv, char *buf, size_t count, enum sdsi_command command) { @@ -355,6 +361,10 @@ static ssize_t sdsi_provision(struct sdsi_priv *priv, char *buf, size_t count, if (count > (SDSI_SIZE_WRITE_MSG - SDSI_SIZE_CMD)) return -EOVERFLOW; + /* Make sure In-band lock is not set */ + if (sdsi_ib_locked(priv)) + return -EPERM; + /* Qword aligned message + command qword */ info.size = round_up(count, SDSI_SIZE_CMD) + SDSI_SIZE_CMD; From patchwork Wed Feb 28 00:00:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 207652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3117912dyb; Tue, 27 Feb 2024 19:43:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX0XEHsD/mfw6jA/UdSBCnSGcXba8UQrCEyXzSJd/n8EbCAd0jHyQ076naJpV8dM/fDqM71OpWDnoGuyNNOfd8xvyh8Wg== X-Google-Smtp-Source: AGHT+IENjMnBfLq0dc1uw0JRL18q2t2aRxHCdhUh3Y8wjFrlzuhBPJiI1jFViZT5OQkZPqcixNeg X-Received: by 2002:a05:6808:f0c:b0:3c1:48de:5f1a with SMTP id m12-20020a0568080f0c00b003c148de5f1amr4506541oiw.11.1709091811270; Tue, 27 Feb 2024 19:43:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709091811; cv=pass; d=google.com; s=arc-20160816; b=Zhzsnp/av1dmIfU4My8yd2DccuCHXOjLwp9GzjauVuIDxxnIR6/lrkMOVvwGj/rX5a A4+X3tOqw8zUZVMzQRVazXmoT9RdcYANWMywRvZ0IDRfxS7ahTl+PM6mhG/RxJbeRnoT 7g7ugrRVSKsxVgyTGZ8Xf/ER+CDePp4B9Mx5OjG1lBUajkJtmqPyBls6BOeXD+Y7SMpa G2bKfHLGtquPVPhNMD8oL6igSHycBltS93NfKCgZBD/G2C9GZrYFVBiedG9nQ0PsI5J+ rnChGKII1I9LssYaDqcTtY5qOq/CY1lwP4Cruvh8QDH9uy/76+Liyq9RpIfLvSBHMA4y NpNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=VKyV+kp8ioT0XJqfV5eLJvP8bag3OU6ulFSGUYN8mcQ=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=Dl+QAfwr5/UFNX42r9FB+OJO0gg2/bbTNfqzxBBQqJ0JqZ2dg/6Pk/Hyn3hIDHlxKG B49tvqDhbmRAROhEUKXH8ZfS7sSMzKEbeLWUfvTeZ7KAL51W3Vx6fb7s2kDSYUzoZoJ/ Lv73uKTGb6KqSaXx81rqVIt2zVvdfj3MELG4Cyp73GQrTcOgyS9b9m4slYNIlHHICkYU z0x62rxFIC0zDxe25MnseWYlykzEG2B8zwNAX1DgEn+M53ByOUf2rTRYksaFe+Qq4305 KDIKR82ZnF964ClYoHrFu6qPKduLsGFxikaL144ltahs/W2kRcRhpAIf2lWj6JI+8Rld jUEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YPO6Qff9; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84248-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84248-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n24-20020a63ee58000000b005cef24b3015si6351252pgk.219.2024.02.27.19.43.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 19:43:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84248-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YPO6Qff9; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84248-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84248-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A90DFB2A72D for ; Wed, 28 Feb 2024 00:02:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16B215733F; Wed, 28 Feb 2024 00:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YPO6Qff9" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 C579E33CC; Wed, 28 Feb 2024 00:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; cv=none; b=ntw9/8RNIa0wawuXWHJeMbbt0/IquTAdPaARZ/abdm++FVOxw15D5OislvXHhcjsUQsYLzLzi/A9PyBDB7UDVH/pMeAhKAfpJ+EPBj0e6B1y0+D5vPsyS8QubQCDCjZaYX9UQj/llofagaLperv5rFSTzzQAgoJDv74ftz6Kg8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; c=relaxed/simple; bh=H/oVc0/R243WLhuh35k20xoR6ierm4mlpBoLWVy2YYA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kjHkY6Q55jVkp+kExPNeBRyqBKqEa0KONd3ZndLoIShaito6O2myhsngk9zGtsjoHyfu9vWCICHJ5ahGKbM/7UwmssQtjZaZsGK74jc4NjkmjKQq35zfjgMsSLZbbrdl0TTo5qlDxLw4ERg2emcfkDH9DGDv7yOmpUW+9Z+K3zE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YPO6Qff9; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709078421; x=1740614421; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=H/oVc0/R243WLhuh35k20xoR6ierm4mlpBoLWVy2YYA=; b=YPO6Qff9DIGG1P/5TaAa/jFyoxD7X+9fkvBFPkFhTUZ0pP90pkqvrmVj i+flQJhfJry7wvVDU7yGRroEsj6nLY9fjDN9QiVzgobwyxPmyMdvnlJbI jsH/BMC+0sFRFZobnWtQrtLEJmFa2/Jxu70r1AIsjbjdmmVRjo93+pmWB r4ZLRMxEvRmgHYqPlSlpEmeiC5wTTDMfPnSM10xzINJN9q9XOM8DKJ04n zo6HngSz4GQ6u9Rv1wdhebqDSiO5r+65d62yXkk7mMjr5GJqDBCO4okuU hR7uQWyU0ej0KVImY4y+J3exHLcWeElcqPulUfZbowhHW/NL4oHL84Qms w==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="25919835" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="25919835" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7439168" Received: from linux.intel.com ([10.54.29.200]) by fmviesa006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:17 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id 1231B580D7F; Tue, 27 Feb 2024 16:00:17 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 4/9] platform/x86/intel/sdsi: Add attribute to read the current meter state Date: Tue, 27 Feb 2024 16:00:11 -0800 Message-Id: <20240228000016.1685518-5-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792112654902929300 X-GMAIL-MSGID: 1792112654902929300 The meter_certificate file provides access to metering information that may be attested but is only updated every 8 hours. Add new attribute, meter_current, to allow reading an untested snapshot of the current values. Signed-off-by: David E. Box Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Ilpo Järvinen --- V2 - make control_flags a parameter to be eventually passed to sdsi_mbox_cmd_read(). This removes the need for a lock which had been added to protect control_flags when it was a member of the private struct. drivers/platform/x86/intel/sdsi.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c index bb3eaf5eb382..277e4f4b20ac 100644 --- a/drivers/platform/x86/intel/sdsi.c +++ b/drivers/platform/x86/intel/sdsi.c @@ -68,6 +68,7 @@ #define CTRL_COMPLETE BIT(6) #define CTRL_READY BIT(7) #define CTRL_INBAND_LOCK BIT(32) +#define CTRL_METER_ENABLE_DRAM BIT(33) #define CTRL_STATUS GENMASK(15, 8) #define CTRL_PACKET_SIZE GENMASK(31, 16) #define CTRL_MSG_SIZE GENMASK(63, 48) @@ -95,6 +96,7 @@ enum sdsi_command { struct sdsi_mbox_info { u64 *payload; void *buffer; + u64 control_flags; int size; }; @@ -250,7 +252,8 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf control = FIELD_PREP(CTRL_EOM, 1) | FIELD_PREP(CTRL_SOM, 1) | FIELD_PREP(CTRL_RUN_BUSY, 1) | - FIELD_PREP(CTRL_PACKET_SIZE, info->size); + FIELD_PREP(CTRL_PACKET_SIZE, info->size) | + info->control_flags; writeq(control, priv->control_addr); return sdsi_mbox_poll(priv, info, data_size); @@ -424,8 +427,8 @@ static ssize_t provision_cap_write(struct file *filp, struct kobject *kobj, static BIN_ATTR_WO(provision_cap, SDSI_SIZE_WRITE_MSG); static ssize_t -certificate_read(u64 command, struct sdsi_priv *priv, char *buf, loff_t off, - size_t count) +certificate_read(u64 command, u64 control_flags, struct sdsi_priv *priv, + char *buf, loff_t off, size_t count) { struct sdsi_mbox_info info = {}; size_t size; @@ -441,6 +444,7 @@ certificate_read(u64 command, struct sdsi_priv *priv, char *buf, loff_t off, info.payload = &command; info.size = sizeof(command); + info.control_flags = control_flags; ret = mutex_lock_interruptible(&priv->mb_lock); if (ret) @@ -472,7 +476,7 @@ state_certificate_read(struct file *filp, struct kobject *kobj, struct device *dev = kobj_to_dev(kobj); struct sdsi_priv *priv = dev_get_drvdata(dev); - return certificate_read(SDSI_CMD_READ_STATE, priv, buf, off, count); + return certificate_read(SDSI_CMD_READ_STATE, 0, priv, buf, off, count); } static BIN_ATTR_ADMIN_RO(state_certificate, SDSI_SIZE_READ_MSG); @@ -484,10 +488,23 @@ meter_certificate_read(struct file *filp, struct kobject *kobj, struct device *dev = kobj_to_dev(kobj); struct sdsi_priv *priv = dev_get_drvdata(dev); - return certificate_read(SDSI_CMD_READ_METER, priv, buf, off, count); + return certificate_read(SDSI_CMD_READ_METER, 0, priv, buf, off, count); } static BIN_ATTR_ADMIN_RO(meter_certificate, SDSI_SIZE_READ_MSG); +static ssize_t +meter_current_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, char *buf, loff_t off, + size_t count) +{ + struct device *dev = kobj_to_dev(kobj); + struct sdsi_priv *priv = dev_get_drvdata(dev); + + return certificate_read(SDSI_CMD_READ_METER, CTRL_METER_ENABLE_DRAM, + priv, buf, off, count); +} +static BIN_ATTR_ADMIN_RO(meter_current, SDSI_SIZE_READ_MSG); + static ssize_t registers_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) @@ -518,6 +535,7 @@ static struct bin_attribute *sdsi_bin_attrs[] = { &bin_attr_registers, &bin_attr_state_certificate, &bin_attr_meter_certificate, + &bin_attr_meter_current, &bin_attr_provision_akc, &bin_attr_provision_cap, NULL @@ -537,7 +555,7 @@ sdsi_battr_is_visible(struct kobject *kobj, struct bin_attribute *attr, int n) if (!(priv->features & SDSI_FEATURE_SDSI)) return 0; - if (attr == &bin_attr_meter_certificate) + if (attr == &bin_attr_meter_certificate || attr == &bin_attr_meter_current) return (priv->features & SDSI_FEATURE_METERING) ? attr->attr.mode : 0; From patchwork Wed Feb 28 00:00:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 207621 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3084935dyb; Tue, 27 Feb 2024 18:03:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWxupIlFFPvmwOyB6ATJ0UihCVFajuq9iM1RKFdDP4M2PLl9H9ouRdZrgzfa5c8SbwAJwC2PUjL1RfmJMkiHxV0QQ9d6A== X-Google-Smtp-Source: AGHT+IEQN/qZ2OSdAbzc0OaIp/SYWM82N91W7rFEgYLNudhEhTrmuuaHRU0wCIWGrK3TtbXGv+uj X-Received: by 2002:a05:6a21:3993:b0:1a1:18ee:1df6 with SMTP id ad19-20020a056a21399300b001a118ee1df6mr896990pzc.35.1709085786566; Tue, 27 Feb 2024 18:03:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709085786; cv=pass; d=google.com; s=arc-20160816; b=DcJJuFkqOF8lrkG/Gm55UhV1sdWT7Oak9iwuYriOD2Qkd99/uGrAT9Usl/7CqoqeqS GwqHRALhFQ73l+5SV83Dk3N4WjNBEQhGpPKtmRqWZloeiUNFZbzY48y+FOnLvyVSBEdf 6Vr3qqxQK25ujlLzLjW/7Tj0h38EnxrgZuYaWyFFn61wuqHfpK6H5iL51DadJdC5zCCj Raah9q1pfhubP0Nb3l6A1wiKsLfy6BidAURfXc/R2VYSb1filtRGy1HzvWSkrD7sAHMd cesHwUg1VUdxDxjqUOynsYOjFD/UNKKbVpGBTJlcBT6Lo6fgbP+ZMuZnhbkask/iO922 5Fxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=b2VW/9Qts1z4Zjhi2OYorq6Yxrdwao3zPoNBUU//oVg=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=ZLpv+nqoqotiMqrSbfzjdiBZFj+9Gvmu1VkbJ/kMtrKEDd6IO67gOI1A7ikOP1nfZp +YdViy0l6CK3HBkkyLovEOtfxmRu+nQCHrpaHYqvnezBBJpjwmNBbIwCX8dF9iZ8uuks m6XS87mz5D3RHO+S0fMXBpdP25XrgN9hon/8V7Tn0OQpyNCZ+LkzveXkjdQW5fSW18Mh aWPiDjWzMzb6BHUosMDZ9n02X3sfCnJnyqNhh+Q39ImFF6kddPaKUbyd/4/6mbE9bYZH Fh9vD9/z6HYtPJBINm8CwBbWu6DO947MENu/K9eDI4McGKxsOrqvgWgfZWg+T0ize7z8 Iv5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WnzX7nR4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84249-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84249-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s10-20020a170902988a00b001db7c5ef0a6si2338535plp.136.2024.02.27.18.03.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 18:03:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84249-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WnzX7nR4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84249-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84249-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 445EEB29B4F for ; Wed, 28 Feb 2024 00:02:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD72F5730A; Wed, 28 Feb 2024 00:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WnzX7nR4" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 F3CDD79ED; Wed, 28 Feb 2024 00:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; cv=none; b=PQkSNA13/uN46Q1CUxPuvPki8t58TWq8c5pquhjSATWCjKFxRn1+Wc9ipvUR9gWb+duIKsDXxLRhi2NjGklMj1kEh42faudjVg4v+Agn7IY5DFSKEAB0w7rYzThrEgHWewrUgwpVFmriYwmPFphFpNGy+ZshjYmr3fNfOspRFsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; c=relaxed/simple; bh=+Z7En2HDO6d1w36dnpCFtmIvi6nCJV8wICBRrJL4X00=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tg1kJfx10ot3u34FTyO3lHrsDEZEV2KdRLYjmhZaVgQ1Ohq+n0wPqw7gDEdsE5tTV/yHPDxw8MeahW717p9NVq/axQEYHGuIVKKrR8WdsBqtPpBDVmvl3qJLdwFYHw/NVJL3dHls5AloLz3630obkPFdzAduEj4iLERXC2FT820= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WnzX7nR4; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709078421; x=1740614421; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=+Z7En2HDO6d1w36dnpCFtmIvi6nCJV8wICBRrJL4X00=; b=WnzX7nR4+nbl8VnWWTRNIvZ4BHSSxR53I/wpeNrT0IZ/4Zq1h7DPE2cL K2tGY/5I/xOSMVAP1C/yKI2Yy81Jih0sqJPIz7M9GTS9PHL7N2NFAIHm2 txioPC+7rLf8N7il5ma8Abc2G/lAaZOjOS+ebxwdYlNujT4xMwJgZA+ki LSja9S5ZspMZ3f97D0rZ0MFgjZbh9vWgqBkrIf+BDhytVh3xNq0mBuplk kq6sxgFtK7Emak0am1bagX6UCBvvFGDy5REmjsYoI2OvQByUlDxahvKna 7JIIauKckHcKr67Qki688M0gnvycJ23Q2Es7COtjGbpylEzfpZTMqxhkg Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14604939" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="14604939" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7176941" Received: from linux.intel.com ([10.54.29.200]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id 406A6580B9A; Tue, 27 Feb 2024 16:00:17 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 5/9] tools/arch/x86/intel_sdsi: Fix maximum meter bundle length Date: Tue, 27 Feb 2024 16:00:12 -0800 Message-Id: <20240228000016.1685518-6-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792106337396304682 X-GMAIL-MSGID: 1792106337396304682 The maximum number of bundles in the meter certificate was set to 8 which is much less than the maximum. Instead, since the bundles appear at the end of the file, set it based on the remaining file size from the bundle start position. Fixes: aad129780bae ("platform/x86/intel/sdsi: Add support for reading the current meter state") Signed-off-by: David E. Box --- V2 - Split of V1 patch 7 tools/arch/x86/intel_sdsi/intel_sdsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c index 2cd92761f171..a02850a710ee 100644 --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c @@ -43,7 +43,6 @@ #define METER_CERT_MAX_SIZE 4096 #define STATE_MAX_NUM_LICENSES 16 #define STATE_MAX_NUM_IN_BUNDLE (uint32_t)8 -#define METER_MAX_NUM_BUNDLES 8 #define __round_mask(x, y) ((__typeof__(x))((y) - 1)) #define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1) @@ -167,6 +166,9 @@ struct bundle_encoding_counter { uint32_t encoding; uint32_t counter; }; +#define METER_MAX_NUM_BUNDLES \ + ((METER_CERT_MAX_SIZE - sizeof(struct meter_certificate)) / \ + sizeof(struct bundle_encoding_counter)) struct sdsi_dev { struct sdsi_regs regs; @@ -387,7 +389,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) } if (mc->bundle_length > METER_MAX_NUM_BUNDLES * 8) { - fprintf(stderr, "More than %d bundles: %d\n", + fprintf(stderr, "More than %ld bundles: actual %d\n", METER_MAX_NUM_BUNDLES, mc->bundle_length / 8); return -1; } From patchwork Wed Feb 28 00:00:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 207562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3069858dyb; Tue, 27 Feb 2024 17:20:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXVOKzk2TjSwquTWnlveIx6lr26MFQPrxsWXsHxXxVDp21LpVjiXznO2IdVsjxyc5DtozkbEktiat+RsZ+r8uZfQfroZQ== X-Google-Smtp-Source: AGHT+IEaUjrBq6ZQhTK7pvQ77JXq2aK1v5cvg6O+IXGCFeTVp1Rf0d3euMRTeuMsoM6egbLpJFn8 X-Received: by 2002:a17:903:41d1:b0:1dc:90b3:eee with SMTP id u17-20020a17090341d100b001dc90b30eeemr11437221ple.22.1709083222965; Tue, 27 Feb 2024 17:20:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709083222; cv=pass; d=google.com; s=arc-20160816; b=ffJMhj5CRtFeYDeuBaAsTdB/jFcpzWApWvtEhpXglaL/CkdHe/LazrardF1DBQ6vf9 3/r20ihKrlgFvYi9/22QUaHWMNphigmObpH9oMj/MkGiSSB3IOhpMISCIHrdIVr0lCiG +wGa+HuSm97KkzB3aRZQiO2LYpXE67FmVDDfss7hk3wK/vZKpbJq4QD3y9OBNFNkhOjU OtGR/eQh28b0uNnokZh2lMHvC20tUXPznZCkPn3qm9H/WyJNcvf7emIfI8YhqDvoQ0Gi +TI+fyL9HS/kWbmXRv9pCSdoNeids5JEi8ADFn7fV+sYmV9PG5XbjJSX+jMzbrkVbJSx hh3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=efQI354iOqeymQbAnEXHo0Dub+2Yv5jsvBf67Rx8v68=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=lansAPPBVzbU+BxhUDjF3atCZ3zVhIojHLvtqs4sJYEuN6pvt+YKJ0QJfhHwrWaeLu M7Ul9gyRIV0OV5icd81hu+euieuETc3UkyxNJiquyqoFYyaYQe9gBHwL7XyUUEh6HxcH oQxRvoGJkNCpAb6XhAxoWC9WH8/+3D2ew9enra+fuqORbz/hUgBkbQYf8AsMQeOtKnXJ smVpfc1STMveiXBf4DsDNTAWf0Y09q+JHnTItFxR+u38+aP/eswgDdaZB0FHBv17jpQm xOVSnp/gZrAZ22kpaDIoQ06z4h8k3lW7BUI4LN+CdJn0wK+kwKDODj+HLhrL+LQd3gtj hdvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NsDOnxB7; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84247-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84247-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f18-20020a170902e99200b001dc69aeefafsi2259420plb.517.2024.02.27.17.20.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 17:20:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84247-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NsDOnxB7; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84247-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84247-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 35022286930 for ; Wed, 28 Feb 2024 00:02:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C4E6381AF; Wed, 28 Feb 2024 00:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NsDOnxB7" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 15BCD652; Wed, 28 Feb 2024 00:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078421; cv=none; b=Cj6vJZ1goXcOHfH8kTw0WzVhd5XKY4cokJcsjDn/WhPXzb+DMr5T0g69xEA40vAIws+ksm5M2evg8ud/YPuz1zbf84u8WunlqPJ4gSv6ipQO3Z3PCOZCyFdCbuHH70AjM863pJ4/+IjXyEUVOOi6YAmJfASfihtWy10D9k4S0Vc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078421; c=relaxed/simple; bh=UkJaObiiJZKiIN9VycVTIOIbM93MxYdzndcsRLEGOWI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RjOcluMnSD5EwOfwx/7khBRI7O0856axHFc8aSSyqELH8luadk0nHsm4Bal5HG4ixOPBOJEh0TBbCj1h9LzT3TzLc0aX78Po4JR+X1Wk25vHWfLbX5JOPhl6GR0fbJ5q2AmawRIO4Sh+NZxbKqpu3YAJFbKr+eB5vn1pJVOqPrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NsDOnxB7; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709078420; x=1740614420; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=UkJaObiiJZKiIN9VycVTIOIbM93MxYdzndcsRLEGOWI=; b=NsDOnxB7K2c2V6M4C472xMJgVct+0gp5RygrUW3rgrK67YzygdkeT+6s kHYgsObVpY3QwHh6n/6jVA5bJPp9pQ4A9KdfXQqI4vyzQHMtl6dCqAvdt 6/0QvYj2hxUFrZ5Gyi/ryl2ImAwMtyMshtk4qoL3+cX7rFZRQWIbxeNkK CccUd1hJP3MtJp/b5hkou5bR6IeHmdpG6oP6Uu+hDTz0XymZkFa3HWw+x 2o5viAOfk7Gr2NPtzK1LZ/jtF8nSNAb4GRu9pOsz06vZNJlT9p5cqe2kS PueHqM171YmUSu9M8AbL4LcLQB0rjA/2rdUSj8kRYFEB/Ogkj0z4M+gaS Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14604941" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="14604941" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7176942" Received: from linux.intel.com ([10.54.29.200]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id 6E3FC580B9A; Tue, 27 Feb 2024 16:00:17 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 6/9] tools/arch/x86/intel_sdsi: Add missing version field Date: Tue, 27 Feb 2024 16:00:13 -0800 Message-Id: <20240228000016.1685518-7-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792103649171014690 X-GMAIL-MSGID: 1792103649171014690 Add missing 'version' field to struct meter_certificate. Also fix output string alignment. Fixes: aad129780bae ("platform/x86/intel/sdsi: Add support for reading the current meter state") Signed-off-by: David E. Box --- V2 - Split of V1 patch 7 tools/arch/x86/intel_sdsi/intel_sdsi.c | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c index a02850a710ee..def1b9a01738 100644 --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c @@ -153,11 +153,12 @@ struct bundle_encoding { }; struct meter_certificate { - uint32_t block_signature; + uint32_t signature; + uint32_t version; + uint64_t ppin; uint32_t counter_unit; - uint64_t ppin; uint32_t bundle_length; - uint32_t reserved; + uint64_t reserved; uint32_t mmrc_encoding; uint32_t mmrc_counter; }; @@ -336,6 +337,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) uint32_t count = 0; FILE *cert_ptr; int ret, size; + char name[4]; ret = sdsi_update_registers(s); if (ret) @@ -377,12 +379,19 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) printf("\n"); printf("Meter certificate for device %s\n", s->dev_name); printf("\n"); - printf("Block Signature: 0x%x\n", mc->block_signature); - printf("Count Unit: %dms\n", mc->counter_unit); - printf("PPIN: 0x%lx\n", mc->ppin); - printf("Feature Bundle Length: %d\n", mc->bundle_length); - printf("MMRC encoding: %d\n", mc->mmrc_encoding); - printf("MMRC counter: %d\n", mc->mmrc_counter); + + get_feature(mc->signature, name); + printf("Signature: %.4s\n", name); + + printf("Version: %d\n", mc->version); + printf("Count Unit: %dms\n", mc->counter_unit); + printf("PPIN: 0x%lx\n", mc->ppin); + printf("Feature Bundle Length: %d\n", mc->bundle_length); + + get_feature(mc->mmrc_encoding, name); + printf("MMRC encoding: %.4s\n", name); + + printf("MMRC counter: %d\n", mc->mmrc_counter); if (mc->bundle_length % 8) { fprintf(stderr, "Invalid bundle length\n"); return -1; @@ -396,7 +405,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) bec = (void *)(mc) + sizeof(mc); - printf("Number of Feature Counters: %d\n", mc->bundle_length / 8); + printf("Number of Feature Counters: %d\n", mc->bundle_length / 8); while (count++ < mc->bundle_length / 8) { char feature[5]; From patchwork Wed Feb 28 00:00:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 207629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3095344dyb; Tue, 27 Feb 2024 18:31:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVkIl1vIiwRWPVJGBFdNFSFqcxZfnv9Pa+pa76TDiJdXKWKk9xMODmja1lobuAif45oGQKVZJbWoRNFxk8ovPfBfCdxrg== X-Google-Smtp-Source: AGHT+IGsKPqvGyTI109mGAgd9cVmKZqnJsfgYBfhNYoU2hiFpFcQXDdqzSX0RPmNiE/IFSWogHNK X-Received: by 2002:a17:906:f0c5:b0:a43:9e1f:240e with SMTP id dk5-20020a170906f0c500b00a439e1f240emr2728339ejb.60.1709087519278; Tue, 27 Feb 2024 18:31:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709087519; cv=pass; d=google.com; s=arc-20160816; b=QesOnS44/eXyA2ozoRYDH0pqA72YLmkm6xBS1vFhrAYMpE7/hY7M/Ki45lrwNQsMrY nL2+tnNqn/WNWQTn5MAM18znySXf2KBT3kd64q7ML/avtfIuXXUVSnUn/bXIb70FILlJ WfJx2deWHnieJx8cuzqI1MG6r+EZCPz53Aq6GVm6c0SLSkYtJhcHQ4055ApSVOrM5yfi N1YLAXCnewQbiZFiee0LyxAnWv8tUKEmSMTR0uy+RM39gfHHSOEwCg4g7EMN9k/+YQrn 1yBQ88/ffVtCALkjIdN2t8GmkfCRIFc0II2oIy65gGanqWvgq1qe5j/lB0dXR46jVyIe kh6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=ahiZ+nUxjza4yXIf6ZoTjQ2flyvo0AuzD35KSGaH9xY=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=OGMDZ66BdKU5LFgIlrc6PZwkzB57+ruOb8sIPJQNsSSZBDr+lpUkHqgtoTQujSdN9R wIBqq6Fxz+p96K0SZGhoEjD45GdhvYeKsxhEXeUSbrC64ovv9/1u7WXGDTGcqObcokla hni65bkeojVCLBZuxq9O+OPsxVfFmiMHY9rc576BF/4Hm4fU0IEKNlN7qlz3FJ/BUmkq fvnn7+SlPt5rrgwg0fc5doOjxWGIsrMipVjelnXIvL1vY/mMntQi/4SaMp/TroXnC+tW Q5XvVWirgVtXe7VeatDUIa9bAW/tGVfqi4amKPPX8glFPiITliQCxBsS8qcGv9h6uZ6L ItuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XG6wMJGI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84250-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84250-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r11-20020a1709062ccb00b00a434e7521a7si1230247ejr.546.2024.02.27.18.31.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 18:31:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84250-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XG6wMJGI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84250-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84250-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7833C1F2B2DB for ; Wed, 28 Feb 2024 00:03:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B842D5788E; Wed, 28 Feb 2024 00:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XG6wMJGI" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 3ED0F1400D; Wed, 28 Feb 2024 00:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; cv=none; b=rmN/zUD/V6A9X1fX+4zChA8cUwRPwIU8T9NUB6yrQ00+nZzOgYmbHqS1oKwjsP5U3UDOkg2xrTLJZaRLHZIaylAGMkuStm7E/YwZBuG7VK42hzPXboi0sWeJxBhkJjKkxn85aU9opMjbARIUQcRSUourQm90f4rAY6Yp/yBbry8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; c=relaxed/simple; bh=iCjI+PJKNrX2ec8KuwZzO40AKoWqyEUBGXtTR4zNvjQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gV8Gl119IQpSRp+ERNM2VgyyzOz1wvTpi2WfHPWnXdvlgN4/uAB+gtMnz8bzd+4GQmTUJ8AVgmsibY2V6H/fxrdB7Lx3JPmmHzHtV47M+AS7XpzgbMx/rJ29eQDmrn0AdQkzhoPcS2l85a9e++A9hBwxL7Itw/T1B8Gx+jQ3oD4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XG6wMJGI; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709078421; x=1740614421; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=iCjI+PJKNrX2ec8KuwZzO40AKoWqyEUBGXtTR4zNvjQ=; b=XG6wMJGIvaKwcqOdaipIYQ+pK0l9u9F4GV9JIDUFNVM7W+JmsLIw9Jsk 70pOQ9M4Q1K31aETO2uOtcypFX34zslB3Jtvd2hak6+PdAz3sAWRneO2G LWWov3AMBRdPtkZdgcEULtBTN9aqP7m3zw4CagPEfb12lvn2YXHmfODOj iRql1jwA+xnIGNio8S9ch9apnZtoQkhyWGSHvYZyCylWvEvKuLADcS4C6 IzlqIw1VbEVPAcr0IufJm9AUD6/Z7zju8fcaIb5xY93okVTvCLe0QjEsD iL66SKjc1ls19Dsa9N6UgpHhhmiXa4T/PfOQN4+rS4ZVnMB9lA4ZigoQi A==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="25919838" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="25919838" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7439177" Received: from linux.intel.com ([10.54.29.200]) by fmviesa006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id 9B989580B9A; Tue, 27 Feb 2024 16:00:17 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 7/9] tools/arch/x86/intel_sdsi: Fix meter_certificate decoding Date: Tue, 27 Feb 2024 16:00:14 -0800 Message-Id: <20240228000016.1685518-8-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792108154867652026 X-GMAIL-MSGID: 1792108154867652026 Fix errors in the calculation of the start position of the counters and in the display loop. Fixes: aad129780bae ("platform/x86/intel/sdsi: Add support for reading the current meter state") Signed-off-by: David E. Box Reviewed-by: Kuppuswamy Sathyanarayanan --- V2 - Split of V1 patch 7 tools/arch/x86/intel_sdsi/intel_sdsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c index def1b9a01738..2acc6be5f5d6 100644 --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c @@ -403,15 +403,16 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) return -1; } - bec = (void *)(mc) + sizeof(mc); + bec = (void *)(mc) + sizeof(*mc); printf("Number of Feature Counters: %d\n", mc->bundle_length / 8); - while (count++ < mc->bundle_length / 8) { + while (count < mc->bundle_length / 8) { char feature[5]; feature[4] = '\0'; get_feature(bec[count].encoding, feature); printf(" %s: %d\n", feature, bec[count].counter); + ++count; } return 0; From patchwork Wed Feb 28 00:00:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 207577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3073467dyb; Tue, 27 Feb 2024 17:30:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVzcng7aJ/y/e5VhO7UNjJI7eLHyc8FsLy0tvuxLEYtaPPFzAWg0sN5lb11TsPwRp3k+6NUvv1F4k58s1p5M0y4O34Kzg== X-Google-Smtp-Source: AGHT+IHDkbadq2OG4o/DzYsxDF7nsmtS6pntyi7QjF8uwFEFK1rNoWRwD2sAkBmOZtWY0wnKZUOJ X-Received: by 2002:a17:902:e74f:b0:1dc:6073:a3a4 with SMTP id p15-20020a170902e74f00b001dc6073a3a4mr1443415plf.3.1709083846890; Tue, 27 Feb 2024 17:30:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709083846; cv=pass; d=google.com; s=arc-20160816; b=k0X8jgHRCjEizY0hzLStqnFgpMwXh9aqJJOQa24OSAi5lnJsjSwFui3wul6vvZKICQ nL2muzpWumVMrso9j0bNiCwiWFvzjBXDankWP4/6kr/5rFpm2lmGp1H5u3AZuGgyMTtY wWzHeWPxlpjkH7VG4f+AIcFtXLJNjYFMS7caGgZRq1ujMmno+CQC+FVLKikLslZKiJHK LdIjwcf0K1bz8wpXFiLlb8g5O/gdmki4gK84uWsP6+/+tZFEWGoAJZAwQyuIp3rB2bYj 3xJo223RKcgET23kwxJFYBlTB8+EFFlDjTEVvZMcglU3KFOBqNe7AFj6/cmUAIX602CM OwnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=bxuCPIWHWUh/5S/QbZNpBTw7dIXgz6wn+DGslZR6H+0=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=VCuhbnCP3yJzSE5Xl13iyuvp+sTxCTukriDsO2PfxP5e8CzPmX7U5DcqlquPQRUZ7w DJYUed0UEAFTcFEex4TZNtBCDZmgT6vI3RKqKxq3PpVHuYt13/ZFCFPTEb7rfLqldl7L MtFzi4bf6927kSnP1T7ynOWcuRodkZk/8IWpm1/3Nzg4U3+OLvon3Y7yTYcPR+iUcr5n rQd3Dqb5q1o1yB5U6pejBgNoKOsmA9gG/45moJs2dL9MkehKee4dS0Z25WlfAh2Sq87w wEoOPQr0X0ctdGW8cyj2Z1bWKRhEIMroz9f5GgQUNrVjGntg6AeSmrA4h/u+18DOfbn3 q8Rw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KIbMAkyI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84251-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84251-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d4-20020a170902cec400b001db63a53b73si2411221plg.45.2024.02.27.17.30.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 17:30:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84251-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KIbMAkyI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84251-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84251-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 250AA286FA7 for ; Wed, 28 Feb 2024 00:03:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B41905788B; Wed, 28 Feb 2024 00:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KIbMAkyI" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 6EE091CF9A; Wed, 28 Feb 2024 00:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; cv=none; b=hyw2eVZeYRd6HzrXbVpkN4vwmhpR60sMrGFXwg2VjmoRs2i195LuLJJUWzCjejigHWSLTGuBV+T8Um9T98ZuQ8fWBpKTQltbB8jBkEROMkaA8Wi5gSRuX84KZ5q9LskZ5gVLHF+4b3wEBweFUdUClaS0pM7kOzxNSOEhLAoQUsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078422; c=relaxed/simple; bh=Xrls4UpurhgVy6jk7w6ROuUCyAmG1GzPqDtSTrya6q4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l29KhKR5AfCwhB42503ujjekWjn4oX8WjMo/wTILr4SI5XLhlm2tE75mHNni9ZC6WJxZoiGlNDVrJp1yEJFFjw4JiZCOVpUdHKms2OTvnblPjBiOTgFqhnHXUs35T0oYkSsIqThmKg5dAhzWyq8INEpopK4uSBJMUIrvqU4W5LE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=KIbMAkyI; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709078422; x=1740614422; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Xrls4UpurhgVy6jk7w6ROuUCyAmG1GzPqDtSTrya6q4=; b=KIbMAkyIzOYE35LxiY0wCShMOOK1LjvEVhdbE+Xw2uRnOrmwboUBsiz7 so5VFJPavYtPMRjocQa3pC23F1xlD2X0dAgMlCp7AXuEIE3cY2fjJiJuv DZjn82PSIdl5m25qs/GAncDS+OFwn7choqO5ZtRuG7Vkjasr9X4hHtDOV GtSC6L7JHQZcSase8NdgH2EMAIwozUE7JdRoxg51vNx/oTlc2fTDxPm7k n7Rss5eRr9OoH6u7j+yZGXrfAKDAEERSk6xaXD/5VDRXxZfvx0zZD1DSj ZzDtkSnJR8QOJinbJngAxQWogAnmhzBmSUpq5sT1Oe1Rn5tgnUoCeRAnO Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14604944" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="14604944" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7176943" Received: from linux.intel.com ([10.54.29.200]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id D2EAF580D7F; Tue, 27 Feb 2024 16:00:17 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 8/9] platform/x86/intel/sdsi: Simplify ascii printing Date: Tue, 27 Feb 2024 16:00:15 -0800 Message-Id: <20240228000016.1685518-9-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792104303866733171 X-GMAIL-MSGID: 1792104303866733171 Use printf width specifier to set the display length of encoded feature names. Signed-off-by: David E. Box Reviewed-by: Kuppuswamy Sathyanarayanan --- V2 - Split of V1 patch 7 tools/arch/x86/intel_sdsi/intel_sdsi.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c index 2acc6be5f5d6..a8fb6d17405f 100644 --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c @@ -407,11 +407,10 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) printf("Number of Feature Counters: %d\n", mc->bundle_length / 8); while (count < mc->bundle_length / 8) { - char feature[5]; + char feature[4]; - feature[4] = '\0'; get_feature(bec[count].encoding, feature); - printf(" %s: %d\n", feature, bec[count].counter); + printf(" %.4s: %d\n", feature, bec[count].counter); ++count; } @@ -492,7 +491,7 @@ static int sdsi_state_cert_show(struct sdsi_dev *s) sizeof(*lki) + // size of the license key info offset; // offset to this blob content struct bundle_encoding *bundle = (void *)(lbc) + sizeof(*lbc); - char feature[5]; + char feature[4]; uint32_t i; printf(" Blob %d:\n", count - 1); @@ -505,11 +504,9 @@ static int sdsi_state_cert_show(struct sdsi_dev *s) printf(" Blob revision ID: %u\n", lbc->rev_id); printf(" Number of Features: %u\n", lbc->num_bundles); - feature[4] = '\0'; - for (i = 0; i < min(lbc->num_bundles, STATE_MAX_NUM_IN_BUNDLE); i++) { get_feature(bundle[i].encoding, feature); - printf(" Feature %d: %s\n", i, feature); + printf(" Feature %d: %.4s\n", i, feature); } if (lbc->num_bundles > STATE_MAX_NUM_IN_BUNDLE) From patchwork Wed Feb 28 00:00:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 207583 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3076869dyb; Tue, 27 Feb 2024 17:40:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWro2VCAB/b68Hw32jGYb0+NFhrhKo7SDCvWhQCCX4xlEQsNJajJWCi+i1Cda8TtI/kgFeDaub+q8TvBEeF4Yf7Fo7DrA== X-Google-Smtp-Source: AGHT+IF46jBfWHTG0I9FGROrOGgHuTHUdjjlo/C1lD/RhgnT4UwGgfTvJNt7igEfpa49+KQK2npe X-Received: by 2002:a05:6214:19eb:b0:68f:5cc4:7389 with SMTP id q11-20020a05621419eb00b0068f5cc47389mr3722773qvc.27.1709084440605; Tue, 27 Feb 2024 17:40:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709084440; cv=pass; d=google.com; s=arc-20160816; b=YjNZcjBx83yKWFnJhyplQru5FhwwDVRjnwZkNZgvmgC5nTOy9DYQqrFxdfB/YLmMBg aGS4iOsB8nRFg1R+lDMyK9javx+KAqXoXboIVyNBaN6Y8x7sCNOlZHqIe/fC557lvyBx vRqXr5OQ7Sfzig4lzS/pX8udCzDvKQlaMLtfXwzgkuTwRGImPQ0bbJhdoPVqteqEm9PQ VRTbTSpV+L/hgmlioHzowyUL9m3B+cjcZnvpIOEDAIeCELIa22BrPN//8qpE/5kRiwMe 676ZfckuERiJV3yc7/tMK0D/UdmNK/37zB5xSzslRwOj6YLrzZY8cWmWNaOYJyKcV939 FDww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=OTx1sieFX1tgV9ZcZ/a7AEqhffD5Y+YorCMBhLBixvs=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=ETDP1KufFjiHKiPNKQFpsbgowR+9ZED1PAwWrQChcmOgvebCnqKyNHw33LcLL9AFlT xAo6E5Q0mFdv/MGrQasDcxtaZjZxSlU5n/g+eNIE+tPrCB0Z7LLOz0MW2u0+anR7Kgvq PvWMvr4YAOc538ULHx87mHx+RYa+A0M87R9Kl3DWwikMYCVDzhYQY5JNdu/kFoOT4/nd yuy3omSppYhauSSuchUNSo0Ix5VbTMq8RjuHhM42QcGc5IS1Kw8A6cGuSl72va4mXfcj kedXooS8XpsRIbbtlR4SUM3Dvp8YftWUunDfuKnkbiBsUoA01VfC5nhVp5SkdLo7KNIO S2uQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EdFXYp99; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84252-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84252-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gf3-20020a056214250300b0068d148b4a64si9240258qvb.419.2024.02.27.17.40.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 17:40:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84252-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EdFXYp99; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84252-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84252-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0EB321C25A86 for ; Wed, 28 Feb 2024 00:03:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 739BF5810E; Wed, 28 Feb 2024 00:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EdFXYp99" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 9EC382031D; Wed, 28 Feb 2024 00:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078423; cv=none; b=D7amLrUUuS8C6LBFxlDJ2HzzaPBOfRKfdcd3+1/WtJUbuTqNs82Z0mKfS5EOGTD+mC8p+rkavqnbzBfn4j1x5Z3x0zIgd6lAgLNaiVl/Kl9L9ny6Ptkg2INFX6U5DDXp7jpseXAc/K8LHhKHVl7GgzVVmbx9d3BKpg9pq8qshO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078423; c=relaxed/simple; bh=aFIWj3cqC8NcatziWVc8C2kC8LNbb5w+GhtCarWn8pk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=guE05f78uYSo9i4EP9+oVhjXlXmfT3W1JfUYcOLk6GxjxkG4I4f0IQsQlmC1qG5Jo4eHsDR3/14AZqJ87Hvq2qGkoWGQd3Kyg2gcVmyzBqtD2YrZ8k54B+nzv2y2Xd1G0eSmVz5/vKdG9zt4X68FfHIlQpNcF5Q0m/lQy5awsnM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EdFXYp99; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709078422; x=1740614422; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=aFIWj3cqC8NcatziWVc8C2kC8LNbb5w+GhtCarWn8pk=; b=EdFXYp99ZCEeGzP+QmB10vA2OndVbZlgATf4TSaS5eqcCV6AUNKC5Ca6 XNoUeZIFV/Yy5bRuaiXl38/bBRdjxedB8i6yPY07EAer4Bc30vGIAaOr+ HpnHpKWGN2YhCABCCP5VS+faBoKvdyT7gAD981ASFkHxKlpcflpqr5bJN Li90cN75HqkIsufvmiT5il86FYtG//1DyxleT+Tdh/smnYgcb9oODagtb /krMsAa95lrN/Yh3HkvxtvcaDaA9O95pB5BoLuchURv+pSZLF9Ww2pdmt TgKYogJvnDvriU881AMhl7m/ZHIXT0PR5/pDihBumUUBXv9OmCGaeWxIB g==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14604946" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="14604946" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7176945" Received: from linux.intel.com ([10.54.29.200]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:19 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id 10FC0580D7F; Tue, 27 Feb 2024 16:00:18 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 9/9] tools: intel_sdsi: Add current meter support Date: Tue, 27 Feb 2024 16:00:16 -0800 Message-Id: <20240228000016.1685518-10-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792104926808514385 X-GMAIL-MSGID: 1792104926808514385 Add support to read the 'meter_current' file. The display is the same as the 'meter_certificate', but will show the current snapshot of the counters. Signed-off-by: David E. Box Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Ilpo Järvinen --- V2 - Set the name of the file to be opened once. tools/arch/x86/intel_sdsi/intel_sdsi.c | 49 ++++++++++++++++---------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c index a8fb6d17405f..325e1e41af1d 100644 --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c @@ -182,6 +182,7 @@ struct sdsi_dev { enum command { CMD_SOCKET_INFO, CMD_METER_CERT, + CMD_METER_CURRENT_CERT, CMD_STATE_CERT, CMD_PROV_AKC, CMD_PROV_CAP, @@ -329,13 +330,14 @@ static void get_feature(uint32_t encoding, char *feature) feature[0] = name[3]; } -static int sdsi_meter_cert_show(struct sdsi_dev *s) +static int sdsi_meter_cert_show(struct sdsi_dev *s, bool show_current) { char buf[METER_CERT_MAX_SIZE] = {0}; struct bundle_encoding_counter *bec; struct meter_certificate *mc; uint32_t count = 0; FILE *cert_ptr; + char *cert_fname; int ret, size; char name[4]; @@ -345,7 +347,6 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) if (!s->regs.en_features.sdsi) { fprintf(stderr, "SDSi feature is present but not enabled.\n"); - fprintf(stderr, " Unable to read meter certificate\n"); return -1; } @@ -360,15 +361,17 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) return ret; } - cert_ptr = fopen("meter_certificate", "r"); + cert_fname = show_current ? "meter_current" : "meter_certificate"; + cert_ptr = fopen(cert_fname, "r"); + if (!cert_ptr) { - perror("Could not open 'meter_certificate' file"); + fprintf(stderr, "Could not open '%s' file: %s", cert_fname, strerror(errno)); return -1; } size = fread(buf, 1, sizeof(buf), cert_ptr); if (!size) { - fprintf(stderr, "Could not read 'meter_certificate' file\n"); + fprintf(stderr, "Could not read '%s' file\n", cert_fname); fclose(cert_ptr); return -1; } @@ -734,7 +737,7 @@ static void sdsi_free_dev(struct sdsi_dev *s) static void usage(char *prog) { - printf("Usage: %s [-l] [-d DEVNO [-i] [-s] [-m] [-a FILE] [-c FILE]]\n", prog); + printf("Usage: %s [-l] [-d DEVNO [-i] [-s] [-m | -C] [-a FILE] [-c FILE]\n", prog); } static void show_help(void) @@ -743,8 +746,9 @@ static void show_help(void) printf(" %-18s\t%s\n", "-l, --list", "list available On Demand devices"); printf(" %-18s\t%s\n", "-d, --devno DEVNO", "On Demand device number"); printf(" %-18s\t%s\n", "-i, --info", "show socket information"); - printf(" %-18s\t%s\n", "-s, --state", "show state certificate"); - printf(" %-18s\t%s\n", "-m, --meter", "show meter certificate"); + printf(" %-18s\t%s\n", "-s, --state", "show state certificate data"); + printf(" %-18s\t%s\n", "-m, --meter", "show meter certificate data"); + printf(" %-18s\t%s\n", "-C, --meter_current", "show live unattested meter data"); printf(" %-18s\t%s\n", "-a, --akc FILE", "provision socket with AKC FILE"); printf(" %-18s\t%s\n", "-c, --cap FILE>", "provision socket with CAP FILE"); } @@ -760,21 +764,22 @@ int main(int argc, char *argv[]) int option_index = 0; static struct option long_options[] = { - {"akc", required_argument, 0, 'a'}, - {"cap", required_argument, 0, 'c'}, - {"devno", required_argument, 0, 'd'}, - {"help", no_argument, 0, 'h'}, - {"info", no_argument, 0, 'i'}, - {"list", no_argument, 0, 'l'}, - {"meter", no_argument, 0, 'm'}, - {"state", no_argument, 0, 's'}, - {0, 0, 0, 0 } + {"akc", required_argument, 0, 'a'}, + {"cap", required_argument, 0, 'c'}, + {"devno", required_argument, 0, 'd'}, + {"help", no_argument, 0, 'h'}, + {"info", no_argument, 0, 'i'}, + {"list", no_argument, 0, 'l'}, + {"meter", no_argument, 0, 'm'}, + {"meter_current", no_argument, 0, 'C'}, + {"state", no_argument, 0, 's'}, + {0, 0, 0, 0 } }; progname = argv[0]; - while ((opt = getopt_long_only(argc, argv, "+a:c:d:hilms", long_options, + while ((opt = getopt_long_only(argc, argv, "+a:c:d:hilmCs", long_options, &option_index)) != -1) { switch (opt) { case 'd': @@ -790,6 +795,9 @@ int main(int argc, char *argv[]) case 'm': command = CMD_METER_CERT; break; + case 'C': + command = CMD_METER_CURRENT_CERT; + break; case 's': command = CMD_STATE_CERT; break; @@ -828,7 +836,10 @@ int main(int argc, char *argv[]) ret = sdsi_read_reg(s); break; case CMD_METER_CERT: - ret = sdsi_meter_cert_show(s); + ret = sdsi_meter_cert_show(s, false); + break; + case CMD_METER_CURRENT_CERT: + ret = sdsi_meter_cert_show(s, true); break; case CMD_STATE_CERT: ret = sdsi_state_cert_show(s);