Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3561205imm; Mon, 20 Aug 2018 00:19:41 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxIyuDc6cwZm0tx1u14sxfiJrRnAR4gjojjRyHVKmzq9yMsT4tyQ2/Bhd6gclb4TunerjX5 X-Received: by 2002:a63:5c65:: with SMTP id n37-v6mr6548666pgm.253.1534749581428; Mon, 20 Aug 2018 00:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534749581; cv=none; d=google.com; s=arc-20160816; b=PHmdXCOXxQVoF0gceKrtsMroev8bVoxIyBNpMBLX9ONn+Az68XimmB+V6DHwxRjjnF Rg+p6QJ3MWNVDU08nusHv7kSZaOxD8v4WQEfhY+1/2xN+kZpH5nacwMgwhkoakGSUpOS fRfRl5VeGSPPQoAJ+l3FKbXN0DRlk8NzNA1JVjEwwEXDqwF8rXksHLZEXUYU8ASouGUM 9TNC5a6dURe5K+e1fnBw12Mjs3+CT8euPs/jDMjKmZWn1MrcnXTyHdT9mia9oPtmK4+S kELegUnsNb2Twvi+A3dtW7p3GDp1W9zVgVnKl3EVzfjdM9eYREMtiZx4Zcr/BG/PUKAD KoAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=zarxQM8N9QDtlbPS8xaAyQv7xPeBJ2vtFDgqx9dpNjM=; b=zYyQsESLXADm5SXiM48ubULSNpYQ5ETlFwaTaukcidNWuSCYqmiP3IQEVNV9Epf688 jE9HXuqjoTRQqKX7Zpwy2ppHsb/1sQaqa+2RuEWWzR+UpAUNuH7l/Sq5YaPdcCx7VHHL 0nUMrUiuvFbfbpZD7m6NA/XVkj/opismScPhFPefTk3kmdS7mw+zM+55ZlxZ7RxaoCR9 LmTJGgZtjysLYzQjLHochPE6E9bnjqFkqHoDiZ1Z246J+5I+ekS7iE+UpPoufKbSxA8Z dM9VgF4runyEbRdvLNLuE1MCL5MmQdHay+uf4inBkLg9NgHIjxYmjpNAeuCaPkCgpTae HjnQ== 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 c5-v6si1802710pgt.144.2018.08.20.00.19.26; Mon, 20 Aug 2018 00:19:41 -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 S1726657AbeHTKbe (ORCPT + 99 others); Mon, 20 Aug 2018 06:31:34 -0400 Received: from bmailout3.hostsharing.net ([176.9.242.62]:39095 "EHLO bmailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726030AbeHTKbe (ORCPT ); Mon, 20 Aug 2018 06:31:34 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id 871AE1030CD10; Mon, 20 Aug 2018 09:17:03 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 3B5F57878D; Mon, 20 Aug 2018 09:17:03 +0200 (CEST) Date: Mon, 20 Aug 2018 09:17:03 +0200 From: Lukas Wunner To: Benjamin Herrenschmidt Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, Hari Vyas , Ray Jui , Srinath Mannam , Guenter Roeck , Jens Axboe , Konstantin Khlebnikov , Marta Rybczynska , Pierre-Yves Kerbrat , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 1/6] Revert "PCI: Fix is_added/is_busmaster race condition" Message-ID: <20180820071703.hnsyhb5pz4svb7jg@wunner.de> 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> <4d777ed8c17b479e59b16cc0b4e9a3f6537f9884.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4d777ed8c17b479e59b16cc0b4e9a3f6537f9884.camel@kernel.crashing.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 20, 2018 at 12:10:59PM +1000, Benjamin Herrenschmidt wrote: > 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. +1 from my side for adding a struct mutex to struct pci_dev to protect state changes. The device_lock() primarily protects binding / unbinding of the device and pci_dev state may have to be changed while binding / unbinding. A global lock invites deadlocks if multiple devices are added / removed concurrently where one is a parent of the other. (Think hot-removal of multiple devices on a Thunderbolt daisy-chain.) As said I'd also welcome folding PCI_DEV_DISCONNECTED into enum pci_channel_state, either as an additional state or by using pci_channel_io_perm_failure. Thanks, Lukas