From: "Jan Beulich" Subject: [PATCH] pv-drivers: use PCI interfaces to request IO and MEM resources on platform device Date: Tue, 11 Jan 2011 15:54:03 +0000 Message-ID: <4D2C8B2B020000780002BBFA@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part7F53130B.1__=" 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" Cc: Ian Campbell 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. --=__Part7F53130B.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This is the correct interface to use and something has broken the use of the previous incorrect interface (which fails because the request conflicts with the resources assigned for the PCI device itself instead of nesting like the PCI interfaces do). pci_request_region() has been available since at least Linux 2.6.5. Signed-off-by: Ian Campbell Signed-off-by: Jan Beulich --- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c @@ -382,18 +382,13 @@ static int __devinit platform_pci_init(s return -ENOENT; } =20 - if (request_mem_region(mmio_addr, mmio_len, DRV_NAME) =3D=3D NULL) = { - printk(KERN_ERR ":MEM I/O resource 0x%lx @ 0x%lx busy\n", - mmio_addr, mmio_len); - return -EBUSY; - } + ret =3D pci_request_region(pdev, 1, DRV_NAME); + if (ret < 0) + return ret; =20 - if (request_region(ioaddr, iolen, DRV_NAME) =3D=3D NULL) { - printk(KERN_ERR DRV_NAME ":I/O resource 0x%lx @ 0x%lx = busy\n", - iolen, ioaddr); - release_mem_region(mmio_addr, mmio_len); - return -EBUSY; - } + ret =3D pci_request_region(pdev, 0, DRV_NAME); + if (ret < 0) + goto mem_out; =20 platform_mmio =3D mmio_addr; platform_mmiolen =3D mmio_len; @@ -429,8 +424,9 @@ static int __devinit platform_pci_init(s =20 out: if (ret) { - release_mem_region(mmio_addr, mmio_len); - release_region(ioaddr, iolen); + pci_release_region(pdev, 0); +mem_out: + pci_release_region(pdev, 1); } =20 return ret; --=__Part7F53130B.1__= Content-Type: text/plain; name="pvdrv-request-resources.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pvdrv-request-resources.patch" This is the correct interface to use and something has broken the use=0Aof = the previous incorrect interface (which fails because the request=0Aconflic= ts with the resources assigned for the PCI device itself=0Ainstead of = nesting like the PCI interfaces do).=0A=0Apci_request_region() has been = available since at least Linux 2.6.5.=0A=0ASigned-off-by: Ian Campbell = =0ASigned-off-by: Jan Beulich =0A=0A--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c=0A+++= b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c=0A@@ -382,18 = +382,13 @@ static int __devinit platform_pci_init(s=0A return = -ENOENT;=0A }=0A =0A- if (request_mem_region(mmio_addr, = mmio_len, DRV_NAME) =3D=3D NULL) {=0A- printk(KERN_ERR ":MEM I/O = resource 0x%lx @ 0x%lx busy\n",=0A- mmio_addr, = mmio_len);=0A- return -EBUSY;=0A- }=0A+ ret =3D pci_request= _region(pdev, 1, DRV_NAME);=0A+ if (ret < 0)=0A+ return = ret;=0A =0A- if (request_region(ioaddr, iolen, DRV_NAME) =3D=3D NULL) = {=0A- printk(KERN_ERR DRV_NAME ":I/O resource 0x%lx @ 0x%lx = busy\n",=0A- iolen, ioaddr);=0A- release_mem= _region(mmio_addr, mmio_len);=0A- return -EBUSY;=0A- = }=0A+ ret =3D pci_request_region(pdev, 0, DRV_NAME);=0A+ if (ret < = 0)=0A+ goto mem_out;=0A =0A platform_mmio =3D mmio_addr;=0A = platform_mmiolen =3D mmio_len;=0A@@ -429,8 +424,9 @@ static int __devinit = platform_pci_init(s=0A =0A out:=0A if (ret) {=0A- release_mem= _region(mmio_addr, mmio_len);=0A- release_region(ioaddr, = iolen);=0A+ pci_release_region(pdev, 0);=0A+mem_out:=0A+ = pci_release_region(pdev, 1);=0A }=0A =0A return ret;=0A --=__Part7F53130B.1__= 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 --=__Part7F53130B.1__=--