From patchwork Wed Nov 9 19:41:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 17790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp528555wru; Wed, 9 Nov 2022 11:47:56 -0800 (PST) X-Google-Smtp-Source: AMsMyM5dkft4NPW96/aNexVV5SsjuRr9kVyujLQTur230QQGZ5pPDKgl6RSB+Odv+DdlREFkauQd X-Received: by 2002:a05:6402:2a03:b0:463:11e7:cd5f with SMTP id ey3-20020a0564022a0300b0046311e7cd5fmr56897349edb.274.1668023276087; Wed, 09 Nov 2022 11:47:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668023276; cv=none; d=google.com; s=arc-20160816; b=t1KXVb+a8GpUcPQ/RCafk1BTnyR+rI9DpQ/ZTqoljijWcukZNUEa1Z5XPQkq8HsQGq kpELJZJvQg/NhEbZ+kMknIFGL21xzTdl+u6iwlWsf1zuoIjPED11hhD5c7b6vfNE8qBS aC9JgeXxT/1sGre6dUoJGgSjWF7FiJxY5pLgrUysm8TEKNyVuwykqRVfqsHcCjlO0nbi Tpe+RP069mm5fj7L8AEa6Nyi/skdpFutI3oPi9MrY16sYBC6bAhagcZhPra20B9pUaoc o7fouXvW4BJIXNTj39FLvpLZYnWYXUBRXbsvSxAoq+pkoXyKZza5aWfBx1mRgJQZybVj 5iTg== 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=3YRrUNeL66JCNcPfJ7eQHnz9OHs6PWOaavo3jhRSQlY=; b=D2IOcKsUTs+U7mtSeJ+VDr7XNf0dX2nDuq9ves3/1SWLPkigCFSr6lrHboTjNkpgF4 945grAoQ/Yb3YjnOvbQyhdDHJyMYpaHMgYvBx//fc9htXLL4UIvz38Xqi0m4Zv7lRgi2 UNQYGR5NRj0YXV9POxdkNyR+CZKGjqds9GxELQBlVwhiVzkJomBRe7POGwxqJxR03KNB rbec7X8RKoPP+Mci/1BwfBqoPtNNggwdPsbF9oblbnvVIY/ssE+QYLlKmTgcroN3d2Qf uKUEff6c5RK9DE1KtRfZJI6pCgoKXYIWpaB222brT1HhBBF3EVJA4fkc4yU4HtIGXQlY Gi8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=E7QUrboO; 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 ga14-20020a1709070c0e00b007ae6869f9d9si12164599ejc.419.2022.11.09.11.47.32; Wed, 09 Nov 2022 11:47:56 -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=E7QUrboO; 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 S231846AbiKITqJ (ORCPT + 99 others); Wed, 9 Nov 2022 14:46:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232025AbiKITpo (ORCPT ); Wed, 9 Nov 2022 14:45:44 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA70F303C1; Wed, 9 Nov 2022 11:45:26 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2A9GoBpA008696; Wed, 9 Nov 2022 19:45:13 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=3YRrUNeL66JCNcPfJ7eQHnz9OHs6PWOaavo3jhRSQlY=; b=E7QUrboO3bFDuXq0hpg5AX/cQtTer9Y6TKdmr4AJ6XsFTVDJevcRBXluDd6CVsbOJLl2 sIIH8JNB8a1ZJRvGq69U6u9gnUvQEb/hCTu1HuO1T+Z66d977yhhiz9XuGDbe1Vvc7Zf Hq76V0wv2WcC6VyN9tc99+bNDNaWZAMY20Xgu1E3BCtZtBusWls8CsZwmrCm6WZbVOMe n3uOdTWKCPTy6GFQS3vfXvmTrbpXE4TGvmKYzK6VXuCyeJpRhb/XFR9KXSNbDmIQkrj4 2IXVJsg4PjmEV0DckIdGkw1UeEAhncp3q9m/Zmp10bVoCzoyvx2ZGujLUpAgD58MFtcr AA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3krg2q8jdw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Nov 2022 19:45:13 +0000 Received: from nasanex01a.na.qualcomm.com (corens_vlan604_snip.qualcomm.com [10.53.140.1]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2A9JjCEY012500 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 9 Nov 2022 19:45:12 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.29; Wed, 9 Nov 2022 11:45:12 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , Arthur Simchaev , open list Subject: [PATCH v4 12/16] ufs: core: mcq: Find hardware queue to queue request Date: Wed, 9 Nov 2022 11:41:37 -0800 Message-ID: <509dbf6ee45764419c94488d8062ec07c188eaa5.1668022680.git.quic_asutoshd@quicinc.com> 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: nasanex01a.na.qualcomm.com (10.52.223.231) 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-ORIG-GUID: JnlgguzDNS-jXLFm3V1a7ne2vu0CiEgO X-Proofpoint-GUID: JnlgguzDNS-jXLFm3V1a7ne2vu0CiEgO 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-09_06,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 clxscore=1015 phishscore=0 adultscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211090149 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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?1749049175045039113?= X-GMAIL-MSGID: =?utf-8?q?1749049175045039113?= 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 --- drivers/ufs/core/ufs-mcq.c | 20 ++++++++++++++++++++ drivers/ufs/core/ufshcd-priv.h | 3 +++ drivers/ufs/core/ufshcd.c | 3 +++ 3 files changed, 26 insertions(+) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 28f217e..41ce70a 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -94,6 +94,26 @@ static const struct ufshcd_res_info ufs_res_info[RES_MAX] = { }; /** + * 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 5616047..14df7ce 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 12c59fa..29a335a 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: