From patchwork Tue Mar 28 15:37:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 76177 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2333572vqo; Tue, 28 Mar 2023 09:09:00 -0700 (PDT) X-Google-Smtp-Source: AK7set8yac9MaD5d8MqryiRHmNL2IHl90Vfdm3T8ZZ+jrX08VyFKZaUlcJ1QTAbl5QbnYdKIsGSA X-Received: by 2002:a05:6a20:b909:b0:d8:d16d:61d with SMTP id fe9-20020a056a20b90900b000d8d16d061dmr13804261pzb.37.1680019739821; Tue, 28 Mar 2023 09:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680019739; cv=none; d=google.com; s=arc-20160816; b=oYN7boOVE8sA4lw5ve8pznsszm4AiWKdaA7ME9Cm+xmmubTZKv2FMVPEg/F5bFXJLT is9L/lqbaC+Ev+mgQ+Pv+cXvHRZIEVx17sO+Uh7/SH2jdswfV1I7o4wZf5VNx5Vrmdlp sfQzqYs7PkamwGw6gHbA3Ld3hfKQ2EmXxMnt02cDJa8FHhjvp9DBDESQcpN+S21cfg0u afnyT76Xa4AZ6Arpx/KJT5m/Oay5QPGsUEZtgVd8syfje/bX2EusX7lRH8jZNreb9vcR 44CFgXiIHoS9zIhPHndkuPt5Sg0dXykFxaijGz/lpO38lFzlnipdm6teTcsF1bcjp+IE aVTw== 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=U1AS6UiLfevrWiMIIHSJZM1VVYFISO73FNGPzUITDKl79x3ZyFCn6QSWmPHtcE0sPc T63XGVLeoaVklNDB21o59Xp1E1dO+qvWzPFiX/PgbFnORt8B0YVDeVF0oDZMLQ8jXIT/ YELCF1K49fVvnXhHCUOD3THp8Cp7VSlvMp+WuLwGRNhyn5AMR0CkX8+XyxgFnIfw51AS /j8RoYLscIgQjqZeRkcRHW3UQ6V3gIFqTr/QE+N7y/d9WLvgC1JDQu6sR6Tix/CJHSCw 7JvZ9wXzqYX7+ji44MVCtT3aS5+FZr2JyQeov69wA/3EuLIoncPgpM5cpBy6EiNDQ/DQ Bo1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=MtuOlzOq; 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 v30-20020aa799de000000b0062d90384500si3194709pfi.307.2023.03.28.09.08.42; Tue, 28 Mar 2023 09:08:59 -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=MtuOlzOq; 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 S234050AbjC1Plg (ORCPT + 99 others); Tue, 28 Mar 2023 11:41:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233729AbjC1PlO (ORCPT ); Tue, 28 Mar 2023 11:41:14 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D5B011674; Tue, 28 Mar 2023 08:40:13 -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 32SAsU6b014641; Tue, 28 Mar 2023 15:39:50 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=MtuOlzOqMLiBtiQBF+u5vUmSjXY3zVomFQq7M6nySKzknyNAdD4ecwfiBbHZS1jZajYJ X+nbqMPw1uA5q64gOAN0owWuBcaVbhzRRrWnTjaOpLIV6he3R2O2bKV6yQOJV+nfXkbe u//GJhIHlNj00Mx64eR1EgLfB3PV4u/WL6AjVbKhs019J531CqkCas9qyH0Mx6ZcNY0X gwrIgLY5ndBt6R/MnfcsKeHcvWm3zIvh0MqtsTPuzw/w7jTPcf0IP+AGHuW68n7UEQ6N YNZa0SLPkRLunqYDCEQ8xjjfZA3O7qNPuDbKU5ygoEQT8C5ORjwRKMix/VjZCCAUGlks aA== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkv45h8gm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:39:50 +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 32SFdnoo004663 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:39:49 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; Tue, 28 Mar 2023 08:39:46 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v5 1/5] firmware: qcom_scm: provide a read-modify-write function Date: Tue, 28 Mar 2023 21:07:45 +0530 Message-ID: <1680017869-22421-2-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> References: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: yhExNJi0zq4kd0jlKCn3f4i02nenOIXD X-Proofpoint-ORIG-GUID: yhExNJi0zq4kd0jlKCn3f4i02nenOIXD 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-24_11,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=646 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303280121 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?1761628378672631133?= X-GMAIL-MSGID: =?utf-8?q?1761628378672631133?= 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 Tue Mar 28 15:37:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 76156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2316903vqo; Tue, 28 Mar 2023 08:45:26 -0700 (PDT) X-Google-Smtp-Source: AKy350aE0jaem4sswy2XxeUKN0GP0COkaV+w6sniqTyyOXrco8zgZam6WE5nb8/D2e/Q2m4w3nTi X-Received: by 2002:aa7:db53:0:b0:4fb:aa0a:5b72 with SMTP id n19-20020aa7db53000000b004fbaa0a5b72mr16378400edt.5.1680018326459; Tue, 28 Mar 2023 08:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680018326; cv=none; d=google.com; s=arc-20160816; b=N1tmwb7D0gFNkj+9eSwZ1iteycG3Cu7ucbDmPq2ocG5UvkrdS0gQZyx0eHCI+eE14G ZAJekiFlOR5HX0ORGB7K6jLFsIq5hLj32ik6t2sR54d61MJxnfRHPBP42w1DZ6dKiRf6 NVVEwIMyzy1HmhACJxVnBsr6uIsT+Km8Uiwizpq+qeY6hwaQqoz9ybBFxsMAea76pyGt sr1w2PH4wCpFgFPeoYrprE2gyL+i4FjNT+f+goaIG18BnJM/MEfD6R5F0xcdCLcEebr2 UF/08G7qhRjLF7PNCZtgaFRST6JH+ZmVSjmhE8U1xyDM/VUz+uuICSckh/MkkYs96Dm1 5Z7g== 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=r+pX2vSb4YAJKMO0j8KLMPAl+BMabReRmbo81yPu2HrUyq+fd9FOyZPXrGK/7AllA5 BbWi7TfGPV2J52eU0lUb05m4wievgVIcQJ5QAkWtS3Ss2wDsGR0Be731SlTyOsivIsD7 uR1jbMUltu1a40Vnbb/sThdfO9hLT6xLSdp6S476EuG4/qpRoOwUHDLRE6/d7fHcENpC SLoQK8nwfoYb0oWMVbN/ySEFfY0TX4oJE1geW8oKja5zdrI4SQXw/PlUhuJIyfhWJebD bq69c8viFadi7P+wL7dMbJmYi6rgA6U5IKNCsuw681imIks/aDqTTfjJnjQUDscipwtI jWrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=OkGE83NW; 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 i16-20020a50fc10000000b004acc454abe7si30776349edr.260.2023.03.28.08.45.02; Tue, 28 Mar 2023 08:45: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=OkGE83NW; 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 S233760AbjC1Plj (ORCPT + 99 others); Tue, 28 Mar 2023 11:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233943AbjC1PlO (ORCPT ); Tue, 28 Mar 2023 11:41:14 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E97611E84; Tue, 28 Mar 2023 08:40:13 -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 32S7iuZD014407; Tue, 28 Mar 2023 15:39:53 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=OkGE83NWHUm6FaTWy2rjtoue1WyewqTKBk8iXXlZVKEqZCqd7fjfHdHVZBVR7cd1ZUa0 pj4res8jGmGrL5Yk13gKLYpGB7krZWMG1s8paGhoSn68GEcabIQIgesBAIXHNgZ7wWLc JA4Jbk1lqkD+KH6ACAIEj3FiY47MxYtrPPsbCAoJ/6jAKI64injR/j31RKmryv3PxhoB CSv5yCaQNePR5nELEAFfKczevC5BVmETA2svkq0cDavjkf+1fi9/KPQs3ZYYCGVpI1mD rDxAhlTRQjZybSIu3miq/2UTzaYBisY9sk9ao1X/3p3Ia+vPOCt+5OqWrEbvwQLNwGiw 0A== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkv45h8gs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:39:53 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32SFdqiq022990 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:39:52 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; Tue, 28 Mar 2023 08:39:49 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v5 2/5] pinctrl: qcom: Use qcom_scm_io_update_field() Date: Tue, 28 Mar 2023 21:07:46 +0530 Message-ID: <1680017869-22421-3-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> References: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: TKn8C7nppsSyggOAmVDd9ObJxSq-Uj6k X-Proofpoint-ORIG-GUID: TKn8C7nppsSyggOAmVDd9ObJxSq-Uj6k 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-24_11,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-2303280121 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?1761626896376218759?= X-GMAIL-MSGID: =?utf-8?q?1761626896376218759?= 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 Tue Mar 28 15:37:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 76158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2317278vqo; Tue, 28 Mar 2023 08:45:56 -0700 (PDT) X-Google-Smtp-Source: AKy350Yx6spYsDD1Elow9SfnPaKYi937h/7Bj8eP+o3bnQUtWMs6ak4wz0zGTboqm/WUWoGhThNm X-Received: by 2002:a17:906:7109:b0:931:32f5:1f31 with SMTP id x9-20020a170906710900b0093132f51f31mr17401186ejj.9.1680018356153; Tue, 28 Mar 2023 08:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680018356; cv=none; d=google.com; s=arc-20160816; b=QPODsyuc5o9c0drxCSKoQ5AxjIduf9eu0UaPrGQzGXl2WF+NDnyqteGrA01aAVnc7a JADnMF4fNbqaGE/PJg8QVt+c4HSNfnvcO4IIyHm5dXGTI4Zxiy49Znj5LjqDaOWkdmZn jT756bHQ7G7px2HngCltJdELdaD3vCYaKZNk4m6FlseCKBabv/OIwyB1qUupMbNBJlwR Vy3xKyG03DdAEaMMMaeJPG9d0zryv2pevhXntNxRdBrCcltHayxgn37LnUaR6jNjTAML BtxhX28uAuF6YPfsxKEtt3tXhMf7m47awroUEzeIQSsRbBFF4Gy2YBNEA8F/hItaWSoX e+mA== 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=u+I2XruE2WFUiD3YIE6myTinHOqM0YelzxYGSpRQXDphaO9/OkUq+34Pe5Nt0wI5pK jmjhJ99D/RF7eOyGiF3T1ytYKjFwLnfH9RP2k2iEmUahd9ilSP2UXrwGuvo/QkxNKBv6 FsqrtlIZMz1Yws1fwnc18voE0HFwSGZP2OKniwHE2f/DkBEJW8c50/Qi6yGUC/gUMKGf SHyUydqJAXJvxRr9Wda7oZxTcDPHPB7ZSrBvhwphzUuCtrwS42ouKV29ekVhnMHQ2PXc yOpD46BctEwkj8vs4EWWaoJpjLtcaqiiXSLhLT4qc8Hx6Wi04nXIxuou31HVyCVLGZUb 7qJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AajSWNS6; 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 a8-20020a1709066d4800b0093de089f33esi10557317ejt.841.2023.03.28.08.45.32; Tue, 28 Mar 2023 08:45:56 -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=AajSWNS6; 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 S234118AbjC1Plm (ORCPT + 99 others); Tue, 28 Mar 2023 11:41:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233953AbjC1PlO (ORCPT ); Tue, 28 Mar 2023 11:41:14 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E23C11650; Tue, 28 Mar 2023 08:40:16 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32S8BVRc021843; Tue, 28 Mar 2023 15:39:56 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=AajSWNS6N15Ja1n7S3/dLPGoSQwfKbDDg1pEZ41fO5acVKDsZekXwT5Kz7UgZEO/kFUg X7UpMq3Hag30T9yew43Dd4R3yVQ3938CPdfDXTUfi7ydxjP+/8//co3xZ97A5VJd41Mv KrehjqX3NUgcdZEfQ5sMZjmjYdSneIVbE1yA+lFg35Xbnyrcd+yCPsa3uxntYlrF/Mt8 GTK/GDGRg3OzG7DA0MZyhI8MrqCy655sXJwAjLYiOWaqLqXmxTlMKxmQO8CZDLWJ5ZgM fxY6M1CmKbTPxcWCA+r7YyiR7e40MzScCQZrv8hZuiSd5cXADj1zUDPbyy3HM16PuktA YA== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkk7baa2r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:39:55 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32SFdtqm023026 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:39:55 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; Tue, 28 Mar 2023 08:39:52 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha , Poovendhan Selvaraj Subject: [PATCH v5 3/5] firmware: scm: Modify only the download bits in TCSR register Date: Tue, 28 Mar 2023 21:07:47 +0530 Message-ID: <1680017869-22421-4-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> References: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: -rQ6Vf_hNS0LxleyEf0pFfSEzAHHGf_e X-Proofpoint-GUID: -rQ6Vf_hNS0LxleyEf0pFfSEzAHHGf_e 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-24_11,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 phishscore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303280122 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?1761626927651571978?= X-GMAIL-MSGID: =?utf-8?q?1761626927651571978?= 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 Tue Mar 28 15:37: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: 76171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2330927vqo; Tue, 28 Mar 2023 09:06:16 -0700 (PDT) X-Google-Smtp-Source: AKy350Z44RLJ0o7Ksi02HSOBpN8UiDTgdL+K/oeB4KUkC1tD4QFkNVSok39FMSa3cAnLoSK1HJjz X-Received: by 2002:a17:906:4e0a:b0:931:829c:9d58 with SMTP id z10-20020a1709064e0a00b00931829c9d58mr16729090eju.23.1680019575877; Tue, 28 Mar 2023 09:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680019575; cv=none; d=google.com; s=arc-20160816; b=mlCz1SqnqUzulq3snDl+Mk13eYpDcPuZs4lk67rByZKXnrlIAc3CBuprkD6KTWB672 hT/Kw9qSMvyDmoOdqyI6CTAGW9bgkSNjr4+UQEysX8nKP+Davh6mKJJyLc/mn5G8y41C fo8J6peVL6+BlR5I7vz4FOFTKQaQEJ6bJvW7+Q/KrxRhuo2iKMGHXbFa+S9NScTMFeRr UgdV3gpdvEZULGqcSarPfUhVUbmn1Vi8+ckXyBnxS/jtYpifle1d+f5KHhm8etNLj3aM Om9gQzsz1fnD2883+P0kqvgt9XSwXMmxdMlXEdB70d55fBiKAYeSTIMqkgvuNDBNVLAH PLLA== 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=UzOkAbo53yU707Z9eFAc6l/Yp8oVbS7bLPnSz7LCwtI=; b=UX5oVl63IZN/rHTqhbfLYZPTwy4BxfBvegPFeI5v3qnXKDzelcUBOcmb5mbIESDnFt +VD2jED16qQWQ33VXss1ilhhM5vP9xcibp2iDl/koVdnH/W+ZMyfeO0a0in19yBpZ6Ko m/syLxWeSfkG4MBz5hS2AdrlYtTl5IauPoYYMhVa9ppf+2IYFrcEsXtsLHWfIhgVDyBL 9QPQKwQW5GWZlA+5D/O8Yb/Uh4k3fWILhG85Z/P/QPVi62Inh93sD44MHEuATaH8SvZt ec/ImsD/68BhnL4/CgM4EvPJ8/CuEhbG41ab1jIqQUhqFv0lgCh167jK06nZ46GqWkAe 82qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lhmNBR6f; 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 l1-20020a056402344100b004be9d2d7efasi32888339edc.1.2023.03.28.09.05.50; Tue, 28 Mar 2023 09:06:15 -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=lhmNBR6f; 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 S234135AbjC1Plu (ORCPT + 99 others); Tue, 28 Mar 2023 11:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234010AbjC1PlR (ORCPT ); Tue, 28 Mar 2023 11:41:17 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8938D11EAB; Tue, 28 Mar 2023 08:40:18 -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 32S84n0S003463; Tue, 28 Mar 2023 15:39:59 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=UzOkAbo53yU707Z9eFAc6l/Yp8oVbS7bLPnSz7LCwtI=; b=lhmNBR6f7ZT0XpnQrLd9KgfkogrxxglK1xxQ1TSrFrXqekUb4ps0ehvJ5BDVKKVy1zhh a6qDhd9xCldPqNkX07jnHRI3tnuPdSH6iZZ7l3EfUxQ3T4IRX/hXph7I/eXDzmRLWoOA kokzlEdeYy3+xZ0uQQHsjwcU1nwSgAD0fpHefsmfDImmeNVf2OjTkcZrdMnrcFDeRjuC 2EfanzOlvv6NRKouYWBL4BNiZ4bXgH4esV26+Ogko5GRY1IxIYHrZVGouiDShkWyZSQ5 Be7wVnTXTVqDUwxcGpU3SIlN5miZ5E+sv+DQjYc49ob7Y4dzku81xdXHIhpoPpogOK+7 pQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkv45h8h2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:39:59 +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 32SFdwC6004813 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:39:58 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; Tue, 28 Mar 2023 08:39:55 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v5 4/5] firmware: qcom_scm: Refactor code to support multiple download mode Date: Tue, 28 Mar 2023 21:07:48 +0530 Message-ID: <1680017869-22421-5-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> References: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: ELpYD3cVWphfpG98tnSHFNe6ZLhkNTYR X-Proofpoint-ORIG-GUID: ELpYD3cVWphfpG98tnSHFNe6ZLhkNTYR 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-24_11,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=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303280121 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?1761628206900187793?= X-GMAIL-MSGID: =?utf-8?q?1761628206900187793?= 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..53ee301 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 (!strncmp(val, "full", strlen("full"))) { + download_mode = QCOM_DOWNLOAD_FULLDUMP; + } else if (!strncmp(val, "off", strlen("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 Tue Mar 28 15:37: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: 76173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2332587vqo; Tue, 28 Mar 2023 09:08:03 -0700 (PDT) X-Google-Smtp-Source: AKy350bwIqb1ZiV8TZTMXjKCAUsm0nJMMUSiFtLKlRffi4PurV3GSt8YmoYrJFKuy6JJ2TEgBhaD X-Received: by 2002:a17:906:8559:b0:931:9cd2:c214 with SMTP id h25-20020a170906855900b009319cd2c214mr16141472ejy.66.1680019683092; Tue, 28 Mar 2023 09:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680019683; cv=none; d=google.com; s=arc-20160816; b=KVltzLIjijRMxZ3AZEX4WKmyQo62KvYLT87JtYxRSj50qFKmIuoCnNxjMSmmUb0VwX 2qmBnC8/YlfuNgBJX2M4DCZO4EZpfnulZel6YS+N08Sa+lNtI1aoeFOFjCXjnZBdNfNA EOo6Fx0l52wCUD86QaHwFUPOFh5BFferG1Hx1ZTbkSYJxQV0guYTm4DjDjZqZNjnMjmt 4nNFKEkVoEwZm2xgF/slMoAK65xgdEaw+PddssmJLOtbLWYz7wPrvMJ3yivTkeXaYLE3 I3WsI4MP1s8reYstMAFPpsAPCgh+DR5nIpK0T4ngHwtaXLjWXkLFkH6kqzdo6TDXw2Z/ RxOQ== 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=H71WGrCAYklp17zVh4ajvpjqsuADx7LOIFaxdrwlAcY=; b=wqJvlLyTFiePK2W6k2NLBZNp/fEkaQ/2ZwnCGMklP5oNmo4pkSDf+fUBdogMtYo06C UTt9C/JgGecKEutw7ExoP82cgFl9EBkIY+gaXMmYes0DQJeP6jrE7g19Zy9pfeOIvC6k JfdLZCs0VdNszZWxkDQgOrr4sE0t7NQaKgQWQBM0Hgvh0pRXTybVJ0YFijTlD8kLSJh7 1Hn5uVpQHScCBjwiOLyrJj8hHrS6rWvSrY1UK2P3z5MFtmbPGg/sc3GUqzm8uaGPWPMG t8v94EJuED0Lr+gya5zTaQzvXyTdQdilAkCabcLy42m7dddAHUjU2d0Id2zyLrTaJEzo TU3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="AJGk/WcC"; 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 sg13-20020a170907a40d00b009334637f8a5si31585025ejc.125.2023.03.28.09.07.38; Tue, 28 Mar 2023 09:08:03 -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="AJGk/WcC"; 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 S233380AbjC1Plz (ORCPT + 99 others); Tue, 28 Mar 2023 11:41:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233901AbjC1PlS (ORCPT ); Tue, 28 Mar 2023 11:41:18 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20C9B11E83; Tue, 28 Mar 2023 08:40:21 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32SBFPsC004224; Tue, 28 Mar 2023 15:40:02 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=H71WGrCAYklp17zVh4ajvpjqsuADx7LOIFaxdrwlAcY=; b=AJGk/WcC9ul2rEStiegDS428RGal32SuykKfYpsecG6SZy/Jhwtodj9vFOosHPXa5g7Q IJjF+wo/M+gcKBZGUkqxpuLb1umWkx/gI6xgxJle8CUrcdHhoGKedhs9nKy2BG2ZXQX8 JAFgiQmAlu28mNytQuDL5cZpfRHqbjV7qDYo18m36OEnboy5cF8FQ34v5yZZC0ev+LaQ NNI3XSIA6Tk9REFE11nNX1AuNlBaQXLtKELFD4kXXOVYPHA7mDbK2MGs89QVlF92wpfi VNVo3z2UvDbm1p0OYiPMMHqV9l2yMecK4AGsPA9ZNR3v1OmxfNv1022RanJw3sDG6FhU SQ== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pky700t4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:40:01 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32SFe0n5007189 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 15:40:00 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; Tue, 28 Mar 2023 08:39:58 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v5 5/5] firmware: qcom_scm: Add multiple download mode support Date: Tue, 28 Mar 2023 21:07:49 +0530 Message-ID: <1680017869-22421-6-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> References: <1680017869-22421-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: xixtT1NBlc3owZrXSEZIypWg2um47GbE X-Proofpoint-GUID: xixtT1NBlc3owZrXSEZIypWg2um47GbE 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-24_11,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303280121 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?1761628319395824237?= X-GMAIL-MSGID: =?utf-8?q?1761628319395824237?= 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 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 53ee301..2a16431 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,13 @@ static int set_download_mode(const char *val, const struct kernel_param *kp) { u32 old = download_mode; - if (!strncmp(val, "full", strlen("full"))) { + if (!strncmp(val, "full,mini", strlen("full,mini")) || + !strncmp(val, "mini,full", strlen("mini,full"))) { + download_mode = QCOM_DOWNLOAD_BOTHDUMP; + } else if (!strncmp(val, "full", strlen("full"))) { download_mode = QCOM_DOWNLOAD_FULLDUMP; + } else if (!strncmp(val, "mini", strlen("mini"))) { + download_mode = QCOM_DOWNLOAD_MINIDUMP; } else if (!strncmp(val, "off", strlen("off"))) { download_mode = QCOM_DOWNLOAD_NODUMP; } else if (kstrtouint(val, 0, &download_mode) || @@ -1461,7 +1471,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) {