Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3364495imm; Sun, 19 Aug 2018 19:14:04 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzfETzffVpPpH3sEwm6TJ673z2IwbAD3yUGzbjnDClXgKgYS/97V1E7NWS3WM/NS6d/PEfv X-Received: by 2002:a63:cb04:: with SMTP id p4-v6mr11930637pgg.197.1534731244458; Sun, 19 Aug 2018 19:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534731244; cv=none; d=google.com; s=arc-20160816; b=f3w3BvBSu1AjqygzOvb60Mo5x5jC3uZ5OCbqBbG1RJNythfvEnrTwx2GGI/aYhBWEN rntLD+cvR9G62lfvvHMVPfeLD2iaiv33qdyuXSwKoAXqVKgSdJz1wVR+CKbr/2yqQZgD XeRU12VVd6bCw5FZ4lj6VW1pPyx3+qtxCVyNEuHQsk9H9Nl2b3ZrSbARYjohqrXTRXdk fc8PVt08tPJzUF50jZpTUd29YTZ+vc1L9m1nXDw/wh5rZPF8NK+jkSOWUB7Grl1JxHh/ lFTStYdOyBbVuIAAqkk/Gg5aXPsXWYlT4qjWJ/dctqApObYzV4XA2TJDqWwvgMRotoqO Mgdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=fZJ/1jPZA7l9AAXQIQJ+ozqzJWRzDI65wbEly2ySjNA=; b=Q/l/F9F8aK15UAqHtyGVEzqzQoE2/I+DcW8CtYwaBrOPzf3m/mQmGxToMoFiAfYuDI Fv+bTZyPYaCzRgCegtjNHuY0cWMgTI+TtaHzI6sRASBTEppu9oqve6z9ZndIP4j/hcj3 6V25sZYoYYYYWYFBiWswhn3DpBQU8nwmIFYszLOIxYHWA8RIMlaY6BtYwvz9sQ6pgHOc mYSfrrVrDK2I8U3axxIR8h67gC7sJYCV2udTbueHGDzAIsKSY3ocqFl2zlkks6aEySb8 wz9t/h5qG7bh9fTs1r94Ugg/UuWaeWUJrxOyXIsLUjQfBl4PdNrcmGeEqswy3uY9VTSw iBZA== 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 m193-v6si8760999pfc.312.2018.08.19.19.13.35; Sun, 19 Aug 2018 19:14:04 -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 S1726024AbeHTFZl (ORCPT + 99 others); Mon, 20 Aug 2018 01:25:41 -0400 Received: from gate.crashing.org ([63.228.1.57]:50853 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbeHTFZl (ORCPT ); Mon, 20 Aug 2018 01:25:41 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id w7K2Axqb026478; Sun, 19 Aug 2018 21:11:02 -0500 Message-ID: <4d777ed8c17b479e59b16cc0b4e9a3f6537f9884.camel@kernel.crashing.org> Subject: Re: [RFC PATCH 1/6] Revert "PCI: Fix is_added/is_busmaster race condition" From: Benjamin Herrenschmidt To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Hari Vyas , Ray Jui , Srinath Mannam , Guenter Roeck , Jens Axboe , Lukas Wunner , Konstantin Khlebnikov , Marta Rybczynska , Pierre-Yves Kerbrat , linux-kernel@vger.kernel.org Date: Mon, 20 Aug 2018 12:10:59 +1000 In-Reply-To: <20180819022440.GG128050@bhelgaas-glaptop.roam.corp.google.com> References: <20180817044902.31420-1-benh@kernel.crashing.org> <20180817044902.31420-2-benh@kernel.crashing.org> <20180817154431.GC128050@bhelgaas-glaptop.roam.corp.google.com> <06c1233b71dea08b1fc32334acefc48c32c46557.camel@kernel.crashing.org> <20180819022440.GG128050@bhelgaas-glaptop.roam.corp.google.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-1.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2018-08-18 at 21:24 -0500, Bjorn Helgaas wrote: > On Sat, Aug 18, 2018 at 01:24:51PM +1000, Benjamin Herrenschmidt wrote: > > On Fri, 2018-08-17 at 10:44 -0500, Bjorn Helgaas wrote: > > > On Fri, Aug 17, 2018 at 02:48:57PM +1000, Benjamin Herrenschmidt wrote: > > > > This reverts commit 44bda4b7d26e9fffed6d7152d98a2e9edaeb2a76. > > > > > > Just to be clear, if I understand correctly, this is a pure revert of > > > 44bda4b7d26e and as such it reintroduces the problem solved by that > > > commit. > > > > > > If your solution turns out to be better, that's great, but it would be > > > nice to avoid the bisection hole of reintroducing the problem, then > > > fixing it again later. > > > > There is no way to do that other than merging the revert and the fix > > into one. That said, the race is sufficiently hard to hit that I > > wouldn't worry too much about it. > > OK, then at least mention that in the changelog. Sure will do. This is just RFC at this stage :-) As for the race with enable, what's your take on my approach ? The basic premise is that we need some kind of mutex to make the updates to enable_cnt and the actual config space changes atomic. While at it we can fold pci_set_master vs. is_busmaster as well as those are racy too. I chose to create a new mutex which we should be able to address other similar races if we find them. The other solutions that I dismissed were: - Using the device_lock. A explained previously, this is tricky, I prefer not using this for anything other than locking against concurrent add/remove. The main issue is that drivers will be sometimes called in context where that's already held, so we can't take it inside pci_enable_device() and I'd rather not add new constraints such as "pci_enable_device() must be only called from probe() unless you also take the device lock". It would be tricky to audit everybody... - Using a global mutex. We could move the bridge lock from AER to core code for example, and use that. But it doesn't buy us much, and slightly redecuces parallelism. It also makes it a little bit more messy to walk up the bridge chain, we'd have to do a pci_enable_device_unlocked or something, messy. So are you ok with the approach ? Do you prefer one of the above regardless ? Something else ? Cheers, Ben.