Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753444AbdGJHCc (ORCPT ); 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 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 Content-Type: text/plain 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2582 Lines: 66 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(+) 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), -- 2.5.0