From patchwork Tue Oct 18 11:15:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 4079 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1886163wrs; Tue, 18 Oct 2022 03:48:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6B6ylYaSYktGYQ3KwzcCuIvX4oTHUGfG6jKBSDSMCKbOkglcwMCPqokFbMafJYuDDgfSaH X-Received: by 2002:a17:902:ea06:b0:185:4c1f:7460 with SMTP id s6-20020a170902ea0600b001854c1f7460mr2362977plg.99.1666090137659; Tue, 18 Oct 2022 03:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666090137; cv=none; d=google.com; s=arc-20160816; b=hx6h/rR+JLUBKlhB+Q4Bgspd9O63Fl6HFRXB0qreq51wLlXk5vLEuX/ZwBG7HrHkQl MJnAPNY0xLTLi5kGkM1lJ+BrZs8mdN/H45uTMlNvTKcyVMjWdv1W2wt7l9RpzJdeAq4Y quR9s05yvJA4RIfqZSG1unB2+/r6s7KLvv4UTg7a3buuMONUG8FtvKM8Z6gL2Co7dGqM YZLDr5ztO6W0A9XwUrqSWZdn3UwAl8bdBfhvIsiuPhc9xSiCvJJIpixqLpSxcqiFFC/v 9S+A2MTOPQlTkXt+du0bDJyw25w6d8akWIsLYztUOa707h+XJMmCEsCDE1kqhBMk5H5D 1mkw== 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=9qqy2n8XCEnpGHPhZm+XKXMBxulGJAWMHigT2bsw3b0=; b=CPt+WUVnw4AtfpUjlFTAC41iwYrGeWSRI60Je/vtZo5u9TIf65pDk2TEP29As9krRj 79Ow/VE/JftWocdrCEZrIybtcdKrtihqSk8QDHPfeMQVmRJANfGppRN80DQwJSt4i2Rm mFcG1I2RBPGXkgwzh/ELQiknNgNNgucsnM/zP1Rl8xb0onCtHjEvm02aksy2CVAzcbhU JDGgoWULriqYmVUV3+I+3dviGQ/UZgVqO/PNlDu0V5Rr6hQez3ofoytKb4FUHx9PWpdy MX/1ItLvpyBP/Bndq/tkb7PHlXaKrO6SHlTpQVYEUzYcmCUcFQohFqdhMA9X/Kn6DMzD HUPA== 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 f7-20020a056a001ac700b0056157a571f6si14751016pfv.191.2022.10.18.03.48.44; Tue, 18 Oct 2022 03:48:57 -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 S229880AbiJRKp5 (ORCPT + 99 others); Tue, 18 Oct 2022 06:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbiJRKpn (ORCPT ); Tue, 18 Oct 2022 06:45:43 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CED15B4892; Tue, 18 Oct 2022 03:45:42 -0700 (PDT) Received: from fraeml734-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Ms9TB287pz67NY6; Tue, 18 Oct 2022 18:43:58 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml734-chm.china.huawei.com (10.206.15.215) 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:41 +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:37 +0100 From: John Garry To: , , , CC: , , , , , , John Garry Subject: [PATCH v4 1/7] scsi: libsas: Add sas_task_find_rq() Date: Tue, 18 Oct 2022 19:15:57 +0800 Message-ID: <1666091763-11023-2-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?1747022132468053892?= X-GMAIL-MSGID: =?utf-8?q?1747022132468053892?= blk-mq already provides a unique tag per request. Some libsas LLDDs - like hisi_sas - already use this tag as the unique per-IO HW tag. Add a common function to provide the request associated with a sas_task for all libsas LLDDs. Signed-off-by: John Garry Reviewed-by: Jack Wang Reviewed-by: Jason Yan Reviewed-by: Hannes Reinecke --- include/scsi/libsas.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index ec6c9ecd8d12..1aee3d0ebbb2 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -644,6 +644,24 @@ static inline bool sas_is_internal_abort(struct sas_task *task) return task->task_proto == SAS_PROTOCOL_INTERNAL_ABORT; } +static inline struct request *sas_task_find_rq(struct sas_task *task) +{ + struct scsi_cmnd *scmd; + + if (task->task_proto & SAS_PROTOCOL_STP_ALL) { + struct ata_queued_cmd *qc = task->uldd_task; + + scmd = qc ? qc->scsicmd : NULL; + } else { + scmd = task->uldd_task; + } + + if (!scmd) + return NULL; + + return scsi_cmd_to_rq(scmd); +} + struct sas_domain_function_template { /* The class calls these to notify the LLDD of an event. */ void (*lldd_port_formed)(struct asd_sas_phy *);