From patchwork Tue Nov 29 18:53:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 27406 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp513295wrr; Tue, 29 Nov 2022 10:59:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf4lR6BdQuRo2yycDIgsP39yObq2Olr6dFbB0+Yhxp7e5cj+fJwu0RSbSgtV09t3zOuv6bsm X-Received: by 2002:a17:906:d7b1:b0:7c0:7cfd:3195 with SMTP id pk17-20020a170906d7b100b007c07cfd3195mr7421290ejb.418.1669748391290; Tue, 29 Nov 2022 10:59:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669748391; cv=none; d=google.com; s=arc-20160816; b=ttbYxOX/slC9o8Ldr61HZ+XifQhLsWnipUwkfebydsJM9pgKoDkNTgJhELBU4mXXxv c5lE1GgIcyOXoVszgQKwxAhvyLfNqpdX3ixT4HGV0t/z1uh044CDvYMIY8WhB9VfqJAt ryvJuCTsJHFD6f5Hs5B2WW6SGh3aL5hRINCj8P43EdDWyPub7qlD59IleoBQVuuTJqbB S9bbcceigULaC9wxto91b10D/jMPc2YIlkwCogeP5M0pkpJtTYFCd0e5mZ2aS/1IrmCS 6gN/ty/bi48Nk0wAUEkIyW5ku1eQGm3Jsc8N6tY0B4ZyoBWBvlc5Qk8QFcYNLO537fGP luNQ== 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=VeII6TNs3qHjY1YJMc/qxFwPXoxlFgkI51Ff3SWFw2CRAgfvEj+UGWOVHnSbkekBVm ypKiEV30X5X1x79X0IfQAHSqJiRsvSocB0NTIORFbxZSfC3x+YlhtKOcopOAeJ4BU4G+ p2nSN+UPYhGomdkBoWHnoQGUr6nB10E7s6x+xkulAwgC/V5vyVMO7BO0LF/UyeB1i/z7 wbhD9Se6LZR5M8jZdWM0HnZ3escgwB9RSSI75EdTrDq4YzfnwJC7Z0Wsgk6KMQCCiqX7 6/3qbnHMuBCDsOv4yib2sF7X/CgCPYQUUw3Yuy4XcWjtKhRYohoYpJO/lDpauW2gYT/9 cW3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mYEZLUik; 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 wz2-20020a170906fe4200b0078e176ef65csi13582570ejb.723.2022.11.29.10.59.23; Tue, 29 Nov 2022 10:59:51 -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=mYEZLUik; 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 S236410AbiK2S5n (ORCPT + 99 others); Tue, 29 Nov 2022 13:57:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236369AbiK2S4u (ORCPT ); Tue, 29 Nov 2022 13:56:50 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40FCD6C73E; Tue, 29 Nov 2022 10:56:31 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ATIqxiG022323; Tue, 29 Nov 2022 18:56:19 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=mYEZLUikyTlO+1DEFzhcd7vAsemzEiVIgkd5ukeybjOz7dDAv8AWcp3i57z8RtpHHgh1 fm3Ek0zyZI6Oyyp6mhOCr+FAPrcZX5SjEKA4U7bxu3ZXfFi8cUPb/SO/esc24wHitfpu PKImeEXd5xXw8a8Mn3fWX2CaD7xSRZu2SR5YnBcVK4lEoNysDKNiPJendK+0TgEE0QtJ 0HUOEY//x/WZ1bK2vVaZu9tUz7gVcwzmudroUpeggKhR7hi3RKYRxyfVnSkfF9tx0eCH rTj2ad2fhwOsWA0HmGY6cLRmuwxi5ZDlNTMhmO6/7luhpVtixkPYPAz0j9C5WNMUl94c 4Q== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m5n1rrka9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 29 Nov 2022 18:56:19 +0000 Received: from nasanex01a.na.qualcomm.com (corens_vlan604_snip.qualcomm.com [10.53.140.1]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2ATIuIZ0030125 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 29 Nov 2022 18:56:18 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; Tue, 29 Nov 2022 10:56:18 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Krzysztof Kozlowski , Jinyoung Choi , open list Subject: [PATCH v7 12/16] ufs: core: mcq: Find hardware queue to queue request Date: Tue, 29 Nov 2022 10:53:18 -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: 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-GUID: 3YK4b0HCLXxOsS2MuGgHBT-2N9S6Cu0w X-Proofpoint-ORIG-GUID: 3YK4b0HCLXxOsS2MuGgHBT-2N9S6Cu0w 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-29_11,2022-11-29_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 spamscore=0 adultscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211290108 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?1750858089221673197?= X-GMAIL-MSGID: =?utf-8?q?1750858089221673197?= 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: