Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp296231iol; Thu, 9 Jun 2022 04:10:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQ9OZd34F441EQb/CgHUPYkOQCmuG0d83JQXut3+Oq41IB3qRbakrNnMABtFU3jLUp8pE/ X-Received: by 2002:a17:90b:4d81:b0:1e3:33e9:6677 with SMTP id oj1-20020a17090b4d8100b001e333e96677mr2886675pjb.116.1654773050807; Thu, 09 Jun 2022 04:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654773050; cv=none; d=google.com; s=arc-20160816; b=hZfxzBZCex9mrSTI9n76ih36jTeH8c0jMj/2NvTVNNxeFS4yvZJBlu+Iee9hde2D5f CCiPmo7gJxJssOvg5KiFHEhmY/hcdeEGLlEnUItZ4PuLxHm7bQbMM/y08rKa6OEnC9Ij WW1Z/2nOkBbxeggWi1OdLS5SwM6Cvz9fJtTvmccajN/ZIhe9NfQRr8bXRGQnkPQSHMuF 3QQcow5X1Exso4I4ROHB9cJQnOiPC1YlHOC1bSbZw3iXwgeNONEJYts/6ddUkMx7Syqp 55Ta4m84kGcl9MnRFa2dXjWx3ZGUky8crQc6XKVuLGo2pIwk7IGvs1FqUIvlshDffHv7 nzlQ== 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=0yGv40t0hHHsFt9W8GMArBArM94CUompUtjBb9e1AGY=; b=b/eitkv6MTrckHIroWm89d1Zdlb1NT6E2IzdF7Up8+8s/HMC+QYTHbqZb9vnMZz0a9 A5wyr3GFh8WvC0043fd5YV1kueQ01mNEuuNjGnNr5LB0yfDEnR6IL3CI5bOruDj6ylv9 6MNShc8gnCPm1C6bCdFNnxhCyT8Bms1aqOwn4/oSo/d227PlUrNqsTpd3Ati3bwpQsDc cd8NqnS+80b3uGfLujb1XauyS2SZvXesajad9lLq9AMIIi0eKFZrdiCErcAKh3w4qV0h nhaiiNHbFLDazPJcz2iklE6UhQBPHcaJYrkeAUp70m+LbllKUbpcERvFyursDRG8TB3Y pAMQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a056a0000d000b005109299b02fsi30275288pfj.113.2022.06.09.04.10.37; Thu, 09 Jun 2022 04:10:50 -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 S243256AbiFIKh3 (ORCPT + 99 others); Thu, 9 Jun 2022 06:37:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243090AbiFIKgx (ORCPT ); Thu, 9 Jun 2022 06:36:53 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D3DD215659; Thu, 9 Jun 2022 03:36:31 -0700 (PDT) Received: from fraeml711-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LJgTW6TRpz67bS0; Thu, 9 Jun 2022 18:35:11 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml711-chm.china.huawei.com (10.206.15.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 9 Jun 2022 12:36:29 +0200 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 9 Jun 2022 11:36:26 +0100 From: John Garry To: , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v2 10/18] libata/scsi: libsas: Add sas_queuecommand_internal() Date: Thu, 9 Jun 2022 18:29:11 +0800 Message-ID: <1654770559-101375-11-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1654770559-101375-1-git-send-email-john.garry@huawei.com> References: <1654770559-101375-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Add a callback for sht reserved_queuecommand callback. We need to add libata helper ata_is_scmd_ata_internal() as it is difficult to know whether the request should be queued as an ATA internal command. We will store the sas_task in the scsi_cmnd payload also in future. Signed-off-by: John Garry --- drivers/ata/libata-core.c | 8 ++++++++ drivers/scsi/libsas/sas_scsi_host.c | 21 +++++++++++++++++++++ include/linux/libata.h | 1 + include/scsi/libsas.h | 8 ++++++++ 4 files changed, 38 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 6b1aaeccb253..a9645951a0f0 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -1454,6 +1454,14 @@ static void ata_internal_end_rq(struct request *rq, blk_status_t error) complete(waiting); } +bool ata_is_scmd_ata_internal(struct scsi_cmnd *scmd) +{ + struct request *rq = scsi_cmd_to_rq(scmd); + + return rq->end_io == ata_internal_end_rq; +} +EXPORT_SYMBOL_GPL(ata_is_scmd_ata_internal); + /** * ata_exec_internal_sg - execute libata internal command * @dev: Device to which the command is sent diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 9c82e5dc4fcc..42279a6d6b06 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -158,6 +158,27 @@ static struct sas_task *sas_create_task(struct scsi_cmnd *cmd, return task; } +int sas_queuecommand_internal(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) +{ + struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost); + struct sas_internal *i = to_sas_internal(ha->core.shost->transportt); + struct request *rq = scsi_cmd_to_rq(cmnd); + + if (ata_is_scmd_ata_internal(cmnd)) { + struct ata_queued_cmd *qc = (struct ata_queued_cmd *)cmnd->host_scribble; + struct ata_port *ap = qc->ap; + int res; + + spin_lock_irq(ap->lock); + res = ata_sas_queuecmd(cmnd, ap); + spin_unlock_irq(ap->lock); + return res; + } + + return i->dft->lldd_execute_task(sas_rq_to_task(rq), GFP_KERNEL); +} +EXPORT_SYMBOL_GPL(sas_queuecommand_internal); + int sas_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) { struct sas_internal *i = to_sas_internal(host->transportt); diff --git a/include/linux/libata.h b/include/linux/libata.h index 5fa6f56bba81..6cb7a5bcb308 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1238,6 +1238,7 @@ extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *); extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap); extern void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis); +extern bool ata_is_scmd_ata_internal(struct scsi_cmnd *scmd); extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf); extern int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active); extern bool sata_lpm_ignore_phy_events(struct ata_link *link); diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index ff04eb6d250b..261169ffdca6 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -725,6 +725,7 @@ int sas_discover_sata(struct domain_device *); int sas_discover_end_dev(struct domain_device *); void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *); +int sas_queuecommand_internal(struct Scsi_Host *shost, struct scsi_cmnd *cmnd); void sas_init_dev(struct domain_device *); @@ -756,4 +757,11 @@ void sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event, void sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event, gfp_t gfp_flags); +static inline struct sas_task *sas_rq_to_task(struct request *rq) +{ + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); + + return (struct sas_task *)(scmd + 1); +} + #endif /* _SASLIB_H_ */ -- 2.26.2