From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] linux/pcifront: claim PCI resources also on rescan Date: Mon, 04 Oct 2010 12:03:59 +0100 Message-ID: <4CA9D0BF020000780001A5A0@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB69B5E8F.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB69B5E8F.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Condensed from the following two patches: http://git.kernel.org/?p=3Dlinux/kernel/git/konrad/xen.git;a=3Dcommitdiff;h= =3D621d869f36b215d63bb99e7ecd7a11f029821b85=20 xen-pcifront: Claim PCI resources before going live. author Konrad Rzeszutek Wilk =09 Fri, 18 Jun 2010 19:31:47 +0000 (15:31 -0400) committer Konrad Rzeszutek Wilk =09 Fri, 18 Jun 2010 19:40:37 +0000 (15:40 -0400) We were missing the important step of claiming (and setting the parent of IO and MEM regions to 'PCI IO' and 'PCI mem' respectivly) of the BARs. This meant that during hot inserts we would get: igb 0000:01:00.1: device not available (can't reserve [mem 0xfb840000-0xfb8= 5ffff]) even thought the memory region had been reserved before. Signed-off-by: Konrad Rzeszutek Wilk http://git.kernel.org/?p=3Dlinux/kernel/git/konrad/xen.git;a=3Dcommitdiff;h= =3D4a65de894fc0af05397eedca180d0ea7d8c6caba=20 xen-pcifront: Don't race with udev when discovering new devices. author Konrad Rzeszutek Wilk =09 Fri, 23 Jul 2010 14:35:57 +0000 (10:35 -0400) committer Konrad Rzeszutek Wilk =09 Fri, 23 Jul 2010 15:15:56 +0000 (11:15 -0400) We inadvertly would call 'pci_bus_add_device' right after discovering the device, but before claiming the BARs. This ended up firing off a uevent and udev loading the module and the modules failing to request_region as they were not claimed. We fix this by holding off going live by calling 'pci_bus_add_devices' at the end. Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Jan Beulich Reported-by: Rafal Wojtczuk --- a/drivers/xen/pcifront/pci_op.c +++ b/drivers/xen/pcifront/pci_op.c @@ -529,14 +529,18 @@ int __devinit pcifront_rescan_root(struc } =20 d =3D pci_scan_single_device(b, devfn); - if (d) { + if (d) dev_info(&pdev->xdev->dev, "New device on " "%04x:%02x:%02x.%02x found.\n", domain, = bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - pci_bus_add_device(d); - } } =20 + /* Claim resources before going "live" with our devices */ + pci_walk_bus(b, pcifront_claim_resource, pdev); + + /* Create SysFS and notify udev of the devices. Aka: "going live" = */ + pci_bus_add_devices(b); + return 0; } =20 --=__PartB69B5E8F.0__= Content-Type: text/plain; name="xen-pcifront-rescan-claim.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-pcifront-rescan-claim.patch" Subject: pcifront: claim PCI resources also on rescan=0A=0ACondensed from = the following two patches:=0A=0Ahttp://git.kernel.org/?p=3Dlinux/kernel/git= /konrad/xen.git;a=3Dcommitdiff;h=3D621d869f36b215d63bb99e7ecd7a11f029821b85= =0Axen-pcifront: Claim PCI resources before going live.=0A=0Aauthor = Konrad Rzeszutek Wilk =0A Fri, 18 Jun 2010 = 19:31:47 +0000 (15:31 -0400)=0Acommitter Konrad Rzeszutek Wilk = =0A Fri, 18 Jun 2010 19:40:37 +0000 = (15:40 -0400)=0A=0AWe were missing the important step of claiming (and = setting the=0Aparent of IO and MEM regions to 'PCI IO' and 'PCI mem' = respectivly)=0Aof the BARs. This meant that during hot inserts we would = get:=0A=0Aigb 0000:01:00.1: device not available (can't reserve [mem = 0xfb840000-0xfb85ffff])=0A=0Aeven thought the memory region had been = reserved before.=0A=0ASigned-off-by: Konrad Rzeszutek Wilk =0A=0Ahttp://git.kernel.org/?p=3Dlinux/kernel/git/konrad/xen.git;a= =3Dcommitdiff;h=3D4a65de894fc0af05397eedca180d0ea7d8c6caba=0Axen-pcifront: = Don't race with udev when discovering new devices.=0A=0Aauthor Konrad = Rzeszutek Wilk =0A Fri, 23 Jul 2010 14:35:57 = +0000 (10:35 -0400)=0Acommitter Konrad Rzeszutek Wilk =0A Fri, 23 Jul 2010 15:15:56 +0000 (11:15 -0400)=0A=0AWe = inadvertly would call 'pci_bus_add_device' right after discovering=0Athe = device, but before claiming the BARs. This ended up firing off=0Aa uevent = and udev loading the module and the modules failing to=0Arequest_region as = they were not claimed. We fix this by holding off=0Agoing live by calling = 'pci_bus_add_devices' at the end.=0A=0ASigned-off-by: Konrad Rzeszutek = Wilk =0A=0ASigned-off-by: Jan Beulich =0AReported-by: Rafal Wojtczuk =0A=0A= --- a/drivers/xen/pcifront/pci_op.c=0A+++ b/drivers/xen/pcifront/pci_op.c= =0A@@ -529,14 +529,18 @@ int __devinit pcifront_rescan_root(struc=0A = }=0A =0A d =3D pci_scan_single_device(b, devfn);=0A- = if (d) {=0A+ if (d)=0A dev_info(&pdev->xde= v->dev, "New device on "=0A "%04x:%02x:%02x.%0= 2x found.\n", domain, bus,=0A PCI_SLOT(devfn), = PCI_FUNC(devfn));=0A- pci_bus_add_device(d);=0A- = }=0A }=0A =0A+ /* Claim resources before going "live" with our = devices */=0A+ pci_walk_bus(b, pcifront_claim_resource, pdev);=0A+=0A+ /* = Create SysFS and notify udev of the devices. Aka: "going live" */=0A+ = pci_bus_add_devices(b);=0A+=0A return 0;=0A }=0A =0A --=__PartB69B5E8F.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartB69B5E8F.0__=--