From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FAKE_REPLY_C,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECE60C4360C for ; Fri, 27 Sep 2019 22:01:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5BF521850 for ; Fri, 27 Sep 2019 22:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569621698; bh=3gKE7NR6aQzEoQPANayg8VF+vjEvBawquzUnQ3HOO9Y=; h=Date:From:To:Cc:Subject:In-Reply-To:List-ID:From; b=1sNMIbNuuG+IkyrUpq+U4uieqrB1O0kJiAwBIX9JyRU/aXZfKSVrKWIMSlK1IdZ/y Z70AKOUdUzPK78hv7NJAiZkKWd79TPPcxEn5921dnue5C5optri+/4M+j2ARxy9jhx q9U2LF0/CulrvEmVGJreFQ0CjEOa8JCyQ6Mfk5zc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725990AbfI0WBi (ORCPT ); Fri, 27 Sep 2019 18:01:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:41612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbfI0WBh (ORCPT ); Fri, 27 Sep 2019 18:01:37 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D221B2082F; Fri, 27 Sep 2019 22:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569621697; bh=3gKE7NR6aQzEoQPANayg8VF+vjEvBawquzUnQ3HOO9Y=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=VYwSf5PqkjJ2JobOy8WvasnNZ3WvFmaP8SFVwZcyFVuN5Fg7KgVkdxsUQCrjE+77r plMmJiTgWXq3/AAQCiu/J6PPxwUilv1znv/xF4viH8tLPbI9INAmzs2fYRWeBwyiAT Wxvk7JdwfwMlyu3n8HgjD16lipxW3I/VhKQkGyi0= Date: Fri, 27 Sep 2019 17:01:35 -0500 From: Bjorn Helgaas To: Sergey Miroshnichenko Cc: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux@yadro.com Subject: Re: [PATCH v5 02/23] PCI: Enable bridge's I/O and MEM access for hotplugged devices Message-ID: <20190927220135.GA55204@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190816165101.911-3-s.miroshnichenko@yadro.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Fri, Aug 16, 2019 at 07:50:40PM +0300, Sergey Miroshnichenko wrote: > The PCI_COMMAND_IO and PCI_COMMAND_MEMORY bits of the bridge must be > updated not only when enabling the bridge for the first time, but also if a > hotplugged device requests these types of resources. Yeah, this assumption that pci_is_enabled() means PCI_COMMAND_IO and PCI_COMMAND_MEMORY are set correctly even though we may now need *different* settings than when we incremented pdev->enable_cnt is quite broken. > Originally these bits were set by the pci_enable_device_flags() only, which > exits early if the bridge is already pci_is_enabled(). So if the bridge was > empty initially (an edge case), then hotplugged devices fail to IO/MEM. > > Signed-off-by: Sergey Miroshnichenko > --- > drivers/pci/pci.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index e7f8c354e644..61d951766087 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -1652,6 +1652,14 @@ static void pci_enable_bridge(struct pci_dev *dev) > pci_enable_bridge(bridge); > > if (pci_is_enabled(dev)) { > + int i, bars = 0; > + > + for (i = PCI_BRIDGE_RESOURCES; i < DEVICE_COUNT_RESOURCE; i++) { > + if (dev->resource[i].flags & (IORESOURCE_MEM | IORESOURCE_IO)) > + bars |= (1 << i); > + } > + do_pci_enable_device(dev, bars); > + > if (!dev->is_busmaster) > pci_set_master(dev); > mutex_unlock(&dev->enable_mutex); > -- > 2.21.0 >