Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp13023pxm; Tue, 22 Feb 2022 05:27:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9R74s+lg9+U/EOmMUIMND+nRnXBzT/K2+zGXTtf/LwJbCrVRHhiwQb31qC7DkXvqzppKi X-Received: by 2002:a17:906:d8dc:b0:6cf:d1d1:db25 with SMTP id re28-20020a170906d8dc00b006cfd1d1db25mr19562863ejb.285.1645536447690; Tue, 22 Feb 2022 05:27:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645536447; cv=none; d=google.com; s=arc-20160816; b=0BVCZPTiweBUnuKr1T5Vg/E97yhwy8Jl2YHI5Uminro1CFvVFtKp8z6bLZHk+lMjrp hPFK+7cMHhfh5OFb/+4Dl5L/Hp6jxziZjKNwnVDB7VIq6yDma4ZlB/oSKewXTkOPZvWO 6jRW0f4kZ9WJMg+eYpMzvWm9pya0ftWe9K6qOg5PZVCuKUcjnTR6RfoCIKpLqMs4Lw61 uagXlv7/s0lc8NgGzyLCqH7jOAVnoTMJ/AQBJweApTyDM8+kSZqrI9EiC32cSd2vzizg /4e6eMkD22F2O2E/GnVamSrNBqy33+7+a8BZCy/8s5OfZPe20Ko6ZBpHBlZAJfJi0Em0 decA== 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=N7uptTKbCdyQ2eHl9h0vIjHiBcILBHkar4IjwgDtdXE=; b=EoYIVnT4U/EXF0AFFMXoRdTKluKlCYGKASY07PgT9so66QAwK8Ok4oYBX8lrgm2xZr phxdjPtGjKLMWVhGpDZ+28K6tl/x5nvV7iqbJb/AEK4b4Sf8XJYwFUT6Uq6uMhTQMoe7 nUY5c11ZdnMBIbmRgOqXO9896RLrKOsptDVzJ4ofH7mUG25fr0ItkBsqWpdBVuAf5rgI KYlBFnfz/ssRWm69rqTVW+H0NQrjFrAx2pdJk/MhQ//H3d8kcF/zYPa1dOgWxwxgSiR6 wELxxWKep8gEH2/YCaGzAAqt93AnWO6sON4YhcMQ09Jb7Mz454X6de9q/vz8VOx9nva3 9+Ag== 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 i12si6990232ejd.37.2022.02.22.05.27.04; Tue, 22 Feb 2022 05:27:27 -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; 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 S231894AbiBVM5h (ORCPT + 99 others); Tue, 22 Feb 2022 07:57:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232102AbiBVM52 (ORCPT ); Tue, 22 Feb 2022 07:57:28 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 733BD93191; Tue, 22 Feb 2022 04:56:57 -0800 (PST) Received: from fraeml703-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4K2zZz4KYPz680Bm; Tue, 22 Feb 2022 20:52:11 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml703-chm.china.huawei.com (10.206.15.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.21; Tue, 22 Feb 2022 13:56:55 +0100 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.2308.21; Tue, 22 Feb 2022 12:56:52 +0000 From: John Garry To: , , , , , , CC: , , , , , , , , John Garry Subject: [PATCH v3 06/18] scsi: libsas: Move SMP task handlers to core Date: Tue, 22 Feb 2022 20:50:47 +0800 Message-ID: <1645534259-27068-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1645534259-27068-1-git-send-email-john.garry@huawei.com> References: <1645534259-27068-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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 Move the SMP task handlers to the core host code as they will be re-used for executing internal abort and TMF tasks. Signed-off-by: John Garry Reviewed-by: Christoph Hellwig Tested-by: Yihang Li Tested-by: Damien Le Moal --- drivers/scsi/libsas/sas_expander.c | 24 ++---------------------- drivers/scsi/libsas/sas_internal.h | 3 +++ drivers/scsi/libsas/sas_scsi_host.c | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 6abce9dfc17b..260e735d06fa 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -28,26 +28,6 @@ static int sas_disable_routing(struct domain_device *dev, u8 *sas_addr); /* ---------- SMP task management ---------- */ -static void smp_task_timedout(struct timer_list *t) -{ - struct sas_task_slow *slow = from_timer(slow, t, timer); - struct sas_task *task = slow->task; - unsigned long flags; - - spin_lock_irqsave(&task->task_state_lock, flags); - if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { - task->task_state_flags |= SAS_TASK_STATE_ABORTED; - complete(&task->slow_task->completion); - } - spin_unlock_irqrestore(&task->task_state_lock, flags); -} - -static void smp_task_done(struct sas_task *task) -{ - del_timer(&task->slow_task->timer); - complete(&task->slow_task->completion); -} - /* Give it some long enough timeout. In seconds. */ #define SMP_TIMEOUT 10 @@ -78,9 +58,9 @@ static int smp_execute_task_sg(struct domain_device *dev, task->smp_task.smp_req = *req; task->smp_task.smp_resp = *resp; - task->task_done = smp_task_done; + task->task_done = sas_task_internal_done; - task->slow_task->timer.function = smp_task_timedout; + task->slow_task->timer.function = sas_task_internal_timedout; task->slow_task->timer.expires = jiffies + SMP_TIMEOUT*HZ; add_timer(&task->slow_task->timer); diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h index acd515c01861..cd6aa723c3e1 100644 --- a/drivers/scsi/libsas/sas_internal.h +++ b/drivers/scsi/libsas/sas_internal.h @@ -95,6 +95,9 @@ void sas_destruct_devices(struct asd_sas_port *port); extern const work_func_t sas_phy_event_fns[PHY_NUM_EVENTS]; extern const work_func_t sas_port_event_fns[PORT_NUM_EVENTS]; +void sas_task_internal_done(struct sas_task *task); +void sas_task_internal_timedout(struct timer_list *t); + #ifdef CONFIG_SCSI_SAS_HOST_SMP extern void sas_smp_host_handler(struct bsg_job *job, struct Scsi_Host *shost); #else diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 387083a16a79..40dcb4e8a747 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -893,6 +893,30 @@ int sas_bios_param(struct scsi_device *scsi_dev, } EXPORT_SYMBOL_GPL(sas_bios_param); +void sas_task_internal_done(struct sas_task *task) +{ + del_timer(&task->slow_task->timer); + complete(&task->slow_task->completion); +} + +void sas_task_internal_timedout(struct timer_list *t) +{ + struct sas_task_slow *slow = from_timer(slow, t, timer); + struct sas_task *task = slow->task; + bool is_completed = true; + unsigned long flags; + + spin_lock_irqsave(&task->task_state_lock, flags); + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { + task->task_state_flags |= SAS_TASK_STATE_ABORTED; + is_completed = false; + } + spin_unlock_irqrestore(&task->task_state_lock, flags); + + if (!is_completed) + complete(&task->slow_task->completion); +} + /* * Tell an upper layer that it needs to initiate an abort for a given task. * This should only ever be called by an LLDD. -- 2.26.2