From e927c08da53e5c87ca07f7a828d4a0048e7bacf0 Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 30 Oct 2007 17:46:19 -0200 Subject: ACPI: thinkpad-acpi: revert keymap changes Revert commit fba956c46a72f9e7503fd464ffee43c632307e31, "Map volume and brightness events on thinkpads". That commit made some modifications to the default keymaps that cause bad behaviour on all IBM ThinkPads if HAL doesn't know to change them into passive (on-screen-display only) events. The proper solution for IBM ThinkPads is to use the _NOTIFY version of the key codes for the IBM default map (which are not available in mainline yet), and for the Lenovo keymap, it will take some studying of the various DSDTs and testing to know the best path (which I will do shortly). For more data, refer to: http://thread.gmane.org/gmane.linux.kernel/591037/focus=591045 Signed-off-by: Henrique de Moraes Holschuh Cc: Jeremy Katz Signed-off-by: Len Brown --- drivers/misc/thinkpad_acpi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index e953276664a..63b1e2610c6 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -964,15 +964,15 @@ 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) */ - KEY_VOLUMEUP, /* 0x14: VOLUME UP */ - KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ - KEY_MUTE, /* 0x16: MUTE */ + KEY_RESERVED, /* 0x14: VOLUME UP */ + KEY_RESERVED, /* 0x15: VOLUME DOWN */ + KEY_RESERVED, /* 0x16: MUTE */ KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ /* (assignments unknown, please report if found) */ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, @@ -993,9 +993,9 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ - KEY_VOLUMEUP, /* 0x14: VOLUME UP */ - KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ - KEY_MUTE, /* 0x16: MUTE */ + KEY_RESERVED, /* 0x14: VOLUME UP */ + KEY_RESERVED, /* 0x15: VOLUME DOWN */ + KEY_RESERVED, /* 0x16: MUTE */ KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ /* (assignments unknown, please report if found) */ KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, -- cgit v1.2.3 From a3f104c02ab842574e699186cf953551aafe2ca9 Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 30 Oct 2007 17:46:20 -0200 Subject: ACPI: thinkpad-acpi: support 16 levels of brightness (v3) Lenovo ThinkPads often have 16 brightness levels in EC, and not just eight levels like older ThinkPads. They also have standard ACPI backlight brightness control. We detect the number of brightness levels by the presence of a BCLL package with 16 entries. If BCLL is not there, we assume eight levels (Z6*). If it is there, but it doesn't have 16 entries, we assume eight levels (T60). Otherwise we assume sixteen levels (T61, X61, etc). We don't use _BCL because it can have side-effects in thinkpads. Thanks to Thomas Renninger for notifying me of this potential problem. Using the standard ACPI backlight brightness control *instead* of the native thinkpad backlight control is a better idea, though. A different patch will take care of this. Signed-off-by: Henrique de Moraes Holschuh Cc: Thomas Renninger Signed-off-by: Len Brown --- drivers/misc/thinkpad_acpi.c | 91 +++++++++++++++++++++++++++++++++++++++----- drivers/misc/thinkpad_acpi.h | 3 +- 2 files changed, 83 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 63b1e2610c6..322ba25b479 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -3114,6 +3114,66 @@ static struct backlight_ops ibm_backlight_data = { static struct mutex brightness_mutex; +static int __init tpacpi_query_bcll_levels(acpi_handle handle) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *obj; + int rc; + + if (ACPI_SUCCESS(acpi_evaluate_object(handle, NULL, NULL, &buffer))) { + obj = (union acpi_object *)buffer.pointer; + if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { + printk(IBM_ERR "Unknown BCLL data, " + "please report this to %s\n", IBM_MAIL); + rc = 0; + } else { + rc = obj->package.count; + } + } else { + return 0; + } + + kfree(buffer.pointer); + return rc; +} + +static acpi_status __init brightness_find_bcll(acpi_handle handle, u32 lvl, + void *context, void **rv) +{ + char name[ACPI_PATH_SEGMENT_LENGTH]; + struct acpi_buffer buffer = { sizeof(name), &name }; + + if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) && + !strncmp("BCLL", name, sizeof(name) - 1)) { + if (tpacpi_query_bcll_levels(handle) == 16) { + *rv = handle; + return AE_CTRL_TERMINATE; + } else { + return AE_OK; + } + } else { + return AE_OK; + } +} + +static int __init brightness_check_levels(void) +{ + int status; + void *found_node = NULL; + + if (!vid_handle) { + IBM_ACPIHANDLE_INIT(vid); + } + if (!vid_handle) + return 0; + + /* Search for a BCLL package with 16 levels */ + status = acpi_walk_namespace(ACPI_TYPE_PACKAGE, vid_handle, 3, + brightness_find_bcll, NULL, &found_node); + + return (ACPI_SUCCESS(status) && found_node != NULL); +} + static int __init brightness_init(struct ibm_init_struct *iibm) { int b; @@ -3135,10 +3195,17 @@ static int __init brightness_init(struct ibm_init_struct *iibm) if (brightness_mode > 3) return -EINVAL; + tp_features.bright_16levels = + thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO && + brightness_check_levels(); + b = brightness_get(NULL); if (b < 0) return 1; + if (tp_features.bright_16levels) + printk(IBM_INFO "detected a 16-level brightness capable ThinkPad\n"); + ibm_backlight_device = backlight_device_register( TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL, &ibm_backlight_data); @@ -3148,7 +3215,8 @@ static int __init brightness_init(struct ibm_init_struct *iibm) } vdbg_printk(TPACPI_DBG_INIT, "brightness is supported\n"); - ibm_backlight_device->props.max_brightness = 7; + ibm_backlight_device->props.max_brightness = + (tp_features.bright_16levels)? 15 : 7; ibm_backlight_device->props.brightness = b; backlight_update_status(ibm_backlight_device); @@ -3184,13 +3252,14 @@ static int brightness_get(struct backlight_device *bd) if (brightness_mode & 1) { if (!acpi_ec_read(brightness_offset, &lec)) return -EIO; - lec &= 7; + lec &= (tp_features.bright_16levels)? 0x0f : 0x07; level = lec; }; if (brightness_mode & 2) { lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS) & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) >> TP_NVRAM_POS_LEVEL_BRIGHTNESS; + lcmos &= (tp_features.bright_16levels)? 0x0f : 0x07; level = lcmos; } @@ -3211,7 +3280,7 @@ static int brightness_set(int value) int cmos_cmd, inc, i, res; int current_value; - if (value > 7) + if (value > ((tp_features.bright_16levels)? 15 : 7)) return -EINVAL; res = mutex_lock_interruptible(&brightness_mutex); @@ -3227,7 +3296,7 @@ static int brightness_set(int value) cmos_cmd = value > current_value ? TP_CMOS_BRIGHTNESS_UP : TP_CMOS_BRIGHTNESS_DOWN; - inc = value > current_value ? 1 : -1; + inc = (value > current_value)? 1 : -1; res = 0; for (i = current_value; i != value; i += inc) { @@ -3256,10 +3325,11 @@ static int brightness_read(char *p) if ((level = brightness_get(NULL)) < 0) { len += sprintf(p + len, "level:\t\tunreadable\n"); } else { - len += sprintf(p + len, "level:\t\t%d\n", level & 0x7); + len += sprintf(p + len, "level:\t\t%d\n", level); len += sprintf(p + len, "commands:\tup, down\n"); len += sprintf(p + len, "commands:\tlevel " - " ( is 0-7)\n"); + " ( is 0-%d)\n", + (tp_features.bright_16levels) ? 15 : 7); } return len; @@ -3270,18 +3340,19 @@ static int brightness_write(char *buf) int level; int new_level; char *cmd; + int max_level = (tp_features.bright_16levels) ? 15 : 7; while ((cmd = next_cmd(&buf))) { if ((level = brightness_get(NULL)) < 0) return level; - level &= 7; if (strlencmp(cmd, "up") == 0) { - new_level = level == 7 ? 7 : level + 1; + new_level = level == (max_level)? + max_level : level + 1; } else if (strlencmp(cmd, "down") == 0) { - new_level = level == 0 ? 0 : level - 1; + new_level = level == 0? 0 : level - 1; } else if (sscanf(cmd, "level %d", &new_level) == 1 && - new_level >= 0 && new_level <= 7) { + new_level >= 0 && new_level <= max_level) { /* new_level set */ } else return -EINVAL; diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h index 3abcc812063..8ca19c33372 100644 --- a/drivers/misc/thinkpad_acpi.h +++ b/drivers/misc/thinkpad_acpi.h @@ -84,7 +84,7 @@ /* ThinkPad CMOS NVRAM constants */ #define TP_NVRAM_ADDR_BRIGHTNESS 0x5e -#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x07 +#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x0f #define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0 #define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off") @@ -246,6 +246,7 @@ static struct { u32 hotkey_wlsw:1; u32 light:1; u32 light_status:1; + u32 bright_16levels:1; u32 wan:1; u32 fan_ctrl_status_undef:1; u32 input_device_registered:1; -- cgit v1.2.3 From 87cc537a54fc017d998cf603f5fab9ca4a85d668 Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 30 Oct 2007 18:02:07 -0200 Subject: ACPI: thinkpad-acpi: add brightness_force parameter Add a "brightness_enable" module parameter that allows the local admin to force the backlight support to not be enabled. It can also be used to force the backlight support to be enabled, but that is currently a no-op as the backlight support is enabled by default when available. This will be changed by a different patch. Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- drivers/misc/thinkpad_acpi.c | 9 +++++++++ drivers/misc/thinkpad_acpi.h | 1 + 2 files changed, 10 insertions(+) (limited to 'drivers') diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 322ba25b479..56a21e6b80a 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -3182,6 +3182,12 @@ static int __init brightness_init(struct ibm_init_struct *iibm) mutex_init(&brightness_mutex); + if (!brightness_enable) { + dbg_printk(TPACPI_DBG_INIT, + "brightness support disabled by module parameter\n"); + return 1; + } + if (!brightness_mode) { if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO) brightness_mode = 2; @@ -4803,6 +4809,9 @@ module_param_named(fan_control, fan_control_allowed, bool, 0); static int brightness_mode; module_param_named(brightness_mode, brightness_mode, int, 0); +static unsigned int brightness_enable = 2; /* 2 = auto, 0 = no, 1 = yes */ +module_param(brightness_enable, uint, 0); + static unsigned int hotkey_report_mode; module_param(hotkey_report_mode, uint, 0); diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h index 8ca19c33372..8fba2bbe345 100644 --- a/drivers/misc/thinkpad_acpi.h +++ b/drivers/misc/thinkpad_acpi.h @@ -339,6 +339,7 @@ static int bluetooth_write(char *buf); static struct backlight_device *ibm_backlight_device; static int brightness_offset = 0x31; static int brightness_mode; +static unsigned int brightness_enable; /* 0 = no, 1 = yes, 2 = auto */ static int brightness_init(struct ibm_init_struct *iibm); static void brightness_exit(void); -- cgit v1.2.3 From e11e211a0b21bbb625fac2056bdb54dd02020556 Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 30 Oct 2007 17:46:22 -0200 Subject: ACPI: thinkpad-acpi: prefer standard ACPI backlight level control Newer Lenovo BIOSes support the standard ACPI backlight brightness interface (_BCM, _BQC, _BCL). It should be used instead of the native thinkpad backlight brightness control interface when possible. This patch disables the native brightness support in the driver by default when we detect that the standard ACPI interface is available. The local admin can still enable it using the module parameter "brightness_enable". Note that we need to detect the standard ACPI backlight interface only in boxes for which we would load the native backlight interface in the first place, and that no ThinkPad BIOS has _BCL but misses the other methods, so the detection routines can be really simple. Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- drivers/misc/thinkpad_acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'drivers') diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 56a21e6b80a..109bd275043 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -3174,6 +3174,39 @@ static int __init brightness_check_levels(void) return (ACPI_SUCCESS(status) && found_node != NULL); } +static acpi_status __init brightness_find_bcl(acpi_handle handle, u32 lvl, + void *context, void **rv) +{ + char name[ACPI_PATH_SEGMENT_LENGTH]; + struct acpi_buffer buffer = { sizeof(name), &name }; + + if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) && + !strncmp("_BCL", name, sizeof(name) - 1)) { + *rv = handle; + return AE_CTRL_TERMINATE; + } else { + return AE_OK; + } +} + +static int __init brightness_check_std_acpi_support(void) +{ + int status; + void *found_node = NULL; + + if (!vid_handle) { + IBM_ACPIHANDLE_INIT(vid); + } + if (!vid_handle) + return 0; + + /* Search for a _BCL method, but don't execute it */ + status = acpi_walk_namespace(ACPI_TYPE_METHOD, vid_handle, 3, + brightness_find_bcl, NULL, &found_node); + + return (ACPI_SUCCESS(status) && found_node != NULL); +} + static int __init brightness_init(struct ibm_init_struct *iibm) { int b; @@ -3186,6 +3219,12 @@ static int __init brightness_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT, "brightness support disabled by module parameter\n"); return 1; + } else if (brightness_enable > 1) { + if (brightness_check_std_acpi_support()) { + printk(IBM_NOTICE + "standard ACPI backlight interface available, not loading native one...\n"); + return 1; + } } if (!brightness_mode) { -- cgit v1.2.3 From b856f5b8c022b75bb0504a8c1ce16a5f1656e08b Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 30 Oct 2007 17:46:23 -0200 Subject: ACPI: thinkpad-acpi: bump up version to 0.17 The lm-sensors 3.0.0/libsensors4 compatibility changes are reason enough to bump up the version string. Do it. Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- drivers/misc/thinkpad_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 109bd275043..251110d0ec8 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -21,7 +21,7 @@ * 02110-1301, USA. */ -#define IBM_VERSION "0.16" +#define IBM_VERSION "0.17" #define TPACPI_SYSFS_VERSION 0x020000 /* -- cgit v1.2.3 From fc589a3ce5f38db6239c147da4f9172a25575ecc Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 30 Oct 2007 17:46:24 -0200 Subject: ACPI: thinkpad-acpi: allow for syscall restart in sysfs handlers Map an mutex_lock_interruptible() error return into ERESTARTSYS, as the only possible error from mutex_lock_interruptible is EINTR, and that will only happen if signal_pending() causes the mutex lock attempt to abort. This still allows signals to be delivered ASAP, which is much nicer than just doing mutex_lock, and still shadows userspace from EINTR when SA_RESTART is active. Problem reported by Peter Jordan. Signed-off-by: Henrique de Moraes Holschuh Cc: Jean Delvare Cc: Peter Jordan Cc: Richard Neill Signed-off-by: Len Brown --- drivers/misc/thinkpad_acpi.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 251110d0ec8..306daa524c0 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -1342,9 +1342,8 @@ static int hotkey_read(char *p) return len; } - res = mutex_lock_interruptible(&hotkey_mutex); - if (res < 0) - return res; + if (mutex_lock_interruptible(&hotkey_mutex)) + return -ERESTARTSYS; res = hotkey_get(&status, &mask); mutex_unlock(&hotkey_mutex); if (res) @@ -1373,9 +1372,8 @@ static int hotkey_write(char *buf) if (!tp_features.hotkey) return -ENODEV; - res = mutex_lock_interruptible(&hotkey_mutex); - if (res < 0) - return res; + if (mutex_lock_interruptible(&hotkey_mutex)) + return -ERESTARTSYS; res = hotkey_get(&status, &mask); if (res) @@ -3768,9 +3766,8 @@ static ssize_t fan_pwm1_store(struct device *dev, /* scale down from 0-255 to 0-7 */ newlevel = (s >> 5) & 0x07; - rc = mutex_lock_interruptible(&fan_mutex); - if (rc < 0) - return rc; + if (mutex_lock_interruptible(&fan_mutex)) + return -ERESTARTSYS; rc = fan_get_status(&status); if (!rc && (status & @@ -4020,9 +4017,8 @@ static int fan_get_status_safe(u8 *status) int rc; u8 s; - rc = mutex_lock_interruptible(&fan_mutex); - if (rc < 0) - return rc; + if (mutex_lock_interruptible(&fan_mutex)) + return -ERESTARTSYS; rc = fan_get_status(&s); if (!rc) fan_update_desired_level(s); @@ -4156,9 +4152,8 @@ static int fan_set_level_safe(int level) if (!fan_control_allowed) return -EPERM; - rc = mutex_lock_interruptible(&fan_mutex); - if (rc < 0) - return rc; + if (mutex_lock_interruptible(&fan_mutex)) + return -ERESTARTSYS; if (level == TPACPI_FAN_LAST_LEVEL) level = fan_control_desired_level; @@ -4179,9 +4174,8 @@ static int fan_set_enable(void) if (!fan_control_allowed) return -EPERM; - rc = mutex_lock_interruptible(&fan_mutex); - if (rc < 0) - return rc; + if (mutex_lock_interruptible(&fan_mutex)) + return -ERESTARTSYS; switch (fan_control_access_mode) { case TPACPI_FAN_WR_ACPI_FANS: @@ -4235,9 +4229,8 @@ static int fan_set_disable(void) if (!fan_control_allowed) return -EPERM; - rc = mutex_lock_interruptible(&fan_mutex); - if (rc < 0) - return rc; + if (mutex_lock_interruptible(&fan_mutex)) + return -ERESTARTSYS; rc = 0; switch (fan_control_access_mode) { @@ -4274,9 +4267,8 @@ static int fan_set_speed(int speed) if (!fan_control_allowed) return -EPERM; - rc = mutex_lock_interruptible(&fan_mutex); - if (rc < 0) - return rc; + if (mutex_lock_interruptible(&fan_mutex)) + return -ERESTARTSYS; rc = 0; switch (fan_control_access_mode) { -- cgit v1.2.3 From 4273af8d08c823d5898a2b1c2d0f25b4a8b9eaee Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Tue, 30 Oct 2007 17:46:25 -0200 Subject: ACPI: thinkpad-acpi: fix brightness_set error paths The code calling brightness_set() can't handle EINTR/ERESTARTSYS well, nor is it checking brightness_set() return status properly. Fix it. Signed-off-by: Henrique de Moraes Holschuh Signed-off-by: Len Brown --- drivers/misc/thinkpad_acpi.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 306daa524c0..8c943077528 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -3278,6 +3278,8 @@ static void brightness_exit(void) static int brightness_update_status(struct backlight_device *bd) { + /* it is the backlight class's job (caller) to handle + * EINTR and other errors properly */ return brightness_set( (bd->props.fb_blank == FB_BLANK_UNBLANK && bd->props.power == FB_BLANK_UNBLANK) ? @@ -3318,6 +3320,7 @@ static int brightness_get(struct backlight_device *bd) return level; } +/* May return EINTR which can always be mapped to ERESTARTSYS */ static int brightness_set(int value) { int cmos_cmd, inc, i, res; @@ -3381,29 +3384,34 @@ static int brightness_read(char *p) static int brightness_write(char *buf) { int level; - int new_level; + int rc; char *cmd; int max_level = (tp_features.bright_16levels) ? 15 : 7; - while ((cmd = next_cmd(&buf))) { - if ((level = brightness_get(NULL)) < 0) - return level; + level = brightness_get(NULL); + if (level < 0) + return level; + while ((cmd = next_cmd(&buf))) { if (strlencmp(cmd, "up") == 0) { - new_level = level == (max_level)? - max_level : level + 1; + if (level < max_level) + level++; } else if (strlencmp(cmd, "down") == 0) { - new_level = level == 0? 0 : level - 1; - } else if (sscanf(cmd, "level %d", &new_level) == 1 && - new_level >= 0 && new_level <= max_level) { - /* new_level set */ + if (level > 0) + level--; + } else if (sscanf(cmd, "level %d", &level) == 1 && + level >= 0 && level <= max_level) { + /* new level set */ } else return -EINVAL; - - brightness_set(new_level); } - return 0; + /* + * Now we know what the final level should be, so we try to set it. + * Doing it this way makes the syscall restartable in case of EINTR + */ + rc = brightness_set(level); + return (rc == -EINTR)? ERESTARTSYS : rc; } static struct ibm_struct brightness_driver_data = { -- cgit v1.2.3 From 4c41d3ad6544f1c9aec37c441af04f5d0ad3a731 Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 7 Nov 2007 15:09:09 -0800 Subject: ACPI: Always return valid 'status' from acpi_battery_get_property() If a battery is at a critical charge level and not being charged or discharged, then the ACPI _BST method will return a state of 4, and the current acpi_battery_get_property() code will not set any property value for POWER_SUPPLY_PROP_STATUS. This will cause an oops in power_supply_show_property() when it reads off the end of the status_text array. This actually was causing a 100% reproducible crash on boot on my laptop with two batteries, when one battery was completely drained and the laptop was not plugged in. Fix this by making sure acpi_battery_get_property() returns POWER_SUPPLY_STATUS_UNKNOWN for any battery state it doesn't already handle explicitly. There doesn't seem to be any status enum value defined that makes more sense than 'unknown' for a battery at a critical charge level. Signed-off-by: Roland Dreier Acked-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/battery.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index c2ce0ad2169..cbb27b4ddea 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -152,6 +152,8 @@ static int acpi_battery_get_property(struct power_supply *psy, val->intval = POWER_SUPPLY_STATUS_CHARGING; else if (battery->state == 0) val->intval = POWER_SUPPLY_STATUS_FULL; + else + val->intval = POWER_SUPPLY_STATUS_UNKNOWN; break; case POWER_SUPPLY_PROP_PRESENT: val->intval = acpi_battery_present(battery); -- cgit v1.2.3 From 91c05c667b2d8e43e0bbc5f269bf45d4821001d6 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 5 Nov 2007 11:43:29 -0500 Subject: ACPI: video - fit input device into sysfs tree Properly set up parent on input device registered by the video driver. Signed-off-by: Dmitry Torokhov Acked-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index bac956b30c5..c0e4e7423fc 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1961,6 +1961,7 @@ static int acpi_video_bus_add(struct acpi_device *device) input->phys = video->phys; input->id.bustype = BUS_HOST; input->id.product = 0x06; + input->dev.parent = &device->dev; input->evbit[0] = BIT(EV_KEY); set_bit(KEY_SWITCHVIDEOMODE, input->keybit); set_bit(KEY_VIDEO_NEXT, input->keybit); @@ -1990,7 +1991,7 @@ static int acpi_video_bus_add(struct acpi_device *device) video->flags.rom ? "yes" : "no", video->flags.post ? "yes" : "no"); - end: + end: if (result) kfree(video); -- cgit v1.2.3 From f51e83916a0a022d3d0ea39ae2f877c703032923 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 5 Nov 2007 11:43:30 -0500 Subject: ACPI: video - add missing input_free_device() If input_register_device() fails input_free_device() must be called to release memory allocated for the device. Also consolidate error handling in acpi_bus_video_add() and handle input_allocate_device() failures. Signed-off-by: Dmitry Torokhov Acked-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 69 ++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index c0e4e7423fc..be66a7c04d3 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1897,14 +1897,10 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) static int instance; static int acpi_video_bus_add(struct acpi_device *device) { - int result = 0; - acpi_status status = 0; - struct acpi_video_bus *video = NULL; + acpi_status status; + struct acpi_video_bus *video; struct input_dev *input; - - - if (!device) - return -EINVAL; + int error; video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); if (!video) @@ -1923,13 +1919,13 @@ static int acpi_video_bus_add(struct acpi_device *device) acpi_driver_data(device) = video; acpi_video_bus_find_cap(video); - result = acpi_video_bus_check(video); - if (result) - goto end; + error = acpi_video_bus_check(video); + if (error) + goto err_free_video; - result = acpi_video_bus_add_fs(device); - if (result) - goto end; + error = acpi_video_bus_add_fs(device); + if (error) + goto err_free_video; init_MUTEX(&video->sem); INIT_LIST_HEAD(&video->video_device_list); @@ -1943,16 +1939,15 @@ static int acpi_video_bus_add(struct acpi_device *device) if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error installing notify handler\n")); - acpi_video_bus_stop_devices(video); - acpi_video_bus_put_devices(video); - kfree(video->attached_array); - acpi_video_bus_remove_fs(device); - result = -ENODEV; - goto end; + error = -ENODEV; + goto err_stop_video; } - video->input = input = input_allocate_device(); + if (!input) { + error = -ENOMEM; + goto err_uninstall_notify; + } snprintf(video->phys, sizeof(video->phys), "%s/video/input0", acpi_device_hid(video->device)); @@ -1972,18 +1967,10 @@ static int acpi_video_bus_add(struct acpi_device *device) set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); set_bit(KEY_DISPLAY_OFF, input->keybit); set_bit(KEY_UNKNOWN, input->keybit); - result = input_register_device(input); - if (result) { - acpi_remove_notify_handler(video->device->handle, - ACPI_DEVICE_NOTIFY, - acpi_video_bus_notify); - acpi_video_bus_stop_devices(video); - acpi_video_bus_put_devices(video); - kfree(video->attached_array); - acpi_video_bus_remove_fs(device); - goto end; - } + error = input_register_device(input); + if (error) + goto err_free_input_dev; printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), @@ -1991,11 +1978,23 @@ static int acpi_video_bus_add(struct acpi_device *device) video->flags.rom ? "yes" : "no", video->flags.post ? "yes" : "no"); - end: - if (result) - kfree(video); + return 0; + + err_free_input_dev: + input_free_device(input); + err_uninstall_notify: + acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + acpi_video_bus_notify); + err_stop_video: + acpi_video_bus_stop_devices(video); + acpi_video_bus_put_devices(video); + kfree(video->attached_array); + acpi_video_bus_remove_fs(device); + err_free_video: + kfree(video); + acpi_driver_data(device) = NULL; - return result; + return error; } static int acpi_video_bus_remove(struct acpi_device *device, int type) -- cgit v1.2.3 From ff102ea99099c36250e93a87a9794b5233801020 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 5 Nov 2007 11:43:31 -0500 Subject: ACPI: video - remove unsafe uses of list_for_each_safe() list_for_each_safe() only protects list from list alterations performed by the same thread. One still needs to implement proper locking when list is being accessed from several threads. Signed-off-by: Dmitry Torokhov Acked-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 71 +++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 37 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index be66a7c04d3..36b64a75167 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1462,12 +1462,14 @@ acpi_video_bus_get_one_device(struct acpi_device *device, static void acpi_video_device_rebind(struct acpi_video_bus *video) { - struct list_head *node, *next; - list_for_each_safe(node, next, &video->video_device_list) { - struct acpi_video_device *dev = - container_of(node, struct acpi_video_device, entry); + struct acpi_video_device *dev; + + down(&video->sem); + + list_for_each_entry(dev, &video->video_device_list, entry) acpi_video_device_bind(video, dev); - } + + up(&video->sem); } /* @@ -1592,30 +1594,33 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) static int acpi_video_switch_output(struct acpi_video_bus *video, int event) { - struct list_head *node, *next; + struct list_head *node; struct acpi_video_device *dev = NULL; struct acpi_video_device *dev_next = NULL; struct acpi_video_device *dev_prev = NULL; unsigned long state; int status = 0; + down(&video->sem); - list_for_each_safe(node, next, &video->video_device_list) { + list_for_each(node, &video->video_device_list) { dev = container_of(node, struct acpi_video_device, entry); status = acpi_video_device_get_state(dev, &state); if (state & 0x2) { - dev_next = - container_of(node->next, struct acpi_video_device, - entry); - dev_prev = - container_of(node->prev, struct acpi_video_device, - entry); + dev_next = container_of(node->next, + struct acpi_video_device, entry); + dev_prev = container_of(node->prev, + struct acpi_video_device, entry); goto out; } } + dev_next = container_of(node->next, struct acpi_video_device, entry); dev_prev = container_of(node->prev, struct acpi_video_device, entry); - out: + + out: + up(&video->sem); + switch (event) { case ACPI_VIDEO_NOTIFY_CYCLE: case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: @@ -1691,24 +1696,17 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video, struct acpi_device *device) { int status = 0; - struct list_head *node, *next; - + struct acpi_device *dev; acpi_video_device_enumerate(video); - list_for_each_safe(node, next, &device->children) { - struct acpi_device *dev = - list_entry(node, struct acpi_device, node); - - if (!dev) - continue; + list_for_each_entry(dev, &device->children, node) { status = acpi_video_bus_get_one_device(dev, video); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Cant attach device")); continue; } - } return status; } @@ -1724,9 +1722,6 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) video = device->video; - down(&video->sem); - list_del(&device->entry); - up(&video->sem); acpi_video_device_remove_fs(device->dev); status = acpi_remove_notify_handler(device->dev->handle, @@ -1734,32 +1729,34 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) acpi_video_device_notify); backlight_device_unregister(device->backlight); video_output_unregister(device->output_dev); + return 0; } static int acpi_video_bus_put_devices(struct acpi_video_bus *video) { int status; - struct list_head *node, *next; + struct acpi_video_device *dev, *next; + down(&video->sem); - list_for_each_safe(node, next, &video->video_device_list) { - struct acpi_video_device *data = - list_entry(node, struct acpi_video_device, entry); - if (!data) - continue; + list_for_each_entry_safe(dev, next, &video->video_device_list, entry) { - status = acpi_video_bus_put_one_device(data); + status = acpi_video_bus_put_one_device(dev); if (ACPI_FAILURE(status)) printk(KERN_WARNING PREFIX "hhuuhhuu bug in acpi video driver.\n"); - if (data->brightness) - kfree(data->brightness->levels); - kfree(data->brightness); - kfree(data); + if (dev->brightness) { + kfree(dev->brightness->levels); + kfree(dev->brightness); + } + list_del(&dev->entry); + kfree(dev); } + up(&video->sem); + return 0; } -- cgit v1.2.3 From bbac81f5487175e4bd5602a80c17689d8f82a63e Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 5 Nov 2007 11:43:32 -0500 Subject: ACPI: video - convert semaphore to a mutex Signed-off-by: Dmitry Torokhov Acked-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 36b64a75167..d54c83d7053 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -135,8 +136,8 @@ struct acpi_video_bus { u8 attached_count; struct acpi_video_bus_cap cap; struct acpi_video_bus_flags flags; - struct semaphore sem; struct list_head video_device_list; + struct mutex device_list_lock; /* protects video_device_list */ struct proc_dir_entry *dir; struct input_dev *input; char phys[32]; /* for input device */ @@ -1436,9 +1437,9 @@ acpi_video_bus_get_one_device(struct acpi_device *device, return -ENODEV; } - down(&video->sem); + mutex_lock(&video->device_list_lock); list_add_tail(&data->entry, &video->video_device_list); - up(&video->sem); + mutex_unlock(&video->device_list_lock); acpi_video_device_add_fs(device); @@ -1464,12 +1465,12 @@ static void acpi_video_device_rebind(struct acpi_video_bus *video) { struct acpi_video_device *dev; - down(&video->sem); + mutex_lock(&video->device_list_lock); list_for_each_entry(dev, &video->video_device_list, entry) acpi_video_device_bind(video, dev); - up(&video->sem); + mutex_unlock(&video->device_list_lock); } /* @@ -1601,7 +1602,7 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event) unsigned long state; int status = 0; - down(&video->sem); + mutex_lock(&video->device_list_lock); list_for_each(node, &video->video_device_list) { dev = container_of(node, struct acpi_video_device, entry); @@ -1619,7 +1620,7 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event) dev_prev = container_of(node->prev, struct acpi_video_device, entry); out: - up(&video->sem); + mutex_unlock(&video->device_list_lock); switch (event) { case ACPI_VIDEO_NOTIFY_CYCLE: @@ -1738,7 +1739,7 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video) int status; struct acpi_video_device *dev, *next; - down(&video->sem); + mutex_lock(&video->device_list_lock); list_for_each_entry_safe(dev, next, &video->video_device_list, entry) { @@ -1755,7 +1756,7 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video) kfree(dev); } - up(&video->sem); + mutex_unlock(&video->device_list_lock); return 0; } @@ -1924,7 +1925,7 @@ static int acpi_video_bus_add(struct acpi_device *device) if (error) goto err_free_video; - init_MUTEX(&video->sem); + mutex_init(&video->device_list_lock); INIT_LIST_HEAD(&video->video_device_list); acpi_video_bus_get_devices(video, device); -- cgit v1.2.3 From a4f0c2767e9c55123d7dad7176554e9d6e6056bc Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 14 Nov 2007 12:49:13 -0500 Subject: ACPI: video - delete stray run-time printk printk("video bus notify\n"); Acked-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index d54c83d7053..dce0a6e47f5 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1780,9 +1780,6 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) struct input_dev *input; int keycode; - - printk("video bus notify\n"); - if (!video) return; -- cgit v1.2.3 From 529a73fbaeee2f3bd932be8b54665994133be6ae Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 23 Nov 2007 14:28:44 +0800 Subject: Blackfin arch: punt CONFIG_BFIN -- we already have CONFIG_BLACKFIN Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu --- drivers/input/serio/Kconfig | 2 +- drivers/rtc/Kconfig | 2 +- drivers/serial/Kconfig | 2 +- drivers/spi/Kconfig | 2 +- drivers/video/console/Kconfig | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig index 5ce632ca681..b88569e21d6 100644 --- a/drivers/input/serio/Kconfig +++ b/drivers/input/serio/Kconfig @@ -21,7 +21,7 @@ if SERIO config SERIO_I8042 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86 default y - depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && !M68K && !BFIN + depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && !M68K && !BLACKFIN ---help--- i8042 is the chip over which the standard AT keyboard and PS/2 mouse are connected to the computer. If you use these devices, diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index e5cdc0294aa..1e6715ec51e 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -447,7 +447,7 @@ config RTC_DRV_AT91RM9200 config RTC_DRV_BFIN tristate "Blackfin On-Chip RTC" - depends on BFIN + depends on BLACKFIN help If you say yes here you will get support for the Blackfin On-Chip Real Time Clock. diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index ed438bc7e98..d7e1996e2fe 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -600,7 +600,7 @@ config SERIAL_SA1100_CONSOLE config SERIAL_BFIN tristate "Blackfin serial port support" - depends on BFIN + depends on BLACKFIN select SERIAL_CORE select SERIAL_BFIN_UART0 if (BF531 || BF532 || BF533 || BF561) help diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index a77ede598d3..abf05048c63 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -61,7 +61,7 @@ config SPI_ATMEL config SPI_BFIN tristate "SPI controller driver for ADI Blackfin5xx" - depends on SPI_MASTER && BFIN + depends on SPI_MASTER && BLACKFIN help This is the SPI controller master driver for Blackfin 5xx processor. diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index 267422f6625..b87ed37ac0c 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig @@ -6,7 +6,7 @@ menu "Console display driver support" config VGA_CONSOLE bool "VGA text console" if EMBEDDED || !X86 - depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !ARCH_VERSATILE && !SUPERH && !BFIN + depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !ARCH_VERSATILE && !SUPERH && !BLACKFIN default y help Saying Y here will allow you to use Linux in text mode through a -- cgit v1.2.3 From 9862cc5278aabd82230369a142c817e37a42caa3 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 15 Nov 2007 21:21:20 +0800 Subject: Blackfin arch: change get_bf537_ether_addr() to bfin_get_ether_addr() since this is not BF537 specific and to better match other Blackfin-specific conventions Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu --- drivers/net/bfin_mac.c | 2 +- drivers/net/bfin_mac.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c index 084acfd6fc5..0b99b554929 100644 --- a/drivers/net/bfin_mac.c +++ b/drivers/net/bfin_mac.c @@ -924,7 +924,7 @@ static int __init bf537mac_probe(struct net_device *dev) if (!is_valid_ether_addr(dev->dev_addr)) { /* Grab the MAC from the board somehow - this is done in the arch/blackfin/mach-bf537/boards/eth_mac.c */ - get_bf537_ether_addr(dev->dev_addr); + bfin_get_ether_addr(dev->dev_addr); } /* If still not valid, get a random one */ diff --git a/drivers/net/bfin_mac.h b/drivers/net/bfin_mac.h index 3a107ad7538..5970ea7142c 100644 --- a/drivers/net/bfin_mac.h +++ b/drivers/net/bfin_mac.h @@ -92,4 +92,4 @@ struct bf537mac_local { struct mii_bus mii_bus; }; -extern void get_bf537_ether_addr(char *addr); +extern void bfin_get_ether_addr(char *addr); -- cgit v1.2.3 From ef54d5ad2f58f899be6419fd1090cdeb2439851a Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Thu, 15 Nov 2007 16:59:30 +0800 Subject: ACPI: Enforce T-state limit changes immediately When a T-state limit change notification is received, Linux must evaluate _TPC and change its current T-state immediately to comply with the new limit. Previously, Linux would notice the new limit only upon the next throttling change. Signed-off-by: Zhao Yakui Signed-off-by: Li Shaohua Signed-off-by: Len Brown --- drivers/acpi/processor_throttling.c | 50 ++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 0b8204e7082..5fa8ac1c0c8 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -70,7 +70,55 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr) int acpi_processor_tstate_has_changed(struct acpi_processor *pr) { - return acpi_processor_get_platform_limit(pr); + int result = 0; + int throttling_limit; + int current_state; + struct acpi_processor_limit *limit; + int target_state; + + result = acpi_processor_get_platform_limit(pr); + if (result) { + /* Throttling Limit is unsupported */ + return result; + } + + throttling_limit = pr->throttling_platform_limit; + if (throttling_limit >= pr->throttling.state_count) { + /* Uncorrect Throttling Limit */ + return -EINVAL; + } + + current_state = pr->throttling.state; + if (current_state > throttling_limit) { + /* + * The current state can meet the requirement of + * _TPC limit. But it is reasonable that OSPM changes + * t-states from high to low for better performance. + * Of course the limit condition of thermal + * and user should be considered. + */ + limit = &pr->limit; + target_state = throttling_limit; + if (limit->thermal.tx > target_state) + target_state = limit->thermal.tx; + if (limit->user.tx > target_state) + target_state = limit->user.tx; + } else if (current_state == throttling_limit) { + /* + * Unnecessary to change the throttling state + */ + return 0; + } else { + /* + * If the current state is lower than the limit of _TPC, it + * will be forced to switch to the throttling state defined + * by throttling_platfor_limit. + * Because the previous state meets with the limit condition + * of thermal and user, it is unnecessary to check it again. + */ + target_state = throttling_limit; + } + return acpi_processor_set_throttling(pr, target_state); } /* -- cgit v1.2.3 From 49fbabf56dc715bbb51e59742e82ba762790aac0 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Thu, 15 Nov 2007 17:01:06 +0800 Subject: ACPI: Handle I/O access width requestst that are not a multiple of 8 bits. We've run into BIOS that hand us 4-bit access width requests for T-state control when the code expected only multipls of 8-bits. Round up. Signed-off-by: Zhao Yakui Signed-off-by: Li Shaohua Signed-off-by: Len Brown --- drivers/acpi/osl.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index aabc6ca4a81..e3a673a0084 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -387,17 +387,14 @@ acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) if (!value) value = &dummy; - switch (width) { - case 8: + *value = 0; + if (width <= 8) { *(u8 *) value = inb(port); - break; - case 16: + } else if (width <= 16) { *(u16 *) value = inw(port); - break; - case 32: + } else if (width <= 32) { *(u32 *) value = inl(port); - break; - default: + } else { BUG(); } @@ -408,17 +405,13 @@ EXPORT_SYMBOL(acpi_os_read_port); acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) { - switch (width) { - case 8: + if (width <= 8) { outb(value, port); - break; - case 16: + } else if (width <= 16) { outw(value, port); - break; - case 32: + } else if (width <= 32) { outl(value, port); - break; - default: + } else { BUG(); } -- cgit v1.2.3 From 22cc50199d0616f7b002563a0e9117ba479356e1 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Thu, 15 Nov 2007 17:02:03 +0800 Subject: ACPI: If _TSS exists, do not access FADT.duty_width Factor out legacy FADT.duty_width code and run it only in the non _TSS case. Signed-off-by: Zhao Yakui Signed-off-by: Li Shaohua Signed-off-by: Len Brown --- drivers/acpi/processor_throttling.c | 66 ++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 30 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 5fa8ac1c0c8..20d82f55ce5 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -478,6 +478,40 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr) return pr->throttling.acpi_processor_get_throttling(pr); } +static int acpi_processor_get_fadt_info(struct acpi_processor *pr) +{ + int i, step; + + if (!pr->throttling.address) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); + return -EINVAL; + } else if (!pr->throttling.duty_width) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); + return -EINVAL; + } + /* TBD: Support duty_cycle values that span bit 4. */ + else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { + printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n"); + return -EINVAL; + } + + pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width; + + /* + * Compute state values. Note that throttling displays a linear power + * performance relationship (at 50% performance the CPU will consume + * 50% power). Values are in 1/10th of a percent to preserve accuracy. + */ + + step = (1000 / pr->throttling.state_count); + + for (i = 0; i < pr->throttling.state_count; i++) { + pr->throttling.states[i].performance = 1000 - step * i; + pr->throttling.states[i].power = 1000 - step * i; + } + return 0; +} + static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, int state) { @@ -591,8 +625,6 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) int acpi_processor_get_throttling_info(struct acpi_processor *pr) { int result = 0; - int step = 0; - int i = 0; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", @@ -611,6 +643,8 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) acpi_processor_get_throttling_states(pr) || acpi_processor_get_platform_limit(pr)) { + if (acpi_processor_get_fadt_info(pr)) + return 0; pr->throttling.acpi_processor_get_throttling = &acpi_processor_get_throttling_fadt; pr->throttling.acpi_processor_set_throttling = @@ -624,19 +658,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) acpi_processor_get_tsd(pr); - if (!pr->throttling.address) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); - return 0; - } else if (!pr->throttling.duty_width) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); - return 0; - } - /* TBD: Support duty_cycle values that span bit 4. */ - else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { - printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n"); - return 0; - } - /* * PIIX4 Errata: We don't support throttling on the original PIIX4. * This shouldn't be an issue as few (if any) mobile systems ever @@ -648,21 +669,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) return 0; } - pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width; - - /* - * Compute state values. Note that throttling displays a linear power/ - * performance relationship (at 50% performance the CPU will consume - * 50% power). Values are in 1/10th of a percent to preserve accuracy. - */ - - step = (1000 / pr->throttling.state_count); - - for (i = 0; i < pr->throttling.state_count; i++) { - pr->throttling.states[i].performance = step * i; - pr->throttling.states[i].power = step * i; - } - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", pr->throttling.state_count)); -- cgit v1.2.3 From 0753f6e0a3d9568fb6b8e34753b944d9f8eed05b Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Thu, 15 Nov 2007 17:03:46 +0800 Subject: ACPI: throttle: Change internal APIs better handle _PTC Change the function interface for throttling control via PTC. The following functions are concerned: acpi_read_throttling_status() acpi_write_throttling_state() acpi_get_throttling_value() acpi_get_throttling_state() Signed-off-by: Zhao Yakui Signed-off-by: Li Shaohua Signed-off-by: Len Brown --- drivers/acpi/processor_throttling.c | 60 ++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 20d82f55ce5..5c96ef18e94 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -376,16 +376,23 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr) return 0; } -static int acpi_read_throttling_status(struct acpi_processor_throttling - *throttling) +static int acpi_read_throttling_status(struct acpi_processor *pr, + acpi_integer *value) { - int value = -1; + u64 ptc_value; + struct acpi_processor_throttling *throttling; + int ret = -1; + + throttling = &pr->throttling; switch (throttling->status_register.space_id) { case ACPI_ADR_SPACE_SYSTEM_IO: + ptc_value = 0; acpi_os_read_port((acpi_io_address) throttling->status_register. - address, &value, + address, (u32 *) &ptc_value, (u32) throttling->status_register.bit_width * 8); + *value = (acpi_integer) ptc_value; + ret = 0; break; case ACPI_ADR_SPACE_FIXED_HARDWARE: printk(KERN_ERR PREFIX @@ -395,18 +402,22 @@ static int acpi_read_throttling_status(struct acpi_processor_throttling printk(KERN_ERR PREFIX "Unknown addr space %d\n", (u32) (throttling->status_register.space_id)); } - return value; + return ret; } -static int acpi_write_throttling_state(struct acpi_processor_throttling - *throttling, int value) +static int acpi_write_throttling_state(struct acpi_processor *pr, + acpi_integer value) { + u64 ptc_value; + struct acpi_processor_throttling *throttling; int ret = -1; + throttling = &pr->throttling; switch (throttling->control_register.space_id) { case ACPI_ADR_SPACE_SYSTEM_IO: + ptc_value = value; acpi_os_write_port((acpi_io_address) throttling-> - control_register.address, value, + control_register.address, (u32) ptc_value, (u32) throttling->control_register. bit_width * 8); ret = 0; @@ -422,7 +433,8 @@ static int acpi_write_throttling_state(struct acpi_processor_throttling return ret; } -static int acpi_get_throttling_state(struct acpi_processor *pr, int value) +static int acpi_get_throttling_state(struct acpi_processor *pr, + acpi_integer value) { int i; @@ -438,22 +450,26 @@ static int acpi_get_throttling_state(struct acpi_processor *pr, int value) return i; } -static int acpi_get_throttling_value(struct acpi_processor *pr, int state) +static int acpi_get_throttling_value(struct acpi_processor *pr, + int state, acpi_integer *value) { - int value = -1; + int ret = -1; + if (state >= 0 && state <= pr->throttling.state_count) { struct acpi_processor_tx_tss *tx = (struct acpi_processor_tx_tss *)&(pr->throttling. states_tss[state]); - value = tx->control; + *value = tx->control; + ret = 0; } - return value; + return ret; } static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) { int state = 0; - u32 value = 0; + int ret; + acpi_integer value; if (!pr) return -EINVAL; @@ -463,8 +479,9 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) pr->throttling.state = 0; local_irq_disable(); - value = acpi_read_throttling_status(&pr->throttling); - if (value >= 0) { + value = 0; + ret = acpi_read_throttling_status(pr, &value); + if (ret >= 0) { state = acpi_get_throttling_state(pr, value); pr->throttling.state = state; } @@ -588,7 +605,8 @@ static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, int state) { - u32 value = 0; + int ret; + acpi_integer value; if (!pr) return -EINVAL; @@ -606,10 +624,10 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, return -EPERM; local_irq_disable(); - - value = acpi_get_throttling_value(pr, state); - if (value >= 0) { - acpi_write_throttling_state(&pr->throttling, value); + value = 0; + ret = acpi_get_throttling_value(pr, state, &value); + if (ret >= 0) { + acpi_write_throttling_state(pr, value); pr->throttling.state = state; } local_irq_enable(); -- cgit v1.2.3 From 9bcb27217344c2c1389db3983a436e19484c2f50 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Thu, 15 Nov 2007 17:05:05 +0800 Subject: ACPI: Use _TSS for throttling control, when present. Add error checks. _TSS was erroneously ignored, in favor of the FADT. When TSS is used, the access width is included in the PTC control/status register. So it is unnecessary that the access bit width is multiplied by 8. At the same time the bit_offset should be considered for system I/O Access. It should be checked the bit_width and bit_offset of PTC regsiter in order to avoid the failure of system I/O access. It means that bit_width plus bit_offset can't be greater than 32. Signed-off-by: Zhao Yakui Signed-off-by: Li Shaohua Signed-off-by: Len Brown --- drivers/acpi/processor_throttling.c | 42 ++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 5c96ef18e94..f4b5f7d5dbe 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -131,6 +131,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr) struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *ptc = NULL; union acpi_object obj = { 0 }; + struct acpi_processor_throttling *throttling; status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer); if (ACPI_FAILURE(status)) { @@ -182,6 +183,22 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr) memcpy(&pr->throttling.status_register, obj.buffer.pointer, sizeof(struct acpi_ptc_register)); + throttling = &pr->throttling; + + if ((throttling->control_register.bit_width + + throttling->control_register.bit_offset) > 32) { + printk(KERN_ERR PREFIX "Invalid _PTC control register\n"); + result = -EFAULT; + goto end; + } + + if ((throttling->status_register.bit_width + + throttling->status_register.bit_offset) > 32) { + printk(KERN_ERR PREFIX "Invalid _PTC status register\n"); + result = -EFAULT; + goto end; + } + end: kfree(buffer.pointer); @@ -379,7 +396,9 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr) static int acpi_read_throttling_status(struct acpi_processor *pr, acpi_integer *value) { + u32 bit_width, bit_offset; u64 ptc_value; + u64 ptc_mask; struct acpi_processor_throttling *throttling; int ret = -1; @@ -387,11 +406,14 @@ static int acpi_read_throttling_status(struct acpi_processor *pr, switch (throttling->status_register.space_id) { case ACPI_ADR_SPACE_SYSTEM_IO: ptc_value = 0; + bit_width = throttling->status_register.bit_width; + bit_offset = throttling->status_register.bit_offset; + acpi_os_read_port((acpi_io_address) throttling->status_register. address, (u32 *) &ptc_value, - (u32) throttling->status_register.bit_width * - 8); - *value = (acpi_integer) ptc_value; + (u32) (bit_width + bit_offset)); + ptc_mask = (1 << bit_width) - 1; + *value = (acpi_integer) ((ptc_value >> bit_offset) & ptc_mask); ret = 0; break; case ACPI_ADR_SPACE_FIXED_HARDWARE: @@ -408,18 +430,24 @@ static int acpi_read_throttling_status(struct acpi_processor *pr, static int acpi_write_throttling_state(struct acpi_processor *pr, acpi_integer value) { + u32 bit_width, bit_offset; u64 ptc_value; + u64 ptc_mask; struct acpi_processor_throttling *throttling; int ret = -1; throttling = &pr->throttling; switch (throttling->control_register.space_id) { case ACPI_ADR_SPACE_SYSTEM_IO: - ptc_value = value; + bit_width = throttling->control_register.bit_width; + bit_offset = throttling->control_register.bit_offset; + ptc_mask = (1 << bit_width) - 1; + ptc_value = value & ptc_mask; + acpi_os_write_port((acpi_io_address) throttling-> - control_register.address, (u32) ptc_value, - (u32) throttling->control_register. - bit_width * 8); + control_register.address, + (u32) (ptc_value << bit_offset), + (u32) (bit_width + bit_offset)); ret = 0; break; case ACPI_ADR_SPACE_FIXED_HARDWARE: -- cgit v1.2.3 From 0ac3c571315a53c14d2733564f14ebdb911fe903 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Thu, 15 Nov 2007 17:05:46 +0800 Subject: ACPI: Get throttling info from BIOS only after evaluating _PDC Previously _PDC was evaluated later, and thus we'd not get the chance to tell the BIOS that we can suport FixedHW registers (MSRs) and the BIOS would always ask us to use System I/O access for throttling. Signed-off-by: Zhao Yakui Signed-off-by: Li Shaohua Signed-off-by: Len Brown --- drivers/acpi/processor_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 235a51e328c..e93318bb029 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -612,12 +612,6 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) request_region(pr->throttling.address, 6, "ACPI CPU throttle"); } -#ifdef CONFIG_CPU_FREQ - acpi_processor_ppc_has_changed(pr); -#endif - acpi_processor_get_throttling_info(pr); - acpi_processor_get_limit_info(pr); - return 0; } @@ -665,6 +659,12 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) /* _PDC call should be done before doing anything else (if reqd.). */ arch_acpi_processor_init_pdc(pr); acpi_processor_set_pdc(pr); +#ifdef CONFIG_CPU_FREQ + acpi_processor_ppc_has_changed(pr); +#endif + acpi_processor_get_throttling_info(pr); + acpi_processor_get_limit_info(pr); + acpi_processor_power_init(pr, device); -- cgit v1.2.3 From f79f06ab9f86d7203006d2ec8992ac80df36a34e Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Thu, 15 Nov 2007 17:06:36 +0800 Subject: ACPI: Enable MSR (FixedHW) support for T-States Add throttling control via MSR when T-states uses the FixHW Control Status registers. Signed-off-by: Zhao Yakui Signed-off-by: Li Shaohua Signed-off-by: Len Brown --- drivers/acpi/processor_throttling.c | 74 +++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index f4b5f7d5dbe..c26c61fb36c 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -393,6 +393,74 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr) return 0; } +#ifdef CONFIG_X86 +static int acpi_throttling_rdmsr(struct acpi_processor *pr, + acpi_integer * value) +{ + struct cpuinfo_x86 *c; + u64 msr_high, msr_low; + unsigned int cpu; + u64 msr = 0; + int ret = -1; + + cpu = pr->id; + c = &cpu_data(cpu); + + if ((c->x86_vendor != X86_VENDOR_INTEL) || + !cpu_has(c, X86_FEATURE_ACPI)) { + printk(KERN_ERR PREFIX + "HARDWARE addr space,NOT supported yet\n"); + } else { + msr_low = 0; + msr_high = 0; + rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, + (u32 *)&msr_low , (u32 *) &msr_high); + msr = (msr_high << 32) | msr_low; + *value = (acpi_integer) msr; + ret = 0; + } + return ret; +} + +static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) +{ + struct cpuinfo_x86 *c; + unsigned int cpu; + int ret = -1; + u64 msr; + + cpu = pr->id; + c = &cpu_data(cpu); + + if ((c->x86_vendor != X86_VENDOR_INTEL) || + !cpu_has(c, X86_FEATURE_ACPI)) { + printk(KERN_ERR PREFIX + "HARDWARE addr space,NOT supported yet\n"); + } else { + msr = value; + wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, + msr & 0xffffffff, msr >> 32); + ret = 0; + } + return ret; +} +#else +static int acpi_throttling_rdmsr(struct acpi_processor *pr, + acpi_integer * value) +{ + printk(KERN_ERR PREFIX + "HARDWARE addr space,NOT supported yet\n"); + return -1; +} + +static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) +{ + printk(KERN_ERR PREFIX + "HARDWARE addr space,NOT supported yet\n"); + return -1; +} +#endif + static int acpi_read_throttling_status(struct acpi_processor *pr, acpi_integer *value) { @@ -417,8 +485,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr, ret = 0; break; case ACPI_ADR_SPACE_FIXED_HARDWARE: - printk(KERN_ERR PREFIX - "HARDWARE addr space,NOT supported yet\n"); + ret = acpi_throttling_rdmsr(pr, value); break; default: printk(KERN_ERR PREFIX "Unknown addr space %d\n", @@ -451,8 +518,7 @@ static int acpi_write_throttling_state(struct acpi_processor *pr, ret = 0; break; case ACPI_ADR_SPACE_FIXED_HARDWARE: - printk(KERN_ERR PREFIX - "HARDWARE addr space,NOT supported yet\n"); + ret = acpi_throttling_wrmsr(pr, value); break; default: printk(KERN_ERR PREFIX "Unknown addr space %d\n", -- cgit v1.2.3 From 037cbc63fd83162a8ee0c69680207ce4609adbea Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 18 Nov 2007 00:32:31 +0300 Subject: ACPI: SBS: Fix retval warning drivers/acpi/sbs.c: In function acpi_battery_add: drivers/acpi/sbs.c:811: warning: ignoring return value of device_create_file, declared with attribute warn_unused_result Additional cleanups: * use struct acpi_battery in acpi_battery_remove() to clean up function calls, just like acpi_battery_add() already does. * put braces around unregister call, as it depends on dev being not NULL. * remove unneeded braces Signed-off-by: Jeff Garzik Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/sbs.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 90fd09c65f9..73c1ba31429 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -113,6 +113,7 @@ struct acpi_battery { u16 spec; u8 id; u8 present:1; + u8 have_sysfs_alarm:1; }; #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); @@ -808,7 +809,13 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) } battery->bat.get_property = acpi_sbs_battery_get_property; result = power_supply_register(&sbs->device->dev, &battery->bat); - device_create_file(battery->bat.dev, &alarm_attr); + if (result) + goto end; + result = device_create_file(battery->bat.dev, &alarm_attr); + if (result) + goto end; + battery->have_sysfs_alarm = 1; + end: printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), battery->name, sbs->battery->present ? "present" : "absent"); @@ -817,14 +824,16 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) static void acpi_battery_remove(struct acpi_sbs *sbs, int id) { - if (sbs->battery[id].bat.dev) - device_remove_file(sbs->battery[id].bat.dev, &alarm_attr); - power_supply_unregister(&sbs->battery[id].bat); -#ifdef CONFIG_ACPI_PROCFS - if (sbs->battery[id].proc_entry) { - acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry), - acpi_battery_dir); + struct acpi_battery *battery = &sbs->battery[id]; + + if (battery->bat.dev) { + if (battery->have_sysfs_alarm) + device_remove_file(battery->bat.dev, &alarm_attr); + power_supply_unregister(&battery->bat); } +#ifdef CONFIG_ACPI_PROCFS + if (battery->proc_entry) + acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir); #endif } -- cgit v1.2.3 From 74b2553f1d13e60fb27063204bd5b6908a6f8494 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 19 Nov 2007 11:20:42 -0500 Subject: virtio: fix module/device unloading The virtio code never hooked through the ->remove callback. Although noone supports device removal at the moment, this code is already needed for module unloading. This of course also revealed bugs in virtio_blk, virtio_net and lguest unloading paths. Signed-off-by: Rusty Russell --- drivers/block/virtio_blk.c | 10 +++++++--- drivers/lguest/lguest_device.c | 2 ++ drivers/net/virtio_net.c | 8 ++++++-- drivers/virtio/virtio.c | 13 +++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 3cf7129d83e..924ddd8bccd 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -223,7 +223,7 @@ static int virtblk_probe(struct virtio_device *vdev) err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_CAPACITY, &cap); if (err) { dev_err(&vdev->dev, "Bad/missing capacity in config\n"); - goto out_put_disk; + goto out_cleanup_queue; } /* If capacity is too big, truncate with warning. */ @@ -239,7 +239,7 @@ static int virtblk_probe(struct virtio_device *vdev) blk_queue_max_segment_size(vblk->disk->queue, v); else if (err != -ENOENT) { dev_err(&vdev->dev, "Bad SIZE_MAX in config\n"); - goto out_put_disk; + goto out_cleanup_queue; } err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_SEG_MAX, &v); @@ -247,12 +247,14 @@ static int virtblk_probe(struct virtio_device *vdev) blk_queue_max_hw_segments(vblk->disk->queue, v); else if (err != -ENOENT) { dev_err(&vdev->dev, "Bad SEG_MAX in config\n"); - goto out_put_disk; + goto out_cleanup_queue; } add_disk(vblk->disk); return 0; +out_cleanup_queue: + blk_cleanup_queue(vblk->disk->queue); out_put_disk: put_disk(vblk->disk); out_unregister_blkdev: @@ -277,6 +279,8 @@ static void virtblk_remove(struct virtio_device *vdev) put_disk(vblk->disk); unregister_blkdev(major, "virtblk"); mempool_destroy(vblk->pool); + /* There should be nothing in the queue now, so no need to shutdown */ + vdev->config->del_vq(vblk->vq); kfree(vblk); } diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 66f38722253..e2eec38c83c 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c @@ -247,6 +247,8 @@ static void lg_del_vq(struct virtqueue *vq) { struct lguest_vq_info *lvq = vq->priv; + /* Release the interrupt */ + free_irq(lvq->config.irq, vq); /* Tell virtio_ring.c to free the virtqueue. */ vring_del_virtqueue(vq); /* Unmap the pages containing the ring. */ diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index a75be57fb20..d74e6f4aa24 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -404,8 +404,12 @@ free: static void virtnet_remove(struct virtio_device *vdev) { - unregister_netdev(vdev->priv); - free_netdev(vdev->priv); + struct virtnet_info *vi = vdev->priv; + + vdev->config->del_vq(vi->svq); + vdev->config->del_vq(vi->rvq); + unregister_netdev(vi->dev); + free_netdev(vi->dev); } static struct virtio_device_id id_table[] = { diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 15d7787dea8..69d7ea02cd4 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -96,10 +96,23 @@ static int virtio_dev_probe(struct device *_d) return err; } +static int virtio_dev_remove(struct device *_d) +{ + struct virtio_device *dev = container_of(_d,struct virtio_device,dev); + struct virtio_driver *drv = container_of(dev->dev.driver, + struct virtio_driver, driver); + + dev->config->set_status(dev, dev->config->get_status(dev) + & ~VIRTIO_CONFIG_S_DRIVER); + drv->remove(dev); + return 0; +} + int register_virtio_driver(struct virtio_driver *driver) { driver->driver.bus = &virtio_bus; driver->driver.probe = virtio_dev_probe; + driver->driver.remove = virtio_dev_remove; return driver_register(&driver->driver); } EXPORT_SYMBOL_GPL(register_virtio_driver); -- cgit v1.2.3 From 8329d98e480250ef5f5a083f9c3af50510b5e65d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 19 Nov 2007 11:20:43 -0500 Subject: virtio: fix net driver loop case where we fail to restart skb is only NULL the first time around: it's more correct to test for being under-budget. Signed-off-by: Rusty Russell --- drivers/net/virtio_net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index d74e6f4aa24..5413dbf3d4a 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -198,8 +198,8 @@ again: if (vi->num < vi->max / 2) try_fill_recv(vi); - /* All done? */ - if (!skb) { + /* Out of packets? */ + if (received < budget) { netif_rx_complete(vi->dev, napi); if (unlikely(!vi->rvq->vq_ops->restart(vi->rvq)) && netif_rx_reschedule(vi->dev, napi)) -- cgit v1.2.3 From b242e891c218162cfbae064b1a9136cdbed5ee53 Mon Sep 17 00:00:00 2001 From: Ivo van Doorn Date: Thu, 15 Nov 2007 23:41:31 +0100 Subject: rt2x00: Request usb_maxpacket() once The usb max packet size won't change during the device's presence. We should store it in a variable inside rt2x00dev and use that. This should also fix a division error when the device is being hot-unplugged while a frame is being send out. Signed-off-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2500usb.c | 7 +++---- drivers/net/wireless/rt2x00/rt2x00.h | 7 ++++++- drivers/net/wireless/rt2x00/rt2x00usb.c | 9 ++++++--- drivers/net/wireless/rt2x00/rt73usb.c | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c index 277a020b35e..50775f9234c 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/drivers/net/wireless/rt2x00/rt2500usb.c @@ -1032,7 +1032,7 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, } static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev, - int maxpacket, struct sk_buff *skb) + struct sk_buff *skb) { int length; @@ -1041,7 +1041,7 @@ static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev, * but it must _not_ be a multiple of the USB packet size. */ length = roundup(skb->len, 2); - length += (2 * !(length % maxpacket)); + length += (2 * !(length % rt2x00dev->usb_maxpacket)); return length; } @@ -1643,7 +1643,6 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct data_entry *beacon; struct data_entry *guardian; int pipe = usb_sndbulkpipe(usb_dev, 1); - int max_packet = usb_maxpacket(usb_dev, pipe, 1); int length; /* @@ -1672,7 +1671,7 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw, ring->desc_size), skb->len - ring->desc_size, control); - length = rt2500usb_get_tx_data_len(rt2x00dev, max_packet, skb); + length = rt2500usb_get_tx_data_len(rt2x00dev, skb); usb_fill_bulk_urb(beacon->priv, usb_dev, pipe, skb->data, length, rt2500usb_beacondone, beacon); diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index d1ad5251a77..c8f16f161c2 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h @@ -418,7 +418,7 @@ struct rt2x00lib_ops { int (*write_tx_data) (struct rt2x00_dev *rt2x00dev, struct data_ring *ring, struct sk_buff *skb, struct ieee80211_tx_control *control); - int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, int maxpacket, + int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, struct sk_buff *skb); void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev, unsigned int queue); @@ -598,6 +598,11 @@ struct rt2x00_dev { */ u32 *rf; + /* + * USB Max frame size (for rt2500usb & rt73usb). + */ + u16 usb_maxpacket; + /* * Current TX power value. */ diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c index 73cc726c404..1f5675dd329 100644 --- a/drivers/net/wireless/rt2x00/rt2x00usb.c +++ b/drivers/net/wireless/rt2x00/rt2x00usb.c @@ -159,7 +159,6 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, interface_to_usbdev(rt2x00dev_usb(rt2x00dev)); struct data_entry *entry = rt2x00_get_data_entry(ring); int pipe = usb_sndbulkpipe(usb_dev, 1); - int max_packet = usb_maxpacket(usb_dev, pipe, 1); u32 length; if (rt2x00_ring_full(ring)) { @@ -194,8 +193,7 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, * length of the data to usb_fill_bulk_urb. Pass the skb * to the driver to determine what the length should be. */ - length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, - max_packet, skb); + length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, skb); /* * Initialize URB and send the frame to the device. @@ -490,6 +488,11 @@ int rt2x00usb_probe(struct usb_interface *usb_intf, rt2x00dev->ops = ops; rt2x00dev->hw = hw; + rt2x00dev->usb_maxpacket = + usb_maxpacket(usb_dev, usb_sndbulkpipe(usb_dev, 1), 1); + if (!rt2x00dev->usb_maxpacket) + rt2x00dev->usb_maxpacket = 1; + retval = rt2x00usb_alloc_reg(rt2x00dev); if (retval) goto exit_free_device; diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index dc640bf6b5e..c0671c2e6e7 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c @@ -1251,7 +1251,7 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, } static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev, - int maxpacket, struct sk_buff *skb) + struct sk_buff *skb) { int length; @@ -1260,7 +1260,7 @@ static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev, * but it must _not_ be a multiple of the USB packet size. */ length = roundup(skb->len, 4); - length += (4 * !(length % maxpacket)); + length += (4 * !(length % rt2x00dev->usb_maxpacket)); return length; } -- cgit v1.2.3 From de753e5e8678d9674de0a3bda9ead9e770fdbf53 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 12 Nov 2007 17:56:24 +0900 Subject: ata_piix: add SATELLITE U205 to broken suspend list Satellite U205 has alternate product name where the satellite part is all capatalized. Add it to the blacklist. This is reported by Ross Patterson in kernel bugzilla bug #7780. Signed-off-by: Tejun Heo Cc: Ross Patterson --- drivers/ata/ata_piix.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 328ce8a0842..80b735b7097 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -973,6 +973,13 @@ static int piix_broken_suspend(void) DMI_MATCH(DMI_PRODUCT_NAME, "Satellite U205"), }, }, + { + .ident = "SATELLITE U205", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), + DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE U205"), + }, + }, { .ident = "Portege M500", .matches = { -- cgit v1.2.3 From 21bef6dd2b419f28c8096a8e30ad86dcbff44c02 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 15 Nov 2007 10:35:45 +0900 Subject: libata: remove unused functions This patch removes the following obsolete functions: - libata-core.c: __sata_phy_reset() - libata-core.c: sata_phy_reset() - libata-eh.c: ata_qc_timeout() - libata-eh.c: ata_eng_timeout() Signed-off-by: Adrian Bunk Signed-off-by: Tejun Heo --- drivers/ata/libata-core.c | 78 -------------------------------------- drivers/ata/libata-eh.c | 95 ----------------------------------------------- 2 files changed, 173 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 81898036dbc..1584164e770 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2580,81 +2580,6 @@ void sata_print_link_status(struct ata_link *link) } } -/** - * __sata_phy_reset - Wake/reset a low-level SATA PHY - * @ap: SATA port associated with target SATA PHY. - * - * This function issues commands to standard SATA Sxxx - * PHY registers, to wake up the phy (and device), and - * clear any reset condition. - * - * LOCKING: - * PCI/etc. bus probe sem. - * - */ -void __sata_phy_reset(struct ata_port *ap) -{ - struct ata_link *link = &ap->link; - unsigned long timeout = jiffies + (HZ * 5); - u32 sstatus; - - if (ap->flags & ATA_FLAG_SATA_RESET) { - /* issue phy wake/reset */ - sata_scr_write_flush(link, SCR_CONTROL, 0x301); - /* Couldn't find anything in SATA I/II specs, but - * AHCI-1.1 10.4.2 says at least 1 ms. */ - mdelay(1); - } - /* phy wake/clear reset */ - sata_scr_write_flush(link, SCR_CONTROL, 0x300); - - /* wait for phy to become ready, if necessary */ - do { - msleep(200); - sata_scr_read(link, SCR_STATUS, &sstatus); - if ((sstatus & 0xf) != 1) - break; - } while (time_before(jiffies, timeout)); - - /* print link status */ - sata_print_link_status(link); - - /* TODO: phy layer with polling, timeouts, etc. */ - if (!ata_link_offline(link)) - ata_port_probe(ap); - else - ata_port_disable(ap); - - if (ap->flags & ATA_FLAG_DISABLED) - return; - - if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { - ata_port_disable(ap); - return; - } - - ap->cbl = ATA_CBL_SATA; -} - -/** - * sata_phy_reset - Reset SATA bus. - * @ap: SATA port associated with target SATA PHY. - * - * This function resets the SATA bus, and then probes - * the bus for devices. - * - * LOCKING: - * PCI/etc. bus probe sem. - * - */ -void sata_phy_reset(struct ata_port *ap) -{ - __sata_phy_reset(ap); - if (ap->flags & ATA_FLAG_DISABLED) - return; - ata_bus_reset(ap); -} - /** * ata_dev_pair - return other device on cable * @adev: device @@ -7653,8 +7578,6 @@ EXPORT_SYMBOL_GPL(ata_dev_disable); EXPORT_SYMBOL_GPL(sata_set_spd); EXPORT_SYMBOL_GPL(sata_link_debounce); EXPORT_SYMBOL_GPL(sata_link_resume); -EXPORT_SYMBOL_GPL(sata_phy_reset); -EXPORT_SYMBOL_GPL(__sata_phy_reset); EXPORT_SYMBOL_GPL(ata_bus_reset); EXPORT_SYMBOL_GPL(ata_std_prereset); EXPORT_SYMBOL_GPL(ata_std_softreset); @@ -7725,7 +7648,6 @@ EXPORT_SYMBOL_GPL(ata_port_desc); #ifdef CONFIG_PCI EXPORT_SYMBOL_GPL(ata_port_pbar_desc); #endif /* CONFIG_PCI */ -EXPORT_SYMBOL_GPL(ata_eng_timeout); EXPORT_SYMBOL_GPL(ata_port_schedule_eh); EXPORT_SYMBOL_GPL(ata_link_abort); EXPORT_SYMBOL_GPL(ata_port_abort); diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index ed8813b222a..0dac69db1fd 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -559,101 +559,6 @@ void ata_port_wait_eh(struct ata_port *ap) } } -/** - * ata_qc_timeout - Handle timeout of queued command - * @qc: Command that timed out - * - * Some part of the kernel (currently, only the SCSI layer) - * has noticed that the active command on port @ap has not - * completed after a specified length of time. Handle this - * condition by disabling DMA (if necessary) and completing - * transactions, with error if necessary. - * - * This also handles the case of the "lost interrupt", where - * for some reason (possibly hardware bug, possibly driver bug) - * an interrupt was not delivered to the driver, even though the - * transaction completed successfully. - * - * TODO: kill this function once old EH is gone. - * - * LOCKING: - * Inherited from SCSI layer (none, can sleep) - */ -static void ata_qc_timeout(struct ata_queued_cmd *qc) -{ - struct ata_port *ap = qc->ap; - u8 host_stat = 0, drv_stat; - unsigned long flags; - - DPRINTK("ENTER\n"); - - ap->hsm_task_state = HSM_ST_IDLE; - - spin_lock_irqsave(ap->lock, flags); - - switch (qc->tf.protocol) { - - case ATA_PROT_DMA: - case ATA_PROT_ATAPI_DMA: - host_stat = ap->ops->bmdma_status(ap); - - /* before we do anything else, clear DMA-Start bit */ - ap->ops->bmdma_stop(qc); - - /* fall through */ - - default: - ata_altstatus(ap); - drv_stat = ata_chk_status(ap); - - /* ack bmdma irq events */ - ap->ops->irq_clear(ap); - - ata_dev_printk(qc->dev, KERN_ERR, "command 0x%x timeout, " - "stat 0x%x host_stat 0x%x\n", - qc->tf.command, drv_stat, host_stat); - - /* complete taskfile transaction */ - qc->err_mask |= AC_ERR_TIMEOUT; - break; - } - - spin_unlock_irqrestore(ap->lock, flags); - - ata_eh_qc_complete(qc); - - DPRINTK("EXIT\n"); -} - -/** - * ata_eng_timeout - Handle timeout of queued command - * @ap: Port on which timed-out command is active - * - * Some part of the kernel (currently, only the SCSI layer) - * has noticed that the active command on port @ap has not - * completed after a specified length of time. Handle this - * condition by disabling DMA (if necessary) and completing - * transactions, with error if necessary. - * - * This also handles the case of the "lost interrupt", where - * for some reason (possibly hardware bug, possibly driver bug) - * an interrupt was not delivered to the driver, even though the - * transaction completed successfully. - * - * TODO: kill this function once old EH is gone. - * - * LOCKING: - * Inherited from SCSI layer (none, can sleep) - */ -void ata_eng_timeout(struct ata_port *ap) -{ - DPRINTK("ENTER\n"); - - ata_qc_timeout(ata_qc_from_tag(ap, ap->link.active_tag)); - - DPRINTK("EXIT\n"); -} - static int ata_eh_nr_in_flight(struct ata_port *ap) { unsigned int tag; -- cgit v1.2.3 From 2d3b8eea7f2fbafd5d779cc92f7aedbd1ef575e9 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Thu, 15 Nov 2007 10:35:46 +0900 Subject: libata: workaround DRQ=1 ERR=1 for ATAPI tape drives After an error condition, some ATAPI tape drives set DRQ=1 together with ERR=1 when asking the host to transfer the CDB of the next packet command (i.e. request sense). This patch, a revised version of Alan/Mark's previous patch, adds ATA_HORKAGE_STUCK_ERR to workaround the problem by ignoring the ERR bit and proceed sending the CDB. Signed-off-by: Albert Lee Cc: Alan Cox Cc: Mark Lord Signed-off-by: Tejun Heo --- drivers/ata/libata-core.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 1584164e770..5478b4c6c6e 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5415,11 +5415,19 @@ fsm_start: * let the EH abort the command or reset the device. */ if (unlikely(status & (ATA_ERR | ATA_DF))) { - ata_port_printk(ap, KERN_WARNING, "DRQ=1 with device " - "error, dev_stat 0x%X\n", status); - qc->err_mask |= AC_ERR_HSM; - ap->hsm_task_state = HSM_ST_ERR; - goto fsm_start; + /* Some ATAPI tape drives forget to clear the ERR bit + * when doing the next command (mostly request sense). + * We ignore ERR here to workaround and proceed sending + * the CDB. + */ + if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) { + ata_port_printk(ap, KERN_WARNING, + "DRQ=1 with device error, " + "dev_stat 0x%X\n", status); + qc->err_mask |= AC_ERR_HSM; + ap->hsm_task_state = HSM_ST_ERR; + goto fsm_start; + } } /* Send the CDB (atapi) or the first data block (ata pio out). -- cgit v1.2.3 From f442cd86c1c86c5f44bc2cf23f89536f7e4cfe59 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Thu, 15 Nov 2007 10:35:47 +0900 Subject: libata: use ATA_HORKAGE_STUCK_ERR for ATAPI tape drives Per Mark's comments, maybe all ATAPI tape drives need ATA_HORKAGE_STUCK_ERR. This patch applys ATA_HORKAGE_STUCK_ERR for all ATAPI tape drives. Signed-off-by: Albert Lee Cc: Mark Lord Signed-off-by: Tejun Heo --- drivers/ata/libata-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 5478b4c6c6e..f7f6ca991e3 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2307,8 +2307,10 @@ int ata_dev_configure(struct ata_device *dev) } if ((dev->class == ATA_DEV_ATAPI) && - (atapi_command_packet_set(id) == TYPE_TAPE)) + (atapi_command_packet_set(id) == TYPE_TAPE)) { dev->max_sectors = ATA_MAX_SECTORS_TAPE; + dev->horkage |= ATA_HORKAGE_STUCK_ERR; + } if (dev->horkage & ATA_HORKAGE_MAX_SEC_128) dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128, -- cgit v1.2.3 From 607126c2a21cd6e9bb807fdd415c1a992f7b9009 Mon Sep 17 00:00:00 2001 From: Mark Lord Date: Thu, 15 Nov 2007 13:13:59 +0900 Subject: libata-scsi: be tolerant of 12-byte ATAPI commands in 16-byte CDBs Sebastian Kemper reported that issuing CD/DVD commands under libata is not fully compatible with ide-scsi. In particular, the GPCMD_SET_STREAMING was being rejected at the host level in some instances. The reason is that libata-scsi insists upon the cmd_len field exactly matching the SCSI opcode being issued, whereas ide-scsi tolerates 12-byte commands contained within a 16-byte (cmd_len) CDB. There doesn't seem to be a good reason for us to not be compatible there, so here is a patch to fix libata-scsi to permit SCSI opcodes so long as they fit within whatever size CDB is provided. Signed-off-by: Mark Lord Signed-off-by: Tejun Heo --- drivers/ata/libata-scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 94144ed50a6..a45f6ac3b24 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2869,7 +2869,8 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, xlat_func = NULL; if (likely((scsi_op != ATA_16) || !atapi_passthru16)) { /* relay SCSI command to ATAPI device */ - if (unlikely(scmd->cmd_len > dev->cdb_len)) + int len = COMMAND_SIZE(scsi_op); + if (unlikely(len > scmd->cmd_len || len > dev->cdb_len)) goto bad_cdb_len; xlat_func = atapi_xlat; -- cgit v1.2.3 From 1f71d0672ac88e79f444d77102e05292dbc66d0d Mon Sep 17 00:00:00 2001 From: Gabriel C Date: Thu, 15 Nov 2007 13:14:00 +0900 Subject: pata_sis.c: Add Packard Bell EasyNote K5305 to laptops With newer kernels HDD in my old laptop is limited to UDMA 33. With this patch I get UDMA 100 again. Signed-off-by: Gabriel Craciunescu Signed-off-by: Tejun Heo --- drivers/ata/pata_sis.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c index 3b5be77e861..87546d9f1ca 100644 --- a/drivers/ata/pata_sis.c +++ b/drivers/ata/pata_sis.c @@ -55,6 +55,7 @@ static const struct sis_laptop sis_laptop[] = { /* devid, subvendor, subdev */ { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */ { 0x5513, 0x1734, 0x105F }, /* FSC Amilo A1630 */ + { 0x5513, 0x1071, 0x8640 }, /* EasyNote K5305 */ /* end marker */ { 0, } }; -- cgit v1.2.3 From 00242ec87608d7a0ed989e54333f3fc8f3d665b0 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 19 Nov 2007 11:24:25 +0900 Subject: ata_piix: reorganize controller IDs Move piix_pata_mwdma to top, rename ich9_2port_sata to ich8_2port_sata for consistency and use automatically incremented values instead of assigning fixed values to ease adding new controller IDs. Signed-off-by: Tejun Heo --- drivers/ata/ata_piix.c | 62 +++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 80b735b7097..77fea05990d 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -119,18 +119,18 @@ enum { PIIX_80C_SEC = (1 << 7) | (1 << 6), /* controller IDs */ - piix_pata_33 = 0, /* PIIX4 at 33Mhz */ - ich_pata_33 = 1, /* ICH up to UDMA 33 only */ - ich_pata_66 = 2, /* ICH up to 66 Mhz */ - ich_pata_100 = 3, /* ICH up to UDMA 100 */ - ich5_sata = 5, - ich6_sata = 6, - ich6_sata_ahci = 7, - ich6m_sata_ahci = 8, - ich8_sata_ahci = 9, - piix_pata_mwdma = 10, /* PIIX3 MWDMA only */ - tolapai_sata_ahci = 11, - ich9_2port_sata = 12, + piix_pata_mwdma = 0, /* PIIX3 MWDMA only */ + piix_pata_33, /* PIIX4 at 33Mhz */ + ich_pata_33, /* ICH up to UDMA 33 only */ + ich_pata_66, /* ICH up to 66 Mhz */ + ich_pata_100, /* ICH up to UDMA 100 */ + ich5_sata, + ich6_sata, + ich6_sata_ahci, + ich6m_sata_ahci, + ich8_sata_ahci, + ich8_2port_sata, + tolapai_sata_ahci, /* constants for mapping table */ P0 = 0, /* port 0 */ @@ -239,19 +239,19 @@ static const struct pci_device_id piix_pci_tbl[] = { /* SATA Controller 1 IDE (ICH8) */ { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, /* SATA Controller 2 IDE (ICH8) */ - { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, + { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, /* Mobile SATA Controller IDE (ICH8M) */ { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, /* SATA Controller IDE (ICH9) */ { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, /* SATA Controller IDE (ICH9) */ - { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, + { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, /* SATA Controller IDE (ICH9) */ - { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, + { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, /* SATA Controller IDE (ICH9M) */ - { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, + { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, /* SATA Controller IDE (ICH9M) */ - { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, + { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, /* SATA Controller IDE (ICH9M) */ { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, /* SATA Controller IDE (Tolapai) */ @@ -437,7 +437,7 @@ static const struct piix_map_db ich8_map_db = { }, }; -static const struct piix_map_db tolapai_map_db = { +static const struct piix_map_db ich8_2port_map_db = { .mask = 0x3, .port_enable = 0x3, .map = { @@ -449,7 +449,7 @@ static const struct piix_map_db tolapai_map_db = { }, }; -static const struct piix_map_db ich9_2port_map_db = { +static const struct piix_map_db tolapai_map_db = { .mask = 0x3, .port_enable = 0x3, .map = { @@ -467,11 +467,20 @@ static const struct piix_map_db *piix_map_db_table[] = { [ich6_sata_ahci] = &ich6_map_db, [ich6m_sata_ahci] = &ich6m_map_db, [ich8_sata_ahci] = &ich8_map_db, + [ich8_2port_sata] = &ich8_2port_map_db, [tolapai_sata_ahci] = &tolapai_map_db, - [ich9_2port_sata] = &ich9_2port_map_db, }; static struct ata_port_info piix_port_info[] = { + [piix_pata_mwdma] = /* PIIX3 MWDMA only */ + { + .sht = &piix_sht, + .flags = PIIX_PATA_FLAGS, + .pio_mask = 0x1f, /* pio0-4 */ + .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ + .port_ops = &piix_pata_ops, + }, + [piix_pata_33] = /* PIIX4 at 33MHz */ { .sht = &piix_sht, @@ -565,16 +574,7 @@ static struct ata_port_info piix_port_info[] = { .port_ops = &piix_sata_ops, }, - [piix_pata_mwdma] = /* PIIX3 MWDMA only */ - { - .sht = &piix_sht, - .flags = PIIX_PATA_FLAGS, - .pio_mask = 0x1f, /* pio0-4 */ - .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ - .port_ops = &piix_pata_ops, - }, - - [tolapai_sata_ahci] = + [ich8_2port_sata] = { .sht = &piix_sht, .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR | @@ -585,7 +585,7 @@ static struct ata_port_info piix_port_info[] = { .port_ops = &piix_sata_ops, }, - [ich9_2port_sata] = + [tolapai_sata_ahci] = { .sht = &piix_sht, .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR | -- cgit v1.2.3 From 8d8ef2fb931d1035e1f02095086cfd3f78eafe3f Mon Sep 17 00:00:00 2001 From: Thomas Rohwer Date: Mon, 19 Nov 2007 11:54:24 +0900 Subject: ata_piix: only enable the first port on apple macbook pro ICH8M on apple macbook pro occasionally locks up completely during PCS initialization if ports other than the first one are enabled. Add a separate controller ID and only enable the first port. tj: commit description added and patch updated to fit with the previous controller ID update. Signed-off-by: Thomas Rohwer Signed-off-by: Tejun Heo --- drivers/ata/ata_piix.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'drivers') diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 77fea05990d..d5ff1d89bea 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -130,6 +130,7 @@ enum { ich6m_sata_ahci, ich8_sata_ahci, ich8_2port_sata, + ich8m_apple_sata_ahci, /* locks up on second port enable */ tolapai_sata_ahci, /* constants for mapping table */ @@ -242,6 +243,8 @@ static const struct pci_device_id piix_pci_tbl[] = { { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, /* Mobile SATA Controller IDE (ICH8M) */ { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, + /* Mobile SATA Controller IDE (ICH8M), Apple */ + { 0x8086, 0x2828, 0x106b, 0x00a0, 0, 0, ich8m_apple_sata_ahci }, /* SATA Controller IDE (ICH9) */ { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, /* SATA Controller IDE (ICH9) */ @@ -449,6 +452,18 @@ static const struct piix_map_db ich8_2port_map_db = { }, }; +static const struct piix_map_db ich8m_apple_map_db = { + .mask = 0x3, + .port_enable = 0x1, + .map = { + /* PM PS SM SS MAP */ + { P0, NA, NA, NA }, /* 00b */ + { RV, RV, RV, RV }, + { P0, P2, IDE, IDE }, /* 10b */ + { RV, RV, RV, RV }, + }, +}; + static const struct piix_map_db tolapai_map_db = { .mask = 0x3, .port_enable = 0x3, @@ -468,6 +483,7 @@ static const struct piix_map_db *piix_map_db_table[] = { [ich6m_sata_ahci] = &ich6m_map_db, [ich8_sata_ahci] = &ich8_map_db, [ich8_2port_sata] = &ich8_2port_map_db, + [ich8m_apple_sata_ahci] = &ich8m_apple_map_db, [tolapai_sata_ahci] = &tolapai_map_db, }; @@ -595,6 +611,18 @@ static struct ata_port_info piix_port_info[] = { .udma_mask = ATA_UDMA6, .port_ops = &piix_sata_ops, }, + + [ich8m_apple_sata_ahci] = + { + .sht = &piix_sht, + .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR | + PIIX_FLAG_AHCI, + .pio_mask = 0x1f, /* pio0-4 */ + .mwdma_mask = 0x07, /* mwdma0-2 */ + .udma_mask = ATA_UDMA6, + .port_ops = &piix_sata_ops, + }, + }; static struct pci_bits piix_enable_bits[] = { -- cgit v1.2.3 From a0ce9aca97ccf71dc969b44a4c9b3c36da0be362 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 19 Nov 2007 12:06:37 +0900 Subject: ata_piix: port enable for the first SATA controller of ICH8 is 0xf not 0x3 ICH8 and 9 use two SFF controllers to show 6 SATA ports. The first controllre hosts the first 4 ports while the second one hosts the last 2. The PCS register of the first controller encompasses the first four ports or all six ports depending on configuration while PCS of the second controller controls the last two ports. Using 0xf for the first controller and 0x3 for the second controller always result in the correct configuration. Signed-off-by: Tejun Heo --- drivers/ata/ata_piix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index d5ff1d89bea..671e7966500 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -430,7 +430,7 @@ static const struct piix_map_db ich6m_map_db = { static const struct piix_map_db ich8_map_db = { .mask = 0x3, - .port_enable = 0x3, + .port_enable = 0xf, .map = { /* PM PS SM SS MAP */ { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */ -- cgit v1.2.3 From f2d68935ba08cf80f151bbdb5628381184e4a498 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Mon, 19 Nov 2007 01:37:03 +0300 Subject: ACPI: EC: Workaround for optimized controllers Some controllers fail to send confirmation GPE after address write. Detect this and don't expect such confirmation in future. This is a generalization of previous workaround (66c5f4e7367b0085652931b2f3366de29e7ff5ec), which did only read address. http://bugzilla.kernel.org/show_bug.cgi?id=9327 Signed-off-by: Alexey Starikovskiy Tested-by: Romano Giannetti Signed-off-by: Len Brown --- drivers/acpi/ec.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 06b78e5e33a..390f8f8666d 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -75,7 +75,8 @@ enum { EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ EC_FLAGS_QUERY_PENDING, /* Query is pending */ EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ - EC_FLAGS_ONLY_IBF_GPE, /* Expect GPE only for IBF = 0 event */ + EC_FLAGS_NO_ADDRESS_GPE, /* Expect GPE only for non-address event */ + EC_FLAGS_ADDRESS, /* Address is being written */ }; static int acpi_ec_remove(struct acpi_device *device, int type); @@ -166,38 +167,45 @@ static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) { + int ret = 0; + if (unlikely(test_bit(EC_FLAGS_ADDRESS, &ec->flags) && + test_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags))) + force_poll = 1; if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && likely(!force_poll)) { if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), msecs_to_jiffies(ACPI_EC_DELAY))) - return 0; + goto end; clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); if (acpi_ec_check_status(ec, event)) { - if (event == ACPI_EC_EVENT_OBF_1) { - /* miss OBF = 1 GPE, don't expect it anymore */ - printk(KERN_INFO PREFIX "missing OBF_1 confirmation," - "switching to degraded mode.\n"); - set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); + if (test_bit(EC_FLAGS_ADDRESS, &ec->flags)) { + /* miss address GPE, don't expect it anymore */ + printk(KERN_INFO PREFIX "missing address confirmation," + "don't expect it any longer.\n"); + set_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags); } else { /* missing GPEs, switch back to poll mode */ - printk(KERN_INFO PREFIX "missing IBF_1 confirmations," + printk(KERN_INFO PREFIX "missing confirmations," "switch off interrupt mode.\n"); clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); } - return 0; + goto end; } } else { unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); while (time_before(jiffies, delay)) { if (acpi_ec_check_status(ec, event)) - return 0; + goto end; } } printk(KERN_ERR PREFIX "acpi_ec_wait timeout," " status = %d, expect_event = %d\n", acpi_ec_read_status(ec), event); - return -ETIME; + ret = -ETIME; + end: + clear_bit(EC_FLAGS_ADDRESS, &ec->flags); + return ret; } static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, @@ -216,6 +224,9 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, "write_cmd timeout, command = %d\n", command); goto end; } + /* mark the address byte written to EC */ + if (rdata_len + wdata_len > 1) + set_bit(EC_FLAGS_ADDRESS, &ec->flags); set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); acpi_ec_write_data(ec, *(wdata++)); } @@ -231,8 +242,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); for (; rdata_len > 0; --rdata_len) { - if (test_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags)) - force_poll = 1; result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); if (result) { printk(KERN_ERR PREFIX "read timeout, command = %d\n", -- cgit v1.2.3 From c88c5786d3df51ccfa4e2d111fc9c8fc0f5b2797 Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Fri, 2 Nov 2007 13:47:53 +0100 Subject: ACPI: Video: Increase buffer size for writes to brightness proc file. In order to be able to write the value "100" to /proc/acpi/video/.../brightness, we have to allocate 5 bytes: 4 characters will be written (1, 0, 0 plus null byte), and 1 byte should be buffer for a terminating NULL character. http://bugzilla.kernel.org/show_bug.cgi?id=9278 Signed-off-by: Danny Baumann Acked-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index dce0a6e47f5..44a0d9ba9bd 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -897,7 +897,7 @@ acpi_video_device_write_brightness(struct file *file, { struct seq_file *m = file->private_data; struct acpi_video_device *dev = m->private; - char str[4] = { 0 }; + char str[5] = { 0 }; unsigned int level = 0; int i; -- cgit v1.2.3 From fdcedbba2f98c94bfbac9f6e712ab765f997b8dc Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Mon, 19 Nov 2007 16:33:45 +0300 Subject: ACPI: Split out control for /proc/acpi entries from battery, ac, and sbs. Introduce new ACPI_PROCFS_POWER (default Yes) config option and move procfs code in battery, ac, and sbs drivers under it. This is done to allow ACPI_PROCFS to be default No. Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/Kconfig | 16 +++++++++++++++- drivers/acpi/Makefile | 2 +- drivers/acpi/ac.c | 20 ++++++++++---------- drivers/acpi/battery.c | 20 ++++++++++---------- drivers/acpi/sbs.c | 20 ++++++++++---------- 5 files changed, 46 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 087a7028ae8..497e92d3833 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -69,7 +69,21 @@ config ACPI_PROCFS and functions which do not yet exist in /sys. Say N to delete /proc/acpi/ files that have moved to /sys/ - +config ACPI_PROCFS_POWER + bool "Deprecated power /proc/acpi folders" + depends on PROC_FS + default y + ---help--- + For backwards compatibility, this option allows + deprecated power /proc/acpi/ folders to exist, even when + they have been replaced by functions in /sys. + The deprecated folders (and their replacements) include: + /proc/acpi/battery/* (/sys/class/power_supply/*) + /proc/acpi/ac_adapter/* (sys/class/power_supply/*) + This option has no effect on /proc/acpi/ folders + and functions, which do not yet exist in /sys + + Say N to delete power /proc/acpi/ folders that have moved to /sys/ config ACPI_PROC_EVENT bool "Deprecated /proc/acpi/event support" depends on PROC_FS diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 54e3ab0e5fc..456446f9007 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -58,6 +58,6 @@ obj-$(CONFIG_ACPI_NUMA) += numa.o obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o -obj-y += cm_sbs.o +obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o obj-$(CONFIG_ACPI_SBS) += sbs.o obj-$(CONFIG_ACPI_SBS) += sbshc.o diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 30238f6ff23..76ed4f52beb 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -27,7 +27,7 @@ #include #include #include -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER #include #include #endif @@ -51,7 +51,7 @@ MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_DESCRIPTION("ACPI AC Adapter Driver"); MODULE_LICENSE("GPL"); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER extern struct proc_dir_entry *acpi_lock_ac_dir(void); extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); static int acpi_ac_open_fs(struct inode *inode, struct file *file); @@ -86,7 +86,7 @@ struct acpi_ac { #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER static const struct file_operations acpi_ac_fops = { .open = acpi_ac_open_fs, .read = seq_read, @@ -136,7 +136,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac) return 0; } -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ @@ -275,7 +275,7 @@ static int acpi_ac_add(struct acpi_device *device) if (result) goto end; -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER result = acpi_ac_add_fs(device); #endif if (result) @@ -300,7 +300,7 @@ static int acpi_ac_add(struct acpi_device *device) end: if (result) { -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_ac_remove_fs(device); #endif kfree(ac); @@ -339,7 +339,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type) ACPI_ALL_NOTIFY, acpi_ac_notify); if (ac->charger.dev) power_supply_unregister(&ac->charger); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_ac_remove_fs(device); #endif @@ -355,7 +355,7 @@ static int __init acpi_ac_init(void) if (acpi_disabled) return -ENODEV; -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_ac_dir = acpi_lock_ac_dir(); if (!acpi_ac_dir) return -ENODEV; @@ -363,7 +363,7 @@ static int __init acpi_ac_init(void) result = acpi_bus_register_driver(&acpi_ac_driver); if (result < 0) { -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_unlock_ac_dir(acpi_ac_dir); #endif return -ENODEV; @@ -377,7 +377,7 @@ static void __exit acpi_ac_exit(void) acpi_bus_unregister_driver(&acpi_ac_driver); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_unlock_ac_dir(acpi_ac_dir); #endif diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 192c244f619..b871f289dd3 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -31,7 +31,7 @@ #include #include -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER #include #include #include @@ -63,7 +63,7 @@ static unsigned int cache_time = 1000; module_param(cache_time, uint, 0644); MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER extern struct proc_dir_entry *acpi_lock_battery_dir(void); extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); @@ -221,7 +221,7 @@ static enum power_supply_property energy_battery_props[] = { POWER_SUPPLY_PROP_MANUFACTURER, }; -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER inline char *acpi_battery_units(struct acpi_battery *battery) { return (battery->power_unit)?"mA":"mW"; @@ -479,7 +479,7 @@ static int acpi_battery_update(struct acpi_battery *battery) FS Interface (/proc) -------------------------------------------------------------------------- */ -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER static struct proc_dir_entry *acpi_battery_dir; static int acpi_battery_print_info(struct seq_file *seq, int result) @@ -786,7 +786,7 @@ static int acpi_battery_add(struct acpi_device *device) acpi_driver_data(device) = battery; mutex_init(&battery->lock); acpi_battery_update(battery); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER result = acpi_battery_add_fs(device); if (result) goto end; @@ -804,7 +804,7 @@ static int acpi_battery_add(struct acpi_device *device) device->status.battery_present ? "present" : "absent"); end: if (result) { -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_battery_remove_fs(device); #endif kfree(battery); @@ -823,7 +823,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type) status = acpi_remove_notify_handler(device->handle, ACPI_ALL_NOTIFY, acpi_battery_notify); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_battery_remove_fs(device); #endif sysfs_remove_battery(battery); @@ -859,13 +859,13 @@ static int __init acpi_battery_init(void) { if (acpi_disabled) return -ENODEV; -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_battery_dir = acpi_lock_battery_dir(); if (!acpi_battery_dir) return -ENODEV; #endif if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_unlock_battery_dir(acpi_battery_dir); #endif return -ENODEV; @@ -876,7 +876,7 @@ static int __init acpi_battery_init(void) static void __exit acpi_battery_exit(void) { acpi_bus_unregister_driver(&acpi_battery_driver); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_unlock_battery_dir(acpi_battery_dir); #endif } diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 90fd09c65f9..278d20f9366 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -29,7 +29,7 @@ #include #include -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER #include #include #include @@ -88,7 +88,7 @@ MODULE_DEVICE_TABLE(acpi, sbs_device_ids); struct acpi_battery { struct power_supply bat; struct acpi_sbs *sbs; -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER struct proc_dir_entry *proc_entry; #endif unsigned long update_time; @@ -122,7 +122,7 @@ struct acpi_sbs { struct acpi_device *device; struct acpi_smb_hc *hc; struct mutex lock; -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER struct proc_dir_entry *charger_entry; #endif struct acpi_battery battery[MAX_SBS_BAT]; @@ -468,7 +468,7 @@ static struct device_attribute alarm_attr = { FS Interface (/proc/acpi) -------------------------------------------------------------------------- */ -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER /* Generic Routines */ static int acpi_sbs_add_fs(struct proc_dir_entry **dir, @@ -789,7 +789,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) return result; sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir, battery->name, &acpi_battery_info_fops, &acpi_battery_state_fops, &acpi_battery_alarm_fops, @@ -820,7 +820,7 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id) if (sbs->battery[id].bat.dev) device_remove_file(sbs->battery[id].bat.dev, &alarm_attr); power_supply_unregister(&sbs->battery[id].bat); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER if (sbs->battery[id].proc_entry) { acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry), acpi_battery_dir); @@ -835,7 +835,7 @@ static int acpi_charger_add(struct acpi_sbs *sbs) result = acpi_ac_get_present(sbs); if (result) goto end; -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir, ACPI_AC_DIR_NAME, NULL, &acpi_ac_state_fops, NULL, sbs); @@ -859,7 +859,7 @@ static void acpi_charger_remove(struct acpi_sbs *sbs) { if (sbs->charger.dev) power_supply_unregister(&sbs->charger); -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER if (sbs->charger_entry) acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); #endif @@ -965,7 +965,7 @@ static int acpi_sbs_remove(struct acpi_device *device, int type) static void acpi_sbs_rmdirs(void) { -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER if (acpi_ac_dir) { acpi_unlock_ac_dir(acpi_ac_dir); acpi_ac_dir = NULL; @@ -1004,7 +1004,7 @@ static int __init acpi_sbs_init(void) if (acpi_disabled) return -ENODEV; -#ifdef CONFIG_ACPI_PROCFS +#ifdef CONFIG_ACPI_PROCFS_POWER acpi_ac_dir = acpi_lock_ac_dir(); if (!acpi_ac_dir) return -ENODEV; -- cgit v1.2.3 From 3539a901d60ae84f8b0748cd26c1c263c2b3ef5f Mon Sep 17 00:00:00 2001 From: Len Brown Date: Mon, 19 Nov 2007 11:22:35 -0500 Subject: Revert "ACPI: add documentation for deprecated /proc/acpi/battery in ACPI_PROCFS" This reverts commit 6e800af233e0bdf108efb7bd23c11ea6fa34cdeb. --- drivers/acpi/Kconfig | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 497e92d3833..5772e1405f7 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -61,7 +61,6 @@ config ACPI_PROCFS /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version) /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT) /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP) - /proc/acpi/battery (/sys/class/power_supply) /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer) /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level) -- cgit v1.2.3 From 65ea6520375cc09d19ecb46f03ab7ef70bcf06dd Mon Sep 17 00:00:00 2001 From: Len Brown Date: Mon, 19 Nov 2007 11:22:44 -0500 Subject: Revert "acpi: make ACPI_PROCFS default to y" This reverts commit cbff2fbf55c21f50298b1aef1263b11bf510e35f. --- drivers/acpi/Kconfig | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 5772e1405f7..b9f923ef173 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -50,7 +50,6 @@ config ACPI_SLEEP config ACPI_PROCFS bool "Deprecated /proc/acpi files" depends on PROC_FS - default y ---help--- For backwards compatibility, this option allows deprecated /proc/acpi/ files to exist, even when -- cgit v1.2.3 From 5870a8cd23181703cc76f88f630372f8602c7648 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Thu, 15 Nov 2007 21:52:47 +0300 Subject: ACPI: EC: Don't init EC early if it has no _INI Option to init EC early inserted to handle #8598 ASUS problem, introduced several others. EC driver in this particular case has fake _INI method, not present on other machines, which don't need or break from this workaround, so lets use its presence as a flag for early init. http://bugzilla.kernel.org/show_bug.cgi?id=9262 http://bugzilla.kernel.org/show_bug.cgi?id=8598 https://bugzilla.novell.com/show_bug.cgi?id=334806 Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/ec.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 06b78e5e33a..56afe13af59 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -881,12 +881,20 @@ int __init acpi_ec_ecdt_probe(void) boot_ec->gpe = ecdt_ptr->gpe; boot_ec->handle = ACPI_ROOT_OBJECT; } else { + /* This workaround is needed only on some broken machines, + * which require early EC, but fail to provide ECDT */ + acpi_handle x; printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n"); status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, boot_ec, NULL); /* Check that acpi_get_devices actually find something */ if (ACPI_FAILURE(status) || !boot_ec->handle) goto error; + /* We really need to limit this workaround, the only ASUS, + * which needs it, has fake EC._INI method, so use it as flag. + */ + if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x))) + goto error; } ret = ec_install_handlers(boot_ec); -- cgit v1.2.3 From f0714d20234062bd0a8f49a6b32f7d1d7f3c2943 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Mon, 19 Nov 2007 12:23:59 -0500 Subject: Revert "Fix very high interrupt rate for IRQ8 (rtc) unless pnpacpi=off" This reverts commit 9cd8047b463f213c294f756119ac353312e7a152. --- drivers/pnp/pnpacpi/rsparser.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'drivers') diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index cd0a204d96d..0e3b8d0ff06 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -85,16 +85,6 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, if (i >= PNP_MAX_IRQ) return; -#ifdef CONFIG_X86 - if (gsi < 16 && (triggering != ACPI_EDGE_SENSITIVE || - polarity != ACPI_ACTIVE_HIGH)) { - pnp_warn("BIOS BUG: legacy PNP IRQ %d should be edge trigger, " - "active high", gsi); - triggering = ACPI_EDGE_SENSITIVE; - polarity = ACPI_ACTIVE_HIGH; - } -#endif - res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag res->irq_resource[i].flags |= irq_flags(triggering, polarity); irq = acpi_register_gsi(gsi, triggering, polarity); -- cgit v1.2.3 From 59f91ff11e594913a5b3c03a4707fdf02338c8df Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Sun, 18 Nov 2007 09:18:29 -0200 Subject: ACPI: thinkpad-acpi: fix oops when a module parameter has no value set_ibm_param() could OOPS with a NULL pointer derreference if one did not give any values for a module parameter it handles. This would, of course, cause all sort of trouble for future modprobing and require a reboot to clean up properly. Fix it by returning -EINVAL if no values are given for the parameter, and also avoid any nastyness from BUG_ON while at it. How to reproduce: modprobe thinkpad-acpi brightness Signed-off-by: Henrique de Moraes Holschuh Tested-by: Mike Kershaw Signed-off-by: Len Brown --- drivers/misc/thinkpad_acpi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 8c943077528..ab23a322158 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -4817,9 +4817,15 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp) unsigned int i; struct ibm_struct *ibm; + if (!kp || !kp->name || !val) + return -EINVAL; + for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { ibm = ibms_init[i].data; - BUG_ON(ibm == NULL); + WARN_ON(ibm == NULL); + + if (!ibm || !ibm->name) + continue; if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { if (strlen(val) > sizeof(ibms_init[i].param) - 2) -- cgit v1.2.3 From c9c860e5349ef62cd9226694b3aa625ef66f504e Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Mon, 19 Nov 2007 19:48:00 -0500 Subject: cpuidle: fix C3 for no bus-master control case Port 18eab8550397f1f3d4b8b2c5257c88dae25d58ed (Enable C3 even when PM2_control is zero) to cpuidle. Without this patch, some systems will notice a regression when enabling CPU_IDLE -- C3 would no longer be available. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 0cad56ca342..943a8806900 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1514,23 +1514,38 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, } else { acpi_idle_update_bm_rld(pr, cx); - spin_lock(&c3_lock); - c3_cpu_count++; - /* Disable bus master arbitration when all CPUs are in C3 */ - if (c3_cpu_count == num_online_cpus()) - acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); - spin_unlock(&c3_lock); + /* + * disable bus master + * bm_check implies we need ARB_DIS + * !bm_check implies we need cache flush + * bm_control implies whether we can do ARB_DIS + * + * That leaves a case where bm_check is set and bm_control is + * not set. In that case we cannot do much, we enter C3 + * without doing anything. + */ + if (pr->flags.bm_check && pr->flags.bm_control) { + spin_lock(&c3_lock); + c3_cpu_count++; + /* Disable bus master arbitration when all CPUs are in C3 */ + if (c3_cpu_count == num_online_cpus()) + acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); + spin_unlock(&c3_lock); + } else if (!pr->flags.bm_check) { + ACPI_FLUSH_CPU_CACHE(); + } t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); acpi_idle_do_entry(cx); t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); - spin_lock(&c3_lock); /* Re-enable bus master arbitration */ - if (c3_cpu_count == num_online_cpus()) + if (pr->flags.bm_check && pr->flags.bm_control) { + spin_lock(&c3_lock); acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); - c3_cpu_count--; - spin_unlock(&c3_lock); + c3_cpu_count--; + spin_unlock(&c3_lock); + } } #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) -- cgit v1.2.3 From 5062911830a66df0c0ad28c387a8c0623cb0d28c Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Mon, 19 Nov 2007 19:49:00 -0500 Subject: cpuidle: add sched_clock_idle_[sleep|wakeup]_event() hooks Port 2aa44d0567ed21b47b87d68819415d48194cb923 (sched: sched_clock_idle_[sleep|wakeup]_event()) to cpuidle. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 943a8806900..1af0694e852 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1411,6 +1411,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, struct acpi_processor *pr; struct acpi_processor_cx *cx = cpuidle_get_statedata(state); u32 t1, t2; + int sleep_ticks = 0; + pr = processors[smp_processor_id()]; if (unlikely(!pr)) @@ -1440,6 +1442,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, ACPI_FLUSH_CPU_CACHE(); t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); + /* Tell the scheduler that we are going deep-idle: */ + sched_clock_idle_sleep_event(); acpi_state_timer_broadcast(pr, cx, 1); acpi_idle_do_entry(cx); t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); @@ -1448,6 +1452,10 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, /* TSC could halt in idle, so notify users */ mark_tsc_unstable("TSC halts in idle");; #endif + sleep_ticks = ticks_elapsed(t1, t2); + + /* Tell the scheduler how much we idled: */ + sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); local_irq_enable(); current_thread_info()->status |= TS_POLLING; @@ -1455,7 +1463,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, cx->usage++; acpi_state_timer_broadcast(pr, cx, 0); - cx->time += ticks_elapsed(t1, t2); + cx->time += sleep_ticks; return ticks_elapsed_in_us(t1, t2); } @@ -1475,6 +1483,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, struct acpi_processor *pr; struct acpi_processor_cx *cx = cpuidle_get_statedata(state); u32 t1, t2; + int sleep_ticks = 0; + pr = processors[smp_processor_id()]; if (unlikely(!pr)) @@ -1497,6 +1507,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, return 0; } + /* Tell the scheduler that we are going deep-idle: */ + sched_clock_idle_sleep_event(); /* * Must be done before busmaster disable as we might need to * access HPET ! @@ -1552,6 +1564,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, /* TSC could halt in idle, so notify users */ mark_tsc_unstable("TSC halts in idle"); #endif + sleep_ticks = ticks_elapsed(t1, t2); + /* Tell the scheduler how much we idled: */ + sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); local_irq_enable(); current_thread_info()->status |= TS_POLLING; @@ -1559,7 +1574,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, cx->usage++; acpi_state_timer_broadcast(pr, cx, 0); - cx->time += ticks_elapsed(t1, t2); + cx->time += sleep_ticks; return ticks_elapsed_in_us(t1, t2); } -- cgit v1.2.3 From ddc081a19585c8ba5aad437779950c2ef215360a Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Mon, 19 Nov 2007 21:43:22 -0500 Subject: cpuidle: fix HP nx6125 regression Fix for http://bugzilla.kernel.org/show_bug.cgi?id=9355 cpuidle always used to fallback to C2 if there is some bm activity while entering C3. But, presence of C2 is not always guaranteed. Change cpuidle algorithm to detect a safe_state to fallback in case of bm_activity and use that state instead of C2. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 125 +++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 70 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 1af0694e852..8904f5c82a1 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -197,6 +197,19 @@ static inline u32 ticks_elapsed_in_us(u32 t1, u32 t2) return PM_TIMER_TICKS_TO_US((0xFFFFFFFF - t1) + t2); } +static void acpi_safe_halt(void) +{ + current_thread_info()->status &= ~TS_POLLING; + /* + * TS_POLLING-cleared state must be visible before we + * test NEED_RESCHED: + */ + smp_mb(); + if (!need_resched()) + safe_halt(); + current_thread_info()->status |= TS_POLLING; +} + #ifndef CONFIG_CPU_IDLE static void @@ -239,19 +252,6 @@ acpi_processor_power_activate(struct acpi_processor *pr, return; } -static void acpi_safe_halt(void) -{ - current_thread_info()->status &= ~TS_POLLING; - /* - * TS_POLLING-cleared state must be visible before we - * test NEED_RESCHED: - */ - smp_mb(); - if (!need_resched()) - safe_halt(); - current_thread_info()->status |= TS_POLLING; -} - static atomic_t c3_cpu_count; /* Common C-state entry for C2, C3, .. */ @@ -1385,15 +1385,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, if (pr->flags.bm_check) acpi_idle_update_bm_rld(pr, cx); - current_thread_info()->status &= ~TS_POLLING; - /* - * TS_POLLING-cleared state must be visible before we test - * NEED_RESCHED: - */ - smp_mb(); - if (!need_resched()) - safe_halt(); - current_thread_info()->status |= TS_POLLING; + acpi_safe_halt(); cx->usage++; @@ -1493,6 +1485,15 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, if (acpi_idle_suspend) return(acpi_idle_enter_c1(dev, state)); + if (acpi_idle_bm_check()) { + if (dev->safe_state) { + return dev->safe_state->enter(dev, dev->safe_state); + } else { + acpi_safe_halt(); + return 0; + } + } + local_irq_disable(); current_thread_info()->status &= ~TS_POLLING; /* @@ -1515,49 +1516,39 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, */ acpi_state_timer_broadcast(pr, cx, 1); - if (acpi_idle_bm_check()) { - cx = pr->power.bm_state; - - acpi_idle_update_bm_rld(pr, cx); - - t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); - acpi_idle_do_entry(cx); - t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); - } else { - acpi_idle_update_bm_rld(pr, cx); + acpi_idle_update_bm_rld(pr, cx); - /* - * disable bus master - * bm_check implies we need ARB_DIS - * !bm_check implies we need cache flush - * bm_control implies whether we can do ARB_DIS - * - * That leaves a case where bm_check is set and bm_control is - * not set. In that case we cannot do much, we enter C3 - * without doing anything. - */ - if (pr->flags.bm_check && pr->flags.bm_control) { - spin_lock(&c3_lock); - c3_cpu_count++; - /* Disable bus master arbitration when all CPUs are in C3 */ - if (c3_cpu_count == num_online_cpus()) - acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); - spin_unlock(&c3_lock); - } else if (!pr->flags.bm_check) { - ACPI_FLUSH_CPU_CACHE(); - } + /* + * disable bus master + * bm_check implies we need ARB_DIS + * !bm_check implies we need cache flush + * bm_control implies whether we can do ARB_DIS + * + * That leaves a case where bm_check is set and bm_control is + * not set. In that case we cannot do much, we enter C3 + * without doing anything. + */ + if (pr->flags.bm_check && pr->flags.bm_control) { + spin_lock(&c3_lock); + c3_cpu_count++; + /* Disable bus master arbitration when all CPUs are in C3 */ + if (c3_cpu_count == num_online_cpus()) + acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); + spin_unlock(&c3_lock); + } else if (!pr->flags.bm_check) { + ACPI_FLUSH_CPU_CACHE(); + } - t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); - acpi_idle_do_entry(cx); - t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); + t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); + acpi_idle_do_entry(cx); + t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); - /* Re-enable bus master arbitration */ - if (pr->flags.bm_check && pr->flags.bm_control) { - spin_lock(&c3_lock); - acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); - c3_cpu_count--; - spin_unlock(&c3_lock); - } + /* Re-enable bus master arbitration */ + if (pr->flags.bm_check && pr->flags.bm_control) { + spin_lock(&c3_lock); + acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); + c3_cpu_count--; + spin_unlock(&c3_lock); } #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) @@ -1626,12 +1617,14 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) case ACPI_STATE_C1: state->flags |= CPUIDLE_FLAG_SHALLOW; state->enter = acpi_idle_enter_c1; + dev->safe_state = state; break; case ACPI_STATE_C2: state->flags |= CPUIDLE_FLAG_BALANCED; state->flags |= CPUIDLE_FLAG_TIME_VALID; state->enter = acpi_idle_enter_simple; + dev->safe_state = state; break; case ACPI_STATE_C3: @@ -1652,14 +1645,6 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) if (!count) return -EINVAL; - /* find the deepest state that can handle active BM */ - if (pr->flags.bm_check) { - for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) - if (pr->power.states[i].type == ACPI_STATE_C3) - break; - pr->power.bm_state = &pr->power.states[i-1]; - } - return 0; } -- cgit v1.2.3 From 4fdb2a05ef5703553fdd28f1b96ebdd79f173657 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 19 Nov 2007 17:48:02 -0800 Subject: ACPI: Add missing spaces to printk format Signed-off-by: Joe Perches Signed-off-by: Len Brown --- drivers/acpi/ec.c | 4 ++-- drivers/acpi/processor_core.c | 2 +- drivers/acpi/tables/tbutils.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 06b78e5e33a..cb09e5e0340 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -175,12 +175,12 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) if (acpi_ec_check_status(ec, event)) { if (event == ACPI_EC_EVENT_OBF_1) { /* miss OBF = 1 GPE, don't expect it anymore */ - printk(KERN_INFO PREFIX "missing OBF_1 confirmation," + printk(KERN_INFO PREFIX "missing OBF_1 confirmation, " "switching to degraded mode.\n"); set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); } else { /* missing GPEs, switch back to poll mode */ - printk(KERN_INFO PREFIX "missing IBF_1 confirmations," + printk(KERN_INFO PREFIX "missing IBF_1 confirmations, " "switch off interrupt mode.\n"); clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); } diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 235a51e328c..44156e73de6 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -647,7 +647,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) */ if (processor_device_array[pr->id] != NULL && processor_device_array[pr->id] != device) { - printk(KERN_WARNING "BIOS reported wrong ACPI id" + printk(KERN_WARNING "BIOS reported wrong ACPI id " "for the processor\n"); return -ENODEV; } diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 5f1d85f2ffe..010f19652f8 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -449,7 +449,7 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags) /* XSDT has NULL entry, RSDT is used */ address = rsdt_address; table_entry_size = sizeof(u32); - ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry," + ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, " "using RSDT")); } } -- cgit v1.2.3 From 61fd47e0c84764f49b4e52bfd8170fac52636f00 Mon Sep 17 00:00:00 2001 From: Shaohua Li Date: Sat, 17 Nov 2007 01:05:28 -0500 Subject: ACPI: fix two IRQ8 issues in IOAPIC mode Use mp_irqs[] to get PNP device's interrupt polarity and trigger. There are two reasons to do this: 1. BIOS bug for PNP interrupt 2. BIOS explictly does override mp_irqs[] should cover all the cases. http://bugzilla.kernel.org/show_bug.cgi?id=5243 http://bugzilla.kernel.org/show_bug.cgi?id=7679 http://bugzilla.kernel.org/show_bug.cgi?id=9153 [lenb: fixed !IOAPIC and 64-bit !SMP builds] Signed-off-by: Shaohua Li Signed-off-by: Len Brown --- drivers/pnp/pnpacpi/rsparser.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'drivers') diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 0e3b8d0ff06..11adab13f2b 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -75,6 +75,7 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, { int i = 0; int irq; + int p, t; if (!valid_IRQ(gsi)) return; @@ -85,6 +86,23 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, if (i >= PNP_MAX_IRQ) return; + /* + * in IO-APIC mode, use overrided attribute. Two reasons: + * 1. BIOS bug in DSDT + * 2. BIOS uses IO-APIC mode Interrupt Source Override + */ + if (!acpi_get_override_irq(gsi, &t, &p)) { + t = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; + p = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; + + if (triggering != t || polarity != p) { + pnp_warn("IRQ %d override to %s, %s", + gsi, t ? "edge":"level", p ? "low":"high"); + triggering = t; + polarity = p; + } + } + res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag res->irq_resource[i].flags |= irq_flags(triggering, polarity); irq = acpi_register_gsi(gsi, triggering, polarity); -- cgit v1.2.3 From 3b8c88993e3709b4d44f7ca4e886044a49605394 Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Tue, 20 Nov 2007 11:13:30 +0100 Subject: [S390] cio: change device sense procedure to work with pav aliases Modify the sense id channel program to allow device sensing of pav alias devices which belong to a base device with ungrouped paths. Signed-off-by: Peter Oberparleiter Signed-off-by: Martin Schwidefsky --- drivers/s390/cio/device_id.c | 45 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 36 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c index f232832f2b2..2f6bf462425 100644 --- a/drivers/s390/cio/device_id.c +++ b/drivers/s390/cio/device_id.c @@ -113,19 +113,10 @@ __ccw_device_sense_id_start(struct ccw_device *cdev) { struct subchannel *sch; struct ccw1 *ccw; - int ret; sch = to_subchannel(cdev->dev.parent); /* Setup sense channel program. */ ccw = cdev->private->iccws; - if (sch->schib.pmcw.pim != 0x80) { - /* more than one path installed. */ - ccw->cmd_code = CCW_CMD_SUSPEND_RECONN; - ccw->cda = 0; - ccw->count = 0; - ccw->flags = CCW_FLAG_SLI | CCW_FLAG_CC; - ccw++; - } ccw->cmd_code = CCW_CMD_SENSE_ID; ccw->cda = (__u32) __pa (&cdev->private->senseid); ccw->count = sizeof (struct senseid); @@ -133,25 +124,9 @@ __ccw_device_sense_id_start(struct ccw_device *cdev) /* Reset device status. */ memset(&cdev->private->irb, 0, sizeof(struct irb)); + cdev->private->flags.intretry = 0; - /* Try on every path. */ - ret = -ENODEV; - while (cdev->private->imask != 0) { - if ((sch->opm & cdev->private->imask) != 0 && - cdev->private->iretry > 0) { - cdev->private->iretry--; - /* Reset internal retry indication. */ - cdev->private->flags.intretry = 0; - ret = cio_start (sch, cdev->private->iccws, - cdev->private->imask); - /* ret is 0, -EBUSY, -EACCES or -ENODEV */ - if (ret != -EACCES) - return ret; - } - cdev->private->imask >>= 1; - cdev->private->iretry = 5; - } - return ret; + return cio_start(sch, ccw, LPM_ANYPATH); } void @@ -161,8 +136,7 @@ ccw_device_sense_id_start(struct ccw_device *cdev) memset (&cdev->private->senseid, 0, sizeof (struct senseid)); cdev->private->senseid.cu_type = 0xFFFF; - cdev->private->imask = 0x80; - cdev->private->iretry = 5; + cdev->private->iretry = 3; ret = __ccw_device_sense_id_start(cdev); if (ret && ret != -EBUSY) ccw_device_sense_id_done(cdev, ret); @@ -278,14 +252,13 @@ ccw_device_sense_id_irq(struct ccw_device *cdev, enum dev_event dev_event) ccw_device_sense_id_done(cdev, ret); break; case -EACCES: /* channel is not operational. */ - sch->lpm &= ~cdev->private->imask; - cdev->private->imask >>= 1; - cdev->private->iretry = 5; - /* fall through. */ case -EAGAIN: /* try again. */ - ret = __ccw_device_sense_id_start(cdev); - if (ret == 0 || ret == -EBUSY) - break; + cdev->private->iretry--; + if (cdev->private->iretry > 0) { + ret = __ccw_device_sense_id_start(cdev); + if (ret == 0 || ret == -EBUSY) + break; + } /* fall through. */ default: /* Sense ID failed. Try asking VM. */ if (MACHINE_IS_VM) { -- cgit v1.2.3 From c5d4a9997b4b2ec71cff0b219f05c6bc51f3fc79 Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Tue, 20 Nov 2007 11:13:41 +0100 Subject: [S390] cio: Register/unregister subchannels only from kslowcrw. Make sure all subchannel handling is done on the slow path workqueue so that we don't have races between an old subchannel unregistering and a new subchannel with the same name registering. Signed-off-by: Cornelia Huck Signed-off-by: Martin Schwidefsky --- drivers/s390/cio/css.c | 2 +- drivers/s390/cio/device_fsm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 838f7ac0dc3..6db31089d2d 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -483,7 +483,7 @@ static DECLARE_WORK(css_reprobe_work, reprobe_all); void css_schedule_reprobe(void) { need_reprobe = 1; - queue_work(ccw_device_work, &css_reprobe_work); + queue_work(slow_path_wq, &css_reprobe_work); } EXPORT_SYMBOL_GPL(css_schedule_reprobe); diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c index 8867443b806..bfad421cda6 100644 --- a/drivers/s390/cio/device_fsm.c +++ b/drivers/s390/cio/device_fsm.c @@ -1034,7 +1034,7 @@ device_trigger_reprobe(struct subchannel *sch) if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) { PREPARE_WORK(&cdev->private->kick_work, ccw_device_move_to_orphanage); - queue_work(ccw_device_work, &cdev->private->kick_work); + queue_work(slow_path_wq, &cdev->private->kick_work); } else ccw_device_start_id(cdev, 0); } -- cgit v1.2.3 From fb74dacb0f00dff851c78411773a5bd5d7128b81 Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Tue, 6 Nov 2007 17:51:38 -0800 Subject: IB/ipath: Fix offset returned to ibv_resize_cq() The wrong offset was being returned to libipathverbs so that when ibv_resize_cq() calls mmap(), it always fails. Signed-off-by: Ralph Campbell Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ipath/ipath_cq.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/hw/ipath/ipath_cq.c b/drivers/infiniband/hw/ipath/ipath_cq.c index 08d8ae148cd..d1380c7a170 100644 --- a/drivers/infiniband/hw/ipath/ipath_cq.c +++ b/drivers/infiniband/hw/ipath/ipath_cq.c @@ -395,12 +395,9 @@ int ipath_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata) goto bail; } - /* - * Return the address of the WC as the offset to mmap. - * See ipath_mmap() for details. - */ + /* Check that we can write the offset to mmap. */ if (udata && udata->outlen >= sizeof(__u64)) { - __u64 offset = (__u64) wc; + __u64 offset = 0; ret = ib_copy_to_udata(udata, &offset, sizeof(offset)); if (ret) @@ -450,6 +447,18 @@ int ipath_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata) struct ipath_mmap_info *ip = cq->ip; ipath_update_mmap_info(dev, ip, sz, wc); + + /* + * Return the offset to mmap. + * See ipath_mmap() for details. + */ + if (udata && udata->outlen >= sizeof(__u64)) { + ret = ib_copy_to_udata(udata, &ip->offset, + sizeof(ip->offset)); + if (ret) + goto bail; + } + spin_lock_irq(&dev->pending_lock); if (list_empty(&ip->pending_mmaps)) list_add(&ip->pending_mmaps, &dev->pending_mmaps); -- cgit v1.2.3 From 8a278e6d571ebe10b96f2b53c74f01fd0a3f005a Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Wed, 14 Nov 2007 12:09:05 -0800 Subject: IB/ipath: Fix error path in QP creation This patch fixes the code which frees the partially allocated QP resources if there was an error while creating the QP. In particular, the QPN wasn't deallocated and the QP wasn't removed from the hash table. Signed-off-by: Ralph Campbell Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ipath/ipath_qp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c index 6a41fdbc8e5..b997ff88401 100644 --- a/drivers/infiniband/hw/ipath/ipath_qp.c +++ b/drivers/infiniband/hw/ipath/ipath_qp.c @@ -835,7 +835,8 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, init_attr->qp_type); if (err) { ret = ERR_PTR(err); - goto bail_rwq; + vfree(qp->r_rq.wq); + goto bail_qp; } qp->ip = NULL; ipath_reset_qp(qp); @@ -863,7 +864,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, sizeof(offset)); if (err) { ret = ERR_PTR(err); - goto bail_rwq; + goto bail_ip; } } else { u32 s = sizeof(struct ipath_rwq) + @@ -875,7 +876,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, qp->r_rq.wq); if (!qp->ip) { ret = ERR_PTR(-ENOMEM); - goto bail_rwq; + goto bail_ip; } err = ib_copy_to_udata(udata, &(qp->ip->offset), @@ -907,9 +908,11 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, goto bail; bail_ip: - kfree(qp->ip); -bail_rwq: - vfree(qp->r_rq.wq); + if (qp->ip) + kref_put(&qp->ip->ref, ipath_release_mmap_info); + else + vfree(qp->r_rq.wq); + ipath_free_qp(&dev->qp_table, qp); bail_qp: kfree(qp); bail_swq: -- cgit v1.2.3 From 14de986a0ba560b54340fd277a3579e95a2d3838 Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Fri, 9 Nov 2007 15:22:31 -0800 Subject: IB/ipath: Fix offset returned to ibv_modify_srq() The wrong offset was being returned to libipathverbs so that when ibv_modify_srq() calls mmap(), it always fails. Signed-off-by: Ralph Campbell Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ipath/ipath_srq.c | 42 ++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/hw/ipath/ipath_srq.c b/drivers/infiniband/hw/ipath/ipath_srq.c index 40c36ec1901..434da6270f6 100644 --- a/drivers/infiniband/hw/ipath/ipath_srq.c +++ b/drivers/infiniband/hw/ipath/ipath_srq.c @@ -211,11 +211,11 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, struct ib_udata *udata) { struct ipath_srq *srq = to_isrq(ibsrq); + struct ipath_rwq *wq; int ret = 0; if (attr_mask & IB_SRQ_MAX_WR) { struct ipath_rwq *owq; - struct ipath_rwq *wq; struct ipath_rwqe *p; u32 sz, size, n, head, tail; @@ -236,27 +236,20 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, goto bail; } - /* - * Return the address of the RWQ as the offset to mmap. - * See ipath_mmap() for details. - */ + /* Check that we can write the offset to mmap. */ if (udata && udata->inlen >= sizeof(__u64)) { __u64 offset_addr; - __u64 offset = (__u64) wq; + __u64 offset = 0; ret = ib_copy_from_udata(&offset_addr, udata, sizeof(offset_addr)); - if (ret) { - vfree(wq); - goto bail; - } + if (ret) + goto bail_free; udata->outbuf = (void __user *) offset_addr; ret = ib_copy_to_udata(udata, &offset, sizeof(offset)); - if (ret) { - vfree(wq); - goto bail; - } + if (ret) + goto bail_free; } spin_lock_irq(&srq->rq.lock); @@ -277,10 +270,8 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, else n -= tail; if (size <= n) { - spin_unlock_irq(&srq->rq.lock); - vfree(wq); ret = -EINVAL; - goto bail; + goto bail_unlock; } n = 0; p = wq->wq; @@ -314,6 +305,18 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, u32 s = sizeof(struct ipath_rwq) + size * sz; ipath_update_mmap_info(dev, ip, s, wq); + + /* + * Return the offset to mmap. + * See ipath_mmap() for details. + */ + if (udata && udata->inlen >= sizeof(__u64)) { + ret = ib_copy_to_udata(udata, &ip->offset, + sizeof(ip->offset)); + if (ret) + goto bail; + } + spin_lock_irq(&dev->pending_lock); if (list_empty(&ip->pending_mmaps)) list_add(&ip->pending_mmaps, @@ -328,7 +331,12 @@ int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, srq->limit = attr->srq_limit; spin_unlock_irq(&srq->rq.lock); } + goto bail; +bail_unlock: + spin_unlock_irq(&srq->rq.lock); +bail_free: + vfree(wq); bail: return ret; } -- cgit v1.2.3 From 4187b915a0f7eaa69707715e80d9fc253ff6167a Mon Sep 17 00:00:00 2001 From: Ralph Campbell Date: Wed, 14 Nov 2007 13:34:14 -0800 Subject: IB/ipath: Normalize error return codes for posting work requests The error codes for ib_post_send(), ib_post_recv(), and ib_post_srq_recv() were inconsistent. Use EINVAL for too many SGEs and ENOMEM for too many WRs. Signed-off-by: Ralph Campbell Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ipath/ipath_srq.c | 2 +- drivers/infiniband/hw/ipath/ipath_verbs.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/hw/ipath/ipath_srq.c b/drivers/infiniband/hw/ipath/ipath_srq.c index 434da6270f6..2fef36f4b67 100644 --- a/drivers/infiniband/hw/ipath/ipath_srq.c +++ b/drivers/infiniband/hw/ipath/ipath_srq.c @@ -59,7 +59,7 @@ int ipath_post_srq_receive(struct ib_srq *ibsrq, struct ib_recv_wr *wr, if ((unsigned) wr->num_sge > srq->rq.max_sge) { *bad_wr = wr; - ret = -ENOMEM; + ret = -EINVAL; goto bail; } diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c index 74f77e7c2c1..c4c998446c7 100644 --- a/drivers/infiniband/hw/ipath/ipath_verbs.c +++ b/drivers/infiniband/hw/ipath/ipath_verbs.c @@ -302,8 +302,10 @@ static int ipath_post_one_send(struct ipath_qp *qp, struct ib_send_wr *wr) next = qp->s_head + 1; if (next >= qp->s_size) next = 0; - if (next == qp->s_last) - goto bail_inval; + if (next == qp->s_last) { + ret = -ENOMEM; + goto bail; + } wqe = get_swqe_ptr(qp, qp->s_head); wqe->wr = *wr; @@ -404,7 +406,7 @@ static int ipath_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, if ((unsigned) wr->num_sge > qp->r_rq.max_sge) { *bad_wr = wr; - ret = -ENOMEM; + ret = -EINVAL; goto bail; } -- cgit v1.2.3 From 9ed87fd34c97a998e63505718ce7e107a23c84c3 Mon Sep 17 00:00:00 2001 From: Jack Morgenstein Date: Tue, 20 Nov 2007 13:01:28 -0800 Subject: mlx4_core: Fix state check in mlx4_qp_modify() When checking the states passed in, mlx4_qp_modify() accidentally checks cur_state twice rather than checking cur_state and new_state. Fix this to make sure that both values are in-bounds. Since these values may be passed in from userspace, this bug results in userspace being able to trigger an oops. Signed-off-by: Jack Morgenstein Cc: stable Signed-off-by: Roland Dreier --- drivers/net/mlx4/qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/mlx4/qp.c b/drivers/net/mlx4/qp.c index 42b47639c81..fa24e659759 100644 --- a/drivers/net/mlx4/qp.c +++ b/drivers/net/mlx4/qp.c @@ -113,7 +113,7 @@ int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt, struct mlx4_cmd_mailbox *mailbox; int ret = 0; - if (cur_state >= MLX4_QP_NUM_STATE || cur_state >= MLX4_QP_NUM_STATE || + if (cur_state >= MLX4_QP_NUM_STATE || new_state >= MLX4_QP_NUM_STATE || !op[cur_state][new_state]) return -EINVAL; -- cgit v1.2.3 From 0af2f653c504d302d83d3a648c0408882ff62d4c Mon Sep 17 00:00:00 2001 From: Len Brown Date: Tue, 20 Nov 2007 19:59:08 -0500 Subject: Revert "ACPI: EC: Workaround for optimized controllers" This reverts commit f2d68935ba08cf80f151bbdb5628381184e4a498. --- drivers/acpi/ec.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 390f8f8666d..06b78e5e33a 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -75,8 +75,7 @@ enum { EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ EC_FLAGS_QUERY_PENDING, /* Query is pending */ EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ - EC_FLAGS_NO_ADDRESS_GPE, /* Expect GPE only for non-address event */ - EC_FLAGS_ADDRESS, /* Address is being written */ + EC_FLAGS_ONLY_IBF_GPE, /* Expect GPE only for IBF = 0 event */ }; static int acpi_ec_remove(struct acpi_device *device, int type); @@ -167,45 +166,38 @@ static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) { - int ret = 0; - if (unlikely(test_bit(EC_FLAGS_ADDRESS, &ec->flags) && - test_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags))) - force_poll = 1; if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && likely(!force_poll)) { if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), msecs_to_jiffies(ACPI_EC_DELAY))) - goto end; + return 0; clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); if (acpi_ec_check_status(ec, event)) { - if (test_bit(EC_FLAGS_ADDRESS, &ec->flags)) { - /* miss address GPE, don't expect it anymore */ - printk(KERN_INFO PREFIX "missing address confirmation," - "don't expect it any longer.\n"); - set_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags); + if (event == ACPI_EC_EVENT_OBF_1) { + /* miss OBF = 1 GPE, don't expect it anymore */ + printk(KERN_INFO PREFIX "missing OBF_1 confirmation," + "switching to degraded mode.\n"); + set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); } else { /* missing GPEs, switch back to poll mode */ - printk(KERN_INFO PREFIX "missing confirmations," + printk(KERN_INFO PREFIX "missing IBF_1 confirmations," "switch off interrupt mode.\n"); clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); } - goto end; + return 0; } } else { unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); while (time_before(jiffies, delay)) { if (acpi_ec_check_status(ec, event)) - goto end; + return 0; } } printk(KERN_ERR PREFIX "acpi_ec_wait timeout," " status = %d, expect_event = %d\n", acpi_ec_read_status(ec), event); - ret = -ETIME; - end: - clear_bit(EC_FLAGS_ADDRESS, &ec->flags); - return ret; + return -ETIME; } static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, @@ -224,9 +216,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, "write_cmd timeout, command = %d\n", command); goto end; } - /* mark the address byte written to EC */ - if (rdata_len + wdata_len > 1) - set_bit(EC_FLAGS_ADDRESS, &ec->flags); set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); acpi_ec_write_data(ec, *(wdata++)); } @@ -242,6 +231,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); for (; rdata_len > 0; --rdata_len) { + if (test_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags)) + force_poll = 1; result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); if (result) { printk(KERN_ERR PREFIX "read timeout, command = %d\n", -- cgit v1.2.3 From 3ebe08a749a0971a5407818169dc16212ef562f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20N=C3=A9meth?= Date: Wed, 21 Nov 2007 03:23:26 +0300 Subject: ACPI: EC: use printk_ratelimit(), add some DEBUG mode messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes it is usefull to see raw protocol dump. Uncomment '#define DEBUG' at the beginning of file to make EC really verbose. Signed-off-by: Márton Németh Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/ec.c | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 06b78e5e33a..d5a5958d4b2 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -47,6 +47,9 @@ #undef PREFIX #define PREFIX "ACPI: EC: " +/* Uncomment next line to get verbose print outs*/ +/* #define DEBUG */ + /* EC status register */ #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ @@ -131,21 +134,27 @@ static struct acpi_ec { static inline u8 acpi_ec_read_status(struct acpi_ec *ec) { - return inb(ec->command_addr); + u8 x = inb(ec->command_addr); + pr_debug(PREFIX "---> status = 0x%2x\n", x); + return x; } static inline u8 acpi_ec_read_data(struct acpi_ec *ec) { + u8 x = inb(ec->data_addr); + pr_debug(PREFIX "---> data = 0x%2x\n", x); return inb(ec->data_addr); } static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) { + pr_debug(PREFIX "<--- command = 0x%2x\n", command); outb(command, ec->command_addr); } static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) { + pr_debug(PREFIX "<--- data = 0x%2x\n", data); outb(data, ec->data_addr); } @@ -175,13 +184,14 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) if (acpi_ec_check_status(ec, event)) { if (event == ACPI_EC_EVENT_OBF_1) { /* miss OBF = 1 GPE, don't expect it anymore */ - printk(KERN_INFO PREFIX "missing OBF_1 confirmation," + pr_info(PREFIX "missing OBF_1 confirmation," "switching to degraded mode.\n"); set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); } else { /* missing GPEs, switch back to poll mode */ - printk(KERN_INFO PREFIX "missing IBF_1 confirmations," - "switch off interrupt mode.\n"); + if (printk_ratelimit()) + pr_info(PREFIX "missing IBF_1 confirmations," + "switch off interrupt mode.\n"); clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); } return 0; @@ -194,7 +204,7 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) return 0; } } - printk(KERN_ERR PREFIX "acpi_ec_wait timeout," + pr_err(PREFIX "acpi_ec_wait timeout," " status = %d, expect_event = %d\n", acpi_ec_read_status(ec), event); return -ETIME; @@ -208,11 +218,11 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, int result = 0; set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); acpi_ec_write_cmd(ec, command); - + pr_debug(PREFIX "transaction start\n"); for (; wdata_len > 0; --wdata_len) { result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); if (result) { - printk(KERN_ERR PREFIX + pr_err(PREFIX "write_cmd timeout, command = %d\n", command); goto end; } @@ -223,7 +233,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, if (!rdata_len) { result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); if (result) { - printk(KERN_ERR PREFIX + pr_err(PREFIX "finish-write timeout, command = %d\n", command); goto end; } @@ -235,8 +245,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, force_poll = 1; result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); if (result) { - printk(KERN_ERR PREFIX "read timeout, command = %d\n", - command); + pr_err(PREFIX "read timeout, command = %d\n", command); goto end; } /* Don't expect GPE after last read */ @@ -245,6 +254,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, *(rdata++) = acpi_ec_read_data(ec); } end: + pr_debug(PREFIX "transaction end\n"); return result; } @@ -273,8 +283,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); if (status) { - printk(KERN_ERR PREFIX - "input buffer is not empty, aborting transaction\n"); + pr_err(PREFIX "input buffer is not empty, " + "aborting transaction\n"); goto end; } @@ -488,6 +498,7 @@ static u32 acpi_ec_gpe_handler(void *data) acpi_status status = AE_OK; struct acpi_ec *ec = data; + pr_debug(PREFIX "~~~> interrupt\n"); clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) wake_up(&ec->wait); @@ -498,8 +509,9 @@ static u32 acpi_ec_gpe_handler(void *data) acpi_ec_gpe_query, ec); } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) { /* this is non-query, must be confirmation */ - printk(KERN_INFO PREFIX "non-query interrupt received," - " switching to interrupt mode\n"); + if (printk_ratelimit()) + pr_info(PREFIX "non-query interrupt received," + " switching to interrupt mode\n"); set_bit(EC_FLAGS_GPE_MODE, &ec->flags); } @@ -701,10 +713,10 @@ static void ec_remove_handlers(struct acpi_ec *ec) { if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) - printk(KERN_ERR PREFIX "failed to remove space handler\n"); + pr_err(PREFIX "failed to remove space handler\n"); if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler))) - printk(KERN_ERR PREFIX "failed to remove gpe handler\n"); + pr_err(PREFIX "failed to remove gpe handler\n"); ec->handlers_installed = 0; } @@ -747,9 +759,9 @@ static int acpi_ec_add(struct acpi_device *device) first_ec = ec; acpi_driver_data(device) = ec; acpi_ec_add_fs(device); - printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", + pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", ec->gpe, ec->command_addr, ec->data_addr); - printk(KERN_INFO PREFIX "driver started in %s mode\n", + pr_info(PREFIX "driver started in %s mode\n", (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll"); return 0; } @@ -875,7 +887,7 @@ int __init acpi_ec_ecdt_probe(void) status = acpi_get_table(ACPI_SIG_ECDT, 1, (struct acpi_table_header **)&ecdt_ptr); if (ACPI_SUCCESS(status)) { - printk(KERN_INFO PREFIX "EC description table is found, configuring boot EC\n"); + pr_info(PREFIX "EC description table is found, configuring boot EC\n"); boot_ec->command_addr = ecdt_ptr->control.address; boot_ec->data_addr = ecdt_ptr->data.address; boot_ec->gpe = ecdt_ptr->gpe; -- cgit v1.2.3 From e790cc8bbb990df900eabdda18a5a480d22a60c8 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Wed, 21 Nov 2007 03:23:32 +0300 Subject: ACPI: EC: Workaround for optimized controllers (version 3) Some controllers fail to send confirmation GPE after address or data write. Detect this and don't expect such confirmation in future. This is a generalization of previous workaround (66c5f4e7367b0085652931b2f3366de29e7ff5ec), which did only read address. Reference: http://bugzilla.kernel.org/show_bug.cgi?id=9327 Signed-off-by: Alexey Starikovskiy Tested-by: Romano Giannetti Tested-by: Mats Johannesson Signed-off-by: Len Brown --- drivers/acpi/ec.c | 46 +++++++++++++++++++++++++++++++------------ drivers/acpi/processor_core.c | 5 ++++- 2 files changed, 37 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index d5a5958d4b2..7d6b8411979 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -78,7 +78,10 @@ enum { EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ EC_FLAGS_QUERY_PENDING, /* Query is pending */ EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ - EC_FLAGS_ONLY_IBF_GPE, /* Expect GPE only for IBF = 0 event */ + EC_FLAGS_NO_ADDRESS_GPE, /* Expect GPE only for non-address event */ + EC_FLAGS_ADDRESS, /* Address is being written */ + EC_FLAGS_NO_WDATA_GPE, /* Don't expect WDATA GPE event */ + EC_FLAGS_WDATA, /* Data is being written */ }; static int acpi_ec_remove(struct acpi_device *device, int type); @@ -175,39 +178,54 @@ static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) { + int ret = 0; + if (unlikely(test_bit(EC_FLAGS_ADDRESS, &ec->flags) && + test_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags))) + force_poll = 1; + if (unlikely(test_bit(EC_FLAGS_WDATA, &ec->flags) && + test_bit(EC_FLAGS_NO_WDATA_GPE, &ec->flags))) + force_poll = 1; if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && likely(!force_poll)) { if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), msecs_to_jiffies(ACPI_EC_DELAY))) - return 0; + goto end; clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); if (acpi_ec_check_status(ec, event)) { - if (event == ACPI_EC_EVENT_OBF_1) { - /* miss OBF = 1 GPE, don't expect it anymore */ - pr_info(PREFIX "missing OBF_1 confirmation," - "switching to degraded mode.\n"); - set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); + if (test_bit(EC_FLAGS_ADDRESS, &ec->flags)) { + /* miss address GPE, don't expect it anymore */ + pr_info(PREFIX "missing address confirmation, " + "don't expect it any longer.\n"); + set_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags); + } else if (test_bit(EC_FLAGS_WDATA, &ec->flags)) { + /* miss write data GPE, don't expect it */ + pr_info(PREFIX "missing write data confirmation, " + "don't expect it any longer.\n"); + set_bit(EC_FLAGS_NO_WDATA_GPE, &ec->flags); } else { /* missing GPEs, switch back to poll mode */ if (printk_ratelimit()) - pr_info(PREFIX "missing IBF_1 confirmations," + pr_info(PREFIX "missing confirmations, " "switch off interrupt mode.\n"); clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); } - return 0; + goto end; } } else { unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); while (time_before(jiffies, delay)) { if (acpi_ec_check_status(ec, event)) - return 0; + goto end; } } pr_err(PREFIX "acpi_ec_wait timeout," " status = %d, expect_event = %d\n", acpi_ec_read_status(ec), event); - return -ETIME; + ret = -ETIME; + end: + clear_bit(EC_FLAGS_ADDRESS, &ec->flags); + return ret; } static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, @@ -226,11 +244,15 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, "write_cmd timeout, command = %d\n", command); goto end; } + /* mark the address byte written to EC */ + if (rdata_len + wdata_len > 1) + set_bit(EC_FLAGS_ADDRESS, &ec->flags); set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); acpi_ec_write_data(ec, *(wdata++)); } if (!rdata_len) { + set_bit(EC_FLAGS_WDATA, &ec->flags); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); if (result) { pr_err(PREFIX @@ -241,8 +263,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); for (; rdata_len > 0; --rdata_len) { - if (test_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags)) - force_poll = 1; result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); if (result) { pr_err(PREFIX "read timeout, command = %d\n", command); diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 235a51e328c..692b2a0a05b 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -684,7 +684,7 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) { struct acpi_processor *pr = data; struct acpi_device *device = NULL; - + int saved; if (!pr) return; @@ -694,7 +694,10 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) switch (event) { case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: + saved = pr->performance_platform_limit; acpi_processor_ppc_has_changed(pr); + if (saved == pr->performance_platform_limit) + break; acpi_bus_generate_proc_event(device, event, pr->performance_platform_limit); acpi_bus_generate_netlink_event(device->pnp.device_class, -- cgit v1.2.3 From d198f101989d9bb950327f0d043f6203bb862343 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 2 Nov 2007 18:21:13 +0100 Subject: mmc_block: check card state after write Some cards have been reported to signal that they're ready prematurely. Checking both the busy bit and card state solves the issue. Signed-off-by: Pierre Ossman --- drivers/mmc/card/block.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index e38d5a3b2a8..acaa05200ae 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -321,7 +321,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) req->rq_disk->disk_name, err); goto cmd_err; } - } while (!(cmd.resp[0] & R1_READY_FOR_DATA)); + /* + * Some cards mishandle the status bits, + * so make sure to check both the busy + * indication and the card state. + */ + } while (!(cmd.resp[0] & R1_READY_FOR_DATA) || + (R1_CURRENT_STATE(cmd.resp[0]) == 7)); #if 0 if (cmd.resp[0] & ~0x00000900) -- cgit v1.2.3 From b37a05069b9ab9fb1e52393a3448d710c50c54d5 Mon Sep 17 00:00:00 2001 From: Alex Dubov Date: Wed, 14 Nov 2007 23:55:36 +1100 Subject: tifm_sd: handle non-power-of-2 block sizes It is possible to handle arbitrary block sizes with tifm card reader by conditionally switching to PIO in case such block has to be delivered. At the beginning of each request, DMA is either disabled (non-power-of-2 block size) or set to load time user preference. Signed-off-by: Alex Dubov Signed-off-by: Pierre Ossman --- drivers/mmc/host/tifm_sd.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c index c11a3d25605..20d5c7bd940 100644 --- a/drivers/mmc/host/tifm_sd.c +++ b/drivers/mmc/host/tifm_sd.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #define DRIVER_NAME "tifm_sd" @@ -638,17 +637,15 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq) goto err_out; } - if (mrq->data && !is_power_of_2(mrq->data->blksz)) { - printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n", - sock->dev.bus_id, mrq->data->blksz); - mrq->cmd->error = -EINVAL; - goto err_out; - } - host->cmd_flags = 0; host->block_pos = 0; host->sg_pos = 0; + if (mrq->data && !is_power_of_2(mrq->data->blksz)) + host->no_dma = 1; + else + host->no_dma = no_dma ? 1 : 0; + if (r_data) { tifm_sd_set_data_timeout(host, r_data); @@ -676,7 +673,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq) : PCI_DMA_FROMDEVICE)) { printk(KERN_ERR "%s : scatterlist map failed\n", sock->dev.bus_id); - spin_unlock_irqrestore(&sock->lock, flags); + mrq->cmd->error = -ENOMEM; goto err_out; } host->sg_len = tifm_map_sg(sock, r_data->sg, @@ -692,7 +689,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq) r_data->flags & MMC_DATA_WRITE ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); - spin_unlock_irqrestore(&sock->lock, flags); + mrq->cmd->error = -ENOMEM; goto err_out; } @@ -966,7 +963,6 @@ static int tifm_sd_probe(struct tifm_dev *sock) return -ENOMEM; host = mmc_priv(mmc); - host->no_dma = no_dma; tifm_set_drvdata(sock, mmc); host->dev = sock; host->timeout_jiffies = msecs_to_jiffies(1000); -- cgit v1.2.3 From 1dff314451fa24d6b107aa05393d3169e56a7e0a Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 21 Nov 2007 18:45:12 +0100 Subject: mmc: Avoid re-using minor numbers before the original device is closed. Move the code which marks the minor number as free to mmc_blk_put() so that it happens on the final close() (or removal), instead of doing it at removal even when the device is still logically open. Signed-off-by: David Woodhouse Signed-off-by: Pierre Ossman --- drivers/mmc/card/block.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index acaa05200ae..aeb32a93f6a 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -44,6 +44,9 @@ * max 8 partitions per card */ #define MMC_SHIFT 3 +#define MMC_NUM_MINORS (256 >> MMC_SHIFT) + +static unsigned long dev_use[MMC_NUM_MINORS/(8*sizeof(unsigned long))]; /* * There is one mmc_blk_data per slot. @@ -80,6 +83,9 @@ static void mmc_blk_put(struct mmc_blk_data *md) mutex_lock(&open_lock); md->usage--; if (md->usage == 0) { + int devidx = md->disk->first_minor >> MMC_SHIFT; + __clear_bit(devidx, dev_use); + put_disk(md->disk); kfree(md); } @@ -406,9 +412,6 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) return 0; } -#define MMC_NUM_MINORS (256 >> MMC_SHIFT) - -static unsigned long dev_use[MMC_NUM_MINORS/(8*sizeof(unsigned long))]; static inline int mmc_blk_readonly(struct mmc_card *card) { @@ -574,17 +577,12 @@ static void mmc_blk_remove(struct mmc_card *card) struct mmc_blk_data *md = mmc_get_drvdata(card); if (md) { - int devidx; - /* Stop new requests from getting into the queue */ del_gendisk(md->disk); /* Then flush out any already in there */ mmc_cleanup_queue(&md->queue); - devidx = md->disk->first_minor >> MMC_SHIFT; - __clear_bit(devidx, dev_use); - mmc_blk_put(md); } mmc_set_drvdata(card, NULL); -- cgit v1.2.3 From 2e4d242ce71e82d931b4deb184ff9d96c9845ac1 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 21 Nov 2007 14:15:53 -0500 Subject: sony-laptop: fit input devices into sysfs tree Properly set up parent on input devices registered by sony-laptop. Signed-off-by: Dmitry Torokhov Acked-by: Mattia Dongili --- drivers/misc/sony-laptop.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c index bb13858f60a..b0f68031b49 100644 --- a/drivers/misc/sony-laptop.c +++ b/drivers/misc/sony-laptop.c @@ -338,7 +338,7 @@ static void sony_laptop_report_input_event(u8 event) dprintk("unknown input event %.2x\n", event); } -static int sony_laptop_setup_input(void) +static int sony_laptop_setup_input(struct acpi_device *acpi_device) { struct input_dev *jog_dev; struct input_dev *key_dev; @@ -379,6 +379,7 @@ static int sony_laptop_setup_input(void) key_dev->name = "Sony Vaio Keys"; key_dev->id.bustype = BUS_ISA; key_dev->id.vendor = PCI_VENDOR_ID_SONY; + key_dev->dev.parent = &acpi_device->dev; /* Initialize the Input Drivers: special keys */ set_bit(EV_KEY, key_dev->evbit); @@ -410,6 +411,7 @@ static int sony_laptop_setup_input(void) jog_dev->name = "Sony Vaio Jogdial"; jog_dev->id.bustype = BUS_ISA; jog_dev->id.vendor = PCI_VENDOR_ID_SONY; + key_dev->dev.parent = &acpi_device->dev; jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE); @@ -1006,7 +1008,7 @@ static int sony_nc_add(struct acpi_device *device) } /* setup input devices and helper fifo */ - result = sony_laptop_setup_input(); + result = sony_laptop_setup_input(device); if (result) { printk(KERN_ERR DRV_PFX "Unabe to create input devices.\n"); @@ -1034,7 +1036,7 @@ static int sony_nc_add(struct acpi_device *device) sony_backlight_device->props.brightness = sony_backlight_get_brightness (sony_backlight_device); - sony_backlight_device->props.max_brightness = + sony_backlight_device->props.max_brightness = SONY_MAX_BRIGHTNESS - 1; } @@ -2453,7 +2455,7 @@ static int sony_pic_add(struct acpi_device *device) } /* setup input devices and helper fifo */ - result = sony_laptop_setup_input(); + result = sony_laptop_setup_input(device); if (result) { printk(KERN_ERR DRV_PFX "Unabe to create input devices.\n"); -- cgit v1.2.3 From dcf65cd41c980278f98b6fc0d9da52747e7d058f Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 21 Nov 2007 14:16:16 -0500 Subject: sonypi: fit input devices into sysfs tree Properly set up parent on input devices registered by sonypi. Signed-off-by: Dmitry Torokhov Acked-by: Mattia Dongili --- drivers/char/sonypi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 877e53dcb99..172d3e47070 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c @@ -1163,7 +1163,7 @@ static struct acpi_driver sonypi_acpi_driver = { }; #endif -static int __devinit sonypi_create_input_devices(void) +static int __devinit sonypi_create_input_devices(struct platform_device *pdev) { struct input_dev *jog_dev; struct input_dev *key_dev; @@ -1177,6 +1177,7 @@ static int __devinit sonypi_create_input_devices(void) jog_dev->name = "Sony Vaio Jogdial"; jog_dev->id.bustype = BUS_ISA; jog_dev->id.vendor = PCI_VENDOR_ID_SONY; + jog_dev->dev.parent = &pdev->dev; jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE); @@ -1191,6 +1192,7 @@ static int __devinit sonypi_create_input_devices(void) key_dev->name = "Sony Vaio Keys"; key_dev->id.bustype = BUS_ISA; key_dev->id.vendor = PCI_VENDOR_ID_SONY; + key_dev->dev.parent = &pdev->dev; /* Initialize the Input Drivers: special keys */ key_dev->evbit[0] = BIT_MASK(EV_KEY); @@ -1385,7 +1387,7 @@ static int __devinit sonypi_probe(struct platform_device *dev) if (useinput) { - error = sonypi_create_input_devices(); + error = sonypi_create_input_devices(dev); if (error) { printk(KERN_ERR "sonypi: failed to create input devices\n"); -- cgit v1.2.3 From 3cb93db6e89bdffeae1f001bd87c9e96f9b634df Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 21 Nov 2007 14:16:38 -0500 Subject: Sonypi: use synchronize_irq instead of sycnronize_sched We know exactly what IRQ we are using, so synchronize_irq() suits much better. Plus synchronize_sched() will not work for us in -rt kernels. Signed-off-by: Dmitry Torokhov Acked-by: Mattia Dongili --- drivers/char/sonypi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 172d3e47070..921c6d2bc8f 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c @@ -1434,7 +1434,7 @@ static int __devexit sonypi_remove(struct platform_device *dev) { sonypi_disable(); - synchronize_sched(); /* Allow sonypi interrupt to complete. */ + synchronize_irq(sonypi_device.irq); flush_scheduled_work(); if (useinput) { -- cgit v1.2.3 From 8bf4215e8a7f7416d7258af211488aabf65863c3 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Wed, 21 Nov 2007 14:17:38 -0500 Subject: Input: i8042 - add i8042.noloop quirk for MS Virtual Machine When booting under Microsoft Virtual Machine, the noloop quirk is needed, otherwise PS/2 mouse is not properly detected. Reported-by: Lawrence Steeger Signed-off-by: Jiri Kosina Signed-off-by: Dmitry Torokhov --- drivers/input/serio/i8042-x86ia64io.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index f8fe4214809..c5e68dcd88a 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -110,6 +110,14 @@ static struct dmi_system_id __initdata i8042_dmi_noloop_table[] = { DMI_MATCH(DMI_PRODUCT_VERSION, "5a"), }, }, + { + .ident = "Microsoft Virtual Machine", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), + DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), + DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"), + }, + }, { } }; -- cgit v1.2.3 From 6a2e391190b17f4fb895bd2d5e8b08c7c8f897a2 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 21 Nov 2007 14:42:33 -0500 Subject: Input: gpio-keys - request and configure GPIOs Currently, gpio_keys.c assumes the GPIOs to be already properly configured; this patch changes gpio-keys to perform explicit calls to gpio_request() and gpio_configure_input(). This matches the behaviour of leds-gpio. Signed-off-by: Herbert Valerio Riedel Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/gpio_keys.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 3eddf52a0bb..6a9ca4bdcb7 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -75,16 +75,32 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) for (i = 0; i < pdata->nbuttons; i++) { struct gpio_keys_button *button = &pdata->buttons[i]; - int irq = gpio_to_irq(button->gpio); + int irq; unsigned int type = button->type ?: EV_KEY; + error = gpio_request(button->gpio, button->desc ?: "gpio_keys"); + if (error < 0) { + pr_err("gpio-keys: failed to request GPIO %d," + " error %d\n", button->gpio, error); + goto fail; + } + + error = gpio_direction_input(button->gpio); + if (error < 0) { + pr_err("gpio-keys: failed to configure input" + " direction for GPIO %d, error %d\n", + button->gpio, error); + gpio_free(button->gpio); + goto fail; + } + + irq = gpio_to_irq(button->gpio); if (irq < 0) { error = irq; - printk(KERN_ERR - "gpio-keys: " - "Unable to get irq number for GPIO %d," - "error %d\n", + pr_err("gpio-keys: Unable to get irq number" + " for GPIO %d, error %d\n", button->gpio, error); + gpio_free(button->gpio); goto fail; } @@ -94,9 +110,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) button->desc ? button->desc : "gpio_keys", pdev); if (error) { - printk(KERN_ERR - "gpio-keys: Unable to claim irq %d; error %d\n", + pr_err("gpio-keys: Unable to claim irq %d; error %d\n", irq, error); + gpio_free(button->gpio); goto fail; } @@ -108,8 +124,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) error = input_register_device(input); if (error) { - printk(KERN_ERR - "gpio-keys: Unable to register input device, " + pr_err("gpio-keys: Unable to register input device, " "error: %d\n", error); goto fail; } @@ -119,8 +134,10 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) return 0; fail: - while (--i >= 0) + while (--i >= 0) { free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); + gpio_free(pdata->buttons[i].gpio); + } platform_set_drvdata(pdev, NULL); input_free_device(input); @@ -139,6 +156,7 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev) for (i = 0; i < pdata->nbuttons; i++) { int irq = gpio_to_irq(pdata->buttons[i].gpio); free_irq(irq, pdev); + gpio_free(pdata->buttons[i].gpio); } input_unregister_device(input); -- cgit v1.2.3 From dd05c199cd02ffd2ac49eb29677f1468910996a8 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Fri, 16 Nov 2007 19:50:04 +0300 Subject: pata_sil680: kill bogus reset code (take 2) Since writing to two reserved bits ain't much of a housekeeping, I think it's time we get rid of the custom error handler in this driver. ;-) Signed-off-by: Sergei Shtylyov Signed-off-by: Jeff Garzik --- drivers/ata/pata_sil680.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index 5c1e9cb59ec..503245a1eaf 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c @@ -33,7 +33,7 @@ #include #define DRV_NAME "pata_sil680" -#define DRV_VERSION "0.4.7" +#define DRV_VERSION "0.4.8" #define SIL680_MMIO_BAR 5 @@ -93,34 +93,6 @@ static int sil680_cable_detect(struct ata_port *ap) { return ATA_CBL_PATA40; } -/** - * sil680_bus_reset - reset the SIL680 bus - * @link: ATA link to reset - * @deadline: deadline jiffies for the operation - * - * Perform the SIL680 housekeeping when doing an ATA bus reset - */ - -static int sil680_bus_reset(struct ata_link *link, unsigned int *classes, - unsigned long deadline) -{ - struct ata_port *ap = link->ap; - struct pci_dev *pdev = to_pci_dev(ap->host->dev); - unsigned long addr = sil680_selreg(ap, 0); - u8 reset; - - pci_read_config_byte(pdev, addr, &reset); - pci_write_config_byte(pdev, addr, reset | 0x03); - udelay(25); - pci_write_config_byte(pdev, addr, reset); - return ata_std_softreset(link, classes, deadline); -} - -static void sil680_error_handler(struct ata_port *ap) -{ - ata_bmdma_drive_eh(ap, ata_std_prereset, sil680_bus_reset, NULL, ata_std_postreset); -} - /** * sil680_set_piomode - set initial PIO mode data * @ap: ATA interface @@ -249,7 +221,7 @@ static struct ata_port_operations sil680_port_ops = { .freeze = ata_bmdma_freeze, .thaw = ata_bmdma_thaw, - .error_handler = sil680_error_handler, + .error_handler = ata_bmdma_error_handler, .post_internal_cmd = ata_bmdma_post_internal_cmd, .cable_detect = sil680_cable_detect, -- cgit v1.2.3 From 0706efd61edfcf958c2c19669aa65c2180ec3ba0 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 19 Nov 2007 18:06:11 +0900 Subject: pata_jmicron: fix disabled port handling in jmicron_pre_reset() There are two bugs in disabled port handling. * test in PORT_PATA0 is reversed * ->prereset should return -ENOENT for disabled ports not 0 The first bug makes the PATA channel considered disabled but the second bug saves the day by returning 0. The net result is that cable is always left at ATA_CBL_UNKNOWN. This results in false 80c configuration and thus transfer errors. This patch fixes both bugs. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/pata_jmicron.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c index 225a7223a72..5b8174d9406 100644 --- a/drivers/ata/pata_jmicron.c +++ b/drivers/ata/pata_jmicron.c @@ -80,11 +80,10 @@ static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline) * actually do our cable checking etc. Thankfully we don't need * to do the plumbing for other cases. */ - switch (port_map[port]) - { + switch (port_map[port]) { case PORT_PATA0: - if (control & (1 << 5)) - return 0; + if ((control & (1 << 5)) == 0) + return -ENOENT; if (control & (1 << 3)) /* 40/80 pin primary */ ap->cbl = ATA_CBL_PATA40; else @@ -93,7 +92,7 @@ static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline) case PORT_PATA1: /* Bit 21 is set if the port is enabled */ if ((control5 & (1 << 21)) == 0) - return 0; + return -ENOENT; if (control5 & (1 << 19)) /* 40/80 pin secondary */ ap->cbl = ATA_CBL_PATA40; else -- cgit v1.2.3 From 93e2618e0cee1f5b5a4cfc1b7521939318dbf5bb Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 22 Nov 2007 18:46:57 +0900 Subject: sata_sil24: fix sg table sizing sil24 unnecessarily used LIBATA_MAX_PRD and ATAPI sg table was short by one entry which might cause very obscure problems. This patch updates sg table sizing such that * One full page is used for PRB + sg table. On 4k page, this results in 253 sg's. * Make ATAPI sg block properly sized. * Make build fail if command block size doesn't equal PAGE_SIZE. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/sata_sil24.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index 187dcb02c68..96fd5260446 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c @@ -63,6 +63,21 @@ enum { SIL24_HOST_BAR = 0, SIL24_PORT_BAR = 2, + /* sil24 fetches in chunks of 64bytes. The first block + * contains the PRB and two SGEs. From the second block, it's + * consisted of four SGEs and called SGT. Calculate the + * number of SGTs that fit into one page. + */ + SIL24_PRB_SZ = sizeof(struct sil24_prb) + + 2 * sizeof(struct sil24_sge), + SIL24_MAX_SGT = (PAGE_SIZE - SIL24_PRB_SZ) + / (4 * sizeof(struct sil24_sge)), + + /* This will give us one unused SGEs for ATA. This extra SGE + * will be used to store CDB for ATAPI devices. + */ + SIL24_MAX_SGE = 4 * SIL24_MAX_SGT + 1, + /* * Global controller registers (128 bytes @ BAR0) */ @@ -247,13 +262,13 @@ enum { struct sil24_ata_block { struct sil24_prb prb; - struct sil24_sge sge[LIBATA_MAX_PRD]; + struct sil24_sge sge[SIL24_MAX_SGE]; }; struct sil24_atapi_block { struct sil24_prb prb; u8 cdb[16]; - struct sil24_sge sge[LIBATA_MAX_PRD - 1]; + struct sil24_sge sge[SIL24_MAX_SGE]; }; union sil24_cmd_block { @@ -378,7 +393,7 @@ static struct scsi_host_template sil24_sht = { .change_queue_depth = ata_scsi_change_queue_depth, .can_queue = SIL24_MAX_CMDS, .this_id = ATA_SHT_THIS_ID, - .sg_tablesize = LIBATA_MAX_PRD, + .sg_tablesize = SIL24_MAX_SGE, .cmd_per_lun = ATA_SHT_CMD_PER_LUN, .emulated = ATA_SHT_EMULATED, .use_clustering = ATA_SHT_USE_CLUSTERING, @@ -1284,6 +1299,7 @@ static void sil24_init_controller(struct ata_host *host) static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { + extern int __MARKER__sil24_cmd_block_is_sized_wrongly; static int printed_version; struct ata_port_info pi = sil24_port_info[ent->driver_data]; const struct ata_port_info *ppi[] = { &pi, NULL }; @@ -1292,6 +1308,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) int i, rc; u32 tmp; + /* cause link error if sil24_cmd_block is sized wrongly */ + if (sizeof(union sil24_cmd_block) != PAGE_SIZE) + __MARKER__sil24_cmd_block_is_sized_wrongly = 1; + if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); -- cgit v1.2.3 From c47a631f8bfad08a6001f8dd479004caa5059a75 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 19 Nov 2007 14:28:28 +0000 Subject: ata_piix: Invalid use of writel/readl with iomap Should use ioread* as discussed previously Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- drivers/ata/ata_piix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 671e7966500..483269db2c7 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -1121,12 +1121,12 @@ static int piix_disable_ahci(struct pci_dev *pdev) if (!mmio) return -ENOMEM; - tmp = readl(mmio + AHCI_GLOBAL_CTL); + tmp = ioread32(mmio + AHCI_GLOBAL_CTL); if (tmp & AHCI_ENABLE) { tmp &= ~AHCI_ENABLE; - writel(tmp, mmio + AHCI_GLOBAL_CTL); + iowrite32(tmp, mmio + AHCI_GLOBAL_CTL); - tmp = readl(mmio + AHCI_GLOBAL_CTL); + tmp = ioread32(mmio + AHCI_GLOBAL_CTL); if (tmp & AHCI_ENABLE) rc = -EIO; } -- cgit v1.2.3 From 92c52c52e123e6fabb85392b16bcdbdb64cfdc1c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 19 Nov 2007 14:30:16 +0000 Subject: libata-core: List more documentation sources for reference And next time I'll be able to find the ata tape spec easily... Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index f7f6ca991e3..33f06277b3b 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -30,6 +30,14 @@ * Hardware documentation available from http://www.t13.org/ and * http://www.sata-io.org/ * + * Standards documents from: + * http://www.t13.org (ATA standards, PCI DMA IDE spec) + * http://www.t10.org (SCSI MMC - for ATAPI MMC) + * http://www.sata-io.org (SATA) + * http://www.compactflash.org (CF) + * http://www.qic.org (QIC157 - Tape and DSC) + * http://www.ce-ata.org (CE-ATA: not supported) + * */ #include -- cgit v1.2.3 From 8f59a13accd78e9759548b40aa2a053938a01ec7 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 19 Nov 2007 14:36:28 +0000 Subject: pata_ali: Add Mitac 8317 and derivatives Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- drivers/ata/pata_ali.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index 364534e7aff..d12f386c150 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c @@ -63,6 +63,9 @@ static int ali_cable_override(struct pci_dev *pdev) /* Fujitsu P2000 */ if (pdev->subsystem_vendor == 0x10CF && pdev->subsystem_device == 0x10AF) return 1; + /* Mitac 8317 (Winbook-A) and relatives */ + if (pdev->subsystem_vendor == 0x1071 && pdev->subsystem_device == 0x8317) + return 1; /* Systems by DMI */ if (dmi_check_system(cable_dmi_table)) return 1; -- cgit v1.2.3 From 498222f323ab11331dc5cfedb97752477f0fe42a Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 19 Nov 2007 14:37:58 +0000 Subject: pata_ali: Lots of problems still showing up with small ATAPI DMA Hopefully there is a better long term solution but for now lets favour reliability. Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- drivers/ata/pata_ali.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'drivers') diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index d12f386c150..62aa2f90329 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c @@ -285,6 +285,21 @@ static void ali_lock_sectors(struct ata_device *adev) adev->max_sectors = 255; } +/** + * ali_check_atapi_dma - DMA check for most ALi controllers + * @adev: Device + * + * Called to decide whether commands should be sent by DMA or PIO + */ + +static int ali_check_atapi_dma(struct ata_queued_cmd *qc) +{ + /* If its not a media command, its not worth it */ + if (qc->nbytes < 2048) + return -EOPNOTSUPP; + return 0; +} + static struct scsi_host_template ali_sht = { .module = THIS_MODULE, .name = DRV_NAME, @@ -381,6 +396,7 @@ static struct ata_port_operations ali_c2_port_ops = { .mode_filter = ata_pci_default_filter, .tf_load = ata_tf_load, .tf_read = ata_tf_read, + .check_atapi_dma = ali_check_atapi_dma, .check_status = ata_check_status, .exec_command = ata_exec_command, .dev_select = ata_std_dev_select, @@ -418,6 +434,7 @@ static struct ata_port_operations ali_c5_port_ops = { .mode_filter = ata_pci_default_filter, .tf_load = ata_tf_load, .tf_read = ata_tf_read, + .check_atapi_dma = ali_check_atapi_dma, .check_status = ata_check_status, .exec_command = ata_exec_command, .dev_select = ata_std_dev_select, -- cgit v1.2.3 From 22d5c760c8bc2f146d5c31f69de7f52efd118992 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 19 Nov 2007 14:39:13 +0000 Subject: pata_hpt37x: Fix cable detect bug spotted by Sergei Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- 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 3816b8605e0..46dc70e0dee 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c @@ -329,7 +329,7 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline) /* Restore state */ pci_write_config_byte(pdev, 0x5B, scr2); - if (ata66 & (1 << ap->port_no)) + if (ata66 & (2 >> ap->port_no)) ap->cbl = ATA_CBL_PATA40; else ap->cbl = ATA_CBL_PATA80; -- cgit v1.2.3 From 91e33d31096a2b518ae5744c345af15c1ff06fd5 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 19 Nov 2007 14:41:05 +0000 Subject: pata_isapnp: Polled devices If a card has no IRQ then pass no interrupt handler but allow polled usage. Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- drivers/ata/pata_isapnp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c index 88ab0e1d353..4320e798632 100644 --- a/drivers/ata/pata_isapnp.c +++ b/drivers/ata/pata_isapnp.c @@ -75,13 +75,16 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev struct ata_host *host; struct ata_port *ap; void __iomem *cmd_addr, *ctl_addr; + int irq = 0; + irq_handler_t handler = NULL; if (pnp_port_valid(idev, 0) == 0) return -ENODEV; - /* FIXME: Should selected polled PIO here not fail */ - if (pnp_irq_valid(idev, 0) == 0) - return -ENODEV; + if (pnp_irq_valid(idev, 0)) { + irq = pnp_irq(idev, 0); + handler = ata_interrupt; + } /* allocate host */ host = ata_host_alloc(&idev->dev, 1); @@ -115,7 +118,7 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev (unsigned long long)pnp_port_start(idev, 1)); /* activate */ - return ata_host_activate(host, pnp_irq(idev, 0), ata_interrupt, 0, + return ata_host_activate(host, irq, handler, 0, &isapnp_sht); } -- cgit v1.2.3 From 2541d0ca7e4645d7e2d295eb241c318a7f875f3a Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Fri, 23 Nov 2007 21:08:42 -0500 Subject: pata_ali: trim trailing whitespace (fix checkpatch complaints) Signed-off-by: Jeff Garzik --- drivers/ata/pata_ali.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index 62aa2f90329..8caf9afc8b9 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c @@ -291,7 +291,7 @@ static void ali_lock_sectors(struct ata_device *adev) * * Called to decide whether commands should be sent by DMA or PIO */ - + static int ali_check_atapi_dma(struct ata_queued_cmd *qc) { /* If its not a media command, its not worth it */ -- cgit v1.2.3 From 3fe2ed344d4b36e7489b1d0c7cf677312b0bf870 Mon Sep 17 00:00:00 2001 From: Joachim Fenkes Date: Thu, 22 Nov 2007 12:26:26 +0200 Subject: IB/ehca: Fix static rate regression Wrong choice of port number caused modify_qp() to fail -- fixed. 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 2e3e6547cb7..dd126681fed 100644 --- a/drivers/infiniband/hw/ehca/ehca_qp.c +++ b/drivers/infiniband/hw/ehca/ehca_qp.c @@ -1203,7 +1203,7 @@ static int internal_modify_qp(struct ib_qp *ibqp, mqpcb->service_level = attr->ah_attr.sl; update_mask |= EHCA_BMASK_SET(MQPCB_MASK_SERVICE_LEVEL, 1); - if (ehca_calc_ipd(shca, my_qp->init_attr.port_num, + if (ehca_calc_ipd(shca, mqpcb->prim_phys_port, attr->ah_attr.static_rate, &mqpcb->max_static_rate)) { ret = -EINVAL; @@ -1302,7 +1302,7 @@ static int internal_modify_qp(struct ib_qp *ibqp, mqpcb->source_path_bits_al = attr->alt_ah_attr.src_path_bits; mqpcb->service_level_al = attr->alt_ah_attr.sl; - if (ehca_calc_ipd(shca, my_qp->init_attr.port_num, + if (ehca_calc_ipd(shca, mqpcb->alt_phys_port, attr->alt_ah_attr.static_rate, &mqpcb->max_static_rate_al)) { ret = -EINVAL; -- cgit v1.2.3 From a316b79c3306c59176d7ae04e4aad12374dfed37 Mon Sep 17 00:00:00 2001 From: Erez Zilber Date: Wed, 21 Nov 2007 13:11:37 +0200 Subject: IB/iser: Add missing counter increment in iser_data_buf_aligned_len() While adding sg chaining support to iSER, a "for" loop was replaced with a "for_each_sg" loop. The "for" loop included the incrementation of 2 variables. Only one of them is incremented in the current "for_each_sg" loop. This caused iSER to think that all data is unaligned, and all data was copied to aligned buffers. This patch increments the missing counter inside the "for_each_sg" loop whenever necessary. Signed-off-by: Erez Zilber Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/iser/iser_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index d6879806179..4a17743a639 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c @@ -310,13 +310,15 @@ static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data, if (i + 1 < data->dma_nents) { next_addr = ib_sg_dma_address(ibdev, sg_next(sg)); /* are i, i+1 fragments of the same page? */ - if (end_addr == next_addr) + if (end_addr == next_addr) { + cnt++; continue; - else if (!IS_4K_ALIGNED(end_addr)) { + } else if (!IS_4K_ALIGNED(end_addr)) { ret_len = cnt + 1; break; } } + cnt++; } if (i == data->dma_nents) ret_len = cnt; /* loop ended */ -- cgit v1.2.3 From fa7f1518e8a107e1feab0357b18c745b9a6927c5 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 22 Nov 2007 17:52:47 +0100 Subject: [ARM] 4662/1: Fix PXA serial driver compilation if SERIAL_PXA_CONSOLE is disabled Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- drivers/serial/pxa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c index af3a011b2b2..352fcb8926a 100644 --- a/drivers/serial/pxa.c +++ b/drivers/serial/pxa.c @@ -585,11 +585,11 @@ serial_pxa_type(struct uart_port *port) return up->name; } -#ifdef CONFIG_SERIAL_PXA_CONSOLE - static struct uart_pxa_port *serial_pxa_ports[4]; static struct uart_driver serial_pxa_reg; +#ifdef CONFIG_SERIAL_PXA_CONSOLE + #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) /* -- cgit v1.2.3 From dc86f6d4183c79a08fa01c08dd2191895c0c7eb0 Mon Sep 17 00:00:00 2001 From: sonic zhang Date: Mon, 26 Nov 2007 17:50:56 +0800 Subject: libata: Return proper ATA INT status in pata_bf54x driver INT status can be OR. Signed-off-by: Sonic Zhang Signed-off-by: Jeff Garzik --- drivers/ata/pata_bf54x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c index b5e38426b81..81db405a544 100644 --- a/drivers/ata/pata_bf54x.c +++ b/drivers/ata/pata_bf54x.c @@ -1145,13 +1145,13 @@ static unsigned char bfin_bmdma_status(struct ata_port *ap) unsigned short int_status = ATAPI_GET_INT_STATUS(base); if (ATAPI_GET_STATUS(base) & (MULTI_XFER_ON|ULTRA_XFER_ON)) { - host_stat = ATA_DMA_ACTIVE; + host_stat |= ATA_DMA_ACTIVE; } if (int_status & (MULTI_DONE_INT|UDMAIN_DONE_INT|UDMAOUT_DONE_INT)) { - host_stat = ATA_DMA_INTR; + host_stat |= ATA_DMA_INTR; } if (int_status & (MULTI_TERM_INT|UDMAIN_TERM_INT|UDMAOUT_TERM_INT)) { - host_stat = ATA_DMA_ERR; + host_stat |= ATA_DMA_ERR; } return host_stat; -- cgit v1.2.3 From e190222d04cb1119c62876ac87cf9b9403ba3bd5 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 26 Nov 2007 20:58:02 +0900 Subject: libata: bump transfer chunk size if it's odd None of the drives I have follows what the standard says about transfer chunk size. Of the four SATA and six PATA ATAPI devices tested, four ignore transfer chunk size completely and the ones which honor it don't behave according to the spec when it's odd. According to the spec, transfer chunk size can be odd if the amount of data to transfer equals or is smaller than the chunk size and the device can indicate the same odd number and transfer the whole thing at one go with a pad byte appended. However, in reality, none of the drives I have does that. They all indicate and transfer even number of bytes one byte shorter than the chunk size first; then indicate and transfer two bytes, which is clearly out of spec. In addition to unnecessary second PIO data phase, this also creates a weird problem when combined with SATA controllers which perform PIO via DMA. Some of these controllers use actualy number of bytes received to update DMA pointer so chunks which are sized 4n + 2 makes DMA pointer off by two bytes. This causes data corruption and buffer overruns. This patch rounds nbytes up to the nearest even number such that ATAPI devices don't split data transfer for the last odd byte. This shouldn't confuse controllers which depend on transfer chunk size as devices will report the rounded-up number, actually transfer that much and padding buffer is there to receive them. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-scsi.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index a45f6ac3b24..a883bb03d4c 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2485,11 +2485,40 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc) if (!using_pio && ata_check_atapi_dma(qc)) using_pio = 1; - /* Some controller variants snoop this value for Packet transfers - to do state machine and FIFO management. Thus we want to set it - properly, and for DMA where it is effectively meaningless */ + /* Some controller variants snoop this value for Packet + * transfers to do state machine and FIFO management. Thus we + * want to set it properly, and for DMA where it is + * effectively meaningless. + */ nbytes = min(qc->nbytes, (unsigned int)63 * 1024); + /* Most ATAPI devices which honor transfer chunk size don't + * behave according to the spec when odd chunk size which + * matches the transfer length is specified. If the number of + * bytes to transfer is 2n+1. According to the spec, what + * should happen is to indicate that 2n+1 is going to be + * transferred and transfer 2n+2 bytes where the last byte is + * padding. + * + * In practice, this doesn't happen. ATAPI devices first + * indicate and transfer 2n bytes and then indicate and + * transfer 2 bytes where the last byte is padding. + * + * This inconsistency confuses several controllers which + * perform PIO using DMA such as Intel AHCIs and sil3124/32. + * These controllers use actual number of transferred bytes to + * update DMA poitner and transfer of 4n+2 bytes make those + * controller push DMA pointer by 4n+4 bytes because SATA data + * FISes are aligned to 4 bytes. This causes data corruption + * and buffer overrun. + * + * Always setting nbytes to even number solves this problem + * because then ATAPI devices don't have to split data at 2n + * boundaries. + */ + if (nbytes & 0x1) + nbytes++; + qc->tf.lbam = (nbytes & 0xFF); qc->tf.lbah = (nbytes >> 8); -- cgit v1.2.3 From c1c306344669ca40255e36192b101060ffbb1271 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Mon, 26 Nov 2007 20:42:19 +0100 Subject: ACPI: Set max_cstate to 1 for early Opterons. AMD Opteron processors before CG revision don't like C-states > 1. This solves the long standing bugzilla #5303 and probably some more on affected machines: http://bugzilla.kernel.org/show_bug.cgi?id=5303 [ tglx@linutronix.de: reworked the patch so it does not wreck ia64 ] Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar --- drivers/acpi/processor_idle.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index f996d0e3768..b52109bd06d 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1658,6 +1658,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, if (!first_run) { dmi_check_system(processor_power_dmi_table); + max_cstate = acpi_processor_cstate_check(max_cstate); if (max_cstate < ACPI_C_STATES_MAX) printk(KERN_NOTICE "ACPI: processor limited to max C-state %d\n", -- cgit v1.2.3 From 8a8037ac9dbe4eb20ce50aa20244faf77444f4a3 Mon Sep 17 00:00:00 2001 From: chas williams Date: Tue, 27 Nov 2007 11:03:16 +0800 Subject: [ATM]: [he] initialize lock and tasklet earlier if you are lucky (unlucky?) enough to have shared interrupts, the interrupt handler can be called before the tasklet and lock are ready for use. Signed-off-by: chas williams Signed-off-by: Herbert Xu --- drivers/atm/he.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/atm/he.c b/drivers/atm/he.c index d33aba6864c..3b64a99772e 100644 --- a/drivers/atm/he.c +++ b/drivers/atm/he.c @@ -394,6 +394,11 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent) he_dev->atm_dev->dev_data = he_dev; atm_dev->dev_data = he_dev; he_dev->number = atm_dev->number; +#ifdef USE_TASKLET + tasklet_init(&he_dev->tasklet, he_tasklet, (unsigned long) he_dev); +#endif + spin_lock_init(&he_dev->global_lock); + if (he_start(atm_dev)) { he_stop(he_dev); err = -ENODEV; @@ -1173,11 +1178,6 @@ he_start(struct atm_dev *dev) if ((err = he_init_irq(he_dev)) != 0) return err; -#ifdef USE_TASKLET - tasklet_init(&he_dev->tasklet, he_tasklet, (unsigned long) he_dev); -#endif - spin_lock_init(&he_dev->global_lock); - /* 4.11 enable pci bus controller state machines */ host_cntl |= (OUTFF_ENB | CMDFF_ENB | QUICK_RD_RETRY | QUICK_WR_RETRY | PERR_INT_ENB); -- cgit v1.2.3 From 0f13864e5b24d9cbe18d125d41bfa4b726a82e40 Mon Sep 17 00:00:00 2001 From: Karsten Keil Date: Thu, 22 Nov 2007 12:43:13 +0100 Subject: isdn: avoid copying overly-long strings Addresses http://bugzilla.kernel.org/show_bug.cgi?id=9416 Signed-off-by: Karsten Keil Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/i4l/isdn_net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index b39d1f5b378..ced83c202ca 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -2104,7 +2104,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) u_long flags; isdn_net_dev *p; isdn_net_phone *n; - char nr[32]; + char nr[ISDN_MSNLEN]; char *my_eaz; /* Search name in netdev-chain */ @@ -2113,7 +2113,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) nr[1] = '\0'; printk(KERN_INFO "isdn_net: Incoming call without OAD, assuming '0'\n"); } else - strcpy(nr, setup->phone); + strlcpy(nr, setup->phone, ISDN_MSNLEN); si1 = (int) setup->si1; si2 = (int) setup->si2; if (!setup->eazmsn[0]) { @@ -2789,7 +2789,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) chidx = -1; } } - strcpy(lp->msn, cfg->eaz); + strlcpy(lp->msn, cfg->eaz, sizeof(lp->msn)); lp->pre_device = drvidx; lp->pre_channel = chidx; lp->onhtime = cfg->onhtime; @@ -2936,7 +2936,7 @@ isdn_net_addphone(isdn_net_ioctl_phone * phone) if (p) { if (!(n = kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) return -ENOMEM; - strcpy(n->num, phone->phone); + strlcpy(n->num, phone->phone, sizeof(n->num)); n->next = p->local->phone[phone->outgoing & 1]; p->local->phone[phone->outgoing & 1] = n; return 0; -- cgit v1.2.3 From 2f9b0b5e46f0381fd41af8cb9ed4daffee59d4f3 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 18 Nov 2007 11:10:04 +0100 Subject: Amiga zorro bus: Add missing zorro_device_remove() Amiga zorro bus: Add missing zorro_device_remove(). Without this ifconfig and /proc/net/dev oops after unloading a Zorro network device driver module. Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Torvalds --- drivers/zorro/zorro-driver.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers') diff --git a/drivers/zorro/zorro-driver.c b/drivers/zorro/zorro-driver.c index 067c07be928..e6c4390d8bd 100644 --- a/drivers/zorro/zorro-driver.c +++ b/drivers/zorro/zorro-driver.c @@ -60,6 +60,20 @@ static int zorro_device_probe(struct device *dev) } +static int zorro_device_remove(struct device *dev) +{ + struct zorro_dev *z = to_zorro_dev(dev); + struct zorro_driver *drv = to_zorro_driver(dev->driver); + + if (drv) { + if (drv->remove) + drv->remove(z); + z->driver = NULL; + } + return 0; +} + + /** * zorro_register_driver - register a new Zorro driver * @drv: the driver structure to register @@ -128,6 +142,7 @@ struct bus_type zorro_bus_type = { .name = "zorro", .match = zorro_bus_match, .probe = zorro_device_probe, + .remove = zorro_device_remove, }; -- cgit v1.2.3 From 3050d45caded2d9fb8170547d08c389122c6c5d5 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Mon, 19 Nov 2007 09:28:22 +0100 Subject: radeonfb: add chip definition for RV370 5b63 ... which I've found on a Sapphire X550 (Silent). Acked-by: Benjamin Herrenschmidt Signed-off-by: Andreas Herrmann Signed-off-by: Linus Torvalds --- drivers/video/aty/radeon_base.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index 1e32b3d13f2..62867cb63fe 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c @@ -202,6 +202,7 @@ static struct pci_device_id radeonfb_pci_table[] = { CHIP_DEF(PCI_CHIP_RV380_3154, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), CHIP_DEF(PCI_CHIP_RV370_5B60, RV380, CHIP_HAS_CRTC2), CHIP_DEF(PCI_CHIP_RV370_5B62, RV380, CHIP_HAS_CRTC2), + CHIP_DEF(PCI_CHIP_RV370_5B63, RV380, CHIP_HAS_CRTC2), CHIP_DEF(PCI_CHIP_RV370_5B64, RV380, CHIP_HAS_CRTC2), CHIP_DEF(PCI_CHIP_RV370_5B65, RV380, CHIP_HAS_CRTC2), CHIP_DEF(PCI_CHIP_RV370_5460, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), -- cgit v1.2.3 From f6ce5cca74b8681fdf1d7307edc66a7213b43f6f Mon Sep 17 00:00:00 2001 From: Mikulas Patocka Date: Thu, 22 Nov 2007 21:19:39 +0100 Subject: plip: use netif_rx_ni() for packet receive netif_rx is meant to be called from interrupts because it doesn't wake up ksoftirqd. For calling from outside interrupts, netif_rx_ni exists. This fixes plip to use netif_rx_ni. It fixes the infamous error "NOHZ: local_softirq_panding 08" that happens on some machines with NOHZ and plip --- it is caused by the fact that softirq is pending and ksoftirqd is sleeping. Signed-off-by: Mikulas Patocka Signed-off-by: Linus Torvalds --- drivers/net/plip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/plip.c b/drivers/net/plip.c index 5071fcd8a0b..baf2cbfc886 100644 --- a/drivers/net/plip.c +++ b/drivers/net/plip.c @@ -663,7 +663,7 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl, case PLIP_PK_DONE: /* Inform the upper layer for the arrival of a packet. */ rcv->skb->protocol=plip_type_trans(rcv->skb, dev); - netif_rx(rcv->skb); + netif_rx_ni(rcv->skb); dev->last_rx = jiffies; dev->stats.rx_bytes += rcv->length.h; dev->stats.rx_packets++; -- cgit v1.2.3 From cdb32706f6948238ed6d1d85473c64c27366e9e9 Mon Sep 17 00:00:00 2001 From: Mikulas Patocka Date: Thu, 22 Nov 2007 21:26:01 +0100 Subject: plip: fix parport_register_device name parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plip passes a string "name" that is allocated on stack to parport_register_device. parport_register_device holds the pointer to "name" and when the registering function exits, it points nowhere. On some machine, this bug causes bad names to appear in /proc, such as /proc/sys/dev/parport/parport0/devices/T^/�X^/�, on others, the plip proc node is completely missing. The patch also fixes documentation to note this requirement. Signed-off-by: Mikulas Patocka Signed-off-by: Linus Torvalds --- drivers/net/plip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/plip.c b/drivers/net/plip.c index baf2cbfc886..57c98669984 100644 --- a/drivers/net/plip.c +++ b/drivers/net/plip.c @@ -1269,7 +1269,7 @@ static void plip_attach (struct parport *port) nl = netdev_priv(dev); nl->dev = dev; - nl->pardev = parport_register_device(port, name, plip_preempt, + nl->pardev = parport_register_device(port, dev->name, plip_preempt, plip_wakeup, plip_interrupt, 0, dev); -- cgit v1.2.3 From 6957c8280080d985518133eab3a57d715a57be78 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 27 Nov 2007 00:46:42 -0500 Subject: Input: bf54x-keys - keypad does not exist on BF544 parts Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 2316a018fae..dfa6592c10f 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -286,7 +286,7 @@ config KEYBOARD_MAPLE config KEYBOARD_BFIN tristate "Blackfin BF54x keypad support" - depends on BF54x + depends on (BF54x && !BF544) help Say Y here if you want to use the BF54x keypad. -- cgit v1.2.3 From 05e5b136459b11cd9559370d5756719e08074fe0 Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Fri, 23 Nov 2007 10:19:00 +0100 Subject: mmc: Add missing sg_init_table() call mmc_init_queue only initializes the scatterlists with sg_init_table() when using a bounce buffer. This leads to a BUG() when CONFIG_DEBUG_SG is set. Signed-off-by: Haavard Skinnemoen Signed-off-by: Jens Axboe --- drivers/mmc/card/queue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index 1b9c9b6da5b..30cd13b13ac 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c @@ -180,12 +180,13 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock blk_queue_max_hw_segments(mq->queue, host->max_hw_segs); blk_queue_max_segment_size(mq->queue, host->max_seg_size); - mq->sg = kzalloc(sizeof(struct scatterlist) * + mq->sg = kmalloc(sizeof(struct scatterlist) * host->max_phys_segs, GFP_KERNEL); if (!mq->sg) { ret = -ENOMEM; goto cleanup_queue; } + sg_init_table(mq->sg, host->max_phys_segs); } init_MUTEX(&mq->thread_sem); -- cgit v1.2.3 From e826ec9ae2baf9980402e85f0bbe1dac53ceb110 Mon Sep 17 00:00:00 2001 From: Izik Eidus Date: Sun, 11 Nov 2007 14:40:48 +0200 Subject: KVM: x86 emulator: fix JMP_REL Change JMP_REL to call to register_address_increment(): the operands size should not effect the calculation of the eip, instead the ad_bytes should affect it. Signed-off-by: Izik Eidus Signed-off-by: Avi Kivity --- drivers/kvm/x86_emulate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index 33b18145155..a1a9c9be39b 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -448,8 +448,7 @@ struct operand { #define JMP_REL(rel) \ do { \ - _eip += (int)(rel); \ - _eip = ((op_bytes == 2) ? (uint16_t)_eip : (uint32_t)_eip); \ + register_address_increment(_eip, rel); \ } while (0) /* -- cgit v1.2.3 From 2a738e20a11b44219aa83073d625ff1a7004e463 Mon Sep 17 00:00:00 2001 From: Izik Eidus Date: Sun, 11 Nov 2007 14:46:34 +0200 Subject: KVM: x86 emulator: fix the saving of of the eip value this make sure that no matter what is the operand size, all the value of the eip will be saved Signed-off-by: Izik Eidus Signed-off-by: Avi Kivity --- drivers/kvm/x86_emulate.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index a1a9c9be39b..6c1413f9e9c 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -1358,6 +1358,7 @@ special_insn: } src.val = (unsigned long) _eip; JMP_REL(rel); + op_bytes = ad_bytes; goto push; } case 0xe9: /* jmp rel */ -- cgit v1.2.3 From 00b2ef475d4728ca53a2bc788c7978042907e354 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Sun, 18 Nov 2007 22:25:40 +0530 Subject: KVM: x86 emulator: Use emulator_write_emulated and not emulator_write_std emulator_write_std() is not implemented, and calling write_emulated should work just as well in place of write_std. Fixes emulator failures with the push r/m instruction. Signed-off-by: Amit Shah Signed-off-by: Avi Kivity --- drivers/kvm/x86_emulate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index 6c1413f9e9c..bd46de6bf89 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -1146,7 +1146,7 @@ done_prefixes: } register_address_increment(_regs[VCPU_REGS_RSP], -dst.bytes); - if ((rc = ops->write_std( + if ((rc = ops->write_emulated( register_address(ctxt->ss_base, _regs[VCPU_REGS_RSP]), &dst.val, dst.bytes, ctxt->vcpu)) != 0) -- cgit v1.2.3 From 8d379a7c069179a98616c9cac6bb2a06a500de49 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 27 Nov 2007 15:33:10 +0200 Subject: KVM: SVM: Unload guest fpu on vcpu_put() Not unloading the guest fpu can cause fpu leaks from guest to guest (or host to guest). Signed-off-by: Avi Kivity --- drivers/kvm/svm.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c index 7a6eead63a6..4e04e49a2f1 100644 --- a/drivers/kvm/svm.c +++ b/drivers/kvm/svm.c @@ -663,6 +663,7 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu) wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]); rdtscll(vcpu->host_tsc); + kvm_put_guest_fpu(vcpu); } static void svm_vcpu_decache(struct kvm_vcpu *vcpu) -- cgit v1.2.3 From 404fb881b82cf0cf6981832f8d31a7484e4dee81 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Mon, 19 Nov 2007 17:57:35 +0200 Subject: KVM: SVM: Fix FPU leak while emulating clts The clts code didn't use set_cr0 properly, so our lazy FPU processing wasn't being done by the clts instruction at all. (this isn't called on Intel as the hardware does the decode for us) Signed-off-by: Amit Shah Signed-off-by: Avi Kivity --- drivers/kvm/kvm_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 07ae280e8fe..47c10b8f89b 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -1188,8 +1188,7 @@ int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address) int emulate_clts(struct kvm_vcpu *vcpu) { - vcpu->cr0 &= ~X86_CR0_TS; - kvm_x86_ops->set_cr0(vcpu, vcpu->cr0); + kvm_x86_ops->set_cr0(vcpu, vcpu->cr0 & ~X86_CR0_TS); return X86EMUL_CONTINUE; } -- cgit v1.2.3 From a1d85864d30181a71243193ed01d322dc0618dc6 Mon Sep 17 00:00:00 2001 From: Gabriel Craciunescu Date: Tue, 27 Nov 2007 21:35:52 +0100 Subject: sis5513.c: Add Packard Bell EasyNote K5305 to laptops With newer kernels HDD in my old laptop is limited to UDMA 33. With this patch I get UDMA 100 again. Signed-off-by: Gabriel Craciunescu Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/sis5513.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index f6e2ab3dd16..d90b4291777 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c @@ -526,6 +526,7 @@ static const struct sis_laptop sis_laptop[] = { /* devid, subvendor, subdev */ { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */ { 0x5513, 0x1734, 0x105f }, /* FSC Amilo A1630 */ + { 0x5513, 0x1071, 0x8640 }, /* EasyNote K5305 */ /* end marker */ { 0, } }; -- cgit v1.2.3 From 89613e667f7539defb053795f18653003179cf7e Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Tue, 27 Nov 2007 21:35:52 +0100 Subject: ide: don't set PIO mode on pre-EIDE drives Fix handling of the PIO modes for the pre-EIDE drives that did not support the PIO Flow Control Transfer Mode value (00001 nnn) of the Set Transfer Mode feature by skipping the actual mode programming. Signed-off-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-iops.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index e17a9ee120e..1cdf688a542 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -756,7 +756,7 @@ int ide_driveid_update(ide_drive_t *drive) int ide_config_drive_speed(ide_drive_t *drive, u8 speed) { ide_hwif_t *hwif = drive->hwif; - int error; + int error = 0; u8 stat; // while (HWGROUP(drive)->busy) @@ -767,6 +767,10 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) hwif->dma_host_off(drive); #endif + /* Skip setting PIO flow-control modes on pre-EIDE drives */ + if ((speed & 0xf8) == XFER_PIO_0 && !(drive->id->capability & 0x08)) + goto skip; + /* * Don't use ide_wait_cmd here - it will * attempt to set_geometry and recalibrate, @@ -814,6 +818,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) drive->id->dma_mword &= ~0x0F00; drive->id->dma_1word &= ~0x0F00; + skip: #ifdef CONFIG_BLK_DEV_IDEDMA if (speed >= XFER_SW_DMA_0) hwif->dma_host_on(drive); -- cgit v1.2.3 From 8ac98ce17cf318f6ceb1eb88053917001f5ca60a Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Tue, 27 Nov 2007 21:35:53 +0100 Subject: siimage: remove resetproc() method The intent behind siimage_reset() was probably to hard reset the interface and the SATA PHY but as the code writes to two reserved bits instead, it obviously has been ineffective from the start. So, just remove it. Signed-off-by: Sergei Shtylyov Cc: Alan Cox Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/siimage.c | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 6d99441c605..5709c252543 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/pci/siimage.c Version 1.18 Oct 18 2007 + * linux/drivers/ide/pci/siimage.c Version 1.19 Nov 16 2007 * * Copyright (C) 2001-2002 Andre Hedrick * Copyright (C) 2003 Red Hat @@ -459,48 +459,6 @@ static void sil_sata_pre_reset(ide_drive_t *drive) } } -/** - * siimage_reset - reset a device on an siimage controller - * @drive: drive to reset - * - * Perform a controller level reset fo the device. For - * SATA we must also check the PHY. - */ - -static void siimage_reset (ide_drive_t *drive) -{ - ide_hwif_t *hwif = HWIF(drive); - u8 reset = 0; - unsigned long addr = siimage_selreg(hwif, 0); - - if (hwif->mmio) { - reset = hwif->INB(addr); - hwif->OUTB((reset|0x03), addr); - /* FIXME:posting */ - udelay(25); - hwif->OUTB(reset, addr); - (void) hwif->INB(addr); - } else { - pci_read_config_byte(hwif->pci_dev, addr, &reset); - pci_write_config_byte(hwif->pci_dev, addr, reset|0x03); - udelay(25); - pci_write_config_byte(hwif->pci_dev, addr, reset); - pci_read_config_byte(hwif->pci_dev, addr, &reset); - } - - if (SATA_STATUS_REG) { - /* SATA_STATUS_REG is valid only when in MMIO mode */ - u32 sata_stat = readl((void __iomem *)SATA_STATUS_REG); - printk(KERN_WARNING "%s: reset phy, status=0x%08x, %s\n", - hwif->name, sata_stat, __FUNCTION__); - if (!(sata_stat)) { - printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n", - hwif->name, sata_stat); - drive->failures++; - } - } -} - /** * proc_reports_siimage - add siimage controller to proc * @dev: PCI device @@ -857,7 +815,6 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif) { u8 sata = is_sata(hwif); - hwif->resetproc = &siimage_reset; hwif->set_pio_mode = &sil_set_pio_mode; hwif->set_dma_mode = &sil_set_dma_mode; -- cgit v1.2.3 From 8266105b15192177ac732ab8a27b315dc9291100 Mon Sep 17 00:00:00 2001 From: Jonas Stare Date: Tue, 27 Nov 2007 21:35:53 +0100 Subject: ide: skip ide_wait_not_busy() on noprobe-disks There is a problem in some hardware where the kernel will stall for 35 seconds waiting for disks that don't exist. This patch will skip waiting for the BSY-bit on IDE drives to go away if you set "hdx=noprobe" as a kernel option and the disk is not marked as 'present' (like when you set the geometry by hand). If no noprobe-option is set the code will work (more or less) as the original but if set the code will skip the ide_wait_not_busy() for that drive. Even if there would be a drive there and it is still busy afterwards it should not matter since it isn't probed for later. The code also honors the MAX_DRIVES variable instead of assuming that there will be two harddrives on the bus. Bart: minor cleanups Signed-off-by: Jonas Stare CC: Andrew Morton , Cc: Linus Torvalds Cc: Alan Cox Cc: Benjamin Herrenschmidt Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-probe.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 56fb0b84342..ee848c70599 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -644,7 +644,7 @@ static void hwif_register (ide_hwif_t *hwif) static int wait_hwif_ready(ide_hwif_t *hwif) { - int rc; + int unit, rc; printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); @@ -661,20 +661,26 @@ static int wait_hwif_ready(ide_hwif_t *hwif) return rc; /* Now make sure both master & slave are ready */ - SELECT_DRIVE(&hwif->drives[0]); - hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); - mdelay(2); - rc = ide_wait_not_busy(hwif, 35000); - if (rc) - return rc; - SELECT_DRIVE(&hwif->drives[1]); - hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); - mdelay(2); - rc = ide_wait_not_busy(hwif, 35000); + for (unit = 0; unit < MAX_DRIVES; unit++) { + ide_drive_t *drive = &hwif->drives[unit]; + /* 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]); + mdelay(2); + rc = ide_wait_not_busy(hwif, 35000); + if (rc) + goto out; + } else + printk(KERN_DEBUG "%s: ide_wait_not_busy() skipped\n", + drive->name); + } +out: /* Exit function with master reselected (let's be sane) */ - SELECT_DRIVE(&hwif->drives[0]); - + if (unit) + SELECT_DRIVE(&hwif->drives[0]); + return rc; } -- cgit v1.2.3 From b48d08177fe635a549aaf63eef508be1de069ebf Mon Sep 17 00:00:00 2001 From: Aleksandar Radovanovic Date: Tue, 27 Nov 2007 21:35:53 +0100 Subject: aec62xx: Fix kernel oops in driver's probe function Add pci_enable_device() to aec62xx probe function before doing any I/O. Original probe function tries to read from device's PCI region 4 before calling ide_setup_pci_device(). Since the device is not enabled at this point, on machines that have no firmware PCI initialization (e.g. ASUS WL-700gE router), corresponding PCI BAR is 0 and the following inb() causes a kernel oops. Signed-off-by: Aleksandar Radovanovic Cc: Linus Torvalds , Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/aec62xx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index 19ec421f7b9..44268504ae4 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c @@ -260,6 +260,11 @@ static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_devi { struct ide_port_info d; u8 idx = id->driver_data; + int err; + + err = pci_enable_device(dev); + if (err) + return err; d = aec62xx_chipsets[idx]; @@ -272,7 +277,11 @@ static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_devi } } - return ide_setup_pci_device(dev, &d); + err = ide_setup_pci_device(dev, &d); + if (err) + pci_disable_device(dev); + + return err; } static const struct pci_device_id aec62xx_pci_tbl[] = { -- cgit v1.2.3 From 355bd12f4aba2f6acaf5e8dd9c85e0cc7dbae965 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:54 +0100 Subject: macide/q40ide: add missing __init tag to {macide,q40ide}_init() Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/legacy/macide.c | 2 +- drivers/ide/legacy/q40ide.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index e87cd2f1643..5c6aa77c237 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c @@ -81,7 +81,7 @@ int macide_ack_intr(ide_hwif_t* hwif) * Probe for a Macintosh IDE interface */ -void macide_init(void) +void __init macide_init(void) { hw_regs_t hw; ide_hwif_t *hwif; diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index a73db1bd482..6ea46a6723e 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c @@ -111,7 +111,7 @@ static const char *q40_ide_names[Q40IDE_NUM_HWIFS]={ * Probe for Q40 IDE interfaces */ -void q40ide_init(void) +void __init q40ide_init(void) { int i; ide_hwif_t *hwif; -- cgit v1.2.3 From c5d252cbe9044054476498df163d99cb5a6d0ba8 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:54 +0100 Subject: ide/Kconfig: fix mpc8xx host driver dependencies Only LWMON, IVMS8, IVML24 and TQM8xxL platforms have the needed defines (IDE0_BASE_OFFSET and friends) in the platform header file. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index e445fe6e4ba..080d7f5d45c 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -963,7 +963,7 @@ config BLK_DEV_Q40IDE config BLK_DEV_MPC8xx_IDE bool "MPC8xx IDE support" - depends on 8xx && IDE=y && BLK_DEV_IDE=y && !PPC_MERGE + depends on 8xx && (LWMON || IVMS8 || IVML24 || TQM8xxL) && IDE=y && BLK_DEV_IDE=y && !PPC_MERGE select IDE_GENERIC help This option provides support for IDE on Motorola MPC8xx Systems. -- cgit v1.2.3 From acfad6e186664fa8521662bb7992ff6508f9357b Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:54 +0100 Subject: ide: add CONFIG_IDE_H8300 config option Add a separate config option for ide-8300 host driver instead of depending on CONFIG_H8300. This change is a preparation for the future changes and also allows ide-h8300 to be disabled if needed. Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/Kconfig | 9 ++++++++- drivers/ide/Makefile | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 080d7f5d45c..ca8239a2c98 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -313,7 +313,6 @@ comment "IDE chipset support/bugfixes" config IDE_GENERIC tristate "generic/default IDE chipset support" - default H8300 help If unsure, say N. @@ -883,6 +882,14 @@ config BLK_DEV_IDE_BAST Say Y here if you want to support the onboard IDE channels on the Simtec BAST or the Thorcom VR1000 +config IDE_H8300 + bool "H8300 IDE support" + depends on H8300 + select IDE_GENERIC + default y + help + Enables the H8300 IDE driver. + config BLK_DEV_GAYLE bool "Amiga Gayle IDE interface support" depends on AMIGA diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index 75dc6969e0a..b181fc67205 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile @@ -39,7 +39,7 @@ ide-core-$(CONFIG_BLK_DEV_MPC8xx_IDE) += ppc/mpc8xx.o ide-core-$(CONFIG_BLK_DEV_IDE_PMAC) += ppc/pmac.o # built-in only drivers from h8300/ -ide-core-$(CONFIG_H8300) += h8300/ide-h8300.o +ide-core-$(CONFIG_IDE_H8300) += h8300/ide-h8300.o obj-$(CONFIG_BLK_DEV_IDE) += ide-core.o obj-$(CONFIG_IDE_GENERIC) += ide-generic.o -- cgit v1.2.3 From c03a9278ad96e1e7d144f5f626c6794f050c0ae7 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:55 +0100 Subject: ide: move CONFIG_IDE_ETRAX to drivers/ide/Kconfig * Move ETRAX_IDE and friends from arch/cris/arch-{v10,v32}/drivers/Kconfig to drivers/ide/Kconfig. * Don't force selecting ide-disk and ide-cd device drivers (please handle this through defconfig if necessary). * Make ETRAX_IDE depend on BROKEN for the time being (it doesn't even compile currently). Cc: Mikael Starvik Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/Kconfig | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'drivers') diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index ca8239a2c98..403e3ffca4e 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -882,6 +882,41 @@ config BLK_DEV_IDE_BAST Say Y here if you want to support the onboard IDE channels on the Simtec BAST or the Thorcom VR1000 +config ETRAX_IDE + bool "ETRAX IDE support" + depends on CRIS && BROKEN + select BLK_DEV_IDEDMA + select IDE_GENERIC + help + Enables the ETRAX IDE driver. + + You can't use parallel ports or SCSI ports at the same time. + +config ETRAX_IDE_DELAY + int "Delay for drives to regain consciousness" + depends on ETRAX_IDE && ETRAX_ARCH_V10 + default 15 + help + Number of seconds to wait for IDE drives to spin up after an IDE + reset. + +choice + prompt "IDE reset pin" + depends on ETRAX_IDE && ETRAX_ARCH_V10 + default ETRAX_IDE_PB7_RESET + +config ETRAX_IDE_PB7_RESET + bool "Port_PB_Bit_7" + help + IDE reset on pin 7 on port B + +config ETRAX_IDE_G27_RESET + bool "Port_G_Bit_27" + help + IDE reset on pin 27 on port G + +endchoice + config IDE_H8300 bool "H8300 IDE support" depends on H8300 -- cgit v1.2.3 From e816056210941e9886e447e331b7fdbe133cb5f0 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:55 +0100 Subject: ide-cris: don't override ide_register_hw() result * Don't override ide_register_hw() result and check if there is a hwif available to use. * MAX_HWIFS is user configurable nowadays so replace it by hard-coded value. * Remove the comment about ide_hwifs[]. Acked-by: Mikael Starvik Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/cris/ide-cris.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c index 7f5bc2ee6c7..476e0d65ed4 100644 --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c @@ -773,15 +773,16 @@ init_e100_ide (void) /* the IDE control register is at ATA address 6, with CS1 active instead of CS0 */ ide_offsets[IDE_CONTROL_OFFSET] = cris_ide_reg_addr(6, 1, 0); - /* first fill in some stuff in the ide_hwifs fields */ + for (h = 0; h < 4; h++) { + ide_hwif_t *hwif = NULL; - for(h = 0; h < MAX_HWIFS; h++) { - ide_hwif_t *hwif = &ide_hwifs[h]; ide_setup_ports(&hw, cris_ide_base_address(h), ide_offsets, 0, 0, cris_ide_ack_intr, ide_default_irq(0)); ide_register_hw(&hw, NULL, 1, &hwif); + if (hwif == NULL) + continue; hwif->mmio = 1; hwif->chipset = ide_etrax100; hwif->set_pio_mode = &cris_set_pio_mode; -- cgit v1.2.3 From aca38a5157dec0090ad800d52c138fb83674481f Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 27 Nov 2007 21:35:55 +0100 Subject: drivers/ide: Add missing "space" Signed-off-by: Joe Perches Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ppc/pmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 5afdfef7264..7f7a5988577 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c @@ -1513,7 +1513,7 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) { if (pmif->broken_dma_warn == 0) { - printk(KERN_WARNING "%s: DMA on non aligned address," + printk(KERN_WARNING "%s: DMA on non aligned address, " "switching to PIO on Ohare chipset\n", drive->name); pmif->broken_dma_warn = 1; } -- cgit v1.2.3 From 9130201003cf3a9f3afe830fe8e544018beab61b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 27 Nov 2007 21:35:56 +0100 Subject: amd74xx: arm hack drivers/ide/pci/amd74xx.c: In function `init_hwif_amd74xx': drivers/ide/pci/amd74xx.c:387: error: implicit declaration of function `pci_get_legacy_ide_irq' Cc: Russell King Signed-off-by: Andrew Morton Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 403e3ffca4e..45b22282f14 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -483,6 +483,7 @@ config WDC_ALI15X3 config BLK_DEV_AMD74XX tristate "AMD and nVidia IDE support" + depends on !ARM select BLK_DEV_IDEDMA_PCI help This driver adds explicit support for AMD-7xx and AMD-8111 chips -- cgit v1.2.3 From b0bc65b9aa7d9eb8af4895ed772ef7fe2c10687c Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:56 +0100 Subject: ide: add TORiSAN model: CD-ROM CDR_U200 fw: 1.09 to DMA blacklist Based on the report from snowbat@gmail.com. Fixes kernel bugzilla bug #9195. Tested-by: snowbat@gmail.com Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-dma.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index e3add70b9cd..0d795a1678c 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -130,6 +130,7 @@ static const struct drive_list_entry drive_blacklist [] = { { "_NEC DV5800A", NULL }, { "SAMSUNG CD-ROM SN-124", "N001" }, { "Seagate STT20000A", NULL }, + { "CD-ROM CDR_U200", "1.09" }, { NULL , NULL } }; -- cgit v1.2.3 From d151456a71e2757da4169a6be2eb68ac115b05b0 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:56 +0100 Subject: alim15x3: add Mitac 8317 and derivatives to ali_cable_override() Port of Alan's patch for pata_ali.c. Cc: Alan Cox Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/alim15x3.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers') diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index a607dd31a64..ce293936af4 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c @@ -603,6 +603,11 @@ static int ali_cable_override(struct pci_dev *pdev) pdev->subsystem_device == 0x10AF) return 1; + /* Mitac 8317 (Winbook-A) and relatives */ + if (pdev->subsystem_vendor == 0x1071 && + pdev->subsystem_device == 0x8317) + return 1; + /* Systems by DMI */ if (dmi_check_system(cable_dmi_table)) return 1; -- cgit v1.2.3 From dd0fd40d5488aadfc54a50919471469a31407322 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:56 +0100 Subject: piix: add HP compaq laptop to short cable list Port of Jeff's libata commit 54174db300ee1bac632d62e4ac37fe02e47d1f18 ("[libata] ata_piix: add HP compaq laptop to short cable list"). Cc: Jeff Garzik Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/piix.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index 63625a0be71..27781d294ce 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c @@ -306,6 +306,7 @@ static const struct ich_laptop ich_laptop[] = { { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */ { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ + { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on Acer Aspire 2023WLMi */ /* end marker */ { 0, } -- cgit v1.2.3 From 8a82387cd235d5251890d53c57bf953d24a76831 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:56 +0100 Subject: trm290: remove bogus init_hwif_trm290() comment Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/trm290.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c index 5011ba22e36..0895e753a35 100644 --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c @@ -240,9 +240,6 @@ static int trm290_ide_dma_test_irq (ide_drive_t *drive) return (status == 0x00ff); } -/* - * Invoked from ide-dma.c at boot time. - */ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) { unsigned int cfgbase = 0; -- cgit v1.2.3 From 0546cb045ea487d8702c5ae4da6e0eab7baa17ba Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:57 +0100 Subject: ide: remove bogus ide_fix_driveid() comment Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-iops.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 1cdf688a542..56463297df7 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -303,9 +303,6 @@ void default_hwif_transport(ide_hwif_t *hwif) hwif->atapi_output_bytes = atapi_output_bytes; } -/* - * Beginning of Taskfile OPCODE Library and feature sets. - */ void ide_fix_driveid (struct hd_driveid *id) { #ifndef __LITTLE_ENDIAN -- cgit v1.2.3 From 498f26b45cfc2e16d15f0416a40bc01156c43e92 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Tue, 27 Nov 2007 21:35:57 +0100 Subject: ali14xx: constify __initdata Acked-by: Sergei Shtylyov Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/legacy/ali14xx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index 10311ecc674..38c3a6d63f3 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c @@ -53,12 +53,13 @@ /* port addresses for auto-detection */ #define ALI_NUM_PORTS 4 -static int ports[ALI_NUM_PORTS] __initdata = {0x074, 0x0f4, 0x034, 0x0e4}; +static const int ports[ALI_NUM_PORTS] __initdata = + { 0x074, 0x0f4, 0x034, 0x0e4 }; /* register initialization data */ typedef struct { u8 reg, data; } RegInitializer; -static RegInitializer initData[] __initdata = { +static const RegInitializer initData[] __initdata = { {0x01, 0x0f}, {0x02, 0x00}, {0x03, 0x00}, {0x04, 0x00}, {0x05, 0x00}, {0x06, 0x00}, {0x07, 0x2b}, {0x0a, 0x0f}, {0x25, 0x00}, {0x26, 0x00}, {0x27, 0x00}, {0x28, 0x00}, @@ -177,7 +178,7 @@ static int __init findPort (void) * Initialize controller registers with default values. */ static int __init initRegisters (void) { - RegInitializer *p; + const RegInitializer *p; u8 t; unsigned long flags; -- cgit v1.2.3 From e97564f362a93f8c248246c19828895950341252 Mon Sep 17 00:00:00 2001 From: Peter Missel Date: Tue, 27 Nov 2007 21:35:57 +0100 Subject: ide: More TSST drives with broken cable detection Add more TSST (Toshiba/Samsung) drives to the 'broken cable detection' blacklist. Signed-off-by: Peter Missel (peter.missel@onlinehome.de) Cc: Alan Cox Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/ide-iops.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 56463297df7..5c3256180ae 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -589,6 +589,9 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list); static const struct drive_list_entry ivb_list[] = { { "QUANTUM FIREBALLlct10 05" , "A03.0900" }, { "TSSTcorp CDDVDW SH-S202J" , "SB00" }, + { "TSSTcorp CDDVDW SH-S202J" , "SB01" }, + { "TSSTcorp CDDVDW SH-S202N" , "SB00" }, + { "TSSTcorp CDDVDW SH-S202N" , "SB01" }, { NULL , NULL } }; -- cgit v1.2.3 From 6413f08666830afec21e41e50c28a2c5105ede69 Mon Sep 17 00:00:00 2001 From: Denis Cheng Date: Tue, 27 Nov 2007 21:35:58 +0100 Subject: ide-scsi: use print_hex_dump from these utilities implemented in lib/hexdump.c are more handy, please use this. Bart: - s/KERN_DEBUG/KERN_CONT/ as pointed out by Randy - s/DUMP_PREFIX_OFFSET/DUMP_PREFIX_NONE/ - don't include ASCII dump - respect 80-columns limit Signed-off-by: Denis Cheng Cc: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/scsi/ide-scsi.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 8d0244c2e7d..7a835a35f21 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -242,16 +242,6 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign } } -static void hexdump(u8 *x, int len) -{ - int i; - - printk("[ "); - for (i = 0; i < len; i++) - printk("%x ", x[i]); - printk("]\n"); -} - static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_command) { idescsi_scsi_t *scsi = drive_to_idescsi(drive); @@ -282,7 +272,8 @@ 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); - hexdump(pc->c, 6); + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, pc->c, + 6, 0); } rq->rq_disk = scsi->disk; return ide_do_drive_cmd(drive, rq, ide_preempt); @@ -337,7 +328,8 @@ 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); - hexdump(pc->buffer,16); + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, + pc->buffer, 16, 0); } memcpy((void *) opc->scsi_cmd->sense_buffer, pc->buffer, SCSI_SENSE_BUFFERSIZE); kfree(pc->buffer); @@ -816,10 +808,12 @@ 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); - hexdump(cmd->cmnd, cmd->cmd_len); + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, + cmd->cmnd, cmd->cmd_len, 0); if (memcmp(pc->c, cmd->cmnd, cmd->cmd_len)) { printk ("ide-scsi: %s: que %lu, tsl = ", drive->name, cmd->serial_number); - hexdump(pc->c, 12); + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, + pc->c, 12, 0); } } -- cgit v1.2.3 From 1401b53acc0328d96bacb2a3393d2852699df96b Mon Sep 17 00:00:00 2001 From: Jack Morgenstein Date: Mon, 26 Nov 2007 10:41:19 +0200 Subject: IPoIB: Fix oops if xmit is called when priv->broadcast is NULL If a port goes down, ipoib_ib_dev_down() is invoked -- which flushes the mcasts (clearing priv->broadcast) and clearing the path record cache. If ipoib_start_xmit() is then invoked (before the broadcast group is rejoined), a kernel oops results from attempting to access priv->broadcast, which is still unset. Returning NULL from path_rec_create() if priv->broadcast is NULL is a harmless way of bypassing the problem -- the offending packet is simply discarded "without prejudice." Signed-off-by: Jack Morgenstein Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index a03a65ebcf0..c9f6077b615 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -460,6 +460,9 @@ static struct ipoib_path *path_rec_create(struct net_device *dev, void *gid) struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_path *path; + if (!priv->broadcast) + return NULL; + path = kzalloc(sizeof *path, GFP_ATOMIC); if (!path) return NULL; -- cgit v1.2.3 From 345ee8392dc149ca529f80e40583928977ad592e Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 14 Nov 2007 23:39:42 +0100 Subject: allow LEGACY_PTYS to be set to 0 The count of legacy pty devices can be set by a kernel commandline parameter. For the distro kernel, we would like to disable all pty's by default, but keep the opportunity to request devices on the kernel commandline. Signed-off-by: Kay Sievers Acked-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/char/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index bf18d757b87..a509b8d7978 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -457,7 +457,7 @@ config LEGACY_PTYS config LEGACY_PTY_COUNT int "Maximum number of legacy PTY in use" depends on LEGACY_PTYS - range 1 256 + range 0 256 default "256" ---help--- The maximum number of legacy PTYs that can be used at any one time. -- cgit v1.2.3 From dec13c15445fec29ca9087890895718450e80b95 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Wed, 21 Nov 2007 14:55:18 -0800 Subject: create /sys/.../power when CONFIG_PM is set The CONFIG_SUSPEND changes in 2.6.23 caused a regression under certain configuration conditions (SUSPEND=n, USB_AUTOSUSPEND=y) where all USB device attributes in sysfs (idVendor, idProduct, ...) silently disappeared, causing udev breakage and more. The cause of this is that the /sys/.../power subdirectory is now only created when CONFIG_PM_SLEEP is set, however, it should be created whenever CONFIG_PM is set to handle the above situation. The following patch fixes the regression. Signed-off-by: Daniel Drake Acked-by: Rafael J. Wysocki Cc: Alan Stern Cc: Kay Sievers Cc: stable Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 4 +++- drivers/base/power/Makefile | 3 ++- drivers/base/power/main.c | 8 +------- drivers/base/power/power.h | 28 +++++++++++++++++++++------- 4 files changed, 27 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/base/core.c b/drivers/base/core.c index 3f4d6aa1399..2683eac30c6 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -770,9 +770,10 @@ int device_add(struct device *dev) error = device_add_attrs(dev); if (error) goto AttrsError; - error = device_pm_add(dev); + error = dpm_sysfs_add(dev); if (error) goto PMError; + device_pm_add(dev); error = bus_add_device(dev); if (error) goto BusError; @@ -797,6 +798,7 @@ int device_add(struct device *dev) return error; BusError: device_pm_remove(dev); + dpm_sysfs_remove(dev); PMError: if (dev->bus) blocking_notifier_call_chain(&dev->bus->bus_notifier, diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile index a803733c839..44504e6618f 100644 --- a/drivers/base/power/Makefile +++ b/drivers/base/power/Makefile @@ -1,5 +1,6 @@ obj-y := shutdown.o -obj-$(CONFIG_PM_SLEEP) += main.o sysfs.o +obj-$(CONFIG_PM) += sysfs.o +obj-$(CONFIG_PM_SLEEP) += main.o obj-$(CONFIG_PM_TRACE) += trace.o ifeq ($(CONFIG_DEBUG_DRIVER),y) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 0ab4ab21f56..691ffb64cc3 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -38,20 +38,14 @@ static DEFINE_MUTEX(dpm_list_mtx); int (*platform_enable_wakeup)(struct device *dev, int is_on); -int device_pm_add(struct device *dev) +void device_pm_add(struct device *dev) { - int error; - pr_debug("PM: Adding info for %s:%s\n", dev->bus ? dev->bus->name : "No Bus", kobject_name(&dev->kobj)); mutex_lock(&dpm_list_mtx); list_add_tail(&dev->power.entry, &dpm_active); - error = dpm_sysfs_add(dev); - if (error) - list_del(&dev->power.entry); mutex_unlock(&dpm_list_mtx); - return error; } void device_pm_remove(struct device *dev) diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index 5c4efd493fa..379da4e958e 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h @@ -13,14 +13,29 @@ extern void device_shutdown(void); extern struct list_head dpm_active; /* The active device list */ -static inline struct device * to_device(struct list_head * entry) +static inline struct device *to_device(struct list_head *entry) { return container_of(entry, struct device, power.entry); } -extern int device_pm_add(struct device *); +extern void device_pm_add(struct device *); extern void device_pm_remove(struct device *); +#else /* CONFIG_PM_SLEEP */ + + +static inline void device_pm_add(struct device *dev) +{ +} + +static inline void device_pm_remove(struct device *dev) +{ +} + +#endif + +#ifdef CONFIG_PM + /* * sysfs.c */ @@ -28,16 +43,15 @@ extern void device_pm_remove(struct device *); extern int dpm_sysfs_add(struct device *); extern void dpm_sysfs_remove(struct device *); -#else /* CONFIG_PM_SLEEP */ - +#else /* CONFIG_PM */ -static inline int device_pm_add(struct device * dev) +static inline int dpm_sysfs_add(struct device *dev) { return 0; } -static inline void device_pm_remove(struct device * dev) -{ +static inline void dpm_sysfs_remove(struct device *dev) +{ } #endif -- cgit v1.2.3 From 1011b326b1e7ab86a480c99b4718d16e6d9f1d11 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sat, 27 Oct 2007 03:06:47 +0200 Subject: USB: fix USB_OHCI_HCD_SSB dependencies This patch fixes a bug introduced by commit b22817b3c81cdb18ffe3d2debfee968731a8b5f4. Signed-off-by: Adrian Bunk Cc: Ingo Molnar Cc: Michael Buesch Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 177e78ed241..49a91c5ee51 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -156,7 +156,7 @@ config USB_OHCI_HCD_PCI config USB_OHCI_HCD_SSB bool "OHCI support for Broadcom SSB OHCI core" - depends on USB_OHCI_HCD && (SSB = y || SSB = CONFIG_USB_OHCI_HCD) && EXPERIMENTAL + depends on USB_OHCI_HCD && (SSB = y || SSB = USB_OHCI_HCD) && EXPERIMENTAL default n ---help--- Support for the Sonics Silicon Backplane (SSB) attached -- cgit v1.2.3 From 9cfbba73118e45d935577389976f0d6af1a8e58b Mon Sep 17 00:00:00 2001 From: David Brownell Date: Fri, 26 Oct 2007 13:42:18 -0700 Subject: USB: omap_udc build fix This fixes some build errors ... unclear how this got past earlier tests. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/omap_udc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 87c4f50dfb6..d377154658b 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c @@ -1241,14 +1241,14 @@ static void pullup_enable(struct omap_udc *udc) udc->gadget.dev.parent->power.power_state = PMSG_ON; udc->gadget.dev.power.power_state = PMSG_ON; UDC_SYSCON1_REG |= UDC_PULLUP_EN; - if (!gadget_is_otg(udc->gadget) && !cpu_is_omap15xx()) + if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx()) OTG_CTRL_REG |= OTG_BSESSVLD; UDC_IRQ_EN_REG = UDC_DS_CHG_IE; } static void pullup_disable(struct omap_udc *udc) { - if (!gadget_is_otg(udc->gadget) && !cpu_is_omap15xx()) + if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx()) OTG_CTRL_REG &= ~OTG_BSESSVLD; UDC_IRQ_EN_REG = UDC_DS_CHG_IE; UDC_SYSCON1_REG &= ~UDC_PULLUP_EN; @@ -1386,7 +1386,7 @@ static void update_otg(struct omap_udc *udc) { u16 devstat; - if (!gadget_is_otg(udc->gadget)) + if (!gadget_is_otg(&udc->gadget)) return; if (OTG_CTRL_REG & OTG_ID) -- cgit v1.2.3 From 9e3285dba5cac12d656da66fd7d420ff1bc0ecc0 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 8 Nov 2007 16:45:46 +0900 Subject: USB: pl2303: add support for Corega CG-USBRS232R pl2303: add support for Corega CG-USBRS232R This patch adds support for Corega CG-USBRS232R Serial Adapters. Signed-off-by: Magnus Damm Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/pl2303.c | 1 + drivers/usb/serial/pl2303.h | 3 +++ 2 files changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 2cd3f1d4b68..cf8add91de0 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -86,6 +86,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) }, { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ID) }, { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, + { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) }, { } /* Terminating entry */ }; diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index ed603e3decd..d31f5d29998 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h @@ -104,3 +104,6 @@ #define WS002IN_VENDOR_ID 0x11f6 #define WS002IN_PRODUCT_ID 0x2001 +/* Corega CG-USBRS232R Serial Adapter */ +#define COREGA_VENDOR_ID 0x07aa +#define COREGA_PRODUCT_ID 0x002a -- cgit v1.2.3 From f09e495df27d80ae77005ddb2e93df18ec24d04a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 10 Oct 2007 16:29:02 -0400 Subject: usb-storage: always set the allow_restart flag This patch (as1000) sets the SCSI allow_restart flag for USB disk devices. In theory this should never hurt, and there definitely are devices out there (such as the Seagate 250-GB external drive) which need the flag to be set. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/scsiglue.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 1ba19eaa197..836a34ae6ec 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -177,6 +177,10 @@ static int slave_configure(struct scsi_device *sdev) * is an occasional series of retries that will all fail. */ sdev->retry_hwerror = 1; + /* USB disks should allow restart. Some drives spin down + * automatically, requiring a START-STOP UNIT command. */ + sdev->allow_restart = 1; + } else { /* Non-disk-type devices don't need to blacklist any pages -- cgit v1.2.3 From 2e2c5eea95cfe4f36d708e6f124d9ac050b19fa1 Mon Sep 17 00:00:00 2001 From: Roel Kluin <12o3l@tiscali.nl> Date: Fri, 26 Oct 2007 23:54:35 +0200 Subject: USB: Fix priority mistakes in drivers/usb/core/hub.c Fixes priority mistakes similar to '!x & y' Signed-off-by: Roel Kluin <12o3l@tiscali.nl> Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 036c3dea855..13b326a1337 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -335,7 +335,7 @@ static void kick_khubd(struct usb_hub *hub) to_usb_interface(hub->intfdev)->pm_usage_cnt = 1; spin_lock_irqsave(&hub_event_lock, flags); - if (!hub->disconnected & list_empty(&hub->event_list)) { + if (!hub->disconnected && list_empty(&hub->event_list)) { list_add_tail(&hub->event_list, &hub_event_list); wake_up(&khubd_wait); } -- cgit v1.2.3 From 7ced46c3ad1dfaaabf9ec6c98cbb0a48e080fb11 Mon Sep 17 00:00:00 2001 From: Roel Kluin <12o3l@tiscali.nl> Date: Sat, 27 Oct 2007 03:36:37 +0200 Subject: USB: free memory when writing fails in usb/serial/mos7840.c Free buffer when writing ZLP_REG5 failed Signed-off-by: Roel Kluin <12o3l@tiscali.nl> Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/mos7840.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index a5ced7e08cb..c29c9127113 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -2711,7 +2711,7 @@ static int mos7840_startup(struct usb_serial *serial) status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); if (status < 0) { dbg("Writing ZLP_REG5 failed status-0x%x\n", status); - return -1; + goto error; } else dbg("ZLP_REG5 Writing success status%d\n", status); -- cgit v1.2.3 From ed206ec9ab398e1c3756ff0eb9507db1d009e65f Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Sun, 28 Oct 2007 08:21:59 +0100 Subject: USB: fix usbled disconnect read race #2 usbled has a race where show methods for attributes in sysfs can follow a NULL pointer during disconnect. The correct ordering fixes it. Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/usbled.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c index 49c5c5c4c43..06cb71942dc 100644 --- a/drivers/usb/misc/usbled.c +++ b/drivers/usb/misc/usbled.c @@ -144,12 +144,14 @@ static void led_disconnect(struct usb_interface *interface) struct usb_led *dev; dev = usb_get_intfdata (interface); - usb_set_intfdata (interface, NULL); device_remove_file(&interface->dev, &dev_attr_blue); device_remove_file(&interface->dev, &dev_attr_red); device_remove_file(&interface->dev, &dev_attr_green); + /* first remove the files, then set the pointer to NULL */ + usb_set_intfdata (interface, NULL); + usb_put_dev(dev->udev); kfree(dev); -- cgit v1.2.3 From bfaeafcfc2242277e31cc1cfae687afaac0cd9ec Mon Sep 17 00:00:00 2001 From: Borislav Petkov Date: Sun, 28 Oct 2007 13:24:16 +0100 Subject: usbserial: fix inconsistent lock state In commit acd2a847e7fee7df11817f67dba75a2802793e5d usb_serial_generic_write() disables interrupts when taking &port->lock which is also taken in usb_serial_generic_read_bulk_callback() resulting in an inconsistent lock state due to the latter not disabling interrupts on the local cpu. Fix that by disabling interrupts in the latter call site also. Signed-off-by: Borislav Petkov Acked-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/generic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 9eb4a65ee4d..d41531139c5 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -327,6 +327,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb) struct usb_serial_port *port = (struct usb_serial_port *)urb->context; unsigned char *data = urb->transfer_buffer; int status = urb->status; + unsigned long flags; dbg("%s - port %d", __FUNCTION__, port->number); @@ -339,11 +340,11 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb) usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); /* Throttle the device if requested by tty */ - spin_lock(&port->lock); + spin_lock_irqsave(&port->lock, flags); if (!(port->throttled = port->throttle_req)) /* Handle data and continue reading from device */ flush_and_resubmit_read_urb(port); - spin_unlock(&port->lock); + spin_unlock_irqrestore(&port->lock, flags); } EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); -- cgit v1.2.3 From f08812d5eb8f8cd1a5bd5f5c26a96eb93d97ab69 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Wed, 31 Oct 2007 15:59:30 -0700 Subject: USB: FIx locks and urb->status in adutux (updated) Two main issues fixed here are: - An improper use of in-struct lock to protect an open count - Use of urb status for -EINPROGRESS Also, along the way: - Change usb_unlink_urb to usb_kill_urb. Apparently there's no need to use usb_unlink_urb whatsoever in this driver, and the old use of usb_kill_urb was outright racy (it unlinked and immediately freed). - Fix indentation in adu_write. Looks like it was damaged by a script. - Vitaly wants -EBUSY on multiply opens. - bInterval was taken from a wrong endpoint. Signed-off-by: Pete Zaitcev Signed-off-by: Vitaliy Ivanov Tested-by: Vitaliy Ivanov Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/adutux.c | 262 ++++++++++++++++++++++++---------------------- 1 file changed, 139 insertions(+), 123 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index c567aa7a41e..5a2c44e4c1f 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c @@ -79,12 +79,22 @@ MODULE_DEVICE_TABLE(usb, device_table); #define COMMAND_TIMEOUT (2*HZ) /* 60 second timeout for a command */ +/* + * The locking scheme is a vanilla 3-lock: + * adu_device.buflock: A spinlock, covers what IRQs touch. + * adutux_mutex: A Static lock to cover open_count. It would also cover + * any globals, but we don't have them in 2.6. + * adu_device.mtx: A mutex to hold across sleepers like copy_from_user. + * It covers all of adu_device, except the open_count + * and what .buflock covers. + */ + /* Structure to hold all of our device specific stuff */ struct adu_device { - struct mutex mtx; /* locks this structure */ + struct mutex mtx; struct usb_device* udev; /* save off the usb device pointer */ struct usb_interface* interface; - unsigned char minor; /* the starting minor number for this device */ + unsigned int minor; /* the starting minor number for this device */ char serial_number[8]; int open_count; /* number of times this port has been opened */ @@ -107,8 +117,11 @@ struct adu_device { char* interrupt_out_buffer; struct usb_endpoint_descriptor* interrupt_out_endpoint; struct urb* interrupt_out_urb; + int out_urb_finished; }; +static DEFINE_MUTEX(adutux_mutex); + static struct usb_driver adu_driver; static void adu_debug_data(int level, const char *function, int size, @@ -132,27 +145,31 @@ static void adu_debug_data(int level, const char *function, int size, */ static void adu_abort_transfers(struct adu_device *dev) { - dbg(2," %s : enter", __FUNCTION__); + unsigned long flags; - if (dev == NULL) { - dbg(1," %s : dev is null", __FUNCTION__); - goto exit; - } + dbg(2," %s : enter", __FUNCTION__); if (dev->udev == NULL) { dbg(1," %s : udev is null", __FUNCTION__); goto exit; } - dbg(2," %s : udev state %d", __FUNCTION__, dev->udev->state); - if (dev->udev->state == USB_STATE_NOTATTACHED) { - dbg(1," %s : udev is not attached", __FUNCTION__); - goto exit; - } - /* shutdown transfer */ - usb_unlink_urb(dev->interrupt_in_urb); - usb_unlink_urb(dev->interrupt_out_urb); + + /* XXX Anchor these instead */ + spin_lock_irqsave(&dev->buflock, flags); + if (!dev->read_urb_finished) { + spin_unlock_irqrestore(&dev->buflock, flags); + usb_kill_urb(dev->interrupt_in_urb); + } else + spin_unlock_irqrestore(&dev->buflock, flags); + + spin_lock_irqsave(&dev->buflock, flags); + if (!dev->out_urb_finished) { + spin_unlock_irqrestore(&dev->buflock, flags); + usb_kill_urb(dev->interrupt_out_urb); + } else + spin_unlock_irqrestore(&dev->buflock, flags); exit: dbg(2," %s : leave", __FUNCTION__); @@ -162,8 +179,6 @@ static void adu_delete(struct adu_device *dev) { dbg(2, "%s enter", __FUNCTION__); - adu_abort_transfers(dev); - /* free data structures */ usb_free_urb(dev->interrupt_in_urb); usb_free_urb(dev->interrupt_out_urb); @@ -239,7 +254,10 @@ static void adu_interrupt_out_callback(struct urb *urb) goto exit; } - wake_up_interruptible(&dev->write_wait); + spin_lock(&dev->buflock); + dev->out_urb_finished = 1; + wake_up(&dev->write_wait); + spin_unlock(&dev->buflock); exit: adu_debug_data(5, __FUNCTION__, urb->actual_length, @@ -252,12 +270,17 @@ static int adu_open(struct inode *inode, struct file *file) struct adu_device *dev = NULL; struct usb_interface *interface; int subminor; - int retval = 0; + int retval; dbg(2,"%s : enter", __FUNCTION__); subminor = iminor(inode); + if ((retval = mutex_lock_interruptible(&adutux_mutex))) { + dbg(2, "%s : mutex lock failed", __FUNCTION__); + goto exit_no_lock; + } + interface = usb_find_interface(&adu_driver, subminor); if (!interface) { err("%s - error, can't find device for minor %d", @@ -267,54 +290,54 @@ static int adu_open(struct inode *inode, struct file *file) } dev = usb_get_intfdata(interface); - if (!dev) { + if (!dev || !dev->udev) { retval = -ENODEV; goto exit_no_device; } - /* lock this device */ - if ((retval = mutex_lock_interruptible(&dev->mtx))) { - dbg(2, "%s : mutex lock failed", __FUNCTION__); + /* check that nobody else is using the device */ + if (dev->open_count) { + retval = -EBUSY; goto exit_no_device; } - /* increment our usage count for the device */ ++dev->open_count; dbg(2,"%s : open count %d", __FUNCTION__, dev->open_count); /* save device in the file's private structure */ file->private_data = dev; - if (dev->open_count == 1) { - /* initialize in direction */ - dev->read_buffer_length = 0; + /* initialize in direction */ + dev->read_buffer_length = 0; - /* fixup first read by having urb waiting for it */ - usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, - usb_rcvintpipe(dev->udev, - dev->interrupt_in_endpoint->bEndpointAddress), - dev->interrupt_in_buffer, - le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), - adu_interrupt_in_callback, dev, - dev->interrupt_in_endpoint->bInterval); - /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */ - dev->read_urb_finished = 0; - retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL); - if (retval) - --dev->open_count; - } - mutex_unlock(&dev->mtx); + /* fixup first read by having urb waiting for it */ + usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, + usb_rcvintpipe(dev->udev, + dev->interrupt_in_endpoint->bEndpointAddress), + dev->interrupt_in_buffer, + le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), + adu_interrupt_in_callback, dev, + dev->interrupt_in_endpoint->bInterval); + dev->read_urb_finished = 0; + if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL)) + dev->read_urb_finished = 1; + /* we ignore failure */ + /* end of fixup for first read */ + + /* initialize out direction */ + dev->out_urb_finished = 1; + + retval = 0; exit_no_device: + mutex_unlock(&adutux_mutex); +exit_no_lock: dbg(2,"%s : leave, return value %d ", __FUNCTION__, retval); - return retval; } -static int adu_release_internal(struct adu_device *dev) +static void adu_release_internal(struct adu_device *dev) { - int retval = 0; - dbg(2," %s : enter", __FUNCTION__); /* decrement our usage count for the device */ @@ -326,12 +349,11 @@ static int adu_release_internal(struct adu_device *dev) } dbg(2," %s : leave", __FUNCTION__); - return retval; } static int adu_release(struct inode *inode, struct file *file) { - struct adu_device *dev = NULL; + struct adu_device *dev; int retval = 0; dbg(2," %s : enter", __FUNCTION__); @@ -343,15 +365,13 @@ static int adu_release(struct inode *inode, struct file *file) } dev = file->private_data; - if (dev == NULL) { dbg(1," %s : object is NULL", __FUNCTION__); retval = -ENODEV; goto exit; } - /* lock our device */ - mutex_lock(&dev->mtx); /* not interruptible */ + mutex_lock(&adutux_mutex); /* not interruptible */ if (dev->open_count <= 0) { dbg(1," %s : device not opened", __FUNCTION__); @@ -359,19 +379,15 @@ static int adu_release(struct inode *inode, struct file *file) goto exit; } + adu_release_internal(dev); if (dev->udev == NULL) { /* the device was unplugged before the file was released */ - mutex_unlock(&dev->mtx); - adu_delete(dev); - dev = NULL; - } else { - /* do the work */ - retval = adu_release_internal(dev); + if (!dev->open_count) /* ... and we're the last user */ + adu_delete(dev); } exit: - if (dev) - mutex_unlock(&dev->mtx); + mutex_unlock(&adutux_mutex); dbg(2," %s : leave, return value %d", __FUNCTION__, retval); return retval; } @@ -393,12 +409,12 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, dev = file->private_data; dbg(2," %s : dev=%p", __FUNCTION__, dev); - /* lock this object */ + if (mutex_lock_interruptible(&dev->mtx)) return -ERESTARTSYS; /* verify that the device wasn't unplugged */ - if (dev->udev == NULL || dev->minor == 0) { + if (dev->udev == NULL) { retval = -ENODEV; err("No device or device unplugged %d", retval); goto exit; @@ -452,7 +468,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, should_submit = 1; } else { /* even the primary was empty - we may need to do IO */ - if (dev->interrupt_in_urb->status == -EINPROGRESS) { + if (!dev->read_urb_finished) { /* somebody is doing IO */ spin_unlock_irqrestore(&dev->buflock, flags); dbg(2," %s : submitted already", __FUNCTION__); @@ -460,6 +476,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, /* we must initiate input */ dbg(2," %s : initiate input", __FUNCTION__); dev->read_urb_finished = 0; + spin_unlock_irqrestore(&dev->buflock, flags); usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, usb_rcvintpipe(dev->udev, @@ -469,15 +486,12 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, adu_interrupt_in_callback, dev, dev->interrupt_in_endpoint->bInterval); - retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC); - if (!retval) { - spin_unlock_irqrestore(&dev->buflock, flags); - dbg(2," %s : submitted OK", __FUNCTION__); - } else { + retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL); + if (retval) { + dev->read_urb_finished = 1; if (retval == -ENOMEM) { retval = bytes_read ? bytes_read : -ENOMEM; } - spin_unlock_irqrestore(&dev->buflock, flags); dbg(2," %s : submit failed", __FUNCTION__); goto exit; } @@ -486,10 +500,14 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, /* we wait for I/O to complete */ set_current_state(TASK_INTERRUPTIBLE); add_wait_queue(&dev->read_wait, &wait); - if (!dev->read_urb_finished) + spin_lock_irqsave(&dev->buflock, flags); + if (!dev->read_urb_finished) { + spin_unlock_irqrestore(&dev->buflock, flags); timeout = schedule_timeout(COMMAND_TIMEOUT); - else + } else { + spin_unlock_irqrestore(&dev->buflock, flags); set_current_state(TASK_RUNNING); + } remove_wait_queue(&dev->read_wait, &wait); if (timeout <= 0) { @@ -509,19 +527,23 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, retval = bytes_read; /* if the primary buffer is empty then use it */ - if (should_submit && !dev->interrupt_in_urb->status==-EINPROGRESS) { + spin_lock_irqsave(&dev->buflock, flags); + if (should_submit && dev->read_urb_finished) { + dev->read_urb_finished = 0; + spin_unlock_irqrestore(&dev->buflock, flags); usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, usb_rcvintpipe(dev->udev, dev->interrupt_in_endpoint->bEndpointAddress), - dev->interrupt_in_buffer, - le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), - adu_interrupt_in_callback, - dev, - dev->interrupt_in_endpoint->bInterval); - /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */ - dev->read_urb_finished = 0; - usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL); + dev->interrupt_in_buffer, + le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), + adu_interrupt_in_callback, + dev, + dev->interrupt_in_endpoint->bInterval); + if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL) != 0) + dev->read_urb_finished = 1; /* we ignore failure */ + } else { + spin_unlock_irqrestore(&dev->buflock, flags); } exit: @@ -535,24 +557,24 @@ exit: static ssize_t adu_write(struct file *file, const __user char *buffer, size_t count, loff_t *ppos) { + DECLARE_WAITQUEUE(waita, current); struct adu_device *dev; size_t bytes_written = 0; size_t bytes_to_write; size_t buffer_size; + unsigned long flags; int retval; - int timeout = 0; dbg(2," %s : enter, count = %Zd", __FUNCTION__, count); dev = file->private_data; - /* lock this object */ retval = mutex_lock_interruptible(&dev->mtx); if (retval) goto exit_nolock; /* verify that the device wasn't unplugged */ - if (dev->udev == NULL || dev->minor == 0) { + if (dev->udev == NULL) { retval = -ENODEV; err("No device or device unplugged %d", retval); goto exit; @@ -564,42 +586,37 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, goto exit; } - while (count > 0) { - if (dev->interrupt_out_urb->status == -EINPROGRESS) { - timeout = COMMAND_TIMEOUT; + add_wait_queue(&dev->write_wait, &waita); + set_current_state(TASK_INTERRUPTIBLE); + spin_lock_irqsave(&dev->buflock, flags); + if (!dev->out_urb_finished) { + spin_unlock_irqrestore(&dev->buflock, flags); - while (timeout > 0) { - if (signal_pending(current)) { + mutex_unlock(&dev->mtx); + if (signal_pending(current)) { dbg(1," %s : interrupted", __FUNCTION__); + set_current_state(TASK_RUNNING); retval = -EINTR; - goto exit; + goto exit_onqueue; } - mutex_unlock(&dev->mtx); - timeout = interruptible_sleep_on_timeout(&dev->write_wait, timeout); + if (schedule_timeout(COMMAND_TIMEOUT) == 0) { + dbg(1, "%s - command timed out.", __FUNCTION__); + retval = -ETIMEDOUT; + goto exit_onqueue; + } + remove_wait_queue(&dev->write_wait, &waita); retval = mutex_lock_interruptible(&dev->mtx); if (retval) { retval = bytes_written ? bytes_written : retval; goto exit_nolock; } - if (timeout > 0) { - break; - } - dbg(1," %s : interrupted timeout: %d", __FUNCTION__, timeout); - } - - - dbg(1," %s : final timeout: %d", __FUNCTION__, timeout); - - if (timeout == 0) { - dbg(1, "%s - command timed out.", __FUNCTION__); - retval = -ETIMEDOUT; - goto exit; - } - - dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count); + dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count); } else { + spin_unlock_irqrestore(&dev->buflock, flags); + set_current_state(TASK_RUNNING); + remove_wait_queue(&dev->write_wait, &waita); dbg(4," %s : sending, count = %Zd", __FUNCTION__, count); /* write the data into interrupt_out_buffer from userspace */ @@ -622,11 +639,12 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, bytes_to_write, adu_interrupt_out_callback, dev, - dev->interrupt_in_endpoint->bInterval); - /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */ + dev->interrupt_out_endpoint->bInterval); dev->interrupt_out_urb->actual_length = bytes_to_write; + dev->out_urb_finished = 0; retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); if (retval < 0) { + dev->out_urb_finished = 1; err("Couldn't submit interrupt_out_urb %d", retval); goto exit; } @@ -637,16 +655,17 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, bytes_written += bytes_to_write; } } - - retval = bytes_written; + mutex_unlock(&dev->mtx); + return bytes_written; exit: - /* unlock the device */ mutex_unlock(&dev->mtx); exit_nolock: - dbg(2," %s : leave, return value %d", __FUNCTION__, retval); + return retval; +exit_onqueue: + remove_wait_queue(&dev->write_wait, &waita); return retval; } @@ -831,25 +850,22 @@ static void adu_disconnect(struct usb_interface *interface) dbg(2," %s : enter", __FUNCTION__); dev = usb_get_intfdata(interface); - usb_set_intfdata(interface, NULL); + mutex_lock(&dev->mtx); /* not interruptible */ + dev->udev = NULL; /* poison */ minor = dev->minor; - - /* give back our minor */ usb_deregister_dev(interface, &adu_class); - dev->minor = 0; + mutex_unlock(&dev->mtx); - mutex_lock(&dev->mtx); /* not interruptible */ + mutex_lock(&adutux_mutex); + usb_set_intfdata(interface, NULL); /* if the device is not opened, then we clean up right now */ dbg(2," %s : open count %d", __FUNCTION__, dev->open_count); - if (!dev->open_count) { - mutex_unlock(&dev->mtx); + if (!dev->open_count) adu_delete(dev); - } else { - dev->udev = NULL; - mutex_unlock(&dev->mtx); - } + + mutex_unlock(&adutux_mutex); dev_info(&interface->dev, "ADU device adutux%d now disconnected\n", (minor - ADU_MINOR_BASE)); -- cgit v1.2.3 From 034fec2e75e97a5429512a6daf2c605a4829853d Mon Sep 17 00:00:00 2001 From: Mike Pagano Date: Thu, 1 Nov 2007 10:53:43 -0700 Subject: USB: add support for an older firmware revision for the Nikon D200 This is a resubmission of the patch to upgrade the unusual_devs.h file to support an older firmware revision of the Nikon D200. This patch includes the requested /proc/bus/usb/devices information. T: Bus=01 Lev=01 Prnt=01 Port=09 Cnt=02 Dev#= 6 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=04b0 ProdID=040f Rev= 1.00 S: Manufacturer=NIKON S: Product=NIKON DSC D200 S: SerialNumber=0000000 C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 2mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms Signed-off-by: Mike Pagano Signed-off-by: Phil Dibowitz Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 22ab2380367..7398229c525 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -342,11 +342,11 @@ UNUSUAL_DEV( 0x04b0, 0x040d, 0x0100, 0x0100, US_FL_FIX_CAPACITY), /* Reported by Graber and Mike Pagano */ -UNUSUAL_DEV( 0x04b0, 0x040f, 0x0200, 0x0200, - "NIKON", - "NIKON DSC D200", - US_SC_DEVICE, US_PR_DEVICE, NULL, - US_FL_FIX_CAPACITY), +UNUSUAL_DEV( 0x04b0, 0x040f, 0x0100, 0x0200, + "NIKON", + "NIKON DSC D200", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_FIX_CAPACITY), /* Reported by Emil Larsson */ UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0101, -- cgit v1.2.3 From 9e3e31046fc4e994583b1197eeefb26811bc9364 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 7 Nov 2007 16:27:23 -0800 Subject: USB: fix directory references in usb/README Another one in the "ok, this is trivial to fix" list... :-) [PATCH] fix directory references in usb/README Signed-off-by: Dirk Hohndel Signed-off-by: Greg Kroah-Hartman --- drivers/usb/README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/README b/drivers/usb/README index 3c843412855..284f46b3e1c 100644 --- a/drivers/usb/README +++ b/drivers/usb/README @@ -39,12 +39,12 @@ first subdirectory in the list below that it fits into. image/ - This is for still image drivers, like scanners or digital cameras. -input/ - This is for any driver that uses the input subsystem, +../input/ - This is for any driver that uses the input subsystem, like keyboard, mice, touchscreens, tablets, etc. -media/ - This is for multimedia drivers, like video cameras, +../media/ - This is for multimedia drivers, like video cameras, radios, and any other drivers that talk to the v4l subsystem. -net/ - This is for network drivers. +../net/ - This is for network drivers. serial/ - This is for USB to serial drivers. storage/ - This is for USB mass-storage drivers. class/ - This is for all USB device drivers that do not fit -- cgit v1.2.3 From ddc1fd6ac1f3ad3275e19451fb07d2eff249161c Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 21 Nov 2007 15:13:10 -0800 Subject: USB HCD: avoid duplicate local_irq_disable() Arnd Bergmann wrote: usb_hcd_flush_endpoint() has a retry loop that starts with a spin_lock_irq(), but only gives up the spinlock, not the irq_disable before jumping to the rescan label. Alan Stern: I agree with your sentiment, but it would be better to solve this problem without using local_irq_disable(). Signed-off-by: Alan Stern Cc: Arnd Bergmann Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index fea8256a18d..d5ed3fa9e30 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1311,8 +1311,8 @@ void usb_hcd_flush_endpoint(struct usb_device *udev, hcd = bus_to_hcd(udev->bus); /* No more submits can occur */ -rescan: spin_lock_irq(&hcd_urb_list_lock); +rescan: list_for_each_entry (urb, &ep->urb_list, urb_list) { int is_in; @@ -1345,6 +1345,7 @@ rescan: usb_put_urb (urb); /* list contents may have changed */ + spin_lock(&hcd_urb_list_lock); goto rescan; } spin_unlock_irq(&hcd_urb_list_lock); -- cgit v1.2.3 From 5fdcd0396be443e36a4e2128f51818acca570ee7 Mon Sep 17 00:00:00 2001 From: "agilmore@wirelessbeehive.com" Date: Tue, 20 Nov 2007 13:39:03 -0700 Subject: USB: sierra: new product id Per the maintainer of the usbserial/sierra.c driver, the patch below adds a new id to the list of supported cards for the sierra driver. Tested and working for me on Fedora 8, kernel 2.6.23 and on the more recent sierra.c available in http://www.sierrawireless.com/resources/support/Software/Linux/v.1.2.6b(kernel2.6.21).zip Hardware is a MiniPCI card in a Lenovo T61p. Signed-off-by: Andrew Gilmore Cc: Kevin Lloyd Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/sierra.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 833f6e1e372..605ebccdcd5 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -136,6 +136,8 @@ static struct usb_device_id id_table_3port [] = { { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ { 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 7e61559f6199bb387037abfc7d10a893973561fc Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 6 Nov 2007 11:43:42 -0500 Subject: USB: keep track of whether interface sysfs files exist This patch (as1009) solves the problem of multiple registrations for USB sysfs files in a more satisfying way than the existing code. It simply adds a flag to keep track of whether or not the files have been created; that way the files can be created or removed as needed. Signed-off-by: Alan Stern --- drivers/usb/core/message.c | 12 ++---------- drivers/usb/core/sysfs.c | 6 ++++++ 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 316a746e008..40fd39de5bf 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1172,7 +1172,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) struct usb_host_interface *alt; int ret; int manual = 0; - int changed; if (dev->state == USB_STATE_SUSPENDED) return -EHOSTUNREACH; @@ -1212,8 +1211,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) */ /* prevent submissions using previous endpoint settings */ - changed = (iface->cur_altsetting != alt); - if (changed && device_is_registered(&iface->dev)) + if (iface->cur_altsetting != alt && device_is_registered(&iface->dev)) usb_remove_sysfs_intf_files(iface); usb_disable_interface(dev, iface); @@ -1250,7 +1248,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) * (Likewise, EP0 never "halts" on well designed devices.) */ usb_enable_interface(dev, iface); - if (changed && device_is_registered(&iface->dev)) + if (device_is_registered(&iface->dev)) usb_create_sysfs_intf_files(iface); return 0; @@ -1641,12 +1639,6 @@ free_interfaces: intf->dev.bus_id, ret); continue; } - - /* The driver's probe method can call usb_set_interface(), - * which would mean the interface's sysfs files are already - * created. Just in case, we'll remove them first. - */ - usb_remove_sysfs_intf_files(intf); usb_create_sysfs_intf_files(intf); } diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index b04afd06e50..32bd130b1ee 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -735,6 +735,8 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf) struct usb_host_interface *alt = intf->cur_altsetting; int retval; + if (intf->sysfs_files_created) + return 0; retval = sysfs_create_group(&dev->kobj, &intf_attr_grp); if (retval) return retval; @@ -746,6 +748,7 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf) if (intf->intf_assoc) retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp); usb_create_intf_ep_files(intf, udev); + intf->sysfs_files_created = 1; return 0; } @@ -753,8 +756,11 @@ void usb_remove_sysfs_intf_files(struct usb_interface *intf) { struct device *dev = &intf->dev; + if (!intf->sysfs_files_created) + return; usb_remove_intf_ep_files(intf); device_remove_file(dev, &dev_attr_interface); sysfs_remove_group(&dev->kobj, &intf_attr_grp); sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp); + intf->sysfs_files_created = 0; } -- cgit v1.2.3 From 4a9bee8256a2dec26290a3bfff86ab86b8992547 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 6 Nov 2007 15:01:52 -0500 Subject: USB: uevent environment key fix This patch (as1010) was written by both Kay Sievers and me. It solves the problem of duplicated keys in USB uevent structures by refactoring the uevent subroutines, taking advantage of the way the hotplug core calls uevent handlers for the device's bus and for the device's type. Keys needed for both USB-device and USB-interface events are added in usb_uevent(), which is the bus handler. Keys appropriate only for USB-device or USB-interface events are added in usb_dev_uevent() or usb_if_uevent() respectively, the type handlers. In addition, unnecessary tests for NULL pointers are removed as are duplicated debugging log statements. Signed-off-by: Alan Stern Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/driver.c | 11 ----------- drivers/usb/core/message.c | 24 ------------------------ drivers/usb/core/usb.c | 25 +++++++++++++++++++++++++ 3 files changed, 25 insertions(+), 35 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 8586817698a..c51f8e9312e 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -585,9 +585,6 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) { struct usb_device *usb_dev; - if (!dev) - return -ENODEV; - /* driver is often null here; dev_dbg() would oops */ pr_debug ("usb %s: uevent\n", dev->bus_id); @@ -631,14 +628,6 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) usb_dev->descriptor.bDeviceProtocol)) return -ENOMEM; - if (add_uevent_var(env, "BUSNUM=%03d", - usb_dev->bus->busnum)) - return -ENOMEM; - - if (add_uevent_var(env, "DEVNUM=%03d", - usb_dev->devnum)) - return -ENOMEM; - return 0; } diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 40fd39de5bf..fcd40ecbeec 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1346,34 +1346,10 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) struct usb_interface *intf; struct usb_host_interface *alt; - if (!dev) - return -ENODEV; - - /* driver is often null here; dev_dbg() would oops */ - pr_debug ("usb %s: uevent\n", dev->bus_id); - intf = to_usb_interface(dev); usb_dev = interface_to_usbdev(intf); alt = intf->cur_altsetting; -#ifdef CONFIG_USB_DEVICEFS - if (add_uevent_var(env, "DEVICE=/proc/bus/usb/%03d/%03d", - usb_dev->bus->busnum, usb_dev->devnum)) - return -ENOMEM; -#endif - - if (add_uevent_var(env, "PRODUCT=%x/%x/%x", - le16_to_cpu(usb_dev->descriptor.idVendor), - le16_to_cpu(usb_dev->descriptor.idProduct), - le16_to_cpu(usb_dev->descriptor.bcdDevice))) - return -ENOMEM; - - if (add_uevent_var(env, "TYPE=%d/%d/%d", - usb_dev->descriptor.bDeviceClass, - usb_dev->descriptor.bDeviceSubClass, - usb_dev->descriptor.bDeviceProtocol)) - return -ENOMEM; - if (add_uevent_var(env, "INTERFACE=%d/%d/%d", alt->desc.bInterfaceClass, alt->desc.bInterfaceSubClass, diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index c4a6f1095b8..8f142370103 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -192,9 +192,34 @@ static void usb_release_dev(struct device *dev) kfree(udev); } +#ifdef CONFIG_HOTPLUG +static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + struct usb_device *usb_dev; + + usb_dev = to_usb_device(dev); + + if (add_uevent_var(env, "BUSNUM=%03d", usb_dev->bus->busnum)) + return -ENOMEM; + + if (add_uevent_var(env, "DEVNUM=%03d", usb_dev->devnum)) + return -ENOMEM; + + return 0; +} + +#else + +static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + return -ENODEV; +} +#endif /* CONFIG_HOTPLUG */ + struct device_type usb_device_type = { .name = "usb_device", .release = usb_release_dev, + .uevent = usb_dev_uevent, }; #ifdef CONFIG_PM -- cgit v1.2.3 From 5cf1973a44bd298e3cfce6f6af8faa8c9d0a6d55 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Mon, 12 Nov 2007 14:08:43 +0100 Subject: USB: make the microtek driver and HAL cooperate to make HAL like the microtek driver's devices the parent must be correctly set. Signed-off-by: Oliver Neukum Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/image/microtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index 91e999c9f68..bc207e3c21f 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c @@ -819,7 +819,7 @@ static int mts_usb_probe(struct usb_interface *intf, goto out_kfree2; new_desc->host->hostdata[0] = (unsigned long)new_desc; - if (scsi_add_host(new_desc->host, NULL)) { + if (scsi_add_host(new_desc->host, &dev->dev)) { err_retval = -EIO; goto out_host_put; } -- cgit v1.2.3 From 1cb52658b4f5b10a9e91f8e1c21ca2bcc1b9a3ca Mon Sep 17 00:00:00 2001 From: David Brownell Date: Tue, 13 Nov 2007 16:22:30 -0800 Subject: USB: fix up EHCI startup synchronization A recent patch added software synchronization during EHCI startup, so ports aren't switched away from the companion controllers after resets have started. This patch adds a short delay letting hardware finish that port switching before any new resets begin ... so both ends of that hardware race window are closed. Signed-off-by: David Brownell Cc: Dave Miller Cc: Dely Sy Cc: stable Cc: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-hcd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index c1514442883..5f2d74ed5ad 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -575,12 +575,15 @@ static int ehci_run (struct usb_hcd *hcd) * from the companions to the EHCI controller. If any of the * companions are in the middle of a port reset at the time, it * could cause trouble. Write-locking ehci_cf_port_reset_rwsem - * guarantees that no resets are in progress. + * guarantees that no resets are in progress. After we set CF, + * a short delay lets the hardware catch up; new resets shouldn't + * be started before the port switching actions could complete. */ down_write(&ehci_cf_port_reset_rwsem); hcd->state = HC_STATE_RUNNING; ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ + msleep(5); up_write(&ehci_cf_port_reset_rwsem); temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); -- cgit v1.2.3 From f1e8de0dbb9ee30cd6eb9c510249847d28443cb1 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Mon, 26 Nov 2007 10:23:05 -0500 Subject: USB: usb-storage: unusual_devs entry for JetFlash TS1GJF2A This patch (as1018) adds an unusual_devs entry for the JetFlash TS1GJF2A. This device doesn't like read requests for more than 188 sectors. Setting max_sectors down to 64 is overkill, but at least it will work without errors. For the torturous debugging history, see this thread: http://marc.info/?t=118745764700005&r=1&w=2 Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 7398229c525..2c27721bd25 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -731,6 +731,13 @@ UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102, US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ), #endif +/* Reported by RTE */ +UNUSUAL_DEV( 0x058f, 0x6387, 0x0141, 0x0141, + "JetFlash", + "TS1GJF2A/120", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_MAX_SECTORS_64 ), + /* Fabrizio Fellini */ UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, "Fujifilm", -- cgit v1.2.3 From 899d566a6e7533cb5ad613a656c7f53a2b88abcd Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 19 Nov 2007 22:28:13 +0000 Subject: USB: s3c2410 gadget: Header move fixups Fixup the fallout from the arch moves earlier in the kernel series. Signed-off-by: Ben Dooks Acked-by: David Brownell --- drivers/usb/gadget/s3c2410_udc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index e3e90f8a75e..9780f86ae8e 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c @@ -52,10 +52,10 @@ #include #include -#include #include -#include -#include + +#include +#include #include -- cgit v1.2.3 From 8802bca4feed9e60d22a91cc5ccb1c4a1d8e3d71 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 19 Nov 2007 22:28:14 +0000 Subject: USB: s3c2410 gadget: allow sharing of vbus irq If another driver wants to claim the vbus pin, say to notify the user of an connect/disconnect then allow the IRQ to be shared by specifiying IRQ_SHARED in the flags. Signed-off-by: Ben Dooks Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/s3c2410_udc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 9780f86ae8e..5acaddabbe8 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c @@ -1872,9 +1872,9 @@ static int s3c2410_udc_probe(struct platform_device *pdev) if (udc_info && udc_info->vbus_pin > 0) { irq = s3c2410_gpio_getirq(udc_info->vbus_pin); retval = request_irq(irq, s3c2410_udc_vbus_irq, - IRQF_DISABLED | IRQF_TRIGGER_RISING - | IRQF_TRIGGER_FALLING, - gadget_name, udc); + IRQF_DISABLED | IRQF_TRIGGER_RISING + | IRQF_TRIGGER_FALLING | IRQF_SHARED, + gadget_name, udc); if (retval != 0) { dev_err(dev, "can't get vbus irq %i, err %d\n", -- cgit v1.2.3 From 5f629ad7e5f9b99c6d025bf199d402734bd72d0f Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 19 Nov 2007 22:28:15 +0000 Subject: USB: s3c2410 gadget: ensure vbus pin in input mode during read Some CPUs in the S3C24XX series do not support readback of the value of a pin when the pin has been configured to an IRQ. Signed-off-by: Ben Dooks Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/s3c2410_udc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 5acaddabbe8..4ce050c3d13 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c @@ -1511,7 +1511,11 @@ static irqreturn_t s3c2410_udc_vbus_irq(int irq, void *_dev) unsigned int value; dprintk(DEBUG_NORMAL, "%s()\n", __func__); + + /* some cpus cannot read from an line configured to IRQ! */ + s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_INPUT); value = s3c2410_gpio_getpin(udc_info->vbus_pin); + s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_SFN2); if (udc_info->vbus_pin_inverted) value = !value; -- cgit v1.2.3 From bf164410d08dc83df416e3a6a43ab29bf88890ed Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Fri, 2 Nov 2007 15:14:28 -0500 Subject: PCI: pcie portdriver: initialize returned value The pcie protdrv status can be returned uninitialized, if there are no children under a device. This leads to bad responses downstream. Fix this. Signed-off-by: Linas Vepstas Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pcie/portdrv_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index df383645e36..26057f98f72 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -217,7 +217,7 @@ static int slot_reset_iter(struct device *device, void *data) static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev) { - pci_ers_result_t status; + pci_ers_result_t status = PCI_ERS_RESULT_NONE; int retval; /* If fatal, restore cfg space for possible link reset at upstream */ -- cgit v1.2.3 From 151fc5dfc87964e85a1cbbb9cc2c0703c017c2ed Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 20 Nov 2007 08:41:16 +0100 Subject: PCI: drivers/pci/pci-sysfs.c: Add missing pci_dev_put There should be a pci_dev_put when breaking out of a loop that iterates over calls to pci_get_device and similar functions. This was fixed using the following semantic patch. // @@ identifier d; type T; expression e; iterator for_each_pci_dev; @@ T *d; ... for_each_pci_dev(d) {... when != pci_dev_put(d) when != e = d ( return d; | + pci_dev_put(d); ? return ...; ) ...} // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci-sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 1b7b2812bf2..7d1877341aa 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -702,8 +702,10 @@ static int __init pci_sysfs_init(void) sysfs_initialized = 1; for_each_pci_dev(pdev) { retval = pci_create_sysfs_dev_files(pdev); - if (retval) + if (retval) { + pci_dev_put(pdev); return retval; + } } return 0; -- cgit v1.2.3 From d885c6b75b60e0df8ab65c82d0c81f4238e664ce Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 28 Nov 2007 09:04:23 -0800 Subject: pci-aer: fix kernel-doc mistakes Fix kernel-doc parameter names and ending block comments (change **/ to */). Signed-off-by: Randy Dunlap Acked-by: Linas Vepstas Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pcie/aer/aerdrv_core.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index 92a8469b21b..3c0d8d138f5 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c @@ -168,11 +168,11 @@ static int find_device_iter(struct device *device, void *data) /** * find_source_device - search through device hierarchy for source device - * @p_dev: pointer to Root Port pci_dev data structure + * @parent: pointer to Root Port pci_dev data structure * @id: device ID of agent who sends an error message to this Root Port * * Invoked when error is detected at the Root Port. - **/ + */ static struct device* find_source_device(struct pci_dev *parent, u16 id) { struct pci_dev *dev = parent; @@ -286,14 +286,15 @@ static void report_resume(struct pci_dev *dev, void *data) /** * broadcast_error_message - handle message broadcast to downstream drivers - * @device: pointer to from where in a hierarchy message is broadcasted down - * @api: callback to be broadcasted + * @dev: pointer to from where in a hierarchy message is broadcasted down * @state: error state + * @error_mesg: message to print + * @cb: callback to be broadcasted * * Invoked during error recovery process. Once being invoked, the content * of error severity will be broadcasted to all downstream drivers in a * hierarchy in question. - **/ + */ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, enum pci_channel_state state, char *error_mesg, @@ -428,7 +429,7 @@ static pci_ers_result_t reset_link(struct pcie_device *aerdev, * Invoked when an error is nonfatal/fatal. Once being invoked, broadcast * error detected message to all downstream drivers within a hierarchy in * question and return the returned code. - **/ + */ static pci_ers_result_t do_recovery(struct pcie_device *aerdev, struct pci_dev *dev, int severity) @@ -488,7 +489,7 @@ static pci_ers_result_t do_recovery(struct pcie_device *aerdev, * @info: comprehensive error information * * Invoked when an error being detected by Root Port. - **/ + */ static void handle_error_source(struct pcie_device * aerdev, struct pci_dev *dev, struct aer_err_info info) @@ -521,7 +522,7 @@ static void handle_error_source(struct pcie_device * aerdev, * @rpc: pointer to a Root Port data structure * * Invoked when PCIE bus loads AER service driver. - **/ + */ void aer_enable_rootport(struct aer_rpc *rpc) { struct pci_dev *pdev = rpc->rpd->port; @@ -569,7 +570,7 @@ void aer_enable_rootport(struct aer_rpc *rpc) * @rpc: pointer to a Root Port data structure * * Invoked when PCIE bus unloads AER service driver. - **/ + */ static void disable_root_aer(struct aer_rpc *rpc) { struct pci_dev *pdev = rpc->rpd->port; @@ -590,7 +591,7 @@ static void disable_root_aer(struct aer_rpc *rpc) * @rpc: pointer to the root port which holds an error * * Invoked by DPC handler to consume an error. - **/ + */ static struct aer_err_source* get_e_source(struct aer_rpc *rpc) { struct aer_err_source *e_source; @@ -655,7 +656,7 @@ static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) * aer_isr_one_error - consume an error detected by root port * @p_device: pointer to error root port service device * @e_src: pointer to an error source - **/ + */ static void aer_isr_one_error(struct pcie_device *p_device, struct aer_err_source *e_src) { @@ -706,7 +707,7 @@ static void aer_isr_one_error(struct pcie_device *p_device, * @work: definition of this work item * * Invoked, as DPC, when root port records new detected error - **/ + */ void aer_isr(struct work_struct *work) { struct aer_rpc *rpc = container_of(work, struct aer_rpc, dpc_handler); @@ -729,7 +730,7 @@ void aer_isr(struct work_struct *work) * @rpc: pointer to a root port device being deleted * * Invoked when AER service unloaded on a specific Root Port - **/ + */ void aer_delete_rootport(struct aer_rpc *rpc) { /* Disable root port AER itself */ @@ -743,7 +744,7 @@ void aer_delete_rootport(struct aer_rpc *rpc) * @dev: pointer to AER pcie device * * Invoked when AER service driver is loaded. - **/ + */ int aer_init(struct pcie_device *dev) { if (aer_osc_setup(dev) && !forceload) -- cgit v1.2.3 From 26e6c66e47fe7f69ef6ddb078e312204a1f17823 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 28 Nov 2007 09:04:30 -0800 Subject: pci hotplug: kernel-doc fixes acpiphp.h: not using kernel-doc, so change /** to /* acpiphp_core.c: lots of kernel-doc cleanups acpiphp_glue.c: lots of kernel-doc cleanups acpiphp_ibm.c: lots of kernel-doc cleanups cpqphp_core.c: lots of kernel-doc cleanups cpqphp_ctrl.c: lots of kernel-doc cleanups fakephp.c: correct kernel-doc notation pciehp_ctrl.c: correct kernel-doc notation rpadlpar_core.c: correct function names & kernel-doc notation rpaphp_core.c: correct kernel-doc notation shpchp_ctrl.c: correct kernel-doc notation Signed-off-by: Randy Dunlap Cc: Kristen Accardi Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/acpiphp.h | 8 ++-- drivers/pci/hotplug/acpiphp_core.c | 29 +++++------ drivers/pci/hotplug/acpiphp_glue.c | 36 ++++++-------- drivers/pci/hotplug/acpiphp_ibm.c | 47 +++++++++--------- drivers/pci/hotplug/cpqphp_core.c | 41 ++++++++-------- drivers/pci/hotplug/cpqphp_ctrl.c | 96 ++++++++++++++++++------------------- drivers/pci/hotplug/fakephp.c | 14 +++--- drivers/pci/hotplug/pciehp_ctrl.c | 16 +++---- drivers/pci/hotplug/rpadlpar_core.c | 19 ++++---- drivers/pci/hotplug/rpaphp_core.c | 15 ++++-- drivers/pci/hotplug/rpaphp_pci.c | 1 + drivers/pci/hotplug/shpchp_ctrl.c | 16 +++---- 12 files changed, 169 insertions(+), 169 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index f6cc0c5b565..1ef417cca2d 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h @@ -66,7 +66,7 @@ struct slot { char name[SLOT_NAME_SIZE]; }; -/** +/* * struct acpiphp_bridge - PCI bridge information * * for each bridge device in ACPI namespace @@ -97,7 +97,7 @@ struct acpiphp_bridge { }; -/** +/* * struct acpiphp_slot - PCI slot information * * PCI slot information for each *physical* PCI slot @@ -118,7 +118,7 @@ struct acpiphp_slot { }; -/** +/* * struct acpiphp_func - PCI function information * * PCI function information for each object in ACPI namespace @@ -137,7 +137,7 @@ struct acpiphp_func { u32 flags; /* see below */ }; -/** +/* * struct acpiphp_attention_info - device specific attention registration * * ACPI has no generic method of setting/getting attention status diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index a0ca63adad5..c8c263875c2 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c @@ -91,10 +91,10 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = { * acpiphp_register_attention - set attention LED callback * @info: must be completely filled with LED callbacks * - * Description: this is used to register a hardware specific ACPI + * Description: This is used to register a hardware specific ACPI * driver that manipulates the attention LED. All the fields in * info must be set. - **/ + */ int acpiphp_register_attention(struct acpiphp_attention_info *info) { int retval = -EINVAL; @@ -112,10 +112,10 @@ int acpiphp_register_attention(struct acpiphp_attention_info *info) * acpiphp_unregister_attention - unset attention LED callback * @info: must match the pointer used to register * - * Description: this is used to un-register a hardware specific acpi + * Description: This is used to un-register a hardware specific acpi * driver that manipulates the attention LED. The pointer to the * info struct must be the same as the one used to set it. - **/ + */ int acpiphp_unregister_attention(struct acpiphp_attention_info *info) { int retval = -EINVAL; @@ -133,7 +133,6 @@ int acpiphp_unregister_attention(struct acpiphp_attention_info *info) * @hotplug_slot: slot to enable * * Actual tasks are done in acpiphp_enable_slot() - * */ static int enable_slot(struct hotplug_slot *hotplug_slot) { @@ -151,7 +150,6 @@ static int enable_slot(struct hotplug_slot *hotplug_slot) * @hotplug_slot: slot to disable * * Actual tasks are done in acpiphp_disable_slot() - * */ static int disable_slot(struct hotplug_slot *hotplug_slot) { @@ -168,15 +166,15 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) } - /** - * set_attention_status - set attention LED +/** + * set_attention_status - set attention LED * @hotplug_slot: slot to set attention LED on * @status: value to set attention LED to (0 or 1) * * attention status LED, so we use a callback that * was registered with us. This allows hardware specific * ACPI implementations to blink the light for us. - **/ + */ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) { int retval = -ENODEV; @@ -199,7 +197,6 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) * * Some platforms may not implement _STA method properly. * In that case, the value returned may not be reliable. - * */ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) { @@ -213,7 +210,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) } - /** +/** * get_attention_status - get attention LED status * @hotplug_slot: slot to get status from * @value: returns with value of attention LED @@ -221,8 +218,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) * ACPI doesn't have known method to determine the state * of the attention status LED, so we use a callback that * was registered with us. This allows hardware specific - * ACPI implementations to determine its state - **/ + * ACPI implementations to determine its state. + */ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) { int retval = -EINVAL; @@ -244,8 +241,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) * @value: pointer to store status * * ACPI doesn't provide any formal means to access latch status. - * Instead, we fake latch status from _STA - * + * Instead, we fake latch status from _STA. */ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) { @@ -265,8 +261,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) * @value: pointer to store status * * ACPI doesn't provide any formal means to access adapter status. - * Instead, we fake adapter status from _STA - * + * Instead, we fake adapter status from _STA. */ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) { diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 1e125b56c9a..ff1b1c71291 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -82,7 +82,6 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *contex * 2. has _PS0 method * 3. has _PS3 method * 4. .. - * */ static int is_ejectable(acpi_handle handle) { @@ -986,10 +985,8 @@ static int power_off_slot(struct acpiphp_slot *slot) /** - * acpiphp_max_busnr - return the highest reserved bus number under - * the given bus. + * acpiphp_max_busnr - return the highest reserved bus number under the given bus. * @bus: bus to start search with - * */ static unsigned char acpiphp_max_busnr(struct pci_bus *bus) { @@ -1018,7 +1015,6 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus) /** * acpiphp_bus_add - add a new bus to acpi subsystem * @func: acpiphp_func of the bridge - * */ static int acpiphp_bus_add(struct acpiphp_func *func) { @@ -1063,7 +1059,6 @@ acpiphp_bus_add_out: /** * acpiphp_bus_trim - trim a bus from acpi subsystem * @handle: handle to acpi namespace - * */ static int acpiphp_bus_trim(acpi_handle handle) { @@ -1089,7 +1084,6 @@ static int acpiphp_bus_trim(acpi_handle handle) * * This function should be called per *physical slot*, * not per each slot object in ACPI namespace. - * */ static int enable_device(struct acpiphp_slot *slot) { @@ -1185,6 +1179,7 @@ static void disable_bridges(struct pci_bus *bus) /** * disable_device - disable a slot + * @slot: ACPI PHP slot */ static int disable_device(struct acpiphp_slot *slot) { @@ -1240,14 +1235,15 @@ static int disable_device(struct acpiphp_slot *slot) /** * get_slot_status - get ACPI slot status + * @slot: ACPI PHP slot * - * if a slot has _STA for each function and if any one of them - * returned non-zero status, return it + * If a slot has _STA for each function and if any one of them + * returned non-zero status, return it. * - * if a slot doesn't have _STA and if any one of its functions' - * configuration space is configured, return 0x0f as a _STA + * If a slot doesn't have _STA and if any one of its functions' + * configuration space is configured, return 0x0f as a _STA. * - * otherwise return 0 + * Otherwise return 0. */ static unsigned int get_slot_status(struct acpiphp_slot *slot) { @@ -1281,6 +1277,7 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot) /** * acpiphp_eject_slot - physically eject the slot + * @slot: ACPI PHP slot */ int acpiphp_eject_slot(struct acpiphp_slot *slot) { @@ -1314,6 +1311,7 @@ int acpiphp_eject_slot(struct acpiphp_slot *slot) /** * acpiphp_check_bridge - re-enumerate devices + * @bridge: where to begin re-enumeration * * Iterate over all slots under this bridge and make sure that if a * card is present they are enabled, and if not they are disabled. @@ -1538,13 +1536,11 @@ check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) /** * handle_hotplug_event_bridge - handle ACPI event on bridges - * * @handle: Notify()'ed acpi_handle * @type: Notify code * @context: pointer to acpiphp_bridge structure * - * handles ACPI event notification on {host,p2p} bridges - * + * Handles ACPI event notification on {host,p2p} bridges. */ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *context) { @@ -1634,13 +1630,11 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont /** * handle_hotplug_event_func - handle ACPI event on functions (i.e. slots) - * * @handle: Notify()'ed acpi_handle * @type: Notify code * @context: pointer to acpiphp_func structure * - * handles ACPI event notification on slots - * + * Handles ACPI event notification on slots. */ static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) { @@ -1705,7 +1699,6 @@ static struct acpi_pci_driver acpi_pci_hp_driver = { /** * acpiphp_glue_init - initializes all PCI hotplug - ACPI glue data structures - * */ int __init acpiphp_glue_init(void) { @@ -1726,7 +1719,7 @@ int __init acpiphp_glue_init(void) /** * acpiphp_glue_exit - terminates all PCI hotplug - ACPI glue data structures * - * This function frees all data allocated in acpiphp_glue_init() + * This function frees all data allocated in acpiphp_glue_init(). */ void acpiphp_glue_exit(void) { @@ -1760,7 +1753,6 @@ int __init acpiphp_get_num_slots(void) * acpiphp_for_each_slot - call function for each slot * @fn: callback function * @data: context to be passed to callback function - * */ static int acpiphp_for_each_slot(acpiphp_callback fn, void *data) { @@ -1786,6 +1778,7 @@ static int acpiphp_for_each_slot(acpiphp_callback fn, void *data) /** * acpiphp_enable_slot - power on slot + * @slot: ACPI PHP slot */ int acpiphp_enable_slot(struct acpiphp_slot *slot) { @@ -1815,6 +1808,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) /** * acpiphp_disable_slot - power off slot + * @slot: ACPI PHP slot */ int acpiphp_disable_slot(struct acpiphp_slot *slot) { diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index 56829f82be4..47d26b65e99 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c @@ -134,11 +134,11 @@ static struct acpiphp_attention_info ibm_attention_info = * ibm_slot_from_id - workaround for bad ibm hardware * @id: the slot number that linux refers to the slot by * - * Description: this method returns the aCPI slot descriptor + * Description: This method returns the aCPI slot descriptor * corresponding to the Linux slot number. This descriptor * has info about the aPCI slot id and attention status. * This descriptor must be freed using kfree when done. - **/ + */ static union apci_descriptor *ibm_slot_from_id(int id) { int ind = 0, size; @@ -173,9 +173,9 @@ ibm_slot_done: * @slot: the hotplug_slot to work with * @status: what to set the LED to (0 or 1) * - * Description: this method is registered with the acpiphp module as a - * callback to do the device specific task of setting the LED status - **/ + * Description: This method is registered with the acpiphp module as a + * callback to do the device specific task of setting the LED status. + */ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status) { union acpi_object args[2]; @@ -213,13 +213,13 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status) * @slot: the hotplug_slot to work with * @status: returns what the LED is set to (0 or 1) * - * Description: this method is registered with the acpiphp module as a - * callback to do the device specific task of getting the LED status + * Description: This method is registered with the acpiphp module as a + * callback to do the device specific task of getting the LED status. * * Because there is no direct method of getting the LED status directly * from an ACPI call, we read the aPCI table and parse out our * slot descriptor to read the status from that. - **/ + */ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status) { union apci_descriptor *ibm_slot; @@ -245,8 +245,8 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status) * @event: the event info (device specific) * @context: passed context (our notification struct) * - * Description: this method is registered as a callback with the ACPI - * subsystem it is called when this device has an event to notify the OS of + * Description: This method is registered as a callback with the ACPI + * subsystem it is called when this device has an event to notify the OS of. * * The events actually come from the device as two events that get * synthesized into one event with data by this function. The event @@ -256,7 +256,7 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status) * From section 5.6.2.2 of the ACPI 2.0 spec, I understand that the OSPM will * only re-enable the interrupt that causes this event AFTER this method * has returned, thereby enforcing serial access for the notification struct. - **/ + */ static void ibm_handle_events(acpi_handle handle, u32 event, void *context) { u8 detail = event & 0x0f; @@ -279,16 +279,16 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context) * ibm_get_table_from_acpi - reads the APLS buffer from ACPI * @bufp: address to pointer to allocate for the table * - * Description: this method reads the APLS buffer in from ACPI and + * Description: This method reads the APLS buffer in from ACPI and * stores the "stripped" table into a single buffer - * it allocates and passes the address back in bufp + * it allocates and passes the address back in bufp. * * If NULL is passed in as buffer, this method only calculates * the size of the table and returns that without filling - * in the buffer + * in the buffer. * - * returns < 0 on error or the size of the table on success - **/ + * Returns < 0 on error or the size of the table on success. + */ static int ibm_get_table_from_acpi(char **bufp) { union acpi_object *package; @@ -349,17 +349,18 @@ read_table_done: /** * ibm_read_apci_table - callback for the sysfs apci_table file * @kobj: the kobject this binary attribute is a part of + * @bin_attr: struct bin_attribute for this file * @buffer: the kernel space buffer to fill * @pos: the offset into the file * @size: the number of bytes requested * - * Description: gets registered with sysfs as the reader callback - * to be executed when /sys/bus/pci/slots/apci_table gets read + * Description: Gets registered with sysfs as the reader callback + * to be executed when /sys/bus/pci/slots/apci_table gets read. * * Since we don't get notified on open and close for this file, * things get really tricky here... - * our solution is to only allow reading the table in all at once - **/ + * our solution is to only allow reading the table in all at once. + */ static ssize_t ibm_read_apci_table(struct kobject *kobj, struct bin_attribute *bin_attr, char *buffer, loff_t pos, size_t size) @@ -385,10 +386,10 @@ static ssize_t ibm_read_apci_table(struct kobject *kobj, * @context: a pointer to our handle to fill when we find the device * @rv: a return value to fill if desired * - * Description: used as a callback when calling acpi_walk_namespace + * Description: Used as a callback when calling acpi_walk_namespace * to find our device. When this method returns non-zero - * acpi_walk_namespace quits its search and returns our value - **/ + * acpi_walk_namespace quits its search and returns our value. + */ static acpi_status __init ibm_find_acpi_device(acpi_handle handle, u32 lvl, void *context, void **rv) { diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index a96b739b2d3..74178875b94 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c @@ -117,12 +117,10 @@ static inline int is_slot66mhz(struct slot *slot) /** * detect_SMBIOS_pointer - find the System Management BIOS Table in mem region. - * * @begin: begin pointer for region to be scanned. * @end: end pointer for region to be scanned. * - * Returns pointer to the head of the SMBIOS tables (or NULL) - * + * Returns pointer to the head of the SMBIOS tables (or %NULL). */ static void __iomem * detect_SMBIOS_pointer(void __iomem *begin, void __iomem *end) { @@ -157,9 +155,9 @@ static void __iomem * detect_SMBIOS_pointer(void __iomem *begin, void __iomem *e /** * init_SERR - Initializes the per slot SERR generation. + * @ctrl: controller to use * * For unexpected switch opens - * */ static int init_SERR(struct controller * ctrl) { @@ -224,14 +222,15 @@ static int pci_print_IRQ_route (void) /** * get_subsequent_smbios_entry: get the next entry from bios table. - * - * Gets the first entry if previous == NULL - * Otherwise, returns the next entry - * Uses global SMBIOS Table pointer - * + * @smbios_start: where to start in the SMBIOS table + * @smbios_table: location of the SMBIOS table * @curr: %NULL or pointer to previously returned structure * - * returns a pointer to an SMBIOS structure or NULL if none found + * Gets the first entry if previous == NULL; + * otherwise, returns the next entry. + * Uses global SMBIOS Table pointer. + * + * Returns a pointer to an SMBIOS structure or NULL if none found. */ static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start, void __iomem *smbios_table, @@ -272,17 +271,18 @@ static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start, /** - * get_SMBIOS_entry - * - * @type:SMBIOS structure type to be returned + * get_SMBIOS_entry - return the requested SMBIOS entry or %NULL + * @smbios_start: where to start in the SMBIOS table + * @smbios_table: location of the SMBIOS table + * @type: SMBIOS structure type to be returned * @previous: %NULL or pointer to previously returned structure * - * Gets the first entry of the specified type if previous == NULL + * Gets the first entry of the specified type if previous == %NULL; * Otherwise, returns the next entry of the given type. - * Uses global SMBIOS Table pointer - * Uses get_subsequent_smbios_entry + * Uses global SMBIOS Table pointer. + * Uses get_subsequent_smbios_entry. * - * returns a pointer to an SMBIOS structure or %NULL if none found + * Returns a pointer to an SMBIOS structure or %NULL if none found. */ static void __iomem *get_SMBIOS_entry(void __iomem *smbios_start, void __iomem *smbios_table, @@ -581,7 +581,9 @@ get_slot_mapping(struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *slot) /** * cpqhp_set_attention_status - Turns the Amber LED for a slot on or off - * + * @ctrl: struct controller to use + * @func: PCI device/function info + * @status: LED control flag: 1 = LED on, 0 = LED off */ static int cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, @@ -621,7 +623,8 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, /** * set_attention_status - Turns the Amber LED for a slot on or off - * + * @hotplug_slot: slot to change LED on + * @status: LED control flag */ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) { diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index 856d57b4d60..4018420c6f9 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c @@ -123,7 +123,7 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl) } /** - * cpqhp_find_slot: find the struct slot of given device + * cpqhp_find_slot - find the struct slot of given device * @ctrl: scan lots of this controller * @device: the device id to find */ @@ -305,9 +305,8 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl) /** - * sort_by_size: sort nodes on the list by their length, smallest first. + * sort_by_size - sort nodes on the list by their length, smallest first. * @head: list to sort - * */ static int sort_by_size(struct pci_resource **head) { @@ -354,9 +353,8 @@ static int sort_by_size(struct pci_resource **head) /** - * sort_by_max_size: sort nodes on the list by their length, largest first. + * sort_by_max_size - sort nodes on the list by their length, largest first. * @head: list to sort - * */ static int sort_by_max_size(struct pci_resource **head) { @@ -403,8 +401,10 @@ static int sort_by_max_size(struct pci_resource **head) /** - * do_pre_bridge_resource_split: find node of resources that are unused - * + * do_pre_bridge_resource_split - find node of resources that are unused + * @head: new list head + * @orig_head: original list head + * @alignment: max node size (?) */ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **head, struct pci_resource **orig_head, u32 alignment) @@ -477,8 +477,9 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h /** - * do_bridge_resource_split: find one node of resources that aren't in use - * + * do_bridge_resource_split - find one node of resources that aren't in use + * @head: list head + * @alignment: max node size (?) */ static struct pci_resource *do_bridge_resource_split(struct pci_resource **head, u32 alignment) { @@ -525,14 +526,13 @@ error: /** - * get_io_resource: find first node of given size not in ISA aliasing window. + * get_io_resource - find first node of given size not in ISA aliasing window. * @head: list to search * @size: size of node to find, must be a power of two. * - * Description: this function sorts the resource list by size and then returns + * Description: This function sorts the resource list by size and then returns * returns the first node of "size" length that is not in the ISA aliasing * window. If it finds a node larger than "size" it will split it up. - * */ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size) { @@ -620,7 +620,7 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size /** - * get_max_resource: get largest node which has at least the given size. + * get_max_resource - get largest node which has at least the given size. * @head: the list to search the node in * @size: the minimum size of the node to find * @@ -712,7 +712,7 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz /** - * get_resource: find resource of given size and split up larger ones. + * get_resource - find resource of given size and split up larger ones. * @head: the list to search for resources * @size: the size limit to use * @@ -804,14 +804,14 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size) /** - * cpqhp_resource_sort_and_combine: sort nodes by base addresses and clean up. + * cpqhp_resource_sort_and_combine - sort nodes by base addresses and clean up * @head: the list to sort and clean up * * Description: Sorts all of the nodes in the list in ascending order by * their base addresses. Also does garbage collection by * combining adjacent nodes. * - * returns 0 if success + * Returns %0 if success. */ int cpqhp_resource_sort_and_combine(struct pci_resource **head) { @@ -951,9 +951,9 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data) /** * cpqhp_slot_create - Creates a node and adds it to the proper bus. - * @busnumber - bus where new node is to be located + * @busnumber: bus where new node is to be located * - * Returns pointer to the new node or NULL if unsuccessful + * Returns pointer to the new node or %NULL if unsuccessful. */ struct pci_func *cpqhp_slot_create(u8 busnumber) { @@ -986,7 +986,7 @@ struct pci_func *cpqhp_slot_create(u8 busnumber) * slot_remove - Removes a node from the linked list of slots. * @old_slot: slot to remove * - * Returns 0 if successful, !0 otherwise. + * Returns %0 if successful, !0 otherwise. */ static int slot_remove(struct pci_func * old_slot) { @@ -1026,7 +1026,7 @@ static int slot_remove(struct pci_func * old_slot) * bridge_slot_remove - Removes a node from the linked list of slots. * @bridge: bridge to remove * - * Returns 0 if successful, !0 otherwise. + * Returns %0 if successful, !0 otherwise. */ static int bridge_slot_remove(struct pci_func *bridge) { @@ -1071,7 +1071,7 @@ out: * cpqhp_slot_find - Looks for a node by bus, and device, multiple functions accessed * @bus: bus to find * @device: device to find - * @index: is 0 for first function found, 1 for the second... + * @index: is %0 for first function found, %1 for the second... * * Returns pointer to the node if successful, %NULL otherwise. */ @@ -1115,16 +1115,13 @@ static int is_bridge(struct pci_func * func) /** - * set_controller_speed - set the frequency and/or mode of a specific - * controller segment. - * + * set_controller_speed - set the frequency and/or mode of a specific controller segment. * @ctrl: controller to change frequency/mode for. * @adapter_speed: the speed of the adapter we want to match. * @hp_slot: the slot number where the adapter is installed. * - * Returns 0 if we successfully change frequency and/or mode to match the + * Returns %0 if we successfully change frequency and/or mode to match the * adapter speed. - * */ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_slot) { @@ -1253,13 +1250,14 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_ /** * board_replaced - Called after a board has been replaced in the system. + * @func: PCI device/function information + * @ctrl: hotplug controller * - * This is only used if we don't have resources for hot add - * Turns power on for the board - * Checks to see if board is the same - * If board is same, reconfigures it + * This is only used if we don't have resources for hot add. + * Turns power on for the board. + * Checks to see if board is the same. + * If board is same, reconfigures it. * If board isn't same, turns it back off. - * */ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) { @@ -1403,10 +1401,11 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) /** * board_added - Called after a board has been added to the system. + * @func: PCI device/function info + * @ctrl: hotplug controller * - * Turns power on for the board - * Configures board - * + * Turns power on for the board. + * Configures board. */ static u32 board_added(struct pci_func *func, struct controller *ctrl) { @@ -1607,8 +1606,10 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) /** - * remove_board - Turns off slot and LED's - * + * remove_board - Turns off slot and LEDs + * @func: PCI device/function info + * @replace_flag: whether replacing or adding a new device + * @ctrl: target controller */ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct controller * ctrl) { @@ -1902,11 +1903,11 @@ static void interrupt_event_handler(struct controller *ctrl) /** - * cpqhp_pushbutton_thread + * cpqhp_pushbutton_thread - handle pushbutton events + * @slot: target slot (struct) * - * Scheduled procedure to handle blocking stuff for the pushbuttons + * Scheduled procedure to handle blocking stuff for the pushbuttons. * Handles all pending events and exits. - * */ void cpqhp_pushbutton_thread(unsigned long slot) { @@ -2137,9 +2138,10 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func) } /** - * switch_leds: switch the leds, go from one site to the other. + * switch_leds - switch the leds, go from one site to the other. * @ctrl: controller to use * @num_of_slots: number of slots to use + * @work_LED: LED control value * @direction: 1 to start from the left side, 0 to start right. */ static void switch_leds(struct controller *ctrl, const int num_of_slots, @@ -2165,11 +2167,11 @@ static void switch_leds(struct controller *ctrl, const int num_of_slots, } /** - * hardware_test - runs hardware tests + * cpqhp_hardware_test - runs hardware tests + * @ctrl: target controller + * @test_num: the number written to the "test" file in sysfs. * * For hot plug ctrl folks to play with. - * test_num is the number written to the "test" file in sysfs - * */ int cpqhp_hardware_test(struct controller *ctrl, int test_num) { @@ -2249,14 +2251,12 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num) /** * configure_new_device - Configures the PCI header information of one board. - * * @ctrl: pointer to controller structure * @func: pointer to function structure * @behind_bridge: 1 if this is a recursive call, 0 if not * @resources: pointer to set of resource lists * - * Returns 0 if success - * + * Returns 0 if success. */ static u32 configure_new_device(struct controller * ctrl, struct pci_func * func, u8 behind_bridge, struct resource_lists * resources) @@ -2346,15 +2346,13 @@ static u32 configure_new_device(struct controller * ctrl, struct pci_func * func /** * configure_new_function - Configures the PCI header information of one device - * * @ctrl: pointer to controller structure * @func: pointer to function structure * @behind_bridge: 1 if this is a recursive call, 0 if not * @resources: pointer to set of resource lists * * Calls itself recursively for bridged devices. - * Returns 0 if success - * + * Returns 0 if success. */ static int configure_new_function(struct controller *ctrl, struct pci_func *func, u8 behind_bridge, diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c index 027f6865d7e..d7a293e3faf 100644 --- a/drivers/pci/hotplug/fakephp.c +++ b/drivers/pci/hotplug/fakephp.c @@ -165,11 +165,11 @@ static void remove_slot(struct dummy_slot *dslot) } /** - * Rescan slot. - * Tries hard not to re-enable already existing devices - * also handles scanning of subfunctions + * pci_rescan_slot - Rescan slot + * @temp: Device template. Should be set: bus and devfn. * - * @param temp Device template. Should be set: bus and devfn. + * Tries hard not to re-enable already existing devices; + * also handles scanning of subfunctions. */ static void pci_rescan_slot(struct pci_dev *temp) { @@ -229,10 +229,10 @@ static void pci_rescan_slot(struct pci_dev *temp) /** - * Rescan PCI bus. - * call pci_rescan_slot for each possible function of the bus + * pci_rescan_bus - Rescan PCI bus + * @bus: the PCI bus to rescan * - * @param bus + * Call pci_rescan_slot for each possible function of the bus. */ static void pci_rescan_bus(const struct pci_bus *bus) { diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index c8cb49c5a75..f1e0966cee9 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -208,10 +208,10 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) /** * board_added - Called after a board has been added to the system. + * @p_slot: &slot where board is added * - * Turns power on for the board - * Configures board - * + * Turns power on for the board. + * Configures board. */ static int board_added(struct slot *p_slot) { @@ -276,8 +276,8 @@ err_exit: } /** - * remove_board - Turns off slot and LED's - * + * remove_board - Turns off slot and LEDs + * @p_slot: slot where board is being removed */ static int remove_board(struct slot *p_slot) { @@ -319,11 +319,11 @@ struct power_work_info { }; /** - * pciehp_pushbutton_thread + * pciehp_power_thread - handle pushbutton events + * @work: &struct work_struct describing work to be done * - * Scheduled procedure to handle blocking stuff for the pushbuttons + * Scheduled procedure to handle blocking stuff for the pushbuttons. * Handles all pending events and exits. - * */ static void pciehp_power_thread(struct work_struct *work) { diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index deb6b5e35fe..b169b0e2647 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -100,6 +100,7 @@ static struct device_node *find_dlpar_node(char *drc_name, int *node_type) /** * find_php_slot - return hotplug slot structure for device node + * @dn: target &device_node * * This routine will return the hotplug slot structure * for a given device node. Note that built-in PCI slots @@ -293,9 +294,8 @@ static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn) * dlpar_add_slot - DLPAR add an I/O Slot * @drc_name: drc-name of newly added slot * - * Make the hotplug module and the kernel aware - * of a newly added I/O Slot. - * Return Codes - + * Make the hotplug module and the kernel aware of a newly added I/O Slot. + * Return Codes: * 0 Success * -ENODEV Not a valid drc_name * -EINVAL Slot already added @@ -339,9 +339,9 @@ exit: /** * dlpar_remove_vio_slot - DLPAR remove a virtual I/O Slot * @drc_name: drc-name of newly added slot + * @dn: &device_node * - * Remove the kernel and hotplug representations - * of an I/O Slot. + * Remove the kernel and hotplug representations of an I/O Slot. * Return Codes: * 0 Success * -EINVAL Vio dev doesn't exist @@ -359,11 +359,11 @@ static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn) } /** - * dlpar_remove_slot - DLPAR remove a PCI I/O Slot + * dlpar_remove_pci_slot - DLPAR remove a PCI I/O Slot * @drc_name: drc-name of newly added slot + * @dn: &device_node * - * Remove the kernel and hotplug representations - * of a PCI I/O Slot. + * Remove the kernel and hotplug representations of a PCI I/O Slot. * Return Codes: * 0 Success * -ENODEV Not a valid drc_name @@ -405,8 +405,7 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn) * dlpar_remove_slot - DLPAR remove an I/O Slot * @drc_name: drc-name of newly added slot * - * Remove the kernel and hotplug representations - * of an I/O Slot. + * Remove the kernel and hotplug representations of an I/O Slot. * Return Codes: * 0 Success * -ENODEV Not a valid drc_name diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 458c08ef265..58f1a992770 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c @@ -54,10 +54,12 @@ module_param(debug, bool, 0644); /** * set_attention_status - set attention LED + * @hotplug_slot: target &hotplug_slot + * @value: LED control value + * * echo 0 > attention -- set LED OFF * echo 1 > attention -- set LED ON * echo 2 > attention -- set LED ID(identify, light is blinking) - * */ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value) { @@ -99,6 +101,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value) /** * get_attention_status - get attention LED status + * @hotplug_slot: slot to get status + * @value: pointer to store status */ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value) { @@ -254,6 +258,11 @@ static int is_php_type(char *drc_type) /** * is_php_dn() - return 1 if this is a hotpluggable pci slot, else 0 + * @dn: target &device_node + * @indexes: passed to get_children_props() + * @names: passed to get_children_props() + * @types: returned from get_children_props() + * @power_domains: * * This routine will return true only if the device node is * a hotpluggable slot. This routine will return false @@ -279,7 +288,7 @@ static int is_php_dn(struct device_node *dn, const int **indexes, /** * rpaphp_add_slot -- declare a hotplug slot to the hotplug subsystem. - * @dn device node of slot + * @dn: device node of slot * * This subroutine will register a hotplugable slot with the * PCI hotplug infrastructure. This routine is typicaly called @@ -291,7 +300,7 @@ static int is_php_dn(struct device_node *dn, const int **indexes, * routine will just return without doing anything, since embedded * slots cannot be hotplugged. * - * To remove a slot, it suffices to call rpaphp_deregister_slot() + * To remove a slot, it suffices to call rpaphp_deregister_slot(). */ int rpaphp_add_slot(struct device_node *dn) { diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 54ca8650d51..0de84533cd8 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -79,6 +79,7 @@ static void set_slot_name(struct slot *slot) /** * rpaphp_enable_slot - record slot state, config pci device + * @slot: target &slot * * Initialize values in the slot, and the hotplug_slot info * structures to indicate if there is a pci card plugged into diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c index d2fc35598cd..eb5cac6f08a 100644 --- a/drivers/pci/hotplug/shpchp_ctrl.c +++ b/drivers/pci/hotplug/shpchp_ctrl.c @@ -231,10 +231,10 @@ static int fix_bus_speed(struct controller *ctrl, struct slot *pslot, /** * board_added - Called after a board has been added to the system. + * @p_slot: target &slot * - * Turns power on for the board - * Configures board - * + * Turns power on for the board. + * Configures board. */ static int board_added(struct slot *p_slot) { @@ -350,8 +350,8 @@ err_exit: /** - * remove_board - Turns off slot and LED's - * + * remove_board - Turns off slot and LEDs + * @p_slot: target &slot */ static int remove_board(struct slot *p_slot) { @@ -397,11 +397,11 @@ struct pushbutton_work_info { }; /** - * shpchp_pushbutton_thread + * shpchp_pushbutton_thread - handle pushbutton events + * @work: &struct work_struct to be handled * - * Scheduled procedure to handle blocking stuff for the pushbuttons + * Scheduled procedure to handle blocking stuff for the pushbuttons. * Handles all pending events and exits. - * */ static void shpchp_pushbutton_thread(struct work_struct *work) { -- cgit v1.2.3 From 65f97a56944b797f5df714d677b541cca0829669 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 28 Nov 2007 16:21:10 -0800 Subject: atmel_spi: label GPIOs better Make the atmel_spi driver label GPIOs according to the device for which they're acting as a chipselect. This way the debugfs dump of gpio state is more informative. Signed-off-by: David Brownell Cc: Haavard Skinnemoen 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 0d342dcdd30..ff6a14bf128 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -497,7 +497,7 @@ static int atmel_spi_setup(struct spi_device *spi) /* chipselect must have been muxed as GPIO (e.g. in board setup) */ npcs_pin = (unsigned int)spi->controller_data; if (!spi->controller_state) { - ret = gpio_request(npcs_pin, "spi_npcs"); + ret = gpio_request(npcs_pin, spi->dev.bus_id); if (ret) return ret; spi->controller_state = (void *)npcs_pin; -- cgit v1.2.3 From 248285501ea251379dd449316bf5af78362ae638 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 28 Nov 2007 16:21:11 -0800 Subject: ps3: prefix all ps3-specific kernel modules with `ps3-' - vuart.ko -> ps3-vuart.ko - sys-manager.ko -> ps3-sys-manager.ko Signed-off-by: Geert Uytterhoeven Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ps3/Makefile | 4 +- drivers/ps3/ps3-sys-manager.c | 702 +++++++++++++++++++++++ drivers/ps3/ps3-vuart.c | 1271 +++++++++++++++++++++++++++++++++++++++++ drivers/ps3/sys-manager.c | 702 ----------------------- drivers/ps3/vuart.c | 1271 ----------------------------------------- 5 files changed, 1975 insertions(+), 1975 deletions(-) create mode 100644 drivers/ps3/ps3-sys-manager.c create mode 100644 drivers/ps3/ps3-vuart.c delete mode 100644 drivers/ps3/sys-manager.c delete mode 100644 drivers/ps3/vuart.c (limited to 'drivers') diff --git a/drivers/ps3/Makefile b/drivers/ps3/Makefile index 746031de219..1f5a2d33bf5 100644 --- a/drivers/ps3/Makefile +++ b/drivers/ps3/Makefile @@ -1,6 +1,6 @@ -obj-$(CONFIG_PS3_VUART) += vuart.o +obj-$(CONFIG_PS3_VUART) += ps3-vuart.o obj-$(CONFIG_PS3_PS3AV) += ps3av_mod.o ps3av_mod-objs += ps3av.o ps3av_cmd.o obj-$(CONFIG_PPC_PS3) += sys-manager-core.o -obj-$(CONFIG_PS3_SYS_MANAGER) += sys-manager.o +obj-$(CONFIG_PS3_SYS_MANAGER) += ps3-sys-manager.o obj-$(CONFIG_PS3_STORAGE) += ps3stor_lib.o diff --git a/drivers/ps3/ps3-sys-manager.c b/drivers/ps3/ps3-sys-manager.c new file mode 100644 index 00000000000..8461b08ab9f --- /dev/null +++ b/drivers/ps3/ps3-sys-manager.c @@ -0,0 +1,702 @@ +/* + * PS3 System Manager. + * + * Copyright (C) 2007 Sony Computer Entertainment Inc. + * Copyright 2007 Sony Corp. + * + * 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; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include + +#include +#include + +#include "vuart.h" + +MODULE_AUTHOR("Sony Corporation"); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("PS3 System Manager"); + +/** + * ps3_sys_manager - PS3 system manager driver. + * + * The system manager provides an asynchronous system event notification + * mechanism for reporting events like thermal alert and button presses to + * guests. It also provides support to control system shutdown and startup. + * + * The actual system manager is implemented as an application running in the + * system policy module in lpar_1. Guests communicate with the system manager + * through port 2 of the vuart using a simple packet message protocol. + * Messages are comprised of a fixed field header followed by a message + * specific payload. + */ + +/** + * struct ps3_sys_manager_header - System manager message header. + * @version: Header version, currently 1. + * @size: Header size in bytes, curently 16. + * @payload_size: Message payload size in bytes. + * @service_id: Message type, one of enum ps3_sys_manager_service_id. + * @request_tag: Unique number to identify reply. + */ + +struct ps3_sys_manager_header { + /* version 1 */ + u8 version; + u8 size; + u16 reserved_1; + u32 payload_size; + u16 service_id; + u16 reserved_2; + u32 request_tag; +}; + +#define dump_sm_header(_h) _dump_sm_header(_h, __func__, __LINE__) +static void __maybe_unused _dump_sm_header( + const struct ps3_sys_manager_header *h, const char *func, int line) +{ + pr_debug("%s:%d: version: %xh\n", func, line, h->version); + pr_debug("%s:%d: size: %xh\n", func, line, h->size); + pr_debug("%s:%d: payload_size: %xh\n", func, line, h->payload_size); + pr_debug("%s:%d: service_id: %xh\n", func, line, h->service_id); + pr_debug("%s:%d: request_tag: %xh\n", func, line, h->request_tag); +} + +/** + * @PS3_SM_RX_MSG_LEN_MIN - Shortest received message length. + * @PS3_SM_RX_MSG_LEN_MAX - Longest received message length. + * + * Currently all messages received from the system manager are either + * (16 bytes header + 8 bytes payload = 24 bytes) or (16 bytes header + * + 16 bytes payload = 32 bytes). This knowlege is used to simplify + * the logic. + */ + +enum { + PS3_SM_RX_MSG_LEN_MIN = 24, + PS3_SM_RX_MSG_LEN_MAX = 32, +}; + +/** + * enum ps3_sys_manager_service_id - Message header service_id. + * @PS3_SM_SERVICE_ID_REQUEST: guest --> sys_manager. + * @PS3_SM_SERVICE_ID_REQUEST_ERROR: guest <-- sys_manager. + * @PS3_SM_SERVICE_ID_COMMAND: guest <-- sys_manager. + * @PS3_SM_SERVICE_ID_RESPONSE: guest --> sys_manager. + * @PS3_SM_SERVICE_ID_SET_ATTR: guest --> sys_manager. + * @PS3_SM_SERVICE_ID_EXTERN_EVENT: guest <-- sys_manager. + * @PS3_SM_SERVICE_ID_SET_NEXT_OP: guest --> sys_manager. + * + * PS3_SM_SERVICE_ID_REQUEST_ERROR is returned for invalid data values in a + * a PS3_SM_SERVICE_ID_REQUEST message. It also seems to be returned when + * a REQUEST message is sent at the wrong time. + */ + +enum ps3_sys_manager_service_id { + /* version 1 */ + PS3_SM_SERVICE_ID_REQUEST = 1, + PS3_SM_SERVICE_ID_RESPONSE = 2, + PS3_SM_SERVICE_ID_COMMAND = 3, + PS3_SM_SERVICE_ID_EXTERN_EVENT = 4, + PS3_SM_SERVICE_ID_SET_NEXT_OP = 5, + PS3_SM_SERVICE_ID_REQUEST_ERROR = 6, + PS3_SM_SERVICE_ID_SET_ATTR = 8, +}; + +/** + * enum ps3_sys_manager_attr - Notification attribute (bit position mask). + * @PS3_SM_ATTR_POWER: Power button. + * @PS3_SM_ATTR_RESET: Reset button, not available on retail console. + * @PS3_SM_ATTR_THERMAL: Sytem thermal alert. + * @PS3_SM_ATTR_CONTROLLER: Remote controller event. + * @PS3_SM_ATTR_ALL: Logical OR of all. + * + * The guest tells the system manager which events it is interested in receiving + * notice of by sending the system manager a logical OR of notification + * attributes via the ps3_sys_manager_send_attr() routine. + */ + +enum ps3_sys_manager_attr { + /* version 1 */ + PS3_SM_ATTR_POWER = 1, + PS3_SM_ATTR_RESET = 2, + PS3_SM_ATTR_THERMAL = 4, + PS3_SM_ATTR_CONTROLLER = 8, /* bogus? */ + PS3_SM_ATTR_ALL = 0x0f, +}; + +/** + * enum ps3_sys_manager_event - External event type, reported by system manager. + * @PS3_SM_EVENT_POWER_PRESSED: payload.value not used. + * @PS3_SM_EVENT_POWER_RELEASED: payload.value = time pressed in millisec. + * @PS3_SM_EVENT_RESET_PRESSED: payload.value not used. + * @PS3_SM_EVENT_RESET_RELEASED: payload.value = time pressed in millisec. + * @PS3_SM_EVENT_THERMAL_ALERT: payload.value = thermal zone id. + * @PS3_SM_EVENT_THERMAL_CLEARED: payload.value = thermal zone id. + */ + +enum ps3_sys_manager_event { + /* version 1 */ + PS3_SM_EVENT_POWER_PRESSED = 3, + PS3_SM_EVENT_POWER_RELEASED = 4, + PS3_SM_EVENT_RESET_PRESSED = 5, + PS3_SM_EVENT_RESET_RELEASED = 6, + PS3_SM_EVENT_THERMAL_ALERT = 7, + PS3_SM_EVENT_THERMAL_CLEARED = 8, + /* no info on controller events */ +}; + +/** + * enum ps3_sys_manager_next_op - Operation to perform after lpar is destroyed. + */ + +enum ps3_sys_manager_next_op { + /* version 3 */ + PS3_SM_NEXT_OP_SYS_SHUTDOWN = 1, + PS3_SM_NEXT_OP_SYS_REBOOT = 2, + PS3_SM_NEXT_OP_LPAR_REBOOT = 0x82, +}; + +/** + * enum ps3_sys_manager_wake_source - Next-op wakeup source (bit position mask). + * @PS3_SM_WAKE_DEFAULT: Disk insert, power button, eject button, IR + * controller, and bluetooth controller. + * @PS3_SM_WAKE_RTC: + * @PS3_SM_WAKE_RTC_ERROR: + * @PS3_SM_WAKE_P_O_R: Power on reset. + * + * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN. + * System will always wake from the PS3_SM_WAKE_DEFAULT sources. + */ + +enum ps3_sys_manager_wake_source { + /* version 3 */ + PS3_SM_WAKE_DEFAULT = 0, + PS3_SM_WAKE_RTC = 0x00000040, + PS3_SM_WAKE_RTC_ERROR = 0x00000080, + PS3_SM_WAKE_P_O_R = 0x10000000, +}; + +/** + * enum ps3_sys_manager_cmd - Command from system manager to guest. + * + * The guest completes the actions needed, then acks or naks the command via + * ps3_sys_manager_send_response(). In the case of @PS3_SM_CMD_SHUTDOWN, + * the guest must be fully prepared for a system poweroff prior to acking the + * command. + */ + +enum ps3_sys_manager_cmd { + /* version 1 */ + PS3_SM_CMD_SHUTDOWN = 1, /* shutdown guest OS */ +}; + +/** + * ps3_sm_force_power_off - Poweroff helper. + * + * A global variable used to force a poweroff when the power button has + * been pressed irrespective of how init handles the ctrl_alt_del signal. + * + */ + +static unsigned int ps3_sm_force_power_off; + +/** + * ps3_sys_manager_write - Helper to write a two part message to the vuart. + * + */ + +static int ps3_sys_manager_write(struct ps3_system_bus_device *dev, + const struct ps3_sys_manager_header *header, const void *payload) +{ + int result; + + BUG_ON(header->version != 1); + BUG_ON(header->size != 16); + BUG_ON(header->payload_size != 8 && header->payload_size != 16); + BUG_ON(header->service_id > 8); + + result = ps3_vuart_write(dev, header, + sizeof(struct ps3_sys_manager_header)); + + if (!result) + result = ps3_vuart_write(dev, payload, header->payload_size); + + return result; +} + +/** + * ps3_sys_manager_send_attr - Send a 'set attribute' to the system manager. + * + */ + +static int ps3_sys_manager_send_attr(struct ps3_system_bus_device *dev, + enum ps3_sys_manager_attr attr) +{ + struct ps3_sys_manager_header header; + struct { + u8 version; + u8 reserved_1[3]; + u32 attribute; + } payload; + + BUILD_BUG_ON(sizeof(payload) != 8); + + dev_dbg(&dev->core, "%s:%d: %xh\n", __func__, __LINE__, attr); + + memset(&header, 0, sizeof(header)); + header.version = 1; + header.size = 16; + header.payload_size = 16; + header.service_id = PS3_SM_SERVICE_ID_SET_ATTR; + + memset(&payload, 0, sizeof(payload)); + payload.version = 1; + payload.attribute = attr; + + return ps3_sys_manager_write(dev, &header, &payload); +} + +/** + * ps3_sys_manager_send_next_op - Send a 'set next op' to the system manager. + * + * Tell the system manager what to do after this lpar is destroyed. + */ + +static int ps3_sys_manager_send_next_op(struct ps3_system_bus_device *dev, + enum ps3_sys_manager_next_op op, + enum ps3_sys_manager_wake_source wake_source) +{ + struct ps3_sys_manager_header header; + struct { + u8 version; + u8 type; + u8 gos_id; + u8 reserved_1; + u32 wake_source; + u8 reserved_2[8]; + } payload; + + BUILD_BUG_ON(sizeof(payload) != 16); + + dev_dbg(&dev->core, "%s:%d: (%xh)\n", __func__, __LINE__, op); + + memset(&header, 0, sizeof(header)); + header.version = 1; + header.size = 16; + header.payload_size = 16; + header.service_id = PS3_SM_SERVICE_ID_SET_NEXT_OP; + + memset(&payload, 0, sizeof(payload)); + payload.version = 3; + payload.type = op; + payload.gos_id = 3; /* other os */ + payload.wake_source = wake_source; + + return ps3_sys_manager_write(dev, &header, &payload); +} + +/** + * ps3_sys_manager_send_request_shutdown - Send 'request' to the system manager. + * + * The guest sends this message to request an operation or action of the system + * manager. The reply is a command message from the system manager. In the + * command handler the guest performs the requested operation. The result of + * the command is then communicated back to the system manager with a response + * message. + * + * Currently, the only supported request is the 'shutdown self' request. + */ + +static int ps3_sys_manager_send_request_shutdown( + struct ps3_system_bus_device *dev) +{ + struct ps3_sys_manager_header header; + struct { + u8 version; + u8 type; + u8 gos_id; + u8 reserved_1[13]; + } payload; + + BUILD_BUG_ON(sizeof(payload) != 16); + + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + + memset(&header, 0, sizeof(header)); + header.version = 1; + header.size = 16; + header.payload_size = 16; + header.service_id = PS3_SM_SERVICE_ID_REQUEST; + + memset(&payload, 0, sizeof(payload)); + payload.version = 1; + payload.type = 1; /* shutdown */ + payload.gos_id = 0; /* self */ + + return ps3_sys_manager_write(dev, &header, &payload); +} + +/** + * ps3_sys_manager_send_response - Send a 'response' to the system manager. + * @status: zero = success, others fail. + * + * The guest sends this message to the system manager to acnowledge success or + * failure of a command sent by the system manager. + */ + +static int ps3_sys_manager_send_response(struct ps3_system_bus_device *dev, + u64 status) +{ + struct ps3_sys_manager_header header; + struct { + u8 version; + u8 reserved_1[3]; + u8 status; + u8 reserved_2[11]; + } payload; + + BUILD_BUG_ON(sizeof(payload) != 16); + + dev_dbg(&dev->core, "%s:%d: (%s)\n", __func__, __LINE__, + (status ? "nak" : "ack")); + + memset(&header, 0, sizeof(header)); + header.version = 1; + header.size = 16; + header.payload_size = 16; + header.service_id = PS3_SM_SERVICE_ID_RESPONSE; + + memset(&payload, 0, sizeof(payload)); + payload.version = 1; + payload.status = status; + + return ps3_sys_manager_write(dev, &header, &payload); +} + +/** + * ps3_sys_manager_handle_event - Second stage event msg handler. + * + */ + +static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev) +{ + int result; + struct { + u8 version; + u8 type; + u8 reserved_1[2]; + u32 value; + u8 reserved_2[8]; + } event; + + BUILD_BUG_ON(sizeof(event) != 16); + + result = ps3_vuart_read(dev, &event, sizeof(event)); + BUG_ON(result && "need to retry here"); + + if (event.version != 1) { + dev_dbg(&dev->core, "%s:%d: unsupported event version (%u)\n", + __func__, __LINE__, event.version); + return -EIO; + } + + switch (event.type) { + case PS3_SM_EVENT_POWER_PRESSED: + dev_dbg(&dev->core, "%s:%d: POWER_PRESSED\n", + __func__, __LINE__); + ps3_sm_force_power_off = 1; + /* + * A memory barrier is use here to sync memory since + * ps3_sys_manager_final_restart() could be called on + * another cpu. + */ + wmb(); + kill_cad_pid(SIGINT, 1); /* ctrl_alt_del */ + break; + case PS3_SM_EVENT_POWER_RELEASED: + dev_dbg(&dev->core, "%s:%d: POWER_RELEASED (%u ms)\n", + __func__, __LINE__, event.value); + break; + case PS3_SM_EVENT_RESET_PRESSED: + dev_dbg(&dev->core, "%s:%d: RESET_PRESSED\n", + __func__, __LINE__); + ps3_sm_force_power_off = 0; + /* + * A memory barrier is use here to sync memory since + * ps3_sys_manager_final_restart() could be called on + * another cpu. + */ + wmb(); + kill_cad_pid(SIGINT, 1); /* ctrl_alt_del */ + break; + case PS3_SM_EVENT_RESET_RELEASED: + dev_dbg(&dev->core, "%s:%d: RESET_RELEASED (%u ms)\n", + __func__, __LINE__, event.value); + break; + case PS3_SM_EVENT_THERMAL_ALERT: + dev_dbg(&dev->core, "%s:%d: THERMAL_ALERT (zone %u)\n", + __func__, __LINE__, event.value); + printk(KERN_INFO "PS3 Thermal Alert Zone %u\n", event.value); + break; + case PS3_SM_EVENT_THERMAL_CLEARED: + dev_dbg(&dev->core, "%s:%d: THERMAL_CLEARED (zone %u)\n", + __func__, __LINE__, event.value); + break; + default: + dev_dbg(&dev->core, "%s:%d: unknown event (%u)\n", + __func__, __LINE__, event.type); + return -EIO; + } + + return 0; +} +/** + * ps3_sys_manager_handle_cmd - Second stage command msg handler. + * + * The system manager sends this in reply to a 'request' message from the guest. + */ + +static int ps3_sys_manager_handle_cmd(struct ps3_system_bus_device *dev) +{ + int result; + struct { + u8 version; + u8 type; + u8 reserved_1[14]; + } cmd; + + BUILD_BUG_ON(sizeof(cmd) != 16); + + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + + result = ps3_vuart_read(dev, &cmd, sizeof(cmd)); + BUG_ON(result && "need to retry here"); + + if(result) + return result; + + if (cmd.version != 1) { + dev_dbg(&dev->core, "%s:%d: unsupported cmd version (%u)\n", + __func__, __LINE__, cmd.version); + return -EIO; + } + + if (cmd.type != PS3_SM_CMD_SHUTDOWN) { + dev_dbg(&dev->core, "%s:%d: unknown cmd (%u)\n", + __func__, __LINE__, cmd.type); + return -EIO; + } + + ps3_sys_manager_send_response(dev, 0); + return 0; +} + +/** + * ps3_sys_manager_handle_msg - First stage msg handler. + * + * Can be called directly to manually poll vuart and pump message handler. + */ + +static int ps3_sys_manager_handle_msg(struct ps3_system_bus_device *dev) +{ + int result; + struct ps3_sys_manager_header header; + + result = ps3_vuart_read(dev, &header, + sizeof(struct ps3_sys_manager_header)); + + if(result) + return result; + + if (header.version != 1) { + dev_dbg(&dev->core, "%s:%d: unsupported header version (%u)\n", + __func__, __LINE__, header.version); + dump_sm_header(&header); + goto fail_header; + } + + BUILD_BUG_ON(sizeof(header) != 16); + + if (header.size != 16 || (header.payload_size != 8 + && header.payload_size != 16)) { + dump_sm_header(&header); + BUG(); + } + + switch (header.service_id) { + case PS3_SM_SERVICE_ID_EXTERN_EVENT: + dev_dbg(&dev->core, "%s:%d: EVENT\n", __func__, __LINE__); + return ps3_sys_manager_handle_event(dev); + case PS3_SM_SERVICE_ID_COMMAND: + dev_dbg(&dev->core, "%s:%d: COMMAND\n", __func__, __LINE__); + return ps3_sys_manager_handle_cmd(dev); + case PS3_SM_SERVICE_ID_REQUEST_ERROR: + dev_dbg(&dev->core, "%s:%d: REQUEST_ERROR\n", __func__, + __LINE__); + dump_sm_header(&header); + break; + default: + dev_dbg(&dev->core, "%s:%d: unknown service_id (%u)\n", + __func__, __LINE__, header.service_id); + break; + } + goto fail_id; + +fail_header: + ps3_vuart_clear_rx_bytes(dev, 0); + return -EIO; +fail_id: + ps3_vuart_clear_rx_bytes(dev, header.payload_size); + return -EIO; +} + +/** + * ps3_sys_manager_final_power_off - The final platform machine_power_off routine. + * + * This routine never returns. The routine disables asynchronous vuart reads + * then spins calling ps3_sys_manager_handle_msg() to receive and acknowledge + * the shutdown command sent from the system manager. Soon after the + * acknowledgement is sent the lpar is destroyed by the HV. This routine + * should only be called from ps3_power_off() through + * ps3_sys_manager_ops.power_off. + */ + +static void ps3_sys_manager_final_power_off(struct ps3_system_bus_device *dev) +{ + BUG_ON(!dev); + + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + + ps3_vuart_cancel_async(dev); + + ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_SHUTDOWN, + PS3_SM_WAKE_DEFAULT); + ps3_sys_manager_send_request_shutdown(dev); + + printk(KERN_EMERG "System Halted, OK to turn off power\n"); + + while(1) + ps3_sys_manager_handle_msg(dev); +} + +/** + * ps3_sys_manager_final_restart - The final platform machine_restart routine. + * + * This routine never returns. The routine disables asynchronous vuart reads + * then spins calling ps3_sys_manager_handle_msg() to receive and acknowledge + * the shutdown command sent from the system manager. Soon after the + * acknowledgement is sent the lpar is destroyed by the HV. This routine + * should only be called from ps3_restart() through ps3_sys_manager_ops.restart. + */ + +static void ps3_sys_manager_final_restart(struct ps3_system_bus_device *dev) +{ + BUG_ON(!dev); + + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + + /* Check if we got here via a power button event. */ + + if (ps3_sm_force_power_off) { + dev_dbg(&dev->core, "%s:%d: forcing poweroff\n", + __func__, __LINE__); + ps3_sys_manager_final_power_off(dev); + } + + ps3_vuart_cancel_async(dev); + + ps3_sys_manager_send_attr(dev, 0); + ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_LPAR_REBOOT, + PS3_SM_WAKE_DEFAULT); + ps3_sys_manager_send_request_shutdown(dev); + + printk(KERN_EMERG "System Halted, OK to turn off power\n"); + + while(1) + ps3_sys_manager_handle_msg(dev); +} + +/** + * ps3_sys_manager_work - Asynchronous read handler. + * + * Signaled when PS3_SM_RX_MSG_LEN_MIN bytes arrive at the vuart port. + */ + +static void ps3_sys_manager_work(struct ps3_system_bus_device *dev) +{ + ps3_sys_manager_handle_msg(dev); + ps3_vuart_read_async(dev, PS3_SM_RX_MSG_LEN_MIN); +} + +static int ps3_sys_manager_probe(struct ps3_system_bus_device *dev) +{ + int result; + struct ps3_sys_manager_ops ops; + + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + + ops.power_off = ps3_sys_manager_final_power_off; + ops.restart = ps3_sys_manager_final_restart; + ops.dev = dev; + + /* ps3_sys_manager_register_ops copies ops. */ + + ps3_sys_manager_register_ops(&ops); + + result = ps3_sys_manager_send_attr(dev, PS3_SM_ATTR_ALL); + BUG_ON(result); + + result = ps3_vuart_read_async(dev, PS3_SM_RX_MSG_LEN_MIN); + BUG_ON(result); + + return result; +} + +static int ps3_sys_manager_remove(struct ps3_system_bus_device *dev) +{ + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + return 0; +} + +static void ps3_sys_manager_shutdown(struct ps3_system_bus_device *dev) +{ + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); +} + +static struct ps3_vuart_port_driver ps3_sys_manager = { + .core.match_id = PS3_MATCH_ID_SYSTEM_MANAGER, + .core.core.name = "ps3_sys_manager", + .probe = ps3_sys_manager_probe, + .remove = ps3_sys_manager_remove, + .shutdown = ps3_sys_manager_shutdown, + .work = ps3_sys_manager_work, +}; + +static int __init ps3_sys_manager_init(void) +{ + if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) + return -ENODEV; + + return ps3_vuart_port_driver_register(&ps3_sys_manager); +} + +module_init(ps3_sys_manager_init); +/* Module remove not supported. */ + +MODULE_ALIAS(PS3_MODULE_ALIAS_SYSTEM_MANAGER); diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c new file mode 100644 index 00000000000..9dea585ef80 --- /dev/null +++ b/drivers/ps3/ps3-vuart.c @@ -0,0 +1,1271 @@ +/* + * PS3 virtual uart + * + * Copyright (C) 2006 Sony Computer Entertainment Inc. + * Copyright 2006 Sony Corp. + * + * 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; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "vuart.h" + +MODULE_AUTHOR("Sony Corporation"); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("PS3 vuart"); + +/** + * vuart - An inter-partition data link service. + * port 0: PS3 AV Settings. + * port 2: PS3 System Manager. + * + * The vuart provides a bi-directional byte stream data link between logical + * partitions. Its primary role is as a communications link between the guest + * OS and the system policy module. The current HV does not support any + * connections other than those listed. + */ + +enum {PORT_COUNT = 3,}; + +enum vuart_param { + PARAM_TX_TRIGGER = 0, + PARAM_RX_TRIGGER = 1, + PARAM_INTERRUPT_MASK = 2, + PARAM_RX_BUF_SIZE = 3, /* read only */ + PARAM_RX_BYTES = 4, /* read only */ + PARAM_TX_BUF_SIZE = 5, /* read only */ + PARAM_TX_BYTES = 6, /* read only */ + PARAM_INTERRUPT_STATUS = 7, /* read only */ +}; + +enum vuart_interrupt_bit { + INTERRUPT_BIT_TX = 0, + INTERRUPT_BIT_RX = 1, + INTERRUPT_BIT_DISCONNECT = 2, +}; + +enum vuart_interrupt_mask { + INTERRUPT_MASK_TX = 1, + INTERRUPT_MASK_RX = 2, + INTERRUPT_MASK_DISCONNECT = 4, +}; + +/** + * struct ps3_vuart_port_priv - private vuart device data. + */ + +struct ps3_vuart_port_priv { + u64 interrupt_mask; + + struct { + spinlock_t lock; + struct list_head head; + } tx_list; + struct { + struct ps3_vuart_work work; + unsigned long bytes_held; + spinlock_t lock; + struct list_head head; + } rx_list; + struct ps3_vuart_stats stats; +}; + +static struct ps3_vuart_port_priv *to_port_priv( + struct ps3_system_bus_device *dev) +{ + BUG_ON(!dev); + BUG_ON(!dev->driver_priv); + return (struct ps3_vuart_port_priv *)dev->driver_priv; +} + +/** + * struct ports_bmp - bitmap indicating ports needing service. + * + * A 256 bit read only bitmap indicating ports needing service. Do not write + * to these bits. Must not cross a page boundary. + */ + +struct ports_bmp { + u64 status; + u64 unused[3]; +} __attribute__ ((aligned (32))); + +#define dump_ports_bmp(_b) _dump_ports_bmp(_b, __func__, __LINE__) +static void __maybe_unused _dump_ports_bmp( + const struct ports_bmp* bmp, const char* func, int line) +{ + pr_debug("%s:%d: ports_bmp: %016lxh\n", func, line, bmp->status); +} + +#define dump_port_params(_b) _dump_port_params(_b, __func__, __LINE__) +static void __maybe_unused _dump_port_params(unsigned int port_number, + const char* func, int line) +{ +#if defined(DEBUG) + static const char *strings[] = { + "tx_trigger ", + "rx_trigger ", + "interrupt_mask ", + "rx_buf_size ", + "rx_bytes ", + "tx_buf_size ", + "tx_bytes ", + "interrupt_status", + }; + int result; + unsigned int i; + u64 value; + + for (i = 0; i < ARRAY_SIZE(strings); i++) { + result = lv1_get_virtual_uart_param(port_number, i, &value); + + if (result) { + pr_debug("%s:%d: port_%u: %s failed: %s\n", func, line, + port_number, strings[i], ps3_result(result)); + continue; + } + pr_debug("%s:%d: port_%u: %s = %lxh\n", + func, line, port_number, strings[i], value); + } +#endif +} + +struct vuart_triggers { + unsigned long rx; + unsigned long tx; +}; + +int ps3_vuart_get_triggers(struct ps3_system_bus_device *dev, + struct vuart_triggers *trig) +{ + int result; + unsigned long size; + unsigned long val; + + result = lv1_get_virtual_uart_param(dev->port_number, + PARAM_TX_TRIGGER, &trig->tx); + + if (result) { + dev_dbg(&dev->core, "%s:%d: tx_trigger failed: %s\n", + __func__, __LINE__, ps3_result(result)); + return result; + } + + result = lv1_get_virtual_uart_param(dev->port_number, + PARAM_RX_BUF_SIZE, &size); + + if (result) { + dev_dbg(&dev->core, "%s:%d: tx_buf_size failed: %s\n", + __func__, __LINE__, ps3_result(result)); + return result; + } + + result = lv1_get_virtual_uart_param(dev->port_number, + PARAM_RX_TRIGGER, &val); + + if (result) { + dev_dbg(&dev->core, "%s:%d: rx_trigger failed: %s\n", + __func__, __LINE__, ps3_result(result)); + return result; + } + + trig->rx = size - val; + + dev_dbg(&dev->core, "%s:%d: tx %lxh, rx %lxh\n", __func__, __LINE__, + trig->tx, trig->rx); + + return result; +} + +int ps3_vuart_set_triggers(struct ps3_system_bus_device *dev, unsigned int tx, + unsigned int rx) +{ + int result; + unsigned long size; + + result = lv1_set_virtual_uart_param(dev->port_number, + PARAM_TX_TRIGGER, tx); + + if (result) { + dev_dbg(&dev->core, "%s:%d: tx_trigger failed: %s\n", + __func__, __LINE__, ps3_result(result)); + return result; + } + + result = lv1_get_virtual_uart_param(dev->port_number, + PARAM_RX_BUF_SIZE, &size); + + if (result) { + dev_dbg(&dev->core, "%s:%d: tx_buf_size failed: %s\n", + __func__, __LINE__, ps3_result(result)); + return result; + } + + result = lv1_set_virtual_uart_param(dev->port_number, + PARAM_RX_TRIGGER, size - rx); + + if (result) { + dev_dbg(&dev->core, "%s:%d: rx_trigger failed: %s\n", + __func__, __LINE__, ps3_result(result)); + return result; + } + + dev_dbg(&dev->core, "%s:%d: tx %xh, rx %xh\n", __func__, __LINE__, + tx, rx); + + return result; +} + +static int ps3_vuart_get_rx_bytes_waiting(struct ps3_system_bus_device *dev, + u64 *bytes_waiting) +{ + int result; + + result = lv1_get_virtual_uart_param(dev->port_number, + PARAM_RX_BYTES, bytes_waiting); + + if (result) + dev_dbg(&dev->core, "%s:%d: rx_bytes failed: %s\n", + __func__, __LINE__, ps3_result(result)); + + dev_dbg(&dev->core, "%s:%d: %lxh\n", __func__, __LINE__, + *bytes_waiting); + return result; +} + +/** + * ps3_vuart_set_interrupt_mask - Enable/disable the port interrupt sources. + * @dev: The struct ps3_system_bus_device instance. + * @bmp: Logical OR of enum vuart_interrupt_mask values. A zero bit disables. + */ + +static int ps3_vuart_set_interrupt_mask(struct ps3_system_bus_device *dev, + unsigned long mask) +{ + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + + dev_dbg(&dev->core, "%s:%d: %lxh\n", __func__, __LINE__, mask); + + priv->interrupt_mask = mask; + + result = lv1_set_virtual_uart_param(dev->port_number, + PARAM_INTERRUPT_MASK, priv->interrupt_mask); + + if (result) + dev_dbg(&dev->core, "%s:%d: interrupt_mask failed: %s\n", + __func__, __LINE__, ps3_result(result)); + + return result; +} + +static int ps3_vuart_get_interrupt_status(struct ps3_system_bus_device *dev, + unsigned long *status) +{ + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + u64 tmp; + + result = lv1_get_virtual_uart_param(dev->port_number, + PARAM_INTERRUPT_STATUS, &tmp); + + if (result) + dev_dbg(&dev->core, "%s:%d: interrupt_status failed: %s\n", + __func__, __LINE__, ps3_result(result)); + + *status = tmp & priv->interrupt_mask; + + dev_dbg(&dev->core, "%s:%d: m %lxh, s %lxh, m&s %lxh\n", + __func__, __LINE__, priv->interrupt_mask, tmp, *status); + + return result; +} + +int ps3_vuart_enable_interrupt_tx(struct ps3_system_bus_device *dev) +{ + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + + return (priv->interrupt_mask & INTERRUPT_MASK_TX) ? 0 + : ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask + | INTERRUPT_MASK_TX); +} + +int ps3_vuart_enable_interrupt_rx(struct ps3_system_bus_device *dev) +{ + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + + return (priv->interrupt_mask & INTERRUPT_MASK_RX) ? 0 + : ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask + | INTERRUPT_MASK_RX); +} + +int ps3_vuart_enable_interrupt_disconnect(struct ps3_system_bus_device *dev) +{ + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + + return (priv->interrupt_mask & INTERRUPT_MASK_DISCONNECT) ? 0 + : ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask + | INTERRUPT_MASK_DISCONNECT); +} + +int ps3_vuart_disable_interrupt_tx(struct ps3_system_bus_device *dev) +{ + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + + return (priv->interrupt_mask & INTERRUPT_MASK_TX) + ? ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask + & ~INTERRUPT_MASK_TX) : 0; +} + +int ps3_vuart_disable_interrupt_rx(struct ps3_system_bus_device *dev) +{ + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + + return (priv->interrupt_mask & INTERRUPT_MASK_RX) + ? ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask + & ~INTERRUPT_MASK_RX) : 0; +} + +int ps3_vuart_disable_interrupt_disconnect(struct ps3_system_bus_device *dev) +{ + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + + return (priv->interrupt_mask & INTERRUPT_MASK_DISCONNECT) + ? ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask + & ~INTERRUPT_MASK_DISCONNECT) : 0; +} + +/** + * ps3_vuart_raw_write - Low level write helper. + * @dev: The struct ps3_system_bus_device instance. + * + * Do not call ps3_vuart_raw_write directly, use ps3_vuart_write. + */ + +static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev, + const void* buf, unsigned int bytes, unsigned long *bytes_written) +{ + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + + result = lv1_write_virtual_uart(dev->port_number, + ps3_mm_phys_to_lpar(__pa(buf)), bytes, bytes_written); + + if (result) { + dev_dbg(&dev->core, "%s:%d: lv1_write_virtual_uart failed: " + "%s\n", __func__, __LINE__, ps3_result(result)); + return result; + } + + priv->stats.bytes_written += *bytes_written; + + dev_dbg(&dev->core, "%s:%d: wrote %lxh/%xh=>%lxh\n", __func__, __LINE__, + *bytes_written, bytes, priv->stats.bytes_written); + + return result; +} + +/** + * ps3_vuart_raw_read - Low level read helper. + * @dev: The struct ps3_system_bus_device instance. + * + * Do not call ps3_vuart_raw_read directly, use ps3_vuart_read. + */ + +static int ps3_vuart_raw_read(struct ps3_system_bus_device *dev, void *buf, + unsigned int bytes, unsigned long *bytes_read) +{ + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + + dev_dbg(&dev->core, "%s:%d: %xh\n", __func__, __LINE__, bytes); + + result = lv1_read_virtual_uart(dev->port_number, + ps3_mm_phys_to_lpar(__pa(buf)), bytes, bytes_read); + + if (result) { + dev_dbg(&dev->core, "%s:%d: lv1_read_virtual_uart failed: %s\n", + __func__, __LINE__, ps3_result(result)); + return result; + } + + priv->stats.bytes_read += *bytes_read; + + dev_dbg(&dev->core, "%s:%d: read %lxh/%xh=>%lxh\n", __func__, __LINE__, + *bytes_read, bytes, priv->stats.bytes_read); + + return result; +} + +/** + * ps3_vuart_clear_rx_bytes - Discard bytes received. + * @dev: The struct ps3_system_bus_device instance. + * @bytes: Max byte count to discard, zero = all pending. + * + * Used to clear pending rx interrupt source. Will not block. + */ + +void ps3_vuart_clear_rx_bytes(struct ps3_system_bus_device *dev, + unsigned int bytes) +{ + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + u64 bytes_waiting; + void* tmp; + + result = ps3_vuart_get_rx_bytes_waiting(dev, &bytes_waiting); + + BUG_ON(result); + + bytes = bytes ? min(bytes, (unsigned int)bytes_waiting) : bytes_waiting; + + dev_dbg(&dev->core, "%s:%d: %u\n", __func__, __LINE__, bytes); + + if (!bytes) + return; + + /* Add some extra space for recently arrived data. */ + + bytes += 128; + + tmp = kmalloc(bytes, GFP_KERNEL); + + if (!tmp) + return; + + ps3_vuart_raw_read(dev, tmp, bytes, &bytes_waiting); + + kfree(tmp); + + /* Don't include these bytes in the stats. */ + + priv->stats.bytes_read -= bytes_waiting; +} +EXPORT_SYMBOL_GPL(ps3_vuart_clear_rx_bytes); + +/** + * struct list_buffer - An element for a port device fifo buffer list. + */ + +struct list_buffer { + struct list_head link; + const unsigned char *head; + const unsigned char *tail; + unsigned long dbg_number; + unsigned char data[]; +}; + +/** + * ps3_vuart_write - the entry point for writing data to a port + * @dev: The struct ps3_system_bus_device instance. + * + * If the port is idle on entry as much of the incoming data is written to + * the port as the port will accept. Otherwise a list buffer is created + * and any remaning incoming data is copied to that buffer. The buffer is + * then enqueued for transmision via the transmit interrupt. + */ + +int ps3_vuart_write(struct ps3_system_bus_device *dev, const void *buf, + unsigned int bytes) +{ + static unsigned long dbg_number; + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + unsigned long flags; + struct list_buffer *lb; + + dev_dbg(&dev->core, "%s:%d: %u(%xh) bytes\n", __func__, __LINE__, + bytes, bytes); + + spin_lock_irqsave(&priv->tx_list.lock, flags); + + if (list_empty(&priv->tx_list.head)) { + unsigned long bytes_written; + + result = ps3_vuart_raw_write(dev, buf, bytes, &bytes_written); + + spin_unlock_irqrestore(&priv->tx_list.lock, flags); + + if (result) { + dev_dbg(&dev->core, + "%s:%d: ps3_vuart_raw_write failed\n", + __func__, __LINE__); + return result; + } + + if (bytes_written == bytes) { + dev_dbg(&dev->core, "%s:%d: wrote %xh bytes\n", + __func__, __LINE__, bytes); + return 0; + } + + bytes -= bytes_written; + buf += bytes_written; + } else + spin_unlock_irqrestore(&priv->tx_list.lock, flags); + + lb = kmalloc(sizeof(struct list_buffer) + bytes, GFP_KERNEL); + + if (!lb) { + return -ENOMEM; + } + + memcpy(lb->data, buf, bytes); + lb->head = lb->data; + lb->tail = lb->data + bytes; + lb->dbg_number = ++dbg_number; + + spin_lock_irqsave(&priv->tx_list.lock, flags); + list_add_tail(&lb->link, &priv->tx_list.head); + ps3_vuart_enable_interrupt_tx(dev); + spin_unlock_irqrestore(&priv->tx_list.lock, flags); + + dev_dbg(&dev->core, "%s:%d: queued buf_%lu, %xh bytes\n", + __func__, __LINE__, lb->dbg_number, bytes); + + return 0; +} +EXPORT_SYMBOL_GPL(ps3_vuart_write); + +/** + * ps3_vuart_queue_rx_bytes - Queue waiting bytes into the buffer list. + * @dev: The struct ps3_system_bus_device instance. + * @bytes_queued: Number of bytes queued to the buffer list. + * + * Must be called with priv->rx_list.lock held. + */ + +static int ps3_vuart_queue_rx_bytes(struct ps3_system_bus_device *dev, + u64 *bytes_queued) +{ + static unsigned long dbg_number; + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + struct list_buffer *lb; + u64 bytes; + + *bytes_queued = 0; + + result = ps3_vuart_get_rx_bytes_waiting(dev, &bytes); + BUG_ON(result); + + if (result) + return -EIO; + + if (!bytes) + return 0; + + /* Add some extra space for recently arrived data. */ + + bytes += 128; + + lb = kmalloc(sizeof(struct list_buffer) + bytes, GFP_ATOMIC); + + if (!lb) + return -ENOMEM; + + ps3_vuart_raw_read(dev, lb->data, bytes, &bytes); + + lb->head = lb->data; + lb->tail = lb->data + bytes; + lb->dbg_number = ++dbg_number; + + list_add_tail(&lb->link, &priv->rx_list.head); + priv->rx_list.bytes_held += bytes; + + dev_dbg(&dev->core, "%s:%d: buf_%lu: queued %lxh bytes\n", + __func__, __LINE__, lb->dbg_number, bytes); + + *bytes_queued = bytes; + + return 0; +} + +/** + * ps3_vuart_read - The entry point for reading data from a port. + * + * Queue data waiting at the port, and if enough bytes to satisfy the request + * are held in the buffer list those bytes are dequeued and copied to the + * caller's buffer. Emptied list buffers are retiered. If the request cannot + * be statified by bytes held in the list buffers -EAGAIN is returned. + */ + +int ps3_vuart_read(struct ps3_system_bus_device *dev, void *buf, + unsigned int bytes) +{ + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + unsigned long flags; + struct list_buffer *lb, *n; + unsigned long bytes_read; + + dev_dbg(&dev->core, "%s:%d: %u(%xh) bytes\n", __func__, __LINE__, + bytes, bytes); + + spin_lock_irqsave(&priv->rx_list.lock, flags); + + /* Queue rx bytes here for polled reads. */ + + while (priv->rx_list.bytes_held < bytes) { + u64 tmp; + + result = ps3_vuart_queue_rx_bytes(dev, &tmp); + if (result || !tmp) { + dev_dbg(&dev->core, "%s:%d: starved for %lxh bytes\n", + __func__, __LINE__, + bytes - priv->rx_list.bytes_held); + spin_unlock_irqrestore(&priv->rx_list.lock, flags); + return -EAGAIN; + } + } + + list_for_each_entry_safe(lb, n, &priv->rx_list.head, link) { + bytes_read = min((unsigned int)(lb->tail - lb->head), bytes); + + memcpy(buf, lb->head, bytes_read); + buf += bytes_read; + bytes -= bytes_read; + priv->rx_list.bytes_held -= bytes_read; + + if (bytes_read < lb->tail - lb->head) { + lb->head += bytes_read; + dev_dbg(&dev->core, "%s:%d: buf_%lu: dequeued %lxh " + "bytes\n", __func__, __LINE__, lb->dbg_number, + bytes_read); + spin_unlock_irqrestore(&priv->rx_list.lock, flags); + return 0; + } + + dev_dbg(&dev->core, "%s:%d: buf_%lu: free, dequeued %lxh " + "bytes\n", __func__, __LINE__, lb->dbg_number, + bytes_read); + + list_del(&lb->link); + kfree(lb); + } + + spin_unlock_irqrestore(&priv->rx_list.lock, flags); + return 0; +} +EXPORT_SYMBOL_GPL(ps3_vuart_read); + +/** + * ps3_vuart_work - Asynchronous read handler. + */ + +static void ps3_vuart_work(struct work_struct *work) +{ + struct ps3_system_bus_device *dev = + ps3_vuart_work_to_system_bus_dev(work); + struct ps3_vuart_port_driver *drv = + ps3_system_bus_dev_to_vuart_drv(dev); + + BUG_ON(!drv); + drv->work(dev); +} + +int ps3_vuart_read_async(struct ps3_system_bus_device *dev, unsigned int bytes) +{ + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + unsigned long flags; + + if (priv->rx_list.work.trigger) { + dev_dbg(&dev->core, "%s:%d: warning, multiple calls\n", + __func__, __LINE__); + return -EAGAIN; + } + + BUG_ON(!bytes); + + PREPARE_WORK(&priv->rx_list.work.work, ps3_vuart_work); + + spin_lock_irqsave(&priv->rx_list.lock, flags); + if (priv->rx_list.bytes_held >= bytes) { + dev_dbg(&dev->core, "%s:%d: schedule_work %xh bytes\n", + __func__, __LINE__, bytes); + schedule_work(&priv->rx_list.work.work); + spin_unlock_irqrestore(&priv->rx_list.lock, flags); + return 0; + } + + priv->rx_list.work.trigger = bytes; + spin_unlock_irqrestore(&priv->rx_list.lock, flags); + + dev_dbg(&dev->core, "%s:%d: waiting for %u(%xh) bytes\n", __func__, + __LINE__, bytes, bytes); + + return 0; +} +EXPORT_SYMBOL_GPL(ps3_vuart_read_async); + +void ps3_vuart_cancel_async(struct ps3_system_bus_device *dev) +{ + to_port_priv(dev)->rx_list.work.trigger = 0; +} +EXPORT_SYMBOL_GPL(ps3_vuart_cancel_async); + +/** + * ps3_vuart_handle_interrupt_tx - third stage transmit interrupt handler + * + * Services the transmit interrupt for the port. Writes as much data from the + * buffer list as the port will accept. Retires any emptied list buffers and + * adjusts the final list buffer state for a partial write. + */ + +static int ps3_vuart_handle_interrupt_tx(struct ps3_system_bus_device *dev) +{ + int result = 0; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + unsigned long flags; + struct list_buffer *lb, *n; + unsigned long bytes_total = 0; + + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + + spin_lock_irqsave(&priv->tx_list.lock, flags); + + list_for_each_entry_safe(lb, n, &priv->tx_list.head, link) { + + unsigned long bytes_written; + + result = ps3_vuart_raw_write(dev, lb->head, lb->tail - lb->head, + &bytes_written); + + if (result) { + dev_dbg(&dev->core, + "%s:%d: ps3_vuart_raw_write failed\n", + __func__, __LINE__); + break; + } + + bytes_total += bytes_written; + + if (bytes_written < lb->tail - lb->head) { + lb->head += bytes_written; + dev_dbg(&dev->core, + "%s:%d cleared buf_%lu, %lxh bytes\n", + __func__, __LINE__, lb->dbg_number, + bytes_written); + goto port_full; + } + + dev_dbg(&dev->core, "%s:%d free buf_%lu\n", __func__, __LINE__, + lb->dbg_number); + + list_del(&lb->link); + kfree(lb); + } + + ps3_vuart_disable_interrupt_tx(dev); +port_full: + spin_unlock_irqrestore(&priv->tx_list.lock, flags); + dev_dbg(&dev->core, "%s:%d wrote %lxh bytes total\n", + __func__, __LINE__, bytes_total); + return result; +} + +/** + * ps3_vuart_handle_interrupt_rx - third stage receive interrupt handler + * + * Services the receive interrupt for the port. Creates a list buffer and + * copies all waiting port data to that buffer and enqueues the buffer in the + * buffer list. Buffer list data is dequeued via ps3_vuart_read. + */ + +static int ps3_vuart_handle_interrupt_rx(struct ps3_system_bus_device *dev) +{ + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + unsigned long flags; + u64 bytes; + + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + + spin_lock_irqsave(&priv->rx_list.lock, flags); + result = ps3_vuart_queue_rx_bytes(dev, &bytes); + + if (result) { + spin_unlock_irqrestore(&priv->rx_list.lock, flags); + return result; + } + + if (priv->rx_list.work.trigger && priv->rx_list.bytes_held + >= priv->rx_list.work.trigger) { + dev_dbg(&dev->core, "%s:%d: schedule_work %lxh bytes\n", + __func__, __LINE__, priv->rx_list.work.trigger); + priv->rx_list.work.trigger = 0; + schedule_work(&priv->rx_list.work.work); + } + + spin_unlock_irqrestore(&priv->rx_list.lock, flags); + return result; +} + +static int ps3_vuart_handle_interrupt_disconnect( + struct ps3_system_bus_device *dev) +{ + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + BUG_ON("no support"); + return -1; +} + +/** + * ps3_vuart_handle_port_interrupt - second stage interrupt handler + * + * Services any pending interrupt types for the port. Passes control to the + * third stage type specific interrupt handler. Returns control to the first + * stage handler after one iteration. + */ + +static int ps3_vuart_handle_port_interrupt(struct ps3_system_bus_device *dev) +{ + int result; + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + unsigned long status; + + result = ps3_vuart_get_interrupt_status(dev, &status); + + if (result) + return result; + + dev_dbg(&dev->core, "%s:%d: status: %lxh\n", __func__, __LINE__, + status); + + if (status & INTERRUPT_MASK_DISCONNECT) { + priv->stats.disconnect_interrupts++; + result = ps3_vuart_handle_interrupt_disconnect(dev); + if (result) + ps3_vuart_disable_interrupt_disconnect(dev); + } + + if (status & INTERRUPT_MASK_TX) { + priv->stats.tx_interrupts++; + result = ps3_vuart_handle_interrupt_tx(dev); + if (result) + ps3_vuart_disable_interrupt_tx(dev); + } + + if (status & INTERRUPT_MASK_RX) { + priv->stats.rx_interrupts++; + result = ps3_vuart_handle_interrupt_rx(dev); + if (result) + ps3_vuart_disable_interrupt_rx(dev); + } + + return 0; +} + +struct vuart_bus_priv { + struct ports_bmp *bmp; + unsigned int virq; + struct semaphore probe_mutex; + int use_count; + struct ps3_system_bus_device *devices[PORT_COUNT]; +} static vuart_bus_priv; + +/** + * ps3_vuart_irq_handler - first stage interrupt handler + * + * Loops finding any interrupting port and its associated instance data. + * Passes control to the second stage port specific interrupt handler. Loops + * until all outstanding interrupts are serviced. + */ + +static irqreturn_t ps3_vuart_irq_handler(int irq, void *_private) +{ + struct vuart_bus_priv *bus_priv = _private; + + BUG_ON(!bus_priv); + + while (1) { + unsigned int port; + + dump_ports_bmp(bus_priv->bmp); + + port = (BITS_PER_LONG - 1) - __ilog2(bus_priv->bmp->status); + + if (port == BITS_PER_LONG) + break; + + BUG_ON(port >= PORT_COUNT); + BUG_ON(!bus_priv->devices[port]); + + ps3_vuart_handle_port_interrupt(bus_priv->devices[port]); + } + + return IRQ_HANDLED; +} + +static int ps3_vuart_bus_interrupt_get(void) +{ + int result; + + pr_debug(" -> %s:%d\n", __func__, __LINE__); + + vuart_bus_priv.use_count++; + + BUG_ON(vuart_bus_priv.use_count > 2); + + if (vuart_bus_priv.use_count != 1) { + return 0; + } + + BUG_ON(vuart_bus_priv.bmp); + + vuart_bus_priv.bmp = kzalloc(sizeof(struct ports_bmp), GFP_KERNEL); + + if (!vuart_bus_priv.bmp) { + pr_debug("%s:%d: kzalloc failed.\n", __func__, __LINE__); + result = -ENOMEM; + goto fail_bmp_malloc; + } + + result = ps3_vuart_irq_setup(PS3_BINDING_CPU_ANY, vuart_bus_priv.bmp, + &vuart_bus_priv.virq); + + if (result) { + pr_debug("%s:%d: ps3_vuart_irq_setup failed (%d)\n", + __func__, __LINE__, result); + result = -EPERM; + goto fail_alloc_irq; + } + + result = request_irq(vuart_bus_priv.virq, ps3_vuart_irq_handler, + IRQF_DISABLED, "vuart", &vuart_bus_priv); + + if (result) { + pr_debug("%s:%d: request_irq failed (%d)\n", + __func__, __LINE__, result); + goto fail_request_irq; + } + + pr_debug(" <- %s:%d: ok\n", __func__, __LINE__); + return result; + +fail_request_irq: + ps3_vuart_irq_destroy(vuart_bus_priv.virq); + vuart_bus_priv.virq = NO_IRQ; +fail_alloc_irq: + kfree(vuart_bus_priv.bmp); + vuart_bus_priv.bmp = NULL; +fail_bmp_malloc: + vuart_bus_priv.use_count--; + pr_debug(" <- %s:%d: failed\n", __func__, __LINE__); + return result; +} + +static int ps3_vuart_bus_interrupt_put(void) +{ + pr_debug(" -> %s:%d\n", __func__, __LINE__); + + vuart_bus_priv.use_count--; + + BUG_ON(vuart_bus_priv.use_count < 0); + + if (vuart_bus_priv.use_count != 0) + return 0; + + free_irq(vuart_bus_priv.virq, &vuart_bus_priv); + + ps3_vuart_irq_destroy(vuart_bus_priv.virq); + vuart_bus_priv.virq = NO_IRQ; + + kfree(vuart_bus_priv.bmp); + vuart_bus_priv.bmp = NULL; + + pr_debug(" <- %s:%d\n", __func__, __LINE__); + return 0; +} + +static int ps3_vuart_probe(struct ps3_system_bus_device *dev) +{ + int result; + struct ps3_vuart_port_driver *drv; + struct ps3_vuart_port_priv *priv = NULL; + + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + + drv = ps3_system_bus_dev_to_vuart_drv(dev); + + dev_dbg(&dev->core, "%s:%d: (%s)\n", __func__, __LINE__, + drv->core.core.name); + + BUG_ON(!drv); + + if (dev->port_number >= PORT_COUNT) { + BUG(); + return -EINVAL; + } + + down(&vuart_bus_priv.probe_mutex); + + result = ps3_vuart_bus_interrupt_get(); + + if (result) + goto fail_setup_interrupt; + + if (vuart_bus_priv.devices[dev->port_number]) { + dev_dbg(&dev->core, "%s:%d: port busy (%d)\n", __func__, + __LINE__, dev->port_number); + result = -EBUSY; + goto fail_busy; + } + + vuart_bus_priv.devices[dev->port_number] = dev; + + /* Setup dev->driver_priv. */ + + dev->driver_priv = kzalloc(sizeof(struct ps3_vuart_port_priv), + GFP_KERNEL); + + if (!dev->driver_priv) { + result = -ENOMEM; + goto fail_dev_malloc; + } + + priv = to_port_priv(dev); + + INIT_LIST_HEAD(&priv->tx_list.head); + spin_lock_init(&priv->tx_list.lock); + + INIT_LIST_HEAD(&priv->rx_list.head); + spin_lock_init(&priv->rx_list.lock); + + INIT_WORK(&priv->rx_list.work.work, NULL); + priv->rx_list.work.trigger = 0; + priv->rx_list.work.dev = dev; + + /* clear stale pending interrupts */ + + ps3_vuart_clear_rx_bytes(dev, 0); + + ps3_vuart_set_interrupt_mask(dev, INTERRUPT_MASK_RX); + + ps3_vuart_set_triggers(dev, 1, 1); + + if (drv->probe) + result = drv->probe(dev); + else { + result = 0; + dev_info(&dev->core, "%s:%d: no probe method\n", __func__, + __LINE__); + } + + if (result) { + dev_dbg(&dev->core, "%s:%d: drv->probe failed\n", + __func__, __LINE__); + down(&vuart_bus_priv.probe_mutex); + goto fail_probe; + } + + up(&vuart_bus_priv.probe_mutex); + + return result; + +fail_probe: + ps3_vuart_set_interrupt_mask(dev, 0); + kfree(dev->driver_priv); + dev->driver_priv = NULL; +fail_dev_malloc: + vuart_bus_priv.devices[dev->port_number] = NULL; +fail_busy: + ps3_vuart_bus_interrupt_put(); +fail_setup_interrupt: + up(&vuart_bus_priv.probe_mutex); + dev_dbg(&dev->core, "%s:%d: failed\n", __func__, __LINE__); + return result; +} + +/** + * ps3_vuart_cleanup - common cleanup helper. + * @dev: The struct ps3_system_bus_device instance. + * + * Cleans interrupts and HV resources. Must be called with + * vuart_bus_priv.probe_mutex held. Used by ps3_vuart_remove and + * ps3_vuart_shutdown. After this call, polled reading will still work. + */ + +static int ps3_vuart_cleanup(struct ps3_system_bus_device *dev) +{ + dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); + + ps3_vuart_cancel_async(dev); + ps3_vuart_set_interrupt_mask(dev, 0); + ps3_vuart_bus_interrupt_put(); + return 0; +} + +/** + * ps3_vuart_remove - Completely clean the device instance. + * @dev: The struct ps3_system_bus_device instance. + * + * Cleans all memory, interrupts and HV resources. After this call the + * device can no longer be used. + */ + +static int ps3_vuart_remove(struct ps3_system_bus_device *dev) +{ + struct ps3_vuart_port_priv *priv = to_port_priv(dev); + struct ps3_vuart_port_driver *drv; + + BUG_ON(!dev); + + down(&vuart_bus_priv.probe_mutex); + + dev_dbg(&dev->core, " -> %s:%d: match_id %d\n", __func__, __LINE__, + dev->match_id); + + if (!dev->core.driver) { + dev_dbg(&dev->core, "%s:%d: no driver bound\n", __func__, + __LINE__); + up(&vuart_bus_priv.probe_mutex); + return 0; + } + + drv = ps3_system_bus_dev_to_vuart_drv(dev); + + BUG_ON(!drv); + + if (drv->remove) { + drv->remove(dev); + } else { + dev_dbg(&dev->core, "%s:%d: no remove method\n", __func__, + __LINE__); + BUG(); + } + + ps3_vuart_cleanup(dev); + + vuart_bus_priv.devices[dev->port_number] = NULL; + kfree(priv); + priv = NULL; + + dev_dbg(&dev->core, " <- %s:%d\n", __func__, __LINE__); + up(&vuart_bus_priv.probe_mutex); + return 0; +} + +/** + * ps3_vuart_shutdown - Cleans interrupts and HV resources. + * @dev: The struct ps3_system_bus_device instance. + * + * Cleans interrupts and HV resources. After this call the + * device can still be used in polling mode. This behavior required + * by sys-manager to be able to complete the device power operation + * sequence. + */ + +static int ps3_vuart_shutdown(struct ps3_system_bus_device *dev) +{ + struct ps3_vuart_port_driver *drv; + + BUG_ON(!dev); + + down(&vuart_bus_priv.probe_mutex); + + dev_dbg(&dev->core, " -> %s:%d: match_id %d\n", __func__, __LINE__, + dev->match_id); + + if (!dev->core.driver) { + dev_dbg(&dev->core, "%s:%d: no driver bound\n", __func__, + __LINE__); + up(&vuart_bus_priv.probe_mutex); + return 0; + } + + drv = ps3_system_bus_dev_to_vuart_drv(dev); + + BUG_ON(!drv); + + if (drv->shutdown) + drv->shutdown(dev); + else if (drv->remove) { + dev_dbg(&dev->core, "%s:%d: no shutdown, calling remove\n", + __func__, __LINE__); + drv->remove(dev); + } else { + dev_dbg(&dev->core, "%s:%d: no shutdown method\n", __func__, + __LINE__); + BUG(); + } + + ps3_vuart_cleanup(dev); + + dev_dbg(&dev->core, " <- %s:%d\n", __func__, __LINE__); + + up(&vuart_bus_priv.probe_mutex); + return 0; +} + +static int __init ps3_vuart_bus_init(void) +{ + pr_debug("%s:%d:\n", __func__, __LINE__); + + if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) + return -ENODEV; + + init_MUTEX(&vuart_bus_priv.probe_mutex); + + return 0; +} + +static void __exit ps3_vuart_bus_exit(void) +{ + pr_debug("%s:%d:\n", __func__, __LINE__); +} + +core_initcall(ps3_vuart_bus_init); +module_exit(ps3_vuart_bus_exit); + +/** + * ps3_vuart_port_driver_register - Add a vuart port device driver. + */ + +int ps3_vuart_port_driver_register(struct ps3_vuart_port_driver *drv) +{ + int result; + + pr_debug("%s:%d: (%s)\n", __func__, __LINE__, drv->core.core.name); + + BUG_ON(!drv->core.match_id); + BUG_ON(!drv->core.core.name); + + drv->core.probe = ps3_vuart_probe; + drv->core.remove = ps3_vuart_remove; + drv->core.shutdown = ps3_vuart_shutdown; + + result = ps3_system_bus_driver_register(&drv->core); + return result; +} +EXPORT_SYMBOL_GPL(ps3_vuart_port_driver_register); + +/** + * ps3_vuart_port_driver_unregister - Remove a vuart port device driver. + */ + +void ps3_vuart_port_driver_unregister(struct ps3_vuart_port_driver *drv) +{ + pr_debug("%s:%d: (%s)\n", __func__, __LINE__, drv->core.core.name); + ps3_system_bus_driver_unregister(&drv->core); +} +EXPORT_SYMBOL_GPL(ps3_vuart_port_driver_unregister); diff --git a/drivers/ps3/sys-manager.c b/drivers/ps3/sys-manager.c deleted file mode 100644 index 8461b08ab9f..00000000000 --- a/drivers/ps3/sys-manager.c +++ /dev/null @@ -1,702 +0,0 @@ -/* - * PS3 System Manager. - * - * Copyright (C) 2007 Sony Computer Entertainment Inc. - * Copyright 2007 Sony Corp. - * - * 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; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include -#include - -#include "vuart.h" - -MODULE_AUTHOR("Sony Corporation"); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PS3 System Manager"); - -/** - * ps3_sys_manager - PS3 system manager driver. - * - * The system manager provides an asynchronous system event notification - * mechanism for reporting events like thermal alert and button presses to - * guests. It also provides support to control system shutdown and startup. - * - * The actual system manager is implemented as an application running in the - * system policy module in lpar_1. Guests communicate with the system manager - * through port 2 of the vuart using a simple packet message protocol. - * Messages are comprised of a fixed field header followed by a message - * specific payload. - */ - -/** - * struct ps3_sys_manager_header - System manager message header. - * @version: Header version, currently 1. - * @size: Header size in bytes, curently 16. - * @payload_size: Message payload size in bytes. - * @service_id: Message type, one of enum ps3_sys_manager_service_id. - * @request_tag: Unique number to identify reply. - */ - -struct ps3_sys_manager_header { - /* version 1 */ - u8 version; - u8 size; - u16 reserved_1; - u32 payload_size; - u16 service_id; - u16 reserved_2; - u32 request_tag; -}; - -#define dump_sm_header(_h) _dump_sm_header(_h, __func__, __LINE__) -static void __maybe_unused _dump_sm_header( - const struct ps3_sys_manager_header *h, const char *func, int line) -{ - pr_debug("%s:%d: version: %xh\n", func, line, h->version); - pr_debug("%s:%d: size: %xh\n", func, line, h->size); - pr_debug("%s:%d: payload_size: %xh\n", func, line, h->payload_size); - pr_debug("%s:%d: service_id: %xh\n", func, line, h->service_id); - pr_debug("%s:%d: request_tag: %xh\n", func, line, h->request_tag); -} - -/** - * @PS3_SM_RX_MSG_LEN_MIN - Shortest received message length. - * @PS3_SM_RX_MSG_LEN_MAX - Longest received message length. - * - * Currently all messages received from the system manager are either - * (16 bytes header + 8 bytes payload = 24 bytes) or (16 bytes header - * + 16 bytes payload = 32 bytes). This knowlege is used to simplify - * the logic. - */ - -enum { - PS3_SM_RX_MSG_LEN_MIN = 24, - PS3_SM_RX_MSG_LEN_MAX = 32, -}; - -/** - * enum ps3_sys_manager_service_id - Message header service_id. - * @PS3_SM_SERVICE_ID_REQUEST: guest --> sys_manager. - * @PS3_SM_SERVICE_ID_REQUEST_ERROR: guest <-- sys_manager. - * @PS3_SM_SERVICE_ID_COMMAND: guest <-- sys_manager. - * @PS3_SM_SERVICE_ID_RESPONSE: guest --> sys_manager. - * @PS3_SM_SERVICE_ID_SET_ATTR: guest --> sys_manager. - * @PS3_SM_SERVICE_ID_EXTERN_EVENT: guest <-- sys_manager. - * @PS3_SM_SERVICE_ID_SET_NEXT_OP: guest --> sys_manager. - * - * PS3_SM_SERVICE_ID_REQUEST_ERROR is returned for invalid data values in a - * a PS3_SM_SERVICE_ID_REQUEST message. It also seems to be returned when - * a REQUEST message is sent at the wrong time. - */ - -enum ps3_sys_manager_service_id { - /* version 1 */ - PS3_SM_SERVICE_ID_REQUEST = 1, - PS3_SM_SERVICE_ID_RESPONSE = 2, - PS3_SM_SERVICE_ID_COMMAND = 3, - PS3_SM_SERVICE_ID_EXTERN_EVENT = 4, - PS3_SM_SERVICE_ID_SET_NEXT_OP = 5, - PS3_SM_SERVICE_ID_REQUEST_ERROR = 6, - PS3_SM_SERVICE_ID_SET_ATTR = 8, -}; - -/** - * enum ps3_sys_manager_attr - Notification attribute (bit position mask). - * @PS3_SM_ATTR_POWER: Power button. - * @PS3_SM_ATTR_RESET: Reset button, not available on retail console. - * @PS3_SM_ATTR_THERMAL: Sytem thermal alert. - * @PS3_SM_ATTR_CONTROLLER: Remote controller event. - * @PS3_SM_ATTR_ALL: Logical OR of all. - * - * The guest tells the system manager which events it is interested in receiving - * notice of by sending the system manager a logical OR of notification - * attributes via the ps3_sys_manager_send_attr() routine. - */ - -enum ps3_sys_manager_attr { - /* version 1 */ - PS3_SM_ATTR_POWER = 1, - PS3_SM_ATTR_RESET = 2, - PS3_SM_ATTR_THERMAL = 4, - PS3_SM_ATTR_CONTROLLER = 8, /* bogus? */ - PS3_SM_ATTR_ALL = 0x0f, -}; - -/** - * enum ps3_sys_manager_event - External event type, reported by system manager. - * @PS3_SM_EVENT_POWER_PRESSED: payload.value not used. - * @PS3_SM_EVENT_POWER_RELEASED: payload.value = time pressed in millisec. - * @PS3_SM_EVENT_RESET_PRESSED: payload.value not used. - * @PS3_SM_EVENT_RESET_RELEASED: payload.value = time pressed in millisec. - * @PS3_SM_EVENT_THERMAL_ALERT: payload.value = thermal zone id. - * @PS3_SM_EVENT_THERMAL_CLEARED: payload.value = thermal zone id. - */ - -enum ps3_sys_manager_event { - /* version 1 */ - PS3_SM_EVENT_POWER_PRESSED = 3, - PS3_SM_EVENT_POWER_RELEASED = 4, - PS3_SM_EVENT_RESET_PRESSED = 5, - PS3_SM_EVENT_RESET_RELEASED = 6, - PS3_SM_EVENT_THERMAL_ALERT = 7, - PS3_SM_EVENT_THERMAL_CLEARED = 8, - /* no info on controller events */ -}; - -/** - * enum ps3_sys_manager_next_op - Operation to perform after lpar is destroyed. - */ - -enum ps3_sys_manager_next_op { - /* version 3 */ - PS3_SM_NEXT_OP_SYS_SHUTDOWN = 1, - PS3_SM_NEXT_OP_SYS_REBOOT = 2, - PS3_SM_NEXT_OP_LPAR_REBOOT = 0x82, -}; - -/** - * enum ps3_sys_manager_wake_source - Next-op wakeup source (bit position mask). - * @PS3_SM_WAKE_DEFAULT: Disk insert, power button, eject button, IR - * controller, and bluetooth controller. - * @PS3_SM_WAKE_RTC: - * @PS3_SM_WAKE_RTC_ERROR: - * @PS3_SM_WAKE_P_O_R: Power on reset. - * - * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN. - * System will always wake from the PS3_SM_WAKE_DEFAULT sources. - */ - -enum ps3_sys_manager_wake_source { - /* version 3 */ - PS3_SM_WAKE_DEFAULT = 0, - PS3_SM_WAKE_RTC = 0x00000040, - PS3_SM_WAKE_RTC_ERROR = 0x00000080, - PS3_SM_WAKE_P_O_R = 0x10000000, -}; - -/** - * enum ps3_sys_manager_cmd - Command from system manager to guest. - * - * The guest completes the actions needed, then acks or naks the command via - * ps3_sys_manager_send_response(). In the case of @PS3_SM_CMD_SHUTDOWN, - * the guest must be fully prepared for a system poweroff prior to acking the - * command. - */ - -enum ps3_sys_manager_cmd { - /* version 1 */ - PS3_SM_CMD_SHUTDOWN = 1, /* shutdown guest OS */ -}; - -/** - * ps3_sm_force_power_off - Poweroff helper. - * - * A global variable used to force a poweroff when the power button has - * been pressed irrespective of how init handles the ctrl_alt_del signal. - * - */ - -static unsigned int ps3_sm_force_power_off; - -/** - * ps3_sys_manager_write - Helper to write a two part message to the vuart. - * - */ - -static int ps3_sys_manager_write(struct ps3_system_bus_device *dev, - const struct ps3_sys_manager_header *header, const void *payload) -{ - int result; - - BUG_ON(header->version != 1); - BUG_ON(header->size != 16); - BUG_ON(header->payload_size != 8 && header->payload_size != 16); - BUG_ON(header->service_id > 8); - - result = ps3_vuart_write(dev, header, - sizeof(struct ps3_sys_manager_header)); - - if (!result) - result = ps3_vuart_write(dev, payload, header->payload_size); - - return result; -} - -/** - * ps3_sys_manager_send_attr - Send a 'set attribute' to the system manager. - * - */ - -static int ps3_sys_manager_send_attr(struct ps3_system_bus_device *dev, - enum ps3_sys_manager_attr attr) -{ - struct ps3_sys_manager_header header; - struct { - u8 version; - u8 reserved_1[3]; - u32 attribute; - } payload; - - BUILD_BUG_ON(sizeof(payload) != 8); - - dev_dbg(&dev->core, "%s:%d: %xh\n", __func__, __LINE__, attr); - - memset(&header, 0, sizeof(header)); - header.version = 1; - header.size = 16; - header.payload_size = 16; - header.service_id = PS3_SM_SERVICE_ID_SET_ATTR; - - memset(&payload, 0, sizeof(payload)); - payload.version = 1; - payload.attribute = attr; - - return ps3_sys_manager_write(dev, &header, &payload); -} - -/** - * ps3_sys_manager_send_next_op - Send a 'set next op' to the system manager. - * - * Tell the system manager what to do after this lpar is destroyed. - */ - -static int ps3_sys_manager_send_next_op(struct ps3_system_bus_device *dev, - enum ps3_sys_manager_next_op op, - enum ps3_sys_manager_wake_source wake_source) -{ - struct ps3_sys_manager_header header; - struct { - u8 version; - u8 type; - u8 gos_id; - u8 reserved_1; - u32 wake_source; - u8 reserved_2[8]; - } payload; - - BUILD_BUG_ON(sizeof(payload) != 16); - - dev_dbg(&dev->core, "%s:%d: (%xh)\n", __func__, __LINE__, op); - - memset(&header, 0, sizeof(header)); - header.version = 1; - header.size = 16; - header.payload_size = 16; - header.service_id = PS3_SM_SERVICE_ID_SET_NEXT_OP; - - memset(&payload, 0, sizeof(payload)); - payload.version = 3; - payload.type = op; - payload.gos_id = 3; /* other os */ - payload.wake_source = wake_source; - - return ps3_sys_manager_write(dev, &header, &payload); -} - -/** - * ps3_sys_manager_send_request_shutdown - Send 'request' to the system manager. - * - * The guest sends this message to request an operation or action of the system - * manager. The reply is a command message from the system manager. In the - * command handler the guest performs the requested operation. The result of - * the command is then communicated back to the system manager with a response - * message. - * - * Currently, the only supported request is the 'shutdown self' request. - */ - -static int ps3_sys_manager_send_request_shutdown( - struct ps3_system_bus_device *dev) -{ - struct ps3_sys_manager_header header; - struct { - u8 version; - u8 type; - u8 gos_id; - u8 reserved_1[13]; - } payload; - - BUILD_BUG_ON(sizeof(payload) != 16); - - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - - memset(&header, 0, sizeof(header)); - header.version = 1; - header.size = 16; - header.payload_size = 16; - header.service_id = PS3_SM_SERVICE_ID_REQUEST; - - memset(&payload, 0, sizeof(payload)); - payload.version = 1; - payload.type = 1; /* shutdown */ - payload.gos_id = 0; /* self */ - - return ps3_sys_manager_write(dev, &header, &payload); -} - -/** - * ps3_sys_manager_send_response - Send a 'response' to the system manager. - * @status: zero = success, others fail. - * - * The guest sends this message to the system manager to acnowledge success or - * failure of a command sent by the system manager. - */ - -static int ps3_sys_manager_send_response(struct ps3_system_bus_device *dev, - u64 status) -{ - struct ps3_sys_manager_header header; - struct { - u8 version; - u8 reserved_1[3]; - u8 status; - u8 reserved_2[11]; - } payload; - - BUILD_BUG_ON(sizeof(payload) != 16); - - dev_dbg(&dev->core, "%s:%d: (%s)\n", __func__, __LINE__, - (status ? "nak" : "ack")); - - memset(&header, 0, sizeof(header)); - header.version = 1; - header.size = 16; - header.payload_size = 16; - header.service_id = PS3_SM_SERVICE_ID_RESPONSE; - - memset(&payload, 0, sizeof(payload)); - payload.version = 1; - payload.status = status; - - return ps3_sys_manager_write(dev, &header, &payload); -} - -/** - * ps3_sys_manager_handle_event - Second stage event msg handler. - * - */ - -static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev) -{ - int result; - struct { - u8 version; - u8 type; - u8 reserved_1[2]; - u32 value; - u8 reserved_2[8]; - } event; - - BUILD_BUG_ON(sizeof(event) != 16); - - result = ps3_vuart_read(dev, &event, sizeof(event)); - BUG_ON(result && "need to retry here"); - - if (event.version != 1) { - dev_dbg(&dev->core, "%s:%d: unsupported event version (%u)\n", - __func__, __LINE__, event.version); - return -EIO; - } - - switch (event.type) { - case PS3_SM_EVENT_POWER_PRESSED: - dev_dbg(&dev->core, "%s:%d: POWER_PRESSED\n", - __func__, __LINE__); - ps3_sm_force_power_off = 1; - /* - * A memory barrier is use here to sync memory since - * ps3_sys_manager_final_restart() could be called on - * another cpu. - */ - wmb(); - kill_cad_pid(SIGINT, 1); /* ctrl_alt_del */ - break; - case PS3_SM_EVENT_POWER_RELEASED: - dev_dbg(&dev->core, "%s:%d: POWER_RELEASED (%u ms)\n", - __func__, __LINE__, event.value); - break; - case PS3_SM_EVENT_RESET_PRESSED: - dev_dbg(&dev->core, "%s:%d: RESET_PRESSED\n", - __func__, __LINE__); - ps3_sm_force_power_off = 0; - /* - * A memory barrier is use here to sync memory since - * ps3_sys_manager_final_restart() could be called on - * another cpu. - */ - wmb(); - kill_cad_pid(SIGINT, 1); /* ctrl_alt_del */ - break; - case PS3_SM_EVENT_RESET_RELEASED: - dev_dbg(&dev->core, "%s:%d: RESET_RELEASED (%u ms)\n", - __func__, __LINE__, event.value); - break; - case PS3_SM_EVENT_THERMAL_ALERT: - dev_dbg(&dev->core, "%s:%d: THERMAL_ALERT (zone %u)\n", - __func__, __LINE__, event.value); - printk(KERN_INFO "PS3 Thermal Alert Zone %u\n", event.value); - break; - case PS3_SM_EVENT_THERMAL_CLEARED: - dev_dbg(&dev->core, "%s:%d: THERMAL_CLEARED (zone %u)\n", - __func__, __LINE__, event.value); - break; - default: - dev_dbg(&dev->core, "%s:%d: unknown event (%u)\n", - __func__, __LINE__, event.type); - return -EIO; - } - - return 0; -} -/** - * ps3_sys_manager_handle_cmd - Second stage command msg handler. - * - * The system manager sends this in reply to a 'request' message from the guest. - */ - -static int ps3_sys_manager_handle_cmd(struct ps3_system_bus_device *dev) -{ - int result; - struct { - u8 version; - u8 type; - u8 reserved_1[14]; - } cmd; - - BUILD_BUG_ON(sizeof(cmd) != 16); - - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - - result = ps3_vuart_read(dev, &cmd, sizeof(cmd)); - BUG_ON(result && "need to retry here"); - - if(result) - return result; - - if (cmd.version != 1) { - dev_dbg(&dev->core, "%s:%d: unsupported cmd version (%u)\n", - __func__, __LINE__, cmd.version); - return -EIO; - } - - if (cmd.type != PS3_SM_CMD_SHUTDOWN) { - dev_dbg(&dev->core, "%s:%d: unknown cmd (%u)\n", - __func__, __LINE__, cmd.type); - return -EIO; - } - - ps3_sys_manager_send_response(dev, 0); - return 0; -} - -/** - * ps3_sys_manager_handle_msg - First stage msg handler. - * - * Can be called directly to manually poll vuart and pump message handler. - */ - -static int ps3_sys_manager_handle_msg(struct ps3_system_bus_device *dev) -{ - int result; - struct ps3_sys_manager_header header; - - result = ps3_vuart_read(dev, &header, - sizeof(struct ps3_sys_manager_header)); - - if(result) - return result; - - if (header.version != 1) { - dev_dbg(&dev->core, "%s:%d: unsupported header version (%u)\n", - __func__, __LINE__, header.version); - dump_sm_header(&header); - goto fail_header; - } - - BUILD_BUG_ON(sizeof(header) != 16); - - if (header.size != 16 || (header.payload_size != 8 - && header.payload_size != 16)) { - dump_sm_header(&header); - BUG(); - } - - switch (header.service_id) { - case PS3_SM_SERVICE_ID_EXTERN_EVENT: - dev_dbg(&dev->core, "%s:%d: EVENT\n", __func__, __LINE__); - return ps3_sys_manager_handle_event(dev); - case PS3_SM_SERVICE_ID_COMMAND: - dev_dbg(&dev->core, "%s:%d: COMMAND\n", __func__, __LINE__); - return ps3_sys_manager_handle_cmd(dev); - case PS3_SM_SERVICE_ID_REQUEST_ERROR: - dev_dbg(&dev->core, "%s:%d: REQUEST_ERROR\n", __func__, - __LINE__); - dump_sm_header(&header); - break; - default: - dev_dbg(&dev->core, "%s:%d: unknown service_id (%u)\n", - __func__, __LINE__, header.service_id); - break; - } - goto fail_id; - -fail_header: - ps3_vuart_clear_rx_bytes(dev, 0); - return -EIO; -fail_id: - ps3_vuart_clear_rx_bytes(dev, header.payload_size); - return -EIO; -} - -/** - * ps3_sys_manager_final_power_off - The final platform machine_power_off routine. - * - * This routine never returns. The routine disables asynchronous vuart reads - * then spins calling ps3_sys_manager_handle_msg() to receive and acknowledge - * the shutdown command sent from the system manager. Soon after the - * acknowledgement is sent the lpar is destroyed by the HV. This routine - * should only be called from ps3_power_off() through - * ps3_sys_manager_ops.power_off. - */ - -static void ps3_sys_manager_final_power_off(struct ps3_system_bus_device *dev) -{ - BUG_ON(!dev); - - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - - ps3_vuart_cancel_async(dev); - - ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_SHUTDOWN, - PS3_SM_WAKE_DEFAULT); - ps3_sys_manager_send_request_shutdown(dev); - - printk(KERN_EMERG "System Halted, OK to turn off power\n"); - - while(1) - ps3_sys_manager_handle_msg(dev); -} - -/** - * ps3_sys_manager_final_restart - The final platform machine_restart routine. - * - * This routine never returns. The routine disables asynchronous vuart reads - * then spins calling ps3_sys_manager_handle_msg() to receive and acknowledge - * the shutdown command sent from the system manager. Soon after the - * acknowledgement is sent the lpar is destroyed by the HV. This routine - * should only be called from ps3_restart() through ps3_sys_manager_ops.restart. - */ - -static void ps3_sys_manager_final_restart(struct ps3_system_bus_device *dev) -{ - BUG_ON(!dev); - - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - - /* Check if we got here via a power button event. */ - - if (ps3_sm_force_power_off) { - dev_dbg(&dev->core, "%s:%d: forcing poweroff\n", - __func__, __LINE__); - ps3_sys_manager_final_power_off(dev); - } - - ps3_vuart_cancel_async(dev); - - ps3_sys_manager_send_attr(dev, 0); - ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_LPAR_REBOOT, - PS3_SM_WAKE_DEFAULT); - ps3_sys_manager_send_request_shutdown(dev); - - printk(KERN_EMERG "System Halted, OK to turn off power\n"); - - while(1) - ps3_sys_manager_handle_msg(dev); -} - -/** - * ps3_sys_manager_work - Asynchronous read handler. - * - * Signaled when PS3_SM_RX_MSG_LEN_MIN bytes arrive at the vuart port. - */ - -static void ps3_sys_manager_work(struct ps3_system_bus_device *dev) -{ - ps3_sys_manager_handle_msg(dev); - ps3_vuart_read_async(dev, PS3_SM_RX_MSG_LEN_MIN); -} - -static int ps3_sys_manager_probe(struct ps3_system_bus_device *dev) -{ - int result; - struct ps3_sys_manager_ops ops; - - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - - ops.power_off = ps3_sys_manager_final_power_off; - ops.restart = ps3_sys_manager_final_restart; - ops.dev = dev; - - /* ps3_sys_manager_register_ops copies ops. */ - - ps3_sys_manager_register_ops(&ops); - - result = ps3_sys_manager_send_attr(dev, PS3_SM_ATTR_ALL); - BUG_ON(result); - - result = ps3_vuart_read_async(dev, PS3_SM_RX_MSG_LEN_MIN); - BUG_ON(result); - - return result; -} - -static int ps3_sys_manager_remove(struct ps3_system_bus_device *dev) -{ - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - return 0; -} - -static void ps3_sys_manager_shutdown(struct ps3_system_bus_device *dev) -{ - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); -} - -static struct ps3_vuart_port_driver ps3_sys_manager = { - .core.match_id = PS3_MATCH_ID_SYSTEM_MANAGER, - .core.core.name = "ps3_sys_manager", - .probe = ps3_sys_manager_probe, - .remove = ps3_sys_manager_remove, - .shutdown = ps3_sys_manager_shutdown, - .work = ps3_sys_manager_work, -}; - -static int __init ps3_sys_manager_init(void) -{ - if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) - return -ENODEV; - - return ps3_vuart_port_driver_register(&ps3_sys_manager); -} - -module_init(ps3_sys_manager_init); -/* Module remove not supported. */ - -MODULE_ALIAS(PS3_MODULE_ALIAS_SYSTEM_MANAGER); diff --git a/drivers/ps3/vuart.c b/drivers/ps3/vuart.c deleted file mode 100644 index 9dea585ef80..00000000000 --- a/drivers/ps3/vuart.c +++ /dev/null @@ -1,1271 +0,0 @@ -/* - * PS3 virtual uart - * - * Copyright (C) 2006 Sony Computer Entertainment Inc. - * Copyright 2006 Sony Corp. - * - * 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; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "vuart.h" - -MODULE_AUTHOR("Sony Corporation"); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PS3 vuart"); - -/** - * vuart - An inter-partition data link service. - * port 0: PS3 AV Settings. - * port 2: PS3 System Manager. - * - * The vuart provides a bi-directional byte stream data link between logical - * partitions. Its primary role is as a communications link between the guest - * OS and the system policy module. The current HV does not support any - * connections other than those listed. - */ - -enum {PORT_COUNT = 3,}; - -enum vuart_param { - PARAM_TX_TRIGGER = 0, - PARAM_RX_TRIGGER = 1, - PARAM_INTERRUPT_MASK = 2, - PARAM_RX_BUF_SIZE = 3, /* read only */ - PARAM_RX_BYTES = 4, /* read only */ - PARAM_TX_BUF_SIZE = 5, /* read only */ - PARAM_TX_BYTES = 6, /* read only */ - PARAM_INTERRUPT_STATUS = 7, /* read only */ -}; - -enum vuart_interrupt_bit { - INTERRUPT_BIT_TX = 0, - INTERRUPT_BIT_RX = 1, - INTERRUPT_BIT_DISCONNECT = 2, -}; - -enum vuart_interrupt_mask { - INTERRUPT_MASK_TX = 1, - INTERRUPT_MASK_RX = 2, - INTERRUPT_MASK_DISCONNECT = 4, -}; - -/** - * struct ps3_vuart_port_priv - private vuart device data. - */ - -struct ps3_vuart_port_priv { - u64 interrupt_mask; - - struct { - spinlock_t lock; - struct list_head head; - } tx_list; - struct { - struct ps3_vuart_work work; - unsigned long bytes_held; - spinlock_t lock; - struct list_head head; - } rx_list; - struct ps3_vuart_stats stats; -}; - -static struct ps3_vuart_port_priv *to_port_priv( - struct ps3_system_bus_device *dev) -{ - BUG_ON(!dev); - BUG_ON(!dev->driver_priv); - return (struct ps3_vuart_port_priv *)dev->driver_priv; -} - -/** - * struct ports_bmp - bitmap indicating ports needing service. - * - * A 256 bit read only bitmap indicating ports needing service. Do not write - * to these bits. Must not cross a page boundary. - */ - -struct ports_bmp { - u64 status; - u64 unused[3]; -} __attribute__ ((aligned (32))); - -#define dump_ports_bmp(_b) _dump_ports_bmp(_b, __func__, __LINE__) -static void __maybe_unused _dump_ports_bmp( - const struct ports_bmp* bmp, const char* func, int line) -{ - pr_debug("%s:%d: ports_bmp: %016lxh\n", func, line, bmp->status); -} - -#define dump_port_params(_b) _dump_port_params(_b, __func__, __LINE__) -static void __maybe_unused _dump_port_params(unsigned int port_number, - const char* func, int line) -{ -#if defined(DEBUG) - static const char *strings[] = { - "tx_trigger ", - "rx_trigger ", - "interrupt_mask ", - "rx_buf_size ", - "rx_bytes ", - "tx_buf_size ", - "tx_bytes ", - "interrupt_status", - }; - int result; - unsigned int i; - u64 value; - - for (i = 0; i < ARRAY_SIZE(strings); i++) { - result = lv1_get_virtual_uart_param(port_number, i, &value); - - if (result) { - pr_debug("%s:%d: port_%u: %s failed: %s\n", func, line, - port_number, strings[i], ps3_result(result)); - continue; - } - pr_debug("%s:%d: port_%u: %s = %lxh\n", - func, line, port_number, strings[i], value); - } -#endif -} - -struct vuart_triggers { - unsigned long rx; - unsigned long tx; -}; - -int ps3_vuart_get_triggers(struct ps3_system_bus_device *dev, - struct vuart_triggers *trig) -{ - int result; - unsigned long size; - unsigned long val; - - result = lv1_get_virtual_uart_param(dev->port_number, - PARAM_TX_TRIGGER, &trig->tx); - - if (result) { - dev_dbg(&dev->core, "%s:%d: tx_trigger failed: %s\n", - __func__, __LINE__, ps3_result(result)); - return result; - } - - result = lv1_get_virtual_uart_param(dev->port_number, - PARAM_RX_BUF_SIZE, &size); - - if (result) { - dev_dbg(&dev->core, "%s:%d: tx_buf_size failed: %s\n", - __func__, __LINE__, ps3_result(result)); - return result; - } - - result = lv1_get_virtual_uart_param(dev->port_number, - PARAM_RX_TRIGGER, &val); - - if (result) { - dev_dbg(&dev->core, "%s:%d: rx_trigger failed: %s\n", - __func__, __LINE__, ps3_result(result)); - return result; - } - - trig->rx = size - val; - - dev_dbg(&dev->core, "%s:%d: tx %lxh, rx %lxh\n", __func__, __LINE__, - trig->tx, trig->rx); - - return result; -} - -int ps3_vuart_set_triggers(struct ps3_system_bus_device *dev, unsigned int tx, - unsigned int rx) -{ - int result; - unsigned long size; - - result = lv1_set_virtual_uart_param(dev->port_number, - PARAM_TX_TRIGGER, tx); - - if (result) { - dev_dbg(&dev->core, "%s:%d: tx_trigger failed: %s\n", - __func__, __LINE__, ps3_result(result)); - return result; - } - - result = lv1_get_virtual_uart_param(dev->port_number, - PARAM_RX_BUF_SIZE, &size); - - if (result) { - dev_dbg(&dev->core, "%s:%d: tx_buf_size failed: %s\n", - __func__, __LINE__, ps3_result(result)); - return result; - } - - result = lv1_set_virtual_uart_param(dev->port_number, - PARAM_RX_TRIGGER, size - rx); - - if (result) { - dev_dbg(&dev->core, "%s:%d: rx_trigger failed: %s\n", - __func__, __LINE__, ps3_result(result)); - return result; - } - - dev_dbg(&dev->core, "%s:%d: tx %xh, rx %xh\n", __func__, __LINE__, - tx, rx); - - return result; -} - -static int ps3_vuart_get_rx_bytes_waiting(struct ps3_system_bus_device *dev, - u64 *bytes_waiting) -{ - int result; - - result = lv1_get_virtual_uart_param(dev->port_number, - PARAM_RX_BYTES, bytes_waiting); - - if (result) - dev_dbg(&dev->core, "%s:%d: rx_bytes failed: %s\n", - __func__, __LINE__, ps3_result(result)); - - dev_dbg(&dev->core, "%s:%d: %lxh\n", __func__, __LINE__, - *bytes_waiting); - return result; -} - -/** - * ps3_vuart_set_interrupt_mask - Enable/disable the port interrupt sources. - * @dev: The struct ps3_system_bus_device instance. - * @bmp: Logical OR of enum vuart_interrupt_mask values. A zero bit disables. - */ - -static int ps3_vuart_set_interrupt_mask(struct ps3_system_bus_device *dev, - unsigned long mask) -{ - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - - dev_dbg(&dev->core, "%s:%d: %lxh\n", __func__, __LINE__, mask); - - priv->interrupt_mask = mask; - - result = lv1_set_virtual_uart_param(dev->port_number, - PARAM_INTERRUPT_MASK, priv->interrupt_mask); - - if (result) - dev_dbg(&dev->core, "%s:%d: interrupt_mask failed: %s\n", - __func__, __LINE__, ps3_result(result)); - - return result; -} - -static int ps3_vuart_get_interrupt_status(struct ps3_system_bus_device *dev, - unsigned long *status) -{ - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - u64 tmp; - - result = lv1_get_virtual_uart_param(dev->port_number, - PARAM_INTERRUPT_STATUS, &tmp); - - if (result) - dev_dbg(&dev->core, "%s:%d: interrupt_status failed: %s\n", - __func__, __LINE__, ps3_result(result)); - - *status = tmp & priv->interrupt_mask; - - dev_dbg(&dev->core, "%s:%d: m %lxh, s %lxh, m&s %lxh\n", - __func__, __LINE__, priv->interrupt_mask, tmp, *status); - - return result; -} - -int ps3_vuart_enable_interrupt_tx(struct ps3_system_bus_device *dev) -{ - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - - return (priv->interrupt_mask & INTERRUPT_MASK_TX) ? 0 - : ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask - | INTERRUPT_MASK_TX); -} - -int ps3_vuart_enable_interrupt_rx(struct ps3_system_bus_device *dev) -{ - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - - return (priv->interrupt_mask & INTERRUPT_MASK_RX) ? 0 - : ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask - | INTERRUPT_MASK_RX); -} - -int ps3_vuart_enable_interrupt_disconnect(struct ps3_system_bus_device *dev) -{ - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - - return (priv->interrupt_mask & INTERRUPT_MASK_DISCONNECT) ? 0 - : ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask - | INTERRUPT_MASK_DISCONNECT); -} - -int ps3_vuart_disable_interrupt_tx(struct ps3_system_bus_device *dev) -{ - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - - return (priv->interrupt_mask & INTERRUPT_MASK_TX) - ? ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask - & ~INTERRUPT_MASK_TX) : 0; -} - -int ps3_vuart_disable_interrupt_rx(struct ps3_system_bus_device *dev) -{ - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - - return (priv->interrupt_mask & INTERRUPT_MASK_RX) - ? ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask - & ~INTERRUPT_MASK_RX) : 0; -} - -int ps3_vuart_disable_interrupt_disconnect(struct ps3_system_bus_device *dev) -{ - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - - return (priv->interrupt_mask & INTERRUPT_MASK_DISCONNECT) - ? ps3_vuart_set_interrupt_mask(dev, priv->interrupt_mask - & ~INTERRUPT_MASK_DISCONNECT) : 0; -} - -/** - * ps3_vuart_raw_write - Low level write helper. - * @dev: The struct ps3_system_bus_device instance. - * - * Do not call ps3_vuart_raw_write directly, use ps3_vuart_write. - */ - -static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev, - const void* buf, unsigned int bytes, unsigned long *bytes_written) -{ - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - - result = lv1_write_virtual_uart(dev->port_number, - ps3_mm_phys_to_lpar(__pa(buf)), bytes, bytes_written); - - if (result) { - dev_dbg(&dev->core, "%s:%d: lv1_write_virtual_uart failed: " - "%s\n", __func__, __LINE__, ps3_result(result)); - return result; - } - - priv->stats.bytes_written += *bytes_written; - - dev_dbg(&dev->core, "%s:%d: wrote %lxh/%xh=>%lxh\n", __func__, __LINE__, - *bytes_written, bytes, priv->stats.bytes_written); - - return result; -} - -/** - * ps3_vuart_raw_read - Low level read helper. - * @dev: The struct ps3_system_bus_device instance. - * - * Do not call ps3_vuart_raw_read directly, use ps3_vuart_read. - */ - -static int ps3_vuart_raw_read(struct ps3_system_bus_device *dev, void *buf, - unsigned int bytes, unsigned long *bytes_read) -{ - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - - dev_dbg(&dev->core, "%s:%d: %xh\n", __func__, __LINE__, bytes); - - result = lv1_read_virtual_uart(dev->port_number, - ps3_mm_phys_to_lpar(__pa(buf)), bytes, bytes_read); - - if (result) { - dev_dbg(&dev->core, "%s:%d: lv1_read_virtual_uart failed: %s\n", - __func__, __LINE__, ps3_result(result)); - return result; - } - - priv->stats.bytes_read += *bytes_read; - - dev_dbg(&dev->core, "%s:%d: read %lxh/%xh=>%lxh\n", __func__, __LINE__, - *bytes_read, bytes, priv->stats.bytes_read); - - return result; -} - -/** - * ps3_vuart_clear_rx_bytes - Discard bytes received. - * @dev: The struct ps3_system_bus_device instance. - * @bytes: Max byte count to discard, zero = all pending. - * - * Used to clear pending rx interrupt source. Will not block. - */ - -void ps3_vuart_clear_rx_bytes(struct ps3_system_bus_device *dev, - unsigned int bytes) -{ - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - u64 bytes_waiting; - void* tmp; - - result = ps3_vuart_get_rx_bytes_waiting(dev, &bytes_waiting); - - BUG_ON(result); - - bytes = bytes ? min(bytes, (unsigned int)bytes_waiting) : bytes_waiting; - - dev_dbg(&dev->core, "%s:%d: %u\n", __func__, __LINE__, bytes); - - if (!bytes) - return; - - /* Add some extra space for recently arrived data. */ - - bytes += 128; - - tmp = kmalloc(bytes, GFP_KERNEL); - - if (!tmp) - return; - - ps3_vuart_raw_read(dev, tmp, bytes, &bytes_waiting); - - kfree(tmp); - - /* Don't include these bytes in the stats. */ - - priv->stats.bytes_read -= bytes_waiting; -} -EXPORT_SYMBOL_GPL(ps3_vuart_clear_rx_bytes); - -/** - * struct list_buffer - An element for a port device fifo buffer list. - */ - -struct list_buffer { - struct list_head link; - const unsigned char *head; - const unsigned char *tail; - unsigned long dbg_number; - unsigned char data[]; -}; - -/** - * ps3_vuart_write - the entry point for writing data to a port - * @dev: The struct ps3_system_bus_device instance. - * - * If the port is idle on entry as much of the incoming data is written to - * the port as the port will accept. Otherwise a list buffer is created - * and any remaning incoming data is copied to that buffer. The buffer is - * then enqueued for transmision via the transmit interrupt. - */ - -int ps3_vuart_write(struct ps3_system_bus_device *dev, const void *buf, - unsigned int bytes) -{ - static unsigned long dbg_number; - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - unsigned long flags; - struct list_buffer *lb; - - dev_dbg(&dev->core, "%s:%d: %u(%xh) bytes\n", __func__, __LINE__, - bytes, bytes); - - spin_lock_irqsave(&priv->tx_list.lock, flags); - - if (list_empty(&priv->tx_list.head)) { - unsigned long bytes_written; - - result = ps3_vuart_raw_write(dev, buf, bytes, &bytes_written); - - spin_unlock_irqrestore(&priv->tx_list.lock, flags); - - if (result) { - dev_dbg(&dev->core, - "%s:%d: ps3_vuart_raw_write failed\n", - __func__, __LINE__); - return result; - } - - if (bytes_written == bytes) { - dev_dbg(&dev->core, "%s:%d: wrote %xh bytes\n", - __func__, __LINE__, bytes); - return 0; - } - - bytes -= bytes_written; - buf += bytes_written; - } else - spin_unlock_irqrestore(&priv->tx_list.lock, flags); - - lb = kmalloc(sizeof(struct list_buffer) + bytes, GFP_KERNEL); - - if (!lb) { - return -ENOMEM; - } - - memcpy(lb->data, buf, bytes); - lb->head = lb->data; - lb->tail = lb->data + bytes; - lb->dbg_number = ++dbg_number; - - spin_lock_irqsave(&priv->tx_list.lock, flags); - list_add_tail(&lb->link, &priv->tx_list.head); - ps3_vuart_enable_interrupt_tx(dev); - spin_unlock_irqrestore(&priv->tx_list.lock, flags); - - dev_dbg(&dev->core, "%s:%d: queued buf_%lu, %xh bytes\n", - __func__, __LINE__, lb->dbg_number, bytes); - - return 0; -} -EXPORT_SYMBOL_GPL(ps3_vuart_write); - -/** - * ps3_vuart_queue_rx_bytes - Queue waiting bytes into the buffer list. - * @dev: The struct ps3_system_bus_device instance. - * @bytes_queued: Number of bytes queued to the buffer list. - * - * Must be called with priv->rx_list.lock held. - */ - -static int ps3_vuart_queue_rx_bytes(struct ps3_system_bus_device *dev, - u64 *bytes_queued) -{ - static unsigned long dbg_number; - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - struct list_buffer *lb; - u64 bytes; - - *bytes_queued = 0; - - result = ps3_vuart_get_rx_bytes_waiting(dev, &bytes); - BUG_ON(result); - - if (result) - return -EIO; - - if (!bytes) - return 0; - - /* Add some extra space for recently arrived data. */ - - bytes += 128; - - lb = kmalloc(sizeof(struct list_buffer) + bytes, GFP_ATOMIC); - - if (!lb) - return -ENOMEM; - - ps3_vuart_raw_read(dev, lb->data, bytes, &bytes); - - lb->head = lb->data; - lb->tail = lb->data + bytes; - lb->dbg_number = ++dbg_number; - - list_add_tail(&lb->link, &priv->rx_list.head); - priv->rx_list.bytes_held += bytes; - - dev_dbg(&dev->core, "%s:%d: buf_%lu: queued %lxh bytes\n", - __func__, __LINE__, lb->dbg_number, bytes); - - *bytes_queued = bytes; - - return 0; -} - -/** - * ps3_vuart_read - The entry point for reading data from a port. - * - * Queue data waiting at the port, and if enough bytes to satisfy the request - * are held in the buffer list those bytes are dequeued and copied to the - * caller's buffer. Emptied list buffers are retiered. If the request cannot - * be statified by bytes held in the list buffers -EAGAIN is returned. - */ - -int ps3_vuart_read(struct ps3_system_bus_device *dev, void *buf, - unsigned int bytes) -{ - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - unsigned long flags; - struct list_buffer *lb, *n; - unsigned long bytes_read; - - dev_dbg(&dev->core, "%s:%d: %u(%xh) bytes\n", __func__, __LINE__, - bytes, bytes); - - spin_lock_irqsave(&priv->rx_list.lock, flags); - - /* Queue rx bytes here for polled reads. */ - - while (priv->rx_list.bytes_held < bytes) { - u64 tmp; - - result = ps3_vuart_queue_rx_bytes(dev, &tmp); - if (result || !tmp) { - dev_dbg(&dev->core, "%s:%d: starved for %lxh bytes\n", - __func__, __LINE__, - bytes - priv->rx_list.bytes_held); - spin_unlock_irqrestore(&priv->rx_list.lock, flags); - return -EAGAIN; - } - } - - list_for_each_entry_safe(lb, n, &priv->rx_list.head, link) { - bytes_read = min((unsigned int)(lb->tail - lb->head), bytes); - - memcpy(buf, lb->head, bytes_read); - buf += bytes_read; - bytes -= bytes_read; - priv->rx_list.bytes_held -= bytes_read; - - if (bytes_read < lb->tail - lb->head) { - lb->head += bytes_read; - dev_dbg(&dev->core, "%s:%d: buf_%lu: dequeued %lxh " - "bytes\n", __func__, __LINE__, lb->dbg_number, - bytes_read); - spin_unlock_irqrestore(&priv->rx_list.lock, flags); - return 0; - } - - dev_dbg(&dev->core, "%s:%d: buf_%lu: free, dequeued %lxh " - "bytes\n", __func__, __LINE__, lb->dbg_number, - bytes_read); - - list_del(&lb->link); - kfree(lb); - } - - spin_unlock_irqrestore(&priv->rx_list.lock, flags); - return 0; -} -EXPORT_SYMBOL_GPL(ps3_vuart_read); - -/** - * ps3_vuart_work - Asynchronous read handler. - */ - -static void ps3_vuart_work(struct work_struct *work) -{ - struct ps3_system_bus_device *dev = - ps3_vuart_work_to_system_bus_dev(work); - struct ps3_vuart_port_driver *drv = - ps3_system_bus_dev_to_vuart_drv(dev); - - BUG_ON(!drv); - drv->work(dev); -} - -int ps3_vuart_read_async(struct ps3_system_bus_device *dev, unsigned int bytes) -{ - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - unsigned long flags; - - if (priv->rx_list.work.trigger) { - dev_dbg(&dev->core, "%s:%d: warning, multiple calls\n", - __func__, __LINE__); - return -EAGAIN; - } - - BUG_ON(!bytes); - - PREPARE_WORK(&priv->rx_list.work.work, ps3_vuart_work); - - spin_lock_irqsave(&priv->rx_list.lock, flags); - if (priv->rx_list.bytes_held >= bytes) { - dev_dbg(&dev->core, "%s:%d: schedule_work %xh bytes\n", - __func__, __LINE__, bytes); - schedule_work(&priv->rx_list.work.work); - spin_unlock_irqrestore(&priv->rx_list.lock, flags); - return 0; - } - - priv->rx_list.work.trigger = bytes; - spin_unlock_irqrestore(&priv->rx_list.lock, flags); - - dev_dbg(&dev->core, "%s:%d: waiting for %u(%xh) bytes\n", __func__, - __LINE__, bytes, bytes); - - return 0; -} -EXPORT_SYMBOL_GPL(ps3_vuart_read_async); - -void ps3_vuart_cancel_async(struct ps3_system_bus_device *dev) -{ - to_port_priv(dev)->rx_list.work.trigger = 0; -} -EXPORT_SYMBOL_GPL(ps3_vuart_cancel_async); - -/** - * ps3_vuart_handle_interrupt_tx - third stage transmit interrupt handler - * - * Services the transmit interrupt for the port. Writes as much data from the - * buffer list as the port will accept. Retires any emptied list buffers and - * adjusts the final list buffer state for a partial write. - */ - -static int ps3_vuart_handle_interrupt_tx(struct ps3_system_bus_device *dev) -{ - int result = 0; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - unsigned long flags; - struct list_buffer *lb, *n; - unsigned long bytes_total = 0; - - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - - spin_lock_irqsave(&priv->tx_list.lock, flags); - - list_for_each_entry_safe(lb, n, &priv->tx_list.head, link) { - - unsigned long bytes_written; - - result = ps3_vuart_raw_write(dev, lb->head, lb->tail - lb->head, - &bytes_written); - - if (result) { - dev_dbg(&dev->core, - "%s:%d: ps3_vuart_raw_write failed\n", - __func__, __LINE__); - break; - } - - bytes_total += bytes_written; - - if (bytes_written < lb->tail - lb->head) { - lb->head += bytes_written; - dev_dbg(&dev->core, - "%s:%d cleared buf_%lu, %lxh bytes\n", - __func__, __LINE__, lb->dbg_number, - bytes_written); - goto port_full; - } - - dev_dbg(&dev->core, "%s:%d free buf_%lu\n", __func__, __LINE__, - lb->dbg_number); - - list_del(&lb->link); - kfree(lb); - } - - ps3_vuart_disable_interrupt_tx(dev); -port_full: - spin_unlock_irqrestore(&priv->tx_list.lock, flags); - dev_dbg(&dev->core, "%s:%d wrote %lxh bytes total\n", - __func__, __LINE__, bytes_total); - return result; -} - -/** - * ps3_vuart_handle_interrupt_rx - third stage receive interrupt handler - * - * Services the receive interrupt for the port. Creates a list buffer and - * copies all waiting port data to that buffer and enqueues the buffer in the - * buffer list. Buffer list data is dequeued via ps3_vuart_read. - */ - -static int ps3_vuart_handle_interrupt_rx(struct ps3_system_bus_device *dev) -{ - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - unsigned long flags; - u64 bytes; - - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - - spin_lock_irqsave(&priv->rx_list.lock, flags); - result = ps3_vuart_queue_rx_bytes(dev, &bytes); - - if (result) { - spin_unlock_irqrestore(&priv->rx_list.lock, flags); - return result; - } - - if (priv->rx_list.work.trigger && priv->rx_list.bytes_held - >= priv->rx_list.work.trigger) { - dev_dbg(&dev->core, "%s:%d: schedule_work %lxh bytes\n", - __func__, __LINE__, priv->rx_list.work.trigger); - priv->rx_list.work.trigger = 0; - schedule_work(&priv->rx_list.work.work); - } - - spin_unlock_irqrestore(&priv->rx_list.lock, flags); - return result; -} - -static int ps3_vuart_handle_interrupt_disconnect( - struct ps3_system_bus_device *dev) -{ - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - BUG_ON("no support"); - return -1; -} - -/** - * ps3_vuart_handle_port_interrupt - second stage interrupt handler - * - * Services any pending interrupt types for the port. Passes control to the - * third stage type specific interrupt handler. Returns control to the first - * stage handler after one iteration. - */ - -static int ps3_vuart_handle_port_interrupt(struct ps3_system_bus_device *dev) -{ - int result; - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - unsigned long status; - - result = ps3_vuart_get_interrupt_status(dev, &status); - - if (result) - return result; - - dev_dbg(&dev->core, "%s:%d: status: %lxh\n", __func__, __LINE__, - status); - - if (status & INTERRUPT_MASK_DISCONNECT) { - priv->stats.disconnect_interrupts++; - result = ps3_vuart_handle_interrupt_disconnect(dev); - if (result) - ps3_vuart_disable_interrupt_disconnect(dev); - } - - if (status & INTERRUPT_MASK_TX) { - priv->stats.tx_interrupts++; - result = ps3_vuart_handle_interrupt_tx(dev); - if (result) - ps3_vuart_disable_interrupt_tx(dev); - } - - if (status & INTERRUPT_MASK_RX) { - priv->stats.rx_interrupts++; - result = ps3_vuart_handle_interrupt_rx(dev); - if (result) - ps3_vuart_disable_interrupt_rx(dev); - } - - return 0; -} - -struct vuart_bus_priv { - struct ports_bmp *bmp; - unsigned int virq; - struct semaphore probe_mutex; - int use_count; - struct ps3_system_bus_device *devices[PORT_COUNT]; -} static vuart_bus_priv; - -/** - * ps3_vuart_irq_handler - first stage interrupt handler - * - * Loops finding any interrupting port and its associated instance data. - * Passes control to the second stage port specific interrupt handler. Loops - * until all outstanding interrupts are serviced. - */ - -static irqreturn_t ps3_vuart_irq_handler(int irq, void *_private) -{ - struct vuart_bus_priv *bus_priv = _private; - - BUG_ON(!bus_priv); - - while (1) { - unsigned int port; - - dump_ports_bmp(bus_priv->bmp); - - port = (BITS_PER_LONG - 1) - __ilog2(bus_priv->bmp->status); - - if (port == BITS_PER_LONG) - break; - - BUG_ON(port >= PORT_COUNT); - BUG_ON(!bus_priv->devices[port]); - - ps3_vuart_handle_port_interrupt(bus_priv->devices[port]); - } - - return IRQ_HANDLED; -} - -static int ps3_vuart_bus_interrupt_get(void) -{ - int result; - - pr_debug(" -> %s:%d\n", __func__, __LINE__); - - vuart_bus_priv.use_count++; - - BUG_ON(vuart_bus_priv.use_count > 2); - - if (vuart_bus_priv.use_count != 1) { - return 0; - } - - BUG_ON(vuart_bus_priv.bmp); - - vuart_bus_priv.bmp = kzalloc(sizeof(struct ports_bmp), GFP_KERNEL); - - if (!vuart_bus_priv.bmp) { - pr_debug("%s:%d: kzalloc failed.\n", __func__, __LINE__); - result = -ENOMEM; - goto fail_bmp_malloc; - } - - result = ps3_vuart_irq_setup(PS3_BINDING_CPU_ANY, vuart_bus_priv.bmp, - &vuart_bus_priv.virq); - - if (result) { - pr_debug("%s:%d: ps3_vuart_irq_setup failed (%d)\n", - __func__, __LINE__, result); - result = -EPERM; - goto fail_alloc_irq; - } - - result = request_irq(vuart_bus_priv.virq, ps3_vuart_irq_handler, - IRQF_DISABLED, "vuart", &vuart_bus_priv); - - if (result) { - pr_debug("%s:%d: request_irq failed (%d)\n", - __func__, __LINE__, result); - goto fail_request_irq; - } - - pr_debug(" <- %s:%d: ok\n", __func__, __LINE__); - return result; - -fail_request_irq: - ps3_vuart_irq_destroy(vuart_bus_priv.virq); - vuart_bus_priv.virq = NO_IRQ; -fail_alloc_irq: - kfree(vuart_bus_priv.bmp); - vuart_bus_priv.bmp = NULL; -fail_bmp_malloc: - vuart_bus_priv.use_count--; - pr_debug(" <- %s:%d: failed\n", __func__, __LINE__); - return result; -} - -static int ps3_vuart_bus_interrupt_put(void) -{ - pr_debug(" -> %s:%d\n", __func__, __LINE__); - - vuart_bus_priv.use_count--; - - BUG_ON(vuart_bus_priv.use_count < 0); - - if (vuart_bus_priv.use_count != 0) - return 0; - - free_irq(vuart_bus_priv.virq, &vuart_bus_priv); - - ps3_vuart_irq_destroy(vuart_bus_priv.virq); - vuart_bus_priv.virq = NO_IRQ; - - kfree(vuart_bus_priv.bmp); - vuart_bus_priv.bmp = NULL; - - pr_debug(" <- %s:%d\n", __func__, __LINE__); - return 0; -} - -static int ps3_vuart_probe(struct ps3_system_bus_device *dev) -{ - int result; - struct ps3_vuart_port_driver *drv; - struct ps3_vuart_port_priv *priv = NULL; - - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - - drv = ps3_system_bus_dev_to_vuart_drv(dev); - - dev_dbg(&dev->core, "%s:%d: (%s)\n", __func__, __LINE__, - drv->core.core.name); - - BUG_ON(!drv); - - if (dev->port_number >= PORT_COUNT) { - BUG(); - return -EINVAL; - } - - down(&vuart_bus_priv.probe_mutex); - - result = ps3_vuart_bus_interrupt_get(); - - if (result) - goto fail_setup_interrupt; - - if (vuart_bus_priv.devices[dev->port_number]) { - dev_dbg(&dev->core, "%s:%d: port busy (%d)\n", __func__, - __LINE__, dev->port_number); - result = -EBUSY; - goto fail_busy; - } - - vuart_bus_priv.devices[dev->port_number] = dev; - - /* Setup dev->driver_priv. */ - - dev->driver_priv = kzalloc(sizeof(struct ps3_vuart_port_priv), - GFP_KERNEL); - - if (!dev->driver_priv) { - result = -ENOMEM; - goto fail_dev_malloc; - } - - priv = to_port_priv(dev); - - INIT_LIST_HEAD(&priv->tx_list.head); - spin_lock_init(&priv->tx_list.lock); - - INIT_LIST_HEAD(&priv->rx_list.head); - spin_lock_init(&priv->rx_list.lock); - - INIT_WORK(&priv->rx_list.work.work, NULL); - priv->rx_list.work.trigger = 0; - priv->rx_list.work.dev = dev; - - /* clear stale pending interrupts */ - - ps3_vuart_clear_rx_bytes(dev, 0); - - ps3_vuart_set_interrupt_mask(dev, INTERRUPT_MASK_RX); - - ps3_vuart_set_triggers(dev, 1, 1); - - if (drv->probe) - result = drv->probe(dev); - else { - result = 0; - dev_info(&dev->core, "%s:%d: no probe method\n", __func__, - __LINE__); - } - - if (result) { - dev_dbg(&dev->core, "%s:%d: drv->probe failed\n", - __func__, __LINE__); - down(&vuart_bus_priv.probe_mutex); - goto fail_probe; - } - - up(&vuart_bus_priv.probe_mutex); - - return result; - -fail_probe: - ps3_vuart_set_interrupt_mask(dev, 0); - kfree(dev->driver_priv); - dev->driver_priv = NULL; -fail_dev_malloc: - vuart_bus_priv.devices[dev->port_number] = NULL; -fail_busy: - ps3_vuart_bus_interrupt_put(); -fail_setup_interrupt: - up(&vuart_bus_priv.probe_mutex); - dev_dbg(&dev->core, "%s:%d: failed\n", __func__, __LINE__); - return result; -} - -/** - * ps3_vuart_cleanup - common cleanup helper. - * @dev: The struct ps3_system_bus_device instance. - * - * Cleans interrupts and HV resources. Must be called with - * vuart_bus_priv.probe_mutex held. Used by ps3_vuart_remove and - * ps3_vuart_shutdown. After this call, polled reading will still work. - */ - -static int ps3_vuart_cleanup(struct ps3_system_bus_device *dev) -{ - dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); - - ps3_vuart_cancel_async(dev); - ps3_vuart_set_interrupt_mask(dev, 0); - ps3_vuart_bus_interrupt_put(); - return 0; -} - -/** - * ps3_vuart_remove - Completely clean the device instance. - * @dev: The struct ps3_system_bus_device instance. - * - * Cleans all memory, interrupts and HV resources. After this call the - * device can no longer be used. - */ - -static int ps3_vuart_remove(struct ps3_system_bus_device *dev) -{ - struct ps3_vuart_port_priv *priv = to_port_priv(dev); - struct ps3_vuart_port_driver *drv; - - BUG_ON(!dev); - - down(&vuart_bus_priv.probe_mutex); - - dev_dbg(&dev->core, " -> %s:%d: match_id %d\n", __func__, __LINE__, - dev->match_id); - - if (!dev->core.driver) { - dev_dbg(&dev->core, "%s:%d: no driver bound\n", __func__, - __LINE__); - up(&vuart_bus_priv.probe_mutex); - return 0; - } - - drv = ps3_system_bus_dev_to_vuart_drv(dev); - - BUG_ON(!drv); - - if (drv->remove) { - drv->remove(dev); - } else { - dev_dbg(&dev->core, "%s:%d: no remove method\n", __func__, - __LINE__); - BUG(); - } - - ps3_vuart_cleanup(dev); - - vuart_bus_priv.devices[dev->port_number] = NULL; - kfree(priv); - priv = NULL; - - dev_dbg(&dev->core, " <- %s:%d\n", __func__, __LINE__); - up(&vuart_bus_priv.probe_mutex); - return 0; -} - -/** - * ps3_vuart_shutdown - Cleans interrupts and HV resources. - * @dev: The struct ps3_system_bus_device instance. - * - * Cleans interrupts and HV resources. After this call the - * device can still be used in polling mode. This behavior required - * by sys-manager to be able to complete the device power operation - * sequence. - */ - -static int ps3_vuart_shutdown(struct ps3_system_bus_device *dev) -{ - struct ps3_vuart_port_driver *drv; - - BUG_ON(!dev); - - down(&vuart_bus_priv.probe_mutex); - - dev_dbg(&dev->core, " -> %s:%d: match_id %d\n", __func__, __LINE__, - dev->match_id); - - if (!dev->core.driver) { - dev_dbg(&dev->core, "%s:%d: no driver bound\n", __func__, - __LINE__); - up(&vuart_bus_priv.probe_mutex); - return 0; - } - - drv = ps3_system_bus_dev_to_vuart_drv(dev); - - BUG_ON(!drv); - - if (drv->shutdown) - drv->shutdown(dev); - else if (drv->remove) { - dev_dbg(&dev->core, "%s:%d: no shutdown, calling remove\n", - __func__, __LINE__); - drv->remove(dev); - } else { - dev_dbg(&dev->core, "%s:%d: no shutdown method\n", __func__, - __LINE__); - BUG(); - } - - ps3_vuart_cleanup(dev); - - dev_dbg(&dev->core, " <- %s:%d\n", __func__, __LINE__); - - up(&vuart_bus_priv.probe_mutex); - return 0; -} - -static int __init ps3_vuart_bus_init(void) -{ - pr_debug("%s:%d:\n", __func__, __LINE__); - - if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) - return -ENODEV; - - init_MUTEX(&vuart_bus_priv.probe_mutex); - - return 0; -} - -static void __exit ps3_vuart_bus_exit(void) -{ - pr_debug("%s:%d:\n", __func__, __LINE__); -} - -core_initcall(ps3_vuart_bus_init); -module_exit(ps3_vuart_bus_exit); - -/** - * ps3_vuart_port_driver_register - Add a vuart port device driver. - */ - -int ps3_vuart_port_driver_register(struct ps3_vuart_port_driver *drv) -{ - int result; - - pr_debug("%s:%d: (%s)\n", __func__, __LINE__, drv->core.core.name); - - BUG_ON(!drv->core.match_id); - BUG_ON(!drv->core.core.name); - - drv->core.probe = ps3_vuart_probe; - drv->core.remove = ps3_vuart_remove; - drv->core.shutdown = ps3_vuart_shutdown; - - result = ps3_system_bus_driver_register(&drv->core); - return result; -} -EXPORT_SYMBOL_GPL(ps3_vuart_port_driver_register); - -/** - * ps3_vuart_port_driver_unregister - Remove a vuart port device driver. - */ - -void ps3_vuart_port_driver_unregister(struct ps3_vuart_port_driver *drv) -{ - pr_debug("%s:%d: (%s)\n", __func__, __LINE__, drv->core.core.name); - ps3_system_bus_driver_unregister(&drv->core); -} -EXPORT_SYMBOL_GPL(ps3_vuart_port_driver_unregister); -- cgit v1.2.3 From ee592a5bd5180cc1ffaf5acd7bf1e91e0d854a08 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 28 Nov 2007 16:21:11 -0800 Subject: ps3fb: video memory size cleanups - Limit video memory size to avoid crossing a 256 MiB boundary in IOIF space. - Pass the actual amount of video memory used to lv1_gpu_memory_allocate(). Signed-off-by: Geert Uytterhoeven Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/ps3fb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c index 75836aa8319..9c56c492a69 100644 --- a/drivers/video/ps3fb.c +++ b/drivers/video/ps3fb.c @@ -51,7 +51,6 @@ #define L1GPU_DISPLAY_SYNC_HSYNC 1 #define L1GPU_DISPLAY_SYNC_VSYNC 2 -#define DDR_SIZE (0) /* used no ddr */ #define GPU_CMD_BUF_SIZE (64 * 1024) #define GPU_IOIF (0x0d000000UL) #define GPU_ALIGN_UP(x) _ALIGN_UP((x), 64) @@ -1060,6 +1059,7 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev) u64 xdr_lpar; int status, res_index; struct task_struct *task; + unsigned long max_ps3fb_size; status = ps3_open_hv_device(dev); if (status) { @@ -1085,8 +1085,15 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev) ps3fb_set_sync(&dev->core); + max_ps3fb_size = _ALIGN_UP(GPU_IOIF, 256*1024*1024) - GPU_IOIF; + if (ps3fb_videomemory.size > max_ps3fb_size) { + dev_info(&dev->core, "Limiting ps3fb mem size to %lu bytes\n", + max_ps3fb_size); + ps3fb_videomemory.size = max_ps3fb_size; + } + /* get gpu context handle */ - status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0, + status = lv1_gpu_memory_allocate(ps3fb_videomemory.size, 0, 0, 0, 0, &ps3fb.memory_handle, &ddr_lpar); if (status) { dev_err(&dev->core, "%s: lv1_gpu_memory_allocate failed: %d\n", -- cgit v1.2.3 From a7839e960675b549f06209d18283d5cee2ce9261 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Wed, 28 Nov 2007 16:21:21 -0800 Subject: PNP: increase the maximum number of resources On some systems the number of resources(IO,MEM) returnedy by PNP device is greater than the PNP constant, for example motherboard devices. It brings that some resources can't be reserved and resource confilicts. This will cause PCI resources are assigned wrongly in some systems, and cause hang. This is a regression since we deleted ACPI motherboard driver and use PNP system driver. [akpm@linux-foundation.org: fix text and coding-style a bit] Signed-off-by: Li Shaohua Signed-off-by: Zhao Yakui Cc: Bjorn Helgaas Cc: Thomas Renninger Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pnp/pnpacpi/rsparser.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 11adab13f2b..3c5eb374adf 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -83,9 +83,11 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_IRQ) i++; - if (i >= PNP_MAX_IRQ) + if (i >= PNP_MAX_IRQ) { + printk(KERN_ERR "pnpacpi: exceeded the max number of IRQ " + "resources: %d \n", PNP_MAX_IRQ); return; - + } /* * in IO-APIC mode, use overrided attribute. Two reasons: * 1. BIOS bug in DSDT @@ -181,6 +183,9 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, } res->dma_resource[i].start = dma; res->dma_resource[i].end = dma; + } else { + printk(KERN_ERR "pnpacpi: exceeded the max number of DMA " + "resources: %d \n", PNP_MAX_DMA); } } @@ -202,6 +207,9 @@ static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, } res->port_resource[i].start = io; res->port_resource[i].end = io + len - 1; + } else { + printk(KERN_ERR "pnpacpi: exceeded the max number of IO " + "resources: %d \n", PNP_MAX_PORT); } } @@ -225,6 +233,9 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, res->mem_resource[i].start = mem; res->mem_resource[i].end = mem + len - 1; + } else { + printk(KERN_ERR "pnpacpi: exceeded the max number of mem " + "resources: %d\n", PNP_MAX_MEM); } } -- cgit v1.2.3 From 05a462afe80553550bc77afc724ce60b42ad587e Mon Sep 17 00:00:00 2001 From: Marcel Selhorst Date: Wed, 28 Nov 2007 16:21:27 -0800 Subject: TPM: fix TIS device driver locality request During the initialization of the TPM TIS driver, the necessary locality has to be requested earlier in the init-process. Depending on the used TPM chip, this leads to wrong information. For example: Lenovo X61s with Atmel TPM: tpm_tis 00:0a: 1.2 TPM (device-id 0xFFFF, rev-id 255) But correct is: tpm_tis 00:0c: 1.2 TPM (device-id 0x3203, rev-id 9) This short patch fixes this issue. Signed-off-by: Marcel Selhorst Cc: Kylene Jo Hall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/tpm/tpm_tis.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index fd771a4d6d1..81503d94fec 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -450,6 +450,11 @@ static int tpm_tis_init(struct device *dev, resource_size_t start, goto out_err; } + if (request_locality(chip, 0) != 0) { + rc = -ENODEV; + goto out_err; + } + vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0)); /* Default timeouts */ @@ -487,11 +492,6 @@ static int tpm_tis_init(struct device *dev, resource_size_t start, if (intfcaps & TPM_INTF_DATA_AVAIL_INT) dev_dbg(dev, "\tData Avail Int Support\n"); - if (request_locality(chip, 0) != 0) { - rc = -ENODEV; - goto out_err; - } - /* INTERRUPT Setup */ init_waitqueue_head(&chip->vendor.read_queue); init_waitqueue_head(&chip->vendor.int_queue); -- cgit v1.2.3 From 438ae1ae7bef17026127b66b1ee16efde93bbcb0 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 28 Nov 2007 16:21:29 -0800 Subject: S3C24XX: ensure we only configure valid GPIOs If we specify an GPIO which cannot be used for the purpose, then assume that the GPIO is not to be used and do not try and configure it. This can be the case where the SPI bus is TX only. Signed-off-by: Ben Dooks Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/spi/spi_s3c24xx_gpio.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c index 0fa25e2e80f..d59105dc308 100644 --- a/drivers/spi/spi_s3c24xx_gpio.c +++ b/drivers/spi/spi_s3c24xx_gpio.c @@ -96,6 +96,7 @@ static void s3c2410_spigpio_chipselect(struct spi_device *dev, int value) static int s3c2410_spigpio_probe(struct platform_device *dev) { + struct s3c2410_spigpio_info *info; struct spi_master *master; struct s3c2410_spigpio *sp; int ret; @@ -113,7 +114,7 @@ static int s3c2410_spigpio_probe(struct platform_device *dev) platform_set_drvdata(dev, sp); /* copy in the plkatform data */ - sp->info = dev->dev.platform_data; + info = sp->info = dev->dev.platform_data; /* setup spi bitbang adaptor */ sp->bitbang.master = spi_master_get(master); @@ -124,13 +125,18 @@ static int s3c2410_spigpio_probe(struct platform_device *dev) sp->bitbang.txrx_word[SPI_MODE_2] = s3c2410_spigpio_txrx_mode2; sp->bitbang.txrx_word[SPI_MODE_3] = s3c2410_spigpio_txrx_mode3; - /* set state of spi pins */ - s3c2410_gpio_setpin(sp->info->pin_clk, 0); - s3c2410_gpio_setpin(sp->info->pin_mosi, 0); + /* set state of spi pins, always assume that the clock is + * available, but do check the MOSI and MISO. */ + s3c2410_gpio_setpin(info->pin_clk, 0); + s3c2410_gpio_cfgpin(info->pin_clk, S3C2410_GPIO_OUTPUT); - s3c2410_gpio_cfgpin(sp->info->pin_clk, S3C2410_GPIO_OUTPUT); - s3c2410_gpio_cfgpin(sp->info->pin_mosi, S3C2410_GPIO_OUTPUT); - s3c2410_gpio_cfgpin(sp->info->pin_miso, S3C2410_GPIO_INPUT); + if (info->pin_mosi < S3C2410_GPH10) { + s3c2410_gpio_setpin(info->pin_mosi, 0); + s3c2410_gpio_cfgpin(info->pin_mosi, S3C2410_GPIO_OUTPUT); + } + + if (info->pin_miso != S3C2410_GPA0 && info->pin_miso < S3C2410_GPH10) + s3c2410_gpio_cfgpin(info->pin_miso, S3C2410_GPIO_INPUT); ret = spi_bitbang_start(&sp->bitbang); if (ret) -- cgit v1.2.3 From 75d427982fef672b3608ae809b8819ec6358edfe Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 28 Nov 2007 16:21:30 -0800 Subject: spi: S3C2410: add bus number to SPI GPIO driver Allow passing a bus number through the platform data for the S3C2410 SPI GPIO driver. This is needed to support multiple SPI busses. Signed-off-by: Ben Dooks Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/spi/spi_s3c24xx_gpio.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c index d59105dc308..109d82c1abc 100644 --- a/drivers/spi/spi_s3c24xx_gpio.c +++ b/drivers/spi/spi_s3c24xx_gpio.c @@ -118,6 +118,7 @@ static int s3c2410_spigpio_probe(struct platform_device *dev) /* setup spi bitbang adaptor */ sp->bitbang.master = spi_master_get(master); + sp->bitbang.master->bus_num = info->bus_num; sp->bitbang.chipselect = s3c2410_spigpio_chipselect; sp->bitbang.txrx_word[SPI_MODE_0] = s3c2410_spigpio_txrx_mode0; -- cgit v1.2.3 From e482179d547ff250cab487859b6fc91995bbdbb5 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 28 Nov 2007 16:21:33 -0800 Subject: m68k: zorro7xx needs m68k: zorro7xx needs if !CONFIG_AMIGA_PCMCIA Reported by Ingo Juergensmann Signed-off-by: Geert Uytterhoeven Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/zorro7xx.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/zorro7xx.c b/drivers/scsi/zorro7xx.c index ac67394c737..64d40a2d4d4 100644 --- a/drivers/scsi/zorro7xx.c +++ b/drivers/scsi/zorro7xx.c @@ -13,7 +13,10 @@ #include #include #include + +#include #include + #include #include -- cgit v1.2.3 From b64d70825abbf706bbe80be1b11b09514b71f45e Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 28 Nov 2007 16:21:35 -0800 Subject: fb_ddc: fix DDC lines quirk The code in fb_ddc_read() is said to be based on the implementation of the radeon driver: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fc5891c8a3ba284f13994d7bc1f1bfa8283982de However, comparing the old radeon driver code with the new fb_ddc code reveals some differences. Most notably, the I2C bus lines are held at the end of the function, while the original code was releasing them (as the comment above correctly says.) There are a few other differences, which appear to be responsible for read failures on my system. While tracing low-level I2C code in i2c-algo-bit, I noticed that the initial attempt to read the EDID always failed. It takes one retry for the read to succeed. As we are about to remove this automatic retry property from i2c-algo-bit, reading the EDID would really fail. As a summary, the I2C lines quirk which is supposedly needed to read EDID on some older monitors is currently breaking the (first) read on all other monitors (and might not even work with older ones - did anyone try since October 2006?) After applying the patch below, which makes the code in fb_ddc_read() really similar to what the radeon driver used to have, the first EDID read succeeds again. On top of that, as it appears that this code has been broken for one year now and nobody seems to have complained, I'm curious if it makes sense to keep this quirk in place. It makes the code more complex and slower just for the sake of monitors which I guess nobody uses anymore. Can't we just get rid of it? Signed-off-by: Jean Delvare Acked-by: Benjamin Herrenschmidt Tested-by: Roger Leigh Tested-by: Michael Buesch Cc: "Antonino A. Daplas" Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/fb_ddc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/video/fb_ddc.c b/drivers/video/fb_ddc.c index f836137a0ed..a0df63289b5 100644 --- a/drivers/video/fb_ddc.c +++ b/drivers/video/fb_ddc.c @@ -56,13 +56,12 @@ unsigned char *fb_ddc_read(struct i2c_adapter *adapter) int i, j; algo_data->setscl(algo_data->data, 1); - algo_data->setscl(algo_data->data, 0); for (i = 0; i < 3; i++) { /* For some old monitors we need the * following process to initialize/stop DDC */ - algo_data->setsda(algo_data->data, 0); + algo_data->setsda(algo_data->data, 1); msleep(13); algo_data->setscl(algo_data->data, 1); @@ -97,14 +96,15 @@ unsigned char *fb_ddc_read(struct i2c_adapter *adapter) algo_data->setsda(algo_data->data, 1); msleep(15); algo_data->setscl(algo_data->data, 0); + algo_data->setsda(algo_data->data, 0); if (edid) break; } /* Release the DDC lines when done or the Apple Cinema HD display * will switch off */ - algo_data->setsda(algo_data->data, 0); - algo_data->setscl(algo_data->data, 0); + algo_data->setsda(algo_data->data, 1); + algo_data->setscl(algo_data->data, 1); return edid; } -- cgit v1.2.3 From 8ea50a3f0b70977939d2d9d3671b8173482afff2 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 28 Nov 2007 16:21:36 -0800 Subject: drivers/pnp/resource.c: Add missing pci_dev_put There should be a pci_dev_put when breaking out of a loop that iterates over calls to pci_get_device and similar functions. This was fixed using the following semantic patch. // @@ identifier d; type T; expression e; iterator for_each_pci_dev; @@ T *d; ... for_each_pci_dev(d) {... when != pci_dev_put(d) when != e = d ( return d; | + pci_dev_put(d); ? return ...; ) ...} // Signed-off-by: Julia Lawall Cc: Greg KH Cc: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pnp/resource.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 41d73a5e931..e50ebcffb96 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -367,8 +367,10 @@ int pnp_check_irq(struct pnp_dev *dev, int idx) { struct pci_dev *pci = NULL; for_each_pci_dev(pci) { - if (pci->irq == *irq) + if (pci->irq == *irq) { + pci_dev_put(pci); return 0; + } } } #endif -- cgit v1.2.3 From 48986f06b6bc6f435debcfad0a748ce35f0a52df Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 28 Nov 2007 16:21:37 -0800 Subject: MFD: SM501 debug typo fix Remove errnoeous x character from dev_dbg() call that stops the driver compiling under debug. Signed-off-by: Ben Dooks Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/mfd/sm501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index 8135e4c3bf4..afd82966f9a 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c @@ -156,7 +156,7 @@ static void sm501_dump_clk(struct sm501_devdata *sm) dev_dbg(sm->dev, "PM0[%c]: " "P2 %ld.%ld MHz (%ld), V2 %ld.%ld (%ld), " -x "M %ld.%ld (%ld), MX1 %ld.%ld (%ld)\n", + "M %ld.%ld (%ld), MX1 %ld.%ld (%ld)\n", (pmc & 3 ) == 0 ? '*' : '-', fmt_freq(decode_div(pll2, pm0, 24, 1<<29, 31, px_div)), fmt_freq(decode_div(pll2, pm0, 16, 1<<20, 15, misc_div)), -- cgit v1.2.3 From e593f070b40887dc0415646a4c0720eb8630c722 Mon Sep 17 00:00:00 2001 From: Anti Sullin Date: Wed, 28 Nov 2007 16:21:40 -0800 Subject: atmel_lcdfb: LCDC startup fix This patch adds an additional loop, that delays turning off the DMA until the LCDC core has been turned off. This prevents the picture to be shifted some random length when the kernel re-initializes the LCDC. Without this patch, the LCDC keeps running for some small time after the PWRCON:LCD_PWR has been cleared ; the FIFO suffers an underrun and on re-starting the LCDC the FIFO data stays shifted. This behavior has been seen and fixed on AT91SAM9261-EK and two custom AT91SAM9261 boards, all of them having different LCD panels. Thanks a lot to Anti Sullin for submitting this patch (long time ago). Signed-off-by: Anti Sullin Signed-off-by: Andrew Victor Signed-off-by: Nicolas Ferre Acked-by: Haavard Skinnemoen Cc: "Antonino A. Daplas" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/atmel_lcdfb.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 235b618b411..11a3a222dfc 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -268,6 +268,10 @@ static int atmel_lcdfb_set_par(struct fb_info *info) /* Turn off the LCD controller and the DMA controller */ lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET); + /* Wait for the LCDC core to become idle */ + while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY) + msleep(10); + lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0); if (info->var.bits_per_pixel == 1) -- cgit v1.2.3 From 6d4f5879b6f4da50bde94e1cae73755978ed048f Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Wed, 28 Nov 2007 16:21:43 -0800 Subject: dmaengine: correct invalid assumptions in the Kconfig text This patch corrects recently changed (and now invalid) Kconfig descriptions for the DMA engine framework: - Non-Intel(R) hardware also has DMA engines; - DMA is used for more than memcpy and RAID offloading. In fact, on most platforms memcpy and RAID aren't factors, and DMA exists so that peripherals can transfer data to/from memory while the CPU does other work. Signed-off-by: Haavard Skinnemoen Signed-off-by: David Brownell Signed-off-by: Dan Williams Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/dma/Kconfig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 6a7d25fc247..c46b7c219ee 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -3,11 +3,13 @@ # menuconfig DMADEVICES - bool "DMA Offload Engine support" + bool "DMA Engine support" depends on (PCI && X86) || ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX help - Intel(R) offload engines enable offloading memory copies in the - network stack and RAID operations in the MD driver. + DMA engines can do asynchronous data transfers without + involving the host CPU. Currently, this framework can be + used to offload memory copies in the network stack and + RAID operations in the MD driver. if DMADEVICES -- cgit v1.2.3 From 68576cf122bc5195c758ed295e78b5858472378a Mon Sep 17 00:00:00 2001 From: Thomas Bogendoerfer Date: Wed, 28 Nov 2007 16:21:44 -0800 Subject: IP22ZILOG: fix lockup and sysrq - fix lockup when switching from early console to real console - make sysrq reliable - fix panic, if sysrq is issued before console is opened Signed-off-by: Thomas Bogendoerfer Acked-by: Ralf Baechle Cc: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/ip22zilog.c | 247 +++++++++++++++++++-------------------------- 1 file changed, 106 insertions(+), 141 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c index f3257f708ef..9c95bc0398a 100644 --- a/drivers/serial/ip22zilog.c +++ b/drivers/serial/ip22zilog.c @@ -45,8 +45,6 @@ #include "ip22zilog.h" -void ip22_do_break(void); - /* * On IP22 we need to delay after register accesses but we do not need to * flush writes. @@ -81,12 +79,9 @@ struct uart_ip22zilog_port { #define IP22ZILOG_FLAG_REGS_HELD 0x00000040 #define IP22ZILOG_FLAG_TX_STOPPED 0x00000080 #define IP22ZILOG_FLAG_TX_ACTIVE 0x00000100 +#define IP22ZILOG_FLAG_RESET_DONE 0x00000200 - unsigned int cflag; - - /* L1-A keyboard break state. */ - int kbd_id; - int l1_down; + unsigned int tty_break; unsigned char parity_mask; unsigned char prev_status; @@ -250,13 +245,26 @@ static void ip22zilog_maybe_update_regs(struct uart_ip22zilog_port *up, } } -static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, - struct zilog_channel *channel) +#define Rx_BRK 0x0100 /* BREAK event software flag. */ +#define Rx_SYS 0x0200 /* SysRq event software flag. */ + +static struct tty_struct *ip22zilog_receive_chars(struct uart_ip22zilog_port *up, + struct zilog_channel *channel) { - struct tty_struct *tty = up->port.info->tty; /* XXX info==NULL? */ + struct tty_struct *tty; + unsigned char ch, flag; + unsigned int r1; + + tty = NULL; + if (up->port.info != NULL && + up->port.info->tty != NULL) + tty = up->port.info->tty; - while (1) { - unsigned char ch, r1, flag; + for (;;) { + ch = readb(&channel->control); + ZSDELAY(); + if (!(ch & Rx_CH_AV)) + break; r1 = read_zsreg(channel, R1); if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) { @@ -265,43 +273,26 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, ZS_WSYNC(channel); } - ch = readb(&channel->control); - ZSDELAY(); - - /* This funny hack depends upon BRK_ABRT not interfering - * with the other bits we care about in R1. - */ - if (ch & BRK_ABRT) - r1 |= BRK_ABRT; - ch = readb(&channel->data); ZSDELAY(); ch &= up->parity_mask; - if (ZS_IS_CONS(up) && (r1 & BRK_ABRT)) { - /* Wait for BREAK to deassert to avoid potentially - * confusing the PROM. - */ - while (1) { - ch = readb(&channel->control); - ZSDELAY(); - if (!(ch & BRK_ABRT)) - break; - } - ip22_do_break(); - return; - } + /* Handle the null char got when BREAK is removed. */ + if (!ch) + r1 |= up->tty_break; /* A real serial line, record the character and status. */ flag = TTY_NORMAL; up->port.icount.rx++; - if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) { - if (r1 & BRK_ABRT) { - r1 &= ~(PAR_ERR | CRC_ERR); + if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR | Rx_SYS | Rx_BRK)) { + up->tty_break = 0; + + if (r1 & (Rx_SYS | Rx_BRK)) { up->port.icount.brk++; - if (uart_handle_break(&up->port)) - goto next_char; + if (r1 & Rx_SYS) + continue; + r1 &= ~(PAR_ERR | CRC_ERR); } else if (r1 & PAR_ERR) up->port.icount.parity++; @@ -310,30 +301,21 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, if (r1 & Rx_OVR) up->port.icount.overrun++; r1 &= up->port.read_status_mask; - if (r1 & BRK_ABRT) + if (r1 & Rx_BRK) flag = TTY_BREAK; else if (r1 & PAR_ERR) flag = TTY_PARITY; else if (r1 & CRC_ERR) flag = TTY_FRAME; } - if (uart_handle_sysrq_char(&up->port, ch)) - goto next_char; - if (up->port.ignore_status_mask == 0xff || - (r1 & up->port.ignore_status_mask) == 0) - tty_insert_flip_char(tty, ch, flag); + if (uart_handle_sysrq_char(&up->port, ch)) + continue; - if (r1 & Rx_OVR) - tty_insert_flip_char(tty, 0, TTY_OVERRUN); - next_char: - ch = readb(&channel->control); - ZSDELAY(); - if (!(ch & Rx_CH_AV)) - break; + if (tty) + uart_insert_char(&up->port, r1, Rx_OVR, ch, flag); } - - tty_flip_buffer_push(tty); + return tty; } static void ip22zilog_status_handle(struct uart_ip22zilog_port *up, @@ -348,6 +330,15 @@ static void ip22zilog_status_handle(struct uart_ip22zilog_port *up, ZSDELAY(); ZS_WSYNC(channel); + if (up->curregs[R15] & BRKIE) { + if ((status & BRK_ABRT) && !(up->prev_status & BRK_ABRT)) { + if (uart_handle_break(&up->port)) + up->tty_break = Rx_SYS; + else + up->tty_break = Rx_BRK; + } + } + if (ZS_WANTS_MODEM_STATUS(up)) { if (status & SYNC) up->port.icount.dsr++; @@ -356,10 +347,10 @@ static void ip22zilog_status_handle(struct uart_ip22zilog_port *up, * But it does not tell us which bit has changed, we have to keep * track of this ourselves. */ - if ((status & DCD) ^ up->prev_status) + if ((status ^ up->prev_status) ^ DCD) uart_handle_dcd_change(&up->port, (status & DCD)); - if ((status & CTS) ^ up->prev_status) + if ((status ^ up->prev_status) ^ CTS) uart_handle_cts_change(&up->port, (status & CTS)); @@ -447,19 +438,21 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id) while (up) { struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port); + struct tty_struct *tty; unsigned char r3; spin_lock(&up->port.lock); r3 = read_zsreg(channel, R3); /* Channel A */ + tty = NULL; if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { writeb(RES_H_IUS, &channel->control); ZSDELAY(); ZS_WSYNC(channel); if (r3 & CHARxIP) - ip22zilog_receive_chars(up, channel); + tty = ip22zilog_receive_chars(up, channel); if (r3 & CHAEXT) ip22zilog_status_handle(up, channel); if (r3 & CHATxIP) @@ -467,18 +460,22 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id) } spin_unlock(&up->port.lock); + if (tty) + tty_flip_buffer_push(tty); + /* Channel B */ up = up->next; channel = ZILOG_CHANNEL_FROM_PORT(&up->port); spin_lock(&up->port.lock); + tty = NULL; if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { writeb(RES_H_IUS, &channel->control); ZSDELAY(); ZS_WSYNC(channel); if (r3 & CHBRxIP) - ip22zilog_receive_chars(up, channel); + tty = ip22zilog_receive_chars(up, channel); if (r3 & CHBEXT) ip22zilog_status_handle(up, channel); if (r3 & CHBTxIP) @@ -486,6 +483,9 @@ static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id) } spin_unlock(&up->port.lock); + if (tty) + tty_flip_buffer_push(tty); + up = up->next; } @@ -681,11 +681,46 @@ static void ip22zilog_break_ctl(struct uart_port *port, int break_state) spin_unlock_irqrestore(&port->lock, flags); } +static void __ip22zilog_reset(struct uart_ip22zilog_port *up) +{ + struct zilog_channel *channel; + int i; + + if (up->flags & IP22ZILOG_FLAG_RESET_DONE) + return; + + /* Let pending transmits finish. */ + channel = ZILOG_CHANNEL_FROM_PORT(&up->port); + for (i = 0; i < 1000; i++) { + unsigned char stat = read_zsreg(channel, R1); + if (stat & ALL_SNT) + break; + udelay(100); + } + + if (!ZS_IS_CHANNEL_A(up)) { + up++; + channel = ZILOG_CHANNEL_FROM_PORT(&up->port); + } + write_zsreg(channel, R9, FHWRES); + ZSDELAY_LONG(); + (void) read_zsreg(channel, R0); + + up->flags |= IP22ZILOG_FLAG_RESET_DONE; + up->next->flags |= IP22ZILOG_FLAG_RESET_DONE; +} + static void __ip22zilog_startup(struct uart_ip22zilog_port *up) { struct zilog_channel *channel; channel = ZILOG_CHANNEL_FROM_PORT(&up->port); + + __ip22zilog_reset(up); + + __load_zsregs(channel, up->curregs); + /* set master interrupt enable */ + write_zsreg(channel, R9, up->curregs[R9]); up->prev_status = readb(&channel->control); /* Enable receiver and transmitter. */ @@ -859,8 +894,6 @@ ip22zilog_set_termios(struct uart_port *port, struct ktermios *termios, else up->flags &= ~IP22ZILOG_FLAG_MODEM_STATUS; - up->cflag = termios->c_cflag; - ip22zilog_maybe_update_regs(up, ZILOG_CHANNEL_FROM_PORT(port)); uart_update_timeout(port, termios->c_cflag, baud); @@ -992,74 +1025,29 @@ ip22zilog_console_write(struct console *con, const char *s, unsigned int count) spin_unlock_irqrestore(&up->port.lock, flags); } -void -ip22serial_console_termios(struct console *con, char *options) -{ - int baud = 9600, bits = 8, cflag; - int parity = 'n'; - int flow = 'n'; - - if (options) - uart_parse_options(options, &baud, &parity, &bits, &flow); - - cflag = CREAD | HUPCL | CLOCAL; - - switch (baud) { - case 150: cflag |= B150; break; - case 300: cflag |= B300; break; - case 600: cflag |= B600; break; - case 1200: cflag |= B1200; break; - case 2400: cflag |= B2400; break; - case 4800: cflag |= B4800; break; - case 9600: cflag |= B9600; break; - case 19200: cflag |= B19200; break; - case 38400: cflag |= B38400; break; - default: baud = 9600; cflag |= B9600; break; - } - - con->cflag = cflag | CS8; /* 8N1 */ - - uart_update_timeout(&ip22zilog_port_table[con->index].port, cflag, baud); -} - static int __init ip22zilog_console_setup(struct console *con, char *options) { struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index]; unsigned long flags; - int baud, brg; - - printk("Console: ttyS%d (IP22-Zilog)\n", con->index); + int baud = 9600, bits = 8; + int parity = 'n'; + int flow = 'n'; - /* Get firmware console settings. */ - ip22serial_console_termios(con, options); + up->flags |= IP22ZILOG_FLAG_IS_CONS; - /* Firmware console speed is limited to 150-->38400 baud so - * this hackish cflag thing is OK. - */ - switch (con->cflag & CBAUD) { - case B150: baud = 150; break; - case B300: baud = 300; break; - case B600: baud = 600; break; - case B1200: baud = 1200; break; - case B2400: baud = 2400; break; - case B4800: baud = 4800; break; - default: case B9600: baud = 9600; break; - case B19200: baud = 19200; break; - case B38400: baud = 38400; break; - }; - - brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR); + printk(KERN_INFO "Console: ttyS%d (IP22-Zilog)\n", con->index); spin_lock_irqsave(&up->port.lock, flags); - up->curregs[R15] = BRKIE; - ip22zilog_convert_to_zs(up, con->cflag, 0, brg); + up->curregs[R15] |= BRKIE; __ip22zilog_startup(up); spin_unlock_irqrestore(&up->port.lock, flags); - return 0; + if (options) + uart_parse_options(options, &baud, &parity, &bits, &flow); + return uart_set_options(&up->port, con, baud, parity, bits, flow); } static struct uart_driver ip22zilog_reg; @@ -1140,25 +1128,10 @@ static void __init ip22zilog_prepare(void) up[(chip * 2) + 1].port.line = (chip * 2) + 1; up[(chip * 2) + 1].flags |= IP22ZILOG_FLAG_IS_CHANNEL_A; } -} - -static void __init ip22zilog_init_hw(void) -{ - int i; - - for (i = 0; i < NUM_CHANNELS; i++) { - struct uart_ip22zilog_port *up = &ip22zilog_port_table[i]; - struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port); - unsigned long flags; - int baud, brg; - spin_lock_irqsave(&up->port.lock, flags); - - if (ZS_IS_CHANNEL_A(up)) { - write_zsreg(channel, R9, FHWRES); - ZSDELAY_LONG(); - (void) read_zsreg(channel, R0); - } + for (channel = 0; channel < NUM_CHANNELS; channel++) { + struct uart_ip22zilog_port *up = &ip22zilog_port_table[channel]; + int brg; /* Normal serial TTY. */ up->parity_mask = 0xff; @@ -1169,16 +1142,10 @@ static void __init ip22zilog_init_hw(void) up->curregs[R9] = NV | MIE; up->curregs[R10] = NRZ; up->curregs[R11] = TCBR | RCBR; - baud = 9600; - brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR); + brg = BPS_TO_BRG(9600, ZS_CLOCK / ZS_CLOCK_DIVISOR); up->curregs[R12] = (brg & 0xff); up->curregs[R13] = (brg >> 8) & 0xff; up->curregs[R14] = BRENAB; - __load_zsregs(channel, up->curregs); - /* set master interrupt enable */ - write_zsreg(channel, R9, up->curregs[R9]); - - spin_unlock_irqrestore(&up->port.lock, flags); } } @@ -1195,8 +1162,6 @@ static int __init ip22zilog_ports_init(void) panic("IP22-Zilog: Unable to register zs interrupt handler.\n"); } - ip22zilog_init_hw(); - ret = uart_register_driver(&ip22zilog_reg); if (ret == 0) { int i; -- cgit v1.2.3 From 9fc89c2dea7ca7915e6606e49167cdca2f3c4e30 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 28 Nov 2007 16:21:50 -0800 Subject: isdn: bootup crash fix got this HiSax bootup crash on a "make randconfig" bzImage bootup: Calling initcall 0xc0bb1320: HiSax_init+0x0/0x380() HiSax: Linux Driver for passive ISDN cards HiSax: Version 3.5 (kernel) HiSax: Layer1 Revision 2.46.2.5 HiSax: Layer2 Revision 2.30.2.4 HiSax: TeiMgr Revision 2.20.2.3 HiSax: Layer3 Revision 2.22.2.3 HiSax: LinkLayer Revision 2.59.2.4 HiSax: Total 1 card defined HiSax: Card 1 Protocol EDSS1 Id=HiSax (0) HiSax: HFC-S driver Rev. 1.10.2.4 HFCS: defined at 0x500 IRQ 5 HZ 250 Teles 16.3c: IRQ 5 count 0 HFCS: resetting card Teles 16.3c: IRQ 5 count 0 Teles 16.3c: IRQ(5) getting no interrupts during init 1 HFCS: resetting card ------------[ cut here ]------------ kernel BUG at include/linux/timer.h:145! invalid opcode: 0000 [#1] PREEMPT DEBUG_PAGEALLOC Modules linked in: Pid: 1, comm: swapper Not tainted (2.6.24-rc3 #2045) EIP: 0060:[] EFLAGS: 00010286 CPU: 0 EIP is at hfcs_card_msg+0x15f/0x180 EAX: c0cf2e5c EBX: 000000f2 ECX: 00000000 EDX: ffff1193 ESI: f76e8000 EDI: f76e8000 EBP: f7c23ec4 ESP: f7c23eac DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068 Process swapper (pid: 1, ti=f7c22000 task=f7c0e000 task.ti=f7c22000) Stack: 00000000 f7c23ec4 c011703b 00000002 f76e8000 00000000 f7c23ef8 c060c3e5 c0a7c9c0 c0a315dc 00000005 00000001 00000000 f7c23f34 00000000 c0b5c9c0 f7c23f34 00000000 c0f5a8e0 f7c23f80 c0bb154f 00000000 00000001 c0a9b5b9 Call Trace: [] show_trace_log_lvl+0x1a/0x40 [] show_stack_log_lvl+0xa9/0xe0 [] show_registers+0xbf/0x200 [] die+0x104/0x220 [] do_trap+0x83/0xc0 [] do_invalid_op+0x88/0xa0 [] error_code+0x6a/0x70 [] checkcard+0x4a5/0x620 [] HiSax_init+0x22f/0x380 [] kernel_init+0x97/0x2a0 [] kernel_thread_helper+0x7/0x20 ======================= Code: e8 43 ae ff 8b 57 3c 85 d2 0f 84 ef fe ff ff b8 a0 99 ad c0 b9 02 00 00 00 e8 ce 11 ae ff 83 c4 0c b8 00 00 00 00 5b 5e 5f c9 c3 <0f> 0b eb fe 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 EIP: [] hfcs_card_msg+0x15f/0x180 SS:ESP 0068:f7c23eac Kernel panic - not syncing: Attempted to kill init! The box has no HiSax card installed. the reason for the crash is add_timer() done on an already running timer. This happens because for some reason CARD_INIT is called twice. this patch works this problem around by using mod_timer() - this gets a booting system - but it would be nice to figure out why CARD_INIT is done twice. the ISDN config section (generated via make randconfig) is this: # # ISDN feature submodules # # CONFIG_ISDN_DRV_LOOP is not set CONFIG_ISDN_DIVERSION=y # # ISDN4Linux hardware drivers # # # Passive cards # CONFIG_ISDN_DRV_HISAX=y # # D-channel protocol features # CONFIG_HISAX_EURO=y CONFIG_DE_AOC=y # CONFIG_HISAX_NO_SENDCOMPLETE is not set # CONFIG_HISAX_NO_LLC is not set # CONFIG_HISAX_NO_KEYPAD is not set CONFIG_HISAX_1TR6=y CONFIG_HISAX_NI1=y CONFIG_HISAX_MAX_CARDS=8 # # HiSax supported cards # CONFIG_HISAX_16_0=y # CONFIG_HISAX_16_3 is not set # CONFIG_HISAX_TELESPCI is not set CONFIG_HISAX_S0BOX=y # CONFIG_HISAX_AVM_A1 is not set CONFIG_HISAX_FRITZPCI=y CONFIG_HISAX_AVM_A1_PCMCIA=y CONFIG_HISAX_ELSA=y CONFIG_HISAX_IX1MICROR2=y CONFIG_HISAX_DIEHLDIVA=y # CONFIG_HISAX_ASUSCOM is not set # CONFIG_HISAX_TELEINT is not set CONFIG_HISAX_HFCS=y # CONFIG_HISAX_SEDLBAUER is not set CONFIG_HISAX_SPORTSTER=y # CONFIG_HISAX_MIC is not set # CONFIG_HISAX_NETJET is not set # CONFIG_HISAX_NETJET_U is not set # CONFIG_HISAX_NICCY is not set # CONFIG_HISAX_ISURF is not set # CONFIG_HISAX_HSTSAPHIR is not set # CONFIG_HISAX_BKM_A4T is not set # CONFIG_HISAX_SCT_QUADRO is not set # CONFIG_HISAX_GAZEL is not set # CONFIG_HISAX_HFC_PCI is not set # CONFIG_HISAX_W6692 is not set # CONFIG_HISAX_HFC_SX is not set # CONFIG_HISAX_DEBUG is not set # # HiSax PCMCIA card service modules # # # HiSax sub driver modules # CONFIG_HISAX_ST5481=y CONFIG_HISAX_HFCUSB=y # CONFIG_HISAX_HFC4S8S is not set CONFIG_HISAX_FRITZ_PCIPNP=y CONFIG_HISAX_HDLC=y # # Active cards # CONFIG_ISDN_DRV_ICN=m CONFIG_ISDN_DRV_PCBIT=m CONFIG_ISDN_DRV_SC=y # CONFIG_ISDN_DRV_ACT2000 is not set CONFIG_HYSDN=m # CONFIG_ISDN_DRV_GIGASET is not set # CONFIG_ISDN_CAPI is not set CONFIG_PHONE=y CONFIG_PHONE_IXJ=m Signed-off-by: Ingo Molnar Cc: Karsten Keil Cc: Kai Germaschewski Cc: "Rafael J. Wysocki" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/hisax/hfcscard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/isdn/hisax/hfcscard.c b/drivers/isdn/hisax/hfcscard.c index 57670dc5034..909d6709ec1 100644 --- a/drivers/isdn/hisax/hfcscard.c +++ b/drivers/isdn/hisax/hfcscard.c @@ -118,8 +118,7 @@ hfcs_card_msg(struct IsdnCardState *cs, int mt, void *arg) return(0); case CARD_INIT: delay = (75*HZ)/100 +1; - cs->hw.hfcD.timer.expires = jiffies + delay; - add_timer(&cs->hw.hfcD.timer); + mod_timer(&cs->hw.hfcD.timer, jiffies + delay); spin_lock_irqsave(&cs->lock, flags); reset_hfcs(cs); init2bds0(cs); -- cgit v1.2.3 From db573b241eb1259f749e88f54105d7fa946cb9b2 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 28 Nov 2007 16:21:52 -0800 Subject: imacfb: remove reference to otherwise-unused, non-existent screen_info.imacpm_seg Cc: Edgar Hucek Cc: "Antonino A. Daplas" Cc: Kamalesh Babulal Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/imacfb.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers') diff --git a/drivers/video/imacfb.c b/drivers/video/imacfb.c index 6455fd2a39f..9366ef2bb5f 100644 --- a/drivers/video/imacfb.c +++ b/drivers/video/imacfb.c @@ -234,10 +234,6 @@ static int __init imacfb_probe(struct platform_device *dev) size_remap = size_total; imacfb_fix.smem_len = size_remap; -#ifndef __i386__ - screen_info.imacpm_seg = 0; -#endif - if (!request_mem_region(imacfb_fix.smem_start, size_total, "imacfb")) { printk(KERN_WARNING "imacfb: cannot reserve video memory at 0x%lx\n", -- cgit v1.2.3 From f78ba15705a5ef36b55c4e3142724e2211cb1733 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 28 Nov 2007 16:21:54 -0800 Subject: revert "keyspan: init termios properly" Revert 7eea436433b7b18045f272562e256976f593f7c0. Lucy said: This patch will work with the 19HS but WILL BREAK all other Keyspan adapters. It will take me a few days to get to looking at a correct fix but that keyspan_send_setup(port, 1) (and the '1' is the important part) must happen once when the port is first opened. The cflag can just be set to whatever the normal default is for your serial environment. So revert this again pending the proper fix. Cc: Borislav Petkov Cc: Greg KH Cc: Alan Cox Cc: Lucy McCoy Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/usb/serial/keyspan.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 1f7ab15df36..feba9679ace 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -1215,12 +1215,14 @@ static int keyspan_chars_in_buffer (struct usb_serial_port *port) static int keyspan_open (struct usb_serial_port *port, struct file *filp) { - struct keyspan_port_private *p_priv; - struct keyspan_serial_private *s_priv; - struct usb_serial *serial = port->serial; + struct keyspan_port_private *p_priv; + struct keyspan_serial_private *s_priv; + struct usb_serial *serial = port->serial; const struct keyspan_device_details *d_details; int i, err; + int baud_rate, device_port; struct urb *urb; + unsigned int cflag; s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -1263,6 +1265,30 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ } + /* get the terminal config for the setup message now so we don't + * need to send 2 of them */ + + cflag = port->tty->termios->c_cflag; + device_port = port->number - port->serial->minor; + + /* Baud rate calculation takes baud rate as an integer + so other rates can be generated if desired. */ + baud_rate = tty_get_baud_rate(port->tty); + /* If no match or invalid, leave as default */ + if (baud_rate >= 0 + && d_details->calculate_baud_rate(baud_rate, d_details->baudclk, + NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { + p_priv->baud = baud_rate; + } + + /* set CTS/RTS handshake etc. */ + p_priv->cflag = cflag; + p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; + + keyspan_send_setup(port, 1); + //mdelay(100); + //keyspan_set_termios(port, NULL); + return (0); } -- cgit v1.2.3 From 7c83172b98e569d9aabf947d8b3b089dadb2ff46 Mon Sep 17 00:00:00 2001 From: "Huang, Ying" Date: Wed, 28 Nov 2007 16:21:55 -0800 Subject: x86_64 EFI boot support: EFI frame buffer driver This patch adds Graphics Output Protocol support to the kernel. UEFI2.0 spec deprecates Universal Graphics Adapter (UGA) protocol and only Graphics Output Protocol (GOP) is produced. Therefore, the boot loader needs to query the UEFI firmware with appropriate Output Protocol and pass the video information to the kernel. As a result of GOP protocol, an EFI framebuffer driver is needed for displaying console messages. The patch adds a EFI framebuffer driver. The EFI frame buffer driver in this patch is based on the Intel Mac framebuffer driver. The ELILO bootloader takes care of passing the video information as appropriate for EFI firmware. The framebuffer driver has been tested in i386 kernel and x86_64 kernel on EFI platform. Signed-off-by: Chandramouli Narayanan Signed-off-by: Huang Ying Cc: "H. Peter Anvin" Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Andi Kleen Cc: "Antonino A. Daplas" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/Kconfig | 11 +++ drivers/video/Makefile | 1 + drivers/video/efifb.c | 232 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+) create mode 100644 drivers/video/efifb.c (limited to 'drivers') diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 7d86e9eae91..5b3dbcfcda4 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -641,6 +641,17 @@ config FB_VESA You will get a boot time penguin logo at no additional cost. Please read . If unsure, say Y. +config FB_EFI + bool "EFI-based Framebuffer Support" + depends on (FB = y) && X86 + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + help + This is the EFI frame buffer device driver. If the firmware on + your platform is UEFI2.0, select Y to add support for + Graphics Output Protocol for early console messages to appear. + config FB_IMAC bool "Intel-based Macintosh Framebuffer Support" depends on (FB = y) && X86 && EFI diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 59d6c45a910..83e02b3429b 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -118,6 +118,7 @@ obj-$(CONFIG_FB_OMAP) += omap/ obj-$(CONFIG_FB_UVESA) += uvesafb.o obj-$(CONFIG_FB_VESA) += vesafb.o obj-$(CONFIG_FB_IMAC) += imacfb.o +obj-$(CONFIG_FB_EFI) += efifb.o obj-$(CONFIG_FB_VGA16) += vga16fb.o obj-$(CONFIG_FB_OF) += offb.o obj-$(CONFIG_FB_BF54X_LQ043) += bf54x-lq043fb.o diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c new file mode 100644 index 00000000000..bd779ae44b1 --- /dev/null +++ b/drivers/video/efifb.c @@ -0,0 +1,232 @@ +/* + * Framebuffer driver for EFI/UEFI based system + * + * (c) 2006 Edgar Hucek + * Original efi driver written by Gerd Knorr + * + */ + +#include +#include +#include +#include +#include +#include + +#include