From patchwork Fri May 31 10:38:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 801053 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B26B156C7A for ; Fri, 31 May 2024 10:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717152594; cv=none; b=jS7fVx3/O+Iw6goEx1Qi3KIfkr1pOmYiIfovc/V+CVhFfycyCoZzQhcwAHLIbcq8WcgmyGW4P+dOFOGtlDDQq+oVrt37zN1I4M3jwmQkUHtf4GkCIQD3PEkJx7lzNpvCNPn2Utg+D0S+OqzA5B/f+Q5iYIQWSjDwrHjfeNIcIn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717152594; c=relaxed/simple; bh=AFfAKnNNAElMu/x0QLDxcvTX9NDDzFCEKVCESmX8MV8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=rNubvyMbrN0l9sNqGZR0ljoFMT3hd2GI6hzn6l9DDovIZkdUTN8TOFFQKh0Y2Wqhu1zkIQh7doGB49MeTvBXfG+lGpW9hTWuD7ojhqzun3b5zpLTd09hUvSGGlhIlKCHOhj/FXRyiqKLnerkZIMc9YMgrquuKdg6ZIcp+MnU3Eg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=XBfEqcw9; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="XBfEqcw9" Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240531104949epoutp02bdae1360ed010acf0699eb79de8559a5~UjS6m-yH92291222912epoutp02g for ; Fri, 31 May 2024 10:49:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240531104949epoutp02bdae1360ed010acf0699eb79de8559a5~UjS6m-yH92291222912epoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1717152589; bh=BGq1tc1rCx1x4oD1ebKrvH6uQdBdZBm2UNu+DAj5ACw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XBfEqcw9fElHblHEk5B/tnF+GyS6jzH0PrK4stQOv4oAUYs4W1o2XwpPWRFcyGFqf vpzOPQsDXh7pAmsa7eHhPhM1Ox9xqg5VVbhhwqAJNaWJ4w8FZiT12nKlxnP+bf1HfH ivjIfswcOIJYJMu89CDa3FoXXk8WDlYXLbi6LybU= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20240531104949epcas2p2e10debed7765c7eb03c80682b2efdd59~UjS6TCWri0395903959epcas2p2x; Fri, 31 May 2024 10:49:49 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.70]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4VrKd82PrWz4x9Py; Fri, 31 May 2024 10:49:48 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 8F.A3.09479.C4BA9566; Fri, 31 May 2024 19:49:48 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20240531104947epcas2p1cd477921c1cd307d84f9ffc25b2c08a8~UjS5Ppb1x1681016810epcas2p13; Fri, 31 May 2024 10:49:47 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240531104947epsmtrp1a4cee3fbfef7de34ed8140bdbface15a~UjS5OtW2k2848028480epsmtrp11; Fri, 31 May 2024 10:49:47 +0000 (GMT) X-AuditID: b6c32a48-105fa70000002507-42-6659ab4c65c0 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 32.A0.07412.B4BA9566; Fri, 31 May 2024 19:49:47 +0900 (KST) Received: from localhost.dsn.sec.samsung.com (unknown [10.229.54.230]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240531104947epsmtip1f0cac1e4fc578a96a482b59a3224bbe6~UjS5DSwHj0934709347epsmtip1K; Fri, 31 May 2024 10:49:47 +0000 (GMT) From: Minwoo Im To: "James E . J . Bottomley" , "Martin K . Petersen" Cc: Alim Akhtar , Avri Altman , Bart Van Assche , Minwoo Im , gost.dev@samsung.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jeuk Kim Subject: [PATCH 1/3] ufs: mcq: Add ufshcd_mcq_queue_cfg_addr helper Date: Fri, 31 May 2024 19:38:19 +0900 Message-Id: <20240531103821.1583934-2-minwoo.im@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240531103821.1583934-1-minwoo.im@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLJsWRmVeSWpSXmKPExsWy7bCmma7P6sg0g3cz+CwezNvGZvHy51U2 i2kffjJb3Dywk8liYz+Hxf2t1xgtLu+aw2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WW4oxEQy3mouJEAIu0SmjtAgAA X-CMS-MailID: 20240531104947epcas2p1cd477921c1cd307d84f9ffc25b2c08a8 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240531104947epcas2p1cd477921c1cd307d84f9ffc25b2c08a8 References: <20240531103821.1583934-1-minwoo.im@samsung.com> This helper returns an offset address of MCQ queue configuration registers. This is a prep patch for the following patch. Signed-off-by: Minwoo Im --- drivers/ufs/core/ufs-mcq.c | 14 ++++++++++++++ include/ufs/ufshcd.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 52210c4c20dc..46faa54aea94 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -18,6 +18,7 @@ #include #define MAX_QUEUE_SUP GENMASK(7, 0) +#define QCFGPTR GENMASK(23, 16) #define UFS_MCQ_MIN_RW_QUEUES 2 #define UFS_MCQ_MIN_READ_QUEUES 0 #define UFS_MCQ_MIN_POLL_QUEUES 0 @@ -116,6 +117,19 @@ struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba, return &hba->uhq[hwq]; } +/** + * ufshcd_mcq_queue_cfg_addr - get an start address of the MCQ Queue Config + * Registers. + * @hba: per adapter instance + * + * Return: Start address of MCQ Queue Config Registers in HCI + */ +unsigned int ufshcd_mcq_queue_cfg_addr(struct ufs_hba *hba) +{ + return FIELD_GET(QCFGPTR, hba->mcq_capabilities) * 0x200; +} +EXPORT_SYMBOL_GPL(ufshcd_mcq_queue_cfg_addr); + /** * ufshcd_mcq_decide_queue_depth - decide the queue depth * @hba: per adapter instance diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index df68fb1d4f3f..9e0581115b34 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -1278,6 +1278,7 @@ 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_config_mac(struct ufs_hba *hba, u32 max_active_cmds); +unsigned int ufshcd_mcq_queue_cfg_addr(struct ufs_hba *hba); u32 ufshcd_mcq_read_cqis(struct ufs_hba *hba, int i); void ufshcd_mcq_write_cqis(struct ufs_hba *hba, u32 val, int i); unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba, From patchwork Fri May 31 10:38:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 800859 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A446C156F42 for ; Fri, 31 May 2024 10:49:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717152595; cv=none; b=t1uvti+sVClVO0sF57NFYNgZYzOVqC8vjM0U4NhHTiWjx4NUYbuuGVZG37JjOLI60qQZ+l1iKgsySBEIfDzd+E9xe+r1v+dfnnfKW6EtL3pDbbg15cPWPlwxzGtMYCU4bUbJOOIQq5+3nb4GFoa30XhUtt+N5YdZEIWJhrfaqh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717152595; c=relaxed/simple; bh=JL0jkyun2LxE4J4kzViXyje0GZZot6jmyEQrYG1n/pc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=bzsTBQrNxDc0avtadlPhP7g600GWLF7Yc4mRpU5dpiqh/uS3hkLoXqxsohkYGkwjD1jBsfWnLwgHs/1PAlfH96+FGc/0Myu3oC5Up7UPWlsvNs1mNAbg8V+NY9Bx4PxnabXSSGI4XSyimjkop4MmUIGUTgQxKS/VcU2u8sS50vM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=SeP2Imor; arc=none smtp.client-ip=203.254.224.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="SeP2Imor" Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240531104949epoutp030bbfb51a6da4f333fd290a1a38b69f91~UjS64m2Fl1958019580epoutp03l for ; Fri, 31 May 2024 10:49:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240531104949epoutp030bbfb51a6da4f333fd290a1a38b69f91~UjS64m2Fl1958019580epoutp03l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1717152589; bh=NeMgLSvpR+9j44c4Bok8cPMbulX9XuhRpiv420ziGJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SeP2ImorqzQSiuGAc/C3m6Qok5m74agez4jjeg+cuh3TbzS1q3c5eURYqsu8K73Ko KNnSRtOxShgKPLrl8BgEKh3sBF6Dzv5iQGdQ//1NRjJRlST9ynmKFwyrxhkaIVpn16 h+Ui5v+o+4Y5TM4W0xsMEisPu6Z1Zh3BrKheaXMs= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20240531104949epcas2p368bacccfff56e330e9d04d559aa7383b~UjS6jeLLP2726827268epcas2p3_; Fri, 31 May 2024 10:49:49 +0000 (GMT) Received: from epsmgec2p1-new.samsung.com (unknown [182.195.36.98]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4VrKd84BZsz4x9Q6; Fri, 31 May 2024 10:49:48 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmgec2p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 6F.D2.18956.C4BA9566; Fri, 31 May 2024 19:49:48 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20240531104947epcas2p30506632eb56025711dfb5768e2f77154~UjS5Qbnut1766317663epcas2p3C; Fri, 31 May 2024 10:49:47 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240531104947epsmtrp16b82d195884d3416abc8665b0a52af06~UjS5PHupy2848028480epsmtrp12; Fri, 31 May 2024 10:49:47 +0000 (GMT) X-AuditID: b6c32a4d-247ff70000004a0c-19-6659ab4cf2ed Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 42.A0.07412.B4BA9566; Fri, 31 May 2024 19:49:47 +0900 (KST) Received: from localhost.dsn.sec.samsung.com (unknown [10.229.54.230]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240531104947epsmtip1bd6f77365a18ee53f40c3fd56100775a~UjS5Gb4Sb0934709347epsmtip1L; Fri, 31 May 2024 10:49:47 +0000 (GMT) From: Minwoo Im To: "James E . J . Bottomley" , "Martin K . Petersen" Cc: Alim Akhtar , Avri Altman , Bart Van Assche , Minwoo Im , gost.dev@samsung.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jeuk Kim Subject: [PATCH 2/3] ufs: pci: Add support MCQ for QEMU-based UFS Date: Fri, 31 May 2024 19:38:20 +0900 Message-Id: <20240531103821.1583934-3-minwoo.im@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240531103821.1583934-1-minwoo.im@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIJsWRmVeSWpSXmKPExsWy7bCmma7P6sg0g61XpCwezNvGZvHy51U2 i2kffjJb3Dywk8liYz+Hxf2t1xgtLu+aw2bRfX0Hm8Xy4/+YLJ6dPsDswOVx+Yq3x7RJp9g8 Pj69xeLRt2UVo8fnTXIe7Qe6mQLYorJtMlITU1KLFFLzkvNTMvPSbZW8g+Od403NDAx1DS0t zJUU8hJzU22VXHwCdN0yc4AOU1IoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fYKqUWpOQUmBfo FSfmFpfmpevlpZZYGRoYGJkCFSZkZzTsv81U8EK8Yu6cTtYGxi/CXYycHBICJhI3jnxi62Lk 4hAS2MMocWpWByOE84lRYtGmv8wQzjdGiROLnzDDtExqOcwEkdjLKLH67HwWCOc3o8Txt3sZ QarYBNQlGqa+YgGxRQSqJTa3/wVbwizQxyTRPns+axcjB4ewgKPE9dWGIDUsAqoS908tAuvl FbCRuHxyGRPENnmJ/QfPgm3mFLCVaPl/kg2iRlDi5MwnYPOZgWqat84GO1VCoJFD4s/7aYwQ zS4St46fZYewhSVeHd8CZUtJvOxvg7LLJX6+mQRVXyFxcNZtNpDbJATsJa49TwExmQU0Jdbv 0oeIKkscuQW1lU+i4/Bfdogwr0RHmxDEDGWJj4cOQYNKUmL5pddsELaHxLPPa6GBO4FR4tP2 XWwTGBVmIXlmFpJnZiEsXsDIvIpRKrWgODc9NdmowFA3L7UcHsnJ+bmbGMFpVct3B+Pr9X/1 DjEycTAeYpTgYFYS4f2VHpEmxJuSWFmVWpQfX1Sak1p8iNEUGNwTmaVEk/OBiT2vJN7QxNLA xMzM0NzI1MBcSZz3XuvcFCGB9MSS1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JW1M4pm/vqe1L8 yuT7Lxbd2GJebXc1MI0hUqc7wfbsvWdRW10q+Cz6bp5RlWLZve58ksOykuOz018aFOX9tth0 p1+mpKraZFJt9f/n3nuPiVbqriz4Uic4w3MN6/3FnDxR4bfMNzDFV0Ve1jWT7c+ZWHExy9Rf Z4+r9KT9PzwWzHIOVbO8zZne4JpTZX1EeHpE6LNnr1NnfJJ5I6F/cM7f+0GTf29a4yW9oMz9 qcTZC4KZKyuOt3keUbDO8qpX6F1yd21F3Y83GuFWUdskd1tVuqpObulJienymqipHcCrWC8T rcRSnJFoqMVcVJwIAHm00EfsAgAA X-CMS-MailID: 20240531104947epcas2p30506632eb56025711dfb5768e2f77154 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240531104947epcas2p30506632eb56025711dfb5768e2f77154 References: <20240531103821.1583934-1-minwoo.im@samsung.com> Recently, ufs-mcq feature has been introduced to QEMU hw/ufs device [1]. This patch adds MCQ support for upstream QEMU UFS PCI controller. This patch provides mandatory vops callbacks to make UFS controller work properly on MCQ mode. Operation and Runtime Config register stride is fixed to 48bytes which is implemented by qemu. [1] https://lore.kernel.org/qemu-devel/cover.1716876237.git.jeuk20.kim@samsung.com/ Signed-off-by: Minwoo Im --- drivers/ufs/host/ufshcd-pci.c | 48 ++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufshcd-pci.c b/drivers/ufs/host/ufshcd-pci.c index 0aca666d2199..d4d64a29390e 100644 --- a/drivers/ufs/host/ufshcd-pci.c +++ b/drivers/ufs/host/ufshcd-pci.c @@ -20,6 +20,8 @@ #include #include +#define MAX_SUPP_MAC 64 + struct ufs_host { void (*late_init)(struct ufs_hba *hba); }; @@ -446,6 +448,49 @@ static int ufs_intel_mtl_init(struct ufs_hba *hba) return ufs_intel_common_init(hba); } +static int ufs_redhat_get_hba_mac(struct ufs_hba *hba) +{ + return MAX_SUPP_MAC; +} + +static int ufs_redhat_mcq_config_resource(struct ufs_hba *hba) +{ + hba->mcq_base = hba->mmio_base + ufshcd_mcq_queue_cfg_addr(hba); + + return 0; +} + +static int ufs_redhat_op_runtime_config(struct ufs_hba *hba) +{ + struct ufshcd_mcq_opr_info_t *opr; + int i; + + u32 sqdao = ufsmcq_readl(hba, ufshcd_mcq_cfg_offset(REG_SQDAO, 0)); + u32 sqisao = ufsmcq_readl(hba, ufshcd_mcq_cfg_offset(REG_SQISAO, 0)); + u32 cqdao = ufsmcq_readl(hba, ufshcd_mcq_cfg_offset(REG_CQDAO, 0)); + u32 cqisao = ufsmcq_readl(hba, ufshcd_mcq_cfg_offset(REG_CQISAO, 0)); + + hba->mcq_opr[OPR_SQD].offset = sqdao; + hba->mcq_opr[OPR_SQIS].offset = sqisao; + hba->mcq_opr[OPR_CQD].offset = cqdao; + hba->mcq_opr[OPR_CQIS].offset = cqisao; + + for (i = 0; i < OPR_MAX; i++) { + opr = &hba->mcq_opr[i]; + opr->stride = 48; + opr->base = hba->mmio_base + opr->offset; + } + + return 0; +} + +static struct ufs_hba_variant_ops ufs_redhat_hba_vops = { + .name = "redhat-pci", + .get_hba_mac = ufs_redhat_get_hba_mac, + .mcq_config_resource = ufs_redhat_mcq_config_resource, + .op_runtime_config = ufs_redhat_op_runtime_config, +}; + static struct ufs_hba_variant_ops ufs_intel_cnl_hba_vops = { .name = "intel-pci", .init = ufs_intel_common_init, @@ -591,7 +636,8 @@ static const struct dev_pm_ops ufshcd_pci_pm_ops = { }; static const struct pci_device_id ufshcd_pci_tbl[] = { - { PCI_VENDOR_ID_REDHAT, 0x0013, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_VENDOR_ID_REDHAT, 0x0013, PCI_ANY_ID, PCI_ANY_ID, 0, 0, + (kernel_ulong_t)&ufs_redhat_hba_vops }, { PCI_VENDOR_ID_SAMSUNG, 0xC00C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VDEVICE(INTEL, 0x9DFA), (kernel_ulong_t)&ufs_intel_cnl_hba_vops }, { PCI_VDEVICE(INTEL, 0x4B41), (kernel_ulong_t)&ufs_intel_ehl_hba_vops }, From patchwork Fri May 31 10:38:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 800860 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3CB2156F3B for ; Fri, 31 May 2024 10:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717152593; cv=none; b=BB4B/NLYZd0UZogJc2bpB+0PPwN+XmXWxtxhkyeYdrHkgKuLzzWvvaRiov0su5Ow7dZg0D1GYMuQngALdyTUrOwuZaLipt77nz72NHMsw7W9SfdkEZGz8tcD3dkSFaFBibCbV4OGOymCf0d3+vcEzy68CotVoJ3fPknQ+0JeqXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717152593; c=relaxed/simple; bh=7mStks36RWqI3qkwa9T/IeoxhBPwl6wnLq4xYtaNlVM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=OFDmVNtiF2gx0bP0Qnnhj6oHHsRpz2PHByOA+WMrAevafhozoPbCZabGDbCA0gzlf18aLesFh/N2bF04sDRItEmfk6UbO7copv1GaFBvxPC1+P2/JHSflssdI/Z7ybUkxUzStjdwNbOZle65v+cMztiyGdyC3GevoxGiIayuO+0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=kizKn1jT; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="kizKn1jT" Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240531104949epoutp0296b38ccaf836257e3a853a367357651f~UjS7GIaNm2291222912epoutp02h for ; Fri, 31 May 2024 10:49:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240531104949epoutp0296b38ccaf836257e3a853a367357651f~UjS7GIaNm2291222912epoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1717152590; bh=uHe4lHWKM8hrsGb57PeAvfZQzle5G0HXraBJlb7Eicw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kizKn1jThcxeUO0KXrJeA5BCN1ay/4ZBkjQB2fv4m5yjM5iggPmkpUIJLmHneFe5N a/fY/OWCfslBzKjm2yVDg08bqkqzbHn/SzmDe2PQXwFaWdxpY2dtZF0FpoF37FDq/L hlNq8zlfNT9CgZL5KdOVY6I3yEjDUghE7VSoJN5U= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20240531104949epcas2p3dc1dc2bec8419dd1bbce0e5129b5b7a1~UjS6f20Sm1766317663epcas2p3D; Fri, 31 May 2024 10:49:49 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.102]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4VrKd83Sk9z4x9Q0; Fri, 31 May 2024 10:49:48 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 7B.DC.09806.C4BA9566; Fri, 31 May 2024 19:49:48 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20240531104948epcas2p1a70f31cd4a1aa5d36267b4187d75056b~UjS5Wu4tl1681016810epcas2p14; Fri, 31 May 2024 10:49:48 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240531104948epsmtrp22765271c56525eaa6a287314494c588e~UjS5V9eGO3112831128epsmtrp21; Fri, 31 May 2024 10:49:48 +0000 (GMT) X-AuditID: b6c32a47-c6bff7000000264e-23-6659ab4c7e3b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 45.F1.18846.B4BA9566; Fri, 31 May 2024 19:49:48 +0900 (KST) Received: from localhost.dsn.sec.samsung.com (unknown [10.229.54.230]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240531104947epsmtip1c63e4851994ea32a017f917a98adb709~UjS5JYUt-0934709347epsmtip1M; Fri, 31 May 2024 10:49:47 +0000 (GMT) From: Minwoo Im To: "James E . J . Bottomley" , "Martin K . Petersen" Cc: Alim Akhtar , Avri Altman , Bart Van Assche , Minwoo Im , gost.dev@samsung.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jeuk Kim Subject: [PATCH 3/3] ufs: mcq: Prevent no I/O queue case for MCQ Date: Fri, 31 May 2024 19:38:21 +0900 Message-Id: <20240531103821.1583934-4-minwoo.im@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240531103821.1583934-1-minwoo.im@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAA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ePsWUGW3AZnD4ZE20rzX96T5/e9l13Wa/F7Iic6TsxetFTuaYAJ/GJSizFGYmGWsxF xYkArvWw5+kCAAA= X-CMS-MailID: 20240531104948epcas2p1a70f31cd4a1aa5d36267b4187d75056b X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240531104948epcas2p1a70f31cd4a1aa5d36267b4187d75056b References: <20240531103821.1583934-1-minwoo.im@samsung.com> If hba_maxq equals poll_queues, which means there are no I/O queues (HCTX_TYPE_DEFAULT, HCTX_TYPE_READ), the very first hw queue will be allocated as HCTX_TYPE_POLL and it will be used as the dev_cmd_queue. In this case, device commands such as QUERY cannot be properly handled. This patch prevents the initialization of MCQ when the number of I/O queues is not set and only the number of POLL queues is set. Signed-off-by: Minwoo Im --- drivers/ufs/core/ufs-mcq.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 46faa54aea94..4bcae410c268 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -179,6 +179,15 @@ static int ufshcd_mcq_config_nr_queues(struct ufs_hba *hba) return -EOPNOTSUPP; } + /* + * Device should support at least one I/O queue to handle device + * commands via hba->dev_cmd_queue. + */ + if (hba_maxq == poll_queues) { + dev_err(hba->dev, "At least one non-poll queue required\n"); + return -EOPNOTSUPP; + } + rem = hba_maxq; if (rw_queues) {