diff options
author | David S. Miller <davem@davemloft.net> | 2008-02-23 23:38:20 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-23 23:38:20 -0500 |
commit | 8d3c202be23c5a915f7053ebd4e96f44700c6a62 (patch) | |
tree | e0f017aff86d3ad0b858fe85f44e11096087ed00 /drivers | |
parent | 1b04ab4597725f75f94942da9aa40daa7b9a4bd9 (diff) | |
parent | 038eb0ea04b245351be34b0ae76b55eee4603989 (diff) |
Merge branch 'master' of ../linux-2.6/
Diffstat (limited to 'drivers')
326 files changed, 11048 insertions, 3089 deletions
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 9ce983ed60f0..ea92bac42c53 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c | |||
@@ -186,6 +186,12 @@ static int __init dmi_unknown_osi_linux(const struct dmi_system_id *d) | |||
186 | acpi_dmi_osi_linux(-1, d); /* unknown */ | 186 | acpi_dmi_osi_linux(-1, d); /* unknown */ |
187 | return 0; | 187 | return 0; |
188 | } | 188 | } |
189 | static int __init dmi_disable_osi_vista(const struct dmi_system_id *d) | ||
190 | { | ||
191 | printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); | ||
192 | acpi_osi_setup("!Windows 2006"); | ||
193 | return 0; | ||
194 | } | ||
189 | 195 | ||
190 | /* | 196 | /* |
191 | * Most BIOS that invoke OSI(Linux) do nothing with it. | 197 | * Most BIOS that invoke OSI(Linux) do nothing with it. |
@@ -228,10 +234,10 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
228 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"), | 234 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"), |
229 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"), | 235 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"), |
230 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"), | 236 | * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"), |
231 | * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"), | ||
232 | * | 237 | * |
233 | * _OSI(Linux) is a NOP: | 238 | * _OSI(Linux) is a NOP: |
234 | * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"), | 239 | * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"), |
240 | * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"), | ||
235 | */ | 241 | */ |
236 | { | 242 | { |
237 | .callback = dmi_disable_osi_linux, | 243 | .callback = dmi_disable_osi_linux, |
@@ -327,12 +333,20 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
327 | }, | 333 | }, |
328 | { /* OSI(Linux) effect unknown */ | 334 | { /* OSI(Linux) effect unknown */ |
329 | .callback = dmi_unknown_osi_linux, | 335 | .callback = dmi_unknown_osi_linux, |
330 | .ident = "Dell OP GX620", | 336 | .ident = "Dell OptiPlex GX620", |
331 | .matches = { | 337 | .matches = { |
332 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | 338 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
333 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"), | 339 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"), |
334 | }, | 340 | }, |
335 | }, | 341 | }, |
342 | { /* OSI(Linux) causes some USB initialization to not run */ | ||
343 | .callback = dmi_unknown_osi_linux, | ||
344 | .ident = "Dell OptiPlex 755", | ||
345 | .matches = { | ||
346 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
347 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 755"), | ||
348 | }, | ||
349 | }, | ||
336 | { /* OSI(Linux) effect unknown */ | 350 | { /* OSI(Linux) effect unknown */ |
337 | .callback = dmi_unknown_osi_linux, | 351 | .callback = dmi_unknown_osi_linux, |
338 | .ident = "Dell PE 1900", | 352 | .ident = "Dell PE 1900", |
@@ -342,6 +356,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
342 | }, | 356 | }, |
343 | }, | 357 | }, |
344 | { /* OSI(Linux) is a NOP */ | 358 | { /* OSI(Linux) is a NOP */ |
359 | .callback = dmi_unknown_osi_linux, | ||
360 | .ident = "Dell PE 1950", | ||
361 | .matches = { | ||
362 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
363 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"), | ||
364 | }, | ||
365 | }, | ||
366 | { /* OSI(Linux) is a NOP */ | ||
345 | .callback = dmi_disable_osi_linux, | 367 | .callback = dmi_disable_osi_linux, |
346 | .ident = "Dell PE R200", | 368 | .ident = "Dell PE R200", |
347 | .matches = { | 369 | .matches = { |
@@ -357,6 +379,22 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
357 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"), | 379 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"), |
358 | }, | 380 | }, |
359 | }, | 381 | }, |
382 | { /* OSI(Linux) touches USB */ | ||
383 | .callback = dmi_unknown_osi_linux, | ||
384 | .ident = "Dell PR 390", | ||
385 | .matches = { | ||
386 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
387 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 690"), | ||
388 | }, | ||
389 | }, | ||
390 | { /* OSI(Linux) unknown - ASL looks benign, but may effect dock/SMM */ | ||
391 | .callback = dmi_unknown_osi_linux, | ||
392 | .ident = "Dell PR M4300", | ||
393 | .matches = { | ||
394 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
395 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision M4300"), | ||
396 | }, | ||
397 | }, | ||
360 | { /* OSI(Linux) is a NOP */ | 398 | { /* OSI(Linux) is a NOP */ |
361 | .callback = dmi_disable_osi_linux, | 399 | .callback = dmi_disable_osi_linux, |
362 | .ident = "Dell Vostro 1000", | 400 | .ident = "Dell Vostro 1000", |
@@ -390,10 +428,10 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
390 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1536"), | 428 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1536"), |
391 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1556"), | 429 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1556"), |
392 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 1546"), | 430 | * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 1546"), |
431 | * DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), | ||
393 | * _OSI(Linux) unknown effect: | 432 | * _OSI(Linux) unknown effect: |
394 | * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo M1425"), | 433 | * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo M1425"), |
395 | * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo Si 1520"), | 434 | * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo Si 1520"), |
396 | * DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), | ||
397 | */ | 435 | */ |
398 | { | 436 | { |
399 | .callback = dmi_disable_osi_linux, | 437 | .callback = dmi_disable_osi_linux, |
@@ -402,6 +440,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
402 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | 440 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), |
403 | }, | 441 | }, |
404 | }, | 442 | }, |
443 | { | ||
444 | .callback = dmi_disable_osi_vista, | ||
445 | .ident = "Fujitsu Siemens", | ||
446 | .matches = { | ||
447 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | ||
448 | DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"), | ||
449 | }, | ||
450 | }, | ||
405 | /* | 451 | /* |
406 | * Disable OSI(Linux) warnings on all "Hewlett-Packard" | 452 | * Disable OSI(Linux) warnings on all "Hewlett-Packard" |
407 | * | 453 | * |
@@ -443,10 +489,11 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
443 | * _OSI(Linux) helps sound | 489 | * _OSI(Linux) helps sound |
444 | * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad R61"), | 490 | * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad R61"), |
445 | * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T61"), | 491 | * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T61"), |
492 | * _OSI(Linux) has Linux specific hooks | ||
493 | * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"), | ||
446 | * _OSI(Linux) is a NOP: | 494 | * _OSI(Linux) is a NOP: |
447 | * DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"), | 495 | * DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"), |
448 | * _OSI(Linux) effect unknown | 496 | * DMI_MATCH(DMI_PRODUCT_VERSION, "LENOVO3000 V100"), |
449 | * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"), | ||
450 | */ | 497 | */ |
451 | { | 498 | { |
452 | .callback = dmi_enable_osi_linux, | 499 | .callback = dmi_enable_osi_linux, |
@@ -465,7 +512,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
465 | }, | 512 | }, |
466 | }, | 513 | }, |
467 | { | 514 | { |
468 | .callback = dmi_unknown_osi_linux, | 515 | .callback = dmi_enable_osi_linux, |
469 | .ident = "Lenovo ThinkPad X61", | 516 | .ident = "Lenovo ThinkPad X61", |
470 | .matches = { | 517 | .matches = { |
471 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | 518 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
@@ -473,7 +520,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
473 | }, | 520 | }, |
474 | }, | 521 | }, |
475 | { | 522 | { |
476 | .callback = dmi_unknown_osi_linux, | 523 | .callback = dmi_disable_osi_linux, |
477 | .ident = "Lenovo 3000 V100", | 524 | .ident = "Lenovo 3000 V100", |
478 | .matches = { | 525 | .matches = { |
479 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | 526 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
@@ -543,8 +590,9 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
543 | * Disable OSI(Linux) warnings on all "Sony Corporation" | 590 | * Disable OSI(Linux) warnings on all "Sony Corporation" |
544 | * | 591 | * |
545 | * _OSI(Linux) is a NOP: | 592 | * _OSI(Linux) is a NOP: |
546 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ650N"), | 593 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NR11S_S"), |
547 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ38GP_C"), | 594 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ38GP_C"), |
595 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ650N"), | ||
548 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-TZ21MN_N"), | 596 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-TZ21MN_N"), |
549 | * _OSI(Linux) unknown effect: | 597 | * _OSI(Linux) unknown effect: |
550 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"), | 598 | * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"), |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 7222a18a0319..caf873c14bfb 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -943,7 +943,11 @@ int __init acpi_ec_ecdt_probe(void) | |||
943 | boot_ec->command_addr = ecdt_ptr->control.address; | 943 | boot_ec->command_addr = ecdt_ptr->control.address; |
944 | boot_ec->data_addr = ecdt_ptr->data.address; | 944 | boot_ec->data_addr = ecdt_ptr->data.address; |
945 | boot_ec->gpe = ecdt_ptr->gpe; | 945 | boot_ec->gpe = ecdt_ptr->gpe; |
946 | boot_ec->handle = ACPI_ROOT_OBJECT; | 946 | if (ACPI_FAILURE(acpi_get_handle(NULL, ecdt_ptr->id, |
947 | &boot_ec->handle))) { | ||
948 | pr_info("Failed to locate handle for boot EC\n"); | ||
949 | boot_ec->handle = ACPI_ROOT_OBJECT; | ||
950 | } | ||
947 | } else { | 951 | } else { |
948 | /* This workaround is needed only on some broken machines, | 952 | /* This workaround is needed only on some broken machines, |
949 | * which require early EC, but fail to provide ECDT */ | 953 | * which require early EC, but fail to provide ECDT */ |
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index 5479dc0eeeec..abec1ca94cf4 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c | |||
@@ -110,7 +110,7 @@ static const struct file_operations acpi_system_event_ops = { | |||
110 | #endif /* CONFIG_ACPI_PROC_EVENT */ | 110 | #endif /* CONFIG_ACPI_PROC_EVENT */ |
111 | 111 | ||
112 | /* ACPI notifier chain */ | 112 | /* ACPI notifier chain */ |
113 | BLOCKING_NOTIFIER_HEAD(acpi_chain_head); | 113 | static BLOCKING_NOTIFIER_HEAD(acpi_chain_head); |
114 | 114 | ||
115 | int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data) | 115 | int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data) |
116 | { | 116 | { |
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c index 2e9ce94798c7..3f51b7e84a17 100644 --- a/drivers/acpi/executer/exregion.c +++ b/drivers/acpi/executer/exregion.c | |||
@@ -338,6 +338,7 @@ acpi_ex_pci_config_space_handler(u32 function, | |||
338 | acpi_status status = AE_OK; | 338 | acpi_status status = AE_OK; |
339 | struct acpi_pci_id *pci_id; | 339 | struct acpi_pci_id *pci_id; |
340 | u16 pci_register; | 340 | u16 pci_register; |
341 | u32 value32; | ||
341 | 342 | ||
342 | ACPI_FUNCTION_TRACE(ex_pci_config_space_handler); | 343 | ACPI_FUNCTION_TRACE(ex_pci_config_space_handler); |
343 | 344 | ||
@@ -364,9 +365,9 @@ acpi_ex_pci_config_space_handler(u32 function, | |||
364 | switch (function) { | 365 | switch (function) { |
365 | case ACPI_READ: | 366 | case ACPI_READ: |
366 | 367 | ||
367 | *value = 0; | ||
368 | status = acpi_os_read_pci_configuration(pci_id, pci_register, | 368 | status = acpi_os_read_pci_configuration(pci_id, pci_register, |
369 | value, bit_width); | 369 | &value32, bit_width); |
370 | *value = value32; | ||
370 | break; | 371 | break; |
371 | 372 | ||
372 | case ACPI_WRITE: | 373 | case ACPI_WRITE: |
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 48cb705b274a..c8e3cba423ef 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -256,22 +256,28 @@ static int acpi_fan_add(struct acpi_device *device) | |||
256 | 256 | ||
257 | cdev = thermal_cooling_device_register("Fan", device, | 257 | cdev = thermal_cooling_device_register("Fan", device, |
258 | &fan_cooling_ops); | 258 | &fan_cooling_ops); |
259 | if (cdev) | 259 | if (IS_ERR(cdev)) { |
260 | result = PTR_ERR(cdev); | ||
261 | goto end; | ||
262 | } | ||
263 | if (cdev) { | ||
260 | printk(KERN_INFO PREFIX | 264 | printk(KERN_INFO PREFIX |
261 | "%s is registered as cooling_device%d\n", | 265 | "%s is registered as cooling_device%d\n", |
262 | device->dev.bus_id, cdev->id); | 266 | device->dev.bus_id, cdev->id); |
263 | else | ||
264 | goto end; | ||
265 | acpi_driver_data(device) = cdev; | ||
266 | result = sysfs_create_link(&device->dev.kobj, &cdev->device.kobj, | ||
267 | "thermal_cooling"); | ||
268 | if (result) | ||
269 | return result; | ||
270 | 267 | ||
271 | result = sysfs_create_link(&cdev->device.kobj, &device->dev.kobj, | 268 | acpi_driver_data(device) = cdev; |
272 | "device"); | 269 | result = sysfs_create_link(&device->dev.kobj, |
273 | if (result) | 270 | &cdev->device.kobj, |
274 | return result; | 271 | "thermal_cooling"); |
272 | if (result) | ||
273 | return result; | ||
274 | |||
275 | result = sysfs_create_link(&cdev->device.kobj, | ||
276 | &device->dev.kobj, | ||
277 | "device"); | ||
278 | if (result) | ||
279 | return result; | ||
280 | } | ||
275 | 281 | ||
276 | result = acpi_fan_add_fs(device); | 282 | result = acpi_fan_add_fs(device); |
277 | if (result) | 283 | if (result) |
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index 058d0be5cbe2..4290e0193097 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c | |||
@@ -616,6 +616,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state) | |||
616 | return_ACPI_STATUS(status); | 616 | return_ACPI_STATUS(status); |
617 | } | 617 | } |
618 | 618 | ||
619 | arg.integer.value = sleep_state; | ||
619 | status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); | 620 | status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); |
620 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | 621 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
621 | ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK")); | 622 | ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK")); |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 34b3386dedca..8edba7b678eb 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -325,7 +325,7 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val, | |||
325 | } | 325 | } |
326 | 326 | ||
327 | #ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD | 327 | #ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD |
328 | struct acpi_table_header *acpi_find_dsdt_initrd(void) | 328 | static struct acpi_table_header *acpi_find_dsdt_initrd(void) |
329 | { | 329 | { |
330 | struct file *firmware_file; | 330 | struct file *firmware_file; |
331 | mm_segment_t oldfs; | 331 | mm_segment_t oldfs; |
@@ -419,7 +419,7 @@ acpi_os_table_override(struct acpi_table_header * existing_table, | |||
419 | } | 419 | } |
420 | 420 | ||
421 | #ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD | 421 | #ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD |
422 | int __init acpi_no_initrd_override_setup(char *s) | 422 | static int __init acpi_no_initrd_override_setup(char *s) |
423 | { | 423 | { |
424 | acpi_no_initrd_override = 1; | 424 | acpi_no_initrd_override = 1; |
425 | return 1; | 425 | return 1; |
@@ -623,7 +623,7 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) | |||
623 | 623 | ||
624 | acpi_status | 624 | acpi_status |
625 | acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, | 625 | acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
626 | void *value, u32 width) | 626 | u32 *value, u32 width) |
627 | { | 627 | { |
628 | int result, size; | 628 | int result, size; |
629 | 629 | ||
@@ -689,7 +689,6 @@ static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ | |||
689 | acpi_status status; | 689 | acpi_status status; |
690 | unsigned long temp; | 690 | unsigned long temp; |
691 | acpi_object_type type; | 691 | acpi_object_type type; |
692 | u8 tu8; | ||
693 | 692 | ||
694 | acpi_get_parent(chandle, &handle); | 693 | acpi_get_parent(chandle, &handle); |
695 | if (handle != rhandle) { | 694 | if (handle != rhandle) { |
@@ -704,6 +703,7 @@ static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ | |||
704 | acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, | 703 | acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, |
705 | &temp); | 704 | &temp); |
706 | if (ACPI_SUCCESS(status)) { | 705 | if (ACPI_SUCCESS(status)) { |
706 | u32 val; | ||
707 | pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp)); | 707 | pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp)); |
708 | pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp)); | 708 | pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp)); |
709 | 709 | ||
@@ -712,24 +712,24 @@ static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ | |||
712 | 712 | ||
713 | /* any nicer way to get bus number of bridge ? */ | 713 | /* any nicer way to get bus number of bridge ? */ |
714 | status = | 714 | status = |
715 | acpi_os_read_pci_configuration(pci_id, 0x0e, &tu8, | 715 | acpi_os_read_pci_configuration(pci_id, 0x0e, &val, |
716 | 8); | 716 | 8); |
717 | if (ACPI_SUCCESS(status) | 717 | if (ACPI_SUCCESS(status) |
718 | && ((tu8 & 0x7f) == 1 || (tu8 & 0x7f) == 2)) { | 718 | && ((val & 0x7f) == 1 || (val & 0x7f) == 2)) { |
719 | status = | 719 | status = |
720 | acpi_os_read_pci_configuration(pci_id, 0x18, | 720 | acpi_os_read_pci_configuration(pci_id, 0x18, |
721 | &tu8, 8); | 721 | &val, 8); |
722 | if (!ACPI_SUCCESS(status)) { | 722 | if (!ACPI_SUCCESS(status)) { |
723 | /* Certainly broken... FIX ME */ | 723 | /* Certainly broken... FIX ME */ |
724 | return; | 724 | return; |
725 | } | 725 | } |
726 | *is_bridge = 1; | 726 | *is_bridge = 1; |
727 | pci_id->bus = tu8; | 727 | pci_id->bus = val; |
728 | status = | 728 | status = |
729 | acpi_os_read_pci_configuration(pci_id, 0x19, | 729 | acpi_os_read_pci_configuration(pci_id, 0x19, |
730 | &tu8, 8); | 730 | &val, 8); |
731 | if (ACPI_SUCCESS(status)) { | 731 | if (ACPI_SUCCESS(status)) { |
732 | *bus_number = tu8; | 732 | *bus_number = val; |
733 | } | 733 | } |
734 | } else | 734 | } else |
735 | *is_bridge = 0; | 735 | *is_bridge = 0; |
@@ -1109,7 +1109,7 @@ void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) | |||
1109 | * string starting with '!' disables that string | 1109 | * string starting with '!' disables that string |
1110 | * otherwise string is added to list, augmenting built-in strings | 1110 | * otherwise string is added to list, augmenting built-in strings |
1111 | */ | 1111 | */ |
1112 | static int __init acpi_osi_setup(char *str) | 1112 | int __init acpi_osi_setup(char *str) |
1113 | { | 1113 | { |
1114 | if (str == NULL || *str == '\0') { | 1114 | if (str == NULL || *str == '\0') { |
1115 | printk(KERN_INFO PREFIX "_OSI method disabled\n"); | 1115 | printk(KERN_INFO PREFIX "_OSI method disabled\n"); |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 75ccf5d18bf4..a3cc8a98255c 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -670,21 +670,26 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) | |||
670 | 670 | ||
671 | pr->cdev = thermal_cooling_device_register("Processor", device, | 671 | pr->cdev = thermal_cooling_device_register("Processor", device, |
672 | &processor_cooling_ops); | 672 | &processor_cooling_ops); |
673 | if (pr->cdev) | 673 | if (IS_ERR(pr->cdev)) { |
674 | result = PTR_ERR(pr->cdev); | ||
675 | goto end; | ||
676 | } | ||
677 | if (pr->cdev) { | ||
674 | printk(KERN_INFO PREFIX | 678 | printk(KERN_INFO PREFIX |
675 | "%s is registered as cooling_device%d\n", | 679 | "%s is registered as cooling_device%d\n", |
676 | device->dev.bus_id, pr->cdev->id); | 680 | device->dev.bus_id, pr->cdev->id); |
677 | else | ||
678 | goto end; | ||
679 | 681 | ||
680 | result = sysfs_create_link(&device->dev.kobj, &pr->cdev->device.kobj, | 682 | result = sysfs_create_link(&device->dev.kobj, |
681 | "thermal_cooling"); | 683 | &pr->cdev->device.kobj, |
682 | if (result) | 684 | "thermal_cooling"); |
683 | return result; | 685 | if (result) |
684 | result = sysfs_create_link(&pr->cdev->device.kobj, &device->dev.kobj, | 686 | return result; |
685 | "device"); | 687 | result = sysfs_create_link(&pr->cdev->device.kobj, |
686 | if (result) | 688 | &device->dev.kobj, |
687 | return result; | 689 | "device"); |
690 | if (result) | ||
691 | return result; | ||
692 | } | ||
688 | 693 | ||
689 | if (pr->flags.throttling) { | 694 | if (pr->flags.throttling) { |
690 | printk(KERN_INFO PREFIX "%s [%s] (supports", | 695 | printk(KERN_INFO PREFIX "%s [%s] (supports", |
@@ -809,10 +814,12 @@ static int acpi_processor_remove(struct acpi_device *device, int type) | |||
809 | 814 | ||
810 | acpi_processor_remove_fs(device); | 815 | acpi_processor_remove_fs(device); |
811 | 816 | ||
812 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | 817 | if (pr->cdev) { |
813 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); | 818 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); |
814 | thermal_cooling_device_unregister(pr->cdev); | 819 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); |
815 | pr->cdev = NULL; | 820 | thermal_cooling_device_unregister(pr->cdev); |
821 | pr->cdev = NULL; | ||
822 | } | ||
816 | 823 | ||
817 | processors[pr->id] = NULL; | 824 | processors[pr->id] = NULL; |
818 | 825 | ||
@@ -826,8 +833,6 @@ static int acpi_processor_remove(struct acpi_device *device, int type) | |||
826 | * Acpi processor hotplug support * | 833 | * Acpi processor hotplug support * |
827 | ****************************************************************************/ | 834 | ****************************************************************************/ |
828 | 835 | ||
829 | static int is_processor_present(acpi_handle handle); | ||
830 | |||
831 | static int is_processor_present(acpi_handle handle) | 836 | static int is_processor_present(acpi_handle handle) |
832 | { | 837 | { |
833 | acpi_status status; | 838 | acpi_status status; |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 32003fdc91e8..6f3b217699e9 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -364,7 +364,7 @@ int acpi_processor_resume(struct acpi_device * device) | |||
364 | return 0; | 364 | return 0; |
365 | } | 365 | } |
366 | 366 | ||
367 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) | 367 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) |
368 | static int tsc_halts_in_c(int state) | 368 | static int tsc_halts_in_c(int state) |
369 | { | 369 | { |
370 | switch (boot_cpu_data.x86_vendor) { | 370 | switch (boot_cpu_data.x86_vendor) { |
@@ -544,7 +544,7 @@ static void acpi_processor_idle(void) | |||
544 | /* Get end time (ticks) */ | 544 | /* Get end time (ticks) */ |
545 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 545 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
546 | 546 | ||
547 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) | 547 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) |
548 | /* TSC halts in C2, so notify users */ | 548 | /* TSC halts in C2, so notify users */ |
549 | if (tsc_halts_in_c(ACPI_STATE_C2)) | 549 | if (tsc_halts_in_c(ACPI_STATE_C2)) |
550 | mark_tsc_unstable("possible TSC halt in C2"); | 550 | mark_tsc_unstable("possible TSC halt in C2"); |
@@ -609,7 +609,7 @@ static void acpi_processor_idle(void) | |||
609 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); | 609 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); |
610 | } | 610 | } |
611 | 611 | ||
612 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) | 612 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) |
613 | /* TSC halts in C3, so notify users */ | 613 | /* TSC halts in C3, so notify users */ |
614 | if (tsc_halts_in_c(ACPI_STATE_C3)) | 614 | if (tsc_halts_in_c(ACPI_STATE_C3)) |
615 | mark_tsc_unstable("TSC halts in C3"); | 615 | mark_tsc_unstable("TSC halts in C3"); |
@@ -945,11 +945,16 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) | |||
945 | * Otherwise, ignore this info and continue. | 945 | * Otherwise, ignore this info and continue. |
946 | */ | 946 | */ |
947 | cx.entry_method = ACPI_CSTATE_HALT; | 947 | cx.entry_method = ACPI_CSTATE_HALT; |
948 | snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT"); | ||
948 | } else { | 949 | } else { |
949 | continue; | 950 | continue; |
950 | } | 951 | } |
952 | } else { | ||
953 | snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x", | ||
954 | cx.address); | ||
951 | } | 955 | } |
952 | 956 | ||
957 | |||
953 | obj = &(element->package.elements[2]); | 958 | obj = &(element->package.elements[2]); |
954 | if (obj->type != ACPI_TYPE_INTEGER) | 959 | if (obj->type != ACPI_TYPE_INTEGER) |
955 | continue; | 960 | continue; |
@@ -1420,6 +1425,14 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, | |||
1420 | return 0; | 1425 | return 0; |
1421 | 1426 | ||
1422 | local_irq_disable(); | 1427 | local_irq_disable(); |
1428 | |||
1429 | /* Do not access any ACPI IO ports in suspend path */ | ||
1430 | if (acpi_idle_suspend) { | ||
1431 | acpi_safe_halt(); | ||
1432 | local_irq_enable(); | ||
1433 | return 0; | ||
1434 | } | ||
1435 | |||
1423 | if (pr->flags.bm_check) | 1436 | if (pr->flags.bm_check) |
1424 | acpi_idle_update_bm_rld(pr, cx); | 1437 | acpi_idle_update_bm_rld(pr, cx); |
1425 | 1438 | ||
@@ -1487,7 +1500,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
1487 | acpi_idle_do_entry(cx); | 1500 | acpi_idle_do_entry(cx); |
1488 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 1501 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
1489 | 1502 | ||
1490 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) | 1503 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) |
1491 | /* TSC could halt in idle, so notify users */ | 1504 | /* TSC could halt in idle, so notify users */ |
1492 | if (tsc_halts_in_c(cx->type)) | 1505 | if (tsc_halts_in_c(cx->type)) |
1493 | mark_tsc_unstable("TSC halts in idle");; | 1506 | mark_tsc_unstable("TSC halts in idle");; |
@@ -1601,7 +1614,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
1601 | spin_unlock(&c3_lock); | 1614 | spin_unlock(&c3_lock); |
1602 | } | 1615 | } |
1603 | 1616 | ||
1604 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) | 1617 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) |
1605 | /* TSC could halt in idle, so notify users */ | 1618 | /* TSC could halt in idle, so notify users */ |
1606 | if (tsc_halts_in_c(ACPI_STATE_C3)) | 1619 | if (tsc_halts_in_c(ACPI_STATE_C3)) |
1607 | mark_tsc_unstable("TSC halts in idle"); | 1620 | mark_tsc_unstable("TSC halts in idle"); |
@@ -1643,6 +1656,11 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
1643 | return -EINVAL; | 1656 | return -EINVAL; |
1644 | } | 1657 | } |
1645 | 1658 | ||
1659 | for (i = 0; i < CPUIDLE_STATE_MAX; i++) { | ||
1660 | dev->states[i].name[0] = '\0'; | ||
1661 | dev->states[i].desc[0] = '\0'; | ||
1662 | } | ||
1663 | |||
1646 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { | 1664 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { |
1647 | cx = &pr->power.states[i]; | 1665 | cx = &pr->power.states[i]; |
1648 | state = &dev->states[count]; | 1666 | state = &dev->states[count]; |
@@ -1659,6 +1677,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
1659 | cpuidle_set_statedata(state, cx); | 1677 | cpuidle_set_statedata(state, cx); |
1660 | 1678 | ||
1661 | snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); | 1679 | snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); |
1680 | strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN); | ||
1662 | state->exit_latency = cx->latency; | 1681 | state->exit_latency = cx->latency; |
1663 | state->target_residency = cx->latency * latency_factor; | 1682 | state->target_residency = cx->latency * latency_factor; |
1664 | state->power_usage = cx->power; | 1683 | state->power_usage = cx->power; |
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 34f157571080..eba55b7d6c95 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
@@ -36,16 +36,20 @@ ACPI_MODULE_NAME("utils"); | |||
36 | /* -------------------------------------------------------------------------- | 36 | /* -------------------------------------------------------------------------- |
37 | Object Evaluation Helpers | 37 | Object Evaluation Helpers |
38 | -------------------------------------------------------------------------- */ | 38 | -------------------------------------------------------------------------- */ |
39 | static void | ||
40 | acpi_util_eval_error(acpi_handle h, acpi_string p, acpi_status s) | ||
41 | { | ||
39 | #ifdef ACPI_DEBUG_OUTPUT | 42 | #ifdef ACPI_DEBUG_OUTPUT |
40 | #define acpi_util_eval_error(h,p,s) {\ | 43 | char prefix[80] = {'\0'}; |
41 | char prefix[80] = {'\0'};\ | 44 | struct acpi_buffer buffer = {sizeof(prefix), prefix}; |
42 | struct acpi_buffer buffer = {sizeof(prefix), prefix};\ | 45 | acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer); |
43 | acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\ | 46 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n", |
44 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",\ | 47 | (char *) prefix, p, acpi_format_exception(s))); |
45 | (char *) prefix, p, acpi_format_exception(s))); } | ||
46 | #else | 48 | #else |
47 | #define acpi_util_eval_error(h,p,s) | 49 | return; |
48 | #endif | 50 | #endif |
51 | } | ||
52 | |||
49 | acpi_status | 53 | acpi_status |
50 | acpi_extract_package(union acpi_object *package, | 54 | acpi_extract_package(union acpi_object *package, |
51 | struct acpi_buffer *format, struct acpi_buffer *buffer) | 55 | struct acpi_buffer *format, struct acpi_buffer *buffer) |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 7f714fa2a454..12cce69b5441 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -731,6 +731,9 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
731 | 731 | ||
732 | device->cdev = thermal_cooling_device_register("LCD", | 732 | device->cdev = thermal_cooling_device_register("LCD", |
733 | device->dev, &video_cooling_ops); | 733 | device->dev, &video_cooling_ops); |
734 | if (IS_ERR(device->cdev)) | ||
735 | return; | ||
736 | |||
734 | if (device->cdev) { | 737 | if (device->cdev) { |
735 | printk(KERN_INFO PREFIX | 738 | printk(KERN_INFO PREFIX |
736 | "%s is registered as cooling_device%d\n", | 739 | "%s is registered as cooling_device%d\n", |
diff --git a/drivers/acpi/wmi.c b/drivers/acpi/wmi.c index 457ed3d3f51c..efacc9f8bfe3 100644 --- a/drivers/acpi/wmi.c +++ b/drivers/acpi/wmi.c | |||
@@ -247,7 +247,7 @@ u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out) | |||
247 | block = &wblock->gblock; | 247 | block = &wblock->gblock; |
248 | handle = wblock->handle; | 248 | handle = wblock->handle; |
249 | 249 | ||
250 | if (!block->flags & ACPI_WMI_METHOD) | 250 | if (!(block->flags & ACPI_WMI_METHOD)) |
251 | return AE_BAD_DATA; | 251 | return AE_BAD_DATA; |
252 | 252 | ||
253 | if (block->instance_count < instance) | 253 | if (block->instance_count < instance) |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 29e71bddd6ff..6dd12f7019a0 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -1932,7 +1932,7 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
1932 | void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; | 1932 | void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; |
1933 | u32 ctl; | 1933 | u32 ctl; |
1934 | 1934 | ||
1935 | if (mesg.event == PM_EVENT_SUSPEND) { | 1935 | if (mesg.event & PM_EVENT_SLEEP) { |
1936 | /* AHCI spec rev1.1 section 8.3.3: | 1936 | /* AHCI spec rev1.1 section 8.3.3: |
1937 | * Software must disable interrupts prior to requesting a | 1937 | * Software must disable interrupts prior to requesting a |
1938 | * transition of the HBA to D3 state. | 1938 | * transition of the HBA to D3 state. |
@@ -1975,16 +1975,11 @@ static int ahci_port_start(struct ata_port *ap) | |||
1975 | struct ahci_port_priv *pp; | 1975 | struct ahci_port_priv *pp; |
1976 | void *mem; | 1976 | void *mem; |
1977 | dma_addr_t mem_dma; | 1977 | dma_addr_t mem_dma; |
1978 | int rc; | ||
1979 | 1978 | ||
1980 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); | 1979 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
1981 | if (!pp) | 1980 | if (!pp) |
1982 | return -ENOMEM; | 1981 | return -ENOMEM; |
1983 | 1982 | ||
1984 | rc = ata_pad_alloc(ap, dev); | ||
1985 | if (rc) | ||
1986 | return rc; | ||
1987 | |||
1988 | mem = dmam_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, | 1983 | mem = dmam_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, |
1989 | GFP_KERNEL); | 1984 | GFP_KERNEL); |
1990 | if (!mem) | 1985 | if (!mem) |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 9c2515f67de5..fae8404254c0 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -1339,7 +1339,7 @@ static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
1339 | * cycles and power trying to do something to the sleeping | 1339 | * cycles and power trying to do something to the sleeping |
1340 | * beauty. | 1340 | * beauty. |
1341 | */ | 1341 | */ |
1342 | if (piix_broken_suspend() && mesg.event == PM_EVENT_SUSPEND) { | 1342 | if (piix_broken_suspend() && (mesg.event & PM_EVENT_SLEEP)) { |
1343 | pci_save_state(pdev); | 1343 | pci_save_state(pdev); |
1344 | 1344 | ||
1345 | /* mark its power state as "unknown", since we don't | 1345 | /* mark its power state as "unknown", since we don't |
@@ -1652,7 +1652,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev, | |||
1652 | u8 tmp; | 1652 | u8 tmp; |
1653 | pci_read_config_byte(pdev, PIIX_SCC, &tmp); | 1653 | pci_read_config_byte(pdev, PIIX_SCC, &tmp); |
1654 | if (tmp == PIIX_AHCI_DEVICE) { | 1654 | if (tmp == PIIX_AHCI_DEVICE) { |
1655 | int rc = piix_disable_ahci(pdev); | 1655 | rc = piix_disable_ahci(pdev); |
1656 | if (rc) | 1656 | if (rc) |
1657 | return rc; | 1657 | return rc; |
1658 | } | 1658 | } |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 004dae4ea5bc..4cf8662df99e 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -87,6 +87,28 @@ static struct workqueue_struct *ata_wq; | |||
87 | 87 | ||
88 | struct workqueue_struct *ata_aux_wq; | 88 | struct workqueue_struct *ata_aux_wq; |
89 | 89 | ||
90 | struct ata_force_param { | ||
91 | const char *name; | ||
92 | unsigned int cbl; | ||
93 | int spd_limit; | ||
94 | unsigned long xfer_mask; | ||
95 | unsigned int horkage_on; | ||
96 | unsigned int horkage_off; | ||
97 | }; | ||
98 | |||
99 | struct ata_force_ent { | ||
100 | int port; | ||
101 | int device; | ||
102 | struct ata_force_param param; | ||
103 | }; | ||
104 | |||
105 | static struct ata_force_ent *ata_force_tbl; | ||
106 | static int ata_force_tbl_size; | ||
107 | |||
108 | static char ata_force_param_buf[PAGE_SIZE] __initdata; | ||
109 | module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0444); | ||
110 | MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)"); | ||
111 | |||
90 | int atapi_enabled = 1; | 112 | int atapi_enabled = 1; |
91 | module_param(atapi_enabled, int, 0444); | 113 | module_param(atapi_enabled, int, 0444); |
92 | MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); | 114 | MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); |
@@ -130,6 +152,179 @@ MODULE_VERSION(DRV_VERSION); | |||
130 | 152 | ||
131 | 153 | ||
132 | /** | 154 | /** |
155 | * ata_force_cbl - force cable type according to libata.force | ||
156 | * @link: ATA link of interest | ||
157 | * | ||
158 | * Force cable type according to libata.force and whine about it. | ||
159 | * The last entry which has matching port number is used, so it | ||
160 | * can be specified as part of device force parameters. For | ||
161 | * example, both "a:40c,1.00:udma4" and "1.00:40c,udma4" have the | ||
162 | * same effect. | ||
163 | * | ||
164 | * LOCKING: | ||
165 | * EH context. | ||
166 | */ | ||
167 | void ata_force_cbl(struct ata_port *ap) | ||
168 | { | ||
169 | int i; | ||
170 | |||
171 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { | ||
172 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | ||
173 | |||
174 | if (fe->port != -1 && fe->port != ap->print_id) | ||
175 | continue; | ||
176 | |||
177 | if (fe->param.cbl == ATA_CBL_NONE) | ||
178 | continue; | ||
179 | |||
180 | ap->cbl = fe->param.cbl; | ||
181 | ata_port_printk(ap, KERN_NOTICE, | ||
182 | "FORCE: cable set to %s\n", fe->param.name); | ||
183 | return; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * ata_force_spd_limit - force SATA spd limit according to libata.force | ||
189 | * @link: ATA link of interest | ||
190 | * | ||
191 | * Force SATA spd limit according to libata.force and whine about | ||
192 | * it. When only the port part is specified (e.g. 1:), the limit | ||
193 | * applies to all links connected to both the host link and all | ||
194 | * fan-out ports connected via PMP. If the device part is | ||
195 | * specified as 0 (e.g. 1.00:), it specifies the first fan-out | ||
196 | * link not the host link. Device number 15 always points to the | ||
197 | * host link whether PMP is attached or not. | ||
198 | * | ||
199 | * LOCKING: | ||
200 | * EH context. | ||
201 | */ | ||
202 | static void ata_force_spd_limit(struct ata_link *link) | ||
203 | { | ||
204 | int linkno, i; | ||
205 | |||
206 | if (ata_is_host_link(link)) | ||
207 | linkno = 15; | ||
208 | else | ||
209 | linkno = link->pmp; | ||
210 | |||
211 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { | ||
212 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | ||
213 | |||
214 | if (fe->port != -1 && fe->port != link->ap->print_id) | ||
215 | continue; | ||
216 | |||
217 | if (fe->device != -1 && fe->device != linkno) | ||
218 | continue; | ||
219 | |||
220 | if (!fe->param.spd_limit) | ||
221 | continue; | ||
222 | |||
223 | link->hw_sata_spd_limit = (1 << fe->param.spd_limit) - 1; | ||
224 | ata_link_printk(link, KERN_NOTICE, | ||
225 | "FORCE: PHY spd limit set to %s\n", fe->param.name); | ||
226 | return; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * ata_force_xfermask - force xfermask according to libata.force | ||
232 | * @dev: ATA device of interest | ||
233 | * | ||
234 | * Force xfer_mask according to libata.force and whine about it. | ||
235 | * For consistency with link selection, device number 15 selects | ||
236 | * the first device connected to the host link. | ||
237 | * | ||
238 | * LOCKING: | ||
239 | * EH context. | ||
240 | */ | ||
241 | static void ata_force_xfermask(struct ata_device *dev) | ||
242 | { | ||
243 | int devno = dev->link->pmp + dev->devno; | ||
244 | int alt_devno = devno; | ||
245 | int i; | ||
246 | |||
247 | /* allow n.15 for the first device attached to host port */ | ||
248 | if (ata_is_host_link(dev->link) && devno == 0) | ||
249 | alt_devno = 15; | ||
250 | |||
251 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { | ||
252 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | ||
253 | unsigned long pio_mask, mwdma_mask, udma_mask; | ||
254 | |||
255 | if (fe->port != -1 && fe->port != dev->link->ap->print_id) | ||
256 | continue; | ||
257 | |||
258 | if (fe->device != -1 && fe->device != devno && | ||
259 | fe->device != alt_devno) | ||
260 | continue; | ||
261 | |||
262 | if (!fe->param.xfer_mask) | ||
263 | continue; | ||
264 | |||
265 | ata_unpack_xfermask(fe->param.xfer_mask, | ||
266 | &pio_mask, &mwdma_mask, &udma_mask); | ||
267 | if (udma_mask) | ||
268 | dev->udma_mask = udma_mask; | ||
269 | else if (mwdma_mask) { | ||
270 | dev->udma_mask = 0; | ||
271 | dev->mwdma_mask = mwdma_mask; | ||
272 | } else { | ||
273 | dev->udma_mask = 0; | ||
274 | dev->mwdma_mask = 0; | ||
275 | dev->pio_mask = pio_mask; | ||
276 | } | ||
277 | |||
278 | ata_dev_printk(dev, KERN_NOTICE, | ||
279 | "FORCE: xfer_mask set to %s\n", fe->param.name); | ||
280 | return; | ||
281 | } | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * ata_force_horkage - force horkage according to libata.force | ||
286 | * @dev: ATA device of interest | ||
287 | * | ||
288 | * Force horkage according to libata.force and whine about it. | ||
289 | * For consistency with link selection, device number 15 selects | ||
290 | * the first device connected to the host link. | ||
291 | * | ||
292 | * LOCKING: | ||
293 | * EH context. | ||
294 | */ | ||
295 | static void ata_force_horkage(struct ata_device *dev) | ||
296 | { | ||
297 | int devno = dev->link->pmp + dev->devno; | ||
298 | int alt_devno = devno; | ||
299 | int i; | ||
300 | |||
301 | /* allow n.15 for the first device attached to host port */ | ||
302 | if (ata_is_host_link(dev->link) && devno == 0) | ||
303 | alt_devno = 15; | ||
304 | |||
305 | for (i = 0; i < ata_force_tbl_size; i++) { | ||
306 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | ||
307 | |||
308 | if (fe->port != -1 && fe->port != dev->link->ap->print_id) | ||
309 | continue; | ||
310 | |||
311 | if (fe->device != -1 && fe->device != devno && | ||
312 | fe->device != alt_devno) | ||
313 | continue; | ||
314 | |||
315 | if (!(~dev->horkage & fe->param.horkage_on) && | ||
316 | !(dev->horkage & fe->param.horkage_off)) | ||
317 | continue; | ||
318 | |||
319 | dev->horkage |= fe->param.horkage_on; | ||
320 | dev->horkage &= ~fe->param.horkage_off; | ||
321 | |||
322 | ata_dev_printk(dev, KERN_NOTICE, | ||
323 | "FORCE: horkage modified (%s)\n", fe->param.name); | ||
324 | } | ||
325 | } | ||
326 | |||
327 | /** | ||
133 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure | 328 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure |
134 | * @tf: Taskfile to convert | 329 | * @tf: Taskfile to convert |
135 | * @pmp: Port multiplier port | 330 | * @pmp: Port multiplier port |
@@ -2067,6 +2262,7 @@ int ata_dev_configure(struct ata_device *dev) | |||
2067 | 2262 | ||
2068 | /* set horkage */ | 2263 | /* set horkage */ |
2069 | dev->horkage |= ata_dev_blacklisted(dev); | 2264 | dev->horkage |= ata_dev_blacklisted(dev); |
2265 | ata_force_horkage(dev); | ||
2070 | 2266 | ||
2071 | /* let ACPI work its magic */ | 2267 | /* let ACPI work its magic */ |
2072 | rc = ata_acpi_on_devcfg(dev); | 2268 | rc = ata_acpi_on_devcfg(dev); |
@@ -3150,6 +3346,7 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) | |||
3150 | mode_mask = ATA_DMA_MASK_CFA; | 3346 | mode_mask = ATA_DMA_MASK_CFA; |
3151 | 3347 | ||
3152 | ata_dev_xfermask(dev); | 3348 | ata_dev_xfermask(dev); |
3349 | ata_force_xfermask(dev); | ||
3153 | 3350 | ||
3154 | pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); | 3351 | pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); |
3155 | dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); | 3352 | dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); |
@@ -4190,6 +4387,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
4190 | /* Devices which report 1 sector over size HPA */ | 4387 | /* Devices which report 1 sector over size HPA */ |
4191 | { "ST340823A", NULL, ATA_HORKAGE_HPA_SIZE, }, | 4388 | { "ST340823A", NULL, ATA_HORKAGE_HPA_SIZE, }, |
4192 | { "ST320413A", NULL, ATA_HORKAGE_HPA_SIZE, }, | 4389 | { "ST320413A", NULL, ATA_HORKAGE_HPA_SIZE, }, |
4390 | { "ST310211A", NULL, ATA_HORKAGE_HPA_SIZE, }, | ||
4193 | 4391 | ||
4194 | /* Devices which get the IVB wrong */ | 4392 | /* Devices which get the IVB wrong */ |
4195 | { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB, }, | 4393 | { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB, }, |
@@ -4492,30 +4690,13 @@ void ata_sg_clean(struct ata_queued_cmd *qc) | |||
4492 | struct ata_port *ap = qc->ap; | 4690 | struct ata_port *ap = qc->ap; |
4493 | struct scatterlist *sg = qc->sg; | 4691 | struct scatterlist *sg = qc->sg; |
4494 | int dir = qc->dma_dir; | 4692 | int dir = qc->dma_dir; |
4495 | void *pad_buf = NULL; | ||
4496 | 4693 | ||
4497 | WARN_ON(sg == NULL); | 4694 | WARN_ON(sg == NULL); |
4498 | 4695 | ||
4499 | VPRINTK("unmapping %u sg elements\n", qc->mapped_n_elem); | 4696 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); |
4500 | 4697 | ||
4501 | /* if we padded the buffer out to 32-bit bound, and data | 4698 | if (qc->n_elem) |
4502 | * xfer direction is from-device, we must copy from the | 4699 | dma_unmap_sg(ap->dev, sg, qc->n_elem, dir); |
4503 | * pad buffer back into the supplied buffer | ||
4504 | */ | ||
4505 | if (qc->pad_len && !(qc->tf.flags & ATA_TFLAG_WRITE)) | ||
4506 | pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); | ||
4507 | |||
4508 | if (qc->mapped_n_elem) | ||
4509 | dma_unmap_sg(ap->dev, sg, qc->mapped_n_elem, dir); | ||
4510 | /* restore last sg */ | ||
4511 | if (qc->last_sg) | ||
4512 | *qc->last_sg = qc->saved_last_sg; | ||
4513 | if (pad_buf) { | ||
4514 | struct scatterlist *psg = &qc->extra_sg[1]; | ||
4515 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); | ||
4516 | memcpy(addr + psg->offset, pad_buf, qc->pad_len); | ||
4517 | kunmap_atomic(addr, KM_IRQ0); | ||
4518 | } | ||
4519 | 4700 | ||
4520 | qc->flags &= ~ATA_QCFLAG_DMAMAP; | 4701 | qc->flags &= ~ATA_QCFLAG_DMAMAP; |
4521 | qc->sg = NULL; | 4702 | qc->sg = NULL; |
@@ -4658,43 +4839,6 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc) | |||
4658 | } | 4839 | } |
4659 | 4840 | ||
4660 | /** | 4841 | /** |
4661 | * atapi_qc_may_overflow - Check whether data transfer may overflow | ||
4662 | * @qc: ATA command in question | ||
4663 | * | ||
4664 | * ATAPI commands which transfer variable length data to host | ||
4665 | * might overflow due to application error or hardare bug. This | ||
4666 | * function checks whether overflow should be drained and ignored | ||
4667 | * for @qc. | ||
4668 | * | ||
4669 | * LOCKING: | ||
4670 | * None. | ||
4671 | * | ||
4672 | * RETURNS: | ||
4673 | * 1 if @qc may overflow; otherwise, 0. | ||
4674 | */ | ||
4675 | static int atapi_qc_may_overflow(struct ata_queued_cmd *qc) | ||
4676 | { | ||
4677 | if (qc->tf.protocol != ATAPI_PROT_PIO && | ||
4678 | qc->tf.protocol != ATAPI_PROT_DMA) | ||
4679 | return 0; | ||
4680 | |||
4681 | if (qc->tf.flags & ATA_TFLAG_WRITE) | ||
4682 | return 0; | ||
4683 | |||
4684 | switch (qc->cdb[0]) { | ||
4685 | case READ_10: | ||
4686 | case READ_12: | ||
4687 | case WRITE_10: | ||
4688 | case WRITE_12: | ||
4689 | case GPCMD_READ_CD: | ||
4690 | case GPCMD_READ_CD_MSF: | ||
4691 | return 0; | ||
4692 | } | ||
4693 | |||
4694 | return 1; | ||
4695 | } | ||
4696 | |||
4697 | /** | ||
4698 | * ata_std_qc_defer - Check whether a qc needs to be deferred | 4842 | * ata_std_qc_defer - Check whether a qc needs to be deferred |
4699 | * @qc: ATA command in question | 4843 | * @qc: ATA command in question |
4700 | * | 4844 | * |
@@ -4781,97 +4925,6 @@ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | |||
4781 | qc->cursg = qc->sg; | 4925 | qc->cursg = qc->sg; |
4782 | } | 4926 | } |
4783 | 4927 | ||
4784 | static unsigned int ata_sg_setup_extra(struct ata_queued_cmd *qc, | ||
4785 | unsigned int *n_elem_extra, | ||
4786 | unsigned int *nbytes_extra) | ||
4787 | { | ||
4788 | struct ata_port *ap = qc->ap; | ||
4789 | unsigned int n_elem = qc->n_elem; | ||
4790 | struct scatterlist *lsg, *copy_lsg = NULL, *tsg = NULL, *esg = NULL; | ||
4791 | |||
4792 | *n_elem_extra = 0; | ||
4793 | *nbytes_extra = 0; | ||
4794 | |||
4795 | /* needs padding? */ | ||
4796 | qc->pad_len = qc->nbytes & 3; | ||
4797 | |||
4798 | if (likely(!qc->pad_len)) | ||
4799 | return n_elem; | ||
4800 | |||
4801 | /* locate last sg and save it */ | ||
4802 | lsg = sg_last(qc->sg, n_elem); | ||
4803 | qc->last_sg = lsg; | ||
4804 | qc->saved_last_sg = *lsg; | ||
4805 | |||
4806 | sg_init_table(qc->extra_sg, ARRAY_SIZE(qc->extra_sg)); | ||
4807 | |||
4808 | if (qc->pad_len) { | ||
4809 | struct scatterlist *psg = &qc->extra_sg[1]; | ||
4810 | void *pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); | ||
4811 | unsigned int offset; | ||
4812 | |||
4813 | WARN_ON(qc->dev->class != ATA_DEV_ATAPI); | ||
4814 | |||
4815 | memset(pad_buf, 0, ATA_DMA_PAD_SZ); | ||
4816 | |||
4817 | /* psg->page/offset are used to copy to-be-written | ||
4818 | * data in this function or read data in ata_sg_clean. | ||
4819 | */ | ||
4820 | offset = lsg->offset + lsg->length - qc->pad_len; | ||
4821 | sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT), | ||
4822 | qc->pad_len, offset_in_page(offset)); | ||
4823 | |||
4824 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | ||
4825 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); | ||
4826 | memcpy(pad_buf, addr + psg->offset, qc->pad_len); | ||
4827 | kunmap_atomic(addr, KM_IRQ0); | ||
4828 | } | ||
4829 | |||
4830 | sg_dma_address(psg) = ap->pad_dma + (qc->tag * ATA_DMA_PAD_SZ); | ||
4831 | sg_dma_len(psg) = ATA_DMA_PAD_SZ; | ||
4832 | |||
4833 | /* Trim the last sg entry and chain the original and | ||
4834 | * padding sg lists. | ||
4835 | * | ||
4836 | * Because chaining consumes one sg entry, one extra | ||
4837 | * sg entry is allocated and the last sg entry is | ||
4838 | * copied to it if the length isn't zero after padded | ||
4839 | * amount is removed. | ||
4840 | * | ||
4841 | * If the last sg entry is completely replaced by | ||
4842 | * padding sg entry, the first sg entry is skipped | ||
4843 | * while chaining. | ||
4844 | */ | ||
4845 | lsg->length -= qc->pad_len; | ||
4846 | if (lsg->length) { | ||
4847 | copy_lsg = &qc->extra_sg[0]; | ||
4848 | tsg = &qc->extra_sg[0]; | ||
4849 | } else { | ||
4850 | n_elem--; | ||
4851 | tsg = &qc->extra_sg[1]; | ||
4852 | } | ||
4853 | |||
4854 | esg = &qc->extra_sg[1]; | ||
4855 | |||
4856 | (*n_elem_extra)++; | ||
4857 | (*nbytes_extra) += 4 - qc->pad_len; | ||
4858 | } | ||
4859 | |||
4860 | if (copy_lsg) | ||
4861 | sg_set_page(copy_lsg, sg_page(lsg), lsg->length, lsg->offset); | ||
4862 | |||
4863 | sg_chain(lsg, 1, tsg); | ||
4864 | sg_mark_end(esg); | ||
4865 | |||
4866 | /* sglist can't start with chaining sg entry, fast forward */ | ||
4867 | if (qc->sg == lsg) { | ||
4868 | qc->sg = tsg; | ||
4869 | qc->cursg = tsg; | ||
4870 | } | ||
4871 | |||
4872 | return n_elem; | ||
4873 | } | ||
4874 | |||
4875 | /** | 4928 | /** |
4876 | * ata_sg_setup - DMA-map the scatter-gather table associated with a command. | 4929 | * ata_sg_setup - DMA-map the scatter-gather table associated with a command. |
4877 | * @qc: Command with scatter-gather table to be mapped. | 4930 | * @qc: Command with scatter-gather table to be mapped. |
@@ -4888,26 +4941,17 @@ static unsigned int ata_sg_setup_extra(struct ata_queued_cmd *qc, | |||
4888 | static int ata_sg_setup(struct ata_queued_cmd *qc) | 4941 | static int ata_sg_setup(struct ata_queued_cmd *qc) |
4889 | { | 4942 | { |
4890 | struct ata_port *ap = qc->ap; | 4943 | struct ata_port *ap = qc->ap; |
4891 | unsigned int n_elem, n_elem_extra, nbytes_extra; | 4944 | unsigned int n_elem; |
4892 | 4945 | ||
4893 | VPRINTK("ENTER, ata%u\n", ap->print_id); | 4946 | VPRINTK("ENTER, ata%u\n", ap->print_id); |
4894 | 4947 | ||
4895 | n_elem = ata_sg_setup_extra(qc, &n_elem_extra, &nbytes_extra); | 4948 | n_elem = dma_map_sg(ap->dev, qc->sg, qc->n_elem, qc->dma_dir); |
4949 | if (n_elem < 1) | ||
4950 | return -1; | ||
4896 | 4951 | ||
4897 | if (n_elem) { | 4952 | DPRINTK("%d sg elements mapped\n", n_elem); |
4898 | n_elem = dma_map_sg(ap->dev, qc->sg, n_elem, qc->dma_dir); | ||
4899 | if (n_elem < 1) { | ||
4900 | /* restore last sg */ | ||
4901 | if (qc->last_sg) | ||
4902 | *qc->last_sg = qc->saved_last_sg; | ||
4903 | return -1; | ||
4904 | } | ||
4905 | DPRINTK("%d sg elements mapped\n", n_elem); | ||
4906 | } | ||
4907 | 4953 | ||
4908 | qc->n_elem = qc->mapped_n_elem = n_elem; | 4954 | qc->n_elem = n_elem; |
4909 | qc->n_elem += n_elem_extra; | ||
4910 | qc->nbytes += nbytes_extra; | ||
4911 | qc->flags |= ATA_QCFLAG_DMAMAP; | 4955 | qc->flags |= ATA_QCFLAG_DMAMAP; |
4912 | 4956 | ||
4913 | return 0; | 4957 | return 0; |
@@ -5145,46 +5189,22 @@ static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
5145 | */ | 5189 | */ |
5146 | static int __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) | 5190 | static int __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) |
5147 | { | 5191 | { |
5148 | int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); | 5192 | int rw = (qc->tf.flags & ATA_TFLAG_WRITE) ? WRITE : READ; |
5149 | struct ata_port *ap = qc->ap; | 5193 | struct ata_port *ap = qc->ap; |
5150 | struct ata_eh_info *ehi = &qc->dev->link->eh_info; | 5194 | struct ata_device *dev = qc->dev; |
5195 | struct ata_eh_info *ehi = &dev->link->eh_info; | ||
5151 | struct scatterlist *sg; | 5196 | struct scatterlist *sg; |
5152 | struct page *page; | 5197 | struct page *page; |
5153 | unsigned char *buf; | 5198 | unsigned char *buf; |
5154 | unsigned int offset, count; | 5199 | unsigned int offset, count, consumed; |
5155 | 5200 | ||
5156 | next_sg: | 5201 | next_sg: |
5157 | sg = qc->cursg; | 5202 | sg = qc->cursg; |
5158 | if (unlikely(!sg)) { | 5203 | if (unlikely(!sg)) { |
5159 | /* | 5204 | ata_ehi_push_desc(ehi, "unexpected or too much trailing data " |
5160 | * The end of qc->sg is reached and the device expects | 5205 | "buf=%u cur=%u bytes=%u", |
5161 | * more data to transfer. In order not to overrun qc->sg | 5206 | qc->nbytes, qc->curbytes, bytes); |
5162 | * and fulfill length specified in the byte count register, | 5207 | return -1; |
5163 | * - for read case, discard trailing data from the device | ||
5164 | * - for write case, padding zero data to the device | ||
5165 | */ | ||
5166 | u16 pad_buf[1] = { 0 }; | ||
5167 | unsigned int i; | ||
5168 | |||
5169 | if (bytes > qc->curbytes - qc->nbytes + ATAPI_MAX_DRAIN) { | ||
5170 | ata_ehi_push_desc(ehi, "too much trailing data " | ||
5171 | "buf=%u cur=%u bytes=%u", | ||
5172 | qc->nbytes, qc->curbytes, bytes); | ||
5173 | return -1; | ||
5174 | } | ||
5175 | |||
5176 | /* overflow is exptected for misc ATAPI commands */ | ||
5177 | if (bytes && !atapi_qc_may_overflow(qc)) | ||
5178 | ata_dev_printk(qc->dev, KERN_WARNING, "ATAPI %u bytes " | ||
5179 | "trailing data (cdb=%02x nbytes=%u)\n", | ||
5180 | bytes, qc->cdb[0], qc->nbytes); | ||
5181 | |||
5182 | for (i = 0; i < (bytes + 1) / 2; i++) | ||
5183 | ap->ops->data_xfer(qc->dev, (unsigned char *)pad_buf, 2, do_write); | ||
5184 | |||
5185 | qc->curbytes += bytes; | ||
5186 | |||
5187 | return 0; | ||
5188 | } | 5208 | } |
5189 | 5209 | ||
5190 | page = sg_page(sg); | 5210 | page = sg_page(sg); |
@@ -5210,18 +5230,16 @@ next_sg: | |||
5210 | buf = kmap_atomic(page, KM_IRQ0); | 5230 | buf = kmap_atomic(page, KM_IRQ0); |
5211 | 5231 | ||
5212 | /* do the actual data transfer */ | 5232 | /* do the actual data transfer */ |
5213 | ap->ops->data_xfer(qc->dev, buf + offset, count, do_write); | 5233 | consumed = ap->ops->data_xfer(dev, buf + offset, count, rw); |
5214 | 5234 | ||
5215 | kunmap_atomic(buf, KM_IRQ0); | 5235 | kunmap_atomic(buf, KM_IRQ0); |
5216 | local_irq_restore(flags); | 5236 | local_irq_restore(flags); |
5217 | } else { | 5237 | } else { |
5218 | buf = page_address(page); | 5238 | buf = page_address(page); |
5219 | ap->ops->data_xfer(qc->dev, buf + offset, count, do_write); | 5239 | consumed = ap->ops->data_xfer(dev, buf + offset, count, rw); |
5220 | } | 5240 | } |
5221 | 5241 | ||
5222 | bytes -= count; | 5242 | bytes -= min(bytes, consumed); |
5223 | if ((count & 1) && bytes) | ||
5224 | bytes--; | ||
5225 | qc->curbytes += count; | 5243 | qc->curbytes += count; |
5226 | qc->cursg_ofs += count; | 5244 | qc->cursg_ofs += count; |
5227 | 5245 | ||
@@ -5230,9 +5248,11 @@ next_sg: | |||
5230 | qc->cursg_ofs = 0; | 5248 | qc->cursg_ofs = 0; |
5231 | } | 5249 | } |
5232 | 5250 | ||
5251 | /* consumed can be larger than count only for the last transfer */ | ||
5252 | WARN_ON(qc->cursg && count != consumed); | ||
5253 | |||
5233 | if (bytes) | 5254 | if (bytes) |
5234 | goto next_sg; | 5255 | goto next_sg; |
5235 | |||
5236 | return 0; | 5256 | return 0; |
5237 | } | 5257 | } |
5238 | 5258 | ||
@@ -5250,6 +5270,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) | |||
5250 | { | 5270 | { |
5251 | struct ata_port *ap = qc->ap; | 5271 | struct ata_port *ap = qc->ap; |
5252 | struct ata_device *dev = qc->dev; | 5272 | struct ata_device *dev = qc->dev; |
5273 | struct ata_eh_info *ehi = &dev->link->eh_info; | ||
5253 | unsigned int ireason, bc_lo, bc_hi, bytes; | 5274 | unsigned int ireason, bc_lo, bc_hi, bytes; |
5254 | int i_write, do_write = (qc->tf.flags & ATA_TFLAG_WRITE) ? 1 : 0; | 5275 | int i_write, do_write = (qc->tf.flags & ATA_TFLAG_WRITE) ? 1 : 0; |
5255 | 5276 | ||
@@ -5267,26 +5288,28 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) | |||
5267 | 5288 | ||
5268 | /* shall be cleared to zero, indicating xfer of data */ | 5289 | /* shall be cleared to zero, indicating xfer of data */ |
5269 | if (unlikely(ireason & (1 << 0))) | 5290 | if (unlikely(ireason & (1 << 0))) |
5270 | goto err_out; | 5291 | goto atapi_check; |
5271 | 5292 | ||
5272 | /* make sure transfer direction matches expected */ | 5293 | /* make sure transfer direction matches expected */ |
5273 | i_write = ((ireason & (1 << 1)) == 0) ? 1 : 0; | 5294 | i_write = ((ireason & (1 << 1)) == 0) ? 1 : 0; |
5274 | if (unlikely(do_write != i_write)) | 5295 | if (unlikely(do_write != i_write)) |
5275 | goto err_out; | 5296 | goto atapi_check; |
5276 | 5297 | ||
5277 | if (unlikely(!bytes)) | 5298 | if (unlikely(!bytes)) |
5278 | goto err_out; | 5299 | goto atapi_check; |
5279 | 5300 | ||
5280 | VPRINTK("ata%u: xfering %d bytes\n", ap->print_id, bytes); | 5301 | VPRINTK("ata%u: xfering %d bytes\n", ap->print_id, bytes); |
5281 | 5302 | ||
5282 | if (__atapi_pio_bytes(qc, bytes)) | 5303 | if (unlikely(__atapi_pio_bytes(qc, bytes))) |
5283 | goto err_out; | 5304 | goto err_out; |
5284 | ata_altstatus(ap); /* flush */ | 5305 | ata_altstatus(ap); /* flush */ |
5285 | 5306 | ||
5286 | return; | 5307 | return; |
5287 | 5308 | ||
5288 | err_out: | 5309 | atapi_check: |
5289 | ata_dev_printk(dev, KERN_INFO, "ATAPI check failed\n"); | 5310 | ata_ehi_push_desc(ehi, "ATAPI check failed (ireason=0x%x bytes=%u)", |
5311 | ireason, bytes); | ||
5312 | err_out: | ||
5290 | qc->err_mask |= AC_ERR_HSM; | 5313 | qc->err_mask |= AC_ERR_HSM; |
5291 | ap->hsm_task_state = HSM_ST_ERR; | 5314 | ap->hsm_task_state = HSM_ST_ERR; |
5292 | } | 5315 | } |
@@ -5971,9 +5994,6 @@ void ata_qc_issue(struct ata_queued_cmd *qc) | |||
5971 | */ | 5994 | */ |
5972 | BUG_ON(ata_is_data(prot) && (!qc->sg || !qc->n_elem || !qc->nbytes)); | 5995 | BUG_ON(ata_is_data(prot) && (!qc->sg || !qc->n_elem || !qc->nbytes)); |
5973 | 5996 | ||
5974 | /* ata_sg_setup() may update nbytes */ | ||
5975 | qc->raw_nbytes = qc->nbytes; | ||
5976 | |||
5977 | if (ata_is_dma(prot) || (ata_is_pio(prot) && | 5997 | if (ata_is_dma(prot) || (ata_is_pio(prot) && |
5978 | (ap->flags & ATA_FLAG_PIO_DMA))) | 5998 | (ap->flags & ATA_FLAG_PIO_DMA))) |
5979 | if (ata_sg_setup(qc)) | 5999 | if (ata_sg_setup(qc)) |
@@ -6582,19 +6602,12 @@ void ata_host_resume(struct ata_host *host) | |||
6582 | int ata_port_start(struct ata_port *ap) | 6602 | int ata_port_start(struct ata_port *ap) |
6583 | { | 6603 | { |
6584 | struct device *dev = ap->dev; | 6604 | struct device *dev = ap->dev; |
6585 | int rc; | ||
6586 | 6605 | ||
6587 | ap->prd = dmam_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma, | 6606 | ap->prd = dmam_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma, |
6588 | GFP_KERNEL); | 6607 | GFP_KERNEL); |
6589 | if (!ap->prd) | 6608 | if (!ap->prd) |
6590 | return -ENOMEM; | 6609 | return -ENOMEM; |
6591 | 6610 | ||
6592 | rc = ata_pad_alloc(ap, dev); | ||
6593 | if (rc) | ||
6594 | return rc; | ||
6595 | |||
6596 | DPRINTK("prd alloc, virt %p, dma %llx\n", ap->prd, | ||
6597 | (unsigned long long)ap->prd_dma); | ||
6598 | return 0; | 6611 | return 0; |
6599 | } | 6612 | } |
6600 | 6613 | ||
@@ -6681,7 +6694,8 @@ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp) | |||
6681 | */ | 6694 | */ |
6682 | int sata_link_init_spd(struct ata_link *link) | 6695 | int sata_link_init_spd(struct ata_link *link) |
6683 | { | 6696 | { |
6684 | u32 scontrol, spd; | 6697 | u32 scontrol; |
6698 | u8 spd; | ||
6685 | int rc; | 6699 | int rc; |
6686 | 6700 | ||
6687 | rc = sata_scr_read(link, SCR_CONTROL, &scontrol); | 6701 | rc = sata_scr_read(link, SCR_CONTROL, &scontrol); |
@@ -6692,6 +6706,8 @@ int sata_link_init_spd(struct ata_link *link) | |||
6692 | if (spd) | 6706 | if (spd) |
6693 | link->hw_sata_spd_limit &= (1 << spd) - 1; | 6707 | link->hw_sata_spd_limit &= (1 << spd) - 1; |
6694 | 6708 | ||
6709 | ata_force_spd_limit(link); | ||
6710 | |||
6695 | link->sata_spd_limit = link->hw_sata_spd_limit; | 6711 | link->sata_spd_limit = link->hw_sata_spd_limit; |
6696 | 6712 | ||
6697 | return 0; | 6713 | return 0; |
@@ -7086,7 +7102,6 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
7086 | DPRINTK("probe begin\n"); | 7102 | DPRINTK("probe begin\n"); |
7087 | for (i = 0; i < host->n_ports; i++) { | 7103 | for (i = 0; i < host->n_ports; i++) { |
7088 | struct ata_port *ap = host->ports[i]; | 7104 | struct ata_port *ap = host->ports[i]; |
7089 | int rc; | ||
7090 | 7105 | ||
7091 | /* probe */ | 7106 | /* probe */ |
7092 | if (ap->ops->error_handler) { | 7107 | if (ap->ops->error_handler) { |
@@ -7353,7 +7368,7 @@ void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
7353 | pci_save_state(pdev); | 7368 | pci_save_state(pdev); |
7354 | pci_disable_device(pdev); | 7369 | pci_disable_device(pdev); |
7355 | 7370 | ||
7356 | if (mesg.event == PM_EVENT_SUSPEND) | 7371 | if (mesg.event & PM_EVENT_SLEEP) |
7357 | pci_set_power_state(pdev, PCI_D3hot); | 7372 | pci_set_power_state(pdev, PCI_D3hot); |
7358 | } | 7373 | } |
7359 | 7374 | ||
@@ -7403,10 +7418,187 @@ int ata_pci_device_resume(struct pci_dev *pdev) | |||
7403 | 7418 | ||
7404 | #endif /* CONFIG_PCI */ | 7419 | #endif /* CONFIG_PCI */ |
7405 | 7420 | ||
7421 | static int __init ata_parse_force_one(char **cur, | ||
7422 | struct ata_force_ent *force_ent, | ||
7423 | const char **reason) | ||
7424 | { | ||
7425 | /* FIXME: Currently, there's no way to tag init const data and | ||
7426 | * using __initdata causes build failure on some versions of | ||
7427 | * gcc. Once __initdataconst is implemented, add const to the | ||
7428 | * following structure. | ||
7429 | */ | ||
7430 | static struct ata_force_param force_tbl[] __initdata = { | ||
7431 | { "40c", .cbl = ATA_CBL_PATA40 }, | ||
7432 | { "80c", .cbl = ATA_CBL_PATA80 }, | ||
7433 | { "short40c", .cbl = ATA_CBL_PATA40_SHORT }, | ||
7434 | { "unk", .cbl = ATA_CBL_PATA_UNK }, | ||
7435 | { "ign", .cbl = ATA_CBL_PATA_IGN }, | ||
7436 | { "sata", .cbl = ATA_CBL_SATA }, | ||
7437 | { "1.5Gbps", .spd_limit = 1 }, | ||
7438 | { "3.0Gbps", .spd_limit = 2 }, | ||
7439 | { "noncq", .horkage_on = ATA_HORKAGE_NONCQ }, | ||
7440 | { "ncq", .horkage_off = ATA_HORKAGE_NONCQ }, | ||
7441 | { "pio0", .xfer_mask = 1 << (ATA_SHIFT_PIO + 0) }, | ||
7442 | { "pio1", .xfer_mask = 1 << (ATA_SHIFT_PIO + 1) }, | ||
7443 | { "pio2", .xfer_mask = 1 << (ATA_SHIFT_PIO + 2) }, | ||
7444 | { "pio3", .xfer_mask = 1 << (ATA_SHIFT_PIO + 3) }, | ||
7445 | { "pio4", .xfer_mask = 1 << (ATA_SHIFT_PIO + 4) }, | ||
7446 | { "pio5", .xfer_mask = 1 << (ATA_SHIFT_PIO + 5) }, | ||
7447 | { "pio6", .xfer_mask = 1 << (ATA_SHIFT_PIO + 6) }, | ||
7448 | { "mwdma0", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 0) }, | ||
7449 | { "mwdma1", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 1) }, | ||
7450 | { "mwdma2", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 2) }, | ||
7451 | { "mwdma3", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 3) }, | ||
7452 | { "mwdma4", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 4) }, | ||
7453 | { "udma0", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) }, | ||
7454 | { "udma16", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) }, | ||
7455 | { "udma/16", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) }, | ||
7456 | { "udma1", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) }, | ||
7457 | { "udma25", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) }, | ||
7458 | { "udma/25", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) }, | ||
7459 | { "udma2", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) }, | ||
7460 | { "udma33", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) }, | ||
7461 | { "udma/33", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) }, | ||
7462 | { "udma3", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) }, | ||
7463 | { "udma44", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) }, | ||
7464 | { "udma/44", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) }, | ||
7465 | { "udma4", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) }, | ||
7466 | { "udma66", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) }, | ||
7467 | { "udma/66", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) }, | ||
7468 | { "udma5", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) }, | ||
7469 | { "udma100", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) }, | ||
7470 | { "udma/100", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) }, | ||
7471 | { "udma6", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) }, | ||
7472 | { "udma133", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) }, | ||
7473 | { "udma/133", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) }, | ||
7474 | { "udma7", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 7) }, | ||
7475 | }; | ||
7476 | char *start = *cur, *p = *cur; | ||
7477 | char *id, *val, *endp; | ||
7478 | const struct ata_force_param *match_fp = NULL; | ||
7479 | int nr_matches = 0, i; | ||
7480 | |||
7481 | /* find where this param ends and update *cur */ | ||
7482 | while (*p != '\0' && *p != ',') | ||
7483 | p++; | ||
7484 | |||
7485 | if (*p == '\0') | ||
7486 | *cur = p; | ||
7487 | else | ||
7488 | *cur = p + 1; | ||
7489 | |||
7490 | *p = '\0'; | ||
7491 | |||
7492 | /* parse */ | ||
7493 | p = strchr(start, ':'); | ||
7494 | if (!p) { | ||
7495 | val = strstrip(start); | ||
7496 | goto parse_val; | ||
7497 | } | ||
7498 | *p = '\0'; | ||
7499 | |||
7500 | id = strstrip(start); | ||
7501 | val = strstrip(p + 1); | ||
7502 | |||
7503 | /* parse id */ | ||
7504 | p = strchr(id, '.'); | ||
7505 | if (p) { | ||
7506 | *p++ = '\0'; | ||
7507 | force_ent->device = simple_strtoul(p, &endp, 10); | ||
7508 | if (p == endp || *endp != '\0') { | ||
7509 | *reason = "invalid device"; | ||
7510 | return -EINVAL; | ||
7511 | } | ||
7512 | } | ||
7513 | |||
7514 | force_ent->port = simple_strtoul(id, &endp, 10); | ||
7515 | if (p == endp || *endp != '\0') { | ||
7516 | *reason = "invalid port/link"; | ||
7517 | return -EINVAL; | ||
7518 | } | ||
7519 | |||
7520 | parse_val: | ||
7521 | /* parse val, allow shortcuts so that both 1.5 and 1.5Gbps work */ | ||
7522 | for (i = 0; i < ARRAY_SIZE(force_tbl); i++) { | ||
7523 | const struct ata_force_param *fp = &force_tbl[i]; | ||
7524 | |||
7525 | if (strncasecmp(val, fp->name, strlen(val))) | ||
7526 | continue; | ||
7527 | |||
7528 | nr_matches++; | ||
7529 | match_fp = fp; | ||
7530 | |||
7531 | if (strcasecmp(val, fp->name) == 0) { | ||
7532 | nr_matches = 1; | ||
7533 | break; | ||
7534 | } | ||
7535 | } | ||
7536 | |||
7537 | if (!nr_matches) { | ||
7538 | *reason = "unknown value"; | ||
7539 | return -EINVAL; | ||
7540 | } | ||
7541 | if (nr_matches > 1) { | ||
7542 | *reason = "ambigious value"; | ||
7543 | return -EINVAL; | ||
7544 | } | ||
7545 | |||
7546 | force_ent->param = *match_fp; | ||
7547 | |||
7548 | return 0; | ||
7549 | } | ||
7550 | |||
7551 | static void __init ata_parse_force_param(void) | ||
7552 | { | ||
7553 | int idx = 0, size = 1; | ||
7554 | int last_port = -1, last_device = -1; | ||
7555 | char *p, *cur, *next; | ||
7556 | |||
7557 | /* calculate maximum number of params and allocate force_tbl */ | ||
7558 | for (p = ata_force_param_buf; *p; p++) | ||
7559 | if (*p == ',') | ||
7560 | size++; | ||
7561 | |||
7562 | ata_force_tbl = kzalloc(sizeof(ata_force_tbl[0]) * size, GFP_KERNEL); | ||
7563 | if (!ata_force_tbl) { | ||
7564 | printk(KERN_WARNING "ata: failed to extend force table, " | ||
7565 | "libata.force ignored\n"); | ||
7566 | return; | ||
7567 | } | ||
7568 | |||
7569 | /* parse and populate the table */ | ||
7570 | for (cur = ata_force_param_buf; *cur != '\0'; cur = next) { | ||
7571 | const char *reason = ""; | ||
7572 | struct ata_force_ent te = { .port = -1, .device = -1 }; | ||
7573 | |||
7574 | next = cur; | ||
7575 | if (ata_parse_force_one(&next, &te, &reason)) { | ||
7576 | printk(KERN_WARNING "ata: failed to parse force " | ||
7577 | "parameter \"%s\" (%s)\n", | ||
7578 | cur, reason); | ||
7579 | continue; | ||
7580 | } | ||
7581 | |||
7582 | if (te.port == -1) { | ||
7583 | te.port = last_port; | ||
7584 | te.device = last_device; | ||
7585 | } | ||
7586 | |||
7587 | ata_force_tbl[idx++] = te; | ||
7588 | |||
7589 | last_port = te.port; | ||
7590 | last_device = te.device; | ||
7591 | } | ||
7592 | |||
7593 | ata_force_tbl_size = idx; | ||
7594 | } | ||
7406 | 7595 | ||
7407 | static int __init ata_init(void) | 7596 | static int __init ata_init(void) |
7408 | { | 7597 | { |
7409 | ata_probe_timeout *= HZ; | 7598 | ata_probe_timeout *= HZ; |
7599 | |||
7600 | ata_parse_force_param(); | ||
7601 | |||
7410 | ata_wq = create_workqueue("ata"); | 7602 | ata_wq = create_workqueue("ata"); |
7411 | if (!ata_wq) | 7603 | if (!ata_wq) |
7412 | return -ENOMEM; | 7604 | return -ENOMEM; |
@@ -7423,6 +7615,7 @@ static int __init ata_init(void) | |||
7423 | 7615 | ||
7424 | static void __exit ata_exit(void) | 7616 | static void __exit ata_exit(void) |
7425 | { | 7617 | { |
7618 | kfree(ata_force_tbl); | ||
7426 | destroy_workqueue(ata_wq); | 7619 | destroy_workqueue(ata_wq); |
7427 | destroy_workqueue(ata_aux_wq); | 7620 | destroy_workqueue(ata_aux_wq); |
7428 | } | 7621 | } |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 4e31071acc02..698ce2cea52c 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -2393,9 +2393,11 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link, | |||
2393 | } | 2393 | } |
2394 | 2394 | ||
2395 | /* PDIAG- should have been released, ask cable type if post-reset */ | 2395 | /* PDIAG- should have been released, ask cable type if post-reset */ |
2396 | if (ata_is_host_link(link) && ap->ops->cable_detect && | 2396 | if ((ehc->i.flags & ATA_EHI_DID_RESET) && ata_is_host_link(link)) { |
2397 | (ehc->i.flags & ATA_EHI_DID_RESET)) | 2397 | if (ap->ops->cable_detect) |
2398 | ap->cbl = ap->ops->cable_detect(ap); | 2398 | ap->cbl = ap->ops->cable_detect(ap); |
2399 | ata_force_cbl(ap); | ||
2400 | } | ||
2399 | 2401 | ||
2400 | /* Configure new devices forward such that user doesn't see | 2402 | /* Configure new devices forward such that user doesn't see |
2401 | * device detection messages backwards. | 2403 | * device detection messages backwards. |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index c02c490122dc..f888babc8283 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -826,30 +826,61 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev) | |||
826 | sdev->max_device_blocked = 1; | 826 | sdev->max_device_blocked = 1; |
827 | } | 827 | } |
828 | 828 | ||
829 | static void ata_scsi_dev_config(struct scsi_device *sdev, | 829 | /** |
830 | struct ata_device *dev) | 830 | * atapi_drain_needed - Check whether data transfer may overflow |
831 | * @rq: request to be checked | ||
832 | * | ||
833 | * ATAPI commands which transfer variable length data to host | ||
834 | * might overflow due to application error or hardare bug. This | ||
835 | * function checks whether overflow should be drained and ignored | ||
836 | * for @request. | ||
837 | * | ||
838 | * LOCKING: | ||
839 | * None. | ||
840 | * | ||
841 | * RETURNS: | ||
842 | * 1 if ; otherwise, 0. | ||
843 | */ | ||
844 | static int atapi_drain_needed(struct request *rq) | ||
845 | { | ||
846 | if (likely(!blk_pc_request(rq))) | ||
847 | return 0; | ||
848 | |||
849 | if (!rq->data_len || (rq->cmd_flags & REQ_RW)) | ||
850 | return 0; | ||
851 | |||
852 | return atapi_cmd_type(rq->cmd[0]) == ATAPI_MISC; | ||
853 | } | ||
854 | |||
855 | static int ata_scsi_dev_config(struct scsi_device *sdev, | ||
856 | struct ata_device *dev) | ||
831 | { | 857 | { |
832 | /* configure max sectors */ | 858 | /* configure max sectors */ |
833 | blk_queue_max_sectors(sdev->request_queue, dev->max_sectors); | 859 | blk_queue_max_sectors(sdev->request_queue, dev->max_sectors); |
834 | 860 | ||
835 | /* SATA DMA transfers must be multiples of 4 byte, so | ||
836 | * we need to pad ATAPI transfers using an extra sg. | ||
837 | * Decrement max hw segments accordingly. | ||
838 | */ | ||
839 | if (dev->class == ATA_DEV_ATAPI) { | 861 | if (dev->class == ATA_DEV_ATAPI) { |
840 | struct request_queue *q = sdev->request_queue; | 862 | struct request_queue *q = sdev->request_queue; |
841 | blk_queue_max_hw_segments(q, q->max_hw_segments - 1); | 863 | void *buf; |
842 | 864 | ||
843 | /* set the min alignment */ | 865 | /* set the min alignment */ |
844 | blk_queue_update_dma_alignment(sdev->request_queue, | 866 | blk_queue_update_dma_alignment(sdev->request_queue, |
845 | ATA_DMA_PAD_SZ - 1); | 867 | ATA_DMA_PAD_SZ - 1); |
846 | } else | 868 | |
869 | /* configure draining */ | ||
870 | buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL); | ||
871 | if (!buf) { | ||
872 | ata_dev_printk(dev, KERN_ERR, | ||
873 | "drain buffer allocation failed\n"); | ||
874 | return -ENOMEM; | ||
875 | } | ||
876 | |||
877 | blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN); | ||
878 | } else { | ||
847 | /* ATA devices must be sector aligned */ | 879 | /* ATA devices must be sector aligned */ |
848 | blk_queue_update_dma_alignment(sdev->request_queue, | 880 | blk_queue_update_dma_alignment(sdev->request_queue, |
849 | ATA_SECT_SIZE - 1); | 881 | ATA_SECT_SIZE - 1); |
850 | |||
851 | if (dev->class == ATA_DEV_ATA) | ||
852 | sdev->manage_start_stop = 1; | 882 | sdev->manage_start_stop = 1; |
883 | } | ||
853 | 884 | ||
854 | if (dev->flags & ATA_DFLAG_AN) | 885 | if (dev->flags & ATA_DFLAG_AN) |
855 | set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events); | 886 | set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events); |
@@ -861,6 +892,8 @@ static void ata_scsi_dev_config(struct scsi_device *sdev, | |||
861 | depth = min(ATA_MAX_QUEUE - 1, depth); | 892 | depth = min(ATA_MAX_QUEUE - 1, depth); |
862 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, depth); | 893 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, depth); |
863 | } | 894 | } |
895 | |||
896 | return 0; | ||
864 | } | 897 | } |
865 | 898 | ||
866 | /** | 899 | /** |
@@ -879,13 +912,14 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
879 | { | 912 | { |
880 | struct ata_port *ap = ata_shost_to_port(sdev->host); | 913 | struct ata_port *ap = ata_shost_to_port(sdev->host); |
881 | struct ata_device *dev = __ata_scsi_find_dev(ap, sdev); | 914 | struct ata_device *dev = __ata_scsi_find_dev(ap, sdev); |
915 | int rc = 0; | ||
882 | 916 | ||
883 | ata_scsi_sdev_config(sdev); | 917 | ata_scsi_sdev_config(sdev); |
884 | 918 | ||
885 | if (dev) | 919 | if (dev) |
886 | ata_scsi_dev_config(sdev, dev); | 920 | rc = ata_scsi_dev_config(sdev, dev); |
887 | 921 | ||
888 | return 0; | 922 | return rc; |
889 | } | 923 | } |
890 | 924 | ||
891 | /** | 925 | /** |
@@ -905,6 +939,7 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
905 | void ata_scsi_slave_destroy(struct scsi_device *sdev) | 939 | void ata_scsi_slave_destroy(struct scsi_device *sdev) |
906 | { | 940 | { |
907 | struct ata_port *ap = ata_shost_to_port(sdev->host); | 941 | struct ata_port *ap = ata_shost_to_port(sdev->host); |
942 | struct request_queue *q = sdev->request_queue; | ||
908 | unsigned long flags; | 943 | unsigned long flags; |
909 | struct ata_device *dev; | 944 | struct ata_device *dev; |
910 | 945 | ||
@@ -920,6 +955,10 @@ void ata_scsi_slave_destroy(struct scsi_device *sdev) | |||
920 | ata_port_schedule_eh(ap); | 955 | ata_port_schedule_eh(ap); |
921 | } | 956 | } |
922 | spin_unlock_irqrestore(ap->lock, flags); | 957 | spin_unlock_irqrestore(ap->lock, flags); |
958 | |||
959 | kfree(q->dma_drain_buffer); | ||
960 | q->dma_drain_buffer = NULL; | ||
961 | q->dma_drain_size = 0; | ||
923 | } | 962 | } |
924 | 963 | ||
925 | /** | 964 | /** |
@@ -1862,7 +1901,7 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, | |||
1862 | * spin_lock_irqsave(host lock) | 1901 | * spin_lock_irqsave(host lock) |
1863 | */ | 1902 | */ |
1864 | 1903 | ||
1865 | unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf, | 1904 | static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf, |
1866 | unsigned int buflen) | 1905 | unsigned int buflen) |
1867 | { | 1906 | { |
1868 | u8 pbuf[60]; | 1907 | u8 pbuf[60]; |
@@ -2500,7 +2539,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc) | |||
2500 | * want to set it properly, and for DMA where it is | 2539 | * want to set it properly, and for DMA where it is |
2501 | * effectively meaningless. | 2540 | * effectively meaningless. |
2502 | */ | 2541 | */ |
2503 | nbytes = min(qc->nbytes, (unsigned int)63 * 1024); | 2542 | nbytes = min(scmd->request->raw_data_len, (unsigned int)63 * 1024); |
2504 | 2543 | ||
2505 | /* Most ATAPI devices which honor transfer chunk size don't | 2544 | /* Most ATAPI devices which honor transfer chunk size don't |
2506 | * behave according to the spec when odd chunk size which | 2545 | * behave according to the spec when odd chunk size which |
@@ -3555,7 +3594,7 @@ EXPORT_SYMBOL_GPL(ata_sas_port_alloc); | |||
3555 | * @ap: Port to initialize | 3594 | * @ap: Port to initialize |
3556 | * | 3595 | * |
3557 | * Called just after data structures for each port are | 3596 | * Called just after data structures for each port are |
3558 | * initialized. Allocates DMA pad. | 3597 | * initialized. |
3559 | * | 3598 | * |
3560 | * May be used as the port_start() entry in ata_port_operations. | 3599 | * May be used as the port_start() entry in ata_port_operations. |
3561 | * | 3600 | * |
@@ -3564,7 +3603,7 @@ EXPORT_SYMBOL_GPL(ata_sas_port_alloc); | |||
3564 | */ | 3603 | */ |
3565 | int ata_sas_port_start(struct ata_port *ap) | 3604 | int ata_sas_port_start(struct ata_port *ap) |
3566 | { | 3605 | { |
3567 | return ata_pad_alloc(ap, ap->dev); | 3606 | return 0; |
3568 | } | 3607 | } |
3569 | EXPORT_SYMBOL_GPL(ata_sas_port_start); | 3608 | EXPORT_SYMBOL_GPL(ata_sas_port_start); |
3570 | 3609 | ||
@@ -3572,8 +3611,6 @@ EXPORT_SYMBOL_GPL(ata_sas_port_start); | |||
3572 | * ata_port_stop - Undo ata_sas_port_start() | 3611 | * ata_port_stop - Undo ata_sas_port_start() |
3573 | * @ap: Port to shut down | 3612 | * @ap: Port to shut down |
3574 | * | 3613 | * |
3575 | * Frees the DMA pad. | ||
3576 | * | ||
3577 | * May be used as the port_stop() entry in ata_port_operations. | 3614 | * May be used as the port_stop() entry in ata_port_operations. |
3578 | * | 3615 | * |
3579 | * LOCKING: | 3616 | * LOCKING: |
@@ -3582,7 +3619,6 @@ EXPORT_SYMBOL_GPL(ata_sas_port_start); | |||
3582 | 3619 | ||
3583 | void ata_sas_port_stop(struct ata_port *ap) | 3620 | void ata_sas_port_stop(struct ata_port *ap) |
3584 | { | 3621 | { |
3585 | ata_pad_free(ap, ap->dev); | ||
3586 | } | 3622 | } |
3587 | EXPORT_SYMBOL_GPL(ata_sas_port_stop); | 3623 | EXPORT_SYMBOL_GPL(ata_sas_port_stop); |
3588 | 3624 | ||
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 409ffb9af163..6036dedfe377 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -61,6 +61,7 @@ extern int atapi_passthru16; | |||
61 | extern int libata_fua; | 61 | extern int libata_fua; |
62 | extern int libata_noacpi; | 62 | extern int libata_noacpi; |
63 | extern int libata_allow_tpm; | 63 | extern int libata_allow_tpm; |
64 | extern void ata_force_cbl(struct ata_port *ap); | ||
64 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); | 65 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); |
65 | extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, | 66 | extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, |
66 | u64 block, u32 n_block, unsigned int tf_flags, | 67 | u64 block, u32 n_block, unsigned int tf_flags, |
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c index 244098a80ce4..bdc3b9d7395c 100644 --- a/drivers/ata/pata_acpi.c +++ b/drivers/ata/pata_acpi.c | |||
@@ -77,8 +77,8 @@ static int pacpi_cable_detect(struct ata_port *ap) | |||
77 | 77 | ||
78 | static void pacpi_error_handler(struct ata_port *ap) | 78 | static void pacpi_error_handler(struct ata_port *ap) |
79 | { | 79 | { |
80 | return ata_bmdma_drive_eh(ap, pacpi_pre_reset, ata_std_softreset, | 80 | ata_bmdma_drive_eh(ap, pacpi_pre_reset, ata_std_softreset, NULL, |
81 | NULL, ata_std_postreset); | 81 | ata_std_postreset); |
82 | } | 82 | } |
83 | 83 | ||
84 | /** | 84 | /** |
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c index ea567e2b1703..4b8d9b592ca4 100644 --- a/drivers/ata/pata_amd.c +++ b/drivers/ata/pata_amd.c | |||
@@ -146,9 +146,8 @@ static int amd_pre_reset(struct ata_link *link, unsigned long deadline) | |||
146 | 146 | ||
147 | static void amd_error_handler(struct ata_port *ap) | 147 | static void amd_error_handler(struct ata_port *ap) |
148 | { | 148 | { |
149 | return ata_bmdma_drive_eh(ap, amd_pre_reset, | 149 | ata_bmdma_drive_eh(ap, amd_pre_reset, ata_std_softreset, NULL, |
150 | ata_std_softreset, NULL, | 150 | ata_std_postreset); |
151 | ata_std_postreset); | ||
152 | } | 151 | } |
153 | 152 | ||
154 | static int amd_cable_detect(struct ata_port *ap) | 153 | static int amd_cable_detect(struct ata_port *ap) |
@@ -506,7 +505,6 @@ static struct ata_port_operations amd133_port_ops = { | |||
506 | static struct ata_port_operations nv100_port_ops = { | 505 | static struct ata_port_operations nv100_port_ops = { |
507 | .set_piomode = nv100_set_piomode, | 506 | .set_piomode = nv100_set_piomode, |
508 | .set_dmamode = nv100_set_dmamode, | 507 | .set_dmamode = nv100_set_dmamode, |
509 | .mode_filter = ata_pci_default_filter, | ||
510 | .tf_load = ata_tf_load, | 508 | .tf_load = ata_tf_load, |
511 | .tf_read = ata_tf_read, | 509 | .tf_read = ata_tf_read, |
512 | .check_status = ata_check_status, | 510 | .check_status = ata_check_status, |
@@ -541,7 +539,6 @@ static struct ata_port_operations nv100_port_ops = { | |||
541 | static struct ata_port_operations nv133_port_ops = { | 539 | static struct ata_port_operations nv133_port_ops = { |
542 | .set_piomode = nv133_set_piomode, | 540 | .set_piomode = nv133_set_piomode, |
543 | .set_dmamode = nv133_set_dmamode, | 541 | .set_dmamode = nv133_set_dmamode, |
544 | .mode_filter = ata_pci_default_filter, | ||
545 | .tf_load = ata_tf_load, | 542 | .tf_load = ata_tf_load, |
546 | .tf_read = ata_tf_read, | 543 | .tf_read = ata_tf_read, |
547 | .check_status = ata_check_status, | 544 | .check_status = ata_check_status, |
diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c index d753e568588e..1c4ff9b52b5c 100644 --- a/drivers/ata/pata_cs5536.c +++ b/drivers/ata/pata_cs5536.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <asm/msr.h> | 40 | #include <asm/msr.h> |
41 | 41 | ||
42 | #define DRV_NAME "pata_cs5536" | 42 | #define DRV_NAME "pata_cs5536" |
43 | #define DRV_VERSION "0.0.6" | 43 | #define DRV_VERSION "0.0.7" |
44 | 44 | ||
45 | enum { | 45 | enum { |
46 | CFG = 0, | 46 | CFG = 0, |
@@ -85,7 +85,7 @@ static const u8 pci_reg[4] = { | |||
85 | PCI_IDE_CFG, PCI_IDE_DTC, PCI_IDE_CAST, PCI_IDE_ETC, | 85 | PCI_IDE_CFG, PCI_IDE_DTC, PCI_IDE_CAST, PCI_IDE_ETC, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | static inline int cs5536_read(struct pci_dev *pdev, int reg, int *val) | 88 | static inline int cs5536_read(struct pci_dev *pdev, int reg, u32 *val) |
89 | { | 89 | { |
90 | if (unlikely(use_msr)) { | 90 | if (unlikely(use_msr)) { |
91 | u32 dummy; | 91 | u32 dummy; |
@@ -153,8 +153,8 @@ static void cs5536_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
153 | struct ata_device *pair = ata_dev_pair(adev); | 153 | struct ata_device *pair = ata_dev_pair(adev); |
154 | int mode = adev->pio_mode - XFER_PIO_0; | 154 | int mode = adev->pio_mode - XFER_PIO_0; |
155 | int cmdmode = mode; | 155 | int cmdmode = mode; |
156 | int dshift = ap->port_no ? IDE_D1_SHIFT : IDE_D0_SHIFT; | 156 | int dshift = adev->devno ? IDE_D1_SHIFT : IDE_D0_SHIFT; |
157 | int cshift = ap->port_no ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT; | 157 | int cshift = adev->devno ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT; |
158 | u32 dtc, cast, etc; | 158 | u32 dtc, cast, etc; |
159 | 159 | ||
160 | if (pair) | 160 | if (pair) |
@@ -201,7 +201,7 @@ static void cs5536_set_dmamode(struct ata_port *ap, struct ata_device *adev) | |||
201 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 201 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
202 | u32 dtc, etc; | 202 | u32 dtc, etc; |
203 | int mode = adev->dma_mode; | 203 | int mode = adev->dma_mode; |
204 | int dshift = ap->port_no ? IDE_D1_SHIFT : IDE_D0_SHIFT; | 204 | int dshift = adev->devno ? IDE_D1_SHIFT : IDE_D0_SHIFT; |
205 | 205 | ||
206 | if (mode >= XFER_UDMA_0) { | 206 | if (mode >= XFER_UDMA_0) { |
207 | cs5536_read(pdev, ETC, &etc); | 207 | cs5536_read(pdev, ETC, &etc); |
diff --git a/drivers/ata/pata_icside.c b/drivers/ata/pata_icside.c index 5b8586dac63b..f97068be2d79 100644 --- a/drivers/ata/pata_icside.c +++ b/drivers/ata/pata_icside.c | |||
@@ -304,12 +304,6 @@ static int icside_dma_init(struct pata_icside_info *info) | |||
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | static int pata_icside_port_start(struct ata_port *ap) | ||
308 | { | ||
309 | /* No PRD to alloc */ | ||
310 | return ata_pad_alloc(ap, ap->dev); | ||
311 | } | ||
312 | |||
313 | static struct scsi_host_template pata_icside_sht = { | 307 | static struct scsi_host_template pata_icside_sht = { |
314 | .module = THIS_MODULE, | 308 | .module = THIS_MODULE, |
315 | .name = DRV_NAME, | 309 | .name = DRV_NAME, |
@@ -389,8 +383,6 @@ static struct ata_port_operations pata_icside_port_ops = { | |||
389 | .irq_clear = ata_dummy_noret, | 383 | .irq_clear = ata_dummy_noret, |
390 | .irq_on = ata_irq_on, | 384 | .irq_on = ata_irq_on, |
391 | 385 | ||
392 | .port_start = pata_icside_port_start, | ||
393 | |||
394 | .bmdma_stop = pata_icside_bmdma_stop, | 386 | .bmdma_stop = pata_icside_bmdma_stop, |
395 | .bmdma_status = pata_icside_bmdma_status, | 387 | .bmdma_status = pata_icside_bmdma_status, |
396 | }; | 388 | }; |
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c index 5b8174d94067..00bbbbd50e97 100644 --- a/drivers/ata/pata_jmicron.c +++ b/drivers/ata/pata_jmicron.c | |||
@@ -115,7 +115,8 @@ static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline) | |||
115 | 115 | ||
116 | static void jmicron_error_handler(struct ata_port *ap) | 116 | static void jmicron_error_handler(struct ata_port *ap) |
117 | { | 117 | { |
118 | return ata_bmdma_drive_eh(ap, jmicron_pre_reset, ata_std_softreset, NULL, ata_std_postreset); | 118 | ata_bmdma_drive_eh(ap, jmicron_pre_reset, ata_std_softreset, NULL, |
119 | ata_std_postreset); | ||
119 | } | 120 | } |
120 | 121 | ||
121 | /* No PIO or DMA methods needed for this device */ | 122 | /* No PIO or DMA methods needed for this device */ |
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index 6c59969fd50b..50fe08ebe23c 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c | |||
@@ -774,14 +774,14 @@ static struct ata_port_operations opti82c46x_port_ops = { | |||
774 | static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev) | 774 | static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev) |
775 | { | 775 | { |
776 | struct ata_timing t; | 776 | struct ata_timing t; |
777 | struct legacy_data *qdi = ap->host->private_data; | 777 | struct legacy_data *ld_qdi = ap->host->private_data; |
778 | int active, recovery; | 778 | int active, recovery; |
779 | u8 timing; | 779 | u8 timing; |
780 | 780 | ||
781 | /* Get the timing data in cycles */ | 781 | /* Get the timing data in cycles */ |
782 | ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); | 782 | ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); |
783 | 783 | ||
784 | if (qdi->fast) { | 784 | if (ld_qdi->fast) { |
785 | active = 8 - FIT(t.active, 1, 8); | 785 | active = 8 - FIT(t.active, 1, 8); |
786 | recovery = 18 - FIT(t.recover, 3, 18); | 786 | recovery = 18 - FIT(t.recover, 3, 18); |
787 | } else { | 787 | } else { |
@@ -790,9 +790,9 @@ static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
790 | } | 790 | } |
791 | timing = (recovery << 4) | active | 0x08; | 791 | timing = (recovery << 4) | active | 0x08; |
792 | 792 | ||
793 | qdi->clock[adev->devno] = timing; | 793 | ld_qdi->clock[adev->devno] = timing; |
794 | 794 | ||
795 | outb(timing, qdi->timing); | 795 | outb(timing, ld_qdi->timing); |
796 | } | 796 | } |
797 | 797 | ||
798 | /** | 798 | /** |
@@ -808,14 +808,14 @@ static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
808 | static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev) | 808 | static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev) |
809 | { | 809 | { |
810 | struct ata_timing t; | 810 | struct ata_timing t; |
811 | struct legacy_data *qdi = ap->host->private_data; | 811 | struct legacy_data *ld_qdi = ap->host->private_data; |
812 | int active, recovery; | 812 | int active, recovery; |
813 | u8 timing; | 813 | u8 timing; |
814 | 814 | ||
815 | /* Get the timing data in cycles */ | 815 | /* Get the timing data in cycles */ |
816 | ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); | 816 | ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); |
817 | 817 | ||
818 | if (qdi->fast) { | 818 | if (ld_qdi->fast) { |
819 | active = 8 - FIT(t.active, 1, 8); | 819 | active = 8 - FIT(t.active, 1, 8); |
820 | recovery = 18 - FIT(t.recover, 3, 18); | 820 | recovery = 18 - FIT(t.recover, 3, 18); |
821 | } else { | 821 | } else { |
@@ -824,12 +824,12 @@ static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
824 | } | 824 | } |
825 | timing = (recovery << 4) | active | 0x08; | 825 | timing = (recovery << 4) | active | 0x08; |
826 | 826 | ||
827 | qdi->clock[adev->devno] = timing; | 827 | ld_qdi->clock[adev->devno] = timing; |
828 | 828 | ||
829 | outb(timing, qdi->timing + 2 * ap->port_no); | 829 | outb(timing, ld_qdi->timing + 2 * ap->port_no); |
830 | /* Clear the FIFO */ | 830 | /* Clear the FIFO */ |
831 | if (adev->class != ATA_DEV_ATA) | 831 | if (adev->class != ATA_DEV_ATA) |
832 | outb(0x5F, qdi->timing + 3); | 832 | outb(0x5F, ld_qdi->timing + 3); |
833 | } | 833 | } |
834 | 834 | ||
835 | /** | 835 | /** |
@@ -845,14 +845,14 @@ static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
845 | static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev) | 845 | static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev) |
846 | { | 846 | { |
847 | struct ata_timing t; | 847 | struct ata_timing t; |
848 | struct legacy_data *qdi = ap->host->private_data; | 848 | struct legacy_data *ld_qdi = ap->host->private_data; |
849 | int active, recovery; | 849 | int active, recovery; |
850 | u8 timing; | 850 | u8 timing; |
851 | 851 | ||
852 | /* Get the timing data in cycles */ | 852 | /* Get the timing data in cycles */ |
853 | ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); | 853 | ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); |
854 | 854 | ||
855 | if (qdi->fast) { | 855 | if (ld_qdi->fast) { |
856 | active = 8 - FIT(t.active, 1, 8); | 856 | active = 8 - FIT(t.active, 1, 8); |
857 | recovery = 18 - FIT(t.recover, 3, 18); | 857 | recovery = 18 - FIT(t.recover, 3, 18); |
858 | } else { | 858 | } else { |
@@ -860,11 +860,11 @@ static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
860 | recovery = 15 - FIT(t.recover, 0, 15); | 860 | recovery = 15 - FIT(t.recover, 0, 15); |
861 | } | 861 | } |
862 | timing = (recovery << 4) | active | 0x08; | 862 | timing = (recovery << 4) | active | 0x08; |
863 | qdi->clock[adev->devno] = timing; | 863 | ld_qdi->clock[adev->devno] = timing; |
864 | outb(timing, qdi->timing + 2 * adev->devno); | 864 | outb(timing, ld_qdi->timing + 2 * adev->devno); |
865 | /* Clear the FIFO */ | 865 | /* Clear the FIFO */ |
866 | if (adev->class != ATA_DEV_ATA) | 866 | if (adev->class != ATA_DEV_ATA) |
867 | outb(0x5F, qdi->timing + 3); | 867 | outb(0x5F, ld_qdi->timing + 3); |
868 | } | 868 | } |
869 | 869 | ||
870 | /** | 870 | /** |
@@ -879,12 +879,12 @@ static unsigned int qdi_qc_issue_prot(struct ata_queued_cmd *qc) | |||
879 | { | 879 | { |
880 | struct ata_port *ap = qc->ap; | 880 | struct ata_port *ap = qc->ap; |
881 | struct ata_device *adev = qc->dev; | 881 | struct ata_device *adev = qc->dev; |
882 | struct legacy_data *qdi = ap->host->private_data; | 882 | struct legacy_data *ld_qdi = ap->host->private_data; |
883 | 883 | ||
884 | if (qdi->clock[adev->devno] != qdi->last) { | 884 | if (ld_qdi->clock[adev->devno] != ld_qdi->last) { |
885 | if (adev->pio_mode) { | 885 | if (adev->pio_mode) { |
886 | qdi->last = qdi->clock[adev->devno]; | 886 | ld_qdi->last = ld_qdi->clock[adev->devno]; |
887 | outb(qdi->clock[adev->devno], qdi->timing + | 887 | outb(ld_qdi->clock[adev->devno], ld_qdi->timing + |
888 | 2 * ap->port_no); | 888 | 2 * ap->port_no); |
889 | } | 889 | } |
890 | } | 890 | } |
@@ -1037,12 +1037,12 @@ static u8 winbond_readcfg(unsigned long port, u8 reg) | |||
1037 | static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev) | 1037 | static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev) |
1038 | { | 1038 | { |
1039 | struct ata_timing t; | 1039 | struct ata_timing t; |
1040 | struct legacy_data *winbond = ap->host->private_data; | 1040 | struct legacy_data *ld_winbond = ap->host->private_data; |
1041 | int active, recovery; | 1041 | int active, recovery; |
1042 | u8 reg; | 1042 | u8 reg; |
1043 | int timing = 0x88 + (ap->port_no * 4) + (adev->devno * 2); | 1043 | int timing = 0x88 + (ap->port_no * 4) + (adev->devno * 2); |
1044 | 1044 | ||
1045 | reg = winbond_readcfg(winbond->timing, 0x81); | 1045 | reg = winbond_readcfg(ld_winbond->timing, 0x81); |
1046 | 1046 | ||
1047 | /* Get the timing data in cycles */ | 1047 | /* Get the timing data in cycles */ |
1048 | if (reg & 0x40) /* Fast VLB bus, assume 50MHz */ | 1048 | if (reg & 0x40) /* Fast VLB bus, assume 50MHz */ |
@@ -1053,7 +1053,7 @@ static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
1053 | active = (FIT(t.active, 3, 17) - 1) & 0x0F; | 1053 | active = (FIT(t.active, 3, 17) - 1) & 0x0F; |
1054 | recovery = (FIT(t.recover, 1, 15) + 1) & 0x0F; | 1054 | recovery = (FIT(t.recover, 1, 15) + 1) & 0x0F; |
1055 | timing = (active << 4) | recovery; | 1055 | timing = (active << 4) | recovery; |
1056 | winbond_writecfg(winbond->timing, timing, reg); | 1056 | winbond_writecfg(ld_winbond->timing, timing, reg); |
1057 | 1057 | ||
1058 | /* Load the setup timing */ | 1058 | /* Load the setup timing */ |
1059 | 1059 | ||
@@ -1063,7 +1063,7 @@ static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
1063 | if (!ata_pio_need_iordy(adev)) | 1063 | if (!ata_pio_need_iordy(adev)) |
1064 | reg |= 0x02; /* IORDY off */ | 1064 | reg |= 0x02; /* IORDY off */ |
1065 | reg |= (FIT(t.setup, 0, 3) << 6); | 1065 | reg |= (FIT(t.setup, 0, 3) << 6); |
1066 | winbond_writecfg(winbond->timing, timing + 1, reg); | 1066 | winbond_writecfg(ld_winbond->timing, timing + 1, reg); |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | static int winbond_port(struct platform_device *dev, | 1069 | static int winbond_port(struct platform_device *dev, |
@@ -1278,8 +1278,6 @@ static __init int legacy_init_one(struct legacy_probe *probe) | |||
1278 | } | 1278 | } |
1279 | } | 1279 | } |
1280 | fail: | 1280 | fail: |
1281 | if (host) | ||
1282 | ata_host_detach(host); | ||
1283 | platform_device_unregister(pdev); | 1281 | platform_device_unregister(pdev); |
1284 | return ret; | 1282 | return ret; |
1285 | } | 1283 | } |
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c index 9afc8a32b226..a81f25d87235 100644 --- a/drivers/ata/pata_marvell.c +++ b/drivers/ata/pata_marvell.c | |||
@@ -85,8 +85,8 @@ static int marvell_cable_detect(struct ata_port *ap) | |||
85 | 85 | ||
86 | static void marvell_error_handler(struct ata_port *ap) | 86 | static void marvell_error_handler(struct ata_port *ap) |
87 | { | 87 | { |
88 | return ata_bmdma_drive_eh(ap, marvell_pre_reset, ata_std_softreset, | 88 | ata_bmdma_drive_eh(ap, marvell_pre_reset, ata_std_softreset, NULL, |
89 | NULL, ata_std_postreset); | 89 | ata_std_postreset); |
90 | } | 90 | } |
91 | 91 | ||
92 | /* No PIO or DMA methods needed for this device */ | 92 | /* No PIO or DMA methods needed for this device */ |
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c index 55055b27524c..6c016deeaed8 100644 --- a/drivers/ata/pata_scc.c +++ b/drivers/ata/pata_scc.c | |||
@@ -1007,6 +1007,8 @@ static const struct ata_port_operations scc_pata_ops = { | |||
1007 | .qc_issue = ata_qc_issue_prot, | 1007 | .qc_issue = ata_qc_issue_prot, |
1008 | 1008 | ||
1009 | .freeze = scc_bmdma_freeze, | 1009 | .freeze = scc_bmdma_freeze, |
1010 | .thaw = ata_bmdma_thaw, | ||
1011 | |||
1010 | .error_handler = scc_error_handler, | 1012 | .error_handler = scc_error_handler, |
1011 | .post_internal_cmd = scc_bmdma_stop, | 1013 | .post_internal_cmd = scc_bmdma_stop, |
1012 | 1014 | ||
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c index efcb66b6ccef..9323dd0c7d8d 100644 --- a/drivers/ata/sata_fsl.c +++ b/drivers/ata/sata_fsl.c | |||
@@ -601,21 +601,9 @@ static int sata_fsl_port_start(struct ata_port *ap) | |||
601 | if (!pp) | 601 | if (!pp) |
602 | return -ENOMEM; | 602 | return -ENOMEM; |
603 | 603 | ||
604 | /* | ||
605 | * allocate per command dma alignment pad buffer, which is used | ||
606 | * internally by libATA to ensure that all transfers ending on | ||
607 | * unaligned boundaries are padded, to align on Dword boundaries | ||
608 | */ | ||
609 | retval = ata_pad_alloc(ap, dev); | ||
610 | if (retval) { | ||
611 | kfree(pp); | ||
612 | return retval; | ||
613 | } | ||
614 | |||
615 | mem = dma_alloc_coherent(dev, SATA_FSL_PORT_PRIV_DMA_SZ, &mem_dma, | 604 | mem = dma_alloc_coherent(dev, SATA_FSL_PORT_PRIV_DMA_SZ, &mem_dma, |
616 | GFP_KERNEL); | 605 | GFP_KERNEL); |
617 | if (!mem) { | 606 | if (!mem) { |
618 | ata_pad_free(ap, dev); | ||
619 | kfree(pp); | 607 | kfree(pp); |
620 | return -ENOMEM; | 608 | return -ENOMEM; |
621 | } | 609 | } |
@@ -694,7 +682,6 @@ static void sata_fsl_port_stop(struct ata_port *ap) | |||
694 | dma_free_coherent(dev, SATA_FSL_PORT_PRIV_DMA_SZ, | 682 | dma_free_coherent(dev, SATA_FSL_PORT_PRIV_DMA_SZ, |
695 | pp->cmdslot, pp->cmdslot_paddr); | 683 | pp->cmdslot, pp->cmdslot_paddr); |
696 | 684 | ||
697 | ata_pad_free(ap, dev); | ||
698 | kfree(pp); | 685 | kfree(pp); |
699 | } | 686 | } |
700 | 687 | ||
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 04b571764aff..6ebebde8454a 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -870,7 +870,7 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio, | |||
870 | struct mv_host_priv *hpriv = ap->host->private_data; | 870 | struct mv_host_priv *hpriv = ap->host->private_data; |
871 | int hard_port = mv_hardport_from_port(ap->port_no); | 871 | int hard_port = mv_hardport_from_port(ap->port_no); |
872 | void __iomem *hc_mmio = mv_hc_base_from_port( | 872 | void __iomem *hc_mmio = mv_hc_base_from_port( |
873 | ap->host->iomap[MV_PRIMARY_BAR], hard_port); | 873 | mv_host_base(ap->host), hard_port); |
874 | u32 hc_irq_cause, ipending; | 874 | u32 hc_irq_cause, ipending; |
875 | 875 | ||
876 | /* clear EDMA event indicators, if any */ | 876 | /* clear EDMA event indicators, if any */ |
@@ -1158,17 +1158,13 @@ static int mv_port_start(struct ata_port *ap) | |||
1158 | struct mv_port_priv *pp; | 1158 | struct mv_port_priv *pp; |
1159 | void __iomem *port_mmio = mv_ap_base(ap); | 1159 | void __iomem *port_mmio = mv_ap_base(ap); |
1160 | unsigned long flags; | 1160 | unsigned long flags; |
1161 | int tag, rc; | 1161 | int tag; |
1162 | 1162 | ||
1163 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); | 1163 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
1164 | if (!pp) | 1164 | if (!pp) |
1165 | return -ENOMEM; | 1165 | return -ENOMEM; |
1166 | ap->private_data = pp; | 1166 | ap->private_data = pp; |
1167 | 1167 | ||
1168 | rc = ata_pad_alloc(ap, dev); | ||
1169 | if (rc) | ||
1170 | return rc; | ||
1171 | |||
1172 | pp->crqb = dma_pool_alloc(hpriv->crqb_pool, GFP_KERNEL, &pp->crqb_dma); | 1168 | pp->crqb = dma_pool_alloc(hpriv->crqb_pool, GFP_KERNEL, &pp->crqb_dma); |
1173 | if (!pp->crqb) | 1169 | if (!pp->crqb) |
1174 | return -ENOMEM; | 1170 | return -ENOMEM; |
@@ -1542,7 +1538,7 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
1542 | eh_freeze_mask = EDMA_EH_FREEZE_5; | 1538 | eh_freeze_mask = EDMA_EH_FREEZE_5; |
1543 | 1539 | ||
1544 | if (edma_err_cause & EDMA_ERR_SELF_DIS_5) { | 1540 | if (edma_err_cause & EDMA_ERR_SELF_DIS_5) { |
1545 | struct mv_port_priv *pp = ap->private_data; | 1541 | pp = ap->private_data; |
1546 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; | 1542 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; |
1547 | ata_ehi_push_desc(ehi, "EDMA self-disable"); | 1543 | ata_ehi_push_desc(ehi, "EDMA self-disable"); |
1548 | } | 1544 | } |
@@ -1550,7 +1546,7 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
1550 | eh_freeze_mask = EDMA_EH_FREEZE; | 1546 | eh_freeze_mask = EDMA_EH_FREEZE; |
1551 | 1547 | ||
1552 | if (edma_err_cause & EDMA_ERR_SELF_DIS) { | 1548 | if (edma_err_cause & EDMA_ERR_SELF_DIS) { |
1553 | struct mv_port_priv *pp = ap->private_data; | 1549 | pp = ap->private_data; |
1554 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; | 1550 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; |
1555 | ata_ehi_push_desc(ehi, "EDMA self-disable"); | 1551 | ata_ehi_push_desc(ehi, "EDMA self-disable"); |
1556 | } | 1552 | } |
@@ -2951,7 +2947,8 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
2951 | hpriv->n_ports = n_ports; | 2947 | hpriv->n_ports = n_ports; |
2952 | 2948 | ||
2953 | host->iomap = NULL; | 2949 | host->iomap = NULL; |
2954 | hpriv->base = ioremap(res->start, res->end - res->start + 1); | 2950 | hpriv->base = devm_ioremap(&pdev->dev, res->start, |
2951 | res->end - res->start + 1); | ||
2955 | hpriv->base -= MV_SATAHC0_REG_BASE; | 2952 | hpriv->base -= MV_SATAHC0_REG_BASE; |
2956 | 2953 | ||
2957 | rc = mv_create_dma_pools(hpriv, &pdev->dev); | 2954 | rc = mv_create_dma_pools(hpriv, &pdev->dev); |
@@ -2983,11 +2980,8 @@ static int __devexit mv_platform_remove(struct platform_device *pdev) | |||
2983 | { | 2980 | { |
2984 | struct device *dev = &pdev->dev; | 2981 | struct device *dev = &pdev->dev; |
2985 | struct ata_host *host = dev_get_drvdata(dev); | 2982 | struct ata_host *host = dev_get_drvdata(dev); |
2986 | struct mv_host_priv *hpriv = host->private_data; | ||
2987 | void __iomem *base = hpriv->base; | ||
2988 | 2983 | ||
2989 | ata_host_detach(host); | 2984 | ata_host_detach(host); |
2990 | iounmap(base); | ||
2991 | return 0; | 2985 | return 0; |
2992 | } | 2986 | } |
2993 | 2987 | ||
@@ -3198,6 +3192,7 @@ MODULE_DESCRIPTION("SCSI low-level driver for Marvell SATA controllers"); | |||
3198 | MODULE_LICENSE("GPL"); | 3192 | MODULE_LICENSE("GPL"); |
3199 | MODULE_DEVICE_TABLE(pci, mv_pci_tbl); | 3193 | MODULE_DEVICE_TABLE(pci, mv_pci_tbl); |
3200 | MODULE_VERSION(DRV_VERSION); | 3194 | MODULE_VERSION(DRV_VERSION); |
3195 | MODULE_ALIAS("platform:sata_mv"); | ||
3201 | 3196 | ||
3202 | #ifdef CONFIG_PCI | 3197 | #ifdef CONFIG_PCI |
3203 | module_param(msi, int, 0444); | 3198 | module_param(msi, int, 0444); |
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index a07d319f6e8c..f251a5f569d5 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -543,7 +543,7 @@ static void pdc_fill_sg(struct ata_queued_cmd *qc) | |||
543 | idx = 0; | 543 | idx = 0; |
544 | for_each_sg(qc->sg, sg, qc->n_elem, si) { | 544 | for_each_sg(qc->sg, sg, qc->n_elem, si) { |
545 | u32 addr, offset; | 545 | u32 addr, offset; |
546 | u32 sg_len, len; | 546 | u32 sg_len; |
547 | 547 | ||
548 | /* determine if physical DMA addr spans 64K boundary. | 548 | /* determine if physical DMA addr spans 64K boundary. |
549 | * Note h/w doesn't support 64-bit, so we unconditionally | 549 | * Note h/w doesn't support 64-bit, so we unconditionally |
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index b4b1f91ea693..df7988df7908 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -1234,7 +1234,6 @@ static int sil24_port_start(struct ata_port *ap) | |||
1234 | union sil24_cmd_block *cb; | 1234 | union sil24_cmd_block *cb; |
1235 | size_t cb_size = sizeof(*cb) * SIL24_MAX_CMDS; | 1235 | size_t cb_size = sizeof(*cb) * SIL24_MAX_CMDS; |
1236 | dma_addr_t cb_dma; | 1236 | dma_addr_t cb_dma; |
1237 | int rc; | ||
1238 | 1237 | ||
1239 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); | 1238 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
1240 | if (!pp) | 1239 | if (!pp) |
@@ -1247,10 +1246,6 @@ static int sil24_port_start(struct ata_port *ap) | |||
1247 | return -ENOMEM; | 1246 | return -ENOMEM; |
1248 | memset(cb, 0, cb_size); | 1247 | memset(cb, 0, cb_size); |
1249 | 1248 | ||
1250 | rc = ata_pad_alloc(ap, dev); | ||
1251 | if (rc) | ||
1252 | return rc; | ||
1253 | |||
1254 | pp->cmd_block = cb; | 1249 | pp->cmd_block = cb; |
1255 | pp->cmd_block_dma = cb_dma; | 1250 | pp->cmd_block_dma = cb_dma; |
1256 | 1251 | ||
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index 30caa0337190..0d03f44824fb 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -333,8 +333,8 @@ static int vt6420_prereset(struct ata_link *link, unsigned long deadline) | |||
333 | 333 | ||
334 | static void vt6420_error_handler(struct ata_port *ap) | 334 | static void vt6420_error_handler(struct ata_port *ap) |
335 | { | 335 | { |
336 | return ata_bmdma_drive_eh(ap, vt6420_prereset, ata_std_softreset, | 336 | ata_bmdma_drive_eh(ap, vt6420_prereset, ata_std_softreset, NULL, |
337 | NULL, ata_std_postreset); | 337 | ata_std_postreset); |
338 | } | 338 | } |
339 | 339 | ||
340 | static int vt6421_pata_cable_detect(struct ata_port *ap) | 340 | static int vt6421_pata_cable_detect(struct ata_port *ap) |
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 055989e94799..2d207ad30336 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -658,9 +658,10 @@ int bus_add_driver(struct device_driver *drv) | |||
658 | pr_debug("bus: '%s': add driver %s\n", bus->name, drv->name); | 658 | pr_debug("bus: '%s': add driver %s\n", bus->name, drv->name); |
659 | 659 | ||
660 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 660 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
661 | if (!priv) | 661 | if (!priv) { |
662 | return -ENOMEM; | 662 | error = -ENOMEM; |
663 | 663 | goto out_put_bus; | |
664 | } | ||
664 | klist_init(&priv->klist_devices, NULL, NULL); | 665 | klist_init(&priv->klist_devices, NULL, NULL); |
665 | priv->driver = drv; | 666 | priv->driver = drv; |
666 | drv->p = priv; | 667 | drv->p = priv; |
@@ -668,7 +669,7 @@ int bus_add_driver(struct device_driver *drv) | |||
668 | error = kobject_init_and_add(&priv->kobj, &driver_ktype, NULL, | 669 | error = kobject_init_and_add(&priv->kobj, &driver_ktype, NULL, |
669 | "%s", drv->name); | 670 | "%s", drv->name); |
670 | if (error) | 671 | if (error) |
671 | goto out_put_bus; | 672 | goto out_unregister; |
672 | 673 | ||
673 | if (drv->bus->p->drivers_autoprobe) { | 674 | if (drv->bus->p->drivers_autoprobe) { |
674 | error = driver_attach(drv); | 675 | error = driver_attach(drv); |
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index ba75184c653c..bf31a0170a48 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c | |||
@@ -120,6 +120,9 @@ EXPORT_SYMBOL_GPL(driver_remove_file); | |||
120 | 120 | ||
121 | /** | 121 | /** |
122 | * driver_add_kobj - add a kobject below the specified driver | 122 | * driver_add_kobj - add a kobject below the specified driver |
123 | * @drv: requesting device driver | ||
124 | * @kobj: kobject to add below this driver | ||
125 | * @fmt: format string that names the kobject | ||
123 | * | 126 | * |
124 | * You really don't want to do this, this is only here due to one looney | 127 | * You really don't want to do this, this is only here due to one looney |
125 | * iseries driver, go poke those developers if you are annoyed about | 128 | * iseries driver, go poke those developers if you are annoyed about |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index bdc03f7e8424..ee9d1c8db0d6 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -415,7 +415,7 @@ EXPORT_SYMBOL_GPL(device_power_down); | |||
415 | * @dev: Device. | 415 | * @dev: Device. |
416 | * @state: Power state device is entering. | 416 | * @state: Power state device is entering. |
417 | */ | 417 | */ |
418 | int suspend_device(struct device *dev, pm_message_t state) | 418 | static int suspend_device(struct device *dev, pm_message_t state) |
419 | { | 419 | { |
420 | int error = 0; | 420 | int error = 0; |
421 | 421 | ||
@@ -479,7 +479,6 @@ static int dpm_suspend(pm_message_t state) | |||
479 | mutex_lock(&dpm_list_mtx); | 479 | mutex_lock(&dpm_list_mtx); |
480 | if (list_empty(&dev->power.entry)) | 480 | if (list_empty(&dev->power.entry)) |
481 | list_add(&dev->power.entry, &dpm_locked); | 481 | list_add(&dev->power.entry, &dpm_locked); |
482 | mutex_unlock(&dpm_list_mtx); | ||
483 | break; | 482 | break; |
484 | } | 483 | } |
485 | mutex_lock(&dpm_list_mtx); | 484 | mutex_lock(&dpm_list_mtx); |
@@ -523,6 +522,7 @@ static void lock_all_devices(void) | |||
523 | 522 | ||
524 | /** | 523 | /** |
525 | * device_suspend - Save state and stop all devices in system. | 524 | * device_suspend - Save state and stop all devices in system. |
525 | * @state: new power management state | ||
526 | * | 526 | * |
527 | * Prevent new devices from being registered, then lock all devices | 527 | * Prevent new devices from being registered, then lock all devices |
528 | * and suspend them. | 528 | * and suspend them. |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 018753c59b8e..b53fdb0a282c 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -655,6 +655,7 @@ static int __init nbd_init(void) | |||
655 | 655 | ||
656 | for (i = 0; i < nbds_max; i++) { | 656 | for (i = 0; i < nbds_max; i++) { |
657 | struct gendisk *disk = alloc_disk(1); | 657 | struct gendisk *disk = alloc_disk(1); |
658 | elevator_t *old_e; | ||
658 | if (!disk) | 659 | if (!disk) |
659 | goto out; | 660 | goto out; |
660 | nbd_dev[i].disk = disk; | 661 | nbd_dev[i].disk = disk; |
@@ -668,6 +669,11 @@ static int __init nbd_init(void) | |||
668 | put_disk(disk); | 669 | put_disk(disk); |
669 | goto out; | 670 | goto out; |
670 | } | 671 | } |
672 | old_e = disk->queue->elevator; | ||
673 | if (elevator_init(disk->queue, "deadline") == 0 || | ||
674 | elevator_init(disk->queue, "noop") == 0) { | ||
675 | elevator_exit(old_e); | ||
676 | } | ||
671 | } | 677 | } |
672 | 678 | ||
673 | if (register_blkdev(NBD_MAJOR, "nbd")) { | 679 | if (register_blkdev(NBD_MAJOR, "nbd")) { |
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index b4e462f154ea..730ccea78e45 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c | |||
@@ -251,10 +251,6 @@ static int floppy_release(struct inode *inode, struct file *filp); | |||
251 | static int floppy_check_change(struct gendisk *disk); | 251 | static int floppy_check_change(struct gendisk *disk); |
252 | static int floppy_revalidate(struct gendisk *disk); | 252 | static int floppy_revalidate(struct gendisk *disk); |
253 | 253 | ||
254 | #ifndef CONFIG_PMAC_MEDIABAY | ||
255 | #define check_media_bay(which, what) 1 | ||
256 | #endif | ||
257 | |||
258 | static void swim3_select(struct floppy_state *fs, int sel) | 254 | static void swim3_select(struct floppy_state *fs, int sel) |
259 | { | 255 | { |
260 | struct swim3 __iomem *sw = fs->swim3; | 256 | struct swim3 __iomem *sw = fs->swim3; |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 8afce67c0aa5..9c6f3f99208d 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
39 | #include <linux/blkdev.h> | 39 | #include <linux/blkdev.h> |
40 | #include <linux/hdreg.h> | ||
40 | #include <linux/module.h> | 41 | #include <linux/module.h> |
41 | 42 | ||
42 | #include <xen/xenbus.h> | 43 | #include <xen/xenbus.h> |
@@ -135,6 +136,22 @@ static void blkif_restart_queue_callback(void *arg) | |||
135 | schedule_work(&info->work); | 136 | schedule_work(&info->work); |
136 | } | 137 | } |
137 | 138 | ||
139 | int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg) | ||
140 | { | ||
141 | /* We don't have real geometry info, but let's at least return | ||
142 | values consistent with the size of the device */ | ||
143 | sector_t nsect = get_capacity(bd->bd_disk); | ||
144 | sector_t cylinders = nsect; | ||
145 | |||
146 | hg->heads = 0xff; | ||
147 | hg->sectors = 0x3f; | ||
148 | sector_div(cylinders, hg->heads * hg->sectors); | ||
149 | hg->cylinders = cylinders; | ||
150 | if ((sector_t)(hg->cylinders + 1) * hg->heads * hg->sectors < nsect) | ||
151 | hg->cylinders = 0xffff; | ||
152 | return 0; | ||
153 | } | ||
154 | |||
138 | /* | 155 | /* |
139 | * blkif_queue_request | 156 | * blkif_queue_request |
140 | * | 157 | * |
@@ -937,6 +954,7 @@ static struct block_device_operations xlvbd_block_fops = | |||
937 | .owner = THIS_MODULE, | 954 | .owner = THIS_MODULE, |
938 | .open = blkif_open, | 955 | .open = blkif_open, |
939 | .release = blkif_release, | 956 | .release = blkif_release, |
957 | .getgeo = blkif_getgeo, | ||
940 | }; | 958 | }; |
941 | 959 | ||
942 | 960 | ||
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c index 87be46406daf..d28669992147 100644 --- a/drivers/char/agp/amd-k7-agp.c +++ b/drivers/char/agp/amd-k7-agp.c | |||
@@ -41,6 +41,7 @@ static int amd_create_page_map(struct amd_page_map *page_map) | |||
41 | if (page_map->real == NULL) | 41 | if (page_map->real == NULL) |
42 | return -ENOMEM; | 42 | return -ENOMEM; |
43 | 43 | ||
44 | #ifndef CONFIG_X86 | ||
44 | SetPageReserved(virt_to_page(page_map->real)); | 45 | SetPageReserved(virt_to_page(page_map->real)); |
45 | global_cache_flush(); | 46 | global_cache_flush(); |
46 | page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real), | 47 | page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real), |
@@ -52,6 +53,10 @@ static int amd_create_page_map(struct amd_page_map *page_map) | |||
52 | return -ENOMEM; | 53 | return -ENOMEM; |
53 | } | 54 | } |
54 | global_cache_flush(); | 55 | global_cache_flush(); |
56 | #else | ||
57 | set_memory_uc((unsigned long)page_map->real, 1); | ||
58 | page_map->remapped = page_map->real; | ||
59 | #endif | ||
55 | 60 | ||
56 | for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) { | 61 | for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) { |
57 | writel(agp_bridge->scratch_page, page_map->remapped+i); | 62 | writel(agp_bridge->scratch_page, page_map->remapped+i); |
@@ -63,8 +68,12 @@ static int amd_create_page_map(struct amd_page_map *page_map) | |||
63 | 68 | ||
64 | static void amd_free_page_map(struct amd_page_map *page_map) | 69 | static void amd_free_page_map(struct amd_page_map *page_map) |
65 | { | 70 | { |
71 | #ifndef CONFIG_X86 | ||
66 | iounmap(page_map->remapped); | 72 | iounmap(page_map->remapped); |
67 | ClearPageReserved(virt_to_page(page_map->real)); | 73 | ClearPageReserved(virt_to_page(page_map->real)); |
74 | #else | ||
75 | set_memory_wb((unsigned long)page_map->real, 1); | ||
76 | #endif | ||
68 | free_page((unsigned long) page_map->real); | 77 | free_page((unsigned long) page_map->real); |
69 | } | 78 | } |
70 | 79 | ||
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c index 2d46b713c8f2..55c97f623242 100644 --- a/drivers/char/agp/ati-agp.c +++ b/drivers/char/agp/ati-agp.c | |||
@@ -60,18 +60,9 @@ static int ati_create_page_map(struct ati_page_map *page_map) | |||
60 | if (page_map->real == NULL) | 60 | if (page_map->real == NULL) |
61 | return -ENOMEM; | 61 | return -ENOMEM; |
62 | 62 | ||
63 | SetPageReserved(virt_to_page(page_map->real)); | 63 | set_memory_uc((unsigned long)page_map->real, 1); |
64 | err = map_page_into_agp(virt_to_page(page_map->real)); | 64 | err = map_page_into_agp(virt_to_page(page_map->real)); |
65 | page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real), | 65 | page_map->remapped = page_map->real; |
66 | PAGE_SIZE); | ||
67 | if (page_map->remapped == NULL || err) { | ||
68 | ClearPageReserved(virt_to_page(page_map->real)); | ||
69 | free_page((unsigned long) page_map->real); | ||
70 | page_map->real = NULL; | ||
71 | return -ENOMEM; | ||
72 | } | ||
73 | /*CACHE_FLUSH();*/ | ||
74 | global_cache_flush(); | ||
75 | 66 | ||
76 | for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) { | 67 | for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) { |
77 | writel(agp_bridge->scratch_page, page_map->remapped+i); | 68 | writel(agp_bridge->scratch_page, page_map->remapped+i); |
@@ -85,8 +76,7 @@ static int ati_create_page_map(struct ati_page_map *page_map) | |||
85 | static void ati_free_page_map(struct ati_page_map *page_map) | 76 | static void ati_free_page_map(struct ati_page_map *page_map) |
86 | { | 77 | { |
87 | unmap_page_from_agp(virt_to_page(page_map->real)); | 78 | unmap_page_from_agp(virt_to_page(page_map->real)); |
88 | iounmap(page_map->remapped); | 79 | set_memory_wb((unsigned long)page_map->real, 1); |
89 | ClearPageReserved(virt_to_page(page_map->real)); | ||
90 | free_page((unsigned long) page_map->real); | 80 | free_page((unsigned long) page_map->real); |
91 | } | 81 | } |
92 | 82 | ||
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index 7484bc759c4c..7fc0c99a3a58 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c | |||
@@ -932,9 +932,14 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge) | |||
932 | agp_gatt_table = (void *)table; | 932 | agp_gatt_table = (void *)table; |
933 | 933 | ||
934 | bridge->driver->cache_flush(); | 934 | bridge->driver->cache_flush(); |
935 | #ifdef CONFIG_X86 | ||
936 | set_memory_uc((unsigned long)table, 1 << page_order); | ||
937 | bridge->gatt_table = (void *)table; | ||
938 | #else | ||
935 | bridge->gatt_table = ioremap_nocache(virt_to_gart(table), | 939 | bridge->gatt_table = ioremap_nocache(virt_to_gart(table), |
936 | (PAGE_SIZE * (1 << page_order))); | 940 | (PAGE_SIZE * (1 << page_order))); |
937 | bridge->driver->cache_flush(); | 941 | bridge->driver->cache_flush(); |
942 | #endif | ||
938 | 943 | ||
939 | if (bridge->gatt_table == NULL) { | 944 | if (bridge->gatt_table == NULL) { |
940 | for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) | 945 | for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) |
@@ -991,7 +996,11 @@ int agp_generic_free_gatt_table(struct agp_bridge_data *bridge) | |||
991 | * called, then all agp memory is deallocated and removed | 996 | * called, then all agp memory is deallocated and removed |
992 | * from the table. */ | 997 | * from the table. */ |
993 | 998 | ||
999 | #ifdef CONFIG_X86 | ||
1000 | set_memory_wb((unsigned long)bridge->gatt_table, 1 << page_order); | ||
1001 | #else | ||
994 | iounmap(bridge->gatt_table); | 1002 | iounmap(bridge->gatt_table); |
1003 | #endif | ||
995 | table = (char *) bridge->gatt_table_real; | 1004 | table = (char *) bridge->gatt_table_real; |
996 | table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1); | 1005 | table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1); |
997 | 1006 | ||
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c index eb1a1c738190..b6791846809f 100644 --- a/drivers/char/agp/sis-agp.c +++ b/drivers/char/agp/sis-agp.c | |||
@@ -14,6 +14,9 @@ | |||
14 | #define SIS_TLBCNTRL 0x97 | 14 | #define SIS_TLBCNTRL 0x97 |
15 | #define SIS_TLBFLUSH 0x98 | 15 | #define SIS_TLBFLUSH 0x98 |
16 | 16 | ||
17 | #define PCI_DEVICE_ID_SI_662 0x0662 | ||
18 | #define PCI_DEVICE_ID_SI_671 0x0671 | ||
19 | |||
17 | static int __devinitdata agp_sis_force_delay = 0; | 20 | static int __devinitdata agp_sis_force_delay = 0; |
18 | static int __devinitdata agp_sis_agp_spec = -1; | 21 | static int __devinitdata agp_sis_agp_spec = -1; |
19 | 22 | ||
@@ -27,8 +30,8 @@ static int sis_fetch_size(void) | |||
27 | values = A_SIZE_8(agp_bridge->driver->aperture_sizes); | 30 | values = A_SIZE_8(agp_bridge->driver->aperture_sizes); |
28 | for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { | 31 | for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { |
29 | if ((temp_size == values[i].size_value) || | 32 | if ((temp_size == values[i].size_value) || |
30 | ((temp_size & ~(0x03)) == | 33 | ((temp_size & ~(0x07)) == |
31 | (values[i].size_value & ~(0x03)))) { | 34 | (values[i].size_value & ~(0x07)))) { |
32 | agp_bridge->previous_size = | 35 | agp_bridge->previous_size = |
33 | agp_bridge->current_size = (void *) (values + i); | 36 | agp_bridge->current_size = (void *) (values + i); |
34 | 37 | ||
@@ -214,6 +217,26 @@ static void __devexit agp_sis_remove(struct pci_dev *pdev) | |||
214 | agp_put_bridge(bridge); | 217 | agp_put_bridge(bridge); |
215 | } | 218 | } |
216 | 219 | ||
220 | #ifdef CONFIG_PM | ||
221 | |||
222 | static int agp_sis_suspend(struct pci_dev *pdev, pm_message_t state) | ||
223 | { | ||
224 | pci_save_state(pdev); | ||
225 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static int agp_sis_resume(struct pci_dev *pdev) | ||
231 | { | ||
232 | pci_set_power_state(pdev, PCI_D0); | ||
233 | pci_restore_state(pdev); | ||
234 | |||
235 | return sis_driver.configure(); | ||
236 | } | ||
237 | |||
238 | #endif /* CONFIG_PM */ | ||
239 | |||
217 | static struct pci_device_id agp_sis_pci_table[] = { | 240 | static struct pci_device_id agp_sis_pci_table[] = { |
218 | { | 241 | { |
219 | .class = (PCI_CLASS_BRIDGE_HOST << 8), | 242 | .class = (PCI_CLASS_BRIDGE_HOST << 8), |
@@ -331,6 +354,22 @@ static struct pci_device_id agp_sis_pci_table[] = { | |||
331 | .class = (PCI_CLASS_BRIDGE_HOST << 8), | 354 | .class = (PCI_CLASS_BRIDGE_HOST << 8), |
332 | .class_mask = ~0, | 355 | .class_mask = ~0, |
333 | .vendor = PCI_VENDOR_ID_SI, | 356 | .vendor = PCI_VENDOR_ID_SI, |
357 | .device = PCI_DEVICE_ID_SI_662, | ||
358 | .subvendor = PCI_ANY_ID, | ||
359 | .subdevice = PCI_ANY_ID, | ||
360 | }, | ||
361 | { | ||
362 | .class = (PCI_CLASS_BRIDGE_HOST << 8), | ||
363 | .class_mask = ~0, | ||
364 | .vendor = PCI_VENDOR_ID_SI, | ||
365 | .device = PCI_DEVICE_ID_SI_671, | ||
366 | .subvendor = PCI_ANY_ID, | ||
367 | .subdevice = PCI_ANY_ID, | ||
368 | }, | ||
369 | { | ||
370 | .class = (PCI_CLASS_BRIDGE_HOST << 8), | ||
371 | .class_mask = ~0, | ||
372 | .vendor = PCI_VENDOR_ID_SI, | ||
334 | .device = PCI_DEVICE_ID_SI_730, | 373 | .device = PCI_DEVICE_ID_SI_730, |
335 | .subvendor = PCI_ANY_ID, | 374 | .subvendor = PCI_ANY_ID, |
336 | .subdevice = PCI_ANY_ID, | 375 | .subdevice = PCI_ANY_ID, |
@@ -393,6 +432,10 @@ static struct pci_driver agp_sis_pci_driver = { | |||
393 | .id_table = agp_sis_pci_table, | 432 | .id_table = agp_sis_pci_table, |
394 | .probe = agp_sis_probe, | 433 | .probe = agp_sis_probe, |
395 | .remove = agp_sis_remove, | 434 | .remove = agp_sis_remove, |
435 | #ifdef CONFIG_PM | ||
436 | .suspend = agp_sis_suspend, | ||
437 | .resume = agp_sis_resume, | ||
438 | #endif | ||
396 | }; | 439 | }; |
397 | 440 | ||
398 | static int __init agp_sis_init(void) | 441 | static int __init agp_sis_init(void) |
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c index 551ef25063ef..e08934e58f32 100644 --- a/drivers/char/agp/sworks-agp.c +++ b/drivers/char/agp/sworks-agp.c | |||
@@ -52,28 +52,20 @@ static int serverworks_create_page_map(struct serverworks_page_map *page_map) | |||
52 | if (page_map->real == NULL) { | 52 | if (page_map->real == NULL) { |
53 | return -ENOMEM; | 53 | return -ENOMEM; |
54 | } | 54 | } |
55 | SetPageReserved(virt_to_page(page_map->real)); | 55 | |
56 | global_cache_flush(); | 56 | set_memory_uc((unsigned long)page_map->real, 1); |
57 | page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real), | 57 | page_map->remapped = page_map->real; |
58 | PAGE_SIZE); | ||
59 | if (page_map->remapped == NULL) { | ||
60 | ClearPageReserved(virt_to_page(page_map->real)); | ||
61 | free_page((unsigned long) page_map->real); | ||
62 | page_map->real = NULL; | ||
63 | return -ENOMEM; | ||
64 | } | ||
65 | global_cache_flush(); | ||
66 | 58 | ||
67 | for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) | 59 | for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) |
68 | writel(agp_bridge->scratch_page, page_map->remapped+i); | 60 | writel(agp_bridge->scratch_page, page_map->remapped+i); |
61 | /* Red Pen: Everyone else does pci posting flush here */ | ||
69 | 62 | ||
70 | return 0; | 63 | return 0; |
71 | } | 64 | } |
72 | 65 | ||
73 | static void serverworks_free_page_map(struct serverworks_page_map *page_map) | 66 | static void serverworks_free_page_map(struct serverworks_page_map *page_map) |
74 | { | 67 | { |
75 | iounmap(page_map->remapped); | 68 | set_memory_wb((unsigned long)page_map->real, 1); |
76 | ClearPageReserved(virt_to_page(page_map->real)); | ||
77 | free_page((unsigned long) page_map->real); | 69 | free_page((unsigned long) page_map->real); |
78 | } | 70 | } |
79 | 71 | ||
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h index 19d3be5c4b2d..a6789f25009b 100644 --- a/drivers/char/drm/drmP.h +++ b/drivers/char/drm/drmP.h | |||
@@ -568,7 +568,7 @@ struct drm_driver { | |||
568 | void (*postclose) (struct drm_device *, struct drm_file *); | 568 | void (*postclose) (struct drm_device *, struct drm_file *); |
569 | void (*lastclose) (struct drm_device *); | 569 | void (*lastclose) (struct drm_device *); |
570 | int (*unload) (struct drm_device *); | 570 | int (*unload) (struct drm_device *); |
571 | int (*suspend) (struct drm_device *); | 571 | int (*suspend) (struct drm_device *, pm_message_t state); |
572 | int (*resume) (struct drm_device *); | 572 | int (*resume) (struct drm_device *); |
573 | int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); | 573 | int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); |
574 | void (*dma_ready) (struct drm_device *); | 574 | void (*dma_ready) (struct drm_device *); |
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h index f52468843678..715b361f0c2b 100644 --- a/drivers/char/drm/drm_pciids.h +++ b/drivers/char/drm/drm_pciids.h | |||
@@ -83,6 +83,7 @@ | |||
83 | {0x1002, 0x5460, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ | 83 | {0x1002, 0x5460, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ |
84 | {0x1002, 0x5462, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ | 84 | {0x1002, 0x5462, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ |
85 | {0x1002, 0x5464, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ | 85 | {0x1002, 0x5464, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ |
86 | {0x1002, 0x5657, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ | ||
86 | {0x1002, 0x5548, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ | 87 | {0x1002, 0x5548, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ |
87 | {0x1002, 0x5549, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ | 88 | {0x1002, 0x5549, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ |
88 | {0x1002, 0x554A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ | 89 | {0x1002, 0x554A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ |
@@ -236,6 +237,7 @@ | |||
236 | {0x1002, 0x7297, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \ | 237 | {0x1002, 0x7297, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \ |
237 | {0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \ | 238 | {0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \ |
238 | {0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | 239 | {0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
240 | {0x1002, 0x791e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \ | ||
239 | {0, 0, 0} | 241 | {0, 0, 0} |
240 | 242 | ||
241 | #define r128_PCI_IDS \ | 243 | #define r128_PCI_IDS \ |
@@ -313,6 +315,7 @@ | |||
313 | {0x1039, 0x5300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ | 315 | {0x1039, 0x5300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ |
314 | {0x1039, 0x6300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ | 316 | {0x1039, 0x6300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ |
315 | {0x1039, 0x6330, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \ | 317 | {0x1039, 0x6330, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \ |
318 | {0x1039, 0x6351, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ | ||
316 | {0x1039, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ | 319 | {0x1039, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ |
317 | {0x18CA, 0x0040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \ | 320 | {0x18CA, 0x0040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \ |
318 | {0x18CA, 0x0042, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \ | 321 | {0x18CA, 0x0042, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \ |
diff --git a/drivers/char/drm/drm_sysfs.c b/drivers/char/drm/drm_sysfs.c index fa36153619e8..05ed5043254f 100644 --- a/drivers/char/drm/drm_sysfs.c +++ b/drivers/char/drm/drm_sysfs.c | |||
@@ -36,7 +36,7 @@ static int drm_sysfs_suspend(struct device *dev, pm_message_t state) | |||
36 | printk(KERN_ERR "%s\n", __FUNCTION__); | 36 | printk(KERN_ERR "%s\n", __FUNCTION__); |
37 | 37 | ||
38 | if (drm_dev->driver->suspend) | 38 | if (drm_dev->driver->suspend) |
39 | return drm_dev->driver->suspend(drm_dev); | 39 | return drm_dev->driver->suspend(drm_dev, state); |
40 | 40 | ||
41 | return 0; | 41 | return 0; |
42 | } | 42 | } |
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c index cea4105374b2..3d65c4dcd0c6 100644 --- a/drivers/char/drm/drm_vm.c +++ b/drivers/char/drm/drm_vm.c | |||
@@ -66,7 +66,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) | |||
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * \c nopage method for AGP virtual memory. | 69 | * \c fault method for AGP virtual memory. |
70 | * | 70 | * |
71 | * \param vma virtual memory area. | 71 | * \param vma virtual memory area. |
72 | * \param address access address. | 72 | * \param address access address. |
@@ -76,8 +76,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) | |||
76 | * map, get the page, increment the use count and return it. | 76 | * map, get the page, increment the use count and return it. |
77 | */ | 77 | */ |
78 | #if __OS_HAS_AGP | 78 | #if __OS_HAS_AGP |
79 | static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, | 79 | static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
80 | unsigned long address) | ||
81 | { | 80 | { |
82 | struct drm_file *priv = vma->vm_file->private_data; | 81 | struct drm_file *priv = vma->vm_file->private_data; |
83 | struct drm_device *dev = priv->head->dev; | 82 | struct drm_device *dev = priv->head->dev; |
@@ -89,19 +88,24 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, | |||
89 | * Find the right map | 88 | * Find the right map |
90 | */ | 89 | */ |
91 | if (!drm_core_has_AGP(dev)) | 90 | if (!drm_core_has_AGP(dev)) |
92 | goto vm_nopage_error; | 91 | goto vm_fault_error; |
93 | 92 | ||
94 | if (!dev->agp || !dev->agp->cant_use_aperture) | 93 | if (!dev->agp || !dev->agp->cant_use_aperture) |
95 | goto vm_nopage_error; | 94 | goto vm_fault_error; |
96 | 95 | ||
97 | if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash)) | 96 | if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash)) |
98 | goto vm_nopage_error; | 97 | goto vm_fault_error; |
99 | 98 | ||
100 | r_list = drm_hash_entry(hash, struct drm_map_list, hash); | 99 | r_list = drm_hash_entry(hash, struct drm_map_list, hash); |
101 | map = r_list->map; | 100 | map = r_list->map; |
102 | 101 | ||
103 | if (map && map->type == _DRM_AGP) { | 102 | if (map && map->type == _DRM_AGP) { |
104 | unsigned long offset = address - vma->vm_start; | 103 | /* |
104 | * Using vm_pgoff as a selector forces us to use this unusual | ||
105 | * addressing scheme. | ||
106 | */ | ||
107 | unsigned long offset = (unsigned long)vmf->virtual_address - | ||
108 | vma->vm_start; | ||
105 | unsigned long baddr = map->offset + offset; | 109 | unsigned long baddr = map->offset + offset; |
106 | struct drm_agp_mem *agpmem; | 110 | struct drm_agp_mem *agpmem; |
107 | struct page *page; | 111 | struct page *page; |
@@ -123,7 +127,7 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, | |||
123 | } | 127 | } |
124 | 128 | ||
125 | if (!agpmem) | 129 | if (!agpmem) |
126 | goto vm_nopage_error; | 130 | goto vm_fault_error; |
127 | 131 | ||
128 | /* | 132 | /* |
129 | * Get the page, inc the use count, and return it | 133 | * Get the page, inc the use count, and return it |
@@ -131,22 +135,21 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, | |||
131 | offset = (baddr - agpmem->bound) >> PAGE_SHIFT; | 135 | offset = (baddr - agpmem->bound) >> PAGE_SHIFT; |
132 | page = virt_to_page(__va(agpmem->memory->memory[offset])); | 136 | page = virt_to_page(__va(agpmem->memory->memory[offset])); |
133 | get_page(page); | 137 | get_page(page); |
138 | vmf->page = page; | ||
134 | 139 | ||
135 | DRM_DEBUG | 140 | DRM_DEBUG |
136 | ("baddr = 0x%lx page = 0x%p, offset = 0x%lx, count=%d\n", | 141 | ("baddr = 0x%lx page = 0x%p, offset = 0x%lx, count=%d\n", |
137 | baddr, __va(agpmem->memory->memory[offset]), offset, | 142 | baddr, __va(agpmem->memory->memory[offset]), offset, |
138 | page_count(page)); | 143 | page_count(page)); |
139 | 144 | return 0; | |
140 | return page; | ||
141 | } | 145 | } |
142 | vm_nopage_error: | 146 | vm_fault_error: |
143 | return NOPAGE_SIGBUS; /* Disallow mremap */ | 147 | return VM_FAULT_SIGBUS; /* Disallow mremap */ |
144 | } | 148 | } |
145 | #else /* __OS_HAS_AGP */ | 149 | #else /* __OS_HAS_AGP */ |
146 | static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, | 150 | static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
147 | unsigned long address) | ||
148 | { | 151 | { |
149 | return NOPAGE_SIGBUS; | 152 | return VM_FAULT_SIGBUS; |
150 | } | 153 | } |
151 | #endif /* __OS_HAS_AGP */ | 154 | #endif /* __OS_HAS_AGP */ |
152 | 155 | ||
@@ -160,28 +163,26 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, | |||
160 | * Get the mapping, find the real physical page to map, get the page, and | 163 | * Get the mapping, find the real physical page to map, get the page, and |
161 | * return it. | 164 | * return it. |
162 | */ | 165 | */ |
163 | static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma, | 166 | static int drm_do_vm_shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
164 | unsigned long address) | ||
165 | { | 167 | { |
166 | struct drm_map *map = (struct drm_map *) vma->vm_private_data; | 168 | struct drm_map *map = (struct drm_map *) vma->vm_private_data; |
167 | unsigned long offset; | 169 | unsigned long offset; |
168 | unsigned long i; | 170 | unsigned long i; |
169 | struct page *page; | 171 | struct page *page; |
170 | 172 | ||
171 | if (address > vma->vm_end) | ||
172 | return NOPAGE_SIGBUS; /* Disallow mremap */ | ||
173 | if (!map) | 173 | if (!map) |
174 | return NOPAGE_SIGBUS; /* Nothing allocated */ | 174 | return VM_FAULT_SIGBUS; /* Nothing allocated */ |
175 | 175 | ||
176 | offset = address - vma->vm_start; | 176 | offset = (unsigned long)vmf->virtual_address - vma->vm_start; |
177 | i = (unsigned long)map->handle + offset; | 177 | i = (unsigned long)map->handle + offset; |
178 | page = vmalloc_to_page((void *)i); | 178 | page = vmalloc_to_page((void *)i); |
179 | if (!page) | 179 | if (!page) |
180 | return NOPAGE_SIGBUS; | 180 | return VM_FAULT_SIGBUS; |
181 | get_page(page); | 181 | get_page(page); |
182 | vmf->page = page; | ||
182 | 183 | ||
183 | DRM_DEBUG("0x%lx\n", address); | 184 | DRM_DEBUG("shm_fault 0x%lx\n", offset); |
184 | return page; | 185 | return 0; |
185 | } | 186 | } |
186 | 187 | ||
187 | /** | 188 | /** |
@@ -263,7 +264,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) | |||
263 | } | 264 | } |
264 | 265 | ||
265 | /** | 266 | /** |
266 | * \c nopage method for DMA virtual memory. | 267 | * \c fault method for DMA virtual memory. |
267 | * | 268 | * |
268 | * \param vma virtual memory area. | 269 | * \param vma virtual memory area. |
269 | * \param address access address. | 270 | * \param address access address. |
@@ -271,8 +272,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) | |||
271 | * | 272 | * |
272 | * Determine the page number from the page offset and get it from drm_device_dma::pagelist. | 273 | * Determine the page number from the page offset and get it from drm_device_dma::pagelist. |
273 | */ | 274 | */ |
274 | static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma, | 275 | static int drm_do_vm_dma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
275 | unsigned long address) | ||
276 | { | 276 | { |
277 | struct drm_file *priv = vma->vm_file->private_data; | 277 | struct drm_file *priv = vma->vm_file->private_data; |
278 | struct drm_device *dev = priv->head->dev; | 278 | struct drm_device *dev = priv->head->dev; |
@@ -282,24 +282,23 @@ static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma, | |||
282 | struct page *page; | 282 | struct page *page; |
283 | 283 | ||
284 | if (!dma) | 284 | if (!dma) |
285 | return NOPAGE_SIGBUS; /* Error */ | 285 | return VM_FAULT_SIGBUS; /* Error */ |
286 | if (address > vma->vm_end) | ||
287 | return NOPAGE_SIGBUS; /* Disallow mremap */ | ||
288 | if (!dma->pagelist) | 286 | if (!dma->pagelist) |
289 | return NOPAGE_SIGBUS; /* Nothing allocated */ | 287 | return VM_FAULT_SIGBUS; /* Nothing allocated */ |
290 | 288 | ||
291 | offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */ | 289 | offset = (unsigned long)vmf->virtual_address - vma->vm_start; /* vm_[pg]off[set] should be 0 */ |
292 | page_nr = offset >> PAGE_SHIFT; | 290 | page_nr = offset >> PAGE_SHIFT; /* page_nr could just be vmf->pgoff */ |
293 | page = virt_to_page((dma->pagelist[page_nr] + (offset & (~PAGE_MASK)))); | 291 | page = virt_to_page((dma->pagelist[page_nr] + (offset & (~PAGE_MASK)))); |
294 | 292 | ||
295 | get_page(page); | 293 | get_page(page); |
294 | vmf->page = page; | ||
296 | 295 | ||
297 | DRM_DEBUG("0x%lx (page %lu)\n", address, page_nr); | 296 | DRM_DEBUG("dma_fault 0x%lx (page %lu)\n", offset, page_nr); |
298 | return page; | 297 | return 0; |
299 | } | 298 | } |
300 | 299 | ||
301 | /** | 300 | /** |
302 | * \c nopage method for scatter-gather virtual memory. | 301 | * \c fault method for scatter-gather virtual memory. |
303 | * | 302 | * |
304 | * \param vma virtual memory area. | 303 | * \param vma virtual memory area. |
305 | * \param address access address. | 304 | * \param address access address. |
@@ -307,8 +306,7 @@ static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma, | |||
307 | * | 306 | * |
308 | * Determine the map offset from the page offset and get it from drm_sg_mem::pagelist. | 307 | * Determine the map offset from the page offset and get it from drm_sg_mem::pagelist. |
309 | */ | 308 | */ |
310 | static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma, | 309 | static int drm_do_vm_sg_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
311 | unsigned long address) | ||
312 | { | 310 | { |
313 | struct drm_map *map = (struct drm_map *) vma->vm_private_data; | 311 | struct drm_map *map = (struct drm_map *) vma->vm_private_data; |
314 | struct drm_file *priv = vma->vm_file->private_data; | 312 | struct drm_file *priv = vma->vm_file->private_data; |
@@ -320,77 +318,64 @@ static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma, | |||
320 | struct page *page; | 318 | struct page *page; |
321 | 319 | ||
322 | if (!entry) | 320 | if (!entry) |
323 | return NOPAGE_SIGBUS; /* Error */ | 321 | return VM_FAULT_SIGBUS; /* Error */ |
324 | if (address > vma->vm_end) | ||
325 | return NOPAGE_SIGBUS; /* Disallow mremap */ | ||
326 | if (!entry->pagelist) | 322 | if (!entry->pagelist) |
327 | return NOPAGE_SIGBUS; /* Nothing allocated */ | 323 | return VM_FAULT_SIGBUS; /* Nothing allocated */ |
328 | 324 | ||
329 | offset = address - vma->vm_start; | 325 | offset = (unsigned long)vmf->virtual_address - vma->vm_start; |
330 | map_offset = map->offset - (unsigned long)dev->sg->virtual; | 326 | map_offset = map->offset - (unsigned long)dev->sg->virtual; |
331 | page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT); | 327 | page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT); |
332 | page = entry->pagelist[page_offset]; | 328 | page = entry->pagelist[page_offset]; |
333 | get_page(page); | 329 | get_page(page); |
330 | vmf->page = page; | ||
334 | 331 | ||
335 | return page; | 332 | return 0; |
336 | } | 333 | } |
337 | 334 | ||
338 | static struct page *drm_vm_nopage(struct vm_area_struct *vma, | 335 | static int drm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
339 | unsigned long address, int *type) | ||
340 | { | 336 | { |
341 | if (type) | 337 | return drm_do_vm_fault(vma, vmf); |
342 | *type = VM_FAULT_MINOR; | ||
343 | return drm_do_vm_nopage(vma, address); | ||
344 | } | 338 | } |
345 | 339 | ||
346 | static struct page *drm_vm_shm_nopage(struct vm_area_struct *vma, | 340 | static int drm_vm_shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
347 | unsigned long address, int *type) | ||
348 | { | 341 | { |
349 | if (type) | 342 | return drm_do_vm_shm_fault(vma, vmf); |
350 | *type = VM_FAULT_MINOR; | ||
351 | return drm_do_vm_shm_nopage(vma, address); | ||
352 | } | 343 | } |
353 | 344 | ||
354 | static struct page *drm_vm_dma_nopage(struct vm_area_struct *vma, | 345 | static int drm_vm_dma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
355 | unsigned long address, int *type) | ||
356 | { | 346 | { |
357 | if (type) | 347 | return drm_do_vm_dma_fault(vma, vmf); |
358 | *type = VM_FAULT_MINOR; | ||
359 | return drm_do_vm_dma_nopage(vma, address); | ||
360 | } | 348 | } |
361 | 349 | ||
362 | static struct page *drm_vm_sg_nopage(struct vm_area_struct *vma, | 350 | static int drm_vm_sg_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
363 | unsigned long address, int *type) | ||
364 | { | 351 | { |
365 | if (type) | 352 | return drm_do_vm_sg_fault(vma, vmf); |
366 | *type = VM_FAULT_MINOR; | ||
367 | return drm_do_vm_sg_nopage(vma, address); | ||
368 | } | 353 | } |
369 | 354 | ||
370 | /** AGP virtual memory operations */ | 355 | /** AGP virtual memory operations */ |
371 | static struct vm_operations_struct drm_vm_ops = { | 356 | static struct vm_operations_struct drm_vm_ops = { |
372 | .nopage = drm_vm_nopage, | 357 | .fault = drm_vm_fault, |
373 | .open = drm_vm_open, | 358 | .open = drm_vm_open, |
374 | .close = drm_vm_close, | 359 | .close = drm_vm_close, |
375 | }; | 360 | }; |
376 | 361 | ||
377 | /** Shared virtual memory operations */ | 362 | /** Shared virtual memory operations */ |
378 | static struct vm_operations_struct drm_vm_shm_ops = { | 363 | static struct vm_operations_struct drm_vm_shm_ops = { |
379 | .nopage = drm_vm_shm_nopage, | 364 | .fault = drm_vm_shm_fault, |
380 | .open = drm_vm_open, | 365 | .open = drm_vm_open, |
381 | .close = drm_vm_shm_close, | 366 | .close = drm_vm_shm_close, |
382 | }; | 367 | }; |
383 | 368 | ||
384 | /** DMA virtual memory operations */ | 369 | /** DMA virtual memory operations */ |
385 | static struct vm_operations_struct drm_vm_dma_ops = { | 370 | static struct vm_operations_struct drm_vm_dma_ops = { |
386 | .nopage = drm_vm_dma_nopage, | 371 | .fault = drm_vm_dma_fault, |
387 | .open = drm_vm_open, | 372 | .open = drm_vm_open, |
388 | .close = drm_vm_close, | 373 | .close = drm_vm_close, |
389 | }; | 374 | }; |
390 | 375 | ||
391 | /** Scatter-gather virtual memory operations */ | 376 | /** Scatter-gather virtual memory operations */ |
392 | static struct vm_operations_struct drm_vm_sg_ops = { | 377 | static struct vm_operations_struct drm_vm_sg_ops = { |
393 | .nopage = drm_vm_sg_nopage, | 378 | .fault = drm_vm_sg_fault, |
394 | .open = drm_vm_open, | 379 | .open = drm_vm_open, |
395 | .close = drm_vm_close, | 380 | .close = drm_vm_close, |
396 | }; | 381 | }; |
@@ -604,7 +589,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma) | |||
604 | /* | 589 | /* |
605 | * On some platforms we can't talk to bus dma address from the CPU, so for | 590 | * On some platforms we can't talk to bus dma address from the CPU, so for |
606 | * memory of type DRM_AGP, we'll deal with sorting out the real physical | 591 | * memory of type DRM_AGP, we'll deal with sorting out the real physical |
607 | * pages and mappings in nopage() | 592 | * pages and mappings in fault() |
608 | */ | 593 | */ |
609 | #if defined(__powerpc__) | 594 | #if defined(__powerpc__) |
610 | pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE; | 595 | pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE; |
@@ -634,7 +619,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma) | |||
634 | break; | 619 | break; |
635 | case _DRM_CONSISTENT: | 620 | case _DRM_CONSISTENT: |
636 | /* Consistent memory is really like shared memory. But | 621 | /* Consistent memory is really like shared memory. But |
637 | * it's allocated in a different way, so avoid nopage */ | 622 | * it's allocated in a different way, so avoid fault */ |
638 | if (remap_pfn_range(vma, vma->vm_start, | 623 | if (remap_pfn_range(vma, vma->vm_start, |
639 | page_to_pfn(virt_to_page(map->handle)), | 624 | page_to_pfn(virt_to_page(map->handle)), |
640 | vma->vm_end - vma->vm_start, vma->vm_page_prot)) | 625 | vma->vm_end - vma->vm_start, vma->vm_page_prot)) |
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index 379cbdad4921..9df08105f4f3 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include "i830_drm.h" | 36 | #include "i830_drm.h" |
37 | #include "i830_drv.h" | 37 | #include "i830_drv.h" |
38 | #include <linux/interrupt.h> /* For task queue support */ | 38 | #include <linux/interrupt.h> /* For task queue support */ |
39 | #include <linux/pagemap.h> /* For FASTCALL on unlock_page() */ | 39 | #include <linux/pagemap.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
42 | 42 | ||
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c index 43986d81ae34..e9d6663bec73 100644 --- a/drivers/char/drm/i915_dma.c +++ b/drivers/char/drm/i915_dma.c | |||
@@ -171,7 +171,7 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init) | |||
171 | dev_priv->allow_batchbuffer = 1; | 171 | dev_priv->allow_batchbuffer = 1; |
172 | 172 | ||
173 | /* Program Hardware Status Page */ | 173 | /* Program Hardware Status Page */ |
174 | if (!IS_G33(dev)) { | 174 | if (!I915_NEED_GFX_HWS(dev)) { |
175 | dev_priv->status_page_dmah = | 175 | dev_priv->status_page_dmah = |
176 | drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff); | 176 | drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff); |
177 | 177 | ||
@@ -720,6 +720,9 @@ static int i915_set_status_page(struct drm_device *dev, void *data, | |||
720 | drm_i915_private_t *dev_priv = dev->dev_private; | 720 | drm_i915_private_t *dev_priv = dev->dev_private; |
721 | drm_i915_hws_addr_t *hws = data; | 721 | drm_i915_hws_addr_t *hws = data; |
722 | 722 | ||
723 | if (!I915_NEED_GFX_HWS(dev)) | ||
724 | return -EINVAL; | ||
725 | |||
723 | if (!dev_priv) { | 726 | if (!dev_priv) { |
724 | DRM_ERROR("called with no initialization\n"); | 727 | DRM_ERROR("called with no initialization\n"); |
725 | return -EINVAL; | 728 | return -EINVAL; |
diff --git a/drivers/char/drm/i915_drv.c b/drivers/char/drm/i915_drv.c index 52e51033d32c..b2b451dc4460 100644 --- a/drivers/char/drm/i915_drv.c +++ b/drivers/char/drm/i915_drv.c | |||
@@ -160,6 +160,7 @@ static void i915_save_vga(struct drm_device *dev) | |||
160 | dev_priv->saveAR[i] = i915_read_ar(st01, i, 0); | 160 | dev_priv->saveAR[i] = i915_read_ar(st01, i, 0); |
161 | inb(st01); | 161 | inb(st01); |
162 | outb(dev_priv->saveAR_INDEX, VGA_AR_INDEX); | 162 | outb(dev_priv->saveAR_INDEX, VGA_AR_INDEX); |
163 | inb(st01); | ||
163 | 164 | ||
164 | /* Graphics controller registers */ | 165 | /* Graphics controller registers */ |
165 | for (i = 0; i < 9; i++) | 166 | for (i = 0; i < 9; i++) |
@@ -221,10 +222,12 @@ static void i915_restore_vga(struct drm_device *dev) | |||
221 | dev_priv->saveGR[0x18]); | 222 | dev_priv->saveGR[0x18]); |
222 | 223 | ||
223 | /* Attribute controller registers */ | 224 | /* Attribute controller registers */ |
225 | inb(st01); | ||
224 | for (i = 0; i < 20; i++) | 226 | for (i = 0; i < 20; i++) |
225 | i915_write_ar(st01, i, dev_priv->saveAR[i], 0); | 227 | i915_write_ar(st01, i, dev_priv->saveAR[i], 0); |
226 | inb(st01); /* switch back to index mode */ | 228 | inb(st01); /* switch back to index mode */ |
227 | outb(dev_priv->saveAR_INDEX | 0x20, VGA_AR_INDEX); | 229 | outb(dev_priv->saveAR_INDEX | 0x20, VGA_AR_INDEX); |
230 | inb(st01); | ||
228 | 231 | ||
229 | /* VGA color palette registers */ | 232 | /* VGA color palette registers */ |
230 | outb(dev_priv->saveDACMASK, VGA_DACMASK); | 233 | outb(dev_priv->saveDACMASK, VGA_DACMASK); |
@@ -236,7 +239,7 @@ static void i915_restore_vga(struct drm_device *dev) | |||
236 | 239 | ||
237 | } | 240 | } |
238 | 241 | ||
239 | static int i915_suspend(struct drm_device *dev) | 242 | static int i915_suspend(struct drm_device *dev, pm_message_t state) |
240 | { | 243 | { |
241 | struct drm_i915_private *dev_priv = dev->dev_private; | 244 | struct drm_i915_private *dev_priv = dev->dev_private; |
242 | int i; | 245 | int i; |
@@ -247,6 +250,9 @@ static int i915_suspend(struct drm_device *dev) | |||
247 | return -ENODEV; | 250 | return -ENODEV; |
248 | } | 251 | } |
249 | 252 | ||
253 | if (state.event == PM_EVENT_PRETHAW) | ||
254 | return 0; | ||
255 | |||
250 | pci_save_state(dev->pdev); | 256 | pci_save_state(dev->pdev); |
251 | pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB); | 257 | pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB); |
252 | 258 | ||
@@ -276,6 +282,7 @@ static int i915_suspend(struct drm_device *dev) | |||
276 | dev_priv->saveDSPATILEOFF = I915_READ(DSPATILEOFF); | 282 | dev_priv->saveDSPATILEOFF = I915_READ(DSPATILEOFF); |
277 | } | 283 | } |
278 | i915_save_palette(dev, PIPE_A); | 284 | i915_save_palette(dev, PIPE_A); |
285 | dev_priv->savePIPEASTAT = I915_READ(I915REG_PIPEASTAT); | ||
279 | 286 | ||
280 | /* Pipe & plane B info */ | 287 | /* Pipe & plane B info */ |
281 | dev_priv->savePIPEBCONF = I915_READ(PIPEBCONF); | 288 | dev_priv->savePIPEBCONF = I915_READ(PIPEBCONF); |
@@ -303,6 +310,7 @@ static int i915_suspend(struct drm_device *dev) | |||
303 | dev_priv->saveDSPBTILEOFF = I915_READ(DSPBTILEOFF); | 310 | dev_priv->saveDSPBTILEOFF = I915_READ(DSPBTILEOFF); |
304 | } | 311 | } |
305 | i915_save_palette(dev, PIPE_B); | 312 | i915_save_palette(dev, PIPE_B); |
313 | dev_priv->savePIPEBSTAT = I915_READ(I915REG_PIPEBSTAT); | ||
306 | 314 | ||
307 | /* CRT state */ | 315 | /* CRT state */ |
308 | dev_priv->saveADPA = I915_READ(ADPA); | 316 | dev_priv->saveADPA = I915_READ(ADPA); |
@@ -329,12 +337,26 @@ static int i915_suspend(struct drm_device *dev) | |||
329 | dev_priv->saveFBC_CONTROL2 = I915_READ(FBC_CONTROL2); | 337 | dev_priv->saveFBC_CONTROL2 = I915_READ(FBC_CONTROL2); |
330 | dev_priv->saveFBC_CONTROL = I915_READ(FBC_CONTROL); | 338 | dev_priv->saveFBC_CONTROL = I915_READ(FBC_CONTROL); |
331 | 339 | ||
340 | /* Interrupt state */ | ||
341 | dev_priv->saveIIR = I915_READ(I915REG_INT_IDENTITY_R); | ||
342 | dev_priv->saveIER = I915_READ(I915REG_INT_ENABLE_R); | ||
343 | dev_priv->saveIMR = I915_READ(I915REG_INT_MASK_R); | ||
344 | |||
332 | /* VGA state */ | 345 | /* VGA state */ |
333 | dev_priv->saveVCLK_DIVISOR_VGA0 = I915_READ(VCLK_DIVISOR_VGA0); | 346 | dev_priv->saveVCLK_DIVISOR_VGA0 = I915_READ(VCLK_DIVISOR_VGA0); |
334 | dev_priv->saveVCLK_DIVISOR_VGA1 = I915_READ(VCLK_DIVISOR_VGA1); | 347 | dev_priv->saveVCLK_DIVISOR_VGA1 = I915_READ(VCLK_DIVISOR_VGA1); |
335 | dev_priv->saveVCLK_POST_DIV = I915_READ(VCLK_POST_DIV); | 348 | dev_priv->saveVCLK_POST_DIV = I915_READ(VCLK_POST_DIV); |
336 | dev_priv->saveVGACNTRL = I915_READ(VGACNTRL); | 349 | dev_priv->saveVGACNTRL = I915_READ(VGACNTRL); |
337 | 350 | ||
351 | /* Clock gating state */ | ||
352 | dev_priv->saveDSPCLK_GATE_D = I915_READ(DSPCLK_GATE_D); | ||
353 | |||
354 | /* Cache mode state */ | ||
355 | dev_priv->saveCACHE_MODE_0 = I915_READ(CACHE_MODE_0); | ||
356 | |||
357 | /* Memory Arbitration state */ | ||
358 | dev_priv->saveMI_ARB_STATE = I915_READ(MI_ARB_STATE); | ||
359 | |||
338 | /* Scratch space */ | 360 | /* Scratch space */ |
339 | for (i = 0; i < 16; i++) { | 361 | for (i = 0; i < 16; i++) { |
340 | dev_priv->saveSWF0[i] = I915_READ(SWF0 + (i << 2)); | 362 | dev_priv->saveSWF0[i] = I915_READ(SWF0 + (i << 2)); |
@@ -345,9 +367,11 @@ static int i915_suspend(struct drm_device *dev) | |||
345 | 367 | ||
346 | i915_save_vga(dev); | 368 | i915_save_vga(dev); |
347 | 369 | ||
348 | /* Shut down the device */ | 370 | if (state.event == PM_EVENT_SUSPEND) { |
349 | pci_disable_device(dev->pdev); | 371 | /* Shut down the device */ |
350 | pci_set_power_state(dev->pdev, PCI_D3hot); | 372 | pci_disable_device(dev->pdev); |
373 | pci_set_power_state(dev->pdev, PCI_D3hot); | ||
374 | } | ||
351 | 375 | ||
352 | return 0; | 376 | return 0; |
353 | } | 377 | } |
@@ -400,9 +424,7 @@ static int i915_resume(struct drm_device *dev) | |||
400 | I915_WRITE(DSPATILEOFF, dev_priv->saveDSPATILEOFF); | 424 | I915_WRITE(DSPATILEOFF, dev_priv->saveDSPATILEOFF); |
401 | } | 425 | } |
402 | 426 | ||
403 | if ((dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) && | 427 | I915_WRITE(PIPEACONF, dev_priv->savePIPEACONF); |
404 | (dev_priv->saveDPLL_A & DPLL_VGA_MODE_DIS)) | ||
405 | I915_WRITE(PIPEACONF, dev_priv->savePIPEACONF); | ||
406 | 428 | ||
407 | i915_restore_palette(dev, PIPE_A); | 429 | i915_restore_palette(dev, PIPE_A); |
408 | /* Enable the plane */ | 430 | /* Enable the plane */ |
@@ -444,10 +466,9 @@ static int i915_resume(struct drm_device *dev) | |||
444 | I915_WRITE(DSPBTILEOFF, dev_priv->saveDSPBTILEOFF); | 466 | I915_WRITE(DSPBTILEOFF, dev_priv->saveDSPBTILEOFF); |
445 | } | 467 | } |
446 | 468 | ||
447 | if ((dev_priv->saveDPLL_B & DPLL_VCO_ENABLE) && | 469 | I915_WRITE(PIPEBCONF, dev_priv->savePIPEBCONF); |
448 | (dev_priv->saveDPLL_B & DPLL_VGA_MODE_DIS)) | 470 | |
449 | I915_WRITE(PIPEBCONF, dev_priv->savePIPEBCONF); | 471 | i915_restore_palette(dev, PIPE_B); |
450 | i915_restore_palette(dev, PIPE_A); | ||
451 | /* Enable the plane */ | 472 | /* Enable the plane */ |
452 | I915_WRITE(DSPBCNTR, dev_priv->saveDSPBCNTR); | 473 | I915_WRITE(DSPBCNTR, dev_priv->saveDSPBCNTR); |
453 | I915_WRITE(DSPBBASE, I915_READ(DSPBBASE)); | 474 | I915_WRITE(DSPBBASE, I915_READ(DSPBBASE)); |
@@ -485,6 +506,15 @@ static int i915_resume(struct drm_device *dev) | |||
485 | I915_WRITE(VCLK_POST_DIV, dev_priv->saveVCLK_POST_DIV); | 506 | I915_WRITE(VCLK_POST_DIV, dev_priv->saveVCLK_POST_DIV); |
486 | udelay(150); | 507 | udelay(150); |
487 | 508 | ||
509 | /* Clock gating state */ | ||
510 | I915_WRITE (DSPCLK_GATE_D, dev_priv->saveDSPCLK_GATE_D); | ||
511 | |||
512 | /* Cache mode state */ | ||
513 | I915_WRITE (CACHE_MODE_0, dev_priv->saveCACHE_MODE_0 | 0xffff0000); | ||
514 | |||
515 | /* Memory arbitration state */ | ||
516 | I915_WRITE (MI_ARB_STATE, dev_priv->saveMI_ARB_STATE | 0xffff0000); | ||
517 | |||
488 | for (i = 0; i < 16; i++) { | 518 | for (i = 0; i < 16; i++) { |
489 | I915_WRITE(SWF0 + (i << 2), dev_priv->saveSWF0[i]); | 519 | I915_WRITE(SWF0 + (i << 2), dev_priv->saveSWF0[i]); |
490 | I915_WRITE(SWF10 + (i << 2), dev_priv->saveSWF1[i+7]); | 520 | I915_WRITE(SWF10 + (i << 2), dev_priv->saveSWF1[i+7]); |
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h index f8308bfb2613..c10d128e34db 100644 --- a/drivers/char/drm/i915_drv.h +++ b/drivers/char/drm/i915_drv.h | |||
@@ -134,6 +134,7 @@ typedef struct drm_i915_private { | |||
134 | u32 saveVBLANK_A; | 134 | u32 saveVBLANK_A; |
135 | u32 saveVSYNC_A; | 135 | u32 saveVSYNC_A; |
136 | u32 saveBCLRPAT_A; | 136 | u32 saveBCLRPAT_A; |
137 | u32 savePIPEASTAT; | ||
137 | u32 saveDSPASTRIDE; | 138 | u32 saveDSPASTRIDE; |
138 | u32 saveDSPASIZE; | 139 | u32 saveDSPASIZE; |
139 | u32 saveDSPAPOS; | 140 | u32 saveDSPAPOS; |
@@ -154,6 +155,7 @@ typedef struct drm_i915_private { | |||
154 | u32 saveVBLANK_B; | 155 | u32 saveVBLANK_B; |
155 | u32 saveVSYNC_B; | 156 | u32 saveVSYNC_B; |
156 | u32 saveBCLRPAT_B; | 157 | u32 saveBCLRPAT_B; |
158 | u32 savePIPEBSTAT; | ||
157 | u32 saveDSPBSTRIDE; | 159 | u32 saveDSPBSTRIDE; |
158 | u32 saveDSPBSIZE; | 160 | u32 saveDSPBSIZE; |
159 | u32 saveDSPBPOS; | 161 | u32 saveDSPBPOS; |
@@ -182,6 +184,12 @@ typedef struct drm_i915_private { | |||
182 | u32 saveFBC_LL_BASE; | 184 | u32 saveFBC_LL_BASE; |
183 | u32 saveFBC_CONTROL; | 185 | u32 saveFBC_CONTROL; |
184 | u32 saveFBC_CONTROL2; | 186 | u32 saveFBC_CONTROL2; |
187 | u32 saveIER; | ||
188 | u32 saveIIR; | ||
189 | u32 saveIMR; | ||
190 | u32 saveCACHE_MODE_0; | ||
191 | u32 saveDSPCLK_GATE_D; | ||
192 | u32 saveMI_ARB_STATE; | ||
185 | u32 saveSWF0[16]; | 193 | u32 saveSWF0[16]; |
186 | u32 saveSWF1[16]; | 194 | u32 saveSWF1[16]; |
187 | u32 saveSWF2[3]; | 195 | u32 saveSWF2[3]; |
@@ -450,6 +458,10 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller); | |||
450 | */ | 458 | */ |
451 | #define DMA_FADD_S 0x20d4 | 459 | #define DMA_FADD_S 0x20d4 |
452 | 460 | ||
461 | /* Memory Interface Arbitration State | ||
462 | */ | ||
463 | #define MI_ARB_STATE 0x20e4 | ||
464 | |||
453 | /* Cache mode 0 reg. | 465 | /* Cache mode 0 reg. |
454 | * - Manipulating render cache behaviour is central | 466 | * - Manipulating render cache behaviour is central |
455 | * to the concept of zone rendering, tuning this reg can help avoid | 467 | * to the concept of zone rendering, tuning this reg can help avoid |
@@ -460,6 +472,7 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller); | |||
460 | * bit of interest either set or cleared. EG: (BIT<<16) | BIT to set. | 472 | * bit of interest either set or cleared. EG: (BIT<<16) | BIT to set. |
461 | */ | 473 | */ |
462 | #define Cache_Mode_0 0x2120 | 474 | #define Cache_Mode_0 0x2120 |
475 | #define CACHE_MODE_0 0x2120 | ||
463 | #define CM0_MASK_SHIFT 16 | 476 | #define CM0_MASK_SHIFT 16 |
464 | #define CM0_IZ_OPT_DISABLE (1<<6) | 477 | #define CM0_IZ_OPT_DISABLE (1<<6) |
465 | #define CM0_ZR_OPT_DISABLE (1<<5) | 478 | #define CM0_ZR_OPT_DISABLE (1<<5) |
@@ -655,6 +668,8 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller); | |||
655 | /** P1 value is 2 greater than this field */ | 668 | /** P1 value is 2 greater than this field */ |
656 | # define VGA0_PD_P1_MASK (0x1f << 0) | 669 | # define VGA0_PD_P1_MASK (0x1f << 0) |
657 | 670 | ||
671 | #define DSPCLK_GATE_D 0x6200 | ||
672 | |||
658 | /* I830 CRTC registers */ | 673 | /* I830 CRTC registers */ |
659 | #define HTOTAL_A 0x60000 | 674 | #define HTOTAL_A 0x60000 |
660 | #define HBLANK_A 0x60004 | 675 | #define HBLANK_A 0x60004 |
@@ -1101,6 +1116,8 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller); | |||
1101 | #define IS_MOBILE(dev) (IS_I830(dev) || IS_I85X(dev) || IS_I915GM(dev) || \ | 1116 | #define IS_MOBILE(dev) (IS_I830(dev) || IS_I85X(dev) || IS_I915GM(dev) || \ |
1102 | IS_I945GM(dev) || IS_I965GM(dev) || IS_IGD_GM(dev)) | 1117 | IS_I945GM(dev) || IS_I965GM(dev) || IS_IGD_GM(dev)) |
1103 | 1118 | ||
1119 | #define I915_NEED_GFX_HWS(dev) (IS_G33(dev) || IS_IGD_GM(dev)) | ||
1120 | |||
1104 | #define PRIMARY_RINGBUFFER_SIZE (128*1024) | 1121 | #define PRIMARY_RINGBUFFER_SIZE (128*1024) |
1105 | 1122 | ||
1106 | #endif | 1123 | #endif |
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c index 5dc799ab86b8..833abc7e55fb 100644 --- a/drivers/char/drm/radeon_cp.c +++ b/drivers/char/drm/radeon_cp.c | |||
@@ -825,11 +825,19 @@ static u32 RADEON_READ_MCIND(drm_radeon_private_t *dev_priv, int addr) | |||
825 | return ret; | 825 | return ret; |
826 | } | 826 | } |
827 | 827 | ||
828 | static u32 RS690_READ_MCIND(drm_radeon_private_t *dev_priv, int addr) | ||
829 | { | ||
830 | RADEON_WRITE(RS690_MC_INDEX, (addr & RS690_MC_INDEX_MASK)); | ||
831 | return RADEON_READ(RS690_MC_DATA); | ||
832 | } | ||
833 | |||
828 | u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv) | 834 | u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv) |
829 | { | 835 | { |
830 | 836 | ||
831 | if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) | 837 | if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) |
832 | return RADEON_READ_MCIND(dev_priv, RV515_MC_FB_LOCATION); | 838 | return RADEON_READ_MCIND(dev_priv, RV515_MC_FB_LOCATION); |
839 | else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) | ||
840 | return RS690_READ_MCIND(dev_priv, RS690_MC_FB_LOCATION); | ||
833 | else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) | 841 | else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) |
834 | return RADEON_READ_MCIND(dev_priv, R520_MC_FB_LOCATION); | 842 | return RADEON_READ_MCIND(dev_priv, R520_MC_FB_LOCATION); |
835 | else | 843 | else |
@@ -840,6 +848,8 @@ static void radeon_write_fb_location(drm_radeon_private_t *dev_priv, u32 fb_loc) | |||
840 | { | 848 | { |
841 | if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) | 849 | if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) |
842 | RADEON_WRITE_MCIND(RV515_MC_FB_LOCATION, fb_loc); | 850 | RADEON_WRITE_MCIND(RV515_MC_FB_LOCATION, fb_loc); |
851 | else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) | ||
852 | RS690_WRITE_MCIND(RS690_MC_FB_LOCATION, fb_loc); | ||
843 | else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) | 853 | else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) |
844 | RADEON_WRITE_MCIND(R520_MC_FB_LOCATION, fb_loc); | 854 | RADEON_WRITE_MCIND(R520_MC_FB_LOCATION, fb_loc); |
845 | else | 855 | else |
@@ -850,6 +860,8 @@ static void radeon_write_agp_location(drm_radeon_private_t *dev_priv, u32 agp_lo | |||
850 | { | 860 | { |
851 | if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) | 861 | if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) |
852 | RADEON_WRITE_MCIND(RV515_MC_AGP_LOCATION, agp_loc); | 862 | RADEON_WRITE_MCIND(RV515_MC_AGP_LOCATION, agp_loc); |
863 | else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) | ||
864 | RS690_WRITE_MCIND(RS690_MC_AGP_LOCATION, agp_loc); | ||
853 | else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) | 865 | else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) |
854 | RADEON_WRITE_MCIND(R520_MC_AGP_LOCATION, agp_loc); | 866 | RADEON_WRITE_MCIND(R520_MC_AGP_LOCATION, agp_loc); |
855 | else | 867 | else |
@@ -1362,6 +1374,70 @@ static void radeon_set_igpgart(drm_radeon_private_t * dev_priv, int on) | |||
1362 | } | 1374 | } |
1363 | } | 1375 | } |
1364 | 1376 | ||
1377 | /* Enable or disable RS690 GART on the chip */ | ||
1378 | static void radeon_set_rs690gart(drm_radeon_private_t *dev_priv, int on) | ||
1379 | { | ||
1380 | u32 temp; | ||
1381 | |||
1382 | if (on) { | ||
1383 | DRM_DEBUG("programming rs690 gart %08X %08lX %08X\n", | ||
1384 | dev_priv->gart_vm_start, | ||
1385 | (long)dev_priv->gart_info.bus_addr, | ||
1386 | dev_priv->gart_size); | ||
1387 | |||
1388 | temp = RS690_READ_MCIND(dev_priv, RS690_MC_MISC_CNTL); | ||
1389 | RS690_WRITE_MCIND(RS690_MC_MISC_CNTL, 0x5000); | ||
1390 | |||
1391 | RS690_WRITE_MCIND(RS690_MC_AGP_SIZE, | ||
1392 | RS690_MC_GART_EN | RS690_MC_AGP_SIZE_32MB); | ||
1393 | |||
1394 | temp = RS690_READ_MCIND(dev_priv, RS690_MC_GART_FEATURE_ID); | ||
1395 | RS690_WRITE_MCIND(RS690_MC_GART_FEATURE_ID, 0x42040800); | ||
1396 | |||
1397 | RS690_WRITE_MCIND(RS690_MC_GART_BASE, | ||
1398 | dev_priv->gart_info.bus_addr); | ||
1399 | |||
1400 | temp = RS690_READ_MCIND(dev_priv, RS690_MC_AGP_MODE_CONTROL); | ||
1401 | RS690_WRITE_MCIND(RS690_MC_AGP_MODE_CONTROL, 0x01400000); | ||
1402 | |||
1403 | RS690_WRITE_MCIND(RS690_MC_AGP_BASE, | ||
1404 | (unsigned int)dev_priv->gart_vm_start); | ||
1405 | |||
1406 | dev_priv->gart_size = 32*1024*1024; | ||
1407 | temp = (((dev_priv->gart_vm_start - 1 + dev_priv->gart_size) & | ||
1408 | 0xffff0000) | (dev_priv->gart_vm_start >> 16)); | ||
1409 | |||
1410 | RS690_WRITE_MCIND(RS690_MC_AGP_LOCATION, temp); | ||
1411 | |||
1412 | temp = RS690_READ_MCIND(dev_priv, RS690_MC_AGP_SIZE); | ||
1413 | RS690_WRITE_MCIND(RS690_MC_AGP_SIZE, | ||
1414 | RS690_MC_GART_EN | RS690_MC_AGP_SIZE_32MB); | ||
1415 | |||
1416 | do { | ||
1417 | temp = RS690_READ_MCIND(dev_priv, RS690_MC_GART_CACHE_CNTL); | ||
1418 | if ((temp & RS690_MC_GART_CLEAR_STATUS) == | ||
1419 | RS690_MC_GART_CLEAR_DONE) | ||
1420 | break; | ||
1421 | DRM_UDELAY(1); | ||
1422 | } while (1); | ||
1423 | |||
1424 | RS690_WRITE_MCIND(RS690_MC_GART_CACHE_CNTL, | ||
1425 | RS690_MC_GART_CC_CLEAR); | ||
1426 | do { | ||
1427 | temp = RS690_READ_MCIND(dev_priv, RS690_MC_GART_CACHE_CNTL); | ||
1428 | if ((temp & RS690_MC_GART_CLEAR_STATUS) == | ||
1429 | RS690_MC_GART_CLEAR_DONE) | ||
1430 | break; | ||
1431 | DRM_UDELAY(1); | ||
1432 | } while (1); | ||
1433 | |||
1434 | RS690_WRITE_MCIND(RS690_MC_GART_CACHE_CNTL, | ||
1435 | RS690_MC_GART_CC_NO_CHANGE); | ||
1436 | } else { | ||
1437 | RS690_WRITE_MCIND(RS690_MC_AGP_SIZE, RS690_MC_GART_DIS); | ||
1438 | } | ||
1439 | } | ||
1440 | |||
1365 | static void radeon_set_pciegart(drm_radeon_private_t * dev_priv, int on) | 1441 | static void radeon_set_pciegart(drm_radeon_private_t * dev_priv, int on) |
1366 | { | 1442 | { |
1367 | u32 tmp = RADEON_READ_PCIE(dev_priv, RADEON_PCIE_TX_GART_CNTL); | 1443 | u32 tmp = RADEON_READ_PCIE(dev_priv, RADEON_PCIE_TX_GART_CNTL); |
@@ -1396,6 +1472,11 @@ static void radeon_set_pcigart(drm_radeon_private_t * dev_priv, int on) | |||
1396 | { | 1472 | { |
1397 | u32 tmp; | 1473 | u32 tmp; |
1398 | 1474 | ||
1475 | if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) { | ||
1476 | radeon_set_rs690gart(dev_priv, on); | ||
1477 | return; | ||
1478 | } | ||
1479 | |||
1399 | if (dev_priv->flags & RADEON_IS_IGPGART) { | 1480 | if (dev_priv->flags & RADEON_IS_IGPGART) { |
1400 | radeon_set_igpgart(dev_priv, on); | 1481 | radeon_set_igpgart(dev_priv, on); |
1401 | return; | 1482 | return; |
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h index 4434332c79bc..173ae620223a 100644 --- a/drivers/char/drm/radeon_drv.h +++ b/drivers/char/drm/radeon_drv.h | |||
@@ -123,6 +123,7 @@ enum radeon_family { | |||
123 | CHIP_R420, | 123 | CHIP_R420, |
124 | CHIP_RV410, | 124 | CHIP_RV410, |
125 | CHIP_RS400, | 125 | CHIP_RS400, |
126 | CHIP_RS690, | ||
126 | CHIP_RV515, | 127 | CHIP_RV515, |
127 | CHIP_R520, | 128 | CHIP_R520, |
128 | CHIP_RV530, | 129 | CHIP_RV530, |
@@ -467,6 +468,36 @@ extern int r300_do_cp_cmdbuf(struct drm_device * dev, | |||
467 | #define RADEON_IGPGART_ENABLE 0x38 | 468 | #define RADEON_IGPGART_ENABLE 0x38 |
468 | #define RADEON_IGPGART_UNK_39 0x39 | 469 | #define RADEON_IGPGART_UNK_39 0x39 |
469 | 470 | ||
471 | #define RS690_MC_INDEX 0x78 | ||
472 | # define RS690_MC_INDEX_MASK 0x1ff | ||
473 | # define RS690_MC_INDEX_WR_EN (1 << 9) | ||
474 | # define RS690_MC_INDEX_WR_ACK 0x7f | ||
475 | #define RS690_MC_DATA 0x7c | ||
476 | |||
477 | #define RS690_MC_MISC_CNTL 0x18 | ||
478 | #define RS690_MC_GART_FEATURE_ID 0x2b | ||
479 | #define RS690_MC_GART_BASE 0x2c | ||
480 | #define RS690_MC_GART_CACHE_CNTL 0x2e | ||
481 | # define RS690_MC_GART_CC_NO_CHANGE 0x0 | ||
482 | # define RS690_MC_GART_CC_CLEAR 0x1 | ||
483 | # define RS690_MC_GART_CLEAR_STATUS (1 << 1) | ||
484 | # define RS690_MC_GART_CLEAR_DONE (0 << 1) | ||
485 | # define RS690_MC_GART_CLEAR_PENDING (1 << 1) | ||
486 | #define RS690_MC_AGP_SIZE 0x38 | ||
487 | # define RS690_MC_GART_DIS 0x0 | ||
488 | # define RS690_MC_GART_EN 0x1 | ||
489 | # define RS690_MC_AGP_SIZE_32MB (0 << 1) | ||
490 | # define RS690_MC_AGP_SIZE_64MB (1 << 1) | ||
491 | # define RS690_MC_AGP_SIZE_128MB (2 << 1) | ||
492 | # define RS690_MC_AGP_SIZE_256MB (3 << 1) | ||
493 | # define RS690_MC_AGP_SIZE_512MB (4 << 1) | ||
494 | # define RS690_MC_AGP_SIZE_1GB (5 << 1) | ||
495 | # define RS690_MC_AGP_SIZE_2GB (6 << 1) | ||
496 | #define RS690_MC_AGP_MODE_CONTROL 0x39 | ||
497 | #define RS690_MC_FB_LOCATION 0x100 | ||
498 | #define RS690_MC_AGP_LOCATION 0x101 | ||
499 | #define RS690_MC_AGP_BASE 0x102 | ||
500 | |||
470 | #define R520_MC_IND_INDEX 0x70 | 501 | #define R520_MC_IND_INDEX 0x70 |
471 | #define R520_MC_IND_WR_EN (1<<24) | 502 | #define R520_MC_IND_WR_EN (1<<24) |
472 | #define R520_MC_IND_DATA 0x74 | 503 | #define R520_MC_IND_DATA 0x74 |
@@ -1076,6 +1107,13 @@ do { \ | |||
1076 | RADEON_WRITE(R520_MC_IND_INDEX, 0); \ | 1107 | RADEON_WRITE(R520_MC_IND_INDEX, 0); \ |
1077 | } while (0) | 1108 | } while (0) |
1078 | 1109 | ||
1110 | #define RS690_WRITE_MCIND( addr, val ) \ | ||
1111 | do { \ | ||
1112 | RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_EN | ((addr) & RS690_MC_INDEX_MASK)); \ | ||
1113 | RADEON_WRITE(RS690_MC_DATA, val); \ | ||
1114 | RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_ACK); \ | ||
1115 | } while (0) | ||
1116 | |||
1079 | #define CP_PACKET0( reg, n ) \ | 1117 | #define CP_PACKET0( reg, n ) \ |
1080 | (RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2)) | 1118 | (RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2)) |
1081 | #define CP_PACKET0_TABLE( reg, n ) \ | 1119 | #define CP_PACKET0_TABLE( reg, n ) \ |
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c index bb09413d5a21..88590d040046 100644 --- a/drivers/char/hvc_rtas.c +++ b/drivers/char/hvc_rtas.c | |||
@@ -76,7 +76,7 @@ static struct hv_ops hvc_rtas_get_put_ops = { | |||
76 | .put_chars = hvc_rtas_write_console, | 76 | .put_chars = hvc_rtas_write_console, |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static int hvc_rtas_init(void) | 79 | static int __init hvc_rtas_init(void) |
80 | { | 80 | { |
81 | struct hvc_struct *hp; | 81 | struct hvc_struct *hp; |
82 | 82 | ||
diff --git a/drivers/char/pcmcia/Kconfig b/drivers/char/pcmcia/Kconfig index 00b8a84b0319..ffa0efce0aed 100644 --- a/drivers/char/pcmcia/Kconfig +++ b/drivers/char/pcmcia/Kconfig | |||
@@ -45,7 +45,7 @@ config CARDMAN_4040 | |||
45 | 45 | ||
46 | config IPWIRELESS | 46 | config IPWIRELESS |
47 | tristate "IPWireless 3G UMTS PCMCIA card support" | 47 | tristate "IPWireless 3G UMTS PCMCIA card support" |
48 | depends on PCMCIA | 48 | depends on PCMCIA && NETDEVICES |
49 | select PPP | 49 | select PPP |
50 | help | 50 | help |
51 | This is a driver for 3G UMTS PCMCIA card from IPWireless company. In | 51 | This is a driver for 3G UMTS PCMCIA card from IPWireless company. In |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 64926aa990db..89a29cd93783 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1006,14 +1006,6 @@ static int __cpufreq_remove_dev (struct sys_device * sys_dev) | |||
1006 | } | 1006 | } |
1007 | #endif | 1007 | #endif |
1008 | 1008 | ||
1009 | |||
1010 | if (!kobject_get(&data->kobj)) { | ||
1011 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
1012 | cpufreq_debug_enable_ratelimit(); | ||
1013 | unlock_policy_rwsem_write(cpu); | ||
1014 | return -EFAULT; | ||
1015 | } | ||
1016 | |||
1017 | #ifdef CONFIG_SMP | 1009 | #ifdef CONFIG_SMP |
1018 | 1010 | ||
1019 | #ifdef CONFIG_HOTPLUG_CPU | 1011 | #ifdef CONFIG_HOTPLUG_CPU |
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 60f71e6345e3..d73663a52324 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -219,7 +219,8 @@ static void poll_idle_init(struct cpuidle_device *dev) | |||
219 | 219 | ||
220 | cpuidle_set_statedata(state, NULL); | 220 | cpuidle_set_statedata(state, NULL); |
221 | 221 | ||
222 | snprintf(state->name, CPUIDLE_NAME_LEN, "C0 (poll idle)"); | 222 | snprintf(state->name, CPUIDLE_NAME_LEN, "C0"); |
223 | snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE"); | ||
223 | state->exit_latency = 0; | 224 | state->exit_latency = 0; |
224 | state->target_residency = 0; | 225 | state->target_residency = 0; |
225 | state->power_usage = -1; | 226 | state->power_usage = -1; |
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 088ea74edd34..69102ca05685 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -218,16 +218,23 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | |||
218 | return sprintf(buf, "%u\n", state->_name);\ | 218 | return sprintf(buf, "%u\n", state->_name);\ |
219 | } | 219 | } |
220 | 220 | ||
221 | static ssize_t show_state_name(struct cpuidle_state *state, char *buf) | 221 | #define define_show_state_str_function(_name) \ |
222 | { | 222 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ |
223 | return sprintf(buf, "%s\n", state->name); | 223 | { \ |
224 | if (state->_name[0] == '\0')\ | ||
225 | return sprintf(buf, "<null>\n");\ | ||
226 | return sprintf(buf, "%s\n", state->_name);\ | ||
224 | } | 227 | } |
225 | 228 | ||
226 | define_show_state_function(exit_latency) | 229 | define_show_state_function(exit_latency) |
227 | define_show_state_function(power_usage) | 230 | define_show_state_function(power_usage) |
228 | define_show_state_function(usage) | 231 | define_show_state_function(usage) |
229 | define_show_state_function(time) | 232 | define_show_state_function(time) |
233 | define_show_state_str_function(name) | ||
234 | define_show_state_str_function(desc) | ||
235 | |||
230 | define_one_state_ro(name, show_state_name); | 236 | define_one_state_ro(name, show_state_name); |
237 | define_one_state_ro(desc, show_state_desc); | ||
231 | define_one_state_ro(latency, show_state_exit_latency); | 238 | define_one_state_ro(latency, show_state_exit_latency); |
232 | define_one_state_ro(power, show_state_power_usage); | 239 | define_one_state_ro(power, show_state_power_usage); |
233 | define_one_state_ro(usage, show_state_usage); | 240 | define_one_state_ro(usage, show_state_usage); |
@@ -235,6 +242,7 @@ define_one_state_ro(time, show_state_time); | |||
235 | 242 | ||
236 | static struct attribute *cpuidle_state_default_attrs[] = { | 243 | static struct attribute *cpuidle_state_default_attrs[] = { |
237 | &attr_name.attr, | 244 | &attr_name.attr, |
245 | &attr_desc.attr, | ||
238 | &attr_latency.attr, | 246 | &attr_latency.attr, |
239 | &attr_power.attr, | 247 | &attr_power.attr, |
240 | &attr_usage.attr, | 248 | &attr_usage.attr, |
diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c index dfbf24c4033c..3110bf7014f7 100644 --- a/drivers/crypto/hifn_795x.c +++ b/drivers/crypto/hifn_795x.c | |||
@@ -463,7 +463,7 @@ struct hifn_device | |||
463 | 463 | ||
464 | unsigned int pk_clk_freq; | 464 | unsigned int pk_clk_freq; |
465 | 465 | ||
466 | #ifdef CRYPTO_DEV_HIFN_795X_RNG | 466 | #ifdef CONFIG_CRYPTO_DEV_HIFN_795X_RNG |
467 | unsigned int rng_wait_time; | 467 | unsigned int rng_wait_time; |
468 | ktime_t rngtime; | 468 | ktime_t rngtime; |
469 | struct hwrng rng; | 469 | struct hwrng rng; |
@@ -795,7 +795,7 @@ static struct pci2id { | |||
795 | } | 795 | } |
796 | }; | 796 | }; |
797 | 797 | ||
798 | #ifdef CRYPTO_DEV_HIFN_795X_RNG | 798 | #ifdef CONFIG_CRYPTO_DEV_HIFN_795X_RNG |
799 | static int hifn_rng_data_present(struct hwrng *rng, int wait) | 799 | static int hifn_rng_data_present(struct hwrng *rng, int wait) |
800 | { | 800 | { |
801 | struct hifn_device *dev = (struct hifn_device *)rng->priv; | 801 | struct hifn_device *dev = (struct hifn_device *)rng->priv; |
@@ -880,7 +880,7 @@ static int hifn_init_pubrng(struct hifn_device *dev) | |||
880 | dprintk("Chip %s: RNG engine has been successfully initialised.\n", | 880 | dprintk("Chip %s: RNG engine has been successfully initialised.\n", |
881 | dev->name); | 881 | dev->name); |
882 | 882 | ||
883 | #ifdef CRYPTO_DEV_HIFN_795X_RNG | 883 | #ifdef CONFIG_CRYPTO_DEV_HIFN_795X_RNG |
884 | /* First value must be discarded */ | 884 | /* First value must be discarded */ |
885 | hifn_read_1(dev, HIFN_1_RNG_DATA); | 885 | hifn_read_1(dev, HIFN_1_RNG_DATA); |
886 | dev->rngtime = ktime_get(); | 886 | dev->rngtime = ktime_get(); |
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 653265a40b7f..4072449ad1cd 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -10,10 +10,9 @@ | |||
10 | 10 | ||
11 | static char dmi_empty_string[] = " "; | 11 | static char dmi_empty_string[] = " "; |
12 | 12 | ||
13 | static char * __init dmi_string(const struct dmi_header *dm, u8 s) | 13 | static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) |
14 | { | 14 | { |
15 | const u8 *bp = ((u8 *) dm) + dm->length; | 15 | const u8 *bp = ((u8 *) dm) + dm->length; |
16 | char *str = ""; | ||
17 | 16 | ||
18 | if (s) { | 17 | if (s) { |
19 | s--; | 18 | s--; |
@@ -28,14 +27,29 @@ static char * __init dmi_string(const struct dmi_header *dm, u8 s) | |||
28 | 27 | ||
29 | if (!memcmp(bp, dmi_empty_string, cmp_len)) | 28 | if (!memcmp(bp, dmi_empty_string, cmp_len)) |
30 | return dmi_empty_string; | 29 | return dmi_empty_string; |
31 | str = dmi_alloc(len); | 30 | return bp; |
32 | if (str != NULL) | ||
33 | strcpy(str, bp); | ||
34 | else | ||
35 | printk(KERN_ERR "dmi_string: cannot allocate %Zu bytes.\n", len); | ||
36 | } | 31 | } |
37 | } | 32 | } |
38 | 33 | ||
34 | return ""; | ||
35 | } | ||
36 | |||
37 | static char * __init dmi_string(const struct dmi_header *dm, u8 s) | ||
38 | { | ||
39 | const char *bp = dmi_string_nosave(dm, s); | ||
40 | char *str; | ||
41 | size_t len; | ||
42 | |||
43 | if (bp == dmi_empty_string) | ||
44 | return dmi_empty_string; | ||
45 | |||
46 | len = strlen(bp) + 1; | ||
47 | str = dmi_alloc(len); | ||
48 | if (str != NULL) | ||
49 | strcpy(str, bp); | ||
50 | else | ||
51 | printk(KERN_ERR "dmi_string: cannot allocate %Zu bytes.\n", len); | ||
52 | |||
39 | return str; | 53 | return str; |
40 | } | 54 | } |
41 | 55 | ||
@@ -167,10 +181,30 @@ static void __init dmi_save_type(const struct dmi_header *dm, int slot, int inde | |||
167 | dmi_ident[slot] = s; | 181 | dmi_ident[slot] = s; |
168 | } | 182 | } |
169 | 183 | ||
184 | static void __init dmi_save_one_device(int type, const char *name) | ||
185 | { | ||
186 | struct dmi_device *dev; | ||
187 | |||
188 | /* No duplicate device */ | ||
189 | if (dmi_find_device(type, name, NULL)) | ||
190 | return; | ||
191 | |||
192 | dev = dmi_alloc(sizeof(*dev) + strlen(name) + 1); | ||
193 | if (!dev) { | ||
194 | printk(KERN_ERR "dmi_save_one_device: out of memory.\n"); | ||
195 | return; | ||
196 | } | ||
197 | |||
198 | dev->type = type; | ||
199 | strcpy((char *)(dev + 1), name); | ||
200 | dev->name = (char *)(dev + 1); | ||
201 | dev->device_data = NULL; | ||
202 | list_add(&dev->list, &dmi_devices); | ||
203 | } | ||
204 | |||
170 | static void __init dmi_save_devices(const struct dmi_header *dm) | 205 | static void __init dmi_save_devices(const struct dmi_header *dm) |
171 | { | 206 | { |
172 | int i, count = (dm->length - sizeof(struct dmi_header)) / 2; | 207 | int i, count = (dm->length - sizeof(struct dmi_header)) / 2; |
173 | struct dmi_device *dev; | ||
174 | 208 | ||
175 | for (i = 0; i < count; i++) { | 209 | for (i = 0; i < count; i++) { |
176 | const char *d = (char *)(dm + 1) + (i * 2); | 210 | const char *d = (char *)(dm + 1) + (i * 2); |
@@ -179,23 +213,10 @@ static void __init dmi_save_devices(const struct dmi_header *dm) | |||
179 | if ((*d & 0x80) == 0) | 213 | if ((*d & 0x80) == 0) |
180 | continue; | 214 | continue; |
181 | 215 | ||
182 | dev = dmi_alloc(sizeof(*dev)); | 216 | dmi_save_one_device(*d & 0x7f, dmi_string_nosave(dm, *(d + 1))); |
183 | if (!dev) { | ||
184 | printk(KERN_ERR "dmi_save_devices: out of memory.\n"); | ||
185 | break; | ||
186 | } | ||
187 | |||
188 | dev->type = *d++ & 0x7f; | ||
189 | dev->name = dmi_string(dm, *d); | ||
190 | dev->device_data = NULL; | ||
191 | list_add(&dev->list, &dmi_devices); | ||
192 | } | 217 | } |
193 | } | 218 | } |
194 | 219 | ||
195 | static struct dmi_device empty_oem_string_dev = { | ||
196 | .name = dmi_empty_string, | ||
197 | }; | ||
198 | |||
199 | static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm) | 220 | static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm) |
200 | { | 221 | { |
201 | int i, count = *(u8 *)(dm + 1); | 222 | int i, count = *(u8 *)(dm + 1); |
@@ -204,10 +225,8 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm) | |||
204 | for (i = 1; i <= count; i++) { | 225 | for (i = 1; i <= count; i++) { |
205 | char *devname = dmi_string(dm, i); | 226 | char *devname = dmi_string(dm, i); |
206 | 227 | ||
207 | if (!strcmp(devname, dmi_empty_string)) { | 228 | if (devname == dmi_empty_string) |
208 | list_add(&empty_oem_string_dev.list, &dmi_devices); | ||
209 | continue; | 229 | continue; |
210 | } | ||
211 | 230 | ||
212 | dev = dmi_alloc(sizeof(*dev)); | 231 | dev = dmi_alloc(sizeof(*dev)); |
213 | if (!dev) { | 232 | if (!dev) { |
@@ -253,23 +272,12 @@ static void __init dmi_save_ipmi_device(const struct dmi_header *dm) | |||
253 | static void __init dmi_save_extended_devices(const struct dmi_header *dm) | 272 | static void __init dmi_save_extended_devices(const struct dmi_header *dm) |
254 | { | 273 | { |
255 | const u8 *d = (u8*) dm + 5; | 274 | const u8 *d = (u8*) dm + 5; |
256 | struct dmi_device *dev; | ||
257 | 275 | ||
258 | /* Skip disabled device */ | 276 | /* Skip disabled device */ |
259 | if ((*d & 0x80) == 0) | 277 | if ((*d & 0x80) == 0) |
260 | return; | 278 | return; |
261 | 279 | ||
262 | dev = dmi_alloc(sizeof(*dev)); | 280 | dmi_save_one_device(*d & 0x7f, dmi_string_nosave(dm, *(d - 1))); |
263 | if (!dev) { | ||
264 | printk(KERN_ERR "dmi_save_extended_devices: out of memory.\n"); | ||
265 | return; | ||
266 | } | ||
267 | |||
268 | dev->type = *d-- & 0x7f; | ||
269 | dev->name = dmi_string(dm, *d); | ||
270 | dev->device_data = NULL; | ||
271 | |||
272 | list_add(&dev->list, &dmi_devices); | ||
273 | } | 281 | } |
274 | 282 | ||
275 | /* | 283 | /* |
diff --git a/drivers/hid/hid-input-quirks.c b/drivers/hid/hid-input-quirks.c index a870ba58faa3..dceadd0c1419 100644 --- a/drivers/hid/hid-input-quirks.c +++ b/drivers/hid/hid-input-quirks.c | |||
@@ -352,7 +352,7 @@ int hidinput_mapping_quirks(struct hid_usage *usage, | |||
352 | return 0; | 352 | return 0; |
353 | } | 353 | } |
354 | 354 | ||
355 | void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) | 355 | int hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) |
356 | { | 356 | { |
357 | struct input_dev *input; | 357 | struct input_dev *input; |
358 | 358 | ||
@@ -362,34 +362,34 @@ void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, stru | |||
362 | || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) { | 362 | || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) { |
363 | if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON; | 363 | if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON; |
364 | else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON; | 364 | else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON; |
365 | return; | 365 | return 1; |
366 | } | 366 | } |
367 | 367 | ||
368 | if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && | 368 | if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && |
369 | (usage->type == EV_REL) && | 369 | (usage->type == EV_REL) && |
370 | (usage->code == REL_WHEEL)) { | 370 | (usage->code == REL_WHEEL)) { |
371 | hid->delayed_value = value; | 371 | hid->delayed_value = value; |
372 | return; | 372 | return 1; |
373 | } | 373 | } |
374 | 374 | ||
375 | if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && | 375 | if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && |
376 | (usage->hid == 0x000100b8)) { | 376 | (usage->hid == 0x000100b8)) { |
377 | input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value); | 377 | input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value); |
378 | return; | 378 | return 1; |
379 | } | 379 | } |
380 | 380 | ||
381 | if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) { | 381 | if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) { |
382 | input_event(input, usage->type, usage->code, -value); | 382 | input_event(input, usage->type, usage->code, -value); |
383 | return; | 383 | return 1; |
384 | } | 384 | } |
385 | 385 | ||
386 | if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) { | 386 | if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) { |
387 | input_event(input, usage->type, REL_HWHEEL, value); | 387 | input_event(input, usage->type, REL_HWHEEL, value); |
388 | return; | 388 | return 1; |
389 | } | 389 | } |
390 | 390 | ||
391 | if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value)) | 391 | if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value)) |
392 | return; | 392 | return 1; |
393 | 393 | ||
394 | /* Handling MS keyboards special buttons */ | 394 | /* Handling MS keyboards special buttons */ |
395 | if (hid->quirks & HID_QUIRK_MICROSOFT_KEYS && | 395 | if (hid->quirks & HID_QUIRK_MICROSOFT_KEYS && |
@@ -416,8 +416,9 @@ void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, stru | |||
416 | if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT && | 416 | if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT && |
417 | usage->type == EV_REL && usage->code == REL_HWHEEL) { | 417 | usage->type == EV_REL && usage->code == REL_HWHEEL) { |
418 | input_event(input, usage->type, REL_WHEEL, -value); | 418 | input_event(input, usage->type, REL_WHEEL, -value); |
419 | return; | 419 | return 1; |
420 | } | 420 | } |
421 | return 0; | ||
421 | } | 422 | } |
422 | 423 | ||
423 | 424 | ||
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 5325d98b4328..5a38fb27d69f 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -97,6 +97,7 @@ struct hidinput_key_translation { | |||
97 | #define APPLE_FLAG_FKEY 0x01 | 97 | #define APPLE_FLAG_FKEY 0x01 |
98 | 98 | ||
99 | static struct hidinput_key_translation apple_fn_keys[] = { | 99 | static struct hidinput_key_translation apple_fn_keys[] = { |
100 | { KEY_BACKSPACE, KEY_DELETE }, | ||
100 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, | 101 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
101 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, | 102 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, |
102 | { KEY_F3, KEY_CYCLEWINDOWS, APPLE_FLAG_FKEY }, /* Exposé */ | 103 | { KEY_F3, KEY_CYCLEWINDOWS, APPLE_FLAG_FKEY }, /* Exposé */ |
@@ -109,6 +110,10 @@ static struct hidinput_key_translation apple_fn_keys[] = { | |||
109 | { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, | 110 | { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, |
110 | { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, | 111 | { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, |
111 | { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, | 112 | { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, |
113 | { KEY_UP, KEY_PAGEUP }, | ||
114 | { KEY_DOWN, KEY_PAGEDOWN }, | ||
115 | { KEY_LEFT, KEY_HOME }, | ||
116 | { KEY_RIGHT, KEY_END }, | ||
112 | { } | 117 | { } |
113 | }; | 118 | }; |
114 | 119 | ||
@@ -854,7 +859,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
854 | return; | 859 | return; |
855 | 860 | ||
856 | /* handle input events for quirky devices */ | 861 | /* handle input events for quirky devices */ |
857 | hidinput_event_quirks(hid, field, usage, value); | 862 | if (hidinput_event_quirks(hid, field, usage, value)) |
863 | return; | ||
858 | 864 | ||
859 | if (usage->hat_min < usage->hat_max || usage->hat_dir) { | 865 | if (usage->hat_min < usage->hat_max || usage->hat_dir) { |
860 | int hat_dir = usage->hat_dir; | 866 | int hat_dir = usage->hat_dir; |
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index b77b61e0cd7b..e6d05f6b1c1c 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
@@ -66,6 +66,12 @@ | |||
66 | #define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220 | 66 | #define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220 |
67 | #define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221 | 67 | #define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221 |
68 | #define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222 | 68 | #define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222 |
69 | #define USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI 0x0229 | ||
70 | #define USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO 0x022a | ||
71 | #define USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS 0x022b | ||
72 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c | ||
73 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d | ||
74 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e | ||
69 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a | 75 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a |
70 | #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b | 76 | #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b |
71 | #define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242 | 77 | #define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242 |
@@ -193,6 +199,17 @@ | |||
193 | #define USB_DEVICE_ID_GTCO_502 0x0502 | 199 | #define USB_DEVICE_ID_GTCO_502 0x0502 |
194 | #define USB_DEVICE_ID_GTCO_503 0x0503 | 200 | #define USB_DEVICE_ID_GTCO_503 0x0503 |
195 | #define USB_DEVICE_ID_GTCO_504 0x0504 | 201 | #define USB_DEVICE_ID_GTCO_504 0x0504 |
202 | #define USB_DEVICE_ID_GTCO_600 0x0600 | ||
203 | #define USB_DEVICE_ID_GTCO_601 0x0601 | ||
204 | #define USB_DEVICE_ID_GTCO_602 0x0602 | ||
205 | #define USB_DEVICE_ID_GTCO_603 0x0603 | ||
206 | #define USB_DEVICE_ID_GTCO_604 0x0604 | ||
207 | #define USB_DEVICE_ID_GTCO_605 0x0605 | ||
208 | #define USB_DEVICE_ID_GTCO_606 0x0606 | ||
209 | #define USB_DEVICE_ID_GTCO_607 0x0607 | ||
210 | #define USB_DEVICE_ID_GTCO_608 0x0608 | ||
211 | #define USB_DEVICE_ID_GTCO_609 0x0609 | ||
212 | #define USB_DEVICE_ID_GTCO_609 0x0609 | ||
196 | #define USB_DEVICE_ID_GTCO_1000 0x1000 | 213 | #define USB_DEVICE_ID_GTCO_1000 0x1000 |
197 | #define USB_DEVICE_ID_GTCO_1001 0x1001 | 214 | #define USB_DEVICE_ID_GTCO_1001 0x1001 |
198 | #define USB_DEVICE_ID_GTCO_1002 0x1002 | 215 | #define USB_DEVICE_ID_GTCO_1002 0x1002 |
@@ -200,7 +217,7 @@ | |||
200 | #define USB_DEVICE_ID_GTCO_1004 0x1004 | 217 | #define USB_DEVICE_ID_GTCO_1004 0x1004 |
201 | #define USB_DEVICE_ID_GTCO_1005 0x1005 | 218 | #define USB_DEVICE_ID_GTCO_1005 0x1005 |
202 | #define USB_DEVICE_ID_GTCO_1006 0x1006 | 219 | #define USB_DEVICE_ID_GTCO_1006 0x1006 |
203 | 220 | #define USB_DEVICE_ID_GTCO_1007 0x1007 | |
204 | #define USB_VENDOR_ID_HAPP 0x078b | 221 | #define USB_VENDOR_ID_HAPP 0x078b |
205 | #define USB_DEVICE_ID_UGCI_DRIVING 0x0010 | 222 | #define USB_DEVICE_ID_UGCI_DRIVING 0x0010 |
206 | #define USB_DEVICE_ID_UGCI_FLYING 0x0020 | 223 | #define USB_DEVICE_ID_UGCI_FLYING 0x0020 |
@@ -368,6 +385,7 @@ | |||
368 | #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 | 385 | #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 |
369 | #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 | 386 | #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 |
370 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 | 387 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 |
388 | #define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 | ||
371 | 389 | ||
372 | #define USB_VENDOR_ID_WACOM 0x056a | 390 | #define USB_VENDOR_ID_WACOM 0x056a |
373 | 391 | ||
@@ -496,6 +514,16 @@ static const struct hid_blacklist { | |||
496 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502, HID_QUIRK_IGNORE }, | 514 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502, HID_QUIRK_IGNORE }, |
497 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503, HID_QUIRK_IGNORE }, | 515 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503, HID_QUIRK_IGNORE }, |
498 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504, HID_QUIRK_IGNORE }, | 516 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504, HID_QUIRK_IGNORE }, |
517 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_600, HID_QUIRK_IGNORE }, | ||
518 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_601, HID_QUIRK_IGNORE }, | ||
519 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_602, HID_QUIRK_IGNORE }, | ||
520 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_603, HID_QUIRK_IGNORE }, | ||
521 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_604, HID_QUIRK_IGNORE }, | ||
522 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_605, HID_QUIRK_IGNORE }, | ||
523 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_606, HID_QUIRK_IGNORE }, | ||
524 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_607, HID_QUIRK_IGNORE }, | ||
525 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_608, HID_QUIRK_IGNORE }, | ||
526 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_609, HID_QUIRK_IGNORE }, | ||
499 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000, HID_QUIRK_IGNORE }, | 527 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000, HID_QUIRK_IGNORE }, |
500 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001, HID_QUIRK_IGNORE }, | 528 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001, HID_QUIRK_IGNORE }, |
501 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002, HID_QUIRK_IGNORE }, | 529 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002, HID_QUIRK_IGNORE }, |
@@ -503,6 +531,7 @@ static const struct hid_blacklist { | |||
503 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004, HID_QUIRK_IGNORE }, | 531 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004, HID_QUIRK_IGNORE }, |
504 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005, HID_QUIRK_IGNORE }, | 532 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005, HID_QUIRK_IGNORE }, |
505 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006, HID_QUIRK_IGNORE }, | 533 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006, HID_QUIRK_IGNORE }, |
534 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007, HID_QUIRK_IGNORE }, | ||
506 | { USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA, HID_QUIRK_IGNORE }, | 535 | { USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA, HID_QUIRK_IGNORE }, |
507 | { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE }, | 536 | { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE }, |
508 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY, HID_QUIRK_IGNORE }, | 537 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY, HID_QUIRK_IGNORE }, |
@@ -541,6 +570,7 @@ static const struct hid_blacklist { | |||
541 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE }, | 570 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE }, |
542 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE }, | 571 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE }, |
543 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE }, | 572 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE }, |
573 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC, HID_QUIRK_IGNORE }, | ||
544 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 574 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
545 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 575 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
546 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT, HID_QUIRK_IGNORE }, | 576 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT, HID_QUIRK_IGNORE }, |
@@ -593,6 +623,12 @@ static const struct hid_blacklist { | |||
593 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI, HID_QUIRK_APPLE_HAS_FN }, | 623 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI, HID_QUIRK_APPLE_HAS_FN }, |
594 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD }, | 624 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD }, |
595 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS, HID_QUIRK_APPLE_HAS_FN }, | 625 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS, HID_QUIRK_APPLE_HAS_FN }, |
626 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, | ||
627 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD }, | ||
628 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, | ||
629 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI, HID_QUIRK_APPLE_HAS_FN }, | ||
630 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD }, | ||
631 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS, HID_QUIRK_APPLE_HAS_FN }, | ||
596 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, | 632 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
597 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, | 633 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
598 | 634 | ||
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 410ffe4e9d80..368879ff5d8c 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -143,6 +143,16 @@ config SENSORS_ADT7470 | |||
143 | This driver can also be built as a module. If so, the module | 143 | This driver can also be built as a module. If so, the module |
144 | will be called adt7470. | 144 | will be called adt7470. |
145 | 145 | ||
146 | config SENSORS_ADT7473 | ||
147 | tristate "Analog Devices ADT7473" | ||
148 | depends on I2C && EXPERIMENTAL | ||
149 | help | ||
150 | If you say yes here you get support for the Analog Devices | ||
151 | ADT7473 temperature monitoring chips. | ||
152 | |||
153 | This driver can also be built as a module. If so, the module | ||
154 | will be called adt7473. | ||
155 | |||
146 | config SENSORS_K8TEMP | 156 | config SENSORS_K8TEMP |
147 | tristate "AMD Athlon64/FX or Opteron temperature sensor" | 157 | tristate "AMD Athlon64/FX or Opteron temperature sensor" |
148 | depends on X86 && PCI && EXPERIMENTAL | 158 | depends on X86 && PCI && EXPERIMENTAL |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 824161337f1c..3bdb05a5cbd7 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -24,6 +24,7 @@ obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o | |||
24 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o | 24 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o |
25 | obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o | 25 | obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o |
26 | obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o | 26 | obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o |
27 | obj-$(CONFIG_SENSORS_ADT7473) += adt7473.o | ||
27 | obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o | 28 | obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o |
28 | obj-$(CONFIG_SENSORS_AMS) += ams/ | 29 | obj-$(CONFIG_SENSORS_AMS) += ams/ |
29 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o | 30 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o |
diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c index fcd7fe78f3f9..466b9ee92797 100644 --- a/drivers/hwmon/ad7418.c +++ b/drivers/hwmon/ad7418.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #define DRV_VERSION "0.3" | 26 | #define DRV_VERSION "0.3" |
27 | 27 | ||
28 | /* Addresses to scan */ | 28 | /* Addresses to scan */ |
29 | static unsigned short normal_i2c[] = { 0x28, I2C_CLIENT_END }; | 29 | static const unsigned short normal_i2c[] = { 0x28, I2C_CLIENT_END }; |
30 | /* Insmod parameters */ | 30 | /* Insmod parameters */ |
31 | I2C_CLIENT_INSMOD_3(ad7416, ad7417, ad7418); | 31 | I2C_CLIENT_INSMOD_3(ad7416, ad7417, ad7418); |
32 | 32 | ||
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index b96be772e498..ecbf69484bf5 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -31,10 +31,8 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | /* Addresses to scan */ | 33 | /* Addresses to scan */ |
34 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, | 34 | static const unsigned short normal_i2c[] = { |
35 | 0x29, 0x2a, 0x2b, | 35 | 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; |
36 | 0x4c, 0x4d, 0x4e, | ||
37 | I2C_CLIENT_END }; | ||
38 | 36 | ||
39 | /* Insmod parameters */ | 37 | /* Insmod parameters */ |
40 | I2C_CLIENT_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, | 38 | I2C_CLIENT_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, |
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index e96c3725203d..1d76de7d75c7 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -62,7 +62,7 @@ | |||
62 | * NE1619 has two possible addresses: 0x2c and 0x2d. | 62 | * NE1619 has two possible addresses: 0x2c and 0x2d. |
63 | */ | 63 | */ |
64 | 64 | ||
65 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 65 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * Insmod parameters | 68 | * Insmod parameters |
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 8002f68240c4..904c6ce9d83f 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
36 | 36 | ||
37 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
38 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 38 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
39 | 39 | ||
40 | /* Insmod parameters */ | 40 | /* Insmod parameters */ |
41 | I2C_CLIENT_INSMOD_1(adm1026); | 41 | I2C_CLIENT_INSMOD_1(adm1026); |
@@ -1624,6 +1624,7 @@ static struct attribute *adm1026_attributes_temp3[] = { | |||
1624 | &dev_attr_temp3_crit_enable.attr, | 1624 | &dev_attr_temp3_crit_enable.attr, |
1625 | &dev_attr_temp3_auto_point1_pwm.attr, | 1625 | &dev_attr_temp3_auto_point1_pwm.attr, |
1626 | &dev_attr_temp3_auto_point2_pwm.attr, | 1626 | &dev_attr_temp3_auto_point2_pwm.attr, |
1627 | NULL | ||
1627 | }; | 1628 | }; |
1628 | 1629 | ||
1629 | static const struct attribute_group adm1026_group_temp3 = { | 1630 | static const struct attribute_group adm1026_group_temp3 = { |
@@ -1639,6 +1640,7 @@ static struct attribute *adm1026_attributes_in8_9[] = { | |||
1639 | &sensor_dev_attr_in9_max.dev_attr.attr, | 1640 | &sensor_dev_attr_in9_max.dev_attr.attr, |
1640 | &sensor_dev_attr_in9_min.dev_attr.attr, | 1641 | &sensor_dev_attr_in9_min.dev_attr.attr, |
1641 | &sensor_dev_attr_in9_alarm.dev_attr.attr, | 1642 | &sensor_dev_attr_in9_alarm.dev_attr.attr, |
1643 | NULL | ||
1642 | }; | 1644 | }; |
1643 | 1645 | ||
1644 | static const struct attribute_group adm1026_group_in8_9 = { | 1646 | static const struct attribute_group adm1026_group_in8_9 = { |
diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c index 0bc897dffa27..2c6608d453c2 100644 --- a/drivers/hwmon/adm1029.c +++ b/drivers/hwmon/adm1029.c | |||
@@ -39,10 +39,8 @@ | |||
39 | * Addresses to scan | 39 | * Addresses to scan |
40 | */ | 40 | */ |
41 | 41 | ||
42 | static unsigned short normal_i2c[] = { | 42 | static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, |
43 | 0x28, 0x29, 0x2a, | 43 | 0x2e, 0x2f, I2C_CLIENT_END |
44 | 0x2b, 0x2c, 0x2d, | ||
45 | 0x2e, 0x2f, I2C_CLIENT_END | ||
46 | }; | 44 | }; |
47 | 45 | ||
48 | /* | 46 | /* |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 5aaad3636c98..2bffcab7dc9f 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -61,7 +61,7 @@ | |||
61 | #define ADM1031_CONF2_TEMP_ENABLE(chan) (0x10 << (chan)) | 61 | #define ADM1031_CONF2_TEMP_ENABLE(chan) (0x10 << (chan)) |
62 | 62 | ||
63 | /* Addresses to scan */ | 63 | /* Addresses to scan */ |
64 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 64 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
65 | 65 | ||
66 | /* Insmod parameters */ | 66 | /* Insmod parameters */ |
67 | I2C_CLIENT_INSMOD_2(adm1030, adm1031); | 67 | I2C_CLIENT_INSMOD_2(adm1030, adm1031); |
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 7671d2bf7800..149ef25252e7 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -52,7 +52,7 @@ | |||
52 | #include <linux/mutex.h> | 52 | #include <linux/mutex.h> |
53 | 53 | ||
54 | /* Addresses to scan */ | 54 | /* Addresses to scan */ |
55 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, | 55 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, |
56 | I2C_CLIENT_END }; | 56 | I2C_CLIENT_END }; |
57 | 57 | ||
58 | /* Insmod parameters */ | 58 | /* Insmod parameters */ |
diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c index 6b8a73ef404c..ed71a8bc70dc 100644 --- a/drivers/hwmon/ads7828.c +++ b/drivers/hwmon/ads7828.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #define ADS7828_INT_VREF_MV 2500 /* Internal vref is 2.5V, 2500mV */ | 44 | #define ADS7828_INT_VREF_MV 2500 /* Internal vref is 2.5V, 2500mV */ |
45 | 45 | ||
46 | /* Addresses to scan */ | 46 | /* Addresses to scan */ |
47 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, | 47 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, |
48 | I2C_CLIENT_END }; | 48 | I2C_CLIENT_END }; |
49 | 49 | ||
50 | /* Insmod parameters */ | 50 | /* Insmod parameters */ |
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 747693ab2ff1..6b5325f33a2c 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/log2.h> | 30 | #include <linux/log2.h> |
31 | 31 | ||
32 | /* Addresses to scan */ | 32 | /* Addresses to scan */ |
33 | static unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END }; | 33 | static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END }; |
34 | 34 | ||
35 | /* Insmod parameters */ | 35 | /* Insmod parameters */ |
36 | I2C_CLIENT_INSMOD_1(adt7470); | 36 | I2C_CLIENT_INSMOD_1(adt7470); |
diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c new file mode 100644 index 000000000000..9587869bdba0 --- /dev/null +++ b/drivers/hwmon/adt7473.c | |||
@@ -0,0 +1,1157 @@ | |||
1 | /* | ||
2 | * A hwmon driver for the Analog Devices ADT7473 | ||
3 | * Copyright (C) 2007 IBM | ||
4 | * | ||
5 | * Author: Darrick J. Wong <djwong@us.ibm.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/jiffies.h> | ||
24 | #include <linux/i2c.h> | ||
25 | #include <linux/hwmon.h> | ||
26 | #include <linux/hwmon-sysfs.h> | ||
27 | #include <linux/err.h> | ||
28 | #include <linux/mutex.h> | ||
29 | #include <linux/delay.h> | ||
30 | #include <linux/log2.h> | ||
31 | |||
32 | /* Addresses to scan */ | ||
33 | static const unsigned short normal_i2c[] = { 0x2C, 0x2D, 0x2E, I2C_CLIENT_END }; | ||
34 | |||
35 | /* Insmod parameters */ | ||
36 | I2C_CLIENT_INSMOD_1(adt7473); | ||
37 | |||
38 | /* ADT7473 registers */ | ||
39 | #define ADT7473_REG_BASE_ADDR 0x20 | ||
40 | |||
41 | #define ADT7473_REG_VOLT_BASE_ADDR 0x21 | ||
42 | #define ADT7473_REG_VOLT_MAX_ADDR 0x22 | ||
43 | #define ADT7473_REG_VOLT_MIN_BASE_ADDR 0x46 | ||
44 | #define ADT7473_REG_VOLT_MIN_MAX_ADDR 0x49 | ||
45 | |||
46 | #define ADT7473_REG_TEMP_BASE_ADDR 0x25 | ||
47 | #define ADT7473_REG_TEMP_MAX_ADDR 0x27 | ||
48 | #define ADT7473_REG_TEMP_LIMITS_BASE_ADDR 0x4E | ||
49 | #define ADT7473_REG_TEMP_LIMITS_MAX_ADDR 0x53 | ||
50 | #define ADT7473_REG_TEMP_TMIN_BASE_ADDR 0x67 | ||
51 | #define ADT7473_REG_TEMP_TMIN_MAX_ADDR 0x69 | ||
52 | #define ADT7473_REG_TEMP_TMAX_BASE_ADDR 0x6A | ||
53 | #define ADT7473_REG_TEMP_TMAX_MAX_ADDR 0x6C | ||
54 | |||
55 | #define ADT7473_REG_FAN_BASE_ADDR 0x28 | ||
56 | #define ADT7473_REG_FAN_MAX_ADDR 0x2F | ||
57 | #define ADT7473_REG_FAN_MIN_BASE_ADDR 0x54 | ||
58 | #define ADT7473_REG_FAN_MIN_MAX_ADDR 0x5B | ||
59 | |||
60 | #define ADT7473_REG_PWM_BASE_ADDR 0x30 | ||
61 | #define ADT7473_REG_PWM_MAX_ADDR 0x32 | ||
62 | #define ADT7473_REG_PWM_MIN_BASE_ADDR 0x64 | ||
63 | #define ADT7473_REG_PWM_MIN_MAX_ADDR 0x66 | ||
64 | #define ADT7473_REG_PWM_MAX_BASE_ADDR 0x38 | ||
65 | #define ADT7473_REG_PWM_MAX_MAX_ADDR 0x3A | ||
66 | #define ADT7473_REG_PWM_BHVR_BASE_ADDR 0x5C | ||
67 | #define ADT7473_REG_PWM_BHVR_MAX_ADDR 0x5E | ||
68 | #define ADT7473_PWM_BHVR_MASK 0xE0 | ||
69 | #define ADT7473_PWM_BHVR_SHIFT 5 | ||
70 | |||
71 | #define ADT7473_REG_CFG1 0x40 | ||
72 | #define ADT7473_CFG1_START 0x01 | ||
73 | #define ADT7473_CFG1_READY 0x04 | ||
74 | #define ADT7473_REG_CFG2 0x73 | ||
75 | #define ADT7473_REG_CFG3 0x78 | ||
76 | #define ADT7473_REG_CFG4 0x7D | ||
77 | #define ADT7473_CFG4_MAX_DUTY_AT_OVT 0x08 | ||
78 | #define ADT7473_REG_CFG5 0x7C | ||
79 | #define ADT7473_CFG5_TEMP_TWOS 0x01 | ||
80 | #define ADT7473_CFG5_TEMP_OFFSET 0x02 | ||
81 | |||
82 | #define ADT7473_REG_DEVICE 0x3D | ||
83 | #define ADT7473_VENDOR 0x41 | ||
84 | #define ADT7473_REG_VENDOR 0x3E | ||
85 | #define ADT7473_DEVICE 0x73 | ||
86 | #define ADT7473_REG_REVISION 0x3F | ||
87 | #define ADT7473_REV_68 0x68 | ||
88 | #define ADT7473_REV_69 0x69 | ||
89 | |||
90 | #define ADT7473_REG_ALARM1 0x41 | ||
91 | #define ADT7473_VCCP_ALARM 0x02 | ||
92 | #define ADT7473_VCC_ALARM 0x04 | ||
93 | #define ADT7473_R1T_ALARM 0x10 | ||
94 | #define ADT7473_LT_ALARM 0x20 | ||
95 | #define ADT7473_R2T_ALARM 0x40 | ||
96 | #define ADT7473_OOL 0x80 | ||
97 | #define ADT7473_REG_ALARM2 0x42 | ||
98 | #define ADT7473_OVT_ALARM 0x02 | ||
99 | #define ADT7473_FAN1_ALARM 0x04 | ||
100 | #define ADT7473_FAN2_ALARM 0x08 | ||
101 | #define ADT7473_FAN3_ALARM 0x10 | ||
102 | #define ADT7473_FAN4_ALARM 0x20 | ||
103 | #define ADT7473_R1T_SHORT 0x40 | ||
104 | #define ADT7473_R2T_SHORT 0x80 | ||
105 | #define ADT7473_REG_MAX_ADDR 0x80 | ||
106 | |||
107 | #define ALARM2(x) ((x) << 8) | ||
108 | |||
109 | #define ADT7473_VOLT_COUNT 2 | ||
110 | #define ADT7473_REG_VOLT(x) (ADT7473_REG_VOLT_BASE_ADDR + (x)) | ||
111 | #define ADT7473_REG_VOLT_MIN(x) (ADT7473_REG_VOLT_MIN_BASE_ADDR + ((x) * 2)) | ||
112 | #define ADT7473_REG_VOLT_MAX(x) (ADT7473_REG_VOLT_MIN_BASE_ADDR + \ | ||
113 | ((x) * 2) + 1) | ||
114 | |||
115 | #define ADT7473_TEMP_COUNT 3 | ||
116 | #define ADT7473_REG_TEMP(x) (ADT7473_REG_TEMP_BASE_ADDR + (x)) | ||
117 | #define ADT7473_REG_TEMP_MIN(x) (ADT7473_REG_TEMP_LIMITS_BASE_ADDR + ((x) * 2)) | ||
118 | #define ADT7473_REG_TEMP_MAX(x) (ADT7473_REG_TEMP_LIMITS_BASE_ADDR + \ | ||
119 | ((x) * 2) + 1) | ||
120 | #define ADT7473_REG_TEMP_TMIN(x) (ADT7473_REG_TEMP_TMIN_BASE_ADDR + (x)) | ||
121 | #define ADT7473_REG_TEMP_TMAX(x) (ADT7473_REG_TEMP_TMAX_BASE_ADDR + (x)) | ||
122 | |||
123 | #define ADT7473_FAN_COUNT 4 | ||
124 | #define ADT7473_REG_FAN(x) (ADT7473_REG_FAN_BASE_ADDR + ((x) * 2)) | ||
125 | #define ADT7473_REG_FAN_MIN(x) (ADT7473_REG_FAN_MIN_BASE_ADDR + ((x) * 2)) | ||
126 | |||
127 | #define ADT7473_PWM_COUNT 3 | ||
128 | #define ADT7473_REG_PWM(x) (ADT7473_REG_PWM_BASE_ADDR + (x)) | ||
129 | #define ADT7473_REG_PWM_MAX(x) (ADT7473_REG_PWM_MAX_BASE_ADDR + (x)) | ||
130 | #define ADT7473_REG_PWM_MIN(x) (ADT7473_REG_PWM_MIN_BASE_ADDR + (x)) | ||
131 | #define ADT7473_REG_PWM_BHVR(x) (ADT7473_REG_PWM_BHVR_BASE_ADDR + (x)) | ||
132 | |||
133 | /* How often do we reread sensors values? (In jiffies) */ | ||
134 | #define SENSOR_REFRESH_INTERVAL (2 * HZ) | ||
135 | |||
136 | /* How often do we reread sensor limit values? (In jiffies) */ | ||
137 | #define LIMIT_REFRESH_INTERVAL (60 * HZ) | ||
138 | |||
139 | /* datasheet says to divide this number by the fan reading to get fan rpm */ | ||
140 | #define FAN_PERIOD_TO_RPM(x) ((90000 * 60) / (x)) | ||
141 | #define FAN_RPM_TO_PERIOD FAN_PERIOD_TO_RPM | ||
142 | #define FAN_PERIOD_INVALID 65535 | ||
143 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) | ||
144 | |||
145 | struct adt7473_data { | ||
146 | struct i2c_client client; | ||
147 | struct device *hwmon_dev; | ||
148 | struct attribute_group attrs; | ||
149 | struct mutex lock; | ||
150 | char sensors_valid; | ||
151 | char limits_valid; | ||
152 | unsigned long sensors_last_updated; /* In jiffies */ | ||
153 | unsigned long limits_last_updated; /* In jiffies */ | ||
154 | |||
155 | u8 volt[ADT7473_VOLT_COUNT]; | ||
156 | s8 volt_min[ADT7473_VOLT_COUNT]; | ||
157 | s8 volt_max[ADT7473_VOLT_COUNT]; | ||
158 | |||
159 | s8 temp[ADT7473_TEMP_COUNT]; | ||
160 | s8 temp_min[ADT7473_TEMP_COUNT]; | ||
161 | s8 temp_max[ADT7473_TEMP_COUNT]; | ||
162 | s8 temp_tmin[ADT7473_TEMP_COUNT]; | ||
163 | /* This is called the !THERM limit in the datasheet */ | ||
164 | s8 temp_tmax[ADT7473_TEMP_COUNT]; | ||
165 | |||
166 | u16 fan[ADT7473_FAN_COUNT]; | ||
167 | u16 fan_min[ADT7473_FAN_COUNT]; | ||
168 | |||
169 | u8 pwm[ADT7473_PWM_COUNT]; | ||
170 | u8 pwm_max[ADT7473_PWM_COUNT]; | ||
171 | u8 pwm_min[ADT7473_PWM_COUNT]; | ||
172 | u8 pwm_behavior[ADT7473_PWM_COUNT]; | ||
173 | |||
174 | u8 temp_twos_complement; | ||
175 | u8 temp_offset; | ||
176 | |||
177 | u16 alarm; | ||
178 | u8 max_duty_at_overheat; | ||
179 | }; | ||
180 | |||
181 | static int adt7473_attach_adapter(struct i2c_adapter *adapter); | ||
182 | static int adt7473_detect(struct i2c_adapter *adapter, int address, int kind); | ||
183 | static int adt7473_detach_client(struct i2c_client *client); | ||
184 | |||
185 | static struct i2c_driver adt7473_driver = { | ||
186 | .driver = { | ||
187 | .name = "adt7473", | ||
188 | }, | ||
189 | .attach_adapter = adt7473_attach_adapter, | ||
190 | .detach_client = adt7473_detach_client, | ||
191 | }; | ||
192 | |||
193 | /* | ||
194 | * 16-bit registers on the ADT7473 are low-byte first. The data sheet says | ||
195 | * that the low byte must be read before the high byte. | ||
196 | */ | ||
197 | static inline int adt7473_read_word_data(struct i2c_client *client, u8 reg) | ||
198 | { | ||
199 | u16 foo; | ||
200 | foo = i2c_smbus_read_byte_data(client, reg); | ||
201 | foo |= ((u16)i2c_smbus_read_byte_data(client, reg + 1) << 8); | ||
202 | return foo; | ||
203 | } | ||
204 | |||
205 | static inline int adt7473_write_word_data(struct i2c_client *client, u8 reg, | ||
206 | u16 value) | ||
207 | { | ||
208 | return i2c_smbus_write_byte_data(client, reg, value & 0xFF) | ||
209 | && i2c_smbus_write_byte_data(client, reg + 1, value >> 8); | ||
210 | } | ||
211 | |||
212 | static void adt7473_init_client(struct i2c_client *client) | ||
213 | { | ||
214 | int reg = i2c_smbus_read_byte_data(client, ADT7473_REG_CFG1); | ||
215 | |||
216 | if (!(reg & ADT7473_CFG1_READY)) { | ||
217 | dev_err(&client->dev, "Chip not ready.\n"); | ||
218 | } else { | ||
219 | /* start monitoring */ | ||
220 | i2c_smbus_write_byte_data(client, ADT7473_REG_CFG1, | ||
221 | reg | ADT7473_CFG1_START); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | static struct adt7473_data *adt7473_update_device(struct device *dev) | ||
226 | { | ||
227 | struct i2c_client *client = to_i2c_client(dev); | ||
228 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
229 | unsigned long local_jiffies = jiffies; | ||
230 | u8 cfg; | ||
231 | int i; | ||
232 | |||
233 | mutex_lock(&data->lock); | ||
234 | if (time_before(local_jiffies, data->sensors_last_updated + | ||
235 | SENSOR_REFRESH_INTERVAL) | ||
236 | && data->sensors_valid) | ||
237 | goto no_sensor_update; | ||
238 | |||
239 | for (i = 0; i < ADT7473_VOLT_COUNT; i++) | ||
240 | data->volt[i] = i2c_smbus_read_byte_data(client, | ||
241 | ADT7473_REG_VOLT(i)); | ||
242 | |||
243 | /* Determine temperature encoding */ | ||
244 | cfg = i2c_smbus_read_byte_data(client, ADT7473_REG_CFG5); | ||
245 | data->temp_twos_complement = (cfg & ADT7473_CFG5_TEMP_TWOS); | ||
246 | |||
247 | /* | ||
248 | * What does this do? it implies a variable temperature sensor | ||
249 | * offset, but the datasheet doesn't say anything about this bit | ||
250 | * and other parts of the datasheet imply that "offset64" mode | ||
251 | * means that you shift temp values by -64 if the above bit was set. | ||
252 | */ | ||
253 | data->temp_offset = (cfg & ADT7473_CFG5_TEMP_OFFSET); | ||
254 | |||
255 | for (i = 0; i < ADT7473_TEMP_COUNT; i++) | ||
256 | data->temp[i] = i2c_smbus_read_byte_data(client, | ||
257 | ADT7473_REG_TEMP(i)); | ||
258 | |||
259 | for (i = 0; i < ADT7473_FAN_COUNT; i++) | ||
260 | data->fan[i] = adt7473_read_word_data(client, | ||
261 | ADT7473_REG_FAN(i)); | ||
262 | |||
263 | for (i = 0; i < ADT7473_PWM_COUNT; i++) | ||
264 | data->pwm[i] = i2c_smbus_read_byte_data(client, | ||
265 | ADT7473_REG_PWM(i)); | ||
266 | |||
267 | data->alarm = i2c_smbus_read_byte_data(client, ADT7473_REG_ALARM1); | ||
268 | if (data->alarm & ADT7473_OOL) | ||
269 | data->alarm |= ALARM2(i2c_smbus_read_byte_data(client, | ||
270 | ADT7473_REG_ALARM2)); | ||
271 | |||
272 | data->sensors_last_updated = local_jiffies; | ||
273 | data->sensors_valid = 1; | ||
274 | |||
275 | no_sensor_update: | ||
276 | if (time_before(local_jiffies, data->limits_last_updated + | ||
277 | LIMIT_REFRESH_INTERVAL) | ||
278 | && data->limits_valid) | ||
279 | goto out; | ||
280 | |||
281 | for (i = 0; i < ADT7473_VOLT_COUNT; i++) { | ||
282 | data->volt_min[i] = i2c_smbus_read_byte_data(client, | ||
283 | ADT7473_REG_VOLT_MIN(i)); | ||
284 | data->volt_max[i] = i2c_smbus_read_byte_data(client, | ||
285 | ADT7473_REG_VOLT_MAX(i)); | ||
286 | } | ||
287 | |||
288 | for (i = 0; i < ADT7473_TEMP_COUNT; i++) { | ||
289 | data->temp_min[i] = i2c_smbus_read_byte_data(client, | ||
290 | ADT7473_REG_TEMP_MIN(i)); | ||
291 | data->temp_max[i] = i2c_smbus_read_byte_data(client, | ||
292 | ADT7473_REG_TEMP_MAX(i)); | ||
293 | data->temp_tmin[i] = i2c_smbus_read_byte_data(client, | ||
294 | ADT7473_REG_TEMP_TMIN(i)); | ||
295 | data->temp_tmax[i] = i2c_smbus_read_byte_data(client, | ||
296 | ADT7473_REG_TEMP_TMAX(i)); | ||
297 | } | ||
298 | |||
299 | for (i = 0; i < ADT7473_FAN_COUNT; i++) | ||
300 | data->fan_min[i] = adt7473_read_word_data(client, | ||
301 | ADT7473_REG_FAN_MIN(i)); | ||
302 | |||
303 | for (i = 0; i < ADT7473_PWM_COUNT; i++) { | ||
304 | data->pwm_max[i] = i2c_smbus_read_byte_data(client, | ||
305 | ADT7473_REG_PWM_MAX(i)); | ||
306 | data->pwm_min[i] = i2c_smbus_read_byte_data(client, | ||
307 | ADT7473_REG_PWM_MIN(i)); | ||
308 | data->pwm_behavior[i] = i2c_smbus_read_byte_data(client, | ||
309 | ADT7473_REG_PWM_BHVR(i)); | ||
310 | } | ||
311 | |||
312 | data->limits_last_updated = local_jiffies; | ||
313 | data->limits_valid = 1; | ||
314 | |||
315 | out: | ||
316 | mutex_unlock(&data->lock); | ||
317 | return data; | ||
318 | } | ||
319 | |||
320 | /* | ||
321 | * On this chip, voltages are given as a count of steps between a minimum | ||
322 | * and maximum voltage, not a direct voltage. | ||
323 | */ | ||
324 | static const int volt_convert_table[][2] = { | ||
325 | {2997, 3}, | ||
326 | {4395, 4}, | ||
327 | }; | ||
328 | |||
329 | static int decode_volt(int volt_index, u8 raw) | ||
330 | { | ||
331 | int cmax = volt_convert_table[volt_index][0]; | ||
332 | int cmin = volt_convert_table[volt_index][1]; | ||
333 | return ((raw * (cmax - cmin)) / 255) + cmin; | ||
334 | } | ||
335 | |||
336 | static u8 encode_volt(int volt_index, int cooked) | ||
337 | { | ||
338 | int cmax = volt_convert_table[volt_index][0]; | ||
339 | int cmin = volt_convert_table[volt_index][1]; | ||
340 | u8 x; | ||
341 | |||
342 | if (cooked > cmax) | ||
343 | cooked = cmax; | ||
344 | else if (cooked < cmin) | ||
345 | cooked = cmin; | ||
346 | |||
347 | x = ((cooked - cmin) * 255) / (cmax - cmin); | ||
348 | |||
349 | return x; | ||
350 | } | ||
351 | |||
352 | static ssize_t show_volt_min(struct device *dev, | ||
353 | struct device_attribute *devattr, | ||
354 | char *buf) | ||
355 | { | ||
356 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
357 | struct adt7473_data *data = adt7473_update_device(dev); | ||
358 | return sprintf(buf, "%d\n", | ||
359 | decode_volt(attr->index, data->volt_min[attr->index])); | ||
360 | } | ||
361 | |||
362 | static ssize_t set_volt_min(struct device *dev, | ||
363 | struct device_attribute *devattr, | ||
364 | const char *buf, | ||
365 | size_t count) | ||
366 | { | ||
367 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
368 | struct i2c_client *client = to_i2c_client(dev); | ||
369 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
370 | int volt = encode_volt(attr->index, simple_strtol(buf, NULL, 10)); | ||
371 | |||
372 | mutex_lock(&data->lock); | ||
373 | data->volt_min[attr->index] = volt; | ||
374 | i2c_smbus_write_byte_data(client, ADT7473_REG_VOLT_MIN(attr->index), | ||
375 | volt); | ||
376 | mutex_unlock(&data->lock); | ||
377 | |||
378 | return count; | ||
379 | } | ||
380 | |||
381 | static ssize_t show_volt_max(struct device *dev, | ||
382 | struct device_attribute *devattr, | ||
383 | char *buf) | ||
384 | { | ||
385 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
386 | struct adt7473_data *data = adt7473_update_device(dev); | ||
387 | return sprintf(buf, "%d\n", | ||
388 | decode_volt(attr->index, data->volt_max[attr->index])); | ||
389 | } | ||
390 | |||
391 | static ssize_t set_volt_max(struct device *dev, | ||
392 | struct device_attribute *devattr, | ||
393 | const char *buf, | ||
394 | size_t count) | ||
395 | { | ||
396 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
397 | struct i2c_client *client = to_i2c_client(dev); | ||
398 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
399 | int volt = encode_volt(attr->index, simple_strtol(buf, NULL, 10)); | ||
400 | |||
401 | mutex_lock(&data->lock); | ||
402 | data->volt_max[attr->index] = volt; | ||
403 | i2c_smbus_write_byte_data(client, ADT7473_REG_VOLT_MAX(attr->index), | ||
404 | volt); | ||
405 | mutex_unlock(&data->lock); | ||
406 | |||
407 | return count; | ||
408 | } | ||
409 | |||
410 | static ssize_t show_volt(struct device *dev, struct device_attribute *devattr, | ||
411 | char *buf) | ||
412 | { | ||
413 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
414 | struct adt7473_data *data = adt7473_update_device(dev); | ||
415 | |||
416 | return sprintf(buf, "%d\n", | ||
417 | decode_volt(attr->index, data->volt[attr->index])); | ||
418 | } | ||
419 | |||
420 | /* | ||
421 | * This chip can report temperature data either as a two's complement | ||
422 | * number in the range -128 to 127, or as an unsigned number that must | ||
423 | * be offset by 64. | ||
424 | */ | ||
425 | static int decode_temp(struct adt7473_data *data, u8 raw) | ||
426 | { | ||
427 | if (data->temp_twos_complement) | ||
428 | return (s8)raw; | ||
429 | return raw - 64; | ||
430 | } | ||
431 | |||
432 | static u8 encode_temp(struct adt7473_data *data, int cooked) | ||
433 | { | ||
434 | if (data->temp_twos_complement) | ||
435 | return (cooked & 0xFF); | ||
436 | return cooked + 64; | ||
437 | } | ||
438 | |||
439 | static ssize_t show_temp_min(struct device *dev, | ||
440 | struct device_attribute *devattr, | ||
441 | char *buf) | ||
442 | { | ||
443 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
444 | struct adt7473_data *data = adt7473_update_device(dev); | ||
445 | return sprintf(buf, "%d\n", | ||
446 | 1000 * decode_temp(data, data->temp_min[attr->index])); | ||
447 | } | ||
448 | |||
449 | static ssize_t set_temp_min(struct device *dev, | ||
450 | struct device_attribute *devattr, | ||
451 | const char *buf, | ||
452 | size_t count) | ||
453 | { | ||
454 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
455 | struct i2c_client *client = to_i2c_client(dev); | ||
456 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
457 | int temp = simple_strtol(buf, NULL, 10) / 1000; | ||
458 | temp = encode_temp(data, temp); | ||
459 | |||
460 | mutex_lock(&data->lock); | ||
461 | data->temp_min[attr->index] = temp; | ||
462 | i2c_smbus_write_byte_data(client, ADT7473_REG_TEMP_MIN(attr->index), | ||
463 | temp); | ||
464 | mutex_unlock(&data->lock); | ||
465 | |||
466 | return count; | ||
467 | } | ||
468 | |||
469 | static ssize_t show_temp_max(struct device *dev, | ||
470 | struct device_attribute *devattr, | ||
471 | char *buf) | ||
472 | { | ||
473 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
474 | struct adt7473_data *data = adt7473_update_device(dev); | ||
475 | return sprintf(buf, "%d\n", | ||
476 | 1000 * decode_temp(data, data->temp_max[attr->index])); | ||
477 | } | ||
478 | |||
479 | static ssize_t set_temp_max(struct device *dev, | ||
480 | struct device_attribute *devattr, | ||
481 | const char *buf, | ||
482 | size_t count) | ||
483 | { | ||
484 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
485 | struct i2c_client *client = to_i2c_client(dev); | ||
486 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
487 | int temp = simple_strtol(buf, NULL, 10) / 1000; | ||
488 | temp = encode_temp(data, temp); | ||
489 | |||
490 | mutex_lock(&data->lock); | ||
491 | data->temp_max[attr->index] = temp; | ||
492 | i2c_smbus_write_byte_data(client, ADT7473_REG_TEMP_MAX(attr->index), | ||
493 | temp); | ||
494 | mutex_unlock(&data->lock); | ||
495 | |||
496 | return count; | ||
497 | } | ||
498 | |||
499 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, | ||
500 | char *buf) | ||
501 | { | ||
502 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
503 | struct adt7473_data *data = adt7473_update_device(dev); | ||
504 | return sprintf(buf, "%d\n", | ||
505 | 1000 * decode_temp(data, data->temp[attr->index])); | ||
506 | } | ||
507 | |||
508 | static ssize_t show_fan_min(struct device *dev, | ||
509 | struct device_attribute *devattr, | ||
510 | char *buf) | ||
511 | { | ||
512 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
513 | struct adt7473_data *data = adt7473_update_device(dev); | ||
514 | |||
515 | if (FAN_DATA_VALID(data->fan_min[attr->index])) | ||
516 | return sprintf(buf, "%d\n", | ||
517 | FAN_PERIOD_TO_RPM(data->fan_min[attr->index])); | ||
518 | else | ||
519 | return sprintf(buf, "0\n"); | ||
520 | } | ||
521 | |||
522 | static ssize_t set_fan_min(struct device *dev, | ||
523 | struct device_attribute *devattr, | ||
524 | const char *buf, size_t count) | ||
525 | { | ||
526 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
527 | struct i2c_client *client = to_i2c_client(dev); | ||
528 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
529 | int temp = simple_strtol(buf, NULL, 10); | ||
530 | |||
531 | if (!temp) | ||
532 | return -EINVAL; | ||
533 | temp = FAN_RPM_TO_PERIOD(temp); | ||
534 | |||
535 | mutex_lock(&data->lock); | ||
536 | data->fan_min[attr->index] = temp; | ||
537 | adt7473_write_word_data(client, ADT7473_REG_FAN_MIN(attr->index), temp); | ||
538 | mutex_unlock(&data->lock); | ||
539 | |||
540 | return count; | ||
541 | } | ||
542 | |||
543 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, | ||
544 | char *buf) | ||
545 | { | ||
546 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
547 | struct adt7473_data *data = adt7473_update_device(dev); | ||
548 | |||
549 | if (FAN_DATA_VALID(data->fan[attr->index])) | ||
550 | return sprintf(buf, "%d\n", | ||
551 | FAN_PERIOD_TO_RPM(data->fan[attr->index])); | ||
552 | else | ||
553 | return sprintf(buf, "0\n"); | ||
554 | } | ||
555 | |||
556 | static ssize_t show_max_duty_at_crit(struct device *dev, | ||
557 | struct device_attribute *devattr, | ||
558 | char *buf) | ||
559 | { | ||
560 | struct adt7473_data *data = adt7473_update_device(dev); | ||
561 | return sprintf(buf, "%d\n", data->max_duty_at_overheat); | ||
562 | } | ||
563 | |||
564 | static ssize_t set_max_duty_at_crit(struct device *dev, | ||
565 | struct device_attribute *devattr, | ||
566 | const char *buf, | ||
567 | size_t count) | ||
568 | { | ||
569 | u8 reg; | ||
570 | struct i2c_client *client = to_i2c_client(dev); | ||
571 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
572 | int temp = simple_strtol(buf, NULL, 10); | ||
573 | temp = temp && 0xFF; | ||
574 | |||
575 | mutex_lock(&data->lock); | ||
576 | data->max_duty_at_overheat = temp; | ||
577 | reg = i2c_smbus_read_byte_data(client, ADT7473_REG_CFG4); | ||
578 | if (temp) | ||
579 | reg |= ADT7473_CFG4_MAX_DUTY_AT_OVT; | ||
580 | else | ||
581 | reg &= ~ADT7473_CFG4_MAX_DUTY_AT_OVT; | ||
582 | i2c_smbus_write_byte_data(client, ADT7473_REG_CFG4, reg); | ||
583 | mutex_unlock(&data->lock); | ||
584 | |||
585 | return count; | ||
586 | } | ||
587 | |||
588 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, | ||
589 | char *buf) | ||
590 | { | ||
591 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
592 | struct adt7473_data *data = adt7473_update_device(dev); | ||
593 | return sprintf(buf, "%d\n", data->pwm[attr->index]); | ||
594 | } | ||
595 | |||
596 | static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, | ||
597 | const char *buf, size_t count) | ||
598 | { | ||
599 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
600 | struct i2c_client *client = to_i2c_client(dev); | ||
601 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
602 | int temp = simple_strtol(buf, NULL, 10); | ||
603 | |||
604 | mutex_lock(&data->lock); | ||
605 | data->pwm[attr->index] = temp; | ||
606 | i2c_smbus_write_byte_data(client, ADT7473_REG_PWM(attr->index), temp); | ||
607 | mutex_unlock(&data->lock); | ||
608 | |||
609 | return count; | ||
610 | } | ||
611 | |||
612 | static ssize_t show_pwm_max(struct device *dev, | ||
613 | struct device_attribute *devattr, | ||
614 | char *buf) | ||
615 | { | ||
616 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
617 | struct adt7473_data *data = adt7473_update_device(dev); | ||
618 | return sprintf(buf, "%d\n", data->pwm_max[attr->index]); | ||
619 | } | ||
620 | |||
621 | static ssize_t set_pwm_max(struct device *dev, | ||
622 | struct device_attribute *devattr, | ||
623 | const char *buf, | ||
624 | size_t count) | ||
625 | { | ||
626 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
627 | struct i2c_client *client = to_i2c_client(dev); | ||
628 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
629 | int temp = simple_strtol(buf, NULL, 10); | ||
630 | |||
631 | mutex_lock(&data->lock); | ||
632 | data->pwm_max[attr->index] = temp; | ||
633 | i2c_smbus_write_byte_data(client, ADT7473_REG_PWM_MAX(attr->index), | ||
634 | temp); | ||
635 | mutex_unlock(&data->lock); | ||
636 | |||
637 | return count; | ||
638 | } | ||
639 | |||
640 | static ssize_t show_pwm_min(struct device *dev, | ||
641 | struct device_attribute *devattr, | ||
642 | char *buf) | ||
643 | { | ||
644 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
645 | struct adt7473_data *data = adt7473_update_device(dev); | ||
646 | return sprintf(buf, "%d\n", data->pwm_min[attr->index]); | ||
647 | } | ||
648 | |||
649 | static ssize_t set_pwm_min(struct device *dev, | ||
650 | struct device_attribute *devattr, | ||
651 | const char *buf, | ||
652 | size_t count) | ||
653 | { | ||
654 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
655 | struct i2c_client *client = to_i2c_client(dev); | ||
656 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
657 | int temp = simple_strtol(buf, NULL, 10); | ||
658 | |||
659 | mutex_lock(&data->lock); | ||
660 | data->pwm_min[attr->index] = temp; | ||
661 | i2c_smbus_write_byte_data(client, ADT7473_REG_PWM_MIN(attr->index), | ||
662 | temp); | ||
663 | mutex_unlock(&data->lock); | ||
664 | |||
665 | return count; | ||
666 | } | ||
667 | |||
668 | static ssize_t show_temp_tmax(struct device *dev, | ||
669 | struct device_attribute *devattr, | ||
670 | char *buf) | ||
671 | { | ||
672 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
673 | struct adt7473_data *data = adt7473_update_device(dev); | ||
674 | return sprintf(buf, "%d\n", | ||
675 | 1000 * decode_temp(data, data->temp_tmax[attr->index])); | ||
676 | } | ||
677 | |||
678 | static ssize_t set_temp_tmax(struct device *dev, | ||
679 | struct device_attribute *devattr, | ||
680 | const char *buf, | ||
681 | size_t count) | ||
682 | { | ||
683 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
684 | struct i2c_client *client = to_i2c_client(dev); | ||
685 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
686 | int temp = simple_strtol(buf, NULL, 10) / 1000; | ||
687 | temp = encode_temp(data, temp); | ||
688 | |||
689 | mutex_lock(&data->lock); | ||
690 | data->temp_tmax[attr->index] = temp; | ||
691 | i2c_smbus_write_byte_data(client, ADT7473_REG_TEMP_TMAX(attr->index), | ||
692 | temp); | ||
693 | mutex_unlock(&data->lock); | ||
694 | |||
695 | return count; | ||
696 | } | ||
697 | |||
698 | static ssize_t show_temp_tmin(struct device *dev, | ||
699 | struct device_attribute *devattr, | ||
700 | char *buf) | ||
701 | { | ||
702 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
703 | struct adt7473_data *data = adt7473_update_device(dev); | ||
704 | return sprintf(buf, "%d\n", | ||
705 | 1000 * decode_temp(data, data->temp_tmin[attr->index])); | ||
706 | } | ||
707 | |||
708 | static ssize_t set_temp_tmin(struct device *dev, | ||
709 | struct device_attribute *devattr, | ||
710 | const char *buf, | ||
711 | size_t count) | ||
712 | { | ||
713 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
714 | struct i2c_client *client = to_i2c_client(dev); | ||
715 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
716 | int temp = simple_strtol(buf, NULL, 10) / 1000; | ||
717 | temp = encode_temp(data, temp); | ||
718 | |||
719 | mutex_lock(&data->lock); | ||
720 | data->temp_tmin[attr->index] = temp; | ||
721 | i2c_smbus_write_byte_data(client, ADT7473_REG_TEMP_TMIN(attr->index), | ||
722 | temp); | ||
723 | mutex_unlock(&data->lock); | ||
724 | |||
725 | return count; | ||
726 | } | ||
727 | |||
728 | static ssize_t show_pwm_enable(struct device *dev, | ||
729 | struct device_attribute *devattr, | ||
730 | char *buf) | ||
731 | { | ||
732 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
733 | struct adt7473_data *data = adt7473_update_device(dev); | ||
734 | |||
735 | switch (data->pwm_behavior[attr->index] >> ADT7473_PWM_BHVR_SHIFT) { | ||
736 | case 3: | ||
737 | return sprintf(buf, "0\n"); | ||
738 | case 7: | ||
739 | return sprintf(buf, "1\n"); | ||
740 | default: | ||
741 | return sprintf(buf, "2\n"); | ||
742 | } | ||
743 | } | ||
744 | |||
745 | static ssize_t set_pwm_enable(struct device *dev, | ||
746 | struct device_attribute *devattr, | ||
747 | const char *buf, | ||
748 | size_t count) | ||
749 | { | ||
750 | u8 reg; | ||
751 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
752 | struct i2c_client *client = to_i2c_client(dev); | ||
753 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
754 | int temp = simple_strtol(buf, NULL, 10); | ||
755 | |||
756 | switch (temp) { | ||
757 | case 0: | ||
758 | temp = 3; | ||
759 | break; | ||
760 | case 1: | ||
761 | temp = 7; | ||
762 | break; | ||
763 | case 2: | ||
764 | /* Enter automatic mode with fans off */ | ||
765 | temp = 4; | ||
766 | break; | ||
767 | default: | ||
768 | return -EINVAL; | ||
769 | } | ||
770 | |||
771 | mutex_lock(&data->lock); | ||
772 | reg = i2c_smbus_read_byte_data(client, | ||
773 | ADT7473_REG_PWM_BHVR(attr->index)); | ||
774 | reg = (temp << ADT7473_PWM_BHVR_SHIFT) | | ||
775 | (reg & ~ADT7473_PWM_BHVR_MASK); | ||
776 | i2c_smbus_write_byte_data(client, ADT7473_REG_PWM_BHVR(attr->index), | ||
777 | reg); | ||
778 | data->pwm_behavior[attr->index] = reg; | ||
779 | mutex_unlock(&data->lock); | ||
780 | |||
781 | return count; | ||
782 | } | ||
783 | |||
784 | static ssize_t show_pwm_auto_temp(struct device *dev, | ||
785 | struct device_attribute *devattr, | ||
786 | char *buf) | ||
787 | { | ||
788 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
789 | struct adt7473_data *data = adt7473_update_device(dev); | ||
790 | int bhvr = data->pwm_behavior[attr->index] >> ADT7473_PWM_BHVR_SHIFT; | ||
791 | |||
792 | switch (bhvr) { | ||
793 | case 3: | ||
794 | case 4: | ||
795 | case 7: | ||
796 | return sprintf(buf, "0\n"); | ||
797 | case 0: | ||
798 | case 1: | ||
799 | case 5: | ||
800 | case 6: | ||
801 | return sprintf(buf, "%d\n", bhvr + 1); | ||
802 | case 2: | ||
803 | return sprintf(buf, "4\n"); | ||
804 | } | ||
805 | /* shouldn't ever get here */ | ||
806 | BUG(); | ||
807 | } | ||
808 | |||
809 | static ssize_t set_pwm_auto_temp(struct device *dev, | ||
810 | struct device_attribute *devattr, | ||
811 | const char *buf, | ||
812 | size_t count) | ||
813 | { | ||
814 | u8 reg; | ||
815 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
816 | struct i2c_client *client = to_i2c_client(dev); | ||
817 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
818 | int temp = simple_strtol(buf, NULL, 10); | ||
819 | |||
820 | switch (temp) { | ||
821 | case 1: | ||
822 | case 2: | ||
823 | case 6: | ||
824 | case 7: | ||
825 | temp--; | ||
826 | break; | ||
827 | case 0: | ||
828 | temp = 4; | ||
829 | break; | ||
830 | default: | ||
831 | return -EINVAL; | ||
832 | } | ||
833 | |||
834 | mutex_lock(&data->lock); | ||
835 | reg = i2c_smbus_read_byte_data(client, | ||
836 | ADT7473_REG_PWM_BHVR(attr->index)); | ||
837 | reg = (temp << ADT7473_PWM_BHVR_SHIFT) | | ||
838 | (reg & ~ADT7473_PWM_BHVR_MASK); | ||
839 | i2c_smbus_write_byte_data(client, ADT7473_REG_PWM_BHVR(attr->index), | ||
840 | reg); | ||
841 | data->pwm_behavior[attr->index] = reg; | ||
842 | mutex_unlock(&data->lock); | ||
843 | |||
844 | return count; | ||
845 | } | ||
846 | |||
847 | static ssize_t show_alarm(struct device *dev, | ||
848 | struct device_attribute *devattr, | ||
849 | char *buf) | ||
850 | { | ||
851 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
852 | struct adt7473_data *data = adt7473_update_device(dev); | ||
853 | |||
854 | if (data->alarm & attr->index) | ||
855 | return sprintf(buf, "1\n"); | ||
856 | else | ||
857 | return sprintf(buf, "0\n"); | ||
858 | } | ||
859 | |||
860 | |||
861 | static SENSOR_DEVICE_ATTR(in1_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
862 | set_volt_max, 0); | ||
863 | static SENSOR_DEVICE_ATTR(in2_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
864 | set_volt_max, 1); | ||
865 | |||
866 | static SENSOR_DEVICE_ATTR(in1_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
867 | set_volt_min, 0); | ||
868 | static SENSOR_DEVICE_ATTR(in2_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
869 | set_volt_min, 1); | ||
870 | |||
871 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_volt, NULL, 0); | ||
872 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_volt, NULL, 1); | ||
873 | |||
874 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, | ||
875 | ADT7473_VCCP_ALARM); | ||
876 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, | ||
877 | ADT7473_VCC_ALARM); | ||
878 | |||
879 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, | ||
880 | set_temp_max, 0); | ||
881 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, | ||
882 | set_temp_max, 1); | ||
883 | static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_max, | ||
884 | set_temp_max, 2); | ||
885 | |||
886 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min, | ||
887 | set_temp_min, 0); | ||
888 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_min, | ||
889 | set_temp_min, 1); | ||
890 | static SENSOR_DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_temp_min, | ||
891 | set_temp_min, 2); | ||
892 | |||
893 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); | ||
894 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); | ||
895 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); | ||
896 | |||
897 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, | ||
898 | ADT7473_R1T_ALARM | ALARM2(ADT7473_R1T_SHORT)); | ||
899 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, | ||
900 | ADT7473_LT_ALARM); | ||
901 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, | ||
902 | ADT7473_R2T_ALARM | ALARM2(ADT7473_R2T_SHORT)); | ||
903 | |||
904 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
905 | set_fan_min, 0); | ||
906 | static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
907 | set_fan_min, 1); | ||
908 | static SENSOR_DEVICE_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
909 | set_fan_min, 2); | ||
910 | static SENSOR_DEVICE_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
911 | set_fan_min, 3); | ||
912 | |||
913 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); | ||
914 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); | ||
915 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); | ||
916 | static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); | ||
917 | |||
918 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, | ||
919 | ALARM2(ADT7473_FAN1_ALARM)); | ||
920 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, | ||
921 | ALARM2(ADT7473_FAN2_ALARM)); | ||
922 | static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, | ||
923 | ALARM2(ADT7473_FAN3_ALARM)); | ||
924 | static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, | ||
925 | ALARM2(ADT7473_FAN4_ALARM)); | ||
926 | |||
927 | static SENSOR_DEVICE_ATTR(pwm_use_point2_pwm_at_crit, S_IWUSR | S_IRUGO, | ||
928 | show_max_duty_at_crit, set_max_duty_at_crit, 0); | ||
929 | |||
930 | static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); | ||
931 | static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); | ||
932 | static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); | ||
933 | |||
934 | static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IWUSR | S_IRUGO, | ||
935 | show_pwm_min, set_pwm_min, 0); | ||
936 | static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm, S_IWUSR | S_IRUGO, | ||
937 | show_pwm_min, set_pwm_min, 1); | ||
938 | static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm, S_IWUSR | S_IRUGO, | ||
939 | show_pwm_min, set_pwm_min, 2); | ||
940 | |||
941 | static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IWUSR | S_IRUGO, | ||
942 | show_pwm_max, set_pwm_max, 0); | ||
943 | static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm, S_IWUSR | S_IRUGO, | ||
944 | show_pwm_max, set_pwm_max, 1); | ||
945 | static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm, S_IWUSR | S_IRUGO, | ||
946 | show_pwm_max, set_pwm_max, 2); | ||
947 | |||
948 | static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp, S_IWUSR | S_IRUGO, | ||
949 | show_temp_tmin, set_temp_tmin, 0); | ||
950 | static SENSOR_DEVICE_ATTR(temp2_auto_point1_temp, S_IWUSR | S_IRUGO, | ||
951 | show_temp_tmin, set_temp_tmin, 1); | ||
952 | static SENSOR_DEVICE_ATTR(temp3_auto_point1_temp, S_IWUSR | S_IRUGO, | ||
953 | show_temp_tmin, set_temp_tmin, 2); | ||
954 | |||
955 | static SENSOR_DEVICE_ATTR(temp1_auto_point2_temp, S_IWUSR | S_IRUGO, | ||
956 | show_temp_tmax, set_temp_tmax, 0); | ||
957 | static SENSOR_DEVICE_ATTR(temp2_auto_point2_temp, S_IWUSR | S_IRUGO, | ||
958 | show_temp_tmax, set_temp_tmax, 1); | ||
959 | static SENSOR_DEVICE_ATTR(temp3_auto_point2_temp, S_IWUSR | S_IRUGO, | ||
960 | show_temp_tmax, set_temp_tmax, 2); | ||
961 | |||
962 | static SENSOR_DEVICE_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, show_pwm_enable, | ||
963 | set_pwm_enable, 0); | ||
964 | static SENSOR_DEVICE_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, show_pwm_enable, | ||
965 | set_pwm_enable, 1); | ||
966 | static SENSOR_DEVICE_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, show_pwm_enable, | ||
967 | set_pwm_enable, 2); | ||
968 | |||
969 | static SENSOR_DEVICE_ATTR(pwm1_auto_channels_temp, S_IWUSR | S_IRUGO, | ||
970 | show_pwm_auto_temp, set_pwm_auto_temp, 0); | ||
971 | static SENSOR_DEVICE_ATTR(pwm2_auto_channels_temp, S_IWUSR | S_IRUGO, | ||
972 | show_pwm_auto_temp, set_pwm_auto_temp, 1); | ||
973 | static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp, S_IWUSR | S_IRUGO, | ||
974 | show_pwm_auto_temp, set_pwm_auto_temp, 2); | ||
975 | |||
976 | static struct attribute *adt7473_attr[] = | ||
977 | { | ||
978 | &sensor_dev_attr_in1_max.dev_attr.attr, | ||
979 | &sensor_dev_attr_in2_max.dev_attr.attr, | ||
980 | &sensor_dev_attr_in1_min.dev_attr.attr, | ||
981 | &sensor_dev_attr_in2_min.dev_attr.attr, | ||
982 | &sensor_dev_attr_in1_input.dev_attr.attr, | ||
983 | &sensor_dev_attr_in2_input.dev_attr.attr, | ||
984 | &sensor_dev_attr_in1_alarm.dev_attr.attr, | ||
985 | &sensor_dev_attr_in2_alarm.dev_attr.attr, | ||
986 | |||
987 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
988 | &sensor_dev_attr_temp2_max.dev_attr.attr, | ||
989 | &sensor_dev_attr_temp3_max.dev_attr.attr, | ||
990 | &sensor_dev_attr_temp1_min.dev_attr.attr, | ||
991 | &sensor_dev_attr_temp2_min.dev_attr.attr, | ||
992 | &sensor_dev_attr_temp3_min.dev_attr.attr, | ||
993 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
994 | &sensor_dev_attr_temp2_input.dev_attr.attr, | ||
995 | &sensor_dev_attr_temp3_input.dev_attr.attr, | ||
996 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | ||
997 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | ||
998 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | ||
999 | &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr, | ||
1000 | &sensor_dev_attr_temp2_auto_point1_temp.dev_attr.attr, | ||
1001 | &sensor_dev_attr_temp3_auto_point1_temp.dev_attr.attr, | ||
1002 | &sensor_dev_attr_temp1_auto_point2_temp.dev_attr.attr, | ||
1003 | &sensor_dev_attr_temp2_auto_point2_temp.dev_attr.attr, | ||
1004 | &sensor_dev_attr_temp3_auto_point2_temp.dev_attr.attr, | ||
1005 | |||
1006 | &sensor_dev_attr_fan1_min.dev_attr.attr, | ||
1007 | &sensor_dev_attr_fan2_min.dev_attr.attr, | ||
1008 | &sensor_dev_attr_fan3_min.dev_attr.attr, | ||
1009 | &sensor_dev_attr_fan4_min.dev_attr.attr, | ||
1010 | &sensor_dev_attr_fan1_input.dev_attr.attr, | ||
1011 | &sensor_dev_attr_fan2_input.dev_attr.attr, | ||
1012 | &sensor_dev_attr_fan3_input.dev_attr.attr, | ||
1013 | &sensor_dev_attr_fan4_input.dev_attr.attr, | ||
1014 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
1015 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
1016 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
1017 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, | ||
1018 | |||
1019 | &sensor_dev_attr_pwm_use_point2_pwm_at_crit.dev_attr.attr, | ||
1020 | |||
1021 | &sensor_dev_attr_pwm1.dev_attr.attr, | ||
1022 | &sensor_dev_attr_pwm2.dev_attr.attr, | ||
1023 | &sensor_dev_attr_pwm3.dev_attr.attr, | ||
1024 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, | ||
1025 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, | ||
1026 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, | ||
1027 | &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr, | ||
1028 | &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, | ||
1029 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, | ||
1030 | |||
1031 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | ||
1032 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | ||
1033 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | ||
1034 | &sensor_dev_attr_pwm1_auto_channels_temp.dev_attr.attr, | ||
1035 | &sensor_dev_attr_pwm2_auto_channels_temp.dev_attr.attr, | ||
1036 | &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr, | ||
1037 | |||
1038 | NULL | ||
1039 | }; | ||
1040 | |||
1041 | static int adt7473_attach_adapter(struct i2c_adapter *adapter) | ||
1042 | { | ||
1043 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
1044 | return 0; | ||
1045 | return i2c_probe(adapter, &addr_data, adt7473_detect); | ||
1046 | } | ||
1047 | |||
1048 | static int adt7473_detect(struct i2c_adapter *adapter, int address, int kind) | ||
1049 | { | ||
1050 | struct i2c_client *client; | ||
1051 | struct adt7473_data *data; | ||
1052 | int err = 0; | ||
1053 | |||
1054 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
1055 | goto exit; | ||
1056 | |||
1057 | data = kzalloc(sizeof(struct adt7473_data), GFP_KERNEL); | ||
1058 | if (!data) { | ||
1059 | err = -ENOMEM; | ||
1060 | goto exit; | ||
1061 | } | ||
1062 | |||
1063 | client = &data->client; | ||
1064 | client->addr = address; | ||
1065 | client->adapter = adapter; | ||
1066 | client->driver = &adt7473_driver; | ||
1067 | |||
1068 | i2c_set_clientdata(client, data); | ||
1069 | |||
1070 | mutex_init(&data->lock); | ||
1071 | |||
1072 | if (kind <= 0) { | ||
1073 | int vendor, device, revision; | ||
1074 | |||
1075 | vendor = i2c_smbus_read_byte_data(client, ADT7473_REG_VENDOR); | ||
1076 | if (vendor != ADT7473_VENDOR) { | ||
1077 | err = -ENODEV; | ||
1078 | goto exit_free; | ||
1079 | } | ||
1080 | |||
1081 | device = i2c_smbus_read_byte_data(client, ADT7473_REG_DEVICE); | ||
1082 | if (device != ADT7473_DEVICE) { | ||
1083 | err = -ENODEV; | ||
1084 | goto exit_free; | ||
1085 | } | ||
1086 | |||
1087 | revision = i2c_smbus_read_byte_data(client, | ||
1088 | ADT7473_REG_REVISION); | ||
1089 | if (revision != ADT7473_REV_68 && revision != ADT7473_REV_69) { | ||
1090 | err = -ENODEV; | ||
1091 | goto exit_free; | ||
1092 | } | ||
1093 | } else | ||
1094 | dev_dbg(&adapter->dev, "detection forced\n"); | ||
1095 | |||
1096 | strlcpy(client->name, "adt7473", I2C_NAME_SIZE); | ||
1097 | |||
1098 | err = i2c_attach_client(client); | ||
1099 | if (err) | ||
1100 | goto exit_free; | ||
1101 | |||
1102 | dev_info(&client->dev, "%s chip found\n", client->name); | ||
1103 | |||
1104 | /* Initialize the ADT7473 chip */ | ||
1105 | adt7473_init_client(client); | ||
1106 | |||
1107 | /* Register sysfs hooks */ | ||
1108 | data->attrs.attrs = adt7473_attr; | ||
1109 | err = sysfs_create_group(&client->dev.kobj, &data->attrs); | ||
1110 | if (err) | ||
1111 | goto exit_detach; | ||
1112 | |||
1113 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
1114 | if (IS_ERR(data->hwmon_dev)) { | ||
1115 | err = PTR_ERR(data->hwmon_dev); | ||
1116 | goto exit_remove; | ||
1117 | } | ||
1118 | |||
1119 | return 0; | ||
1120 | |||
1121 | exit_remove: | ||
1122 | sysfs_remove_group(&client->dev.kobj, &data->attrs); | ||
1123 | exit_detach: | ||
1124 | i2c_detach_client(client); | ||
1125 | exit_free: | ||
1126 | kfree(data); | ||
1127 | exit: | ||
1128 | return err; | ||
1129 | } | ||
1130 | |||
1131 | static int adt7473_detach_client(struct i2c_client *client) | ||
1132 | { | ||
1133 | struct adt7473_data *data = i2c_get_clientdata(client); | ||
1134 | |||
1135 | hwmon_device_unregister(data->hwmon_dev); | ||
1136 | sysfs_remove_group(&client->dev.kobj, &data->attrs); | ||
1137 | i2c_detach_client(client); | ||
1138 | kfree(data); | ||
1139 | return 0; | ||
1140 | } | ||
1141 | |||
1142 | static int __init adt7473_init(void) | ||
1143 | { | ||
1144 | return i2c_add_driver(&adt7473_driver); | ||
1145 | } | ||
1146 | |||
1147 | static void __exit adt7473_exit(void) | ||
1148 | { | ||
1149 | i2c_del_driver(&adt7473_driver); | ||
1150 | } | ||
1151 | |||
1152 | MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>"); | ||
1153 | MODULE_DESCRIPTION("ADT7473 driver"); | ||
1154 | MODULE_LICENSE("GPL"); | ||
1155 | |||
1156 | module_init(adt7473_init); | ||
1157 | module_exit(adt7473_exit); | ||
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 0c94770b7f83..aacc0c4b809c 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c | |||
@@ -84,12 +84,15 @@ static const char* temperature_sensors_sets[][36] = { | |||
84 | /* Set 0: Macbook Pro */ | 84 | /* Set 0: Macbook Pro */ |
85 | { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H", | 85 | { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H", |
86 | "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL }, | 86 | "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL }, |
87 | /* Set 1: Macbook set */ | 87 | /* Set 1: Macbook2 set */ |
88 | { "TB0T", "TC0D", "TC0P", "TM0P", "TN0P", "TN1P", "TTF0", "Th0H", | ||
89 | "Th0S", "Th1H", NULL }, | ||
90 | /* Set 2: Macbook set */ | ||
88 | { "TB0T", "TC0D", "TC0P", "TM0P", "TN0P", "TN1P", "Th0H", "Th0S", | 91 | { "TB0T", "TC0D", "TC0P", "TM0P", "TN0P", "TN1P", "Th0H", "Th0S", |
89 | "Th1H", "Ts0P", NULL }, | 92 | "Th1H", "Ts0P", NULL }, |
90 | /* Set 2: Macmini set */ | 93 | /* Set 3: Macmini set */ |
91 | { "TC0D", "TC0P", NULL }, | 94 | { "TC0D", "TC0P", NULL }, |
92 | /* Set 3: Mac Pro (2 x Quad-Core) */ | 95 | /* Set 4: Mac Pro (2 x Quad-Core) */ |
93 | { "TA0P", "TCAG", "TCAH", "TCBG", "TCBH", "TC0C", "TC0D", "TC0P", | 96 | { "TA0P", "TCAG", "TCAH", "TCBG", "TCBH", "TC0C", "TC0D", "TC0P", |
94 | "TC1C", "TC1D", "TC2C", "TC2D", "TC3C", "TC3D", "THTG", "TH0P", | 97 | "TC1C", "TC1D", "TC2C", "TC2D", "TC3C", "TC3D", "THTG", "TH0P", |
95 | "TH1P", "TH2P", "TH3P", "TMAP", "TMAS", "TMBS", "TM0P", "TM0S", | 98 | "TH1P", "TH2P", "TH3P", "TMAP", "TMAS", "TMBS", "TM0P", "TM0S", |
@@ -1212,12 +1215,14 @@ static void applesmc_release_accelerometer(void) | |||
1212 | static __initdata struct dmi_match_data applesmc_dmi_data[] = { | 1215 | static __initdata struct dmi_match_data applesmc_dmi_data[] = { |
1213 | /* MacBook Pro: accelerometer, backlight and temperature set 0 */ | 1216 | /* MacBook Pro: accelerometer, backlight and temperature set 0 */ |
1214 | { .accelerometer = 1, .light = 1, .temperature_set = 0 }, | 1217 | { .accelerometer = 1, .light = 1, .temperature_set = 0 }, |
1215 | /* MacBook: accelerometer and temperature set 1 */ | 1218 | /* MacBook2: accelerometer and temperature set 1 */ |
1216 | { .accelerometer = 1, .light = 0, .temperature_set = 1 }, | 1219 | { .accelerometer = 1, .light = 0, .temperature_set = 1 }, |
1217 | /* MacMini: temperature set 2 */ | 1220 | /* MacBook: accelerometer and temperature set 2 */ |
1218 | { .accelerometer = 0, .light = 0, .temperature_set = 2 }, | 1221 | { .accelerometer = 1, .light = 0, .temperature_set = 2 }, |
1219 | /* MacPro: temperature set 3 */ | 1222 | /* MacMini: temperature set 3 */ |
1220 | { .accelerometer = 0, .light = 0, .temperature_set = 3 }, | 1223 | { .accelerometer = 0, .light = 0, .temperature_set = 3 }, |
1224 | /* MacPro: temperature set 4 */ | ||
1225 | { .accelerometer = 0, .light = 0, .temperature_set = 4 }, | ||
1221 | }; | 1226 | }; |
1222 | 1227 | ||
1223 | /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". | 1228 | /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". |
@@ -1229,16 +1234,20 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = { | |||
1229 | (void*)&applesmc_dmi_data[0]}, | 1234 | (void*)&applesmc_dmi_data[0]}, |
1230 | { applesmc_dmi_match, "Apple MacBook", { | 1235 | { applesmc_dmi_match, "Apple MacBook", { |
1231 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | 1236 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), |
1232 | DMI_MATCH(DMI_PRODUCT_NAME,"MacBook") }, | 1237 | DMI_MATCH(DMI_PRODUCT_NAME,"MacBook2") }, |
1233 | (void*)&applesmc_dmi_data[1]}, | 1238 | (void*)&applesmc_dmi_data[1]}, |
1239 | { applesmc_dmi_match, "Apple MacBook", { | ||
1240 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | ||
1241 | DMI_MATCH(DMI_PRODUCT_NAME,"MacBook") }, | ||
1242 | (void*)&applesmc_dmi_data[2]}, | ||
1234 | { applesmc_dmi_match, "Apple Macmini", { | 1243 | { applesmc_dmi_match, "Apple Macmini", { |
1235 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | 1244 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), |
1236 | DMI_MATCH(DMI_PRODUCT_NAME,"Macmini") }, | 1245 | DMI_MATCH(DMI_PRODUCT_NAME,"Macmini") }, |
1237 | (void*)&applesmc_dmi_data[2]}, | 1246 | (void*)&applesmc_dmi_data[3]}, |
1238 | { applesmc_dmi_match, "Apple MacPro2", { | 1247 | { applesmc_dmi_match, "Apple MacPro2", { |
1239 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | 1248 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), |
1240 | DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") }, | 1249 | DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") }, |
1241 | (void*)&applesmc_dmi_data[3]}, | 1250 | (void*)&applesmc_dmi_data[4]}, |
1242 | { .ident = NULL } | 1251 | { .ident = NULL } |
1243 | }; | 1252 | }; |
1244 | 1253 | ||
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 950cea8d1d65..84712a22acea 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #include "lm75.h" | 49 | #include "lm75.h" |
50 | 50 | ||
51 | /* I2C addresses to scan */ | 51 | /* I2C addresses to scan */ |
52 | static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; | 52 | static const unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; |
53 | 53 | ||
54 | /* Insmod parameters */ | 54 | /* Insmod parameters */ |
55 | I2C_CLIENT_INSMOD_1(asb100); | 55 | I2C_CLIENT_INSMOD_1(asb100); |
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index cce3350e539e..01c17e387f03 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -42,7 +42,7 @@ MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>"); | |||
42 | #define ATXP1_VIDMASK 0x1f | 42 | #define ATXP1_VIDMASK 0x1f |
43 | #define ATXP1_GPIO1MASK 0x0f | 43 | #define ATXP1_GPIO1MASK 0x0f |
44 | 44 | ||
45 | static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; | 45 | static const unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; |
46 | 46 | ||
47 | I2C_CLIENT_INSMOD_1(atxp1); | 47 | I2C_CLIENT_INSMOD_1(atxp1); |
48 | 48 | ||
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 3ee60d26e3a2..70239acecc8e 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
@@ -38,7 +38,8 @@ | |||
38 | 38 | ||
39 | #define DRVNAME "coretemp" | 39 | #define DRVNAME "coretemp" |
40 | 40 | ||
41 | typedef enum { SHOW_TEMP, SHOW_TJMAX, SHOW_LABEL, SHOW_NAME } SHOW; | 41 | typedef enum { SHOW_TEMP, SHOW_TJMAX, SHOW_TTARGET, SHOW_LABEL, |
42 | SHOW_NAME } SHOW; | ||
42 | 43 | ||
43 | /* | 44 | /* |
44 | * Functions declaration | 45 | * Functions declaration |
@@ -55,6 +56,7 @@ struct coretemp_data { | |||
55 | unsigned long last_updated; /* in jiffies */ | 56 | unsigned long last_updated; /* in jiffies */ |
56 | int temp; | 57 | int temp; |
57 | int tjmax; | 58 | int tjmax; |
59 | int ttarget; | ||
58 | u8 alarm; | 60 | u8 alarm; |
59 | }; | 61 | }; |
60 | 62 | ||
@@ -93,9 +95,10 @@ static ssize_t show_temp(struct device *dev, | |||
93 | 95 | ||
94 | if (attr->index == SHOW_TEMP) | 96 | if (attr->index == SHOW_TEMP) |
95 | err = data->valid ? sprintf(buf, "%d\n", data->temp) : -EAGAIN; | 97 | err = data->valid ? sprintf(buf, "%d\n", data->temp) : -EAGAIN; |
96 | else | 98 | else if (attr->index == SHOW_TJMAX) |
97 | err = sprintf(buf, "%d\n", data->tjmax); | 99 | err = sprintf(buf, "%d\n", data->tjmax); |
98 | 100 | else | |
101 | err = sprintf(buf, "%d\n", data->ttarget); | ||
99 | return err; | 102 | return err; |
100 | } | 103 | } |
101 | 104 | ||
@@ -103,6 +106,8 @@ static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, | |||
103 | SHOW_TEMP); | 106 | SHOW_TEMP); |
104 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, | 107 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, |
105 | SHOW_TJMAX); | 108 | SHOW_TJMAX); |
109 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, | ||
110 | SHOW_TTARGET); | ||
106 | static DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL); | 111 | static DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL); |
107 | static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_name, NULL, SHOW_LABEL); | 112 | static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_name, NULL, SHOW_LABEL); |
108 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, SHOW_NAME); | 113 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, SHOW_NAME); |
@@ -147,6 +152,56 @@ static struct coretemp_data *coretemp_update_device(struct device *dev) | |||
147 | return data; | 152 | return data; |
148 | } | 153 | } |
149 | 154 | ||
155 | static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) | ||
156 | { | ||
157 | /* The 100C is default for both mobile and non mobile CPUs */ | ||
158 | |||
159 | int tjmax = 100000; | ||
160 | int ismobile = 1; | ||
161 | int err; | ||
162 | u32 eax, edx; | ||
163 | |||
164 | /* Early chips have no MSR for TjMax */ | ||
165 | |||
166 | if ((c->x86_model == 0xf) && (c->x86_mask < 4)) { | ||
167 | ismobile = 0; | ||
168 | } | ||
169 | |||
170 | if ((c->x86_model > 0xe) && (ismobile)) { | ||
171 | |||
172 | /* Now we can detect the mobile CPU using Intel provided table | ||
173 | http://softwarecommunity.intel.com/Wiki/Mobility/720.htm | ||
174 | For Core2 cores, check MSR 0x17, bit 28 1 = Mobile CPU | ||
175 | */ | ||
176 | |||
177 | err = rdmsr_safe_on_cpu(id, 0x17, &eax, &edx); | ||
178 | if (err) { | ||
179 | dev_warn(dev, | ||
180 | "Unable to access MSR 0x17, assuming desktop" | ||
181 | " CPU\n"); | ||
182 | ismobile = 0; | ||
183 | } else if (!(eax & 0x10000000)) { | ||
184 | ismobile = 0; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | if (ismobile) { | ||
189 | |||
190 | err = rdmsr_safe_on_cpu(id, 0xee, &eax, &edx); | ||
191 | if (err) { | ||
192 | dev_warn(dev, | ||
193 | "Unable to access MSR 0xEE, for Tjmax, left" | ||
194 | " at default"); | ||
195 | } else if (eax & 0x40000000) { | ||
196 | tjmax = 85000; | ||
197 | } | ||
198 | } else { | ||
199 | dev_warn(dev, "Using relative temperature scale!\n"); | ||
200 | } | ||
201 | |||
202 | return tjmax; | ||
203 | } | ||
204 | |||
150 | static int __devinit coretemp_probe(struct platform_device *pdev) | 205 | static int __devinit coretemp_probe(struct platform_device *pdev) |
151 | { | 206 | { |
152 | struct coretemp_data *data; | 207 | struct coretemp_data *data; |
@@ -163,8 +218,6 @@ static int __devinit coretemp_probe(struct platform_device *pdev) | |||
163 | data->id = pdev->id; | 218 | data->id = pdev->id; |
164 | data->name = "coretemp"; | 219 | data->name = "coretemp"; |
165 | mutex_init(&data->update_lock); | 220 | mutex_init(&data->update_lock); |
166 | /* Tjmax default is 100 degrees C */ | ||
167 | data->tjmax = 100000; | ||
168 | 221 | ||
169 | /* test if we can access the THERM_STATUS MSR */ | 222 | /* test if we can access the THERM_STATUS MSR */ |
170 | err = rdmsr_safe_on_cpu(data->id, MSR_IA32_THERM_STATUS, &eax, &edx); | 223 | err = rdmsr_safe_on_cpu(data->id, MSR_IA32_THERM_STATUS, &eax, &edx); |
@@ -191,40 +244,29 @@ static int __devinit coretemp_probe(struct platform_device *pdev) | |||
191 | } | 244 | } |
192 | } | 245 | } |
193 | 246 | ||
194 | /* Some processors have Tjmax 85 following magic should detect it | 247 | data->tjmax = adjust_tjmax(c, data->id, &pdev->dev); |
195 | Intel won't disclose the information without signed NDA, but | 248 | platform_set_drvdata(pdev, data); |
196 | individuals cannot sign it. Catch(ed) 22. | ||
197 | */ | ||
198 | 249 | ||
199 | if (((c->x86_model == 0xf) && (c->x86_mask > 3)) || | 250 | /* read the still undocumented IA32_TEMPERATURE_TARGET it exists |
200 | (c->x86_model == 0xe)) { | 251 | on older CPUs but not in this register */ |
201 | err = rdmsr_safe_on_cpu(data->id, 0xee, &eax, &edx); | 252 | |
253 | if (c->x86_model > 0xe) { | ||
254 | err = rdmsr_safe_on_cpu(data->id, 0x1a2, &eax, &edx); | ||
202 | if (err) { | 255 | if (err) { |
203 | dev_warn(&pdev->dev, | 256 | dev_warn(&pdev->dev, "Unable to read" |
204 | "Unable to access MSR 0xEE, Tjmax left at %d " | 257 | " IA32_TEMPERATURE_TARGET MSR\n"); |
205 | "degrees C\n", data->tjmax/1000); | 258 | } else { |
206 | } else if (eax & 0x40000000) { | 259 | data->ttarget = data->tjmax - |
207 | data->tjmax = 85000; | 260 | (((eax >> 8) & 0xff) * 1000); |
261 | err = device_create_file(&pdev->dev, | ||
262 | &sensor_dev_attr_temp1_max.dev_attr); | ||
263 | if (err) | ||
264 | goto exit_free; | ||
208 | } | 265 | } |
209 | } | 266 | } |
210 | 267 | ||
211 | /* Intel says that above should not work for desktop Core2 processors, | ||
212 | but it seems to work. There is no other way how get the absolute | ||
213 | readings. Warn the user about this. First check if are desktop, | ||
214 | bit 50 of MSR_IA32_PLATFORM_ID should be 0. | ||
215 | */ | ||
216 | |||
217 | rdmsr_safe_on_cpu(data->id, MSR_IA32_PLATFORM_ID, &eax, &edx); | ||
218 | |||
219 | if ((c->x86_model == 0xf) && (!(edx & 0x00040000))) { | ||
220 | dev_warn(&pdev->dev, "Using undocumented features, absolute " | ||
221 | "temperature might be wrong!\n"); | ||
222 | } | ||
223 | |||
224 | platform_set_drvdata(pdev, data); | ||
225 | |||
226 | if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group))) | 268 | if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group))) |
227 | goto exit_free; | 269 | goto exit_dev; |
228 | 270 | ||
229 | data->hwmon_dev = hwmon_device_register(&pdev->dev); | 271 | data->hwmon_dev = hwmon_device_register(&pdev->dev); |
230 | if (IS_ERR(data->hwmon_dev)) { | 272 | if (IS_ERR(data->hwmon_dev)) { |
@@ -238,6 +280,8 @@ static int __devinit coretemp_probe(struct platform_device *pdev) | |||
238 | 280 | ||
239 | exit_class: | 281 | exit_class: |
240 | sysfs_remove_group(&pdev->dev.kobj, &coretemp_group); | 282 | sysfs_remove_group(&pdev->dev.kobj, &coretemp_group); |
283 | exit_dev: | ||
284 | device_remove_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr); | ||
241 | exit_free: | 285 | exit_free: |
242 | kfree(data); | 286 | kfree(data); |
243 | exit: | 287 | exit: |
@@ -250,6 +294,7 @@ static int __devexit coretemp_remove(struct platform_device *pdev) | |||
250 | 294 | ||
251 | hwmon_device_unregister(data->hwmon_dev); | 295 | hwmon_device_unregister(data->hwmon_dev); |
252 | sysfs_remove_group(&pdev->dev.kobj, &coretemp_group); | 296 | sysfs_remove_group(&pdev->dev.kobj, &coretemp_group); |
297 | device_remove_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr); | ||
253 | platform_set_drvdata(pdev, NULL); | 298 | platform_set_drvdata(pdev, NULL); |
254 | kfree(data); | 299 | kfree(data); |
255 | return 0; | 300 | return 0; |
@@ -330,7 +375,7 @@ static void coretemp_device_remove(unsigned int cpu) | |||
330 | mutex_unlock(&pdev_list_mutex); | 375 | mutex_unlock(&pdev_list_mutex); |
331 | } | 376 | } |
332 | 377 | ||
333 | static int coretemp_cpu_callback(struct notifier_block *nfb, | 378 | static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb, |
334 | unsigned long action, void *hcpu) | 379 | unsigned long action, void *hcpu) |
335 | { | 380 | { |
336 | unsigned int cpu = (unsigned long) hcpu; | 381 | unsigned int cpu = (unsigned long) hcpu; |
@@ -347,7 +392,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb, | |||
347 | return NOTIFY_OK; | 392 | return NOTIFY_OK; |
348 | } | 393 | } |
349 | 394 | ||
350 | static struct notifier_block coretemp_cpu_notifier = { | 395 | static struct notifier_block coretemp_cpu_notifier __refdata = { |
351 | .notifier_call = coretemp_cpu_callback, | 396 | .notifier_call = coretemp_cpu_callback, |
352 | }; | 397 | }; |
353 | #endif /* !CONFIG_HOTPLUG_CPU */ | 398 | #endif /* !CONFIG_HOTPLUG_CPU */ |
@@ -368,10 +413,10 @@ static int __init coretemp_init(void) | |||
368 | for_each_online_cpu(i) { | 413 | for_each_online_cpu(i) { |
369 | struct cpuinfo_x86 *c = &cpu_data(i); | 414 | struct cpuinfo_x86 *c = &cpu_data(i); |
370 | 415 | ||
371 | /* check if family 6, models e, f, 16 */ | 416 | /* check if family 6, models 0xe, 0xf, 0x16, 0x17 */ |
372 | if ((c->cpuid_level < 0) || (c->x86 != 0x6) || | 417 | if ((c->cpuid_level < 0) || (c->x86 != 0x6) || |
373 | !((c->x86_model == 0xe) || (c->x86_model == 0xf) || | 418 | !((c->x86_model == 0xe) || (c->x86_model == 0xf) || |
374 | (c->x86_model == 0x16))) { | 419 | (c->x86_model == 0x16) || (c->x86_model == 0x17))) { |
375 | 420 | ||
376 | /* supported CPU not found, but report the unknown | 421 | /* supported CPU not found, but report the unknown |
377 | family 6 CPU */ | 422 | family 6 CPU */ |
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c index ddddd9f34c19..7673f65877e1 100644 --- a/drivers/hwmon/dme1737.c +++ b/drivers/hwmon/dme1737.c | |||
@@ -49,7 +49,7 @@ module_param(force_id, ushort, 0); | |||
49 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); | 49 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
50 | 50 | ||
51 | /* Addresses to scan */ | 51 | /* Addresses to scan */ |
52 | static unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END}; | 52 | static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END}; |
53 | 53 | ||
54 | /* Insmod parameters */ | 54 | /* Insmod parameters */ |
55 | I2C_CLIENT_INSMOD_1(dme1737); | 55 | I2C_CLIENT_INSMOD_1(dme1737); |
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 3f5163de13c1..5f300ffed657 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "lm75.h" | 34 | #include "lm75.h" |
35 | 35 | ||
36 | /* Addresses to scan */ | 36 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | 37 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
38 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; | 38 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; |
39 | 39 | ||
40 | /* Insmod parameters */ | 40 | /* Insmod parameters */ |
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c index 6892f76fc18a..1464338e4e11 100644 --- a/drivers/hwmon/f75375s.c +++ b/drivers/hwmon/f75375s.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/f75375s.h> | 37 | #include <linux/f75375s.h> |
38 | 38 | ||
39 | /* Addresses to scan */ | 39 | /* Addresses to scan */ |
40 | static unsigned short normal_i2c[] = { 0x2d, 0x2e, I2C_CLIENT_END }; | 40 | static const unsigned short normal_i2c[] = { 0x2d, 0x2e, I2C_CLIENT_END }; |
41 | 41 | ||
42 | /* Insmod parameters */ | 42 | /* Insmod parameters */ |
43 | I2C_CLIENT_INSMOD_2(f75373, f75375); | 43 | I2C_CLIENT_INSMOD_2(f75373, f75375); |
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index 721c70177b17..ed26b66e0831 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c | |||
@@ -40,7 +40,7 @@ | |||
40 | * Addresses to scan | 40 | * Addresses to scan |
41 | */ | 41 | */ |
42 | 42 | ||
43 | static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; | 43 | static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * Insmod parameters | 46 | * Insmod parameters |
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c index b7c9eef0f928..bd89d270a5ed 100644 --- a/drivers/hwmon/fschmd.c +++ b/drivers/hwmon/fschmd.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/dmi.h> | 44 | #include <linux/dmi.h> |
45 | 45 | ||
46 | /* Addresses to scan */ | 46 | /* Addresses to scan */ |
47 | static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; | 47 | static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; |
48 | 48 | ||
49 | /* Insmod parameters */ | 49 | /* Insmod parameters */ |
50 | I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd); | 50 | I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd); |
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 2f1075323a1e..00f48484e54b 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c | |||
@@ -43,7 +43,7 @@ | |||
43 | /* | 43 | /* |
44 | * Addresses to scan | 44 | * Addresses to scan |
45 | */ | 45 | */ |
46 | static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; | 46 | static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; |
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Insmod parameters | 49 | * Insmod parameters |
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 3b1ac48fce23..33e9e8a8d1ce 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/sysfs.h> | 44 | #include <linux/sysfs.h> |
45 | 45 | ||
46 | /* Addresses to scan */ | 46 | /* Addresses to scan */ |
47 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 47 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
48 | 48 | ||
49 | /* Insmod parameters */ | 49 | /* Insmod parameters */ |
50 | I2C_CLIENT_INSMOD_2(gl518sm_r00, gl518sm_r80); | 50 | I2C_CLIENT_INSMOD_2(gl518sm_r00, gl518sm_r80); |
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 03ecdc334764..8984ef141627 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -39,7 +39,7 @@ module_param(extra_sensor_type, ushort, 0); | |||
39 | MODULE_PARM_DESC(extra_sensor_type, "Type of extra sensor (0=autodetect, 1=temperature, 2=voltage)"); | 39 | MODULE_PARM_DESC(extra_sensor_type, "Type of extra sensor (0=autodetect, 1=temperature, 2=voltage)"); |
40 | 40 | ||
41 | /* Addresses to scan */ | 41 | /* Addresses to scan */ |
42 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 42 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
43 | 43 | ||
44 | /* Insmod parameters */ | 44 | /* Insmod parameters */ |
45 | I2C_CLIENT_INSMOD_1(gl520sm); | 45 | I2C_CLIENT_INSMOD_1(gl520sm); |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 650b07d5b902..116287008083 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -53,7 +53,7 @@ | |||
53 | * Address is fully defined internally and cannot be changed. | 53 | * Address is fully defined internally and cannot be changed. |
54 | */ | 54 | */ |
55 | 55 | ||
56 | static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; | 56 | static const unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * Insmod parameters | 59 | * Insmod parameters |
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index e5c35a355a57..115f4090b98e 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | /* Addresses to scan */ | 33 | /* Addresses to scan */ |
34 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | 34 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
35 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; | 35 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; |
36 | 36 | ||
37 | /* Insmod parameters */ | 37 | /* Insmod parameters */ |
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 459b70ad6bee..36d5a8c3ad8c 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -36,7 +36,8 @@ | |||
36 | #include <linux/mutex.h> | 36 | #include <linux/mutex.h> |
37 | 37 | ||
38 | /* Addresses to scan */ | 38 | /* Addresses to scan */ |
39 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; | 39 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, |
40 | I2C_CLIENT_END }; | ||
40 | 41 | ||
41 | /* Insmod parameters */ | 42 | /* Insmod parameters */ |
42 | I2C_CLIENT_INSMOD_1(lm77); | 43 | I2C_CLIENT_INSMOD_1(lm77); |
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 0a9eb1f6f4e4..ed7859f0e16a 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -37,8 +37,8 @@ | |||
37 | static struct platform_device *pdev; | 37 | static struct platform_device *pdev; |
38 | 38 | ||
39 | /* Addresses to scan */ | 39 | /* Addresses to scan */ |
40 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, | 40 | static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, |
41 | 0x2e, 0x2f, I2C_CLIENT_END }; | 41 | 0x2e, 0x2f, I2C_CLIENT_END }; |
42 | static unsigned short isa_address = 0x290; | 42 | static unsigned short isa_address = 0x290; |
43 | 43 | ||
44 | /* Insmod parameters */ | 44 | /* Insmod parameters */ |
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index a2ca055f3922..26c91c9d4769 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c | |||
@@ -32,8 +32,8 @@ | |||
32 | #include <linux/mutex.h> | 32 | #include <linux/mutex.h> |
33 | 33 | ||
34 | /* Addresses to scan */ | 34 | /* Addresses to scan */ |
35 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, | 35 | static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, |
36 | 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; | 36 | 0x2e, 0x2f, I2C_CLIENT_END }; |
37 | 37 | ||
38 | /* Insmod parameters */ | 38 | /* Insmod parameters */ |
39 | I2C_CLIENT_INSMOD_1(lm80); | 39 | I2C_CLIENT_INSMOD_1(lm80); |
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 6e8903a6e902..6a8642fa25fb 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -48,10 +48,8 @@ | |||
48 | * addresses. | 48 | * addresses. |
49 | */ | 49 | */ |
50 | 50 | ||
51 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, | 51 | static const unsigned short normal_i2c[] = { |
52 | 0x29, 0x2a, 0x2b, | 52 | 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; |
53 | 0x4c, 0x4d, 0x4e, | ||
54 | I2C_CLIENT_END }; | ||
55 | 53 | ||
56 | /* | 54 | /* |
57 | * Insmod parameters | 55 | * Insmod parameters |
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 4bb0f291a6b8..182fe6a5605f 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
36 | 36 | ||
37 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
38 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 38 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
39 | 39 | ||
40 | /* Insmod parameters */ | 40 | /* Insmod parameters */ |
41 | I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); | 41 | I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); |
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 8ee07c5c97a1..e1c183f0aae0 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -73,7 +73,7 @@ | |||
73 | * LM87 has three possible addresses: 0x2c, 0x2d and 0x2e. | 73 | * LM87 has three possible addresses: 0x2c, 0x2d and 0x2e. |
74 | */ | 74 | */ |
75 | 75 | ||
76 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 76 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
77 | 77 | ||
78 | /* | 78 | /* |
79 | * Insmod parameters | 79 | * Insmod parameters |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index f7ec95bedbf6..d1a3da3dd8e0 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -101,10 +101,8 @@ | |||
101 | * 0x4c, 0x4d or 0x4e. | 101 | * 0x4c, 0x4d or 0x4e. |
102 | */ | 102 | */ |
103 | 103 | ||
104 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, | 104 | static const unsigned short normal_i2c[] = { |
105 | 0x29, 0x2a, 0x2b, | 105 | 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; |
106 | 0x4c, 0x4d, 0x4e, | ||
107 | I2C_CLIENT_END }; | ||
108 | 106 | ||
109 | /* | 107 | /* |
110 | * Insmod parameters | 108 | * Insmod parameters |
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index af5c77d568fe..c31942e08246 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -45,13 +45,14 @@ | |||
45 | #include <linux/slab.h> | 45 | #include <linux/slab.h> |
46 | #include <linux/i2c.h> | 46 | #include <linux/i2c.h> |
47 | #include <linux/hwmon.h> | 47 | #include <linux/hwmon.h> |
48 | #include <linux/hwmon-sysfs.h> | ||
48 | #include <linux/err.h> | 49 | #include <linux/err.h> |
49 | #include <linux/mutex.h> | 50 | #include <linux/mutex.h> |
50 | 51 | ||
51 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, | 52 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, |
52 | resulting in 4 possible addresses. */ | 53 | resulting in 4 possible addresses. */ |
53 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, | 54 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, |
54 | I2C_CLIENT_END }; | 55 | I2C_CLIENT_END }; |
55 | 56 | ||
56 | /* Insmod parameters */ | 57 | /* Insmod parameters */ |
57 | I2C_CLIENT_INSMOD_1(lm92); | 58 | I2C_CLIENT_INSMOD_1(lm92); |
@@ -209,6 +210,14 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch | |||
209 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->temp1_input)); | 210 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->temp1_input)); |
210 | } | 211 | } |
211 | 212 | ||
213 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | ||
214 | char *buf) | ||
215 | { | ||
216 | int bitnr = to_sensor_dev_attr(attr)->index; | ||
217 | struct lm92_data *data = lm92_update_device(dev); | ||
218 | return sprintf(buf, "%d\n", (data->temp1_input >> bitnr) & 1); | ||
219 | } | ||
220 | |||
212 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); | 221 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); |
213 | static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp1_crit, | 222 | static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp1_crit, |
214 | set_temp1_crit); | 223 | set_temp1_crit); |
@@ -221,6 +230,9 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp1_max, | |||
221 | set_temp1_max); | 230 | set_temp1_max); |
222 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_temp1_max_hyst, NULL); | 231 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_temp1_max_hyst, NULL); |
223 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 232 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
233 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 2); | ||
234 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
235 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
224 | 236 | ||
225 | 237 | ||
226 | /* | 238 | /* |
@@ -297,7 +309,9 @@ static struct attribute *lm92_attributes[] = { | |||
297 | &dev_attr_temp1_max.attr, | 309 | &dev_attr_temp1_max.attr, |
298 | &dev_attr_temp1_max_hyst.attr, | 310 | &dev_attr_temp1_max_hyst.attr, |
299 | &dev_attr_alarms.attr, | 311 | &dev_attr_alarms.attr, |
300 | 312 | &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, | |
313 | &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, | ||
314 | &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, | ||
301 | NULL | 315 | NULL |
302 | }; | 316 | }; |
303 | 317 | ||
diff --git a/drivers/hwmon/lm93.c b/drivers/hwmon/lm93.c index ea61946a4bf7..5e678f5c883d 100644 --- a/drivers/hwmon/lm93.c +++ b/drivers/hwmon/lm93.c | |||
@@ -142,7 +142,7 @@ | |||
142 | I2C_FUNC_SMBUS_WORD_DATA) | 142 | I2C_FUNC_SMBUS_WORD_DATA) |
143 | 143 | ||
144 | /* Addresses to scan */ | 144 | /* Addresses to scan */ |
145 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 145 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
146 | 146 | ||
147 | /* Insmod parameters */ | 147 | /* Insmod parameters */ |
148 | I2C_CLIENT_INSMOD_1(lm93); | 148 | I2C_CLIENT_INSMOD_1(lm93); |
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 38a44c3d6cee..7e7267a04544 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -32,14 +32,13 @@ | |||
32 | #include <linux/jiffies.h> | 32 | #include <linux/jiffies.h> |
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/hwmon-sysfs.h> | ||
35 | #include <linux/err.h> | 36 | #include <linux/err.h> |
36 | #include <linux/mutex.h> | 37 | #include <linux/mutex.h> |
37 | #include <linux/sysfs.h> | 38 | #include <linux/sysfs.h> |
38 | 39 | ||
39 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, | 40 | static const unsigned short normal_i2c[] = { |
40 | 0x29, 0x2a, 0x2b, | 41 | 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; |
41 | 0x4c, 0x4d, 0x4e, | ||
42 | I2C_CLIENT_END }; | ||
43 | 42 | ||
44 | /* | 43 | /* |
45 | * Insmod parameters | 44 | * Insmod parameters |
@@ -161,6 +160,14 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch | |||
161 | return sprintf(buf, "%d\n", data->alarms); | 160 | return sprintf(buf, "%d\n", data->alarms); |
162 | } | 161 | } |
163 | 162 | ||
163 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | ||
164 | char *buf) | ||
165 | { | ||
166 | int bitnr = to_sensor_dev_attr(attr)->index; | ||
167 | struct max1619_data *data = max1619_update_device(dev); | ||
168 | return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1); | ||
169 | } | ||
170 | |||
164 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); | 171 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); |
165 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); | 172 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); |
166 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2, | 173 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2, |
@@ -172,6 +179,10 @@ static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2, | |||
172 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst2, | 179 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst2, |
173 | set_temp_hyst2); | 180 | set_temp_hyst2); |
174 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 181 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
182 | static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
183 | static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); | ||
184 | static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
185 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
175 | 186 | ||
176 | static struct attribute *max1619_attributes[] = { | 187 | static struct attribute *max1619_attributes[] = { |
177 | &dev_attr_temp1_input.attr, | 188 | &dev_attr_temp1_input.attr, |
@@ -182,6 +193,10 @@ static struct attribute *max1619_attributes[] = { | |||
182 | &dev_attr_temp2_crit_hyst.attr, | 193 | &dev_attr_temp2_crit_hyst.attr, |
183 | 194 | ||
184 | &dev_attr_alarms.attr, | 195 | &dev_attr_alarms.attr, |
196 | &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, | ||
197 | &sensor_dev_attr_temp2_fault.dev_attr.attr, | ||
198 | &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, | ||
199 | &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, | ||
185 | NULL | 200 | NULL |
186 | }; | 201 | }; |
187 | 202 | ||
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index 755570c1f4eb..52d528b76cc3 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c | |||
@@ -44,7 +44,8 @@ | |||
44 | * Addresses to scan. There are four disjoint possibilities, by pin config. | 44 | * Addresses to scan. There are four disjoint possibilities, by pin config. |
45 | */ | 45 | */ |
46 | 46 | ||
47 | static unsigned short normal_i2c[] = {0x1b, 0x1f, 0x48, 0x4b, I2C_CLIENT_END}; | 47 | static const unsigned short normal_i2c[] = {0x1b, 0x1f, 0x48, 0x4b, |
48 | I2C_CLIENT_END}; | ||
48 | 49 | ||
49 | /* | 50 | /* |
50 | * Insmod parameters | 51 | * Insmod parameters |
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 0d7f0c4d06bb..d1b498548736 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -198,6 +198,14 @@ static ssize_t get_fan_div(struct device *dev, struct device_attribute | |||
198 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[attr->index])); | 198 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[attr->index])); |
199 | } | 199 | } |
200 | 200 | ||
201 | static ssize_t get_fan_alarm(struct device *dev, struct device_attribute | ||
202 | *devattr, char *buf) | ||
203 | { | ||
204 | int bitnr = to_sensor_dev_attr(devattr)->index; | ||
205 | struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); | ||
206 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); | ||
207 | } | ||
208 | |||
201 | static ssize_t get_pwm(struct device *dev, struct device_attribute | 209 | static ssize_t get_pwm(struct device *dev, struct device_attribute |
202 | *devattr, char *buf) | 210 | *devattr, char *buf) |
203 | { | 211 | { |
@@ -347,6 +355,8 @@ static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | |||
347 | get_fan_min, set_fan_min, offset - 1); \ | 355 | get_fan_min, set_fan_min, offset - 1); \ |
348 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | 356 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ |
349 | get_fan_div, set_fan_div, offset - 1); \ | 357 | get_fan_div, set_fan_div, offset - 1); \ |
358 | static SENSOR_DEVICE_ATTR(fan##offset##_alarm, S_IRUGO, get_fan_alarm, \ | ||
359 | NULL, offset - 1); \ | ||
350 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ | 360 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ |
351 | get_pwm, set_pwm, offset - 1); \ | 361 | get_pwm, set_pwm, offset - 1); \ |
352 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ | 362 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ |
@@ -374,12 +384,15 @@ static struct attribute *smsc47m1_attributes[] = { | |||
374 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 384 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
375 | &sensor_dev_attr_fan1_min.dev_attr.attr, | 385 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
376 | &sensor_dev_attr_fan1_div.dev_attr.attr, | 386 | &sensor_dev_attr_fan1_div.dev_attr.attr, |
387 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
377 | &sensor_dev_attr_fan2_input.dev_attr.attr, | 388 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
378 | &sensor_dev_attr_fan2_min.dev_attr.attr, | 389 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
379 | &sensor_dev_attr_fan2_div.dev_attr.attr, | 390 | &sensor_dev_attr_fan2_div.dev_attr.attr, |
391 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
380 | &sensor_dev_attr_fan3_input.dev_attr.attr, | 392 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
381 | &sensor_dev_attr_fan3_min.dev_attr.attr, | 393 | &sensor_dev_attr_fan3_min.dev_attr.attr, |
382 | &sensor_dev_attr_fan3_div.dev_attr.attr, | 394 | &sensor_dev_attr_fan3_div.dev_attr.attr, |
395 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
383 | 396 | ||
384 | &sensor_dev_attr_pwm1.dev_attr.attr, | 397 | &sensor_dev_attr_pwm1.dev_attr.attr, |
385 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | 398 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
@@ -533,7 +546,9 @@ static int __devinit smsc47m1_probe(struct platform_device *pdev) | |||
533 | || (err = device_create_file(dev, | 546 | || (err = device_create_file(dev, |
534 | &sensor_dev_attr_fan1_min.dev_attr)) | 547 | &sensor_dev_attr_fan1_min.dev_attr)) |
535 | || (err = device_create_file(dev, | 548 | || (err = device_create_file(dev, |
536 | &sensor_dev_attr_fan1_div.dev_attr))) | 549 | &sensor_dev_attr_fan1_div.dev_attr)) |
550 | || (err = device_create_file(dev, | ||
551 | &sensor_dev_attr_fan1_alarm.dev_attr))) | ||
537 | goto error_remove_files; | 552 | goto error_remove_files; |
538 | } else | 553 | } else |
539 | dev_dbg(dev, "Fan 1 not enabled by hardware, skipping\n"); | 554 | dev_dbg(dev, "Fan 1 not enabled by hardware, skipping\n"); |
@@ -544,7 +559,9 @@ static int __devinit smsc47m1_probe(struct platform_device *pdev) | |||
544 | || (err = device_create_file(dev, | 559 | || (err = device_create_file(dev, |
545 | &sensor_dev_attr_fan2_min.dev_attr)) | 560 | &sensor_dev_attr_fan2_min.dev_attr)) |
546 | || (err = device_create_file(dev, | 561 | || (err = device_create_file(dev, |
547 | &sensor_dev_attr_fan2_div.dev_attr))) | 562 | &sensor_dev_attr_fan2_div.dev_attr)) |
563 | || (err = device_create_file(dev, | ||
564 | &sensor_dev_attr_fan2_alarm.dev_attr))) | ||
548 | goto error_remove_files; | 565 | goto error_remove_files; |
549 | } else | 566 | } else |
550 | dev_dbg(dev, "Fan 2 not enabled by hardware, skipping\n"); | 567 | dev_dbg(dev, "Fan 2 not enabled by hardware, skipping\n"); |
@@ -555,7 +572,9 @@ static int __devinit smsc47m1_probe(struct platform_device *pdev) | |||
555 | || (err = device_create_file(dev, | 572 | || (err = device_create_file(dev, |
556 | &sensor_dev_attr_fan3_min.dev_attr)) | 573 | &sensor_dev_attr_fan3_min.dev_attr)) |
557 | || (err = device_create_file(dev, | 574 | || (err = device_create_file(dev, |
558 | &sensor_dev_attr_fan3_div.dev_attr))) | 575 | &sensor_dev_attr_fan3_div.dev_attr)) |
576 | || (err = device_create_file(dev, | ||
577 | &sensor_dev_attr_fan3_alarm.dev_attr))) | ||
559 | goto error_remove_files; | 578 | goto error_remove_files; |
560 | } else if (data->type == smsc47m2) | 579 | } else if (data->type == smsc47m2) |
561 | dev_dbg(dev, "Fan 3 not enabled by hardware, skipping\n"); | 580 | dev_dbg(dev, "Fan 3 not enabled by hardware, skipping\n"); |
diff --git a/drivers/hwmon/smsc47m192.c b/drivers/hwmon/smsc47m192.c index 8b0c188e60f6..3c9db6598ba7 100644 --- a/drivers/hwmon/smsc47m192.c +++ b/drivers/hwmon/smsc47m192.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | 35 | ||
36 | /* Addresses to scan */ | 36 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 37 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
38 | 38 | ||
39 | /* Insmod parameters */ | 39 | /* Insmod parameters */ |
40 | I2C_CLIENT_INSMOD_1(smsc47m192); | 40 | I2C_CLIENT_INSMOD_1(smsc47m192); |
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c index 04dd7699b3ac..76a3859c3fbe 100644 --- a/drivers/hwmon/thmc50.c +++ b/drivers/hwmon/thmc50.c | |||
@@ -32,7 +32,7 @@ | |||
32 | MODULE_LICENSE("GPL"); | 32 | MODULE_LICENSE("GPL"); |
33 | 33 | ||
34 | /* Addresses to scan */ | 34 | /* Addresses to scan */ |
35 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 35 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
36 | 36 | ||
37 | /* Insmod parameters */ | 37 | /* Insmod parameters */ |
38 | I2C_CLIENT_INSMOD_2(thmc50, adm1022); | 38 | I2C_CLIENT_INSMOD_2(thmc50, adm1022); |
@@ -52,9 +52,9 @@ I2C_CLIENT_MODULE_PARM(adm1022_temp3, "List of adapter,address pairs " | |||
52 | */ | 52 | */ |
53 | #define THMC50_REG_INTR 0x41 | 53 | #define THMC50_REG_INTR 0x41 |
54 | 54 | ||
55 | const static u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 }; | 55 | static const u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 }; |
56 | const static u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C }; | 56 | static const u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C }; |
57 | const static u8 THMC50_REG_TEMP_MAX[] = { 0x39, 0x37, 0x2B }; | 57 | static const u8 THMC50_REG_TEMP_MAX[] = { 0x39, 0x37, 0x2B }; |
58 | 58 | ||
59 | #define THMC50_REG_CONF_nFANOFF 0x20 | 59 | #define THMC50_REG_CONF_nFANOFF 0x20 |
60 | 60 | ||
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 2635bba1e3fc..f1ee5e731968 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -533,6 +533,24 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch | |||
533 | } | 533 | } |
534 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 534 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
535 | 535 | ||
536 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | ||
537 | char *buf) | ||
538 | { | ||
539 | int bitnr = to_sensor_dev_attr(attr)->index; | ||
540 | struct via686a_data *data = via686a_update_device(dev); | ||
541 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); | ||
542 | } | ||
543 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
544 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
545 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); | ||
546 | static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
547 | static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); | ||
548 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
549 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 11); | ||
550 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 15); | ||
551 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); | ||
552 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); | ||
553 | |||
536 | static ssize_t show_name(struct device *dev, struct device_attribute | 554 | static ssize_t show_name(struct device *dev, struct device_attribute |
537 | *devattr, char *buf) | 555 | *devattr, char *buf) |
538 | { | 556 | { |
@@ -557,6 +575,11 @@ static struct attribute *via686a_attributes[] = { | |||
557 | &sensor_dev_attr_in2_max.dev_attr.attr, | 575 | &sensor_dev_attr_in2_max.dev_attr.attr, |
558 | &sensor_dev_attr_in3_max.dev_attr.attr, | 576 | &sensor_dev_attr_in3_max.dev_attr.attr, |
559 | &sensor_dev_attr_in4_max.dev_attr.attr, | 577 | &sensor_dev_attr_in4_max.dev_attr.attr, |
578 | &sensor_dev_attr_in0_alarm.dev_attr.attr, | ||
579 | &sensor_dev_attr_in1_alarm.dev_attr.attr, | ||
580 | &sensor_dev_attr_in2_alarm.dev_attr.attr, | ||
581 | &sensor_dev_attr_in3_alarm.dev_attr.attr, | ||
582 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
560 | 583 | ||
561 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 584 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
562 | &sensor_dev_attr_temp2_input.dev_attr.attr, | 585 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
@@ -567,6 +590,9 @@ static struct attribute *via686a_attributes[] = { | |||
567 | &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, | 590 | &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, |
568 | &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, | 591 | &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, |
569 | &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, | 592 | &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, |
593 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | ||
594 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | ||
595 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | ||
570 | 596 | ||
571 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 597 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
572 | &sensor_dev_attr_fan2_input.dev_attr.attr, | 598 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
@@ -574,6 +600,8 @@ static struct attribute *via686a_attributes[] = { | |||
574 | &sensor_dev_attr_fan2_min.dev_attr.attr, | 600 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
575 | &sensor_dev_attr_fan1_div.dev_attr.attr, | 601 | &sensor_dev_attr_fan1_div.dev_attr.attr, |
576 | &sensor_dev_attr_fan2_div.dev_attr.attr, | 602 | &sensor_dev_attr_fan2_div.dev_attr.attr, |
603 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
604 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
577 | 605 | ||
578 | &dev_attr_alarms.attr, | 606 | &dev_attr_alarms.attr, |
579 | &dev_attr_name.attr, | 607 | &dev_attr_name.attr, |
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index f87661775fe0..5bc57275cae8 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c | |||
@@ -2,7 +2,7 @@ | |||
2 | vt8231.c - Part of lm_sensors, Linux kernel modules | 2 | vt8231.c - Part of lm_sensors, Linux kernel modules |
3 | for hardware monitoring | 3 | for hardware monitoring |
4 | 4 | ||
5 | Copyright (c) 2005 Roger Lucas <roger@planbit.co.uk> | 5 | Copyright (c) 2005 Roger Lucas <vt8231@hiddenengine.co.uk> |
6 | Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> | 6 | Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> |
7 | Aaron M. Marsh <amarsh@sdf.lonestar.org> | 7 | Aaron M. Marsh <amarsh@sdf.lonestar.org> |
8 | 8 | ||
@@ -541,6 +541,28 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, | |||
541 | } | 541 | } |
542 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 542 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
543 | 543 | ||
544 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | ||
545 | char *buf) | ||
546 | { | ||
547 | int bitnr = to_sensor_dev_attr(attr)->index; | ||
548 | struct vt8231_data *data = vt8231_update_device(dev); | ||
549 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); | ||
550 | } | ||
551 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
552 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 11); | ||
553 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
554 | static SENSOR_DEVICE_ATTR(temp4_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
555 | static SENSOR_DEVICE_ATTR(temp5_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
556 | static SENSOR_DEVICE_ATTR(temp6_alarm, S_IRUGO, show_alarm, NULL, 8); | ||
557 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 11); | ||
558 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
559 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
560 | static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
561 | static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); | ||
562 | static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 2); | ||
563 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); | ||
564 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); | ||
565 | |||
544 | static ssize_t show_name(struct device *dev, struct device_attribute | 566 | static ssize_t show_name(struct device *dev, struct device_attribute |
545 | *devattr, char *buf) | 567 | *devattr, char *buf) |
546 | { | 568 | { |
@@ -549,36 +571,42 @@ static ssize_t show_name(struct device *dev, struct device_attribute | |||
549 | } | 571 | } |
550 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 572 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); |
551 | 573 | ||
552 | static struct attribute *vt8231_attributes_temps[6][4] = { | 574 | static struct attribute *vt8231_attributes_temps[6][5] = { |
553 | { | 575 | { |
554 | &dev_attr_temp1_input.attr, | 576 | &dev_attr_temp1_input.attr, |
555 | &dev_attr_temp1_max_hyst.attr, | 577 | &dev_attr_temp1_max_hyst.attr, |
556 | &dev_attr_temp1_max.attr, | 578 | &dev_attr_temp1_max.attr, |
579 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | ||
557 | NULL | 580 | NULL |
558 | }, { | 581 | }, { |
559 | &sensor_dev_attr_temp2_input.dev_attr.attr, | 582 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
560 | &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, | 583 | &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, |
561 | &sensor_dev_attr_temp2_max.dev_attr.attr, | 584 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
585 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | ||
562 | NULL | 586 | NULL |
563 | }, { | 587 | }, { |
564 | &sensor_dev_attr_temp3_input.dev_attr.attr, | 588 | &sensor_dev_attr_temp3_input.dev_attr.attr, |
565 | &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, | 589 | &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, |
566 | &sensor_dev_attr_temp3_max.dev_attr.attr, | 590 | &sensor_dev_attr_temp3_max.dev_attr.attr, |
591 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | ||
567 | NULL | 592 | NULL |
568 | }, { | 593 | }, { |
569 | &sensor_dev_attr_temp4_input.dev_attr.attr, | 594 | &sensor_dev_attr_temp4_input.dev_attr.attr, |
570 | &sensor_dev_attr_temp4_max_hyst.dev_attr.attr, | 595 | &sensor_dev_attr_temp4_max_hyst.dev_attr.attr, |
571 | &sensor_dev_attr_temp4_max.dev_attr.attr, | 596 | &sensor_dev_attr_temp4_max.dev_attr.attr, |
597 | &sensor_dev_attr_temp4_alarm.dev_attr.attr, | ||
572 | NULL | 598 | NULL |
573 | }, { | 599 | }, { |
574 | &sensor_dev_attr_temp5_input.dev_attr.attr, | 600 | &sensor_dev_attr_temp5_input.dev_attr.attr, |
575 | &sensor_dev_attr_temp5_max_hyst.dev_attr.attr, | 601 | &sensor_dev_attr_temp5_max_hyst.dev_attr.attr, |
576 | &sensor_dev_attr_temp5_max.dev_attr.attr, | 602 | &sensor_dev_attr_temp5_max.dev_attr.attr, |
603 | &sensor_dev_attr_temp5_alarm.dev_attr.attr, | ||
577 | NULL | 604 | NULL |
578 | }, { | 605 | }, { |
579 | &sensor_dev_attr_temp6_input.dev_attr.attr, | 606 | &sensor_dev_attr_temp6_input.dev_attr.attr, |
580 | &sensor_dev_attr_temp6_max_hyst.dev_attr.attr, | 607 | &sensor_dev_attr_temp6_max_hyst.dev_attr.attr, |
581 | &sensor_dev_attr_temp6_max.dev_attr.attr, | 608 | &sensor_dev_attr_temp6_max.dev_attr.attr, |
609 | &sensor_dev_attr_temp6_alarm.dev_attr.attr, | ||
582 | NULL | 610 | NULL |
583 | } | 611 | } |
584 | }; | 612 | }; |
@@ -592,36 +620,42 @@ static const struct attribute_group vt8231_group_temps[6] = { | |||
592 | { .attrs = vt8231_attributes_temps[5] }, | 620 | { .attrs = vt8231_attributes_temps[5] }, |
593 | }; | 621 | }; |
594 | 622 | ||
595 | static struct attribute *vt8231_attributes_volts[6][4] = { | 623 | static struct attribute *vt8231_attributes_volts[6][5] = { |
596 | { | 624 | { |
597 | &sensor_dev_attr_in0_input.dev_attr.attr, | 625 | &sensor_dev_attr_in0_input.dev_attr.attr, |
598 | &sensor_dev_attr_in0_min.dev_attr.attr, | 626 | &sensor_dev_attr_in0_min.dev_attr.attr, |
599 | &sensor_dev_attr_in0_max.dev_attr.attr, | 627 | &sensor_dev_attr_in0_max.dev_attr.attr, |
628 | &sensor_dev_attr_in0_alarm.dev_attr.attr, | ||
600 | NULL | 629 | NULL |
601 | }, { | 630 | }, { |
602 | &sensor_dev_attr_in1_input.dev_attr.attr, | 631 | &sensor_dev_attr_in1_input.dev_attr.attr, |
603 | &sensor_dev_attr_in1_min.dev_attr.attr, | 632 | &sensor_dev_attr_in1_min.dev_attr.attr, |
604 | &sensor_dev_attr_in1_max.dev_attr.attr, | 633 | &sensor_dev_attr_in1_max.dev_attr.attr, |
634 | &sensor_dev_attr_in1_alarm.dev_attr.attr, | ||
605 | NULL | 635 | NULL |
606 | }, { | 636 | }, { |
607 | &sensor_dev_attr_in2_input.dev_attr.attr, | 637 | &sensor_dev_attr_in2_input.dev_attr.attr, |
608 | &sensor_dev_attr_in2_min.dev_attr.attr, | 638 | &sensor_dev_attr_in2_min.dev_attr.attr, |
609 | &sensor_dev_attr_in2_max.dev_attr.attr, | 639 | &sensor_dev_attr_in2_max.dev_attr.attr, |
640 | &sensor_dev_attr_in2_alarm.dev_attr.attr, | ||
610 | NULL | 641 | NULL |
611 | }, { | 642 | }, { |
612 | &sensor_dev_attr_in3_input.dev_attr.attr, | 643 | &sensor_dev_attr_in3_input.dev_attr.attr, |
613 | &sensor_dev_attr_in3_min.dev_attr.attr, | 644 | &sensor_dev_attr_in3_min.dev_attr.attr, |
614 | &sensor_dev_attr_in3_max.dev_attr.attr, | 645 | &sensor_dev_attr_in3_max.dev_attr.attr, |
646 | &sensor_dev_attr_in3_alarm.dev_attr.attr, | ||
615 | NULL | 647 | NULL |
616 | }, { | 648 | }, { |
617 | &sensor_dev_attr_in4_input.dev_attr.attr, | 649 | &sensor_dev_attr_in4_input.dev_attr.attr, |
618 | &sensor_dev_attr_in4_min.dev_attr.attr, | 650 | &sensor_dev_attr_in4_min.dev_attr.attr, |
619 | &sensor_dev_attr_in4_max.dev_attr.attr, | 651 | &sensor_dev_attr_in4_max.dev_attr.attr, |
652 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
620 | NULL | 653 | NULL |
621 | }, { | 654 | }, { |
622 | &dev_attr_in5_input.attr, | 655 | &dev_attr_in5_input.attr, |
623 | &dev_attr_in5_min.attr, | 656 | &dev_attr_in5_min.attr, |
624 | &dev_attr_in5_max.attr, | 657 | &dev_attr_in5_max.attr, |
658 | &sensor_dev_attr_in5_alarm.dev_attr.attr, | ||
625 | NULL | 659 | NULL |
626 | } | 660 | } |
627 | }; | 661 | }; |
@@ -642,6 +676,8 @@ static struct attribute *vt8231_attributes[] = { | |||
642 | &sensor_dev_attr_fan2_min.dev_attr.attr, | 676 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
643 | &sensor_dev_attr_fan1_div.dev_attr.attr, | 677 | &sensor_dev_attr_fan1_div.dev_attr.attr, |
644 | &sensor_dev_attr_fan2_div.dev_attr.attr, | 678 | &sensor_dev_attr_fan2_div.dev_attr.attr, |
679 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
680 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
645 | &dev_attr_alarms.attr, | 681 | &dev_attr_alarms.attr, |
646 | &dev_attr_name.attr, | 682 | &dev_attr_name.attr, |
647 | NULL | 683 | NULL |
@@ -963,7 +999,7 @@ static void __exit sm_vt8231_exit(void) | |||
963 | } | 999 | } |
964 | } | 1000 | } |
965 | 1001 | ||
966 | MODULE_AUTHOR("Roger Lucas <roger@planbit.co.uk>"); | 1002 | MODULE_AUTHOR("Roger Lucas <vt8231@hiddenengine.co.uk>"); |
967 | MODULE_DESCRIPTION("VT8231 sensors"); | 1003 | MODULE_DESCRIPTION("VT8231 sensors"); |
968 | MODULE_LICENSE("GPL"); | 1004 | MODULE_LICENSE("GPL"); |
969 | 1005 | ||
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 7421f6ea53e1..5c85670e2d16 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -53,8 +53,8 @@ | |||
53 | static struct platform_device *pdev; | 53 | static struct platform_device *pdev; |
54 | 54 | ||
55 | /* Addresses to scan */ | 55 | /* Addresses to scan */ |
56 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, | 56 | static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, |
57 | 0x2e, 0x2f, I2C_CLIENT_END }; | 57 | 0x2e, 0x2f, I2C_CLIENT_END }; |
58 | static unsigned short isa_address = 0x290; | 58 | static unsigned short isa_address = 0x290; |
59 | 59 | ||
60 | /* Insmod parameters */ | 60 | /* Insmod parameters */ |
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c index 85bd21ee3298..85077c4c8039 100644 --- a/drivers/hwmon/w83791d.c +++ b/drivers/hwmon/w83791d.c | |||
@@ -47,7 +47,8 @@ | |||
47 | #define NUMBER_OF_TEMPIN 3 | 47 | #define NUMBER_OF_TEMPIN 3 |
48 | 48 | ||
49 | /* Addresses to scan */ | 49 | /* Addresses to scan */ |
50 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; | 50 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, |
51 | I2C_CLIENT_END }; | ||
51 | 52 | ||
52 | /* Insmod parameters */ | 53 | /* Insmod parameters */ |
53 | I2C_CLIENT_INSMOD_1(w83791d); | 54 | I2C_CLIENT_INSMOD_1(w83791d); |
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 007449d3e16e..299629d47ed6 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -46,7 +46,8 @@ | |||
46 | #include <linux/sysfs.h> | 46 | #include <linux/sysfs.h> |
47 | 47 | ||
48 | /* Addresses to scan */ | 48 | /* Addresses to scan */ |
49 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; | 49 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, |
50 | I2C_CLIENT_END }; | ||
50 | 51 | ||
51 | /* Insmod parameters */ | 52 | /* Insmod parameters */ |
52 | I2C_CLIENT_INSMOD_1(w83792d); | 53 | I2C_CLIENT_INSMOD_1(w83792d); |
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c index 3ba1d6b33473..ee35af93b574 100644 --- a/drivers/hwmon/w83793.c +++ b/drivers/hwmon/w83793.c | |||
@@ -37,7 +37,8 @@ | |||
37 | #include <linux/mutex.h> | 37 | #include <linux/mutex.h> |
38 | 38 | ||
39 | /* Addresses to scan */ | 39 | /* Addresses to scan */ |
40 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; | 40 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, |
41 | I2C_CLIENT_END }; | ||
41 | 42 | ||
42 | /* Insmod parameters */ | 43 | /* Insmod parameters */ |
43 | I2C_CLIENT_INSMOD_1(w83793); | 44 | I2C_CLIENT_INSMOD_1(w83793); |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 1d6259d29e74..77f2d482888b 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -49,7 +49,7 @@ | |||
49 | * Address is fully defined internally and cannot be changed. | 49 | * Address is fully defined internally and cannot be changed. |
50 | */ | 50 | */ |
51 | 51 | ||
52 | static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END }; | 52 | static const unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END }; |
53 | 53 | ||
54 | /* | 54 | /* |
55 | * Insmod parameters | 55 | * Insmod parameters |
diff --git a/drivers/hwmon/w83l786ng.c b/drivers/hwmon/w83l786ng.c index 1dbee4fa23ad..41e22ddb568a 100644 --- a/drivers/hwmon/w83l786ng.c +++ b/drivers/hwmon/w83l786ng.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
36 | 36 | ||
37 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
38 | static unsigned short normal_i2c[] = { 0x2e, 0x2f, I2C_CLIENT_END }; | 38 | static const unsigned short normal_i2c[] = { 0x2e, 0x2f, I2C_CLIENT_END }; |
39 | 39 | ||
40 | /* Insmod parameters */ | 40 | /* Insmod parameters */ |
41 | I2C_CLIENT_INSMOD_1(w83l786ng); | 41 | I2C_CLIENT_INSMOD_1(w83l786ng); |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 2598d29fd7a4..2b557bfd7f70 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -138,11 +138,13 @@ static const struct bits icr_bits[] = { | |||
138 | PXA_BIT(ICR_UR, "UR", "ur"), | 138 | PXA_BIT(ICR_UR, "UR", "ur"), |
139 | }; | 139 | }; |
140 | 140 | ||
141 | #ifdef CONFIG_I2C_PXA_SLAVE | ||
141 | static void decode_ICR(unsigned int val) | 142 | static void decode_ICR(unsigned int val) |
142 | { | 143 | { |
143 | decode_bits(KERN_DEBUG "ICR", icr_bits, ARRAY_SIZE(icr_bits), val); | 144 | decode_bits(KERN_DEBUG "ICR", icr_bits, ARRAY_SIZE(icr_bits), val); |
144 | printk("\n"); | 145 | printk("\n"); |
145 | } | 146 | } |
147 | #endif | ||
146 | 148 | ||
147 | static unsigned int i2c_debug = DEBUG; | 149 | static unsigned int i2c_debug = DEBUG; |
148 | 150 | ||
@@ -1122,7 +1124,7 @@ static int __init i2c_adap_pxa_init(void) | |||
1122 | 1124 | ||
1123 | static void i2c_adap_pxa_exit(void) | 1125 | static void i2c_adap_pxa_exit(void) |
1124 | { | 1126 | { |
1125 | return platform_driver_unregister(&i2c_pxa_driver); | 1127 | platform_driver_unregister(&i2c_pxa_driver); |
1126 | } | 1128 | } |
1127 | 1129 | ||
1128 | MODULE_LICENSE("GPL"); | 1130 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 354c91d06a6d..310e497b5838 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1207,9 +1207,13 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1207 | end_request: | 1207 | end_request: |
1208 | if (blk_pc_request(rq)) { | 1208 | if (blk_pc_request(rq)) { |
1209 | unsigned long flags; | 1209 | unsigned long flags; |
1210 | unsigned int dlen = rq->data_len; | ||
1211 | |||
1212 | if (dma) | ||
1213 | rq->data_len = 0; | ||
1210 | 1214 | ||
1211 | spin_lock_irqsave(&ide_lock, flags); | 1215 | spin_lock_irqsave(&ide_lock, flags); |
1212 | if (__blk_end_request(rq, 0, rq->data_len)) | 1216 | if (__blk_end_request(rq, 0, dlen)) |
1213 | BUG(); | 1217 | BUG(); |
1214 | HWGROUP(drive)->rq = NULL; | 1218 | HWGROUP(drive)->rq = NULL; |
1215 | spin_unlock_irqrestore(&ide_lock, flags); | 1219 | spin_unlock_irqrestore(&ide_lock, flags); |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index aed8b31ca561..8f5bed471050 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -397,6 +397,7 @@ static inline int idedisk_supports_lba48(const struct hd_driveid *id) | |||
397 | static const struct drive_list_entry hpa_list[] = { | 397 | static const struct drive_list_entry hpa_list[] = { |
398 | { "ST340823A", NULL }, | 398 | { "ST340823A", NULL }, |
399 | { "ST320413A", NULL }, | 399 | { "ST320413A", NULL }, |
400 | { "ST310211A", NULL }, | ||
400 | { NULL, NULL } | 401 | { NULL, NULL } |
401 | }; | 402 | }; |
402 | 403 | ||
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 709b9e4d2871..9ebec08eefd9 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
@@ -17,9 +17,6 @@ static int __init ide_generic_init(void) | |||
17 | u8 idx[MAX_HWIFS]; | 17 | u8 idx[MAX_HWIFS]; |
18 | int i; | 18 | int i; |
19 | 19 | ||
20 | if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) | ||
21 | ide_get_lock(NULL, NULL); /* for atari only */ | ||
22 | |||
23 | for (i = 0; i < MAX_HWIFS; i++) { | 20 | for (i = 0; i < MAX_HWIFS; i++) { |
24 | ide_hwif_t *hwif = &ide_hwifs[i]; | 21 | ide_hwif_t *hwif = &ide_hwifs[i]; |
25 | 22 | ||
@@ -31,9 +28,6 @@ static int __init ide_generic_init(void) | |||
31 | 28 | ||
32 | ide_device_add_all(idx, NULL); | 29 | ide_device_add_all(idx, NULL); |
33 | 30 | ||
34 | if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) | ||
35 | ide_release_lock(); /* for atari only */ | ||
36 | |||
37 | return 0; | 31 | return 0; |
38 | } | 32 | } |
39 | 33 | ||
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 4a8952a6c3da..477833f0daf5 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -1229,7 +1229,7 @@ static int __init ide_setup(char *s) | |||
1229 | if (!strcmp(s, "ide=reverse")) { | 1229 | if (!strcmp(s, "ide=reverse")) { |
1230 | ide_scan_direction = 1; | 1230 | ide_scan_direction = 1; |
1231 | printk(" : Enabled support for IDE inverse scan order.\n"); | 1231 | printk(" : Enabled support for IDE inverse scan order.\n"); |
1232 | return 1; | 1232 | goto obsolete_option; |
1233 | } | 1233 | } |
1234 | #endif | 1234 | #endif |
1235 | 1235 | ||
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index f044048903b3..8949ce71bddc 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
@@ -54,7 +54,7 @@ static void __init falconide_setup_ports(hw_regs_t *hw) | |||
54 | for (i = 1; i < 8; i++) | 54 | for (i = 1; i < 8; i++) |
55 | hw->io_ports[i] = ATA_HD_BASE + 1 + i * 4; | 55 | hw->io_ports[i] = ATA_HD_BASE + 1 + i * 4; |
56 | 56 | ||
57 | hw->io_ports[IDE_CONTROL_OFFSET] = ATA_HD_CONTROL; | 57 | hw->io_ports[IDE_CONTROL_OFFSET] = ATA_HD_BASE + ATA_HD_CONTROL; |
58 | 58 | ||
59 | hw->irq = IRQ_MFP_IDE; | 59 | hw->irq = IRQ_MFP_IDE; |
60 | hw->ack_intr = NULL; | 60 | hw->ack_intr = NULL; |
@@ -84,7 +84,9 @@ static int __init falconide_init(void) | |||
84 | ide_init_port_data(hwif, index); | 84 | ide_init_port_data(hwif, index); |
85 | ide_init_port_hw(hwif, &hw); | 85 | ide_init_port_hw(hwif, &hw); |
86 | 86 | ||
87 | ide_get_lock(NULL, NULL); | ||
87 | ide_device_add(idx, NULL); | 88 | ide_device_add(idx, NULL); |
89 | ide_release_lock(); | ||
88 | } | 90 | } |
89 | 91 | ||
90 | return 0; | 92 | return 0; |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 02d12c74764a..78ca68e60f97 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -21,18 +21,21 @@ | |||
21 | * "Prefetch" mode bit OFF for ide disks and | 21 | * "Prefetch" mode bit OFF for ide disks and |
22 | * ON for anything else. | 22 | * ON for anything else. |
23 | * | 23 | * |
24 | * Version 0.08 Need to force prefetch for CDs and other non-disk | ||
25 | * devices. (not sure which devices exactly need | ||
26 | * prefetch) | ||
24 | * | 27 | * |
25 | * HT-6560B EIDE-controller support | 28 | * HT-6560B EIDE-controller support |
26 | * To activate controller support use kernel parameter "ide0=ht6560b". | 29 | * To activate controller support use kernel parameter "ide0=ht6560b". |
27 | * Use hdparm utility to enable PIO mode support. | 30 | * Use hdparm utility to enable PIO mode support. |
28 | * | 31 | * |
29 | * Author: Mikko Ala-Fossi <maf@iki.fi> | 32 | * Author: Mikko Ala-Fossi <maf@iki.fi> |
30 | * Jan Evert van Grootheest <janevert@iae.nl> | 33 | * Jan Evert van Grootheest <janevert@caiway.nl> |
31 | * | 34 | * |
32 | * Try: http://www.maf.iki.fi/~maf/ht6560b/ | 35 | * Try: http://www.maf.iki.fi/~maf/ht6560b/ |
33 | */ | 36 | */ |
34 | 37 | ||
35 | #define HT6560B_VERSION "v0.07" | 38 | #define HT6560B_VERSION "v0.08" |
36 | 39 | ||
37 | #include <linux/module.h> | 40 | #include <linux/module.h> |
38 | #include <linux/types.h> | 41 | #include <linux/types.h> |
@@ -130,15 +133,20 @@ static void ht6560b_selectproc (ide_drive_t *drive) | |||
130 | u8 select, timing; | 133 | u8 select, timing; |
131 | 134 | ||
132 | local_irq_save(flags); | 135 | local_irq_save(flags); |
133 | 136 | ||
134 | select = HT_CONFIG(drive); | 137 | select = HT_CONFIG(drive); |
135 | timing = HT_TIMING(drive); | 138 | timing = HT_TIMING(drive); |
136 | 139 | ||
140 | /* | ||
141 | * Need to enforce prefetch sometimes because otherwise | ||
142 | * it'll hang (hard). | ||
143 | */ | ||
144 | if (drive->media != ide_disk || !drive->present) | ||
145 | select |= HT_PREFETCH_MODE; | ||
146 | |||
137 | if (select != current_select || timing != current_timing) { | 147 | if (select != current_select || timing != current_timing) { |
138 | current_select = select; | 148 | current_select = select; |
139 | current_timing = timing; | 149 | current_timing = timing; |
140 | if (drive->media != ide_disk || !drive->present) | ||
141 | select |= HT_PREFETCH_MODE; | ||
142 | (void)inb(HT_CONFIG_PORT); | 150 | (void)inb(HT_CONFIG_PORT); |
143 | (void)inb(HT_CONFIG_PORT); | 151 | (void)inb(HT_CONFIG_PORT); |
144 | (void)inb(HT_CONFIG_PORT); | 152 | (void)inb(HT_CONFIG_PORT); |
@@ -188,11 +196,12 @@ static int __init try_to_init_ht6560b(void) | |||
188 | outb(HT_TIMING_DEFAULT, 0x1f6); /* IDE_SELECT_REG */ | 196 | outb(HT_TIMING_DEFAULT, 0x1f6); /* IDE_SELECT_REG */ |
189 | (void) inb(0x1f7); /* IDE_STATUS_REG */ | 197 | (void) inb(0x1f7); /* IDE_STATUS_REG */ |
190 | 198 | ||
191 | printk("\nht6560b " HT6560B_VERSION | 199 | printk("ht6560b " HT6560B_VERSION |
192 | ": chipset detected and initialized" | 200 | ": chipset detected and initialized" |
193 | #ifdef DEBUG | 201 | #ifdef DEBUG |
194 | " with debug enabled" | 202 | " with debug enabled" |
195 | #endif | 203 | #endif |
204 | "\n" | ||
196 | ); | 205 | ); |
197 | return 1; | 206 | return 1; |
198 | } | 207 | } |
@@ -323,7 +332,7 @@ static const struct ide_port_info ht6560b_port_info __initdata = { | |||
323 | IDE_HFLAG_NO_DMA | | 332 | IDE_HFLAG_NO_DMA | |
324 | IDE_HFLAG_NO_AUTOTUNE | | 333 | IDE_HFLAG_NO_AUTOTUNE | |
325 | IDE_HFLAG_ABUSE_PREFETCH, | 334 | IDE_HFLAG_ABUSE_PREFETCH, |
326 | .pio_mask = ATA_PIO5, | 335 | .pio_mask = ATA_PIO4, |
327 | }; | 336 | }; |
328 | 337 | ||
329 | static int __init ht6560b_init(void) | 338 | static int __init ht6560b_init(void) |
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index a61e60737dc7..9a79098d9eb4 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c | |||
@@ -74,7 +74,7 @@ static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base, | |||
74 | for (i = 0; i < 8; i++) | 74 | for (i = 0; i < 8; i++) |
75 | hw->io_ports[i] = base + i * 4; | 75 | hw->io_ports[i] = base + i * 4; |
76 | 76 | ||
77 | hw->io_ports[IDE_CONTROL_OFFSET] = IDE_CONTROL; | 77 | hw->io_ports[IDE_CONTROL_OFFSET] = base + IDE_CONTROL; |
78 | 78 | ||
79 | hw->irq = irq; | 79 | hw->irq = irq; |
80 | hw->ack_intr = ack_intr; | 80 | hw->ack_intr = ack_intr; |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index f3f79f805813..9004e7521889 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -479,6 +479,7 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i | |||
479 | static const struct pci_device_id via_pci_tbl[] = { | 479 | static const struct pci_device_id via_pci_tbl[] = { |
480 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), 0 }, | 480 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), 0 }, |
481 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), 0 }, | 481 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), 0 }, |
482 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_CX700_IDE), 0 }, | ||
482 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), 1 }, | 483 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), 1 }, |
483 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), 1 }, | 484 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), 1 }, |
484 | { 0, }, | 485 | { 0, }, |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 12ac3bfb4f9a..78c9eeb85634 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -1254,7 +1254,7 @@ pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg) | |||
1254 | int rc = 0; | 1254 | int rc = 0; |
1255 | 1255 | ||
1256 | if (mesg.event != mdev->ofdev.dev.power.power_state.event | 1256 | if (mesg.event != mdev->ofdev.dev.power.power_state.event |
1257 | && mesg.event == PM_EVENT_SUSPEND) { | 1257 | && (mesg.event & PM_EVENT_SLEEP)) { |
1258 | rc = pmac_ide_do_suspend(hwif); | 1258 | rc = pmac_ide_do_suspend(hwif); |
1259 | if (rc == 0) | 1259 | if (rc == 0) |
1260 | mdev->ofdev.dev.power.power_state = mesg; | 1260 | mdev->ofdev.dev.power.power_state = mesg; |
@@ -1364,7 +1364,7 @@ pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
1364 | int rc = 0; | 1364 | int rc = 0; |
1365 | 1365 | ||
1366 | if (mesg.event != pdev->dev.power.power_state.event | 1366 | if (mesg.event != pdev->dev.power.power_state.event |
1367 | && mesg.event == PM_EVENT_SUSPEND) { | 1367 | && (mesg.event & PM_EVENT_SLEEP)) { |
1368 | rc = pmac_ide_do_suspend(hwif); | 1368 | rc = pmac_ide_do_suspend(hwif); |
1369 | if (rc == 0) | 1369 | if (rc == 0) |
1370 | pdev->dev.power.power_state = mesg; | 1370 | pdev->dev.power.power_state = mesg; |
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 638b727d42e0..b10ade92efed 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c | |||
@@ -3587,8 +3587,6 @@ static void cm_release_port_obj(struct kobject *obj) | |||
3587 | { | 3587 | { |
3588 | struct cm_port *cm_port; | 3588 | struct cm_port *cm_port; |
3589 | 3589 | ||
3590 | printk(KERN_ERR "free cm port\n"); | ||
3591 | |||
3592 | cm_port = container_of(obj, struct cm_port, port_obj); | 3590 | cm_port = container_of(obj, struct cm_port, port_obj); |
3593 | kfree(cm_port); | 3591 | kfree(cm_port); |
3594 | } | 3592 | } |
@@ -3601,8 +3599,6 @@ static void cm_release_dev_obj(struct kobject *obj) | |||
3601 | { | 3599 | { |
3602 | struct cm_device *cm_dev; | 3600 | struct cm_device *cm_dev; |
3603 | 3601 | ||
3604 | printk(KERN_ERR "free cm dev\n"); | ||
3605 | |||
3606 | cm_dev = container_of(obj, struct cm_device, dev_obj); | 3602 | cm_dev = container_of(obj, struct cm_device, dev_obj); |
3607 | kfree(cm_dev); | 3603 | kfree(cm_dev); |
3608 | } | 3604 | } |
@@ -3616,18 +3612,12 @@ struct class cm_class = { | |||
3616 | }; | 3612 | }; |
3617 | EXPORT_SYMBOL(cm_class); | 3613 | EXPORT_SYMBOL(cm_class); |
3618 | 3614 | ||
3619 | static void cm_remove_fs_obj(struct kobject *obj) | ||
3620 | { | ||
3621 | kobject_put(obj->parent); | ||
3622 | kobject_put(obj); | ||
3623 | } | ||
3624 | |||
3625 | static int cm_create_port_fs(struct cm_port *port) | 3615 | static int cm_create_port_fs(struct cm_port *port) |
3626 | { | 3616 | { |
3627 | int i, ret; | 3617 | int i, ret; |
3628 | 3618 | ||
3629 | ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type, | 3619 | ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type, |
3630 | kobject_get(&port->cm_dev->dev_obj), | 3620 | &port->cm_dev->dev_obj, |
3631 | "%d", port->port_num); | 3621 | "%d", port->port_num); |
3632 | if (ret) { | 3622 | if (ret) { |
3633 | kfree(port); | 3623 | kfree(port); |
@@ -3637,7 +3627,7 @@ static int cm_create_port_fs(struct cm_port *port) | |||
3637 | for (i = 0; i < CM_COUNTER_GROUPS; i++) { | 3627 | for (i = 0; i < CM_COUNTER_GROUPS; i++) { |
3638 | ret = kobject_init_and_add(&port->counter_group[i].obj, | 3628 | ret = kobject_init_and_add(&port->counter_group[i].obj, |
3639 | &cm_counter_obj_type, | 3629 | &cm_counter_obj_type, |
3640 | kobject_get(&port->port_obj), | 3630 | &port->port_obj, |
3641 | "%s", counter_group_names[i]); | 3631 | "%s", counter_group_names[i]); |
3642 | if (ret) | 3632 | if (ret) |
3643 | goto error; | 3633 | goto error; |
@@ -3647,8 +3637,8 @@ static int cm_create_port_fs(struct cm_port *port) | |||
3647 | 3637 | ||
3648 | error: | 3638 | error: |
3649 | while (i--) | 3639 | while (i--) |
3650 | cm_remove_fs_obj(&port->counter_group[i].obj); | 3640 | kobject_put(&port->counter_group[i].obj); |
3651 | cm_remove_fs_obj(&port->port_obj); | 3641 | kobject_put(&port->port_obj); |
3652 | return ret; | 3642 | return ret; |
3653 | 3643 | ||
3654 | } | 3644 | } |
@@ -3658,9 +3648,9 @@ static void cm_remove_port_fs(struct cm_port *port) | |||
3658 | int i; | 3648 | int i; |
3659 | 3649 | ||
3660 | for (i = 0; i < CM_COUNTER_GROUPS; i++) | 3650 | for (i = 0; i < CM_COUNTER_GROUPS; i++) |
3661 | cm_remove_fs_obj(&port->counter_group[i].obj); | 3651 | kobject_put(&port->counter_group[i].obj); |
3662 | 3652 | ||
3663 | cm_remove_fs_obj(&port->port_obj); | 3653 | kobject_put(&port->port_obj); |
3664 | } | 3654 | } |
3665 | 3655 | ||
3666 | static void cm_add_one(struct ib_device *device) | 3656 | static void cm_add_one(struct ib_device *device) |
@@ -3744,7 +3734,7 @@ error1: | |||
3744 | ib_unregister_mad_agent(port->mad_agent); | 3734 | ib_unregister_mad_agent(port->mad_agent); |
3745 | cm_remove_port_fs(port); | 3735 | cm_remove_port_fs(port); |
3746 | } | 3736 | } |
3747 | cm_remove_fs_obj(&cm_dev->dev_obj); | 3737 | kobject_put(&cm_dev->dev_obj); |
3748 | } | 3738 | } |
3749 | 3739 | ||
3750 | static void cm_remove_one(struct ib_device *device) | 3740 | static void cm_remove_one(struct ib_device *device) |
@@ -3771,7 +3761,7 @@ static void cm_remove_one(struct ib_device *device) | |||
3771 | ib_unregister_mad_agent(port->mad_agent); | 3761 | ib_unregister_mad_agent(port->mad_agent); |
3772 | cm_remove_port_fs(port); | 3762 | cm_remove_port_fs(port); |
3773 | } | 3763 | } |
3774 | cm_remove_fs_obj(&cm_dev->dev_obj); | 3764 | kobject_put(&cm_dev->dev_obj); |
3775 | } | 3765 | } |
3776 | 3766 | ||
3777 | static int __init ib_cm_init(void) | 3767 | static int __init ib_cm_init(void) |
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 1eff1b2c0e08..34507daaf9b6 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -1107,7 +1107,6 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) | |||
1107 | event.param.ud.private_data_len = | 1107 | event.param.ud.private_data_len = |
1108 | IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset; | 1108 | IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset; |
1109 | } else { | 1109 | } else { |
1110 | ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0); | ||
1111 | conn_id = cma_new_conn_id(&listen_id->id, ib_event); | 1110 | conn_id = cma_new_conn_id(&listen_id->id, ib_event); |
1112 | cma_set_req_event_data(&event, &ib_event->param.req_rcvd, | 1111 | cma_set_req_event_data(&event, &ib_event->param.req_rcvd, |
1113 | ib_event->private_data, offset); | 1112 | ib_event->private_data, offset); |
@@ -1130,6 +1129,15 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) | |||
1130 | 1129 | ||
1131 | ret = conn_id->id.event_handler(&conn_id->id, &event); | 1130 | ret = conn_id->id.event_handler(&conn_id->id, &event); |
1132 | if (!ret) { | 1131 | if (!ret) { |
1132 | /* | ||
1133 | * Acquire mutex to prevent user executing rdma_destroy_id() | ||
1134 | * while we're accessing the cm_id. | ||
1135 | */ | ||
1136 | mutex_lock(&lock); | ||
1137 | if (cma_comp(conn_id, CMA_CONNECT) && | ||
1138 | !cma_is_ud_ps(conn_id->id.ps)) | ||
1139 | ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0); | ||
1140 | mutex_unlock(&lock); | ||
1133 | cma_enable_remove(conn_id); | 1141 | cma_enable_remove(conn_id); |
1134 | goto out; | 1142 | goto out; |
1135 | } | 1143 | } |
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index c864ef70fdf9..5a4b2e65534b 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -686,8 +686,10 @@ int ib_device_register_sysfs(struct ib_device *device) | |||
686 | 686 | ||
687 | device->ports_parent = kobject_create_and_add("ports", | 687 | device->ports_parent = kobject_create_and_add("ports", |
688 | kobject_get(&class_dev->kobj)); | 688 | kobject_get(&class_dev->kobj)); |
689 | if (!device->ports_parent) | 689 | if (!device->ports_parent) { |
690 | ret = -ENOMEM; | ||
690 | goto err_put; | 691 | goto err_put; |
692 | } | ||
691 | 693 | ||
692 | if (device->node_type == RDMA_NODE_IB_SWITCH) { | 694 | if (device->node_type == RDMA_NODE_IB_SWITCH) { |
693 | ret = add_port(device, 0); | 695 | ret = add_port(device, 0); |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c index e9a08fa3dffe..320f2b6ddee6 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_cm.c +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/skbuff.h> | 35 | #include <linux/skbuff.h> |
36 | #include <linux/timer.h> | 36 | #include <linux/timer.h> |
37 | #include <linux/notifier.h> | 37 | #include <linux/notifier.h> |
38 | #include <linux/inetdevice.h> | ||
38 | 39 | ||
39 | #include <net/neighbour.h> | 40 | #include <net/neighbour.h> |
40 | #include <net/netevent.h> | 41 | #include <net/netevent.h> |
@@ -1784,6 +1785,17 @@ err: | |||
1784 | return err; | 1785 | return err; |
1785 | } | 1786 | } |
1786 | 1787 | ||
1788 | static int is_loopback_dst(struct iw_cm_id *cm_id) | ||
1789 | { | ||
1790 | struct net_device *dev; | ||
1791 | |||
1792 | dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr); | ||
1793 | if (!dev) | ||
1794 | return 0; | ||
1795 | dev_put(dev); | ||
1796 | return 1; | ||
1797 | } | ||
1798 | |||
1787 | int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | 1799 | int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) |
1788 | { | 1800 | { |
1789 | int err = 0; | 1801 | int err = 0; |
@@ -1791,6 +1803,11 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
1791 | struct iwch_ep *ep; | 1803 | struct iwch_ep *ep; |
1792 | struct rtable *rt; | 1804 | struct rtable *rt; |
1793 | 1805 | ||
1806 | if (is_loopback_dst(cm_id)) { | ||
1807 | err = -ENOSYS; | ||
1808 | goto out; | ||
1809 | } | ||
1810 | |||
1794 | ep = alloc_ep(sizeof(*ep), GFP_KERNEL); | 1811 | ep = alloc_ep(sizeof(*ep), GFP_KERNEL); |
1795 | if (!ep) { | 1812 | if (!ep) { |
1796 | printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__); | 1813 | printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__); |
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c index 7dc91a3e712d..fe2c2e94a5f8 100644 --- a/drivers/infiniband/hw/mlx4/mr.c +++ b/drivers/infiniband/hw/mlx4/mr.c | |||
@@ -199,7 +199,7 @@ struct ib_fmr *mlx4_ib_fmr_alloc(struct ib_pd *pd, int acc, | |||
199 | if (err) | 199 | if (err) |
200 | goto err_free; | 200 | goto err_free; |
201 | 201 | ||
202 | err = mlx4_mr_enable(to_mdev(pd->device)->dev, &fmr->mfmr.mr); | 202 | err = mlx4_fmr_enable(to_mdev(pd->device)->dev, &fmr->mfmr); |
203 | if (err) | 203 | if (err) |
204 | goto err_mr; | 204 | goto err_mr; |
205 | 205 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c index 6bd9f1393349..1e1e336d3ef9 100644 --- a/drivers/infiniband/hw/mthca/mthca_cq.c +++ b/drivers/infiniband/hw/mthca/mthca_cq.c | |||
@@ -473,7 +473,7 @@ static void handle_error_cqe(struct mthca_dev *dev, struct mthca_cq *cq, | |||
473 | if (!(new_wqe & cpu_to_be32(0x3f)) || (!cqe->db_cnt && dbd)) | 473 | if (!(new_wqe & cpu_to_be32(0x3f)) || (!cqe->db_cnt && dbd)) |
474 | return; | 474 | return; |
475 | 475 | ||
476 | cqe->db_cnt = cpu_to_be16(be16_to_cpu(cqe->db_cnt) - dbd); | 476 | be16_add_cpu(&cqe->db_cnt, -dbd); |
477 | cqe->wqe = new_wqe; | 477 | cqe->wqe = new_wqe; |
478 | cqe->syndrome = SYNDROME_WR_FLUSH_ERR; | 478 | cqe->syndrome = SYNDROME_WR_FLUSH_ERR; |
479 | 479 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 1f4d27d7c16d..252db0822f6c 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
@@ -542,6 +542,7 @@ struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev) | |||
542 | for (i = 0; i < npages; ++i) { | 542 | for (i = 0; i < npages; ++i) { |
543 | db_tab->page[i].refcount = 0; | 543 | db_tab->page[i].refcount = 0; |
544 | db_tab->page[i].uvirt = 0; | 544 | db_tab->page[i].uvirt = 0; |
545 | sg_init_table(&db_tab->page[i].mem, 1); | ||
545 | } | 546 | } |
546 | 547 | ||
547 | return db_tab; | 548 | return db_tab; |
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c index 3b6985557cb2..3538da16e3fe 100644 --- a/drivers/infiniband/hw/mthca/mthca_mr.c +++ b/drivers/infiniband/hw/mthca/mthca_mr.c | |||
@@ -686,7 +686,7 @@ err_out_table: | |||
686 | mthca_table_put(dev, dev->mr_table.mpt_table, key); | 686 | mthca_table_put(dev, dev->mr_table.mpt_table, key); |
687 | 687 | ||
688 | err_out_mpt_free: | 688 | err_out_mpt_free: |
689 | mthca_free(&dev->mr_table.mpt_alloc, mr->ibmr.lkey); | 689 | mthca_free(&dev->mr_table.mpt_alloc, key); |
690 | return err; | 690 | return err; |
691 | } | 691 | } |
692 | 692 | ||
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c index b6cc265aa9a4..eee77da61935 100644 --- a/drivers/infiniband/hw/nes/nes_nic.c +++ b/drivers/infiniband/hw/nes/nes_nic.c | |||
@@ -148,14 +148,15 @@ static int nes_netdev_open(struct net_device *netdev) | |||
148 | struct nes_device *nesdev = nesvnic->nesdev; | 148 | struct nes_device *nesdev = nesvnic->nesdev; |
149 | int ret; | 149 | int ret; |
150 | int i; | 150 | int i; |
151 | struct nes_vnic *first_nesvnic; | 151 | struct nes_vnic *first_nesvnic = NULL; |
152 | u32 nic_active_bit; | 152 | u32 nic_active_bit; |
153 | u32 nic_active; | 153 | u32 nic_active; |
154 | struct list_head *list_pos, *list_temp; | ||
154 | 155 | ||
155 | assert(nesdev != NULL); | 156 | assert(nesdev != NULL); |
156 | 157 | ||
157 | first_nesvnic = list_entry(nesdev->nesadapter->nesvnic_list[nesdev->mac_index].next, | 158 | if (nesvnic->netdev_open == 1) |
158 | struct nes_vnic, list); | 159 | return 0; |
159 | 160 | ||
160 | if (netif_msg_ifup(nesvnic)) | 161 | if (netif_msg_ifup(nesvnic)) |
161 | printk(KERN_INFO PFX "%s: enabling interface\n", netdev->name); | 162 | printk(KERN_INFO PFX "%s: enabling interface\n", netdev->name); |
@@ -225,7 +226,18 @@ static int nes_netdev_open(struct net_device *netdev) | |||
225 | nes_write32(nesdev->regs+NES_CQE_ALLOC, NES_CQE_ALLOC_NOTIFY_NEXT | | 226 | nes_write32(nesdev->regs+NES_CQE_ALLOC, NES_CQE_ALLOC_NOTIFY_NEXT | |
226 | nesvnic->nic_cq.cq_number); | 227 | nesvnic->nic_cq.cq_number); |
227 | nes_read32(nesdev->regs+NES_CQE_ALLOC); | 228 | nes_read32(nesdev->regs+NES_CQE_ALLOC); |
228 | 229 | list_for_each_safe(list_pos, list_temp, &nesdev->nesadapter->nesvnic_list[nesdev->mac_index]) { | |
230 | first_nesvnic = container_of(list_pos, struct nes_vnic, list); | ||
231 | if (first_nesvnic->netdev_open == 1) | ||
232 | break; | ||
233 | } | ||
234 | if (first_nesvnic->netdev_open == 0) { | ||
235 | nes_debug(NES_DBG_INIT, "Setting up MAC interrupt mask.\n"); | ||
236 | nes_write_indexed(nesdev, NES_IDX_MAC_INT_MASK + (0x200 * nesdev->mac_index), | ||
237 | ~(NES_MAC_INT_LINK_STAT_CHG | NES_MAC_INT_XGMII_EXT | | ||
238 | NES_MAC_INT_TX_UNDERFLOW | NES_MAC_INT_TX_ERROR)); | ||
239 | first_nesvnic = nesvnic; | ||
240 | } | ||
229 | if (first_nesvnic->linkup) { | 241 | if (first_nesvnic->linkup) { |
230 | /* Enable network packets */ | 242 | /* Enable network packets */ |
231 | nesvnic->linkup = 1; | 243 | nesvnic->linkup = 1; |
@@ -248,6 +260,8 @@ static int nes_netdev_stop(struct net_device *netdev) | |||
248 | struct nes_device *nesdev = nesvnic->nesdev; | 260 | struct nes_device *nesdev = nesvnic->nesdev; |
249 | u32 nic_active_mask; | 261 | u32 nic_active_mask; |
250 | u32 nic_active; | 262 | u32 nic_active; |
263 | struct nes_vnic *first_nesvnic = NULL; | ||
264 | struct list_head *list_pos, *list_temp; | ||
251 | 265 | ||
252 | nes_debug(NES_DBG_SHUTDOWN, "nesvnic=%p, nesdev=%p, netdev=%p %s\n", | 266 | nes_debug(NES_DBG_SHUTDOWN, "nesvnic=%p, nesdev=%p, netdev=%p %s\n", |
253 | nesvnic, nesdev, netdev, netdev->name); | 267 | nesvnic, nesdev, netdev, netdev->name); |
@@ -260,9 +274,20 @@ static int nes_netdev_stop(struct net_device *netdev) | |||
260 | /* Disable network packets */ | 274 | /* Disable network packets */ |
261 | napi_disable(&nesvnic->napi); | 275 | napi_disable(&nesvnic->napi); |
262 | netif_stop_queue(netdev); | 276 | netif_stop_queue(netdev); |
263 | if ((nesdev->netdev[0] == netdev) & (nesvnic->logical_port == nesdev->mac_index)) { | 277 | list_for_each_safe(list_pos, list_temp, &nesdev->nesadapter->nesvnic_list[nesdev->mac_index]) { |
264 | nes_write_indexed(nesdev, | 278 | first_nesvnic = container_of(list_pos, struct nes_vnic, list); |
265 | NES_IDX_MAC_INT_MASK+(0x200*nesdev->mac_index), 0xffffffff); | 279 | if ((first_nesvnic->netdev_open == 1) && (first_nesvnic != nesvnic)) |
280 | break; | ||
281 | } | ||
282 | |||
283 | if (first_nesvnic->netdev_open == 0) | ||
284 | nes_write_indexed(nesdev, NES_IDX_MAC_INT_MASK+(0x200*nesdev->mac_index), 0xffffffff); | ||
285 | else if ((first_nesvnic != nesvnic) && | ||
286 | (PCI_FUNC(first_nesvnic->nesdev->pcidev->devfn) != PCI_FUNC(nesvnic->nesdev->pcidev->devfn))) { | ||
287 | nes_write_indexed(nesdev, NES_IDX_MAC_INT_MASK + (0x200 * nesdev->mac_index), 0xffffffff); | ||
288 | nes_write_indexed(first_nesvnic->nesdev, NES_IDX_MAC_INT_MASK + (0x200 * first_nesvnic->nesdev->mac_index), | ||
289 | ~(NES_MAC_INT_LINK_STAT_CHG | NES_MAC_INT_XGMII_EXT | | ||
290 | NES_MAC_INT_TX_UNDERFLOW | NES_MAC_INT_TX_ERROR)); | ||
266 | } | 291 | } |
267 | 292 | ||
268 | nic_active_mask = ~((u32)(1 << nesvnic->nic_index)); | 293 | nic_active_mask = ~((u32)(1 << nesvnic->nic_index)); |
@@ -859,7 +884,6 @@ void nes_netdev_set_multicast_list(struct net_device *netdev) | |||
859 | for (mc_index=0; mc_index < NES_MULTICAST_PF_MAX; mc_index++) { | 884 | for (mc_index=0; mc_index < NES_MULTICAST_PF_MAX; mc_index++) { |
860 | while (multicast_addr && nesvnic->mcrq_mcast_filter && ((mc_nic_index = nesvnic->mcrq_mcast_filter(nesvnic, multicast_addr->dmi_addr)) == 0)) | 885 | while (multicast_addr && nesvnic->mcrq_mcast_filter && ((mc_nic_index = nesvnic->mcrq_mcast_filter(nesvnic, multicast_addr->dmi_addr)) == 0)) |
861 | multicast_addr = multicast_addr->next; | 886 | multicast_addr = multicast_addr->next; |
862 | |||
863 | if (mc_nic_index < 0) | 887 | if (mc_nic_index < 0) |
864 | mc_nic_index = nesvnic->nic_index; | 888 | mc_nic_index = nesvnic->nic_index; |
865 | if (multicast_addr) { | 889 | if (multicast_addr) { |
@@ -908,7 +932,7 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu) | |||
908 | return -EINVAL; | 932 | return -EINVAL; |
909 | 933 | ||
910 | netdev->mtu = new_mtu; | 934 | netdev->mtu = new_mtu; |
911 | nesvnic->max_frame_size = new_mtu+ETH_HLEN; | 935 | nesvnic->max_frame_size = new_mtu + VLAN_ETH_HLEN; |
912 | 936 | ||
913 | if (netdev->mtu > 1500) { | 937 | if (netdev->mtu > 1500) { |
914 | jumbomode=1; | 938 | jumbomode=1; |
@@ -1470,10 +1494,15 @@ static void nes_netdev_vlan_rx_register(struct net_device *netdev, struct vlan_g | |||
1470 | { | 1494 | { |
1471 | struct nes_vnic *nesvnic = netdev_priv(netdev); | 1495 | struct nes_vnic *nesvnic = netdev_priv(netdev); |
1472 | struct nes_device *nesdev = nesvnic->nesdev; | 1496 | struct nes_device *nesdev = nesvnic->nesdev; |
1497 | struct nes_adapter *nesadapter = nesdev->nesadapter; | ||
1473 | u32 u32temp; | 1498 | u32 u32temp; |
1499 | unsigned long flags; | ||
1474 | 1500 | ||
1501 | spin_lock_irqsave(&nesadapter->phy_lock, flags); | ||
1475 | nesvnic->vlan_grp = grp; | 1502 | nesvnic->vlan_grp = grp; |
1476 | 1503 | ||
1504 | nes_debug(NES_DBG_NETDEV, "%s: %s\n", __func__, netdev->name); | ||
1505 | |||
1477 | /* Enable/Disable VLAN Stripping */ | 1506 | /* Enable/Disable VLAN Stripping */ |
1478 | u32temp = nes_read_indexed(nesdev, NES_IDX_PCIX_DIAG); | 1507 | u32temp = nes_read_indexed(nesdev, NES_IDX_PCIX_DIAG); |
1479 | if (grp) | 1508 | if (grp) |
@@ -1482,6 +1511,7 @@ static void nes_netdev_vlan_rx_register(struct net_device *netdev, struct vlan_g | |||
1482 | u32temp |= 0x02000000; | 1511 | u32temp |= 0x02000000; |
1483 | 1512 | ||
1484 | nes_write_indexed(nesdev, NES_IDX_PCIX_DIAG, u32temp); | 1513 | nes_write_indexed(nesdev, NES_IDX_PCIX_DIAG, u32temp); |
1514 | spin_unlock_irqrestore(&nesadapter->phy_lock, flags); | ||
1485 | } | 1515 | } |
1486 | 1516 | ||
1487 | 1517 | ||
@@ -1540,7 +1570,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev, | |||
1540 | nesvnic->msg_enable = netif_msg_init(debug, default_msg); | 1570 | nesvnic->msg_enable = netif_msg_init(debug, default_msg); |
1541 | nesvnic->netdev_index = nesdev->netdev_count; | 1571 | nesvnic->netdev_index = nesdev->netdev_count; |
1542 | nesvnic->perfect_filter_index = nesdev->nesadapter->netdev_count; | 1572 | nesvnic->perfect_filter_index = nesdev->nesadapter->netdev_count; |
1543 | nesvnic->max_frame_size = netdev->mtu+netdev->hard_header_len; | 1573 | nesvnic->max_frame_size = netdev->mtu + netdev->hard_header_len + VLAN_HLEN; |
1544 | 1574 | ||
1545 | curr_qp_map = nic_qp_mapping_per_function[PCI_FUNC(nesdev->pcidev->devfn)]; | 1575 | curr_qp_map = nic_qp_mapping_per_function[PCI_FUNC(nesdev->pcidev->devfn)]; |
1546 | nesvnic->nic.qp_id = curr_qp_map[nesdev->netdev_count].qpid; | 1576 | nesvnic->nic.qp_id = curr_qp_map[nesdev->netdev_count].qpid; |
@@ -1610,7 +1640,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev, | |||
1610 | list_add_tail(&nesvnic->list, &nesdev->nesadapter->nesvnic_list[nesdev->mac_index]); | 1640 | list_add_tail(&nesvnic->list, &nesdev->nesadapter->nesvnic_list[nesdev->mac_index]); |
1611 | 1641 | ||
1612 | if ((nesdev->netdev_count == 0) && | 1642 | if ((nesdev->netdev_count == 0) && |
1613 | (PCI_FUNC(nesdev->pcidev->devfn) == nesdev->mac_index)) { | 1643 | (PCI_FUNC(nesdev->pcidev->devfn) == nesdev->mac_index)) { |
1614 | nes_debug(NES_DBG_INIT, "Setting up PHY interrupt mask. Using register index 0x%04X\n", | 1644 | nes_debug(NES_DBG_INIT, "Setting up PHY interrupt mask. Using register index 0x%04X\n", |
1615 | NES_IDX_PHY_PCS_CONTROL_STATUS0+(0x200*(nesvnic->logical_port&1))); | 1645 | NES_IDX_PHY_PCS_CONTROL_STATUS0+(0x200*(nesvnic->logical_port&1))); |
1616 | u32temp = nes_read_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 + | 1646 | u32temp = nes_read_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 + |
@@ -1648,18 +1678,14 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev, | |||
1648 | nesvnic->linkup = 1; | 1678 | nesvnic->linkup = 1; |
1649 | } | 1679 | } |
1650 | } | 1680 | } |
1651 | nes_debug(NES_DBG_INIT, "Setting up MAC interrupt mask.\n"); | ||
1652 | /* clear the MAC interrupt status, assumes direct logical to physical mapping */ | 1681 | /* clear the MAC interrupt status, assumes direct logical to physical mapping */ |
1653 | u32temp = nes_read_indexed(nesdev, NES_IDX_MAC_INT_STATUS+(0x200*nesvnic->logical_port)); | 1682 | u32temp = nes_read_indexed(nesdev, NES_IDX_MAC_INT_STATUS + (0x200 * nesdev->mac_index)); |
1654 | nes_debug(NES_DBG_INIT, "Phy interrupt status = 0x%X.\n", u32temp); | 1683 | nes_debug(NES_DBG_INIT, "Phy interrupt status = 0x%X.\n", u32temp); |
1655 | nes_write_indexed(nesdev, NES_IDX_MAC_INT_STATUS+(0x200*nesvnic->logical_port), u32temp); | 1684 | nes_write_indexed(nesdev, NES_IDX_MAC_INT_STATUS + (0x200 * nesdev->mac_index), u32temp); |
1656 | 1685 | ||
1657 | if (nesdev->nesadapter->phy_type[nesvnic->logical_port] != NES_PHY_TYPE_IRIS) | 1686 | if (nesdev->nesadapter->phy_type[nesdev->mac_index] != NES_PHY_TYPE_IRIS) |
1658 | nes_init_phy(nesdev); | 1687 | nes_init_phy(nesdev); |
1659 | 1688 | ||
1660 | nes_write_indexed(nesdev, NES_IDX_MAC_INT_MASK+(0x200*nesvnic->logical_port), | ||
1661 | ~(NES_MAC_INT_LINK_STAT_CHG | NES_MAC_INT_XGMII_EXT | | ||
1662 | NES_MAC_INT_TX_UNDERFLOW | NES_MAC_INT_TX_ERROR)); | ||
1663 | } | 1689 | } |
1664 | 1690 | ||
1665 | return netdev; | 1691 | return netdev; |
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index ffd4b425567f..4dafbe16e82a 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c | |||
@@ -1337,7 +1337,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, | |||
1337 | NES_MAX_USER_WQ_REGIONS, nes_ucontext->first_free_wq); | 1337 | NES_MAX_USER_WQ_REGIONS, nes_ucontext->first_free_wq); |
1338 | /* nes_debug(NES_DBG_QP, "find_first_zero_biton wqs returned %u\n", | 1338 | /* nes_debug(NES_DBG_QP, "find_first_zero_biton wqs returned %u\n", |
1339 | nespd->mmap_db_index); */ | 1339 | nespd->mmap_db_index); */ |
1340 | if (nesqp->mmap_sq_db_index > NES_MAX_USER_WQ_REGIONS) { | 1340 | if (nesqp->mmap_sq_db_index >= NES_MAX_USER_WQ_REGIONS) { |
1341 | nes_debug(NES_DBG_QP, | 1341 | nes_debug(NES_DBG_QP, |
1342 | "db index > max user regions, failing create QP\n"); | 1342 | "db index > max user regions, failing create QP\n"); |
1343 | nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num); | 1343 | nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h index f9b7caa54143..054fab8e27a0 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/drivers/infiniband/ulp/ipoib/ipoib.h | |||
@@ -209,7 +209,6 @@ struct ipoib_cm_tx { | |||
209 | unsigned tx_tail; | 209 | unsigned tx_tail; |
210 | unsigned long flags; | 210 | unsigned long flags; |
211 | u32 mtu; | 211 | u32 mtu; |
212 | struct ib_wc ibwc[IPOIB_NUM_WC]; | ||
213 | }; | 212 | }; |
214 | 213 | ||
215 | struct ipoib_cm_rx_buf { | 214 | struct ipoib_cm_rx_buf { |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 7dd2ec473d24..52b1bebfa744 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
@@ -824,7 +824,6 @@ void ipoib_cm_dev_stop(struct net_device *dev) | |||
824 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 824 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
825 | struct ipoib_cm_rx *p; | 825 | struct ipoib_cm_rx *p; |
826 | unsigned long begin; | 826 | unsigned long begin; |
827 | LIST_HEAD(list); | ||
828 | int ret; | 827 | int ret; |
829 | 828 | ||
830 | if (!IPOIB_CM_SUPPORTED(dev->dev_addr) || !priv->cm.id) | 829 | if (!IPOIB_CM_SUPPORTED(dev->dev_addr) || !priv->cm.id) |
@@ -857,9 +856,12 @@ void ipoib_cm_dev_stop(struct net_device *dev) | |||
857 | /* | 856 | /* |
858 | * assume the HW is wedged and just free up everything. | 857 | * assume the HW is wedged and just free up everything. |
859 | */ | 858 | */ |
860 | list_splice_init(&priv->cm.rx_flush_list, &list); | 859 | list_splice_init(&priv->cm.rx_flush_list, |
861 | list_splice_init(&priv->cm.rx_error_list, &list); | 860 | &priv->cm.rx_reap_list); |
862 | list_splice_init(&priv->cm.rx_drain_list, &list); | 861 | list_splice_init(&priv->cm.rx_error_list, |
862 | &priv->cm.rx_reap_list); | ||
863 | list_splice_init(&priv->cm.rx_drain_list, | ||
864 | &priv->cm.rx_reap_list); | ||
863 | break; | 865 | break; |
864 | } | 866 | } |
865 | spin_unlock_irq(&priv->lock); | 867 | spin_unlock_irq(&priv->lock); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 9d3e778dc56d..08c4396cf418 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
@@ -780,6 +780,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event) | |||
780 | if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) { | 780 | if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) { |
781 | clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); | 781 | clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); |
782 | ipoib_ib_dev_down(dev, 0); | 782 | ipoib_ib_dev_down(dev, 0); |
783 | ipoib_ib_dev_stop(dev, 0); | ||
783 | ipoib_pkey_dev_delay_open(dev); | 784 | ipoib_pkey_dev_delay_open(dev); |
784 | return; | 785 | return; |
785 | } | 786 | } |
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c index 936788272a5f..bd8a1d14b45d 100644 --- a/drivers/macintosh/mediabay.c +++ b/drivers/macintosh/mediabay.c | |||
@@ -416,7 +416,6 @@ static void poll_media_bay(struct media_bay_info* bay) | |||
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | #ifdef CONFIG_MAC_FLOPPY | ||
420 | int check_media_bay(struct device_node *which_bay, int what) | 419 | int check_media_bay(struct device_node *which_bay, int what) |
421 | { | 420 | { |
422 | int i; | 421 | int i; |
@@ -431,7 +430,6 @@ int check_media_bay(struct device_node *which_bay, int what) | |||
431 | return -ENODEV; | 430 | return -ENODEV; |
432 | } | 431 | } |
433 | EXPORT_SYMBOL(check_media_bay); | 432 | EXPORT_SYMBOL(check_media_bay); |
434 | #endif /* CONFIG_MAC_FLOPPY */ | ||
435 | 433 | ||
436 | #ifdef CONFIG_BLK_DEV_IDE_PMAC | 434 | #ifdef CONFIG_BLK_DEV_IDE_PMAC |
437 | int check_media_bay_by_base(unsigned long base, int what) | 435 | int check_media_bay_by_base(unsigned long base, int what) |
@@ -700,7 +698,8 @@ static int media_bay_suspend(struct macio_dev *mdev, pm_message_t state) | |||
700 | { | 698 | { |
701 | struct media_bay_info *bay = macio_get_drvdata(mdev); | 699 | struct media_bay_info *bay = macio_get_drvdata(mdev); |
702 | 700 | ||
703 | if (state.event != mdev->ofdev.dev.power.power_state.event && state.event == PM_EVENT_SUSPEND) { | 701 | if (state.event != mdev->ofdev.dev.power.power_state.event |
702 | && (state.event & PM_EVENT_SLEEP)) { | ||
704 | down(&bay->lock); | 703 | down(&bay->lock); |
705 | bay->sleeping = 1; | 704 | bay->sleeping = 1; |
706 | set_mb_power(bay, 0); | 705 | set_mb_power(bay, 0); |
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index a0585fb6da94..7aeceedcf7d4 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -206,16 +206,10 @@ static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page) | |||
206 | /* copy the pathname of a file to a buffer */ | 206 | /* copy the pathname of a file to a buffer */ |
207 | char *file_path(struct file *file, char *buf, int count) | 207 | char *file_path(struct file *file, char *buf, int count) |
208 | { | 208 | { |
209 | struct dentry *d; | ||
210 | struct vfsmount *v; | ||
211 | |||
212 | if (!buf) | 209 | if (!buf) |
213 | return NULL; | 210 | return NULL; |
214 | 211 | ||
215 | d = file->f_path.dentry; | 212 | buf = d_path(&file->f_path, buf, count); |
216 | v = file->f_path.mnt; | ||
217 | |||
218 | buf = d_path(d, v, buf, count); | ||
219 | 213 | ||
220 | return IS_ERR(buf) ? NULL : buf; | 214 | return IS_ERR(buf) ? NULL : buf; |
221 | } | 215 | } |
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index edc057f5cdcc..51605870f898 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
@@ -124,7 +124,7 @@ enum dm_raid1_error { | |||
124 | struct mirror { | 124 | struct mirror { |
125 | struct mirror_set *ms; | 125 | struct mirror_set *ms; |
126 | atomic_t error_count; | 126 | atomic_t error_count; |
127 | uint32_t error_type; | 127 | unsigned long error_type; |
128 | struct dm_dev *dev; | 128 | struct dm_dev *dev; |
129 | sector_t offset; | 129 | sector_t offset; |
130 | }; | 130 | }; |
@@ -1695,14 +1695,15 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, | |||
1695 | * information for a retry or there was no other | 1695 | * information for a retry or there was no other |
1696 | * mirror in-sync. | 1696 | * mirror in-sync. |
1697 | */ | 1697 | */ |
1698 | DMERR_LIMIT("Mirror read failed from %s.", | 1698 | DMERR_LIMIT("Mirror read failed."); |
1699 | m->dev->name); | ||
1700 | return -EIO; | 1699 | return -EIO; |
1701 | } | 1700 | } |
1701 | |||
1702 | m = read_record->m; | ||
1703 | |||
1702 | DMERR("Mirror read failed from %s. Trying alternative device.", | 1704 | DMERR("Mirror read failed from %s. Trying alternative device.", |
1703 | m->dev->name); | 1705 | m->dev->name); |
1704 | 1706 | ||
1705 | m = read_record->m; | ||
1706 | fail_mirror(m, DM_RAID1_READ_ERROR); | 1707 | fail_mirror(m, DM_RAID1_READ_ERROR); |
1707 | 1708 | ||
1708 | /* | 1709 | /* |
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index f16062982383..e75b1437b58b 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -361,7 +361,7 @@ static int lookup_device(const char *path, dev_t *dev) | |||
361 | if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd))) | 361 | if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd))) |
362 | return r; | 362 | return r; |
363 | 363 | ||
364 | inode = nd.dentry->d_inode; | 364 | inode = nd.path.dentry->d_inode; |
365 | if (!inode) { | 365 | if (!inode) { |
366 | r = -ENOENT; | 366 | r = -ENOENT; |
367 | goto out; | 367 | goto out; |
@@ -375,7 +375,7 @@ static int lookup_device(const char *path, dev_t *dev) | |||
375 | *dev = inode->i_rdev; | 375 | *dev = inode->i_rdev; |
376 | 376 | ||
377 | out: | 377 | out: |
378 | path_release(&nd); | 378 | path_put(&nd.path); |
379 | return r; | 379 | return r; |
380 | } | 380 | } |
381 | 381 | ||
diff --git a/drivers/md/md.c b/drivers/md/md.c index 5fc326d3970e..7da6ec244e15 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -5197,8 +5197,7 @@ static int md_seq_show(struct seq_file *seq, void *v) | |||
5197 | chunk_kb ? "KB" : "B"); | 5197 | chunk_kb ? "KB" : "B"); |
5198 | if (bitmap->file) { | 5198 | if (bitmap->file) { |
5199 | seq_printf(seq, ", file: "); | 5199 | seq_printf(seq, ", file: "); |
5200 | seq_path(seq, bitmap->file->f_path.mnt, | 5200 | seq_path(seq, &bitmap->file->f_path, " \t\n"); |
5201 | bitmap->file->f_path.dentry," \t\n"); | ||
5202 | } | 5201 | } |
5203 | 5202 | ||
5204 | seq_printf(seq, "\n"); | 5203 | seq_printf(seq, "\n"); |
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index 8f4a45346de7..11950698a2e7 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig | |||
@@ -25,11 +25,16 @@ config VIDEO_DEV | |||
25 | To compile this driver as a module, choose M here: the | 25 | To compile this driver as a module, choose M here: the |
26 | module will be called videodev. | 26 | module will be called videodev. |
27 | 27 | ||
28 | config VIDEO_V4L2_COMMON | ||
29 | tristate | ||
30 | depends on (I2C || I2C=n) && VIDEO_DEV | ||
31 | default (I2C || I2C=n) && VIDEO_DEV | ||
32 | |||
28 | config VIDEO_V4L1 | 33 | config VIDEO_V4L1 |
29 | bool "Enable Video For Linux API 1 (DEPRECATED)" | 34 | bool "Enable Video For Linux API 1 (DEPRECATED)" |
30 | depends on VIDEO_DEV | 35 | depends on VIDEO_DEV && VIDEO_V4L2_COMMON |
36 | default VIDEO_DEV && VIDEO_V4L2_COMMON | ||
31 | select VIDEO_V4L1_COMPAT | 37 | select VIDEO_V4L1_COMPAT |
32 | default y | ||
33 | ---help--- | 38 | ---help--- |
34 | Enables a compatibility API used by most V4L2 devices to allow | 39 | Enables a compatibility API used by most V4L2 devices to allow |
35 | its usage with legacy applications that supports only V4L1 api. | 40 | its usage with legacy applications that supports only V4L1 api. |
@@ -39,7 +44,7 @@ config VIDEO_V4L1 | |||
39 | config VIDEO_V4L1_COMPAT | 44 | config VIDEO_V4L1_COMPAT |
40 | bool "Enable Video For Linux API 1 compatible Layer" | 45 | bool "Enable Video For Linux API 1 compatible Layer" |
41 | depends on VIDEO_DEV | 46 | depends on VIDEO_DEV |
42 | default y | 47 | default VIDEO_DEV |
43 | ---help--- | 48 | ---help--- |
44 | This api were developed to be used at Kernel 2.2 and 2.4, but | 49 | This api were developed to be used at Kernel 2.2 and 2.4, but |
45 | lacks support for several video standards. There are several | 50 | lacks support for several video standards. There are several |
@@ -55,8 +60,8 @@ config VIDEO_V4L1_COMPAT | |||
55 | 60 | ||
56 | config VIDEO_V4L2 | 61 | config VIDEO_V4L2 |
57 | bool | 62 | bool |
58 | depends on VIDEO_DEV | 63 | depends on VIDEO_DEV && VIDEO_V4L2_COMMON |
59 | default y | 64 | default VIDEO_DEV && VIDEO_V4L2_COMMON |
60 | 65 | ||
61 | source "drivers/media/video/Kconfig" | 66 | source "drivers/media/video/Kconfig" |
62 | 67 | ||
@@ -93,7 +98,7 @@ if VIDEO_TUNER_CUSTOMIZE | |||
93 | 98 | ||
94 | config TUNER_XC2028 | 99 | config TUNER_XC2028 |
95 | tristate "XCeive xc2028/xc3028 tuners" | 100 | tristate "XCeive xc2028/xc3028 tuners" |
96 | depends on I2C | 101 | depends on I2C && FW_LOADER |
97 | default m if VIDEO_TUNER_CUSTOMIZE | 102 | default m if VIDEO_TUNER_CUSTOMIZE |
98 | help | 103 | help |
99 | Say Y here to include support for the xc2028/xc3028 tuners. | 104 | Say Y here to include support for the xc2028/xc3028 tuners. |
@@ -180,7 +185,6 @@ config VIDEO_TVEEPROM | |||
180 | 185 | ||
181 | config DAB | 186 | config DAB |
182 | boolean "DAB adapters" | 187 | boolean "DAB adapters" |
183 | default y | ||
184 | ---help--- | 188 | ---help--- |
185 | Allow selecting support for for Digital Audio Broadcasting (DAB) | 189 | Allow selecting support for for Digital Audio Broadcasting (DAB) |
186 | Receiver adapters. | 190 | Receiver adapters. |
diff --git a/drivers/media/common/Kconfig b/drivers/media/common/Kconfig index 06ca75911b7f..769c6f8142d2 100644 --- a/drivers/media/common/Kconfig +++ b/drivers/media/common/Kconfig | |||
@@ -4,6 +4,6 @@ config VIDEO_SAA7146 | |||
4 | 4 | ||
5 | config VIDEO_SAA7146_VV | 5 | config VIDEO_SAA7146_VV |
6 | tristate | 6 | tristate |
7 | depends on VIDEO_DEV | 7 | depends on VIDEO_V4L2 |
8 | select VIDEOBUF_DMA_SG | 8 | select VIDEOBUF_DMA_SG |
9 | select VIDEO_SAA7146 | 9 | select VIDEO_SAA7146 |
diff --git a/drivers/media/common/ir-keymaps.c b/drivers/media/common/ir-keymaps.c index a4a937c90534..2ab5a120470d 100644 --- a/drivers/media/common/ir-keymaps.c +++ b/drivers/media/common/ir-keymaps.c | |||
@@ -1987,3 +1987,49 @@ IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE] = { | |||
1987 | }; | 1987 | }; |
1988 | 1988 | ||
1989 | EXPORT_SYMBOL_GPL(ir_codes_behold); | 1989 | EXPORT_SYMBOL_GPL(ir_codes_behold); |
1990 | |||
1991 | /* | ||
1992 | * Remote control for the Genius TVGO A11MCE | ||
1993 | * Adrian Pardini <pardo.bsso@gmail.com> | ||
1994 | */ | ||
1995 | IR_KEYTAB_TYPE ir_codes_genius_tvgo_a11mce[IR_KEYTAB_SIZE] = { | ||
1996 | /* Keys 0 to 9 */ | ||
1997 | [0x48] = KEY_0, | ||
1998 | [0x09] = KEY_1, | ||
1999 | [0x1d] = KEY_2, | ||
2000 | [0x1f] = KEY_3, | ||
2001 | [0x19] = KEY_4, | ||
2002 | [0x1b] = KEY_5, | ||
2003 | [0x11] = KEY_6, | ||
2004 | [0x17] = KEY_7, | ||
2005 | [0x12] = KEY_8, | ||
2006 | [0x16] = KEY_9, | ||
2007 | |||
2008 | [0x54] = KEY_RECORD, /* recording */ | ||
2009 | [0x06] = KEY_MUTE, /* mute */ | ||
2010 | [0x10] = KEY_POWER, | ||
2011 | [0x40] = KEY_LAST, /* recall */ | ||
2012 | [0x4c] = KEY_CHANNELUP, /* channel / program + */ | ||
2013 | [0x00] = KEY_CHANNELDOWN, /* channel / program - */ | ||
2014 | [0x0d] = KEY_VOLUMEUP, | ||
2015 | [0x15] = KEY_VOLUMEDOWN, | ||
2016 | [0x4d] = KEY_OK, /* also labeled as Pause */ | ||
2017 | [0x1c] = KEY_ZOOM, /* full screen and Stop*/ | ||
2018 | [0x02] = KEY_MODE, /* AV Source or Rewind*/ | ||
2019 | [0x04] = KEY_LIST, /* -/-- */ | ||
2020 | /* small arrows above numbers */ | ||
2021 | [0x1a] = KEY_NEXT, /* also Fast Forward */ | ||
2022 | [0x0e] = KEY_PREVIOUS, /* also Rewind */ | ||
2023 | /* these are in a rather non standard layout and have | ||
2024 | an alternate name written */ | ||
2025 | [0x1e] = KEY_UP, /* Video Setting */ | ||
2026 | [0x0a] = KEY_DOWN, /* Video Default */ | ||
2027 | [0x05] = KEY_LEFT, /* Snapshot */ | ||
2028 | [0x0c] = KEY_RIGHT, /* Hide Panel */ | ||
2029 | /* Four buttons without label */ | ||
2030 | [0x49] = KEY_RED, | ||
2031 | [0x0b] = KEY_GREEN, | ||
2032 | [0x13] = KEY_YELLOW, | ||
2033 | [0x50] = KEY_BLUE, | ||
2034 | }; | ||
2035 | EXPORT_SYMBOL_GPL(ir_codes_genius_tvgo_a11mce); | ||
diff --git a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c index c32dda973e92..bfbd5a841ebf 100644 --- a/drivers/media/common/saa7146_vbi.c +++ b/drivers/media/common/saa7146_vbi.c | |||
@@ -413,7 +413,6 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file) | |||
413 | V4L2_FIELD_SEQ_TB, // FIXME: does this really work? | 413 | V4L2_FIELD_SEQ_TB, // FIXME: does this really work? |
414 | sizeof(struct saa7146_buf), | 414 | sizeof(struct saa7146_buf), |
415 | file); | 415 | file); |
416 | mutex_init(&fh->vbi_q.lock); | ||
417 | 416 | ||
418 | init_timer(&fh->vbi_read_timeout); | 417 | init_timer(&fh->vbi_read_timeout); |
419 | fh->vbi_read_timeout.function = vbi_read_timeout; | 418 | fh->vbi_read_timeout.function = vbi_read_timeout; |
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c index c31ab480d8e1..66fdbd0e6a6d 100644 --- a/drivers/media/common/saa7146_video.c +++ b/drivers/media/common/saa7146_video.c | |||
@@ -1417,8 +1417,6 @@ static int video_open(struct saa7146_dev *dev, struct file *file) | |||
1417 | sizeof(struct saa7146_buf), | 1417 | sizeof(struct saa7146_buf), |
1418 | file); | 1418 | file); |
1419 | 1419 | ||
1420 | mutex_init(&fh->video_q.lock); | ||
1421 | |||
1422 | return 0; | 1420 | return 0; |
1423 | } | 1421 | } |
1424 | 1422 | ||
diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index c7bbb40223f5..56d8fab688bb 100644 --- a/drivers/media/dvb/bt8xx/bt878.c +++ b/drivers/media/dvb/bt8xx/bt878.c | |||
@@ -75,7 +75,11 @@ EXPORT_SYMBOL(bt878); | |||
75 | #if defined(dprintk) | 75 | #if defined(dprintk) |
76 | #undef dprintk | 76 | #undef dprintk |
77 | #endif | 77 | #endif |
78 | #define dprintk if(bt878_debug) printk | 78 | #define dprintk(fmt, arg...) \ |
79 | do { \ | ||
80 | if (bt878_debug) \ | ||
81 | printk(KERN_DEBUG fmt, ##arg); \ | ||
82 | } while (0) | ||
79 | 83 | ||
80 | static void bt878_mem_free(struct bt878 *bt) | 84 | static void bt878_mem_free(struct bt878 *bt) |
81 | { | 85 | { |
@@ -154,7 +158,7 @@ static int bt878_make_risc(struct bt878 *bt) | |||
154 | } | 158 | } |
155 | 159 | ||
156 | if (bt->line_count > 255) { | 160 | if (bt->line_count > 255) { |
157 | printk("bt878: buffer size error!\n"); | 161 | printk(KERN_ERR "bt878: buffer size error!\n"); |
158 | return -EINVAL; | 162 | return -EINVAL; |
159 | } | 163 | } |
160 | return 0; | 164 | return 0; |
@@ -285,7 +289,8 @@ static irqreturn_t bt878_irq(int irq, void *dev_id) | |||
285 | 289 | ||
286 | if (astat & (BT878_ASCERR | BT878_AOCERR)) { | 290 | if (astat & (BT878_ASCERR | BT878_AOCERR)) { |
287 | if (bt878_verbose) { | 291 | if (bt878_verbose) { |
288 | printk("bt878(%d): irq%s%s risc_pc=%08x\n", | 292 | printk(KERN_INFO |
293 | "bt878(%d): irq%s%s risc_pc=%08x\n", | ||
289 | bt->nr, | 294 | bt->nr, |
290 | (astat & BT878_ASCERR) ? " SCERR" : | 295 | (astat & BT878_ASCERR) ? " SCERR" : |
291 | "", | 296 | "", |
@@ -295,8 +300,8 @@ static irqreturn_t bt878_irq(int irq, void *dev_id) | |||
295 | } | 300 | } |
296 | if (astat & (BT878_APABORT | BT878_ARIPERR | BT878_APPERR)) { | 301 | if (astat & (BT878_APABORT | BT878_ARIPERR | BT878_APPERR)) { |
297 | if (bt878_verbose) { | 302 | if (bt878_verbose) { |
298 | printk | 303 | printk(KERN_INFO |
299 | ("bt878(%d): irq%s%s%s risc_pc=%08x\n", | 304 | "bt878(%d): irq%s%s%s risc_pc=%08x\n", |
300 | bt->nr, | 305 | bt->nr, |
301 | (astat & BT878_APABORT) ? " PABORT" : | 306 | (astat & BT878_APABORT) ? " PABORT" : |
302 | "", | 307 | "", |
@@ -308,8 +313,8 @@ static irqreturn_t bt878_irq(int irq, void *dev_id) | |||
308 | } | 313 | } |
309 | if (astat & (BT878_AFDSR | BT878_AFTRGT | BT878_AFBUS)) { | 314 | if (astat & (BT878_AFDSR | BT878_AFTRGT | BT878_AFBUS)) { |
310 | if (bt878_verbose) { | 315 | if (bt878_verbose) { |
311 | printk | 316 | printk(KERN_INFO |
312 | ("bt878(%d): irq%s%s%s risc_pc=%08x\n", | 317 | "bt878(%d): irq%s%s%s risc_pc=%08x\n", |
313 | bt->nr, | 318 | bt->nr, |
314 | (astat & BT878_AFDSR) ? " FDSR" : "", | 319 | (astat & BT878_AFDSR) ? " FDSR" : "", |
315 | (astat & BT878_AFTRGT) ? " FTRGT" : | 320 | (astat & BT878_AFTRGT) ? " FTRGT" : |
@@ -510,7 +515,7 @@ static int __devinit bt878_probe(struct pci_dev *dev, | |||
510 | */ | 515 | */ |
511 | 516 | ||
512 | if ((result = bt878_mem_alloc(bt))) { | 517 | if ((result = bt878_mem_alloc(bt))) { |
513 | printk("bt878: failed to allocate memory!\n"); | 518 | printk(KERN_ERR "bt878: failed to allocate memory!\n"); |
514 | goto fail2; | 519 | goto fail2; |
515 | } | 520 | } |
516 | 521 | ||
@@ -536,7 +541,7 @@ static void __devexit bt878_remove(struct pci_dev *pci_dev) | |||
536 | struct bt878 *bt = pci_get_drvdata(pci_dev); | 541 | struct bt878 *bt = pci_get_drvdata(pci_dev); |
537 | 542 | ||
538 | if (bt878_verbose) | 543 | if (bt878_verbose) |
539 | printk("bt878(%d): unloading\n", bt->nr); | 544 | printk(KERN_INFO "bt878(%d): unloading\n", bt->nr); |
540 | 545 | ||
541 | /* turn off all capturing, DMA and IRQs */ | 546 | /* turn off all capturing, DMA and IRQs */ |
542 | btand(~0x13, BT878_AGPIO_DMA_CTL); | 547 | btand(~0x13, BT878_AGPIO_DMA_CTL); |
diff --git a/drivers/media/dvb/dvb-usb/ttusb2.c b/drivers/media/dvb/dvb-usb/ttusb2.c index 88dc4367a2e3..3b9da9c25c6e 100644 --- a/drivers/media/dvb/dvb-usb/ttusb2.c +++ b/drivers/media/dvb/dvb-usb/ttusb2.c | |||
@@ -144,6 +144,7 @@ static int ttusb2_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
144 | static struct tda10086_config tda10086_config = { | 144 | static struct tda10086_config tda10086_config = { |
145 | .demod_address = 0x0e, | 145 | .demod_address = 0x0e, |
146 | .invert = 0, | 146 | .invert = 0, |
147 | .diseqc_tone = 1, | ||
147 | }; | 148 | }; |
148 | 149 | ||
149 | static int ttusb2_frontend_attach(struct dvb_usb_adapter *adap) | 150 | static int ttusb2_frontend_attach(struct dvb_usb_adapter *adap) |
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c index 9d26ace65151..0d2b69a99ad4 100644 --- a/drivers/media/dvb/frontends/tda10086.c +++ b/drivers/media/dvb/frontends/tda10086.c | |||
@@ -106,9 +106,12 @@ static int tda10086_write_mask(struct tda10086_state *state, int reg, int mask, | |||
106 | static int tda10086_init(struct dvb_frontend* fe) | 106 | static int tda10086_init(struct dvb_frontend* fe) |
107 | { | 107 | { |
108 | struct tda10086_state* state = fe->demodulator_priv; | 108 | struct tda10086_state* state = fe->demodulator_priv; |
109 | u8 t22k_off = 0x80; | ||
109 | 110 | ||
110 | dprintk ("%s\n", __FUNCTION__); | 111 | dprintk ("%s\n", __FUNCTION__); |
111 | 112 | ||
113 | if (state->config->diseqc_tone) | ||
114 | t22k_off = 0; | ||
112 | // reset | 115 | // reset |
113 | tda10086_write_byte(state, 0x00, 0x00); | 116 | tda10086_write_byte(state, 0x00, 0x00); |
114 | msleep(10); | 117 | msleep(10); |
@@ -158,7 +161,7 @@ static int tda10086_init(struct dvb_frontend* fe) | |||
158 | tda10086_write_byte(state, 0x3d, 0x80); | 161 | tda10086_write_byte(state, 0x3d, 0x80); |
159 | 162 | ||
160 | // setup SEC | 163 | // setup SEC |
161 | tda10086_write_byte(state, 0x36, 0x80); // all SEC off, no 22k tone | 164 | tda10086_write_byte(state, 0x36, t22k_off); // all SEC off, 22k tone |
162 | tda10086_write_byte(state, 0x34, (((1<<19) * (22000/1000)) / (SACLK/1000))); // } tone frequency | 165 | tda10086_write_byte(state, 0x34, (((1<<19) * (22000/1000)) / (SACLK/1000))); // } tone frequency |
163 | tda10086_write_byte(state, 0x35, (((1<<19) * (22000/1000)) / (SACLK/1000)) >> 8); // } | 166 | tda10086_write_byte(state, 0x35, (((1<<19) * (22000/1000)) / (SACLK/1000)) >> 8); // } |
164 | 167 | ||
@@ -180,16 +183,20 @@ static void tda10086_diseqc_wait(struct tda10086_state *state) | |||
180 | static int tda10086_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | 183 | static int tda10086_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) |
181 | { | 184 | { |
182 | struct tda10086_state* state = fe->demodulator_priv; | 185 | struct tda10086_state* state = fe->demodulator_priv; |
186 | u8 t22k_off = 0x80; | ||
183 | 187 | ||
184 | dprintk ("%s\n", __FUNCTION__); | 188 | dprintk ("%s\n", __FUNCTION__); |
185 | 189 | ||
190 | if (state->config->diseqc_tone) | ||
191 | t22k_off = 0; | ||
192 | |||
186 | switch (tone) { | 193 | switch (tone) { |
187 | case SEC_TONE_OFF: | 194 | case SEC_TONE_OFF: |
188 | tda10086_write_byte(state, 0x36, 0x80); | 195 | tda10086_write_byte(state, 0x36, t22k_off); |
189 | break; | 196 | break; |
190 | 197 | ||
191 | case SEC_TONE_ON: | 198 | case SEC_TONE_ON: |
192 | tda10086_write_byte(state, 0x36, 0x81); | 199 | tda10086_write_byte(state, 0x36, 0x01 + t22k_off); |
193 | break; | 200 | break; |
194 | } | 201 | } |
195 | 202 | ||
@@ -202,9 +209,13 @@ static int tda10086_send_master_cmd (struct dvb_frontend* fe, | |||
202 | struct tda10086_state* state = fe->demodulator_priv; | 209 | struct tda10086_state* state = fe->demodulator_priv; |
203 | int i; | 210 | int i; |
204 | u8 oldval; | 211 | u8 oldval; |
212 | u8 t22k_off = 0x80; | ||
205 | 213 | ||
206 | dprintk ("%s\n", __FUNCTION__); | 214 | dprintk ("%s\n", __FUNCTION__); |
207 | 215 | ||
216 | if (state->config->diseqc_tone) | ||
217 | t22k_off = 0; | ||
218 | |||
208 | if (cmd->msg_len > 6) | 219 | if (cmd->msg_len > 6) |
209 | return -EINVAL; | 220 | return -EINVAL; |
210 | oldval = tda10086_read_byte(state, 0x36); | 221 | oldval = tda10086_read_byte(state, 0x36); |
@@ -212,7 +223,8 @@ static int tda10086_send_master_cmd (struct dvb_frontend* fe, | |||
212 | for(i=0; i< cmd->msg_len; i++) { | 223 | for(i=0; i< cmd->msg_len; i++) { |
213 | tda10086_write_byte(state, 0x48+i, cmd->msg[i]); | 224 | tda10086_write_byte(state, 0x48+i, cmd->msg[i]); |
214 | } | 225 | } |
215 | tda10086_write_byte(state, 0x36, 0x88 | ((cmd->msg_len - 1) << 4)); | 226 | tda10086_write_byte(state, 0x36, (0x08 + t22k_off) |
227 | | ((cmd->msg_len - 1) << 4)); | ||
216 | 228 | ||
217 | tda10086_diseqc_wait(state); | 229 | tda10086_diseqc_wait(state); |
218 | 230 | ||
@@ -225,16 +237,20 @@ static int tda10086_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minic | |||
225 | { | 237 | { |
226 | struct tda10086_state* state = fe->demodulator_priv; | 238 | struct tda10086_state* state = fe->demodulator_priv; |
227 | u8 oldval = tda10086_read_byte(state, 0x36); | 239 | u8 oldval = tda10086_read_byte(state, 0x36); |
240 | u8 t22k_off = 0x80; | ||
228 | 241 | ||
229 | dprintk ("%s\n", __FUNCTION__); | 242 | dprintk ("%s\n", __FUNCTION__); |
230 | 243 | ||
244 | if (state->config->diseqc_tone) | ||
245 | t22k_off = 0; | ||
246 | |||
231 | switch(minicmd) { | 247 | switch(minicmd) { |
232 | case SEC_MINI_A: | 248 | case SEC_MINI_A: |
233 | tda10086_write_byte(state, 0x36, 0x84); | 249 | tda10086_write_byte(state, 0x36, 0x04 + t22k_off); |
234 | break; | 250 | break; |
235 | 251 | ||
236 | case SEC_MINI_B: | 252 | case SEC_MINI_B: |
237 | tda10086_write_byte(state, 0x36, 0x86); | 253 | tda10086_write_byte(state, 0x36, 0x06 + t22k_off); |
238 | break; | 254 | break; |
239 | } | 255 | } |
240 | 256 | ||
diff --git a/drivers/media/dvb/frontends/tda10086.h b/drivers/media/dvb/frontends/tda10086.h index ed584a8f4a89..eeceaeee78ff 100644 --- a/drivers/media/dvb/frontends/tda10086.h +++ b/drivers/media/dvb/frontends/tda10086.h | |||
@@ -33,6 +33,9 @@ struct tda10086_config | |||
33 | 33 | ||
34 | /* does the "inversion" need inverted? */ | 34 | /* does the "inversion" need inverted? */ |
35 | u8 invert; | 35 | u8 invert; |
36 | |||
37 | /* do we need the diseqc signal with carrier? */ | ||
38 | u8 diseqc_tone; | ||
36 | }; | 39 | }; |
37 | 40 | ||
38 | #if defined(CONFIG_DVB_TDA10086) || (defined(CONFIG_DVB_TDA10086_MODULE) && defined(MODULE)) | 41 | #if defined(CONFIG_DVB_TDA10086) || (defined(CONFIG_DVB_TDA10086_MODULE) && defined(MODULE)) |
diff --git a/drivers/media/dvb/frontends/tda18271-common.c b/drivers/media/dvb/frontends/tda18271-common.c index cebb6b90b7e0..bca570990613 100644 --- a/drivers/media/dvb/frontends/tda18271-common.c +++ b/drivers/media/dvb/frontends/tda18271-common.c | |||
@@ -171,7 +171,7 @@ int tda18271_read_extended(struct dvb_frontend *fe) | |||
171 | if (ret != 2) | 171 | if (ret != 2) |
172 | tda_err("ERROR: i2c_transfer returned: %d\n", ret); | 172 | tda_err("ERROR: i2c_transfer returned: %d\n", ret); |
173 | 173 | ||
174 | for (i = 0; i <= TDA18271_NUM_REGS; i++) { | 174 | for (i = 0; i < TDA18271_NUM_REGS; i++) { |
175 | /* don't update write-only registers */ | 175 | /* don't update write-only registers */ |
176 | if ((i != R_EB9) && | 176 | if ((i != R_EB9) && |
177 | (i != R_EB16) && | 177 | (i != R_EB16) && |
diff --git a/drivers/media/dvb/frontends/xc5000.h b/drivers/media/dvb/frontends/xc5000.h index e0e84562aed1..32a5f1c86a16 100644 --- a/drivers/media/dvb/frontends/xc5000.h +++ b/drivers/media/dvb/frontends/xc5000.h | |||
@@ -45,7 +45,8 @@ struct xc5000_config { | |||
45 | /* xc5000 callback command */ | 45 | /* xc5000 callback command */ |
46 | #define XC5000_TUNER_RESET 0 | 46 | #define XC5000_TUNER_RESET 0 |
47 | 47 | ||
48 | #if defined(CONFIG_DVB_TUNER_XC5000) || defined(CONFIG_DVB_TUNER_XC5000_MODULE) | 48 | #if defined(CONFIG_DVB_TUNER_XC5000) || \ |
49 | (defined(CONFIG_DVB_TUNER_XC5000_MODULE) && defined(MODULE)) | ||
49 | extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, | 50 | extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, |
50 | struct i2c_adapter *i2c, | 51 | struct i2c_adapter *i2c, |
51 | struct xc5000_config *cfg); | 52 | struct xc5000_config *cfg); |
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c index aef6e36d7c5c..3e6b650fbb81 100644 --- a/drivers/media/dvb/ttpci/av7110_av.c +++ b/drivers/media/dvb/ttpci/av7110_av.c | |||
@@ -966,6 +966,7 @@ static u8 iframe_header[] = { 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x | |||
966 | static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len, int nonblock) | 966 | static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len, int nonblock) |
967 | { | 967 | { |
968 | int i, n; | 968 | int i, n; |
969 | int progressive = 0; | ||
969 | 970 | ||
970 | dprintk(2, "av7110:%p, \n", av7110); | 971 | dprintk(2, "av7110:%p, \n", av7110); |
971 | 972 | ||
@@ -974,6 +975,14 @@ static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len | |||
974 | return -EBUSY; | 975 | return -EBUSY; |
975 | } | 976 | } |
976 | 977 | ||
978 | for (i = 0; i < len - 5; i++) { | ||
979 | /* get progressive flag from picture extension */ | ||
980 | if (buf[i] == 0x00 && buf[i+1] == 0x00 && | ||
981 | buf[i+2] == 0x01 && (unsigned char)buf[i+3] == 0xb5 && | ||
982 | (buf[i+4] & 0xf0) == 0x10) | ||
983 | progressive = buf[i+5] & 0x08; | ||
984 | } | ||
985 | |||
977 | /* setting n always > 1, fixes problems when playing stillframes | 986 | /* setting n always > 1, fixes problems when playing stillframes |
978 | consisting of I- and P-Frames */ | 987 | consisting of I- and P-Frames */ |
979 | n = MIN_IFRAME / len + 1; | 988 | n = MIN_IFRAME / len + 1; |
@@ -985,7 +994,11 @@ static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len | |||
985 | dvb_play(av7110, buf, len, 0, 1); | 994 | dvb_play(av7110, buf, len, 0, 1); |
986 | 995 | ||
987 | av7110_ipack_flush(&av7110->ipack[1]); | 996 | av7110_ipack_flush(&av7110->ipack[1]); |
988 | return 0; | 997 | |
998 | if (progressive) | ||
999 | return vidcom(av7110, AV_VIDEO_CMD_FREEZE, 1); | ||
1000 | else | ||
1001 | return 0; | ||
989 | } | 1002 | } |
990 | 1003 | ||
991 | 1004 | ||
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 3439c9864f67..2d64d557b977 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c | |||
@@ -896,6 +896,7 @@ static u8 read_pwm(struct budget_av *budget_av) | |||
896 | #define SUBID_DVBS_CINERGY1200 0x1154 | 896 | #define SUBID_DVBS_CINERGY1200 0x1154 |
897 | #define SUBID_DVBS_CYNERGY1200N 0x1155 | 897 | #define SUBID_DVBS_CYNERGY1200N 0x1155 |
898 | #define SUBID_DVBS_TV_STAR 0x0014 | 898 | #define SUBID_DVBS_TV_STAR 0x0014 |
899 | #define SUBID_DVBS_TV_STAR_PLUS_X4 0x0015 | ||
899 | #define SUBID_DVBS_TV_STAR_CI 0x0016 | 900 | #define SUBID_DVBS_TV_STAR_CI 0x0016 |
900 | #define SUBID_DVBS_EASYWATCH_1 0x001a | 901 | #define SUBID_DVBS_EASYWATCH_1 0x001a |
901 | #define SUBID_DVBS_EASYWATCH_2 0x001b | 902 | #define SUBID_DVBS_EASYWATCH_2 0x001b |
@@ -910,6 +911,7 @@ static u8 read_pwm(struct budget_av *budget_av) | |||
910 | #define SUBID_DVBC_CINERGY1200 0x1156 | 911 | #define SUBID_DVBC_CINERGY1200 0x1156 |
911 | #define SUBID_DVBC_CINERGY1200_MK3 0x1176 | 912 | #define SUBID_DVBC_CINERGY1200_MK3 0x1176 |
912 | 913 | ||
914 | #define SUBID_DVBT_EASYWATCH 0x003a | ||
913 | #define SUBID_DVBT_KNC1_PLUS 0x0031 | 915 | #define SUBID_DVBT_KNC1_PLUS 0x0031 |
914 | #define SUBID_DVBT_KNC1 0x0030 | 916 | #define SUBID_DVBT_KNC1 0x0030 |
915 | #define SUBID_DVBT_CINERGY1200 0x1157 | 917 | #define SUBID_DVBT_CINERGY1200 0x1157 |
@@ -957,6 +959,7 @@ static void frontend_init(struct budget_av *budget_av) | |||
957 | break; | 959 | break; |
958 | 960 | ||
959 | case SUBID_DVBS_TV_STAR: | 961 | case SUBID_DVBS_TV_STAR: |
962 | case SUBID_DVBS_TV_STAR_PLUS_X4: | ||
960 | case SUBID_DVBS_TV_STAR_CI: | 963 | case SUBID_DVBS_TV_STAR_CI: |
961 | case SUBID_DVBS_CYNERGY1200N: | 964 | case SUBID_DVBS_CYNERGY1200N: |
962 | case SUBID_DVBS_EASYWATCH: | 965 | case SUBID_DVBS_EASYWATCH: |
@@ -1018,6 +1021,7 @@ static void frontend_init(struct budget_av *budget_av) | |||
1018 | } | 1021 | } |
1019 | break; | 1022 | break; |
1020 | 1023 | ||
1024 | case SUBID_DVBT_EASYWATCH: | ||
1021 | case SUBID_DVBT_KNC1: | 1025 | case SUBID_DVBT_KNC1: |
1022 | case SUBID_DVBT_KNC1_PLUS: | 1026 | case SUBID_DVBT_KNC1_PLUS: |
1023 | case SUBID_DVBT_CINERGY1200: | 1027 | case SUBID_DVBT_CINERGY1200: |
@@ -1248,7 +1252,9 @@ MAKE_BUDGET_INFO(satewpls1, "Satelco EasyWatch DVB-S light", BUDGET_KNC1S); | |||
1248 | MAKE_BUDGET_INFO(satewps, "Satelco EasyWatch DVB-S", BUDGET_KNC1S); | 1252 | MAKE_BUDGET_INFO(satewps, "Satelco EasyWatch DVB-S", BUDGET_KNC1S); |
1249 | MAKE_BUDGET_INFO(satewplc, "Satelco EasyWatch DVB-C", BUDGET_KNC1CP); | 1253 | MAKE_BUDGET_INFO(satewplc, "Satelco EasyWatch DVB-C", BUDGET_KNC1CP); |
1250 | MAKE_BUDGET_INFO(satewcmk3, "Satelco EasyWatch DVB-C MK3", BUDGET_KNC1C_MK3); | 1254 | MAKE_BUDGET_INFO(satewcmk3, "Satelco EasyWatch DVB-C MK3", BUDGET_KNC1C_MK3); |
1255 | MAKE_BUDGET_INFO(satewt, "Satelco EasyWatch DVB-T", BUDGET_KNC1T); | ||
1251 | MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP); | 1256 | MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP); |
1257 | MAKE_BUDGET_INFO(knc1spx4, "KNC1 DVB-S Plus X4", BUDGET_KNC1SP); | ||
1252 | MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP); | 1258 | MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP); |
1253 | MAKE_BUDGET_INFO(knc1cmk3, "KNC1 DVB-C MK3", BUDGET_KNC1C_MK3); | 1259 | MAKE_BUDGET_INFO(knc1cmk3, "KNC1 DVB-C MK3", BUDGET_KNC1C_MK3); |
1254 | MAKE_BUDGET_INFO(knc1cpmk3, "KNC1 DVB-C Plus MK3", BUDGET_KNC1CP_MK3); | 1260 | MAKE_BUDGET_INFO(knc1cpmk3, "KNC1 DVB-C Plus MK3", BUDGET_KNC1CP_MK3); |
@@ -1266,12 +1272,14 @@ static struct pci_device_id pci_tbl[] = { | |||
1266 | MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011), | 1272 | MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011), |
1267 | MAKE_EXTENSION_PCI(knc1sp, 0x1894, 0x0011), | 1273 | MAKE_EXTENSION_PCI(knc1sp, 0x1894, 0x0011), |
1268 | MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014), | 1274 | MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014), |
1275 | MAKE_EXTENSION_PCI(knc1spx4, 0x1894, 0x0015), | ||
1269 | MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016), | 1276 | MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016), |
1270 | MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e), | 1277 | MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e), |
1271 | MAKE_EXTENSION_PCI(satewpls1, 0x1894, 0x001a), | 1278 | MAKE_EXTENSION_PCI(satewpls1, 0x1894, 0x001a), |
1272 | MAKE_EXTENSION_PCI(satewps, 0x1894, 0x001b), | 1279 | MAKE_EXTENSION_PCI(satewps, 0x1894, 0x001b), |
1273 | MAKE_EXTENSION_PCI(satewplc, 0x1894, 0x002a), | 1280 | MAKE_EXTENSION_PCI(satewplc, 0x1894, 0x002a), |
1274 | MAKE_EXTENSION_PCI(satewcmk3, 0x1894, 0x002c), | 1281 | MAKE_EXTENSION_PCI(satewcmk3, 0x1894, 0x002c), |
1282 | MAKE_EXTENSION_PCI(satewt, 0x1894, 0x003a), | ||
1275 | MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020), | 1283 | MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020), |
1276 | MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021), | 1284 | MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021), |
1277 | MAKE_EXTENSION_PCI(knc1cmk3, 0x1894, 0x0022), | 1285 | MAKE_EXTENSION_PCI(knc1cmk3, 0x1894, 0x0022), |
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 9268a82bada6..14b00f57b5de 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c | |||
@@ -351,6 +351,7 @@ static struct s5h1420_config s5h1420_config = { | |||
351 | static struct tda10086_config tda10086_config = { | 351 | static struct tda10086_config tda10086_config = { |
352 | .demod_address = 0x0e, | 352 | .demod_address = 0x0e, |
353 | .invert = 0, | 353 | .invert = 0, |
354 | .diseqc_tone = 1, | ||
354 | }; | 355 | }; |
355 | 356 | ||
356 | static u8 read_pwm(struct budget* budget) | 357 | static u8 read_pwm(struct budget* budget) |
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index 8d5214f18cf0..1b41b3f77cf9 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -4,12 +4,12 @@ | |||
4 | 4 | ||
5 | menuconfig RADIO_ADAPTERS | 5 | menuconfig RADIO_ADAPTERS |
6 | bool "Radio Adapters" | 6 | bool "Radio Adapters" |
7 | depends on VIDEO_DEV | 7 | depends on VIDEO_V4L2 |
8 | default y | 8 | default y |
9 | ---help--- | 9 | ---help--- |
10 | Say Y here to enable selecting AM/FM radio adapters. | 10 | Say Y here to enable selecting AM/FM radio adapters. |
11 | 11 | ||
12 | if RADIO_ADAPTERS && VIDEO_DEV | 12 | if RADIO_ADAPTERS && VIDEO_V4L2 |
13 | 13 | ||
14 | config RADIO_CADET | 14 | config RADIO_CADET |
15 | tristate "ADS Cadet AM/FM Tuner" | 15 | tristate "ADS Cadet AM/FM Tuner" |
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 3118bdab3183..53e114857377 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c | |||
@@ -361,6 +361,7 @@ static int __init fmi_init(void) | |||
361 | } | 361 | } |
362 | if (!request_region(io, 2, "radio-sf16fmi")) { | 362 | if (!request_region(io, 2, "radio-sf16fmi")) { |
363 | printk(KERN_ERR "radio-sf16fmi: port 0x%x already in use\n", io); | 363 | printk(KERN_ERR "radio-sf16fmi: port 0x%x already in use\n", io); |
364 | pnp_device_detach(dev); | ||
364 | return -EBUSY; | 365 | return -EBUSY; |
365 | } | 366 | } |
366 | 367 | ||
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c index f7c8b000404f..ebc5fbbc38bb 100644 --- a/drivers/media/radio/radio-sf16fmr2.c +++ b/drivers/media/radio/radio-sf16fmr2.c | |||
@@ -470,9 +470,8 @@ static int __init fmr2_init(void) | |||
470 | 470 | ||
471 | mutex_init(&lock); | 471 | mutex_init(&lock); |
472 | 472 | ||
473 | if (request_region(io, 2, "sf16fmr2")) | 473 | if (!request_region(io, 2, "sf16fmr2")) { |
474 | { | 474 | printk(KERN_ERR "radio-sf16fmr2: request_region failed!\n"); |
475 | printk(KERN_ERR "fmr2: port 0x%x already in use\n", io); | ||
476 | return -EBUSY; | 475 | return -EBUSY; |
477 | } | 476 | } |
478 | 477 | ||
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c index 8e4bd4769048..649f14d2c013 100644 --- a/drivers/media/radio/radio-si470x.c +++ b/drivers/media/radio/radio-si470x.c | |||
@@ -62,6 +62,29 @@ | |||
62 | * - code cleaned of unnecessary rds_commands | 62 | * - code cleaned of unnecessary rds_commands |
63 | * - USB Vendor/Product ID for ADS/Tech FM Radio Receiver verified | 63 | * - USB Vendor/Product ID for ADS/Tech FM Radio Receiver verified |
64 | * (thanks to Guillaume RAMOUSSE) | 64 | * (thanks to Guillaume RAMOUSSE) |
65 | * 2008-01-27 Tobias Lorenz <tobias.lorenz@gmx.net> | ||
66 | * Version 1.0.5 | ||
67 | * - number of seek_retries changed to tune_timeout | ||
68 | * - fixed problem with incomplete tune operations by own buffers | ||
69 | * - optimization of variables and printf types | ||
70 | * - improved error logging | ||
71 | * 2008-01-31 Tobias Lorenz <tobias.lorenz@gmx.net> | ||
72 | * Oliver Neukum <oliver@neukum.org> | ||
73 | * Version 1.0.6 | ||
74 | * - fixed coverity checker warnings in *_usb_driver_disconnect | ||
75 | * - probe()/open() race by correct ordering in probe() | ||
76 | * - DMA coherency rules by separate allocation of all buffers | ||
77 | * - use of endianness macros | ||
78 | * - abuse of spinlock, replaced by mutex | ||
79 | * - racy handling of timer in disconnect, | ||
80 | * replaced by delayed_work | ||
81 | * - racy interruptible_sleep_on(), | ||
82 | * replaced with wait_event_interruptible() | ||
83 | * - handle signals in read() | ||
84 | * 2008-02-08 Tobias Lorenz <tobias.lorenz@gmx.net> | ||
85 | * Oliver Neukum <oliver@neukum.org> | ||
86 | * Version 1.0.7 | ||
87 | * - usb autosuspend support | ||
65 | * | 88 | * |
66 | * ToDo: | 89 | * ToDo: |
67 | * - add seeking support | 90 | * - add seeking support |
@@ -74,9 +97,10 @@ | |||
74 | /* driver definitions */ | 97 | /* driver definitions */ |
75 | #define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@gmx.net>" | 98 | #define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@gmx.net>" |
76 | #define DRIVER_NAME "radio-si470x" | 99 | #define DRIVER_NAME "radio-si470x" |
77 | #define DRIVER_VERSION KERNEL_VERSION(1, 0, 4) | 100 | #define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 6) |
78 | #define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver" | 101 | #define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver" |
79 | #define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers" | 102 | #define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers" |
103 | #define DRIVER_VERSION "1.0.6" | ||
80 | 104 | ||
81 | 105 | ||
82 | /* kernel includes */ | 106 | /* kernel includes */ |
@@ -89,8 +113,10 @@ | |||
89 | #include <linux/hid.h> | 113 | #include <linux/hid.h> |
90 | #include <linux/version.h> | 114 | #include <linux/version.h> |
91 | #include <linux/videodev2.h> | 115 | #include <linux/videodev2.h> |
116 | #include <linux/mutex.h> | ||
92 | #include <media/v4l2-common.h> | 117 | #include <media/v4l2-common.h> |
93 | #include <media/rds.h> | 118 | #include <media/rds.h> |
119 | #include <asm/unaligned.h> | ||
94 | 120 | ||
95 | 121 | ||
96 | /* USB Device ID List */ | 122 | /* USB Device ID List */ |
@@ -119,56 +145,56 @@ MODULE_PARM_DESC(radio_nr, "Radio Nr"); | |||
119 | /* 0: 200 kHz (USA, Australia) */ | 145 | /* 0: 200 kHz (USA, Australia) */ |
120 | /* 1: 100 kHz (Europe, Japan) */ | 146 | /* 1: 100 kHz (Europe, Japan) */ |
121 | /* 2: 50 kHz */ | 147 | /* 2: 50 kHz */ |
122 | static int space = 2; | 148 | static unsigned short space = 2; |
123 | module_param(space, int, 0); | 149 | module_param(space, ushort, 0); |
124 | MODULE_PARM_DESC(radio_nr, "Spacing: 0=200kHz 1=100kHz *2=50kHz*"); | 150 | MODULE_PARM_DESC(radio_nr, "Spacing: 0=200kHz 1=100kHz *2=50kHz*"); |
125 | 151 | ||
126 | /* Bottom of Band (MHz) */ | 152 | /* Bottom of Band (MHz) */ |
127 | /* 0: 87.5 - 108 MHz (USA, Europe)*/ | 153 | /* 0: 87.5 - 108 MHz (USA, Europe)*/ |
128 | /* 1: 76 - 108 MHz (Japan wide band) */ | 154 | /* 1: 76 - 108 MHz (Japan wide band) */ |
129 | /* 2: 76 - 90 MHz (Japan) */ | 155 | /* 2: 76 - 90 MHz (Japan) */ |
130 | static int band = 1; | 156 | static unsigned short band = 1; |
131 | module_param(band, int, 0); | 157 | module_param(band, ushort, 0); |
132 | MODULE_PARM_DESC(radio_nr, "Band: 0=87.5..108MHz *1=76..108MHz* 2=76..90MHz"); | 158 | MODULE_PARM_DESC(radio_nr, "Band: 0=87.5..108MHz *1=76..108MHz* 2=76..90MHz"); |
133 | 159 | ||
134 | /* De-emphasis */ | 160 | /* De-emphasis */ |
135 | /* 0: 75 us (USA) */ | 161 | /* 0: 75 us (USA) */ |
136 | /* 1: 50 us (Europe, Australia, Japan) */ | 162 | /* 1: 50 us (Europe, Australia, Japan) */ |
137 | static int de = 1; | 163 | static unsigned short de = 1; |
138 | module_param(de, int, 0); | 164 | module_param(de, ushort, 0); |
139 | MODULE_PARM_DESC(radio_nr, "De-emphasis: 0=75us *1=50us*"); | 165 | MODULE_PARM_DESC(radio_nr, "De-emphasis: 0=75us *1=50us*"); |
140 | 166 | ||
141 | /* USB timeout */ | 167 | /* USB timeout */ |
142 | static int usb_timeout = 500; | 168 | static unsigned int usb_timeout = 500; |
143 | module_param(usb_timeout, int, 0); | 169 | module_param(usb_timeout, uint, 0); |
144 | MODULE_PARM_DESC(usb_timeout, "USB timeout (ms): *500*"); | 170 | MODULE_PARM_DESC(usb_timeout, "USB timeout (ms): *500*"); |
145 | 171 | ||
146 | /* Seek retries */ | 172 | /* Tune timeout */ |
147 | static int seek_retries = 100; | 173 | static unsigned int tune_timeout = 3000; |
148 | module_param(seek_retries, int, 0); | 174 | module_param(tune_timeout, uint, 0); |
149 | MODULE_PARM_DESC(seek_retries, "Seek retries: *100*"); | 175 | MODULE_PARM_DESC(tune_timeout, "Tune timeout: *3000*"); |
150 | 176 | ||
151 | /* RDS buffer blocks */ | 177 | /* RDS buffer blocks */ |
152 | static int rds_buf = 100; | 178 | static unsigned int rds_buf = 100; |
153 | module_param(rds_buf, int, 0); | 179 | module_param(rds_buf, uint, 0); |
154 | MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*"); | 180 | MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*"); |
155 | 181 | ||
156 | /* RDS maximum block errors */ | 182 | /* RDS maximum block errors */ |
157 | static int max_rds_errors = 1; | 183 | static unsigned short max_rds_errors = 1; |
158 | /* 0 means 0 errors requiring correction */ | 184 | /* 0 means 0 errors requiring correction */ |
159 | /* 1 means 1-2 errors requiring correction (used by original USBRadio.exe) */ | 185 | /* 1 means 1-2 errors requiring correction (used by original USBRadio.exe) */ |
160 | /* 2 means 3-5 errors requiring correction */ | 186 | /* 2 means 3-5 errors requiring correction */ |
161 | /* 3 means 6+ errors or errors in checkword, correction not possible */ | 187 | /* 3 means 6+ errors or errors in checkword, correction not possible */ |
162 | module_param(max_rds_errors, int, 0); | 188 | module_param(max_rds_errors, ushort, 0); |
163 | MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*"); | 189 | MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*"); |
164 | 190 | ||
165 | /* RDS poll frequency */ | 191 | /* RDS poll frequency */ |
166 | static int rds_poll_time = 40; | 192 | static unsigned int rds_poll_time = 40; |
167 | /* 40 is used by the original USBRadio.exe */ | 193 | /* 40 is used by the original USBRadio.exe */ |
168 | /* 50 is used by radio-cadet */ | 194 | /* 50 is used by radio-cadet */ |
169 | /* 75 should be okay */ | 195 | /* 75 should be okay */ |
170 | /* 80 is the usual RDS receive interval */ | 196 | /* 80 is the usual RDS receive interval */ |
171 | module_param(rds_poll_time, int, 0); | 197 | module_param(rds_poll_time, uint, 0); |
172 | MODULE_PARM_DESC(rds_poll_time, "RDS poll time (ms): *40*"); | 198 | MODULE_PARM_DESC(rds_poll_time, "RDS poll time (ms): *40*"); |
173 | 199 | ||
174 | 200 | ||
@@ -393,22 +419,19 @@ MODULE_PARM_DESC(rds_poll_time, "RDS poll time (ms): *40*"); | |||
393 | struct si470x_device { | 419 | struct si470x_device { |
394 | /* reference to USB and video device */ | 420 | /* reference to USB and video device */ |
395 | struct usb_device *usbdev; | 421 | struct usb_device *usbdev; |
422 | struct usb_interface *intf; | ||
396 | struct video_device *videodev; | 423 | struct video_device *videodev; |
397 | 424 | ||
398 | /* are these really necessary ? */ | 425 | /* driver management */ |
399 | int users; | 426 | unsigned int users; |
400 | |||
401 | /* report buffer (maximum 64 bytes) */ | ||
402 | unsigned char buf[64]; | ||
403 | 427 | ||
404 | /* Silabs internal registers (0..15) */ | 428 | /* Silabs internal registers (0..15) */ |
405 | unsigned short registers[RADIO_REGISTER_NUM]; | 429 | unsigned short registers[RADIO_REGISTER_NUM]; |
406 | 430 | ||
407 | /* RDS receive buffer */ | 431 | /* RDS receive buffer */ |
408 | struct work_struct work; | 432 | struct delayed_work work; |
409 | wait_queue_head_t read_queue; | 433 | wait_queue_head_t read_queue; |
410 | struct timer_list timer; | 434 | struct mutex lock; /* buffer locking */ |
411 | spinlock_t lock; /* buffer locking */ | ||
412 | unsigned char *buffer; /* size is always multiple of three */ | 435 | unsigned char *buffer; /* size is always multiple of three */ |
413 | unsigned int buf_size; | 436 | unsigned int buf_size; |
414 | unsigned int rd_index; | 437 | unsigned int rd_index; |
@@ -434,28 +457,46 @@ struct si470x_device { | |||
434 | /* | 457 | /* |
435 | * si470x_get_report - receive a HID report | 458 | * si470x_get_report - receive a HID report |
436 | */ | 459 | */ |
437 | static int si470x_get_report(struct si470x_device *radio, int size) | 460 | static int si470x_get_report(struct si470x_device *radio, void *buf, int size) |
438 | { | 461 | { |
439 | return usb_control_msg(radio->usbdev, | 462 | unsigned char *report = (unsigned char *) buf; |
463 | int retval; | ||
464 | |||
465 | retval = usb_control_msg(radio->usbdev, | ||
440 | usb_rcvctrlpipe(radio->usbdev, 0), | 466 | usb_rcvctrlpipe(radio->usbdev, 0), |
441 | HID_REQ_GET_REPORT, | 467 | HID_REQ_GET_REPORT, |
442 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | 468 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, |
443 | radio->buf[0], 2, | 469 | report[0], 2, |
444 | radio->buf, size, usb_timeout); | 470 | buf, size, usb_timeout); |
471 | if (retval < 0) | ||
472 | printk(KERN_WARNING DRIVER_NAME | ||
473 | ": si470x_get_report: usb_control_msg returned %d\n", | ||
474 | retval); | ||
475 | |||
476 | return retval; | ||
445 | } | 477 | } |
446 | 478 | ||
447 | 479 | ||
448 | /* | 480 | /* |
449 | * si470x_set_report - send a HID report | 481 | * si470x_set_report - send a HID report |
450 | */ | 482 | */ |
451 | static int si470x_set_report(struct si470x_device *radio, int size) | 483 | static int si470x_set_report(struct si470x_device *radio, void *buf, int size) |
452 | { | 484 | { |
453 | return usb_control_msg(radio->usbdev, | 485 | unsigned char *report = (unsigned char *) buf; |
486 | int retval; | ||
487 | |||
488 | retval = usb_control_msg(radio->usbdev, | ||
454 | usb_sndctrlpipe(radio->usbdev, 0), | 489 | usb_sndctrlpipe(radio->usbdev, 0), |
455 | HID_REQ_SET_REPORT, | 490 | HID_REQ_SET_REPORT, |
456 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, | 491 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, |
457 | radio->buf[0], 2, | 492 | report[0], 2, |
458 | radio->buf, size, usb_timeout); | 493 | buf, size, usb_timeout); |
494 | if (retval < 0) | ||
495 | printk(KERN_WARNING DRIVER_NAME | ||
496 | ": si470x_set_report: usb_control_msg returned %d\n", | ||
497 | retval); | ||
498 | |||
499 | return retval; | ||
459 | } | 500 | } |
460 | 501 | ||
461 | 502 | ||
@@ -464,13 +505,16 @@ static int si470x_set_report(struct si470x_device *radio, int size) | |||
464 | */ | 505 | */ |
465 | static int si470x_get_register(struct si470x_device *radio, int regnr) | 506 | static int si470x_get_register(struct si470x_device *radio, int regnr) |
466 | { | 507 | { |
508 | unsigned char buf[REGISTER_REPORT_SIZE]; | ||
467 | int retval; | 509 | int retval; |
468 | 510 | ||
469 | radio->buf[0] = REGISTER_REPORT(regnr); | 511 | buf[0] = REGISTER_REPORT(regnr); |
512 | |||
513 | retval = si470x_get_report(radio, (void *) &buf, sizeof(buf)); | ||
470 | 514 | ||
471 | retval = si470x_get_report(radio, REGISTER_REPORT_SIZE); | ||
472 | if (retval >= 0) | 515 | if (retval >= 0) |
473 | radio->registers[regnr] = (radio->buf[1] << 8) | radio->buf[2]; | 516 | radio->registers[regnr] = be16_to_cpu(get_unaligned( |
517 | (unsigned short *) &buf[1])); | ||
474 | 518 | ||
475 | return (retval < 0) ? -EINVAL : 0; | 519 | return (retval < 0) ? -EINVAL : 0; |
476 | } | 520 | } |
@@ -481,13 +525,14 @@ static int si470x_get_register(struct si470x_device *radio, int regnr) | |||
481 | */ | 525 | */ |
482 | static int si470x_set_register(struct si470x_device *radio, int regnr) | 526 | static int si470x_set_register(struct si470x_device *radio, int regnr) |
483 | { | 527 | { |
528 | unsigned char buf[REGISTER_REPORT_SIZE]; | ||
484 | int retval; | 529 | int retval; |
485 | 530 | ||
486 | radio->buf[0] = REGISTER_REPORT(regnr); | 531 | buf[0] = REGISTER_REPORT(regnr); |
487 | radio->buf[1] = (radio->registers[regnr] & 0xff00) >> 8; | 532 | put_unaligned(cpu_to_be16(radio->registers[regnr]), |
488 | radio->buf[2] = (radio->registers[regnr] & 0x00ff); | 533 | (unsigned short *) &buf[1]); |
489 | 534 | ||
490 | retval = si470x_set_report(radio, REGISTER_REPORT_SIZE); | 535 | retval = si470x_set_report(radio, (void *) &buf, sizeof(buf)); |
491 | 536 | ||
492 | return (retval < 0) ? -EINVAL : 0; | 537 | return (retval < 0) ? -EINVAL : 0; |
493 | } | 538 | } |
@@ -498,18 +543,19 @@ static int si470x_set_register(struct si470x_device *radio, int regnr) | |||
498 | */ | 543 | */ |
499 | static int si470x_get_all_registers(struct si470x_device *radio) | 544 | static int si470x_get_all_registers(struct si470x_device *radio) |
500 | { | 545 | { |
546 | unsigned char buf[ENTIRE_REPORT_SIZE]; | ||
501 | int retval; | 547 | int retval; |
502 | int regnr; | 548 | unsigned char regnr; |
503 | 549 | ||
504 | radio->buf[0] = ENTIRE_REPORT; | 550 | buf[0] = ENTIRE_REPORT; |
505 | 551 | ||
506 | retval = si470x_get_report(radio, ENTIRE_REPORT_SIZE); | 552 | retval = si470x_get_report(radio, (void *) &buf, sizeof(buf)); |
507 | 553 | ||
508 | if (retval >= 0) | 554 | if (retval >= 0) |
509 | for (regnr = 0; regnr < RADIO_REGISTER_NUM; regnr++) | 555 | for (regnr = 0; regnr < RADIO_REGISTER_NUM; regnr++) |
510 | radio->registers[regnr] = | 556 | radio->registers[regnr] = be16_to_cpu(get_unaligned( |
511 | (radio->buf[regnr * RADIO_REGISTER_SIZE + 1] << 8) | | 557 | (unsigned short *) |
512 | radio->buf[regnr * RADIO_REGISTER_SIZE + 2]; | 558 | &buf[regnr * RADIO_REGISTER_SIZE + 1])); |
513 | 559 | ||
514 | return (retval < 0) ? -EINVAL : 0; | 560 | return (retval < 0) ? -EINVAL : 0; |
515 | } | 561 | } |
@@ -520,21 +566,28 @@ static int si470x_get_all_registers(struct si470x_device *radio) | |||
520 | */ | 566 | */ |
521 | static int si470x_get_rds_registers(struct si470x_device *radio) | 567 | static int si470x_get_rds_registers(struct si470x_device *radio) |
522 | { | 568 | { |
569 | unsigned char buf[RDS_REPORT_SIZE]; | ||
523 | int retval; | 570 | int retval; |
524 | int regnr; | ||
525 | int size; | 571 | int size; |
572 | unsigned char regnr; | ||
526 | 573 | ||
527 | radio->buf[0] = RDS_REPORT; | 574 | buf[0] = RDS_REPORT; |
528 | 575 | ||
529 | retval = usb_interrupt_msg(radio->usbdev, | 576 | retval = usb_interrupt_msg(radio->usbdev, |
530 | usb_rcvctrlpipe(radio->usbdev, 1), | 577 | usb_rcvintpipe(radio->usbdev, 1), |
531 | radio->buf, RDS_REPORT_SIZE, &size, usb_timeout); | 578 | (void *) &buf, sizeof(buf), &size, usb_timeout); |
579 | if (size != sizeof(buf)) | ||
580 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_register: " | ||
581 | "return size differs: %d != %zu\n", size, sizeof(buf)); | ||
582 | if (retval < 0) | ||
583 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: " | ||
584 | "usb_interrupt_msg returned %d\n", retval); | ||
532 | 585 | ||
533 | if (retval >= 0) | 586 | if (retval >= 0) |
534 | for (regnr = 0; regnr < RDS_REGISTER_NUM; regnr++) | 587 | for (regnr = 0; regnr < RDS_REGISTER_NUM; regnr++) |
535 | radio->registers[STATUSRSSI + regnr] = | 588 | radio->registers[STATUSRSSI + regnr] = |
536 | (radio->buf[regnr * RADIO_REGISTER_SIZE + 1] << 8) | | 589 | be16_to_cpu(get_unaligned((unsigned short *) |
537 | radio->buf[regnr * RADIO_REGISTER_SIZE + 2]; | 590 | &buf[regnr * RADIO_REGISTER_SIZE + 1])); |
538 | 591 | ||
539 | return (retval < 0) ? -EINVAL : 0; | 592 | return (retval < 0) ? -EINVAL : 0; |
540 | } | 593 | } |
@@ -543,9 +596,11 @@ static int si470x_get_rds_registers(struct si470x_device *radio) | |||
543 | /* | 596 | /* |
544 | * si470x_set_chan - set the channel | 597 | * si470x_set_chan - set the channel |
545 | */ | 598 | */ |
546 | static int si470x_set_chan(struct si470x_device *radio, int chan) | 599 | static int si470x_set_chan(struct si470x_device *radio, unsigned short chan) |
547 | { | 600 | { |
548 | int retval, i; | 601 | int retval; |
602 | unsigned long timeout; | ||
603 | bool timed_out = 0; | ||
549 | 604 | ||
550 | /* start tuning */ | 605 | /* start tuning */ |
551 | radio->registers[CHANNEL] &= ~CHANNEL_CHAN; | 606 | radio->registers[CHANNEL] &= ~CHANNEL_CHAN; |
@@ -555,16 +610,17 @@ static int si470x_set_chan(struct si470x_device *radio, int chan) | |||
555 | return retval; | 610 | return retval; |
556 | 611 | ||
557 | /* wait till seek operation has completed */ | 612 | /* wait till seek operation has completed */ |
558 | i = 0; | 613 | timeout = jiffies + msecs_to_jiffies(tune_timeout); |
559 | do { | 614 | do { |
560 | retval = si470x_get_register(radio, STATUSRSSI); | 615 | retval = si470x_get_register(radio, STATUSRSSI); |
561 | if (retval < 0) | 616 | if (retval < 0) |
562 | return retval; | 617 | return retval; |
563 | } while ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) && | 618 | timed_out = time_after(jiffies, timeout); |
564 | (++i < seek_retries)); | 619 | } while (((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) && |
565 | if (i >= seek_retries) | 620 | (!timed_out)); |
621 | if (timed_out) | ||
566 | printk(KERN_WARNING DRIVER_NAME | 622 | printk(KERN_WARNING DRIVER_NAME |
567 | ": seek does not finish after %d tries\n", i); | 623 | ": seek does not finish after %u ms\n", tune_timeout); |
568 | 624 | ||
569 | /* stop tuning */ | 625 | /* stop tuning */ |
570 | radio->registers[CHANNEL] &= ~CHANNEL_TUNE; | 626 | radio->registers[CHANNEL] &= ~CHANNEL_TUNE; |
@@ -575,9 +631,10 @@ static int si470x_set_chan(struct si470x_device *radio, int chan) | |||
575 | /* | 631 | /* |
576 | * si470x_get_freq - get the frequency | 632 | * si470x_get_freq - get the frequency |
577 | */ | 633 | */ |
578 | static int si470x_get_freq(struct si470x_device *radio) | 634 | static unsigned int si470x_get_freq(struct si470x_device *radio) |
579 | { | 635 | { |
580 | int spacing, band_bottom, chan, freq; | 636 | unsigned int spacing, band_bottom, freq; |
637 | unsigned short chan; | ||
581 | int retval; | 638 | int retval; |
582 | 639 | ||
583 | /* Spacing (kHz) */ | 640 | /* Spacing (kHz) */ |
@@ -616,9 +673,10 @@ static int si470x_get_freq(struct si470x_device *radio) | |||
616 | /* | 673 | /* |
617 | * si470x_set_freq - set the frequency | 674 | * si470x_set_freq - set the frequency |
618 | */ | 675 | */ |
619 | static int si470x_set_freq(struct si470x_device *radio, int freq) | 676 | static int si470x_set_freq(struct si470x_device *radio, unsigned int freq) |
620 | { | 677 | { |
621 | int spacing, band_bottom, chan; | 678 | unsigned int spacing, band_bottom; |
679 | unsigned short chan; | ||
622 | 680 | ||
623 | /* Spacing (kHz) */ | 681 | /* Spacing (kHz) */ |
624 | switch (space) { | 682 | switch (space) { |
@@ -709,9 +767,17 @@ static int si470x_stop(struct si470x_device *radio) | |||
709 | */ | 767 | */ |
710 | static int si470x_rds_on(struct si470x_device *radio) | 768 | static int si470x_rds_on(struct si470x_device *radio) |
711 | { | 769 | { |
770 | int retval; | ||
771 | |||
712 | /* sysconfig 1 */ | 772 | /* sysconfig 1 */ |
773 | mutex_lock(&radio->lock); | ||
713 | radio->registers[SYSCONFIG1] |= SYSCONFIG1_RDS; | 774 | radio->registers[SYSCONFIG1] |= SYSCONFIG1_RDS; |
714 | return si470x_set_register(radio, SYSCONFIG1); | 775 | retval = si470x_set_register(radio, SYSCONFIG1); |
776 | if (retval < 0) | ||
777 | radio->registers[SYSCONFIG1] &= ~SYSCONFIG1_RDS; | ||
778 | mutex_unlock(&radio->lock); | ||
779 | |||
780 | return retval; | ||
715 | } | 781 | } |
716 | 782 | ||
717 | 783 | ||
@@ -725,11 +791,10 @@ static int si470x_rds_on(struct si470x_device *radio) | |||
725 | */ | 791 | */ |
726 | static void si470x_rds(struct si470x_device *radio) | 792 | static void si470x_rds(struct si470x_device *radio) |
727 | { | 793 | { |
728 | unsigned char tmpbuf[3]; | ||
729 | unsigned char blocknum; | 794 | unsigned char blocknum; |
730 | unsigned char bler; /* rds block errors */ | 795 | unsigned short bler; /* rds block errors */ |
731 | unsigned short rds; | 796 | unsigned short rds; |
732 | unsigned int i; | 797 | unsigned char tmpbuf[3]; |
733 | 798 | ||
734 | /* get rds blocks */ | 799 | /* get rds blocks */ |
735 | if (si470x_get_rds_registers(radio) < 0) | 800 | if (si470x_get_rds_registers(radio) < 0) |
@@ -743,63 +808,58 @@ static void si470x_rds(struct si470x_device *radio) | |||
743 | return; | 808 | return; |
744 | } | 809 | } |
745 | 810 | ||
746 | /* copy four RDS blocks to internal buffer */ | 811 | /* copy all four RDS blocks to internal buffer */ |
747 | if (spin_trylock(&radio->lock)) { | 812 | mutex_lock(&radio->lock); |
748 | /* process each rds block */ | 813 | for (blocknum = 0; blocknum < 4; blocknum++) { |
749 | for (blocknum = 0; blocknum < 4; blocknum++) { | 814 | switch (blocknum) { |
750 | switch (blocknum) { | 815 | default: |
751 | default: | 816 | bler = (radio->registers[STATUSRSSI] & |
752 | bler = (radio->registers[STATUSRSSI] & | 817 | STATUSRSSI_BLERA) >> 9; |
753 | STATUSRSSI_BLERA) >> 9; | 818 | rds = radio->registers[RDSA]; |
754 | rds = radio->registers[RDSA]; | 819 | break; |
755 | break; | 820 | case 1: |
756 | case 1: | 821 | bler = (radio->registers[READCHAN] & |
757 | bler = (radio->registers[READCHAN] & | 822 | READCHAN_BLERB) >> 14; |
758 | READCHAN_BLERB) >> 14; | 823 | rds = radio->registers[RDSB]; |
759 | rds = radio->registers[RDSB]; | 824 | break; |
760 | break; | 825 | case 2: |
761 | case 2: | 826 | bler = (radio->registers[READCHAN] & |
762 | bler = (radio->registers[READCHAN] & | 827 | READCHAN_BLERC) >> 12; |
763 | READCHAN_BLERC) >> 12; | 828 | rds = radio->registers[RDSC]; |
764 | rds = radio->registers[RDSC]; | 829 | break; |
765 | break; | 830 | case 3: |
766 | case 3: | 831 | bler = (radio->registers[READCHAN] & |
767 | bler = (radio->registers[READCHAN] & | 832 | READCHAN_BLERD) >> 10; |
768 | READCHAN_BLERD) >> 10; | 833 | rds = radio->registers[RDSD]; |
769 | rds = radio->registers[RDSD]; | 834 | break; |
770 | break; | 835 | }; |
771 | }; | 836 | |
772 | 837 | /* Fill the V4L2 RDS buffer */ | |
773 | /* Fill the V4L2 RDS buffer */ | 838 | put_unaligned(cpu_to_le16(rds), (unsigned short *) &tmpbuf); |
774 | tmpbuf[0] = rds & 0x00ff; /* LSB */ | 839 | tmpbuf[2] = blocknum; /* offset name */ |
775 | tmpbuf[1] = (rds & 0xff00) >> 8;/* MSB */ | 840 | tmpbuf[2] |= blocknum << 3; /* received offset */ |
776 | tmpbuf[2] = blocknum; /* offset name */ | 841 | if (bler > max_rds_errors) |
777 | tmpbuf[2] |= blocknum << 3; /* received offset */ | 842 | tmpbuf[2] |= 0x80; /* uncorrectable errors */ |
778 | if (bler > max_rds_errors) | 843 | else if (bler > 0) |
779 | tmpbuf[2] |= 0x80; /* uncorrectable errors */ | 844 | tmpbuf[2] |= 0x40; /* corrected error(s) */ |
780 | else if (bler > 0) | 845 | |
781 | tmpbuf[2] |= 0x40; /* corrected error(s) */ | 846 | /* copy RDS block to internal buffer */ |
782 | 847 | memcpy(&radio->buffer[radio->wr_index], &tmpbuf, 3); | |
783 | /* copy RDS block to internal buffer */ | 848 | radio->wr_index += 3; |
784 | for (i = 0; i < 3; i++) { | 849 | |
785 | radio->buffer[radio->wr_index] = tmpbuf[i]; | 850 | /* wrap write pointer */ |
786 | radio->wr_index++; | 851 | if (radio->wr_index >= radio->buf_size) |
787 | } | 852 | radio->wr_index = 0; |
788 | 853 | ||
789 | /* wrap write pointer */ | 854 | /* check for overflow */ |
790 | if (radio->wr_index >= radio->buf_size) | 855 | if (radio->wr_index == radio->rd_index) { |
791 | radio->wr_index = 0; | 856 | /* increment and wrap read pointer */ |
792 | 857 | radio->rd_index += 3; | |
793 | /* check for overflow */ | 858 | if (radio->rd_index >= radio->buf_size) |
794 | if (radio->wr_index == radio->rd_index) { | 859 | radio->rd_index = 0; |
795 | /* increment and wrap read pointer */ | ||
796 | radio->rd_index += 3; | ||
797 | if (radio->rd_index >= radio->buf_size) | ||
798 | radio->rd_index = 0; | ||
799 | } | ||
800 | } | 860 | } |
801 | spin_unlock(&radio->lock); | ||
802 | } | 861 | } |
862 | mutex_unlock(&radio->lock); | ||
803 | 863 | ||
804 | /* wake up read queue */ | 864 | /* wake up read queue */ |
805 | if (radio->wr_index != radio->rd_index) | 865 | if (radio->wr_index != radio->rd_index) |
@@ -808,29 +868,18 @@ static void si470x_rds(struct si470x_device *radio) | |||
808 | 868 | ||
809 | 869 | ||
810 | /* | 870 | /* |
811 | * si470x_timer - rds timer function | ||
812 | */ | ||
813 | static void si470x_timer(unsigned long data) | ||
814 | { | ||
815 | struct si470x_device *radio = (struct si470x_device *) data; | ||
816 | |||
817 | schedule_work(&radio->work); | ||
818 | } | ||
819 | |||
820 | |||
821 | /* | ||
822 | * si470x_work - rds work function | 871 | * si470x_work - rds work function |
823 | */ | 872 | */ |
824 | static void si470x_work(struct work_struct *work) | 873 | static void si470x_work(struct work_struct *work) |
825 | { | 874 | { |
826 | struct si470x_device *radio = container_of(work, struct si470x_device, | 875 | struct si470x_device *radio = container_of(work, struct si470x_device, |
827 | work); | 876 | work.work); |
828 | 877 | ||
829 | if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) | 878 | if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) |
830 | return; | 879 | return; |
831 | 880 | ||
832 | si470x_rds(radio); | 881 | si470x_rds(radio); |
833 | mod_timer(&radio->timer, jiffies + msecs_to_jiffies(rds_poll_time)); | 882 | schedule_delayed_work(&radio->work, msecs_to_jiffies(rds_poll_time)); |
834 | } | 883 | } |
835 | 884 | ||
836 | 885 | ||
@@ -852,44 +901,44 @@ static ssize_t si470x_fops_read(struct file *file, char __user *buf, | |||
852 | /* switch on rds reception */ | 901 | /* switch on rds reception */ |
853 | if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) { | 902 | if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) { |
854 | si470x_rds_on(radio); | 903 | si470x_rds_on(radio); |
855 | schedule_work(&radio->work); | 904 | schedule_delayed_work(&radio->work, |
905 | msecs_to_jiffies(rds_poll_time)); | ||
856 | } | 906 | } |
857 | 907 | ||
858 | /* block if no new data available */ | 908 | /* block if no new data available */ |
859 | while (radio->wr_index == radio->rd_index) { | 909 | while (radio->wr_index == radio->rd_index) { |
860 | if (file->f_flags & O_NONBLOCK) | 910 | if (file->f_flags & O_NONBLOCK) |
861 | return -EWOULDBLOCK; | 911 | return -EWOULDBLOCK; |
862 | interruptible_sleep_on(&radio->read_queue); | 912 | if (wait_event_interruptible(radio->read_queue, |
913 | radio->wr_index != radio->rd_index) < 0) | ||
914 | return -EINTR; | ||
863 | } | 915 | } |
864 | 916 | ||
865 | /* calculate block count from byte count */ | 917 | /* calculate block count from byte count */ |
866 | count /= 3; | 918 | count /= 3; |
867 | 919 | ||
868 | /* copy RDS block out of internal buffer and to user buffer */ | 920 | /* copy RDS block out of internal buffer and to user buffer */ |
869 | if (spin_trylock(&radio->lock)) { | 921 | mutex_lock(&radio->lock); |
870 | while (block_count < count) { | 922 | while (block_count < count) { |
871 | if (radio->rd_index == radio->wr_index) | 923 | if (radio->rd_index == radio->wr_index) |
872 | break; | 924 | break; |
873 | 925 | ||
874 | /* always transfer rds complete blocks */ | 926 | /* always transfer rds complete blocks */ |
875 | if (copy_to_user(buf, | 927 | if (copy_to_user(buf, &radio->buffer[radio->rd_index], 3)) |
876 | &radio->buffer[radio->rd_index], 3)) | 928 | /* retval = -EFAULT; */ |
877 | /* retval = -EFAULT; */ | 929 | break; |
878 | break; | 930 | |
879 | 931 | /* increment and wrap read pointer */ | |
880 | /* increment and wrap read pointer */ | 932 | radio->rd_index += 3; |
881 | radio->rd_index += 3; | 933 | if (radio->rd_index >= radio->buf_size) |
882 | if (radio->rd_index >= radio->buf_size) | 934 | radio->rd_index = 0; |
883 | radio->rd_index = 0; | 935 | |
884 | 936 | /* increment counters */ | |
885 | /* increment counters */ | 937 | block_count++; |
886 | block_count++; | 938 | buf += 3; |
887 | buf += 3; | 939 | retval += 3; |
888 | retval += 3; | ||
889 | } | ||
890 | |||
891 | spin_unlock(&radio->lock); | ||
892 | } | 940 | } |
941 | mutex_unlock(&radio->lock); | ||
893 | 942 | ||
894 | return retval; | 943 | return retval; |
895 | } | 944 | } |
@@ -906,7 +955,8 @@ static unsigned int si470x_fops_poll(struct file *file, | |||
906 | /* switch on rds reception */ | 955 | /* switch on rds reception */ |
907 | if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) { | 956 | if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) { |
908 | si470x_rds_on(radio); | 957 | si470x_rds_on(radio); |
909 | schedule_work(&radio->work); | 958 | schedule_delayed_work(&radio->work, |
959 | msecs_to_jiffies(rds_poll_time)); | ||
910 | } | 960 | } |
911 | 961 | ||
912 | poll_wait(file, &radio->read_queue, pts); | 962 | poll_wait(file, &radio->read_queue, pts); |
@@ -924,10 +974,22 @@ static unsigned int si470x_fops_poll(struct file *file, | |||
924 | static int si470x_fops_open(struct inode *inode, struct file *file) | 974 | static int si470x_fops_open(struct inode *inode, struct file *file) |
925 | { | 975 | { |
926 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 976 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
977 | int retval; | ||
927 | 978 | ||
928 | radio->users++; | 979 | radio->users++; |
929 | if (radio->users == 1) | 980 | |
930 | return si470x_start(radio); | 981 | retval = usb_autopm_get_interface(radio->intf); |
982 | if (retval < 0) { | ||
983 | radio->users--; | ||
984 | return -EIO; | ||
985 | } | ||
986 | |||
987 | if (radio->users == 1) { | ||
988 | retval = si470x_start(radio); | ||
989 | if (retval < 0) | ||
990 | usb_autopm_put_interface(radio->intf); | ||
991 | return retval; | ||
992 | } | ||
931 | 993 | ||
932 | return 0; | 994 | return 0; |
933 | } | 995 | } |
@@ -939,6 +1001,7 @@ static int si470x_fops_open(struct inode *inode, struct file *file) | |||
939 | static int si470x_fops_release(struct inode *inode, struct file *file) | 1001 | static int si470x_fops_release(struct inode *inode, struct file *file) |
940 | { | 1002 | { |
941 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1003 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
1004 | int retval; | ||
942 | 1005 | ||
943 | if (!radio) | 1006 | if (!radio) |
944 | return -ENODEV; | 1007 | return -ENODEV; |
@@ -946,13 +1009,14 @@ static int si470x_fops_release(struct inode *inode, struct file *file) | |||
946 | radio->users--; | 1009 | radio->users--; |
947 | if (radio->users == 0) { | 1010 | if (radio->users == 0) { |
948 | /* stop rds reception */ | 1011 | /* stop rds reception */ |
949 | del_timer_sync(&radio->timer); | 1012 | cancel_delayed_work_sync(&radio->work); |
950 | flush_scheduled_work(); | ||
951 | 1013 | ||
952 | /* cancel read processes */ | 1014 | /* cancel read processes */ |
953 | wake_up_interruptible(&radio->read_queue); | 1015 | wake_up_interruptible(&radio->read_queue); |
954 | 1016 | ||
955 | return si470x_stop(radio); | 1017 | retval = si470x_stop(radio); |
1018 | usb_autopm_put_interface(radio->intf); | ||
1019 | return retval; | ||
956 | } | 1020 | } |
957 | 1021 | ||
958 | return 0; | 1022 | return 0; |
@@ -1030,7 +1094,7 @@ static int si470x_vidioc_querycap(struct file *file, void *priv, | |||
1030 | strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver)); | 1094 | strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver)); |
1031 | strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card)); | 1095 | strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card)); |
1032 | sprintf(capability->bus_info, "USB"); | 1096 | sprintf(capability->bus_info, "USB"); |
1033 | capability->version = DRIVER_VERSION; | 1097 | capability->version = DRIVER_KERNEL_VERSION; |
1034 | capability->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; | 1098 | capability->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; |
1035 | 1099 | ||
1036 | return 0; | 1100 | return 0; |
@@ -1067,16 +1131,21 @@ static int si470x_vidioc_s_input(struct file *filp, void *priv, unsigned int i) | |||
1067 | static int si470x_vidioc_queryctrl(struct file *file, void *priv, | 1131 | static int si470x_vidioc_queryctrl(struct file *file, void *priv, |
1068 | struct v4l2_queryctrl *qc) | 1132 | struct v4l2_queryctrl *qc) |
1069 | { | 1133 | { |
1070 | int i; | 1134 | unsigned char i; |
1135 | int retval = -EINVAL; | ||
1071 | 1136 | ||
1072 | for (i = 0; i < ARRAY_SIZE(si470x_v4l2_queryctrl); i++) { | 1137 | for (i = 0; i < ARRAY_SIZE(si470x_v4l2_queryctrl); i++) { |
1073 | if (qc->id && qc->id == si470x_v4l2_queryctrl[i].id) { | 1138 | if (qc->id && qc->id == si470x_v4l2_queryctrl[i].id) { |
1074 | memcpy(qc, &(si470x_v4l2_queryctrl[i]), sizeof(*qc)); | 1139 | memcpy(qc, &(si470x_v4l2_queryctrl[i]), sizeof(*qc)); |
1075 | return 0; | 1140 | retval = 0; |
1141 | break; | ||
1076 | } | 1142 | } |
1077 | } | 1143 | } |
1144 | if (retval < 0) | ||
1145 | printk(KERN_WARNING DRIVER_NAME | ||
1146 | ": query control failed with %d\n", retval); | ||
1078 | 1147 | ||
1079 | return -EINVAL; | 1148 | return retval; |
1080 | } | 1149 | } |
1081 | 1150 | ||
1082 | 1151 | ||
@@ -1110,21 +1179,29 @@ static int si470x_vidioc_s_ctrl(struct file *file, void *priv, | |||
1110 | struct v4l2_control *ctrl) | 1179 | struct v4l2_control *ctrl) |
1111 | { | 1180 | { |
1112 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1181 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
1182 | int retval; | ||
1113 | 1183 | ||
1114 | switch (ctrl->id) { | 1184 | switch (ctrl->id) { |
1115 | case V4L2_CID_AUDIO_VOLUME: | 1185 | case V4L2_CID_AUDIO_VOLUME: |
1116 | radio->registers[SYSCONFIG2] &= ~SYSCONFIG2_VOLUME; | 1186 | radio->registers[SYSCONFIG2] &= ~SYSCONFIG2_VOLUME; |
1117 | radio->registers[SYSCONFIG2] |= ctrl->value; | 1187 | radio->registers[SYSCONFIG2] |= ctrl->value; |
1118 | return si470x_set_register(radio, SYSCONFIG2); | 1188 | retval = si470x_set_register(radio, SYSCONFIG2); |
1189 | break; | ||
1119 | case V4L2_CID_AUDIO_MUTE: | 1190 | case V4L2_CID_AUDIO_MUTE: |
1120 | if (ctrl->value == 1) | 1191 | if (ctrl->value == 1) |
1121 | radio->registers[POWERCFG] &= ~POWERCFG_DMUTE; | 1192 | radio->registers[POWERCFG] &= ~POWERCFG_DMUTE; |
1122 | else | 1193 | else |
1123 | radio->registers[POWERCFG] |= POWERCFG_DMUTE; | 1194 | radio->registers[POWERCFG] |= POWERCFG_DMUTE; |
1124 | return si470x_set_register(radio, POWERCFG); | 1195 | retval = si470x_set_register(radio, POWERCFG); |
1196 | break; | ||
1197 | default: | ||
1198 | retval = -EINVAL; | ||
1125 | } | 1199 | } |
1200 | if (retval < 0) | ||
1201 | printk(KERN_WARNING DRIVER_NAME | ||
1202 | ": set control failed with %d\n", retval); | ||
1126 | 1203 | ||
1127 | return -EINVAL; | 1204 | return retval; |
1128 | } | 1205 | } |
1129 | 1206 | ||
1130 | 1207 | ||
@@ -1163,8 +1240,8 @@ static int si470x_vidioc_s_audio(struct file *file, void *priv, | |||
1163 | static int si470x_vidioc_g_tuner(struct file *file, void *priv, | 1240 | static int si470x_vidioc_g_tuner(struct file *file, void *priv, |
1164 | struct v4l2_tuner *tuner) | 1241 | struct v4l2_tuner *tuner) |
1165 | { | 1242 | { |
1166 | int retval; | ||
1167 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1243 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
1244 | int retval; | ||
1168 | 1245 | ||
1169 | if (tuner->index > 0) | 1246 | if (tuner->index > 0) |
1170 | return -EINVAL; | 1247 | return -EINVAL; |
@@ -1220,6 +1297,7 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv, | |||
1220 | struct v4l2_tuner *tuner) | 1297 | struct v4l2_tuner *tuner) |
1221 | { | 1298 | { |
1222 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1299 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
1300 | int retval; | ||
1223 | 1301 | ||
1224 | if (tuner->index > 0) | 1302 | if (tuner->index > 0) |
1225 | return -EINVAL; | 1303 | return -EINVAL; |
@@ -1229,7 +1307,12 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv, | |||
1229 | else | 1307 | else |
1230 | radio->registers[POWERCFG] &= ~POWERCFG_MONO; /* try stereo */ | 1308 | radio->registers[POWERCFG] &= ~POWERCFG_MONO; /* try stereo */ |
1231 | 1309 | ||
1232 | return si470x_set_register(radio, POWERCFG); | 1310 | retval = si470x_set_register(radio, POWERCFG); |
1311 | if (retval < 0) | ||
1312 | printk(KERN_WARNING DRIVER_NAME | ||
1313 | ": set tuner failed with %d\n", retval); | ||
1314 | |||
1315 | return retval; | ||
1233 | } | 1316 | } |
1234 | 1317 | ||
1235 | 1318 | ||
@@ -1255,11 +1338,17 @@ static int si470x_vidioc_s_frequency(struct file *file, void *priv, | |||
1255 | struct v4l2_frequency *freq) | 1338 | struct v4l2_frequency *freq) |
1256 | { | 1339 | { |
1257 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1340 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
1341 | int retval; | ||
1258 | 1342 | ||
1259 | if (freq->type != V4L2_TUNER_RADIO) | 1343 | if (freq->type != V4L2_TUNER_RADIO) |
1260 | return -EINVAL; | 1344 | return -EINVAL; |
1261 | 1345 | ||
1262 | return si470x_set_freq(radio, freq->frequency); | 1346 | retval = si470x_set_freq(radio, freq->frequency); |
1347 | if (retval < 0) | ||
1348 | printk(KERN_WARNING DRIVER_NAME | ||
1349 | ": set frequency failed with %d\n", retval); | ||
1350 | |||
1351 | return 0; | ||
1263 | } | 1352 | } |
1264 | 1353 | ||
1265 | 1354 | ||
@@ -1299,71 +1388,116 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, | |||
1299 | const struct usb_device_id *id) | 1388 | const struct usb_device_id *id) |
1300 | { | 1389 | { |
1301 | struct si470x_device *radio; | 1390 | struct si470x_device *radio; |
1391 | int retval = -ENOMEM; | ||
1302 | 1392 | ||
1303 | /* memory and interface allocations */ | 1393 | /* private data allocation */ |
1304 | radio = kmalloc(sizeof(struct si470x_device), GFP_KERNEL); | 1394 | radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL); |
1305 | if (!radio) | 1395 | if (!radio) |
1306 | return -ENOMEM; | 1396 | goto err_initial; |
1397 | |||
1398 | /* video device allocation */ | ||
1307 | radio->videodev = video_device_alloc(); | 1399 | radio->videodev = video_device_alloc(); |
1308 | if (!radio->videodev) { | 1400 | if (!radio->videodev) |
1309 | kfree(radio); | 1401 | goto err_radio; |
1310 | return -ENOMEM; | 1402 | |
1311 | } | 1403 | /* initial configuration */ |
1312 | memcpy(radio->videodev, &si470x_viddev_template, | 1404 | memcpy(radio->videodev, &si470x_viddev_template, |
1313 | sizeof(si470x_viddev_template)); | 1405 | sizeof(si470x_viddev_template)); |
1314 | radio->users = 0; | 1406 | radio->users = 0; |
1315 | radio->usbdev = interface_to_usbdev(intf); | 1407 | radio->usbdev = interface_to_usbdev(intf); |
1408 | radio->intf = intf; | ||
1409 | mutex_init(&radio->lock); | ||
1316 | video_set_drvdata(radio->videodev, radio); | 1410 | video_set_drvdata(radio->videodev, radio); |
1317 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr)) { | ||
1318 | printk(KERN_WARNING DRIVER_NAME | ||
1319 | ": Could not register video device\n"); | ||
1320 | video_device_release(radio->videodev); | ||
1321 | kfree(radio); | ||
1322 | return -EIO; | ||
1323 | } | ||
1324 | usb_set_intfdata(intf, radio); | ||
1325 | 1411 | ||
1326 | /* show some infos about the specific device */ | 1412 | /* show some infos about the specific device */ |
1327 | if (si470x_get_all_registers(radio) < 0) { | 1413 | retval = -EIO; |
1328 | video_device_release(radio->videodev); | 1414 | if (si470x_get_all_registers(radio) < 0) |
1329 | kfree(radio); | 1415 | goto err_all; |
1330 | return -EIO; | 1416 | printk(KERN_INFO DRIVER_NAME ": DeviceID=0x%4.4hx ChipID=0x%4.4hx\n", |
1331 | } | ||
1332 | printk(KERN_INFO DRIVER_NAME ": DeviceID=0x%4.4x ChipID=0x%4.4x\n", | ||
1333 | radio->registers[DEVICEID], radio->registers[CHIPID]); | 1417 | radio->registers[DEVICEID], radio->registers[CHIPID]); |
1334 | 1418 | ||
1335 | /* check if firmware is current */ | 1419 | /* check if firmware is current */ |
1336 | if ((radio->registers[CHIPID] & CHIPID_FIRMWARE) | 1420 | if ((radio->registers[CHIPID] & CHIPID_FIRMWARE) |
1337 | < RADIO_SW_VERSION_CURRENT) | 1421 | < RADIO_SW_VERSION_CURRENT) { |
1422 | printk(KERN_WARNING DRIVER_NAME | ||
1423 | ": This driver is known to work with " | ||
1424 | "firmware version %hu,\n", RADIO_SW_VERSION_CURRENT); | ||
1425 | printk(KERN_WARNING DRIVER_NAME | ||
1426 | ": but the device has firmware version %hu.\n", | ||
1427 | radio->registers[CHIPID] & CHIPID_FIRMWARE); | ||
1428 | printk(KERN_WARNING DRIVER_NAME | ||
1429 | ": If you have some trouble using this driver,\n"); | ||
1338 | printk(KERN_WARNING DRIVER_NAME | 1430 | printk(KERN_WARNING DRIVER_NAME |
1339 | ": This driver is known to work with chip version %d, " | 1431 | ": please report to V4L ML at " |
1340 | "but the device has firmware %d.\n" | 1432 | "video4linux-list@redhat.com\n"); |
1341 | DRIVER_NAME | 1433 | } |
1342 | "If you have some trouble using this driver, please " | ||
1343 | "report to V4L ML at video4linux-list@redhat.com\n", | ||
1344 | radio->registers[CHIPID] & CHIPID_FIRMWARE, | ||
1345 | RADIO_SW_VERSION_CURRENT); | ||
1346 | 1434 | ||
1347 | /* set initial frequency */ | 1435 | /* set initial frequency */ |
1348 | si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */ | 1436 | si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */ |
1349 | 1437 | ||
1350 | /* rds initialization */ | 1438 | /* rds buffer allocation */ |
1351 | radio->buf_size = rds_buf * 3; | 1439 | radio->buf_size = rds_buf * 3; |
1352 | radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); | 1440 | radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); |
1353 | if (!radio->buffer) { | 1441 | if (!radio->buffer) |
1354 | video_device_release(radio->videodev); | 1442 | goto err_all; |
1355 | kfree(radio); | 1443 | |
1356 | return -ENOMEM; | 1444 | /* rds buffer configuration */ |
1357 | } | ||
1358 | radio->wr_index = 0; | 1445 | radio->wr_index = 0; |
1359 | radio->rd_index = 0; | 1446 | radio->rd_index = 0; |
1360 | init_waitqueue_head(&radio->read_queue); | 1447 | init_waitqueue_head(&radio->read_queue); |
1361 | 1448 | ||
1362 | /* prepare polling via eventd */ | 1449 | /* prepare rds work function */ |
1363 | INIT_WORK(&radio->work, si470x_work); | 1450 | INIT_DELAYED_WORK(&radio->work, si470x_work); |
1364 | init_timer(&radio->timer); | 1451 | |
1365 | radio->timer.function = si470x_timer; | 1452 | /* register video device */ |
1366 | radio->timer.data = (unsigned long) radio; | 1453 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr)) { |
1454 | printk(KERN_WARNING DRIVER_NAME | ||
1455 | ": Could not register video device\n"); | ||
1456 | goto err_all; | ||
1457 | } | ||
1458 | usb_set_intfdata(intf, radio); | ||
1459 | |||
1460 | return 0; | ||
1461 | err_all: | ||
1462 | video_device_release(radio->videodev); | ||
1463 | kfree(radio->buffer); | ||
1464 | err_radio: | ||
1465 | kfree(radio); | ||
1466 | err_initial: | ||
1467 | return retval; | ||
1468 | } | ||
1469 | |||
1470 | |||
1471 | /* | ||
1472 | * si470x_usb_driver_suspend - suspend the device | ||
1473 | */ | ||
1474 | static int si470x_usb_driver_suspend(struct usb_interface *intf, | ||
1475 | pm_message_t message) | ||
1476 | { | ||
1477 | struct si470x_device *radio = usb_get_intfdata(intf); | ||
1478 | |||
1479 | printk(KERN_INFO DRIVER_NAME ": suspending now...\n"); | ||
1480 | |||
1481 | cancel_delayed_work_sync(&radio->work); | ||
1482 | |||
1483 | return 0; | ||
1484 | } | ||
1485 | |||
1486 | |||
1487 | /* | ||
1488 | * si470x_usb_driver_resume - resume the device | ||
1489 | */ | ||
1490 | static int si470x_usb_driver_resume(struct usb_interface *intf) | ||
1491 | { | ||
1492 | struct si470x_device *radio = usb_get_intfdata(intf); | ||
1493 | |||
1494 | printk(KERN_INFO DRIVER_NAME ": resuming now...\n"); | ||
1495 | |||
1496 | mutex_lock(&radio->lock); | ||
1497 | if (radio->users && radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) | ||
1498 | schedule_delayed_work(&radio->work, | ||
1499 | msecs_to_jiffies(rds_poll_time)); | ||
1500 | mutex_unlock(&radio->lock); | ||
1367 | 1501 | ||
1368 | return 0; | 1502 | return 0; |
1369 | } | 1503 | } |
@@ -1376,15 +1510,11 @@ static void si470x_usb_driver_disconnect(struct usb_interface *intf) | |||
1376 | { | 1510 | { |
1377 | struct si470x_device *radio = usb_get_intfdata(intf); | 1511 | struct si470x_device *radio = usb_get_intfdata(intf); |
1378 | 1512 | ||
1379 | del_timer_sync(&radio->timer); | 1513 | cancel_delayed_work_sync(&radio->work); |
1380 | flush_scheduled_work(); | ||
1381 | |||
1382 | usb_set_intfdata(intf, NULL); | 1514 | usb_set_intfdata(intf, NULL); |
1383 | if (radio) { | 1515 | video_unregister_device(radio->videodev); |
1384 | video_unregister_device(radio->videodev); | 1516 | kfree(radio->buffer); |
1385 | kfree(radio->buffer); | 1517 | kfree(radio); |
1386 | kfree(radio); | ||
1387 | } | ||
1388 | } | 1518 | } |
1389 | 1519 | ||
1390 | 1520 | ||
@@ -1392,10 +1522,13 @@ static void si470x_usb_driver_disconnect(struct usb_interface *intf) | |||
1392 | * si470x_usb_driver - usb driver interface | 1522 | * si470x_usb_driver - usb driver interface |
1393 | */ | 1523 | */ |
1394 | static struct usb_driver si470x_usb_driver = { | 1524 | static struct usb_driver si470x_usb_driver = { |
1395 | .name = DRIVER_NAME, | 1525 | .name = DRIVER_NAME, |
1396 | .probe = si470x_usb_driver_probe, | 1526 | .probe = si470x_usb_driver_probe, |
1397 | .disconnect = si470x_usb_driver_disconnect, | 1527 | .disconnect = si470x_usb_driver_disconnect, |
1398 | .id_table = si470x_usb_driver_id_table, | 1528 | .suspend = si470x_usb_driver_suspend, |
1529 | .resume = si470x_usb_driver_resume, | ||
1530 | .id_table = si470x_usb_driver_id_table, | ||
1531 | .supports_autosuspend = 1, | ||
1399 | }; | 1532 | }; |
1400 | 1533 | ||
1401 | 1534 | ||
@@ -1409,7 +1542,7 @@ static struct usb_driver si470x_usb_driver = { | |||
1409 | */ | 1542 | */ |
1410 | static int __init si470x_module_init(void) | 1543 | static int __init si470x_module_init(void) |
1411 | { | 1544 | { |
1412 | printk(KERN_INFO DRIVER_DESC "\n"); | 1545 | printk(KERN_INFO DRIVER_DESC ", Version " DRIVER_VERSION "\n"); |
1413 | return usb_register(&si470x_usb_driver); | 1546 | return usb_register(&si470x_usb_driver); |
1414 | } | 1547 | } |
1415 | 1548 | ||
@@ -1429,4 +1562,4 @@ module_exit(si470x_module_exit); | |||
1429 | MODULE_LICENSE("GPL"); | 1562 | MODULE_LICENSE("GPL"); |
1430 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1563 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1431 | MODULE_DESCRIPTION(DRIVER_DESC); | 1564 | MODULE_DESCRIPTION(DRIVER_DESC); |
1432 | MODULE_VERSION("1.0.4"); | 1565 | MODULE_VERSION(DRIVER_VERSION); |
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index a2e8987a6195..37072a21d8c9 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -4,14 +4,14 @@ | |||
4 | 4 | ||
5 | menuconfig VIDEO_CAPTURE_DRIVERS | 5 | menuconfig VIDEO_CAPTURE_DRIVERS |
6 | bool "Video capture adapters" | 6 | bool "Video capture adapters" |
7 | depends on VIDEO_DEV | 7 | depends on VIDEO_V4L2 |
8 | default y | 8 | default y |
9 | ---help--- | 9 | ---help--- |
10 | Say Y here to enable selecting the video adapters for | 10 | Say Y here to enable selecting the video adapters for |
11 | webcams, analog TV, and hybrid analog/digital TV. | 11 | webcams, analog TV, and hybrid analog/digital TV. |
12 | Some of those devices also supports FM radio. | 12 | Some of those devices also supports FM radio. |
13 | 13 | ||
14 | if VIDEO_CAPTURE_DRIVERS && VIDEO_DEV | 14 | if VIDEO_CAPTURE_DRIVERS && VIDEO_V4L2 |
15 | 15 | ||
16 | config VIDEO_ADV_DEBUG | 16 | config VIDEO_ADV_DEBUG |
17 | bool "Enable advanced debug functionality" | 17 | bool "Enable advanced debug functionality" |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 850b8c6f4577..3f209b32eeac 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -10,8 +10,9 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o | |||
10 | 10 | ||
11 | stkwebcam-objs := stk-webcam.o stk-sensor.o | 11 | stkwebcam-objs := stk-webcam.o stk-sensor.o |
12 | 12 | ||
13 | obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o compat_ioctl32.o \ | 13 | obj-$(CONFIG_VIDEO_DEV) += videodev.o compat_ioctl32.o v4l2-int-device.o |
14 | v4l2-int-device.o | 14 | |
15 | obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o | ||
15 | 16 | ||
16 | ifeq ($(CONFIG_VIDEO_V4L1_COMPAT),y) | 17 | ifeq ($(CONFIG_VIDEO_V4L1_COMPAT),y) |
17 | obj-$(CONFIG_VIDEO_DEV) += v4l1-compat.o | 18 | obj-$(CONFIG_VIDEO_DEV) += v4l1-compat.o |
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index 907dc62c1783..5404fcc5276d 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
@@ -2354,8 +2354,8 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv, | |||
2354 | BUG(); | 2354 | BUG(); |
2355 | } | 2355 | } |
2356 | 2356 | ||
2357 | mutex_lock(&fh->cap.lock); | 2357 | mutex_lock(&fh->cap.vb_lock); |
2358 | kfree(fh->ov.clips); | 2358 | kfree(fh->ov.clips); |
2359 | fh->ov.clips = clips; | 2359 | fh->ov.clips = clips; |
2360 | fh->ov.nclips = n; | 2360 | fh->ov.nclips = n; |
2361 | 2361 | ||
@@ -2376,7 +2376,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv, | |||
2376 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | 2376 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); |
2377 | retval = bttv_switch_overlay(btv,fh,new); | 2377 | retval = bttv_switch_overlay(btv,fh,new); |
2378 | } | 2378 | } |
2379 | mutex_unlock(&fh->cap.lock); | 2379 | mutex_unlock(&fh->cap.vb_lock); |
2380 | return retval; | 2380 | return retval; |
2381 | } | 2381 | } |
2382 | 2382 | ||
@@ -2576,7 +2576,7 @@ static int bttv_s_fmt_cap(struct file *file, void *priv, | |||
2576 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 2576 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
2577 | 2577 | ||
2578 | /* update our state informations */ | 2578 | /* update our state informations */ |
2579 | mutex_lock(&fh->cap.lock); | 2579 | mutex_lock(&fh->cap.vb_lock); |
2580 | fh->fmt = fmt; | 2580 | fh->fmt = fmt; |
2581 | fh->cap.field = f->fmt.pix.field; | 2581 | fh->cap.field = f->fmt.pix.field; |
2582 | fh->cap.last = V4L2_FIELD_NONE; | 2582 | fh->cap.last = V4L2_FIELD_NONE; |
@@ -2585,7 +2585,7 @@ static int bttv_s_fmt_cap(struct file *file, void *priv, | |||
2585 | btv->init.fmt = fmt; | 2585 | btv->init.fmt = fmt; |
2586 | btv->init.width = f->fmt.pix.width; | 2586 | btv->init.width = f->fmt.pix.width; |
2587 | btv->init.height = f->fmt.pix.height; | 2587 | btv->init.height = f->fmt.pix.height; |
2588 | mutex_unlock(&fh->cap.lock); | 2588 | mutex_unlock(&fh->cap.vb_lock); |
2589 | 2589 | ||
2590 | return 0; | 2590 | return 0; |
2591 | } | 2591 | } |
@@ -2611,11 +2611,11 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) | |||
2611 | unsigned int i; | 2611 | unsigned int i; |
2612 | struct bttv_fh *fh = priv; | 2612 | struct bttv_fh *fh = priv; |
2613 | 2613 | ||
2614 | mutex_lock(&fh->cap.lock); | 2614 | mutex_lock(&fh->cap.vb_lock); |
2615 | retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, | 2615 | retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, |
2616 | V4L2_MEMORY_MMAP); | 2616 | V4L2_MEMORY_MMAP); |
2617 | if (retval < 0) { | 2617 | if (retval < 0) { |
2618 | mutex_unlock(&fh->cap.lock); | 2618 | mutex_unlock(&fh->cap.vb_lock); |
2619 | return retval; | 2619 | return retval; |
2620 | } | 2620 | } |
2621 | 2621 | ||
@@ -2627,7 +2627,7 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) | |||
2627 | for (i = 0; i < gbuffers; i++) | 2627 | for (i = 0; i < gbuffers; i++) |
2628 | mbuf->offsets[i] = i * gbufsize; | 2628 | mbuf->offsets[i] = i * gbufsize; |
2629 | 2629 | ||
2630 | mutex_unlock(&fh->cap.lock); | 2630 | mutex_unlock(&fh->cap.vb_lock); |
2631 | return 0; | 2631 | return 0; |
2632 | } | 2632 | } |
2633 | #endif | 2633 | #endif |
@@ -2756,10 +2756,11 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on) | |||
2756 | if (!check_alloc_btres(btv, fh, RESOURCE_OVERLAY)) | 2756 | if (!check_alloc_btres(btv, fh, RESOURCE_OVERLAY)) |
2757 | return -EBUSY; | 2757 | return -EBUSY; |
2758 | 2758 | ||
2759 | mutex_lock(&fh->cap.lock); | 2759 | mutex_lock(&fh->cap.vb_lock); |
2760 | if (on) { | 2760 | if (on) { |
2761 | fh->ov.tvnorm = btv->tvnorm; | 2761 | fh->ov.tvnorm = btv->tvnorm; |
2762 | new = videobuf_pci_alloc(sizeof(*new)); | 2762 | new = videobuf_pci_alloc(sizeof(*new)); |
2763 | new->crop = btv->crop[!!fh->do_crop].rect; | ||
2763 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | 2764 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); |
2764 | } else { | 2765 | } else { |
2765 | new = NULL; | 2766 | new = NULL; |
@@ -2767,7 +2768,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on) | |||
2767 | 2768 | ||
2768 | /* switch over */ | 2769 | /* switch over */ |
2769 | retval = bttv_switch_overlay(btv, fh, new); | 2770 | retval = bttv_switch_overlay(btv, fh, new); |
2770 | mutex_unlock(&fh->cap.lock); | 2771 | mutex_unlock(&fh->cap.vb_lock); |
2771 | return retval; | 2772 | return retval; |
2772 | } | 2773 | } |
2773 | 2774 | ||
@@ -2806,7 +2807,7 @@ static int bttv_s_fbuf(struct file *file, void *f, | |||
2806 | } | 2807 | } |
2807 | 2808 | ||
2808 | /* ok, accept it */ | 2809 | /* ok, accept it */ |
2809 | mutex_lock(&fh->cap.lock); | 2810 | mutex_lock(&fh->cap.vb_lock); |
2810 | btv->fbuf.base = fb->base; | 2811 | btv->fbuf.base = fb->base; |
2811 | btv->fbuf.fmt.width = fb->fmt.width; | 2812 | btv->fbuf.fmt.width = fb->fmt.width; |
2812 | btv->fbuf.fmt.height = fb->fmt.height; | 2813 | btv->fbuf.fmt.height = fb->fmt.height; |
@@ -2838,7 +2839,7 @@ static int bttv_s_fbuf(struct file *file, void *f, | |||
2838 | retval = bttv_switch_overlay(btv, fh, new); | 2839 | retval = bttv_switch_overlay(btv, fh, new); |
2839 | } | 2840 | } |
2840 | } | 2841 | } |
2841 | mutex_unlock(&fh->cap.lock); | 2842 | mutex_unlock(&fh->cap.vb_lock); |
2842 | return retval; | 2843 | return retval; |
2843 | } | 2844 | } |
2844 | 2845 | ||
@@ -3090,7 +3091,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop) | |||
3090 | 3091 | ||
3091 | fh->do_crop = 1; | 3092 | fh->do_crop = 1; |
3092 | 3093 | ||
3093 | mutex_lock(&fh->cap.lock); | 3094 | mutex_lock(&fh->cap.vb_lock); |
3094 | 3095 | ||
3095 | if (fh->width < c.min_scaled_width) { | 3096 | if (fh->width < c.min_scaled_width) { |
3096 | fh->width = c.min_scaled_width; | 3097 | fh->width = c.min_scaled_width; |
@@ -3108,7 +3109,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop) | |||
3108 | btv->init.height = c.max_scaled_height; | 3109 | btv->init.height = c.max_scaled_height; |
3109 | } | 3110 | } |
3110 | 3111 | ||
3111 | mutex_unlock(&fh->cap.lock); | 3112 | mutex_unlock(&fh->cap.vb_lock); |
3112 | 3113 | ||
3113 | return 0; | 3114 | return 0; |
3114 | } | 3115 | } |
@@ -3177,30 +3178,25 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) | |||
3177 | buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); | 3178 | buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); |
3178 | } else { | 3179 | } else { |
3179 | /* read() capture */ | 3180 | /* read() capture */ |
3180 | mutex_lock(&fh->cap.lock); | 3181 | mutex_lock(&fh->cap.vb_lock); |
3181 | if (NULL == fh->cap.read_buf) { | 3182 | if (NULL == fh->cap.read_buf) { |
3182 | /* need to capture a new frame */ | 3183 | /* need to capture a new frame */ |
3183 | if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) { | 3184 | if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) |
3184 | mutex_unlock(&fh->cap.lock); | 3185 | goto err; |
3185 | return POLLERR; | ||
3186 | } | ||
3187 | fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize); | 3186 | fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize); |
3188 | if (NULL == fh->cap.read_buf) { | 3187 | if (NULL == fh->cap.read_buf) |
3189 | mutex_unlock(&fh->cap.lock); | 3188 | goto err; |
3190 | return POLLERR; | ||
3191 | } | ||
3192 | fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; | 3189 | fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; |
3193 | field = videobuf_next_field(&fh->cap); | 3190 | field = videobuf_next_field(&fh->cap); |
3194 | if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { | 3191 | if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { |
3195 | kfree (fh->cap.read_buf); | 3192 | kfree (fh->cap.read_buf); |
3196 | fh->cap.read_buf = NULL; | 3193 | fh->cap.read_buf = NULL; |
3197 | mutex_unlock(&fh->cap.lock); | 3194 | goto err; |
3198 | return POLLERR; | ||
3199 | } | 3195 | } |
3200 | fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); | 3196 | fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); |
3201 | fh->cap.read_off = 0; | 3197 | fh->cap.read_off = 0; |
3202 | } | 3198 | } |
3203 | mutex_unlock(&fh->cap.lock); | 3199 | mutex_unlock(&fh->cap.vb_lock); |
3204 | buf = (struct bttv_buffer*)fh->cap.read_buf; | 3200 | buf = (struct bttv_buffer*)fh->cap.read_buf; |
3205 | } | 3201 | } |
3206 | 3202 | ||
@@ -3209,6 +3205,9 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) | |||
3209 | buf->vb.state == VIDEOBUF_ERROR) | 3205 | buf->vb.state == VIDEOBUF_ERROR) |
3210 | return POLLIN|POLLRDNORM; | 3206 | return POLLIN|POLLRDNORM; |
3211 | return 0; | 3207 | return 0; |
3208 | err: | ||
3209 | mutex_unlock(&fh->cap.vb_lock); | ||
3210 | return POLLERR; | ||
3212 | } | 3211 | } |
3213 | 3212 | ||
3214 | static int bttv_open(struct inode *inode, struct file *file) | 3213 | static int bttv_open(struct inode *inode, struct file *file) |
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c index 1f0cc79e2a33..75fa82c7c735 100644 --- a/drivers/media/video/bt8xx/bttv-vbi.c +++ b/drivers/media/video/bt8xx/bttv-vbi.c | |||
@@ -352,13 +352,13 @@ int bttv_s_fmt_vbi(struct file *file, void *f, struct v4l2_format *frt) | |||
352 | because vbi_fmt.end counts field lines times two. */ | 352 | because vbi_fmt.end counts field lines times two. */ |
353 | end = max(frt->fmt.vbi.start[0], start1) * 2 + 2; | 353 | end = max(frt->fmt.vbi.start[0], start1) * 2 + 2; |
354 | 354 | ||
355 | mutex_lock(&fh->vbi.lock); | 355 | mutex_lock(&fh->vbi.vb_lock); |
356 | 356 | ||
357 | fh->vbi_fmt.fmt = frt->fmt.vbi; | 357 | fh->vbi_fmt.fmt = frt->fmt.vbi; |
358 | fh->vbi_fmt.tvnorm = tvnorm; | 358 | fh->vbi_fmt.tvnorm = tvnorm; |
359 | fh->vbi_fmt.end = end; | 359 | fh->vbi_fmt.end = end; |
360 | 360 | ||
361 | mutex_unlock(&fh->vbi.lock); | 361 | mutex_unlock(&fh->vbi.vb_lock); |
362 | 362 | ||
363 | rc = 0; | 363 | rc = 0; |
364 | 364 | ||
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index 0aedbeaf94cd..e357f415db06 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
@@ -609,13 +609,19 @@ static int cx8802_request_acquire(struct cx8802_driver *drv) | |||
609 | struct cx88_core *core = drv->core; | 609 | struct cx88_core *core = drv->core; |
610 | 610 | ||
611 | /* Fail a request for hardware if the device is busy. */ | 611 | /* Fail a request for hardware if the device is busy. */ |
612 | if (core->active_type_id != CX88_BOARD_NONE) | 612 | if (core->active_type_id != CX88_BOARD_NONE && |
613 | core->active_type_id != drv->type_id) | ||
613 | return -EBUSY; | 614 | return -EBUSY; |
614 | 615 | ||
615 | if (drv->advise_acquire) | 616 | if (drv->advise_acquire) |
616 | { | 617 | { |
617 | core->active_type_id = drv->type_id; | 618 | mutex_lock(&drv->core->lock); |
618 | drv->advise_acquire(drv); | 619 | core->active_ref++; |
620 | if (core->active_type_id == CX88_BOARD_NONE) { | ||
621 | core->active_type_id = drv->type_id; | ||
622 | drv->advise_acquire(drv); | ||
623 | } | ||
624 | mutex_unlock(&drv->core->lock); | ||
619 | 625 | ||
620 | mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO)); | 626 | mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO)); |
621 | } | 627 | } |
@@ -628,12 +634,14 @@ static int cx8802_request_release(struct cx8802_driver *drv) | |||
628 | { | 634 | { |
629 | struct cx88_core *core = drv->core; | 635 | struct cx88_core *core = drv->core; |
630 | 636 | ||
631 | if (drv->advise_release) | 637 | mutex_lock(&drv->core->lock); |
638 | if (drv->advise_release && --core->active_ref == 0) | ||
632 | { | 639 | { |
633 | drv->advise_release(drv); | 640 | drv->advise_release(drv); |
634 | core->active_type_id = CX88_BOARD_NONE; | 641 | core->active_type_id = CX88_BOARD_NONE; |
635 | mpeg_dbg(1,"%s() Post release GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO)); | 642 | mpeg_dbg(1,"%s() Post release GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO)); |
636 | } | 643 | } |
644 | mutex_unlock(&drv->core->lock); | ||
637 | 645 | ||
638 | return 0; | 646 | return 0; |
639 | } | 647 | } |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 4e823f2a539a..37e6d2e4002f 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -336,6 +336,7 @@ struct cx88_core { | |||
336 | /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ | 336 | /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ |
337 | struct cx8802_dev *dvbdev; | 337 | struct cx8802_dev *dvbdev; |
338 | enum cx88_board_type active_type_id; | 338 | enum cx88_board_type active_type_id; |
339 | int active_ref; | ||
339 | }; | 340 | }; |
340 | 341 | ||
341 | struct cx8800_dev; | 342 | struct cx8800_dev; |
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c index 941357c4f3f5..8c67f678266a 100644 --- a/drivers/media/video/em28xx/em28xx-audio.c +++ b/drivers/media/video/em28xx/em28xx-audio.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/vmalloc.h> | 35 | #include <linux/vmalloc.h> |
36 | #include <linux/proc_fs.h> | 36 | #include <linux/proc_fs.h> |
37 | #include <linux/module.h> | 37 | #include <linux/module.h> |
38 | #include <sound/driver.h> | ||
39 | #include <sound/core.h> | 38 | #include <sound/core.h> |
40 | #include <sound/pcm.h> | 39 | #include <sound/pcm.h> |
41 | #include <sound/pcm_params.h> | 40 | #include <sound/pcm_params.h> |
@@ -270,8 +269,11 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) | |||
270 | dprintk("opening device and trying to acquire exclusive lock\n"); | 269 | dprintk("opening device and trying to acquire exclusive lock\n"); |
271 | 270 | ||
272 | /* Sets volume, mute, etc */ | 271 | /* Sets volume, mute, etc */ |
272 | |||
273 | dev->mute = 0; | 273 | dev->mute = 0; |
274 | mutex_lock(&dev->lock); | ||
274 | ret = em28xx_audio_analog_set(dev); | 275 | ret = em28xx_audio_analog_set(dev); |
276 | mutex_unlock(&dev->lock); | ||
275 | if (ret < 0) | 277 | if (ret < 0) |
276 | goto err; | 278 | goto err; |
277 | 279 | ||
@@ -303,7 +305,9 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) | |||
303 | dprintk("closing device\n"); | 305 | dprintk("closing device\n"); |
304 | 306 | ||
305 | dev->mute = 1; | 307 | dev->mute = 1; |
308 | mutex_lock(&dev->lock); | ||
306 | em28xx_audio_analog_set(dev); | 309 | em28xx_audio_analog_set(dev); |
310 | mutex_unlock(&dev->lock); | ||
307 | 311 | ||
308 | if (dev->adev->users == 0 && dev->adev->shutdown == 1) { | 312 | if (dev->adev->users == 0 && dev->adev->shutdown == 1) { |
309 | dprintk("audio users: %d\n", dev->adev->users); | 313 | dprintk("audio users: %d\n", dev->adev->users); |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 2159d0160df2..aae7753fef11 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -393,15 +393,15 @@ struct em28xx_board em28xx_boards[] = { | |||
393 | .input = { { | 393 | .input = { { |
394 | .type = EM28XX_VMUX_TELEVISION, | 394 | .type = EM28XX_VMUX_TELEVISION, |
395 | .vmux = SAA7115_COMPOSITE2, | 395 | .vmux = SAA7115_COMPOSITE2, |
396 | .amux = 1, | 396 | .amux = EM28XX_AMUX_LINE_IN, |
397 | }, { | 397 | }, { |
398 | .type = EM28XX_VMUX_COMPOSITE1, | 398 | .type = EM28XX_VMUX_COMPOSITE1, |
399 | .vmux = SAA7115_COMPOSITE0, | 399 | .vmux = SAA7115_COMPOSITE0, |
400 | .amux = 1, | 400 | .amux = EM28XX_AMUX_LINE_IN, |
401 | }, { | 401 | }, { |
402 | .type = EM28XX_VMUX_SVIDEO, | 402 | .type = EM28XX_VMUX_SVIDEO, |
403 | .vmux = SAA7115_SVIDEO3, | 403 | .vmux = SAA7115_SVIDEO3, |
404 | .amux = 1, | 404 | .amux = EM28XX_AMUX_LINE_IN, |
405 | } }, | 405 | } }, |
406 | }, | 406 | }, |
407 | }; | 407 | }; |
@@ -441,6 +441,8 @@ struct usb_device_id em28xx_id_table [] = { | |||
441 | .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, | 441 | .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, |
442 | { USB_DEVICE(0x2040, 0x6500), | 442 | { USB_DEVICE(0x2040, 0x6500), |
443 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, | 443 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, |
444 | { USB_DEVICE(0x2040, 0x6502), | ||
445 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, | ||
444 | { USB_DEVICE(0x2040, 0x6513), | 446 | { USB_DEVICE(0x2040, 0x6513), |
445 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, | 447 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, |
446 | { USB_DEVICE(0x0ccd, 0x0042), | 448 | { USB_DEVICE(0x0ccd, 0x0042), |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index f6b78357f0e5..7d1537cab867 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -72,7 +72,8 @@ u32 em28xx_request_buffers(struct em28xx *dev, u32 count) | |||
72 | const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */ | 72 | const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */ |
73 | void *buff = NULL; | 73 | void *buff = NULL; |
74 | u32 i; | 74 | u32 i; |
75 | em28xx_coredbg("requested %i buffers with size %zi", count, imagesize); | 75 | em28xx_coredbg("requested %i buffers with size %zi\n", |
76 | count, imagesize); | ||
76 | if (count > EM28XX_NUM_FRAMES) | 77 | if (count > EM28XX_NUM_FRAMES) |
77 | count = EM28XX_NUM_FRAMES; | 78 | count = EM28XX_NUM_FRAMES; |
78 | 79 | ||
@@ -150,7 +151,7 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, | |||
150 | if (reg_debug){ | 151 | if (reg_debug){ |
151 | printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); | 152 | printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); |
152 | for (byte = 0; byte < len; byte++) { | 153 | for (byte = 0; byte < len; byte++) { |
153 | printk(" %02x", buf[byte]); | 154 | printk(" %02x", (unsigned char)buf[byte]); |
154 | } | 155 | } |
155 | printk("\n"); | 156 | printk("\n"); |
156 | } | 157 | } |
@@ -177,7 +178,8 @@ int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg) | |||
177 | 0x0000, reg, &val, 1, HZ); | 178 | 0x0000, reg, &val, 1, HZ); |
178 | 179 | ||
179 | if (reg_debug) | 180 | if (reg_debug) |
180 | printk(ret < 0 ? " failed!\n" : "%02x\n", val); | 181 | printk(ret < 0 ? " failed!\n" : |
182 | "%02x\n", (unsigned char) val); | ||
181 | 183 | ||
182 | if (ret < 0) | 184 | if (ret < 0) |
183 | return ret; | 185 | return ret; |
@@ -237,7 +239,7 @@ int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len) | |||
237 | * sets only some bits (specified by bitmask) of a register, by first reading | 239 | * sets only some bits (specified by bitmask) of a register, by first reading |
238 | * the actual value | 240 | * the actual value |
239 | */ | 241 | */ |
240 | int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, | 242 | static int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, |
241 | u8 bitmask) | 243 | u8 bitmask) |
242 | { | 244 | { |
243 | int oldval; | 245 | int oldval; |
@@ -254,26 +256,31 @@ int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, | |||
254 | */ | 256 | */ |
255 | static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val) | 257 | static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val) |
256 | { | 258 | { |
257 | int ret; | 259 | int ret, i; |
258 | u8 addr = reg & 0x7f; | 260 | u8 addr = reg & 0x7f; |
259 | if ((ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2)) < 0) | 261 | if ((ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2)) < 0) |
260 | return ret; | 262 | return ret; |
261 | if ((ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0) | 263 | if ((ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0) |
262 | return ret; | 264 | return ret; |
263 | if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0) | 265 | |
264 | return ret; | 266 | /* Wait up to 50 ms for AC97 command to complete */ |
265 | else if (((u8) ret) & 0x01) { | 267 | for (i = 0; i < 10; i++) { |
266 | em28xx_warn ("AC97 command still being executed: not handled properly!\n"); | 268 | if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0) |
269 | return ret; | ||
270 | if (!((u8) ret) & 0x01) | ||
271 | return 0; | ||
272 | msleep(5); | ||
267 | } | 273 | } |
274 | em28xx_warn ("AC97 command still being executed: not handled properly!\n"); | ||
268 | return 0; | 275 | return 0; |
269 | } | 276 | } |
270 | 277 | ||
271 | int em28xx_set_audio_source(struct em28xx *dev) | 278 | static int em28xx_set_audio_source(struct em28xx *dev) |
272 | { | 279 | { |
273 | static char *enable = "\x08\x08"; | 280 | static char *enable = "\x08\x08"; |
274 | static char *disable = "\x08\x88"; | 281 | static char *disable = "\x08\x88"; |
275 | char *video = enable, *line = disable; | 282 | char *video = enable, *line = disable; |
276 | int ret, no_ac97; | 283 | int ret; |
277 | u8 input; | 284 | u8 input; |
278 | 285 | ||
279 | if (dev->is_em2800) { | 286 | if (dev->is_em2800) { |
@@ -293,11 +300,9 @@ int em28xx_set_audio_source(struct em28xx *dev) | |||
293 | switch (dev->ctl_ainput) { | 300 | switch (dev->ctl_ainput) { |
294 | case EM28XX_AMUX_VIDEO: | 301 | case EM28XX_AMUX_VIDEO: |
295 | input = EM28XX_AUDIO_SRC_TUNER; | 302 | input = EM28XX_AUDIO_SRC_TUNER; |
296 | no_ac97 = 1; | ||
297 | break; | 303 | break; |
298 | case EM28XX_AMUX_LINE_IN: | 304 | case EM28XX_AMUX_LINE_IN: |
299 | input = EM28XX_AUDIO_SRC_LINE; | 305 | input = EM28XX_AUDIO_SRC_LINE; |
300 | no_ac97 = 1; | ||
301 | break; | 306 | break; |
302 | case EM28XX_AMUX_AC97_VIDEO: | 307 | case EM28XX_AMUX_AC97_VIDEO: |
303 | input = EM28XX_AUDIO_SRC_LINE; | 308 | input = EM28XX_AUDIO_SRC_LINE; |
@@ -313,12 +318,11 @@ int em28xx_set_audio_source(struct em28xx *dev) | |||
313 | ret = em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0); | 318 | ret = em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0); |
314 | if (ret < 0) | 319 | if (ret < 0) |
315 | return ret; | 320 | return ret; |
321 | msleep(5); | ||
316 | 322 | ||
317 | if (no_ac97) | 323 | /* Sets AC97 mixer registers |
318 | return 0; | 324 | This is seems to be needed, even for non-ac97 configs |
319 | 325 | */ | |
320 | /* Sets AC97 mixer registers */ | ||
321 | |||
322 | ret = em28xx_write_ac97(dev, VIDEO_AC97, video); | 326 | ret = em28xx_write_ac97(dev, VIDEO_AC97, video); |
323 | if (ret < 0) | 327 | if (ret < 0) |
324 | return ret; | 328 | return ret; |
@@ -337,9 +341,10 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
337 | s[0] |= 0x1f - dev->volume; | 341 | s[0] |= 0x1f - dev->volume; |
338 | s[1] |= 0x1f - dev->volume; | 342 | s[1] |= 0x1f - dev->volume; |
339 | 343 | ||
340 | if (dev->mute) | 344 | /* Mute */ |
341 | s[1] |= 0x80; | 345 | s[1] |= 0x80; |
342 | ret = em28xx_write_ac97(dev, MASTER_AC97, s); | 346 | ret = em28xx_write_ac97(dev, MASTER_AC97, s); |
347 | |||
343 | if (ret < 0) | 348 | if (ret < 0) |
344 | return ret; | 349 | return ret; |
345 | 350 | ||
@@ -357,6 +362,11 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
357 | /* Selects the proper audio input */ | 362 | /* Selects the proper audio input */ |
358 | ret = em28xx_set_audio_source(dev); | 363 | ret = em28xx_set_audio_source(dev); |
359 | 364 | ||
365 | /* Unmute device */ | ||
366 | if (!dev->mute) | ||
367 | s[1] &= ~0x80; | ||
368 | ret = em28xx_write_ac97(dev, MASTER_AC97, s); | ||
369 | |||
360 | return ret; | 370 | return ret; |
361 | } | 371 | } |
362 | EXPORT_SYMBOL_GPL(em28xx_audio_analog_set); | 372 | EXPORT_SYMBOL_GPL(em28xx_audio_analog_set); |
@@ -667,7 +677,7 @@ static void em28xx_isocIrq(struct urb *urb) | |||
667 | continue; | 677 | continue; |
668 | } | 678 | } |
669 | if (urb->iso_frame_desc[i].actual_length > | 679 | if (urb->iso_frame_desc[i].actual_length > |
670 | dev->max_pkt_size) { | 680 | urb->iso_frame_desc[i].length) { |
671 | em28xx_isocdbg("packet bigger than packet size"); | 681 | em28xx_isocdbg("packet bigger than packet size"); |
672 | continue; | 682 | continue; |
673 | } | 683 | } |
@@ -713,8 +723,11 @@ void em28xx_uninit_isoc(struct em28xx *dev) | |||
713 | for (i = 0; i < EM28XX_NUM_BUFS; i++) { | 723 | for (i = 0; i < EM28XX_NUM_BUFS; i++) { |
714 | if (dev->urb[i]) { | 724 | if (dev->urb[i]) { |
715 | usb_kill_urb(dev->urb[i]); | 725 | usb_kill_urb(dev->urb[i]); |
716 | if (dev->transfer_buffer[i]){ | 726 | if (dev->transfer_buffer[i]) { |
717 | usb_buffer_free(dev->udev,(EM28XX_NUM_PACKETS*dev->max_pkt_size),dev->transfer_buffer[i],dev->urb[i]->transfer_dma); | 727 | usb_buffer_free(dev->udev, |
728 | dev->urb[i]->transfer_buffer_length, | ||
729 | dev->transfer_buffer[i], | ||
730 | dev->urb[i]->transfer_dma); | ||
718 | } | 731 | } |
719 | usb_free_urb(dev->urb[i]); | 732 | usb_free_urb(dev->urb[i]); |
720 | } | 733 | } |
@@ -732,7 +745,10 @@ int em28xx_init_isoc(struct em28xx *dev) | |||
732 | { | 745 | { |
733 | /* change interface to 3 which allows the biggest packet sizes */ | 746 | /* change interface to 3 which allows the biggest packet sizes */ |
734 | int i, errCode; | 747 | int i, errCode; |
735 | const int sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size; | 748 | int sb_size; |
749 | |||
750 | em28xx_set_alternate(dev); | ||
751 | sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size; | ||
736 | 752 | ||
737 | /* reset streaming vars */ | 753 | /* reset streaming vars */ |
738 | dev->frame_current = NULL; | 754 | dev->frame_current = NULL; |
@@ -741,7 +757,7 @@ int em28xx_init_isoc(struct em28xx *dev) | |||
741 | /* allocate urbs */ | 757 | /* allocate urbs */ |
742 | for (i = 0; i < EM28XX_NUM_BUFS; i++) { | 758 | for (i = 0; i < EM28XX_NUM_BUFS; i++) { |
743 | struct urb *urb; | 759 | struct urb *urb; |
744 | int j, k; | 760 | int j; |
745 | /* allocate transfer buffer */ | 761 | /* allocate transfer buffer */ |
746 | urb = usb_alloc_urb(EM28XX_NUM_PACKETS, GFP_KERNEL); | 762 | urb = usb_alloc_urb(EM28XX_NUM_PACKETS, GFP_KERNEL); |
747 | if (!urb){ | 763 | if (!urb){ |
@@ -749,7 +765,9 @@ int em28xx_init_isoc(struct em28xx *dev) | |||
749 | em28xx_uninit_isoc(dev); | 765 | em28xx_uninit_isoc(dev); |
750 | return -ENOMEM; | 766 | return -ENOMEM; |
751 | } | 767 | } |
752 | dev->transfer_buffer[i] = usb_buffer_alloc(dev->udev, sb_size, GFP_KERNEL,&urb->transfer_dma); | 768 | dev->transfer_buffer[i] = usb_buffer_alloc(dev->udev, sb_size, |
769 | GFP_KERNEL, | ||
770 | &urb->transfer_dma); | ||
753 | if (!dev->transfer_buffer[i]) { | 771 | if (!dev->transfer_buffer[i]) { |
754 | em28xx_errdev | 772 | em28xx_errdev |
755 | ("unable to allocate %i bytes for transfer buffer %i\n", | 773 | ("unable to allocate %i bytes for transfer buffer %i\n", |
@@ -762,22 +780,22 @@ int em28xx_init_isoc(struct em28xx *dev) | |||
762 | urb->dev = dev->udev; | 780 | urb->dev = dev->udev; |
763 | urb->context = dev; | 781 | urb->context = dev; |
764 | urb->pipe = usb_rcvisocpipe(dev->udev, 0x82); | 782 | urb->pipe = usb_rcvisocpipe(dev->udev, 0x82); |
765 | urb->transfer_flags = URB_ISO_ASAP; | 783 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; |
766 | urb->interval = 1; | 784 | urb->interval = 1; |
767 | urb->transfer_buffer = dev->transfer_buffer[i]; | 785 | urb->transfer_buffer = dev->transfer_buffer[i]; |
768 | urb->complete = em28xx_isocIrq; | 786 | urb->complete = em28xx_isocIrq; |
769 | urb->number_of_packets = EM28XX_NUM_PACKETS; | 787 | urb->number_of_packets = EM28XX_NUM_PACKETS; |
770 | urb->transfer_buffer_length = sb_size; | 788 | urb->transfer_buffer_length = sb_size; |
771 | for (j = k = 0; j < EM28XX_NUM_PACKETS; | 789 | for (j = 0; j < EM28XX_NUM_PACKETS; j++) { |
772 | j++, k += dev->max_pkt_size) { | 790 | urb->iso_frame_desc[j].offset = j * dev->max_pkt_size; |
773 | urb->iso_frame_desc[j].offset = k; | 791 | urb->iso_frame_desc[j].length = dev->max_pkt_size; |
774 | urb->iso_frame_desc[j].length = | ||
775 | dev->max_pkt_size; | ||
776 | } | 792 | } |
777 | dev->urb[i] = urb; | 793 | dev->urb[i] = urb; |
778 | } | 794 | } |
779 | 795 | ||
780 | /* submit urbs */ | 796 | /* submit urbs */ |
797 | em28xx_coredbg("Submitting %d urbs of %d packets (%d each)\n", | ||
798 | EM28XX_NUM_BUFS, EM28XX_NUM_PACKETS, dev->max_pkt_size); | ||
781 | for (i = 0; i < EM28XX_NUM_BUFS; i++) { | 799 | for (i = 0; i < EM28XX_NUM_BUFS; i++) { |
782 | errCode = usb_submit_urb(dev->urb[i], GFP_KERNEL); | 800 | errCode = usb_submit_urb(dev->urb[i], GFP_KERNEL); |
783 | if (errCode) { | 801 | if (errCode) { |
@@ -794,22 +812,31 @@ int em28xx_init_isoc(struct em28xx *dev) | |||
794 | int em28xx_set_alternate(struct em28xx *dev) | 812 | int em28xx_set_alternate(struct em28xx *dev) |
795 | { | 813 | { |
796 | int errCode, prev_alt = dev->alt; | 814 | int errCode, prev_alt = dev->alt; |
797 | dev->alt = alt; | 815 | int i; |
798 | if (dev->alt == 0) { | 816 | unsigned int min_pkt_size = dev->bytesperline+4; |
799 | int i; | 817 | |
800 | for(i=0;i< dev->num_alt; i++) | 818 | /* When image size is bigger than a ceirtain value, |
801 | if(dev->alt_max_pkt_size[i]>dev->alt_max_pkt_size[dev->alt]) | 819 | the frame size should be increased, otherwise, only |
802 | dev->alt=i; | 820 | green screen will be received. |
803 | } | 821 | */ |
822 | if (dev->frame_size > 720*240*2) | ||
823 | min_pkt_size *= 2; | ||
824 | |||
825 | for (i = 0; i < dev->num_alt; i++) | ||
826 | if (dev->alt_max_pkt_size[i] >= min_pkt_size) | ||
827 | break; | ||
828 | dev->alt = i; | ||
804 | 829 | ||
805 | if (dev->alt != prev_alt) { | 830 | if (dev->alt != prev_alt) { |
831 | em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", | ||
832 | min_pkt_size, dev->alt); | ||
806 | dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; | 833 | dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; |
807 | em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", dev->alt, | 834 | em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", |
808 | dev->max_pkt_size); | 835 | dev->alt, dev->max_pkt_size); |
809 | errCode = usb_set_interface(dev->udev, 0, dev->alt); | 836 | errCode = usb_set_interface(dev->udev, 0, dev->alt); |
810 | if (errCode < 0) { | 837 | if (errCode < 0) { |
811 | em28xx_errdev ("cannot change alternate number to %d (error=%i)\n", | 838 | em28xx_errdev ("cannot change alternate number to %d (error=%i)\n", |
812 | dev->alt, errCode); | 839 | dev->alt, errCode); |
813 | return errCode; | 840 | return errCode; |
814 | } | 841 | } |
815 | } | 842 | } |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index a0c334672488..4abe6701a770 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -189,7 +189,7 @@ static void video_mux(struct em28xx *dev, int index) | |||
189 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route); | 189 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route); |
190 | } | 190 | } |
191 | 191 | ||
192 | em28xx_set_audio_source(dev); | 192 | em28xx_audio_analog_set(dev); |
193 | } | 193 | } |
194 | 194 | ||
195 | /* Usage lock check functions */ | 195 | /* Usage lock check functions */ |
@@ -830,6 +830,63 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
830 | return 0; | 830 | return 0; |
831 | } | 831 | } |
832 | 832 | ||
833 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
834 | static int em28xx_reg_len(int reg) | ||
835 | { | ||
836 | switch (reg) { | ||
837 | case AC97LSB_REG: | ||
838 | case HSCALELOW_REG: | ||
839 | case VSCALELOW_REG: | ||
840 | return 2; | ||
841 | default: | ||
842 | return 1; | ||
843 | } | ||
844 | } | ||
845 | |||
846 | static int vidioc_g_register(struct file *file, void *priv, | ||
847 | struct v4l2_register *reg) | ||
848 | { | ||
849 | struct em28xx_fh *fh = priv; | ||
850 | struct em28xx *dev = fh->dev; | ||
851 | int ret; | ||
852 | |||
853 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | ||
854 | return -EINVAL; | ||
855 | |||
856 | if (em28xx_reg_len(reg->reg) == 1) { | ||
857 | ret = em28xx_read_reg(dev, reg->reg); | ||
858 | if (ret < 0) | ||
859 | return ret; | ||
860 | |||
861 | reg->val = ret; | ||
862 | } else { | ||
863 | u64 val = 0; | ||
864 | ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, | ||
865 | reg->reg, (char *)&val, 2); | ||
866 | if (ret < 0) | ||
867 | return ret; | ||
868 | |||
869 | reg->val = cpu_to_le64((__u64)val); | ||
870 | } | ||
871 | |||
872 | return 0; | ||
873 | } | ||
874 | |||
875 | static int vidioc_s_register(struct file *file, void *priv, | ||
876 | struct v4l2_register *reg) | ||
877 | { | ||
878 | struct em28xx_fh *fh = priv; | ||
879 | struct em28xx *dev = fh->dev; | ||
880 | u64 buf; | ||
881 | |||
882 | buf = le64_to_cpu((__u64)reg->val); | ||
883 | |||
884 | return em28xx_write_regs(dev, reg->reg, (char *)&buf, | ||
885 | em28xx_reg_len(reg->reg)); | ||
886 | } | ||
887 | #endif | ||
888 | |||
889 | |||
833 | static int vidioc_cropcap(struct file *file, void *priv, | 890 | static int vidioc_cropcap(struct file *file, void *priv, |
834 | struct v4l2_cropcap *cc) | 891 | struct v4l2_cropcap *cc) |
835 | { | 892 | { |
@@ -1295,8 +1352,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
1295 | filp->private_data = fh; | 1352 | filp->private_data = fh; |
1296 | 1353 | ||
1297 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { | 1354 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { |
1298 | em28xx_set_alternate(dev); | ||
1299 | |||
1300 | dev->width = norm_maxw(dev); | 1355 | dev->width = norm_maxw(dev); |
1301 | dev->height = norm_maxh(dev); | 1356 | dev->height = norm_maxh(dev); |
1302 | dev->frame_size = dev->width * dev->height * 2; | 1357 | dev->frame_size = dev->width * dev->height * 2; |
@@ -1305,6 +1360,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
1305 | dev->hscale = 0; | 1360 | dev->hscale = 0; |
1306 | dev->vscale = 0; | 1361 | dev->vscale = 0; |
1307 | 1362 | ||
1363 | em28xx_set_alternate(dev); | ||
1308 | em28xx_capture_start(dev, 1); | 1364 | em28xx_capture_start(dev, 1); |
1309 | em28xx_resolution_set(dev); | 1365 | em28xx_resolution_set(dev); |
1310 | 1366 | ||
@@ -1730,6 +1786,10 @@ static const struct video_device em28xx_video_template = { | |||
1730 | .vidioc_s_tuner = vidioc_s_tuner, | 1786 | .vidioc_s_tuner = vidioc_s_tuner, |
1731 | .vidioc_g_frequency = vidioc_g_frequency, | 1787 | .vidioc_g_frequency = vidioc_g_frequency, |
1732 | .vidioc_s_frequency = vidioc_s_frequency, | 1788 | .vidioc_s_frequency = vidioc_s_frequency, |
1789 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1790 | .vidioc_g_register = vidioc_g_register, | ||
1791 | .vidioc_s_register = vidioc_s_register, | ||
1792 | #endif | ||
1733 | 1793 | ||
1734 | .tvnorms = V4L2_STD_ALL, | 1794 | .tvnorms = V4L2_STD_ALL, |
1735 | .current_norm = V4L2_STD_PAL, | 1795 | .current_norm = V4L2_STD_PAL, |
@@ -1752,6 +1812,10 @@ static struct video_device em28xx_radio_template = { | |||
1752 | .vidioc_s_ctrl = vidioc_s_ctrl, | 1812 | .vidioc_s_ctrl = vidioc_s_ctrl, |
1753 | .vidioc_g_frequency = vidioc_g_frequency, | 1813 | .vidioc_g_frequency = vidioc_g_frequency, |
1754 | .vidioc_s_frequency = vidioc_s_frequency, | 1814 | .vidioc_s_frequency = vidioc_s_frequency, |
1815 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1816 | .vidioc_g_register = vidioc_g_register, | ||
1817 | .vidioc_s_register = vidioc_s_register, | ||
1818 | #endif | ||
1755 | }; | 1819 | }; |
1756 | 1820 | ||
1757 | /******************************** usb interface *****************************************/ | 1821 | /******************************** usb interface *****************************************/ |
@@ -1796,10 +1860,10 @@ void em28xx_unregister_extension(struct em28xx_ops *ops) | |||
1796 | } | 1860 | } |
1797 | EXPORT_SYMBOL(em28xx_unregister_extension); | 1861 | EXPORT_SYMBOL(em28xx_unregister_extension); |
1798 | 1862 | ||
1799 | struct video_device *em28xx_vdev_init(struct em28xx *dev, | 1863 | static struct video_device *em28xx_vdev_init(struct em28xx *dev, |
1800 | const struct video_device *template, | 1864 | const struct video_device *template, |
1801 | const int type, | 1865 | const int type, |
1802 | const char *type_name) | 1866 | const char *type_name) |
1803 | { | 1867 | { |
1804 | struct video_device *vfd; | 1868 | struct video_device *vfd; |
1805 | 1869 | ||
@@ -2064,6 +2128,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2064 | snprintf(dev->name, 29, "em28xx #%d", nr); | 2128 | snprintf(dev->name, 29, "em28xx #%d", nr); |
2065 | dev->devno = nr; | 2129 | dev->devno = nr; |
2066 | dev->model = id->driver_info; | 2130 | dev->model = id->driver_info; |
2131 | dev->alt = -1; | ||
2067 | 2132 | ||
2068 | /* Checks if audio is provided by some interface */ | 2133 | /* Checks if audio is provided by some interface */ |
2069 | for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { | 2134 | for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index f3bad0c1c517..04e0e48ecabe 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -33,7 +33,7 @@ | |||
33 | #define UNSET -1 | 33 | #define UNSET -1 |
34 | 34 | ||
35 | /* maximum number of em28xx boards */ | 35 | /* maximum number of em28xx boards */ |
36 | #define EM28XX_MAXBOARDS 1 /*FIXME: should be bigger */ | 36 | #define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ |
37 | 37 | ||
38 | /* maximum number of frames that can be queued */ | 38 | /* maximum number of frames that can be queued */ |
39 | #define EM28XX_NUM_FRAMES 5 | 39 | #define EM28XX_NUM_FRAMES 5 |
@@ -345,9 +345,6 @@ int em28xx_read_reg(struct em28xx *dev, u16 reg); | |||
345 | int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | 345 | int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, |
346 | int len); | 346 | int len); |
347 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); | 347 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); |
348 | int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, | ||
349 | u8 bitmask); | ||
350 | int em28xx_set_audio_source(struct em28xx *dev); | ||
351 | int em28xx_audio_analog_set(struct em28xx *dev); | 348 | int em28xx_audio_analog_set(struct em28xx *dev); |
352 | 349 | ||
353 | int em28xx_colorlevels_set_default(struct em28xx *dev); | 350 | int em28xx_colorlevels_set_default(struct em28xx *dev); |
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 7d7f383b404f..262830da08c8 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -928,27 +928,38 @@ struct saa7134_board saa7134_boards[] = { | |||
928 | .tuner_addr = ADDR_UNSET, | 928 | .tuner_addr = ADDR_UNSET, |
929 | .radio_addr = ADDR_UNSET, | 929 | .radio_addr = ADDR_UNSET, |
930 | .tda9887_conf = TDA9887_PRESENT, | 930 | .tda9887_conf = TDA9887_PRESENT, |
931 | .gpiomask = 0x03, | ||
931 | .inputs = {{ | 932 | .inputs = {{ |
932 | .name = name_tv, | 933 | .name = name_tv, |
933 | .vmux = 1, | 934 | .vmux = 1, |
934 | .amux = TV, | 935 | .amux = TV, |
935 | .tv = 1, | 936 | .tv = 1, |
936 | },{ | 937 | .gpio = 0x00, |
938 | }, { | ||
937 | .name = name_comp1, | 939 | .name = name_comp1, |
938 | .vmux = 0, | ||
939 | .amux = LINE2, | ||
940 | },{ | ||
941 | .name = name_comp2, | ||
942 | .vmux = 3, | 940 | .vmux = 3, |
943 | .amux = LINE2, | 941 | .amux = LINE1, |
944 | },{ | 942 | .gpio = 0x02, |
943 | }, { | ||
944 | .name = name_comp2, | ||
945 | .vmux = 0, | ||
946 | .amux = LINE1, | ||
947 | .gpio = 0x02, | ||
948 | }, { | ||
945 | .name = name_svideo, | 949 | .name = name_svideo, |
946 | .vmux = 8, | 950 | .vmux = 8, |
947 | .amux = LINE2, | 951 | .amux = LINE1, |
948 | }}, | 952 | .gpio = 0x02, |
953 | } }, | ||
949 | .radio = { | 954 | .radio = { |
950 | .name = name_radio, | 955 | .name = name_radio, |
951 | .amux = LINE2, | 956 | .amux = LINE1, |
957 | .gpio = 0x01, | ||
958 | }, | ||
959 | .mute = { | ||
960 | .name = name_mute, | ||
961 | .amux = TV, | ||
962 | .gpio = 0x00, | ||
952 | }, | 963 | }, |
953 | }, | 964 | }, |
954 | [SAA7134_BOARD_BMK_MPEX_TUNER] = { | 965 | [SAA7134_BOARD_BMK_MPEX_TUNER] = { |
@@ -3912,6 +3923,74 @@ struct saa7134_board saa7134_boards[] = { | |||
3912 | }, | 3923 | }, |
3913 | .mpeg = SAA7134_MPEG_EMPRESS, | 3924 | .mpeg = SAA7134_MPEG_EMPRESS, |
3914 | }, | 3925 | }, |
3926 | [SAA7134_BOARD_TWINHAN_DTV_DVB_3056] = { | ||
3927 | .name = "Twinhan Hybrid DTV-DVB 3056 PCI", | ||
3928 | .audio_clock = 0x00187de7, | ||
3929 | .tuner_type = TUNER_PHILIPS_TDA8290, | ||
3930 | .radio_type = UNSET, | ||
3931 | .tuner_addr = ADDR_UNSET, | ||
3932 | .radio_addr = ADDR_UNSET, | ||
3933 | .tuner_config = 2, | ||
3934 | .mpeg = SAA7134_MPEG_DVB, | ||
3935 | .gpiomask = 0x0200000, | ||
3936 | .inputs = {{ | ||
3937 | .name = name_tv, | ||
3938 | .vmux = 1, | ||
3939 | .amux = TV, | ||
3940 | .tv = 1, | ||
3941 | }, { | ||
3942 | .name = name_comp1, | ||
3943 | .vmux = 3, | ||
3944 | .amux = LINE1, | ||
3945 | }, { | ||
3946 | .name = name_svideo, | ||
3947 | .vmux = 8, /* untested */ | ||
3948 | .amux = LINE1, | ||
3949 | } }, | ||
3950 | .radio = { | ||
3951 | .name = name_radio, | ||
3952 | .amux = TV, | ||
3953 | .gpio = 0x0200000, | ||
3954 | }, | ||
3955 | }, | ||
3956 | [SAA7134_BOARD_GENIUS_TVGO_A11MCE] = { | ||
3957 | /* Adrian Pardini <pardo.bsso@gmail.com> */ | ||
3958 | .name = "Genius TVGO AM11MCE", | ||
3959 | .audio_clock = 0x00200000, | ||
3960 | .tuner_type = TUNER_TNF_5335MF, | ||
3961 | .radio_type = UNSET, | ||
3962 | .tuner_addr = ADDR_UNSET, | ||
3963 | .radio_addr = ADDR_UNSET, | ||
3964 | .gpiomask = 0xf000, | ||
3965 | .inputs = {{ | ||
3966 | .name = name_tv_mono, | ||
3967 | .vmux = 1, | ||
3968 | .amux = LINE2, | ||
3969 | .gpio = 0x0000, | ||
3970 | .tv = 1, | ||
3971 | }, { | ||
3972 | .name = name_comp1, | ||
3973 | .vmux = 3, | ||
3974 | .amux = LINE1, | ||
3975 | .gpio = 0x2000, | ||
3976 | .tv = 1 | ||
3977 | }, { | ||
3978 | .name = name_svideo, | ||
3979 | .vmux = 8, | ||
3980 | .amux = LINE1, | ||
3981 | .gpio = 0x2000, | ||
3982 | } }, | ||
3983 | .radio = { | ||
3984 | .name = name_radio, | ||
3985 | .amux = LINE2, | ||
3986 | .gpio = 0x1000, | ||
3987 | }, | ||
3988 | .mute = { | ||
3989 | .name = name_mute, | ||
3990 | .amux = LINE2, | ||
3991 | .gpio = 0x6000, | ||
3992 | }, | ||
3993 | }, | ||
3915 | }; | 3994 | }; |
3916 | 3995 | ||
3917 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); | 3996 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); |
@@ -4511,6 +4590,12 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
4511 | },{ | 4590 | },{ |
4512 | .vendor = PCI_VENDOR_ID_PHILIPS, | 4591 | .vendor = PCI_VENDOR_ID_PHILIPS, |
4513 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | 4592 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, |
4593 | .subvendor = 0x5168, | ||
4594 | .subdevice = 0x3307, /* FlyDVB-T Hybrid Mini PCI */ | ||
4595 | .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS, | ||
4596 | }, { | ||
4597 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
4598 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
4514 | .subvendor = 0x16be, | 4599 | .subvendor = 0x16be, |
4515 | .subdevice = 0x0007, | 4600 | .subdevice = 0x0007, |
4516 | .driver_data = SAA7134_BOARD_MEDION_MD8800_QUADRO, | 4601 | .driver_data = SAA7134_BOARD_MEDION_MD8800_QUADRO, |
@@ -4523,6 +4608,12 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
4523 | },{ | 4608 | },{ |
4524 | .vendor = PCI_VENDOR_ID_PHILIPS, | 4609 | .vendor = PCI_VENDOR_ID_PHILIPS, |
4525 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | 4610 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, |
4611 | .subvendor = 0x16be, | ||
4612 | .subdevice = 0x000d, /* triple CTX948_V1.1.1 */ | ||
4613 | .driver_data = SAA7134_BOARD_MEDION_MD8800_QUADRO, | ||
4614 | }, { | ||
4615 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
4616 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
4526 | .subvendor = 0x1461, | 4617 | .subvendor = 0x1461, |
4527 | .subdevice = 0x2c05, | 4618 | .subdevice = 0x2c05, |
4528 | .driver_data = SAA7134_BOARD_AVERMEDIA_777, | 4619 | .driver_data = SAA7134_BOARD_AVERMEDIA_777, |
@@ -4843,7 +4934,13 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
4843 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | 4934 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, |
4844 | .subvendor = 0x4e42, | 4935 | .subvendor = 0x4e42, |
4845 | .subdevice = 0x3502, | 4936 | .subdevice = 0x3502, |
4846 | .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS | 4937 | .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS, |
4938 | }, { | ||
4939 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
4940 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
4941 | .subvendor = 0x1822, /*Twinhan Technology Co. Ltd*/ | ||
4942 | .subdevice = 0x0022, | ||
4943 | .driver_data = SAA7134_BOARD_TWINHAN_DTV_DVB_3056, | ||
4847 | },{ | 4944 | },{ |
4848 | /* --- boards without eeprom + subsystem ID --- */ | 4945 | /* --- boards without eeprom + subsystem ID --- */ |
4849 | .vendor = PCI_VENDOR_ID_PHILIPS, | 4946 | .vendor = PCI_VENDOR_ID_PHILIPS, |
@@ -4995,6 +5092,7 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
4995 | case SAA7134_BOARD_BEHOLD_409: | 5092 | case SAA7134_BOARD_BEHOLD_409: |
4996 | case SAA7134_BOARD_BEHOLD_505FM: | 5093 | case SAA7134_BOARD_BEHOLD_505FM: |
4997 | case SAA7134_BOARD_BEHOLD_507_9FM: | 5094 | case SAA7134_BOARD_BEHOLD_507_9FM: |
5095 | case SAA7134_BOARD_GENIUS_TVGO_A11MCE: | ||
4998 | dev->has_remote = SAA7134_REMOTE_GPIO; | 5096 | dev->has_remote = SAA7134_REMOTE_GPIO; |
4999 | break; | 5097 | break; |
5000 | case SAA7134_BOARD_FLYDVBS_LR300: | 5098 | case SAA7134_BOARD_FLYDVBS_LR300: |
@@ -5232,7 +5330,8 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
5232 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: | 5330 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
5233 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: | 5331 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
5234 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: | 5332 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: |
5235 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: | 5333 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: |
5334 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: | ||
5236 | /* this is a hybrid board, initialize to analog mode | 5335 | /* this is a hybrid board, initialize to analog mode |
5237 | * and configure firmware eeprom address | 5336 | * and configure firmware eeprom address |
5238 | */ | 5337 | */ |
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index a9ca5730826f..ea2be9eceeb8 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
@@ -779,6 +779,21 @@ static struct tda1004x_config avermedia_super_007_config = { | |||
779 | .request_firmware = philips_tda1004x_request_firmware | 779 | .request_firmware = philips_tda1004x_request_firmware |
780 | }; | 780 | }; |
781 | 781 | ||
782 | static struct tda1004x_config twinhan_dtv_dvb_3056_config = { | ||
783 | .demod_address = 0x08, | ||
784 | .invert = 1, | ||
785 | .invert_oclk = 0, | ||
786 | .xtal_freq = TDA10046_XTAL_16M, | ||
787 | .agc_config = TDA10046_AGC_TDA827X, | ||
788 | .gpio_config = TDA10046_GP01_I, | ||
789 | .if_freq = TDA10046_FREQ_045, | ||
790 | .i2c_gate = 0x42, | ||
791 | .tuner_address = 0x61, | ||
792 | .tuner_config = 2, | ||
793 | .antenna_switch = 1, | ||
794 | .request_firmware = philips_tda1004x_request_firmware | ||
795 | }; | ||
796 | |||
782 | /* ------------------------------------------------------------------ | 797 | /* ------------------------------------------------------------------ |
783 | * special case: this card uses saa713x GPIO22 for the mode switch | 798 | * special case: this card uses saa713x GPIO22 for the mode switch |
784 | */ | 799 | */ |
@@ -826,6 +841,7 @@ static struct tda1004x_config ads_tech_duo_config = { | |||
826 | static struct tda10086_config flydvbs = { | 841 | static struct tda10086_config flydvbs = { |
827 | .demod_address = 0x0e, | 842 | .demod_address = 0x0e, |
828 | .invert = 0, | 843 | .invert = 0, |
844 | .diseqc_tone = 0, | ||
829 | }; | 845 | }; |
830 | 846 | ||
831 | /* ================================================================== | 847 | /* ================================================================== |
@@ -940,9 +956,9 @@ static int dvb_init(struct saa7134_dev *dev) | |||
940 | configure_tda827x_fe(dev, &tda827x_lifeview_config); | 956 | configure_tda827x_fe(dev, &tda827x_lifeview_config); |
941 | break; | 957 | break; |
942 | case SAA7134_BOARD_FLYDVB_TRIO: | 958 | case SAA7134_BOARD_FLYDVB_TRIO: |
943 | if(! use_frontend) { //terrestrial | 959 | if(! use_frontend) { /* terrestrial */ |
944 | configure_tda827x_fe(dev, &lifeview_trio_config); | 960 | configure_tda827x_fe(dev, &lifeview_trio_config); |
945 | } else { //satellite | 961 | } else { /* satellite */ |
946 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); | 962 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); |
947 | if (dev->dvb.frontend) { | 963 | if (dev->dvb.frontend) { |
948 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, | 964 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, |
@@ -1007,8 +1023,9 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1007 | } | 1023 | } |
1008 | break; | 1024 | break; |
1009 | case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: | 1025 | case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: |
1010 | dev->dvb.frontend = tda10046_attach(&medion_cardbus, | 1026 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
1011 | &dev->i2c_adap); | 1027 | &medion_cardbus, |
1028 | &dev->i2c_adap); | ||
1012 | if (dev->dvb.frontend) { | 1029 | if (dev->dvb.frontend) { |
1013 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; | 1030 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; |
1014 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; | 1031 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; |
@@ -1044,6 +1061,9 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1044 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: | 1061 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: |
1045 | configure_tda827x_fe(dev, &avermedia_super_007_config); | 1062 | configure_tda827x_fe(dev, &avermedia_super_007_config); |
1046 | break; | 1063 | break; |
1064 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: | ||
1065 | configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config); | ||
1066 | break; | ||
1047 | default: | 1067 | default: |
1048 | wprintk("Huh? unknown DVB card?\n"); | 1068 | wprintk("Huh? unknown DVB card?\n"); |
1049 | break; | 1069 | break; |
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index b1b01fa86720..3d2ec30de227 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c | |||
@@ -87,7 +87,7 @@ static int ts_open(struct inode *inode, struct file *file) | |||
87 | 87 | ||
88 | dprintk("open minor=%d\n",minor); | 88 | dprintk("open minor=%d\n",minor); |
89 | err = -EBUSY; | 89 | err = -EBUSY; |
90 | if (!mutex_trylock(&dev->empress_tsq.lock)) | 90 | if (!mutex_trylock(&dev->empress_tsq.vb_lock)) |
91 | goto done; | 91 | goto done; |
92 | if (dev->empress_users) | 92 | if (dev->empress_users) |
93 | goto done_up; | 93 | goto done_up; |
@@ -101,7 +101,7 @@ static int ts_open(struct inode *inode, struct file *file) | |||
101 | err = 0; | 101 | err = 0; |
102 | 102 | ||
103 | done_up: | 103 | done_up: |
104 | mutex_unlock(&dev->empress_tsq.lock); | 104 | mutex_unlock(&dev->empress_tsq.vb_lock); |
105 | done: | 105 | done: |
106 | return err; | 106 | return err; |
107 | } | 107 | } |
@@ -110,7 +110,6 @@ static int ts_release(struct inode *inode, struct file *file) | |||
110 | { | 110 | { |
111 | struct saa7134_dev *dev = file->private_data; | 111 | struct saa7134_dev *dev = file->private_data; |
112 | 112 | ||
113 | mutex_lock(&dev->empress_tsq.lock); | ||
114 | videobuf_stop(&dev->empress_tsq); | 113 | videobuf_stop(&dev->empress_tsq); |
115 | videobuf_mmap_free(&dev->empress_tsq); | 114 | videobuf_mmap_free(&dev->empress_tsq); |
116 | dev->empress_users--; | 115 | dev->empress_users--; |
@@ -122,7 +121,6 @@ static int ts_release(struct inode *inode, struct file *file) | |||
122 | saa_writeb(SAA7134_AUDIO_MUTE_CTRL, | 121 | saa_writeb(SAA7134_AUDIO_MUTE_CTRL, |
123 | saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6)); | 122 | saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6)); |
124 | 123 | ||
125 | mutex_unlock(&dev->empress_tsq.lock); | ||
126 | return 0; | 124 | return 0; |
127 | } | 125 | } |
128 | 126 | ||
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 0db955c2d9b9..b4188819782f 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
@@ -406,6 +406,12 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
406 | mask_keyup = 0x8000000; | 406 | mask_keyup = 0x8000000; |
407 | polling = 50; //ms | 407 | polling = 50; //ms |
408 | break; | 408 | break; |
409 | case SAA7134_BOARD_GENIUS_TVGO_A11MCE: | ||
410 | ir_codes = ir_codes_genius_tvgo_a11mce; | ||
411 | mask_keycode = 0xff; | ||
412 | mask_keydown = 0xf00000; | ||
413 | polling = 50; /* ms */ | ||
414 | break; | ||
409 | } | 415 | } |
410 | if (NULL == ir_codes) { | 416 | if (NULL == ir_codes) { |
411 | printk("%s: Oops: IR config error [card=%d]\n", | 417 | printk("%s: Oops: IR config error [card=%d]\n", |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 1184d359e848..39c41ad97d0e 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
@@ -1414,21 +1414,17 @@ video_poll(struct file *file, struct poll_table_struct *wait) | |||
1414 | if (!list_empty(&fh->cap.stream)) | 1414 | if (!list_empty(&fh->cap.stream)) |
1415 | buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream); | 1415 | buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream); |
1416 | } else { | 1416 | } else { |
1417 | mutex_lock(&fh->cap.lock); | 1417 | mutex_lock(&fh->cap.vb_lock); |
1418 | if (UNSET == fh->cap.read_off) { | 1418 | if (UNSET == fh->cap.read_off) { |
1419 | /* need to capture a new frame */ | 1419 | /* need to capture a new frame */ |
1420 | if (res_locked(fh->dev,RESOURCE_VIDEO)) { | 1420 | if (res_locked(fh->dev,RESOURCE_VIDEO)) |
1421 | mutex_unlock(&fh->cap.lock); | 1421 | goto err; |
1422 | return POLLERR; | 1422 | if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) |
1423 | } | 1423 | goto err; |
1424 | if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) { | ||
1425 | mutex_unlock(&fh->cap.lock); | ||
1426 | return POLLERR; | ||
1427 | } | ||
1428 | fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); | 1424 | fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); |
1429 | fh->cap.read_off = 0; | 1425 | fh->cap.read_off = 0; |
1430 | } | 1426 | } |
1431 | mutex_unlock(&fh->cap.lock); | 1427 | mutex_unlock(&fh->cap.vb_lock); |
1432 | buf = fh->cap.read_buf; | 1428 | buf = fh->cap.read_buf; |
1433 | } | 1429 | } |
1434 | 1430 | ||
@@ -1440,6 +1436,10 @@ video_poll(struct file *file, struct poll_table_struct *wait) | |||
1440 | buf->state == VIDEOBUF_ERROR) | 1436 | buf->state == VIDEOBUF_ERROR) |
1441 | return POLLIN|POLLRDNORM; | 1437 | return POLLIN|POLLRDNORM; |
1442 | return 0; | 1438 | return 0; |
1439 | |||
1440 | err: | ||
1441 | mutex_unlock(&fh->cap.vb_lock); | ||
1442 | return POLLERR; | ||
1443 | } | 1443 | } |
1444 | 1444 | ||
1445 | static int video_release(struct inode *inode, struct file *file) | 1445 | static int video_release(struct inode *inode, struct file *file) |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index b88ca995fafb..f940d0254798 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -252,6 +252,8 @@ struct saa7134_format { | |||
252 | #define SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM 128 | 252 | #define SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM 128 |
253 | #define SAA7134_BOARD_BEHOLD_607_9FM 129 | 253 | #define SAA7134_BOARD_BEHOLD_607_9FM 129 |
254 | #define SAA7134_BOARD_BEHOLD_M6 130 | 254 | #define SAA7134_BOARD_BEHOLD_M6 130 |
255 | #define SAA7134_BOARD_TWINHAN_DTV_DVB_3056 131 | ||
256 | #define SAA7134_BOARD_GENIUS_TVGO_A11MCE 132 | ||
255 | 257 | ||
256 | #define SAA7134_MAXBOARDS 8 | 258 | #define SAA7134_MAXBOARDS 8 |
257 | #define SAA7134_INPUT_MAX 8 | 259 | #define SAA7134_INPUT_MAX 8 |
diff --git a/drivers/media/video/stk-sensor.c b/drivers/media/video/stk-sensor.c index 4a9a0b62efa3..e546b014d7ad 100644 --- a/drivers/media/video/stk-sensor.c +++ b/drivers/media/video/stk-sensor.c | |||
@@ -225,7 +225,7 @@ | |||
225 | 225 | ||
226 | 226 | ||
227 | /* Returns 0 if OK */ | 227 | /* Returns 0 if OK */ |
228 | int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val) | 228 | static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val) |
229 | { | 229 | { |
230 | int i = 0; | 230 | int i = 0; |
231 | int tmpval = 0; | 231 | int tmpval = 0; |
@@ -250,7 +250,7 @@ int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val) | |||
250 | return 0; | 250 | return 0; |
251 | } | 251 | } |
252 | 252 | ||
253 | int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val) | 253 | static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val) |
254 | { | 254 | { |
255 | int i = 0; | 255 | int i = 0; |
256 | int tmpval = 0; | 256 | int tmpval = 0; |
@@ -380,7 +380,7 @@ int stk_sensor_init(struct stk_camera *dev) | |||
380 | STK_ERROR("Strange error reading sensor ID\n"); | 380 | STK_ERROR("Strange error reading sensor ID\n"); |
381 | return -ENODEV; | 381 | return -ENODEV; |
382 | } | 382 | } |
383 | if (idh != 0x7F || idl != 0xA2) { | 383 | if (idh != 0x7f || idl != 0xa2) { |
384 | STK_ERROR("Huh? you don't have a sensor from ovt\n"); | 384 | STK_ERROR("Huh? you don't have a sensor from ovt\n"); |
385 | return -ENODEV; | 385 | return -ENODEV; |
386 | } | 386 | } |
@@ -409,6 +409,19 @@ static struct regval ov_fmt_uyvy[] = { | |||
409 | {REG_COM15, COM15_R00FF }, | 409 | {REG_COM15, COM15_R00FF }, |
410 | {0xff, 0xff}, /* END MARKER */ | 410 | {0xff, 0xff}, /* END MARKER */ |
411 | }; | 411 | }; |
412 | /* V4L2_PIX_FMT_YUYV */ | ||
413 | static struct regval ov_fmt_yuyv[] = { | ||
414 | {REG_TSLB, 0 }, | ||
415 | { 0x4f, 0x80 }, /* "matrix coefficient 1" */ | ||
416 | { 0x50, 0x80 }, /* "matrix coefficient 2" */ | ||
417 | { 0x51, 0 }, /* vb */ | ||
418 | { 0x52, 0x22 }, /* "matrix coefficient 4" */ | ||
419 | { 0x53, 0x5e }, /* "matrix coefficient 5" */ | ||
420 | { 0x54, 0x80 }, /* "matrix coefficient 6" */ | ||
421 | {REG_COM13, COM13_UVSAT|COM13_CMATRIX}, | ||
422 | {REG_COM15, COM15_R00FF }, | ||
423 | {0xff, 0xff}, /* END MARKER */ | ||
424 | }; | ||
412 | 425 | ||
413 | /* V4L2_PIX_FMT_RGB565X rrrrrggg gggbbbbb */ | 426 | /* V4L2_PIX_FMT_RGB565X rrrrrggg gggbbbbb */ |
414 | static struct regval ov_fmt_rgbr[] = { | 427 | static struct regval ov_fmt_rgbr[] = { |
@@ -519,6 +532,10 @@ int stk_sensor_configure(struct stk_camera *dev) | |||
519 | com7 |= COM7_YUV; | 532 | com7 |= COM7_YUV; |
520 | rv = ov_fmt_uyvy; | 533 | rv = ov_fmt_uyvy; |
521 | break; | 534 | break; |
535 | case V4L2_PIX_FMT_YUYV: | ||
536 | com7 |= COM7_YUV; | ||
537 | rv = ov_fmt_yuyv; | ||
538 | break; | ||
522 | case V4L2_PIX_FMT_RGB565: | 539 | case V4L2_PIX_FMT_RGB565: |
523 | com7 |= COM7_RGB; | 540 | com7 |= COM7_RGB; |
524 | rv = ov_fmt_rgbp; | 541 | rv = ov_fmt_rgbp; |
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c index d37e5e2594b4..ceba45ad0294 100644 --- a/drivers/media/video/stk-webcam.c +++ b/drivers/media/video/stk-webcam.c | |||
@@ -63,7 +63,7 @@ static struct usb_device_id stkwebcam_table[] = { | |||
63 | }; | 63 | }; |
64 | MODULE_DEVICE_TABLE(usb, stkwebcam_table); | 64 | MODULE_DEVICE_TABLE(usb, stkwebcam_table); |
65 | 65 | ||
66 | void stk_camera_cleanup(struct kref *kref) | 66 | static void stk_camera_cleanup(struct kref *kref) |
67 | { | 67 | { |
68 | struct stk_camera *dev = to_stk_camera(kref); | 68 | struct stk_camera *dev = to_stk_camera(kref); |
69 | 69 | ||
@@ -682,6 +682,7 @@ static int v4l_stk_open(struct inode *inode, struct file *fp) | |||
682 | return -ENXIO; | 682 | return -ENXIO; |
683 | fp->private_data = vdev; | 683 | fp->private_data = vdev; |
684 | kref_get(&dev->kref); | 684 | kref_get(&dev->kref); |
685 | usb_autopm_get_interface(dev->interface); | ||
685 | 686 | ||
686 | return 0; | 687 | return 0; |
687 | } | 688 | } |
@@ -703,6 +704,7 @@ static int v4l_stk_release(struct inode *inode, struct file *fp) | |||
703 | } | 704 | } |
704 | 705 | ||
705 | if (dev->owner != fp) { | 706 | if (dev->owner != fp) { |
707 | usb_autopm_put_interface(dev->interface); | ||
706 | kref_put(&dev->kref, stk_camera_cleanup); | 708 | kref_put(&dev->kref, stk_camera_cleanup); |
707 | return 0; | 709 | return 0; |
708 | } | 710 | } |
@@ -713,6 +715,7 @@ static int v4l_stk_release(struct inode *inode, struct file *fp) | |||
713 | 715 | ||
714 | dev->owner = NULL; | 716 | dev->owner = NULL; |
715 | 717 | ||
718 | usb_autopm_put_interface(dev->interface); | ||
716 | kref_put(&dev->kref, stk_camera_cleanup); | 719 | kref_put(&dev->kref, stk_camera_cleanup); |
717 | 720 | ||
718 | return 0; | 721 | return 0; |
@@ -993,6 +996,10 @@ static int stk_vidioc_enum_fmt_cap(struct file *filp, | |||
993 | fmtd->pixelformat = V4L2_PIX_FMT_SBGGR8; | 996 | fmtd->pixelformat = V4L2_PIX_FMT_SBGGR8; |
994 | strcpy(fmtd->description, "Raw bayer"); | 997 | strcpy(fmtd->description, "Raw bayer"); |
995 | break; | 998 | break; |
999 | case 4: | ||
1000 | fmtd->pixelformat = V4L2_PIX_FMT_YUYV; | ||
1001 | strcpy(fmtd->description, "yuv4:2:2"); | ||
1002 | break; | ||
996 | default: | 1003 | default: |
997 | return -EINVAL; | 1004 | return -EINVAL; |
998 | } | 1005 | } |
@@ -1048,6 +1055,7 @@ static int stk_vidioc_try_fmt_cap(struct file *filp, | |||
1048 | case V4L2_PIX_FMT_RGB565: | 1055 | case V4L2_PIX_FMT_RGB565: |
1049 | case V4L2_PIX_FMT_RGB565X: | 1056 | case V4L2_PIX_FMT_RGB565X: |
1050 | case V4L2_PIX_FMT_UYVY: | 1057 | case V4L2_PIX_FMT_UYVY: |
1058 | case V4L2_PIX_FMT_YUYV: | ||
1051 | case V4L2_PIX_FMT_SBGGR8: | 1059 | case V4L2_PIX_FMT_SBGGR8: |
1052 | break; | 1060 | break; |
1053 | default: | 1061 | default: |
@@ -1080,6 +1088,42 @@ static int stk_vidioc_try_fmt_cap(struct file *filp, | |||
1080 | return 0; | 1088 | return 0; |
1081 | } | 1089 | } |
1082 | 1090 | ||
1091 | static int stk_setup_format(struct stk_camera *dev) | ||
1092 | { | ||
1093 | int i = 0; | ||
1094 | int depth; | ||
1095 | if (dev->vsettings.palette == V4L2_PIX_FMT_SBGGR8) | ||
1096 | depth = 1; | ||
1097 | else | ||
1098 | depth = 2; | ||
1099 | while (stk_sizes[i].m != dev->vsettings.mode | ||
1100 | && i < ARRAY_SIZE(stk_sizes)) | ||
1101 | i++; | ||
1102 | if (i == ARRAY_SIZE(stk_sizes)) { | ||
1103 | STK_ERROR("Something is broken in %s\n", __FUNCTION__); | ||
1104 | return -EFAULT; | ||
1105 | } | ||
1106 | /* This registers controls some timings, not sure of what. */ | ||
1107 | stk_camera_write_reg(dev, 0x001b, 0x0e); | ||
1108 | if (dev->vsettings.mode == MODE_SXGA) | ||
1109 | stk_camera_write_reg(dev, 0x001c, 0x0e); | ||
1110 | else | ||
1111 | stk_camera_write_reg(dev, 0x001c, 0x46); | ||
1112 | /* | ||
1113 | * Registers 0x0115 0x0114 are the size of each line (bytes), | ||
1114 | * regs 0x0117 0x0116 are the heigth of the image. | ||
1115 | */ | ||
1116 | stk_camera_write_reg(dev, 0x0115, | ||
1117 | ((stk_sizes[i].w * depth) >> 8) & 0xff); | ||
1118 | stk_camera_write_reg(dev, 0x0114, | ||
1119 | (stk_sizes[i].w * depth) & 0xff); | ||
1120 | stk_camera_write_reg(dev, 0x0117, | ||
1121 | (stk_sizes[i].h >> 8) & 0xff); | ||
1122 | stk_camera_write_reg(dev, 0x0116, | ||
1123 | stk_sizes[i].h & 0xff); | ||
1124 | return stk_sensor_configure(dev); | ||
1125 | } | ||
1126 | |||
1083 | static int stk_vidioc_s_fmt_cap(struct file *filp, | 1127 | static int stk_vidioc_s_fmt_cap(struct file *filp, |
1084 | void *priv, struct v4l2_format *fmtd) | 1128 | void *priv, struct v4l2_format *fmtd) |
1085 | { | 1129 | { |
@@ -1094,10 +1138,10 @@ static int stk_vidioc_s_fmt_cap(struct file *filp, | |||
1094 | return -EBUSY; | 1138 | return -EBUSY; |
1095 | if (dev->owner && dev->owner != filp) | 1139 | if (dev->owner && dev->owner != filp) |
1096 | return -EBUSY; | 1140 | return -EBUSY; |
1097 | dev->owner = filp; | ||
1098 | ret = stk_vidioc_try_fmt_cap(filp, priv, fmtd); | 1141 | ret = stk_vidioc_try_fmt_cap(filp, priv, fmtd); |
1099 | if (ret) | 1142 | if (ret) |
1100 | return ret; | 1143 | return ret; |
1144 | dev->owner = filp; | ||
1101 | 1145 | ||
1102 | dev->vsettings.palette = fmtd->fmt.pix.pixelformat; | 1146 | dev->vsettings.palette = fmtd->fmt.pix.pixelformat; |
1103 | stk_free_buffers(dev); | 1147 | stk_free_buffers(dev); |
@@ -1105,25 +1149,7 @@ static int stk_vidioc_s_fmt_cap(struct file *filp, | |||
1105 | dev->vsettings.mode = stk_sizes[fmtd->fmt.pix.priv].m; | 1149 | dev->vsettings.mode = stk_sizes[fmtd->fmt.pix.priv].m; |
1106 | 1150 | ||
1107 | stk_initialise(dev); | 1151 | stk_initialise(dev); |
1108 | /* This registers controls some timings, not sure of what. */ | 1152 | return stk_setup_format(dev); |
1109 | stk_camera_write_reg(dev, 0x001b, 0x0e); | ||
1110 | if (dev->vsettings.mode == MODE_SXGA) | ||
1111 | stk_camera_write_reg(dev, 0x001c, 0x0e); | ||
1112 | else | ||
1113 | stk_camera_write_reg(dev, 0x001c, 0x46); | ||
1114 | /* | ||
1115 | * Registers 0x0115 0x0114 are the size of each line (bytes), | ||
1116 | * regs 0x0117 0x0116 are the heigth of the image. | ||
1117 | */ | ||
1118 | stk_camera_write_reg(dev, 0x0115, | ||
1119 | (fmtd->fmt.pix.bytesperline >> 8) & 0xff); | ||
1120 | stk_camera_write_reg(dev, 0x0114, | ||
1121 | fmtd->fmt.pix.bytesperline & 0xff); | ||
1122 | stk_camera_write_reg(dev, 0x0117, | ||
1123 | (fmtd->fmt.pix.height >> 8) & 0xff); | ||
1124 | stk_camera_write_reg(dev, 0x0116, | ||
1125 | fmtd->fmt.pix.height & 0xff); | ||
1126 | return stk_sensor_configure(dev); | ||
1127 | } | 1153 | } |
1128 | 1154 | ||
1129 | static int stk_vidioc_reqbufs(struct file *filp, | 1155 | static int stk_vidioc_reqbufs(struct file *filp, |
@@ -1288,6 +1314,9 @@ static struct file_operations v4l_stk_fops = { | |||
1288 | .poll = v4l_stk_poll, | 1314 | .poll = v4l_stk_poll, |
1289 | .mmap = v4l_stk_mmap, | 1315 | .mmap = v4l_stk_mmap, |
1290 | .ioctl = video_ioctl2, | 1316 | .ioctl = video_ioctl2, |
1317 | #ifdef CONFIG_COMPAT | ||
1318 | .compat_ioctl = v4l_compat_ioctl32, | ||
1319 | #endif | ||
1291 | .llseek = no_llseek | 1320 | .llseek = no_llseek |
1292 | }; | 1321 | }; |
1293 | 1322 | ||
@@ -1403,7 +1432,7 @@ static int stk_camera_probe(struct usb_interface *interface, | |||
1403 | dev->vsettings.brightness = 0x7fff; | 1432 | dev->vsettings.brightness = 0x7fff; |
1404 | dev->vsettings.palette = V4L2_PIX_FMT_RGB565; | 1433 | dev->vsettings.palette = V4L2_PIX_FMT_RGB565; |
1405 | dev->vsettings.mode = MODE_VGA; | 1434 | dev->vsettings.mode = MODE_VGA; |
1406 | dev->frame_size = 640*480*2; | 1435 | dev->frame_size = 640 * 480 * 2; |
1407 | 1436 | ||
1408 | INIT_LIST_HEAD(&dev->sio_avail); | 1437 | INIT_LIST_HEAD(&dev->sio_avail); |
1409 | INIT_LIST_HEAD(&dev->sio_full); | 1438 | INIT_LIST_HEAD(&dev->sio_full); |
@@ -1417,6 +1446,7 @@ static int stk_camera_probe(struct usb_interface *interface, | |||
1417 | } | 1446 | } |
1418 | 1447 | ||
1419 | stk_create_sysfs_files(&dev->vdev); | 1448 | stk_create_sysfs_files(&dev->vdev); |
1449 | usb_autopm_enable(dev->interface); | ||
1420 | 1450 | ||
1421 | return 0; | 1451 | return 0; |
1422 | } | 1452 | } |
@@ -1434,11 +1464,41 @@ static void stk_camera_disconnect(struct usb_interface *interface) | |||
1434 | kref_put(&dev->kref, stk_camera_cleanup); | 1464 | kref_put(&dev->kref, stk_camera_cleanup); |
1435 | } | 1465 | } |
1436 | 1466 | ||
1467 | #ifdef CONFIG_PM | ||
1468 | int stk_camera_suspend(struct usb_interface *intf, pm_message_t message) | ||
1469 | { | ||
1470 | struct stk_camera *dev = usb_get_intfdata(intf); | ||
1471 | if (is_streaming(dev)) { | ||
1472 | stk_stop_stream(dev); | ||
1473 | /* yes, this is ugly */ | ||
1474 | set_streaming(dev); | ||
1475 | } | ||
1476 | return 0; | ||
1477 | } | ||
1478 | |||
1479 | int stk_camera_resume(struct usb_interface *intf) | ||
1480 | { | ||
1481 | struct stk_camera *dev = usb_get_intfdata(intf); | ||
1482 | if (!is_initialised(dev)) | ||
1483 | return 0; | ||
1484 | unset_initialised(dev); | ||
1485 | stk_initialise(dev); | ||
1486 | stk_setup_format(dev); | ||
1487 | if (is_streaming(dev)) | ||
1488 | stk_start_stream(dev); | ||
1489 | return 0; | ||
1490 | } | ||
1491 | #endif | ||
1492 | |||
1437 | static struct usb_driver stk_camera_driver = { | 1493 | static struct usb_driver stk_camera_driver = { |
1438 | .name = "stkwebcam", | 1494 | .name = "stkwebcam", |
1439 | .probe = stk_camera_probe, | 1495 | .probe = stk_camera_probe, |
1440 | .disconnect = stk_camera_disconnect, | 1496 | .disconnect = stk_camera_disconnect, |
1441 | .id_table = stkwebcam_table, | 1497 | .id_table = stkwebcam_table, |
1498 | #ifdef CONFIG_PM | ||
1499 | .suspend = stk_camera_suspend, | ||
1500 | .resume = stk_camera_resume, | ||
1501 | #endif | ||
1442 | }; | 1502 | }; |
1443 | 1503 | ||
1444 | 1504 | ||
diff --git a/drivers/media/video/stk-webcam.h b/drivers/media/video/stk-webcam.h index 7e989d1ac1e0..df4dfefc5327 100644 --- a/drivers/media/video/stk-webcam.h +++ b/drivers/media/video/stk-webcam.h | |||
@@ -79,6 +79,7 @@ enum stk_status { | |||
79 | #define unset_present(dev) ((dev)->status &= \ | 79 | #define unset_present(dev) ((dev)->status &= \ |
80 | ~(S_PRESENT|S_INITIALISED|S_STREAMING)) | 80 | ~(S_PRESENT|S_INITIALISED|S_STREAMING)) |
81 | #define set_initialised(dev) ((dev)->status |= S_INITIALISED) | 81 | #define set_initialised(dev) ((dev)->status |= S_INITIALISED) |
82 | #define unset_initialised(dev) ((dev)->status &= ~S_INITIALISED) | ||
82 | #define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD) | 83 | #define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD) |
83 | #define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD) | 84 | #define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD) |
84 | #define set_streaming(dev) ((dev)->status |= S_STREAMING) | 85 | #define set_streaming(dev) ((dev)->status |= S_STREAMING) |
@@ -127,8 +128,6 @@ void stk_camera_delete(struct kref *); | |||
127 | int stk_camera_write_reg(struct stk_camera *, u16, u8); | 128 | int stk_camera_write_reg(struct stk_camera *, u16, u8); |
128 | int stk_camera_read_reg(struct stk_camera *, u16, int *); | 129 | int stk_camera_read_reg(struct stk_camera *, u16, int *); |
129 | 130 | ||
130 | int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val); | ||
131 | int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val); | ||
132 | int stk_sensor_init(struct stk_camera *); | 131 | int stk_sensor_init(struct stk_camera *); |
133 | int stk_sensor_configure(struct stk_camera *); | 132 | int stk_sensor_configure(struct stk_camera *); |
134 | int stk_sensor_sleep(struct stk_camera *dev); | 133 | int stk_sensor_sleep(struct stk_camera *dev); |
diff --git a/drivers/media/video/tcm825x.c b/drivers/media/video/tcm825x.c index 41cd6a0b0485..fb895f6684a3 100644 --- a/drivers/media/video/tcm825x.c +++ b/drivers/media/video/tcm825x.c | |||
@@ -851,7 +851,7 @@ static int tcm825x_probe(struct i2c_client *client) | |||
851 | sensor->platform_data = client->dev.platform_data; | 851 | sensor->platform_data = client->dev.platform_data; |
852 | 852 | ||
853 | if (sensor->platform_data == NULL | 853 | if (sensor->platform_data == NULL |
854 | && !sensor->platform_data->is_okay()) | 854 | || !sensor->platform_data->is_okay()) |
855 | return -ENODEV; | 855 | return -ENODEV; |
856 | 856 | ||
857 | sensor->v4l2_int_device = &tcm825x_int_device; | 857 | sensor->v4l2_int_device = &tcm825x_int_device; |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index ba538f6fbcc3..78a09a2a4857 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -1038,7 +1038,7 @@ static int tuner_resume(struct i2c_client *c) | |||
1038 | 1038 | ||
1039 | /* ---------------------------------------------------------------------- */ | 1039 | /* ---------------------------------------------------------------------- */ |
1040 | 1040 | ||
1041 | LIST_HEAD(tuner_list); | 1041 | static LIST_HEAD(tuner_list); |
1042 | 1042 | ||
1043 | /* Search for existing radio and/or TV tuners on the given I2C adapter. | 1043 | /* Search for existing radio and/or TV tuners on the given I2C adapter. |
1044 | Note that when this function is called from tuner_probe you can be | 1044 | Note that when this function is called from tuner_probe you can be |
diff --git a/drivers/media/video/tuner-xc2028.c b/drivers/media/video/tuner-xc2028.c index f191f6a48070..50cf876f020f 100644 --- a/drivers/media/video/tuner-xc2028.c +++ b/drivers/media/video/tuner-xc2028.c | |||
@@ -754,6 +754,9 @@ skip_std_specific: | |||
754 | goto check_device; | 754 | goto check_device; |
755 | } | 755 | } |
756 | 756 | ||
757 | if (new_fw.type & FM) | ||
758 | goto check_device; | ||
759 | |||
757 | /* Load SCODE firmware, if exists */ | 760 | /* Load SCODE firmware, if exists */ |
758 | tuner_dbg("Trying to load scode %d\n", new_fw.scode_nr); | 761 | tuner_dbg("Trying to load scode %d\n", new_fw.scode_nr); |
759 | 762 | ||
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index a75560540e79..01ebcec040c4 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -1571,14 +1571,14 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip, | |||
1571 | ctrl->value=chip->muted; | 1571 | ctrl->value=chip->muted; |
1572 | return 0; | 1572 | return 0; |
1573 | case V4L2_CID_AUDIO_VOLUME: | 1573 | case V4L2_CID_AUDIO_VOLUME: |
1574 | if (!desc->flags & CHIP_HAS_VOLUME) | 1574 | if (!(desc->flags & CHIP_HAS_VOLUME)) |
1575 | break; | 1575 | break; |
1576 | ctrl->value = max(chip->left,chip->right); | 1576 | ctrl->value = max(chip->left,chip->right); |
1577 | return 0; | 1577 | return 0; |
1578 | case V4L2_CID_AUDIO_BALANCE: | 1578 | case V4L2_CID_AUDIO_BALANCE: |
1579 | { | 1579 | { |
1580 | int volume; | 1580 | int volume; |
1581 | if (!desc->flags & CHIP_HAS_VOLUME) | 1581 | if (!(desc->flags & CHIP_HAS_VOLUME)) |
1582 | break; | 1582 | break; |
1583 | volume = max(chip->left,chip->right); | 1583 | volume = max(chip->left,chip->right); |
1584 | if (volume) | 1584 | if (volume) |
@@ -1621,7 +1621,7 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip, | |||
1621 | { | 1621 | { |
1622 | int volume,balance; | 1622 | int volume,balance; |
1623 | 1623 | ||
1624 | if (!desc->flags & CHIP_HAS_VOLUME) | 1624 | if (!(desc->flags & CHIP_HAS_VOLUME)) |
1625 | break; | 1625 | break; |
1626 | 1626 | ||
1627 | volume = max(chip->left,chip->right); | 1627 | volume = max(chip->left,chip->right); |
@@ -1642,7 +1642,7 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip, | |||
1642 | case V4L2_CID_AUDIO_BALANCE: | 1642 | case V4L2_CID_AUDIO_BALANCE: |
1643 | { | 1643 | { |
1644 | int volume, balance; | 1644 | int volume, balance; |
1645 | if (!desc->flags & CHIP_HAS_VOLUME) | 1645 | if (!(desc->flags & CHIP_HAS_VOLUME)) |
1646 | break; | 1646 | break; |
1647 | 1647 | ||
1648 | volume = max(chip->left,chip->right); | 1648 | volume = max(chip->left,chip->right); |
@@ -1702,7 +1702,7 @@ static int chip_command(struct i2c_client *client, | |||
1702 | break; | 1702 | break; |
1703 | case V4L2_CID_AUDIO_VOLUME: | 1703 | case V4L2_CID_AUDIO_VOLUME: |
1704 | case V4L2_CID_AUDIO_BALANCE: | 1704 | case V4L2_CID_AUDIO_BALANCE: |
1705 | if (!desc->flags & CHIP_HAS_VOLUME) | 1705 | if (!(desc->flags & CHIP_HAS_VOLUME)) |
1706 | return -EINVAL; | 1706 | return -EINVAL; |
1707 | break; | 1707 | break; |
1708 | case V4L2_CID_AUDIO_BASS: | 1708 | case V4L2_CID_AUDIO_BASS: |
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 0b8fbad3c721..dc0da44a5af6 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c | |||
@@ -242,7 +242,7 @@ hauppauge_tuner[] = | |||
242 | { TUNER_ABSENT, "TCL M2523_3DBH_E"}, | 242 | { TUNER_ABSENT, "TCL M2523_3DBH_E"}, |
243 | { TUNER_ABSENT, "TCL M2523_3DIH_E"}, | 243 | { TUNER_ABSENT, "TCL M2523_3DIH_E"}, |
244 | { TUNER_ABSENT, "TCL MFPE05_2_U"}, | 244 | { TUNER_ABSENT, "TCL MFPE05_2_U"}, |
245 | { TUNER_ABSENT, "Philips FMD1216MEX"}, | 245 | { TUNER_PHILIPS_FMD1216ME_MK3, "Philips FMD1216MEX"}, |
246 | { TUNER_ABSENT, "Philips FRH2036B"}, | 246 | { TUNER_ABSENT, "Philips FRH2036B"}, |
247 | { TUNER_ABSENT, "Panasonic ENGF75_01GF"}, | 247 | { TUNER_ABSENT, "Panasonic ENGF75_01GF"}, |
248 | { TUNER_ABSENT, "MaxLinear MXL5005"}, | 248 | { TUNER_ABSENT, "MaxLinear MXL5005"}, |
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index c056ff6d810c..34deb68ae568 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -56,7 +56,6 @@ | |||
56 | #include <asm/pgtable.h> | 56 | #include <asm/pgtable.h> |
57 | #include <asm/io.h> | 57 | #include <asm/io.h> |
58 | #include <asm/div64.h> | 58 | #include <asm/div64.h> |
59 | #include <linux/video_decoder.h> | ||
60 | #define __OLD_VIDIOC_ /* To allow fixing old calls*/ | 59 | #define __OLD_VIDIOC_ /* To allow fixing old calls*/ |
61 | #include <media/v4l2-common.h> | 60 | #include <media/v4l2-common.h> |
62 | #include <media/v4l2-chip-ident.h> | 61 | #include <media/v4l2-chip-ident.h> |
@@ -82,108 +81,6 @@ MODULE_LICENSE("GPL"); | |||
82 | */ | 81 | */ |
83 | 82 | ||
84 | 83 | ||
85 | char *v4l2_norm_to_name(v4l2_std_id id) | ||
86 | { | ||
87 | char *name; | ||
88 | u32 myid = id; | ||
89 | |||
90 | /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle | ||
91 | 64 bit comparations. So, on that architecture, with some gcc variants, | ||
92 | compilation fails. Currently, the max value is 30bit wide. | ||
93 | */ | ||
94 | BUG_ON(myid != id); | ||
95 | |||
96 | switch (myid) { | ||
97 | case V4L2_STD_PAL: | ||
98 | name="PAL"; break; | ||
99 | case V4L2_STD_PAL_BG: | ||
100 | name="PAL-BG"; break; | ||
101 | case V4L2_STD_PAL_DK: | ||
102 | name="PAL-DK"; break; | ||
103 | case V4L2_STD_PAL_B: | ||
104 | name="PAL-B"; break; | ||
105 | case V4L2_STD_PAL_B1: | ||
106 | name="PAL-B1"; break; | ||
107 | case V4L2_STD_PAL_G: | ||
108 | name="PAL-G"; break; | ||
109 | case V4L2_STD_PAL_H: | ||
110 | name="PAL-H"; break; | ||
111 | case V4L2_STD_PAL_I: | ||
112 | name="PAL-I"; break; | ||
113 | case V4L2_STD_PAL_D: | ||
114 | name="PAL-D"; break; | ||
115 | case V4L2_STD_PAL_D1: | ||
116 | name="PAL-D1"; break; | ||
117 | case V4L2_STD_PAL_K: | ||
118 | name="PAL-K"; break; | ||
119 | case V4L2_STD_PAL_M: | ||
120 | name="PAL-M"; break; | ||
121 | case V4L2_STD_PAL_N: | ||
122 | name="PAL-N"; break; | ||
123 | case V4L2_STD_PAL_Nc: | ||
124 | name="PAL-Nc"; break; | ||
125 | case V4L2_STD_PAL_60: | ||
126 | name="PAL-60"; break; | ||
127 | case V4L2_STD_NTSC: | ||
128 | name="NTSC"; break; | ||
129 | case V4L2_STD_NTSC_M: | ||
130 | name="NTSC-M"; break; | ||
131 | case V4L2_STD_NTSC_M_JP: | ||
132 | name="NTSC-M-JP"; break; | ||
133 | case V4L2_STD_NTSC_443: | ||
134 | name="NTSC-443"; break; | ||
135 | case V4L2_STD_NTSC_M_KR: | ||
136 | name="NTSC-M-KR"; break; | ||
137 | case V4L2_STD_SECAM: | ||
138 | name="SECAM"; break; | ||
139 | case V4L2_STD_SECAM_DK: | ||
140 | name="SECAM-DK"; break; | ||
141 | case V4L2_STD_SECAM_B: | ||
142 | name="SECAM-B"; break; | ||
143 | case V4L2_STD_SECAM_D: | ||
144 | name="SECAM-D"; break; | ||
145 | case V4L2_STD_SECAM_G: | ||
146 | name="SECAM-G"; break; | ||
147 | case V4L2_STD_SECAM_H: | ||
148 | name="SECAM-H"; break; | ||
149 | case V4L2_STD_SECAM_K: | ||
150 | name="SECAM-K"; break; | ||
151 | case V4L2_STD_SECAM_K1: | ||
152 | name="SECAM-K1"; break; | ||
153 | case V4L2_STD_SECAM_L: | ||
154 | name="SECAM-L"; break; | ||
155 | case V4L2_STD_SECAM_LC: | ||
156 | name="SECAM-LC"; break; | ||
157 | default: | ||
158 | name="Unknown"; break; | ||
159 | } | ||
160 | |||
161 | return name; | ||
162 | } | ||
163 | |||
164 | /* Fill in the fields of a v4l2_standard structure according to the | ||
165 | 'id' and 'transmission' parameters. Returns negative on error. */ | ||
166 | int v4l2_video_std_construct(struct v4l2_standard *vs, | ||
167 | int id, char *name) | ||
168 | { | ||
169 | u32 index = vs->index; | ||
170 | |||
171 | memset(vs, 0, sizeof(struct v4l2_standard)); | ||
172 | vs->index = index; | ||
173 | vs->id = id; | ||
174 | if (id & V4L2_STD_525_60) { | ||
175 | vs->frameperiod.numerator = 1001; | ||
176 | vs->frameperiod.denominator = 30000; | ||
177 | vs->framelines = 525; | ||
178 | } else { | ||
179 | vs->frameperiod.numerator = 1; | ||
180 | vs->frameperiod.denominator = 25; | ||
181 | vs->framelines = 625; | ||
182 | } | ||
183 | strlcpy(vs->name,name,sizeof(vs->name)); | ||
184 | return 0; | ||
185 | } | ||
186 | |||
187 | /* ----------------------------------------------------------------- */ | 84 | /* ----------------------------------------------------------------- */ |
188 | /* priority handling */ | 85 | /* priority handling */ |
189 | 86 | ||
@@ -196,6 +93,7 @@ int v4l2_prio_init(struct v4l2_prio_state *global) | |||
196 | memset(global,0,sizeof(*global)); | 93 | memset(global,0,sizeof(*global)); |
197 | return 0; | 94 | return 0; |
198 | } | 95 | } |
96 | EXPORT_SYMBOL(v4l2_prio_init); | ||
199 | 97 | ||
200 | int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, | 98 | int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, |
201 | enum v4l2_priority new) | 99 | enum v4l2_priority new) |
@@ -211,11 +109,13 @@ int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, | |||
211 | *local = new; | 109 | *local = new; |
212 | return 0; | 110 | return 0; |
213 | } | 111 | } |
112 | EXPORT_SYMBOL(v4l2_prio_change); | ||
214 | 113 | ||
215 | int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local) | 114 | int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local) |
216 | { | 115 | { |
217 | return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT); | 116 | return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT); |
218 | } | 117 | } |
118 | EXPORT_SYMBOL(v4l2_prio_open); | ||
219 | 119 | ||
220 | int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local) | 120 | int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local) |
221 | { | 121 | { |
@@ -223,6 +123,7 @@ int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local) | |||
223 | atomic_dec(&global->prios[*local]); | 123 | atomic_dec(&global->prios[*local]); |
224 | return 0; | 124 | return 0; |
225 | } | 125 | } |
126 | EXPORT_SYMBOL(v4l2_prio_close); | ||
226 | 127 | ||
227 | enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global) | 128 | enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global) |
228 | { | 129 | { |
@@ -234,6 +135,7 @@ enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global) | |||
234 | return V4L2_PRIORITY_BACKGROUND; | 135 | return V4L2_PRIORITY_BACKGROUND; |
235 | return V4L2_PRIORITY_UNSET; | 136 | return V4L2_PRIORITY_UNSET; |
236 | } | 137 | } |
138 | EXPORT_SYMBOL(v4l2_prio_max); | ||
237 | 139 | ||
238 | int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local) | 140 | int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local) |
239 | { | 141 | { |
@@ -241,225 +143,7 @@ int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local) | |||
241 | return -EBUSY; | 143 | return -EBUSY; |
242 | return 0; | 144 | return 0; |
243 | } | 145 | } |
244 | 146 | EXPORT_SYMBOL(v4l2_prio_check); | |
245 | |||
246 | /* ----------------------------------------------------------------- */ | ||
247 | /* some arrays for pretty-printing debug messages of enum types */ | ||
248 | |||
249 | char *v4l2_field_names[] = { | ||
250 | [V4L2_FIELD_ANY] = "any", | ||
251 | [V4L2_FIELD_NONE] = "none", | ||
252 | [V4L2_FIELD_TOP] = "top", | ||
253 | [V4L2_FIELD_BOTTOM] = "bottom", | ||
254 | [V4L2_FIELD_INTERLACED] = "interlaced", | ||
255 | [V4L2_FIELD_SEQ_TB] = "seq-tb", | ||
256 | [V4L2_FIELD_SEQ_BT] = "seq-bt", | ||
257 | [V4L2_FIELD_ALTERNATE] = "alternate", | ||
258 | [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb", | ||
259 | [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt", | ||
260 | }; | ||
261 | |||
262 | char *v4l2_type_names[] = { | ||
263 | [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap", | ||
264 | [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over", | ||
265 | [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out", | ||
266 | [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap", | ||
267 | [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out", | ||
268 | [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap", | ||
269 | [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out", | ||
270 | [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over", | ||
271 | }; | ||
272 | |||
273 | |||
274 | #define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown" | ||
275 | |||
276 | /* ------------------------------------------------------------------ */ | ||
277 | /* debug help functions */ | ||
278 | |||
279 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
280 | static const char *v4l1_ioctls[] = { | ||
281 | [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP", | ||
282 | [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN", | ||
283 | [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN", | ||
284 | [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER", | ||
285 | [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER", | ||
286 | [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT", | ||
287 | [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT", | ||
288 | [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE", | ||
289 | [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN", | ||
290 | [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN", | ||
291 | [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF", | ||
292 | [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF", | ||
293 | [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY", | ||
294 | [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ", | ||
295 | [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ", | ||
296 | [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO", | ||
297 | [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO", | ||
298 | [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC", | ||
299 | [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE", | ||
300 | [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF", | ||
301 | [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT", | ||
302 | [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE", | ||
303 | [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE", | ||
304 | [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE", | ||
305 | [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE", | ||
306 | [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO", | ||
307 | [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE", | ||
308 | [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT", | ||
309 | [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT" | ||
310 | }; | ||
311 | #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls) | ||
312 | #endif | ||
313 | |||
314 | static const char *v4l2_ioctls[] = { | ||
315 | [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP", | ||
316 | [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED", | ||
317 | [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", | ||
318 | [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", | ||
319 | [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", | ||
320 | [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", | ||
321 | [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", | ||
322 | [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", | ||
323 | [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF", | ||
324 | [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY", | ||
325 | [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF", | ||
326 | [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF", | ||
327 | [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON", | ||
328 | [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF", | ||
329 | [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM", | ||
330 | [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM", | ||
331 | [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD", | ||
332 | [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD", | ||
333 | [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD", | ||
334 | [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT", | ||
335 | [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL", | ||
336 | [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL", | ||
337 | [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER", | ||
338 | [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER", | ||
339 | [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO", | ||
340 | [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO", | ||
341 | [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL", | ||
342 | [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU", | ||
343 | [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT", | ||
344 | [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT", | ||
345 | [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT", | ||
346 | [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT", | ||
347 | [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT", | ||
348 | [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT", | ||
349 | [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT", | ||
350 | [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR", | ||
351 | [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR", | ||
352 | [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY", | ||
353 | [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY", | ||
354 | [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP", | ||
355 | [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP", | ||
356 | [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP", | ||
357 | [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP", | ||
358 | [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP", | ||
359 | [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD", | ||
360 | [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT", | ||
361 | [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO", | ||
362 | [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT", | ||
363 | [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY", | ||
364 | [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY", | ||
365 | [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP", | ||
366 | [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS", | ||
367 | [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS", | ||
368 | [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS", | ||
369 | [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS", | ||
370 | #if 1 | ||
371 | [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES", | ||
372 | [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS", | ||
373 | [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX", | ||
374 | [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD", | ||
375 | [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD", | ||
376 | |||
377 | [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", | ||
378 | [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", | ||
379 | |||
380 | [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT", | ||
381 | #endif | ||
382 | }; | ||
383 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | ||
384 | |||
385 | static const char *v4l2_int_ioctls[] = { | ||
386 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
387 | [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES", | ||
388 | [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS", | ||
389 | [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM", | ||
390 | [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT", | ||
391 | [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT", | ||
392 | [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT", | ||
393 | [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE", | ||
394 | [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO", | ||
395 | [_IOC_NR(DECODER_INIT)] = "DECODER_INIT", | ||
396 | [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS", | ||
397 | [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP", | ||
398 | #endif | ||
399 | [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO", | ||
400 | |||
401 | [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR", | ||
402 | [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", | ||
403 | [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG", | ||
404 | |||
405 | [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE", | ||
406 | [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET", | ||
407 | [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ", | ||
408 | [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE", | ||
409 | [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA", | ||
410 | [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA", | ||
411 | [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ", | ||
412 | [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY", | ||
413 | [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING", | ||
414 | [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING", | ||
415 | [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING", | ||
416 | [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING", | ||
417 | [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ", | ||
418 | [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT", | ||
419 | [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT", | ||
420 | [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT", | ||
421 | }; | ||
422 | #define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls) | ||
423 | |||
424 | |||
425 | /* Common ioctl debug function. This function can be used by | ||
426 | external ioctl messages as well as internal V4L ioctl */ | ||
427 | void v4l_printk_ioctl(unsigned int cmd) | ||
428 | { | ||
429 | char *dir; | ||
430 | |||
431 | switch (_IOC_DIR(cmd)) { | ||
432 | case _IOC_NONE: dir = "--"; break; | ||
433 | case _IOC_READ: dir = "r-"; break; | ||
434 | case _IOC_WRITE: dir = "-w"; break; | ||
435 | case _IOC_READ | _IOC_WRITE: dir = "rw"; break; | ||
436 | default: dir = "*ERR*"; break; | ||
437 | } | ||
438 | switch (_IOC_TYPE(cmd)) { | ||
439 | case 'd': | ||
440 | printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n", | ||
441 | (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ? | ||
442 | v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); | ||
443 | break; | ||
444 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
445 | case 'v': | ||
446 | printk("v4l1 ioctl %s, dir=%s (0x%08x)\n", | ||
447 | (_IOC_NR(cmd) < V4L1_IOCTLS) ? | ||
448 | v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); | ||
449 | break; | ||
450 | #endif | ||
451 | case 'V': | ||
452 | printk("v4l2 ioctl %s, dir=%s (0x%08x)\n", | ||
453 | (_IOC_NR(cmd) < V4L2_IOCTLS) ? | ||
454 | v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); | ||
455 | break; | ||
456 | |||
457 | default: | ||
458 | printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n", | ||
459 | _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); | ||
460 | } | ||
461 | } | ||
462 | |||
463 | 147 | ||
464 | /* ----------------------------------------------------------------- */ | 148 | /* ----------------------------------------------------------------- */ |
465 | 149 | ||
@@ -488,6 +172,7 @@ int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, | |||
488 | } | 172 | } |
489 | return 0; | 173 | return 0; |
490 | } | 174 | } |
175 | EXPORT_SYMBOL(v4l2_ctrl_check); | ||
491 | 176 | ||
492 | /* Returns NULL or a character pointer array containing the menu for | 177 | /* Returns NULL or a character pointer array containing the menu for |
493 | the given control ID. The pointer array ends with a NULL pointer. | 178 | the given control ID. The pointer array ends with a NULL pointer. |
@@ -648,6 +333,7 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
648 | return NULL; | 333 | return NULL; |
649 | } | 334 | } |
650 | } | 335 | } |
336 | EXPORT_SYMBOL(v4l2_ctrl_get_menu); | ||
651 | 337 | ||
652 | /* Fill in a struct v4l2_queryctrl */ | 338 | /* Fill in a struct v4l2_queryctrl */ |
653 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) | 339 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) |
@@ -770,6 +456,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste | |||
770 | snprintf(qctrl->name, sizeof(qctrl->name), name); | 456 | snprintf(qctrl->name, sizeof(qctrl->name), name); |
771 | return 0; | 457 | return 0; |
772 | } | 458 | } |
459 | EXPORT_SYMBOL(v4l2_ctrl_query_fill); | ||
773 | 460 | ||
774 | /* Fill in a struct v4l2_queryctrl with standard values based on | 461 | /* Fill in a struct v4l2_queryctrl with standard values based on |
775 | the control ID. */ | 462 | the control ID. */ |
@@ -904,6 +591,7 @@ int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl) | |||
904 | return -EINVAL; | 591 | return -EINVAL; |
905 | } | 592 | } |
906 | } | 593 | } |
594 | EXPORT_SYMBOL(v4l2_ctrl_query_fill_std); | ||
907 | 595 | ||
908 | /* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and | 596 | /* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and |
909 | the menu. The qctrl pointer may be NULL, in which case it is ignored. */ | 597 | the menu. The qctrl pointer may be NULL, in which case it is ignored. */ |
@@ -922,6 +610,7 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc | |||
922 | qmenu->reserved = 0; | 610 | qmenu->reserved = 0; |
923 | return 0; | 611 | return 0; |
924 | } | 612 | } |
613 | EXPORT_SYMBOL(v4l2_ctrl_query_menu); | ||
925 | 614 | ||
926 | /* ctrl_classes points to an array of u32 pointers, the last element is | 615 | /* ctrl_classes points to an array of u32 pointers, the last element is |
927 | a NULL pointer. Each u32 array is a 0-terminated array of control IDs. | 616 | a NULL pointer. Each u32 array is a 0-terminated array of control IDs. |
@@ -972,7 +661,20 @@ u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id) | |||
972 | return 0; | 661 | return 0; |
973 | return **ctrl_classes; | 662 | return **ctrl_classes; |
974 | } | 663 | } |
664 | EXPORT_SYMBOL(v4l2_ctrl_next); | ||
975 | 665 | ||
666 | int v4l2_chip_match_host(u32 match_type, u32 match_chip) | ||
667 | { | ||
668 | switch (match_type) { | ||
669 | case V4L2_CHIP_MATCH_HOST: | ||
670 | return match_chip == 0; | ||
671 | default: | ||
672 | return 0; | ||
673 | } | ||
674 | } | ||
675 | EXPORT_SYMBOL(v4l2_chip_match_host); | ||
676 | |||
677 | #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) | ||
976 | int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_chip) | 678 | int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_chip) |
977 | { | 679 | { |
978 | switch (match_type) { | 680 | switch (match_type) { |
@@ -984,6 +686,7 @@ int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_c | |||
984 | return 0; | 686 | return 0; |
985 | } | 687 | } |
986 | } | 688 | } |
689 | EXPORT_SYMBOL(v4l2_chip_match_i2c_client); | ||
987 | 690 | ||
988 | int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip, | 691 | int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip, |
989 | u32 ident, u32 revision) | 692 | u32 ident, u32 revision) |
@@ -1000,16 +703,7 @@ int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chi | |||
1000 | } | 703 | } |
1001 | return 0; | 704 | return 0; |
1002 | } | 705 | } |
1003 | 706 | EXPORT_SYMBOL(v4l2_chip_ident_i2c_client); | |
1004 | int v4l2_chip_match_host(u32 match_type, u32 match_chip) | ||
1005 | { | ||
1006 | switch (match_type) { | ||
1007 | case V4L2_CHIP_MATCH_HOST: | ||
1008 | return match_chip == 0; | ||
1009 | default: | ||
1010 | return 0; | ||
1011 | } | ||
1012 | } | ||
1013 | 707 | ||
1014 | /* ----------------------------------------------------------------- */ | 708 | /* ----------------------------------------------------------------- */ |
1015 | 709 | ||
@@ -1038,38 +732,5 @@ int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver | |||
1038 | } | 732 | } |
1039 | return err != -ENOMEM ? 0 : err; | 733 | return err != -ENOMEM ? 0 : err; |
1040 | } | 734 | } |
1041 | |||
1042 | /* ----------------------------------------------------------------- */ | ||
1043 | |||
1044 | EXPORT_SYMBOL(v4l2_norm_to_name); | ||
1045 | EXPORT_SYMBOL(v4l2_video_std_construct); | ||
1046 | |||
1047 | EXPORT_SYMBOL(v4l2_prio_init); | ||
1048 | EXPORT_SYMBOL(v4l2_prio_change); | ||
1049 | EXPORT_SYMBOL(v4l2_prio_open); | ||
1050 | EXPORT_SYMBOL(v4l2_prio_close); | ||
1051 | EXPORT_SYMBOL(v4l2_prio_max); | ||
1052 | EXPORT_SYMBOL(v4l2_prio_check); | ||
1053 | |||
1054 | EXPORT_SYMBOL(v4l2_field_names); | ||
1055 | EXPORT_SYMBOL(v4l2_type_names); | ||
1056 | EXPORT_SYMBOL(v4l_printk_ioctl); | ||
1057 | |||
1058 | EXPORT_SYMBOL(v4l2_ctrl_next); | ||
1059 | EXPORT_SYMBOL(v4l2_ctrl_check); | ||
1060 | EXPORT_SYMBOL(v4l2_ctrl_get_menu); | ||
1061 | EXPORT_SYMBOL(v4l2_ctrl_query_menu); | ||
1062 | EXPORT_SYMBOL(v4l2_ctrl_query_fill); | ||
1063 | EXPORT_SYMBOL(v4l2_ctrl_query_fill_std); | ||
1064 | |||
1065 | EXPORT_SYMBOL(v4l2_chip_match_i2c_client); | ||
1066 | EXPORT_SYMBOL(v4l2_chip_ident_i2c_client); | ||
1067 | EXPORT_SYMBOL(v4l2_chip_match_host); | ||
1068 | |||
1069 | EXPORT_SYMBOL(v4l2_i2c_attach); | 735 | EXPORT_SYMBOL(v4l2_i2c_attach); |
1070 | 736 | #endif | |
1071 | /* | ||
1072 | * Local variables: | ||
1073 | * c-basic-offset: 8 | ||
1074 | * End: | ||
1075 | */ | ||
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index 80a14da9acef..eab79ffdf56a 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c | |||
@@ -147,7 +147,7 @@ void videobuf_queue_core_init(struct videobuf_queue *q, | |||
147 | /* Having implementations for abstract methods are mandatory */ | 147 | /* Having implementations for abstract methods are mandatory */ |
148 | BUG_ON(!q->int_ops); | 148 | BUG_ON(!q->int_ops); |
149 | 149 | ||
150 | mutex_init(&q->lock); | 150 | mutex_init(&q->vb_lock); |
151 | INIT_LIST_HEAD(&q->stream); | 151 | INIT_LIST_HEAD(&q->stream); |
152 | } | 152 | } |
153 | 153 | ||
@@ -189,7 +189,7 @@ int videobuf_queue_is_busy(struct videobuf_queue *q) | |||
189 | return 0; | 189 | return 0; |
190 | } | 190 | } |
191 | 191 | ||
192 | /* Locking: Caller holds q->lock */ | 192 | /* Locking: Caller holds q->vb_lock */ |
193 | void videobuf_queue_cancel(struct videobuf_queue *q) | 193 | void videobuf_queue_cancel(struct videobuf_queue *q) |
194 | { | 194 | { |
195 | unsigned long flags = 0; | 195 | unsigned long flags = 0; |
@@ -220,7 +220,7 @@ void videobuf_queue_cancel(struct videobuf_queue *q) | |||
220 | 220 | ||
221 | /* --------------------------------------------------------------------- */ | 221 | /* --------------------------------------------------------------------- */ |
222 | 222 | ||
223 | /* Locking: Caller holds q->lock */ | 223 | /* Locking: Caller holds q->vb_lock */ |
224 | enum v4l2_field videobuf_next_field(struct videobuf_queue *q) | 224 | enum v4l2_field videobuf_next_field(struct videobuf_queue *q) |
225 | { | 225 | { |
226 | enum v4l2_field field = q->field; | 226 | enum v4l2_field field = q->field; |
@@ -239,7 +239,7 @@ enum v4l2_field videobuf_next_field(struct videobuf_queue *q) | |||
239 | return field; | 239 | return field; |
240 | } | 240 | } |
241 | 241 | ||
242 | /* Locking: Caller holds q->lock */ | 242 | /* Locking: Caller holds q->vb_lock */ |
243 | static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, | 243 | static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, |
244 | struct videobuf_buffer *vb, enum v4l2_buf_type type) | 244 | struct videobuf_buffer *vb, enum v4l2_buf_type type) |
245 | { | 245 | { |
@@ -295,7 +295,7 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, | |||
295 | b->sequence = vb->field_count >> 1; | 295 | b->sequence = vb->field_count >> 1; |
296 | } | 296 | } |
297 | 297 | ||
298 | /* Locking: Caller holds q->lock */ | 298 | /* Locking: Caller holds q->vb_lock */ |
299 | static int __videobuf_mmap_free(struct videobuf_queue *q) | 299 | static int __videobuf_mmap_free(struct videobuf_queue *q) |
300 | { | 300 | { |
301 | int i; | 301 | int i; |
@@ -328,13 +328,13 @@ static int __videobuf_mmap_free(struct videobuf_queue *q) | |||
328 | int videobuf_mmap_free(struct videobuf_queue *q) | 328 | int videobuf_mmap_free(struct videobuf_queue *q) |
329 | { | 329 | { |
330 | int ret; | 330 | int ret; |
331 | mutex_lock(&q->lock); | 331 | mutex_lock(&q->vb_lock); |
332 | ret = __videobuf_mmap_free(q); | 332 | ret = __videobuf_mmap_free(q); |
333 | mutex_unlock(&q->lock); | 333 | mutex_unlock(&q->vb_lock); |
334 | return ret; | 334 | return ret; |
335 | } | 335 | } |
336 | 336 | ||
337 | /* Locking: Caller holds q->lock */ | 337 | /* Locking: Caller holds q->vb_lock */ |
338 | static int __videobuf_mmap_setup(struct videobuf_queue *q, | 338 | static int __videobuf_mmap_setup(struct videobuf_queue *q, |
339 | unsigned int bcount, unsigned int bsize, | 339 | unsigned int bcount, unsigned int bsize, |
340 | enum v4l2_memory memory) | 340 | enum v4l2_memory memory) |
@@ -384,9 +384,9 @@ int videobuf_mmap_setup(struct videobuf_queue *q, | |||
384 | enum v4l2_memory memory) | 384 | enum v4l2_memory memory) |
385 | { | 385 | { |
386 | int ret; | 386 | int ret; |
387 | mutex_lock(&q->lock); | 387 | mutex_lock(&q->vb_lock); |
388 | ret = __videobuf_mmap_setup(q, bcount, bsize, memory); | 388 | ret = __videobuf_mmap_setup(q, bcount, bsize, memory); |
389 | mutex_unlock(&q->lock); | 389 | mutex_unlock(&q->vb_lock); |
390 | return ret; | 390 | return ret; |
391 | } | 391 | } |
392 | 392 | ||
@@ -408,7 +408,7 @@ int videobuf_reqbufs(struct videobuf_queue *q, | |||
408 | return -EINVAL; | 408 | return -EINVAL; |
409 | } | 409 | } |
410 | 410 | ||
411 | mutex_lock(&q->lock); | 411 | mutex_lock(&q->vb_lock); |
412 | if (req->type != q->type) { | 412 | if (req->type != q->type) { |
413 | dprintk(1, "reqbufs: queue type invalid\n"); | 413 | dprintk(1, "reqbufs: queue type invalid\n"); |
414 | retval = -EINVAL; | 414 | retval = -EINVAL; |
@@ -444,7 +444,7 @@ int videobuf_reqbufs(struct videobuf_queue *q, | |||
444 | req->count = retval; | 444 | req->count = retval; |
445 | 445 | ||
446 | done: | 446 | done: |
447 | mutex_unlock(&q->lock); | 447 | mutex_unlock(&q->vb_lock); |
448 | return retval; | 448 | return retval; |
449 | } | 449 | } |
450 | 450 | ||
@@ -452,7 +452,7 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) | |||
452 | { | 452 | { |
453 | int ret = -EINVAL; | 453 | int ret = -EINVAL; |
454 | 454 | ||
455 | mutex_lock(&q->lock); | 455 | mutex_lock(&q->vb_lock); |
456 | if (unlikely(b->type != q->type)) { | 456 | if (unlikely(b->type != q->type)) { |
457 | dprintk(1, "querybuf: Wrong type.\n"); | 457 | dprintk(1, "querybuf: Wrong type.\n"); |
458 | goto done; | 458 | goto done; |
@@ -470,7 +470,7 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) | |||
470 | 470 | ||
471 | ret = 0; | 471 | ret = 0; |
472 | done: | 472 | done: |
473 | mutex_unlock(&q->lock); | 473 | mutex_unlock(&q->vb_lock); |
474 | return ret; | 474 | return ret; |
475 | } | 475 | } |
476 | 476 | ||
@@ -487,7 +487,7 @@ int videobuf_qbuf(struct videobuf_queue *q, | |||
487 | if (b->memory == V4L2_MEMORY_MMAP) | 487 | if (b->memory == V4L2_MEMORY_MMAP) |
488 | down_read(¤t->mm->mmap_sem); | 488 | down_read(¤t->mm->mmap_sem); |
489 | 489 | ||
490 | mutex_lock(&q->lock); | 490 | mutex_lock(&q->vb_lock); |
491 | retval = -EBUSY; | 491 | retval = -EBUSY; |
492 | if (q->reading) { | 492 | if (q->reading) { |
493 | dprintk(1, "qbuf: Reading running...\n"); | 493 | dprintk(1, "qbuf: Reading running...\n"); |
@@ -573,7 +573,7 @@ int videobuf_qbuf(struct videobuf_queue *q, | |||
573 | retval = 0; | 573 | retval = 0; |
574 | 574 | ||
575 | done: | 575 | done: |
576 | mutex_unlock(&q->lock); | 576 | mutex_unlock(&q->vb_lock); |
577 | 577 | ||
578 | if (b->memory == V4L2_MEMORY_MMAP) | 578 | if (b->memory == V4L2_MEMORY_MMAP) |
579 | up_read(¤t->mm->mmap_sem); | 579 | up_read(¤t->mm->mmap_sem); |
@@ -589,7 +589,7 @@ int videobuf_dqbuf(struct videobuf_queue *q, | |||
589 | 589 | ||
590 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 590 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
591 | 591 | ||
592 | mutex_lock(&q->lock); | 592 | mutex_lock(&q->vb_lock); |
593 | retval = -EBUSY; | 593 | retval = -EBUSY; |
594 | if (q->reading) { | 594 | if (q->reading) { |
595 | dprintk(1, "dqbuf: Reading running...\n"); | 595 | dprintk(1, "dqbuf: Reading running...\n"); |
@@ -632,7 +632,7 @@ int videobuf_dqbuf(struct videobuf_queue *q, | |||
632 | videobuf_status(q, b, buf, q->type); | 632 | videobuf_status(q, b, buf, q->type); |
633 | 633 | ||
634 | done: | 634 | done: |
635 | mutex_unlock(&q->lock); | 635 | mutex_unlock(&q->vb_lock); |
636 | return retval; | 636 | return retval; |
637 | } | 637 | } |
638 | 638 | ||
@@ -642,7 +642,7 @@ int videobuf_streamon(struct videobuf_queue *q) | |||
642 | unsigned long flags = 0; | 642 | unsigned long flags = 0; |
643 | int retval; | 643 | int retval; |
644 | 644 | ||
645 | mutex_lock(&q->lock); | 645 | mutex_lock(&q->vb_lock); |
646 | retval = -EBUSY; | 646 | retval = -EBUSY; |
647 | if (q->reading) | 647 | if (q->reading) |
648 | goto done; | 648 | goto done; |
@@ -659,11 +659,11 @@ int videobuf_streamon(struct videobuf_queue *q) | |||
659 | spin_unlock_irqrestore(q->irqlock, flags); | 659 | spin_unlock_irqrestore(q->irqlock, flags); |
660 | 660 | ||
661 | done: | 661 | done: |
662 | mutex_unlock(&q->lock); | 662 | mutex_unlock(&q->vb_lock); |
663 | return retval; | 663 | return retval; |
664 | } | 664 | } |
665 | 665 | ||
666 | /* Locking: Caller holds q->lock */ | 666 | /* Locking: Caller holds q->vb_lock */ |
667 | static int __videobuf_streamoff(struct videobuf_queue *q) | 667 | static int __videobuf_streamoff(struct videobuf_queue *q) |
668 | { | 668 | { |
669 | if (!q->streaming) | 669 | if (!q->streaming) |
@@ -679,14 +679,14 @@ int videobuf_streamoff(struct videobuf_queue *q) | |||
679 | { | 679 | { |
680 | int retval; | 680 | int retval; |
681 | 681 | ||
682 | mutex_lock(&q->lock); | 682 | mutex_lock(&q->vb_lock); |
683 | retval = __videobuf_streamoff(q); | 683 | retval = __videobuf_streamoff(q); |
684 | mutex_unlock(&q->lock); | 684 | mutex_unlock(&q->vb_lock); |
685 | 685 | ||
686 | return retval; | 686 | return retval; |
687 | } | 687 | } |
688 | 688 | ||
689 | /* Locking: Caller holds q->lock */ | 689 | /* Locking: Caller holds q->vb_lock */ |
690 | static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, | 690 | static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, |
691 | char __user *data, | 691 | char __user *data, |
692 | size_t count, loff_t *ppos) | 692 | size_t count, loff_t *ppos) |
@@ -745,7 +745,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
745 | 745 | ||
746 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 746 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
747 | 747 | ||
748 | mutex_lock(&q->lock); | 748 | mutex_lock(&q->vb_lock); |
749 | 749 | ||
750 | nbufs = 1; size = 0; | 750 | nbufs = 1; size = 0; |
751 | q->ops->buf_setup(q, &nbufs, &size); | 751 | q->ops->buf_setup(q, &nbufs, &size); |
@@ -817,11 +817,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
817 | } | 817 | } |
818 | 818 | ||
819 | done: | 819 | done: |
820 | mutex_unlock(&q->lock); | 820 | mutex_unlock(&q->vb_lock); |
821 | return retval; | 821 | return retval; |
822 | } | 822 | } |
823 | 823 | ||
824 | /* Locking: Caller holds q->lock */ | 824 | /* Locking: Caller holds q->vb_lock */ |
825 | static int __videobuf_read_start(struct videobuf_queue *q) | 825 | static int __videobuf_read_start(struct videobuf_queue *q) |
826 | { | 826 | { |
827 | enum v4l2_field field; | 827 | enum v4l2_field field; |
@@ -882,23 +882,23 @@ int videobuf_read_start(struct videobuf_queue *q) | |||
882 | { | 882 | { |
883 | int rc; | 883 | int rc; |
884 | 884 | ||
885 | mutex_lock(&q->lock); | 885 | mutex_lock(&q->vb_lock); |
886 | rc = __videobuf_read_start(q); | 886 | rc = __videobuf_read_start(q); |
887 | mutex_unlock(&q->lock); | 887 | mutex_unlock(&q->vb_lock); |
888 | 888 | ||
889 | return rc; | 889 | return rc; |
890 | } | 890 | } |
891 | 891 | ||
892 | void videobuf_read_stop(struct videobuf_queue *q) | 892 | void videobuf_read_stop(struct videobuf_queue *q) |
893 | { | 893 | { |
894 | mutex_lock(&q->lock); | 894 | mutex_lock(&q->vb_lock); |
895 | __videobuf_read_stop(q); | 895 | __videobuf_read_stop(q); |
896 | mutex_unlock(&q->lock); | 896 | mutex_unlock(&q->vb_lock); |
897 | } | 897 | } |
898 | 898 | ||
899 | void videobuf_stop(struct videobuf_queue *q) | 899 | void videobuf_stop(struct videobuf_queue *q) |
900 | { | 900 | { |
901 | mutex_lock(&q->lock); | 901 | mutex_lock(&q->vb_lock); |
902 | 902 | ||
903 | if (q->streaming) | 903 | if (q->streaming) |
904 | __videobuf_streamoff(q); | 904 | __videobuf_streamoff(q); |
@@ -906,7 +906,7 @@ void videobuf_stop(struct videobuf_queue *q) | |||
906 | if (q->reading) | 906 | if (q->reading) |
907 | __videobuf_read_stop(q); | 907 | __videobuf_read_stop(q); |
908 | 908 | ||
909 | mutex_unlock(&q->lock); | 909 | mutex_unlock(&q->vb_lock); |
910 | } | 910 | } |
911 | 911 | ||
912 | 912 | ||
@@ -920,7 +920,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
920 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 920 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
921 | 921 | ||
922 | dprintk(2, "%s\n", __FUNCTION__); | 922 | dprintk(2, "%s\n", __FUNCTION__); |
923 | mutex_lock(&q->lock); | 923 | mutex_lock(&q->vb_lock); |
924 | retval = -EBUSY; | 924 | retval = -EBUSY; |
925 | if (q->streaming) | 925 | if (q->streaming) |
926 | goto done; | 926 | goto done; |
@@ -980,7 +980,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
980 | } | 980 | } |
981 | 981 | ||
982 | done: | 982 | done: |
983 | mutex_unlock(&q->lock); | 983 | mutex_unlock(&q->vb_lock); |
984 | return retval; | 984 | return retval; |
985 | } | 985 | } |
986 | 986 | ||
@@ -991,7 +991,7 @@ unsigned int videobuf_poll_stream(struct file *file, | |||
991 | struct videobuf_buffer *buf = NULL; | 991 | struct videobuf_buffer *buf = NULL; |
992 | unsigned int rc = 0; | 992 | unsigned int rc = 0; |
993 | 993 | ||
994 | mutex_lock(&q->lock); | 994 | mutex_lock(&q->vb_lock); |
995 | if (q->streaming) { | 995 | if (q->streaming) { |
996 | if (!list_empty(&q->stream)) | 996 | if (!list_empty(&q->stream)) |
997 | buf = list_entry(q->stream.next, | 997 | buf = list_entry(q->stream.next, |
@@ -1019,7 +1019,7 @@ unsigned int videobuf_poll_stream(struct file *file, | |||
1019 | buf->state == VIDEOBUF_ERROR) | 1019 | buf->state == VIDEOBUF_ERROR) |
1020 | rc = POLLIN|POLLRDNORM; | 1020 | rc = POLLIN|POLLRDNORM; |
1021 | } | 1021 | } |
1022 | mutex_unlock(&q->lock); | 1022 | mutex_unlock(&q->vb_lock); |
1023 | return rc; | 1023 | return rc; |
1024 | } | 1024 | } |
1025 | 1025 | ||
@@ -1030,10 +1030,10 @@ int videobuf_mmap_mapper(struct videobuf_queue *q, | |||
1030 | 1030 | ||
1031 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 1031 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
1032 | 1032 | ||
1033 | mutex_lock(&q->lock); | 1033 | mutex_lock(&q->vb_lock); |
1034 | retval = CALL(q, mmap_mapper, q, vma); | 1034 | retval = CALL(q, mmap_mapper, q, vma); |
1035 | q->is_mmapped = 1; | 1035 | q->is_mmapped = 1; |
1036 | mutex_unlock(&q->lock); | 1036 | mutex_unlock(&q->vb_lock); |
1037 | 1037 | ||
1038 | return retval; | 1038 | return retval; |
1039 | } | 1039 | } |
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 98efd7ab1f50..53fed4b74ce9 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
@@ -356,7 +356,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
356 | map->count--; | 356 | map->count--; |
357 | if (0 == map->count) { | 357 | if (0 == map->count) { |
358 | dprintk(1,"munmap %p q=%p\n",map,q); | 358 | dprintk(1,"munmap %p q=%p\n",map,q); |
359 | mutex_lock(&q->lock); | 359 | mutex_lock(&q->vb_lock); |
360 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 360 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
361 | if (NULL == q->bufs[i]) | 361 | if (NULL == q->bufs[i]) |
362 | continue; | 362 | continue; |
@@ -373,7 +373,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
373 | q->bufs[i]->baddr = 0; | 373 | q->bufs[i]->baddr = 0; |
374 | q->ops->buf_release(q,q->bufs[i]); | 374 | q->ops->buf_release(q,q->bufs[i]); |
375 | } | 375 | } |
376 | mutex_unlock(&q->lock); | 376 | mutex_unlock(&q->vb_lock); |
377 | kfree(map); | 377 | kfree(map); |
378 | } | 378 | } |
379 | return; | 379 | return; |
diff --git a/drivers/media/video/videobuf-vmalloc.c b/drivers/media/video/videobuf-vmalloc.c index 9b3898347ca5..5266ecc91dab 100644 --- a/drivers/media/video/videobuf-vmalloc.c +++ b/drivers/media/video/videobuf-vmalloc.c | |||
@@ -70,7 +70,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
70 | map->count--; | 70 | map->count--; |
71 | if (0 == map->count) { | 71 | if (0 == map->count) { |
72 | dprintk(1,"munmap %p q=%p\n",map,q); | 72 | dprintk(1,"munmap %p q=%p\n",map,q); |
73 | mutex_lock(&q->lock); | 73 | mutex_lock(&q->vb_lock); |
74 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 74 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
75 | if (NULL == q->bufs[i]) | 75 | if (NULL == q->bufs[i]) |
76 | continue; | 76 | continue; |
@@ -83,7 +83,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
83 | q->bufs[i]->map = NULL; | 83 | q->bufs[i]->map = NULL; |
84 | q->bufs[i]->baddr = 0; | 84 | q->bufs[i]->baddr = 0; |
85 | } | 85 | } |
86 | mutex_unlock(&q->lock); | 86 | mutex_unlock(&q->vb_lock); |
87 | kfree(map); | 87 | kfree(map); |
88 | } | 88 | } |
89 | return; | 89 | return; |
@@ -107,7 +107,7 @@ static struct vm_operations_struct videobuf_vm_ops = | |||
107 | 107 | ||
108 | static void *__videobuf_alloc(size_t size) | 108 | static void *__videobuf_alloc(size_t size) |
109 | { | 109 | { |
110 | struct videbuf_vmalloc_memory *mem; | 110 | struct videobuf_vmalloc_memory *mem; |
111 | struct videobuf_buffer *vb; | 111 | struct videobuf_buffer *vb; |
112 | 112 | ||
113 | vb = kzalloc(size+sizeof(*mem),GFP_KERNEL); | 113 | vb = kzalloc(size+sizeof(*mem),GFP_KERNEL); |
@@ -127,9 +127,7 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
127 | struct v4l2_framebuffer *fbuf) | 127 | struct v4l2_framebuffer *fbuf) |
128 | { | 128 | { |
129 | int pages; | 129 | int pages; |
130 | 130 | struct videobuf_vmalloc_memory *mem=vb->priv; | |
131 | struct videbuf_vmalloc_memory *mem=vb->priv; | ||
132 | |||
133 | 131 | ||
134 | BUG_ON(!mem); | 132 | BUG_ON(!mem); |
135 | 133 | ||
@@ -195,7 +193,7 @@ static int __videobuf_mmap_free(struct videobuf_queue *q) | |||
195 | static int __videobuf_mmap_mapper(struct videobuf_queue *q, | 193 | static int __videobuf_mmap_mapper(struct videobuf_queue *q, |
196 | struct vm_area_struct *vma) | 194 | struct vm_area_struct *vma) |
197 | { | 195 | { |
198 | struct videbuf_vmalloc_memory *mem; | 196 | struct videobuf_vmalloc_memory *mem; |
199 | struct videobuf_mapping *map; | 197 | struct videobuf_mapping *map; |
200 | unsigned int first; | 198 | unsigned int first; |
201 | int retval; | 199 | int retval; |
@@ -267,7 +265,7 @@ static int __videobuf_copy_to_user ( struct videobuf_queue *q, | |||
267 | char __user *data, size_t count, | 265 | char __user *data, size_t count, |
268 | int nonblocking ) | 266 | int nonblocking ) |
269 | { | 267 | { |
270 | struct videbuf_vmalloc_memory *mem=q->read_buf->priv; | 268 | struct videobuf_vmalloc_memory *mem=q->read_buf->priv; |
271 | BUG_ON (!mem); | 269 | BUG_ON (!mem); |
272 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); | 270 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); |
273 | 271 | ||
@@ -288,7 +286,7 @@ static int __videobuf_copy_stream ( struct videobuf_queue *q, | |||
288 | int vbihack, int nonblocking ) | 286 | int vbihack, int nonblocking ) |
289 | { | 287 | { |
290 | unsigned int *fc; | 288 | unsigned int *fc; |
291 | struct videbuf_vmalloc_memory *mem=q->read_buf->priv; | 289 | struct videobuf_vmalloc_memory *mem=q->read_buf->priv; |
292 | BUG_ON (!mem); | 290 | BUG_ON (!mem); |
293 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); | 291 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); |
294 | 292 | ||
@@ -341,7 +339,7 @@ EXPORT_SYMBOL_GPL(videobuf_queue_vmalloc_init); | |||
341 | 339 | ||
342 | void *videobuf_to_vmalloc (struct videobuf_buffer *buf) | 340 | void *videobuf_to_vmalloc (struct videobuf_buffer *buf) |
343 | { | 341 | { |
344 | struct videbuf_vmalloc_memory *mem=buf->priv; | 342 | struct videobuf_vmalloc_memory *mem=buf->priv; |
345 | BUG_ON (!mem); | 343 | BUG_ON (!mem); |
346 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); | 344 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); |
347 | 345 | ||
@@ -351,7 +349,7 @@ EXPORT_SYMBOL_GPL(videobuf_to_vmalloc); | |||
351 | 349 | ||
352 | void videobuf_vmalloc_free (struct videobuf_buffer *buf) | 350 | void videobuf_vmalloc_free (struct videobuf_buffer *buf) |
353 | { | 351 | { |
354 | struct videbuf_vmalloc_memory *mem=buf->priv; | 352 | struct videobuf_vmalloc_memory *mem=buf->priv; |
355 | BUG_ON (!mem); | 353 | BUG_ON (!mem); |
356 | 354 | ||
357 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); | 355 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); |
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 28655f8983c6..0d9b63762a48 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -46,10 +46,373 @@ | |||
46 | #include <linux/videodev.h> | 46 | #include <linux/videodev.h> |
47 | #endif | 47 | #endif |
48 | #include <media/v4l2-common.h> | 48 | #include <media/v4l2-common.h> |
49 | #include <linux/video_decoder.h> | ||
49 | 50 | ||
50 | #define VIDEO_NUM_DEVICES 256 | 51 | #define VIDEO_NUM_DEVICES 256 |
51 | #define VIDEO_NAME "video4linux" | 52 | #define VIDEO_NAME "video4linux" |
52 | 53 | ||
54 | /* video4linux standard ID conversion to standard name | ||
55 | */ | ||
56 | char *v4l2_norm_to_name(v4l2_std_id id) | ||
57 | { | ||
58 | char *name; | ||
59 | u32 myid = id; | ||
60 | |||
61 | /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle | ||
62 | 64 bit comparations. So, on that architecture, with some gcc | ||
63 | variants, compilation fails. Currently, the max value is 30bit wide. | ||
64 | */ | ||
65 | BUG_ON(myid != id); | ||
66 | |||
67 | switch (myid) { | ||
68 | case V4L2_STD_PAL: | ||
69 | name = "PAL"; | ||
70 | break; | ||
71 | case V4L2_STD_PAL_BG: | ||
72 | name = "PAL-BG"; | ||
73 | break; | ||
74 | case V4L2_STD_PAL_DK: | ||
75 | name = "PAL-DK"; | ||
76 | break; | ||
77 | case V4L2_STD_PAL_B: | ||
78 | name = "PAL-B"; | ||
79 | break; | ||
80 | case V4L2_STD_PAL_B1: | ||
81 | name = "PAL-B1"; | ||
82 | break; | ||
83 | case V4L2_STD_PAL_G: | ||
84 | name = "PAL-G"; | ||
85 | break; | ||
86 | case V4L2_STD_PAL_H: | ||
87 | name = "PAL-H"; | ||
88 | break; | ||
89 | case V4L2_STD_PAL_I: | ||
90 | name = "PAL-I"; | ||
91 | break; | ||
92 | case V4L2_STD_PAL_D: | ||
93 | name = "PAL-D"; | ||
94 | break; | ||
95 | case V4L2_STD_PAL_D1: | ||
96 | name = "PAL-D1"; | ||
97 | break; | ||
98 | case V4L2_STD_PAL_K: | ||
99 | name = "PAL-K"; | ||
100 | break; | ||
101 | case V4L2_STD_PAL_M: | ||
102 | name = "PAL-M"; | ||
103 | break; | ||
104 | case V4L2_STD_PAL_N: | ||
105 | name = "PAL-N"; | ||
106 | break; | ||
107 | case V4L2_STD_PAL_Nc: | ||
108 | name = "PAL-Nc"; | ||
109 | break; | ||
110 | case V4L2_STD_PAL_60: | ||
111 | name = "PAL-60"; | ||
112 | break; | ||
113 | case V4L2_STD_NTSC: | ||
114 | name = "NTSC"; | ||
115 | break; | ||
116 | case V4L2_STD_NTSC_M: | ||
117 | name = "NTSC-M"; | ||
118 | break; | ||
119 | case V4L2_STD_NTSC_M_JP: | ||
120 | name = "NTSC-M-JP"; | ||
121 | break; | ||
122 | case V4L2_STD_NTSC_443: | ||
123 | name = "NTSC-443"; | ||
124 | break; | ||
125 | case V4L2_STD_NTSC_M_KR: | ||
126 | name = "NTSC-M-KR"; | ||
127 | break; | ||
128 | case V4L2_STD_SECAM: | ||
129 | name = "SECAM"; | ||
130 | break; | ||
131 | case V4L2_STD_SECAM_DK: | ||
132 | name = "SECAM-DK"; | ||
133 | break; | ||
134 | case V4L2_STD_SECAM_B: | ||
135 | name = "SECAM-B"; | ||
136 | break; | ||
137 | case V4L2_STD_SECAM_D: | ||
138 | name = "SECAM-D"; | ||
139 | break; | ||
140 | case V4L2_STD_SECAM_G: | ||
141 | name = "SECAM-G"; | ||
142 | break; | ||
143 | case V4L2_STD_SECAM_H: | ||
144 | name = "SECAM-H"; | ||
145 | break; | ||
146 | case V4L2_STD_SECAM_K: | ||
147 | name = "SECAM-K"; | ||
148 | break; | ||
149 | case V4L2_STD_SECAM_K1: | ||
150 | name = "SECAM-K1"; | ||
151 | break; | ||
152 | case V4L2_STD_SECAM_L: | ||
153 | name = "SECAM-L"; | ||
154 | break; | ||
155 | case V4L2_STD_SECAM_LC: | ||
156 | name = "SECAM-LC"; | ||
157 | break; | ||
158 | default: | ||
159 | name = "Unknown"; | ||
160 | break; | ||
161 | } | ||
162 | |||
163 | return name; | ||
164 | } | ||
165 | EXPORT_SYMBOL(v4l2_norm_to_name); | ||
166 | |||
167 | /* Fill in the fields of a v4l2_standard structure according to the | ||
168 | 'id' and 'transmission' parameters. Returns negative on error. */ | ||
169 | int v4l2_video_std_construct(struct v4l2_standard *vs, | ||
170 | int id, char *name) | ||
171 | { | ||
172 | u32 index = vs->index; | ||
173 | |||
174 | memset(vs, 0, sizeof(struct v4l2_standard)); | ||
175 | vs->index = index; | ||
176 | vs->id = id; | ||
177 | if (id & V4L2_STD_525_60) { | ||
178 | vs->frameperiod.numerator = 1001; | ||
179 | vs->frameperiod.denominator = 30000; | ||
180 | vs->framelines = 525; | ||
181 | } else { | ||
182 | vs->frameperiod.numerator = 1; | ||
183 | vs->frameperiod.denominator = 25; | ||
184 | vs->framelines = 625; | ||
185 | } | ||
186 | strlcpy(vs->name, name, sizeof(vs->name)); | ||
187 | return 0; | ||
188 | } | ||
189 | EXPORT_SYMBOL(v4l2_video_std_construct); | ||
190 | |||
191 | /* ----------------------------------------------------------------- */ | ||
192 | /* some arrays for pretty-printing debug messages of enum types */ | ||
193 | |||
194 | char *v4l2_field_names[] = { | ||
195 | [V4L2_FIELD_ANY] = "any", | ||
196 | [V4L2_FIELD_NONE] = "none", | ||
197 | [V4L2_FIELD_TOP] = "top", | ||
198 | [V4L2_FIELD_BOTTOM] = "bottom", | ||
199 | [V4L2_FIELD_INTERLACED] = "interlaced", | ||
200 | [V4L2_FIELD_SEQ_TB] = "seq-tb", | ||
201 | [V4L2_FIELD_SEQ_BT] = "seq-bt", | ||
202 | [V4L2_FIELD_ALTERNATE] = "alternate", | ||
203 | [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb", | ||
204 | [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt", | ||
205 | }; | ||
206 | EXPORT_SYMBOL(v4l2_field_names); | ||
207 | |||
208 | char *v4l2_type_names[] = { | ||
209 | [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap", | ||
210 | [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over", | ||
211 | [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out", | ||
212 | [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap", | ||
213 | [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out", | ||
214 | [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap", | ||
215 | [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out", | ||
216 | [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over", | ||
217 | }; | ||
218 | EXPORT_SYMBOL(v4l2_type_names); | ||
219 | |||
220 | static char *v4l2_memory_names[] = { | ||
221 | [V4L2_MEMORY_MMAP] = "mmap", | ||
222 | [V4L2_MEMORY_USERPTR] = "userptr", | ||
223 | [V4L2_MEMORY_OVERLAY] = "overlay", | ||
224 | }; | ||
225 | |||
226 | #define prt_names(a, arr) ((((a) >= 0) && ((a) < ARRAY_SIZE(arr))) ? \ | ||
227 | arr[a] : "unknown") | ||
228 | |||
229 | /* ------------------------------------------------------------------ */ | ||
230 | /* debug help functions */ | ||
231 | |||
232 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
233 | static const char *v4l1_ioctls[] = { | ||
234 | [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP", | ||
235 | [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN", | ||
236 | [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN", | ||
237 | [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER", | ||
238 | [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER", | ||
239 | [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT", | ||
240 | [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT", | ||
241 | [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE", | ||
242 | [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN", | ||
243 | [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN", | ||
244 | [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF", | ||
245 | [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF", | ||
246 | [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY", | ||
247 | [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ", | ||
248 | [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ", | ||
249 | [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO", | ||
250 | [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO", | ||
251 | [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC", | ||
252 | [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE", | ||
253 | [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF", | ||
254 | [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT", | ||
255 | [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE", | ||
256 | [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE", | ||
257 | [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE", | ||
258 | [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE", | ||
259 | [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO", | ||
260 | [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE", | ||
261 | [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT", | ||
262 | [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT" | ||
263 | }; | ||
264 | #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls) | ||
265 | #endif | ||
266 | |||
267 | static const char *v4l2_ioctls[] = { | ||
268 | [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP", | ||
269 | [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED", | ||
270 | [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", | ||
271 | [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", | ||
272 | [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", | ||
273 | [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", | ||
274 | [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", | ||
275 | [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", | ||
276 | [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF", | ||
277 | [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY", | ||
278 | [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF", | ||
279 | [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF", | ||
280 | [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON", | ||
281 | [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF", | ||
282 | [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM", | ||
283 | [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM", | ||
284 | [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD", | ||
285 | [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD", | ||
286 | [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD", | ||
287 | [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT", | ||
288 | [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL", | ||
289 | [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL", | ||
290 | [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER", | ||
291 | [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER", | ||
292 | [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO", | ||
293 | [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO", | ||
294 | [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL", | ||
295 | [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU", | ||
296 | [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT", | ||
297 | [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT", | ||
298 | [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT", | ||
299 | [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT", | ||
300 | [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT", | ||
301 | [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT", | ||
302 | [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT", | ||
303 | [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR", | ||
304 | [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR", | ||
305 | [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY", | ||
306 | [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY", | ||
307 | [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP", | ||
308 | [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP", | ||
309 | [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP", | ||
310 | [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP", | ||
311 | [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP", | ||
312 | [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD", | ||
313 | [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT", | ||
314 | [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO", | ||
315 | [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT", | ||
316 | [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY", | ||
317 | [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY", | ||
318 | [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP", | ||
319 | [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS", | ||
320 | [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS", | ||
321 | [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS", | ||
322 | [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS", | ||
323 | #if 1 | ||
324 | [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES", | ||
325 | [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS", | ||
326 | [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX", | ||
327 | [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD", | ||
328 | [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD", | ||
329 | |||
330 | [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", | ||
331 | [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", | ||
332 | |||
333 | [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT", | ||
334 | #endif | ||
335 | }; | ||
336 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | ||
337 | |||
338 | static const char *v4l2_int_ioctls[] = { | ||
339 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
340 | [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES", | ||
341 | [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS", | ||
342 | [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM", | ||
343 | [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT", | ||
344 | [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT", | ||
345 | [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT", | ||
346 | [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE", | ||
347 | [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO", | ||
348 | [_IOC_NR(DECODER_INIT)] = "DECODER_INIT", | ||
349 | [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS", | ||
350 | [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP", | ||
351 | #endif | ||
352 | [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO", | ||
353 | |||
354 | [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR", | ||
355 | [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", | ||
356 | [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG", | ||
357 | |||
358 | [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE", | ||
359 | [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET", | ||
360 | [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ", | ||
361 | [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE", | ||
362 | [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA", | ||
363 | [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA", | ||
364 | [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ", | ||
365 | [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY", | ||
366 | [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING", | ||
367 | [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING", | ||
368 | [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING", | ||
369 | [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING", | ||
370 | [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ", | ||
371 | [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT", | ||
372 | [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT", | ||
373 | [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT", | ||
374 | }; | ||
375 | #define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls) | ||
376 | |||
377 | /* Common ioctl debug function. This function can be used by | ||
378 | external ioctl messages as well as internal V4L ioctl */ | ||
379 | void v4l_printk_ioctl(unsigned int cmd) | ||
380 | { | ||
381 | char *dir; | ||
382 | |||
383 | switch (_IOC_DIR(cmd)) { | ||
384 | case _IOC_NONE: dir = "--"; break; | ||
385 | case _IOC_READ: dir = "r-"; break; | ||
386 | case _IOC_WRITE: dir = "-w"; break; | ||
387 | case _IOC_READ | _IOC_WRITE: dir = "rw"; break; | ||
388 | default: dir = "*ERR*"; break; | ||
389 | } | ||
390 | switch (_IOC_TYPE(cmd)) { | ||
391 | case 'd': | ||
392 | printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n", | ||
393 | (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ? | ||
394 | v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); | ||
395 | break; | ||
396 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
397 | case 'v': | ||
398 | printk("v4l1 ioctl %s, dir=%s (0x%08x)\n", | ||
399 | (_IOC_NR(cmd) < V4L1_IOCTLS) ? | ||
400 | v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); | ||
401 | break; | ||
402 | #endif | ||
403 | case 'V': | ||
404 | printk("v4l2 ioctl %s, dir=%s (0x%08x)\n", | ||
405 | (_IOC_NR(cmd) < V4L2_IOCTLS) ? | ||
406 | v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); | ||
407 | break; | ||
408 | |||
409 | default: | ||
410 | printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n", | ||
411 | _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); | ||
412 | } | ||
413 | } | ||
414 | EXPORT_SYMBOL(v4l_printk_ioctl); | ||
415 | |||
53 | /* | 416 | /* |
54 | * sysfs stuff | 417 | * sysfs stuff |
55 | */ | 418 | */ |
@@ -69,11 +432,13 @@ struct video_device *video_device_alloc(void) | |||
69 | vfd = kzalloc(sizeof(*vfd),GFP_KERNEL); | 432 | vfd = kzalloc(sizeof(*vfd),GFP_KERNEL); |
70 | return vfd; | 433 | return vfd; |
71 | } | 434 | } |
435 | EXPORT_SYMBOL(video_device_alloc); | ||
72 | 436 | ||
73 | void video_device_release(struct video_device *vfd) | 437 | void video_device_release(struct video_device *vfd) |
74 | { | 438 | { |
75 | kfree(vfd); | 439 | kfree(vfd); |
76 | } | 440 | } |
441 | EXPORT_SYMBOL(video_device_release); | ||
77 | 442 | ||
78 | static void video_release(struct device *cd) | 443 | static void video_release(struct device *cd) |
79 | { | 444 | { |
@@ -110,6 +475,7 @@ struct video_device* video_devdata(struct file *file) | |||
110 | { | 475 | { |
111 | return video_device[iminor(file->f_path.dentry->d_inode)]; | 476 | return video_device[iminor(file->f_path.dentry->d_inode)]; |
112 | } | 477 | } |
478 | EXPORT_SYMBOL(video_devdata); | ||
113 | 479 | ||
114 | /* | 480 | /* |
115 | * Open a video device - FIXME: Obsoleted | 481 | * Open a video device - FIXME: Obsoleted |
@@ -278,6 +644,7 @@ out: | |||
278 | kfree(mbuf); | 644 | kfree(mbuf); |
279 | return err; | 645 | return err; |
280 | } | 646 | } |
647 | EXPORT_SYMBOL(video_usercopy); | ||
281 | 648 | ||
282 | /* | 649 | /* |
283 | * open/release helper functions -- handle exclusive opens | 650 | * open/release helper functions -- handle exclusive opens |
@@ -297,6 +664,7 @@ int video_exclusive_open(struct inode *inode, struct file *file) | |||
297 | mutex_unlock(&vfl->lock); | 664 | mutex_unlock(&vfl->lock); |
298 | return retval; | 665 | return retval; |
299 | } | 666 | } |
667 | EXPORT_SYMBOL(video_exclusive_open); | ||
300 | 668 | ||
301 | int video_exclusive_release(struct inode *inode, struct file *file) | 669 | int video_exclusive_release(struct inode *inode, struct file *file) |
302 | { | 670 | { |
@@ -305,41 +673,7 @@ int video_exclusive_release(struct inode *inode, struct file *file) | |||
305 | vfl->users--; | 673 | vfl->users--; |
306 | return 0; | 674 | return 0; |
307 | } | 675 | } |
308 | 676 | EXPORT_SYMBOL(video_exclusive_release); | |
309 | static char *v4l2_memory_names[] = { | ||
310 | [V4L2_MEMORY_MMAP] = "mmap", | ||
311 | [V4L2_MEMORY_USERPTR] = "userptr", | ||
312 | [V4L2_MEMORY_OVERLAY] = "overlay", | ||
313 | }; | ||
314 | |||
315 | |||
316 | /* FIXME: Those stuff are replicated also on v4l2-common.c */ | ||
317 | static char *v4l2_type_names_FIXME[] = { | ||
318 | [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap", | ||
319 | [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over", | ||
320 | [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out", | ||
321 | [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap", | ||
322 | [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out", | ||
323 | [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out", | ||
324 | [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-capture", | ||
325 | [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over", | ||
326 | [V4L2_BUF_TYPE_PRIVATE] = "private", | ||
327 | }; | ||
328 | |||
329 | static char *v4l2_field_names_FIXME[] = { | ||
330 | [V4L2_FIELD_ANY] = "any", | ||
331 | [V4L2_FIELD_NONE] = "none", | ||
332 | [V4L2_FIELD_TOP] = "top", | ||
333 | [V4L2_FIELD_BOTTOM] = "bottom", | ||
334 | [V4L2_FIELD_INTERLACED] = "interlaced", | ||
335 | [V4L2_FIELD_SEQ_TB] = "seq-tb", | ||
336 | [V4L2_FIELD_SEQ_BT] = "seq-bt", | ||
337 | [V4L2_FIELD_ALTERNATE] = "alternate", | ||
338 | [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb", | ||
339 | [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt", | ||
340 | }; | ||
341 | |||
342 | #define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown" | ||
343 | 677 | ||
344 | static void dbgbuf(unsigned int cmd, struct video_device *vfd, | 678 | static void dbgbuf(unsigned int cmd, struct video_device *vfd, |
345 | struct v4l2_buffer *p) | 679 | struct v4l2_buffer *p) |
@@ -354,10 +688,10 @@ static void dbgbuf(unsigned int cmd, struct video_device *vfd, | |||
354 | (int)(p->timestamp.tv_sec%60), | 688 | (int)(p->timestamp.tv_sec%60), |
355 | p->timestamp.tv_usec, | 689 | p->timestamp.tv_usec, |
356 | p->index, | 690 | p->index, |
357 | prt_names(p->type,v4l2_type_names_FIXME), | 691 | prt_names(p->type, v4l2_type_names), |
358 | p->bytesused,p->flags, | 692 | p->bytesused, p->flags, |
359 | p->field,p->sequence, | 693 | p->field, p->sequence, |
360 | prt_names(p->memory,v4l2_memory_names), | 694 | prt_names(p->memory, v4l2_memory_names), |
361 | p->m.userptr, p->length); | 695 | p->m.userptr, p->length); |
362 | dbgarg2 ("timecode= %02d:%02d:%02d type=%d, " | 696 | dbgarg2 ("timecode= %02d:%02d:%02d type=%d, " |
363 | "flags=0x%08d, frames=%d, userbits=0x%08x\n", | 697 | "flags=0x%08d, frames=%d, userbits=0x%08x\n", |
@@ -382,8 +716,8 @@ static inline void v4l_print_pix_fmt (struct video_device *vfd, | |||
382 | (fmt->pixelformat >> 8) & 0xff, | 716 | (fmt->pixelformat >> 8) & 0xff, |
383 | (fmt->pixelformat >> 16) & 0xff, | 717 | (fmt->pixelformat >> 16) & 0xff, |
384 | (fmt->pixelformat >> 24) & 0xff, | 718 | (fmt->pixelformat >> 24) & 0xff, |
385 | prt_names(fmt->field,v4l2_field_names_FIXME), | 719 | prt_names(fmt->field, v4l2_field_names), |
386 | fmt->bytesperline,fmt->sizeimage,fmt->colorspace); | 720 | fmt->bytesperline, fmt->sizeimage, fmt->colorspace); |
387 | }; | 721 | }; |
388 | 722 | ||
389 | 723 | ||
@@ -597,7 +931,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
597 | 931 | ||
598 | /* FIXME: Should be one dump per type */ | 932 | /* FIXME: Should be one dump per type */ |
599 | dbgarg (cmd, "type=%s\n", prt_names(type, | 933 | dbgarg (cmd, "type=%s\n", prt_names(type, |
600 | v4l2_type_names_FIXME)); | 934 | v4l2_type_names)); |
601 | 935 | ||
602 | switch (type) { | 936 | switch (type) { |
603 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 937 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
@@ -650,7 +984,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
650 | 984 | ||
651 | /* FIXME: Should be one dump per type */ | 985 | /* FIXME: Should be one dump per type */ |
652 | dbgarg (cmd, "type=%s\n", prt_names(f->type, | 986 | dbgarg (cmd, "type=%s\n", prt_names(f->type, |
653 | v4l2_type_names_FIXME)); | 987 | v4l2_type_names)); |
654 | 988 | ||
655 | switch (f->type) { | 989 | switch (f->type) { |
656 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 990 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
@@ -702,7 +1036,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
702 | 1036 | ||
703 | /* FIXME: Should be one dump per type */ | 1037 | /* FIXME: Should be one dump per type */ |
704 | dbgarg (cmd, "type=%s\n", prt_names(f->type, | 1038 | dbgarg (cmd, "type=%s\n", prt_names(f->type, |
705 | v4l2_type_names_FIXME)); | 1039 | v4l2_type_names)); |
706 | switch (f->type) { | 1040 | switch (f->type) { |
707 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1041 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
708 | if (vfd->vidioc_try_fmt_cap) | 1042 | if (vfd->vidioc_try_fmt_cap) |
@@ -768,8 +1102,8 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
768 | ret=vfd->vidioc_reqbufs(file, fh, p); | 1102 | ret=vfd->vidioc_reqbufs(file, fh, p); |
769 | dbgarg (cmd, "count=%d, type=%s, memory=%s\n", | 1103 | dbgarg (cmd, "count=%d, type=%s, memory=%s\n", |
770 | p->count, | 1104 | p->count, |
771 | prt_names(p->type,v4l2_type_names_FIXME), | 1105 | prt_names(p->type, v4l2_type_names), |
772 | prt_names(p->memory,v4l2_memory_names)); | 1106 | prt_names(p->memory, v4l2_memory_names)); |
773 | break; | 1107 | break; |
774 | } | 1108 | } |
775 | case VIDIOC_QUERYBUF: | 1109 | case VIDIOC_QUERYBUF: |
@@ -858,7 +1192,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
858 | enum v4l2_buf_type i = *(int *)arg; | 1192 | enum v4l2_buf_type i = *(int *)arg; |
859 | if (!vfd->vidioc_streamon) | 1193 | if (!vfd->vidioc_streamon) |
860 | break; | 1194 | break; |
861 | dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME)); | 1195 | dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); |
862 | ret=vfd->vidioc_streamon(file, fh,i); | 1196 | ret=vfd->vidioc_streamon(file, fh,i); |
863 | break; | 1197 | break; |
864 | } | 1198 | } |
@@ -868,7 +1202,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
868 | 1202 | ||
869 | if (!vfd->vidioc_streamoff) | 1203 | if (!vfd->vidioc_streamoff) |
870 | break; | 1204 | break; |
871 | dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME)); | 1205 | dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); |
872 | ret=vfd->vidioc_streamoff(file, fh, i); | 1206 | ret=vfd->vidioc_streamoff(file, fh, i); |
873 | break; | 1207 | break; |
874 | } | 1208 | } |
@@ -1624,7 +1958,7 @@ out: | |||
1624 | kfree(mbuf); | 1958 | kfree(mbuf); |
1625 | return err; | 1959 | return err; |
1626 | } | 1960 | } |
1627 | 1961 | EXPORT_SYMBOL(video_ioctl2); | |
1628 | 1962 | ||
1629 | static const struct file_operations video_fops; | 1963 | static const struct file_operations video_fops; |
1630 | 1964 | ||
@@ -1743,6 +2077,7 @@ fail_minor: | |||
1743 | mutex_unlock(&videodev_lock); | 2077 | mutex_unlock(&videodev_lock); |
1744 | return ret; | 2078 | return ret; |
1745 | } | 2079 | } |
2080 | EXPORT_SYMBOL(video_register_device); | ||
1746 | 2081 | ||
1747 | /** | 2082 | /** |
1748 | * video_unregister_device - unregister a video4linux device | 2083 | * video_unregister_device - unregister a video4linux device |
@@ -1762,6 +2097,7 @@ void video_unregister_device(struct video_device *vfd) | |||
1762 | device_unregister(&vfd->class_dev); | 2097 | device_unregister(&vfd->class_dev); |
1763 | mutex_unlock(&videodev_lock); | 2098 | mutex_unlock(&videodev_lock); |
1764 | } | 2099 | } |
2100 | EXPORT_SYMBOL(video_unregister_device); | ||
1765 | 2101 | ||
1766 | /* | 2102 | /* |
1767 | * Video fs operations | 2103 | * Video fs operations |
@@ -1806,16 +2142,6 @@ static void __exit videodev_exit(void) | |||
1806 | module_init(videodev_init) | 2142 | module_init(videodev_init) |
1807 | module_exit(videodev_exit) | 2143 | module_exit(videodev_exit) |
1808 | 2144 | ||
1809 | EXPORT_SYMBOL(video_register_device); | ||
1810 | EXPORT_SYMBOL(video_unregister_device); | ||
1811 | EXPORT_SYMBOL(video_devdata); | ||
1812 | EXPORT_SYMBOL(video_usercopy); | ||
1813 | EXPORT_SYMBOL(video_exclusive_open); | ||
1814 | EXPORT_SYMBOL(video_exclusive_release); | ||
1815 | EXPORT_SYMBOL(video_ioctl2); | ||
1816 | EXPORT_SYMBOL(video_device_alloc); | ||
1817 | EXPORT_SYMBOL(video_device_release); | ||
1818 | |||
1819 | MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>"); | 2145 | MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>"); |
1820 | MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2"); | 2146 | MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2"); |
1821 | MODULE_LICENSE("GPL"); | 2147 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h index 937c4a616c0e..498a43c1f2b1 100644 --- a/drivers/media/video/zoran.h +++ b/drivers/media/video/zoran.h | |||
@@ -221,15 +221,15 @@ enum zoran_map_mode { | |||
221 | }; | 221 | }; |
222 | 222 | ||
223 | enum gpio_type { | 223 | enum gpio_type { |
224 | GPIO_JPEG_SLEEP = 0, | 224 | ZR_GPIO_JPEG_SLEEP = 0, |
225 | GPIO_JPEG_RESET, | 225 | ZR_GPIO_JPEG_RESET, |
226 | GPIO_JPEG_FRAME, | 226 | ZR_GPIO_JPEG_FRAME, |
227 | GPIO_VID_DIR, | 227 | ZR_GPIO_VID_DIR, |
228 | GPIO_VID_EN, | 228 | ZR_GPIO_VID_EN, |
229 | GPIO_VID_RESET, | 229 | ZR_GPIO_VID_RESET, |
230 | GPIO_CLK_SEL1, | 230 | ZR_GPIO_CLK_SEL1, |
231 | GPIO_CLK_SEL2, | 231 | ZR_GPIO_CLK_SEL2, |
232 | GPIO_MAX, | 232 | ZR_GPIO_MAX, |
233 | }; | 233 | }; |
234 | 234 | ||
235 | enum gpcs_type { | 235 | enum gpcs_type { |
@@ -378,11 +378,11 @@ struct card_info { | |||
378 | 378 | ||
379 | u32 jpeg_int; /* JPEG interrupt */ | 379 | u32 jpeg_int; /* JPEG interrupt */ |
380 | u32 vsync_int; /* VSYNC interrupt */ | 380 | u32 vsync_int; /* VSYNC interrupt */ |
381 | s8 gpio[GPIO_MAX]; | 381 | s8 gpio[ZR_GPIO_MAX]; |
382 | u8 gpcs[GPCS_MAX]; | 382 | u8 gpcs[GPCS_MAX]; |
383 | 383 | ||
384 | struct vfe_polarity vfe_pol; | 384 | struct vfe_polarity vfe_pol; |
385 | u8 gpio_pol[GPIO_MAX]; | 385 | u8 gpio_pol[ZR_GPIO_MAX]; |
386 | 386 | ||
387 | /* is the /GWS line conected? */ | 387 | /* is the /GWS line conected? */ |
388 | u8 gws_not_connected; | 388 | u8 gws_not_connected; |
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c index 68c7c505587e..f97c20692057 100644 --- a/drivers/media/video/zoran_device.c +++ b/drivers/media/video/zoran_device.c | |||
@@ -250,7 +250,7 @@ void | |||
250 | jpeg_codec_sleep (struct zoran *zr, | 250 | jpeg_codec_sleep (struct zoran *zr, |
251 | int sleep) | 251 | int sleep) |
252 | { | 252 | { |
253 | GPIO(zr, zr->card.gpio[GPIO_JPEG_SLEEP], !sleep); | 253 | GPIO(zr, zr->card.gpio[ZR_GPIO_JPEG_SLEEP], !sleep); |
254 | if (!sleep) { | 254 | if (!sleep) { |
255 | dprintk(3, | 255 | dprintk(3, |
256 | KERN_DEBUG | 256 | KERN_DEBUG |
@@ -277,9 +277,9 @@ jpeg_codec_reset (struct zoran *zr) | |||
277 | 0); | 277 | 0); |
278 | udelay(2); | 278 | udelay(2); |
279 | } else { | 279 | } else { |
280 | GPIO(zr, zr->card.gpio[GPIO_JPEG_RESET], 0); | 280 | GPIO(zr, zr->card.gpio[ZR_GPIO_JPEG_RESET], 0); |
281 | udelay(2); | 281 | udelay(2); |
282 | GPIO(zr, zr->card.gpio[GPIO_JPEG_RESET], 1); | 282 | GPIO(zr, zr->card.gpio[ZR_GPIO_JPEG_RESET], 1); |
283 | udelay(2); | 283 | udelay(2); |
284 | } | 284 | } |
285 | 285 | ||
@@ -688,7 +688,7 @@ static inline void | |||
688 | set_frame (struct zoran *zr, | 688 | set_frame (struct zoran *zr, |
689 | int val) | 689 | int val) |
690 | { | 690 | { |
691 | GPIO(zr, zr->card.gpio[GPIO_JPEG_FRAME], val); | 691 | GPIO(zr, zr->card.gpio[ZR_GPIO_JPEG_FRAME], val); |
692 | } | 692 | } |
693 | 693 | ||
694 | static void | 694 | static void |
@@ -704,8 +704,8 @@ set_videobus_dir (struct zoran *zr, | |||
704 | GPIO(zr, 5, 1); | 704 | GPIO(zr, 5, 1); |
705 | break; | 705 | break; |
706 | default: | 706 | default: |
707 | GPIO(zr, zr->card.gpio[GPIO_VID_DIR], | 707 | GPIO(zr, zr->card.gpio[ZR_GPIO_VID_DIR], |
708 | zr->card.gpio_pol[GPIO_VID_DIR] ? !val : val); | 708 | zr->card.gpio_pol[ZR_GPIO_VID_DIR] ? !val : val); |
709 | break; | 709 | break; |
710 | } | 710 | } |
711 | } | 711 | } |
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c index 1fdbb46de7f3..1b44784d0efb 100644 --- a/drivers/media/video/zr364xx.c +++ b/drivers/media/video/zr364xx.c | |||
@@ -93,6 +93,8 @@ static struct usb_device_id device_table[] = { | |||
93 | {USB_DEVICE(0x06d6, 0x0034), .driver_info = METHOD0 }, | 93 | {USB_DEVICE(0x06d6, 0x0034), .driver_info = METHOD0 }, |
94 | {USB_DEVICE(0x0a17, 0x0062), .driver_info = METHOD2 }, | 94 | {USB_DEVICE(0x0a17, 0x0062), .driver_info = METHOD2 }, |
95 | {USB_DEVICE(0x06d6, 0x003b), .driver_info = METHOD0 }, | 95 | {USB_DEVICE(0x06d6, 0x003b), .driver_info = METHOD0 }, |
96 | {USB_DEVICE(0x0a17, 0x004e), .driver_info = METHOD2 }, | ||
97 | {USB_DEVICE(0x041e, 0x405d), .driver_info = METHOD2 }, | ||
96 | {} /* Terminating entry */ | 98 | {} /* Terminating entry */ |
97 | }; | 99 | }; |
98 | 100 | ||
diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c index f55b71a4337d..4fb24215bd95 100644 --- a/drivers/memstick/host/tifm_ms.c +++ b/drivers/memstick/host/tifm_ms.c | |||
@@ -282,7 +282,7 @@ static int tifm_ms_issue_cmd(struct tifm_ms *host) | |||
282 | 282 | ||
283 | writel(TIFM_MS_SYS_LATCH | 283 | writel(TIFM_MS_SYS_LATCH |
284 | | readl(sock->addr + SOCK_MS_SYSTEM), | 284 | | readl(sock->addr + SOCK_MS_SYSTEM), |
285 | sock + SOCK_MS_SYSTEM); | 285 | sock->addr + SOCK_MS_SYSTEM); |
286 | writel(0, sock->addr + SOCK_MS_DATA); | 286 | writel(0, sock->addr + SOCK_MS_DATA); |
287 | dev_dbg(&sock->dev, "writing %x\n", 0); | 287 | dev_dbg(&sock->dev, "writing %x\n", 0); |
288 | 288 | ||
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 425f60c21fdd..0c303c84b37b 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c | |||
@@ -1470,9 +1470,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1470 | if (mpt_debug_level) | 1470 | if (mpt_debug_level) |
1471 | printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level); | 1471 | printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level); |
1472 | 1472 | ||
1473 | if (pci_enable_device(pdev)) | ||
1474 | return r; | ||
1475 | |||
1476 | ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); | 1473 | ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); |
1477 | if (ioc == NULL) { | 1474 | if (ioc == NULL) { |
1478 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); | 1475 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); |
@@ -1482,6 +1479,20 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1482 | ioc->id = mpt_ids++; | 1479 | ioc->id = mpt_ids++; |
1483 | sprintf(ioc->name, "ioc%d", ioc->id); | 1480 | sprintf(ioc->name, "ioc%d", ioc->id); |
1484 | 1481 | ||
1482 | ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); | ||
1483 | if (pci_enable_device_mem(pdev)) { | ||
1484 | printk(MYIOC_s_ERR_FMT "pci_enable_device_mem() " | ||
1485 | "failed\n", ioc->name); | ||
1486 | kfree(ioc); | ||
1487 | return r; | ||
1488 | } | ||
1489 | if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) { | ||
1490 | printk(MYIOC_s_ERR_FMT "pci_request_selected_regions() with " | ||
1491 | "MEM failed\n", ioc->name); | ||
1492 | kfree(ioc); | ||
1493 | return r; | ||
1494 | } | ||
1495 | |||
1485 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name)); | 1496 | dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name)); |
1486 | 1497 | ||
1487 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { | 1498 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { |
@@ -1658,6 +1669,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1658 | ioc->active = 0; | 1669 | ioc->active = 0; |
1659 | CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); | 1670 | CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); |
1660 | 1671 | ||
1672 | /* Set IOC ptr in the pcidev's driver data. */ | ||
1673 | pci_set_drvdata(ioc->pcidev, ioc); | ||
1674 | |||
1661 | /* Set lookup ptr. */ | 1675 | /* Set lookup ptr. */ |
1662 | list_add_tail(&ioc->list, &ioc_list); | 1676 | list_add_tail(&ioc->list, &ioc_list); |
1663 | 1677 | ||
@@ -1791,6 +1805,7 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state) | |||
1791 | CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); | 1805 | CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); |
1792 | 1806 | ||
1793 | pci_disable_device(pdev); | 1807 | pci_disable_device(pdev); |
1808 | pci_release_selected_regions(pdev, ioc->bars); | ||
1794 | pci_set_power_state(pdev, device_state); | 1809 | pci_set_power_state(pdev, device_state); |
1795 | 1810 | ||
1796 | return 0; | 1811 | return 0; |
@@ -1807,7 +1822,6 @@ mpt_resume(struct pci_dev *pdev) | |||
1807 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | 1822 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
1808 | u32 device_state = pdev->current_state; | 1823 | u32 device_state = pdev->current_state; |
1809 | int recovery_state; | 1824 | int recovery_state; |
1810 | int err; | ||
1811 | 1825 | ||
1812 | printk(MYIOC_s_INFO_FMT | 1826 | printk(MYIOC_s_INFO_FMT |
1813 | "pci-resume: pdev=0x%p, slot=%s, Previous operating state [D%d]\n", | 1827 | "pci-resume: pdev=0x%p, slot=%s, Previous operating state [D%d]\n", |
@@ -1815,9 +1829,18 @@ mpt_resume(struct pci_dev *pdev) | |||
1815 | 1829 | ||
1816 | pci_set_power_state(pdev, 0); | 1830 | pci_set_power_state(pdev, 0); |
1817 | pci_restore_state(pdev); | 1831 | pci_restore_state(pdev); |
1818 | err = pci_enable_device(pdev); | 1832 | if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) { |
1819 | if (err) | 1833 | ioc->bars = pci_select_bars(ioc->pcidev, IORESOURCE_MEM | |
1820 | return err; | 1834 | IORESOURCE_IO); |
1835 | if (pci_enable_device(pdev)) | ||
1836 | return 0; | ||
1837 | } else { | ||
1838 | ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); | ||
1839 | if (pci_enable_device_mem(pdev)) | ||
1840 | return 0; | ||
1841 | } | ||
1842 | if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) | ||
1843 | return 0; | ||
1821 | 1844 | ||
1822 | /* enable interrupts */ | 1845 | /* enable interrupts */ |
1823 | CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); | 1846 | CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); |
@@ -1878,6 +1901,7 @@ mpt_signal_reset(u8 index, MPT_ADAPTER *ioc, int reset_phase) | |||
1878 | * -2 if READY but IOCFacts Failed | 1901 | * -2 if READY but IOCFacts Failed |
1879 | * -3 if READY but PrimeIOCFifos Failed | 1902 | * -3 if READY but PrimeIOCFifos Failed |
1880 | * -4 if READY but IOCInit Failed | 1903 | * -4 if READY but IOCInit Failed |
1904 | * -5 if failed to enable_device and/or request_selected_regions | ||
1881 | */ | 1905 | */ |
1882 | static int | 1906 | static int |
1883 | mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | 1907 | mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) |
@@ -1976,6 +2000,18 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1976 | } | 2000 | } |
1977 | } | 2001 | } |
1978 | 2002 | ||
2003 | if ((ret == 0) && (reason == MPT_HOSTEVENT_IOC_BRINGUP) && | ||
2004 | (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT)) { | ||
2005 | pci_release_selected_regions(ioc->pcidev, ioc->bars); | ||
2006 | ioc->bars = pci_select_bars(ioc->pcidev, IORESOURCE_MEM | | ||
2007 | IORESOURCE_IO); | ||
2008 | if (pci_enable_device(ioc->pcidev)) | ||
2009 | return -5; | ||
2010 | if (pci_request_selected_regions(ioc->pcidev, ioc->bars, | ||
2011 | "mpt")) | ||
2012 | return -5; | ||
2013 | } | ||
2014 | |||
1979 | /* | 2015 | /* |
1980 | * Device is reset now. It must have de-asserted the interrupt line | 2016 | * Device is reset now. It must have de-asserted the interrupt line |
1981 | * (if it was asserted) and it should be safe to register for the | 2017 | * (if it was asserted) and it should be safe to register for the |
@@ -1999,7 +2035,6 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) | |||
1999 | irq_allocated = 1; | 2035 | irq_allocated = 1; |
2000 | ioc->pci_irq = ioc->pcidev->irq; | 2036 | ioc->pci_irq = ioc->pcidev->irq; |
2001 | pci_set_master(ioc->pcidev); /* ?? */ | 2037 | pci_set_master(ioc->pcidev); /* ?? */ |
2002 | pci_set_drvdata(ioc->pcidev, ioc); | ||
2003 | dprintk(ioc, printk(MYIOC_s_INFO_FMT "installed at interrupt " | 2038 | dprintk(ioc, printk(MYIOC_s_INFO_FMT "installed at interrupt " |
2004 | "%d\n", ioc->name, ioc->pcidev->irq)); | 2039 | "%d\n", ioc->name, ioc->pcidev->irq)); |
2005 | } | 2040 | } |
@@ -2381,6 +2416,9 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc) | |||
2381 | ioc->memmap = NULL; | 2416 | ioc->memmap = NULL; |
2382 | } | 2417 | } |
2383 | 2418 | ||
2419 | pci_disable_device(ioc->pcidev); | ||
2420 | pci_release_selected_regions(ioc->pcidev, ioc->bars); | ||
2421 | |||
2384 | #if defined(CONFIG_MTRR) && 0 | 2422 | #if defined(CONFIG_MTRR) && 0 |
2385 | if (ioc->mtrr_reg > 0) { | 2423 | if (ioc->mtrr_reg > 0) { |
2386 | mtrr_del(ioc->mtrr_reg, 0, 0); | 2424 | mtrr_del(ioc->mtrr_reg, 0, 0); |
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index b49b706c0020..caadc68c3000 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h | |||
@@ -629,6 +629,7 @@ typedef struct _MPT_ADAPTER | |||
629 | dma_addr_t HostPageBuffer_dma; | 629 | dma_addr_t HostPageBuffer_dma; |
630 | int mtrr_reg; | 630 | int mtrr_reg; |
631 | struct pci_dev *pcidev; /* struct pci_dev pointer */ | 631 | struct pci_dev *pcidev; /* struct pci_dev pointer */ |
632 | int bars; /* bitmask of BAR's that must be configured */ | ||
632 | u8 __iomem *memmap; /* mmap address */ | 633 | u8 __iomem *memmap; /* mmap address */ |
633 | struct Scsi_Host *sh; /* Scsi Host pointer */ | 634 | struct Scsi_Host *sh; /* Scsi Host pointer */ |
634 | SpiCfgData spi_data; /* Scsi config. data */ | 635 | SpiCfgData spi_data; /* Scsi config. data */ |
@@ -922,7 +923,7 @@ extern struct proc_dir_entry *mpt_proc_root_dir; | |||
922 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 923 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
923 | #endif /* } __KERNEL__ */ | 924 | #endif /* } __KERNEL__ */ |
924 | 925 | ||
925 | #if defined(__alpha__) || defined(__sparc_v9__) || defined(__ia64__) || defined(__x86_64__) || defined(__powerpc__) | 926 | #ifdef CONFIG_64BIT |
926 | #define CAST_U32_TO_PTR(x) ((void *)(u64)x) | 927 | #define CAST_U32_TO_PTR(x) ((void *)(u64)x) |
927 | #define CAST_PTR_TO_U32(x) ((u32)(u64)x) | 928 | #define CAST_PTR_TO_U32(x) ((u32)(u64)x) |
928 | #else | 929 | #else |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 1abc95ca9dfa..982e27b86d10 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -258,6 +258,23 @@ config THINKPAD_ACPI_BAY | |||
258 | 258 | ||
259 | If you are not sure, say Y here. | 259 | If you are not sure, say Y here. |
260 | 260 | ||
261 | config THINKPAD_ACPI_VIDEO | ||
262 | bool "Video output control support" | ||
263 | depends on THINKPAD_ACPI | ||
264 | default y | ||
265 | ---help--- | ||
266 | Allows the thinkpad_acpi driver to provide an interface to control | ||
267 | the various video output ports. | ||
268 | |||
269 | This feature often won't work well, depending on ThinkPad model, | ||
270 | display state, video output devices in use, whether there is a X | ||
271 | server running, phase of the moon, and the current mood of | ||
272 | Schroedinger's cat. If you can use X.org's RandR to control | ||
273 | your ThinkPad's video output ports instead of this feature, | ||
274 | don't think twice: do it and say N here to save some memory. | ||
275 | |||
276 | If you are not sure, say Y here. | ||
277 | |||
261 | config THINKPAD_ACPI_HOTKEY_POLL | 278 | config THINKPAD_ACPI_HOTKEY_POLL |
262 | bool "Suport NVRAM polling for hot keys" | 279 | bool "Suport NVRAM polling for hot keys" |
263 | depends on THINKPAD_ACPI | 280 | depends on THINKPAD_ACPI |
diff --git a/drivers/misc/acer-wmi.c b/drivers/misc/acer-wmi.c index d7aea93081f2..74d12b4a3abd 100644 --- a/drivers/misc/acer-wmi.c +++ b/drivers/misc/acer-wmi.c | |||
@@ -273,6 +273,15 @@ static struct dmi_system_id acer_quirks[] = { | |||
273 | }, | 273 | }, |
274 | { | 274 | { |
275 | .callback = dmi_matched, | 275 | .callback = dmi_matched, |
276 | .ident = "Acer TravelMate 4200", | ||
277 | .matches = { | ||
278 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
279 | DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4200"), | ||
280 | }, | ||
281 | .driver_data = &quirk_acer_travelmate_2490, | ||
282 | }, | ||
283 | { | ||
284 | .callback = dmi_matched, | ||
276 | .ident = "Medion MD 98300", | 285 | .ident = "Medion MD 98300", |
277 | .matches = { | 286 | .matches = { |
278 | DMI_MATCH(DMI_SYS_VENDOR, "MEDION"), | 287 | DMI_MATCH(DMI_SYS_VENDOR, "MEDION"), |
diff --git a/drivers/misc/intel_menlow.c b/drivers/misc/intel_menlow.c index f70984ab1e1b..de16e88eb8d3 100644 --- a/drivers/misc/intel_menlow.c +++ b/drivers/misc/intel_menlow.c | |||
@@ -170,10 +170,13 @@ static int intel_menlow_memory_add(struct acpi_device *device) | |||
170 | 170 | ||
171 | cdev = thermal_cooling_device_register("Memory controller", device, | 171 | cdev = thermal_cooling_device_register("Memory controller", device, |
172 | &memory_cooling_ops); | 172 | &memory_cooling_ops); |
173 | acpi_driver_data(device) = cdev; | 173 | if (IS_ERR(cdev)) { |
174 | if (!cdev) | 174 | result = PTR_ERR(cdev); |
175 | result = -ENODEV; | 175 | goto end; |
176 | else { | 176 | } |
177 | |||
178 | if (cdev) { | ||
179 | acpi_driver_data(device) = cdev; | ||
177 | result = sysfs_create_link(&device->dev.kobj, | 180 | result = sysfs_create_link(&device->dev.kobj, |
178 | &cdev->device.kobj, "thermal_cooling"); | 181 | &cdev->device.kobj, "thermal_cooling"); |
179 | if (result) | 182 | if (result) |
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 7ba1acad5402..bb269d0c677e 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -221,6 +221,7 @@ static struct { | |||
221 | u32 hotkey:1; | 221 | u32 hotkey:1; |
222 | u32 hotkey_mask:1; | 222 | u32 hotkey_mask:1; |
223 | u32 hotkey_wlsw:1; | 223 | u32 hotkey_wlsw:1; |
224 | u32 hotkey_tablet:1; | ||
224 | u32 light:1; | 225 | u32 light:1; |
225 | u32 light_status:1; | 226 | u32 light_status:1; |
226 | u32 bright_16levels:1; | 227 | u32 bright_16levels:1; |
@@ -301,6 +302,13 @@ TPACPI_HANDLE(hkey, ec, "\\_SB.HKEY", /* 600e/x, 770e, 770x */ | |||
301 | "HKEY", /* all others */ | 302 | "HKEY", /* all others */ |
302 | ); /* 570 */ | 303 | ); /* 570 */ |
303 | 304 | ||
305 | TPACPI_HANDLE(vid, root, "\\_SB.PCI.AGP.VGA", /* 570 */ | ||
306 | "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */ | ||
307 | "\\_SB.PCI0.VID0", /* 770e */ | ||
308 | "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */ | ||
309 | "\\_SB.PCI0.AGP.VID", /* all others */ | ||
310 | ); /* R30, R31 */ | ||
311 | |||
304 | 312 | ||
305 | /************************************************************************* | 313 | /************************************************************************* |
306 | * ACPI helpers | 314 | * ACPI helpers |
@@ -1053,6 +1061,9 @@ static struct attribute_set *hotkey_dev_attributes; | |||
1053 | #define HOTKEY_CONFIG_CRITICAL_END | 1061 | #define HOTKEY_CONFIG_CRITICAL_END |
1054 | #endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ | 1062 | #endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ |
1055 | 1063 | ||
1064 | /* HKEY.MHKG() return bits */ | ||
1065 | #define TP_HOTKEY_TABLET_MASK (1 << 3) | ||
1066 | |||
1056 | static int hotkey_get_wlsw(int *status) | 1067 | static int hotkey_get_wlsw(int *status) |
1057 | { | 1068 | { |
1058 | if (!acpi_evalf(hkey_handle, status, "WLSW", "d")) | 1069 | if (!acpi_evalf(hkey_handle, status, "WLSW", "d")) |
@@ -1060,6 +1071,16 @@ static int hotkey_get_wlsw(int *status) | |||
1060 | return 0; | 1071 | return 0; |
1061 | } | 1072 | } |
1062 | 1073 | ||
1074 | static int hotkey_get_tablet_mode(int *status) | ||
1075 | { | ||
1076 | int s; | ||
1077 | |||
1078 | if (!acpi_evalf(hkey_handle, &s, "MHKG", "d")) | ||
1079 | return -EIO; | ||
1080 | |||
1081 | return ((s & TP_HOTKEY_TABLET_MASK) != 0); | ||
1082 | } | ||
1083 | |||
1063 | /* | 1084 | /* |
1064 | * Call with hotkey_mutex held | 1085 | * Call with hotkey_mutex held |
1065 | */ | 1086 | */ |
@@ -1154,15 +1175,31 @@ static void tpacpi_input_send_radiosw(void) | |||
1154 | { | 1175 | { |
1155 | int wlsw; | 1176 | int wlsw; |
1156 | 1177 | ||
1157 | mutex_lock(&tpacpi_inputdev_send_mutex); | ||
1158 | |||
1159 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) { | 1178 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) { |
1179 | mutex_lock(&tpacpi_inputdev_send_mutex); | ||
1180 | |||
1160 | input_report_switch(tpacpi_inputdev, | 1181 | input_report_switch(tpacpi_inputdev, |
1161 | SW_RADIO, !!wlsw); | 1182 | SW_RADIO, !!wlsw); |
1162 | input_sync(tpacpi_inputdev); | 1183 | input_sync(tpacpi_inputdev); |
1184 | |||
1185 | mutex_unlock(&tpacpi_inputdev_send_mutex); | ||
1163 | } | 1186 | } |
1187 | } | ||
1188 | |||
1189 | static void tpacpi_input_send_tabletsw(void) | ||
1190 | { | ||
1191 | int state; | ||
1192 | |||
1193 | if (tp_features.hotkey_tablet && | ||
1194 | !hotkey_get_tablet_mode(&state)) { | ||
1195 | mutex_lock(&tpacpi_inputdev_send_mutex); | ||
1164 | 1196 | ||
1165 | mutex_unlock(&tpacpi_inputdev_send_mutex); | 1197 | input_report_switch(tpacpi_inputdev, |
1198 | SW_TABLET_MODE, !!state); | ||
1199 | input_sync(tpacpi_inputdev); | ||
1200 | |||
1201 | mutex_unlock(&tpacpi_inputdev_send_mutex); | ||
1202 | } | ||
1166 | } | 1203 | } |
1167 | 1204 | ||
1168 | static void tpacpi_input_send_key(unsigned int scancode) | 1205 | static void tpacpi_input_send_key(unsigned int scancode) |
@@ -1417,6 +1454,14 @@ static void hotkey_poll_setup_safe(int may_warn) | |||
1417 | mutex_unlock(&hotkey_mutex); | 1454 | mutex_unlock(&hotkey_mutex); |
1418 | } | 1455 | } |
1419 | 1456 | ||
1457 | #else /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ | ||
1458 | |||
1459 | static void hotkey_poll_setup_safe(int __unused) | ||
1460 | { | ||
1461 | } | ||
1462 | |||
1463 | #endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ | ||
1464 | |||
1420 | static int hotkey_inputdev_open(struct input_dev *dev) | 1465 | static int hotkey_inputdev_open(struct input_dev *dev) |
1421 | { | 1466 | { |
1422 | switch (tpacpi_lifecycle) { | 1467 | switch (tpacpi_lifecycle) { |
@@ -1444,7 +1489,6 @@ static void hotkey_inputdev_close(struct input_dev *dev) | |||
1444 | if (tpacpi_lifecycle == TPACPI_LIFE_RUNNING) | 1489 | if (tpacpi_lifecycle == TPACPI_LIFE_RUNNING) |
1445 | hotkey_poll_setup_safe(0); | 1490 | hotkey_poll_setup_safe(0); |
1446 | } | 1491 | } |
1447 | #endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ | ||
1448 | 1492 | ||
1449 | /* sysfs hotkey enable ------------------------------------------------- */ | 1493 | /* sysfs hotkey enable ------------------------------------------------- */ |
1450 | static ssize_t hotkey_enable_show(struct device *dev, | 1494 | static ssize_t hotkey_enable_show(struct device *dev, |
@@ -1666,6 +1710,29 @@ static void hotkey_radio_sw_notify_change(void) | |||
1666 | "hotkey_radio_sw"); | 1710 | "hotkey_radio_sw"); |
1667 | } | 1711 | } |
1668 | 1712 | ||
1713 | /* sysfs hotkey tablet mode (pollable) --------------------------------- */ | ||
1714 | static ssize_t hotkey_tablet_mode_show(struct device *dev, | ||
1715 | struct device_attribute *attr, | ||
1716 | char *buf) | ||
1717 | { | ||
1718 | int res, s; | ||
1719 | res = hotkey_get_tablet_mode(&s); | ||
1720 | if (res < 0) | ||
1721 | return res; | ||
1722 | |||
1723 | return snprintf(buf, PAGE_SIZE, "%d\n", !!s); | ||
1724 | } | ||
1725 | |||
1726 | static struct device_attribute dev_attr_hotkey_tablet_mode = | ||
1727 | __ATTR(hotkey_tablet_mode, S_IRUGO, hotkey_tablet_mode_show, NULL); | ||
1728 | |||
1729 | static void hotkey_tablet_mode_notify_change(void) | ||
1730 | { | ||
1731 | if (tp_features.hotkey_tablet) | ||
1732 | sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, | ||
1733 | "hotkey_tablet_mode"); | ||
1734 | } | ||
1735 | |||
1669 | /* sysfs hotkey report_mode -------------------------------------------- */ | 1736 | /* sysfs hotkey report_mode -------------------------------------------- */ |
1670 | static ssize_t hotkey_report_mode_show(struct device *dev, | 1737 | static ssize_t hotkey_report_mode_show(struct device *dev, |
1671 | struct device_attribute *attr, | 1738 | struct device_attribute *attr, |
@@ -1689,7 +1756,7 @@ static ssize_t hotkey_wakeup_reason_show(struct device *dev, | |||
1689 | static struct device_attribute dev_attr_hotkey_wakeup_reason = | 1756 | static struct device_attribute dev_attr_hotkey_wakeup_reason = |
1690 | __ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL); | 1757 | __ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL); |
1691 | 1758 | ||
1692 | void hotkey_wakeup_reason_notify_change(void) | 1759 | static void hotkey_wakeup_reason_notify_change(void) |
1693 | { | 1760 | { |
1694 | if (tp_features.hotkey_mask) | 1761 | if (tp_features.hotkey_mask) |
1695 | sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, | 1762 | sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, |
@@ -1708,7 +1775,7 @@ static struct device_attribute dev_attr_hotkey_wakeup_hotunplug_complete = | |||
1708 | __ATTR(wakeup_hotunplug_complete, S_IRUGO, | 1775 | __ATTR(wakeup_hotunplug_complete, S_IRUGO, |
1709 | hotkey_wakeup_hotunplug_complete_show, NULL); | 1776 | hotkey_wakeup_hotunplug_complete_show, NULL); |
1710 | 1777 | ||
1711 | void hotkey_wakeup_hotunplug_complete_notify_change(void) | 1778 | static void hotkey_wakeup_hotunplug_complete_notify_change(void) |
1712 | { | 1779 | { |
1713 | if (tp_features.hotkey_mask) | 1780 | if (tp_features.hotkey_mask) |
1714 | sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, | 1781 | sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, |
@@ -1878,7 +1945,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
1878 | str_supported(tp_features.hotkey)); | 1945 | str_supported(tp_features.hotkey)); |
1879 | 1946 | ||
1880 | if (tp_features.hotkey) { | 1947 | if (tp_features.hotkey) { |
1881 | hotkey_dev_attributes = create_attr_set(12, NULL); | 1948 | hotkey_dev_attributes = create_attr_set(13, NULL); |
1882 | if (!hotkey_dev_attributes) | 1949 | if (!hotkey_dev_attributes) |
1883 | return -ENOMEM; | 1950 | return -ENOMEM; |
1884 | res = add_many_to_attr_set(hotkey_dev_attributes, | 1951 | res = add_many_to_attr_set(hotkey_dev_attributes, |
@@ -1957,6 +2024,18 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
1957 | &dev_attr_hotkey_radio_sw.attr); | 2024 | &dev_attr_hotkey_radio_sw.attr); |
1958 | } | 2025 | } |
1959 | 2026 | ||
2027 | /* For X41t, X60t, X61t Tablets... */ | ||
2028 | if (!res && acpi_evalf(hkey_handle, &status, "MHKG", "qd")) { | ||
2029 | tp_features.hotkey_tablet = 1; | ||
2030 | printk(TPACPI_INFO | ||
2031 | "possible tablet mode switch found; " | ||
2032 | "ThinkPad in %s mode\n", | ||
2033 | (status & TP_HOTKEY_TABLET_MASK)? | ||
2034 | "tablet" : "laptop"); | ||
2035 | res = add_to_attr_set(hotkey_dev_attributes, | ||
2036 | &dev_attr_hotkey_tablet_mode.attr); | ||
2037 | } | ||
2038 | |||
1960 | if (!res) | 2039 | if (!res) |
1961 | res = register_attr_set_with_sysfs( | 2040 | res = register_attr_set_with_sysfs( |
1962 | hotkey_dev_attributes, | 2041 | hotkey_dev_attributes, |
@@ -2006,6 +2085,10 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
2006 | set_bit(EV_SW, tpacpi_inputdev->evbit); | 2085 | set_bit(EV_SW, tpacpi_inputdev->evbit); |
2007 | set_bit(SW_RADIO, tpacpi_inputdev->swbit); | 2086 | set_bit(SW_RADIO, tpacpi_inputdev->swbit); |
2008 | } | 2087 | } |
2088 | if (tp_features.hotkey_tablet) { | ||
2089 | set_bit(EV_SW, tpacpi_inputdev->evbit); | ||
2090 | set_bit(SW_TABLET_MODE, tpacpi_inputdev->swbit); | ||
2091 | } | ||
2009 | 2092 | ||
2010 | dbg_printk(TPACPI_DBG_INIT, | 2093 | dbg_printk(TPACPI_DBG_INIT, |
2011 | "enabling hot key handling\n"); | 2094 | "enabling hot key handling\n"); |
@@ -2023,12 +2106,12 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
2023 | (hotkey_report_mode < 2) ? | 2106 | (hotkey_report_mode < 2) ? |
2024 | "enabled" : "disabled"); | 2107 | "enabled" : "disabled"); |
2025 | 2108 | ||
2026 | #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL | ||
2027 | tpacpi_inputdev->open = &hotkey_inputdev_open; | 2109 | tpacpi_inputdev->open = &hotkey_inputdev_open; |
2028 | tpacpi_inputdev->close = &hotkey_inputdev_close; | 2110 | tpacpi_inputdev->close = &hotkey_inputdev_close; |
2029 | 2111 | ||
2030 | hotkey_poll_setup_safe(1); | 2112 | hotkey_poll_setup_safe(1); |
2031 | #endif | 2113 | tpacpi_input_send_radiosw(); |
2114 | tpacpi_input_send_tabletsw(); | ||
2032 | } | 2115 | } |
2033 | 2116 | ||
2034 | return (tp_features.hotkey)? 0 : 1; | 2117 | return (tp_features.hotkey)? 0 : 1; |
@@ -2156,11 +2239,15 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
2156 | /* 0x5000-0x5FFF: human interface helpers */ | 2239 | /* 0x5000-0x5FFF: human interface helpers */ |
2157 | switch (hkey) { | 2240 | switch (hkey) { |
2158 | case 0x5010: /* Lenovo new BIOS: brightness changed */ | 2241 | case 0x5010: /* Lenovo new BIOS: brightness changed */ |
2159 | case 0x5009: /* X61t: swivel up (tablet mode) */ | ||
2160 | case 0x500a: /* X61t: swivel down (normal mode) */ | ||
2161 | case 0x500b: /* X61t: tablet pen inserted into bay */ | 2242 | case 0x500b: /* X61t: tablet pen inserted into bay */ |
2162 | case 0x500c: /* X61t: tablet pen removed from bay */ | 2243 | case 0x500c: /* X61t: tablet pen removed from bay */ |
2163 | break; | 2244 | break; |
2245 | case 0x5009: /* X41t-X61t: swivel up (tablet mode) */ | ||
2246 | case 0x500a: /* X41t-X61t: swivel down (normal mode) */ | ||
2247 | tpacpi_input_send_tabletsw(); | ||
2248 | hotkey_tablet_mode_notify_change(); | ||
2249 | send_acpi_ev = 0; | ||
2250 | break; | ||
2164 | case 0x5001: | 2251 | case 0x5001: |
2165 | case 0x5002: | 2252 | case 0x5002: |
2166 | /* LID switch events. Do not propagate */ | 2253 | /* LID switch events. Do not propagate */ |
@@ -2219,11 +2306,10 @@ static void hotkey_resume(void) | |||
2219 | "from firmware\n"); | 2306 | "from firmware\n"); |
2220 | tpacpi_input_send_radiosw(); | 2307 | tpacpi_input_send_radiosw(); |
2221 | hotkey_radio_sw_notify_change(); | 2308 | hotkey_radio_sw_notify_change(); |
2309 | hotkey_tablet_mode_notify_change(); | ||
2222 | hotkey_wakeup_reason_notify_change(); | 2310 | hotkey_wakeup_reason_notify_change(); |
2223 | hotkey_wakeup_hotunplug_complete_notify_change(); | 2311 | hotkey_wakeup_hotunplug_complete_notify_change(); |
2224 | #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL | ||
2225 | hotkey_poll_setup_safe(0); | 2312 | hotkey_poll_setup_safe(0); |
2226 | #endif | ||
2227 | } | 2313 | } |
2228 | 2314 | ||
2229 | /* procfs -------------------------------------------------------------- */ | 2315 | /* procfs -------------------------------------------------------------- */ |
@@ -2676,6 +2762,8 @@ static struct ibm_struct wan_driver_data = { | |||
2676 | * Video subdriver | 2762 | * Video subdriver |
2677 | */ | 2763 | */ |
2678 | 2764 | ||
2765 | #ifdef CONFIG_THINKPAD_ACPI_VIDEO | ||
2766 | |||
2679 | enum video_access_mode { | 2767 | enum video_access_mode { |
2680 | TPACPI_VIDEO_NONE = 0, | 2768 | TPACPI_VIDEO_NONE = 0, |
2681 | TPACPI_VIDEO_570, /* 570 */ | 2769 | TPACPI_VIDEO_570, /* 570 */ |
@@ -2703,13 +2791,6 @@ static int video_orig_autosw; | |||
2703 | static int video_autosw_get(void); | 2791 | static int video_autosw_get(void); |
2704 | static int video_autosw_set(int enable); | 2792 | static int video_autosw_set(int enable); |
2705 | 2793 | ||
2706 | TPACPI_HANDLE(vid, root, "\\_SB.PCI.AGP.VGA", /* 570 */ | ||
2707 | "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */ | ||
2708 | "\\_SB.PCI0.VID0", /* 770e */ | ||
2709 | "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */ | ||
2710 | "\\_SB.PCI0.AGP.VID", /* all others */ | ||
2711 | ); /* R30, R31 */ | ||
2712 | |||
2713 | TPACPI_HANDLE(vid2, root, "\\_SB.PCI0.AGPB.VID"); /* G41 */ | 2794 | TPACPI_HANDLE(vid2, root, "\\_SB.PCI0.AGPB.VID"); /* G41 */ |
2714 | 2795 | ||
2715 | static int __init video_init(struct ibm_init_struct *iibm) | 2796 | static int __init video_init(struct ibm_init_struct *iibm) |
@@ -3019,6 +3100,8 @@ static struct ibm_struct video_driver_data = { | |||
3019 | .exit = video_exit, | 3100 | .exit = video_exit, |
3020 | }; | 3101 | }; |
3021 | 3102 | ||
3103 | #endif /* CONFIG_THINKPAD_ACPI_VIDEO */ | ||
3104 | |||
3022 | /************************************************************************* | 3105 | /************************************************************************* |
3023 | * Light (thinklight) subdriver | 3106 | * Light (thinklight) subdriver |
3024 | */ | 3107 | */ |
@@ -5803,10 +5886,12 @@ static struct ibm_init_struct ibms_init[] __initdata = { | |||
5803 | .init = wan_init, | 5886 | .init = wan_init, |
5804 | .data = &wan_driver_data, | 5887 | .data = &wan_driver_data, |
5805 | }, | 5888 | }, |
5889 | #ifdef CONFIG_THINKPAD_ACPI_VIDEO | ||
5806 | { | 5890 | { |
5807 | .init = video_init, | 5891 | .init = video_init, |
5808 | .data = &video_driver_data, | 5892 | .data = &video_driver_data, |
5809 | }, | 5893 | }, |
5894 | #endif | ||
5810 | { | 5895 | { |
5811 | .init = light_init, | 5896 | .init = light_init, |
5812 | .data = &light_driver_data, | 5897 | .data = &light_driver_data, |
@@ -5918,7 +6003,7 @@ MODULE_PARM_DESC(hotkey_report_mode, | |||
5918 | 6003 | ||
5919 | #define TPACPI_PARAM(feature) \ | 6004 | #define TPACPI_PARAM(feature) \ |
5920 | module_param_call(feature, set_ibm_param, NULL, NULL, 0); \ | 6005 | module_param_call(feature, set_ibm_param, NULL, NULL, 0); \ |
5921 | MODULE_PARM_DESC(feature, "Simulates thinkpad-aci procfs command " \ | 6006 | MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command " \ |
5922 | "at module load, see documentation") | 6007 | "at module load, see documentation") |
5923 | 6008 | ||
5924 | TPACPI_PARAM(hotkey); | 6009 | TPACPI_PARAM(hotkey); |
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c index 9b430f20b640..28cc6787a800 100644 --- a/drivers/mtd/mtdsuper.c +++ b/drivers/mtd/mtdsuper.c | |||
@@ -184,26 +184,26 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags, | |||
184 | ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); | 184 | ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); |
185 | 185 | ||
186 | DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n", | 186 | DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n", |
187 | ret, nd.dentry ? nd.dentry->d_inode : NULL); | 187 | ret, nd.path.dentry ? nd.path.dentry->d_inode : NULL); |
188 | 188 | ||
189 | if (ret) | 189 | if (ret) |
190 | return ret; | 190 | return ret; |
191 | 191 | ||
192 | ret = -EINVAL; | 192 | ret = -EINVAL; |
193 | 193 | ||
194 | if (!S_ISBLK(nd.dentry->d_inode->i_mode)) | 194 | if (!S_ISBLK(nd.path.dentry->d_inode->i_mode)) |
195 | goto out; | 195 | goto out; |
196 | 196 | ||
197 | if (nd.mnt->mnt_flags & MNT_NODEV) { | 197 | if (nd.path.mnt->mnt_flags & MNT_NODEV) { |
198 | ret = -EACCES; | 198 | ret = -EACCES; |
199 | goto out; | 199 | goto out; |
200 | } | 200 | } |
201 | 201 | ||
202 | if (imajor(nd.dentry->d_inode) != MTD_BLOCK_MAJOR) | 202 | if (imajor(nd.path.dentry->d_inode) != MTD_BLOCK_MAJOR) |
203 | goto not_an_MTD_device; | 203 | goto not_an_MTD_device; |
204 | 204 | ||
205 | mtdnr = iminor(nd.dentry->d_inode); | 205 | mtdnr = iminor(nd.path.dentry->d_inode); |
206 | path_release(&nd); | 206 | path_put(&nd.path); |
207 | 207 | ||
208 | return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, | 208 | return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, |
209 | mnt); | 209 | mnt); |
@@ -214,7 +214,7 @@ not_an_MTD_device: | |||
214 | "MTD: Attempt to mount non-MTD device \"%s\"\n", | 214 | "MTD: Attempt to mount non-MTD device \"%s\"\n", |
215 | dev_name); | 215 | dev_name); |
216 | out: | 216 | out: |
217 | path_release(&nd); | 217 | path_put(&nd.path); |
218 | return ret; | 218 | return ret; |
219 | 219 | ||
220 | } | 220 | } |
diff --git a/drivers/net/ibm_newemac/rgmii.c b/drivers/net/ibm_newemac/rgmii.c index 9bc1132fa788..5757788227be 100644 --- a/drivers/net/ibm_newemac/rgmii.c +++ b/drivers/net/ibm_newemac/rgmii.c | |||
@@ -302,7 +302,6 @@ static int __devexit rgmii_remove(struct of_device *ofdev) | |||
302 | static struct of_device_id rgmii_match[] = | 302 | static struct of_device_id rgmii_match[] = |
303 | { | 303 | { |
304 | { | 304 | { |
305 | .type = "rgmii-interface", | ||
306 | .compatible = "ibm,rgmii", | 305 | .compatible = "ibm,rgmii", |
307 | }, | 306 | }, |
308 | { | 307 | { |
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c index 679dfdb6807f..79b317b88c86 100644 --- a/drivers/net/mlx4/mr.c +++ b/drivers/net/mlx4/mr.c | |||
@@ -578,13 +578,6 @@ int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages, | |||
578 | goto err_free; | 578 | goto err_free; |
579 | } | 579 | } |
580 | 580 | ||
581 | fmr->mpt = mlx4_table_find(&priv->mr_table.dmpt_table, | ||
582 | key_to_hw_index(fmr->mr.key), NULL); | ||
583 | if (!fmr->mpt) { | ||
584 | err = -ENOMEM; | ||
585 | goto err_free; | ||
586 | } | ||
587 | |||
588 | return 0; | 581 | return 0; |
589 | 582 | ||
590 | err_free: | 583 | err_free: |
@@ -595,7 +588,19 @@ EXPORT_SYMBOL_GPL(mlx4_fmr_alloc); | |||
595 | 588 | ||
596 | int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr) | 589 | int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr) |
597 | { | 590 | { |
598 | return mlx4_mr_enable(dev, &fmr->mr); | 591 | struct mlx4_priv *priv = mlx4_priv(dev); |
592 | int err; | ||
593 | |||
594 | err = mlx4_mr_enable(dev, &fmr->mr); | ||
595 | if (err) | ||
596 | return err; | ||
597 | |||
598 | fmr->mpt = mlx4_table_find(&priv->mr_table.dmpt_table, | ||
599 | key_to_hw_index(fmr->mr.key), NULL); | ||
600 | if (!fmr->mpt) | ||
601 | return -ENOMEM; | ||
602 | |||
603 | return 0; | ||
599 | } | 604 | } |
600 | EXPORT_SYMBOL_GPL(mlx4_fmr_enable); | 605 | EXPORT_SYMBOL_GPL(mlx4_fmr_enable); |
601 | 606 | ||
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c index 8134c7e198a5..b07ba2a14119 100644 --- a/drivers/oprofile/buffer_sync.c +++ b/drivers/oprofile/buffer_sync.c | |||
@@ -187,23 +187,22 @@ void sync_stop(void) | |||
187 | end_sync(); | 187 | end_sync(); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | /* Optimisation. We can manage without taking the dcookie sem | 191 | /* Optimisation. We can manage without taking the dcookie sem |
192 | * because we cannot reach this code without at least one | 192 | * because we cannot reach this code without at least one |
193 | * dcookie user still being registered (namely, the reader | 193 | * dcookie user still being registered (namely, the reader |
194 | * of the event buffer). */ | 194 | * of the event buffer). */ |
195 | static inline unsigned long fast_get_dcookie(struct dentry * dentry, | 195 | static inline unsigned long fast_get_dcookie(struct path *path) |
196 | struct vfsmount * vfsmnt) | ||
197 | { | 196 | { |
198 | unsigned long cookie; | 197 | unsigned long cookie; |
199 | 198 | ||
200 | if (dentry->d_cookie) | 199 | if (path->dentry->d_cookie) |
201 | return (unsigned long)dentry; | 200 | return (unsigned long)path->dentry; |
202 | get_dcookie(dentry, vfsmnt, &cookie); | 201 | get_dcookie(path, &cookie); |
203 | return cookie; | 202 | return cookie; |
204 | } | 203 | } |
205 | 204 | ||
206 | 205 | ||
207 | /* Look up the dcookie for the task's first VM_EXECUTABLE mapping, | 206 | /* Look up the dcookie for the task's first VM_EXECUTABLE mapping, |
208 | * which corresponds loosely to "application name". This is | 207 | * which corresponds loosely to "application name". This is |
209 | * not strictly necessary but allows oprofile to associate | 208 | * not strictly necessary but allows oprofile to associate |
@@ -222,8 +221,7 @@ static unsigned long get_exec_dcookie(struct mm_struct * mm) | |||
222 | continue; | 221 | continue; |
223 | if (!(vma->vm_flags & VM_EXECUTABLE)) | 222 | if (!(vma->vm_flags & VM_EXECUTABLE)) |
224 | continue; | 223 | continue; |
225 | cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, | 224 | cookie = fast_get_dcookie(&vma->vm_file->f_path); |
226 | vma->vm_file->f_path.mnt); | ||
227 | break; | 225 | break; |
228 | } | 226 | } |
229 | 227 | ||
@@ -248,8 +246,7 @@ static unsigned long lookup_dcookie(struct mm_struct * mm, unsigned long addr, o | |||
248 | continue; | 246 | continue; |
249 | 247 | ||
250 | if (vma->vm_file) { | 248 | if (vma->vm_file) { |
251 | cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, | 249 | cookie = fast_get_dcookie(&vma->vm_file->f_path); |
252 | vma->vm_file->f_path.mnt); | ||
253 | *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - | 250 | *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - |
254 | vma->vm_start; | 251 | vma->vm_start; |
255 | } else { | 252 | } else { |
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index 238628d3a854..d76d37bcb9cc 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c | |||
@@ -1768,7 +1768,7 @@ static int parport_PS2_supported(struct parport *pb) | |||
1768 | } | 1768 | } |
1769 | 1769 | ||
1770 | #ifdef CONFIG_PARPORT_PC_FIFO | 1770 | #ifdef CONFIG_PARPORT_PC_FIFO |
1771 | static int __devinit parport_ECP_supported(struct parport *pb) | 1771 | static int parport_ECP_supported(struct parport *pb) |
1772 | { | 1772 | { |
1773 | int i; | 1773 | int i; |
1774 | int config, configb; | 1774 | int config, configb; |
@@ -1992,7 +1992,7 @@ static int parport_ECPEPP_supported(struct parport *pb) | |||
1992 | /* Don't bother probing for modes we know we won't use. */ | 1992 | /* Don't bother probing for modes we know we won't use. */ |
1993 | static int __devinit parport_PS2_supported(struct parport *pb) { return 0; } | 1993 | static int __devinit parport_PS2_supported(struct parport *pb) { return 0; } |
1994 | #ifdef CONFIG_PARPORT_PC_FIFO | 1994 | #ifdef CONFIG_PARPORT_PC_FIFO |
1995 | static int __devinit parport_ECP_supported(struct parport *pb) { return 0; } | 1995 | static int parport_ECP_supported(struct parport *pb) { return 0; } |
1996 | #endif | 1996 | #endif |
1997 | static int __devinit parport_EPP_supported(struct parport *pb) { return 0; } | 1997 | static int __devinit parport_EPP_supported(struct parport *pb) { return 0; } |
1998 | static int __devinit parport_ECPEPP_supported(struct parport *pb){return 0;} | 1998 | static int __devinit parport_ECPEPP_supported(struct parport *pb){return 0;} |
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c index 8ed26480371f..f941f609dbf3 100644 --- a/drivers/pci/dmar.c +++ b/drivers/pci/dmar.c | |||
@@ -14,11 +14,12 @@ | |||
14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | 14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
15 | * Place - Suite 330, Boston, MA 02111-1307 USA. | 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. |
16 | * | 16 | * |
17 | * Copyright (C) Ashok Raj <ashok.raj@intel.com> | 17 | * Copyright (C) 2006-2008 Intel Corporation |
18 | * Copyright (C) Shaohua Li <shaohua.li@intel.com> | 18 | * Author: Ashok Raj <ashok.raj@intel.com> |
19 | * Copyright (C) Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 19 | * Author: Shaohua Li <shaohua.li@intel.com> |
20 | * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
20 | * | 21 | * |
21 | * This file implements early detection/parsing of DMA Remapping Devices | 22 | * This file implements early detection/parsing of DMA Remapping Devices |
22 | * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI | 23 | * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI |
23 | * tables. | 24 | * tables. |
24 | */ | 25 | */ |
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index c8c263875c21..9279d5ba62e6 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -392,6 +392,9 @@ static int __init acpiphp_init(void) | |||
392 | { | 392 | { |
393 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 393 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
394 | 394 | ||
395 | if (acpi_pci_disabled) | ||
396 | return 0; | ||
397 | |||
395 | acpiphp_debug = debug; | 398 | acpiphp_debug = debug; |
396 | 399 | ||
397 | /* read all the ACPI info from the system */ | 400 | /* read all the ACPI info from the system */ |
@@ -401,6 +404,9 @@ static int __init acpiphp_init(void) | |||
401 | 404 | ||
402 | static void __exit acpiphp_exit(void) | 405 | static void __exit acpiphp_exit(void) |
403 | { | 406 | { |
407 | if (acpi_pci_disabled) | ||
408 | return; | ||
409 | |||
404 | /* deallocate internal data structures etc. */ | 410 | /* deallocate internal data structures etc. */ |
405 | acpiphp_glue_exit(); | 411 | acpiphp_glue_exit(); |
406 | } | 412 | } |
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index 750ebd7a4c10..b0a22b92717e 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c | |||
@@ -395,33 +395,34 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle, | |||
395 | { | 395 | { |
396 | acpi_handle *phandle = (acpi_handle *)context; | 396 | acpi_handle *phandle = (acpi_handle *)context; |
397 | acpi_status status; | 397 | acpi_status status; |
398 | struct acpi_device_info info; | 398 | struct acpi_device_info *info; |
399 | struct acpi_buffer info_buffer = { | 399 | struct acpi_buffer info_buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
400 | .length = sizeof(struct acpi_device_info), | 400 | int retval = 0; |
401 | .pointer = &info, | ||
402 | }; | ||
403 | 401 | ||
404 | status = acpi_get_object_info(handle, &info_buffer); | 402 | status = acpi_get_object_info(handle, &info_buffer); |
405 | if (ACPI_FAILURE(status)) { | 403 | if (ACPI_FAILURE(status)) { |
406 | err("%s: Failed to get device information\n", __FUNCTION__); | 404 | err("%s: Failed to get device information status=0x%x\n", |
407 | return 0; | 405 | __FUNCTION__, status); |
406 | return retval; | ||
408 | } | 407 | } |
409 | info.hardware_id.value[sizeof(info.hardware_id.value) - 1] = '\0'; | 408 | info = info_buffer.pointer; |
410 | 409 | info->hardware_id.value[sizeof(info->hardware_id.value) - 1] = '\0'; | |
411 | if (info.current_status && (info.valid & ACPI_VALID_HID) && | 410 | |
412 | (!strcmp(info.hardware_id.value, IBM_HARDWARE_ID1) || | 411 | if (info->current_status && (info->valid & ACPI_VALID_HID) && |
413 | !strcmp(info.hardware_id.value, IBM_HARDWARE_ID2))) { | 412 | (!strcmp(info->hardware_id.value, IBM_HARDWARE_ID1) || |
414 | dbg("found hardware: %s, handle: %p\n", info.hardware_id.value, | 413 | !strcmp(info->hardware_id.value, IBM_HARDWARE_ID2))) { |
415 | handle); | 414 | dbg("found hardware: %s, handle: %p\n", |
415 | info->hardware_id.value, handle); | ||
416 | *phandle = handle; | 416 | *phandle = handle; |
417 | /* returning non-zero causes the search to stop | 417 | /* returning non-zero causes the search to stop |
418 | * and returns this value to the caller of | 418 | * and returns this value to the caller of |
419 | * acpi_walk_namespace, but it also causes some warnings | 419 | * acpi_walk_namespace, but it also causes some warnings |
420 | * in the acpi debug code to print... | 420 | * in the acpi debug code to print... |
421 | */ | 421 | */ |
422 | return FOUND_APCI; | 422 | retval = FOUND_APCI; |
423 | } | 423 | } |
424 | return 0; | 424 | kfree(info); |
425 | return retval; | ||
425 | } | 426 | } |
426 | 427 | ||
427 | static int __init ibm_acpiphp_init(void) | 428 | static int __init ibm_acpiphp_init(void) |
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index a4c3089f892a..977d29b32295 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -14,9 +14,10 @@ | |||
14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | 14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
15 | * Place - Suite 330, Boston, MA 02111-1307 USA. | 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. |
16 | * | 16 | * |
17 | * Copyright (C) Ashok Raj <ashok.raj@intel.com> | 17 | * Copyright (C) 2006-2008 Intel Corporation |
18 | * Copyright (C) Shaohua Li <shaohua.li@intel.com> | 18 | * Author: Ashok Raj <ashok.raj@intel.com> |
19 | * Copyright (C) Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 19 | * Author: Shaohua Li <shaohua.li@intel.com> |
20 | * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
20 | */ | 21 | */ |
21 | 22 | ||
22 | #include <linux/init.h> | 23 | #include <linux/init.h> |
diff --git a/drivers/pci/intel-iommu.h b/drivers/pci/intel-iommu.h index 07f5f6353bda..afc0ad96122e 100644 --- a/drivers/pci/intel-iommu.h +++ b/drivers/pci/intel-iommu.h | |||
@@ -14,8 +14,9 @@ | |||
14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | 14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
15 | * Place - Suite 330, Boston, MA 02111-1307 USA. | 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. |
16 | * | 16 | * |
17 | * Copyright (C) Ashok Raj <ashok.raj@intel.com> | 17 | * Copyright (C) 2006-2008 Intel Corporation |
18 | * Copyright (C) Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 18 | * Author: Ashok Raj <ashok.raj@intel.com> |
19 | * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
19 | */ | 20 | */ |
20 | 21 | ||
21 | #ifndef _INTEL_IOMMU_H_ | 22 | #ifndef _INTEL_IOMMU_H_ |
diff --git a/drivers/pci/iova.c b/drivers/pci/iova.c index 8de7ab6c6d0c..dbcdd6bfa63a 100644 --- a/drivers/pci/iova.c +++ b/drivers/pci/iova.c | |||
@@ -3,7 +3,8 @@ | |||
3 | * | 3 | * |
4 | * This file is released under the GPLv2. | 4 | * This file is released under the GPLv2. |
5 | * | 5 | * |
6 | * Copyright (C) 2006 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 6 | * Copyright (C) 2006-2008 Intel Corporation |
7 | * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
7 | */ | 8 | */ |
8 | 9 | ||
9 | #include "iova.h" | 10 | #include "iova.h" |
diff --git a/drivers/pci/iova.h b/drivers/pci/iova.h index d521b5b7319c..228f6c94b69c 100644 --- a/drivers/pci/iova.h +++ b/drivers/pci/iova.h | |||
@@ -3,7 +3,8 @@ | |||
3 | * | 3 | * |
4 | * This file is released under the GPLv2. | 4 | * This file is released under the GPLv2. |
5 | * | 5 | * |
6 | * Copyright (C) 2006 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 6 | * Copyright (C) 2006-2008 Intel Corporation |
7 | * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
7 | * | 8 | * |
8 | */ | 9 | */ |
9 | 10 | ||
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index e569645d59e2..4a23654184fc 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -158,6 +158,7 @@ run_osc_out: | |||
158 | /** | 158 | /** |
159 | * __pci_osc_support_set - register OS support to Firmware | 159 | * __pci_osc_support_set - register OS support to Firmware |
160 | * @flags: OS support bits | 160 | * @flags: OS support bits |
161 | * @hid: hardware ID | ||
161 | * | 162 | * |
162 | * Update OS support fields and doing a _OSC Query to obtain an update | 163 | * Update OS support fields and doing a _OSC Query to obtain an update |
163 | * from Firmware on supported control bits. | 164 | * from Firmware on supported control bits. |
@@ -241,8 +242,6 @@ EXPORT_SYMBOL(pci_osc_control_set); | |||
241 | * choose from highest power _SxD to lowest power _SxW | 242 | * choose from highest power _SxD to lowest power _SxW |
242 | * else // no _PRW at S-state x | 243 | * else // no _PRW at S-state x |
243 | * choose highest power _SxD or any lower power | 244 | * choose highest power _SxD or any lower power |
244 | * | ||
245 | * currently we simply return _SxD, if present. | ||
246 | */ | 245 | */ |
247 | 246 | ||
248 | static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev, | 247 | static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev, |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index ae3df46eaabf..183fddaa38b7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -554,6 +554,7 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) | |||
554 | case PM_EVENT_PRETHAW: | 554 | case PM_EVENT_PRETHAW: |
555 | /* REVISIT both freeze and pre-thaw "should" use D0 */ | 555 | /* REVISIT both freeze and pre-thaw "should" use D0 */ |
556 | case PM_EVENT_SUSPEND: | 556 | case PM_EVENT_SUSPEND: |
557 | case PM_EVENT_HIBERNATE: | ||
557 | return PCI_D3hot; | 558 | return PCI_D3hot; |
558 | default: | 559 | default: |
559 | printk("Unrecognized suspend event %d\n", state.event); | 560 | printk("Unrecognized suspend event %d\n", state.event); |
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 68aeeb7206de..ef18fcd641e2 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c | |||
@@ -422,7 +422,7 @@ int pci_proc_detach_device(struct pci_dev *dev) | |||
422 | struct proc_dir_entry *e; | 422 | struct proc_dir_entry *e; |
423 | 423 | ||
424 | if ((e = dev->procent)) { | 424 | if ((e = dev->procent)) { |
425 | if (atomic_read(&e->count)) | 425 | if (atomic_read(&e->count) > 1) |
426 | return -EBUSY; | 426 | return -EBUSY; |
427 | remove_proc_entry(e->name, dev->bus->procdir); | 427 | remove_proc_entry(e->name, dev->bus->procdir); |
428 | dev->procent = NULL; | 428 | dev->procent = NULL; |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 0a953d43b9a2..bbad4a9f264f 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -867,13 +867,13 @@ static void quirk_disable_pxb(struct pci_dev *pdev) | |||
867 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); | 867 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); |
868 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); | 868 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); |
869 | 869 | ||
870 | 870 | static void __devinit quirk_amd_ide_mode(struct pci_dev *pdev) | |
871 | static void __devinit quirk_sb600_sata(struct pci_dev *pdev) | ||
872 | { | 871 | { |
873 | /* set sb600 sata to ahci mode */ | 872 | /* set sb600/sb700/sb800 sata to ahci mode */ |
874 | if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) { | 873 | u8 tmp; |
875 | u8 tmp; | ||
876 | 874 | ||
875 | pci_read_config_byte(pdev, PCI_CLASS_DEVICE, &tmp); | ||
876 | if (tmp == 0x01) { | ||
877 | pci_read_config_byte(pdev, 0x40, &tmp); | 877 | pci_read_config_byte(pdev, 0x40, &tmp); |
878 | pci_write_config_byte(pdev, 0x40, tmp|1); | 878 | pci_write_config_byte(pdev, 0x40, tmp|1); |
879 | pci_write_config_byte(pdev, 0x9, 1); | 879 | pci_write_config_byte(pdev, 0x9, 1); |
@@ -881,10 +881,13 @@ static void __devinit quirk_sb600_sata(struct pci_dev *pdev) | |||
881 | pci_write_config_byte(pdev, 0x40, tmp); | 881 | pci_write_config_byte(pdev, 0x40, tmp); |
882 | 882 | ||
883 | pdev->class = PCI_CLASS_STORAGE_SATA_AHCI; | 883 | pdev->class = PCI_CLASS_STORAGE_SATA_AHCI; |
884 | dev_info(&pdev->dev, "set SATA to AHCI mode\n"); | ||
884 | } | 885 | } |
885 | } | 886 | } |
886 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); | 887 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); |
887 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_sb600_sata); | 888 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); |
889 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); | ||
890 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); | ||
888 | 891 | ||
889 | /* | 892 | /* |
890 | * Serverworks CSB5 IDE does not fully support native mode | 893 | * Serverworks CSB5 IDE does not fully support native mode |
@@ -1775,6 +1778,68 @@ static void __devinit quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev) | |||
1775 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, | 1778 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, |
1776 | quirk_nvidia_ck804_msi_ht_cap); | 1779 | quirk_nvidia_ck804_msi_ht_cap); |
1777 | 1780 | ||
1781 | /* | ||
1782 | * Force enable MSI mapping capability on HT bridges */ | ||
1783 | static inline void ht_enable_msi_mapping(struct pci_dev *dev) | ||
1784 | { | ||
1785 | int pos, ttl = 48; | ||
1786 | |||
1787 | pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING); | ||
1788 | while (pos && ttl--) { | ||
1789 | u8 flags; | ||
1790 | |||
1791 | if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, | ||
1792 | &flags) == 0) { | ||
1793 | dev_info(&dev->dev, "Enabling HT MSI Mapping\n"); | ||
1794 | |||
1795 | pci_write_config_byte(dev, pos + HT_MSI_FLAGS, | ||
1796 | flags | HT_MSI_FLAGS_ENABLE); | ||
1797 | } | ||
1798 | pos = pci_find_next_ht_capability(dev, pos, | ||
1799 | HT_CAPTYPE_MSI_MAPPING); | ||
1800 | } | ||
1801 | } | ||
1802 | |||
1803 | static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev) | ||
1804 | { | ||
1805 | struct pci_dev *host_bridge; | ||
1806 | int pos, ttl = 48; | ||
1807 | |||
1808 | /* | ||
1809 | * HT MSI mapping should be disabled on devices that are below | ||
1810 | * a non-Hypertransport host bridge. Locate the host bridge... | ||
1811 | */ | ||
1812 | host_bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)); | ||
1813 | if (host_bridge == NULL) { | ||
1814 | dev_warn(&dev->dev, | ||
1815 | "nv_msi_ht_cap_quirk didn't locate host bridge\n"); | ||
1816 | return; | ||
1817 | } | ||
1818 | |||
1819 | pos = pci_find_ht_capability(host_bridge, HT_CAPTYPE_SLAVE); | ||
1820 | if (pos != 0) { | ||
1821 | /* Host bridge is to HT */ | ||
1822 | ht_enable_msi_mapping(dev); | ||
1823 | return; | ||
1824 | } | ||
1825 | |||
1826 | /* Host bridge is not to HT, disable HT MSI mapping on this device */ | ||
1827 | pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING); | ||
1828 | while (pos && ttl--) { | ||
1829 | u8 flags; | ||
1830 | |||
1831 | if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, | ||
1832 | &flags) == 0) { | ||
1833 | dev_info(&dev->dev, "Quirk disabling HT MSI mapping"); | ||
1834 | pci_write_config_byte(dev, pos + HT_MSI_FLAGS, | ||
1835 | flags & ~HT_MSI_FLAGS_ENABLE); | ||
1836 | } | ||
1837 | pos = pci_find_next_ht_capability(dev, pos, | ||
1838 | HT_CAPTYPE_MSI_MAPPING); | ||
1839 | } | ||
1840 | } | ||
1841 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk); | ||
1842 | |||
1778 | static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev) | 1843 | static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev) |
1779 | { | 1844 | { |
1780 | dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG; | 1845 | dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG; |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 262b0439abe9..125e7b7f34ff 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -206,10 +206,8 @@ pci_setup_bridge(struct pci_bus *bus) | |||
206 | if (bus->resource[2]->flags & IORESOURCE_PREFETCH) { | 206 | if (bus->resource[2]->flags & IORESOURCE_PREFETCH) { |
207 | l = (region.start >> 16) & 0xfff0; | 207 | l = (region.start >> 16) & 0xfff0; |
208 | l |= region.end & 0xfff00000; | 208 | l |= region.end & 0xfff00000; |
209 | #ifdef CONFIG_RESOURCES_64BIT | 209 | bu = upper_32_bits(region.start); |
210 | bu = region.start >> 32; | 210 | lu = upper_32_bits(region.end); |
211 | lu = region.end >> 32; | ||
212 | #endif | ||
213 | DBG(KERN_INFO " PREFETCH window: 0x%016llx-0x%016llx\n", | 211 | DBG(KERN_INFO " PREFETCH window: 0x%016llx-0x%016llx\n", |
214 | (unsigned long long)region.start, | 212 | (unsigned long long)region.start, |
215 | (unsigned long long)region.end); | 213 | (unsigned long long)region.end); |
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c index 749515534cc0..e54ecc580d9e 100644 --- a/drivers/pcmcia/i82092.c +++ b/drivers/pcmcia/i82092.c | |||
@@ -647,7 +647,12 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_ | |||
647 | if ( (mem->card_start > 0x3ffffff) || (region.start > region.end) || | 647 | if ( (mem->card_start > 0x3ffffff) || (region.start > region.end) || |
648 | (mem->speed > 1000) ) { | 648 | (mem->speed > 1000) ) { |
649 | leave("i82092aa_set_mem_map: invalid address / speed"); | 649 | leave("i82092aa_set_mem_map: invalid address / speed"); |
650 | printk("invalid mem map for socket %i : %lx to %lx with a start of %x \n",sock,region.start, region.end, mem->card_start); | 650 | printk("invalid mem map for socket %i: %llx to %llx with a " |
651 | "start of %x\n", | ||
652 | sock, | ||
653 | (unsigned long long)region.start, | ||
654 | (unsigned long long)region.end, | ||
655 | mem->card_start); | ||
651 | return -EINVAL; | 656 | return -EINVAL; |
652 | } | 657 | } |
653 | 658 | ||
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 662b4c279cfc..c283a9a70d83 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c | |||
@@ -36,7 +36,7 @@ static int num = 0; | |||
36 | * have irqs (PIC, Timer) because we call acpi_register_gsi. | 36 | * have irqs (PIC, Timer) because we call acpi_register_gsi. |
37 | * Finally, only devices that have a CRS method need to be in this list. | 37 | * Finally, only devices that have a CRS method need to be in this list. |
38 | */ | 38 | */ |
39 | static struct __initdata acpi_device_id excluded_id_list[] = { | 39 | static struct acpi_device_id excluded_id_list[] __initdata = { |
40 | {"PNP0C09", 0}, /* EC */ | 40 | {"PNP0C09", 0}, /* EC */ |
41 | {"PNP0C0F", 0}, /* Link device */ | 41 | {"PNP0C0F", 0}, /* Link device */ |
42 | {"PNP0000", 0}, /* PIC */ | 42 | {"PNP0000", 0}, /* PIC */ |
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index f7e67197a568..a8a51500e1e9 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c | |||
@@ -105,8 +105,6 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) | |||
105 | char *argv[3], **envp, *buf, *scratch; | 105 | char *argv[3], **envp, *buf, *scratch; |
106 | int i = 0, value; | 106 | int i = 0, value; |
107 | 107 | ||
108 | if (!current->fs->root) | ||
109 | return -EAGAIN; | ||
110 | if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL))) | 108 | if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL))) |
111 | return -ENOMEM; | 109 | return -ENOMEM; |
112 | if (!(buf = kzalloc(256, GFP_KERNEL))) { | 110 | if (!(buf = kzalloc(256, GFP_KERNEL))) { |
diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c index 4c066545d176..6c9592ce4996 100644 --- a/drivers/ps3/ps3-lpm.c +++ b/drivers/ps3/ps3-lpm.c | |||
@@ -76,7 +76,6 @@ | |||
76 | * | 76 | * |
77 | * @pm_control: Shadow of the processor's pm_control register. | 77 | * @pm_control: Shadow of the processor's pm_control register. |
78 | * @pm_start_stop: Shadow of the processor's pm_start_stop register. | 78 | * @pm_start_stop: Shadow of the processor's pm_start_stop register. |
79 | * @pm_interval: Shadow of the processor's pm_interval register. | ||
80 | * @group_control: Shadow of the processor's group_control register. | 79 | * @group_control: Shadow of the processor's group_control register. |
81 | * @debug_bus_control: Shadow of the processor's debug_bus_control register. | 80 | * @debug_bus_control: Shadow of the processor's debug_bus_control register. |
82 | * | 81 | * |
@@ -91,7 +90,6 @@ | |||
91 | struct ps3_lpm_shadow_regs { | 90 | struct ps3_lpm_shadow_regs { |
92 | u64 pm_control; | 91 | u64 pm_control; |
93 | u64 pm_start_stop; | 92 | u64 pm_start_stop; |
94 | u64 pm_interval; | ||
95 | u64 group_control; | 93 | u64 group_control; |
96 | u64 debug_bus_control; | 94 | u64 debug_bus_control; |
97 | }; | 95 | }; |
@@ -181,9 +179,9 @@ void ps3_set_bookmark(u64 bookmark) | |||
181 | * includes cycles before the call. | 179 | * includes cycles before the call. |
182 | */ | 180 | */ |
183 | 181 | ||
184 | asm volatile("or 29, 29, 29;"); /* db10cyc */ | 182 | asm volatile("nop;nop;nop;nop;nop;nop;nop;nop;nop;"); |
185 | mtspr(SPRN_BKMK, bookmark); | 183 | mtspr(SPRN_BKMK, bookmark); |
186 | asm volatile("or 29, 29, 29;"); /* db10cyc */ | 184 | asm volatile("nop;nop;nop;nop;nop;nop;nop;nop;nop;"); |
187 | } | 185 | } |
188 | EXPORT_SYMBOL_GPL(ps3_set_bookmark); | 186 | EXPORT_SYMBOL_GPL(ps3_set_bookmark); |
189 | 187 | ||
@@ -408,7 +406,14 @@ u32 ps3_read_pm(u32 cpu, enum pm_reg_name reg) | |||
408 | case pm_start_stop: | 406 | case pm_start_stop: |
409 | return lpm_priv->shadow.pm_start_stop; | 407 | return lpm_priv->shadow.pm_start_stop; |
410 | case pm_interval: | 408 | case pm_interval: |
411 | return lpm_priv->shadow.pm_interval; | 409 | result = lv1_set_lpm_interval(lpm_priv->lpm_id, 0, 0, &val); |
410 | if (result) { | ||
411 | val = 0; | ||
412 | dev_dbg(sbd_core(), "%s:%u: lv1 set_inteval failed: " | ||
413 | "reg %u, %s\n", __func__, __LINE__, reg, | ||
414 | ps3_result(result)); | ||
415 | } | ||
416 | return (u32)val; | ||
412 | case group_control: | 417 | case group_control: |
413 | return lpm_priv->shadow.group_control; | 418 | return lpm_priv->shadow.group_control; |
414 | case debug_bus_control: | 419 | case debug_bus_control: |
@@ -475,10 +480,8 @@ void ps3_write_pm(u32 cpu, enum pm_reg_name reg, u32 val) | |||
475 | lpm_priv->shadow.pm_control = val; | 480 | lpm_priv->shadow.pm_control = val; |
476 | break; | 481 | break; |
477 | case pm_interval: | 482 | case pm_interval: |
478 | if (val != lpm_priv->shadow.pm_interval) | 483 | result = lv1_set_lpm_interval(lpm_priv->lpm_id, val, |
479 | result = lv1_set_lpm_interval(lpm_priv->lpm_id, val, | 484 | PS3_WRITE_PM_MASK, &dummy); |
480 | PS3_WRITE_PM_MASK, &dummy); | ||
481 | lpm_priv->shadow.pm_interval = val; | ||
482 | break; | 485 | break; |
483 | case pm_start_stop: | 486 | case pm_start_stop: |
484 | if (val != lpm_priv->shadow.pm_start_stop) | 487 | if (val != lpm_priv->shadow.pm_start_stop) |
@@ -1140,7 +1143,6 @@ int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache, | |||
1140 | 1143 | ||
1141 | lpm_priv->shadow.pm_control = PS3_LPM_SHADOW_REG_INIT; | 1144 | lpm_priv->shadow.pm_control = PS3_LPM_SHADOW_REG_INIT; |
1142 | lpm_priv->shadow.pm_start_stop = PS3_LPM_SHADOW_REG_INIT; | 1145 | lpm_priv->shadow.pm_start_stop = PS3_LPM_SHADOW_REG_INIT; |
1143 | lpm_priv->shadow.pm_interval = PS3_LPM_SHADOW_REG_INIT; | ||
1144 | lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT; | 1146 | lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT; |
1145 | lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT; | 1147 | lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT; |
1146 | 1148 | ||
diff --git a/drivers/ps3/ps3-sys-manager.c b/drivers/ps3/ps3-sys-manager.c index c3c3aba3ffce..d4f6f960dd18 100644 --- a/drivers/ps3/ps3-sys-manager.c +++ b/drivers/ps3/ps3-sys-manager.c | |||
@@ -28,10 +28,6 @@ | |||
28 | 28 | ||
29 | #include "vuart.h" | 29 | #include "vuart.h" |
30 | 30 | ||
31 | MODULE_AUTHOR("Sony Corporation"); | ||
32 | MODULE_LICENSE("GPL v2"); | ||
33 | MODULE_DESCRIPTION("PS3 System Manager"); | ||
34 | |||
35 | /** | 31 | /** |
36 | * ps3_sys_manager - PS3 system manager driver. | 32 | * ps3_sys_manager - PS3 system manager driver. |
37 | * | 33 | * |
@@ -142,9 +138,11 @@ enum ps3_sys_manager_attr { | |||
142 | 138 | ||
143 | /** | 139 | /** |
144 | * enum ps3_sys_manager_event - External event type, reported by system manager. | 140 | * enum ps3_sys_manager_event - External event type, reported by system manager. |
145 | * @PS3_SM_EVENT_POWER_PRESSED: payload.value not used. | 141 | * @PS3_SM_EVENT_POWER_PRESSED: payload.value = |
142 | * enum ps3_sys_manager_button_event. | ||
146 | * @PS3_SM_EVENT_POWER_RELEASED: payload.value = time pressed in millisec. | 143 | * @PS3_SM_EVENT_POWER_RELEASED: payload.value = time pressed in millisec. |
147 | * @PS3_SM_EVENT_RESET_PRESSED: payload.value not used. | 144 | * @PS3_SM_EVENT_RESET_PRESSED: payload.value = |
145 | * enum ps3_sys_manager_button_event. | ||
148 | * @PS3_SM_EVENT_RESET_RELEASED: payload.value = time pressed in millisec. | 146 | * @PS3_SM_EVENT_RESET_RELEASED: payload.value = time pressed in millisec. |
149 | * @PS3_SM_EVENT_THERMAL_ALERT: payload.value = thermal zone id. | 147 | * @PS3_SM_EVENT_THERMAL_ALERT: payload.value = thermal zone id. |
150 | * @PS3_SM_EVENT_THERMAL_CLEARED: payload.value = thermal zone id. | 148 | * @PS3_SM_EVENT_THERMAL_CLEARED: payload.value = thermal zone id. |
@@ -162,6 +160,17 @@ enum ps3_sys_manager_event { | |||
162 | }; | 160 | }; |
163 | 161 | ||
164 | /** | 162 | /** |
163 | * enum ps3_sys_manager_button_event - Button event payload values. | ||
164 | * @PS3_SM_BUTTON_EVENT_HARD: Hardware generated event. | ||
165 | * @PS3_SM_BUTTON_EVENT_SOFT: Software generated event. | ||
166 | */ | ||
167 | |||
168 | enum ps3_sys_manager_button_event { | ||
169 | PS3_SM_BUTTON_EVENT_HARD = 0, | ||
170 | PS3_SM_BUTTON_EVENT_SOFT = 1, | ||
171 | }; | ||
172 | |||
173 | /** | ||
165 | * enum ps3_sys_manager_next_op - Operation to perform after lpar is destroyed. | 174 | * enum ps3_sys_manager_next_op - Operation to perform after lpar is destroyed. |
166 | */ | 175 | */ |
167 | 176 | ||
@@ -181,7 +190,9 @@ enum ps3_sys_manager_next_op { | |||
181 | * @PS3_SM_WAKE_P_O_R: Power on reset. | 190 | * @PS3_SM_WAKE_P_O_R: Power on reset. |
182 | * | 191 | * |
183 | * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN. | 192 | * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN. |
184 | * System will always wake from the PS3_SM_WAKE_DEFAULT sources. | 193 | * The system will always wake from the PS3_SM_WAKE_DEFAULT sources. |
194 | * Sources listed here are the only ones available to guests in the | ||
195 | * other-os lpar. | ||
185 | */ | 196 | */ |
186 | 197 | ||
187 | enum ps3_sys_manager_wake_source { | 198 | enum ps3_sys_manager_wake_source { |
@@ -189,7 +200,7 @@ enum ps3_sys_manager_wake_source { | |||
189 | PS3_SM_WAKE_DEFAULT = 0, | 200 | PS3_SM_WAKE_DEFAULT = 0, |
190 | PS3_SM_WAKE_RTC = 0x00000040, | 201 | PS3_SM_WAKE_RTC = 0x00000040, |
191 | PS3_SM_WAKE_RTC_ERROR = 0x00000080, | 202 | PS3_SM_WAKE_RTC_ERROR = 0x00000080, |
192 | PS3_SM_WAKE_P_O_R = 0x10000000, | 203 | PS3_SM_WAKE_P_O_R = 0x80000000, |
193 | }; | 204 | }; |
194 | 205 | ||
195 | /** | 206 | /** |
@@ -418,8 +429,10 @@ static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev) | |||
418 | 429 | ||
419 | switch (event.type) { | 430 | switch (event.type) { |
420 | case PS3_SM_EVENT_POWER_PRESSED: | 431 | case PS3_SM_EVENT_POWER_PRESSED: |
421 | dev_dbg(&dev->core, "%s:%d: POWER_PRESSED\n", | 432 | dev_dbg(&dev->core, "%s:%d: POWER_PRESSED (%s)\n", |
422 | __func__, __LINE__); | 433 | __func__, __LINE__, |
434 | (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft" | ||
435 | : "hard")); | ||
423 | ps3_sm_force_power_off = 1; | 436 | ps3_sm_force_power_off = 1; |
424 | /* | 437 | /* |
425 | * A memory barrier is use here to sync memory since | 438 | * A memory barrier is use here to sync memory since |
@@ -434,8 +447,10 @@ static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev) | |||
434 | __func__, __LINE__, event.value); | 447 | __func__, __LINE__, event.value); |
435 | break; | 448 | break; |
436 | case PS3_SM_EVENT_RESET_PRESSED: | 449 | case PS3_SM_EVENT_RESET_PRESSED: |
437 | dev_dbg(&dev->core, "%s:%d: RESET_PRESSED\n", | 450 | dev_dbg(&dev->core, "%s:%d: RESET_PRESSED (%s)\n", |
438 | __func__, __LINE__); | 451 | __func__, __LINE__, |
452 | (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft" | ||
453 | : "hard")); | ||
439 | ps3_sm_force_power_off = 0; | 454 | ps3_sm_force_power_off = 0; |
440 | /* | 455 | /* |
441 | * A memory barrier is use here to sync memory since | 456 | * A memory barrier is use here to sync memory since |
@@ -622,7 +637,7 @@ static void ps3_sys_manager_final_restart(struct ps3_system_bus_device *dev) | |||
622 | ps3_vuart_cancel_async(dev); | 637 | ps3_vuart_cancel_async(dev); |
623 | 638 | ||
624 | ps3_sys_manager_send_attr(dev, 0); | 639 | ps3_sys_manager_send_attr(dev, 0); |
625 | ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_LPAR_REBOOT, | 640 | ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_REBOOT, |
626 | PS3_SM_WAKE_DEFAULT); | 641 | PS3_SM_WAKE_DEFAULT); |
627 | ps3_sys_manager_send_request_shutdown(dev); | 642 | ps3_sys_manager_send_request_shutdown(dev); |
628 | 643 | ||
@@ -699,4 +714,7 @@ static int __init ps3_sys_manager_init(void) | |||
699 | module_init(ps3_sys_manager_init); | 714 | module_init(ps3_sys_manager_init); |
700 | /* Module remove not supported. */ | 715 | /* Module remove not supported. */ |
701 | 716 | ||
717 | MODULE_AUTHOR("Sony Corporation"); | ||
718 | MODULE_LICENSE("GPL v2"); | ||
719 | MODULE_DESCRIPTION("PS3 System Manager"); | ||
702 | MODULE_ALIAS(PS3_MODULE_ALIAS_SYSTEM_MANAGER); | 720 | MODULE_ALIAS(PS3_MODULE_ALIAS_SYSTEM_MANAGER); |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index e059f94c79eb..f3ee2ad566b4 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -388,6 +388,7 @@ static int cmos_procfs(struct device *dev, struct seq_file *seq) | |||
388 | return seq_printf(seq, | 388 | return seq_printf(seq, |
389 | "periodic_IRQ\t: %s\n" | 389 | "periodic_IRQ\t: %s\n" |
390 | "update_IRQ\t: %s\n" | 390 | "update_IRQ\t: %s\n" |
391 | "HPET_emulated\t: %s\n" | ||
391 | // "square_wave\t: %s\n" | 392 | // "square_wave\t: %s\n" |
392 | // "BCD\t\t: %s\n" | 393 | // "BCD\t\t: %s\n" |
393 | "DST_enable\t: %s\n" | 394 | "DST_enable\t: %s\n" |
@@ -395,6 +396,7 @@ static int cmos_procfs(struct device *dev, struct seq_file *seq) | |||
395 | "batt_status\t: %s\n", | 396 | "batt_status\t: %s\n", |
396 | (rtc_control & RTC_PIE) ? "yes" : "no", | 397 | (rtc_control & RTC_PIE) ? "yes" : "no", |
397 | (rtc_control & RTC_UIE) ? "yes" : "no", | 398 | (rtc_control & RTC_UIE) ? "yes" : "no", |
399 | is_hpet_enabled() ? "yes" : "no", | ||
398 | // (rtc_control & RTC_SQWE) ? "yes" : "no", | 400 | // (rtc_control & RTC_SQWE) ? "yes" : "no", |
399 | // (rtc_control & RTC_DM_BINARY) ? "no" : "yes", | 401 | // (rtc_control & RTC_DM_BINARY) ? "no" : "yes", |
400 | (rtc_control & RTC_DST_EN) ? "yes" : "no", | 402 | (rtc_control & RTC_DST_EN) ? "yes" : "no", |
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index d984e0fae630..ccf46c96adb4 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c | |||
@@ -1149,12 +1149,14 @@ static void __dasd_device_process_final_queue(struct dasd_device *device, | |||
1149 | { | 1149 | { |
1150 | struct list_head *l, *n; | 1150 | struct list_head *l, *n; |
1151 | struct dasd_ccw_req *cqr; | 1151 | struct dasd_ccw_req *cqr; |
1152 | struct dasd_block *block; | ||
1152 | 1153 | ||
1153 | list_for_each_safe(l, n, final_queue) { | 1154 | list_for_each_safe(l, n, final_queue) { |
1154 | cqr = list_entry(l, struct dasd_ccw_req, devlist); | 1155 | cqr = list_entry(l, struct dasd_ccw_req, devlist); |
1155 | list_del_init(&cqr->devlist); | 1156 | list_del_init(&cqr->devlist); |
1156 | if (cqr->block) | 1157 | block = cqr->block; |
1157 | spin_lock_bh(&cqr->block->queue_lock); | 1158 | if (block) |
1159 | spin_lock_bh(&block->queue_lock); | ||
1158 | switch (cqr->status) { | 1160 | switch (cqr->status) { |
1159 | case DASD_CQR_SUCCESS: | 1161 | case DASD_CQR_SUCCESS: |
1160 | cqr->status = DASD_CQR_DONE; | 1162 | cqr->status = DASD_CQR_DONE; |
@@ -1172,15 +1174,13 @@ static void __dasd_device_process_final_queue(struct dasd_device *device, | |||
1172 | cqr, cqr->status); | 1174 | cqr, cqr->status); |
1173 | BUG(); | 1175 | BUG(); |
1174 | } | 1176 | } |
1175 | if (cqr->block) | ||
1176 | spin_unlock_bh(&cqr->block->queue_lock); | ||
1177 | if (cqr->callback != NULL) | 1177 | if (cqr->callback != NULL) |
1178 | (cqr->callback)(cqr, cqr->callback_data); | 1178 | (cqr->callback)(cqr, cqr->callback_data); |
1179 | if (block) | ||
1180 | spin_unlock_bh(&block->queue_lock); | ||
1179 | } | 1181 | } |
1180 | } | 1182 | } |
1181 | 1183 | ||
1182 | |||
1183 | |||
1184 | /* | 1184 | /* |
1185 | * Take a look at the first request on the ccw queue and check | 1185 | * Take a look at the first request on the ccw queue and check |
1186 | * if it reached its expire time. If so, terminate the IO. | 1186 | * if it reached its expire time. If so, terminate the IO. |
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 3faf0538b328..e6c94dbfdeaa 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c | |||
@@ -666,7 +666,7 @@ dcssblk_make_request(struct request_queue *q, struct bio *bio) | |||
666 | page_addr = (unsigned long) | 666 | page_addr = (unsigned long) |
667 | page_address(bvec->bv_page) + bvec->bv_offset; | 667 | page_address(bvec->bv_page) + bvec->bv_offset; |
668 | source_addr = dev_info->start + (index<<12) + bytes_done; | 668 | source_addr = dev_info->start + (index<<12) + bytes_done; |
669 | if (unlikely(page_addr & 4095) != 0 || (bvec->bv_len & 4095) != 0) | 669 | if (unlikely((page_addr & 4095) != 0) || (bvec->bv_len & 4095) != 0) |
670 | // More paranoia. | 670 | // More paranoia. |
671 | goto fail; | 671 | goto fail; |
672 | if (bio_data_dir(bio) == READ) { | 672 | if (bio_data_dir(bio) == READ) { |
diff --git a/drivers/s390/char/sclp.c b/drivers/s390/char/sclp.c index 25629b92dec3..2c7a1ee6b041 100644 --- a/drivers/s390/char/sclp.c +++ b/drivers/s390/char/sclp.c | |||
@@ -29,10 +29,10 @@ static ext_int_info_t ext_int_info_hwc; | |||
29 | /* Lock to protect internal data consistency. */ | 29 | /* Lock to protect internal data consistency. */ |
30 | static DEFINE_SPINLOCK(sclp_lock); | 30 | static DEFINE_SPINLOCK(sclp_lock); |
31 | 31 | ||
32 | /* Mask of events that we can receive from the sclp interface. */ | 32 | /* Mask of events that we can send to the sclp interface. */ |
33 | static sccb_mask_t sclp_receive_mask; | 33 | static sccb_mask_t sclp_receive_mask; |
34 | 34 | ||
35 | /* Mask of events that we can send to the sclp interface. */ | 35 | /* Mask of events that we can receive from the sclp interface. */ |
36 | static sccb_mask_t sclp_send_mask; | 36 | static sccb_mask_t sclp_send_mask; |
37 | 37 | ||
38 | /* List of registered event listeners and senders. */ | 38 | /* List of registered event listeners and senders. */ |
@@ -380,7 +380,7 @@ sclp_interrupt_handler(__u16 code) | |||
380 | } | 380 | } |
381 | sclp_running_state = sclp_running_state_idle; | 381 | sclp_running_state = sclp_running_state_idle; |
382 | } | 382 | } |
383 | if (evbuf_pending && sclp_receive_mask != 0 && | 383 | if (evbuf_pending && |
384 | sclp_activation_state == sclp_activation_state_active) | 384 | sclp_activation_state == sclp_activation_state_active) |
385 | __sclp_queue_read_req(); | 385 | __sclp_queue_read_req(); |
386 | spin_unlock(&sclp_lock); | 386 | spin_unlock(&sclp_lock); |
@@ -459,8 +459,8 @@ sclp_dispatch_state_change(void) | |||
459 | reg = NULL; | 459 | reg = NULL; |
460 | list_for_each(l, &sclp_reg_list) { | 460 | list_for_each(l, &sclp_reg_list) { |
461 | reg = list_entry(l, struct sclp_register, list); | 461 | reg = list_entry(l, struct sclp_register, list); |
462 | receive_mask = reg->receive_mask & sclp_receive_mask; | 462 | receive_mask = reg->send_mask & sclp_receive_mask; |
463 | send_mask = reg->send_mask & sclp_send_mask; | 463 | send_mask = reg->receive_mask & sclp_send_mask; |
464 | if (reg->sclp_receive_mask != receive_mask || | 464 | if (reg->sclp_receive_mask != receive_mask || |
465 | reg->sclp_send_mask != send_mask) { | 465 | reg->sclp_send_mask != send_mask) { |
466 | reg->sclp_receive_mask = receive_mask; | 466 | reg->sclp_receive_mask = receive_mask; |
@@ -615,8 +615,8 @@ struct init_sccb { | |||
615 | u16 mask_length; | 615 | u16 mask_length; |
616 | sccb_mask_t receive_mask; | 616 | sccb_mask_t receive_mask; |
617 | sccb_mask_t send_mask; | 617 | sccb_mask_t send_mask; |
618 | sccb_mask_t sclp_send_mask; | ||
619 | sccb_mask_t sclp_receive_mask; | 618 | sccb_mask_t sclp_receive_mask; |
619 | sccb_mask_t sclp_send_mask; | ||
620 | } __attribute__((packed)); | 620 | } __attribute__((packed)); |
621 | 621 | ||
622 | /* Prepare init mask request. Called while sclp_lock is locked. */ | 622 | /* Prepare init mask request. Called while sclp_lock is locked. */ |
diff --git a/drivers/s390/char/sclp.h b/drivers/s390/char/sclp.h index aa8186d18aee..bac80e856f97 100644 --- a/drivers/s390/char/sclp.h +++ b/drivers/s390/char/sclp.h | |||
@@ -122,11 +122,13 @@ struct sclp_req { | |||
122 | /* of some routines it wants to be called from the low level driver */ | 122 | /* of some routines it wants to be called from the low level driver */ |
123 | struct sclp_register { | 123 | struct sclp_register { |
124 | struct list_head list; | 124 | struct list_head list; |
125 | /* event masks this user is registered for */ | 125 | /* User wants to receive: */ |
126 | sccb_mask_t receive_mask; | 126 | sccb_mask_t receive_mask; |
127 | /* User wants to send: */ | ||
127 | sccb_mask_t send_mask; | 128 | sccb_mask_t send_mask; |
128 | /* actually present events */ | 129 | /* H/W can receive: */ |
129 | sccb_mask_t sclp_receive_mask; | 130 | sccb_mask_t sclp_receive_mask; |
131 | /* H/W can send: */ | ||
130 | sccb_mask_t sclp_send_mask; | 132 | sccb_mask_t sclp_send_mask; |
131 | /* called if event type availability changes */ | 133 | /* called if event type availability changes */ |
132 | void (*state_change_fn)(struct sclp_register *); | 134 | void (*state_change_fn)(struct sclp_register *); |
diff --git a/drivers/s390/char/sclp_config.c b/drivers/s390/char/sclp_config.c index 9dc77f14fa52..b8f35bc52b7b 100644 --- a/drivers/s390/char/sclp_config.c +++ b/drivers/s390/char/sclp_config.c | |||
@@ -64,7 +64,7 @@ static int __init sclp_conf_init(void) | |||
64 | return rc; | 64 | return rc; |
65 | } | 65 | } |
66 | 66 | ||
67 | if (!(sclp_conf_register.sclp_receive_mask & EVTYP_CONFMGMDATA_MASK)) { | 67 | if (!(sclp_conf_register.sclp_send_mask & EVTYP_CONFMGMDATA_MASK)) { |
68 | printk(KERN_WARNING TAG "no configuration management.\n"); | 68 | printk(KERN_WARNING TAG "no configuration management.\n"); |
69 | sclp_unregister(&sclp_conf_register); | 69 | sclp_unregister(&sclp_conf_register); |
70 | rc = -ENOSYS; | 70 | rc = -ENOSYS; |
diff --git a/drivers/s390/char/sclp_cpi_sys.c b/drivers/s390/char/sclp_cpi_sys.c index 41617032afdc..9f37456222e9 100644 --- a/drivers/s390/char/sclp_cpi_sys.c +++ b/drivers/s390/char/sclp_cpi_sys.c | |||
@@ -129,7 +129,7 @@ static int cpi_req(void) | |||
129 | "to hardware console.\n"); | 129 | "to hardware console.\n"); |
130 | goto out; | 130 | goto out; |
131 | } | 131 | } |
132 | if (!(sclp_cpi_event.sclp_send_mask & EVTYP_CTLPROGIDENT_MASK)) { | 132 | if (!(sclp_cpi_event.sclp_receive_mask & EVTYP_CTLPROGIDENT_MASK)) { |
133 | printk(KERN_WARNING "cpi: no control program " | 133 | printk(KERN_WARNING "cpi: no control program " |
134 | "identification support\n"); | 134 | "identification support\n"); |
135 | rc = -EOPNOTSUPP; | 135 | rc = -EOPNOTSUPP; |
diff --git a/drivers/s390/char/sclp_rw.c b/drivers/s390/char/sclp_rw.c index ad7195d3de0c..da09781b32f7 100644 --- a/drivers/s390/char/sclp_rw.c +++ b/drivers/s390/char/sclp_rw.c | |||
@@ -452,10 +452,10 @@ sclp_emit_buffer(struct sclp_buffer *buffer, | |||
452 | return -EIO; | 452 | return -EIO; |
453 | 453 | ||
454 | sccb = buffer->sccb; | 454 | sccb = buffer->sccb; |
455 | if (sclp_rw_event.sclp_send_mask & EVTYP_MSG_MASK) | 455 | if (sclp_rw_event.sclp_receive_mask & EVTYP_MSG_MASK) |
456 | /* Use normal write message */ | 456 | /* Use normal write message */ |
457 | sccb->msg_buf.header.type = EVTYP_MSG; | 457 | sccb->msg_buf.header.type = EVTYP_MSG; |
458 | else if (sclp_rw_event.sclp_send_mask & EVTYP_PMSGCMD_MASK) | 458 | else if (sclp_rw_event.sclp_receive_mask & EVTYP_PMSGCMD_MASK) |
459 | /* Use write priority message */ | 459 | /* Use write priority message */ |
460 | sccb->msg_buf.header.type = EVTYP_PMSGCMD; | 460 | sccb->msg_buf.header.type = EVTYP_PMSGCMD; |
461 | else | 461 | else |
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index f47f4a768be5..92f527201792 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c | |||
@@ -202,7 +202,7 @@ sclp_vt220_callback(struct sclp_req *request, void *data) | |||
202 | static int | 202 | static int |
203 | __sclp_vt220_emit(struct sclp_vt220_request *request) | 203 | __sclp_vt220_emit(struct sclp_vt220_request *request) |
204 | { | 204 | { |
205 | if (!(sclp_vt220_register.sclp_send_mask & EVTYP_VT220MSG_MASK)) { | 205 | if (!(sclp_vt220_register.sclp_receive_mask & EVTYP_VT220MSG_MASK)) { |
206 | request->sclp_req.status = SCLP_REQ_FAILED; | 206 | request->sclp_req.status = SCLP_REQ_FAILED; |
207 | return -EIO; | 207 | return -EIO; |
208 | } | 208 | } |
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index d35dc3f25d06..fec004f62bcf 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "io_sch.h" | 32 | #include "io_sch.h" |
33 | 33 | ||
34 | static struct timer_list recovery_timer; | 34 | static struct timer_list recovery_timer; |
35 | static spinlock_t recovery_lock; | 35 | static DEFINE_SPINLOCK(recovery_lock); |
36 | static int recovery_phase; | 36 | static int recovery_phase; |
37 | static const unsigned long recovery_delay[] = { 3, 30, 300 }; | 37 | static const unsigned long recovery_delay[] = { 3, 30, 300 }; |
38 | 38 | ||
@@ -1535,7 +1535,7 @@ static int recovery_check(struct device *dev, void *data) | |||
1535 | return 0; | 1535 | return 0; |
1536 | } | 1536 | } |
1537 | 1537 | ||
1538 | static void recovery_func(unsigned long data) | 1538 | static void recovery_work_func(struct work_struct *unused) |
1539 | { | 1539 | { |
1540 | int redo = 0; | 1540 | int redo = 0; |
1541 | 1541 | ||
@@ -1553,6 +1553,17 @@ static void recovery_func(unsigned long data) | |||
1553 | CIO_MSG_EVENT(2, "recovery: end\n"); | 1553 | CIO_MSG_EVENT(2, "recovery: end\n"); |
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | static DECLARE_WORK(recovery_work, recovery_work_func); | ||
1557 | |||
1558 | static void recovery_func(unsigned long data) | ||
1559 | { | ||
1560 | /* | ||
1561 | * We can't do our recovery in softirq context and it's not | ||
1562 | * performance critical, so we schedule it. | ||
1563 | */ | ||
1564 | schedule_work(&recovery_work); | ||
1565 | } | ||
1566 | |||
1556 | void ccw_device_schedule_recovery(void) | 1567 | void ccw_device_schedule_recovery(void) |
1557 | { | 1568 | { |
1558 | unsigned long flags; | 1569 | unsigned long flags; |
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index 097fc0967e9d..2b5bfb7c69e5 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c | |||
@@ -32,7 +32,7 @@ | |||
32 | 32 | ||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | 35 | #include <linux/delay.h> | |
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
@@ -1215,9 +1215,6 @@ tiqdio_is_inbound_q_done(struct qdio_q *q) | |||
1215 | 1215 | ||
1216 | if (!no_used) | 1216 | if (!no_used) |
1217 | return 1; | 1217 | return 1; |
1218 | if (!q->siga_sync && !irq->is_qebsm) | ||
1219 | /* we'll check for more primed buffers in qeth_stop_polling */ | ||
1220 | return 0; | ||
1221 | if (irq->is_qebsm) { | 1218 | if (irq->is_qebsm) { |
1222 | count = 1; | 1219 | count = 1; |
1223 | start_buf = q->first_to_check; | 1220 | start_buf = q->first_to_check; |
@@ -3332,13 +3329,7 @@ qdio_activate(struct ccw_device *cdev, int flags) | |||
3332 | } | 3329 | } |
3333 | } | 3330 | } |
3334 | 3331 | ||
3335 | wait_event_interruptible_timeout(cdev->private->wait_q, | 3332 | msleep(QDIO_ACTIVATE_TIMEOUT); |
3336 | ((irq_ptr->state == | ||
3337 | QDIO_IRQ_STATE_STOPPED) || | ||
3338 | (irq_ptr->state == | ||
3339 | QDIO_IRQ_STATE_ERR)), | ||
3340 | QDIO_ACTIVATE_TIMEOUT); | ||
3341 | |||
3342 | switch (irq_ptr->state) { | 3333 | switch (irq_ptr->state) { |
3343 | case QDIO_IRQ_STATE_STOPPED: | 3334 | case QDIO_IRQ_STATE_STOPPED: |
3344 | case QDIO_IRQ_STATE_ERR: | 3335 | case QDIO_IRQ_STATE_ERR: |
diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h index 37870e4e938e..da8a272fd75b 100644 --- a/drivers/s390/cio/qdio.h +++ b/drivers/s390/cio/qdio.h | |||
@@ -57,10 +57,10 @@ | |||
57 | of the queue to 0 */ | 57 | of the queue to 0 */ |
58 | 58 | ||
59 | #define QDIO_ESTABLISH_TIMEOUT (1*HZ) | 59 | #define QDIO_ESTABLISH_TIMEOUT (1*HZ) |
60 | #define QDIO_ACTIVATE_TIMEOUT (5*HZ) | ||
61 | #define QDIO_CLEANUP_CLEAR_TIMEOUT (20*HZ) | 60 | #define QDIO_CLEANUP_CLEAR_TIMEOUT (20*HZ) |
62 | #define QDIO_CLEANUP_HALT_TIMEOUT (10*HZ) | 61 | #define QDIO_CLEANUP_HALT_TIMEOUT (10*HZ) |
63 | #define QDIO_FORCE_CHECK_TIMEOUT (10*HZ) | 62 | #define QDIO_FORCE_CHECK_TIMEOUT (10*HZ) |
63 | #define QDIO_ACTIVATE_TIMEOUT (5) /* 5 ms */ | ||
64 | 64 | ||
65 | enum qdio_irq_states { | 65 | enum qdio_irq_states { |
66 | QDIO_IRQ_STATE_INACTIVE, | 66 | QDIO_IRQ_STATE_INACTIVE, |
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index a5f0aaaf0dd4..c46666a24809 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -722,7 +722,7 @@ config SCSI_FD_MCS | |||
722 | 722 | ||
723 | config SCSI_GDTH | 723 | config SCSI_GDTH |
724 | tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support" | 724 | tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support" |
725 | depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API && PCI_LEGACY | 725 | depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API |
726 | ---help--- | 726 | ---help--- |
727 | Formerly called GDT SCSI Disk Array Controller Support. | 727 | Formerly called GDT SCSI Disk Array Controller Support. |
728 | 728 | ||
@@ -992,6 +992,16 @@ config SCSI_IZIP_SLOW_CTR | |||
992 | 992 | ||
993 | Generally, saying N is fine. | 993 | Generally, saying N is fine. |
994 | 994 | ||
995 | config SCSI_MVSAS | ||
996 | tristate "Marvell 88SE6440 SAS/SATA support" | ||
997 | depends on PCI && SCSI | ||
998 | select SCSI_SAS_LIBSAS | ||
999 | help | ||
1000 | This driver supports Marvell SAS/SATA PCI devices. | ||
1001 | |||
1002 | To compiler this driver as a module, choose M here: the module | ||
1003 | will be called mvsas. | ||
1004 | |||
995 | config SCSI_NCR53C406A | 1005 | config SCSI_NCR53C406A |
996 | tristate "NCR53c406a SCSI support" | 1006 | tristate "NCR53c406a SCSI support" |
997 | depends on ISA && SCSI | 1007 | depends on ISA && SCSI |
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 925c26b4fff9..23e6ecbd4778 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile | |||
@@ -119,6 +119,7 @@ obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/ | |||
119 | obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/ | 119 | obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/ |
120 | obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o | 120 | obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o |
121 | obj-$(CONFIG_SCSI_STEX) += stex.o | 121 | obj-$(CONFIG_SCSI_STEX) += stex.o |
122 | obj-$(CONFIG_SCSI_MVSAS) += mvsas.o | ||
122 | obj-$(CONFIG_PS3_ROM) += ps3rom.o | 123 | obj-$(CONFIG_PS3_ROM) += ps3rom.o |
123 | 124 | ||
124 | obj-$(CONFIG_ARM) += arm/ | 125 | obj-$(CONFIG_ARM) += arm/ |
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index bfd0e64964ac..c05092fd3a9d 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -144,51 +144,77 @@ static char *aac_get_status_string(u32 status); | |||
144 | */ | 144 | */ |
145 | 145 | ||
146 | static int nondasd = -1; | 146 | static int nondasd = -1; |
147 | static int aac_cache = 0; | 147 | static int aac_cache; |
148 | static int dacmode = -1; | 148 | static int dacmode = -1; |
149 | 149 | int aac_msi; | |
150 | int aac_commit = -1; | 150 | int aac_commit = -1; |
151 | int startup_timeout = 180; | 151 | int startup_timeout = 180; |
152 | int aif_timeout = 120; | 152 | int aif_timeout = 120; |
153 | 153 | ||
154 | module_param(nondasd, int, S_IRUGO|S_IWUSR); | 154 | module_param(nondasd, int, S_IRUGO|S_IWUSR); |
155 | MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices. 0=off, 1=on"); | 155 | MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices." |
156 | " 0=off, 1=on"); | ||
156 | module_param_named(cache, aac_cache, int, S_IRUGO|S_IWUSR); | 157 | module_param_named(cache, aac_cache, int, S_IRUGO|S_IWUSR); |
157 | MODULE_PARM_DESC(cache, "Disable Queue Flush commands:\n\tbit 0 - Disable FUA in WRITE SCSI commands\n\tbit 1 - Disable SYNCHRONIZE_CACHE SCSI command\n\tbit 2 - Disable only if Battery not protecting Cache"); | 158 | MODULE_PARM_DESC(cache, "Disable Queue Flush commands:\n" |
159 | "\tbit 0 - Disable FUA in WRITE SCSI commands\n" | ||
160 | "\tbit 1 - Disable SYNCHRONIZE_CACHE SCSI command\n" | ||
161 | "\tbit 2 - Disable only if Battery not protecting Cache"); | ||
158 | module_param(dacmode, int, S_IRUGO|S_IWUSR); | 162 | module_param(dacmode, int, S_IRUGO|S_IWUSR); |
159 | MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on"); | 163 | MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC." |
164 | " 0=off, 1=on"); | ||
160 | module_param_named(commit, aac_commit, int, S_IRUGO|S_IWUSR); | 165 | module_param_named(commit, aac_commit, int, S_IRUGO|S_IWUSR); |
161 | MODULE_PARM_DESC(commit, "Control whether a COMMIT_CONFIG is issued to the adapter for foreign arrays.\nThis is typically needed in systems that do not have a BIOS. 0=off, 1=on"); | 166 | MODULE_PARM_DESC(commit, "Control whether a COMMIT_CONFIG is issued to the" |
167 | " adapter for foreign arrays.\n" | ||
168 | "This is typically needed in systems that do not have a BIOS." | ||
169 | " 0=off, 1=on"); | ||
170 | module_param_named(msi, aac_msi, int, S_IRUGO|S_IWUSR); | ||
171 | MODULE_PARM_DESC(msi, "IRQ handling." | ||
172 | " 0=PIC(default), 1=MSI, 2=MSI-X(unsupported, uses MSI)"); | ||
162 | module_param(startup_timeout, int, S_IRUGO|S_IWUSR); | 173 | module_param(startup_timeout, int, S_IRUGO|S_IWUSR); |
163 | MODULE_PARM_DESC(startup_timeout, "The duration of time in seconds to wait for adapter to have it's kernel up and\nrunning. This is typically adjusted for large systems that do not have a BIOS."); | 174 | MODULE_PARM_DESC(startup_timeout, "The duration of time in seconds to wait for" |
175 | " adapter to have it's kernel up and\n" | ||
176 | "running. This is typically adjusted for large systems that do not" | ||
177 | " have a BIOS."); | ||
164 | module_param(aif_timeout, int, S_IRUGO|S_IWUSR); | 178 | module_param(aif_timeout, int, S_IRUGO|S_IWUSR); |
165 | MODULE_PARM_DESC(aif_timeout, "The duration of time in seconds to wait for applications to pick up AIFs before\nderegistering them. This is typically adjusted for heavily burdened systems."); | 179 | MODULE_PARM_DESC(aif_timeout, "The duration of time in seconds to wait for" |
180 | " applications to pick up AIFs before\n" | ||
181 | "deregistering them. This is typically adjusted for heavily burdened" | ||
182 | " systems."); | ||
166 | 183 | ||
167 | int numacb = -1; | 184 | int numacb = -1; |
168 | module_param(numacb, int, S_IRUGO|S_IWUSR); | 185 | module_param(numacb, int, S_IRUGO|S_IWUSR); |
169 | MODULE_PARM_DESC(numacb, "Request a limit to the number of adapter control blocks (FIB) allocated. Valid values are 512 and down. Default is to use suggestion from Firmware."); | 186 | MODULE_PARM_DESC(numacb, "Request a limit to the number of adapter control" |
187 | " blocks (FIB) allocated. Valid values are 512 and down. Default is" | ||
188 | " to use suggestion from Firmware."); | ||
170 | 189 | ||
171 | int acbsize = -1; | 190 | int acbsize = -1; |
172 | module_param(acbsize, int, S_IRUGO|S_IWUSR); | 191 | module_param(acbsize, int, S_IRUGO|S_IWUSR); |
173 | MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB) size. Valid values are 512, 2048, 4096 and 8192. Default is to use suggestion from Firmware."); | 192 | MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB)" |
193 | " size. Valid values are 512, 2048, 4096 and 8192. Default is to use" | ||
194 | " suggestion from Firmware."); | ||
174 | 195 | ||
175 | int update_interval = 30 * 60; | 196 | int update_interval = 30 * 60; |
176 | module_param(update_interval, int, S_IRUGO|S_IWUSR); | 197 | module_param(update_interval, int, S_IRUGO|S_IWUSR); |
177 | MODULE_PARM_DESC(update_interval, "Interval in seconds between time sync updates issued to adapter."); | 198 | MODULE_PARM_DESC(update_interval, "Interval in seconds between time sync" |
199 | " updates issued to adapter."); | ||
178 | 200 | ||
179 | int check_interval = 24 * 60 * 60; | 201 | int check_interval = 24 * 60 * 60; |
180 | module_param(check_interval, int, S_IRUGO|S_IWUSR); | 202 | module_param(check_interval, int, S_IRUGO|S_IWUSR); |
181 | MODULE_PARM_DESC(check_interval, "Interval in seconds between adapter health checks."); | 203 | MODULE_PARM_DESC(check_interval, "Interval in seconds between adapter health" |
204 | " checks."); | ||
182 | 205 | ||
183 | int aac_check_reset = 1; | 206 | int aac_check_reset = 1; |
184 | module_param_named(check_reset, aac_check_reset, int, S_IRUGO|S_IWUSR); | 207 | module_param_named(check_reset, aac_check_reset, int, S_IRUGO|S_IWUSR); |
185 | MODULE_PARM_DESC(aac_check_reset, "If adapter fails health check, reset the adapter. a value of -1 forces the reset to adapters programmed to ignore it."); | 208 | MODULE_PARM_DESC(aac_check_reset, "If adapter fails health check, reset the" |
209 | " adapter. a value of -1 forces the reset to adapters programmed to" | ||
210 | " ignore it."); | ||
186 | 211 | ||
187 | int expose_physicals = -1; | 212 | int expose_physicals = -1; |
188 | module_param(expose_physicals, int, S_IRUGO|S_IWUSR); | 213 | module_param(expose_physicals, int, S_IRUGO|S_IWUSR); |
189 | MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on"); | 214 | MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays." |
215 | " -1=protect 0=off, 1=on"); | ||
190 | 216 | ||
191 | int aac_reset_devices = 0; | 217 | int aac_reset_devices; |
192 | module_param_named(reset_devices, aac_reset_devices, int, S_IRUGO|S_IWUSR); | 218 | module_param_named(reset_devices, aac_reset_devices, int, S_IRUGO|S_IWUSR); |
193 | MODULE_PARM_DESC(reset_devices, "Force an adapter reset at initialization."); | 219 | MODULE_PARM_DESC(reset_devices, "Force an adapter reset at initialization."); |
194 | 220 | ||
@@ -1315,7 +1341,7 @@ int aac_get_adapter_info(struct aac_dev* dev) | |||
1315 | (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid), | 1341 | (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid), |
1316 | dev->supplement_adapter_info.VpdInfo.Tsid); | 1342 | dev->supplement_adapter_info.VpdInfo.Tsid); |
1317 | } | 1343 | } |
1318 | if (!aac_check_reset || ((aac_check_reset != 1) && | 1344 | if (!aac_check_reset || ((aac_check_reset == 1) && |
1319 | (dev->supplement_adapter_info.SupportedOptions2 & | 1345 | (dev->supplement_adapter_info.SupportedOptions2 & |
1320 | AAC_OPTION_IGNORE_RESET))) { | 1346 | AAC_OPTION_IGNORE_RESET))) { |
1321 | printk(KERN_INFO "%s%d: Reset Adapter Ignored\n", | 1347 | printk(KERN_INFO "%s%d: Reset Adapter Ignored\n", |
@@ -1353,13 +1379,14 @@ int aac_get_adapter_info(struct aac_dev* dev) | |||
1353 | 1379 | ||
1354 | if (nondasd != -1) | 1380 | if (nondasd != -1) |
1355 | dev->nondasd_support = (nondasd!=0); | 1381 | dev->nondasd_support = (nondasd!=0); |
1356 | if(dev->nondasd_support != 0) { | 1382 | if (dev->nondasd_support && !dev->in_reset) |
1357 | printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id); | 1383 | printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id); |
1358 | } | ||
1359 | 1384 | ||
1360 | dev->dac_support = 0; | 1385 | dev->dac_support = 0; |
1361 | if( (sizeof(dma_addr_t) > 4) && (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)){ | 1386 | if( (sizeof(dma_addr_t) > 4) && (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)){ |
1362 | printk(KERN_INFO "%s%d: 64bit support enabled.\n", dev->name, dev->id); | 1387 | if (!dev->in_reset) |
1388 | printk(KERN_INFO "%s%d: 64bit support enabled.\n", | ||
1389 | dev->name, dev->id); | ||
1363 | dev->dac_support = 1; | 1390 | dev->dac_support = 1; |
1364 | } | 1391 | } |
1365 | 1392 | ||
@@ -1369,8 +1396,9 @@ int aac_get_adapter_info(struct aac_dev* dev) | |||
1369 | if(dev->dac_support != 0) { | 1396 | if(dev->dac_support != 0) { |
1370 | if (!pci_set_dma_mask(dev->pdev, DMA_64BIT_MASK) && | 1397 | if (!pci_set_dma_mask(dev->pdev, DMA_64BIT_MASK) && |
1371 | !pci_set_consistent_dma_mask(dev->pdev, DMA_64BIT_MASK)) { | 1398 | !pci_set_consistent_dma_mask(dev->pdev, DMA_64BIT_MASK)) { |
1372 | printk(KERN_INFO"%s%d: 64 Bit DAC enabled\n", | 1399 | if (!dev->in_reset) |
1373 | dev->name, dev->id); | 1400 | printk(KERN_INFO"%s%d: 64 Bit DAC enabled\n", |
1401 | dev->name, dev->id); | ||
1374 | } else if (!pci_set_dma_mask(dev->pdev, DMA_32BIT_MASK) && | 1402 | } else if (!pci_set_dma_mask(dev->pdev, DMA_32BIT_MASK) && |
1375 | !pci_set_consistent_dma_mask(dev->pdev, DMA_32BIT_MASK)) { | 1403 | !pci_set_consistent_dma_mask(dev->pdev, DMA_32BIT_MASK)) { |
1376 | printk(KERN_INFO"%s%d: DMA mask set failed, 64 Bit DAC disabled\n", | 1404 | printk(KERN_INFO"%s%d: DMA mask set failed, 64 Bit DAC disabled\n", |
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 3195d29f2177..ace0b751c131 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h | |||
@@ -1026,6 +1026,7 @@ struct aac_dev | |||
1026 | u8 raw_io_64; | 1026 | u8 raw_io_64; |
1027 | u8 printf_enabled; | 1027 | u8 printf_enabled; |
1028 | u8 in_reset; | 1028 | u8 in_reset; |
1029 | u8 msi; | ||
1029 | }; | 1030 | }; |
1030 | 1031 | ||
1031 | #define aac_adapter_interrupt(dev) \ | 1032 | #define aac_adapter_interrupt(dev) \ |
@@ -1881,6 +1882,7 @@ extern int startup_timeout; | |||
1881 | extern int aif_timeout; | 1882 | extern int aif_timeout; |
1882 | extern int expose_physicals; | 1883 | extern int expose_physicals; |
1883 | extern int aac_reset_devices; | 1884 | extern int aac_reset_devices; |
1885 | extern int aac_msi; | ||
1884 | extern int aac_commit; | 1886 | extern int aac_commit; |
1885 | extern int update_interval; | 1887 | extern int update_interval; |
1886 | extern int check_interval; | 1888 | extern int check_interval; |
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 81b36923e0ef..47434499e82b 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c | |||
@@ -1458,7 +1458,7 @@ int aac_check_health(struct aac_dev * aac) | |||
1458 | 1458 | ||
1459 | printk(KERN_ERR "%s: Host adapter BLINK LED 0x%x\n", aac->name, BlinkLED); | 1459 | printk(KERN_ERR "%s: Host adapter BLINK LED 0x%x\n", aac->name, BlinkLED); |
1460 | 1460 | ||
1461 | if (!aac_check_reset || ((aac_check_reset != 1) && | 1461 | if (!aac_check_reset || ((aac_check_reset == 1) && |
1462 | (aac->supplement_adapter_info.SupportedOptions2 & | 1462 | (aac->supplement_adapter_info.SupportedOptions2 & |
1463 | AAC_OPTION_IGNORE_RESET))) | 1463 | AAC_OPTION_IGNORE_RESET))) |
1464 | goto out; | 1464 | goto out; |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index e80d2a0c46af..ae5f74fb62d5 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -275,9 +275,9 @@ static const char *aac_info(struct Scsi_Host *shost) | |||
275 | 275 | ||
276 | /** | 276 | /** |
277 | * aac_get_driver_ident | 277 | * aac_get_driver_ident |
278 | * @devtype: index into lookup table | 278 | * @devtype: index into lookup table |
279 | * | 279 | * |
280 | * Returns a pointer to the entry in the driver lookup table. | 280 | * Returns a pointer to the entry in the driver lookup table. |
281 | */ | 281 | */ |
282 | 282 | ||
283 | struct aac_driver_ident* aac_get_driver_ident(int devtype) | 283 | struct aac_driver_ident* aac_get_driver_ident(int devtype) |
@@ -494,13 +494,14 @@ static int aac_change_queue_depth(struct scsi_device *sdev, int depth) | |||
494 | 494 | ||
495 | static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute *attr, char *buf) | 495 | static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute *attr, char *buf) |
496 | { | 496 | { |
497 | struct scsi_device * sdev = to_scsi_device(dev); | 497 | struct scsi_device *sdev = to_scsi_device(dev); |
498 | struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata); | ||
498 | if (sdev_channel(sdev) != CONTAINER_CHANNEL) | 499 | if (sdev_channel(sdev) != CONTAINER_CHANNEL) |
499 | return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach | 500 | return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach |
500 | ? "Hidden\n" : "JBOD"); | 501 | ? "Hidden\n" : |
502 | ((aac->jbod && (sdev->type == TYPE_DISK)) ? "JBOD\n" : "")); | ||
501 | return snprintf(buf, PAGE_SIZE, "%s\n", | 503 | return snprintf(buf, PAGE_SIZE, "%s\n", |
502 | get_container_type(((struct aac_dev *)(sdev->host->hostdata)) | 504 | get_container_type(aac->fsa_dev[sdev_id(sdev)].type)); |
503 | ->fsa_dev[sdev_id(sdev)].type)); | ||
504 | } | 505 | } |
505 | 506 | ||
506 | static struct device_attribute aac_raid_level_attr = { | 507 | static struct device_attribute aac_raid_level_attr = { |
@@ -641,7 +642,7 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) | |||
641 | AAC_OPTION_MU_RESET) && | 642 | AAC_OPTION_MU_RESET) && |
642 | aac_check_reset && | 643 | aac_check_reset && |
643 | ((aac_check_reset != 1) || | 644 | ((aac_check_reset != 1) || |
644 | (aac->supplement_adapter_info.SupportedOptions2 & | 645 | !(aac->supplement_adapter_info.SupportedOptions2 & |
645 | AAC_OPTION_IGNORE_RESET))) | 646 | AAC_OPTION_IGNORE_RESET))) |
646 | aac_reset_adapter(aac, 2); /* Bypass wait for command quiesce */ | 647 | aac_reset_adapter(aac, 2); /* Bypass wait for command quiesce */ |
647 | return SUCCESS; /* Cause an immediate retry of the command with a ten second delay after successful tur */ | 648 | return SUCCESS; /* Cause an immediate retry of the command with a ten second delay after successful tur */ |
@@ -860,8 +861,8 @@ ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf) | |||
860 | le32_to_cpu(dev->adapter_info.serial[0])); | 861 | le32_to_cpu(dev->adapter_info.serial[0])); |
861 | if (len && | 862 | if (len && |
862 | !memcmp(&dev->supplement_adapter_info.MfgPcbaSerialNo[ | 863 | !memcmp(&dev->supplement_adapter_info.MfgPcbaSerialNo[ |
863 | sizeof(dev->supplement_adapter_info.MfgPcbaSerialNo)+2-len], | 864 | sizeof(dev->supplement_adapter_info.MfgPcbaSerialNo)-len], |
864 | buf, len)) | 865 | buf, len-1)) |
865 | len = snprintf(buf, PAGE_SIZE, "%.*s\n", | 866 | len = snprintf(buf, PAGE_SIZE, "%.*s\n", |
866 | (int)sizeof(dev->supplement_adapter_info.MfgPcbaSerialNo), | 867 | (int)sizeof(dev->supplement_adapter_info.MfgPcbaSerialNo), |
867 | dev->supplement_adapter_info.MfgPcbaSerialNo); | 868 | dev->supplement_adapter_info.MfgPcbaSerialNo); |
@@ -1004,32 +1005,32 @@ static const struct file_operations aac_cfg_fops = { | |||
1004 | 1005 | ||
1005 | static struct scsi_host_template aac_driver_template = { | 1006 | static struct scsi_host_template aac_driver_template = { |
1006 | .module = THIS_MODULE, | 1007 | .module = THIS_MODULE, |
1007 | .name = "AAC", | 1008 | .name = "AAC", |
1008 | .proc_name = AAC_DRIVERNAME, | 1009 | .proc_name = AAC_DRIVERNAME, |
1009 | .info = aac_info, | 1010 | .info = aac_info, |
1010 | .ioctl = aac_ioctl, | 1011 | .ioctl = aac_ioctl, |
1011 | #ifdef CONFIG_COMPAT | 1012 | #ifdef CONFIG_COMPAT |
1012 | .compat_ioctl = aac_compat_ioctl, | 1013 | .compat_ioctl = aac_compat_ioctl, |
1013 | #endif | 1014 | #endif |
1014 | .queuecommand = aac_queuecommand, | 1015 | .queuecommand = aac_queuecommand, |
1015 | .bios_param = aac_biosparm, | 1016 | .bios_param = aac_biosparm, |
1016 | .shost_attrs = aac_attrs, | 1017 | .shost_attrs = aac_attrs, |
1017 | .slave_configure = aac_slave_configure, | 1018 | .slave_configure = aac_slave_configure, |
1018 | .change_queue_depth = aac_change_queue_depth, | 1019 | .change_queue_depth = aac_change_queue_depth, |
1019 | .sdev_attrs = aac_dev_attrs, | 1020 | .sdev_attrs = aac_dev_attrs, |
1020 | .eh_abort_handler = aac_eh_abort, | 1021 | .eh_abort_handler = aac_eh_abort, |
1021 | .eh_host_reset_handler = aac_eh_reset, | 1022 | .eh_host_reset_handler = aac_eh_reset, |
1022 | .can_queue = AAC_NUM_IO_FIB, | 1023 | .can_queue = AAC_NUM_IO_FIB, |
1023 | .this_id = MAXIMUM_NUM_CONTAINERS, | 1024 | .this_id = MAXIMUM_NUM_CONTAINERS, |
1024 | .sg_tablesize = 16, | 1025 | .sg_tablesize = 16, |
1025 | .max_sectors = 128, | 1026 | .max_sectors = 128, |
1026 | #if (AAC_NUM_IO_FIB > 256) | 1027 | #if (AAC_NUM_IO_FIB > 256) |
1027 | .cmd_per_lun = 256, | 1028 | .cmd_per_lun = 256, |
1028 | #else | 1029 | #else |
1029 | .cmd_per_lun = AAC_NUM_IO_FIB, | 1030 | .cmd_per_lun = AAC_NUM_IO_FIB, |
1030 | #endif | 1031 | #endif |
1031 | .use_clustering = ENABLE_CLUSTERING, | 1032 | .use_clustering = ENABLE_CLUSTERING, |
1032 | .emulated = 1, | 1033 | .emulated = 1, |
1033 | }; | 1034 | }; |
1034 | 1035 | ||
1035 | static void __aac_shutdown(struct aac_dev * aac) | 1036 | static void __aac_shutdown(struct aac_dev * aac) |
@@ -1039,6 +1040,8 @@ static void __aac_shutdown(struct aac_dev * aac) | |||
1039 | aac_send_shutdown(aac); | 1040 | aac_send_shutdown(aac); |
1040 | aac_adapter_disable_int(aac); | 1041 | aac_adapter_disable_int(aac); |
1041 | free_irq(aac->pdev->irq, aac); | 1042 | free_irq(aac->pdev->irq, aac); |
1043 | if (aac->msi) | ||
1044 | pci_disable_msi(aac->pdev); | ||
1042 | } | 1045 | } |
1043 | 1046 | ||
1044 | static int __devinit aac_probe_one(struct pci_dev *pdev, | 1047 | static int __devinit aac_probe_one(struct pci_dev *pdev, |
@@ -1254,7 +1257,7 @@ static struct pci_driver aac_pci_driver = { | |||
1254 | .id_table = aac_pci_tbl, | 1257 | .id_table = aac_pci_tbl, |
1255 | .probe = aac_probe_one, | 1258 | .probe = aac_probe_one, |
1256 | .remove = __devexit_p(aac_remove_one), | 1259 | .remove = __devexit_p(aac_remove_one), |
1257 | .shutdown = aac_shutdown, | 1260 | .shutdown = aac_shutdown, |
1258 | }; | 1261 | }; |
1259 | 1262 | ||
1260 | static int __init aac_init(void) | 1263 | static int __init aac_init(void) |
@@ -1271,7 +1274,7 @@ static int __init aac_init(void) | |||
1271 | aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops); | 1274 | aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops); |
1272 | if (aac_cfg_major < 0) { | 1275 | if (aac_cfg_major < 0) { |
1273 | printk(KERN_WARNING | 1276 | printk(KERN_WARNING |
1274 | "aacraid: unable to register \"aac\" device.\n"); | 1277 | "aacraid: unable to register \"aac\" device.\n"); |
1275 | } | 1278 | } |
1276 | 1279 | ||
1277 | return 0; | 1280 | return 0; |
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c index a08bbf1fd76c..1f18b83e1e02 100644 --- a/drivers/scsi/aacraid/rx.c +++ b/drivers/scsi/aacraid/rx.c | |||
@@ -625,8 +625,11 @@ int _aac_rx_init(struct aac_dev *dev) | |||
625 | if (aac_init_adapter(dev) == NULL) | 625 | if (aac_init_adapter(dev) == NULL) |
626 | goto error_iounmap; | 626 | goto error_iounmap; |
627 | aac_adapter_comm(dev, dev->comm_interface); | 627 | aac_adapter_comm(dev, dev->comm_interface); |
628 | if (request_irq(dev->scsi_host_ptr->irq, dev->a_ops.adapter_intr, | 628 | dev->msi = aac_msi && !pci_enable_msi(dev->pdev); |
629 | if (request_irq(dev->pdev->irq, dev->a_ops.adapter_intr, | ||
629 | IRQF_SHARED|IRQF_DISABLED, "aacraid", dev) < 0) { | 630 | IRQF_SHARED|IRQF_DISABLED, "aacraid", dev) < 0) { |
631 | if (dev->msi) | ||
632 | pci_disable_msi(dev->pdev); | ||
630 | printk(KERN_ERR "%s%d: Interrupt unavailable.\n", | 633 | printk(KERN_ERR "%s%d: Interrupt unavailable.\n", |
631 | name, instance); | 634 | name, instance); |
632 | goto error_iounmap; | 635 | goto error_iounmap; |
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c index 85b91bc578c9..cfc3410ec073 100644 --- a/drivers/scsi/aacraid/sa.c +++ b/drivers/scsi/aacraid/sa.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/types.h> | 33 | #include <linux/types.h> |
34 | #include <linux/pci.h> | ||
34 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
35 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
36 | #include <linux/blkdev.h> | 37 | #include <linux/blkdev.h> |
@@ -385,7 +386,7 @@ int aac_sa_init(struct aac_dev *dev) | |||
385 | 386 | ||
386 | if(aac_init_adapter(dev) == NULL) | 387 | if(aac_init_adapter(dev) == NULL) |
387 | goto error_irq; | 388 | goto error_irq; |
388 | if (request_irq(dev->scsi_host_ptr->irq, dev->a_ops.adapter_intr, | 389 | if (request_irq(dev->pdev->irq, dev->a_ops.adapter_intr, |
389 | IRQF_SHARED|IRQF_DISABLED, | 390 | IRQF_SHARED|IRQF_DISABLED, |
390 | "aacraid", (void *)dev ) < 0) { | 391 | "aacraid", (void *)dev ) < 0) { |
391 | printk(KERN_WARNING "%s%d: Interrupt unavailable.\n", | 392 | printk(KERN_WARNING "%s%d: Interrupt unavailable.\n", |
@@ -403,7 +404,7 @@ int aac_sa_init(struct aac_dev *dev) | |||
403 | 404 | ||
404 | error_irq: | 405 | error_irq: |
405 | aac_sa_disable_interrupt(dev); | 406 | aac_sa_disable_interrupt(dev); |
406 | free_irq(dev->scsi_host_ptr->irq, (void *)dev); | 407 | free_irq(dev->pdev->irq, (void *)dev); |
407 | 408 | ||
408 | error_iounmap: | 409 | error_iounmap: |
409 | 410 | ||
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index ccef891d642f..3c2d6888bb8c 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c | |||
@@ -566,7 +566,7 @@ typedef struct asc_dvc_var { | |||
566 | ASC_SCSI_BIT_ID_TYPE unit_not_ready; | 566 | ASC_SCSI_BIT_ID_TYPE unit_not_ready; |
567 | ASC_SCSI_BIT_ID_TYPE queue_full_or_busy; | 567 | ASC_SCSI_BIT_ID_TYPE queue_full_or_busy; |
568 | ASC_SCSI_BIT_ID_TYPE start_motor; | 568 | ASC_SCSI_BIT_ID_TYPE start_motor; |
569 | uchar overrun_buf[ASC_OVERRUN_BSIZE] __aligned(8); | 569 | uchar *overrun_buf; |
570 | dma_addr_t overrun_dma; | 570 | dma_addr_t overrun_dma; |
571 | uchar scsi_reset_wait; | 571 | uchar scsi_reset_wait; |
572 | uchar chip_no; | 572 | uchar chip_no; |
@@ -13833,6 +13833,12 @@ static int __devinit advansys_board_found(struct Scsi_Host *shost, | |||
13833 | */ | 13833 | */ |
13834 | if (ASC_NARROW_BOARD(boardp)) { | 13834 | if (ASC_NARROW_BOARD(boardp)) { |
13835 | ASC_DBG(2, "AscInitAsc1000Driver()\n"); | 13835 | ASC_DBG(2, "AscInitAsc1000Driver()\n"); |
13836 | |||
13837 | asc_dvc_varp->overrun_buf = kzalloc(ASC_OVERRUN_BSIZE, GFP_KERNEL); | ||
13838 | if (!asc_dvc_varp->overrun_buf) { | ||
13839 | ret = -ENOMEM; | ||
13840 | goto err_free_wide_mem; | ||
13841 | } | ||
13836 | warn_code = AscInitAsc1000Driver(asc_dvc_varp); | 13842 | warn_code = AscInitAsc1000Driver(asc_dvc_varp); |
13837 | 13843 | ||
13838 | if (warn_code || asc_dvc_varp->err_code) { | 13844 | if (warn_code || asc_dvc_varp->err_code) { |
@@ -13840,8 +13846,10 @@ static int __devinit advansys_board_found(struct Scsi_Host *shost, | |||
13840 | "warn 0x%x, error 0x%x\n", | 13846 | "warn 0x%x, error 0x%x\n", |
13841 | asc_dvc_varp->init_state, warn_code, | 13847 | asc_dvc_varp->init_state, warn_code, |
13842 | asc_dvc_varp->err_code); | 13848 | asc_dvc_varp->err_code); |
13843 | if (asc_dvc_varp->err_code) | 13849 | if (asc_dvc_varp->err_code) { |
13844 | ret = -ENODEV; | 13850 | ret = -ENODEV; |
13851 | kfree(asc_dvc_varp->overrun_buf); | ||
13852 | } | ||
13845 | } | 13853 | } |
13846 | } else { | 13854 | } else { |
13847 | if (advansys_wide_init_chip(shost)) | 13855 | if (advansys_wide_init_chip(shost)) |
@@ -13894,6 +13902,7 @@ static int advansys_release(struct Scsi_Host *shost) | |||
13894 | dma_unmap_single(board->dev, | 13902 | dma_unmap_single(board->dev, |
13895 | board->dvc_var.asc_dvc_var.overrun_dma, | 13903 | board->dvc_var.asc_dvc_var.overrun_dma, |
13896 | ASC_OVERRUN_BSIZE, DMA_FROM_DEVICE); | 13904 | ASC_OVERRUN_BSIZE, DMA_FROM_DEVICE); |
13905 | kfree(board->dvc_var.asc_dvc_var.overrun_buf); | ||
13897 | } else { | 13906 | } else { |
13898 | iounmap(board->ioremap_addr); | 13907 | iounmap(board->ioremap_addr); |
13899 | advansys_wide_free_mem(board); | 13908 | advansys_wide_free_mem(board); |
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c index 4150c8a8fdc2..dfaaae5e73ae 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c | |||
@@ -89,7 +89,7 @@ ahd_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
89 | pci_save_state(pdev); | 89 | pci_save_state(pdev); |
90 | pci_disable_device(pdev); | 90 | pci_disable_device(pdev); |
91 | 91 | ||
92 | if (mesg.event == PM_EVENT_SUSPEND) | 92 | if (mesg.event & PM_EVENT_SLEEP) |
93 | pci_set_power_state(pdev, PCI_D3hot); | 93 | pci_set_power_state(pdev, PCI_D3hot); |
94 | 94 | ||
95 | return rc; | 95 | return rc; |
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c index 6d2ae641273c..64e62ce59c15 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c | |||
@@ -695,15 +695,16 @@ ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat) | |||
695 | scb_index = ahc_inb(ahc, SCB_TAG); | 695 | scb_index = ahc_inb(ahc, SCB_TAG); |
696 | scb = ahc_lookup_scb(ahc, scb_index); | 696 | scb = ahc_lookup_scb(ahc, scb_index); |
697 | if (devinfo.role == ROLE_INITIATOR) { | 697 | if (devinfo.role == ROLE_INITIATOR) { |
698 | if (scb == NULL) | 698 | if (bus_phase == P_MESGOUT) { |
699 | panic("HOST_MSG_LOOP with " | 699 | if (scb == NULL) |
700 | "invalid SCB %x\n", scb_index); | 700 | panic("HOST_MSG_LOOP with " |
701 | "invalid SCB %x\n", | ||
702 | scb_index); | ||
701 | 703 | ||
702 | if (bus_phase == P_MESGOUT) | ||
703 | ahc_setup_initiator_msgout(ahc, | 704 | ahc_setup_initiator_msgout(ahc, |
704 | &devinfo, | 705 | &devinfo, |
705 | scb); | 706 | scb); |
706 | else { | 707 | } else { |
707 | ahc->msg_type = | 708 | ahc->msg_type = |
708 | MSG_TYPE_INITIATOR_MSGIN; | 709 | MSG_TYPE_INITIATOR_MSGIN; |
709 | ahc->msgin_index = 0; | 710 | ahc->msgin_index = 0; |
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index dd6e21d6f1dd..3d3eaef65fb3 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | |||
@@ -134,7 +134,7 @@ ahc_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
134 | pci_save_state(pdev); | 134 | pci_save_state(pdev); |
135 | pci_disable_device(pdev); | 135 | pci_disable_device(pdev); |
136 | 136 | ||
137 | if (mesg.event == PM_EVENT_SUSPEND) | 137 | if (mesg.event & PM_EVENT_SLEEP) |
138 | pci_set_power_state(pdev, PCI_D3hot); | 138 | pci_set_power_state(pdev, PCI_D3hot); |
139 | 139 | ||
140 | return rc; | 140 | return rc; |
diff --git a/drivers/scsi/aic94xx/aic94xx_sas.h b/drivers/scsi/aic94xx/aic94xx_sas.h index fa7c5290257d..912e6b755f74 100644 --- a/drivers/scsi/aic94xx/aic94xx_sas.h +++ b/drivers/scsi/aic94xx/aic94xx_sas.h | |||
@@ -292,7 +292,7 @@ struct scb_header { | |||
292 | #define INITIATE_SSP_TASK 0x00 | 292 | #define INITIATE_SSP_TASK 0x00 |
293 | #define INITIATE_LONG_SSP_TASK 0x01 | 293 | #define INITIATE_LONG_SSP_TASK 0x01 |
294 | #define INITIATE_BIDIR_SSP_TASK 0x02 | 294 | #define INITIATE_BIDIR_SSP_TASK 0x02 |
295 | #define ABORT_TASK 0x03 | 295 | #define SCB_ABORT_TASK 0x03 |
296 | #define INITIATE_SSP_TMF 0x04 | 296 | #define INITIATE_SSP_TMF 0x04 |
297 | #define SSP_TARG_GET_DATA 0x05 | 297 | #define SSP_TARG_GET_DATA 0x05 |
298 | #define SSP_TARG_GET_DATA_GOOD 0x06 | 298 | #define SSP_TARG_GET_DATA_GOOD 0x06 |
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c index 0febad4dd75f..ab350504ca5a 100644 --- a/drivers/scsi/aic94xx/aic94xx_scb.c +++ b/drivers/scsi/aic94xx/aic94xx_scb.c | |||
@@ -458,13 +458,19 @@ static void escb_tasklet_complete(struct asd_ascb *ascb, | |||
458 | tc_abort = le16_to_cpu(tc_abort); | 458 | tc_abort = le16_to_cpu(tc_abort); |
459 | 459 | ||
460 | list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) { | 460 | list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) { |
461 | struct sas_task *task = ascb->uldd_task; | 461 | struct sas_task *task = a->uldd_task; |
462 | |||
463 | if (a->tc_index != tc_abort) | ||
464 | continue; | ||
462 | 465 | ||
463 | if (task && a->tc_index == tc_abort) { | 466 | if (task) { |
464 | failed_dev = task->dev; | 467 | failed_dev = task->dev; |
465 | sas_task_abort(task); | 468 | sas_task_abort(task); |
466 | break; | 469 | } else { |
470 | ASD_DPRINTK("R_T_A for non TASK scb 0x%x\n", | ||
471 | a->scb->header.opcode); | ||
467 | } | 472 | } |
473 | break; | ||
468 | } | 474 | } |
469 | 475 | ||
470 | if (!failed_dev) { | 476 | if (!failed_dev) { |
@@ -478,7 +484,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb, | |||
478 | * that the EH will wake up and do something. | 484 | * that the EH will wake up and do something. |
479 | */ | 485 | */ |
480 | list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) { | 486 | list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) { |
481 | struct sas_task *task = ascb->uldd_task; | 487 | struct sas_task *task = a->uldd_task; |
482 | 488 | ||
483 | if (task && | 489 | if (task && |
484 | task->dev == failed_dev && | 490 | task->dev == failed_dev && |
diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c index 87b2f6e6adfe..144f5ad20453 100644 --- a/drivers/scsi/aic94xx/aic94xx_tmf.c +++ b/drivers/scsi/aic94xx/aic94xx_tmf.c | |||
@@ -151,8 +151,6 @@ static int asd_clear_nexus_I_T(struct domain_device *dev) | |||
151 | CLEAR_NEXUS_PRE; | 151 | CLEAR_NEXUS_PRE; |
152 | scb->clear_nexus.nexus = NEXUS_I_T; | 152 | scb->clear_nexus.nexus = NEXUS_I_T; |
153 | scb->clear_nexus.flags = SEND_Q | EXEC_Q | NOTINQ; | 153 | scb->clear_nexus.flags = SEND_Q | EXEC_Q | NOTINQ; |
154 | if (dev->tproto) | ||
155 | scb->clear_nexus.flags |= SUSPEND_TX; | ||
156 | scb->clear_nexus.conn_handle = cpu_to_le16((u16)(unsigned long) | 154 | scb->clear_nexus.conn_handle = cpu_to_le16((u16)(unsigned long) |
157 | dev->lldd_dev); | 155 | dev->lldd_dev); |
158 | CLEAR_NEXUS_POST; | 156 | CLEAR_NEXUS_POST; |
@@ -169,8 +167,6 @@ static int asd_clear_nexus_I_T_L(struct domain_device *dev, u8 *lun) | |||
169 | CLEAR_NEXUS_PRE; | 167 | CLEAR_NEXUS_PRE; |
170 | scb->clear_nexus.nexus = NEXUS_I_T_L; | 168 | scb->clear_nexus.nexus = NEXUS_I_T_L; |
171 | scb->clear_nexus.flags = SEND_Q | EXEC_Q | NOTINQ; | 169 | scb->clear_nexus.flags = SEND_Q | EXEC_Q | NOTINQ; |
172 | if (dev->tproto) | ||
173 | scb->clear_nexus.flags |= SUSPEND_TX; | ||
174 | memcpy(scb->clear_nexus.ssp_task.lun, lun, 8); | 170 | memcpy(scb->clear_nexus.ssp_task.lun, lun, 8); |
175 | scb->clear_nexus.conn_handle = cpu_to_le16((u16)(unsigned long) | 171 | scb->clear_nexus.conn_handle = cpu_to_le16((u16)(unsigned long) |
176 | dev->lldd_dev); | 172 | dev->lldd_dev); |
@@ -369,7 +365,7 @@ int asd_abort_task(struct sas_task *task) | |||
369 | return -ENOMEM; | 365 | return -ENOMEM; |
370 | scb = ascb->scb; | 366 | scb = ascb->scb; |
371 | 367 | ||
372 | scb->header.opcode = ABORT_TASK; | 368 | scb->header.opcode = SCB_ABORT_TASK; |
373 | 369 | ||
374 | switch (task->task_proto) { | 370 | switch (task->task_proto) { |
375 | case SAS_PROTOCOL_SATA: | 371 | case SAS_PROTOCOL_SATA: |
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 4f9ff32cfed0..f91f79c8007d 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c | |||
@@ -1387,18 +1387,16 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \ | |||
1387 | switch(controlcode) { | 1387 | switch(controlcode) { |
1388 | 1388 | ||
1389 | case ARCMSR_MESSAGE_READ_RQBUFFER: { | 1389 | case ARCMSR_MESSAGE_READ_RQBUFFER: { |
1390 | unsigned long *ver_addr; | 1390 | unsigned char *ver_addr; |
1391 | uint8_t *pQbuffer, *ptmpQbuffer; | 1391 | uint8_t *pQbuffer, *ptmpQbuffer; |
1392 | int32_t allxfer_len = 0; | 1392 | int32_t allxfer_len = 0; |
1393 | void *tmp; | ||
1394 | 1393 | ||
1395 | tmp = kmalloc(1032, GFP_KERNEL|GFP_DMA); | 1394 | ver_addr = kmalloc(1032, GFP_ATOMIC); |
1396 | ver_addr = (unsigned long *)tmp; | 1395 | if (!ver_addr) { |
1397 | if (!tmp) { | ||
1398 | retvalue = ARCMSR_MESSAGE_FAIL; | 1396 | retvalue = ARCMSR_MESSAGE_FAIL; |
1399 | goto message_out; | 1397 | goto message_out; |
1400 | } | 1398 | } |
1401 | ptmpQbuffer = (uint8_t *) ver_addr; | 1399 | ptmpQbuffer = ver_addr; |
1402 | while ((acb->rqbuf_firstindex != acb->rqbuf_lastindex) | 1400 | while ((acb->rqbuf_firstindex != acb->rqbuf_lastindex) |
1403 | && (allxfer_len < 1031)) { | 1401 | && (allxfer_len < 1031)) { |
1404 | pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex]; | 1402 | pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex]; |
@@ -1427,26 +1425,24 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \ | |||
1427 | } | 1425 | } |
1428 | arcmsr_iop_message_read(acb); | 1426 | arcmsr_iop_message_read(acb); |
1429 | } | 1427 | } |
1430 | memcpy(pcmdmessagefld->messagedatabuffer, (uint8_t *)ver_addr, allxfer_len); | 1428 | memcpy(pcmdmessagefld->messagedatabuffer, ver_addr, allxfer_len); |
1431 | pcmdmessagefld->cmdmessage.Length = allxfer_len; | 1429 | pcmdmessagefld->cmdmessage.Length = allxfer_len; |
1432 | pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; | 1430 | pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK; |
1433 | kfree(tmp); | 1431 | kfree(ver_addr); |
1434 | } | 1432 | } |
1435 | break; | 1433 | break; |
1436 | 1434 | ||
1437 | case ARCMSR_MESSAGE_WRITE_WQBUFFER: { | 1435 | case ARCMSR_MESSAGE_WRITE_WQBUFFER: { |
1438 | unsigned long *ver_addr; | 1436 | unsigned char *ver_addr; |
1439 | int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex; | 1437 | int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex; |
1440 | uint8_t *pQbuffer, *ptmpuserbuffer; | 1438 | uint8_t *pQbuffer, *ptmpuserbuffer; |
1441 | void *tmp; | ||
1442 | 1439 | ||
1443 | tmp = kmalloc(1032, GFP_KERNEL|GFP_DMA); | 1440 | ver_addr = kmalloc(1032, GFP_ATOMIC); |
1444 | ver_addr = (unsigned long *)tmp; | 1441 | if (!ver_addr) { |
1445 | if (!tmp) { | ||
1446 | retvalue = ARCMSR_MESSAGE_FAIL; | 1442 | retvalue = ARCMSR_MESSAGE_FAIL; |
1447 | goto message_out; | 1443 | goto message_out; |
1448 | } | 1444 | } |
1449 | ptmpuserbuffer = (uint8_t *)ver_addr; | 1445 | ptmpuserbuffer = ver_addr; |
1450 | user_len = pcmdmessagefld->cmdmessage.Length; | 1446 | user_len = pcmdmessagefld->cmdmessage.Length; |
1451 | memcpy(ptmpuserbuffer, pcmdmessagefld->messagedatabuffer, user_len); | 1447 | memcpy(ptmpuserbuffer, pcmdmessagefld->messagedatabuffer, user_len); |
1452 | wqbuf_lastindex = acb->wqbuf_lastindex; | 1448 | wqbuf_lastindex = acb->wqbuf_lastindex; |
@@ -1492,7 +1488,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \ | |||
1492 | retvalue = ARCMSR_MESSAGE_FAIL; | 1488 | retvalue = ARCMSR_MESSAGE_FAIL; |
1493 | } | 1489 | } |
1494 | } | 1490 | } |
1495 | kfree(tmp); | 1491 | kfree(ver_addr); |
1496 | } | 1492 | } |
1497 | break; | 1493 | break; |
1498 | 1494 | ||
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index fb5f20284389..a715632e19d4 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c | |||
@@ -2018,6 +2018,7 @@ static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, | |||
2018 | * the upper layers to process. This would have been set | 2018 | * the upper layers to process. This would have been set |
2019 | * correctly by fas216_std_done. | 2019 | * correctly by fas216_std_done. |
2020 | */ | 2020 | */ |
2021 | scsi_eh_restore_cmnd(SCpnt, &info->ses); | ||
2021 | SCpnt->scsi_done(SCpnt); | 2022 | SCpnt->scsi_done(SCpnt); |
2022 | } | 2023 | } |
2023 | 2024 | ||
@@ -2103,23 +2104,12 @@ request_sense: | |||
2103 | if (SCpnt->cmnd[0] == REQUEST_SENSE) | 2104 | if (SCpnt->cmnd[0] == REQUEST_SENSE) |
2104 | goto done; | 2105 | goto done; |
2105 | 2106 | ||
2107 | scsi_eh_prep_cmnd(SCpnt, &info->ses, NULL, 0, ~0); | ||
2106 | fas216_log_target(info, LOG_CONNECT, SCpnt->device->id, | 2108 | fas216_log_target(info, LOG_CONNECT, SCpnt->device->id, |
2107 | "requesting sense"); | 2109 | "requesting sense"); |
2108 | memset(SCpnt->cmnd, 0, sizeof (SCpnt->cmnd)); | 2110 | init_SCp(SCpnt); |
2109 | SCpnt->cmnd[0] = REQUEST_SENSE; | ||
2110 | SCpnt->cmnd[1] = SCpnt->device->lun << 5; | ||
2111 | SCpnt->cmnd[4] = sizeof(SCpnt->sense_buffer); | ||
2112 | SCpnt->cmd_len = COMMAND_SIZE(SCpnt->cmnd[0]); | ||
2113 | SCpnt->SCp.buffer = NULL; | ||
2114 | SCpnt->SCp.buffers_residual = 0; | ||
2115 | SCpnt->SCp.ptr = (char *)SCpnt->sense_buffer; | ||
2116 | SCpnt->SCp.this_residual = sizeof(SCpnt->sense_buffer); | ||
2117 | SCpnt->SCp.phase = sizeof(SCpnt->sense_buffer); | ||
2118 | SCpnt->SCp.Message = 0; | 2111 | SCpnt->SCp.Message = 0; |
2119 | SCpnt->SCp.Status = 0; | 2112 | SCpnt->SCp.Status = 0; |
2120 | SCpnt->request_bufflen = sizeof(SCpnt->sense_buffer); | ||
2121 | SCpnt->sc_data_direction = DMA_FROM_DEVICE; | ||
2122 | SCpnt->use_sg = 0; | ||
2123 | SCpnt->tag = 0; | 2113 | SCpnt->tag = 0; |
2124 | SCpnt->host_scribble = (void *)fas216_rq_sns_done; | 2114 | SCpnt->host_scribble = (void *)fas216_rq_sns_done; |
2125 | 2115 | ||
diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h index 00e5f055afdc..b65f4cf0eec9 100644 --- a/drivers/scsi/arm/fas216.h +++ b/drivers/scsi/arm/fas216.h | |||
@@ -16,6 +16,8 @@ | |||
16 | #define NO_IRQ 255 | 16 | #define NO_IRQ 255 |
17 | #endif | 17 | #endif |
18 | 18 | ||
19 | #include <scsi/scsi_eh.h> | ||
20 | |||
19 | #include "queue.h" | 21 | #include "queue.h" |
20 | #include "msgqueue.h" | 22 | #include "msgqueue.h" |
21 | 23 | ||
@@ -311,6 +313,7 @@ typedef struct { | |||
311 | 313 | ||
312 | /* miscellaneous */ | 314 | /* miscellaneous */ |
313 | int internal_done; /* flag to indicate request done */ | 315 | int internal_done; /* flag to indicate request done */ |
316 | struct scsi_eh_save ses; /* holds request sense restore info */ | ||
314 | unsigned long magic_end; | 317 | unsigned long magic_end; |
315 | } FAS216_Info; | 318 | } FAS216_Info; |
316 | 319 | ||
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index c82523908c2e..6d67f5c0eb8e 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -642,12 +642,15 @@ static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt, | |||
642 | *cnt, vendor, device)); | 642 | *cnt, vendor, device)); |
643 | 643 | ||
644 | pdev = NULL; | 644 | pdev = NULL; |
645 | while ((pdev = pci_find_device(vendor, device, pdev)) | 645 | while ((pdev = pci_get_device(vendor, device, pdev)) |
646 | != NULL) { | 646 | != NULL) { |
647 | if (pci_enable_device(pdev)) | 647 | if (pci_enable_device(pdev)) |
648 | continue; | 648 | continue; |
649 | if (*cnt >= MAXHA) | 649 | if (*cnt >= MAXHA) { |
650 | pci_dev_put(pdev); | ||
650 | return; | 651 | return; |
652 | } | ||
653 | |||
651 | /* GDT PCI controller found, resources are already in pdev */ | 654 | /* GDT PCI controller found, resources are already in pdev */ |
652 | pcistr[*cnt].pdev = pdev; | 655 | pcistr[*cnt].pdev = pdev; |
653 | pcistr[*cnt].irq = pdev->irq; | 656 | pcistr[*cnt].irq = pdev->irq; |
@@ -4836,6 +4839,9 @@ static int __init gdth_isa_probe_one(ulong32 isa_bios) | |||
4836 | if (error) | 4839 | if (error) |
4837 | goto out_free_coal_stat; | 4840 | goto out_free_coal_stat; |
4838 | list_add_tail(&ha->list, &gdth_instances); | 4841 | list_add_tail(&ha->list, &gdth_instances); |
4842 | |||
4843 | scsi_scan_host(shp); | ||
4844 | |||
4839 | return 0; | 4845 | return 0; |
4840 | 4846 | ||
4841 | out_free_coal_stat: | 4847 | out_free_coal_stat: |
@@ -4963,6 +4969,9 @@ static int __init gdth_eisa_probe_one(ushort eisa_slot) | |||
4963 | if (error) | 4969 | if (error) |
4964 | goto out_free_coal_stat; | 4970 | goto out_free_coal_stat; |
4965 | list_add_tail(&ha->list, &gdth_instances); | 4971 | list_add_tail(&ha->list, &gdth_instances); |
4972 | |||
4973 | scsi_scan_host(shp); | ||
4974 | |||
4966 | return 0; | 4975 | return 0; |
4967 | 4976 | ||
4968 | out_free_ccb_phys: | 4977 | out_free_ccb_phys: |
@@ -5100,6 +5109,9 @@ static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) | |||
5100 | if (error) | 5109 | if (error) |
5101 | goto out_free_coal_stat; | 5110 | goto out_free_coal_stat; |
5102 | list_add_tail(&ha->list, &gdth_instances); | 5111 | list_add_tail(&ha->list, &gdth_instances); |
5112 | |||
5113 | scsi_scan_host(shp); | ||
5114 | |||
5103 | return 0; | 5115 | return 0; |
5104 | 5116 | ||
5105 | out_free_coal_stat: | 5117 | out_free_coal_stat: |
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c index de5773443c62..ce0228e26aec 100644 --- a/drivers/scsi/gdth_proc.c +++ b/drivers/scsi/gdth_proc.c | |||
@@ -694,15 +694,13 @@ static void gdth_ioctl_free(gdth_ha_str *ha, int size, char *buf, ulong64 paddr) | |||
694 | { | 694 | { |
695 | ulong flags; | 695 | ulong flags; |
696 | 696 | ||
697 | spin_lock_irqsave(&ha->smp_lock, flags); | ||
698 | |||
699 | if (buf == ha->pscratch) { | 697 | if (buf == ha->pscratch) { |
698 | spin_lock_irqsave(&ha->smp_lock, flags); | ||
700 | ha->scratch_busy = FALSE; | 699 | ha->scratch_busy = FALSE; |
700 | spin_unlock_irqrestore(&ha->smp_lock, flags); | ||
701 | } else { | 701 | } else { |
702 | pci_free_consistent(ha->pdev, size, buf, paddr); | 702 | pci_free_consistent(ha->pdev, size, buf, paddr); |
703 | } | 703 | } |
704 | |||
705 | spin_unlock_irqrestore(&ha->smp_lock, flags); | ||
706 | } | 704 | } |
707 | 705 | ||
708 | #ifdef GDTH_IOCTL_PROC | 706 | #ifdef GDTH_IOCTL_PROC |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 2074701f7e76..c72014a3e7d4 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -5140,7 +5140,7 @@ static void ipr_build_ata_ioadl(struct ipr_cmnd *ipr_cmd, | |||
5140 | struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; | 5140 | struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; |
5141 | struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; | 5141 | struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; |
5142 | struct ipr_ioadl_desc *last_ioadl = NULL; | 5142 | struct ipr_ioadl_desc *last_ioadl = NULL; |
5143 | int len = qc->nbytes + qc->pad_len; | 5143 | int len = qc->nbytes; |
5144 | struct scatterlist *sg; | 5144 | struct scatterlist *sg; |
5145 | unsigned int si; | 5145 | unsigned int si; |
5146 | 5146 | ||
@@ -5206,7 +5206,7 @@ static unsigned int ipr_qc_issue(struct ata_queued_cmd *qc) | |||
5206 | ioarcb->cmd_pkt.request_type = IPR_RQTYPE_ATA_PASSTHRU; | 5206 | ioarcb->cmd_pkt.request_type = IPR_RQTYPE_ATA_PASSTHRU; |
5207 | ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_LINK_DESC; | 5207 | ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_LINK_DESC; |
5208 | ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_ULEN_CHK; | 5208 | ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_ULEN_CHK; |
5209 | ipr_cmd->dma_use_sg = qc->pad_len ? qc->n_elem + 1 : qc->n_elem; | 5209 | ipr_cmd->dma_use_sg = qc->n_elem; |
5210 | 5210 | ||
5211 | ipr_build_ata_ioadl(ipr_cmd, qc); | 5211 | ipr_build_ata_ioadl(ipr_cmd, qc); |
5212 | regs->flags |= IPR_ATA_FLAG_STATUS_ON_GOOD_COMPLETION; | 5212 | regs->flags |= IPR_ATA_FLAG_STATUS_ON_GOOD_COMPLETION; |
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index bb152fb9fec7..7ed568f180ae 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c | |||
@@ -1576,7 +1576,7 @@ ips_make_passthru(ips_ha_t *ha, struct scsi_cmnd *SC, ips_scb_t *scb, int intr) | |||
1576 | METHOD_TRACE("ips_make_passthru", 1); | 1576 | METHOD_TRACE("ips_make_passthru", 1); |
1577 | 1577 | ||
1578 | scsi_for_each_sg(SC, sg, scsi_sg_count(SC), i) | 1578 | scsi_for_each_sg(SC, sg, scsi_sg_count(SC), i) |
1579 | length += sg[i].length; | 1579 | length += sg->length; |
1580 | 1580 | ||
1581 | if (length < sizeof (ips_passthru_t)) { | 1581 | if (length < sizeof (ips_passthru_t)) { |
1582 | /* wrong size */ | 1582 | /* wrong size */ |
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 0996f866f14c..7cd05b599a12 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c | |||
@@ -178,8 +178,8 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) | |||
178 | task->uldd_task = qc; | 178 | task->uldd_task = qc; |
179 | if (ata_is_atapi(qc->tf.protocol)) { | 179 | if (ata_is_atapi(qc->tf.protocol)) { |
180 | memcpy(task->ata_task.atapi_packet, qc->cdb, qc->dev->cdb_len); | 180 | memcpy(task->ata_task.atapi_packet, qc->cdb, qc->dev->cdb_len); |
181 | task->total_xfer_len = qc->nbytes + qc->pad_len; | 181 | task->total_xfer_len = qc->nbytes; |
182 | task->num_scatter = qc->pad_len ? qc->n_elem + 1 : qc->n_elem; | 182 | task->num_scatter = qc->n_elem; |
183 | } else { | 183 | } else { |
184 | for_each_sg(qc->sg, sg, qc->n_elem, si) | 184 | for_each_sg(qc->sg, sg, qc->n_elem, si) |
185 | xfer += sg->length; | 185 | xfer += sg->length; |
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index f869fba86807..704ea06a6e50 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c | |||
@@ -51,10 +51,14 @@ static void sas_scsi_task_done(struct sas_task *task) | |||
51 | { | 51 | { |
52 | struct task_status_struct *ts = &task->task_status; | 52 | struct task_status_struct *ts = &task->task_status; |
53 | struct scsi_cmnd *sc = task->uldd_task; | 53 | struct scsi_cmnd *sc = task->uldd_task; |
54 | struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(sc->device->host); | ||
55 | unsigned ts_flags = task->task_state_flags; | ||
56 | int hs = 0, stat = 0; | 54 | int hs = 0, stat = 0; |
57 | 55 | ||
56 | if (unlikely(task->task_state_flags & SAS_TASK_STATE_ABORTED)) { | ||
57 | /* Aborted tasks will be completed by the error handler */ | ||
58 | SAS_DPRINTK("task done but aborted\n"); | ||
59 | return; | ||
60 | } | ||
61 | |||
58 | if (unlikely(!sc)) { | 62 | if (unlikely(!sc)) { |
59 | SAS_DPRINTK("task_done called with non existing SCSI cmnd!\n"); | 63 | SAS_DPRINTK("task_done called with non existing SCSI cmnd!\n"); |
60 | list_del_init(&task->list); | 64 | list_del_init(&task->list); |
@@ -120,11 +124,7 @@ static void sas_scsi_task_done(struct sas_task *task) | |||
120 | sc->result = (hs << 16) | stat; | 124 | sc->result = (hs << 16) | stat; |
121 | list_del_init(&task->list); | 125 | list_del_init(&task->list); |
122 | sas_free_task(task); | 126 | sas_free_task(task); |
123 | /* This is very ugly but this is how SCSI Core works. */ | 127 | sc->scsi_done(sc); |
124 | if (ts_flags & SAS_TASK_STATE_ABORTED) | ||
125 | scsi_eh_finish_cmd(sc, &sas_ha->eh_done_q); | ||
126 | else | ||
127 | sc->scsi_done(sc); | ||
128 | } | 128 | } |
129 | 129 | ||
130 | static enum task_attribute sas_scsi_get_task_attr(struct scsi_cmnd *cmd) | 130 | static enum task_attribute sas_scsi_get_task_attr(struct scsi_cmnd *cmd) |
@@ -255,13 +255,34 @@ out: | |||
255 | return res; | 255 | return res; |
256 | } | 256 | } |
257 | 257 | ||
258 | static void sas_eh_finish_cmd(struct scsi_cmnd *cmd) | ||
259 | { | ||
260 | struct sas_task *task = TO_SAS_TASK(cmd); | ||
261 | struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(cmd->device->host); | ||
262 | |||
263 | /* remove the aborted task flag to allow the task to be | ||
264 | * completed now. At this point, we only get called following | ||
265 | * an actual abort of the task, so we should be guaranteed not | ||
266 | * to be racing with any completions from the LLD (hence we | ||
267 | * don't need the task state lock to clear the flag) */ | ||
268 | task->task_state_flags &= ~SAS_TASK_STATE_ABORTED; | ||
269 | /* Now call task_done. However, task will be free'd after | ||
270 | * this */ | ||
271 | task->task_done(task); | ||
272 | /* now finish the command and move it on to the error | ||
273 | * handler done list, this also takes it off the | ||
274 | * error handler pending list */ | ||
275 | scsi_eh_finish_cmd(cmd, &sas_ha->eh_done_q); | ||
276 | } | ||
277 | |||
258 | static void sas_scsi_clear_queue_lu(struct list_head *error_q, struct scsi_cmnd *my_cmd) | 278 | static void sas_scsi_clear_queue_lu(struct list_head *error_q, struct scsi_cmnd *my_cmd) |
259 | { | 279 | { |
260 | struct scsi_cmnd *cmd, *n; | 280 | struct scsi_cmnd *cmd, *n; |
261 | 281 | ||
262 | list_for_each_entry_safe(cmd, n, error_q, eh_entry) { | 282 | list_for_each_entry_safe(cmd, n, error_q, eh_entry) { |
263 | if (cmd == my_cmd) | 283 | if (cmd->device->sdev_target == my_cmd->device->sdev_target && |
264 | list_del_init(&cmd->eh_entry); | 284 | cmd->device->lun == my_cmd->device->lun) |
285 | sas_eh_finish_cmd(cmd); | ||
265 | } | 286 | } |
266 | } | 287 | } |
267 | 288 | ||
@@ -274,7 +295,7 @@ static void sas_scsi_clear_queue_I_T(struct list_head *error_q, | |||
274 | struct domain_device *x = cmd_to_domain_dev(cmd); | 295 | struct domain_device *x = cmd_to_domain_dev(cmd); |
275 | 296 | ||
276 | if (x == dev) | 297 | if (x == dev) |
277 | list_del_init(&cmd->eh_entry); | 298 | sas_eh_finish_cmd(cmd); |
278 | } | 299 | } |
279 | } | 300 | } |
280 | 301 | ||
@@ -288,7 +309,7 @@ static void sas_scsi_clear_queue_port(struct list_head *error_q, | |||
288 | struct asd_sas_port *x = dev->port; | 309 | struct asd_sas_port *x = dev->port; |
289 | 310 | ||
290 | if (x == port) | 311 | if (x == port) |
291 | list_del_init(&cmd->eh_entry); | 312 | sas_eh_finish_cmd(cmd); |
292 | } | 313 | } |
293 | } | 314 | } |
294 | 315 | ||
@@ -528,14 +549,14 @@ Again: | |||
528 | case TASK_IS_DONE: | 549 | case TASK_IS_DONE: |
529 | SAS_DPRINTK("%s: task 0x%p is done\n", __FUNCTION__, | 550 | SAS_DPRINTK("%s: task 0x%p is done\n", __FUNCTION__, |
530 | task); | 551 | task); |
531 | task->task_done(task); | 552 | sas_eh_finish_cmd(cmd); |
532 | if (need_reset) | 553 | if (need_reset) |
533 | try_to_reset_cmd_device(shost, cmd); | 554 | try_to_reset_cmd_device(shost, cmd); |
534 | continue; | 555 | continue; |
535 | case TASK_IS_ABORTED: | 556 | case TASK_IS_ABORTED: |
536 | SAS_DPRINTK("%s: task 0x%p is aborted\n", | 557 | SAS_DPRINTK("%s: task 0x%p is aborted\n", |
537 | __FUNCTION__, task); | 558 | __FUNCTION__, task); |
538 | task->task_done(task); | 559 | sas_eh_finish_cmd(cmd); |
539 | if (need_reset) | 560 | if (need_reset) |
540 | try_to_reset_cmd_device(shost, cmd); | 561 | try_to_reset_cmd_device(shost, cmd); |
541 | continue; | 562 | continue; |
@@ -547,7 +568,7 @@ Again: | |||
547 | "recovered\n", | 568 | "recovered\n", |
548 | SAS_ADDR(task->dev), | 569 | SAS_ADDR(task->dev), |
549 | cmd->device->lun); | 570 | cmd->device->lun); |
550 | task->task_done(task); | 571 | sas_eh_finish_cmd(cmd); |
551 | if (need_reset) | 572 | if (need_reset) |
552 | try_to_reset_cmd_device(shost, cmd); | 573 | try_to_reset_cmd_device(shost, cmd); |
553 | sas_scsi_clear_queue_lu(work_q, cmd); | 574 | sas_scsi_clear_queue_lu(work_q, cmd); |
@@ -562,7 +583,7 @@ Again: | |||
562 | if (tmf_resp == TMF_RESP_FUNC_COMPLETE) { | 583 | if (tmf_resp == TMF_RESP_FUNC_COMPLETE) { |
563 | SAS_DPRINTK("I_T %016llx recovered\n", | 584 | SAS_DPRINTK("I_T %016llx recovered\n", |
564 | SAS_ADDR(task->dev->sas_addr)); | 585 | SAS_ADDR(task->dev->sas_addr)); |
565 | task->task_done(task); | 586 | sas_eh_finish_cmd(cmd); |
566 | if (need_reset) | 587 | if (need_reset) |
567 | try_to_reset_cmd_device(shost, cmd); | 588 | try_to_reset_cmd_device(shost, cmd); |
568 | sas_scsi_clear_queue_I_T(work_q, task->dev); | 589 | sas_scsi_clear_queue_I_T(work_q, task->dev); |
@@ -577,7 +598,7 @@ Again: | |||
577 | if (res == TMF_RESP_FUNC_COMPLETE) { | 598 | if (res == TMF_RESP_FUNC_COMPLETE) { |
578 | SAS_DPRINTK("clear nexus port:%d " | 599 | SAS_DPRINTK("clear nexus port:%d " |
579 | "succeeded\n", port->id); | 600 | "succeeded\n", port->id); |
580 | task->task_done(task); | 601 | sas_eh_finish_cmd(cmd); |
581 | if (need_reset) | 602 | if (need_reset) |
582 | try_to_reset_cmd_device(shost, cmd); | 603 | try_to_reset_cmd_device(shost, cmd); |
583 | sas_scsi_clear_queue_port(work_q, | 604 | sas_scsi_clear_queue_port(work_q, |
@@ -591,10 +612,10 @@ Again: | |||
591 | if (res == TMF_RESP_FUNC_COMPLETE) { | 612 | if (res == TMF_RESP_FUNC_COMPLETE) { |
592 | SAS_DPRINTK("clear nexus ha " | 613 | SAS_DPRINTK("clear nexus ha " |
593 | "succeeded\n"); | 614 | "succeeded\n"); |
594 | task->task_done(task); | 615 | sas_eh_finish_cmd(cmd); |
595 | if (need_reset) | 616 | if (need_reset) |
596 | try_to_reset_cmd_device(shost, cmd); | 617 | try_to_reset_cmd_device(shost, cmd); |
597 | goto out; | 618 | goto clear_q; |
598 | } | 619 | } |
599 | } | 620 | } |
600 | /* If we are here -- this means that no amount | 621 | /* If we are here -- this means that no amount |
@@ -606,21 +627,18 @@ Again: | |||
606 | SAS_ADDR(task->dev->sas_addr), | 627 | SAS_ADDR(task->dev->sas_addr), |
607 | cmd->device->lun); | 628 | cmd->device->lun); |
608 | 629 | ||
609 | task->task_done(task); | 630 | sas_eh_finish_cmd(cmd); |
610 | if (need_reset) | 631 | if (need_reset) |
611 | try_to_reset_cmd_device(shost, cmd); | 632 | try_to_reset_cmd_device(shost, cmd); |
612 | goto clear_q; | 633 | goto clear_q; |
613 | } | 634 | } |
614 | } | 635 | } |
615 | out: | ||
616 | return list_empty(work_q); | 636 | return list_empty(work_q); |
617 | clear_q: | 637 | clear_q: |
618 | SAS_DPRINTK("--- Exit %s -- clear_q\n", __FUNCTION__); | 638 | SAS_DPRINTK("--- Exit %s -- clear_q\n", __FUNCTION__); |
619 | list_for_each_entry_safe(cmd, n, work_q, eh_entry) { | 639 | list_for_each_entry_safe(cmd, n, work_q, eh_entry) |
620 | struct sas_task *task = TO_SAS_TASK(cmd); | 640 | sas_eh_finish_cmd(cmd); |
621 | list_del_init(&cmd->eh_entry); | 641 | |
622 | task->task_done(task); | ||
623 | } | ||
624 | return list_empty(work_q); | 642 | return list_empty(work_q); |
625 | } | 643 | } |
626 | 644 | ||
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 83567b9755b4..2ab2d24dcc15 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -307,6 +307,7 @@ struct lpfc_vport { | |||
307 | 307 | ||
308 | uint32_t fc_nlp_cnt; /* outstanding NODELIST requests */ | 308 | uint32_t fc_nlp_cnt; /* outstanding NODELIST requests */ |
309 | uint32_t fc_rscn_id_cnt; /* count of RSCNs payloads in list */ | 309 | uint32_t fc_rscn_id_cnt; /* count of RSCNs payloads in list */ |
310 | uint32_t fc_rscn_flush; /* flag use of fc_rscn_id_list */ | ||
310 | struct lpfc_dmabuf *fc_rscn_id_list[FC_MAX_HOLD_RSCN]; | 311 | struct lpfc_dmabuf *fc_rscn_id_list[FC_MAX_HOLD_RSCN]; |
311 | struct lpfc_name fc_nodename; /* fc nodename */ | 312 | struct lpfc_name fc_nodename; /* fc nodename */ |
312 | struct lpfc_name fc_portname; /* fc portname */ | 313 | struct lpfc_name fc_portname; /* fc portname */ |
@@ -392,6 +393,13 @@ enum hba_temp_state { | |||
392 | HBA_OVER_TEMP | 393 | HBA_OVER_TEMP |
393 | }; | 394 | }; |
394 | 395 | ||
396 | enum intr_type_t { | ||
397 | NONE = 0, | ||
398 | INTx, | ||
399 | MSI, | ||
400 | MSIX, | ||
401 | }; | ||
402 | |||
395 | struct lpfc_hba { | 403 | struct lpfc_hba { |
396 | struct lpfc_sli sli; | 404 | struct lpfc_sli sli; |
397 | uint32_t sli_rev; /* SLI2 or SLI3 */ | 405 | uint32_t sli_rev; /* SLI2 or SLI3 */ |
@@ -409,7 +417,7 @@ struct lpfc_hba { | |||
409 | /* This flag is set while issuing */ | 417 | /* This flag is set while issuing */ |
410 | /* INIT_LINK mailbox command */ | 418 | /* INIT_LINK mailbox command */ |
411 | #define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */ | 419 | #define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */ |
412 | #define LS_IGNORE_ERATT 0x3 /* intr handler should ignore ERATT */ | 420 | #define LS_IGNORE_ERATT 0x4 /* intr handler should ignore ERATT */ |
413 | 421 | ||
414 | struct lpfc_sli2_slim *slim2p; | 422 | struct lpfc_sli2_slim *slim2p; |
415 | struct lpfc_dmabuf hbqslimp; | 423 | struct lpfc_dmabuf hbqslimp; |
@@ -487,6 +495,8 @@ struct lpfc_hba { | |||
487 | wait_queue_head_t *work_wait; | 495 | wait_queue_head_t *work_wait; |
488 | struct task_struct *worker_thread; | 496 | struct task_struct *worker_thread; |
489 | 497 | ||
498 | uint32_t hbq_in_use; /* HBQs in use flag */ | ||
499 | struct list_head hbqbuf_in_list; /* in-fly hbq buffer list */ | ||
490 | uint32_t hbq_count; /* Count of configured HBQs */ | 500 | uint32_t hbq_count; /* Count of configured HBQs */ |
491 | struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies */ | 501 | struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies */ |
492 | 502 | ||
@@ -555,7 +565,8 @@ struct lpfc_hba { | |||
555 | mempool_t *nlp_mem_pool; | 565 | mempool_t *nlp_mem_pool; |
556 | 566 | ||
557 | struct fc_host_statistics link_stats; | 567 | struct fc_host_statistics link_stats; |
558 | uint8_t using_msi; | 568 | enum intr_type_t intr_type; |
569 | struct msix_entry msix_entries[1]; | ||
559 | 570 | ||
560 | struct list_head port_list; | 571 | struct list_head port_list; |
561 | struct lpfc_vport *pport; /* physical lpfc_vport pointer */ | 572 | struct lpfc_vport *pport; /* physical lpfc_vport pointer */ |
@@ -595,6 +606,8 @@ struct lpfc_hba { | |||
595 | unsigned long last_completion_time; | 606 | unsigned long last_completion_time; |
596 | struct timer_list hb_tmofunc; | 607 | struct timer_list hb_tmofunc; |
597 | uint8_t hb_outstanding; | 608 | uint8_t hb_outstanding; |
609 | /* ndlp reference management */ | ||
610 | spinlock_t ndlp_lock; | ||
598 | /* | 611 | /* |
599 | * Following bit will be set for all buffer tags which are not | 612 | * Following bit will be set for all buffer tags which are not |
600 | * associated with any HBQ. | 613 | * associated with any HBQ. |
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 4bae4a2ed2f1..b12a841703ca 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -1191,7 +1191,7 @@ lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) | |||
1191 | shost = lpfc_shost_from_vport(vport); | 1191 | shost = lpfc_shost_from_vport(vport); |
1192 | spin_lock_irq(shost->host_lock); | 1192 | spin_lock_irq(shost->host_lock); |
1193 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) | 1193 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
1194 | if (ndlp->rport) | 1194 | if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport) |
1195 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; | 1195 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
1196 | spin_unlock_irq(shost->host_lock); | 1196 | spin_unlock_irq(shost->host_lock); |
1197 | } | 1197 | } |
@@ -1592,9 +1592,11 @@ LPFC_ATTR_RW(poll_tmo, 10, 1, 255, | |||
1592 | # support this feature | 1592 | # support this feature |
1593 | # 0 = MSI disabled (default) | 1593 | # 0 = MSI disabled (default) |
1594 | # 1 = MSI enabled | 1594 | # 1 = MSI enabled |
1595 | # Value range is [0,1]. Default value is 0. | 1595 | # 2 = MSI-X enabled |
1596 | # Value range is [0,2]. Default value is 0. | ||
1596 | */ | 1597 | */ |
1597 | LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible"); | 1598 | LPFC_ATTR_R(use_msi, 0, 0, 2, "Use Message Signaled Interrupts (1) or " |
1599 | "MSI-X (2), if possible"); | ||
1598 | 1600 | ||
1599 | /* | 1601 | /* |
1600 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. | 1602 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
@@ -1946,11 +1948,13 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
1946 | } | 1948 | } |
1947 | 1949 | ||
1948 | /* If HBA encountered an error attention, allow only DUMP | 1950 | /* If HBA encountered an error attention, allow only DUMP |
1949 | * mailbox command until the HBA is restarted. | 1951 | * or RESTART mailbox commands until the HBA is restarted. |
1950 | */ | 1952 | */ |
1951 | if ((phba->pport->stopped) && | 1953 | if ((phba->pport->stopped) && |
1952 | (phba->sysfs_mbox.mbox->mb.mbxCommand | 1954 | (phba->sysfs_mbox.mbox->mb.mbxCommand != |
1953 | != MBX_DUMP_MEMORY)) { | 1955 | MBX_DUMP_MEMORY && |
1956 | phba->sysfs_mbox.mbox->mb.mbxCommand != | ||
1957 | MBX_RESTART)) { | ||
1954 | sysfs_mbox_idle(phba); | 1958 | sysfs_mbox_idle(phba); |
1955 | spin_unlock_irq(&phba->hbalock); | 1959 | spin_unlock_irq(&phba->hbalock); |
1956 | return -EPERM; | 1960 | return -EPERM; |
@@ -2384,7 +2388,8 @@ lpfc_get_node_by_target(struct scsi_target *starget) | |||
2384 | spin_lock_irq(shost->host_lock); | 2388 | spin_lock_irq(shost->host_lock); |
2385 | /* Search for this, mapped, target ID */ | 2389 | /* Search for this, mapped, target ID */ |
2386 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { | 2390 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
2387 | if (ndlp->nlp_state == NLP_STE_MAPPED_NODE && | 2391 | if (NLP_CHK_NODE_ACT(ndlp) && |
2392 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && | ||
2388 | starget->id == ndlp->nlp_sid) { | 2393 | starget->id == ndlp->nlp_sid) { |
2389 | spin_unlock_irq(shost->host_lock); | 2394 | spin_unlock_irq(shost->host_lock); |
2390 | return ndlp; | 2395 | return ndlp; |
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index 50fcb7c930bc..0819f5f39de5 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * * | 7 | * * |
@@ -53,7 +53,10 @@ void lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *, LPFC_MBOXQ_t *); | |||
53 | void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); | 53 | void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); |
54 | void lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); | 54 | void lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); |
55 | void lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); | 55 | void lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); |
56 | void lpfc_enqueue_node(struct lpfc_vport *, struct lpfc_nodelist *); | ||
56 | void lpfc_dequeue_node(struct lpfc_vport *, struct lpfc_nodelist *); | 57 | void lpfc_dequeue_node(struct lpfc_vport *, struct lpfc_nodelist *); |
58 | struct lpfc_nodelist *lpfc_enable_node(struct lpfc_vport *, | ||
59 | struct lpfc_nodelist *, int); | ||
57 | void lpfc_nlp_set_state(struct lpfc_vport *, struct lpfc_nodelist *, int); | 60 | void lpfc_nlp_set_state(struct lpfc_vport *, struct lpfc_nodelist *, int); |
58 | void lpfc_drop_node(struct lpfc_vport *, struct lpfc_nodelist *); | 61 | void lpfc_drop_node(struct lpfc_vport *, struct lpfc_nodelist *); |
59 | void lpfc_set_disctmo(struct lpfc_vport *); | 62 | void lpfc_set_disctmo(struct lpfc_vport *); |
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 92441ce610ed..3d0ccd9b341d 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * * | 7 | * * |
@@ -294,7 +294,7 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, | |||
294 | /* Save for completion so we can release these resources */ | 294 | /* Save for completion so we can release these resources */ |
295 | geniocb->context1 = (uint8_t *) inp; | 295 | geniocb->context1 = (uint8_t *) inp; |
296 | geniocb->context2 = (uint8_t *) outp; | 296 | geniocb->context2 = (uint8_t *) outp; |
297 | geniocb->context_un.ndlp = ndlp; | 297 | geniocb->context_un.ndlp = lpfc_nlp_get(ndlp); |
298 | 298 | ||
299 | /* Fill in payload, bp points to frame payload */ | 299 | /* Fill in payload, bp points to frame payload */ |
300 | icmd->ulpCommand = CMD_GEN_REQUEST64_CR; | 300 | icmd->ulpCommand = CMD_GEN_REQUEST64_CR; |
@@ -489,8 +489,10 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) | |||
489 | */ | 489 | */ |
490 | ndlp = lpfc_findnode_did(vport, | 490 | ndlp = lpfc_findnode_did(vport, |
491 | Did); | 491 | Did); |
492 | if (ndlp && (ndlp->nlp_type & | 492 | if (ndlp && |
493 | NLP_FCP_TARGET)) | 493 | NLP_CHK_NODE_ACT(ndlp) |
494 | && (ndlp->nlp_type & | ||
495 | NLP_FCP_TARGET)) | ||
494 | lpfc_setup_disc_node | 496 | lpfc_setup_disc_node |
495 | (vport, Did); | 497 | (vport, Did); |
496 | else if (lpfc_ns_cmd(vport, | 498 | else if (lpfc_ns_cmd(vport, |
@@ -773,7 +775,7 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
773 | "0267 NameServer GFF Rsp " | 775 | "0267 NameServer GFF Rsp " |
774 | "x%x Error (%d %d) Data: x%x x%x\n", | 776 | "x%x Error (%d %d) Data: x%x x%x\n", |
775 | did, irsp->ulpStatus, irsp->un.ulpWord[4], | 777 | did, irsp->ulpStatus, irsp->un.ulpWord[4], |
776 | vport->fc_flag, vport->fc_rscn_id_cnt) | 778 | vport->fc_flag, vport->fc_rscn_id_cnt); |
777 | } | 779 | } |
778 | 780 | ||
779 | /* This is a target port, unregistered port, or the GFF_ID failed */ | 781 | /* This is a target port, unregistered port, or the GFF_ID failed */ |
@@ -1064,7 +1066,8 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, | |||
1064 | int rc = 0; | 1066 | int rc = 0; |
1065 | 1067 | ||
1066 | ndlp = lpfc_findnode_did(vport, NameServer_DID); | 1068 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
1067 | if (ndlp == NULL || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) { | 1069 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) |
1070 | || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) { | ||
1068 | rc=1; | 1071 | rc=1; |
1069 | goto ns_cmd_exit; | 1072 | goto ns_cmd_exit; |
1070 | } | 1073 | } |
@@ -1213,8 +1216,9 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, | |||
1213 | cmpl = lpfc_cmpl_ct_cmd_rff_id; | 1216 | cmpl = lpfc_cmpl_ct_cmd_rff_id; |
1214 | break; | 1217 | break; |
1215 | } | 1218 | } |
1216 | lpfc_nlp_get(ndlp); | 1219 | /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count |
1217 | 1220 | * to hold ndlp reference for the corresponding callback function. | |
1221 | */ | ||
1218 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) { | 1222 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) { |
1219 | /* On success, The cmpl function will free the buffers */ | 1223 | /* On success, The cmpl function will free the buffers */ |
1220 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, | 1224 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
@@ -1222,9 +1226,13 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, | |||
1222 | cmdcode, ndlp->nlp_DID, 0); | 1226 | cmdcode, ndlp->nlp_DID, 0); |
1223 | return 0; | 1227 | return 0; |
1224 | } | 1228 | } |
1225 | |||
1226 | rc=6; | 1229 | rc=6; |
1230 | |||
1231 | /* Decrement ndlp reference count to release ndlp reference held | ||
1232 | * for the failed command's callback function. | ||
1233 | */ | ||
1227 | lpfc_nlp_put(ndlp); | 1234 | lpfc_nlp_put(ndlp); |
1235 | |||
1228 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); | 1236 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
1229 | ns_cmd_free_bmp: | 1237 | ns_cmd_free_bmp: |
1230 | kfree(bmp); | 1238 | kfree(bmp); |
@@ -1271,6 +1279,9 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
1271 | } | 1279 | } |
1272 | 1280 | ||
1273 | ndlp = lpfc_findnode_did(vport, FDMI_DID); | 1281 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
1282 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) | ||
1283 | goto fail_out; | ||
1284 | |||
1274 | if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { | 1285 | if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
1275 | /* FDMI rsp failed */ | 1286 | /* FDMI rsp failed */ |
1276 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | 1287 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
@@ -1294,6 +1305,8 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
1294 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA); | 1305 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA); |
1295 | break; | 1306 | break; |
1296 | } | 1307 | } |
1308 | |||
1309 | fail_out: | ||
1297 | lpfc_ct_free_iocb(phba, cmdiocb); | 1310 | lpfc_ct_free_iocb(phba, cmdiocb); |
1298 | return; | 1311 | return; |
1299 | } | 1312 | } |
@@ -1650,12 +1663,18 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode) | |||
1650 | bpl->tus.w = le32_to_cpu(bpl->tus.w); | 1663 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
1651 | 1664 | ||
1652 | cmpl = lpfc_cmpl_ct_cmd_fdmi; | 1665 | cmpl = lpfc_cmpl_ct_cmd_fdmi; |
1653 | lpfc_nlp_get(ndlp); | ||
1654 | 1666 | ||
1667 | /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count | ||
1668 | * to hold ndlp reference for the corresponding callback function. | ||
1669 | */ | ||
1655 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, FC_MAX_NS_RSP, 0)) | 1670 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, FC_MAX_NS_RSP, 0)) |
1656 | return 0; | 1671 | return 0; |
1657 | 1672 | ||
1673 | /* Decrement ndlp reference count to release ndlp reference held | ||
1674 | * for the failed command's callback function. | ||
1675 | */ | ||
1658 | lpfc_nlp_put(ndlp); | 1676 | lpfc_nlp_put(ndlp); |
1677 | |||
1659 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); | 1678 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
1660 | fdmi_cmd_free_bmp: | 1679 | fdmi_cmd_free_bmp: |
1661 | kfree(bmp); | 1680 | kfree(bmp); |
@@ -1698,7 +1717,7 @@ lpfc_fdmi_timeout_handler(struct lpfc_vport *vport) | |||
1698 | struct lpfc_nodelist *ndlp; | 1717 | struct lpfc_nodelist *ndlp; |
1699 | 1718 | ||
1700 | ndlp = lpfc_findnode_did(vport, FDMI_DID); | 1719 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
1701 | if (ndlp) { | 1720 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
1702 | if (init_utsname()->nodename[0] != '\0') | 1721 | if (init_utsname()->nodename[0] != '\0') |
1703 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA); | 1722 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA); |
1704 | else | 1723 | else |
diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h index cfe81c50529a..2db0b74b6fad 100644 --- a/drivers/scsi/lpfc/lpfc_disc.h +++ b/drivers/scsi/lpfc/lpfc_disc.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * * | 7 | * * |
@@ -73,6 +73,12 @@ struct lpfc_nodelist { | |||
73 | uint8_t nlp_fcp_info; /* class info, bits 0-3 */ | 73 | uint8_t nlp_fcp_info; /* class info, bits 0-3 */ |
74 | #define NLP_FCP_2_DEVICE 0x10 /* FCP-2 device */ | 74 | #define NLP_FCP_2_DEVICE 0x10 /* FCP-2 device */ |
75 | 75 | ||
76 | uint16_t nlp_usg_map; /* ndlp management usage bitmap */ | ||
77 | #define NLP_USG_NODE_ACT_BIT 0x1 /* Indicate ndlp is actively used */ | ||
78 | #define NLP_USG_IACT_REQ_BIT 0x2 /* Request to inactivate ndlp */ | ||
79 | #define NLP_USG_FREE_REQ_BIT 0x4 /* Request to invoke ndlp memory free */ | ||
80 | #define NLP_USG_FREE_ACK_BIT 0x8 /* Indicate ndlp memory free invoked */ | ||
81 | |||
76 | struct timer_list nlp_delayfunc; /* Used for delayed ELS cmds */ | 82 | struct timer_list nlp_delayfunc; /* Used for delayed ELS cmds */ |
77 | struct fc_rport *rport; /* Corresponding FC transport | 83 | struct fc_rport *rport; /* Corresponding FC transport |
78 | port structure */ | 84 | port structure */ |
@@ -85,25 +91,51 @@ struct lpfc_nodelist { | |||
85 | }; | 91 | }; |
86 | 92 | ||
87 | /* Defines for nlp_flag (uint32) */ | 93 | /* Defines for nlp_flag (uint32) */ |
88 | #define NLP_PLOGI_SND 0x20 /* sent PLOGI request for this entry */ | 94 | #define NLP_PLOGI_SND 0x00000020 /* sent PLOGI request for this entry */ |
89 | #define NLP_PRLI_SND 0x40 /* sent PRLI request for this entry */ | 95 | #define NLP_PRLI_SND 0x00000040 /* sent PRLI request for this entry */ |
90 | #define NLP_ADISC_SND 0x80 /* sent ADISC request for this entry */ | 96 | #define NLP_ADISC_SND 0x00000080 /* sent ADISC request for this entry */ |
91 | #define NLP_LOGO_SND 0x100 /* sent LOGO request for this entry */ | 97 | #define NLP_LOGO_SND 0x00000100 /* sent LOGO request for this entry */ |
92 | #define NLP_RNID_SND 0x400 /* sent RNID request for this entry */ | 98 | #define NLP_RNID_SND 0x00000400 /* sent RNID request for this entry */ |
93 | #define NLP_ELS_SND_MASK 0x7e0 /* sent ELS request for this entry */ | 99 | #define NLP_ELS_SND_MASK 0x000007e0 /* sent ELS request for this entry */ |
94 | #define NLP_DEFER_RM 0x10000 /* Remove this ndlp if no longer used */ | 100 | #define NLP_DEFER_RM 0x00010000 /* Remove this ndlp if no longer used */ |
95 | #define NLP_DELAY_TMO 0x20000 /* delay timeout is running for node */ | 101 | #define NLP_DELAY_TMO 0x00020000 /* delay timeout is running for node */ |
96 | #define NLP_NPR_2B_DISC 0x40000 /* node is included in num_disc_nodes */ | 102 | #define NLP_NPR_2B_DISC 0x00040000 /* node is included in num_disc_nodes */ |
97 | #define NLP_RCV_PLOGI 0x80000 /* Rcv'ed PLOGI from remote system */ | 103 | #define NLP_RCV_PLOGI 0x00080000 /* Rcv'ed PLOGI from remote system */ |
98 | #define NLP_LOGO_ACC 0x100000 /* Process LOGO after ACC completes */ | 104 | #define NLP_LOGO_ACC 0x00100000 /* Process LOGO after ACC completes */ |
99 | #define NLP_TGT_NO_SCSIID 0x200000 /* good PRLI but no binding for scsid */ | 105 | #define NLP_TGT_NO_SCSIID 0x00200000 /* good PRLI but no binding for scsid */ |
100 | #define NLP_ACC_REGLOGIN 0x1000000 /* Issue Reg Login after successful | 106 | #define NLP_ACC_REGLOGIN 0x01000000 /* Issue Reg Login after successful |
101 | ACC */ | 107 | ACC */ |
102 | #define NLP_NPR_ADISC 0x2000000 /* Issue ADISC when dq'ed from | 108 | #define NLP_NPR_ADISC 0x02000000 /* Issue ADISC when dq'ed from |
103 | NPR list */ | 109 | NPR list */ |
104 | #define NLP_RM_DFLT_RPI 0x4000000 /* need to remove leftover dflt RPI */ | 110 | #define NLP_RM_DFLT_RPI 0x04000000 /* need to remove leftover dflt RPI */ |
105 | #define NLP_NODEV_REMOVE 0x8000000 /* Defer removal till discovery ends */ | 111 | #define NLP_NODEV_REMOVE 0x08000000 /* Defer removal till discovery ends */ |
106 | #define NLP_TARGET_REMOVE 0x10000000 /* Target remove in process */ | 112 | #define NLP_TARGET_REMOVE 0x10000000 /* Target remove in process */ |
113 | #define NLP_SC_REQ 0x20000000 /* Target requires authentication */ | ||
114 | |||
115 | /* ndlp usage management macros */ | ||
116 | #define NLP_CHK_NODE_ACT(ndlp) (((ndlp)->nlp_usg_map \ | ||
117 | & NLP_USG_NODE_ACT_BIT) \ | ||
118 | && \ | ||
119 | !((ndlp)->nlp_usg_map \ | ||
120 | & NLP_USG_FREE_ACK_BIT)) | ||
121 | #define NLP_SET_NODE_ACT(ndlp) ((ndlp)->nlp_usg_map \ | ||
122 | |= NLP_USG_NODE_ACT_BIT) | ||
123 | #define NLP_INT_NODE_ACT(ndlp) ((ndlp)->nlp_usg_map \ | ||
124 | = NLP_USG_NODE_ACT_BIT) | ||
125 | #define NLP_CLR_NODE_ACT(ndlp) ((ndlp)->nlp_usg_map \ | ||
126 | &= ~NLP_USG_NODE_ACT_BIT) | ||
127 | #define NLP_CHK_IACT_REQ(ndlp) ((ndlp)->nlp_usg_map \ | ||
128 | & NLP_USG_IACT_REQ_BIT) | ||
129 | #define NLP_SET_IACT_REQ(ndlp) ((ndlp)->nlp_usg_map \ | ||
130 | |= NLP_USG_IACT_REQ_BIT) | ||
131 | #define NLP_CHK_FREE_REQ(ndlp) ((ndlp)->nlp_usg_map \ | ||
132 | & NLP_USG_FREE_REQ_BIT) | ||
133 | #define NLP_SET_FREE_REQ(ndlp) ((ndlp)->nlp_usg_map \ | ||
134 | |= NLP_USG_FREE_REQ_BIT) | ||
135 | #define NLP_CHK_FREE_ACK(ndlp) ((ndlp)->nlp_usg_map \ | ||
136 | & NLP_USG_FREE_ACK_BIT) | ||
137 | #define NLP_SET_FREE_ACK(ndlp) ((ndlp)->nlp_usg_map \ | ||
138 | |= NLP_USG_FREE_ACK_BIT) | ||
107 | 139 | ||
108 | /* There are 4 different double linked lists nodelist entries can reside on. | 140 | /* There are 4 different double linked lists nodelist entries can reside on. |
109 | * The Port Login (PLOGI) list and Address Discovery (ADISC) list are used | 141 | * The Port Login (PLOGI) list and Address Discovery (ADISC) list are used |
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index c6b739dc6bc3..cbb68a942255 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -113,6 +113,7 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, | |||
113 | 113 | ||
114 | if (elsiocb == NULL) | 114 | if (elsiocb == NULL) |
115 | return NULL; | 115 | return NULL; |
116 | |||
116 | icmd = &elsiocb->iocb; | 117 | icmd = &elsiocb->iocb; |
117 | 118 | ||
118 | /* fill in BDEs for command */ | 119 | /* fill in BDEs for command */ |
@@ -134,9 +135,8 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, | |||
134 | if (!prsp || !prsp->virt) | 135 | if (!prsp || !prsp->virt) |
135 | goto els_iocb_free_prsp_exit; | 136 | goto els_iocb_free_prsp_exit; |
136 | INIT_LIST_HEAD(&prsp->list); | 137 | INIT_LIST_HEAD(&prsp->list); |
137 | } else { | 138 | } else |
138 | prsp = NULL; | 139 | prsp = NULL; |
139 | } | ||
140 | 140 | ||
141 | /* Allocate buffer for Buffer ptr list */ | 141 | /* Allocate buffer for Buffer ptr list */ |
142 | pbuflist = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); | 142 | pbuflist = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
@@ -246,7 +246,7 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) | |||
246 | 246 | ||
247 | sp = &phba->fc_fabparam; | 247 | sp = &phba->fc_fabparam; |
248 | ndlp = lpfc_findnode_did(vport, Fabric_DID); | 248 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
249 | if (!ndlp) { | 249 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
250 | err = 1; | 250 | err = 1; |
251 | goto fail; | 251 | goto fail; |
252 | } | 252 | } |
@@ -282,6 +282,9 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) | |||
282 | 282 | ||
283 | mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login; | 283 | mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login; |
284 | mbox->vport = vport; | 284 | mbox->vport = vport; |
285 | /* increment the reference count on ndlp to hold reference | ||
286 | * for the callback routine. | ||
287 | */ | ||
285 | mbox->context2 = lpfc_nlp_get(ndlp); | 288 | mbox->context2 = lpfc_nlp_get(ndlp); |
286 | 289 | ||
287 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); | 290 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
@@ -293,6 +296,9 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) | |||
293 | return 0; | 296 | return 0; |
294 | 297 | ||
295 | fail_issue_reg_login: | 298 | fail_issue_reg_login: |
299 | /* decrement the reference count on ndlp just incremented | ||
300 | * for the failed mbox command. | ||
301 | */ | ||
296 | lpfc_nlp_put(ndlp); | 302 | lpfc_nlp_put(ndlp); |
297 | mp = (struct lpfc_dmabuf *) mbox->context1; | 303 | mp = (struct lpfc_dmabuf *) mbox->context1; |
298 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 304 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
@@ -381,6 +387,8 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
381 | */ | 387 | */ |
382 | list_for_each_entry_safe(np, next_np, | 388 | list_for_each_entry_safe(np, next_np, |
383 | &vport->fc_nodes, nlp_listp) { | 389 | &vport->fc_nodes, nlp_listp) { |
390 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
391 | continue; | ||
384 | if ((np->nlp_state != NLP_STE_NPR_NODE) || | 392 | if ((np->nlp_state != NLP_STE_NPR_NODE) || |
385 | !(np->nlp_flag & NLP_NPR_ADISC)) | 393 | !(np->nlp_flag & NLP_NPR_ADISC)) |
386 | continue; | 394 | continue; |
@@ -456,6 +464,9 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
456 | mempool_free(mbox, phba->mbox_mem_pool); | 464 | mempool_free(mbox, phba->mbox_mem_pool); |
457 | goto fail; | 465 | goto fail; |
458 | } | 466 | } |
467 | /* Decrement ndlp reference count indicating that ndlp can be | ||
468 | * safely released when other references to it are done. | ||
469 | */ | ||
459 | lpfc_nlp_put(ndlp); | 470 | lpfc_nlp_put(ndlp); |
460 | 471 | ||
461 | ndlp = lpfc_findnode_did(vport, PT2PT_RemoteID); | 472 | ndlp = lpfc_findnode_did(vport, PT2PT_RemoteID); |
@@ -467,22 +478,29 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
467 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); | 478 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
468 | if (!ndlp) | 479 | if (!ndlp) |
469 | goto fail; | 480 | goto fail; |
470 | |||
471 | lpfc_nlp_init(vport, ndlp, PT2PT_RemoteID); | 481 | lpfc_nlp_init(vport, ndlp, PT2PT_RemoteID); |
482 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
483 | ndlp = lpfc_enable_node(vport, ndlp, | ||
484 | NLP_STE_UNUSED_NODE); | ||
485 | if(!ndlp) | ||
486 | goto fail; | ||
472 | } | 487 | } |
473 | 488 | ||
474 | memcpy(&ndlp->nlp_portname, &sp->portName, | 489 | memcpy(&ndlp->nlp_portname, &sp->portName, |
475 | sizeof(struct lpfc_name)); | 490 | sizeof(struct lpfc_name)); |
476 | memcpy(&ndlp->nlp_nodename, &sp->nodeName, | 491 | memcpy(&ndlp->nlp_nodename, &sp->nodeName, |
477 | sizeof(struct lpfc_name)); | 492 | sizeof(struct lpfc_name)); |
493 | /* Set state will put ndlp onto node list if not already done */ | ||
478 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | 494 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
479 | spin_lock_irq(shost->host_lock); | 495 | spin_lock_irq(shost->host_lock); |
480 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | 496 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
481 | spin_unlock_irq(shost->host_lock); | 497 | spin_unlock_irq(shost->host_lock); |
482 | } else { | 498 | } else |
483 | /* This side will wait for the PLOGI */ | 499 | /* This side will wait for the PLOGI, decrement ndlp reference |
500 | * count indicating that ndlp can be released when other | ||
501 | * references to it are done. | ||
502 | */ | ||
484 | lpfc_nlp_put(ndlp); | 503 | lpfc_nlp_put(ndlp); |
485 | } | ||
486 | 504 | ||
487 | /* If we are pt2pt with another NPort, force NPIV off! */ | 505 | /* If we are pt2pt with another NPort, force NPIV off! */ |
488 | phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; | 506 | phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; |
@@ -728,16 +746,21 @@ lpfc_initial_flogi(struct lpfc_vport *vport) | |||
728 | if (!ndlp) | 746 | if (!ndlp) |
729 | return 0; | 747 | return 0; |
730 | lpfc_nlp_init(vport, ndlp, Fabric_DID); | 748 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
731 | } else { | 749 | /* Put ndlp onto node list */ |
732 | lpfc_dequeue_node(vport, ndlp); | 750 | lpfc_enqueue_node(vport, ndlp); |
751 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
752 | /* re-setup ndlp without removing from node list */ | ||
753 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); | ||
754 | if (!ndlp) | ||
755 | return 0; | ||
733 | } | 756 | } |
734 | 757 | ||
735 | if (lpfc_issue_els_flogi(vport, ndlp, 0)) { | 758 | if (lpfc_issue_els_flogi(vport, ndlp, 0)) |
736 | /* This decrement of reference count to node shall kick off | 759 | /* This decrement of reference count to node shall kick off |
737 | * the release of the node. | 760 | * the release of the node. |
738 | */ | 761 | */ |
739 | lpfc_nlp_put(ndlp); | 762 | lpfc_nlp_put(ndlp); |
740 | } | 763 | |
741 | return 1; | 764 | return 1; |
742 | } | 765 | } |
743 | 766 | ||
@@ -755,9 +778,15 @@ lpfc_initial_fdisc(struct lpfc_vport *vport) | |||
755 | if (!ndlp) | 778 | if (!ndlp) |
756 | return 0; | 779 | return 0; |
757 | lpfc_nlp_init(vport, ndlp, Fabric_DID); | 780 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
758 | } else { | 781 | /* Put ndlp onto node list */ |
759 | lpfc_dequeue_node(vport, ndlp); | 782 | lpfc_enqueue_node(vport, ndlp); |
783 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
784 | /* re-setup ndlp without removing from node list */ | ||
785 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); | ||
786 | if (!ndlp) | ||
787 | return 0; | ||
760 | } | 788 | } |
789 | |||
761 | if (lpfc_issue_els_fdisc(vport, ndlp, 0)) { | 790 | if (lpfc_issue_els_fdisc(vport, ndlp, 0)) { |
762 | /* decrement node reference count to trigger the release of | 791 | /* decrement node reference count to trigger the release of |
763 | * the node. | 792 | * the node. |
@@ -816,7 +845,7 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, | |||
816 | */ | 845 | */ |
817 | new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName); | 846 | new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName); |
818 | 847 | ||
819 | if (new_ndlp == ndlp) | 848 | if (new_ndlp == ndlp && NLP_CHK_NODE_ACT(new_ndlp)) |
820 | return ndlp; | 849 | return ndlp; |
821 | 850 | ||
822 | if (!new_ndlp) { | 851 | if (!new_ndlp) { |
@@ -827,8 +856,12 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, | |||
827 | new_ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_ATOMIC); | 856 | new_ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_ATOMIC); |
828 | if (!new_ndlp) | 857 | if (!new_ndlp) |
829 | return ndlp; | 858 | return ndlp; |
830 | |||
831 | lpfc_nlp_init(vport, new_ndlp, ndlp->nlp_DID); | 859 | lpfc_nlp_init(vport, new_ndlp, ndlp->nlp_DID); |
860 | } else if (!NLP_CHK_NODE_ACT(new_ndlp)) { | ||
861 | new_ndlp = lpfc_enable_node(vport, new_ndlp, | ||
862 | NLP_STE_UNUSED_NODE); | ||
863 | if (!new_ndlp) | ||
864 | return ndlp; | ||
832 | } | 865 | } |
833 | 866 | ||
834 | lpfc_unreg_rpi(vport, new_ndlp); | 867 | lpfc_unreg_rpi(vport, new_ndlp); |
@@ -839,6 +872,7 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, | |||
839 | new_ndlp->nlp_flag |= NLP_NPR_2B_DISC; | 872 | new_ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
840 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | 873 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
841 | 874 | ||
875 | /* Set state will put new_ndlp on to node list if not already done */ | ||
842 | lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state); | 876 | lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state); |
843 | 877 | ||
844 | /* Move this back to NPR state */ | 878 | /* Move this back to NPR state */ |
@@ -912,7 +946,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
912 | irsp->un.elsreq64.remoteID); | 946 | irsp->un.elsreq64.remoteID); |
913 | 947 | ||
914 | ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); | 948 | ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); |
915 | if (!ndlp) { | 949 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
916 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, | 950 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
917 | "0136 PLOGI completes to NPort x%x " | 951 | "0136 PLOGI completes to NPort x%x " |
918 | "with no ndlp. Data: x%x x%x x%x\n", | 952 | "with no ndlp. Data: x%x x%x x%x\n", |
@@ -962,12 +996,11 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
962 | } | 996 | } |
963 | /* PLOGI failed */ | 997 | /* PLOGI failed */ |
964 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ | 998 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
965 | if (lpfc_error_lost_link(irsp)) { | 999 | if (lpfc_error_lost_link(irsp)) |
966 | rc = NLP_STE_FREED_NODE; | 1000 | rc = NLP_STE_FREED_NODE; |
967 | } else { | 1001 | else |
968 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, | 1002 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
969 | NLP_EVT_CMPL_PLOGI); | 1003 | NLP_EVT_CMPL_PLOGI); |
970 | } | ||
971 | } else { | 1004 | } else { |
972 | /* Good status, call state machine */ | 1005 | /* Good status, call state machine */ |
973 | prsp = list_entry(((struct lpfc_dmabuf *) | 1006 | prsp = list_entry(((struct lpfc_dmabuf *) |
@@ -1015,8 +1048,10 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) | |||
1015 | pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ | 1048 | pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ |
1016 | 1049 | ||
1017 | ndlp = lpfc_findnode_did(vport, did); | 1050 | ndlp = lpfc_findnode_did(vport, did); |
1018 | /* If ndlp if not NULL, we will bump the reference count on it */ | 1051 | if (ndlp && !NLP_CHK_NODE_ACT(ndlp)) |
1052 | ndlp = NULL; | ||
1019 | 1053 | ||
1054 | /* If ndlp is not NULL, we will bump the reference count on it */ | ||
1020 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); | 1055 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
1021 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, | 1056 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, |
1022 | ELS_CMD_PLOGI); | 1057 | ELS_CMD_PLOGI); |
@@ -1097,18 +1132,15 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
1097 | } | 1132 | } |
1098 | /* PRLI failed */ | 1133 | /* PRLI failed */ |
1099 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ | 1134 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
1100 | if (lpfc_error_lost_link(irsp)) { | 1135 | if (lpfc_error_lost_link(irsp)) |
1101 | goto out; | 1136 | goto out; |
1102 | } else { | 1137 | else |
1103 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, | 1138 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
1104 | NLP_EVT_CMPL_PRLI); | 1139 | NLP_EVT_CMPL_PRLI); |
1105 | } | 1140 | } else |
1106 | } else { | ||
1107 | /* Good status, call state machine */ | 1141 | /* Good status, call state machine */ |
1108 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, | 1142 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
1109 | NLP_EVT_CMPL_PRLI); | 1143 | NLP_EVT_CMPL_PRLI); |
1110 | } | ||
1111 | |||
1112 | out: | 1144 | out: |
1113 | lpfc_els_free_iocb(phba, cmdiocb); | 1145 | lpfc_els_free_iocb(phba, cmdiocb); |
1114 | return; | 1146 | return; |
@@ -1275,15 +1307,13 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
1275 | } | 1307 | } |
1276 | /* ADISC failed */ | 1308 | /* ADISC failed */ |
1277 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ | 1309 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
1278 | if (!lpfc_error_lost_link(irsp)) { | 1310 | if (!lpfc_error_lost_link(irsp)) |
1279 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, | 1311 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
1280 | NLP_EVT_CMPL_ADISC); | 1312 | NLP_EVT_CMPL_ADISC); |
1281 | } | 1313 | } else |
1282 | } else { | ||
1283 | /* Good status, call state machine */ | 1314 | /* Good status, call state machine */ |
1284 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, | 1315 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
1285 | NLP_EVT_CMPL_ADISC); | 1316 | NLP_EVT_CMPL_ADISC); |
1286 | } | ||
1287 | 1317 | ||
1288 | if (disc && vport->num_disc_nodes) { | 1318 | if (disc && vport->num_disc_nodes) { |
1289 | /* Check to see if there are more ADISCs to be sent */ | 1319 | /* Check to see if there are more ADISCs to be sent */ |
@@ -1443,14 +1473,12 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
1443 | else | 1473 | else |
1444 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, | 1474 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
1445 | NLP_EVT_CMPL_LOGO); | 1475 | NLP_EVT_CMPL_LOGO); |
1446 | } else { | 1476 | } else |
1447 | /* Good status, call state machine. | 1477 | /* Good status, call state machine. |
1448 | * This will unregister the rpi if needed. | 1478 | * This will unregister the rpi if needed. |
1449 | */ | 1479 | */ |
1450 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, | 1480 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
1451 | NLP_EVT_CMPL_LOGO); | 1481 | NLP_EVT_CMPL_LOGO); |
1452 | } | ||
1453 | |||
1454 | out: | 1482 | out: |
1455 | lpfc_els_free_iocb(phba, cmdiocb); | 1483 | lpfc_els_free_iocb(phba, cmdiocb); |
1456 | return; | 1484 | return; |
@@ -1556,11 +1584,19 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) | |||
1556 | psli = &phba->sli; | 1584 | psli = &phba->sli; |
1557 | pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ | 1585 | pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ |
1558 | cmdsize = (sizeof(uint32_t) + sizeof(SCR)); | 1586 | cmdsize = (sizeof(uint32_t) + sizeof(SCR)); |
1559 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); | ||
1560 | if (!ndlp) | ||
1561 | return 1; | ||
1562 | 1587 | ||
1563 | lpfc_nlp_init(vport, ndlp, nportid); | 1588 | ndlp = lpfc_findnode_did(vport, nportid); |
1589 | if (!ndlp) { | ||
1590 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); | ||
1591 | if (!ndlp) | ||
1592 | return 1; | ||
1593 | lpfc_nlp_init(vport, ndlp, nportid); | ||
1594 | lpfc_enqueue_node(vport, ndlp); | ||
1595 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
1596 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); | ||
1597 | if (!ndlp) | ||
1598 | return 1; | ||
1599 | } | ||
1564 | 1600 | ||
1565 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, | 1601 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
1566 | ndlp->nlp_DID, ELS_CMD_SCR); | 1602 | ndlp->nlp_DID, ELS_CMD_SCR); |
@@ -1623,11 +1659,19 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) | |||
1623 | psli = &phba->sli; | 1659 | psli = &phba->sli; |
1624 | pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ | 1660 | pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ |
1625 | cmdsize = (sizeof(uint32_t) + sizeof(FARP)); | 1661 | cmdsize = (sizeof(uint32_t) + sizeof(FARP)); |
1626 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); | ||
1627 | if (!ndlp) | ||
1628 | return 1; | ||
1629 | 1662 | ||
1630 | lpfc_nlp_init(vport, ndlp, nportid); | 1663 | ndlp = lpfc_findnode_did(vport, nportid); |
1664 | if (!ndlp) { | ||
1665 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); | ||
1666 | if (!ndlp) | ||
1667 | return 1; | ||
1668 | lpfc_nlp_init(vport, ndlp, nportid); | ||
1669 | lpfc_enqueue_node(vport, ndlp); | ||
1670 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
1671 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); | ||
1672 | if (!ndlp) | ||
1673 | return 1; | ||
1674 | } | ||
1631 | 1675 | ||
1632 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, | 1676 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
1633 | ndlp->nlp_DID, ELS_CMD_RNID); | 1677 | ndlp->nlp_DID, ELS_CMD_RNID); |
@@ -1657,7 +1701,7 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) | |||
1657 | memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name)); | 1701 | memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name)); |
1658 | memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); | 1702 | memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
1659 | ondlp = lpfc_findnode_did(vport, nportid); | 1703 | ondlp = lpfc_findnode_did(vport, nportid); |
1660 | if (ondlp) { | 1704 | if (ondlp && NLP_CHK_NODE_ACT(ondlp)) { |
1661 | memcpy(&fp->OportName, &ondlp->nlp_portname, | 1705 | memcpy(&fp->OportName, &ondlp->nlp_portname, |
1662 | sizeof(struct lpfc_name)); | 1706 | sizeof(struct lpfc_name)); |
1663 | memcpy(&fp->OnodeName, &ondlp->nlp_nodename, | 1707 | memcpy(&fp->OnodeName, &ondlp->nlp_nodename, |
@@ -1690,6 +1734,7 @@ void | |||
1690 | lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp) | 1734 | lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp) |
1691 | { | 1735 | { |
1692 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | 1736 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
1737 | struct lpfc_work_evt *evtp; | ||
1693 | 1738 | ||
1694 | spin_lock_irq(shost->host_lock); | 1739 | spin_lock_irq(shost->host_lock); |
1695 | nlp->nlp_flag &= ~NLP_DELAY_TMO; | 1740 | nlp->nlp_flag &= ~NLP_DELAY_TMO; |
@@ -1697,8 +1742,12 @@ lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp) | |||
1697 | del_timer_sync(&nlp->nlp_delayfunc); | 1742 | del_timer_sync(&nlp->nlp_delayfunc); |
1698 | nlp->nlp_last_elscmd = 0; | 1743 | nlp->nlp_last_elscmd = 0; |
1699 | 1744 | ||
1700 | if (!list_empty(&nlp->els_retry_evt.evt_listp)) | 1745 | if (!list_empty(&nlp->els_retry_evt.evt_listp)) { |
1701 | list_del_init(&nlp->els_retry_evt.evt_listp); | 1746 | list_del_init(&nlp->els_retry_evt.evt_listp); |
1747 | /* Decrement nlp reference count held for the delayed retry */ | ||
1748 | evtp = &nlp->els_retry_evt; | ||
1749 | lpfc_nlp_put((struct lpfc_nodelist *)evtp->evt_arg1); | ||
1750 | } | ||
1702 | 1751 | ||
1703 | if (nlp->nlp_flag & NLP_NPR_2B_DISC) { | 1752 | if (nlp->nlp_flag & NLP_NPR_2B_DISC) { |
1704 | spin_lock_irq(shost->host_lock); | 1753 | spin_lock_irq(shost->host_lock); |
@@ -1842,13 +1891,14 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
1842 | cmd = *elscmd++; | 1891 | cmd = *elscmd++; |
1843 | } | 1892 | } |
1844 | 1893 | ||
1845 | if (ndlp) | 1894 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
1846 | did = ndlp->nlp_DID; | 1895 | did = ndlp->nlp_DID; |
1847 | else { | 1896 | else { |
1848 | /* We should only hit this case for retrying PLOGI */ | 1897 | /* We should only hit this case for retrying PLOGI */ |
1849 | did = irsp->un.elsreq64.remoteID; | 1898 | did = irsp->un.elsreq64.remoteID; |
1850 | ndlp = lpfc_findnode_did(vport, did); | 1899 | ndlp = lpfc_findnode_did(vport, did); |
1851 | if (!ndlp && (cmd != ELS_CMD_PLOGI)) | 1900 | if ((!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
1901 | && (cmd != ELS_CMD_PLOGI)) | ||
1852 | return 1; | 1902 | return 1; |
1853 | } | 1903 | } |
1854 | 1904 | ||
@@ -1870,18 +1920,15 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
1870 | break; | 1920 | break; |
1871 | 1921 | ||
1872 | case IOERR_ILLEGAL_COMMAND: | 1922 | case IOERR_ILLEGAL_COMMAND: |
1873 | if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) && | 1923 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
1874 | (cmd == ELS_CMD_FDISC)) { | 1924 | "0124 Retry illegal cmd x%x " |
1875 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, | 1925 | "retry:x%x delay:x%x\n", |
1876 | "0124 FDISC failed (3/6) " | 1926 | cmd, cmdiocb->retry, delay); |
1877 | "retrying...\n"); | 1927 | retry = 1; |
1878 | lpfc_mbx_unreg_vpi(vport); | 1928 | /* All command's retry policy */ |
1879 | retry = 1; | 1929 | maxretry = 8; |
1880 | /* FDISC retry policy */ | 1930 | if (cmdiocb->retry > 2) |
1881 | maxretry = 48; | 1931 | delay = 1000; |
1882 | if (cmdiocb->retry >= 32) | ||
1883 | delay = 1000; | ||
1884 | } | ||
1885 | break; | 1932 | break; |
1886 | 1933 | ||
1887 | case IOERR_NO_RESOURCES: | 1934 | case IOERR_NO_RESOURCES: |
@@ -1967,6 +2014,17 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
1967 | break; | 2014 | break; |
1968 | 2015 | ||
1969 | case LSRJT_LOGICAL_ERR: | 2016 | case LSRJT_LOGICAL_ERR: |
2017 | /* There are some cases where switches return this | ||
2018 | * error when they are not ready and should be returning | ||
2019 | * Logical Busy. We should delay every time. | ||
2020 | */ | ||
2021 | if (cmd == ELS_CMD_FDISC && | ||
2022 | stat.un.b.lsRjtRsnCodeExp == LSEXP_PORT_LOGIN_REQ) { | ||
2023 | maxretry = 3; | ||
2024 | delay = 1000; | ||
2025 | retry = 1; | ||
2026 | break; | ||
2027 | } | ||
1970 | case LSRJT_PROTOCOL_ERR: | 2028 | case LSRJT_PROTOCOL_ERR: |
1971 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && | 2029 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
1972 | (cmd == ELS_CMD_FDISC) && | 2030 | (cmd == ELS_CMD_FDISC) && |
@@ -1996,7 +2054,8 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
1996 | retry = 1; | 2054 | retry = 1; |
1997 | 2055 | ||
1998 | if ((cmd == ELS_CMD_FLOGI) && | 2056 | if ((cmd == ELS_CMD_FLOGI) && |
1999 | (phba->fc_topology != TOPOLOGY_LOOP)) { | 2057 | (phba->fc_topology != TOPOLOGY_LOOP) && |
2058 | !lpfc_error_lost_link(irsp)) { | ||
2000 | /* FLOGI retry policy */ | 2059 | /* FLOGI retry policy */ |
2001 | retry = 1; | 2060 | retry = 1; |
2002 | maxretry = 48; | 2061 | maxretry = 48; |
@@ -2322,6 +2381,9 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
2322 | if ((rspiocb->iocb.ulpStatus == 0) | 2381 | if ((rspiocb->iocb.ulpStatus == 0) |
2323 | && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { | 2382 | && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { |
2324 | lpfc_unreg_rpi(vport, ndlp); | 2383 | lpfc_unreg_rpi(vport, ndlp); |
2384 | /* Increment reference count to ndlp to hold the | ||
2385 | * reference to ndlp for the callback function. | ||
2386 | */ | ||
2325 | mbox->context2 = lpfc_nlp_get(ndlp); | 2387 | mbox->context2 = lpfc_nlp_get(ndlp); |
2326 | mbox->vport = vport; | 2388 | mbox->vport = vport; |
2327 | if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) { | 2389 | if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) { |
@@ -2335,9 +2397,13 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
2335 | NLP_STE_REG_LOGIN_ISSUE); | 2397 | NLP_STE_REG_LOGIN_ISSUE); |
2336 | } | 2398 | } |
2337 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) | 2399 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
2338 | != MBX_NOT_FINISHED) { | 2400 | != MBX_NOT_FINISHED) |
2339 | goto out; | 2401 | goto out; |
2340 | } | 2402 | else |
2403 | /* Decrement the ndlp reference count we | ||
2404 | * set for this failed mailbox command. | ||
2405 | */ | ||
2406 | lpfc_nlp_put(ndlp); | ||
2341 | 2407 | ||
2342 | /* ELS rsp: Cannot issue reg_login for <NPortid> */ | 2408 | /* ELS rsp: Cannot issue reg_login for <NPortid> */ |
2343 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, | 2409 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
@@ -2796,6 +2862,8 @@ lpfc_els_disc_adisc(struct lpfc_vport *vport) | |||
2796 | 2862 | ||
2797 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ | 2863 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ |
2798 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | 2864 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
2865 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
2866 | continue; | ||
2799 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && | 2867 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
2800 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && | 2868 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
2801 | (ndlp->nlp_flag & NLP_NPR_ADISC) != 0) { | 2869 | (ndlp->nlp_flag & NLP_NPR_ADISC) != 0) { |
@@ -2833,6 +2901,8 @@ lpfc_els_disc_plogi(struct lpfc_vport *vport) | |||
2833 | 2901 | ||
2834 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ | 2902 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ |
2835 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | 2903 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
2904 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
2905 | continue; | ||
2836 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && | 2906 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
2837 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && | 2907 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
2838 | (ndlp->nlp_flag & NLP_DELAY_TMO) == 0 && | 2908 | (ndlp->nlp_flag & NLP_DELAY_TMO) == 0 && |
@@ -2869,6 +2939,16 @@ lpfc_els_flush_rscn(struct lpfc_vport *vport) | |||
2869 | struct lpfc_hba *phba = vport->phba; | 2939 | struct lpfc_hba *phba = vport->phba; |
2870 | int i; | 2940 | int i; |
2871 | 2941 | ||
2942 | spin_lock_irq(shost->host_lock); | ||
2943 | if (vport->fc_rscn_flush) { | ||
2944 | /* Another thread is walking fc_rscn_id_list on this vport */ | ||
2945 | spin_unlock_irq(shost->host_lock); | ||
2946 | return; | ||
2947 | } | ||
2948 | /* Indicate we are walking lpfc_els_flush_rscn on this vport */ | ||
2949 | vport->fc_rscn_flush = 1; | ||
2950 | spin_unlock_irq(shost->host_lock); | ||
2951 | |||
2872 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { | 2952 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
2873 | lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]); | 2953 | lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]); |
2874 | vport->fc_rscn_id_list[i] = NULL; | 2954 | vport->fc_rscn_id_list[i] = NULL; |
@@ -2878,6 +2958,8 @@ lpfc_els_flush_rscn(struct lpfc_vport *vport) | |||
2878 | vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY); | 2958 | vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY); |
2879 | spin_unlock_irq(shost->host_lock); | 2959 | spin_unlock_irq(shost->host_lock); |
2880 | lpfc_can_disctmo(vport); | 2960 | lpfc_can_disctmo(vport); |
2961 | /* Indicate we are done walking this fc_rscn_id_list */ | ||
2962 | vport->fc_rscn_flush = 0; | ||
2881 | } | 2963 | } |
2882 | 2964 | ||
2883 | int | 2965 | int |
@@ -2887,6 +2969,7 @@ lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did) | |||
2887 | D_ID rscn_did; | 2969 | D_ID rscn_did; |
2888 | uint32_t *lp; | 2970 | uint32_t *lp; |
2889 | uint32_t payload_len, i; | 2971 | uint32_t payload_len, i; |
2972 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | ||
2890 | 2973 | ||
2891 | ns_did.un.word = did; | 2974 | ns_did.un.word = did; |
2892 | 2975 | ||
@@ -2898,6 +2981,15 @@ lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did) | |||
2898 | if (vport->fc_flag & FC_RSCN_DISCOVERY) | 2981 | if (vport->fc_flag & FC_RSCN_DISCOVERY) |
2899 | return did; | 2982 | return did; |
2900 | 2983 | ||
2984 | spin_lock_irq(shost->host_lock); | ||
2985 | if (vport->fc_rscn_flush) { | ||
2986 | /* Another thread is walking fc_rscn_id_list on this vport */ | ||
2987 | spin_unlock_irq(shost->host_lock); | ||
2988 | return 0; | ||
2989 | } | ||
2990 | /* Indicate we are walking fc_rscn_id_list on this vport */ | ||
2991 | vport->fc_rscn_flush = 1; | ||
2992 | spin_unlock_irq(shost->host_lock); | ||
2901 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { | 2993 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
2902 | lp = vport->fc_rscn_id_list[i]->virt; | 2994 | lp = vport->fc_rscn_id_list[i]->virt; |
2903 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); | 2995 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); |
@@ -2908,16 +3000,16 @@ lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did) | |||
2908 | switch (rscn_did.un.b.resv) { | 3000 | switch (rscn_did.un.b.resv) { |
2909 | case 0: /* Single N_Port ID effected */ | 3001 | case 0: /* Single N_Port ID effected */ |
2910 | if (ns_did.un.word == rscn_did.un.word) | 3002 | if (ns_did.un.word == rscn_did.un.word) |
2911 | return did; | 3003 | goto return_did_out; |
2912 | break; | 3004 | break; |
2913 | case 1: /* Whole N_Port Area effected */ | 3005 | case 1: /* Whole N_Port Area effected */ |
2914 | if ((ns_did.un.b.domain == rscn_did.un.b.domain) | 3006 | if ((ns_did.un.b.domain == rscn_did.un.b.domain) |
2915 | && (ns_did.un.b.area == rscn_did.un.b.area)) | 3007 | && (ns_did.un.b.area == rscn_did.un.b.area)) |
2916 | return did; | 3008 | goto return_did_out; |
2917 | break; | 3009 | break; |
2918 | case 2: /* Whole N_Port Domain effected */ | 3010 | case 2: /* Whole N_Port Domain effected */ |
2919 | if (ns_did.un.b.domain == rscn_did.un.b.domain) | 3011 | if (ns_did.un.b.domain == rscn_did.un.b.domain) |
2920 | return did; | 3012 | goto return_did_out; |
2921 | break; | 3013 | break; |
2922 | default: | 3014 | default: |
2923 | /* Unknown Identifier in RSCN node */ | 3015 | /* Unknown Identifier in RSCN node */ |
@@ -2926,11 +3018,17 @@ lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did) | |||
2926 | "RSCN payload Data: x%x\n", | 3018 | "RSCN payload Data: x%x\n", |
2927 | rscn_did.un.word); | 3019 | rscn_did.un.word); |
2928 | case 3: /* Whole Fabric effected */ | 3020 | case 3: /* Whole Fabric effected */ |
2929 | return did; | 3021 | goto return_did_out; |
2930 | } | 3022 | } |
2931 | } | 3023 | } |
2932 | } | 3024 | } |
3025 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ | ||
3026 | vport->fc_rscn_flush = 0; | ||
2933 | return 0; | 3027 | return 0; |
3028 | return_did_out: | ||
3029 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ | ||
3030 | vport->fc_rscn_flush = 0; | ||
3031 | return did; | ||
2934 | } | 3032 | } |
2935 | 3033 | ||
2936 | static int | 3034 | static int |
@@ -2943,7 +3041,8 @@ lpfc_rscn_recovery_check(struct lpfc_vport *vport) | |||
2943 | */ | 3041 | */ |
2944 | 3042 | ||
2945 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { | 3043 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
2946 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE || | 3044 | if (!NLP_CHK_NODE_ACT(ndlp) || |
3045 | ndlp->nlp_state == NLP_STE_UNUSED_NODE || | ||
2947 | lpfc_rscn_payload_check(vport, ndlp->nlp_DID) == 0) | 3046 | lpfc_rscn_payload_check(vport, ndlp->nlp_DID) == 0) |
2948 | continue; | 3047 | continue; |
2949 | 3048 | ||
@@ -2971,7 +3070,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
2971 | uint32_t *lp, *datap; | 3070 | uint32_t *lp, *datap; |
2972 | IOCB_t *icmd; | 3071 | IOCB_t *icmd; |
2973 | uint32_t payload_len, length, nportid, *cmd; | 3072 | uint32_t payload_len, length, nportid, *cmd; |
2974 | int rscn_cnt = vport->fc_rscn_id_cnt; | 3073 | int rscn_cnt; |
2975 | int rscn_id = 0, hba_id = 0; | 3074 | int rscn_id = 0, hba_id = 0; |
2976 | int i; | 3075 | int i; |
2977 | 3076 | ||
@@ -2984,7 +3083,8 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
2984 | /* RSCN received */ | 3083 | /* RSCN received */ |
2985 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | 3084 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
2986 | "0214 RSCN received Data: x%x x%x x%x x%x\n", | 3085 | "0214 RSCN received Data: x%x x%x x%x x%x\n", |
2987 | vport->fc_flag, payload_len, *lp, rscn_cnt); | 3086 | vport->fc_flag, payload_len, *lp, |
3087 | vport->fc_rscn_id_cnt); | ||
2988 | for (i = 0; i < payload_len/sizeof(uint32_t); i++) | 3088 | for (i = 0; i < payload_len/sizeof(uint32_t); i++) |
2989 | fc_host_post_event(shost, fc_get_event_number(), | 3089 | fc_host_post_event(shost, fc_get_event_number(), |
2990 | FCH_EVT_RSCN, lp[i]); | 3090 | FCH_EVT_RSCN, lp[i]); |
@@ -3022,7 +3122,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
3022 | "0214 Ignore RSCN " | 3122 | "0214 Ignore RSCN " |
3023 | "Data: x%x x%x x%x x%x\n", | 3123 | "Data: x%x x%x x%x x%x\n", |
3024 | vport->fc_flag, payload_len, | 3124 | vport->fc_flag, payload_len, |
3025 | *lp, rscn_cnt); | 3125 | *lp, vport->fc_rscn_id_cnt); |
3026 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, | 3126 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
3027 | "RCV RSCN vport: did:x%x/ste:x%x flg:x%x", | 3127 | "RCV RSCN vport: did:x%x/ste:x%x flg:x%x", |
3028 | ndlp->nlp_DID, vport->port_state, | 3128 | ndlp->nlp_DID, vport->port_state, |
@@ -3034,6 +3134,18 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
3034 | } | 3134 | } |
3035 | } | 3135 | } |
3036 | 3136 | ||
3137 | spin_lock_irq(shost->host_lock); | ||
3138 | if (vport->fc_rscn_flush) { | ||
3139 | /* Another thread is walking fc_rscn_id_list on this vport */ | ||
3140 | spin_unlock_irq(shost->host_lock); | ||
3141 | vport->fc_flag |= FC_RSCN_DISCOVERY; | ||
3142 | return 0; | ||
3143 | } | ||
3144 | /* Indicate we are walking fc_rscn_id_list on this vport */ | ||
3145 | vport->fc_rscn_flush = 1; | ||
3146 | spin_unlock_irq(shost->host_lock); | ||
3147 | /* Get the array count after sucessfully have the token */ | ||
3148 | rscn_cnt = vport->fc_rscn_id_cnt; | ||
3037 | /* If we are already processing an RSCN, save the received | 3149 | /* If we are already processing an RSCN, save the received |
3038 | * RSCN payload buffer, cmdiocb->context2 to process later. | 3150 | * RSCN payload buffer, cmdiocb->context2 to process later. |
3039 | */ | 3151 | */ |
@@ -3055,7 +3167,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
3055 | if ((rscn_cnt) && | 3167 | if ((rscn_cnt) && |
3056 | (payload_len + length <= LPFC_BPL_SIZE)) { | 3168 | (payload_len + length <= LPFC_BPL_SIZE)) { |
3057 | *cmd &= ELS_CMD_MASK; | 3169 | *cmd &= ELS_CMD_MASK; |
3058 | *cmd |= be32_to_cpu(payload_len + length); | 3170 | *cmd |= cpu_to_be32(payload_len + length); |
3059 | memcpy(((uint8_t *)cmd) + length, lp, | 3171 | memcpy(((uint8_t *)cmd) + length, lp, |
3060 | payload_len); | 3172 | payload_len); |
3061 | } else { | 3173 | } else { |
@@ -3066,7 +3178,6 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
3066 | */ | 3178 | */ |
3067 | cmdiocb->context2 = NULL; | 3179 | cmdiocb->context2 = NULL; |
3068 | } | 3180 | } |
3069 | |||
3070 | /* Deferred RSCN */ | 3181 | /* Deferred RSCN */ |
3071 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | 3182 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
3072 | "0235 Deferred RSCN " | 3183 | "0235 Deferred RSCN " |
@@ -3083,9 +3194,10 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
3083 | vport->fc_rscn_id_cnt, vport->fc_flag, | 3194 | vport->fc_rscn_id_cnt, vport->fc_flag, |
3084 | vport->port_state); | 3195 | vport->port_state); |
3085 | } | 3196 | } |
3197 | /* Indicate we are done walking fc_rscn_id_list on this vport */ | ||
3198 | vport->fc_rscn_flush = 0; | ||
3086 | /* Send back ACC */ | 3199 | /* Send back ACC */ |
3087 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); | 3200 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
3088 | |||
3089 | /* send RECOVERY event for ALL nodes that match RSCN payload */ | 3201 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
3090 | lpfc_rscn_recovery_check(vport); | 3202 | lpfc_rscn_recovery_check(vport); |
3091 | spin_lock_irq(shost->host_lock); | 3203 | spin_lock_irq(shost->host_lock); |
@@ -3093,7 +3205,6 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
3093 | spin_unlock_irq(shost->host_lock); | 3205 | spin_unlock_irq(shost->host_lock); |
3094 | return 0; | 3206 | return 0; |
3095 | } | 3207 | } |
3096 | |||
3097 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, | 3208 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
3098 | "RCV RSCN: did:x%x/ste:x%x flg:x%x", | 3209 | "RCV RSCN: did:x%x/ste:x%x flg:x%x", |
3099 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); | 3210 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
@@ -3102,20 +3213,18 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
3102 | vport->fc_flag |= FC_RSCN_MODE; | 3213 | vport->fc_flag |= FC_RSCN_MODE; |
3103 | spin_unlock_irq(shost->host_lock); | 3214 | spin_unlock_irq(shost->host_lock); |
3104 | vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd; | 3215 | vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd; |
3216 | /* Indicate we are done walking fc_rscn_id_list on this vport */ | ||
3217 | vport->fc_rscn_flush = 0; | ||
3105 | /* | 3218 | /* |
3106 | * If we zero, cmdiocb->context2, the calling routine will | 3219 | * If we zero, cmdiocb->context2, the calling routine will |
3107 | * not try to free it. | 3220 | * not try to free it. |
3108 | */ | 3221 | */ |
3109 | cmdiocb->context2 = NULL; | 3222 | cmdiocb->context2 = NULL; |
3110 | |||
3111 | lpfc_set_disctmo(vport); | 3223 | lpfc_set_disctmo(vport); |
3112 | |||
3113 | /* Send back ACC */ | 3224 | /* Send back ACC */ |
3114 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); | 3225 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
3115 | |||
3116 | /* send RECOVERY event for ALL nodes that match RSCN payload */ | 3226 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
3117 | lpfc_rscn_recovery_check(vport); | 3227 | lpfc_rscn_recovery_check(vport); |
3118 | |||
3119 | return lpfc_els_handle_rscn(vport); | 3228 | return lpfc_els_handle_rscn(vport); |
3120 | } | 3229 | } |
3121 | 3230 | ||
@@ -3145,7 +3254,8 @@ lpfc_els_handle_rscn(struct lpfc_vport *vport) | |||
3145 | vport->num_disc_nodes = 0; | 3254 | vport->num_disc_nodes = 0; |
3146 | 3255 | ||
3147 | ndlp = lpfc_findnode_did(vport, NameServer_DID); | 3256 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
3148 | if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { | 3257 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) |
3258 | && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { | ||
3149 | /* Good ndlp, issue CT Request to NameServer */ | 3259 | /* Good ndlp, issue CT Request to NameServer */ |
3150 | if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, 0) == 0) | 3260 | if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, 0) == 0) |
3151 | /* Wait for NameServer query cmpl before we can | 3261 | /* Wait for NameServer query cmpl before we can |
@@ -3155,25 +3265,35 @@ lpfc_els_handle_rscn(struct lpfc_vport *vport) | |||
3155 | /* If login to NameServer does not exist, issue one */ | 3265 | /* If login to NameServer does not exist, issue one */ |
3156 | /* Good status, issue PLOGI to NameServer */ | 3266 | /* Good status, issue PLOGI to NameServer */ |
3157 | ndlp = lpfc_findnode_did(vport, NameServer_DID); | 3267 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
3158 | if (ndlp) | 3268 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
3159 | /* Wait for NameServer login cmpl before we can | 3269 | /* Wait for NameServer login cmpl before we can |
3160 | continue */ | 3270 | continue */ |
3161 | return 1; | 3271 | return 1; |
3162 | 3272 | ||
3163 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); | 3273 | if (ndlp) { |
3164 | if (!ndlp) { | 3274 | ndlp = lpfc_enable_node(vport, ndlp, |
3165 | lpfc_els_flush_rscn(vport); | 3275 | NLP_STE_PLOGI_ISSUE); |
3166 | return 0; | 3276 | if (!ndlp) { |
3277 | lpfc_els_flush_rscn(vport); | ||
3278 | return 0; | ||
3279 | } | ||
3280 | ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; | ||
3167 | } else { | 3281 | } else { |
3282 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); | ||
3283 | if (!ndlp) { | ||
3284 | lpfc_els_flush_rscn(vport); | ||
3285 | return 0; | ||
3286 | } | ||
3168 | lpfc_nlp_init(vport, ndlp, NameServer_DID); | 3287 | lpfc_nlp_init(vport, ndlp, NameServer_DID); |
3169 | ndlp->nlp_type |= NLP_FABRIC; | ||
3170 | ndlp->nlp_prev_state = ndlp->nlp_state; | 3288 | ndlp->nlp_prev_state = ndlp->nlp_state; |
3171 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); | 3289 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
3172 | lpfc_issue_els_plogi(vport, NameServer_DID, 0); | ||
3173 | /* Wait for NameServer login cmpl before we can | ||
3174 | continue */ | ||
3175 | return 1; | ||
3176 | } | 3290 | } |
3291 | ndlp->nlp_type |= NLP_FABRIC; | ||
3292 | lpfc_issue_els_plogi(vport, NameServer_DID, 0); | ||
3293 | /* Wait for NameServer login cmpl before we can | ||
3294 | * continue | ||
3295 | */ | ||
3296 | return 1; | ||
3177 | } | 3297 | } |
3178 | 3298 | ||
3179 | lpfc_els_flush_rscn(vport); | 3299 | lpfc_els_flush_rscn(vport); |
@@ -3672,6 +3792,8 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
3672 | 3792 | ||
3673 | list_for_each_entry_safe(ndlp, next_ndlp, | 3793 | list_for_each_entry_safe(ndlp, next_ndlp, |
3674 | &vport->fc_nodes, nlp_listp) { | 3794 | &vport->fc_nodes, nlp_listp) { |
3795 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
3796 | continue; | ||
3675 | if (ndlp->nlp_state != NLP_STE_NPR_NODE) | 3797 | if (ndlp->nlp_state != NLP_STE_NPR_NODE) |
3676 | continue; | 3798 | continue; |
3677 | if (ndlp->nlp_type & NLP_FABRIC) { | 3799 | if (ndlp->nlp_type & NLP_FABRIC) { |
@@ -3697,6 +3819,8 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
3697 | */ | 3819 | */ |
3698 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, | 3820 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, |
3699 | nlp_listp) { | 3821 | nlp_listp) { |
3822 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
3823 | continue; | ||
3700 | if (ndlp->nlp_state != NLP_STE_NPR_NODE) | 3824 | if (ndlp->nlp_state != NLP_STE_NPR_NODE) |
3701 | continue; | 3825 | continue; |
3702 | 3826 | ||
@@ -3936,7 +4060,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3936 | uint32_t cmd, did, newnode, rjt_err = 0; | 4060 | uint32_t cmd, did, newnode, rjt_err = 0; |
3937 | IOCB_t *icmd = &elsiocb->iocb; | 4061 | IOCB_t *icmd = &elsiocb->iocb; |
3938 | 4062 | ||
3939 | if (vport == NULL || elsiocb->context2 == NULL) | 4063 | if (!vport || !(elsiocb->context2)) |
3940 | goto dropit; | 4064 | goto dropit; |
3941 | 4065 | ||
3942 | newnode = 0; | 4066 | newnode = 0; |
@@ -3971,14 +4095,20 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3971 | lpfc_nlp_init(vport, ndlp, did); | 4095 | lpfc_nlp_init(vport, ndlp, did); |
3972 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | 4096 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
3973 | newnode = 1; | 4097 | newnode = 1; |
3974 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) { | 4098 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
3975 | ndlp->nlp_type |= NLP_FABRIC; | 4099 | ndlp->nlp_type |= NLP_FABRIC; |
4100 | } else { | ||
4101 | if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
4102 | ndlp = lpfc_enable_node(vport, ndlp, | ||
4103 | NLP_STE_UNUSED_NODE); | ||
4104 | if (!ndlp) | ||
4105 | goto dropit; | ||
3976 | } | 4106 | } |
3977 | } | ||
3978 | else { | ||
3979 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) { | 4107 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) { |
3980 | /* This is simular to the new node path */ | 4108 | /* This is simular to the new node path */ |
3981 | lpfc_nlp_get(ndlp); | 4109 | ndlp = lpfc_nlp_get(ndlp); |
4110 | if (!ndlp) | ||
4111 | goto dropit; | ||
3982 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | 4112 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
3983 | newnode = 1; | 4113 | newnode = 1; |
3984 | } | 4114 | } |
@@ -3987,6 +4117,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3987 | phba->fc_stat.elsRcvFrame++; | 4117 | phba->fc_stat.elsRcvFrame++; |
3988 | if (elsiocb->context1) | 4118 | if (elsiocb->context1) |
3989 | lpfc_nlp_put(elsiocb->context1); | 4119 | lpfc_nlp_put(elsiocb->context1); |
4120 | |||
3990 | elsiocb->context1 = lpfc_nlp_get(ndlp); | 4121 | elsiocb->context1 = lpfc_nlp_get(ndlp); |
3991 | elsiocb->vport = vport; | 4122 | elsiocb->vport = vport; |
3992 | 4123 | ||
@@ -4007,8 +4138,15 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
4007 | ndlp = lpfc_plogi_confirm_nport(phba, payload, ndlp); | 4138 | ndlp = lpfc_plogi_confirm_nport(phba, payload, ndlp); |
4008 | 4139 | ||
4009 | if (vport->port_state < LPFC_DISC_AUTH) { | 4140 | if (vport->port_state < LPFC_DISC_AUTH) { |
4010 | rjt_err = LSRJT_UNABLE_TPC; | 4141 | if (!(phba->pport->fc_flag & FC_PT2PT) || |
4011 | break; | 4142 | (phba->pport->fc_flag & FC_PT2PT_PLOGI)) { |
4143 | rjt_err = LSRJT_UNABLE_TPC; | ||
4144 | break; | ||
4145 | } | ||
4146 | /* We get here, and drop thru, if we are PT2PT with | ||
4147 | * another NPort and the other side has initiated | ||
4148 | * the PLOGI before responding to our FLOGI. | ||
4149 | */ | ||
4012 | } | 4150 | } |
4013 | 4151 | ||
4014 | shost = lpfc_shost_from_vport(vport); | 4152 | shost = lpfc_shost_from_vport(vport); |
@@ -4251,15 +4389,15 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
4251 | vport = lpfc_find_vport_by_vpid(phba, vpi); | 4389 | vport = lpfc_find_vport_by_vpid(phba, vpi); |
4252 | } | 4390 | } |
4253 | } | 4391 | } |
4254 | /* If there are no BDEs associated | 4392 | /* If there are no BDEs associated |
4255 | * with this IOCB, there is nothing to do. | 4393 | * with this IOCB, there is nothing to do. |
4256 | */ | 4394 | */ |
4257 | if (icmd->ulpBdeCount == 0) | 4395 | if (icmd->ulpBdeCount == 0) |
4258 | return; | 4396 | return; |
4259 | 4397 | ||
4260 | /* type of ELS cmd is first 32bit word | 4398 | /* type of ELS cmd is first 32bit word |
4261 | * in packet | 4399 | * in packet |
4262 | */ | 4400 | */ |
4263 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { | 4401 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
4264 | elsiocb->context2 = bdeBuf1; | 4402 | elsiocb->context2 = bdeBuf1; |
4265 | } else { | 4403 | } else { |
@@ -4314,6 +4452,18 @@ lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport) | |||
4314 | } | 4452 | } |
4315 | lpfc_nlp_init(vport, ndlp, NameServer_DID); | 4453 | lpfc_nlp_init(vport, ndlp, NameServer_DID); |
4316 | ndlp->nlp_type |= NLP_FABRIC; | 4454 | ndlp->nlp_type |= NLP_FABRIC; |
4455 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
4456 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); | ||
4457 | if (!ndlp) { | ||
4458 | if (phba->fc_topology == TOPOLOGY_LOOP) { | ||
4459 | lpfc_disc_start(vport); | ||
4460 | return; | ||
4461 | } | ||
4462 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); | ||
4463 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, | ||
4464 | "0348 NameServer login: node freed\n"); | ||
4465 | return; | ||
4466 | } | ||
4317 | } | 4467 | } |
4318 | 4468 | ||
4319 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); | 4469 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
@@ -4360,6 +4510,7 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
4360 | switch (mb->mbxStatus) { | 4510 | switch (mb->mbxStatus) { |
4361 | case 0x11: /* unsupported feature */ | 4511 | case 0x11: /* unsupported feature */ |
4362 | case 0x9603: /* max_vpi exceeded */ | 4512 | case 0x9603: /* max_vpi exceeded */ |
4513 | case 0x9602: /* Link event since CLEAR_LA */ | ||
4363 | /* giving up on vport registration */ | 4514 | /* giving up on vport registration */ |
4364 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); | 4515 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
4365 | spin_lock_irq(shost->host_lock); | 4516 | spin_lock_irq(shost->host_lock); |
@@ -4373,7 +4524,10 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
4373 | spin_lock_irq(shost->host_lock); | 4524 | spin_lock_irq(shost->host_lock); |
4374 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | 4525 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
4375 | spin_unlock_irq(shost->host_lock); | 4526 | spin_unlock_irq(shost->host_lock); |
4376 | lpfc_initial_fdisc(vport); | 4527 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
4528 | lpfc_initial_flogi(vport); | ||
4529 | else | ||
4530 | lpfc_initial_fdisc(vport); | ||
4377 | break; | 4531 | break; |
4378 | } | 4532 | } |
4379 | 4533 | ||
@@ -4471,7 +4625,6 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
4471 | irsp->ulpStatus, irsp->un.ulpWord[4]); | 4625 | irsp->ulpStatus, irsp->un.ulpWord[4]); |
4472 | if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING) | 4626 | if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING) |
4473 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); | 4627 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
4474 | |||
4475 | lpfc_nlp_put(ndlp); | 4628 | lpfc_nlp_put(ndlp); |
4476 | /* giving up on FDISC. Cancel discovery timer */ | 4629 | /* giving up on FDISC. Cancel discovery timer */ |
4477 | lpfc_can_disctmo(vport); | 4630 | lpfc_can_disctmo(vport); |
@@ -4492,8 +4645,9 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
4492 | */ | 4645 | */ |
4493 | list_for_each_entry_safe(np, next_np, | 4646 | list_for_each_entry_safe(np, next_np, |
4494 | &vport->fc_nodes, nlp_listp) { | 4647 | &vport->fc_nodes, nlp_listp) { |
4495 | if (np->nlp_state != NLP_STE_NPR_NODE | 4648 | if (!NLP_CHK_NODE_ACT(ndlp) || |
4496 | || !(np->nlp_flag & NLP_NPR_ADISC)) | 4649 | (np->nlp_state != NLP_STE_NPR_NODE) || |
4650 | !(np->nlp_flag & NLP_NPR_ADISC)) | ||
4497 | continue; | 4651 | continue; |
4498 | spin_lock_irq(shost->host_lock); | 4652 | spin_lock_irq(shost->host_lock); |
4499 | np->nlp_flag &= ~NLP_NPR_ADISC; | 4653 | np->nlp_flag &= ~NLP_NPR_ADISC; |
@@ -4599,6 +4753,8 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
4599 | { | 4753 | { |
4600 | struct lpfc_vport *vport = cmdiocb->vport; | 4754 | struct lpfc_vport *vport = cmdiocb->vport; |
4601 | IOCB_t *irsp; | 4755 | IOCB_t *irsp; |
4756 | struct lpfc_nodelist *ndlp; | ||
4757 | ndlp = (struct lpfc_nodelist *)cmdiocb->context1; | ||
4602 | 4758 | ||
4603 | irsp = &rspiocb->iocb; | 4759 | irsp = &rspiocb->iocb; |
4604 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, | 4760 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
@@ -4607,6 +4763,9 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
4607 | 4763 | ||
4608 | lpfc_els_free_iocb(phba, cmdiocb); | 4764 | lpfc_els_free_iocb(phba, cmdiocb); |
4609 | vport->unreg_vpi_cmpl = VPORT_ERROR; | 4765 | vport->unreg_vpi_cmpl = VPORT_ERROR; |
4766 | |||
4767 | /* Trigger the release of the ndlp after logo */ | ||
4768 | lpfc_nlp_put(ndlp); | ||
4610 | } | 4769 | } |
4611 | 4770 | ||
4612 | int | 4771 | int |
@@ -4686,11 +4845,12 @@ lpfc_resume_fabric_iocbs(struct lpfc_hba *phba) | |||
4686 | repeat: | 4845 | repeat: |
4687 | iocb = NULL; | 4846 | iocb = NULL; |
4688 | spin_lock_irqsave(&phba->hbalock, iflags); | 4847 | spin_lock_irqsave(&phba->hbalock, iflags); |
4689 | /* Post any pending iocb to the SLI layer */ | 4848 | /* Post any pending iocb to the SLI layer */ |
4690 | if (atomic_read(&phba->fabric_iocb_count) == 0) { | 4849 | if (atomic_read(&phba->fabric_iocb_count) == 0) { |
4691 | list_remove_head(&phba->fabric_iocb_list, iocb, typeof(*iocb), | 4850 | list_remove_head(&phba->fabric_iocb_list, iocb, typeof(*iocb), |
4692 | list); | 4851 | list); |
4693 | if (iocb) | 4852 | if (iocb) |
4853 | /* Increment fabric iocb count to hold the position */ | ||
4694 | atomic_inc(&phba->fabric_iocb_count); | 4854 | atomic_inc(&phba->fabric_iocb_count); |
4695 | } | 4855 | } |
4696 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 4856 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
@@ -4737,9 +4897,7 @@ lpfc_block_fabric_iocbs(struct lpfc_hba *phba) | |||
4737 | int blocked; | 4897 | int blocked; |
4738 | 4898 | ||
4739 | blocked = test_and_set_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); | 4899 | blocked = test_and_set_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
4740 | /* Start a timer to unblock fabric | 4900 | /* Start a timer to unblock fabric iocbs after 100ms */ |
4741 | * iocbs after 100ms | ||
4742 | */ | ||
4743 | if (!blocked) | 4901 | if (!blocked) |
4744 | mod_timer(&phba->fabric_block_timer, jiffies + HZ/10 ); | 4902 | mod_timer(&phba->fabric_block_timer, jiffies + HZ/10 ); |
4745 | 4903 | ||
@@ -4787,8 +4945,8 @@ lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
4787 | 4945 | ||
4788 | atomic_dec(&phba->fabric_iocb_count); | 4946 | atomic_dec(&phba->fabric_iocb_count); |
4789 | if (!test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags)) { | 4947 | if (!test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags)) { |
4790 | /* Post any pending iocbs to HBA */ | 4948 | /* Post any pending iocbs to HBA */ |
4791 | lpfc_resume_fabric_iocbs(phba); | 4949 | lpfc_resume_fabric_iocbs(phba); |
4792 | } | 4950 | } |
4793 | } | 4951 | } |
4794 | 4952 | ||
@@ -4807,6 +4965,9 @@ lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) | |||
4807 | ready = atomic_read(&phba->fabric_iocb_count) == 0 && | 4965 | ready = atomic_read(&phba->fabric_iocb_count) == 0 && |
4808 | !test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); | 4966 | !test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
4809 | 4967 | ||
4968 | if (ready) | ||
4969 | /* Increment fabric iocb count to hold the position */ | ||
4970 | atomic_inc(&phba->fabric_iocb_count); | ||
4810 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 4971 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
4811 | if (ready) { | 4972 | if (ready) { |
4812 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; | 4973 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; |
@@ -4817,7 +4978,6 @@ lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) | |||
4817 | "Fabric sched2: ste:x%x", | 4978 | "Fabric sched2: ste:x%x", |
4818 | iocb->vport->port_state, 0, 0); | 4979 | iocb->vport->port_state, 0, 0); |
4819 | 4980 | ||
4820 | atomic_inc(&phba->fabric_iocb_count); | ||
4821 | ret = lpfc_sli_issue_iocb(phba, pring, iocb, 0); | 4981 | ret = lpfc_sli_issue_iocb(phba, pring, iocb, 0); |
4822 | 4982 | ||
4823 | if (ret == IOCB_ERROR) { | 4983 | if (ret == IOCB_ERROR) { |
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index dc042bd97baa..976653440fba 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -272,9 +272,8 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) | |||
272 | if (!(vport->load_flag & FC_UNLOADING) && | 272 | if (!(vport->load_flag & FC_UNLOADING) && |
273 | !(ndlp->nlp_flag & NLP_DELAY_TMO) && | 273 | !(ndlp->nlp_flag & NLP_DELAY_TMO) && |
274 | !(ndlp->nlp_flag & NLP_NPR_2B_DISC) && | 274 | !(ndlp->nlp_flag & NLP_NPR_2B_DISC) && |
275 | (ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)) { | 275 | (ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)) |
276 | lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM); | 276 | lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM); |
277 | } | ||
278 | } | 277 | } |
279 | 278 | ||
280 | 279 | ||
@@ -566,9 +565,10 @@ lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove) | |||
566 | int rc; | 565 | int rc; |
567 | 566 | ||
568 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | 567 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
568 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
569 | continue; | ||
569 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) | 570 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
570 | continue; | 571 | continue; |
571 | |||
572 | if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) || | 572 | if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) || |
573 | ((vport->port_type == LPFC_NPIV_PORT) && | 573 | ((vport->port_type == LPFC_NPIV_PORT) && |
574 | (ndlp->nlp_DID == NameServer_DID))) | 574 | (ndlp->nlp_DID == NameServer_DID))) |
@@ -629,9 +629,8 @@ lpfc_linkdown(struct lpfc_hba *phba) | |||
629 | LPFC_MBOXQ_t *mb; | 629 | LPFC_MBOXQ_t *mb; |
630 | int i; | 630 | int i; |
631 | 631 | ||
632 | if (phba->link_state == LPFC_LINK_DOWN) { | 632 | if (phba->link_state == LPFC_LINK_DOWN) |
633 | return 0; | 633 | return 0; |
634 | } | ||
635 | spin_lock_irq(&phba->hbalock); | 634 | spin_lock_irq(&phba->hbalock); |
636 | if (phba->link_state > LPFC_LINK_DOWN) { | 635 | if (phba->link_state > LPFC_LINK_DOWN) { |
637 | phba->link_state = LPFC_LINK_DOWN; | 636 | phba->link_state = LPFC_LINK_DOWN; |
@@ -684,20 +683,21 @@ lpfc_linkup_cleanup_nodes(struct lpfc_vport *vport) | |||
684 | struct lpfc_nodelist *ndlp; | 683 | struct lpfc_nodelist *ndlp; |
685 | 684 | ||
686 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { | 685 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
686 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
687 | continue; | ||
687 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) | 688 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
688 | continue; | 689 | continue; |
689 | |||
690 | if (ndlp->nlp_type & NLP_FABRIC) { | 690 | if (ndlp->nlp_type & NLP_FABRIC) { |
691 | /* On Linkup its safe to clean up the ndlp | 691 | /* On Linkup its safe to clean up the ndlp |
692 | * from Fabric connections. | 692 | * from Fabric connections. |
693 | */ | 693 | */ |
694 | if (ndlp->nlp_DID != Fabric_DID) | 694 | if (ndlp->nlp_DID != Fabric_DID) |
695 | lpfc_unreg_rpi(vport, ndlp); | 695 | lpfc_unreg_rpi(vport, ndlp); |
696 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | 696 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
697 | } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { | 697 | } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { |
698 | /* Fail outstanding IO now since device is | 698 | /* Fail outstanding IO now since device is |
699 | * marked for PLOGI. | 699 | * marked for PLOGI. |
700 | */ | 700 | */ |
701 | lpfc_unreg_rpi(vport, ndlp); | 701 | lpfc_unreg_rpi(vport, ndlp); |
702 | } | 702 | } |
703 | } | 703 | } |
@@ -799,21 +799,9 @@ lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
799 | writel(control, phba->HCregaddr); | 799 | writel(control, phba->HCregaddr); |
800 | readl(phba->HCregaddr); /* flush */ | 800 | readl(phba->HCregaddr); /* flush */ |
801 | spin_unlock_irq(&phba->hbalock); | 801 | spin_unlock_irq(&phba->hbalock); |
802 | mempool_free(pmb, phba->mbox_mem_pool); | ||
802 | return; | 803 | return; |
803 | 804 | ||
804 | vport->num_disc_nodes = 0; | ||
805 | /* go thru NPR nodes and issue ELS PLOGIs */ | ||
806 | if (vport->fc_npr_cnt) | ||
807 | lpfc_els_disc_plogi(vport); | ||
808 | |||
809 | if (!vport->num_disc_nodes) { | ||
810 | spin_lock_irq(shost->host_lock); | ||
811 | vport->fc_flag &= ~FC_NDISC_ACTIVE; | ||
812 | spin_unlock_irq(shost->host_lock); | ||
813 | } | ||
814 | |||
815 | vport->port_state = LPFC_VPORT_READY; | ||
816 | |||
817 | out: | 805 | out: |
818 | /* Device Discovery completes */ | 806 | /* Device Discovery completes */ |
819 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | 807 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
@@ -1133,7 +1121,7 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1133 | if (la->attType == AT_LINK_UP) { | 1121 | if (la->attType == AT_LINK_UP) { |
1134 | phba->fc_stat.LinkUp++; | 1122 | phba->fc_stat.LinkUp++; |
1135 | if (phba->link_flag & LS_LOOPBACK_MODE) { | 1123 | if (phba->link_flag & LS_LOOPBACK_MODE) { |
1136 | lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, | 1124 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, |
1137 | "1306 Link Up Event in loop back mode " | 1125 | "1306 Link Up Event in loop back mode " |
1138 | "x%x received Data: x%x x%x x%x x%x\n", | 1126 | "x%x received Data: x%x x%x x%x x%x\n", |
1139 | la->eventTag, phba->fc_eventTag, | 1127 | la->eventTag, phba->fc_eventTag, |
@@ -1150,11 +1138,21 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1150 | lpfc_mbx_process_link_up(phba, la); | 1138 | lpfc_mbx_process_link_up(phba, la); |
1151 | } else { | 1139 | } else { |
1152 | phba->fc_stat.LinkDown++; | 1140 | phba->fc_stat.LinkDown++; |
1153 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | 1141 | if (phba->link_flag & LS_LOOPBACK_MODE) { |
1142 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | ||
1143 | "1308 Link Down Event in loop back mode " | ||
1144 | "x%x received " | ||
1145 | "Data: x%x x%x x%x\n", | ||
1146 | la->eventTag, phba->fc_eventTag, | ||
1147 | phba->pport->port_state, vport->fc_flag); | ||
1148 | } | ||
1149 | else { | ||
1150 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | ||
1154 | "1305 Link Down Event x%x received " | 1151 | "1305 Link Down Event x%x received " |
1155 | "Data: x%x x%x x%x\n", | 1152 | "Data: x%x x%x x%x\n", |
1156 | la->eventTag, phba->fc_eventTag, | 1153 | la->eventTag, phba->fc_eventTag, |
1157 | phba->pport->port_state, vport->fc_flag); | 1154 | phba->pport->port_state, vport->fc_flag); |
1155 | } | ||
1158 | lpfc_mbx_issue_link_down(phba); | 1156 | lpfc_mbx_issue_link_down(phba); |
1159 | } | 1157 | } |
1160 | 1158 | ||
@@ -1305,7 +1303,6 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1305 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 1303 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
1306 | kfree(mp); | 1304 | kfree(mp); |
1307 | mempool_free(pmb, phba->mbox_mem_pool); | 1305 | mempool_free(pmb, phba->mbox_mem_pool); |
1308 | lpfc_nlp_put(ndlp); | ||
1309 | 1306 | ||
1310 | if (phba->fc_topology == TOPOLOGY_LOOP) { | 1307 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
1311 | /* FLOGI failed, use loop map to make discovery list */ | 1308 | /* FLOGI failed, use loop map to make discovery list */ |
@@ -1313,6 +1310,10 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1313 | 1310 | ||
1314 | /* Start discovery */ | 1311 | /* Start discovery */ |
1315 | lpfc_disc_start(vport); | 1312 | lpfc_disc_start(vport); |
1313 | /* Decrement the reference count to ndlp after the | ||
1314 | * reference to the ndlp are done. | ||
1315 | */ | ||
1316 | lpfc_nlp_put(ndlp); | ||
1316 | return; | 1317 | return; |
1317 | } | 1318 | } |
1318 | 1319 | ||
@@ -1320,6 +1321,10 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1320 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, | 1321 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
1321 | "0258 Register Fabric login error: 0x%x\n", | 1322 | "0258 Register Fabric login error: 0x%x\n", |
1322 | mb->mbxStatus); | 1323 | mb->mbxStatus); |
1324 | /* Decrement the reference count to ndlp after the reference | ||
1325 | * to the ndlp are done. | ||
1326 | */ | ||
1327 | lpfc_nlp_put(ndlp); | ||
1323 | return; | 1328 | return; |
1324 | } | 1329 | } |
1325 | 1330 | ||
@@ -1327,8 +1332,6 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1327 | ndlp->nlp_type |= NLP_FABRIC; | 1332 | ndlp->nlp_type |= NLP_FABRIC; |
1328 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); | 1333 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); |
1329 | 1334 | ||
1330 | lpfc_nlp_put(ndlp); /* Drop the reference from the mbox */ | ||
1331 | |||
1332 | if (vport->port_state == LPFC_FABRIC_CFG_LINK) { | 1335 | if (vport->port_state == LPFC_FABRIC_CFG_LINK) { |
1333 | vports = lpfc_create_vport_work_array(phba); | 1336 | vports = lpfc_create_vport_work_array(phba); |
1334 | if (vports != NULL) | 1337 | if (vports != NULL) |
@@ -1356,6 +1359,11 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1356 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 1359 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
1357 | kfree(mp); | 1360 | kfree(mp); |
1358 | mempool_free(pmb, phba->mbox_mem_pool); | 1361 | mempool_free(pmb, phba->mbox_mem_pool); |
1362 | |||
1363 | /* Drop the reference count from the mbox at the end after | ||
1364 | * all the current reference to the ndlp have been done. | ||
1365 | */ | ||
1366 | lpfc_nlp_put(ndlp); | ||
1359 | return; | 1367 | return; |
1360 | } | 1368 | } |
1361 | 1369 | ||
@@ -1463,9 +1471,8 @@ lpfc_register_remote_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
1463 | * registered the port. | 1471 | * registered the port. |
1464 | */ | 1472 | */ |
1465 | if (ndlp->rport && ndlp->rport->dd_data && | 1473 | if (ndlp->rport && ndlp->rport->dd_data && |
1466 | ((struct lpfc_rport_data *) ndlp->rport->dd_data)->pnode == ndlp) { | 1474 | ((struct lpfc_rport_data *) ndlp->rport->dd_data)->pnode == ndlp) |
1467 | lpfc_nlp_put(ndlp); | 1475 | lpfc_nlp_put(ndlp); |
1468 | } | ||
1469 | 1476 | ||
1470 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, | 1477 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, |
1471 | "rport add: did:x%x flg:x%x type x%x", | 1478 | "rport add: did:x%x flg:x%x type x%x", |
@@ -1660,6 +1667,18 @@ lpfc_nlp_set_state(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
1660 | } | 1667 | } |
1661 | 1668 | ||
1662 | void | 1669 | void |
1670 | lpfc_enqueue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | ||
1671 | { | ||
1672 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | ||
1673 | |||
1674 | if (list_empty(&ndlp->nlp_listp)) { | ||
1675 | spin_lock_irq(shost->host_lock); | ||
1676 | list_add_tail(&ndlp->nlp_listp, &vport->fc_nodes); | ||
1677 | spin_unlock_irq(shost->host_lock); | ||
1678 | } | ||
1679 | } | ||
1680 | |||
1681 | void | ||
1663 | lpfc_dequeue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | 1682 | lpfc_dequeue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
1664 | { | 1683 | { |
1665 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | 1684 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
@@ -1672,7 +1691,80 @@ lpfc_dequeue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
1672 | list_del_init(&ndlp->nlp_listp); | 1691 | list_del_init(&ndlp->nlp_listp); |
1673 | spin_unlock_irq(shost->host_lock); | 1692 | spin_unlock_irq(shost->host_lock); |
1674 | lpfc_nlp_state_cleanup(vport, ndlp, ndlp->nlp_state, | 1693 | lpfc_nlp_state_cleanup(vport, ndlp, ndlp->nlp_state, |
1675 | NLP_STE_UNUSED_NODE); | 1694 | NLP_STE_UNUSED_NODE); |
1695 | } | ||
1696 | |||
1697 | static void | ||
1698 | lpfc_disable_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | ||
1699 | { | ||
1700 | if ((ndlp->nlp_flag & NLP_DELAY_TMO) != 0) | ||
1701 | lpfc_cancel_retry_delay_tmo(vport, ndlp); | ||
1702 | if (ndlp->nlp_state && !list_empty(&ndlp->nlp_listp)) | ||
1703 | lpfc_nlp_counters(vport, ndlp->nlp_state, -1); | ||
1704 | lpfc_nlp_state_cleanup(vport, ndlp, ndlp->nlp_state, | ||
1705 | NLP_STE_UNUSED_NODE); | ||
1706 | } | ||
1707 | |||
1708 | struct lpfc_nodelist * | ||
1709 | lpfc_enable_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | ||
1710 | int state) | ||
1711 | { | ||
1712 | struct lpfc_hba *phba = vport->phba; | ||
1713 | uint32_t did; | ||
1714 | unsigned long flags; | ||
1715 | |||
1716 | if (!ndlp) | ||
1717 | return NULL; | ||
1718 | |||
1719 | spin_lock_irqsave(&phba->ndlp_lock, flags); | ||
1720 | /* The ndlp should not be in memory free mode */ | ||
1721 | if (NLP_CHK_FREE_REQ(ndlp)) { | ||
1722 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | ||
1723 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE, | ||
1724 | "0277 lpfc_enable_node: ndlp:x%p " | ||
1725 | "usgmap:x%x refcnt:%d\n", | ||
1726 | (void *)ndlp, ndlp->nlp_usg_map, | ||
1727 | atomic_read(&ndlp->kref.refcount)); | ||
1728 | return NULL; | ||
1729 | } | ||
1730 | /* The ndlp should not already be in active mode */ | ||
1731 | if (NLP_CHK_NODE_ACT(ndlp)) { | ||
1732 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | ||
1733 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE, | ||
1734 | "0278 lpfc_enable_node: ndlp:x%p " | ||
1735 | "usgmap:x%x refcnt:%d\n", | ||
1736 | (void *)ndlp, ndlp->nlp_usg_map, | ||
1737 | atomic_read(&ndlp->kref.refcount)); | ||
1738 | return NULL; | ||
1739 | } | ||
1740 | |||
1741 | /* Keep the original DID */ | ||
1742 | did = ndlp->nlp_DID; | ||
1743 | |||
1744 | /* re-initialize ndlp except of ndlp linked list pointer */ | ||
1745 | memset((((char *)ndlp) + sizeof (struct list_head)), 0, | ||
1746 | sizeof (struct lpfc_nodelist) - sizeof (struct list_head)); | ||
1747 | INIT_LIST_HEAD(&ndlp->els_retry_evt.evt_listp); | ||
1748 | INIT_LIST_HEAD(&ndlp->dev_loss_evt.evt_listp); | ||
1749 | init_timer(&ndlp->nlp_delayfunc); | ||
1750 | ndlp->nlp_delayfunc.function = lpfc_els_retry_delay; | ||
1751 | ndlp->nlp_delayfunc.data = (unsigned long)ndlp; | ||
1752 | ndlp->nlp_DID = did; | ||
1753 | ndlp->vport = vport; | ||
1754 | ndlp->nlp_sid = NLP_NO_SID; | ||
1755 | /* ndlp management re-initialize */ | ||
1756 | kref_init(&ndlp->kref); | ||
1757 | NLP_INT_NODE_ACT(ndlp); | ||
1758 | |||
1759 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | ||
1760 | |||
1761 | if (state != NLP_STE_UNUSED_NODE) | ||
1762 | lpfc_nlp_set_state(vport, ndlp, state); | ||
1763 | |||
1764 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE, | ||
1765 | "node enable: did:x%x", | ||
1766 | ndlp->nlp_DID, 0, 0); | ||
1767 | return ndlp; | ||
1676 | } | 1768 | } |
1677 | 1769 | ||
1678 | void | 1770 | void |
@@ -1972,7 +2064,21 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
1972 | "Data: x%x x%x x%x\n", | 2064 | "Data: x%x x%x x%x\n", |
1973 | ndlp->nlp_DID, ndlp->nlp_flag, | 2065 | ndlp->nlp_DID, ndlp->nlp_flag, |
1974 | ndlp->nlp_state, ndlp->nlp_rpi); | 2066 | ndlp->nlp_state, ndlp->nlp_rpi); |
1975 | lpfc_dequeue_node(vport, ndlp); | 2067 | if (NLP_CHK_FREE_REQ(ndlp)) { |
2068 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE, | ||
2069 | "0280 lpfc_cleanup_node: ndlp:x%p " | ||
2070 | "usgmap:x%x refcnt:%d\n", | ||
2071 | (void *)ndlp, ndlp->nlp_usg_map, | ||
2072 | atomic_read(&ndlp->kref.refcount)); | ||
2073 | lpfc_dequeue_node(vport, ndlp); | ||
2074 | } else { | ||
2075 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE, | ||
2076 | "0281 lpfc_cleanup_node: ndlp:x%p " | ||
2077 | "usgmap:x%x refcnt:%d\n", | ||
2078 | (void *)ndlp, ndlp->nlp_usg_map, | ||
2079 | atomic_read(&ndlp->kref.refcount)); | ||
2080 | lpfc_disable_node(vport, ndlp); | ||
2081 | } | ||
1976 | 2082 | ||
1977 | /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ | 2083 | /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ |
1978 | if ((mb = phba->sli.mbox_active)) { | 2084 | if ((mb = phba->sli.mbox_active)) { |
@@ -1994,12 +2100,16 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
1994 | } | 2100 | } |
1995 | list_del(&mb->list); | 2101 | list_del(&mb->list); |
1996 | mempool_free(mb, phba->mbox_mem_pool); | 2102 | mempool_free(mb, phba->mbox_mem_pool); |
1997 | lpfc_nlp_put(ndlp); | 2103 | /* We shall not invoke the lpfc_nlp_put to decrement |
2104 | * the ndlp reference count as we are in the process | ||
2105 | * of lpfc_nlp_release. | ||
2106 | */ | ||
1998 | } | 2107 | } |
1999 | } | 2108 | } |
2000 | spin_unlock_irq(&phba->hbalock); | 2109 | spin_unlock_irq(&phba->hbalock); |
2001 | 2110 | ||
2002 | lpfc_els_abort(phba,ndlp); | 2111 | lpfc_els_abort(phba, ndlp); |
2112 | |||
2003 | spin_lock_irq(shost->host_lock); | 2113 | spin_lock_irq(shost->host_lock); |
2004 | ndlp->nlp_flag &= ~NLP_DELAY_TMO; | 2114 | ndlp->nlp_flag &= ~NLP_DELAY_TMO; |
2005 | spin_unlock_irq(shost->host_lock); | 2115 | spin_unlock_irq(shost->host_lock); |
@@ -2057,7 +2167,6 @@ lpfc_nlp_remove(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
2057 | } | 2167 | } |
2058 | } | 2168 | } |
2059 | } | 2169 | } |
2060 | |||
2061 | lpfc_cleanup_node(vport, ndlp); | 2170 | lpfc_cleanup_node(vport, ndlp); |
2062 | 2171 | ||
2063 | /* | 2172 | /* |
@@ -2182,7 +2291,16 @@ lpfc_setup_disc_node(struct lpfc_vport *vport, uint32_t did) | |||
2182 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | 2291 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
2183 | spin_unlock_irq(shost->host_lock); | 2292 | spin_unlock_irq(shost->host_lock); |
2184 | return ndlp; | 2293 | return ndlp; |
2294 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
2295 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_NPR_NODE); | ||
2296 | if (!ndlp) | ||
2297 | return NULL; | ||
2298 | spin_lock_irq(shost->host_lock); | ||
2299 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | ||
2300 | spin_unlock_irq(shost->host_lock); | ||
2301 | return ndlp; | ||
2185 | } | 2302 | } |
2303 | |||
2186 | if (vport->fc_flag & FC_RSCN_MODE) { | 2304 | if (vport->fc_flag & FC_RSCN_MODE) { |
2187 | if (lpfc_rscn_payload_check(vport, did)) { | 2305 | if (lpfc_rscn_payload_check(vport, did)) { |
2188 | /* If we've already recieved a PLOGI from this NPort | 2306 | /* If we've already recieved a PLOGI from this NPort |
@@ -2363,6 +2481,7 @@ lpfc_disc_start(struct lpfc_vport *vport) | |||
2363 | * continue discovery. | 2481 | * continue discovery. |
2364 | */ | 2482 | */ |
2365 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && | 2483 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
2484 | !(vport->fc_flag & FC_PT2PT) && | ||
2366 | !(vport->fc_flag & FC_RSCN_MODE)) { | 2485 | !(vport->fc_flag & FC_RSCN_MODE)) { |
2367 | lpfc_issue_reg_vpi(phba, vport); | 2486 | lpfc_issue_reg_vpi(phba, vport); |
2368 | return; | 2487 | return; |
@@ -2485,6 +2604,8 @@ lpfc_disc_flush_list(struct lpfc_vport *vport) | |||
2485 | if (vport->fc_plogi_cnt || vport->fc_adisc_cnt) { | 2604 | if (vport->fc_plogi_cnt || vport->fc_adisc_cnt) { |
2486 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, | 2605 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, |
2487 | nlp_listp) { | 2606 | nlp_listp) { |
2607 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
2608 | continue; | ||
2488 | if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE || | 2609 | if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE || |
2489 | ndlp->nlp_state == NLP_STE_ADISC_ISSUE) { | 2610 | ndlp->nlp_state == NLP_STE_ADISC_ISSUE) { |
2490 | lpfc_free_tx(phba, ndlp); | 2611 | lpfc_free_tx(phba, ndlp); |
@@ -2572,6 +2693,8 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) | |||
2572 | /* Start discovery by sending FLOGI, clean up old rpis */ | 2693 | /* Start discovery by sending FLOGI, clean up old rpis */ |
2573 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, | 2694 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, |
2574 | nlp_listp) { | 2695 | nlp_listp) { |
2696 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
2697 | continue; | ||
2575 | if (ndlp->nlp_state != NLP_STE_NPR_NODE) | 2698 | if (ndlp->nlp_state != NLP_STE_NPR_NODE) |
2576 | continue; | 2699 | continue; |
2577 | if (ndlp->nlp_type & NLP_FABRIC) { | 2700 | if (ndlp->nlp_type & NLP_FABRIC) { |
@@ -2618,7 +2741,7 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) | |||
2618 | "NameServer login\n"); | 2741 | "NameServer login\n"); |
2619 | /* Next look for NameServer ndlp */ | 2742 | /* Next look for NameServer ndlp */ |
2620 | ndlp = lpfc_findnode_did(vport, NameServer_DID); | 2743 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
2621 | if (ndlp) | 2744 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
2622 | lpfc_els_abort(phba, ndlp); | 2745 | lpfc_els_abort(phba, ndlp); |
2623 | 2746 | ||
2624 | /* ReStart discovery */ | 2747 | /* ReStart discovery */ |
@@ -2897,6 +3020,7 @@ lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
2897 | ndlp->nlp_sid = NLP_NO_SID; | 3020 | ndlp->nlp_sid = NLP_NO_SID; |
2898 | INIT_LIST_HEAD(&ndlp->nlp_listp); | 3021 | INIT_LIST_HEAD(&ndlp->nlp_listp); |
2899 | kref_init(&ndlp->kref); | 3022 | kref_init(&ndlp->kref); |
3023 | NLP_INT_NODE_ACT(ndlp); | ||
2900 | 3024 | ||
2901 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE, | 3025 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE, |
2902 | "node init: did:x%x", | 3026 | "node init: did:x%x", |
@@ -2911,6 +3035,8 @@ lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
2911 | static void | 3035 | static void |
2912 | lpfc_nlp_release(struct kref *kref) | 3036 | lpfc_nlp_release(struct kref *kref) |
2913 | { | 3037 | { |
3038 | struct lpfc_hba *phba; | ||
3039 | unsigned long flags; | ||
2914 | struct lpfc_nodelist *ndlp = container_of(kref, struct lpfc_nodelist, | 3040 | struct lpfc_nodelist *ndlp = container_of(kref, struct lpfc_nodelist, |
2915 | kref); | 3041 | kref); |
2916 | 3042 | ||
@@ -2918,8 +3044,24 @@ lpfc_nlp_release(struct kref *kref) | |||
2918 | "node release: did:x%x flg:x%x type:x%x", | 3044 | "node release: did:x%x flg:x%x type:x%x", |
2919 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type); | 3045 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type); |
2920 | 3046 | ||
3047 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE, | ||
3048 | "0279 lpfc_nlp_release: ndlp:x%p " | ||
3049 | "usgmap:x%x refcnt:%d\n", | ||
3050 | (void *)ndlp, ndlp->nlp_usg_map, | ||
3051 | atomic_read(&ndlp->kref.refcount)); | ||
3052 | |||
3053 | /* remove ndlp from action. */ | ||
2921 | lpfc_nlp_remove(ndlp->vport, ndlp); | 3054 | lpfc_nlp_remove(ndlp->vport, ndlp); |
2922 | mempool_free(ndlp, ndlp->vport->phba->nlp_mem_pool); | 3055 | |
3056 | /* clear the ndlp active flag for all release cases */ | ||
3057 | phba = ndlp->vport->phba; | ||
3058 | spin_lock_irqsave(&phba->ndlp_lock, flags); | ||
3059 | NLP_CLR_NODE_ACT(ndlp); | ||
3060 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | ||
3061 | |||
3062 | /* free ndlp memory for final ndlp release */ | ||
3063 | if (NLP_CHK_FREE_REQ(ndlp)) | ||
3064 | mempool_free(ndlp, ndlp->vport->phba->nlp_mem_pool); | ||
2923 | } | 3065 | } |
2924 | 3066 | ||
2925 | /* This routine bumps the reference count for a ndlp structure to ensure | 3067 | /* This routine bumps the reference count for a ndlp structure to ensure |
@@ -2929,37 +3071,108 @@ lpfc_nlp_release(struct kref *kref) | |||
2929 | struct lpfc_nodelist * | 3071 | struct lpfc_nodelist * |
2930 | lpfc_nlp_get(struct lpfc_nodelist *ndlp) | 3072 | lpfc_nlp_get(struct lpfc_nodelist *ndlp) |
2931 | { | 3073 | { |
3074 | struct lpfc_hba *phba; | ||
3075 | unsigned long flags; | ||
3076 | |||
2932 | if (ndlp) { | 3077 | if (ndlp) { |
2933 | lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE, | 3078 | lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE, |
2934 | "node get: did:x%x flg:x%x refcnt:x%x", | 3079 | "node get: did:x%x flg:x%x refcnt:x%x", |
2935 | ndlp->nlp_DID, ndlp->nlp_flag, | 3080 | ndlp->nlp_DID, ndlp->nlp_flag, |
2936 | atomic_read(&ndlp->kref.refcount)); | 3081 | atomic_read(&ndlp->kref.refcount)); |
2937 | kref_get(&ndlp->kref); | 3082 | /* The check of ndlp usage to prevent incrementing the |
3083 | * ndlp reference count that is in the process of being | ||
3084 | * released. | ||
3085 | */ | ||
3086 | phba = ndlp->vport->phba; | ||
3087 | spin_lock_irqsave(&phba->ndlp_lock, flags); | ||
3088 | if (!NLP_CHK_NODE_ACT(ndlp) || NLP_CHK_FREE_ACK(ndlp)) { | ||
3089 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | ||
3090 | lpfc_printf_vlog(ndlp->vport, KERN_WARNING, LOG_NODE, | ||
3091 | "0276 lpfc_nlp_get: ndlp:x%p " | ||
3092 | "usgmap:x%x refcnt:%d\n", | ||
3093 | (void *)ndlp, ndlp->nlp_usg_map, | ||
3094 | atomic_read(&ndlp->kref.refcount)); | ||
3095 | return NULL; | ||
3096 | } else | ||
3097 | kref_get(&ndlp->kref); | ||
3098 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | ||
2938 | } | 3099 | } |
2939 | return ndlp; | 3100 | return ndlp; |
2940 | } | 3101 | } |
2941 | 3102 | ||
2942 | |||
2943 | /* This routine decrements the reference count for a ndlp structure. If the | 3103 | /* This routine decrements the reference count for a ndlp structure. If the |
2944 | * count goes to 0, this indicates the the associated nodelist should be freed. | 3104 | * count goes to 0, this indicates the the associated nodelist should be |
3105 | * freed. Returning 1 indicates the ndlp resource has been released; on the | ||
3106 | * other hand, returning 0 indicates the ndlp resource has not been released | ||
3107 | * yet. | ||
2945 | */ | 3108 | */ |
2946 | int | 3109 | int |
2947 | lpfc_nlp_put(struct lpfc_nodelist *ndlp) | 3110 | lpfc_nlp_put(struct lpfc_nodelist *ndlp) |
2948 | { | 3111 | { |
2949 | if (ndlp) { | 3112 | struct lpfc_hba *phba; |
2950 | lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE, | 3113 | unsigned long flags; |
2951 | "node put: did:x%x flg:x%x refcnt:x%x", | 3114 | |
2952 | ndlp->nlp_DID, ndlp->nlp_flag, | 3115 | if (!ndlp) |
2953 | atomic_read(&ndlp->kref.refcount)); | 3116 | return 1; |
3117 | |||
3118 | lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE, | ||
3119 | "node put: did:x%x flg:x%x refcnt:x%x", | ||
3120 | ndlp->nlp_DID, ndlp->nlp_flag, | ||
3121 | atomic_read(&ndlp->kref.refcount)); | ||
3122 | phba = ndlp->vport->phba; | ||
3123 | spin_lock_irqsave(&phba->ndlp_lock, flags); | ||
3124 | /* Check the ndlp memory free acknowledge flag to avoid the | ||
3125 | * possible race condition that kref_put got invoked again | ||
3126 | * after previous one has done ndlp memory free. | ||
3127 | */ | ||
3128 | if (NLP_CHK_FREE_ACK(ndlp)) { | ||
3129 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | ||
3130 | lpfc_printf_vlog(ndlp->vport, KERN_WARNING, LOG_NODE, | ||
3131 | "0274 lpfc_nlp_put: ndlp:x%p " | ||
3132 | "usgmap:x%x refcnt:%d\n", | ||
3133 | (void *)ndlp, ndlp->nlp_usg_map, | ||
3134 | atomic_read(&ndlp->kref.refcount)); | ||
3135 | return 1; | ||
2954 | } | 3136 | } |
2955 | return ndlp ? kref_put(&ndlp->kref, lpfc_nlp_release) : 0; | 3137 | /* Check the ndlp inactivate log flag to avoid the possible |
3138 | * race condition that kref_put got invoked again after ndlp | ||
3139 | * is already in inactivating state. | ||
3140 | */ | ||
3141 | if (NLP_CHK_IACT_REQ(ndlp)) { | ||
3142 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | ||
3143 | lpfc_printf_vlog(ndlp->vport, KERN_WARNING, LOG_NODE, | ||
3144 | "0275 lpfc_nlp_put: ndlp:x%p " | ||
3145 | "usgmap:x%x refcnt:%d\n", | ||
3146 | (void *)ndlp, ndlp->nlp_usg_map, | ||
3147 | atomic_read(&ndlp->kref.refcount)); | ||
3148 | return 1; | ||
3149 | } | ||
3150 | /* For last put, mark the ndlp usage flags to make sure no | ||
3151 | * other kref_get and kref_put on the same ndlp shall get | ||
3152 | * in between the process when the final kref_put has been | ||
3153 | * invoked on this ndlp. | ||
3154 | */ | ||
3155 | if (atomic_read(&ndlp->kref.refcount) == 1) { | ||
3156 | /* Indicate ndlp is put to inactive state. */ | ||
3157 | NLP_SET_IACT_REQ(ndlp); | ||
3158 | /* Acknowledge ndlp memory free has been seen. */ | ||
3159 | if (NLP_CHK_FREE_REQ(ndlp)) | ||
3160 | NLP_SET_FREE_ACK(ndlp); | ||
3161 | } | ||
3162 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | ||
3163 | /* Note, the kref_put returns 1 when decrementing a reference | ||
3164 | * count that was 1, it invokes the release callback function, | ||
3165 | * but it still left the reference count as 1 (not actually | ||
3166 | * performs the last decrementation). Otherwise, it actually | ||
3167 | * decrements the reference count and returns 0. | ||
3168 | */ | ||
3169 | return kref_put(&ndlp->kref, lpfc_nlp_release); | ||
2956 | } | 3170 | } |
2957 | 3171 | ||
2958 | /* This routine free's the specified nodelist if it is not in use | 3172 | /* This routine free's the specified nodelist if it is not in use |
2959 | * by any other discovery thread. This routine returns 1 if the ndlp | 3173 | * by any other discovery thread. This routine returns 1 if the |
2960 | * is not being used by anyone and has been freed. A return value of | 3174 | * ndlp has been freed. A return value of 0 indicates the ndlp is |
2961 | * 0 indicates it is being used by another discovery thread and the | 3175 | * not yet been released. |
2962 | * refcount is left unchanged. | ||
2963 | */ | 3176 | */ |
2964 | int | 3177 | int |
2965 | lpfc_nlp_not_used(struct lpfc_nodelist *ndlp) | 3178 | lpfc_nlp_not_used(struct lpfc_nodelist *ndlp) |
@@ -2968,11 +3181,8 @@ lpfc_nlp_not_used(struct lpfc_nodelist *ndlp) | |||
2968 | "node not used: did:x%x flg:x%x refcnt:x%x", | 3181 | "node not used: did:x%x flg:x%x refcnt:x%x", |
2969 | ndlp->nlp_DID, ndlp->nlp_flag, | 3182 | ndlp->nlp_DID, ndlp->nlp_flag, |
2970 | atomic_read(&ndlp->kref.refcount)); | 3183 | atomic_read(&ndlp->kref.refcount)); |
2971 | 3184 | if (atomic_read(&ndlp->kref.refcount) == 1) | |
2972 | if (atomic_read(&ndlp->kref.refcount) == 1) { | 3185 | if (lpfc_nlp_put(ndlp)) |
2973 | lpfc_nlp_put(ndlp); | 3186 | return 1; |
2974 | return 1; | ||
2975 | } | ||
2976 | return 0; | 3187 | return 0; |
2977 | } | 3188 | } |
2978 | |||
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index 041f83e7634a..7773b949aa7c 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * * | 7 | * * |
@@ -581,6 +581,7 @@ struct ls_rjt { /* Structure is in Big Endian format */ | |||
581 | #define LSEXP_INVALID_O_SID 0x15 | 581 | #define LSEXP_INVALID_O_SID 0x15 |
582 | #define LSEXP_INVALID_OX_RX 0x17 | 582 | #define LSEXP_INVALID_OX_RX 0x17 |
583 | #define LSEXP_CMD_IN_PROGRESS 0x19 | 583 | #define LSEXP_CMD_IN_PROGRESS 0x19 |
584 | #define LSEXP_PORT_LOGIN_REQ 0x1E | ||
584 | #define LSEXP_INVALID_NPORT_ID 0x1F | 585 | #define LSEXP_INVALID_NPORT_ID 0x1F |
585 | #define LSEXP_INVALID_SEQ_ID 0x21 | 586 | #define LSEXP_INVALID_SEQ_ID 0x21 |
586 | #define LSEXP_INVALID_XCHG 0x23 | 587 | #define LSEXP_INVALID_XCHG 0x23 |
@@ -1376,11 +1377,26 @@ typedef struct { /* FireFly BIU registers */ | |||
1376 | #define CMD_QUE_XRI64_CX 0xB3 | 1377 | #define CMD_QUE_XRI64_CX 0xB3 |
1377 | #define CMD_IOCB_RCV_SEQ64_CX 0xB5 | 1378 | #define CMD_IOCB_RCV_SEQ64_CX 0xB5 |
1378 | #define CMD_IOCB_RCV_ELS64_CX 0xB7 | 1379 | #define CMD_IOCB_RCV_ELS64_CX 0xB7 |
1380 | #define CMD_IOCB_RET_XRI64_CX 0xB9 | ||
1379 | #define CMD_IOCB_RCV_CONT64_CX 0xBB | 1381 | #define CMD_IOCB_RCV_CONT64_CX 0xBB |
1380 | 1382 | ||
1381 | #define CMD_GEN_REQUEST64_CR 0xC2 | 1383 | #define CMD_GEN_REQUEST64_CR 0xC2 |
1382 | #define CMD_GEN_REQUEST64_CX 0xC3 | 1384 | #define CMD_GEN_REQUEST64_CX 0xC3 |
1383 | 1385 | ||
1386 | /* Unhandled SLI-3 Commands */ | ||
1387 | #define CMD_IOCB_XMIT_MSEQ64_CR 0xB0 | ||
1388 | #define CMD_IOCB_XMIT_MSEQ64_CX 0xB1 | ||
1389 | #define CMD_IOCB_RCV_SEQ_LIST64_CX 0xC1 | ||
1390 | #define CMD_IOCB_RCV_ELS_LIST64_CX 0xCD | ||
1391 | #define CMD_IOCB_CLOSE_EXTENDED_CN 0xB6 | ||
1392 | #define CMD_IOCB_ABORT_EXTENDED_CN 0xBA | ||
1393 | #define CMD_IOCB_RET_HBQE64_CN 0xCA | ||
1394 | #define CMD_IOCB_FCP_IBIDIR64_CR 0xAC | ||
1395 | #define CMD_IOCB_FCP_IBIDIR64_CX 0xAD | ||
1396 | #define CMD_IOCB_FCP_ITASKMGT64_CX 0xAF | ||
1397 | #define CMD_IOCB_LOGENTRY_CN 0x94 | ||
1398 | #define CMD_IOCB_LOGENTRY_ASYNC_CN 0x96 | ||
1399 | |||
1384 | #define CMD_MAX_IOCB_CMD 0xE6 | 1400 | #define CMD_MAX_IOCB_CMD 0xE6 |
1385 | #define CMD_IOCB_MASK 0xff | 1401 | #define CMD_IOCB_MASK 0xff |
1386 | 1402 | ||
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 6cfeba7454d4..22843751c2ca 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -461,11 +461,21 @@ lpfc_config_port_post(struct lpfc_hba *phba) | |||
461 | int | 461 | int |
462 | lpfc_hba_down_prep(struct lpfc_hba *phba) | 462 | lpfc_hba_down_prep(struct lpfc_hba *phba) |
463 | { | 463 | { |
464 | struct lpfc_vport **vports; | ||
465 | int i; | ||
464 | /* Disable interrupts */ | 466 | /* Disable interrupts */ |
465 | writel(0, phba->HCregaddr); | 467 | writel(0, phba->HCregaddr); |
466 | readl(phba->HCregaddr); /* flush */ | 468 | readl(phba->HCregaddr); /* flush */ |
467 | 469 | ||
468 | lpfc_cleanup_discovery_resources(phba->pport); | 470 | if (phba->pport->load_flag & FC_UNLOADING) |
471 | lpfc_cleanup_discovery_resources(phba->pport); | ||
472 | else { | ||
473 | vports = lpfc_create_vport_work_array(phba); | ||
474 | if (vports != NULL) | ||
475 | for(i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) | ||
476 | lpfc_cleanup_discovery_resources(vports[i]); | ||
477 | lpfc_destroy_vport_work_array(phba, vports); | ||
478 | } | ||
469 | return 0; | 479 | return 0; |
470 | } | 480 | } |
471 | 481 | ||
@@ -1422,9 +1432,32 @@ lpfc_cleanup(struct lpfc_vport *vport) | |||
1422 | lpfc_port_link_failure(vport); | 1432 | lpfc_port_link_failure(vport); |
1423 | 1433 | ||
1424 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | 1434 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
1435 | if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
1436 | ndlp = lpfc_enable_node(vport, ndlp, | ||
1437 | NLP_STE_UNUSED_NODE); | ||
1438 | if (!ndlp) | ||
1439 | continue; | ||
1440 | spin_lock_irq(&phba->ndlp_lock); | ||
1441 | NLP_SET_FREE_REQ(ndlp); | ||
1442 | spin_unlock_irq(&phba->ndlp_lock); | ||
1443 | /* Trigger the release of the ndlp memory */ | ||
1444 | lpfc_nlp_put(ndlp); | ||
1445 | continue; | ||
1446 | } | ||
1447 | spin_lock_irq(&phba->ndlp_lock); | ||
1448 | if (NLP_CHK_FREE_REQ(ndlp)) { | ||
1449 | /* The ndlp should not be in memory free mode already */ | ||
1450 | spin_unlock_irq(&phba->ndlp_lock); | ||
1451 | continue; | ||
1452 | } else | ||
1453 | /* Indicate request for freeing ndlp memory */ | ||
1454 | NLP_SET_FREE_REQ(ndlp); | ||
1455 | spin_unlock_irq(&phba->ndlp_lock); | ||
1456 | |||
1425 | if (ndlp->nlp_type & NLP_FABRIC) | 1457 | if (ndlp->nlp_type & NLP_FABRIC) |
1426 | lpfc_disc_state_machine(vport, ndlp, NULL, | 1458 | lpfc_disc_state_machine(vport, ndlp, NULL, |
1427 | NLP_EVT_DEVICE_RECOVERY); | 1459 | NLP_EVT_DEVICE_RECOVERY); |
1460 | |||
1428 | lpfc_disc_state_machine(vport, ndlp, NULL, | 1461 | lpfc_disc_state_machine(vport, ndlp, NULL, |
1429 | NLP_EVT_DEVICE_RM); | 1462 | NLP_EVT_DEVICE_RM); |
1430 | } | 1463 | } |
@@ -1438,6 +1471,17 @@ lpfc_cleanup(struct lpfc_vport *vport) | |||
1438 | if (i++ > 3000) { | 1471 | if (i++ > 3000) { |
1439 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, | 1472 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
1440 | "0233 Nodelist not empty\n"); | 1473 | "0233 Nodelist not empty\n"); |
1474 | list_for_each_entry_safe(ndlp, next_ndlp, | ||
1475 | &vport->fc_nodes, nlp_listp) { | ||
1476 | lpfc_printf_vlog(ndlp->vport, KERN_ERR, | ||
1477 | LOG_NODE, | ||
1478 | "0282: did:x%x ndlp:x%p " | ||
1479 | "usgmap:x%x refcnt:%d\n", | ||
1480 | ndlp->nlp_DID, (void *)ndlp, | ||
1481 | ndlp->nlp_usg_map, | ||
1482 | atomic_read( | ||
1483 | &ndlp->kref.refcount)); | ||
1484 | } | ||
1441 | break; | 1485 | break; |
1442 | } | 1486 | } |
1443 | 1487 | ||
@@ -1586,6 +1630,8 @@ lpfc_offline_prep(struct lpfc_hba * phba) | |||
1586 | list_for_each_entry_safe(ndlp, next_ndlp, | 1630 | list_for_each_entry_safe(ndlp, next_ndlp, |
1587 | &vports[i]->fc_nodes, | 1631 | &vports[i]->fc_nodes, |
1588 | nlp_listp) { | 1632 | nlp_listp) { |
1633 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
1634 | continue; | ||
1589 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) | 1635 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
1590 | continue; | 1636 | continue; |
1591 | if (ndlp->nlp_type & NLP_FABRIC) { | 1637 | if (ndlp->nlp_type & NLP_FABRIC) { |
@@ -1695,9 +1741,9 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev) | |||
1695 | 1741 | ||
1696 | vport = (struct lpfc_vport *) shost->hostdata; | 1742 | vport = (struct lpfc_vport *) shost->hostdata; |
1697 | vport->phba = phba; | 1743 | vport->phba = phba; |
1698 | |||
1699 | vport->load_flag |= FC_LOADING; | 1744 | vport->load_flag |= FC_LOADING; |
1700 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | 1745 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
1746 | vport->fc_rscn_flush = 0; | ||
1701 | 1747 | ||
1702 | lpfc_get_vport_cfgparam(vport); | 1748 | lpfc_get_vport_cfgparam(vport); |
1703 | shost->unique_id = instance; | 1749 | shost->unique_id = instance; |
@@ -1879,6 +1925,42 @@ void lpfc_host_attrib_init(struct Scsi_Host *shost) | |||
1879 | spin_unlock_irq(shost->host_lock); | 1925 | spin_unlock_irq(shost->host_lock); |
1880 | } | 1926 | } |
1881 | 1927 | ||
1928 | static int | ||
1929 | lpfc_enable_msix(struct lpfc_hba *phba) | ||
1930 | { | ||
1931 | int error; | ||
1932 | |||
1933 | phba->msix_entries[0].entry = 0; | ||
1934 | phba->msix_entries[0].vector = 0; | ||
1935 | |||
1936 | error = pci_enable_msix(phba->pcidev, phba->msix_entries, | ||
1937 | ARRAY_SIZE(phba->msix_entries)); | ||
1938 | if (error) { | ||
1939 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | ||
1940 | "0420 Enable MSI-X failed (%d), continuing " | ||
1941 | "with MSI\n", error); | ||
1942 | pci_disable_msix(phba->pcidev); | ||
1943 | return error; | ||
1944 | } | ||
1945 | |||
1946 | error = request_irq(phba->msix_entries[0].vector, lpfc_intr_handler, 0, | ||
1947 | LPFC_DRIVER_NAME, phba); | ||
1948 | if (error) { | ||
1949 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | ||
1950 | "0421 MSI-X request_irq failed (%d), " | ||
1951 | "continuing with MSI\n", error); | ||
1952 | pci_disable_msix(phba->pcidev); | ||
1953 | } | ||
1954 | return error; | ||
1955 | } | ||
1956 | |||
1957 | static void | ||
1958 | lpfc_disable_msix(struct lpfc_hba *phba) | ||
1959 | { | ||
1960 | free_irq(phba->msix_entries[0].vector, phba); | ||
1961 | pci_disable_msix(phba->pcidev); | ||
1962 | } | ||
1963 | |||
1882 | static int __devinit | 1964 | static int __devinit |
1883 | lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | 1965 | lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) |
1884 | { | 1966 | { |
@@ -1905,6 +1987,9 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |||
1905 | 1987 | ||
1906 | spin_lock_init(&phba->hbalock); | 1988 | spin_lock_init(&phba->hbalock); |
1907 | 1989 | ||
1990 | /* Initialize ndlp management spinlock */ | ||
1991 | spin_lock_init(&phba->ndlp_lock); | ||
1992 | |||
1908 | phba->pcidev = pdev; | 1993 | phba->pcidev = pdev; |
1909 | 1994 | ||
1910 | /* Assign an unused board number */ | 1995 | /* Assign an unused board number */ |
@@ -2002,6 +2087,8 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |||
2002 | 2087 | ||
2003 | memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); | 2088 | memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); |
2004 | 2089 | ||
2090 | INIT_LIST_HEAD(&phba->hbqbuf_in_list); | ||
2091 | |||
2005 | /* Initialize the SLI Layer to run with lpfc HBAs. */ | 2092 | /* Initialize the SLI Layer to run with lpfc HBAs. */ |
2006 | lpfc_sli_setup(phba); | 2093 | lpfc_sli_setup(phba); |
2007 | lpfc_sli_queue_setup(phba); | 2094 | lpfc_sli_queue_setup(phba); |
@@ -2077,24 +2164,36 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |||
2077 | lpfc_debugfs_initialize(vport); | 2164 | lpfc_debugfs_initialize(vport); |
2078 | 2165 | ||
2079 | pci_set_drvdata(pdev, shost); | 2166 | pci_set_drvdata(pdev, shost); |
2167 | phba->intr_type = NONE; | ||
2080 | 2168 | ||
2081 | if (phba->cfg_use_msi) { | 2169 | if (phba->cfg_use_msi == 2) { |
2170 | error = lpfc_enable_msix(phba); | ||
2171 | if (!error) | ||
2172 | phba->intr_type = MSIX; | ||
2173 | } | ||
2174 | |||
2175 | /* Fallback to MSI if MSI-X initialization failed */ | ||
2176 | if (phba->cfg_use_msi >= 1 && phba->intr_type == NONE) { | ||
2082 | retval = pci_enable_msi(phba->pcidev); | 2177 | retval = pci_enable_msi(phba->pcidev); |
2083 | if (!retval) | 2178 | if (!retval) |
2084 | phba->using_msi = 1; | 2179 | phba->intr_type = MSI; |
2085 | else | 2180 | else |
2086 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | 2181 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
2087 | "0452 Enable MSI failed, continuing " | 2182 | "0452 Enable MSI failed, continuing " |
2088 | "with IRQ\n"); | 2183 | "with IRQ\n"); |
2089 | } | 2184 | } |
2090 | 2185 | ||
2091 | retval = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED, | 2186 | /* MSI-X is the only case the doesn't need to call request_irq */ |
2092 | LPFC_DRIVER_NAME, phba); | 2187 | if (phba->intr_type != MSIX) { |
2093 | if (retval) { | 2188 | retval = request_irq(phba->pcidev->irq, lpfc_intr_handler, |
2094 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 2189 | IRQF_SHARED, LPFC_DRIVER_NAME, phba); |
2095 | "0451 Enable interrupt handler failed\n"); | 2190 | if (retval) { |
2096 | error = retval; | 2191 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "0451 Enable " |
2097 | goto out_disable_msi; | 2192 | "interrupt handler failed\n"); |
2193 | error = retval; | ||
2194 | goto out_disable_msi; | ||
2195 | } else if (phba->intr_type != MSI) | ||
2196 | phba->intr_type = INTx; | ||
2098 | } | 2197 | } |
2099 | 2198 | ||
2100 | phba->MBslimaddr = phba->slim_memmap_p; | 2199 | phba->MBslimaddr = phba->slim_memmap_p; |
@@ -2139,9 +2238,14 @@ out_remove_device: | |||
2139 | out_free_irq: | 2238 | out_free_irq: |
2140 | lpfc_stop_phba_timers(phba); | 2239 | lpfc_stop_phba_timers(phba); |
2141 | phba->pport->work_port_events = 0; | 2240 | phba->pport->work_port_events = 0; |
2142 | free_irq(phba->pcidev->irq, phba); | 2241 | |
2242 | if (phba->intr_type == MSIX) | ||
2243 | lpfc_disable_msix(phba); | ||
2244 | else | ||
2245 | free_irq(phba->pcidev->irq, phba); | ||
2246 | |||
2143 | out_disable_msi: | 2247 | out_disable_msi: |
2144 | if (phba->using_msi) | 2248 | if (phba->intr_type == MSI) |
2145 | pci_disable_msi(phba->pcidev); | 2249 | pci_disable_msi(phba->pcidev); |
2146 | destroy_port(vport); | 2250 | destroy_port(vport); |
2147 | out_kthread_stop: | 2251 | out_kthread_stop: |
@@ -2214,10 +2318,13 @@ lpfc_pci_remove_one(struct pci_dev *pdev) | |||
2214 | 2318 | ||
2215 | lpfc_debugfs_terminate(vport); | 2319 | lpfc_debugfs_terminate(vport); |
2216 | 2320 | ||
2217 | /* Release the irq reservation */ | 2321 | if (phba->intr_type == MSIX) |
2218 | free_irq(phba->pcidev->irq, phba); | 2322 | lpfc_disable_msix(phba); |
2219 | if (phba->using_msi) | 2323 | else { |
2220 | pci_disable_msi(phba->pcidev); | 2324 | free_irq(phba->pcidev->irq, phba); |
2325 | if (phba->intr_type == MSI) | ||
2326 | pci_disable_msi(phba->pcidev); | ||
2327 | } | ||
2221 | 2328 | ||
2222 | pci_set_drvdata(pdev, NULL); | 2329 | pci_set_drvdata(pdev, NULL); |
2223 | scsi_host_put(shost); | 2330 | scsi_host_put(shost); |
@@ -2276,10 +2383,13 @@ static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev, | |||
2276 | pring = &psli->ring[psli->fcp_ring]; | 2383 | pring = &psli->ring[psli->fcp_ring]; |
2277 | lpfc_sli_abort_iocb_ring(phba, pring); | 2384 | lpfc_sli_abort_iocb_ring(phba, pring); |
2278 | 2385 | ||
2279 | /* Release the irq reservation */ | 2386 | if (phba->intr_type == MSIX) |
2280 | free_irq(phba->pcidev->irq, phba); | 2387 | lpfc_disable_msix(phba); |
2281 | if (phba->using_msi) | 2388 | else { |
2282 | pci_disable_msi(phba->pcidev); | 2389 | free_irq(phba->pcidev->irq, phba); |
2390 | if (phba->intr_type == MSI) | ||
2391 | pci_disable_msi(phba->pcidev); | ||
2392 | } | ||
2283 | 2393 | ||
2284 | /* Request a slot reset. */ | 2394 | /* Request a slot reset. */ |
2285 | return PCI_ERS_RESULT_NEED_RESET; | 2395 | return PCI_ERS_RESULT_NEED_RESET; |
diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h index c5841d7565f7..39fd2b843bec 100644 --- a/drivers/scsi/lpfc/lpfc_logmsg.h +++ b/drivers/scsi/lpfc/lpfc_logmsg.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2005 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * * | 7 | * * |
@@ -35,11 +35,15 @@ | |||
35 | #define LOG_ALL_MSG 0xffff /* LOG all messages */ | 35 | #define LOG_ALL_MSG 0xffff /* LOG all messages */ |
36 | 36 | ||
37 | #define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \ | 37 | #define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \ |
38 | do { \ | ||
38 | { if (((mask) &(vport)->cfg_log_verbose) || (level[1] <= '3')) \ | 39 | { if (((mask) &(vport)->cfg_log_verbose) || (level[1] <= '3')) \ |
39 | dev_printk(level, &((vport)->phba->pcidev)->dev, "%d:(%d):" \ | 40 | dev_printk(level, &((vport)->phba->pcidev)->dev, "%d:(%d):" \ |
40 | fmt, (vport)->phba->brd_no, vport->vpi, ##arg); } | 41 | fmt, (vport)->phba->brd_no, vport->vpi, ##arg); } \ |
42 | } while (0) | ||
41 | 43 | ||
42 | #define lpfc_printf_log(phba, level, mask, fmt, arg...) \ | 44 | #define lpfc_printf_log(phba, level, mask, fmt, arg...) \ |
45 | do { \ | ||
43 | { if (((mask) &(phba)->pport->cfg_log_verbose) || (level[1] <= '3')) \ | 46 | { if (((mask) &(phba)->pport->cfg_log_verbose) || (level[1] <= '3')) \ |
44 | dev_printk(level, &((phba)->pcidev)->dev, "%d:" \ | 47 | dev_printk(level, &((phba)->pcidev)->dev, "%d:" \ |
45 | fmt, phba->brd_no, ##arg); } | 48 | fmt, phba->brd_no, ##arg); } \ |
49 | } while (0) | ||
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c index 6dc5ab8d6716..3c0cebc71800 100644 --- a/drivers/scsi/lpfc/lpfc_mem.c +++ b/drivers/scsi/lpfc/lpfc_mem.c | |||
@@ -264,19 +264,30 @@ void | |||
264 | lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp) | 264 | lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp) |
265 | { | 265 | { |
266 | struct hbq_dmabuf *hbq_entry; | 266 | struct hbq_dmabuf *hbq_entry; |
267 | unsigned long flags; | ||
268 | |||
269 | if (!mp) | ||
270 | return; | ||
267 | 271 | ||
268 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { | 272 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
273 | /* Check whether HBQ is still in use */ | ||
274 | spin_lock_irqsave(&phba->hbalock, flags); | ||
275 | if (!phba->hbq_in_use) { | ||
276 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
277 | return; | ||
278 | } | ||
269 | hbq_entry = container_of(mp, struct hbq_dmabuf, dbuf); | 279 | hbq_entry = container_of(mp, struct hbq_dmabuf, dbuf); |
280 | list_del(&hbq_entry->dbuf.list); | ||
270 | if (hbq_entry->tag == -1) { | 281 | if (hbq_entry->tag == -1) { |
271 | (phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer) | 282 | (phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer) |
272 | (phba, hbq_entry); | 283 | (phba, hbq_entry); |
273 | } else { | 284 | } else { |
274 | lpfc_sli_free_hbq(phba, hbq_entry); | 285 | lpfc_sli_free_hbq(phba, hbq_entry); |
275 | } | 286 | } |
287 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
276 | } else { | 288 | } else { |
277 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 289 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
278 | kfree(mp); | 290 | kfree(mp); |
279 | } | 291 | } |
280 | return; | 292 | return; |
281 | } | 293 | } |
282 | |||
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index 4a0e3406e37a..d513813f6697 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -249,6 +249,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
249 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | 249 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
250 | struct lpfc_hba *phba = vport->phba; | 250 | struct lpfc_hba *phba = vport->phba; |
251 | struct lpfc_dmabuf *pcmd; | 251 | struct lpfc_dmabuf *pcmd; |
252 | struct lpfc_work_evt *evtp; | ||
252 | uint32_t *lp; | 253 | uint32_t *lp; |
253 | IOCB_t *icmd; | 254 | IOCB_t *icmd; |
254 | struct serv_parm *sp; | 255 | struct serv_parm *sp; |
@@ -435,8 +436,14 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
435 | del_timer_sync(&ndlp->nlp_delayfunc); | 436 | del_timer_sync(&ndlp->nlp_delayfunc); |
436 | ndlp->nlp_last_elscmd = 0; | 437 | ndlp->nlp_last_elscmd = 0; |
437 | 438 | ||
438 | if (!list_empty(&ndlp->els_retry_evt.evt_listp)) | 439 | if (!list_empty(&ndlp->els_retry_evt.evt_listp)) { |
439 | list_del_init(&ndlp->els_retry_evt.evt_listp); | 440 | list_del_init(&ndlp->els_retry_evt.evt_listp); |
441 | /* Decrement ndlp reference count held for the | ||
442 | * delayed retry | ||
443 | */ | ||
444 | evtp = &ndlp->els_retry_evt; | ||
445 | lpfc_nlp_put((struct lpfc_nodelist *)evtp->evt_arg1); | ||
446 | } | ||
440 | 447 | ||
441 | if (ndlp->nlp_flag & NLP_NPR_2B_DISC) { | 448 | if (ndlp->nlp_flag & NLP_NPR_2B_DISC) { |
442 | spin_lock_irq(shost->host_lock); | 449 | spin_lock_irq(shost->host_lock); |
@@ -638,13 +645,15 @@ lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
638 | return 0; | 645 | return 0; |
639 | } | 646 | } |
640 | 647 | ||
641 | /* Check config parameter use-adisc or FCP-2 */ | 648 | if (!(vport->fc_flag & FC_PT2PT)) { |
642 | if ((vport->cfg_use_adisc && (vport->fc_flag & FC_RSCN_MODE)) || | 649 | /* Check config parameter use-adisc or FCP-2 */ |
643 | ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) { | 650 | if ((vport->cfg_use_adisc && (vport->fc_flag & FC_RSCN_MODE)) || |
644 | spin_lock_irq(shost->host_lock); | 651 | ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) { |
645 | ndlp->nlp_flag |= NLP_NPR_ADISC; | 652 | spin_lock_irq(shost->host_lock); |
646 | spin_unlock_irq(shost->host_lock); | 653 | ndlp->nlp_flag |= NLP_NPR_ADISC; |
647 | return 1; | 654 | spin_unlock_irq(shost->host_lock); |
655 | return 1; | ||
656 | } | ||
648 | } | 657 | } |
649 | ndlp->nlp_flag &= ~NLP_NPR_ADISC; | 658 | ndlp->nlp_flag &= ~NLP_NPR_ADISC; |
650 | lpfc_unreg_rpi(vport, ndlp); | 659 | lpfc_unreg_rpi(vport, ndlp); |
@@ -656,7 +665,7 @@ lpfc_disc_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
656 | void *arg, uint32_t evt) | 665 | void *arg, uint32_t evt) |
657 | { | 666 | { |
658 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, | 667 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
659 | "0253 Illegal State Transition: node x%x " | 668 | "0271 Illegal State Transition: node x%x " |
660 | "event x%x, state x%x Data: x%x x%x\n", | 669 | "event x%x, state x%x Data: x%x x%x\n", |
661 | ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi, | 670 | ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi, |
662 | ndlp->nlp_flag); | 671 | ndlp->nlp_flag); |
@@ -674,7 +683,7 @@ lpfc_cmpl_plogi_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
674 | */ | 683 | */ |
675 | if (!(ndlp->nlp_flag & NLP_RCV_PLOGI)) { | 684 | if (!(ndlp->nlp_flag & NLP_RCV_PLOGI)) { |
676 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, | 685 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
677 | "0253 Illegal State Transition: node x%x " | 686 | "0272 Illegal State Transition: node x%x " |
678 | "event x%x, state x%x Data: x%x x%x\n", | 687 | "event x%x, state x%x Data: x%x x%x\n", |
679 | ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi, | 688 | ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi, |
680 | ndlp->nlp_flag); | 689 | ndlp->nlp_flag); |
@@ -2144,8 +2153,11 @@ lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
2144 | uint32_t cur_state, rc; | 2153 | uint32_t cur_state, rc; |
2145 | uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *, | 2154 | uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *, |
2146 | uint32_t); | 2155 | uint32_t); |
2156 | uint32_t got_ndlp = 0; | ||
2157 | |||
2158 | if (lpfc_nlp_get(ndlp)) | ||
2159 | got_ndlp = 1; | ||
2147 | 2160 | ||
2148 | lpfc_nlp_get(ndlp); | ||
2149 | cur_state = ndlp->nlp_state; | 2161 | cur_state = ndlp->nlp_state; |
2150 | 2162 | ||
2151 | /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */ | 2163 | /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */ |
@@ -2162,15 +2174,24 @@ lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
2162 | rc = (func) (vport, ndlp, arg, evt); | 2174 | rc = (func) (vport, ndlp, arg, evt); |
2163 | 2175 | ||
2164 | /* DSM out state <rc> on NPort <nlp_DID> */ | 2176 | /* DSM out state <rc> on NPort <nlp_DID> */ |
2165 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | 2177 | if (got_ndlp) { |
2178 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | ||
2166 | "0212 DSM out state %d on NPort x%x Data: x%x\n", | 2179 | "0212 DSM out state %d on NPort x%x Data: x%x\n", |
2167 | rc, ndlp->nlp_DID, ndlp->nlp_flag); | 2180 | rc, ndlp->nlp_DID, ndlp->nlp_flag); |
2168 | 2181 | ||
2169 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, | 2182 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, |
2170 | "DSM out: ste:%d did:x%x flg:x%x", | 2183 | "DSM out: ste:%d did:x%x flg:x%x", |
2171 | rc, ndlp->nlp_DID, ndlp->nlp_flag); | 2184 | rc, ndlp->nlp_DID, ndlp->nlp_flag); |
2185 | /* Decrement the ndlp reference count held for this function */ | ||
2186 | lpfc_nlp_put(ndlp); | ||
2187 | } else { | ||
2188 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | ||
2189 | "0212 DSM out state %d on NPort free\n", rc); | ||
2172 | 2190 | ||
2173 | lpfc_nlp_put(ndlp); | 2191 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, |
2192 | "DSM out: ste:%d did:x%x flg:x%x", | ||
2193 | rc, 0, 0); | ||
2194 | } | ||
2174 | 2195 | ||
2175 | return rc; | 2196 | return rc; |
2176 | } | 2197 | } |
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index fc5c3a42b05a..70255c11d3ad 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -1283,6 +1283,8 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) | |||
1283 | match = 0; | 1283 | match = 0; |
1284 | spin_lock_irq(shost->host_lock); | 1284 | spin_lock_irq(shost->host_lock); |
1285 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { | 1285 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
1286 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
1287 | continue; | ||
1286 | if (ndlp->nlp_state == NLP_STE_MAPPED_NODE && | 1288 | if (ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
1287 | i == ndlp->nlp_sid && | 1289 | i == ndlp->nlp_sid && |
1288 | ndlp->rport) { | 1290 | ndlp->rport) { |
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index fdd01e384e36..fc0d9501aba6 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -203,8 +203,25 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd) | |||
203 | case CMD_IOCB_RCV_SEQ64_CX: | 203 | case CMD_IOCB_RCV_SEQ64_CX: |
204 | case CMD_IOCB_RCV_ELS64_CX: | 204 | case CMD_IOCB_RCV_ELS64_CX: |
205 | case CMD_IOCB_RCV_CONT64_CX: | 205 | case CMD_IOCB_RCV_CONT64_CX: |
206 | case CMD_IOCB_RET_XRI64_CX: | ||
206 | type = LPFC_UNSOL_IOCB; | 207 | type = LPFC_UNSOL_IOCB; |
207 | break; | 208 | break; |
209 | case CMD_IOCB_XMIT_MSEQ64_CR: | ||
210 | case CMD_IOCB_XMIT_MSEQ64_CX: | ||
211 | case CMD_IOCB_RCV_SEQ_LIST64_CX: | ||
212 | case CMD_IOCB_RCV_ELS_LIST64_CX: | ||
213 | case CMD_IOCB_CLOSE_EXTENDED_CN: | ||
214 | case CMD_IOCB_ABORT_EXTENDED_CN: | ||
215 | case CMD_IOCB_RET_HBQE64_CN: | ||
216 | case CMD_IOCB_FCP_IBIDIR64_CR: | ||
217 | case CMD_IOCB_FCP_IBIDIR64_CX: | ||
218 | case CMD_IOCB_FCP_ITASKMGT64_CX: | ||
219 | case CMD_IOCB_LOGENTRY_CN: | ||
220 | case CMD_IOCB_LOGENTRY_ASYNC_CN: | ||
221 | printk("%s - Unhandled SLI-3 Command x%x\n", | ||
222 | __FUNCTION__, iocb_cmnd); | ||
223 | type = LPFC_UNKNOWN_IOCB; | ||
224 | break; | ||
208 | default: | 225 | default: |
209 | type = LPFC_UNKNOWN_IOCB; | 226 | type = LPFC_UNKNOWN_IOCB; |
210 | break; | 227 | break; |
@@ -529,10 +546,13 @@ lpfc_sli_hbqbuf_free_all(struct lpfc_hba *phba) | |||
529 | { | 546 | { |
530 | struct lpfc_dmabuf *dmabuf, *next_dmabuf; | 547 | struct lpfc_dmabuf *dmabuf, *next_dmabuf; |
531 | struct hbq_dmabuf *hbq_buf; | 548 | struct hbq_dmabuf *hbq_buf; |
549 | unsigned long flags; | ||
532 | int i, hbq_count; | 550 | int i, hbq_count; |
551 | uint32_t hbqno; | ||
533 | 552 | ||
534 | hbq_count = lpfc_sli_hbq_count(); | 553 | hbq_count = lpfc_sli_hbq_count(); |
535 | /* Return all memory used by all HBQs */ | 554 | /* Return all memory used by all HBQs */ |
555 | spin_lock_irqsave(&phba->hbalock, flags); | ||
536 | for (i = 0; i < hbq_count; ++i) { | 556 | for (i = 0; i < hbq_count; ++i) { |
537 | list_for_each_entry_safe(dmabuf, next_dmabuf, | 557 | list_for_each_entry_safe(dmabuf, next_dmabuf, |
538 | &phba->hbqs[i].hbq_buffer_list, list) { | 558 | &phba->hbqs[i].hbq_buffer_list, list) { |
@@ -542,6 +562,28 @@ lpfc_sli_hbqbuf_free_all(struct lpfc_hba *phba) | |||
542 | } | 562 | } |
543 | phba->hbqs[i].buffer_count = 0; | 563 | phba->hbqs[i].buffer_count = 0; |
544 | } | 564 | } |
565 | /* Return all HBQ buffer that are in-fly */ | ||
566 | list_for_each_entry_safe(dmabuf, next_dmabuf, | ||
567 | &phba->hbqbuf_in_list, list) { | ||
568 | hbq_buf = container_of(dmabuf, struct hbq_dmabuf, dbuf); | ||
569 | list_del(&hbq_buf->dbuf.list); | ||
570 | if (hbq_buf->tag == -1) { | ||
571 | (phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer) | ||
572 | (phba, hbq_buf); | ||
573 | } else { | ||
574 | hbqno = hbq_buf->tag >> 16; | ||
575 | if (hbqno >= LPFC_MAX_HBQS) | ||
576 | (phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer) | ||
577 | (phba, hbq_buf); | ||
578 | else | ||
579 | (phba->hbqs[hbqno].hbq_free_buffer)(phba, | ||
580 | hbq_buf); | ||
581 | } | ||
582 | } | ||
583 | |||
584 | /* Mark the HBQs not in use */ | ||
585 | phba->hbq_in_use = 0; | ||
586 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
545 | } | 587 | } |
546 | 588 | ||
547 | static struct lpfc_hbq_entry * | 589 | static struct lpfc_hbq_entry * |
@@ -603,30 +645,40 @@ static int | |||
603 | lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) | 645 | lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) |
604 | { | 646 | { |
605 | uint32_t i, start, end; | 647 | uint32_t i, start, end; |
648 | unsigned long flags; | ||
606 | struct hbq_dmabuf *hbq_buffer; | 649 | struct hbq_dmabuf *hbq_buffer; |
607 | 650 | ||
608 | if (!phba->hbqs[hbqno].hbq_alloc_buffer) { | 651 | if (!phba->hbqs[hbqno].hbq_alloc_buffer) |
609 | return 0; | 652 | return 0; |
610 | } | ||
611 | 653 | ||
612 | start = phba->hbqs[hbqno].buffer_count; | 654 | start = phba->hbqs[hbqno].buffer_count; |
613 | end = count + start; | 655 | end = count + start; |
614 | if (end > lpfc_hbq_defs[hbqno]->entry_count) { | 656 | if (end > lpfc_hbq_defs[hbqno]->entry_count) |
615 | end = lpfc_hbq_defs[hbqno]->entry_count; | 657 | end = lpfc_hbq_defs[hbqno]->entry_count; |
616 | } | 658 | |
659 | /* Check whether HBQ is still in use */ | ||
660 | spin_lock_irqsave(&phba->hbalock, flags); | ||
661 | if (!phba->hbq_in_use) | ||
662 | goto out; | ||
617 | 663 | ||
618 | /* Populate HBQ entries */ | 664 | /* Populate HBQ entries */ |
619 | for (i = start; i < end; i++) { | 665 | for (i = start; i < end; i++) { |
620 | hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | 666 | hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); |
621 | if (!hbq_buffer) | 667 | if (!hbq_buffer) |
622 | return 1; | 668 | goto err; |
623 | hbq_buffer->tag = (i | (hbqno << 16)); | 669 | hbq_buffer->tag = (i | (hbqno << 16)); |
624 | if (lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer)) | 670 | if (lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer)) |
625 | phba->hbqs[hbqno].buffer_count++; | 671 | phba->hbqs[hbqno].buffer_count++; |
626 | else | 672 | else |
627 | (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); | 673 | (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); |
628 | } | 674 | } |
675 | |||
676 | out: | ||
677 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
629 | return 0; | 678 | return 0; |
679 | err: | ||
680 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
681 | return 1; | ||
630 | } | 682 | } |
631 | 683 | ||
632 | int | 684 | int |
@@ -910,16 +962,29 @@ lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) | |||
910 | uint32_t hbqno; | 962 | uint32_t hbqno; |
911 | void *virt; /* virtual address ptr */ | 963 | void *virt; /* virtual address ptr */ |
912 | dma_addr_t phys; /* mapped address */ | 964 | dma_addr_t phys; /* mapped address */ |
965 | unsigned long flags; | ||
966 | |||
967 | /* Check whether HBQ is still in use */ | ||
968 | spin_lock_irqsave(&phba->hbalock, flags); | ||
969 | if (!phba->hbq_in_use) { | ||
970 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
971 | return NULL; | ||
972 | } | ||
913 | 973 | ||
914 | hbq_entry = lpfc_sli_hbqbuf_find(phba, tag); | 974 | hbq_entry = lpfc_sli_hbqbuf_find(phba, tag); |
915 | if (hbq_entry == NULL) | 975 | if (hbq_entry == NULL) { |
976 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
916 | return NULL; | 977 | return NULL; |
978 | } | ||
917 | list_del(&hbq_entry->dbuf.list); | 979 | list_del(&hbq_entry->dbuf.list); |
918 | 980 | ||
919 | hbqno = tag >> 16; | 981 | hbqno = tag >> 16; |
920 | new_hbq_entry = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | 982 | new_hbq_entry = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); |
921 | if (new_hbq_entry == NULL) | 983 | if (new_hbq_entry == NULL) { |
984 | list_add_tail(&hbq_entry->dbuf.list, &phba->hbqbuf_in_list); | ||
985 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
922 | return &hbq_entry->dbuf; | 986 | return &hbq_entry->dbuf; |
987 | } | ||
923 | new_hbq_entry->tag = -1; | 988 | new_hbq_entry->tag = -1; |
924 | phys = new_hbq_entry->dbuf.phys; | 989 | phys = new_hbq_entry->dbuf.phys; |
925 | virt = new_hbq_entry->dbuf.virt; | 990 | virt = new_hbq_entry->dbuf.virt; |
@@ -928,6 +993,9 @@ lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) | |||
928 | hbq_entry->dbuf.phys = phys; | 993 | hbq_entry->dbuf.phys = phys; |
929 | hbq_entry->dbuf.virt = virt; | 994 | hbq_entry->dbuf.virt = virt; |
930 | lpfc_sli_free_hbq(phba, hbq_entry); | 995 | lpfc_sli_free_hbq(phba, hbq_entry); |
996 | list_add_tail(&new_hbq_entry->dbuf.list, &phba->hbqbuf_in_list); | ||
997 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
998 | |||
931 | return &new_hbq_entry->dbuf; | 999 | return &new_hbq_entry->dbuf; |
932 | } | 1000 | } |
933 | 1001 | ||
@@ -951,6 +1019,7 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
951 | uint32_t Rctl, Type; | 1019 | uint32_t Rctl, Type; |
952 | uint32_t match, i; | 1020 | uint32_t match, i; |
953 | struct lpfc_iocbq *iocbq; | 1021 | struct lpfc_iocbq *iocbq; |
1022 | struct lpfc_dmabuf *dmzbuf; | ||
954 | 1023 | ||
955 | match = 0; | 1024 | match = 0; |
956 | irsp = &(saveq->iocb); | 1025 | irsp = &(saveq->iocb); |
@@ -972,6 +1041,29 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
972 | return 1; | 1041 | return 1; |
973 | } | 1042 | } |
974 | 1043 | ||
1044 | if ((irsp->ulpCommand == CMD_IOCB_RET_XRI64_CX) && | ||
1045 | (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) { | ||
1046 | if (irsp->ulpBdeCount > 0) { | ||
1047 | dmzbuf = lpfc_sli_get_buff(phba, pring, | ||
1048 | irsp->un.ulpWord[3]); | ||
1049 | lpfc_in_buf_free(phba, dmzbuf); | ||
1050 | } | ||
1051 | |||
1052 | if (irsp->ulpBdeCount > 1) { | ||
1053 | dmzbuf = lpfc_sli_get_buff(phba, pring, | ||
1054 | irsp->unsli3.sli3Words[3]); | ||
1055 | lpfc_in_buf_free(phba, dmzbuf); | ||
1056 | } | ||
1057 | |||
1058 | if (irsp->ulpBdeCount > 2) { | ||
1059 | dmzbuf = lpfc_sli_get_buff(phba, pring, | ||
1060 | irsp->unsli3.sli3Words[7]); | ||
1061 | lpfc_in_buf_free(phba, dmzbuf); | ||
1062 | } | ||
1063 | |||
1064 | return 1; | ||
1065 | } | ||
1066 | |||
975 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { | 1067 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
976 | if (irsp->ulpBdeCount != 0) { | 1068 | if (irsp->ulpBdeCount != 0) { |
977 | saveq->context2 = lpfc_sli_get_buff(phba, pring, | 1069 | saveq->context2 = lpfc_sli_get_buff(phba, pring, |
@@ -2293,6 +2385,7 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba) | |||
2293 | 2385 | ||
2294 | /* Initialize the struct lpfc_sli_hbq structure for each hbq */ | 2386 | /* Initialize the struct lpfc_sli_hbq structure for each hbq */ |
2295 | phba->link_state = LPFC_INIT_MBX_CMDS; | 2387 | phba->link_state = LPFC_INIT_MBX_CMDS; |
2388 | phba->hbq_in_use = 1; | ||
2296 | 2389 | ||
2297 | hbq_entry_index = 0; | 2390 | hbq_entry_index = 0; |
2298 | for (hbqno = 0; hbqno < hbq_count; ++hbqno) { | 2391 | for (hbqno = 0; hbqno < hbq_count; ++hbqno) { |
@@ -2404,9 +2497,7 @@ lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode) | |||
2404 | if ((pmb->mb.un.varCfgPort.sli_mode == 3) && | 2497 | if ((pmb->mb.un.varCfgPort.sli_mode == 3) && |
2405 | (!pmb->mb.un.varCfgPort.cMA)) { | 2498 | (!pmb->mb.un.varCfgPort.cMA)) { |
2406 | rc = -ENXIO; | 2499 | rc = -ENXIO; |
2407 | goto do_prep_failed; | ||
2408 | } | 2500 | } |
2409 | return rc; | ||
2410 | 2501 | ||
2411 | do_prep_failed: | 2502 | do_prep_failed: |
2412 | mempool_free(pmb, phba->mbox_mem_pool); | 2503 | mempool_free(pmb, phba->mbox_mem_pool); |
@@ -2625,14 +2716,14 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag) | |||
2625 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); | 2716 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); |
2626 | 2717 | ||
2627 | /* Mbox command <mbxCommand> cannot issue */ | 2718 | /* Mbox command <mbxCommand> cannot issue */ |
2628 | LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag) | 2719 | LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag); |
2629 | return MBX_NOT_FINISHED; | 2720 | return MBX_NOT_FINISHED; |
2630 | } | 2721 | } |
2631 | 2722 | ||
2632 | if (mb->mbxCommand != MBX_KILL_BOARD && flag & MBX_NOWAIT && | 2723 | if (mb->mbxCommand != MBX_KILL_BOARD && flag & MBX_NOWAIT && |
2633 | !(readl(phba->HCregaddr) & HC_MBINT_ENA)) { | 2724 | !(readl(phba->HCregaddr) & HC_MBINT_ENA)) { |
2634 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); | 2725 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); |
2635 | LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag) | 2726 | LOG_MBOX_CANNOT_ISSUE_DATA(phba, pmbox, psli, flag); |
2636 | return MBX_NOT_FINISHED; | 2727 | return MBX_NOT_FINISHED; |
2637 | } | 2728 | } |
2638 | 2729 | ||
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h index 4b633d39a82a..ca540d1d041e 100644 --- a/drivers/scsi/lpfc/lpfc_version.h +++ b/drivers/scsi/lpfc/lpfc_version.h | |||
@@ -18,7 +18,7 @@ | |||
18 | * included with this package. * | 18 | * included with this package. * |
19 | *******************************************************************/ | 19 | *******************************************************************/ |
20 | 20 | ||
21 | #define LPFC_DRIVER_VERSION "8.2.4" | 21 | #define LPFC_DRIVER_VERSION "8.2.5" |
22 | 22 | ||
23 | #define LPFC_DRIVER_NAME "lpfc" | 23 | #define LPFC_DRIVER_NAME "lpfc" |
24 | 24 | ||
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c index 9fad7663c117..86d05beb00b8 100644 --- a/drivers/scsi/lpfc/lpfc_vport.c +++ b/drivers/scsi/lpfc/lpfc_vport.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2006 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -327,7 +327,8 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable) | |||
327 | * up and ready to FDISC. | 327 | * up and ready to FDISC. |
328 | */ | 328 | */ |
329 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); | 329 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); |
330 | if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { | 330 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
331 | ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { | ||
331 | if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) { | 332 | if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) { |
332 | lpfc_set_disctmo(vport); | 333 | lpfc_set_disctmo(vport); |
333 | lpfc_initial_fdisc(vport); | 334 | lpfc_initial_fdisc(vport); |
@@ -358,7 +359,8 @@ disable_vport(struct fc_vport *fc_vport) | |||
358 | long timeout; | 359 | long timeout; |
359 | 360 | ||
360 | ndlp = lpfc_findnode_did(vport, Fabric_DID); | 361 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
361 | if (ndlp && phba->link_state >= LPFC_LINK_UP) { | 362 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) |
363 | && phba->link_state >= LPFC_LINK_UP) { | ||
362 | vport->unreg_vpi_cmpl = VPORT_INVAL; | 364 | vport->unreg_vpi_cmpl = VPORT_INVAL; |
363 | timeout = msecs_to_jiffies(phba->fc_ratov * 2000); | 365 | timeout = msecs_to_jiffies(phba->fc_ratov * 2000); |
364 | if (!lpfc_issue_els_npiv_logo(vport, ndlp)) | 366 | if (!lpfc_issue_els_npiv_logo(vport, ndlp)) |
@@ -372,6 +374,8 @@ disable_vport(struct fc_vport *fc_vport) | |||
372 | * calling lpfc_cleanup_rpis(vport, 1) | 374 | * calling lpfc_cleanup_rpis(vport, 1) |
373 | */ | 375 | */ |
374 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { | 376 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
377 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
378 | continue; | ||
375 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) | 379 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
376 | continue; | 380 | continue; |
377 | lpfc_disc_state_machine(vport, ndlp, NULL, | 381 | lpfc_disc_state_machine(vport, ndlp, NULL, |
@@ -414,7 +418,8 @@ enable_vport(struct fc_vport *fc_vport) | |||
414 | * up and ready to FDISC. | 418 | * up and ready to FDISC. |
415 | */ | 419 | */ |
416 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); | 420 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); |
417 | if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { | 421 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) |
422 | && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { | ||
418 | if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) { | 423 | if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) { |
419 | lpfc_set_disctmo(vport); | 424 | lpfc_set_disctmo(vport); |
420 | lpfc_initial_fdisc(vport); | 425 | lpfc_initial_fdisc(vport); |
@@ -498,7 +503,41 @@ lpfc_vport_delete(struct fc_vport *fc_vport) | |||
498 | scsi_remove_host(lpfc_shost_from_vport(vport)); | 503 | scsi_remove_host(lpfc_shost_from_vport(vport)); |
499 | 504 | ||
500 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); | 505 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); |
501 | if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE && | 506 | |
507 | /* In case of driver unload, we shall not perform fabric logo as the | ||
508 | * worker thread already stopped at this stage and, in this case, we | ||
509 | * can safely skip the fabric logo. | ||
510 | */ | ||
511 | if (phba->pport->load_flag & FC_UNLOADING) { | ||
512 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && | ||
513 | ndlp->nlp_state == NLP_STE_UNMAPPED_NODE && | ||
514 | phba->link_state >= LPFC_LINK_UP) { | ||
515 | /* First look for the Fabric ndlp */ | ||
516 | ndlp = lpfc_findnode_did(vport, Fabric_DID); | ||
517 | if (!ndlp) | ||
518 | goto skip_logo; | ||
519 | else if (!NLP_CHK_NODE_ACT(ndlp)) { | ||
520 | ndlp = lpfc_enable_node(vport, ndlp, | ||
521 | NLP_STE_UNUSED_NODE); | ||
522 | if (!ndlp) | ||
523 | goto skip_logo; | ||
524 | } | ||
525 | /* Remove ndlp from vport npld list */ | ||
526 | lpfc_dequeue_node(vport, ndlp); | ||
527 | |||
528 | /* Indicate free memory when release */ | ||
529 | spin_lock_irq(&phba->ndlp_lock); | ||
530 | NLP_SET_FREE_REQ(ndlp); | ||
531 | spin_unlock_irq(&phba->ndlp_lock); | ||
532 | /* Kick off release ndlp when it can be safely done */ | ||
533 | lpfc_nlp_put(ndlp); | ||
534 | } | ||
535 | goto skip_logo; | ||
536 | } | ||
537 | |||
538 | /* Otherwise, we will perform fabric logo as needed */ | ||
539 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && | ||
540 | ndlp->nlp_state == NLP_STE_UNMAPPED_NODE && | ||
502 | phba->link_state >= LPFC_LINK_UP) { | 541 | phba->link_state >= LPFC_LINK_UP) { |
503 | if (vport->cfg_enable_da_id) { | 542 | if (vport->cfg_enable_da_id) { |
504 | timeout = msecs_to_jiffies(phba->fc_ratov * 2000); | 543 | timeout = msecs_to_jiffies(phba->fc_ratov * 2000); |
@@ -519,8 +558,27 @@ lpfc_vport_delete(struct fc_vport *fc_vport) | |||
519 | if (!ndlp) | 558 | if (!ndlp) |
520 | goto skip_logo; | 559 | goto skip_logo; |
521 | lpfc_nlp_init(vport, ndlp, Fabric_DID); | 560 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
561 | /* Indicate free memory when release */ | ||
562 | NLP_SET_FREE_REQ(ndlp); | ||
522 | } else { | 563 | } else { |
564 | if (!NLP_CHK_NODE_ACT(ndlp)) | ||
565 | ndlp = lpfc_enable_node(vport, ndlp, | ||
566 | NLP_STE_UNUSED_NODE); | ||
567 | if (!ndlp) | ||
568 | goto skip_logo; | ||
569 | |||
570 | /* Remove ndlp from vport npld list */ | ||
523 | lpfc_dequeue_node(vport, ndlp); | 571 | lpfc_dequeue_node(vport, ndlp); |
572 | spin_lock_irq(&phba->ndlp_lock); | ||
573 | if (!NLP_CHK_FREE_REQ(ndlp)) | ||
574 | /* Indicate free memory when release */ | ||
575 | NLP_SET_FREE_REQ(ndlp); | ||
576 | else { | ||
577 | /* Skip this if ndlp is already in free mode */ | ||
578 | spin_unlock_irq(&phba->ndlp_lock); | ||
579 | goto skip_logo; | ||
580 | } | ||
581 | spin_unlock_irq(&phba->ndlp_lock); | ||
524 | } | 582 | } |
525 | vport->unreg_vpi_cmpl = VPORT_INVAL; | 583 | vport->unreg_vpi_cmpl = VPORT_INVAL; |
526 | timeout = msecs_to_jiffies(phba->fc_ratov * 2000); | 584 | timeout = msecs_to_jiffies(phba->fc_ratov * 2000); |
@@ -534,9 +592,9 @@ skip_logo: | |||
534 | lpfc_sli_host_down(vport); | 592 | lpfc_sli_host_down(vport); |
535 | 593 | ||
536 | lpfc_stop_vport_timers(vport); | 594 | lpfc_stop_vport_timers(vport); |
537 | lpfc_unreg_all_rpis(vport); | ||
538 | 595 | ||
539 | if (!(phba->pport->load_flag & FC_UNLOADING)) { | 596 | if (!(phba->pport->load_flag & FC_UNLOADING)) { |
597 | lpfc_unreg_all_rpis(vport); | ||
540 | lpfc_unreg_default_rpis(vport); | 598 | lpfc_unreg_default_rpis(vport); |
541 | /* | 599 | /* |
542 | * Completion of unreg_vpi (lpfc_mbx_cmpl_unreg_vpi) | 600 | * Completion of unreg_vpi (lpfc_mbx_cmpl_unreg_vpi) |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 4d59ae8491a4..b135a1ed4b2c 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -151,19 +151,19 @@ mega_setup_mailbox(adapter_t *adapter) | |||
151 | */ | 151 | */ |
152 | if( adapter->flag & BOARD_IOMAP ) { | 152 | if( adapter->flag & BOARD_IOMAP ) { |
153 | 153 | ||
154 | outb_p(adapter->mbox_dma & 0xFF, | 154 | outb(adapter->mbox_dma & 0xFF, |
155 | adapter->host->io_port + MBOX_PORT0); | 155 | adapter->host->io_port + MBOX_PORT0); |
156 | 156 | ||
157 | outb_p((adapter->mbox_dma >> 8) & 0xFF, | 157 | outb((adapter->mbox_dma >> 8) & 0xFF, |
158 | adapter->host->io_port + MBOX_PORT1); | 158 | adapter->host->io_port + MBOX_PORT1); |
159 | 159 | ||
160 | outb_p((adapter->mbox_dma >> 16) & 0xFF, | 160 | outb((adapter->mbox_dma >> 16) & 0xFF, |
161 | adapter->host->io_port + MBOX_PORT2); | 161 | adapter->host->io_port + MBOX_PORT2); |
162 | 162 | ||
163 | outb_p((adapter->mbox_dma >> 24) & 0xFF, | 163 | outb((adapter->mbox_dma >> 24) & 0xFF, |
164 | adapter->host->io_port + MBOX_PORT3); | 164 | adapter->host->io_port + MBOX_PORT3); |
165 | 165 | ||
166 | outb_p(ENABLE_MBOX_BYTE, | 166 | outb(ENABLE_MBOX_BYTE, |
167 | adapter->host->io_port + ENABLE_MBOX_REGION); | 167 | adapter->host->io_port + ENABLE_MBOX_REGION); |
168 | 168 | ||
169 | irq_ack(adapter); | 169 | irq_ack(adapter); |
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c index b6587a6d8486..0ad215e27b83 100644 --- a/drivers/scsi/megaraid/megaraid_mm.c +++ b/drivers/scsi/megaraid/megaraid_mm.c | |||
@@ -59,7 +59,6 @@ EXPORT_SYMBOL(mraid_mm_register_adp); | |||
59 | EXPORT_SYMBOL(mraid_mm_unregister_adp); | 59 | EXPORT_SYMBOL(mraid_mm_unregister_adp); |
60 | EXPORT_SYMBOL(mraid_mm_adapter_app_handle); | 60 | EXPORT_SYMBOL(mraid_mm_adapter_app_handle); |
61 | 61 | ||
62 | static int majorno; | ||
63 | static uint32_t drvr_ver = 0x02200207; | 62 | static uint32_t drvr_ver = 0x02200207; |
64 | 63 | ||
65 | static int adapters_count_g; | 64 | static int adapters_count_g; |
@@ -76,6 +75,12 @@ static const struct file_operations lsi_fops = { | |||
76 | .owner = THIS_MODULE, | 75 | .owner = THIS_MODULE, |
77 | }; | 76 | }; |
78 | 77 | ||
78 | static struct miscdevice megaraid_mm_dev = { | ||
79 | .minor = MISC_DYNAMIC_MINOR, | ||
80 | .name = "megadev0", | ||
81 | .fops = &lsi_fops, | ||
82 | }; | ||
83 | |||
79 | /** | 84 | /** |
80 | * mraid_mm_open - open routine for char node interface | 85 | * mraid_mm_open - open routine for char node interface |
81 | * @inode : unused | 86 | * @inode : unused |
@@ -1184,15 +1189,16 @@ mraid_mm_teardown_dma_pools(mraid_mmadp_t *adp) | |||
1184 | static int __init | 1189 | static int __init |
1185 | mraid_mm_init(void) | 1190 | mraid_mm_init(void) |
1186 | { | 1191 | { |
1192 | int err; | ||
1193 | |||
1187 | // Announce the driver version | 1194 | // Announce the driver version |
1188 | con_log(CL_ANN, (KERN_INFO "megaraid cmm: %s %s\n", | 1195 | con_log(CL_ANN, (KERN_INFO "megaraid cmm: %s %s\n", |
1189 | LSI_COMMON_MOD_VERSION, LSI_COMMON_MOD_EXT_VERSION)); | 1196 | LSI_COMMON_MOD_VERSION, LSI_COMMON_MOD_EXT_VERSION)); |
1190 | 1197 | ||
1191 | majorno = register_chrdev(0, "megadev", &lsi_fops); | 1198 | err = misc_register(&megaraid_mm_dev); |
1192 | 1199 | if (err < 0) { | |
1193 | if (majorno < 0) { | 1200 | con_log(CL_ANN, ("megaraid cmm: cannot register misc device\n")); |
1194 | con_log(CL_ANN, ("megaraid cmm: cannot get major\n")); | 1201 | return err; |
1195 | return majorno; | ||
1196 | } | 1202 | } |
1197 | 1203 | ||
1198 | init_waitqueue_head(&wait_q); | 1204 | init_waitqueue_head(&wait_q); |
@@ -1230,7 +1236,7 @@ mraid_mm_exit(void) | |||
1230 | { | 1236 | { |
1231 | con_log(CL_DLEVEL1 , ("exiting common mod\n")); | 1237 | con_log(CL_DLEVEL1 , ("exiting common mod\n")); |
1232 | 1238 | ||
1233 | unregister_chrdev(majorno, "megadev"); | 1239 | misc_deregister(&megaraid_mm_dev); |
1234 | } | 1240 | } |
1235 | 1241 | ||
1236 | module_init(mraid_mm_init); | 1242 | module_init(mraid_mm_init); |
diff --git a/drivers/scsi/megaraid/megaraid_mm.h b/drivers/scsi/megaraid/megaraid_mm.h index c8762b2b8ed1..55b425c0a654 100644 --- a/drivers/scsi/megaraid/megaraid_mm.h +++ b/drivers/scsi/megaraid/megaraid_mm.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/moduleparam.h> | 22 | #include <linux/moduleparam.h> |
23 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <linux/miscdevice.h> | ||
25 | 26 | ||
26 | #include "mbox_defs.h" | 27 | #include "mbox_defs.h" |
27 | #include "megaraid_ioctl.h" | 28 | #include "megaraid_ioctl.h" |
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index 651d09b08f2a..fd63b06d9ef1 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c | |||
@@ -1759,6 +1759,7 @@ static int mesh_suspend(struct macio_dev *mdev, pm_message_t mesg) | |||
1759 | 1759 | ||
1760 | switch (mesg.event) { | 1760 | switch (mesg.event) { |
1761 | case PM_EVENT_SUSPEND: | 1761 | case PM_EVENT_SUSPEND: |
1762 | case PM_EVENT_HIBERNATE: | ||
1762 | case PM_EVENT_FREEZE: | 1763 | case PM_EVENT_FREEZE: |
1763 | break; | 1764 | break; |
1764 | default: | 1765 | default: |
diff --git a/drivers/scsi/mvsas.c b/drivers/scsi/mvsas.c new file mode 100644 index 000000000000..d4a6ac3c9c47 --- /dev/null +++ b/drivers/scsi/mvsas.c | |||
@@ -0,0 +1,2970 @@ | |||
1 | /* | ||
2 | mvsas.c - Marvell 88SE6440 SAS/SATA support | ||
3 | |||
4 | Copyright 2007 Red Hat, Inc. | ||
5 | Copyright 2008 Marvell. <kewei@marvell.com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or | ||
8 | modify it under the terms of the GNU General Public License as | ||
9 | published by the Free Software Foundation; either version 2, | ||
10 | or (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty | ||
14 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
15 | See the GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public | ||
18 | License along with this program; see the file COPYING. If not, | ||
19 | write to the Free Software Foundation, 675 Mass Ave, Cambridge, | ||
20 | MA 02139, USA. | ||
21 | |||
22 | --------------------------------------------------------------- | ||
23 | |||
24 | Random notes: | ||
25 | * hardware supports controlling the endian-ness of data | ||
26 | structures. this permits elimination of all the le32_to_cpu() | ||
27 | and cpu_to_le32() conversions. | ||
28 | |||
29 | */ | ||
30 | |||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/module.h> | ||
33 | #include <linux/pci.h> | ||
34 | #include <linux/interrupt.h> | ||
35 | #include <linux/spinlock.h> | ||
36 | #include <linux/delay.h> | ||
37 | #include <linux/dma-mapping.h> | ||
38 | #include <linux/ctype.h> | ||
39 | #include <scsi/libsas.h> | ||
40 | #include <asm/io.h> | ||
41 | |||
42 | #define DRV_NAME "mvsas" | ||
43 | #define DRV_VERSION "0.5" | ||
44 | #define _MV_DUMP 0 | ||
45 | #define MVS_DISABLE_NVRAM | ||
46 | #define MVS_DISABLE_MSI | ||
47 | |||
48 | #define mr32(reg) readl(regs + MVS_##reg) | ||
49 | #define mw32(reg,val) writel((val), regs + MVS_##reg) | ||
50 | #define mw32_f(reg,val) do { \ | ||
51 | writel((val), regs + MVS_##reg); \ | ||
52 | readl(regs + MVS_##reg); \ | ||
53 | } while (0) | ||
54 | |||
55 | #define MVS_ID_NOT_MAPPED 0xff | ||
56 | #define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width) | ||
57 | |||
58 | /* offset for D2H FIS in the Received FIS List Structure */ | ||
59 | #define SATA_RECEIVED_D2H_FIS(reg_set) \ | ||
60 | ((void *) mvi->rx_fis + 0x400 + 0x100 * reg_set + 0x40) | ||
61 | #define SATA_RECEIVED_PIO_FIS(reg_set) \ | ||
62 | ((void *) mvi->rx_fis + 0x400 + 0x100 * reg_set + 0x20) | ||
63 | #define UNASSOC_D2H_FIS(id) \ | ||
64 | ((void *) mvi->rx_fis + 0x100 * id) | ||
65 | |||
66 | #define for_each_phy(__lseq_mask, __mc, __lseq, __rest) \ | ||
67 | for ((__mc) = (__lseq_mask), (__lseq) = 0; \ | ||
68 | (__mc) != 0 && __rest; \ | ||
69 | (++__lseq), (__mc) >>= 1) | ||
70 | |||
71 | /* driver compile-time configuration */ | ||
72 | enum driver_configuration { | ||
73 | MVS_TX_RING_SZ = 1024, /* TX ring size (12-bit) */ | ||
74 | MVS_RX_RING_SZ = 1024, /* RX ring size (12-bit) */ | ||
75 | /* software requires power-of-2 | ||
76 | ring size */ | ||
77 | |||
78 | MVS_SLOTS = 512, /* command slots */ | ||
79 | MVS_SLOT_BUF_SZ = 8192, /* cmd tbl + IU + status + PRD */ | ||
80 | MVS_SSP_CMD_SZ = 64, /* SSP command table buffer size */ | ||
81 | MVS_ATA_CMD_SZ = 96, /* SATA command table buffer size */ | ||
82 | MVS_OAF_SZ = 64, /* Open address frame buffer size */ | ||
83 | |||
84 | MVS_RX_FIS_COUNT = 17, /* Optional rx'd FISs (max 17) */ | ||
85 | |||
86 | MVS_QUEUE_SIZE = 30, /* Support Queue depth */ | ||
87 | }; | ||
88 | |||
89 | /* unchangeable hardware details */ | ||
90 | enum hardware_details { | ||
91 | MVS_MAX_PHYS = 8, /* max. possible phys */ | ||
92 | MVS_MAX_PORTS = 8, /* max. possible ports */ | ||
93 | MVS_RX_FISL_SZ = 0x400 + (MVS_RX_FIS_COUNT * 0x100), | ||
94 | }; | ||
95 | |||
96 | /* peripheral registers (BAR2) */ | ||
97 | enum peripheral_registers { | ||
98 | SPI_CTL = 0x10, /* EEPROM control */ | ||
99 | SPI_CMD = 0x14, /* EEPROM command */ | ||
100 | SPI_DATA = 0x18, /* EEPROM data */ | ||
101 | }; | ||
102 | |||
103 | enum peripheral_register_bits { | ||
104 | TWSI_RDY = (1U << 7), /* EEPROM interface ready */ | ||
105 | TWSI_RD = (1U << 4), /* EEPROM read access */ | ||
106 | |||
107 | SPI_ADDR_MASK = 0x3ffff, /* bits 17:0 */ | ||
108 | }; | ||
109 | |||
110 | /* enhanced mode registers (BAR4) */ | ||
111 | enum hw_registers { | ||
112 | MVS_GBL_CTL = 0x04, /* global control */ | ||
113 | MVS_GBL_INT_STAT = 0x08, /* global irq status */ | ||
114 | MVS_GBL_PI = 0x0C, /* ports implemented bitmask */ | ||
115 | MVS_GBL_PORT_TYPE = 0xa0, /* port type */ | ||
116 | |||
117 | MVS_CTL = 0x100, /* SAS/SATA port configuration */ | ||
118 | MVS_PCS = 0x104, /* SAS/SATA port control/status */ | ||
119 | MVS_CMD_LIST_LO = 0x108, /* cmd list addr */ | ||
120 | MVS_CMD_LIST_HI = 0x10C, | ||
121 | MVS_RX_FIS_LO = 0x110, /* RX FIS list addr */ | ||
122 | MVS_RX_FIS_HI = 0x114, | ||
123 | |||
124 | MVS_TX_CFG = 0x120, /* TX configuration */ | ||
125 | MVS_TX_LO = 0x124, /* TX (delivery) ring addr */ | ||
126 | MVS_TX_HI = 0x128, | ||
127 | |||
128 | MVS_TX_PROD_IDX = 0x12C, /* TX producer pointer */ | ||
129 | MVS_TX_CONS_IDX = 0x130, /* TX consumer pointer (RO) */ | ||
130 | MVS_RX_CFG = 0x134, /* RX configuration */ | ||
131 | MVS_RX_LO = 0x138, /* RX (completion) ring addr */ | ||
132 | MVS_RX_HI = 0x13C, | ||
133 | MVS_RX_CONS_IDX = 0x140, /* RX consumer pointer (RO) */ | ||
134 | |||
135 | MVS_INT_COAL = 0x148, /* Int coalescing config */ | ||
136 | MVS_INT_COAL_TMOUT = 0x14C, /* Int coalescing timeout */ | ||
137 | MVS_INT_STAT = 0x150, /* Central int status */ | ||
138 | MVS_INT_MASK = 0x154, /* Central int enable */ | ||
139 | MVS_INT_STAT_SRS = 0x158, /* SATA register set status */ | ||
140 | MVS_INT_MASK_SRS = 0x15C, | ||
141 | |||
142 | /* ports 1-3 follow after this */ | ||
143 | MVS_P0_INT_STAT = 0x160, /* port0 interrupt status */ | ||
144 | MVS_P0_INT_MASK = 0x164, /* port0 interrupt mask */ | ||
145 | MVS_P4_INT_STAT = 0x200, /* Port 4 interrupt status */ | ||
146 | MVS_P4_INT_MASK = 0x204, /* Port 4 interrupt enable mask */ | ||
147 | |||
148 | /* ports 1-3 follow after this */ | ||
149 | MVS_P0_SER_CTLSTAT = 0x180, /* port0 serial control/status */ | ||
150 | MVS_P4_SER_CTLSTAT = 0x220, /* port4 serial control/status */ | ||
151 | |||
152 | MVS_CMD_ADDR = 0x1B8, /* Command register port (addr) */ | ||
153 | MVS_CMD_DATA = 0x1BC, /* Command register port (data) */ | ||
154 | |||
155 | /* ports 1-3 follow after this */ | ||
156 | MVS_P0_CFG_ADDR = 0x1C0, /* port0 phy register address */ | ||
157 | MVS_P0_CFG_DATA = 0x1C4, /* port0 phy register data */ | ||
158 | MVS_P4_CFG_ADDR = 0x230, /* Port 4 config address */ | ||
159 | MVS_P4_CFG_DATA = 0x234, /* Port 4 config data */ | ||
160 | |||
161 | /* ports 1-3 follow after this */ | ||
162 | MVS_P0_VSR_ADDR = 0x1E0, /* port0 VSR address */ | ||
163 | MVS_P0_VSR_DATA = 0x1E4, /* port0 VSR data */ | ||
164 | MVS_P4_VSR_ADDR = 0x250, /* port 4 VSR addr */ | ||
165 | MVS_P4_VSR_DATA = 0x254, /* port 4 VSR data */ | ||
166 | }; | ||
167 | |||
168 | enum hw_register_bits { | ||
169 | /* MVS_GBL_CTL */ | ||
170 | INT_EN = (1U << 1), /* Global int enable */ | ||
171 | HBA_RST = (1U << 0), /* HBA reset */ | ||
172 | |||
173 | /* MVS_GBL_INT_STAT */ | ||
174 | INT_XOR = (1U << 4), /* XOR engine event */ | ||
175 | INT_SAS_SATA = (1U << 0), /* SAS/SATA event */ | ||
176 | |||
177 | /* MVS_GBL_PORT_TYPE */ /* shl for ports 1-3 */ | ||
178 | SATA_TARGET = (1U << 16), /* port0 SATA target enable */ | ||
179 | MODE_AUTO_DET_PORT7 = (1U << 15), /* port0 SAS/SATA autodetect */ | ||
180 | MODE_AUTO_DET_PORT6 = (1U << 14), | ||
181 | MODE_AUTO_DET_PORT5 = (1U << 13), | ||
182 | MODE_AUTO_DET_PORT4 = (1U << 12), | ||
183 | MODE_AUTO_DET_PORT3 = (1U << 11), | ||
184 | MODE_AUTO_DET_PORT2 = (1U << 10), | ||
185 | MODE_AUTO_DET_PORT1 = (1U << 9), | ||
186 | MODE_AUTO_DET_PORT0 = (1U << 8), | ||
187 | MODE_AUTO_DET_EN = MODE_AUTO_DET_PORT0 | MODE_AUTO_DET_PORT1 | | ||
188 | MODE_AUTO_DET_PORT2 | MODE_AUTO_DET_PORT3 | | ||
189 | MODE_AUTO_DET_PORT4 | MODE_AUTO_DET_PORT5 | | ||
190 | MODE_AUTO_DET_PORT6 | MODE_AUTO_DET_PORT7, | ||
191 | MODE_SAS_PORT7_MASK = (1U << 7), /* port0 SAS(1), SATA(0) mode */ | ||
192 | MODE_SAS_PORT6_MASK = (1U << 6), | ||
193 | MODE_SAS_PORT5_MASK = (1U << 5), | ||
194 | MODE_SAS_PORT4_MASK = (1U << 4), | ||
195 | MODE_SAS_PORT3_MASK = (1U << 3), | ||
196 | MODE_SAS_PORT2_MASK = (1U << 2), | ||
197 | MODE_SAS_PORT1_MASK = (1U << 1), | ||
198 | MODE_SAS_PORT0_MASK = (1U << 0), | ||
199 | MODE_SAS_SATA = MODE_SAS_PORT0_MASK | MODE_SAS_PORT1_MASK | | ||
200 | MODE_SAS_PORT2_MASK | MODE_SAS_PORT3_MASK | | ||
201 | MODE_SAS_PORT4_MASK | MODE_SAS_PORT5_MASK | | ||
202 | MODE_SAS_PORT6_MASK | MODE_SAS_PORT7_MASK, | ||
203 | |||
204 | /* SAS_MODE value may be | ||
205 | * dictated (in hw) by values | ||
206 | * of SATA_TARGET & AUTO_DET | ||
207 | */ | ||
208 | |||
209 | /* MVS_TX_CFG */ | ||
210 | TX_EN = (1U << 16), /* Enable TX */ | ||
211 | TX_RING_SZ_MASK = 0xfff, /* TX ring size, bits 11:0 */ | ||
212 | |||
213 | /* MVS_RX_CFG */ | ||
214 | RX_EN = (1U << 16), /* Enable RX */ | ||
215 | RX_RING_SZ_MASK = 0xfff, /* RX ring size, bits 11:0 */ | ||
216 | |||
217 | /* MVS_INT_COAL */ | ||
218 | COAL_EN = (1U << 16), /* Enable int coalescing */ | ||
219 | |||
220 | /* MVS_INT_STAT, MVS_INT_MASK */ | ||
221 | CINT_I2C = (1U << 31), /* I2C event */ | ||
222 | CINT_SW0 = (1U << 30), /* software event 0 */ | ||
223 | CINT_SW1 = (1U << 29), /* software event 1 */ | ||
224 | CINT_PRD_BC = (1U << 28), /* PRD BC err for read cmd */ | ||
225 | CINT_DMA_PCIE = (1U << 27), /* DMA to PCIE timeout */ | ||
226 | CINT_MEM = (1U << 26), /* int mem parity err */ | ||
227 | CINT_I2C_SLAVE = (1U << 25), /* slave I2C event */ | ||
228 | CINT_SRS = (1U << 3), /* SRS event */ | ||
229 | CINT_CI_STOP = (1U << 1), /* cmd issue stopped */ | ||
230 | CINT_DONE = (1U << 0), /* cmd completion */ | ||
231 | |||
232 | /* shl for ports 1-3 */ | ||
233 | CINT_PORT_STOPPED = (1U << 16), /* port0 stopped */ | ||
234 | CINT_PORT = (1U << 8), /* port0 event */ | ||
235 | CINT_PORT_MASK_OFFSET = 8, | ||
236 | CINT_PORT_MASK = (0xFF << CINT_PORT_MASK_OFFSET), | ||
237 | |||
238 | /* TX (delivery) ring bits */ | ||
239 | TXQ_CMD_SHIFT = 29, | ||
240 | TXQ_CMD_SSP = 1, /* SSP protocol */ | ||
241 | TXQ_CMD_SMP = 2, /* SMP protocol */ | ||
242 | TXQ_CMD_STP = 3, /* STP/SATA protocol */ | ||
243 | TXQ_CMD_SSP_FREE_LIST = 4, /* add to SSP targ free list */ | ||
244 | TXQ_CMD_SLOT_RESET = 7, /* reset command slot */ | ||
245 | TXQ_MODE_I = (1U << 28), /* mode: 0=target,1=initiator */ | ||
246 | TXQ_PRIO_HI = (1U << 27), /* priority: 0=normal, 1=high */ | ||
247 | TXQ_SRS_SHIFT = 20, /* SATA register set */ | ||
248 | TXQ_SRS_MASK = 0x7f, | ||
249 | TXQ_PHY_SHIFT = 12, /* PHY bitmap */ | ||
250 | TXQ_PHY_MASK = 0xff, | ||
251 | TXQ_SLOT_MASK = 0xfff, /* slot number */ | ||
252 | |||
253 | /* RX (completion) ring bits */ | ||
254 | RXQ_GOOD = (1U << 23), /* Response good */ | ||
255 | RXQ_SLOT_RESET = (1U << 21), /* Slot reset complete */ | ||
256 | RXQ_CMD_RX = (1U << 20), /* target cmd received */ | ||
257 | RXQ_ATTN = (1U << 19), /* attention */ | ||
258 | RXQ_RSP = (1U << 18), /* response frame xfer'd */ | ||
259 | RXQ_ERR = (1U << 17), /* err info rec xfer'd */ | ||
260 | RXQ_DONE = (1U << 16), /* cmd complete */ | ||
261 | RXQ_SLOT_MASK = 0xfff, /* slot number */ | ||
262 | |||
263 | /* mvs_cmd_hdr bits */ | ||
264 | MCH_PRD_LEN_SHIFT = 16, /* 16-bit PRD table len */ | ||
265 | MCH_SSP_FR_TYPE_SHIFT = 13, /* SSP frame type */ | ||
266 | |||
267 | /* SSP initiator only */ | ||
268 | MCH_SSP_FR_CMD = 0x0, /* COMMAND frame */ | ||
269 | |||
270 | /* SSP initiator or target */ | ||
271 | MCH_SSP_FR_TASK = 0x1, /* TASK frame */ | ||
272 | |||
273 | /* SSP target only */ | ||
274 | MCH_SSP_FR_XFER_RDY = 0x4, /* XFER_RDY frame */ | ||
275 | MCH_SSP_FR_RESP = 0x5, /* RESPONSE frame */ | ||
276 | MCH_SSP_FR_READ = 0x6, /* Read DATA frame(s) */ | ||
277 | MCH_SSP_FR_READ_RESP = 0x7, /* ditto, plus RESPONSE */ | ||
278 | |||
279 | MCH_PASSTHRU = (1U << 12), /* pass-through (SSP) */ | ||
280 | MCH_FBURST = (1U << 11), /* first burst (SSP) */ | ||
281 | MCH_CHK_LEN = (1U << 10), /* chk xfer len (SSP) */ | ||
282 | MCH_RETRY = (1U << 9), /* tport layer retry (SSP) */ | ||
283 | MCH_PROTECTION = (1U << 8), /* protection info rec (SSP) */ | ||
284 | MCH_RESET = (1U << 7), /* Reset (STP/SATA) */ | ||
285 | MCH_FPDMA = (1U << 6), /* First party DMA (STP/SATA) */ | ||
286 | MCH_ATAPI = (1U << 5), /* ATAPI (STP/SATA) */ | ||
287 | MCH_BIST = (1U << 4), /* BIST activate (STP/SATA) */ | ||
288 | MCH_PMP_MASK = 0xf, /* PMP from cmd FIS (STP/SATA)*/ | ||
289 | |||
290 | CCTL_RST = (1U << 5), /* port logic reset */ | ||
291 | |||
292 | /* 0(LSB first), 1(MSB first) */ | ||
293 | CCTL_ENDIAN_DATA = (1U << 3), /* PRD data */ | ||
294 | CCTL_ENDIAN_RSP = (1U << 2), /* response frame */ | ||
295 | CCTL_ENDIAN_OPEN = (1U << 1), /* open address frame */ | ||
296 | CCTL_ENDIAN_CMD = (1U << 0), /* command table */ | ||
297 | |||
298 | /* MVS_Px_SER_CTLSTAT (per-phy control) */ | ||
299 | PHY_SSP_RST = (1U << 3), /* reset SSP link layer */ | ||
300 | PHY_BCAST_CHG = (1U << 2), /* broadcast(change) notif */ | ||
301 | PHY_RST_HARD = (1U << 1), /* hard reset + phy reset */ | ||
302 | PHY_RST = (1U << 0), /* phy reset */ | ||
303 | PHY_MIN_SPP_PHYS_LINK_RATE_MASK = (0xF << 8), | ||
304 | PHY_MAX_SPP_PHYS_LINK_RATE_MASK = (0xF << 12), | ||
305 | PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET = (16), | ||
306 | PHY_NEG_SPP_PHYS_LINK_RATE_MASK = | ||
307 | (0xF << PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET), | ||
308 | PHY_READY_MASK = (1U << 20), | ||
309 | |||
310 | /* MVS_Px_INT_STAT, MVS_Px_INT_MASK (per-phy events) */ | ||
311 | PHYEV_DEC_ERR = (1U << 24), /* Phy Decoding Error */ | ||
312 | PHYEV_UNASSOC_FIS = (1U << 19), /* unassociated FIS rx'd */ | ||
313 | PHYEV_AN = (1U << 18), /* SATA async notification */ | ||
314 | PHYEV_BIST_ACT = (1U << 17), /* BIST activate FIS */ | ||
315 | PHYEV_SIG_FIS = (1U << 16), /* signature FIS */ | ||
316 | PHYEV_POOF = (1U << 12), /* phy ready from 1 -> 0 */ | ||
317 | PHYEV_IU_BIG = (1U << 11), /* IU too long err */ | ||
318 | PHYEV_IU_SMALL = (1U << 10), /* IU too short err */ | ||
319 | PHYEV_UNK_TAG = (1U << 9), /* unknown tag */ | ||
320 | PHYEV_BROAD_CH = (1U << 8), /* broadcast(CHANGE) */ | ||
321 | PHYEV_COMWAKE = (1U << 7), /* COMWAKE rx'd */ | ||
322 | PHYEV_PORT_SEL = (1U << 6), /* port selector present */ | ||
323 | PHYEV_HARD_RST = (1U << 5), /* hard reset rx'd */ | ||
324 | PHYEV_ID_TMOUT = (1U << 4), /* identify timeout */ | ||
325 | PHYEV_ID_FAIL = (1U << 3), /* identify failed */ | ||
326 | PHYEV_ID_DONE = (1U << 2), /* identify done */ | ||
327 | PHYEV_HARD_RST_DONE = (1U << 1), /* hard reset done */ | ||
328 | PHYEV_RDY_CH = (1U << 0), /* phy ready changed state */ | ||
329 | |||
330 | /* MVS_PCS */ | ||
331 | PCS_EN_SATA_REG_SHIFT = (16), /* Enable SATA Register Set */ | ||
332 | PCS_EN_PORT_XMT_SHIFT = (12), /* Enable Port Transmit */ | ||
333 | PCS_EN_PORT_XMT_SHIFT2 = (8), /* For 6480 */ | ||
334 | PCS_SATA_RETRY = (1U << 8), /* retry ctl FIS on R_ERR */ | ||
335 | PCS_RSP_RX_EN = (1U << 7), /* raw response rx */ | ||
336 | PCS_SELF_CLEAR = (1U << 5), /* self-clearing int mode */ | ||
337 | PCS_FIS_RX_EN = (1U << 4), /* FIS rx enable */ | ||
338 | PCS_CMD_STOP_ERR = (1U << 3), /* cmd stop-on-err enable */ | ||
339 | PCS_CMD_RST = (1U << 1), /* reset cmd issue */ | ||
340 | PCS_CMD_EN = (1U << 0), /* enable cmd issue */ | ||
341 | |||
342 | /* Port n Attached Device Info */ | ||
343 | PORT_DEV_SSP_TRGT = (1U << 19), | ||
344 | PORT_DEV_SMP_TRGT = (1U << 18), | ||
345 | PORT_DEV_STP_TRGT = (1U << 17), | ||
346 | PORT_DEV_SSP_INIT = (1U << 11), | ||
347 | PORT_DEV_SMP_INIT = (1U << 10), | ||
348 | PORT_DEV_STP_INIT = (1U << 9), | ||
349 | PORT_PHY_ID_MASK = (0xFFU << 24), | ||
350 | PORT_DEV_TRGT_MASK = (0x7U << 17), | ||
351 | PORT_DEV_INIT_MASK = (0x7U << 9), | ||
352 | PORT_DEV_TYPE_MASK = (0x7U << 0), | ||
353 | |||
354 | /* Port n PHY Status */ | ||
355 | PHY_RDY = (1U << 2), | ||
356 | PHY_DW_SYNC = (1U << 1), | ||
357 | PHY_OOB_DTCTD = (1U << 0), | ||
358 | |||
359 | /* VSR */ | ||
360 | /* PHYMODE 6 (CDB) */ | ||
361 | PHY_MODE6_DTL_SPEED = (1U << 27), | ||
362 | }; | ||
363 | |||
364 | enum mvs_info_flags { | ||
365 | MVF_MSI = (1U << 0), /* MSI is enabled */ | ||
366 | MVF_PHY_PWR_FIX = (1U << 1), /* bug workaround */ | ||
367 | }; | ||
368 | |||
369 | enum sas_cmd_port_registers { | ||
370 | CMD_CMRST_OOB_DET = 0x100, /* COMRESET OOB detect register */ | ||
371 | CMD_CMWK_OOB_DET = 0x104, /* COMWAKE OOB detect register */ | ||
372 | CMD_CMSAS_OOB_DET = 0x108, /* COMSAS OOB detect register */ | ||
373 | CMD_BRST_OOB_DET = 0x10c, /* burst OOB detect register */ | ||
374 | CMD_OOB_SPACE = 0x110, /* OOB space control register */ | ||
375 | CMD_OOB_BURST = 0x114, /* OOB burst control register */ | ||
376 | CMD_PHY_TIMER = 0x118, /* PHY timer control register */ | ||
377 | CMD_PHY_CONFIG0 = 0x11c, /* PHY config register 0 */ | ||
378 | CMD_PHY_CONFIG1 = 0x120, /* PHY config register 1 */ | ||
379 | CMD_SAS_CTL0 = 0x124, /* SAS control register 0 */ | ||
380 | CMD_SAS_CTL1 = 0x128, /* SAS control register 1 */ | ||
381 | CMD_SAS_CTL2 = 0x12c, /* SAS control register 2 */ | ||
382 | CMD_SAS_CTL3 = 0x130, /* SAS control register 3 */ | ||
383 | CMD_ID_TEST = 0x134, /* ID test register */ | ||
384 | CMD_PL_TIMER = 0x138, /* PL timer register */ | ||
385 | CMD_WD_TIMER = 0x13c, /* WD timer register */ | ||
386 | CMD_PORT_SEL_COUNT = 0x140, /* port selector count register */ | ||
387 | CMD_APP_MEM_CTL = 0x144, /* Application Memory Control */ | ||
388 | CMD_XOR_MEM_CTL = 0x148, /* XOR Block Memory Control */ | ||
389 | CMD_DMA_MEM_CTL = 0x14c, /* DMA Block Memory Control */ | ||
390 | CMD_PORT_MEM_CTL0 = 0x150, /* Port Memory Control 0 */ | ||
391 | CMD_PORT_MEM_CTL1 = 0x154, /* Port Memory Control 1 */ | ||
392 | CMD_SATA_PORT_MEM_CTL0 = 0x158, /* SATA Port Memory Control 0 */ | ||
393 | CMD_SATA_PORT_MEM_CTL1 = 0x15c, /* SATA Port Memory Control 1 */ | ||
394 | CMD_XOR_MEM_BIST_CTL = 0x160, /* XOR Memory BIST Control */ | ||
395 | CMD_XOR_MEM_BIST_STAT = 0x164, /* XOR Memroy BIST Status */ | ||
396 | CMD_DMA_MEM_BIST_CTL = 0x168, /* DMA Memory BIST Control */ | ||
397 | CMD_DMA_MEM_BIST_STAT = 0x16c, /* DMA Memory BIST Status */ | ||
398 | CMD_PORT_MEM_BIST_CTL = 0x170, /* Port Memory BIST Control */ | ||
399 | CMD_PORT_MEM_BIST_STAT0 = 0x174, /* Port Memory BIST Status 0 */ | ||
400 | CMD_PORT_MEM_BIST_STAT1 = 0x178, /* Port Memory BIST Status 1 */ | ||
401 | CMD_STP_MEM_BIST_CTL = 0x17c, /* STP Memory BIST Control */ | ||
402 | CMD_STP_MEM_BIST_STAT0 = 0x180, /* STP Memory BIST Status 0 */ | ||
403 | CMD_STP_MEM_BIST_STAT1 = 0x184, /* STP Memory BIST Status 1 */ | ||
404 | CMD_RESET_COUNT = 0x188, /* Reset Count */ | ||
405 | CMD_MONTR_DATA_SEL = 0x18C, /* Monitor Data/Select */ | ||
406 | CMD_PLL_PHY_CONFIG = 0x190, /* PLL/PHY Configuration */ | ||
407 | CMD_PHY_CTL = 0x194, /* PHY Control and Status */ | ||
408 | CMD_PHY_TEST_COUNT0 = 0x198, /* Phy Test Count 0 */ | ||
409 | CMD_PHY_TEST_COUNT1 = 0x19C, /* Phy Test Count 1 */ | ||
410 | CMD_PHY_TEST_COUNT2 = 0x1A0, /* Phy Test Count 2 */ | ||
411 | CMD_APP_ERR_CONFIG = 0x1A4, /* Application Error Configuration */ | ||
412 | CMD_PND_FIFO_CTL0 = 0x1A8, /* Pending FIFO Control 0 */ | ||
413 | CMD_HOST_CTL = 0x1AC, /* Host Control Status */ | ||
414 | CMD_HOST_WR_DATA = 0x1B0, /* Host Write Data */ | ||
415 | CMD_HOST_RD_DATA = 0x1B4, /* Host Read Data */ | ||
416 | CMD_PHY_MODE_21 = 0x1B8, /* Phy Mode 21 */ | ||
417 | CMD_SL_MODE0 = 0x1BC, /* SL Mode 0 */ | ||
418 | CMD_SL_MODE1 = 0x1C0, /* SL Mode 1 */ | ||
419 | CMD_PND_FIFO_CTL1 = 0x1C4, /* Pending FIFO Control 1 */ | ||
420 | }; | ||
421 | |||
422 | /* SAS/SATA configuration port registers, aka phy registers */ | ||
423 | enum sas_sata_config_port_regs { | ||
424 | PHYR_IDENTIFY = 0x00, /* info for IDENTIFY frame */ | ||
425 | PHYR_ADDR_LO = 0x04, /* my SAS address (low) */ | ||
426 | PHYR_ADDR_HI = 0x08, /* my SAS address (high) */ | ||
427 | PHYR_ATT_DEV_INFO = 0x0C, /* attached device info */ | ||
428 | PHYR_ATT_ADDR_LO = 0x10, /* attached dev SAS addr (low) */ | ||
429 | PHYR_ATT_ADDR_HI = 0x14, /* attached dev SAS addr (high) */ | ||
430 | PHYR_SATA_CTL = 0x18, /* SATA control */ | ||
431 | PHYR_PHY_STAT = 0x1C, /* PHY status */ | ||
432 | PHYR_SATA_SIG0 = 0x20, /*port SATA signature FIS(Byte 0-3) */ | ||
433 | PHYR_SATA_SIG1 = 0x24, /*port SATA signature FIS(Byte 4-7) */ | ||
434 | PHYR_SATA_SIG2 = 0x28, /*port SATA signature FIS(Byte 8-11) */ | ||
435 | PHYR_SATA_SIG3 = 0x2c, /*port SATA signature FIS(Byte 12-15) */ | ||
436 | PHYR_R_ERR_COUNT = 0x30, /* port R_ERR count register */ | ||
437 | PHYR_CRC_ERR_COUNT = 0x34, /* port CRC error count register */ | ||
438 | PHYR_WIDE_PORT = 0x38, /* wide port participating */ | ||
439 | PHYR_CURRENT0 = 0x80, /* current connection info 0 */ | ||
440 | PHYR_CURRENT1 = 0x84, /* current connection info 1 */ | ||
441 | PHYR_CURRENT2 = 0x88, /* current connection info 2 */ | ||
442 | }; | ||
443 | |||
444 | /* SAS/SATA Vendor Specific Port Registers */ | ||
445 | enum sas_sata_vsp_regs { | ||
446 | VSR_PHY_STAT = 0x00, /* Phy Status */ | ||
447 | VSR_PHY_MODE1 = 0x01, /* phy tx */ | ||
448 | VSR_PHY_MODE2 = 0x02, /* tx scc */ | ||
449 | VSR_PHY_MODE3 = 0x03, /* pll */ | ||
450 | VSR_PHY_MODE4 = 0x04, /* VCO */ | ||
451 | VSR_PHY_MODE5 = 0x05, /* Rx */ | ||
452 | VSR_PHY_MODE6 = 0x06, /* CDR */ | ||
453 | VSR_PHY_MODE7 = 0x07, /* Impedance */ | ||
454 | VSR_PHY_MODE8 = 0x08, /* Voltage */ | ||
455 | VSR_PHY_MODE9 = 0x09, /* Test */ | ||
456 | VSR_PHY_MODE10 = 0x0A, /* Power */ | ||
457 | VSR_PHY_MODE11 = 0x0B, /* Phy Mode */ | ||
458 | VSR_PHY_VS0 = 0x0C, /* Vednor Specific 0 */ | ||
459 | VSR_PHY_VS1 = 0x0D, /* Vednor Specific 1 */ | ||
460 | }; | ||
461 | |||
462 | enum pci_cfg_registers { | ||
463 | PCR_PHY_CTL = 0x40, | ||
464 | PCR_PHY_CTL2 = 0x90, | ||
465 | PCR_DEV_CTRL = 0xE8, | ||
466 | }; | ||
467 | |||
468 | enum pci_cfg_register_bits { | ||
469 | PCTL_PWR_ON = (0xFU << 24), | ||
470 | PCTL_OFF = (0xFU << 12), | ||
471 | PRD_REQ_SIZE = (0x4000), | ||
472 | PRD_REQ_MASK = (0x00007000), | ||
473 | }; | ||
474 | |||
475 | enum nvram_layout_offsets { | ||
476 | NVR_SIG = 0x00, /* 0xAA, 0x55 */ | ||
477 | NVR_SAS_ADDR = 0x02, /* 8-byte SAS address */ | ||
478 | }; | ||
479 | |||
480 | enum chip_flavors { | ||
481 | chip_6320, | ||
482 | chip_6440, | ||
483 | chip_6480, | ||
484 | }; | ||
485 | |||
486 | enum port_type { | ||
487 | PORT_TYPE_SAS = (1L << 1), | ||
488 | PORT_TYPE_SATA = (1L << 0), | ||
489 | }; | ||
490 | |||
491 | /* Command Table Format */ | ||
492 | enum ct_format { | ||
493 | /* SSP */ | ||
494 | SSP_F_H = 0x00, | ||
495 | SSP_F_IU = 0x18, | ||
496 | SSP_F_MAX = 0x4D, | ||
497 | /* STP */ | ||
498 | STP_CMD_FIS = 0x00, | ||
499 | STP_ATAPI_CMD = 0x40, | ||
500 | STP_F_MAX = 0x10, | ||
501 | /* SMP */ | ||
502 | SMP_F_T = 0x00, | ||
503 | SMP_F_DEP = 0x01, | ||
504 | SMP_F_MAX = 0x101, | ||
505 | }; | ||
506 | |||
507 | enum status_buffer { | ||
508 | SB_EIR_OFF = 0x00, /* Error Information Record */ | ||
509 | SB_RFB_OFF = 0x08, /* Response Frame Buffer */ | ||
510 | SB_RFB_MAX = 0x400, /* RFB size*/ | ||
511 | }; | ||
512 | |||
513 | enum error_info_rec { | ||
514 | CMD_ISS_STPD = (1U << 31), /* Cmd Issue Stopped */ | ||
515 | }; | ||
516 | |||
517 | struct mvs_chip_info { | ||
518 | u32 n_phy; | ||
519 | u32 srs_sz; | ||
520 | u32 slot_width; | ||
521 | }; | ||
522 | |||
523 | struct mvs_err_info { | ||
524 | __le32 flags; | ||
525 | __le32 flags2; | ||
526 | }; | ||
527 | |||
528 | struct mvs_prd { | ||
529 | __le64 addr; /* 64-bit buffer address */ | ||
530 | __le32 reserved; | ||
531 | __le32 len; /* 16-bit length */ | ||
532 | }; | ||
533 | |||
534 | struct mvs_cmd_hdr { | ||
535 | __le32 flags; /* PRD tbl len; SAS, SATA ctl */ | ||
536 | __le32 lens; /* cmd, max resp frame len */ | ||
537 | __le32 tags; /* targ port xfer tag; tag */ | ||
538 | __le32 data_len; /* data xfer len */ | ||
539 | __le64 cmd_tbl; /* command table address */ | ||
540 | __le64 open_frame; /* open addr frame address */ | ||
541 | __le64 status_buf; /* status buffer address */ | ||
542 | __le64 prd_tbl; /* PRD tbl address */ | ||
543 | __le32 reserved[4]; | ||
544 | }; | ||
545 | |||
546 | struct mvs_slot_info { | ||
547 | struct sas_task *task; | ||
548 | u32 n_elem; | ||
549 | u32 tx; | ||
550 | |||
551 | /* DMA buffer for storing cmd tbl, open addr frame, status buffer, | ||
552 | * and PRD table | ||
553 | */ | ||
554 | void *buf; | ||
555 | dma_addr_t buf_dma; | ||
556 | #if _MV_DUMP | ||
557 | u32 cmd_size; | ||
558 | #endif | ||
559 | |||
560 | void *response; | ||
561 | }; | ||
562 | |||
563 | struct mvs_port { | ||
564 | struct asd_sas_port sas_port; | ||
565 | u8 port_attached; | ||
566 | u8 taskfileset; | ||
567 | u8 wide_port_phymap; | ||
568 | }; | ||
569 | |||
570 | struct mvs_phy { | ||
571 | struct mvs_port *port; | ||
572 | struct asd_sas_phy sas_phy; | ||
573 | struct sas_identify identify; | ||
574 | struct scsi_device *sdev; | ||
575 | u64 dev_sas_addr; | ||
576 | u64 att_dev_sas_addr; | ||
577 | u32 att_dev_info; | ||
578 | u32 dev_info; | ||
579 | u32 phy_type; | ||
580 | u32 phy_status; | ||
581 | u32 irq_status; | ||
582 | u32 frame_rcvd_size; | ||
583 | u8 frame_rcvd[32]; | ||
584 | u8 phy_attached; | ||
585 | }; | ||
586 | |||
587 | struct mvs_info { | ||
588 | unsigned long flags; | ||
589 | |||
590 | spinlock_t lock; /* host-wide lock */ | ||
591 | struct pci_dev *pdev; /* our device */ | ||
592 | void __iomem *regs; /* enhanced mode registers */ | ||
593 | void __iomem *peri_regs; /* peripheral registers */ | ||
594 | |||
595 | u8 sas_addr[SAS_ADDR_SIZE]; | ||
596 | struct sas_ha_struct sas; /* SCSI/SAS glue */ | ||
597 | struct Scsi_Host *shost; | ||
598 | |||
599 | __le32 *tx; /* TX (delivery) DMA ring */ | ||
600 | dma_addr_t tx_dma; | ||
601 | u32 tx_prod; /* cached next-producer idx */ | ||
602 | |||
603 | __le32 *rx; /* RX (completion) DMA ring */ | ||
604 | dma_addr_t rx_dma; | ||
605 | u32 rx_cons; /* RX consumer idx */ | ||
606 | |||
607 | __le32 *rx_fis; /* RX'd FIS area */ | ||
608 | dma_addr_t rx_fis_dma; | ||
609 | |||
610 | struct mvs_cmd_hdr *slot; /* DMA command header slots */ | ||
611 | dma_addr_t slot_dma; | ||
612 | |||
613 | const struct mvs_chip_info *chip; | ||
614 | |||
615 | unsigned long tags[MVS_SLOTS]; | ||
616 | struct mvs_slot_info slot_info[MVS_SLOTS]; | ||
617 | /* further per-slot information */ | ||
618 | struct mvs_phy phy[MVS_MAX_PHYS]; | ||
619 | struct mvs_port port[MVS_MAX_PHYS]; | ||
620 | |||
621 | u32 can_queue; /* per adapter */ | ||
622 | u32 tag_out; /*Get*/ | ||
623 | u32 tag_in; /*Give*/ | ||
624 | }; | ||
625 | |||
626 | struct mvs_queue_task { | ||
627 | struct list_head list; | ||
628 | |||
629 | void *uldd_task; | ||
630 | }; | ||
631 | |||
632 | static int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, | ||
633 | void *funcdata); | ||
634 | static u32 mvs_read_phy_ctl(struct mvs_info *mvi, u32 port); | ||
635 | static void mvs_write_phy_ctl(struct mvs_info *mvi, u32 port, u32 val); | ||
636 | static u32 mvs_read_port_irq_stat(struct mvs_info *mvi, u32 port); | ||
637 | static void mvs_write_port_irq_stat(struct mvs_info *mvi, u32 port, u32 val); | ||
638 | static void mvs_write_port_irq_mask(struct mvs_info *mvi, u32 port, u32 val); | ||
639 | static u32 mvs_read_port_irq_mask(struct mvs_info *mvi, u32 port); | ||
640 | |||
641 | static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i); | ||
642 | static void mvs_detect_porttype(struct mvs_info *mvi, int i); | ||
643 | static void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st); | ||
644 | |||
645 | static int mvs_scan_finished(struct Scsi_Host *, unsigned long); | ||
646 | static void mvs_scan_start(struct Scsi_Host *); | ||
647 | static int mvs_sas_slave_alloc(struct scsi_device *scsi_dev); | ||
648 | |||
649 | static struct scsi_transport_template *mvs_stt; | ||
650 | |||
651 | static const struct mvs_chip_info mvs_chips[] = { | ||
652 | [chip_6320] = { 2, 16, 9 }, | ||
653 | [chip_6440] = { 4, 16, 9 }, | ||
654 | [chip_6480] = { 8, 32, 10 }, | ||
655 | }; | ||
656 | |||
657 | static struct scsi_host_template mvs_sht = { | ||
658 | .module = THIS_MODULE, | ||
659 | .name = DRV_NAME, | ||
660 | .queuecommand = sas_queuecommand, | ||
661 | .target_alloc = sas_target_alloc, | ||
662 | .slave_configure = sas_slave_configure, | ||
663 | .slave_destroy = sas_slave_destroy, | ||
664 | .scan_finished = mvs_scan_finished, | ||
665 | .scan_start = mvs_scan_start, | ||
666 | .change_queue_depth = sas_change_queue_depth, | ||
667 | .change_queue_type = sas_change_queue_type, | ||
668 | .bios_param = sas_bios_param, | ||
669 | .can_queue = 1, | ||
670 | .cmd_per_lun = 1, | ||
671 | .this_id = -1, | ||
672 | .sg_tablesize = SG_ALL, | ||
673 | .max_sectors = SCSI_DEFAULT_MAX_SECTORS, | ||
674 | .use_clustering = ENABLE_CLUSTERING, | ||
675 | .eh_device_reset_handler = sas_eh_device_reset_handler, | ||
676 | .eh_bus_reset_handler = sas_eh_bus_reset_handler, | ||
677 | .slave_alloc = mvs_sas_slave_alloc, | ||
678 | .target_destroy = sas_target_destroy, | ||
679 | .ioctl = sas_ioctl, | ||
680 | }; | ||
681 | |||
682 | static void mvs_hexdump(u32 size, u8 *data, u32 baseaddr) | ||
683 | { | ||
684 | u32 i; | ||
685 | u32 run; | ||
686 | u32 offset; | ||
687 | |||
688 | offset = 0; | ||
689 | while (size) { | ||
690 | printk("%08X : ", baseaddr + offset); | ||
691 | if (size >= 16) | ||
692 | run = 16; | ||
693 | else | ||
694 | run = size; | ||
695 | size -= run; | ||
696 | for (i = 0; i < 16; i++) { | ||
697 | if (i < run) | ||
698 | printk("%02X ", (u32)data[i]); | ||
699 | else | ||
700 | printk(" "); | ||
701 | } | ||
702 | printk(": "); | ||
703 | for (i = 0; i < run; i++) | ||
704 | printk("%c", isalnum(data[i]) ? data[i] : '.'); | ||
705 | printk("\n"); | ||
706 | data = &data[16]; | ||
707 | offset += run; | ||
708 | } | ||
709 | printk("\n"); | ||
710 | } | ||
711 | |||
712 | static void mvs_hba_sb_dump(struct mvs_info *mvi, u32 tag, | ||
713 | enum sas_protocol proto) | ||
714 | { | ||
715 | #if _MV_DUMP | ||
716 | u32 offset; | ||
717 | struct pci_dev *pdev = mvi->pdev; | ||
718 | struct mvs_slot_info *slot = &mvi->slot_info[tag]; | ||
719 | |||
720 | offset = slot->cmd_size + MVS_OAF_SZ + | ||
721 | sizeof(struct mvs_prd) * slot->n_elem; | ||
722 | dev_printk(KERN_DEBUG, &pdev->dev, "+---->Status buffer[%d] :\n", | ||
723 | tag); | ||
724 | mvs_hexdump(32, (u8 *) slot->response, | ||
725 | (u32) slot->buf_dma + offset); | ||
726 | #endif | ||
727 | } | ||
728 | |||
729 | static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag, | ||
730 | enum sas_protocol proto) | ||
731 | { | ||
732 | #if _MV_DUMP | ||
733 | u32 sz, w_ptr, r_ptr; | ||
734 | u64 addr; | ||
735 | void __iomem *regs = mvi->regs; | ||
736 | struct pci_dev *pdev = mvi->pdev; | ||
737 | struct mvs_slot_info *slot = &mvi->slot_info[tag]; | ||
738 | |||
739 | /*Delivery Queue */ | ||
740 | sz = mr32(TX_CFG) & TX_RING_SZ_MASK; | ||
741 | w_ptr = mr32(TX_PROD_IDX) & TX_RING_SZ_MASK; | ||
742 | r_ptr = mr32(TX_CONS_IDX) & TX_RING_SZ_MASK; | ||
743 | addr = mr32(TX_HI) << 16 << 16 | mr32(TX_LO); | ||
744 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
745 | "Delivery Queue Size=%04d , WRT_PTR=%04X , RD_PTR=%04X\n", | ||
746 | sz, w_ptr, r_ptr); | ||
747 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
748 | "Delivery Queue Base Address=0x%llX (PA)" | ||
749 | "(tx_dma=0x%llX), Entry=%04d\n", | ||
750 | addr, mvi->tx_dma, w_ptr); | ||
751 | mvs_hexdump(sizeof(u32), (u8 *)(&mvi->tx[mvi->tx_prod]), | ||
752 | (u32) mvi->tx_dma + sizeof(u32) * w_ptr); | ||
753 | /*Command List */ | ||
754 | addr = mr32(CMD_LIST_HI) << 16 << 16 | mr32(CMD_LIST_LO); | ||
755 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
756 | "Command List Base Address=0x%llX (PA)" | ||
757 | "(slot_dma=0x%llX), Header=%03d\n", | ||
758 | addr, mvi->slot_dma, tag); | ||
759 | dev_printk(KERN_DEBUG, &pdev->dev, "Command Header[%03d]:\n", tag); | ||
760 | /*mvs_cmd_hdr */ | ||
761 | mvs_hexdump(sizeof(struct mvs_cmd_hdr), (u8 *)(&mvi->slot[tag]), | ||
762 | (u32) mvi->slot_dma + tag * sizeof(struct mvs_cmd_hdr)); | ||
763 | /*1.command table area */ | ||
764 | dev_printk(KERN_DEBUG, &pdev->dev, "+---->Command Table :\n"); | ||
765 | mvs_hexdump(slot->cmd_size, (u8 *) slot->buf, (u32) slot->buf_dma); | ||
766 | /*2.open address frame area */ | ||
767 | dev_printk(KERN_DEBUG, &pdev->dev, "+---->Open Address Frame :\n"); | ||
768 | mvs_hexdump(MVS_OAF_SZ, (u8 *) slot->buf + slot->cmd_size, | ||
769 | (u32) slot->buf_dma + slot->cmd_size); | ||
770 | /*3.status buffer */ | ||
771 | mvs_hba_sb_dump(mvi, tag, proto); | ||
772 | /*4.PRD table */ | ||
773 | dev_printk(KERN_DEBUG, &pdev->dev, "+---->PRD table :\n"); | ||
774 | mvs_hexdump(sizeof(struct mvs_prd) * slot->n_elem, | ||
775 | (u8 *) slot->buf + slot->cmd_size + MVS_OAF_SZ, | ||
776 | (u32) slot->buf_dma + slot->cmd_size + MVS_OAF_SZ); | ||
777 | #endif | ||
778 | } | ||
779 | |||
780 | static void mvs_hba_cq_dump(struct mvs_info *mvi) | ||
781 | { | ||
782 | #if _MV_DUMP | ||
783 | u64 addr; | ||
784 | void __iomem *regs = mvi->regs; | ||
785 | struct pci_dev *pdev = mvi->pdev; | ||
786 | u32 entry = mvi->rx_cons + 1; | ||
787 | u32 rx_desc = le32_to_cpu(mvi->rx[entry]); | ||
788 | |||
789 | /*Completion Queue */ | ||
790 | addr = mr32(RX_HI) << 16 << 16 | mr32(RX_LO); | ||
791 | dev_printk(KERN_DEBUG, &pdev->dev, "Completion Task = 0x%08X\n", | ||
792 | (u32) mvi->slot_info[rx_desc & RXQ_SLOT_MASK].task); | ||
793 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
794 | "Completion List Base Address=0x%llX (PA), " | ||
795 | "CQ_Entry=%04d, CQ_WP=0x%08X\n", | ||
796 | addr, entry - 1, mvi->rx[0]); | ||
797 | mvs_hexdump(sizeof(u32), (u8 *)(&rx_desc), | ||
798 | mvi->rx_dma + sizeof(u32) * entry); | ||
799 | #endif | ||
800 | } | ||
801 | |||
802 | static void mvs_hba_interrupt_enable(struct mvs_info *mvi) | ||
803 | { | ||
804 | void __iomem *regs = mvi->regs; | ||
805 | u32 tmp; | ||
806 | |||
807 | tmp = mr32(GBL_CTL); | ||
808 | |||
809 | mw32(GBL_CTL, tmp | INT_EN); | ||
810 | } | ||
811 | |||
812 | static void mvs_hba_interrupt_disable(struct mvs_info *mvi) | ||
813 | { | ||
814 | void __iomem *regs = mvi->regs; | ||
815 | u32 tmp; | ||
816 | |||
817 | tmp = mr32(GBL_CTL); | ||
818 | |||
819 | mw32(GBL_CTL, tmp & ~INT_EN); | ||
820 | } | ||
821 | |||
822 | static int mvs_int_rx(struct mvs_info *mvi, bool self_clear); | ||
823 | |||
824 | /* move to PCI layer or libata core? */ | ||
825 | static int pci_go_64(struct pci_dev *pdev) | ||
826 | { | ||
827 | int rc; | ||
828 | |||
829 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { | ||
830 | rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); | ||
831 | if (rc) { | ||
832 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | ||
833 | if (rc) { | ||
834 | dev_printk(KERN_ERR, &pdev->dev, | ||
835 | "64-bit DMA enable failed\n"); | ||
836 | return rc; | ||
837 | } | ||
838 | } | ||
839 | } else { | ||
840 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | ||
841 | if (rc) { | ||
842 | dev_printk(KERN_ERR, &pdev->dev, | ||
843 | "32-bit DMA enable failed\n"); | ||
844 | return rc; | ||
845 | } | ||
846 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | ||
847 | if (rc) { | ||
848 | dev_printk(KERN_ERR, &pdev->dev, | ||
849 | "32-bit consistent DMA enable failed\n"); | ||
850 | return rc; | ||
851 | } | ||
852 | } | ||
853 | |||
854 | return rc; | ||
855 | } | ||
856 | |||
857 | static void mvs_tag_clear(struct mvs_info *mvi, u32 tag) | ||
858 | { | ||
859 | mvi->tag_in = (mvi->tag_in + 1) & (MVS_SLOTS - 1); | ||
860 | mvi->tags[mvi->tag_in] = tag; | ||
861 | } | ||
862 | |||
863 | static void mvs_tag_free(struct mvs_info *mvi, u32 tag) | ||
864 | { | ||
865 | mvi->tag_out = (mvi->tag_out - 1) & (MVS_SLOTS - 1); | ||
866 | } | ||
867 | |||
868 | static int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out) | ||
869 | { | ||
870 | if (mvi->tag_out != mvi->tag_in) { | ||
871 | *tag_out = mvi->tags[mvi->tag_out]; | ||
872 | mvi->tag_out = (mvi->tag_out + 1) & (MVS_SLOTS - 1); | ||
873 | return 0; | ||
874 | } | ||
875 | return -EBUSY; | ||
876 | } | ||
877 | |||
878 | static void mvs_tag_init(struct mvs_info *mvi) | ||
879 | { | ||
880 | int i; | ||
881 | for (i = 0; i < MVS_SLOTS; ++i) | ||
882 | mvi->tags[i] = i; | ||
883 | mvi->tag_out = 0; | ||
884 | mvi->tag_in = MVS_SLOTS - 1; | ||
885 | } | ||
886 | |||
887 | #ifndef MVS_DISABLE_NVRAM | ||
888 | static int mvs_eep_read(void __iomem *regs, u32 addr, u32 *data) | ||
889 | { | ||
890 | int timeout = 1000; | ||
891 | |||
892 | if (addr & ~SPI_ADDR_MASK) | ||
893 | return -EINVAL; | ||
894 | |||
895 | writel(addr, regs + SPI_CMD); | ||
896 | writel(TWSI_RD, regs + SPI_CTL); | ||
897 | |||
898 | while (timeout-- > 0) { | ||
899 | if (readl(regs + SPI_CTL) & TWSI_RDY) { | ||
900 | *data = readl(regs + SPI_DATA); | ||
901 | return 0; | ||
902 | } | ||
903 | |||
904 | udelay(10); | ||
905 | } | ||
906 | |||
907 | return -EBUSY; | ||
908 | } | ||
909 | |||
910 | static int mvs_eep_read_buf(void __iomem *regs, u32 addr, | ||
911 | void *buf, u32 buflen) | ||
912 | { | ||
913 | u32 addr_end, tmp_addr, i, j; | ||
914 | u32 tmp = 0; | ||
915 | int rc; | ||
916 | u8 *tmp8, *buf8 = buf; | ||
917 | |||
918 | addr_end = addr + buflen; | ||
919 | tmp_addr = ALIGN(addr, 4); | ||
920 | if (addr > 0xff) | ||
921 | return -EINVAL; | ||
922 | |||
923 | j = addr & 0x3; | ||
924 | if (j) { | ||
925 | rc = mvs_eep_read(regs, tmp_addr, &tmp); | ||
926 | if (rc) | ||
927 | return rc; | ||
928 | |||
929 | tmp8 = (u8 *)&tmp; | ||
930 | for (i = j; i < 4; i++) | ||
931 | *buf8++ = tmp8[i]; | ||
932 | |||
933 | tmp_addr += 4; | ||
934 | } | ||
935 | |||
936 | for (j = ALIGN(addr_end, 4); tmp_addr < j; tmp_addr += 4) { | ||
937 | rc = mvs_eep_read(regs, tmp_addr, &tmp); | ||
938 | if (rc) | ||
939 | return rc; | ||
940 | |||
941 | memcpy(buf8, &tmp, 4); | ||
942 | buf8 += 4; | ||
943 | } | ||
944 | |||
945 | if (tmp_addr < addr_end) { | ||
946 | rc = mvs_eep_read(regs, tmp_addr, &tmp); | ||
947 | if (rc) | ||
948 | return rc; | ||
949 | |||
950 | tmp8 = (u8 *)&tmp; | ||
951 | j = addr_end - tmp_addr; | ||
952 | for (i = 0; i < j; i++) | ||
953 | *buf8++ = tmp8[i]; | ||
954 | |||
955 | tmp_addr += 4; | ||
956 | } | ||
957 | |||
958 | return 0; | ||
959 | } | ||
960 | #endif | ||
961 | |||
962 | static int mvs_nvram_read(struct mvs_info *mvi, u32 addr, | ||
963 | void *buf, u32 buflen) | ||
964 | { | ||
965 | #ifndef MVS_DISABLE_NVRAM | ||
966 | void __iomem *regs = mvi->regs; | ||
967 | int rc, i; | ||
968 | u32 sum; | ||
969 | u8 hdr[2], *tmp; | ||
970 | const char *msg; | ||
971 | |||
972 | rc = mvs_eep_read_buf(regs, addr, &hdr, 2); | ||
973 | if (rc) { | ||
974 | msg = "nvram hdr read failed"; | ||
975 | goto err_out; | ||
976 | } | ||
977 | rc = mvs_eep_read_buf(regs, addr + 2, buf, buflen); | ||
978 | if (rc) { | ||
979 | msg = "nvram read failed"; | ||
980 | goto err_out; | ||
981 | } | ||
982 | |||
983 | if (hdr[0] != 0x5A) { | ||
984 | /* entry id */ | ||
985 | msg = "invalid nvram entry id"; | ||
986 | rc = -ENOENT; | ||
987 | goto err_out; | ||
988 | } | ||
989 | |||
990 | tmp = buf; | ||
991 | sum = ((u32)hdr[0]) + ((u32)hdr[1]); | ||
992 | for (i = 0; i < buflen; i++) | ||
993 | sum += ((u32)tmp[i]); | ||
994 | |||
995 | if (sum) { | ||
996 | msg = "nvram checksum failure"; | ||
997 | rc = -EILSEQ; | ||
998 | goto err_out; | ||
999 | } | ||
1000 | |||
1001 | return 0; | ||
1002 | |||
1003 | err_out: | ||
1004 | dev_printk(KERN_ERR, &mvi->pdev->dev, "%s", msg); | ||
1005 | return rc; | ||
1006 | #else | ||
1007 | /* FIXME , For SAS target mode */ | ||
1008 | memcpy(buf, "\x00\x00\xab\x11\x30\x04\x05\x50", 8); | ||
1009 | return 0; | ||
1010 | #endif | ||
1011 | } | ||
1012 | |||
1013 | static void mvs_bytes_dmaed(struct mvs_info *mvi, int i) | ||
1014 | { | ||
1015 | struct mvs_phy *phy = &mvi->phy[i]; | ||
1016 | |||
1017 | if (!phy->phy_attached) | ||
1018 | return; | ||
1019 | |||
1020 | if (phy->phy_type & PORT_TYPE_SAS) { | ||
1021 | struct sas_identify_frame *id; | ||
1022 | |||
1023 | id = (struct sas_identify_frame *)phy->frame_rcvd; | ||
1024 | id->dev_type = phy->identify.device_type; | ||
1025 | id->initiator_bits = SAS_PROTOCOL_ALL; | ||
1026 | id->target_bits = phy->identify.target_port_protocols; | ||
1027 | } else if (phy->phy_type & PORT_TYPE_SATA) { | ||
1028 | /* TODO */ | ||
1029 | } | ||
1030 | mvi->sas.sas_phy[i]->frame_rcvd_size = phy->frame_rcvd_size; | ||
1031 | mvi->sas.notify_port_event(mvi->sas.sas_phy[i], | ||
1032 | PORTE_BYTES_DMAED); | ||
1033 | } | ||
1034 | |||
1035 | static int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time) | ||
1036 | { | ||
1037 | /* give the phy enabling interrupt event time to come in (1s | ||
1038 | * is empirically about all it takes) */ | ||
1039 | if (time < HZ) | ||
1040 | return 0; | ||
1041 | /* Wait for discovery to finish */ | ||
1042 | scsi_flush_work(shost); | ||
1043 | return 1; | ||
1044 | } | ||
1045 | |||
1046 | static void mvs_scan_start(struct Scsi_Host *shost) | ||
1047 | { | ||
1048 | int i; | ||
1049 | struct mvs_info *mvi = SHOST_TO_SAS_HA(shost)->lldd_ha; | ||
1050 | |||
1051 | for (i = 0; i < mvi->chip->n_phy; ++i) { | ||
1052 | mvs_bytes_dmaed(mvi, i); | ||
1053 | } | ||
1054 | } | ||
1055 | |||
1056 | static int mvs_sas_slave_alloc(struct scsi_device *scsi_dev) | ||
1057 | { | ||
1058 | int rc; | ||
1059 | |||
1060 | rc = sas_slave_alloc(scsi_dev); | ||
1061 | |||
1062 | return rc; | ||
1063 | } | ||
1064 | |||
1065 | static void mvs_int_port(struct mvs_info *mvi, int port_no, u32 events) | ||
1066 | { | ||
1067 | struct pci_dev *pdev = mvi->pdev; | ||
1068 | struct sas_ha_struct *sas_ha = &mvi->sas; | ||
1069 | struct mvs_phy *phy = &mvi->phy[port_no]; | ||
1070 | struct asd_sas_phy *sas_phy = &phy->sas_phy; | ||
1071 | |||
1072 | phy->irq_status = mvs_read_port_irq_stat(mvi, port_no); | ||
1073 | /* | ||
1074 | * events is port event now , | ||
1075 | * we need check the interrupt status which belongs to per port. | ||
1076 | */ | ||
1077 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
1078 | "Port %d Event = %X\n", | ||
1079 | port_no, phy->irq_status); | ||
1080 | |||
1081 | if (phy->irq_status & (PHYEV_POOF | PHYEV_DEC_ERR)) { | ||
1082 | if (!mvs_is_phy_ready(mvi, port_no)) { | ||
1083 | sas_phy_disconnected(sas_phy); | ||
1084 | sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL); | ||
1085 | } else | ||
1086 | mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET, NULL); | ||
1087 | } | ||
1088 | if (!(phy->irq_status & PHYEV_DEC_ERR)) { | ||
1089 | if (phy->irq_status & PHYEV_COMWAKE) { | ||
1090 | u32 tmp = mvs_read_port_irq_mask(mvi, port_no); | ||
1091 | mvs_write_port_irq_mask(mvi, port_no, | ||
1092 | tmp | PHYEV_SIG_FIS); | ||
1093 | } | ||
1094 | if (phy->irq_status & (PHYEV_SIG_FIS | PHYEV_ID_DONE)) { | ||
1095 | phy->phy_status = mvs_is_phy_ready(mvi, port_no); | ||
1096 | if (phy->phy_status) { | ||
1097 | mvs_detect_porttype(mvi, port_no); | ||
1098 | |||
1099 | if (phy->phy_type & PORT_TYPE_SATA) { | ||
1100 | u32 tmp = mvs_read_port_irq_mask(mvi, | ||
1101 | port_no); | ||
1102 | tmp &= ~PHYEV_SIG_FIS; | ||
1103 | mvs_write_port_irq_mask(mvi, | ||
1104 | port_no, tmp); | ||
1105 | } | ||
1106 | |||
1107 | mvs_update_phyinfo(mvi, port_no, 0); | ||
1108 | sas_ha->notify_phy_event(sas_phy, | ||
1109 | PHYE_OOB_DONE); | ||
1110 | mvs_bytes_dmaed(mvi, port_no); | ||
1111 | } else { | ||
1112 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
1113 | "plugin interrupt but phy is gone\n"); | ||
1114 | mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET, | ||
1115 | NULL); | ||
1116 | } | ||
1117 | } else if (phy->irq_status & PHYEV_BROAD_CH) | ||
1118 | sas_ha->notify_port_event(sas_phy, | ||
1119 | PORTE_BROADCAST_RCVD); | ||
1120 | } | ||
1121 | mvs_write_port_irq_stat(mvi, port_no, phy->irq_status); | ||
1122 | } | ||
1123 | |||
1124 | static void mvs_int_sata(struct mvs_info *mvi) | ||
1125 | { | ||
1126 | /* FIXME */ | ||
1127 | } | ||
1128 | |||
1129 | static void mvs_slot_free(struct mvs_info *mvi, struct sas_task *task, | ||
1130 | struct mvs_slot_info *slot, u32 slot_idx) | ||
1131 | { | ||
1132 | if (!sas_protocol_ata(task->task_proto)) | ||
1133 | if (slot->n_elem) | ||
1134 | pci_unmap_sg(mvi->pdev, task->scatter, | ||
1135 | slot->n_elem, task->data_dir); | ||
1136 | |||
1137 | switch (task->task_proto) { | ||
1138 | case SAS_PROTOCOL_SMP: | ||
1139 | pci_unmap_sg(mvi->pdev, &task->smp_task.smp_resp, 1, | ||
1140 | PCI_DMA_FROMDEVICE); | ||
1141 | pci_unmap_sg(mvi->pdev, &task->smp_task.smp_req, 1, | ||
1142 | PCI_DMA_TODEVICE); | ||
1143 | break; | ||
1144 | |||
1145 | case SAS_PROTOCOL_SATA: | ||
1146 | case SAS_PROTOCOL_STP: | ||
1147 | case SAS_PROTOCOL_SSP: | ||
1148 | default: | ||
1149 | /* do nothing */ | ||
1150 | break; | ||
1151 | } | ||
1152 | |||
1153 | slot->task = NULL; | ||
1154 | mvs_tag_clear(mvi, slot_idx); | ||
1155 | } | ||
1156 | |||
1157 | static void mvs_slot_err(struct mvs_info *mvi, struct sas_task *task, | ||
1158 | u32 slot_idx) | ||
1159 | { | ||
1160 | struct mvs_slot_info *slot = &mvi->slot_info[slot_idx]; | ||
1161 | u64 err_dw0 = *(u32 *) slot->response; | ||
1162 | void __iomem *regs = mvi->regs; | ||
1163 | u32 tmp; | ||
1164 | |||
1165 | if (err_dw0 & CMD_ISS_STPD) | ||
1166 | if (sas_protocol_ata(task->task_proto)) { | ||
1167 | tmp = mr32(INT_STAT_SRS); | ||
1168 | mw32(INT_STAT_SRS, tmp & 0xFFFF); | ||
1169 | } | ||
1170 | |||
1171 | mvs_hba_sb_dump(mvi, slot_idx, task->task_proto); | ||
1172 | } | ||
1173 | |||
1174 | static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc) | ||
1175 | { | ||
1176 | u32 slot_idx = rx_desc & RXQ_SLOT_MASK; | ||
1177 | struct mvs_slot_info *slot = &mvi->slot_info[slot_idx]; | ||
1178 | struct sas_task *task = slot->task; | ||
1179 | struct task_status_struct *tstat = &task->task_status; | ||
1180 | struct mvs_port *port = &mvi->port[task->dev->port->id]; | ||
1181 | bool aborted; | ||
1182 | void *to; | ||
1183 | |||
1184 | spin_lock(&task->task_state_lock); | ||
1185 | aborted = task->task_state_flags & SAS_TASK_STATE_ABORTED; | ||
1186 | if (!aborted) { | ||
1187 | task->task_state_flags &= | ||
1188 | ~(SAS_TASK_STATE_PENDING | SAS_TASK_AT_INITIATOR); | ||
1189 | task->task_state_flags |= SAS_TASK_STATE_DONE; | ||
1190 | } | ||
1191 | spin_unlock(&task->task_state_lock); | ||
1192 | |||
1193 | if (aborted) | ||
1194 | return -1; | ||
1195 | |||
1196 | memset(tstat, 0, sizeof(*tstat)); | ||
1197 | tstat->resp = SAS_TASK_COMPLETE; | ||
1198 | |||
1199 | |||
1200 | if (unlikely(!port->port_attached)) { | ||
1201 | tstat->stat = SAS_PHY_DOWN; | ||
1202 | goto out; | ||
1203 | } | ||
1204 | |||
1205 | /* error info record present */ | ||
1206 | if ((rx_desc & RXQ_ERR) && (*(u64 *) slot->response)) { | ||
1207 | tstat->stat = SAM_CHECK_COND; | ||
1208 | mvs_slot_err(mvi, task, slot_idx); | ||
1209 | goto out; | ||
1210 | } | ||
1211 | |||
1212 | switch (task->task_proto) { | ||
1213 | case SAS_PROTOCOL_SSP: | ||
1214 | /* hw says status == 0, datapres == 0 */ | ||
1215 | if (rx_desc & RXQ_GOOD) { | ||
1216 | tstat->stat = SAM_GOOD; | ||
1217 | tstat->resp = SAS_TASK_COMPLETE; | ||
1218 | } | ||
1219 | /* response frame present */ | ||
1220 | else if (rx_desc & RXQ_RSP) { | ||
1221 | struct ssp_response_iu *iu = | ||
1222 | slot->response + sizeof(struct mvs_err_info); | ||
1223 | sas_ssp_task_response(&mvi->pdev->dev, task, iu); | ||
1224 | } | ||
1225 | |||
1226 | /* should never happen? */ | ||
1227 | else | ||
1228 | tstat->stat = SAM_CHECK_COND; | ||
1229 | break; | ||
1230 | |||
1231 | case SAS_PROTOCOL_SMP: { | ||
1232 | struct scatterlist *sg_resp = &task->smp_task.smp_resp; | ||
1233 | tstat->stat = SAM_GOOD; | ||
1234 | to = kmap_atomic(sg_page(sg_resp), KM_IRQ0); | ||
1235 | memcpy(to + sg_resp->offset, | ||
1236 | slot->response + sizeof(struct mvs_err_info), | ||
1237 | sg_dma_len(sg_resp)); | ||
1238 | kunmap_atomic(to, KM_IRQ0); | ||
1239 | break; | ||
1240 | } | ||
1241 | |||
1242 | case SAS_PROTOCOL_SATA: | ||
1243 | case SAS_PROTOCOL_STP: | ||
1244 | case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: { | ||
1245 | struct ata_task_resp *resp = | ||
1246 | (struct ata_task_resp *)tstat->buf; | ||
1247 | |||
1248 | if ((rx_desc & (RXQ_DONE | RXQ_ERR | RXQ_ATTN)) == | ||
1249 | RXQ_DONE) | ||
1250 | tstat->stat = SAM_GOOD; | ||
1251 | else | ||
1252 | tstat->stat = SAM_CHECK_COND; | ||
1253 | |||
1254 | resp->frame_len = sizeof(struct dev_to_host_fis); | ||
1255 | memcpy(&resp->ending_fis[0], | ||
1256 | SATA_RECEIVED_D2H_FIS(port->taskfileset), | ||
1257 | sizeof(struct dev_to_host_fis)); | ||
1258 | if (resp->ending_fis[2] & ATA_ERR) | ||
1259 | mvs_hexdump(16, resp->ending_fis, 0); | ||
1260 | break; | ||
1261 | } | ||
1262 | |||
1263 | default: | ||
1264 | tstat->stat = SAM_CHECK_COND; | ||
1265 | break; | ||
1266 | } | ||
1267 | |||
1268 | out: | ||
1269 | mvs_slot_free(mvi, task, slot, slot_idx); | ||
1270 | task->task_done(task); | ||
1271 | return tstat->stat; | ||
1272 | } | ||
1273 | |||
1274 | static void mvs_int_full(struct mvs_info *mvi) | ||
1275 | { | ||
1276 | void __iomem *regs = mvi->regs; | ||
1277 | u32 tmp, stat; | ||
1278 | int i; | ||
1279 | |||
1280 | stat = mr32(INT_STAT); | ||
1281 | |||
1282 | mvs_int_rx(mvi, false); | ||
1283 | |||
1284 | for (i = 0; i < MVS_MAX_PORTS; i++) { | ||
1285 | tmp = (stat >> i) & (CINT_PORT | CINT_PORT_STOPPED); | ||
1286 | if (tmp) | ||
1287 | mvs_int_port(mvi, i, tmp); | ||
1288 | } | ||
1289 | |||
1290 | if (stat & CINT_SRS) | ||
1291 | mvs_int_sata(mvi); | ||
1292 | |||
1293 | mw32(INT_STAT, stat); | ||
1294 | } | ||
1295 | |||
1296 | static int mvs_int_rx(struct mvs_info *mvi, bool self_clear) | ||
1297 | { | ||
1298 | void __iomem *regs = mvi->regs; | ||
1299 | u32 rx_prod_idx, rx_desc; | ||
1300 | bool attn = false; | ||
1301 | struct pci_dev *pdev = mvi->pdev; | ||
1302 | |||
1303 | /* the first dword in the RX ring is special: it contains | ||
1304 | * a mirror of the hardware's RX producer index, so that | ||
1305 | * we don't have to stall the CPU reading that register. | ||
1306 | * The actual RX ring is offset by one dword, due to this. | ||
1307 | */ | ||
1308 | rx_prod_idx = mr32(RX_CONS_IDX) & RX_RING_SZ_MASK; | ||
1309 | if (rx_prod_idx == 0xfff) { /* h/w hasn't touched RX ring yet */ | ||
1310 | mvi->rx_cons = 0xfff; | ||
1311 | return 0; | ||
1312 | } | ||
1313 | |||
1314 | /* The CMPL_Q may come late, read from register and try again | ||
1315 | * note: if coalescing is enabled, | ||
1316 | * it will need to read from register every time for sure | ||
1317 | */ | ||
1318 | if (mvi->rx_cons == rx_prod_idx) | ||
1319 | return 0; | ||
1320 | |||
1321 | if (mvi->rx_cons == 0xfff) | ||
1322 | mvi->rx_cons = MVS_RX_RING_SZ - 1; | ||
1323 | |||
1324 | while (mvi->rx_cons != rx_prod_idx) { | ||
1325 | |||
1326 | /* increment our internal RX consumer pointer */ | ||
1327 | mvi->rx_cons = (mvi->rx_cons + 1) & (MVS_RX_RING_SZ - 1); | ||
1328 | |||
1329 | rx_desc = le32_to_cpu(mvi->rx[mvi->rx_cons + 1]); | ||
1330 | |||
1331 | mvs_hba_cq_dump(mvi); | ||
1332 | |||
1333 | if (unlikely(rx_desc & RXQ_DONE)) | ||
1334 | mvs_slot_complete(mvi, rx_desc); | ||
1335 | if (rx_desc & RXQ_ATTN) { | ||
1336 | attn = true; | ||
1337 | dev_printk(KERN_DEBUG, &pdev->dev, "ATTN %X\n", | ||
1338 | rx_desc); | ||
1339 | } else if (rx_desc & RXQ_ERR) { | ||
1340 | dev_printk(KERN_DEBUG, &pdev->dev, "RXQ_ERR %X\n", | ||
1341 | rx_desc); | ||
1342 | } | ||
1343 | } | ||
1344 | |||
1345 | if (attn && self_clear) | ||
1346 | mvs_int_full(mvi); | ||
1347 | |||
1348 | return 0; | ||
1349 | } | ||
1350 | |||
1351 | static irqreturn_t mvs_interrupt(int irq, void *opaque) | ||
1352 | { | ||
1353 | struct mvs_info *mvi = opaque; | ||
1354 | void __iomem *regs = mvi->regs; | ||
1355 | u32 stat; | ||
1356 | |||
1357 | stat = mr32(GBL_INT_STAT); | ||
1358 | |||
1359 | /* clear CMD_CMPLT ASAP */ | ||
1360 | mw32_f(INT_STAT, CINT_DONE); | ||
1361 | |||
1362 | if (stat == 0 || stat == 0xffffffff) | ||
1363 | return IRQ_NONE; | ||
1364 | |||
1365 | spin_lock(&mvi->lock); | ||
1366 | |||
1367 | mvs_int_full(mvi); | ||
1368 | |||
1369 | spin_unlock(&mvi->lock); | ||
1370 | |||
1371 | return IRQ_HANDLED; | ||
1372 | } | ||
1373 | |||
1374 | #ifndef MVS_DISABLE_MSI | ||
1375 | static irqreturn_t mvs_msi_interrupt(int irq, void *opaque) | ||
1376 | { | ||
1377 | struct mvs_info *mvi = opaque; | ||
1378 | |||
1379 | spin_lock(&mvi->lock); | ||
1380 | |||
1381 | mvs_int_rx(mvi, true); | ||
1382 | |||
1383 | spin_unlock(&mvi->lock); | ||
1384 | |||
1385 | return IRQ_HANDLED; | ||
1386 | } | ||
1387 | #endif | ||
1388 | |||
1389 | struct mvs_task_exec_info { | ||
1390 | struct sas_task *task; | ||
1391 | struct mvs_cmd_hdr *hdr; | ||
1392 | struct mvs_port *port; | ||
1393 | u32 tag; | ||
1394 | int n_elem; | ||
1395 | }; | ||
1396 | |||
1397 | static int mvs_task_prep_smp(struct mvs_info *mvi, | ||
1398 | struct mvs_task_exec_info *tei) | ||
1399 | { | ||
1400 | int elem, rc, i; | ||
1401 | struct sas_task *task = tei->task; | ||
1402 | struct mvs_cmd_hdr *hdr = tei->hdr; | ||
1403 | struct scatterlist *sg_req, *sg_resp; | ||
1404 | u32 req_len, resp_len, tag = tei->tag; | ||
1405 | void *buf_tmp; | ||
1406 | u8 *buf_oaf; | ||
1407 | dma_addr_t buf_tmp_dma; | ||
1408 | struct mvs_prd *buf_prd; | ||
1409 | struct scatterlist *sg; | ||
1410 | struct mvs_slot_info *slot = &mvi->slot_info[tag]; | ||
1411 | struct asd_sas_port *sas_port = task->dev->port; | ||
1412 | u32 flags = (tei->n_elem << MCH_PRD_LEN_SHIFT); | ||
1413 | #if _MV_DUMP | ||
1414 | u8 *buf_cmd; | ||
1415 | void *from; | ||
1416 | #endif | ||
1417 | /* | ||
1418 | * DMA-map SMP request, response buffers | ||
1419 | */ | ||
1420 | sg_req = &task->smp_task.smp_req; | ||
1421 | elem = pci_map_sg(mvi->pdev, sg_req, 1, PCI_DMA_TODEVICE); | ||
1422 | if (!elem) | ||
1423 | return -ENOMEM; | ||
1424 | req_len = sg_dma_len(sg_req); | ||
1425 | |||
1426 | sg_resp = &task->smp_task.smp_resp; | ||
1427 | elem = pci_map_sg(mvi->pdev, sg_resp, 1, PCI_DMA_FROMDEVICE); | ||
1428 | if (!elem) { | ||
1429 | rc = -ENOMEM; | ||
1430 | goto err_out; | ||
1431 | } | ||
1432 | resp_len = sg_dma_len(sg_resp); | ||
1433 | |||
1434 | /* must be in dwords */ | ||
1435 | if ((req_len & 0x3) || (resp_len & 0x3)) { | ||
1436 | rc = -EINVAL; | ||
1437 | goto err_out_2; | ||
1438 | } | ||
1439 | |||
1440 | /* | ||
1441 | * arrange MVS_SLOT_BUF_SZ-sized DMA buffer according to our needs | ||
1442 | */ | ||
1443 | |||
1444 | /* region 1: command table area (MVS_SSP_CMD_SZ bytes) ************** */ | ||
1445 | buf_tmp = slot->buf; | ||
1446 | buf_tmp_dma = slot->buf_dma; | ||
1447 | |||
1448 | #if _MV_DUMP | ||
1449 | buf_cmd = buf_tmp; | ||
1450 | hdr->cmd_tbl = cpu_to_le64(buf_tmp_dma); | ||
1451 | buf_tmp += req_len; | ||
1452 | buf_tmp_dma += req_len; | ||
1453 | slot->cmd_size = req_len; | ||
1454 | #else | ||
1455 | hdr->cmd_tbl = cpu_to_le64(sg_dma_address(sg_req)); | ||
1456 | #endif | ||
1457 | |||
1458 | /* region 2: open address frame area (MVS_OAF_SZ bytes) ********* */ | ||
1459 | buf_oaf = buf_tmp; | ||
1460 | hdr->open_frame = cpu_to_le64(buf_tmp_dma); | ||
1461 | |||
1462 | buf_tmp += MVS_OAF_SZ; | ||
1463 | buf_tmp_dma += MVS_OAF_SZ; | ||
1464 | |||
1465 | /* region 3: PRD table ********************************************* */ | ||
1466 | buf_prd = buf_tmp; | ||
1467 | if (tei->n_elem) | ||
1468 | hdr->prd_tbl = cpu_to_le64(buf_tmp_dma); | ||
1469 | else | ||
1470 | hdr->prd_tbl = 0; | ||
1471 | |||
1472 | i = sizeof(struct mvs_prd) * tei->n_elem; | ||
1473 | buf_tmp += i; | ||
1474 | buf_tmp_dma += i; | ||
1475 | |||
1476 | /* region 4: status buffer (larger the PRD, smaller this buf) ****** */ | ||
1477 | slot->response = buf_tmp; | ||
1478 | hdr->status_buf = cpu_to_le64(buf_tmp_dma); | ||
1479 | |||
1480 | /* | ||
1481 | * Fill in TX ring and command slot header | ||
1482 | */ | ||
1483 | slot->tx = mvi->tx_prod; | ||
1484 | mvi->tx[mvi->tx_prod] = cpu_to_le32((TXQ_CMD_SMP << TXQ_CMD_SHIFT) | | ||
1485 | TXQ_MODE_I | tag | | ||
1486 | (sas_port->phy_mask << TXQ_PHY_SHIFT)); | ||
1487 | |||
1488 | hdr->flags |= flags; | ||
1489 | hdr->lens = cpu_to_le32(((resp_len / 4) << 16) | ((req_len - 4) / 4)); | ||
1490 | hdr->tags = cpu_to_le32(tag); | ||
1491 | hdr->data_len = 0; | ||
1492 | |||
1493 | /* generate open address frame hdr (first 12 bytes) */ | ||
1494 | buf_oaf[0] = (1 << 7) | (0 << 4) | 0x01; /* initiator, SMP, ftype 1h */ | ||
1495 | buf_oaf[1] = task->dev->linkrate & 0xf; | ||
1496 | *(u16 *)(buf_oaf + 2) = 0xFFFF; /* SAS SPEC */ | ||
1497 | memcpy(buf_oaf + 4, task->dev->sas_addr, SAS_ADDR_SIZE); | ||
1498 | |||
1499 | /* fill in PRD (scatter/gather) table, if any */ | ||
1500 | for_each_sg(task->scatter, sg, tei->n_elem, i) { | ||
1501 | buf_prd->addr = cpu_to_le64(sg_dma_address(sg)); | ||
1502 | buf_prd->len = cpu_to_le32(sg_dma_len(sg)); | ||
1503 | buf_prd++; | ||
1504 | } | ||
1505 | |||
1506 | #if _MV_DUMP | ||
1507 | /* copy cmd table */ | ||
1508 | from = kmap_atomic(sg_page(sg_req), KM_IRQ0); | ||
1509 | memcpy(buf_cmd, from + sg_req->offset, req_len); | ||
1510 | kunmap_atomic(from, KM_IRQ0); | ||
1511 | #endif | ||
1512 | return 0; | ||
1513 | |||
1514 | err_out_2: | ||
1515 | pci_unmap_sg(mvi->pdev, &tei->task->smp_task.smp_resp, 1, | ||
1516 | PCI_DMA_FROMDEVICE); | ||
1517 | err_out: | ||
1518 | pci_unmap_sg(mvi->pdev, &tei->task->smp_task.smp_req, 1, | ||
1519 | PCI_DMA_TODEVICE); | ||
1520 | return rc; | ||
1521 | } | ||
1522 | |||
1523 | static void mvs_free_reg_set(struct mvs_info *mvi, struct mvs_port *port) | ||
1524 | { | ||
1525 | void __iomem *regs = mvi->regs; | ||
1526 | u32 tmp, offs; | ||
1527 | u8 *tfs = &port->taskfileset; | ||
1528 | |||
1529 | if (*tfs == MVS_ID_NOT_MAPPED) | ||
1530 | return; | ||
1531 | |||
1532 | offs = 1U << ((*tfs & 0x0f) + PCS_EN_SATA_REG_SHIFT); | ||
1533 | if (*tfs < 16) { | ||
1534 | tmp = mr32(PCS); | ||
1535 | mw32(PCS, tmp & ~offs); | ||
1536 | } else { | ||
1537 | tmp = mr32(CTL); | ||
1538 | mw32(CTL, tmp & ~offs); | ||
1539 | } | ||
1540 | |||
1541 | tmp = mr32(INT_STAT_SRS) & (1U << *tfs); | ||
1542 | if (tmp) | ||
1543 | mw32(INT_STAT_SRS, tmp); | ||
1544 | |||
1545 | *tfs = MVS_ID_NOT_MAPPED; | ||
1546 | } | ||
1547 | |||
1548 | static u8 mvs_assign_reg_set(struct mvs_info *mvi, struct mvs_port *port) | ||
1549 | { | ||
1550 | int i; | ||
1551 | u32 tmp, offs; | ||
1552 | void __iomem *regs = mvi->regs; | ||
1553 | |||
1554 | if (port->taskfileset != MVS_ID_NOT_MAPPED) | ||
1555 | return 0; | ||
1556 | |||
1557 | tmp = mr32(PCS); | ||
1558 | |||
1559 | for (i = 0; i < mvi->chip->srs_sz; i++) { | ||
1560 | if (i == 16) | ||
1561 | tmp = mr32(CTL); | ||
1562 | offs = 1U << ((i & 0x0f) + PCS_EN_SATA_REG_SHIFT); | ||
1563 | if (!(tmp & offs)) { | ||
1564 | port->taskfileset = i; | ||
1565 | |||
1566 | if (i < 16) | ||
1567 | mw32(PCS, tmp | offs); | ||
1568 | else | ||
1569 | mw32(CTL, tmp | offs); | ||
1570 | tmp = mr32(INT_STAT_SRS) & (1U << i); | ||
1571 | if (tmp) | ||
1572 | mw32(INT_STAT_SRS, tmp); | ||
1573 | return 0; | ||
1574 | } | ||
1575 | } | ||
1576 | return MVS_ID_NOT_MAPPED; | ||
1577 | } | ||
1578 | |||
1579 | static u32 mvs_get_ncq_tag(struct sas_task *task) | ||
1580 | { | ||
1581 | u32 tag = 0; | ||
1582 | struct ata_queued_cmd *qc = task->uldd_task; | ||
1583 | |||
1584 | if (qc) | ||
1585 | tag = qc->tag; | ||
1586 | |||
1587 | return tag; | ||
1588 | } | ||
1589 | |||
1590 | static int mvs_task_prep_ata(struct mvs_info *mvi, | ||
1591 | struct mvs_task_exec_info *tei) | ||
1592 | { | ||
1593 | struct sas_task *task = tei->task; | ||
1594 | struct domain_device *dev = task->dev; | ||
1595 | struct mvs_cmd_hdr *hdr = tei->hdr; | ||
1596 | struct asd_sas_port *sas_port = dev->port; | ||
1597 | struct mvs_slot_info *slot; | ||
1598 | struct scatterlist *sg; | ||
1599 | struct mvs_prd *buf_prd; | ||
1600 | struct mvs_port *port = tei->port; | ||
1601 | u32 tag = tei->tag; | ||
1602 | u32 flags = (tei->n_elem << MCH_PRD_LEN_SHIFT); | ||
1603 | void *buf_tmp; | ||
1604 | u8 *buf_cmd, *buf_oaf; | ||
1605 | dma_addr_t buf_tmp_dma; | ||
1606 | u32 i, req_len, resp_len; | ||
1607 | const u32 max_resp_len = SB_RFB_MAX; | ||
1608 | |||
1609 | if (mvs_assign_reg_set(mvi, port) == MVS_ID_NOT_MAPPED) | ||
1610 | return -EBUSY; | ||
1611 | |||
1612 | slot = &mvi->slot_info[tag]; | ||
1613 | slot->tx = mvi->tx_prod; | ||
1614 | mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | tag | | ||
1615 | (TXQ_CMD_STP << TXQ_CMD_SHIFT) | | ||
1616 | (sas_port->phy_mask << TXQ_PHY_SHIFT) | | ||
1617 | (port->taskfileset << TXQ_SRS_SHIFT)); | ||
1618 | |||
1619 | if (task->ata_task.use_ncq) | ||
1620 | flags |= MCH_FPDMA; | ||
1621 | if (dev->sata_dev.command_set == ATAPI_COMMAND_SET) { | ||
1622 | if (task->ata_task.fis.command != ATA_CMD_ID_ATAPI) | ||
1623 | flags |= MCH_ATAPI; | ||
1624 | } | ||
1625 | |||
1626 | /* FIXME: fill in port multiplier number */ | ||
1627 | |||
1628 | hdr->flags = cpu_to_le32(flags); | ||
1629 | |||
1630 | /* FIXME: the low order order 5 bits for the TAG if enable NCQ */ | ||
1631 | if (task->ata_task.use_ncq) { | ||
1632 | hdr->tags = cpu_to_le32(mvs_get_ncq_tag(task)); | ||
1633 | /*Fill in task file */ | ||
1634 | task->ata_task.fis.sector_count = hdr->tags << 3; | ||
1635 | } else | ||
1636 | hdr->tags = cpu_to_le32(tag); | ||
1637 | hdr->data_len = cpu_to_le32(task->total_xfer_len); | ||
1638 | |||
1639 | /* | ||
1640 | * arrange MVS_SLOT_BUF_SZ-sized DMA buffer according to our needs | ||
1641 | */ | ||
1642 | |||
1643 | /* region 1: command table area (MVS_ATA_CMD_SZ bytes) ************** */ | ||
1644 | buf_cmd = buf_tmp = slot->buf; | ||
1645 | buf_tmp_dma = slot->buf_dma; | ||
1646 | |||
1647 | hdr->cmd_tbl = cpu_to_le64(buf_tmp_dma); | ||
1648 | |||
1649 | buf_tmp += MVS_ATA_CMD_SZ; | ||
1650 | buf_tmp_dma += MVS_ATA_CMD_SZ; | ||
1651 | #if _MV_DUMP | ||
1652 | slot->cmd_size = MVS_ATA_CMD_SZ; | ||
1653 | #endif | ||
1654 | |||
1655 | /* region 2: open address frame area (MVS_OAF_SZ bytes) ********* */ | ||
1656 | /* used for STP. unused for SATA? */ | ||
1657 | buf_oaf = buf_tmp; | ||
1658 | hdr->open_frame = cpu_to_le64(buf_tmp_dma); | ||
1659 | |||
1660 | buf_tmp += MVS_OAF_SZ; | ||
1661 | buf_tmp_dma += MVS_OAF_SZ; | ||
1662 | |||
1663 | /* region 3: PRD table ********************************************* */ | ||
1664 | buf_prd = buf_tmp; | ||
1665 | if (tei->n_elem) | ||
1666 | hdr->prd_tbl = cpu_to_le64(buf_tmp_dma); | ||
1667 | else | ||
1668 | hdr->prd_tbl = 0; | ||
1669 | |||
1670 | i = sizeof(struct mvs_prd) * tei->n_elem; | ||
1671 | buf_tmp += i; | ||
1672 | buf_tmp_dma += i; | ||
1673 | |||
1674 | /* region 4: status buffer (larger the PRD, smaller this buf) ****** */ | ||
1675 | /* FIXME: probably unused, for SATA. kept here just in case | ||
1676 | * we get a STP/SATA error information record | ||
1677 | */ | ||
1678 | slot->response = buf_tmp; | ||
1679 | hdr->status_buf = cpu_to_le64(buf_tmp_dma); | ||
1680 | |||
1681 | req_len = sizeof(struct host_to_dev_fis); | ||
1682 | resp_len = MVS_SLOT_BUF_SZ - MVS_ATA_CMD_SZ - | ||
1683 | sizeof(struct mvs_err_info) - i; | ||
1684 | |||
1685 | /* request, response lengths */ | ||
1686 | resp_len = min(resp_len, max_resp_len); | ||
1687 | hdr->lens = cpu_to_le32(((resp_len / 4) << 16) | (req_len / 4)); | ||
1688 | |||
1689 | task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */ | ||
1690 | /* fill in command FIS and ATAPI CDB */ | ||
1691 | memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); | ||
1692 | if (dev->sata_dev.command_set == ATAPI_COMMAND_SET) | ||
1693 | memcpy(buf_cmd + STP_ATAPI_CMD, | ||
1694 | task->ata_task.atapi_packet, 16); | ||
1695 | |||
1696 | /* generate open address frame hdr (first 12 bytes) */ | ||
1697 | buf_oaf[0] = (1 << 7) | (2 << 4) | 0x1; /* initiator, STP, ftype 1h */ | ||
1698 | buf_oaf[1] = task->dev->linkrate & 0xf; | ||
1699 | *(u16 *)(buf_oaf + 2) = cpu_to_be16(tag); | ||
1700 | memcpy(buf_oaf + 4, task->dev->sas_addr, SAS_ADDR_SIZE); | ||
1701 | |||
1702 | /* fill in PRD (scatter/gather) table, if any */ | ||
1703 | for_each_sg(task->scatter, sg, tei->n_elem, i) { | ||
1704 | buf_prd->addr = cpu_to_le64(sg_dma_address(sg)); | ||
1705 | buf_prd->len = cpu_to_le32(sg_dma_len(sg)); | ||
1706 | buf_prd++; | ||
1707 | } | ||
1708 | |||
1709 | return 0; | ||
1710 | } | ||
1711 | |||
1712 | static int mvs_task_prep_ssp(struct mvs_info *mvi, | ||
1713 | struct mvs_task_exec_info *tei) | ||
1714 | { | ||
1715 | struct sas_task *task = tei->task; | ||
1716 | struct mvs_cmd_hdr *hdr = tei->hdr; | ||
1717 | struct mvs_port *port = tei->port; | ||
1718 | struct mvs_slot_info *slot; | ||
1719 | struct scatterlist *sg; | ||
1720 | struct mvs_prd *buf_prd; | ||
1721 | struct ssp_frame_hdr *ssp_hdr; | ||
1722 | void *buf_tmp; | ||
1723 | u8 *buf_cmd, *buf_oaf, fburst = 0; | ||
1724 | dma_addr_t buf_tmp_dma; | ||
1725 | u32 flags; | ||
1726 | u32 resp_len, req_len, i, tag = tei->tag; | ||
1727 | const u32 max_resp_len = SB_RFB_MAX; | ||
1728 | |||
1729 | slot = &mvi->slot_info[tag]; | ||
1730 | |||
1731 | slot->tx = mvi->tx_prod; | ||
1732 | mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | tag | | ||
1733 | (TXQ_CMD_SSP << TXQ_CMD_SHIFT) | | ||
1734 | (port->wide_port_phymap << TXQ_PHY_SHIFT)); | ||
1735 | |||
1736 | flags = MCH_RETRY; | ||
1737 | if (task->ssp_task.enable_first_burst) { | ||
1738 | flags |= MCH_FBURST; | ||
1739 | fburst = (1 << 7); | ||
1740 | } | ||
1741 | hdr->flags = cpu_to_le32(flags | | ||
1742 | (tei->n_elem << MCH_PRD_LEN_SHIFT) | | ||
1743 | (MCH_SSP_FR_CMD << MCH_SSP_FR_TYPE_SHIFT)); | ||
1744 | |||
1745 | hdr->tags = cpu_to_le32(tag); | ||
1746 | hdr->data_len = cpu_to_le32(task->total_xfer_len); | ||
1747 | |||
1748 | /* | ||
1749 | * arrange MVS_SLOT_BUF_SZ-sized DMA buffer according to our needs | ||
1750 | */ | ||
1751 | |||
1752 | /* region 1: command table area (MVS_SSP_CMD_SZ bytes) ************** */ | ||
1753 | buf_cmd = buf_tmp = slot->buf; | ||
1754 | buf_tmp_dma = slot->buf_dma; | ||
1755 | |||
1756 | hdr->cmd_tbl = cpu_to_le64(buf_tmp_dma); | ||
1757 | |||
1758 | buf_tmp += MVS_SSP_CMD_SZ; | ||
1759 | buf_tmp_dma += MVS_SSP_CMD_SZ; | ||
1760 | #if _MV_DUMP | ||
1761 | slot->cmd_size = MVS_SSP_CMD_SZ; | ||
1762 | #endif | ||
1763 | |||
1764 | /* region 2: open address frame area (MVS_OAF_SZ bytes) ********* */ | ||
1765 | buf_oaf = buf_tmp; | ||
1766 | hdr->open_frame = cpu_to_le64(buf_tmp_dma); | ||
1767 | |||
1768 | buf_tmp += MVS_OAF_SZ; | ||
1769 | buf_tmp_dma += MVS_OAF_SZ; | ||
1770 | |||
1771 | /* region 3: PRD table ********************************************* */ | ||
1772 | buf_prd = buf_tmp; | ||
1773 | if (tei->n_elem) | ||
1774 | hdr->prd_tbl = cpu_to_le64(buf_tmp_dma); | ||
1775 | else | ||
1776 | hdr->prd_tbl = 0; | ||
1777 | |||
1778 | i = sizeof(struct mvs_prd) * tei->n_elem; | ||
1779 | buf_tmp += i; | ||
1780 | buf_tmp_dma += i; | ||
1781 | |||
1782 | /* region 4: status buffer (larger the PRD, smaller this buf) ****** */ | ||
1783 | slot->response = buf_tmp; | ||
1784 | hdr->status_buf = cpu_to_le64(buf_tmp_dma); | ||
1785 | |||
1786 | resp_len = MVS_SLOT_BUF_SZ - MVS_SSP_CMD_SZ - MVS_OAF_SZ - | ||
1787 | sizeof(struct mvs_err_info) - i; | ||
1788 | resp_len = min(resp_len, max_resp_len); | ||
1789 | |||
1790 | req_len = sizeof(struct ssp_frame_hdr) + 28; | ||
1791 | |||
1792 | /* request, response lengths */ | ||
1793 | hdr->lens = cpu_to_le32(((resp_len / 4) << 16) | (req_len / 4)); | ||
1794 | |||
1795 | /* generate open address frame hdr (first 12 bytes) */ | ||
1796 | buf_oaf[0] = (1 << 7) | (1 << 4) | 0x1; /* initiator, SSP, ftype 1h */ | ||
1797 | buf_oaf[1] = task->dev->linkrate & 0xf; | ||
1798 | *(u16 *)(buf_oaf + 2) = cpu_to_be16(tag); | ||
1799 | memcpy(buf_oaf + 4, task->dev->sas_addr, SAS_ADDR_SIZE); | ||
1800 | |||
1801 | /* fill in SSP frame header (Command Table.SSP frame header) */ | ||
1802 | ssp_hdr = (struct ssp_frame_hdr *)buf_cmd; | ||
1803 | ssp_hdr->frame_type = SSP_COMMAND; | ||
1804 | memcpy(ssp_hdr->hashed_dest_addr, task->dev->hashed_sas_addr, | ||
1805 | HASHED_SAS_ADDR_SIZE); | ||
1806 | memcpy(ssp_hdr->hashed_src_addr, | ||
1807 | task->dev->port->ha->hashed_sas_addr, HASHED_SAS_ADDR_SIZE); | ||
1808 | ssp_hdr->tag = cpu_to_be16(tag); | ||
1809 | |||
1810 | /* fill in command frame IU */ | ||
1811 | buf_cmd += sizeof(*ssp_hdr); | ||
1812 | memcpy(buf_cmd, &task->ssp_task.LUN, 8); | ||
1813 | buf_cmd[9] = fburst | task->ssp_task.task_attr | | ||
1814 | (task->ssp_task.task_prio << 3); | ||
1815 | memcpy(buf_cmd + 12, &task->ssp_task.cdb, 16); | ||
1816 | |||
1817 | /* fill in PRD (scatter/gather) table, if any */ | ||
1818 | for_each_sg(task->scatter, sg, tei->n_elem, i) { | ||
1819 | buf_prd->addr = cpu_to_le64(sg_dma_address(sg)); | ||
1820 | buf_prd->len = cpu_to_le32(sg_dma_len(sg)); | ||
1821 | buf_prd++; | ||
1822 | } | ||
1823 | |||
1824 | return 0; | ||
1825 | } | ||
1826 | |||
1827 | static int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags) | ||
1828 | { | ||
1829 | struct domain_device *dev = task->dev; | ||
1830 | struct mvs_info *mvi = dev->port->ha->lldd_ha; | ||
1831 | struct pci_dev *pdev = mvi->pdev; | ||
1832 | void __iomem *regs = mvi->regs; | ||
1833 | struct mvs_task_exec_info tei; | ||
1834 | struct sas_task *t = task; | ||
1835 | u32 tag = 0xdeadbeef, rc, n_elem = 0; | ||
1836 | unsigned long flags; | ||
1837 | u32 n = num, pass = 0; | ||
1838 | |||
1839 | spin_lock_irqsave(&mvi->lock, flags); | ||
1840 | |||
1841 | do { | ||
1842 | tei.port = &mvi->port[dev->port->id]; | ||
1843 | |||
1844 | if (!tei.port->port_attached) { | ||
1845 | struct task_status_struct *ts = &t->task_status; | ||
1846 | ts->stat = SAS_PHY_DOWN; | ||
1847 | t->task_done(t); | ||
1848 | rc = 0; | ||
1849 | goto exec_exit; | ||
1850 | } | ||
1851 | if (!sas_protocol_ata(t->task_proto)) { | ||
1852 | if (t->num_scatter) { | ||
1853 | n_elem = pci_map_sg(mvi->pdev, t->scatter, | ||
1854 | t->num_scatter, | ||
1855 | t->data_dir); | ||
1856 | if (!n_elem) { | ||
1857 | rc = -ENOMEM; | ||
1858 | goto err_out; | ||
1859 | } | ||
1860 | } | ||
1861 | } else { | ||
1862 | n_elem = t->num_scatter; | ||
1863 | } | ||
1864 | |||
1865 | rc = mvs_tag_alloc(mvi, &tag); | ||
1866 | if (rc) | ||
1867 | goto err_out; | ||
1868 | |||
1869 | mvi->slot_info[tag].task = t; | ||
1870 | mvi->slot_info[tag].n_elem = n_elem; | ||
1871 | memset(mvi->slot_info[tag].buf, 0, MVS_SLOT_BUF_SZ); | ||
1872 | tei.task = t; | ||
1873 | tei.hdr = &mvi->slot[tag]; | ||
1874 | tei.tag = tag; | ||
1875 | tei.n_elem = n_elem; | ||
1876 | |||
1877 | switch (t->task_proto) { | ||
1878 | case SAS_PROTOCOL_SMP: | ||
1879 | rc = mvs_task_prep_smp(mvi, &tei); | ||
1880 | break; | ||
1881 | case SAS_PROTOCOL_SSP: | ||
1882 | rc = mvs_task_prep_ssp(mvi, &tei); | ||
1883 | break; | ||
1884 | case SAS_PROTOCOL_SATA: | ||
1885 | case SAS_PROTOCOL_STP: | ||
1886 | case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: | ||
1887 | rc = mvs_task_prep_ata(mvi, &tei); | ||
1888 | break; | ||
1889 | default: | ||
1890 | dev_printk(KERN_ERR, &pdev->dev, | ||
1891 | "unknown sas_task proto: 0x%x\n", | ||
1892 | t->task_proto); | ||
1893 | rc = -EINVAL; | ||
1894 | break; | ||
1895 | } | ||
1896 | |||
1897 | if (rc) | ||
1898 | goto err_out_tag; | ||
1899 | |||
1900 | /* TODO: select normal or high priority */ | ||
1901 | |||
1902 | spin_lock(&t->task_state_lock); | ||
1903 | t->task_state_flags |= SAS_TASK_AT_INITIATOR; | ||
1904 | spin_unlock(&t->task_state_lock); | ||
1905 | |||
1906 | if (n == 1) { | ||
1907 | spin_unlock_irqrestore(&mvi->lock, flags); | ||
1908 | mw32(TX_PROD_IDX, mvi->tx_prod); | ||
1909 | } | ||
1910 | mvs_hba_memory_dump(mvi, tag, t->task_proto); | ||
1911 | |||
1912 | ++pass; | ||
1913 | mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1); | ||
1914 | |||
1915 | if (n == 1) | ||
1916 | break; | ||
1917 | |||
1918 | t = list_entry(t->list.next, struct sas_task, list); | ||
1919 | } while (--n); | ||
1920 | |||
1921 | return 0; | ||
1922 | |||
1923 | err_out_tag: | ||
1924 | mvs_tag_free(mvi, tag); | ||
1925 | err_out: | ||
1926 | dev_printk(KERN_ERR, &pdev->dev, "mvsas exec failed[%d]!\n", rc); | ||
1927 | if (!sas_protocol_ata(t->task_proto)) | ||
1928 | if (n_elem) | ||
1929 | pci_unmap_sg(mvi->pdev, t->scatter, n_elem, | ||
1930 | t->data_dir); | ||
1931 | exec_exit: | ||
1932 | if (pass) | ||
1933 | mw32(TX_PROD_IDX, (mvi->tx_prod - 1) & (MVS_CHIP_SLOT_SZ - 1)); | ||
1934 | spin_unlock_irqrestore(&mvi->lock, flags); | ||
1935 | return rc; | ||
1936 | } | ||
1937 | |||
1938 | static int mvs_task_abort(struct sas_task *task) | ||
1939 | { | ||
1940 | int rc = 1; | ||
1941 | unsigned long flags; | ||
1942 | struct mvs_info *mvi = task->dev->port->ha->lldd_ha; | ||
1943 | struct pci_dev *pdev = mvi->pdev; | ||
1944 | |||
1945 | spin_lock_irqsave(&task->task_state_lock, flags); | ||
1946 | if (task->task_state_flags & SAS_TASK_STATE_DONE) { | ||
1947 | rc = TMF_RESP_FUNC_COMPLETE; | ||
1948 | goto out_done; | ||
1949 | } | ||
1950 | spin_unlock_irqrestore(&task->task_state_lock, flags); | ||
1951 | |||
1952 | /*FIXME*/ | ||
1953 | rc = TMF_RESP_FUNC_COMPLETE; | ||
1954 | |||
1955 | switch (task->task_proto) { | ||
1956 | case SAS_PROTOCOL_SMP: | ||
1957 | dev_printk(KERN_DEBUG, &pdev->dev, "SMP Abort! "); | ||
1958 | break; | ||
1959 | case SAS_PROTOCOL_SSP: | ||
1960 | dev_printk(KERN_DEBUG, &pdev->dev, "SSP Abort! "); | ||
1961 | break; | ||
1962 | case SAS_PROTOCOL_SATA: | ||
1963 | case SAS_PROTOCOL_STP: | ||
1964 | case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:{ | ||
1965 | dev_printk(KERN_DEBUG, &pdev->dev, "STP Abort! " | ||
1966 | "Dump D2H FIS: \n"); | ||
1967 | mvs_hexdump(sizeof(struct host_to_dev_fis), | ||
1968 | (void *)&task->ata_task.fis, 0); | ||
1969 | dev_printk(KERN_DEBUG, &pdev->dev, "Dump ATAPI Cmd : \n"); | ||
1970 | mvs_hexdump(16, task->ata_task.atapi_packet, 0); | ||
1971 | break; | ||
1972 | } | ||
1973 | default: | ||
1974 | break; | ||
1975 | } | ||
1976 | out_done: | ||
1977 | return rc; | ||
1978 | } | ||
1979 | |||
1980 | static void mvs_free(struct mvs_info *mvi) | ||
1981 | { | ||
1982 | int i; | ||
1983 | |||
1984 | if (!mvi) | ||
1985 | return; | ||
1986 | |||
1987 | for (i = 0; i < MVS_SLOTS; i++) { | ||
1988 | struct mvs_slot_info *slot = &mvi->slot_info[i]; | ||
1989 | |||
1990 | if (slot->buf) | ||
1991 | dma_free_coherent(&mvi->pdev->dev, MVS_SLOT_BUF_SZ, | ||
1992 | slot->buf, slot->buf_dma); | ||
1993 | } | ||
1994 | |||
1995 | if (mvi->tx) | ||
1996 | dma_free_coherent(&mvi->pdev->dev, | ||
1997 | sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ, | ||
1998 | mvi->tx, mvi->tx_dma); | ||
1999 | if (mvi->rx_fis) | ||
2000 | dma_free_coherent(&mvi->pdev->dev, MVS_RX_FISL_SZ, | ||
2001 | mvi->rx_fis, mvi->rx_fis_dma); | ||
2002 | if (mvi->rx) | ||
2003 | dma_free_coherent(&mvi->pdev->dev, | ||
2004 | sizeof(*mvi->rx) * MVS_RX_RING_SZ, | ||
2005 | mvi->rx, mvi->rx_dma); | ||
2006 | if (mvi->slot) | ||
2007 | dma_free_coherent(&mvi->pdev->dev, | ||
2008 | sizeof(*mvi->slot) * MVS_SLOTS, | ||
2009 | mvi->slot, mvi->slot_dma); | ||
2010 | #ifdef MVS_ENABLE_PERI | ||
2011 | if (mvi->peri_regs) | ||
2012 | iounmap(mvi->peri_regs); | ||
2013 | #endif | ||
2014 | if (mvi->regs) | ||
2015 | iounmap(mvi->regs); | ||
2016 | if (mvi->shost) | ||
2017 | scsi_host_put(mvi->shost); | ||
2018 | kfree(mvi->sas.sas_port); | ||
2019 | kfree(mvi->sas.sas_phy); | ||
2020 | kfree(mvi); | ||
2021 | } | ||
2022 | |||
2023 | /* FIXME: locking? */ | ||
2024 | static int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, | ||
2025 | void *funcdata) | ||
2026 | { | ||
2027 | struct mvs_info *mvi = sas_phy->ha->lldd_ha; | ||
2028 | int rc = 0, phy_id = sas_phy->id; | ||
2029 | u32 tmp; | ||
2030 | |||
2031 | tmp = mvs_read_phy_ctl(mvi, phy_id); | ||
2032 | |||
2033 | switch (func) { | ||
2034 | case PHY_FUNC_SET_LINK_RATE:{ | ||
2035 | struct sas_phy_linkrates *rates = funcdata; | ||
2036 | u32 lrmin = 0, lrmax = 0; | ||
2037 | |||
2038 | lrmin = (rates->minimum_linkrate << 8); | ||
2039 | lrmax = (rates->maximum_linkrate << 12); | ||
2040 | |||
2041 | if (lrmin) { | ||
2042 | tmp &= ~(0xf << 8); | ||
2043 | tmp |= lrmin; | ||
2044 | } | ||
2045 | if (lrmax) { | ||
2046 | tmp &= ~(0xf << 12); | ||
2047 | tmp |= lrmax; | ||
2048 | } | ||
2049 | mvs_write_phy_ctl(mvi, phy_id, tmp); | ||
2050 | break; | ||
2051 | } | ||
2052 | |||
2053 | case PHY_FUNC_HARD_RESET: | ||
2054 | if (tmp & PHY_RST_HARD) | ||
2055 | break; | ||
2056 | mvs_write_phy_ctl(mvi, phy_id, tmp | PHY_RST_HARD); | ||
2057 | break; | ||
2058 | |||
2059 | case PHY_FUNC_LINK_RESET: | ||
2060 | mvs_write_phy_ctl(mvi, phy_id, tmp | PHY_RST); | ||
2061 | break; | ||
2062 | |||
2063 | case PHY_FUNC_DISABLE: | ||
2064 | case PHY_FUNC_RELEASE_SPINUP_HOLD: | ||
2065 | default: | ||
2066 | rc = -EOPNOTSUPP; | ||
2067 | } | ||
2068 | |||
2069 | return rc; | ||
2070 | } | ||
2071 | |||
2072 | static void __devinit mvs_phy_init(struct mvs_info *mvi, int phy_id) | ||
2073 | { | ||
2074 | struct mvs_phy *phy = &mvi->phy[phy_id]; | ||
2075 | struct asd_sas_phy *sas_phy = &phy->sas_phy; | ||
2076 | |||
2077 | sas_phy->enabled = (phy_id < mvi->chip->n_phy) ? 1 : 0; | ||
2078 | sas_phy->class = SAS; | ||
2079 | sas_phy->iproto = SAS_PROTOCOL_ALL; | ||
2080 | sas_phy->tproto = 0; | ||
2081 | sas_phy->type = PHY_TYPE_PHYSICAL; | ||
2082 | sas_phy->role = PHY_ROLE_INITIATOR; | ||
2083 | sas_phy->oob_mode = OOB_NOT_CONNECTED; | ||
2084 | sas_phy->linkrate = SAS_LINK_RATE_UNKNOWN; | ||
2085 | |||
2086 | sas_phy->id = phy_id; | ||
2087 | sas_phy->sas_addr = &mvi->sas_addr[0]; | ||
2088 | sas_phy->frame_rcvd = &phy->frame_rcvd[0]; | ||
2089 | sas_phy->ha = &mvi->sas; | ||
2090 | sas_phy->lldd_phy = phy; | ||
2091 | } | ||
2092 | |||
2093 | static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev, | ||
2094 | const struct pci_device_id *ent) | ||
2095 | { | ||
2096 | struct mvs_info *mvi; | ||
2097 | unsigned long res_start, res_len, res_flag; | ||
2098 | struct asd_sas_phy **arr_phy; | ||
2099 | struct asd_sas_port **arr_port; | ||
2100 | const struct mvs_chip_info *chip = &mvs_chips[ent->driver_data]; | ||
2101 | int i; | ||
2102 | |||
2103 | /* | ||
2104 | * alloc and init our per-HBA mvs_info struct | ||
2105 | */ | ||
2106 | |||
2107 | mvi = kzalloc(sizeof(*mvi), GFP_KERNEL); | ||
2108 | if (!mvi) | ||
2109 | return NULL; | ||
2110 | |||
2111 | spin_lock_init(&mvi->lock); | ||
2112 | mvi->pdev = pdev; | ||
2113 | mvi->chip = chip; | ||
2114 | |||
2115 | if (pdev->device == 0x6440 && pdev->revision == 0) | ||
2116 | mvi->flags |= MVF_PHY_PWR_FIX; | ||
2117 | |||
2118 | /* | ||
2119 | * alloc and init SCSI, SAS glue | ||
2120 | */ | ||
2121 | |||
2122 | mvi->shost = scsi_host_alloc(&mvs_sht, sizeof(void *)); | ||
2123 | if (!mvi->shost) | ||
2124 | goto err_out; | ||
2125 | |||
2126 | arr_phy = kcalloc(MVS_MAX_PHYS, sizeof(void *), GFP_KERNEL); | ||
2127 | arr_port = kcalloc(MVS_MAX_PHYS, sizeof(void *), GFP_KERNEL); | ||
2128 | if (!arr_phy || !arr_port) | ||
2129 | goto err_out; | ||
2130 | |||
2131 | for (i = 0; i < MVS_MAX_PHYS; i++) { | ||
2132 | mvs_phy_init(mvi, i); | ||
2133 | arr_phy[i] = &mvi->phy[i].sas_phy; | ||
2134 | arr_port[i] = &mvi->port[i].sas_port; | ||
2135 | } | ||
2136 | |||
2137 | SHOST_TO_SAS_HA(mvi->shost) = &mvi->sas; | ||
2138 | mvi->shost->transportt = mvs_stt; | ||
2139 | mvi->shost->max_id = 21; | ||
2140 | mvi->shost->max_lun = ~0; | ||
2141 | mvi->shost->max_channel = 0; | ||
2142 | mvi->shost->max_cmd_len = 16; | ||
2143 | |||
2144 | mvi->sas.sas_ha_name = DRV_NAME; | ||
2145 | mvi->sas.dev = &pdev->dev; | ||
2146 | mvi->sas.lldd_module = THIS_MODULE; | ||
2147 | mvi->sas.sas_addr = &mvi->sas_addr[0]; | ||
2148 | mvi->sas.sas_phy = arr_phy; | ||
2149 | mvi->sas.sas_port = arr_port; | ||
2150 | mvi->sas.num_phys = chip->n_phy; | ||
2151 | mvi->sas.lldd_max_execute_num = MVS_CHIP_SLOT_SZ - 1; | ||
2152 | mvi->sas.lldd_queue_size = MVS_QUEUE_SIZE; | ||
2153 | mvi->can_queue = (MVS_CHIP_SLOT_SZ >> 1) - 1; | ||
2154 | mvi->sas.lldd_ha = mvi; | ||
2155 | mvi->sas.core.shost = mvi->shost; | ||
2156 | |||
2157 | mvs_tag_init(mvi); | ||
2158 | |||
2159 | /* | ||
2160 | * ioremap main and peripheral registers | ||
2161 | */ | ||
2162 | |||
2163 | #ifdef MVS_ENABLE_PERI | ||
2164 | res_start = pci_resource_start(pdev, 2); | ||
2165 | res_len = pci_resource_len(pdev, 2); | ||
2166 | if (!res_start || !res_len) | ||
2167 | goto err_out; | ||
2168 | |||
2169 | mvi->peri_regs = ioremap_nocache(res_start, res_len); | ||
2170 | if (!mvi->peri_regs) | ||
2171 | goto err_out; | ||
2172 | #endif | ||
2173 | |||
2174 | res_start = pci_resource_start(pdev, 4); | ||
2175 | res_len = pci_resource_len(pdev, 4); | ||
2176 | if (!res_start || !res_len) | ||
2177 | goto err_out; | ||
2178 | |||
2179 | res_flag = pci_resource_flags(pdev, 4); | ||
2180 | if (res_flag & IORESOURCE_CACHEABLE) | ||
2181 | mvi->regs = ioremap(res_start, res_len); | ||
2182 | else | ||
2183 | mvi->regs = ioremap_nocache(res_start, res_len); | ||
2184 | |||
2185 | if (!mvi->regs) | ||
2186 | goto err_out; | ||
2187 | |||
2188 | /* | ||
2189 | * alloc and init our DMA areas | ||
2190 | */ | ||
2191 | |||
2192 | mvi->tx = dma_alloc_coherent(&pdev->dev, | ||
2193 | sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ, | ||
2194 | &mvi->tx_dma, GFP_KERNEL); | ||
2195 | if (!mvi->tx) | ||
2196 | goto err_out; | ||
2197 | memset(mvi->tx, 0, sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ); | ||
2198 | |||
2199 | mvi->rx_fis = dma_alloc_coherent(&pdev->dev, MVS_RX_FISL_SZ, | ||
2200 | &mvi->rx_fis_dma, GFP_KERNEL); | ||
2201 | if (!mvi->rx_fis) | ||
2202 | goto err_out; | ||
2203 | memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ); | ||
2204 | |||
2205 | mvi->rx = dma_alloc_coherent(&pdev->dev, | ||
2206 | sizeof(*mvi->rx) * MVS_RX_RING_SZ, | ||
2207 | &mvi->rx_dma, GFP_KERNEL); | ||
2208 | if (!mvi->rx) | ||
2209 | goto err_out; | ||
2210 | memset(mvi->rx, 0, sizeof(*mvi->rx) * MVS_RX_RING_SZ); | ||
2211 | |||
2212 | mvi->rx[0] = cpu_to_le32(0xfff); | ||
2213 | mvi->rx_cons = 0xfff; | ||
2214 | |||
2215 | mvi->slot = dma_alloc_coherent(&pdev->dev, | ||
2216 | sizeof(*mvi->slot) * MVS_SLOTS, | ||
2217 | &mvi->slot_dma, GFP_KERNEL); | ||
2218 | if (!mvi->slot) | ||
2219 | goto err_out; | ||
2220 | memset(mvi->slot, 0, sizeof(*mvi->slot) * MVS_SLOTS); | ||
2221 | |||
2222 | for (i = 0; i < MVS_SLOTS; i++) { | ||
2223 | struct mvs_slot_info *slot = &mvi->slot_info[i]; | ||
2224 | |||
2225 | slot->buf = dma_alloc_coherent(&pdev->dev, MVS_SLOT_BUF_SZ, | ||
2226 | &slot->buf_dma, GFP_KERNEL); | ||
2227 | if (!slot->buf) | ||
2228 | goto err_out; | ||
2229 | memset(slot->buf, 0, MVS_SLOT_BUF_SZ); | ||
2230 | } | ||
2231 | |||
2232 | /* finally, read NVRAM to get our SAS address */ | ||
2233 | if (mvs_nvram_read(mvi, NVR_SAS_ADDR, &mvi->sas_addr, 8)) | ||
2234 | goto err_out; | ||
2235 | return mvi; | ||
2236 | |||
2237 | err_out: | ||
2238 | mvs_free(mvi); | ||
2239 | return NULL; | ||
2240 | } | ||
2241 | |||
2242 | static u32 mvs_cr32(void __iomem *regs, u32 addr) | ||
2243 | { | ||
2244 | mw32(CMD_ADDR, addr); | ||
2245 | return mr32(CMD_DATA); | ||
2246 | } | ||
2247 | |||
2248 | static void mvs_cw32(void __iomem *regs, u32 addr, u32 val) | ||
2249 | { | ||
2250 | mw32(CMD_ADDR, addr); | ||
2251 | mw32(CMD_DATA, val); | ||
2252 | } | ||
2253 | |||
2254 | static u32 mvs_read_phy_ctl(struct mvs_info *mvi, u32 port) | ||
2255 | { | ||
2256 | void __iomem *regs = mvi->regs; | ||
2257 | return (port < 4)?mr32(P0_SER_CTLSTAT + port * 4): | ||
2258 | mr32(P4_SER_CTLSTAT + (port - 4) * 4); | ||
2259 | } | ||
2260 | |||
2261 | static void mvs_write_phy_ctl(struct mvs_info *mvi, u32 port, u32 val) | ||
2262 | { | ||
2263 | void __iomem *regs = mvi->regs; | ||
2264 | if (port < 4) | ||
2265 | mw32(P0_SER_CTLSTAT + port * 4, val); | ||
2266 | else | ||
2267 | mw32(P4_SER_CTLSTAT + (port - 4) * 4, val); | ||
2268 | } | ||
2269 | |||
2270 | static u32 mvs_read_port(struct mvs_info *mvi, u32 off, u32 off2, u32 port) | ||
2271 | { | ||
2272 | void __iomem *regs = mvi->regs + off; | ||
2273 | void __iomem *regs2 = mvi->regs + off2; | ||
2274 | return (port < 4)?readl(regs + port * 8): | ||
2275 | readl(regs2 + (port - 4) * 8); | ||
2276 | } | ||
2277 | |||
2278 | static void mvs_write_port(struct mvs_info *mvi, u32 off, u32 off2, | ||
2279 | u32 port, u32 val) | ||
2280 | { | ||
2281 | void __iomem *regs = mvi->regs + off; | ||
2282 | void __iomem *regs2 = mvi->regs + off2; | ||
2283 | if (port < 4) | ||
2284 | writel(val, regs + port * 8); | ||
2285 | else | ||
2286 | writel(val, regs2 + (port - 4) * 8); | ||
2287 | } | ||
2288 | |||
2289 | static u32 mvs_read_port_cfg_data(struct mvs_info *mvi, u32 port) | ||
2290 | { | ||
2291 | return mvs_read_port(mvi, MVS_P0_CFG_DATA, MVS_P4_CFG_DATA, port); | ||
2292 | } | ||
2293 | |||
2294 | static void mvs_write_port_cfg_data(struct mvs_info *mvi, u32 port, u32 val) | ||
2295 | { | ||
2296 | mvs_write_port(mvi, MVS_P0_CFG_DATA, MVS_P4_CFG_DATA, port, val); | ||
2297 | } | ||
2298 | |||
2299 | static void mvs_write_port_cfg_addr(struct mvs_info *mvi, u32 port, u32 addr) | ||
2300 | { | ||
2301 | mvs_write_port(mvi, MVS_P0_CFG_ADDR, MVS_P4_CFG_ADDR, port, addr); | ||
2302 | } | ||
2303 | |||
2304 | static u32 mvs_read_port_vsr_data(struct mvs_info *mvi, u32 port) | ||
2305 | { | ||
2306 | return mvs_read_port(mvi, MVS_P0_VSR_DATA, MVS_P4_VSR_DATA, port); | ||
2307 | } | ||
2308 | |||
2309 | static void mvs_write_port_vsr_data(struct mvs_info *mvi, u32 port, u32 val) | ||
2310 | { | ||
2311 | mvs_write_port(mvi, MVS_P0_VSR_DATA, MVS_P4_VSR_DATA, port, val); | ||
2312 | } | ||
2313 | |||
2314 | static void mvs_write_port_vsr_addr(struct mvs_info *mvi, u32 port, u32 addr) | ||
2315 | { | ||
2316 | mvs_write_port(mvi, MVS_P0_VSR_ADDR, MVS_P4_VSR_ADDR, port, addr); | ||
2317 | } | ||
2318 | |||
2319 | static u32 mvs_read_port_irq_stat(struct mvs_info *mvi, u32 port) | ||
2320 | { | ||
2321 | return mvs_read_port(mvi, MVS_P0_INT_STAT, MVS_P4_INT_STAT, port); | ||
2322 | } | ||
2323 | |||
2324 | static void mvs_write_port_irq_stat(struct mvs_info *mvi, u32 port, u32 val) | ||
2325 | { | ||
2326 | mvs_write_port(mvi, MVS_P0_INT_STAT, MVS_P4_INT_STAT, port, val); | ||
2327 | } | ||
2328 | |||
2329 | static u32 mvs_read_port_irq_mask(struct mvs_info *mvi, u32 port) | ||
2330 | { | ||
2331 | return mvs_read_port(mvi, MVS_P0_INT_MASK, MVS_P4_INT_MASK, port); | ||
2332 | } | ||
2333 | |||
2334 | static void mvs_write_port_irq_mask(struct mvs_info *mvi, u32 port, u32 val) | ||
2335 | { | ||
2336 | mvs_write_port(mvi, MVS_P0_INT_MASK, MVS_P4_INT_MASK, port, val); | ||
2337 | } | ||
2338 | |||
2339 | static void __devinit mvs_phy_hacks(struct mvs_info *mvi) | ||
2340 | { | ||
2341 | void __iomem *regs = mvi->regs; | ||
2342 | u32 tmp; | ||
2343 | |||
2344 | /* workaround for SATA R-ERR, to ignore phy glitch */ | ||
2345 | tmp = mvs_cr32(regs, CMD_PHY_TIMER); | ||
2346 | tmp &= ~(1 << 9); | ||
2347 | tmp |= (1 << 10); | ||
2348 | mvs_cw32(regs, CMD_PHY_TIMER, tmp); | ||
2349 | |||
2350 | /* enable retry 127 times */ | ||
2351 | mvs_cw32(regs, CMD_SAS_CTL1, 0x7f7f); | ||
2352 | |||
2353 | /* extend open frame timeout to max */ | ||
2354 | tmp = mvs_cr32(regs, CMD_SAS_CTL0); | ||
2355 | tmp &= ~0xffff; | ||
2356 | tmp |= 0x3fff; | ||
2357 | mvs_cw32(regs, CMD_SAS_CTL0, tmp); | ||
2358 | |||
2359 | /* workaround for WDTIMEOUT , set to 550 ms */ | ||
2360 | mvs_cw32(regs, CMD_WD_TIMER, 0xffffff); | ||
2361 | |||
2362 | /* not to halt for different port op during wideport link change */ | ||
2363 | mvs_cw32(regs, CMD_APP_ERR_CONFIG, 0xffefbf7d); | ||
2364 | |||
2365 | /* workaround for Seagate disk not-found OOB sequence, recv | ||
2366 | * COMINIT before sending out COMWAKE */ | ||
2367 | tmp = mvs_cr32(regs, CMD_PHY_MODE_21); | ||
2368 | tmp &= 0x0000ffff; | ||
2369 | tmp |= 0x00fa0000; | ||
2370 | mvs_cw32(regs, CMD_PHY_MODE_21, tmp); | ||
2371 | |||
2372 | tmp = mvs_cr32(regs, CMD_PHY_TIMER); | ||
2373 | tmp &= 0x1fffffff; | ||
2374 | tmp |= (2U << 29); /* 8 ms retry */ | ||
2375 | mvs_cw32(regs, CMD_PHY_TIMER, tmp); | ||
2376 | |||
2377 | /* TEST - for phy decoding error, adjust voltage levels */ | ||
2378 | mw32(P0_VSR_ADDR + 0, 0x8); | ||
2379 | mw32(P0_VSR_DATA + 0, 0x2F0); | ||
2380 | |||
2381 | mw32(P0_VSR_ADDR + 8, 0x8); | ||
2382 | mw32(P0_VSR_DATA + 8, 0x2F0); | ||
2383 | |||
2384 | mw32(P0_VSR_ADDR + 16, 0x8); | ||
2385 | mw32(P0_VSR_DATA + 16, 0x2F0); | ||
2386 | |||
2387 | mw32(P0_VSR_ADDR + 24, 0x8); | ||
2388 | mw32(P0_VSR_DATA + 24, 0x2F0); | ||
2389 | |||
2390 | } | ||
2391 | |||
2392 | static void mvs_enable_xmt(struct mvs_info *mvi, int PhyId) | ||
2393 | { | ||
2394 | void __iomem *regs = mvi->regs; | ||
2395 | u32 tmp; | ||
2396 | |||
2397 | tmp = mr32(PCS); | ||
2398 | if (mvi->chip->n_phy <= 4) | ||
2399 | tmp |= 1 << (PhyId + PCS_EN_PORT_XMT_SHIFT); | ||
2400 | else | ||
2401 | tmp |= 1 << (PhyId + PCS_EN_PORT_XMT_SHIFT2); | ||
2402 | mw32(PCS, tmp); | ||
2403 | } | ||
2404 | |||
2405 | static void mvs_detect_porttype(struct mvs_info *mvi, int i) | ||
2406 | { | ||
2407 | void __iomem *regs = mvi->regs; | ||
2408 | u32 reg; | ||
2409 | struct mvs_phy *phy = &mvi->phy[i]; | ||
2410 | |||
2411 | /* TODO check & save device type */ | ||
2412 | reg = mr32(GBL_PORT_TYPE); | ||
2413 | |||
2414 | if (reg & MODE_SAS_SATA & (1 << i)) | ||
2415 | phy->phy_type |= PORT_TYPE_SAS; | ||
2416 | else | ||
2417 | phy->phy_type |= PORT_TYPE_SATA; | ||
2418 | } | ||
2419 | |||
2420 | static void *mvs_get_d2h_reg(struct mvs_info *mvi, int i, void *buf) | ||
2421 | { | ||
2422 | u32 *s = (u32 *) buf; | ||
2423 | |||
2424 | if (!s) | ||
2425 | return NULL; | ||
2426 | |||
2427 | mvs_write_port_cfg_addr(mvi, i, PHYR_SATA_SIG3); | ||
2428 | s[3] = mvs_read_port_cfg_data(mvi, i); | ||
2429 | |||
2430 | mvs_write_port_cfg_addr(mvi, i, PHYR_SATA_SIG2); | ||
2431 | s[2] = mvs_read_port_cfg_data(mvi, i); | ||
2432 | |||
2433 | mvs_write_port_cfg_addr(mvi, i, PHYR_SATA_SIG1); | ||
2434 | s[1] = mvs_read_port_cfg_data(mvi, i); | ||
2435 | |||
2436 | mvs_write_port_cfg_addr(mvi, i, PHYR_SATA_SIG0); | ||
2437 | s[0] = mvs_read_port_cfg_data(mvi, i); | ||
2438 | |||
2439 | return (void *)s; | ||
2440 | } | ||
2441 | |||
2442 | static u32 mvs_is_sig_fis_received(u32 irq_status) | ||
2443 | { | ||
2444 | return irq_status & PHYEV_SIG_FIS; | ||
2445 | } | ||
2446 | |||
2447 | static void mvs_update_wideport(struct mvs_info *mvi, int i) | ||
2448 | { | ||
2449 | struct mvs_phy *phy = &mvi->phy[i]; | ||
2450 | struct mvs_port *port = phy->port; | ||
2451 | int j, no; | ||
2452 | |||
2453 | for_each_phy(port->wide_port_phymap, no, j, mvi->chip->n_phy) | ||
2454 | if (no & 1) { | ||
2455 | mvs_write_port_cfg_addr(mvi, no, PHYR_WIDE_PORT); | ||
2456 | mvs_write_port_cfg_data(mvi, no, | ||
2457 | port->wide_port_phymap); | ||
2458 | } else { | ||
2459 | mvs_write_port_cfg_addr(mvi, no, PHYR_WIDE_PORT); | ||
2460 | mvs_write_port_cfg_data(mvi, no, 0); | ||
2461 | } | ||
2462 | } | ||
2463 | |||
2464 | static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i) | ||
2465 | { | ||
2466 | u32 tmp; | ||
2467 | struct mvs_phy *phy = &mvi->phy[i]; | ||
2468 | struct mvs_port *port; | ||
2469 | |||
2470 | tmp = mvs_read_phy_ctl(mvi, i); | ||
2471 | |||
2472 | if ((tmp & PHY_READY_MASK) && !(phy->irq_status & PHYEV_POOF)) { | ||
2473 | if (!phy->port) | ||
2474 | phy->phy_attached = 1; | ||
2475 | return tmp; | ||
2476 | } | ||
2477 | |||
2478 | port = phy->port; | ||
2479 | if (port) { | ||
2480 | if (phy->phy_type & PORT_TYPE_SAS) { | ||
2481 | port->wide_port_phymap &= ~(1U << i); | ||
2482 | if (!port->wide_port_phymap) | ||
2483 | port->port_attached = 0; | ||
2484 | mvs_update_wideport(mvi, i); | ||
2485 | } else if (phy->phy_type & PORT_TYPE_SATA) | ||
2486 | port->port_attached = 0; | ||
2487 | mvs_free_reg_set(mvi, phy->port); | ||
2488 | phy->port = NULL; | ||
2489 | phy->phy_attached = 0; | ||
2490 | phy->phy_type &= ~(PORT_TYPE_SAS | PORT_TYPE_SATA); | ||
2491 | } | ||
2492 | return 0; | ||
2493 | } | ||
2494 | |||
2495 | static void mvs_update_phyinfo(struct mvs_info *mvi, int i, | ||
2496 | int get_st) | ||
2497 | { | ||
2498 | struct mvs_phy *phy = &mvi->phy[i]; | ||
2499 | struct pci_dev *pdev = mvi->pdev; | ||
2500 | u32 tmp, j; | ||
2501 | u64 tmp64; | ||
2502 | |||
2503 | mvs_write_port_cfg_addr(mvi, i, PHYR_IDENTIFY); | ||
2504 | phy->dev_info = mvs_read_port_cfg_data(mvi, i); | ||
2505 | |||
2506 | mvs_write_port_cfg_addr(mvi, i, PHYR_ADDR_HI); | ||
2507 | phy->dev_sas_addr = (u64) mvs_read_port_cfg_data(mvi, i) << 32; | ||
2508 | |||
2509 | mvs_write_port_cfg_addr(mvi, i, PHYR_ADDR_LO); | ||
2510 | phy->dev_sas_addr |= mvs_read_port_cfg_data(mvi, i); | ||
2511 | |||
2512 | if (get_st) { | ||
2513 | phy->irq_status = mvs_read_port_irq_stat(mvi, i); | ||
2514 | phy->phy_status = mvs_is_phy_ready(mvi, i); | ||
2515 | } | ||
2516 | |||
2517 | if (phy->phy_status) { | ||
2518 | u32 phy_st; | ||
2519 | struct asd_sas_phy *sas_phy = mvi->sas.sas_phy[i]; | ||
2520 | |||
2521 | mvs_write_port_cfg_addr(mvi, i, PHYR_PHY_STAT); | ||
2522 | phy_st = mvs_read_port_cfg_data(mvi, i); | ||
2523 | |||
2524 | sas_phy->linkrate = | ||
2525 | (phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >> | ||
2526 | PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET; | ||
2527 | |||
2528 | /* Updated attached_sas_addr */ | ||
2529 | mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_HI); | ||
2530 | phy->att_dev_sas_addr = | ||
2531 | (u64) mvs_read_port_cfg_data(mvi, i) << 32; | ||
2532 | |||
2533 | mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_LO); | ||
2534 | phy->att_dev_sas_addr |= mvs_read_port_cfg_data(mvi, i); | ||
2535 | |||
2536 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
2537 | "phy[%d] Get Attached Address 0x%llX ," | ||
2538 | " SAS Address 0x%llX\n", | ||
2539 | i, phy->att_dev_sas_addr, phy->dev_sas_addr); | ||
2540 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
2541 | "Rate = %x , type = %d\n", | ||
2542 | sas_phy->linkrate, phy->phy_type); | ||
2543 | |||
2544 | #if 1 | ||
2545 | /* | ||
2546 | * If the device is capable of supporting a wide port | ||
2547 | * on its phys, it may configure the phys as a wide port. | ||
2548 | */ | ||
2549 | if (phy->phy_type & PORT_TYPE_SAS) | ||
2550 | for (j = 0; j < mvi->chip->n_phy && j != i; ++j) { | ||
2551 | if ((mvi->phy[j].phy_attached) && | ||
2552 | (mvi->phy[j].phy_type & PORT_TYPE_SAS)) | ||
2553 | if (phy->att_dev_sas_addr == | ||
2554 | mvi->phy[j].att_dev_sas_addr - 1) { | ||
2555 | phy->att_dev_sas_addr = | ||
2556 | mvi->phy[j].att_dev_sas_addr; | ||
2557 | break; | ||
2558 | } | ||
2559 | } | ||
2560 | |||
2561 | #endif | ||
2562 | |||
2563 | tmp64 = cpu_to_be64(phy->att_dev_sas_addr); | ||
2564 | memcpy(sas_phy->attached_sas_addr, &tmp64, SAS_ADDR_SIZE); | ||
2565 | |||
2566 | if (phy->phy_type & PORT_TYPE_SAS) { | ||
2567 | mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_DEV_INFO); | ||
2568 | phy->att_dev_info = mvs_read_port_cfg_data(mvi, i); | ||
2569 | phy->identify.device_type = | ||
2570 | phy->att_dev_info & PORT_DEV_TYPE_MASK; | ||
2571 | |||
2572 | if (phy->identify.device_type == SAS_END_DEV) | ||
2573 | phy->identify.target_port_protocols = | ||
2574 | SAS_PROTOCOL_SSP; | ||
2575 | else if (phy->identify.device_type != NO_DEVICE) | ||
2576 | phy->identify.target_port_protocols = | ||
2577 | SAS_PROTOCOL_SMP; | ||
2578 | if (phy_st & PHY_OOB_DTCTD) | ||
2579 | sas_phy->oob_mode = SAS_OOB_MODE; | ||
2580 | phy->frame_rcvd_size = | ||
2581 | sizeof(struct sas_identify_frame); | ||
2582 | } else if (phy->phy_type & PORT_TYPE_SATA) { | ||
2583 | phy->identify.target_port_protocols = SAS_PROTOCOL_STP; | ||
2584 | if (mvs_is_sig_fis_received(phy->irq_status)) { | ||
2585 | if (phy_st & PHY_OOB_DTCTD) | ||
2586 | sas_phy->oob_mode = SATA_OOB_MODE; | ||
2587 | phy->frame_rcvd_size = | ||
2588 | sizeof(struct dev_to_host_fis); | ||
2589 | mvs_get_d2h_reg(mvi, i, | ||
2590 | (void *)sas_phy->frame_rcvd); | ||
2591 | } else { | ||
2592 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
2593 | "No sig fis\n"); | ||
2594 | } | ||
2595 | } | ||
2596 | /* workaround for HW phy decoding error on 1.5g disk drive */ | ||
2597 | mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE6); | ||
2598 | tmp = mvs_read_port_vsr_data(mvi, i); | ||
2599 | if (((phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >> | ||
2600 | PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET) == | ||
2601 | SAS_LINK_RATE_1_5_GBPS) | ||
2602 | tmp &= ~PHY_MODE6_DTL_SPEED; | ||
2603 | else | ||
2604 | tmp |= PHY_MODE6_DTL_SPEED; | ||
2605 | mvs_write_port_vsr_data(mvi, i, tmp); | ||
2606 | |||
2607 | } | ||
2608 | if (get_st) | ||
2609 | mvs_write_port_irq_stat(mvi, i, phy->irq_status); | ||
2610 | } | ||
2611 | |||
2612 | static void mvs_port_formed(struct asd_sas_phy *sas_phy) | ||
2613 | { | ||
2614 | struct sas_ha_struct *sas_ha = sas_phy->ha; | ||
2615 | struct mvs_info *mvi = sas_ha->lldd_ha; | ||
2616 | struct asd_sas_port *sas_port = sas_phy->port; | ||
2617 | struct mvs_phy *phy = sas_phy->lldd_phy; | ||
2618 | struct mvs_port *port = &mvi->port[sas_port->id]; | ||
2619 | unsigned long flags; | ||
2620 | |||
2621 | spin_lock_irqsave(&mvi->lock, flags); | ||
2622 | port->port_attached = 1; | ||
2623 | phy->port = port; | ||
2624 | port->taskfileset = MVS_ID_NOT_MAPPED; | ||
2625 | if (phy->phy_type & PORT_TYPE_SAS) { | ||
2626 | port->wide_port_phymap = sas_port->phy_mask; | ||
2627 | mvs_update_wideport(mvi, sas_phy->id); | ||
2628 | } | ||
2629 | spin_unlock_irqrestore(&mvi->lock, flags); | ||
2630 | } | ||
2631 | |||
2632 | static int __devinit mvs_hw_init(struct mvs_info *mvi) | ||
2633 | { | ||
2634 | void __iomem *regs = mvi->regs; | ||
2635 | int i; | ||
2636 | u32 tmp, cctl; | ||
2637 | |||
2638 | /* make sure interrupts are masked immediately (paranoia) */ | ||
2639 | mw32(GBL_CTL, 0); | ||
2640 | tmp = mr32(GBL_CTL); | ||
2641 | |||
2642 | /* Reset Controller */ | ||
2643 | if (!(tmp & HBA_RST)) { | ||
2644 | if (mvi->flags & MVF_PHY_PWR_FIX) { | ||
2645 | pci_read_config_dword(mvi->pdev, PCR_PHY_CTL, &tmp); | ||
2646 | tmp &= ~PCTL_PWR_ON; | ||
2647 | tmp |= PCTL_OFF; | ||
2648 | pci_write_config_dword(mvi->pdev, PCR_PHY_CTL, tmp); | ||
2649 | |||
2650 | pci_read_config_dword(mvi->pdev, PCR_PHY_CTL2, &tmp); | ||
2651 | tmp &= ~PCTL_PWR_ON; | ||
2652 | tmp |= PCTL_OFF; | ||
2653 | pci_write_config_dword(mvi->pdev, PCR_PHY_CTL2, tmp); | ||
2654 | } | ||
2655 | |||
2656 | /* global reset, incl. COMRESET/H_RESET_N (self-clearing) */ | ||
2657 | mw32_f(GBL_CTL, HBA_RST); | ||
2658 | } | ||
2659 | |||
2660 | /* wait for reset to finish; timeout is just a guess */ | ||
2661 | i = 1000; | ||
2662 | while (i-- > 0) { | ||
2663 | msleep(10); | ||
2664 | |||
2665 | if (!(mr32(GBL_CTL) & HBA_RST)) | ||
2666 | break; | ||
2667 | } | ||
2668 | if (mr32(GBL_CTL) & HBA_RST) { | ||
2669 | dev_printk(KERN_ERR, &mvi->pdev->dev, "HBA reset failed\n"); | ||
2670 | return -EBUSY; | ||
2671 | } | ||
2672 | |||
2673 | /* Init Chip */ | ||
2674 | /* make sure RST is set; HBA_RST /should/ have done that for us */ | ||
2675 | cctl = mr32(CTL); | ||
2676 | if (cctl & CCTL_RST) | ||
2677 | cctl &= ~CCTL_RST; | ||
2678 | else | ||
2679 | mw32_f(CTL, cctl | CCTL_RST); | ||
2680 | |||
2681 | /* write to device control _AND_ device status register? - A.C. */ | ||
2682 | pci_read_config_dword(mvi->pdev, PCR_DEV_CTRL, &tmp); | ||
2683 | tmp &= ~PRD_REQ_MASK; | ||
2684 | tmp |= PRD_REQ_SIZE; | ||
2685 | pci_write_config_dword(mvi->pdev, PCR_DEV_CTRL, tmp); | ||
2686 | |||
2687 | pci_read_config_dword(mvi->pdev, PCR_PHY_CTL, &tmp); | ||
2688 | tmp |= PCTL_PWR_ON; | ||
2689 | tmp &= ~PCTL_OFF; | ||
2690 | pci_write_config_dword(mvi->pdev, PCR_PHY_CTL, tmp); | ||
2691 | |||
2692 | pci_read_config_dword(mvi->pdev, PCR_PHY_CTL2, &tmp); | ||
2693 | tmp |= PCTL_PWR_ON; | ||
2694 | tmp &= ~PCTL_OFF; | ||
2695 | pci_write_config_dword(mvi->pdev, PCR_PHY_CTL2, tmp); | ||
2696 | |||
2697 | mw32_f(CTL, cctl); | ||
2698 | |||
2699 | /* reset control */ | ||
2700 | mw32(PCS, 0); /*MVS_PCS */ | ||
2701 | |||
2702 | mvs_phy_hacks(mvi); | ||
2703 | |||
2704 | mw32(CMD_LIST_LO, mvi->slot_dma); | ||
2705 | mw32(CMD_LIST_HI, (mvi->slot_dma >> 16) >> 16); | ||
2706 | |||
2707 | mw32(RX_FIS_LO, mvi->rx_fis_dma); | ||
2708 | mw32(RX_FIS_HI, (mvi->rx_fis_dma >> 16) >> 16); | ||
2709 | |||
2710 | mw32(TX_CFG, MVS_CHIP_SLOT_SZ); | ||
2711 | mw32(TX_LO, mvi->tx_dma); | ||
2712 | mw32(TX_HI, (mvi->tx_dma >> 16) >> 16); | ||
2713 | |||
2714 | mw32(RX_CFG, MVS_RX_RING_SZ); | ||
2715 | mw32(RX_LO, mvi->rx_dma); | ||
2716 | mw32(RX_HI, (mvi->rx_dma >> 16) >> 16); | ||
2717 | |||
2718 | /* enable auto port detection */ | ||
2719 | mw32(GBL_PORT_TYPE, MODE_AUTO_DET_EN); | ||
2720 | msleep(100); | ||
2721 | /* init and reset phys */ | ||
2722 | for (i = 0; i < mvi->chip->n_phy; i++) { | ||
2723 | /* FIXME: is this the correct dword order? */ | ||
2724 | u32 lo = *((u32 *)&mvi->sas_addr[0]); | ||
2725 | u32 hi = *((u32 *)&mvi->sas_addr[4]); | ||
2726 | |||
2727 | mvs_detect_porttype(mvi, i); | ||
2728 | |||
2729 | /* set phy local SAS address */ | ||
2730 | mvs_write_port_cfg_addr(mvi, i, PHYR_ADDR_LO); | ||
2731 | mvs_write_port_cfg_data(mvi, i, lo); | ||
2732 | mvs_write_port_cfg_addr(mvi, i, PHYR_ADDR_HI); | ||
2733 | mvs_write_port_cfg_data(mvi, i, hi); | ||
2734 | |||
2735 | /* reset phy */ | ||
2736 | tmp = mvs_read_phy_ctl(mvi, i); | ||
2737 | tmp |= PHY_RST; | ||
2738 | mvs_write_phy_ctl(mvi, i, tmp); | ||
2739 | } | ||
2740 | |||
2741 | msleep(100); | ||
2742 | |||
2743 | for (i = 0; i < mvi->chip->n_phy; i++) { | ||
2744 | /* clear phy int status */ | ||
2745 | tmp = mvs_read_port_irq_stat(mvi, i); | ||
2746 | tmp &= ~PHYEV_SIG_FIS; | ||
2747 | mvs_write_port_irq_stat(mvi, i, tmp); | ||
2748 | |||
2749 | /* set phy int mask */ | ||
2750 | tmp = PHYEV_RDY_CH | PHYEV_BROAD_CH | PHYEV_UNASSOC_FIS | | ||
2751 | PHYEV_ID_DONE | PHYEV_DEC_ERR; | ||
2752 | mvs_write_port_irq_mask(mvi, i, tmp); | ||
2753 | |||
2754 | msleep(100); | ||
2755 | mvs_update_phyinfo(mvi, i, 1); | ||
2756 | mvs_enable_xmt(mvi, i); | ||
2757 | } | ||
2758 | |||
2759 | /* FIXME: update wide port bitmaps */ | ||
2760 | |||
2761 | /* little endian for open address and command table, etc. */ | ||
2762 | /* A.C. | ||
2763 | * it seems that ( from the spec ) turning on big-endian won't | ||
2764 | * do us any good on big-endian machines, need further confirmation | ||
2765 | */ | ||
2766 | cctl = mr32(CTL); | ||
2767 | cctl |= CCTL_ENDIAN_CMD; | ||
2768 | cctl |= CCTL_ENDIAN_DATA; | ||
2769 | cctl &= ~CCTL_ENDIAN_OPEN; | ||
2770 | cctl |= CCTL_ENDIAN_RSP; | ||
2771 | mw32_f(CTL, cctl); | ||
2772 | |||
2773 | /* reset CMD queue */ | ||
2774 | tmp = mr32(PCS); | ||
2775 | tmp |= PCS_CMD_RST; | ||
2776 | mw32(PCS, tmp); | ||
2777 | /* interrupt coalescing may cause missing HW interrput in some case, | ||
2778 | * and the max count is 0x1ff, while our max slot is 0x200, | ||
2779 | * it will make count 0. | ||
2780 | */ | ||
2781 | tmp = 0; | ||
2782 | mw32(INT_COAL, tmp); | ||
2783 | |||
2784 | tmp = 0x100; | ||
2785 | mw32(INT_COAL_TMOUT, tmp); | ||
2786 | |||
2787 | /* ladies and gentlemen, start your engines */ | ||
2788 | mw32(TX_CFG, 0); | ||
2789 | mw32(TX_CFG, MVS_CHIP_SLOT_SZ | TX_EN); | ||
2790 | mw32(RX_CFG, MVS_RX_RING_SZ | RX_EN); | ||
2791 | /* enable CMD/CMPL_Q/RESP mode */ | ||
2792 | mw32(PCS, PCS_SATA_RETRY | PCS_FIS_RX_EN | PCS_CMD_EN); | ||
2793 | |||
2794 | /* re-enable interrupts globally */ | ||
2795 | mvs_hba_interrupt_enable(mvi); | ||
2796 | |||
2797 | /* enable completion queue interrupt */ | ||
2798 | tmp = (CINT_PORT_MASK | CINT_DONE | CINT_MEM); | ||
2799 | mw32(INT_MASK, tmp); | ||
2800 | |||
2801 | return 0; | ||
2802 | } | ||
2803 | |||
2804 | static void __devinit mvs_print_info(struct mvs_info *mvi) | ||
2805 | { | ||
2806 | struct pci_dev *pdev = mvi->pdev; | ||
2807 | static int printed_version; | ||
2808 | |||
2809 | if (!printed_version++) | ||
2810 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); | ||
2811 | |||
2812 | dev_printk(KERN_INFO, &pdev->dev, "%u phys, addr %llx\n", | ||
2813 | mvi->chip->n_phy, SAS_ADDR(mvi->sas_addr)); | ||
2814 | } | ||
2815 | |||
2816 | static int __devinit mvs_pci_init(struct pci_dev *pdev, | ||
2817 | const struct pci_device_id *ent) | ||
2818 | { | ||
2819 | int rc; | ||
2820 | struct mvs_info *mvi; | ||
2821 | irq_handler_t irq_handler = mvs_interrupt; | ||
2822 | |||
2823 | rc = pci_enable_device(pdev); | ||
2824 | if (rc) | ||
2825 | return rc; | ||
2826 | |||
2827 | pci_set_master(pdev); | ||
2828 | |||
2829 | rc = pci_request_regions(pdev, DRV_NAME); | ||
2830 | if (rc) | ||
2831 | goto err_out_disable; | ||
2832 | |||
2833 | rc = pci_go_64(pdev); | ||
2834 | if (rc) | ||
2835 | goto err_out_regions; | ||
2836 | |||
2837 | mvi = mvs_alloc(pdev, ent); | ||
2838 | if (!mvi) { | ||
2839 | rc = -ENOMEM; | ||
2840 | goto err_out_regions; | ||
2841 | } | ||
2842 | |||
2843 | rc = mvs_hw_init(mvi); | ||
2844 | if (rc) | ||
2845 | goto err_out_mvi; | ||
2846 | |||
2847 | #ifndef MVS_DISABLE_MSI | ||
2848 | if (!pci_enable_msi(pdev)) { | ||
2849 | u32 tmp; | ||
2850 | void __iomem *regs = mvi->regs; | ||
2851 | mvi->flags |= MVF_MSI; | ||
2852 | irq_handler = mvs_msi_interrupt; | ||
2853 | tmp = mr32(PCS); | ||
2854 | mw32(PCS, tmp | PCS_SELF_CLEAR); | ||
2855 | } | ||
2856 | #endif | ||
2857 | |||
2858 | rc = request_irq(pdev->irq, irq_handler, IRQF_SHARED, DRV_NAME, mvi); | ||
2859 | if (rc) | ||
2860 | goto err_out_msi; | ||
2861 | |||
2862 | rc = scsi_add_host(mvi->shost, &pdev->dev); | ||
2863 | if (rc) | ||
2864 | goto err_out_irq; | ||
2865 | |||
2866 | rc = sas_register_ha(&mvi->sas); | ||
2867 | if (rc) | ||
2868 | goto err_out_shost; | ||
2869 | |||
2870 | pci_set_drvdata(pdev, mvi); | ||
2871 | |||
2872 | mvs_print_info(mvi); | ||
2873 | |||
2874 | scsi_scan_host(mvi->shost); | ||
2875 | |||
2876 | return 0; | ||
2877 | |||
2878 | err_out_shost: | ||
2879 | scsi_remove_host(mvi->shost); | ||
2880 | err_out_irq: | ||
2881 | free_irq(pdev->irq, mvi); | ||
2882 | err_out_msi: | ||
2883 | if (mvi->flags |= MVF_MSI) | ||
2884 | pci_disable_msi(pdev); | ||
2885 | err_out_mvi: | ||
2886 | mvs_free(mvi); | ||
2887 | err_out_regions: | ||
2888 | pci_release_regions(pdev); | ||
2889 | err_out_disable: | ||
2890 | pci_disable_device(pdev); | ||
2891 | return rc; | ||
2892 | } | ||
2893 | |||
2894 | static void __devexit mvs_pci_remove(struct pci_dev *pdev) | ||
2895 | { | ||
2896 | struct mvs_info *mvi = pci_get_drvdata(pdev); | ||
2897 | |||
2898 | pci_set_drvdata(pdev, NULL); | ||
2899 | |||
2900 | if (mvi) { | ||
2901 | sas_unregister_ha(&mvi->sas); | ||
2902 | mvs_hba_interrupt_disable(mvi); | ||
2903 | sas_remove_host(mvi->shost); | ||
2904 | scsi_remove_host(mvi->shost); | ||
2905 | |||
2906 | free_irq(pdev->irq, mvi); | ||
2907 | if (mvi->flags & MVF_MSI) | ||
2908 | pci_disable_msi(pdev); | ||
2909 | mvs_free(mvi); | ||
2910 | pci_release_regions(pdev); | ||
2911 | } | ||
2912 | pci_disable_device(pdev); | ||
2913 | } | ||
2914 | |||
2915 | static struct sas_domain_function_template mvs_transport_ops = { | ||
2916 | .lldd_execute_task = mvs_task_exec, | ||
2917 | .lldd_control_phy = mvs_phy_control, | ||
2918 | .lldd_abort_task = mvs_task_abort, | ||
2919 | .lldd_port_formed = mvs_port_formed | ||
2920 | }; | ||
2921 | |||
2922 | static struct pci_device_id __devinitdata mvs_pci_table[] = { | ||
2923 | { PCI_VDEVICE(MARVELL, 0x6320), chip_6320 }, | ||
2924 | { PCI_VDEVICE(MARVELL, 0x6340), chip_6440 }, | ||
2925 | { PCI_VDEVICE(MARVELL, 0x6440), chip_6440 }, | ||
2926 | { PCI_VDEVICE(MARVELL, 0x6480), chip_6480 }, | ||
2927 | |||
2928 | { } /* terminate list */ | ||
2929 | }; | ||
2930 | |||
2931 | static struct pci_driver mvs_pci_driver = { | ||
2932 | .name = DRV_NAME, | ||
2933 | .id_table = mvs_pci_table, | ||
2934 | .probe = mvs_pci_init, | ||
2935 | .remove = __devexit_p(mvs_pci_remove), | ||
2936 | }; | ||
2937 | |||
2938 | static int __init mvs_init(void) | ||
2939 | { | ||
2940 | int rc; | ||
2941 | |||
2942 | mvs_stt = sas_domain_attach_transport(&mvs_transport_ops); | ||
2943 | if (!mvs_stt) | ||
2944 | return -ENOMEM; | ||
2945 | |||
2946 | rc = pci_register_driver(&mvs_pci_driver); | ||
2947 | if (rc) | ||
2948 | goto err_out; | ||
2949 | |||
2950 | return 0; | ||
2951 | |||
2952 | err_out: | ||
2953 | sas_release_transport(mvs_stt); | ||
2954 | return rc; | ||
2955 | } | ||
2956 | |||
2957 | static void __exit mvs_exit(void) | ||
2958 | { | ||
2959 | pci_unregister_driver(&mvs_pci_driver); | ||
2960 | sas_release_transport(mvs_stt); | ||
2961 | } | ||
2962 | |||
2963 | module_init(mvs_init); | ||
2964 | module_exit(mvs_exit); | ||
2965 | |||
2966 | MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>"); | ||
2967 | MODULE_DESCRIPTION("Marvell 88SE6440 SAS/SATA controller driver"); | ||
2968 | MODULE_VERSION(DRV_VERSION); | ||
2969 | MODULE_LICENSE("GPL"); | ||
2970 | MODULE_DEVICE_TABLE(pci, mvs_pci_table); | ||
diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c index 1479c60441c8..2cd899bfe84b 100644 --- a/drivers/scsi/qla2xxx/qla_dfs.c +++ b/drivers/scsi/qla2xxx/qla_dfs.c | |||
@@ -23,7 +23,7 @@ qla2x00_dfs_fce_show(struct seq_file *s, void *unused) | |||
23 | mutex_lock(&ha->fce_mutex); | 23 | mutex_lock(&ha->fce_mutex); |
24 | 24 | ||
25 | seq_printf(s, "FCE Trace Buffer\n"); | 25 | seq_printf(s, "FCE Trace Buffer\n"); |
26 | seq_printf(s, "In Pointer = %llx\n\n", ha->fce_wr); | 26 | seq_printf(s, "In Pointer = %llx\n\n", (unsigned long long)ha->fce_wr); |
27 | seq_printf(s, "Base = %llx\n\n", (unsigned long long) ha->fce_dma); | 27 | seq_printf(s, "Base = %llx\n\n", (unsigned long long) ha->fce_dma); |
28 | seq_printf(s, "FCE Enable Registers\n"); | 28 | seq_printf(s, "FCE Enable Registers\n"); |
29 | seq_printf(s, "%08x %08x %08x %08x %08x %08x\n", | 29 | seq_printf(s, "%08x %08x %08x %08x %08x %08x\n", |
diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c index 0f029d0d7315..fc84db4069f4 100644 --- a/drivers/scsi/qla4xxx/ql4_isr.c +++ b/drivers/scsi/qla4xxx/ql4_isr.c | |||
@@ -100,8 +100,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha, | |||
100 | 100 | ||
101 | if (sts_entry->iscsiFlags &ISCSI_FLAG_RESIDUAL_UNDER) { | 101 | if (sts_entry->iscsiFlags &ISCSI_FLAG_RESIDUAL_UNDER) { |
102 | scsi_set_resid(cmd, residual); | 102 | scsi_set_resid(cmd, residual); |
103 | if (!scsi_status && ((scsi_bufflen(cmd) - residual) < | 103 | if ((scsi_bufflen(cmd) - residual) < cmd->underflow) { |
104 | cmd->underflow)) { | ||
105 | 104 | ||
106 | cmd->result = DID_ERROR << 16; | 105 | cmd->result = DID_ERROR << 16; |
107 | 106 | ||
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index 65455ab1f3b9..4a1cf6377f6c 100644 --- a/drivers/scsi/qlogicpti.c +++ b/drivers/scsi/qlogicpti.c | |||
@@ -651,7 +651,7 @@ static int qlogicpti_verify_tmon(struct qlogicpti *qpti) | |||
651 | 651 | ||
652 | static irqreturn_t qpti_intr(int irq, void *dev_id); | 652 | static irqreturn_t qpti_intr(int irq, void *dev_id); |
653 | 653 | ||
654 | static void __init qpti_chain_add(struct qlogicpti *qpti) | 654 | static void __devinit qpti_chain_add(struct qlogicpti *qpti) |
655 | { | 655 | { |
656 | spin_lock_irq(&qptichain_lock); | 656 | spin_lock_irq(&qptichain_lock); |
657 | if (qptichain != NULL) { | 657 | if (qptichain != NULL) { |
@@ -667,7 +667,7 @@ static void __init qpti_chain_add(struct qlogicpti *qpti) | |||
667 | spin_unlock_irq(&qptichain_lock); | 667 | spin_unlock_irq(&qptichain_lock); |
668 | } | 668 | } |
669 | 669 | ||
670 | static void __init qpti_chain_del(struct qlogicpti *qpti) | 670 | static void __devexit qpti_chain_del(struct qlogicpti *qpti) |
671 | { | 671 | { |
672 | spin_lock_irq(&qptichain_lock); | 672 | spin_lock_irq(&qptichain_lock); |
673 | if (qptichain == qpti) { | 673 | if (qptichain == qpti) { |
@@ -682,7 +682,7 @@ static void __init qpti_chain_del(struct qlogicpti *qpti) | |||
682 | spin_unlock_irq(&qptichain_lock); | 682 | spin_unlock_irq(&qptichain_lock); |
683 | } | 683 | } |
684 | 684 | ||
685 | static int __init qpti_map_regs(struct qlogicpti *qpti) | 685 | static int __devinit qpti_map_regs(struct qlogicpti *qpti) |
686 | { | 686 | { |
687 | struct sbus_dev *sdev = qpti->sdev; | 687 | struct sbus_dev *sdev = qpti->sdev; |
688 | 688 | ||
@@ -705,7 +705,7 @@ static int __init qpti_map_regs(struct qlogicpti *qpti) | |||
705 | return 0; | 705 | return 0; |
706 | } | 706 | } |
707 | 707 | ||
708 | static int __init qpti_register_irq(struct qlogicpti *qpti) | 708 | static int __devinit qpti_register_irq(struct qlogicpti *qpti) |
709 | { | 709 | { |
710 | struct sbus_dev *sdev = qpti->sdev; | 710 | struct sbus_dev *sdev = qpti->sdev; |
711 | 711 | ||
@@ -730,7 +730,7 @@ fail: | |||
730 | return -1; | 730 | return -1; |
731 | } | 731 | } |
732 | 732 | ||
733 | static void __init qpti_get_scsi_id(struct qlogicpti *qpti) | 733 | static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) |
734 | { | 734 | { |
735 | qpti->scsi_id = prom_getintdefault(qpti->prom_node, | 735 | qpti->scsi_id = prom_getintdefault(qpti->prom_node, |
736 | "initiator-id", | 736 | "initiator-id", |
@@ -783,7 +783,7 @@ static void qpti_get_clock(struct qlogicpti *qpti) | |||
783 | /* The request and response queues must each be aligned | 783 | /* The request and response queues must each be aligned |
784 | * on a page boundary. | 784 | * on a page boundary. |
785 | */ | 785 | */ |
786 | static int __init qpti_map_queues(struct qlogicpti *qpti) | 786 | static int __devinit qpti_map_queues(struct qlogicpti *qpti) |
787 | { | 787 | { |
788 | struct sbus_dev *sdev = qpti->sdev; | 788 | struct sbus_dev *sdev = qpti->sdev; |
789 | 789 | ||
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 1541c174937a..d1777a9a9625 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
@@ -222,7 +222,7 @@ static struct scsi_host_template sdebug_driver_template = { | |||
222 | .cmd_per_lun = 16, | 222 | .cmd_per_lun = 16, |
223 | .max_sectors = 0xffff, | 223 | .max_sectors = 0xffff, |
224 | .unchecked_isa_dma = 0, | 224 | .unchecked_isa_dma = 0, |
225 | .use_clustering = ENABLE_CLUSTERING, | 225 | .use_clustering = DISABLE_CLUSTERING, |
226 | .module = THIS_MODULE, | 226 | .module = THIS_MODULE, |
227 | }; | 227 | }; |
228 | 228 | ||
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 135c1d054701..ba21d97d1855 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1014,10 +1014,6 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, | |||
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | req->buffer = NULL; | 1016 | req->buffer = NULL; |
1017 | if (blk_pc_request(req)) | ||
1018 | sdb->length = req->data_len; | ||
1019 | else | ||
1020 | sdb->length = req->nr_sectors << 9; | ||
1021 | 1017 | ||
1022 | /* | 1018 | /* |
1023 | * Next, walk the list, and fill in the addresses and sizes of | 1019 | * Next, walk the list, and fill in the addresses and sizes of |
@@ -1026,6 +1022,10 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, | |||
1026 | count = blk_rq_map_sg(req->q, req, sdb->table.sgl); | 1022 | count = blk_rq_map_sg(req->q, req, sdb->table.sgl); |
1027 | BUG_ON(count > sdb->table.nents); | 1023 | BUG_ON(count > sdb->table.nents); |
1028 | sdb->table.nents = count; | 1024 | sdb->table.nents = count; |
1025 | if (blk_pc_request(req)) | ||
1026 | sdb->length = req->data_len; | ||
1027 | else | ||
1028 | sdb->length = req->nr_sectors << 9; | ||
1029 | return BLKPREP_OK; | 1029 | return BLKPREP_OK; |
1030 | } | 1030 | } |
1031 | 1031 | ||
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index fac7534f3ec4..9981682d5302 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -231,7 +231,7 @@ static struct { | |||
231 | { ISCSI_SESSION_FREE, "FREE" }, | 231 | { ISCSI_SESSION_FREE, "FREE" }, |
232 | }; | 232 | }; |
233 | 233 | ||
234 | const char *iscsi_session_state_name(int state) | 234 | static const char *iscsi_session_state_name(int state) |
235 | { | 235 | { |
236 | int i; | 236 | int i; |
237 | char *name = NULL; | 237 | char *name = NULL; |
@@ -373,7 +373,7 @@ static void session_recovery_timedout(struct work_struct *work) | |||
373 | scsi_target_unblock(&session->dev); | 373 | scsi_target_unblock(&session->dev); |
374 | } | 374 | } |
375 | 375 | ||
376 | void __iscsi_unblock_session(struct iscsi_cls_session *session) | 376 | static void __iscsi_unblock_session(struct iscsi_cls_session *session) |
377 | { | 377 | { |
378 | if (!cancel_delayed_work(&session->recovery_work)) | 378 | if (!cancel_delayed_work(&session->recovery_work)) |
379 | flush_workqueue(iscsi_eh_timer_workq); | 379 | flush_workqueue(iscsi_eh_timer_workq); |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 37df8bbe7f46..7aee64dbfbeb 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -1835,8 +1835,7 @@ static int sd_suspend(struct device *dev, pm_message_t mesg) | |||
1835 | goto done; | 1835 | goto done; |
1836 | } | 1836 | } |
1837 | 1837 | ||
1838 | if (mesg.event == PM_EVENT_SUSPEND && | 1838 | if ((mesg.event & PM_EVENT_SLEEP) && sdkp->device->manage_start_stop) { |
1839 | sdkp->device->manage_start_stop) { | ||
1840 | sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); | 1839 | sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); |
1841 | ret = sd_start_stop_device(sdkp, 0); | 1840 | ret = sd_start_stop_device(sdkp, 0); |
1842 | } | 1841 | } |
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 2a6e4f472eaa..a6d96694d0a5 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
@@ -33,9 +33,9 @@ | |||
33 | #include <scsi/scsi_host.h> | 33 | #include <scsi/scsi_host.h> |
34 | 34 | ||
35 | struct ses_device { | 35 | struct ses_device { |
36 | char *page1; | 36 | unsigned char *page1; |
37 | char *page2; | 37 | unsigned char *page2; |
38 | char *page10; | 38 | unsigned char *page10; |
39 | short page1_len; | 39 | short page1_len; |
40 | short page2_len; | 40 | short page2_len; |
41 | short page10_len; | 41 | short page10_len; |
@@ -67,7 +67,7 @@ static int ses_probe(struct device *dev) | |||
67 | static int ses_recv_diag(struct scsi_device *sdev, int page_code, | 67 | static int ses_recv_diag(struct scsi_device *sdev, int page_code, |
68 | void *buf, int bufflen) | 68 | void *buf, int bufflen) |
69 | { | 69 | { |
70 | char cmd[] = { | 70 | unsigned char cmd[] = { |
71 | RECEIVE_DIAGNOSTIC, | 71 | RECEIVE_DIAGNOSTIC, |
72 | 1, /* Set PCV bit */ | 72 | 1, /* Set PCV bit */ |
73 | page_code, | 73 | page_code, |
@@ -85,7 +85,7 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code, | |||
85 | { | 85 | { |
86 | u32 result; | 86 | u32 result; |
87 | 87 | ||
88 | char cmd[] = { | 88 | unsigned char cmd[] = { |
89 | SEND_DIAGNOSTIC, | 89 | SEND_DIAGNOSTIC, |
90 | 0x10, /* Set PF bit */ | 90 | 0x10, /* Set PF bit */ |
91 | 0, | 91 | 0, |
@@ -104,13 +104,13 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code, | |||
104 | 104 | ||
105 | static int ses_set_page2_descriptor(struct enclosure_device *edev, | 105 | static int ses_set_page2_descriptor(struct enclosure_device *edev, |
106 | struct enclosure_component *ecomp, | 106 | struct enclosure_component *ecomp, |
107 | char *desc) | 107 | unsigned char *desc) |
108 | { | 108 | { |
109 | int i, j, count = 0, descriptor = ecomp->number; | 109 | int i, j, count = 0, descriptor = ecomp->number; |
110 | struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); | 110 | struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); |
111 | struct ses_device *ses_dev = edev->scratch; | 111 | struct ses_device *ses_dev = edev->scratch; |
112 | char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; | 112 | unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; |
113 | char *desc_ptr = ses_dev->page2 + 8; | 113 | unsigned char *desc_ptr = ses_dev->page2 + 8; |
114 | 114 | ||
115 | /* Clear everything */ | 115 | /* Clear everything */ |
116 | memset(desc_ptr, 0, ses_dev->page2_len - 8); | 116 | memset(desc_ptr, 0, ses_dev->page2_len - 8); |
@@ -133,14 +133,14 @@ static int ses_set_page2_descriptor(struct enclosure_device *edev, | |||
133 | return ses_send_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len); | 133 | return ses_send_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len); |
134 | } | 134 | } |
135 | 135 | ||
136 | static char *ses_get_page2_descriptor(struct enclosure_device *edev, | 136 | static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev, |
137 | struct enclosure_component *ecomp) | 137 | struct enclosure_component *ecomp) |
138 | { | 138 | { |
139 | int i, j, count = 0, descriptor = ecomp->number; | 139 | int i, j, count = 0, descriptor = ecomp->number; |
140 | struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); | 140 | struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); |
141 | struct ses_device *ses_dev = edev->scratch; | 141 | struct ses_device *ses_dev = edev->scratch; |
142 | char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; | 142 | unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; |
143 | char *desc_ptr = ses_dev->page2 + 8; | 143 | unsigned char *desc_ptr = ses_dev->page2 + 8; |
144 | 144 | ||
145 | ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len); | 145 | ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len); |
146 | 146 | ||
@@ -160,17 +160,18 @@ static char *ses_get_page2_descriptor(struct enclosure_device *edev, | |||
160 | static void ses_get_fault(struct enclosure_device *edev, | 160 | static void ses_get_fault(struct enclosure_device *edev, |
161 | struct enclosure_component *ecomp) | 161 | struct enclosure_component *ecomp) |
162 | { | 162 | { |
163 | char *desc; | 163 | unsigned char *desc; |
164 | 164 | ||
165 | desc = ses_get_page2_descriptor(edev, ecomp); | 165 | desc = ses_get_page2_descriptor(edev, ecomp); |
166 | ecomp->fault = (desc[3] & 0x60) >> 4; | 166 | if (desc) |
167 | ecomp->fault = (desc[3] & 0x60) >> 4; | ||
167 | } | 168 | } |
168 | 169 | ||
169 | static int ses_set_fault(struct enclosure_device *edev, | 170 | static int ses_set_fault(struct enclosure_device *edev, |
170 | struct enclosure_component *ecomp, | 171 | struct enclosure_component *ecomp, |
171 | enum enclosure_component_setting val) | 172 | enum enclosure_component_setting val) |
172 | { | 173 | { |
173 | char desc[4] = {0 }; | 174 | unsigned char desc[4] = {0 }; |
174 | 175 | ||
175 | switch (val) { | 176 | switch (val) { |
176 | case ENCLOSURE_SETTING_DISABLED: | 177 | case ENCLOSURE_SETTING_DISABLED: |
@@ -190,26 +191,28 @@ static int ses_set_fault(struct enclosure_device *edev, | |||
190 | static void ses_get_status(struct enclosure_device *edev, | 191 | static void ses_get_status(struct enclosure_device *edev, |
191 | struct enclosure_component *ecomp) | 192 | struct enclosure_component *ecomp) |
192 | { | 193 | { |
193 | char *desc; | 194 | unsigned char *desc; |
194 | 195 | ||
195 | desc = ses_get_page2_descriptor(edev, ecomp); | 196 | desc = ses_get_page2_descriptor(edev, ecomp); |
196 | ecomp->status = (desc[0] & 0x0f); | 197 | if (desc) |
198 | ecomp->status = (desc[0] & 0x0f); | ||
197 | } | 199 | } |
198 | 200 | ||
199 | static void ses_get_locate(struct enclosure_device *edev, | 201 | static void ses_get_locate(struct enclosure_device *edev, |
200 | struct enclosure_component *ecomp) | 202 | struct enclosure_component *ecomp) |
201 | { | 203 | { |
202 | char *desc; | 204 | unsigned char *desc; |
203 | 205 | ||
204 | desc = ses_get_page2_descriptor(edev, ecomp); | 206 | desc = ses_get_page2_descriptor(edev, ecomp); |
205 | ecomp->locate = (desc[2] & 0x02) ? 1 : 0; | 207 | if (desc) |
208 | ecomp->locate = (desc[2] & 0x02) ? 1 : 0; | ||
206 | } | 209 | } |
207 | 210 | ||
208 | static int ses_set_locate(struct enclosure_device *edev, | 211 | static int ses_set_locate(struct enclosure_device *edev, |
209 | struct enclosure_component *ecomp, | 212 | struct enclosure_component *ecomp, |
210 | enum enclosure_component_setting val) | 213 | enum enclosure_component_setting val) |
211 | { | 214 | { |
212 | char desc[4] = {0 }; | 215 | unsigned char desc[4] = {0 }; |
213 | 216 | ||
214 | switch (val) { | 217 | switch (val) { |
215 | case ENCLOSURE_SETTING_DISABLED: | 218 | case ENCLOSURE_SETTING_DISABLED: |
@@ -229,7 +232,7 @@ static int ses_set_active(struct enclosure_device *edev, | |||
229 | struct enclosure_component *ecomp, | 232 | struct enclosure_component *ecomp, |
230 | enum enclosure_component_setting val) | 233 | enum enclosure_component_setting val) |
231 | { | 234 | { |
232 | char desc[4] = {0 }; | 235 | unsigned char desc[4] = {0 }; |
233 | 236 | ||
234 | switch (val) { | 237 | switch (val) { |
235 | case ENCLOSURE_SETTING_DISABLED: | 238 | case ENCLOSURE_SETTING_DISABLED: |
@@ -409,18 +412,18 @@ static int ses_intf_add(struct class_device *cdev, | |||
409 | { | 412 | { |
410 | struct scsi_device *sdev = to_scsi_device(cdev->dev); | 413 | struct scsi_device *sdev = to_scsi_device(cdev->dev); |
411 | struct scsi_device *tmp_sdev; | 414 | struct scsi_device *tmp_sdev; |
412 | unsigned char *buf = NULL, *hdr_buf, *type_ptr, *desc_ptr, | 415 | unsigned char *buf = NULL, *hdr_buf, *type_ptr, *desc_ptr = NULL, |
413 | *addl_desc_ptr; | 416 | *addl_desc_ptr = NULL; |
414 | struct ses_device *ses_dev; | 417 | struct ses_device *ses_dev; |
415 | u32 result; | 418 | u32 result; |
416 | int i, j, types, len, components = 0; | 419 | int i, j, types, len, page7_len = 0, components = 0; |
417 | int err = -ENOMEM; | 420 | int err = -ENOMEM; |
418 | struct enclosure_device *edev; | 421 | struct enclosure_device *edev; |
419 | struct ses_component *scomp; | 422 | struct ses_component *scomp = NULL; |
420 | 423 | ||
421 | if (!scsi_device_enclosure(sdev)) { | 424 | if (!scsi_device_enclosure(sdev)) { |
422 | /* not an enclosure, but might be in one */ | 425 | /* not an enclosure, but might be in one */ |
423 | edev = enclosure_find(&sdev->host->shost_gendev); | 426 | edev = enclosure_find(&sdev->host->shost_gendev); |
424 | if (edev) { | 427 | if (edev) { |
425 | ses_match_to_enclosure(edev, sdev); | 428 | ses_match_to_enclosure(edev, sdev); |
426 | class_device_put(&edev->cdev); | 429 | class_device_put(&edev->cdev); |
@@ -447,7 +450,7 @@ static int ses_intf_add(struct class_device *cdev, | |||
447 | * traversal routines more complex */ | 450 | * traversal routines more complex */ |
448 | sdev_printk(KERN_ERR, sdev, | 451 | sdev_printk(KERN_ERR, sdev, |
449 | "FIXME driver has no support for subenclosures (%d)\n", | 452 | "FIXME driver has no support for subenclosures (%d)\n", |
450 | buf[1]); | 453 | hdr_buf[1]); |
451 | goto err_free; | 454 | goto err_free; |
452 | } | 455 | } |
453 | 456 | ||
@@ -456,23 +459,22 @@ static int ses_intf_add(struct class_device *cdev, | |||
456 | if (!buf) | 459 | if (!buf) |
457 | goto err_free; | 460 | goto err_free; |
458 | 461 | ||
459 | ses_dev->page1 = buf; | ||
460 | ses_dev->page1_len = len; | ||
461 | |||
462 | result = ses_recv_diag(sdev, 1, buf, len); | 462 | result = ses_recv_diag(sdev, 1, buf, len); |
463 | if (result) | 463 | if (result) |
464 | goto recv_failed; | 464 | goto recv_failed; |
465 | 465 | ||
466 | types = buf[10]; | 466 | types = buf[10]; |
467 | len = buf[11]; | ||
468 | 467 | ||
469 | type_ptr = buf + 12 + len; | 468 | type_ptr = buf + 12 + buf[11]; |
470 | 469 | ||
471 | for (i = 0; i < types; i++, type_ptr += 4) { | 470 | for (i = 0; i < types; i++, type_ptr += 4) { |
472 | if (type_ptr[0] == ENCLOSURE_COMPONENT_DEVICE || | 471 | if (type_ptr[0] == ENCLOSURE_COMPONENT_DEVICE || |
473 | type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE) | 472 | type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE) |
474 | components += type_ptr[1]; | 473 | components += type_ptr[1]; |
475 | } | 474 | } |
475 | ses_dev->page1 = buf; | ||
476 | ses_dev->page1_len = len; | ||
477 | buf = NULL; | ||
476 | 478 | ||
477 | result = ses_recv_diag(sdev, 2, hdr_buf, INIT_ALLOC_SIZE); | 479 | result = ses_recv_diag(sdev, 2, hdr_buf, INIT_ALLOC_SIZE); |
478 | if (result) | 480 | if (result) |
@@ -489,28 +491,29 @@ static int ses_intf_add(struct class_device *cdev, | |||
489 | goto recv_failed; | 491 | goto recv_failed; |
490 | ses_dev->page2 = buf; | 492 | ses_dev->page2 = buf; |
491 | ses_dev->page2_len = len; | 493 | ses_dev->page2_len = len; |
494 | buf = NULL; | ||
492 | 495 | ||
493 | /* The additional information page --- allows us | 496 | /* The additional information page --- allows us |
494 | * to match up the devices */ | 497 | * to match up the devices */ |
495 | result = ses_recv_diag(sdev, 10, hdr_buf, INIT_ALLOC_SIZE); | 498 | result = ses_recv_diag(sdev, 10, hdr_buf, INIT_ALLOC_SIZE); |
496 | if (result) | 499 | if (!result) { |
497 | goto no_page10; | 500 | |
498 | 501 | len = (hdr_buf[2] << 8) + hdr_buf[3] + 4; | |
499 | len = (hdr_buf[2] << 8) + hdr_buf[3] + 4; | 502 | buf = kzalloc(len, GFP_KERNEL); |
500 | buf = kzalloc(len, GFP_KERNEL); | 503 | if (!buf) |
501 | if (!buf) | 504 | goto err_free; |
502 | goto err_free; | 505 | |
503 | 506 | result = ses_recv_diag(sdev, 10, buf, len); | |
504 | result = ses_recv_diag(sdev, 10, buf, len); | 507 | if (result) |
505 | if (result) | 508 | goto recv_failed; |
506 | goto recv_failed; | 509 | ses_dev->page10 = buf; |
507 | ses_dev->page10 = buf; | 510 | ses_dev->page10_len = len; |
508 | ses_dev->page10_len = len; | 511 | buf = NULL; |
512 | } | ||
509 | 513 | ||
510 | no_page10: | 514 | scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL); |
511 | scomp = kmalloc(sizeof(struct ses_component) * components, GFP_KERNEL); | ||
512 | if (!scomp) | 515 | if (!scomp) |
513 | goto err_free; | 516 | goto err_free; |
514 | 517 | ||
515 | edev = enclosure_register(cdev->dev, sdev->sdev_gendev.bus_id, | 518 | edev = enclosure_register(cdev->dev, sdev->sdev_gendev.bus_id, |
516 | components, &ses_enclosure_callbacks); | 519 | components, &ses_enclosure_callbacks); |
@@ -521,17 +524,18 @@ static int ses_intf_add(struct class_device *cdev, | |||
521 | 524 | ||
522 | edev->scratch = ses_dev; | 525 | edev->scratch = ses_dev; |
523 | for (i = 0; i < components; i++) | 526 | for (i = 0; i < components; i++) |
524 | edev->component[i].scratch = scomp++; | 527 | edev->component[i].scratch = scomp + i; |
525 | 528 | ||
526 | /* Page 7 for the descriptors is optional */ | 529 | /* Page 7 for the descriptors is optional */ |
527 | buf = NULL; | ||
528 | result = ses_recv_diag(sdev, 7, hdr_buf, INIT_ALLOC_SIZE); | 530 | result = ses_recv_diag(sdev, 7, hdr_buf, INIT_ALLOC_SIZE); |
529 | if (result) | 531 | if (result) |
530 | goto simple_populate; | 532 | goto simple_populate; |
531 | 533 | ||
532 | len = (hdr_buf[2] << 8) + hdr_buf[3] + 4; | 534 | page7_len = len = (hdr_buf[2] << 8) + hdr_buf[3] + 4; |
533 | /* add 1 for trailing '\0' we'll use */ | 535 | /* add 1 for trailing '\0' we'll use */ |
534 | buf = kzalloc(len + 1, GFP_KERNEL); | 536 | buf = kzalloc(len + 1, GFP_KERNEL); |
537 | if (!buf) | ||
538 | goto simple_populate; | ||
535 | result = ses_recv_diag(sdev, 7, buf, len); | 539 | result = ses_recv_diag(sdev, 7, buf, len); |
536 | if (result) { | 540 | if (result) { |
537 | simple_populate: | 541 | simple_populate: |
@@ -544,7 +548,8 @@ static int ses_intf_add(struct class_device *cdev, | |||
544 | len = (desc_ptr[2] << 8) + desc_ptr[3]; | 548 | len = (desc_ptr[2] << 8) + desc_ptr[3]; |
545 | /* skip past overall descriptor */ | 549 | /* skip past overall descriptor */ |
546 | desc_ptr += len + 4; | 550 | desc_ptr += len + 4; |
547 | addl_desc_ptr = ses_dev->page10 + 8; | 551 | if (ses_dev->page10) |
552 | addl_desc_ptr = ses_dev->page10 + 8; | ||
548 | } | 553 | } |
549 | type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; | 554 | type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; |
550 | components = 0; | 555 | components = 0; |
@@ -554,29 +559,35 @@ static int ses_intf_add(struct class_device *cdev, | |||
554 | struct enclosure_component *ecomp; | 559 | struct enclosure_component *ecomp; |
555 | 560 | ||
556 | if (desc_ptr) { | 561 | if (desc_ptr) { |
557 | len = (desc_ptr[2] << 8) + desc_ptr[3]; | 562 | if (desc_ptr >= buf + page7_len) { |
558 | desc_ptr += 4; | 563 | desc_ptr = NULL; |
559 | /* Add trailing zero - pushes into | 564 | } else { |
560 | * reserved space */ | 565 | len = (desc_ptr[2] << 8) + desc_ptr[3]; |
561 | desc_ptr[len] = '\0'; | 566 | desc_ptr += 4; |
562 | name = desc_ptr; | 567 | /* Add trailing zero - pushes into |
568 | * reserved space */ | ||
569 | desc_ptr[len] = '\0'; | ||
570 | name = desc_ptr; | ||
571 | } | ||
563 | } | 572 | } |
564 | if (type_ptr[0] != ENCLOSURE_COMPONENT_DEVICE && | 573 | if (type_ptr[0] == ENCLOSURE_COMPONENT_DEVICE || |
565 | type_ptr[0] != ENCLOSURE_COMPONENT_ARRAY_DEVICE) | 574 | type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE) { |
566 | continue; | 575 | |
567 | ecomp = enclosure_component_register(edev, | 576 | ecomp = enclosure_component_register(edev, |
568 | components++, | 577 | components++, |
569 | type_ptr[0], | 578 | type_ptr[0], |
570 | name); | 579 | name); |
571 | if (desc_ptr) { | 580 | |
572 | desc_ptr += len; | 581 | if (!IS_ERR(ecomp) && addl_desc_ptr) |
573 | if (!IS_ERR(ecomp)) | ||
574 | ses_process_descriptor(ecomp, | 582 | ses_process_descriptor(ecomp, |
575 | addl_desc_ptr); | 583 | addl_desc_ptr); |
576 | |||
577 | if (addl_desc_ptr) | ||
578 | addl_desc_ptr += addl_desc_ptr[1] + 2; | ||
579 | } | 584 | } |
585 | if (desc_ptr) | ||
586 | desc_ptr += len; | ||
587 | |||
588 | if (addl_desc_ptr) | ||
589 | addl_desc_ptr += addl_desc_ptr[1] + 2; | ||
590 | |||
580 | } | 591 | } |
581 | } | 592 | } |
582 | kfree(buf); | 593 | kfree(buf); |
@@ -598,6 +609,7 @@ static int ses_intf_add(struct class_device *cdev, | |||
598 | err = -ENODEV; | 609 | err = -ENODEV; |
599 | err_free: | 610 | err_free: |
600 | kfree(buf); | 611 | kfree(buf); |
612 | kfree(scomp); | ||
601 | kfree(ses_dev->page10); | 613 | kfree(ses_dev->page10); |
602 | kfree(ses_dev->page2); | 614 | kfree(ses_dev->page2); |
603 | kfree(ses_dev->page1); | 615 | kfree(ses_dev->page1); |
@@ -630,6 +642,7 @@ static void ses_intf_remove(struct class_device *cdev, | |||
630 | ses_dev = edev->scratch; | 642 | ses_dev = edev->scratch; |
631 | edev->scratch = NULL; | 643 | edev->scratch = NULL; |
632 | 644 | ||
645 | kfree(ses_dev->page10); | ||
633 | kfree(ses_dev->page1); | 646 | kfree(ses_dev->page1); |
634 | kfree(ses_dev->page2); | 647 | kfree(ses_dev->page2); |
635 | kfree(ses_dev); | 648 | kfree(ses_dev); |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 71952703125a..0a52d9d2da2c 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -17,7 +17,7 @@ | |||
17 | Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support | 17 | Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support |
18 | */ | 18 | */ |
19 | 19 | ||
20 | static const char *verstr = "20080117"; | 20 | static const char *verstr = "20080221"; |
21 | 21 | ||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | 23 | ||
@@ -1172,7 +1172,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1172 | STp->try_dio_now = STp->try_dio; | 1172 | STp->try_dio_now = STp->try_dio; |
1173 | STp->recover_count = 0; | 1173 | STp->recover_count = 0; |
1174 | DEB( STp->nbr_waits = STp->nbr_finished = 0; | 1174 | DEB( STp->nbr_waits = STp->nbr_finished = 0; |
1175 | STp->nbr_requests = STp->nbr_dio = STp->nbr_pages = STp->nbr_combinable = 0; ) | 1175 | STp->nbr_requests = STp->nbr_dio = STp->nbr_pages = 0; ) |
1176 | 1176 | ||
1177 | retval = check_tape(STp, filp); | 1177 | retval = check_tape(STp, filp); |
1178 | if (retval < 0) | 1178 | if (retval < 0) |
@@ -1226,8 +1226,8 @@ static int st_flush(struct file *filp, fl_owner_t id) | |||
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | DEBC( if (STp->nbr_requests) | 1228 | DEBC( if (STp->nbr_requests) |
1229 | printk(KERN_DEBUG "%s: Number of r/w requests %d, dio used in %d, pages %d (%d).\n", | 1229 | printk(KERN_DEBUG "%s: Number of r/w requests %d, dio used in %d, pages %d.\n", |
1230 | name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages, STp->nbr_combinable)); | 1230 | name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages)); |
1231 | 1231 | ||
1232 | if (STps->rw == ST_WRITING && !STp->pos_unknown) { | 1232 | if (STps->rw == ST_WRITING && !STp->pos_unknown) { |
1233 | struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; | 1233 | struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; |
@@ -1422,9 +1422,6 @@ static int setup_buffering(struct scsi_tape *STp, const char __user *buf, | |||
1422 | if (STbp->do_dio) { | 1422 | if (STbp->do_dio) { |
1423 | STp->nbr_dio++; | 1423 | STp->nbr_dio++; |
1424 | STp->nbr_pages += STbp->do_dio; | 1424 | STp->nbr_pages += STbp->do_dio; |
1425 | for (i=1; i < STbp->do_dio; i++) | ||
1426 | if (page_to_pfn(STbp->sg[i].page) == page_to_pfn(STbp->sg[i-1].page) + 1) | ||
1427 | STp->nbr_combinable++; | ||
1428 | } | 1425 | } |
1429 | ) | 1426 | ) |
1430 | } else | 1427 | } else |
diff --git a/drivers/scsi/st.h b/drivers/scsi/st.h index 6c8075712974..5931726fcf93 100644 --- a/drivers/scsi/st.h +++ b/drivers/scsi/st.h | |||
@@ -164,7 +164,6 @@ struct scsi_tape { | |||
164 | int nbr_requests; | 164 | int nbr_requests; |
165 | int nbr_dio; | 165 | int nbr_dio; |
166 | int nbr_pages; | 166 | int nbr_pages; |
167 | int nbr_combinable; | ||
168 | unsigned char last_cmnd[6]; | 167 | unsigned char last_cmnd[6]; |
169 | unsigned char last_sense[16]; | 168 | unsigned char last_sense[16]; |
170 | #endif | 169 | #endif |
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 72f6d8015358..654430edf74d 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c | |||
@@ -461,30 +461,14 @@ static void stex_internal_copy(struct scsi_cmnd *cmd, | |||
461 | } | 461 | } |
462 | } | 462 | } |
463 | 463 | ||
464 | static int stex_direct_copy(struct scsi_cmnd *cmd, | ||
465 | const void *src, size_t count) | ||
466 | { | ||
467 | size_t cp_len = count; | ||
468 | int n_elem = 0; | ||
469 | |||
470 | n_elem = scsi_dma_map(cmd); | ||
471 | if (n_elem < 0) | ||
472 | return 0; | ||
473 | |||
474 | stex_internal_copy(cmd, src, &cp_len, n_elem, ST_TO_CMD); | ||
475 | |||
476 | scsi_dma_unmap(cmd); | ||
477 | |||
478 | return cp_len == count; | ||
479 | } | ||
480 | |||
481 | static void stex_controller_info(struct st_hba *hba, struct st_ccb *ccb) | 464 | static void stex_controller_info(struct st_hba *hba, struct st_ccb *ccb) |
482 | { | 465 | { |
483 | struct st_frame *p; | 466 | struct st_frame *p; |
484 | size_t count = sizeof(struct st_frame); | 467 | size_t count = sizeof(struct st_frame); |
485 | 468 | ||
486 | p = hba->copy_buffer; | 469 | p = hba->copy_buffer; |
487 | stex_internal_copy(ccb->cmd, p, &count, ccb->sg_count, ST_FROM_CMD); | 470 | stex_internal_copy(ccb->cmd, p, &count, scsi_sg_count(ccb->cmd), |
471 | ST_FROM_CMD); | ||
488 | memset(p->base, 0, sizeof(u32)*6); | 472 | memset(p->base, 0, sizeof(u32)*6); |
489 | *(unsigned long *)(p->base) = pci_resource_start(hba->pdev, 0); | 473 | *(unsigned long *)(p->base) = pci_resource_start(hba->pdev, 0); |
490 | p->rom_addr = 0; | 474 | p->rom_addr = 0; |
@@ -502,7 +486,8 @@ static void stex_controller_info(struct st_hba *hba, struct st_ccb *ccb) | |||
502 | p->subid = | 486 | p->subid = |
503 | hba->pdev->subsystem_vendor << 16 | hba->pdev->subsystem_device; | 487 | hba->pdev->subsystem_vendor << 16 | hba->pdev->subsystem_device; |
504 | 488 | ||
505 | stex_internal_copy(ccb->cmd, p, &count, ccb->sg_count, ST_TO_CMD); | 489 | stex_internal_copy(ccb->cmd, p, &count, scsi_sg_count(ccb->cmd), |
490 | ST_TO_CMD); | ||
506 | } | 491 | } |
507 | 492 | ||
508 | static void | 493 | static void |
@@ -569,8 +554,10 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) | |||
569 | unsigned char page; | 554 | unsigned char page; |
570 | page = cmd->cmnd[2] & 0x3f; | 555 | page = cmd->cmnd[2] & 0x3f; |
571 | if (page == 0x8 || page == 0x3f) { | 556 | if (page == 0x8 || page == 0x3f) { |
572 | stex_direct_copy(cmd, ms10_caching_page, | 557 | size_t cp_len = sizeof(ms10_caching_page); |
573 | sizeof(ms10_caching_page)); | 558 | stex_internal_copy(cmd, ms10_caching_page, |
559 | &cp_len, scsi_sg_count(cmd), | ||
560 | ST_TO_CMD); | ||
574 | cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; | 561 | cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; |
575 | done(cmd); | 562 | done(cmd); |
576 | } else | 563 | } else |
@@ -599,8 +586,10 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) | |||
599 | if (id != host->max_id - 1) | 586 | if (id != host->max_id - 1) |
600 | break; | 587 | break; |
601 | if (lun == 0 && (cmd->cmnd[1] & INQUIRY_EVPD) == 0) { | 588 | if (lun == 0 && (cmd->cmnd[1] & INQUIRY_EVPD) == 0) { |
602 | stex_direct_copy(cmd, console_inq_page, | 589 | size_t cp_len = sizeof(console_inq_page); |
603 | sizeof(console_inq_page)); | 590 | stex_internal_copy(cmd, console_inq_page, |
591 | &cp_len, scsi_sg_count(cmd), | ||
592 | ST_TO_CMD); | ||
604 | cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; | 593 | cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; |
605 | done(cmd); | 594 | done(cmd); |
606 | } else | 595 | } else |
@@ -609,6 +598,7 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) | |||
609 | case PASSTHRU_CMD: | 598 | case PASSTHRU_CMD: |
610 | if (cmd->cmnd[1] == PASSTHRU_GET_DRVVER) { | 599 | if (cmd->cmnd[1] == PASSTHRU_GET_DRVVER) { |
611 | struct st_drvver ver; | 600 | struct st_drvver ver; |
601 | size_t cp_len = sizeof(ver); | ||
612 | ver.major = ST_VER_MAJOR; | 602 | ver.major = ST_VER_MAJOR; |
613 | ver.minor = ST_VER_MINOR; | 603 | ver.minor = ST_VER_MINOR; |
614 | ver.oem = ST_OEM; | 604 | ver.oem = ST_OEM; |
@@ -616,7 +606,9 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) | |||
616 | ver.signature[0] = PASSTHRU_SIGNATURE; | 606 | ver.signature[0] = PASSTHRU_SIGNATURE; |
617 | ver.console_id = host->max_id - 1; | 607 | ver.console_id = host->max_id - 1; |
618 | ver.host_no = hba->host->host_no; | 608 | ver.host_no = hba->host->host_no; |
619 | cmd->result = stex_direct_copy(cmd, &ver, sizeof(ver)) ? | 609 | stex_internal_copy(cmd, &ver, &cp_len, |
610 | scsi_sg_count(cmd), ST_TO_CMD); | ||
611 | cmd->result = sizeof(ver) == cp_len ? | ||
620 | DID_OK << 16 | COMMAND_COMPLETE << 8 : | 612 | DID_OK << 16 | COMMAND_COMPLETE << 8 : |
621 | DID_ERROR << 16 | COMMAND_COMPLETE << 8; | 613 | DID_ERROR << 16 | COMMAND_COMPLETE << 8; |
622 | done(cmd); | 614 | done(cmd); |
@@ -709,7 +701,7 @@ static void stex_copy_data(struct st_ccb *ccb, | |||
709 | if (ccb->cmd == NULL) | 701 | if (ccb->cmd == NULL) |
710 | return; | 702 | return; |
711 | stex_internal_copy(ccb->cmd, | 703 | stex_internal_copy(ccb->cmd, |
712 | resp->variable, &count, ccb->sg_count, ST_TO_CMD); | 704 | resp->variable, &count, scsi_sg_count(ccb->cmd), ST_TO_CMD); |
713 | } | 705 | } |
714 | 706 | ||
715 | static void stex_ys_commands(struct st_hba *hba, | 707 | static void stex_ys_commands(struct st_hba *hba, |
@@ -734,7 +726,7 @@ static void stex_ys_commands(struct st_hba *hba, | |||
734 | 726 | ||
735 | count = STEX_EXTRA_SIZE; | 727 | count = STEX_EXTRA_SIZE; |
736 | stex_internal_copy(ccb->cmd, hba->copy_buffer, | 728 | stex_internal_copy(ccb->cmd, hba->copy_buffer, |
737 | &count, ccb->sg_count, ST_FROM_CMD); | 729 | &count, scsi_sg_count(ccb->cmd), ST_FROM_CMD); |
738 | inq_data = (ST_INQ *)hba->copy_buffer; | 730 | inq_data = (ST_INQ *)hba->copy_buffer; |
739 | if (inq_data->DeviceTypeQualifier != 0) | 731 | if (inq_data->DeviceTypeQualifier != 0) |
740 | ccb->srb_status = SRB_STATUS_SELECTION_TIMEOUT; | 732 | ccb->srb_status = SRB_STATUS_SELECTION_TIMEOUT; |
diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c index 6325901e5093..f7d279542fa5 100644 --- a/drivers/scsi/sym53c416.c +++ b/drivers/scsi/sym53c416.c | |||
@@ -187,10 +187,10 @@ | |||
187 | #define sym53c416_base_2 sym53c416_2 | 187 | #define sym53c416_base_2 sym53c416_2 |
188 | #define sym53c416_base_3 sym53c416_3 | 188 | #define sym53c416_base_3 sym53c416_3 |
189 | 189 | ||
190 | static unsigned int sym53c416_base[2] = {0,0}; | 190 | static unsigned int sym53c416_base[2]; |
191 | static unsigned int sym53c416_base_1[2] = {0,0}; | 191 | static unsigned int sym53c416_base_1[2]; |
192 | static unsigned int sym53c416_base_2[2] = {0,0}; | 192 | static unsigned int sym53c416_base_2[2]; |
193 | static unsigned int sym53c416_base_3[2] = {0,0}; | 193 | static unsigned int sym53c416_base_3[2]; |
194 | 194 | ||
195 | #endif | 195 | #endif |
196 | 196 | ||
@@ -621,25 +621,25 @@ int __init sym53c416_detect(struct scsi_host_template *tpnt) | |||
621 | int ints[3]; | 621 | int ints[3]; |
622 | 622 | ||
623 | ints[0] = 2; | 623 | ints[0] = 2; |
624 | if(sym53c416_base) | 624 | if(sym53c416_base[0]) |
625 | { | 625 | { |
626 | ints[1] = sym53c416_base[0]; | 626 | ints[1] = sym53c416_base[0]; |
627 | ints[2] = sym53c416_base[1]; | 627 | ints[2] = sym53c416_base[1]; |
628 | sym53c416_setup(NULL, ints); | 628 | sym53c416_setup(NULL, ints); |
629 | } | 629 | } |
630 | if(sym53c416_base_1) | 630 | if(sym53c416_base_1[0]) |
631 | { | 631 | { |
632 | ints[1] = sym53c416_base_1[0]; | 632 | ints[1] = sym53c416_base_1[0]; |
633 | ints[2] = sym53c416_base_1[1]; | 633 | ints[2] = sym53c416_base_1[1]; |
634 | sym53c416_setup(NULL, ints); | 634 | sym53c416_setup(NULL, ints); |
635 | } | 635 | } |
636 | if(sym53c416_base_2) | 636 | if(sym53c416_base_2[0]) |
637 | { | 637 | { |
638 | ints[1] = sym53c416_base_2[0]; | 638 | ints[1] = sym53c416_base_2[0]; |
639 | ints[2] = sym53c416_base_2[1]; | 639 | ints[2] = sym53c416_base_2[1]; |
640 | sym53c416_setup(NULL, ints); | 640 | sym53c416_setup(NULL, ints); |
641 | } | 641 | } |
642 | if(sym53c416_base_3) | 642 | if(sym53c416_base_3[0]) |
643 | { | 643 | { |
644 | ints[1] = sym53c416_base_3[0]; | 644 | ints[1] = sym53c416_base_3[0]; |
645 | ints[2] = sym53c416_base_3[1]; | 645 | ints[2] = sym53c416_base_3[1]; |
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c index fad245b064d6..d57bf3e708d8 100644 --- a/drivers/serial/atmel_serial.c +++ b/drivers/serial/atmel_serial.c | |||
@@ -549,7 +549,7 @@ static irqreturn_t atmel_interrupt(int irq, void *dev_id) | |||
549 | atmel_handle_transmit(port, pending); | 549 | atmel_handle_transmit(port, pending); |
550 | } while (pass_counter++ < ATMEL_ISR_PASS_LIMIT); | 550 | } while (pass_counter++ < ATMEL_ISR_PASS_LIMIT); |
551 | 551 | ||
552 | return IRQ_HANDLED; | 552 | return pass_counter ? IRQ_HANDLED : IRQ_NONE; |
553 | } | 553 | } |
554 | 554 | ||
555 | /* | 555 | /* |
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index ddf639144538..9ce12cb2cebc 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -393,7 +393,7 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) | |||
393 | if (cflag & CRTSCTS) { | 393 | if (cflag & CRTSCTS) { |
394 | fcr_val |= SCFCR_MCE; | 394 | fcr_val |= SCFCR_MCE; |
395 | } else { | 395 | } else { |
396 | #ifdef CONFIG_CPU_SUBTYPE_SH7343 | 396 | #if defined(CONFIG_CPU_SUBTYPE_SH7343) || defined(CONFIG_CPU_SUBTYPE_SH7366) |
397 | /* Nothing */ | 397 | /* Nothing */ |
398 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ | 398 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ |
399 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ | 399 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h index f5764ebcfe07..01a9dd715f5d 100644 --- a/drivers/serial/sh-sci.h +++ b/drivers/serial/sh-sci.h | |||
@@ -97,13 +97,18 @@ | |||
97 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 97 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
98 | # define SCIF_ONLY | 98 | # define SCIF_ONLY |
99 | # define PORT_PSCR 0xA405011E | 99 | # define PORT_PSCR 0xA405011E |
100 | #elif defined(CONFIG_CPU_SUBTYPE_SH7366) | ||
101 | # define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */ | ||
102 | # define SCSPTR0 SCPDR0 | ||
103 | # define SCIF_ORER 0x0001 /* overrun error bit */ | ||
104 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | ||
105 | # define SCIF_ONLY | ||
100 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) | 106 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) |
101 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ | 107 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ |
102 | # define SCIF_ORER 0x0001 /* overrun error bit */ | 108 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
103 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 109 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
104 | # define SCIF_ONLY | 110 | # define SCIF_ONLY |
105 | #elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) | 111 | #elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) |
106 | # include <asm/hardware.h> | ||
107 | # define SCIF_BASE_ADDR 0x01030000 | 112 | # define SCIF_BASE_ADDR 0x01030000 |
108 | # define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR | 113 | # define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR |
109 | # define SCIF_PTR2_OFFS 0x0000020 | 114 | # define SCIF_PTR2_OFFS 0x0000020 |
@@ -577,7 +582,7 @@ static inline int sci_rxd_in(struct uart_port *port) | |||
577 | return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ | 582 | return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ |
578 | return 1; | 583 | return 1; |
579 | } | 584 | } |
580 | #elif defined(CONFIG_CPU_SUBTYPE_SH7722) | 585 | #elif defined(CONFIG_CPU_SUBTYPE_SH7722) || defined(CONFIG_CPU_SUBTYPE_SH7366) |
581 | static inline int sci_rxd_in(struct uart_port *port) | 586 | static inline int sci_rxd_in(struct uart_port *port) |
582 | { | 587 | { |
583 | if (port->mapbase == 0xffe00000) | 588 | if (port->mapbase == 0xffe00000) |
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c index e52a6296ca46..9cfcfd8dad5e 100644 --- a/drivers/sh/maple/maple.c +++ b/drivers/sh/maple/maple.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <asm/mach/dma.h> | 31 | #include <asm/mach/dma.h> |
32 | #include <asm/mach/sysasic.h> | 32 | #include <asm/mach/sysasic.h> |
33 | #include <asm/mach/maple.h> | 33 | #include <asm/mach/maple.h> |
34 | #include <linux/delay.h> | ||
34 | 35 | ||
35 | MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin"); | 36 | MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin"); |
36 | MODULE_DESCRIPTION("Maple bus driver for Dreamcast"); | 37 | MODULE_DESCRIPTION("Maple bus driver for Dreamcast"); |
@@ -53,12 +54,12 @@ static struct device maple_bus; | |||
53 | static int subdevice_map[MAPLE_PORTS]; | 54 | static int subdevice_map[MAPLE_PORTS]; |
54 | static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr; | 55 | static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr; |
55 | static unsigned long maple_pnp_time; | 56 | static unsigned long maple_pnp_time; |
56 | static int started, scanning, liststatus; | 57 | static int started, scanning, liststatus, realscan; |
57 | static struct kmem_cache *maple_queue_cache; | 58 | static struct kmem_cache *maple_queue_cache; |
58 | 59 | ||
59 | struct maple_device_specify { | 60 | struct maple_device_specify { |
60 | int port; | 61 | int port; |
61 | int unit; | 62 | int unit; |
62 | }; | 63 | }; |
63 | 64 | ||
64 | /** | 65 | /** |
@@ -68,22 +69,22 @@ struct maple_device_specify { | |||
68 | */ | 69 | */ |
69 | int maple_driver_register(struct device_driver *drv) | 70 | int maple_driver_register(struct device_driver *drv) |
70 | { | 71 | { |
71 | if (!drv) | 72 | if (!drv) |
72 | return -EINVAL; | 73 | return -EINVAL; |
73 | drv->bus = &maple_bus_type; | 74 | drv->bus = &maple_bus_type; |
74 | return driver_register(drv); | 75 | return driver_register(drv); |
75 | } | 76 | } |
76 | EXPORT_SYMBOL_GPL(maple_driver_register); | 77 | EXPORT_SYMBOL_GPL(maple_driver_register); |
77 | 78 | ||
78 | /* set hardware registers to enable next round of dma */ | 79 | /* set hardware registers to enable next round of dma */ |
79 | static void maplebus_dma_reset(void) | 80 | static void maplebus_dma_reset(void) |
80 | { | 81 | { |
81 | ctrl_outl(MAPLE_MAGIC, MAPLE_RESET); | 82 | ctrl_outl(MAPLE_MAGIC, MAPLE_RESET); |
82 | /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */ | 83 | /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */ |
83 | ctrl_outl(1, MAPLE_TRIGTYPE); | 84 | ctrl_outl(1, MAPLE_TRIGTYPE); |
84 | ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(50000), MAPLE_SPEED); | 85 | ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(50000), MAPLE_SPEED); |
85 | ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR); | 86 | ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR); |
86 | ctrl_outl(1, MAPLE_ENABLE); | 87 | ctrl_outl(1, MAPLE_ENABLE); |
87 | } | 88 | } |
88 | 89 | ||
89 | /** | 90 | /** |
@@ -94,27 +95,36 @@ static void maplebus_dma_reset(void) | |||
94 | * @function: the function code for the device | 95 | * @function: the function code for the device |
95 | */ | 96 | */ |
96 | void maple_getcond_callback(struct maple_device *dev, | 97 | void maple_getcond_callback(struct maple_device *dev, |
97 | void (*callback) (struct mapleq * mq), | 98 | void (*callback) (struct mapleq *mq), |
98 | unsigned long interval, unsigned long function) | 99 | unsigned long interval, unsigned long function) |
99 | { | 100 | { |
100 | dev->callback = callback; | 101 | dev->callback = callback; |
101 | dev->interval = interval; | 102 | dev->interval = interval; |
102 | dev->function = cpu_to_be32(function); | 103 | dev->function = cpu_to_be32(function); |
103 | dev->when = jiffies; | 104 | dev->when = jiffies; |
104 | } | 105 | } |
105 | EXPORT_SYMBOL_GPL(maple_getcond_callback); | 106 | EXPORT_SYMBOL_GPL(maple_getcond_callback); |
106 | 107 | ||
107 | static int maple_dma_done(void) | 108 | static int maple_dma_done(void) |
108 | { | 109 | { |
109 | return (ctrl_inl(MAPLE_STATE) & 1) == 0; | 110 | return (ctrl_inl(MAPLE_STATE) & 1) == 0; |
110 | } | 111 | } |
111 | 112 | ||
112 | static void maple_release_device(struct device *dev) | 113 | static void maple_release_device(struct device *dev) |
113 | { | 114 | { |
114 | if (dev->type) { | 115 | struct maple_device *mdev; |
115 | kfree(dev->type->name); | 116 | struct mapleq *mq; |
116 | kfree(dev->type); | 117 | if (!dev) |
117 | } | 118 | return; |
119 | mdev = to_maple_dev(dev); | ||
120 | mq = mdev->mq; | ||
121 | if (mq) { | ||
122 | if (mq->recvbufdcsp) | ||
123 | kmem_cache_free(maple_queue_cache, mq->recvbufdcsp); | ||
124 | kfree(mq); | ||
125 | mq = NULL; | ||
126 | } | ||
127 | kfree(mdev); | ||
118 | } | 128 | } |
119 | 129 | ||
120 | /** | 130 | /** |
@@ -123,60 +133,64 @@ static void maple_release_device(struct device *dev) | |||
123 | */ | 133 | */ |
124 | void maple_add_packet(struct mapleq *mq) | 134 | void maple_add_packet(struct mapleq *mq) |
125 | { | 135 | { |
126 | mutex_lock(&maple_list_lock); | 136 | mutex_lock(&maple_list_lock); |
127 | list_add(&mq->list, &maple_waitq); | 137 | list_add(&mq->list, &maple_waitq); |
128 | mutex_unlock(&maple_list_lock); | 138 | mutex_unlock(&maple_list_lock); |
129 | } | 139 | } |
130 | EXPORT_SYMBOL_GPL(maple_add_packet); | 140 | EXPORT_SYMBOL_GPL(maple_add_packet); |
131 | 141 | ||
132 | static struct mapleq *maple_allocq(struct maple_device *dev) | 142 | static struct mapleq *maple_allocq(struct maple_device *mdev) |
133 | { | 143 | { |
134 | struct mapleq *mq; | 144 | struct mapleq *mq; |
135 | 145 | ||
136 | mq = kmalloc(sizeof(*mq), GFP_KERNEL); | 146 | mq = kmalloc(sizeof(*mq), GFP_KERNEL); |
137 | if (!mq) | 147 | if (!mq) |
138 | return NULL; | 148 | return NULL; |
139 | 149 | ||
140 | mq->dev = dev; | 150 | mq->dev = mdev; |
141 | mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL); | 151 | mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL); |
142 | mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp); | 152 | mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp); |
143 | if (!mq->recvbuf) { | 153 | if (!mq->recvbuf) { |
144 | kfree(mq); | 154 | kfree(mq); |
145 | return NULL; | 155 | return NULL; |
146 | } | 156 | } |
147 | 157 | ||
148 | return mq; | 158 | return mq; |
149 | } | 159 | } |
150 | 160 | ||
151 | static struct maple_device *maple_alloc_dev(int port, int unit) | 161 | static struct maple_device *maple_alloc_dev(int port, int unit) |
152 | { | 162 | { |
153 | struct maple_device *dev; | 163 | struct maple_device *mdev; |
154 | 164 | ||
155 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 165 | mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); |
156 | if (!dev) | 166 | if (!mdev) |
157 | return NULL; | 167 | return NULL; |
158 | 168 | ||
159 | dev->port = port; | 169 | mdev->port = port; |
160 | dev->unit = unit; | 170 | mdev->unit = unit; |
161 | dev->mq = maple_allocq(dev); | 171 | mdev->mq = maple_allocq(mdev); |
162 | 172 | ||
163 | if (!dev->mq) { | 173 | if (!mdev->mq) { |
164 | kfree(dev); | 174 | kfree(mdev); |
165 | return NULL; | 175 | return NULL; |
166 | } | 176 | } |
167 | 177 | mdev->dev.bus = &maple_bus_type; | |
168 | return dev; | 178 | mdev->dev.parent = &maple_bus; |
179 | mdev->function = 0; | ||
180 | return mdev; | ||
169 | } | 181 | } |
170 | 182 | ||
171 | static void maple_free_dev(struct maple_device *mdev) | 183 | static void maple_free_dev(struct maple_device *mdev) |
172 | { | 184 | { |
173 | if (!mdev) | 185 | if (!mdev) |
174 | return; | 186 | return; |
175 | if (mdev->mq) { | 187 | if (mdev->mq) { |
176 | kmem_cache_free(maple_queue_cache, mdev->mq->recvbufdcsp); | 188 | if (mdev->mq->recvbufdcsp) |
177 | kfree(mdev->mq); | 189 | kmem_cache_free(maple_queue_cache, |
178 | } | 190 | mdev->mq->recvbufdcsp); |
179 | kfree(mdev); | 191 | kfree(mdev->mq); |
192 | } | ||
193 | kfree(mdev); | ||
180 | } | 194 | } |
181 | 195 | ||
182 | /* process the command queue into a maple command block | 196 | /* process the command queue into a maple command block |
@@ -184,153 +198,162 @@ static void maple_free_dev(struct maple_device *mdev) | |||
184 | */ | 198 | */ |
185 | static void maple_build_block(struct mapleq *mq) | 199 | static void maple_build_block(struct mapleq *mq) |
186 | { | 200 | { |
187 | int port, unit, from, to, len; | 201 | int port, unit, from, to, len; |
188 | unsigned long *lsendbuf = mq->sendbuf; | 202 | unsigned long *lsendbuf = mq->sendbuf; |
189 | 203 | ||
190 | port = mq->dev->port & 3; | 204 | port = mq->dev->port & 3; |
191 | unit = mq->dev->unit; | 205 | unit = mq->dev->unit; |
192 | len = mq->length; | 206 | len = mq->length; |
193 | from = port << 6; | 207 | from = port << 6; |
194 | to = (port << 6) | (unit > 0 ? (1 << (unit - 1)) & 0x1f : 0x20); | 208 | to = (port << 6) | (unit > 0 ? (1 << (unit - 1)) & 0x1f : 0x20); |
195 | 209 | ||
196 | *maple_lastptr &= 0x7fffffff; | 210 | *maple_lastptr &= 0x7fffffff; |
197 | maple_lastptr = maple_sendptr; | 211 | maple_lastptr = maple_sendptr; |
198 | 212 | ||
199 | *maple_sendptr++ = (port << 16) | len | 0x80000000; | 213 | *maple_sendptr++ = (port << 16) | len | 0x80000000; |
200 | *maple_sendptr++ = PHYSADDR(mq->recvbuf); | 214 | *maple_sendptr++ = PHYSADDR(mq->recvbuf); |
201 | *maple_sendptr++ = | 215 | *maple_sendptr++ = |
202 | mq->command | (to << 8) | (from << 16) | (len << 24); | 216 | mq->command | (to << 8) | (from << 16) | (len << 24); |
203 | 217 | ||
204 | while (len-- > 0) | 218 | while (len-- > 0) |
205 | *maple_sendptr++ = *lsendbuf++; | 219 | *maple_sendptr++ = *lsendbuf++; |
206 | } | 220 | } |
207 | 221 | ||
208 | /* build up command queue */ | 222 | /* build up command queue */ |
209 | static void maple_send(void) | 223 | static void maple_send(void) |
210 | { | 224 | { |
211 | int i; | 225 | int i; |
212 | int maple_packets; | 226 | int maple_packets; |
213 | struct mapleq *mq, *nmq; | 227 | struct mapleq *mq, *nmq; |
214 | 228 | ||
215 | if (!list_empty(&maple_sentq)) | 229 | if (!list_empty(&maple_sentq)) |
216 | return; | 230 | return; |
217 | if (list_empty(&maple_waitq) || !maple_dma_done()) | 231 | if (list_empty(&maple_waitq) || !maple_dma_done()) |
218 | return; | 232 | return; |
219 | maple_packets = 0; | 233 | maple_packets = 0; |
220 | maple_sendptr = maple_lastptr = maple_sendbuf; | 234 | maple_sendptr = maple_lastptr = maple_sendbuf; |
221 | list_for_each_entry_safe(mq, nmq, &maple_waitq, list) { | 235 | list_for_each_entry_safe(mq, nmq, &maple_waitq, list) { |
222 | maple_build_block(mq); | 236 | maple_build_block(mq); |
223 | list_move(&mq->list, &maple_sentq); | 237 | list_move(&mq->list, &maple_sentq); |
224 | if (maple_packets++ > MAPLE_MAXPACKETS) | 238 | if (maple_packets++ > MAPLE_MAXPACKETS) |
225 | break; | 239 | break; |
226 | } | 240 | } |
227 | if (maple_packets > 0) { | 241 | if (maple_packets > 0) { |
228 | for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++) | 242 | for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++) |
229 | dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE, | 243 | dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE, |
230 | PAGE_SIZE, DMA_BIDIRECTIONAL); | 244 | PAGE_SIZE, DMA_BIDIRECTIONAL); |
231 | } | 245 | } |
232 | } | 246 | } |
233 | 247 | ||
234 | static int attach_matching_maple_driver(struct device_driver *driver, | 248 | static int attach_matching_maple_driver(struct device_driver *driver, |
235 | void *devptr) | 249 | void *devptr) |
236 | { | 250 | { |
237 | struct maple_driver *maple_drv; | 251 | struct maple_driver *maple_drv; |
238 | struct maple_device *mdev; | 252 | struct maple_device *mdev; |
239 | 253 | ||
240 | mdev = devptr; | 254 | mdev = devptr; |
241 | maple_drv = to_maple_driver(driver); | 255 | maple_drv = to_maple_driver(driver); |
242 | if (mdev->devinfo.function & be32_to_cpu(maple_drv->function)) { | 256 | if (mdev->devinfo.function & be32_to_cpu(maple_drv->function)) { |
243 | if (maple_drv->connect(mdev) == 0) { | 257 | if (maple_drv->connect(mdev) == 0) { |
244 | mdev->driver = maple_drv; | 258 | mdev->driver = maple_drv; |
245 | return 1; | 259 | return 1; |
246 | } | 260 | } |
247 | } | 261 | } |
248 | return 0; | 262 | return 0; |
249 | } | 263 | } |
250 | 264 | ||
251 | static void maple_detach_driver(struct maple_device *mdev) | 265 | static void maple_detach_driver(struct maple_device *mdev) |
252 | { | 266 | { |
253 | if (!mdev) | 267 | if (!mdev) |
254 | return; | 268 | return; |
255 | if (mdev->driver) { | 269 | if (mdev->driver) { |
256 | if (mdev->driver->disconnect) | 270 | if (mdev->driver->disconnect) |
257 | mdev->driver->disconnect(mdev); | 271 | mdev->driver->disconnect(mdev); |
258 | } | 272 | } |
259 | mdev->driver = NULL; | 273 | mdev->driver = NULL; |
260 | if (mdev->registered) { | 274 | device_unregister(&mdev->dev); |
261 | maple_release_device(&mdev->dev); | 275 | mdev = NULL; |
262 | device_unregister(&mdev->dev); | ||
263 | } | ||
264 | mdev->registered = 0; | ||
265 | maple_free_dev(mdev); | ||
266 | } | 276 | } |
267 | 277 | ||
268 | /* process initial MAPLE_COMMAND_DEVINFO for each device or port */ | 278 | /* process initial MAPLE_COMMAND_DEVINFO for each device or port */ |
269 | static void maple_attach_driver(struct maple_device *dev) | 279 | static void maple_attach_driver(struct maple_device *mdev) |
270 | { | 280 | { |
271 | char *p; | 281 | char *p, *recvbuf; |
272 | 282 | unsigned long function; | |
273 | char *recvbuf; | 283 | int matched, retval; |
274 | unsigned long function; | 284 | |
275 | int matched, retval; | 285 | recvbuf = mdev->mq->recvbuf; |
276 | 286 | /* copy the data as individual elements in | |
277 | recvbuf = dev->mq->recvbuf; | 287 | * case of memory optimisation */ |
278 | memcpy(&dev->devinfo, recvbuf + 4, sizeof(dev->devinfo)); | 288 | memcpy(&mdev->devinfo.function, recvbuf + 4, 4); |
279 | memcpy(dev->product_name, dev->devinfo.product_name, 30); | 289 | memcpy(&mdev->devinfo.function_data[0], recvbuf + 8, 12); |
280 | memcpy(dev->product_licence, dev->devinfo.product_licence, 60); | 290 | memcpy(&mdev->devinfo.area_code, recvbuf + 20, 1); |
281 | dev->product_name[30] = '\0'; | 291 | memcpy(&mdev->devinfo.connector_direction, recvbuf + 21, 1); |
282 | dev->product_licence[60] = '\0'; | 292 | memcpy(&mdev->devinfo.product_name[0], recvbuf + 22, 30); |
283 | 293 | memcpy(&mdev->devinfo.product_licence[0], recvbuf + 52, 60); | |
284 | for (p = dev->product_name + 29; dev->product_name <= p; p--) | 294 | memcpy(&mdev->devinfo.standby_power, recvbuf + 112, 2); |
285 | if (*p == ' ') | 295 | memcpy(&mdev->devinfo.max_power, recvbuf + 114, 2); |
286 | *p = '\0'; | 296 | memcpy(mdev->product_name, mdev->devinfo.product_name, 30); |
287 | else | 297 | mdev->product_name[30] = '\0'; |
288 | break; | 298 | memcpy(mdev->product_licence, mdev->devinfo.product_licence, 60); |
289 | 299 | mdev->product_licence[60] = '\0'; | |
290 | for (p = dev->product_licence + 59; dev->product_licence <= p; p--) | 300 | |
291 | if (*p == ' ') | 301 | for (p = mdev->product_name + 29; mdev->product_name <= p; p--) |
292 | *p = '\0'; | 302 | if (*p == ' ') |
293 | else | 303 | *p = '\0'; |
294 | break; | 304 | else |
295 | 305 | break; | |
296 | function = be32_to_cpu(dev->devinfo.function); | 306 | for (p = mdev->product_licence + 59; mdev->product_licence <= p; p--) |
297 | 307 | if (*p == ' ') | |
298 | if (function > 0x200) { | 308 | *p = '\0'; |
299 | /* Do this silently - as not a real device */ | 309 | else |
300 | function = 0; | 310 | break; |
301 | dev->driver = &maple_dummy_driver; | 311 | |
302 | sprintf(dev->dev.bus_id, "%d:0.port", dev->port); | 312 | if (realscan) { |
303 | } else { | 313 | printk(KERN_INFO "Maple device detected: %s\n", |
304 | printk(KERN_INFO | 314 | mdev->product_name); |
305 | "Maple bus at (%d, %d): Connected function 0x%lX\n", | 315 | printk(KERN_INFO "Maple device: %s\n", mdev->product_licence); |
306 | dev->port, dev->unit, function); | 316 | } |
307 | 317 | ||
308 | matched = | 318 | function = be32_to_cpu(mdev->devinfo.function); |
309 | bus_for_each_drv(&maple_bus_type, NULL, dev, | 319 | |
310 | attach_matching_maple_driver); | 320 | if (function > 0x200) { |
311 | 321 | /* Do this silently - as not a real device */ | |
312 | if (matched == 0) { | 322 | function = 0; |
313 | /* Driver does not exist yet */ | 323 | mdev->driver = &maple_dummy_driver; |
314 | printk(KERN_INFO | 324 | sprintf(mdev->dev.bus_id, "%d:0.port", mdev->port); |
315 | "No maple driver found for this device\n"); | 325 | } else { |
316 | dev->driver = &maple_dummy_driver; | 326 | if (realscan) |
317 | } | 327 | printk(KERN_INFO |
318 | 328 | "Maple bus at (%d, %d): Function 0x%lX\n", | |
319 | sprintf(dev->dev.bus_id, "%d:0%d.%lX", dev->port, | 329 | mdev->port, mdev->unit, function); |
320 | dev->unit, function); | 330 | |
321 | } | 331 | matched = |
322 | dev->function = function; | 332 | bus_for_each_drv(&maple_bus_type, NULL, mdev, |
323 | dev->dev.bus = &maple_bus_type; | 333 | attach_matching_maple_driver); |
324 | dev->dev.parent = &maple_bus; | 334 | |
325 | dev->dev.release = &maple_release_device; | 335 | if (matched == 0) { |
326 | retval = device_register(&dev->dev); | 336 | /* Driver does not exist yet */ |
327 | if (retval) { | 337 | if (realscan) |
328 | printk(KERN_INFO | 338 | printk(KERN_INFO |
329 | "Maple bus: Attempt to register device (%x, %x) failed.\n", | 339 | "No maple driver found.\n"); |
330 | dev->port, dev->unit); | 340 | mdev->driver = &maple_dummy_driver; |
331 | maple_free_dev(dev); | 341 | } |
332 | } | 342 | sprintf(mdev->dev.bus_id, "%d:0%d.%lX", mdev->port, |
333 | dev->registered = 1; | 343 | mdev->unit, function); |
344 | } | ||
345 | mdev->function = function; | ||
346 | mdev->dev.release = &maple_release_device; | ||
347 | retval = device_register(&mdev->dev); | ||
348 | if (retval) { | ||
349 | printk(KERN_INFO | ||
350 | "Maple bus: Attempt to register device" | ||
351 | " (%x, %x) failed.\n", | ||
352 | mdev->port, mdev->unit); | ||
353 | maple_free_dev(mdev); | ||
354 | mdev = NULL; | ||
355 | return; | ||
356 | } | ||
334 | } | 357 | } |
335 | 358 | ||
336 | /* | 359 | /* |
@@ -340,270 +363,262 @@ static void maple_attach_driver(struct maple_device *dev) | |||
340 | */ | 363 | */ |
341 | static int detach_maple_device(struct device *device, void *portptr) | 364 | static int detach_maple_device(struct device *device, void *portptr) |
342 | { | 365 | { |
343 | struct maple_device_specify *ds; | 366 | struct maple_device_specify *ds; |
344 | struct maple_device *mdev; | 367 | struct maple_device *mdev; |
345 | 368 | ||
346 | ds = portptr; | 369 | ds = portptr; |
347 | mdev = to_maple_dev(device); | 370 | mdev = to_maple_dev(device); |
348 | if (mdev->port == ds->port && mdev->unit == ds->unit) | 371 | if (mdev->port == ds->port && mdev->unit == ds->unit) |
349 | return 1; | 372 | return 1; |
350 | return 0; | 373 | return 0; |
351 | } | 374 | } |
352 | 375 | ||
353 | static int setup_maple_commands(struct device *device, void *ignored) | 376 | static int setup_maple_commands(struct device *device, void *ignored) |
354 | { | 377 | { |
355 | struct maple_device *maple_dev = to_maple_dev(device); | 378 | struct maple_device *maple_dev = to_maple_dev(device); |
356 | 379 | ||
357 | if ((maple_dev->interval > 0) | 380 | if ((maple_dev->interval > 0) |
358 | && time_after(jiffies, maple_dev->when)) { | 381 | && time_after(jiffies, maple_dev->when)) { |
359 | maple_dev->when = jiffies + maple_dev->interval; | 382 | maple_dev->when = jiffies + maple_dev->interval; |
360 | maple_dev->mq->command = MAPLE_COMMAND_GETCOND; | 383 | maple_dev->mq->command = MAPLE_COMMAND_GETCOND; |
361 | maple_dev->mq->sendbuf = &maple_dev->function; | 384 | maple_dev->mq->sendbuf = &maple_dev->function; |
362 | maple_dev->mq->length = 1; | 385 | maple_dev->mq->length = 1; |
363 | maple_add_packet(maple_dev->mq); | 386 | maple_add_packet(maple_dev->mq); |
364 | liststatus++; | 387 | liststatus++; |
365 | } else { | 388 | } else { |
366 | if (time_after(jiffies, maple_pnp_time)) { | 389 | if (time_after(jiffies, maple_pnp_time)) { |
367 | maple_dev->mq->command = MAPLE_COMMAND_DEVINFO; | 390 | maple_dev->mq->command = MAPLE_COMMAND_DEVINFO; |
368 | maple_dev->mq->length = 0; | 391 | maple_dev->mq->length = 0; |
369 | maple_add_packet(maple_dev->mq); | 392 | maple_add_packet(maple_dev->mq); |
370 | liststatus++; | 393 | liststatus++; |
371 | } | 394 | } |
372 | } | 395 | } |
373 | 396 | ||
374 | return 0; | 397 | return 0; |
375 | } | 398 | } |
376 | 399 | ||
377 | /* VBLANK bottom half - implemented via workqueue */ | 400 | /* VBLANK bottom half - implemented via workqueue */ |
378 | static void maple_vblank_handler(struct work_struct *work) | 401 | static void maple_vblank_handler(struct work_struct *work) |
379 | { | 402 | { |
380 | if (!maple_dma_done()) | 403 | if (!maple_dma_done()) |
381 | return; | 404 | return; |
382 | if (!list_empty(&maple_sentq)) | 405 | if (!list_empty(&maple_sentq)) |
383 | return; | 406 | return; |
384 | ctrl_outl(0, MAPLE_ENABLE); | 407 | ctrl_outl(0, MAPLE_ENABLE); |
385 | liststatus = 0; | 408 | liststatus = 0; |
386 | bus_for_each_dev(&maple_bus_type, NULL, NULL, | 409 | bus_for_each_dev(&maple_bus_type, NULL, NULL, |
387 | setup_maple_commands); | 410 | setup_maple_commands); |
388 | if (time_after(jiffies, maple_pnp_time)) | 411 | if (time_after(jiffies, maple_pnp_time)) |
389 | maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL; | 412 | maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL; |
390 | if (liststatus && list_empty(&maple_sentq)) { | 413 | if (liststatus && list_empty(&maple_sentq)) { |
391 | INIT_LIST_HEAD(&maple_sentq); | 414 | INIT_LIST_HEAD(&maple_sentq); |
392 | maple_send(); | 415 | maple_send(); |
393 | } | 416 | } |
394 | maplebus_dma_reset(); | 417 | maplebus_dma_reset(); |
395 | } | 418 | } |
396 | 419 | ||
397 | /* handle devices added via hotplugs - placing them on queue for DEVINFO*/ | 420 | /* handle devices added via hotplugs - placing them on queue for DEVINFO*/ |
398 | static void maple_map_subunits(struct maple_device *mdev, int submask) | 421 | static void maple_map_subunits(struct maple_device *mdev, int submask) |
399 | { | 422 | { |
400 | int retval, k, devcheck; | 423 | int retval, k, devcheck; |
401 | struct maple_device *mdev_add; | 424 | struct maple_device *mdev_add; |
402 | struct maple_device_specify ds; | 425 | struct maple_device_specify ds; |
403 | 426 | ||
404 | for (k = 0; k < 5; k++) { | 427 | for (k = 0; k < 5; k++) { |
405 | ds.port = mdev->port; | 428 | ds.port = mdev->port; |
406 | ds.unit = k + 1; | 429 | ds.unit = k + 1; |
407 | retval = | 430 | retval = |
408 | bus_for_each_dev(&maple_bus_type, NULL, &ds, | 431 | bus_for_each_dev(&maple_bus_type, NULL, &ds, |
409 | detach_maple_device); | 432 | detach_maple_device); |
410 | if (retval) { | 433 | if (retval) { |
411 | submask = submask >> 1; | 434 | submask = submask >> 1; |
412 | continue; | 435 | continue; |
413 | } | 436 | } |
414 | devcheck = submask & 0x01; | 437 | devcheck = submask & 0x01; |
415 | if (devcheck) { | 438 | if (devcheck) { |
416 | mdev_add = maple_alloc_dev(mdev->port, k + 1); | 439 | mdev_add = maple_alloc_dev(mdev->port, k + 1); |
417 | if (!mdev_add) | 440 | if (!mdev_add) |
418 | return; | 441 | return; |
419 | mdev_add->mq->command = MAPLE_COMMAND_DEVINFO; | 442 | mdev_add->mq->command = MAPLE_COMMAND_DEVINFO; |
420 | mdev_add->mq->length = 0; | 443 | mdev_add->mq->length = 0; |
421 | maple_add_packet(mdev_add->mq); | 444 | maple_add_packet(mdev_add->mq); |
422 | scanning = 1; | 445 | scanning = 1; |
423 | } | 446 | } |
424 | submask = submask >> 1; | 447 | submask = submask >> 1; |
425 | } | 448 | } |
426 | } | 449 | } |
427 | 450 | ||
428 | /* mark a device as removed */ | 451 | /* mark a device as removed */ |
429 | static void maple_clean_submap(struct maple_device *mdev) | 452 | static void maple_clean_submap(struct maple_device *mdev) |
430 | { | 453 | { |
431 | int killbit; | 454 | int killbit; |
432 | 455 | ||
433 | killbit = (mdev->unit > 0 ? (1 << (mdev->unit - 1)) & 0x1f : 0x20); | 456 | killbit = (mdev->unit > 0 ? (1 << (mdev->unit - 1)) & 0x1f : 0x20); |
434 | killbit = ~killbit; | 457 | killbit = ~killbit; |
435 | killbit &= 0xFF; | 458 | killbit &= 0xFF; |
436 | subdevice_map[mdev->port] = subdevice_map[mdev->port] & killbit; | 459 | subdevice_map[mdev->port] = subdevice_map[mdev->port] & killbit; |
437 | } | 460 | } |
438 | 461 | ||
439 | /* handle empty port or hotplug removal */ | 462 | /* handle empty port or hotplug removal */ |
440 | static void maple_response_none(struct maple_device *mdev, | 463 | static void maple_response_none(struct maple_device *mdev, |
441 | struct mapleq *mq) | 464 | struct mapleq *mq) |
442 | { | 465 | { |
443 | if (mdev->unit != 0) { | 466 | if (mdev->unit != 0) { |
444 | list_del(&mq->list); | 467 | list_del(&mq->list); |
445 | maple_clean_submap(mdev); | 468 | maple_clean_submap(mdev); |
446 | printk(KERN_INFO | 469 | printk(KERN_INFO |
447 | "Maple bus device detaching at (%d, %d)\n", | 470 | "Maple bus device detaching at (%d, %d)\n", |
448 | mdev->port, mdev->unit); | 471 | mdev->port, mdev->unit); |
449 | maple_detach_driver(mdev); | 472 | maple_detach_driver(mdev); |
450 | return; | 473 | return; |
451 | } | 474 | } |
452 | if (!started) { | 475 | if (!started) { |
453 | printk(KERN_INFO "No maple devices attached to port %d\n", | 476 | printk(KERN_INFO "No maple devices attached to port %d\n", |
454 | mdev->port); | 477 | mdev->port); |
455 | return; | 478 | return; |
456 | } | 479 | } |
457 | maple_clean_submap(mdev); | 480 | maple_clean_submap(mdev); |
458 | } | 481 | } |
459 | 482 | ||
460 | /* preprocess hotplugs or scans */ | 483 | /* preprocess hotplugs or scans */ |
461 | static void maple_response_devinfo(struct maple_device *mdev, | 484 | static void maple_response_devinfo(struct maple_device *mdev, |
462 | char *recvbuf) | 485 | char *recvbuf) |
463 | { | 486 | { |
464 | char submask; | 487 | char submask; |
465 | if ((!started) || (scanning == 2)) { | 488 | if ((!started) || (scanning == 2)) { |
466 | maple_attach_driver(mdev); | 489 | maple_attach_driver(mdev); |
467 | return; | 490 | return; |
468 | } | 491 | } |
469 | if (mdev->unit == 0) { | 492 | if (mdev->unit == 0) { |
470 | submask = recvbuf[2] & 0x1F; | 493 | submask = recvbuf[2] & 0x1F; |
471 | if (submask ^ subdevice_map[mdev->port]) { | 494 | if (submask ^ subdevice_map[mdev->port]) { |
472 | maple_map_subunits(mdev, submask); | 495 | maple_map_subunits(mdev, submask); |
473 | subdevice_map[mdev->port] = submask; | 496 | subdevice_map[mdev->port] = submask; |
474 | } | 497 | } |
475 | } | 498 | } |
476 | } | 499 | } |
477 | 500 | ||
478 | /* maple dma end bottom half - implemented via workqueue */ | 501 | /* maple dma end bottom half - implemented via workqueue */ |
479 | static void maple_dma_handler(struct work_struct *work) | 502 | static void maple_dma_handler(struct work_struct *work) |
480 | { | 503 | { |
481 | struct mapleq *mq, *nmq; | 504 | struct mapleq *mq, *nmq; |
482 | struct maple_device *dev; | 505 | struct maple_device *dev; |
483 | char *recvbuf; | 506 | char *recvbuf; |
484 | enum maple_code code; | 507 | enum maple_code code; |
485 | 508 | ||
486 | if (!maple_dma_done()) | 509 | if (!maple_dma_done()) |
487 | return; | 510 | return; |
488 | ctrl_outl(0, MAPLE_ENABLE); | 511 | ctrl_outl(0, MAPLE_ENABLE); |
489 | if (!list_empty(&maple_sentq)) { | 512 | if (!list_empty(&maple_sentq)) { |
490 | list_for_each_entry_safe(mq, nmq, &maple_sentq, list) { | 513 | list_for_each_entry_safe(mq, nmq, &maple_sentq, list) { |
491 | recvbuf = mq->recvbuf; | 514 | recvbuf = mq->recvbuf; |
492 | code = recvbuf[0]; | 515 | code = recvbuf[0]; |
493 | dev = mq->dev; | 516 | dev = mq->dev; |
494 | switch (code) { | 517 | switch (code) { |
495 | case MAPLE_RESPONSE_NONE: | 518 | case MAPLE_RESPONSE_NONE: |
496 | maple_response_none(dev, mq); | 519 | maple_response_none(dev, mq); |
497 | break; | 520 | break; |
498 | 521 | ||
499 | case MAPLE_RESPONSE_DEVINFO: | 522 | case MAPLE_RESPONSE_DEVINFO: |
500 | maple_response_devinfo(dev, recvbuf); | 523 | maple_response_devinfo(dev, recvbuf); |
501 | break; | 524 | break; |
502 | 525 | ||
503 | case MAPLE_RESPONSE_DATATRF: | 526 | case MAPLE_RESPONSE_DATATRF: |
504 | if (dev->callback) | 527 | if (dev->callback) |
505 | dev->callback(mq); | 528 | dev->callback(mq); |
506 | break; | 529 | break; |
507 | 530 | ||
508 | case MAPLE_RESPONSE_FILEERR: | 531 | case MAPLE_RESPONSE_FILEERR: |
509 | case MAPLE_RESPONSE_AGAIN: | 532 | case MAPLE_RESPONSE_AGAIN: |
510 | case MAPLE_RESPONSE_BADCMD: | 533 | case MAPLE_RESPONSE_BADCMD: |
511 | case MAPLE_RESPONSE_BADFUNC: | 534 | case MAPLE_RESPONSE_BADFUNC: |
512 | printk(KERN_DEBUG | 535 | printk(KERN_DEBUG |
513 | "Maple non-fatal error 0x%X\n", | 536 | "Maple non-fatal error 0x%X\n", |
514 | code); | 537 | code); |
515 | break; | 538 | break; |
516 | 539 | ||
517 | case MAPLE_RESPONSE_ALLINFO: | 540 | case MAPLE_RESPONSE_ALLINFO: |
518 | printk(KERN_DEBUG | 541 | printk(KERN_DEBUG |
519 | "Maple - extended device information not supported\n"); | 542 | "Maple - extended device information" |
520 | break; | 543 | " not supported\n"); |
521 | 544 | break; | |
522 | case MAPLE_RESPONSE_OK: | 545 | |
523 | break; | 546 | case MAPLE_RESPONSE_OK: |
524 | 547 | break; | |
525 | default: | 548 | |
526 | break; | 549 | default: |
527 | } | 550 | break; |
528 | } | 551 | } |
529 | INIT_LIST_HEAD(&maple_sentq); | 552 | } |
530 | if (scanning == 1) { | 553 | INIT_LIST_HEAD(&maple_sentq); |
531 | maple_send(); | 554 | if (scanning == 1) { |
532 | scanning = 2; | 555 | maple_send(); |
533 | } else | 556 | scanning = 2; |
534 | scanning = 0; | 557 | } else |
535 | 558 | scanning = 0; | |
536 | if (started == 0) | 559 | |
537 | started = 1; | 560 | if (started == 0) |
538 | } | 561 | started = 1; |
539 | maplebus_dma_reset(); | 562 | } |
563 | maplebus_dma_reset(); | ||
540 | } | 564 | } |
541 | 565 | ||
542 | static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id) | 566 | static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id) |
543 | { | 567 | { |
544 | /* Load everything into the bottom half */ | 568 | /* Load everything into the bottom half */ |
545 | schedule_work(&maple_dma_process); | 569 | schedule_work(&maple_dma_process); |
546 | return IRQ_HANDLED; | 570 | return IRQ_HANDLED; |
547 | } | 571 | } |
548 | 572 | ||
549 | static irqreturn_t maplebus_vblank_interrupt(int irq, void *dev_id) | 573 | static irqreturn_t maplebus_vblank_interrupt(int irq, void *dev_id) |
550 | { | 574 | { |
551 | schedule_work(&maple_vblank_process); | 575 | schedule_work(&maple_vblank_process); |
552 | return IRQ_HANDLED; | 576 | return IRQ_HANDLED; |
553 | } | 577 | } |
554 | 578 | ||
555 | static struct irqaction maple_dma_irq = { | ||
556 | .name = "maple bus DMA handler", | ||
557 | .handler = maplebus_dma_interrupt, | ||
558 | .flags = IRQF_SHARED, | ||
559 | }; | ||
560 | |||
561 | static struct irqaction maple_vblank_irq = { | ||
562 | .name = "maple bus VBLANK handler", | ||
563 | .handler = maplebus_vblank_interrupt, | ||
564 | .flags = IRQF_SHARED, | ||
565 | }; | ||
566 | |||
567 | static int maple_set_dma_interrupt_handler(void) | 579 | static int maple_set_dma_interrupt_handler(void) |
568 | { | 580 | { |
569 | return setup_irq(HW_EVENT_MAPLE_DMA, &maple_dma_irq); | 581 | return request_irq(HW_EVENT_MAPLE_DMA, maplebus_dma_interrupt, |
582 | IRQF_SHARED, "maple bus DMA", &maple_dummy_driver); | ||
570 | } | 583 | } |
571 | 584 | ||
572 | static int maple_set_vblank_interrupt_handler(void) | 585 | static int maple_set_vblank_interrupt_handler(void) |
573 | { | 586 | { |
574 | return setup_irq(HW_EVENT_VSYNC, &maple_vblank_irq); | 587 | return request_irq(HW_EVENT_VSYNC, maplebus_vblank_interrupt, |
588 | IRQF_SHARED, "maple bus VBLANK", &maple_dummy_driver); | ||
575 | } | 589 | } |
576 | 590 | ||
577 | static int maple_get_dma_buffer(void) | 591 | static int maple_get_dma_buffer(void) |
578 | { | 592 | { |
579 | maple_sendbuf = | 593 | maple_sendbuf = |
580 | (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO, | 594 | (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO, |
581 | MAPLE_DMA_PAGES); | 595 | MAPLE_DMA_PAGES); |
582 | if (!maple_sendbuf) | 596 | if (!maple_sendbuf) |
583 | return -ENOMEM; | 597 | return -ENOMEM; |
584 | return 0; | 598 | return 0; |
585 | } | 599 | } |
586 | 600 | ||
587 | static int match_maple_bus_driver(struct device *devptr, | 601 | static int match_maple_bus_driver(struct device *devptr, |
588 | struct device_driver *drvptr) | 602 | struct device_driver *drvptr) |
589 | { | 603 | { |
590 | struct maple_driver *maple_drv; | 604 | struct maple_driver *maple_drv; |
591 | struct maple_device *maple_dev; | 605 | struct maple_device *maple_dev; |
592 | 606 | ||
593 | maple_drv = container_of(drvptr, struct maple_driver, drv); | 607 | maple_drv = container_of(drvptr, struct maple_driver, drv); |
594 | maple_dev = container_of(devptr, struct maple_device, dev); | 608 | maple_dev = container_of(devptr, struct maple_device, dev); |
595 | /* Trap empty port case */ | 609 | /* Trap empty port case */ |
596 | if (maple_dev->devinfo.function == 0xFFFFFFFF) | 610 | if (maple_dev->devinfo.function == 0xFFFFFFFF) |
597 | return 0; | 611 | return 0; |
598 | else if (maple_dev->devinfo.function & | 612 | else if (maple_dev->devinfo.function & |
599 | be32_to_cpu(maple_drv->function)) | 613 | be32_to_cpu(maple_drv->function)) |
600 | return 1; | 614 | return 1; |
601 | return 0; | 615 | return 0; |
602 | } | 616 | } |
603 | 617 | ||
604 | static int maple_bus_uevent(struct device *dev, struct kobj_uevent_env *env) | 618 | static int maple_bus_uevent(struct device *dev, |
619 | struct kobj_uevent_env *env) | ||
605 | { | 620 | { |
606 | return 0; | 621 | return 0; |
607 | } | 622 | } |
608 | 623 | ||
609 | static void maple_bus_release(struct device *dev) | 624 | static void maple_bus_release(struct device *dev) |
@@ -611,124 +626,122 @@ static void maple_bus_release(struct device *dev) | |||
611 | } | 626 | } |
612 | 627 | ||
613 | static struct maple_driver maple_dummy_driver = { | 628 | static struct maple_driver maple_dummy_driver = { |
614 | .drv = { | 629 | .drv = { |
615 | .name = "maple_dummy_driver", | 630 | .name = "maple_dummy_driver", |
616 | .bus = &maple_bus_type, | 631 | .bus = &maple_bus_type, |
617 | }, | 632 | }, |
618 | }; | 633 | }; |
619 | 634 | ||
620 | struct bus_type maple_bus_type = { | 635 | struct bus_type maple_bus_type = { |
621 | .name = "maple", | 636 | .name = "maple", |
622 | .match = match_maple_bus_driver, | 637 | .match = match_maple_bus_driver, |
623 | .uevent = maple_bus_uevent, | 638 | .uevent = maple_bus_uevent, |
624 | }; | 639 | }; |
625 | EXPORT_SYMBOL_GPL(maple_bus_type); | 640 | EXPORT_SYMBOL_GPL(maple_bus_type); |
626 | 641 | ||
627 | static struct device maple_bus = { | 642 | static struct device maple_bus = { |
628 | .bus_id = "maple", | 643 | .bus_id = "maple", |
629 | .release = maple_bus_release, | 644 | .release = maple_bus_release, |
630 | }; | 645 | }; |
631 | 646 | ||
632 | static int __init maple_bus_init(void) | 647 | static int __init maple_bus_init(void) |
633 | { | 648 | { |
634 | int retval, i; | 649 | int retval, i; |
635 | struct maple_device *mdev[MAPLE_PORTS]; | 650 | struct maple_device *mdev[MAPLE_PORTS]; |
636 | ctrl_outl(0, MAPLE_STATE); | 651 | ctrl_outl(0, MAPLE_STATE); |
637 | 652 | ||
638 | retval = device_register(&maple_bus); | 653 | retval = device_register(&maple_bus); |
639 | if (retval) | 654 | if (retval) |
640 | goto cleanup; | 655 | goto cleanup; |
641 | 656 | ||
642 | retval = bus_register(&maple_bus_type); | 657 | retval = bus_register(&maple_bus_type); |
643 | if (retval) | 658 | if (retval) |
644 | goto cleanup_device; | 659 | goto cleanup_device; |
645 | 660 | ||
646 | retval = driver_register(&maple_dummy_driver.drv); | 661 | retval = driver_register(&maple_dummy_driver.drv); |
647 | 662 | if (retval) | |
648 | if (retval) | 663 | goto cleanup_bus; |
649 | goto cleanup_bus; | 664 | |
650 | 665 | /* allocate memory for maple bus dma */ | |
651 | /* allocate memory for maple bus dma */ | 666 | retval = maple_get_dma_buffer(); |
652 | retval = maple_get_dma_buffer(); | 667 | if (retval) { |
653 | if (retval) { | 668 | printk(KERN_INFO |
654 | printk(KERN_INFO | 669 | "Maple bus: Failed to allocate Maple DMA buffers\n"); |
655 | "Maple bus: Failed to allocate Maple DMA buffers\n"); | 670 | goto cleanup_basic; |
656 | goto cleanup_basic; | 671 | } |
657 | } | 672 | |
658 | 673 | /* set up DMA interrupt handler */ | |
659 | /* set up DMA interrupt handler */ | 674 | retval = maple_set_dma_interrupt_handler(); |
660 | retval = maple_set_dma_interrupt_handler(); | 675 | if (retval) { |
661 | if (retval) { | 676 | printk(KERN_INFO |
662 | printk(KERN_INFO | 677 | "Maple bus: Failed to grab maple DMA IRQ\n"); |
663 | "Maple bus: Failed to grab maple DMA IRQ\n"); | 678 | goto cleanup_dma; |
664 | goto cleanup_dma; | 679 | } |
665 | } | 680 | |
666 | 681 | /* set up VBLANK interrupt handler */ | |
667 | /* set up VBLANK interrupt handler */ | 682 | retval = maple_set_vblank_interrupt_handler(); |
668 | retval = maple_set_vblank_interrupt_handler(); | 683 | if (retval) { |
669 | if (retval) { | 684 | printk(KERN_INFO "Maple bus: Failed to grab VBLANK IRQ\n"); |
670 | printk(KERN_INFO "Maple bus: Failed to grab VBLANK IRQ\n"); | 685 | goto cleanup_irq; |
671 | goto cleanup_irq; | 686 | } |
672 | } | 687 | |
673 | 688 | maple_queue_cache = | |
674 | maple_queue_cache = | 689 | kmem_cache_create("maple_queue_cache", 0x400, 0, |
675 | kmem_cache_create("maple_queue_cache", 0x400, 0, | 690 | SLAB_POISON|SLAB_HWCACHE_ALIGN, NULL); |
676 | SLAB_HWCACHE_ALIGN, NULL); | 691 | |
677 | 692 | if (!maple_queue_cache) | |
678 | if (!maple_queue_cache) | 693 | goto cleanup_bothirqs; |
679 | goto cleanup_bothirqs; | 694 | |
680 | 695 | /* setup maple ports */ | |
681 | /* setup maple ports */ | 696 | for (i = 0; i < MAPLE_PORTS; i++) { |
682 | for (i = 0; i < MAPLE_PORTS; i++) { | 697 | mdev[i] = maple_alloc_dev(i, 0); |
683 | mdev[i] = maple_alloc_dev(i, 0); | 698 | if (!mdev[i]) { |
684 | if (!mdev[i]) { | 699 | while (i-- > 0) |
685 | while (i-- > 0) | 700 | maple_free_dev(mdev[i]); |
686 | maple_free_dev(mdev[i]); | 701 | goto cleanup_cache; |
687 | goto cleanup_cache; | 702 | } |
688 | } | 703 | mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO; |
689 | mdev[i]->registered = 0; | 704 | mdev[i]->mq->length = 0; |
690 | mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO; | 705 | maple_add_packet(mdev[i]->mq); |
691 | mdev[i]->mq->length = 0; | 706 | /* delay aids hardware detection */ |
692 | maple_attach_driver(mdev[i]); | 707 | mdelay(5); |
693 | maple_add_packet(mdev[i]->mq); | 708 | subdevice_map[i] = 0; |
694 | subdevice_map[i] = 0; | 709 | } |
695 | } | 710 | |
696 | 711 | realscan = 1; | |
697 | /* setup maplebus hardware */ | 712 | /* setup maplebus hardware */ |
698 | maplebus_dma_reset(); | 713 | maplebus_dma_reset(); |
699 | 714 | /* initial detection */ | |
700 | /* initial detection */ | 715 | maple_send(); |
701 | maple_send(); | 716 | maple_pnp_time = jiffies; |
702 | 717 | printk(KERN_INFO "Maple bus core now registered.\n"); | |
703 | maple_pnp_time = jiffies; | 718 | |
704 | 719 | return 0; | |
705 | printk(KERN_INFO "Maple bus core now registered.\n"); | ||
706 | |||
707 | return 0; | ||
708 | 720 | ||
709 | cleanup_cache: | 721 | cleanup_cache: |
710 | kmem_cache_destroy(maple_queue_cache); | 722 | kmem_cache_destroy(maple_queue_cache); |
711 | 723 | ||
712 | cleanup_bothirqs: | 724 | cleanup_bothirqs: |
713 | free_irq(HW_EVENT_VSYNC, 0); | 725 | free_irq(HW_EVENT_VSYNC, 0); |
714 | 726 | ||
715 | cleanup_irq: | 727 | cleanup_irq: |
716 | free_irq(HW_EVENT_MAPLE_DMA, 0); | 728 | free_irq(HW_EVENT_MAPLE_DMA, 0); |
717 | 729 | ||
718 | cleanup_dma: | 730 | cleanup_dma: |
719 | free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES); | 731 | free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES); |
720 | 732 | ||
721 | cleanup_basic: | 733 | cleanup_basic: |
722 | driver_unregister(&maple_dummy_driver.drv); | 734 | driver_unregister(&maple_dummy_driver.drv); |
723 | 735 | ||
724 | cleanup_bus: | 736 | cleanup_bus: |
725 | bus_unregister(&maple_bus_type); | 737 | bus_unregister(&maple_bus_type); |
726 | 738 | ||
727 | cleanup_device: | 739 | cleanup_device: |
728 | device_unregister(&maple_bus); | 740 | device_unregister(&maple_bus); |
729 | 741 | ||
730 | cleanup: | 742 | cleanup: |
731 | printk(KERN_INFO "Maple bus registration failed\n"); | 743 | printk(KERN_INFO "Maple bus registration failed\n"); |
732 | return retval; | 744 | return retval; |
733 | } | 745 | } |
734 | subsys_initcall(maple_bus_init); | 746 | /* Push init to later to ensure hardware gets detected */ |
747 | fs_initcall(maple_bus_init); | ||
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 293b7cab3e57..85687aaf9cab 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c | |||
@@ -87,6 +87,16 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi) | |||
87 | unsigned gpio = (unsigned) spi->controller_data; | 87 | unsigned gpio = (unsigned) spi->controller_data; |
88 | unsigned active = spi->mode & SPI_CS_HIGH; | 88 | unsigned active = spi->mode & SPI_CS_HIGH; |
89 | u32 mr; | 89 | u32 mr; |
90 | int i; | ||
91 | u32 csr; | ||
92 | u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0; | ||
93 | |||
94 | /* Make sure clock polarity is correct */ | ||
95 | for (i = 0; i < spi->master->num_chipselect; i++) { | ||
96 | csr = spi_readl(as, CSR0 + 4 * i); | ||
97 | if ((csr ^ cpol) & SPI_BIT(CPOL)) | ||
98 | spi_writel(as, CSR0 + 4 * i, csr ^ SPI_BIT(CPOL)); | ||
99 | } | ||
90 | 100 | ||
91 | mr = spi_readl(as, MR); | 101 | mr = spi_readl(as, MR); |
92 | mr = SPI_BFINS(PCS, ~(1 << spi->chip_select), mr); | 102 | mr = SPI_BFINS(PCS, ~(1 << spi->chip_select), mr); |
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c index 365e0e355aea..59deed79e0ab 100644 --- a/drivers/spi/pxa2xx_spi.c +++ b/drivers/spi/pxa2xx_spi.c | |||
@@ -51,13 +51,19 @@ MODULE_LICENSE("GPL"); | |||
51 | #define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK) | 51 | #define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK) |
52 | #define IS_DMA_ALIGNED(x) (((u32)(x)&0x07)==0) | 52 | #define IS_DMA_ALIGNED(x) (((u32)(x)&0x07)==0) |
53 | 53 | ||
54 | /* for testing SSCR1 changes that require SSP restart, basically | 54 | /* |
55 | * everything except the service and interrupt enables */ | 55 | * for testing SSCR1 changes that require SSP restart, basically |
56 | #define SSCR1_CHANGE_MASK (SSCR1_TTELP | SSCR1_TTE | SSCR1_EBCEI | SSCR1_SCFR \ | 56 | * everything except the service and interrupt enables, the pxa270 developer |
57 | * manual says only SSCR1_SCFR, SSCR1_SPH, SSCR1_SPO need to be in this | ||
58 | * list, but the PXA255 dev man says all bits without really meaning the | ||
59 | * service and interrupt enables | ||
60 | */ | ||
61 | #define SSCR1_CHANGE_MASK (SSCR1_TTELP | SSCR1_TTE | SSCR1_SCFR \ | ||
57 | | SSCR1_ECRA | SSCR1_ECRB | SSCR1_SCLKDIR \ | 62 | | SSCR1_ECRA | SSCR1_ECRB | SSCR1_SCLKDIR \ |
58 | | SSCR1_RWOT | SSCR1_TRAIL | SSCR1_PINTE \ | 63 | | SSCR1_SFRMDIR | SSCR1_RWOT | SSCR1_TRAIL \ |
59 | | SSCR1_STRF | SSCR1_EFWR |SSCR1_RFT \ | 64 | | SSCR1_IFS | SSCR1_STRF | SSCR1_EFWR \ |
60 | | SSCR1_TFT | SSCR1_SPH | SSCR1_SPO | SSCR1_LBM) | 65 | | SSCR1_RFT | SSCR1_TFT | SSCR1_MWDS \ |
66 | | SSCR1_SPH | SSCR1_SPO | SSCR1_LBM) | ||
61 | 67 | ||
62 | #define DEFINE_SSP_REG(reg, off) \ | 68 | #define DEFINE_SSP_REG(reg, off) \ |
63 | static inline u32 read_##reg(void *p) { return __raw_readl(p + (off)); } \ | 69 | static inline u32 read_##reg(void *p) { return __raw_readl(p + (off)); } \ |
@@ -973,9 +979,6 @@ static void pump_transfers(unsigned long data) | |||
973 | if (drv_data->ssp_type == PXA25x_SSP) | 979 | if (drv_data->ssp_type == PXA25x_SSP) |
974 | DCMD(drv_data->tx_channel) |= DCMD_ENDIRQEN; | 980 | DCMD(drv_data->tx_channel) |= DCMD_ENDIRQEN; |
975 | 981 | ||
976 | /* Fix me, need to handle cs polarity */ | ||
977 | drv_data->cs_control(PXA2XX_CS_ASSERT); | ||
978 | |||
979 | /* Clear status and start DMA engine */ | 982 | /* Clear status and start DMA engine */ |
980 | cr1 = chip->cr1 | dma_thresh | drv_data->dma_cr1; | 983 | cr1 = chip->cr1 | dma_thresh | drv_data->dma_cr1; |
981 | write_SSSR(drv_data->clear_sr, reg); | 984 | write_SSSR(drv_data->clear_sr, reg); |
@@ -985,9 +988,6 @@ static void pump_transfers(unsigned long data) | |||
985 | /* Ensure we have the correct interrupt handler */ | 988 | /* Ensure we have the correct interrupt handler */ |
986 | drv_data->transfer_handler = interrupt_transfer; | 989 | drv_data->transfer_handler = interrupt_transfer; |
987 | 990 | ||
988 | /* Fix me, need to handle cs polarity */ | ||
989 | drv_data->cs_control(PXA2XX_CS_ASSERT); | ||
990 | |||
991 | /* Clear status */ | 991 | /* Clear status */ |
992 | cr1 = chip->cr1 | chip->threshold | drv_data->int_cr1; | 992 | cr1 = chip->cr1 | chip->threshold | drv_data->int_cr1; |
993 | write_SSSR(drv_data->clear_sr, reg); | 993 | write_SSSR(drv_data->clear_sr, reg); |
@@ -998,16 +998,29 @@ static void pump_transfers(unsigned long data) | |||
998 | || (read_SSCR1(reg) & SSCR1_CHANGE_MASK) != | 998 | || (read_SSCR1(reg) & SSCR1_CHANGE_MASK) != |
999 | (cr1 & SSCR1_CHANGE_MASK)) { | 999 | (cr1 & SSCR1_CHANGE_MASK)) { |
1000 | 1000 | ||
1001 | /* stop the SSP, and update the other bits */ | ||
1001 | write_SSCR0(cr0 & ~SSCR0_SSE, reg); | 1002 | write_SSCR0(cr0 & ~SSCR0_SSE, reg); |
1002 | if (drv_data->ssp_type != PXA25x_SSP) | 1003 | if (drv_data->ssp_type != PXA25x_SSP) |
1003 | write_SSTO(chip->timeout, reg); | 1004 | write_SSTO(chip->timeout, reg); |
1004 | write_SSCR1(cr1, reg); | 1005 | /* first set CR1 without interrupt and service enables */ |
1006 | write_SSCR1(cr1 & SSCR1_CHANGE_MASK, reg); | ||
1007 | /* restart the SSP */ | ||
1005 | write_SSCR0(cr0, reg); | 1008 | write_SSCR0(cr0, reg); |
1009 | |||
1006 | } else { | 1010 | } else { |
1007 | if (drv_data->ssp_type != PXA25x_SSP) | 1011 | if (drv_data->ssp_type != PXA25x_SSP) |
1008 | write_SSTO(chip->timeout, reg); | 1012 | write_SSTO(chip->timeout, reg); |
1009 | write_SSCR1(cr1, reg); | ||
1010 | } | 1013 | } |
1014 | |||
1015 | /* FIXME, need to handle cs polarity, | ||
1016 | * this driver uses struct pxa2xx_spi_chip.cs_control to | ||
1017 | * specify a CS handling function, and it ignores most | ||
1018 | * struct spi_device.mode[s], including SPI_CS_HIGH */ | ||
1019 | drv_data->cs_control(PXA2XX_CS_ASSERT); | ||
1020 | |||
1021 | /* after chip select, release the data by enabling service | ||
1022 | * requests and interrupts, without changing any mode bits */ | ||
1023 | write_SSCR1(cr1, reg); | ||
1011 | } | 1024 | } |
1012 | 1025 | ||
1013 | static void pump_messages(struct work_struct *work) | 1026 | static void pump_messages(struct work_struct *work) |
diff --git a/drivers/thermal/thermal.c b/drivers/thermal/thermal.c index e782b3e7fcdb..8b86e53ccf7a 100644 --- a/drivers/thermal/thermal.c +++ b/drivers/thermal/thermal.c | |||
@@ -306,12 +306,23 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, | |||
306 | { | 306 | { |
307 | struct thermal_cooling_device_instance *dev; | 307 | struct thermal_cooling_device_instance *dev; |
308 | struct thermal_cooling_device_instance *pos; | 308 | struct thermal_cooling_device_instance *pos; |
309 | struct thermal_zone_device *pos1; | ||
310 | struct thermal_cooling_device *pos2; | ||
309 | int result; | 311 | int result; |
310 | 312 | ||
311 | if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE)) | 313 | if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE)) |
312 | return -EINVAL; | 314 | return -EINVAL; |
313 | 315 | ||
314 | if (!tz || !cdev) | 316 | list_for_each_entry(pos1, &thermal_tz_list, node) { |
317 | if (pos1 == tz) | ||
318 | break; | ||
319 | } | ||
320 | list_for_each_entry(pos2, &thermal_cdev_list, node) { | ||
321 | if (pos2 == cdev) | ||
322 | break; | ||
323 | } | ||
324 | |||
325 | if (tz != pos1 || cdev != pos2) | ||
315 | return -EINVAL; | 326 | return -EINVAL; |
316 | 327 | ||
317 | dev = | 328 | dev = |
@@ -437,20 +448,20 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type, | |||
437 | int result; | 448 | int result; |
438 | 449 | ||
439 | if (strlen(type) >= THERMAL_NAME_LENGTH) | 450 | if (strlen(type) >= THERMAL_NAME_LENGTH) |
440 | return NULL; | 451 | return ERR_PTR(-EINVAL); |
441 | 452 | ||
442 | if (!ops || !ops->get_max_state || !ops->get_cur_state || | 453 | if (!ops || !ops->get_max_state || !ops->get_cur_state || |
443 | !ops->set_cur_state) | 454 | !ops->set_cur_state) |
444 | return NULL; | 455 | return ERR_PTR(-EINVAL); |
445 | 456 | ||
446 | cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL); | 457 | cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL); |
447 | if (!cdev) | 458 | if (!cdev) |
448 | return NULL; | 459 | return ERR_PTR(-ENOMEM); |
449 | 460 | ||
450 | result = get_idr(&thermal_cdev_idr, &thermal_idr_lock, &cdev->id); | 461 | result = get_idr(&thermal_cdev_idr, &thermal_idr_lock, &cdev->id); |
451 | if (result) { | 462 | if (result) { |
452 | kfree(cdev); | 463 | kfree(cdev); |
453 | return NULL; | 464 | return ERR_PTR(result); |
454 | } | 465 | } |
455 | 466 | ||
456 | strcpy(cdev->type, type); | 467 | strcpy(cdev->type, type); |
@@ -462,7 +473,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type, | |||
462 | if (result) { | 473 | if (result) { |
463 | release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); | 474 | release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); |
464 | kfree(cdev); | 475 | kfree(cdev); |
465 | return NULL; | 476 | return ERR_PTR(result); |
466 | } | 477 | } |
467 | 478 | ||
468 | /* sys I/F */ | 479 | /* sys I/F */ |
@@ -498,7 +509,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type, | |||
498 | unregister: | 509 | unregister: |
499 | release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); | 510 | release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); |
500 | device_unregister(&cdev->device); | 511 | device_unregister(&cdev->device); |
501 | return NULL; | 512 | return ERR_PTR(result); |
502 | } | 513 | } |
503 | 514 | ||
504 | EXPORT_SYMBOL(thermal_cooling_device_register); | 515 | EXPORT_SYMBOL(thermal_cooling_device_register); |
@@ -570,17 +581,17 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, | |||
570 | int count; | 581 | int count; |
571 | 582 | ||
572 | if (strlen(type) >= THERMAL_NAME_LENGTH) | 583 | if (strlen(type) >= THERMAL_NAME_LENGTH) |
573 | return NULL; | 584 | return ERR_PTR(-EINVAL); |
574 | 585 | ||
575 | if (trips > THERMAL_MAX_TRIPS || trips < 0) | 586 | if (trips > THERMAL_MAX_TRIPS || trips < 0) |
576 | return NULL; | 587 | return ERR_PTR(-EINVAL); |
577 | 588 | ||
578 | if (!ops || !ops->get_temp) | 589 | if (!ops || !ops->get_temp) |
579 | return NULL; | 590 | return ERR_PTR(-EINVAL); |
580 | 591 | ||
581 | tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL); | 592 | tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL); |
582 | if (!tz) | 593 | if (!tz) |
583 | return NULL; | 594 | return ERR_PTR(-ENOMEM); |
584 | 595 | ||
585 | INIT_LIST_HEAD(&tz->cooling_devices); | 596 | INIT_LIST_HEAD(&tz->cooling_devices); |
586 | idr_init(&tz->idr); | 597 | idr_init(&tz->idr); |
@@ -588,7 +599,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, | |||
588 | result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id); | 599 | result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id); |
589 | if (result) { | 600 | if (result) { |
590 | kfree(tz); | 601 | kfree(tz); |
591 | return NULL; | 602 | return ERR_PTR(result); |
592 | } | 603 | } |
593 | 604 | ||
594 | strcpy(tz->type, type); | 605 | strcpy(tz->type, type); |
@@ -601,7 +612,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, | |||
601 | if (result) { | 612 | if (result) { |
602 | release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); | 613 | release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); |
603 | kfree(tz); | 614 | kfree(tz); |
604 | return NULL; | 615 | return ERR_PTR(result); |
605 | } | 616 | } |
606 | 617 | ||
607 | /* sys I/F */ | 618 | /* sys I/F */ |
@@ -643,7 +654,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, | |||
643 | unregister: | 654 | unregister: |
644 | release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); | 655 | release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); |
645 | device_unregister(&tz->device); | 656 | device_unregister(&tz->device); |
646 | return NULL; | 657 | return ERR_PTR(result); |
647 | } | 658 | } |
648 | 659 | ||
649 | EXPORT_SYMBOL(thermal_zone_device_register); | 660 | EXPORT_SYMBOL(thermal_zone_device_register); |
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 2a77e9d42c68..e8a01f264540 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -57,29 +57,29 @@ struct uio_map { | |||
57 | }; | 57 | }; |
58 | #define to_map(map) container_of(map, struct uio_map, kobj) | 58 | #define to_map(map) container_of(map, struct uio_map, kobj) |
59 | 59 | ||
60 | 60 | static ssize_t map_addr_show(struct uio_mem *mem, char *buf) | |
61 | static ssize_t map_attr_show(struct kobject *kobj, struct kobj_attribute *attr, | ||
62 | char *buf) | ||
63 | { | 61 | { |
64 | struct uio_map *map = to_map(kobj); | 62 | return sprintf(buf, "0x%lx\n", mem->addr); |
65 | struct uio_mem *mem = map->mem; | 63 | } |
66 | |||
67 | if (strncmp(attr->attr.name, "addr", 4) == 0) | ||
68 | return sprintf(buf, "0x%lx\n", mem->addr); | ||
69 | |||
70 | if (strncmp(attr->attr.name, "size", 4) == 0) | ||
71 | return sprintf(buf, "0x%lx\n", mem->size); | ||
72 | 64 | ||
73 | return -ENODEV; | 65 | static ssize_t map_size_show(struct uio_mem *mem, char *buf) |
66 | { | ||
67 | return sprintf(buf, "0x%lx\n", mem->size); | ||
74 | } | 68 | } |
75 | 69 | ||
76 | static struct kobj_attribute attr_attribute = | 70 | struct uio_sysfs_entry { |
77 | __ATTR(addr, S_IRUGO, map_attr_show, NULL); | 71 | struct attribute attr; |
78 | static struct kobj_attribute size_attribute = | 72 | ssize_t (*show)(struct uio_mem *, char *); |
79 | __ATTR(size, S_IRUGO, map_attr_show, NULL); | 73 | ssize_t (*store)(struct uio_mem *, const char *, size_t); |
74 | }; | ||
75 | |||
76 | static struct uio_sysfs_entry addr_attribute = | ||
77 | __ATTR(addr, S_IRUGO, map_addr_show, NULL); | ||
78 | static struct uio_sysfs_entry size_attribute = | ||
79 | __ATTR(size, S_IRUGO, map_size_show, NULL); | ||
80 | 80 | ||
81 | static struct attribute *attrs[] = { | 81 | static struct attribute *attrs[] = { |
82 | &attr_attribute.attr, | 82 | &addr_attribute.attr, |
83 | &size_attribute.attr, | 83 | &size_attribute.attr, |
84 | NULL, /* need to NULL terminate the list of attributes */ | 84 | NULL, /* need to NULL terminate the list of attributes */ |
85 | }; | 85 | }; |
@@ -90,8 +90,28 @@ static void map_release(struct kobject *kobj) | |||
90 | kfree(map); | 90 | kfree(map); |
91 | } | 91 | } |
92 | 92 | ||
93 | static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr, | ||
94 | char *buf) | ||
95 | { | ||
96 | struct uio_map *map = to_map(kobj); | ||
97 | struct uio_mem *mem = map->mem; | ||
98 | struct uio_sysfs_entry *entry; | ||
99 | |||
100 | entry = container_of(attr, struct uio_sysfs_entry, attr); | ||
101 | |||
102 | if (!entry->show) | ||
103 | return -EIO; | ||
104 | |||
105 | return entry->show(mem, buf); | ||
106 | } | ||
107 | |||
108 | static struct sysfs_ops uio_sysfs_ops = { | ||
109 | .show = map_type_show, | ||
110 | }; | ||
111 | |||
93 | static struct kobj_type map_attr_type = { | 112 | static struct kobj_type map_attr_type = { |
94 | .release = map_release, | 113 | .release = map_release, |
114 | .sysfs_ops = &uio_sysfs_ops, | ||
95 | .default_attrs = attrs, | 115 | .default_attrs = attrs, |
96 | }; | 116 | }; |
97 | 117 | ||
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index bcc42136c93f..0147ea39340e 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -496,13 +496,10 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) | |||
496 | otherwise it is scheduled, and with high data rates data can get lost. */ | 496 | otherwise it is scheduled, and with high data rates data can get lost. */ |
497 | tty->low_latency = 1; | 497 | tty->low_latency = 1; |
498 | 498 | ||
499 | if (usb_autopm_get_interface(acm->control)) { | 499 | if (usb_autopm_get_interface(acm->control) < 0) |
500 | mutex_unlock(&open_mutex); | 500 | goto early_bail; |
501 | return -EIO; | ||
502 | } | ||
503 | 501 | ||
504 | mutex_lock(&acm->mutex); | 502 | mutex_lock(&acm->mutex); |
505 | mutex_unlock(&open_mutex); | ||
506 | if (acm->used++) { | 503 | if (acm->used++) { |
507 | usb_autopm_put_interface(acm->control); | 504 | usb_autopm_put_interface(acm->control); |
508 | goto done; | 505 | goto done; |
@@ -536,6 +533,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) | |||
536 | done: | 533 | done: |
537 | err_out: | 534 | err_out: |
538 | mutex_unlock(&acm->mutex); | 535 | mutex_unlock(&acm->mutex); |
536 | mutex_unlock(&open_mutex); | ||
539 | return rv; | 537 | return rv; |
540 | 538 | ||
541 | full_bailout: | 539 | full_bailout: |
@@ -544,6 +542,8 @@ bail_out: | |||
544 | usb_autopm_put_interface(acm->control); | 542 | usb_autopm_put_interface(acm->control); |
545 | acm->used--; | 543 | acm->used--; |
546 | mutex_unlock(&acm->mutex); | 544 | mutex_unlock(&acm->mutex); |
545 | early_bail: | ||
546 | mutex_unlock(&open_mutex); | ||
547 | return -EIO; | 547 | return -EIO; |
548 | } | 548 | } |
549 | 549 | ||
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index ad632f2d6f94..0647164d36db 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -428,6 +428,7 @@ static int usblp_open(struct inode *inode, struct file *file) | |||
428 | usblp->rcomplete = 0; | 428 | usblp->rcomplete = 0; |
429 | 429 | ||
430 | if (handle_bidir(usblp) < 0) { | 430 | if (handle_bidir(usblp) < 0) { |
431 | usb_autopm_put_interface(intf); | ||
431 | usblp->used = 0; | 432 | usblp->used = 0; |
432 | file->private_data = NULL; | 433 | file->private_data = NULL; |
433 | retval = -EIO; | 434 | retval = -EIO; |
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index d42c561c75f1..f90ab5e94c58 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
@@ -28,11 +28,23 @@ | |||
28 | * devices is broken... | 28 | * devices is broken... |
29 | */ | 29 | */ |
30 | static const struct usb_device_id usb_quirk_list[] = { | 30 | static const struct usb_device_id usb_quirk_list[] = { |
31 | /* Action Semiconductor flash disk */ | ||
32 | { USB_DEVICE(0x10d6, 0x2200), .driver_info = USB_QUIRK_STRING_FETCH_255}, | ||
33 | |||
31 | /* CBM - Flash disk */ | 34 | /* CBM - Flash disk */ |
32 | { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME }, | 35 | { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME }, |
33 | /* HP 5300/5370C scanner */ | 36 | /* HP 5300/5370C scanner */ |
34 | { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 }, | 37 | { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 }, |
35 | 38 | ||
39 | /* Creative SB Audigy 2 NX */ | ||
40 | { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
41 | |||
42 | /* Roland SC-8820 */ | ||
43 | { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
44 | |||
45 | /* Edirol SD-20 */ | ||
46 | { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
47 | |||
36 | /* INTEL VALUE SSD */ | 48 | /* INTEL VALUE SSD */ |
37 | { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, | 49 | { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, |
38 | 50 | ||
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index a70e255402b8..e99872308144 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -1561,6 +1561,7 @@ done_set_intf: | |||
1561 | memcpy(req->buf, buf, n); | 1561 | memcpy(req->buf, buf, n); |
1562 | req->complete = rndis_response_complete; | 1562 | req->complete = rndis_response_complete; |
1563 | rndis_free_response(dev->rndis_config, buf); | 1563 | rndis_free_response(dev->rndis_config, buf); |
1564 | value = n; | ||
1564 | } | 1565 | } |
1565 | /* else stalls ... spec says to avoid that */ | 1566 | /* else stalls ... spec says to avoid that */ |
1566 | } | 1567 | } |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 3301167d4f2a..017a196d041f 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -3563,8 +3563,7 @@ static ssize_t show_file(struct device *dev, struct device_attribute *attr, | |||
3563 | 3563 | ||
3564 | down_read(&fsg->filesem); | 3564 | down_read(&fsg->filesem); |
3565 | if (backing_file_is_open(curlun)) { // Get the complete pathname | 3565 | if (backing_file_is_open(curlun)) { // Get the complete pathname |
3566 | p = d_path(curlun->filp->f_path.dentry, | 3566 | p = d_path(&curlun->filp->f_path, buf, PAGE_SIZE - 1); |
3567 | curlun->filp->f_path.mnt, buf, PAGE_SIZE - 1); | ||
3568 | if (IS_ERR(p)) | 3567 | if (IS_ERR(p)) |
3569 | rc = PTR_ERR(p); | 3568 | rc = PTR_ERR(p); |
3570 | else { | 3569 | else { |
@@ -3981,9 +3980,8 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3981 | if (backing_file_is_open(curlun)) { | 3980 | if (backing_file_is_open(curlun)) { |
3982 | p = NULL; | 3981 | p = NULL; |
3983 | if (pathbuf) { | 3982 | if (pathbuf) { |
3984 | p = d_path(curlun->filp->f_path.dentry, | 3983 | p = d_path(&curlun->filp->f_path, |
3985 | curlun->filp->f_path.mnt, | 3984 | pathbuf, PATH_MAX); |
3986 | pathbuf, PATH_MAX); | ||
3987 | if (IS_ERR(p)) | 3985 | if (IS_ERR(p)) |
3988 | p = NULL; | 3986 | p = NULL; |
3989 | } | 3987 | } |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 9fdabc8fcac4..4f6bfa100f2a 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -1299,7 +1299,7 @@ printer_unbind(struct usb_gadget *gadget) | |||
1299 | printer_req_free(dev->in_ep, req); | 1299 | printer_req_free(dev->in_ep, req); |
1300 | } | 1300 | } |
1301 | 1301 | ||
1302 | if (dev->current_rx_req != NULL); | 1302 | if (dev->current_rx_req != NULL) |
1303 | printer_req_free(dev->out_ep, dev->current_rx_req); | 1303 | printer_req_free(dev->out_ep, dev->current_rx_req); |
1304 | 1304 | ||
1305 | while (!list_empty(&dev->rx_reqs)) { | 1305 | while (!list_empty(&dev->rx_reqs)) { |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index d97b16b52efa..bf8be2a41a4a 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -69,10 +69,9 @@ config USB_EHCI_BIG_ENDIAN_DESC | |||
69 | default y | 69 | default y |
70 | 70 | ||
71 | config USB_EHCI_FSL | 71 | config USB_EHCI_FSL |
72 | bool | 72 | bool "Support for Freescale on-chip EHCI USB controller" |
73 | depends on USB_EHCI_HCD | 73 | depends on USB_EHCI_HCD && FSL_SOC |
74 | select USB_EHCI_ROOT_HUB_TT | 74 | select USB_EHCI_ROOT_HUB_TT |
75 | default y if MPC834x || PPC_MPC831x | ||
76 | ---help--- | 75 | ---help--- |
77 | Variation of ARC USB block used in some Freescale chips. | 76 | Variation of ARC USB block used in some Freescale chips. |
78 | 77 | ||
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 4caa6a8b9a37..b8ad55aff842 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -862,18 +862,18 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
862 | /* reschedule QH iff another request is queued */ | 862 | /* reschedule QH iff another request is queued */ |
863 | if (!list_empty (&qh->qtd_list) | 863 | if (!list_empty (&qh->qtd_list) |
864 | && HC_IS_RUNNING (hcd->state)) { | 864 | && HC_IS_RUNNING (hcd->state)) { |
865 | int schedule_status; | 865 | rc = qh_schedule(ehci, qh); |
866 | 866 | ||
867 | schedule_status = qh_schedule (ehci, qh); | 867 | /* An error here likely indicates handshake failure |
868 | spin_unlock_irqrestore (&ehci->lock, flags); | 868 | * or no space left in the schedule. Neither fault |
869 | 869 | * should happen often ... | |
870 | if (schedule_status != 0) { | 870 | * |
871 | // shouldn't happen often, but ... | 871 | * FIXME kill the now-dysfunctional queued urbs |
872 | // FIXME kill those tds' urbs | 872 | */ |
873 | err ("can't reschedule qh %p, err %d", | 873 | if (rc != 0) |
874 | qh, schedule_status); | 874 | ehci_err(ehci, |
875 | } | 875 | "can't reschedule qh %p, err %d", |
876 | return status; | 876 | qh, rc); |
877 | } | 877 | } |
878 | break; | 878 | break; |
879 | 879 | ||
@@ -1014,7 +1014,7 @@ MODULE_LICENSE ("GPL"); | |||
1014 | #endif | 1014 | #endif |
1015 | 1015 | ||
1016 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1016 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
1017 | !defined(PS3_SYSTEM_BUS_DRIVER) | 1017 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) |
1018 | #error "missing bus glue for ehci-hcd" | 1018 | #error "missing bus glue for ehci-hcd" |
1019 | #endif | 1019 | #endif |
1020 | 1020 | ||
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index ba370c56172c..59be276ccd9d 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -1766,6 +1766,7 @@ sl811h_suspend(struct platform_device *dev, pm_message_t state) | |||
1766 | retval = sl811h_bus_suspend(hcd); | 1766 | retval = sl811h_bus_suspend(hcd); |
1767 | break; | 1767 | break; |
1768 | case PM_EVENT_SUSPEND: | 1768 | case PM_EVENT_SUSPEND: |
1769 | case PM_EVENT_HIBERNATE: | ||
1769 | case PM_EVENT_PRETHAW: /* explicitly discard hw state */ | 1770 | case PM_EVENT_PRETHAW: /* explicitly discard hw state */ |
1770 | port_power(sl811, 0); | 1771 | port_power(sl811, 0); |
1771 | break; | 1772 | break; |
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index ac283b09a63f..3033d6945202 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
@@ -3213,15 +3213,20 @@ static int u132_suspend(struct platform_device *pdev, pm_message_t state) | |||
3213 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | 3213 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); |
3214 | return -ESHUTDOWN; | 3214 | return -ESHUTDOWN; |
3215 | } else { | 3215 | } else { |
3216 | int retval = 0; | 3216 | int retval = 0, ports; |
3217 | if (state.event == PM_EVENT_FREEZE) { | 3217 | |
3218 | switch (state.event) { | ||
3219 | case PM_EVENT_FREEZE: | ||
3218 | retval = u132_bus_suspend(hcd); | 3220 | retval = u132_bus_suspend(hcd); |
3219 | } else if (state.event == PM_EVENT_SUSPEND) { | 3221 | break; |
3220 | int ports = MAX_U132_PORTS; | 3222 | case PM_EVENT_SUSPEND: |
3223 | case PM_EVENT_HIBERNATE: | ||
3224 | ports = MAX_U132_PORTS; | ||
3221 | while (ports-- > 0) { | 3225 | while (ports-- > 0) { |
3222 | port_power(u132, ports, 0); | 3226 | port_power(u132, ports, 0); |
3223 | } | 3227 | } |
3224 | } | 3228 | break; |
3229 | } | ||
3225 | if (retval == 0) | 3230 | if (retval == 0) |
3226 | pdev->dev.power.power_state = state; | 3231 | pdev->dev.power.power_state = state; |
3227 | return retval; | 3232 | return retval; |
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 8208496dfc63..c730d20eec66 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
@@ -61,6 +61,7 @@ | |||
61 | #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 | 61 | #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 |
62 | #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 | 62 | #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 |
63 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 | 63 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 |
64 | #define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 | ||
64 | 65 | ||
65 | #define USB_VENDOR_ID_MICROCHIP 0x04d8 | 66 | #define USB_VENDOR_ID_MICROCHIP 0x04d8 |
66 | #define USB_DEVICE_ID_PICDEM 0x000c | 67 | #define USB_DEVICE_ID_PICDEM 0x000c |
@@ -92,6 +93,7 @@ static struct usb_device_id ld_usb_table [] = { | |||
92 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, | 93 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, |
93 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, | 94 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, |
94 | { USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICDEM) }, | 95 | { USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICDEM) }, |
96 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, | ||
95 | { } /* Terminating entry */ | 97 | { } /* Terminating entry */ |
96 | }; | 98 | }; |
97 | MODULE_DEVICE_TABLE(usb, ld_usb_table); | 99 | MODULE_DEVICE_TABLE(usb, ld_usb_table); |
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index 67e2fc20eeeb..03368edf3f22 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c | |||
@@ -59,13 +59,14 @@ static ssize_t set_speed(struct device *dev, struct device_attribute *attr, | |||
59 | { | 59 | { |
60 | struct usb_interface *intf = to_usb_interface(dev); | 60 | struct usb_interface *intf = to_usb_interface(dev); |
61 | struct trancevibrator *tv = usb_get_intfdata(intf); | 61 | struct trancevibrator *tv = usb_get_intfdata(intf); |
62 | int temp, retval; | 62 | int temp, retval, old; |
63 | 63 | ||
64 | temp = simple_strtoul(buf, NULL, 10); | 64 | temp = simple_strtoul(buf, NULL, 10); |
65 | if (temp > 255) | 65 | if (temp > 255) |
66 | temp = 255; | 66 | temp = 255; |
67 | else if (temp < 0) | 67 | else if (temp < 0) |
68 | temp = 0; | 68 | temp = 0; |
69 | old = tv->speed; | ||
69 | tv->speed = temp; | 70 | tv->speed = temp; |
70 | 71 | ||
71 | dev_dbg(&tv->udev->dev, "speed = %d\n", tv->speed); | 72 | dev_dbg(&tv->udev->dev, "speed = %d\n", tv->speed); |
@@ -77,6 +78,7 @@ static ssize_t set_speed(struct device *dev, struct device_attribute *attr, | |||
77 | tv->speed, /* speed value */ | 78 | tv->speed, /* speed value */ |
78 | 0, NULL, 0, USB_CTRL_GET_TIMEOUT); | 79 | 0, NULL, 0, USB_CTRL_GET_TIMEOUT); |
79 | if (retval) { | 80 | if (retval) { |
81 | tv->speed = old; | ||
80 | dev_dbg(&tv->udev->dev, "retval = %d\n", retval); | 82 | dev_dbg(&tv->udev->dev, "retval = %d\n", retval); |
81 | return retval; | 83 | return retval; |
82 | } | 84 | } |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 90dcc625f70d..76db2fef4657 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -393,8 +393,8 @@ static const char *ftdi_chip_name[] = { | |||
393 | #define FTDI_STATUS_B1_MASK (FTDI_RS_BI) | 393 | #define FTDI_STATUS_B1_MASK (FTDI_RS_BI) |
394 | /* End TIOCMIWAIT */ | 394 | /* End TIOCMIWAIT */ |
395 | 395 | ||
396 | #define FTDI_IMPL_ASYNC_FLAGS = ( ASYNC_SPD_HI | ASYNC_SPD_VHI \ | 396 | #define FTDI_IMPL_ASYNC_FLAGS = (ASYNC_SPD_HI | ASYNC_SPD_VHI \ |
397 | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP ) | 397 | | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP) |
398 | 398 | ||
399 | /* function prototypes for a FTDI serial converter */ | 399 | /* function prototypes for a FTDI serial converter */ |
400 | static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id); | 400 | static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id); |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 5e8bf1bc1e50..af2674c57414 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -113,6 +113,9 @@ static int option_send_setup(struct usb_serial_port *port); | |||
113 | #define NOVATELWIRELESS_VENDOR_ID 0x1410 | 113 | #define NOVATELWIRELESS_VENDOR_ID 0x1410 |
114 | #define DELL_VENDOR_ID 0x413C | 114 | #define DELL_VENDOR_ID 0x413C |
115 | 115 | ||
116 | #define KYOCERA_VENDOR_ID 0x0c88 | ||
117 | #define KYOCERA_PRODUCT_KPC680 0x180a | ||
118 | |||
116 | #define ANYDATA_VENDOR_ID 0x16d5 | 119 | #define ANYDATA_VENDOR_ID 0x16d5 |
117 | #define ANYDATA_PRODUCT_ADU_E100A 0x6501 | 120 | #define ANYDATA_PRODUCT_ADU_E100A 0x6501 |
118 | #define ANYDATA_PRODUCT_ADU_500A 0x6502 | 121 | #define ANYDATA_PRODUCT_ADU_500A 0x6502 |
@@ -121,6 +124,8 @@ static int option_send_setup(struct usb_serial_port *port); | |||
121 | #define BANDRICH_PRODUCT_C100_1 0x1002 | 124 | #define BANDRICH_PRODUCT_C100_1 0x1002 |
122 | #define BANDRICH_PRODUCT_C100_2 0x1003 | 125 | #define BANDRICH_PRODUCT_C100_2 0x1003 |
123 | 126 | ||
127 | #define QUALCOMM_VENDOR_ID 0x05C6 | ||
128 | |||
124 | static struct usb_device_id option_ids[] = { | 129 | static struct usb_device_id option_ids[] = { |
125 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 130 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
126 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, | 131 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
@@ -174,18 +179,23 @@ static struct usb_device_id option_ids[] = { | |||
174 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ | 179 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ |
175 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4100) }, /* Novatel U727 */ | 180 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4100) }, /* Novatel U727 */ |
176 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4400) }, /* Novatel MC950 */ | 181 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4400) }, /* Novatel MC950 */ |
182 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x5010) }, /* Novatel U727 */ | ||
177 | { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ | 183 | { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ |
178 | { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ | 184 | { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ |
179 | { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ | 185 | { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ |
180 | { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ | 186 | { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ |
181 | { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ | 187 | { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ |
182 | { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ | 188 | { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ |
189 | { USB_DEVICE(DELL_VENDOR_ID, 0x8129) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite ET620 CDMA/EV-DO */ | ||
190 | { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ | ||
183 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ | 191 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ |
184 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ | 192 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ |
185 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, | 193 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, |
186 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, | 194 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, |
187 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, | 195 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, |
188 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, | 196 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, |
197 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, | ||
198 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ | ||
189 | { } /* Terminating entry */ | 199 | { } /* Terminating entry */ |
190 | }; | 200 | }; |
191 | MODULE_DEVICE_TABLE(usb, option_ids); | 201 | MODULE_DEVICE_TABLE(usb, option_ids); |
@@ -247,10 +257,10 @@ static int debug; | |||
247 | struct option_port_private { | 257 | struct option_port_private { |
248 | /* Input endpoints and buffer for this port */ | 258 | /* Input endpoints and buffer for this port */ |
249 | struct urb *in_urbs[N_IN_URB]; | 259 | struct urb *in_urbs[N_IN_URB]; |
250 | char in_buffer[N_IN_URB][IN_BUFLEN]; | 260 | u8 *in_buffer[N_IN_URB]; |
251 | /* Output endpoints and buffer for this port */ | 261 | /* Output endpoints and buffer for this port */ |
252 | struct urb *out_urbs[N_OUT_URB]; | 262 | struct urb *out_urbs[N_OUT_URB]; |
253 | char out_buffer[N_OUT_URB][OUT_BUFLEN]; | 263 | u8 *out_buffer[N_OUT_URB]; |
254 | unsigned long out_busy; /* Bit vector of URBs in use */ | 264 | unsigned long out_busy; /* Bit vector of URBs in use */ |
255 | 265 | ||
256 | /* Settings for the port */ | 266 | /* Settings for the port */ |
@@ -737,9 +747,10 @@ static int option_send_setup(struct usb_serial_port *port) | |||
737 | 747 | ||
738 | static int option_startup(struct usb_serial *serial) | 748 | static int option_startup(struct usb_serial *serial) |
739 | { | 749 | { |
740 | int i, err; | 750 | int i, j, err; |
741 | struct usb_serial_port *port; | 751 | struct usb_serial_port *port; |
742 | struct option_port_private *portdata; | 752 | struct option_port_private *portdata; |
753 | u8 *buffer; | ||
743 | 754 | ||
744 | dbg("%s", __FUNCTION__); | 755 | dbg("%s", __FUNCTION__); |
745 | 756 | ||
@@ -753,6 +764,20 @@ static int option_startup(struct usb_serial *serial) | |||
753 | return (1); | 764 | return (1); |
754 | } | 765 | } |
755 | 766 | ||
767 | for (j = 0; j < N_IN_URB; j++) { | ||
768 | buffer = (u8 *)__get_free_page(GFP_KERNEL); | ||
769 | if (!buffer) | ||
770 | goto bail_out_error; | ||
771 | portdata->in_buffer[j] = buffer; | ||
772 | } | ||
773 | |||
774 | for (j = 0; j < N_OUT_URB; j++) { | ||
775 | buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL); | ||
776 | if (!buffer) | ||
777 | goto bail_out_error2; | ||
778 | portdata->out_buffer[j] = buffer; | ||
779 | } | ||
780 | |||
756 | usb_set_serial_port_data(port, portdata); | 781 | usb_set_serial_port_data(port, portdata); |
757 | 782 | ||
758 | if (! port->interrupt_in_urb) | 783 | if (! port->interrupt_in_urb) |
@@ -766,6 +791,16 @@ static int option_startup(struct usb_serial *serial) | |||
766 | option_setup_urbs(serial); | 791 | option_setup_urbs(serial); |
767 | 792 | ||
768 | return (0); | 793 | return (0); |
794 | |||
795 | bail_out_error2: | ||
796 | for (j = 0; j < N_OUT_URB; j++) | ||
797 | kfree(portdata->out_buffer[j]); | ||
798 | bail_out_error: | ||
799 | for (j = 0; j < N_IN_URB; j++) | ||
800 | if (portdata->in_buffer[j]) | ||
801 | free_page((unsigned long)portdata->in_buffer[j]); | ||
802 | kfree(portdata); | ||
803 | return 1; | ||
769 | } | 804 | } |
770 | 805 | ||
771 | static void option_shutdown(struct usb_serial *serial) | 806 | static void option_shutdown(struct usb_serial *serial) |
@@ -794,12 +829,14 @@ static void option_shutdown(struct usb_serial *serial) | |||
794 | for (j = 0; j < N_IN_URB; j++) { | 829 | for (j = 0; j < N_IN_URB; j++) { |
795 | if (portdata->in_urbs[j]) { | 830 | if (portdata->in_urbs[j]) { |
796 | usb_free_urb(portdata->in_urbs[j]); | 831 | usb_free_urb(portdata->in_urbs[j]); |
832 | free_page((unsigned long)portdata->in_buffer[j]); | ||
797 | portdata->in_urbs[j] = NULL; | 833 | portdata->in_urbs[j] = NULL; |
798 | } | 834 | } |
799 | } | 835 | } |
800 | for (j = 0; j < N_OUT_URB; j++) { | 836 | for (j = 0; j < N_OUT_URB; j++) { |
801 | if (portdata->out_urbs[j]) { | 837 | if (portdata->out_urbs[j]) { |
802 | usb_free_urb(portdata->out_urbs[j]); | 838 | usb_free_urb(portdata->out_urbs[j]); |
839 | kfree(portdata->out_buffer[j]); | ||
803 | portdata->out_urbs[j] = NULL; | 840 | portdata->out_urbs[j] = NULL; |
804 | } | 841 | } |
805 | } | 842 | } |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 4c925e3e8a63..e3d44ae8d448 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -178,7 +178,6 @@ static struct usb_device_id id_table [] = { | |||
178 | 178 | ||
179 | { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */ | 179 | { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */ |
180 | { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */ | 180 | { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */ |
181 | { USB_DEVICE(0x05C6, 0x6613), .driver_info = DEVICE_1_PORT }, /* Onda H600/ZTE MF330 */ | ||
182 | 181 | ||
183 | { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER}, | 182 | { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER}, |
184 | { } | 183 | { } |
diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c index a41ce21c0697..958f5b17847c 100644 --- a/drivers/usb/storage/protocol.c +++ b/drivers/usb/storage/protocol.c | |||
@@ -150,13 +150,14 @@ void usb_stor_transparent_scsi_command(struct scsi_cmnd *srb, | |||
150 | 150 | ||
151 | /* Copy a buffer of length buflen to/from the srb's transfer buffer. | 151 | /* Copy a buffer of length buflen to/from the srb's transfer buffer. |
152 | * Update the **sgptr and *offset variables so that the next copy will | 152 | * Update the **sgptr and *offset variables so that the next copy will |
153 | * pick up from where this one left off. */ | 153 | * pick up from where this one left off. |
154 | 154 | */ | |
155 | unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | 155 | unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, |
156 | unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **sgptr, | 156 | unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **sgptr, |
157 | unsigned int *offset, enum xfer_buf_dir dir) | 157 | unsigned int *offset, enum xfer_buf_dir dir) |
158 | { | 158 | { |
159 | unsigned int cnt; | 159 | unsigned int cnt; |
160 | struct scatterlist *sg = *sgptr; | ||
160 | 161 | ||
161 | /* We have to go through the list one entry | 162 | /* We have to go through the list one entry |
162 | * at a time. Each s-g entry contains some number of pages, and | 163 | * at a time. Each s-g entry contains some number of pages, and |
@@ -164,22 +165,23 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | |||
164 | * in kernel-addressable memory then kmap() will return its address. | 165 | * in kernel-addressable memory then kmap() will return its address. |
165 | * If the page is not directly accessible -- such as a user buffer | 166 | * If the page is not directly accessible -- such as a user buffer |
166 | * located in high memory -- then kmap() will map it to a temporary | 167 | * located in high memory -- then kmap() will map it to a temporary |
167 | * position in the kernel's virtual address space. */ | 168 | * position in the kernel's virtual address space. |
168 | struct scatterlist *sg = *sgptr; | 169 | */ |
169 | 170 | ||
170 | if (!sg) | 171 | if (!sg) |
171 | sg = scsi_sglist(srb); | 172 | sg = scsi_sglist(srb); |
173 | buflen = min(buflen, scsi_bufflen(srb)); | ||
172 | 174 | ||
173 | /* This loop handles a single s-g list entry, which may | 175 | /* This loop handles a single s-g list entry, which may |
174 | * include multiple pages. Find the initial page structure | 176 | * include multiple pages. Find the initial page structure |
175 | * and the starting offset within the page, and update | 177 | * and the starting offset within the page, and update |
176 | * the *offset and **sgptr values for the next loop. */ | 178 | * the *offset and **sgptr values for the next loop. |
179 | */ | ||
177 | cnt = 0; | 180 | cnt = 0; |
178 | while (cnt < buflen) { | 181 | while (cnt < buflen && sg) { |
179 | struct page *page = sg_page(sg) + | 182 | struct page *page = sg_page(sg) + |
180 | ((sg->offset + *offset) >> PAGE_SHIFT); | 183 | ((sg->offset + *offset) >> PAGE_SHIFT); |
181 | unsigned int poff = | 184 | unsigned int poff = (sg->offset + *offset) & (PAGE_SIZE-1); |
182 | (sg->offset + *offset) & (PAGE_SIZE-1); | ||
183 | unsigned int sglen = sg->length - *offset; | 185 | unsigned int sglen = sg->length - *offset; |
184 | 186 | ||
185 | if (sglen > buflen - cnt) { | 187 | if (sglen > buflen - cnt) { |
@@ -222,14 +224,15 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | |||
222 | } | 224 | } |
223 | 225 | ||
224 | /* Store the contents of buffer into srb's transfer buffer and set the | 226 | /* Store the contents of buffer into srb's transfer buffer and set the |
225 | * SCSI residue. */ | 227 | * SCSI residue. |
228 | */ | ||
226 | void usb_stor_set_xfer_buf(unsigned char *buffer, | 229 | void usb_stor_set_xfer_buf(unsigned char *buffer, |
227 | unsigned int buflen, struct scsi_cmnd *srb) | 230 | unsigned int buflen, struct scsi_cmnd *srb) |
228 | { | 231 | { |
229 | unsigned int offset = 0; | 232 | unsigned int offset = 0; |
230 | struct scatterlist *sg = NULL; | 233 | struct scatterlist *sg = NULL; |
231 | 234 | ||
232 | usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset, | 235 | buflen = usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset, |
233 | TO_XFER_BUF); | 236 | TO_XFER_BUF); |
234 | if (buflen < scsi_bufflen(srb)) | 237 | if (buflen < scsi_bufflen(srb)) |
235 | scsi_set_resid(srb, scsi_bufflen(srb) - buflen); | 238 | scsi_set_resid(srb, scsi_bufflen(srb) - buflen); |
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index d9f4912f873d..5780ed15f1ad 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
@@ -891,17 +891,6 @@ int usb_stor_Bulk_max_lun(struct us_data *us) | |||
891 | if (result > 0) | 891 | if (result > 0) |
892 | return us->iobuf[0]; | 892 | return us->iobuf[0]; |
893 | 893 | ||
894 | /* | ||
895 | * Some devices (i.e. Iomega Zip100) need this -- apparently | ||
896 | * the bulk pipes get STALLed when the GetMaxLUN request is | ||
897 | * processed. This is, in theory, harmless to all other devices | ||
898 | * (regardless of if they stall or not). | ||
899 | */ | ||
900 | if (result == -EPIPE) { | ||
901 | usb_stor_clear_halt(us, us->recv_bulk_pipe); | ||
902 | usb_stor_clear_halt(us, us->send_bulk_pipe); | ||
903 | } | ||
904 | |||
905 | /* | 894 | /* |
906 | * Some devices don't like GetMaxLUN. They may STALL the control | 895 | * Some devices don't like GetMaxLUN. They may STALL the control |
907 | * pipe, they may return a zero-length result, they may do nothing at | 896 | * pipe, they may return a zero-length result, they may do nothing at |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index fe12737e0e2b..99679a8cfa02 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -357,7 +357,7 @@ UNUSUAL_DEV( 0x04b0, 0x040f, 0x0100, 0x0200, | |||
357 | US_FL_FIX_CAPACITY), | 357 | US_FL_FIX_CAPACITY), |
358 | 358 | ||
359 | /* Reported by Emil Larsson <emil@swip.net> */ | 359 | /* Reported by Emil Larsson <emil@swip.net> */ |
360 | UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0101, | 360 | UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0110, |
361 | "NIKON", | 361 | "NIKON", |
362 | "NIKON DSC D80", | 362 | "NIKON DSC D80", |
363 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 363 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
@@ -759,6 +759,18 @@ UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, | |||
759 | "Digital Camera EX-20 DSC", | 759 | "Digital Camera EX-20 DSC", |
760 | US_SC_8070, US_PR_DEVICE, NULL, 0 ), | 760 | US_SC_8070, US_PR_DEVICE, NULL, 0 ), |
761 | 761 | ||
762 | /* Reported by Andre Welter <a.r.welter@gmx.de> | ||
763 | * This antique device predates the release of the Bulk-only Transport | ||
764 | * spec, and if it gets a Get-Max-LUN then it requires the host to do a | ||
765 | * Clear-Halt on the bulk endpoints. The SINGLE_LUN flag will prevent | ||
766 | * us from sending the request. | ||
767 | */ | ||
768 | UNUSUAL_DEV( 0x059b, 0x0001, 0x0100, 0x0100, | ||
769 | "Iomega", | ||
770 | "ZIP 100", | ||
771 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
772 | US_FL_SINGLE_LUN ), | ||
773 | |||
762 | /* Reported by <Hendryk.Pfeiffer@gmx.de> */ | 774 | /* Reported by <Hendryk.Pfeiffer@gmx.de> */ |
763 | UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000, | 775 | UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000, |
764 | "LaCie", | 776 | "LaCie", |
@@ -1412,6 +1424,17 @@ UNUSUAL_DEV( 0x0ed1, 0x7636, 0x0103, 0x0103, | |||
1412 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1424 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1413 | US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64), | 1425 | US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64), |
1414 | 1426 | ||
1427 | /* Patch by Leonid Petrov mail at lpetrov.net | ||
1428 | * Reported by Robert Spitzenpfeil <robert@spitzenpfeil.org> | ||
1429 | * http://www.qbik.ch/usb/devices/showdev.php?id=1705 | ||
1430 | * Updated to 103 device by MJ Ray mjr at phonecoop.coop | ||
1431 | */ | ||
1432 | UNUSUAL_DEV( 0x0f19, 0x0103, 0x0100, 0x0100, | ||
1433 | "Oracom Co., Ltd", | ||
1434 | "ORC-200M", | ||
1435 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1436 | US_FL_IGNORE_RESIDUE ), | ||
1437 | |||
1415 | /* David Kuehling <dvdkhlng@gmx.de>: | 1438 | /* David Kuehling <dvdkhlng@gmx.de>: |
1416 | * for MP3-Player AVOX WSX-300ER (bought in Japan). Reports lots of SCSI | 1439 | * for MP3-Player AVOX WSX-300ER (bought in Japan). Reports lots of SCSI |
1417 | * errors when trying to write. | 1440 | * errors when trying to write. |
@@ -1477,6 +1500,15 @@ UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110, | |||
1477 | US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, | 1500 | US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, |
1478 | 0 ), | 1501 | 0 ), |
1479 | 1502 | ||
1503 | /* Reported by Fabio Venturi <f.venturi@tdnet.it> | ||
1504 | * The device reports a vendor-specific bDeviceClass. | ||
1505 | */ | ||
1506 | UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100, | ||
1507 | "Actions Semiconductor", | ||
1508 | "Mtp device", | ||
1509 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1510 | 0), | ||
1511 | |||
1480 | /* Reported by Kevin Lloyd <linux@sierrawireless.com> | 1512 | /* Reported by Kevin Lloyd <linux@sierrawireless.com> |
1481 | * Entry is needed for the initializer function override, | 1513 | * Entry is needed for the initializer function override, |
1482 | * which instructs the device to load as a modem | 1514 | * which instructs the device to load as a modem |
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index d775eb6590b6..62f9c6e387cc 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c | |||
@@ -1913,61 +1913,6 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma) | |||
1913 | par->mmaped = 1; | 1913 | par->mmaped = 1; |
1914 | return 0; | 1914 | return 0; |
1915 | } | 1915 | } |
1916 | |||
1917 | static struct { | ||
1918 | u32 yoffset; | ||
1919 | u8 r[2][256]; | ||
1920 | u8 g[2][256]; | ||
1921 | u8 b[2][256]; | ||
1922 | } atyfb_save; | ||
1923 | |||
1924 | static void atyfb_save_palette(struct atyfb_par *par, int enter) | ||
1925 | { | ||
1926 | int i, tmp; | ||
1927 | |||
1928 | for (i = 0; i < 256; i++) { | ||
1929 | tmp = aty_ld_8(DAC_CNTL, par) & 0xfc; | ||
1930 | if (M64_HAS(EXTRA_BRIGHT)) | ||
1931 | tmp |= 0x2; | ||
1932 | aty_st_8(DAC_CNTL, tmp, par); | ||
1933 | aty_st_8(DAC_MASK, 0xff, par); | ||
1934 | |||
1935 | aty_st_8(DAC_R_INDEX, i, par); | ||
1936 | atyfb_save.r[enter][i] = aty_ld_8(DAC_DATA, par); | ||
1937 | atyfb_save.g[enter][i] = aty_ld_8(DAC_DATA, par); | ||
1938 | atyfb_save.b[enter][i] = aty_ld_8(DAC_DATA, par); | ||
1939 | aty_st_8(DAC_W_INDEX, i, par); | ||
1940 | aty_st_8(DAC_DATA, atyfb_save.r[1 - enter][i], par); | ||
1941 | aty_st_8(DAC_DATA, atyfb_save.g[1 - enter][i], par); | ||
1942 | aty_st_8(DAC_DATA, atyfb_save.b[1 - enter][i], par); | ||
1943 | } | ||
1944 | } | ||
1945 | |||
1946 | static void atyfb_palette(int enter) | ||
1947 | { | ||
1948 | struct atyfb_par *par; | ||
1949 | struct fb_info *info; | ||
1950 | int i; | ||
1951 | |||
1952 | for (i = 0; i < FB_MAX; i++) { | ||
1953 | info = registered_fb[i]; | ||
1954 | if (info && info->fbops == &atyfb_ops) { | ||
1955 | par = (struct atyfb_par *) info->par; | ||
1956 | |||
1957 | atyfb_save_palette(par, enter); | ||
1958 | if (enter) { | ||
1959 | atyfb_save.yoffset = info->var.yoffset; | ||
1960 | info->var.yoffset = 0; | ||
1961 | set_off_pitch(par, info); | ||
1962 | } else { | ||
1963 | info->var.yoffset = atyfb_save.yoffset; | ||
1964 | set_off_pitch(par, info); | ||
1965 | } | ||
1966 | aty_st_le32(CRTC_OFF_PITCH, par->crtc.off_pitch, par); | ||
1967 | break; | ||
1968 | } | ||
1969 | } | ||
1970 | } | ||
1971 | #endif /* __sparc__ */ | 1916 | #endif /* __sparc__ */ |
1972 | 1917 | ||
1973 | 1918 | ||
@@ -2670,10 +2615,6 @@ static int __devinit aty_init(struct fb_info *info) | |||
2670 | goto aty_init_exit; | 2615 | goto aty_init_exit; |
2671 | } | 2616 | } |
2672 | 2617 | ||
2673 | #ifdef __sparc__ | ||
2674 | atyfb_save_palette(par, 0); | ||
2675 | #endif | ||
2676 | |||
2677 | #ifdef CONFIG_FB_ATY_CT | 2618 | #ifdef CONFIG_FB_ATY_CT |
2678 | if (!noaccel && M64_HAS(INTEGRATED)) | 2619 | if (!noaccel && M64_HAS(INTEGRATED)) |
2679 | aty_init_cursor(info); | 2620 | aty_init_cursor(info); |
@@ -2900,8 +2841,6 @@ static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
2900 | 2841 | ||
2901 | #ifdef __sparc__ | 2842 | #ifdef __sparc__ |
2902 | 2843 | ||
2903 | extern void (*prom_palette) (int); | ||
2904 | |||
2905 | static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, | 2844 | static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, |
2906 | struct fb_info *info, unsigned long addr) | 2845 | struct fb_info *info, unsigned long addr) |
2907 | { | 2846 | { |
@@ -3536,9 +3475,6 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi | |||
3536 | goto err_release_io; | 3475 | goto err_release_io; |
3537 | 3476 | ||
3538 | #ifdef __sparc__ | 3477 | #ifdef __sparc__ |
3539 | if (!prom_palette) | ||
3540 | prom_palette = atyfb_palette; | ||
3541 | |||
3542 | /* | 3478 | /* |
3543 | * Add /dev/fb mmap values. | 3479 | * Add /dev/fb mmap values. |
3544 | */ | 3480 | */ |
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c index 41f6dbf61be7..fdc9f43ec30a 100644 --- a/drivers/video/cg14.c +++ b/drivers/video/cg14.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/fb.h> | 17 | #include <linux/fb.h> |
18 | #include <linux/mm.h> | 18 | #include <linux/mm.h> |
19 | #include <linux/uaccess.h> | ||
19 | 20 | ||
20 | #include <asm/io.h> | 21 | #include <asm/io.h> |
21 | #include <asm/prom.h> | 22 | #include <asm/prom.h> |
diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c index 6796ba62c3c6..777389c40988 100644 --- a/drivers/video/chipsfb.c +++ b/drivers/video/chipsfb.c | |||
@@ -459,7 +459,7 @@ static int chipsfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
459 | 459 | ||
460 | if (state.event == pdev->dev.power.power_state.event) | 460 | if (state.event == pdev->dev.power.power_state.event) |
461 | return 0; | 461 | return 0; |
462 | if (state.event != PM_EVENT_SUSPEND) | 462 | if (!(state.event & PM_EVENT_SLEEP)) |
463 | goto done; | 463 | goto done; |
464 | 464 | ||
465 | acquire_console_sem(); | 465 | acquire_console_sem(); |
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c index 74517b1b26a6..596652d2831f 100644 --- a/drivers/video/nvidia/nvidia.c +++ b/drivers/video/nvidia/nvidia.c | |||
@@ -1066,7 +1066,7 @@ static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg) | |||
1066 | acquire_console_sem(); | 1066 | acquire_console_sem(); |
1067 | par->pm_state = mesg.event; | 1067 | par->pm_state = mesg.event; |
1068 | 1068 | ||
1069 | if (mesg.event == PM_EVENT_SUSPEND) { | 1069 | if (mesg.event & PM_EVENT_SLEEP) { |
1070 | fb_set_suspend(info, 1); | 1070 | fb_set_suspend(info, 1); |
1071 | nvidiafb_blank(FB_BLANK_POWERDOWN, info); | 1071 | nvidiafb_blank(FB_BLANK_POWERDOWN, info); |
1072 | nvidia_write_regs(par, &par->SavedReg); | 1072 | nvidia_write_regs(par, &par->SavedReg); |
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index 10f912df2dad..97facb121c73 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c | |||
@@ -1046,7 +1046,7 @@ pxafb_freq_policy(struct notifier_block *nb, unsigned long val, void *data) | |||
1046 | switch (val) { | 1046 | switch (val) { |
1047 | case CPUFREQ_ADJUST: | 1047 | case CPUFREQ_ADJUST: |
1048 | case CPUFREQ_INCOMPATIBLE: | 1048 | case CPUFREQ_INCOMPATIBLE: |
1049 | printk(KERN_DEBUG "min dma period: %d ps, " | 1049 | pr_debug("min dma period: %d ps, " |
1050 | "new clock %d kHz\n", pxafb_display_dma_period(var), | 1050 | "new clock %d kHz\n", pxafb_display_dma_period(var), |
1051 | policy->max); | 1051 | policy->max); |
1052 | // TODO: fill in min/max values | 1052 | // TODO: fill in min/max values |
@@ -1361,7 +1361,7 @@ static int __init pxafb_parse_options(struct device *dev, char *options) | |||
1361 | } | 1361 | } |
1362 | #endif | 1362 | #endif |
1363 | 1363 | ||
1364 | int __init pxafb_probe(struct platform_device *dev) | 1364 | static int __init pxafb_probe(struct platform_device *dev) |
1365 | { | 1365 | { |
1366 | struct pxafb_info *fbi; | 1366 | struct pxafb_info *fbi; |
1367 | struct pxafb_mach_info *inf; | 1367 | struct pxafb_mach_info *inf; |
@@ -1486,7 +1486,7 @@ static struct platform_driver pxafb_driver = { | |||
1486 | }; | 1486 | }; |
1487 | 1487 | ||
1488 | #ifndef MODULE | 1488 | #ifndef MODULE |
1489 | int __devinit pxafb_setup(char *options) | 1489 | static int __devinit pxafb_setup(char *options) |
1490 | { | 1490 | { |
1491 | # ifdef CONFIG_FB_PXA_PARAMETERS | 1491 | # ifdef CONFIG_FB_PXA_PARAMETERS |
1492 | if (options) | 1492 | if (options) |
@@ -1501,7 +1501,7 @@ MODULE_PARM_DESC(options, "LCD parameters (see Documentation/fb/pxafb.txt)"); | |||
1501 | # endif | 1501 | # endif |
1502 | #endif | 1502 | #endif |
1503 | 1503 | ||
1504 | int __devinit pxafb_init(void) | 1504 | static int __devinit pxafb_init(void) |
1505 | { | 1505 | { |
1506 | #ifndef MODULE | 1506 | #ifndef MODULE |
1507 | char *option = NULL; | 1507 | char *option = NULL; |
diff --git a/drivers/video/sbuslib.c b/drivers/video/sbuslib.c index 963a454b7074..4deaac05b938 100644 --- a/drivers/video/sbuslib.c +++ b/drivers/video/sbuslib.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/string.h> | 9 | #include <linux/string.h> |
10 | #include <linux/fb.h> | 10 | #include <linux/fb.h> |
11 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
12 | #include <linux/uaccess.h> | ||
12 | 13 | ||
13 | #include <asm/oplib.h> | 14 | #include <asm/oplib.h> |
14 | #include <asm/fbio.h> | 15 | #include <asm/fbio.h> |
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c index be27b9c1ed72..93361656316c 100644 --- a/drivers/video/uvesafb.c +++ b/drivers/video/uvesafb.c | |||
@@ -44,7 +44,7 @@ static struct fb_fix_screeninfo uvesafb_fix __devinitdata = { | |||
44 | 44 | ||
45 | static int mtrr __devinitdata = 3; /* enable mtrr by default */ | 45 | static int mtrr __devinitdata = 3; /* enable mtrr by default */ |
46 | static int blank = 1; /* enable blanking by default */ | 46 | static int blank = 1; /* enable blanking by default */ |
47 | static int ypan __devinitdata = 1; /* 0: scroll, 1: ypan, 2: ywrap */ | 47 | static int ypan = 1; /* 0: scroll, 1: ypan, 2: ywrap */ |
48 | static int pmi_setpal __devinitdata = 1; /* use PMI for palette changes */ | 48 | static int pmi_setpal __devinitdata = 1; /* use PMI for palette changes */ |
49 | static int nocrtc __devinitdata; /* ignore CRTC settings */ | 49 | static int nocrtc __devinitdata; /* ignore CRTC settings */ |
50 | static int noedid __devinitdata; /* don't try DDC transfers */ | 50 | static int noedid __devinitdata; /* don't try DDC transfers */ |
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index afcdc69e37d6..254d115cafab 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -402,6 +402,18 @@ config IT8712F_WDT | |||
402 | To compile this driver as a module, choose M here: the | 402 | To compile this driver as a module, choose M here: the |
403 | module will be called it8712f_wdt. | 403 | module will be called it8712f_wdt. |
404 | 404 | ||
405 | config HP_WATCHDOG | ||
406 | tristate "HP Proliant iLO 2 Hardware Watchdog Timer" | ||
407 | depends on X86 | ||
408 | help | ||
409 | A software monitoring watchdog and NMI sourcing driver. This driver | ||
410 | will detect lockups and provide stack trace. Also, when an NMI | ||
411 | occurs this driver will make the necessary BIOS calls to log | ||
412 | the cause of the NMI. This is a driver that will only load on a | ||
413 | HP ProLiant system with a minimum of iLO2 support. | ||
414 | To compile this driver as a module, choose M here: the | ||
415 | module will be called hpwdt. | ||
416 | |||
405 | config SC1200_WDT | 417 | config SC1200_WDT |
406 | tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" | 418 | tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" |
407 | depends on X86 | 419 | depends on X86 |
@@ -633,6 +645,19 @@ config WDT_RM9K_GPI | |||
633 | To compile this driver as a module, choose M here: the | 645 | To compile this driver as a module, choose M here: the |
634 | module will be called rm9k_wdt. | 646 | module will be called rm9k_wdt. |
635 | 647 | ||
648 | config SIBYTE_WDOG | ||
649 | tristate "Sibyte SoC hardware watchdog" | ||
650 | depends on CPU_SB1 | ||
651 | help | ||
652 | Watchdog driver for the built in watchdog hardware in Sibyte | ||
653 | SoC processors. There are apparently two watchdog timers | ||
654 | on such processors; this driver supports only the first one, | ||
655 | because currently Linux only supports exporting one watchdog | ||
656 | to userspace. | ||
657 | |||
658 | To compile this driver as a loadable module, choose M here. | ||
659 | The module will be called sb_wdog. | ||
660 | |||
636 | config AR7_WDT | 661 | config AR7_WDT |
637 | tristate "TI AR7 Watchdog Timer" | 662 | tristate "TI AR7 Watchdog Timer" |
638 | depends on AR7 | 663 | depends on AR7 |
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index ebc21146d40c..f3fb170fe5c6 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile | |||
@@ -67,6 +67,7 @@ obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o | |||
67 | obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o | 67 | obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o |
68 | obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o iTCO_vendor_support.o | 68 | obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o iTCO_vendor_support.o |
69 | obj-$(CONFIG_IT8712F_WDT) += it8712f_wdt.o | 69 | obj-$(CONFIG_IT8712F_WDT) += it8712f_wdt.o |
70 | obj-$(CONFIG_HP_WATCHDOG) += hpwdt.o | ||
70 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o | 71 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o |
71 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o | 72 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o |
72 | obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o | 73 | obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o |
@@ -92,6 +93,7 @@ obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o | |||
92 | obj-$(CONFIG_INDYDOG) += indydog.o | 93 | obj-$(CONFIG_INDYDOG) += indydog.o |
93 | obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o | 94 | obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o |
94 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o | 95 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o |
96 | obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o | ||
95 | obj-$(CONFIG_AR7_WDT) += ar7_wdt.o | 97 | obj-$(CONFIG_AR7_WDT) += ar7_wdt.o |
96 | obj-$(CONFIG_TXX9_WDT) += txx9wdt.o | 98 | obj-$(CONFIG_TXX9_WDT) += txx9wdt.o |
97 | 99 | ||
diff --git a/drivers/watchdog/bfin_wdt.c b/drivers/watchdog/bfin_wdt.c index 472be10f0686..1237113dc14a 100644 --- a/drivers/watchdog/bfin_wdt.c +++ b/drivers/watchdog/bfin_wdt.c | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #define stamp(fmt, args...) pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args) | 30 | #define stamp(fmt, args...) pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args) |
31 | #define stampit() stamp("here i am") | 31 | #define stampit() stamp("here i am") |
32 | #define pr_init(fmt, args...) ({ static const __initdata char __fmt[] = fmt; printk(__fmt, ## args); }) | ||
32 | 33 | ||
33 | #define WATCHDOG_NAME "bfin-wdt" | 34 | #define WATCHDOG_NAME "bfin-wdt" |
34 | #define PFX WATCHDOG_NAME ": " | 35 | #define PFX WATCHDOG_NAME ": " |
@@ -445,19 +446,19 @@ static int __init bfin_wdt_init(void) | |||
445 | 446 | ||
446 | ret = register_reboot_notifier(&bfin_wdt_notifier); | 447 | ret = register_reboot_notifier(&bfin_wdt_notifier); |
447 | if (ret) { | 448 | if (ret) { |
448 | printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret); | 449 | pr_init(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret); |
449 | return ret; | 450 | return ret; |
450 | } | 451 | } |
451 | 452 | ||
452 | ret = misc_register(&bfin_wdt_miscdev); | 453 | ret = misc_register(&bfin_wdt_miscdev); |
453 | if (ret) { | 454 | if (ret) { |
454 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | 455 | pr_init(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", |
455 | WATCHDOG_MINOR, ret); | 456 | WATCHDOG_MINOR, ret); |
456 | unregister_reboot_notifier(&bfin_wdt_notifier); | 457 | unregister_reboot_notifier(&bfin_wdt_notifier); |
457 | return ret; | 458 | return ret; |
458 | } | 459 | } |
459 | 460 | ||
460 | printk(KERN_INFO PFX "initialized: timeout=%d sec (nowayout=%d)\n", | 461 | pr_init(KERN_INFO PFX "initialized: timeout=%d sec (nowayout=%d)\n", |
461 | timeout, nowayout); | 462 | timeout, nowayout); |
462 | 463 | ||
463 | return 0; | 464 | return 0; |
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c new file mode 100644 index 000000000000..a2e174b09fe7 --- /dev/null +++ b/drivers/watchdog/hpwdt.c | |||
@@ -0,0 +1,926 @@ | |||
1 | /* | ||
2 | * HP WatchDog Driver | ||
3 | * based on | ||
4 | * | ||
5 | * SoftDog 0.05: A Software Watchdog Device | ||
6 | * | ||
7 | * (c) Copyright 2007 Hewlett-Packard Development Company, L.P. | ||
8 | * Thomas Mingarelli <thomas.mingarelli@hp.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * version 2 as published by the Free Software Foundation | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/device.h> | ||
17 | #include <linux/fs.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/io.h> | ||
21 | #include <linux/irq.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/miscdevice.h> | ||
24 | #include <linux/mm.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/kdebug.h> | ||
27 | #include <linux/moduleparam.h> | ||
28 | #include <linux/notifier.h> | ||
29 | #include <linux/pci.h> | ||
30 | #include <linux/pci_ids.h> | ||
31 | #include <linux/reboot.h> | ||
32 | #include <linux/sched.h> | ||
33 | #include <linux/timer.h> | ||
34 | #include <linux/types.h> | ||
35 | #include <linux/uaccess.h> | ||
36 | #include <linux/watchdog.h> | ||
37 | #include <linux/dmi.h> | ||
38 | #include <linux/efi.h> | ||
39 | #include <linux/string.h> | ||
40 | #include <linux/bootmem.h> | ||
41 | #include <linux/slab.h> | ||
42 | #include <asm/dmi.h> | ||
43 | #include <asm/desc.h> | ||
44 | #include <asm/kdebug.h> | ||
45 | |||
46 | #define PCI_BIOS32_SD_VALUE 0x5F32335F /* "_32_" */ | ||
47 | #define CRU_BIOS_SIGNATURE_VALUE 0x55524324 | ||
48 | #define PCI_BIOS32_PARAGRAPH_LEN 16 | ||
49 | #define PCI_ROM_BASE1 0x000F0000 | ||
50 | #define ROM_SIZE 0x10000 | ||
51 | |||
52 | struct bios32_service_dir { | ||
53 | u32 signature; | ||
54 | u32 entry_point; | ||
55 | u8 revision; | ||
56 | u8 length; | ||
57 | u8 checksum; | ||
58 | u8 reserved[5]; | ||
59 | }; | ||
60 | |||
61 | /* | ||
62 | * smbios_entry_point - defines SMBIOS entry point structure | ||
63 | * | ||
64 | * anchor[4] - anchor string (_SM_) | ||
65 | * checksum - checksum of the entry point structure | ||
66 | * length - length of the entry point structure | ||
67 | * major_ver - major version (02h for revision 2.1) | ||
68 | * minor_ver - minor version (01h for revision 2.1) | ||
69 | * max_struct_size - size of the largest SMBIOS structure | ||
70 | * revision - entry point structure revision implemented | ||
71 | * formatted_area[5] - reserved | ||
72 | * intermediate_anchor[5] - intermediate anchor string (_DMI_) | ||
73 | * intermediate_checksum - intermediate checksum | ||
74 | * table_length - structure table length | ||
75 | * table_address - structure table address | ||
76 | * table_num_structs - number of SMBIOS structures present | ||
77 | * bcd_revision - BCD revision | ||
78 | */ | ||
79 | struct smbios_entry_point { | ||
80 | u8 anchor[4]; | ||
81 | u8 checksum; | ||
82 | u8 length; | ||
83 | u8 major_ver; | ||
84 | u8 minor_ver; | ||
85 | u16 max_struct_size; | ||
86 | u8 revision; | ||
87 | u8 formatted_area[5]; | ||
88 | u8 intermediate_anchor[5]; | ||
89 | u8 intermediate_checksum; | ||
90 | u16 table_length; | ||
91 | u64 table_address; | ||
92 | u16 table_num_structs; | ||
93 | u8 bcd_revision; | ||
94 | }; | ||
95 | |||
96 | /* type 212 */ | ||
97 | struct smbios_cru64_info { | ||
98 | u8 type; | ||
99 | u8 byte_length; | ||
100 | u16 handle; | ||
101 | u32 signature; | ||
102 | u64 physical_address; | ||
103 | u32 double_length; | ||
104 | u32 double_offset; | ||
105 | }; | ||
106 | #define SMBIOS_CRU64_INFORMATION 212 | ||
107 | |||
108 | struct cmn_registers { | ||
109 | union { | ||
110 | struct { | ||
111 | u8 ral; | ||
112 | u8 rah; | ||
113 | u16 rea2; | ||
114 | }; | ||
115 | u32 reax; | ||
116 | } u1; | ||
117 | union { | ||
118 | struct { | ||
119 | u8 rbl; | ||
120 | u8 rbh; | ||
121 | u8 reb2l; | ||
122 | u8 reb2h; | ||
123 | }; | ||
124 | u32 rebx; | ||
125 | } u2; | ||
126 | union { | ||
127 | struct { | ||
128 | u8 rcl; | ||
129 | u8 rch; | ||
130 | u16 rec2; | ||
131 | }; | ||
132 | u32 recx; | ||
133 | } u3; | ||
134 | union { | ||
135 | struct { | ||
136 | u8 rdl; | ||
137 | u8 rdh; | ||
138 | u16 red2; | ||
139 | }; | ||
140 | u32 redx; | ||
141 | } u4; | ||
142 | |||
143 | u32 resi; | ||
144 | u32 redi; | ||
145 | u16 rds; | ||
146 | u16 res; | ||
147 | u32 reflags; | ||
148 | } __attribute__((packed)); | ||
149 | |||
150 | #define DEFAULT_MARGIN 30 | ||
151 | static unsigned int soft_margin = DEFAULT_MARGIN; /* in seconds */ | ||
152 | static unsigned int reload; /* the computed soft_margin */ | ||
153 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
154 | static char expect_release; | ||
155 | static unsigned long hpwdt_is_open; | ||
156 | |||
157 | static void __iomem *pci_mem_addr; /* the PCI-memory address */ | ||
158 | static unsigned long __iomem *hpwdt_timer_reg; | ||
159 | static unsigned long __iomem *hpwdt_timer_con; | ||
160 | |||
161 | static DEFINE_SPINLOCK(rom_lock); | ||
162 | |||
163 | static void *cru_rom_addr; | ||
164 | |||
165 | static struct cmn_registers cmn_regs; | ||
166 | |||
167 | static struct pci_device_id hpwdt_devices[] = { | ||
168 | { | ||
169 | .vendor = PCI_VENDOR_ID_COMPAQ, | ||
170 | .device = 0xB203, | ||
171 | .subvendor = PCI_ANY_ID, | ||
172 | .subdevice = PCI_ANY_ID, | ||
173 | }, | ||
174 | {0}, /* terminate list */ | ||
175 | }; | ||
176 | MODULE_DEVICE_TABLE(pci, hpwdt_devices); | ||
177 | |||
178 | /* | ||
179 | * bios_checksum | ||
180 | */ | ||
181 | static int __devinit bios_checksum(const char __iomem *ptr, int len) | ||
182 | { | ||
183 | char sum = 0; | ||
184 | int i; | ||
185 | |||
186 | /* | ||
187 | * calculate checksum of size bytes. This should add up | ||
188 | * to zero if we have a valid header. | ||
189 | */ | ||
190 | for (i = 0; i < len; i++) | ||
191 | sum += ptr[i]; | ||
192 | |||
193 | return ((sum == 0) && (len > 0)); | ||
194 | } | ||
195 | |||
196 | #ifndef CONFIG_X86_64 | ||
197 | /* --32 Bit Bios------------------------------------------------------------ */ | ||
198 | |||
199 | #define HPWDT_ARCH 32 | ||
200 | |||
201 | asmlinkage void asminline_call(struct cmn_registers *pi86Regs, | ||
202 | unsigned long *pRomEntry) | ||
203 | { | ||
204 | asm("pushl %ebp \n\t" | ||
205 | "movl %esp, %ebp \n\t" | ||
206 | "pusha \n\t" | ||
207 | "pushf \n\t" | ||
208 | "push %es \n\t" | ||
209 | "push %ds \n\t" | ||
210 | "pop %es \n\t" | ||
211 | "movl 8(%ebp),%eax \n\t" | ||
212 | "movl 4(%eax),%ebx \n\t" | ||
213 | "movl 8(%eax),%ecx \n\t" | ||
214 | "movl 12(%eax),%edx \n\t" | ||
215 | "movl 16(%eax),%esi \n\t" | ||
216 | "movl 20(%eax),%edi \n\t" | ||
217 | "movl (%eax),%eax \n\t" | ||
218 | "push %cs \n\t" | ||
219 | "call *12(%ebp) \n\t" | ||
220 | "pushf \n\t" | ||
221 | "pushl %eax \n\t" | ||
222 | "movl 8(%ebp),%eax \n\t" | ||
223 | "movl %ebx,4(%eax) \n\t" | ||
224 | "movl %ecx,8(%eax) \n\t" | ||
225 | "movl %edx,12(%eax) \n\t" | ||
226 | "movl %esi,16(%eax) \n\t" | ||
227 | "movl %edi,20(%eax) \n\t" | ||
228 | "movw %ds,24(%eax) \n\t" | ||
229 | "movw %es,26(%eax) \n\t" | ||
230 | "popl %ebx \n\t" | ||
231 | "movl %ebx,(%eax) \n\t" | ||
232 | "popl %ebx \n\t" | ||
233 | "movl %ebx,28(%eax) \n\t" | ||
234 | "pop %es \n\t" | ||
235 | "popf \n\t" | ||
236 | "popa \n\t" | ||
237 | "leave \n\t" "ret"); | ||
238 | } | ||
239 | |||
240 | /* | ||
241 | * cru_detect | ||
242 | * | ||
243 | * Routine Description: | ||
244 | * This function uses the 32-bit BIOS Service Directory record to | ||
245 | * search for a $CRU record. | ||
246 | * | ||
247 | * Return Value: | ||
248 | * 0 : SUCCESS | ||
249 | * <0 : FAILURE | ||
250 | */ | ||
251 | static int __devinit cru_detect(unsigned long map_entry, | ||
252 | unsigned long map_offset) | ||
253 | { | ||
254 | void *bios32_map; | ||
255 | unsigned long *bios32_entrypoint; | ||
256 | unsigned long cru_physical_address; | ||
257 | unsigned long cru_length; | ||
258 | unsigned long physical_bios_base = 0; | ||
259 | unsigned long physical_bios_offset = 0; | ||
260 | int retval = -ENODEV; | ||
261 | |||
262 | bios32_map = ioremap(map_entry, (2 * PAGE_SIZE)); | ||
263 | |||
264 | if (bios32_map == NULL) | ||
265 | return -ENODEV; | ||
266 | |||
267 | bios32_entrypoint = bios32_map + map_offset; | ||
268 | |||
269 | cmn_regs.u1.reax = CRU_BIOS_SIGNATURE_VALUE; | ||
270 | |||
271 | asminline_call(&cmn_regs, bios32_entrypoint); | ||
272 | |||
273 | if (cmn_regs.u1.ral != 0) { | ||
274 | printk(KERN_WARNING | ||
275 | "hpwdt: Call succeeded but with an error: 0x%x\n", | ||
276 | cmn_regs.u1.ral); | ||
277 | } else { | ||
278 | physical_bios_base = cmn_regs.u2.rebx; | ||
279 | physical_bios_offset = cmn_regs.u4.redx; | ||
280 | cru_length = cmn_regs.u3.recx; | ||
281 | cru_physical_address = | ||
282 | physical_bios_base + physical_bios_offset; | ||
283 | |||
284 | /* If the values look OK, then map it in. */ | ||
285 | if ((physical_bios_base + physical_bios_offset)) { | ||
286 | cru_rom_addr = | ||
287 | ioremap(cru_physical_address, cru_length); | ||
288 | if (cru_rom_addr) | ||
289 | retval = 0; | ||
290 | } | ||
291 | |||
292 | printk(KERN_DEBUG "hpwdt: CRU Base Address: 0x%lx\n", | ||
293 | physical_bios_base); | ||
294 | printk(KERN_DEBUG "hpwdt: CRU Offset Address: 0x%lx\n", | ||
295 | physical_bios_offset); | ||
296 | printk(KERN_DEBUG "hpwdt: CRU Length: 0x%lx\n", | ||
297 | cru_length); | ||
298 | printk(KERN_DEBUG "hpwdt: CRU Mapped Address: 0x%x\n", | ||
299 | (unsigned int)&cru_rom_addr); | ||
300 | } | ||
301 | iounmap(bios32_map); | ||
302 | return retval; | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | * bios32_present | ||
307 | * | ||
308 | * Routine Description: | ||
309 | * This function finds the 32-bit BIOS Service Directory | ||
310 | * | ||
311 | * Return Value: | ||
312 | * 0 : SUCCESS | ||
313 | * <0 : FAILURE | ||
314 | */ | ||
315 | static int __devinit bios32_present(const char __iomem *p) | ||
316 | { | ||
317 | struct bios32_service_dir *bios_32_ptr; | ||
318 | int length; | ||
319 | unsigned long map_entry, map_offset; | ||
320 | |||
321 | bios_32_ptr = (struct bios32_service_dir *) p; | ||
322 | |||
323 | /* | ||
324 | * Search for signature by checking equal to the swizzled value | ||
325 | * instead of calling another routine to perform a strcmp. | ||
326 | */ | ||
327 | if (bios_32_ptr->signature == PCI_BIOS32_SD_VALUE) { | ||
328 | length = bios_32_ptr->length * PCI_BIOS32_PARAGRAPH_LEN; | ||
329 | if (bios_checksum(p, length)) { | ||
330 | /* | ||
331 | * According to the spec, we're looking for the | ||
332 | * first 4KB-aligned address below the entrypoint | ||
333 | * listed in the header. The Service Directory code | ||
334 | * is guaranteed to occupy no more than 2 4KB pages. | ||
335 | */ | ||
336 | map_entry = bios_32_ptr->entry_point & ~(PAGE_SIZE - 1); | ||
337 | map_offset = bios_32_ptr->entry_point - map_entry; | ||
338 | |||
339 | return cru_detect(map_entry, map_offset); | ||
340 | } | ||
341 | } | ||
342 | return -ENODEV; | ||
343 | } | ||
344 | |||
345 | static int __devinit detect_cru_service(void) | ||
346 | { | ||
347 | char __iomem *p, *q; | ||
348 | int rc = -1; | ||
349 | |||
350 | /* | ||
351 | * Search from 0x0f0000 through 0x0fffff, inclusive. | ||
352 | */ | ||
353 | p = ioremap(PCI_ROM_BASE1, ROM_SIZE); | ||
354 | if (p == NULL) | ||
355 | return -ENOMEM; | ||
356 | |||
357 | for (q = p; q < p + ROM_SIZE; q += 16) { | ||
358 | rc = bios32_present(q); | ||
359 | if (!rc) | ||
360 | break; | ||
361 | } | ||
362 | iounmap(p); | ||
363 | return rc; | ||
364 | } | ||
365 | |||
366 | #else | ||
367 | /* --64 Bit Bios------------------------------------------------------------ */ | ||
368 | |||
369 | #define HPWDT_ARCH 64 | ||
370 | |||
371 | asmlinkage void asminline_call(struct cmn_registers *pi86Regs, | ||
372 | unsigned long *pRomEntry) | ||
373 | { | ||
374 | asm("pushq %rbp \n\t" | ||
375 | "movq %rsp, %rbp \n\t" | ||
376 | "pushq %rax \n\t" | ||
377 | "pushq %rbx \n\t" | ||
378 | "pushq %rdx \n\t" | ||
379 | "pushq %r12 \n\t" | ||
380 | "pushq %r9 \n\t" | ||
381 | "movq %rsi, %r12 \n\t" | ||
382 | "movq %rdi, %r9 \n\t" | ||
383 | "movl 4(%r9),%ebx \n\t" | ||
384 | "movl 8(%r9),%ecx \n\t" | ||
385 | "movl 12(%r9),%edx \n\t" | ||
386 | "movl 16(%r9),%esi \n\t" | ||
387 | "movl 20(%r9),%edi \n\t" | ||
388 | "movl (%r9),%eax \n\t" | ||
389 | "call *%r12 \n\t" | ||
390 | "pushfq \n\t" | ||
391 | "popq %r12 \n\t" | ||
392 | "popfq \n\t" | ||
393 | "movl %eax, (%r9) \n\t" | ||
394 | "movl %ebx, 4(%r9) \n\t" | ||
395 | "movl %ecx, 8(%r9) \n\t" | ||
396 | "movl %edx, 12(%r9) \n\t" | ||
397 | "movl %esi, 16(%r9) \n\t" | ||
398 | "movl %edi, 20(%r9) \n\t" | ||
399 | "movq %r12, %rax \n\t" | ||
400 | "movl %eax, 28(%r9) \n\t" | ||
401 | "popq %r9 \n\t" | ||
402 | "popq %r12 \n\t" | ||
403 | "popq %rdx \n\t" | ||
404 | "popq %rbx \n\t" | ||
405 | "popq %rax \n\t" | ||
406 | "leave \n\t" "ret"); | ||
407 | } | ||
408 | |||
409 | /* | ||
410 | * dmi_find_cru | ||
411 | * | ||
412 | * Routine Description: | ||
413 | * This function checks wether or not a SMBIOS/DMI record is | ||
414 | * the 64bit CRU info or not | ||
415 | * | ||
416 | * Return Value: | ||
417 | * 0 : SUCCESS - if record found | ||
418 | * <0 : FAILURE - if record not found | ||
419 | */ | ||
420 | static void __devinit dmi_find_cru(const struct dmi_header *dm) | ||
421 | { | ||
422 | struct smbios_cru64_info *smbios_cru64_ptr; | ||
423 | unsigned long cru_physical_address; | ||
424 | |||
425 | if (dm->type == SMBIOS_CRU64_INFORMATION) { | ||
426 | smbios_cru64_ptr = (struct smbios_cru64_info *) dm; | ||
427 | if (smbios_cru64_ptr->signature == CRU_BIOS_SIGNATURE_VALUE) { | ||
428 | cru_physical_address = | ||
429 | smbios_cru64_ptr->physical_address + | ||
430 | smbios_cru64_ptr->double_offset; | ||
431 | cru_rom_addr = ioremap(cru_physical_address, | ||
432 | smbios_cru64_ptr->double_length); | ||
433 | } | ||
434 | } | ||
435 | } | ||
436 | |||
437 | /* | ||
438 | * dmi_table | ||
439 | * | ||
440 | * Routine Description: | ||
441 | * Decode the SMBIOS/DMI table and check if we have a 64bit CRU record | ||
442 | * or not. | ||
443 | * | ||
444 | * We have to be cautious here. We have seen BIOSes with DMI pointers | ||
445 | * pointing to completely the wrong place for example | ||
446 | */ | ||
447 | static void __devinit dmi_table(u8 *buf, int len, int num, | ||
448 | void (*decode)(const struct dmi_header *)) | ||
449 | { | ||
450 | u8 *data = buf; | ||
451 | int i = 0; | ||
452 | |||
453 | /* | ||
454 | * Stop when we see all the items the table claimed to have | ||
455 | * OR we run off the end of the table (also happens) | ||
456 | */ | ||
457 | while ((i < num) && (data - buf + sizeof(struct dmi_header)) <= len) { | ||
458 | const struct dmi_header *dm = (const struct dmi_header *)data; | ||
459 | |||
460 | /* | ||
461 | * We want to know the total length (formated area and strings) | ||
462 | * before decoding to make sure we won't run off the table in | ||
463 | * dmi_decode or dmi_string | ||
464 | */ | ||
465 | data += dm->length; | ||
466 | while ((data - buf < len - 1) && (data[0] || data[1])) | ||
467 | data++; | ||
468 | if (data - buf < len - 1) | ||
469 | decode(dm); | ||
470 | data += 2; | ||
471 | i++; | ||
472 | } | ||
473 | } | ||
474 | |||
475 | /* | ||
476 | * smbios_present | ||
477 | * | ||
478 | * Routine Description: | ||
479 | * This function parses the SMBIOS entry point table to retrieve | ||
480 | * the 64 bit CRU Service. | ||
481 | * | ||
482 | * Return Value: | ||
483 | * 0 : SUCCESS | ||
484 | * <0 : FAILURE | ||
485 | */ | ||
486 | static int __devinit smbios_present(const char __iomem *p) | ||
487 | { | ||
488 | struct smbios_entry_point *eps = | ||
489 | (struct smbios_entry_point *) p; | ||
490 | int length; | ||
491 | u8 *buf; | ||
492 | |||
493 | /* check if we have indeed the SMBIOS table entry point */ | ||
494 | if ((strncmp((char *)eps->anchor, "_SM_", | ||
495 | sizeof(eps->anchor))) == 0) { | ||
496 | length = eps->length; | ||
497 | |||
498 | /* SMBIOS v2.1 implementation might use 0x1e */ | ||
499 | if ((length == 0x1e) && | ||
500 | (eps->major_ver == 2) && | ||
501 | (eps->minor_ver == 1)) | ||
502 | length = 0x1f; | ||
503 | |||
504 | /* | ||
505 | * Now we will check: | ||
506 | * - SMBIOS checksum must be 0 | ||
507 | * - intermediate anchor should be _DMI_ | ||
508 | * - intermediate checksum should be 0 | ||
509 | */ | ||
510 | if ((bios_checksum(p, length)) && | ||
511 | (strncmp((char *)eps->intermediate_anchor, "_DMI_", | ||
512 | sizeof(eps->intermediate_anchor)) == 0) && | ||
513 | (bios_checksum(p+0x10, 15))) { | ||
514 | buf = ioremap(eps->table_address, eps->table_length); | ||
515 | if (buf == NULL) | ||
516 | return -ENODEV; | ||
517 | |||
518 | |||
519 | /* Scan the DMI table for the 64 bit CRU service */ | ||
520 | dmi_table(buf, eps->table_length, | ||
521 | eps->table_num_structs, dmi_find_cru); | ||
522 | |||
523 | iounmap(buf); | ||
524 | return 0; | ||
525 | } | ||
526 | } | ||
527 | |||
528 | return -ENODEV; | ||
529 | } | ||
530 | |||
531 | static int __devinit smbios_scan_machine(void) | ||
532 | { | ||
533 | char __iomem *p, *q; | ||
534 | int rc; | ||
535 | |||
536 | if (efi_enabled) { | ||
537 | if (efi.smbios == EFI_INVALID_TABLE_ADDR) | ||
538 | return -ENODEV; | ||
539 | |||
540 | p = ioremap(efi.smbios, 32); | ||
541 | if (p == NULL) | ||
542 | return -ENOMEM; | ||
543 | |||
544 | rc = smbios_present(p); | ||
545 | iounmap(p); | ||
546 | } else { | ||
547 | /* | ||
548 | * Search from 0x0f0000 through 0x0fffff, inclusive. | ||
549 | */ | ||
550 | p = ioremap(PCI_ROM_BASE1, ROM_SIZE); | ||
551 | if (p == NULL) | ||
552 | return -ENOMEM; | ||
553 | |||
554 | for (q = p; q < p + ROM_SIZE; q += 16) { | ||
555 | rc = smbios_present(q); | ||
556 | if (!rc) { | ||
557 | break; | ||
558 | } | ||
559 | } | ||
560 | iounmap(p); | ||
561 | } | ||
562 | } | ||
563 | |||
564 | static int __devinit detect_cru_service(void) | ||
565 | { | ||
566 | cru_rom_addr = NULL; | ||
567 | |||
568 | smbios_scan_machine(); /* will become dmi_walk(dmi_find_cru); */ | ||
569 | |||
570 | /* if cru_rom_addr has been set then we found a CRU service */ | ||
571 | return ((cru_rom_addr != NULL)? 0: -ENODEV); | ||
572 | } | ||
573 | |||
574 | /* ------------------------------------------------------------------------- */ | ||
575 | |||
576 | #endif | ||
577 | |||
578 | /* | ||
579 | * NMI Handler | ||
580 | */ | ||
581 | static int hpwdt_pretimeout(struct notifier_block *nb, unsigned long ulReason, | ||
582 | void *data) | ||
583 | { | ||
584 | static unsigned long rom_pl; | ||
585 | static int die_nmi_called; | ||
586 | |||
587 | if (ulReason != DIE_NMI && ulReason != DIE_NMI_IPI) | ||
588 | return NOTIFY_OK; | ||
589 | |||
590 | spin_lock_irqsave(&rom_lock, rom_pl); | ||
591 | if (!die_nmi_called) | ||
592 | asminline_call(&cmn_regs, cru_rom_addr); | ||
593 | die_nmi_called = 1; | ||
594 | spin_unlock_irqrestore(&rom_lock, rom_pl); | ||
595 | if (cmn_regs.u1.ral == 0) { | ||
596 | printk(KERN_WARNING "hpwdt: An NMI occurred, " | ||
597 | "but unable to determine source.\n"); | ||
598 | } else { | ||
599 | panic("An NMI occurred, please see the Integrated " | ||
600 | "Management Log for details.\n"); | ||
601 | } | ||
602 | |||
603 | return NOTIFY_STOP; | ||
604 | } | ||
605 | |||
606 | /* | ||
607 | * Watchdog operations | ||
608 | */ | ||
609 | static void hpwdt_start(void) | ||
610 | { | ||
611 | reload = (soft_margin * 1000) / 128; | ||
612 | iowrite16(reload, hpwdt_timer_reg); | ||
613 | iowrite16(0x85, hpwdt_timer_con); | ||
614 | } | ||
615 | |||
616 | static void hpwdt_stop(void) | ||
617 | { | ||
618 | unsigned long data; | ||
619 | |||
620 | data = ioread16(hpwdt_timer_con); | ||
621 | data &= 0xFE; | ||
622 | iowrite16(data, hpwdt_timer_con); | ||
623 | } | ||
624 | |||
625 | static void hpwdt_ping(void) | ||
626 | { | ||
627 | iowrite16(reload, hpwdt_timer_reg); | ||
628 | } | ||
629 | |||
630 | static int hpwdt_change_timer(int new_margin) | ||
631 | { | ||
632 | /* Arbitrary, can't find the card's limits */ | ||
633 | if (new_margin < 30 || new_margin > 600) { | ||
634 | printk(KERN_WARNING | ||
635 | "hpwdt: New value passed in is invalid: %d seconds.\n", | ||
636 | new_margin); | ||
637 | return -EINVAL; | ||
638 | } | ||
639 | |||
640 | soft_margin = new_margin; | ||
641 | printk(KERN_DEBUG | ||
642 | "hpwdt: New timer passed in is %d seconds.\n", | ||
643 | new_margin); | ||
644 | reload = (soft_margin * 1000) / 128; | ||
645 | |||
646 | return 0; | ||
647 | } | ||
648 | |||
649 | /* | ||
650 | * /dev/watchdog handling | ||
651 | */ | ||
652 | static int hpwdt_open(struct inode *inode, struct file *file) | ||
653 | { | ||
654 | /* /dev/watchdog can only be opened once */ | ||
655 | if (test_and_set_bit(0, &hpwdt_is_open)) | ||
656 | return -EBUSY; | ||
657 | |||
658 | /* Start the watchdog */ | ||
659 | hpwdt_start(); | ||
660 | hpwdt_ping(); | ||
661 | |||
662 | return nonseekable_open(inode, file); | ||
663 | } | ||
664 | |||
665 | static int hpwdt_release(struct inode *inode, struct file *file) | ||
666 | { | ||
667 | /* Stop the watchdog */ | ||
668 | if (expect_release == 42) { | ||
669 | hpwdt_stop(); | ||
670 | } else { | ||
671 | printk(KERN_CRIT | ||
672 | "hpwdt: Unexpected close, not stopping watchdog!\n"); | ||
673 | hpwdt_ping(); | ||
674 | } | ||
675 | |||
676 | expect_release = 0; | ||
677 | |||
678 | /* /dev/watchdog is being closed, make sure it can be re-opened */ | ||
679 | clear_bit(0, &hpwdt_is_open); | ||
680 | |||
681 | return 0; | ||
682 | } | ||
683 | |||
684 | static ssize_t hpwdt_write(struct file *file, const char __user *data, | ||
685 | size_t len, loff_t *ppos) | ||
686 | { | ||
687 | /* See if we got the magic character 'V' and reload the timer */ | ||
688 | if (len) { | ||
689 | if (!nowayout) { | ||
690 | size_t i; | ||
691 | |||
692 | /* note: just in case someone wrote the magic character | ||
693 | * five months ago... */ | ||
694 | expect_release = 0; | ||
695 | |||
696 | /* scan to see whether or not we got the magic char. */ | ||
697 | for (i = 0; i != len; i++) { | ||
698 | char c; | ||
699 | if (get_user(c, data+i)) | ||
700 | return -EFAULT; | ||
701 | if (c == 'V') | ||
702 | expect_release = 42; | ||
703 | } | ||
704 | } | ||
705 | |||
706 | /* someone wrote to us, we should reload the timer */ | ||
707 | hpwdt_ping(); | ||
708 | } | ||
709 | |||
710 | return len; | ||
711 | } | ||
712 | |||
713 | static struct watchdog_info ident = { | ||
714 | .options = WDIOF_SETTIMEOUT | | ||
715 | WDIOF_KEEPALIVEPING | | ||
716 | WDIOF_MAGICCLOSE, | ||
717 | .identity = "HP iLO2 HW Watchdog Timer", | ||
718 | }; | ||
719 | |||
720 | static long hpwdt_ioctl(struct file *file, unsigned int cmd, | ||
721 | unsigned long arg) | ||
722 | { | ||
723 | void __user *argp = (void __user *)arg; | ||
724 | int __user *p = argp; | ||
725 | int new_margin; | ||
726 | int ret = -ENOTTY; | ||
727 | |||
728 | switch (cmd) { | ||
729 | case WDIOC_GETSUPPORT: | ||
730 | ret = 0; | ||
731 | if (copy_to_user(argp, &ident, sizeof(ident))) | ||
732 | ret = -EFAULT; | ||
733 | break; | ||
734 | |||
735 | case WDIOC_GETSTATUS: | ||
736 | case WDIOC_GETBOOTSTATUS: | ||
737 | ret = put_user(0, p); | ||
738 | break; | ||
739 | |||
740 | case WDIOC_KEEPALIVE: | ||
741 | hpwdt_ping(); | ||
742 | ret = 0; | ||
743 | break; | ||
744 | |||
745 | case WDIOC_SETTIMEOUT: | ||
746 | ret = get_user(new_margin, p); | ||
747 | if (ret) | ||
748 | break; | ||
749 | |||
750 | ret = hpwdt_change_timer(new_margin); | ||
751 | if (ret) | ||
752 | break; | ||
753 | |||
754 | hpwdt_ping(); | ||
755 | /* Fall */ | ||
756 | case WDIOC_GETTIMEOUT: | ||
757 | ret = put_user(soft_margin, p); | ||
758 | break; | ||
759 | } | ||
760 | return ret; | ||
761 | } | ||
762 | |||
763 | /* | ||
764 | * Kernel interfaces | ||
765 | */ | ||
766 | static struct file_operations hpwdt_fops = { | ||
767 | .owner = THIS_MODULE, | ||
768 | .llseek = no_llseek, | ||
769 | .write = hpwdt_write, | ||
770 | .unlocked_ioctl = hpwdt_ioctl, | ||
771 | .open = hpwdt_open, | ||
772 | .release = hpwdt_release, | ||
773 | }; | ||
774 | |||
775 | static struct miscdevice hpwdt_miscdev = { | ||
776 | .minor = WATCHDOG_MINOR, | ||
777 | .name = "watchdog", | ||
778 | .fops = &hpwdt_fops, | ||
779 | }; | ||
780 | |||
781 | static struct notifier_block die_notifier = { | ||
782 | .notifier_call = hpwdt_pretimeout, | ||
783 | .priority = 0x7FFFFFFF, | ||
784 | }; | ||
785 | |||
786 | /* | ||
787 | * Init & Exit | ||
788 | */ | ||
789 | |||
790 | static int __devinit hpwdt_init_one(struct pci_dev *dev, | ||
791 | const struct pci_device_id *ent) | ||
792 | { | ||
793 | int retval; | ||
794 | |||
795 | /* | ||
796 | * First let's find out if we are on an iLO2 server. We will | ||
797 | * not run on a legacy ASM box. | ||
798 | */ | ||
799 | if (dev->subsystem_vendor != PCI_VENDOR_ID_HP) { | ||
800 | dev_warn(&dev->dev, | ||
801 | "This server does not have an iLO2 ASIC.\n"); | ||
802 | return -ENODEV; | ||
803 | } | ||
804 | |||
805 | if (pci_enable_device(dev)) { | ||
806 | dev_warn(&dev->dev, | ||
807 | "Not possible to enable PCI Device: 0x%x:0x%x.\n", | ||
808 | ent->vendor, ent->device); | ||
809 | return -ENODEV; | ||
810 | } | ||
811 | |||
812 | pci_mem_addr = pci_iomap(dev, 1, 0x80); | ||
813 | if (!pci_mem_addr) { | ||
814 | dev_warn(&dev->dev, | ||
815 | "Unable to detect the iLO2 server memory.\n"); | ||
816 | retval = -ENOMEM; | ||
817 | goto error_pci_iomap; | ||
818 | } | ||
819 | hpwdt_timer_reg = pci_mem_addr + 0x70; | ||
820 | hpwdt_timer_con = pci_mem_addr + 0x72; | ||
821 | |||
822 | /* Make sure that we have a valid soft_margin */ | ||
823 | if (hpwdt_change_timer(soft_margin)) | ||
824 | hpwdt_change_timer(DEFAULT_MARGIN); | ||
825 | |||
826 | /* | ||
827 | * We need to map the ROM to get the CRU service. | ||
828 | * For 32 bit Operating Systems we need to go through the 32 Bit | ||
829 | * BIOS Service Directory | ||
830 | * For 64 bit Operating Systems we get that service through SMBIOS. | ||
831 | */ | ||
832 | retval = detect_cru_service(); | ||
833 | if (retval < 0) { | ||
834 | dev_warn(&dev->dev, | ||
835 | "Unable to detect the %d Bit CRU Service.\n", | ||
836 | HPWDT_ARCH); | ||
837 | goto error_get_cru; | ||
838 | } | ||
839 | |||
840 | /* | ||
841 | * We know this is the only CRU call we need to make so lets keep as | ||
842 | * few instructions as possible once the NMI comes in. | ||
843 | */ | ||
844 | cmn_regs.u1.rah = 0x0D; | ||
845 | cmn_regs.u1.ral = 0x02; | ||
846 | |||
847 | retval = register_die_notifier(&die_notifier); | ||
848 | if (retval != 0) { | ||
849 | dev_warn(&dev->dev, | ||
850 | "Unable to register a die notifier (err=%d).\n", | ||
851 | retval); | ||
852 | goto error_die_notifier; | ||
853 | } | ||
854 | |||
855 | retval = misc_register(&hpwdt_miscdev); | ||
856 | if (retval < 0) { | ||
857 | dev_warn(&dev->dev, | ||
858 | "Unable to register miscdev on minor=%d (err=%d).\n", | ||
859 | WATCHDOG_MINOR, retval); | ||
860 | goto error_misc_register; | ||
861 | } | ||
862 | |||
863 | printk(KERN_INFO | ||
864 | "hp Watchdog Timer Driver: 1.00" | ||
865 | ", timer margin: %d seconds( nowayout=%d).\n", | ||
866 | soft_margin, nowayout); | ||
867 | |||
868 | return 0; | ||
869 | |||
870 | error_misc_register: | ||
871 | unregister_die_notifier(&die_notifier); | ||
872 | error_die_notifier: | ||
873 | if (cru_rom_addr) | ||
874 | iounmap(cru_rom_addr); | ||
875 | error_get_cru: | ||
876 | pci_iounmap(dev, pci_mem_addr); | ||
877 | error_pci_iomap: | ||
878 | pci_disable_device(dev); | ||
879 | return retval; | ||
880 | } | ||
881 | |||
882 | static void __devexit hpwdt_exit(struct pci_dev *dev) | ||
883 | { | ||
884 | if (!nowayout) | ||
885 | hpwdt_stop(); | ||
886 | |||
887 | misc_deregister(&hpwdt_miscdev); | ||
888 | unregister_die_notifier(&die_notifier); | ||
889 | |||
890 | if (cru_rom_addr) | ||
891 | iounmap(cru_rom_addr); | ||
892 | pci_iounmap(dev, pci_mem_addr); | ||
893 | pci_disable_device(dev); | ||
894 | } | ||
895 | |||
896 | static struct pci_driver hpwdt_driver = { | ||
897 | .name = "hpwdt", | ||
898 | .id_table = hpwdt_devices, | ||
899 | .probe = hpwdt_init_one, | ||
900 | .remove = __devexit_p(hpwdt_exit), | ||
901 | }; | ||
902 | |||
903 | static void __exit hpwdt_cleanup(void) | ||
904 | { | ||
905 | pci_unregister_driver(&hpwdt_driver); | ||
906 | } | ||
907 | |||
908 | static int __init hpwdt_init(void) | ||
909 | { | ||
910 | return pci_register_driver(&hpwdt_driver); | ||
911 | } | ||
912 | |||
913 | MODULE_AUTHOR("Tom Mingarelli"); | ||
914 | MODULE_DESCRIPTION("hp watchdog driver"); | ||
915 | MODULE_LICENSE("GPL"); | ||
916 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
917 | |||
918 | module_param(soft_margin, int, 0); | ||
919 | MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds"); | ||
920 | |||
921 | module_param(nowayout, int, 0); | ||
922 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | ||
923 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
924 | |||
925 | module_init(hpwdt_init); | ||
926 | module_exit(hpwdt_cleanup); | ||
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c index 98451747d3cd..789831b3fa00 100644 --- a/drivers/watchdog/mtx-1_wdt.c +++ b/drivers/watchdog/mtx-1_wdt.c | |||
@@ -45,10 +45,13 @@ | |||
45 | #include <linux/completion.h> | 45 | #include <linux/completion.h> |
46 | #include <linux/jiffies.h> | 46 | #include <linux/jiffies.h> |
47 | #include <linux/watchdog.h> | 47 | #include <linux/watchdog.h> |
48 | #include <linux/platform_device.h> | ||
49 | |||
48 | #include <asm/io.h> | 50 | #include <asm/io.h> |
49 | #include <asm/uaccess.h> | 51 | #include <asm/uaccess.h> |
50 | 52 | ||
51 | #include <asm/mach-au1x00/au1000.h> | 53 | #include <asm/mach-au1x00/au1000.h> |
54 | #include <asm/gpio.h> | ||
52 | 55 | ||
53 | #define MTX1_WDT_INTERVAL (5 * HZ) | 56 | #define MTX1_WDT_INTERVAL (5 * HZ) |
54 | 57 | ||
@@ -61,6 +64,7 @@ static struct { | |||
61 | volatile int queue; | 64 | volatile int queue; |
62 | int default_ticks; | 65 | int default_ticks; |
63 | unsigned long inuse; | 66 | unsigned long inuse; |
67 | unsigned gpio; | ||
64 | } mtx1_wdt_device; | 68 | } mtx1_wdt_device; |
65 | 69 | ||
66 | static void mtx1_wdt_trigger(unsigned long unused) | 70 | static void mtx1_wdt_trigger(unsigned long unused) |
@@ -73,7 +77,8 @@ static void mtx1_wdt_trigger(unsigned long unused) | |||
73 | * toggle GPIO2_15 | 77 | * toggle GPIO2_15 |
74 | */ | 78 | */ |
75 | tmp = au_readl(GPIO2_DIR); | 79 | tmp = au_readl(GPIO2_DIR); |
76 | tmp = (tmp & ~(1<<15)) | ((~tmp) & (1<<15)); | 80 | tmp = (tmp & ~(1 << mtx1_wdt_device.gpio)) | |
81 | ((~tmp) & (1 << mtx1_wdt_device.gpio)); | ||
77 | au_writel (tmp, GPIO2_DIR); | 82 | au_writel (tmp, GPIO2_DIR); |
78 | 83 | ||
79 | if (mtx1_wdt_device.queue && ticks) | 84 | if (mtx1_wdt_device.queue && ticks) |
@@ -93,7 +98,7 @@ static void mtx1_wdt_start(void) | |||
93 | { | 98 | { |
94 | if (!mtx1_wdt_device.queue) { | 99 | if (!mtx1_wdt_device.queue) { |
95 | mtx1_wdt_device.queue = 1; | 100 | mtx1_wdt_device.queue = 1; |
96 | au_writel (au_readl(GPIO2_DIR) | (u32)(1<<15), GPIO2_DIR); | 101 | gpio_set_value(mtx1_wdt_device.gpio, 1); |
97 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); | 102 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); |
98 | } | 103 | } |
99 | mtx1_wdt_device.running++; | 104 | mtx1_wdt_device.running++; |
@@ -103,7 +108,7 @@ static int mtx1_wdt_stop(void) | |||
103 | { | 108 | { |
104 | if (mtx1_wdt_device.queue) { | 109 | if (mtx1_wdt_device.queue) { |
105 | mtx1_wdt_device.queue = 0; | 110 | mtx1_wdt_device.queue = 0; |
106 | au_writel (au_readl(GPIO2_DIR) & ~((u32)(1<<15)), GPIO2_DIR); | 111 | gpio_set_value(mtx1_wdt_device.gpio, 0); |
107 | } | 112 | } |
108 | 113 | ||
109 | ticks = mtx1_wdt_device.default_ticks; | 114 | ticks = mtx1_wdt_device.default_ticks; |
@@ -197,10 +202,12 @@ static struct miscdevice mtx1_wdt_misc = { | |||
197 | }; | 202 | }; |
198 | 203 | ||
199 | 204 | ||
200 | static int __init mtx1_wdt_init(void) | 205 | static int mtx1_wdt_probe(struct platform_device *pdev) |
201 | { | 206 | { |
202 | int ret; | 207 | int ret; |
203 | 208 | ||
209 | mtx1_wdt_device.gpio = pdev->resource[0].start; | ||
210 | |||
204 | if ((ret = misc_register(&mtx1_wdt_misc)) < 0) { | 211 | if ((ret = misc_register(&mtx1_wdt_misc)) < 0) { |
205 | printk(KERN_ERR " mtx-1_wdt : failed to register\n"); | 212 | printk(KERN_ERR " mtx-1_wdt : failed to register\n"); |
206 | return ret; | 213 | return ret; |
@@ -222,13 +229,30 @@ static int __init mtx1_wdt_init(void) | |||
222 | return 0; | 229 | return 0; |
223 | } | 230 | } |
224 | 231 | ||
225 | static void __exit mtx1_wdt_exit(void) | 232 | static int mtx1_wdt_remove(struct platform_device *pdev) |
226 | { | 233 | { |
227 | if (mtx1_wdt_device.queue) { | 234 | if (mtx1_wdt_device.queue) { |
228 | mtx1_wdt_device.queue = 0; | 235 | mtx1_wdt_device.queue = 0; |
229 | wait_for_completion(&mtx1_wdt_device.stop); | 236 | wait_for_completion(&mtx1_wdt_device.stop); |
230 | } | 237 | } |
231 | misc_deregister(&mtx1_wdt_misc); | 238 | misc_deregister(&mtx1_wdt_misc); |
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static struct platform_driver mtx1_wdt = { | ||
243 | .probe = mtx1_wdt_probe, | ||
244 | .remove = mtx1_wdt_remove, | ||
245 | .driver.name = "mtx1-wdt", | ||
246 | }; | ||
247 | |||
248 | static int __init mtx1_wdt_init(void) | ||
249 | { | ||
250 | return platform_driver_register(&mtx1_wdt); | ||
251 | } | ||
252 | |||
253 | static void __exit mtx1_wdt_exit(void) | ||
254 | { | ||
255 | platform_driver_unregister(&mtx1_wdt); | ||
232 | } | 256 | } |
233 | 257 | ||
234 | module_init(mtx1_wdt_init); | 258 | module_init(mtx1_wdt_init); |
@@ -237,3 +261,4 @@ module_exit(mtx1_wdt_exit); | |||
237 | MODULE_AUTHOR("Michael Stickel, Florian Fainelli"); | 261 | MODULE_AUTHOR("Michael Stickel, Florian Fainelli"); |
238 | MODULE_DESCRIPTION("Driver for the MTX-1 watchdog"); | 262 | MODULE_DESCRIPTION("Driver for the MTX-1 watchdog"); |
239 | MODULE_LICENSE("GPL"); | 263 | MODULE_LICENSE("GPL"); |
264 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/sb_wdog.c b/drivers/watchdog/sb_wdog.c new file mode 100644 index 000000000000..b94431433695 --- /dev/null +++ b/drivers/watchdog/sb_wdog.c | |||
@@ -0,0 +1,353 @@ | |||
1 | /* | ||
2 | * Watchdog driver for SiByte SB1 SoCs | ||
3 | * | ||
4 | * Copyright (C) 2007 OnStor, Inc. * Andrew Sharp <andy.sharp@onstor.com> | ||
5 | * | ||
6 | * This driver is intended to make the second of two hardware watchdogs | ||
7 | * on the Sibyte 12XX and 11XX SoCs available to the user. There are two | ||
8 | * such devices available on the SoC, but it seems that there isn't an | ||
9 | * enumeration class for watchdogs in Linux like there is for RTCs. | ||
10 | * The second is used rather than the first because it uses IRQ 1, | ||
11 | * thereby avoiding all that IRQ 0 problematic nonsense. | ||
12 | * | ||
13 | * I have not tried this driver on a 1480 processor; it might work | ||
14 | * just well enough to really screw things up. | ||
15 | * | ||
16 | * It is a simple timer, and there is an interrupt that is raised the | ||
17 | * first time the timer expires. The second time it expires, the chip | ||
18 | * is reset and there is no way to redirect that NMI. Which could | ||
19 | * be problematic in some cases where this chip is sitting on the HT | ||
20 | * bus and has just taken responsibility for providing a cache block. | ||
21 | * Since the reset can't be redirected to the external reset pin, it is | ||
22 | * possible that other HT connected processors might hang and not reset. | ||
23 | * For Linux, a soft reset would probably be even worse than a hard reset. | ||
24 | * There you have it. | ||
25 | * | ||
26 | * The timer takes 23 bits of a 64 bit register (?) as a count value, | ||
27 | * and decrements the count every microsecond, for a max value of | ||
28 | * 0x7fffff usec or about 8.3ish seconds. | ||
29 | * | ||
30 | * This watchdog borrows some user semantics from the softdog driver, | ||
31 | * in that if you close the fd, it leaves the watchdog running, unless | ||
32 | * you previously wrote a 'V' to the fd, in which case it disables | ||
33 | * the watchdog when you close the fd like some other drivers. | ||
34 | * | ||
35 | * Based on various other watchdog drivers, which are probably all | ||
36 | * loosely based on something Alan Cox wrote years ago. | ||
37 | * | ||
38 | * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved. | ||
39 | * http://www.redhat.com | ||
40 | * | ||
41 | * This program is free software; you can redistribute it and/or | ||
42 | * modify it under the terms of the GNU General Public License | ||
43 | * version 1 or 2 as published by the Free Software Foundation. | ||
44 | * | ||
45 | */ | ||
46 | #include <linux/module.h> | ||
47 | #include <linux/io.h> | ||
48 | #include <linux/uaccess.h> | ||
49 | #include <linux/fs.h> | ||
50 | #include <linux/reboot.h> | ||
51 | #include <linux/miscdevice.h> | ||
52 | #include <linux/watchdog.h> | ||
53 | #include <linux/interrupt.h> | ||
54 | |||
55 | #include <asm/sibyte/sb1250.h> | ||
56 | #include <asm/sibyte/sb1250_regs.h> | ||
57 | #include <asm/sibyte/sb1250_int.h> | ||
58 | #include <asm/sibyte/sb1250_scd.h> | ||
59 | |||
60 | |||
61 | /* | ||
62 | * set the initial count value of a timer | ||
63 | * | ||
64 | * wdog is the iomem address of the cfg register | ||
65 | */ | ||
66 | void sbwdog_set(char __iomem *wdog, unsigned long t) | ||
67 | { | ||
68 | __raw_writeb(0, wdog - 0x10); | ||
69 | __raw_writeq(t & 0x7fffffUL, wdog); | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * cause the timer to [re]load it's initial count and start counting | ||
74 | * all over again | ||
75 | * | ||
76 | * wdog is the iomem address of the cfg register | ||
77 | */ | ||
78 | void sbwdog_pet(char __iomem *wdog) | ||
79 | { | ||
80 | __raw_writeb(__raw_readb(wdog) | 1, wdog); | ||
81 | } | ||
82 | |||
83 | static unsigned long sbwdog_gate; /* keeps it to one thread only */ | ||
84 | static char __iomem *kern_dog = (char __iomem *)(IO_BASE + (A_SCD_WDOG_CFG_0)); | ||
85 | static char __iomem *user_dog = (char __iomem *)(IO_BASE + (A_SCD_WDOG_CFG_1)); | ||
86 | static unsigned long timeout = 0x7fffffUL; /* useconds: 8.3ish secs. */ | ||
87 | static int expect_close; | ||
88 | |||
89 | static struct watchdog_info ident = { | ||
90 | .options = WDIOF_CARDRESET | WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | ||
91 | .identity = "SiByte Watchdog", | ||
92 | }; | ||
93 | |||
94 | /* | ||
95 | * Allow only a single thread to walk the dog | ||
96 | */ | ||
97 | static int sbwdog_open(struct inode *inode, struct file *file) | ||
98 | { | ||
99 | nonseekable_open(inode, file); | ||
100 | if (test_and_set_bit(0, &sbwdog_gate)) { | ||
101 | return -EBUSY; | ||
102 | } | ||
103 | __module_get(THIS_MODULE); | ||
104 | |||
105 | /* | ||
106 | * Activate the timer | ||
107 | */ | ||
108 | sbwdog_set(user_dog, timeout); | ||
109 | __raw_writeb(1, user_dog); | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * Put the dog back in the kennel. | ||
116 | */ | ||
117 | static int sbwdog_release(struct inode *inode, struct file *file) | ||
118 | { | ||
119 | if (expect_close == 42) { | ||
120 | __raw_writeb(0, user_dog); | ||
121 | module_put(THIS_MODULE); | ||
122 | } else { | ||
123 | printk(KERN_CRIT "%s: Unexpected close, not stopping watchdog!\n", | ||
124 | ident.identity); | ||
125 | sbwdog_pet(user_dog); | ||
126 | } | ||
127 | clear_bit(0, &sbwdog_gate); | ||
128 | expect_close = 0; | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * 42 - the answer | ||
135 | */ | ||
136 | static ssize_t sbwdog_write(struct file *file, const char __user *data, | ||
137 | size_t len, loff_t *ppos) | ||
138 | { | ||
139 | int i; | ||
140 | |||
141 | if (len) { | ||
142 | /* | ||
143 | * restart the timer | ||
144 | */ | ||
145 | expect_close = 0; | ||
146 | |||
147 | for (i = 0; i != len; i++) { | ||
148 | char c; | ||
149 | |||
150 | if (get_user(c, data + i)) { | ||
151 | return -EFAULT; | ||
152 | } | ||
153 | if (c == 'V') { | ||
154 | expect_close = 42; | ||
155 | } | ||
156 | } | ||
157 | sbwdog_pet(user_dog); | ||
158 | } | ||
159 | |||
160 | return len; | ||
161 | } | ||
162 | |||
163 | static int sbwdog_ioctl(struct inode *inode, struct file *file, | ||
164 | unsigned int cmd, unsigned long arg) | ||
165 | { | ||
166 | int ret = -ENOTTY; | ||
167 | unsigned long time; | ||
168 | void __user *argp = (void __user *)arg; | ||
169 | int __user *p = argp; | ||
170 | |||
171 | switch (cmd) { | ||
172 | case WDIOC_GETSUPPORT: | ||
173 | ret = copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0; | ||
174 | break; | ||
175 | |||
176 | case WDIOC_GETSTATUS: | ||
177 | case WDIOC_GETBOOTSTATUS: | ||
178 | ret = put_user(0, p); | ||
179 | break; | ||
180 | |||
181 | case WDIOC_SETTIMEOUT: | ||
182 | ret = get_user(time, p); | ||
183 | if (ret) { | ||
184 | break; | ||
185 | } | ||
186 | |||
187 | time *= 1000000; | ||
188 | if (time > 0x7fffffUL) { | ||
189 | ret = -EINVAL; | ||
190 | break; | ||
191 | } | ||
192 | timeout = time; | ||
193 | sbwdog_set(user_dog, timeout); | ||
194 | sbwdog_pet(user_dog); | ||
195 | |||
196 | case WDIOC_GETTIMEOUT: | ||
197 | /* | ||
198 | * get the remaining count from the ... count register | ||
199 | * which is 1*8 before the config register | ||
200 | */ | ||
201 | ret = put_user(__raw_readq(user_dog - 8) / 1000000, p); | ||
202 | break; | ||
203 | |||
204 | case WDIOC_KEEPALIVE: | ||
205 | sbwdog_pet(user_dog); | ||
206 | ret = 0; | ||
207 | break; | ||
208 | } | ||
209 | return ret; | ||
210 | } | ||
211 | |||
212 | /* | ||
213 | * Notifier for system down | ||
214 | */ | ||
215 | static int | ||
216 | sbwdog_notify_sys(struct notifier_block *this, unsigned long code, void *erf) | ||
217 | { | ||
218 | if (code == SYS_DOWN || code == SYS_HALT) { | ||
219 | /* | ||
220 | * sit and sit | ||
221 | */ | ||
222 | __raw_writeb(0, user_dog); | ||
223 | __raw_writeb(0, kern_dog); | ||
224 | } | ||
225 | |||
226 | return NOTIFY_DONE; | ||
227 | } | ||
228 | |||
229 | static const struct file_operations sbwdog_fops = | ||
230 | { | ||
231 | .owner = THIS_MODULE, | ||
232 | .llseek = no_llseek, | ||
233 | .write = sbwdog_write, | ||
234 | .ioctl = sbwdog_ioctl, | ||
235 | .open = sbwdog_open, | ||
236 | .release = sbwdog_release, | ||
237 | }; | ||
238 | |||
239 | static struct miscdevice sbwdog_miscdev = | ||
240 | { | ||
241 | .minor = WATCHDOG_MINOR, | ||
242 | .name = "watchdog", | ||
243 | .fops = &sbwdog_fops, | ||
244 | }; | ||
245 | |||
246 | static struct notifier_block sbwdog_notifier = { | ||
247 | .notifier_call = sbwdog_notify_sys, | ||
248 | }; | ||
249 | |||
250 | /* | ||
251 | * interrupt handler | ||
252 | * | ||
253 | * doesn't do a whole lot for user, but oh so cleverly written so kernel | ||
254 | * code can use it to re-up the watchdog, thereby saving the kernel from | ||
255 | * having to create and maintain a timer, just to tickle another timer, | ||
256 | * which is just so wrong. | ||
257 | */ | ||
258 | irqreturn_t sbwdog_interrupt(int irq, void *addr) | ||
259 | { | ||
260 | unsigned long wd_init; | ||
261 | char *wd_cfg_reg = (char *)addr; | ||
262 | u8 cfg; | ||
263 | |||
264 | cfg = __raw_readb(wd_cfg_reg); | ||
265 | wd_init = __raw_readq(wd_cfg_reg - 8) & 0x7fffff; | ||
266 | |||
267 | /* | ||
268 | * if it's the second watchdog timer, it's for those users | ||
269 | */ | ||
270 | if (wd_cfg_reg == user_dog) { | ||
271 | printk(KERN_CRIT | ||
272 | "%s in danger of initiating system reset in %ld.%01ld seconds\n", | ||
273 | ident.identity, wd_init / 1000000, (wd_init / 100000) % 10); | ||
274 | } else { | ||
275 | cfg |= 1; | ||
276 | } | ||
277 | |||
278 | __raw_writeb(cfg, wd_cfg_reg); | ||
279 | |||
280 | return IRQ_HANDLED; | ||
281 | } | ||
282 | |||
283 | static int __init sbwdog_init(void) | ||
284 | { | ||
285 | int ret; | ||
286 | |||
287 | /* | ||
288 | * register a reboot notifier | ||
289 | */ | ||
290 | ret = register_reboot_notifier(&sbwdog_notifier); | ||
291 | if (ret) { | ||
292 | printk (KERN_ERR "%s: cannot register reboot notifier (err=%d)\n", | ||
293 | ident.identity, ret); | ||
294 | return ret; | ||
295 | } | ||
296 | |||
297 | /* | ||
298 | * get the resources | ||
299 | */ | ||
300 | ret = misc_register(&sbwdog_miscdev); | ||
301 | if (ret == 0) { | ||
302 | printk(KERN_INFO "%s: timeout is %ld.%ld secs\n", ident.identity, | ||
303 | timeout / 1000000, (timeout / 100000) % 10); | ||
304 | } | ||
305 | |||
306 | ret = request_irq(1, sbwdog_interrupt, IRQF_DISABLED | IRQF_SHARED, | ||
307 | ident.identity, (void *)user_dog); | ||
308 | if (ret) { | ||
309 | printk(KERN_ERR "%s: failed to request irq 1 - %d\n", ident.identity, | ||
310 | ret); | ||
311 | misc_deregister(&sbwdog_miscdev); | ||
312 | } | ||
313 | |||
314 | return ret; | ||
315 | } | ||
316 | |||
317 | static void __exit sbwdog_exit(void) | ||
318 | { | ||
319 | misc_deregister(&sbwdog_miscdev); | ||
320 | } | ||
321 | |||
322 | module_init(sbwdog_init); | ||
323 | module_exit(sbwdog_exit); | ||
324 | |||
325 | MODULE_AUTHOR("Andrew Sharp <andy.sharp@onstor.com>"); | ||
326 | MODULE_DESCRIPTION("SiByte Watchdog"); | ||
327 | |||
328 | module_param(timeout, ulong, 0); | ||
329 | MODULE_PARM_DESC(timeout, | ||
330 | "Watchdog timeout in microseconds (max/default 8388607 or 8.3ish secs)"); | ||
331 | |||
332 | MODULE_LICENSE("GPL"); | ||
333 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
334 | |||
335 | /* | ||
336 | * example code that can be put in a platform code area to utilize the | ||
337 | * first watchdog timer for the kernels own purpose. | ||
338 | |||
339 | void | ||
340 | platform_wd_setup(void) | ||
341 | { | ||
342 | int ret; | ||
343 | |||
344 | ret = request_irq(0, sbwdog_interrupt, IRQF_DISABLED | IRQF_SHARED, | ||
345 | "Kernel Watchdog", IOADDR(A_SCD_WDOG_CFG_0)); | ||
346 | if (ret) { | ||
347 | printk(KERN_CRIT "Watchdog IRQ zero(0) failed to be requested - %d\n", | ||
348 | ret); | ||
349 | } | ||
350 | } | ||
351 | |||
352 | |||
353 | */ | ||