From bb133450ee95746a9387f12de8bd738e79c21433 Mon Sep 17 00:00:00 2001 From: Hans-Christian Egtvedt Date: Tue, 30 Oct 2007 14:56:20 +0100 Subject: [WATCHDOG] at32ap700x_wdt: add support for boot status and add fix for silicon errata This patch enables the watchdog to read out the reset cause after a boot and provide this to the user. The driver will now also return -EIO if probed when booting from a watchdog reset. This is due to a silicon errata in the AT32AP700x devices. Detailed description and work-arounds can be found in the errata section of the datasheet avilable from http://www.atmel.com/dyn/products/datasheets.asp?family_id=682 Signed-off-by: Hans-Christian Egtvedt Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/watchdog/at32ap700x_wdt.c | 69 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c index 54a516169d0..fb5ed6478f7 100644 --- a/drivers/watchdog/at32ap700x_wdt.c +++ b/drivers/watchdog/at32ap700x_wdt.c @@ -6,6 +6,19 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. + * + * + * Errata: WDT Clear is blocked after WDT Reset + * + * A watchdog timer event will, after reset, block writes to the WDT_CLEAR + * register, preventing the program to clear the next Watchdog Timer Reset. + * + * If you still want to use the WDT after a WDT reset a small code can be + * insterted at the startup checking the AVR32_PM.rcause register for WDT reset + * and use a GPIO pin to reset the system. This method requires that one of the + * GPIO pins are available and connected externally to the RESET_N pin. After + * the GPIO pin has pulled down the reset line the GPIO will be reset and leave + * the pin tristated with pullup. */ #include @@ -44,6 +57,13 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" #define WDT_CLR 0x04 +#define WDT_RCAUSE 0x10 +#define WDT_RCAUSE_POR 0 +#define WDT_RCAUSE_EXT 2 +#define WDT_RCAUSE_WDT 3 +#define WDT_RCAUSE_JTAG 4 +#define WDT_RCAUSE_SERP 5 + #define WDT_BIT(name) (1 << WDT_##name) #define WDT_BF(name, value) ((value) << WDT_##name) @@ -56,6 +76,7 @@ struct wdt_at32ap700x { void __iomem *regs; spinlock_t io_lock; int timeout; + int boot_status; unsigned long users; struct miscdevice miscdev; }; @@ -126,7 +147,7 @@ static int at32_wdt_close(struct inode *inode, struct file *file) at32_wdt_stop(); } else { dev_dbg(wdt->miscdev.parent, - "Unexpected close, not stopping watchdog!\n"); + "unexpected close, not stopping watchdog!\n"); at32_wdt_pat(); } clear_bit(1, &wdt->users); @@ -154,6 +175,33 @@ static int at32_wdt_settimeout(int time) return 0; } +/* + * Get the watchdog status. + */ +static int at32_wdt_get_status(void) +{ + int rcause; + int status = 0; + + rcause = wdt_readl(wdt, RCAUSE); + + switch (rcause) { + case WDT_BIT(RCAUSE_EXT): + status = WDIOF_EXTERN1; + break; + case WDT_BIT(RCAUSE_WDT): + status = WDIOF_CARDRESET; + break; + case WDT_BIT(RCAUSE_POR): /* fall through */ + case WDT_BIT(RCAUSE_JTAG): /* fall through */ + case WDT_BIT(RCAUSE_SERP): /* fall through */ + default: + break; + } + + return status; +} + static struct watchdog_info at32_wdt_info = { .identity = "at32ap700x watchdog", .options = WDIOF_SETTIMEOUT | @@ -194,10 +242,12 @@ static int at32_wdt_ioctl(struct inode *inode, struct file *file, case WDIOC_GETTIMEOUT: ret = put_user(wdt->timeout, p); break; - case WDIOC_GETSTATUS: /* fall through */ - case WDIOC_GETBOOTSTATUS: + case WDIOC_GETSTATUS: ret = put_user(0, p); break; + case WDIOC_GETBOOTSTATUS: + ret = put_user(wdt->boot_status, p); + break; case WDIOC_SETOPTIONS: ret = get_user(time, p); if (ret) @@ -282,8 +332,19 @@ static int __init at32_wdt_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "could not map I/O memory\n"); goto err_free; } + spin_lock_init(&wdt->io_lock); - wdt->users = 0; + wdt->boot_status = at32_wdt_get_status(); + + /* Work-around for watchdog silicon errata. */ + if (wdt->boot_status & WDIOF_CARDRESET) { + dev_info(&pdev->dev, "CPU must be reset with external " + "reset or POR due to silicon errata.\n"); + ret = -EIO; + goto err_iounmap; + } else { + wdt->users = 0; + } wdt->miscdev.minor = WATCHDOG_MINOR; wdt->miscdev.name = "watchdog"; wdt->miscdev.fops = &at32_wdt_fops; -- cgit v1.2.3 From 3ff6eb4a2fe5757cbe7c5d57c8eb60ab0775f2f0 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sun, 4 Nov 2007 20:20:23 +0100 Subject: [WATCHDOG] Stop looking for device as soon as one is found If no address is given for the W83697HF/HG watchdog IO port, stop looping through possible locations when a watchdog device has been found. Signed-off-by: Samuel Tardieu Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/w83697hf_wdt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/watchdog/w83697hf_wdt.c b/drivers/watchdog/w83697hf_wdt.c index c622a0e6c9a..6ea125eabea 100644 --- a/drivers/watchdog/w83697hf_wdt.c +++ b/drivers/watchdog/w83697hf_wdt.c @@ -382,8 +382,10 @@ wdt_init(void) /* we will autodetect the W83697HF/HG watchdog */ for (i = 0; ((!found) && (w83697hf_ioports[i] != 0)); i++) { wdt_io = w83697hf_ioports[i]; - if (!w83697hf_check_wdt()) + if (!w83697hf_check_wdt()) { found++; + break; + } } } else { if (!w83697hf_check_wdt()) -- cgit v1.2.3 From bf6350a3dfcbd0a0811d7c210beacb66e90eca47 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Sat, 10 Nov 2007 05:58:44 +0100 Subject: [WATCHDOG] bfin_wdt, remove SPIN_LOCK_UNLOCKED bfin_wdt, remove SPIN_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED is deprecated, use DEFINE_SPINLOCK instead Signed-off-by: Jiri Slaby Acked-by: Mike Frysinger Cc: Bryan Wu Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/watchdog/bfin_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/watchdog/bfin_wdt.c b/drivers/watchdog/bfin_wdt.c index 309d27913fc..31dc7a69e90 100644 --- a/drivers/watchdog/bfin_wdt.c +++ b/drivers/watchdog/bfin_wdt.c @@ -71,7 +71,7 @@ static int nowayout = WATCHDOG_NOWAYOUT; static struct watchdog_info bfin_wdt_info; static unsigned long open_check; static char expect_close; -static spinlock_t bfin_wdt_spinlock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(bfin_wdt_spinlock); /** * bfin_wdt_keepalive - Keep the Userspace Watchdog Alive -- cgit v1.2.3 From 6027f661f8da653f084df80f4aade21359bcea35 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Sat, 10 Nov 2007 04:32:45 +0100 Subject: [WATCHDOG] Sbus: cpwatchdog, remove SPIN_LOCK_UNLOCKED cpwatchdog, remove SPIN_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED is deprecated, use __SPIN_LOCK_UNLOCKED with an unique name instead Signed-off-by: Jiri Slaby Cc: "David S. Miller" Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/sbus/char/cpwatchdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c index 7b5773d8821..a4e75814366 100644 --- a/drivers/sbus/char/cpwatchdog.c +++ b/drivers/sbus/char/cpwatchdog.c @@ -154,7 +154,7 @@ struct wd_device { }; static struct wd_device wd_dev = { - 0, SPIN_LOCK_UNLOCKED, 0, 0, 0, 0, + 0, __SPIN_LOCK_UNLOCKED(wd_dev.lock), 0, 0, 0, 0, }; static struct timer_list wd_timer; -- cgit v1.2.3 From 38ff6fd2fa4959925cf217ccaebea90fabd8ce04 Mon Sep 17 00:00:00 2001 From: "Jorge Boncompte [DTI2]" Date: Mon, 19 Nov 2007 15:09:21 +0100 Subject: [WATCHDOG] IT8212F watchdog driver This patch adds support for the ITE Tech Inc. IT8712F EC-LPC Super I/O chipset found on many Pentium III and AMD motherboards. Developed using code from other watchdog drivers and the datasheet on ITE Tech homepage. Signed-off-by: Jorge Boncompte Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/Kconfig | 10 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/it8712f_wdt.c | 400 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 411 insertions(+) create mode 100644 drivers/watchdog/it8712f_wdt.c (limited to 'drivers') diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 2792bc1a726..126b554810c 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -392,6 +392,16 @@ config ITCO_VENDOR_SUPPORT devices. At this moment we only have additional support for some SuperMicro Inc. motherboards. +config IT8712F_WDT + tristate "IT8712F (Smart Guardian) Watchdog Timer" + depends on X86 + ---help--- + This is the driver for the built-in watchdog timer on the IT8712F + Super I/0 chipset used on many motherboards. + + To compile this driver as a module, choose M here: the + module will be called it8712f_wdt. + config SC1200_WDT tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" depends on X86 diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 7d9e5734f8b..e4779f76b1e 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_IBMASR) += ibmasr.o obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o iTCO_vendor_support.o +obj-$(CONFIG_IT8712F_WDT) += it8712f_wdt.o obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o diff --git a/drivers/watchdog/it8712f_wdt.c b/drivers/watchdog/it8712f_wdt.c new file mode 100644 index 00000000000..6330fc02464 --- /dev/null +++ b/drivers/watchdog/it8712f_wdt.c @@ -0,0 +1,400 @@ +/* + * IT8712F "Smart Guardian" Watchdog support + * + * Copyright (c) 2006-2007 Jorge Boncompte - DTI2 + * + * Based on info and code taken from: + * + * drivers/char/watchdog/scx200_wdt.c + * drivers/hwmon/it87.c + * IT8712F EC-LPC I/O Preliminary Specification 0.9.2.pdf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * The author(s) of this software shall not be held liable for damages + * of any nature resulting due to the use of this software. This + * software is provided AS-IS with no warranties. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define NAME "it8712f_wdt" + +MODULE_AUTHOR("Jorge Boncompte - DTI2 "); +MODULE_DESCRIPTION("IT8712F Watchdog Driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); + +static int margin = 60; /* in seconds */ +module_param(margin, int, 0); +MODULE_PARM_DESC(margin, "Watchdog margin in seconds"); + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); + +static struct semaphore it8712f_wdt_sem; +static unsigned expect_close; +static spinlock_t io_lock; + +/* Dog Food address - We use the game port address */ +static unsigned short address; + +#define REG 0x2e /* The register to read/write */ +#define VAL 0x2f /* The value to read/write */ + +#define LDN 0x07 /* Register: Logical device select */ +#define DEVID 0x20 /* Register: Device ID */ +#define DEVREV 0x22 /* Register: Device Revision */ +#define ACT_REG 0x30 /* LDN Register: Activation */ +#define BASE_REG 0x60 /* LDN Register: Base address */ + +#define IT8712F_DEVID 0x8712 + +#define LDN_GPIO 0x07 /* GPIO and Watch Dog Timer */ +#define LDN_GAME 0x09 /* Game Port */ + +#define WDT_CONTROL 0x71 /* WDT Register: Control */ +#define WDT_CONFIG 0x72 /* WDT Register: Configuration */ +#define WDT_TIMEOUT 0x73 /* WDT Register: Timeout Value */ + +#define WDT_RESET_GAME 0x10 +#define WDT_RESET_KBD 0x20 +#define WDT_RESET_MOUSE 0x40 +#define WDT_RESET_CIR 0x80 + +#define WDT_UNIT_SEC 0x80 /* If 0 in MINUTES */ + +#define WDT_OUT_PWROK 0x10 +#define WDT_OUT_KRST 0x40 + +static int +superio_inb(int reg) +{ + outb(reg, REG); + return inb(VAL); +} + +static void +superio_outb(int val, int reg) +{ + outb(reg, REG); + outb(val, VAL); +} + +static int +superio_inw(int reg) +{ + int val; + outb(reg++, REG); + val = inb(VAL) << 8; + outb(reg, REG); + val |= inb(VAL); + return val; +} + +static inline void +superio_select(int ldn) +{ + outb(LDN, REG); + outb(ldn, VAL); +} + +static inline void +superio_enter(void) +{ + spin_lock(&io_lock); + outb(0x87, REG); + outb(0x01, REG); + outb(0x55, REG); + outb(0x55, REG); +} + +static inline void +superio_exit(void) +{ + outb(0x02, REG); + outb(0x02, VAL); + spin_unlock(&io_lock); +} + +static inline void +it8712f_wdt_ping(void) +{ + inb(address); +} + +static void +it8712f_wdt_update_margin(void) +{ + int config = WDT_OUT_KRST | WDT_OUT_PWROK; + + printk(KERN_INFO NAME ": timer margin %d seconds\n", margin); + + /* The timeout register only has 8bits wide */ + if (margin < 256) + config |= WDT_UNIT_SEC; /* else UNIT are MINUTES */ + superio_outb(config, WDT_CONFIG); + + superio_outb((margin > 255) ? (margin / 60) : margin, WDT_TIMEOUT); +} + +static void +it8712f_wdt_enable(void) +{ + printk(KERN_DEBUG NAME ": enabling watchdog timer\n"); + superio_enter(); + superio_select(LDN_GPIO); + + superio_outb(WDT_RESET_GAME, WDT_CONTROL); + + it8712f_wdt_update_margin(); + + superio_exit(); + + it8712f_wdt_ping(); +} + +static void +it8712f_wdt_disable(void) +{ + printk(KERN_DEBUG NAME ": disabling watchdog timer\n"); + + superio_enter(); + superio_select(LDN_GPIO); + + superio_outb(0, WDT_CONFIG); + superio_outb(0, WDT_CONTROL); + superio_outb(0, WDT_TIMEOUT); + + superio_exit(); +} + +static int +it8712f_wdt_notify(struct notifier_block *this, + unsigned long code, void *unused) +{ + if (code == SYS_HALT || code == SYS_POWER_OFF) + if (!nowayout) + it8712f_wdt_disable(); + + return NOTIFY_DONE; +} + +static struct notifier_block it8712f_wdt_notifier = { + .notifier_call = it8712f_wdt_notify, +}; + +static ssize_t +it8712f_wdt_write(struct file *file, const char __user *data, + size_t len, loff_t *ppos) +{ + /* check for a magic close character */ + if (len) { + size_t i; + + it8712f_wdt_ping(); + + expect_close = 0; + for (i = 0; i < len; ++i) { + char c; + if (get_user(c, data+i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + + return len; +} + +static int +it8712f_wdt_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + void __user *argp = (void __user *)arg; + int __user *p = argp; + static struct watchdog_info ident = { + .identity = "IT8712F Watchdog", + .firmware_version = 1, + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, + }; + int new_margin; + + switch (cmd) { + default: + return -ENOTTY; + case WDIOC_GETSUPPORT: + if (copy_to_user(argp, &ident, sizeof(ident))) + return -EFAULT; + return 0; + case WDIOC_GETSTATUS: + case WDIOC_GETBOOTSTATUS: + return put_user(0, p); + case WDIOC_KEEPALIVE: + it8712f_wdt_ping(); + return 0; + case WDIOC_SETTIMEOUT: + if (get_user(new_margin, p)) + return -EFAULT; + if (new_margin < 1) + return -EINVAL; + margin = new_margin; + superio_enter(); + superio_select(LDN_GPIO); + + it8712f_wdt_update_margin(); + + superio_exit(); + it8712f_wdt_ping(); + case WDIOC_GETTIMEOUT: + if (put_user(margin, p)) + return -EFAULT; + return 0; + } +} + +static int +it8712f_wdt_open(struct inode *inode, struct file *file) +{ + /* only allow one at a time */ + if (down_trylock(&it8712f_wdt_sem)) + return -EBUSY; + it8712f_wdt_enable(); + + return nonseekable_open(inode, file); +} + +static int +it8712f_wdt_release(struct inode *inode, struct file *file) +{ + if (expect_close != 42) { + printk(KERN_WARNING NAME + ": watchdog device closed unexpectedly, will not" + " disable the watchdog timer\n"); + } else if (!nowayout) { + it8712f_wdt_disable(); + } + expect_close = 0; + up(&it8712f_wdt_sem); + + return 0; +} + +static struct file_operations it8712f_wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = it8712f_wdt_write, + .ioctl = it8712f_wdt_ioctl, + .open = it8712f_wdt_open, + .release = it8712f_wdt_release, +}; + +static struct miscdevice it8712f_wdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &it8712f_wdt_fops, +}; + +static int __init +it8712f_wdt_find(unsigned short *address) +{ + int err = -ENODEV; + int chip_type; + + superio_enter(); + chip_type = superio_inw(DEVID); + if (chip_type != IT8712F_DEVID) + goto exit; + + superio_select(LDN_GAME); + superio_outb(1, ACT_REG); + if (!(superio_inb(ACT_REG) & 0x01)) { + printk(KERN_ERR NAME ": Device not activated, skipping\n"); + goto exit; + } + + *address = superio_inw(BASE_REG); + if (*address == 0) { + printk(KERN_ERR NAME ": Base address not set, skipping\n"); + goto exit; + } + + err = 0; + printk(KERN_DEBUG NAME ": Found IT%04xF chip revision %d - " + "using DogFood address 0x%x\n", + chip_type, superio_inb(DEVREV) & 0x0f, *address); + +exit: + superio_exit(); + return err; +} + +static int __init +it8712f_wdt_init(void) +{ + int err = 0; + + spin_lock_init(&io_lock); + + if (it8712f_wdt_find(&address)) + return -ENODEV; + + if (!request_region(address, 1, "IT8712F Watchdog")) { + printk(KERN_WARNING NAME ": watchdog I/O region busy\n"); + return -EBUSY; + } + + it8712f_wdt_disable(); + + sema_init(&it8712f_wdt_sem, 1); + + err = register_reboot_notifier(&it8712f_wdt_notifier); + if (err) { + printk(KERN_ERR NAME ": unable to register reboot notifier\n"); + goto out; + } + + err = misc_register(&it8712f_wdt_miscdev); + if (err) { + printk(KERN_ERR NAME + ": cannot register miscdev on minor=%d (err=%d)\n", + WATCHDOG_MINOR, err); + goto reboot_out; + } + + return 0; + + +reboot_out: + unregister_reboot_notifier(&it8712f_wdt_notifier); +out: + release_region(address, 1); + return err; +} + +static void __exit +it8712f_wdt_exit(void) +{ + misc_deregister(&it8712f_wdt_miscdev); + unregister_reboot_notifier(&it8712f_wdt_notifier); + release_region(address, 1); +} + +module_init(it8712f_wdt_init); +module_exit(it8712f_wdt_exit); -- cgit v1.2.3 From 6ce7641b879e4b9ead46e14275d9d3645b47fa63 Mon Sep 17 00:00:00 2001 From: Gary Hade Date: Tue, 20 Nov 2007 12:19:12 -0800 Subject: ACPI: acpiphp: Remove dmesg spam on device remove In cases where acpi_pci_bind() does not attach device data, acpi_pci_unbind() complains via an ACPI exception about the missing data when the device is removed. For example, acpi_pci_bind() does not attach data for non-existent device functions so when the device is removed using the ACPI PCI hotplug driver 'acpiphp' an ACPI exception is logged for every non-existent function. This patch avoids the confusing log messages by removing the unnecessary ACPI exception. Signed-off-by: Gary Hade Signed-off-by: Len Brown --- drivers/acpi/pci_bind.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c index 028969370bb..388300de005 100644 --- a/drivers/acpi/pci_bind.c +++ b/drivers/acpi/pci_bind.c @@ -294,9 +294,6 @@ int acpi_pci_unbind(struct acpi_device *device) acpi_get_data(device->handle, acpi_pci_data_handler, (void **)&data); if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, - "Unable to get data from device %s", - acpi_device_bid(device))); result = -ENODEV; goto end; } -- cgit v1.2.3 From 783e6bcde4e6a7c849fa5fa7f35b0fba721ac5f4 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Tue, 20 Nov 2007 12:14:46 -0800 Subject: [WATCHDOG] ipmi: add the standard watchdog timeout ioctls Add the standard IOCTLs to the IPMI driver for setting and getting the pretimeout. Tested by Benoit Guillon. Signed off by: Corey Minyard Cc: Benoit Guillon Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/ipmi/ipmi_watchdog.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index e686fc92516..8f45ca9235a 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -669,6 +669,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, return 0; case WDIOC_SET_PRETIMEOUT: + case WDIOC_SETPRETIMEOUT: i = copy_from_user(&val, argp, sizeof(int)); if (i) return -EFAULT; @@ -676,6 +677,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); case WDIOC_GET_PRETIMEOUT: + case WDIOC_GETPRETIMEOUT: i = copy_to_user(argp, &pretimeout, sizeof(pretimeout)); if (i) return -EFAULT; -- cgit v1.2.3 From c4c283357d865aad1f124c069f5f6e3f39e76790 Mon Sep 17 00:00:00 2001 From: Gilles Gigan Date: Wed, 31 Oct 2007 16:31:42 +1000 Subject: [WATCHDOG] add Nano 7240 driver Adds support for the built-in watchdog on EPIC Nano 7240 boards from IEI. Tested on Nano-7240RS. Hardware documentation of the platform (including watchdog) can be found on the IEI website: http://www.ieiworld.com Signed-off-by: Gilles Gigan Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/Kconfig | 13 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sbc7240_wdt.c | 324 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 338 insertions(+) create mode 100644 drivers/watchdog/sbc7240_wdt.c (limited to 'drivers') diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 126b554810c..52dff40ec19 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -466,6 +466,19 @@ config SBC8360_WDT Most people will say N. +config SBC7240_WDT + tristate "SBC Nano 7240 Watchdog Timer" + depends on X86_32 + ---help--- + This is the driver for the hardware watchdog found on the IEI + single board computers EPIC Nano 7240 (and likely others). This + watchdog simply watches your kernel to make sure it doesn't freeze, + and if it does, it reboots your computer after a certain amount of + time. + + To compile this driver as a module, choose M here: the + module will be called sbc7240_wdt. + config CPU5_WDT tristate "SMA CPU5 Watchdog" depends on X86 diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index e4779f76b1e..87483cc6325 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -72,6 +72,7 @@ obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o obj-$(CONFIG_SBC8360_WDT) += sbc8360.o +obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o diff --git a/drivers/watchdog/sbc7240_wdt.c b/drivers/watchdog/sbc7240_wdt.c new file mode 100644 index 00000000000..4c8cefbd862 --- /dev/null +++ b/drivers/watchdog/sbc7240_wdt.c @@ -0,0 +1,324 @@ +/* + * NANO7240 SBC Watchdog device driver + * + * Based on w83877f.c by Scott Jennings, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * (c) Copyright 2007 Gilles GIGAN + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SBC7240_PREFIX "sbc7240_wdt: " + +#define SBC7240_ENABLE_PORT 0x443 +#define SBC7240_DISABLE_PORT 0x043 +#define SBC7240_SET_TIMEOUT_PORT SBC7240_ENABLE_PORT +#define SBC7240_MAGIC_CHAR 'V' + +#define SBC7240_TIMEOUT 30 +#define SBC7240_MAX_TIMEOUT 255 +static int timeout = SBC7240_TIMEOUT; /* in seconds */ +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=" + __MODULE_STRING(SBC7240_MAX_TIMEOUT) ", default=" + __MODULE_STRING(SBC7240_TIMEOUT) ")"); + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Disable watchdog when closing device file"); + +#define SBC7240_OPEN_STATUS_BIT 0 +#define SBC7240_ENABLED_STATUS_BIT 1 +#define SBC7240_EXPECT_CLOSE_STATUS_BIT 2 +static unsigned long wdt_status; + +/* + * Utility routines + */ + +static void wdt_disable(void) +{ + /* disable the watchdog */ + if (test_and_clear_bit(SBC7240_ENABLED_STATUS_BIT, &wdt_status)) { + inb_p(SBC7240_DISABLE_PORT); + printk(KERN_INFO SBC7240_PREFIX + "Watchdog timer is now disabled.\n"); + } +} + +static void wdt_enable(void) +{ + /* enable the watchdog */ + if (!test_and_set_bit(SBC7240_ENABLED_STATUS_BIT, &wdt_status)) { + inb_p(SBC7240_ENABLE_PORT); + printk(KERN_INFO SBC7240_PREFIX + "Watchdog timer is now enabled.\n"); + } +} + +static int wdt_set_timeout(int t) +{ + if (t < 1 || t > SBC7240_MAX_TIMEOUT) { + printk(KERN_ERR SBC7240_PREFIX + "timeout value must be 1<=x<=%d\n", + SBC7240_MAX_TIMEOUT); + return -1; + } + /* set the timeout */ + outb_p((unsigned)t, SBC7240_SET_TIMEOUT_PORT); + timeout = t; + printk(KERN_INFO SBC7240_PREFIX "timeout set to %d seconds\n", t); + return 0; +} + +/* Whack the dog */ +static inline void wdt_keepalive(void) +{ + if (test_bit(SBC7240_ENABLED_STATUS_BIT, &wdt_status)) + inb_p(SBC7240_ENABLE_PORT); +} + +/* + * /dev/watchdog handling + */ +static ssize_t fop_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + size_t i; + char c; + + if (count) { + if (!nowayout) { + clear_bit(SBC7240_EXPECT_CLOSE_STATUS_BIT, + &wdt_status); + + /* is there a magic char ? */ + for (i = 0; i != count; i++) { + if (get_user(c, buf + i)) + return -EFAULT; + if (c == SBC7240_MAGIC_CHAR) { + set_bit(SBC7240_EXPECT_CLOSE_STATUS_BIT, + &wdt_status); + break; + } + } + } + + wdt_keepalive(); + } + + return count; +} + +static int fop_open(struct inode *inode, struct file *file) +{ + if (test_and_set_bit(SBC7240_OPEN_STATUS_BIT, &wdt_status)) + return -EBUSY; + + wdt_enable(); + + return nonseekable_open(inode, file); +} + +static int fop_close(struct inode *inode, struct file *file) +{ + if (test_and_clear_bit(SBC7240_EXPECT_CLOSE_STATUS_BIT, &wdt_status) + || !nowayout) { + wdt_disable(); + } else { + printk(KERN_CRIT SBC7240_PREFIX + "Unexpected close, not stopping watchdog!\n"); + wdt_keepalive(); + } + + clear_bit(SBC7240_OPEN_STATUS_BIT, &wdt_status); + return 0; +} + +static struct watchdog_info ident = { + .options = WDIOF_KEEPALIVEPING| + WDIOF_SETTIMEOUT| + WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "SBC7240", +}; + + +static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + switch (cmd) { + case WDIOC_GETSUPPORT: + return copy_to_user + ((void __user *)arg, &ident, sizeof(ident)) + ? -EFAULT : 0; + case WDIOC_GETSTATUS: + case WDIOC_GETBOOTSTATUS: + return put_user(0, (int __user *)arg); + case WDIOC_KEEPALIVE: + wdt_keepalive(); + return 0; + case WDIOC_SETOPTIONS:{ + int options; + int retval = -EINVAL; + + if (get_user(options, (int __user *)arg)) + return -EFAULT; + + if (options & WDIOS_DISABLECARD) { + wdt_disable(); + retval = 0; + } + + if (options & WDIOS_ENABLECARD) { + wdt_enable(); + retval = 0; + } + + return retval; + } + case WDIOC_SETTIMEOUT:{ + int new_timeout; + + if (get_user(new_timeout, (int __user *)arg)) + return -EFAULT; + + if (wdt_set_timeout(new_timeout)) + return -EINVAL; + + /* Fall through */ + } + case WDIOC_GETTIMEOUT: + return put_user(timeout, (int __user *)arg); + default: + return -ENOTTY; + } +} + +static const struct file_operations wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = fop_write, + .open = fop_open, + .release = fop_close, + .ioctl = fop_ioctl, +}; + +static struct miscdevice wdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wdt_fops, +}; + +/* + * Notifier for system down + */ + +static int wdt_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if (code == SYS_DOWN || code == SYS_HALT) + wdt_disable(); + return NOTIFY_DONE; +} + +static struct notifier_block wdt_notifier = { + .notifier_call = wdt_notify_sys, +}; + +static void __exit sbc7240_wdt_unload(void) +{ + printk(KERN_INFO SBC7240_PREFIX "Removing watchdog\n"); + misc_deregister(&wdt_miscdev); + + unregister_reboot_notifier(&wdt_notifier); + release_region(SBC7240_ENABLE_PORT, 1); +} + +static int __init sbc7240_wdt_init(void) +{ + int rc = -EBUSY; + + if (!request_region(SBC7240_ENABLE_PORT, 1, "SBC7240 WDT")) { + printk(KERN_ERR SBC7240_PREFIX + "I/O address 0x%04x already in use\n", + SBC7240_ENABLE_PORT); + rc = -EIO; + goto err_out; + } + + /* The IO port 0x043 used to disable the watchdog + * is already claimed by the system timer, so we + * cant request_region() it ...*/ + + if (timeout < 1 || timeout > SBC7240_MAX_TIMEOUT) { + timeout = SBC7240_TIMEOUT; + printk(KERN_INFO SBC7240_PREFIX + "timeout value must be 1<=x<=%d, using %d\n", + SBC7240_MAX_TIMEOUT, timeout); + } + wdt_set_timeout(timeout); + wdt_disable(); + + rc = register_reboot_notifier(&wdt_notifier); + if (rc) { + printk(KERN_ERR SBC7240_PREFIX + "cannot register reboot notifier (err=%d)\n", rc); + goto err_out_region; + } + + rc = misc_register(&wdt_miscdev); + if (rc) { + printk(KERN_ERR SBC7240_PREFIX + "cannot register miscdev on minor=%d (err=%d)\n", + wdt_miscdev.minor, rc); + goto err_out_reboot_notifier; + } + + printk(KERN_INFO SBC7240_PREFIX + "Watchdog driver for SBC7240 initialised (nowayout=%d)\n", + nowayout); + + return 0; + +err_out_reboot_notifier: + unregister_reboot_notifier(&wdt_notifier); +err_out_region: + release_region(SBC7240_ENABLE_PORT, 1); +err_out: + return rc; +} + +module_init(sbc7240_wdt_init); +module_exit(sbc7240_wdt_unload); + +MODULE_AUTHOR("Gilles Gigan"); +MODULE_DESCRIPTION("Watchdog device driver for single board" + " computers EPIC Nano 7240 from iEi"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); + -- cgit v1.2.3 From ad40e68bf5c54831cd6b2199fd24d616bac179f7 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 10 Nov 2007 20:02:49 +0300 Subject: ACPI: battery: fix ACPI battery technology reporting At least some systems report technology information with trailing spaces: {pts/1}% cat -E /var/tmp/bat/2.6.23 | grep type battery type: Li-ION $ Use strncasecmp to compare model string to skip trailing part Signed-off-by: Andrey Borzenkov Acked-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 7d6be23eff8..8f7505d304b 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -125,7 +125,7 @@ static int acpi_battery_technology(struct acpi_battery *battery) return POWER_SUPPLY_TECHNOLOGY_NiMH; if (!strcasecmp("LION", battery->type)) return POWER_SUPPLY_TECHNOLOGY_LION; - if (!strcasecmp("LI-ION", battery->type)) + if (!strncasecmp("LI-ION", battery->type, 6)) return POWER_SUPPLY_TECHNOLOGY_LION; if (!strcasecmp("LiP", battery->type)) return POWER_SUPPLY_TECHNOLOGY_LIPO; -- cgit v1.2.3 From a186b4a6b22fdc96a1ed63da483d267b5d00839e Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Mon, 3 Dec 2007 13:43:12 -0500 Subject: firewire: OHCI 1.0 Isochronous Receive support Third rendition of FireWire OHCI 1.0 Isochronous Receive support, using a zer-copy method similar to OHCI 1.1 which puts the IR data payload directly into the userspace buffer. The zero-copy implementation eliminates the video artifacts, audio popping, and buffer underrun problems seen with version 1 of this patch, as well as fixing a regression in OHCI 1.1 support introduced by version 2 of this patch. Successfully tested in OHCI 1.1 mode on the following chipsets: - NEC uPD72847 (rev 01), OHCI 1.1 (PCI) - Ti XIO2200(A) (rev 01), OHCI 1.1 (PCIe) - Ti TSB41AB2 (rev 01), OHCI 1.1 (PCI on SB Audigy) - Apple UniNorth 2 (rev 81), OHCI 1.1 (PowerBook G4 onboard) Successfully tested in OHCI 1.0 mode on the following chipsets: - Agere FW323 (rev 06), OHCI 1.0 (Mac Mini onboard) - Agere FW323 (rev 06), OHCI 1.0 (PCI) - Via VT6306 (rev 46), OHCI 1.0 (PCI) - NEC OrangeLink (rev 01), OHCI 1.0 (PCI) - NEC uPD72847 (rev 01), OHCI 1.1 (PCI) - Ti XIO2200(A) (rev 01), OHCI 1.1 (PCIe) The bulk of testing was done in an x86_64 system, but was also successfully sanity-tested on other systems, including a PPC(32) PowerBook G4 and an i686 EPIA M10k. Crude benchmarking (watching top during capture) puts the cpu utilization during capture on the EPIA's 1GHz Via C3 processor around 13%, which is down from 30% with the v1 code. Some implementation details: To maintain the same userspace API as dual-buffer mode, we set up two descriptors for every incoming packet. The first is an INPUT_MORE descriptor, pointing to a buffer large enough to hold just the packet's iso headers, immediately followed by an INPUT_LAST descriptor, pointing to a chunk of the userspace buffer big enough for the packet's data payload. With this setup, each incoming packet fills in these two descriptors in a manner that very closely emulates dual-buffer receive, to the point where the bulk of the handle_ir_* code is now identical between the two (and probably primed for some restructuring to share code between them). The only caveat I have at the moment is that neither of my OHCI 1.0 Via VT6307-based FireWire controllers work particularly well with this code for reasons I have yet to figure out. Signed-off-by: Jarod Wilson Signed-off-by: Stefan Richter --- drivers/firewire/fw-ohci.c | 175 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 155 insertions(+), 20 deletions(-) (limited to 'drivers') diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c index c9b9081831d..436a855a4c6 100644 --- a/drivers/firewire/fw-ohci.c +++ b/drivers/firewire/fw-ohci.c @@ -437,6 +437,21 @@ static void ar_context_run(struct ar_context *ctx) flush_writes(ctx->ohci); } +static struct descriptor * +find_branch_descriptor(struct descriptor *d, int z) +{ + int b, key; + + b = (le16_to_cpu(d->control) & DESCRIPTOR_BRANCH_ALWAYS) >> 2; + key = (le16_to_cpu(d->control) & DESCRIPTOR_KEY_IMMEDIATE) >> 8; + + /* figure out which descriptor the branch address goes in */ + if (z == 2 && (b == 3 || key == 2)) + return d; + else + return d + z - 1; +} + static void context_tasklet(unsigned long data) { struct context *ctx = (struct context *) data; @@ -455,7 +470,7 @@ static void context_tasklet(unsigned long data) address = le32_to_cpu(last->branch_address); z = address & 0xf; d = ctx->buffer + (address - ctx->buffer_bus) / sizeof(*d); - last = (z == 2) ? d : d + z - 1; + last = find_branch_descriptor(d, z); if (!ctx->callback(ctx, d, last)) break; @@ -566,7 +581,7 @@ static void context_append(struct context *ctx, ctx->head_descriptor = d + z + extra; ctx->prev_descriptor->branch_address = cpu_to_le32(d_bus | z); - ctx->prev_descriptor = z == 2 ? d : d + z - 1; + ctx->prev_descriptor = find_branch_descriptor(d, z); dma_sync_single_for_device(ctx->ohci->card.device, ctx->buffer_bus, ctx->buffer_size, DMA_TO_DEVICE); @@ -655,7 +670,7 @@ at_context_queue_packet(struct context *ctx, struct fw_packet *packet) driver_data = (struct driver_data *) &d[3]; driver_data->packet = packet; packet->driver_data = driver_data; - + if (packet->payload_length > 0) { payload_bus = dma_map_single(ohci->card.device, packet->payload, @@ -903,7 +918,7 @@ at_context_transmit(struct context *ctx, struct fw_packet *packet) if (retval < 0) packet->callback(packet, &ctx->ohci->card, packet->ack); - + } static void bus_reset_tasklet(unsigned long data) @@ -1431,6 +1446,57 @@ static int handle_ir_dualbuffer_packet(struct context *context, return 1; } +static int handle_ir_packet_per_buffer(struct context *context, + struct descriptor *d, + struct descriptor *last) +{ + struct iso_context *ctx = + container_of(context, struct iso_context, context); + struct descriptor *pd = d + 1; + __le32 *ir_header; + size_t header_length; + void *p, *end; + int i, z; + + if (pd->res_count == pd->req_count) + /* Descriptor(s) not done yet, stop iteration */ + return 0; + + header_length = le16_to_cpu(d->req_count); + + i = ctx->header_length; + z = le32_to_cpu(pd->branch_address) & 0xf; + p = d + z; + end = p + header_length; + + while (p < end && i + ctx->base.header_size <= PAGE_SIZE) { + /* + * The iso header is byteswapped to little endian by + * the controller, but the remaining header quadlets + * are big endian. We want to present all the headers + * as big endian, so we have to swap the first quadlet. + */ + *(u32 *) (ctx->header + i) = __swab32(*(u32 *) (p + 4)); + memcpy(ctx->header + i + 4, p + 8, ctx->base.header_size - 4); + i += ctx->base.header_size; + p += ctx->base.header_size + 4; + } + + ctx->header_length = i; + + if (le16_to_cpu(pd->control) & DESCRIPTOR_IRQ_ALWAYS) { + ir_header = (__le32 *) (d + z); + ctx->base.callback(&ctx->base, + le32_to_cpu(ir_header[0]) & 0xffff, + ctx->header_length, ctx->header, + ctx->base.callback_data); + ctx->header_length = 0; + } + + + return 1; +} + static int handle_it_packet(struct context *context, struct descriptor *d, struct descriptor *last) @@ -1466,14 +1532,12 @@ ohci_allocate_iso_context(struct fw_card *card, int type, size_t header_size) } else { mask = &ohci->ir_context_mask; list = ohci->ir_context_list; - callback = handle_ir_dualbuffer_packet; + if (ohci->version >= OHCI_VERSION_1_1) + callback = handle_ir_dualbuffer_packet; + else + callback = handle_ir_packet_per_buffer; } - /* FIXME: We need a fallback for pre 1.1 OHCI. */ - if (callback == handle_ir_dualbuffer_packet && - ohci->version < OHCI_VERSION_1_1) - return ERR_PTR(-ENOSYS); - spin_lock_irqsave(&ohci->lock, flags); index = ffs(*mask) - 1; if (index >= 0) @@ -1532,7 +1596,9 @@ static int ohci_start_iso(struct fw_iso_context *base, context_run(&ctx->context, match); } else { index = ctx - ohci->ir_context_list; - control = IR_CONTEXT_DUAL_BUFFER_MODE | IR_CONTEXT_ISOCH_HEADER; + control = IR_CONTEXT_ISOCH_HEADER; + if (ohci->version >= OHCI_VERSION_1_1) + control |= IR_CONTEXT_DUAL_BUFFER_MODE; match = (tags << 28) | (sync << 8) | ctx->base.channel; if (cycle >= 0) { match |= (cycle & 0x07fff) << 12; @@ -1738,7 +1804,6 @@ ohci_queue_iso_receive_dualbuffer(struct fw_iso_context *base, offset = payload & ~PAGE_MASK; rest = p->payload_length; - /* FIXME: OHCI 1.0 doesn't support dual buffer receive */ /* FIXME: make packet-per-buffer/dual-buffer a context option */ while (rest > 0) { d = context_get_descriptors(&ctx->context, @@ -1776,6 +1841,81 @@ ohci_queue_iso_receive_dualbuffer(struct fw_iso_context *base, return 0; } +static int +ohci_queue_iso_receive_packet_per_buffer(struct fw_iso_context *base, + struct fw_iso_packet *packet, + struct fw_iso_buffer *buffer, + unsigned long payload) +{ + struct iso_context *ctx = container_of(base, struct iso_context, base); + struct descriptor *d = NULL, *pd = NULL; + struct fw_iso_packet *p; + dma_addr_t d_bus, page_bus; + u32 z, header_z, rest; + int i, page, offset, packet_count, header_size; + + if (packet->skip) { + d = context_get_descriptors(&ctx->context, 1, &d_bus); + if (d == NULL) + return -ENOMEM; + + d->control = cpu_to_le16(DESCRIPTOR_STATUS | + DESCRIPTOR_INPUT_LAST | + DESCRIPTOR_BRANCH_ALWAYS | + DESCRIPTOR_WAIT); + context_append(&ctx->context, d, 1, 0); + } + + /* one descriptor for header, one for payload */ + /* FIXME: handle cases where we need multiple desc. for payload */ + z = 2; + p = packet; + + /* + * The OHCI controller puts the status word in the + * buffer too, so we need 4 extra bytes per packet. + */ + packet_count = p->header_length / ctx->base.header_size; + header_size = packet_count * (ctx->base.header_size + 4); + + /* Get header size in number of descriptors. */ + header_z = DIV_ROUND_UP(header_size, sizeof(*d)); + page = payload >> PAGE_SHIFT; + offset = payload & ~PAGE_MASK; + rest = p->payload_length; + + for (i = 0; i < packet_count; i++) { + /* d points to the header descriptor */ + d = context_get_descriptors(&ctx->context, + z + header_z, &d_bus); + if (d == NULL) + return -ENOMEM; + + d->control = cpu_to_le16(DESCRIPTOR_INPUT_MORE); + d->req_count = cpu_to_le16(header_size); + d->res_count = d->req_count; + d->data_address = cpu_to_le32(d_bus + (z * sizeof(*d))); + + /* pd points to the payload descriptor */ + pd = d + 1; + pd->control = cpu_to_le16(DESCRIPTOR_STATUS | + DESCRIPTOR_INPUT_LAST | + DESCRIPTOR_BRANCH_ALWAYS); + if (p->interrupt) + pd->control |= cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS); + + pd->req_count = cpu_to_le16(rest); + pd->res_count = pd->req_count; + + page_bus = page_private(buffer->pages[page]); + pd->data_address = cpu_to_le32(page_bus + offset); + + context_append(&ctx->context, d, z, header_z); + } + + return 0; +} + static int ohci_queue_iso(struct fw_iso_context *base, struct fw_iso_packet *packet, @@ -1790,8 +1930,9 @@ ohci_queue_iso(struct fw_iso_context *base, return ohci_queue_iso_receive_dualbuffer(base, packet, buffer, payload); else - /* FIXME: Implement fallback for OHCI 1.0 controllers. */ - return -ENOSYS; + return ohci_queue_iso_receive_packet_per_buffer(base, packet, + buffer, + payload); } static const struct fw_card_driver ohci_driver = { @@ -1911,12 +2052,6 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) ohci->version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff; fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n", dev->dev.bus_id, ohci->version >> 16, ohci->version & 0xff); - if (ohci->version < OHCI_VERSION_1_1) { - fw_notify(" Isochronous I/O is not yet implemented for " - "OHCI 1.0 chips.\n"); - fw_notify(" Cameras, audio devices etc. won't work on " - "this controller with this driver version.\n"); - } return 0; fail_self_id: -- cgit v1.2.3 From 43cbe2cbdd5320f1ac785c6f016923609831effe Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 10 Dec 2007 15:49:13 -0800 Subject: aoe: properly initialise the request_queue's backing_dev_info AOE forgot to initialise its queue's backing_dev_info, so kernels crash. (http://bugzilla.kernel.org/show_bug.cgi?id=9482) Fix that and consoldate aoeblk_gdalloc()'s error handling. Thanks be to Jon for reporting and testing. Cc: "Ed L. Cashin" Cc: Cc: "Jon Nelson" Acked-by: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/aoe/aoeblk.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index b1d00ef6659..ad00b3d9471 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -210,25 +211,20 @@ aoeblk_gdalloc(void *vp) if (gd == NULL) { printk(KERN_ERR "aoe: cannot allocate disk structure for %ld.%ld\n", d->aoemajor, d->aoeminor); - spin_lock_irqsave(&d->lock, flags); - d->flags &= ~DEVFL_GDALLOC; - spin_unlock_irqrestore(&d->lock, flags); - return; + goto err; } d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache); if (d->bufpool == NULL) { printk(KERN_ERR "aoe: cannot allocate bufpool for %ld.%ld\n", d->aoemajor, d->aoeminor); - put_disk(gd); - spin_lock_irqsave(&d->lock, flags); - d->flags &= ~DEVFL_GDALLOC; - spin_unlock_irqrestore(&d->lock, flags); - return; + goto err_disk; } - spin_lock_irqsave(&d->lock, flags); blk_queue_make_request(&d->blkq, aoeblk_make_request); + if (bdi_init(&d->blkq.backing_dev_info)) + goto err_mempool; + spin_lock_irqsave(&d->lock, flags); gd->major = AOE_MAJOR; gd->first_minor = d->sysminor * AOE_PARTITIONS; gd->fops = &aoe_bdops; @@ -246,6 +242,16 @@ aoeblk_gdalloc(void *vp) add_disk(gd); aoedisk_add_sysfs(d); + return; + +err_mempool: + mempool_destroy(d->bufpool); +err_disk: + put_disk(gd); +err: + spin_lock_irqsave(&d->lock, flags); + d->flags &= ~DEVFL_GDALLOC; + spin_unlock_irqrestore(&d->lock, flags); } void -- cgit v1.2.3 From 24601bbcacb3356657747f2e64317923feb7a1a2 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 10 Dec 2007 15:49:20 -0800 Subject: revert "dpt_i2o: convert to SCSI hotplug model" revert commit 55d9fcf57ba5ec427544fca7abc335cf3da78160 Author: Matthew Wilcox Date: Mon Jul 30 15:19:18 2007 -0600 [SCSI] dpt_i2o: convert to SCSI hotplug model - Delete refereces to HOSTS_C - Switch to module_init/module_exit instead of detect/release - Don't pass around the host template and rename it to adpt_template - Switch from scsi_register/scsi_unregister to scsi_host_alloc, scsi_add_host, scsi_scan_host and scsi_host_put. Because it caused (for unknown reasons) Andres' all-data-reads-as-zeroes problem, reported at http://groups.google.com/group/fa.linux.kernel/msg/083a9acff0330234 Cc: Matthew Wilcox Cc: "Salyzyn, Mark" Cc: James Bottomley Acked-by: FUJITA Tomonori Cc: Anders Henke Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/dpt_i2o.c | 132 +++++++++++++++++++++++-------------------------- drivers/scsi/dpti.h | 9 +++- 2 files changed, 68 insertions(+), 73 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 8258506ba7d..70f48a1a6d5 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -173,20 +173,20 @@ static struct pci_device_id dptids[] = { }; MODULE_DEVICE_TABLE(pci,dptids); -static void adpt_exit(void); - -static int adpt_detect(void) +static int adpt_detect(struct scsi_host_template* sht) { struct pci_dev *pDev = NULL; adpt_hba* pHba; + adpt_init(); + PINFO("Detecting Adaptec I2O RAID controllers...\n"); /* search for all Adatpec I2O RAID cards */ while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) { if(pDev->device == PCI_DPT_DEVICE_ID || pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){ - if(adpt_install_hba(pDev) ){ + if(adpt_install_hba(sht, pDev) ){ PERROR("Could not Init an I2O RAID device\n"); PERROR("Will not try to detect others.\n"); return hba_count-1; @@ -248,33 +248,34 @@ rebuild_sys_tab: } for (pHba = hba_chain; pHba; pHba = pHba->next) { - if (adpt_scsi_register(pHba) < 0) { + if( adpt_scsi_register(pHba,sht) < 0){ adpt_i2o_delete_hba(pHba); continue; } pHba->initialized = TRUE; pHba->state &= ~DPTI_STATE_RESET; - scsi_scan_host(pHba->host); } // Register our control device node // nodes will need to be created in /dev to access this // the nodes can not be created from within the driver if (hba_count && register_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER, &adpt_fops)) { - adpt_exit(); + adpt_i2o_sys_shutdown(); return 0; } return hba_count; } -static int adpt_release(adpt_hba *pHba) +/* + * scsi_unregister will be called AFTER we return. + */ +static int adpt_release(struct Scsi_Host *host) { - struct Scsi_Host *shost = pHba->host; - scsi_remove_host(shost); + adpt_hba* pHba = (adpt_hba*) host->hostdata[0]; // adpt_i2o_quiesce_hba(pHba); adpt_i2o_delete_hba(pHba); - scsi_host_put(shost); + scsi_unregister(host); return 0; } @@ -881,7 +882,7 @@ static int adpt_reboot_event(struct notifier_block *n, ulong code, void *p) #endif -static int adpt_install_hba(struct pci_dev* pDev) +static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) { adpt_hba* pHba = NULL; @@ -1028,6 +1029,8 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba) mutex_lock(&adpt_configuration_lock); + // scsi_unregister calls our adpt_release which + // does a quiese if(pHba->host){ free_irq(pHba->host->irq, pHba); } @@ -1079,6 +1082,17 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba) } +static int adpt_init(void) +{ + printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n"); +#ifdef REBOOT_NOTIFIER + register_reboot_notifier(&adpt_reboot_notifier); +#endif + + return 0; +} + + static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun) { struct adpt_device* d; @@ -2164,6 +2178,37 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d } +static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht) +{ + struct Scsi_Host *host = NULL; + + host = scsi_register(sht, sizeof(adpt_hba*)); + if (host == NULL) { + printk ("%s: scsi_register returned NULL\n",pHba->name); + return -1; + } + host->hostdata[0] = (unsigned long)pHba; + pHba->host = host; + + host->irq = pHba->pDev->irq; + /* no IO ports, so don't have to set host->io_port and + * host->n_io_port + */ + host->io_port = 0; + host->n_io_port = 0; + /* see comments in scsi_host.h */ + host->max_id = 16; + host->max_lun = 256; + host->max_channel = pHba->top_scsi_channel + 1; + host->cmd_per_lun = 1; + host->unique_id = (uint) pHba; + host->sg_tablesize = pHba->sg_tablesize; + host->can_queue = pHba->post_fifo_size; + + return 0; +} + + static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) { adpt_hba* pHba; @@ -3279,10 +3324,12 @@ static static void adpt_delay(int millisec) #endif -static struct scsi_host_template adpt_template = { +static struct scsi_host_template driver_template = { .name = "dpt_i2o", .proc_name = "dpt_i2o", .proc_info = adpt_proc_info, + .detect = adpt_detect, + .release = adpt_release, .info = adpt_info, .queuecommand = adpt_queue, .eh_abort_handler = adpt_abort, @@ -3297,62 +3344,5 @@ static struct scsi_host_template adpt_template = { .use_clustering = ENABLE_CLUSTERING, .use_sg_chaining = ENABLE_SG_CHAINING, }; - -static s32 adpt_scsi_register(adpt_hba* pHba) -{ - struct Scsi_Host *host; - - host = scsi_host_alloc(&adpt_template, sizeof(adpt_hba*)); - if (host == NULL) { - printk ("%s: scsi_host_alloc returned NULL\n",pHba->name); - return -1; - } - host->hostdata[0] = (unsigned long)pHba; - pHba->host = host; - - host->irq = pHba->pDev->irq; - /* no IO ports, so don't have to set host->io_port and - * host->n_io_port - */ - host->io_port = 0; - host->n_io_port = 0; - /* see comments in scsi_host.h */ - host->max_id = 16; - host->max_lun = 256; - host->max_channel = pHba->top_scsi_channel + 1; - host->cmd_per_lun = 1; - host->unique_id = (uint) pHba; - host->sg_tablesize = pHba->sg_tablesize; - host->can_queue = pHba->post_fifo_size; - - if (scsi_add_host(host, &pHba->pDev->dev)) { - scsi_host_put(host); - return -1; - } - - return 0; -} - -static int __init adpt_init(void) -{ - int count; - - printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n"); -#ifdef REBOOT_NOTIFIER - register_reboot_notifier(&adpt_reboot_notifier); -#endif - - count = adpt_detect(); - - return count > 0 ? 0 : -ENODEV; -} - -static void adpt_exit(void) -{ - while (hba_chain) - adpt_release(hba_chain); -} - -module_init(adpt_init); -module_exit(adpt_exit); +#include "scsi_module.c" MODULE_LICENSE("GPL"); diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h index 0892f6c7031..fd79068c586 100644 --- a/drivers/scsi/dpti.h +++ b/drivers/scsi/dpti.h @@ -28,9 +28,11 @@ * SCSI interface function Prototypes */ +static int adpt_detect(struct scsi_host_template * sht); static int adpt_queue(struct scsi_cmnd * cmd, void (*cmdcomplete) (struct scsi_cmnd *)); static int adpt_abort(struct scsi_cmnd * cmd); static int adpt_reset(struct scsi_cmnd* cmd); +static int adpt_release(struct Scsi_Host *host); static int adpt_slave_configure(struct scsi_device *); static const char *adpt_info(struct Scsi_Host *pSHost); @@ -47,6 +49,8 @@ static int adpt_device_reset(struct scsi_cmnd* cmd); #define DPT_DRIVER_NAME "Adaptec I2O RAID" +#ifndef HOSTS_C + #include "dpt/sys_info.h" #include #include "dpt/dpti_i2o.h" @@ -285,7 +289,7 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba); static s32 adpt_i2o_hrt_get(adpt_hba* pHba); static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice); static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd); -static s32 adpt_scsi_register(adpt_hba* pHba); +static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht); static s32 adpt_hba_reset(adpt_hba* pHba); static s32 adpt_i2o_reset_hba(adpt_hba* pHba); static s32 adpt_rescan(adpt_hba* pHba); @@ -295,7 +299,7 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba); static void adpt_inquiry(adpt_hba* pHba); static void adpt_fail_posted_scbs(adpt_hba* pHba); static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun); -static int adpt_install_hba(struct pci_dev* pDev) ; +static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) ; static int adpt_i2o_online_hba(adpt_hba* pHba); static void adpt_i2o_post_wait_complete(u32, int); static int adpt_i2o_systab_send(adpt_hba* pHba); @@ -339,4 +343,5 @@ static void adpt_i386_info(sysInfo_S* si); #define FW_DEBUG_BLED_OFFSET 8 #define FW_DEBUG_FLAGS_NO_HEADERS_B 0x01 +#endif /* !HOSTS_C */ #endif /* _DPT_H */ -- cgit v1.2.3 From 78187865efa5aec5a28a200a39153f98d8f38d4d Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 10 Dec 2007 15:49:22 -0800 Subject: pcmcia: fix kernel-doc comments Fix kernel-doc comments in drivers/pcmcia/: - ti113x.h does not contain kernel-doc, so don't use /** to begin a doc comment - yenta_socket.c: remove /** on non-kernel-doc comments; escape the ':' in an "http:" comment so that it won't be treated as a section heading; - cs.c: remove /** on non-kernel-doc comments & add function parameter info - ds.c: fix function parameter info Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cs.c | 8 +++++--- drivers/pcmcia/ds.c | 6 ++++-- drivers/pcmcia/ti113x.h | 2 +- drivers/pcmcia/yenta_socket.c | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index a0aca46ce87..56230dbd347 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -89,7 +89,7 @@ DECLARE_RWSEM(pcmcia_socket_list_rwsem); EXPORT_SYMBOL(pcmcia_socket_list_rwsem); -/** +/* * Low-level PCMCIA socket drivers need to register with the PCCard * core using pcmcia_register_socket. * @@ -174,6 +174,7 @@ static int pccardd(void *__skt); /** * pcmcia_register_socket - add a new pcmcia socket device + * @socket: the &socket to register */ int pcmcia_register_socket(struct pcmcia_socket *socket) { @@ -268,6 +269,7 @@ EXPORT_SYMBOL(pcmcia_register_socket); /** * pcmcia_unregister_socket - remove a pcmcia socket device + * @socket: the &socket to unregister */ void pcmcia_unregister_socket(struct pcmcia_socket *socket) { @@ -311,7 +313,7 @@ struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr) } EXPORT_SYMBOL(pcmcia_get_socket_by_nr); -/** +/* * The central event handler. Send_event() sends an event to the * 16-bit subsystem, which then calls the relevant device drivers. * Parse_events() interprets the event bits from @@ -380,7 +382,7 @@ static int socket_reset(struct pcmcia_socket *skt) return CS_GENERAL_FAILURE; } -/** +/* * socket_setup() and socket_shutdown() are called by the main event handler * when card insertion and removal events are received. * socket_setup() turns on socket power and resets the socket, in two stages. diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 7bf78c12789..5cf89a91da1 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -320,6 +320,7 @@ pcmcia_create_newid_file(struct pcmcia_driver *drv) /** * pcmcia_register_driver - register a PCMCIA driver with the bus core + * @driver: the &driver being registered * * Registers a PCMCIA driver with the PCMCIA bus core. */ @@ -354,6 +355,7 @@ EXPORT_SYMBOL(pcmcia_register_driver); /** * pcmcia_unregister_driver - unregister a PCMCIA driver with the bus core + * @driver: the &driver being unregistered */ void pcmcia_unregister_driver(struct pcmcia_driver *driver) { @@ -840,8 +842,8 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis) /** * pcmcia_load_firmware - load CIS from userspace if device-provided is broken - * @dev - the pcmcia device which needs a CIS override - * @filename - requested filename in /lib/firmware/ + * @dev: the pcmcia device which needs a CIS override + * @filename: requested filename in /lib/firmware/ * * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if * the one provided by the card is broken. The firmware files reside in diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h index 62e9ebf967f..d29657bf1b4 100644 --- a/drivers/pcmcia/ti113x.h +++ b/drivers/pcmcia/ti113x.h @@ -874,7 +874,7 @@ static int ti1250_override(struct yenta_socket *socket) */ #ifdef CONFIG_YENTA_ENE_TUNE -/** +/* * set/clear various test bits: * Defaults to clear the bit. * - mask (u8) defines what bits to change diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 20853a03202..0ab1fb65cdc 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -48,7 +48,7 @@ MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only #define to_cycles(ns) ((ns)/120) #define to_ns(cycles) ((cycles)*120) -/** +/* * yenta PCI irq probing. * currently only used in the TI/EnE initialization code */ @@ -888,7 +888,7 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas } -/** +/* * yenta PCI irq probing. * currently only used in the TI/EnE initialization code */ @@ -1012,7 +1012,7 @@ static void yenta_config_init(struct yenta_socket *socket) * invisible during PCI scans because of a misconfigured subordinate number * of the parent brige - some BIOSes seem to be too lazy to set it right. * Does the fixup carefully by checking how far it can go without conflicts. - * See http://bugzilla.kernel.org/show_bug.cgi?id=2944 for more information. + * See http\://bugzilla.kernel.org/show_bug.cgi?id=2944 for more information. */ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge) { -- cgit v1.2.3 From 037cdafe42c775020e7b0e8a16ff8f52233df4c7 Mon Sep 17 00:00:00 2001 From: Will Newton Date: Mon, 10 Dec 2007 15:49:25 -0800 Subject: pxa2xx_spi: fix typo in description Signed-off-by: Will Newton Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/spi/pxa2xx_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c index 5f3d808cbc2..1c2ab541d37 100644 --- a/drivers/spi/pxa2xx_spi.c +++ b/drivers/spi/pxa2xx_spi.c @@ -39,7 +39,7 @@ #include MODULE_AUTHOR("Stephen Street"); -MODULE_DESCRIPTION("PXA2xx SSP SPI Contoller"); +MODULE_DESCRIPTION("PXA2xx SSP SPI Controller"); MODULE_LICENSE("GPL"); #define MAX_BUSES 3 -- cgit v1.2.3 From 6b1a80283908e463cbf1d96d48d7b989af0f2b2f Mon Sep 17 00:00:00 2001 From: Will Newton Date: Mon, 10 Dec 2007 15:49:26 -0800 Subject: spi_bfin5xx: fix typo in description Signed-off-by: Will Newton Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/spi/spi_bfin5xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c index 22697b81220..7ef39a6e8c0 100644 --- a/drivers/spi/spi_bfin5xx.c +++ b/drivers/spi/spi_bfin5xx.c @@ -54,7 +54,7 @@ #define DRV_NAME "bfin-spi" #define DRV_AUTHOR "Bryan Wu, Luke Yang" -#define DRV_DESC "Blackfin BF5xx on-chip SPI Contoller Driver" +#define DRV_DESC "Blackfin BF5xx on-chip SPI Controller Driver" #define DRV_VERSION "1.0" MODULE_AUTHOR(DRV_AUTHOR); -- cgit v1.2.3 From 8805f2387086a7e6a9647d0713fc075694130d6c Mon Sep 17 00:00:00 2001 From: Will Newton Date: Mon, 10 Dec 2007 15:49:27 -0800 Subject: spi_imx: fix typo in description Signed-off-by: Will Newton Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/spi/spi_imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c index 7686ba34430..2cd8573fb09 100644 --- a/drivers/spi/spi_imx.c +++ b/drivers/spi/spi_imx.c @@ -1758,5 +1758,5 @@ static void __exit spi_imx_exit(void) module_exit(spi_imx_exit); MODULE_AUTHOR("Andrea Paterniani, "); -MODULE_DESCRIPTION("iMX SPI Contoller Driver"); +MODULE_DESCRIPTION("iMX SPI Controller Driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 76832d8416430d6dd0575579ca1e00d1a790f4cb Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 10 Dec 2007 15:49:28 -0800 Subject: drivers/serial/uartlite.c: Add missing of_node_put There should be an of_node_put when breaking out of a loop that iterates using for_each_compatible_node. This was detected and fixed using the following semantic patch. (http://www.emn.fr/x-info/coccinelle/) // @@ identifier d; type T; expression e; iterator for_each_compatible_node; @@ T *d; ... for_each_compatible_node(d,...) {... when != of_node_put(d) when != e = d ( return d; | + of_node_put(d); ? return ...; ) ...} // Signed-off-by: Julia Lawall Acked-by: Grant Likely Acked-by: Peter Korsgaard Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/uartlite.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c index a85f2d31a68..3f593247c41 100644 --- a/drivers/serial/uartlite.c +++ b/drivers/serial/uartlite.c @@ -393,6 +393,7 @@ static inline void __init ulite_console_of_find_device(int id) continue; ulite_ports[id].mapbase = res.start; + of_node_put(np); return; } } -- cgit v1.2.3 From 794e64d5e9c7f088378e093a48eb36a30091d82d Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 10 Dec 2007 15:49:30 -0800 Subject: Fix NULL dereference in umem.c Fix NULL dereference in umem.c Signed-off-by: Neil Brown Tested-by: Dave Chinner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/umem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 99806f9ee4c..5f5095afb06 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c @@ -484,7 +484,8 @@ static void process_page(unsigned long data) page->idx++; if (page->idx >= bio->bi_vcnt) { page->bio = bio->bi_next; - page->idx = page->bio->bi_idx; + if (page->bio) + page->idx = page->bio->bi_idx; } pci_unmap_page(card->dev, desc->data_dma_handle, -- cgit v1.2.3 From 522939d45c293388e6a360210905f9230298df16 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Mon, 10 Dec 2007 15:49:31 -0800 Subject: esp_scsi: fix reset cleanup spinlock recursion The esp_reset_cleanup() function is called with the host lock held and invokes starget_for_each_device() which wants to take it too. Here is a fix along the lines of shost_for_each_device()/__shost_for_each_device() adding a __starget_for_each_device() counterpart which assumes the lock has already been taken. Eventually, I think the driver should get modified so that more work is done as a softirq rather than in the interrupt context, but for now it fixes a bug that causes the spinlock debugger to fire. While at it, it fixes a small number of cosmetic problems with starget_for_each_device() too. Signed-off-by: Maciej W. Rozycki Acked-by: David S. Miller Cc: James Bottomley Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/esp_scsi.c | 4 ++-- drivers/scsi/scsi.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 4ed3a529706..bfdee596889 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -2026,8 +2026,8 @@ static void esp_reset_cleanup(struct esp *esp) tp->flags |= ESP_TGT_CHECK_NEGO; if (tp->starget) - starget_for_each_device(tp->starget, NULL, - esp_clear_hold); + __starget_for_each_device(tp->starget, NULL, + esp_clear_hold); } esp->flags &= ~ESP_FLAG_RESETTING; } diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 19294882245..0fb1709ce5e 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -896,11 +896,11 @@ EXPORT_SYMBOL(__scsi_iterate_devices); * starget_for_each_device - helper to walk all devices of a target * @starget: target whose devices we want to iterate over. * - * This traverses over each devices of @shost. The devices have + * This traverses over each device of @starget. The devices have * a reference that must be released by scsi_host_put when breaking * out of the loop. */ -void starget_for_each_device(struct scsi_target *starget, void * data, +void starget_for_each_device(struct scsi_target *starget, void *data, void (*fn)(struct scsi_device *, void *)) { struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); @@ -914,6 +914,33 @@ void starget_for_each_device(struct scsi_target *starget, void * data, } EXPORT_SYMBOL(starget_for_each_device); +/** + * __starget_for_each_device - helper to walk all devices of a target + * (UNLOCKED) + * @starget: target whose devices we want to iterate over. + * + * This traverses over each device of @starget. It does _not_ + * take a reference on the scsi_device, so the whole loop must be + * protected by shost->host_lock. + * + * Note: The only reason why drivers would want to use this is because + * they need to access the device list in irq context. Otherwise you + * really want to use starget_for_each_device instead. + **/ +void __starget_for_each_device(struct scsi_target *starget, void *data, + void (*fn)(struct scsi_device *, void *)) +{ + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct scsi_device *sdev; + + __shost_for_each_device(sdev, shost) { + if ((sdev->channel == starget->channel) && + (sdev->id == starget->id)) + fn(sdev, data); + } +} +EXPORT_SYMBOL(__starget_for_each_device); + /** * __scsi_device_lookup_by_target - find a device given the target (UNLOCKED) * @starget: SCSI target pointer -- cgit v1.2.3 From d84248bf46582a406116c55b94405c05193773b1 Mon Sep 17 00:00:00 2001 From: Rini van Zetten Date: Mon, 10 Dec 2007 15:49:34 -0800 Subject: atmel_spi: reload RCR before TCR We have a wifi module connected to the spi bus and got sometimes FIFO overrun errors on the spi bus. After some investigation i found that the driver loads the TCR (transmit count) register before the RCR (receive count). When the transfer list is not empty the atmel_spi_next_message is called while tx and rx are enabled. As soon as the TCR is loaded, hardware starts transfer and causes a rx fifo overrun because the RCR is not loaded yet. Load the RCR before the TCR. After this patch the fifo overrun disapears at out setup. Signed-off-by: Haavard Skinnemoen Signed-off-by: Rini van Zetten Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/spi/atmel_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index ff6a14bf128..ff10808183a 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -195,8 +195,8 @@ static void atmel_spi_next_xfer(struct spi_master *master, xfer, xfer->len, xfer->tx_buf, xfer->tx_dma, xfer->rx_buf, xfer->rx_dma, spi_readl(as, IMR)); - spi_writel(as, TCR, len); spi_writel(as, RCR, len); + spi_writel(as, TCR, len); spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN)); } -- cgit v1.2.3 From 9b3efc0133a807070dbd21254102995b65969965 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 10 Dec 2007 17:17:37 -0800 Subject: [S390]: Fix use of skb after netif_rx Recently, Wang Chen submitted a patch (d30f53aeb31d453a5230f526bea592af07944564) to move a call to netif_rx(skb) after a subsequent reference to skb, because netif_rx may call kfree_skb on its argument. netif_rx_ni calls netif_rx, so the same problem occurs in the files below. I have left the updating of dev->last_rx after the calls to netif_rx_ni because it seems time dependent, but moved the other field updates before. This was found using the following semantic match. (http://www.emn.fr/x-info/coccinelle/) // @@ expression skb, e,e1; @@ ( netif_rx(skb); | netif_rx_ni(skb); ) ... when != skb = e ( skb = e1 | * skb ) // Signed-off-by: Julia Lawall Signed-off-by: David S. Miller --- drivers/s390/net/ctcmain.c | 6 +++--- drivers/s390/net/netiucv.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c index 97adc701a81..77a503139e3 100644 --- a/drivers/s390/net/ctcmain.c +++ b/drivers/s390/net/ctcmain.c @@ -478,14 +478,14 @@ ctc_unpack_skb(struct channel *ch, struct sk_buff *pskb) skb->dev = pskb->dev; skb->protocol = pskb->protocol; pskb->ip_summed = CHECKSUM_UNNECESSARY; - netif_rx_ni(skb); /** - * Successful rx; reset logflags + * reset logflags */ ch->logflags = 0; - dev->last_rx = jiffies; privptr->stats.rx_packets++; privptr->stats.rx_bytes += skb->len; + netif_rx_ni(skb); + dev->last_rx = jiffies; if (len > 0) { skb_pull(pskb, header->length); if (skb_tailroom(pskb) < LL_HEADER_LENGTH) { diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c index 4d18d6419dd..c7ea9381db9 100644 --- a/drivers/s390/net/netiucv.c +++ b/drivers/s390/net/netiucv.c @@ -639,14 +639,14 @@ static void netiucv_unpack_skb(struct iucv_connection *conn, skb->dev = pskb->dev; skb->protocol = pskb->protocol; pskb->ip_summed = CHECKSUM_UNNECESSARY; + privptr->stats.rx_packets++; + privptr->stats.rx_bytes += skb->len; /* * Since receiving is always initiated from a tasklet (in iucv.c), * we must use netif_rx_ni() instead of netif_rx() */ netif_rx_ni(skb); dev->last_rx = jiffies; - privptr->stats.rx_packets++; - privptr->stats.rx_bytes += skb->len; skb_pull(pskb, header->next); skb_put(pskb, NETIUCV_HDRLEN); } -- cgit v1.2.3 From fb0c18bd1f61086fcfac90017b59891a356cc288 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Mon, 10 Dec 2007 17:18:23 -0800 Subject: [BNX2]: Add PHY_DIS_EARLY_DAC workaround. 5709 Ax and Bx chips all need this workaround. Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/bnx2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index da767d3d5af..a4f3832d0a6 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -6685,8 +6685,9 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev) } else if (CHIP_NUM(bp) == CHIP_NUM_5706 || CHIP_NUM(bp) == CHIP_NUM_5708) bp->phy_flags |= PHY_CRC_FIX_FLAG; - else if (CHIP_ID(bp) == CHIP_ID_5709_A0 || - CHIP_ID(bp) == CHIP_ID_5709_A1) + else if (CHIP_NUM(bp) == CHIP_NUM_5709 && + (CHIP_REV(bp) == CHIP_REV_Ax || + CHIP_REV(bp) == CHIP_REV_Bx)) bp->phy_flags |= PHY_DIS_EARLY_DAC_FLAG; if ((CHIP_ID(bp) == CHIP_ID_5708_A0) || -- cgit v1.2.3 From c09c262783dcac62352293912d82b794063cefc3 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Mon, 10 Dec 2007 17:18:37 -0800 Subject: [BNX2]: Fix RX packet rot. Packets can be left in the RX ring if the NAPI budget is reached. This is caused by storing the latest rx index at the beginning of bnx2_rx_int(). We may not process all the work up to this index if the budget is reached and so some packets in the RX ring may rot when we later check for more work using this stored rx index. The fix is to not store this latest hw index and only store the processed rx index. We use a new function bnx2_get_hw_rx_cons() to fetch the latest hw rx index. Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/bnx2.c | 26 ++++++++++++++------------ drivers/net/bnx2.h | 1 - 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index a4f3832d0a6..f9eea6e84c8 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -2387,18 +2387,24 @@ bnx2_reuse_rx_skb(struct bnx2 *bp, struct sk_buff *skb, prod_bd->rx_bd_haddr_lo = cons_bd->rx_bd_haddr_lo; } +static inline u16 +bnx2_get_hw_rx_cons(struct bnx2 *bp) +{ + u16 cons = bp->status_blk->status_rx_quick_consumer_index0; + + if (unlikely((cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT)) + cons++; + return cons; +} + static int bnx2_rx_int(struct bnx2 *bp, int budget) { - struct status_block *sblk = bp->status_blk; u16 hw_cons, sw_cons, sw_ring_cons, sw_prod, sw_ring_prod; struct l2_fhdr *rx_hdr; int rx_pkt = 0; - hw_cons = bp->hw_rx_cons = sblk->status_rx_quick_consumer_index0; - if ((hw_cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT) { - hw_cons++; - } + hw_cons = bnx2_get_hw_rx_cons(bp); sw_cons = bp->rx_cons; sw_prod = bp->rx_prod; @@ -2515,10 +2521,7 @@ next_rx: /* Refresh hw_cons to see if there is new work */ if (sw_cons == hw_cons) { - hw_cons = bp->hw_rx_cons = - sblk->status_rx_quick_consumer_index0; - if ((hw_cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT) - hw_cons++; + hw_cons = bnx2_get_hw_rx_cons(bp); rmb(); } } @@ -2622,7 +2625,7 @@ bnx2_has_work(struct bnx2 *bp) { struct status_block *sblk = bp->status_blk; - if ((sblk->status_rx_quick_consumer_index0 != bp->hw_rx_cons) || + if ((bnx2_get_hw_rx_cons(bp) != bp->rx_cons) || (sblk->status_tx_quick_consumer_index0 != bp->hw_tx_cons)) return 1; @@ -2655,7 +2658,7 @@ static int bnx2_poll_work(struct bnx2 *bp, int work_done, int budget) if (sblk->status_tx_quick_consumer_index0 != bp->hw_tx_cons) bnx2_tx_int(bp); - if (sblk->status_rx_quick_consumer_index0 != bp->hw_rx_cons) + if (bnx2_get_hw_rx_cons(bp) != bp->rx_cons) work_done += bnx2_rx_int(bp, budget - work_done); return work_done; @@ -4177,7 +4180,6 @@ bnx2_init_rx_ring(struct bnx2 *bp) ring_prod = prod = bp->rx_prod = 0; bp->rx_cons = 0; - bp->hw_rx_cons = 0; bp->rx_prod_bseq = 0; for (i = 0; i < bp->rx_max_ring; i++) { diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h index 1dce0d1a258..30ba366608b 100644 --- a/drivers/net/bnx2.h +++ b/drivers/net/bnx2.h @@ -6513,7 +6513,6 @@ struct bnx2 { u32 rx_prod_bseq; u16 rx_prod; u16 rx_cons; - u16 hw_rx_cons; u32 rx_csum; -- cgit v1.2.3 From bbe42974215eb7a483c344fca50652b3b9dd1ae4 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Mon, 10 Dec 2007 17:18:51 -0800 Subject: [BNX2]: Update version to 1.6.9. Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/bnx2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index f9eea6e84c8..4e7b46e4487 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -56,8 +56,8 @@ #define DRV_MODULE_NAME "bnx2" #define PFX DRV_MODULE_NAME ": " -#define DRV_MODULE_VERSION "1.6.8" -#define DRV_MODULE_RELDATE "October 17, 2007" +#define DRV_MODULE_VERSION "1.6.9" +#define DRV_MODULE_RELDATE "December 8, 2007" #define RUN_AT(x) (jiffies + (x)) -- cgit v1.2.3 From 8a75601035848e267baaae76b6e784cf1f899cd0 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Tue, 30 Oct 2007 04:16:35 -0300 Subject: V4L/DVB (6485): ivtv: fix compile warning Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/ivtv/ivtv-streams.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index aa03e61ef31..74fb0e02197 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c @@ -76,7 +76,7 @@ static struct { int minor_offset; int dma, pio; enum v4l2_buf_type buf_type; - struct file_operations *fops; + const struct file_operations *fops; } ivtv_stream_info[] = { { /* IVTV_ENC_STREAM_TYPE_MPG */ "encoder MPG", -- cgit v1.2.3 From 2b2c93ac998896db0d2b754a4fd83479bda7efde Mon Sep 17 00:00:00 2001 From: Sascha Sommer Date: Sat, 3 Nov 2007 16:48:01 -0300 Subject: V4L/DVB (6540): em28xx: fix failing autodetection after the reboot The attached patch is required so that the autodetecion code also works after a reboot. Setting the I2C speed does not seem to be supported for em2800. Signed-off-by: Sascha Sommer Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/em28xx/em28xx-video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 2529c298b86..d3dd6a0fc8a 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c @@ -144,7 +144,8 @@ static int em28xx_config(struct em28xx *dev) { /* Sets I2C speed to 100 KHz */ - em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1); + if (!dev->is_em2800) + em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1); /* enable vbi capturing */ -- cgit v1.2.3 From f4b8b3ae13b2246cf7e1b998f0292f3297d03d41 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 3 Nov 2007 22:40:24 -0300 Subject: V4L/DVB (6542): Fix S-video mode on tvp5150 Thanks to Markus Reichberger to point this. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/tvp5150.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers') diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index 25d0aef88ef..445eba4174d 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c @@ -290,6 +290,7 @@ static inline void tvp5150_selmux(struct i2c_client *c) int opmode=0; struct tvp5150 *decoder = i2c_get_clientdata(c); int input = 0; + unsigned char val; if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable) input = 8; @@ -315,6 +316,16 @@ static inline void tvp5150_selmux(struct i2c_client *c) tvp5150_write(c, TVP5150_OP_MODE_CTL, opmode); tvp5150_write(c, TVP5150_VD_IN_SRC_SEL_1, input); + + /* Svideo should enable YCrCb output and disable GPCL output + * For Composite and TV, it should be the reverse + */ + val = tvp5150_read(c, TVP5150_MISC_CTL); + if (decoder->route.input == TVP5150_SVIDEO) + val = (val & ~0x40) | 0x10; + else + val = (val & ~0x10) | 0x40; + tvp5150_write(c, TVP5150_MISC_CTL, val); }; struct i2c_reg_value { -- cgit v1.2.3 From 33f7771411c1f815208f6593d8fde8f9a135cea5 Mon Sep 17 00:00:00 2001 From: Hartmut Hackmann Date: Thu, 8 Nov 2007 08:54:53 -0300 Subject: V4L/DVB (6579): Fix bug #8824: Correct support for Diseqc on tda10086 This is a modified version of a patch previously posted by Thomas Unverzagt. Signed-off-by: Hartmut Hackmann Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/tda10086.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c index 9a8ddc537f8..9d26ace6515 100644 --- a/drivers/media/dvb/frontends/tda10086.c +++ b/drivers/media/dvb/frontends/tda10086.c @@ -158,7 +158,7 @@ static int tda10086_init(struct dvb_frontend* fe) tda10086_write_byte(state, 0x3d, 0x80); // setup SEC - tda10086_write_byte(state, 0x36, 0x00); // all SEC off + tda10086_write_byte(state, 0x36, 0x80); // all SEC off, no 22k tone tda10086_write_byte(state, 0x34, (((1<<19) * (22000/1000)) / (SACLK/1000))); // } tone frequency tda10086_write_byte(state, 0x35, (((1<<19) * (22000/1000)) / (SACLK/1000)) >> 8); // } @@ -183,13 +183,13 @@ static int tda10086_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) dprintk ("%s\n", __FUNCTION__); - switch(tone) { + switch (tone) { case SEC_TONE_OFF: - tda10086_write_byte(state, 0x36, 0x00); + tda10086_write_byte(state, 0x36, 0x80); break; case SEC_TONE_ON: - tda10086_write_byte(state, 0x36, 0x01); + tda10086_write_byte(state, 0x36, 0x81); break; } @@ -212,7 +212,7 @@ static int tda10086_send_master_cmd (struct dvb_frontend* fe, for(i=0; i< cmd->msg_len; i++) { tda10086_write_byte(state, 0x48+i, cmd->msg[i]); } - tda10086_write_byte(state, 0x36, 0x08 | ((cmd->msg_len - 1) << 4)); + tda10086_write_byte(state, 0x36, 0x88 | ((cmd->msg_len - 1) << 4)); tda10086_diseqc_wait(state); @@ -230,11 +230,11 @@ static int tda10086_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minic switch(minicmd) { case SEC_MINI_A: - tda10086_write_byte(state, 0x36, 0x04); + tda10086_write_byte(state, 0x36, 0x84); break; case SEC_MINI_B: - tda10086_write_byte(state, 0x36, 0x06); + tda10086_write_byte(state, 0x36, 0x86); break; } -- cgit v1.2.3 From 63337dd3f5506628e4831b08e39e09d7f1407769 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 10 Nov 2007 10:26:20 -0300 Subject: V4L/DVB (6581): Fix: avoids negative vma usage count Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/em28xx/em28xx-video.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index d3dd6a0fc8a..0906bc5766c 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c @@ -571,7 +571,9 @@ static void em28xx_vm_close(struct vm_area_struct *vma) { /* NOTE: buffers are not freed here */ struct em28xx_frame_t *f = vma->vm_private_data; - f->vma_use_count--; + + if (f->vma_use_count) + f->vma_use_count--; } static struct vm_operations_struct em28xx_vm_ops = { -- cgit v1.2.3 From 19bc5133dae9562e8824ef101464061f9854c1d8 Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Tue, 13 Nov 2007 20:05:38 -0300 Subject: V4L/DVB (6601): V4L: videobuf-core locking fixes and comments - Add comments to functions that require that caller hold q->lock - Add __videobuf_mmap_free that doesn't hold q->lock for use within videobuf - Add locking to videobuf_mmap_free - Fix linux/drivers/media/common/saa7146_video.c which was holding lock around videobuf_read_stop - Add locking to functions that operate on a queue - Add videobuf_stop to take care of stopping in both the read and stream case TODO: bttv still has an unsafe call to videobuf_queue_is_busy Signed-off-by: Brandon Philips Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/saa7146_video.c | 5 +- drivers/media/video/videobuf-core.c | 247 ++++++++++++++++++++++------------- 2 files changed, 159 insertions(+), 93 deletions(-) (limited to 'drivers') diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c index f245a3b2ef4..7cc4213ba56 100644 --- a/drivers/media/common/saa7146_video.c +++ b/drivers/media/common/saa7146_video.c @@ -1440,10 +1440,7 @@ static void video_close(struct saa7146_dev *dev, struct file *file) err = saa7146_stop_preview(fh); } - // release all capture buffers - mutex_lock(&q->lock); - videobuf_read_stop(q); - mutex_unlock(&q->lock); + videobuf_stop(q); /* hmm, why is this function declared void? */ /* return err */ diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index 89a44f16f0b..de2f56b1916 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c @@ -141,6 +141,7 @@ void videobuf_queue_core_init(struct videobuf_queue* q, INIT_LIST_HEAD(&q->stream); } +/* Locking: Only usage in bttv unsafe find way to remove */ int videobuf_queue_is_busy(struct videobuf_queue *q) { int i; @@ -178,6 +179,7 @@ int videobuf_queue_is_busy(struct videobuf_queue *q) return 0; } +/* Locking: Caller holds q->lock */ void videobuf_queue_cancel(struct videobuf_queue *q) { unsigned long flags=0; @@ -208,6 +210,7 @@ void videobuf_queue_cancel(struct videobuf_queue *q) /* --------------------------------------------------------------------- */ +/* Locking: Caller holds q->lock */ enum v4l2_field videobuf_next_field(struct videobuf_queue *q) { enum v4l2_field field = q->field; @@ -226,6 +229,7 @@ enum v4l2_field videobuf_next_field(struct videobuf_queue *q) return field; } +/* Locking: Caller holds q->lock */ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, struct videobuf_buffer *vb, enum v4l2_buf_type type) { @@ -281,20 +285,108 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, b->sequence = vb->field_count >> 1; } +/* Locking: Caller holds q->lock */ +static int __videobuf_mmap_free(struct videobuf_queue *q) +{ + int i; + int rc; + + if (!q) + return 0; + + MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS); + + rc = CALL(q,mmap_free,q); + if (rc<0) + return rc; + + for (i = 0; i < VIDEO_MAX_FRAME; i++) { + if (NULL == q->bufs[i]) + continue; + q->ops->buf_release(q,q->bufs[i]); + kfree(q->bufs[i]); + q->bufs[i] = NULL; + } + + return rc; +} + +int videobuf_mmap_free(struct videobuf_queue *q) +{ + int ret; + mutex_lock(&q->lock); + ret = __videobuf_mmap_free(q); + mutex_unlock(&q->lock); + return ret; +} + +/* Locking: Caller holds q->lock */ +static int __videobuf_mmap_setup(struct videobuf_queue *q, + unsigned int bcount, unsigned int bsize, + enum v4l2_memory memory) +{ + unsigned int i; + int err; + + MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS); + + err = __videobuf_mmap_free(q); + if (0 != err) + return err; + + /* Allocate and initialize buffers */ + for (i = 0; i < bcount; i++) { + q->bufs[i] = videobuf_alloc(q); + + if (q->bufs[i] == NULL) + break; + + q->bufs[i]->i = i; + q->bufs[i]->input = UNSET; + q->bufs[i]->memory = memory; + q->bufs[i]->bsize = bsize; + switch (memory) { + case V4L2_MEMORY_MMAP: + q->bufs[i]->boff = bsize * i; + break; + case V4L2_MEMORY_USERPTR: + case V4L2_MEMORY_OVERLAY: + /* nothing */ + break; + } + } + + if (!i) + return -ENOMEM; + + dprintk(1,"mmap setup: %d buffers, %d bytes each\n", + i, bsize); + + return i; +} + +int videobuf_mmap_setup(struct videobuf_queue *q, + unsigned int bcount, unsigned int bsize, + enum v4l2_memory memory) +{ + int ret; + mutex_lock(&q->lock); + ret = __videobuf_mmap_setup(q, bcount, bsize, memory); + mutex_unlock(&q->lock); + return ret; +} + int videobuf_reqbufs(struct videobuf_queue *q, struct v4l2_requestbuffers *req) { unsigned int size,count; int retval; - if (req->type != q->type) { - dprintk(1,"reqbufs: queue type invalid\n"); - return -EINVAL; - } if (req->count < 1) { dprintk(1,"reqbufs: count invalid (%d)\n",req->count); return -EINVAL; } + if (req->memory != V4L2_MEMORY_MMAP && req->memory != V4L2_MEMORY_USERPTR && req->memory != V4L2_MEMORY_OVERLAY) { @@ -303,6 +395,12 @@ int videobuf_reqbufs(struct videobuf_queue *q, } mutex_lock(&q->lock); + if (req->type != q->type) { + dprintk(1,"reqbufs: queue type invalid\n"); + retval = -EINVAL; + goto done; + } + if (q->streaming) { dprintk(1,"reqbufs: streaming already exists\n"); retval = -EBUSY; @@ -323,7 +421,7 @@ int videobuf_reqbufs(struct videobuf_queue *q, dprintk(1,"reqbufs: bufs=%d, size=0x%x [%d pages total]\n", count, size, (count*size)>>PAGE_SHIFT); - retval = videobuf_mmap_setup(q,count,size,req->memory); + retval = __videobuf_mmap_setup(q,count,size,req->memory); if (retval < 0) { dprintk(1,"reqbufs: mmap setup returned %d\n",retval); goto done; @@ -338,20 +436,28 @@ int videobuf_reqbufs(struct videobuf_queue *q, int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) { + int ret = -EINVAL; + + mutex_lock(&q->lock); if (unlikely(b->type != q->type)) { dprintk(1,"querybuf: Wrong type.\n"); - return -EINVAL; + goto done; } if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) { dprintk(1,"querybuf: index out of range.\n"); - return -EINVAL; + goto done; } if (unlikely(NULL == q->bufs[b->index])) { dprintk(1,"querybuf: buffer is null.\n"); - return -EINVAL; + goto done; } + videobuf_status(q,b,q->bufs[b->index],q->type); - return 0; + + ret = 0; +done: + mutex_unlock(&q->lock); + return ret; } int videobuf_qbuf(struct videobuf_queue *q, @@ -541,22 +647,30 @@ int videobuf_streamon(struct videobuf_queue *q) return retval; } -int videobuf_streamoff(struct videobuf_queue *q) +/* Locking: Caller holds q->lock */ +static int __videobuf_streamoff(struct videobuf_queue *q) { - int retval = -EINVAL; - - mutex_lock(&q->lock); if (!q->streaming) - goto done; + return -EINVAL; + videobuf_queue_cancel(q); q->streaming = 0; - retval = 0; - done: + return 0; +} + +int videobuf_streamoff(struct videobuf_queue *q) +{ + int retval; + + mutex_lock(&q->lock); + retval = __videobuf_streamoff(q); mutex_unlock(&q->lock); + return retval; } +/* Locking: Caller holds q->lock */ static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data, size_t count, loff_t *ppos) @@ -691,6 +805,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, return retval; } +/* Locking: Caller holds q->lock */ int videobuf_read_start(struct videobuf_queue *q) { enum v4l2_field field; @@ -705,7 +820,7 @@ int videobuf_read_start(struct videobuf_queue *q) count = VIDEO_MAX_FRAME; size = PAGE_ALIGN(size); - err = videobuf_mmap_setup(q, count, size, V4L2_MEMORY_USERPTR); + err = __videobuf_mmap_setup(q, count, size, V4L2_MEMORY_USERPTR); if (err < 0) return err; @@ -728,12 +843,13 @@ int videobuf_read_start(struct videobuf_queue *q) return 0; } -void videobuf_read_stop(struct videobuf_queue *q) +static void __videobuf_read_stop(struct videobuf_queue *q) { int i; + videobuf_queue_cancel(q); - videobuf_mmap_free(q); + __videobuf_mmap_free(q); INIT_LIST_HEAD(&q->stream); for (i = 0; i < VIDEO_MAX_FRAME; i++) { if (NULL == q->bufs[i]) @@ -743,8 +859,30 @@ void videobuf_read_stop(struct videobuf_queue *q) } q->read_buf = NULL; q->reading = 0; + +} + +void videobuf_read_stop(struct videobuf_queue *q) +{ + mutex_lock(&q->lock); + __videobuf_read_stop(q); + mutex_unlock(&q->lock); +} + +void videobuf_stop(struct videobuf_queue *q) +{ + mutex_lock(&q->lock); + + if (q->streaming) + __videobuf_streamoff(q); + + if (q->reading) + __videobuf_read_stop(q); + + mutex_unlock(&q->lock); } + ssize_t videobuf_read_stream(struct videobuf_queue *q, char __user *data, size_t count, loff_t *ppos, int vbihack, int nonblocking) @@ -858,75 +996,6 @@ unsigned int videobuf_poll_stream(struct file *file, return rc; } -int videobuf_mmap_setup(struct videobuf_queue *q, - unsigned int bcount, unsigned int bsize, - enum v4l2_memory memory) -{ - unsigned int i; - int err; - - MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS); - - err = videobuf_mmap_free(q); - if (0 != err) - return err; - - /* Allocate and initialize buffers */ - for (i = 0; i < bcount; i++) { - q->bufs[i] = videobuf_alloc(q); - - if (q->bufs[i] == NULL) - break; - - q->bufs[i]->i = i; - q->bufs[i]->input = UNSET; - q->bufs[i]->memory = memory; - q->bufs[i]->bsize = bsize; - switch (memory) { - case V4L2_MEMORY_MMAP: - q->bufs[i]->boff = bsize * i; - break; - case V4L2_MEMORY_USERPTR: - case V4L2_MEMORY_OVERLAY: - /* nothing */ - break; - } - } - - if (!i) - return -ENOMEM; - - dprintk(1,"mmap setup: %d buffers, %d bytes each\n", - i, bsize); - - return i; -} - -int videobuf_mmap_free(struct videobuf_queue *q) -{ - int i; - int rc; - - if (!q) - return 0; - - MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS); - - rc = CALL(q,mmap_free,q); - if (rc<0) - return rc; - - for (i = 0; i < VIDEO_MAX_FRAME; i++) { - if (NULL == q->bufs[i]) - continue; - q->ops->buf_release(q,q->bufs[i]); - kfree(q->bufs[i]); - q->bufs[i] = NULL; - } - - return rc; -} - int videobuf_mmap_mapper(struct videobuf_queue *q, struct vm_area_struct *vma) { @@ -989,8 +1058,8 @@ EXPORT_SYMBOL_GPL(videobuf_dqbuf); EXPORT_SYMBOL_GPL(videobuf_streamon); EXPORT_SYMBOL_GPL(videobuf_streamoff); -EXPORT_SYMBOL_GPL(videobuf_read_start); EXPORT_SYMBOL_GPL(videobuf_read_stop); +EXPORT_SYMBOL_GPL(videobuf_stop); EXPORT_SYMBOL_GPL(videobuf_read_stream); EXPORT_SYMBOL_GPL(videobuf_read_one); EXPORT_SYMBOL_GPL(videobuf_poll_stream); -- cgit v1.2.3 From 053fcb6014eef31c2674d344c704118e0ac229ef Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Tue, 13 Nov 2007 20:11:26 -0300 Subject: V4L/DVB (6602): V4L: Convert videobuf drivers to videobuf_stop Drivers were using cookie cutter code for stopping the read/stream. Use the new videobuf_stop function which is lock safe. Signed-off-by: Brandon Philips Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/bt8xx/bttv-driver.c | 5 +---- drivers/media/video/cx88/cx88-blackbird.c | 5 +---- drivers/media/video/cx88/cx88-video.c | 5 +---- drivers/media/video/saa7134/saa7134-empress.c | 5 +---- drivers/media/video/saa7134/saa7134-video.c | 5 +---- drivers/media/video/vivi.c | 1 + 6 files changed, 6 insertions(+), 20 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index a88b56e6ca0..2182ef089eb 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c @@ -3827,10 +3827,7 @@ static int bttv_release(struct inode *inode, struct file *file) /* stop vbi capture */ if (check_btres(fh, RESOURCE_VBI)) { - if (fh->vbi.streaming) - videobuf_streamoff(&fh->vbi); - if (fh->vbi.reading) - videobuf_read_stop(&fh->vbi); + videobuf_stop(&fh->vbi); free_btres(btv,fh,RESOURCE_VBI); } diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index f33f0b47142..f802b565356 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c @@ -1085,10 +1085,7 @@ static int mpeg_release(struct inode *inode, struct file *file) cx8802_cancel_buffers(fh->dev); /* stop mpeg capture */ - if (fh->mpegq.streaming) - videobuf_streamoff(&fh->mpegq); - if (fh->mpegq.reading) - videobuf_read_stop(&fh->mpegq); + videobuf_stop(&fh->mpegq); videobuf_mmap_free(&fh->mpegq); file->private_data = NULL; diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 5ee05f8f3fa..c84dafbdb99 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c @@ -851,10 +851,7 @@ static int video_release(struct inode *inode, struct file *file) /* stop vbi capture */ if (res_check(fh, RESOURCE_VBI)) { - if (fh->vbiq.streaming) - videobuf_streamoff(&fh->vbiq); - if (fh->vbiq.reading) - videobuf_read_stop(&fh->vbiq); + videobuf_stop(&fh->vbiq); res_free(dev,fh,RESOURCE_VBI); } diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index 75d0c5bf46d..9322f44865b 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c @@ -110,11 +110,8 @@ static int ts_release(struct inode *inode, struct file *file) { struct saa7134_dev *dev = file->private_data; - if (dev->empress_tsq.streaming) - videobuf_streamoff(&dev->empress_tsq); mutex_lock(&dev->empress_tsq.lock); - if (dev->empress_tsq.reading) - videobuf_read_stop(&dev->empress_tsq); + videobuf_stop(&dev->empress_tsq); videobuf_mmap_free(&dev->empress_tsq); dev->empress_users--; diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 3b9ffb4b648..6396d9b5c06 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c @@ -1445,10 +1445,7 @@ static int video_release(struct inode *inode, struct file *file) /* stop vbi capture */ if (res_check(fh, RESOURCE_VBI)) { - if (fh->vbi.streaming) - videobuf_streamoff(&fh->vbi); - if (fh->vbi.reading) - videobuf_read_stop(&fh->vbi); + videobuf_stop(&fh->vbi); res_free(dev,fh,RESOURCE_VBI); } diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index ee73dc75131..9b54ff9d2e3 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c @@ -1076,6 +1076,7 @@ static int vivi_release(struct inode *inode, struct file *file) int minor = iminor(inode); vivi_stop_thread(vidq); + videobuf_stop(&fh->vb_vidq); videobuf_mmap_free(&fh->vb_vidq); kfree (fh); -- cgit v1.2.3 From 820eacd84cff23b76693f4be1e28feb672f4488f Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Mon, 19 Nov 2007 15:10:48 -0300 Subject: V4L/DVB (6615): V4L: Fix VIDIOCGMBUF locking in saa7146 Fallout from videobuf_mmap_setup() locking fixes. Signed-off-by: Brandon Philips Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/saa7146_video.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c index 7cc4213ba56..ae36d101006 100644 --- a/drivers/media/common/saa7146_video.c +++ b/drivers/media/common/saa7146_video.c @@ -1205,13 +1205,10 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int DEB_D(("VIDIOCGMBUF \n")); q = &fh->video_q; - mutex_lock(&q->lock); err = videobuf_mmap_setup(q,gbuffers,gbufsize, V4L2_MEMORY_MMAP); - if (err < 0) { - mutex_unlock(&q->lock); + if (err < 0) return err; - } gbuffers = err; memset(mbuf,0,sizeof(*mbuf)); @@ -1219,7 +1216,6 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int mbuf->size = gbuffers * gbufsize; for (i = 0; i < gbuffers; i++) mbuf->offsets[i] = i * gbufsize; - mutex_unlock(&q->lock); return 0; } #endif -- cgit v1.2.3 From 78f3b0b672c79df9ffa55399a7d6fc4b173e9b4b Mon Sep 17 00:00:00 2001 From: Chris Pascoe Date: Mon, 19 Nov 2007 03:47:07 -0300 Subject: V4L/DVB (6629): zl10353: fix default adc_clock and TRL nominal rate calculation The default adc_clock for the zl10353 is different from what was originally thought to be the case and the TRL nominal rate formula was incorrect as a result. Use a better (and hopefully now correct) formula. Signed-off-by: Chris Pascoe Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/zl10353.c | 4 ++-- drivers/media/dvb/frontends/zl10353.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c index a97a7fd2c89..0106df4c55e 100644 --- a/drivers/media/dvb/frontends/zl10353.c +++ b/drivers/media/dvb/frontends/zl10353.c @@ -122,7 +122,7 @@ static void zl10353_calc_nominal_rate(struct dvb_frontend *fe, enum fe_bandwidth bandwidth, u16 *nominal_rate) { - u32 adc_clock = 22528; /* 20.480 MHz on the board(!?) */ + u32 adc_clock = 45056; /* 45.056 MHz */ u8 bw; struct zl10353_state *state = fe->demodulator_priv; @@ -142,7 +142,7 @@ static void zl10353_calc_nominal_rate(struct dvb_frontend *fe, break; } - *nominal_rate = (64 * bw * (1<<16) / (7 * 8) * 4000 / adc_clock + 2) / 4; + *nominal_rate = (bw * (1 << 23) / 7 * 125 + adc_clock / 2) / adc_clock; dprintk("%s: bw %d, adc_clock %d => 0x%x\n", __FUNCTION__, bw, adc_clock, *nominal_rate); diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h index cb274dc12b8..1c3d494a6da 100644 --- a/drivers/media/dvb/frontends/zl10353.h +++ b/drivers/media/dvb/frontends/zl10353.h @@ -30,7 +30,7 @@ struct zl10353_config u8 demod_address; /* frequencies in kHz */ - int adc_clock; // default: 22528 + int adc_clock; /* default: 45056 */ /* set if no pll is connected to the secondary i2c bus */ int no_tuner; -- cgit v1.2.3 From 174eb8e8cb1ec97904ddeaae54366a03789162ef Mon Sep 17 00:00:00 2001 From: Heikki Lindholm Date: Fri, 23 Nov 2007 18:59:18 -0300 Subject: V4L/DVB (6666): saa7134-alsa: fix period handling The period handling in saa7134-alsa is broken in two ways. First, the minimum number of periods of two does not work, because the dma is setup two periods ahead in the irq handler. Fix the minimum to four periods. Second, the code assumes that the number of periods is divisible by two, which isn't always the case on ALSA. Fix by adding a constraint. Signed-off-by: Heikki Lindholm Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7134/saa7134-alsa.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index b9c5cf7dc84..ece177de72a 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c @@ -457,7 +457,7 @@ static struct snd_pcm_hardware snd_card_saa7134_capture = .buffer_bytes_max = (256*1024), .period_bytes_min = 64, .period_bytes_max = (256*1024), - .periods_min = 2, + .periods_min = 4, .periods_max = 1024, }; @@ -491,7 +491,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream, snd_assert(period_size >= 0x100 && period_size <= 0x10000, return -EINVAL); - snd_assert(periods >= 2, return -EINVAL); + snd_assert(periods >= 4, return -EINVAL); snd_assert(period_size * periods <= 1024 * 1024, return -EINVAL); dev = saa7134->dev; @@ -647,7 +647,14 @@ static int snd_card_saa7134_capture_open(struct snd_pcm_substream * substream) saa7134_tvaudio_setmute(dev); } - if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) + err = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + if (err < 0) + return err; + + err = snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_PERIODS, 2); + if (err < 0) return err; return 0; -- cgit v1.2.3 From b730a81c51adc8e87ae3b055fc211af7d5472df2 Mon Sep 17 00:00:00 2001 From: Richard Knutsson Date: Tue, 27 Nov 2007 06:59:37 -0300 Subject: V4L/DVB (6684): Complement va_start() with va_end() + style fixes Complement va_start() with va_end() + minor style fixes in the same function. Signed-off-by: Richard Knutsson Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa5246a.c | 10 ++++++---- drivers/media/video/saa5249.c | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index ad0232935df..996b49491f5 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c @@ -187,12 +187,14 @@ static int i2c_senddata(struct saa5246a_device *t, ...) { unsigned char buf[64]; int v; - int ct=0; + int ct = 0; va_list argp; - va_start(argp,t); + va_start(argp, t); - while((v=va_arg(argp,int))!=-1) - buf[ct++]=v; + while ((v = va_arg(argp, int)) != -1) + buf[ct++] = v; + + va_end(argp); return i2c_sendbuf(t, buf[0], ct-1, buf+1); } diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index 94bb59a32b1..f55d6e85f20 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c @@ -282,12 +282,14 @@ static int i2c_senddata(struct saa5249_device *t, ...) { unsigned char buf[64]; int v; - int ct=0; + int ct = 0; va_list argp; va_start(argp,t); - while((v=va_arg(argp,int))!=-1) - buf[ct++]=v; + while ((v = va_arg(argp, int)) != -1) + buf[ct++] = v; + + va_end(argp); return i2c_sendbuf(t, buf[0], ct-1, buf+1); } -- cgit v1.2.3 From 4aa504a89a140f482ddabb45460e0005bf3e522a Mon Sep 17 00:00:00 2001 From: Hermann Pitton Date: Wed, 28 Nov 2007 21:50:26 -0300 Subject: V4L/DVB (6686): saa7134: fix composite over s-video input on the Tevion MD 9717 The vmux for composite over s-video input was wrong. Signed-off-by: Hermann Pitton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7134/saa7134-cards.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 4f3dad9ae6d..c6eb1e37a46 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -334,7 +334,7 @@ struct saa7134_board saa7134_boards[] = { .tv = 1, },{ .name = name_comp1, - .vmux = 2, + .vmux = 0, .amux = LINE1, },{ .name = name_comp2, -- cgit v1.2.3 From 843b1378c2ab47ab1ed9cb471938e0f0ec839fcd Mon Sep 17 00:00:00 2001 From: Heikki Lindholm Date: Fri, 30 Nov 2007 13:27:26 -0300 Subject: V4L/DVB (6690): saa7134: fix ignored interrupts The saa7134 video driver starts dropping frames when used together with the saa7134-alsa driver. Frames are dropped because when an audio event is waiting the driver simply ignores the interrupt and passes it on to the saa7134-alsa interrupt handler. The alsa interrupt handler in turn acknowledges all types of events thus clearing the pending video events as well. Fix by only masking out the audio event in the video interrupt handler and by only acknowledging the audio event in the alsa driver. Signed-off-by: Heikki Lindholm Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7134/saa7134-alsa.c | 3 ++- drivers/media/video/saa7134/saa7134-core.c | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index ece177de72a..4878f306778 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c @@ -222,7 +222,8 @@ static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id) if (report & SAA7134_IRQ_REPORT_DONE_RA3) { handled = 1; - saa_writel(SAA7134_IRQ_REPORT,report); + saa_writel(SAA7134_IRQ_REPORT, + SAA7134_IRQ_REPORT_DONE_RA3); saa7134_irq_alsa_done(dev, status); } else { goto out; diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index a499eea379e..4fd187ac9d7 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c @@ -569,21 +569,22 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id) for (loop = 0; loop < 10; loop++) { report = saa_readl(SAA7134_IRQ_REPORT); status = saa_readl(SAA7134_IRQ_STATUS); - if (0 == report) { - if (irq_debug > 1) - printk(KERN_DEBUG "%s/irq: no (more) work\n", - dev->name); - goto out; - } - - /* If dmasound support is active and we get a sound report, exit - and let the saa7134-alsa/oss module deal with it */ + /* If dmasound support is active and we get a sound report, + * mask out the report and let the saa7134-alsa module deal + * with it */ if ((report & SAA7134_IRQ_REPORT_DONE_RA3) && (dev->dmasound.priv_data != NULL) ) { if (irq_debug > 1) - printk(KERN_DEBUG "%s/irq: ignoring interrupt for DMA sound\n", + printk(KERN_DEBUG "%s/irq: preserving DMA sound interrupt\n", + dev->name); + report &= ~SAA7134_IRQ_REPORT_DONE_RA3; + } + + if (0 == report) { + if (irq_debug > 1) + printk(KERN_DEBUG "%s/irq: no (more) work\n", dev->name); goto out; } -- cgit v1.2.3 From 0b29669c065f60501e7289e1950fa2a618962358 Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Sat, 8 Dec 2007 23:05:53 -0300 Subject: V4L/DVB (6751): V4L: Memory leak! Fix count in videobuf-vmalloc mmap This is pretty serious bug. map->count is never initialized after the call to kmalloc making the count start at some random trash value. The end result is leaking videobufs. Also, fix up the debug statements to print unsigned values. Pushed to http://ifup.org/hg/v4l-dvb too Signed-off-by: Brandon Philips Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/videobuf-vmalloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/videobuf-vmalloc.c b/drivers/media/video/videobuf-vmalloc.c index cd74341c984..e01259438bb 100644 --- a/drivers/media/video/videobuf-vmalloc.c +++ b/drivers/media/video/videobuf-vmalloc.c @@ -51,7 +51,7 @@ videobuf_vm_open(struct vm_area_struct *vma) { struct videobuf_mapping *map = vma->vm_private_data; - dprintk(2,"vm_open %p [count=%d,vma=%08lx-%08lx]\n",map, + dprintk(2,"vm_open %p [count=%u,vma=%08lx-%08lx]\n",map, map->count,vma->vm_start,vma->vm_end); map->count++; @@ -64,7 +64,7 @@ videobuf_vm_close(struct vm_area_struct *vma) struct videobuf_queue *q = map->q; int i; - dprintk(2,"vm_close %p [count=%d,vma=%08lx-%08lx]\n",map, + dprintk(2,"vm_close %p [count=%u,vma=%08lx-%08lx]\n",map, map->count,vma->vm_start,vma->vm_end); map->count--; @@ -221,7 +221,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, } /* create mapping + update buffer list */ - map = q->bufs[first]->map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); + map = q->bufs[first]->map = kzalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); if (NULL == map) return -ENOMEM; -- cgit v1.2.3 From bc5483705ce08795ad64c3fb14aa7cee4847a2ea Mon Sep 17 00:00:00 2001 From: Benoit Istin Date: Fri, 7 Dec 2007 02:00:04 -0300 Subject: V4L/DVB (6746): saa7134-dvb: fix tuning for WinTV HVR-1110 There are several months my hvr1110 stop working. This is very simple to fix, for my card revision at least, by setting a missing field to the hauppauge_hvr_1110_config. Signed-off-by: Benoit Istin Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7134/saa7134-dvb.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 38d87332cc5..e1ab099ec4c 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c @@ -662,6 +662,7 @@ static struct tda1004x_config hauppauge_hvr_1110_config = { .if_freq = TDA10046_FREQ_045, .i2c_gate = 0x4b, .tuner_address = 0x61, + .tuner_config = 1, .request_firmware = philips_tda1004x_request_firmware }; -- cgit v1.2.3 From 8733e29748591ce04f7cf07fc9c177f63e7df6af Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 8 Dec 2007 09:34:37 -0300 Subject: V4L/DVB (6750): Fix in-kernel compilation for cxusb cxusb needs tuner-xc2028*.h files, but Makefile is not adding its patch drivers/media/dvb/dvb-usb/cxusb.c:33:26: error: tuner-xc2028.h: File not found drivers/media/dvb/dvb-usb/cxusb.c:34:32: error: tuner-xc2028-types.h: File not found Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-usb/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 73ac0a93fde..60a910052c1 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile @@ -62,3 +62,6 @@ dvb-usb-af9005-remote-objs = af9005-remote.o obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ +# due to tuner-xc3028 +EXTRA_CFLAGS += -Idrivers/media/video + -- cgit v1.2.3 From f6b5cf771afcc96444cab44805e5a73e42f97db2 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Wed, 5 Dec 2007 15:14:19 -0300 Subject: V4L/DVB (6733): DVB: Compile 3000MC-specific DIB code only for CONFIG_DVB_DIB3000MC On Tue, 4 Dec 2007, Ingo Molnar wrote: > drivers/built-in.o: In function `dibusb_dib3000mc_tuner_attach': > : undefined reference to `dib3000mc_get_tuner_i2c_master' > drivers/built-in.o: In function `dibusb_dib3000mc_tuner_attach': > : undefined reference to `dib3000mc_set_config' Seems like -common part contains also code that is not completely common to all the modules. Signed-off-by: Jiri Kosina Tested-by: Ingo Molnar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-usb/dibusb-common.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c index 9a184da01c4..b95b1eb1eba 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-common.c +++ b/drivers/media/dvb/dvb-usb/dibusb-common.c @@ -223,6 +223,7 @@ static struct dibx000_agc_config dib3000p_panasonic_agc_config = { .agc2_slope2 = 0x1e, }; +#ifdef CONFIG_DVB_DIB3000MC static struct dib3000mc_config mod3000p_dib3000p_config = { &dib3000p_panasonic_agc_config, @@ -305,6 +306,7 @@ int dibusb_dib3000mc_tuner_attach(struct dvb_usb_adapter *adap) return 0; } EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach); +#endif /* * common remote control stuff -- cgit v1.2.3 From 4a56087f3b7660c9824e9ec69b96ccf8d9b25d1c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 11 Dec 2007 14:59:10 -0300 Subject: V4L/DVB (6794): Fix compilation when dib3000mc is compiled as a module As reported by Andrew Morton: > ERROR: "dibusb_dib3000mc_frontend_attach" [drivers/media/dvb/dvb-usb/dvb-usb-nova-t-usb2.ko] undefined! > ERROR: "dibusb_dib3000mc_tuner_attach" [drivers/media/dvb/dvb-usb/dvb-usb-nova-t-usb2.ko] undefined! > ERROR: "dibusb_dib3000mc_frontend_attach" [drivers/media/dvb/dvb-usb/dvb-usb-dibusb-mc.ko] undefined! > ERROR: "dibusb_dib3000mc_tuner_attach" [drivers/media/dvb/dvb-usb/dvb-usb-dibusb-mc.ko] undefined! > ERROR: "dibusb_dib3000mc_frontend_attach" [drivers/media/dvb/dvb-usb/dvb-usb-a800.ko] undefined! > ERROR: "dibusb_dib3000mc_tuner_attach" [drivers/media/dvb/dvb-usb/dvb-usb-a800.ko] undefined Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-usb/dibusb-common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c index b95b1eb1eba..8ee6cd4da9e 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-common.c +++ b/drivers/media/dvb/dvb-usb/dibusb-common.c @@ -223,7 +223,9 @@ static struct dibx000_agc_config dib3000p_panasonic_agc_config = { .agc2_slope2 = 0x1e, }; -#ifdef CONFIG_DVB_DIB3000MC +#if defined(CONFIG_DVB_DIB3000MC) || \ + (defined(CONFIG_DVB_DIB3000MC_MODULE) && defined(MODULE)) + static struct dib3000mc_config mod3000p_dib3000p_config = { &dib3000p_panasonic_agc_config, -- cgit v1.2.3 From 056827a49ce65a8d10197d35468500b501d1eec1 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 11 Dec 2007 19:23:49 -0300 Subject: V4L/DVB (6796): ivtv/ section fix This patch fixes the following section mismatch with CONFIG_HOTPLUG=n: <-- snip --> ... ... <-- snip --> Signed-off-by: Adrian Bunk Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/ivtv/ivtv-i2c.c | 2 +- drivers/media/video/ivtv/ivtv-i2c.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c index 623eea2652c..77b27dc750b 100644 --- a/drivers/media/video/ivtv/ivtv-i2c.c +++ b/drivers/media/video/ivtv/ivtv-i2c.c @@ -706,7 +706,7 @@ void ivtv_call_i2c_clients(struct ivtv *itv, unsigned int cmd, void *arg) } /* init + register i2c algo-bit adapter */ -int __devinit init_ivtv_i2c(struct ivtv *itv) +int init_ivtv_i2c(struct ivtv *itv) { IVTV_DEBUG_I2C("i2c init\n"); diff --git a/drivers/media/video/ivtv/ivtv-i2c.h b/drivers/media/video/ivtv/ivtv-i2c.h index de6a0744229..987042c09b6 100644 --- a/drivers/media/video/ivtv/ivtv-i2c.h +++ b/drivers/media/video/ivtv/ivtv-i2c.h @@ -35,7 +35,7 @@ int ivtv_call_i2c_client(struct ivtv *itv, int addr, unsigned int cmd, void *arg void ivtv_call_i2c_clients(struct ivtv *itv, unsigned int cmd, void *arg); /* init + register i2c algo-bit adapter */ -int __devinit init_ivtv_i2c(struct ivtv *itv); +int init_ivtv_i2c(struct ivtv *itv); void exit_ivtv_i2c(struct ivtv *itv); #endif -- cgit v1.2.3 From 7d44e8921851f460bcacb3ade432a4f5ada20fb6 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 11 Dec 2007 19:23:43 -0300 Subject: V4L/DVB (6797): bt8xx/ section fixes This patch fixes the following section mismatch with CONFIG_HOTPLUG=n: <-- snip --> ... ... <-- snip --> Signed-off-by: Adrian Bunk Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/bt8xx/bttv-cards.c | 2 +- drivers/media/video/bt8xx/bttv-driver.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c index 3abd9fa54d2..585d1ef95af 100644 --- a/drivers/media/video/bt8xx/bttv-cards.c +++ b/drivers/media/video/bt8xx/bttv-cards.c @@ -5080,7 +5080,7 @@ static void PXC200_muxsel(struct bttv *btv, unsigned int input) /* ----------------------------------------------------------------------- */ /* motherboard chipset specific stuff */ -void __devinit bttv_check_chipset(void) +void __init bttv_check_chipset(void) { int pcipci_fail = 0; struct pci_dev *dev = NULL; diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index 2182ef089eb..c02d92deacd 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c @@ -4985,7 +4985,7 @@ static struct pci_driver bttv_pci_driver = { #endif }; -static int bttv_init_module(void) +static int __init bttv_init_module(void) { int ret; @@ -5018,7 +5018,7 @@ static int bttv_init_module(void) return pci_register_driver(&bttv_pci_driver); } -static void bttv_cleanup_module(void) +static void __exit bttv_cleanup_module(void) { pci_unregister_driver(&bttv_pci_driver); bus_unregister(&bttv_sub_bus_type); -- cgit v1.2.3 From 4af75653031c6d454b4ace47c1536f0d2e727e3e Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 11 Dec 2007 19:28:36 -0800 Subject: Revert "make bnx2x select ZLIB_INFLATE" This reverts commit 70eba18b5664f90d7620905e005b89388e5fd94b, as per Jeff Garzik: "That was meant for 2.6.25, and actually (due to patching) applied to a completely unrelated 2.6.24 net driver." Noted-by: Roland Dreier Requested-by: Jeff Garzik Signed-off-by: Linus Torvalds --- drivers/net/Kconfig | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 6cde4edc846..d9107e542df 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2588,7 +2588,6 @@ config MLX4_DEBUG config TEHUTI tristate "Tehuti Networks 10G Ethernet" depends on PCI - select ZLIB_INFLATE help Tehuti Networks 10G Ethernet NIC -- cgit v1.2.3 From 19fb1457990b6b7e15586ec7331541a184233acc Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 15 Nov 2007 23:09:30 -0300 Subject: V4L/DVB (6609): Re-adds lock safe videobuf_read_start videobuf_dvb needs videobuf_read_start. The EXPORT_SYMBOL_GPL() were removed by a previous patch. However, videobuf_dvb needs this. This patch re-adds videobuf_read_start, doing the proper lock. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/videobuf-core.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index de2f56b1916..81f77d2b4bd 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c @@ -806,7 +806,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, } /* Locking: Caller holds q->lock */ -int videobuf_read_start(struct videobuf_queue *q) +int __videobuf_read_start(struct videobuf_queue *q) { enum v4l2_field field; unsigned long flags=0; @@ -862,6 +862,17 @@ static void __videobuf_read_stop(struct videobuf_queue *q) } +int videobuf_read_start(struct videobuf_queue *q) +{ + int rc; + + mutex_lock(&q->lock); + rc = __videobuf_read_start(q); + mutex_unlock(&q->lock); + + return rc; +} + void videobuf_read_stop(struct videobuf_queue *q) { mutex_lock(&q->lock); @@ -1058,6 +1069,7 @@ EXPORT_SYMBOL_GPL(videobuf_dqbuf); EXPORT_SYMBOL_GPL(videobuf_streamon); EXPORT_SYMBOL_GPL(videobuf_streamoff); +EXPORT_SYMBOL_GPL(videobuf_read_start); EXPORT_SYMBOL_GPL(videobuf_read_stop); EXPORT_SYMBOL_GPL(videobuf_stop); EXPORT_SYMBOL_GPL(videobuf_read_stream); -- cgit v1.2.3 From 50862d9490e8fbb317040b3faeee7caf56c00025 Mon Sep 17 00:00:00 2001 From: Atsushi Nemoto Date: Wed, 12 Dec 2007 13:45:24 +0100 Subject: i2c-gpio: Initialize adapter class This is required to let hwmon drivers attach to the adapter. Signed-off-by: Atsushi Nemoto Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-gpio.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 44e1cd21bb0..3ca19fc234f 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -140,6 +140,7 @@ static int __init i2c_gpio_probe(struct platform_device *pdev) adap->owner = THIS_MODULE; snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); adap->algo_data = bit_data; + adap->class = I2C_CLASS_HWMON; adap->dev.parent = &pdev->dev; /* -- cgit v1.2.3 From fce3ff03311e0397e2867cce67d4ccf31707a1ea Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 12 Dec 2007 13:45:24 +0100 Subject: i2c: Add missing spaces in split log messages Signed-off-by: Joe Perches Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-davinci.c | 4 ++-- drivers/i2c/busses/i2c-omap.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index bd7aaff3524..67679882ebe 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c @@ -404,7 +404,7 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id) DAVINCI_I2C_STR_REG, w); } else - dev_err(dev->dev, "RDR IRQ while no" + dev_err(dev->dev, "RDR IRQ while no " "data requested\n"); break; @@ -423,7 +423,7 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id) DAVINCI_I2C_IMR_REG, w); } else - dev_err(dev->dev, "TDR IRQ while no data to" + dev_err(dev->dev, "TDR IRQ while no data to " "send\n"); break; diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 89a30028ddb..cb55cf2ba1e 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -203,7 +203,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) & OMAP_I2C_SYSS_RDONE)) { if (time_after(jiffies, timeout)) { - dev_warn(dev->dev, "timeout waiting" + dev_warn(dev->dev, "timeout waiting " "for controller reset\n"); return -ETIMEDOUT; } @@ -483,7 +483,7 @@ omap_i2c_isr(int this_irq, void *dev_id) dev->buf_len--; } } else - dev_err(dev->dev, "RRDY IRQ while no data" + dev_err(dev->dev, "RRDY IRQ while no data " "requested\n"); omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RRDY); continue; @@ -498,7 +498,7 @@ omap_i2c_isr(int this_irq, void *dev_id) dev->buf_len--; } } else - dev_err(dev->dev, "XRDY IRQ while no" + dev_err(dev->dev, "XRDY IRQ while no " "data to send\n"); omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XRDY); -- cgit v1.2.3 From 187426e69afe0a2ad697c9c5f5f654254da0e3a0 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 12 Dec 2007 13:45:25 +0100 Subject: i2c/isp1301_omap: Build fix Build fix to the isp1301_omap driver ... this driver gets built more often in the OMAP tree than in mainline, partly because the defconfig for H2 (plus probably H3 and H4) needs updating. Signed-off-by: David Brownell Signed-off-by: Jean Delvare --- drivers/i2c/chips/isp1301_omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index fe04e46991a..b767603a07b 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include -- cgit v1.2.3 From 58d784a5c754cd66ecd4791222162504d3c16c74 Mon Sep 17 00:00:00 2001 From: Martin Habets Date: Tue, 11 Dec 2007 03:37:04 -0800 Subject: [SERIAL] sparc: Infrastructure to fix section mismatch bugs. This patch against 2.6.23 sparc-2.6.git contains a number of minor cleanups of the sparc serial drivers. Initially I fixed this build warning: WARNING: vmlinux.o(.text+0x107a2c): Section mismatch: reference to .init.text:add_preferred_console (between 'sunserial_console_match' and 'sunserial_console_termios') which is done by declaring sunserial_console_match() as __init. This resulted in build warnings on sunserial_current_minor. To resolve these the variable was changed so it is no longer global, and to hide operations on it inside 2 new functions. These functions handle the UART minor handling code that is common to all sparc serial drivers. These changes allowed to clean up the uart counters in all the sparc serial drivers, and the administration of minor device numbers. Lastly, sunserial_console_termios() does not need to be exported since it is only called from non-modular code. Sadly, the following build warning still exists: WARNING: vmlinux.o(__ksymtab+0x2910): Section mismatch: reference to .init.text:sunserial_console_match (between '__ksymtab_sunserial_console_match' and '__ksymtab_sunserial_unregister_minors') This could be resolved by not exporting sunserial_console_match(), but this is not possible at the moment because it is being called from modular code. On the other hand, this is a bogus warning since it comes from a ksymtab section. Signed-off-by: Martin Habets Signed-off-by: David S. Miller --- drivers/serial/suncore.c | 33 ++++++++++++++++++++++++++++----- drivers/serial/suncore.h | 3 ++- drivers/serial/sunhv.c | 14 +++----------- drivers/serial/sunsab.c | 16 ++++------------ drivers/serial/sunsu.c | 16 +++++----------- drivers/serial/sunzilog.c | 41 ++++++++++++++++------------------------- 6 files changed, 58 insertions(+), 65 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/suncore.c b/drivers/serial/suncore.c index 70a09a3d5af..707c5b03bce 100644 --- a/drivers/serial/suncore.c +++ b/drivers/serial/suncore.c @@ -23,11 +23,36 @@ #include "suncore.h" -int sunserial_current_minor = 64; +static int sunserial_current_minor = 64; -EXPORT_SYMBOL(sunserial_current_minor); +int sunserial_register_minors(struct uart_driver *drv, int count) +{ + int err = 0; + + drv->minor = sunserial_current_minor; + drv->nr += count; + /* Register the driver on the first call */ + if (drv->nr == count) + err = uart_register_driver(drv); + if (err == 0) { + sunserial_current_minor += count; + drv->tty_driver->name_base = drv->minor - 64; + } + return err; +} +EXPORT_SYMBOL(sunserial_register_minors); + +void sunserial_unregister_minors(struct uart_driver *drv, int count) +{ + drv->nr -= count; + sunserial_current_minor -= count; + + if (drv->nr == 0) + uart_unregister_driver(drv); +} +EXPORT_SYMBOL(sunserial_unregister_minors); -int sunserial_console_match(struct console *con, struct device_node *dp, +int __init sunserial_console_match(struct console *con, struct device_node *dp, struct uart_driver *drv, int line) { int off; @@ -133,8 +158,6 @@ sunserial_console_termios(struct console *con) con->cflag = cflag; } -EXPORT_SYMBOL(sunserial_console_termios); - /* Sun serial MOUSE auto baud rate detection. */ static struct mouse_baud_cflag { int baud; diff --git a/drivers/serial/suncore.h b/drivers/serial/suncore.h index 829d7d65d6d..042668aa602 100644 --- a/drivers/serial/suncore.h +++ b/drivers/serial/suncore.h @@ -22,7 +22,8 @@ extern unsigned int suncore_mouse_baud_cflag_next(unsigned int, int *); extern int suncore_mouse_baud_detection(unsigned char, int); -extern int sunserial_current_minor; +extern int sunserial_register_minors(struct uart_driver *, int); +extern void sunserial_unregister_minors(struct uart_driver *, int); extern int sunserial_console_match(struct console *, struct device_node *, struct uart_driver *, int); diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c index 8ff900b0981..be0fe152891 100644 --- a/drivers/serial/sunhv.c +++ b/drivers/serial/sunhv.c @@ -562,16 +562,10 @@ static int __devinit hv_probe(struct of_device *op, const struct of_device_id *m port->dev = &op->dev; - sunhv_reg.minor = sunserial_current_minor; - sunhv_reg.nr = 1; - - err = uart_register_driver(&sunhv_reg); + err = sunserial_register_minors(&sunhv_reg, 1); if (err) goto out_free_con_read_page; - sunhv_reg.tty_driver->name_base = sunhv_reg.minor - 64; - sunserial_current_minor += 1; - sunserial_console_match(&sunhv_console, op->node, &sunhv_reg, port->line); @@ -591,8 +585,7 @@ out_remove_port: uart_remove_one_port(&sunhv_reg, port); out_unregister_driver: - sunserial_current_minor -= 1; - uart_unregister_driver(&sunhv_reg); + sunserial_unregister_minors(&sunhv_reg, 1); out_free_con_read_page: kfree(con_read_page); @@ -614,8 +607,7 @@ static int __devexit hv_remove(struct of_device *dev) uart_remove_one_port(&sunhv_reg, port); - sunserial_current_minor -= 1; - uart_unregister_driver(&sunhv_reg); + sunserial_unregister_minors(&sunhv_reg, 1); kfree(port); sunhv_port = NULL; diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index ff610c23314..543f93741e6 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c @@ -832,7 +832,6 @@ static struct uart_driver sunsab_reg = { }; static struct uart_sunsab_port *sunsab_ports; -static int num_channels; #ifdef CONFIG_SERIAL_SUNSAB_CONSOLE @@ -1102,8 +1101,8 @@ static int __init sunsab_init(void) { struct device_node *dp; int err; + int num_channels = 0; - num_channels = 0; for_each_node_by_name(dp, "se") num_channels += 2; for_each_node_by_name(dp, "serial") { @@ -1117,20 +1116,14 @@ static int __init sunsab_init(void) if (!sunsab_ports) return -ENOMEM; - sunsab_reg.minor = sunserial_current_minor; - sunsab_reg.nr = num_channels; sunsab_reg.cons = SUNSAB_CONSOLE(); - - err = uart_register_driver(&sunsab_reg); + err = sunserial_register_minors(&sunsab_reg, num_channels); if (err) { kfree(sunsab_ports); sunsab_ports = NULL; return err; } - - sunsab_reg.tty_driver->name_base = sunsab_reg.minor - 64; - sunserial_current_minor += num_channels; } return of_register_driver(&sab_driver, &of_bus_type); @@ -1139,9 +1132,8 @@ static int __init sunsab_init(void) static void __exit sunsab_exit(void) { of_unregister_driver(&sab_driver); - if (num_channels) { - sunserial_current_minor -= num_channels; - uart_unregister_driver(&sunsab_reg); + if (sunsab_reg.nr) { + sunserial_unregister_minors(&sunsab_reg, sunsab_reg.nr); } kfree(sunsab_ports); diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index e074943feff..4e2302d43ab 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c @@ -1528,14 +1528,12 @@ static struct of_platform_driver su_driver = { .remove = __devexit_p(su_remove), }; -static int num_uart; - static int __init sunsu_init(void) { struct device_node *dp; int err; + int num_uart = 0; - num_uart = 0; for_each_node_by_name(dp, "su") { if (su_get_type(dp) == SU_PORT_PORT) num_uart++; @@ -1552,26 +1550,22 @@ static int __init sunsu_init(void) } if (num_uart) { - sunsu_reg.minor = sunserial_current_minor; - sunsu_reg.nr = num_uart; - err = uart_register_driver(&sunsu_reg); + err = sunserial_register_minors(&sunsu_reg, num_uart); if (err) return err; - sunsu_reg.tty_driver->name_base = sunsu_reg.minor - 64; - sunserial_current_minor += num_uart; } err = of_register_driver(&su_driver, &of_bus_type); if (err && num_uart) - uart_unregister_driver(&sunsu_reg); + sunserial_unregister_minors(&sunsu_reg, num_uart); return err; } static void __exit sunsu_exit(void) { - if (num_uart) - uart_unregister_driver(&sunsu_reg); + if (sunsu_reg.nr) + sunserial_unregister_minors(&sunsu_reg, sunsu_reg.nr); } module_init(sunsu_init); diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index 283bef0d24c..cb2e4050637 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c @@ -63,10 +63,6 @@ readb(&((__channel)->control)) #endif -static int num_sunzilog; -#define NUM_SUNZILOG num_sunzilog -#define NUM_CHANNELS (NUM_SUNZILOG * 2) - #define ZS_CLOCK 4915200 /* Zilog input clock rate. */ #define ZS_CLOCK_DIVISOR 16 /* Divisor this driver uses. */ @@ -1031,18 +1027,19 @@ static struct uart_driver sunzilog_reg = { .major = TTY_MAJOR, }; -static int __init sunzilog_alloc_tables(void) +static int __init sunzilog_alloc_tables(int num_sunzilog) { struct uart_sunzilog_port *up; unsigned long size; + int num_channels = num_sunzilog * 2; int i; - size = NUM_CHANNELS * sizeof(struct uart_sunzilog_port); + size = num_channels * sizeof(struct uart_sunzilog_port); sunzilog_port_table = kzalloc(size, GFP_KERNEL); if (!sunzilog_port_table) return -ENOMEM; - for (i = 0; i < NUM_CHANNELS; i++) { + for (i = 0; i < num_channels; i++) { up = &sunzilog_port_table[i]; spin_lock_init(&up->port.lock); @@ -1050,13 +1047,13 @@ static int __init sunzilog_alloc_tables(void) if (i == 0) sunzilog_irq_chain = up; - if (i < NUM_CHANNELS - 1) + if (i < num_channels - 1) up->next = up + 1; else up->next = NULL; } - size = NUM_SUNZILOG * sizeof(struct zilog_layout __iomem *); + size = num_sunzilog * sizeof(struct zilog_layout __iomem *); sunzilog_chip_regs = kzalloc(size, GFP_KERNEL); if (!sunzilog_chip_regs) { kfree(sunzilog_port_table); @@ -1496,34 +1493,28 @@ static int __init sunzilog_init(void) struct device_node *dp; int err, uart_count; int num_keybms; + int num_sunzilog = 0; - NUM_SUNZILOG = 0; num_keybms = 0; for_each_node_by_name(dp, "zs") { - NUM_SUNZILOG++; + num_sunzilog++; if (of_find_property(dp, "keyboard", NULL)) num_keybms++; } uart_count = 0; - if (NUM_SUNZILOG) { + if (num_sunzilog) { int uart_count; - err = sunzilog_alloc_tables(); + err = sunzilog_alloc_tables(num_sunzilog); if (err) goto out; - uart_count = (NUM_SUNZILOG * 2) - (2 * num_keybms); + uart_count = (num_sunzilog * 2) - (2 * num_keybms); - sunzilog_reg.nr = uart_count; - sunzilog_reg.minor = sunserial_current_minor; - err = uart_register_driver(&sunzilog_reg); + err = sunserial_register_minors(&sunzilog_reg, uart_count); if (err) goto out_free_tables; - - sunzilog_reg.tty_driver->name_base = sunzilog_reg.minor - 64; - - sunserial_current_minor += uart_count; } err = of_register_driver(&zs_driver, &of_bus_type); @@ -1557,8 +1548,8 @@ out_unregister_driver: of_unregister_driver(&zs_driver); out_unregister_uart: - if (NUM_SUNZILOG) { - uart_unregister_driver(&sunzilog_reg); + if (num_sunzilog) { + sunserial_unregister_minors(&sunzilog_reg, num_sunzilog); sunzilog_reg.cons = NULL; } @@ -1590,8 +1581,8 @@ static void __exit sunzilog_exit(void) zilog_irq = -1; } - if (NUM_SUNZILOG) { - uart_unregister_driver(&sunzilog_reg); + if (sunzilog_reg.nr) { + sunserial_unregister_minors(&sunzilog_reg, sunzilog_reg.nr); sunzilog_free_tables(); } } -- cgit v1.2.3 From dc93441b3f5879a096dd117a81df541b0855ebbb Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sun, 2 Dec 2007 19:45:19 +0100 Subject: sdhci: describe quirks Add a comment for each quirk to describe what it does and why. Signed-off-by: Pierre Ossman --- drivers/mmc/host/sdhci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers') diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ff59d2e0475..17b4e391db3 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -26,12 +26,22 @@ static unsigned int debug_quirks = 0; +/* + * Different quirks to handle when the hardware deviates from a strict + * interpretation of the SDHCI specification. + */ + +/* Controller doesn't honor resets unless we touch the clock register */ #define SDHCI_QUIRK_CLOCK_BEFORE_RESET (1<<0) +/* Controller has bad caps bits, but really supports DMA */ #define SDHCI_QUIRK_FORCE_DMA (1<<1) /* Controller doesn't like some resets when there is no card inserted. */ #define SDHCI_QUIRK_NO_CARD_NO_RESET (1<<2) +/* Controller doesn't like clearing the power reg before a change */ #define SDHCI_QUIRK_SINGLE_POWER_WRITE (1<<3) +/* Controller has flaky internal state so reset it on each ios change */ #define SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS (1<<4) +/* Controller has an unusable DMA engine */ #define SDHCI_QUIRK_BROKEN_DMA (1<<5) static const struct pci_device_id pci_ids[] __devinitdata = { -- cgit v1.2.3 From c6573c94670882079174e2ea0da4abf1a0da51fe Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sun, 2 Dec 2007 19:46:49 +0100 Subject: sdhci: don't warn about sdhci 2.0 controllers We support 2.0 controllers, even though we don't use anything in the new feature set. Signed-off-by: Pierre Ossman --- drivers/mmc/host/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 17b4e391db3..758a7417eb5 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1294,7 +1294,7 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot) version = readw(host->ioaddr + SDHCI_HOST_VERSION); version = (version & SDHCI_SPEC_VER_MASK) >> SDHCI_SPEC_VER_SHIFT; - if (version != 0) { + if (version > 1) { printk(KERN_ERR "%s: Unknown controller version (%d). " "You may experience problems.\n", host->slot_descr, version); -- cgit v1.2.3 From c9fddbc4f844f5a16b5957c61fe2cfcb5c12f990 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sun, 2 Dec 2007 19:52:11 +0100 Subject: sdhci: use PIO when DMA can't satisfy the request Some controllers have been designed on the assumption that all transfers will be 32-bit aligned, both in start address and in size. This is not a guarantee the SDHCI specification provides and not one we can provide. Revert back to PIO for individual requests in order to work around the hardware bug. Signed-off-by: Pierre Ossman --- drivers/mmc/host/sdhci.c | 32 +++++++++++++++++++++++++++++--- drivers/mmc/host/sdhci.h | 3 ++- 2 files changed, 31 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 758a7417eb5..a5300f238d9 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -43,6 +43,10 @@ static unsigned int debug_quirks = 0; #define SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS (1<<4) /* Controller has an unusable DMA engine */ #define SDHCI_QUIRK_BROKEN_DMA (1<<5) +/* Controller can only DMA from 32-bit aligned addresses */ +#define SDHCI_QUIRK_32BIT_DMA_ADDR (1<<6) +/* Controller can only DMA chunk sizes that are a multiple of 32 bits */ +#define SDHCI_QUIRK_32BIT_DMA_SIZE (1<<7) static const struct pci_device_id pci_ids[] __devinitdata = { { @@ -429,7 +433,29 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) writeb(count, host->ioaddr + SDHCI_TIMEOUT_CONTROL); - if (host->flags & SDHCI_USE_DMA) { + if (host->flags & SDHCI_USE_DMA) + host->flags |= SDHCI_REQ_USE_DMA; + + if (unlikely((host->flags & SDHCI_REQ_USE_DMA) && + (host->chip->quirks & SDHCI_QUIRK_32BIT_DMA_SIZE) && + ((data->blksz * data->blocks) & 0x3))) { + DBG("Reverting to PIO because of transfer size (%d)\n", + data->blksz * data->blocks); + host->flags &= ~SDHCI_REQ_USE_DMA; + } + + /* + * The assumption here being that alignment is the same after + * translation to device address space. + */ + if (unlikely((host->flags & SDHCI_REQ_USE_DMA) && + (host->chip->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) && + (data->sg->offset & 0x3))) { + DBG("Reverting to PIO because of bad alignment\n"); + host->flags &= ~SDHCI_REQ_USE_DMA; + } + + if (host->flags & SDHCI_REQ_USE_DMA) { int count; count = pci_map_sg(host->chip->pdev, data->sg, data->sg_len, @@ -466,7 +492,7 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host, mode |= SDHCI_TRNS_MULTI; if (data->flags & MMC_DATA_READ) mode |= SDHCI_TRNS_READ; - if (host->flags & SDHCI_USE_DMA) + if (host->flags & SDHCI_REQ_USE_DMA) mode |= SDHCI_TRNS_DMA; writew(mode, host->ioaddr + SDHCI_TRANSFER_MODE); @@ -482,7 +508,7 @@ static void sdhci_finish_data(struct sdhci_host *host) data = host->data; host->data = NULL; - if (host->flags & SDHCI_USE_DMA) { + if (host->flags & SDHCI_REQ_USE_DMA) { pci_unmap_sg(host->chip->pdev, data->sg, data->sg_len, (data->flags & MMC_DATA_READ)?PCI_DMA_FROMDEVICE:PCI_DMA_TODEVICE); } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 05195ea900f..e4d77b038bf 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -171,7 +171,8 @@ struct sdhci_host { spinlock_t lock; /* Mutex */ int flags; /* Host attributes */ -#define SDHCI_USE_DMA (1<<0) +#define SDHCI_USE_DMA (1<<0) /* Host is DMA capable */ +#define SDHCI_REQ_USE_DMA (1<<1) /* Use DMA for this req. */ unsigned int max_clk; /* Max possible freq (MHz) */ unsigned int timeout_clk; /* Timeout freq (KHz) */ -- cgit v1.2.3 From 84c46a53fc4ea4ff36df783a20187b2f65dd21cc Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sun, 2 Dec 2007 19:58:16 +0100 Subject: sdhci: support JMicron JMB38x chips The JMicron JMB38x chip doesn't support transfers that aren't 32-bit aligned (both size and start address). It also doesn't like switching between PIO and DMA mode, so it needs to be reset after each request. Signed-off-by: Pierre Ossman --- drivers/mmc/host/sdhci.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index a5300f238d9..785bbdcf4a5 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -7,6 +7,10 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. + * + * Thanks to the following companies for their support: + * + * - JMicron (hardware and technical support) */ #include @@ -47,6 +51,8 @@ static unsigned int debug_quirks = 0; #define SDHCI_QUIRK_32BIT_DMA_ADDR (1<<6) /* Controller can only DMA chunk sizes that are a multiple of 32 bits */ #define SDHCI_QUIRK_32BIT_DMA_SIZE (1<<7) +/* Controller needs to be reset after each request to stay stable */ +#define SDHCI_QUIRK_RESET_AFTER_REQUEST (1<<8) static const struct pci_device_id pci_ids[] __devinitdata = { { @@ -111,6 +117,16 @@ static const struct pci_device_id pci_ids[] __devinitdata = { SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS, }, + { + .vendor = PCI_VENDOR_ID_JMICRON, + .device = PCI_DEVICE_ID_JMICRON_JMB38X_SD, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = SDHCI_QUIRK_32BIT_DMA_ADDR | + SDHCI_QUIRK_32BIT_DMA_SIZE | + SDHCI_QUIRK_RESET_AFTER_REQUEST, + }, + { /* Generic SD host controller */ PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00) }, @@ -922,7 +938,8 @@ static void sdhci_tasklet_finish(unsigned long param) */ if (mrq->cmd->error || (mrq->data && (mrq->data->error || - (mrq->data->stop && mrq->data->stop->error)))) { + (mrq->data->stop && mrq->data->stop->error))) || + (host->chip->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST)) { /* Some controllers need this kick or reset won't work here */ if (host->chip->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET) { -- cgit v1.2.3 From 1457edc72d187f452be1374c7d9281f1dfa16f32 Mon Sep 17 00:00:00 2001 From: Joachim Fenkes Date: Mon, 10 Dec 2007 12:20:57 +0100 Subject: IB/ehca: Return correct number of SGEs for SRQ Firmware would round up the number of SGEs to four, because the WQE structure holds four SGEs. For SRQ, only three are supported, so return a fixed value instead. Signed-off-by: Joachim Fenkes Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ehca/ehca_qp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c index dd126681fed..eff5fb55604 100644 --- a/drivers/infiniband/hw/ehca/ehca_qp.c +++ b/drivers/infiniband/hw/ehca/ehca_qp.c @@ -838,7 +838,7 @@ struct ib_srq *ehca_create_srq(struct ib_pd *pd, /* copy back return values */ srq_init_attr->attr.max_wr = qp_init_attr.cap.max_recv_wr; - srq_init_attr->attr.max_sge = qp_init_attr.cap.max_recv_sge; + srq_init_attr->attr.max_sge = 3; /* drive SRQ into RTR state */ mqpcb = ehca_alloc_fw_ctrlblock(GFP_KERNEL); @@ -1750,7 +1750,7 @@ int ehca_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr) } srq_attr->max_wr = qpcb->max_nr_outst_recv_wr - 1; - srq_attr->max_sge = qpcb->actual_nr_sges_in_rq_wqe; + srq_attr->max_sge = 3; srq_attr->srq_limit = EHCA_BMASK_GET( MQPCB_CURR_SRQ_LIMIT, qpcb->curr_srq_limit); -- cgit v1.2.3 From 4faf7757955239c1b259e7dab224d4638a99b456 Mon Sep 17 00:00:00 2001 From: Joachim Fenkes Date: Mon, 10 Dec 2007 18:59:10 +0100 Subject: IB/ehca: Serialize HCA-related hCalls if necessary Several pSeries firmware versions share a rare locking issue in the HCA-related hCalls. Check for a feature flag that indicates the issue being fixed and serialize all HCA hCalls if not. Signed-off-by: Joachim Fenkes Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ehca/ehca_main.c | 13 +++++++++++++ drivers/infiniband/hw/ehca/hcp_if.c | 28 +++++++++++----------------- drivers/infiniband/hw/ehca/hipz_hw.h | 1 + 3 files changed, 25 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c index 90d4334179b..c7bff3ee9ab 100644 --- a/drivers/infiniband/hw/ehca/ehca_main.c +++ b/drivers/infiniband/hw/ehca/ehca_main.c @@ -43,6 +43,7 @@ #ifdef CONFIG_PPC_64K_PAGES #include #endif + #include "ehca_classes.h" #include "ehca_iverbs.h" #include "ehca_mrmw.h" @@ -66,6 +67,7 @@ int ehca_poll_all_eqs = 1; int ehca_static_rate = -1; int ehca_scaling_code = 0; int ehca_mr_largepage = 1; +int ehca_lock_hcalls = -1; module_param_named(open_aqp1, ehca_open_aqp1, int, S_IRUGO); module_param_named(debug_level, ehca_debug_level, int, S_IRUGO); @@ -77,6 +79,7 @@ module_param_named(poll_all_eqs, ehca_poll_all_eqs, int, S_IRUGO); module_param_named(static_rate, ehca_static_rate, int, S_IRUGO); module_param_named(scaling_code, ehca_scaling_code, int, S_IRUGO); module_param_named(mr_largepage, ehca_mr_largepage, int, S_IRUGO); +module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO); MODULE_PARM_DESC(open_aqp1, "AQP1 on startup (0: no (default), 1: yes)"); @@ -102,6 +105,9 @@ MODULE_PARM_DESC(scaling_code, MODULE_PARM_DESC(mr_largepage, "use large page for MR (0: use PAGE_SIZE (default), " "1: use large page depending on MR size"); +MODULE_PARM_DESC(lock_hcalls, + "serialize all hCalls made by the driver " + "(default: autodetect)"); DEFINE_RWLOCK(ehca_qp_idr_lock); DEFINE_RWLOCK(ehca_cq_idr_lock); @@ -258,6 +264,7 @@ static struct cap_descr { { HCA_CAP_UD_LL_QP, "HCA_CAP_UD_LL_QP" }, { HCA_CAP_RESIZE_MR, "HCA_CAP_RESIZE_MR" }, { HCA_CAP_MINI_QP, "HCA_CAP_MINI_QP" }, + { HCA_CAP_H_ALLOC_RES_SYNC, "HCA_CAP_H_ALLOC_RES_SYNC" }, }; static int ehca_sense_attributes(struct ehca_shca *shca) @@ -333,6 +340,12 @@ static int ehca_sense_attributes(struct ehca_shca *shca) if (EHCA_BMASK_GET(hca_cap_descr[i].mask, shca->hca_cap)) ehca_gen_dbg(" %s", hca_cap_descr[i].descr); + /* Autodetect hCall locking -- the "H_ALLOC_RESOURCE synced" flag is + * a firmware property, so it's valid across all adapters + */ + if (ehca_lock_hcalls == -1) + ehca_lock_hcalls = !(shca->hca_cap & HCA_CAP_H_ALLOC_RES_SYNC); + /* translate supported MR page sizes; always support 4K */ shca->hca_cap_mr_pgsize = EHCA_PAGESIZE; if (ehca_mr_largepage) { /* support extra sizes only if enabled */ diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c index c16a21374bb..331b5e82ef7 100644 --- a/drivers/infiniband/hw/ehca/hcp_if.c +++ b/drivers/infiniband/hw/ehca/hcp_if.c @@ -89,6 +89,7 @@ #define HCALL9_REGS_FORMAT HCALL7_REGS_FORMAT " r11=%lx r12=%lx" static DEFINE_SPINLOCK(hcall_lock); +extern int ehca_lock_hcalls; static u32 get_longbusy_msecs(int longbusy_rc) { @@ -120,26 +121,21 @@ static long ehca_plpar_hcall_norets(unsigned long opcode, unsigned long arg7) { long ret; - int i, sleep_msecs, do_lock; - unsigned long flags; + int i, sleep_msecs; + unsigned long flags = 0; ehca_gen_dbg("opcode=%lx " HCALL7_REGS_FORMAT, opcode, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - /* lock H_FREE_RESOURCE(MR) against itself and H_ALLOC_RESOURCE(MR) */ - if ((opcode == H_FREE_RESOURCE) && (arg7 == 5)) { - arg7 = 0; /* better not upset firmware */ - do_lock = 1; - } - for (i = 0; i < 5; i++) { - if (do_lock) + /* serialize hCalls to work around firmware issue */ + if (ehca_lock_hcalls) spin_lock_irqsave(&hcall_lock, flags); ret = plpar_hcall_norets(opcode, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - if (do_lock) + if (ehca_lock_hcalls) spin_unlock_irqrestore(&hcall_lock, flags); if (H_IS_LONG_BUSY(ret)) { @@ -174,24 +170,22 @@ static long ehca_plpar_hcall9(unsigned long opcode, unsigned long arg9) { long ret; - int i, sleep_msecs, do_lock; + int i, sleep_msecs; unsigned long flags = 0; ehca_gen_dbg("INPUT -- opcode=%lx " HCALL9_REGS_FORMAT, opcode, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - /* lock H_ALLOC_RESOURCE(MR) against itself and H_FREE_RESOURCE(MR) */ - do_lock = ((opcode == H_ALLOC_RESOURCE) && (arg2 == 5)); - for (i = 0; i < 5; i++) { - if (do_lock) + /* serialize hCalls to work around firmware issue */ + if (ehca_lock_hcalls) spin_lock_irqsave(&hcall_lock, flags); ret = plpar_hcall9(opcode, outs, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - if (do_lock) + if (ehca_lock_hcalls) spin_unlock_irqrestore(&hcall_lock, flags); if (H_IS_LONG_BUSY(ret)) { @@ -821,7 +815,7 @@ u64 hipz_h_free_resource_mr(const struct ipz_adapter_handle adapter_handle, return ehca_plpar_hcall_norets(H_FREE_RESOURCE, adapter_handle.handle, /* r4 */ mr->ipz_mr_handle.handle, /* r5 */ - 0, 0, 0, 0, 5); + 0, 0, 0, 0, 0); } u64 hipz_h_reregister_pmr(const struct ipz_adapter_handle adapter_handle, diff --git a/drivers/infiniband/hw/ehca/hipz_hw.h b/drivers/infiniband/hw/ehca/hipz_hw.h index 485b8400359..bf996c7acc4 100644 --- a/drivers/infiniband/hw/ehca/hipz_hw.h +++ b/drivers/infiniband/hw/ehca/hipz_hw.h @@ -378,6 +378,7 @@ struct hipz_query_hca { #define HCA_CAP_UD_LL_QP EHCA_BMASK_IBM(16, 16) #define HCA_CAP_RESIZE_MR EHCA_BMASK_IBM(17, 17) #define HCA_CAP_MINI_QP EHCA_BMASK_IBM(18, 18) +#define HCA_CAP_H_ALLOC_RES_SYNC EHCA_BMASK_IBM(19, 19) /* query port response block */ struct hipz_query_port { -- cgit v1.2.3 From 69ae6fee4f95c0535e49e338ce0ed3b27fd485b5 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:31:57 +0100 Subject: ide-scsi: add ide_scsi_hex_dump() helper Cc: Andrew Morton Cc: Denis Cheng Cc: Randy Dunlap Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/scsi/ide-scsi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 7a835a35f21..9706de9d98d 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -242,6 +242,11 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign } } +static void ide_scsi_hex_dump(u8 *data, int len) +{ + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0); +} + static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_command) { idescsi_scsi_t *scsi = drive_to_idescsi(drive); @@ -272,8 +277,7 @@ static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_co pc->scsi_cmd = ((idescsi_pc_t *) failed_command->special)->scsi_cmd; if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { printk ("ide-scsi: %s: queue cmd = ", drive->name); - print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, pc->c, - 6, 0); + ide_scsi_hex_dump(pc->c, 6); } rq->rq_disk = scsi->disk; return ide_do_drive_cmd(drive, rq, ide_preempt); @@ -328,8 +332,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs) idescsi_pc_t *opc = (idescsi_pc_t *) rq->buffer; if (log) { printk ("ide-scsi: %s: wrap up check %lu, rst = ", drive->name, opc->scsi_cmd->serial_number); - print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, - pc->buffer, 16, 0); + ide_scsi_hex_dump(pc->buffer, 16); } memcpy((void *) opc->scsi_cmd->sense_buffer, pc->buffer, SCSI_SENSE_BUFFERSIZE); kfree(pc->buffer); @@ -808,12 +811,10 @@ static int idescsi_queue (struct scsi_cmnd *cmd, if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number); - print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, - cmd->cmnd, cmd->cmd_len, 0); + ide_scsi_hex_dump(cmd->cmnd, cmd->cmd_len); if (memcmp(pc->c, cmd->cmnd, cmd->cmd_len)) { printk ("ide-scsi: %s: que %lu, tsl = ", drive->name, cmd->serial_number); - print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, - pc->c, 12, 0); + ide_scsi_hex_dump(pc->c, 12); } } -- cgit v1.2.3 From ad0e74d3851e440e0882424577bc984c89019f52 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:31:57 +0100 Subject: ide: add missing checks for control register existence Add missing checks for control register existence (some legacy m68k specific IDE controllers don't have it). Also use drive->ctl while at it. Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-io.c | 3 ++- drivers/ide/ide-probe.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index db22d1ff4e5..bef781fec50 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -970,7 +970,8 @@ static void ide_check_pm_state(ide_drive_t *drive, struct request *rq) if (rc) printk(KERN_WARNING "%s: bus not ready on wakeup\n", drive->name); SELECT_DRIVE(drive); - HWIF(drive)->OUTB(8, HWIF(drive)->io_ports[IDE_CONTROL_OFFSET]); + if (IDE_CONTROL_REG) + HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG); rc = ide_wait_not_busy(HWIF(drive), 100000); if (rc) printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name); diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index ee848c70599..bd0a6004a13 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -667,7 +667,8 @@ static int wait_hwif_ready(ide_hwif_t *hwif) /* Ignore disks that we will not probe for later. */ if (!drive->noprobe || drive->present) { SELECT_DRIVE(drive); - hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); + if (IDE_CONTROL_REG) + hwif->OUTB(drive->ctl, IDE_CONTROL_REG); mdelay(2); rc = ide_wait_not_busy(hwif, 35000); if (rc) -- cgit v1.2.3 From 46255d4083ca6c6e3c40cb4d2f3198c77bca7e24 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:31:57 +0100 Subject: ide: deprecate CONFIG_BLK_DEV_OFFBOARD Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/Kconfig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 45b22282f14..fb06555708a 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -390,7 +390,7 @@ config IDEPCI_PCIBUS_ORDER # TODO: split it on per host driver config options (or module parameters) config BLK_DEV_OFFBOARD - bool "Boot off-board chipsets first support" + bool "Boot off-board chipsets first support (DEPRECATED)" depends on BLK_DEV_IDEPCI && (BLK_DEV_AEC62XX || BLK_DEV_GENERIC || BLK_DEV_HPT34X || BLK_DEV_HPT366 || BLK_DEV_PDC202XX_NEW || BLK_DEV_PDC202XX_OLD || BLK_DEV_TC86C001) help Normally, IDE controllers built into the motherboard (on-board @@ -410,6 +410,10 @@ config BLK_DEV_OFFBOARD Note that, if you do this, the order of the hd* devices will be rearranged which may require modification of fstab and other files. + Please also note that this method of assuring stable naming of + IDE devices is unreliable and use other means for achieving it + (i.e. udev). + If in doubt, say N. config BLK_DEV_GENERIC -- cgit v1.2.3 From 125a8191dcbc927441263a332826989cc2925681 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:31:57 +0100 Subject: ide: fix ide_scan_pcibus() error message Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/setup-pci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 25fd0905322..708e01d8a9d 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c @@ -794,9 +794,10 @@ void __init ide_scan_pcibus (int scan_direction) list_for_each_safe(l, n, &ide_pci_drivers) { list_del(l); d = list_entry(l, struct pci_driver, node); - if (__pci_register_driver(d, d->driver.owner, d->driver.mod_name)) - printk(KERN_ERR "%s: failed to register driver for %s\n", - __FUNCTION__, d->driver.mod_name); + if (__pci_register_driver(d, d->driver.owner, + d->driver.mod_name)) + printk(KERN_ERR "%s: failed to register %s driver\n", + __FUNCTION__, d->driver.mod_name); } } #endif -- cgit v1.2.3 From 1b7d3477a7b0d52406d68b01bc8931f43112677f Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:31:57 +0100 Subject: ide: coding style fixes for drivers/ide/setup-pci.c * remove trailing whitespaces * 'if()' -> 'if ()' * remove extra new-line before EXPORT_SYMBOL_GPL() * add extra new-line after 'id' definition * respect 80-columns limit There should be no functionality changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/setup-pci.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 708e01d8a9d..d2cd5a3d38f 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c @@ -704,7 +704,7 @@ EXPORT_SYMBOL_GPL(ide_setup_pci_devices); /* * Module interfaces */ - + static int pre_init = 1; /* Before first ordered IDE scan */ static LIST_HEAD(ide_pci_drivers); @@ -714,7 +714,7 @@ static LIST_HEAD(ide_pci_drivers); * @module: owner module of the driver * * Registers a driver with the IDE layer. The IDE layer arranges that - * boot time setup is done in the expected device order and then + * boot time setup is done in the expected device order and then * hands the controllers off to the core PCI code to do the rest of * the work. * @@ -724,13 +724,12 @@ static LIST_HEAD(ide_pci_drivers); int __ide_pci_register_driver(struct pci_driver *driver, struct module *module, const char *mod_name) { - if(!pre_init) + if (!pre_init) return __pci_register_driver(driver, module, mod_name); driver->driver.owner = module; list_add_tail(&driver->node, &ide_pci_drivers); return 0; } - EXPORT_SYMBOL_GPL(__ide_pci_register_driver); /** @@ -741,17 +740,18 @@ EXPORT_SYMBOL_GPL(__ide_pci_register_driver); * This is only used during boot up to get the ordering correct. After * boot up the pci layer takes over the job. */ - + static int __init ide_scan_pcidev(struct pci_dev *dev) { struct list_head *l; struct pci_driver *d; - + list_for_each(l, &ide_pci_drivers) { d = list_entry(l, struct pci_driver, node); if (d->id_table) { - const struct pci_device_id *id = pci_match_id(d->id_table, - dev); + const struct pci_device_id *id = + pci_match_id(d->id_table, dev); + if (id != NULL && d->probe(dev, id) >= 0) { dev->driver = d; pci_dev_get(dev); @@ -779,13 +779,13 @@ void __init ide_scan_pcibus (int scan_direction) pre_init = 0; if (!scan_direction) - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) + while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev))) ide_scan_pcidev(dev); else - while ((dev = pci_get_device_reverse(PCI_ANY_ID, PCI_ANY_ID, dev)) - != NULL) + while ((dev = pci_get_device_reverse(PCI_ANY_ID, PCI_ANY_ID, + dev))) ide_scan_pcidev(dev); - + /* * Hand the drivers over to the PCI layer now we * are post init. -- cgit v1.2.3 From e11b9035a47da66fcd4bafd3a5f6b14f51ca667e Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:31:58 +0100 Subject: ide: add /sys/bus/ide/devices/*/{model,firmware,serial} sysfs entries Cc: Dan Kegel Cc: Kay Sievers Cc: Xavier Bestel Cc: Andrey Borzenkov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'drivers') diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 674a65c1a13..85740ae5d68 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1670,10 +1670,34 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, return sprintf(buf, "ide:m-%s\n", media_string(drive)); } +static ssize_t model_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + ide_drive_t *drive = to_ide_device(dev); + return sprintf(buf, "%s\n", drive->id->model); +} + +static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + ide_drive_t *drive = to_ide_device(dev); + return sprintf(buf, "%s\n", drive->id->fw_rev); +} + +static ssize_t serial_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + ide_drive_t *drive = to_ide_device(dev); + return sprintf(buf, "%s\n", drive->id->serial_no); +} + static struct device_attribute ide_dev_attrs[] = { __ATTR_RO(media), __ATTR_RO(drivename), __ATTR_RO(modalias), + __ATTR_RO(model), + __ATTR_RO(firmware), + __ATTR(serial, 0400, serial_show, NULL), __ATTR_NULL }; -- cgit v1.2.3 From 3ab7efe8e2cbcca2d401b43cfcc2fa9a7dac2299 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:31:58 +0100 Subject: ide: DMA reporting and validity checking fixes (take 3) * ide_xfer_verbose() fixups: - beautify returned mode names - fix PIO5 reporting - make it return 'const char *' * Change printk() level from KERN_DEBUG to KERN_INFO in ide_find_dma_mode(). * Add ide_id_dma_bug() helper based on ide_dma_verbose() to check for invalid DMA info in identify block. * Use ide_id_dma_bug() in ide_tune_dma() and ide_driveid_update(). As a result DMA won't be tuned or will be disabled after tuning if device reports inconsistent info about enabled DMA mode (ide_dma_verbose() does the same checks while the IDE device is probed by ide-{cd,disk} device driver). * Remove no longer needed ide_dma_verbose(). This patch should fix the following problem with out-of-sync IDE messages reported by Nick Warne: hdd: ATAPI 48X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache<7>hdd: skipping word 93 validity check , UDMA(66) and later debugged by Mark Lord to be caused by: ide_dma_verbose() printk( ... "2048kB Cache"); eighty_ninty_three() printk(KERN_DEBUG "%s: skipping word 93 validity check\n"); ide_dma_verbose() printk(", UDMA(66)" Please note that as a result ide-{cd,disk} device drivers won't report the DMA speed used but this is intended since now DMA mode being used is always reported by IDE core code. v2: * fixes suggested by Randy: - use KERN_CONT for printk()-s in ide-{cd,disk}.c - don't remove argument name from ide_xfer_verbose() declaration v3: * Remove incorrect check for (id->field_valid & 1) from ide_id_dma_bug() (spotted by Sergei). * "XFER SLOW" -> "PIO SLOW" in ide_xfer_verbose() (suggested by Sergei). * Fix ide_find_dma_mode() to report the correct mode ('mode' after being limited by 'req_mode'). Cc: Sergei Shtylyov Cc: Nick Warne Cc: Mark Lord Cc: Randy Dunlap Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-cd.c | 7 +----- drivers/ide/ide-disk.c | 7 ++---- drivers/ide/ide-dma.c | 60 +++++++++++++------------------------------------- drivers/ide/ide-iops.c | 3 +++ drivers/ide/ide-lib.c | 55 +++++++++++++++++++++++---------------------- 5 files changed, 50 insertions(+), 82 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 57a5f63d6ae..db9abd83d95 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -3049,12 +3049,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) else printk(" drive"); - printk(", %dkB Cache", be16_to_cpu(cap.buffer_size)); - - if (drive->using_dma) - ide_dma_verbose(drive); - - printk("\n"); + printk(KERN_CONT ", %dkB Cache\n", be16_to_cpu(cap.buffer_size)); return nslots; } diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 00123d99527..b77c849cdd2 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -961,11 +961,8 @@ static void idedisk_setup (ide_drive_t *drive) if (id->buf_size) printk (" w/%dKiB Cache", id->buf_size/2); - printk(", CHS=%d/%d/%d", - drive->bios_cyl, drive->bios_head, drive->bios_sect); - if (drive->using_dma) - ide_dma_verbose(drive); - printk("\n"); + printk(KERN_CONT ", CHS=%d/%d/%d\n", + drive->bios_cyl, drive->bios_head, drive->bios_sect); /* write cache enabled? */ if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5))) diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 0d795a1678c..6879aaae544 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -753,10 +753,12 @@ u8 ide_find_dma_mode(ide_drive_t *drive, u8 req_mode) mode = XFER_MW_DMA_1; } - printk(KERN_DEBUG "%s: %s mode selected\n", drive->name, + mode = min(mode, req_mode); + + printk(KERN_INFO "%s: %s mode selected\n", drive->name, mode ? ide_xfer_verbose(mode) : "no DMA"); - return min(mode, req_mode); + return mode; } EXPORT_SYMBOL_GPL(ide_find_dma_mode); @@ -772,6 +774,9 @@ static int ide_tune_dma(ide_drive_t *drive) if (__ide_dma_bad_drive(drive)) return 0; + if (ide_id_dma_bug(drive)) + return 0; + if (drive->hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA) return config_drive_for_dma(drive); @@ -806,58 +811,23 @@ static int ide_dma_check(ide_drive_t *drive) return vdma ? 0 : -1; } -void ide_dma_verbose(ide_drive_t *drive) +int ide_id_dma_bug(ide_drive_t *drive) { - struct hd_driveid *id = drive->id; - ide_hwif_t *hwif = HWIF(drive); + struct hd_driveid *id = drive->id; if (id->field_valid & 4) { if ((id->dma_ultra >> 8) && (id->dma_mword >> 8)) - goto bug_dma_off; - if (id->dma_ultra & ((id->dma_ultra >> 8) & hwif->ultra_mask)) { - if (((id->dma_ultra >> 11) & 0x1F) && - eighty_ninty_three(drive)) { - if ((id->dma_ultra >> 15) & 1) { - printk(", UDMA(mode 7)"); - } else if ((id->dma_ultra >> 14) & 1) { - printk(", UDMA(133)"); - } else if ((id->dma_ultra >> 13) & 1) { - printk(", UDMA(100)"); - } else if ((id->dma_ultra >> 12) & 1) { - printk(", UDMA(66)"); - } else if ((id->dma_ultra >> 11) & 1) { - printk(", UDMA(44)"); - } else - goto mode_two; - } else { - mode_two: - if ((id->dma_ultra >> 10) & 1) { - printk(", UDMA(33)"); - } else if ((id->dma_ultra >> 9) & 1) { - printk(", UDMA(25)"); - } else if ((id->dma_ultra >> 8) & 1) { - printk(", UDMA(16)"); - } - } - } else { - printk(", (U)DMA"); /* Can be BIOS-enabled! */ - } + goto err_out; } else if (id->field_valid & 2) { if ((id->dma_mword >> 8) && (id->dma_1word >> 8)) - goto bug_dma_off; - printk(", DMA"); - } else if (id->field_valid & 1) { - goto bug_dma_off; + goto err_out; } - return; -bug_dma_off: - printk(", BUG DMA OFF"); - hwif->dma_off_quietly(drive); - return; + return 0; +err_out: + printk(KERN_ERR "%s: bad DMA info in identify block\n", drive->name); + return 1; } -EXPORT_SYMBOL(ide_dma_verbose); - int ide_set_dma(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 5c3256180ae..cef405ddaf0 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -748,6 +748,9 @@ int ide_driveid_update(ide_drive_t *drive) drive->id->dma_1word = id->dma_1word; /* anything more ? */ kfree(id); + + if (drive->using_dma && ide_id_dma_bug(drive)) + ide_dma_off(drive); } return 1; diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 1609b8604f5..062d3bcb247 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -29,41 +29,44 @@ * Add common non I/O op stuff here. Make sure it has proper * kernel-doc function headers or your patch will be rejected */ - + +static const char *udma_str[] = + { "UDMA/16", "UDMA/25", "UDMA/33", "UDMA/44", + "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" }; +static const char *mwdma_str[] = + { "MWDMA0", "MWDMA1", "MWDMA2" }; +static const char *swdma_str[] = + { "SWDMA0", "SWDMA1", "SWDMA2" }; +static const char *pio_str[] = + { "PIO0", "PIO1", "PIO2", "PIO3", "PIO4", "PIO5" }; /** * ide_xfer_verbose - return IDE mode names - * @xfer_rate: rate to name + * @mode: transfer mode * * Returns a constant string giving the name of the mode * requested. */ -char *ide_xfer_verbose (u8 xfer_rate) +const char *ide_xfer_verbose(u8 mode) { - switch(xfer_rate) { - case XFER_UDMA_7: return("UDMA 7"); - case XFER_UDMA_6: return("UDMA 6"); - case XFER_UDMA_5: return("UDMA 5"); - case XFER_UDMA_4: return("UDMA 4"); - case XFER_UDMA_3: return("UDMA 3"); - case XFER_UDMA_2: return("UDMA 2"); - case XFER_UDMA_1: return("UDMA 1"); - case XFER_UDMA_0: return("UDMA 0"); - case XFER_MW_DMA_2: return("MW DMA 2"); - case XFER_MW_DMA_1: return("MW DMA 1"); - case XFER_MW_DMA_0: return("MW DMA 0"); - case XFER_SW_DMA_2: return("SW DMA 2"); - case XFER_SW_DMA_1: return("SW DMA 1"); - case XFER_SW_DMA_0: return("SW DMA 0"); - case XFER_PIO_4: return("PIO 4"); - case XFER_PIO_3: return("PIO 3"); - case XFER_PIO_2: return("PIO 2"); - case XFER_PIO_1: return("PIO 1"); - case XFER_PIO_0: return("PIO 0"); - case XFER_PIO_SLOW: return("PIO SLOW"); - default: return("XFER ERROR"); - } + const char *s; + u8 i = mode & 0xf; + + if (mode >= XFER_UDMA_0 && mode <= XFER_UDMA_7) + s = udma_str[i]; + else if (mode >= XFER_MW_DMA_0 && mode <= XFER_MW_DMA_2) + s = mwdma_str[i]; + else if (mode >= XFER_SW_DMA_0 && mode <= XFER_SW_DMA_2) + s = swdma_str[i]; + else if (mode >= XFER_PIO_0 && mode <= XFER_PIO_5) + s = pio_str[i & 0x7]; + else if (mode == XFER_PIO_SLOW) + s = "PIO SLOW"; + else + s = "XFER ERROR"; + + return s; } EXPORT_SYMBOL(ide_xfer_verbose); -- cgit v1.2.3 From c86ae7df90a26708e9e54e3a362046873d874e6c Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:31:58 +0100 Subject: ide-cd: remove dead post_transform_command() post_transform_command() call in cdrom_newpc_intr() has no effect because it is done after the request has already been fully completed (rq->bio and rq->data are always NULL). It was verified to be true regardless whether INQUIRY command is using DMA or PIO to transfer data (by using modified Tejun Heo's test-shortsg.c utility and adding a few printk()-s to ide-cd). This was uncovered thanks to the "blk_end_request: full I/O completion handler (take 3)" patch series from Kiyoshi Ueda. Cc: jens.axboe@oracle.com Cc: bharrosh@panasas.com Cc: Kiyoshi Ueda Cc: Tejun Heo Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-cd.c | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index db9abd83d95..92ac658dac3 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -1650,31 +1650,6 @@ static int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason) return 1; } -static void post_transform_command(struct request *req) -{ - u8 *c = req->cmd; - char *ibuf; - - if (!blk_pc_request(req)) - return; - - if (req->bio) - ibuf = bio_data(req->bio); - else - ibuf = req->data; - - if (!ibuf) - return; - - /* - * set ansi-revision and response data as atapi - */ - if (c[0] == GPCMD_INQUIRY) { - ibuf[2] |= 2; - ibuf[3] = (ibuf[3] & 0xf0) | 2; - } -} - typedef void (xfer_func_t)(ide_drive_t *, void *, u32); /* @@ -1810,9 +1785,6 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) return ide_started; end_request: - if (!rq->data_len) - post_transform_command(rq); - spin_lock_irqsave(&ide_lock, flags); blkdev_dequeue_request(rq); end_that_request_last(rq, 1); -- cgit v1.2.3 From eadb6ecf761166aa55ad44f05b7a29b10ddaba34 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:31:58 +0100 Subject: pdc202xx_new: fix Promise TX4 support In case of Promise TX4 the first PCI device is located at slot 1 and the second one is at slot 2 so the offset used by pci_get_slot() should be "+1" and not "+2". Thanks goes out to Markus Dietz for bugreport and testing this patch. Cc: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/pdc202xx_new.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index 4234efeba60..2b4f44e45a1 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c @@ -482,8 +482,9 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) { struct pci_dev *dev2; - dev2 = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn) + 2, + dev2 = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn) + 1, PCI_FUNC(dev->devfn))); + if (dev2 && dev2->vendor == dev->vendor && dev2->device == dev->device) { -- cgit v1.2.3 From 809b53c4ef7188dc284498ef6e4ec2d4d587a275 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Wed, 12 Dec 2007 23:31:58 +0100 Subject: hpt366: fix HPT37x PIO mode timings (take 2) After looking into the HPT370 manual (now that I have it) and re-checking all the timing tables, here's what I have discovered: - at 33 MHz clock, PIO mode 0 timings turned to be overclocked, and all other PIO modes underclocked; - at 50 MHz clock, PIO modes 0 to 2 turned to be overclocked; - at 66 MHz clock, PIO mode 0 was overclocked too. Finally, the taskfile timing (matching PIO mode 0) turned to be overclocked at all clock frequencies (and in all manuals)... The new timings have been tested on HPT370 chip (at 33 MHz PCI clock) and on HPT371N chip (at both 50 and 66 MHz DPLL clock). Signed-off-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/hpt366.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 5682895d36d..9fce25bdec8 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/pci/hpt366.c Version 1.21 Oct 23, 2007 + * linux/drivers/ide/pci/hpt366.c Version 1.22 Dec 4, 2007 * * Copyright (C) 1999-2003 Andre Hedrick * Portions Copyright (C) 2001 Sun Microsystems, Inc. @@ -310,6 +310,8 @@ static u32 twenty_five_base_hpt36x[] = { /* XFER_PIO_0 */ 0xc0d08585 }; +#if 0 +/* These are the timing tables from the HighPoint open source drivers... */ static u32 thirty_three_base_hpt37x[] = { /* XFER_UDMA_6 */ 0x12446231, /* 0x12646231 ?? */ /* XFER_UDMA_5 */ 0x12446231, @@ -369,6 +371,73 @@ static u32 sixty_six_base_hpt37x[] = { /* XFER_PIO_1 */ 0x0d029d26, /* XFER_PIO_0 */ 0x0d029d5e }; +#else +/* + * The following are the new timing tables with PIO mode data/taskfile transfer + * overclocking fixed... + */ + +/* This table is taken from the HPT370 data manual rev. 1.02 */ +static u32 thirty_three_base_hpt37x[] = { + /* XFER_UDMA_6 */ 0x16455031, /* 0x16655031 ?? */ + /* XFER_UDMA_5 */ 0x16455031, + /* XFER_UDMA_4 */ 0x16455031, + /* XFER_UDMA_3 */ 0x166d5031, + /* XFER_UDMA_2 */ 0x16495031, + /* XFER_UDMA_1 */ 0x164d5033, + /* XFER_UDMA_0 */ 0x16515097, + + /* XFER_MW_DMA_2 */ 0x26515031, + /* XFER_MW_DMA_1 */ 0x26515033, + /* XFER_MW_DMA_0 */ 0x26515097, + + /* XFER_PIO_4 */ 0x06515021, + /* XFER_PIO_3 */ 0x06515022, + /* XFER_PIO_2 */ 0x06515033, + /* XFER_PIO_1 */ 0x06915065, + /* XFER_PIO_0 */ 0x06d1508a +}; + +static u32 fifty_base_hpt37x[] = { + /* XFER_UDMA_6 */ 0x1a861842, + /* XFER_UDMA_5 */ 0x1a861842, + /* XFER_UDMA_4 */ 0x1aae1842, + /* XFER_UDMA_3 */ 0x1a8e1842, + /* XFER_UDMA_2 */ 0x1a0e1842, + /* XFER_UDMA_1 */ 0x1a161854, + /* XFER_UDMA_0 */ 0x1a1a18ea, + + /* XFER_MW_DMA_2 */ 0x2a821842, + /* XFER_MW_DMA_1 */ 0x2a821854, + /* XFER_MW_DMA_0 */ 0x2a8218ea, + + /* XFER_PIO_4 */ 0x0a821842, + /* XFER_PIO_3 */ 0x0a821843, + /* XFER_PIO_2 */ 0x0a821855, + /* XFER_PIO_1 */ 0x0ac218a8, + /* XFER_PIO_0 */ 0x0b02190c +}; + +static u32 sixty_six_base_hpt37x[] = { + /* XFER_UDMA_6 */ 0x1c86fe62, + /* XFER_UDMA_5 */ 0x1caefe62, /* 0x1c8afe62 */ + /* XFER_UDMA_4 */ 0x1c8afe62, + /* XFER_UDMA_3 */ 0x1c8efe62, + /* XFER_UDMA_2 */ 0x1c92fe62, + /* XFER_UDMA_1 */ 0x1c9afe62, + /* XFER_UDMA_0 */ 0x1c82fe62, + + /* XFER_MW_DMA_2 */ 0x2c82fe62, + /* XFER_MW_DMA_1 */ 0x2c82fe66, + /* XFER_MW_DMA_0 */ 0x2c82ff2e, + + /* XFER_PIO_4 */ 0x0c82fe62, + /* XFER_PIO_3 */ 0x0c82fe84, + /* XFER_PIO_2 */ 0x0c82fea6, + /* XFER_PIO_1 */ 0x0d02ff26, + /* XFER_PIO_0 */ 0x0d42ff7f +}; +#endif #define HPT366_DEBUG_DRIVE_INFO 0 #define HPT371_ALLOW_ATA133_6 1 -- cgit v1.2.3 From 3f3e6e21845259854d862bfa3c39f6a84356fc3d Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:32:00 +0100 Subject: ide: remove dead code from __ide_dma_test_irq() Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-dma.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 6879aaae544..4703837bf1f 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -611,12 +611,6 @@ static int __ide_dma_test_irq(ide_drive_t *drive) ide_hwif_t *hwif = HWIF(drive); u8 dma_stat = hwif->INB(hwif->dma_status); -#if 0 /* do not set unless you know what you are doing */ - if (dma_stat & 4) { - u8 stat = hwif->INB(IDE_STATUS_REG); - hwif->OUTB(hwif->dma_status, dma_stat & 0xE4); - } -#endif /* return 1 if INTR asserted */ if ((dma_stat & 4) == 4) return 1; -- cgit v1.2.3 From fedda1e13125153d502e84856a2640acdb4c38f0 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:32:00 +0100 Subject: ide: remove stale changelog from ide-disk.c Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-disk.c | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index b77c849cdd2..b1781908e1f 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -13,32 +13,6 @@ * and Andre Hedrick * * This is the IDE/ATA disk driver, as evolved from hd.c and ide.c. - * - * Version 1.00 move disk only code from ide.c to ide-disk.c - * support optional byte-swapping of all data - * Version 1.01 fix previous byte-swapping code - * Version 1.02 remove ", LBA" from drive identification msgs - * Version 1.03 fix display of id->buf_size for big-endian - * Version 1.04 add /proc configurable settings and S.M.A.R.T support - * Version 1.05 add capacity support for ATA3 >= 8GB - * Version 1.06 get boot-up messages to show full cyl count - * Version 1.07 disable door-locking if it fails - * Version 1.08 fixed CHS/LBA translations for ATA4 > 8GB, - * process of adding new ATA4 compliance. - * fixed problems in allowing fdisk to see - * the entire disk. - * Version 1.09 added increment of rq->sector in ide_multwrite - * added UDMA 3/4 reporting - * Version 1.10 request queue changes, Ultra DMA 100 - * Version 1.11 added 48-bit lba - * Version 1.12 adding taskfile io access method - * Version 1.13 added standby and flush-cache for notifier - * Version 1.14 added acoustic-wcache - * Version 1.15 convert all calls to ide_raw_taskfile - * since args will return register content. - * Version 1.16 added suspend-resume-checkpower - * Version 1.17 do flush on standby, do flush on ATA < ATA6 - * fix wcache setup. */ #define IDEDISK_VERSION "1.18" -- cgit v1.2.3 From bbe4d6d86565bfd9edbc3f19bc23f816af66240d Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:32:00 +0100 Subject: ide: remove stale changelog from ide-probe.c Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-probe.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index bd0a6004a13..2994523be7b 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -13,22 +13,8 @@ * * This is the IDE probe module, as evolved from hd.c and ide.c. * - * Version 1.00 move drive probing code from ide.c to ide-probe.c - * Version 1.01 fix compilation problem for m68k - * Version 1.02 increase WAIT_PIDENTIFY to avoid CD-ROM locking at boot - * by Andrea Arcangeli - * Version 1.03 fix for (hwif->chipset == ide_4drives) - * Version 1.04 fixed buggy treatments of known flash memory cards - * - * Version 1.05 fix for (hwif->chipset == ide_pdc4030) - * added ide6/7/8/9 - * allowed for secondary flash card to be detectable - * with new flag : drive->ata_flash : 1; - * Version 1.06 stream line request queue and prep for cascade project. - * Version 1.07 max_sect <= 255; slower disks would get behind and - * then fall over when they get to 256. Paul G. - * Version 1.10 Update set for new IDE. drive->id is now always - * valid after probe time even with noprobe + * -- increase WAIT_PIDENTIFY to avoid CD-ROM locking at boot + * by Andrea Arcangeli */ #include -- cgit v1.2.3 From 644a9d764b4747af057b3db73ccba28a168b1f4f Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 12 Dec 2007 23:32:00 +0100 Subject: ide: fix ->io_32bit race in set_io_32bit() set_io_32bit() (ide_procset_t function) can race against running PIO transfers. Fix it by using ide_spin_wait_hwgroup(). Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 85740ae5d68..54943da6e4e 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -800,11 +800,17 @@ int set_io_32bit(ide_drive_t *drive, int arg) if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1)) return -EINVAL; + if (ide_spin_wait_hwgroup(drive)) + return -EBUSY; + drive->io_32bit = arg; #ifdef CONFIG_BLK_DEV_DTC2278 if (HWIF(drive)->chipset == ide_dtc2278) HWIF(drive)->drives[!drive->select.b.unit].io_32bit = arg; #endif /* CONFIG_BLK_DEV_DTC2278 */ + + spin_unlock_irq(&ide_lock); + return 0; } -- cgit v1.2.3 From 3f84307a10b4d9039c5c8f718bcdd0928c9994c1 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 12 Dec 2007 16:44:54 -0300 Subject: V4L/DVB (6803): buf-core.c locking fixes After commit 19fb1457990b6b7e15586ec7331541a184233acc the callers in videobuf-core.c that already hold the lock must call __videobuf_read_start() instead of videobuf_read_start(). Signed-off-by: Adrian Bunk Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/videobuf-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index 81f77d2b4bd..c8a5cb57963 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c @@ -909,7 +909,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, if (q->streaming) goto done; if (!q->reading) { - retval = videobuf_read_start(q); + retval = __videobuf_read_start(q); if (retval < 0) goto done; } @@ -982,7 +982,7 @@ unsigned int videobuf_poll_stream(struct file *file, struct videobuf_buffer, stream); } else { if (!q->reading) - videobuf_read_start(q); + __videobuf_read_start(q); if (!q->reading) { rc = POLLERR; } else if (NULL == q->read_buf) { -- cgit v1.2.3 From 3d758a4a48682639d3996968499913ecb1552e06 Mon Sep 17 00:00:00 2001 From: Joachim Fenkes Date: Thu, 13 Dec 2007 13:35:57 +0100 Subject: IB/ehca: Fix lock flag variable location, bump version number Signed-off-by: Joachim Fenkes Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ehca/ehca_classes.h | 1 + drivers/infiniband/hw/ehca/ehca_main.c | 2 +- drivers/infiniband/hw/ehca/hcp_if.c | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/hw/ehca/ehca_classes.h b/drivers/infiniband/hw/ehca/ehca_classes.h index 87f12d4312a..74d2b72a11d 100644 --- a/drivers/infiniband/hw/ehca/ehca_classes.h +++ b/drivers/infiniband/hw/ehca/ehca_classes.h @@ -322,6 +322,7 @@ extern int ehca_static_rate; extern int ehca_port_act_time; extern int ehca_use_hp_mr; extern int ehca_scaling_code; +extern int ehca_lock_hcalls; struct ipzu_queue_resp { u32 qe_size; /* queue entry size */ diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c index c7bff3ee9ab..6a56d86a295 100644 --- a/drivers/infiniband/hw/ehca/ehca_main.c +++ b/drivers/infiniband/hw/ehca/ehca_main.c @@ -50,7 +50,7 @@ #include "ehca_tools.h" #include "hcp_if.h" -#define HCAD_VERSION "0024" +#define HCAD_VERSION "0025" MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Christoph Raisch "); diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c index 331b5e82ef7..7029aa65375 100644 --- a/drivers/infiniband/hw/ehca/hcp_if.c +++ b/drivers/infiniband/hw/ehca/hcp_if.c @@ -89,7 +89,6 @@ #define HCALL9_REGS_FORMAT HCALL7_REGS_FORMAT " r11=%lx r12=%lx" static DEFINE_SPINLOCK(hcall_lock); -extern int ehca_lock_hcalls; static u32 get_longbusy_msecs(int longbusy_rc) { -- cgit v1.2.3 From b3aa2269bd06681fbd0c47d2007381c35258ce0c Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Sun, 9 Dec 2007 21:13:38 -0300 Subject: V4L/DVB (6798): saa7134: enable LNA in analog mode for Hauppauge WinTV HVR-1110 Thanks to Hermann Pitton for noticing that this was missing. Signed-off-by: Michael Krufky Cc: Hermann Pitton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7134/saa7134-cards.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index c6eb1e37a46..98c1b084a71 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -3221,6 +3221,7 @@ struct saa7134_board saa7134_boards[] = { .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, + .tuner_config = 1, .mpeg = SAA7134_MPEG_DVB, .inputs = {{ .name = name_tv, -- cgit v1.2.3 From 1c1a8b9cbec2b6a75b8fa0abf6ccfd948229998a Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 12 Dec 2007 15:40:32 -0300 Subject: V4L/DVB (6814): Makefile: always enter video/ Since not all code under drivers/media/video/ depends on CONFIG_VIDEO_DEV we cannot only enter it depending on CONFIG_VIDEO_DEV. Signed-off-by: Adrian Bunk Signed-off-by: Mauro Carvalho Chehab --- drivers/media/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/Makefile b/drivers/media/Makefile index 8fa19939c2b..8cf91353b56 100644 --- a/drivers/media/Makefile +++ b/drivers/media/Makefile @@ -3,6 +3,6 @@ # obj-y := common/ -obj-$(CONFIG_VIDEO_DEV) += video/ +obj-y += video/ obj-$(CONFIG_VIDEO_DEV) += radio/ obj-$(CONFIG_DVB_CORE) += dvb/ -- cgit v1.2.3 From 4b5ae10c815941fab8e0e3b3801b4cb60ee2383a Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 13 Dec 2007 02:30:26 -0300 Subject: V4L/DVB (6819): i2c: fix drivers/media/video/bt866.c usage_count got removed. Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/bt866.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c index b767b098d14..96b415576f0 100644 --- a/drivers/media/video/bt866.c +++ b/drivers/media/video/bt866.c @@ -300,7 +300,6 @@ static struct i2c_client bt866_client_tmpl = .addr = 0, .adapter = NULL, .driver = &i2c_driver_bt866, - .usage_count = 0 }; static int bt866_found_proc(struct i2c_adapter *adapter, -- cgit v1.2.3 From 2300317f30770abd625fb051b0e5d373ce55a6ad Mon Sep 17 00:00:00 2001 From: Steven Toth Date: Wed, 12 Dec 2007 22:14:00 -0300 Subject: V4L/DVB (6820): s5h1409: QAM SNR related fixes QAM SNR values were incorrect when the cable was disconnected. This patch extends the lookup tables to ensure correct values are being returned. Signed-off-by: Steven Toth Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/s5h1409.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/s5h1409.c b/drivers/media/dvb/frontends/s5h1409.c index 8dee7ec9456..562d9208857 100644 --- a/drivers/media/dvb/frontends/s5h1409.c +++ b/drivers/media/dvb/frontends/s5h1409.c @@ -107,7 +107,7 @@ static struct vsb_snr_tab { u16 val; u16 data; } vsb_snr_tab[] = { - { 1023, 770, }, + { 924, 300, }, { 923, 300, }, { 918, 295, }, { 915, 290, }, @@ -154,6 +154,7 @@ static struct qam64_snr_tab { u16 val; u16 data; } qam64_snr_tab[] = { + { 1, 0, }, { 12, 300, }, { 15, 290, }, { 18, 280, }, @@ -217,6 +218,7 @@ static struct qam64_snr_tab { { 95, 202, }, { 96, 201, }, { 104, 200, }, + { 255, 0, }, }; /* QAM256 SNR lookup table */ @@ -224,6 +226,7 @@ static struct qam256_snr_tab { u16 val; u16 data; } qam256_snr_tab[] = { + { 1, 0, }, { 12, 400, }, { 13, 390, }, { 15, 380, }, @@ -292,6 +295,7 @@ static struct qam256_snr_tab { { 105, 262, }, { 106, 261, }, { 110, 260, }, + { 255, 0, }, }; /* 8 bit registers, 16 bit values */ @@ -670,14 +674,15 @@ static int s5h1409_read_snr(struct dvb_frontend* fe, u16* snr) u16 reg; dprintk("%s()\n", __FUNCTION__); - reg = s5h1409_readreg(state, 0xf1) & 0x1ff; - switch(state->current_modulation) { case QAM_64: + reg = s5h1409_readreg(state, 0xf0) & 0xff; return s5h1409_qam64_lookup_snr(fe, snr, reg); case QAM_256: + reg = s5h1409_readreg(state, 0xf0) & 0xff; return s5h1409_qam256_lookup_snr(fe, snr, reg); case VSB_8: + reg = s5h1409_readreg(state, 0xf1) & 0x3ff; return s5h1409_vsb_lookup_snr(fe, snr, reg); default: break; -- cgit v1.2.3 From 98934def70b48dac74fac3738b78ab2d1a28edda Mon Sep 17 00:00:00 2001 From: William Lee Irwin III Date: Wed, 12 Dec 2007 03:56:55 -0800 Subject: ACPI: video_device_list corruption The ->cap fields of struct acpi_video_device and struct acpi_video_bus are 1B each, not 4B. The oversized memset()'s corrupted the subsequent list_head fields. This resulted in silent corruption without CONFIG_DEBUG_LIST and BUG's with it. This patch uses sizeof() to pass the proper bounds to the memset() calls and thereby correct the bugs. Signed-off-by: William Irwin Acked-by: Mikael Pettersson Signed-off-by: Len Brown --- drivers/acpi/video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 44a0d9ba9bd..bd77e81e81c 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -577,7 +577,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) struct acpi_video_device_brightness *br = NULL; - memset(&device->cap, 0, 4); + memset(&device->cap, 0, sizeof(device->cap)); if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_ADR", &h_dummy1))) { device->cap._ADR = 1; @@ -697,7 +697,7 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video) { acpi_handle h_dummy1; - memset(&video->cap, 0, 4); + memset(&video->cap, 0, sizeof(video->cap)); if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOS", &h_dummy1))) { video->cap._DOS = 1; } -- cgit v1.2.3 From ffada8913e39e6fd35e95d7040ccac57b45812c9 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 13 Dec 2007 08:32:26 +0000 Subject: ACPI: fix modpost warnings for sn2_defconfig: WARNING: vmlinux.o(.text+0x4b8601): Section mismatch: reference to .init.data:node_to_pxm_map (between '__acpi_map_pxm_to_node' and 'acpi_get_pxm') WARNING: vmlinux.o(.text+0x4b8741): Section mismatch: reference to .init.data:pxm_to_node_map (between 'acpi_map_pxm_to_node' and 'acpi_get_node') Signed-off-by: Jan Beulich Signed-off-by: Len Brown --- drivers/acpi/numa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index ab04d848b19..0822d9fc1cb 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -38,9 +38,9 @@ ACPI_MODULE_NAME("numa"); static nodemask_t nodes_found_map = NODE_MASK_NONE; /* maps to convert between proximity domain and logical node ID */ -static int __cpuinitdata pxm_to_node_map[MAX_PXM_DOMAINS] +static int pxm_to_node_map[MAX_PXM_DOMAINS] = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL }; -static int __cpuinitdata node_to_pxm_map[MAX_NUMNODES] +static int node_to_pxm_map[MAX_NUMNODES] = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL }; int pxm_to_node(int pxm) -- cgit v1.2.3 From 56a185b43be05e48da7428e6a1d3e2585b232b1d Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Thu, 13 Dec 2007 12:14:09 -0200 Subject: ACPI: thinkpad-acpi: fix lenovo keymap for brightness Starting in 2.6.23... Several reports from X60 users complained that the default Lenovo keymap issuing EV_KEY KEY_BRIGHTNESS_UP/DOWN input events caused major issues when the proper brightness support through ACPI video.c was loaded. Therefore, remove the generation of these events by default, which is the right thing for T60, X60, R60, T61, X61 and R61 with their latest BIOSes. Distros that want to misuse these events into OSD reporting (which requires an ugly hack from hell in HAL) are welcome to set up the key map they need through HAL. That way, we don't break everyone else's systems. Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- drivers/misc/thinkpad_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index ab23a322158..cf56647a6ca 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -987,9 +987,9 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */ KEY_UNKNOWN, /* 0x0D: FN+INSERT */ KEY_UNKNOWN, /* 0x0E: FN+DELETE */ - KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */ + KEY_RESERVED, /* 0x0F: FN+HOME (brightness up) */ /* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */ - KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */ + KEY_RESERVED, /* 0x10: FN+END (brightness down) */ KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ -- cgit v1.2.3 From 075b9cd66236191e8f5ce1668e0a601caa8c3570 Mon Sep 17 00:00:00 2001 From: Jochen Friedrich Date: Thu, 22 Nov 2007 17:53:47 +0100 Subject: [POWERPC] Fix typo #ifdef -> #ifndef fpi->cp_command should be overwritten only if CONFIG_PPC_CPM_NEW_BINDING is NOT set. Otherwise it is already set from the device tree. Signed-off-by: Jochen Friedrich Cc: Paul Mackerras Cc: Benjamin Herrenschmidt Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Vitaly Bordug Signed-off-by: Kumar Gala --- drivers/net/fs_enet/mac-scc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c index 03134f47a4e..48f2f300593 100644 --- a/drivers/net/fs_enet/mac-scc.c +++ b/drivers/net/fs_enet/mac-scc.c @@ -158,7 +158,7 @@ static int setup_data(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); -#ifdef CONFIG_PPC_CPM_NEW_BINDING +#ifndef CONFIG_PPC_CPM_NEW_BINDING struct fs_platform_info *fpi = fep->fpi; fep->scc.idx = fs_get_scc_index(fpi->fs_no); -- cgit v1.2.3 From 09f1fb41ad45bc18abe07c62f7b56560571584d1 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Sat, 8 Dec 2007 13:02:33 +0300 Subject: ACPI: SBS: Reset alarm bit Alarm bit should be cleared in order for other alarms to be sent. http://bugzilla.kernel.org/show_bug.cgi?id=9362 Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/sbshc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index 046d7c3ed35..12a1532513e 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c @@ -222,6 +222,7 @@ static int smbus_alarm(void *context) if (!status.fields.alarm) return 0; mutex_lock(&hc->lock); + status.fields.alarm = 0; smb_hc_write(hc, ACPI_SMB_STATUS, status.raw); if (hc->callback) acpi_os_execute(OSL_GPE_HANDLER, acpi_smbus_callback, hc); -- cgit v1.2.3 From c2d00f2d1bf8dd721f5557b0df23729addc1898d Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Sat, 8 Dec 2007 13:02:40 +0300 Subject: ACPI: SBS: Ignore alarms coming from unknown devices http://bugzilla.kernel.org/show_bug.cgi?id=9362 Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/sbs.c | 6 ------ drivers/acpi/sbshc.c | 16 ++++++++++++---- drivers/acpi/sbshc.h | 6 ++++++ 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 6045cdbe176..813ef328f74 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -54,12 +54,6 @@ #define ACPI_BATTERY_DIR_NAME "BAT%i" #define ACPI_AC_DIR_NAME "AC0" -enum acpi_sbs_device_addr { - ACPI_SBS_CHARGER = 0x9, - ACPI_SBS_MANAGER = 0xa, - ACPI_SBS_BATTERY = 0xb, -}; - #define ACPI_SBS_NOTIFY_STATUS 0x80 #define ACPI_SBS_NOTIFY_INFO 0x81 diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index 12a1532513e..fd40b6a1d63 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c @@ -202,10 +202,9 @@ int acpi_smbus_unregister_callback(struct acpi_smb_hc *hc) EXPORT_SYMBOL_GPL(acpi_smbus_unregister_callback); -static void acpi_smbus_callback(void *context) +static inline void acpi_smbus_callback(void *context) { struct acpi_smb_hc *hc = context; - if (hc->callback) hc->callback(hc->context); } @@ -214,6 +213,7 @@ static int smbus_alarm(void *context) { struct acpi_smb_hc *hc = context; union acpi_smb_status status; + u8 address; if (smb_hc_read(hc, ACPI_SMB_STATUS, &status.raw)) return 0; /* Check if it is only a completion notify */ @@ -222,10 +222,18 @@ static int smbus_alarm(void *context) if (!status.fields.alarm) return 0; mutex_lock(&hc->lock); + smb_hc_read(hc, ACPI_SMB_ALARM_ADDRESS, &address); status.fields.alarm = 0; smb_hc_write(hc, ACPI_SMB_STATUS, status.raw); - if (hc->callback) - acpi_os_execute(OSL_GPE_HANDLER, acpi_smbus_callback, hc); + /* We are only interested in events coming from known devices */ + switch (address >> 1) { + case ACPI_SBS_CHARGER: + case ACPI_SBS_MANAGER: + case ACPI_SBS_BATTERY: + acpi_os_execute(OSL_GPE_HANDLER, + acpi_smbus_callback, hc); + default:; + } mutex_unlock(&hc->lock); return 0; } diff --git a/drivers/acpi/sbshc.h b/drivers/acpi/sbshc.h index 3bda3491a97..a57b0762dd7 100644 --- a/drivers/acpi/sbshc.h +++ b/drivers/acpi/sbshc.h @@ -16,6 +16,12 @@ enum acpi_smb_protocol { static const u8 SMBUS_PEC = 0x80; +enum acpi_sbs_device_addr { + ACPI_SBS_CHARGER = 0x9, + ACPI_SBS_MANAGER = 0xa, + ACPI_SBS_BATTERY = 0xb, +}; + typedef void (*smbus_alarm_callback)(void *context); extern int acpi_smbus_read(struct acpi_smb_hc *hc, u8 protocol, u8 address, -- cgit v1.2.3 From 5a21e4fe587ebb793bf3a1c02755f8a845170328 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Sat, 8 Dec 2007 13:02:46 +0300 Subject: ACPI: SBS: Return rate in mW if capacity in mWh klaptopd assumes rate to be in same units as capacity. http://bugzilla.kernel.org/show_bug.cgi?id=9362 Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/sbs.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 813ef328f74..22cb95b349e 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -533,7 +533,7 @@ static struct proc_dir_entry *acpi_battery_dir = NULL; static inline char *acpi_battery_units(struct acpi_battery *battery) { - return acpi_battery_mode(battery) ? " mWh" : " mAh"; + return acpi_battery_mode(battery) ? " mW" : " mA"; } @@ -550,10 +550,10 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) if (!battery->present) goto end; - seq_printf(seq, "design capacity: %i%s\n", + seq_printf(seq, "design capacity: %i%sh\n", battery->design_capacity * acpi_battery_scale(battery), acpi_battery_units(battery)); - seq_printf(seq, "last full capacity: %i%s\n", + seq_printf(seq, "last full capacity: %i%sh\n", battery->full_charge_capacity * acpi_battery_scale(battery), acpi_battery_units(battery)); seq_printf(seq, "battery technology: rechargeable\n"); @@ -584,7 +584,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) { struct acpi_battery *battery = seq->private; struct acpi_sbs *sbs = battery->sbs; - int result = 0; + int rate; mutex_lock(&sbs->lock); seq_printf(seq, "present: %s\n", @@ -598,9 +598,12 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) seq_printf(seq, "charging state: %s\n", (battery->current_now < 0) ? "discharging" : ((battery->current_now > 0) ? "charging" : "charged")); - seq_printf(seq, "present rate: %d mA\n", - abs(battery->current_now) * acpi_battery_ipscale(battery)); - seq_printf(seq, "remaining capacity: %i%s\n", + rate = abs(battery->current_now) * acpi_battery_ipscale(battery); + rate *= (acpi_battery_mode(battery))?(battery->voltage_now * + acpi_battery_vscale(battery)/1000):1; + seq_printf(seq, "present rate: %d%s\n", rate, + acpi_battery_units(battery)); + seq_printf(seq, "remaining capacity: %i%sh\n", battery->capacity_now * acpi_battery_scale(battery), acpi_battery_units(battery)); seq_printf(seq, "present voltage: %i mV\n", @@ -608,7 +611,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) end: mutex_unlock(&sbs->lock); - return result; + return 0; } static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) @@ -632,7 +635,7 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) acpi_battery_get_alarm(battery); seq_printf(seq, "alarm: "); if (battery->alarm_capacity) - seq_printf(seq, "%i%s\n", + seq_printf(seq, "%i%sh\n", battery->alarm_capacity * acpi_battery_scale(battery), acpi_battery_units(battery)); -- cgit v1.2.3 From 798fdd07fcc131f396e521febb4a7d42559bf4b5 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 7 Dec 2007 15:22:15 -0800 Subject: sky2: RX lockup fix I'm using a Marvell 88E8062 on a custom PPC64 blade and ran into RX lockups while validating the sky2 driver. The receive MAC FIFO would become stuck during testing with high traffic. One port of the 88E8062 would lockup, while the other port remained functional. Re-inserting the sky2 module would not fix the problem - only a power cycle would. I looked over Marvell's most recent sk98lin driver and it looks like they had a "workaround" for the Yukon XL that the sky2 doesn't have yet. The sk98lin driver disables the RX MAC FIFO flush feature for all revisions of the Yukon XL. According to skgeinit.c of the sk98lin driver, "Flushing must be enabled (needed for ASF see dev. #4.29), but the flushing mask should be disabled (see dev. #4.115)". Nice. I implemented this same change in the sky2 driver and verified that the RX lockup I was seeing was resolved. Signed-off-by: Peter Tyser Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 6197afb3ed8..a74fc11a648 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -822,8 +822,13 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), rx_reg); - /* Flush Rx MAC FIFO on any flow control or error */ - sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR); + if (hw->chip_id == CHIP_ID_YUKON_XL) { + /* Hardware errata - clear flush mask */ + sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), 0); + } else { + /* Flush Rx MAC FIFO on any flow control or error */ + sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR); + } /* Set threshold to 0xa (64 bytes) + 1 to workaround pause bug */ reg = RX_GMF_FL_THR_DEF + 1; -- cgit v1.2.3 From 14c9d9b03bb8ec63c77aebddea9a6f730f1b62d5 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 9 Dec 2007 16:50:47 +0000 Subject: sundance fixes * all places where we assign ->addr get cpu_to_le32(pci_map_single(....)), so we ought to convert back to host-endian before doing pci_unmap_single() et.al. * poisoning addresses in netdev_close() should be done _after_ unmapping them, not before it... Signed-off-by: Al Viro Signed-off-by: Jeff Garzik --- drivers/net/sundance.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c index ff98f5d597f..0a6186d4a48 100644 --- a/drivers/net/sundance.c +++ b/drivers/net/sundance.c @@ -340,9 +340,9 @@ enum mac_ctrl1_bits { /* Note that using only 32 bit fields simplifies conversion to big-endian architectures. */ struct netdev_desc { - u32 next_desc; - u32 status; - struct desc_frag { u32 addr, length; } frag[1]; + __le32 next_desc; + __le32 status; + struct desc_frag { __le32 addr, length; } frag[1]; }; /* Bits in netdev_desc.status */ @@ -495,8 +495,8 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev, goto err_out_res; for (i = 0; i < 3; i++) - ((u16 *)dev->dev_addr)[i] = - le16_to_cpu(eeprom_read(ioaddr, i + EEPROM_SA_OFFSET)); + ((__le16 *)dev->dev_addr)[i] = + cpu_to_le16(eeprom_read(ioaddr, i + EEPROM_SA_OFFSET)); memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); dev->base_addr = (unsigned long)ioaddr; @@ -1090,8 +1090,8 @@ reset_tx (struct net_device *dev) skb = np->tx_skbuff[i]; if (skb) { pci_unmap_single(np->pci_dev, - np->tx_ring[i].frag[0].addr, skb->len, - PCI_DMA_TODEVICE); + le32_to_cpu(np->tx_ring[i].frag[0].addr), + skb->len, PCI_DMA_TODEVICE); if (irq) dev_kfree_skb_irq (skb); else @@ -1214,7 +1214,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance) skb = np->tx_skbuff[entry]; /* Free the original skb. */ pci_unmap_single(np->pci_dev, - np->tx_ring[entry].frag[0].addr, + le32_to_cpu(np->tx_ring[entry].frag[0].addr), skb->len, PCI_DMA_TODEVICE); dev_kfree_skb_irq (np->tx_skbuff[entry]); np->tx_skbuff[entry] = NULL; @@ -1233,7 +1233,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance) skb = np->tx_skbuff[entry]; /* Free the original skb. */ pci_unmap_single(np->pci_dev, - np->tx_ring[entry].frag[0].addr, + le32_to_cpu(np->tx_ring[entry].frag[0].addr), skb->len, PCI_DMA_TODEVICE); dev_kfree_skb_irq (np->tx_skbuff[entry]); np->tx_skbuff[entry] = NULL; @@ -1311,19 +1311,19 @@ static void rx_poll(unsigned long data) && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { skb_reserve(skb, 2); /* 16 byte align the IP header */ pci_dma_sync_single_for_cpu(np->pci_dev, - desc->frag[0].addr, + le32_to_cpu(desc->frag[0].addr), np->rx_buf_sz, PCI_DMA_FROMDEVICE); skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len); pci_dma_sync_single_for_device(np->pci_dev, - desc->frag[0].addr, + le32_to_cpu(desc->frag[0].addr), np->rx_buf_sz, PCI_DMA_FROMDEVICE); skb_put(skb, pkt_len); } else { pci_unmap_single(np->pci_dev, - desc->frag[0].addr, + le32_to_cpu(desc->frag[0].addr), np->rx_buf_sz, PCI_DMA_FROMDEVICE); skb_put(skb = np->rx_skbuff[entry], pkt_len); @@ -1709,23 +1709,23 @@ static int netdev_close(struct net_device *dev) /* Free all the skbuffs in the Rx queue. */ for (i = 0; i < RX_RING_SIZE; i++) { np->rx_ring[i].status = 0; - np->rx_ring[i].frag[0].addr = 0xBADF00D0; /* An invalid address. */ skb = np->rx_skbuff[i]; if (skb) { pci_unmap_single(np->pci_dev, - np->rx_ring[i].frag[0].addr, np->rx_buf_sz, - PCI_DMA_FROMDEVICE); + le32_to_cpu(np->rx_ring[i].frag[0].addr), + np->rx_buf_sz, PCI_DMA_FROMDEVICE); dev_kfree_skb(skb); np->rx_skbuff[i] = NULL; } + np->rx_ring[i].frag[0].addr = cpu_to_le32(0xBADF00D0); /* poison */ } for (i = 0; i < TX_RING_SIZE; i++) { np->tx_ring[i].next_desc = 0; skb = np->tx_skbuff[i]; if (skb) { pci_unmap_single(np->pci_dev, - np->tx_ring[i].frag[0].addr, skb->len, - PCI_DMA_TODEVICE); + le32_to_cpu(np->tx_ring[i].frag[0].addr), + skb->len, PCI_DMA_TODEVICE); dev_kfree_skb(skb); np->tx_skbuff[i] = NULL; } -- cgit v1.2.3 From 813820b9b9adb98d4ad3cd7434eb662b0fc15684 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 9 Dec 2007 17:00:54 +0000 Subject: starfire VLAN fix Recognized VLAN ids are set via writew(), should go in host-endian. That's a long-standing bug, BTW - see http://lkml.org/lkml/2004/2/27/180 for example. What happens is that card gets VLAN id table populated by byteswapped values on little-endian boxen (so 257 works as expected, 256 and 258 do not, etc.). Bug is easily reproduced, patch fixes it. Signed-off-by: Al Viro Signed-off-by: Jeff Garzik --- drivers/net/starfire.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c index bcc430bd9e4..6e00dc857af 100644 --- a/drivers/net/starfire.c +++ b/drivers/net/starfire.c @@ -1742,7 +1742,7 @@ static void set_rx_mode(struct net_device *dev) if (vlan_group_get_device(np->vlgrp, i)) { if (vlan_count >= 32) break; - writew(cpu_to_be16(i), filter_addr); + writew(i, filter_addr); filter_addr += 16; vlan_count++; } -- cgit v1.2.3 From 8543da6672b0994921f014f2250e27ae81645580 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 12 Dec 2007 16:30:42 -0800 Subject: e100: free IRQ to remove warningwhenrebooting Adapted from Ian Wienand Explicitly free the IRQ before removing the device to remove a warning "Destroying IRQ without calling free_irq" Signed-off-by: Auke Kok Cc: Ian Wienand Signed-off-by: Jeff Garzik --- drivers/net/e100.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/e100.c b/drivers/net/e100.c index e1c8a0d023e..2b06e4b4dab 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c @@ -2737,8 +2737,9 @@ static int e100_suspend(struct pci_dev *pdev, pm_message_t state) pci_enable_wake(pdev, PCI_D3cold, 0); } - pci_disable_device(pdev); free_irq(pdev->irq, netdev); + + pci_disable_device(pdev); pci_set_power_state(pdev, PCI_D3hot); return 0; @@ -2780,6 +2781,8 @@ static void e100_shutdown(struct pci_dev *pdev) pci_enable_wake(pdev, PCI_D3cold, 0); } + free_irq(pdev->irq, netdev); + pci_disable_device(pdev); pci_set_power_state(pdev, PCI_D3hot); } -- cgit v1.2.3 From 8e9859184031ac1b0a0234b8671a90cfcd333666 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 10 Dec 2007 18:39:29 +0000 Subject: hamachi endianness fixes badly broken on big-endian * passing little-endian to pci_unmap_single() et.al. * cpu_to_le32() before passing value to writel() * worse, cpu_to_le64() and shifting/masking result before the same * hmp->tx_ring[i].status_n_length = cpu_to_le32( DescEndRing | (hmp->tx_ring[i].status_n_length & 0x0000FFFF)); is obviously bogus on big-endian. Not hard to untangle, fortunately... * poisoning addresses in rx_ring is better done after we'd done pci_unmap_single() on them, not before that. [this one affects little-endian as well, obviously, provided that pci_unmap_single() is not a no-op on target in question] Signed-off-by: Al Viro Signed-off-by: Jeff Garzik --- drivers/net/hamachi.c | 70 +++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 33 deletions(-) (limited to 'drivers') diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c index ed407c85708..b53f6b6491b 100644 --- a/drivers/net/hamachi.c +++ b/drivers/net/hamachi.c @@ -204,8 +204,10 @@ KERN_INFO " Further modifications by Keith Underwood /* Condensed bus+endian portability operations. */ #if ADDRLEN == 64 #define cpu_to_leXX(addr) cpu_to_le64(addr) +#define leXX_to_cpu(addr) le64_to_cpu(addr) #else #define cpu_to_leXX(addr) cpu_to_le32(addr) +#define leXX_to_cpu(addr) le32_to_cpu(addr) #endif @@ -465,12 +467,12 @@ enum intr_status_bits { /* The Hamachi Rx and Tx buffer descriptors. */ struct hamachi_desc { - u32 status_n_length; + __le32 status_n_length; #if ADDRLEN == 64 u32 pad; - u64 addr; + __le64 addr; #else - u32 addr; + __le32 addr; #endif }; @@ -874,13 +876,13 @@ static int hamachi_open(struct net_device *dev) #if ADDRLEN == 64 /* writellll anyone ? */ - writel(cpu_to_le64(hmp->rx_ring_dma), ioaddr + RxPtr); - writel(cpu_to_le64(hmp->rx_ring_dma) >> 32, ioaddr + RxPtr + 4); - writel(cpu_to_le64(hmp->tx_ring_dma), ioaddr + TxPtr); - writel(cpu_to_le64(hmp->tx_ring_dma) >> 32, ioaddr + TxPtr + 4); + writel(hmp->rx_ring_dma, ioaddr + RxPtr); + writel(hmp->rx_ring_dma >> 32, ioaddr + RxPtr + 4); + writel(hmp->tx_ring_dma, ioaddr + TxPtr); + writel(hmp->tx_ring_dma >> 32, ioaddr + TxPtr + 4); #else - writel(cpu_to_le32(hmp->rx_ring_dma), ioaddr + RxPtr); - writel(cpu_to_le32(hmp->tx_ring_dma), ioaddr + TxPtr); + writel(hmp->rx_ring_dma, ioaddr + RxPtr); + writel(hmp->tx_ring_dma, ioaddr + TxPtr); #endif /* TODO: It would make sense to organize this as words since the card @@ -1019,8 +1021,8 @@ static inline int hamachi_tx(struct net_device *dev) skb = hmp->tx_skbuff[entry]; if (skb) { pci_unmap_single(hmp->pci_dev, - hmp->tx_ring[entry].addr, skb->len, - PCI_DMA_TODEVICE); + leXX_to_cpu(hmp->tx_ring[entry].addr), + skb->len, PCI_DMA_TODEVICE); dev_kfree_skb(skb); hmp->tx_skbuff[entry] = NULL; } @@ -1071,10 +1073,10 @@ static void hamachi_tx_timeout(struct net_device *dev) { printk(KERN_DEBUG " Rx ring %p: ", hmp->rx_ring); for (i = 0; i < RX_RING_SIZE; i++) - printk(" %8.8x", (unsigned int)hmp->rx_ring[i].status_n_length); + printk(" %8.8x", le32_to_cpu(hmp->rx_ring[i].status_n_length)); printk("\n"KERN_DEBUG" Tx ring %p: ", hmp->tx_ring); for (i = 0; i < TX_RING_SIZE; i++) - printk(" %4.4x", hmp->tx_ring[i].status_n_length); + printk(" %4.4x", le32_to_cpu(hmp->tx_ring[i].status_n_length)); printk("\n"); } @@ -1099,14 +1101,15 @@ static void hamachi_tx_timeout(struct net_device *dev) struct sk_buff *skb; if (i >= TX_RING_SIZE - 1) - hmp->tx_ring[i].status_n_length = cpu_to_le32( - DescEndRing | - (hmp->tx_ring[i].status_n_length & 0x0000FFFF)); + hmp->tx_ring[i].status_n_length = + cpu_to_le32(DescEndRing) | + (hmp->tx_ring[i].status_n_length & + cpu_to_le32(0x0000ffff)); else - hmp->tx_ring[i].status_n_length &= 0x0000ffff; + hmp->tx_ring[i].status_n_length &= cpu_to_le32(0x0000ffff); skb = hmp->tx_skbuff[i]; if (skb){ - pci_unmap_single(hmp->pci_dev, hmp->tx_ring[i].addr, + pci_unmap_single(hmp->pci_dev, leXX_to_cpu(hmp->tx_ring[i].addr), skb->len, PCI_DMA_TODEVICE); dev_kfree_skb(skb); hmp->tx_skbuff[i] = NULL; @@ -1128,7 +1131,8 @@ static void hamachi_tx_timeout(struct net_device *dev) struct sk_buff *skb = hmp->rx_skbuff[i]; if (skb){ - pci_unmap_single(hmp->pci_dev, hmp->rx_ring[i].addr, + pci_unmap_single(hmp->pci_dev, + leXX_to_cpu(hmp->rx_ring[i].addr), hmp->rx_buf_sz, PCI_DMA_FROMDEVICE); dev_kfree_skb(skb); hmp->rx_skbuff[i] = NULL; @@ -1420,7 +1424,7 @@ static irqreturn_t hamachi_interrupt(int irq, void *dev_instance) /* Free the original skb. */ if (skb){ pci_unmap_single(hmp->pci_dev, - hmp->tx_ring[entry].addr, + leXX_to_cpu(hmp->tx_ring[entry].addr), skb->len, PCI_DMA_TODEVICE); dev_kfree_skb_irq(skb); @@ -1500,11 +1504,11 @@ static int hamachi_rx(struct net_device *dev) if (desc_status & DescOwn) break; pci_dma_sync_single_for_cpu(hmp->pci_dev, - desc->addr, + leXX_to_cpu(desc->addr), hmp->rx_buf_sz, PCI_DMA_FROMDEVICE); buf_addr = (u8 *) hmp->rx_skbuff[entry]->data; - frame_status = le32_to_cpu(get_unaligned((s32*)&(buf_addr[data_size - 12]))); + frame_status = le32_to_cpu(get_unaligned((__le32*)&(buf_addr[data_size - 12]))); if (hamachi_debug > 4) printk(KERN_DEBUG " hamachi_rx() status was %8.8x.\n", frame_status); @@ -1518,9 +1522,9 @@ static int hamachi_rx(struct net_device *dev) dev->name, desc, &hmp->rx_ring[hmp->cur_rx % RX_RING_SIZE]); printk(KERN_WARNING "%s: Oversized Ethernet frame -- next status %x/%x last status %x.\n", dev->name, - hmp->rx_ring[(hmp->cur_rx+1) % RX_RING_SIZE].status_n_length & 0xffff0000, - hmp->rx_ring[(hmp->cur_rx+1) % RX_RING_SIZE].status_n_length & 0x0000ffff, - hmp->rx_ring[(hmp->cur_rx-1) % RX_RING_SIZE].status_n_length); + le32_to_cpu(hmp->rx_ring[(hmp->cur_rx+1) % RX_RING_SIZE].status_n_length) & 0xffff0000, + le32_to_cpu(hmp->rx_ring[(hmp->cur_rx+1) % RX_RING_SIZE].status_n_length) & 0x0000ffff, + le32_to_cpu(hmp->rx_ring[(hmp->cur_rx-1) % RX_RING_SIZE].status_n_length)); hmp->stats.rx_length_errors++; } /* else Omit for prototype errata??? */ if (frame_status & 0x00380000) { @@ -1566,7 +1570,7 @@ static int hamachi_rx(struct net_device *dev) #endif skb_reserve(skb, 2); /* 16 byte align the IP header */ pci_dma_sync_single_for_cpu(hmp->pci_dev, - hmp->rx_ring[entry].addr, + leXX_to_cpu(hmp->rx_ring[entry].addr), hmp->rx_buf_sz, PCI_DMA_FROMDEVICE); /* Call copy + cksum if available. */ @@ -1579,12 +1583,12 @@ static int hamachi_rx(struct net_device *dev) + entry*sizeof(*desc), pkt_len); #endif pci_dma_sync_single_for_device(hmp->pci_dev, - hmp->rx_ring[entry].addr, + leXX_to_cpu(hmp->rx_ring[entry].addr), hmp->rx_buf_sz, PCI_DMA_FROMDEVICE); } else { pci_unmap_single(hmp->pci_dev, - hmp->rx_ring[entry].addr, + leXX_to_cpu(hmp->rx_ring[entry].addr), hmp->rx_buf_sz, PCI_DMA_FROMDEVICE); skb_put(skb = hmp->rx_skbuff[entry], pkt_len); hmp->rx_skbuff[entry] = NULL; @@ -1787,21 +1791,21 @@ static int hamachi_close(struct net_device *dev) for (i = 0; i < RX_RING_SIZE; i++) { skb = hmp->rx_skbuff[i]; hmp->rx_ring[i].status_n_length = 0; - hmp->rx_ring[i].addr = 0xBADF00D0; /* An invalid address. */ if (skb) { pci_unmap_single(hmp->pci_dev, - hmp->rx_ring[i].addr, hmp->rx_buf_sz, - PCI_DMA_FROMDEVICE); + leXX_to_cpu(hmp->rx_ring[i].addr), + hmp->rx_buf_sz, PCI_DMA_FROMDEVICE); dev_kfree_skb(skb); hmp->rx_skbuff[i] = NULL; } + hmp->rx_ring[i].addr = cpu_to_leXX(0xBADF00D0); /* An invalid address. */ } for (i = 0; i < TX_RING_SIZE; i++) { skb = hmp->tx_skbuff[i]; if (skb) { pci_unmap_single(hmp->pci_dev, - hmp->tx_ring[i].addr, skb->len, - PCI_DMA_TODEVICE); + leXX_to_cpu(hmp->tx_ring[i].addr), + skb->len, PCI_DMA_TODEVICE); dev_kfree_skb(skb); hmp->tx_skbuff[i] = NULL; } -- cgit v1.2.3 From c2b75f0cd7cb14874f179d2c09c81f77ad784df2 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 11 Dec 2007 23:23:56 +0100 Subject: drivers/net/sis190.c section fix This patch fixes the following section mismatch with CONFIG_HOTPLUG=n: <-- snip --> ... WARNING: vmlinux.o(.init.text.20+0x4cb25): Section mismatch: reference to .exit.text:sis190_mii_remove (between 'sis190_init_one' and 'read_eeprom') ... <-- snip --> Signed-off-by: Adrian Bunk Signed-off-by: Jeff Garzik --- drivers/net/sis190.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c index 720088396bb..49f767bef6a 100644 --- a/drivers/net/sis190.c +++ b/drivers/net/sis190.c @@ -1381,7 +1381,7 @@ out: return rc; } -static void __devexit sis190_mii_remove(struct net_device *dev) +static void sis190_mii_remove(struct net_device *dev) { struct sis190_private *tp = netdev_priv(dev); -- cgit v1.2.3 From 33390a700129aa03f3808c35de017650a688f82a Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 11 Dec 2007 23:23:06 +0100 Subject: drivers/net/s2io.c section fixes Code used by the non-__devinit s2io_open() mustn't be __devinit. This patch fixes the following section mismatch with CONFIG_HOTPLUG=n: <-- snip --> ... WARNING: vmlinux.o(.text+0x6f6e3e): Section mismatch: reference to .init.text.20:s2io_test_intr (between 's2io_open' and 's2io_ethtool_sset') ... <-- snip --> Signed-off-by: Adrian Bunk Signed-off-by: Jeff Garzik --- drivers/net/s2io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 121cb100f93..9d80f1cf73a 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c @@ -3737,7 +3737,7 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) } /* Handle software interrupt used during MSI(X) test */ -static irqreturn_t __devinit s2io_test_intr(int irq, void *dev_id) +static irqreturn_t s2io_test_intr(int irq, void *dev_id) { struct s2io_nic *sp = dev_id; @@ -3748,7 +3748,7 @@ static irqreturn_t __devinit s2io_test_intr(int irq, void *dev_id) } /* Test interrupt path by forcing a a software IRQ */ -static int __devinit s2io_test_msi(struct s2io_nic *sp) +static int s2io_test_msi(struct s2io_nic *sp) { struct pci_dev *pdev = sp->pdev; struct XENA_dev_config __iomem *bar0 = sp->bar0; -- cgit v1.2.3 From 4b8fdefa090c8b9582f58a93f73938f9b86c264a Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 13 Dec 2007 16:02:55 -0800 Subject: ucc_geth: minor whitespace fix The zombie whitespace from outer space that will not die! Cc: "David S. Miller" Cc: Emil Medve Cc: Jeff Garzik Cc: Kumar Gala Cc: Li Yang Cc: Paul Mackerras Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/net/ucc_geth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 7f689907ac2..abac7db3819 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c @@ -3447,7 +3447,7 @@ static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit u16 length, howmany = 0; u32 bd_status; u8 *bdBuffer; - struct net_device * dev; + struct net_device *dev; ugeth_vdbg("%s: IN", __FUNCTION__); -- cgit v1.2.3 From b173079feaed7664a3407eb17e102010d687a051 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Thu, 13 Dec 2007 16:02:59 -0800 Subject: net: smc911x: shut up compiler warnings Trivial fix to shut up gcc. Signed-off-by: Paul Mundt Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/net/smc911x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h index d04e4fa3520..7defa63b9c7 100644 --- a/drivers/net/smc911x.h +++ b/drivers/net/smc911x.h @@ -76,7 +76,7 @@ -#if SMC_USE_PXA_DMA +#ifdef SMC_USE_PXA_DMA #define SMC_USE_DMA /* -- cgit v1.2.3 From 470738758db2c209481fdf92ca09f60e690a62d3 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 13 Dec 2007 16:02:57 -0800 Subject: Net: ibm_newemac, remove SPIN_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED is deprecated, use DEFINE_SPINLOCK instead Signed-off-by: Jiri Slaby Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/ibm_newemac/debug.c b/drivers/net/ibm_newemac/debug.c index a2fc660ca5d..86b756a3078 100644 --- a/drivers/net/ibm_newemac/debug.c +++ b/drivers/net/ibm_newemac/debug.c @@ -26,7 +26,7 @@ #include "core.h" -static spinlock_t emac_dbg_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(emac_dbg_lock); static void emac_desc_dump(struct emac_instance *p) { -- cgit v1.2.3 From 3fd7131feacc01c1e23e46c416228f36ebdcc0d4 Mon Sep 17 00:00:00 2001 From: Matheos Worku Date: Fri, 14 Dec 2007 11:48:29 -0800 Subject: ixgb: make sure jumbos stay enabled after reset Currently a device reset (ethtool -r ethX) would cause the adapter to fall back to regular MTU sizes. Signed-off-by: Matheos Worku Signed-off-by: Jesse Brandeburg Signed-off-by: Auke Kok Signed-off-by: Jeff Garzik --- drivers/net/ixgb/ixgb_main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c index 3021234b1e1..bf9085fe035 100644 --- a/drivers/net/ixgb/ixgb_main.c +++ b/drivers/net/ixgb/ixgb_main.c @@ -320,10 +320,22 @@ ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog) void ixgb_reset(struct ixgb_adapter *adapter) { + struct ixgb_hw *hw = &adapter->hw; - ixgb_adapter_stop(&adapter->hw); - if(!ixgb_init_hw(&adapter->hw)) + ixgb_adapter_stop(hw); + if (!ixgb_init_hw(hw)) DPRINTK(PROBE, ERR, "ixgb_init_hw failed.\n"); + + /* restore frame size information */ + IXGB_WRITE_REG(hw, MFS, hw->max_frame_size << IXGB_MFS_SHIFT); + if (hw->max_frame_size > + IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) { + u32 ctrl0 = IXGB_READ_REG(hw, CTRL0); + if (!(ctrl0 & IXGB_CTRL0_JFE)) { + ctrl0 |= IXGB_CTRL0_JFE; + IXGB_WRITE_REG(hw, CTRL0, ctrl0); + } + } } /** -- cgit v1.2.3 From 6f229d76b4c4a7fae601ea9398b23c2b426ab3b9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 12 Dec 2007 18:50:18 -0800 Subject: [SYNCPPP]: Endianness and 64bit fixes. * trivial annotations * long != 32bit, use __be32 * wrong endianness in sending CISCO_ADDR_REPLY Signed-off-by: Al Viro Signed-off-by: David S. Miller --- drivers/net/wan/syncppp.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c index 232ecba5340..61e24b7a45a 100644 --- a/drivers/net/wan/syncppp.c +++ b/drivers/net/wan/syncppp.c @@ -107,24 +107,24 @@ struct ppp_header { u8 address; u8 control; - u16 protocol; + __be16 protocol; }; #define PPP_HEADER_LEN sizeof (struct ppp_header) struct lcp_header { u8 type; u8 ident; - u16 len; + __be16 len; }; #define LCP_HEADER_LEN sizeof (struct lcp_header) struct cisco_packet { - u32 type; - u32 par1; - u32 par2; - u16 rel; - u16 time0; - u16 time1; + __be32 type; + __be32 par1; + __be32 par2; + __be16 rel; + __be16 time0; + __be16 time1; }; #define CISCO_PACKET_LEN 18 #define CISCO_BIG_PACKET_LEN 20 @@ -139,7 +139,7 @@ static struct sk_buff_head tx_queue; static void sppp_keepalive (unsigned long dummy); static void sppp_cp_send (struct sppp *sp, u16 proto, u8 type, u8 ident, u16 len, void *data); -static void sppp_cisco_send (struct sppp *sp, int type, long par1, long par2); +static void sppp_cisco_send (struct sppp *sp, int type, u32 par1, u32 par2); static void sppp_lcp_input (struct sppp *sp, struct sk_buff *m); static void sppp_cisco_input (struct sppp *sp, struct sk_buff *m); static void sppp_ipcp_input (struct sppp *sp, struct sk_buff *m); @@ -447,7 +447,7 @@ static void sppp_keepalive (unsigned long dummy) sppp_cisco_send (sp, CISCO_KEEPALIVE_REQ, ++sp->pp_seq, sp->pp_rseq); else if (sp->lcp.state == LCP_STATE_OPENED) { - long nmagic = htonl (sp->lcp.magic); + __be32 nmagic = htonl (sp->lcp.magic); sp->lcp.echoid = ++sp->pp_seq; sppp_cp_send (sp, PPP_LCP, LCP_ECHO_REQ, sp->lcp.echoid, 4, &nmagic); @@ -667,7 +667,7 @@ badreq: dev->name, len); break; } - if (ntohl (*(long*)(h+1)) == sp->lcp.magic) { + if (ntohl (*(__be32*)(h+1)) == sp->lcp.magic) { /* Line loopback mode detected. */ printk (KERN_WARNING "%s: loopback\n", dev->name); if_down (dev); @@ -680,7 +680,7 @@ badreq: sppp_lcp_open (sp); break; } - *(long*)(h+1) = htonl (sp->lcp.magic); + *(__be32 *)(h+1) = htonl (sp->lcp.magic); sppp_cp_send (sp, PPP_LCP, LCP_ECHO_REPLY, h->ident, len-4, h+1); break; case LCP_ECHO_REPLY: @@ -692,7 +692,7 @@ badreq: dev->name, len); break; } - if (ntohl (*(long*)(h+1)) != sp->lcp.magic) + if (ntohl(*(__be32 *)(h+1)) != sp->lcp.magic) sp->pp_alivecnt = 0; break; } @@ -765,7 +765,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb) { struct in_device *in_dev; struct in_ifaddr *ifa; - __be32 addr = 0, mask = ~0; /* FIXME: is the mask correct? */ + __be32 addr = 0, mask = htonl(~0U); /* FIXME: is the mask correct? */ #ifdef CONFIG_INET rcu_read_lock(); if ((in_dev = __in_dev_get_rcu(dev)) != NULL) @@ -782,8 +782,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb) } rcu_read_unlock(); #endif - /* I hope both addr and mask are in the net order */ - sppp_cisco_send (sp, CISCO_ADDR_REPLY, addr, mask); + sppp_cisco_send (sp, CISCO_ADDR_REPLY, ntohl(addr), ntohl(mask)); break; } } @@ -844,7 +843,7 @@ static void sppp_cp_send (struct sppp *sp, u16 proto, u8 type, * Send Cisco keepalive packet. */ -static void sppp_cisco_send (struct sppp *sp, int type, long par1, long par2) +static void sppp_cisco_send (struct sppp *sp, int type, u32 par1, u32 par2) { struct ppp_header *h; struct cisco_packet *ch; @@ -868,7 +867,7 @@ static void sppp_cisco_send (struct sppp *sp, int type, long par1, long par2) ch->type = htonl (type); ch->par1 = htonl (par1); ch->par2 = htonl (par2); - ch->rel = -1; + ch->rel = htons(0xffff); ch->time0 = htons ((u16) (t >> 16)); ch->time1 = htons ((u16) t); -- cgit v1.2.3 From f58adb757be48068e2bded3dd77ba072c22a10ff Mon Sep 17 00:00:00 2001 From: "Tom \"spot\" Callaway" Date: Thu, 13 Dec 2007 09:33:50 -0800 Subject: [ATM]: Fix compiler warning noise with FORE200E driver gcc throws these warnings with: CONFIG_ATM_FORE200E=m # CONFIG_ATM_FORE200E_PCA is not set drivers/atm/fore200e.c:2695: warning: 'fore200e_pca_detect' defined but not used drivers/atm/fore200e.c:2748: warning: 'fore200e_pca_remove_one' defined but not used By moving the #ifdef CONFIG_ATM_FORE200E_PCA around those two functions, the compiler warnings are silenced. Signed-off-by: Tom "spot" Callaway Signed-off-by: David S. Miller --- drivers/atm/fore200e.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index 8b12925fe7a..f97e050338f 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c @@ -2689,7 +2689,7 @@ fore200e_init(struct fore200e* fore200e) return 0; } - +#ifdef CONFIG_ATM_FORE200E_PCA static int __devinit fore200e_pca_detect(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent) { @@ -2756,7 +2756,6 @@ static void __devexit fore200e_pca_remove_one(struct pci_dev *pci_dev) } -#ifdef CONFIG_ATM_FORE200E_PCA static struct pci_device_id fore200e_pca_tbl[] = { { PCI_VENDOR_ID_FORE, PCI_DEVICE_ID_FORE_PCA200E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &fore200e_bus[0] }, -- cgit v1.2.3 From 497ba7f4c8113ed699a4fd793d1437f0c8f2da5e Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Sun, 16 Dec 2007 14:07:36 -0800 Subject: [IRDA]: Race between open and disconnect in irda-usb. It seems to me that irda_usb_net_open() must set self->netopen under spinlock or disconnect() may fail to kill all URBs, if it is called while an interface is opened. Signed-off-by: Oliver Neukum Signed-off-by: Samuel Ortiz Signed-off-by: David S. Miller --- drivers/net/irda/irda-usb.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers') diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index c6355c00fd7..9081234ab45 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -1168,6 +1168,7 @@ static int stir421x_patch_device(struct irda_usb_cb *self) static int irda_usb_net_open(struct net_device *netdev) { struct irda_usb_cb *self; + unsigned long flags; char hwname[16]; int i; @@ -1177,13 +1178,16 @@ static int irda_usb_net_open(struct net_device *netdev) self = (struct irda_usb_cb *) netdev->priv; IRDA_ASSERT(self != NULL, return -1;); + spin_lock_irqsave(&self->lock, flags); /* Can only open the device if it's there */ if(!self->present) { + spin_unlock_irqrestore(&self->lock, flags); IRDA_WARNING("%s(), device not present!\n", __FUNCTION__); return -1; } if(self->needspatch) { + spin_unlock_irqrestore(&self->lock, flags); IRDA_WARNING("%s(), device needs patch\n", __FUNCTION__) ; return -EIO ; } @@ -1198,6 +1202,7 @@ static int irda_usb_net_open(struct net_device *netdev) /* To do *before* submitting Rx urbs and starting net Tx queue * Jean II */ self->netopen = 1; + spin_unlock_irqrestore(&self->lock, flags); /* * Now that everything should be initialized properly, -- cgit v1.2.3 From 0ff804348d66550e7dd1d6781c65403b312e2da2 Mon Sep 17 00:00:00 2001 From: Hinko Kocevar Date: Sun, 16 Dec 2007 14:08:22 -0800 Subject: [IRDA]: mcs7780 needs to free allocated rx buffer. While testing the mcs7780 based IrDA USB dongle I've stumbled upon memory leak in mcs_net_close(). Patch below fixes it. Signed-off-by: Hinko Kocevar Signed-off-by: Samuel Ortiz Signed-off-by: David S. Miller --- drivers/net/irda/mcs7780.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c index 0b769192d4c..93916cf33f2 100644 --- a/drivers/net/irda/mcs7780.c +++ b/drivers/net/irda/mcs7780.c @@ -677,6 +677,8 @@ static int mcs_net_close(struct net_device *netdev) /* Stop transmit processing */ netif_stop_queue(netdev); + kfree_skb(mcs->rx_buff.skb); + /* kill and free the receive and transmit URBs */ usb_kill_urb(mcs->rx_urb); usb_free_urb(mcs->rx_urb); -- cgit v1.2.3 From ea332912b8a2e0b2f51ac3b6c197b71d3a18cbb7 Mon Sep 17 00:00:00 2001 From: Olaf Hartmann Date: Sun, 16 Dec 2007 14:09:44 -0800 Subject: [IRDA]: stir4200 fixes. From: Olaf Hartmann The attached patch observes the stir4200 fifo size and will clear the fifo, if the size is increasing, while it should be transmitting bytes Signed-off-by: Samuel Ortiz Signed-off-by: David S. Miller --- drivers/net/irda/stir4200.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c index 042bc2f0417..e59c485bc49 100644 --- a/drivers/net/irda/stir4200.c +++ b/drivers/net/irda/stir4200.c @@ -142,9 +142,6 @@ enum StirCtrl2Mask { }; enum StirFifoCtlMask { - FIFOCTL_EOF = 0x80, - FIFOCTL_UNDER = 0x40, - FIFOCTL_OVER = 0x20, FIFOCTL_DIR = 0x10, FIFOCTL_CLR = 0x08, FIFOCTL_EMPTY = 0x04, @@ -594,9 +591,10 @@ static int fifo_txwait(struct stir_cb *stir, int space) { int err; unsigned long count, status; + unsigned long prev_count = 0x1fff; /* Read FIFO status and count */ - for(;;) { + for (;; prev_count = count) { err = read_reg(stir, REG_FIFOCTL, stir->fifo_status, FIFO_REGS_SIZE); if (unlikely(err != FIFO_REGS_SIZE)) { @@ -629,6 +627,10 @@ static int fifo_txwait(struct stir_cb *stir, int space) if (space >= 0 && STIR_FIFO_SIZE - 4 > space + count) return 0; + /* queue confused */ + if (prev_count < count) + break; + /* estimate transfer time for remaining chars */ msleep((count * 8000) / stir->speed); } -- cgit v1.2.3 From cb8c9b6de076d981ca22801dbd6bce12b0758468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Li=C3=A9vin?= Date: Sat, 1 Dec 2007 08:51:58 +0100 Subject: tipar: remove obsolete module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tipar: remove obsolete module The tipar character driver was used to implement bit-banging access to Texas Instruments parallel link cable. A user-land method now exists thru PPDEV & PARPORT. Signed-off-by: Romain Liévin Signed-off-by: Greg Kroah-Hartman --- drivers/char/Kconfig | 22 -- drivers/char/tipar.c | 557 --------------------------------------------------- 2 files changed, 579 deletions(-) delete mode 100644 drivers/char/tipar.c (limited to 'drivers') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index a509b8d7978..ef1ed5d7012 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -543,28 +543,6 @@ config PPDEV If unsure, say N. -config TIPAR - tristate "Texas Instruments parallel link cable support" - depends on PARPORT - ---help--- - If you own a Texas Instruments graphing calculator and use a - parallel link cable, then you might be interested in this driver. - - If you enable this driver, you will be able to communicate with - your calculator through a set of device nodes under /dev. The - main advantage of this driver is that you don't have to be root - to use this precise link cable (depending on the permissions on - the device nodes, though). - - To compile this driver as a module, choose M here: the - module will be called tipar. - - If you don't know what a parallel link cable is or what a Texas - Instruments graphing calculator is, then you probably don't need this - driver. - - If unsure, say N. - config HVC_DRIVER bool help diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c deleted file mode 100644 index cef55c40654..00000000000 --- a/drivers/char/tipar.c +++ /dev/null @@ -1,557 +0,0 @@ -/* Hey EMACS -*- linux-c -*- - * - * tipar - low level driver for handling a parallel link cable designed - * for Texas Instruments graphing calculators (http://lpg.ticalc.org). - * A part of the TiLP project. - * - * Copyright (C) 2000-2002, Romain Lievin - * under the terms of the GNU General Public License. - * - * Various fixes & clean-up from the Linux Kernel Mailing List - * (Alan Cox, Richard B. Johnson, Christoph Hellwig). - */ - -/* This driver should, in theory, work with any parallel port that has an - * appropriate low-level driver; all I/O is done through the parport - * abstraction layer. - * - * If this driver is built into the kernel, you can configure it using the - * kernel command-line. For example: - * - * tipar=timeout,delay (set timeout and delay) - * - * If the driver is loaded as a module, similar functionality is available - * using module parameters. The equivalent of the above commands would be: - * - * # insmod tipar timeout=15 delay=10 - */ - -/* COMPATIBILITY WITH OLD KERNELS - * - * Usually, parallel cables were bound to ports at - * particular I/O addresses, as follows: - * - * tipar0 0x378 - * tipar1 0x278 - * tipar2 0x3bc - * - * - * This driver, by default, binds tipar devices according to parport and - * the minor number. - * - */ -#undef DEBUG /* change to #define to get debugging - * output - for pr_debug() */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* Our code depend on parport */ -#include - -/* - * TI definitions - */ -#include - -/* - * Version Information - */ -#define DRIVER_VERSION "1.19" -#define DRIVER_AUTHOR "Romain Lievin " -#define DRIVER_DESC "Device driver for TI/PC parallel link cables" -#define DRIVER_LICENSE "GPL" - -#define VERSION(ver,rel,seq) (((ver)<<16) | ((rel)<<8) | (seq)) - -/* ----- global variables --------------------------------------------- */ - -struct tipar_struct { - struct pardevice *dev; /* Parport device entry */ -}; - -#define PP_NO 3 -static struct tipar_struct table[PP_NO]; - -static int delay = IO_DELAY; /* inter-bit delay in microseconds */ -static int timeout = TIMAXTIME; /* timeout in tenth of seconds */ - -static unsigned int tp_count; /* tipar count */ -static unsigned long opened; /* opened devices */ - -static struct class *tipar_class; - -/* --- macros for parport access -------------------------------------- */ - -#define r_dtr(x) (parport_read_data(table[(x)].dev->port)) -#define r_str(x) (parport_read_status(table[(x)].dev->port)) -#define w_ctr(x,y) (parport_write_control(table[(x)].dev->port, (y))) -#define w_dtr(x,y) (parport_write_data(table[(x)].dev->port, (y))) - -/* --- setting states on the D-bus with the right timing: ------------- */ - -static inline void -outbyte(int value, int minor) -{ - w_dtr(minor, value); -} - -static inline int -inbyte(int minor) -{ - return (r_str(minor)); -} - -static inline void -init_ti_parallel(int minor) -{ - outbyte(3, minor); -} - -/* ----- global defines ----------------------------------------------- */ - -#define START(x) { x = jiffies + (HZ * timeout) / 10; } -#define WAIT(x) { \ - if (time_before((x), jiffies)) return -1; \ - if (need_resched()) schedule(); } - -/* ----- D-bus bit-banging functions ---------------------------------- */ - -/* D-bus protocol (45kbit/s max): - 1 0 0 - _______ ______|______ __________|________ __________ -Red : ________ | ____ | ____ - _ ____________|________ ______|__________ _____ -White: ________ | ______ | _______ -*/ - -/* Try to transmit a byte on the specified port (-1 if error). */ -static int -put_ti_parallel(int minor, unsigned char data) -{ - unsigned int bit; - unsigned long max; - - for (bit = 0; bit < 8; bit++) { - if (data & 1) { - outbyte(2, minor); - START(max); - do { - WAIT(max); - } while (inbyte(minor) & 0x10); - - outbyte(3, minor); - START(max); - do { - WAIT(max); - } while (!(inbyte(minor) & 0x10)); - } else { - outbyte(1, minor); - START(max); - do { - WAIT(max); - } while (inbyte(minor) & 0x20); - - outbyte(3, minor); - START(max); - do { - WAIT(max); - } while (!(inbyte(minor) & 0x20)); - } - - data >>= 1; - udelay(delay); - - if (need_resched()) - schedule(); - } - - return 0; -} - -/* Receive a byte on the specified port or -1 if error. */ -static int -get_ti_parallel(int minor) -{ - unsigned int bit; - unsigned char v, data = 0; - unsigned long max; - - for (bit = 0; bit < 8; bit++) { - START(max); - do { - WAIT(max); - } while ((v = inbyte(minor) & 0x30) == 0x30); - - if (v == 0x10) { - data = (data >> 1) | 0x80; - outbyte(1, minor); - START(max); - do { - WAIT(max); - } while (!(inbyte(minor) & 0x20)); - outbyte(3, minor); - } else { - data = data >> 1; - outbyte(2, minor); - START(max); - do { - WAIT(max); - } while (!(inbyte(minor) & 0x10)); - outbyte(3, minor); - } - - udelay(delay); - if (need_resched()) - schedule(); - } - - return (int) data; -} - -/* Try to detect a parallel link cable on the specified port */ -static int -probe_ti_parallel(int minor) -{ - int i; - int seq[] = { 0x00, 0x20, 0x10, 0x30 }; - int data; - - for (i = 3; i >= 0; i--) { - outbyte(3, minor); - outbyte(i, minor); - udelay(delay); - data = inbyte(minor) & 0x30; - pr_debug("tipar: Probing -> %i: 0x%02x 0x%02x\n", i, - data, seq[i]); - if (data != seq[i]) { - outbyte(3, minor); - return -1; - } - } - - outbyte(3, minor); - return 0; -} - -/* ----- kernel module functions--------------------------------------- */ - -static int -tipar_open(struct inode *inode, struct file *file) -{ - unsigned int minor = iminor(inode) - TIPAR_MINOR; - - if (tp_count == 0 || minor > tp_count - 1) - return -ENXIO; - - if (test_and_set_bit(minor, &opened)) - return -EBUSY; - - if (!table[minor].dev) { - printk(KERN_ERR "%s: NULL device for minor %u\n", - __FUNCTION__, minor); - return -ENXIO; - } - parport_claim_or_block(table[minor].dev); - init_ti_parallel(minor); - parport_release(table[minor].dev); - - return nonseekable_open(inode, file); -} - -static int -tipar_close(struct inode *inode, struct file *file) -{ - unsigned int minor = iminor(inode) - TIPAR_MINOR; - - if (minor > tp_count - 1) - return -ENXIO; - - clear_bit(minor, &opened); - - return 0; -} - -static ssize_t -tipar_write (struct file *file, const char __user *buf, size_t count, - loff_t * ppos) -{ - unsigned int minor = iminor(file->f_path.dentry->d_inode) - TIPAR_MINOR; - ssize_t n; - - parport_claim_or_block(table[minor].dev); - - for (n = 0; n < count; n++) { - unsigned char b; - - if (get_user(b, buf + n)) { - n = -EFAULT; - goto out; - } - - if (put_ti_parallel(minor, b) == -1) { - init_ti_parallel(minor); - n = -ETIMEDOUT; - goto out; - } - } - out: - parport_release(table[minor].dev); - return n; -} - -static ssize_t -tipar_read(struct file *file, char __user *buf, size_t count, loff_t * ppos) -{ - int b = 0; - unsigned int minor = iminor(file->f_path.dentry->d_inode) - TIPAR_MINOR; - ssize_t retval = 0; - ssize_t n = 0; - - if (count == 0) - return 0; - - parport_claim_or_block(table[minor].dev); - - while (n < count) { - b = get_ti_parallel(minor); - if (b == -1) { - init_ti_parallel(minor); - retval = -ETIMEDOUT; - goto out; - } else { - if (put_user(b, buf + n)) { - retval = -EFAULT; - break; - } else - retval = ++n; - } - - /* Non-blocking mode : try again ! */ - if (file->f_flags & O_NONBLOCK) { - retval = -EAGAIN; - goto out; - } - - /* Signal pending, try again ! */ - if (signal_pending(current)) { - retval = -ERESTARTSYS; - goto out; - } - - if (need_resched()) - schedule(); - } - - out: - parport_release(table[minor].dev); - return retval; -} - -static int -tipar_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -{ - int retval = 0; - - switch (cmd) { - case IOCTL_TIPAR_DELAY: - delay = (int)arg; //get_user(delay, &arg); - break; - case IOCTL_TIPAR_TIMEOUT: - if (arg != 0) - timeout = (int)arg; - else - retval = -EINVAL; - break; - default: - retval = -ENOTTY; - break; - } - - return retval; -} - -/* ----- kernel module registering ------------------------------------ */ - -static const struct file_operations tipar_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .read = tipar_read, - .write = tipar_write, - .ioctl = tipar_ioctl, - .open = tipar_open, - .release = tipar_close, -}; - -/* --- initialisation code ------------------------------------- */ - -#ifndef MODULE -/* You must set these - there is no sane way to probe for this cable. - * You can use 'tipar=timeout,delay' to set these now. */ -static int __init -tipar_setup(char *str) -{ - int ints[3]; - - str = get_options(str, ARRAY_SIZE(ints), ints); - - if (ints[0] > 0) { - if (ints[1] != 0) - timeout = ints[1]; - else - printk(KERN_WARNING "tipar: bad timeout value (0), " - "using default value instead"); - if (ints[0] > 1) { - delay = ints[2]; - } - } - - return 1; -} -#endif - -/* - * Register our module into parport. - * Pass also 2 callbacks functions to parport: a pre-emptive function and an - * interrupt handler function (unused). - * Display a message such "tipar0: using parport0 (polling)". - */ -static int -tipar_register(int nr, struct parport *port) -{ - int err = 0; - - /* Register our module into parport */ - table[nr].dev = parport_register_device(port, "tipar", - NULL, NULL, NULL, 0, - (void *) &table[nr]); - - if (table[nr].dev == NULL) { - err = 1; - goto out; - } - - device_create(tipar_class, port->dev, MKDEV(TIPAR_MAJOR, - TIPAR_MINOR + nr), "par%d", nr); - - /* Display informations */ - pr_info("tipar%d: using %s (%s)\n", nr, port->name, (port->irq == - PARPORT_IRQ_NONE) ? "polling" : "interrupt-driven"); - - if (probe_ti_parallel(nr) != -1) - pr_info("tipar%d: link cable found\n", nr); - else - pr_info("tipar%d: link cable not found\n", nr); - - err = 0; - -out: - return err; -} - -static void -tipar_attach(struct parport *port) -{ - if (tp_count == PP_NO) { - pr_info("tipar: ignoring parallel port (max. %d)\n", PP_NO); - return; - } - - if (!tipar_register(tp_count, port)) - tp_count++; -} - -static void -tipar_detach(struct parport *port) -{ - /* Nothing to do */ -} - -static struct parport_driver tipar_driver = { - .name = "tipar", - .attach = tipar_attach, - .detach = tipar_detach, -}; - -static int __init -tipar_init_module(void) -{ - int err = 0; - - pr_info("tipar: parallel link cable driver, version %s\n", - DRIVER_VERSION); - - if (register_chrdev(TIPAR_MAJOR, "tipar", &tipar_fops)) { - printk(KERN_ERR "tipar: unable to get major %d\n", TIPAR_MAJOR); - err = -EIO; - goto out; - } - - tipar_class = class_create(THIS_MODULE, "ticables"); - if (IS_ERR(tipar_class)) { - err = PTR_ERR(tipar_class); - goto out_chrdev; - } - if (parport_register_driver(&tipar_driver)) { - printk(KERN_ERR "tipar: unable to register with parport\n"); - err = -EIO; - goto out_class; - } - - err = 0; - goto out; - -out_class: - class_destroy(tipar_class); - -out_chrdev: - unregister_chrdev(TIPAR_MAJOR, "tipar"); -out: - return err; -} - -static void __exit -tipar_cleanup_module(void) -{ - unsigned int i; - - /* Unregistering module */ - parport_unregister_driver(&tipar_driver); - - unregister_chrdev(TIPAR_MAJOR, "tipar"); - - for (i = 0; i < PP_NO; i++) { - if (table[i].dev == NULL) - continue; - parport_unregister_device(table[i].dev); - device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, i)); - } - class_destroy(tipar_class); - - pr_info("tipar: module unloaded\n"); -} - -/* --------------------------------------------------------------------- */ - -__setup("tipar=", tipar_setup); -module_init(tipar_init_module); -module_exit(tipar_cleanup_module); - -MODULE_AUTHOR(DRIVER_AUTHOR); -MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE(DRIVER_LICENSE); - -module_param(timeout, int, 0); -MODULE_PARM_DESC(timeout, "Timeout (default=1.5 seconds)"); -module_param(delay, int, 0); -MODULE_PARM_DESC(delay, "Inter-bit delay (default=10 microseconds)"); -- cgit v1.2.3 From bb44609361fe87c5e136c2b8dfde59bcbdbabf61 Mon Sep 17 00:00:00 2001 From: Gary Hade Date: Tue, 11 Dec 2007 17:09:13 -0800 Subject: PCI: Restore PCI expansion ROM P2P prefetch window creation Restore PCI expansion ROM P2P prefetch window creation. This patch reverts previous "Avoid creating P2P prefetch window for expansion ROMs" change due to regressions that were spotted on some systems. Signed-off-by: Gary Hade Signed-off-by: Greg Kroah-Hartman --- drivers/pci/probe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index c2f8a78c894..2f75d695eed 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -276,7 +276,8 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) sz = pci_size(l, sz, (u32)PCI_ROM_ADDRESS_MASK); if (sz) { res->flags = (l & IORESOURCE_ROM_ENABLE) | - IORESOURCE_MEM | IORESOURCE_READONLY; + IORESOURCE_MEM | IORESOURCE_PREFETCH | + IORESOURCE_READONLY | IORESOURCE_CACHEABLE; res->start = l & PCI_ROM_ADDRESS_MASK; res->end = res->start + (unsigned long) sz; } -- cgit v1.2.3 From b9e13ac30f850313be9232497ff98e90c43bc6b6 Mon Sep 17 00:00:00 2001 From: "agilmore@wirelessbeehive.com" Date: Tue, 4 Dec 2007 11:37:12 -0700 Subject: USB: sierra: fix product id Attached is a patch to fix the addition of the new product ids I sent. It is against 2.6.24-rc4, as Linus included the broken version of the patch I sent you in that tree. :( Not sure if this is the right method to go about this, but hopefully I got it right this time. Signed-off-by: Andrew Gilmore CC: Kevin Lloyd Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/sierra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 605ebccdcd5..e5c274044a5 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -100,6 +100,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ + { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ @@ -137,7 +138,6 @@ static struct usb_device_id id_table_3port [] = { { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ - { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U*/ -- cgit v1.2.3 From 33abc04f0420dceed0ebc2d1094019d3bb2b5c29 Mon Sep 17 00:00:00 2001 From: Doug Maxey Date: Wed, 5 Dec 2007 23:36:45 -0600 Subject: usb-storage: Fix devices that cannot handle 32k transfers When a device cannot handle the smallest previously limited transfer size (64 blocks) without stalling, limit the device to the amount of packets that fit in a platform native page. The lowest possible limit is PAGE_CACHE_SIZE, so if the device is ever used on a platform that has larger than 8K pages, you lose unless you can convince the device firmware folks to fix the issue. Cc: Mathew Dharm Cc: Alan Stern Cc: Pete Zaitcev Signed-off-by: Doug Maxey Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/scsiglue.c | 12 +++++++++--- drivers/usb/storage/unusual_devs.h | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 836a34ae6ec..7c9593b7b04 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -114,9 +114,15 @@ static int slave_configure(struct scsi_device *sdev) * while others have trouble with more than 64K. At this time we * are limiting both to 32K (64 sectores). */ - if ((us->flags & US_FL_MAX_SECTORS_64) && - sdev->request_queue->max_sectors > 64) - blk_queue_max_sectors(sdev->request_queue, 64); + if (us->flags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) { + unsigned int max_sectors = 64; + + if (us->flags & US_FL_MAX_SECTORS_MIN) + max_sectors = PAGE_CACHE_SIZE >> 9; + if (sdev->request_queue->max_sectors > max_sectors) + blk_queue_max_sectors(sdev->request_queue, + max_sectors); + } /* We can't put these settings in slave_alloc() because that gets * called before the device type is known. Consequently these diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 2c27721bd25..7bbfd31a964 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -376,6 +376,13 @@ UNUSUAL_DEV( 0x04b0, 0x0417, 0x0100, 0x0100, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_CAPACITY), +/* Reported by Doug Maxey (dwm@austin.ibm.com) */ +UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110, + "IBM", + "IBM RSA2", + US_SC_DEVICE, US_PR_CB, NULL, + US_FL_MAX_SECTORS_MIN), + /* BENQ DC5330 * Reported by Manuel Fombuena and * Frank Copeland */ -- cgit v1.2.3 From 8be27c2de64e95c3da12a4b002f623570b039874 Mon Sep 17 00:00:00 2001 From: Jeff Long Date: Wed, 28 Nov 2007 11:02:09 -0500 Subject: USB: cp2101: new device id This adds a device ID for the Aerocomm Radio Modem, which uses the cp2102. I'm sure changing num_bulk_in/num_bulk_out to NUM_DONT_CARE is the wrong fix, but this is the only device I have with a cp2102, so I have no idea what a good global value would be, if there is one. Zero didn't work with this device. From: Jeff Long Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/cp2101.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 3a83cb4c4bc..da16b515781 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c @@ -71,6 +71,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ + { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ @@ -98,8 +99,8 @@ static struct usb_serial_driver cp2101_device = { .usb_driver = &cp2101_driver, .id_table = id_table, .num_interrupt_in = 0, - .num_bulk_in = 0, - .num_bulk_out = 0, + .num_bulk_in = NUM_DONT_CARE, + .num_bulk_out = NUM_DONT_CARE, .num_ports = 1, .open = cp2101_open, .close = cp2101_close, -- cgit v1.2.3 From b5ce18afecda8ce1a9ed5fb8ec6362df6f6f85b8 Mon Sep 17 00:00:00 2001 From: Jaime Velasco Juan Date: Fri, 30 Nov 2007 16:30:11 +0000 Subject: USB: option: Bind to the correct interface of the Huawei E220 This fixes a bunch of problems we are having with the Huawei devices... Signed-off-by: Oliver Neukum Signed-off-by: Jaime Velasco Juan Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 4590124cf88..d1185f53447 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -158,8 +158,8 @@ static struct usb_device_id option_ids[] = { { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_NETWORK) }, { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, - { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220) }, - { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS) }, + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) }, { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1100) }, /* Novatel Merlin XS620/S640 */ { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1110) }, /* Novatel Merlin S620 */ { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1120) }, /* Novatel Merlin EX720 */ -- cgit v1.2.3 From d48bd977e0dd8c17081d12242bfc09d743ea0d26 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 11 Dec 2007 16:02:23 -0500 Subject: USB: fix locking loop by avoiding flush_scheduled_work This patch (as1027) replaces a call to flush_scheduled_work() -- a dangerous routine to invoke, especially while holding any sort of lock -- with calls to cancel_work_sync() and cancel_delayed_work_sync(). This fixes Bugzilla #9532. Signed-off-by: Alan Stern CC: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 13b326a1337..b04d232d4c6 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -522,9 +522,9 @@ static void hub_quiesce(struct usb_hub *hub) /* (blocking) stop khubd and related activity */ usb_kill_urb(hub->urb); if (hub->has_indicators) - cancel_delayed_work(&hub->leds); - if (hub->has_indicators || hub->tt.hub) - flush_scheduled_work(); + cancel_delayed_work_sync(&hub->leds); + if (hub->tt.hub) + cancel_work_sync(&hub->tt.kevent); } static void hub_activate(struct usb_hub *hub) -- cgit v1.2.3 From 442258e2ff69276ff767f3703b30ce6a31fdd181 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 6 Dec 2007 14:47:08 -0500 Subject: USB: use IRQF_DISABLED for HCD interrupt handlers Host controller IRQs are supposed to be serviced with interrupts disabled. This patch (as1026) adds an IRQF_DISABLED flag to all the controller drivers that lack it. It also replaces the spin_lock_irqsave() and spin_unlock_irqrestore() calls in uhci_irq() with simple spin_lock() and spin_unlock(). This fixes Bugzilla #9335. Signed-off-by: Alan Stern Acked-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd-pci.c | 2 +- drivers/usb/host/ehci-fsl.c | 2 +- drivers/usb/host/ohci-ppc-of.c | 2 +- drivers/usb/host/ohci-ssb.c | 2 +- drivers/usb/host/r8a66597-hcd.c | 2 +- drivers/usb/host/uhci-hcd.c | 9 ++++----- 6 files changed, 9 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 5cf6d5f9acb..3fb9af80cbf 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -125,7 +125,7 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) pci_set_master (dev); - retval = usb_add_hcd (hcd, dev->irq, IRQF_SHARED); + retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); if (retval != 0) goto err4; return retval; diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index b7b7bfbce52..430821cb95c 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -122,7 +122,7 @@ int usb_hcd_fsl_probe(const struct hc_driver *driver, temp = in_le32(hcd->regs + 0x1a8); out_le32(hcd->regs + 0x1a8, temp | 0x3); - retval = usb_add_hcd(hcd, irq, IRQF_SHARED); + retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); if (retval != 0) goto err4; return retval; diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c index 0a742692015..0c3e6b790b7 100644 --- a/drivers/usb/host/ohci-ppc-of.c +++ b/drivers/usb/host/ohci-ppc-of.c @@ -142,7 +142,7 @@ ohci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) ohci_hcd_init(ohci); - rv = usb_add_hcd(hcd, irq, 0); + rv = usb_add_hcd(hcd, irq, IRQF_DISABLED); if (rv == 0) return 0; diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c index fe70e72340d..6e9c2d6db88 100644 --- a/drivers/usb/host/ohci-ssb.c +++ b/drivers/usb/host/ohci-ssb.c @@ -160,7 +160,7 @@ static int ssb_ohci_attach(struct ssb_device *dev) hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) goto err_put_hcd; - err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED); + err = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); if (err) goto err_iounmap; diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index ae8ec4474eb..0ce2fc5e396 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c @@ -2197,7 +2197,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) INIT_LIST_HEAD(&r8a66597->child_device); hcd->rsrc_start = res->start; - ret = usb_add_hcd(hcd, irq, 0); + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); if (ret != 0) { err("Failed to add hcd"); goto clean_up; diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 4db17f75f4f..ec987897b8e 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -378,7 +378,6 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd) { struct uhci_hcd *uhci = hcd_to_uhci(hcd); unsigned short status; - unsigned long flags; /* * Read the interrupt status, and write it back to clear the @@ -398,7 +397,7 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd) dev_err(uhci_dev(uhci), "host controller process " "error, something bad happened!\n"); if (status & USBSTS_HCH) { - spin_lock_irqsave(&uhci->lock, flags); + spin_lock(&uhci->lock); if (uhci->rh_state >= UHCI_RH_RUNNING) { dev_err(uhci_dev(uhci), "host controller halted, " @@ -415,16 +414,16 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd) * pending unlinks */ mod_timer(&hcd->rh_timer, jiffies); } - spin_unlock_irqrestore(&uhci->lock, flags); + spin_unlock(&uhci->lock); } } if (status & USBSTS_RD) usb_hcd_poll_rh_status(hcd); else { - spin_lock_irqsave(&uhci->lock, flags); + spin_lock(&uhci->lock); uhci_scan_schedule(uhci); - spin_unlock_irqrestore(&uhci->lock, flags); + spin_unlock(&uhci->lock); } return IRQ_HANDLED; -- cgit v1.2.3 From 08cbc706acd2dd601b0663e28fa97ffb0564e105 Mon Sep 17 00:00:00 2001 From: Nicolas Ferre Date: Thu, 13 Dec 2007 15:52:58 -0800 Subject: USB: at91_udc: correct hanging while disconnecting usb cable Correct hanging while disconnecting the USB device cable. Prevent a race between vbus and UDP interrupts. This bug was tracked on at91sam9260ek boards. A usb resume interrupt was firing after the vbus interrupt : the IP was then already stoped and not able to deal with it (no more clock). A simple interrupt disabling is ok as the "end of bus reset" irq is non maskable and ok to resume the USB device IP. Signed-off-by: Nicolas Ferre Acked-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/at91_udc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index a6adf7e0f6f..cd62b029d17 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -887,6 +887,7 @@ static void pullup(struct at91_udc *udc, int is_on) if (is_on) { clk_on(udc); + at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM); at91_udp_write(udc, AT91_UDP_TXVC, 0); if (cpu_is_at91rm9200()) at91_set_gpio_value(udc->board.pullup_pin, 1); @@ -904,6 +905,7 @@ static void pullup(struct at91_udc *udc, int is_on) } } else { stop_activity(udc); + at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM); at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); if (cpu_is_at91rm9200()) at91_set_gpio_value(udc->board.pullup_pin, 0); -- cgit v1.2.3 From 565227c08226e458da191518251dbff6831624c2 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Thu, 6 Dec 2007 13:28:25 -0800 Subject: usb: Remove broken optimisation in OHCI IRQ handler The OHCI IRQ handler has an optimisation that avoids reading some chip registers when the controller reports that the interrupt was triggered *only* because completed requests were written into the controller's "done list" and handed to the host. This mechanism can't be used on some controllers. Among others, it fails for the SA1111 and the AMCC 440EP PowerPC processor. This patch removes the optimisation and makes the code clearer. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-hcd.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 704f33fdd2f..ecfe800fd72 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -732,24 +732,27 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) struct ohci_regs __iomem *regs = ohci->regs; int ints; - /* we can eliminate a (slow) ohci_readl() - * if _only_ WDH caused this irq + /* Read interrupt status (and flush pending writes). We ignore the + * optimization of checking the LSB of hcca->done_head; it doesn't + * work on all systems (edge triggering for OHCI can be a factor). */ - if ((ohci->hcca->done_head != 0) - && ! (hc32_to_cpup (ohci, &ohci->hcca->done_head) - & 0x01)) { - ints = OHCI_INTR_WDH; + ints = ohci_readl(ohci, ®s->intrstatus); - /* cardbus/... hardware gone before remove() */ - } else if ((ints = ohci_readl (ohci, ®s->intrstatus)) == ~(u32)0) { + /* Check for an all 1's result which is a typical consequence + * of dead, unclocked, or unplugged (CardBus...) devices + */ + if (ints == ~(u32)0) { disable (ohci); ohci_dbg (ohci, "device removed!\n"); return IRQ_HANDLED; + } + + /* We only care about interrupts that are enabled */ + ints &= ohci_readl(ohci, ®s->intrenable); /* interrupt for some other device? */ - } else if ((ints &= ohci_readl (ohci, ®s->intrenable)) == 0) { + if (ints == 0) return IRQ_NOTMINE; - } if (ints & OHCI_INTR_UE) { // e.g. due to PCI Master/Target Abort -- cgit v1.2.3 From e70e7690b66dc06fe2ad9058e696e18fe7f3faa6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 14 Dec 2007 19:18:31 -0500 Subject: USB: revert portions of "UNUSUAL_DEV: Sync up some reported devices from Ubuntu" This reverts one change from 67fa10627ec0d8aa16f1cf38cf527e67d8097d3c that prevented userspace from seing the "driver disk" lun in a san disk device. The kernel shouldn't do this, it's up to userspace to handle this properly, if it somehow wants to filter this away. Cc: Ben Collins Cc: Alan Stern Cc: Phil Dibowitz Cc: Kyle McMartin Cc: Matthew Dharm Cc: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 7bbfd31a964..6d6108b3993 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -1265,14 +1265,6 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_IGNORE_DEVICE ), -/* SanDisk that has a second LUN for a driver ISO, reported by - * Ben Collins */ -UNUSUAL_DEV( 0x0781, 0x5406, 0x0000, 0xffff, - "SanDisk", - "U3 Cruzer Micro driver ISO", - US_SC_DEVICE, US_PR_DEVICE, NULL, - US_FL_SINGLE_LUN ), - #ifdef CONFIG_USB_STORAGE_ISD200 UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, "ATI", -- cgit v1.2.3 From 7a1fd330571530d44261bf8e9ee63b880f2bb4db Mon Sep 17 00:00:00 2001 From: Komuro Date: Mon, 17 Dec 2007 22:22:31 +0900 Subject: pcnet_cs: add new id add new id: Planex CF-10T Signed-off-by: Komuro Signed-off-by: Jeff Garzik --- drivers/net/pcmcia/pcnet_cs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index db6a97d1d7b..51bbd582f16 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -1746,6 +1746,7 @@ static struct pcmcia_device_id pcnet_ids[] = { PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "NE2K.cis"), PCMCIA_DEVICE_CIS_PROD_ID12("PMX ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "PE-200.cis"), PCMCIA_DEVICE_CIS_PROD_ID12("TAMARACK", "Ethernet", 0xcf434fba, 0x00b2e941, "tamarack.cis"), + PCMCIA_DEVICE_PROD_ID12("Ethernet", "CF Size PC Card", 0x00b2e941, 0x43ac239b), PCMCIA_DEVICE_PROD_ID123("Fast Ethernet", "CF Size PC Card", "1.0", 0xb4be14e3, 0x43ac239b, 0x0877b627), PCMCIA_DEVICE_NULL -- cgit v1.2.3 From 87e417b2f3a061d5eb85906288738f4313f1d924 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Mon, 17 Dec 2007 14:54:35 +0300 Subject: ucc_geth: really fix section mismatch Commit ed7e63a51d46e835422d89c687b8a3e419a4212a has tried to fix section mismatch: WARNING: vmlinux.o(.init.text+0x17278): Section mismatch: reference to .exit.text:uec_mdio_exit (between 'ucc_geth_init' and 'uec_mdio_init') But that mismatch still happens. This patch actually fixing section mismatch by removing __exit from the header file. Signed-off-by: Anton Vorontsov Signed-off-by: Jeff Garzik --- drivers/net/ucc_geth_mii.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/ucc_geth_mii.h b/drivers/net/ucc_geth_mii.h index d8343703991..1e45b2028a5 100644 --- a/drivers/net/ucc_geth_mii.h +++ b/drivers/net/ucc_geth_mii.h @@ -96,5 +96,5 @@ enum enet_tbi_mii_reg { int uec_mdio_read(struct mii_bus *bus, int mii_id, int regnum); int uec_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value); int __init uec_mdio_init(void); -void __exit uec_mdio_exit(void); +void uec_mdio_exit(void); #endif /* __UEC_MII_H */ -- cgit v1.2.3 From 961994a0c2a24d9622eea7144b30ac773169659f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 15 Dec 2007 01:44:33 +0000 Subject: sis190 endianness Check in sis190_rx_interrupt() is broken on big-endian (desc->status is little-endian and everything else actually uses it correctly, including other checks for OWNbit. Signed-off-by: Al Viro Signed-off-by: Jeff Garzik --- drivers/net/sis190.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c index 49f767bef6a..7eab072ae79 100644 --- a/drivers/net/sis190.c +++ b/drivers/net/sis190.c @@ -474,7 +474,7 @@ static inline void sis190_map_to_asic(struct RxDesc *desc, dma_addr_t mapping, static inline void sis190_make_unusable_by_asic(struct RxDesc *desc) { desc->PSize = 0x0; - desc->addr = 0xdeadbeef; + desc->addr = cpu_to_le32(0xdeadbeef); desc->size &= cpu_to_le32(RingEnd); wmb(); desc->status = 0x0; @@ -580,7 +580,7 @@ static int sis190_rx_interrupt(struct net_device *dev, struct RxDesc *desc = tp->RxDescRing + entry; u32 status; - if (desc->status & OWNbit) + if (le32_to_cpu(desc->status) & OWNbit) break; status = le32_to_cpu(desc->PSize); @@ -1538,9 +1538,9 @@ static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev, /* Get MAC address from EEPROM */ for (i = 0; i < MAC_ADDR_LEN / 2; i++) { - __le16 w = sis190_read_eeprom(ioaddr, EEPROMMACAddr + i); + u16 w = sis190_read_eeprom(ioaddr, EEPROMMACAddr + i); - ((u16 *)dev->dev_addr)[i] = le16_to_cpu(w); + ((__le16 *)dev->dev_addr)[i] = cpu_to_le16(w); } sis190_set_rgmii(tp, sis190_read_eeprom(ioaddr, EEPROMInfo)); -- cgit v1.2.3 From 9313794371ad39e6bf88e1fbef8dfb3bd1ae3fe7 Mon Sep 17 00:00:00 2001 From: Ulrich Kunitz Date: Sat, 1 Dec 2007 11:26:05 +0100 Subject: zd1211rw: Fix alignment problems Shaddy Baddah found an alignment problem with zd1211rw driver at 2007-11-19. This patch fixes it, it is based on the patch proposed by Herbert Xu. The alignment 4 has been the agreed value on the linux-wireless mailing list. Notify that the problem does only affect the old zd1211rw softmac driver and not the zd1211rw-mac80211 driver. Daniel Drake has already provided a patch for the replacement of the softmac driver, which this patch will break. Signed-off-by: Ulrich Kunitz Signed-off-by: John W. Linville --- drivers/net/wireless/zd1211rw/zd_mac.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index a903645e157..5298a8bf112 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c @@ -1130,6 +1130,8 @@ static void zd_mac_rx(struct zd_mac *mac, struct sk_buff *skb) __skb_trim(skb, skb->len - (IEEE80211_FCS_LEN + sizeof(struct rx_status))); + ZD_ASSERT(IS_ALIGNED((unsigned long)skb->data, 4)); + update_qual_rssi(mac, skb->data, skb->len, stats.signal, status->signal_strength); @@ -1166,15 +1168,19 @@ static void do_rx(unsigned long mac_ptr) int zd_mac_rx_irq(struct zd_mac *mac, const u8 *buffer, unsigned int length) { struct sk_buff *skb; + unsigned int reserved = + ALIGN(max_t(unsigned int, + sizeof(struct zd_rt_hdr), ZD_PLCP_HEADER_SIZE), 4) - + ZD_PLCP_HEADER_SIZE; - skb = dev_alloc_skb(sizeof(struct zd_rt_hdr) + length); + skb = dev_alloc_skb(reserved + length); if (!skb) { struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); dev_warn(zd_mac_dev(mac), "Could not allocate skb.\n"); ieee->stats.rx_dropped++; return -ENOMEM; } - skb_reserve(skb, sizeof(struct zd_rt_hdr)); + skb_reserve(skb, reserved); memcpy(__skb_put(skb, length), buffer, length); skb_queue_tail(&mac->rx_queue, skb); tasklet_schedule(&mac->rx_tasklet); -- cgit v1.2.3 From 2ef19e63e698d740661e04bd6d62ac3305435c61 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 11 Dec 2007 23:20:22 +0100 Subject: wireless/ipw2200.c: add __dev{init,exit} annotations This patch adds __dev{init,exit} annotations. Signed-off-by: Adrian Bunk Signed-off-by: John W. Linville --- drivers/net/wireless/ipw2200.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index 54f44e5473c..da51f477e9d 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -10751,7 +10751,7 @@ static void ipw_bg_link_down(struct work_struct *work) mutex_unlock(&priv->mutex); } -static int ipw_setup_deferred_work(struct ipw_priv *priv) +static int __devinit ipw_setup_deferred_work(struct ipw_priv *priv) { int ret = 0; @@ -11600,7 +11600,8 @@ static void ipw_prom_free(struct ipw_priv *priv) #endif -static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +static int __devinit ipw_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) { int err = 0; struct net_device *net_dev; @@ -11767,7 +11768,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return err; } -static void ipw_pci_remove(struct pci_dev *pdev) +static void __devexit ipw_pci_remove(struct pci_dev *pdev) { struct ipw_priv *priv = pci_get_drvdata(pdev); struct list_head *p, *q; -- cgit v1.2.3 From a5acc379e52c78db407c73537daff387b179202c Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 13 Dec 2007 15:52:12 -0800 Subject: iwlwifi3945/4965: fix rate control algo reference leak Fix rate control algo reference leak in case if network device has been failed to register. In this case special flag priv->mac80211_registered is not set and the rate algo reference is not freeing on module unload. That leads to OOPs in further ieee80211 rate register/unregister procedure (by any callee). It should fix the bug #9470 http://bugzilla.kernel.org/show_bug.cgi?id=9470 [akpm@linux-foundation.org: build fix] Signed-off-by: Cyrill Gorcunov Acked-by: Zhu Yi Signed-off-by: Andrew Morton Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl3945-base.c | 1 + drivers/net/wireless/iwlwifi/iwl4965-base.c | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 4bdf237f6ad..1c3ca6ebdc4 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c @@ -6171,6 +6171,7 @@ static void iwl_alive_start(struct iwl_priv *priv) mutex_lock(&priv->mutex); if (rc) { + iwl_rate_control_unregister(priv->hw); IWL_ERROR("Failed to register network " "device (error %d)\n", rc); return; diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 8f85564ec6f..3b31607a27f 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c @@ -6527,6 +6527,7 @@ static void iwl_alive_start(struct iwl_priv *priv) mutex_lock(&priv->mutex); if (rc) { + iwl_rate_control_unregister(priv->hw); IWL_ERROR("Failed to register network " "device (error %d)\n", rc); return; -- cgit v1.2.3 From aaf44a06b7c4864d93660e04701a72153197932c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 13 Dec 2007 15:52:12 -0800 Subject: libertas: select WIRELESS_EXT Ensure that libertas selects WIRELESS_EXT, since selecting other stuff that should depend on WEXT, like IEEE80211, doesn't seem to drag that in for us. Signed-off-by: Dan Williams Signed-off-by: Andrew Morton Signed-off-by: John W. Linville --- drivers/net/wireless/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index 2b733c58291..5583719a0dc 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig @@ -264,6 +264,7 @@ config IPW2200_DEBUG config LIBERTAS tristate "Marvell 8xxx Libertas WLAN driver support" depends on WLAN_80211 + select WIRELESS_EXT select IEEE80211 select FW_LOADER ---help--- -- cgit v1.2.3 From cb935cb4bd155d50ac98617b580aadd9d7ef3a0f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 13 Dec 2007 15:52:13 -0800 Subject: bcm43xx_debugfs sscanf fix ia64: drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c: In function `tsf_write_file': drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c:237: warning: long long int format, u64 arg (arg 3) drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c:237: warning: long long int format, u64 arg (arg 3) We do not know what type was used to implement u64 and we can never use u64 in printk(), sscanf(), etc. Cc: Michael Buesch Signed-off-by: Andrew Morton Signed-off-by: John W. Linville --- drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c index 35dbe455451..76e9dd843fa 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c @@ -219,7 +219,7 @@ static ssize_t tsf_write_file(struct file *file, const char __user *user_buf, ssize_t buf_size; ssize_t res; unsigned long flags; - u64 tsf; + unsigned long long tsf; buf_size = min(count, sizeof (really_big_buffer) - 1); down(&big_buffer_sem); -- cgit v1.2.3 From 1a8d122782bdabe4475f29d022c9a0c092ac9878 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 14 Dec 2007 13:59:11 +0100 Subject: b43: Fix rfkill radio LED This fixes Bug #9414 Since addition of the rfkill callback, the LED associated with the off switch on the radio has not worked for several reasons: (1) Essential data in the rfkill structure were missing. (2) The rfkill structure was initialized after the LED initialization. (3) There was a minor memory leak if the radio LED structure was inited. Once the above problems were fixed, additional difficulties were noted: (4) The radio LED was in the wrong state at startup. (5) The radio switch had to be manipulated twice for each state change. (6) A circular mutex locking situation existed. (7) If rfkill-input is built as a module, it is not automatically loaded. This patch fixes all of the above. Signed-off-by: Larry Finger Signed-off-by: Michael Buesch Signed-off-by: John W. Linville --- drivers/net/wireless/b43/leds.c | 4 ++++ drivers/net/wireless/b43/main.c | 22 +++++++++++----------- drivers/net/wireless/b43/rfkill.c | 37 ++++++++++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c index 19e588582c7..6c0e2b9f776 100644 --- a/drivers/net/wireless/b43/leds.c +++ b/drivers/net/wireless/b43/leds.c @@ -163,6 +163,9 @@ static void b43_map_led(struct b43_wldev *dev, b43_register_led(dev, &dev->led_radio, name, b43_rfkill_led_name(dev), led_index, activelow); + /* Sync the RF-kill LED state with the switch state. */ + if (dev->radio_hw_enable) + b43_led_turn_on(dev, led_index, activelow); break; case B43_LED_WEIRD: case B43_LED_ASSOC: @@ -232,4 +235,5 @@ void b43_leds_exit(struct b43_wldev *dev) b43_unregister_led(&dev->led_tx); b43_unregister_led(&dev->led_rx); b43_unregister_led(&dev->led_assoc); + b43_unregister_led(&dev->led_radio); } diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index b45eecc53c4..1c93b4f4bfe 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c @@ -2163,7 +2163,6 @@ static void b43_mgmtframe_txantenna(struct b43_wldev *dev, int antenna) static void b43_chip_exit(struct b43_wldev *dev) { b43_radio_turn_off(dev, 1); - b43_leds_exit(dev); b43_gpio_cleanup(dev); /* firmware is released later */ } @@ -2191,11 +2190,10 @@ static int b43_chip_init(struct b43_wldev *dev) err = b43_gpio_init(dev); if (err) goto out; /* firmware is released later */ - b43_leds_init(dev); err = b43_upload_initvals(dev); if (err) - goto err_leds_exit; + goto err_gpio_clean; b43_radio_turn_on(dev); b43_write16(dev, 0x03E6, 0x0000); @@ -2271,8 +2269,7 @@ out: err_radio_off: b43_radio_turn_off(dev, 1); -err_leds_exit: - b43_leds_exit(dev); +err_gpio_clean: b43_gpio_cleanup(dev); return err; } @@ -3273,10 +3270,7 @@ static void b43_wireless_core_exit(struct b43_wldev *dev) return; b43_set_status(dev, B43_STAT_UNINIT); - mutex_unlock(&dev->wl->mutex); - b43_rfkill_exit(dev); - mutex_lock(&dev->wl->mutex); - + b43_leds_exit(dev); b43_rng_exit(dev->wl); b43_pio_free(dev); b43_dma_free(dev); @@ -3405,12 +3399,12 @@ static int b43_wireless_core_init(struct b43_wldev *dev) memset(wl->mac_addr, 0, ETH_ALEN); b43_upload_card_macaddress(dev); b43_security_init(dev); - b43_rfkill_init(dev); b43_rng_init(wl); b43_set_status(dev, B43_STAT_INITIALIZED); - out: + b43_leds_init(dev); +out: return err; err_chip_exit: @@ -3499,6 +3493,10 @@ static int b43_start(struct ieee80211_hw *hw) int did_init = 0; int err = 0; + /* First register RFkill. + * LEDs that are registered later depend on it. */ + b43_rfkill_init(dev); + mutex_lock(&wl->mutex); if (b43_status(dev) < B43_STAT_INITIALIZED) { @@ -3528,6 +3526,8 @@ static void b43_stop(struct ieee80211_hw *hw) struct b43_wl *wl = hw_to_b43_wl(hw); struct b43_wldev *dev = wl->current_dev; + b43_rfkill_exit(dev); + mutex_lock(&wl->mutex); if (b43_status(dev) >= B43_STAT_STARTED) b43_wireless_core_stop(dev); diff --git a/drivers/net/wireless/b43/rfkill.c b/drivers/net/wireless/b43/rfkill.c index 9b1f905ffbf..98cf70c5fd4 100644 --- a/drivers/net/wireless/b43/rfkill.c +++ b/drivers/net/wireless/b43/rfkill.c @@ -25,6 +25,8 @@ #include "rfkill.h" #include "b43.h" +#include + /* Returns TRUE, if the radio is enabled in hardware. */ static bool b43_is_hw_radio_enabled(struct b43_wldev *dev) @@ -50,7 +52,10 @@ static void b43_rfkill_poll(struct input_polled_dev *poll_dev) bool report_change = 0; mutex_lock(&wl->mutex); - B43_WARN_ON(b43_status(dev) < B43_STAT_INITIALIZED); + if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) { + mutex_unlock(&wl->mutex); + return; + } enabled = b43_is_hw_radio_enabled(dev); if (unlikely(enabled != dev->radio_hw_enable)) { dev->radio_hw_enable = enabled; @@ -60,8 +65,12 @@ static void b43_rfkill_poll(struct input_polled_dev *poll_dev) } mutex_unlock(&wl->mutex); - if (unlikely(report_change)) - input_report_key(poll_dev->input, KEY_WLAN, enabled); + /* send the radio switch event to the system - note both a key press + * and a release are required */ + if (unlikely(report_change)) { + input_report_key(poll_dev->input, KEY_WLAN, 1); + input_report_key(poll_dev->input, KEY_WLAN, 0); + } } /* Called when the RFKILL toggled in software. */ @@ -69,13 +78,15 @@ static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state) { struct b43_wldev *dev = data; struct b43_wl *wl = dev->wl; - int err = 0; + int err = -EBUSY; if (!wl->rfkill.registered) return 0; mutex_lock(&wl->mutex); - B43_WARN_ON(b43_status(dev) < B43_STAT_INITIALIZED); + if (b43_status(dev) < B43_STAT_INITIALIZED) + goto out_unlock; + err = 0; switch (state) { case RFKILL_STATE_ON: if (!dev->radio_hw_enable) { @@ -133,9 +144,25 @@ void b43_rfkill_init(struct b43_wldev *dev) rfk->poll_dev->poll = b43_rfkill_poll; rfk->poll_dev->poll_interval = 1000; /* msecs */ + rfk->poll_dev->input->name = rfk->name; + rfk->poll_dev->input->id.bustype = BUS_HOST; + rfk->poll_dev->input->id.vendor = dev->dev->bus->boardinfo.vendor; + rfk->poll_dev->input->evbit[0] = BIT(EV_KEY); + set_bit(KEY_WLAN, rfk->poll_dev->input->keybit); + err = rfkill_register(rfk->rfkill); if (err) goto err_free_polldev; + +#ifdef CONFIG_RFKILL_INPUT_MODULE + /* B43 RF-kill isn't useful without the rfkill-input subsystem. + * Try to load the module. */ + err = request_module("rfkill-input"); + if (err) + b43warn(wl, "Failed to load the rfkill-input module. " + "The built-in radio LED will not work.\n"); +#endif /* CONFIG_RFKILL_INPUT */ + err = input_register_polled_device(rfk->poll_dev); if (err) goto err_unreg_rfk; -- cgit v1.2.3 From 53e490936a91940a153e231c3b8288e3ecfcc5aa Mon Sep 17 00:00:00 2001 From: Zhu Yi Date: Thu, 6 Dec 2007 16:08:44 +0800 Subject: iwlwifi: fix rf_kill state inconsistent during suspend and resume The patch fixes the STATUS_RF_KILL_HW state is not cleared problem if the device goes to suspend when the rf_kill switch is enabled. The bug causes the driver always thinks the rf_kill switch is enabled (although it is disabled) after resume. Signed-off-by: Zhu Yi Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl3945-base.c | 4 +++- drivers/net/wireless/iwlwifi/iwl4965-base.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 1c3ca6ebdc4..3d1da0759b9 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c @@ -4743,8 +4743,10 @@ static void iwl_irq_tasklet(struct iwl_priv *priv) * when we loaded driver, and is now set to "enable". * After we're Alive, RF_KILL gets handled by * iwl_rx_card_state_notif() */ - if (!hw_rf_kill && !test_bit(STATUS_ALIVE, &priv->status)) + if (!hw_rf_kill && !test_bit(STATUS_ALIVE, &priv->status)) { + clear_bit(STATUS_RF_KILL_HW, &priv->status); queue_work(priv->workqueue, &priv->restart); + } handled |= CSR_INT_BIT_RF_KILL; } diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 3b31607a27f..b54fe5e6d52 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c @@ -5059,8 +5059,10 @@ static void iwl_irq_tasklet(struct iwl_priv *priv) * when we loaded driver, and is now set to "enable". * After we're Alive, RF_KILL gets handled by * iwl_rx_card_state_notif() */ - if (!hw_rf_kill && !test_bit(STATUS_ALIVE, &priv->status)) + if (!hw_rf_kill && !test_bit(STATUS_ALIVE, &priv->status)) { + clear_bit(STATUS_RF_KILL_HW, &priv->status); queue_work(priv->workqueue, &priv->restart); + } handled |= CSR_INT_BIT_RF_KILL; } -- cgit v1.2.3 From 8cf32ac6578a70025be1103466da9d1d6141429e Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 8 Dec 2007 08:45:27 +0900 Subject: sata_sil: fix spurious IRQ handling Interestingly, sata_sil raises spurious interrupts if it's coupled with Sil SATA_PATA bridge. Currently, sata_sil interrupt handler is strict about spurious interrupts and freezes the port when it occurs. This patch makes it more forgiving. * On SATA PHY event interrupt, serror value is checked to see whether it really is PHYRDY CHG event. If not, SATA PHY event interrupt is ignored. * If ATA interrupt occurs while no command is in progress, it's cleared and ignored. This fixes bugzilla bug 9505. http://bugzilla.kernel.org/show_bug.cgi?id=9505 Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/sata_sil.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 4e6e381279c..025622b14ef 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c @@ -390,23 +390,28 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2) sil_scr_read(ap, SCR_ERROR, &serror); sil_scr_write(ap, SCR_ERROR, serror); - /* Trigger hotplug and accumulate SError only if the - * port isn't already frozen. Otherwise, PHY events - * during hardreset makes controllers with broken SIEN - * repeat probing needlessly. + /* Sometimes spurious interrupts occur, double check + * it's PHYRDY CHG. */ - if (!(ap->pflags & ATA_PFLAG_FROZEN)) { - ata_ehi_hotplugged(&ap->link.eh_info); - ap->link.eh_info.serror |= serror; + if (serror & SERR_PHYRDY_CHG) { + /* Trigger hotplug and accumulate SError only + * if the port isn't already frozen. + * Otherwise, PHY events during hardreset + * makes controllers with broken SIEN repeat + * probing needlessly. + */ + if (!(ap->pflags & ATA_PFLAG_FROZEN)) { + ata_ehi_hotplugged(&ap->link.eh_info); + ap->link.eh_info.serror |= serror; + } + goto freeze; } - goto freeze; + if (!(bmdma2 & SIL_DMA_COMPLETE)) + return; } - if (unlikely(!qc)) - goto freeze; - - if (unlikely(qc->tf.flags & ATA_TFLAG_POLLING)) { + if (unlikely(!qc || (qc->tf.flags & ATA_TFLAG_POLLING))) { /* this sometimes happens, just clear IRQ */ ata_chk_status(ap); return; -- cgit v1.2.3 From f7fe7ad4bcaba17f05d5cbf1119772c645783b08 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 8 Dec 2007 08:47:01 +0900 Subject: libata: clear link->eh_info.serror from ata_std_postreset() link->eh_info.serror is used to cache SError for controllers which need it cleared from interrupt handler to clear IRQ. It also should be cleared after reset just like SError itself. Make ata_std_postreset() clear link->eh_info.serror too and update sata_sil such that it doesn't care about bookkeeping the value. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 1 + drivers/ata/sata_sil.c | 11 +---------- 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index e4dea8623a7..b0d1dc3cdb2 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3923,6 +3923,7 @@ void ata_std_postreset(struct ata_link *link, unsigned int *classes) /* clear SError */ if (sata_scr_read(link, SCR_ERROR, &serror) == 0) sata_scr_write(link, SCR_ERROR, serror); + link->eh_info.serror = 0; /* is double-select really necessary? */ if (classes[0] != ATA_DEV_NONE) diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 025622b14ef..f5119bf40c2 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c @@ -394,16 +394,7 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2) * it's PHYRDY CHG. */ if (serror & SERR_PHYRDY_CHG) { - /* Trigger hotplug and accumulate SError only - * if the port isn't already frozen. - * Otherwise, PHY events during hardreset - * makes controllers with broken SIEN repeat - * probing needlessly. - */ - if (!(ap->pflags & ATA_PFLAG_FROZEN)) { - ata_ehi_hotplugged(&ap->link.eh_info); - ap->link.eh_info.serror |= serror; - } + ap->link.eh_info.serror |= serror; goto freeze; } -- cgit v1.2.3 From e41bd3e854e3536de847d5831c0e25a47f394885 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sun, 9 Dec 2007 19:45:39 +0900 Subject: libata: add ST3160023AS / 3.42 to NCQ blacklist Like ST380817AS / 3.42, ST3160023AS / 3.42 times out commands if NCQ is used. Blacklist it. This is reported by Matheus Izvekov in the following thread. http://thread.gmane.org/gmane.linux.ide/24202 Signed-off-by: Tejun Heo Cc: Matheus Izvekov Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index b0d1dc3cdb2..99a18cea316 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4150,6 +4150,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { "HITACHI HDS7250SASUN500G*", NULL, ATA_HORKAGE_NONCQ }, { "HITACHI HDS7225SBSUN250G*", NULL, ATA_HORKAGE_NONCQ }, { "ST380817AS", "3.42", ATA_HORKAGE_NONCQ }, + { "ST3160023AS", "3.42", ATA_HORKAGE_NONCQ }, /* Blacklist entries taken from Silicon Image 3124/3132 Windows driver .inf file - also several Linux problem reports */ -- cgit v1.2.3 From 4e5200334e03e5620aa19d538300c13db270a063 Mon Sep 17 00:00:00 2001 From: Mark Lord Date: Tue, 11 Dec 2007 12:58:05 -0500 Subject: sata_mv: improve warnings about Highpoint RocketRAID 23xx cards Improve the existing boot/load time warnings from sata_mv for Highpoint RocketRAID 23xx cards, based on new knowledge about where the BIOS likes to overwrite sectors with metadata. Harmless to us, but very useful for end users. Signed-off-by: Mark Lord Signed-off-by: Jeff Garzik --- drivers/ata/sata_mv.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index fe0105d35ba..37b850ae084 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c @@ -2506,11 +2506,31 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx) if (pdev->vendor == PCI_VENDOR_ID_TTI && (pdev->device == 0x2300 || pdev->device == 0x2310)) { - printk(KERN_WARNING "sata_mv: Highpoint RocketRAID BIOS" - " will CORRUPT DATA on attached drives when" - " configured as \"Legacy\". BEWARE!\n"); - printk(KERN_WARNING "sata_mv: Use BIOS \"JBOD\" volumes" - " instead for safety.\n"); + /* + * Highpoint RocketRAID PCIe 23xx series cards: + * + * Unconfigured drives are treated as "Legacy" + * by the BIOS, and it overwrites sector 8 with + * a "Lgcy" metadata block prior to Linux boot. + * + * Configured drives (RAID or JBOD) leave sector 8 + * alone, but instead overwrite a high numbered + * sector for the RAID metadata. This sector can + * be determined exactly, by truncating the physical + * drive capacity to a nice even GB value. + * + * RAID metadata is at: (dev->n_sectors & ~0xfffff) + * + * Warn the user, lest they think we're just buggy. + */ + printk(KERN_WARNING DRV_NAME ": Highpoint RocketRAID" + " BIOS CORRUPTS DATA on all attached drives," + " regardless of if/how they are configured." + " BEWARE!\n"); + printk(KERN_WARNING DRV_NAME ": For data safety, do not" + " use sectors 8-9 on \"Legacy\" drives," + " and avoid the final two gigabytes on" + " all RocketRAID BIOS initialized drives.\n"); } case chip_6042: hpriv->ops = &mv6xxx_ops; -- cgit v1.2.3 From 0d02f0b22b678b9d6c8ac8cad7b4cfbbdf6fab18 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 15 Dec 2007 15:04:57 +0900 Subject: libata-acpi: adjust constness in ata_acpi_gtm/stm() parameters * No internal function uses const ata_port. Drop const from @ap. * Make ata_acpi_stm() copy @stm before using it and change @stm to const. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 545ea865ceb..8ae36ad029c 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -200,7 +200,7 @@ void ata_acpi_associate(struct ata_host *host) * RETURNS: * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure. */ -int ata_acpi_gtm(const struct ata_port *ap, struct ata_acpi_gtm *gtm) +int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm) { struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER }; union acpi_object *out_obj; @@ -259,15 +259,16 @@ EXPORT_SYMBOL_GPL(ata_acpi_gtm); * RETURNS: * 0 on success, -ENOENT if _STM doesn't exist, -errno on failure. */ -int ata_acpi_stm(const struct ata_port *ap, struct ata_acpi_gtm *stm) +int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm) { acpi_status status; + struct ata_acpi_gtm stm_buf = *stm; struct acpi_object_list input; union acpi_object in_params[3]; in_params[0].type = ACPI_TYPE_BUFFER; in_params[0].buffer.length = sizeof(struct ata_acpi_gtm); - in_params[0].buffer.pointer = (u8 *)stm; + in_params[0].buffer.pointer = (u8 *)&stm_buf; /* Buffers for id may need byteswapping ? */ in_params[1].type = ACPI_TYPE_BUFFER; in_params[1].buffer.length = 512; -- cgit v1.2.3 From 7f9ad9b8b96855f529f4fe9db0bf32cd3f14c01b Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 15 Dec 2007 15:05:00 +0900 Subject: libata: ata_dev_disable() should be called from EH context ata_port_detach() calls ata_dev_disable() with host lock held but ata_dev_disable() should be called from EH context. ata_port_detach() steals EH context by setting ATA_PFLAG_UNLOADAING and flushing EH. Drop locking around ata_dev_disable() and note that ata_port_detach() owns EH context at that point. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 99a18cea316..c316eacbedd 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -7210,18 +7210,14 @@ static void ata_port_detach(struct ata_port *ap) ata_port_wait_eh(ap); - /* EH is now guaranteed to see UNLOADING, so no new device - * will be attached. Disable all existing devices. + /* EH is now guaranteed to see UNLOADING - EH context belongs + * to us. Disable all existing devices. */ - spin_lock_irqsave(ap->lock, flags); - ata_port_for_each_link(link, ap) { ata_link_for_each_dev(dev, link) ata_dev_disable(dev); } - spin_unlock_irqrestore(ap->lock, flags); - /* Final freeze & EH. All in-flight commands are aborted. EH * will be skipped and retrials will be terminated with bad * target. -- cgit v1.2.3 From 562f0c2d771ee7be6b37fe015f94a929f8056120 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 15 Dec 2007 15:05:01 +0900 Subject: libata-acpi: add new hooks ata_acpi_dissociate() and ata_acpi_on_disable() Add two hooks - ata_acpi_dissociate() which is called during driver detach after the whole host is shutdown and ata_acpi_on_disable() which is called when a device is disabled. Signed-off-by: Tejun heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 28 ++++++++++++++++++++++++++++ drivers/ata/libata-core.c | 4 ++++ drivers/ata/libata.h | 8 ++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 8ae36ad029c..9e5fc5d75b2 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -187,6 +187,21 @@ void ata_acpi_associate(struct ata_host *host) } } +/** + * ata_acpi_dissociate - dissociate ATA host from ACPI objects + * @host: target ATA host + * + * This function is called during driver detach after the whole host + * is shut down. + * + * LOCKING: + * EH context. + */ +void ata_acpi_dissociate(struct ata_host *host) +{ + /* nada */ +} + /** * ata_acpi_gtm - execute _GTM * @ap: target ATA port @@ -716,3 +731,16 @@ int ata_acpi_on_devcfg(struct ata_device *dev) dev->flags |= ATA_DFLAG_ACPI_FAILED; return rc; } + +/** + * ata_acpi_on_disable - ATA ACPI hook called when a device is disabled + * @dev: target ATA device + * + * This function is called when @dev is about to be disabled. + * + * LOCKING: + * EH context. + */ +void ata_acpi_on_disable(struct ata_device *dev) +{ +} diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index c316eacbedd..4af939a00e5 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -622,6 +622,7 @@ void ata_dev_disable(struct ata_device *dev) if (ata_dev_enabled(dev)) { if (ata_msg_drv(dev->link->ap)) ata_dev_printk(dev, KERN_WARNING, "disabled\n"); + ata_acpi_on_disable(dev); ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | ATA_DNXFER_QUIET); dev->class++; @@ -7249,6 +7250,9 @@ void ata_host_detach(struct ata_host *host) for (i = 0; i < host->n_ports; i++) ata_port_detach(host->ports[i]); + + /* the host is dead now, dissociate ACPI */ + ata_acpi_dissociate(host); } /** diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 0e6cf3a484d..bbe59c2fd1e 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h @@ -108,15 +108,19 @@ extern void ata_lpm_schedule(struct ata_port *ap, enum link_pm); #ifdef CONFIG_ATA_ACPI extern void ata_acpi_associate_sata_port(struct ata_port *ap); extern void ata_acpi_associate(struct ata_host *host); +extern void ata_acpi_dissociate(struct ata_host *host); extern int ata_acpi_on_suspend(struct ata_port *ap); extern void ata_acpi_on_resume(struct ata_port *ap); -extern int ata_acpi_on_devcfg(struct ata_device *adev); +extern int ata_acpi_on_devcfg(struct ata_device *dev); +extern void ata_acpi_on_disable(struct ata_device *dev); #else static inline void ata_acpi_associate_sata_port(struct ata_port *ap) { } static inline void ata_acpi_associate(struct ata_host *host) { } +static inline void ata_acpi_dissociate(struct ata_host *host) { } static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } static inline void ata_acpi_on_resume(struct ata_port *ap) { } -static inline int ata_acpi_on_devcfg(struct ata_device *adev) { return 0; } +static inline int ata_acpi_on_devcfg(struct ata_device *dev) { return 0; } +static inline void ata_acpi_on_disable(struct ata_device *dev) { } #endif /* libata-scsi.c */ -- cgit v1.2.3 From c05e6ff035c1b25d17364a685432b33937d3dc23 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 15 Dec 2007 15:05:02 +0900 Subject: libata-acpi: implement and use ata_acpi_init_gtm() _GTM fetches currently configured transfer mode while _STM configures controller according to _GTM parameter and prepares transfer mode configuration TFs for _GTF. In many cases _GTM and _STM implementations are quite brittle and can't cope with configuration changed by libata. libata does not depend on ATA ACPI to configure devices. The only reason libata performs _GTM and _STM are to make _GTF evaluation succeed and libata also doesn't care about how _GTF TFs configure transfer mode. It overrides that configuration anyway, so from libata's POV, it doesn't matter what value is feeded to _STM as long as evaluation succeeds for _STM and following _GTF. This patch adds dev->__acpi_init_gtm and store initial _GTM values on host initialization before modified by reset and mode configuration. If the field is valid, ata_acpi_init_gtm() returns pointer to the saved _GTM structure; otherwise, NULL. This saved value is used for _STM during resume and peek at BIOS/firmware programmed initial timing for later use. The accessor is there to make building w/o ACPI easy as dev->__acpi_init doesn't exist if ACPI is not enabled. On driver detach, the initial BIOS configuration is restored by executing _STM with the initial _GTM values such that the next driver can also use the initial BIOS configured values. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 62 +++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 35 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 9e5fc5d75b2..b3aeca36877 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -94,6 +94,9 @@ static void ata_acpi_associate_ide_port(struct ata_port *ap) dev->acpi_handle = acpi_get_child(ap->acpi_handle, i); } + + if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) + ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; } static void ata_acpi_handle_hotplug(struct ata_port *ap, struct kobject *kobj, @@ -199,7 +202,18 @@ void ata_acpi_associate(struct ata_host *host) */ void ata_acpi_dissociate(struct ata_host *host) { - /* nada */ + int i; + + /* Restore initial _GTM values so that driver which attaches + * afterward can use them too. + */ + for (i = 0; i < host->n_ports; i++) { + struct ata_port *ap = host->ports[i]; + const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); + + if (ap->acpi_handle && gtm) + ata_acpi_stm(ap, gtm); + } } /** @@ -409,22 +423,21 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, int ata_acpi_cbl_80wire(struct ata_port *ap) { - struct ata_acpi_gtm gtm; + const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); int valid = 0; - /* No _GTM data, no information */ - if (ata_acpi_gtm(ap, >m) < 0) + if (!gtm) return 0; /* Split timing, DMA enabled */ - if ((gtm.flags & 0x11) == 0x11 && gtm.drive[0].dma < 55) + if ((gtm->flags & 0x11) == 0x11 && gtm->drive[0].dma < 55) valid |= 1; - if ((gtm.flags & 0x14) == 0x14 && gtm.drive[1].dma < 55) + if ((gtm->flags & 0x14) == 0x14 && gtm->drive[1].dma < 55) valid |= 2; /* Shared timing, DMA enabled */ - if ((gtm.flags & 0x11) == 0x01 && gtm.drive[0].dma < 55) + if ((gtm->flags & 0x11) == 0x01 && gtm->drive[0].dma < 55) valid |= 1; - if ((gtm.flags & 0x14) == 0x04 && gtm.drive[0].dma < 55) + if ((gtm->flags & 0x14) == 0x04 && gtm->drive[0].dma < 55) valid |= 2; /* Drive check */ @@ -612,27 +625,8 @@ static int ata_acpi_push_id(struct ata_device *dev) */ int ata_acpi_on_suspend(struct ata_port *ap) { - unsigned long flags; - int rc; - - /* proceed iff per-port acpi_handle is valid */ - if (!ap->acpi_handle) - return 0; - BUG_ON(ap->flags & ATA_FLAG_ACPI_SATA); - - /* store timing parameters */ - rc = ata_acpi_gtm(ap, &ap->acpi_gtm); - - spin_lock_irqsave(ap->lock, flags); - if (rc == 0) - ap->pflags |= ATA_PFLAG_GTM_VALID; - else - ap->pflags &= ~ATA_PFLAG_GTM_VALID; - spin_unlock_irqrestore(ap->lock, flags); - - if (rc == -ENOENT) - rc = 0; - return rc; + /* nada */ + return 0; } /** @@ -647,14 +641,12 @@ int ata_acpi_on_suspend(struct ata_port *ap) */ void ata_acpi_on_resume(struct ata_port *ap) { + const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); struct ata_device *dev; - if (ap->acpi_handle && (ap->pflags & ATA_PFLAG_GTM_VALID)) { - BUG_ON(ap->flags & ATA_FLAG_ACPI_SATA); - - /* restore timing parameters */ - ata_acpi_stm(ap, &ap->acpi_gtm); - } + /* restore timing parameters */ + if (ap->acpi_handle && gtm) + ata_acpi_stm(ap, gtm); /* schedule _GTF */ ata_link_for_each_dev(dev, &ap->link) -- cgit v1.2.3 From 398e07826b24cbeb5ff2f0a178367fc9d24cd475 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 15 Dec 2007 15:05:03 +0900 Subject: libata-acpi: implement dev->gtf_cache and evaluate _GTF right after _STM during resume On certain implementations, _GTF evaluation depends on preceding _STM and both can be pretty picky about the configuration. Using _GTM result cached during controller initialization satisfies the most neurotic _STM implementation. However, libata evaluates _GTF after reset during device configuration and the hardware state can be different from what _GTF expects and can cause evaluation failure. This patch adds dev->gtf_cache and updates ata_dev_get_GTF() such that it uses the cached value if available. Cache is cleared with a call to ata_acpi_clear_gtf(). Because for SATA ACPI nodes _GTF must be evaluated after _SDD which can't be done till IDENTIFY is complete, _GTF caching from ata_acpi_on_resume() is used only for IDE ACPI nodes. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 69 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 20 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index b3aeca36877..e0dd132fd49 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -41,6 +41,12 @@ static int is_pci_dev(struct device *dev) return (dev->bus == &pci_bus_type); } +static void ata_acpi_clear_gtf(struct ata_device *dev) +{ + kfree(dev->gtf_cache); + dev->gtf_cache = NULL; +} + /** * ata_acpi_associate_sata_port - associate SATA port with ACPI objects * @ap: target SATA port @@ -327,7 +333,6 @@ EXPORT_SYMBOL_GPL(ata_acpi_stm); * ata_dev_get_GTF - get the drive bootup default taskfile settings * @dev: target ATA device * @gtf: output parameter for buffer containing _GTF taskfile arrays - * @ptr_to_free: pointer which should be freed * * This applies to both PATA and SATA drives. * @@ -344,8 +349,7 @@ EXPORT_SYMBOL_GPL(ata_acpi_stm); * Number of taskfiles on success, 0 if _GTF doesn't exist or doesn't * contain valid data. */ -static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, - void **ptr_to_free) +static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf) { struct ata_port *ap = dev->link->ap; acpi_status status; @@ -353,6 +357,12 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, union acpi_object *out_obj; int rc = 0; + /* if _GTF is cached, use the cached value */ + if (dev->gtf_cache) { + out_obj = dev->gtf_cache; + goto done; + } + /* set up output buffer */ output.length = ACPI_ALLOCATE_BUFFER; output.pointer = NULL; /* ACPI-CA sets this; save/free it later */ @@ -363,6 +373,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, /* _GTF has no input parameters */ status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output); + out_obj = dev->gtf_cache = output.pointer; if (ACPI_FAILURE(status)) { if (status != AE_NOT_FOUND) { @@ -383,7 +394,6 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, goto out_free; } - out_obj = output.pointer; if (out_obj->type != ACPI_TYPE_BUFFER) { ata_dev_printk(dev, KERN_WARNING, "_GTF unexpected object type 0x%x\n", @@ -398,18 +408,19 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, goto out_free; } - *ptr_to_free = out_obj; - *gtf = (void *)out_obj->buffer.pointer; + done: rc = out_obj->buffer.length / REGS_PER_GTF; - - if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: returning " - "gtf=%p, gtf_count=%d, ptr_to_free=%p\n", - __FUNCTION__, *gtf, rc, *ptr_to_free); + if (gtf) { + *gtf = (void *)out_obj->buffer.pointer; + if (ata_msg_probe(ap)) + ata_dev_printk(dev, KERN_DEBUG, + "%s: returning gtf=%p, gtf_count=%d\n", + __FUNCTION__, *gtf, rc); + } return rc; out_free: - kfree(output.pointer); + ata_acpi_clear_gtf(dev); return rc; } @@ -533,11 +544,10 @@ static int taskfile_load_raw(struct ata_device *dev, static int ata_acpi_exec_tfs(struct ata_device *dev) { struct ata_acpi_gtf *gtf = NULL; - void *ptr_to_free = NULL; int gtf_count, i, rc; /* get taskfiles */ - gtf_count = ata_dev_get_GTF(dev, >f, &ptr_to_free); + gtf_count = ata_dev_get_GTF(dev, >f); /* execute them */ for (i = 0, rc = 0; i < gtf_count; i++) { @@ -551,7 +561,7 @@ static int ata_acpi_exec_tfs(struct ata_device *dev) rc = tmp; } - kfree(ptr_to_free); + ata_acpi_clear_gtf(dev); if (rc == 0) return gtf_count; @@ -644,13 +654,31 @@ void ata_acpi_on_resume(struct ata_port *ap) const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); struct ata_device *dev; - /* restore timing parameters */ - if (ap->acpi_handle && gtm) + if (ap->acpi_handle && gtm) { + /* _GTM valid */ + + /* restore timing parameters */ ata_acpi_stm(ap, gtm); - /* schedule _GTF */ - ata_link_for_each_dev(dev, &ap->link) - dev->flags |= ATA_DFLAG_ACPI_PENDING; + /* _GTF should immediately follow _STM so that it can + * use values set by _STM. Cache _GTF result and + * schedule _GTF. + */ + ata_link_for_each_dev(dev, &ap->link) { + ata_acpi_clear_gtf(dev); + if (ata_dev_get_GTF(dev, NULL) >= 0) + dev->flags |= ATA_DFLAG_ACPI_PENDING; + } + } else { + /* SATA _GTF needs to be evaulated after _SDD and + * there's no reason to evaluate IDE _GTF early + * without _STM. Clear cache and schedule _GTF. + */ + ata_link_for_each_dev(dev, &ap->link) { + ata_acpi_clear_gtf(dev); + dev->flags |= ATA_DFLAG_ACPI_PENDING; + } + } } /** @@ -735,4 +763,5 @@ int ata_acpi_on_devcfg(struct ata_device *dev) */ void ata_acpi_on_disable(struct ata_device *dev) { + ata_acpi_clear_gtf(dev); } -- cgit v1.2.3 From 66fa7f2158e84530aa4a1839a3500d6bdb231301 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 15 Dec 2007 15:05:04 +0900 Subject: libata-acpi: improve ACPI disabling * If _GTF evalution fails, it's pointless to retry. If nothing else is wrong, just ignore the error. * After disabling ACPI, return success iff the number of executed _GTF command equals zero. Otherwise, tell EH to retry. This change fixes bogus 1 return bug where ata_acpi_on_devcfg() expects the caller to reload IDENTIFY data and continue but the caller interprets it as an error. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 59 ++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index e0dd132fd49..5932ae24ddc 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -346,8 +346,8 @@ EXPORT_SYMBOL_GPL(ata_acpi_stm); * EH context. * * RETURNS: - * Number of taskfiles on success, 0 if _GTF doesn't exist or doesn't - * contain valid data. + * Number of taskfiles on success, 0 if _GTF doesn't exist. -EINVAL + * if _GTF is invalid. */ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf) { @@ -380,6 +380,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf) ata_dev_printk(dev, KERN_WARNING, "_GTF evaluation failed (AE 0x%x)\n", status); + rc = -EINVAL; } goto out_free; } @@ -391,6 +392,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf) __FUNCTION__, (unsigned long long)output.length, output.pointer); + rc = -EINVAL; goto out_free; } @@ -398,6 +400,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf) ata_dev_printk(dev, KERN_WARNING, "_GTF unexpected object type 0x%x\n", out_obj->type); + rc = -EINVAL; goto out_free; } @@ -405,6 +408,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf) ata_dev_printk(dev, KERN_WARNING, "unexpected _GTF length (%d)\n", out_obj->buffer.length); + rc = -EINVAL; goto out_free; } @@ -531,6 +535,7 @@ static int taskfile_load_raw(struct ata_device *dev, /** * ata_acpi_exec_tfs - get then write drive taskfile settings * @dev: target ATA device + * @nr_executed: out paramter for the number of executed commands * * Evaluate _GTF and excute returned taskfiles. * @@ -538,16 +543,19 @@ static int taskfile_load_raw(struct ata_device *dev, * EH context. * * RETURNS: - * Number of executed taskfiles on success, 0 if _GTF doesn't exist or - * doesn't contain valid data. -errno on other errors. + * Number of executed taskfiles on success, 0 if _GTF doesn't exist. + * -errno on other errors. */ -static int ata_acpi_exec_tfs(struct ata_device *dev) +static int ata_acpi_exec_tfs(struct ata_device *dev, int *nr_executed) { struct ata_acpi_gtf *gtf = NULL; int gtf_count, i, rc; /* get taskfiles */ - gtf_count = ata_dev_get_GTF(dev, >f); + rc = ata_dev_get_GTF(dev, >f); + if (rc < 0) + return rc; + gtf_count = rc; /* execute them */ for (i = 0, rc = 0; i < gtf_count; i++) { @@ -559,12 +567,12 @@ static int ata_acpi_exec_tfs(struct ata_device *dev) tmp = taskfile_load_raw(dev, gtf++); if (!rc) rc = tmp; + + (*nr_executed)++; } ata_acpi_clear_gtf(dev); - if (rc == 0) - return gtf_count; return rc; } @@ -700,6 +708,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev) struct ata_port *ap = dev->link->ap; struct ata_eh_context *ehc = &ap->link.eh_context; int acpi_sata = ap->flags & ATA_FLAG_ACPI_SATA; + int nr_executed = 0; int rc; if (!dev->acpi_handle) @@ -718,14 +727,14 @@ int ata_acpi_on_devcfg(struct ata_device *dev) } /* do _GTF */ - rc = ata_acpi_exec_tfs(dev); - if (rc < 0) + rc = ata_acpi_exec_tfs(dev, &nr_executed); + if (rc) goto acpi_err; dev->flags &= ~ATA_DFLAG_ACPI_PENDING; /* refresh IDENTIFY page if any _GTF command has been executed */ - if (rc > 0) { + if (nr_executed) { rc = ata_dev_reread_id(dev, 0); if (rc < 0) { ata_dev_printk(dev, KERN_ERR, "failed to IDENTIFY " @@ -737,18 +746,26 @@ int ata_acpi_on_devcfg(struct ata_device *dev) return 0; acpi_err: - /* let EH retry on the first failure, disable ACPI on the second */ - if (dev->flags & ATA_DFLAG_ACPI_FAILED) { - ata_dev_printk(dev, KERN_WARNING, "ACPI on devcfg failed the " - "second time, disabling (errno=%d)\n", rc); - - dev->acpi_handle = NULL; + /* ignore evaluation failure if we can continue safely */ + if (rc == -EINVAL && !nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN)) + return 0; - /* if port is working, request IDENTIFY reload and continue */ - if (!(ap->pflags & ATA_PFLAG_FROZEN)) - rc = 1; + /* fail and let EH retry once more for unknown IO errors */ + if (!(dev->flags & ATA_DFLAG_ACPI_FAILED)) { + dev->flags |= ATA_DFLAG_ACPI_FAILED; + return rc; } - dev->flags |= ATA_DFLAG_ACPI_FAILED; + + ata_dev_printk(dev, KERN_WARNING, + "ACPI: failed the second time, disabled\n"); + dev->acpi_handle = NULL; + + /* We can safely continue if no _GTF command has been executed + * and port is not frozen. + */ + if (!nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN)) + return 0; + return rc; } -- cgit v1.2.3 From 0e8634bf8e48e50aa96c7e7becafcf9d98c1a28d Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 15 Dec 2007 15:05:05 +0900 Subject: libata-acpi: improve _GTF execution error handling and reporting As _GTF commands can't transfer data, device error never signals transfer error. It indicates that the device vetoed the operation, so it's meaningless to retry. This patch makes libata-acpi to report and continue on device errors when executing _GTF commands. Also commands rejected by device don't contribute to the number of _GTF commands executed. While at it, update _GTF execution reporting such that all successful commands are logged at KERN_DEBUG and rename taskfile_load_raw() to ata_acpi_run_tf() for consistency. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 77 ++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 31 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 5932ae24ddc..d4cb557a727 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -466,7 +466,7 @@ int ata_acpi_cbl_80wire(struct ata_port *ap) EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire); /** - * taskfile_load_raw - send taskfile registers to host controller + * ata_acpi_run_tf - send taskfile registers to host controller * @dev: target ATA device * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) * @@ -485,14 +485,17 @@ EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire); * EH context. * * RETURNS: - * 0 on success, -errno on failure. + * 1 if command is executed successfully. 0 if ignored or rejected, + * -errno on other errors. */ -static int taskfile_load_raw(struct ata_device *dev, - const struct ata_acpi_gtf *gtf) +static int ata_acpi_run_tf(struct ata_device *dev, + const struct ata_acpi_gtf *gtf) { - struct ata_port *ap = dev->link->ap; struct ata_taskfile tf, rtf; unsigned int err_mask; + const char *level; + char msg[60]; + int rc; if ((gtf->tf[0] == 0) && (gtf->tf[1] == 0) && (gtf->tf[2] == 0) && (gtf->tf[3] == 0) && (gtf->tf[4] == 0) && (gtf->tf[5] == 0) @@ -512,24 +515,39 @@ static int taskfile_load_raw(struct ata_device *dev, tf.device = gtf->tf[5]; /* 0x1f6 */ tf.command = gtf->tf[6]; /* 0x1f7 */ - if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "executing ACPI cmd " - "%02x/%02x:%02x:%02x:%02x:%02x:%02x\n", - tf.command, tf.feature, tf.nsect, - tf.lbal, tf.lbam, tf.lbah, tf.device); - rtf = tf; err_mask = ata_exec_internal(dev, &rtf, NULL, DMA_NONE, NULL, 0, 0); - if (err_mask) { - ata_dev_printk(dev, KERN_ERR, - "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x failed " - "(Emask=0x%x Stat=0x%02x Err=0x%02x)\n", - tf.command, tf.feature, tf.nsect, tf.lbal, tf.lbam, - tf.lbah, tf.device, err_mask, rtf.command, rtf.feature); - return -EIO; + + switch (err_mask) { + case 0: + level = KERN_DEBUG; + snprintf(msg, sizeof(msg), "succeeded"); + rc = 1; + break; + + case AC_ERR_DEV: + level = KERN_INFO; + snprintf(msg, sizeof(msg), + "rejected by device (Stat=0x%02x Err=0x%02x)", + rtf.command, rtf.feature); + rc = 0; + break; + + default: + level = KERN_ERR; + snprintf(msg, sizeof(msg), + "failed (Emask=0x%x Stat=0x%02x Err=0x%02x)", + err_mask, rtf.command, rtf.feature); + rc = -EIO; + break; } - return 0; + ata_dev_printk(dev, level, + "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x %s\n", + tf.command, tf.feature, tf.nsect, tf.lbal, + tf.lbam, tf.lbah, tf.device, msg); + + return rc; } /** @@ -558,22 +576,19 @@ static int ata_acpi_exec_tfs(struct ata_device *dev, int *nr_executed) gtf_count = rc; /* execute them */ - for (i = 0, rc = 0; i < gtf_count; i++) { - int tmp; - - /* ACPI errors are eventually ignored. Run till the - * end even after errors. - */ - tmp = taskfile_load_raw(dev, gtf++); - if (!rc) - rc = tmp; - - (*nr_executed)++; + for (i = 0; i < gtf_count; i++) { + rc = ata_acpi_run_tf(dev, gtf++); + if (rc < 0) + break; + if (rc) + (*nr_executed)++; } ata_acpi_clear_gtf(dev); - return rc; + if (rc < 0) + return rc; + return 0; } /** -- cgit v1.2.3 From 3264a8d8f95348e05cc6ac1ce747a8339ed7ab08 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 15 Dec 2007 15:05:06 +0900 Subject: libata-acpi: implement _GTF command filtering Implement _GTF command filtering which can be controlled by libata.acpi_filter kernel parameter. Currently SETXFER and LOCK commands are filtered. libata configures transfer mode by itself and _GTF SETXFER commands can potentially disrupt device configuration. _GTM/_STM mechanism can't handle hotplugging too well and when _GTF is executed, controller is in PIO0 rather than the mode _STM configured. Note that detecting SET MAX LOCK requires looking at the previous command. This adds a bit to code complexity. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 159 +++++++++++++++++++++++++++++++++------------- 1 file changed, 115 insertions(+), 44 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index d4cb557a727..7bf4befd96b 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -6,6 +6,7 @@ * Copyright (C) 2006 Randy Dunlap */ +#include #include #include #include @@ -25,6 +26,18 @@ #include #include +enum { + ATA_ACPI_FILTER_SETXFER = 1 << 0, + ATA_ACPI_FILTER_LOCK = 1 << 1, + + ATA_ACPI_FILTER_DEFAULT = ATA_ACPI_FILTER_SETXFER | + ATA_ACPI_FILTER_LOCK, +}; + +static unsigned int ata_acpi_gtf_filter = ATA_ACPI_FILTER_DEFAULT; +module_param_named(acpi_gtf_filter, ata_acpi_gtf_filter, int, 0644); +MODULE_PARM_DESC(acpi_gtf_filter, "filter mask for ACPI _GTF commands, set to filter out (0x1=set xfermode, 0x2=lock/freeze lock)"); + #define NO_PORT_MULT 0xffff #define SATA_ADR(root, pmp) (((root) << 16) | (pmp)) @@ -465,6 +478,60 @@ int ata_acpi_cbl_80wire(struct ata_port *ap) EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire); +static void ata_acpi_gtf_to_tf(struct ata_device *dev, + const struct ata_acpi_gtf *gtf, + struct ata_taskfile *tf) +{ + ata_tf_init(dev, tf); + + tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; + tf->protocol = ATA_PROT_NODATA; + tf->feature = gtf->tf[0]; /* 0x1f1 */ + tf->nsect = gtf->tf[1]; /* 0x1f2 */ + tf->lbal = gtf->tf[2]; /* 0x1f3 */ + tf->lbam = gtf->tf[3]; /* 0x1f4 */ + tf->lbah = gtf->tf[4]; /* 0x1f5 */ + tf->device = gtf->tf[5]; /* 0x1f6 */ + tf->command = gtf->tf[6]; /* 0x1f7 */ +} + +static int ata_acpi_filter_tf(const struct ata_taskfile *tf, + const struct ata_taskfile *ptf) +{ + if (ata_acpi_gtf_filter & ATA_ACPI_FILTER_SETXFER) { + /* libata doesn't use ACPI to configure transfer mode. + * It will only confuse device configuration. Skip. + */ + if (tf->command == ATA_CMD_SET_FEATURES && + tf->feature == SETFEATURES_XFER) + return 1; + } + + if (ata_acpi_gtf_filter & ATA_ACPI_FILTER_LOCK) { + /* BIOS writers, sorry but we don't wanna lock + * features unless the user explicitly said so. + */ + + /* DEVICE CONFIGURATION FREEZE LOCK */ + if (tf->command == ATA_CMD_CONF_OVERLAY && + tf->feature == ATA_DCO_FREEZE_LOCK) + return 1; + + /* SECURITY FREEZE LOCK */ + if (tf->command == ATA_CMD_SEC_FREEZE_LOCK) + return 1; + + /* SET MAX LOCK and SET MAX FREEZE LOCK */ + if ((!ptf || ptf->command != ATA_CMD_READ_NATIVE_MAX) && + tf->command == ATA_CMD_SET_MAX && + (tf->feature == ATA_SET_MAX_LOCK || + tf->feature == ATA_SET_MAX_FREEZE_LOCK)) + return 1; + } + + return 0; +} + /** * ata_acpi_run_tf - send taskfile registers to host controller * @dev: target ATA device @@ -485,13 +552,15 @@ EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire); * EH context. * * RETURNS: - * 1 if command is executed successfully. 0 if ignored or rejected, - * -errno on other errors. + * 1 if command is executed successfully. 0 if ignored, rejected or + * filtered out, -errno on other errors. */ static int ata_acpi_run_tf(struct ata_device *dev, - const struct ata_acpi_gtf *gtf) + const struct ata_acpi_gtf *gtf, + const struct ata_acpi_gtf *prev_gtf) { - struct ata_taskfile tf, rtf; + struct ata_taskfile *pptf = NULL; + struct ata_taskfile tf, ptf, rtf; unsigned int err_mask; const char *level; char msg[60]; @@ -502,44 +571,44 @@ static int ata_acpi_run_tf(struct ata_device *dev, && (gtf->tf[6] == 0)) return 0; - ata_tf_init(dev, &tf); - - /* convert gtf to tf */ - tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ - tf.protocol = ATA_PROT_NODATA; - tf.feature = gtf->tf[0]; /* 0x1f1 */ - tf.nsect = gtf->tf[1]; /* 0x1f2 */ - tf.lbal = gtf->tf[2]; /* 0x1f3 */ - tf.lbam = gtf->tf[3]; /* 0x1f4 */ - tf.lbah = gtf->tf[4]; /* 0x1f5 */ - tf.device = gtf->tf[5]; /* 0x1f6 */ - tf.command = gtf->tf[6]; /* 0x1f7 */ - - rtf = tf; - err_mask = ata_exec_internal(dev, &rtf, NULL, DMA_NONE, NULL, 0, 0); - - switch (err_mask) { - case 0: - level = KERN_DEBUG; - snprintf(msg, sizeof(msg), "succeeded"); - rc = 1; - break; - - case AC_ERR_DEV: + ata_acpi_gtf_to_tf(dev, gtf, &tf); + if (prev_gtf) { + ata_acpi_gtf_to_tf(dev, prev_gtf, &ptf); + pptf = &ptf; + } + + if (!ata_acpi_filter_tf(&tf, pptf)) { + rtf = tf; + err_mask = ata_exec_internal(dev, &rtf, NULL, + DMA_NONE, NULL, 0, 0); + + switch (err_mask) { + case 0: + level = KERN_DEBUG; + snprintf(msg, sizeof(msg), "succeeded"); + rc = 1; + break; + + case AC_ERR_DEV: + level = KERN_INFO; + snprintf(msg, sizeof(msg), + "rejected by device (Stat=0x%02x Err=0x%02x)", + rtf.command, rtf.feature); + rc = 0; + break; + + default: + level = KERN_ERR; + snprintf(msg, sizeof(msg), + "failed (Emask=0x%x Stat=0x%02x Err=0x%02x)", + err_mask, rtf.command, rtf.feature); + rc = -EIO; + break; + } + } else { level = KERN_INFO; - snprintf(msg, sizeof(msg), - "rejected by device (Stat=0x%02x Err=0x%02x)", - rtf.command, rtf.feature); + snprintf(msg, sizeof(msg), "filtered out"); rc = 0; - break; - - default: - level = KERN_ERR; - snprintf(msg, sizeof(msg), - "failed (Emask=0x%x Stat=0x%02x Err=0x%02x)", - err_mask, rtf.command, rtf.feature); - rc = -EIO; - break; } ata_dev_printk(dev, level, @@ -566,7 +635,7 @@ static int ata_acpi_run_tf(struct ata_device *dev, */ static int ata_acpi_exec_tfs(struct ata_device *dev, int *nr_executed) { - struct ata_acpi_gtf *gtf = NULL; + struct ata_acpi_gtf *gtf = NULL, *pgtf = NULL; int gtf_count, i, rc; /* get taskfiles */ @@ -576,12 +645,14 @@ static int ata_acpi_exec_tfs(struct ata_device *dev, int *nr_executed) gtf_count = rc; /* execute them */ - for (i = 0; i < gtf_count; i++) { - rc = ata_acpi_run_tf(dev, gtf++); + for (i = 0; i < gtf_count; i++, gtf++) { + rc = ata_acpi_run_tf(dev, gtf, pgtf); if (rc < 0) break; - if (rc) + if (rc) { (*nr_executed)++; + pgtf = gtf; + } } ata_acpi_clear_gtf(dev); -- cgit v1.2.3 From f2dfc1a12bb1a029df62b018a8e1882e91041025 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 12 Dec 2007 12:12:46 +0900 Subject: libata: update atapi_eh_request_sense() such that lbam/lbah contains buffer size While updating lbam/h for ATAPI commands, atapi_eh_request_sense() was left out. Update it. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-eh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index e6605f03864..f0124a8d313 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -1264,8 +1264,8 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc) tf.feature |= ATAPI_PKT_DMA; } else { tf.protocol = ATA_PROT_ATAPI; - tf.lbam = (8 * 1024) & 0xff; - tf.lbah = (8 * 1024) >> 8; + tf.lbam = SCSI_SENSE_BUFFERSIZE; + tf.lbah = 0; } return ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE, -- cgit v1.2.3 From 140b5e59119a172a91b5fa13d54ca4f79bbefee1 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 12 Dec 2007 12:21:52 +0900 Subject: libata: fix ATAPI draining With ATAPI transfer chunk size properly programmed, libata PIO HSM should be able to handle full spurious data chunks. Also, it's a good idea to suppress trailing data warning for misc ATAPI commands as there can be many of them per command - for example, if the chunk size is 16 and the drive tries to transfer 510 bytes, there can be 31 trailing data messages. This patch makes the following updates to libata ATAPI PIO HSM implementation. * Make it drain full spurious chunks. * Suppress trailing data warning message for misc commands. * Put limit on how many bytes can be drained. * If odd, round up consumed bytes and the number of bytes to be drained. This gets the number of bytes to drain right for drivers which do 16bit PIO. This patch is partial backport of improve-ATAPI-data-xfer patchset pending for #upstream. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 87 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 22 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 4af939a00e5..4753a1831db 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -64,6 +64,7 @@ #include #include #include +#include #include "libata.h" @@ -4651,6 +4652,43 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc) return 0; } +/** + * atapi_qc_may_overflow - Check whether data transfer may overflow + * @qc: ATA command in question + * + * ATAPI commands which transfer variable length data to host + * might overflow due to application error or hardare bug. This + * function checks whether overflow should be drained and ignored + * for @qc. + * + * LOCKING: + * None. + * + * RETURNS: + * 1 if @qc may overflow; otherwise, 0. + */ +static int atapi_qc_may_overflow(struct ata_queued_cmd *qc) +{ + if (qc->tf.protocol != ATA_PROT_ATAPI && + qc->tf.protocol != ATA_PROT_ATAPI_DMA) + return 0; + + if (qc->tf.flags & ATA_TFLAG_WRITE) + return 0; + + switch (qc->cdb[0]) { + case READ_10: + case READ_12: + case WRITE_10: + case WRITE_12: + case GPCMD_READ_CD: + case GPCMD_READ_CD_MSF: + return 0; + } + + return 1; +} + /** * ata_std_qc_defer - Check whether a qc needs to be deferred * @qc: ATA command in question @@ -5139,23 +5177,19 @@ static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) * Inherited from caller. * */ - -static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) +static int __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) { int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); - struct scatterlist *sg = qc->__sg; - struct scatterlist *lsg = sg_last(qc->__sg, qc->n_elem); struct ata_port *ap = qc->ap; + struct ata_eh_info *ehi = &qc->dev->link->eh_info; + struct scatterlist *sg; struct page *page; unsigned char *buf; unsigned int offset, count; - int no_more_sg = 0; - - if (qc->curbytes + bytes >= qc->nbytes) - ap->hsm_task_state = HSM_ST_LAST; next_sg: - if (unlikely(no_more_sg)) { + sg = qc->cursg; + if (unlikely(!sg)) { /* * The end of qc->sg is reached and the device expects * more data to transfer. In order not to overrun qc->sg @@ -5164,21 +5198,28 @@ next_sg: * - for write case, padding zero data to the device */ u16 pad_buf[1] = { 0 }; - unsigned int words = bytes >> 1; unsigned int i; - if (words) /* warning if bytes > 1 */ - ata_dev_printk(qc->dev, KERN_WARNING, - "%u bytes trailing data\n", bytes); + if (bytes > qc->curbytes - qc->nbytes + ATAPI_MAX_DRAIN) { + ata_ehi_push_desc(ehi, "too much trailing data " + "buf=%u cur=%u bytes=%u", + qc->nbytes, qc->curbytes, bytes); + return -1; + } + + /* overflow is exptected for misc ATAPI commands */ + if (bytes && !atapi_qc_may_overflow(qc)) + ata_dev_printk(qc->dev, KERN_WARNING, "ATAPI %u bytes " + "trailing data (cdb=%02x nbytes=%u)\n", + bytes, qc->cdb[0], qc->nbytes); - for (i = 0; i < words; i++) + for (i = 0; i < (bytes + 1) / 2; i++) ap->ops->data_xfer(qc->dev, (unsigned char *)pad_buf, 2, do_write); - ap->hsm_task_state = HSM_ST_LAST; - return; - } + qc->curbytes += bytes; - sg = qc->cursg; + return 0; + } page = sg_page(sg); offset = sg->offset + qc->cursg_ofs; @@ -5213,19 +5254,20 @@ next_sg: } bytes -= count; + if ((count & 1) && bytes) + bytes--; qc->curbytes += count; qc->cursg_ofs += count; if (qc->cursg_ofs == sg->length) { - if (qc->cursg == lsg) - no_more_sg = 1; - qc->cursg = sg_next(qc->cursg); qc->cursg_ofs = 0; } if (bytes) goto next_sg; + + return 0; } /** @@ -5268,7 +5310,8 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) VPRINTK("ata%u: xfering %d bytes\n", ap->print_id, bytes); - __atapi_pio_bytes(qc, bytes); + if (__atapi_pio_bytes(qc, bytes)) + goto err_out; ata_altstatus(ap); /* flush */ return; -- cgit v1.2.3 From 8d431dbef4e63d54f1965c3ed6ca5f91ee4512de Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 17 Dec 2007 16:19:50 -0800 Subject: rtc-at32ap700x: fix irq init oops Reorder at32_rtc_probe() so that it's safe (no oopsing) to fire the IRQ handler the instant that it's registered. (Bug noted via "Debug shared IRQ handlers" kernel debug option.) Signed-off-by: David Brownell Cc: Alessandro Zummo Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-at32ap700x.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c index 2999214ca53..d3b9b14267a 100644 --- a/drivers/rtc/rtc-at32ap700x.c +++ b/drivers/rtc/rtc-at32ap700x.c @@ -225,18 +225,12 @@ static int __init at32_rtc_probe(struct platform_device *pdev) goto out; } - ret = request_irq(irq, at32_rtc_interrupt, IRQF_SHARED, "rtc", rtc); - if (ret) { - dev_dbg(&pdev->dev, "could not request irq %d\n", irq); - goto out; - } - rtc->irq = irq; rtc->regs = ioremap(regs->start, regs->end - regs->start + 1); if (!rtc->regs) { ret = -ENOMEM; dev_dbg(&pdev->dev, "could not map I/O memory\n"); - goto out_free_irq; + goto out; } spin_lock_init(&rtc->lock); @@ -253,12 +247,18 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | RTC_BIT(CTRL_EN)); } + ret = request_irq(irq, at32_rtc_interrupt, IRQF_SHARED, "rtc", rtc); + if (ret) { + dev_dbg(&pdev->dev, "could not request irq %d\n", irq); + goto out_iounmap; + } + rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, &at32_rtc_ops, THIS_MODULE); if (IS_ERR(rtc->rtc)) { dev_dbg(&pdev->dev, "could not register rtc device\n"); ret = PTR_ERR(rtc->rtc); - goto out_iounmap; + goto out_free_irq; } platform_set_drvdata(pdev, rtc); @@ -268,10 +268,10 @@ static int __init at32_rtc_probe(struct platform_device *pdev) return 0; -out_iounmap: - iounmap(rtc->regs); out_free_irq: free_irq(irq, rtc); +out_iounmap: + iounmap(rtc->regs); out: kfree(rtc); return ret; -- cgit v1.2.3 From 60af880339aae440293a0c8e93178fdcb41f8a29 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 17 Dec 2007 16:19:51 -0800 Subject: parport: "dev->timeslice" is an unsigned long, not an int While auditing proc_doulongvec_ms_jiffies_minmax() usage in kernel, I found a bug in drivers/parport/procfs.c, incorrectly using sizeof(int) instead of sizeof(unsigned long) Only 64bit arches are affected by this old bug. Signed-off-by: Eric Dumazet Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/procfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index ed82e41210d..d950fc34320 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c @@ -384,7 +384,7 @@ parport_device_sysctl_template = { { .procname = "timeslice", .data = NULL, - .maxlen = sizeof(int), + .maxlen = sizeof(unsigned long), .mode = 0644, .proc_handler = &proc_doulongvec_ms_jiffies_minmax, .extra1 = (void*) &parport_min_timeslice_value, -- cgit v1.2.3 From bd6cba53c524dccf72900435d29722b22f61d835 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Mon, 17 Dec 2007 16:19:58 -0800 Subject: cpufreq: fix missing unlocks in cpufreq_add_dev error paths. Ingo hit some BUG_ONs that were probably caused by these missing unlocks causing an unbalance. He couldn't reproduce the bug reliably, so it's unknown that it's definitly fixing the problem he hit, but it's a fairly good chance, and this fixes an obvious bug. [ Dave: "Ingo followed up that he hit some lockdep related output with this applied, so it may not be right. I'll look at it after xmas if no-one has it figured out before then." Akpm: "It looks pretty correct to me though." ] Signed-off-by: Dave Jones Cc: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/cpufreq/cpufreq.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 5e626b12b97..79581fab82d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -841,19 +841,25 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) drv_attr = cpufreq_driver->attr; while ((drv_attr) && (*drv_attr)) { ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); - if (ret) + if (ret) { + unlock_policy_rwsem_write(cpu); goto err_out_driver_exit; + } drv_attr++; } if (cpufreq_driver->get){ ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); - if (ret) + if (ret) { + unlock_policy_rwsem_write(cpu); goto err_out_driver_exit; + } } if (cpufreq_driver->target){ ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); - if (ret) + if (ret) { + unlock_policy_rwsem_write(cpu); goto err_out_driver_exit; + } } spin_lock_irqsave(&cpufreq_driver_lock, flags); -- cgit v1.2.3 From d17a18dd92c91c784fcf7c785fa6bbf178fd0a6d Mon Sep 17 00:00:00 2001 From: Dave Young Date: Mon, 17 Dec 2007 16:20:00 -0800 Subject: pktcdvd: add kobject_put when kobject register fails In kobject_register, the kobject reference is get in kobject_init, and then kobject_add. If kobject_add fail, it will only cleanup the reference got by itself. Signed-off-by: Dave Young Reviewed-by: Pekka Enberg Cc: Greg KH Cc: Peter Osterlund Cc: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/pktcdvd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index a5ee21319d3..3535ef89667 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -117,8 +117,10 @@ static struct pktcdvd_kobj* pkt_kobj_create(struct pktcdvd_device *pd, p->kobj.parent = parent; p->kobj.ktype = ktype; p->pd = pd; - if (kobject_register(&p->kobj) != 0) + if (kobject_register(&p->kobj) != 0) { + kobject_put(&p->kobj); return NULL; + } return p; } /* -- cgit v1.2.3 From 771cceb464874d4a22efd4a600e4597ad3f2fc9e Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 17 Dec 2007 16:20:02 -0800 Subject: drivers/macintosh/via-pmu.c: Added a missing iounmap The error handling code should undo the ioremap as well. The problem was detected using the following semantic match (http://www.emn.fr/x-info/coccinelle/) // @@ type T,T1,T2; identifier E; statement S; expression x1,x2; constant C; int ret; @@ T E; ... * E = ioremap(...); if (E == NULL) S ... when != iounmap(E) when != if (E != NULL) { ... iounmap(E); ...} when != x1 = (T1)E if (...) { ... when != iounmap(E) when != if (E != NULL) { ... iounmap(E); ...} when != x2 = (T2)E ( * return; | * return C; | * return ret; ) } // Signed-off-by: Julia Lawall Cc: Johannes Berg Cc: Olaf Hering Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/macintosh/via-pmu.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index dc741d3a453..6123c70153d 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -2336,6 +2336,7 @@ powerbook_sleep_3400(void) ret = pmac_suspend_devices(); if (ret) { pbook_free_pci_save(); + iounmap(mem_ctrl); printk(KERN_ERR "Sleep rejected by devices\n"); return ret; } -- cgit v1.2.3 From a33234735b2bcfb23cf1facb1f0d8656b8edab8f Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 17 Dec 2007 16:20:03 -0800 Subject: drivers/cpufreq/cpufreq_stats.c section fix cpufreq_stats_free_table() mustn't be __cpuexit since it's called by the __cpuinit cpufreq_stat_cpu_callback(). This patch fixes the following section mismatch reported by Chris Clayton: WARNING: vmlinux.o(.init.text+0x143dd): Section mismatch: reference to .exit.text:cpufreq_stats_free_table (between 'cpufreq_stat_cpu_callback' and 'cpufreq_stats_init') Signed-off-by: Adrian Bunk Cc: Chris Clayton Acked-by: Dave Jones Cc: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/cpufreq/cpufreq_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 8a45d0f93e2..1b8312b0200 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -164,7 +164,7 @@ freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq) return -1; } -static void __cpuexit cpufreq_stats_free_table(unsigned int cpu) +static void cpufreq_stats_free_table(unsigned int cpu) { struct cpufreq_stats *stat = cpufreq_stats_table[cpu]; struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); -- cgit v1.2.3 From 711924b1052a280bd2452c3babb9816e4a77c723 Mon Sep 17 00:00:00 2001 From: Shannon Nelson Date: Mon, 17 Dec 2007 16:20:08 -0800 Subject: I/OAT: fixups from code comments A few fixups from Andrew's code comments. - removed "static inline" forward-declares - changed use of min() to min_t() - removed some unnecessary NULL initializations - removed a couple of BUG() calls Fixes this: drivers/dma/ioat_dma.c: In function `ioat1_tx_submit': drivers/dma/ioat_dma.c:177: sorry, unimplemented: inlining failed in call to '__ioat1_dma_memcpy_issue_pending': function body not available drivers/dma/ioat_dma.c:268: sorry, unimplemented: called from here Signed-off-by: Shannon Nelson Cc: "Williams, Dan J" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/dma/ioat_dma.c | 142 +++++++++++++++++++++++++++---------------------- drivers/dma/ioatdma.h | 2 +- 2 files changed, 78 insertions(+), 66 deletions(-) (limited to 'drivers') diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c index c1c2dcc6fc2..c17ec327606 100644 --- a/drivers/dma/ioat_dma.c +++ b/drivers/dma/ioat_dma.c @@ -173,10 +173,47 @@ static void ioat_set_dest(dma_addr_t addr, tx_to_ioat_desc(tx)->dst = addr; } +/** + * ioat_dma_memcpy_issue_pending - push potentially unrecognized appended + * descriptors to hw + * @chan: DMA channel handle + */ static inline void __ioat1_dma_memcpy_issue_pending( - struct ioat_dma_chan *ioat_chan); + struct ioat_dma_chan *ioat_chan) +{ + ioat_chan->pending = 0; + writeb(IOAT_CHANCMD_APPEND, ioat_chan->reg_base + IOAT1_CHANCMD_OFFSET); +} + +static void ioat1_dma_memcpy_issue_pending(struct dma_chan *chan) +{ + struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); + + if (ioat_chan->pending != 0) { + spin_lock_bh(&ioat_chan->desc_lock); + __ioat1_dma_memcpy_issue_pending(ioat_chan); + spin_unlock_bh(&ioat_chan->desc_lock); + } +} + static inline void __ioat2_dma_memcpy_issue_pending( - struct ioat_dma_chan *ioat_chan); + struct ioat_dma_chan *ioat_chan) +{ + ioat_chan->pending = 0; + writew(ioat_chan->dmacount, + ioat_chan->reg_base + IOAT_CHAN_DMACOUNT_OFFSET); +} + +static void ioat2_dma_memcpy_issue_pending(struct dma_chan *chan) +{ + struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); + + if (ioat_chan->pending != 0) { + spin_lock_bh(&ioat_chan->desc_lock); + __ioat2_dma_memcpy_issue_pending(ioat_chan); + spin_unlock_bh(&ioat_chan->desc_lock); + } +} static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx) { @@ -203,7 +240,7 @@ static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx) prev = to_ioat_desc(ioat_chan->used_desc.prev); prefetch(prev->hw); do { - copy = min((u32) len, ioat_chan->xfercap); + copy = min_t(size_t, len, ioat_chan->xfercap); new->async_tx.ack = 1; @@ -291,10 +328,12 @@ static dma_cookie_t ioat2_tx_submit(struct dma_async_tx_descriptor *tx) orig_ack = first->async_tx.ack; new = first; - /* ioat_chan->desc_lock is still in force in version 2 path */ - + /* + * ioat_chan->desc_lock is still in force in version 2 path + * it gets unlocked at end of this function + */ do { - copy = min((u32) len, ioat_chan->xfercap); + copy = min_t(size_t, len, ioat_chan->xfercap); new->async_tx.ack = 1; @@ -432,7 +471,7 @@ static void ioat2_dma_massage_chan_desc(struct ioat_dma_chan *ioat_chan) static int ioat_dma_alloc_chan_resources(struct dma_chan *chan) { struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); - struct ioat_desc_sw *desc = NULL; + struct ioat_desc_sw *desc; u16 chanctrl; u32 chanerr; int i; @@ -575,7 +614,7 @@ static void ioat_dma_free_chan_resources(struct dma_chan *chan) static struct ioat_desc_sw * ioat1_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan) { - struct ioat_desc_sw *new = NULL; + struct ioat_desc_sw *new; if (!list_empty(&ioat_chan->free_desc)) { new = to_ioat_desc(ioat_chan->free_desc.next); @@ -583,9 +622,11 @@ ioat1_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan) } else { /* try to get another desc */ new = ioat_dma_alloc_descriptor(ioat_chan, GFP_ATOMIC); - /* will this ever happen? */ - /* TODO add upper limit on these */ - BUG_ON(!new); + if (!new) { + dev_err(&ioat_chan->device->pdev->dev, + "alloc failed\n"); + return NULL; + } } prefetch(new->hw); @@ -595,7 +636,7 @@ ioat1_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan) static struct ioat_desc_sw * ioat2_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan) { - struct ioat_desc_sw *new = NULL; + struct ioat_desc_sw *new; /* * used.prev points to where to start processing @@ -609,8 +650,8 @@ ioat2_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan) if (ioat_chan->used_desc.prev && ioat_chan->used_desc.next == ioat_chan->used_desc.prev->prev) { - struct ioat_desc_sw *desc = NULL; - struct ioat_desc_sw *noop_desc = NULL; + struct ioat_desc_sw *desc; + struct ioat_desc_sw *noop_desc; int i; /* set up the noop descriptor */ @@ -624,10 +665,14 @@ ioat2_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan) ioat_chan->pending++; ioat_chan->dmacount++; - /* get a few more descriptors */ + /* try to get a few more descriptors */ for (i = 16; i; i--) { desc = ioat_dma_alloc_descriptor(ioat_chan, GFP_ATOMIC); - BUG_ON(!desc); + if (!desc) { + dev_err(&ioat_chan->device->pdev->dev, + "alloc failed\n"); + break; + } list_add_tail(&desc->node, ioat_chan->used_desc.next); desc->hw->next @@ -677,10 +722,13 @@ static struct dma_async_tx_descriptor *ioat1_dma_prep_memcpy( spin_lock_bh(&ioat_chan->desc_lock); new = ioat_dma_get_next_descriptor(ioat_chan); - new->len = len; spin_unlock_bh(&ioat_chan->desc_lock); - return new ? &new->async_tx : NULL; + if (new) { + new->len = len; + return &new->async_tx; + } else + return NULL; } static struct dma_async_tx_descriptor *ioat2_dma_prep_memcpy( @@ -693,53 +741,17 @@ static struct dma_async_tx_descriptor *ioat2_dma_prep_memcpy( spin_lock_bh(&ioat_chan->desc_lock); new = ioat2_dma_get_next_descriptor(ioat_chan); - new->len = len; - - /* leave ioat_chan->desc_lock set in version 2 path */ - return new ? &new->async_tx : NULL; -} - - -/** - * ioat_dma_memcpy_issue_pending - push potentially unrecognized appended - * descriptors to hw - * @chan: DMA channel handle - */ -static inline void __ioat1_dma_memcpy_issue_pending( - struct ioat_dma_chan *ioat_chan) -{ - ioat_chan->pending = 0; - writeb(IOAT_CHANCMD_APPEND, ioat_chan->reg_base + IOAT1_CHANCMD_OFFSET); -} - -static void ioat1_dma_memcpy_issue_pending(struct dma_chan *chan) -{ - struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); - - if (ioat_chan->pending != 0) { - spin_lock_bh(&ioat_chan->desc_lock); - __ioat1_dma_memcpy_issue_pending(ioat_chan); - spin_unlock_bh(&ioat_chan->desc_lock); - } -} - -static inline void __ioat2_dma_memcpy_issue_pending( - struct ioat_dma_chan *ioat_chan) -{ - ioat_chan->pending = 0; - writew(ioat_chan->dmacount, - ioat_chan->reg_base + IOAT_CHAN_DMACOUNT_OFFSET); -} -static void ioat2_dma_memcpy_issue_pending(struct dma_chan *chan) -{ - struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); + /* + * leave ioat_chan->desc_lock set in ioat 2 path + * it will get unlocked at end of tx_submit + */ - if (ioat_chan->pending != 0) { - spin_lock_bh(&ioat_chan->desc_lock); - __ioat2_dma_memcpy_issue_pending(ioat_chan); - spin_unlock_bh(&ioat_chan->desc_lock); - } + if (new) { + new->len = len; + return &new->async_tx; + } else + return NULL; } static void ioat_dma_cleanup_tasklet(unsigned long data) @@ -1019,7 +1031,7 @@ static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan) static void ioat_dma_test_callback(void *dma_async_param) { printk(KERN_ERR "ioatdma: ioat_dma_test_callback(%p)\n", - dma_async_param); + dma_async_param); } /** @@ -1032,7 +1044,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device) u8 *src; u8 *dest; struct dma_chan *dma_chan; - struct dma_async_tx_descriptor *tx = NULL; + struct dma_async_tx_descriptor *tx; dma_addr_t addr; dma_cookie_t cookie; int err = 0; diff --git a/drivers/dma/ioatdma.h b/drivers/dma/ioatdma.h index b668234ef65..f2c7fedbf00 100644 --- a/drivers/dma/ioatdma.h +++ b/drivers/dma/ioatdma.h @@ -76,7 +76,7 @@ struct ioat_dma_chan { dma_cookie_t completed_cookie; unsigned long last_completion; - u32 xfercap; /* XFERCAP register value expanded out */ + size_t xfercap; /* XFERCAP register value expanded out */ spinlock_t cleanup_lock; spinlock_t desc_lock; -- cgit v1.2.3 From bb8e8bcce7eceacb52eb0a3ebb64202ad6bcc438 Mon Sep 17 00:00:00 2001 From: Shannon Nelson Date: Mon, 17 Dec 2007 16:20:08 -0800 Subject: I/OAT: fix null device in call to dev_err() We can't use the device in a dev_err() after a kzalloc failure or after the kfree, so simplify it to the pdev that was originally passed in. Cc: Eric Sesterhenn Signed-off-by: Shannon Nelson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/dma/ioat_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c index c17ec327606..45e7b4666c7 100644 --- a/drivers/dma/ioat_dma.c +++ b/drivers/dma/ioat_dma.c @@ -1363,7 +1363,7 @@ err_completion_pool: err_dma_pool: kfree(device); err_kzalloc: - dev_err(&device->pdev->dev, + dev_err(&pdev->dev, "Intel(R) I/OAT DMA Engine initialization failed\n"); return NULL; } -- cgit v1.2.3 From 458cf5e9b666c251b04cb5242fb19fd5114645ba Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 17 Dec 2007 20:24:20 +0100 Subject: Cleanup umem driver: fix most checkpatch warnings, conform to kernel coding style. linux-2.6.24-rc5-git3> checkpatch.pl-next patches/block-umem-ckpatch.patch total: 0 errors, 5 warnings, 530 lines checked All of these are line-length warnings. Only change in generated object file is due to not initializing a static global variable to 0. Signed-off-by: Randy Dunlap Signed-off-by: Jens Axboe --- drivers/block/umem.c | 237 ++++++++++++++++++--------------------------------- 1 file changed, 81 insertions(+), 156 deletions(-) (limited to 'drivers') diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 5f5095afb06..c24e1bdbad4 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c @@ -34,7 +34,7 @@ * - set initialised bit then. */ -//#define DEBUG /* uncomment if you want debugging info (pr_debug) */ +#undef DEBUG /* #define DEBUG if you want debugging info (pr_debug) */ #include #include #include @@ -143,17 +143,12 @@ static struct cardinfo cards[MM_MAXCARDS]; static struct block_device_operations mm_fops; static struct timer_list battery_timer; -static int num_cards = 0; +static int num_cards; static struct gendisk *mm_gendisk[MM_MAXCARDS]; static void check_batteries(struct cardinfo *card); -/* ------------------------------------------------------------------------------------ --- get_userbit ------------------------------------------------------------------------------------ -*/ static int get_userbit(struct cardinfo *card, int bit) { unsigned char led; @@ -161,11 +156,7 @@ static int get_userbit(struct cardinfo *card, int bit) led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL); return led & bit; } -/* ------------------------------------------------------------------------------------ --- set_userbit ------------------------------------------------------------------------------------ -*/ + static int set_userbit(struct cardinfo *card, int bit, unsigned char state) { unsigned char led; @@ -179,11 +170,7 @@ static int set_userbit(struct cardinfo *card, int bit, unsigned char state) return 0; } -/* ------------------------------------------------------------------------------------ --- set_led ------------------------------------------------------------------------------------ -*/ + /* * NOTE: For the power LED, use the LED_POWER_* macros since they differ */ @@ -203,11 +190,6 @@ static void set_led(struct cardinfo *card, int shift, unsigned char state) } #ifdef MM_DIAG -/* ------------------------------------------------------------------------------------ --- dump_regs ------------------------------------------------------------------------------------ -*/ static void dump_regs(struct cardinfo *card) { unsigned char *p; @@ -224,32 +206,28 @@ static void dump_regs(struct cardinfo *card) } } #endif -/* ------------------------------------------------------------------------------------ --- dump_dmastat ------------------------------------------------------------------------------------ -*/ + static void dump_dmastat(struct cardinfo *card, unsigned int dmastat) { dev_printk(KERN_DEBUG, &card->dev->dev, "DMAstat - "); if (dmastat & DMASCR_ANY_ERR) - printk("ANY_ERR "); + printk(KERN_CONT "ANY_ERR "); if (dmastat & DMASCR_MBE_ERR) - printk("MBE_ERR "); + printk(KERN_CONT "MBE_ERR "); if (dmastat & DMASCR_PARITY_ERR_REP) - printk("PARITY_ERR_REP "); + printk(KERN_CONT "PARITY_ERR_REP "); if (dmastat & DMASCR_PARITY_ERR_DET) - printk("PARITY_ERR_DET "); + printk(KERN_CONT "PARITY_ERR_DET "); if (dmastat & DMASCR_SYSTEM_ERR_SIG) - printk("SYSTEM_ERR_SIG "); + printk(KERN_CONT "SYSTEM_ERR_SIG "); if (dmastat & DMASCR_TARGET_ABT) - printk("TARGET_ABT "); + printk(KERN_CONT "TARGET_ABT "); if (dmastat & DMASCR_MASTER_ABT) - printk("MASTER_ABT "); + printk(KERN_CONT "MASTER_ABT "); if (dmastat & DMASCR_CHAIN_COMPLETE) - printk("CHAIN_COMPLETE "); + printk(KERN_CONT "CHAIN_COMPLETE "); if (dmastat & DMASCR_DMA_COMPLETE) - printk("DMA_COMPLETE "); + printk(KERN_CONT "DMA_COMPLETE "); printk("\n"); } @@ -286,7 +264,8 @@ static void mm_start_io(struct cardinfo *card) /* make the last descriptor end the chain */ page = &card->mm_pages[card->Active]; - pr_debug("start_io: %d %d->%d\n", card->Active, page->headcnt, page->cnt-1); + pr_debug("start_io: %d %d->%d\n", + card->Active, page->headcnt, page->cnt - 1); desc = &page->desc[page->cnt-1]; desc->control_bits |= cpu_to_le32(DMASCR_CHAIN_COMP_EN); @@ -310,8 +289,8 @@ static void mm_start_io(struct cardinfo *card) writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR); writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR + 4); - offset = ((char*)desc) - ((char*)page->desc); - writel(cpu_to_le32((page->page_dma+offset)&0xffffffff), + offset = ((char *)desc) - ((char *)page->desc); + writel(cpu_to_le32((page->page_dma+offset) & 0xffffffff), card->csr_remap + DMA_DESCRIPTOR_ADDR); /* Force the value to u64 before shifting otherwise >> 32 is undefined C * and on some ports will do nothing ! */ @@ -352,7 +331,7 @@ static inline void reset_page(struct mm_page *page) page->cnt = 0; page->headcnt = 0; page->bio = NULL; - page->biotail = & page->bio; + page->biotail = &page->bio; } static void mm_unplug_device(struct request_queue *q) @@ -408,7 +387,7 @@ static int add_bio(struct cardinfo *card) vec->bv_page, vec->bv_offset, len, - (rw==READ) ? + (rw == READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); p = &card->mm_pages[card->Ready]; @@ -427,10 +406,10 @@ static int add_bio(struct cardinfo *card) desc->pci_addr = cpu_to_le64((u64)desc->data_dma_handle); desc->local_addr = cpu_to_le64(card->current_sector << 9); desc->transfer_size = cpu_to_le32(len); - offset = ( ((char*)&desc->sem_control_bits) - ((char*)p->desc)); + offset = (((char *)&desc->sem_control_bits) - ((char *)p->desc)); desc->sem_addr = cpu_to_le64((u64)(p->page_dma+offset)); desc->zero1 = desc->zero2 = 0; - offset = ( ((char*)(desc+1)) - ((char*)p->desc)); + offset = (((char *)(desc+1)) - ((char *)p->desc)); desc->next_desc_addr = cpu_to_le64(p->page_dma+offset); desc->control_bits = cpu_to_le32(DMASCR_GO|DMASCR_ERR_INT_EN| DMASCR_PARITY_INT_EN| @@ -455,11 +434,11 @@ static void process_page(unsigned long data) /* check if any of the requests in the page are DMA_COMPLETE, * and deal with them appropriately. * If we find a descriptor without DMA_COMPLETE in the semaphore, then - * dma must have hit an error on that descriptor, so use dma_status instead - * and assume that all following descriptors must be re-tried. + * dma must have hit an error on that descriptor, so use dma_status + * instead and assume that all following descriptors must be re-tried. */ struct mm_page *page; - struct bio *return_bio=NULL; + struct bio *return_bio = NULL; struct cardinfo *card = (struct cardinfo *)data; unsigned int dma_status = card->dma_status; @@ -472,12 +451,12 @@ static void process_page(unsigned long data) struct bio *bio = page->bio; struct mm_dma_desc *desc = &page->desc[page->headcnt]; int control = le32_to_cpu(desc->sem_control_bits); - int last=0; + int last = 0; int idx; if (!(control & DMASCR_DMA_COMPLETE)) { control = dma_status; - last=1; + last = 1; } page->headcnt++; idx = page->idx; @@ -489,8 +468,8 @@ static void process_page(unsigned long data) } pci_unmap_page(card->dev, desc->data_dma_handle, - bio_iovec_idx(bio,idx)->bv_len, - (control& DMASCR_TRANSFER_READ) ? + bio_iovec_idx(bio, idx)->bv_len, + (control & DMASCR_TRANSFER_READ) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); if (control & DMASCR_HARD_ERROR) { /* error */ @@ -501,9 +480,10 @@ static void process_page(unsigned long data) le32_to_cpu(desc->transfer_size)); dump_dmastat(card, control); } else if (test_bit(BIO_RW, &bio->bi_rw) && - le32_to_cpu(desc->local_addr)>>9 == card->init_size) { - card->init_size += le32_to_cpu(desc->transfer_size)>>9; - if (card->init_size>>1 >= card->mm_size) { + le32_to_cpu(desc->local_addr) >> 9 == + card->init_size) { + card->init_size += le32_to_cpu(desc->transfer_size) >> 9; + if (card->init_size >> 1 >= card->mm_size) { dev_printk(KERN_INFO, &card->dev->dev, "memory now initialised\n"); set_userbit(card, MEMORY_INITIALIZED, 1); @@ -514,7 +494,8 @@ static void process_page(unsigned long data) return_bio = bio; } - if (last) break; + if (last) + break; } if (debug & DEBUG_LED_ON_TRANSFER) @@ -536,7 +517,7 @@ static void process_page(unsigned long data) out_unlock: spin_unlock_bh(&card->lock); - while(return_bio) { + while (return_bio) { struct bio *bio = return_bio; return_bio = bio->bi_next; @@ -545,11 +526,6 @@ static void process_page(unsigned long data) } } -/* ------------------------------------------------------------------------------------ --- mm_make_request ------------------------------------------------------------------------------------ -*/ static int mm_make_request(struct request_queue *q, struct bio *bio) { struct cardinfo *card = q->queuedata; @@ -566,11 +542,6 @@ static int mm_make_request(struct request_queue *q, struct bio *bio) return 0; } -/* ------------------------------------------------------------------------------------ --- mm_interrupt ------------------------------------------------------------------------------------ -*/ static irqreturn_t mm_interrupt(int irq, void *__card) { struct cardinfo *card = (struct cardinfo *) __card; @@ -584,15 +555,15 @@ HW_TRACE(0x30); if (!(dma_status & (DMASCR_ERROR_MASK | DMASCR_CHAIN_COMPLETE))) { /* interrupt wasn't for me ... */ return IRQ_NONE; - } + } /* clear COMPLETION interrupts */ if (card->flags & UM_FLAG_NO_BYTE_STATUS) writel(cpu_to_le32(DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE), - card->csr_remap+ DMA_STATUS_CTRL); + card->csr_remap + DMA_STATUS_CTRL); else writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16, - card->csr_remap+ DMA_STATUS_CTRL + 2); + card->csr_remap + DMA_STATUS_CTRL + 2); /* log errors and clear interrupt status */ if (dma_status & DMASCR_ANY_ERR) { @@ -602,9 +573,12 @@ HW_TRACE(0x30); stat = readb(card->csr_remap + MEMCTRLCMD_ERRSTATUS); - data_log1 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG)); - data_log2 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG + 4)); - addr_log1 = le32_to_cpu(readl(card->csr_remap + ERROR_ADDR_LOG)); + data_log1 = le32_to_cpu(readl(card->csr_remap + + ERROR_DATA_LOG)); + data_log2 = le32_to_cpu(readl(card->csr_remap + + ERROR_DATA_LOG + 4)); + addr_log1 = le32_to_cpu(readl(card->csr_remap + + ERROR_ADDR_LOG)); addr_log2 = readb(card->csr_remap + ERROR_ADDR_LOG + 4); count = readb(card->csr_remap + ERROR_COUNT); @@ -671,11 +645,7 @@ HW_TRACE(0x36); return IRQ_HANDLED; } -/* ------------------------------------------------------------------------------------ --- set_fault_to_battery_status ------------------------------------------------------------------------------------ -*/ + /* * If both batteries are good, no LED * If either battery has been warned, solid LED @@ -696,12 +666,6 @@ static void set_fault_to_battery_status(struct cardinfo *card) static void init_battery_timer(void); - -/* ------------------------------------------------------------------------------------ --- check_battery ------------------------------------------------------------------------------------ -*/ static int check_battery(struct cardinfo *card, int battery, int status) { if (status != card->battery[battery].good) { @@ -730,11 +694,7 @@ static int check_battery(struct cardinfo *card, int battery, int status) return 0; } -/* ------------------------------------------------------------------------------------ --- check_batteries ------------------------------------------------------------------------------------ -*/ + static void check_batteries(struct cardinfo *card) { /* NOTE: this must *never* be called while the card @@ -775,11 +735,7 @@ static void check_all_batteries(unsigned long ptr) init_battery_timer(); } -/* ------------------------------------------------------------------------------------ --- init_battery_timer ------------------------------------------------------------------------------------ -*/ + static void init_battery_timer(void) { init_timer(&battery_timer); @@ -787,20 +743,12 @@ static void init_battery_timer(void) battery_timer.expires = jiffies + (HZ * 60); add_timer(&battery_timer); } -/* ------------------------------------------------------------------------------------ --- del_battery_timer ------------------------------------------------------------------------------------ -*/ + static void del_battery_timer(void) { del_timer(&battery_timer); } -/* ------------------------------------------------------------------------------------ --- mm_revalidate ------------------------------------------------------------------------------------ -*/ + /* * Note no locks taken out here. In a worst case scenario, we could drop * a chunk of system memory. But that should never happen, since validation @@ -833,33 +781,23 @@ static int mm_getgeo(struct block_device *bdev, struct hd_geometry *geo) } /* ------------------------------------------------------------------------------------ --- mm_check_change ------------------------------------------------------------------------------------ - Future support for removable devices -*/ + * Future support for removable devices + */ static int mm_check_change(struct gendisk *disk) { /* struct cardinfo *dev = disk->private_data; */ return 0; } -/* ------------------------------------------------------------------------------------ --- mm_fops ------------------------------------------------------------------------------------ -*/ + static struct block_device_operations mm_fops = { .owner = THIS_MODULE, .getgeo = mm_getgeo, - .revalidate_disk= mm_revalidate, + .revalidate_disk = mm_revalidate, .media_changed = mm_check_change, }; -/* ------------------------------------------------------------------------------------ --- mm_pci_probe ------------------------------------------------------------------------------------ -*/ -static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) + +static int __devinit mm_pci_probe(struct pci_dev *dev, + const struct pci_device_id *id) { int ret = -ENODEV; struct cardinfo *card = &cards[num_cards]; @@ -889,7 +827,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i return -ENODEV; dev_printk(KERN_INFO, &dev->dev, - "Micro Memory(tm) controller found (PCI Mem Module (Battery Backup))\n"); + "Micro Memory(tm) controller found (PCI Mem Module (Battery Backup))\n"); if (pci_set_dma_mask(dev, DMA_64BIT_MASK) && pci_set_dma_mask(dev, DMA_32BIT_MASK)) { @@ -917,7 +855,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i "CSR 0x%08lx -> 0x%p (0x%lx)\n", csr_base, card->csr_remap, csr_len); - switch(card->dev->device) { + switch (card->dev->device) { case 0x5415: card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG; magic_number = 0x59; @@ -929,7 +867,8 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i break; case 0x6155: - card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG | UM_FLAG_NO_BATT; + card->flags |= UM_FLAG_NO_BYTE_STATUS | + UM_FLAG_NO_BATTREG | UM_FLAG_NO_BATT; magic_number = 0x99; break; @@ -945,11 +884,11 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i } card->mm_pages[0].desc = pci_alloc_consistent(card->dev, - PAGE_SIZE*2, - &card->mm_pages[0].page_dma); + PAGE_SIZE * 2, + &card->mm_pages[0].page_dma); card->mm_pages[1].desc = pci_alloc_consistent(card->dev, - PAGE_SIZE*2, - &card->mm_pages[1].page_dma); + PAGE_SIZE * 2, + &card->mm_pages[1].page_dma); if (card->mm_pages[0].desc == NULL || card->mm_pages[1].desc == NULL) { dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n"); @@ -1013,9 +952,9 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i dev_printk(KERN_INFO, &card->dev->dev, "Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n", card->mm_size, - (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"), + batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled", card->battery[0].good ? "OK" : "FAILURE", - (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"), + batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled", card->battery[1].good ? "OK" : "FAILURE"); set_fault_to_battery_status(card); @@ -1030,18 +969,18 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i data = ~data; data += 1; - if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, DRIVER_NAME, card)) { + if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, DRIVER_NAME, + card)) { dev_printk(KERN_ERR, &card->dev->dev, "Unable to allocate IRQ\n"); ret = -ENODEV; - goto failed_req_irq; } dev_printk(KERN_INFO, &card->dev->dev, "Window size %d bytes, IRQ %d\n", data, dev->irq); - spin_lock_init(&card->lock); + spin_lock_init(&card->lock); pci_set_drvdata(dev, card); @@ -1060,7 +999,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i if (!get_userbit(card, MEMORY_INITIALIZED)) { dev_printk(KERN_INFO, &card->dev->dev, - "memory NOT initialized. Consider over-writing whole device.\n"); + "memory NOT initialized. Consider over-writing whole device.\n"); card->init_size = 0; } else { dev_printk(KERN_INFO, &card->dev->dev, @@ -1091,11 +1030,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i return ret; } -/* ------------------------------------------------------------------------------------ --- mm_pci_remove ------------------------------------------------------------------------------------ -*/ + static void mm_pci_remove(struct pci_dev *dev) { struct cardinfo *card = pci_get_drvdata(dev); @@ -1119,16 +1054,16 @@ static void mm_pci_remove(struct pci_dev *dev) } static const struct pci_device_id mm_pci_ids[] = { - {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY,PCI_DEVICE_ID_MICRO_MEMORY_5415CN)}, - {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY,PCI_DEVICE_ID_MICRO_MEMORY_5425CN)}, - {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY,PCI_DEVICE_ID_MICRO_MEMORY_6155)}, + {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY, PCI_DEVICE_ID_MICRO_MEMORY_5415CN)}, + {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY, PCI_DEVICE_ID_MICRO_MEMORY_5425CN)}, + {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY, PCI_DEVICE_ID_MICRO_MEMORY_6155)}, { .vendor = 0x8086, .device = 0xB555, - .subvendor= 0x1332, - .subdevice= 0x5460, - .class = 0x050000, - .class_mask= 0, + .subvendor = 0x1332, + .subdevice = 0x5460, + .class = 0x050000, + .class_mask = 0, }, { /* end: all zeroes */ } }; @@ -1141,12 +1076,6 @@ static struct pci_driver mm_pci_driver = { .remove = mm_pci_remove, }; -/* ------------------------------------------------------------------------------------ --- mm_init ------------------------------------------------------------------------------------ -*/ - static int __init mm_init(void) { int retval, i; @@ -1193,18 +1122,14 @@ out: put_disk(mm_gendisk[i]); return -ENOMEM; } -/* ------------------------------------------------------------------------------------ --- mm_cleanup ------------------------------------------------------------------------------------ -*/ + static void __exit mm_cleanup(void) { int i; del_battery_timer(); - for (i=0; i < num_cards ; i++) { + for (i = 0; i < num_cards ; i++) { del_gendisk(mm_gendisk[i]); put_disk(mm_gendisk[i]); } -- cgit v1.2.3 From 7ee2413ca0da80c819f2388c0faeffce1ac8513b Mon Sep 17 00:00:00 2001 From: Tony Battersby Date: Tue, 6 Nov 2007 14:40:54 -0500 Subject: [SCSI] sym53c8xx: fix free_irq() regression The following commit changed the pointer passed to request_irq(), but failed to change the pointer passed to free_irq(): commit 99c9e0a1d6cfe1ba1169a7a81435ee85bc00e4a1 Author: Matthew Wilcox Date: Fri Oct 5 15:55:12 2007 -0400 [SCSI] sym53c8xx: Make interrupt handler capable of returning IRQ_NONE ... The result is that free_irq() doesn't actually take any action. This patch fixes it. Signed-off-by: Tony Battersby Acked-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 0f74aba5b23..9e0908d1981 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1243,7 +1243,7 @@ static void sym_free_resources(struct sym_hcb *np, struct pci_dev *pdev) * Free O/S specific resources. */ if (pdev->irq) - free_irq(pdev->irq, np); + free_irq(pdev->irq, np->s.host); if (np->s.ioaddr) pci_iounmap(pdev, np->s.ioaddr); if (np->s.ramaddr) -- cgit v1.2.3 From c80ddf00cde4c21018dbd0ea2872736c90c7dda2 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 12 Dec 2007 15:06:21 -0500 Subject: [SCSI] dpt_i2o: driver is only 32 bit so don't set 64 bit DMA mask This fixes a potential corruption bug where the truncation would cause reading or writing to the wrong memory area on machines with >4GB of main memory. Cc: Stable Kernel Tree Signed-off-by: James Bottomley --- drivers/scsi/dpt_i2o.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 70f48a1a6d5..b31d1c95c9f 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -906,8 +906,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev } pci_set_master(pDev); - if (pci_set_dma_mask(pDev, DMA_64BIT_MASK) && - pci_set_dma_mask(pDev, DMA_32BIT_MASK)) + if (pci_set_dma_mask(pDev, DMA_32BIT_MASK)) return -EINVAL; base_addr0_phys = pci_resource_start(pDev,0); -- cgit v1.2.3 From cedefa13db502432905c29819c195f46805b13eb Mon Sep 17 00:00:00 2001 From: Tony Battersby Date: Fri, 14 Dec 2007 15:45:16 -0500 Subject: [SCSI] sym53c8xx: fix "irq X: nobody cared" regression The patch described by the following excerpt from ChangeLog-2.6.24-rc1 eventually causes a "irq X: nobody cared" error after a while: commit 99c9e0a1d6cfe1ba1169a7a81435ee85bc00e4a1 Author: Matthew Wilcox Date: Fri Oct 5 15:55:12 2007 -0400 [SCSI] sym53c8xx: Make interrupt handler capable of returning IRQ_NONE After this happens, the kernel disables the IRQ, causing the SCSI card to stop working until the next reboot. The problem is caused by the interrupt handler returning IRQ_NONE instead of IRQ_HANDLED after handling an interrupt-on-the-fly (INTF) condition. The following patch fixes the problem. Signed-off-by: Tony Battersby Acked-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_hipd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 463f119f20e..254bdaeb35f 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -2791,7 +2791,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) istat = INB(np, nc_istat); if (istat & INTF) { OUTB(np, nc_istat, (istat & SIGP) | INTF | np->istat_sem); - istat = INB(np, nc_istat); /* DUMMY READ */ + istat |= INB(np, nc_istat); /* DUMMY READ */ if (DEBUG_FLAGS & DEBUG_TINY) printf ("F "); sym_wakeup_done(np); } -- cgit v1.2.3 From 99f1f534922a2f2251ba05b14657a1c62882a80e Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 13 Dec 2007 16:14:05 -0800 Subject: [SCSI] initio: fix conflict when loading driver > I have a scanner connected to a Initio INI-950 SCSI card and I recently > upgraded from SuSE 10.2 to 10.3. The new kernel doesn't see any of my > devices. I get the following in /var/log/messages: > > ACPI: PCI Interrupt 0000:00:0a.0[A] -> GSI 17 (level, low) -> IRQ 16 > initio: I/O port range 0x0 is busy. > ACPI: PCI interrupt for device 0000:00:0a.0 disabled Humm not a collision - thats a bug in the driver updating. Looks like the changes I made and combined with Christoph's lost a line somewhere when I was merging it all. Signed-off-by: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/scsi/initio.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index 4c4465d39a1..769a7a80585 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c @@ -2867,6 +2867,7 @@ static int initio_probe_one(struct pci_dev *pdev, } host = (struct initio_host *)shost->hostdata; memset(host, 0, sizeof(struct initio_host)); + host->addr = pci_resource_start(pdev, 0); if (!request_region(host->addr, 256, "i91u")) { printk(KERN_WARNING "initio: I/O port range 0x%x is busy.\n", host->addr); -- cgit v1.2.3 From cd81621c5c5c869b848818b506962dab4499e0d9 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sat, 15 Dec 2007 15:51:55 +0900 Subject: [SCSI] st: fix kernel BUG at include/linux/scatterlist.h:59! This is caused by a missing scatterlist initialisation (it only shows up when sg list handling debugging is turned on). Signed-off-by: FUJITA Tomonori Cc: Kai Makisara Signed-off-by: James Bottomley --- drivers/scsi/st.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 98dfd6ea209..328c47c6aeb 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -3611,6 +3611,7 @@ static struct st_buffer * tb->dma = need_dma; tb->buffer_size = got; + sg_init_table(tb->sg, max_sg); return tb; } -- cgit v1.2.3 From a169e63740779f62a9a5ddf0aa61091a393a03c5 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Mon, 17 Dec 2007 18:08:59 +0200 Subject: [SCSI] initio: bugfix for accessors patch patch: [SCSI] initio: convert to use the data buffer accessors had a small but fatal bug in that it didn't increment the pointer into the initio scatterlist descriptors as it looped over the block generated ones. Fixed here. Signed-off-by: Boaz Harrosh Signed-off-by: James Bottomley --- drivers/scsi/initio.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index 769a7a80585..01bf0189367 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c @@ -2616,6 +2616,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c scsi_for_each_sg(cmnd, sglist, cblk->sglen, i) { sg->data = cpu_to_le32((u32)sg_dma_address(sglist)); total_len += sg->len = cpu_to_le32((u32)sg_dma_len(sglist)); + ++sg; } cblk->buflen = (scsi_bufflen(cmnd) > total_len) ? -- cgit v1.2.3 From 9ac67a35827ee03d71f2f1c656a725e263b14a7e Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 19 Dec 2007 11:16:41 +0100 Subject: ps3fb: Update for firmware 2.10 ps3fb: Update for firmware 2.10 As of PS3 firmware version 2.10, the GPU command buffer size must be at least 2 MiB large. Since we use only a small part of the GPU command buffer and don't want to waste precious XDR memory, move the GPU command buffer back to the start of the XDR memory reserved for ps3fb and let the unused part overlap with the actual frame buffer. Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Torvalds --- drivers/video/ps3fb.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c index 9c56c492a69..614586557cd 100644 --- a/drivers/video/ps3fb.c +++ b/drivers/video/ps3fb.c @@ -51,7 +51,8 @@ #define L1GPU_DISPLAY_SYNC_HSYNC 1 #define L1GPU_DISPLAY_SYNC_VSYNC 2 -#define GPU_CMD_BUF_SIZE (64 * 1024) +#define GPU_CMD_BUF_SIZE (2 * 1024 * 1024) +#define GPU_FB_START (64 * 1024) #define GPU_IOIF (0x0d000000UL) #define GPU_ALIGN_UP(x) _ALIGN_UP((x), 64) #define GPU_MAX_LINE_LENGTH (65536 - 64) @@ -406,6 +407,7 @@ static void ps3fb_sync_image(struct device *dev, u64 frame_offset, if (src_line_length != dst_line_length) line_length |= (u64)src_line_length << 32; + src_offset += GPU_FB_START; status = lv1_gpu_context_attribute(ps3fb.context_handle, L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, dst_offset, GPU_IOIF + src_offset, @@ -976,9 +978,8 @@ static int ps3fb_xdr_settings(u64 xdr_lpar, struct device *dev) status = lv1_gpu_context_attribute(ps3fb.context_handle, L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP, - xdr_lpar + ps3fb.xdr_size, - GPU_CMD_BUF_SIZE, - GPU_IOIF + ps3fb.xdr_size, 0); + xdr_lpar, GPU_CMD_BUF_SIZE, + GPU_IOIF, 0); if (status) { dev_err(dev, "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n", @@ -1061,6 +1062,11 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev) struct task_struct *task; unsigned long max_ps3fb_size; + if (ps3fb_videomemory.size < GPU_CMD_BUF_SIZE) { + dev_err(&dev->core, "%s: Not enough video memory\n", __func__); + return -ENOMEM; + } + status = ps3_open_hv_device(dev); if (status) { dev_err(&dev->core, "%s: ps3_open_hv_device failed\n", @@ -1131,8 +1137,14 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev) /* Clear memory to prevent kernel info leakage into userspace */ memset(ps3fb.xdr_ea, 0, ps3fb_videomemory.size); - /* The GPU command buffer is at the end of video memory */ - ps3fb.xdr_size = ps3fb_videomemory.size - GPU_CMD_BUF_SIZE; + /* + * The GPU command buffer is at the start of video memory + * As we don't use the full command buffer, we can put the actual + * frame buffer at offset GPU_FB_START and save some precious XDR + * memory + */ + ps3fb.xdr_ea += GPU_FB_START; + ps3fb.xdr_size = ps3fb_videomemory.size - GPU_FB_START; retval = ps3fb_xdr_settings(xdr_lpar, &dev->core); if (retval) -- cgit v1.2.3 From fcbe6e9709f90fd83cfa614a4e0efe83174018ea Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Wed, 19 Dec 2007 11:17:31 +0100 Subject: ps3fb: Fix ps3fb free_irq() dev_id The dev_id arg passed to free_irq() must match that passed to request_irq(). Fixes this PS3 error message: Trying to free already-free IRQ 44 Signed-off-by: Geoff Levand Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Torvalds --- drivers/video/ps3fb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c index 614586557cd..b3128903d67 100644 --- a/drivers/video/ps3fb.c +++ b/drivers/video/ps3fb.c @@ -1212,7 +1212,7 @@ err_fb_dealloc: err_framebuffer_release: framebuffer_release(info); err_free_irq: - free_irq(ps3fb.irq_no, dev); + free_irq(ps3fb.irq_no, &dev->core); ps3_irq_plug_destroy(ps3fb.irq_no); err_iounmap_dinfo: iounmap((u8 __iomem *)ps3fb.dinfo); @@ -1247,7 +1247,7 @@ static int ps3fb_shutdown(struct ps3_system_bus_device *dev) kthread_stop(task); } if (ps3fb.irq_no) { - free_irq(ps3fb.irq_no, dev); + free_irq(ps3fb.irq_no, &dev->core); ps3_irq_plug_destroy(ps3fb.irq_no); } iounmap((u8 __iomem *)ps3fb.dinfo); -- cgit v1.2.3 From f941b168a4d7281bf49e166f2febc49470c0149f Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 19 Dec 2007 17:50:32 +0000 Subject: pata_hpt37x: Fix HPT374 detection Bug #9261 Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/ata/pata_hpt37x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 46dc70e0dee..c79f066c2bc 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c @@ -375,7 +375,7 @@ static int hpt374_pre_reset(struct ata_link *link, unsigned long deadline) pci_write_config_word(pdev, mcrbase + 2, mcr3 | 0x8000); pci_read_config_byte(pdev, 0x5A, &ata66); /* Reset TCBLID/FCBLID to output */ - pci_write_config_word(pdev, 0x52, mcr3); + pci_write_config_word(pdev, mcrbase + 2, mcr3); if (ata66 & (2 >> ap->port_no)) ap->cbl = ATA_CBL_PATA40; -- cgit v1.2.3 From 512875bd9661368da6f993205a61213b79ba1df0 Mon Sep 17 00:00:00 2001 From: Jun'ichi Nomura Date: Thu, 13 Dec 2007 14:15:25 +0000 Subject: dm: table detect io beyond device This patch fixes a panic on shrinking a DM device if there is outstanding I/O to the part of the device that is being removed. (Normally this doesn't happen - a filesystem would be resized first, for example.) The bug is that __clone_and_map() assumes dm_table_find_target() always returns a valid pointer. It may fail if a bio arrives from the block layer but its target sector is no longer included in the DM btree. This patch appends an empty entry to table->targets[] which will be returned by a lookup beyond the end of the device. After calling dm_table_find_target(), __clone_and_map() and target_message() check for this condition using dm_target_is_valid(). Sample test script to trigger oops: --- drivers/md/dm-ioctl.c | 10 +++------- drivers/md/dm-table.c | 7 ++++++- drivers/md/dm.c | 24 ++++++++++++++++++------ drivers/md/dm.h | 5 +++++ 4 files changed, 32 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 138200bf5e0..be730fdd483 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1250,21 +1250,17 @@ static int target_message(struct dm_ioctl *param, size_t param_size) if (!table) goto out_argv; - if (tmsg->sector >= dm_table_get_size(table)) { + ti = dm_table_find_target(table, tmsg->sector); + if (!dm_target_is_valid(ti)) { DMWARN("Target message sector outside device."); r = -EINVAL; - goto out_table; - } - - ti = dm_table_find_target(table, tmsg->sector); - if (ti->type->message) + } else if (ti->type->message) r = ti->type->message(ti, argc, argv); else { DMWARN("Target type does not support messages"); r = -EINVAL; } - out_table: dm_table_put(table); out_argv: kfree(argv); diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index e298d8d11f2..f3f952e347e 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -189,8 +189,10 @@ static int alloc_targets(struct dm_table *t, unsigned int num) /* * Allocate both the target array and offset array at once. + * Append an empty entry to catch sectors beyond the end of + * the device. */ - n_highs = (sector_t *) dm_vcalloc(num, sizeof(struct dm_target) + + n_highs = (sector_t *) dm_vcalloc(num + 1, sizeof(struct dm_target) + sizeof(sector_t)); if (!n_highs) return -ENOMEM; @@ -867,6 +869,9 @@ struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index) /* * Search the btree for the correct target. + * + * Caller should check returned pointer with dm_target_is_valid() + * to trap I/O beyond end of device. */ struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector) { diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 07cbbb8eb3e..cff2a714c10 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -672,13 +672,19 @@ static struct bio *clone_bio(struct bio *bio, sector_t sector, return clone; } -static void __clone_and_map(struct clone_info *ci) +static int __clone_and_map(struct clone_info *ci) { struct bio *clone, *bio = ci->bio; - struct dm_target *ti = dm_table_find_target(ci->map, ci->sector); - sector_t len = 0, max = max_io_len(ci->md, ci->sector, ti); + struct dm_target *ti; + sector_t len = 0, max; struct dm_target_io *tio; + ti = dm_table_find_target(ci->map, ci->sector); + if (!dm_target_is_valid(ti)) + return -EIO; + + max = max_io_len(ci->md, ci->sector, ti); + /* * Allocate a target io object. */ @@ -736,6 +742,9 @@ static void __clone_and_map(struct clone_info *ci) do { if (offset) { ti = dm_table_find_target(ci->map, ci->sector); + if (!dm_target_is_valid(ti)) + return -EIO; + max = max_io_len(ci->md, ci->sector, ti); tio = alloc_tio(ci->md); @@ -759,6 +768,8 @@ static void __clone_and_map(struct clone_info *ci) ci->idx++; } + + return 0; } /* @@ -767,6 +778,7 @@ static void __clone_and_map(struct clone_info *ci) static int __split_bio(struct mapped_device *md, struct bio *bio) { struct clone_info ci; + int error = 0; ci.map = dm_get_table(md); if (unlikely(!ci.map)) @@ -784,11 +796,11 @@ static int __split_bio(struct mapped_device *md, struct bio *bio) ci.idx = bio->bi_idx; start_io_acct(ci.io); - while (ci.sector_count) - __clone_and_map(&ci); + while (ci.sector_count && !error) + error = __clone_and_map(&ci); /* drop the extra reference count */ - dec_pending(ci.io, 0); + dec_pending(ci.io, error); dm_table_put(ci.map); return 0; diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 4b3faa45277..177297a88eb 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -112,6 +112,11 @@ int dm_table_resume_targets(struct dm_table *t); int dm_table_any_congested(struct dm_table *t, int bdi_bits); void dm_table_unplug_all(struct dm_table *t); +/* + * To check the return value from dm_table_find_target(). + */ +#define dm_target_is_valid(t) ((t)->table) + /*----------------------------------------------------------------- * A registry of target types. *---------------------------------------------------------------*/ -- cgit v1.2.3 From d1622e89099b7cdda20d95a68940067bdddda03c Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Thu, 13 Dec 2007 14:15:43 +0000 Subject: dm mpath: hp requires scsi With CONFIG_SCSI=n __scsi_print_sense() is never linked in. drivers/built-in.o: In function `hp_sw_end_io': dm-mpath-hp-sw.c:(.text+0x914f8): undefined reference to `__scsi_print_sense' Caught with a randconfig on current git. Signed-off-by: Paul Mundt Signed-off-by: Alasdair G Kergon --- drivers/md/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 9b6fbf044fd..3fa7c77d9bd 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -269,7 +269,7 @@ config DM_MULTIPATH_RDAC config DM_MULTIPATH_HP tristate "HP MSA multipath support (EXPERIMENTAL)" - depends on DM_MULTIPATH && BLK_DEV_DM && EXPERIMENTAL + depends on DM_MULTIPATH && BLK_DEV_DM && SCSI && EXPERIMENTAL ---help--- Multipath support for HP MSA (Active/Passive) series hardware. -- cgit v1.2.3 From adfe47702c4726b3e045f9f83178def02833be4c Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 13 Dec 2007 14:15:51 +0000 Subject: dm crypt: fix write endio Fix BIO_UPTODATE test for write io. Cc: stable@kernel.org Cc: dm-crypt@saout.de Signed-off-by: Milan Broz Signed-off-by: Alasdair G Kergon --- drivers/md/dm-crypt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 28c6ae095c5..30d51a0c011 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -511,6 +511,9 @@ static void crypt_endio(struct bio *clone, int error) struct crypt_config *cc = io->target->private; unsigned read_io = bio_data_dir(clone) == READ; + if (unlikely(!bio_flagged(clone, BIO_UPTODATE) && !error)) + error = -EIO; + /* * free the processed pages */ @@ -519,10 +522,8 @@ static void crypt_endio(struct bio *clone, int error) goto out; } - if (unlikely(!bio_flagged(clone, BIO_UPTODATE))) { - error = -EIO; + if (unlikely(error)) goto out; - } bio_put(clone); kcryptd_queue_crypt(io); -- cgit v1.2.3 From 69267a30bed1fabec658058c63845528a8b813d4 Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Thu, 13 Dec 2007 14:15:57 +0000 Subject: dm: trigger change uevent on rename Insert a missing KOBJ_CHANGE notification when a device is renamed. Cc: Scott James Remnant Signed-off-by: Alasdair G Kergon --- drivers/md/dm-ioctl.c | 2 ++ drivers/md/dm.c | 7 ++++++- drivers/md/dm.h | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index be730fdd483..9627fa0f947 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -332,6 +332,8 @@ static int dm_hash_rename(const char *old, const char *new) dm_table_put(table); } + dm_kobject_uevent(hc->md); + dm_put(hc->md); up_write(&_hash_lock); kfree(old_name); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index cff2a714c10..88c0fd65782 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1514,7 +1514,7 @@ int dm_resume(struct mapped_device *md) dm_table_unplug_all(map); - kobject_uevent(&md->disk->kobj, KOBJ_CHANGE); + dm_kobject_uevent(md); r = 0; @@ -1528,6 +1528,11 @@ out: /*----------------------------------------------------------------- * Event notification. *---------------------------------------------------------------*/ +void dm_kobject_uevent(struct mapped_device *md) +{ + kobject_uevent(&md->disk->kobj, KOBJ_CHANGE); +} + uint32_t dm_next_uevent_seq(struct mapped_device *md) { return atomic_add_return(1, &md->uevent_seq); diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 177297a88eb..b4584a39383 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -187,4 +187,6 @@ union map_info *dm_get_mapinfo(struct bio *bio); int dm_open_count(struct mapped_device *md); int dm_lock_for_deletion(struct mapped_device *md); +void dm_kobject_uevent(struct mapped_device *md); + #endif -- cgit v1.2.3 From 91212507f93778c09d4c1335207b6f4b995f5ad1 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 13 Dec 2007 14:16:04 +0000 Subject: dm: merge max_hw_sector Make sure dm honours max_hw_sectors of underlying devices We still have no firm testing evidence in support of this patch but believe it may help to resolve some bug reports. - agk Signed-off-by: Neil Brown Signed-off-by: Alasdair G Kergon --- drivers/md/dm-table.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index f3f952e347e..47818d8249c 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -99,6 +99,9 @@ static void combine_restrictions_low(struct io_restrictions *lhs, lhs->max_segment_size = min_not_zero(lhs->max_segment_size, rhs->max_segment_size); + lhs->max_hw_sectors = + min_not_zero(lhs->max_hw_sectors, rhs->max_hw_sectors); + lhs->seg_boundary_mask = min_not_zero(lhs->seg_boundary_mask, rhs->seg_boundary_mask); @@ -566,6 +569,9 @@ void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev) rs->max_segment_size = min_not_zero(rs->max_segment_size, q->max_segment_size); + rs->max_hw_sectors = + min_not_zero(rs->max_hw_sectors, q->max_hw_sectors); + rs->seg_boundary_mask = min_not_zero(rs->seg_boundary_mask, q->seg_boundary_mask); @@ -703,6 +709,8 @@ static void check_for_valid_limits(struct io_restrictions *rs) { if (!rs->max_sectors) rs->max_sectors = SAFE_MAX_SECTORS; + if (!rs->max_hw_sectors) + rs->max_hw_sectors = SAFE_MAX_SECTORS; if (!rs->max_phys_segments) rs->max_phys_segments = MAX_PHYS_SEGMENTS; if (!rs->max_hw_segments) @@ -901,6 +909,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q) q->max_hw_segments = t->limits.max_hw_segments; q->hardsect_size = t->limits.hardsect_size; q->max_segment_size = t->limits.max_segment_size; + q->max_hw_sectors = t->limits.max_hw_sectors; q->seg_boundary_mask = t->limits.seg_boundary_mask; q->bounce_pfn = t->limits.bounce_pfn; if (t->limits.no_cluster) -- cgit v1.2.3 From 91e106259214b40e992a58fb9417da46868e19b2 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 13 Dec 2007 14:16:10 +0000 Subject: dm crypt: use bio_add_page Fix possible max_phys_segments violation in cloned dm-crypt bio. In write operation dm-crypt needs to allocate new bio request and run crypto operation on this clone. Cloned request has always the same size, but number of physical segments can be increased and violate max_phys_segments restriction. This can lead to data corruption and serious hardware malfunction. This was observed when using XFS over dm-crypt and at least two HBA controller drivers (arcmsr, cciss) recently. Fix it by using bio_add_page() call (which tests for other restrictions too) instead of constructing own biovec. All versions of dm-crypt are affected by this bug. Cc: stable@kernel.org Cc: dm-crypt@saout.de Signed-off-by: Milan Broz Signed-off-by: Alasdair G Kergon --- drivers/md/dm-crypt.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 30d51a0c011..6b66ee46b87 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -398,7 +398,8 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size) struct bio *clone; unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; gfp_t gfp_mask = GFP_NOIO | __GFP_HIGHMEM; - unsigned int i; + unsigned i, len; + struct page *page; clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, cc->bs); if (!clone) @@ -407,10 +408,8 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size) clone_init(io, clone); for (i = 0; i < nr_iovecs; i++) { - struct bio_vec *bv = bio_iovec_idx(clone, i); - - bv->bv_page = mempool_alloc(cc->page_pool, gfp_mask); - if (!bv->bv_page) + page = mempool_alloc(cc->page_pool, gfp_mask); + if (!page) break; /* @@ -421,15 +420,14 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size) if (i == (MIN_BIO_PAGES - 1)) gfp_mask = (gfp_mask | __GFP_NOWARN) & ~__GFP_WAIT; - bv->bv_offset = 0; - if (size > PAGE_SIZE) - bv->bv_len = PAGE_SIZE; - else - bv->bv_len = size; + len = (size > PAGE_SIZE) ? PAGE_SIZE : size; + + if (!bio_add_page(clone, page, len, 0)) { + mempool_free(page, cc->page_pool); + break; + } - clone->bi_size += bv->bv_len; - clone->bi_vcnt++; - size -= bv->bv_len; + size -= len; } if (!clone->bi_size) { -- cgit v1.2.3