From patchwork Thu Sep 10 00:20:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Sunil Dhamne X-Patchwork-Id: 11766341 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52AB0112E for ; Thu, 10 Sep 2020 00:20:37 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05D8021D7E for ; Thu, 10 Sep 2020 00:20:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HXuG4Mp3"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="VKEofA2O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05D8021D7E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/wJU9OP9HXb4zk0V/GY7yhU56nyeUi7JkLLcIR8neq4=; b=HXuG4Mp3NLI6kzQw99KDX9LrZ eLFK0ndoFhJDspEhaZzVQTyE1Ulib/o7jRxCGpEzxpCeMEh2Ld5gU7gKt+IK06aJ9mJhuLQ0479Ao T3JFW/QkCC64zVzSCdvn0S9zQAWDhVj2r+E07hJHwV/v5TWbd6xvjk1usioioW+2kRcd1YJLPxILL VCCsblHw8em1E/M4kFbZuRj4GvMd8qJgirDuvdtmA7WsWcaEvZ2Im6JvP4U3ANbp+n26x7BySfOUa F2JG624wJkLREXrkog7ZAhlQeP/TPs5Ca845hrtMKUoYNdwvMW8hhFBqzf1wuuuSNsIPe/fRgJZb1 feDuhHqkQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGAK3-00015j-NM; Thu, 10 Sep 2020 00:20:19 +0000 Received: from mail-dm6nam12on2058.outbound.protection.outlook.com ([40.107.243.58] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGAJz-00014P-Fp for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 00:20:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZgwNJtwb7/FcApGP+5kHK9+ynaK9mCDErjpGf0oGgZKQ4RAYasDSbxT2dhBBdvd2YTYQXZvI1icoHsj0RMMuQmrCxk0e2YGbt6ptJQ15p4VD8boQDf5ED4gcbp1IwbZQS8aLQv6bN6kp4gnZpvBLkb/zzllL6+xm9EMryIO6Oa+WxSLYOm4o/sz/1oYvQ/TXbYFIp+eBb28lFzeqceOfsMoNQoI4+LZWIfCQupjch0Z/xOjWRtz5Efz0ovPyOTZ7g1MyM9HIC/byxpUWiLq2hcToJTgAs9G7s3/J5uIZIn52SC4sdCihgthrLTT1z2VqS1kLhz5KnBRVtDU1PChwTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k34GbCKNhs5oVWSpXkK5XyHxD3fgz/UVd2dZGEfcxBE=; b=XvhHBSBz6gT0QviTSQcE5XuzsnpgYxevj//pxB5RTOILKGtSB49qJaeMkufihXSTioRGgmEx+O+2EOAq2/SbV607a9Nc3DmOWtB1pHN92bXU4sfvsYd3EbXMPfNN3jTiziSO+bn3CuqaA/pyNyHvelcqKu8A1/RLzjuDgAiCrTs+qEO9NCfx2OpDVn6ANQpEKe7vuRUMkCtf+v657ROyOH9R1fVjM63G5IgTqB0rfv+97vARvc3yk++3oUQzmCaHaTkUTo8+tueN4bG/yaPnuz2a3vcvTYEtcw82gbp6NVmvud4bRPV4HDsrs03QxGjf/3JKCqksI/Jl9QLHK9pk+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k34GbCKNhs5oVWSpXkK5XyHxD3fgz/UVd2dZGEfcxBE=; b=VKEofA2OLHKteMWxOJtpohVW+Cdnxzo/3Rox9MLIpMuo15FC3sby/M6ya+jcHYM9wcH4avYRZ3dEHpnw02x87Nc2IF3FX8wVoKRwlvQPrkGoNRhzWKRU83jAnct7Ld/mXvkA8GEte5hyM8tmbmVtfgmoCfHuByCRnwsAndWyxLM= Received: from CY4PR04CA0046.namprd04.prod.outlook.com (2603:10b6:903:c6::32) by SN6PR02MB4319.namprd02.prod.outlook.com (2603:10b6:805:ac::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Thu, 10 Sep 2020 00:20:13 +0000 Received: from CY1NAM02FT021.eop-nam02.prod.protection.outlook.com (2603:10b6:903:c6:cafe::77) by CY4PR04CA0046.outlook.office365.com (2603:10b6:903:c6::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16 via Frontend Transport; Thu, 10 Sep 2020 00:20:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by CY1NAM02FT021.mail.protection.outlook.com (10.152.75.187) with Microsoft SMTP Server id 15.20.3348.17 via Frontend Transport; Thu, 10 Sep 2020 00:20:11 +0000 Received: from [149.199.38.66] (port=46259 helo=smtp.xilinx.com) by xsj-pvapsmtpgw01 with esmtp (Exim 4.90) (envelope-from ) id 1kGAJf-0007M4-4S; Wed, 09 Sep 2020 17:19:55 -0700 Received: from [127.0.0.1] (helo=localhost) by smtp.xilinx.com with smtp (Exim 4.63) (envelope-from ) id 1kGAJv-0006Qx-HQ; Wed, 09 Sep 2020 17:20:11 -0700 Received: from xsj-pvapsmtp01 (mailman.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 08A0K6Dd001924; Wed, 9 Sep 2020 17:20:06 -0700 Received: from [10.18.5.8] (helo=xsjamitsuni51.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1kGAJq-0006Dg-0i; Wed, 09 Sep 2020 17:20:06 -0700 From: Amit Sunil Dhamne To: ard.biesheuvel@linaro.org, mingo@kernel.org, gregkh@linuxfoundation.org, matt@codeblueprint.co.uk, sudeep.holla@arm.com, hkallweit1@gmail.com, keescook@chromium.org, dmitry.torokhov@gmail.com, michal.simek@xilinx.com, rajanv@xilinx.com, tejas.patel@xilinx.com, jollys@xilinx.com Subject: [PATCH 1/3] firmware: xilinx: Add validation check for IOCTL Date: Wed, 9 Sep 2020 17:20:02 -0700 Message-Id: <1599697204-32103-2-git-send-email-amit.sunil.dhamne@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599697204-32103-1-git-send-email-amit.sunil.dhamne@xilinx.com> References: <1599697204-32103-1-git-send-email-amit.sunil.dhamne@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 14c5ebb9-c08e-4049-1352-08d8551f484b X-MS-TrafficTypeDiagnostic: SN6PR02MB4319: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6U9fJgUYmWTpHB4GdC/MXniwipBn8L+mMleBaS6zmlObiiN7eYYXeyL/bg+rn2FTDk2AqD5CQ1ZLXIp1Bztgeqtf2ZS7WZobZ0LRVPf+KYb82KlBqOFWegywYKRnzTRN9iNnZJ6MKhN78KD8pOF8ZGniY9JJnLcCSyc05roUv2eD40mKMzCj7OnmxweDBrIqo/kWhT41F710pVJlJyW/l4CfFx9zvGbspY8Ox1zePqiyiwB8UHxfjdN9W8CBzeKyL/YCvTnG55rmeNE9/aOAk9BxNMPV20/ytd8+L10+CAedjzIm3i8DtGi8tpLCPY8syYue+PDuzLZmM+XsNNgeB3AaObex5/to4hDf0LS0AYy7fyk+w06E313uqiY3sL3ZrRl1jMJTps1kVBZkNX+QrwTE1rtltCs7qTbGKHvva34= X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapsmtpgw01; PTR:unknown-60-83.xilinx.com; CAT:NONE; SFS:(346002)(376002)(39860400002)(136003)(396003)(46966005)(426003)(6666004)(82740400003)(6636002)(2616005)(316002)(478600001)(336012)(7696005)(8936002)(107886003)(5660300002)(2906002)(70206006)(4326008)(8676002)(70586007)(186003)(356005)(26005)(7416002)(83380400001)(47076004)(36756003)(82310400003)(81166007)(9786002)(921003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2020 00:20:11.8022 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 14c5ebb9-c08e-4049-1352-08d8551f484b X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-AuthSource: CY1NAM02FT021.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB4319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200909_202015_561010_D8203960 X-CRM114-Status: GOOD ( 15.70 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.243.58 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.243.58 listed in list.dnswl.org] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jolly.shah@xilinx.com, rajan.vaja@xilinx.com, Amit Sunil Dhamne , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tejas Patel Validate IOCTL ID for ZynqMP and Versal before calling zynqmp_pm_invoke_fn(). Signed-off-by: Tejas Patel Signed-off-by: Amit Sunil Dhamne --- drivers/firmware/xilinx/zynqmp.c | 117 +++++++++++++++++++++++++++++++-------- 1 file changed, 95 insertions(+), 22 deletions(-) -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately. diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index 8d1ff24..8fe0912 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -514,6 +514,89 @@ int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id) EXPORT_SYMBOL_GPL(zynqmp_pm_clock_getparent); /** + * versal_is_valid_ioctl() - Check whether IOCTL ID is valid or not for versal + * @ioctl_id: IOCTL ID + * + * Return: 1 if IOCTL is valid else 0 + */ +static inline int versal_is_valid_ioctl(u32 ioctl_id) +{ + switch (ioctl_id) { + case IOCTL_SD_DLL_RESET: + case IOCTL_SET_SD_TAPDELAY: + case IOCTL_SET_PLL_FRAC_MODE: + case IOCTL_GET_PLL_FRAC_MODE: + case IOCTL_SET_PLL_FRAC_DATA: + case IOCTL_GET_PLL_FRAC_DATA: + case IOCTL_WRITE_GGS: + case IOCTL_READ_GGS: + case IOCTL_WRITE_PGGS: + case IOCTL_READ_PGGS: + case IOCTL_SET_BOOT_HEALTH_STATUS: + return 1; + default: + return 0; + } +} + +/** + * zynqmp_is_valid_ioctl() - Check whether IOCTL ID is valid or not + * @ioctl_id: IOCTL ID + * + * Return: 1 if IOCTL is valid else 0 + */ +static inline int zynqmp_is_valid_ioctl(u32 ioctl_id) +{ + switch (ioctl_id) { + case IOCTL_SD_DLL_RESET: + case IOCTL_SET_SD_TAPDELAY: + case IOCTL_SET_PLL_FRAC_MODE: + case IOCTL_GET_PLL_FRAC_MODE: + case IOCTL_SET_PLL_FRAC_DATA: + case IOCTL_GET_PLL_FRAC_DATA: + case IOCTL_WRITE_GGS: + case IOCTL_READ_GGS: + case IOCTL_WRITE_PGGS: + case IOCTL_READ_PGGS: + case IOCTL_SET_BOOT_HEALTH_STATUS: + return 1; + default: + return 0; + } +} + +/** + * zynqmp_pm_ioctl() - PM IOCTL API for device control and configs + * @node_id: Node ID of the device + * @ioctl_id: ID of the requested IOCTL + * @arg1: Argument 1 to requested IOCTL call + * @arg2: Argument 2 to requested IOCTL call + * @out: Returned output value + * + * This function calls IOCTL to firmware for device control and configuration. + * + * Return: Returns status, either success or error+reason + */ +static int zynqmp_pm_ioctl(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2, + u32 *out) +{ + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, "xlnx,versal"); + if (np) { + if (!versal_is_valid_ioctl(ioctl_id)) + return -EINVAL; + } else { + if (!zynqmp_is_valid_ioctl(ioctl_id)) + return -EINVAL; + } + of_node_put(np); + + return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, ioctl_id, arg1, arg2, + out); +} + +/** * zynqmp_pm_set_pll_frac_mode() - PM API for set PLL mode * * @clk_id: PLL clock ID @@ -525,8 +608,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_clock_getparent); */ int zynqmp_pm_set_pll_frac_mode(u32 clk_id, u32 mode) { - return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_SET_PLL_FRAC_MODE, - clk_id, mode, NULL); + return zynqmp_pm_ioctl(0, IOCTL_SET_PLL_FRAC_MODE, clk_id, mode, NULL); } EXPORT_SYMBOL_GPL(zynqmp_pm_set_pll_frac_mode); @@ -542,8 +624,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_set_pll_frac_mode); */ int zynqmp_pm_get_pll_frac_mode(u32 clk_id, u32 *mode) { - return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_GET_PLL_FRAC_MODE, - clk_id, 0, mode); + return zynqmp_pm_ioctl(0, IOCTL_GET_PLL_FRAC_MODE, clk_id, 0, mode); } EXPORT_SYMBOL_GPL(zynqmp_pm_get_pll_frac_mode); @@ -560,8 +641,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_get_pll_frac_mode); */ int zynqmp_pm_set_pll_frac_data(u32 clk_id, u32 data) { - return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_SET_PLL_FRAC_DATA, - clk_id, data, NULL); + return zynqmp_pm_ioctl(0, IOCTL_SET_PLL_FRAC_DATA, clk_id, data, NULL); } EXPORT_SYMBOL_GPL(zynqmp_pm_set_pll_frac_data); @@ -577,8 +657,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_set_pll_frac_data); */ int zynqmp_pm_get_pll_frac_data(u32 clk_id, u32 *data) { - return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_GET_PLL_FRAC_DATA, - clk_id, 0, data); + return zynqmp_pm_ioctl(0, IOCTL_GET_PLL_FRAC_DATA, clk_id, 0, data); } EXPORT_SYMBOL_GPL(zynqmp_pm_get_pll_frac_data); @@ -595,8 +674,8 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_get_pll_frac_data); */ int zynqmp_pm_set_sd_tapdelay(u32 node_id, u32 type, u32 value) { - return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, IOCTL_SET_SD_TAPDELAY, - type, value, NULL); + return zynqmp_pm_ioctl(node_id, IOCTL_SET_SD_TAPDELAY, type, value, + NULL); } EXPORT_SYMBOL_GPL(zynqmp_pm_set_sd_tapdelay); @@ -612,8 +691,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_set_sd_tapdelay); */ int zynqmp_pm_sd_dll_reset(u32 node_id, u32 type) { - return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, IOCTL_SET_SD_TAPDELAY, - type, 0, NULL); + return zynqmp_pm_ioctl(node_id, IOCTL_SET_SD_TAPDELAY, type, 0, NULL); } EXPORT_SYMBOL_GPL(zynqmp_pm_sd_dll_reset); @@ -628,8 +706,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_sd_dll_reset); */ int zynqmp_pm_write_ggs(u32 index, u32 value) { - return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_WRITE_GGS, - index, value, NULL); + return zynqmp_pm_ioctl(0, IOCTL_WRITE_GGS, index, value, NULL); } EXPORT_SYMBOL_GPL(zynqmp_pm_write_ggs); @@ -644,8 +721,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_write_ggs); */ int zynqmp_pm_read_ggs(u32 index, u32 *value) { - return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_READ_GGS, - index, 0, value); + return zynqmp_pm_ioctl(0, IOCTL_READ_GGS, index, 0, value); } EXPORT_SYMBOL_GPL(zynqmp_pm_read_ggs); @@ -661,8 +737,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_read_ggs); */ int zynqmp_pm_write_pggs(u32 index, u32 value) { - return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_WRITE_PGGS, index, value, - NULL); + return zynqmp_pm_ioctl(0, IOCTL_WRITE_PGGS, index, value, NULL); } EXPORT_SYMBOL_GPL(zynqmp_pm_write_pggs); @@ -678,8 +753,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_write_pggs); */ int zynqmp_pm_read_pggs(u32 index, u32 *value) { - return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_READ_PGGS, index, 0, - value); + return zynqmp_pm_ioctl(0, IOCTL_READ_PGGS, index, 0, value); } EXPORT_SYMBOL_GPL(zynqmp_pm_read_pggs); @@ -694,8 +768,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_read_pggs); */ int zynqmp_pm_set_boot_health_status(u32 value) { - return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_SET_BOOT_HEALTH_STATUS, - value, 0, NULL); + return zynqmp_pm_ioctl(0, IOCTL_SET_BOOT_HEALTH_STATUS, value, 0, NULL); } /** From patchwork Thu Sep 10 00:20:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Sunil Dhamne X-Patchwork-Id: 11766347 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C77C1580 for ; Thu, 10 Sep 2020 00:21:55 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE469221EE for ; Thu, 10 Sep 2020 00:21:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Fzr+jBf3"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="jTrND0St" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE469221EE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g89MmPnOlVZQxbe0PvQz26M5b3oGSRUxVdhIhpqG5oc=; b=Fzr+jBf3r7+M6WFXV330RTUi3 xiQjPO9Hu21WBd+bepp3PZqYwn/cfjW/in1F001gcadYacVonDPYHuyn9NgxZBfX9JId87T5pTSiG V9xJjxNktBodFtC/M8okmgCDSZzc7EK8/IIhQeDe3q/HyZfqbDQLy4BdRcu1aUtSThIC7zeI/7pf3 nimYel0RMOficSQqBQvfgD8IeGDyWs0GXTwJzjR+d4DDoTVwsDkZr6phkO1MjgpufIWfGz093x2wv ekm0EKNU4cpq4VCqmZ3aSD8TGYEaMgpnfa5y5NQDSknc7n+mDfX1gQRefqcGo+LirODxyoJuBChxq RExsyqquA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGAKC-00016x-3z; Thu, 10 Sep 2020 00:20:28 +0000 Received: from mail-eopbgr750055.outbound.protection.outlook.com ([40.107.75.55] helo=NAM02-BL2-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGAK8-00016H-G1 for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 00:20:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GgNOaHyOXBCIsNWiNSZ+QnxF4nvnjUfqO100x0IQObKjnHSmbdXZJE/U+CC3WUM4diLQIsFfv/EWzdYCoOvFBAD0GmwQpN/125KpKDZeStlLp4pu89Rn73dXif3/t8OSU3g4aVB9YN4f52ULr4+qdztz6g9NH7IYMh3ZL8FHe5WbazuJGtzbv2O2XURHUyKvsW4OUWxkVntJJs5q+bbBqUTGuJV9JTHv5ziS8MuFw2Qq/MKE9ZqNbjiNfOfMyV8OxqzCmV6I0I5HnA31SYFcQmg2oL8ZZ8BWHlc8Awgm2NC/FFOO9CF+xOeu76F3ftOR3Pp27DnpQrmCxEZVkwcvpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p4qgcsxwL1pyNoSkL4sAWpCgU7raFfiiSG5cGLfWf8I=; b=fOVXiiccVCP0arhVN6fwMmm9HFc5ULxEjpopH+PrclwKS+utHW0H33Mj+w3g9jMINGjE6/rRV2rwkTHFUhHUDht2CK7yyjAokBni2s/fiRU7uzdkXL4N6c7JIBAEvTK68CWF/BVCwi7MhBktb4taXJJZQhBb1Vwq33qIM564TMmMZjc3bLrxCynEygXeYS6xjcFtgCBkGiumjn6Sti6TiARri7S5b1I021sV+TAmMebAm1rttHjdap+gnh7vuPm7kEX/7cJxeKcevzVSSdL4ZQI+Sp4t9n+UQwMJ4WRCvtYGegB5ZFGtiAQDtV5wQA9iZBBIP09rUINWJV32hp8RtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p4qgcsxwL1pyNoSkL4sAWpCgU7raFfiiSG5cGLfWf8I=; b=jTrND0StFrHbxEHfaS0MANYXY6QDrs7hmYS5AA6up6pwGwlZ8G12U0/HCJp/F03y3mA1JfEwpabFu6Hn2QfosZBk1xCyxfYYddTNve2hwVmMsxD1nA84NMaGGe5s4uM0eTuFS96JVpOy51FuaKedLP4JeEwCVgacVW6O/wdwYSc= Received: from SN6PR05CA0017.namprd05.prod.outlook.com (2603:10b6:805:de::30) by DM5PR02MB3372.namprd02.prod.outlook.com (2603:10b6:4:63::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Thu, 10 Sep 2020 00:20:22 +0000 Received: from SN1NAM02FT021.eop-nam02.prod.protection.outlook.com (2603:10b6:805:de:cafe::90) by SN6PR05CA0017.outlook.office365.com (2603:10b6:805:de::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.10 via Frontend Transport; Thu, 10 Sep 2020 00:20:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT021.mail.protection.outlook.com (10.152.72.144) with Microsoft SMTP Server id 15.20.3370.16 via Frontend Transport; Thu, 10 Sep 2020 00:20:21 +0000 Received: from [149.199.38.66] (port=47475 helo=smtp.xilinx.com) by xsj-pvapsmtpgw01 with esmtp (Exim 4.90) (envelope-from ) id 1kGAJp-0007Mk-85; Wed, 09 Sep 2020 17:20:05 -0700 Received: from [127.0.0.1] (helo=localhost) by smtp.xilinx.com with smtp (Exim 4.63) (envelope-from ) id 1kGAK5-0006hf-M9; Wed, 09 Sep 2020 17:20:21 -0700 Received: from xsj-pvapsmtp01 (smtp3.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 08A0K6a3001925; Wed, 9 Sep 2020 17:20:08 -0700 Received: from [10.18.5.8] (helo=xsjamitsuni51.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1kGAJq-0006Dg-3G; Wed, 09 Sep 2020 17:20:06 -0700 From: Amit Sunil Dhamne To: ard.biesheuvel@linaro.org, mingo@kernel.org, gregkh@linuxfoundation.org, matt@codeblueprint.co.uk, sudeep.holla@arm.com, hkallweit1@gmail.com, keescook@chromium.org, dmitry.torokhov@gmail.com, michal.simek@xilinx.com, rajanv@xilinx.com, tejas.patel@xilinx.com, jollys@xilinx.com Subject: [PATCH 2/3] firmware: xilinx: Add support for GET_LAST_RESET_REASON IOCTL Date: Wed, 9 Sep 2020 17:20:03 -0700 Message-Id: <1599697204-32103-3-git-send-email-amit.sunil.dhamne@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599697204-32103-1-git-send-email-amit.sunil.dhamne@xilinx.com> References: <1599697204-32103-1-git-send-email-amit.sunil.dhamne@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 66949870-ea4d-4cc1-49c8-08d8551f4e58 X-MS-TrafficTypeDiagnostic: DM5PR02MB3372: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3fb8N4/+a2aMiPABAOJC27KtIiKaHKpeV5QM/Nc2EGwabO4dsIxfx8lfJAcEyWzJIFnWS06mn+kILbvMt974tHXi7VVJ8ixwZgXH73kC1r8ao038heAKF/utxioEswl4Ot/DrSof3KPJ7tVXuxtROXnDSOHWT13S92J2e3ZXRikhFR1tyLXRltXFgDu603+1sFH1Qlhld6Tght6nF6vRmKRcO1kNxlI3gsqwN2+7nA3yatO1vJRiXbu5qPeN/p0VC9Z+JihpsTDAUKRkOZspTpmqiv2OGf+PeNPujN6lR5mQVHLySS5SZviDfrknrai+mtbOVV8dwt+J4BkoTt4Ye1+UJv9IwN0jNxfd5Z9VkmyvPhdejctBSXLLDJNa4w/55yWOpMgPAWE2MvgQx/DvgZStTCMlh+29bAAvImVHRQw= X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapsmtpgw01; PTR:unknown-60-83.xilinx.com; CAT:NONE; SFS:(136003)(396003)(346002)(376002)(39860400002)(46966005)(478600001)(5660300002)(7696005)(426003)(8676002)(6666004)(82740400003)(81166007)(47076004)(70206006)(70586007)(26005)(7416002)(2906002)(36756003)(4326008)(6636002)(9786002)(316002)(2616005)(186003)(107886003)(336012)(8936002)(356005)(83380400001)(82310400003)(921003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2020 00:20:21.9541 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66949870-ea4d-4cc1-49c8-08d8551f4e58 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT021.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB3372 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200909_202024_716189_4DB05B32 X-CRM114-Status: GOOD ( 14.58 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.75.55 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.75.55 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jolly.shah@xilinx.com, rajan.vaja@xilinx.com, Amit Sunil Dhamne , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tejas Patel Add support to get last reason using IOCTL API. Also validate IOCTL ID for Versal or ZynqMP platforms before calling zynqmp_pm_invoke_fn(). Signed-off-by: Tejas Patel Signed-off-by: Amit Sunil Dhamne --- drivers/firmware/xilinx/zynqmp.c | 20 ++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 7 +++++++ 2 files changed, 27 insertions(+) -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately. diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index 8fe0912..c5db34f 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -533,6 +533,7 @@ static inline int versal_is_valid_ioctl(u32 ioctl_id) case IOCTL_WRITE_PGGS: case IOCTL_READ_PGGS: case IOCTL_SET_BOOT_HEALTH_STATUS: + case IOCTL_GET_LAST_RESET_REASON: return 1; default: return 0; @@ -772,6 +773,25 @@ int zynqmp_pm_set_boot_health_status(u32 value) } /** + * zynqmp_pm_get_last_reset_reason() - PM API for getting last reset reason + * + * @reset_reason: last reset reason + * + * This function returns last reset reason + * + * Return: Returns status, either success or error+reason + */ +int zynqmp_pm_get_last_reset_reason(u32 *reset_reason) +{ + if (!reset_reason) + return -EINVAL; + + return zynqmp_pm_ioctl(0, IOCTL_GET_LAST_RESET_REASON, 0, 0, + reset_reason); +} +EXPORT_SYMBOL_GPL(zynqmp_pm_get_last_reset_reason); + +/** * zynqmp_pm_reset_assert - Request setting of reset (1 - assert, 0 - release) * @reset: Reset to be configured * @assert_flag: Flag stating should reset be asserted (1) or diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h index 5968df8..90c8664 100644 --- a/include/linux/firmware/xlnx-zynqmp.h +++ b/include/linux/firmware/xlnx-zynqmp.h @@ -116,6 +116,8 @@ enum pm_ioctl_id { IOCTL_READ_PGGS = 15, /* Set healthy bit value */ IOCTL_SET_BOOT_HEALTH_STATUS = 17, + /* IOCTL to get last reset reason */ + IOCTL_GET_LAST_RESET_REASON = 23, }; enum pm_query_id { @@ -357,6 +359,7 @@ int zynqmp_pm_write_pggs(u32 index, u32 value); int zynqmp_pm_read_pggs(u32 index, u32 *value); int zynqmp_pm_system_shutdown(const u32 type, const u32 subtype); int zynqmp_pm_set_boot_health_status(u32 value); +int zynqmp_pm_get_last_reset_reason(u32 *reset_reason); #else static inline struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void) { @@ -507,6 +510,10 @@ static inline int zynqmp_pm_set_boot_health_status(u32 value) { return -ENODEV; } +static inline int zynqmp_pm_get_last_reset_reason(u32 *reset_reason) +{ + return -ENODEV; +} #endif #endif /* __FIRMWARE_ZYNQMP_H__ */ From patchwork Thu Sep 10 00:20:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Sunil Dhamne X-Patchwork-Id: 11766345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9280192C for ; Thu, 10 Sep 2020 00:21:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1AF40221EE for ; Thu, 10 Sep 2020 00:21:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b7lSzuvQ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="VNrKtroQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AF40221EE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mmPhvrSpcIoh5Qcq35VQi4A1dO7m4NQfuODAVSF+hvY=; b=b7lSzuvQ+wc6S6rUeFl86OxqO YnoURoNyhTeCy1P/9oSrw7WXeFswC5IBzdT3cGIfzRgXZUZ4/EWnCiQO+Ffh9QxcoGwKQINXyiS0l xriFlFXyIT9sGJJwBOv78CaaIpKT0yH7g+km2VXYVwSnAr1KKhyU8S8OPSkoU8F+lwGfPmCCwj3fR AJ1BVQmvqcHa/MFcqaTfnSq+dHWnieg2ahL1bnxY8P4tLtx6a/tZmHM+5WVjaNW08yaABVkfTETC7 ZjAySf+Hu6UDsAj9wSmG23SRrbOXKsP7zAYNOD+pTC4TnmDOZvKi7OkQpcnYkJl0Tq1slOJ5fYlp6 0b9BNUsCQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGAK4-00015z-UF; Thu, 10 Sep 2020 00:20:20 +0000 Received: from mail-eopbgr700068.outbound.protection.outlook.com ([40.107.70.68] helo=NAM04-SN1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGAJz-00014Q-Hw for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 00:20:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HqdUYRsx9yXavQhrKs+qzhZi1J1sLgaAv3OjfERjcQ8K1aDcZ0qX4+ZlIQ+llaNpiixf/ObNN+LXiPc7JnxLwGOEdTR0GZx3ZoM3An1JlSj9fxT9Y4Pu+EWMqIYftOSUACBaUWb6qR8x4Z9NlHE74FH7/Mbxoa/yhfrBG0ftzhh8nYdyW+EQhJIlCw/cCryzCx0RuN3ogUaSz511ZBJQon6EX4lRcYwRtvWXIji9Yyg6pSpyy2WL3MxpsSrKYm7gvyt4cEiOLqkRRNUqfr0bUObB5/wONz+8BHvcDvreCFAT/sITKZdXgn8ybe5XI5mBtaoNzJx8G59y4Npxi4U9IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0oJbVftP5GZ8OS1xyRkZm/DV0t/DZEYm/aH36t+sg8U=; b=Z3RoimXiD0MNRFisV7AXOPgEkiY8CdAHNfTwdfyGi3pw7alYbkny+VWNR3yvWyqEXYSjkwQ5YFQfxpKszkEIio6xRv4lHlPCvjZSpw3fOmpTpKIEFZjOlpaqVfS1+Ow0XVBGKjpB9Jtbl6tb7iiRCJLUnoluTXP9QxVRHL4+pJtcLWqCuVtsyK58/yRoC/nCtv1T0gc+EEljZF0pVcRUi1Za5LkxpvEfirDWOsrt7rxsMeIhMOhfjm+Wnx2JjHLPfkCJa3KkRD8DMMoJYBip8wEiiDoSGMuTNiEkSZmBSZpW0RpUJOqXAlWAx2WL6hP4SVZGcfzDdL9FeceSKwuOJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0oJbVftP5GZ8OS1xyRkZm/DV0t/DZEYm/aH36t+sg8U=; b=VNrKtroQaZGJnre/6IX9kUIZm2DBZcLSThYeJzq3I0gj7WcjJWRt9hIPKOmL/ddWxxZ1iSaVSZilIXaVJchueU+LwaJd3CLt0B4eC9IYWjGf1KRgXynXrd5YfO30Ki3H9/qDS/7r9j8U2/KTCwU3AQsh0L0zULfRRUmE82t/MO8= Received: from SN6PR05CA0002.namprd05.prod.outlook.com (2603:10b6:805:de::15) by SN6PR02MB5357.namprd02.prod.outlook.com (2603:10b6:805:75::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Thu, 10 Sep 2020 00:20:11 +0000 Received: from SN1NAM02FT051.eop-nam02.prod.protection.outlook.com (2603:10b6:805:de:cafe::e9) by SN6PR05CA0002.outlook.office365.com (2603:10b6:805:de::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.5 via Frontend Transport; Thu, 10 Sep 2020 00:20:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT051.mail.protection.outlook.com (10.152.73.103) with Microsoft SMTP Server id 15.20.3370.16 via Frontend Transport; Thu, 10 Sep 2020 00:20:11 +0000 Received: from [149.199.38.66] (port=46184 helo=smtp.xilinx.com) by xsj-pvapsmtpgw01 with esmtp (Exim 4.90) (envelope-from ) id 1kGAJe-0007Ly-SI; Wed, 09 Sep 2020 17:19:54 -0700 Received: from [127.0.0.1] (helo=localhost) by smtp.xilinx.com with smtp (Exim 4.63) (envelope-from ) id 1kGAJv-0006Qx-8v; Wed, 09 Sep 2020 17:20:11 -0700 Received: from xsj-pvapsmtp01 (mailman.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 08A0K6aH001929; Wed, 9 Sep 2020 17:20:06 -0700 Received: from [10.18.5.8] (helo=xsjamitsuni51.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1kGAJq-0006Dg-50; Wed, 09 Sep 2020 17:20:06 -0700 From: Amit Sunil Dhamne To: ard.biesheuvel@linaro.org, mingo@kernel.org, gregkh@linuxfoundation.org, matt@codeblueprint.co.uk, sudeep.holla@arm.com, hkallweit1@gmail.com, keescook@chromium.org, dmitry.torokhov@gmail.com, michal.simek@xilinx.com, rajanv@xilinx.com, tejas.patel@xilinx.com, jollys@xilinx.com Subject: [PATCH 3/3] firmware: xilinx: Add sysfs to get last reset reason Date: Wed, 9 Sep 2020 17:20:04 -0700 Message-Id: <1599697204-32103-4-git-send-email-amit.sunil.dhamne@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599697204-32103-1-git-send-email-amit.sunil.dhamne@xilinx.com> References: <1599697204-32103-1-git-send-email-amit.sunil.dhamne@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 85746a71-5ab6-49d1-8ae8-08d8551f4836 X-MS-TrafficTypeDiagnostic: SN6PR02MB5357: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:321; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yllcl5yFj5B/GoCaZedNtqqHrkJwLSDnCXMDC64HKU/w0KAbCxh3/FASGDhzp1SUQA8DYZY3WBPAo6wpnadNE2KKakAfUu5yoa/UCFspRPi1zsfwV06rommNY15qbcKv8VLZXD66+/89OhSpvLAMr4z0I+fLur5oYTJ+w4VUtfnf7h9uuygoJE1fVyHUjTJ4SfwoQNjiOTFEXQ5jENt68AJkyNeJcQqrLf6NrvCrGOJMVB8q/8f5Xq5WTbuGnybXfC3ExLvLToxYcBk0exfFHLDgTSHlehczd/Ks9GNWYLgNBdrv7VQzcXpfPqmF0ChmhEpF6xxpZtMP/RPnHYwoGvVIeIoU11aKNK5GMus+GuSggZEMoIOeOnHsOH4IsnHi2YfsZUgHq+ODpRaRiDMV3XuGVHYfyB5S5Um41vEIw3Y= X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapsmtpgw01; PTR:unknown-60-83.xilinx.com; CAT:NONE; SFS:(376002)(346002)(396003)(39860400002)(136003)(46966005)(81166007)(36756003)(70206006)(9786002)(2616005)(2906002)(47076004)(8936002)(82310400003)(7696005)(426003)(70586007)(8676002)(356005)(6636002)(4326008)(316002)(83380400001)(186003)(478600001)(7416002)(107886003)(82740400003)(5660300002)(336012)(26005)(921003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2020 00:20:11.6676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85746a71-5ab6-49d1-8ae8-08d8551f4836 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT051.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB5357 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200909_202015_616503_7919DF39 X-CRM114-Status: GOOD ( 14.38 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.70.68 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.70.68 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jolly.shah@xilinx.com, rajan.vaja@xilinx.com, Amit Sunil Dhamne , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tejas Patel Add sysfs to get last reset reason. Signed-off-by: Tejas Patel Signed-off-by: Amit Sunil Dhamne --- .../ABI/stable/sysfs-driver-firmware-zynqmp | 13 ++++++++ drivers/firmware/xilinx/zynqmp.c | 37 ++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 11 +++++++ 3 files changed, 61 insertions(+) -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately. diff --git a/Documentation/ABI/stable/sysfs-driver-firmware-zynqmp b/Documentation/ABI/stable/sysfs-driver-firmware-zynqmp index 00fa04c..96a5760 100644 --- a/Documentation/ABI/stable/sysfs-driver-firmware-zynqmp +++ b/Documentation/ABI/stable/sysfs-driver-firmware-zynqmp @@ -101,3 +101,16 @@ Description: # echo 0 > /sys/devices/platform/firmware\:zynqmp-firmware/health_status Users: Xilinx + +What: /sys/devices/platform/firmware\:zynqmp-firmware/last_reset_reason +Date: June 2020 +KernelVersion: 5.9.0 +Contact: "Tejas Patel" +Description: + This sysfs interface allows to get last reset reason. + + Usage: + Get last reset reason + # cat /sys/devices/platform/firmware\:zynqmp-firmware/last_reset_reason + +Users: Xilinx diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index c5db34f..f590856 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -1266,6 +1266,42 @@ static DEVICE_ATTR_RW(pggs1); static DEVICE_ATTR_RW(pggs2); static DEVICE_ATTR_RW(pggs3); +static ssize_t last_reset_reason_show(struct device *device, + struct device_attribute *attr, char *buf) +{ + int ret; + u32 ret_payload[PAYLOAD_ARG_CNT]; + + ret = zynqmp_pm_get_last_reset_reason(ret_payload); + if (-EINVAL == ret) + return sprintf(buf, "Feature not supported\n"); + else if (ret) + return ret; + + switch (ret_payload[1]) { + case PM_RESET_REASON_EXT_POR: + return sprintf(buf, "ext_por\n"); + case PM_RESET_REASON_SW_POR: + return sprintf(buf, "sw_por\n"); + case PM_RESET_REASON_SLR_POR: + return sprintf(buf, "sl_por\n"); + case PM_RESET_REASON_ERR_POR: + return sprintf(buf, "err_por\n"); + case PM_RESET_REASON_DAP_SRST: + return sprintf(buf, "dap_srst\n"); + case PM_RESET_REASON_ERR_SRST: + return sprintf(buf, "err_srst\n"); + case PM_RESET_REASON_SW_SRST: + return sprintf(buf, "sw_srst\n"); + case PM_RESET_REASON_SLR_SRST: + return sprintf(buf, "slr_srst\n"); + default: + return sprintf(buf, "unknown reset\n"); + } +} + +static DEVICE_ATTR_RO(last_reset_reason); + static struct attribute *zynqmp_firmware_attrs[] = { &dev_attr_ggs0.attr, &dev_attr_ggs1.attr, @@ -1277,6 +1313,7 @@ static struct attribute *zynqmp_firmware_attrs[] = { &dev_attr_pggs3.attr, &dev_attr_shutdown_scope.attr, &dev_attr_health_status.attr, + &dev_attr_last_reset_reason.attr, NULL, }; diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h index 90c8664..f7cb0a9 100644 --- a/include/linux/firmware/xlnx-zynqmp.h +++ b/include/linux/firmware/xlnx-zynqmp.h @@ -302,6 +302,17 @@ enum zynqmp_pm_shutdown_subtype { ZYNQMP_PM_SHUTDOWN_SUBTYPE_SYSTEM, }; +enum pm_reset_reason { + PM_RESET_REASON_EXT_POR = 0, + PM_RESET_REASON_SW_POR = 1, + PM_RESET_REASON_SLR_POR = 2, + PM_RESET_REASON_ERR_POR = 3, + PM_RESET_REASON_DAP_SRST = 7, + PM_RESET_REASON_ERR_SRST = 8, + PM_RESET_REASON_SW_SRST = 9, + PM_RESET_REASON_SLR_SRST = 10, +}; + /** * struct zynqmp_pm_query_data - PM query data * @qid: query ID