Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp69543rdb; Wed, 20 Dec 2023 06:34:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfbtfuC1rWS8TbSkFqftPKsbAAL5t3q983HhJ8Rylivdkua18h3Lg0Tcs9vbr5LE4JzToe X-Received: by 2002:a17:902:ed92:b0:1d3:bc88:59af with SMTP id e18-20020a170902ed9200b001d3bc8859afmr5530057plj.136.1703082888856; Wed, 20 Dec 2023 06:34:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703082888; cv=none; d=google.com; s=arc-20160816; b=jHloNGpYYMt4hHkmKkFZSyA9ef87haBxab/htM9geiv2goje6aVNd5mv0m6IT/IPhg cCTPh206jimWXMRQhoyDhfhvvfres0gRwnhe0Var4LWcrIhEn9nScojU7Yhs7oRRRgyw YsuPjwsRdhkGeDaL2TV/X70GqdN08TfLKn/z/gHxVVEpq1FSz+I6KeM26+hxAo4hiEHA E3PoRItZOoU9zM+E1FRRGmFgWtDMReRygCNqdHckiebfAw23YQWjn/hGEJ1sQ9n/XdTH b9HAubMrLQOb26lcRQkEmqHyuEVtGVLFfOPbUegyVkt/ETcaKHErrub1VvD1Sc4EmqR2 wYmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TlYfIEwj43ovPaKj1Dqv2FA/0OB32NB/8xoiGE3pC34=; fh=vASBoBKa2dB/Dpw75Rmk1Wv4r644YrkCHth94LzDnZ4=; b=JVCXiZ2No+XHXi0BoZc+YX6IFTbiAyXgmAHiAInE4WjsE/D5UfWPs90cqhJR9NySLW iQpCCRY10zVOa1xFdXyHUdiHtNmATuR+pSkZQmlEu1U19fxIW0fTs1UPBv0XE6cGC8kP eJoj9Ddf0+sPEblkVhLyhpK3Qdx38JigU0ZXuQNhblTJ07dXmM9UothYFJUE5xVRxzEW 7eguvvIAuemM2xO8qOosgHgA+kaHFO2a6vpvaqMPU7eEaBAtgTZQjEaLmnfjgGMNXLGq J3FQGwdCdnG8G4KFHJDc0c5/CFCCneElNNko85hLE9r+AkMD/XG4XtQYJPSvfOjCSVQ/ TsRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ax/u038B"; spf=pass (google.com: domain of linux-kernel+bounces-7066-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7066-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j12-20020a170903024c00b001d0c1281f07si21848400plh.205.2023.12.20.06.34.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 06:34:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7066-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ax/u038B"; spf=pass (google.com: domain of linux-kernel+bounces-7066-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7066-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 286DA284D86 for ; Wed, 20 Dec 2023 14:34:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79E043B29C; Wed, 20 Dec 2023 14:34:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ax/u038B" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A73043AC1A; Wed, 20 Dec 2023 14:34:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87BEEC433CA; Wed, 20 Dec 2023 14:34:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703082881; bh=iNsI8JfwO+C25hEOmVx+Z0q3QIW2jx9qavk1Utsxgy4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ax/u038BkU+2lQkEoNO6vULvumIx9BczrUQfu3Zkcpac03PvdKfZ7yn54XvC4IqG4 rYyIej/075WZvwXH/UO3s2WJ9vHe4rnVF2g3AnWgwHd/ZCjfDcpALbkr0ZyoGZIjL+ jhiYqau5FIXhITuc8XTbZvP5Vxt6nVp3jtIseZPB4j8HQLA8ZHVV6lVYD6ybhRheUJ HHpkSashYQQxYjxU/kt743PGBPTlpuM/n/+kVJPuYyu/bhOjq79NAHH27vq/+2USbV raw1KMS0sErTjbcDqKFkk24v43FMiM3XoNSDDDSfiVd/WQWUeMjHPOEiSB7XqP4+XR BG+OeSv71QGBQ== Date: Wed, 20 Dec 2023 20:04:22 +0530 From: Manivannan Sadhasivam To: Chanwoo Lee Cc: alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, jejb@linux.ibm.com, martin.petersen@oracle.com, peter.wang@mediatek.com, chu.stanley@gmail.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, stanley.chu@mediatek.com, quic_cang@quicinc.com, quic_asutoshd@quicinc.com, powen.kao@mediatek.com, quic_nguyenb@quicinc.com, yang.lee@linux.alibaba.com, beanhuo@micron.com, Arthur.Simchaev@wdc.com, ebiggers@google.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, grant.jung@samsung.com, jt77.jang@samsung.com, dh0421.hwang@samsung.com, sh043.lee@samsung.com Subject: Re: [PATCH] ufs: mcq: Adding a function for MCQ enable Message-ID: <20231220143422.GF3544@thinkpad> References: <20231220052737.19857-1-cw9316.lee@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231220052737.19857-1-cw9316.lee@samsung.com> On Wed, Dec 20, 2023 at 02:27:37PM +0900, Chanwoo Lee wrote: > From: ChanWoo Lee > > The REG_UFS_MEM_CFG register is too general(broad) > and it is difficult to know the meaning of only values of 0x1 and 0x2. > So far, comments were required. > > Therefore, I have added new functions and defines > to improve code readability/reusability. > > Signed-off-by: ChanWoo Lee > --- > drivers/ufs/core/ufs-mcq.c | 10 +++++++++- > drivers/ufs/core/ufshcd.c | 5 +---- > drivers/ufs/host/ufs-mediatek.c | 4 +--- > include/ufs/ufshcd.h | 1 + > include/ufs/ufshci.h | 4 ++++ > 5 files changed, 16 insertions(+), 8 deletions(-) > > diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c > index 0787456c2b89..a34ef3aac540 100644 > --- a/drivers/ufs/core/ufs-mcq.c > +++ b/drivers/ufs/core/ufs-mcq.c > @@ -394,11 +394,19 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_make_queues_operational); > > void ufshcd_mcq_enable_esi(struct ufs_hba *hba) > { > - ufshcd_writel(hba, ufshcd_readl(hba, REG_UFS_MEM_CFG) | 0x2, > + ufshcd_writel(hba, ufshcd_readl(hba, REG_UFS_MEM_CFG) | ESI_ENABLE, > REG_UFS_MEM_CFG); This change should be a separate patch. > } > EXPORT_SYMBOL_GPL(ufshcd_mcq_enable_esi); > > +void ufshcd_mcq_enable(struct ufs_hba *hba) > +{ > + ufshcd_writel(hba, ufshcd_readl(hba, REG_UFS_MEM_CFG) | MCQ_MODE_SELECT, > + REG_UFS_MEM_CFG); Use ufshcd_rmwl(). > + hba->mcq_enabled = true; > +} > +EXPORT_SYMBOL_GPL(ufshcd_mcq_enable); > + > void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg) > { > ufshcd_writel(hba, msg->address_lo, REG_UFS_ESILBA); > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index ae9936fc6ffb..8195e01e7a3f 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -8723,10 +8723,7 @@ static void ufshcd_config_mcq(struct ufs_hba *hba) > hba->host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED; > hba->reserved_slot = hba->nutrs - UFSHCD_NUM_RESERVED; > > - /* Select MCQ mode */ > - ufshcd_writel(hba, ufshcd_readl(hba, REG_UFS_MEM_CFG) | 0x1, > - REG_UFS_MEM_CFG); > - hba->mcq_enabled = true; > + ufshcd_mcq_enable(hba); > > dev_info(hba->dev, "MCQ configured, nr_queues=%d, io_queues=%d, read_queue=%d, poll_queues=%d, queue_depth=%d\n", > hba->nr_hw_queues, hba->nr_queues[HCTX_TYPE_DEFAULT], > diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c > index fc61790d289b..1048add66419 100644 > --- a/drivers/ufs/host/ufs-mediatek.c > +++ b/drivers/ufs/host/ufs-mediatek.c > @@ -1219,9 +1219,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) > ufs_mtk_config_mcq(hba, false); > ufshcd_mcq_make_queues_operational(hba); > ufshcd_mcq_config_mac(hba, hba->nutrs); > - /* Enable MCQ mode */ > - ufshcd_writel(hba, ufshcd_readl(hba, REG_UFS_MEM_CFG) | 0x1, > - REG_UFS_MEM_CFG); > + ufshcd_mcq_enable(hba); hba->mcq_enabled flag will be set now which is not done previously. > } > > if (err) > diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h > index d862c8ddce03..a96c45fa4b4b 100644 > --- a/include/ufs/ufshcd.h > +++ b/include/ufs/ufshcd.h > @@ -1257,6 +1257,7 @@ unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba, > struct ufs_hw_queue *hwq); > void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba); > void ufshcd_mcq_enable_esi(struct ufs_hba *hba); > +void ufshcd_mcq_enable(struct ufs_hba *hba); > void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg); > > int ufshcd_opp_config_clks(struct device *dev, struct opp_table *opp_table, > diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h > index d5accacae6bc..e669fad11fd4 100644 > --- a/include/ufs/ufshci.h > +++ b/include/ufs/ufshci.h > @@ -282,6 +282,10 @@ enum { > /* UTMRLRSR - UTP Task Management Request Run-Stop Register 80h */ > #define UTP_TASK_REQ_LIST_RUN_STOP_BIT 0x1 > > +/* REG_UFS_MEM_CFG - Global Config Registers 300h */ > +#define MCQ_MODE_SELECT 0x1 > +#define ESI_ENABLE 0x2 Use BIT() macros. - Mani > + > /* CQISy - CQ y Interrupt Status Register */ > #define UFSHCD_MCQ_CQIS_TAIL_ENT_PUSH_STS 0x1 > > -- > 2.29.0 > -- மணிவண்ணன் சதாசிவம்