From patchwork Mon Jul 10 07:06:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 107276 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3038239qge; Mon, 10 Jul 2017 00:02:59 -0700 (PDT) X-Received: by 10.99.166.17 with SMTP id t17mr13543706pge.60.1499670179355; Mon, 10 Jul 2017 00:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499670179; cv=none; d=google.com; s=arc-20160816; b=G+iND9jlFIsD4NPKiDYoLrCS4Z2xcDJ7mXI7k9+qD/GwKC2+nPou+T1RMlmKgvmMBx bvVYGONHuNQ/J4M2QLg1kh5ykx5Xz7epuPbC7a9OEdw2HnZaLAWKvDUlq/oiPVV9Ah4T iwPFOvKHW2pMW2EQ1FNtrZAD75LbK72e4pgrhv0+pWulWSQaLt6LbqorlN7E1vKXwCXn bDNlJ6zgfIsuSL6tGM57wR1M0gxkCYhyvvwY5VJ+PSgbwYlaMt9QsDNCe5+PkfOXIa67 Ia/dzBffgZz/AwURFh2QI3nuxD2jt1ffGwGMP9njePJ14erp2y079d1+W89wRDGE45qs DM2A== 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:arc-authentication-results; bh=RmJgRcEl+VahwCr5Aq4xncZkx+5PuiYnNtaoiq1323E=; b=STq6VB2CNpGOuXOxtTFSKkXZFgWkzcolq0H72fqFPGGaADe+1qturmDQjc7z2B1IRq rJ737EfDhixwo0W89azFh+BOaW/xS1mQOLVmCVauViE/kWQhtUo7BW+K/luib7Nl/Uoq djQ8L+JXypPP/rsx9gs/e79uvRH0jpMUnblW/ln+O+B+OrpuEyPmqxxpjeCjPqZjS6WN YCHeWgz23Ir0FK2ySYUF7BeZEZxSyV3rj1teJUK5FlQ3LuAAncVYJkXGtSKJRsai4W74 XW1daaNKFXYvCxuxfx1fNuwkuB1nMZmA4PBOowTYs4zLx7u4REC70YdROxrYLD5KNw4c b2nA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si7528255pgk.495.2017.07.10.00.02.59; Mon, 10 Jul 2017 00:02:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753446AbdGJHCc (ORCPT + 25 others); Mon, 10 Jul 2017 03:02:32 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:9814 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753413AbdGJHCa (ORCPT ); Mon, 10 Jul 2017 03:02:30 -0400 Received: from 172.30.72.53 (EHLO dggeml406-hub.china.huawei.com) ([172.30.72.53]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AQU38388; Mon, 10 Jul 2017 15:02:16 +0800 (CST) Received: from 138.huawei.com (10.175.124.28) by dggeml406-hub.china.huawei.com (10.3.17.50) with Microsoft SMTP Server id 14.3.301.0; Mon, 10 Jul 2017 15:02:08 +0800 From: Yijing Wang To: , CC: , , , , , , , , , , , , , , , , , , , Yijing Wang , "Johannes Thumshirn" Subject: [PATCH v3 7/7] libsas: release disco mutex during waiting in sas_ex_discover_end_dev Date: Mon, 10 Jul 2017 15:06:09 +0800 Message-ID: <1499670369-44143-8-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1499670369-44143-1-git-send-email-wangyijing@huawei.com> References: <1499670369-44143-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0204.59632679.0093, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: aab5a385a1f8cfa8ed9ea75cbe812aac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Disco mutex was introudced to prevent domain rediscovery competing with ata error handling(87c8331). If we have already hold the lock in sas_revalidate_domain and sync executing probe, deadlock caused, because, sas_probe_sata() also need hold disco_mutex. Since disco mutex use to prevent revalidata domain happen during ata error handler, it should be safe to release disco mutex when sync probe, because no new revalidate domain event would be process until the sync return, and the current sas revalidate domain finish. Signed-off-by: Yijing Wang CC: John Garry CC: Johannes Thumshirn CC: Ewan Milne CC: Christoph Hellwig CC: Tomas Henzl CC: Dan Williams --- drivers/scsi/libsas/sas_expander.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.5.0 Reviewed-by: Hannes Reinecke diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 9d26c28..077024e 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -776,6 +776,7 @@ static struct domain_device *sas_ex_discover_end_dev( struct ex_phy *phy = &parent_ex->ex_phy[phy_id]; struct domain_device *child = NULL; struct sas_rphy *rphy; + bool prev_lock; int res; if (phy->attached_sata_host || phy->attached_sata_ps) @@ -803,6 +804,7 @@ static struct domain_device *sas_ex_discover_end_dev( sas_ex_get_linkrate(parent, child, phy); sas_device_set_phy(child, phy->port); + prev_lock = mutex_is_locked(&child->port->ha->disco_mutex); #ifdef CONFIG_SCSI_SAS_ATA if ((phy->attached_tproto & SAS_PROTOCOL_STP) || phy->attached_sata_dev) { res = sas_get_ata_info(child, phy); @@ -832,7 +834,11 @@ static struct domain_device *sas_ex_discover_end_dev( SAS_ADDR(parent->sas_addr), phy_id, res); goto out_list_del; } + if (prev_lock) + mutex_unlock(&child->port->ha->disco_mutex); sas_disc_wait_completion(child->port, DISCE_PROBE); + if (prev_lock) + mutex_lock(&child->port->ha->disco_mutex); } else #endif @@ -861,7 +867,11 @@ static struct domain_device *sas_ex_discover_end_dev( SAS_ADDR(parent->sas_addr), phy_id, res); goto out_list_del; } + if (prev_lock) + mutex_unlock(&child->port->ha->disco_mutex); sas_disc_wait_completion(child->port, DISCE_PROBE); + if (prev_lock) + mutex_lock(&child->port->ha->disco_mutex); } else { SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n", phy->attached_tproto, SAS_ADDR(parent->sas_addr),