From patchwork Fri Dec 2 08:15:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 28768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp714002wrr; Fri, 2 Dec 2022 00:27:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7BCWxBJaWgUhXUAmjhe0/yhz9xkGcdzHbkCNWm9fOtnetnnFbDqLhbFWRjahVT2oDwi6M/ X-Received: by 2002:a05:6402:114c:b0:457:35d4:ac66 with SMTP id g12-20020a056402114c00b0045735d4ac66mr5165654edw.415.1669969676394; Fri, 02 Dec 2022 00:27:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669969676; cv=none; d=google.com; s=arc-20160816; b=x1MTW6DHEYOlWSrHvZxYmOUKKEgxFU3pRg3+XSi5CJedqOaIqkYak09qftCXrPAFSl 70LmJfQnXbA6Bul7fzRL0QznpyKNn7qpsuqJ0jfAPtu9ZQrscAqxCOtZZpNkn1xZVoX9 2+tcwNk9V5hHJk8kF79hIKuTSf+ZFWytduaoHhY1cILVF7SrRFrDigBGAdkZj83JZi3L PmNCAXHInb9yG+h7nrJgvurDgSMkVTKnN0RyZQGkCQ1LnP9wN7o9n4K0/nVK7JSRSG1V rJOH0KzXMnt7jL3u8EBia4oDOQPpAZcw/dI2VO9awRf4qsaJ0lnGReqfBNsoEvkvO7qZ Dtfg== 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=bqlmWmuWwDlEiAfu4tj0y45q3AZFfaCcixQBG3PM2Zs=; b=sfK+r7gV336LZyT3EuLKg7cvlHgaJoT2R/JMFXVc62jSW8ejxKQDVly9OHVqYyrG+z vIDE7ZHtlYSglaNVg4Euunhl1FFN3LSfpTXqdT86B5UG4GA/P9AOayysXV/01GUCMmsL 0zsmXzcatSEHZbWGcHR9rlVGES/lUcHf/u3HVtkhysBWF4a2s03geLqe1/6Jj4mnvBFA KzspkZB6CvP0S/Qw5Ef4ZSXYIQj/HRGTYiwZe4zCkGZUDKq6kydqgqNuC3Vt5vmz4B0+ BYjNFT0rYNnGFca2AatMRjhNEE4YKv3p7A1XXVV3q1NXRaqjeWujOoJO1yPdpuCucim0 fNMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SaGnE8Fe; 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 ka7-20020a170907990700b007aedb84056csi4516847ejc.718.2022.12.02.00.27.32; Fri, 02 Dec 2022 00:27:56 -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=SaGnE8Fe; 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 S232733AbiLBISq (ORCPT + 99 others); Fri, 2 Dec 2022 03:18:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232746AbiLBIS3 (ORCPT ); Fri, 2 Dec 2022 03:18:29 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77C792B263; Fri, 2 Dec 2022 00:16:49 -0800 (PST) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B28E6fu021178; Fri, 2 Dec 2022 08:16:35 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=bqlmWmuWwDlEiAfu4tj0y45q3AZFfaCcixQBG3PM2Zs=; b=SaGnE8Fe+4o5Xi3S4SP9vA1qeEMbPIh4jS3LR93NY/TvEdNUMzue6Vmu1MC/jtykQ3l4 XJ4siNxWAt9NyPPFAa8ArRaRPl7zIzxtakpHZi+jGwjITHQSzz0cUC00S7zknF5UNxpw V3w1/m7Oh5aP3th+9WMV67NHQlqQLde+2eQWYGgcUTHRYEBki82NXxBgRdG/O+dbAF44 SC5KflaQeLMAmITATGQ+cZdXZe6DIbC3kg/NQCExd2aIJsn2F/HXXS79rQRjL9D0JKC3 o34KzgbdnjuOEx98PGjEzHsT/a3A99Nezm4cKiltUtimETrbeEgGTexR97DbvLcbVZjg aw== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m6k5td6yk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Dec 2022 08:16:35 +0000 Received: from pps.filterd (NASANPPMTA03.qualcomm.com [127.0.0.1]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 2B28C0M7019033; Fri, 2 Dec 2022 08:16:34 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 3m6j6ucj1x-1; Fri, 02 Dec 2022 08:16:34 +0000 Received: from NASANPPMTA03.qualcomm.com (NASANPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2B28GYPC029328; Fri, 2 Dec 2022 08:16:34 GMT Received: from stor-presley.qualcomm.com (stor-presley.qualcomm.com [192.168.140.85]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 2B28GXUK029323; Fri, 02 Dec 2022 08:16:34 +0000 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id D438720DAF; Fri, 2 Dec 2022 00:16:33 -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 , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/3] ufs: core: Add Event Specific Interrupt configuration vendor specific ops Date: Fri, 2 Dec 2022 00:15:05 -0800 Message-Id: <1669968909-33021-2-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1669968909-33021-1-git-send-email-quic_cang@quicinc.com> References: <1669968909-33021-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: _YiaBnl3JcAaexnvs1aSjttgfjE2DE7N X-Proofpoint-ORIG-GUID: _YiaBnl3JcAaexnvs1aSjttgfjE2DE7N X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-02_04,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 clxscore=1011 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212020062 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,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?1751090123323666503?= X-GMAIL-MSGID: =?utf-8?q?1751090123323666503?= 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 Fri Dec 2 08:15:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 28766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp713756wrr; Fri, 2 Dec 2022 00:26:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf5eyTz8ABphRSJ3uLjnYNH8hkQiTif1DMQllWJOvXETBt7hurFOpu33Ws1VxVDNtS1X/nrX X-Received: by 2002:aa7:c6da:0:b0:469:172:1f38 with SMTP id b26-20020aa7c6da000000b0046901721f38mr61610297eds.195.1669969619244; Fri, 02 Dec 2022 00:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669969619; cv=none; d=google.com; s=arc-20160816; b=OOA6QWx4TuF75Lk7u1Ba3n3YbMxJi08+z542znBtSlgOyIpfJ6QI10RpkdX5yA+t9H Sm17P6c/pfXncz2S8i16aCqyZUs4hTEi/KlcreJd1M3fdCKIUqZ6aP5aY0ilQizvyX08 54nCvKb7qZqEqp2CoI9z35g6xIdVyY4dF5e5eYpoZToe7o21lUGjSoD5YU/cG1ZLPomz wCrsyCav7Dkp22J2EXxcjdeBXFuVBpkHVG7YcUCdakKRGrrdilYPiqXMS2ZPslUnLMzt gsFM+4Y37GXBR1wyaIfLolekpBXRxLPfeS7jMj+oVy1ZPJa7+pRm2ez8nRdEU4gnCtmb RyJw== 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=dy9XbWkrjC5fa2DzU1vqdWwDxq4XYdcaigLaGuV9cT4=; b=Qd5GWV8q/SjK8tTN4K/WlHQfOXyVDhsjFVLHSwgA+X1nGDNfj2SUo8Nti76mdLjd21 Yo+LtUmzsbw5/n9cZU84jpOYDnI//acQboLAGi/56F3OQVeO34JZBtF0r3/zJOoX1X/o Nn5cJPEn3AjMONF8gsnGpsX6hGAfT3EZSUuaMd+NvotJC5Uhp4Wm8TaB0/4NDvI6NRn3 1CgzokcIKABXae0jmoeCTK8x8g1MNZLgkYI13z5vWov6ueqQiyuUNwIzj/EH9HAYR9gJ G80Ihtf7Q2nSveadwg4xS68ZxI80TCXF14aGQN+vxKfEfPvoox1lScxQ66sb0+VNPq6K QAPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=go1LazcQ; 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 di5-20020a170906730500b00770872942d8si6447665ejc.958.2022.12.02.00.26.35; Fri, 02 Dec 2022 00:26:59 -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=go1LazcQ; 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 S232865AbiLBISv (ORCPT + 99 others); Fri, 2 Dec 2022 03:18:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232739AbiLBISa (ORCPT ); Fri, 2 Dec 2022 03:18:30 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35668DFE2; Fri, 2 Dec 2022 00:17:02 -0800 (PST) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B28E7ij015126; Fri, 2 Dec 2022 08:16:49 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=dy9XbWkrjC5fa2DzU1vqdWwDxq4XYdcaigLaGuV9cT4=; b=go1LazcQ95hh/CbmBI5pVEql0dK6tnppDOnA0ZKaWQ4KT+ayrV7F9n9yzFQ2QmgzPH34 a0dQLXuGNM+a+V1RWp25K5YHz90MCli99oyMWCJJWGeLVGh2ocAGhOXCrjaqOYcOX//S 844HUgU2NrPwPvJuAN4GIwXRwLfd/pR8D+2jhgeLthcxu/ib2Dw/ZlSrpX6eRTaocs14 1BB4PVN/YX2LHIVw5r8b2ZIvEIRdzS+M+O1icpm/oaP2qltJLvwpfc+1YXpdj8HAMnxV PXkTRTttuqO6z2VPa/kVUz3jPxMSTEQ50nugBBb/oi+LnzBjtRGkwh1BJ6gumfb7T0e7 dQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m6k2c55r2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Dec 2022 08:16:49 +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 2B28GmeO014138; Fri, 2 Dec 2022 08:16:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA04.qualcomm.com (PPS) with ESMTPS id 3m5dmy6esr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 02 Dec 2022 08:16:48 +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 2B28GlMc014125; Fri, 2 Dec 2022 08:16:47 GMT Received: from stor-presley.qualcomm.com (stor-presley.qualcomm.com [192.168.140.85]) by NASANPPMTA04.qualcomm.com (PPS) with ESMTP id 2B28GltO014117; Fri, 02 Dec 2022 08:16:47 +0000 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 8090C20DAF; Fri, 2 Dec 2022 00:16:47 -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" , Kiwoong Kim , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/3] ufs: core: mcq: Add Event Specific Interrupt enable and config APIs Date: Fri, 2 Dec 2022 00:15:06 -0800 Message-Id: <1669968909-33021-3-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1669968909-33021-1-git-send-email-quic_cang@quicinc.com> References: <1669968909-33021-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: rbyctX3mf74UUk9cpf8WN_I7RAhAOITv X-Proofpoint-GUID: rbyctX3mf74UUk9cpf8WN_I7RAhAOITv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-02_04,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 clxscore=1011 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212020062 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,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?1751090063440379024?= X-GMAIL-MSGID: =?utf-8?q?1751090063440379024?= 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 Fri Dec 2 08:15:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 28767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp713998wrr; Fri, 2 Dec 2022 00:27:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf4WYQ6vGfQpodEXvzYgP90ya/ZtMeKNarFNHI6q4OKp8eW5RqiXsA6vtROX7XyJ/h9/8fAi X-Received: by 2002:a17:906:1e48:b0:7ad:a943:ee49 with SMTP id i8-20020a1709061e4800b007ada943ee49mr13913650ejj.311.1669969675983; Fri, 02 Dec 2022 00:27:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669969675; cv=none; d=google.com; s=arc-20160816; b=L0VyW0EzJeVnhv1C6dO3c3zVq4b+K2AOe3pPj7Qkl7p5JYr9nnuBRie7/xpFYre3ZS +CJCznspG3kd3j4X91jHfxaZLcpqzno1z9jfI6sPBXSkdU8+0Jbz3xlG7/vagWZeNgr9 YtmUZlpSZbodsSiBuIS7Wr8UUI/ofeTo1M5DnlyCYC6Wx1FMkGku4GvnVsOHAeF9MMol UkLez42UncmlP5S3etPbx1wFwyhuNCnSnZGmvEHZWZXeqpDe03k5IqEPmvZePQIOeUBb F/sJHAaHxXYuhnvfjYssYQ2UjdRnxcQSE4/2Z25KmA9Kxsu2WrSohJEVyp/CulIk1yoi hXzQ== 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=XyOJIMJLrukixYZyXffRB/uMBNyS/MdzUFxolzrOKuU=; b=dfwY4weSik5DSrD0PfeOcGGZjG6a3zZ7DRa/+1V/r0TIbTNRZnlZ1OxK+YWXMeq/d6 qcjJarPGqB+zDgPvGd/50OxxbedkaztDDq9ZWAUHSAl67fv11V4GcHIYr3tViPPUpbIy R2ShCwOYjm3SMPkmCseKxPfaHLt7/wyRlJoygTueVXHOkIBF5SPJYNqXO9kayF+/YUN0 vWmLDAgZbgNJLz94c10qwEpotu12b0cwmZlW2gsHE7Te0c5tfK7trVbR0oxEvBMzjawZ zGhOuOqSM41Oh//ZG6vHRFDJgDboHfQ44DXeh92ia89Whv2+xusD1a7UyGjhkPar/3Ub 79hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=VUxfg3Eq; 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 xc3-20020a170907074300b007b790c183c1si6226833ejb.455.2022.12.02.00.27.32; Fri, 02 Dec 2022 00:27:55 -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=VUxfg3Eq; 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 S232871AbiLBISy (ORCPT + 99 others); Fri, 2 Dec 2022 03:18:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232754AbiLBISb (ORCPT ); Fri, 2 Dec 2022 03:18:31 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A51ABA1F; Fri, 2 Dec 2022 00:17:05 -0800 (PST) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B28Dv2n015942; Fri, 2 Dec 2022 08:16:49 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=XyOJIMJLrukixYZyXffRB/uMBNyS/MdzUFxolzrOKuU=; b=VUxfg3EqxNcHqAp1ZSVfGoicptRPgAjXNs4RWhFmVow7QQ2oNWRDjTU45RnfKnanbSqr VzZ8OYAij6CrnY945OXhwTFuy5LqEMIBFI9hie6cqTyutaNoNa0RfIcf5I59ecT+xxTp nzSoteG8IrcbiX6J/W1HUBAMSgf52zgzEoFSmPQPbQ42edmzt9W6oID1wPrPf+4romfA KyVdijkUjJEOKKgbxGZVOiu4wGEvw8VKFij+K9ADH7+IwI7tGOKN1y1sP46gR/d0oZa/ CkmMzB+TSzgKVXK++FETUiTsGQYNc9akwnCkMjZYzbor1ZNTwEjBWULCrVdvd62MPUGx kg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m7b82rm9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Dec 2022 08:16:49 +0000 Received: from pps.filterd (NASANPPMTA03.qualcomm.com [127.0.0.1]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 2B28GmlG029542; Fri, 2 Dec 2022 08:16:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 3m6j6ucj38-1; Fri, 02 Dec 2022 08:16:48 +0000 Received: from NASANPPMTA03.qualcomm.com (NASANPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2B28Gm4e029537; Fri, 2 Dec 2022 08:16:48 GMT Received: from stor-presley.qualcomm.com (stor-presley.qualcomm.com [192.168.140.85]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 2B28Gm8t029534; Fri, 02 Dec 2022 08:16:48 +0000 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 1675720DAF; Fri, 2 Dec 2022 00:16:48 -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 3/3] ufs-host: qcom: Add MCQ ESI config vendor specific ops Date: Fri, 2 Dec 2022 00:15:07 -0800 Message-Id: <1669968909-33021-4-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1669968909-33021-1-git-send-email-quic_cang@quicinc.com> References: <1669968909-33021-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: X-cFrFXxf-NxC3dU_kfrfRh02wvoBQYI X-Proofpoint-GUID: X-cFrFXxf-NxC3dU_kfrfRh02wvoBQYI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-02_04,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 adultscore=0 mlxscore=0 clxscore=1011 malwarescore=0 impostorscore=0 spamscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212020062 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,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?1751090123266202064?= X-GMAIL-MSGID: =?utf-8?q?1751090123266202064?= 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 | 99 +++++++++++++++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-qcom.h | 5 +++ 2 files changed, 104 insertions(+) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 96a58b4..18bdece 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1568,6 +1568,103 @@ 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; + u32 reg; + 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) { + reg = ufshcd_readl(hba, REG_UFS_CFG3); + reg |= 0x1F000; + ufshcd_writel(hba, reg, REG_UFS_CFG3); + reg = ufshcd_readl(hba, 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 +1692,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 +1726,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