From patchwork Tue Oct 18 11:15:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 4080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1886190wrs; Tue, 18 Oct 2022 03:49:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ZWYhH5rEkEcgVyNkdLzC8Yua2DWoHANCQbHrepZ+/tQUlQuPh+ZsnlqQD/7Zs5t0mCX0z X-Received: by 2002:a17:90b:1d03:b0:20d:a935:944e with SMTP id on3-20020a17090b1d0300b0020da935944emr2920463pjb.38.1666090144302; Tue, 18 Oct 2022 03:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666090144; cv=none; d=google.com; s=arc-20160816; b=lv5w+VAD/L3dR7b1P8OtTZM+2Lic2bgQE0JTGDWPrQUO2tsYt1Kc+za47Q4/N37m+z 7XD1+u29lqB+eebR3bQswe2DQBKvPj9IWnM8JnqF9GC34ArQYlj8cMRLl5IiV0cU4Ntn zqCR8zazWh/XqmyUkFikuTRIihDmgJ5pXta4L4cUpi7og8Y9swToGQ+LIFWK69eL65sR QGs3ZL8mS5LxHhjBucnyk01QtD5FaTFLrZbkj7PjM/yyNktD4b+ZqFduGz2igK1CBLou EkuOkP02i5wprcRvLC7CLuckWKi1Q2irhwtA++58VRY3lGHT76iFd14Hgi8toNkl8c+M ffgA== 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; bh=dTPG+D/jdpmq5VFOmlYMqd3g9QXR8Md6jeMos3e9ZNY=; b=LlOhsg6qGF9spo9qdAir7FYchWpPI8PHTna9oYl/VDlxchXTfPaco4T8mhDCudedAA P8y8nSSEcT9vFpQW2uIeLSm260pdBSSRUG/yttY5SIyQSZ2n9OIIy8OZY56D7P6yzCug y3RTGbMMNkPcFVoIBGrIEfAADNwapxNFzvW1Dui6xcy90p/r7j6Dg5zJ7puYjnEUiJAv 6kzQTWYErrMMA2Dj6zZMKi8a6PVg5BFO+g5obYrw4EpES1dClqeuLZbSAxXay+pBA+e1 Ha7AlIcqB9kJbh2jqXjuNDnl2ERKvrh8+vtTIEQn9xeDAIINRp9bosDty2O1bVbXUnqU aBNA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a170902ea0400b00182631bdf78si6126367plg.222.2022.10.18.03.48.51; Tue, 18 Oct 2022 03:49:04 -0700 (PDT) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbiJRKqB (ORCPT + 99 others); Tue, 18 Oct 2022 06:46:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbiJRKpr (ORCPT ); Tue, 18 Oct 2022 06:45:47 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B28B44A5; Tue, 18 Oct 2022 03:45:45 -0700 (PDT) Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Ms9TF2yy5z67hlj; Tue, 18 Oct 2022 18:44:01 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 12:45:44 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 11:45:41 +0100 From: John Garry To: , , , CC: , , , , , , John Garry Subject: [PATCH v4 2/7] scsi: hisi_sas: Use sas_task_find_rq() Date: Tue, 18 Oct 2022 19:15:58 +0800 Message-ID: <1666091763-11023-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1666091763-11023-1-git-send-email-john.garry@huawei.com> References: <1666091763-11023-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,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?1747022139434142301?= X-GMAIL-MSGID: =?utf-8?q?1747022139434142301?= Use sas_task_find_rq() to lookup the request per task for its driver tag. Signed-off-by: John Garry Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke --- drivers/scsi/hisi_sas/hisi_sas_main.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 10813836a728..26e474b0f53f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -177,13 +177,13 @@ static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx) } static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, - struct scsi_cmnd *scsi_cmnd) + struct request *rq) { int index; void *bitmap = hisi_hba->slot_index_tags; - if (scsi_cmnd) - return scsi_cmd_to_rq(scsi_cmnd)->tag; + if (rq) + return rq->tag; spin_lock(&hisi_hba->lock); index = find_next_zero_bit(bitmap, hisi_hba->slot_index_count, @@ -461,11 +461,11 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) struct asd_sas_port *sas_port = device->port; struct hisi_sas_device *sas_dev = device->lldd_dev; bool internal_abort = sas_is_internal_abort(task); - struct scsi_cmnd *scmd = NULL; struct hisi_sas_dq *dq = NULL; struct hisi_sas_port *port; struct hisi_hba *hisi_hba; struct hisi_sas_slot *slot; + struct request *rq = NULL; struct device *dev; int rc; @@ -520,22 +520,12 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) return -ECOMM; } - if (task->uldd_task) { - struct ata_queued_cmd *qc; - - if (dev_is_sata(device)) { - qc = task->uldd_task; - scmd = qc->scsicmd; - } else { - scmd = task->uldd_task; - } - } - - if (scmd) { + rq = sas_task_find_rq(task); + if (rq) { unsigned int dq_index; u32 blk_tag; - blk_tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd)); + blk_tag = blk_mq_unique_tag(rq); dq_index = blk_mq_unique_tag_to_hwq(blk_tag); dq = &hisi_hba->dq[dq_index]; } else { @@ -580,7 +570,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) if (!internal_abort && hisi_hba->hw->slot_index_alloc) rc = hisi_hba->hw->slot_index_alloc(hisi_hba, device); else - rc = hisi_sas_slot_index_alloc(hisi_hba, scmd); + rc = hisi_sas_slot_index_alloc(hisi_hba, rq); if (rc < 0) goto err_out_dif_dma_unmap;