From patchwork Tue Nov 28 18:56:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 170924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp4151254vqx; Tue, 28 Nov 2023 10:57:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDXGUNXu+mdcKqzQ7td3+L41Wr8sEvHk4t+CVNU9BmOpmCooEpRRQwg7dogRy9MjT99nri X-Received: by 2002:a05:6a00:27ab:b0:6be:265:1bf6 with SMTP id bd43-20020a056a0027ab00b006be02651bf6mr17981804pfb.32.1701197831545; Tue, 28 Nov 2023 10:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701197831; cv=none; d=google.com; s=arc-20160816; b=VYkoPvrVEnvKM9+p7oELQWGgsczDqG99T6uvGyWczBaZmsd96xEW7J2Ykh669hwoUq Lb15g/+Xn65xE7a1Oy4fPNZviBKuKOfLs9ogAH4DRYX1sDdArXkZizpZ65fs8L5aAVBV 5OspjhMq10J/1TyquNZtxXdqukBj+6SUVnfdsV7BwLeau01b0ZyQ9vqB4tp00MdH2IwT xgIEGQxUz6ocgfZmG/ZKhP4n32RD7DUjbZ62kEqeoCW4B2glxY6QZ266gFOW1sQX2BCY kUHmogyuk1p2Sq+LmrdqOSvVAbx5a2rr/xwF0MAwR7TR85UtQsKBFBzE4Rs/cE0fYBQH T/4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VrM1qNgu2gJE+Gt9wtrTZ/bnBxA/uSUo6nQldqqpb+k=; fh=WxcXzAXi1awalX5nBNdKiu2pCszhVA/a0vtqlN5we7w=; b=mw4YEj9jhN5ZyTexk9gygDxH5XqgFWLVLKHSPHjskqBe6VfWYvYHp1IyM2ATEGef3E X1pTK7aK1d1LH+JSn+swZ6Z30wFnjd4ce9S+qZJK3W2bYn/oETHOi6QM2EJ3KiqmWukZ tXxlud+qnz99zjfIDW+zXfReJ0RXPsJAZ/YWJvENjCAgTE1/ApY9msUBq4wY68xRssNf OH+xk89fV6jIKAge0j+r8mBbDmo2CYkrVzGYRbpA2+4rcPDIkfaZpvUAVlnXNfdGhO7u l5wOlulQVXk0tFw67YNbdt+6e7TwPrwWQmSjvUj7Ecbh1OwJJRqWmty2WCMmdp6nG33C 3ISQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c88wYJwg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id a33-20020a056a0011e100b006cd90790ce7si4334344pfu.399.2023.11.28.10.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 10:57:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c88wYJwg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 0D27A80758E5; Tue, 28 Nov 2023 10:57:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376273AbjK1S4n (ORCPT + 99 others); Tue, 28 Nov 2023 13:56:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbjK1S4b (ORCPT ); Tue, 28 Nov 2023 13:56:31 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDBE4D63; Tue, 28 Nov 2023 10:56:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701197797; x=1732733797; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3bkVOKyBtFYAd4+DZfRvnlnd4INO8vcisMC16xxuhTw=; b=c88wYJwgs78a01IJfJ46ELLPNM9ugU0Gm2HAQzoH6h5GeHJ0BsrKuEIS XV3DGIfBUhwfWCAraKo7lsJIC+XyDCdX4AoKGulh7Yr+cheah9QoVBmFq PkJs+tcLNMpdfUtT6BtcGsFEKjx1tKHy2N2SYkp5hTNnqYVjn7keDKbzy jt13ElYYO9wo81LlAnK+rJc85z50BnVqF51Ed2gjhNZVgqrwF27a896SB xR6eRh8/kjtMGmHI8y1Kc/ftErd5fC4fGO6MUh1OlVs3DibhEhLc88/Sw 2KsEmz0jw0zvvtpOB0PMdMMcCXHa4cTZoBy05nUkARfWL8ehaNalyrWFY A==; X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="372366976" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="372366976" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 10:56:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="892165784" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="892165784" Received: from spandruv-desk.jf.intel.com ([10.54.75.14]) by orsmga004.jf.intel.com with ESMTP; 28 Nov 2023 10:56:11 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, andriy.shevchenko@linux.intel.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH 5/6] platform/x86: ISST: Process read/write blocked feature status Date: Tue, 28 Nov 2023 10:56:04 -0800 Message-Id: <20231128185605.3027653-6-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231128185605.3027653-1-srinivas.pandruvada@linux.intel.com> References: <20231128185605.3027653-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 28 Nov 2023 10:57:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783835217088367218 X-GMAIL-MSGID: 1783835217088367218 When a feature is read blocked, don't continue to read SST information and register with SST core. When the feature is write blocked, continue to offer read interface for SST parameters, but don't allow any operation to change state. A state change results from SST level change, feature change or class of service change. Signed-off-by: Srinivas Pandruvada --- .../intel/speed_select_if/isst_tpmi_core.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index 0b6d2c864437..ed3a04d6c99c 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +++ b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c @@ -234,6 +234,7 @@ struct perf_level { * @saved_clos_configs: Save SST-CP CLOS configuration to store restore for suspend/resume * @saved_clos_assocs: Save SST-CP CLOS association to store restore for suspend/resume * @saved_pp_control: Save SST-PP control information to store restore for suspend/resume + * @write_blocked: Write operation is blocked, so can't change SST state * * This structure is used store complete SST information for a power_domain. This information * is used to read/write request for any SST IOCTL. Each physical CPU package can have multiple @@ -259,6 +260,7 @@ struct tpmi_per_power_domain_info { u64 saved_clos_configs[4]; u64 saved_clos_assocs[4]; u64 saved_pp_control; + bool write_blocked; }; /** @@ -514,6 +516,9 @@ static long isst_if_clos_param(void __user *argp) if (!power_domain_info) return -EINVAL; + if (power_domain_info->write_blocked) + return -EPERM; + if (clos_param.get_set) { _write_cp_info("clos.min_freq", clos_param.min_freq_mhz, (SST_CLOS_CONFIG_0_OFFSET + clos_param.clos * SST_REG_SIZE), @@ -602,6 +607,9 @@ static long isst_if_clos_assoc(void __user *argp) power_domain_info = &sst_inst->power_domain_info[punit_id]; + if (power_domain_info->write_blocked) + return -EPERM; + offset = SST_CLOS_ASSOC_0_OFFSET + (punit_cpu_no / SST_CLOS_ASSOC_CPUS_PER_REG) * SST_REG_SIZE; shift = punit_cpu_no % SST_CLOS_ASSOC_CPUS_PER_REG; @@ -752,6 +760,9 @@ static int isst_if_set_perf_level(void __user *argp) if (!power_domain_info) return -EINVAL; + if (power_domain_info->write_blocked) + return -EPERM; + if (!(power_domain_info->pp_header.allowed_level_mask & BIT(perf_level.level))) return -EINVAL; @@ -809,6 +820,9 @@ static int isst_if_set_perf_feature(void __user *argp) if (!power_domain_info) return -EINVAL; + if (power_domain_info->write_blocked) + return -EPERM; + _write_pp_info("perf_feature", perf_feature.feature, SST_PP_CONTROL_OFFSET, SST_PP_FEATURE_STATE_START, SST_PP_FEATURE_STATE_WIDTH, SST_MUL_FACTOR_NONE) @@ -1257,11 +1271,21 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd, int tpmi_sst_dev_add(struct auxiliary_device *auxdev) { + int read_blocked = 0, write_blocked = 0; struct intel_tpmi_plat_info *plat_info; struct tpmi_sst_struct *tpmi_sst; int i, ret, pkg = 0, inst = 0; int num_resources; + ret = tpmi_get_feature_status(auxdev, TPMI_ID_SST, &read_blocked, &write_blocked); + if (ret) + dev_info(&auxdev->dev, "Can't read feature status: ignoring read/write blocked status\n"); + + if (read_blocked) { + dev_info(&auxdev->dev, "Firmware has blocked reads, exiting\n"); + return -ENODEV; + } + plat_info = tpmi_get_platform_data(auxdev); if (!plat_info) { dev_err(&auxdev->dev, "No platform info\n"); @@ -1306,6 +1330,7 @@ int tpmi_sst_dev_add(struct auxiliary_device *auxdev) tpmi_sst->power_domain_info[i].package_id = pkg; tpmi_sst->power_domain_info[i].power_domain_id = i; tpmi_sst->power_domain_info[i].auxdev = auxdev; + tpmi_sst->power_domain_info[i].write_blocked = write_blocked; tpmi_sst->power_domain_info[i].sst_base = devm_ioremap_resource(&auxdev->dev, res); if (IS_ERR(tpmi_sst->power_domain_info[i].sst_base)) return PTR_ERR(tpmi_sst->power_domain_info[i].sst_base);