From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
Zwane Mwaikambo <zwane@arm.linux.org.uk>,
"Theodore Ts'o" <tytso@mit.edu>,
Randy Dunlap <rdunlap@xenotime.net>,
Dave Jones <davej@redhat.com>,
Chuck Wolber <chuckw@quantumlinux.com>,
Chris Wedgwood <reviews@ml.cw.f00f.org>,
Michael Krufky <mkrufky@linuxtv.org>,
Chuck Ebbert <cebbert@redhat.com>,
Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Karl Bongers <kbongers@jged.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Stefan Bader <stefan.bader@canonical.com>
Subject: [patch 18/41] USB: isp1760: Fix probe in PCI glue code
Date: Wed, 4 Feb 2009 10:46:24 -0800 [thread overview]
Message-ID: <20090204184624.GS25246@kroah.com> (raw)
In-Reply-To: <20090204184539.GA25246@kroah.com>
[-- Attachment #1: usb-isp1760-fix-probe-in-pci-glue-code.patch --]
[-- Type: text/plain, Size: 5216 bytes --]
2.6.27-stable review patch. If anyone has any objections, please let us know.
------------------
From: Karl Bongers <kbongers@jged.com>
This is the backported version of the upstream commit
Stefan Bader <stefan.bader@canonical.com> did the backport
Contains fixes so probe on x86 PCI runs, apparently I'm first to try
this. Several fixes to memory access to probe host scratch register.
Previously would bug check on chip_addr var used uninitialized.
Scratch reg write failed in one instance due to 16-bit initial access
mode, so added "& 0x0000ffff" to the readl as fix.
Includes some general cleanup - remove global vars, organize memory map
resource use.
Signed-off-by: Karl Bongers <kbongers@jged.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/host/isp1760-if.c | 96 ++++++++++++++++++++++++------------------
1 file changed, 55 insertions(+), 41 deletions(-)
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -129,23 +129,23 @@ static struct of_platform_driver isp1760
#endif
#ifdef CONFIG_PCI
-static u32 nxp_pci_io_base;
-static u32 iolength;
-static u32 pci_mem_phy0;
-static u32 length;
-static u8 __iomem *chip_addr;
-static u8 __iomem *iobase;
-
static int __devinit isp1761_pci_probe(struct pci_dev *dev,
const struct pci_device_id *id)
{
u8 latency, limit;
__u32 reg_data;
int retry_count;
- int length;
- int status = 1;
struct usb_hcd *hcd;
unsigned int devflags = 0;
+ int ret_status = 0;
+
+ resource_size_t pci_mem_phy0;
+ resource_size_t memlength;
+
+ u8 __iomem *chip_addr;
+ u8 __iomem *iobase;
+ resource_size_t nxp_pci_io_base;
+ resource_size_t iolength;
if (usb_disabled())
return -ENODEV;
@@ -168,26 +168,30 @@ static int __devinit isp1761_pci_probe(s
iobase = ioremap_nocache(nxp_pci_io_base, iolength);
if (!iobase) {
printk(KERN_ERR "ioremap #1\n");
- release_mem_region(nxp_pci_io_base, iolength);
- return -ENOMEM;
+ ret_status = -ENOMEM;
+ goto cleanup1;
}
/* Grab the PLX PCI shared memory of the ISP 1761 we need */
pci_mem_phy0 = pci_resource_start(dev, 3);
- length = pci_resource_len(dev, 3);
-
- if (length < 0xffff) {
- printk(KERN_ERR "memory length for this resource is less than "
- "required\n");
- release_mem_region(nxp_pci_io_base, iolength);
- iounmap(iobase);
- return -ENOMEM;
+ memlength = pci_resource_len(dev, 3);
+ if (memlength < 0xffff) {
+ printk(KERN_ERR "memory length for this resource is wrong\n");
+ ret_status = -ENOMEM;
+ goto cleanup2;
}
- if (!request_mem_region(pci_mem_phy0, length, "ISP-PCI")) {
+ if (!request_mem_region(pci_mem_phy0, memlength, "ISP-PCI")) {
printk(KERN_ERR "host controller already in use\n");
- release_mem_region(nxp_pci_io_base, iolength);
- iounmap(iobase);
- return -EBUSY;
+ ret_status = -EBUSY;
+ goto cleanup2;
+ }
+
+ /* map available memory */
+ chip_addr = ioremap_nocache(pci_mem_phy0,memlength);
+ if (!chip_addr) {
+ printk(KERN_ERR "Error ioremap failed\n");
+ ret_status = -ENOMEM;
+ goto cleanup3;
}
/* bad pci latencies can contribute to overruns */
@@ -210,38 +214,54 @@ static int __devinit isp1761_pci_probe(s
* */
writel(0xface, chip_addr + HC_SCRATCH_REG);
udelay(100);
- reg_data = readl(chip_addr + HC_SCRATCH_REG);
+ reg_data = readl(chip_addr + HC_SCRATCH_REG) & 0x0000ffff;
retry_count--;
}
+ iounmap(chip_addr);
+
/* Host Controller presence is detected by writing to scratch register
* and reading back and checking the contents are same or not
*/
if (reg_data != 0xFACE) {
err("scratch register mismatch %x", reg_data);
- goto clean;
+ ret_status = -ENOMEM;
+ goto cleanup3;
}
pci_set_master(dev);
- status = readl(iobase + 0x68);
- status |= 0x900;
- writel(status, iobase + 0x68);
+ /* configure PLX PCI chip to pass interrupts */
+#define PLX_INT_CSR_REG 0x68
+ reg_data = readl(iobase + PLX_INT_CSR_REG);
+ reg_data |= 0x900;
+ writel(reg_data, iobase + PLX_INT_CSR_REG);
dev->dev.dma_mask = NULL;
- hcd = isp1760_register(pci_mem_phy0, length, dev->irq,
+ hcd = isp1760_register(pci_mem_phy0, memlength, dev->irq,
IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev),
devflags);
+ if (IS_ERR(hcd)) {
+ ret_status = -ENODEV;
+ goto cleanup3;
+ }
+
+ /* done with PLX IO access */
+ iounmap(iobase);
+ release_mem_region(nxp_pci_io_base, iolength);
+
pci_set_drvdata(dev, hcd);
- if (!hcd)
- return 0;
-clean:
- status = -ENODEV;
+ return 0;
+
+cleanup3:
+ release_mem_region(pci_mem_phy0, memlength);
+cleanup2:
iounmap(iobase);
- release_mem_region(pci_mem_phy0, length);
+cleanup1:
release_mem_region(nxp_pci_io_base, iolength);
- return status;
+ return ret_status;
}
+
static void isp1761_pci_remove(struct pci_dev *dev)
{
struct usb_hcd *hcd;
@@ -254,12 +274,6 @@ static void isp1761_pci_remove(struct pc
usb_put_hcd(hcd);
pci_disable_device(dev);
-
- iounmap(iobase);
- iounmap(chip_addr);
-
- release_mem_region(nxp_pci_io_base, iolength);
- release_mem_region(pci_mem_phy0, length);
}
static void isp1761_pci_shutdown(struct pci_dev *dev)
next prev parent reply other threads:[~2009-02-04 18:58 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090204184029.881610776@mini.kroah.org>
2009-02-04 18:45 ` [patch 00/41] 2.6.27-stable review Greg KH
2009-02-04 18:45 ` [patch 01/41] cifs: make sure we allocate enough storage for socket address Greg KH
2009-02-04 18:45 ` [patch 02/41] ixgb: fix bug when freeing resources Greg KH
2009-02-04 18:45 ` [patch 03/41] m68knommu: set NO_DMA Greg KH
2009-02-04 18:45 ` [patch 04/41] sata_mv: fix 8-port timeouts on 508x/6081 chips Greg KH
2009-02-04 18:45 ` [patch 05/41] x86: use early clobbers in usercopy*.c Greg KH
2009-02-04 18:46 ` [patch 06/41] Add enable_ms to jsm driver Greg KH
2009-02-04 18:46 ` [patch 07/41] fbdev/atyfb: Fix DSP config on some PowerMacs & PowerBooks Greg KH
2009-02-04 23:51 ` Benjamin Herrenschmidt
2009-02-05 0:02 ` Greg KH
2009-02-05 9:23 ` Benjamin Herrenschmidt
2009-02-06 12:05 ` David Woodhouse
2009-02-06 13:48 ` Risto Suominen
2009-02-07 2:50 ` Benjamin Herrenschmidt
2009-02-04 18:46 ` [patch 08/41] Fix memory corruption in console selection Greg KH
2009-02-04 18:46 ` [patch 09/41] Input: atkbd - broaden the Dell DMI signatures Greg KH
2009-02-04 18:46 ` [patch 10/41] Input: atkbd - Samsung NC10 key repeat fix Greg KH
2009-02-04 18:46 ` [patch 11/41] net: fix packet socket delivery in rx irq handler Greg KH
2009-02-04 18:46 ` [patch 12/41] nfsd: Ensure nfsv4 calls the underlying filesystem on LOCKT Greg KH
2009-02-04 18:46 ` [patch 13/41] nfsd: only set file_lock.fl_lmops in nfsd4_lockt if a stateowner is found Greg KH
2009-02-04 18:46 ` [patch 14/41] PCI: irq and pci_ids patch for Intel Tigerpoint DeviceIDs Greg KH
2009-02-04 18:46 ` [patch 15/41] sata_nv: rename nv_nf2_hardreset() Greg KH
2009-02-04 18:46 ` [patch 16/41] sata_nv: fix MCP5x reset Greg KH
2009-02-04 18:46 ` [patch 17/41] sata_nv: ck804 has borked hardreset too Greg KH
2009-02-04 18:46 ` Greg KH [this message]
2009-02-04 18:46 ` [patch 19/41] x86: fix page attribute corruption with cpa() Greg KH
2009-02-04 18:46 ` [patch 20/41] cpuidle: update the last_state acpi cpuidle reflecting actual state entered Greg KH
2009-02-04 18:46 ` [patch 21/41] cpuidle: upon BIOS bug, default to default_idle rather than polling Greg KH
2009-02-04 18:46 ` [patch 22/41] cpuidle: use last_state which can reflect the actual state entered Greg KH
2009-02-04 18:46 ` [patch 23/41] cpuidle: Add decaying history logic to menu idle predictor Greg KH
2009-02-04 18:46 ` [patch 24/41] ACPI: Avoid array address overflow when _CST MWAIT hint bits are set Greg KH
2009-02-04 18:46 ` [patch 25/41] ACPI: Attach the ACPI device to the ACPI handle as early as possible Greg KH
2009-02-04 18:46 ` [patch 26/41] ACPICA: Fixed a couple memory leaks associated with "implicit return" Greg KH
2009-02-04 18:46 ` [patch 27/41] ACPICA: Add check for invalid handle in acpi_get_object_info Greg KH
2009-02-04 18:46 ` [patch 28/41] ACPI: Change acpi_evaluate_integer to support 64-bit on 32-bit kernels Greg KH
2009-02-04 18:46 ` [patch 29/41] ACPI: Fix compiler warnings introduced by 32 to 64 bit acpi conversions Greg KH
2009-02-04 18:46 ` [patch 30/41] ACPI EC: Fix regression due to use of uninitialized variable Greg KH
2009-02-05 8:08 ` Thomas Renninger
2009-02-05 15:06 ` Thomas Renninger
2009-02-05 17:30 ` Greg KH
2009-02-05 17:30 ` Greg KH
2009-02-04 18:46 ` [patch 31/41] ACPICA: Fix wrong resource descriptor length for 64-bit build Greg KH
2009-02-04 18:46 ` [patch 32/41] asus-laptop: Add support for P30/P35 Greg KH
2009-02-04 18:46 ` [patch 33/41] asus-laptop: Fix the led behavior with value > 1 Greg KH
2009-02-10 20:24 ` Pavel Machek
2009-02-10 20:57 ` Greg KH
2009-02-12 8:58 ` Pavel Machek
2009-02-12 9:15 ` Corentin Chary
2009-02-04 18:46 ` [patch 34/41] video: always update the brightness when poking "brightness" Greg KH
2009-02-04 18:46 ` [patch 35/41] dont load asus-acpi if model is not supported Greg KH
2009-02-04 18:47 ` [patch 36/41] Newly inserted battery might differ from one just removed, so Greg KH
2009-02-04 18:47 ` [patch 37/41] ACPI: Do not modify SCI_EN directly Greg KH
2009-02-04 18:47 ` [patch 38/41] ACPI suspend: Blacklist HP xw4600 Workstation for old code ordering Greg KH
2009-02-04 18:47 ` [patch 39/41] dlm: initialize file_lock struct in GETLK before copying conflicting lock Greg KH
2009-02-04 18:47 ` [patch 40/41] sata_mv: Fix chip type for Hightpoint RocketRaid 1740/1742 Greg KH
2009-02-04 18:47 ` [patch 41/41] ACPICA: Allow multiple backslash prefix in namepaths Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090204184624.GS25246@kroah.com \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bigeasy@linutronix.de \
--cc=cavokz@gmail.com \
--cc=cebbert@redhat.com \
--cc=chuckw@quantumlinux.com \
--cc=davej@redhat.com \
--cc=eteo@redhat.com \
--cc=jake@lwn.net \
--cc=jmforbes@linuxtx.org \
--cc=kbongers@jged.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mkrufky@linuxtv.org \
--cc=rbranco@la.checkpoint.com \
--cc=rdunlap@xenotime.net \
--cc=reviews@ml.cw.f00f.org \
--cc=stable@kernel.org \
--cc=stefan.bader@canonical.com \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=w@1wt.eu \
--cc=zwane@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox