From patchwork Tue Nov 29 01:20:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 27010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp56524wrr; Mon, 28 Nov 2022 17:25:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf4yTL8qyYDAbOlxvYQGygH/GTajJeeOT7dLMzkN5GgnZAFdJ3YeefTTnk6cIoVi78IaGoxK X-Received: by 2002:a62:5e41:0:b0:56b:db09:a235 with SMTP id s62-20020a625e41000000b0056bdb09a235mr36183282pfb.20.1669685134949; Mon, 28 Nov 2022 17:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669685134; cv=none; d=google.com; s=arc-20160816; b=oT8bOXD0t1BjACBAJllbwWSzDb5QkZtvrxomWc9wE5o4kAs7QTvu+HjdraDL7yPA/5 wTa3CrYKHZN+5etHvtMwmFicgkWe2y7Q59yFr+Y4C5N1S+1AK9Mq7XbElJ6toAI8Tk60 5durcT9kA32frWgCUfi0A+NV56raa4QdC0durm2OnK9HCi4c2708aFb9jUfa9LdeLt4L 6PpcLMe9GGY7iaUviXnMoAOSjn6WOUwkP1QI0DuKiG63wbRoGyBtefhXLgvSrpOZqSEW kGZsaajLzr8O34O9ntoex+KjFSiEKHFVeu0C761qQ9dYVYZej8FOe8ZGghnJtRvPyXRy 4Waw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bCtcUnuQx784SPpXFevZhrx6T0D8/QPhSZ/6TBnLv6Q=; b=DTfFocqyGF8viOOkvsdDI50qhP0+PQNd1yopxinHtFGa7SwusDJ8sGYktZyaTOYt91 sckuYLYb+qPr1yl1d5JZaMG7MmNByWiP1CeI1V1DG1m4H9hZ2Ee+/UUMIpFnRWgM5JEF 71WwLmEzWK6faD0Eua9g04w/pwndO0S/+nDVSXQV78om7OMMY1GPmocuj7d+aFhG1ONk CKaqY8eu3XeJwrSYaWB6z5kUXySAzpISQkOERvBEpcTAWhMEjC6kPRAJ+VI5tGwb/qZz rl9me/2izBq/DkC30J9LyjsK7iW6VT6sxp/c9gibCuNwwnLgl/KcjTcFxpenXVhUzmmE ZGPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="dG9fNzr/"; 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 s23-20020a056a00179700b0056ea2b142b6si13938163pfg.373.2022.11.28.17.25.22; Mon, 28 Nov 2022 17:25:34 -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="dG9fNzr/"; 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 S234676AbiK2BXy (ORCPT + 99 others); Mon, 28 Nov 2022 20:23:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234983AbiK2BXo (ORCPT ); Mon, 28 Nov 2022 20:23:44 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFCF62AE31; Mon, 28 Nov 2022 17:23:43 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AT19RZG006990; Tue, 29 Nov 2022 01:23:29 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 : mime-version : content-type; s=qcppdkim1; bh=bCtcUnuQx784SPpXFevZhrx6T0D8/QPhSZ/6TBnLv6Q=; b=dG9fNzr/E9wuXAKfnjK5zPrQIWW2DirensyQmssNK886oo17buXWM7fqJiWaeR3PJSjY tfcVk6Q8FUHzXpY232ns5MWzBkG53GG3egQkCypZUHX+WNFqPQb6Nsqgmt0LT2UAxWH/ SMabPOzQbhDcF1TGIOzgQTcrvg7Ry8q1MMVQuzQKazEKsN8heGzlZbxgESv9pCoWtqqd EO02Gf1AGtJCGHiPJc4cBXG++YN9kyeRj832mZxRvDSMJQLTRFSlfEnrZiVUSOTOkhNw 7ZqQz6qlqGIgqBzB72a8wur3AOCdfIwYCgUXcMiwxXLYbt7Y9Bm88EwNZZJ8kgxNcmu7 Xw== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m57rjg2by-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 29 Nov 2022 01:23:29 +0000 Received: from nasanex01a.na.qualcomm.com ([10.52.223.231]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2AT1NSZY012877 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 29 Nov 2022 01:23:28 GMT Received: from asutoshd-linux1.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 28 Nov 2022 17:23:28 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Arthur Simchaev , Jinyoung Choi , open list Subject: [PATCH v6 12/16] ufs: core: mcq: Find hardware queue to queue request Date: Mon, 28 Nov 2022 17:20:53 -0800 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: YtFB2n7p8tNTxYgbTUCyBQCnsgRcyfHN X-Proofpoint-ORIG-GUID: YtFB2n7p8tNTxYgbTUCyBQCnsgRcyfHN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-28_17,2022-11-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 malwarescore=0 spamscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211290006 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750791760356013393?= X-GMAIL-MSGID: =?utf-8?q?1750791760356013393?= Adds support to find the hardware queue on which the request would be queued. Since the very first queue is to serve device commands, an offset of 1 is added to the index of the hardware queue. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufs-mcq.c | 19 +++++++++++++++++++ drivers/ufs/core/ufshcd-priv.h | 3 +++ drivers/ufs/core/ufshcd.c | 3 +++ 3 files changed, 25 insertions(+) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 0c40fe2..151caf3 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -93,6 +93,25 @@ void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds) } /** + * ufshcd_mcq_req_to_hwq - find the hardware queue on which the + * request would be issued. + * @hba - per adapter instance + * @req - pointer to the request to be issued + * + * Returns the hardware queue instance on which the request would + * be queued. + */ +struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba, + struct request *req) +{ + u32 utag = blk_mq_unique_tag(req); + u32 hwq = blk_mq_unique_tag_to_hwq(utag); + + /* uhq[0] is used to serve device commands */ + return &hba->uhq[hwq + UFSHCD_MCQ_IO_QUEUE_OFFSET]; +} + +/** * ufshcd_mcq_decide_queue_depth - decide the queue depth * @hba - per adapter instance * diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index 8fe936e..8b03a29 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -67,7 +67,10 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba); void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba); void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds); void ufshcd_mcq_select_mcq_mode(struct ufs_hba *hba); +struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba, + struct request *req); +#define UFSHCD_MCQ_IO_QUEUE_OFFSET 1 #define SD_ASCII_STD true #define SD_RAW false int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 1639a97..b0b0f2c 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2921,6 +2921,9 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) goto out; } + if (is_mcq_enabled(hba)) + hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd)); + ufshcd_send_command(hba, tag, hwq); out: