From nobody Thu Apr 9 03:08:59 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 619C8C433FE for ; Sat, 19 Nov 2022 01:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231984AbiKSBYK (ORCPT ); Fri, 18 Nov 2022 20:24:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233053AbiKSBWz (ORCPT ); Fri, 18 Nov 2022 20:22:55 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AA3232B82; Fri, 18 Nov 2022 16:23:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668817431; x=1700353431; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kG3nCP9dnjVyAb0rhxfcQS0XfXKR+QBYZvRjPdhXez0=; b=ZlvQD5LAiE5dqkBxDSWQ5XXgNmhCR8+KYFPKnBpCp2xG0LtmtdkALozS OXpHqJhlH9f6kE02XUQ40a/B21fGk4+P4AGeSkNmHRP82+0qtPUS4Dke2 4IyB8RGZBFymMY8zZnGaVNOrOSWTTn6DNVlWmFwC0ucM33iC8p7qc+qIO sOPY+GrrqOLTJeVEszXnR0C4lg2BWyneJGn/KVXOB2l/FIwfM4/Dp9wx+ UP/FgXHbFhxyjRaw2j/j8lAFQvw88NqFQb5ltUq42qYaEqUpaiYyPQIyj xc8W72luu+JJMHZ/lRI3p9KuOlflOeDS7AKRqNn6Tx0123GLzJstXWysH Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="293656147" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="293656147" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2022 16:23:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="618202703" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="618202703" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 18 Nov 2022 16:23:45 -0800 Received: from debox1-desk4.lan (unknown [10.252.138.169]) by linux.intel.com (Postfix) with ESMTP id B43B9580A6C; Fri, 18 Nov 2022 16:23:45 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, hdegoede@redhat.com, markgross@kernel.org, andriy.shevchenko@linux.intel.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 2/9] platform/x86/intel/sdsi: Hide attributes if hardware doesn't support Date: Fri, 18 Nov 2022 16:23:36 -0800 Message-Id: <20221119002343.1281885-3-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221119002343.1281885-1-david.e.box@linux.intel.com> References: <20221119002343.1281885-1-david.e.box@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Provisioning capabilities are enabled by a bit set by BIOS. Read this bit and hide the provisioning attributes if the On Demand feature is not enabled. Also, remove the sdsi_enabled boolean from private and instead add a features register since this will be used for future features. Signed-off-by: David E. Box Reviewed-by: Hans de Goede --- V2 - No change drivers/platform/x86/intel/sdsi.c | 33 ++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel= /sdsi.c index 32793919473d..bca05b4dd983 100644 --- a/drivers/platform/x86/intel/sdsi.c +++ b/drivers/platform/x86/intel/sdsi.c @@ -41,7 +41,8 @@ #define SDSI_SIZE_READ_MSG (SDSI_SIZE_MAILBOX * 4) =20 #define SDSI_ENABLED_FEATURES_OFFSET 16 -#define SDSI_ENABLED BIT(3) +#define SDSI_FEATURE_SDSI BIT(3) + #define SDSI_SOCKET_ID_OFFSET 64 #define SDSI_SOCKET_ID GENMASK(3, 0) =20 @@ -100,7 +101,7 @@ struct sdsi_priv { void __iomem *mbox_addr; void __iomem *regs_addr; u32 guid; - bool sdsi_enabled; + u32 features; }; =20 /* SDSi mailbox operations must be performed using 64bit mov instructions = */ @@ -332,9 +333,6 @@ static ssize_t sdsi_provision(struct sdsi_priv *priv, c= har *buf, size_t count, struct sdsi_mbox_info info; int ret; =20 - if (!priv->sdsi_enabled) - return -EPERM; - if (count > (SDSI_SIZE_WRITE_MSG - SDSI_SIZE_CMD)) return -EOVERFLOW; =20 @@ -405,9 +403,6 @@ static long state_certificate_read(struct file *filp, s= truct kobject *kobj, size_t size; int ret; =20 - if (!priv->sdsi_enabled) - return -EPERM; - if (off) return 0; =20 @@ -464,6 +459,23 @@ static struct bin_attribute *sdsi_bin_attrs[] =3D { NULL }; =20 +static umode_t +sdsi_battr_is_visible(struct kobject *kobj, struct bin_attribute *attr, in= t n) +{ + struct device *dev =3D kobj_to_dev(kobj); + struct sdsi_priv *priv =3D dev_get_drvdata(dev); + + /* Registers file is always readable if the device is present */ + if (attr =3D=3D &bin_attr_registers) + return attr->attr.mode; + + /* All other attributes not visible if BIOS has not enabled On Demand */ + if (!(priv->features & SDSI_FEATURE_SDSI)) + return 0; + + return attr->attr.mode; +} + static ssize_t guid_show(struct device *dev, struct device_attribute *attr= , char *buf) { struct sdsi_priv *priv =3D dev_get_drvdata(dev); @@ -480,6 +492,7 @@ static struct attribute *sdsi_attrs[] =3D { static const struct attribute_group sdsi_group =3D { .attrs =3D sdsi_attrs, .bin_attrs =3D sdsi_bin_attrs, + .is_bin_visible =3D sdsi_battr_is_visible, }; __ATTRIBUTE_GROUPS(sdsi); =20 @@ -490,7 +503,6 @@ static int sdsi_map_mbox_registers(struct sdsi_priv *pr= iv, struct pci_dev *paren u32 size =3D FIELD_GET(DT_SIZE, disc_table->access_info); u32 tbir =3D FIELD_GET(DT_TBIR, disc_table->offset); u32 offset =3D DT_OFFSET(disc_table->offset); - u32 features_offset; struct resource res =3D {}; =20 /* Starting location of SDSi MMIO region based on access type */ @@ -528,8 +540,7 @@ static int sdsi_map_mbox_registers(struct sdsi_priv *pr= iv, struct pci_dev *paren priv->mbox_addr =3D priv->control_addr + SDSI_SIZE_CONTROL; priv->regs_addr =3D priv->mbox_addr + SDSI_SIZE_MAILBOX; =20 - features_offset =3D readq(priv->regs_addr + SDSI_ENABLED_FEATURES_OFFSET); - priv->sdsi_enabled =3D !!(features_offset & SDSI_ENABLED); + priv->features =3D readq(priv->regs_addr + SDSI_ENABLED_FEATURES_OFFSET); =20 return 0; } --=20 2.34.1