Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp810628ybn; Tue, 24 Sep 2019 09:51:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAI54FHs/paHg/0BzdhiJj4OAsXHUQU8srGlyOOO/ubtMVZqxsrDoDfsyvX4c4Nr9bmkj8 X-Received: by 2002:a17:906:fad6:: with SMTP id lu22mr3296438ejb.98.1569343906270; Tue, 24 Sep 2019 09:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569343906; cv=none; d=google.com; s=arc-20160816; b=X96NqbuAwCAnwpqjTyRTrplQ1+/fnk096W81eEinp0KWI07CgSdB9GYlZox2QClUD8 1WUOxZaRQKjbvrM5Q05itIlmmL+/BIDPogIpXGwq4gqiSo8CSgcixkqiHGxGVekyx6JC YioZJYDmgb07udET+KPBbCyu74aosZm4HqiYzn00NSNvxozDaMWbNvJS9BWjXABv6Rxa GDXvOhXmmAealU/kVoDVxUQOjjoaVdc4PEedCpkbaRA3mUlKITe0uRk6zzy1snzG+90z FPKuMsBrOqS6O5f3s9CgWDZMGNzNhj3l00zOgG1prvhj+2KX8NDzhgUpEr4Bc/fqgrUg zR/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=djEoCOsKXH6WZQzEEgYfB7Mi9kfVqOuamjrBPkBc/0o=; b=khfBf6NHQ/OTanRlwFjVyk6Nol3xquIaaIJIrH+v6tWORlX5cleH4Bb2rASgO1zkZi 99cpCfs4ajweHrdNWifiohAb6FFWRslS8qfCnbA1mRLfn+kp+o5X+G0u8r6GEcuj/tBJ lhYQMLkxceYnO2d3GezlpzaKD0PPibyi0BWQZF4LD4amgZxv+iRkHdJNUeiL6Uqk5wiF fAfjrKkf8feH1acv3suXPwOWjfjguZ5z6+Yj2/YJyTigWcz8E7yyfSXxWu+kzK9f4YL5 p+tIxOmf+ufnxfUUTa/EKmeNIn2hmcGcXd5+kGbpLH8U6VeodkLsiJbNrIrU4l8Eh1Yu vLhA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nl6si1191976ejb.207.2019.09.24.09.51.21; Tue, 24 Sep 2019 09:51:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405822AbfIWIMm (ORCPT + 99 others); Mon, 23 Sep 2019 04:12:42 -0400 Received: from mga05.intel.com ([192.55.52.43]:11443 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388953AbfIWIMm (ORCPT ); Mon, 23 Sep 2019 04:12:42 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 01:12:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,539,1559545200"; d="scan'208";a="203076028" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by fmsmga001.fm.intel.com with SMTP; 23 Sep 2019 01:12:38 -0700 Received: by lahna (sSMTP sendmail emulation); Mon, 23 Sep 2019 11:12:37 +0300 Date: Mon, 23 Sep 2019 11:12:37 +0300 From: Mika Westerberg To: Lukas Wunner Cc: Bjorn Helgaas , "Rafael J. Wysocki" , Keith Busch , Andy Shevchenko , Frederick Lawler , "Gustavo A . R . Silva" , Sinan Kaya , Kai-Heng Feng , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] PCI: pciehp: Prevent deadlock on disconnect Message-ID: <20190923081237.GB2773@lahna.fi.intel.com> References: <20190812143133.75319-1-mika.westerberg@linux.intel.com> <20190812143133.75319-2-mika.westerberg@linux.intel.com> <20190923053403.jdjw6ed3sub6iuou@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190923053403.jdjw6ed3sub6iuou@wunner.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lukas, On Mon, Sep 23, 2019 at 07:34:03AM +0200, Lukas Wunner wrote: > On Mon, Aug 12, 2019 at 05:31:33PM +0300, Mika Westerberg wrote: > > If there are more than one PCIe switch with hotplug downstream ports > > hot-removing them leads to a following deadlock: > > For the record, I think my comments on v1 of this patch still apply: > > https://patchwork.ozlabs.org/patch/1117870/#2230798 Well, so do I ;-) As I tried to explain in v1 discussion, I think what we do here in this patch is correct thing to do regardless. I mean once the hardware is gone the driver should not do any decisions based on what it thinks it reads from the now missing hardware. This also makes the deadlock problem go away on all the system I've been testing. Where previously I was able to reproduce the deadlock 100% reliably I have not seen it happen once with this one applied (and haven't got reports from our internal testing either). Regarding suggestion of unbinding PCI drivers without pci_lock_rescan_remove() hold, I haven't looked it too closely but I think we need to take that lock anyway because when we are unbinding a hotplug driver it is supposed to remove the hierarchy below touching the shared structures, possibly concurrently. Unfortunately there is no documentation what data pci_lock_rescan_remove() actually protects so first one needs to understand that. I think one way to clean up this is to use finer grained locking (with documented lock ordering) for PCI bus structures that can be accessed simultaneusly by different threads. But that is not a simple task.