Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2786534ybh; Sat, 25 Jul 2020 01:21:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXLOmn/Pb0bUbM+j54haIVErnqI11mQJiN4JsJAqY0h1r5rYm249ljG4WuN0R3FS+HNFHS X-Received: by 2002:a50:8a62:: with SMTP id i89mr12728212edi.324.1595665285942; Sat, 25 Jul 2020 01:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595665285; cv=none; d=google.com; s=arc-20160816; b=VrVXcNHJ4OCUILizqxPF1tUtUTy3sujniMH+iWtLkyJvDIEOOpHVm3QGv8eGcmiA9l Q8iP24nRJeHgc1J+LgZ4XDBNrLXEFlstTD7OF+9f/E8PDGIPUi+oJz+gdZhv3aUEiC3J pHqO5LJdwJh5vtLyD4v7pU4F/SXXzATQ0MOpkxylIK1No9LJvmdZL2skgUzDg6ZCfknx llb1DsYLgRi0qcC34BjMjSnEwmkd9TU+Sw4fus9xaOoS3lkoXka81AfpcLreEA3YZOEz +Zznco0lpwuX/fwqgMih5/EhvEljGZtpLOo7C+23rzCegojxOdRPBY5WHEo1/2B8kaQF Occg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ObF9oSZEx/bHg/txUwu8VKmvIw/tZYauUp4Y03uSxbs=; b=LzGaUK7/kSuhUyHfFI41h0TZ9VX4Ej6tIPGYm+TfJMPIx7l4AIosQbYQUb4MSMnxEx OP42SMYQdRmIHVBU21dWweNG43cZUvH07VhGB5EK69bizJDIjo4Ig/2XvtkPgPyoaBhA kzFN9t+g4mQoRsTrsk6jlo5lEjUQjvL+SZFzGIB2LfMqY8woqQdBhyJtXg2ql1OpByrs /fZmmw/8X3sDK0ejFtXW+UBwRvyZF5aL2U9kgeSwLA8FDgjC1wJj+J6SlbtJjuHTd3tQ 4juMH0YF9Ypdbi0WpM42LGlTDP9jJ+WJhHmPbv51mTze3vI62++FWi+ikBoCbSA8HbDE ejmA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si1871496eju.192.2020.07.25.01.21.02; Sat, 25 Jul 2020 01:21:25 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726926AbgGYIUy (ORCPT + 99 others); Sat, 25 Jul 2020 04:20:54 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8822 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726572AbgGYIUw (ORCPT ); Sat, 25 Jul 2020 04:20:52 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9FBFE4EE2EF00779B999; Sat, 25 Jul 2020 16:20:48 +0800 (CST) Received: from huawei.com (10.69.192.56) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Sat, 25 Jul 2020 16:20:41 +0800 From: Luo Jiaxing To: , CC: , , , , , , Subject: [PATCH v2 2/2] scsi: libsas: check link status at ATA prereset() ops Date: Sat, 25 Jul 2020 16:18:51 +0800 Message-ID: <1595665131-24543-3-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595665131-24543-1-git-send-email-luojiaxing@huawei.com> References: <1595665131-24543-1-git-send-email-luojiaxing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We found out that libata will retry reset even if SATA disk is unpluged. We should report offline to libata to avoid meaningless reset on the disk. Libata provide an ops of prereset() for this purpose, it was called by ata_eh_reset() only and used to decide whether to skip reset base on the return value of it. We check status of phy and disk at prereset(). If disk is already offline or phy is disabled, we return -ENOENT to libata to skip disk reset. As prereset() should be best-effort, we should continue to try disk reset beyond the situation we mentioned before. Signed-off-by: Luo Jiaxing Reviewed-by: John Garry Reviewed-by: Jason Yan --- drivers/scsi/libsas/sas_ata.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index a7d16d2..1b93332 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -507,8 +507,22 @@ void sas_ata_end_eh(struct ata_port *ap) spin_unlock_irqrestore(&ha->lock, flags); } +static int sas_ata_prereset(struct ata_link *link, unsigned long deadline) +{ + struct ata_port *ap = link->ap; + struct domain_device *dev = ap->private_data; + struct sas_phy *local_phy = sas_get_local_phy(dev); + int res = 0; + + if (!local_phy->enabled || test_bit(SAS_DEV_GONE, &dev->state)) + res = -ENOENT; + sas_put_local_phy(local_phy); + + return res; +} + static struct ata_port_operations sas_sata_ops = { - .prereset = ata_std_prereset, + .prereset = sas_ata_prereset, .hardreset = sas_ata_hard_reset, .error_handler = ata_std_error_handler, .post_internal_cmd = sas_ata_post_internal, -- 2.7.4