From patchwork Fri Jul 7 08:03:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lee, Kah Jing" X-Patchwork-Id: 117034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3100374vqx; Fri, 7 Jul 2023 01:08:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlFdcpdKOcTyWV4w2W5omgqVmlXzLeGIVIN6cktxGKkndhYjwqJ+DVzu72PH7gkuo4yGVokd X-Received: by 2002:a05:6a20:197:b0:127:aaf:59a2 with SMTP id 23-20020a056a20019700b001270aaf59a2mr4125248pzy.35.1688717314791; Fri, 07 Jul 2023 01:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688717314; cv=none; d=google.com; s=arc-20160816; b=qX+YvN+INm9aqtFcrQJZOADSF9ljc9akpBKdMUQwgc9QTXfUkakr//iiClxMEir1bF R3vtez3Pyhd7xlN+m3unL1vG9guqwM/lnwCNXOV0r1GzPx8GsxUhBR07e6BMfq0WD4Ep qXGWE8wqlksxCSH+dgAlVV3RE555Q1abz/1ul1OZ1feEstg7fzg7n82NBFuBEsj1H+y8 uPmNcPEGsmhcjqIxk/sJRGlewyX3mlE5L+c5uABYbhxH7u8DnIM01vLdqhtwayBPiLXd A73IydZ7+Amu3ZrJSS2eA2JgJHnscwsN7siw5P0PKMGmKmk+ItnXi96PKlyhHq0sVWTE SlrA== 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=0cbyUw7HbNwtDvEufCqQwp/0sSTq1slk/MDyKZ/azHo=; fh=DinVQorn00FiJ7YepuTCINDjGwzfdGRGqKOa5gmpmNI=; b=nrvqoqCVUYE0qx6P+VNvJALb2T78v+h5FDQl36SbtrXp5CgTNV3DMDzcbBoeVfp9Aj D0Si0eFx46PRpyuuSc+6LKl+eYmd/gYT5NVLkFTJ52UNcP/Gsu02fj2d3ubjfxMdAZ6A PNC7rl62UuOHV4Tqv08ldKOlm+6U3HTTgezof2BniQ41ab5VykYTwFlC9+VkeztNnde1 qqmrGz8hAH3LZxE6itzyqIeqNhqkt9iqEx+bjoqPwkN/IY9p867ND6HMzsRAh8XyjcBG DhxzwsUe6Mzkdzkx6wxjYqC7JlDsZgjBndPwhAQUHR2a5VwB0e3mvR4xPjvyU8wsoCDx E4hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VxHKHhZl; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a170902d4cf00b001ab29e00303si3274321plg.426.2023.07.07.01.08.22; Fri, 07 Jul 2023 01:08:34 -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=VxHKHhZl; 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 S232391AbjGGIE2 (ORCPT + 99 others); Fri, 7 Jul 2023 04:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231962AbjGGIE1 (ORCPT ); Fri, 7 Jul 2023 04:04:27 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24143170C for ; Fri, 7 Jul 2023 01:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688717066; x=1720253066; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ueADtJqxoyNqdjFUUjZp6Vw7c9mnY+aYtssylW9Ip58=; b=VxHKHhZlW+l4pB8T6ielYbPqSO6iODdXUPi9VFN4zxNiHJ06VNYAiRol T0vDdhrYmkZWZ4+HEhKlL7eOuhfgNhUZaBuxoZfu9i4l3NSOPLhOwkKt0 fAKE1T4zpWRVNN7mFl1rsjFPAW0v5eETo6nWNT6dd8/zwInH2tFIhXBdw 2qUeI3mGkOfeC/tlWhdpASHGN/LEm4KzeC3ExKY06hhaYlnMOEtxNmE2i +Rmw41rG2y+9CuH+wX8BsM7iV8q6G3fts0qurdC7n0ShladUrnO8dZ5pw bWEAuUIkQNOe80qsIUvlpGYr1LCgnTqOqSwkiGx0Rf8Ypo+Cx6DvGGqHi A==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="429896775" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="429896775" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2023 01:04:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="844019395" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="844019395" Received: from unknown (HELO localhost.localdomain) ([10.226.216.117]) by orsmga004.jf.intel.com with ESMTP; 07 Jul 2023 01:04:23 -0700 From: kah.jing.lee@intel.com To: dinguyen@kernel.org Cc: linux-kernel@vger.kernel.org, radu.bacrau@intel.com, tien.sung.ang@intel.com, Teh Wen Ping , Kah Jing Lee Subject: [PATCH 1/2 RESEND] firmware: stratix10-svc: Generic Mailbox Command Date: Fri, 7 Jul 2023 16:03:06 +0800 Message-Id: <20230707080305.1722983-1-kah.jing.lee@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230707080112.1722827-1-kah.jing.lee@intel.com> References: <20230707080112.1722827-1-kah.jing.lee@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770748447281965306?= X-GMAIL-MSGID: =?utf-8?q?1770748447281965306?= From: Teh Wen Ping Add generic mailbox command that can support SDM command. User can use this command to send SDM mailbox command. User have to specified an input file which contain the command data and an output file for SDM response to be copied over. Signed-off-by: Teh Wen Ping Signed-off-by: Kah Jing Lee --- drivers/firmware/stratix10-svc.c | 18 +++++++++++++ include/linux/firmware/intel/stratix10-smc.h | 25 +++++++++++++++++++ .../firmware/intel/stratix10-svc-client.h | 5 ++++ 3 files changed, 48 insertions(+) diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c index 2d674126160f..430e8bf0bca9 100644 --- a/drivers/firmware/stratix10-svc.c +++ b/drivers/firmware/stratix10-svc.c @@ -37,6 +37,7 @@ #define SVC_NUM_CHANNEL 3 #define FPGA_CONFIG_DATA_CLAIM_TIMEOUT_MS 200 #define FPGA_CONFIG_STATUS_TIMEOUT_SEC 30 +#define BYTE_TO_WORD_SIZE 4 /* stratix10 service layer clients */ #define STRATIX10_RSU "stratix10-rsu" @@ -361,6 +362,13 @@ static void svc_thread_recv_status_ok(struct stratix10_svc_data *p_data, cb_data->kaddr2 = svc_pa_to_va(res.a2); cb_data->kaddr3 = &res.a3; break; + case COMMAND_MBOX_SEND_CMD: + cb_data->status = BIT(SVC_STATUS_OK); + cb_data->kaddr1 = &res.a1; + /* SDM return size in u32 word. Convert size to u8 */ + res.a2 = res.a2 * BYTE_TO_WORD_SIZE; + cb_data->kaddr2 = &res.a2; + break; default: pr_warn("it shouldn't happen\n"); break; @@ -534,6 +542,15 @@ static int svc_normal_to_secure_thread(void *data) a1 = 0; a2 = 0; break; + case COMMAND_MBOX_SEND_CMD: + a0 = INTEL_SIP_SMC_MBOX_SEND_CMD; + a1 = pdata->arg[0]; + a2 = (unsigned long)pdata->paddr; + a3 = (unsigned long)pdata->size / BYTE_TO_WORD_SIZE; + a4 = pdata->arg[1]; + a5 = (unsigned long)pdata->paddr_output; + a6 = (unsigned long)pdata->size_output / BYTE_TO_WORD_SIZE; + break; default: pr_warn("it shouldn't happen\n"); break; @@ -597,6 +614,7 @@ static int svc_normal_to_secure_thread(void *data) case COMMAND_FCS_DATA_ENCRYPTION: case COMMAND_FCS_DATA_DECRYPTION: case COMMAND_FCS_RANDOM_NUMBER_GEN: + case COMMAND_MBOX_SEND_CMD: cbdata->status = BIT(SVC_STATUS_INVALID_PARAM); cbdata->kaddr1 = NULL; cbdata->kaddr2 = NULL; diff --git a/include/linux/firmware/intel/stratix10-smc.h b/include/linux/firmware/intel/stratix10-smc.h index a718f853d457..ee80ca4bb0d0 100644 --- a/include/linux/firmware/intel/stratix10-smc.h +++ b/include/linux/firmware/intel/stratix10-smc.h @@ -466,6 +466,31 @@ INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE) #define INTEL_SIP_SMC_FIRMWARE_VERSION \ INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FIRMWARE_VERSION) +/** + * SMC call protocol for Mailbox, starting FUNCID from 60 + * + * Call register usage: + * a0 INTEL_SIP_SMC_MBOX_SEND_CMD + * a1 mailbox command code + * a2 physical address that contain mailbox command data (not include header) + * a3 mailbox command data size in word + * a4 set to 0 for CASUAL, set to 1 for URGENT + * a5 physical address for secure firmware to put response data + * (not include header) + * a6 maximum size in word of physical address to store response data + * a7 not used + * + * Return status + * a0 INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_REJECTED or + * INTEL_SIP_SMC_STATUS_ERROR + * a1 mailbox error code + * a2 response data length in word + * a3 not used + */ +#define INTEL_SIP_SMC_FUNCID_MBOX_SEND_CMD 60 + #define INTEL_SIP_SMC_MBOX_SEND_CMD \ + INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_MBOX_SEND_CMD) + /** * Request INTEL_SIP_SMC_SVC_VERSION * diff --git a/include/linux/firmware/intel/stratix10-svc-client.h b/include/linux/firmware/intel/stratix10-svc-client.h index 0c16037fd08d..60ed82112680 100644 --- a/include/linux/firmware/intel/stratix10-svc-client.h +++ b/include/linux/firmware/intel/stratix10-svc-client.h @@ -118,6 +118,9 @@ struct stratix10_svc_chan; * @COMMAND_SMC_SVC_VERSION: Non-mailbox SMC SVC API Version, * return status is SVC_STATUS_OK * + * @COMMAND_MBOX_SEND_CMD: send generic mailbox command, return status is + * SVC_STATUS_OK or SVC_STATUS_ERROR + * * @COMMAND_RSU_DCMF_STATUS: query firmware for the DCMF status * return status is SVC_STATUS_OK or SVC_STATUS_ERROR * @@ -164,6 +167,8 @@ enum stratix10_svc_command_code { COMMAND_FCS_RANDOM_NUMBER_GEN, /* for general status poll */ COMMAND_POLL_SERVICE_STATUS = 40, + /* for generic mailbox send command */ + COMMAND_MBOX_SEND_CMD = 100, /* Non-mailbox SMC Call */ COMMAND_SMC_SVC_VERSION = 200, }; From patchwork Fri Jul 7 08:03:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lee, Kah Jing" X-Patchwork-Id: 117036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3105297vqx; Fri, 7 Jul 2023 01:20:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlH5bjPfZDlc+oKmpaXBIjV8J18btYhRTpapljwm7lrm8ZGnb50lEoRfUHuIDz/mmPpRJqTT X-Received: by 2002:a17:90a:77c7:b0:263:53be:5120 with SMTP id e7-20020a17090a77c700b0026353be5120mr3275725pjs.36.1688718007491; Fri, 07 Jul 2023 01:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688718007; cv=none; d=google.com; s=arc-20160816; b=cFFwdJ0Ro6hhnMMXZtbU61pyHZTjNj3QXKe/eyHjXlQKV1OIoaRyxz0M1JdiyzBmZz zCfo2R5D8X6LIRzHpsC0HpQLRp+n0gh4g+KG+yqFP7S0+0BBOQTNGZaqJHQYw7qo24F1 QAURyLD77vDKWtmJxUIPV0ULLrpc8tygvO7oUBeFqxs3mXSoyTmLmn3u3ak0YVDS7ZHO X5lvHmKxbdD4sx1vVCy1QDx9kkqC70Y/Te7Qp0slabMv+5eUUP8DhExbiBGhKU5B2BtF upWf5YvisFLsGxQ3rsIRWO6shaaMHCmJBrV1doEM3snHalux89l3exJy5fYbztfvbDnk eYcA== 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=YElKbXEXX8+V3MZZHJpSoaU7ai2VZYg8j0QLusfQMGw=; fh=M8JEvLWIcsunHoO97L4UkAx3HF9Ty+6j85QHG/TkO8Q=; b=Mi7iDfDgfyLbLmPB9aysRRCbZw1hHVu2qxGn7tePt76X3OFuJRQqNZn5eEomvaGH1Z IjZlJZcp2FcU2e8UYWFcKNVVtSBIqEqT+dwJLFtKALCJZI3xMo3GIYJDLssL0vZoDvuN JPnfggE3sEdNfSW38XICJoI4PXL07vKidjUjw2yvE9uBYWnhdiu4T6PlZKxvkQ+P7Xta PzGugIHaVWsitBtNuEZGIO9kA2g3oz24Y1KrjdFdDU/7Ue0bvA3mu2kuqEwQtRSHNh4+ c+291Nn0zwYFxD6vG2c5RvQOaGdAbEG5GKSWYWiyq5ce3EgZeB+ufuN/eXwqXArLRa8q NMcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kCCIGBeK; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a17090adac100b0025bcf85bda2si1545107pjx.7.2023.07.07.01.19.54; Fri, 07 Jul 2023 01:20:07 -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=kCCIGBeK; 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 S232320AbjGGIFI (ORCPT + 99 others); Fri, 7 Jul 2023 04:05:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231962AbjGGIFH (ORCPT ); Fri, 7 Jul 2023 04:05:07 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6194E1BD2 for ; Fri, 7 Jul 2023 01:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688717104; x=1720253104; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cwyIneQDYmXvAFfgDqQkbLNXcw1T1FsKuFKsibrJ0v0=; b=kCCIGBeKtP4KE9P+hB/tJIjN4sdZGhTbv50MIZEKMl2cZ3wBDTk5lWXP KDXD08lJ5IjH225EqqNDXTfaEcM8hrWMIcrf52nfebltWHKsEweh6/+g9 2E1z+TL4ePQDI0icYX0enM1imqIKCqop5LFKWWvIvNPpXTg7NI5HqB1bS NK5TRN2MmfYUhTP65Ex4R9OugKdjN35zxVoyYU7EjgKziIDddM2dstYmX YXud+T+zxmNQiGuVK096uQK2wb6mASrHOl62OZeG+YCZgnzEVmnsqN0CG tWqnQagDiEgxxNdPCyQv5EUftP8n7LuS6p1I4ThpWLtHMJBsJq/H2frzt g==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="362700392" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="362700392" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2023 01:05:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="713923393" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="713923393" Received: from unknown (HELO localhost.localdomain) ([10.226.216.117]) by orsmga007.jf.intel.com with ESMTP; 07 Jul 2023 01:05:01 -0700 From: kah.jing.lee@intel.com To: dinguyen@kernel.org Cc: linux-kernel@vger.kernel.org, radu.bacrau@intel.com, tien.sung.ang@intel.com, Kah Jing Lee Subject: [PATCH 2/2 RESEND] firmware: stratix10-rsu: query spt addresses Date: Fri, 7 Jul 2023 16:03:50 +0800 Message-Id: <20230707080349.1723083-1-kah.jing.lee@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230707080112.1722827-1-kah.jing.lee@intel.com> References: <20230707080112.1722827-1-kah.jing.lee@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770749173498003637?= X-GMAIL-MSGID: =?utf-8?q?1770749173498003637?= From: Radu Bacrau Extend Intel Remote System Update (RSU) driver to get SPT (Sub-Partition Table) addresses. The query SPT address can be used to determine if the RSU QSPI layout is 32kB or 64kB aligned. The alignment can be determined by minus the upper with the lower of the SPT addresses. This patch depends on patch: firmware: stratix10-svc: Generic Mailbox Command Signed-off-by: Radu Bacrau Signed-off-by: Kah Jing Lee --- drivers/firmware/stratix10-rsu.c | 100 ++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c index e51c95f8d445..9f82d5147890 100644 --- a/drivers/firmware/stratix10-rsu.c +++ b/drivers/firmware/stratix10-rsu.c @@ -34,6 +34,10 @@ #define INVALID_RETRY_COUNTER 0xFF #define INVALID_DCMF_VERSION 0xFF #define INVALID_DCMF_STATUS 0xFFFFFFFF +#define INVALID_SPT_ADDRESS 0x0 + +#define RSU_GET_SPT_CMD 0x5A +#define RSU_GET_SPT_RESP_LEN (4 * sizeof(unsigned int)) typedef void (*rsu_callback)(struct stratix10_svc_client *client, struct stratix10_svc_cb_data *data); @@ -59,6 +63,9 @@ typedef void (*rsu_callback)(struct stratix10_svc_client *client, * @dcmf_status.dcmf3: dcmf3 status * @retry_counter: the current image's retry counter * @max_retry: the preset max retry value + * @spt0_address: address of spt0 + * @spt1_address: address of spt1 + * @get_spt_response_buf: response from sdm for get_spt command */ struct stratix10_rsu_priv { struct stratix10_svc_chan *chan; @@ -90,6 +97,11 @@ struct stratix10_rsu_priv { unsigned int retry_counter; unsigned int max_retry; + + unsigned long spt0_address; + unsigned long spt1_address; + + unsigned int *get_spt_response_buf; }; /** @@ -259,6 +271,36 @@ static void rsu_dcmf_status_callback(struct stratix10_svc_client *client, complete(&priv->completion); } +static void rsu_get_spt_callback(struct stratix10_svc_client *client, + struct stratix10_svc_cb_data *data) +{ + struct stratix10_rsu_priv *priv = client->priv; + unsigned long *mbox_err = (unsigned long *)data->kaddr1; + unsigned long *resp_len = (unsigned long *)data->kaddr2; + + if ((data->status != BIT(SVC_STATUS_OK)) || (*mbox_err) || + (*resp_len != RSU_GET_SPT_RESP_LEN)) + goto error; + + priv->spt0_address = priv->get_spt_response_buf[0]; + priv->spt0_address <<= 32; + priv->spt0_address |= priv->get_spt_response_buf[1]; + + priv->spt1_address = priv->get_spt_response_buf[2]; + priv->spt1_address <<= 32; + priv->spt1_address |= priv->get_spt_response_buf[3]; + + goto complete; + +error: + dev_err(client->dev, "failed to get SPTs\n"); + +complete: + stratix10_svc_free_memory(priv->chan, priv->get_spt_response_buf); + priv->get_spt_response_buf = NULL; + complete(&priv->completion); +} + /** * rsu_send_msg() - send a message to Intel service layer * @priv: pointer to rsu private data @@ -288,6 +330,14 @@ static int rsu_send_msg(struct stratix10_rsu_priv *priv, if (arg) msg.arg[0] = arg; + if (command == COMMAND_MBOX_SEND_CMD) { + msg.arg[1] = 0; + msg.payload = NULL; + msg.payload_length = 0; + msg.payload_output = priv->get_spt_response_buf; + msg.payload_length_output = RSU_GET_SPT_RESP_LEN; + } + ret = stratix10_svc_send(priv->chan, &msg); if (ret < 0) goto status_done; @@ -572,6 +622,34 @@ static ssize_t notify_store(struct device *dev, return count; } +static ssize_t spt0_address_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->spt0_address == INVALID_SPT_ADDRESS) + return -EIO; + + return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt0_address); +} + +static ssize_t spt1_address_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->spt1_address == INVALID_SPT_ADDRESS) + return -EIO; + + return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt1_address); +} + static DEVICE_ATTR_RO(current_image); static DEVICE_ATTR_RO(fail_image); static DEVICE_ATTR_RO(state); @@ -590,6 +668,8 @@ static DEVICE_ATTR_RO(dcmf2_status); static DEVICE_ATTR_RO(dcmf3_status); static DEVICE_ATTR_WO(reboot_image); static DEVICE_ATTR_WO(notify); +static DEVICE_ATTR_RO(spt0_address); +static DEVICE_ATTR_RO(spt1_address); static struct attribute *rsu_attrs[] = { &dev_attr_current_image.attr, @@ -610,6 +690,8 @@ static struct attribute *rsu_attrs[] = { &dev_attr_dcmf3_status.attr, &dev_attr_reboot_image.attr, &dev_attr_notify.attr, + &dev_attr_spt0_address.attr, + &dev_attr_spt1_address.attr, NULL }; @@ -639,11 +721,13 @@ static int stratix10_rsu_probe(struct platform_device *pdev) priv->dcmf_version.dcmf1 = INVALID_DCMF_VERSION; 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; + priv->max_retry = INVALID_RETRY_COUNTER; + priv->spt0_address = INVALID_SPT_ADDRESS; + priv->spt1_address = INVALID_SPT_ADDRESS; mutex_init(&priv->lock); priv->chan = stratix10_svc_request_channel_byname(&priv->client, @@ -693,6 +777,20 @@ static int stratix10_rsu_probe(struct platform_device *pdev) stratix10_svc_free_channel(priv->chan); } + priv->get_spt_response_buf = + stratix10_svc_allocate_memory(priv->chan, RSU_GET_SPT_RESP_LEN); + + if (!priv->get_spt_response_buf) { + dev_err(dev, "failed to allocate get spt buffer\n"); + } else { + int ret_val = rsu_send_msg(priv, COMMAND_MBOX_SEND_CMD, + RSU_GET_SPT_CMD, rsu_get_spt_callback); + if (ret_val) { + dev_err(dev, "Error, getting SPT table %i\n", ret_val); + stratix10_svc_free_channel(priv->chan); + } + } + return ret; }