Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp370949pjb; Wed, 22 Jul 2020 02:07:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxviBEHHcfgX0HFya+nxldw/bcP7tKwzPJIAiuNrHfFrS45+rG3aN2txxgBP5gj8UTnAFRz X-Received: by 2002:a17:906:8392:: with SMTP id p18mr30912533ejx.24.1595408822457; Wed, 22 Jul 2020 02:07:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595408822; cv=none; d=google.com; s=arc-20160816; b=VGR7C6/VSmhMZouxqoVpVMFl3hHIbvVk7u2O+mfBQzJ4riqXEIpZ3JoiVdp5gyH1UU X6K38tDlNXr/vxavM4Yfmj9fN7+dKxFOMLw7xL757s5qZxepMmgDXPv92sCyNEpwaYsV GRcrgQnRk2caSarY9ZZoQIp5MEXNd9fPWnp3gVb/TWzQf53iVoEI27GEyJ5qVwHp9mPk xpO38hAEFvp9nNvfMtY5jmB6G+SYtLy6Vb/XkUHhfuui8qyVa+D6saftq7OR6Y8tcPSP EyRcWORXx7V8dHg3+HgieenG57otaV9mxG7LEhxDYxJcs3hXaFYlLCGhqEFZQ4f+Fh58 KCtg== 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=ANsTa5/CXDkhb9jtUcQ+bZU6V6wOcQChj7Vd3r0OL5Y=; b=wPkg5WJFVJRmHVxYkiFNdal7M0i2oKk8dlJdCN3VkeHC8KSZxk+Efh7HV/OdBsExUA /wbEKm36iPhRnIJYDw9N5U7bUeVbv19ChVcYtyWRD3lCeg6DW7J8oGlzE/jmatiRKbR/ RbvDlXnAQhCY8M+3GMG73w7VQXAeEKvMkjqo+ucGvdDHRiU3jV/sqD3EoK4SGEVRABby yzUAByfaelQ6Qt7pJcI5hXZ0z528io21f4Z+ijh2H6LrdKRMVwPxelGMQxG5yCd43Fg1 UQWY0vwRWfzKtpWrWXqzEYR+zkavRxibn+fLfXckJsoZog1QLYsTQMGpeHFEGPNRsNW/ KOgg== 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 y8si15725091edw.59.2020.07.22.02.06.39; Wed, 22 Jul 2020 02:07:02 -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 S1731254AbgGVJGH (ORCPT + 99 others); Wed, 22 Jul 2020 05:06:07 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:51994 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726821AbgGVJGD (ORCPT ); Wed, 22 Jul 2020 05:06:03 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DFF3E3682621332C239E; Wed, 22 Jul 2020 17:05:59 +0800 (CST) Received: from huawei.com (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Wed, 22 Jul 2020 17:05:52 +0800 From: Luo Jiaxing To: , CC: , , , , , , Subject: [PATCH v1 2/2] {topost} scsi: libsas: check link status at ATA prereset() ops Date: Wed, 22 Jul 2020 17:04:03 +0800 Message-ID: <1595408643-63011-3-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595408643-63011-1-git-send-email-luojiaxing@huawei.com> References: <1595408643-63011-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 --- 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