Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp362798lqh; Fri, 31 May 2024 03:52:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9k+4n46W96BGgVFCEv1j/1JZI2WysMt0C0pilIYofFnHQODysJITa+JehZ4B0l46PswB9bGysmgpjaCxwXbclFrZ8NZ3yuyhOd8B8gA== X-Google-Smtp-Source: AGHT+IHEBy25mPWvAPJmRMTtpAqryfzFSFaSlL50g7kOdfPZ/FoSIDU+6rog3WGpGr3OPF4Y86kB X-Received: by 2002:a05:6a00:130c:b0:702:42af:ca18 with SMTP id d2e1a72fcca58-702456e089emr1758535b3a.7.1717152757079; Fri, 31 May 2024 03:52:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717152757; cv=pass; d=google.com; s=arc-20160816; b=hA5uyAkkSPzP17g/jLylzsaMN7FlPTaqvLLzLSajm5Woz2VsaFOEQqm0q1XQm+eR3t vMm+smGOBb7fdhPE2bYPW42Z0fP3cS2gjtkx6E4Q3C1cAjZOdnrsKHks97h4BLn2Rs/N S6YyDt7nSGfYTT1JNS9+B3ERxLHzzXP8IVulz5WzMEoF0LsUJF83TUlYq4cEx/wn+kFu KPyvv3A0m5OJy6BccbVaRCOGb8eStunwo14ZsB88Pr6ehKPm5sPJANGXsjDOgtF9kI9c PFsC5lfGqFUNj4+H9QIVoMTWu3FKWoL31lNZwnYbAUojCwchQuUEIfEYe7jB2yISm29G xbZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:dlp-filter:cms-type:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=NeMgLSvpR+9j44c4Bok8cPMbulX9XuhRpiv420ziGJ4=; fh=gK7FBjto+diHrgskPY1eNwAmc/UVHBuFUmF57yEsVP4=; b=WC0fxD3Ii5Zt3XHoc9ywJ5Ttrjudb6XQltBj8SvcclI7xr5F5SqoVnaD6GcfQ8FRcf GG8GbP45nN+VUEAcVAT8XC8EN+M9Q8SzkFqs5oa6ZuPvaAww2oSgfHToA9s3oAPYAFNw zLZ275sJKqf8xa/Nc84BUPCeqxmGydChFTIGE+TcJLg10c/uj7fnJPkm8cjwKiqTLkc/ 38KpBPgqCAiGpDZ+L5Wx8O5ylaO68pPd54N53rhj7ja8CSy7vAYMf/QG4xFGkXeHIzBV UU/D8EIUE0zSaEZCfIHLXFlZy91UG0ypbEP51M0mNUoK7kS1o83GgUGRWngkatHx1ET0 yS6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=SeP2Imor; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-196694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-7024aeef0f1si771650b3a.302.2024.05.31.03.52.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 03:52:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=SeP2Imor; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-196694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 23970B25A16 for ; Fri, 31 May 2024 10:50:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FA0B156F42; Fri, 31 May 2024 10:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="SeP2Imor" Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 8B758156F25 for ; Fri, 31 May 2024 10:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717152595; cv=none; b=h43vju202Oi7x6WMpB4ehf/fLGxZDlGK8Ejvk0xOyEiASESzLrN9TJ1Jtl/OBwUbnchZMCd++FsXAj1WWUGCopeBQpeJOgnzGeJ9Z3erw8zgGXElfL1dFDPTp7oLek6FcQz0La5ZOcICDRHmR6LeaUrSvvuDJ0ljPY7jEyM1jSI= 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.34 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 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240531104949epoutp04003d711136c93af72cff4a59a29ab93b~UjS64-5DV1265812658epoutp04j for ; Fri, 31 May 2024 10:49:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240531104949epoutp04003d711136c93af72cff4a59a29ab93b~UjS64-5DV1265812658epoutp04j 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 xMzM0NzI1MBcSZz3XuvcF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9vagBtGL5JW1M4pm/vqe1L8 yuT7Lxbd2GJebXc1MI0hUqc7wfbsvWdRW10q+Cz6bp5RlWLZve58ksOykuOz018aFOX9tth0 p1+mpKraZFJt9f/n3nuPiVbqriz4Uic4w3MN6/3FnDxR4bfMNzDFV0Ve1jWT7c+ZWHExy9Rf Z4+r9KT9PzwWzHIOVbO8zZne4JpTZX1EeHpE6LNnr1NnfJJ5I6F/cM7f+0GTf29a4yW9oMz9 qcTZC4KZKyuOt3keUbDO8qpX6F1yd21F3Y83GuFWUdskd1tVuqpObulJienymqipHcCrWC8T rcRSnJFoqMVcVJwIAHm00EfsAgAA X-CMS-MailID: 20240531104947epcas2p30506632eb56025711dfb5768e2f77154 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" 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 }, -- 2.34.1