Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4352426pxb; Tue, 25 Jan 2022 08:36:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxuuIqtDGGKgYpWHzdkFCc7yoF0mnRKLTeEvHN1coov3TS2H8EV3koWDCep7Ksk2YxCncee X-Received: by 2002:a17:906:1841:: with SMTP id w1mr16711788eje.306.1643128582168; Tue, 25 Jan 2022 08:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643128582; cv=none; d=google.com; s=arc-20160816; b=JKI+Yh2e01CVjX51ZRPnfiSPBeWFKI9I2GjtbWQO/dTT4xjz3E9YHoBkclDoinXF8e aoYafmLxMKcL7s4VsxzhsLUdxdJFlhYA3jtlESt6XJXcKGayCTwSFT+XnVoPdq5u2tuK yKS6AgtuNyYUYuymQg8bLP5ciaGK8v8l9EDxW0nN1CN8RJaT2Q1LzcM35RC+2TuXAoTV RKNYiMWxDZlodlHDSeu9PatJPazhqypqMpfKKGYZzji9EHJaP27Kd8Ht7R7gWT1BwJe3 6TSRTU/4zVisQ2pQeuvqwTJcaDGyJWwPzeWlfdnbb1v6gipSBdIW6WEIoPb8oM2RVDoz aqWg== 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=rQKwCOzVqIpn/FqgThe+WC1pTDLRa1djTARKWI1oRcY=; b=XqR5UYQo67Qir4famPBPl8tiprhvWxcSHwGQ+gF4t0ixCB1RVNP2dIFMPA0dwhpbju X/sdc998NGF73ZTsH+zvOAyoKW/KUOUKia6DIH90UoM5zB8xPLUG+1ro8LOhD2DATiBC 7roNaql2UgSR7c22mXL09Rm+nQ2V9coGs6B3a+zA1cfBF2iY1ixQxvlV6vVTNrCUtwtb VP33fLkneyjN77OK/G6gRVG7i30CzUgQnepGaf5zw+Sg6n+fjRlofnmhvazAucKBC0yL yOpCcR+iCZNoFfojulkaJ3gjTe8CCcA3kM3RjKALcr1qzGtpnQtNS2V3d2DninbJEsRi NCPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si9272253edp.549.2022.01.25.08.35.57; Tue, 25 Jan 2022 08:36:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1382724AbiAYLnO (ORCPT + 99 others); Tue, 25 Jan 2022 06:43:14 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:4496 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382137AbiAYLin (ORCPT ); Tue, 25 Jan 2022 06:38:43 -0500 Received: from fraeml706-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JjlB55lvNz6FGxF; Tue, 25 Jan 2022 19:34:21 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml706-chm.china.huawei.com (10.206.15.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.21; Tue, 25 Jan 2022 12:38:37 +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, 25 Jan 2022 11:38:33 +0000 From: John Garry To: , , , , , CC: , , , , , , , , John Garry Subject: [PATCH 04/16] scsi: libsas: Move SMP task handlers to core Date: Tue, 25 Jan 2022 19:32:40 +0800 Message-ID: <1643110372-85470-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1643110372-85470-1-git-send-email-john.garry@huawei.com> References: <1643110372-85470-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: dggems701-chm.china.huawei.com (10.3.19.178) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected 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 --- 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 fb19e739a39c..42b6041d10fc 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -894,6 +894,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