Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp255629pxb; Thu, 31 Mar 2022 04:52:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvw5jvegbwSmXAF0+4HCPHoM2FcRow8ruFfCATTny51nBN+z00N/TEzKdop2Aj4Tnz74z/ X-Received: by 2002:a17:90a:dd46:b0:1b8:8:7303 with SMTP id u6-20020a17090add4600b001b800087303mr5640139pjv.197.1648727552735; Thu, 31 Mar 2022 04:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648727552; cv=none; d=google.com; s=arc-20160816; b=UnwWWj24ed5w0Cik0DIRo0nh28GID+4jGReTH4Z+z0VzADUMMr83Dgxa8bmIfShEzo YDnckKHUNZeEp84nCT6xAqU1e7Bd6PDZR3BVxiVIr0kTznM7/mfCCTMpNfPAcCA6223X s9OYf33KssTQvizW8aaaNWc3NO2PS/OAgDVLcQwNs5CW0us/fedoVfge8RV64n+UmRmk QN9hESxOALtkFIOZ2R4ypnlz4DOniliAvAyh0EVrUs2+9qxCGzDQ0RGe3rnQkDetYpEG HTe/Hxrwh/fU38RR07DG4QYlSL7jOGCUwsDu+WL3dGhqPLhpvC1m0u2Mm0wN4U3oPKoB IhKA== 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=OnA9eqY0Hu7/oiqlukn/YB6rjaz4uLkDY9HGFVrYIVg=; b=tjvjI87fo5gCZcsxHKd8bs54JKXRzJWRHplQIOzFVDgL8nvmrIVtOcPBsA4zCsjnER RnsXtPtYXe+/pTCZ1UxoPDYznjfYijwsG3bEYF7FkHqq3cOjEfr8hpWWTGUb69Pew15D E/xMWPvPF63DBX+awKk43xefRV1djI86/mN+ANjqvu3yzL+seKy7f4Cqdx2vf2EwryZy TMe68J6CMEjWbJEMkp93GBFuxa9dkLHa7Vs4w8mZcCOzP44p1BD13MAVo1E22mWBOB3A R8w4PjzkCkVngrZJvrRibc7qowDqMBSP72Tt9aphKI2CftoVBdYI8hScxd91Ed1ICS0e 0RAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=InqlwMuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ip8-20020a17090b314800b001c993d8106dsi3339155pjb.62.2022.03.31.04.52.17; Thu, 31 Mar 2022 04:52:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=InqlwMuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232349AbiCaHpb (ORCPT + 99 others); Thu, 31 Mar 2022 03:45:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232358AbiCaHp0 (ORCPT ); Thu, 31 Mar 2022 03:45:26 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 248D322B17 for ; Thu, 31 Mar 2022 00:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648712620; x=1680248620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qUXUdIx3W5/Jng1H4E3s8psSKJYBq5/lfpgRd8OZoYE=; b=InqlwMuMQ9pa0XV4VQIQ1oR6lzzyxrPSaNcqNRRM2JKnsAtmsVtn6FFv tIkRMKLkjzZYK2D/EHc4IkGBQuArye3++jVypnI9hg5dQK3lzEO3qseZa 1gXk5q3kUl4Loj9055GbmPHjSIumAOeD6tdTl4sVVedudUqLX7L/vMKT3 zYlyysN5PzAbFzJDzQbZAMBkJqVzvSP5HSEZ+yacU/l3uRy+R+qs/AYw/ Hb+PtoJnBD54TM0N9Upkmg8rMxWGm4E3pADt5tFoFnvLhYBy9ZwuBfVJA /U3y6NU8WDzBrr/qnYSiTmm2p8r4DaDSbzrdBOOkMQz6GDt1m8f80ltSx Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10302"; a="257326439" X-IronPort-AV: E=Sophos;i="5.90,224,1643702400"; d="scan'208";a="257326439" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 00:43:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,224,1643702400"; d="scan'208";a="566240327" Received: from unknown (HELO localhost.localdomain) ([10.226.216.87]) by orsmga008.jf.intel.com with ESMTP; 31 Mar 2022 00:43:37 -0700 From: kah.jing.lee@intel.com To: Dinh Nguyen Cc: linux-kernel@vger.kernel.org, radu.bacrau@intel.com, tien.sung.ang@intel.com, Kah Jing Lee Subject: [PATCH 2/2] firmware: stratix10-rsu: extend RSU driver to get DCMF status Date: Thu, 31 Mar 2022 23:42:39 +0800 Message-Id: <20220331154237.4158001-3-kah.jing.lee@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <4ab174c2-8772-d543-9784-31b4660efd82@kernel.org> References: <4ab174c2-8772-d543-9784-31b4660efd82@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kah Jing Lee Extend RSU driver to get DCMF status. The status of each DCMF is reported. The currently used DCMF is used as reference, while the other three are compared against it to determine if they are corrupted. DCMF = Decision Configuration Management Firmware. RSU = Remote System Update Signed-off-by: Radu Bacrau Signed-off-by: Kah Jing Lee --- drivers/firmware/stratix10-rsu.c | 131 +++++++++++++++++++++++++++++-- 1 file changed, 125 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c index 9378075d04e9..856bc03ca07c 100644 --- a/drivers/firmware/stratix10-rsu.c +++ b/drivers/firmware/stratix10-rsu.c @@ -24,12 +24,16 @@ #define RSU_DCMF1_MASK GENMASK_ULL(63, 32) #define RSU_DCMF2_MASK GENMASK_ULL(31, 0) #define RSU_DCMF3_MASK GENMASK_ULL(63, 32) +#define RSU_DCMF0_STATUS_MASK GENMASK_ULL(15, 0) +#define RSU_DCMF1_STATUS_MASK GENMASK_ULL(31, 16) +#define RSU_DCMF2_STATUS_MASK GENMASK_ULL(47, 32) +#define RSU_DCMF3_STATUS_MASK GENMASK_ULL(63, 48) #define RSU_TIMEOUT (msecs_to_jiffies(SVC_RSU_REQUEST_TIMEOUT_MS)) #define INVALID_RETRY_COUNTER 0xFF #define INVALID_DCMF_VERSION 0xFF - +#define INVALID_DCMF_STATUS 0xFFFFFFFF typedef void (*rsu_callback)(struct stratix10_svc_client *client, struct stratix10_svc_cb_data *data); @@ -49,6 +53,10 @@ typedef void (*rsu_callback)(struct stratix10_svc_client *client, * @dcmf_version.dcmf1: Quartus dcmf1 version * @dcmf_version.dcmf2: Quartus dcmf2 version * @dcmf_version.dcmf3: Quartus dcmf3 version + * @dcmf_status.dcmf0: dcmf0 status + * @dcmf_status.dcmf1: dcmf1 status + * @dcmf_status.dcmf2: dcmf2 status + * @dcmf_status.dcmf3: dcmf3 status * @retry_counter: the current image's retry counter * @max_retry: the preset max retry value */ @@ -73,6 +81,13 @@ struct stratix10_rsu_priv { unsigned int dcmf3; } dcmf_version; + struct { + unsigned int dcmf0; + unsigned int dcmf1; + unsigned int dcmf2; + unsigned int dcmf3; + } dcmf_status; + unsigned int retry_counter; unsigned int max_retry; }; @@ -129,7 +144,7 @@ static void rsu_command_callback(struct stratix10_svc_client *client, struct stratix10_rsu_priv *priv = client->priv; if (data->status == BIT(SVC_STATUS_NO_SUPPORT)) - dev_warn(client->dev, "FW doesn't support notify\n"); + dev_warn(client->dev, "Secure FW doesn't support notify\n"); else if (data->status == BIT(SVC_STATUS_ERROR)) dev_err(client->dev, "Failure, returned status is %lu\n", BIT(data->status)); @@ -139,7 +154,7 @@ static void rsu_command_callback(struct stratix10_svc_client *client, /** * rsu_retry_callback() - Callback from Intel service layer for getting - * the current image's retry counter from the firmware + * the current image's retry counter from firmware * @client: pointer to client * @data: pointer to callback data structure * @@ -156,7 +171,7 @@ static void rsu_retry_callback(struct stratix10_svc_client *client, if (data->status == BIT(SVC_STATUS_OK)) priv->retry_counter = *counter; else if (data->status == BIT(SVC_STATUS_NO_SUPPORT)) - dev_warn(client->dev, "FW doesn't support retry\n"); + dev_warn(client->dev, "Secure FW doesn't support retry\n"); else dev_err(client->dev, "Failed to get retry counter %lu\n", BIT(data->status)); @@ -181,7 +196,7 @@ static void rsu_max_retry_callback(struct stratix10_svc_client *client, if (data->status == BIT(SVC_STATUS_OK)) priv->max_retry = *max_retry; else if (data->status == BIT(SVC_STATUS_NO_SUPPORT)) - dev_warn(client->dev, "FW doesn't support max retry\n"); + dev_warn(client->dev, "Secure FW doesn't support max retry\n"); else dev_err(client->dev, "Failed to get max retry %lu\n", BIT(data->status)); @@ -215,6 +230,35 @@ static void rsu_dcmf_version_callback(struct stratix10_svc_client *client, complete(&priv->completion); } +/** + * rsu_dcmf_status_callback() - Callback from Intel service layer for getting + * the DCMF status + * @client: pointer to client + * @data: pointer to callback data structure + * + * Callback from Intel service layer for DCMF status + */ +static void rsu_dcmf_status_callback(struct stratix10_svc_client *client, + struct stratix10_svc_cb_data *data) +{ + struct stratix10_rsu_priv *priv = client->priv; + unsigned long long *value = (unsigned long long *)data->kaddr1; + + if (data->status == BIT(SVC_STATUS_OK)) { + priv->dcmf_status.dcmf0 = FIELD_GET(RSU_DCMF0_STATUS_MASK, + *value); + priv->dcmf_status.dcmf1 = FIELD_GET(RSU_DCMF1_STATUS_MASK, + *value); + priv->dcmf_status.dcmf2 = FIELD_GET(RSU_DCMF2_STATUS_MASK, + *value); + priv->dcmf_status.dcmf3 = FIELD_GET(RSU_DCMF3_STATUS_MASK, + *value); + } else + dev_err(client->dev, "failed to get DCMF status\n"); + + complete(&priv->completion); +} + /** * rsu_send_msg() - send a message to Intel service layer * @priv: pointer to rsu private data @@ -361,7 +405,8 @@ static ssize_t max_retry_show(struct device *dev, if (!priv) return -ENODEV; - return sprintf(buf, "0x%08x\n", priv->max_retry); + return scnprintf(buf, sizeof(priv->max_retry), + "0x%08x\n", priv->max_retry); } static ssize_t dcmf0_show(struct device *dev, @@ -408,6 +453,61 @@ static ssize_t dcmf3_show(struct device *dev, return sprintf(buf, "0x%08x\n", priv->dcmf_version.dcmf3); } +static ssize_t dcmf0_status_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct stratix10_rsu_priv *priv = dev_get_drvdata(dev); + + if (!priv) + return -ENODEV; + + if (priv->dcmf_status.dcmf0 == INVALID_DCMF_STATUS) + return -EIO; + + return sprintf(buf, "0x%08x\n", priv->dcmf_status.dcmf0); +} + +static ssize_t dcmf1_status_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct stratix10_rsu_priv *priv = dev_get_drvdata(dev); + + if (!priv) + return -ENODEV; + + if (priv->dcmf_status.dcmf1 == INVALID_DCMF_STATUS) + return -EIO; + + return sprintf(buf, "0x%08x\n", priv->dcmf_status.dcmf1); +} + +static ssize_t dcmf2_status_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct stratix10_rsu_priv *priv = dev_get_drvdata(dev); + + if (!priv) + return -ENODEV; + + if (priv->dcmf_status.dcmf2 == INVALID_DCMF_STATUS) + return -EIO; + + return sprintf(buf, "0x%08x\n", priv->dcmf_status.dcmf2); +} + +static ssize_t dcmf3_status_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct stratix10_rsu_priv *priv = dev_get_drvdata(dev); + + if (!priv) + return -ENODEV; + + if (priv->dcmf_status.dcmf3 == INVALID_DCMF_STATUS) + return -EIO; + + return sprintf(buf, "0x%08x\n", priv->dcmf_status.dcmf3); +} static ssize_t reboot_image_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -484,6 +584,10 @@ static DEVICE_ATTR_RO(dcmf0); static DEVICE_ATTR_RO(dcmf1); static DEVICE_ATTR_RO(dcmf2); static DEVICE_ATTR_RO(dcmf3); +static DEVICE_ATTR_RO(dcmf0_status); +static DEVICE_ATTR_RO(dcmf1_status); +static DEVICE_ATTR_RO(dcmf2_status); +static DEVICE_ATTR_RO(dcmf3_status); static DEVICE_ATTR_WO(reboot_image); static DEVICE_ATTR_WO(notify); @@ -500,6 +604,10 @@ static struct attribute *rsu_attrs[] = { &dev_attr_dcmf1.attr, &dev_attr_dcmf2.attr, &dev_attr_dcmf3.attr, + &dev_attr_dcmf0_status.attr, + &dev_attr_dcmf1_status.attr, + &dev_attr_dcmf2_status.attr, + &dev_attr_dcmf3_status.attr, &dev_attr_reboot_image.attr, &dev_attr_notify.attr, NULL @@ -532,6 +640,10 @@ static int stratix10_rsu_probe(struct platform_device *pdev) priv->dcmf_version.dcmf2 = INVALID_DCMF_VERSION; priv->dcmf_version.dcmf3 = INVALID_DCMF_VERSION; priv->max_retry = INVALID_RETRY_COUNTER; + priv->dcmf_status.dcmf0 = INVALID_DCMF_STATUS; + priv->dcmf_status.dcmf1 = INVALID_DCMF_STATUS; + priv->dcmf_status.dcmf2 = INVALID_DCMF_STATUS; + priv->dcmf_status.dcmf3 = INVALID_DCMF_STATUS; mutex_init(&priv->lock); priv->chan = stratix10_svc_request_channel_byname(&priv->client, @@ -561,6 +673,13 @@ static int stratix10_rsu_probe(struct platform_device *pdev) stratix10_svc_free_channel(priv->chan); } + ret = rsu_send_msg(priv, COMMAND_RSU_DCMF_STATUS, + 0, rsu_dcmf_status_callback); + if (ret) { + dev_err(dev, "Error, getting DCMF status %i\n", ret); + stratix10_svc_free_channel(priv->chan); + } + ret = rsu_send_msg(priv, COMMAND_RSU_RETRY, 0, rsu_retry_callback); if (ret) { dev_err(dev, "Error, getting RSU retry %i\n", ret); -- 2.25.1