From patchwork Mon Mar 27 16:41:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 75569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3404:b0:112:7285:5352 with SMTP id h4csp1551833rwd; Mon, 27 Mar 2023 09:47:10 -0700 (PDT) X-Google-Smtp-Source: AKy350Y7in5lRP8g9YgsQCOHREesfmahxOhX3YTp4cxF8jJ//aNdPaFvF9adDpQPM8CvHMyfsQDg X-Received: by 2002:a05:6402:1486:b0:501:cced:9c6c with SMTP id e6-20020a056402148600b00501cced9c6cmr12522276edv.7.1679935630675; Mon, 27 Mar 2023 09:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679935630; cv=none; d=google.com; s=arc-20160816; b=iaXfj6n32OGrA9FT8/X4BGT1FTt/u9Tolv+p/MBYUTauHdQ5heX2OeUvgGO+zhP54q ycsQxdacS0Vnw2jpfuSrtKS0NS32aV4OpOpCylGCxogPMiLPAFYXC+lf/BJTnkJmRSVC WiyfYBq1QwSjkn0T6mKwAOQYMQSTOqZ8cjzNazAGdV2ptEsgDjSRxX4hcKIBCNIm7PY5 5ymZ8AiqzVjWErHGbbZudMIOE4EEINoi5wRPeDaxTa8xQLJMWOwol1dDfETGA6ZBsCkp BULtl9aj9Rpucx2jvnBZxEjjB7bQtJINxlrhcPDxjrBdYC42S/zSKKvxFZXZurVmP2ty exeg== 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=azGCApQlpLxOLIrzoDCuftMQf1s7q+OB2PswQwWfrxE=; b=CvEK1IleHrAbAEKyohvGmh7pD4VZUFqyiLWLZ3gD6iazU5l4RESB6jQAfQXHwkN3dB yfCK7nRXRRG4Caxz3DHDWvq1SHxIdivPQl1gRmQAC76qXpTW5ixcqaztU98iIHh0dYlm 5kAWFVmcpLahLAsMt/VNWDi/szb5UGMcAgng/lZ9w/K6gCnL9XRUk4EVqHk6gqZwtLJj 6flNR4jBa/r5Q67IAH6HtWU/+QGRlc+sTDIJHQQGwDa0wS5MnASBBLk4DGJTodnk3l0S dzcrCHDcP5BoY0kiv1lcmS3sztHYWBmKU+T1du6L7XInIkbtWRH9GBxbTuzlbT23zh9c WD2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=iJw4YbG4; 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 z25-20020aa7cf99000000b004beb39bf058si28232276edx.83.2023.03.27.09.46.47; Mon, 27 Mar 2023 09:47: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=iJw4YbG4; 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 S230138AbjC0Qlu (ORCPT + 99 others); Mon, 27 Mar 2023 12:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232446AbjC0Qlr (ORCPT ); Mon, 27 Mar 2023 12:41:47 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62B4F2108; Mon, 27 Mar 2023 09:41:45 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32RALcTA026412; Mon, 27 Mar 2023 16:41:42 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=azGCApQlpLxOLIrzoDCuftMQf1s7q+OB2PswQwWfrxE=; b=iJw4YbG4zBS5m9KKFTYAFGkw7m7GWsTkRVxlR1Nl9wRDY0CehlbLjE7KGNAr+3dKjwBt FHqZy+nwIc7NiP7S6dYlmU10NmAfgvMjVHRjOVnmqJwBLdE+ZXdXCT7HtE96HubYFzUu y+6UQsMq7QyilbslWREESRafUC+RrxSYlcVLupawYEUZ4OOSWc/dkWVl0PjCmK4xLrnr W9dsMx8cqgu7yzfp3KVKx043GANDp+Ip0cxnD/rq+bwpbIrYUsLCLoiJPkUfcZrJEtXt vO0pyexHKg6yd/JxJ1CHSSNYYKhglrH75cGH0w7o3ZCUCXOILh+uu0GjwYaT1l2RrWdD iA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pk7h8s8t0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:42 +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 32RGfffX028907 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:41 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.41; Mon, 27 Mar 2023 09:41:38 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v4 1/5] firmware: qcom_scm: provide a read-modify-write function Date: Mon, 27 Mar 2023 22:11:17 +0530 Message-ID: <1679935281-18445-2-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1679935281-18445-1-git-send-email-quic_mojha@quicinc.com> References: <1679935281-18445-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: RsAX7rDOzTU8oaw4p8f2SggbG2wvDFc_ X-Proofpoint-ORIG-GUID: RsAX7rDOzTU8oaw4p8f2SggbG2wvDFc_ 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-27_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=647 phishscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303270134 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?1761540183973611942?= X-GMAIL-MSGID: =?utf-8?q?1761540183973611942?= 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..431fe1f 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 Mon Mar 27 16:41:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 75570 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3404:b0:112:7285:5352 with SMTP id h4csp1552340rwd; Mon, 27 Mar 2023 09:48:11 -0700 (PDT) X-Google-Smtp-Source: AKy350b8WfKu98i6mdY5vzl7h34arLWuf5/jmJuDqL4upQUGM1dR6RyDPgGxavYwFrdqaiTjW50e X-Received: by 2002:a17:906:5d0b:b0:933:3aa7:57a7 with SMTP id g11-20020a1709065d0b00b009333aa757a7mr15547807ejt.49.1679935690736; Mon, 27 Mar 2023 09:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679935690; cv=none; d=google.com; s=arc-20160816; b=Gu8hf2Slqvq3ZQkBdYKUzyvwu8nzUBEi2sa5/0WTv+yz9FViTdFxuOdETg1Xx7Y06k OuoU59U8+Z9/q6SXPO8QsT7znmTF7sO76gYCOiIEj5pbDbve4+BoAjkXEzKUFMhbQsGq j1bRUVucSmCSS5gfeTMyQqRgDMOaGW2kMytmqO4rr+Y+o1cn77dB7/rxyh4NQuzcMb2W NpPRcOPZ4Ob8Qed4yw6n1/Y0IV/Z8Zia4I3mfrFcyE8V3yPIl4TKFTwssrGT4o35MSiQ BhaoCj2rLwR2eWoMQ2m0P/Pny6fcU+W5pVc50QP6Mjkmt36uLO/Po7W/8/ZrH+4hdOUI z7ZA== 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=KQIqLmxhznRo9seOwThpnF1ewZWAr0a9vImROth3AOjObVxWR7FqjrNOgXfcKLK5Nj 2+KnCUO5TzRv9mcJgMRu73gjtB88HpXPvs3SQDbPSYZarG20ZMoKcB2KHoucD1cvbk1z hHBgQWxfpd5AwMGMbI2SjkbWBWbVS2g6eC6pTpYgx68LYA8jOPhrBDOJ/TgN2iBFAXGj He4Exx/5SLqT4p8mvreT/u6dY9cTcg9SCMbBAzd8IC+SmihEAzi9vfxbwjJWf9UOa3eZ ACHtMcnyuQjgGJ9VHnXvy1Wr1yDMtU9o1+AkM3GsuK+8HYBtrZVBN0WQlWE5cUuWqA5h zSAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=P7yqQUFz; 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 sb1-20020a1709076d8100b009256ac76f98si26248781ejc.676.2023.03.27.09.47.45; Mon, 27 Mar 2023 09:48: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=P7yqQUFz; 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 S232520AbjC0Qlz (ORCPT + 99 others); Mon, 27 Mar 2023 12:41:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232467AbjC0Qlt (ORCPT ); Mon, 27 Mar 2023 12:41:49 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4CE7273A; Mon, 27 Mar 2023 09:41:48 -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 32RDM52c015305; Mon, 27 Mar 2023 16:41:45 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=P7yqQUFzTx9wNiHGgXZy5jTN7rucXo2QdDwVuE47+7drtt2XXnMj/AJxvbj7fHhOHOAx 5UT68HX1zyOi2VtXUOKIJ0eTpMKJh5TVE3UBoAMPNILOvP9hXHJKf5ZyX4K2KV8lt9Po 7Gj9uZ0h/RuNJe/X7mu/Pvldb4fbn1xHW/vAcWegryA3fWO5kSRLXMMtGWcz6PUfKgrn iDXUWB2dzs44KNRSGZZ+JL6JrdiNqmOjbthxDiIAFp3kcrEWd6ysFm9GWcztlcN2dps8 5nnekZAcP2vUsa5LNnQLK76CGe0pGGugh6cqY/P3fAUaXn8i60QqfW1IDcIS6GmDZ3PP 9w== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkby48k0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:45 +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 32RGfia6022544 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:44 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.41; Mon, 27 Mar 2023 09:41:41 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v4 2/5] pinctrl: qcom: Use qcom_scm_io_update_field() Date: Mon, 27 Mar 2023 22:11:18 +0530 Message-ID: <1679935281-18445-3-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1679935281-18445-1-git-send-email-quic_mojha@quicinc.com> References: <1679935281-18445-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: c67uhQ2rKaZ0M1zzOviNmCLSK794sqLR X-Proofpoint-GUID: c67uhQ2rKaZ0M1zzOviNmCLSK794sqLR 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-27_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 spamscore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 mlxlogscore=693 mlxscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303270134 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?1761540246555388881?= X-GMAIL-MSGID: =?utf-8?q?1761540246555388881?= 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 Mon Mar 27 16:41:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 75574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1657918vqo; Mon, 27 Mar 2023 10:03:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZJOFh1huf92+wwZGyme4x2gVKpxckbKmSPq79mvut3Ce2PNb9olVF3vDrvA3PNSVWulgA6 X-Received: by 2002:a17:90b:350a:b0:23b:4388:7d8a with SMTP id ls10-20020a17090b350a00b0023b43887d8amr12720906pjb.21.1679936609554; Mon, 27 Mar 2023 10:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679936609; cv=none; d=google.com; s=arc-20160816; b=XQsk7maqx8UiA/YU1zbAugXEVDjszUN7E4Gx/ccJbqYsgYwly4e4fDJzqoJcmvNMGK h3JSriQtEeemuz8Ir3j7KoWSREfozl/mM/Cga9WR3mUDmCuPsfm3WR3//mzmgiYuT/jC nYEbEI19U4EemWhzcMQpabAF1NlZ1177Y0xFqJ3TPirBB/JqteTcurf7ciA9QNLJWZpe 7mkNUl6b3PIgycEU/B8kbNENm+bR1Ie42dqimoXSbGxvGcCLv3O/Z/BFxUGOK+basUCu J95H2jCzNV70H/AiKoPf/5SsXvO5ASVuDpgGHYNcQhYGsJbVPbTx0Ns8GLm7TmgPxjEH X5Jg== 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=WBWxgfw1drJhnxfAO2rN43QRoy939GS0Cvk3nm2plig=; b=Nn8/IEwat2q2JInbMuqxe8QInUFdPAUUVq2CQNySZu9J4y1G5UavaUd8qr93nL0EG1 Uo+HzkG8lS4ax+Batt1KgSPYZaq5D7QnjzVkLe6TA3SUXH2XryFOPJMbfnNdoKwM7lUt TOUnbv/XNyNsSDKpaSlU8d7aJnWJiAmCuyeWzUaHRGvMoD0YnPwFsaKdf9SjU9hUGe8Q zZ123aRsdGYfRM/wgJUzxx2VPZ5vWFd2pmtl0BDvBoAph+FulbLFDOBg0YYIVIAZQfew rMS01iat9A8xn6Fo4maPoZiBY43br/FRH8CG2XpoQ5wnU2G/u6ka7BawfT7xZvR3icQr V65g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZLtWQLMD; 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 r11-20020a170902e3cb00b001a05e6e4b23si26012749ple.266.2023.03.27.10.02.58; Mon, 27 Mar 2023 10:03:29 -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=ZLtWQLMD; 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 S232486AbjC0Qmd (ORCPT + 99 others); Mon, 27 Mar 2023 12:42:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232488AbjC0Qly (ORCPT ); Mon, 27 Mar 2023 12:41:54 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 646C4271E; Mon, 27 Mar 2023 09:41:51 -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 32RDv4BU015017; Mon, 27 Mar 2023 16:41:48 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=WBWxgfw1drJhnxfAO2rN43QRoy939GS0Cvk3nm2plig=; b=ZLtWQLMDnuE9j9VtCphYcvdC7H3nVVw23nBKbCghUt0+9Q7T0gIbji6UsRfsXQ2MAXNN 1Icmwg4oov1BtnJuT7pj9NSyzhq/6Gex1EorhVh+iJpAEfeWTMbOTP5uOOse6CGsohhD rWsO6nibtVNBIeYDumVtv5gNKQ3+sK3Q/EsC/Jq8D1EvUNi/cg6rlv8U92DS5NtAMnxz 4kzA7rD4LWiao40rdIu6n2Qkfcx6t8mMY8biq1Ohbzc4rIK9mVKj7Cnu+b4a6OdZmFLC 07M2DzPCcTht5kxbI/APIP1NgBoshdqj2VKjignOfrGOKIJG7YidoQsHhSG+NvoSTIdW lA== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkby48k0u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:48 +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 32RGfl1j022812 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:47 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.41; Mon, 27 Mar 2023 09:41:44 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha , Poovendhan Selvaraj Subject: [PATCH v4 3/5] firmware: scm: Modify only the download bits in TCSR register Date: Mon, 27 Mar 2023 22:11:19 +0530 Message-ID: <1679935281-18445-4-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1679935281-18445-1-git-send-email-quic_mojha@quicinc.com> References: <1679935281-18445-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: dL0mLgZziigV_OZ2r9BkioyTvvUzIk3W X-Proofpoint-GUID: dL0mLgZziigV_OZ2r9BkioyTvvUzIk3W 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-27_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 spamscore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303270134 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?1761541210218220460?= X-GMAIL-MSGID: =?utf-8?q?1761541210218220460?= 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 431fe1f..3c6c5e7 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 Mon Mar 27 16:41:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 75572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1655609vqo; Mon, 27 Mar 2023 10:01:05 -0700 (PDT) X-Google-Smtp-Source: AKy350YtSvDYlpWWh3uQKM1yFniqTAE+5HIBbSyphENaQdVu6hQ0x5MmDLzaRxclHJPws+IsY6oH X-Received: by 2002:a17:903:234a:b0:19d:f7e:9864 with SMTP id c10-20020a170903234a00b0019d0f7e9864mr14766226plh.57.1679936465008; Mon, 27 Mar 2023 10:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679936464; cv=none; d=google.com; s=arc-20160816; b=Blz8U6UX2kqk1a1ybR/BOa0CJY8gDoVVM7jSuGmXn1Zw1sd2kfe1Of65/KOF4SKrqX uGiJGiHFThrTOkz443fT3tyFyCqc7e7BrxaqLOxUrQJlW3nYJX2LUYwbk/1+d8/kgO9E JGKbaknsghpsmRuSNHiiQfHsMKKbZ6JzCLcUMIGd/JD92HJp/Bu78f9xD+ZMG3NJpyni u01EuSZUIaUJIsznl+gAErT2y+PR9NIg9i1yaaEC7wCWUdA/c5NenvOWP1AqtxOCdG4z DQtlnjYrd1RhzR6AoBpER/forZlQMKVxFqi27cgV3SNBT9xqMR0zuulOlSLG1wLcrMKG 2QIQ== 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=osDVzH0Z2u2znrt6uc6bcSp3r0ZEKNk0WazWpwQ/6L8=; b=M8E6lnXQMkyiaFswa8iFIc47FMLccKYRHs8B7Q8OIUVRp78PowENF8eo7zMP3z7Bvn LjxX+YgGHEDcQX/fFp4hPPXu/4kuXQE9JU7nBV/A8j6mo7AGgZ5oWJ+6iafTDAh2Yr+t imL934/rM7Q6lzNEIHdvkiO3xfXXuM4yEp7LCQ4n/DJxyW1TAyGR8dWytOszQcYqS4NW IZjjG5DMvN93xerZs/9Tg3N9pF55ulIRJJLE2ayDIVBHRDvNO62t6eVPp7y5F1E2i3rz 1Ssffup4wBYmN9l8PVl7IG/bjVEWT9/GHYTSbINdFpDvhcmd3rLOecv9/sdrWkbhtMre IuvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cFf3obJa; 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 21-20020a630d55000000b0050fa771219csi15676768pgn.510.2023.03.27.10.00.48; Mon, 27 Mar 2023 10:01:04 -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=cFf3obJa; 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 S232530AbjC0Qmg (ORCPT + 99 others); Mon, 27 Mar 2023 12:42:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232572AbjC0Ql7 (ORCPT ); Mon, 27 Mar 2023 12:41:59 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84EAE2715; Mon, 27 Mar 2023 09:41:55 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32RAG1tM018457; Mon, 27 Mar 2023 16:41:51 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=osDVzH0Z2u2znrt6uc6bcSp3r0ZEKNk0WazWpwQ/6L8=; b=cFf3obJaABPNKu5O8YQG7dECLCGaz6vX0gHg0ayY5LOyKNY2cduEif5iOtii0nPqmuUT 61dsFy4p0A8AqKyNlvbaYYQP4s4cKQvtPWKrgQRGv5ELdkPcB4WoGnGRbt3noXqc9E2B f8mhwiJtyie2dmJCFXkkWCmOZYIblfWSudfrAH61suvC/bR8N1R+2XUQL6Bcc1lbcCSD pLDjYCQY1K3A1nbEmb0pMuFdUr3Xj4/kVh1XSGWfNTdV8bWrNJLru5ZUgQyKegdnkUBk ZjnZWNmUZfyLU0t3OD9g8/pthY+mPotkNCie79ol36xzG/h7mv8Bu2HM/2oSOb0cTv2L Ag== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3phsqqn2ut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:51 +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 32RGfoQq014760 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:50 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.41; Mon, 27 Mar 2023 09:41:47 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v4 4/5] firmware: qcom_scm: Refactor code to support multiple download mode Date: Mon, 27 Mar 2023 22:11:20 +0530 Message-ID: <1679935281-18445-5-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1679935281-18445-1-git-send-email-quic_mojha@quicinc.com> References: <1679935281-18445-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: K51evE9NE7d5YkNIQWw2yDa6jBMSPdOS X-Proofpoint-ORIG-GUID: K51evE9NE7d5YkNIQWw2yDa6jBMSPdOS 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-27_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 clxscore=1015 mlxscore=0 spamscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303270134 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?1761541058929153361?= X-GMAIL-MSGID: =?utf-8?q?1761541058929153361?= 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 | 59 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 18 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 3c6c5e7..0c94429 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; @@ -453,7 +455,7 @@ static void qcom_scm_set_download_mode(bool 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); + enable ? download_mode : 0); } else { dev_err(__scm->dev, "No available mechanism for setting download mode\n"); @@ -1419,6 +1421,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("unknown download mode\n"); + 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 +1557,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 +1570,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 Mon Mar 27 16:41:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 75571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3404:b0:112:7285:5352 with SMTP id h4csp1555155rwd; Mon, 27 Mar 2023 09:53:42 -0700 (PDT) X-Google-Smtp-Source: AKy350bunOTrwoeqZb1Xi1nlYOWDcbvBufHbxFA4oMx38MIYp4qdnBG1qTPfaM7GOSTd2eJJTcIV X-Received: by 2002:a17:907:c292:b0:93f:9b1c:a45 with SMTP id tk18-20020a170907c29200b0093f9b1c0a45mr8369814ejc.35.1679936022304; Mon, 27 Mar 2023 09:53:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679936022; cv=none; d=google.com; s=arc-20160816; b=bC2OG9gV1JFqrXwsg0LPepApHeq83xLYEx2LP3wfc0wup5gQAAOOIfyHNANekCb2gk PDezh2C5aJC3uuGdva3WH0MRt5s8jlFTE8qA/omd7mrzOh//ibe1enBdH87kV2CaI1yW 847Ck1cLGrmGHqxdrVx8riBKxNszjkJMLt5rb/VGcmfF0kWLq2ZBs5IkACIV2CGgq/Wo vZYok2hTCq9oWuXgGUFDGRnK9zYCXr0wmvfq9vhQ5/mWPAjvoH9OaJHLaNyu5bUQq95Z z+NT3YETBYYuf6cKvTc+QcoblDnBqRuO5heqZdnMvouhLsQ24jdSnQmOy23QyOX/EhO5 qviw== 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=rdW3275cbw6qbQR0iizsgq/hJswZIcUGspaRgj6jMLk=; b=M/WnclzDyob5wzkrBEoglnmy15VRNyIFgVAuzn9vyOwaj/pAxx6fFselAkrW/yeiFM LQOLZ+9ajOUQxLXS/mBAIHkkWa8jwqZzU/LTF8cPatgbP+QRYXnMI9yqywBagCblHTHl bBaYSLkrBmrh3ZrrUdnJV4bHT5Gix0q3HpLan3ejw7294HcwlQ8QXutpDC0sJAoCVGy2 wjgy8U6hAl1ZZ78ntyCn7qRvVwaPXtDzWlGwPrc3WVFw7zzmJC0yxZwDOUAZFoOiPX8A B5l7y41Hsyx8RhII7wUXtNcvPg+5nt46cG56Qkt0U2tBb2FD20Blr6DY6ckm1kfoq0Co jknA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JaS0orVP; 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 y8-20020a17090614c800b009334d9758c6si22158350ejc.66.2023.03.27.09.53.19; Mon, 27 Mar 2023 09:53:42 -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=JaS0orVP; 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 S232454AbjC0Qmb (ORCPT + 99 others); Mon, 27 Mar 2023 12:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232618AbjC0QmD (ORCPT ); Mon, 27 Mar 2023 12:42:03 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF99A3A8C; Mon, 27 Mar 2023 09:41:58 -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 32RE6Bgf019036; Mon, 27 Mar 2023 16:41:54 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=rdW3275cbw6qbQR0iizsgq/hJswZIcUGspaRgj6jMLk=; b=JaS0orVPRDkP93z0JaL9efVuYSQ6NSU5xqZxMz+mdZQl+EQpdrwukzfQpHAyUvMpQ2yz D9ZLhbdFc7wrGazWluHXarB1v3FRij4LI5e96vJqiWd988mS4W6m5Swx1UKokVz2c2oq sCnTNiDLR5KZkFH+lYWY4KTEsBgLHdv8agPrSjgv3bzeQxIUqUtt14exky4a5Jy2R66J ckRcqjHKDinJrhexU7j4gVgufTIM7Itt5vjhPkZnlEBPWrKoQxv/7N1Fag99HarVud56 uq/tnPtFT4ZTHQzBjrDltHHL9S8hCOrR8/fY/dqce+U8QJzgVx/+tgDxQJOJoD285VRL /A== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pkcm2rg4h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:54 +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 32RGfrHX022663 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 16:41:53 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.41; Mon, 27 Mar 2023 09:41:50 -0700 From: Mukesh Ojha To: , , , CC: , , , Mukesh Ojha Subject: [PATCH v4 5/5] firmware: qcom_scm: Add multiple download mode support Date: Mon, 27 Mar 2023 22:11:21 +0530 Message-ID: <1679935281-18445-6-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1679935281-18445-1-git-send-email-quic_mojha@quicinc.com> References: <1679935281-18445-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: BPRsb3e66BsdNY7tW2-pp1CxjgSMXdre X-Proofpoint-GUID: BPRsb3e66BsdNY7tW2-pp1CxjgSMXdre 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-27_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 suspectscore=0 spamscore=0 clxscore=1015 impostorscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303270134 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?1761540594247604351?= X-GMAIL-MSGID: =?utf-8?q?1761540594247604351?= Currently, scm driver only supports full dump when download mode is selected. Add support to enable minidump as well both dump(full dump + minidump). Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom_scm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 0c94429..19315d0 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 { @@ -1421,13 +1423,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, "both\n"); else if (download_mode == QCOM_DOWNLOAD_NODUMP) len = sysfs_emit(buffer, "off\n"); @@ -1440,6 +1445,10 @@ static int set_download_mode(const char *val, const struct kernel_param *kp) 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, "both", strlen("both"))) { + download_mode = QCOM_DOWNLOAD_BOTHDUMP; } else if (!strncmp(val, "off", strlen("off"))) { download_mode = QCOM_DOWNLOAD_NODUMP; } else if (kstrtouint(val, 0, &download_mode) || @@ -1462,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/both(full+mini) or 0/1 for existing users"); static int qcom_scm_probe(struct platform_device *pdev) {