Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp15178035rwb; Mon, 28 Nov 2022 08:44:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf7eG3FUtG7lKyMw+D9ynpcceWx/ZqxiOmmakLS7eerzAbs7a6L01SfrS8kmyS++YvDrpP9z X-Received: by 2002:a17:906:3da2:b0:7ac:a2b7:6c96 with SMTP id y2-20020a1709063da200b007aca2b76c96mr42597757ejh.412.1669653861740; Mon, 28 Nov 2022 08:44:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669653861; cv=none; d=google.com; s=arc-20160816; b=F0CNxuTJolQwr7Fz+sI8ta4Dc+tL/ZAFQkq8RModlYfEUEkzTpoV7b295FevqnBOZb 8ZE+ZVwE/AkowBS81U/fMF7yBu+D7kXgGy4pJYRJxfoVkq1anF4tPYl7zCUkAIwqgPeg Gly0dOH0dbhDTQfLvOkfdZNyOwN50zT6uYU8a0oc69h26wTnBZB8OwIou5jOsKe/RZBQ lXnIwTd2dF3DC7/s3GoMPZ8NgfvmEElm+DQDEajPc91cg+3qzLTYuZ/WnLDEQVqYNtA9 jv3Xbma62SbfwJ+gtIUT7iSq0QI3gGxlKGZ0JRhUo3ChfmbmS9Q59w/YqGcNZOVfBmaB le7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Rpy3UTyA+B62gMPP+McxBL9dqkg8u7puKmRFtyplXEM=; b=KWYmKUVbQR6glmTR2csR/mMa5dEMX0bhFhrPeG/EYC9SeuDbhzlC5b++1qQRggRI4Z FG0debrojVkmpwhci34ZY7POSpmQlaNiOA58hXaH5RvTV16bSWpitYXDZIUtpA+NvpOs oTFbE+4zB0ZydgoVgg9z5Sy5nAPirm7Qa4b/ysQHR9KnhE6ROQnZzm1NVYl2b0oZCNtL 0Pp+ANzy5//u7KPIhOdEZV4lBS8UgEOh8IlUJ4xKo6lpB8q5qSI9LPVqh8y8utSLAECf dihcVR6RP/2D1InyNR5jqFFD7s+rpFj6yuZ0aoyw0+Y2A9cY8BlO5ucppbZn0rX09Ywe b9Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SnpeCGRT; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq25-20020a1709073f1900b0078334ccc570si10166147ejc.328.2022.11.28.08.43.57; Mon, 28 Nov 2022 08:44:21 -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=@kernel.org header.s=k20201202 header.b=SnpeCGRT; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231424AbiK1QME (ORCPT + 85 others); Mon, 28 Nov 2022 11:12:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbiK1QLx (ORCPT ); Mon, 28 Nov 2022 11:11:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65E2E62DF; Mon, 28 Nov 2022 08:11:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E7AF461053; Mon, 28 Nov 2022 16:11:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFE9FC433D6; Mon, 28 Nov 2022 16:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669651911; bh=/AfMrRO3Gs++Irv+cSQmDnR4JW658Sic77CmiYl5VTg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SnpeCGRT89ht/EL42vkGT98ucBHJcFrSOQ+mtt9ix1rVW7MqA/gct5mvfce25bpR/ ZAfLBWVx2VSYAdzcUqEcCink0vxW34Rnhz0hp96cPO8B9gdSLIbYIa6y18NwuK5JLB Q15uiUejDU6SoIFJSp2K8aTzBim4Ke0vHpeiygOu3sE5hDWCXfJ2D1AJ/HJCnKLmvm YO+rhT/+w/LNdtNtXyBvyr/yMeoeYnZ6SAH7Rv8m0m7qFtU1NvLu9l+rRnRr/965i3 R5EiErAJ2msu3wNOwVvjv6vSMx6fhymx8uFip8BkYEVnZ+h2Jy3pJVHCjVziIEhrm2 8neFpdDvJrRdQ== Date: Mon, 28 Nov 2022 21:41:34 +0530 From: Manivannan Sadhasivam To: Asutosh Das Cc: quic_cang@quicinc.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, quic_nguyenb@quicinc.com, quic_xiaosenh@quicinc.com, stanley.chu@mediatek.com, eddie.huang@mediatek.com, daejun7.park@samsung.com, bvanassche@acm.org, avri.altman@wdc.com, beanhuo@micron.com, linux-arm-msm@vger.kernel.org, Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , Krzysztof Kozlowski , open list Subject: Re: [PATCH v5 13/16] ufs: core: Prepare for completion in mcq Message-ID: <20221128161134.GL62721@thinkpad> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Tue, Nov 22, 2022 at 08:10:26PM -0800, Asutosh Das wrote: > Modify completion path APIs and add completion queue > entry. > > Co-developed-by: Can Guo > Signed-off-by: Can Guo > Signed-off-by: Asutosh Das Reviewed-by: Manivannan Sadhasivam Thanks, Mani > Reviewed-by: Bart Van Assche > --- > drivers/ufs/core/ufshcd-priv.h | 2 ++ > drivers/ufs/core/ufshcd.c | 80 ++++++++++++++++++++++++++---------------- > 2 files changed, 51 insertions(+), 31 deletions(-) > > diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h > index 14df7ce..6453449 100644 > --- a/drivers/ufs/core/ufshcd-priv.h > +++ b/drivers/ufs/core/ufshcd-priv.h > @@ -61,6 +61,8 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, > int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, > enum flag_idn idn, u8 index, bool *flag_res); > void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); > +void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag, > + struct cq_entry *cqe); > int ufshcd_mcq_init(struct ufs_hba *hba); > int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba); > int ufshcd_mcq_memory_alloc(struct ufs_hba *hba); > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index 52c0386..f16d02c 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -784,12 +784,17 @@ static inline bool ufshcd_is_device_present(struct ufs_hba *hba) > /** > * ufshcd_get_tr_ocs - Get the UTRD Overall Command Status > * @lrbp: pointer to local command reference block > + * @cqe: pointer to the completion queue entry > * > * This function is used to get the OCS field from UTRD > * Returns the OCS field in the UTRD > */ > -static enum utp_ocs ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp) > +static enum utp_ocs ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp, > + struct cq_entry *cqe) > { > + if (cqe) > + return le32_to_cpu(cqe->status) & MASK_OCS; > + > return le32_to_cpu(lrbp->utr_descriptor_ptr->header.dword_2) & MASK_OCS; > } > > @@ -3048,7 +3053,7 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, > * not trigger any race conditions. > */ > hba->dev_cmd.complete = NULL; > - err = ufshcd_get_tr_ocs(lrbp); > + err = ufshcd_get_tr_ocs(lrbp, hba->dev_cmd.cqe); > if (!err) > err = ufshcd_dev_cmd_completion(hba, lrbp); > } else { > @@ -5214,18 +5219,20 @@ ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, int scsi_status) > * ufshcd_transfer_rsp_status - Get overall status of the response > * @hba: per adapter instance > * @lrbp: pointer to local reference block of completed command > + * @cqe: pointer to the completion queue entry > * > * Returns result of the command to notify SCSI midlayer > */ > static inline int > -ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) > +ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, > + struct cq_entry *cqe) > { > int result = 0; > int scsi_status; > enum utp_ocs ocs; > > /* overall command status of utrd */ > - ocs = ufshcd_get_tr_ocs(lrbp); > + ocs = ufshcd_get_tr_ocs(lrbp, cqe); > > if (hba->quirks & UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR) { > if (be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_1) & > @@ -5390,42 +5397,53 @@ static void ufshcd_release_scsi_cmd(struct ufs_hba *hba, > } > > /** > - * __ufshcd_transfer_req_compl - handle SCSI and query command completion > + * ufshcd_compl_one_cqe - handle a completion queue entry > * @hba: per adapter instance > - * @completed_reqs: bitmask that indicates which requests to complete > + * @task_tag: the task tag of the request to be completed > + * @cqe: pointer to the completion queue entry > */ > -static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, > - unsigned long completed_reqs) > +void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag, > + struct cq_entry *cqe) > { > struct ufshcd_lrb *lrbp; > struct scsi_cmnd *cmd; > - int index; > - > - for_each_set_bit(index, &completed_reqs, hba->nutrs) { > - lrbp = &hba->lrb[index]; > - lrbp->compl_time_stamp = ktime_get(); > - lrbp->compl_time_stamp_local_clock = local_clock(); > - cmd = lrbp->cmd; > - if (cmd) { > - if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) > - ufshcd_update_monitor(hba, lrbp); > - ufshcd_add_command_trace(hba, index, UFS_CMD_COMP); > - cmd->result = ufshcd_transfer_rsp_status(hba, lrbp); > - ufshcd_release_scsi_cmd(hba, lrbp); > - /* Do not touch lrbp after scsi done */ > - scsi_done(cmd); > - } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE || > - lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) { > - if (hba->dev_cmd.complete) { > - ufshcd_add_command_trace(hba, index, > - UFS_DEV_COMP); > - complete(hba->dev_cmd.complete); > - ufshcd_clk_scaling_update_busy(hba); > - } > + > + lrbp = &hba->lrb[task_tag]; > + lrbp->compl_time_stamp = ktime_get(); > + cmd = lrbp->cmd; > + if (cmd) { > + if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) > + ufshcd_update_monitor(hba, lrbp); > + ufshcd_add_command_trace(hba, task_tag, UFS_CMD_COMP); > + cmd->result = ufshcd_transfer_rsp_status(hba, lrbp, cqe); > + ufshcd_release_scsi_cmd(hba, lrbp); > + /* Do not touch lrbp after scsi done */ > + scsi_done(cmd); > + } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE || > + lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) { > + if (hba->dev_cmd.complete) { > + hba->dev_cmd.cqe = cqe; > + ufshcd_add_command_trace(hba, task_tag, UFS_DEV_COMP); > + complete(hba->dev_cmd.complete); > + ufshcd_clk_scaling_update_busy(hba); > } > } > } > > +/** > + * __ufshcd_transfer_req_compl - handle SCSI and query command completion > + * @hba: per adapter instance > + * @completed_reqs: bitmask that indicates which requests to complete > + */ > +static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, > + unsigned long completed_reqs) > +{ > + int tag; > + > + for_each_set_bit(tag, &completed_reqs, hba->nutrs) > + ufshcd_compl_one_cqe(hba, tag, NULL); > +} > + > /* > * Returns > 0 if one or more commands have been completed or 0 if no > * requests have been completed. > -- > 2.7.4 > -- மணிவண்ணன் சதாசிவம்