From patchwork Wed Dec 14 04:06:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 33044 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp526865wrn; Tue, 13 Dec 2022 20:10:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf6DdvRoc6pTWFAwcRBUFzD1wwSOWKRFQimdwrqQZICQvm91DtNiHQrLiWCgsx/VNLmivCWW X-Received: by 2002:a05:6a20:93a3:b0:ad:a277:eeee with SMTP id x35-20020a056a2093a300b000ada277eeeemr12479026pzh.45.1670991037989; Tue, 13 Dec 2022 20:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670991037; cv=none; d=google.com; s=arc-20160816; b=YGxiE0/tHZQo7C1U8F9DADe2CEfNcbMml0TtOZW1pJOKpYXdZy/Cs06L1TeKVPxryB rsvaai9RJlUsqYthjpzXn8rDorXrGHNle7q5euhE1ukhrJi3Z0RkOq8ZKNA8wcPvVk4A TluHmWz6WYd2L6C21nSZQUUbO0apzbLaauY5TIo5kG5SuQuRDqL3lhpaAXUWVW5lWuGa yqC/HhnLv8cEsYSIVkAoJ33uGr/sAnjeANOtdDrsbCpyFDgwVpaEqKyyyzbnqgEYYeQk sqkadsAJfC5yRh3T915z9H4OqUmiOhlbCm93hFGA87bXPa7s5m988FPd96oe7nV6tpnX LZ3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=+QGfhuusRgaYAJxvaVImjvCkuiYU+EOv+jzC4ezRLZQ=; b=i3LPh7Flr9RXt8LCIvBh9Y4dx3r94nzd4ptBdNS7qD3tcJDXQ6ENJsqtJN4qd+fL1e iIagvURNABOu9128XvFBEET03etlN7xy2nwTciTP6zibSzE6VlaQUuUiO/7NhsAz+cRi uAmDCAixwEoqCRUuc/KhUvqpGLWCE3ZZMy9n5zl8JJ0PnoRtegxNMRtkQpJwqh3eIV8S vUEltQPdeMnb4yOQpvvnN3g+Mopd8OK3jPP2nCvmzxFKZuyCG+RCmB3cm35Jnu0eG8Oc 20JhKF8V569T/eEm1EuRwL5V+Yzox52khpmrGxVdbNR42CEZNd4Z6vz6Ieqt5eRobHCc 1DRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Schtrp9T; 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 u20-20020a634714000000b0047839ae135csi13992207pga.434.2022.12.13.20.09.59; Tue, 13 Dec 2022 20:10:37 -0800 (PST) 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=Schtrp9T; 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 S229694AbiLNEIz (ORCPT + 99 others); Tue, 13 Dec 2022 23:08:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237451AbiLNEIn (ORCPT ); Tue, 13 Dec 2022 23:08:43 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9BB6D2ED; Tue, 13 Dec 2022 20:08:41 -0800 (PST) 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 2BE3oJmv026035; Wed, 14 Dec 2022 04:08:20 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; s=qcppdkim1; bh=+QGfhuusRgaYAJxvaVImjvCkuiYU+EOv+jzC4ezRLZQ=; b=Schtrp9TcSO9NQaT5PKpnsrgQTE4zdX5B5NXIZZ66GW0oDRSCr5X0VHVgRfkglLL16r3 wfjYOrb2BOSkSLk1nGqh4leoq436K0fZBx9zGX9q6U/B+/dNWbda++m7SzcmQjZ3SUB4 XV3LDGIuA680EvjtO3gmmOkoiwqGDGV6FaCb6zQ8FvbqOh8QDoHBDzPmftejQ8kKZ88I cGjXVdeubIBKcpnKs6iqQrSc/4XZ+xvC1aYa67Tlkz0XH89LClJT6S9EFVuYDLs5sNfU /4A/YvMxfg76TiyVVymDuswnZ410rBfOE3HJ36mYY2zNnxaW4ZAbGtjlpVvuI6iXiKuE Lg== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mf6rkg1e8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 04:08:20 +0000 Received: from pps.filterd (NASANPPMTA04.qualcomm.com [127.0.0.1]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 2BE48JEU024461; Wed, 14 Dec 2022 04:08:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA04.qualcomm.com (PPS) with ESMTP id 3mck6m3hc1-1; Wed, 14 Dec 2022 04:08:19 +0000 Received: from NASANPPMTA04.qualcomm.com (NASANPPMTA04.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2BE45uWa019716; Wed, 14 Dec 2022 04:08:18 GMT Received: from stor-presley.qualcomm.com (wsp769891wss.qualcomm.com [192.168.140.85] (may be forged)) by NASANPPMTA04.qualcomm.com (PPS) with ESMTP id 2BE48Il3024455; Wed, 14 Dec 2022 04:08:18 +0000 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 9CB1A20DF0; Tue, 13 Dec 2022 20:08:18 -0800 (PST) From: Can Guo To: quic_asutoshd@quicinc.com, bvanassche@acm.org, mani@kernel.org, stanley.chu@mediatek.com, adrian.hunter@intel.com, beanhuo@micron.com, avri.altman@wdc.com, junwoo80.lee@samsung.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, Can Guo , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , Arthur Simchaev , Yoshihiro Shimoda , Keoseong Park , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 1/3] ufs: core: Add Event Specific Interrupt configuration vendor specific ops Date: Tue, 13 Dec 2022 20:06:00 -0800 Message-Id: <1670990763-30806-2-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1670990763-30806-1-git-send-email-quic_cang@quicinc.com> References: <1670990763-30806-1-git-send-email-quic_cang@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: _9zkmuENL6K-W9XUQwD48HH-eZ09j8_F X-Proofpoint-GUID: _9zkmuENL6K-W9XUQwD48HH-eZ09j8_F X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-14_01,2022-12-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 clxscore=1011 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 impostorscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212140031 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE, SPF_NONE autolearn=no 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?1752161098847942243?= X-GMAIL-MSGID: =?utf-8?q?1752161098847942243?= As Event Specific Interrupt message format is not defined in UFSHCI JEDEC specs, and the ESI handling highly depends on how the format is designed, hence add a vendor specific ops such that SoC vendors can configure their own ESI handlers. If ESI vops is not provided or returning error, go with the legacy (central) interrupt way. Signed-off-by: Can Guo --- drivers/ufs/core/ufshcd-priv.h | 8 ++++++++ drivers/ufs/core/ufshcd.c | 5 +++++ include/ufs/ufshcd.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index ff03aa5..802029e 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -276,6 +276,14 @@ static inline int ufshcd_vops_get_outstanding_cqs(struct ufs_hba *hba, return -EOPNOTSUPP; } +static inline int ufshcd_mcq_vops_config_esi(struct ufs_hba *hba) +{ + if (hba->vops && hba->vops->config_esi) + return hba->vops->config_esi(hba); + + return -EOPNOTSUPP; +} + extern const struct ufs_pm_lvl_states ufs_pm_lvl_states[]; /** diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index e9d6891..3762dca 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8375,6 +8375,11 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba) static void ufshcd_config_mcq(struct ufs_hba *hba) { + int ret; + + ret = ufshcd_mcq_vops_config_esi(hba); + dev_info(hba->dev, "ESI %sconfigured\n", ret ? "is not " : ""); + ufshcd_enable_intr(hba, UFSHCD_ENABLE_MCQ_INTRS); ufshcd_mcq_make_queues_operational(hba); ufshcd_mcq_config_mac(hba, hba->nutrs); diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index f20557b..7f0139b 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -302,6 +302,7 @@ struct ufs_pwr_mode_info { * @get_hba_mac: called to get vendor specific mac value, mandatory for mcq mode * @op_runtime_config: called to config Operation and runtime regs Pointers * @get_outstanding_cqs: called to get outstanding completion queues + * @config_esi: called to config Event Specific Interrupt */ struct ufs_hba_variant_ops { const char *name; @@ -345,6 +346,7 @@ struct ufs_hba_variant_ops { int (*op_runtime_config)(struct ufs_hba *hba); int (*get_outstanding_cqs)(struct ufs_hba *hba, unsigned long *ocqs); + int (*config_esi)(struct ufs_hba *hba); }; /* clock gating state */ From patchwork Wed Dec 14 04:06:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 33046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp526931wrn; Tue, 13 Dec 2022 20:10:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf6tu5TKVG/HzoGNEWLnzzFghkNyEWBWYYnrXBmdLxjEryNp2ep7KVzH9r/i+iBgQewSm9Ih X-Received: by 2002:a17:906:f247:b0:7c1:7669:629 with SMTP id gy7-20020a170906f24700b007c176690629mr8670523ejb.49.1670991048678; Tue, 13 Dec 2022 20:10:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670991048; cv=none; d=google.com; s=arc-20160816; b=es+mQlL5YW14Vbm7gdqTo4wHFEAF0yQ3hAAQ3HjTgtvGtXShVDNK5bWj8A/LYZXr/4 pFCQJGot/jSIkOYUid/Jn+ZybnymMmzMY64fWKU2uqWBHnTfoVJiyQGqSs6hRI9Sg5Gt wOGhjeGOPc0h2CtoVUdchHMdTKQmbpGqNXLwxCAifolpYOPbrY2ExVV/hiNH+mRdjMKX rXWkpLc+KqYf9uHYDBBpUXpC5uQ6EKFMQbuQngIDwfbk249J+jEMr5lXLlN8lebeeRns 2oJy8TOyo7jJkZXUOmrk/gh41vYr83pyHjD8w0j/Za3M7S1Tz0KypyCQf+XXUXXpqDxS bing== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=XrQ5Jw89llK1p/7+oyj2VSzcXyF2nqgQKJ4Q9FtdaLA=; b=vDUlTDayLDoA+VTEA+io2e1i6ObECB3n7f+TPHTp3z39DnmknqsmxXxvEsj9vivERL 1HpO4C/9lvR80KR9gFvf9MzEsf2AuMmxPy9V5F8qdsiH7rYP6Ecp5OWhdoBCd8WXb3aL JLRXJwlfIjmTe6H9SO5vld8aBX1RMuDSVFiheT0yQznKbPkpTwNMwUvcBsA7L8rZ3s+d O/0j367YWMf6d2Nk3Y28cfgu4gxqbg7KKR3di64Mzu642pYtofGO//iv4B+bgUYhjCak nMnOM471EU23T9Fq0ZJlrspGQl+TZ38fL5tdJZsgeskJ1yoQ1BSBNn1fiOqeavqeKJ0i yLew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="fKa/kBgM"; 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 sb22-20020a1709076d9600b007c179af6e14si5400876ejc.961.2022.12.13.20.10.26; Tue, 13 Dec 2022 20:10:48 -0800 (PST) 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="fKa/kBgM"; 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 S237506AbiLNEJj (ORCPT + 99 others); Tue, 13 Dec 2022 23:09:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237317AbiLNEJT (ORCPT ); Tue, 13 Dec 2022 23:09:19 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E262227B3D; Tue, 13 Dec 2022 20:08:55 -0800 (PST) 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 2BE46i5u031286; Wed, 14 Dec 2022 04:08:39 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; s=qcppdkim1; bh=XrQ5Jw89llK1p/7+oyj2VSzcXyF2nqgQKJ4Q9FtdaLA=; b=fKa/kBgMB8l6sfypDsBtj4eMwRGPTjsffS7db0pUMpWwwHVjaQA66tkqt2bCkFnAHO8I aTU4ukMwzsNIdL1pqAuX8tpeH2BYAEDU0yCWfarWppyjM0LodbaUqGMKqayAgHJwtKUK bfXpL6GQsJjxVaTkdBEWUAxxS/t9AmB5R2dCGSaMXLhcZIsIW9JSBrcsvFVtbvyUCUN8 E5h+MRLHHZPGI3xCsJ7pQoHJ6JmX1tIzIPmkeATF6u2govHLBLjMShxkzd/dmzCegvIB yRnCwwZB/14asJVdwEHOsdPykTy9y57lAnHomrVkhKNa038zx4KMoKjsuO13FfADbd7P HA== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mf6rkg1bs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 04:08:38 +0000 Received: from pps.filterd (NASANPPMTA04.qualcomm.com [127.0.0.1]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 2BE46xTB022230; Wed, 14 Dec 2022 04:08:37 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA04.qualcomm.com (PPS) with ESMTP id 3mck6m3hcr-1; Wed, 14 Dec 2022 04:08:37 +0000 Received: from NASANPPMTA04.qualcomm.com (NASANPPMTA04.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2BE48bwg024555; Wed, 14 Dec 2022 04:08:37 GMT Received: from stor-presley.qualcomm.com (wsp769891wss.qualcomm.com [192.168.140.85] (may be forged)) by NASANPPMTA04.qualcomm.com (PPS) with ESMTP id 2BE48bQQ024551; Wed, 14 Dec 2022 04:08:37 +0000 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 3194320DF0; Tue, 13 Dec 2022 20:08:37 -0800 (PST) From: Can Guo To: quic_asutoshd@quicinc.com, bvanassche@acm.org, mani@kernel.org, stanley.chu@mediatek.com, adrian.hunter@intel.com, beanhuo@micron.com, avri.altman@wdc.com, junwoo80.lee@samsung.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, Can Guo , Alim Akhtar , "James E.J. Bottomley" , Yoshihiro Shimoda , Kiwoong Kim , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 2/3] ufs: core: mcq: Add Event Specific Interrupt enable and config APIs Date: Tue, 13 Dec 2022 20:06:01 -0800 Message-Id: <1670990763-30806-3-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1670990763-30806-1-git-send-email-quic_cang@quicinc.com> References: <1670990763-30806-1-git-send-email-quic_cang@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: eLnFj10qD-nFBoUA4aPGtXriOe52caZb X-Proofpoint-ORIG-GUID: eLnFj10qD-nFBoUA4aPGtXriOe52caZb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-14_01,2022-12-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212140031 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE, SPF_NONE autolearn=no 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?1752161109477153946?= X-GMAIL-MSGID: =?utf-8?q?1752161109477153946?= Add two APIs to enable ESI and config ESI base addresses. Signed-off-by: Can Guo --- drivers/ufs/core/ufs-mcq.c | 16 ++++++++++++++++ include/ufs/ufshcd.h | 6 ++++++ include/ufs/ufshci.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index f99c912..c81e424 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -246,6 +246,7 @@ void ufshcd_mcq_write_cqis(struct ufs_hba *hba, u32 val, int i) { writel(val, mcq_opr_base(hba, OPR_CQIS, i) + REG_CQIS); } +EXPORT_SYMBOL_GPL(ufshcd_mcq_write_cqis); /* * Current MCQ specification doesn't provide a Task Tag or its equivalent in @@ -293,6 +294,7 @@ unsigned long ufshcd_mcq_poll_cqe_nolock(struct ufs_hba *hba, return completed_reqs; } +EXPORT_SYMBOL_GPL(ufshcd_mcq_poll_cqe_nolock); unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba, struct ufs_hw_queue *hwq) @@ -370,6 +372,20 @@ void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba) } } +void ufshcd_mcq_enable_esi(struct ufs_hba *hba) +{ + ufshcd_writel(hba, ufshcd_readl(hba, REG_UFS_MEM_CFG) | 0x2, + REG_UFS_MEM_CFG); +} +EXPORT_SYMBOL_GPL(ufshcd_mcq_enable_esi); + +void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg) +{ + ufshcd_writel(hba, msg->address_lo, REG_UFS_ESILBA); + ufshcd_writel(hba, msg->address_hi, REG_UFS_ESIUBA); +} +EXPORT_SYMBOL_GPL(ufshcd_mcq_config_esi); + int ufshcd_mcq_init(struct ufs_hba *hba) { struct Scsi_Host *host = hba->host; diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 7f0139b..660ccd3 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1201,6 +1202,11 @@ void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk); void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val); void ufshcd_hba_stop(struct ufs_hba *hba); void ufshcd_schedule_eh_work(struct ufs_hba *hba); +void ufshcd_mcq_write_cqis(struct ufs_hba *hba, u32 val, int i); +unsigned long ufshcd_mcq_poll_cqe_nolock(struct ufs_hba *hba, + struct ufs_hw_queue *hwq); +void ufshcd_mcq_enable_esi(struct ufs_hba *hba); +void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg); /** * ufshcd_set_variant - set variant specific data to the hba diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h index 1df8425..9b74194 100644 --- a/include/ufs/ufshci.h +++ b/include/ufs/ufshci.h @@ -59,6 +59,8 @@ enum { REG_UFS_MEM_CFG = 0x300, REG_UFS_MCQ_CFG = 0x380, + REG_UFS_ESILBA = 0x384, + REG_UFS_ESIUBA = 0x388, UFSHCI_CRYPTO_REG_SPACE_SIZE = 0x400, }; From patchwork Wed Dec 14 04:06:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 33045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp526875wrn; Tue, 13 Dec 2022 20:10:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5sJWzv4HVYlkTEvHkE8JH1ZUyJ+ErWbd64nvGBgLaoRNfj8/mmGrOixyRZwzPsL0WAGYqg X-Received: by 2002:a17:907:9866:b0:7c1:9e6:d38e with SMTP id ko6-20020a170907986600b007c109e6d38emr20332818ejc.67.1670991039790; Tue, 13 Dec 2022 20:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670991039; cv=none; d=google.com; s=arc-20160816; b=k9fiYjFBF5qlO5BzxqcJiooDup6cgM9d5+ngpSsRyOsmQwm9j0UfVZZWJ2klHRcyxt 3TqyizFkpYJJNlRHU+vwqlSNZOAEtq0BqShVjvvB+x6esmHx9rAeqy/8Dj4D9nbK1QMt qjBlGkGdLq2q2krgSwtfLu6frd9H2S0SCBSYt4XuL5e3t8LJ+CyMFN/VEYDjoYMChUtd lxtIdveOr5mW4JvRXSkMk2wwYpQosGqfseoFdgAEqc6cFqoDnznDIyQoUbgprWJcxq+Z Ji2FHfMORvKqM56ImXGhVJst8dx50KoOfR85T+447HdWUIhYnV09W96DRqAtLoUGq6+H kdSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=oIXeANiSO2xeKVP26joYA3LvkoR6iSGiERvirdV0NJg=; b=M98qiMJSTGH6iXpJDm7XehVyDqd8tIL+sFZEJ+dnQvV9Jrbwpb6+QWPJV/uBS5QKYQ xOJsS1ZIzSIqc3dTtA3NczNffNLgfRajF134UgQ3zSqeRvOOUcwAk0Wg/ApVATCPzWri VR9cP9dNBZKhnsWp6wfIEtncC8RcLM0uVJUpaK++HdNtR1oePwSM5uZvMZWrFvXtICjC kqoQMOOSNHpTfbeNXGmENWOl1GsQ/B2U1knSV3mgV3NIOCRAcvByLqj9hLP88v4X2FB6 9GhAUOVR1fgyJmwa9HPb0CzX2Wkwv5TxrQ7+2sISwl0wz+KgVmVb/LJeJvfZg7RHF+0S iXdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=lZ7JKHYb; 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 i10-20020a1709064fca00b007ad2d85d753si11169348ejw.495.2022.12.13.20.09.51; Tue, 13 Dec 2022 20:10:39 -0800 (PST) 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=qcdkim header.b=lZ7JKHYb; 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 S236626AbiLNEIt (ORCPT + 99 others); Tue, 13 Dec 2022 23:08:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237402AbiLNEIk (ORCPT ); Tue, 13 Dec 2022 23:08:40 -0500 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80825DF21; Tue, 13 Dec 2022 20:08:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1670990919; x=1702526919; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=oIXeANiSO2xeKVP26joYA3LvkoR6iSGiERvirdV0NJg=; b=lZ7JKHYbIzZWJR09PfDXCQHVi6nsjGaZDpd3duezEc/jK5Xyf8Y3ZWHb DxECvZJ1R/F8UD7nlvWwBNXPWCiJDLHtS1Y7kpvwVDL68MOCdYv7K1VSJ 12v7X650uBEDSuTfNbUjVTc/55zrqJ9RuXJV3Nz6vS+bo5uPEns0koLkv s=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 13 Dec 2022 20:08:38 -0800 X-QCInternal: smtphost Received: from wsp769891wss.qualcomm.com (HELO stor-presley.qualcomm.com) ([192.168.140.85]) by ironmsg04-sd.qualcomm.com with ESMTP; 13 Dec 2022 20:08:37 -0800 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id BCD4C20DF0; Tue, 13 Dec 2022 20:08:37 -0800 (PST) From: Can Guo To: quic_asutoshd@quicinc.com, bvanassche@acm.org, mani@kernel.org, stanley.chu@mediatek.com, adrian.hunter@intel.com, beanhuo@micron.com, avri.altman@wdc.com, junwoo80.lee@samsung.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, Can Guo , Andy Gross , Bjorn Andersson , Konrad Dybcio , "James E.J. Bottomley" , linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM SUPPORT), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 3/3] ufs-host: qcom: Add MCQ ESI config vendor specific ops Date: Tue, 13 Dec 2022 20:06:02 -0800 Message-Id: <1670990763-30806-4-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1670990763-30806-1-git-send-email-quic_cang@quicinc.com> References: <1670990763-30806-1-git-send-email-quic_cang@quicinc.com> X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham 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?1752161100278188109?= X-GMAIL-MSGID: =?utf-8?q?1752161100278188109?= Add MCQ ESI config vendor specific ops. Co-developed-by: Asutosh Das Signed-off-by: Asutosh Das Signed-off-by: Can Guo --- drivers/ufs/host/ufs-qcom.c | 97 +++++++++++++++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-qcom.h | 5 +++ 2 files changed, 102 insertions(+) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 96a58b4..ea5b5f7 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1568,6 +1568,101 @@ static int ufs_qcom_get_outstanding_cqs(struct ufs_hba *hba, return 0; } +#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +static void ufs_qcom_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) +{ + struct device *dev = msi_desc_to_dev(desc); + struct ufs_hba *hba = dev_get_drvdata(dev); + + ufshcd_mcq_config_esi(hba, msg); +} + +static irqreturn_t ufs_qcom_mcq_esi_handler(int irq, void *__hba) +{ + struct ufs_hba *hba = __hba; + struct ufs_qcom_host *host = ufshcd_get_variant(hba); + u32 id = irq - host->esi_base; + struct ufs_hw_queue *hwq = &hba->uhq[id]; + + ufshcd_mcq_write_cqis(hba, 0x1, id); + ufshcd_mcq_poll_cqe_nolock(hba, hwq); + + return IRQ_HANDLED; +} + +static int ufs_qcom_config_esi(struct ufs_hba *hba) +{ + struct ufs_qcom_host *host = ufshcd_get_variant(hba); + struct msi_desc *desc; + struct msi_desc *failed_desc = NULL; + int nr_irqs, ret; + + if (host->esi_enabled) + return 0; + else if (host->esi_base < 0) + return -EINVAL; + + /* + * 1. We only handle CQs as of now. + * 2. Poll queues do not need ESI. + */ + nr_irqs = hba->nr_hw_queues - hba->nr_queues[HCTX_TYPE_POLL]; + ret = platform_msi_domain_alloc_irqs(hba->dev, nr_irqs, + ufs_qcom_write_msi_msg); + if (ret) + goto out; + + msi_for_each_desc(desc, hba->dev, MSI_DESC_ALL) { + if (!desc->msi_index) + host->esi_base = desc->irq; + + ret = devm_request_irq(hba->dev, desc->irq, + ufs_qcom_mcq_esi_handler, + IRQF_SHARED, "qcom-mcq-esi", hba); + if (ret) { + dev_err(hba->dev, "%s: Fail to request IRQ for %d, err = %d\n", + __func__, desc->irq, ret); + failed_desc = desc; + break; + } + } + + if (ret) { + /* Rewind */ + msi_for_each_desc(desc, hba->dev, MSI_DESC_ALL) { + if (desc == failed_desc) + break; + devm_free_irq(hba->dev, desc->irq, hba); + } + platform_msi_domain_free_irqs(hba->dev); + } else { + if (host->hw_ver.major == 6 && host->hw_ver.minor == 0 && + host->hw_ver.step == 0) { + ufshcd_writel(hba, + ufshcd_readl(hba, REG_UFS_CFG3) | 0x1F000, + REG_UFS_CFG3); + } + ufshcd_mcq_enable_esi(hba); + } + +out: + if (ret) { + host->esi_base = -1; + dev_warn(hba->dev, "Failed to request Platform MSI %d\n", ret); + } else { + host->esi_enabled = true; + } + + return ret; +} + +#else +static int ufs_qcom_config_esi(struct ufs_hba *hba) +{ + return -EOPNOTSUPP; +} +#endif + /* * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations * @@ -1595,6 +1690,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .get_hba_mac = ufs_qcom_get_hba_mac, .op_runtime_config = ufs_qcom_op_runtime_config, .get_outstanding_cqs = ufs_qcom_get_outstanding_cqs, + .config_esi = ufs_qcom_config_esi, }; /** @@ -1628,6 +1724,7 @@ static int ufs_qcom_remove(struct platform_device *pdev) pm_runtime_get_sync(&(pdev)->dev); ufshcd_remove(hba); + platform_msi_domain_free_irqs(hba->dev); return 0; } diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index 6912bdf..7937b41 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -54,6 +54,8 @@ enum { * added in HW Version 3.0.0 */ UFS_AH8_CFG = 0xFC, + + REG_UFS_CFG3 = 0x271C, }; /* QCOM UFS host controller vendor specific debug registers */ @@ -226,6 +228,9 @@ struct ufs_qcom_host { struct reset_controller_dev rcdev; struct gpio_desc *device_reset; + + int esi_base; + bool esi_enabled; }; static inline u32