From patchwork Wed Mar 29 07:46:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 76428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp239289vqo; Wed, 29 Mar 2023 01:01:10 -0700 (PDT) X-Google-Smtp-Source: AKy350aS4Q+XPCu4M2paZUeWG1JRKHx7P/TV9AWu7gs2HTbId7ddTzgGKWV93iM6VGS/r4Zzki/4 X-Received: by 2002:a17:906:d966:b0:7c0:e30a:d3e5 with SMTP id rp6-20020a170906d96600b007c0e30ad3e5mr18207106ejb.18.1680076870424; Wed, 29 Mar 2023 01:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680076870; cv=none; d=google.com; s=arc-20160816; b=zd6QLnkfPoT0MF3GooONAvRtXtRz5iknQ9MHmEJeChLeHZOZV9qoLXi7pRxQPBvavR yG1hd44Wjqwx/PHp7d9uBC+68zA0pWfyqvUriVPqQ5KO7MiE7zIp5MTGr7LzGrqESLSF J0PI74ww92Rk1Ue8g1y4t1OAEDudzM3b/a45LoMLPArjpwycOZBIoHO55DYiP6qP96sp rTl3Qg7pzslbANFp6W0p+SjVve6m+3YFt4VEmGmsifdBCCNu7qv00H3QCaY385TsY8Ea QGLvgKlckWYN9m8tc4vNpnPV1U3NIi/N5PiYh90k84bWw6kKpl60nsHq9bqG/JqTLgZi Fx8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nOAvH2qE72J+9pGBrgAidXdZmAdy3OZE8caa/4T+p7w=; b=YYR7h0wzsNfp4afeSjy42HStP6nqep6EJJXLNVdkWuGgzWKExFXntRXWymdBONmfF3 1Vi5ZL8GcBtLRsjjWEdPfmF7f7ibaECTV0ePblzdxx/b6RLWO01GUhQUt2KxdCMlDshc 5UMqzTs8SDZZc3cdmzjrSk2N05EeKnRr+TYC1Nnn+AESLfAk5CT76/Jz8pvFW4VAWjrg CycZmDV2UhDBxFczmdqgb96Y/BrLrsf7wF+JMykWcHXQdFChQt7pB1k8VUvBAmEyKDrx FN1V5fUczk/bru5KhfHlfy8lzE7zioomj4WtiqXxsRpPhlMK/e+Mm/9NKQMdr2yfM92Y 5fJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JhLZb4eo; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg17-20020a170907205100b0092fd56751ffsi30702498ejb.420.2023.03.29.01.00.44; Wed, 29 Mar 2023 01:01:10 -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=@quicinc.com header.s=qcppdkim1 header.b=JhLZb4eo; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbjC2Hr2 (ORCPT + 99 others); Wed, 29 Mar 2023 03:47:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbjC2HrT (ORCPT ); Wed, 29 Mar 2023 03:47:19 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AFF335A2; Wed, 29 Mar 2023 00:47:19 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32T2l95N017029; Wed, 29 Mar 2023 07:47:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=nOAvH2qE72J+9pGBrgAidXdZmAdy3OZE8caa/4T+p7w=; b=JhLZb4eo3LcmkTFHYtYuWZ9as22PtiKOO6xFQQwy7egx+L8zxFVgYdkOyo10SJ9Zj1/X gSfwj67/Fd3fGamw9UzSUCZpDU1RjiXJu6sd4IEZ1CIo+W1/aT6VPcNaAU9VaMnj0gtk hI8nZA1p4Qu4oKo26WxKBQooZ/3Zo55sGDcKiUs/1GQU/lP5kOtX72fp7axCJTbmQtqU lPTJ2Ntq2JcdH4vkIVVHLk9eydHb56wODp25wNevvTNJ5UDCWkO4XeoXwSKp6TmmV+0q 986/7fthcV5ZhVa61vV1pCggasUFbrzyRerl0XOpL5b1N+tohihgg8ndVCAcwnHuuOpm aQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkx0ftty9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:10 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32T7l9kS023692 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:09 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 29 Mar 2023 00:47:06 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v6 1/5] firmware: qcom_scm: provide a read-modify-write function Date: Wed, 29 Mar 2023 13:16:48 +0530 Message-ID: <1680076012-10785-2-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> References: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 7RlvtKQieLUnk52DAQDsOApBEzTLBm5O X-Proofpoint-GUID: 7RlvtKQieLUnk52DAQDsOApBEzTLBm5O X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-29_02,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 bulkscore=0 mlxlogscore=646 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303290063 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1761688284384130689?= X-GMAIL-MSGID: =?utf-8?q?1761688284384130689?= It was realized by Srinivas K. that there is a need of read-modify-write scm exported function so that it can be used by multiple clients. Let's introduce qcom_scm_io_update_field() which masks out the bits and write the passed value to that bit-offset. Subsequent patch will use this function. Suggested-by: Srinivas Kandagatla Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom_scm.c | 15 +++++++++++++++ include/linux/firmware/qcom/qcom_scm.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 5f281cb..cb0bc32 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -407,6 +407,21 @@ int qcom_scm_set_remote_state(u32 state, u32 id) } EXPORT_SYMBOL(qcom_scm_set_remote_state); +int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, unsigned int val) +{ + unsigned int old, new; + int ret; + + ret = qcom_scm_io_readl(addr, &old); + if (ret) + return ret; + + new = (old & ~mask) | val << (ffs(mask) - 1); + + return qcom_scm_io_writel(addr, new); +} +EXPORT_SYMBOL(qcom_scm_io_update_field); + static int __qcom_scm_set_dload_mode(struct device *dev, bool enable) { struct qcom_scm_desc desc = { diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h index 1e449a5..203a781 100644 --- a/include/linux/firmware/qcom/qcom_scm.h +++ b/include/linux/firmware/qcom/qcom_scm.h @@ -84,6 +84,8 @@ extern bool qcom_scm_pas_supported(u32 peripheral); extern int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val); extern int qcom_scm_io_writel(phys_addr_t addr, unsigned int val); +extern int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, + unsigned int val); extern bool qcom_scm_restore_sec_cfg_available(void); extern int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare); From patchwork Wed Mar 29 07:46:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 76430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp241398vqo; Wed, 29 Mar 2023 01:04:26 -0700 (PDT) X-Google-Smtp-Source: AKy350YvXALTxF0eN/mpjke5N5hSBAbHee6xkxV4k+bOjcGwhHjJN2YZ6JpHCzekY78aTk8ZoKls X-Received: by 2002:a17:903:1109:b0:1a2:38a3:7958 with SMTP id n9-20020a170903110900b001a238a37958mr16875821plh.1.1680077066721; Wed, 29 Mar 2023 01:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680077066; cv=none; d=google.com; s=arc-20160816; b=Xc6244nD1MrqRObA/5yC3Al6J5tSNMnTn6Z+PD+4zZH7Pe2ZVdRyzxMM07Ns5LX7a8 IcDyewug+czGcpK8kRf7OGHGuzxF10SW6UAPjs/1TU/pvoFXt2hx4a90E1QyrDIARgXj Qx5/ay5DNISYAbnMeq60j6VQHjDiYqvGqAO3DUsanrLGKXQCoWFPLPD1EoZRU8ybHyrQ oKf4dmpvWhnCLROohmIWhcs+FG5x+6qnZRprEaDQGVyNoqtl8IlzfftQMXfai2zgD3Yl TVKvRZlMW3Nu85ki6nA2Sh2Zx5JqCrCTnkRIKV4NZab9mQKN/RKGxlASMvzIQ92rD5mX FdaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HsA+LxQVnxzKseTa2KZjRCjKmeq9PeHoILc6rkYATsQ=; b=pQ9qP4jQttvNLs16ubimp+yVbMV+6UJZe8fcxdXIgvG39SrShtHIjB9IvlDjLpIA9b 14cEpP/1Mt5pwph7XxT4TrgLPyMm+5PP/iujaijVdAXIi2xR5jb+JYNjNRdM+7bW7Uzg IfHvDY5R2a/QOYrluTWIE5xhD0B5zHP334Zeh0lbUFE0rQipXmY7CEj92745rfqJvuQm NwnG+dV7Kp30bJDWa/926jV1tFEpH1AzdjtrMJoPfD7iJj6UEodhzu6CGNh8CYCytnIj F5AZqutEQrV3K/vGmp0jbwuQOkRg1qsSjAZcBnkv76c07kJtdnf3JNWrxwfVNQrZVQmB 9wxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EmgB3sD0; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a170902854c00b0019c14335fc0si8147970plo.70.2023.03.29.01.04.14; Wed, 29 Mar 2023 01:04:26 -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=@quicinc.com header.s=qcppdkim1 header.b=EmgB3sD0; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230071AbjC2HrU (ORCPT + 99 others); Wed, 29 Mar 2023 03:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbjC2HrR (ORCPT ); Wed, 29 Mar 2023 03:47:17 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 900951BF0; Wed, 29 Mar 2023 00:47:16 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32T1nRqh015200; Wed, 29 Mar 2023 07:47:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=HsA+LxQVnxzKseTa2KZjRCjKmeq9PeHoILc6rkYATsQ=; b=EmgB3sD0/nys+tpY/koIEhVOLAB2YAbieOmEjl/CS1bIz5vXy68qlMaCGKsG8BaPQlR/ cYUfVr+hjjr05YTOV+rvh8AC4a+h2c0YmBMic3top5UbmKF54EujWJ0TqTfWKlAVEnoo TFicHaY99q+R4Atd/rBwyU/idGrPLngk7GxVCr4W65W0QlDyulyGlHD9DMQmJQmWqjoy 4tnJihDSRcfpuQxV/lhz1eGx6vABhvQtLAeWUiovDEMrNyTTDkiUtVG5TWULJF4CiJFm 3f3kHmUNpRk8cKClwterSWRcerd74btIR7AqH4MifUOMvy7tRjbadqdP04IwuL2HtYf4 xw== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkv45k4pm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:13 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32T7lCi9013399 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:12 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 29 Mar 2023 00:47:09 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v6 2/5] pinctrl: qcom: Use qcom_scm_io_update_field() Date: Wed, 29 Mar 2023 13:16:49 +0530 Message-ID: <1680076012-10785-3-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> References: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: ZlzBY3xBCeo8FIJWnh0gakDjsK21A9QC X-Proofpoint-ORIG-GUID: ZlzBY3xBCeo8FIJWnh0gakDjsK21A9QC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-29_02,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 clxscore=1015 mlxlogscore=693 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303290063 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1761688489846807293?= X-GMAIL-MSGID: =?utf-8?q?1761688489846807293?= Use qcom_scm_io_update_field() exported function introduced in last commit. Acked-by: Linus Walleij Signed-off-by: Mukesh Ojha --- drivers/pinctrl/qcom/pinctrl-msm.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index daeb79a..6e1a5e4 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -1016,6 +1016,7 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type) unsigned long flags; bool was_enabled; u32 val; + u32 mask; if (msm_gpio_needs_dual_edge_parent_workaround(d, type)) { set_bit(d->hwirq, pctrl->dual_edge_irqs); @@ -1049,23 +1050,19 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type) * With intr_target_use_scm interrupts are routed to * application cpu using scm calls. */ + mask = (7 << g->intr_target_bit); if (pctrl->intr_target_use_scm) { u32 addr = pctrl->phys_base[0] + g->intr_target_reg; int ret; - qcom_scm_io_readl(addr, &val); - - val &= ~(7 << g->intr_target_bit); - val |= g->intr_target_kpss_val << g->intr_target_bit; - - ret = qcom_scm_io_writel(addr, val); + ret = qcom_scm_io_update_field(addr, mask, g->intr_target_kpss_val); if (ret) dev_err(pctrl->dev, "Failed routing %lu interrupt to Apps proc", d->hwirq); } else { val = msm_readl_intr_target(pctrl, g); - val &= ~(7 << g->intr_target_bit); + val &= ~mask; val |= g->intr_target_kpss_val << g->intr_target_bit; msm_writel_intr_target(val, pctrl, g); } From patchwork Wed Mar 29 07:46:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 76426 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp237090vqo; Wed, 29 Mar 2023 00:56:26 -0700 (PDT) X-Google-Smtp-Source: AKy350YCm+6acXKsbBYHgTeJ2JCQlbHqBY1yX47027jGzaMJay1f8PhJd0YPAUXIPx6o5khM8hek X-Received: by 2002:a17:90a:e7cf:b0:23c:8ee2:bc14 with SMTP id kb15-20020a17090ae7cf00b0023c8ee2bc14mr21397105pjb.24.1680076586599; Wed, 29 Mar 2023 00:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680076586; cv=none; d=google.com; s=arc-20160816; b=QrPiYGQtuFMaK0EY5WeSC5SibNkZVNPFZT7mpED5Wi2/BLZynKPfHBJ1+GPmWuXOAY KbXbzP/46mozhGDy0whW1zhphmbpMk9etikQ4Vzpc+ZTyGrnsaZTg2PRUU2WrtVk7F45 eWRYSZatvSuaoV6dOadrxpk7InAYCClxQGCHNnk67zLVda0c6+UkyiICuWyM4/aScQ7A JQR+TU71hmsgrKitiVARiwyZQvPk+eFpMvc71V0Bh7TJi2mFcIMYdYPzS61ddUu7uDk1 YjQcdhQG4IyCnZp1DN1qH2Ww7N9YS/ih/d3d6Gei8WV+TMpDlDdERfwrWo8SuyHEX8ai 745g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=KcmvK3x2l/sjuj0B2Rs4nb0BSROUfiFMyCxxKIHcBv0=; b=rYYqZQSs7pax+2vFbX0gFZ2l35JwyLVzSy/AAYri1JGhPljbUDpZ94VhztxBs7+rkd JYNLhM/yVBDOoqpg2/R0zkOQqYdBxJgkX2ddCTwQmeWtQZIqrb1/laNdWC8Iz30reuua 5T7g3s91JZUklc1vwMs7TsNDtwyqS8z7l8ZlgYoWfuJXZdGd+L4uzsLRvPaRgmm40ean eNG57ye0o9AiH88Xy0abM4H6hIJmlx19r/Q47OoDXUGvSho+2qBWxdewhaZ/UrTJ8aUc b9mxl/nn+GB8YsrNFVJeZylB4CftT50jmLWiKTomE6nMB4DTODS9vWlOMR1fthZTeL5G fPqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=b6N0RbVe; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf6-20020a17090b1d8600b0023b2fff4d50si984219pjb.119.2023.03.29.00.56.14; Wed, 29 Mar 2023 00:56:26 -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=@quicinc.com header.s=qcppdkim1 header.b=b6N0RbVe; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230123AbjC2Hre (ORCPT + 99 others); Wed, 29 Mar 2023 03:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjC2HrV (ORCPT ); Wed, 29 Mar 2023 03:47:21 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C9E40D7; Wed, 29 Mar 2023 00:47:20 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32T5YfBN015459; Wed, 29 Mar 2023 07:47:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=KcmvK3x2l/sjuj0B2Rs4nb0BSROUfiFMyCxxKIHcBv0=; b=b6N0RbVejV89EXq1AmhLHb2S8LYjWjlMWq++E9ldOeC0Aphc6IGwaLIoDCCynv2uxFDk hlkYsXQNmD7rj2H63MBjSxQMwvGGj79gHrhMX85ybTdP2RhbL9UA6B+v/I9+5Y8rS1EV g/vaxwR3u3WVFWS2KMr+Z61CI7sq0RVo+NPMKrKc09WTVN2WW15srA+ctbox3leDnlPW BBRuyhwAFqUX7+Td/zbYr8EmWOLodcAQsuInX6SpXrfRP4zcPMSiCL9sjTHgV3Qt1yAY aB/8P7kgoQqUQdvdWdZsYgm47tGWYzh7kGBcWXgTFgGQjIf8OsIxF14njYWwh4kHZhk9 fA== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pmawsgs17-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:16 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32T7lFIM013483 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:15 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 29 Mar 2023 00:47:12 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha , Poovendhan Selvaraj Subject: [PATCH v6 3/5] firmware: scm: Modify only the download bits in TCSR register Date: Wed, 29 Mar 2023 13:16:50 +0530 Message-ID: <1680076012-10785-4-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> References: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: tEIs343Wi4OzvcZ1pAuaAxqCHa3g2Eve X-Proofpoint-ORIG-GUID: tEIs343Wi4OzvcZ1pAuaAxqCHa3g2Eve X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-29_02,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 phishscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303290063 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1761687987007058878?= X-GMAIL-MSGID: =?utf-8?q?1761687987007058878?= CrashDump collection is based on the DLOAD bit of TCSR register. To retain other bits, we read the register and modify only the DLOAD bit as the other bits have their own significance. Signed-off-by: Poovendhan Selvaraj Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom_scm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index cb0bc32..8e39b97 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -30,6 +30,9 @@ module_param(download_mode, bool, 0); #define SCM_HAS_IFACE_CLK BIT(1) #define SCM_HAS_BUS_CLK BIT(2) +#define QCOM_DOWNLOAD_MODE_MASK 0x30 +#define QCOM_DOWNLOAD_FULLDUMP 0x1 + struct qcom_scm { struct device *dev; struct clk *core_clk; @@ -448,8 +451,9 @@ static void qcom_scm_set_download_mode(bool enable) if (avail) { ret = __qcom_scm_set_dload_mode(__scm->dev, enable); } else if (__scm->dload_mode_addr) { - ret = qcom_scm_io_writel(__scm->dload_mode_addr, - enable ? QCOM_SCM_BOOT_SET_DLOAD_MODE : 0); + ret = qcom_scm_io_update_field(__scm->dload_mode_addr, + QCOM_DOWNLOAD_MODE_MASK, + enable ? QCOM_DOWNLOAD_FULLDUMP : 0); } else { dev_err(__scm->dev, "No available mechanism for setting download mode\n"); From patchwork Wed Mar 29 07:46:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 76418 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp234840vqo; Wed, 29 Mar 2023 00:50:36 -0700 (PDT) X-Google-Smtp-Source: AKy350aSun98bYDfyJVkLBKooo3W8W1LsScwgXDkG34fe/fqKMQm1daH93u8bFvpUuBWyzp6Inbd X-Received: by 2002:a05:6402:20b:b0:4fe:ddf:8d8c with SMTP id t11-20020a056402020b00b004fe0ddf8d8cmr17563940edv.13.1680076236224; Wed, 29 Mar 2023 00:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680076236; cv=none; d=google.com; s=arc-20160816; b=RnnnInT8rUqVHQ/oyCsAbQ8t+lap/RrXP6WRGeMOrM9JZIX4sfM5p7T+nDwO71QRZ7 eccwh0NeKYNad68T7A9DM5gDeRaYbCMLzVlzTCvxL/I/t/snA+JlakxfPCLBQVFbZu/7 ueUusmj+uINYY0boydJuE7uNtMzk0LNNwMeckH4wwCthfB5sW7is2UqBLxRYwPRD4Ssy 9b1OmkXyt+wZPEGbx51efBS1p/bG29knOmfSIJcqyxT2a4yHPPHboJeBRNZw9Tev9rg8 ebT6aAkiIQeDXnK1erVUhcBVhZi7SWidDVZdoopCJo0Y7AqIYS9uyc3AZiTiZyqFqE5I c9Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XCWf0qlDqgL6QBd8bLodPcr6euwFUcbCK8kA14bi6fU=; b=dsh4MdFuG49wgRP1Gv+MR7dy3HaDCRrauyXiomowOWnvpd5HgRrKkJos4VY51KOjsE 3DPuolpAy5RV/Utjx37aaXtrbm/GmZb+Hx4dQc32lEPsM432DFTxRYl7Zbm97XZteZWL vFqaGj46cMklyfyOUKXYbzM7Hw9G9RKoXzeoTkNjKi++1F1w6jtTYa3gymf00R7M+YIm /RXTu8WXJYNklHcbR5GBYULkqTviUVVtoGWwEb9Y8dsEEL1T8Qx7us2gdGG7Za9oRLgH 5xZtLIqT+J9OC7fXmH83qPlZkEuebkBR8OoZEv+i4tpzaulvf2PlEAXXmUOiOcFcqtvW zIgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="H3P4/tcY"; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e8-20020a056402088800b004acd22dcc07si13114891edy.212.2023.03.29.00.50.12; Wed, 29 Mar 2023 00:50:36 -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=@quicinc.com header.s=qcppdkim1 header.b="H3P4/tcY"; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbjC2Hrl (ORCPT + 99 others); Wed, 29 Mar 2023 03:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbjC2Hr3 (ORCPT ); Wed, 29 Mar 2023 03:47:29 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 127AE211B; Wed, 29 Mar 2023 00:47:23 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32T3qcol011696; Wed, 29 Mar 2023 07:47:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=XCWf0qlDqgL6QBd8bLodPcr6euwFUcbCK8kA14bi6fU=; b=H3P4/tcYxUTtu5KcXPzw7CUXqNhpxMOsQEdHCzBom6Qoh/qwulvdFlFA+CjXGdf9QJzV NMipcUlxGYcxAeHhwDQaFu0+Yp1leuow1sowAw5TtlNKH/U8twYunm/uRTSUA4fyRvd/ Ozl1oMHOFGAr+GI28BOQS1ZejRykQA02vXDM0NcNY7tGrJiYhJ7D/HJKw6xsWOYw1wg6 vh66MJXl7Wjf4Qa5BMFFEFRdRBd0Yc49wup1u9b0XcQMjeMIk3wdcrDgpOv7+rNtJWQk fn+Ef3oNm7iTZnsHqivj2Ihc93wJ0L49Jlhwub82UiCReMoHr/9sgtQo7iggxusHolV0 5Q== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkx0ftu00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:19 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32T7lIc1004038 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:18 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 29 Mar 2023 00:47:15 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v6 4/5] firmware: qcom_scm: Refactor code to support multiple download mode Date: Wed, 29 Mar 2023 13:16:51 +0530 Message-ID: <1680076012-10785-5-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> References: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 8ahuGs8fXwZ8rsl2jj0_aewsBQyb5rQU X-Proofpoint-GUID: 8ahuGs8fXwZ8rsl2jj0_aewsBQyb5rQU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-29_02,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303290063 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1761687619490864516?= X-GMAIL-MSGID: =?utf-8?q?1761687619490864516?= Currently on Qualcomm SoC, download_mode is enabled if CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT is selected. Refactor the code such that it supports multiple download modes and drop CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT config instead, give interface to set the download mode from module parameter. Signed-off-by: Mukesh Ojha --- drivers/firmware/Kconfig | 11 --------- drivers/firmware/qcom_scm.c | 60 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index b59e304..ff7e9f3 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -215,17 +215,6 @@ config MTK_ADSP_IPC config QCOM_SCM tristate -config QCOM_SCM_DOWNLOAD_MODE_DEFAULT - bool "Qualcomm download mode enabled by default" - depends on QCOM_SCM - help - A device with "download mode" enabled will upon an unexpected - warm-restart enter a special debug mode that allows the user to - "download" memory content over USB for offline postmortem analysis. - The feature can be enabled/disabled on the kernel command line. - - Say Y here to enable "download mode" by default. - config SYSFB bool select BOOT_VESA_SUPPORT diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 8e39b97..fa6502a 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -20,11 +20,11 @@ #include #include #include +#include #include "qcom_scm.h" -static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT); -module_param(download_mode, bool, 0); +static u32 download_mode; #define SCM_HAS_CORE_CLK BIT(0) #define SCM_HAS_IFACE_CLK BIT(1) @@ -32,6 +32,7 @@ module_param(download_mode, bool, 0); #define QCOM_DOWNLOAD_MODE_MASK 0x30 #define QCOM_DOWNLOAD_FULLDUMP 0x1 +#define QCOM_DOWNLOAD_NODUMP 0x0 struct qcom_scm { struct device *dev; @@ -440,8 +441,9 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable) return qcom_scm_call_atomic(__scm->dev, &desc, NULL); } -static void qcom_scm_set_download_mode(bool enable) +static void qcom_scm_set_download_mode(u32 download_mode) { + bool enable = !!download_mode; bool avail; int ret = 0; @@ -452,8 +454,7 @@ static void qcom_scm_set_download_mode(bool enable) ret = __qcom_scm_set_dload_mode(__scm->dev, enable); } else if (__scm->dload_mode_addr) { ret = qcom_scm_io_update_field(__scm->dload_mode_addr, - QCOM_DOWNLOAD_MODE_MASK, - enable ? QCOM_DOWNLOAD_FULLDUMP : 0); + QCOM_DOWNLOAD_MODE_MASK, download_mode); } else { dev_err(__scm->dev, "No available mechanism for setting download mode\n"); @@ -1419,6 +1420,49 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data) return IRQ_HANDLED; } + +static int get_download_mode(char *buffer, const struct kernel_param *kp) +{ + int len = 0; + + if (download_mode == QCOM_DOWNLOAD_FULLDUMP) + len = sysfs_emit(buffer, "full\n"); + else if (download_mode == QCOM_DOWNLOAD_NODUMP) + len = sysfs_emit(buffer, "off\n"); + + return len; +} + +static int set_download_mode(const char *val, const struct kernel_param *kp) +{ + u32 old = download_mode; + + if (sysfs_streq(val, "full")) { + download_mode = QCOM_DOWNLOAD_FULLDUMP; + } else if (sysfs_streq(val, "off")) { + download_mode = QCOM_DOWNLOAD_NODUMP; + } else if (kstrtouint(val, 0, &download_mode) || + !(download_mode == 0 || download_mode == 1)) { + download_mode = old; + pr_err("qcom_scm: unknown download mode: %s\n", val); + return -EINVAL; + } + + if (__scm) + qcom_scm_set_download_mode(download_mode); + + return 0; +} + +static const struct kernel_param_ops download_mode_param_ops = { + .get = get_download_mode, + .set = set_download_mode, +}; + +module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644); +MODULE_PARM_DESC(download_mode, + "Download mode: off/full or 0/1 for existing users"); + static int qcom_scm_probe(struct platform_device *pdev) { struct qcom_scm *scm; @@ -1512,12 +1556,12 @@ static int qcom_scm_probe(struct platform_device *pdev) __get_convention(); /* - * If requested enable "download mode", from this point on warmboot + * If "download mode" is requested, from this point on warmboot * will cause the boot stages to enter download mode, unless * disabled below by a clean shutdown/reboot. */ if (download_mode) - qcom_scm_set_download_mode(true); + qcom_scm_set_download_mode(download_mode); return 0; } @@ -1525,7 +1569,7 @@ static int qcom_scm_probe(struct platform_device *pdev) static void qcom_scm_shutdown(struct platform_device *pdev) { /* Clean shutdown, disable download mode to allow normal restart */ - qcom_scm_set_download_mode(false); + qcom_scm_set_download_mode(QCOM_DOWNLOAD_NODUMP); } static const struct of_device_id qcom_scm_dt_match[] = { From patchwork Wed Mar 29 07:46:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 76429 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp241162vqo; Wed, 29 Mar 2023 01:04:01 -0700 (PDT) X-Google-Smtp-Source: AKy350ZCSZAP7ic0Q2z6GpPj1BiwM2c83xmqHqRHqh5pwT3qX8N8SFybtkQ7LMjy0HXtxA+FjrBn X-Received: by 2002:a17:902:e38b:b0:1a2:ca:c6cd with SMTP id g11-20020a170902e38b00b001a200cac6cdmr14623708ple.43.1680077040733; Wed, 29 Mar 2023 01:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680077040; cv=none; d=google.com; s=arc-20160816; b=tClICLeoNXInVBet6rG0O9TOS1+F4Gf98Ll0sFkXbVabHdGOxY2PtHm0lzRqFjIvkN jgejXS8RI9arwUboRS+ITjt8mu+RGOZ2oPhQv/UAYQjgfv8XkC5vAzTVStdyb7OOUYns N3lVnRkrUBgAYKm1bpTZ248YrcYbDMI5zR7cicUXZJsG768gvSjS+FWE+dtjDJs1CZnQ /PSO6/IRo1I+hAzl1tNHzXzlTvo2yRTJrkSmNPzFZnvxOilwGr9/MqMVrnI7E8Jv6xLF 6gDLlrGd57JQA63u7d9yL2ErzZK46J/V4MDPR03jiptr9V5Fxpkqb1Jjnm4lyjuw7sO0 Z1Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zl6Aev0GuHxXwgicjeSDL0BKmzlXRcvwn/SV8yruS8Q=; b=x32Xvkuc0JfNDTnY/qhsj2P6Asda99ntaI6z2FbxTeCh+QHlktgDM9uk4HRAKkc3LX N8qyQW3sI9f6gPVAUMFd7KQcWvlFIHG9KZx9gHq9H3PdRiZPtCRtr8e3ID/TDTiQs8Q7 /mJVXcnFCTrCiC2laOtcrzrCkLyEw8/PDeNXxxHeFI4rLoVOAbQeQkV4FBR5TyJRyz0L 8vu7teHtt8fYTlO3RslzPDU/pybg2DWXJnIORa3ccTi60zhy+F11oZwp4LpyU3ifHIjT weFM4gq28FMvHv0PXUfNl0s0YMToxfTGsrlLokvQG7rZHepHy6rvNLVIP7TyZ294zLHg fkwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=e53eDvg7; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k12-20020a170902c40c00b001a20296932fsi15808309plk.538.2023.03.29.01.03.47; Wed, 29 Mar 2023 01:04:00 -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=@quicinc.com header.s=qcppdkim1 header.b=e53eDvg7; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbjC2Hro (ORCPT + 99 others); Wed, 29 Mar 2023 03:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjC2Hrj (ORCPT ); Wed, 29 Mar 2023 03:47:39 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E46421E; Wed, 29 Mar 2023 00:47:26 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32T62q1H026836; Wed, 29 Mar 2023 07:47:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=zl6Aev0GuHxXwgicjeSDL0BKmzlXRcvwn/SV8yruS8Q=; b=e53eDvg7Zi1muAdmZmaSp45vTMK+aEKmZS4QNNm+1QGvZOSArM8S6y36hDSB0snVyvz/ 7JY6Oj56d6l68H+5uDI2jS8GQsjoWzvDhUZXa9tws7ljxPzLqaAhQJIKRifkGauCwlLh +Njp/3qAR4q+swiHZJZ7C3AKHhS/ZS7Rg+bAMMjU6LNqH5LDJsbjrColHjBEUENVmPx3 BpTflPs8A5IemjiCFczOljMvBulVfYmJJQDf3ru9o5HLh2/fRjzF3jMb7ERiwWI5k55x dmjV8n9oa9KLQb694UprwpF8SSxLWBeRXv9HvnfZDW9kl7jFFo7ndq5i9tFmCJbRgKgc 3Q== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pmbs88nc7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:23 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32T7lLp8013636 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 07:47:21 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 29 Mar 2023 00:47:18 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v6 5/5] firmware: qcom_scm: Add multiple download mode support Date: Wed, 29 Mar 2023 13:16:52 +0530 Message-ID: <1680076012-10785-6-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> References: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: IB1Q3HGCzdX9VDJmtj0myzZ2XtxGpxLJ X-Proofpoint-GUID: IB1Q3HGCzdX9VDJmtj0myzZ2XtxGpxLJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-29_02,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303290063 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1761688463443339068?= X-GMAIL-MSGID: =?utf-8?q?1761688463443339068?= Currently, scm driver only supports full dump when download mode is selected. Add support to enable minidump as well as enable it along with fulldump. Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom_scm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index fa6502a..780e50a 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -32,6 +32,8 @@ static u32 download_mode; #define QCOM_DOWNLOAD_MODE_MASK 0x30 #define QCOM_DOWNLOAD_FULLDUMP 0x1 +#define QCOM_DOWNLOAD_MINIDUMP 0x2 +#define QCOM_DOWNLOAD_BOTHDUMP (QCOM_DOWNLOAD_FULLDUMP | QCOM_DOWNLOAD_MINIDUMP) #define QCOM_DOWNLOAD_NODUMP 0x0 struct qcom_scm { @@ -1420,13 +1422,16 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data) return IRQ_HANDLED; } - static int get_download_mode(char *buffer, const struct kernel_param *kp) { int len = 0; if (download_mode == QCOM_DOWNLOAD_FULLDUMP) len = sysfs_emit(buffer, "full\n"); + else if (download_mode == QCOM_DOWNLOAD_MINIDUMP) + len = sysfs_emit(buffer, "mini\n"); + else if (download_mode == QCOM_DOWNLOAD_BOTHDUMP) + len = sysfs_emit(buffer, "full,mini\n"); else if (download_mode == QCOM_DOWNLOAD_NODUMP) len = sysfs_emit(buffer, "off\n"); @@ -1437,8 +1442,12 @@ static int set_download_mode(const char *val, const struct kernel_param *kp) { u32 old = download_mode; - if (sysfs_streq(val, "full")) { + if (sysfs_streq(val, "full,mini") || sysfs_streq(val, "mini,full")) { + download_mode = QCOM_DOWNLOAD_BOTHDUMP; + } else if (sysfs_streq(val, "full")) { download_mode = QCOM_DOWNLOAD_FULLDUMP; + } else if (sysfs_streq(val, "mini")) { + download_mode = QCOM_DOWNLOAD_MINIDUMP; } else if (sysfs_streq(val, "off")) { download_mode = QCOM_DOWNLOAD_NODUMP; } else if (kstrtouint(val, 0, &download_mode) || @@ -1461,7 +1470,7 @@ static const struct kernel_param_ops download_mode_param_ops = { module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644); MODULE_PARM_DESC(download_mode, - "Download mode: off/full or 0/1 for existing users"); + "download mode: off/full/mini/full,mini or mini,full and 0/1 for existing users"); static int qcom_scm_probe(struct platform_device *pdev) {