From patchwork Tue May 7 21:32:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 242467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CE5E52C0104 for ; Wed, 8 May 2013 07:32:56 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757658Ab3EGVcz (ORCPT ); Tue, 7 May 2013 17:32:55 -0400 Received: from mail-ia0-f180.google.com ([209.85.210.180]:36992 "EHLO mail-ia0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757507Ab3EGVcy (ORCPT ); Tue, 7 May 2013 17:32:54 -0400 Received: by mail-ia0-f180.google.com with SMTP id 21so1197564iay.39 for ; Tue, 07 May 2013 14:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=JtzXPMBaJKMr9qXcrua3z+FjoBPE1WYwcUmXM2npMEs=; b=GBkMqNQCIZRjZJwrDJCRanHX08oM+t7CBfcfQBL9eU3c7T4Yy/CqVy/K9aWXo1JbPF D3Ke4XVvhKVyOe1vgvpZ3ag3AJ5qzw9wtkdKdbKr5ED0aO0acyJNUsxGDAp/B2pGmQuu YVI1uETarfSmM01bgSOwRIoMhFJZlJRo3SheazSE/jWFkSi4ZspSMVIRYxm4LrzSQRvk SUf3DDbcGsLfZAxFsDYfl5acXdEvqSiHpVqPrXfp7eRnbhNGgcz2wdVtpXGYACGZFz/7 97dk9Xx7rl+sM11Soa6yvy2Rh9gA8XGnHfIpZVRf8T7vKWr4qXU8XA1mTKsgC/5OBSwE /K7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent:x-gm-message-state; bh=JtzXPMBaJKMr9qXcrua3z+FjoBPE1WYwcUmXM2npMEs=; b=bc1rE2ynnCjIPHULngFgp054dMgMpFKnnHZj64/sOrUDUcB7oWzT2cf7ORAOX2SGxc X4u5MbdcAXdv0CYzdulw/sObt0jWzEl0pwGg9q0ocrVjpCohJtR/x7wM9pG35edapyPH CmIalEv78DOXQWOpfuOlGuI5JsGYHiofkvNvGBXVHwfNC/JbequjsHlODN7KWMJ7B+b0 aWCgazk+Vn+GDfbK3MS5qLWrOd/ssjX+GWTAnq0y6+UXTB29eBVsthRofoMNLEKRR8i9 A2ApwgIA8i9+eLGMk+YH11D1Zbh5xFcTOL3lD+9uVpzeW/W8YafVIAZebDuKsw0/rSgg nQJg== X-Received: by 10.50.1.113 with SMTP id 17mr1355449igl.65.1367962373992; Tue, 07 May 2013 14:32:53 -0700 (PDT) Received: from google.com ([172.29.120.5]) by mx.google.com with ESMTPSA id wn10sm1261010igb.2.2013.05.07.14.32.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 07 May 2013 14:32:53 -0700 (PDT) Date: Tue, 7 May 2013 15:32:50 -0600 From: Bjorn Helgaas To: Yinghai Lu Cc: David Bulkow , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: move down pci_fixup_final for hotplug path Message-ID: <20130507213250.GA22773@google.com> References: <5AA430FFE4486C448003201AC83BC85E03DEA379@EXHQ.corp.stratus.com> <1366940827-15336-1-git-send-email-yinghai@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1366940827-15336-1-git-send-email-yinghai@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQmvqnOyo/kMK2bYpNxfQtVmT4d3mStWZRLDxGk6Dpk/6WijSMQgWtZ1Du0X9ndz0D7DWV509/0aFjl5PQDZsuxUmk+pXY788vVLpoE/ySTlIufS2yP/UDF5TzccrShiGnywogJY3cVGyLGeaNtNsvWdoeEckrgkQImBHkEs5hrIoVqwVcqMblaQKqhs0qDDpu4raYemYRqRRKc3umcsIbj6OCGC+A== Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, Apr 25, 2013 at 06:47:07PM -0700, Yinghai Lu wrote: > David found some resource conflict issue after > | PCI: Put pci_dev in device tree as early as possible > | commit 4f535093cf8f6da8cfda7c36c2c1ecd2e9586ee4 > > and > | USB: Fix handoff when BIOS disables host PCI device > | commit: cab928ee1f221c9cc48d6615070fefe2e444384a > > for usb qirks for hotplug path. > > After checking pci_fixup_device() with pci_fixup_final, > now we have different path for boot path and hotadd path. > > Boot path: because pci_apply_fix_final_quirks is not set yet, > so pci_fixup_device(pci_fixup_final) will be skipped > from pci_device_add(). > And later pci_apply_final_quirks will be called for all > pci devices via fs_initcall. > That is after pci_assign_unassign resource. > In that case quirk could use bars with problem. > > Hotadd path: pci_fixup_device(pci_fixup_final) will be executed > via pci_device_add(), and that is too early for hotplug > path, as pci bar for hot add devices is not assigned yet > after commit 4f535093. > > So we need to move down that for hotplug path, call that in > pci_bus_add_devices instead, as at that time just before > drivers get attached. > And that is simliar calling place for pci_device_add before > commit 4f535093 is applied. > > We should apply this fix for v3.9, but is too late now. > so get it into v3.10 and could get into v3.9 stable instead. > > Reported-by: David Bulkow > Tested-by: David Bulkow > Signed-off-by: Yinghai Lu I applied the following slightly tweaked patch to for-linus and will ask Linus to pull it for v3.10. Let me know if it looks OK. Bjorn commit a939563f3fd9cd6226c7fb7135d0b93507c53888 Author: Bjorn Helgaas Date: Tue May 7 14:35:44 2013 -0600 PCI: Delay final fixups until resources are assigned Commit 4f535093cf "PCI: Put pci_dev in device tree as early as possible" moved final fixups from pci_bus_add_device() to pci_device_add(). But pci_device_add() happens before resource assignment, so BARs may not be valid yet. Typical flow for hot-add: pciehp_configure_device pci_scan_slot pci_scan_single_device pci_device_add pci_fixup_device(pci_fixup_final, dev) # previous location # resource assignment happens here pci_bus_add_devices pci_bus_add_device pci_fixup_device(pci_fixup_final, dev) # new location [bhelgaas: changelog, move fixups to pci_bus_add_device()] Reference: https://lkml.kernel.org/r/20130415182614.GB9224@xanatos Reported-by: David Bulkow Tested-by: David Bulkow Signed-off-by: Yinghai Lu Signed-off-by: Bjorn Helgaas CC: stable@vger.kernel.org # v3.9+ --- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 748f8f3..32e66a6 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -174,6 +174,7 @@ int pci_bus_add_device(struct pci_dev *dev) * Can not put in pci_device_add yet because resources * are not assigned yet for some devices. */ + pci_fixup_device(pci_fixup_final, dev); pci_create_sysfs_dev_files(dev); dev->match_driver = true; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 43ece5d..67cd045 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1341,7 +1341,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) list_add_tail(&dev->bus_list, &bus->devices); up_write(&pci_bus_sem); - pci_fixup_device(pci_fixup_final, dev); ret = pcibios_add_device(dev); WARN_ON(ret < 0);