Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp708044imm; Thu, 26 Jul 2018 10:33:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpccX0pTQzY4/vh4Wp5XZSYZb/4qz0v/Pvlykw+8DVITWsp5YrbwcDJJGWpnZbM6k0A+gNWg X-Received: by 2002:a17:902:8308:: with SMTP id bd8-v6mr2779285plb.329.1532626437650; Thu, 26 Jul 2018 10:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532626437; cv=none; d=google.com; s=arc-20160816; b=jeOFZpDaKDVs48K0NhDtYkkDSx3kJ8W+SJIiUM/HlmmxZIN0OZ7l7iugRae/aQxLb4 /rZ4L+/yQdd3aijZOKpjT3lcOmIx1+uFOpEFzEDr7nEbMyTPMwpl14o5aM70Es/Z41Mo sSpX5mFd/R//Hhr4zDJoJek9pdhsNFJCdEHi1rrHy68SYfx6b+yqeZoXSKcHn9xSrrNc UfwEeSlYSY92Pr1NZvFucxoDJyQxPtbWdiC+dH17yGu6Xz4xbTXs9iiAZHXHkNGZqkPe e/E9uQn8docm7QQA8VptH5Ytq4AplfltGS+aok2299CAmOWQOcHUtNEuCaMkF9MkdOSQ nlAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=jtyKAvKlQeBwvL76CSsGWBEbC3DPojdPQd3jZUYBKjY=; b=0O86QTmouywYoQ+giydz1kqh859Mg4Xmg9OxjxZauJdggIjlI3pV6Ok+SFrPELbjOY HU3gDIoztbaXC/lRmew69Q0jc0lvkWZ4IURWPVqdUdwsSnk/8JkeBdo5d+27BMY+t8kc HIF800Jtv7JbT3ZGhT4Nz3lygnwKSGojfP6QicIcNzts6NF541CDqDHdwjw2t5HxE/Cc QmCQfRUIFxubSLQ0Sbs+Yangthu2oz4Tk/MmJpkvOb/Mj59zI56w3+Az5jYPLwvz85RX 3H9csNzdLZR2b4B7f+COByEpJXp/TvDNXjN954HvZSLKfEKBGOoUTPoqOydS8Gy47A+r JU7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5-v6si1583706pga.602.2018.07.26.10.33.42; Thu, 26 Jul 2018 10:33:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732689AbeGZRnO (ORCPT + 99 others); Thu, 26 Jul 2018 13:43:14 -0400 Received: from mga03.intel.com ([134.134.136.65]:54862 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731011AbeGZRnN (ORCPT ); Thu, 26 Jul 2018 13:43:13 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2018 09:25:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,405,1526367600"; d="scan'208";a="76192082" Received: from marshy.an.intel.com ([10.122.105.159]) by orsmga001.jf.intel.com with ESMTP; 26 Jul 2018 09:25:38 -0700 From: richard.gong@linux.intel.com To: gregkh@linuxfoundation.org, catalin.marinas@arm.com, will.deacon@arm.com, dinguyen@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, atull@kernel.org, mdf@kernel.org, arnd@arndb.de, corbet@lwn.net Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, yves.vandervennet@linux.intel.com, richard.gong@intel.com, joyce.ooi@intel.com Subject: [PATCHv8 9/9] misc: add remote status update client support Date: Thu, 26 Jul 2018 11:27:26 -0500 Message-Id: <1532622446-19663-10-git-send-email-richard.gong@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532622446-19663-1-git-send-email-richard.gong@linux.intel.com> References: <1532622446-19663-1-git-send-email-richard.gong@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Richard Gong Extend Intel Stratix10 service layer to support the second service layer client, Remote Status Update (RSU). RSU is used to provide our customers with protection against loading bas bitstreams onto their devices when those device are booting from flash. Signed-off-by: Richard Gong Signed-off-by: Alan Tull --- v7: this patch is added in patch set version 7 v8: no change --- drivers/misc/stratix10-svc.c | 39 ++++++++++++++++++++++++++++-------- include/linux/stratix10-smc.h | 6 ++++++ include/linux/stratix10-svc-client.h | 20 ++++++++++++++++-- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/drivers/misc/stratix10-svc.c b/drivers/misc/stratix10-svc.c index d552703..82ab423 100644 --- a/drivers/misc/stratix10-svc.c +++ b/drivers/misc/stratix10-svc.c @@ -35,7 +35,7 @@ * timeout is set to 30 seconds (30 * 1000) at Intel Stratix10 SoC. */ #define SVC_NUM_DATA_IN_FIFO 32 -#define SVC_NUM_CHANNEL 1 +#define SVC_NUM_CHANNEL 2 #define FPGA_CONFIG_DATA_CLAIM_TIMEOUT_MS 200 #define FPGA_CONFIG_STATUS_TIMEOUT_SEC 30 @@ -270,7 +270,7 @@ static void svc_thread_cmd_config_status(struct stratix10_svc_controller *ctrl, * @cb_data: pointer to callback data structure to service client * @res: result from SMC or HVC call * - * Send back the correspond status to the service client (FPGA manager etc). + * Send back the correspond status to the service clients. */ static void svc_thread_recv_status_ok(struct stratix10_svc_data *p_data, struct stratix10_svc_cb_data *cb_data, @@ -406,6 +406,16 @@ static int svc_normal_to_secure_thread(void *data) a1 = 0; a2 = 0; break; + case COMMAND_RSU_STATUS: + a0 = INTEL_SIP_SMC_RSU_STATUS; + a1 = 0; + a2 = 0; + break; + case COMMAND_RSU_UPDATE: + a0 = INTEL_SIP_SMC_RSU_UPDATE; + a1 = pdata->arg[0]; + a2 = 0; + break; default: pr_warn("it shouldn't happen\n"); break; @@ -422,6 +432,19 @@ static int svc_normal_to_secure_thread(void *data) (unsigned int)res.a1, (unsigned int)res.a2); pr_debug(" res.a3=0x%016x\n", (unsigned int)res.a3); + if (pdata->command == COMMAND_RSU_STATUS) { + if (res.a0 == INTEL_SIP_SMC_RSU_ERROR) + cbdata->status = BIT(SVC_STATUS_RSU_ERROR); + else + cbdata->status = BIT(SVC_STATUS_RSU_OK); + + cbdata->kaddr1 = &res; + cbdata->kaddr2 = NULL; + cbdata->kaddr3 = NULL; + pdata->chan->scl->receive_cb(pdata->chan->scl, cbdata); + continue; + } + switch (res.a0) { case INTEL_SIP_SMC_STATUS_OK: svc_thread_recv_status_ok(pdata, cbdata, res); @@ -445,12 +468,7 @@ static int svc_normal_to_secure_thread(void *data) pr_debug("%s: STATUS_REJECTED\n", __func__); break; case INTEL_SIP_SMC_FPGA_CONFIG_STATUS_ERROR: - pr_err("%s: STATUS_ERROR\n", __func__); - cbdata->status = BIT(SVC_STATUS_RECONFIG_ERROR); - cbdata->kaddr1 = NULL; - cbdata->kaddr2 = NULL; - cbdata->kaddr3 = NULL; - pdata->chan->scl->receive_cb(pdata->chan->scl, cbdata); + svc_thread_recv_status_err(pdata, cbdata, res); break; default: pr_warn("it shouldn't happen\n"); @@ -971,6 +989,11 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev) chans[0].name = SVC_CLIENT_FPGA; spin_lock_init(&chans[0].lock); + chans[1].scl = NULL; + chans[1].ctrl = controller; + chans[1].name = SVC_CLIENT_RSU; + spin_lock_init(&chans[1].lock); + list_add_tail(&controller->node, &svc_ctrl); platform_set_drvdata(pdev, controller); diff --git a/include/linux/stratix10-smc.h b/include/linux/stratix10-smc.h index 14c7223..5be5dab 100644 --- a/include/linux/stratix10-smc.h +++ b/include/linux/stratix10-smc.h @@ -67,6 +67,12 @@ * * INTEL_SIP_SMC_FPGA_CONFIG_STATUS_ERROR: * There is error during the FPGA configuration process. + * + * INTEL_SIP_SMC_REG_ERROR: + * There is error during a read or write operation of the protected registers. + * + * INTEL_SIP_SMC_RSU_ERROR: + * There is error during a remote status update. */ #define INTEL_SIP_SMC_RETURN_UNKNOWN_FUNCTION 0xFFFFFFFF #define INTEL_SIP_SMC_STATUS_OK 0x0 diff --git a/include/linux/stratix10-svc-client.h b/include/linux/stratix10-svc-client.h index 4e5f0af..f7b09e3 100644 --- a/include/linux/stratix10-svc-client.h +++ b/include/linux/stratix10-svc-client.h @@ -10,8 +10,10 @@ * Service layer driver supports client names * * fpga: for FPGA configuration + * rsu: for remote status update */ #define SVC_CLIENT_FPGA "fpga" +#define SVC_CLIENT_RSU "rsu" /** * Status of the sent command, in bit number @@ -36,6 +38,9 @@ * * SVC_COMMAND_STATUS_RECONFIG_ERROR: * Error encountered during FPGA configuration. + * + * SVC_STATUS_RSU_OK: + * Secure firmware accepts the request of remote status update (RSU). */ #define SVC_STATUS_RECONFIG_REQUEST_OK 0 #define SVC_STATUS_RECONFIG_BUFFER_SUBMITTED 1 @@ -43,7 +48,8 @@ #define SVC_STATUS_RECONFIG_COMPLETED 3 #define SVC_STATUS_RECONFIG_BUSY 4 #define SVC_STATUS_RECONFIG_ERROR 5 - +#define SVC_STATUS_RSU_OK 6 +#define SVC_STATUS_RSU_ERROR 7 /** * Flag bit for COMMAND_RECONFIG * @@ -56,9 +62,11 @@ /** * Timeout settings for service clients: * timeout value used in Stratix10 FPGA manager driver. + * timeout value used in RSU driver */ #define SVC_RECONFIG_REQUEST_TIMEOUT_MS 100 #define SVC_RECONFIG_BUFFER_TIMEOUT_MS 240 +#define SVC_RSU_REQUEST_TIMEOUT_MS 300 struct stratix10_svc_chan; @@ -81,13 +89,21 @@ struct stratix10_svc_chan; * @COMMAND_RECONFIG_STATUS: check the status of the configuration, return * status is SVC_STATUS_RECONFIG_COMPLETED, or SVC_STATUS_RECONFIG_BUSY, or * SVC_STATUS_RECONFIG_ERROR + * + * @COMMAND_RSU_STATUS: request remote system update boot log, return status + * is log data or SVC_STATUS_RSU_ERROR + * + * @COMMAND_RSU_UPDATE: set the offset of the bitstream to boot after reboot, + * return status is SVC_STATUS_RSU_OK or SVC_STATUS_RSU_ERROR */ enum stratix10_svc_command_code { COMMAND_NOOP = 0, COMMAND_RECONFIG, COMMAND_RECONFIG_DATA_SUBMIT, COMMAND_RECONFIG_DATA_CLAIM, - COMMAND_RECONFIG_STATUS + COMMAND_RECONFIG_STATUS, + COMMAND_RSU_STATUS, + COMMAND_RSU_UPDATE }; /** -- 2.7.4