diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2013-12-09 08:04:37 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-12-09 08:04:37 -0500 |
commit | bdc54ef45d7670aeb52ce73f8b7ad5f3e5563661 (patch) | |
tree | da6e170ce87891a0242de88d8d7c1ba34faf9bb7 /drivers | |
parent | 33e0aae11e4854c792e9871f94da6d28bf2e2bb8 (diff) | |
parent | 374b105797c3d4f29c685f3be535c35f5689b30e (diff) |
Merge tag 'v3.13-rc3' into devel
Linux 3.13-rc3
Diffstat (limited to 'drivers')
250 files changed, 3627 insertions, 1415 deletions
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h index f691d0e4d9fa..ff97430455cb 100644 --- a/drivers/acpi/acpica/acresrc.h +++ b/drivers/acpi/acpica/acresrc.h | |||
@@ -184,7 +184,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, | |||
184 | struct acpi_buffer *output_buffer); | 184 | struct acpi_buffer *output_buffer); |
185 | 185 | ||
186 | acpi_status | 186 | acpi_status |
187 | acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | 187 | acpi_rs_create_aml_resources(struct acpi_buffer *resource_list, |
188 | struct acpi_buffer *output_buffer); | 188 | struct acpi_buffer *output_buffer); |
189 | 189 | ||
190 | acpi_status | 190 | acpi_status |
@@ -227,8 +227,8 @@ acpi_rs_get_list_length(u8 * aml_buffer, | |||
227 | u32 aml_buffer_length, acpi_size * size_needed); | 227 | u32 aml_buffer_length, acpi_size * size_needed); |
228 | 228 | ||
229 | acpi_status | 229 | acpi_status |
230 | acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer, | 230 | acpi_rs_get_aml_length(struct acpi_resource *resource_list, |
231 | acpi_size * size_needed); | 231 | acpi_size resource_list_size, acpi_size * size_needed); |
232 | 232 | ||
233 | acpi_status | 233 | acpi_status |
234 | acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | 234 | acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, |
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c index 243737363fb8..fd1ff54cda19 100644 --- a/drivers/acpi/acpica/nsalloc.c +++ b/drivers/acpi/acpica/nsalloc.c | |||
@@ -106,6 +106,7 @@ struct acpi_namespace_node *acpi_ns_create_node(u32 name) | |||
106 | void acpi_ns_delete_node(struct acpi_namespace_node *node) | 106 | void acpi_ns_delete_node(struct acpi_namespace_node *node) |
107 | { | 107 | { |
108 | union acpi_operand_object *obj_desc; | 108 | union acpi_operand_object *obj_desc; |
109 | union acpi_operand_object *next_desc; | ||
109 | 110 | ||
110 | ACPI_FUNCTION_NAME(ns_delete_node); | 111 | ACPI_FUNCTION_NAME(ns_delete_node); |
111 | 112 | ||
@@ -114,12 +115,13 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node) | |||
114 | acpi_ns_detach_object(node); | 115 | acpi_ns_detach_object(node); |
115 | 116 | ||
116 | /* | 117 | /* |
117 | * Delete an attached data object if present (an object that was created | 118 | * Delete an attached data object list if present (objects that were |
118 | * and attached via acpi_attach_data). Note: After any normal object is | 119 | * attached via acpi_attach_data). Note: After any normal object is |
119 | * detached above, the only possible remaining object is a data object. | 120 | * detached above, the only possible remaining object(s) are data |
121 | * objects, in a linked list. | ||
120 | */ | 122 | */ |
121 | obj_desc = node->object; | 123 | obj_desc = node->object; |
122 | if (obj_desc && (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) { | 124 | while (obj_desc && (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) { |
123 | 125 | ||
124 | /* Invoke the attached data deletion handler if present */ | 126 | /* Invoke the attached data deletion handler if present */ |
125 | 127 | ||
@@ -127,7 +129,15 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node) | |||
127 | obj_desc->data.handler(node, obj_desc->data.pointer); | 129 | obj_desc->data.handler(node, obj_desc->data.pointer); |
128 | } | 130 | } |
129 | 131 | ||
132 | next_desc = obj_desc->common.next_object; | ||
130 | acpi_ut_remove_reference(obj_desc); | 133 | acpi_ut_remove_reference(obj_desc); |
134 | obj_desc = next_desc; | ||
135 | } | ||
136 | |||
137 | /* Special case for the statically allocated root node */ | ||
138 | |||
139 | if (node == acpi_gbl_root_node) { | ||
140 | return; | ||
131 | } | 141 | } |
132 | 142 | ||
133 | /* Now we can delete the node */ | 143 | /* Now we can delete the node */ |
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c index cc2fea94c5f0..4a0665b6bcc1 100644 --- a/drivers/acpi/acpica/nsutils.c +++ b/drivers/acpi/acpica/nsutils.c | |||
@@ -593,24 +593,26 @@ struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle) | |||
593 | 593 | ||
594 | void acpi_ns_terminate(void) | 594 | void acpi_ns_terminate(void) |
595 | { | 595 | { |
596 | union acpi_operand_object *obj_desc; | 596 | acpi_status status; |
597 | 597 | ||
598 | ACPI_FUNCTION_TRACE(ns_terminate); | 598 | ACPI_FUNCTION_TRACE(ns_terminate); |
599 | 599 | ||
600 | /* | 600 | /* |
601 | * 1) Free the entire namespace -- all nodes and objects | 601 | * Free the entire namespace -- all nodes and all objects |
602 | * | 602 | * attached to the nodes |
603 | * Delete all object descriptors attached to namepsace nodes | ||
604 | */ | 603 | */ |
605 | acpi_ns_delete_namespace_subtree(acpi_gbl_root_node); | 604 | acpi_ns_delete_namespace_subtree(acpi_gbl_root_node); |
606 | 605 | ||
607 | /* Detach any objects attached to the root */ | 606 | /* Delete any objects attached to the root node */ |
608 | 607 | ||
609 | obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node); | 608 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
610 | if (obj_desc) { | 609 | if (ACPI_FAILURE(status)) { |
611 | acpi_ns_detach_object(acpi_gbl_root_node); | 610 | return_VOID; |
612 | } | 611 | } |
613 | 612 | ||
613 | acpi_ns_delete_node(acpi_gbl_root_node); | ||
614 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
615 | |||
614 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n")); | 616 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n")); |
615 | return_VOID; | 617 | return_VOID; |
616 | } | 618 | } |
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c index b62a0f4f4f9b..b60c9cf82862 100644 --- a/drivers/acpi/acpica/rscalc.c +++ b/drivers/acpi/acpica/rscalc.c | |||
@@ -174,6 +174,7 @@ acpi_rs_stream_option_length(u32 resource_length, | |||
174 | * FUNCTION: acpi_rs_get_aml_length | 174 | * FUNCTION: acpi_rs_get_aml_length |
175 | * | 175 | * |
176 | * PARAMETERS: resource - Pointer to the resource linked list | 176 | * PARAMETERS: resource - Pointer to the resource linked list |
177 | * resource_list_size - Size of the resource linked list | ||
177 | * size_needed - Where the required size is returned | 178 | * size_needed - Where the required size is returned |
178 | * | 179 | * |
179 | * RETURN: Status | 180 | * RETURN: Status |
@@ -185,16 +186,20 @@ acpi_rs_stream_option_length(u32 resource_length, | |||
185 | ******************************************************************************/ | 186 | ******************************************************************************/ |
186 | 187 | ||
187 | acpi_status | 188 | acpi_status |
188 | acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) | 189 | acpi_rs_get_aml_length(struct acpi_resource *resource, |
190 | acpi_size resource_list_size, acpi_size * size_needed) | ||
189 | { | 191 | { |
190 | acpi_size aml_size_needed = 0; | 192 | acpi_size aml_size_needed = 0; |
193 | struct acpi_resource *resource_end; | ||
191 | acpi_rs_length total_size; | 194 | acpi_rs_length total_size; |
192 | 195 | ||
193 | ACPI_FUNCTION_TRACE(rs_get_aml_length); | 196 | ACPI_FUNCTION_TRACE(rs_get_aml_length); |
194 | 197 | ||
195 | /* Traverse entire list of internal resource descriptors */ | 198 | /* Traverse entire list of internal resource descriptors */ |
196 | 199 | ||
197 | while (resource) { | 200 | resource_end = |
201 | ACPI_ADD_PTR(struct acpi_resource, resource, resource_list_size); | ||
202 | while (resource < resource_end) { | ||
198 | 203 | ||
199 | /* Validate the descriptor type */ | 204 | /* Validate the descriptor type */ |
200 | 205 | ||
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c index 65f3e1c5b598..3a2ace93e62c 100644 --- a/drivers/acpi/acpica/rscreate.c +++ b/drivers/acpi/acpica/rscreate.c | |||
@@ -418,22 +418,21 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
418 | * | 418 | * |
419 | * FUNCTION: acpi_rs_create_aml_resources | 419 | * FUNCTION: acpi_rs_create_aml_resources |
420 | * | 420 | * |
421 | * PARAMETERS: linked_list_buffer - Pointer to the resource linked list | 421 | * PARAMETERS: resource_list - Pointer to the resource list buffer |
422 | * output_buffer - Pointer to the user's buffer | 422 | * output_buffer - Where the AML buffer is returned |
423 | * | 423 | * |
424 | * RETURN: Status AE_OK if okay, else a valid acpi_status code. | 424 | * RETURN: Status AE_OK if okay, else a valid acpi_status code. |
425 | * If the output_buffer is too small, the error will be | 425 | * If the output_buffer is too small, the error will be |
426 | * AE_BUFFER_OVERFLOW and output_buffer->Length will point | 426 | * AE_BUFFER_OVERFLOW and output_buffer->Length will point |
427 | * to the size buffer needed. | 427 | * to the size buffer needed. |
428 | * | 428 | * |
429 | * DESCRIPTION: Takes the linked list of device resources and | 429 | * DESCRIPTION: Converts a list of device resources to an AML bytestream |
430 | * creates a bytestream to be used as input for the | 430 | * to be used as input for the _SRS control method. |
431 | * _SRS control method. | ||
432 | * | 431 | * |
433 | ******************************************************************************/ | 432 | ******************************************************************************/ |
434 | 433 | ||
435 | acpi_status | 434 | acpi_status |
436 | acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | 435 | acpi_rs_create_aml_resources(struct acpi_buffer *resource_list, |
437 | struct acpi_buffer *output_buffer) | 436 | struct acpi_buffer *output_buffer) |
438 | { | 437 | { |
439 | acpi_status status; | 438 | acpi_status status; |
@@ -441,16 +440,16 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | |||
441 | 440 | ||
442 | ACPI_FUNCTION_TRACE(rs_create_aml_resources); | 441 | ACPI_FUNCTION_TRACE(rs_create_aml_resources); |
443 | 442 | ||
444 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "LinkedListBuffer = %p\n", | 443 | /* Params already validated, no need to re-validate here */ |
445 | linked_list_buffer)); | ||
446 | 444 | ||
447 | /* | 445 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ResourceList Buffer = %p\n", |
448 | * Params already validated, so we don't re-validate here | 446 | resource_list->pointer)); |
449 | * | 447 | |
450 | * Pass the linked_list_buffer into a module that calculates | 448 | /* Get the buffer size needed for the AML byte stream */ |
451 | * the buffer size needed for the byte stream. | 449 | |
452 | */ | 450 | status = acpi_rs_get_aml_length(resource_list->pointer, |
453 | status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); | 451 | resource_list->length, |
452 | &aml_size_needed); | ||
454 | 453 | ||
455 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", | 454 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", |
456 | (u32)aml_size_needed, acpi_format_exception(status))); | 455 | (u32)aml_size_needed, acpi_format_exception(status))); |
@@ -467,10 +466,9 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, | |||
467 | 466 | ||
468 | /* Do the conversion */ | 467 | /* Do the conversion */ |
469 | 468 | ||
470 | status = | 469 | status = acpi_rs_convert_resources_to_aml(resource_list->pointer, |
471 | acpi_rs_convert_resources_to_aml(linked_list_buffer, | 470 | aml_size_needed, |
472 | aml_size_needed, | 471 | output_buffer->pointer); |
473 | output_buffer->pointer); | ||
474 | if (ACPI_FAILURE(status)) { | 472 | if (ACPI_FAILURE(status)) { |
475 | return_ACPI_STATUS(status); | 473 | return_ACPI_STATUS(status); |
476 | } | 474 | } |
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c index aef303d56d86..14a7982c9961 100644 --- a/drivers/acpi/acpica/rsutils.c +++ b/drivers/acpi/acpica/rsutils.c | |||
@@ -753,7 +753,7 @@ acpi_rs_set_srs_method_data(struct acpi_namespace_node *node, | |||
753 | * Convert the linked list into a byte stream | 753 | * Convert the linked list into a byte stream |
754 | */ | 754 | */ |
755 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | 755 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; |
756 | status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer); | 756 | status = acpi_rs_create_aml_resources(in_buffer, &buffer); |
757 | if (ACPI_FAILURE(status)) { | 757 | if (ACPI_FAILURE(status)) { |
758 | goto cleanup; | 758 | goto cleanup; |
759 | } | 759 | } |
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index 1a67b3944b3b..03ae8affe48f 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c | |||
@@ -185,6 +185,7 @@ acpi_debug_print(u32 requested_debug_level, | |||
185 | } | 185 | } |
186 | 186 | ||
187 | acpi_gbl_prev_thread_id = thread_id; | 187 | acpi_gbl_prev_thread_id = thread_id; |
188 | acpi_gbl_nesting_level = 0; | ||
188 | } | 189 | } |
189 | 190 | ||
190 | /* | 191 | /* |
@@ -193,13 +194,21 @@ acpi_debug_print(u32 requested_debug_level, | |||
193 | */ | 194 | */ |
194 | acpi_os_printf("%9s-%04ld ", module_name, line_number); | 195 | acpi_os_printf("%9s-%04ld ", module_name, line_number); |
195 | 196 | ||
197 | #ifdef ACPI_EXEC_APP | ||
198 | /* | ||
199 | * For acpi_exec only, emit the thread ID and nesting level. | ||
200 | * Note: nesting level is really only useful during a single-thread | ||
201 | * execution. Otherwise, multiple threads will keep resetting the | ||
202 | * level. | ||
203 | */ | ||
196 | if (ACPI_LV_THREADS & acpi_dbg_level) { | 204 | if (ACPI_LV_THREADS & acpi_dbg_level) { |
197 | acpi_os_printf("[%u] ", (u32)thread_id); | 205 | acpi_os_printf("[%u] ", (u32)thread_id); |
198 | } | 206 | } |
199 | 207 | ||
200 | acpi_os_printf("[%02ld] %-22.22s: ", | 208 | acpi_os_printf("[%02ld] ", acpi_gbl_nesting_level); |
201 | acpi_gbl_nesting_level, | 209 | #endif |
202 | acpi_ut_trim_function_name(function_name)); | 210 | |
211 | acpi_os_printf("%-22.22s: ", acpi_ut_trim_function_name(function_name)); | ||
203 | 212 | ||
204 | va_start(args, format); | 213 | va_start(args, format); |
205 | acpi_os_vprintf(format, args); | 214 | acpi_os_vprintf(format, args); |
@@ -420,7 +429,9 @@ acpi_ut_exit(u32 line_number, | |||
420 | component_id, "%s\n", acpi_gbl_fn_exit_str); | 429 | component_id, "%s\n", acpi_gbl_fn_exit_str); |
421 | } | 430 | } |
422 | 431 | ||
423 | acpi_gbl_nesting_level--; | 432 | if (acpi_gbl_nesting_level) { |
433 | acpi_gbl_nesting_level--; | ||
434 | } | ||
424 | } | 435 | } |
425 | 436 | ||
426 | ACPI_EXPORT_SYMBOL(acpi_ut_exit) | 437 | ACPI_EXPORT_SYMBOL(acpi_ut_exit) |
@@ -467,7 +478,9 @@ acpi_ut_status_exit(u32 line_number, | |||
467 | } | 478 | } |
468 | } | 479 | } |
469 | 480 | ||
470 | acpi_gbl_nesting_level--; | 481 | if (acpi_gbl_nesting_level) { |
482 | acpi_gbl_nesting_level--; | ||
483 | } | ||
471 | } | 484 | } |
472 | 485 | ||
473 | ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) | 486 | ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) |
@@ -504,7 +517,9 @@ acpi_ut_value_exit(u32 line_number, | |||
504 | ACPI_FORMAT_UINT64(value)); | 517 | ACPI_FORMAT_UINT64(value)); |
505 | } | 518 | } |
506 | 519 | ||
507 | acpi_gbl_nesting_level--; | 520 | if (acpi_gbl_nesting_level) { |
521 | acpi_gbl_nesting_level--; | ||
522 | } | ||
508 | } | 523 | } |
509 | 524 | ||
510 | ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) | 525 | ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) |
@@ -540,7 +555,9 @@ acpi_ut_ptr_exit(u32 line_number, | |||
540 | ptr); | 555 | ptr); |
541 | } | 556 | } |
542 | 557 | ||
543 | acpi_gbl_nesting_level--; | 558 | if (acpi_gbl_nesting_level) { |
559 | acpi_gbl_nesting_level--; | ||
560 | } | ||
544 | } | 561 | } |
545 | 562 | ||
546 | #endif | 563 | #endif |
diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c index 266bc58ce0ce..386a9fe497b4 100644 --- a/drivers/acpi/nvs.c +++ b/drivers/acpi/nvs.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/acpi.h> | 14 | #include <linux/acpi.h> |
15 | #include <linux/acpi_io.h> | 15 | #include <linux/acpi_io.h> |
16 | #include <acpi/acpiosxf.h> | ||
17 | 16 | ||
18 | /* ACPI NVS regions, APEI may use it */ | 17 | /* ACPI NVS regions, APEI may use it */ |
19 | 18 | ||
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 0703bff5e60e..20360e480bd8 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -65,6 +65,9 @@ static struct acpi_scan_handler pci_root_handler = { | |||
65 | .ids = root_device_ids, | 65 | .ids = root_device_ids, |
66 | .attach = acpi_pci_root_add, | 66 | .attach = acpi_pci_root_add, |
67 | .detach = acpi_pci_root_remove, | 67 | .detach = acpi_pci_root_remove, |
68 | .hotplug = { | ||
69 | .ignore = true, | ||
70 | }, | ||
68 | }; | 71 | }; |
69 | 72 | ||
70 | static DEFINE_MUTEX(osc_lock); | 73 | static DEFINE_MUTEX(osc_lock); |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 15daa21fcd05..fd39459926b1 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -1772,7 +1772,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type) | |||
1772 | */ | 1772 | */ |
1773 | list_for_each_entry(hwid, &pnp.ids, list) { | 1773 | list_for_each_entry(hwid, &pnp.ids, list) { |
1774 | handler = acpi_scan_match_handler(hwid->id, NULL); | 1774 | handler = acpi_scan_match_handler(hwid->id, NULL); |
1775 | if (handler) { | 1775 | if (handler && !handler->hotplug.ignore) { |
1776 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | 1776 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
1777 | acpi_hotplug_notify_cb, handler); | 1777 | acpi_hotplug_notify_cb, handler); |
1778 | break; | 1778 | break; |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 14df30580e15..721e949e606e 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -525,7 +525,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) | |||
525 | * generate wakeup events. | 525 | * generate wakeup events. |
526 | */ | 526 | */ |
527 | if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) { | 527 | if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) { |
528 | acpi_event_status pwr_btn_status; | 528 | acpi_event_status pwr_btn_status = ACPI_EVENT_FLAG_DISABLED; |
529 | 529 | ||
530 | acpi_get_event_status(ACPI_EVENT_POWER_BUTTON, &pwr_btn_status); | 530 | acpi_get_event_status(ACPI_EVENT_POWER_BUTTON, &pwr_btn_status); |
531 | 531 | ||
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index db5293650f62..6dbc3ca45223 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
@@ -309,7 +309,7 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr, | |||
309 | sprintf(table_attr->name + ACPI_NAME_SIZE, "%d", | 309 | sprintf(table_attr->name + ACPI_NAME_SIZE, "%d", |
310 | table_attr->instance); | 310 | table_attr->instance); |
311 | 311 | ||
312 | table_attr->attr.size = 0; | 312 | table_attr->attr.size = table_header->length; |
313 | table_attr->attr.read = acpi_table_show; | 313 | table_attr->attr.read = acpi_table_show; |
314 | table_attr->attr.attr.name = table_attr->name; | 314 | table_attr->attr.attr.name = table_attr->name; |
315 | table_attr->attr.attr.mode = 0400; | 315 | table_attr->attr.attr.mode = 0400; |
@@ -354,8 +354,9 @@ static int acpi_tables_sysfs_init(void) | |||
354 | { | 354 | { |
355 | struct acpi_table_attr *table_attr; | 355 | struct acpi_table_attr *table_attr; |
356 | struct acpi_table_header *table_header = NULL; | 356 | struct acpi_table_header *table_header = NULL; |
357 | int table_index = 0; | 357 | int table_index; |
358 | int result; | 358 | acpi_status status; |
359 | int ret; | ||
359 | 360 | ||
360 | tables_kobj = kobject_create_and_add("tables", acpi_kobj); | 361 | tables_kobj = kobject_create_and_add("tables", acpi_kobj); |
361 | if (!tables_kobj) | 362 | if (!tables_kobj) |
@@ -365,33 +366,34 @@ static int acpi_tables_sysfs_init(void) | |||
365 | if (!dynamic_tables_kobj) | 366 | if (!dynamic_tables_kobj) |
366 | goto err_dynamic_tables; | 367 | goto err_dynamic_tables; |
367 | 368 | ||
368 | do { | 369 | for (table_index = 0;; table_index++) { |
369 | result = acpi_get_table_by_index(table_index, &table_header); | 370 | status = acpi_get_table_by_index(table_index, &table_header); |
370 | if (!result) { | 371 | |
371 | table_index++; | 372 | if (status == AE_BAD_PARAMETER) |
372 | table_attr = NULL; | 373 | break; |
373 | table_attr = | 374 | |
374 | kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL); | 375 | if (ACPI_FAILURE(status)) |
375 | if (!table_attr) | 376 | continue; |
376 | return -ENOMEM; | 377 | |
377 | 378 | table_attr = NULL; | |
378 | acpi_table_attr_init(table_attr, table_header); | 379 | table_attr = kzalloc(sizeof(*table_attr), GFP_KERNEL); |
379 | result = | 380 | if (!table_attr) |
380 | sysfs_create_bin_file(tables_kobj, | 381 | return -ENOMEM; |
381 | &table_attr->attr); | 382 | |
382 | if (result) { | 383 | acpi_table_attr_init(table_attr, table_header); |
383 | kfree(table_attr); | 384 | ret = sysfs_create_bin_file(tables_kobj, &table_attr->attr); |
384 | return result; | 385 | if (ret) { |
385 | } else | 386 | kfree(table_attr); |
386 | list_add_tail(&table_attr->node, | 387 | return ret; |
387 | &acpi_table_attr_list); | ||
388 | } | 388 | } |
389 | } while (!result); | 389 | list_add_tail(&table_attr->node, &acpi_table_attr_list); |
390 | } | ||
391 | |||
390 | kobject_uevent(tables_kobj, KOBJ_ADD); | 392 | kobject_uevent(tables_kobj, KOBJ_ADD); |
391 | kobject_uevent(dynamic_tables_kobj, KOBJ_ADD); | 393 | kobject_uevent(dynamic_tables_kobj, KOBJ_ADD); |
392 | result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); | 394 | status = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); |
393 | 395 | ||
394 | return result == AE_OK ? 0 : -EINVAL; | 396 | return ACPI_FAILURE(status) ? -EINVAL : 0; |
395 | err_dynamic_tables: | 397 | err_dynamic_tables: |
396 | kobject_put(tables_kobj); | 398 | kobject_put(tables_kobj); |
397 | err: | 399 | err: |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index e2903d03180e..14f1e9506338 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -435,6 +435,8 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
435 | .driver_data = board_ahci_yes_fbs }, /* 88se9172 on some Gigabyte */ | 435 | .driver_data = board_ahci_yes_fbs }, /* 88se9172 on some Gigabyte */ |
436 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a3), | 436 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a3), |
437 | .driver_data = board_ahci_yes_fbs }, | 437 | .driver_data = board_ahci_yes_fbs }, |
438 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230), | ||
439 | .driver_data = board_ahci_yes_fbs }, | ||
438 | 440 | ||
439 | /* Promise */ | 441 | /* Promise */ |
440 | { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */ | 442 | { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */ |
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index f9554318504f..4b231baceb09 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c | |||
@@ -329,6 +329,7 @@ static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume); | |||
329 | static const struct of_device_id ahci_of_match[] = { | 329 | static const struct of_device_id ahci_of_match[] = { |
330 | { .compatible = "snps,spear-ahci", }, | 330 | { .compatible = "snps,spear-ahci", }, |
331 | { .compatible = "snps,exynos5440-ahci", }, | 331 | { .compatible = "snps,exynos5440-ahci", }, |
332 | { .compatible = "ibm,476gtr-ahci", }, | ||
332 | {}, | 333 | {}, |
333 | }; | 334 | }; |
334 | MODULE_DEVICE_TABLE(of, ahci_of_match); | 335 | MODULE_DEVICE_TABLE(of, ahci_of_match); |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 81a94a3919db..75b93678bbcd 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -6304,10 +6304,9 @@ static void ata_port_detach(struct ata_port *ap) | |||
6304 | for (i = 0; i < SATA_PMP_MAX_PORTS; i++) | 6304 | for (i = 0; i < SATA_PMP_MAX_PORTS; i++) |
6305 | ata_tlink_delete(&ap->pmp_link[i]); | 6305 | ata_tlink_delete(&ap->pmp_link[i]); |
6306 | } | 6306 | } |
6307 | ata_tport_delete(ap); | ||
6308 | |||
6309 | /* remove the associated SCSI host */ | 6307 | /* remove the associated SCSI host */ |
6310 | scsi_remove_host(ap->scsi_host); | 6308 | scsi_remove_host(ap->scsi_host); |
6309 | ata_tport_delete(ap); | ||
6311 | } | 6310 | } |
6312 | 6311 | ||
6313 | /** | 6312 | /** |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index db6dfcfa3e2e..ab58556d347c 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -3625,6 +3625,7 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht) | |||
3625 | shost->max_lun = 1; | 3625 | shost->max_lun = 1; |
3626 | shost->max_channel = 1; | 3626 | shost->max_channel = 1; |
3627 | shost->max_cmd_len = 16; | 3627 | shost->max_cmd_len = 16; |
3628 | shost->no_write_same = 1; | ||
3628 | 3629 | ||
3629 | /* Schedule policy is determined by ->qc_defer() | 3630 | /* Schedule policy is determined by ->qc_defer() |
3630 | * callback and it needs to see every deferred qc. | 3631 | * callback and it needs to see every deferred qc. |
diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c index 68f9e3293e9c..88949c6d55dd 100644 --- a/drivers/ata/libata-zpodd.c +++ b/drivers/ata/libata-zpodd.c | |||
@@ -88,15 +88,13 @@ static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev) | |||
88 | static bool odd_can_poweroff(struct ata_device *ata_dev) | 88 | static bool odd_can_poweroff(struct ata_device *ata_dev) |
89 | { | 89 | { |
90 | acpi_handle handle; | 90 | acpi_handle handle; |
91 | acpi_status status; | ||
92 | struct acpi_device *acpi_dev; | 91 | struct acpi_device *acpi_dev; |
93 | 92 | ||
94 | handle = ata_dev_acpi_handle(ata_dev); | 93 | handle = ata_dev_acpi_handle(ata_dev); |
95 | if (!handle) | 94 | if (!handle) |
96 | return false; | 95 | return false; |
97 | 96 | ||
98 | status = acpi_bus_get_device(handle, &acpi_dev); | 97 | if (acpi_bus_get_device(handle, &acpi_dev)) |
99 | if (ACPI_FAILURE(status)) | ||
100 | return false; | 98 | return false; |
101 | 99 | ||
102 | return acpi_device_can_poweroff(acpi_dev); | 100 | return acpi_device_can_poweroff(acpi_dev); |
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c index e88690ebfd82..73492dd4a4bc 100644 --- a/drivers/ata/pata_arasan_cf.c +++ b/drivers/ata/pata_arasan_cf.c | |||
@@ -319,6 +319,7 @@ static int cf_init(struct arasan_cf_dev *acdev) | |||
319 | ret = clk_set_rate(acdev->clk, 166000000); | 319 | ret = clk_set_rate(acdev->clk, 166000000); |
320 | if (ret) { | 320 | if (ret) { |
321 | dev_warn(acdev->host->dev, "clock set rate failed"); | 321 | dev_warn(acdev->host->dev, "clock set rate failed"); |
322 | clk_disable_unprepare(acdev->clk); | ||
322 | return ret; | 323 | return ret; |
323 | } | 324 | } |
324 | 325 | ||
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 1b41fca3d65a..e3219dfd736c 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/async.h> | 29 | #include <linux/async.h> |
30 | #include <linux/suspend.h> | 30 | #include <linux/suspend.h> |
31 | #include <trace/events/power.h> | 31 | #include <trace/events/power.h> |
32 | #include <linux/cpufreq.h> | ||
32 | #include <linux/cpuidle.h> | 33 | #include <linux/cpuidle.h> |
33 | #include <linux/timer.h> | 34 | #include <linux/timer.h> |
34 | 35 | ||
@@ -540,6 +541,7 @@ static void dpm_resume_noirq(pm_message_t state) | |||
540 | dpm_show_time(starttime, state, "noirq"); | 541 | dpm_show_time(starttime, state, "noirq"); |
541 | resume_device_irqs(); | 542 | resume_device_irqs(); |
542 | cpuidle_resume(); | 543 | cpuidle_resume(); |
544 | cpufreq_resume(); | ||
543 | } | 545 | } |
544 | 546 | ||
545 | /** | 547 | /** |
@@ -955,6 +957,7 @@ static int dpm_suspend_noirq(pm_message_t state) | |||
955 | ktime_t starttime = ktime_get(); | 957 | ktime_t starttime = ktime_get(); |
956 | int error = 0; | 958 | int error = 0; |
957 | 959 | ||
960 | cpufreq_suspend(); | ||
958 | cpuidle_pause(); | 961 | cpuidle_pause(); |
959 | suspend_device_irqs(); | 962 | suspend_device_irqs(); |
960 | mutex_lock(&dpm_list_mtx); | 963 | mutex_lock(&dpm_list_mtx); |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 432db1b59b00..c4a4c9006288 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -489,7 +489,7 @@ static int blkif_queue_request(struct request *req) | |||
489 | 489 | ||
490 | if ((ring_req->operation == BLKIF_OP_INDIRECT) && | 490 | if ((ring_req->operation == BLKIF_OP_INDIRECT) && |
491 | (i % SEGS_PER_INDIRECT_FRAME == 0)) { | 491 | (i % SEGS_PER_INDIRECT_FRAME == 0)) { |
492 | unsigned long pfn; | 492 | unsigned long uninitialized_var(pfn); |
493 | 493 | ||
494 | if (segments) | 494 | if (segments) |
495 | kunmap_atomic(segments); | 495 | kunmap_atomic(segments); |
@@ -2011,6 +2011,10 @@ static void blkif_release(struct gendisk *disk, fmode_t mode) | |||
2011 | 2011 | ||
2012 | bdev = bdget_disk(disk, 0); | 2012 | bdev = bdget_disk(disk, 0); |
2013 | 2013 | ||
2014 | if (!bdev) { | ||
2015 | WARN(1, "Block device %s yanked out from us!\n", disk->disk_name); | ||
2016 | goto out_mutex; | ||
2017 | } | ||
2014 | if (bdev->bd_openers) | 2018 | if (bdev->bd_openers) |
2015 | goto out; | 2019 | goto out; |
2016 | 2020 | ||
@@ -2041,6 +2045,7 @@ static void blkif_release(struct gendisk *disk, fmode_t mode) | |||
2041 | 2045 | ||
2042 | out: | 2046 | out: |
2043 | bdput(bdev); | 2047 | bdput(bdev); |
2048 | out_mutex: | ||
2044 | mutex_unlock(&blkfront_mutex); | 2049 | mutex_unlock(&blkfront_mutex); |
2045 | } | 2050 | } |
2046 | 2051 | ||
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index c206de2951f2..2f2b08457c67 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig | |||
@@ -165,6 +165,19 @@ config HW_RANDOM_OMAP | |||
165 | 165 | ||
166 | If unsure, say Y. | 166 | If unsure, say Y. |
167 | 167 | ||
168 | config HW_RANDOM_OMAP3_ROM | ||
169 | tristate "OMAP3 ROM Random Number Generator support" | ||
170 | depends on HW_RANDOM && ARCH_OMAP3 | ||
171 | default HW_RANDOM | ||
172 | ---help--- | ||
173 | This driver provides kernel-side support for the Random Number | ||
174 | Generator hardware found on OMAP34xx processors. | ||
175 | |||
176 | To compile this driver as a module, choose M here: the | ||
177 | module will be called omap3-rom-rng. | ||
178 | |||
179 | If unsure, say Y. | ||
180 | |||
168 | config HW_RANDOM_OCTEON | 181 | config HW_RANDOM_OCTEON |
169 | tristate "Octeon Random Number Generator support" | 182 | tristate "Octeon Random Number Generator support" |
170 | depends on HW_RANDOM && CAVIUM_OCTEON_SOC | 183 | depends on HW_RANDOM && CAVIUM_OCTEON_SOC |
@@ -327,3 +340,15 @@ config HW_RANDOM_TPM | |||
327 | module will be called tpm-rng. | 340 | module will be called tpm-rng. |
328 | 341 | ||
329 | If unsure, say Y. | 342 | If unsure, say Y. |
343 | |||
344 | config HW_RANDOM_MSM | ||
345 | tristate "Qualcomm MSM Random Number Generator support" | ||
346 | depends on HW_RANDOM && ARCH_MSM | ||
347 | ---help--- | ||
348 | This driver provides kernel-side support for the Random Number | ||
349 | Generator hardware found on Qualcomm MSM SoCs. | ||
350 | |||
351 | To compile this driver as a module, choose M here. the | ||
352 | module will be called msm-rng. | ||
353 | |||
354 | If unsure, say Y. | ||
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index d7d2435ff7fa..3ae7755a52e7 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile | |||
@@ -15,6 +15,7 @@ n2-rng-y := n2-drv.o n2-asm.o | |||
15 | obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o | 15 | obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o |
16 | obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o | 16 | obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o |
17 | obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o | 17 | obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o |
18 | obj-$(CONFIG_HW_RANDOM_OMAP3_ROM) += omap3-rom-rng.o | ||
18 | obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o | 19 | obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o |
19 | obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o | 20 | obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o |
20 | obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o | 21 | obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o |
@@ -28,3 +29,4 @@ obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o | |||
28 | obj-$(CONFIG_HW_RANDOM_EXYNOS) += exynos-rng.o | 29 | obj-$(CONFIG_HW_RANDOM_EXYNOS) += exynos-rng.o |
29 | obj-$(CONFIG_HW_RANDOM_TPM) += tpm-rng.o | 30 | obj-$(CONFIG_HW_RANDOM_TPM) += tpm-rng.o |
30 | obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o | 31 | obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o |
32 | obj-$(CONFIG_HW_RANDOM_MSM) += msm-rng.o | ||
diff --git a/drivers/char/hw_random/msm-rng.c b/drivers/char/hw_random/msm-rng.c new file mode 100644 index 000000000000..148521e51dc6 --- /dev/null +++ b/drivers/char/hw_random/msm-rng.c | |||
@@ -0,0 +1,197 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 and | ||
6 | * only version 2 as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | */ | ||
14 | #include <linux/clk.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/hw_random.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/of.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | |||
22 | /* Device specific register offsets */ | ||
23 | #define PRNG_DATA_OUT 0x0000 | ||
24 | #define PRNG_STATUS 0x0004 | ||
25 | #define PRNG_LFSR_CFG 0x0100 | ||
26 | #define PRNG_CONFIG 0x0104 | ||
27 | |||
28 | /* Device specific register masks and config values */ | ||
29 | #define PRNG_LFSR_CFG_MASK 0x0000ffff | ||
30 | #define PRNG_LFSR_CFG_CLOCKS 0x0000dddd | ||
31 | #define PRNG_CONFIG_HW_ENABLE BIT(1) | ||
32 | #define PRNG_STATUS_DATA_AVAIL BIT(0) | ||
33 | |||
34 | #define MAX_HW_FIFO_DEPTH 16 | ||
35 | #define MAX_HW_FIFO_SIZE (MAX_HW_FIFO_DEPTH * 4) | ||
36 | #define WORD_SZ 4 | ||
37 | |||
38 | struct msm_rng { | ||
39 | void __iomem *base; | ||
40 | struct clk *clk; | ||
41 | struct hwrng hwrng; | ||
42 | }; | ||
43 | |||
44 | #define to_msm_rng(p) container_of(p, struct msm_rng, hwrng) | ||
45 | |||
46 | static int msm_rng_enable(struct hwrng *hwrng, int enable) | ||
47 | { | ||
48 | struct msm_rng *rng = to_msm_rng(hwrng); | ||
49 | u32 val; | ||
50 | int ret; | ||
51 | |||
52 | ret = clk_prepare_enable(rng->clk); | ||
53 | if (ret) | ||
54 | return ret; | ||
55 | |||
56 | if (enable) { | ||
57 | /* Enable PRNG only if it is not already enabled */ | ||
58 | val = readl_relaxed(rng->base + PRNG_CONFIG); | ||
59 | if (val & PRNG_CONFIG_HW_ENABLE) | ||
60 | goto already_enabled; | ||
61 | |||
62 | val = readl_relaxed(rng->base + PRNG_LFSR_CFG); | ||
63 | val &= ~PRNG_LFSR_CFG_MASK; | ||
64 | val |= PRNG_LFSR_CFG_CLOCKS; | ||
65 | writel(val, rng->base + PRNG_LFSR_CFG); | ||
66 | |||
67 | val = readl_relaxed(rng->base + PRNG_CONFIG); | ||
68 | val |= PRNG_CONFIG_HW_ENABLE; | ||
69 | writel(val, rng->base + PRNG_CONFIG); | ||
70 | } else { | ||
71 | val = readl_relaxed(rng->base + PRNG_CONFIG); | ||
72 | val &= ~PRNG_CONFIG_HW_ENABLE; | ||
73 | writel(val, rng->base + PRNG_CONFIG); | ||
74 | } | ||
75 | |||
76 | already_enabled: | ||
77 | clk_disable_unprepare(rng->clk); | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static int msm_rng_read(struct hwrng *hwrng, void *data, size_t max, bool wait) | ||
82 | { | ||
83 | struct msm_rng *rng = to_msm_rng(hwrng); | ||
84 | size_t currsize = 0; | ||
85 | u32 *retdata = data; | ||
86 | size_t maxsize; | ||
87 | int ret; | ||
88 | u32 val; | ||
89 | |||
90 | /* calculate max size bytes to transfer back to caller */ | ||
91 | maxsize = min_t(size_t, MAX_HW_FIFO_SIZE, max); | ||
92 | |||
93 | /* no room for word data */ | ||
94 | if (maxsize < WORD_SZ) | ||
95 | return 0; | ||
96 | |||
97 | ret = clk_prepare_enable(rng->clk); | ||
98 | if (ret) | ||
99 | return ret; | ||
100 | |||
101 | /* read random data from hardware */ | ||
102 | do { | ||
103 | val = readl_relaxed(rng->base + PRNG_STATUS); | ||
104 | if (!(val & PRNG_STATUS_DATA_AVAIL)) | ||
105 | break; | ||
106 | |||
107 | val = readl_relaxed(rng->base + PRNG_DATA_OUT); | ||
108 | if (!val) | ||
109 | break; | ||
110 | |||
111 | *retdata++ = val; | ||
112 | currsize += WORD_SZ; | ||
113 | |||
114 | /* make sure we stay on 32bit boundary */ | ||
115 | if ((maxsize - currsize) < WORD_SZ) | ||
116 | break; | ||
117 | } while (currsize < maxsize); | ||
118 | |||
119 | clk_disable_unprepare(rng->clk); | ||
120 | |||
121 | return currsize; | ||
122 | } | ||
123 | |||
124 | static int msm_rng_init(struct hwrng *hwrng) | ||
125 | { | ||
126 | return msm_rng_enable(hwrng, 1); | ||
127 | } | ||
128 | |||
129 | static void msm_rng_cleanup(struct hwrng *hwrng) | ||
130 | { | ||
131 | msm_rng_enable(hwrng, 0); | ||
132 | } | ||
133 | |||
134 | static int msm_rng_probe(struct platform_device *pdev) | ||
135 | { | ||
136 | struct resource *res; | ||
137 | struct msm_rng *rng; | ||
138 | int ret; | ||
139 | |||
140 | rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); | ||
141 | if (!rng) | ||
142 | return -ENOMEM; | ||
143 | |||
144 | platform_set_drvdata(pdev, rng); | ||
145 | |||
146 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
147 | rng->base = devm_ioremap_resource(&pdev->dev, res); | ||
148 | if (IS_ERR(rng->base)) | ||
149 | return PTR_ERR(rng->base); | ||
150 | |||
151 | rng->clk = devm_clk_get(&pdev->dev, "core"); | ||
152 | if (IS_ERR(rng->clk)) | ||
153 | return PTR_ERR(rng->clk); | ||
154 | |||
155 | rng->hwrng.name = KBUILD_MODNAME, | ||
156 | rng->hwrng.init = msm_rng_init, | ||
157 | rng->hwrng.cleanup = msm_rng_cleanup, | ||
158 | rng->hwrng.read = msm_rng_read, | ||
159 | |||
160 | ret = hwrng_register(&rng->hwrng); | ||
161 | if (ret) { | ||
162 | dev_err(&pdev->dev, "failed to register hwrng\n"); | ||
163 | return ret; | ||
164 | } | ||
165 | |||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | static int msm_rng_remove(struct platform_device *pdev) | ||
170 | { | ||
171 | struct msm_rng *rng = platform_get_drvdata(pdev); | ||
172 | |||
173 | hwrng_unregister(&rng->hwrng); | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | static const struct of_device_id msm_rng_of_match[] = { | ||
178 | { .compatible = "qcom,prng", }, | ||
179 | {} | ||
180 | }; | ||
181 | MODULE_DEVICE_TABLE(of, msm_rng_of_match); | ||
182 | |||
183 | static struct platform_driver msm_rng_driver = { | ||
184 | .probe = msm_rng_probe, | ||
185 | .remove = msm_rng_remove, | ||
186 | .driver = { | ||
187 | .name = KBUILD_MODNAME, | ||
188 | .owner = THIS_MODULE, | ||
189 | .of_match_table = of_match_ptr(msm_rng_of_match), | ||
190 | } | ||
191 | }; | ||
192 | module_platform_driver(msm_rng_driver); | ||
193 | |||
194 | MODULE_ALIAS("platform:" KBUILD_MODNAME); | ||
195 | MODULE_AUTHOR("The Linux Foundation"); | ||
196 | MODULE_DESCRIPTION("Qualcomm MSM random number generator driver"); | ||
197 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/char/hw_random/omap3-rom-rng.c b/drivers/char/hw_random/omap3-rom-rng.c new file mode 100644 index 000000000000..c853e9e68573 --- /dev/null +++ b/drivers/char/hw_random/omap3-rom-rng.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * omap3-rom-rng.c - RNG driver for TI OMAP3 CPU family | ||
3 | * | ||
4 | * Copyright (C) 2009 Nokia Corporation | ||
5 | * Author: Juha Yrjola <juha.yrjola@solidboot.com> | ||
6 | * | ||
7 | * Copyright (C) 2013 Pali Rohár <pali.rohar@gmail.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/random.h> | ||
19 | #include <linux/hw_random.h> | ||
20 | #include <linux/timer.h> | ||
21 | #include <linux/clk.h> | ||
22 | #include <linux/err.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | |||
25 | #define RNG_RESET 0x01 | ||
26 | #define RNG_GEN_PRNG_HW_INIT 0x02 | ||
27 | #define RNG_GEN_HW 0x08 | ||
28 | |||
29 | /* param1: ptr, param2: count, param3: flag */ | ||
30 | static u32 (*omap3_rom_rng_call)(u32, u32, u32); | ||
31 | |||
32 | static struct timer_list idle_timer; | ||
33 | static int rng_idle; | ||
34 | static struct clk *rng_clk; | ||
35 | |||
36 | static void omap3_rom_rng_idle(unsigned long data) | ||
37 | { | ||
38 | int r; | ||
39 | |||
40 | r = omap3_rom_rng_call(0, 0, RNG_RESET); | ||
41 | if (r != 0) { | ||
42 | pr_err("reset failed: %d\n", r); | ||
43 | return; | ||
44 | } | ||
45 | clk_disable_unprepare(rng_clk); | ||
46 | rng_idle = 1; | ||
47 | } | ||
48 | |||
49 | static int omap3_rom_rng_get_random(void *buf, unsigned int count) | ||
50 | { | ||
51 | u32 r; | ||
52 | u32 ptr; | ||
53 | |||
54 | del_timer_sync(&idle_timer); | ||
55 | if (rng_idle) { | ||
56 | clk_prepare_enable(rng_clk); | ||
57 | r = omap3_rom_rng_call(0, 0, RNG_GEN_PRNG_HW_INIT); | ||
58 | if (r != 0) { | ||
59 | clk_disable_unprepare(rng_clk); | ||
60 | pr_err("HW init failed: %d\n", r); | ||
61 | return -EIO; | ||
62 | } | ||
63 | rng_idle = 0; | ||
64 | } | ||
65 | |||
66 | ptr = virt_to_phys(buf); | ||
67 | r = omap3_rom_rng_call(ptr, count, RNG_GEN_HW); | ||
68 | mod_timer(&idle_timer, jiffies + msecs_to_jiffies(500)); | ||
69 | if (r != 0) | ||
70 | return -EINVAL; | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static int omap3_rom_rng_data_present(struct hwrng *rng, int wait) | ||
75 | { | ||
76 | return 1; | ||
77 | } | ||
78 | |||
79 | static int omap3_rom_rng_data_read(struct hwrng *rng, u32 *data) | ||
80 | { | ||
81 | int r; | ||
82 | |||
83 | r = omap3_rom_rng_get_random(data, 4); | ||
84 | if (r < 0) | ||
85 | return r; | ||
86 | return 4; | ||
87 | } | ||
88 | |||
89 | static struct hwrng omap3_rom_rng_ops = { | ||
90 | .name = "omap3-rom", | ||
91 | .data_present = omap3_rom_rng_data_present, | ||
92 | .data_read = omap3_rom_rng_data_read, | ||
93 | }; | ||
94 | |||
95 | static int omap3_rom_rng_probe(struct platform_device *pdev) | ||
96 | { | ||
97 | pr_info("initializing\n"); | ||
98 | |||
99 | omap3_rom_rng_call = pdev->dev.platform_data; | ||
100 | if (!omap3_rom_rng_call) { | ||
101 | pr_err("omap3_rom_rng_call is NULL\n"); | ||
102 | return -EINVAL; | ||
103 | } | ||
104 | |||
105 | setup_timer(&idle_timer, omap3_rom_rng_idle, 0); | ||
106 | rng_clk = clk_get(&pdev->dev, "ick"); | ||
107 | if (IS_ERR(rng_clk)) { | ||
108 | pr_err("unable to get RNG clock\n"); | ||
109 | return PTR_ERR(rng_clk); | ||
110 | } | ||
111 | |||
112 | /* Leave the RNG in reset state. */ | ||
113 | clk_prepare_enable(rng_clk); | ||
114 | omap3_rom_rng_idle(0); | ||
115 | |||
116 | return hwrng_register(&omap3_rom_rng_ops); | ||
117 | } | ||
118 | |||
119 | static int omap3_rom_rng_remove(struct platform_device *pdev) | ||
120 | { | ||
121 | hwrng_unregister(&omap3_rom_rng_ops); | ||
122 | clk_disable_unprepare(rng_clk); | ||
123 | clk_put(rng_clk); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static struct platform_driver omap3_rom_rng_driver = { | ||
128 | .driver = { | ||
129 | .name = "omap3-rom-rng", | ||
130 | .owner = THIS_MODULE, | ||
131 | }, | ||
132 | .probe = omap3_rom_rng_probe, | ||
133 | .remove = omap3_rom_rng_remove, | ||
134 | }; | ||
135 | |||
136 | module_platform_driver(omap3_rom_rng_driver); | ||
137 | |||
138 | MODULE_ALIAS("platform:omap3-rom-rng"); | ||
139 | MODULE_AUTHOR("Juha Yrjola"); | ||
140 | MODULE_AUTHOR("Pali Rohár <pali.rohar@gmail.com>"); | ||
141 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/char/hw_random/pseries-rng.c b/drivers/char/hw_random/pseries-rng.c index b761459a3436..ab7ffdec0ec3 100644 --- a/drivers/char/hw_random/pseries-rng.c +++ b/drivers/char/hw_random/pseries-rng.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/hw_random.h> | 24 | #include <linux/hw_random.h> |
25 | #include <asm/vio.h> | 25 | #include <asm/vio.h> |
26 | 26 | ||
27 | #define MODULE_NAME "pseries-rng" | ||
28 | 27 | ||
29 | static int pseries_rng_data_read(struct hwrng *rng, u32 *data) | 28 | static int pseries_rng_data_read(struct hwrng *rng, u32 *data) |
30 | { | 29 | { |
@@ -55,7 +54,7 @@ static unsigned long pseries_rng_get_desired_dma(struct vio_dev *vdev) | |||
55 | }; | 54 | }; |
56 | 55 | ||
57 | static struct hwrng pseries_rng = { | 56 | static struct hwrng pseries_rng = { |
58 | .name = MODULE_NAME, | 57 | .name = KBUILD_MODNAME, |
59 | .data_read = pseries_rng_data_read, | 58 | .data_read = pseries_rng_data_read, |
60 | }; | 59 | }; |
61 | 60 | ||
@@ -78,7 +77,7 @@ static struct vio_device_id pseries_rng_driver_ids[] = { | |||
78 | MODULE_DEVICE_TABLE(vio, pseries_rng_driver_ids); | 77 | MODULE_DEVICE_TABLE(vio, pseries_rng_driver_ids); |
79 | 78 | ||
80 | static struct vio_driver pseries_rng_driver = { | 79 | static struct vio_driver pseries_rng_driver = { |
81 | .name = MODULE_NAME, | 80 | .name = KBUILD_MODNAME, |
82 | .probe = pseries_rng_probe, | 81 | .probe = pseries_rng_probe, |
83 | .remove = pseries_rng_remove, | 82 | .remove = pseries_rng_remove, |
84 | .get_desired_dma = pseries_rng_get_desired_dma, | 83 | .get_desired_dma = pseries_rng_get_desired_dma, |
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c index e737772ad69a..de5a6dcfb3e2 100644 --- a/drivers/char/hw_random/via-rng.c +++ b/drivers/char/hw_random/via-rng.c | |||
@@ -221,7 +221,7 @@ static void __exit mod_exit(void) | |||
221 | module_init(mod_init); | 221 | module_init(mod_init); |
222 | module_exit(mod_exit); | 222 | module_exit(mod_exit); |
223 | 223 | ||
224 | static struct x86_cpu_id via_rng_cpu_id[] = { | 224 | static struct x86_cpu_id __maybe_unused via_rng_cpu_id[] = { |
225 | X86_FEATURE_MATCH(X86_FEATURE_XSTORE), | 225 | X86_FEATURE_MATCH(X86_FEATURE_XSTORE), |
226 | {} | 226 | {} |
227 | }; | 227 | }; |
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index bdb953e15d2a..5c07a56962db 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig | |||
@@ -87,6 +87,7 @@ config ARM_ARCH_TIMER | |||
87 | config ARM_ARCH_TIMER_EVTSTREAM | 87 | config ARM_ARCH_TIMER_EVTSTREAM |
88 | bool "Support for ARM architected timer event stream generation" | 88 | bool "Support for ARM architected timer event stream generation" |
89 | default y if ARM_ARCH_TIMER | 89 | default y if ARM_ARCH_TIMER |
90 | depends on ARM_ARCH_TIMER | ||
90 | help | 91 | help |
91 | This option enables support for event stream generation based on | 92 | This option enables support for event stream generation based on |
92 | the ARM architected timer. It is used for waking up CPUs executing | 93 | the ARM architected timer. It is used for waking up CPUs executing |
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 4aac9ee0d0c0..3cf12834681e 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c | |||
@@ -313,8 +313,20 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) | |||
313 | goto err1; | 313 | goto err1; |
314 | } | 314 | } |
315 | 315 | ||
316 | return sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev), | 316 | ret = clk_prepare(p->clk); |
317 | cfg->clockevent_rating); | 317 | if (ret < 0) |
318 | goto err2; | ||
319 | |||
320 | ret = sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev), | ||
321 | cfg->clockevent_rating); | ||
322 | if (ret < 0) | ||
323 | goto err3; | ||
324 | |||
325 | return 0; | ||
326 | err3: | ||
327 | clk_unprepare(p->clk); | ||
328 | err2: | ||
329 | clk_put(p->clk); | ||
318 | err1: | 330 | err1: |
319 | iounmap(p->mapbase); | 331 | iounmap(p->mapbase); |
320 | err0: | 332 | err0: |
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 78b8dae49628..63557cda0a7d 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c | |||
@@ -472,12 +472,26 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) | |||
472 | ret = PTR_ERR(p->clk); | 472 | ret = PTR_ERR(p->clk); |
473 | goto err1; | 473 | goto err1; |
474 | } | 474 | } |
475 | |||
476 | ret = clk_prepare(p->clk); | ||
477 | if (ret < 0) | ||
478 | goto err2; | ||
479 | |||
475 | p->cs_enabled = false; | 480 | p->cs_enabled = false; |
476 | p->enable_count = 0; | 481 | p->enable_count = 0; |
477 | 482 | ||
478 | return sh_tmu_register(p, (char *)dev_name(&p->pdev->dev), | 483 | ret = sh_tmu_register(p, (char *)dev_name(&p->pdev->dev), |
479 | cfg->clockevent_rating, | 484 | cfg->clockevent_rating, |
480 | cfg->clocksource_rating); | 485 | cfg->clocksource_rating); |
486 | if (ret < 0) | ||
487 | goto err3; | ||
488 | |||
489 | return 0; | ||
490 | |||
491 | err3: | ||
492 | clk_unprepare(p->clk); | ||
493 | err2: | ||
494 | clk_put(p->clk); | ||
481 | err1: | 495 | err1: |
482 | iounmap(p->mapbase); | 496 | iounmap(p->mapbase); |
483 | err0: | 497 | err0: |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 02d534da22dd..81e9d4412db8 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/suspend.h> | ||
29 | #include <linux/syscore_ops.h> | 30 | #include <linux/syscore_ops.h> |
30 | #include <linux/tick.h> | 31 | #include <linux/tick.h> |
31 | #include <trace/events/power.h> | 32 | #include <trace/events/power.h> |
@@ -47,6 +48,9 @@ static LIST_HEAD(cpufreq_policy_list); | |||
47 | static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); | 48 | static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); |
48 | #endif | 49 | #endif |
49 | 50 | ||
51 | /* Flag to suspend/resume CPUFreq governors */ | ||
52 | static bool cpufreq_suspended; | ||
53 | |||
50 | static inline bool has_target(void) | 54 | static inline bool has_target(void) |
51 | { | 55 | { |
52 | return cpufreq_driver->target_index || cpufreq_driver->target; | 56 | return cpufreq_driver->target_index || cpufreq_driver->target; |
@@ -1462,6 +1466,41 @@ static struct subsys_interface cpufreq_interface = { | |||
1462 | .remove_dev = cpufreq_remove_dev, | 1466 | .remove_dev = cpufreq_remove_dev, |
1463 | }; | 1467 | }; |
1464 | 1468 | ||
1469 | void cpufreq_suspend(void) | ||
1470 | { | ||
1471 | struct cpufreq_policy *policy; | ||
1472 | |||
1473 | if (!has_target()) | ||
1474 | return; | ||
1475 | |||
1476 | pr_debug("%s: Suspending Governors\n", __func__); | ||
1477 | |||
1478 | list_for_each_entry(policy, &cpufreq_policy_list, policy_list) | ||
1479 | if (__cpufreq_governor(policy, CPUFREQ_GOV_STOP)) | ||
1480 | pr_err("%s: Failed to stop governor for policy: %p\n", | ||
1481 | __func__, policy); | ||
1482 | |||
1483 | cpufreq_suspended = true; | ||
1484 | } | ||
1485 | |||
1486 | void cpufreq_resume(void) | ||
1487 | { | ||
1488 | struct cpufreq_policy *policy; | ||
1489 | |||
1490 | if (!has_target()) | ||
1491 | return; | ||
1492 | |||
1493 | pr_debug("%s: Resuming Governors\n", __func__); | ||
1494 | |||
1495 | cpufreq_suspended = false; | ||
1496 | |||
1497 | list_for_each_entry(policy, &cpufreq_policy_list, policy_list) | ||
1498 | if (__cpufreq_governor(policy, CPUFREQ_GOV_START) | ||
1499 | || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS)) | ||
1500 | pr_err("%s: Failed to start governor for policy: %p\n", | ||
1501 | __func__, policy); | ||
1502 | } | ||
1503 | |||
1465 | /** | 1504 | /** |
1466 | * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. | 1505 | * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. |
1467 | * | 1506 | * |
@@ -1764,6 +1803,10 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1764 | struct cpufreq_governor *gov = NULL; | 1803 | struct cpufreq_governor *gov = NULL; |
1765 | #endif | 1804 | #endif |
1766 | 1805 | ||
1806 | /* Don't start any governor operations if we are entering suspend */ | ||
1807 | if (cpufreq_suspended) | ||
1808 | return 0; | ||
1809 | |||
1767 | if (policy->governor->max_transition_latency && | 1810 | if (policy->governor->max_transition_latency && |
1768 | policy->cpuinfo.transition_latency > | 1811 | policy->cpuinfo.transition_latency > |
1769 | policy->governor->max_transition_latency) { | 1812 | policy->governor->max_transition_latency) { |
@@ -2076,9 +2119,6 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, | |||
2076 | dev = get_cpu_device(cpu); | 2119 | dev = get_cpu_device(cpu); |
2077 | if (dev) { | 2120 | if (dev) { |
2078 | 2121 | ||
2079 | if (action & CPU_TASKS_FROZEN) | ||
2080 | frozen = true; | ||
2081 | |||
2082 | switch (action & ~CPU_TASKS_FROZEN) { | 2122 | switch (action & ~CPU_TASKS_FROZEN) { |
2083 | case CPU_ONLINE: | 2123 | case CPU_ONLINE: |
2084 | __cpufreq_add_dev(dev, NULL, frozen); | 2124 | __cpufreq_add_dev(dev, NULL, frozen); |
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c index f2c75065ce19..dfd1643b0b2f 100644 --- a/drivers/cpufreq/exynos4210-cpufreq.c +++ b/drivers/cpufreq/exynos4210-cpufreq.c | |||
@@ -157,4 +157,3 @@ err_moutcore: | |||
157 | pr_debug("%s: failed initialization\n", __func__); | 157 | pr_debug("%s: failed initialization\n", __func__); |
158 | return -EINVAL; | 158 | return -EINVAL; |
159 | } | 159 | } |
160 | EXPORT_SYMBOL(exynos4210_cpufreq_init); | ||
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c index 8683304ce62c..efad5e657f6f 100644 --- a/drivers/cpufreq/exynos4x12-cpufreq.c +++ b/drivers/cpufreq/exynos4x12-cpufreq.c | |||
@@ -211,4 +211,3 @@ err_moutcore: | |||
211 | pr_debug("%s: failed initialization\n", __func__); | 211 | pr_debug("%s: failed initialization\n", __func__); |
212 | return -EINVAL; | 212 | return -EINVAL; |
213 | } | 213 | } |
214 | EXPORT_SYMBOL(exynos4x12_cpufreq_init); | ||
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c index 9fae466d7746..8feda86fe42c 100644 --- a/drivers/cpufreq/exynos5250-cpufreq.c +++ b/drivers/cpufreq/exynos5250-cpufreq.c | |||
@@ -236,4 +236,3 @@ err_moutcore: | |||
236 | pr_err("%s: failed initialization\n", __func__); | 236 | pr_err("%s: failed initialization\n", __func__); |
237 | return -EINVAL; | 237 | return -EINVAL; |
238 | } | 238 | } |
239 | EXPORT_SYMBOL(exynos5250_cpufreq_init); | ||
diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c index f42df7ec03c5..b7309c37033d 100644 --- a/drivers/cpufreq/tegra-cpufreq.c +++ b/drivers/cpufreq/tegra-cpufreq.c | |||
@@ -142,10 +142,8 @@ static int tegra_target(struct cpufreq_policy *policy, unsigned int index) | |||
142 | 142 | ||
143 | mutex_lock(&tegra_cpu_lock); | 143 | mutex_lock(&tegra_cpu_lock); |
144 | 144 | ||
145 | if (is_suspended) { | 145 | if (is_suspended) |
146 | ret = -EBUSY; | ||
147 | goto out; | 146 | goto out; |
148 | } | ||
149 | 147 | ||
150 | freq = freq_table[index].frequency; | 148 | freq = freq_table[index].frequency; |
151 | 149 | ||
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 2a991e468f78..a55e68f2cfc8 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -400,7 +400,7 @@ EXPORT_SYMBOL_GPL(cpuidle_register_device); | |||
400 | */ | 400 | */ |
401 | void cpuidle_unregister_device(struct cpuidle_device *dev) | 401 | void cpuidle_unregister_device(struct cpuidle_device *dev) |
402 | { | 402 | { |
403 | if (dev->registered == 0) | 403 | if (!dev || dev->registered == 0) |
404 | return; | 404 | return; |
405 | 405 | ||
406 | cpuidle_pause_and_lock(); | 406 | cpuidle_pause_and_lock(); |
diff --git a/drivers/crypto/caam/Kconfig b/drivers/crypto/caam/Kconfig index ca89f6b84b06..e7555ff4cafd 100644 --- a/drivers/crypto/caam/Kconfig +++ b/drivers/crypto/caam/Kconfig | |||
@@ -4,16 +4,29 @@ config CRYPTO_DEV_FSL_CAAM | |||
4 | help | 4 | help |
5 | Enables the driver module for Freescale's Cryptographic Accelerator | 5 | Enables the driver module for Freescale's Cryptographic Accelerator |
6 | and Assurance Module (CAAM), also known as the SEC version 4 (SEC4). | 6 | and Assurance Module (CAAM), also known as the SEC version 4 (SEC4). |
7 | This module adds a job ring operation interface, and configures h/w | 7 | This module creates job ring devices, and configures h/w |
8 | to operate as a DPAA component automatically, depending | 8 | to operate as a DPAA component automatically, depending |
9 | on h/w feature availability. | 9 | on h/w feature availability. |
10 | 10 | ||
11 | To compile this driver as a module, choose M here: the module | 11 | To compile this driver as a module, choose M here: the module |
12 | will be called caam. | 12 | will be called caam. |
13 | 13 | ||
14 | config CRYPTO_DEV_FSL_CAAM_JR | ||
15 | tristate "Freescale CAAM Job Ring driver backend" | ||
16 | depends on CRYPTO_DEV_FSL_CAAM | ||
17 | default y | ||
18 | help | ||
19 | Enables the driver module for Job Rings which are part of | ||
20 | Freescale's Cryptographic Accelerator | ||
21 | and Assurance Module (CAAM). This module adds a job ring operation | ||
22 | interface. | ||
23 | |||
24 | To compile this driver as a module, choose M here: the module | ||
25 | will be called caam_jr. | ||
26 | |||
14 | config CRYPTO_DEV_FSL_CAAM_RINGSIZE | 27 | config CRYPTO_DEV_FSL_CAAM_RINGSIZE |
15 | int "Job Ring size" | 28 | int "Job Ring size" |
16 | depends on CRYPTO_DEV_FSL_CAAM | 29 | depends on CRYPTO_DEV_FSL_CAAM_JR |
17 | range 2 9 | 30 | range 2 9 |
18 | default "9" | 31 | default "9" |
19 | help | 32 | help |
@@ -31,7 +44,7 @@ config CRYPTO_DEV_FSL_CAAM_RINGSIZE | |||
31 | 44 | ||
32 | config CRYPTO_DEV_FSL_CAAM_INTC | 45 | config CRYPTO_DEV_FSL_CAAM_INTC |
33 | bool "Job Ring interrupt coalescing" | 46 | bool "Job Ring interrupt coalescing" |
34 | depends on CRYPTO_DEV_FSL_CAAM | 47 | depends on CRYPTO_DEV_FSL_CAAM_JR |
35 | default n | 48 | default n |
36 | help | 49 | help |
37 | Enable the Job Ring's interrupt coalescing feature. | 50 | Enable the Job Ring's interrupt coalescing feature. |
@@ -62,7 +75,7 @@ config CRYPTO_DEV_FSL_CAAM_INTC_TIME_THLD | |||
62 | 75 | ||
63 | config CRYPTO_DEV_FSL_CAAM_CRYPTO_API | 76 | config CRYPTO_DEV_FSL_CAAM_CRYPTO_API |
64 | tristate "Register algorithm implementations with the Crypto API" | 77 | tristate "Register algorithm implementations with the Crypto API" |
65 | depends on CRYPTO_DEV_FSL_CAAM | 78 | depends on CRYPTO_DEV_FSL_CAAM && CRYPTO_DEV_FSL_CAAM_JR |
66 | default y | 79 | default y |
67 | select CRYPTO_ALGAPI | 80 | select CRYPTO_ALGAPI |
68 | select CRYPTO_AUTHENC | 81 | select CRYPTO_AUTHENC |
@@ -76,7 +89,7 @@ config CRYPTO_DEV_FSL_CAAM_CRYPTO_API | |||
76 | 89 | ||
77 | config CRYPTO_DEV_FSL_CAAM_AHASH_API | 90 | config CRYPTO_DEV_FSL_CAAM_AHASH_API |
78 | tristate "Register hash algorithm implementations with Crypto API" | 91 | tristate "Register hash algorithm implementations with Crypto API" |
79 | depends on CRYPTO_DEV_FSL_CAAM | 92 | depends on CRYPTO_DEV_FSL_CAAM && CRYPTO_DEV_FSL_CAAM_JR |
80 | default y | 93 | default y |
81 | select CRYPTO_HASH | 94 | select CRYPTO_HASH |
82 | help | 95 | help |
@@ -88,7 +101,7 @@ config CRYPTO_DEV_FSL_CAAM_AHASH_API | |||
88 | 101 | ||
89 | config CRYPTO_DEV_FSL_CAAM_RNG_API | 102 | config CRYPTO_DEV_FSL_CAAM_RNG_API |
90 | tristate "Register caam device for hwrng API" | 103 | tristate "Register caam device for hwrng API" |
91 | depends on CRYPTO_DEV_FSL_CAAM | 104 | depends on CRYPTO_DEV_FSL_CAAM && CRYPTO_DEV_FSL_CAAM_JR |
92 | default y | 105 | default y |
93 | select CRYPTO_RNG | 106 | select CRYPTO_RNG |
94 | select HW_RANDOM | 107 | select HW_RANDOM |
diff --git a/drivers/crypto/caam/Makefile b/drivers/crypto/caam/Makefile index d56bd0ec65d8..550758a333e7 100644 --- a/drivers/crypto/caam/Makefile +++ b/drivers/crypto/caam/Makefile | |||
@@ -6,8 +6,10 @@ ifeq ($(CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG), y) | |||
6 | endif | 6 | endif |
7 | 7 | ||
8 | obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM) += caam.o | 8 | obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM) += caam.o |
9 | obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_JR) += caam_jr.o | ||
9 | obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API) += caamalg.o | 10 | obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API) += caamalg.o |
10 | obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_AHASH_API) += caamhash.o | 11 | obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_AHASH_API) += caamhash.o |
11 | obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API) += caamrng.o | 12 | obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API) += caamrng.o |
12 | 13 | ||
13 | caam-objs := ctrl.o jr.o error.o key_gen.o | 14 | caam-objs := ctrl.o |
15 | caam_jr-objs := jr.o key_gen.o error.o | ||
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 7c63b72ecd75..4cf5dec826e1 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c | |||
@@ -86,6 +86,7 @@ | |||
86 | #else | 86 | #else |
87 | #define debug(format, arg...) | 87 | #define debug(format, arg...) |
88 | #endif | 88 | #endif |
89 | static struct list_head alg_list; | ||
89 | 90 | ||
90 | /* Set DK bit in class 1 operation if shared */ | 91 | /* Set DK bit in class 1 operation if shared */ |
91 | static inline void append_dec_op1(u32 *desc, u32 type) | 92 | static inline void append_dec_op1(u32 *desc, u32 type) |
@@ -817,7 +818,7 @@ static void aead_decrypt_done(struct device *jrdev, u32 *desc, u32 err, | |||
817 | ivsize, 1); | 818 | ivsize, 1); |
818 | print_hex_dump(KERN_ERR, "dst @"__stringify(__LINE__)": ", | 819 | print_hex_dump(KERN_ERR, "dst @"__stringify(__LINE__)": ", |
819 | DUMP_PREFIX_ADDRESS, 16, 4, sg_virt(req->dst), | 820 | DUMP_PREFIX_ADDRESS, 16, 4, sg_virt(req->dst), |
820 | req->cryptlen, 1); | 821 | req->cryptlen - ctx->authsize, 1); |
821 | #endif | 822 | #endif |
822 | 823 | ||
823 | if (err) { | 824 | if (err) { |
@@ -971,12 +972,9 @@ static void init_aead_job(u32 *sh_desc, dma_addr_t ptr, | |||
971 | (edesc->src_nents ? : 1); | 972 | (edesc->src_nents ? : 1); |
972 | in_options = LDST_SGF; | 973 | in_options = LDST_SGF; |
973 | } | 974 | } |
974 | if (encrypt) | 975 | |
975 | append_seq_in_ptr(desc, src_dma, req->assoclen + ivsize + | 976 | append_seq_in_ptr(desc, src_dma, req->assoclen + ivsize + req->cryptlen, |
976 | req->cryptlen - authsize, in_options); | 977 | in_options); |
977 | else | ||
978 | append_seq_in_ptr(desc, src_dma, req->assoclen + ivsize + | ||
979 | req->cryptlen, in_options); | ||
980 | 978 | ||
981 | if (likely(req->src == req->dst)) { | 979 | if (likely(req->src == req->dst)) { |
982 | if (all_contig) { | 980 | if (all_contig) { |
@@ -997,7 +995,8 @@ static void init_aead_job(u32 *sh_desc, dma_addr_t ptr, | |||
997 | } | 995 | } |
998 | } | 996 | } |
999 | if (encrypt) | 997 | if (encrypt) |
1000 | append_seq_out_ptr(desc, dst_dma, req->cryptlen, out_options); | 998 | append_seq_out_ptr(desc, dst_dma, req->cryptlen + authsize, |
999 | out_options); | ||
1001 | else | 1000 | else |
1002 | append_seq_out_ptr(desc, dst_dma, req->cryptlen - authsize, | 1001 | append_seq_out_ptr(desc, dst_dma, req->cryptlen - authsize, |
1003 | out_options); | 1002 | out_options); |
@@ -1047,8 +1046,8 @@ static void init_aead_giv_job(u32 *sh_desc, dma_addr_t ptr, | |||
1047 | sec4_sg_index += edesc->assoc_nents + 1 + edesc->src_nents; | 1046 | sec4_sg_index += edesc->assoc_nents + 1 + edesc->src_nents; |
1048 | in_options = LDST_SGF; | 1047 | in_options = LDST_SGF; |
1049 | } | 1048 | } |
1050 | append_seq_in_ptr(desc, src_dma, req->assoclen + ivsize + | 1049 | append_seq_in_ptr(desc, src_dma, req->assoclen + ivsize + req->cryptlen, |
1051 | req->cryptlen - authsize, in_options); | 1050 | in_options); |
1052 | 1051 | ||
1053 | if (contig & GIV_DST_CONTIG) { | 1052 | if (contig & GIV_DST_CONTIG) { |
1054 | dst_dma = edesc->iv_dma; | 1053 | dst_dma = edesc->iv_dma; |
@@ -1065,7 +1064,8 @@ static void init_aead_giv_job(u32 *sh_desc, dma_addr_t ptr, | |||
1065 | } | 1064 | } |
1066 | } | 1065 | } |
1067 | 1066 | ||
1068 | append_seq_out_ptr(desc, dst_dma, ivsize + req->cryptlen, out_options); | 1067 | append_seq_out_ptr(desc, dst_dma, ivsize + req->cryptlen + authsize, |
1068 | out_options); | ||
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | /* | 1071 | /* |
@@ -1129,7 +1129,8 @@ static void init_ablkcipher_job(u32 *sh_desc, dma_addr_t ptr, | |||
1129 | * allocate and map the aead extended descriptor | 1129 | * allocate and map the aead extended descriptor |
1130 | */ | 1130 | */ |
1131 | static struct aead_edesc *aead_edesc_alloc(struct aead_request *req, | 1131 | static struct aead_edesc *aead_edesc_alloc(struct aead_request *req, |
1132 | int desc_bytes, bool *all_contig_ptr) | 1132 | int desc_bytes, bool *all_contig_ptr, |
1133 | bool encrypt) | ||
1133 | { | 1134 | { |
1134 | struct crypto_aead *aead = crypto_aead_reqtfm(req); | 1135 | struct crypto_aead *aead = crypto_aead_reqtfm(req); |
1135 | struct caam_ctx *ctx = crypto_aead_ctx(aead); | 1136 | struct caam_ctx *ctx = crypto_aead_ctx(aead); |
@@ -1144,12 +1145,22 @@ static struct aead_edesc *aead_edesc_alloc(struct aead_request *req, | |||
1144 | bool assoc_chained = false, src_chained = false, dst_chained = false; | 1145 | bool assoc_chained = false, src_chained = false, dst_chained = false; |
1145 | int ivsize = crypto_aead_ivsize(aead); | 1146 | int ivsize = crypto_aead_ivsize(aead); |
1146 | int sec4_sg_index, sec4_sg_len = 0, sec4_sg_bytes; | 1147 | int sec4_sg_index, sec4_sg_len = 0, sec4_sg_bytes; |
1148 | unsigned int authsize = ctx->authsize; | ||
1147 | 1149 | ||
1148 | assoc_nents = sg_count(req->assoc, req->assoclen, &assoc_chained); | 1150 | assoc_nents = sg_count(req->assoc, req->assoclen, &assoc_chained); |
1149 | src_nents = sg_count(req->src, req->cryptlen, &src_chained); | ||
1150 | 1151 | ||
1151 | if (unlikely(req->dst != req->src)) | 1152 | if (unlikely(req->dst != req->src)) { |
1152 | dst_nents = sg_count(req->dst, req->cryptlen, &dst_chained); | 1153 | src_nents = sg_count(req->src, req->cryptlen, &src_chained); |
1154 | dst_nents = sg_count(req->dst, | ||
1155 | req->cryptlen + | ||
1156 | (encrypt ? authsize : (-authsize)), | ||
1157 | &dst_chained); | ||
1158 | } else { | ||
1159 | src_nents = sg_count(req->src, | ||
1160 | req->cryptlen + | ||
1161 | (encrypt ? authsize : 0), | ||
1162 | &src_chained); | ||
1163 | } | ||
1153 | 1164 | ||
1154 | sgc = dma_map_sg_chained(jrdev, req->assoc, assoc_nents ? : 1, | 1165 | sgc = dma_map_sg_chained(jrdev, req->assoc, assoc_nents ? : 1, |
1155 | DMA_TO_DEVICE, assoc_chained); | 1166 | DMA_TO_DEVICE, assoc_chained); |
@@ -1233,11 +1244,9 @@ static int aead_encrypt(struct aead_request *req) | |||
1233 | u32 *desc; | 1244 | u32 *desc; |
1234 | int ret = 0; | 1245 | int ret = 0; |
1235 | 1246 | ||
1236 | req->cryptlen += ctx->authsize; | ||
1237 | |||
1238 | /* allocate extended descriptor */ | 1247 | /* allocate extended descriptor */ |
1239 | edesc = aead_edesc_alloc(req, DESC_JOB_IO_LEN * | 1248 | edesc = aead_edesc_alloc(req, DESC_JOB_IO_LEN * |
1240 | CAAM_CMD_SZ, &all_contig); | 1249 | CAAM_CMD_SZ, &all_contig, true); |
1241 | if (IS_ERR(edesc)) | 1250 | if (IS_ERR(edesc)) |
1242 | return PTR_ERR(edesc); | 1251 | return PTR_ERR(edesc); |
1243 | 1252 | ||
@@ -1274,7 +1283,7 @@ static int aead_decrypt(struct aead_request *req) | |||
1274 | 1283 | ||
1275 | /* allocate extended descriptor */ | 1284 | /* allocate extended descriptor */ |
1276 | edesc = aead_edesc_alloc(req, DESC_JOB_IO_LEN * | 1285 | edesc = aead_edesc_alloc(req, DESC_JOB_IO_LEN * |
1277 | CAAM_CMD_SZ, &all_contig); | 1286 | CAAM_CMD_SZ, &all_contig, false); |
1278 | if (IS_ERR(edesc)) | 1287 | if (IS_ERR(edesc)) |
1279 | return PTR_ERR(edesc); | 1288 | return PTR_ERR(edesc); |
1280 | 1289 | ||
@@ -1331,7 +1340,8 @@ static struct aead_edesc *aead_giv_edesc_alloc(struct aead_givcrypt_request | |||
1331 | src_nents = sg_count(req->src, req->cryptlen, &src_chained); | 1340 | src_nents = sg_count(req->src, req->cryptlen, &src_chained); |
1332 | 1341 | ||
1333 | if (unlikely(req->dst != req->src)) | 1342 | if (unlikely(req->dst != req->src)) |
1334 | dst_nents = sg_count(req->dst, req->cryptlen, &dst_chained); | 1343 | dst_nents = sg_count(req->dst, req->cryptlen + ctx->authsize, |
1344 | &dst_chained); | ||
1335 | 1345 | ||
1336 | sgc = dma_map_sg_chained(jrdev, req->assoc, assoc_nents ? : 1, | 1346 | sgc = dma_map_sg_chained(jrdev, req->assoc, assoc_nents ? : 1, |
1337 | DMA_TO_DEVICE, assoc_chained); | 1347 | DMA_TO_DEVICE, assoc_chained); |
@@ -1425,8 +1435,6 @@ static int aead_givencrypt(struct aead_givcrypt_request *areq) | |||
1425 | u32 *desc; | 1435 | u32 *desc; |
1426 | int ret = 0; | 1436 | int ret = 0; |
1427 | 1437 | ||
1428 | req->cryptlen += ctx->authsize; | ||
1429 | |||
1430 | /* allocate extended descriptor */ | 1438 | /* allocate extended descriptor */ |
1431 | edesc = aead_giv_edesc_alloc(areq, DESC_JOB_IO_LEN * | 1439 | edesc = aead_giv_edesc_alloc(areq, DESC_JOB_IO_LEN * |
1432 | CAAM_CMD_SZ, &contig); | 1440 | CAAM_CMD_SZ, &contig); |
@@ -2057,7 +2065,6 @@ static struct caam_alg_template driver_algs[] = { | |||
2057 | 2065 | ||
2058 | struct caam_crypto_alg { | 2066 | struct caam_crypto_alg { |
2059 | struct list_head entry; | 2067 | struct list_head entry; |
2060 | struct device *ctrldev; | ||
2061 | int class1_alg_type; | 2068 | int class1_alg_type; |
2062 | int class2_alg_type; | 2069 | int class2_alg_type; |
2063 | int alg_op; | 2070 | int alg_op; |
@@ -2070,14 +2077,12 @@ static int caam_cra_init(struct crypto_tfm *tfm) | |||
2070 | struct caam_crypto_alg *caam_alg = | 2077 | struct caam_crypto_alg *caam_alg = |
2071 | container_of(alg, struct caam_crypto_alg, crypto_alg); | 2078 | container_of(alg, struct caam_crypto_alg, crypto_alg); |
2072 | struct caam_ctx *ctx = crypto_tfm_ctx(tfm); | 2079 | struct caam_ctx *ctx = crypto_tfm_ctx(tfm); |
2073 | struct caam_drv_private *priv = dev_get_drvdata(caam_alg->ctrldev); | ||
2074 | int tgt_jr = atomic_inc_return(&priv->tfm_count); | ||
2075 | 2080 | ||
2076 | /* | 2081 | ctx->jrdev = caam_jr_alloc(); |
2077 | * distribute tfms across job rings to ensure in-order | 2082 | if (IS_ERR(ctx->jrdev)) { |
2078 | * crypto request processing per tfm | 2083 | pr_err("Job Ring Device allocation for transform failed\n"); |
2079 | */ | 2084 | return PTR_ERR(ctx->jrdev); |
2080 | ctx->jrdev = priv->jrdev[(tgt_jr / 2) % priv->total_jobrs]; | 2085 | } |
2081 | 2086 | ||
2082 | /* copy descriptor header template value */ | 2087 | /* copy descriptor header template value */ |
2083 | ctx->class1_alg_type = OP_TYPE_CLASS1_ALG | caam_alg->class1_alg_type; | 2088 | ctx->class1_alg_type = OP_TYPE_CLASS1_ALG | caam_alg->class1_alg_type; |
@@ -2104,44 +2109,26 @@ static void caam_cra_exit(struct crypto_tfm *tfm) | |||
2104 | dma_unmap_single(ctx->jrdev, ctx->sh_desc_givenc_dma, | 2109 | dma_unmap_single(ctx->jrdev, ctx->sh_desc_givenc_dma, |
2105 | desc_bytes(ctx->sh_desc_givenc), | 2110 | desc_bytes(ctx->sh_desc_givenc), |
2106 | DMA_TO_DEVICE); | 2111 | DMA_TO_DEVICE); |
2112 | |||
2113 | caam_jr_free(ctx->jrdev); | ||
2107 | } | 2114 | } |
2108 | 2115 | ||
2109 | static void __exit caam_algapi_exit(void) | 2116 | static void __exit caam_algapi_exit(void) |
2110 | { | 2117 | { |
2111 | 2118 | ||
2112 | struct device_node *dev_node; | ||
2113 | struct platform_device *pdev; | ||
2114 | struct device *ctrldev; | ||
2115 | struct caam_drv_private *priv; | ||
2116 | struct caam_crypto_alg *t_alg, *n; | 2119 | struct caam_crypto_alg *t_alg, *n; |
2117 | 2120 | ||
2118 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); | 2121 | if (!alg_list.next) |
2119 | if (!dev_node) { | ||
2120 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); | ||
2121 | if (!dev_node) | ||
2122 | return; | ||
2123 | } | ||
2124 | |||
2125 | pdev = of_find_device_by_node(dev_node); | ||
2126 | if (!pdev) | ||
2127 | return; | ||
2128 | |||
2129 | ctrldev = &pdev->dev; | ||
2130 | of_node_put(dev_node); | ||
2131 | priv = dev_get_drvdata(ctrldev); | ||
2132 | |||
2133 | if (!priv->alg_list.next) | ||
2134 | return; | 2122 | return; |
2135 | 2123 | ||
2136 | list_for_each_entry_safe(t_alg, n, &priv->alg_list, entry) { | 2124 | list_for_each_entry_safe(t_alg, n, &alg_list, entry) { |
2137 | crypto_unregister_alg(&t_alg->crypto_alg); | 2125 | crypto_unregister_alg(&t_alg->crypto_alg); |
2138 | list_del(&t_alg->entry); | 2126 | list_del(&t_alg->entry); |
2139 | kfree(t_alg); | 2127 | kfree(t_alg); |
2140 | } | 2128 | } |
2141 | } | 2129 | } |
2142 | 2130 | ||
2143 | static struct caam_crypto_alg *caam_alg_alloc(struct device *ctrldev, | 2131 | static struct caam_crypto_alg *caam_alg_alloc(struct caam_alg_template |
2144 | struct caam_alg_template | ||
2145 | *template) | 2132 | *template) |
2146 | { | 2133 | { |
2147 | struct caam_crypto_alg *t_alg; | 2134 | struct caam_crypto_alg *t_alg; |
@@ -2149,7 +2136,7 @@ static struct caam_crypto_alg *caam_alg_alloc(struct device *ctrldev, | |||
2149 | 2136 | ||
2150 | t_alg = kzalloc(sizeof(struct caam_crypto_alg), GFP_KERNEL); | 2137 | t_alg = kzalloc(sizeof(struct caam_crypto_alg), GFP_KERNEL); |
2151 | if (!t_alg) { | 2138 | if (!t_alg) { |
2152 | dev_err(ctrldev, "failed to allocate t_alg\n"); | 2139 | pr_err("failed to allocate t_alg\n"); |
2153 | return ERR_PTR(-ENOMEM); | 2140 | return ERR_PTR(-ENOMEM); |
2154 | } | 2141 | } |
2155 | 2142 | ||
@@ -2181,62 +2168,39 @@ static struct caam_crypto_alg *caam_alg_alloc(struct device *ctrldev, | |||
2181 | t_alg->class1_alg_type = template->class1_alg_type; | 2168 | t_alg->class1_alg_type = template->class1_alg_type; |
2182 | t_alg->class2_alg_type = template->class2_alg_type; | 2169 | t_alg->class2_alg_type = template->class2_alg_type; |
2183 | t_alg->alg_op = template->alg_op; | 2170 | t_alg->alg_op = template->alg_op; |
2184 | t_alg->ctrldev = ctrldev; | ||
2185 | 2171 | ||
2186 | return t_alg; | 2172 | return t_alg; |
2187 | } | 2173 | } |
2188 | 2174 | ||
2189 | static int __init caam_algapi_init(void) | 2175 | static int __init caam_algapi_init(void) |
2190 | { | 2176 | { |
2191 | struct device_node *dev_node; | ||
2192 | struct platform_device *pdev; | ||
2193 | struct device *ctrldev; | ||
2194 | struct caam_drv_private *priv; | ||
2195 | int i = 0, err = 0; | 2177 | int i = 0, err = 0; |
2196 | 2178 | ||
2197 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); | 2179 | INIT_LIST_HEAD(&alg_list); |
2198 | if (!dev_node) { | ||
2199 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); | ||
2200 | if (!dev_node) | ||
2201 | return -ENODEV; | ||
2202 | } | ||
2203 | |||
2204 | pdev = of_find_device_by_node(dev_node); | ||
2205 | if (!pdev) | ||
2206 | return -ENODEV; | ||
2207 | |||
2208 | ctrldev = &pdev->dev; | ||
2209 | priv = dev_get_drvdata(ctrldev); | ||
2210 | of_node_put(dev_node); | ||
2211 | |||
2212 | INIT_LIST_HEAD(&priv->alg_list); | ||
2213 | |||
2214 | atomic_set(&priv->tfm_count, -1); | ||
2215 | 2180 | ||
2216 | /* register crypto algorithms the device supports */ | 2181 | /* register crypto algorithms the device supports */ |
2217 | for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { | 2182 | for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { |
2218 | /* TODO: check if h/w supports alg */ | 2183 | /* TODO: check if h/w supports alg */ |
2219 | struct caam_crypto_alg *t_alg; | 2184 | struct caam_crypto_alg *t_alg; |
2220 | 2185 | ||
2221 | t_alg = caam_alg_alloc(ctrldev, &driver_algs[i]); | 2186 | t_alg = caam_alg_alloc(&driver_algs[i]); |
2222 | if (IS_ERR(t_alg)) { | 2187 | if (IS_ERR(t_alg)) { |
2223 | err = PTR_ERR(t_alg); | 2188 | err = PTR_ERR(t_alg); |
2224 | dev_warn(ctrldev, "%s alg allocation failed\n", | 2189 | pr_warn("%s alg allocation failed\n", |
2225 | driver_algs[i].driver_name); | 2190 | driver_algs[i].driver_name); |
2226 | continue; | 2191 | continue; |
2227 | } | 2192 | } |
2228 | 2193 | ||
2229 | err = crypto_register_alg(&t_alg->crypto_alg); | 2194 | err = crypto_register_alg(&t_alg->crypto_alg); |
2230 | if (err) { | 2195 | if (err) { |
2231 | dev_warn(ctrldev, "%s alg registration failed\n", | 2196 | pr_warn("%s alg registration failed\n", |
2232 | t_alg->crypto_alg.cra_driver_name); | 2197 | t_alg->crypto_alg.cra_driver_name); |
2233 | kfree(t_alg); | 2198 | kfree(t_alg); |
2234 | } else | 2199 | } else |
2235 | list_add_tail(&t_alg->entry, &priv->alg_list); | 2200 | list_add_tail(&t_alg->entry, &alg_list); |
2236 | } | 2201 | } |
2237 | if (!list_empty(&priv->alg_list)) | 2202 | if (!list_empty(&alg_list)) |
2238 | dev_info(ctrldev, "%s algorithms registered in /proc/crypto\n", | 2203 | pr_info("caam algorithms registered in /proc/crypto\n"); |
2239 | (char *)of_get_property(dev_node, "compatible", NULL)); | ||
2240 | 2204 | ||
2241 | return err; | 2205 | return err; |
2242 | } | 2206 | } |
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index e732bd962e98..0378328f47a7 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c | |||
@@ -94,6 +94,9 @@ | |||
94 | #define debug(format, arg...) | 94 | #define debug(format, arg...) |
95 | #endif | 95 | #endif |
96 | 96 | ||
97 | |||
98 | static struct list_head hash_list; | ||
99 | |||
97 | /* ahash per-session context */ | 100 | /* ahash per-session context */ |
98 | struct caam_hash_ctx { | 101 | struct caam_hash_ctx { |
99 | struct device *jrdev; | 102 | struct device *jrdev; |
@@ -1653,7 +1656,6 @@ static struct caam_hash_template driver_hash[] = { | |||
1653 | 1656 | ||
1654 | struct caam_hash_alg { | 1657 | struct caam_hash_alg { |
1655 | struct list_head entry; | 1658 | struct list_head entry; |
1656 | struct device *ctrldev; | ||
1657 | int alg_type; | 1659 | int alg_type; |
1658 | int alg_op; | 1660 | int alg_op; |
1659 | struct ahash_alg ahash_alg; | 1661 | struct ahash_alg ahash_alg; |
@@ -1670,7 +1672,6 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm) | |||
1670 | struct caam_hash_alg *caam_hash = | 1672 | struct caam_hash_alg *caam_hash = |
1671 | container_of(alg, struct caam_hash_alg, ahash_alg); | 1673 | container_of(alg, struct caam_hash_alg, ahash_alg); |
1672 | struct caam_hash_ctx *ctx = crypto_tfm_ctx(tfm); | 1674 | struct caam_hash_ctx *ctx = crypto_tfm_ctx(tfm); |
1673 | struct caam_drv_private *priv = dev_get_drvdata(caam_hash->ctrldev); | ||
1674 | /* Sizes for MDHA running digests: MD5, SHA1, 224, 256, 384, 512 */ | 1675 | /* Sizes for MDHA running digests: MD5, SHA1, 224, 256, 384, 512 */ |
1675 | static const u8 runninglen[] = { HASH_MSG_LEN + MD5_DIGEST_SIZE, | 1676 | static const u8 runninglen[] = { HASH_MSG_LEN + MD5_DIGEST_SIZE, |
1676 | HASH_MSG_LEN + SHA1_DIGEST_SIZE, | 1677 | HASH_MSG_LEN + SHA1_DIGEST_SIZE, |
@@ -1678,15 +1679,17 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm) | |||
1678 | HASH_MSG_LEN + SHA256_DIGEST_SIZE, | 1679 | HASH_MSG_LEN + SHA256_DIGEST_SIZE, |
1679 | HASH_MSG_LEN + 64, | 1680 | HASH_MSG_LEN + 64, |
1680 | HASH_MSG_LEN + SHA512_DIGEST_SIZE }; | 1681 | HASH_MSG_LEN + SHA512_DIGEST_SIZE }; |
1681 | int tgt_jr = atomic_inc_return(&priv->tfm_count); | ||
1682 | int ret = 0; | 1682 | int ret = 0; |
1683 | 1683 | ||
1684 | /* | 1684 | /* |
1685 | * distribute tfms across job rings to ensure in-order | 1685 | * Get a Job ring from Job Ring driver to ensure in-order |
1686 | * crypto request processing per tfm | 1686 | * crypto request processing per tfm |
1687 | */ | 1687 | */ |
1688 | ctx->jrdev = priv->jrdev[tgt_jr % priv->total_jobrs]; | 1688 | ctx->jrdev = caam_jr_alloc(); |
1689 | 1689 | if (IS_ERR(ctx->jrdev)) { | |
1690 | pr_err("Job Ring Device allocation for transform failed\n"); | ||
1691 | return PTR_ERR(ctx->jrdev); | ||
1692 | } | ||
1690 | /* copy descriptor header template value */ | 1693 | /* copy descriptor header template value */ |
1691 | ctx->alg_type = OP_TYPE_CLASS2_ALG | caam_hash->alg_type; | 1694 | ctx->alg_type = OP_TYPE_CLASS2_ALG | caam_hash->alg_type; |
1692 | ctx->alg_op = OP_TYPE_CLASS2_ALG | caam_hash->alg_op; | 1695 | ctx->alg_op = OP_TYPE_CLASS2_ALG | caam_hash->alg_op; |
@@ -1729,35 +1732,18 @@ static void caam_hash_cra_exit(struct crypto_tfm *tfm) | |||
1729 | !dma_mapping_error(ctx->jrdev, ctx->sh_desc_finup_dma)) | 1732 | !dma_mapping_error(ctx->jrdev, ctx->sh_desc_finup_dma)) |
1730 | dma_unmap_single(ctx->jrdev, ctx->sh_desc_finup_dma, | 1733 | dma_unmap_single(ctx->jrdev, ctx->sh_desc_finup_dma, |
1731 | desc_bytes(ctx->sh_desc_finup), DMA_TO_DEVICE); | 1734 | desc_bytes(ctx->sh_desc_finup), DMA_TO_DEVICE); |
1735 | |||
1736 | caam_jr_free(ctx->jrdev); | ||
1732 | } | 1737 | } |
1733 | 1738 | ||
1734 | static void __exit caam_algapi_hash_exit(void) | 1739 | static void __exit caam_algapi_hash_exit(void) |
1735 | { | 1740 | { |
1736 | struct device_node *dev_node; | ||
1737 | struct platform_device *pdev; | ||
1738 | struct device *ctrldev; | ||
1739 | struct caam_drv_private *priv; | ||
1740 | struct caam_hash_alg *t_alg, *n; | 1741 | struct caam_hash_alg *t_alg, *n; |
1741 | 1742 | ||
1742 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); | 1743 | if (!hash_list.next) |
1743 | if (!dev_node) { | ||
1744 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); | ||
1745 | if (!dev_node) | ||
1746 | return; | ||
1747 | } | ||
1748 | |||
1749 | pdev = of_find_device_by_node(dev_node); | ||
1750 | if (!pdev) | ||
1751 | return; | 1744 | return; |
1752 | 1745 | ||
1753 | ctrldev = &pdev->dev; | 1746 | list_for_each_entry_safe(t_alg, n, &hash_list, entry) { |
1754 | of_node_put(dev_node); | ||
1755 | priv = dev_get_drvdata(ctrldev); | ||
1756 | |||
1757 | if (!priv->hash_list.next) | ||
1758 | return; | ||
1759 | |||
1760 | list_for_each_entry_safe(t_alg, n, &priv->hash_list, entry) { | ||
1761 | crypto_unregister_ahash(&t_alg->ahash_alg); | 1747 | crypto_unregister_ahash(&t_alg->ahash_alg); |
1762 | list_del(&t_alg->entry); | 1748 | list_del(&t_alg->entry); |
1763 | kfree(t_alg); | 1749 | kfree(t_alg); |
@@ -1765,7 +1751,7 @@ static void __exit caam_algapi_hash_exit(void) | |||
1765 | } | 1751 | } |
1766 | 1752 | ||
1767 | static struct caam_hash_alg * | 1753 | static struct caam_hash_alg * |
1768 | caam_hash_alloc(struct device *ctrldev, struct caam_hash_template *template, | 1754 | caam_hash_alloc(struct caam_hash_template *template, |
1769 | bool keyed) | 1755 | bool keyed) |
1770 | { | 1756 | { |
1771 | struct caam_hash_alg *t_alg; | 1757 | struct caam_hash_alg *t_alg; |
@@ -1774,7 +1760,7 @@ caam_hash_alloc(struct device *ctrldev, struct caam_hash_template *template, | |||
1774 | 1760 | ||
1775 | t_alg = kzalloc(sizeof(struct caam_hash_alg), GFP_KERNEL); | 1761 | t_alg = kzalloc(sizeof(struct caam_hash_alg), GFP_KERNEL); |
1776 | if (!t_alg) { | 1762 | if (!t_alg) { |
1777 | dev_err(ctrldev, "failed to allocate t_alg\n"); | 1763 | pr_err("failed to allocate t_alg\n"); |
1778 | return ERR_PTR(-ENOMEM); | 1764 | return ERR_PTR(-ENOMEM); |
1779 | } | 1765 | } |
1780 | 1766 | ||
@@ -1805,37 +1791,15 @@ caam_hash_alloc(struct device *ctrldev, struct caam_hash_template *template, | |||
1805 | 1791 | ||
1806 | t_alg->alg_type = template->alg_type; | 1792 | t_alg->alg_type = template->alg_type; |
1807 | t_alg->alg_op = template->alg_op; | 1793 | t_alg->alg_op = template->alg_op; |
1808 | t_alg->ctrldev = ctrldev; | ||
1809 | 1794 | ||
1810 | return t_alg; | 1795 | return t_alg; |
1811 | } | 1796 | } |
1812 | 1797 | ||
1813 | static int __init caam_algapi_hash_init(void) | 1798 | static int __init caam_algapi_hash_init(void) |
1814 | { | 1799 | { |
1815 | struct device_node *dev_node; | ||
1816 | struct platform_device *pdev; | ||
1817 | struct device *ctrldev; | ||
1818 | struct caam_drv_private *priv; | ||
1819 | int i = 0, err = 0; | 1800 | int i = 0, err = 0; |
1820 | 1801 | ||
1821 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); | 1802 | INIT_LIST_HEAD(&hash_list); |
1822 | if (!dev_node) { | ||
1823 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); | ||
1824 | if (!dev_node) | ||
1825 | return -ENODEV; | ||
1826 | } | ||
1827 | |||
1828 | pdev = of_find_device_by_node(dev_node); | ||
1829 | if (!pdev) | ||
1830 | return -ENODEV; | ||
1831 | |||
1832 | ctrldev = &pdev->dev; | ||
1833 | priv = dev_get_drvdata(ctrldev); | ||
1834 | of_node_put(dev_node); | ||
1835 | |||
1836 | INIT_LIST_HEAD(&priv->hash_list); | ||
1837 | |||
1838 | atomic_set(&priv->tfm_count, -1); | ||
1839 | 1803 | ||
1840 | /* register crypto algorithms the device supports */ | 1804 | /* register crypto algorithms the device supports */ |
1841 | for (i = 0; i < ARRAY_SIZE(driver_hash); i++) { | 1805 | for (i = 0; i < ARRAY_SIZE(driver_hash); i++) { |
@@ -1843,38 +1807,38 @@ static int __init caam_algapi_hash_init(void) | |||
1843 | struct caam_hash_alg *t_alg; | 1807 | struct caam_hash_alg *t_alg; |
1844 | 1808 | ||
1845 | /* register hmac version */ | 1809 | /* register hmac version */ |
1846 | t_alg = caam_hash_alloc(ctrldev, &driver_hash[i], true); | 1810 | t_alg = caam_hash_alloc(&driver_hash[i], true); |
1847 | if (IS_ERR(t_alg)) { | 1811 | if (IS_ERR(t_alg)) { |
1848 | err = PTR_ERR(t_alg); | 1812 | err = PTR_ERR(t_alg); |
1849 | dev_warn(ctrldev, "%s alg allocation failed\n", | 1813 | pr_warn("%s alg allocation failed\n", |
1850 | driver_hash[i].driver_name); | 1814 | driver_hash[i].driver_name); |
1851 | continue; | 1815 | continue; |
1852 | } | 1816 | } |
1853 | 1817 | ||
1854 | err = crypto_register_ahash(&t_alg->ahash_alg); | 1818 | err = crypto_register_ahash(&t_alg->ahash_alg); |
1855 | if (err) { | 1819 | if (err) { |
1856 | dev_warn(ctrldev, "%s alg registration failed\n", | 1820 | pr_warn("%s alg registration failed\n", |
1857 | t_alg->ahash_alg.halg.base.cra_driver_name); | 1821 | t_alg->ahash_alg.halg.base.cra_driver_name); |
1858 | kfree(t_alg); | 1822 | kfree(t_alg); |
1859 | } else | 1823 | } else |
1860 | list_add_tail(&t_alg->entry, &priv->hash_list); | 1824 | list_add_tail(&t_alg->entry, &hash_list); |
1861 | 1825 | ||
1862 | /* register unkeyed version */ | 1826 | /* register unkeyed version */ |
1863 | t_alg = caam_hash_alloc(ctrldev, &driver_hash[i], false); | 1827 | t_alg = caam_hash_alloc(&driver_hash[i], false); |
1864 | if (IS_ERR(t_alg)) { | 1828 | if (IS_ERR(t_alg)) { |
1865 | err = PTR_ERR(t_alg); | 1829 | err = PTR_ERR(t_alg); |
1866 | dev_warn(ctrldev, "%s alg allocation failed\n", | 1830 | pr_warn("%s alg allocation failed\n", |
1867 | driver_hash[i].driver_name); | 1831 | driver_hash[i].driver_name); |
1868 | continue; | 1832 | continue; |
1869 | } | 1833 | } |
1870 | 1834 | ||
1871 | err = crypto_register_ahash(&t_alg->ahash_alg); | 1835 | err = crypto_register_ahash(&t_alg->ahash_alg); |
1872 | if (err) { | 1836 | if (err) { |
1873 | dev_warn(ctrldev, "%s alg registration failed\n", | 1837 | pr_warn("%s alg registration failed\n", |
1874 | t_alg->ahash_alg.halg.base.cra_driver_name); | 1838 | t_alg->ahash_alg.halg.base.cra_driver_name); |
1875 | kfree(t_alg); | 1839 | kfree(t_alg); |
1876 | } else | 1840 | } else |
1877 | list_add_tail(&t_alg->entry, &priv->hash_list); | 1841 | list_add_tail(&t_alg->entry, &hash_list); |
1878 | } | 1842 | } |
1879 | 1843 | ||
1880 | return err; | 1844 | return err; |
diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index d1939a9539c0..28486b19fc36 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c | |||
@@ -273,34 +273,23 @@ static struct hwrng caam_rng = { | |||
273 | 273 | ||
274 | static void __exit caam_rng_exit(void) | 274 | static void __exit caam_rng_exit(void) |
275 | { | 275 | { |
276 | caam_jr_free(rng_ctx.jrdev); | ||
276 | hwrng_unregister(&caam_rng); | 277 | hwrng_unregister(&caam_rng); |
277 | } | 278 | } |
278 | 279 | ||
279 | static int __init caam_rng_init(void) | 280 | static int __init caam_rng_init(void) |
280 | { | 281 | { |
281 | struct device_node *dev_node; | 282 | struct device *dev; |
282 | struct platform_device *pdev; | ||
283 | struct device *ctrldev; | ||
284 | struct caam_drv_private *priv; | ||
285 | |||
286 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); | ||
287 | if (!dev_node) { | ||
288 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); | ||
289 | if (!dev_node) | ||
290 | return -ENODEV; | ||
291 | } | ||
292 | |||
293 | pdev = of_find_device_by_node(dev_node); | ||
294 | if (!pdev) | ||
295 | return -ENODEV; | ||
296 | 283 | ||
297 | ctrldev = &pdev->dev; | 284 | dev = caam_jr_alloc(); |
298 | priv = dev_get_drvdata(ctrldev); | 285 | if (IS_ERR(dev)) { |
299 | of_node_put(dev_node); | 286 | pr_err("Job Ring Device allocation for transform failed\n"); |
287 | return PTR_ERR(dev); | ||
288 | } | ||
300 | 289 | ||
301 | caam_init_rng(&rng_ctx, priv->jrdev[0]); | 290 | caam_init_rng(&rng_ctx, dev); |
302 | 291 | ||
303 | dev_info(priv->jrdev[0], "registering rng-caam\n"); | 292 | dev_info(dev, "registering rng-caam\n"); |
304 | return hwrng_register(&caam_rng); | 293 | return hwrng_register(&caam_rng); |
305 | } | 294 | } |
306 | 295 | ||
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index bc6d820812b6..63fb1af2c431 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c | |||
@@ -16,82 +16,75 @@ | |||
16 | #include "error.h" | 16 | #include "error.h" |
17 | #include "ctrl.h" | 17 | #include "ctrl.h" |
18 | 18 | ||
19 | static int caam_remove(struct platform_device *pdev) | ||
20 | { | ||
21 | struct device *ctrldev; | ||
22 | struct caam_drv_private *ctrlpriv; | ||
23 | struct caam_drv_private_jr *jrpriv; | ||
24 | struct caam_full __iomem *topregs; | ||
25 | int ring, ret = 0; | ||
26 | |||
27 | ctrldev = &pdev->dev; | ||
28 | ctrlpriv = dev_get_drvdata(ctrldev); | ||
29 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; | ||
30 | |||
31 | /* shut down JobRs */ | ||
32 | for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) { | ||
33 | ret |= caam_jr_shutdown(ctrlpriv->jrdev[ring]); | ||
34 | jrpriv = dev_get_drvdata(ctrlpriv->jrdev[ring]); | ||
35 | irq_dispose_mapping(jrpriv->irq); | ||
36 | } | ||
37 | |||
38 | /* Shut down debug views */ | ||
39 | #ifdef CONFIG_DEBUG_FS | ||
40 | debugfs_remove_recursive(ctrlpriv->dfs_root); | ||
41 | #endif | ||
42 | |||
43 | /* Unmap controller region */ | ||
44 | iounmap(&topregs->ctrl); | ||
45 | |||
46 | kfree(ctrlpriv->jrdev); | ||
47 | kfree(ctrlpriv); | ||
48 | |||
49 | return ret; | ||
50 | } | ||
51 | |||
52 | /* | 19 | /* |
53 | * Descriptor to instantiate RNG State Handle 0 in normal mode and | 20 | * Descriptor to instantiate RNG State Handle 0 in normal mode and |
54 | * load the JDKEK, TDKEK and TDSK registers | 21 | * load the JDKEK, TDKEK and TDSK registers |
55 | */ | 22 | */ |
56 | static void build_instantiation_desc(u32 *desc) | 23 | static void build_instantiation_desc(u32 *desc, int handle, int do_sk) |
57 | { | 24 | { |
58 | u32 *jump_cmd; | 25 | u32 *jump_cmd, op_flags; |
59 | 26 | ||
60 | init_job_desc(desc, 0); | 27 | init_job_desc(desc, 0); |
61 | 28 | ||
29 | op_flags = OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG | | ||
30 | (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INIT; | ||
31 | |||
62 | /* INIT RNG in non-test mode */ | 32 | /* INIT RNG in non-test mode */ |
63 | append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG | | 33 | append_operation(desc, op_flags); |
64 | OP_ALG_AS_INIT); | 34 | |
35 | if (!handle && do_sk) { | ||
36 | /* | ||
37 | * For SH0, Secure Keys must be generated as well | ||
38 | */ | ||
39 | |||
40 | /* wait for done */ | ||
41 | jump_cmd = append_jump(desc, JUMP_CLASS_CLASS1); | ||
42 | set_jump_tgt_here(desc, jump_cmd); | ||
43 | |||
44 | /* | ||
45 | * load 1 to clear written reg: | ||
46 | * resets the done interrrupt and returns the RNG to idle. | ||
47 | */ | ||
48 | append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW); | ||
49 | |||
50 | /* Initialize State Handle */ | ||
51 | append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG | | ||
52 | OP_ALG_AAI_RNG4_SK); | ||
53 | } | ||
65 | 54 | ||
66 | /* wait for done */ | 55 | append_jump(desc, JUMP_CLASS_CLASS1 | JUMP_TYPE_HALT); |
67 | jump_cmd = append_jump(desc, JUMP_CLASS_CLASS1); | 56 | } |
68 | set_jump_tgt_here(desc, jump_cmd); | ||
69 | 57 | ||
70 | /* | 58 | /* Descriptor for deinstantiation of State Handle 0 of the RNG block. */ |
71 | * load 1 to clear written reg: | 59 | static void build_deinstantiation_desc(u32 *desc, int handle) |
72 | * resets the done interrupt and returns the RNG to idle. | 60 | { |
73 | */ | 61 | init_job_desc(desc, 0); |
74 | append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW); | ||
75 | 62 | ||
76 | /* generate secure keys (non-test) */ | 63 | /* Uninstantiate State Handle 0 */ |
77 | append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG | | 64 | append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG | |
78 | OP_ALG_RNG4_SK); | 65 | (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INITFINAL); |
66 | |||
67 | append_jump(desc, JUMP_CLASS_CLASS1 | JUMP_TYPE_HALT); | ||
79 | } | 68 | } |
80 | 69 | ||
81 | static int instantiate_rng(struct device *ctrldev) | 70 | /* |
71 | * run_descriptor_deco0 - runs a descriptor on DECO0, under direct control of | ||
72 | * the software (no JR/QI used). | ||
73 | * @ctrldev - pointer to device | ||
74 | * @status - descriptor status, after being run | ||
75 | * | ||
76 | * Return: - 0 if no error occurred | ||
77 | * - -ENODEV if the DECO couldn't be acquired | ||
78 | * - -EAGAIN if an error occurred while executing the descriptor | ||
79 | */ | ||
80 | static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, | ||
81 | u32 *status) | ||
82 | { | 82 | { |
83 | struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev); | 83 | struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev); |
84 | struct caam_full __iomem *topregs; | 84 | struct caam_full __iomem *topregs; |
85 | unsigned int timeout = 100000; | 85 | unsigned int timeout = 100000; |
86 | u32 *desc; | 86 | u32 deco_dbg_reg, flags; |
87 | int i, ret = 0; | 87 | int i; |
88 | |||
89 | desc = kmalloc(CAAM_CMD_SZ * 6, GFP_KERNEL | GFP_DMA); | ||
90 | if (!desc) { | ||
91 | dev_err(ctrldev, "can't allocate RNG init descriptor memory\n"); | ||
92 | return -ENOMEM; | ||
93 | } | ||
94 | build_instantiation_desc(desc); | ||
95 | 88 | ||
96 | /* Set the bit to request direct access to DECO0 */ | 89 | /* Set the bit to request direct access to DECO0 */ |
97 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; | 90 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; |
@@ -103,36 +96,219 @@ static int instantiate_rng(struct device *ctrldev) | |||
103 | 96 | ||
104 | if (!timeout) { | 97 | if (!timeout) { |
105 | dev_err(ctrldev, "failed to acquire DECO 0\n"); | 98 | dev_err(ctrldev, "failed to acquire DECO 0\n"); |
106 | ret = -EIO; | 99 | clrbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); |
107 | goto out; | 100 | return -ENODEV; |
108 | } | 101 | } |
109 | 102 | ||
110 | for (i = 0; i < desc_len(desc); i++) | 103 | for (i = 0; i < desc_len(desc); i++) |
111 | topregs->deco.descbuf[i] = *(desc + i); | 104 | wr_reg32(&topregs->deco.descbuf[i], *(desc + i)); |
105 | |||
106 | flags = DECO_JQCR_WHL; | ||
107 | /* | ||
108 | * If the descriptor length is longer than 4 words, then the | ||
109 | * FOUR bit in JRCTRL register must be set. | ||
110 | */ | ||
111 | if (desc_len(desc) >= 4) | ||
112 | flags |= DECO_JQCR_FOUR; | ||
112 | 113 | ||
113 | wr_reg32(&topregs->deco.jr_ctl_hi, DECO_JQCR_WHL | DECO_JQCR_FOUR); | 114 | /* Instruct the DECO to execute it */ |
115 | wr_reg32(&topregs->deco.jr_ctl_hi, flags); | ||
114 | 116 | ||
115 | timeout = 10000000; | 117 | timeout = 10000000; |
116 | while ((rd_reg32(&topregs->deco.desc_dbg) & DECO_DBG_VALID) && | 118 | do { |
117 | --timeout) | 119 | deco_dbg_reg = rd_reg32(&topregs->deco.desc_dbg); |
120 | /* | ||
121 | * If an error occured in the descriptor, then | ||
122 | * the DECO status field will be set to 0x0D | ||
123 | */ | ||
124 | if ((deco_dbg_reg & DESC_DBG_DECO_STAT_MASK) == | ||
125 | DESC_DBG_DECO_STAT_HOST_ERR) | ||
126 | break; | ||
118 | cpu_relax(); | 127 | cpu_relax(); |
128 | } while ((deco_dbg_reg & DESC_DBG_DECO_STAT_VALID) && --timeout); | ||
119 | 129 | ||
120 | if (!timeout) { | 130 | *status = rd_reg32(&topregs->deco.op_status_hi) & |
121 | dev_err(ctrldev, "failed to instantiate RNG\n"); | 131 | DECO_OP_STATUS_HI_ERR_MASK; |
122 | ret = -EIO; | ||
123 | } | ||
124 | 132 | ||
133 | /* Mark the DECO as free */ | ||
125 | clrbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); | 134 | clrbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); |
126 | out: | 135 | |
136 | if (!timeout) | ||
137 | return -EAGAIN; | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * instantiate_rng - builds and executes a descriptor on DECO0, | ||
144 | * which initializes the RNG block. | ||
145 | * @ctrldev - pointer to device | ||
146 | * @state_handle_mask - bitmask containing the instantiation status | ||
147 | * for the RNG4 state handles which exist in | ||
148 | * the RNG4 block: 1 if it's been instantiated | ||
149 | * by an external entry, 0 otherwise. | ||
150 | * @gen_sk - generate data to be loaded into the JDKEK, TDKEK and TDSK; | ||
151 | * Caution: this can be done only once; if the keys need to be | ||
152 | * regenerated, a POR is required | ||
153 | * | ||
154 | * Return: - 0 if no error occurred | ||
155 | * - -ENOMEM if there isn't enough memory to allocate the descriptor | ||
156 | * - -ENODEV if DECO0 couldn't be acquired | ||
157 | * - -EAGAIN if an error occurred when executing the descriptor | ||
158 | * f.i. there was a RNG hardware error due to not "good enough" | ||
159 | * entropy being aquired. | ||
160 | */ | ||
161 | static int instantiate_rng(struct device *ctrldev, int state_handle_mask, | ||
162 | int gen_sk) | ||
163 | { | ||
164 | struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev); | ||
165 | struct caam_full __iomem *topregs; | ||
166 | struct rng4tst __iomem *r4tst; | ||
167 | u32 *desc, status, rdsta_val; | ||
168 | int ret = 0, sh_idx; | ||
169 | |||
170 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; | ||
171 | r4tst = &topregs->ctrl.r4tst[0]; | ||
172 | |||
173 | desc = kmalloc(CAAM_CMD_SZ * 7, GFP_KERNEL); | ||
174 | if (!desc) | ||
175 | return -ENOMEM; | ||
176 | |||
177 | for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) { | ||
178 | /* | ||
179 | * If the corresponding bit is set, this state handle | ||
180 | * was initialized by somebody else, so it's left alone. | ||
181 | */ | ||
182 | if ((1 << sh_idx) & state_handle_mask) | ||
183 | continue; | ||
184 | |||
185 | /* Create the descriptor for instantiating RNG State Handle */ | ||
186 | build_instantiation_desc(desc, sh_idx, gen_sk); | ||
187 | |||
188 | /* Try to run it through DECO0 */ | ||
189 | ret = run_descriptor_deco0(ctrldev, desc, &status); | ||
190 | |||
191 | /* | ||
192 | * If ret is not 0, or descriptor status is not 0, then | ||
193 | * something went wrong. No need to try the next state | ||
194 | * handle (if available), bail out here. | ||
195 | * Also, if for some reason, the State Handle didn't get | ||
196 | * instantiated although the descriptor has finished | ||
197 | * without any error (HW optimizations for later | ||
198 | * CAAM eras), then try again. | ||
199 | */ | ||
200 | rdsta_val = | ||
201 | rd_reg32(&topregs->ctrl.r4tst[0].rdsta) & RDSTA_IFMASK; | ||
202 | if (status || !(rdsta_val & (1 << sh_idx))) | ||
203 | ret = -EAGAIN; | ||
204 | if (ret) | ||
205 | break; | ||
206 | |||
207 | dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx); | ||
208 | /* Clear the contents before recreating the descriptor */ | ||
209 | memset(desc, 0x00, CAAM_CMD_SZ * 7); | ||
210 | } | ||
211 | |||
127 | kfree(desc); | 212 | kfree(desc); |
213 | |||
128 | return ret; | 214 | return ret; |
129 | } | 215 | } |
130 | 216 | ||
131 | /* | 217 | /* |
132 | * By default, the TRNG runs for 200 clocks per sample; | 218 | * deinstantiate_rng - builds and executes a descriptor on DECO0, |
133 | * 1600 clocks per sample generates better entropy. | 219 | * which deinitializes the RNG block. |
220 | * @ctrldev - pointer to device | ||
221 | * @state_handle_mask - bitmask containing the instantiation status | ||
222 | * for the RNG4 state handles which exist in | ||
223 | * the RNG4 block: 1 if it's been instantiated | ||
224 | * | ||
225 | * Return: - 0 if no error occurred | ||
226 | * - -ENOMEM if there isn't enough memory to allocate the descriptor | ||
227 | * - -ENODEV if DECO0 couldn't be acquired | ||
228 | * - -EAGAIN if an error occurred when executing the descriptor | ||
134 | */ | 229 | */ |
135 | static void kick_trng(struct platform_device *pdev) | 230 | static int deinstantiate_rng(struct device *ctrldev, int state_handle_mask) |
231 | { | ||
232 | u32 *desc, status; | ||
233 | int sh_idx, ret = 0; | ||
234 | |||
235 | desc = kmalloc(CAAM_CMD_SZ * 3, GFP_KERNEL); | ||
236 | if (!desc) | ||
237 | return -ENOMEM; | ||
238 | |||
239 | for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) { | ||
240 | /* | ||
241 | * If the corresponding bit is set, then it means the state | ||
242 | * handle was initialized by us, and thus it needs to be | ||
243 | * deintialized as well | ||
244 | */ | ||
245 | if ((1 << sh_idx) & state_handle_mask) { | ||
246 | /* | ||
247 | * Create the descriptor for deinstantating this state | ||
248 | * handle | ||
249 | */ | ||
250 | build_deinstantiation_desc(desc, sh_idx); | ||
251 | |||
252 | /* Try to run it through DECO0 */ | ||
253 | ret = run_descriptor_deco0(ctrldev, desc, &status); | ||
254 | |||
255 | if (ret || status) { | ||
256 | dev_err(ctrldev, | ||
257 | "Failed to deinstantiate RNG4 SH%d\n", | ||
258 | sh_idx); | ||
259 | break; | ||
260 | } | ||
261 | dev_info(ctrldev, "Deinstantiated RNG4 SH%d\n", sh_idx); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | kfree(desc); | ||
266 | |||
267 | return ret; | ||
268 | } | ||
269 | |||
270 | static int caam_remove(struct platform_device *pdev) | ||
271 | { | ||
272 | struct device *ctrldev; | ||
273 | struct caam_drv_private *ctrlpriv; | ||
274 | struct caam_full __iomem *topregs; | ||
275 | int ring, ret = 0; | ||
276 | |||
277 | ctrldev = &pdev->dev; | ||
278 | ctrlpriv = dev_get_drvdata(ctrldev); | ||
279 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; | ||
280 | |||
281 | /* Remove platform devices for JobRs */ | ||
282 | for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) { | ||
283 | if (ctrlpriv->jrpdev[ring]) | ||
284 | of_device_unregister(ctrlpriv->jrpdev[ring]); | ||
285 | } | ||
286 | |||
287 | /* De-initialize RNG state handles initialized by this driver. */ | ||
288 | if (ctrlpriv->rng4_sh_init) | ||
289 | deinstantiate_rng(ctrldev, ctrlpriv->rng4_sh_init); | ||
290 | |||
291 | /* Shut down debug views */ | ||
292 | #ifdef CONFIG_DEBUG_FS | ||
293 | debugfs_remove_recursive(ctrlpriv->dfs_root); | ||
294 | #endif | ||
295 | |||
296 | /* Unmap controller region */ | ||
297 | iounmap(&topregs->ctrl); | ||
298 | |||
299 | kfree(ctrlpriv->jrpdev); | ||
300 | kfree(ctrlpriv); | ||
301 | |||
302 | return ret; | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | * kick_trng - sets the various parameters for enabling the initialization | ||
307 | * of the RNG4 block in CAAM | ||
308 | * @pdev - pointer to the platform device | ||
309 | * @ent_delay - Defines the length (in system clocks) of each entropy sample. | ||
310 | */ | ||
311 | static void kick_trng(struct platform_device *pdev, int ent_delay) | ||
136 | { | 312 | { |
137 | struct device *ctrldev = &pdev->dev; | 313 | struct device *ctrldev = &pdev->dev; |
138 | struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev); | 314 | struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev); |
@@ -145,14 +321,31 @@ static void kick_trng(struct platform_device *pdev) | |||
145 | 321 | ||
146 | /* put RNG4 into program mode */ | 322 | /* put RNG4 into program mode */ |
147 | setbits32(&r4tst->rtmctl, RTMCTL_PRGM); | 323 | setbits32(&r4tst->rtmctl, RTMCTL_PRGM); |
148 | /* 1600 clocks per sample */ | 324 | |
325 | /* | ||
326 | * Performance-wise, it does not make sense to | ||
327 | * set the delay to a value that is lower | ||
328 | * than the last one that worked (i.e. the state handles | ||
329 | * were instantiated properly. Thus, instead of wasting | ||
330 | * time trying to set the values controlling the sample | ||
331 | * frequency, the function simply returns. | ||
332 | */ | ||
333 | val = (rd_reg32(&r4tst->rtsdctl) & RTSDCTL_ENT_DLY_MASK) | ||
334 | >> RTSDCTL_ENT_DLY_SHIFT; | ||
335 | if (ent_delay <= val) { | ||
336 | /* put RNG4 into run mode */ | ||
337 | clrbits32(&r4tst->rtmctl, RTMCTL_PRGM); | ||
338 | return; | ||
339 | } | ||
340 | |||
149 | val = rd_reg32(&r4tst->rtsdctl); | 341 | val = rd_reg32(&r4tst->rtsdctl); |
150 | val = (val & ~RTSDCTL_ENT_DLY_MASK) | (1600 << RTSDCTL_ENT_DLY_SHIFT); | 342 | val = (val & ~RTSDCTL_ENT_DLY_MASK) | |
343 | (ent_delay << RTSDCTL_ENT_DLY_SHIFT); | ||
151 | wr_reg32(&r4tst->rtsdctl, val); | 344 | wr_reg32(&r4tst->rtsdctl, val); |
152 | /* min. freq. count */ | 345 | /* min. freq. count, equal to 1/4 of the entropy sample length */ |
153 | wr_reg32(&r4tst->rtfrqmin, 400); | 346 | wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2); |
154 | /* max. freq. count */ | 347 | /* max. freq. count, equal to 8 times the entropy sample length */ |
155 | wr_reg32(&r4tst->rtfrqmax, 6400); | 348 | wr_reg32(&r4tst->rtfrqmax, ent_delay << 3); |
156 | /* put RNG4 into run mode */ | 349 | /* put RNG4 into run mode */ |
157 | clrbits32(&r4tst->rtmctl, RTMCTL_PRGM); | 350 | clrbits32(&r4tst->rtmctl, RTMCTL_PRGM); |
158 | } | 351 | } |
@@ -193,7 +386,7 @@ EXPORT_SYMBOL(caam_get_era); | |||
193 | /* Probe routine for CAAM top (controller) level */ | 386 | /* Probe routine for CAAM top (controller) level */ |
194 | static int caam_probe(struct platform_device *pdev) | 387 | static int caam_probe(struct platform_device *pdev) |
195 | { | 388 | { |
196 | int ret, ring, rspec; | 389 | int ret, ring, rspec, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN; |
197 | u64 caam_id; | 390 | u64 caam_id; |
198 | struct device *dev; | 391 | struct device *dev; |
199 | struct device_node *nprop, *np; | 392 | struct device_node *nprop, *np; |
@@ -258,8 +451,9 @@ static int caam_probe(struct platform_device *pdev) | |||
258 | rspec++; | 451 | rspec++; |
259 | } | 452 | } |
260 | 453 | ||
261 | ctrlpriv->jrdev = kzalloc(sizeof(struct device *) * rspec, GFP_KERNEL); | 454 | ctrlpriv->jrpdev = kzalloc(sizeof(struct platform_device *) * rspec, |
262 | if (ctrlpriv->jrdev == NULL) { | 455 | GFP_KERNEL); |
456 | if (ctrlpriv->jrpdev == NULL) { | ||
263 | iounmap(&topregs->ctrl); | 457 | iounmap(&topregs->ctrl); |
264 | return -ENOMEM; | 458 | return -ENOMEM; |
265 | } | 459 | } |
@@ -267,13 +461,24 @@ static int caam_probe(struct platform_device *pdev) | |||
267 | ring = 0; | 461 | ring = 0; |
268 | ctrlpriv->total_jobrs = 0; | 462 | ctrlpriv->total_jobrs = 0; |
269 | for_each_compatible_node(np, NULL, "fsl,sec-v4.0-job-ring") { | 463 | for_each_compatible_node(np, NULL, "fsl,sec-v4.0-job-ring") { |
270 | caam_jr_probe(pdev, np, ring); | 464 | ctrlpriv->jrpdev[ring] = |
465 | of_platform_device_create(np, NULL, dev); | ||
466 | if (!ctrlpriv->jrpdev[ring]) { | ||
467 | pr_warn("JR%d Platform device creation error\n", ring); | ||
468 | continue; | ||
469 | } | ||
271 | ctrlpriv->total_jobrs++; | 470 | ctrlpriv->total_jobrs++; |
272 | ring++; | 471 | ring++; |
273 | } | 472 | } |
274 | if (!ring) { | 473 | if (!ring) { |
275 | for_each_compatible_node(np, NULL, "fsl,sec4.0-job-ring") { | 474 | for_each_compatible_node(np, NULL, "fsl,sec4.0-job-ring") { |
276 | caam_jr_probe(pdev, np, ring); | 475 | ctrlpriv->jrpdev[ring] = |
476 | of_platform_device_create(np, NULL, dev); | ||
477 | if (!ctrlpriv->jrpdev[ring]) { | ||
478 | pr_warn("JR%d Platform device creation error\n", | ||
479 | ring); | ||
480 | continue; | ||
481 | } | ||
277 | ctrlpriv->total_jobrs++; | 482 | ctrlpriv->total_jobrs++; |
278 | ring++; | 483 | ring++; |
279 | } | 484 | } |
@@ -299,16 +504,55 @@ static int caam_probe(struct platform_device *pdev) | |||
299 | 504 | ||
300 | /* | 505 | /* |
301 | * If SEC has RNG version >= 4 and RNG state handle has not been | 506 | * If SEC has RNG version >= 4 and RNG state handle has not been |
302 | * already instantiated ,do RNG instantiation | 507 | * already instantiated, do RNG instantiation |
303 | */ | 508 | */ |
304 | if ((cha_vid & CHA_ID_RNG_MASK) >> CHA_ID_RNG_SHIFT >= 4 && | 509 | if ((cha_vid & CHA_ID_RNG_MASK) >> CHA_ID_RNG_SHIFT >= 4) { |
305 | !(rd_reg32(&topregs->ctrl.r4tst[0].rdsta) & RDSTA_IF0)) { | 510 | ctrlpriv->rng4_sh_init = |
306 | kick_trng(pdev); | 511 | rd_reg32(&topregs->ctrl.r4tst[0].rdsta); |
307 | ret = instantiate_rng(dev); | 512 | /* |
513 | * If the secure keys (TDKEK, JDKEK, TDSK), were already | ||
514 | * generated, signal this to the function that is instantiating | ||
515 | * the state handles. An error would occur if RNG4 attempts | ||
516 | * to regenerate these keys before the next POR. | ||
517 | */ | ||
518 | gen_sk = ctrlpriv->rng4_sh_init & RDSTA_SKVN ? 0 : 1; | ||
519 | ctrlpriv->rng4_sh_init &= RDSTA_IFMASK; | ||
520 | do { | ||
521 | int inst_handles = | ||
522 | rd_reg32(&topregs->ctrl.r4tst[0].rdsta) & | ||
523 | RDSTA_IFMASK; | ||
524 | /* | ||
525 | * If either SH were instantiated by somebody else | ||
526 | * (e.g. u-boot) then it is assumed that the entropy | ||
527 | * parameters are properly set and thus the function | ||
528 | * setting these (kick_trng(...)) is skipped. | ||
529 | * Also, if a handle was instantiated, do not change | ||
530 | * the TRNG parameters. | ||
531 | */ | ||
532 | if (!(ctrlpriv->rng4_sh_init || inst_handles)) { | ||
533 | kick_trng(pdev, ent_delay); | ||
534 | ent_delay += 400; | ||
535 | } | ||
536 | /* | ||
537 | * if instantiate_rng(...) fails, the loop will rerun | ||
538 | * and the kick_trng(...) function will modfiy the | ||
539 | * upper and lower limits of the entropy sampling | ||
540 | * interval, leading to a sucessful initialization of | ||
541 | * the RNG. | ||
542 | */ | ||
543 | ret = instantiate_rng(dev, inst_handles, | ||
544 | gen_sk); | ||
545 | } while ((ret == -EAGAIN) && (ent_delay < RTSDCTL_ENT_DLY_MAX)); | ||
308 | if (ret) { | 546 | if (ret) { |
547 | dev_err(dev, "failed to instantiate RNG"); | ||
309 | caam_remove(pdev); | 548 | caam_remove(pdev); |
310 | return ret; | 549 | return ret; |
311 | } | 550 | } |
551 | /* | ||
552 | * Set handles init'ed by this module as the complement of the | ||
553 | * already initialized ones | ||
554 | */ | ||
555 | ctrlpriv->rng4_sh_init = ~ctrlpriv->rng4_sh_init & RDSTA_IFMASK; | ||
312 | 556 | ||
313 | /* Enable RDB bit so that RNG works faster */ | 557 | /* Enable RDB bit so that RNG works faster */ |
314 | setbits32(&topregs->ctrl.scfgr, SCFGR_RDBENABLE); | 558 | setbits32(&topregs->ctrl.scfgr, SCFGR_RDBENABLE); |
diff --git a/drivers/crypto/caam/desc.h b/drivers/crypto/caam/desc.h index 53b296f78b0d..7e4500f18df6 100644 --- a/drivers/crypto/caam/desc.h +++ b/drivers/crypto/caam/desc.h | |||
@@ -1155,8 +1155,15 @@ struct sec4_sg_entry { | |||
1155 | 1155 | ||
1156 | /* randomizer AAI set */ | 1156 | /* randomizer AAI set */ |
1157 | #define OP_ALG_AAI_RNG (0x00 << OP_ALG_AAI_SHIFT) | 1157 | #define OP_ALG_AAI_RNG (0x00 << OP_ALG_AAI_SHIFT) |
1158 | #define OP_ALG_AAI_RNG_NOZERO (0x10 << OP_ALG_AAI_SHIFT) | 1158 | #define OP_ALG_AAI_RNG_NZB (0x10 << OP_ALG_AAI_SHIFT) |
1159 | #define OP_ALG_AAI_RNG_ODD (0x20 << OP_ALG_AAI_SHIFT) | 1159 | #define OP_ALG_AAI_RNG_OBP (0x20 << OP_ALG_AAI_SHIFT) |
1160 | |||
1161 | /* RNG4 AAI set */ | ||
1162 | #define OP_ALG_AAI_RNG4_SH_0 (0x00 << OP_ALG_AAI_SHIFT) | ||
1163 | #define OP_ALG_AAI_RNG4_SH_1 (0x01 << OP_ALG_AAI_SHIFT) | ||
1164 | #define OP_ALG_AAI_RNG4_PS (0x40 << OP_ALG_AAI_SHIFT) | ||
1165 | #define OP_ALG_AAI_RNG4_AI (0x80 << OP_ALG_AAI_SHIFT) | ||
1166 | #define OP_ALG_AAI_RNG4_SK (0x100 << OP_ALG_AAI_SHIFT) | ||
1160 | 1167 | ||
1161 | /* hmac/smac AAI set */ | 1168 | /* hmac/smac AAI set */ |
1162 | #define OP_ALG_AAI_HASH (0x00 << OP_ALG_AAI_SHIFT) | 1169 | #define OP_ALG_AAI_HASH (0x00 << OP_ALG_AAI_SHIFT) |
@@ -1178,12 +1185,6 @@ struct sec4_sg_entry { | |||
1178 | #define OP_ALG_AAI_GSM (0x10 << OP_ALG_AAI_SHIFT) | 1185 | #define OP_ALG_AAI_GSM (0x10 << OP_ALG_AAI_SHIFT) |
1179 | #define OP_ALG_AAI_EDGE (0x20 << OP_ALG_AAI_SHIFT) | 1186 | #define OP_ALG_AAI_EDGE (0x20 << OP_ALG_AAI_SHIFT) |
1180 | 1187 | ||
1181 | /* RNG4 set */ | ||
1182 | #define OP_ALG_RNG4_SHIFT 4 | ||
1183 | #define OP_ALG_RNG4_MASK (0x1f3 << OP_ALG_RNG4_SHIFT) | ||
1184 | |||
1185 | #define OP_ALG_RNG4_SK (0x100 << OP_ALG_RNG4_SHIFT) | ||
1186 | |||
1187 | #define OP_ALG_AS_SHIFT 2 | 1188 | #define OP_ALG_AS_SHIFT 2 |
1188 | #define OP_ALG_AS_MASK (0x3 << OP_ALG_AS_SHIFT) | 1189 | #define OP_ALG_AS_MASK (0x3 << OP_ALG_AS_SHIFT) |
1189 | #define OP_ALG_AS_UPDATE (0 << OP_ALG_AS_SHIFT) | 1190 | #define OP_ALG_AS_UPDATE (0 << OP_ALG_AS_SHIFT) |
diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 34c4b9f7fbfa..6d85fcc5bd0a 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h | |||
@@ -37,13 +37,16 @@ struct caam_jrentry_info { | |||
37 | 37 | ||
38 | /* Private sub-storage for a single JobR */ | 38 | /* Private sub-storage for a single JobR */ |
39 | struct caam_drv_private_jr { | 39 | struct caam_drv_private_jr { |
40 | struct device *parentdev; /* points back to controller dev */ | 40 | struct list_head list_node; /* Job Ring device list */ |
41 | struct platform_device *jr_pdev;/* points to platform device for JR */ | 41 | struct device *dev; |
42 | int ridx; | 42 | int ridx; |
43 | struct caam_job_ring __iomem *rregs; /* JobR's register space */ | 43 | struct caam_job_ring __iomem *rregs; /* JobR's register space */ |
44 | struct tasklet_struct irqtask; | 44 | struct tasklet_struct irqtask; |
45 | int irq; /* One per queue */ | 45 | int irq; /* One per queue */ |
46 | 46 | ||
47 | /* Number of scatterlist crypt transforms active on the JobR */ | ||
48 | atomic_t tfm_count ____cacheline_aligned; | ||
49 | |||
47 | /* Job ring info */ | 50 | /* Job ring info */ |
48 | int ringsize; /* Size of rings (assume input = output) */ | 51 | int ringsize; /* Size of rings (assume input = output) */ |
49 | struct caam_jrentry_info *entinfo; /* Alloc'ed 1 per ring entry */ | 52 | struct caam_jrentry_info *entinfo; /* Alloc'ed 1 per ring entry */ |
@@ -63,7 +66,7 @@ struct caam_drv_private_jr { | |||
63 | struct caam_drv_private { | 66 | struct caam_drv_private { |
64 | 67 | ||
65 | struct device *dev; | 68 | struct device *dev; |
66 | struct device **jrdev; /* Alloc'ed array per sub-device */ | 69 | struct platform_device **jrpdev; /* Alloc'ed array per sub-device */ |
67 | struct platform_device *pdev; | 70 | struct platform_device *pdev; |
68 | 71 | ||
69 | /* Physical-presence section */ | 72 | /* Physical-presence section */ |
@@ -80,12 +83,11 @@ struct caam_drv_private { | |||
80 | u8 qi_present; /* Nonzero if QI present in device */ | 83 | u8 qi_present; /* Nonzero if QI present in device */ |
81 | int secvio_irq; /* Security violation interrupt number */ | 84 | int secvio_irq; /* Security violation interrupt number */ |
82 | 85 | ||
83 | /* which jr allocated to scatterlist crypto */ | 86 | #define RNG4_MAX_HANDLES 2 |
84 | atomic_t tfm_count ____cacheline_aligned; | 87 | /* RNG4 block */ |
85 | /* list of registered crypto algorithms (mk generic context handle?) */ | 88 | u32 rng4_sh_init; /* This bitmap shows which of the State |
86 | struct list_head alg_list; | 89 | Handles of the RNG4 block are initialized |
87 | /* list of registered hash algorithms (mk generic context handle?) */ | 90 | by this driver */ |
88 | struct list_head hash_list; | ||
89 | 91 | ||
90 | /* | 92 | /* |
91 | * debugfs entries for developer view into driver/device | 93 | * debugfs entries for developer view into driver/device |
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index bdb786d5a5e5..1d80bd3636c5 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c | |||
@@ -6,6 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/of_irq.h> | 8 | #include <linux/of_irq.h> |
9 | #include <linux/of_address.h> | ||
9 | 10 | ||
10 | #include "compat.h" | 11 | #include "compat.h" |
11 | #include "regs.h" | 12 | #include "regs.h" |
@@ -13,6 +14,113 @@ | |||
13 | #include "desc.h" | 14 | #include "desc.h" |
14 | #include "intern.h" | 15 | #include "intern.h" |
15 | 16 | ||
17 | struct jr_driver_data { | ||
18 | /* List of Physical JobR's with the Driver */ | ||
19 | struct list_head jr_list; | ||
20 | spinlock_t jr_alloc_lock; /* jr_list lock */ | ||
21 | } ____cacheline_aligned; | ||
22 | |||
23 | static struct jr_driver_data driver_data; | ||
24 | |||
25 | static int caam_reset_hw_jr(struct device *dev) | ||
26 | { | ||
27 | struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); | ||
28 | unsigned int timeout = 100000; | ||
29 | |||
30 | /* | ||
31 | * mask interrupts since we are going to poll | ||
32 | * for reset completion status | ||
33 | */ | ||
34 | setbits32(&jrp->rregs->rconfig_lo, JRCFG_IMSK); | ||
35 | |||
36 | /* initiate flush (required prior to reset) */ | ||
37 | wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); | ||
38 | while (((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) == | ||
39 | JRINT_ERR_HALT_INPROGRESS) && --timeout) | ||
40 | cpu_relax(); | ||
41 | |||
42 | if ((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) != | ||
43 | JRINT_ERR_HALT_COMPLETE || timeout == 0) { | ||
44 | dev_err(dev, "failed to flush job ring %d\n", jrp->ridx); | ||
45 | return -EIO; | ||
46 | } | ||
47 | |||
48 | /* initiate reset */ | ||
49 | timeout = 100000; | ||
50 | wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); | ||
51 | while ((rd_reg32(&jrp->rregs->jrcommand) & JRCR_RESET) && --timeout) | ||
52 | cpu_relax(); | ||
53 | |||
54 | if (timeout == 0) { | ||
55 | dev_err(dev, "failed to reset job ring %d\n", jrp->ridx); | ||
56 | return -EIO; | ||
57 | } | ||
58 | |||
59 | /* unmask interrupts */ | ||
60 | clrbits32(&jrp->rregs->rconfig_lo, JRCFG_IMSK); | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | /* | ||
66 | * Shutdown JobR independent of platform property code | ||
67 | */ | ||
68 | int caam_jr_shutdown(struct device *dev) | ||
69 | { | ||
70 | struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); | ||
71 | dma_addr_t inpbusaddr, outbusaddr; | ||
72 | int ret; | ||
73 | |||
74 | ret = caam_reset_hw_jr(dev); | ||
75 | |||
76 | tasklet_kill(&jrp->irqtask); | ||
77 | |||
78 | /* Release interrupt */ | ||
79 | free_irq(jrp->irq, dev); | ||
80 | |||
81 | /* Free rings */ | ||
82 | inpbusaddr = rd_reg64(&jrp->rregs->inpring_base); | ||
83 | outbusaddr = rd_reg64(&jrp->rregs->outring_base); | ||
84 | dma_free_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, | ||
85 | jrp->inpring, inpbusaddr); | ||
86 | dma_free_coherent(dev, sizeof(struct jr_outentry) * JOBR_DEPTH, | ||
87 | jrp->outring, outbusaddr); | ||
88 | kfree(jrp->entinfo); | ||
89 | |||
90 | return ret; | ||
91 | } | ||
92 | |||
93 | static int caam_jr_remove(struct platform_device *pdev) | ||
94 | { | ||
95 | int ret; | ||
96 | struct device *jrdev; | ||
97 | struct caam_drv_private_jr *jrpriv; | ||
98 | |||
99 | jrdev = &pdev->dev; | ||
100 | jrpriv = dev_get_drvdata(jrdev); | ||
101 | |||
102 | /* | ||
103 | * Return EBUSY if job ring already allocated. | ||
104 | */ | ||
105 | if (atomic_read(&jrpriv->tfm_count)) { | ||
106 | dev_err(jrdev, "Device is busy\n"); | ||
107 | return -EBUSY; | ||
108 | } | ||
109 | |||
110 | /* Remove the node from Physical JobR list maintained by driver */ | ||
111 | spin_lock(&driver_data.jr_alloc_lock); | ||
112 | list_del(&jrpriv->list_node); | ||
113 | spin_unlock(&driver_data.jr_alloc_lock); | ||
114 | |||
115 | /* Release ring */ | ||
116 | ret = caam_jr_shutdown(jrdev); | ||
117 | if (ret) | ||
118 | dev_err(jrdev, "Failed to shut down job ring\n"); | ||
119 | irq_dispose_mapping(jrpriv->irq); | ||
120 | |||
121 | return ret; | ||
122 | } | ||
123 | |||
16 | /* Main per-ring interrupt handler */ | 124 | /* Main per-ring interrupt handler */ |
17 | static irqreturn_t caam_jr_interrupt(int irq, void *st_dev) | 125 | static irqreturn_t caam_jr_interrupt(int irq, void *st_dev) |
18 | { | 126 | { |
@@ -128,6 +236,59 @@ static void caam_jr_dequeue(unsigned long devarg) | |||
128 | } | 236 | } |
129 | 237 | ||
130 | /** | 238 | /** |
239 | * caam_jr_alloc() - Alloc a job ring for someone to use as needed. | ||
240 | * | ||
241 | * returns : pointer to the newly allocated physical | ||
242 | * JobR dev can be written to if successful. | ||
243 | **/ | ||
244 | struct device *caam_jr_alloc(void) | ||
245 | { | ||
246 | struct caam_drv_private_jr *jrpriv, *min_jrpriv = NULL; | ||
247 | struct device *dev = NULL; | ||
248 | int min_tfm_cnt = INT_MAX; | ||
249 | int tfm_cnt; | ||
250 | |||
251 | spin_lock(&driver_data.jr_alloc_lock); | ||
252 | |||
253 | if (list_empty(&driver_data.jr_list)) { | ||
254 | spin_unlock(&driver_data.jr_alloc_lock); | ||
255 | return ERR_PTR(-ENODEV); | ||
256 | } | ||
257 | |||
258 | list_for_each_entry(jrpriv, &driver_data.jr_list, list_node) { | ||
259 | tfm_cnt = atomic_read(&jrpriv->tfm_count); | ||
260 | if (tfm_cnt < min_tfm_cnt) { | ||
261 | min_tfm_cnt = tfm_cnt; | ||
262 | min_jrpriv = jrpriv; | ||
263 | } | ||
264 | if (!min_tfm_cnt) | ||
265 | break; | ||
266 | } | ||
267 | |||
268 | if (min_jrpriv) { | ||
269 | atomic_inc(&min_jrpriv->tfm_count); | ||
270 | dev = min_jrpriv->dev; | ||
271 | } | ||
272 | spin_unlock(&driver_data.jr_alloc_lock); | ||
273 | |||
274 | return dev; | ||
275 | } | ||
276 | EXPORT_SYMBOL(caam_jr_alloc); | ||
277 | |||
278 | /** | ||
279 | * caam_jr_free() - Free the Job Ring | ||
280 | * @rdev - points to the dev that identifies the Job ring to | ||
281 | * be released. | ||
282 | **/ | ||
283 | void caam_jr_free(struct device *rdev) | ||
284 | { | ||
285 | struct caam_drv_private_jr *jrpriv = dev_get_drvdata(rdev); | ||
286 | |||
287 | atomic_dec(&jrpriv->tfm_count); | ||
288 | } | ||
289 | EXPORT_SYMBOL(caam_jr_free); | ||
290 | |||
291 | /** | ||
131 | * caam_jr_enqueue() - Enqueue a job descriptor head. Returns 0 if OK, | 292 | * caam_jr_enqueue() - Enqueue a job descriptor head. Returns 0 if OK, |
132 | * -EBUSY if the queue is full, -EIO if it cannot map the caller's | 293 | * -EBUSY if the queue is full, -EIO if it cannot map the caller's |
133 | * descriptor. | 294 | * descriptor. |
@@ -207,46 +368,6 @@ int caam_jr_enqueue(struct device *dev, u32 *desc, | |||
207 | } | 368 | } |
208 | EXPORT_SYMBOL(caam_jr_enqueue); | 369 | EXPORT_SYMBOL(caam_jr_enqueue); |
209 | 370 | ||
210 | static int caam_reset_hw_jr(struct device *dev) | ||
211 | { | ||
212 | struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); | ||
213 | unsigned int timeout = 100000; | ||
214 | |||
215 | /* | ||
216 | * mask interrupts since we are going to poll | ||
217 | * for reset completion status | ||
218 | */ | ||
219 | setbits32(&jrp->rregs->rconfig_lo, JRCFG_IMSK); | ||
220 | |||
221 | /* initiate flush (required prior to reset) */ | ||
222 | wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); | ||
223 | while (((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) == | ||
224 | JRINT_ERR_HALT_INPROGRESS) && --timeout) | ||
225 | cpu_relax(); | ||
226 | |||
227 | if ((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) != | ||
228 | JRINT_ERR_HALT_COMPLETE || timeout == 0) { | ||
229 | dev_err(dev, "failed to flush job ring %d\n", jrp->ridx); | ||
230 | return -EIO; | ||
231 | } | ||
232 | |||
233 | /* initiate reset */ | ||
234 | timeout = 100000; | ||
235 | wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); | ||
236 | while ((rd_reg32(&jrp->rregs->jrcommand) & JRCR_RESET) && --timeout) | ||
237 | cpu_relax(); | ||
238 | |||
239 | if (timeout == 0) { | ||
240 | dev_err(dev, "failed to reset job ring %d\n", jrp->ridx); | ||
241 | return -EIO; | ||
242 | } | ||
243 | |||
244 | /* unmask interrupts */ | ||
245 | clrbits32(&jrp->rregs->rconfig_lo, JRCFG_IMSK); | ||
246 | |||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | /* | 371 | /* |
251 | * Init JobR independent of platform property detection | 372 | * Init JobR independent of platform property detection |
252 | */ | 373 | */ |
@@ -262,7 +383,7 @@ static int caam_jr_init(struct device *dev) | |||
262 | 383 | ||
263 | /* Connect job ring interrupt handler. */ | 384 | /* Connect job ring interrupt handler. */ |
264 | error = request_irq(jrp->irq, caam_jr_interrupt, IRQF_SHARED, | 385 | error = request_irq(jrp->irq, caam_jr_interrupt, IRQF_SHARED, |
265 | "caam-jobr", dev); | 386 | dev_name(dev), dev); |
266 | if (error) { | 387 | if (error) { |
267 | dev_err(dev, "can't connect JobR %d interrupt (%d)\n", | 388 | dev_err(dev, "can't connect JobR %d interrupt (%d)\n", |
268 | jrp->ridx, jrp->irq); | 389 | jrp->ridx, jrp->irq); |
@@ -318,86 +439,43 @@ static int caam_jr_init(struct device *dev) | |||
318 | return 0; | 439 | return 0; |
319 | } | 440 | } |
320 | 441 | ||
321 | /* | ||
322 | * Shutdown JobR independent of platform property code | ||
323 | */ | ||
324 | int caam_jr_shutdown(struct device *dev) | ||
325 | { | ||
326 | struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); | ||
327 | dma_addr_t inpbusaddr, outbusaddr; | ||
328 | int ret; | ||
329 | |||
330 | ret = caam_reset_hw_jr(dev); | ||
331 | |||
332 | tasklet_kill(&jrp->irqtask); | ||
333 | |||
334 | /* Release interrupt */ | ||
335 | free_irq(jrp->irq, dev); | ||
336 | |||
337 | /* Free rings */ | ||
338 | inpbusaddr = rd_reg64(&jrp->rregs->inpring_base); | ||
339 | outbusaddr = rd_reg64(&jrp->rregs->outring_base); | ||
340 | dma_free_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, | ||
341 | jrp->inpring, inpbusaddr); | ||
342 | dma_free_coherent(dev, sizeof(struct jr_outentry) * JOBR_DEPTH, | ||
343 | jrp->outring, outbusaddr); | ||
344 | kfree(jrp->entinfo); | ||
345 | of_device_unregister(jrp->jr_pdev); | ||
346 | |||
347 | return ret; | ||
348 | } | ||
349 | 442 | ||
350 | /* | 443 | /* |
351 | * Probe routine for each detected JobR subsystem. It assumes that | 444 | * Probe routine for each detected JobR subsystem. |
352 | * property detection was picked up externally. | ||
353 | */ | 445 | */ |
354 | int caam_jr_probe(struct platform_device *pdev, struct device_node *np, | 446 | static int caam_jr_probe(struct platform_device *pdev) |
355 | int ring) | ||
356 | { | 447 | { |
357 | struct device *ctrldev, *jrdev; | 448 | struct device *jrdev; |
358 | struct platform_device *jr_pdev; | 449 | struct device_node *nprop; |
359 | struct caam_drv_private *ctrlpriv; | 450 | struct caam_job_ring __iomem *ctrl; |
360 | struct caam_drv_private_jr *jrpriv; | 451 | struct caam_drv_private_jr *jrpriv; |
361 | u32 *jroffset; | 452 | static int total_jobrs; |
362 | int error; | 453 | int error; |
363 | 454 | ||
364 | ctrldev = &pdev->dev; | 455 | jrdev = &pdev->dev; |
365 | ctrlpriv = dev_get_drvdata(ctrldev); | ||
366 | |||
367 | jrpriv = kmalloc(sizeof(struct caam_drv_private_jr), | 456 | jrpriv = kmalloc(sizeof(struct caam_drv_private_jr), |
368 | GFP_KERNEL); | 457 | GFP_KERNEL); |
369 | if (jrpriv == NULL) { | 458 | if (!jrpriv) |
370 | dev_err(ctrldev, "can't alloc private mem for job ring %d\n", | ||
371 | ring); | ||
372 | return -ENOMEM; | 459 | return -ENOMEM; |
373 | } | ||
374 | jrpriv->parentdev = ctrldev; /* point back to parent */ | ||
375 | jrpriv->ridx = ring; /* save ring identity relative to detection */ | ||
376 | 460 | ||
377 | /* | 461 | dev_set_drvdata(jrdev, jrpriv); |
378 | * Derive a pointer to the detected JobRs regs | ||
379 | * Driver has already iomapped the entire space, we just | ||
380 | * need to add in the offset to this JobR. Don't know if I | ||
381 | * like this long-term, but it'll run | ||
382 | */ | ||
383 | jroffset = (u32 *)of_get_property(np, "reg", NULL); | ||
384 | jrpriv->rregs = (struct caam_job_ring __iomem *)((void *)ctrlpriv->ctrl | ||
385 | + *jroffset); | ||
386 | 462 | ||
387 | /* Build a local dev for each detected queue */ | 463 | /* save ring identity relative to detection */ |
388 | jr_pdev = of_platform_device_create(np, NULL, ctrldev); | 464 | jrpriv->ridx = total_jobrs++; |
389 | if (jr_pdev == NULL) { | 465 | |
390 | kfree(jrpriv); | 466 | nprop = pdev->dev.of_node; |
391 | return -EINVAL; | 467 | /* Get configuration properties from device tree */ |
468 | /* First, get register page */ | ||
469 | ctrl = of_iomap(nprop, 0); | ||
470 | if (!ctrl) { | ||
471 | dev_err(jrdev, "of_iomap() failed\n"); | ||
472 | return -ENOMEM; | ||
392 | } | 473 | } |
393 | 474 | ||
394 | jrpriv->jr_pdev = jr_pdev; | 475 | jrpriv->rregs = (struct caam_job_ring __force *)ctrl; |
395 | jrdev = &jr_pdev->dev; | ||
396 | dev_set_drvdata(jrdev, jrpriv); | ||
397 | ctrlpriv->jrdev[ring] = jrdev; | ||
398 | 476 | ||
399 | if (sizeof(dma_addr_t) == sizeof(u64)) | 477 | if (sizeof(dma_addr_t) == sizeof(u64)) |
400 | if (of_device_is_compatible(np, "fsl,sec-v5.0-job-ring")) | 478 | if (of_device_is_compatible(nprop, "fsl,sec-v5.0-job-ring")) |
401 | dma_set_mask(jrdev, DMA_BIT_MASK(40)); | 479 | dma_set_mask(jrdev, DMA_BIT_MASK(40)); |
402 | else | 480 | else |
403 | dma_set_mask(jrdev, DMA_BIT_MASK(36)); | 481 | dma_set_mask(jrdev, DMA_BIT_MASK(36)); |
@@ -405,15 +483,61 @@ int caam_jr_probe(struct platform_device *pdev, struct device_node *np, | |||
405 | dma_set_mask(jrdev, DMA_BIT_MASK(32)); | 483 | dma_set_mask(jrdev, DMA_BIT_MASK(32)); |
406 | 484 | ||
407 | /* Identify the interrupt */ | 485 | /* Identify the interrupt */ |
408 | jrpriv->irq = irq_of_parse_and_map(np, 0); | 486 | jrpriv->irq = irq_of_parse_and_map(nprop, 0); |
409 | 487 | ||
410 | /* Now do the platform independent part */ | 488 | /* Now do the platform independent part */ |
411 | error = caam_jr_init(jrdev); /* now turn on hardware */ | 489 | error = caam_jr_init(jrdev); /* now turn on hardware */ |
412 | if (error) { | 490 | if (error) { |
413 | of_device_unregister(jr_pdev); | ||
414 | kfree(jrpriv); | 491 | kfree(jrpriv); |
415 | return error; | 492 | return error; |
416 | } | 493 | } |
417 | 494 | ||
418 | return error; | 495 | jrpriv->dev = jrdev; |
496 | spin_lock(&driver_data.jr_alloc_lock); | ||
497 | list_add_tail(&jrpriv->list_node, &driver_data.jr_list); | ||
498 | spin_unlock(&driver_data.jr_alloc_lock); | ||
499 | |||
500 | atomic_set(&jrpriv->tfm_count, 0); | ||
501 | |||
502 | return 0; | ||
503 | } | ||
504 | |||
505 | static struct of_device_id caam_jr_match[] = { | ||
506 | { | ||
507 | .compatible = "fsl,sec-v4.0-job-ring", | ||
508 | }, | ||
509 | { | ||
510 | .compatible = "fsl,sec4.0-job-ring", | ||
511 | }, | ||
512 | {}, | ||
513 | }; | ||
514 | MODULE_DEVICE_TABLE(of, caam_jr_match); | ||
515 | |||
516 | static struct platform_driver caam_jr_driver = { | ||
517 | .driver = { | ||
518 | .name = "caam_jr", | ||
519 | .owner = THIS_MODULE, | ||
520 | .of_match_table = caam_jr_match, | ||
521 | }, | ||
522 | .probe = caam_jr_probe, | ||
523 | .remove = caam_jr_remove, | ||
524 | }; | ||
525 | |||
526 | static int __init jr_driver_init(void) | ||
527 | { | ||
528 | spin_lock_init(&driver_data.jr_alloc_lock); | ||
529 | INIT_LIST_HEAD(&driver_data.jr_list); | ||
530 | return platform_driver_register(&caam_jr_driver); | ||
531 | } | ||
532 | |||
533 | static void __exit jr_driver_exit(void) | ||
534 | { | ||
535 | platform_driver_unregister(&caam_jr_driver); | ||
419 | } | 536 | } |
537 | |||
538 | module_init(jr_driver_init); | ||
539 | module_exit(jr_driver_exit); | ||
540 | |||
541 | MODULE_LICENSE("GPL"); | ||
542 | MODULE_DESCRIPTION("FSL CAAM JR request backend"); | ||
543 | MODULE_AUTHOR("Freescale Semiconductor - NMG/STC"); | ||
diff --git a/drivers/crypto/caam/jr.h b/drivers/crypto/caam/jr.h index 9d8741a59037..97113a6d6c58 100644 --- a/drivers/crypto/caam/jr.h +++ b/drivers/crypto/caam/jr.h | |||
@@ -8,12 +8,11 @@ | |||
8 | #define JR_H | 8 | #define JR_H |
9 | 9 | ||
10 | /* Prototypes for backend-level services exposed to APIs */ | 10 | /* Prototypes for backend-level services exposed to APIs */ |
11 | struct device *caam_jr_alloc(void); | ||
12 | void caam_jr_free(struct device *rdev); | ||
11 | int caam_jr_enqueue(struct device *dev, u32 *desc, | 13 | int caam_jr_enqueue(struct device *dev, u32 *desc, |
12 | void (*cbk)(struct device *dev, u32 *desc, u32 status, | 14 | void (*cbk)(struct device *dev, u32 *desc, u32 status, |
13 | void *areq), | 15 | void *areq), |
14 | void *areq); | 16 | void *areq); |
15 | 17 | ||
16 | extern int caam_jr_probe(struct platform_device *pdev, struct device_node *np, | ||
17 | int ring); | ||
18 | extern int caam_jr_shutdown(struct device *dev); | ||
19 | #endif /* JR_H */ | 18 | #endif /* JR_H */ |
diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index 4455396918de..d50174f45b21 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h | |||
@@ -245,7 +245,7 @@ struct rngtst { | |||
245 | 245 | ||
246 | /* RNG4 TRNG test registers */ | 246 | /* RNG4 TRNG test registers */ |
247 | struct rng4tst { | 247 | struct rng4tst { |
248 | #define RTMCTL_PRGM 0x00010000 /* 1 -> program mode, 0 -> run mode */ | 248 | #define RTMCTL_PRGM 0x00010000 /* 1 -> program mode, 0 -> run mode */ |
249 | u32 rtmctl; /* misc. control register */ | 249 | u32 rtmctl; /* misc. control register */ |
250 | u32 rtscmisc; /* statistical check misc. register */ | 250 | u32 rtscmisc; /* statistical check misc. register */ |
251 | u32 rtpkrrng; /* poker range register */ | 251 | u32 rtpkrrng; /* poker range register */ |
@@ -255,6 +255,8 @@ struct rng4tst { | |||
255 | }; | 255 | }; |
256 | #define RTSDCTL_ENT_DLY_SHIFT 16 | 256 | #define RTSDCTL_ENT_DLY_SHIFT 16 |
257 | #define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT) | 257 | #define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT) |
258 | #define RTSDCTL_ENT_DLY_MIN 1200 | ||
259 | #define RTSDCTL_ENT_DLY_MAX 12800 | ||
258 | u32 rtsdctl; /* seed control register */ | 260 | u32 rtsdctl; /* seed control register */ |
259 | union { | 261 | union { |
260 | u32 rtsblim; /* PRGM=1: sparse bit limit register */ | 262 | u32 rtsblim; /* PRGM=1: sparse bit limit register */ |
@@ -266,7 +268,11 @@ struct rng4tst { | |||
266 | u32 rtfrqcnt; /* PRGM=0: freq. count register */ | 268 | u32 rtfrqcnt; /* PRGM=0: freq. count register */ |
267 | }; | 269 | }; |
268 | u32 rsvd1[40]; | 270 | u32 rsvd1[40]; |
271 | #define RDSTA_SKVT 0x80000000 | ||
272 | #define RDSTA_SKVN 0x40000000 | ||
269 | #define RDSTA_IF0 0x00000001 | 273 | #define RDSTA_IF0 0x00000001 |
274 | #define RDSTA_IF1 0x00000002 | ||
275 | #define RDSTA_IFMASK (RDSTA_IF1 | RDSTA_IF0) | ||
270 | u32 rdsta; | 276 | u32 rdsta; |
271 | u32 rsvd2[15]; | 277 | u32 rsvd2[15]; |
272 | }; | 278 | }; |
@@ -692,6 +698,7 @@ struct caam_deco { | |||
692 | u32 jr_ctl_hi; /* CxJRR - JobR Control Register @800 */ | 698 | u32 jr_ctl_hi; /* CxJRR - JobR Control Register @800 */ |
693 | u32 jr_ctl_lo; | 699 | u32 jr_ctl_lo; |
694 | u64 jr_descaddr; /* CxDADR - JobR Descriptor Address */ | 700 | u64 jr_descaddr; /* CxDADR - JobR Descriptor Address */ |
701 | #define DECO_OP_STATUS_HI_ERR_MASK 0xF00000FF | ||
695 | u32 op_status_hi; /* DxOPSTA - DECO Operation Status */ | 702 | u32 op_status_hi; /* DxOPSTA - DECO Operation Status */ |
696 | u32 op_status_lo; | 703 | u32 op_status_lo; |
697 | u32 rsvd24[2]; | 704 | u32 rsvd24[2]; |
@@ -706,12 +713,13 @@ struct caam_deco { | |||
706 | u32 rsvd29[48]; | 713 | u32 rsvd29[48]; |
707 | u32 descbuf[64]; /* DxDESB - Descriptor buffer */ | 714 | u32 descbuf[64]; /* DxDESB - Descriptor buffer */ |
708 | u32 rscvd30[193]; | 715 | u32 rscvd30[193]; |
716 | #define DESC_DBG_DECO_STAT_HOST_ERR 0x00D00000 | ||
717 | #define DESC_DBG_DECO_STAT_VALID 0x80000000 | ||
718 | #define DESC_DBG_DECO_STAT_MASK 0x00F00000 | ||
709 | u32 desc_dbg; /* DxDDR - DECO Debug Register */ | 719 | u32 desc_dbg; /* DxDDR - DECO Debug Register */ |
710 | u32 rsvd31[126]; | 720 | u32 rsvd31[126]; |
711 | }; | 721 | }; |
712 | 722 | ||
713 | /* DECO DBG Register Valid Bit*/ | ||
714 | #define DECO_DBG_VALID 0x80000000 | ||
715 | #define DECO_JQCR_WHL 0x20000000 | 723 | #define DECO_JQCR_WHL 0x20000000 |
716 | #define DECO_JQCR_FOUR 0x10000000 | 724 | #define DECO_JQCR_FOUR 0x10000000 |
717 | 725 | ||
diff --git a/drivers/crypto/caam/sg_sw_sec4.h b/drivers/crypto/caam/sg_sw_sec4.h index e0037c8ee243..b12ff85f4241 100644 --- a/drivers/crypto/caam/sg_sw_sec4.h +++ b/drivers/crypto/caam/sg_sw_sec4.h | |||
@@ -117,6 +117,21 @@ static int dma_unmap_sg_chained(struct device *dev, struct scatterlist *sg, | |||
117 | return nents; | 117 | return nents; |
118 | } | 118 | } |
119 | 119 | ||
120 | /* Map SG page in kernel virtual address space and copy */ | ||
121 | static inline void sg_map_copy(u8 *dest, struct scatterlist *sg, | ||
122 | int len, int offset) | ||
123 | { | ||
124 | u8 *mapped_addr; | ||
125 | |||
126 | /* | ||
127 | * Page here can be user-space pinned using get_user_pages | ||
128 | * Same must be kmapped before use and kunmapped subsequently | ||
129 | */ | ||
130 | mapped_addr = kmap_atomic(sg_page(sg)); | ||
131 | memcpy(dest, mapped_addr + offset, len); | ||
132 | kunmap_atomic(mapped_addr); | ||
133 | } | ||
134 | |||
120 | /* Copy from len bytes of sg to dest, starting from beginning */ | 135 | /* Copy from len bytes of sg to dest, starting from beginning */ |
121 | static inline void sg_copy(u8 *dest, struct scatterlist *sg, unsigned int len) | 136 | static inline void sg_copy(u8 *dest, struct scatterlist *sg, unsigned int len) |
122 | { | 137 | { |
@@ -124,15 +139,15 @@ static inline void sg_copy(u8 *dest, struct scatterlist *sg, unsigned int len) | |||
124 | int cpy_index = 0, next_cpy_index = current_sg->length; | 139 | int cpy_index = 0, next_cpy_index = current_sg->length; |
125 | 140 | ||
126 | while (next_cpy_index < len) { | 141 | while (next_cpy_index < len) { |
127 | memcpy(dest + cpy_index, (u8 *) sg_virt(current_sg), | 142 | sg_map_copy(dest + cpy_index, current_sg, current_sg->length, |
128 | current_sg->length); | 143 | current_sg->offset); |
129 | current_sg = scatterwalk_sg_next(current_sg); | 144 | current_sg = scatterwalk_sg_next(current_sg); |
130 | cpy_index = next_cpy_index; | 145 | cpy_index = next_cpy_index; |
131 | next_cpy_index += current_sg->length; | 146 | next_cpy_index += current_sg->length; |
132 | } | 147 | } |
133 | if (cpy_index < len) | 148 | if (cpy_index < len) |
134 | memcpy(dest + cpy_index, (u8 *) sg_virt(current_sg), | 149 | sg_map_copy(dest + cpy_index, current_sg, len-cpy_index, |
135 | len - cpy_index); | 150 | current_sg->offset); |
136 | } | 151 | } |
137 | 152 | ||
138 | /* Copy sg data, from to_skip to end, to dest */ | 153 | /* Copy sg data, from to_skip to end, to dest */ |
@@ -140,7 +155,7 @@ static inline void sg_copy_part(u8 *dest, struct scatterlist *sg, | |||
140 | int to_skip, unsigned int end) | 155 | int to_skip, unsigned int end) |
141 | { | 156 | { |
142 | struct scatterlist *current_sg = sg; | 157 | struct scatterlist *current_sg = sg; |
143 | int sg_index, cpy_index; | 158 | int sg_index, cpy_index, offset; |
144 | 159 | ||
145 | sg_index = current_sg->length; | 160 | sg_index = current_sg->length; |
146 | while (sg_index <= to_skip) { | 161 | while (sg_index <= to_skip) { |
@@ -148,9 +163,10 @@ static inline void sg_copy_part(u8 *dest, struct scatterlist *sg, | |||
148 | sg_index += current_sg->length; | 163 | sg_index += current_sg->length; |
149 | } | 164 | } |
150 | cpy_index = sg_index - to_skip; | 165 | cpy_index = sg_index - to_skip; |
151 | memcpy(dest, (u8 *) sg_virt(current_sg) + | 166 | offset = current_sg->offset + current_sg->length - cpy_index; |
152 | current_sg->length - cpy_index, cpy_index); | 167 | sg_map_copy(dest, current_sg, cpy_index, offset); |
153 | current_sg = scatterwalk_sg_next(current_sg); | 168 | if (end - sg_index) { |
154 | if (end - sg_index) | 169 | current_sg = scatterwalk_sg_next(current_sg); |
155 | sg_copy(dest + cpy_index, current_sg, end - sg_index); | 170 | sg_copy(dest + cpy_index, current_sg, end - sg_index); |
171 | } | ||
156 | } | 172 | } |
diff --git a/drivers/crypto/dcp.c b/drivers/crypto/dcp.c index a8a7dd4b0d25..247ab8048f5b 100644 --- a/drivers/crypto/dcp.c +++ b/drivers/crypto/dcp.c | |||
@@ -733,12 +733,9 @@ static int dcp_probe(struct platform_device *pdev) | |||
733 | platform_set_drvdata(pdev, dev); | 733 | platform_set_drvdata(pdev, dev); |
734 | 734 | ||
735 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 735 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
736 | if (!r) { | 736 | dev->dcp_regs_base = devm_ioremap_resource(&pdev->dev, r); |
737 | dev_err(&pdev->dev, "failed to get IORESOURCE_MEM\n"); | 737 | if (IS_ERR(dev->dcp_regs_base)) |
738 | return -ENXIO; | 738 | return PTR_ERR(dev->dcp_regs_base); |
739 | } | ||
740 | dev->dcp_regs_base = devm_ioremap(&pdev->dev, r->start, | ||
741 | resource_size(r)); | ||
742 | 739 | ||
743 | dcp_set(dev, DCP_CTRL_SFRST, DCP_REG_CTRL); | 740 | dcp_set(dev, DCP_CTRL_SFRST, DCP_REG_CTRL); |
744 | udelay(10); | 741 | udelay(10); |
@@ -762,7 +759,8 @@ static int dcp_probe(struct platform_device *pdev) | |||
762 | return -EIO; | 759 | return -EIO; |
763 | } | 760 | } |
764 | dev->dcp_vmi_irq = r->start; | 761 | dev->dcp_vmi_irq = r->start; |
765 | ret = request_irq(dev->dcp_vmi_irq, dcp_vmi_irq, 0, "dcp", dev); | 762 | ret = devm_request_irq(&pdev->dev, dev->dcp_vmi_irq, dcp_vmi_irq, 0, |
763 | "dcp", dev); | ||
766 | if (ret != 0) { | 764 | if (ret != 0) { |
767 | dev_err(&pdev->dev, "can't request_irq (0)\n"); | 765 | dev_err(&pdev->dev, "can't request_irq (0)\n"); |
768 | return -EIO; | 766 | return -EIO; |
@@ -771,15 +769,14 @@ static int dcp_probe(struct platform_device *pdev) | |||
771 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 1); | 769 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 1); |
772 | if (!r) { | 770 | if (!r) { |
773 | dev_err(&pdev->dev, "can't get IRQ resource (1)\n"); | 771 | dev_err(&pdev->dev, "can't get IRQ resource (1)\n"); |
774 | ret = -EIO; | 772 | return -EIO; |
775 | goto err_free_irq0; | ||
776 | } | 773 | } |
777 | dev->dcp_irq = r->start; | 774 | dev->dcp_irq = r->start; |
778 | ret = request_irq(dev->dcp_irq, dcp_irq, 0, "dcp", dev); | 775 | ret = devm_request_irq(&pdev->dev, dev->dcp_irq, dcp_irq, 0, "dcp", |
776 | dev); | ||
779 | if (ret != 0) { | 777 | if (ret != 0) { |
780 | dev_err(&pdev->dev, "can't request_irq (1)\n"); | 778 | dev_err(&pdev->dev, "can't request_irq (1)\n"); |
781 | ret = -EIO; | 779 | return -EIO; |
782 | goto err_free_irq0; | ||
783 | } | 780 | } |
784 | 781 | ||
785 | dev->hw_pkg[0] = dma_alloc_coherent(&pdev->dev, | 782 | dev->hw_pkg[0] = dma_alloc_coherent(&pdev->dev, |
@@ -788,8 +785,7 @@ static int dcp_probe(struct platform_device *pdev) | |||
788 | GFP_KERNEL); | 785 | GFP_KERNEL); |
789 | if (!dev->hw_pkg[0]) { | 786 | if (!dev->hw_pkg[0]) { |
790 | dev_err(&pdev->dev, "Could not allocate hw descriptors\n"); | 787 | dev_err(&pdev->dev, "Could not allocate hw descriptors\n"); |
791 | ret = -ENOMEM; | 788 | return -ENOMEM; |
792 | goto err_free_irq1; | ||
793 | } | 789 | } |
794 | 790 | ||
795 | for (i = 1; i < DCP_MAX_PKG; i++) { | 791 | for (i = 1; i < DCP_MAX_PKG; i++) { |
@@ -848,16 +844,14 @@ err_unregister: | |||
848 | for (j = 0; j < i; j++) | 844 | for (j = 0; j < i; j++) |
849 | crypto_unregister_alg(&algs[j]); | 845 | crypto_unregister_alg(&algs[j]); |
850 | err_free_key_iv: | 846 | err_free_key_iv: |
847 | tasklet_kill(&dev->done_task); | ||
848 | tasklet_kill(&dev->queue_task); | ||
851 | dma_free_coherent(&pdev->dev, 2 * AES_KEYSIZE_128, dev->payload_base, | 849 | dma_free_coherent(&pdev->dev, 2 * AES_KEYSIZE_128, dev->payload_base, |
852 | dev->payload_base_dma); | 850 | dev->payload_base_dma); |
853 | err_free_hw_packet: | 851 | err_free_hw_packet: |
854 | dma_free_coherent(&pdev->dev, DCP_MAX_PKG * | 852 | dma_free_coherent(&pdev->dev, DCP_MAX_PKG * |
855 | sizeof(struct dcp_hw_packet), dev->hw_pkg[0], | 853 | sizeof(struct dcp_hw_packet), dev->hw_pkg[0], |
856 | dev->hw_phys_pkg); | 854 | dev->hw_phys_pkg); |
857 | err_free_irq1: | ||
858 | free_irq(dev->dcp_irq, dev); | ||
859 | err_free_irq0: | ||
860 | free_irq(dev->dcp_vmi_irq, dev); | ||
861 | 855 | ||
862 | return ret; | 856 | return ret; |
863 | } | 857 | } |
@@ -868,23 +862,20 @@ static int dcp_remove(struct platform_device *pdev) | |||
868 | int j; | 862 | int j; |
869 | dev = platform_get_drvdata(pdev); | 863 | dev = platform_get_drvdata(pdev); |
870 | 864 | ||
871 | dma_free_coherent(&pdev->dev, | 865 | misc_deregister(&dev->dcp_bootstream_misc); |
872 | DCP_MAX_PKG * sizeof(struct dcp_hw_packet), | ||
873 | dev->hw_pkg[0], dev->hw_phys_pkg); | ||
874 | |||
875 | dma_free_coherent(&pdev->dev, 2 * AES_KEYSIZE_128, dev->payload_base, | ||
876 | dev->payload_base_dma); | ||
877 | 866 | ||
878 | free_irq(dev->dcp_irq, dev); | 867 | for (j = 0; j < ARRAY_SIZE(algs); j++) |
879 | free_irq(dev->dcp_vmi_irq, dev); | 868 | crypto_unregister_alg(&algs[j]); |
880 | 869 | ||
881 | tasklet_kill(&dev->done_task); | 870 | tasklet_kill(&dev->done_task); |
882 | tasklet_kill(&dev->queue_task); | 871 | tasklet_kill(&dev->queue_task); |
883 | 872 | ||
884 | for (j = 0; j < ARRAY_SIZE(algs); j++) | 873 | dma_free_coherent(&pdev->dev, 2 * AES_KEYSIZE_128, dev->payload_base, |
885 | crypto_unregister_alg(&algs[j]); | 874 | dev->payload_base_dma); |
886 | 875 | ||
887 | misc_deregister(&dev->dcp_bootstream_misc); | 876 | dma_free_coherent(&pdev->dev, |
877 | DCP_MAX_PKG * sizeof(struct dcp_hw_packet), | ||
878 | dev->hw_pkg[0], dev->hw_phys_pkg); | ||
888 | 879 | ||
889 | return 0; | 880 | return 0; |
890 | } | 881 | } |
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c index 214357e12dc0..9dd6e01eac33 100644 --- a/drivers/crypto/ixp4xx_crypto.c +++ b/drivers/crypto/ixp4xx_crypto.c | |||
@@ -1149,32 +1149,24 @@ static int aead_setkey(struct crypto_aead *tfm, const u8 *key, | |||
1149 | unsigned int keylen) | 1149 | unsigned int keylen) |
1150 | { | 1150 | { |
1151 | struct ixp_ctx *ctx = crypto_aead_ctx(tfm); | 1151 | struct ixp_ctx *ctx = crypto_aead_ctx(tfm); |
1152 | struct rtattr *rta = (struct rtattr *)key; | 1152 | struct crypto_authenc_keys keys; |
1153 | struct crypto_authenc_key_param *param; | ||
1154 | 1153 | ||
1155 | if (!RTA_OK(rta, keylen)) | 1154 | if (crypto_authenc_extractkeys(&keys, key, keylen) != 0) |
1156 | goto badkey; | ||
1157 | if (rta->rta_type != CRYPTO_AUTHENC_KEYA_PARAM) | ||
1158 | goto badkey; | ||
1159 | if (RTA_PAYLOAD(rta) < sizeof(*param)) | ||
1160 | goto badkey; | 1155 | goto badkey; |
1161 | 1156 | ||
1162 | param = RTA_DATA(rta); | 1157 | if (keys.authkeylen > sizeof(ctx->authkey)) |
1163 | ctx->enckey_len = be32_to_cpu(param->enckeylen); | 1158 | goto badkey; |
1164 | |||
1165 | key += RTA_ALIGN(rta->rta_len); | ||
1166 | keylen -= RTA_ALIGN(rta->rta_len); | ||
1167 | 1159 | ||
1168 | if (keylen < ctx->enckey_len) | 1160 | if (keys.enckeylen > sizeof(ctx->enckey)) |
1169 | goto badkey; | 1161 | goto badkey; |
1170 | 1162 | ||
1171 | ctx->authkey_len = keylen - ctx->enckey_len; | 1163 | memcpy(ctx->authkey, keys.authkey, keys.authkeylen); |
1172 | memcpy(ctx->enckey, key + ctx->authkey_len, ctx->enckey_len); | 1164 | memcpy(ctx->enckey, keys.enckey, keys.enckeylen); |
1173 | memcpy(ctx->authkey, key, ctx->authkey_len); | 1165 | ctx->authkey_len = keys.authkeylen; |
1166 | ctx->enckey_len = keys.enckeylen; | ||
1174 | 1167 | ||
1175 | return aead_setup(tfm, crypto_aead_authsize(tfm)); | 1168 | return aead_setup(tfm, crypto_aead_authsize(tfm)); |
1176 | badkey: | 1169 | badkey: |
1177 | ctx->enckey_len = 0; | ||
1178 | crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); | 1170 | crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); |
1179 | return -EINVAL; | 1171 | return -EINVAL; |
1180 | } | 1172 | } |
diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c index 3374a3ebe4c7..8d1e6f8e9e9c 100644 --- a/drivers/crypto/mv_cesa.c +++ b/drivers/crypto/mv_cesa.c | |||
@@ -907,7 +907,7 @@ static int mv_cra_hash_hmac_sha1_init(struct crypto_tfm *tfm) | |||
907 | return mv_cra_hash_init(tfm, "sha1", COP_HMAC_SHA1, SHA1_BLOCK_SIZE); | 907 | return mv_cra_hash_init(tfm, "sha1", COP_HMAC_SHA1, SHA1_BLOCK_SIZE); |
908 | } | 908 | } |
909 | 909 | ||
910 | irqreturn_t crypto_int(int irq, void *priv) | 910 | static irqreturn_t crypto_int(int irq, void *priv) |
911 | { | 911 | { |
912 | u32 val; | 912 | u32 val; |
913 | 913 | ||
@@ -928,7 +928,7 @@ irqreturn_t crypto_int(int irq, void *priv) | |||
928 | return IRQ_HANDLED; | 928 | return IRQ_HANDLED; |
929 | } | 929 | } |
930 | 930 | ||
931 | struct crypto_alg mv_aes_alg_ecb = { | 931 | static struct crypto_alg mv_aes_alg_ecb = { |
932 | .cra_name = "ecb(aes)", | 932 | .cra_name = "ecb(aes)", |
933 | .cra_driver_name = "mv-ecb-aes", | 933 | .cra_driver_name = "mv-ecb-aes", |
934 | .cra_priority = 300, | 934 | .cra_priority = 300, |
@@ -951,7 +951,7 @@ struct crypto_alg mv_aes_alg_ecb = { | |||
951 | }, | 951 | }, |
952 | }; | 952 | }; |
953 | 953 | ||
954 | struct crypto_alg mv_aes_alg_cbc = { | 954 | static struct crypto_alg mv_aes_alg_cbc = { |
955 | .cra_name = "cbc(aes)", | 955 | .cra_name = "cbc(aes)", |
956 | .cra_driver_name = "mv-cbc-aes", | 956 | .cra_driver_name = "mv-cbc-aes", |
957 | .cra_priority = 300, | 957 | .cra_priority = 300, |
@@ -975,7 +975,7 @@ struct crypto_alg mv_aes_alg_cbc = { | |||
975 | }, | 975 | }, |
976 | }; | 976 | }; |
977 | 977 | ||
978 | struct ahash_alg mv_sha1_alg = { | 978 | static struct ahash_alg mv_sha1_alg = { |
979 | .init = mv_hash_init, | 979 | .init = mv_hash_init, |
980 | .update = mv_hash_update, | 980 | .update = mv_hash_update, |
981 | .final = mv_hash_final, | 981 | .final = mv_hash_final, |
@@ -999,7 +999,7 @@ struct ahash_alg mv_sha1_alg = { | |||
999 | } | 999 | } |
1000 | }; | 1000 | }; |
1001 | 1001 | ||
1002 | struct ahash_alg mv_hmac_sha1_alg = { | 1002 | static struct ahash_alg mv_hmac_sha1_alg = { |
1003 | .init = mv_hash_init, | 1003 | .init = mv_hash_init, |
1004 | .update = mv_hash_update, | 1004 | .update = mv_hash_update, |
1005 | .final = mv_hash_final, | 1005 | .final = mv_hash_final, |
@@ -1084,7 +1084,7 @@ static int mv_probe(struct platform_device *pdev) | |||
1084 | goto err_unmap_sram; | 1084 | goto err_unmap_sram; |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | ret = request_irq(irq, crypto_int, IRQF_DISABLED, dev_name(&pdev->dev), | 1087 | ret = request_irq(irq, crypto_int, 0, dev_name(&pdev->dev), |
1088 | cp); | 1088 | cp); |
1089 | if (ret) | 1089 | if (ret) |
1090 | goto err_thread; | 1090 | goto err_thread; |
@@ -1187,7 +1187,7 @@ static struct platform_driver marvell_crypto = { | |||
1187 | .driver = { | 1187 | .driver = { |
1188 | .owner = THIS_MODULE, | 1188 | .owner = THIS_MODULE, |
1189 | .name = "mv_crypto", | 1189 | .name = "mv_crypto", |
1190 | .of_match_table = of_match_ptr(mv_cesa_of_match_table), | 1190 | .of_match_table = mv_cesa_of_match_table, |
1191 | }, | 1191 | }, |
1192 | }; | 1192 | }; |
1193 | MODULE_ALIAS("platform:mv_crypto"); | 1193 | MODULE_ALIAS("platform:mv_crypto"); |
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index ce791c2f81f7..a9ccbf14096e 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c | |||
@@ -275,7 +275,7 @@ static int omap_aes_write_ctrl(struct omap_aes_dev *dd) | |||
275 | if (dd->flags & FLAGS_CBC) | 275 | if (dd->flags & FLAGS_CBC) |
276 | val |= AES_REG_CTRL_CBC; | 276 | val |= AES_REG_CTRL_CBC; |
277 | if (dd->flags & FLAGS_CTR) { | 277 | if (dd->flags & FLAGS_CTR) { |
278 | val |= AES_REG_CTRL_CTR | AES_REG_CTRL_CTR_WIDTH_32; | 278 | val |= AES_REG_CTRL_CTR | AES_REG_CTRL_CTR_WIDTH_128; |
279 | mask = AES_REG_CTRL_CTR | AES_REG_CTRL_CTR_WIDTH_MASK; | 279 | mask = AES_REG_CTRL_CTR | AES_REG_CTRL_CTR_WIDTH_MASK; |
280 | } | 280 | } |
281 | if (dd->flags & FLAGS_ENCRYPT) | 281 | if (dd->flags & FLAGS_ENCRYPT) |
@@ -554,7 +554,7 @@ static int omap_aes_crypt_dma_stop(struct omap_aes_dev *dd) | |||
554 | return err; | 554 | return err; |
555 | } | 555 | } |
556 | 556 | ||
557 | int omap_aes_check_aligned(struct scatterlist *sg) | 557 | static int omap_aes_check_aligned(struct scatterlist *sg) |
558 | { | 558 | { |
559 | while (sg) { | 559 | while (sg) { |
560 | if (!IS_ALIGNED(sg->offset, 4)) | 560 | if (!IS_ALIGNED(sg->offset, 4)) |
@@ -566,7 +566,7 @@ int omap_aes_check_aligned(struct scatterlist *sg) | |||
566 | return 0; | 566 | return 0; |
567 | } | 567 | } |
568 | 568 | ||
569 | int omap_aes_copy_sgs(struct omap_aes_dev *dd) | 569 | static int omap_aes_copy_sgs(struct omap_aes_dev *dd) |
570 | { | 570 | { |
571 | void *buf_in, *buf_out; | 571 | void *buf_in, *buf_out; |
572 | int pages; | 572 | int pages; |
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index e28104b4aab0..e45aaaf0db30 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c | |||
@@ -2033,3 +2033,4 @@ module_platform_driver(omap_sham_driver); | |||
2033 | MODULE_DESCRIPTION("OMAP SHA1/MD5 hw acceleration support."); | 2033 | MODULE_DESCRIPTION("OMAP SHA1/MD5 hw acceleration support."); |
2034 | MODULE_LICENSE("GPL v2"); | 2034 | MODULE_LICENSE("GPL v2"); |
2035 | MODULE_AUTHOR("Dmitry Kasatkin"); | 2035 | MODULE_AUTHOR("Dmitry Kasatkin"); |
2036 | MODULE_ALIAS("platform:omap-sham"); | ||
diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c index 888f7f4a6d3f..a6175ba6d238 100644 --- a/drivers/crypto/picoxcell_crypto.c +++ b/drivers/crypto/picoxcell_crypto.c | |||
@@ -495,45 +495,29 @@ static int spacc_aead_setkey(struct crypto_aead *tfm, const u8 *key, | |||
495 | { | 495 | { |
496 | struct spacc_aead_ctx *ctx = crypto_aead_ctx(tfm); | 496 | struct spacc_aead_ctx *ctx = crypto_aead_ctx(tfm); |
497 | struct spacc_alg *alg = to_spacc_alg(tfm->base.__crt_alg); | 497 | struct spacc_alg *alg = to_spacc_alg(tfm->base.__crt_alg); |
498 | struct rtattr *rta = (void *)key; | 498 | struct crypto_authenc_keys keys; |
499 | struct crypto_authenc_key_param *param; | ||
500 | unsigned int authkeylen, enckeylen; | ||
501 | int err = -EINVAL; | 499 | int err = -EINVAL; |
502 | 500 | ||
503 | if (!RTA_OK(rta, keylen)) | 501 | if (crypto_authenc_extractkeys(&keys, key, keylen) != 0) |
504 | goto badkey; | 502 | goto badkey; |
505 | 503 | ||
506 | if (rta->rta_type != CRYPTO_AUTHENC_KEYA_PARAM) | 504 | if (keys.enckeylen > AES_MAX_KEY_SIZE) |
507 | goto badkey; | 505 | goto badkey; |
508 | 506 | ||
509 | if (RTA_PAYLOAD(rta) < sizeof(*param)) | 507 | if (keys.authkeylen > sizeof(ctx->hash_ctx)) |
510 | goto badkey; | ||
511 | |||
512 | param = RTA_DATA(rta); | ||
513 | enckeylen = be32_to_cpu(param->enckeylen); | ||
514 | |||
515 | key += RTA_ALIGN(rta->rta_len); | ||
516 | keylen -= RTA_ALIGN(rta->rta_len); | ||
517 | |||
518 | if (keylen < enckeylen) | ||
519 | goto badkey; | ||
520 | |||
521 | authkeylen = keylen - enckeylen; | ||
522 | |||
523 | if (enckeylen > AES_MAX_KEY_SIZE) | ||
524 | goto badkey; | 508 | goto badkey; |
525 | 509 | ||
526 | if ((alg->ctrl_default & SPACC_CRYPTO_ALG_MASK) == | 510 | if ((alg->ctrl_default & SPACC_CRYPTO_ALG_MASK) == |
527 | SPA_CTRL_CIPH_ALG_AES) | 511 | SPA_CTRL_CIPH_ALG_AES) |
528 | err = spacc_aead_aes_setkey(tfm, key + authkeylen, enckeylen); | 512 | err = spacc_aead_aes_setkey(tfm, keys.enckey, keys.enckeylen); |
529 | else | 513 | else |
530 | err = spacc_aead_des_setkey(tfm, key + authkeylen, enckeylen); | 514 | err = spacc_aead_des_setkey(tfm, keys.enckey, keys.enckeylen); |
531 | 515 | ||
532 | if (err) | 516 | if (err) |
533 | goto badkey; | 517 | goto badkey; |
534 | 518 | ||
535 | memcpy(ctx->hash_ctx, key, authkeylen); | 519 | memcpy(ctx->hash_ctx, keys.authkey, keys.authkeylen); |
536 | ctx->hash_key_len = authkeylen; | 520 | ctx->hash_key_len = keys.authkeylen; |
537 | 521 | ||
538 | return 0; | 522 | return 0; |
539 | 523 | ||
diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c index d7bb8bac36e9..785a9ded7bdf 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c | |||
@@ -1058,7 +1058,7 @@ static struct platform_driver sahara_driver = { | |||
1058 | .driver = { | 1058 | .driver = { |
1059 | .name = SAHARA_NAME, | 1059 | .name = SAHARA_NAME, |
1060 | .owner = THIS_MODULE, | 1060 | .owner = THIS_MODULE, |
1061 | .of_match_table = of_match_ptr(sahara_dt_ids), | 1061 | .of_match_table = sahara_dt_ids, |
1062 | }, | 1062 | }, |
1063 | .id_table = sahara_platform_ids, | 1063 | .id_table = sahara_platform_ids, |
1064 | }; | 1064 | }; |
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 6cd0e6038583..b44f4ddc565c 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c | |||
@@ -673,39 +673,20 @@ static int aead_setkey(struct crypto_aead *authenc, | |||
673 | const u8 *key, unsigned int keylen) | 673 | const u8 *key, unsigned int keylen) |
674 | { | 674 | { |
675 | struct talitos_ctx *ctx = crypto_aead_ctx(authenc); | 675 | struct talitos_ctx *ctx = crypto_aead_ctx(authenc); |
676 | struct rtattr *rta = (void *)key; | 676 | struct crypto_authenc_keys keys; |
677 | struct crypto_authenc_key_param *param; | ||
678 | unsigned int authkeylen; | ||
679 | unsigned int enckeylen; | ||
680 | |||
681 | if (!RTA_OK(rta, keylen)) | ||
682 | goto badkey; | ||
683 | 677 | ||
684 | if (rta->rta_type != CRYPTO_AUTHENC_KEYA_PARAM) | 678 | if (crypto_authenc_extractkeys(&keys, key, keylen) != 0) |
685 | goto badkey; | 679 | goto badkey; |
686 | 680 | ||
687 | if (RTA_PAYLOAD(rta) < sizeof(*param)) | 681 | if (keys.authkeylen + keys.enckeylen > TALITOS_MAX_KEY_SIZE) |
688 | goto badkey; | 682 | goto badkey; |
689 | 683 | ||
690 | param = RTA_DATA(rta); | 684 | memcpy(ctx->key, keys.authkey, keys.authkeylen); |
691 | enckeylen = be32_to_cpu(param->enckeylen); | 685 | memcpy(&ctx->key[keys.authkeylen], keys.enckey, keys.enckeylen); |
692 | |||
693 | key += RTA_ALIGN(rta->rta_len); | ||
694 | keylen -= RTA_ALIGN(rta->rta_len); | ||
695 | 686 | ||
696 | if (keylen < enckeylen) | 687 | ctx->keylen = keys.authkeylen + keys.enckeylen; |
697 | goto badkey; | 688 | ctx->enckeylen = keys.enckeylen; |
698 | 689 | ctx->authkeylen = keys.authkeylen; | |
699 | authkeylen = keylen - enckeylen; | ||
700 | |||
701 | if (keylen > TALITOS_MAX_KEY_SIZE) | ||
702 | goto badkey; | ||
703 | |||
704 | memcpy(&ctx->key, key, keylen); | ||
705 | |||
706 | ctx->keylen = keylen; | ||
707 | ctx->enckeylen = enckeylen; | ||
708 | ctx->authkeylen = authkeylen; | ||
709 | 690 | ||
710 | return 0; | 691 | return 0; |
711 | 692 | ||
@@ -809,7 +790,7 @@ static void ipsec_esp_unmap(struct device *dev, | |||
809 | 790 | ||
810 | if (edesc->assoc_chained) | 791 | if (edesc->assoc_chained) |
811 | talitos_unmap_sg_chain(dev, areq->assoc, DMA_TO_DEVICE); | 792 | talitos_unmap_sg_chain(dev, areq->assoc, DMA_TO_DEVICE); |
812 | else | 793 | else if (areq->assoclen) |
813 | /* assoc_nents counts also for IV in non-contiguous cases */ | 794 | /* assoc_nents counts also for IV in non-contiguous cases */ |
814 | dma_unmap_sg(dev, areq->assoc, | 795 | dma_unmap_sg(dev, areq->assoc, |
815 | edesc->assoc_nents ? edesc->assoc_nents - 1 : 1, | 796 | edesc->assoc_nents ? edesc->assoc_nents - 1 : 1, |
@@ -992,7 +973,11 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, | |||
992 | dma_sync_single_for_device(dev, edesc->dma_link_tbl, | 973 | dma_sync_single_for_device(dev, edesc->dma_link_tbl, |
993 | edesc->dma_len, DMA_BIDIRECTIONAL); | 974 | edesc->dma_len, DMA_BIDIRECTIONAL); |
994 | } else { | 975 | } else { |
995 | to_talitos_ptr(&desc->ptr[1], sg_dma_address(areq->assoc)); | 976 | if (areq->assoclen) |
977 | to_talitos_ptr(&desc->ptr[1], | ||
978 | sg_dma_address(areq->assoc)); | ||
979 | else | ||
980 | to_talitos_ptr(&desc->ptr[1], edesc->iv_dma); | ||
996 | desc->ptr[1].j_extent = 0; | 981 | desc->ptr[1].j_extent = 0; |
997 | } | 982 | } |
998 | 983 | ||
@@ -1127,7 +1112,8 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | |||
1127 | unsigned int authsize, | 1112 | unsigned int authsize, |
1128 | unsigned int ivsize, | 1113 | unsigned int ivsize, |
1129 | int icv_stashing, | 1114 | int icv_stashing, |
1130 | u32 cryptoflags) | 1115 | u32 cryptoflags, |
1116 | bool encrypt) | ||
1131 | { | 1117 | { |
1132 | struct talitos_edesc *edesc; | 1118 | struct talitos_edesc *edesc; |
1133 | int assoc_nents = 0, src_nents, dst_nents, alloc_len, dma_len; | 1119 | int assoc_nents = 0, src_nents, dst_nents, alloc_len, dma_len; |
@@ -1141,10 +1127,10 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | |||
1141 | return ERR_PTR(-EINVAL); | 1127 | return ERR_PTR(-EINVAL); |
1142 | } | 1128 | } |
1143 | 1129 | ||
1144 | if (iv) | 1130 | if (ivsize) |
1145 | iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE); | 1131 | iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE); |
1146 | 1132 | ||
1147 | if (assoc) { | 1133 | if (assoclen) { |
1148 | /* | 1134 | /* |
1149 | * Currently it is assumed that iv is provided whenever assoc | 1135 | * Currently it is assumed that iv is provided whenever assoc |
1150 | * is. | 1136 | * is. |
@@ -1160,19 +1146,17 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | |||
1160 | assoc_nents = assoc_nents ? assoc_nents + 1 : 2; | 1146 | assoc_nents = assoc_nents ? assoc_nents + 1 : 2; |
1161 | } | 1147 | } |
1162 | 1148 | ||
1163 | src_nents = sg_count(src, cryptlen + authsize, &src_chained); | 1149 | if (!dst || dst == src) { |
1164 | src_nents = (src_nents == 1) ? 0 : src_nents; | 1150 | src_nents = sg_count(src, cryptlen + authsize, &src_chained); |
1165 | 1151 | src_nents = (src_nents == 1) ? 0 : src_nents; | |
1166 | if (!dst) { | 1152 | dst_nents = dst ? src_nents : 0; |
1167 | dst_nents = 0; | 1153 | } else { /* dst && dst != src*/ |
1168 | } else { | 1154 | src_nents = sg_count(src, cryptlen + (encrypt ? 0 : authsize), |
1169 | if (dst == src) { | 1155 | &src_chained); |
1170 | dst_nents = src_nents; | 1156 | src_nents = (src_nents == 1) ? 0 : src_nents; |
1171 | } else { | 1157 | dst_nents = sg_count(dst, cryptlen + (encrypt ? authsize : 0), |
1172 | dst_nents = sg_count(dst, cryptlen + authsize, | 1158 | &dst_chained); |
1173 | &dst_chained); | 1159 | dst_nents = (dst_nents == 1) ? 0 : dst_nents; |
1174 | dst_nents = (dst_nents == 1) ? 0 : dst_nents; | ||
1175 | } | ||
1176 | } | 1160 | } |
1177 | 1161 | ||
1178 | /* | 1162 | /* |
@@ -1192,9 +1176,16 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | |||
1192 | 1176 | ||
1193 | edesc = kmalloc(alloc_len, GFP_DMA | flags); | 1177 | edesc = kmalloc(alloc_len, GFP_DMA | flags); |
1194 | if (!edesc) { | 1178 | if (!edesc) { |
1195 | talitos_unmap_sg_chain(dev, assoc, DMA_TO_DEVICE); | 1179 | if (assoc_chained) |
1180 | talitos_unmap_sg_chain(dev, assoc, DMA_TO_DEVICE); | ||
1181 | else if (assoclen) | ||
1182 | dma_unmap_sg(dev, assoc, | ||
1183 | assoc_nents ? assoc_nents - 1 : 1, | ||
1184 | DMA_TO_DEVICE); | ||
1185 | |||
1196 | if (iv_dma) | 1186 | if (iv_dma) |
1197 | dma_unmap_single(dev, iv_dma, ivsize, DMA_TO_DEVICE); | 1187 | dma_unmap_single(dev, iv_dma, ivsize, DMA_TO_DEVICE); |
1188 | |||
1198 | dev_err(dev, "could not allocate edescriptor\n"); | 1189 | dev_err(dev, "could not allocate edescriptor\n"); |
1199 | return ERR_PTR(-ENOMEM); | 1190 | return ERR_PTR(-ENOMEM); |
1200 | } | 1191 | } |
@@ -1216,7 +1207,7 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | |||
1216 | } | 1207 | } |
1217 | 1208 | ||
1218 | static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv, | 1209 | static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv, |
1219 | int icv_stashing) | 1210 | int icv_stashing, bool encrypt) |
1220 | { | 1211 | { |
1221 | struct crypto_aead *authenc = crypto_aead_reqtfm(areq); | 1212 | struct crypto_aead *authenc = crypto_aead_reqtfm(areq); |
1222 | struct talitos_ctx *ctx = crypto_aead_ctx(authenc); | 1213 | struct talitos_ctx *ctx = crypto_aead_ctx(authenc); |
@@ -1225,7 +1216,7 @@ static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv, | |||
1225 | return talitos_edesc_alloc(ctx->dev, areq->assoc, areq->src, areq->dst, | 1216 | return talitos_edesc_alloc(ctx->dev, areq->assoc, areq->src, areq->dst, |
1226 | iv, areq->assoclen, areq->cryptlen, | 1217 | iv, areq->assoclen, areq->cryptlen, |
1227 | ctx->authsize, ivsize, icv_stashing, | 1218 | ctx->authsize, ivsize, icv_stashing, |
1228 | areq->base.flags); | 1219 | areq->base.flags, encrypt); |
1229 | } | 1220 | } |
1230 | 1221 | ||
1231 | static int aead_encrypt(struct aead_request *req) | 1222 | static int aead_encrypt(struct aead_request *req) |
@@ -1235,7 +1226,7 @@ static int aead_encrypt(struct aead_request *req) | |||
1235 | struct talitos_edesc *edesc; | 1226 | struct talitos_edesc *edesc; |
1236 | 1227 | ||
1237 | /* allocate extended descriptor */ | 1228 | /* allocate extended descriptor */ |
1238 | edesc = aead_edesc_alloc(req, req->iv, 0); | 1229 | edesc = aead_edesc_alloc(req, req->iv, 0, true); |
1239 | if (IS_ERR(edesc)) | 1230 | if (IS_ERR(edesc)) |
1240 | return PTR_ERR(edesc); | 1231 | return PTR_ERR(edesc); |
1241 | 1232 | ||
@@ -1258,7 +1249,7 @@ static int aead_decrypt(struct aead_request *req) | |||
1258 | req->cryptlen -= authsize; | 1249 | req->cryptlen -= authsize; |
1259 | 1250 | ||
1260 | /* allocate extended descriptor */ | 1251 | /* allocate extended descriptor */ |
1261 | edesc = aead_edesc_alloc(req, req->iv, 1); | 1252 | edesc = aead_edesc_alloc(req, req->iv, 1, false); |
1262 | if (IS_ERR(edesc)) | 1253 | if (IS_ERR(edesc)) |
1263 | return PTR_ERR(edesc); | 1254 | return PTR_ERR(edesc); |
1264 | 1255 | ||
@@ -1304,7 +1295,7 @@ static int aead_givencrypt(struct aead_givcrypt_request *req) | |||
1304 | struct talitos_edesc *edesc; | 1295 | struct talitos_edesc *edesc; |
1305 | 1296 | ||
1306 | /* allocate extended descriptor */ | 1297 | /* allocate extended descriptor */ |
1307 | edesc = aead_edesc_alloc(areq, req->giv, 0); | 1298 | edesc = aead_edesc_alloc(areq, req->giv, 0, true); |
1308 | if (IS_ERR(edesc)) | 1299 | if (IS_ERR(edesc)) |
1309 | return PTR_ERR(edesc); | 1300 | return PTR_ERR(edesc); |
1310 | 1301 | ||
@@ -1460,7 +1451,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc, | |||
1460 | } | 1451 | } |
1461 | 1452 | ||
1462 | static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request * | 1453 | static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request * |
1463 | areq) | 1454 | areq, bool encrypt) |
1464 | { | 1455 | { |
1465 | struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); | 1456 | struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); |
1466 | struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); | 1457 | struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); |
@@ -1468,7 +1459,7 @@ static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request * | |||
1468 | 1459 | ||
1469 | return talitos_edesc_alloc(ctx->dev, NULL, areq->src, areq->dst, | 1460 | return talitos_edesc_alloc(ctx->dev, NULL, areq->src, areq->dst, |
1470 | areq->info, 0, areq->nbytes, 0, ivsize, 0, | 1461 | areq->info, 0, areq->nbytes, 0, ivsize, 0, |
1471 | areq->base.flags); | 1462 | areq->base.flags, encrypt); |
1472 | } | 1463 | } |
1473 | 1464 | ||
1474 | static int ablkcipher_encrypt(struct ablkcipher_request *areq) | 1465 | static int ablkcipher_encrypt(struct ablkcipher_request *areq) |
@@ -1478,7 +1469,7 @@ static int ablkcipher_encrypt(struct ablkcipher_request *areq) | |||
1478 | struct talitos_edesc *edesc; | 1469 | struct talitos_edesc *edesc; |
1479 | 1470 | ||
1480 | /* allocate extended descriptor */ | 1471 | /* allocate extended descriptor */ |
1481 | edesc = ablkcipher_edesc_alloc(areq); | 1472 | edesc = ablkcipher_edesc_alloc(areq, true); |
1482 | if (IS_ERR(edesc)) | 1473 | if (IS_ERR(edesc)) |
1483 | return PTR_ERR(edesc); | 1474 | return PTR_ERR(edesc); |
1484 | 1475 | ||
@@ -1495,7 +1486,7 @@ static int ablkcipher_decrypt(struct ablkcipher_request *areq) | |||
1495 | struct talitos_edesc *edesc; | 1486 | struct talitos_edesc *edesc; |
1496 | 1487 | ||
1497 | /* allocate extended descriptor */ | 1488 | /* allocate extended descriptor */ |
1498 | edesc = ablkcipher_edesc_alloc(areq); | 1489 | edesc = ablkcipher_edesc_alloc(areq, false); |
1499 | if (IS_ERR(edesc)) | 1490 | if (IS_ERR(edesc)) |
1500 | return PTR_ERR(edesc); | 1491 | return PTR_ERR(edesc); |
1501 | 1492 | ||
@@ -1647,7 +1638,7 @@ static struct talitos_edesc *ahash_edesc_alloc(struct ahash_request *areq, | |||
1647 | struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); | 1638 | struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); |
1648 | 1639 | ||
1649 | return talitos_edesc_alloc(ctx->dev, NULL, req_ctx->psrc, NULL, NULL, 0, | 1640 | return talitos_edesc_alloc(ctx->dev, NULL, req_ctx->psrc, NULL, NULL, 0, |
1650 | nbytes, 0, 0, 0, areq->base.flags); | 1641 | nbytes, 0, 0, 0, areq->base.flags, false); |
1651 | } | 1642 | } |
1652 | 1643 | ||
1653 | static int ahash_init(struct ahash_request *areq) | 1644 | static int ahash_init(struct ahash_request *areq) |
diff --git a/drivers/crypto/tegra-aes.c b/drivers/crypto/tegra-aes.c index fa05e3c329bd..060eecc5dbc3 100644 --- a/drivers/crypto/tegra-aes.c +++ b/drivers/crypto/tegra-aes.c | |||
@@ -27,6 +27,8 @@ | |||
27 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 27 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
31 | |||
30 | #include <linux/module.h> | 32 | #include <linux/module.h> |
31 | #include <linux/init.h> | 33 | #include <linux/init.h> |
32 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
@@ -199,8 +201,6 @@ static void aes_workqueue_handler(struct work_struct *work); | |||
199 | static DECLARE_WORK(aes_work, aes_workqueue_handler); | 201 | static DECLARE_WORK(aes_work, aes_workqueue_handler); |
200 | static struct workqueue_struct *aes_wq; | 202 | static struct workqueue_struct *aes_wq; |
201 | 203 | ||
202 | extern unsigned long long tegra_chip_uid(void); | ||
203 | |||
204 | static inline u32 aes_readl(struct tegra_aes_dev *dd, u32 offset) | 204 | static inline u32 aes_readl(struct tegra_aes_dev *dd, u32 offset) |
205 | { | 205 | { |
206 | return readl(dd->io_base + offset); | 206 | return readl(dd->io_base + offset); |
@@ -713,13 +713,12 @@ static int tegra_aes_rng_reset(struct crypto_rng *tfm, u8 *seed, | |||
713 | struct tegra_aes_dev *dd = aes_dev; | 713 | struct tegra_aes_dev *dd = aes_dev; |
714 | struct tegra_aes_ctx *ctx = &rng_ctx; | 714 | struct tegra_aes_ctx *ctx = &rng_ctx; |
715 | struct tegra_aes_slot *key_slot; | 715 | struct tegra_aes_slot *key_slot; |
716 | struct timespec ts; | ||
717 | int ret = 0; | 716 | int ret = 0; |
718 | u64 nsec, tmp[2]; | 717 | u8 tmp[16]; /* 16 bytes = 128 bits of entropy */ |
719 | u8 *dt; | 718 | u8 *dt; |
720 | 719 | ||
721 | if (!ctx || !dd) { | 720 | if (!ctx || !dd) { |
722 | dev_err(dd->dev, "ctx=0x%x, dd=0x%x\n", | 721 | pr_err("ctx=0x%x, dd=0x%x\n", |
723 | (unsigned int)ctx, (unsigned int)dd); | 722 | (unsigned int)ctx, (unsigned int)dd); |
724 | return -EINVAL; | 723 | return -EINVAL; |
725 | } | 724 | } |
@@ -778,14 +777,8 @@ static int tegra_aes_rng_reset(struct crypto_rng *tfm, u8 *seed, | |||
778 | if (dd->ivlen >= (2 * DEFAULT_RNG_BLK_SZ + AES_KEYSIZE_128)) { | 777 | if (dd->ivlen >= (2 * DEFAULT_RNG_BLK_SZ + AES_KEYSIZE_128)) { |
779 | dt = dd->iv + DEFAULT_RNG_BLK_SZ + AES_KEYSIZE_128; | 778 | dt = dd->iv + DEFAULT_RNG_BLK_SZ + AES_KEYSIZE_128; |
780 | } else { | 779 | } else { |
781 | getnstimeofday(&ts); | 780 | get_random_bytes(tmp, sizeof(tmp)); |
782 | nsec = timespec_to_ns(&ts); | 781 | dt = tmp; |
783 | do_div(nsec, 1000); | ||
784 | nsec ^= dd->ctr << 56; | ||
785 | dd->ctr++; | ||
786 | tmp[0] = nsec; | ||
787 | tmp[1] = tegra_chip_uid(); | ||
788 | dt = (u8 *)tmp; | ||
789 | } | 782 | } |
790 | memcpy(dd->dt, dt, DEFAULT_RNG_BLK_SZ); | 783 | memcpy(dd->dt, dt, DEFAULT_RNG_BLK_SZ); |
791 | 784 | ||
@@ -804,7 +797,7 @@ static int tegra_aes_cra_init(struct crypto_tfm *tfm) | |||
804 | return 0; | 797 | return 0; |
805 | } | 798 | } |
806 | 799 | ||
807 | void tegra_aes_cra_exit(struct crypto_tfm *tfm) | 800 | static void tegra_aes_cra_exit(struct crypto_tfm *tfm) |
808 | { | 801 | { |
809 | struct tegra_aes_ctx *ctx = | 802 | struct tegra_aes_ctx *ctx = |
810 | crypto_ablkcipher_ctx((struct crypto_ablkcipher *)tfm); | 803 | crypto_ablkcipher_ctx((struct crypto_ablkcipher *)tfm); |
@@ -924,7 +917,7 @@ static int tegra_aes_probe(struct platform_device *pdev) | |||
924 | } | 917 | } |
925 | 918 | ||
926 | /* Initialize the vde clock */ | 919 | /* Initialize the vde clock */ |
927 | dd->aes_clk = clk_get(dev, "vde"); | 920 | dd->aes_clk = devm_clk_get(dev, "vde"); |
928 | if (IS_ERR(dd->aes_clk)) { | 921 | if (IS_ERR(dd->aes_clk)) { |
929 | dev_err(dev, "iclock intialization failed.\n"); | 922 | dev_err(dev, "iclock intialization failed.\n"); |
930 | err = -ENODEV; | 923 | err = -ENODEV; |
@@ -1033,8 +1026,6 @@ out: | |||
1033 | if (dd->buf_out) | 1026 | if (dd->buf_out) |
1034 | dma_free_coherent(dev, AES_HW_DMA_BUFFER_SIZE_BYTES, | 1027 | dma_free_coherent(dev, AES_HW_DMA_BUFFER_SIZE_BYTES, |
1035 | dd->buf_out, dd->dma_buf_out); | 1028 | dd->buf_out, dd->dma_buf_out); |
1036 | if (!IS_ERR(dd->aes_clk)) | ||
1037 | clk_put(dd->aes_clk); | ||
1038 | if (aes_wq) | 1029 | if (aes_wq) |
1039 | destroy_workqueue(aes_wq); | 1030 | destroy_workqueue(aes_wq); |
1040 | spin_lock(&list_lock); | 1031 | spin_lock(&list_lock); |
@@ -1068,7 +1059,6 @@ static int tegra_aes_remove(struct platform_device *pdev) | |||
1068 | dd->buf_in, dd->dma_buf_in); | 1059 | dd->buf_in, dd->dma_buf_in); |
1069 | dma_free_coherent(dev, AES_HW_DMA_BUFFER_SIZE_BYTES, | 1060 | dma_free_coherent(dev, AES_HW_DMA_BUFFER_SIZE_BYTES, |
1070 | dd->buf_out, dd->dma_buf_out); | 1061 | dd->buf_out, dd->dma_buf_out); |
1071 | clk_put(dd->aes_clk); | ||
1072 | aes_dev = NULL; | 1062 | aes_dev = NULL; |
1073 | 1063 | ||
1074 | return 0; | 1064 | return 0; |
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index 281029daf98c..b0bb056458a3 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c | |||
@@ -1623,6 +1623,7 @@ static struct scsi_host_template scsi_driver_template = { | |||
1623 | .cmd_per_lun = 1, | 1623 | .cmd_per_lun = 1, |
1624 | .can_queue = 1, | 1624 | .can_queue = 1, |
1625 | .sdev_attrs = sbp2_scsi_sysfs_attrs, | 1625 | .sdev_attrs = sbp2_scsi_sysfs_attrs, |
1626 | .no_write_same = 1, | ||
1626 | }; | 1627 | }; |
1627 | 1628 | ||
1628 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); | 1629 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); |
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c index 5002d50e3781..743fd426f21b 100644 --- a/drivers/firmware/efi/efi-pstore.c +++ b/drivers/firmware/efi/efi-pstore.c | |||
@@ -18,14 +18,12 @@ module_param_named(pstore_disable, efivars_pstore_disable, bool, 0644); | |||
18 | 18 | ||
19 | static int efi_pstore_open(struct pstore_info *psi) | 19 | static int efi_pstore_open(struct pstore_info *psi) |
20 | { | 20 | { |
21 | efivar_entry_iter_begin(); | ||
22 | psi->data = NULL; | 21 | psi->data = NULL; |
23 | return 0; | 22 | return 0; |
24 | } | 23 | } |
25 | 24 | ||
26 | static int efi_pstore_close(struct pstore_info *psi) | 25 | static int efi_pstore_close(struct pstore_info *psi) |
27 | { | 26 | { |
28 | efivar_entry_iter_end(); | ||
29 | psi->data = NULL; | 27 | psi->data = NULL; |
30 | return 0; | 28 | return 0; |
31 | } | 29 | } |
@@ -39,6 +37,12 @@ struct pstore_read_data { | |||
39 | char **buf; | 37 | char **buf; |
40 | }; | 38 | }; |
41 | 39 | ||
40 | static inline u64 generic_id(unsigned long timestamp, | ||
41 | unsigned int part, int count) | ||
42 | { | ||
43 | return (timestamp * 100 + part) * 1000 + count; | ||
44 | } | ||
45 | |||
42 | static int efi_pstore_read_func(struct efivar_entry *entry, void *data) | 46 | static int efi_pstore_read_func(struct efivar_entry *entry, void *data) |
43 | { | 47 | { |
44 | efi_guid_t vendor = LINUX_EFI_CRASH_GUID; | 48 | efi_guid_t vendor = LINUX_EFI_CRASH_GUID; |
@@ -57,7 +61,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data) | |||
57 | 61 | ||
58 | if (sscanf(name, "dump-type%u-%u-%d-%lu-%c", | 62 | if (sscanf(name, "dump-type%u-%u-%d-%lu-%c", |
59 | cb_data->type, &part, &cnt, &time, &data_type) == 5) { | 63 | cb_data->type, &part, &cnt, &time, &data_type) == 5) { |
60 | *cb_data->id = part; | 64 | *cb_data->id = generic_id(time, part, cnt); |
61 | *cb_data->count = cnt; | 65 | *cb_data->count = cnt; |
62 | cb_data->timespec->tv_sec = time; | 66 | cb_data->timespec->tv_sec = time; |
63 | cb_data->timespec->tv_nsec = 0; | 67 | cb_data->timespec->tv_nsec = 0; |
@@ -67,7 +71,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data) | |||
67 | *cb_data->compressed = false; | 71 | *cb_data->compressed = false; |
68 | } else if (sscanf(name, "dump-type%u-%u-%d-%lu", | 72 | } else if (sscanf(name, "dump-type%u-%u-%d-%lu", |
69 | cb_data->type, &part, &cnt, &time) == 4) { | 73 | cb_data->type, &part, &cnt, &time) == 4) { |
70 | *cb_data->id = part; | 74 | *cb_data->id = generic_id(time, part, cnt); |
71 | *cb_data->count = cnt; | 75 | *cb_data->count = cnt; |
72 | cb_data->timespec->tv_sec = time; | 76 | cb_data->timespec->tv_sec = time; |
73 | cb_data->timespec->tv_nsec = 0; | 77 | cb_data->timespec->tv_nsec = 0; |
@@ -79,7 +83,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data) | |||
79 | * which doesn't support holding | 83 | * which doesn't support holding |
80 | * multiple logs, remains. | 84 | * multiple logs, remains. |
81 | */ | 85 | */ |
82 | *cb_data->id = part; | 86 | *cb_data->id = generic_id(time, part, 0); |
83 | *cb_data->count = 0; | 87 | *cb_data->count = 0; |
84 | cb_data->timespec->tv_sec = time; | 88 | cb_data->timespec->tv_sec = time; |
85 | cb_data->timespec->tv_nsec = 0; | 89 | cb_data->timespec->tv_nsec = 0; |
@@ -91,19 +95,125 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data) | |||
91 | __efivar_entry_get(entry, &entry->var.Attributes, | 95 | __efivar_entry_get(entry, &entry->var.Attributes, |
92 | &entry->var.DataSize, entry->var.Data); | 96 | &entry->var.DataSize, entry->var.Data); |
93 | size = entry->var.DataSize; | 97 | size = entry->var.DataSize; |
98 | memcpy(*cb_data->buf, entry->var.Data, | ||
99 | (size_t)min_t(unsigned long, EFIVARS_DATA_SIZE_MAX, size)); | ||
94 | 100 | ||
95 | *cb_data->buf = kmemdup(entry->var.Data, size, GFP_KERNEL); | ||
96 | if (*cb_data->buf == NULL) | ||
97 | return -ENOMEM; | ||
98 | return size; | 101 | return size; |
99 | } | 102 | } |
100 | 103 | ||
104 | /** | ||
105 | * efi_pstore_scan_sysfs_enter | ||
106 | * @entry: scanning entry | ||
107 | * @next: next entry | ||
108 | * @head: list head | ||
109 | */ | ||
110 | static void efi_pstore_scan_sysfs_enter(struct efivar_entry *pos, | ||
111 | struct efivar_entry *next, | ||
112 | struct list_head *head) | ||
113 | { | ||
114 | pos->scanning = true; | ||
115 | if (&next->list != head) | ||
116 | next->scanning = true; | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * __efi_pstore_scan_sysfs_exit | ||
121 | * @entry: deleting entry | ||
122 | * @turn_off_scanning: Check if a scanning flag should be turned off | ||
123 | */ | ||
124 | static inline void __efi_pstore_scan_sysfs_exit(struct efivar_entry *entry, | ||
125 | bool turn_off_scanning) | ||
126 | { | ||
127 | if (entry->deleting) { | ||
128 | list_del(&entry->list); | ||
129 | efivar_entry_iter_end(); | ||
130 | efivar_unregister(entry); | ||
131 | efivar_entry_iter_begin(); | ||
132 | } else if (turn_off_scanning) | ||
133 | entry->scanning = false; | ||
134 | } | ||
135 | |||
136 | /** | ||
137 | * efi_pstore_scan_sysfs_exit | ||
138 | * @pos: scanning entry | ||
139 | * @next: next entry | ||
140 | * @head: list head | ||
141 | * @stop: a flag checking if scanning will stop | ||
142 | */ | ||
143 | static void efi_pstore_scan_sysfs_exit(struct efivar_entry *pos, | ||
144 | struct efivar_entry *next, | ||
145 | struct list_head *head, bool stop) | ||
146 | { | ||
147 | __efi_pstore_scan_sysfs_exit(pos, true); | ||
148 | if (stop) | ||
149 | __efi_pstore_scan_sysfs_exit(next, &next->list != head); | ||
150 | } | ||
151 | |||
152 | /** | ||
153 | * efi_pstore_sysfs_entry_iter | ||
154 | * | ||
155 | * @data: function-specific data to pass to callback | ||
156 | * @pos: entry to begin iterating from | ||
157 | * | ||
158 | * You MUST call efivar_enter_iter_begin() before this function, and | ||
159 | * efivar_entry_iter_end() afterwards. | ||
160 | * | ||
161 | * It is possible to begin iteration from an arbitrary entry within | ||
162 | * the list by passing @pos. @pos is updated on return to point to | ||
163 | * the next entry of the last one passed to efi_pstore_read_func(). | ||
164 | * To begin iterating from the beginning of the list @pos must be %NULL. | ||
165 | */ | ||
166 | static int efi_pstore_sysfs_entry_iter(void *data, struct efivar_entry **pos) | ||
167 | { | ||
168 | struct efivar_entry *entry, *n; | ||
169 | struct list_head *head = &efivar_sysfs_list; | ||
170 | int size = 0; | ||
171 | |||
172 | if (!*pos) { | ||
173 | list_for_each_entry_safe(entry, n, head, list) { | ||
174 | efi_pstore_scan_sysfs_enter(entry, n, head); | ||
175 | |||
176 | size = efi_pstore_read_func(entry, data); | ||
177 | efi_pstore_scan_sysfs_exit(entry, n, head, size < 0); | ||
178 | if (size) | ||
179 | break; | ||
180 | } | ||
181 | *pos = n; | ||
182 | return size; | ||
183 | } | ||
184 | |||
185 | list_for_each_entry_safe_from((*pos), n, head, list) { | ||
186 | efi_pstore_scan_sysfs_enter((*pos), n, head); | ||
187 | |||
188 | size = efi_pstore_read_func((*pos), data); | ||
189 | efi_pstore_scan_sysfs_exit((*pos), n, head, size < 0); | ||
190 | if (size) | ||
191 | break; | ||
192 | } | ||
193 | *pos = n; | ||
194 | return size; | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * efi_pstore_read | ||
199 | * | ||
200 | * This function returns a size of NVRAM entry logged via efi_pstore_write(). | ||
201 | * The meaning and behavior of efi_pstore/pstore are as below. | ||
202 | * | ||
203 | * size > 0: Got data of an entry logged via efi_pstore_write() successfully, | ||
204 | * and pstore filesystem will continue reading subsequent entries. | ||
205 | * size == 0: Entry was not logged via efi_pstore_write(), | ||
206 | * and efi_pstore driver will continue reading subsequent entries. | ||
207 | * size < 0: Failed to get data of entry logging via efi_pstore_write(), | ||
208 | * and pstore will stop reading entry. | ||
209 | */ | ||
101 | static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, | 210 | static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, |
102 | int *count, struct timespec *timespec, | 211 | int *count, struct timespec *timespec, |
103 | char **buf, bool *compressed, | 212 | char **buf, bool *compressed, |
104 | struct pstore_info *psi) | 213 | struct pstore_info *psi) |
105 | { | 214 | { |
106 | struct pstore_read_data data; | 215 | struct pstore_read_data data; |
216 | ssize_t size; | ||
107 | 217 | ||
108 | data.id = id; | 218 | data.id = id; |
109 | data.type = type; | 219 | data.type = type; |
@@ -112,8 +222,17 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, | |||
112 | data.compressed = compressed; | 222 | data.compressed = compressed; |
113 | data.buf = buf; | 223 | data.buf = buf; |
114 | 224 | ||
115 | return __efivar_entry_iter(efi_pstore_read_func, &efivar_sysfs_list, &data, | 225 | *data.buf = kzalloc(EFIVARS_DATA_SIZE_MAX, GFP_KERNEL); |
116 | (struct efivar_entry **)&psi->data); | 226 | if (!*data.buf) |
227 | return -ENOMEM; | ||
228 | |||
229 | efivar_entry_iter_begin(); | ||
230 | size = efi_pstore_sysfs_entry_iter(&data, | ||
231 | (struct efivar_entry **)&psi->data); | ||
232 | efivar_entry_iter_end(); | ||
233 | if (size <= 0) | ||
234 | kfree(*data.buf); | ||
235 | return size; | ||
117 | } | 236 | } |
118 | 237 | ||
119 | static int efi_pstore_write(enum pstore_type_id type, | 238 | static int efi_pstore_write(enum pstore_type_id type, |
@@ -184,9 +303,17 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data) | |||
184 | return 0; | 303 | return 0; |
185 | } | 304 | } |
186 | 305 | ||
306 | if (entry->scanning) { | ||
307 | /* | ||
308 | * Skip deletion because this entry will be deleted | ||
309 | * after scanning is completed. | ||
310 | */ | ||
311 | entry->deleting = true; | ||
312 | } else | ||
313 | list_del(&entry->list); | ||
314 | |||
187 | /* found */ | 315 | /* found */ |
188 | __efivar_entry_delete(entry); | 316 | __efivar_entry_delete(entry); |
189 | list_del(&entry->list); | ||
190 | 317 | ||
191 | return 1; | 318 | return 1; |
192 | } | 319 | } |
@@ -199,14 +326,16 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, | |||
199 | char name[DUMP_NAME_LEN]; | 326 | char name[DUMP_NAME_LEN]; |
200 | efi_char16_t efi_name[DUMP_NAME_LEN]; | 327 | efi_char16_t efi_name[DUMP_NAME_LEN]; |
201 | int found, i; | 328 | int found, i; |
329 | unsigned int part; | ||
202 | 330 | ||
203 | sprintf(name, "dump-type%u-%u-%d-%lu", type, (unsigned int)id, count, | 331 | do_div(id, 1000); |
204 | time.tv_sec); | 332 | part = do_div(id, 100); |
333 | sprintf(name, "dump-type%u-%u-%d-%lu", type, part, count, time.tv_sec); | ||
205 | 334 | ||
206 | for (i = 0; i < DUMP_NAME_LEN; i++) | 335 | for (i = 0; i < DUMP_NAME_LEN; i++) |
207 | efi_name[i] = name[i]; | 336 | efi_name[i] = name[i]; |
208 | 337 | ||
209 | edata.id = id; | 338 | edata.id = part; |
210 | edata.type = type; | 339 | edata.type = type; |
211 | edata.count = count; | 340 | edata.count = count; |
212 | edata.time = time; | 341 | edata.time = time; |
@@ -214,10 +343,12 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, | |||
214 | 343 | ||
215 | efivar_entry_iter_begin(); | 344 | efivar_entry_iter_begin(); |
216 | found = __efivar_entry_iter(efi_pstore_erase_func, &efivar_sysfs_list, &edata, &entry); | 345 | found = __efivar_entry_iter(efi_pstore_erase_func, &efivar_sysfs_list, &edata, &entry); |
217 | efivar_entry_iter_end(); | ||
218 | 346 | ||
219 | if (found) | 347 | if (found && !entry->scanning) { |
348 | efivar_entry_iter_end(); | ||
220 | efivar_unregister(entry); | 349 | efivar_unregister(entry); |
350 | } else | ||
351 | efivar_entry_iter_end(); | ||
221 | 352 | ||
222 | return 0; | 353 | return 0; |
223 | } | 354 | } |
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index 933eb027d527..3dc248239197 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c | |||
@@ -383,12 +383,16 @@ static ssize_t efivar_delete(struct file *filp, struct kobject *kobj, | |||
383 | else if (__efivar_entry_delete(entry)) | 383 | else if (__efivar_entry_delete(entry)) |
384 | err = -EIO; | 384 | err = -EIO; |
385 | 385 | ||
386 | efivar_entry_iter_end(); | 386 | if (err) { |
387 | 387 | efivar_entry_iter_end(); | |
388 | if (err) | ||
389 | return err; | 388 | return err; |
389 | } | ||
390 | 390 | ||
391 | efivar_unregister(entry); | 391 | if (!entry->scanning) { |
392 | efivar_entry_iter_end(); | ||
393 | efivar_unregister(entry); | ||
394 | } else | ||
395 | efivar_entry_iter_end(); | ||
392 | 396 | ||
393 | /* It's dead Jim.... */ | 397 | /* It's dead Jim.... */ |
394 | return count; | 398 | return count; |
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index 391c67b182d9..b22659cccca4 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c | |||
@@ -683,8 +683,16 @@ struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid, | |||
683 | if (!found) | 683 | if (!found) |
684 | return NULL; | 684 | return NULL; |
685 | 685 | ||
686 | if (remove) | 686 | if (remove) { |
687 | list_del(&entry->list); | 687 | if (entry->scanning) { |
688 | /* | ||
689 | * The entry will be deleted | ||
690 | * after scanning is completed. | ||
691 | */ | ||
692 | entry->deleting = true; | ||
693 | } else | ||
694 | list_del(&entry->list); | ||
695 | } | ||
688 | 696 | ||
689 | return entry; | 697 | return entry; |
690 | } | 698 | } |
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index 3437414eaef2..233d088ac59f 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c | |||
@@ -158,7 +158,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) | |||
158 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 158 | spin_unlock_irqrestore(&kona_gpio->lock, flags); |
159 | 159 | ||
160 | /* return the specified bit status */ | 160 | /* return the specified bit status */ |
161 | return !!(val & bit); | 161 | return !!(val & BIT(bit)); |
162 | } | 162 | } |
163 | 163 | ||
164 | static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | 164 | static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) |
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index 914e859e3eda..d7d6d72eba33 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c | |||
@@ -70,10 +70,14 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio) | |||
70 | u32 val; | 70 | u32 val; |
71 | struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); | 71 | struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); |
72 | struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); | 72 | struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); |
73 | u32 out_mask, out_shadow; | ||
73 | 74 | ||
74 | val = in_be32(mm->regs + GPIO_DAT) & ~in_be32(mm->regs + GPIO_DIR); | 75 | out_mask = in_be32(mm->regs + GPIO_DIR); |
75 | 76 | ||
76 | return (val | mpc8xxx_gc->data) & mpc8xxx_gpio2mask(gpio); | 77 | val = in_be32(mm->regs + GPIO_DAT) & ~out_mask; |
78 | out_shadow = mpc8xxx_gc->data & out_mask; | ||
79 | |||
80 | return (val | out_shadow) & mpc8xxx_gpio2mask(gpio); | ||
77 | } | 81 | } |
78 | 82 | ||
79 | static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio) | 83 | static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio) |
diff --git a/drivers/gpio/gpio-msm-v2.c b/drivers/gpio/gpio-msm-v2.c index f7a0cc4da950..7b37300973db 100644 --- a/drivers/gpio/gpio-msm-v2.c +++ b/drivers/gpio/gpio-msm-v2.c | |||
@@ -102,7 +102,7 @@ struct msm_gpio_dev { | |||
102 | DECLARE_BITMAP(wake_irqs, MAX_NR_GPIO); | 102 | DECLARE_BITMAP(wake_irqs, MAX_NR_GPIO); |
103 | DECLARE_BITMAP(dual_edge_irqs, MAX_NR_GPIO); | 103 | DECLARE_BITMAP(dual_edge_irqs, MAX_NR_GPIO); |
104 | struct irq_domain *domain; | 104 | struct irq_domain *domain; |
105 | unsigned int summary_irq; | 105 | int summary_irq; |
106 | void __iomem *msm_tlmm_base; | 106 | void __iomem *msm_tlmm_base; |
107 | }; | 107 | }; |
108 | 108 | ||
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index a8908009803f..bc78a9da5502 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c | |||
@@ -79,7 +79,7 @@ struct mvebu_gpio_chip { | |||
79 | spinlock_t lock; | 79 | spinlock_t lock; |
80 | void __iomem *membase; | 80 | void __iomem *membase; |
81 | void __iomem *percpu_membase; | 81 | void __iomem *percpu_membase; |
82 | unsigned int irqbase; | 82 | int irqbase; |
83 | struct irq_domain *domain; | 83 | struct irq_domain *domain; |
84 | int soc_variant; | 84 | int soc_variant; |
85 | }; | 85 | }; |
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index f22f7f3e2e53..b4d42112d02d 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
@@ -286,11 +286,6 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | |||
286 | if (!chip->base) | 286 | if (!chip->base) |
287 | return -ENOMEM; | 287 | return -ENOMEM; |
288 | 288 | ||
289 | chip->domain = irq_domain_add_simple(adev->dev.of_node, PL061_GPIO_NR, | ||
290 | irq_base, &pl061_domain_ops, chip); | ||
291 | if (!chip->domain) | ||
292 | return -ENODEV; | ||
293 | |||
294 | spin_lock_init(&chip->lock); | 289 | spin_lock_init(&chip->lock); |
295 | 290 | ||
296 | chip->gc.request = pl061_gpio_request; | 291 | chip->gc.request = pl061_gpio_request; |
@@ -320,6 +315,11 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | |||
320 | irq_set_chained_handler(irq, pl061_irq_handler); | 315 | irq_set_chained_handler(irq, pl061_irq_handler); |
321 | irq_set_handler_data(irq, chip); | 316 | irq_set_handler_data(irq, chip); |
322 | 317 | ||
318 | chip->domain = irq_domain_add_simple(adev->dev.of_node, PL061_GPIO_NR, | ||
319 | irq_base, &pl061_domain_ops, chip); | ||
320 | if (!chip->domain) | ||
321 | return -ENODEV; | ||
322 | |||
323 | for (i = 0; i < PL061_GPIO_NR; i++) { | 323 | for (i = 0; i < PL061_GPIO_NR; i++) { |
324 | if (pdata) { | 324 | if (pdata) { |
325 | if (pdata->directions & (1 << i)) | 325 | if (pdata->directions & (1 << i)) |
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 28fa94a316ff..2fdd0191819d 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c | |||
@@ -421,7 +421,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) | |||
421 | if (!p->irq_domain) { | 421 | if (!p->irq_domain) { |
422 | ret = -ENXIO; | 422 | ret = -ENXIO; |
423 | dev_err(&pdev->dev, "cannot initialize irq domain\n"); | 423 | dev_err(&pdev->dev, "cannot initialize irq domain\n"); |
424 | goto err1; | 424 | goto err0; |
425 | } | 425 | } |
426 | 426 | ||
427 | if (devm_request_irq(&pdev->dev, irq->start, | 427 | if (devm_request_irq(&pdev->dev, irq->start, |
diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c index 66a54ea4f779..3162555ca1cb 100644 --- a/drivers/gpio/gpio-tb10x.c +++ b/drivers/gpio/gpio-tb10x.c | |||
@@ -132,6 +132,7 @@ static int tb10x_gpio_direction_out(struct gpio_chip *chip, | |||
132 | int mask = BIT(offset); | 132 | int mask = BIT(offset); |
133 | int val = TB10X_GPIO_DIR_OUT << offset; | 133 | int val = TB10X_GPIO_DIR_OUT << offset; |
134 | 134 | ||
135 | tb10x_gpio_set(chip, offset, value); | ||
135 | tb10x_set_bits(tb10x_gpio, OFFSET_TO_REG_DDR, mask, val); | 136 | tb10x_set_bits(tb10x_gpio, OFFSET_TO_REG_DDR, mask, val); |
136 | 137 | ||
137 | return 0; | 138 | return 0; |
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c index cd06678a29f7..29f00a76bb92 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c | |||
@@ -354,17 +354,18 @@ static void twl_set(struct gpio_chip *chip, unsigned offset, int value) | |||
354 | static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value) | 354 | static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value) |
355 | { | 355 | { |
356 | struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); | 356 | struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); |
357 | int ret = -EINVAL; | ||
357 | 358 | ||
358 | mutex_lock(&priv->mutex); | 359 | mutex_lock(&priv->mutex); |
359 | if (offset < TWL4030_GPIO_MAX) | 360 | if (offset < TWL4030_GPIO_MAX) |
360 | twl4030_set_gpio_dataout(offset, value); | 361 | ret = twl4030_set_gpio_direction(offset, 0); |
361 | 362 | ||
362 | priv->direction |= BIT(offset); | 363 | priv->direction |= BIT(offset); |
363 | mutex_unlock(&priv->mutex); | 364 | mutex_unlock(&priv->mutex); |
364 | 365 | ||
365 | twl_set(chip, offset, value); | 366 | twl_set(chip, offset, value); |
366 | 367 | ||
367 | return 0; | 368 | return ret; |
368 | } | 369 | } |
369 | 370 | ||
370 | static int twl_to_irq(struct gpio_chip *chip, unsigned offset) | 371 | static int twl_to_irq(struct gpio_chip *chip, unsigned offset) |
@@ -435,7 +436,8 @@ static int gpio_twl4030_debounce(u32 debounce, u8 mmc_cd) | |||
435 | 436 | ||
436 | static int gpio_twl4030_remove(struct platform_device *pdev); | 437 | static int gpio_twl4030_remove(struct platform_device *pdev); |
437 | 438 | ||
438 | static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev) | 439 | static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev, |
440 | struct twl4030_gpio_platform_data *pdata) | ||
439 | { | 441 | { |
440 | struct twl4030_gpio_platform_data *omap_twl_info; | 442 | struct twl4030_gpio_platform_data *omap_twl_info; |
441 | 443 | ||
@@ -443,6 +445,9 @@ static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev) | |||
443 | if (!omap_twl_info) | 445 | if (!omap_twl_info) |
444 | return NULL; | 446 | return NULL; |
445 | 447 | ||
448 | if (pdata) | ||
449 | *omap_twl_info = *pdata; | ||
450 | |||
446 | omap_twl_info->use_leds = of_property_read_bool(dev->of_node, | 451 | omap_twl_info->use_leds = of_property_read_bool(dev->of_node, |
447 | "ti,use-leds"); | 452 | "ti,use-leds"); |
448 | 453 | ||
@@ -500,7 +505,7 @@ no_irqs: | |||
500 | mutex_init(&priv->mutex); | 505 | mutex_init(&priv->mutex); |
501 | 506 | ||
502 | if (node) | 507 | if (node) |
503 | pdata = of_gpio_twl4030(&pdev->dev); | 508 | pdata = of_gpio_twl4030(&pdev->dev, pdata); |
504 | 509 | ||
505 | if (pdata == NULL) { | 510 | if (pdata == NULL) { |
506 | dev_err(&pdev->dev, "Platform data is missing\n"); | 511 | dev_err(&pdev->dev, "Platform data is missing\n"); |
diff --git a/drivers/gpio/gpio-ucb1400.c b/drivers/gpio/gpio-ucb1400.c index c6a53971387b..2445fe771179 100644 --- a/drivers/gpio/gpio-ucb1400.c +++ b/drivers/gpio/gpio-ucb1400.c | |||
@@ -105,3 +105,4 @@ module_platform_driver(ucb1400_gpio_driver); | |||
105 | 105 | ||
106 | MODULE_DESCRIPTION("Philips UCB1400 GPIO driver"); | 106 | MODULE_DESCRIPTION("Philips UCB1400 GPIO driver"); |
107 | MODULE_LICENSE("GPL"); | 107 | MODULE_LICENSE("GPL"); |
108 | MODULE_ALIAS("platform:ucb1400_gpio"); | ||
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 94467ddb3711..44a232701179 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/idr.h> | 14 | #include <linux/idr.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/acpi.h> | 16 | #include <linux/acpi.h> |
17 | #include <linux/gpio/driver.h> | ||
17 | 18 | ||
18 | #define CREATE_TRACE_POINTS | 19 | #define CREATE_TRACE_POINTS |
19 | #include <trace/events/gpio.h> | 20 | #include <trace/events/gpio.h> |
@@ -1309,6 +1310,18 @@ struct gpio_chip *gpiochip_find(void *data, | |||
1309 | } | 1310 | } |
1310 | EXPORT_SYMBOL_GPL(gpiochip_find); | 1311 | EXPORT_SYMBOL_GPL(gpiochip_find); |
1311 | 1312 | ||
1313 | static int gpiochip_match_name(struct gpio_chip *chip, void *data) | ||
1314 | { | ||
1315 | const char *name = data; | ||
1316 | |||
1317 | return !strcmp(chip->label, name); | ||
1318 | } | ||
1319 | |||
1320 | static struct gpio_chip *find_chip_by_name(const char *name) | ||
1321 | { | ||
1322 | return gpiochip_find((void *)name, gpiochip_match_name); | ||
1323 | } | ||
1324 | |||
1312 | #ifdef CONFIG_PINCTRL | 1325 | #ifdef CONFIG_PINCTRL |
1313 | 1326 | ||
1314 | /** | 1327 | /** |
@@ -1342,8 +1355,10 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip, | |||
1342 | ret = pinctrl_get_group_pins(pctldev, pin_group, | 1355 | ret = pinctrl_get_group_pins(pctldev, pin_group, |
1343 | &pin_range->range.pins, | 1356 | &pin_range->range.pins, |
1344 | &pin_range->range.npins); | 1357 | &pin_range->range.npins); |
1345 | if (ret < 0) | 1358 | if (ret < 0) { |
1359 | kfree(pin_range); | ||
1346 | return ret; | 1360 | return ret; |
1361 | } | ||
1347 | 1362 | ||
1348 | pinctrl_add_gpio_range(pctldev, &pin_range->range); | 1363 | pinctrl_add_gpio_range(pctldev, &pin_range->range); |
1349 | 1364 | ||
@@ -2261,26 +2276,10 @@ void gpiod_add_table(struct gpiod_lookup *table, size_t size) | |||
2261 | mutex_unlock(&gpio_lookup_lock); | 2276 | mutex_unlock(&gpio_lookup_lock); |
2262 | } | 2277 | } |
2263 | 2278 | ||
2264 | /* | ||
2265 | * Caller must have a acquired gpio_lookup_lock | ||
2266 | */ | ||
2267 | static struct gpio_chip *find_chip_by_name(const char *name) | ||
2268 | { | ||
2269 | struct gpio_chip *chip = NULL; | ||
2270 | |||
2271 | list_for_each_entry(chip, &gpio_lookup_list, list) { | ||
2272 | if (chip->label == NULL) | ||
2273 | continue; | ||
2274 | if (!strcmp(chip->label, name)) | ||
2275 | break; | ||
2276 | } | ||
2277 | |||
2278 | return chip; | ||
2279 | } | ||
2280 | |||
2281 | #ifdef CONFIG_OF | 2279 | #ifdef CONFIG_OF |
2282 | static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | 2280 | static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, |
2283 | unsigned int idx, unsigned long *flags) | 2281 | unsigned int idx, |
2282 | enum gpio_lookup_flags *flags) | ||
2284 | { | 2283 | { |
2285 | char prop_name[32]; /* 32 is max size of property name */ | 2284 | char prop_name[32]; /* 32 is max size of property name */ |
2286 | enum of_gpio_flags of_flags; | 2285 | enum of_gpio_flags of_flags; |
@@ -2298,20 +2297,22 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | |||
2298 | return desc; | 2297 | return desc; |
2299 | 2298 | ||
2300 | if (of_flags & OF_GPIO_ACTIVE_LOW) | 2299 | if (of_flags & OF_GPIO_ACTIVE_LOW) |
2301 | *flags |= GPIOF_ACTIVE_LOW; | 2300 | *flags |= GPIO_ACTIVE_LOW; |
2302 | 2301 | ||
2303 | return desc; | 2302 | return desc; |
2304 | } | 2303 | } |
2305 | #else | 2304 | #else |
2306 | static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | 2305 | static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, |
2307 | unsigned int idx, unsigned long *flags) | 2306 | unsigned int idx, |
2307 | enum gpio_lookup_flags *flags) | ||
2308 | { | 2308 | { |
2309 | return ERR_PTR(-ENODEV); | 2309 | return ERR_PTR(-ENODEV); |
2310 | } | 2310 | } |
2311 | #endif | 2311 | #endif |
2312 | 2312 | ||
2313 | static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, | 2313 | static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, |
2314 | unsigned int idx, unsigned long *flags) | 2314 | unsigned int idx, |
2315 | enum gpio_lookup_flags *flags) | ||
2315 | { | 2316 | { |
2316 | struct acpi_gpio_info info; | 2317 | struct acpi_gpio_info info; |
2317 | struct gpio_desc *desc; | 2318 | struct gpio_desc *desc; |
@@ -2321,13 +2322,14 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, | |||
2321 | return desc; | 2322 | return desc; |
2322 | 2323 | ||
2323 | if (info.gpioint && info.active_low) | 2324 | if (info.gpioint && info.active_low) |
2324 | *flags |= GPIOF_ACTIVE_LOW; | 2325 | *flags |= GPIO_ACTIVE_LOW; |
2325 | 2326 | ||
2326 | return desc; | 2327 | return desc; |
2327 | } | 2328 | } |
2328 | 2329 | ||
2329 | static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, | 2330 | static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, |
2330 | unsigned int idx, unsigned long *flags) | 2331 | unsigned int idx, |
2332 | enum gpio_lookup_flags *flags) | ||
2331 | { | 2333 | { |
2332 | const char *dev_id = dev ? dev_name(dev) : NULL; | 2334 | const char *dev_id = dev ? dev_name(dev) : NULL; |
2333 | struct gpio_desc *desc = ERR_PTR(-ENODEV); | 2335 | struct gpio_desc *desc = ERR_PTR(-ENODEV); |
@@ -2367,7 +2369,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, | |||
2367 | continue; | 2369 | continue; |
2368 | } | 2370 | } |
2369 | 2371 | ||
2370 | if (chip->ngpio >= p->chip_hwnum) { | 2372 | if (chip->ngpio <= p->chip_hwnum) { |
2371 | dev_warn(dev, "GPIO chip %s has %d GPIOs\n", | 2373 | dev_warn(dev, "GPIO chip %s has %d GPIOs\n", |
2372 | chip->label, chip->ngpio); | 2374 | chip->label, chip->ngpio); |
2373 | continue; | 2375 | continue; |
@@ -2417,9 +2419,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, | |||
2417 | const char *con_id, | 2419 | const char *con_id, |
2418 | unsigned int idx) | 2420 | unsigned int idx) |
2419 | { | 2421 | { |
2420 | struct gpio_desc *desc; | 2422 | struct gpio_desc *desc = NULL; |
2421 | int status; | 2423 | int status; |
2422 | unsigned long flags = 0; | 2424 | enum gpio_lookup_flags flags = 0; |
2423 | 2425 | ||
2424 | dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id); | 2426 | dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id); |
2425 | 2427 | ||
@@ -2430,13 +2432,23 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, | |||
2430 | } else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) { | 2432 | } else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) { |
2431 | dev_dbg(dev, "using ACPI for GPIO lookup\n"); | 2433 | dev_dbg(dev, "using ACPI for GPIO lookup\n"); |
2432 | desc = acpi_find_gpio(dev, con_id, idx, &flags); | 2434 | desc = acpi_find_gpio(dev, con_id, idx, &flags); |
2433 | } else { | 2435 | } |
2436 | |||
2437 | /* | ||
2438 | * Either we are not using DT or ACPI, or their lookup did not return | ||
2439 | * a result. In that case, use platform lookup as a fallback. | ||
2440 | */ | ||
2441 | if (!desc || IS_ERR(desc)) { | ||
2442 | struct gpio_desc *pdesc; | ||
2434 | dev_dbg(dev, "using lookup tables for GPIO lookup"); | 2443 | dev_dbg(dev, "using lookup tables for GPIO lookup"); |
2435 | desc = gpiod_find(dev, con_id, idx, &flags); | 2444 | pdesc = gpiod_find(dev, con_id, idx, &flags); |
2445 | /* If used as fallback, do not replace the previous error */ | ||
2446 | if (!IS_ERR(pdesc) || !desc) | ||
2447 | desc = pdesc; | ||
2436 | } | 2448 | } |
2437 | 2449 | ||
2438 | if (IS_ERR(desc)) { | 2450 | if (IS_ERR(desc)) { |
2439 | dev_warn(dev, "lookup for GPIO %s failed\n", con_id); | 2451 | dev_dbg(dev, "lookup for GPIO %s failed\n", con_id); |
2440 | return desc; | 2452 | return desc; |
2441 | } | 2453 | } |
2442 | 2454 | ||
@@ -2445,8 +2457,12 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, | |||
2445 | if (status < 0) | 2457 | if (status < 0) |
2446 | return ERR_PTR(status); | 2458 | return ERR_PTR(status); |
2447 | 2459 | ||
2448 | if (flags & GPIOF_ACTIVE_LOW) | 2460 | if (flags & GPIO_ACTIVE_LOW) |
2449 | set_bit(FLAG_ACTIVE_LOW, &desc->flags); | 2461 | set_bit(FLAG_ACTIVE_LOW, &desc->flags); |
2462 | if (flags & GPIO_OPEN_DRAIN) | ||
2463 | set_bit(FLAG_OPEN_DRAIN, &desc->flags); | ||
2464 | if (flags & GPIO_OPEN_SOURCE) | ||
2465 | set_bit(FLAG_OPEN_SOURCE, &desc->flags); | ||
2450 | 2466 | ||
2451 | return desc; | 2467 | return desc; |
2452 | } | 2468 | } |
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index bd2bca395792..c22c3097c3e8 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c | |||
@@ -516,7 +516,7 @@ int drm_sysfs_device_add(struct drm_minor *minor) | |||
516 | minor_str = "card%d"; | 516 | minor_str = "card%d"; |
517 | 517 | ||
518 | minor->kdev = kzalloc(sizeof(*minor->kdev), GFP_KERNEL); | 518 | minor->kdev = kzalloc(sizeof(*minor->kdev), GFP_KERNEL); |
519 | if (!minor->dev) { | 519 | if (!minor->kdev) { |
520 | r = -ENOMEM; | 520 | r = -ENOMEM; |
521 | goto error; | 521 | goto error; |
522 | } | 522 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c index 38a4db5bfe21..4aff04fa483c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c | |||
@@ -630,7 +630,6 @@ error: | |||
630 | hwmon->hwmon = NULL; | 630 | hwmon->hwmon = NULL; |
631 | return ret; | 631 | return ret; |
632 | #else | 632 | #else |
633 | hwmon->hwmon = NULL; | ||
634 | return 0; | 633 | return 0; |
635 | #endif | 634 | #endif |
636 | } | 635 | } |
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c index 0109a9644cb2..821ab7b9409b 100644 --- a/drivers/gpu/drm/qxl/qxl_release.c +++ b/drivers/gpu/drm/qxl/qxl_release.c | |||
@@ -92,6 +92,7 @@ qxl_release_free(struct qxl_device *qdev, | |||
92 | - DRM_FILE_OFFSET); | 92 | - DRM_FILE_OFFSET); |
93 | qxl_fence_remove_release(&bo->fence, release->id); | 93 | qxl_fence_remove_release(&bo->fence, release->id); |
94 | qxl_bo_unref(&bo); | 94 | qxl_bo_unref(&bo); |
95 | kfree(entry); | ||
95 | } | 96 | } |
96 | spin_lock(&qdev->release_idr_lock); | 97 | spin_lock(&qdev->release_idr_lock); |
97 | idr_remove(&qdev->release_idr, release->id); | 98 | idr_remove(&qdev->release_idr, release->id); |
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 329fbb9b5976..34e2d39d4ce8 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -460,6 +460,7 @@ config HID_MULTITOUCH | |||
460 | - Stantum multitouch panels | 460 | - Stantum multitouch panels |
461 | - Touch International Panels | 461 | - Touch International Panels |
462 | - Unitec Panels | 462 | - Unitec Panels |
463 | - Wistron optical touch panels | ||
463 | - XAT optical touch panels | 464 | - XAT optical touch panels |
464 | - Xiroku optical touch panels | 465 | - Xiroku optical touch panels |
465 | - Zytronic touch panels | 466 | - Zytronic touch panels |
diff --git a/drivers/hid/hid-appleir.c b/drivers/hid/hid-appleir.c index a42e6a394c5e..0e6a42d37eb6 100644 --- a/drivers/hid/hid-appleir.c +++ b/drivers/hid/hid-appleir.c | |||
@@ -297,6 +297,9 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id) | |||
297 | 297 | ||
298 | appleir->hid = hid; | 298 | appleir->hid = hid; |
299 | 299 | ||
300 | /* force input as some remotes bypass the input registration */ | ||
301 | hid->quirks |= HID_QUIRK_HIDINPUT_FORCE; | ||
302 | |||
300 | spin_lock_init(&appleir->lock); | 303 | spin_lock_init(&appleir->lock); |
301 | setup_timer(&appleir->key_up_timer, | 304 | setup_timer(&appleir->key_up_timer, |
302 | key_up_tick, (unsigned long) appleir); | 305 | key_up_tick, (unsigned long) appleir); |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 8c10f2742233..253fe23ef7fe 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1723,6 +1723,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1723 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, | 1723 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, |
1724 | { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, | 1724 | { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, |
1725 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) }, | 1725 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) }, |
1726 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_MANTICORE) }, | ||
1726 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GX_IMPERATOR) }, | 1727 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GX_IMPERATOR) }, |
1727 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, | 1728 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, |
1728 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) }, | 1729 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) }, |
@@ -1879,7 +1880,6 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1879 | 1880 | ||
1880 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, | 1881 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, |
1881 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, | 1882 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, |
1882 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO2, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, | ||
1883 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE2) }, | 1883 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE2) }, |
1884 | { } | 1884 | { } |
1885 | }; | 1885 | }; |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 76559629568c..f9304cb37154 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -489,6 +489,7 @@ | |||
489 | #define USB_VENDOR_ID_KYE 0x0458 | 489 | #define USB_VENDOR_ID_KYE 0x0458 |
490 | #define USB_DEVICE_ID_KYE_ERGO_525V 0x0087 | 490 | #define USB_DEVICE_ID_KYE_ERGO_525V 0x0087 |
491 | #define USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE 0x0138 | 491 | #define USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE 0x0138 |
492 | #define USB_DEVICE_ID_GENIUS_MANTICORE 0x0153 | ||
492 | #define USB_DEVICE_ID_GENIUS_GX_IMPERATOR 0x4018 | 493 | #define USB_DEVICE_ID_GENIUS_GX_IMPERATOR 0x4018 |
493 | #define USB_DEVICE_ID_KYE_GPEN_560 0x5003 | 494 | #define USB_DEVICE_ID_KYE_GPEN_560 0x5003 |
494 | #define USB_DEVICE_ID_KYE_EASYPEN_I405X 0x5010 | 495 | #define USB_DEVICE_ID_KYE_EASYPEN_I405X 0x5010 |
@@ -640,7 +641,6 @@ | |||
640 | #define USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN 0x0003 | 641 | #define USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN 0x0003 |
641 | 642 | ||
642 | #define USB_VENDOR_ID_NINTENDO 0x057e | 643 | #define USB_VENDOR_ID_NINTENDO 0x057e |
643 | #define USB_VENDOR_ID_NINTENDO2 0x054c | ||
644 | #define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306 | 644 | #define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306 |
645 | #define USB_DEVICE_ID_NINTENDO_WIIMOTE2 0x0330 | 645 | #define USB_DEVICE_ID_NINTENDO_WIIMOTE2 0x0330 |
646 | 646 | ||
@@ -902,6 +902,9 @@ | |||
902 | #define USB_DEVICE_ID_SUPER_DUAL_BOX_PRO 0x8802 | 902 | #define USB_DEVICE_ID_SUPER_DUAL_BOX_PRO 0x8802 |
903 | #define USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO 0x8804 | 903 | #define USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO 0x8804 |
904 | 904 | ||
905 | #define USB_VENDOR_ID_WISTRON 0x0fb8 | ||
906 | #define USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH 0x1109 | ||
907 | |||
905 | #define USB_VENDOR_ID_X_TENSIONS 0x1ae7 | 908 | #define USB_VENDOR_ID_X_TENSIONS 0x1ae7 |
906 | #define USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE 0x9001 | 909 | #define USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE 0x9001 |
907 | 910 | ||
diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c index 73845120295e..ecb5ca669e97 100644 --- a/drivers/hid/hid-kye.c +++ b/drivers/hid/hid-kye.c | |||
@@ -341,6 +341,9 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
341 | case USB_DEVICE_ID_GENIUS_GX_IMPERATOR: | 341 | case USB_DEVICE_ID_GENIUS_GX_IMPERATOR: |
342 | rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 83, | 342 | rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 83, |
343 | "Genius Gx Imperator Keyboard"); | 343 | "Genius Gx Imperator Keyboard"); |
344 | case USB_DEVICE_ID_GENIUS_MANTICORE: | ||
345 | rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104, | ||
346 | "Genius Manticore Keyboard"); | ||
344 | break; | 347 | break; |
345 | } | 348 | } |
346 | return rdesc; | 349 | return rdesc; |
@@ -418,6 +421,14 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
418 | goto enabling_err; | 421 | goto enabling_err; |
419 | } | 422 | } |
420 | break; | 423 | break; |
424 | case USB_DEVICE_ID_GENIUS_MANTICORE: | ||
425 | /* | ||
426 | * The manticore keyboard needs to have all the interfaces | ||
427 | * opened at least once to be fully functional. | ||
428 | */ | ||
429 | if (hid_hw_open(hdev)) | ||
430 | hid_hw_close(hdev); | ||
431 | break; | ||
421 | } | 432 | } |
422 | 433 | ||
423 | return 0; | 434 | return 0; |
@@ -439,6 +450,8 @@ static const struct hid_device_id kye_devices[] = { | |||
439 | USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) }, | 450 | USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) }, |
440 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, | 451 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, |
441 | USB_DEVICE_ID_GENIUS_GX_IMPERATOR) }, | 452 | USB_DEVICE_ID_GENIUS_GX_IMPERATOR) }, |
453 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, | ||
454 | USB_DEVICE_ID_GENIUS_MANTICORE) }, | ||
442 | { } | 455 | { } |
443 | }; | 456 | }; |
444 | MODULE_DEVICE_TABLE(hid, kye_devices); | 457 | MODULE_DEVICE_TABLE(hid, kye_devices); |
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index a2cedb8ae1c0..d83b1e8b505b 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
@@ -1335,6 +1335,12 @@ static const struct hid_device_id mt_devices[] = { | |||
1335 | { .driver_data = MT_CLS_NSMU, | 1335 | { .driver_data = MT_CLS_NSMU, |
1336 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, | 1336 | MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, |
1337 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, | 1337 | USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, |
1338 | |||
1339 | /* Wistron panels */ | ||
1340 | { .driver_data = MT_CLS_NSMU, | ||
1341 | MT_USB_DEVICE(USB_VENDOR_ID_WISTRON, | ||
1342 | USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH) }, | ||
1343 | |||
1338 | /* XAT */ | 1344 | /* XAT */ |
1339 | { .driver_data = MT_CLS_NSMU, | 1345 | { .driver_data = MT_CLS_NSMU, |
1340 | MT_USB_DEVICE(USB_VENDOR_ID_XAT, | 1346 | MT_USB_DEVICE(USB_VENDOR_ID_XAT, |
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index da551d113762..098af2f84b8c 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
@@ -225,6 +225,13 @@ static const unsigned int buzz_keymap[] = { | |||
225 | struct sony_sc { | 225 | struct sony_sc { |
226 | unsigned long quirks; | 226 | unsigned long quirks; |
227 | 227 | ||
228 | #ifdef CONFIG_SONY_FF | ||
229 | struct work_struct rumble_worker; | ||
230 | struct hid_device *hdev; | ||
231 | __u8 left; | ||
232 | __u8 right; | ||
233 | #endif | ||
234 | |||
228 | void *extra; | 235 | void *extra; |
229 | }; | 236 | }; |
230 | 237 | ||
@@ -615,9 +622,9 @@ static void buzz_remove(struct hid_device *hdev) | |||
615 | } | 622 | } |
616 | 623 | ||
617 | #ifdef CONFIG_SONY_FF | 624 | #ifdef CONFIG_SONY_FF |
618 | static int sony_play_effect(struct input_dev *dev, void *data, | 625 | static void sony_rumble_worker(struct work_struct *work) |
619 | struct ff_effect *effect) | ||
620 | { | 626 | { |
627 | struct sony_sc *sc = container_of(work, struct sony_sc, rumble_worker); | ||
621 | unsigned char buf[] = { | 628 | unsigned char buf[] = { |
622 | 0x01, | 629 | 0x01, |
623 | 0x00, 0xff, 0x00, 0xff, 0x00, | 630 | 0x00, 0xff, 0x00, 0xff, 0x00, |
@@ -628,21 +635,28 @@ static int sony_play_effect(struct input_dev *dev, void *data, | |||
628 | 0xff, 0x27, 0x10, 0x00, 0x32, | 635 | 0xff, 0x27, 0x10, 0x00, 0x32, |
629 | 0x00, 0x00, 0x00, 0x00, 0x00 | 636 | 0x00, 0x00, 0x00, 0x00, 0x00 |
630 | }; | 637 | }; |
631 | __u8 left; | 638 | |
632 | __u8 right; | 639 | buf[3] = sc->right; |
640 | buf[5] = sc->left; | ||
641 | |||
642 | sc->hdev->hid_output_raw_report(sc->hdev, buf, sizeof(buf), | ||
643 | HID_OUTPUT_REPORT); | ||
644 | } | ||
645 | |||
646 | static int sony_play_effect(struct input_dev *dev, void *data, | ||
647 | struct ff_effect *effect) | ||
648 | { | ||
633 | struct hid_device *hid = input_get_drvdata(dev); | 649 | struct hid_device *hid = input_get_drvdata(dev); |
650 | struct sony_sc *sc = hid_get_drvdata(hid); | ||
634 | 651 | ||
635 | if (effect->type != FF_RUMBLE) | 652 | if (effect->type != FF_RUMBLE) |
636 | return 0; | 653 | return 0; |
637 | 654 | ||
638 | left = effect->u.rumble.strong_magnitude / 256; | 655 | sc->left = effect->u.rumble.strong_magnitude / 256; |
639 | right = effect->u.rumble.weak_magnitude ? 1 : 0; | 656 | sc->right = effect->u.rumble.weak_magnitude ? 1 : 0; |
640 | |||
641 | buf[3] = right; | ||
642 | buf[5] = left; | ||
643 | 657 | ||
644 | return hid->hid_output_raw_report(hid, buf, sizeof(buf), | 658 | schedule_work(&sc->rumble_worker); |
645 | HID_OUTPUT_REPORT); | 659 | return 0; |
646 | } | 660 | } |
647 | 661 | ||
648 | static int sony_init_ff(struct hid_device *hdev) | 662 | static int sony_init_ff(struct hid_device *hdev) |
@@ -650,16 +664,31 @@ static int sony_init_ff(struct hid_device *hdev) | |||
650 | struct hid_input *hidinput = list_entry(hdev->inputs.next, | 664 | struct hid_input *hidinput = list_entry(hdev->inputs.next, |
651 | struct hid_input, list); | 665 | struct hid_input, list); |
652 | struct input_dev *input_dev = hidinput->input; | 666 | struct input_dev *input_dev = hidinput->input; |
667 | struct sony_sc *sc = hid_get_drvdata(hdev); | ||
668 | |||
669 | sc->hdev = hdev; | ||
670 | INIT_WORK(&sc->rumble_worker, sony_rumble_worker); | ||
653 | 671 | ||
654 | input_set_capability(input_dev, EV_FF, FF_RUMBLE); | 672 | input_set_capability(input_dev, EV_FF, FF_RUMBLE); |
655 | return input_ff_create_memless(input_dev, NULL, sony_play_effect); | 673 | return input_ff_create_memless(input_dev, NULL, sony_play_effect); |
656 | } | 674 | } |
657 | 675 | ||
676 | static void sony_destroy_ff(struct hid_device *hdev) | ||
677 | { | ||
678 | struct sony_sc *sc = hid_get_drvdata(hdev); | ||
679 | |||
680 | cancel_work_sync(&sc->rumble_worker); | ||
681 | } | ||
682 | |||
658 | #else | 683 | #else |
659 | static int sony_init_ff(struct hid_device *hdev) | 684 | static int sony_init_ff(struct hid_device *hdev) |
660 | { | 685 | { |
661 | return 0; | 686 | return 0; |
662 | } | 687 | } |
688 | |||
689 | static void sony_destroy_ff(struct hid_device *hdev) | ||
690 | { | ||
691 | } | ||
663 | #endif | 692 | #endif |
664 | 693 | ||
665 | static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | 694 | static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) |
@@ -728,6 +757,8 @@ static void sony_remove(struct hid_device *hdev) | |||
728 | if (sc->quirks & BUZZ_CONTROLLER) | 757 | if (sc->quirks & BUZZ_CONTROLLER) |
729 | buzz_remove(hdev); | 758 | buzz_remove(hdev); |
730 | 759 | ||
760 | sony_destroy_ff(hdev); | ||
761 | |||
731 | hid_hw_stop(hdev); | 762 | hid_hw_stop(hdev); |
732 | } | 763 | } |
733 | 764 | ||
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c index 1446f526ee8b..abb20db2b443 100644 --- a/drivers/hid/hid-wiimote-core.c +++ b/drivers/hid/hid-wiimote-core.c | |||
@@ -834,8 +834,7 @@ static void wiimote_init_set_type(struct wiimote_data *wdata, | |||
834 | goto done; | 834 | goto done; |
835 | } | 835 | } |
836 | 836 | ||
837 | if (vendor == USB_VENDOR_ID_NINTENDO || | 837 | if (vendor == USB_VENDOR_ID_NINTENDO) { |
838 | vendor == USB_VENDOR_ID_NINTENDO2) { | ||
839 | if (product == USB_DEVICE_ID_NINTENDO_WIIMOTE) { | 838 | if (product == USB_DEVICE_ID_NINTENDO_WIIMOTE) { |
840 | devtype = WIIMOTE_DEV_GEN10; | 839 | devtype = WIIMOTE_DEV_GEN10; |
841 | goto done; | 840 | goto done; |
@@ -1856,8 +1855,6 @@ static void wiimote_hid_remove(struct hid_device *hdev) | |||
1856 | static const struct hid_device_id wiimote_hid_devices[] = { | 1855 | static const struct hid_device_id wiimote_hid_devices[] = { |
1857 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, | 1856 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, |
1858 | USB_DEVICE_ID_NINTENDO_WIIMOTE) }, | 1857 | USB_DEVICE_ID_NINTENDO_WIIMOTE) }, |
1859 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO2, | ||
1860 | USB_DEVICE_ID_NINTENDO_WIIMOTE) }, | ||
1861 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, | 1858 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, |
1862 | USB_DEVICE_ID_NINTENDO_WIIMOTE2) }, | 1859 | USB_DEVICE_ID_NINTENDO_WIIMOTE2) }, |
1863 | { } | 1860 | { } |
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 93b00d76374c..cedc6da93c19 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c | |||
@@ -287,7 +287,7 @@ static int uhid_event_from_user(const char __user *buffer, size_t len, | |||
287 | */ | 287 | */ |
288 | struct uhid_create_req_compat *compat; | 288 | struct uhid_create_req_compat *compat; |
289 | 289 | ||
290 | compat = kmalloc(sizeof(*compat), GFP_KERNEL); | 290 | compat = kzalloc(sizeof(*compat), GFP_KERNEL); |
291 | if (!compat) | 291 | if (!compat) |
292 | return -ENOMEM; | 292 | return -ENOMEM; |
293 | 293 | ||
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c index 1d7ff46812c3..dafc63c6932d 100644 --- a/drivers/hwmon/asus_atk0110.c +++ b/drivers/hwmon/asus_atk0110.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | 19 | ||
20 | #include <acpi/acpi.h> | 20 | #include <acpi/acpi.h> |
21 | #include <acpi/acpixf.h> | ||
22 | #include <acpi/acpi_drivers.h> | 21 | #include <acpi/acpi_drivers.h> |
23 | #include <acpi/acpi_bus.h> | 22 | #include <acpi/acpi_bus.h> |
24 | 23 | ||
diff --git a/drivers/i2c/busses/i2c-bcm-kona.c b/drivers/i2c/busses/i2c-bcm-kona.c index 036cf03aeb61..18a74a6751a9 100644 --- a/drivers/i2c/busses/i2c-bcm-kona.c +++ b/drivers/i2c/busses/i2c-bcm-kona.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/clk.h> | ||
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
25 | 24 | ||
26 | /* Hardware register offsets and field defintions */ | 25 | /* Hardware register offsets and field defintions */ |
@@ -891,7 +890,7 @@ static const struct of_device_id bcm_kona_i2c_of_match[] = { | |||
891 | {.compatible = "brcm,kona-i2c",}, | 890 | {.compatible = "brcm,kona-i2c",}, |
892 | {}, | 891 | {}, |
893 | }; | 892 | }; |
894 | MODULE_DEVICE_TABLE(of, kona_i2c_of_match); | 893 | MODULE_DEVICE_TABLE(of, bcm_kona_i2c_of_match); |
895 | 894 | ||
896 | static struct platform_driver bcm_kona_i2c_driver = { | 895 | static struct platform_driver bcm_kona_i2c_driver = { |
897 | .driver = { | 896 | .driver = { |
diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index d7e8600f31fb..77df97b932af 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c | |||
@@ -299,6 +299,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) | |||
299 | strlcpy(adap->name, "bcm2835 I2C adapter", sizeof(adap->name)); | 299 | strlcpy(adap->name, "bcm2835 I2C adapter", sizeof(adap->name)); |
300 | adap->algo = &bcm2835_i2c_algo; | 300 | adap->algo = &bcm2835_i2c_algo; |
301 | adap->dev.parent = &pdev->dev; | 301 | adap->dev.parent = &pdev->dev; |
302 | adap->dev.of_node = pdev->dev.of_node; | ||
302 | 303 | ||
303 | bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0); | 304 | bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0); |
304 | 305 | ||
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index ff05d9fef4a8..af0b5830303d 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c | |||
@@ -125,12 +125,12 @@ static struct davinci_i2c_platform_data davinci_i2c_platform_data_default = { | |||
125 | static inline void davinci_i2c_write_reg(struct davinci_i2c_dev *i2c_dev, | 125 | static inline void davinci_i2c_write_reg(struct davinci_i2c_dev *i2c_dev, |
126 | int reg, u16 val) | 126 | int reg, u16 val) |
127 | { | 127 | { |
128 | __raw_writew(val, i2c_dev->base + reg); | 128 | writew_relaxed(val, i2c_dev->base + reg); |
129 | } | 129 | } |
130 | 130 | ||
131 | static inline u16 davinci_i2c_read_reg(struct davinci_i2c_dev *i2c_dev, int reg) | 131 | static inline u16 davinci_i2c_read_reg(struct davinci_i2c_dev *i2c_dev, int reg) |
132 | { | 132 | { |
133 | return __raw_readw(i2c_dev->base + reg); | 133 | return readw_relaxed(i2c_dev->base + reg); |
134 | } | 134 | } |
135 | 135 | ||
136 | /* Generate a pulse on the i2c clock pin. */ | 136 | /* Generate a pulse on the i2c clock pin. */ |
diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c index dae3ddfe7619..721f7ebf9a3b 100644 --- a/drivers/i2c/busses/i2c-diolan-u2c.c +++ b/drivers/i2c/busses/i2c-diolan-u2c.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #define USB_VENDOR_ID_DIOLAN 0x0abf | 25 | #define USB_VENDOR_ID_DIOLAN 0x0abf |
26 | #define USB_DEVICE_ID_DIOLAN_U2C 0x3370 | 26 | #define USB_DEVICE_ID_DIOLAN_U2C 0x3370 |
27 | 27 | ||
28 | #define DIOLAN_OUT_EP 0x02 | ||
29 | #define DIOLAN_IN_EP 0x84 | ||
30 | 28 | ||
31 | /* commands via USB, must match command ids in the firmware */ | 29 | /* commands via USB, must match command ids in the firmware */ |
32 | #define CMD_I2C_READ 0x01 | 30 | #define CMD_I2C_READ 0x01 |
@@ -84,6 +82,7 @@ | |||
84 | struct i2c_diolan_u2c { | 82 | struct i2c_diolan_u2c { |
85 | u8 obuffer[DIOLAN_OUTBUF_LEN]; /* output buffer */ | 83 | u8 obuffer[DIOLAN_OUTBUF_LEN]; /* output buffer */ |
86 | u8 ibuffer[DIOLAN_INBUF_LEN]; /* input buffer */ | 84 | u8 ibuffer[DIOLAN_INBUF_LEN]; /* input buffer */ |
85 | int ep_in, ep_out; /* Endpoints */ | ||
87 | struct usb_device *usb_dev; /* the usb device for this device */ | 86 | struct usb_device *usb_dev; /* the usb device for this device */ |
88 | struct usb_interface *interface;/* the interface for this device */ | 87 | struct usb_interface *interface;/* the interface for this device */ |
89 | struct i2c_adapter adapter; /* i2c related things */ | 88 | struct i2c_adapter adapter; /* i2c related things */ |
@@ -109,7 +108,7 @@ static int diolan_usb_transfer(struct i2c_diolan_u2c *dev) | |||
109 | return -EINVAL; | 108 | return -EINVAL; |
110 | 109 | ||
111 | ret = usb_bulk_msg(dev->usb_dev, | 110 | ret = usb_bulk_msg(dev->usb_dev, |
112 | usb_sndbulkpipe(dev->usb_dev, DIOLAN_OUT_EP), | 111 | usb_sndbulkpipe(dev->usb_dev, dev->ep_out), |
113 | dev->obuffer, dev->olen, &actual, | 112 | dev->obuffer, dev->olen, &actual, |
114 | DIOLAN_USB_TIMEOUT); | 113 | DIOLAN_USB_TIMEOUT); |
115 | if (!ret) { | 114 | if (!ret) { |
@@ -118,7 +117,7 @@ static int diolan_usb_transfer(struct i2c_diolan_u2c *dev) | |||
118 | 117 | ||
119 | tmpret = usb_bulk_msg(dev->usb_dev, | 118 | tmpret = usb_bulk_msg(dev->usb_dev, |
120 | usb_rcvbulkpipe(dev->usb_dev, | 119 | usb_rcvbulkpipe(dev->usb_dev, |
121 | DIOLAN_IN_EP), | 120 | dev->ep_in), |
122 | dev->ibuffer, | 121 | dev->ibuffer, |
123 | sizeof(dev->ibuffer), &actual, | 122 | sizeof(dev->ibuffer), &actual, |
124 | DIOLAN_USB_TIMEOUT); | 123 | DIOLAN_USB_TIMEOUT); |
@@ -210,7 +209,7 @@ static void diolan_flush_input(struct i2c_diolan_u2c *dev) | |||
210 | int ret; | 209 | int ret; |
211 | 210 | ||
212 | ret = usb_bulk_msg(dev->usb_dev, | 211 | ret = usb_bulk_msg(dev->usb_dev, |
213 | usb_rcvbulkpipe(dev->usb_dev, DIOLAN_IN_EP), | 212 | usb_rcvbulkpipe(dev->usb_dev, dev->ep_in), |
214 | dev->ibuffer, sizeof(dev->ibuffer), &actual, | 213 | dev->ibuffer, sizeof(dev->ibuffer), &actual, |
215 | DIOLAN_USB_TIMEOUT); | 214 | DIOLAN_USB_TIMEOUT); |
216 | if (ret < 0 || actual == 0) | 215 | if (ret < 0 || actual == 0) |
@@ -445,9 +444,14 @@ static void diolan_u2c_free(struct i2c_diolan_u2c *dev) | |||
445 | static int diolan_u2c_probe(struct usb_interface *interface, | 444 | static int diolan_u2c_probe(struct usb_interface *interface, |
446 | const struct usb_device_id *id) | 445 | const struct usb_device_id *id) |
447 | { | 446 | { |
447 | struct usb_host_interface *hostif = interface->cur_altsetting; | ||
448 | struct i2c_diolan_u2c *dev; | 448 | struct i2c_diolan_u2c *dev; |
449 | int ret; | 449 | int ret; |
450 | 450 | ||
451 | if (hostif->desc.bInterfaceNumber != 0 | ||
452 | || hostif->desc.bNumEndpoints < 2) | ||
453 | return -ENODEV; | ||
454 | |||
451 | /* allocate memory for our device state and initialize it */ | 455 | /* allocate memory for our device state and initialize it */ |
452 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 456 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
453 | if (dev == NULL) { | 457 | if (dev == NULL) { |
@@ -455,6 +459,8 @@ static int diolan_u2c_probe(struct usb_interface *interface, | |||
455 | ret = -ENOMEM; | 459 | ret = -ENOMEM; |
456 | goto error; | 460 | goto error; |
457 | } | 461 | } |
462 | dev->ep_out = hostif->endpoint[0].desc.bEndpointAddress; | ||
463 | dev->ep_in = hostif->endpoint[1].desc.bEndpointAddress; | ||
458 | 464 | ||
459 | dev->usb_dev = usb_get_dev(interface_to_usbdev(interface)); | 465 | dev->usb_dev = usb_get_dev(interface_to_usbdev(interface)); |
460 | dev->interface = interface; | 466 | dev->interface = interface; |
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index a6a891d7970d..90dcc2eaac5f 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -266,13 +266,13 @@ static const u8 reg_map_ip_v2[] = { | |||
266 | static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, | 266 | static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, |
267 | int reg, u16 val) | 267 | int reg, u16 val) |
268 | { | 268 | { |
269 | __raw_writew(val, i2c_dev->base + | 269 | writew_relaxed(val, i2c_dev->base + |
270 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); | 270 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); |
271 | } | 271 | } |
272 | 272 | ||
273 | static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) | 273 | static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) |
274 | { | 274 | { |
275 | return __raw_readw(i2c_dev->base + | 275 | return readw_relaxed(i2c_dev->base + |
276 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); | 276 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); |
277 | } | 277 | } |
278 | 278 | ||
@@ -1037,6 +1037,20 @@ static const struct i2c_algorithm omap_i2c_algo = { | |||
1037 | }; | 1037 | }; |
1038 | 1038 | ||
1039 | #ifdef CONFIG_OF | 1039 | #ifdef CONFIG_OF |
1040 | static struct omap_i2c_bus_platform_data omap2420_pdata = { | ||
1041 | .rev = OMAP_I2C_IP_VERSION_1, | ||
1042 | .flags = OMAP_I2C_FLAG_NO_FIFO | | ||
1043 | OMAP_I2C_FLAG_SIMPLE_CLOCK | | ||
1044 | OMAP_I2C_FLAG_16BIT_DATA_REG | | ||
1045 | OMAP_I2C_FLAG_BUS_SHIFT_2, | ||
1046 | }; | ||
1047 | |||
1048 | static struct omap_i2c_bus_platform_data omap2430_pdata = { | ||
1049 | .rev = OMAP_I2C_IP_VERSION_1, | ||
1050 | .flags = OMAP_I2C_FLAG_BUS_SHIFT_2 | | ||
1051 | OMAP_I2C_FLAG_FORCE_19200_INT_CLK, | ||
1052 | }; | ||
1053 | |||
1040 | static struct omap_i2c_bus_platform_data omap3_pdata = { | 1054 | static struct omap_i2c_bus_platform_data omap3_pdata = { |
1041 | .rev = OMAP_I2C_IP_VERSION_1, | 1055 | .rev = OMAP_I2C_IP_VERSION_1, |
1042 | .flags = OMAP_I2C_FLAG_BUS_SHIFT_2, | 1056 | .flags = OMAP_I2C_FLAG_BUS_SHIFT_2, |
@@ -1055,6 +1069,14 @@ static const struct of_device_id omap_i2c_of_match[] = { | |||
1055 | .compatible = "ti,omap3-i2c", | 1069 | .compatible = "ti,omap3-i2c", |
1056 | .data = &omap3_pdata, | 1070 | .data = &omap3_pdata, |
1057 | }, | 1071 | }, |
1072 | { | ||
1073 | .compatible = "ti,omap2430-i2c", | ||
1074 | .data = &omap2430_pdata, | ||
1075 | }, | ||
1076 | { | ||
1077 | .compatible = "ti,omap2420-i2c", | ||
1078 | .data = &omap2420_pdata, | ||
1079 | }, | ||
1058 | { }, | 1080 | { }, |
1059 | }; | 1081 | }; |
1060 | MODULE_DEVICE_TABLE(of, omap_i2c_of_match); | 1082 | MODULE_DEVICE_TABLE(of, omap_i2c_of_match); |
@@ -1140,9 +1162,9 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1140 | * Read the Rev hi bit-[15:14] ie scheme this is 1 indicates ver2. | 1162 | * Read the Rev hi bit-[15:14] ie scheme this is 1 indicates ver2. |
1141 | * On omap1/3/2 Offset 4 is IE Reg the bit [15:14] is 0 at reset. | 1163 | * On omap1/3/2 Offset 4 is IE Reg the bit [15:14] is 0 at reset. |
1142 | * Also since the omap_i2c_read_reg uses reg_map_ip_* a | 1164 | * Also since the omap_i2c_read_reg uses reg_map_ip_* a |
1143 | * raw_readw is done. | 1165 | * readw_relaxed is done. |
1144 | */ | 1166 | */ |
1145 | rev = __raw_readw(dev->base + 0x04); | 1167 | rev = readw_relaxed(dev->base + 0x04); |
1146 | 1168 | ||
1147 | dev->scheme = OMAP_I2C_SCHEME(rev); | 1169 | dev->scheme = OMAP_I2C_SCHEME(rev); |
1148 | switch (dev->scheme) { | 1170 | switch (dev->scheme) { |
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index cbd4e9abc47e..92d1206482a6 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c | |||
@@ -329,7 +329,7 @@ static struct cpuidle_state atom_cstates[] __initdata = { | |||
329 | { | 329 | { |
330 | .enter = NULL } | 330 | .enter = NULL } |
331 | }; | 331 | }; |
332 | static struct cpuidle_state avn_cstates[CPUIDLE_STATE_MAX] = { | 332 | static struct cpuidle_state avn_cstates[] __initdata = { |
333 | { | 333 | { |
334 | .name = "C1-AVN", | 334 | .name = "C1-AVN", |
335 | .desc = "MWAIT 0x00", | 335 | .desc = "MWAIT 0x00", |
@@ -340,7 +340,7 @@ static struct cpuidle_state avn_cstates[CPUIDLE_STATE_MAX] = { | |||
340 | { | 340 | { |
341 | .name = "C6-AVN", | 341 | .name = "C6-AVN", |
342 | .desc = "MWAIT 0x51", | 342 | .desc = "MWAIT 0x51", |
343 | .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, | 343 | .flags = MWAIT2flg(0x51) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, |
344 | .exit_latency = 15, | 344 | .exit_latency = 15, |
345 | .target_residency = 45, | 345 | .target_residency = 45, |
346 | .enter = &intel_idle }, | 346 | .enter = &intel_idle }, |
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index dcda17395c4e..1cae4e920c9b 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c | |||
@@ -350,7 +350,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) | |||
350 | error_iio_unreg: | 350 | error_iio_unreg: |
351 | iio_device_unregister(indio_dev); | 351 | iio_device_unregister(indio_dev); |
352 | error_remove_trigger: | 352 | error_remove_trigger: |
353 | hid_sensor_remove_trigger(indio_dev); | 353 | hid_sensor_remove_trigger(&accel_state->common_attributes); |
354 | error_unreg_buffer_funcs: | 354 | error_unreg_buffer_funcs: |
355 | iio_triggered_buffer_cleanup(indio_dev); | 355 | iio_triggered_buffer_cleanup(indio_dev); |
356 | error_free_dev_mem: | 356 | error_free_dev_mem: |
@@ -363,10 +363,11 @@ static int hid_accel_3d_remove(struct platform_device *pdev) | |||
363 | { | 363 | { |
364 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; | 364 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; |
365 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | 365 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); |
366 | struct accel_3d_state *accel_state = iio_priv(indio_dev); | ||
366 | 367 | ||
367 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ACCEL_3D); | 368 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ACCEL_3D); |
368 | iio_device_unregister(indio_dev); | 369 | iio_device_unregister(indio_dev); |
369 | hid_sensor_remove_trigger(indio_dev); | 370 | hid_sensor_remove_trigger(&accel_state->common_attributes); |
370 | iio_triggered_buffer_cleanup(indio_dev); | 371 | iio_triggered_buffer_cleanup(indio_dev); |
371 | kfree(indio_dev->channels); | 372 | kfree(indio_dev->channels); |
372 | 373 | ||
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index d72118d1189c..98ba761cbb9c 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c | |||
@@ -112,9 +112,10 @@ static int kxsd9_read(struct iio_dev *indio_dev, u8 address) | |||
112 | mutex_lock(&st->buf_lock); | 112 | mutex_lock(&st->buf_lock); |
113 | st->tx[0] = KXSD9_READ(address); | 113 | st->tx[0] = KXSD9_READ(address); |
114 | ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); | 114 | ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); |
115 | if (ret) | 115 | if (!ret) |
116 | return ret; | 116 | ret = (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0); |
117 | return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0); | 117 | mutex_unlock(&st->buf_lock); |
118 | return ret; | ||
118 | } | 119 | } |
119 | 120 | ||
120 | static IIO_CONST_ATTR(accel_scale_available, | 121 | static IIO_CONST_ATTR(accel_scale_available, |
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 17df74908db1..5b1aa027c034 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c | |||
@@ -1047,6 +1047,7 @@ static int at91_adc_probe(struct platform_device *pdev) | |||
1047 | } else { | 1047 | } else { |
1048 | if (!st->caps->has_tsmr) { | 1048 | if (!st->caps->has_tsmr) { |
1049 | dev_err(&pdev->dev, "We don't support non-TSMR adc\n"); | 1049 | dev_err(&pdev->dev, "We don't support non-TSMR adc\n"); |
1050 | ret = -ENODEV; | ||
1050 | goto error_disable_adc_clk; | 1051 | goto error_disable_adc_clk; |
1051 | } | 1052 | } |
1052 | 1053 | ||
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index 12948325431c..c8c1baaec6c1 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c | |||
@@ -88,10 +88,10 @@ static const int mcp3422_sample_rates[4] = { | |||
88 | 88 | ||
89 | /* sample rates to sign extension table */ | 89 | /* sample rates to sign extension table */ |
90 | static const int mcp3422_sign_extend[4] = { | 90 | static const int mcp3422_sign_extend[4] = { |
91 | [MCP3422_SRATE_240] = 12, | 91 | [MCP3422_SRATE_240] = 11, |
92 | [MCP3422_SRATE_60] = 14, | 92 | [MCP3422_SRATE_60] = 13, |
93 | [MCP3422_SRATE_15] = 16, | 93 | [MCP3422_SRATE_15] = 15, |
94 | [MCP3422_SRATE_3] = 18 }; | 94 | [MCP3422_SRATE_3] = 17 }; |
95 | 95 | ||
96 | /* Client data (each client gets its own) */ | 96 | /* Client data (each client gets its own) */ |
97 | struct mcp3422 { | 97 | struct mcp3422 { |
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 728411ec7642..d4d748214e4b 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c | |||
@@ -229,12 +229,15 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev, | |||
229 | unsigned long flags, | 229 | unsigned long flags, |
230 | const struct iio_buffer_setup_ops *setup_ops) | 230 | const struct iio_buffer_setup_ops *setup_ops) |
231 | { | 231 | { |
232 | struct iio_buffer *buffer; | ||
232 | int ret; | 233 | int ret; |
233 | 234 | ||
234 | indio_dev->buffer = iio_kfifo_allocate(indio_dev); | 235 | buffer = iio_kfifo_allocate(indio_dev); |
235 | if (!indio_dev->buffer) | 236 | if (!buffer) |
236 | return -ENOMEM; | 237 | return -ENOMEM; |
237 | 238 | ||
239 | iio_device_attach_buffer(indio_dev, buffer); | ||
240 | |||
238 | ret = request_threaded_irq(irq, pollfunc_th, pollfunc_bh, | 241 | ret = request_threaded_irq(irq, pollfunc_th, pollfunc_bh, |
239 | flags, indio_dev->name, indio_dev); | 242 | flags, indio_dev->name, indio_dev); |
240 | if (ret) | 243 | if (ret) |
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index b6e77e0fc420..bbd6426c9726 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c | |||
@@ -55,11 +55,10 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, | |||
55 | return 0; | 55 | return 0; |
56 | } | 56 | } |
57 | 57 | ||
58 | void hid_sensor_remove_trigger(struct iio_dev *indio_dev) | 58 | void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) |
59 | { | 59 | { |
60 | iio_trigger_unregister(indio_dev->trig); | 60 | iio_trigger_unregister(attrb->trigger); |
61 | iio_trigger_free(indio_dev->trig); | 61 | iio_trigger_free(attrb->trigger); |
62 | indio_dev->trig = NULL; | ||
63 | } | 62 | } |
64 | EXPORT_SYMBOL(hid_sensor_remove_trigger); | 63 | EXPORT_SYMBOL(hid_sensor_remove_trigger); |
65 | 64 | ||
@@ -90,7 +89,7 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, | |||
90 | dev_err(&indio_dev->dev, "Trigger Register Failed\n"); | 89 | dev_err(&indio_dev->dev, "Trigger Register Failed\n"); |
91 | goto error_free_trig; | 90 | goto error_free_trig; |
92 | } | 91 | } |
93 | indio_dev->trig = trig; | 92 | indio_dev->trig = attrb->trigger = trig; |
94 | 93 | ||
95 | return ret; | 94 | return ret; |
96 | 95 | ||
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h index 9a8731478eda..ca02f7811aa8 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h | |||
@@ -21,6 +21,6 @@ | |||
21 | 21 | ||
22 | int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, | 22 | int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, |
23 | struct hid_sensor_common *attrb); | 23 | struct hid_sensor_common *attrb); |
24 | void hid_sensor_remove_trigger(struct iio_dev *indio_dev); | 24 | void hid_sensor_remove_trigger(struct hid_sensor_common *attrb); |
25 | 25 | ||
26 | #endif | 26 | #endif |
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index ea01c6bcfb56..e54f0f4959d3 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c | |||
@@ -348,7 +348,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) | |||
348 | error_iio_unreg: | 348 | error_iio_unreg: |
349 | iio_device_unregister(indio_dev); | 349 | iio_device_unregister(indio_dev); |
350 | error_remove_trigger: | 350 | error_remove_trigger: |
351 | hid_sensor_remove_trigger(indio_dev); | 351 | hid_sensor_remove_trigger(&gyro_state->common_attributes); |
352 | error_unreg_buffer_funcs: | 352 | error_unreg_buffer_funcs: |
353 | iio_triggered_buffer_cleanup(indio_dev); | 353 | iio_triggered_buffer_cleanup(indio_dev); |
354 | error_free_dev_mem: | 354 | error_free_dev_mem: |
@@ -361,10 +361,11 @@ static int hid_gyro_3d_remove(struct platform_device *pdev) | |||
361 | { | 361 | { |
362 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; | 362 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; |
363 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | 363 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); |
364 | struct gyro_3d_state *gyro_state = iio_priv(indio_dev); | ||
364 | 365 | ||
365 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D); | 366 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D); |
366 | iio_device_unregister(indio_dev); | 367 | iio_device_unregister(indio_dev); |
367 | hid_sensor_remove_trigger(indio_dev); | 368 | hid_sensor_remove_trigger(&gyro_state->common_attributes); |
368 | iio_triggered_buffer_cleanup(indio_dev); | 369 | iio_triggered_buffer_cleanup(indio_dev); |
369 | kfree(indio_dev->channels); | 370 | kfree(indio_dev->channels); |
370 | 371 | ||
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index f98c2b509254..b0d65df3ede2 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig | |||
@@ -81,6 +81,8 @@ config SENSORS_LM3533 | |||
81 | config TCS3472 | 81 | config TCS3472 |
82 | tristate "TAOS TCS3472 color light-to-digital converter" | 82 | tristate "TAOS TCS3472 color light-to-digital converter" |
83 | depends on I2C | 83 | depends on I2C |
84 | select IIO_BUFFER | ||
85 | select IIO_TRIGGERED_BUFFER | ||
84 | help | 86 | help |
85 | If you say yes here you get support for the TAOS TCS3472 | 87 | If you say yes here you get support for the TAOS TCS3472 |
86 | family of color light-to-digital converters with IR filter. | 88 | family of color light-to-digital converters with IR filter. |
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index fa6ae8cf89ea..8e8b9d722853 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c | |||
@@ -314,7 +314,7 @@ static int hid_als_probe(struct platform_device *pdev) | |||
314 | error_iio_unreg: | 314 | error_iio_unreg: |
315 | iio_device_unregister(indio_dev); | 315 | iio_device_unregister(indio_dev); |
316 | error_remove_trigger: | 316 | error_remove_trigger: |
317 | hid_sensor_remove_trigger(indio_dev); | 317 | hid_sensor_remove_trigger(&als_state->common_attributes); |
318 | error_unreg_buffer_funcs: | 318 | error_unreg_buffer_funcs: |
319 | iio_triggered_buffer_cleanup(indio_dev); | 319 | iio_triggered_buffer_cleanup(indio_dev); |
320 | error_free_dev_mem: | 320 | error_free_dev_mem: |
@@ -327,10 +327,11 @@ static int hid_als_remove(struct platform_device *pdev) | |||
327 | { | 327 | { |
328 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; | 328 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; |
329 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | 329 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); |
330 | struct als_state *als_state = iio_priv(indio_dev); | ||
330 | 331 | ||
331 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS); | 332 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS); |
332 | iio_device_unregister(indio_dev); | 333 | iio_device_unregister(indio_dev); |
333 | hid_sensor_remove_trigger(indio_dev); | 334 | hid_sensor_remove_trigger(&als_state->common_attributes); |
334 | iio_triggered_buffer_cleanup(indio_dev); | 335 | iio_triggered_buffer_cleanup(indio_dev); |
335 | kfree(indio_dev->channels); | 336 | kfree(indio_dev->channels); |
336 | 337 | ||
diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index 0cf09637b35b..d86d226dcd67 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig | |||
@@ -19,6 +19,8 @@ config AK8975 | |||
19 | config MAG3110 | 19 | config MAG3110 |
20 | tristate "Freescale MAG3110 3-Axis Magnetometer" | 20 | tristate "Freescale MAG3110 3-Axis Magnetometer" |
21 | depends on I2C | 21 | depends on I2C |
22 | select IIO_BUFFER | ||
23 | select IIO_TRIGGERED_BUFFER | ||
22 | help | 24 | help |
23 | Say yes here to build support for the Freescale MAG3110 3-Axis | 25 | Say yes here to build support for the Freescale MAG3110 3-Axis |
24 | magnetometer. | 26 | magnetometer. |
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 2634920562fb..b26e1028a0a0 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c | |||
@@ -351,7 +351,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev) | |||
351 | error_iio_unreg: | 351 | error_iio_unreg: |
352 | iio_device_unregister(indio_dev); | 352 | iio_device_unregister(indio_dev); |
353 | error_remove_trigger: | 353 | error_remove_trigger: |
354 | hid_sensor_remove_trigger(indio_dev); | 354 | hid_sensor_remove_trigger(&magn_state->common_attributes); |
355 | error_unreg_buffer_funcs: | 355 | error_unreg_buffer_funcs: |
356 | iio_triggered_buffer_cleanup(indio_dev); | 356 | iio_triggered_buffer_cleanup(indio_dev); |
357 | error_free_dev_mem: | 357 | error_free_dev_mem: |
@@ -364,10 +364,11 @@ static int hid_magn_3d_remove(struct platform_device *pdev) | |||
364 | { | 364 | { |
365 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; | 365 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; |
366 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | 366 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); |
367 | struct magn_3d_state *magn_state = iio_priv(indio_dev); | ||
367 | 368 | ||
368 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D); | 369 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D); |
369 | iio_device_unregister(indio_dev); | 370 | iio_device_unregister(indio_dev); |
370 | hid_sensor_remove_trigger(indio_dev); | 371 | hid_sensor_remove_trigger(&magn_state->common_attributes); |
371 | iio_triggered_buffer_cleanup(indio_dev); | 372 | iio_triggered_buffer_cleanup(indio_dev); |
372 | kfree(indio_dev->channels); | 373 | kfree(indio_dev->channels); |
373 | 374 | ||
diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index 783c5b417356..becf54496967 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c | |||
@@ -250,7 +250,12 @@ done: | |||
250 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ | 250 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ |
251 | BIT(IIO_CHAN_INFO_SCALE), \ | 251 | BIT(IIO_CHAN_INFO_SCALE), \ |
252 | .scan_index = idx, \ | 252 | .scan_index = idx, \ |
253 | .scan_type = IIO_ST('s', 16, 16, IIO_BE), \ | 253 | .scan_type = { \ |
254 | .sign = 's', \ | ||
255 | .realbits = 16, \ | ||
256 | .storagebits = 16, \ | ||
257 | .endianness = IIO_BE, \ | ||
258 | }, \ | ||
254 | } | 259 | } |
255 | 260 | ||
256 | static const struct iio_chan_spec mag3110_channels[] = { | 261 | static const struct iio_chan_spec mag3110_channels[] = { |
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index 86b822806e95..45e0e3e55de2 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c | |||
@@ -180,7 +180,10 @@ static int64_t hp_sdc_rtc_read_i8042timer (uint8_t loadcmd, int numreg) | |||
180 | if (WARN_ON(down_interruptible(&i8042tregs))) | 180 | if (WARN_ON(down_interruptible(&i8042tregs))) |
181 | return -1; | 181 | return -1; |
182 | 182 | ||
183 | if (hp_sdc_enqueue_transaction(&t)) return -1; | 183 | if (hp_sdc_enqueue_transaction(&t)) { |
184 | up(&i8042tregs); | ||
185 | return -1; | ||
186 | } | ||
184 | 187 | ||
185 | /* Sleep until results come back. */ | 188 | /* Sleep until results come back. */ |
186 | if (WARN_ON(down_interruptible(&i8042tregs))) | 189 | if (WARN_ON(down_interruptible(&i8042tregs))) |
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 00d1e547b211..961d58d32647 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -906,6 +906,17 @@ config TOUCHSCREEN_STMPE | |||
906 | To compile this driver as a module, choose M here: the | 906 | To compile this driver as a module, choose M here: the |
907 | module will be called stmpe-ts. | 907 | module will be called stmpe-ts. |
908 | 908 | ||
909 | config TOUCHSCREEN_SUR40 | ||
910 | tristate "Samsung SUR40 (Surface 2.0/PixelSense) touchscreen" | ||
911 | depends on USB | ||
912 | select INPUT_POLLDEV | ||
913 | help | ||
914 | Say Y here if you want support for the Samsung SUR40 touchscreen | ||
915 | (also known as Microsoft Surface 2.0 or Microsoft PixelSense). | ||
916 | |||
917 | To compile this driver as a module, choose M here: the | ||
918 | module will be called sur40. | ||
919 | |||
909 | config TOUCHSCREEN_TPS6507X | 920 | config TOUCHSCREEN_TPS6507X |
910 | tristate "TPS6507x based touchscreens" | 921 | tristate "TPS6507x based touchscreens" |
911 | depends on I2C | 922 | depends on I2C |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 7587883b8d38..62801f213346 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -54,6 +54,7 @@ obj-$(CONFIG_TOUCHSCREEN_PIXCIR) += pixcir_i2c_ts.o | |||
54 | obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o | 54 | obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o |
55 | obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o | 55 | obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o |
56 | obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o | 56 | obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o |
57 | obj-$(CONFIG_TOUCHSCREEN_SUR40) += sur40.o | ||
57 | obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o | 58 | obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o |
58 | obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o | 59 | obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o |
59 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o | 60 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o |
diff --git a/drivers/input/touchscreen/atmel-wm97xx.c b/drivers/input/touchscreen/atmel-wm97xx.c index 268a35e55d7f..279c0e42b8a7 100644 --- a/drivers/input/touchscreen/atmel-wm97xx.c +++ b/drivers/input/touchscreen/atmel-wm97xx.c | |||
@@ -391,7 +391,7 @@ static int __exit atmel_wm97xx_remove(struct platform_device *pdev) | |||
391 | } | 391 | } |
392 | 392 | ||
393 | #ifdef CONFIG_PM_SLEEP | 393 | #ifdef CONFIG_PM_SLEEP |
394 | static int atmel_wm97xx_suspend(struct *dev) | 394 | static int atmel_wm97xx_suspend(struct device *dev) |
395 | { | 395 | { |
396 | struct platform_device *pdev = to_platform_device(dev); | 396 | struct platform_device *pdev = to_platform_device(dev); |
397 | struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev); | 397 | struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev); |
diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 42d830efa316..a035a390f8e2 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c | |||
@@ -1246,8 +1246,7 @@ static void cyttsp4_watchdog_timer(unsigned long handle) | |||
1246 | 1246 | ||
1247 | dev_vdbg(cd->dev, "%s: Watchdog timer triggered\n", __func__); | 1247 | dev_vdbg(cd->dev, "%s: Watchdog timer triggered\n", __func__); |
1248 | 1248 | ||
1249 | if (!work_pending(&cd->watchdog_work)) | 1249 | schedule_work(&cd->watchdog_work); |
1250 | schedule_work(&cd->watchdog_work); | ||
1251 | 1250 | ||
1252 | return; | 1251 | return; |
1253 | } | 1252 | } |
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c new file mode 100644 index 000000000000..cfd1b7e8c001 --- /dev/null +++ b/drivers/input/touchscreen/sur40.c | |||
@@ -0,0 +1,466 @@ | |||
1 | /* | ||
2 | * Surface2.0/SUR40/PixelSense input driver | ||
3 | * | ||
4 | * Copyright (c) 2013 by Florian 'floe' Echtler <floe@butterbrot.org> | ||
5 | * | ||
6 | * Derived from the USB Skeleton driver 1.1, | ||
7 | * Copyright (c) 2003 Greg Kroah-Hartman (greg@kroah.com) | ||
8 | * | ||
9 | * and from the Apple USB BCM5974 multitouch driver, | ||
10 | * Copyright (c) 2008 Henrik Rydberg (rydberg@euromail.se) | ||
11 | * | ||
12 | * and from the generic hid-multitouch driver, | ||
13 | * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr> | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License as | ||
17 | * published by the Free Software Foundation; either version 2 of | ||
18 | * the License, or (at your option) any later version. | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/errno.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/slab.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/completion.h> | ||
28 | #include <linux/uaccess.h> | ||
29 | #include <linux/usb.h> | ||
30 | #include <linux/printk.h> | ||
31 | #include <linux/input-polldev.h> | ||
32 | #include <linux/input/mt.h> | ||
33 | #include <linux/usb/input.h> | ||
34 | |||
35 | /* read 512 bytes from endpoint 0x86 -> get header + blobs */ | ||
36 | struct sur40_header { | ||
37 | |||
38 | __le16 type; /* always 0x0001 */ | ||
39 | __le16 count; /* count of blobs (if 0: continue prev. packet) */ | ||
40 | |||
41 | __le32 packet_id; /* unique ID for all packets in one frame */ | ||
42 | |||
43 | __le32 timestamp; /* milliseconds (inc. by 16 or 17 each frame) */ | ||
44 | __le32 unknown; /* "epoch?" always 02/03 00 00 00 */ | ||
45 | |||
46 | } __packed; | ||
47 | |||
48 | struct sur40_blob { | ||
49 | |||
50 | __le16 blob_id; | ||
51 | |||
52 | u8 action; /* 0x02 = enter/exit, 0x03 = update (?) */ | ||
53 | u8 unknown; /* always 0x01 or 0x02 (no idea what this is?) */ | ||
54 | |||
55 | __le16 bb_pos_x; /* upper left corner of bounding box */ | ||
56 | __le16 bb_pos_y; | ||
57 | |||
58 | __le16 bb_size_x; /* size of bounding box */ | ||
59 | __le16 bb_size_y; | ||
60 | |||
61 | __le16 pos_x; /* finger tip position */ | ||
62 | __le16 pos_y; | ||
63 | |||
64 | __le16 ctr_x; /* centroid position */ | ||
65 | __le16 ctr_y; | ||
66 | |||
67 | __le16 axis_x; /* somehow related to major/minor axis, mostly: */ | ||
68 | __le16 axis_y; /* axis_x == bb_size_y && axis_y == bb_size_x */ | ||
69 | |||
70 | __le32 angle; /* orientation in radians relative to x axis - | ||
71 | actually an IEEE754 float, don't use in kernel */ | ||
72 | |||
73 | __le32 area; /* size in pixels/pressure (?) */ | ||
74 | |||
75 | u8 padding[32]; | ||
76 | |||
77 | } __packed; | ||
78 | |||
79 | /* combined header/blob data */ | ||
80 | struct sur40_data { | ||
81 | struct sur40_header header; | ||
82 | struct sur40_blob blobs[]; | ||
83 | } __packed; | ||
84 | |||
85 | |||
86 | /* version information */ | ||
87 | #define DRIVER_SHORT "sur40" | ||
88 | #define DRIVER_AUTHOR "Florian 'floe' Echtler <floe@butterbrot.org>" | ||
89 | #define DRIVER_DESC "Surface2.0/SUR40/PixelSense input driver" | ||
90 | |||
91 | /* vendor and device IDs */ | ||
92 | #define ID_MICROSOFT 0x045e | ||
93 | #define ID_SUR40 0x0775 | ||
94 | |||
95 | /* sensor resolution */ | ||
96 | #define SENSOR_RES_X 1920 | ||
97 | #define SENSOR_RES_Y 1080 | ||
98 | |||
99 | /* touch data endpoint */ | ||
100 | #define TOUCH_ENDPOINT 0x86 | ||
101 | |||
102 | /* polling interval (ms) */ | ||
103 | #define POLL_INTERVAL 10 | ||
104 | |||
105 | /* maximum number of contacts FIXME: this is a guess? */ | ||
106 | #define MAX_CONTACTS 64 | ||
107 | |||
108 | /* control commands */ | ||
109 | #define SUR40_GET_VERSION 0xb0 /* 12 bytes string */ | ||
110 | #define SUR40_UNKNOWN1 0xb3 /* 5 bytes */ | ||
111 | #define SUR40_UNKNOWN2 0xc1 /* 24 bytes */ | ||
112 | |||
113 | #define SUR40_GET_STATE 0xc5 /* 4 bytes state (?) */ | ||
114 | #define SUR40_GET_SENSORS 0xb1 /* 8 bytes sensors */ | ||
115 | |||
116 | /* | ||
117 | * Note: an earlier, non-public version of this driver used USB_RECIP_ENDPOINT | ||
118 | * here by mistake which is very likely to have corrupted the firmware EEPROM | ||
119 | * on two separate SUR40 devices. Thanks to Alan Stern who spotted this bug. | ||
120 | * Should you ever run into a similar problem, the background story to this | ||
121 | * incident and instructions on how to fix the corrupted EEPROM are available | ||
122 | * at https://floe.butterbrot.org/matrix/hacking/surface/brick.html | ||
123 | */ | ||
124 | |||
125 | struct sur40_state { | ||
126 | |||
127 | struct usb_device *usbdev; | ||
128 | struct device *dev; | ||
129 | struct input_polled_dev *input; | ||
130 | |||
131 | struct sur40_data *bulk_in_buffer; | ||
132 | size_t bulk_in_size; | ||
133 | u8 bulk_in_epaddr; | ||
134 | |||
135 | char phys[64]; | ||
136 | }; | ||
137 | |||
138 | static int sur40_command(struct sur40_state *dev, | ||
139 | u8 command, u16 index, void *buffer, u16 size) | ||
140 | { | ||
141 | return usb_control_msg(dev->usbdev, usb_rcvctrlpipe(dev->usbdev, 0), | ||
142 | command, | ||
143 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, | ||
144 | 0x00, index, buffer, size, 1000); | ||
145 | } | ||
146 | |||
147 | /* Initialization routine, called from sur40_open */ | ||
148 | static int sur40_init(struct sur40_state *dev) | ||
149 | { | ||
150 | int result; | ||
151 | u8 buffer[24]; | ||
152 | |||
153 | /* stupidly replay the original MS driver init sequence */ | ||
154 | result = sur40_command(dev, SUR40_GET_VERSION, 0x00, buffer, 12); | ||
155 | if (result < 0) | ||
156 | return result; | ||
157 | |||
158 | result = sur40_command(dev, SUR40_GET_VERSION, 0x01, buffer, 12); | ||
159 | if (result < 0) | ||
160 | return result; | ||
161 | |||
162 | result = sur40_command(dev, SUR40_GET_VERSION, 0x02, buffer, 12); | ||
163 | if (result < 0) | ||
164 | return result; | ||
165 | |||
166 | result = sur40_command(dev, SUR40_UNKNOWN2, 0x00, buffer, 24); | ||
167 | if (result < 0) | ||
168 | return result; | ||
169 | |||
170 | result = sur40_command(dev, SUR40_UNKNOWN1, 0x00, buffer, 5); | ||
171 | if (result < 0) | ||
172 | return result; | ||
173 | |||
174 | result = sur40_command(dev, SUR40_GET_VERSION, 0x03, buffer, 12); | ||
175 | |||
176 | /* | ||
177 | * Discard the result buffer - no known data inside except | ||
178 | * some version strings, maybe extract these sometime... | ||
179 | */ | ||
180 | |||
181 | return result; | ||
182 | } | ||
183 | |||
184 | /* | ||
185 | * Callback routines from input_polled_dev | ||
186 | */ | ||
187 | |||
188 | /* Enable the device, polling will now start. */ | ||
189 | static void sur40_open(struct input_polled_dev *polldev) | ||
190 | { | ||
191 | struct sur40_state *sur40 = polldev->private; | ||
192 | |||
193 | dev_dbg(sur40->dev, "open\n"); | ||
194 | sur40_init(sur40); | ||
195 | } | ||
196 | |||
197 | /* Disable device, polling has stopped. */ | ||
198 | static void sur40_close(struct input_polled_dev *polldev) | ||
199 | { | ||
200 | struct sur40_state *sur40 = polldev->private; | ||
201 | |||
202 | dev_dbg(sur40->dev, "close\n"); | ||
203 | /* | ||
204 | * There is no known way to stop the device, so we simply | ||
205 | * stop polling. | ||
206 | */ | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * This function is called when a whole contact has been processed, | ||
211 | * so that it can assign it to a slot and store the data there. | ||
212 | */ | ||
213 | static void sur40_report_blob(struct sur40_blob *blob, struct input_dev *input) | ||
214 | { | ||
215 | int wide, major, minor; | ||
216 | |||
217 | int bb_size_x = le16_to_cpu(blob->bb_size_x); | ||
218 | int bb_size_y = le16_to_cpu(blob->bb_size_y); | ||
219 | |||
220 | int pos_x = le16_to_cpu(blob->pos_x); | ||
221 | int pos_y = le16_to_cpu(blob->pos_y); | ||
222 | |||
223 | int ctr_x = le16_to_cpu(blob->ctr_x); | ||
224 | int ctr_y = le16_to_cpu(blob->ctr_y); | ||
225 | |||
226 | int slotnum = input_mt_get_slot_by_key(input, blob->blob_id); | ||
227 | if (slotnum < 0 || slotnum >= MAX_CONTACTS) | ||
228 | return; | ||
229 | |||
230 | input_mt_slot(input, slotnum); | ||
231 | input_mt_report_slot_state(input, MT_TOOL_FINGER, 1); | ||
232 | wide = (bb_size_x > bb_size_y); | ||
233 | major = max(bb_size_x, bb_size_y); | ||
234 | minor = min(bb_size_x, bb_size_y); | ||
235 | |||
236 | input_report_abs(input, ABS_MT_POSITION_X, pos_x); | ||
237 | input_report_abs(input, ABS_MT_POSITION_Y, pos_y); | ||
238 | input_report_abs(input, ABS_MT_TOOL_X, ctr_x); | ||
239 | input_report_abs(input, ABS_MT_TOOL_Y, ctr_y); | ||
240 | |||
241 | /* TODO: use a better orientation measure */ | ||
242 | input_report_abs(input, ABS_MT_ORIENTATION, wide); | ||
243 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, major); | ||
244 | input_report_abs(input, ABS_MT_TOUCH_MINOR, minor); | ||
245 | } | ||
246 | |||
247 | /* core function: poll for new input data */ | ||
248 | static void sur40_poll(struct input_polled_dev *polldev) | ||
249 | { | ||
250 | |||
251 | struct sur40_state *sur40 = polldev->private; | ||
252 | struct input_dev *input = polldev->input; | ||
253 | int result, bulk_read, need_blobs, packet_blobs, i; | ||
254 | u32 packet_id; | ||
255 | |||
256 | struct sur40_header *header = &sur40->bulk_in_buffer->header; | ||
257 | struct sur40_blob *inblob = &sur40->bulk_in_buffer->blobs[0]; | ||
258 | |||
259 | dev_dbg(sur40->dev, "poll\n"); | ||
260 | |||
261 | need_blobs = -1; | ||
262 | |||
263 | do { | ||
264 | |||
265 | /* perform a blocking bulk read to get data from the device */ | ||
266 | result = usb_bulk_msg(sur40->usbdev, | ||
267 | usb_rcvbulkpipe(sur40->usbdev, sur40->bulk_in_epaddr), | ||
268 | sur40->bulk_in_buffer, sur40->bulk_in_size, | ||
269 | &bulk_read, 1000); | ||
270 | |||
271 | dev_dbg(sur40->dev, "received %d bytes\n", bulk_read); | ||
272 | |||
273 | if (result < 0) { | ||
274 | dev_err(sur40->dev, "error in usb_bulk_read\n"); | ||
275 | return; | ||
276 | } | ||
277 | |||
278 | result = bulk_read - sizeof(struct sur40_header); | ||
279 | |||
280 | if (result % sizeof(struct sur40_blob) != 0) { | ||
281 | dev_err(sur40->dev, "transfer size mismatch\n"); | ||
282 | return; | ||
283 | } | ||
284 | |||
285 | /* first packet? */ | ||
286 | if (need_blobs == -1) { | ||
287 | need_blobs = le16_to_cpu(header->count); | ||
288 | dev_dbg(sur40->dev, "need %d blobs\n", need_blobs); | ||
289 | packet_id = header->packet_id; | ||
290 | } | ||
291 | |||
292 | /* | ||
293 | * Sanity check. when video data is also being retrieved, the | ||
294 | * packet ID will usually increase in the middle of a series | ||
295 | * instead of at the end. | ||
296 | */ | ||
297 | if (packet_id != header->packet_id) | ||
298 | dev_warn(sur40->dev, "packet ID mismatch\n"); | ||
299 | |||
300 | packet_blobs = result / sizeof(struct sur40_blob); | ||
301 | dev_dbg(sur40->dev, "received %d blobs\n", packet_blobs); | ||
302 | |||
303 | /* packets always contain at least 4 blobs, even if empty */ | ||
304 | if (packet_blobs > need_blobs) | ||
305 | packet_blobs = need_blobs; | ||
306 | |||
307 | for (i = 0; i < packet_blobs; i++) { | ||
308 | need_blobs--; | ||
309 | dev_dbg(sur40->dev, "processing blob\n"); | ||
310 | sur40_report_blob(&(inblob[i]), input); | ||
311 | } | ||
312 | |||
313 | } while (need_blobs > 0); | ||
314 | |||
315 | input_mt_sync_frame(input); | ||
316 | input_sync(input); | ||
317 | } | ||
318 | |||
319 | /* Initialize input device parameters. */ | ||
320 | static void sur40_input_setup(struct input_dev *input_dev) | ||
321 | { | ||
322 | __set_bit(EV_KEY, input_dev->evbit); | ||
323 | __set_bit(EV_ABS, input_dev->evbit); | ||
324 | |||
325 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | ||
326 | 0, SENSOR_RES_X, 0, 0); | ||
327 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, | ||
328 | 0, SENSOR_RES_Y, 0, 0); | ||
329 | |||
330 | input_set_abs_params(input_dev, ABS_MT_TOOL_X, | ||
331 | 0, SENSOR_RES_X, 0, 0); | ||
332 | input_set_abs_params(input_dev, ABS_MT_TOOL_Y, | ||
333 | 0, SENSOR_RES_Y, 0, 0); | ||
334 | |||
335 | /* max value unknown, but major/minor axis | ||
336 | * can never be larger than screen */ | ||
337 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | ||
338 | 0, SENSOR_RES_X, 0, 0); | ||
339 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, | ||
340 | 0, SENSOR_RES_Y, 0, 0); | ||
341 | |||
342 | input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); | ||
343 | |||
344 | input_mt_init_slots(input_dev, MAX_CONTACTS, | ||
345 | INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); | ||
346 | } | ||
347 | |||
348 | /* Check candidate USB interface. */ | ||
349 | static int sur40_probe(struct usb_interface *interface, | ||
350 | const struct usb_device_id *id) | ||
351 | { | ||
352 | struct usb_device *usbdev = interface_to_usbdev(interface); | ||
353 | struct sur40_state *sur40; | ||
354 | struct usb_host_interface *iface_desc; | ||
355 | struct usb_endpoint_descriptor *endpoint; | ||
356 | struct input_polled_dev *poll_dev; | ||
357 | int error; | ||
358 | |||
359 | /* Check if we really have the right interface. */ | ||
360 | iface_desc = &interface->altsetting[0]; | ||
361 | if (iface_desc->desc.bInterfaceClass != 0xFF) | ||
362 | return -ENODEV; | ||
363 | |||
364 | /* Use endpoint #4 (0x86). */ | ||
365 | endpoint = &iface_desc->endpoint[4].desc; | ||
366 | if (endpoint->bEndpointAddress != TOUCH_ENDPOINT) | ||
367 | return -ENODEV; | ||
368 | |||
369 | /* Allocate memory for our device state and initialize it. */ | ||
370 | sur40 = kzalloc(sizeof(struct sur40_state), GFP_KERNEL); | ||
371 | if (!sur40) | ||
372 | return -ENOMEM; | ||
373 | |||
374 | poll_dev = input_allocate_polled_device(); | ||
375 | if (!poll_dev) { | ||
376 | error = -ENOMEM; | ||
377 | goto err_free_dev; | ||
378 | } | ||
379 | |||
380 | /* Set up polled input device control structure */ | ||
381 | poll_dev->private = sur40; | ||
382 | poll_dev->poll_interval = POLL_INTERVAL; | ||
383 | poll_dev->open = sur40_open; | ||
384 | poll_dev->poll = sur40_poll; | ||
385 | poll_dev->close = sur40_close; | ||
386 | |||
387 | /* Set up regular input device structure */ | ||
388 | sur40_input_setup(poll_dev->input); | ||
389 | |||
390 | poll_dev->input->name = "Samsung SUR40"; | ||
391 | usb_to_input_id(usbdev, &poll_dev->input->id); | ||
392 | usb_make_path(usbdev, sur40->phys, sizeof(sur40->phys)); | ||
393 | strlcat(sur40->phys, "/input0", sizeof(sur40->phys)); | ||
394 | poll_dev->input->phys = sur40->phys; | ||
395 | poll_dev->input->dev.parent = &interface->dev; | ||
396 | |||
397 | sur40->usbdev = usbdev; | ||
398 | sur40->dev = &interface->dev; | ||
399 | sur40->input = poll_dev; | ||
400 | |||
401 | /* use the bulk-in endpoint tested above */ | ||
402 | sur40->bulk_in_size = usb_endpoint_maxp(endpoint); | ||
403 | sur40->bulk_in_epaddr = endpoint->bEndpointAddress; | ||
404 | sur40->bulk_in_buffer = kmalloc(sur40->bulk_in_size, GFP_KERNEL); | ||
405 | if (!sur40->bulk_in_buffer) { | ||
406 | dev_err(&interface->dev, "Unable to allocate input buffer."); | ||
407 | error = -ENOMEM; | ||
408 | goto err_free_polldev; | ||
409 | } | ||
410 | |||
411 | error = input_register_polled_device(poll_dev); | ||
412 | if (error) { | ||
413 | dev_err(&interface->dev, | ||
414 | "Unable to register polled input device."); | ||
415 | goto err_free_buffer; | ||
416 | } | ||
417 | |||
418 | /* we can register the device now, as it is ready */ | ||
419 | usb_set_intfdata(interface, sur40); | ||
420 | dev_dbg(&interface->dev, "%s is now attached\n", DRIVER_DESC); | ||
421 | |||
422 | return 0; | ||
423 | |||
424 | err_free_buffer: | ||
425 | kfree(sur40->bulk_in_buffer); | ||
426 | err_free_polldev: | ||
427 | input_free_polled_device(sur40->input); | ||
428 | err_free_dev: | ||
429 | kfree(sur40); | ||
430 | |||
431 | return error; | ||
432 | } | ||
433 | |||
434 | /* Unregister device & clean up. */ | ||
435 | static void sur40_disconnect(struct usb_interface *interface) | ||
436 | { | ||
437 | struct sur40_state *sur40 = usb_get_intfdata(interface); | ||
438 | |||
439 | input_unregister_polled_device(sur40->input); | ||
440 | input_free_polled_device(sur40->input); | ||
441 | kfree(sur40->bulk_in_buffer); | ||
442 | kfree(sur40); | ||
443 | |||
444 | usb_set_intfdata(interface, NULL); | ||
445 | dev_dbg(&interface->dev, "%s is now disconnected\n", DRIVER_DESC); | ||
446 | } | ||
447 | |||
448 | static const struct usb_device_id sur40_table[] = { | ||
449 | { USB_DEVICE(ID_MICROSOFT, ID_SUR40) }, /* Samsung SUR40 */ | ||
450 | { } /* terminating null entry */ | ||
451 | }; | ||
452 | MODULE_DEVICE_TABLE(usb, sur40_table); | ||
453 | |||
454 | /* USB-specific object needed to register this driver with the USB subsystem. */ | ||
455 | static struct usb_driver sur40_driver = { | ||
456 | .name = DRIVER_SHORT, | ||
457 | .probe = sur40_probe, | ||
458 | .disconnect = sur40_disconnect, | ||
459 | .id_table = sur40_table, | ||
460 | }; | ||
461 | |||
462 | module_usb_driver(sur40_driver); | ||
463 | |||
464 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
465 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
466 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 9031171c141b..341c6016812d 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c | |||
@@ -957,12 +957,13 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start, | |||
957 | if (WARN_ON(!gic->domain)) | 957 | if (WARN_ON(!gic->domain)) |
958 | return; | 958 | return; |
959 | 959 | ||
960 | if (gic_nr == 0) { | ||
960 | #ifdef CONFIG_SMP | 961 | #ifdef CONFIG_SMP |
961 | set_smp_cross_call(gic_raise_softirq); | 962 | set_smp_cross_call(gic_raise_softirq); |
962 | register_cpu_notifier(&gic_cpu_notifier); | 963 | register_cpu_notifier(&gic_cpu_notifier); |
963 | #endif | 964 | #endif |
964 | 965 | set_handle_irq(gic_handle_irq); | |
965 | set_handle_irq(gic_handle_irq); | 966 | } |
966 | 967 | ||
967 | gic_chip.flags |= gic_arch_extn.flags; | 968 | gic_chip.flags |= gic_arch_extn.flags; |
968 | gic_dist_init(gic); | 969 | gic_dist_init(gic); |
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index 2848171b8576..b31d8e99c419 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c | |||
@@ -82,22 +82,12 @@ static inline size_t sizeof_pwm_leds_priv(int num_leds) | |||
82 | (sizeof(struct led_pwm_data) * num_leds); | 82 | (sizeof(struct led_pwm_data) * num_leds); |
83 | } | 83 | } |
84 | 84 | ||
85 | static struct led_pwm_priv *led_pwm_create_of(struct platform_device *pdev) | 85 | static int led_pwm_create_of(struct platform_device *pdev, |
86 | struct led_pwm_priv *priv) | ||
86 | { | 87 | { |
87 | struct device_node *node = pdev->dev.of_node; | 88 | struct device_node *node = pdev->dev.of_node; |
88 | struct device_node *child; | 89 | struct device_node *child; |
89 | struct led_pwm_priv *priv; | 90 | int ret; |
90 | int count, ret; | ||
91 | |||
92 | /* count LEDs in this device, so we know how much to allocate */ | ||
93 | count = of_get_child_count(node); | ||
94 | if (!count) | ||
95 | return NULL; | ||
96 | |||
97 | priv = devm_kzalloc(&pdev->dev, sizeof_pwm_leds_priv(count), | ||
98 | GFP_KERNEL); | ||
99 | if (!priv) | ||
100 | return NULL; | ||
101 | 91 | ||
102 | for_each_child_of_node(node, child) { | 92 | for_each_child_of_node(node, child) { |
103 | struct led_pwm_data *led_dat = &priv->leds[priv->num_leds]; | 93 | struct led_pwm_data *led_dat = &priv->leds[priv->num_leds]; |
@@ -109,6 +99,7 @@ static struct led_pwm_priv *led_pwm_create_of(struct platform_device *pdev) | |||
109 | if (IS_ERR(led_dat->pwm)) { | 99 | if (IS_ERR(led_dat->pwm)) { |
110 | dev_err(&pdev->dev, "unable to request PWM for %s\n", | 100 | dev_err(&pdev->dev, "unable to request PWM for %s\n", |
111 | led_dat->cdev.name); | 101 | led_dat->cdev.name); |
102 | ret = PTR_ERR(led_dat->pwm); | ||
112 | goto err; | 103 | goto err; |
113 | } | 104 | } |
114 | /* Get the period from PWM core when n*/ | 105 | /* Get the period from PWM core when n*/ |
@@ -137,28 +128,36 @@ static struct led_pwm_priv *led_pwm_create_of(struct platform_device *pdev) | |||
137 | priv->num_leds++; | 128 | priv->num_leds++; |
138 | } | 129 | } |
139 | 130 | ||
140 | return priv; | 131 | return 0; |
141 | err: | 132 | err: |
142 | while (priv->num_leds--) | 133 | while (priv->num_leds--) |
143 | led_classdev_unregister(&priv->leds[priv->num_leds].cdev); | 134 | led_classdev_unregister(&priv->leds[priv->num_leds].cdev); |
144 | 135 | ||
145 | return NULL; | 136 | return ret; |
146 | } | 137 | } |
147 | 138 | ||
148 | static int led_pwm_probe(struct platform_device *pdev) | 139 | static int led_pwm_probe(struct platform_device *pdev) |
149 | { | 140 | { |
150 | struct led_pwm_platform_data *pdata = dev_get_platdata(&pdev->dev); | 141 | struct led_pwm_platform_data *pdata = dev_get_platdata(&pdev->dev); |
151 | struct led_pwm_priv *priv; | 142 | struct led_pwm_priv *priv; |
152 | int i, ret = 0; | 143 | int count, i; |
144 | int ret = 0; | ||
145 | |||
146 | if (pdata) | ||
147 | count = pdata->num_leds; | ||
148 | else | ||
149 | count = of_get_child_count(pdev->dev.of_node); | ||
150 | |||
151 | if (!count) | ||
152 | return -EINVAL; | ||
153 | 153 | ||
154 | if (pdata && pdata->num_leds) { | 154 | priv = devm_kzalloc(&pdev->dev, sizeof_pwm_leds_priv(count), |
155 | priv = devm_kzalloc(&pdev->dev, | 155 | GFP_KERNEL); |
156 | sizeof_pwm_leds_priv(pdata->num_leds), | 156 | if (!priv) |
157 | GFP_KERNEL); | 157 | return -ENOMEM; |
158 | if (!priv) | ||
159 | return -ENOMEM; | ||
160 | 158 | ||
161 | for (i = 0; i < pdata->num_leds; i++) { | 159 | if (pdata) { |
160 | for (i = 0; i < count; i++) { | ||
162 | struct led_pwm *cur_led = &pdata->leds[i]; | 161 | struct led_pwm *cur_led = &pdata->leds[i]; |
163 | struct led_pwm_data *led_dat = &priv->leds[i]; | 162 | struct led_pwm_data *led_dat = &priv->leds[i]; |
164 | 163 | ||
@@ -188,11 +187,11 @@ static int led_pwm_probe(struct platform_device *pdev) | |||
188 | if (ret < 0) | 187 | if (ret < 0) |
189 | goto err; | 188 | goto err; |
190 | } | 189 | } |
191 | priv->num_leds = pdata->num_leds; | 190 | priv->num_leds = count; |
192 | } else { | 191 | } else { |
193 | priv = led_pwm_create_of(pdev); | 192 | ret = led_pwm_create_of(pdev, priv); |
194 | if (!priv) | 193 | if (ret) |
195 | return -ENODEV; | 194 | return ret; |
196 | } | 195 | } |
197 | 196 | ||
198 | platform_set_drvdata(pdev, priv); | 197 | platform_set_drvdata(pdev, priv); |
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile index 6753b65f8ede..d2f0120bc878 100644 --- a/drivers/macintosh/Makefile +++ b/drivers/macintosh/Makefile | |||
@@ -40,6 +40,7 @@ obj-$(CONFIG_WINDFARM_RM31) += windfarm_fcu_controls.o \ | |||
40 | windfarm_ad7417_sensor.o \ | 40 | windfarm_ad7417_sensor.o \ |
41 | windfarm_lm75_sensor.o \ | 41 | windfarm_lm75_sensor.o \ |
42 | windfarm_lm87_sensor.o \ | 42 | windfarm_lm87_sensor.o \ |
43 | windfarm_max6690_sensor.o \ | ||
43 | windfarm_pid.o \ | 44 | windfarm_pid.o \ |
44 | windfarm_cpufreq_clamp.o \ | 45 | windfarm_cpufreq_clamp.o \ |
45 | windfarm_rm31.o | 46 | windfarm_rm31.o |
diff --git a/drivers/md/md.c b/drivers/md/md.c index b6b7a2866c9e..21f4d7ff0da2 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -776,16 +776,10 @@ void md_super_wait(struct mddev *mddev) | |||
776 | finish_wait(&mddev->sb_wait, &wq); | 776 | finish_wait(&mddev->sb_wait, &wq); |
777 | } | 777 | } |
778 | 778 | ||
779 | static void bi_complete(struct bio *bio, int error) | ||
780 | { | ||
781 | complete((struct completion*)bio->bi_private); | ||
782 | } | ||
783 | |||
784 | int sync_page_io(struct md_rdev *rdev, sector_t sector, int size, | 779 | int sync_page_io(struct md_rdev *rdev, sector_t sector, int size, |
785 | struct page *page, int rw, bool metadata_op) | 780 | struct page *page, int rw, bool metadata_op) |
786 | { | 781 | { |
787 | struct bio *bio = bio_alloc_mddev(GFP_NOIO, 1, rdev->mddev); | 782 | struct bio *bio = bio_alloc_mddev(GFP_NOIO, 1, rdev->mddev); |
788 | struct completion event; | ||
789 | int ret; | 783 | int ret; |
790 | 784 | ||
791 | rw |= REQ_SYNC; | 785 | rw |= REQ_SYNC; |
@@ -801,11 +795,7 @@ int sync_page_io(struct md_rdev *rdev, sector_t sector, int size, | |||
801 | else | 795 | else |
802 | bio->bi_sector = sector + rdev->data_offset; | 796 | bio->bi_sector = sector + rdev->data_offset; |
803 | bio_add_page(bio, page, size, 0); | 797 | bio_add_page(bio, page, size, 0); |
804 | init_completion(&event); | 798 | submit_bio_wait(rw, bio); |
805 | bio->bi_private = &event; | ||
806 | bio->bi_end_io = bi_complete; | ||
807 | submit_bio(rw, bio); | ||
808 | wait_for_completion(&event); | ||
809 | 799 | ||
810 | ret = test_bit(BIO_UPTODATE, &bio->bi_flags); | 800 | ret = test_bit(BIO_UPTODATE, &bio->bi_flags); |
811 | bio_put(bio); | 801 | bio_put(bio); |
@@ -7777,7 +7767,7 @@ void md_check_recovery(struct mddev *mddev) | |||
7777 | if (mddev->ro && !test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) | 7767 | if (mddev->ro && !test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) |
7778 | return; | 7768 | return; |
7779 | if ( ! ( | 7769 | if ( ! ( |
7780 | (mddev->flags & ~ (1<<MD_CHANGE_PENDING)) || | 7770 | (mddev->flags & MD_UPDATE_SB_FLAGS & ~ (1<<MD_CHANGE_PENDING)) || |
7781 | test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) || | 7771 | test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) || |
7782 | test_bit(MD_RECOVERY_DONE, &mddev->recovery) || | 7772 | test_bit(MD_RECOVERY_DONE, &mddev->recovery) || |
7783 | (mddev->external == 0 && mddev->safemode == 1) || | 7773 | (mddev->external == 0 && mddev->safemode == 1) || |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 47da0af6322b..cc055da02e2a 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -678,26 +678,23 @@ get_active_stripe(struct r5conf *conf, sector_t sector, | |||
678 | } else | 678 | } else |
679 | init_stripe(sh, sector, previous); | 679 | init_stripe(sh, sector, previous); |
680 | } else { | 680 | } else { |
681 | spin_lock(&conf->device_lock); | ||
681 | if (atomic_read(&sh->count)) { | 682 | if (atomic_read(&sh->count)) { |
682 | BUG_ON(!list_empty(&sh->lru) | 683 | BUG_ON(!list_empty(&sh->lru) |
683 | && !test_bit(STRIPE_EXPANDING, &sh->state) | 684 | && !test_bit(STRIPE_EXPANDING, &sh->state) |
684 | && !test_bit(STRIPE_ON_UNPLUG_LIST, &sh->state) | 685 | && !test_bit(STRIPE_ON_UNPLUG_LIST, &sh->state) |
685 | && !test_bit(STRIPE_ON_RELEASE_LIST, &sh->state)); | 686 | ); |
686 | } else { | 687 | } else { |
687 | spin_lock(&conf->device_lock); | ||
688 | if (!test_bit(STRIPE_HANDLE, &sh->state)) | 688 | if (!test_bit(STRIPE_HANDLE, &sh->state)) |
689 | atomic_inc(&conf->active_stripes); | 689 | atomic_inc(&conf->active_stripes); |
690 | if (list_empty(&sh->lru) && | 690 | BUG_ON(list_empty(&sh->lru)); |
691 | !test_bit(STRIPE_ON_RELEASE_LIST, &sh->state) && | ||
692 | !test_bit(STRIPE_EXPANDING, &sh->state)) | ||
693 | BUG(); | ||
694 | list_del_init(&sh->lru); | 691 | list_del_init(&sh->lru); |
695 | if (sh->group) { | 692 | if (sh->group) { |
696 | sh->group->stripes_cnt--; | 693 | sh->group->stripes_cnt--; |
697 | sh->group = NULL; | 694 | sh->group = NULL; |
698 | } | 695 | } |
699 | spin_unlock(&conf->device_lock); | ||
700 | } | 696 | } |
697 | spin_unlock(&conf->device_lock); | ||
701 | } | 698 | } |
702 | } while (sh == NULL); | 699 | } while (sh == NULL); |
703 | 700 | ||
@@ -5471,7 +5468,7 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt, | |||
5471 | for (i = 0; i < *group_cnt; i++) { | 5468 | for (i = 0; i < *group_cnt; i++) { |
5472 | struct r5worker_group *group; | 5469 | struct r5worker_group *group; |
5473 | 5470 | ||
5474 | group = worker_groups[i]; | 5471 | group = &(*worker_groups)[i]; |
5475 | INIT_LIST_HEAD(&group->handle_list); | 5472 | INIT_LIST_HEAD(&group->handle_list); |
5476 | group->conf = conf; | 5473 | group->conf = conf; |
5477 | group->workers = workers + i * cnt; | 5474 | group->workers = workers + i * cnt; |
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 0e8df41aaf14..2cf2bbc0b927 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c | |||
@@ -198,6 +198,13 @@ static void enclosure_remove_links(struct enclosure_component *cdev) | |||
198 | { | 198 | { |
199 | char name[ENCLOSURE_NAME_SIZE]; | 199 | char name[ENCLOSURE_NAME_SIZE]; |
200 | 200 | ||
201 | /* | ||
202 | * In odd circumstances, like multipath devices, something else may | ||
203 | * already have removed the links, so check for this condition first. | ||
204 | */ | ||
205 | if (!cdev->dev->kobj.sd) | ||
206 | return; | ||
207 | |||
201 | enclosure_link_name(cdev, name); | 208 | enclosure_link_name(cdev, name); |
202 | sysfs_remove_link(&cdev->dev->kobj, name); | 209 | sysfs_remove_link(&cdev->dev->kobj, name); |
203 | sysfs_remove_link(&cdev->cdev.kobj, "device"); | 210 | sysfs_remove_link(&cdev->cdev.kobj, "device"); |
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 0b10a9030f4e..98b6b6ef7e5c 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
24 | #include <linux/timer.h> | 24 | #include <linux/timer.h> |
25 | #include <linux/of.h> | ||
25 | #include <linux/omap-dma.h> | 26 | #include <linux/omap-dma.h> |
26 | #include <linux/mmc/host.h> | 27 | #include <linux/mmc/host.h> |
27 | #include <linux/mmc/card.h> | 28 | #include <linux/mmc/card.h> |
@@ -90,17 +91,6 @@ | |||
90 | #define OMAP_MMC_CMDTYPE_AC 2 | 91 | #define OMAP_MMC_CMDTYPE_AC 2 |
91 | #define OMAP_MMC_CMDTYPE_ADTC 3 | 92 | #define OMAP_MMC_CMDTYPE_ADTC 3 |
92 | 93 | ||
93 | #define OMAP_DMA_MMC_TX 21 | ||
94 | #define OMAP_DMA_MMC_RX 22 | ||
95 | #define OMAP_DMA_MMC2_TX 54 | ||
96 | #define OMAP_DMA_MMC2_RX 55 | ||
97 | |||
98 | #define OMAP24XX_DMA_MMC2_TX 47 | ||
99 | #define OMAP24XX_DMA_MMC2_RX 48 | ||
100 | #define OMAP24XX_DMA_MMC1_TX 61 | ||
101 | #define OMAP24XX_DMA_MMC1_RX 62 | ||
102 | |||
103 | |||
104 | #define DRIVER_NAME "mmci-omap" | 94 | #define DRIVER_NAME "mmci-omap" |
105 | 95 | ||
106 | /* Specifies how often in millisecs to poll for card status changes | 96 | /* Specifies how often in millisecs to poll for card status changes |
@@ -1330,7 +1320,7 @@ static int mmc_omap_probe(struct platform_device *pdev) | |||
1330 | struct mmc_omap_host *host = NULL; | 1320 | struct mmc_omap_host *host = NULL; |
1331 | struct resource *res; | 1321 | struct resource *res; |
1332 | dma_cap_mask_t mask; | 1322 | dma_cap_mask_t mask; |
1333 | unsigned sig; | 1323 | unsigned sig = 0; |
1334 | int i, ret = 0; | 1324 | int i, ret = 0; |
1335 | int irq; | 1325 | int irq; |
1336 | 1326 | ||
@@ -1340,7 +1330,7 @@ static int mmc_omap_probe(struct platform_device *pdev) | |||
1340 | } | 1330 | } |
1341 | if (pdata->nr_slots == 0) { | 1331 | if (pdata->nr_slots == 0) { |
1342 | dev_err(&pdev->dev, "no slots\n"); | 1332 | dev_err(&pdev->dev, "no slots\n"); |
1343 | return -ENXIO; | 1333 | return -EPROBE_DEFER; |
1344 | } | 1334 | } |
1345 | 1335 | ||
1346 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1336 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -1407,19 +1397,20 @@ static int mmc_omap_probe(struct platform_device *pdev) | |||
1407 | host->dma_tx_burst = -1; | 1397 | host->dma_tx_burst = -1; |
1408 | host->dma_rx_burst = -1; | 1398 | host->dma_rx_burst = -1; |
1409 | 1399 | ||
1410 | if (mmc_omap2()) | 1400 | res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); |
1411 | sig = host->id == 0 ? OMAP24XX_DMA_MMC1_TX : OMAP24XX_DMA_MMC2_TX; | 1401 | if (res) |
1412 | else | 1402 | sig = res->start; |
1413 | sig = host->id == 0 ? OMAP_DMA_MMC_TX : OMAP_DMA_MMC2_TX; | 1403 | host->dma_tx = dma_request_slave_channel_compat(mask, |
1414 | host->dma_tx = dma_request_channel(mask, omap_dma_filter_fn, &sig); | 1404 | omap_dma_filter_fn, &sig, &pdev->dev, "tx"); |
1415 | if (!host->dma_tx) | 1405 | if (!host->dma_tx) |
1416 | dev_warn(host->dev, "unable to obtain TX DMA engine channel %u\n", | 1406 | dev_warn(host->dev, "unable to obtain TX DMA engine channel %u\n", |
1417 | sig); | 1407 | sig); |
1418 | if (mmc_omap2()) | 1408 | |
1419 | sig = host->id == 0 ? OMAP24XX_DMA_MMC1_RX : OMAP24XX_DMA_MMC2_RX; | 1409 | res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); |
1420 | else | 1410 | if (res) |
1421 | sig = host->id == 0 ? OMAP_DMA_MMC_RX : OMAP_DMA_MMC2_RX; | 1411 | sig = res->start; |
1422 | host->dma_rx = dma_request_channel(mask, omap_dma_filter_fn, &sig); | 1412 | host->dma_rx = dma_request_slave_channel_compat(mask, |
1413 | omap_dma_filter_fn, &sig, &pdev->dev, "rx"); | ||
1423 | if (!host->dma_rx) | 1414 | if (!host->dma_rx) |
1424 | dev_warn(host->dev, "unable to obtain RX DMA engine channel %u\n", | 1415 | dev_warn(host->dev, "unable to obtain RX DMA engine channel %u\n", |
1425 | sig); | 1416 | sig); |
@@ -1512,12 +1503,20 @@ static int mmc_omap_remove(struct platform_device *pdev) | |||
1512 | return 0; | 1503 | return 0; |
1513 | } | 1504 | } |
1514 | 1505 | ||
1506 | #if IS_BUILTIN(CONFIG_OF) | ||
1507 | static const struct of_device_id mmc_omap_match[] = { | ||
1508 | { .compatible = "ti,omap2420-mmc", }, | ||
1509 | { }, | ||
1510 | }; | ||
1511 | #endif | ||
1512 | |||
1515 | static struct platform_driver mmc_omap_driver = { | 1513 | static struct platform_driver mmc_omap_driver = { |
1516 | .probe = mmc_omap_probe, | 1514 | .probe = mmc_omap_probe, |
1517 | .remove = mmc_omap_remove, | 1515 | .remove = mmc_omap_remove, |
1518 | .driver = { | 1516 | .driver = { |
1519 | .name = DRIVER_NAME, | 1517 | .name = DRIVER_NAME, |
1520 | .owner = THIS_MODULE, | 1518 | .owner = THIS_MODULE, |
1519 | .of_match_table = of_match_ptr(mmc_omap_match), | ||
1521 | }, | 1520 | }, |
1522 | }; | 1521 | }; |
1523 | 1522 | ||
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 4dd5ee2a34cc..36eab0c4fb33 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4110,7 +4110,7 @@ static int bond_check_params(struct bond_params *params) | |||
4110 | if (!miimon) { | 4110 | if (!miimon) { |
4111 | pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed and duplex which are essential for 802.3ad operation\n"); | 4111 | pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed and duplex which are essential for 802.3ad operation\n"); |
4112 | pr_warning("Forcing miimon to 100msec\n"); | 4112 | pr_warning("Forcing miimon to 100msec\n"); |
4113 | miimon = 100; | 4113 | miimon = BOND_DEFAULT_MIIMON; |
4114 | } | 4114 | } |
4115 | } | 4115 | } |
4116 | 4116 | ||
@@ -4147,7 +4147,7 @@ static int bond_check_params(struct bond_params *params) | |||
4147 | if (!miimon) { | 4147 | if (!miimon) { |
4148 | pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure and link speed which are essential for TLB/ALB load balancing\n"); | 4148 | pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure and link speed which are essential for TLB/ALB load balancing\n"); |
4149 | pr_warning("Forcing miimon to 100msec\n"); | 4149 | pr_warning("Forcing miimon to 100msec\n"); |
4150 | miimon = 100; | 4150 | miimon = BOND_DEFAULT_MIIMON; |
4151 | } | 4151 | } |
4152 | } | 4152 | } |
4153 | 4153 | ||
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 9a5223c7b4d1..ea6f640782b7 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -45,10 +45,15 @@ int bond_option_mode_set(struct bonding *bond, int mode) | |||
45 | return -EPERM; | 45 | return -EPERM; |
46 | } | 46 | } |
47 | 47 | ||
48 | if (BOND_MODE_IS_LB(mode) && bond->params.arp_interval) { | 48 | if (BOND_NO_USES_ARP(mode) && bond->params.arp_interval) { |
49 | pr_err("%s: %s mode is incompatible with arp monitoring.\n", | 49 | pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n", |
50 | bond->dev->name, bond_mode_tbl[mode].modename); | 50 | bond->dev->name, bond_mode_tbl[mode].modename); |
51 | return -EINVAL; | 51 | /* disable arp monitoring */ |
52 | bond->params.arp_interval = 0; | ||
53 | /* set miimon to default value */ | ||
54 | bond->params.miimon = BOND_DEFAULT_MIIMON; | ||
55 | pr_info("%s: Setting MII monitoring interval to %d.\n", | ||
56 | bond->dev->name, bond->params.miimon); | ||
52 | } | 57 | } |
53 | 58 | ||
54 | /* don't cache arp_validate between modes */ | 59 | /* don't cache arp_validate between modes */ |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 0ec2a7e8c8a9..abf5e106edc5 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -523,9 +523,7 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
523 | ret = -EINVAL; | 523 | ret = -EINVAL; |
524 | goto out; | 524 | goto out; |
525 | } | 525 | } |
526 | if (bond->params.mode == BOND_MODE_ALB || | 526 | if (BOND_NO_USES_ARP(bond->params.mode)) { |
527 | bond->params.mode == BOND_MODE_TLB || | ||
528 | bond->params.mode == BOND_MODE_8023AD) { | ||
529 | pr_info("%s: ARP monitoring cannot be used with ALB/TLB/802.3ad. Only MII monitoring is supported on %s.\n", | 527 | pr_info("%s: ARP monitoring cannot be used with ALB/TLB/802.3ad. Only MII monitoring is supported on %s.\n", |
530 | bond->dev->name, bond->dev->name); | 528 | bond->dev->name, bond->dev->name); |
531 | ret = -EINVAL; | 529 | ret = -EINVAL; |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index ca31286aa028..a9f4f9f4d8ce 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -35,6 +35,8 @@ | |||
35 | 35 | ||
36 | #define BOND_MAX_ARP_TARGETS 16 | 36 | #define BOND_MAX_ARP_TARGETS 16 |
37 | 37 | ||
38 | #define BOND_DEFAULT_MIIMON 100 | ||
39 | |||
38 | #define IS_UP(dev) \ | 40 | #define IS_UP(dev) \ |
39 | ((((dev)->flags & IFF_UP) == IFF_UP) && \ | 41 | ((((dev)->flags & IFF_UP) == IFF_UP) && \ |
40 | netif_running(dev) && \ | 42 | netif_running(dev) && \ |
@@ -55,6 +57,11 @@ | |||
55 | ((mode) == BOND_MODE_TLB) || \ | 57 | ((mode) == BOND_MODE_TLB) || \ |
56 | ((mode) == BOND_MODE_ALB)) | 58 | ((mode) == BOND_MODE_ALB)) |
57 | 59 | ||
60 | #define BOND_NO_USES_ARP(mode) \ | ||
61 | (((mode) == BOND_MODE_8023AD) || \ | ||
62 | ((mode) == BOND_MODE_TLB) || \ | ||
63 | ((mode) == BOND_MODE_ALB)) | ||
64 | |||
58 | #define TX_QUEUE_OVERRIDE(mode) \ | 65 | #define TX_QUEUE_OVERRIDE(mode) \ |
59 | (((mode) == BOND_MODE_ACTIVEBACKUP) || \ | 66 | (((mode) == BOND_MODE_ACTIVEBACKUP) || \ |
60 | ((mode) == BOND_MODE_ROUNDROBIN)) | 67 | ((mode) == BOND_MODE_ROUNDROBIN)) |
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index e3fc07cf2f62..77061eebb034 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c | |||
@@ -712,22 +712,31 @@ static int c_can_set_mode(struct net_device *dev, enum can_mode mode) | |||
712 | return 0; | 712 | return 0; |
713 | } | 713 | } |
714 | 714 | ||
715 | static int c_can_get_berr_counter(const struct net_device *dev, | 715 | static int __c_can_get_berr_counter(const struct net_device *dev, |
716 | struct can_berr_counter *bec) | 716 | struct can_berr_counter *bec) |
717 | { | 717 | { |
718 | unsigned int reg_err_counter; | 718 | unsigned int reg_err_counter; |
719 | struct c_can_priv *priv = netdev_priv(dev); | 719 | struct c_can_priv *priv = netdev_priv(dev); |
720 | 720 | ||
721 | c_can_pm_runtime_get_sync(priv); | ||
722 | |||
723 | reg_err_counter = priv->read_reg(priv, C_CAN_ERR_CNT_REG); | 721 | reg_err_counter = priv->read_reg(priv, C_CAN_ERR_CNT_REG); |
724 | bec->rxerr = (reg_err_counter & ERR_CNT_REC_MASK) >> | 722 | bec->rxerr = (reg_err_counter & ERR_CNT_REC_MASK) >> |
725 | ERR_CNT_REC_SHIFT; | 723 | ERR_CNT_REC_SHIFT; |
726 | bec->txerr = reg_err_counter & ERR_CNT_TEC_MASK; | 724 | bec->txerr = reg_err_counter & ERR_CNT_TEC_MASK; |
727 | 725 | ||
726 | return 0; | ||
727 | } | ||
728 | |||
729 | static int c_can_get_berr_counter(const struct net_device *dev, | ||
730 | struct can_berr_counter *bec) | ||
731 | { | ||
732 | struct c_can_priv *priv = netdev_priv(dev); | ||
733 | int err; | ||
734 | |||
735 | c_can_pm_runtime_get_sync(priv); | ||
736 | err = __c_can_get_berr_counter(dev, bec); | ||
728 | c_can_pm_runtime_put_sync(priv); | 737 | c_can_pm_runtime_put_sync(priv); |
729 | 738 | ||
730 | return 0; | 739 | return err; |
731 | } | 740 | } |
732 | 741 | ||
733 | /* | 742 | /* |
@@ -754,6 +763,7 @@ static void c_can_do_tx(struct net_device *dev) | |||
754 | if (!(val & (1 << (msg_obj_no - 1)))) { | 763 | if (!(val & (1 << (msg_obj_no - 1)))) { |
755 | can_get_echo_skb(dev, | 764 | can_get_echo_skb(dev, |
756 | msg_obj_no - C_CAN_MSG_OBJ_TX_FIRST); | 765 | msg_obj_no - C_CAN_MSG_OBJ_TX_FIRST); |
766 | c_can_object_get(dev, 0, msg_obj_no, IF_COMM_ALL); | ||
757 | stats->tx_bytes += priv->read_reg(priv, | 767 | stats->tx_bytes += priv->read_reg(priv, |
758 | C_CAN_IFACE(MSGCTRL_REG, 0)) | 768 | C_CAN_IFACE(MSGCTRL_REG, 0)) |
759 | & IF_MCONT_DLC_MASK; | 769 | & IF_MCONT_DLC_MASK; |
@@ -872,7 +882,7 @@ static int c_can_handle_state_change(struct net_device *dev, | |||
872 | if (unlikely(!skb)) | 882 | if (unlikely(!skb)) |
873 | return 0; | 883 | return 0; |
874 | 884 | ||
875 | c_can_get_berr_counter(dev, &bec); | 885 | __c_can_get_berr_counter(dev, &bec); |
876 | reg_err_counter = priv->read_reg(priv, C_CAN_ERR_CNT_REG); | 886 | reg_err_counter = priv->read_reg(priv, C_CAN_ERR_CNT_REG); |
877 | rx_err_passive = (reg_err_counter & ERR_CNT_RP_MASK) >> | 887 | rx_err_passive = (reg_err_counter & ERR_CNT_RP_MASK) >> |
878 | ERR_CNT_RP_SHIFT; | 888 | ERR_CNT_RP_SHIFT; |
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index ae08cf129ebb..aaed97bee471 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c | |||
@@ -1020,13 +1020,13 @@ static int flexcan_probe(struct platform_device *pdev) | |||
1020 | dev_err(&pdev->dev, "no ipg clock defined\n"); | 1020 | dev_err(&pdev->dev, "no ipg clock defined\n"); |
1021 | return PTR_ERR(clk_ipg); | 1021 | return PTR_ERR(clk_ipg); |
1022 | } | 1022 | } |
1023 | clock_freq = clk_get_rate(clk_ipg); | ||
1024 | 1023 | ||
1025 | clk_per = devm_clk_get(&pdev->dev, "per"); | 1024 | clk_per = devm_clk_get(&pdev->dev, "per"); |
1026 | if (IS_ERR(clk_per)) { | 1025 | if (IS_ERR(clk_per)) { |
1027 | dev_err(&pdev->dev, "no per clock defined\n"); | 1026 | dev_err(&pdev->dev, "no per clock defined\n"); |
1028 | return PTR_ERR(clk_per); | 1027 | return PTR_ERR(clk_per); |
1029 | } | 1028 | } |
1029 | clock_freq = clk_get_rate(clk_per); | ||
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1032 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index 7164a999f50f..f17c3018b7c7 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c | |||
@@ -494,20 +494,20 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id) | |||
494 | uint8_t isrc, status; | 494 | uint8_t isrc, status; |
495 | int n = 0; | 495 | int n = 0; |
496 | 496 | ||
497 | /* Shared interrupts and IRQ off? */ | ||
498 | if (priv->read_reg(priv, SJA1000_IER) == IRQ_OFF) | ||
499 | return IRQ_NONE; | ||
500 | |||
501 | if (priv->pre_irq) | 497 | if (priv->pre_irq) |
502 | priv->pre_irq(priv); | 498 | priv->pre_irq(priv); |
503 | 499 | ||
500 | /* Shared interrupts and IRQ off? */ | ||
501 | if (priv->read_reg(priv, SJA1000_IER) == IRQ_OFF) | ||
502 | goto out; | ||
503 | |||
504 | while ((isrc = priv->read_reg(priv, SJA1000_IR)) && | 504 | while ((isrc = priv->read_reg(priv, SJA1000_IR)) && |
505 | (n < SJA1000_MAX_IRQ)) { | 505 | (n < SJA1000_MAX_IRQ)) { |
506 | n++; | 506 | |
507 | status = priv->read_reg(priv, SJA1000_SR); | 507 | status = priv->read_reg(priv, SJA1000_SR); |
508 | /* check for absent controller due to hw unplug */ | 508 | /* check for absent controller due to hw unplug */ |
509 | if (status == 0xFF && sja1000_is_absent(priv)) | 509 | if (status == 0xFF && sja1000_is_absent(priv)) |
510 | return IRQ_NONE; | 510 | goto out; |
511 | 511 | ||
512 | if (isrc & IRQ_WUI) | 512 | if (isrc & IRQ_WUI) |
513 | netdev_warn(dev, "wakeup interrupt\n"); | 513 | netdev_warn(dev, "wakeup interrupt\n"); |
@@ -535,7 +535,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id) | |||
535 | status = priv->read_reg(priv, SJA1000_SR); | 535 | status = priv->read_reg(priv, SJA1000_SR); |
536 | /* check for absent controller */ | 536 | /* check for absent controller */ |
537 | if (status == 0xFF && sja1000_is_absent(priv)) | 537 | if (status == 0xFF && sja1000_is_absent(priv)) |
538 | return IRQ_NONE; | 538 | goto out; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) { | 541 | if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) { |
@@ -543,8 +543,9 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id) | |||
543 | if (sja1000_err(dev, isrc, status)) | 543 | if (sja1000_err(dev, isrc, status)) |
544 | break; | 544 | break; |
545 | } | 545 | } |
546 | n++; | ||
546 | } | 547 | } |
547 | 548 | out: | |
548 | if (priv->post_irq) | 549 | if (priv->post_irq) |
549 | priv->post_irq(priv); | 550 | priv->post_irq(priv); |
550 | 551 | ||
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index a9e068423ba0..369b736dde05 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
@@ -10629,10 +10629,8 @@ static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir) | |||
10629 | static ssize_t tg3_show_temp(struct device *dev, | 10629 | static ssize_t tg3_show_temp(struct device *dev, |
10630 | struct device_attribute *devattr, char *buf) | 10630 | struct device_attribute *devattr, char *buf) |
10631 | { | 10631 | { |
10632 | struct pci_dev *pdev = to_pci_dev(dev); | ||
10633 | struct net_device *netdev = pci_get_drvdata(pdev); | ||
10634 | struct tg3 *tp = netdev_priv(netdev); | ||
10635 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 10632 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
10633 | struct tg3 *tp = dev_get_drvdata(dev); | ||
10636 | u32 temperature; | 10634 | u32 temperature; |
10637 | 10635 | ||
10638 | spin_lock_bh(&tp->lock); | 10636 | spin_lock_bh(&tp->lock); |
@@ -10650,29 +10648,25 @@ static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, tg3_show_temp, NULL, | |||
10650 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, tg3_show_temp, NULL, | 10648 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, tg3_show_temp, NULL, |
10651 | TG3_TEMP_MAX_OFFSET); | 10649 | TG3_TEMP_MAX_OFFSET); |
10652 | 10650 | ||
10653 | static struct attribute *tg3_attributes[] = { | 10651 | static struct attribute *tg3_attrs[] = { |
10654 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 10652 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
10655 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | 10653 | &sensor_dev_attr_temp1_crit.dev_attr.attr, |
10656 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 10654 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
10657 | NULL | 10655 | NULL |
10658 | }; | 10656 | }; |
10659 | 10657 | ATTRIBUTE_GROUPS(tg3); | |
10660 | static const struct attribute_group tg3_group = { | ||
10661 | .attrs = tg3_attributes, | ||
10662 | }; | ||
10663 | 10658 | ||
10664 | static void tg3_hwmon_close(struct tg3 *tp) | 10659 | static void tg3_hwmon_close(struct tg3 *tp) |
10665 | { | 10660 | { |
10666 | if (tp->hwmon_dev) { | 10661 | if (tp->hwmon_dev) { |
10667 | hwmon_device_unregister(tp->hwmon_dev); | 10662 | hwmon_device_unregister(tp->hwmon_dev); |
10668 | tp->hwmon_dev = NULL; | 10663 | tp->hwmon_dev = NULL; |
10669 | sysfs_remove_group(&tp->pdev->dev.kobj, &tg3_group); | ||
10670 | } | 10664 | } |
10671 | } | 10665 | } |
10672 | 10666 | ||
10673 | static void tg3_hwmon_open(struct tg3 *tp) | 10667 | static void tg3_hwmon_open(struct tg3 *tp) |
10674 | { | 10668 | { |
10675 | int i, err; | 10669 | int i; |
10676 | u32 size = 0; | 10670 | u32 size = 0; |
10677 | struct pci_dev *pdev = tp->pdev; | 10671 | struct pci_dev *pdev = tp->pdev; |
10678 | struct tg3_ocir ocirs[TG3_SD_NUM_RECS]; | 10672 | struct tg3_ocir ocirs[TG3_SD_NUM_RECS]; |
@@ -10690,18 +10684,11 @@ static void tg3_hwmon_open(struct tg3 *tp) | |||
10690 | if (!size) | 10684 | if (!size) |
10691 | return; | 10685 | return; |
10692 | 10686 | ||
10693 | /* Register hwmon sysfs hooks */ | 10687 | tp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, "tg3", |
10694 | err = sysfs_create_group(&pdev->dev.kobj, &tg3_group); | 10688 | tp, tg3_groups); |
10695 | if (err) { | ||
10696 | dev_err(&pdev->dev, "Cannot create sysfs group, aborting\n"); | ||
10697 | return; | ||
10698 | } | ||
10699 | |||
10700 | tp->hwmon_dev = hwmon_device_register(&pdev->dev); | ||
10701 | if (IS_ERR(tp->hwmon_dev)) { | 10689 | if (IS_ERR(tp->hwmon_dev)) { |
10702 | tp->hwmon_dev = NULL; | 10690 | tp->hwmon_dev = NULL; |
10703 | dev_err(&pdev->dev, "Cannot register hwmon device, aborting\n"); | 10691 | dev_err(&pdev->dev, "Cannot register hwmon device, aborting\n"); |
10704 | sysfs_remove_group(&pdev->dev.kobj, &tg3_group); | ||
10705 | } | 10692 | } |
10706 | } | 10693 | } |
10707 | 10694 | ||
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index f4825db5d179..5878df619b53 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h | |||
@@ -503,6 +503,7 @@ struct be_adapter { | |||
503 | }; | 503 | }; |
504 | 504 | ||
505 | #define be_physfn(adapter) (!adapter->virtfn) | 505 | #define be_physfn(adapter) (!adapter->virtfn) |
506 | #define be_virtfn(adapter) (adapter->virtfn) | ||
506 | #define sriov_enabled(adapter) (adapter->num_vfs > 0) | 507 | #define sriov_enabled(adapter) (adapter->num_vfs > 0) |
507 | #define sriov_want(adapter) (be_physfn(adapter) && \ | 508 | #define sriov_want(adapter) (be_physfn(adapter) && \ |
508 | (num_vfs || pci_num_vf(adapter->pdev))) | 509 | (num_vfs || pci_num_vf(adapter->pdev))) |
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index dbcd5262c016..e0e8bc1ef14c 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c | |||
@@ -1032,6 +1032,13 @@ int be_cmd_cq_create(struct be_adapter *adapter, struct be_queue_info *cq, | |||
1032 | } else { | 1032 | } else { |
1033 | req->hdr.version = 2; | 1033 | req->hdr.version = 2; |
1034 | req->page_size = 1; /* 1 for 4K */ | 1034 | req->page_size = 1; /* 1 for 4K */ |
1035 | |||
1036 | /* coalesce-wm field in this cmd is not relevant to Lancer. | ||
1037 | * Lancer uses COMMON_MODIFY_CQ to set this field | ||
1038 | */ | ||
1039 | if (!lancer_chip(adapter)) | ||
1040 | AMAP_SET_BITS(struct amap_cq_context_v2, coalescwm, | ||
1041 | ctxt, coalesce_wm); | ||
1035 | AMAP_SET_BITS(struct amap_cq_context_v2, nodelay, ctxt, | 1042 | AMAP_SET_BITS(struct amap_cq_context_v2, nodelay, ctxt, |
1036 | no_delay); | 1043 | no_delay); |
1037 | AMAP_SET_BITS(struct amap_cq_context_v2, count, ctxt, | 1044 | AMAP_SET_BITS(struct amap_cq_context_v2, count, ctxt, |
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index abde97471636..fee64bf10446 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
@@ -2658,8 +2658,8 @@ static int be_close(struct net_device *netdev) | |||
2658 | 2658 | ||
2659 | be_roce_dev_close(adapter); | 2659 | be_roce_dev_close(adapter); |
2660 | 2660 | ||
2661 | for_all_evt_queues(adapter, eqo, i) { | 2661 | if (adapter->flags & BE_FLAGS_NAPI_ENABLED) { |
2662 | if (adapter->flags & BE_FLAGS_NAPI_ENABLED) { | 2662 | for_all_evt_queues(adapter, eqo, i) { |
2663 | napi_disable(&eqo->napi); | 2663 | napi_disable(&eqo->napi); |
2664 | be_disable_busy_poll(eqo); | 2664 | be_disable_busy_poll(eqo); |
2665 | } | 2665 | } |
@@ -3253,12 +3253,10 @@ static int be_mac_setup(struct be_adapter *adapter) | |||
3253 | memcpy(mac, adapter->netdev->dev_addr, ETH_ALEN); | 3253 | memcpy(mac, adapter->netdev->dev_addr, ETH_ALEN); |
3254 | } | 3254 | } |
3255 | 3255 | ||
3256 | /* On BE3 VFs this cmd may fail due to lack of privilege. | 3256 | /* For BE3-R VFs, the PF programs the initial MAC address */ |
3257 | * Ignore the failure as in this case pmac_id is fetched | 3257 | if (!(BEx_chip(adapter) && be_virtfn(adapter))) |
3258 | * in the IFACE_CREATE cmd. | 3258 | be_cmd_pmac_add(adapter, mac, adapter->if_handle, |
3259 | */ | 3259 | &adapter->pmac_id[0], 0); |
3260 | be_cmd_pmac_add(adapter, mac, adapter->if_handle, | ||
3261 | &adapter->pmac_id[0], 0); | ||
3262 | return 0; | 3260 | return 0; |
3263 | } | 3261 | } |
3264 | 3262 | ||
@@ -4599,6 +4597,7 @@ static int be_suspend(struct pci_dev *pdev, pm_message_t state) | |||
4599 | if (adapter->wol) | 4597 | if (adapter->wol) |
4600 | be_setup_wol(adapter, true); | 4598 | be_setup_wol(adapter, true); |
4601 | 4599 | ||
4600 | be_intr_set(adapter, false); | ||
4602 | cancel_delayed_work_sync(&adapter->func_recovery_work); | 4601 | cancel_delayed_work_sync(&adapter->func_recovery_work); |
4603 | 4602 | ||
4604 | netif_device_detach(netdev); | 4603 | netif_device_detach(netdev); |
@@ -4634,6 +4633,7 @@ static int be_resume(struct pci_dev *pdev) | |||
4634 | if (status) | 4633 | if (status) |
4635 | return status; | 4634 | return status; |
4636 | 4635 | ||
4636 | be_intr_set(adapter, true); | ||
4637 | /* tell fw we're ready to fire cmds */ | 4637 | /* tell fw we're ready to fire cmds */ |
4638 | status = be_cmd_fw_init(adapter); | 4638 | status = be_cmd_fw_init(adapter); |
4639 | if (status) | 4639 | if (status) |
diff --git a/drivers/net/ethernet/intel/e1000/e1000.h b/drivers/net/ethernet/intel/e1000/e1000.h index 58c147271a36..f9313b36c887 100644 --- a/drivers/net/ethernet/intel/e1000/e1000.h +++ b/drivers/net/ethernet/intel/e1000/e1000.h | |||
@@ -83,6 +83,11 @@ struct e1000_adapter; | |||
83 | 83 | ||
84 | #define E1000_MAX_INTR 10 | 84 | #define E1000_MAX_INTR 10 |
85 | 85 | ||
86 | /* | ||
87 | * Count for polling __E1000_RESET condition every 10-20msec. | ||
88 | */ | ||
89 | #define E1000_CHECK_RESET_COUNT 50 | ||
90 | |||
86 | /* TX/RX descriptor defines */ | 91 | /* TX/RX descriptor defines */ |
87 | #define E1000_DEFAULT_TXD 256 | 92 | #define E1000_DEFAULT_TXD 256 |
88 | #define E1000_MAX_TXD 256 | 93 | #define E1000_MAX_TXD 256 |
@@ -312,8 +317,6 @@ struct e1000_adapter { | |||
312 | struct delayed_work watchdog_task; | 317 | struct delayed_work watchdog_task; |
313 | struct delayed_work fifo_stall_task; | 318 | struct delayed_work fifo_stall_task; |
314 | struct delayed_work phy_info_task; | 319 | struct delayed_work phy_info_task; |
315 | |||
316 | struct mutex mutex; | ||
317 | }; | 320 | }; |
318 | 321 | ||
319 | enum e1000_state_t { | 322 | enum e1000_state_t { |
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index e38622825fa7..46e6544ed1b7 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c | |||
@@ -494,13 +494,20 @@ static void e1000_down_and_stop(struct e1000_adapter *adapter) | |||
494 | { | 494 | { |
495 | set_bit(__E1000_DOWN, &adapter->flags); | 495 | set_bit(__E1000_DOWN, &adapter->flags); |
496 | 496 | ||
497 | /* Only kill reset task if adapter is not resetting */ | ||
498 | if (!test_bit(__E1000_RESETTING, &adapter->flags)) | ||
499 | cancel_work_sync(&adapter->reset_task); | ||
500 | |||
501 | cancel_delayed_work_sync(&adapter->watchdog_task); | 497 | cancel_delayed_work_sync(&adapter->watchdog_task); |
498 | |||
499 | /* | ||
500 | * Since the watchdog task can reschedule other tasks, we should cancel | ||
501 | * it first, otherwise we can run into the situation when a work is | ||
502 | * still running after the adapter has been turned down. | ||
503 | */ | ||
504 | |||
502 | cancel_delayed_work_sync(&adapter->phy_info_task); | 505 | cancel_delayed_work_sync(&adapter->phy_info_task); |
503 | cancel_delayed_work_sync(&adapter->fifo_stall_task); | 506 | cancel_delayed_work_sync(&adapter->fifo_stall_task); |
507 | |||
508 | /* Only kill reset task if adapter is not resetting */ | ||
509 | if (!test_bit(__E1000_RESETTING, &adapter->flags)) | ||
510 | cancel_work_sync(&adapter->reset_task); | ||
504 | } | 511 | } |
505 | 512 | ||
506 | void e1000_down(struct e1000_adapter *adapter) | 513 | void e1000_down(struct e1000_adapter *adapter) |
@@ -544,21 +551,8 @@ void e1000_down(struct e1000_adapter *adapter) | |||
544 | e1000_clean_all_rx_rings(adapter); | 551 | e1000_clean_all_rx_rings(adapter); |
545 | } | 552 | } |
546 | 553 | ||
547 | static void e1000_reinit_safe(struct e1000_adapter *adapter) | ||
548 | { | ||
549 | while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) | ||
550 | msleep(1); | ||
551 | mutex_lock(&adapter->mutex); | ||
552 | e1000_down(adapter); | ||
553 | e1000_up(adapter); | ||
554 | mutex_unlock(&adapter->mutex); | ||
555 | clear_bit(__E1000_RESETTING, &adapter->flags); | ||
556 | } | ||
557 | |||
558 | void e1000_reinit_locked(struct e1000_adapter *adapter) | 554 | void e1000_reinit_locked(struct e1000_adapter *adapter) |
559 | { | 555 | { |
560 | /* if rtnl_lock is not held the call path is bogus */ | ||
561 | ASSERT_RTNL(); | ||
562 | WARN_ON(in_interrupt()); | 556 | WARN_ON(in_interrupt()); |
563 | while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) | 557 | while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) |
564 | msleep(1); | 558 | msleep(1); |
@@ -1316,7 +1310,6 @@ static int e1000_sw_init(struct e1000_adapter *adapter) | |||
1316 | e1000_irq_disable(adapter); | 1310 | e1000_irq_disable(adapter); |
1317 | 1311 | ||
1318 | spin_lock_init(&adapter->stats_lock); | 1312 | spin_lock_init(&adapter->stats_lock); |
1319 | mutex_init(&adapter->mutex); | ||
1320 | 1313 | ||
1321 | set_bit(__E1000_DOWN, &adapter->flags); | 1314 | set_bit(__E1000_DOWN, &adapter->flags); |
1322 | 1315 | ||
@@ -1440,6 +1433,10 @@ static int e1000_close(struct net_device *netdev) | |||
1440 | { | 1433 | { |
1441 | struct e1000_adapter *adapter = netdev_priv(netdev); | 1434 | struct e1000_adapter *adapter = netdev_priv(netdev); |
1442 | struct e1000_hw *hw = &adapter->hw; | 1435 | struct e1000_hw *hw = &adapter->hw; |
1436 | int count = E1000_CHECK_RESET_COUNT; | ||
1437 | |||
1438 | while (test_bit(__E1000_RESETTING, &adapter->flags) && count--) | ||
1439 | usleep_range(10000, 20000); | ||
1443 | 1440 | ||
1444 | WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); | 1441 | WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); |
1445 | e1000_down(adapter); | 1442 | e1000_down(adapter); |
@@ -2325,11 +2322,8 @@ static void e1000_update_phy_info_task(struct work_struct *work) | |||
2325 | struct e1000_adapter *adapter = container_of(work, | 2322 | struct e1000_adapter *adapter = container_of(work, |
2326 | struct e1000_adapter, | 2323 | struct e1000_adapter, |
2327 | phy_info_task.work); | 2324 | phy_info_task.work); |
2328 | if (test_bit(__E1000_DOWN, &adapter->flags)) | 2325 | |
2329 | return; | ||
2330 | mutex_lock(&adapter->mutex); | ||
2331 | e1000_phy_get_info(&adapter->hw, &adapter->phy_info); | 2326 | e1000_phy_get_info(&adapter->hw, &adapter->phy_info); |
2332 | mutex_unlock(&adapter->mutex); | ||
2333 | } | 2327 | } |
2334 | 2328 | ||
2335 | /** | 2329 | /** |
@@ -2345,9 +2339,6 @@ static void e1000_82547_tx_fifo_stall_task(struct work_struct *work) | |||
2345 | struct net_device *netdev = adapter->netdev; | 2339 | struct net_device *netdev = adapter->netdev; |
2346 | u32 tctl; | 2340 | u32 tctl; |
2347 | 2341 | ||
2348 | if (test_bit(__E1000_DOWN, &adapter->flags)) | ||
2349 | return; | ||
2350 | mutex_lock(&adapter->mutex); | ||
2351 | if (atomic_read(&adapter->tx_fifo_stall)) { | 2342 | if (atomic_read(&adapter->tx_fifo_stall)) { |
2352 | if ((er32(TDT) == er32(TDH)) && | 2343 | if ((er32(TDT) == er32(TDH)) && |
2353 | (er32(TDFT) == er32(TDFH)) && | 2344 | (er32(TDFT) == er32(TDFH)) && |
@@ -2368,7 +2359,6 @@ static void e1000_82547_tx_fifo_stall_task(struct work_struct *work) | |||
2368 | schedule_delayed_work(&adapter->fifo_stall_task, 1); | 2359 | schedule_delayed_work(&adapter->fifo_stall_task, 1); |
2369 | } | 2360 | } |
2370 | } | 2361 | } |
2371 | mutex_unlock(&adapter->mutex); | ||
2372 | } | 2362 | } |
2373 | 2363 | ||
2374 | bool e1000_has_link(struct e1000_adapter *adapter) | 2364 | bool e1000_has_link(struct e1000_adapter *adapter) |
@@ -2422,10 +2412,6 @@ static void e1000_watchdog(struct work_struct *work) | |||
2422 | struct e1000_tx_ring *txdr = adapter->tx_ring; | 2412 | struct e1000_tx_ring *txdr = adapter->tx_ring; |
2423 | u32 link, tctl; | 2413 | u32 link, tctl; |
2424 | 2414 | ||
2425 | if (test_bit(__E1000_DOWN, &adapter->flags)) | ||
2426 | return; | ||
2427 | |||
2428 | mutex_lock(&adapter->mutex); | ||
2429 | link = e1000_has_link(adapter); | 2415 | link = e1000_has_link(adapter); |
2430 | if ((netif_carrier_ok(netdev)) && link) | 2416 | if ((netif_carrier_ok(netdev)) && link) |
2431 | goto link_up; | 2417 | goto link_up; |
@@ -2516,7 +2502,7 @@ link_up: | |||
2516 | adapter->tx_timeout_count++; | 2502 | adapter->tx_timeout_count++; |
2517 | schedule_work(&adapter->reset_task); | 2503 | schedule_work(&adapter->reset_task); |
2518 | /* exit immediately since reset is imminent */ | 2504 | /* exit immediately since reset is imminent */ |
2519 | goto unlock; | 2505 | return; |
2520 | } | 2506 | } |
2521 | } | 2507 | } |
2522 | 2508 | ||
@@ -2544,9 +2530,6 @@ link_up: | |||
2544 | /* Reschedule the task */ | 2530 | /* Reschedule the task */ |
2545 | if (!test_bit(__E1000_DOWN, &adapter->flags)) | 2531 | if (!test_bit(__E1000_DOWN, &adapter->flags)) |
2546 | schedule_delayed_work(&adapter->watchdog_task, 2 * HZ); | 2532 | schedule_delayed_work(&adapter->watchdog_task, 2 * HZ); |
2547 | |||
2548 | unlock: | ||
2549 | mutex_unlock(&adapter->mutex); | ||
2550 | } | 2533 | } |
2551 | 2534 | ||
2552 | enum latency_range { | 2535 | enum latency_range { |
@@ -3495,10 +3478,8 @@ static void e1000_reset_task(struct work_struct *work) | |||
3495 | struct e1000_adapter *adapter = | 3478 | struct e1000_adapter *adapter = |
3496 | container_of(work, struct e1000_adapter, reset_task); | 3479 | container_of(work, struct e1000_adapter, reset_task); |
3497 | 3480 | ||
3498 | if (test_bit(__E1000_DOWN, &adapter->flags)) | ||
3499 | return; | ||
3500 | e_err(drv, "Reset adapter\n"); | 3481 | e_err(drv, "Reset adapter\n"); |
3501 | e1000_reinit_safe(adapter); | 3482 | e1000_reinit_locked(adapter); |
3502 | } | 3483 | } |
3503 | 3484 | ||
3504 | /** | 3485 | /** |
@@ -4963,6 +4944,11 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) | |||
4963 | netif_device_detach(netdev); | 4944 | netif_device_detach(netdev); |
4964 | 4945 | ||
4965 | if (netif_running(netdev)) { | 4946 | if (netif_running(netdev)) { |
4947 | int count = E1000_CHECK_RESET_COUNT; | ||
4948 | |||
4949 | while (test_bit(__E1000_RESETTING, &adapter->flags) && count--) | ||
4950 | usleep_range(10000, 20000); | ||
4951 | |||
4966 | WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); | 4952 | WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); |
4967 | e1000_down(adapter); | 4953 | e1000_down(adapter); |
4968 | } | 4954 | } |
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index b0f3666b1d7f..c3143da497c8 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c | |||
@@ -2062,14 +2062,15 @@ static void igb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | |||
2062 | { | 2062 | { |
2063 | struct igb_adapter *adapter = netdev_priv(netdev); | 2063 | struct igb_adapter *adapter = netdev_priv(netdev); |
2064 | 2064 | ||
2065 | wol->supported = WAKE_UCAST | WAKE_MCAST | | ||
2066 | WAKE_BCAST | WAKE_MAGIC | | ||
2067 | WAKE_PHY; | ||
2068 | wol->wolopts = 0; | 2065 | wol->wolopts = 0; |
2069 | 2066 | ||
2070 | if (!(adapter->flags & IGB_FLAG_WOL_SUPPORTED)) | 2067 | if (!(adapter->flags & IGB_FLAG_WOL_SUPPORTED)) |
2071 | return; | 2068 | return; |
2072 | 2069 | ||
2070 | wol->supported = WAKE_UCAST | WAKE_MCAST | | ||
2071 | WAKE_BCAST | WAKE_MAGIC | | ||
2072 | WAKE_PHY; | ||
2073 | |||
2073 | /* apply any specific unsupported masks here */ | 2074 | /* apply any specific unsupported masks here */ |
2074 | switch (adapter->hw.device_id) { | 2075 | switch (adapter->hw.device_id) { |
2075 | default: | 2076 | default: |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 0c55079ebee3..cc06854296a3 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | |||
@@ -4251,8 +4251,8 @@ static void ixgbe_disable_fwd_ring(struct ixgbe_fwd_adapter *vadapter, | |||
4251 | rx_ring->l2_accel_priv = NULL; | 4251 | rx_ring->l2_accel_priv = NULL; |
4252 | } | 4252 | } |
4253 | 4253 | ||
4254 | int ixgbe_fwd_ring_down(struct net_device *vdev, | 4254 | static int ixgbe_fwd_ring_down(struct net_device *vdev, |
4255 | struct ixgbe_fwd_adapter *accel) | 4255 | struct ixgbe_fwd_adapter *accel) |
4256 | { | 4256 | { |
4257 | struct ixgbe_adapter *adapter = accel->real_adapter; | 4257 | struct ixgbe_adapter *adapter = accel->real_adapter; |
4258 | unsigned int rxbase = accel->rx_base_queue; | 4258 | unsigned int rxbase = accel->rx_base_queue; |
@@ -7986,10 +7986,9 @@ skip_sriov: | |||
7986 | NETIF_F_TSO | | 7986 | NETIF_F_TSO | |
7987 | NETIF_F_TSO6 | | 7987 | NETIF_F_TSO6 | |
7988 | NETIF_F_RXHASH | | 7988 | NETIF_F_RXHASH | |
7989 | NETIF_F_RXCSUM | | 7989 | NETIF_F_RXCSUM; |
7990 | NETIF_F_HW_L2FW_DOFFLOAD; | ||
7991 | 7990 | ||
7992 | netdev->hw_features = netdev->features; | 7991 | netdev->hw_features = netdev->features | NETIF_F_HW_L2FW_DOFFLOAD; |
7993 | 7992 | ||
7994 | switch (adapter->hw.mac.type) { | 7993 | switch (adapter->hw.mac.type) { |
7995 | case ixgbe_mac_82599EB: | 7994 | case ixgbe_mac_82599EB: |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c index e4c676006be9..39217e5ff7dc 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | |||
@@ -46,6 +46,7 @@ static bool ixgbe_get_i2c_data(u32 *i2cctl); | |||
46 | static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw); | 46 | static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw); |
47 | static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id); | 47 | static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id); |
48 | static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw); | 48 | static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw); |
49 | static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw); | ||
49 | 50 | ||
50 | /** | 51 | /** |
51 | * ixgbe_identify_phy_generic - Get physical layer module | 52 | * ixgbe_identify_phy_generic - Get physical layer module |
@@ -1164,7 +1165,7 @@ err_read_i2c_eeprom: | |||
1164 | * | 1165 | * |
1165 | * Searches for and identifies the QSFP module and assigns appropriate PHY type | 1166 | * Searches for and identifies the QSFP module and assigns appropriate PHY type |
1166 | **/ | 1167 | **/ |
1167 | s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) | 1168 | static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) |
1168 | { | 1169 | { |
1169 | struct ixgbe_adapter *adapter = hw->back; | 1170 | struct ixgbe_adapter *adapter = hw->back; |
1170 | s32 status = IXGBE_ERR_PHY_ADDR_INVALID; | 1171 | s32 status = IXGBE_ERR_PHY_ADDR_INVALID; |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h index aae900a256da..fffcbdd2bf0e 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h | |||
@@ -145,7 +145,6 @@ s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw, | |||
145 | s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw); | 145 | s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw); |
146 | s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw); | 146 | s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw); |
147 | s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw); | 147 | s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw); |
148 | s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw); | ||
149 | s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw, | 148 | s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw, |
150 | u16 *list_offset, | 149 | u16 *list_offset, |
151 | u16 *data_offset); | 150 | u16 *data_offset); |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_selftest.c b/drivers/net/ethernet/mellanox/mlx4/en_selftest.c index 40626690e8a8..c11d063473e5 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_selftest.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_selftest.c | |||
@@ -140,7 +140,6 @@ void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf) | |||
140 | { | 140 | { |
141 | struct mlx4_en_priv *priv = netdev_priv(dev); | 141 | struct mlx4_en_priv *priv = netdev_priv(dev); |
142 | struct mlx4_en_dev *mdev = priv->mdev; | 142 | struct mlx4_en_dev *mdev = priv->mdev; |
143 | struct mlx4_en_tx_ring *tx_ring; | ||
144 | int i, carrier_ok; | 143 | int i, carrier_ok; |
145 | 144 | ||
146 | memset(buf, 0, sizeof(u64) * MLX4_EN_NUM_SELF_TEST); | 145 | memset(buf, 0, sizeof(u64) * MLX4_EN_NUM_SELF_TEST); |
@@ -150,16 +149,10 @@ void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf) | |||
150 | carrier_ok = netif_carrier_ok(dev); | 149 | carrier_ok = netif_carrier_ok(dev); |
151 | 150 | ||
152 | netif_carrier_off(dev); | 151 | netif_carrier_off(dev); |
153 | retry_tx: | ||
154 | /* Wait until all tx queues are empty. | 152 | /* Wait until all tx queues are empty. |
155 | * there should not be any additional incoming traffic | 153 | * there should not be any additional incoming traffic |
156 | * since we turned the carrier off */ | 154 | * since we turned the carrier off */ |
157 | msleep(200); | 155 | msleep(200); |
158 | for (i = 0; i < priv->tx_ring_num && carrier_ok; i++) { | ||
159 | tx_ring = priv->tx_ring[i]; | ||
160 | if (tx_ring->prod != (tx_ring->cons + tx_ring->last_nr_txbb)) | ||
161 | goto retry_tx; | ||
162 | } | ||
163 | 156 | ||
164 | if (priv->mdev->dev->caps.flags & | 157 | if (priv->mdev->dev->caps.flags & |
165 | MLX4_DEV_CAP_FLAG_UC_LOOPBACK) { | 158 | MLX4_DEV_CAP_FLAG_UC_LOOPBACK) { |
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index f2a2128165dd..737c1a881f78 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c | |||
@@ -678,9 +678,6 @@ static void cp_tx (struct cp_private *cp) | |||
678 | le32_to_cpu(txd->opts1) & 0xffff, | 678 | le32_to_cpu(txd->opts1) & 0xffff, |
679 | PCI_DMA_TODEVICE); | 679 | PCI_DMA_TODEVICE); |
680 | 680 | ||
681 | bytes_compl += skb->len; | ||
682 | pkts_compl++; | ||
683 | |||
684 | if (status & LastFrag) { | 681 | if (status & LastFrag) { |
685 | if (status & (TxError | TxFIFOUnder)) { | 682 | if (status & (TxError | TxFIFOUnder)) { |
686 | netif_dbg(cp, tx_err, cp->dev, | 683 | netif_dbg(cp, tx_err, cp->dev, |
@@ -702,6 +699,8 @@ static void cp_tx (struct cp_private *cp) | |||
702 | netif_dbg(cp, tx_done, cp->dev, | 699 | netif_dbg(cp, tx_done, cp->dev, |
703 | "tx done, slot %d\n", tx_tail); | 700 | "tx done, slot %d\n", tx_tail); |
704 | } | 701 | } |
702 | bytes_compl += skb->len; | ||
703 | pkts_compl++; | ||
705 | dev_kfree_skb_irq(skb); | 704 | dev_kfree_skb_irq(skb); |
706 | } | 705 | } |
707 | 706 | ||
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 799387570766..c737f0ea5de7 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
@@ -3465,6 +3465,11 @@ static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp) | |||
3465 | rtl_writephy(tp, 0x14, 0x9065); | 3465 | rtl_writephy(tp, 0x14, 0x9065); |
3466 | rtl_writephy(tp, 0x14, 0x1065); | 3466 | rtl_writephy(tp, 0x14, 0x1065); |
3467 | 3467 | ||
3468 | /* Check ALDPS bit, disable it if enabled */ | ||
3469 | rtl_writephy(tp, 0x1f, 0x0a43); | ||
3470 | if (rtl_readphy(tp, 0x10) & 0x0004) | ||
3471 | rtl_w1w0_phy(tp, 0x10, 0x0000, 0x0004); | ||
3472 | |||
3468 | rtl_writephy(tp, 0x1f, 0x0000); | 3473 | rtl_writephy(tp, 0x1f, 0x0000); |
3469 | } | 3474 | } |
3470 | 3475 | ||
diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h index 656a3277c2b2..15816cacb548 100644 --- a/drivers/net/ethernet/sfc/mcdi.h +++ b/drivers/net/ethernet/sfc/mcdi.h | |||
@@ -75,6 +75,8 @@ struct efx_mcdi_mon { | |||
75 | unsigned long last_update; | 75 | unsigned long last_update; |
76 | struct device *device; | 76 | struct device *device; |
77 | struct efx_mcdi_mon_attribute *attrs; | 77 | struct efx_mcdi_mon_attribute *attrs; |
78 | struct attribute_group group; | ||
79 | const struct attribute_group *groups[2]; | ||
78 | unsigned int n_attrs; | 80 | unsigned int n_attrs; |
79 | }; | 81 | }; |
80 | 82 | ||
diff --git a/drivers/net/ethernet/sfc/mcdi_mon.c b/drivers/net/ethernet/sfc/mcdi_mon.c index 4cc5d95b2a5a..d72ad4fc3617 100644 --- a/drivers/net/ethernet/sfc/mcdi_mon.c +++ b/drivers/net/ethernet/sfc/mcdi_mon.c | |||
@@ -139,17 +139,10 @@ static int efx_mcdi_mon_update(struct efx_nic *efx) | |||
139 | return rc; | 139 | return rc; |
140 | } | 140 | } |
141 | 141 | ||
142 | static ssize_t efx_mcdi_mon_show_name(struct device *dev, | ||
143 | struct device_attribute *attr, | ||
144 | char *buf) | ||
145 | { | ||
146 | return sprintf(buf, "%s\n", KBUILD_MODNAME); | ||
147 | } | ||
148 | |||
149 | static int efx_mcdi_mon_get_entry(struct device *dev, unsigned int index, | 142 | static int efx_mcdi_mon_get_entry(struct device *dev, unsigned int index, |
150 | efx_dword_t *entry) | 143 | efx_dword_t *entry) |
151 | { | 144 | { |
152 | struct efx_nic *efx = dev_get_drvdata(dev); | 145 | struct efx_nic *efx = dev_get_drvdata(dev->parent); |
153 | struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); | 146 | struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); |
154 | int rc; | 147 | int rc; |
155 | 148 | ||
@@ -263,7 +256,7 @@ static ssize_t efx_mcdi_mon_show_label(struct device *dev, | |||
263 | efx_mcdi_sensor_type[mon_attr->type].label); | 256 | efx_mcdi_sensor_type[mon_attr->type].label); |
264 | } | 257 | } |
265 | 258 | ||
266 | static int | 259 | static void |
267 | efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name, | 260 | efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name, |
268 | ssize_t (*reader)(struct device *, | 261 | ssize_t (*reader)(struct device *, |
269 | struct device_attribute *, char *), | 262 | struct device_attribute *, char *), |
@@ -272,7 +265,6 @@ efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name, | |||
272 | { | 265 | { |
273 | struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); | 266 | struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); |
274 | struct efx_mcdi_mon_attribute *attr = &hwmon->attrs[hwmon->n_attrs]; | 267 | struct efx_mcdi_mon_attribute *attr = &hwmon->attrs[hwmon->n_attrs]; |
275 | int rc; | ||
276 | 268 | ||
277 | strlcpy(attr->name, name, sizeof(attr->name)); | 269 | strlcpy(attr->name, name, sizeof(attr->name)); |
278 | attr->index = index; | 270 | attr->index = index; |
@@ -286,10 +278,7 @@ efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name, | |||
286 | attr->dev_attr.attr.name = attr->name; | 278 | attr->dev_attr.attr.name = attr->name; |
287 | attr->dev_attr.attr.mode = S_IRUGO; | 279 | attr->dev_attr.attr.mode = S_IRUGO; |
288 | attr->dev_attr.show = reader; | 280 | attr->dev_attr.show = reader; |
289 | rc = device_create_file(&efx->pci_dev->dev, &attr->dev_attr); | 281 | hwmon->group.attrs[hwmon->n_attrs++] = &attr->dev_attr.attr; |
290 | if (rc == 0) | ||
291 | ++hwmon->n_attrs; | ||
292 | return rc; | ||
293 | } | 282 | } |
294 | 283 | ||
295 | int efx_mcdi_mon_probe(struct efx_nic *efx) | 284 | int efx_mcdi_mon_probe(struct efx_nic *efx) |
@@ -338,26 +327,22 @@ int efx_mcdi_mon_probe(struct efx_nic *efx) | |||
338 | efx_mcdi_mon_update(efx); | 327 | efx_mcdi_mon_update(efx); |
339 | 328 | ||
340 | /* Allocate space for the maximum possible number of | 329 | /* Allocate space for the maximum possible number of |
341 | * attributes for this set of sensors: name of the driver plus | 330 | * attributes for this set of sensors: |
342 | * value, min, max, crit, alarm and label for each sensor. | 331 | * value, min, max, crit, alarm and label for each sensor. |
343 | */ | 332 | */ |
344 | n_attrs = 1 + 6 * n_sensors; | 333 | n_attrs = 6 * n_sensors; |
345 | hwmon->attrs = kcalloc(n_attrs, sizeof(*hwmon->attrs), GFP_KERNEL); | 334 | hwmon->attrs = kcalloc(n_attrs, sizeof(*hwmon->attrs), GFP_KERNEL); |
346 | if (!hwmon->attrs) { | 335 | if (!hwmon->attrs) { |
347 | rc = -ENOMEM; | 336 | rc = -ENOMEM; |
348 | goto fail; | 337 | goto fail; |
349 | } | 338 | } |
350 | 339 | hwmon->group.attrs = kcalloc(n_attrs + 1, sizeof(struct attribute *), | |
351 | hwmon->device = hwmon_device_register(&efx->pci_dev->dev); | 340 | GFP_KERNEL); |
352 | if (IS_ERR(hwmon->device)) { | 341 | if (!hwmon->group.attrs) { |
353 | rc = PTR_ERR(hwmon->device); | 342 | rc = -ENOMEM; |
354 | goto fail; | 343 | goto fail; |
355 | } | 344 | } |
356 | 345 | ||
357 | rc = efx_mcdi_mon_add_attr(efx, "name", efx_mcdi_mon_show_name, 0, 0, 0); | ||
358 | if (rc) | ||
359 | goto fail; | ||
360 | |||
361 | for (i = 0, j = -1, type = -1; ; i++) { | 346 | for (i = 0, j = -1, type = -1; ; i++) { |
362 | enum efx_hwmon_type hwmon_type; | 347 | enum efx_hwmon_type hwmon_type; |
363 | const char *hwmon_prefix; | 348 | const char *hwmon_prefix; |
@@ -372,7 +357,7 @@ int efx_mcdi_mon_probe(struct efx_nic *efx) | |||
372 | page = type / 32; | 357 | page = type / 32; |
373 | j = -1; | 358 | j = -1; |
374 | if (page == n_pages) | 359 | if (page == n_pages) |
375 | return 0; | 360 | goto hwmon_register; |
376 | 361 | ||
377 | MCDI_SET_DWORD(inbuf, SENSOR_INFO_EXT_IN_PAGE, | 362 | MCDI_SET_DWORD(inbuf, SENSOR_INFO_EXT_IN_PAGE, |
378 | page); | 363 | page); |
@@ -453,28 +438,22 @@ int efx_mcdi_mon_probe(struct efx_nic *efx) | |||
453 | if (min1 != max1) { | 438 | if (min1 != max1) { |
454 | snprintf(name, sizeof(name), "%s%u_input", | 439 | snprintf(name, sizeof(name), "%s%u_input", |
455 | hwmon_prefix, hwmon_index); | 440 | hwmon_prefix, hwmon_index); |
456 | rc = efx_mcdi_mon_add_attr( | 441 | efx_mcdi_mon_add_attr( |
457 | efx, name, efx_mcdi_mon_show_value, i, type, 0); | 442 | efx, name, efx_mcdi_mon_show_value, i, type, 0); |
458 | if (rc) | ||
459 | goto fail; | ||
460 | 443 | ||
461 | if (hwmon_type != EFX_HWMON_POWER) { | 444 | if (hwmon_type != EFX_HWMON_POWER) { |
462 | snprintf(name, sizeof(name), "%s%u_min", | 445 | snprintf(name, sizeof(name), "%s%u_min", |
463 | hwmon_prefix, hwmon_index); | 446 | hwmon_prefix, hwmon_index); |
464 | rc = efx_mcdi_mon_add_attr( | 447 | efx_mcdi_mon_add_attr( |
465 | efx, name, efx_mcdi_mon_show_limit, | 448 | efx, name, efx_mcdi_mon_show_limit, |
466 | i, type, min1); | 449 | i, type, min1); |
467 | if (rc) | ||
468 | goto fail; | ||
469 | } | 450 | } |
470 | 451 | ||
471 | snprintf(name, sizeof(name), "%s%u_max", | 452 | snprintf(name, sizeof(name), "%s%u_max", |
472 | hwmon_prefix, hwmon_index); | 453 | hwmon_prefix, hwmon_index); |
473 | rc = efx_mcdi_mon_add_attr( | 454 | efx_mcdi_mon_add_attr( |
474 | efx, name, efx_mcdi_mon_show_limit, | 455 | efx, name, efx_mcdi_mon_show_limit, |
475 | i, type, max1); | 456 | i, type, max1); |
476 | if (rc) | ||
477 | goto fail; | ||
478 | 457 | ||
479 | if (min2 != max2) { | 458 | if (min2 != max2) { |
480 | /* Assume max2 is critical value. | 459 | /* Assume max2 is critical value. |
@@ -482,32 +461,38 @@ int efx_mcdi_mon_probe(struct efx_nic *efx) | |||
482 | */ | 461 | */ |
483 | snprintf(name, sizeof(name), "%s%u_crit", | 462 | snprintf(name, sizeof(name), "%s%u_crit", |
484 | hwmon_prefix, hwmon_index); | 463 | hwmon_prefix, hwmon_index); |
485 | rc = efx_mcdi_mon_add_attr( | 464 | efx_mcdi_mon_add_attr( |
486 | efx, name, efx_mcdi_mon_show_limit, | 465 | efx, name, efx_mcdi_mon_show_limit, |
487 | i, type, max2); | 466 | i, type, max2); |
488 | if (rc) | ||
489 | goto fail; | ||
490 | } | 467 | } |
491 | } | 468 | } |
492 | 469 | ||
493 | snprintf(name, sizeof(name), "%s%u_alarm", | 470 | snprintf(name, sizeof(name), "%s%u_alarm", |
494 | hwmon_prefix, hwmon_index); | 471 | hwmon_prefix, hwmon_index); |
495 | rc = efx_mcdi_mon_add_attr( | 472 | efx_mcdi_mon_add_attr( |
496 | efx, name, efx_mcdi_mon_show_alarm, i, type, 0); | 473 | efx, name, efx_mcdi_mon_show_alarm, i, type, 0); |
497 | if (rc) | ||
498 | goto fail; | ||
499 | 474 | ||
500 | if (type < ARRAY_SIZE(efx_mcdi_sensor_type) && | 475 | if (type < ARRAY_SIZE(efx_mcdi_sensor_type) && |
501 | efx_mcdi_sensor_type[type].label) { | 476 | efx_mcdi_sensor_type[type].label) { |
502 | snprintf(name, sizeof(name), "%s%u_label", | 477 | snprintf(name, sizeof(name), "%s%u_label", |
503 | hwmon_prefix, hwmon_index); | 478 | hwmon_prefix, hwmon_index); |
504 | rc = efx_mcdi_mon_add_attr( | 479 | efx_mcdi_mon_add_attr( |
505 | efx, name, efx_mcdi_mon_show_label, i, type, 0); | 480 | efx, name, efx_mcdi_mon_show_label, i, type, 0); |
506 | if (rc) | ||
507 | goto fail; | ||
508 | } | 481 | } |
509 | } | 482 | } |
510 | 483 | ||
484 | hwmon_register: | ||
485 | hwmon->groups[0] = &hwmon->group; | ||
486 | hwmon->device = hwmon_device_register_with_groups(&efx->pci_dev->dev, | ||
487 | KBUILD_MODNAME, NULL, | ||
488 | hwmon->groups); | ||
489 | if (IS_ERR(hwmon->device)) { | ||
490 | rc = PTR_ERR(hwmon->device); | ||
491 | goto fail; | ||
492 | } | ||
493 | |||
494 | return 0; | ||
495 | |||
511 | fail: | 496 | fail: |
512 | efx_mcdi_mon_remove(efx); | 497 | efx_mcdi_mon_remove(efx); |
513 | return rc; | 498 | return rc; |
@@ -516,14 +501,11 @@ fail: | |||
516 | void efx_mcdi_mon_remove(struct efx_nic *efx) | 501 | void efx_mcdi_mon_remove(struct efx_nic *efx) |
517 | { | 502 | { |
518 | struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); | 503 | struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); |
519 | unsigned int i; | ||
520 | 504 | ||
521 | for (i = 0; i < hwmon->n_attrs; i++) | ||
522 | device_remove_file(&efx->pci_dev->dev, | ||
523 | &hwmon->attrs[i].dev_attr); | ||
524 | kfree(hwmon->attrs); | ||
525 | if (hwmon->device) | 505 | if (hwmon->device) |
526 | hwmon_device_unregister(hwmon->device); | 506 | hwmon_device_unregister(hwmon->device); |
507 | kfree(hwmon->attrs); | ||
508 | kfree(hwmon->group.attrs); | ||
527 | efx_nic_free_buffer(efx, &hwmon->dma_buf); | 509 | efx_nic_free_buffer(efx, &hwmon->dma_buf); |
528 | } | 510 | } |
529 | 511 | ||
diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h index c9d4c872e81d..749654b976bc 100644 --- a/drivers/net/ethernet/smsc/smc91x.h +++ b/drivers/net/ethernet/smsc/smc91x.h | |||
@@ -46,7 +46,8 @@ | |||
46 | defined(CONFIG_MACH_LITTLETON) ||\ | 46 | defined(CONFIG_MACH_LITTLETON) ||\ |
47 | defined(CONFIG_MACH_ZYLONITE2) ||\ | 47 | defined(CONFIG_MACH_ZYLONITE2) ||\ |
48 | defined(CONFIG_ARCH_VIPER) ||\ | 48 | defined(CONFIG_ARCH_VIPER) ||\ |
49 | defined(CONFIG_MACH_STARGATE2) | 49 | defined(CONFIG_MACH_STARGATE2) ||\ |
50 | defined(CONFIG_ARCH_VERSATILE) | ||
50 | 51 | ||
51 | #include <asm/mach-types.h> | 52 | #include <asm/mach-types.h> |
52 | 53 | ||
@@ -154,6 +155,8 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg) | |||
154 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) | 155 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) |
155 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) | 156 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) |
156 | #define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) | 157 | #define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) |
158 | #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) | ||
159 | #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) | ||
157 | #define SMC_IRQ_FLAGS (-1) /* from resource */ | 160 | #define SMC_IRQ_FLAGS (-1) /* from resource */ |
158 | 161 | ||
159 | /* We actually can't write halfwords properly if not word aligned */ | 162 | /* We actually can't write halfwords properly if not word aligned */ |
@@ -206,23 +209,6 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg) | |||
206 | #define RPC_LSA_DEFAULT RPC_LED_TX_RX | 209 | #define RPC_LSA_DEFAULT RPC_LED_TX_RX |
207 | #define RPC_LSB_DEFAULT RPC_LED_100_10 | 210 | #define RPC_LSB_DEFAULT RPC_LED_100_10 |
208 | 211 | ||
209 | #elif defined(CONFIG_ARCH_VERSATILE) | ||
210 | |||
211 | #define SMC_CAN_USE_8BIT 1 | ||
212 | #define SMC_CAN_USE_16BIT 1 | ||
213 | #define SMC_CAN_USE_32BIT 1 | ||
214 | #define SMC_NOWAIT 1 | ||
215 | |||
216 | #define SMC_inb(a, r) readb((a) + (r)) | ||
217 | #define SMC_inw(a, r) readw((a) + (r)) | ||
218 | #define SMC_inl(a, r) readl((a) + (r)) | ||
219 | #define SMC_outb(v, a, r) writeb(v, (a) + (r)) | ||
220 | #define SMC_outw(v, a, r) writew(v, (a) + (r)) | ||
221 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) | ||
222 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) | ||
223 | #define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) | ||
224 | #define SMC_IRQ_FLAGS (-1) /* from resource */ | ||
225 | |||
226 | #elif defined(CONFIG_MN10300) | 212 | #elif defined(CONFIG_MN10300) |
227 | 213 | ||
228 | /* | 214 | /* |
diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c index d022bf936572..ad61d26a44f3 100644 --- a/drivers/net/ethernet/via/via-velocity.c +++ b/drivers/net/ethernet/via/via-velocity.c | |||
@@ -2172,16 +2172,13 @@ static int velocity_poll(struct napi_struct *napi, int budget) | |||
2172 | unsigned int rx_done; | 2172 | unsigned int rx_done; |
2173 | unsigned long flags; | 2173 | unsigned long flags; |
2174 | 2174 | ||
2175 | spin_lock_irqsave(&vptr->lock, flags); | ||
2176 | /* | 2175 | /* |
2177 | * Do rx and tx twice for performance (taken from the VIA | 2176 | * Do rx and tx twice for performance (taken from the VIA |
2178 | * out-of-tree driver). | 2177 | * out-of-tree driver). |
2179 | */ | 2178 | */ |
2180 | rx_done = velocity_rx_srv(vptr, budget / 2); | 2179 | rx_done = velocity_rx_srv(vptr, budget); |
2181 | velocity_tx_srv(vptr); | 2180 | spin_lock_irqsave(&vptr->lock, flags); |
2182 | rx_done += velocity_rx_srv(vptr, budget - rx_done); | ||
2183 | velocity_tx_srv(vptr); | 2181 | velocity_tx_srv(vptr); |
2184 | |||
2185 | /* If budget not fully consumed, exit the polling mode */ | 2182 | /* If budget not fully consumed, exit the polling mode */ |
2186 | if (rx_done < budget) { | 2183 | if (rx_done < budget) { |
2187 | napi_complete(napi); | 2184 | napi_complete(napi); |
@@ -2342,6 +2339,8 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu) | |||
2342 | if (ret < 0) | 2339 | if (ret < 0) |
2343 | goto out_free_tmp_vptr_1; | 2340 | goto out_free_tmp_vptr_1; |
2344 | 2341 | ||
2342 | napi_disable(&vptr->napi); | ||
2343 | |||
2345 | spin_lock_irqsave(&vptr->lock, flags); | 2344 | spin_lock_irqsave(&vptr->lock, flags); |
2346 | 2345 | ||
2347 | netif_stop_queue(dev); | 2346 | netif_stop_queue(dev); |
@@ -2362,6 +2361,8 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu) | |||
2362 | 2361 | ||
2363 | velocity_give_many_rx_descs(vptr); | 2362 | velocity_give_many_rx_descs(vptr); |
2364 | 2363 | ||
2364 | napi_enable(&vptr->napi); | ||
2365 | |||
2365 | mac_enable_int(vptr->mac_regs); | 2366 | mac_enable_int(vptr->mac_regs); |
2366 | netif_start_queue(dev); | 2367 | netif_start_queue(dev); |
2367 | 2368 | ||
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index dc76670c2f2a..9093004f9b63 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c | |||
@@ -744,7 +744,7 @@ err: | |||
744 | rcu_read_lock(); | 744 | rcu_read_lock(); |
745 | vlan = rcu_dereference(q->vlan); | 745 | vlan = rcu_dereference(q->vlan); |
746 | if (vlan) | 746 | if (vlan) |
747 | vlan->dev->stats.tx_dropped++; | 747 | this_cpu_inc(vlan->pcpu_stats->tx_dropped); |
748 | rcu_read_unlock(); | 748 | rcu_read_unlock(); |
749 | 749 | ||
750 | return err; | 750 | return err; |
@@ -767,7 +767,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q, | |||
767 | const struct sk_buff *skb, | 767 | const struct sk_buff *skb, |
768 | const struct iovec *iv, int len) | 768 | const struct iovec *iv, int len) |
769 | { | 769 | { |
770 | struct macvlan_dev *vlan; | ||
771 | int ret; | 770 | int ret; |
772 | int vnet_hdr_len = 0; | 771 | int vnet_hdr_len = 0; |
773 | int vlan_offset = 0; | 772 | int vlan_offset = 0; |
@@ -821,15 +820,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q, | |||
821 | copied += len; | 820 | copied += len; |
822 | 821 | ||
823 | done: | 822 | done: |
824 | rcu_read_lock(); | ||
825 | vlan = rcu_dereference(q->vlan); | ||
826 | if (vlan) { | ||
827 | preempt_disable(); | ||
828 | macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0); | ||
829 | preempt_enable(); | ||
830 | } | ||
831 | rcu_read_unlock(); | ||
832 | |||
833 | return ret ? ret : copied; | 823 | return ret ? ret : copied; |
834 | } | 824 | } |
835 | 825 | ||
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c index 508e4359338b..14372c65a7e8 100644 --- a/drivers/net/phy/vitesse.c +++ b/drivers/net/phy/vitesse.c | |||
@@ -64,6 +64,7 @@ | |||
64 | 64 | ||
65 | #define PHY_ID_VSC8234 0x000fc620 | 65 | #define PHY_ID_VSC8234 0x000fc620 |
66 | #define PHY_ID_VSC8244 0x000fc6c0 | 66 | #define PHY_ID_VSC8244 0x000fc6c0 |
67 | #define PHY_ID_VSC8514 0x00070670 | ||
67 | #define PHY_ID_VSC8574 0x000704a0 | 68 | #define PHY_ID_VSC8574 0x000704a0 |
68 | #define PHY_ID_VSC8662 0x00070660 | 69 | #define PHY_ID_VSC8662 0x00070660 |
69 | #define PHY_ID_VSC8221 0x000fc550 | 70 | #define PHY_ID_VSC8221 0x000fc550 |
@@ -131,6 +132,7 @@ static int vsc82xx_config_intr(struct phy_device *phydev) | |||
131 | err = phy_write(phydev, MII_VSC8244_IMASK, | 132 | err = phy_write(phydev, MII_VSC8244_IMASK, |
132 | (phydev->drv->phy_id == PHY_ID_VSC8234 || | 133 | (phydev->drv->phy_id == PHY_ID_VSC8234 || |
133 | phydev->drv->phy_id == PHY_ID_VSC8244 || | 134 | phydev->drv->phy_id == PHY_ID_VSC8244 || |
135 | phydev->drv->phy_id == PHY_ID_VSC8514 || | ||
134 | phydev->drv->phy_id == PHY_ID_VSC8574) ? | 136 | phydev->drv->phy_id == PHY_ID_VSC8574) ? |
135 | MII_VSC8244_IMASK_MASK : | 137 | MII_VSC8244_IMASK_MASK : |
136 | MII_VSC8221_IMASK_MASK); | 138 | MII_VSC8221_IMASK_MASK); |
@@ -246,6 +248,18 @@ static struct phy_driver vsc82xx_driver[] = { | |||
246 | .config_intr = &vsc82xx_config_intr, | 248 | .config_intr = &vsc82xx_config_intr, |
247 | .driver = { .owner = THIS_MODULE,}, | 249 | .driver = { .owner = THIS_MODULE,}, |
248 | }, { | 250 | }, { |
251 | .phy_id = PHY_ID_VSC8514, | ||
252 | .name = "Vitesse VSC8514", | ||
253 | .phy_id_mask = 0x000ffff0, | ||
254 | .features = PHY_GBIT_FEATURES, | ||
255 | .flags = PHY_HAS_INTERRUPT, | ||
256 | .config_init = &vsc824x_config_init, | ||
257 | .config_aneg = &vsc82x4_config_aneg, | ||
258 | .read_status = &genphy_read_status, | ||
259 | .ack_interrupt = &vsc824x_ack_interrupt, | ||
260 | .config_intr = &vsc82xx_config_intr, | ||
261 | .driver = { .owner = THIS_MODULE,}, | ||
262 | }, { | ||
249 | .phy_id = PHY_ID_VSC8574, | 263 | .phy_id = PHY_ID_VSC8574, |
250 | .name = "Vitesse VSC8574", | 264 | .name = "Vitesse VSC8574", |
251 | .phy_id_mask = 0x000ffff0, | 265 | .phy_id_mask = 0x000ffff0, |
@@ -315,6 +329,7 @@ module_exit(vsc82xx_exit); | |||
315 | static struct mdio_device_id __maybe_unused vitesse_tbl[] = { | 329 | static struct mdio_device_id __maybe_unused vitesse_tbl[] = { |
316 | { PHY_ID_VSC8234, 0x000ffff0 }, | 330 | { PHY_ID_VSC8234, 0x000ffff0 }, |
317 | { PHY_ID_VSC8244, 0x000fffc0 }, | 331 | { PHY_ID_VSC8244, 0x000fffc0 }, |
332 | { PHY_ID_VSC8514, 0x000ffff0 }, | ||
318 | { PHY_ID_VSC8574, 0x000ffff0 }, | 333 | { PHY_ID_VSC8574, 0x000ffff0 }, |
319 | { PHY_ID_VSC8662, 0x000ffff0 }, | 334 | { PHY_ID_VSC8662, 0x000ffff0 }, |
320 | { PHY_ID_VSC8221, 0x000ffff0 }, | 335 | { PHY_ID_VSC8221, 0x000ffff0 }, |
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 34b0de09d881..736050d6b451 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c | |||
@@ -1366,6 +1366,8 @@ static int team_user_linkup_option_get(struct team *team, | |||
1366 | return 0; | 1366 | return 0; |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | static void __team_carrier_check(struct team *team); | ||
1370 | |||
1369 | static int team_user_linkup_option_set(struct team *team, | 1371 | static int team_user_linkup_option_set(struct team *team, |
1370 | struct team_gsetter_ctx *ctx) | 1372 | struct team_gsetter_ctx *ctx) |
1371 | { | 1373 | { |
@@ -1373,6 +1375,7 @@ static int team_user_linkup_option_set(struct team *team, | |||
1373 | 1375 | ||
1374 | port->user.linkup = ctx->data.bool_val; | 1376 | port->user.linkup = ctx->data.bool_val; |
1375 | team_refresh_port_linkup(port); | 1377 | team_refresh_port_linkup(port); |
1378 | __team_carrier_check(port->team); | ||
1376 | return 0; | 1379 | return 0; |
1377 | } | 1380 | } |
1378 | 1381 | ||
@@ -1392,6 +1395,7 @@ static int team_user_linkup_en_option_set(struct team *team, | |||
1392 | 1395 | ||
1393 | port->user.linkup_enabled = ctx->data.bool_val; | 1396 | port->user.linkup_enabled = ctx->data.bool_val; |
1394 | team_refresh_port_linkup(port); | 1397 | team_refresh_port_linkup(port); |
1398 | __team_carrier_check(port->team); | ||
1395 | return 0; | 1399 | return 0; |
1396 | } | 1400 | } |
1397 | 1401 | ||
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7bab4de658a9..916241d16c67 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -299,35 +299,76 @@ static struct sk_buff *page_to_skb(struct receive_queue *rq, | |||
299 | return skb; | 299 | return skb; |
300 | } | 300 | } |
301 | 301 | ||
302 | static int receive_mergeable(struct receive_queue *rq, struct sk_buff *head_skb) | 302 | static struct sk_buff *receive_small(void *buf, unsigned int len) |
303 | { | 303 | { |
304 | struct skb_vnet_hdr *hdr = skb_vnet_hdr(head_skb); | 304 | struct sk_buff * skb = buf; |
305 | |||
306 | len -= sizeof(struct virtio_net_hdr); | ||
307 | skb_trim(skb, len); | ||
308 | |||
309 | return skb; | ||
310 | } | ||
311 | |||
312 | static struct sk_buff *receive_big(struct net_device *dev, | ||
313 | struct receive_queue *rq, | ||
314 | void *buf, | ||
315 | unsigned int len) | ||
316 | { | ||
317 | struct page *page = buf; | ||
318 | struct sk_buff *skb = page_to_skb(rq, page, 0, len, PAGE_SIZE); | ||
319 | |||
320 | if (unlikely(!skb)) | ||
321 | goto err; | ||
322 | |||
323 | return skb; | ||
324 | |||
325 | err: | ||
326 | dev->stats.rx_dropped++; | ||
327 | give_pages(rq, page); | ||
328 | return NULL; | ||
329 | } | ||
330 | |||
331 | static struct sk_buff *receive_mergeable(struct net_device *dev, | ||
332 | struct receive_queue *rq, | ||
333 | void *buf, | ||
334 | unsigned int len) | ||
335 | { | ||
336 | struct skb_vnet_hdr *hdr = buf; | ||
337 | int num_buf = hdr->mhdr.num_buffers; | ||
338 | struct page *page = virt_to_head_page(buf); | ||
339 | int offset = buf - page_address(page); | ||
340 | struct sk_buff *head_skb = page_to_skb(rq, page, offset, len, | ||
341 | MERGE_BUFFER_LEN); | ||
305 | struct sk_buff *curr_skb = head_skb; | 342 | struct sk_buff *curr_skb = head_skb; |
306 | char *buf; | ||
307 | struct page *page; | ||
308 | int num_buf, len, offset; | ||
309 | 343 | ||
310 | num_buf = hdr->mhdr.num_buffers; | 344 | if (unlikely(!curr_skb)) |
345 | goto err_skb; | ||
346 | |||
311 | while (--num_buf) { | 347 | while (--num_buf) { |
312 | int num_skb_frags = skb_shinfo(curr_skb)->nr_frags; | 348 | int num_skb_frags; |
349 | |||
313 | buf = virtqueue_get_buf(rq->vq, &len); | 350 | buf = virtqueue_get_buf(rq->vq, &len); |
314 | if (unlikely(!buf)) { | 351 | if (unlikely(!buf)) { |
315 | pr_debug("%s: rx error: %d buffers missing\n", | 352 | pr_debug("%s: rx error: %d buffers out of %d missing\n", |
316 | head_skb->dev->name, hdr->mhdr.num_buffers); | 353 | dev->name, num_buf, hdr->mhdr.num_buffers); |
317 | head_skb->dev->stats.rx_length_errors++; | 354 | dev->stats.rx_length_errors++; |
318 | return -EINVAL; | 355 | goto err_buf; |
319 | } | 356 | } |
320 | if (unlikely(len > MERGE_BUFFER_LEN)) { | 357 | if (unlikely(len > MERGE_BUFFER_LEN)) { |
321 | pr_debug("%s: rx error: merge buffer too long\n", | 358 | pr_debug("%s: rx error: merge buffer too long\n", |
322 | head_skb->dev->name); | 359 | dev->name); |
323 | len = MERGE_BUFFER_LEN; | 360 | len = MERGE_BUFFER_LEN; |
324 | } | 361 | } |
362 | |||
363 | page = virt_to_head_page(buf); | ||
364 | --rq->num; | ||
365 | |||
366 | num_skb_frags = skb_shinfo(curr_skb)->nr_frags; | ||
325 | if (unlikely(num_skb_frags == MAX_SKB_FRAGS)) { | 367 | if (unlikely(num_skb_frags == MAX_SKB_FRAGS)) { |
326 | struct sk_buff *nskb = alloc_skb(0, GFP_ATOMIC); | 368 | struct sk_buff *nskb = alloc_skb(0, GFP_ATOMIC); |
327 | if (unlikely(!nskb)) { | 369 | |
328 | head_skb->dev->stats.rx_dropped++; | 370 | if (unlikely(!nskb)) |
329 | return -ENOMEM; | 371 | goto err_skb; |
330 | } | ||
331 | if (curr_skb == head_skb) | 372 | if (curr_skb == head_skb) |
332 | skb_shinfo(curr_skb)->frag_list = nskb; | 373 | skb_shinfo(curr_skb)->frag_list = nskb; |
333 | else | 374 | else |
@@ -341,8 +382,7 @@ static int receive_mergeable(struct receive_queue *rq, struct sk_buff *head_skb) | |||
341 | head_skb->len += len; | 382 | head_skb->len += len; |
342 | head_skb->truesize += MERGE_BUFFER_LEN; | 383 | head_skb->truesize += MERGE_BUFFER_LEN; |
343 | } | 384 | } |
344 | page = virt_to_head_page(buf); | 385 | offset = buf - page_address(page); |
345 | offset = buf - (char *)page_address(page); | ||
346 | if (skb_can_coalesce(curr_skb, num_skb_frags, page, offset)) { | 386 | if (skb_can_coalesce(curr_skb, num_skb_frags, page, offset)) { |
347 | put_page(page); | 387 | put_page(page); |
348 | skb_coalesce_rx_frag(curr_skb, num_skb_frags - 1, | 388 | skb_coalesce_rx_frag(curr_skb, num_skb_frags - 1, |
@@ -351,9 +391,28 @@ static int receive_mergeable(struct receive_queue *rq, struct sk_buff *head_skb) | |||
351 | skb_add_rx_frag(curr_skb, num_skb_frags, page, | 391 | skb_add_rx_frag(curr_skb, num_skb_frags, page, |
352 | offset, len, MERGE_BUFFER_LEN); | 392 | offset, len, MERGE_BUFFER_LEN); |
353 | } | 393 | } |
394 | } | ||
395 | |||
396 | return head_skb; | ||
397 | |||
398 | err_skb: | ||
399 | put_page(page); | ||
400 | while (--num_buf) { | ||
401 | buf = virtqueue_get_buf(rq->vq, &len); | ||
402 | if (unlikely(!buf)) { | ||
403 | pr_debug("%s: rx error: %d buffers missing\n", | ||
404 | dev->name, num_buf); | ||
405 | dev->stats.rx_length_errors++; | ||
406 | break; | ||
407 | } | ||
408 | page = virt_to_head_page(buf); | ||
409 | put_page(page); | ||
354 | --rq->num; | 410 | --rq->num; |
355 | } | 411 | } |
356 | return 0; | 412 | err_buf: |
413 | dev->stats.rx_dropped++; | ||
414 | dev_kfree_skb(head_skb); | ||
415 | return NULL; | ||
357 | } | 416 | } |
358 | 417 | ||
359 | static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len) | 418 | static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len) |
@@ -362,7 +421,6 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len) | |||
362 | struct net_device *dev = vi->dev; | 421 | struct net_device *dev = vi->dev; |
363 | struct virtnet_stats *stats = this_cpu_ptr(vi->stats); | 422 | struct virtnet_stats *stats = this_cpu_ptr(vi->stats); |
364 | struct sk_buff *skb; | 423 | struct sk_buff *skb; |
365 | struct page *page; | ||
366 | struct skb_vnet_hdr *hdr; | 424 | struct skb_vnet_hdr *hdr; |
367 | 425 | ||
368 | if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) { | 426 | if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) { |
@@ -377,33 +435,15 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len) | |||
377 | return; | 435 | return; |
378 | } | 436 | } |
379 | 437 | ||
380 | if (!vi->mergeable_rx_bufs && !vi->big_packets) { | 438 | if (vi->mergeable_rx_bufs) |
381 | skb = buf; | 439 | skb = receive_mergeable(dev, rq, buf, len); |
382 | len -= sizeof(struct virtio_net_hdr); | 440 | else if (vi->big_packets) |
383 | skb_trim(skb, len); | 441 | skb = receive_big(dev, rq, buf, len); |
384 | } else if (vi->mergeable_rx_bufs) { | 442 | else |
385 | struct page *page = virt_to_head_page(buf); | 443 | skb = receive_small(buf, len); |
386 | skb = page_to_skb(rq, page, | 444 | |
387 | (char *)buf - (char *)page_address(page), | 445 | if (unlikely(!skb)) |
388 | len, MERGE_BUFFER_LEN); | 446 | return; |
389 | if (unlikely(!skb)) { | ||
390 | dev->stats.rx_dropped++; | ||
391 | put_page(page); | ||
392 | return; | ||
393 | } | ||
394 | if (receive_mergeable(rq, skb)) { | ||
395 | dev_kfree_skb(skb); | ||
396 | return; | ||
397 | } | ||
398 | } else { | ||
399 | page = buf; | ||
400 | skb = page_to_skb(rq, page, 0, len, PAGE_SIZE); | ||
401 | if (unlikely(!skb)) { | ||
402 | dev->stats.rx_dropped++; | ||
403 | give_pages(rq, page); | ||
404 | return; | ||
405 | } | ||
406 | } | ||
407 | 447 | ||
408 | hdr = skb_vnet_hdr(skb); | 448 | hdr = skb_vnet_hdr(skb); |
409 | 449 | ||
@@ -1084,7 +1124,7 @@ static void virtnet_set_rx_mode(struct net_device *dev) | |||
1084 | if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MAC, | 1124 | if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MAC, |
1085 | VIRTIO_NET_CTRL_MAC_TABLE_SET, | 1125 | VIRTIO_NET_CTRL_MAC_TABLE_SET, |
1086 | sg, NULL)) | 1126 | sg, NULL)) |
1087 | dev_warn(&dev->dev, "Failed to set MAC fitler table.\n"); | 1127 | dev_warn(&dev->dev, "Failed to set MAC filter table.\n"); |
1088 | 1128 | ||
1089 | kfree(buf); | 1129 | kfree(buf); |
1090 | } | 1130 | } |
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 919b6509455c..64f0e0d18b81 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/udp.h> | 39 | #include <linux/udp.h> |
40 | 40 | ||
41 | #include <net/tcp.h> | 41 | #include <net/tcp.h> |
42 | #include <net/ip6_checksum.h> | ||
42 | 43 | ||
43 | #include <xen/xen.h> | 44 | #include <xen/xen.h> |
44 | #include <xen/events.h> | 45 | #include <xen/events.h> |
diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c index 1cb6e51e6bda..170e8e60cdb7 100644 --- a/drivers/ntb/ntb_hw.c +++ b/drivers/ntb/ntb_hw.c | |||
@@ -141,6 +141,24 @@ void ntb_unregister_event_callback(struct ntb_device *ndev) | |||
141 | ndev->event_cb = NULL; | 141 | ndev->event_cb = NULL; |
142 | } | 142 | } |
143 | 143 | ||
144 | static void ntb_irq_work(unsigned long data) | ||
145 | { | ||
146 | struct ntb_db_cb *db_cb = (struct ntb_db_cb *)data; | ||
147 | int rc; | ||
148 | |||
149 | rc = db_cb->callback(db_cb->data, db_cb->db_num); | ||
150 | if (rc) | ||
151 | tasklet_schedule(&db_cb->irq_work); | ||
152 | else { | ||
153 | struct ntb_device *ndev = db_cb->ndev; | ||
154 | unsigned long mask; | ||
155 | |||
156 | mask = readw(ndev->reg_ofs.ldb_mask); | ||
157 | clear_bit(db_cb->db_num * ndev->bits_per_vector, &mask); | ||
158 | writew(mask, ndev->reg_ofs.ldb_mask); | ||
159 | } | ||
160 | } | ||
161 | |||
144 | /** | 162 | /** |
145 | * ntb_register_db_callback() - register a callback for doorbell interrupt | 163 | * ntb_register_db_callback() - register a callback for doorbell interrupt |
146 | * @ndev: pointer to ntb_device instance | 164 | * @ndev: pointer to ntb_device instance |
@@ -155,7 +173,7 @@ void ntb_unregister_event_callback(struct ntb_device *ndev) | |||
155 | * RETURNS: An appropriate -ERRNO error value on error, or zero for success. | 173 | * RETURNS: An appropriate -ERRNO error value on error, or zero for success. |
156 | */ | 174 | */ |
157 | int ntb_register_db_callback(struct ntb_device *ndev, unsigned int idx, | 175 | int ntb_register_db_callback(struct ntb_device *ndev, unsigned int idx, |
158 | void *data, void (*func)(void *data, int db_num)) | 176 | void *data, int (*func)(void *data, int db_num)) |
159 | { | 177 | { |
160 | unsigned long mask; | 178 | unsigned long mask; |
161 | 179 | ||
@@ -166,6 +184,10 @@ int ntb_register_db_callback(struct ntb_device *ndev, unsigned int idx, | |||
166 | 184 | ||
167 | ndev->db_cb[idx].callback = func; | 185 | ndev->db_cb[idx].callback = func; |
168 | ndev->db_cb[idx].data = data; | 186 | ndev->db_cb[idx].data = data; |
187 | ndev->db_cb[idx].ndev = ndev; | ||
188 | |||
189 | tasklet_init(&ndev->db_cb[idx].irq_work, ntb_irq_work, | ||
190 | (unsigned long) &ndev->db_cb[idx]); | ||
169 | 191 | ||
170 | /* unmask interrupt */ | 192 | /* unmask interrupt */ |
171 | mask = readw(ndev->reg_ofs.ldb_mask); | 193 | mask = readw(ndev->reg_ofs.ldb_mask); |
@@ -194,6 +216,8 @@ void ntb_unregister_db_callback(struct ntb_device *ndev, unsigned int idx) | |||
194 | set_bit(idx * ndev->bits_per_vector, &mask); | 216 | set_bit(idx * ndev->bits_per_vector, &mask); |
195 | writew(mask, ndev->reg_ofs.ldb_mask); | 217 | writew(mask, ndev->reg_ofs.ldb_mask); |
196 | 218 | ||
219 | tasklet_disable(&ndev->db_cb[idx].irq_work); | ||
220 | |||
197 | ndev->db_cb[idx].callback = NULL; | 221 | ndev->db_cb[idx].callback = NULL; |
198 | } | 222 | } |
199 | 223 | ||
@@ -678,6 +702,7 @@ static int ntb_xeon_setup(struct ntb_device *ndev) | |||
678 | return -EINVAL; | 702 | return -EINVAL; |
679 | 703 | ||
680 | ndev->limits.max_mw = SNB_ERRATA_MAX_MW; | 704 | ndev->limits.max_mw = SNB_ERRATA_MAX_MW; |
705 | ndev->limits.max_db_bits = SNB_MAX_DB_BITS; | ||
681 | ndev->reg_ofs.spad_write = ndev->mw[1].vbase + | 706 | ndev->reg_ofs.spad_write = ndev->mw[1].vbase + |
682 | SNB_SPAD_OFFSET; | 707 | SNB_SPAD_OFFSET; |
683 | ndev->reg_ofs.rdb = ndev->mw[1].vbase + | 708 | ndev->reg_ofs.rdb = ndev->mw[1].vbase + |
@@ -688,8 +713,21 @@ static int ntb_xeon_setup(struct ntb_device *ndev) | |||
688 | */ | 713 | */ |
689 | writeq(ndev->mw[1].bar_sz + 0x1000, ndev->reg_base + | 714 | writeq(ndev->mw[1].bar_sz + 0x1000, ndev->reg_base + |
690 | SNB_PBAR4LMT_OFFSET); | 715 | SNB_PBAR4LMT_OFFSET); |
716 | /* HW errata on the Limit registers. They can only be | ||
717 | * written when the base register is 4GB aligned and | ||
718 | * < 32bit. This should already be the case based on the | ||
719 | * driver defaults, but write the Limit registers first | ||
720 | * just in case. | ||
721 | */ | ||
691 | } else { | 722 | } else { |
692 | ndev->limits.max_mw = SNB_MAX_MW; | 723 | ndev->limits.max_mw = SNB_MAX_MW; |
724 | |||
725 | /* HW Errata on bit 14 of b2bdoorbell register. Writes | ||
726 | * will not be mirrored to the remote system. Shrink | ||
727 | * the number of bits by one, since bit 14 is the last | ||
728 | * bit. | ||
729 | */ | ||
730 | ndev->limits.max_db_bits = SNB_MAX_DB_BITS - 1; | ||
693 | ndev->reg_ofs.spad_write = ndev->reg_base + | 731 | ndev->reg_ofs.spad_write = ndev->reg_base + |
694 | SNB_B2B_SPAD_OFFSET; | 732 | SNB_B2B_SPAD_OFFSET; |
695 | ndev->reg_ofs.rdb = ndev->reg_base + | 733 | ndev->reg_ofs.rdb = ndev->reg_base + |
@@ -699,6 +737,12 @@ static int ntb_xeon_setup(struct ntb_device *ndev) | |||
699 | * something silly | 737 | * something silly |
700 | */ | 738 | */ |
701 | writeq(0, ndev->reg_base + SNB_PBAR4LMT_OFFSET); | 739 | writeq(0, ndev->reg_base + SNB_PBAR4LMT_OFFSET); |
740 | /* HW errata on the Limit registers. They can only be | ||
741 | * written when the base register is 4GB aligned and | ||
742 | * < 32bit. This should already be the case based on the | ||
743 | * driver defaults, but write the Limit registers first | ||
744 | * just in case. | ||
745 | */ | ||
702 | } | 746 | } |
703 | 747 | ||
704 | /* The Xeon errata workaround requires setting SBAR Base | 748 | /* The Xeon errata workaround requires setting SBAR Base |
@@ -769,6 +813,7 @@ static int ntb_xeon_setup(struct ntb_device *ndev) | |||
769 | * have an equal amount. | 813 | * have an equal amount. |
770 | */ | 814 | */ |
771 | ndev->limits.max_spads = SNB_MAX_COMPAT_SPADS / 2; | 815 | ndev->limits.max_spads = SNB_MAX_COMPAT_SPADS / 2; |
816 | ndev->limits.max_db_bits = SNB_MAX_DB_BITS; | ||
772 | /* Note: The SDOORBELL is the cause of the errata. You REALLY | 817 | /* Note: The SDOORBELL is the cause of the errata. You REALLY |
773 | * don't want to touch it. | 818 | * don't want to touch it. |
774 | */ | 819 | */ |
@@ -793,6 +838,7 @@ static int ntb_xeon_setup(struct ntb_device *ndev) | |||
793 | * have an equal amount. | 838 | * have an equal amount. |
794 | */ | 839 | */ |
795 | ndev->limits.max_spads = SNB_MAX_COMPAT_SPADS / 2; | 840 | ndev->limits.max_spads = SNB_MAX_COMPAT_SPADS / 2; |
841 | ndev->limits.max_db_bits = SNB_MAX_DB_BITS; | ||
796 | ndev->reg_ofs.rdb = ndev->reg_base + SNB_PDOORBELL_OFFSET; | 842 | ndev->reg_ofs.rdb = ndev->reg_base + SNB_PDOORBELL_OFFSET; |
797 | ndev->reg_ofs.ldb = ndev->reg_base + SNB_SDOORBELL_OFFSET; | 843 | ndev->reg_ofs.ldb = ndev->reg_base + SNB_SDOORBELL_OFFSET; |
798 | ndev->reg_ofs.ldb_mask = ndev->reg_base + SNB_SDBMSK_OFFSET; | 844 | ndev->reg_ofs.ldb_mask = ndev->reg_base + SNB_SDBMSK_OFFSET; |
@@ -819,7 +865,6 @@ static int ntb_xeon_setup(struct ntb_device *ndev) | |||
819 | ndev->reg_ofs.lnk_stat = ndev->reg_base + SNB_SLINK_STATUS_OFFSET; | 865 | ndev->reg_ofs.lnk_stat = ndev->reg_base + SNB_SLINK_STATUS_OFFSET; |
820 | ndev->reg_ofs.spci_cmd = ndev->reg_base + SNB_PCICMD_OFFSET; | 866 | ndev->reg_ofs.spci_cmd = ndev->reg_base + SNB_PCICMD_OFFSET; |
821 | 867 | ||
822 | ndev->limits.max_db_bits = SNB_MAX_DB_BITS; | ||
823 | ndev->limits.msix_cnt = SNB_MSIX_CNT; | 868 | ndev->limits.msix_cnt = SNB_MSIX_CNT; |
824 | ndev->bits_per_vector = SNB_DB_BITS_PER_VEC; | 869 | ndev->bits_per_vector = SNB_DB_BITS_PER_VEC; |
825 | 870 | ||
@@ -934,12 +979,16 @@ static irqreturn_t bwd_callback_msix_irq(int irq, void *data) | |||
934 | { | 979 | { |
935 | struct ntb_db_cb *db_cb = data; | 980 | struct ntb_db_cb *db_cb = data; |
936 | struct ntb_device *ndev = db_cb->ndev; | 981 | struct ntb_device *ndev = db_cb->ndev; |
982 | unsigned long mask; | ||
937 | 983 | ||
938 | dev_dbg(&ndev->pdev->dev, "MSI-X irq %d received for DB %d\n", irq, | 984 | dev_dbg(&ndev->pdev->dev, "MSI-X irq %d received for DB %d\n", irq, |
939 | db_cb->db_num); | 985 | db_cb->db_num); |
940 | 986 | ||
941 | if (db_cb->callback) | 987 | mask = readw(ndev->reg_ofs.ldb_mask); |
942 | db_cb->callback(db_cb->data, db_cb->db_num); | 988 | set_bit(db_cb->db_num * ndev->bits_per_vector, &mask); |
989 | writew(mask, ndev->reg_ofs.ldb_mask); | ||
990 | |||
991 | tasklet_schedule(&db_cb->irq_work); | ||
943 | 992 | ||
944 | /* No need to check for the specific HB irq, any interrupt means | 993 | /* No need to check for the specific HB irq, any interrupt means |
945 | * we're connected. | 994 | * we're connected. |
@@ -955,12 +1004,16 @@ static irqreturn_t xeon_callback_msix_irq(int irq, void *data) | |||
955 | { | 1004 | { |
956 | struct ntb_db_cb *db_cb = data; | 1005 | struct ntb_db_cb *db_cb = data; |
957 | struct ntb_device *ndev = db_cb->ndev; | 1006 | struct ntb_device *ndev = db_cb->ndev; |
1007 | unsigned long mask; | ||
958 | 1008 | ||
959 | dev_dbg(&ndev->pdev->dev, "MSI-X irq %d received for DB %d\n", irq, | 1009 | dev_dbg(&ndev->pdev->dev, "MSI-X irq %d received for DB %d\n", irq, |
960 | db_cb->db_num); | 1010 | db_cb->db_num); |
961 | 1011 | ||
962 | if (db_cb->callback) | 1012 | mask = readw(ndev->reg_ofs.ldb_mask); |
963 | db_cb->callback(db_cb->data, db_cb->db_num); | 1013 | set_bit(db_cb->db_num * ndev->bits_per_vector, &mask); |
1014 | writew(mask, ndev->reg_ofs.ldb_mask); | ||
1015 | |||
1016 | tasklet_schedule(&db_cb->irq_work); | ||
964 | 1017 | ||
965 | /* On Sandybridge, there are 16 bits in the interrupt register | 1018 | /* On Sandybridge, there are 16 bits in the interrupt register |
966 | * but only 4 vectors. So, 5 bits are assigned to the first 3 | 1019 | * but only 4 vectors. So, 5 bits are assigned to the first 3 |
@@ -986,7 +1039,7 @@ static irqreturn_t xeon_event_msix_irq(int irq, void *dev) | |||
986 | dev_err(&ndev->pdev->dev, "Error determining link status\n"); | 1039 | dev_err(&ndev->pdev->dev, "Error determining link status\n"); |
987 | 1040 | ||
988 | /* bit 15 is always the link bit */ | 1041 | /* bit 15 is always the link bit */ |
989 | writew(1 << ndev->limits.max_db_bits, ndev->reg_ofs.ldb); | 1042 | writew(1 << SNB_LINK_DB, ndev->reg_ofs.ldb); |
990 | 1043 | ||
991 | return IRQ_HANDLED; | 1044 | return IRQ_HANDLED; |
992 | } | 1045 | } |
@@ -1075,6 +1128,10 @@ static int ntb_setup_msix(struct ntb_device *ndev) | |||
1075 | "Only %d MSI-X vectors. Limiting the number of queues to that number.\n", | 1128 | "Only %d MSI-X vectors. Limiting the number of queues to that number.\n", |
1076 | rc); | 1129 | rc); |
1077 | msix_entries = rc; | 1130 | msix_entries = rc; |
1131 | |||
1132 | rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries); | ||
1133 | if (rc) | ||
1134 | goto err1; | ||
1078 | } | 1135 | } |
1079 | 1136 | ||
1080 | for (i = 0; i < msix_entries; i++) { | 1137 | for (i = 0; i < msix_entries; i++) { |
@@ -1176,9 +1233,10 @@ static int ntb_setup_interrupts(struct ntb_device *ndev) | |||
1176 | */ | 1233 | */ |
1177 | if (ndev->hw_type == BWD_HW) | 1234 | if (ndev->hw_type == BWD_HW) |
1178 | writeq(~0, ndev->reg_ofs.ldb_mask); | 1235 | writeq(~0, ndev->reg_ofs.ldb_mask); |
1179 | else | 1236 | else { |
1180 | writew(~(1 << ndev->limits.max_db_bits), | 1237 | u16 var = 1 << SNB_LINK_DB; |
1181 | ndev->reg_ofs.ldb_mask); | 1238 | writew(~var, ndev->reg_ofs.ldb_mask); |
1239 | } | ||
1182 | 1240 | ||
1183 | rc = ntb_setup_msix(ndev); | 1241 | rc = ntb_setup_msix(ndev); |
1184 | if (!rc) | 1242 | if (!rc) |
@@ -1286,6 +1344,39 @@ static void ntb_free_debugfs(struct ntb_device *ndev) | |||
1286 | } | 1344 | } |
1287 | } | 1345 | } |
1288 | 1346 | ||
1347 | static void ntb_hw_link_up(struct ntb_device *ndev) | ||
1348 | { | ||
1349 | if (ndev->conn_type == NTB_CONN_TRANSPARENT) | ||
1350 | ntb_link_event(ndev, NTB_LINK_UP); | ||
1351 | else { | ||
1352 | u32 ntb_cntl; | ||
1353 | |||
1354 | /* Let's bring the NTB link up */ | ||
1355 | ntb_cntl = readl(ndev->reg_ofs.lnk_cntl); | ||
1356 | ntb_cntl &= ~(NTB_CNTL_LINK_DISABLE | NTB_CNTL_CFG_LOCK); | ||
1357 | ntb_cntl |= NTB_CNTL_P2S_BAR23_SNOOP | NTB_CNTL_S2P_BAR23_SNOOP; | ||
1358 | ntb_cntl |= NTB_CNTL_P2S_BAR45_SNOOP | NTB_CNTL_S2P_BAR45_SNOOP; | ||
1359 | writel(ntb_cntl, ndev->reg_ofs.lnk_cntl); | ||
1360 | } | ||
1361 | } | ||
1362 | |||
1363 | static void ntb_hw_link_down(struct ntb_device *ndev) | ||
1364 | { | ||
1365 | u32 ntb_cntl; | ||
1366 | |||
1367 | if (ndev->conn_type == NTB_CONN_TRANSPARENT) { | ||
1368 | ntb_link_event(ndev, NTB_LINK_DOWN); | ||
1369 | return; | ||
1370 | } | ||
1371 | |||
1372 | /* Bring NTB link down */ | ||
1373 | ntb_cntl = readl(ndev->reg_ofs.lnk_cntl); | ||
1374 | ntb_cntl &= ~(NTB_CNTL_P2S_BAR23_SNOOP | NTB_CNTL_S2P_BAR23_SNOOP); | ||
1375 | ntb_cntl &= ~(NTB_CNTL_P2S_BAR45_SNOOP | NTB_CNTL_S2P_BAR45_SNOOP); | ||
1376 | ntb_cntl |= NTB_CNTL_LINK_DISABLE | NTB_CNTL_CFG_LOCK; | ||
1377 | writel(ntb_cntl, ndev->reg_ofs.lnk_cntl); | ||
1378 | } | ||
1379 | |||
1289 | static int ntb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 1380 | static int ntb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
1290 | { | 1381 | { |
1291 | struct ntb_device *ndev; | 1382 | struct ntb_device *ndev; |
@@ -1374,9 +1465,7 @@ static int ntb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1374 | if (rc) | 1465 | if (rc) |
1375 | goto err6; | 1466 | goto err6; |
1376 | 1467 | ||
1377 | /* Let's bring the NTB link up */ | 1468 | ntb_hw_link_up(ndev); |
1378 | writel(NTB_CNTL_BAR23_SNOOP | NTB_CNTL_BAR45_SNOOP, | ||
1379 | ndev->reg_ofs.lnk_cntl); | ||
1380 | 1469 | ||
1381 | return 0; | 1470 | return 0; |
1382 | 1471 | ||
@@ -1406,12 +1495,8 @@ static void ntb_pci_remove(struct pci_dev *pdev) | |||
1406 | { | 1495 | { |
1407 | struct ntb_device *ndev = pci_get_drvdata(pdev); | 1496 | struct ntb_device *ndev = pci_get_drvdata(pdev); |
1408 | int i; | 1497 | int i; |
1409 | u32 ntb_cntl; | ||
1410 | 1498 | ||
1411 | /* Bring NTB link down */ | 1499 | ntb_hw_link_down(ndev); |
1412 | ntb_cntl = readl(ndev->reg_ofs.lnk_cntl); | ||
1413 | ntb_cntl |= NTB_CNTL_LINK_DISABLE; | ||
1414 | writel(ntb_cntl, ndev->reg_ofs.lnk_cntl); | ||
1415 | 1500 | ||
1416 | ntb_transport_free(ndev->ntb_transport); | 1501 | ntb_transport_free(ndev->ntb_transport); |
1417 | 1502 | ||
diff --git a/drivers/ntb/ntb_hw.h b/drivers/ntb/ntb_hw.h index 0a31cedae7d4..bbdb7edca10c 100644 --- a/drivers/ntb/ntb_hw.h +++ b/drivers/ntb/ntb_hw.h | |||
@@ -106,10 +106,11 @@ struct ntb_mw { | |||
106 | }; | 106 | }; |
107 | 107 | ||
108 | struct ntb_db_cb { | 108 | struct ntb_db_cb { |
109 | void (*callback) (void *data, int db_num); | 109 | int (*callback)(void *data, int db_num); |
110 | unsigned int db_num; | 110 | unsigned int db_num; |
111 | void *data; | 111 | void *data; |
112 | struct ntb_device *ndev; | 112 | struct ntb_device *ndev; |
113 | struct tasklet_struct irq_work; | ||
113 | }; | 114 | }; |
114 | 115 | ||
115 | struct ntb_device { | 116 | struct ntb_device { |
@@ -228,8 +229,8 @@ struct ntb_device *ntb_register_transport(struct pci_dev *pdev, | |||
228 | void ntb_unregister_transport(struct ntb_device *ndev); | 229 | void ntb_unregister_transport(struct ntb_device *ndev); |
229 | void ntb_set_mw_addr(struct ntb_device *ndev, unsigned int mw, u64 addr); | 230 | void ntb_set_mw_addr(struct ntb_device *ndev, unsigned int mw, u64 addr); |
230 | int ntb_register_db_callback(struct ntb_device *ndev, unsigned int idx, | 231 | int ntb_register_db_callback(struct ntb_device *ndev, unsigned int idx, |
231 | void *data, void (*db_cb_func) (void *data, | 232 | void *data, int (*db_cb_func)(void *data, |
232 | int db_num)); | 233 | int db_num)); |
233 | void ntb_unregister_db_callback(struct ntb_device *ndev, unsigned int idx); | 234 | void ntb_unregister_db_callback(struct ntb_device *ndev, unsigned int idx); |
234 | int ntb_register_event_callback(struct ntb_device *ndev, | 235 | int ntb_register_event_callback(struct ntb_device *ndev, |
235 | void (*event_cb_func) (void *handle, | 236 | void (*event_cb_func) (void *handle, |
diff --git a/drivers/ntb/ntb_regs.h b/drivers/ntb/ntb_regs.h index aa4bdd393c58..9774506419d7 100644 --- a/drivers/ntb/ntb_regs.h +++ b/drivers/ntb/ntb_regs.h | |||
@@ -55,6 +55,7 @@ | |||
55 | #define SNB_MAX_COMPAT_SPADS 16 | 55 | #define SNB_MAX_COMPAT_SPADS 16 |
56 | /* Reserve the uppermost bit for link interrupt */ | 56 | /* Reserve the uppermost bit for link interrupt */ |
57 | #define SNB_MAX_DB_BITS 15 | 57 | #define SNB_MAX_DB_BITS 15 |
58 | #define SNB_LINK_DB 15 | ||
58 | #define SNB_DB_BITS_PER_VEC 5 | 59 | #define SNB_DB_BITS_PER_VEC 5 |
59 | #define SNB_MAX_MW 2 | 60 | #define SNB_MAX_MW 2 |
60 | #define SNB_ERRATA_MAX_MW 1 | 61 | #define SNB_ERRATA_MAX_MW 1 |
@@ -75,9 +76,6 @@ | |||
75 | #define SNB_SBAR2XLAT_OFFSET 0x0030 | 76 | #define SNB_SBAR2XLAT_OFFSET 0x0030 |
76 | #define SNB_SBAR4XLAT_OFFSET 0x0038 | 77 | #define SNB_SBAR4XLAT_OFFSET 0x0038 |
77 | #define SNB_SBAR0BASE_OFFSET 0x0040 | 78 | #define SNB_SBAR0BASE_OFFSET 0x0040 |
78 | #define SNB_SBAR0BASE_OFFSET 0x0040 | ||
79 | #define SNB_SBAR2BASE_OFFSET 0x0048 | ||
80 | #define SNB_SBAR4BASE_OFFSET 0x0050 | ||
81 | #define SNB_SBAR2BASE_OFFSET 0x0048 | 79 | #define SNB_SBAR2BASE_OFFSET 0x0048 |
82 | #define SNB_SBAR4BASE_OFFSET 0x0050 | 80 | #define SNB_SBAR4BASE_OFFSET 0x0050 |
83 | #define SNB_NTBCNTL_OFFSET 0x0058 | 81 | #define SNB_NTBCNTL_OFFSET 0x0058 |
@@ -145,11 +143,13 @@ | |||
145 | #define BWD_LTSSMSTATEJMP_FORCEDETECT (1 << 2) | 143 | #define BWD_LTSSMSTATEJMP_FORCEDETECT (1 << 2) |
146 | #define BWD_IBIST_ERR_OFLOW 0x7FFF7FFF | 144 | #define BWD_IBIST_ERR_OFLOW 0x7FFF7FFF |
147 | 145 | ||
148 | #define NTB_CNTL_CFG_LOCK (1 << 0) | 146 | #define NTB_CNTL_CFG_LOCK (1 << 0) |
149 | #define NTB_CNTL_LINK_DISABLE (1 << 1) | 147 | #define NTB_CNTL_LINK_DISABLE (1 << 1) |
150 | #define NTB_CNTL_BAR23_SNOOP (1 << 2) | 148 | #define NTB_CNTL_S2P_BAR23_SNOOP (1 << 2) |
151 | #define NTB_CNTL_BAR45_SNOOP (1 << 6) | 149 | #define NTB_CNTL_P2S_BAR23_SNOOP (1 << 4) |
152 | #define BWD_CNTL_LINK_DOWN (1 << 16) | 150 | #define NTB_CNTL_S2P_BAR45_SNOOP (1 << 6) |
151 | #define NTB_CNTL_P2S_BAR45_SNOOP (1 << 8) | ||
152 | #define BWD_CNTL_LINK_DOWN (1 << 16) | ||
153 | 153 | ||
154 | #define NTB_PPD_OFFSET 0x00D4 | 154 | #define NTB_PPD_OFFSET 0x00D4 |
155 | #define SNB_PPD_CONN_TYPE 0x0003 | 155 | #define SNB_PPD_CONN_TYPE 0x0003 |
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index d0222f13d154..3217f394d45b 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c | |||
@@ -119,7 +119,6 @@ struct ntb_transport_qp { | |||
119 | 119 | ||
120 | void (*rx_handler) (struct ntb_transport_qp *qp, void *qp_data, | 120 | void (*rx_handler) (struct ntb_transport_qp *qp, void *qp_data, |
121 | void *data, int len); | 121 | void *data, int len); |
122 | struct tasklet_struct rx_work; | ||
123 | struct list_head rx_pend_q; | 122 | struct list_head rx_pend_q; |
124 | struct list_head rx_free_q; | 123 | struct list_head rx_free_q; |
125 | spinlock_t ntb_rx_pend_q_lock; | 124 | spinlock_t ntb_rx_pend_q_lock; |
@@ -584,11 +583,8 @@ static int ntb_set_mw(struct ntb_transport *nt, int num_mw, unsigned int size) | |||
584 | return 0; | 583 | return 0; |
585 | } | 584 | } |
586 | 585 | ||
587 | static void ntb_qp_link_cleanup(struct work_struct *work) | 586 | static void ntb_qp_link_cleanup(struct ntb_transport_qp *qp) |
588 | { | 587 | { |
589 | struct ntb_transport_qp *qp = container_of(work, | ||
590 | struct ntb_transport_qp, | ||
591 | link_cleanup); | ||
592 | struct ntb_transport *nt = qp->transport; | 588 | struct ntb_transport *nt = qp->transport; |
593 | struct pci_dev *pdev = ntb_query_pdev(nt->ndev); | 589 | struct pci_dev *pdev = ntb_query_pdev(nt->ndev); |
594 | 590 | ||
@@ -602,6 +598,16 @@ static void ntb_qp_link_cleanup(struct work_struct *work) | |||
602 | 598 | ||
603 | dev_info(&pdev->dev, "qp %d: Link Down\n", qp->qp_num); | 599 | dev_info(&pdev->dev, "qp %d: Link Down\n", qp->qp_num); |
604 | qp->qp_link = NTB_LINK_DOWN; | 600 | qp->qp_link = NTB_LINK_DOWN; |
601 | } | ||
602 | |||
603 | static void ntb_qp_link_cleanup_work(struct work_struct *work) | ||
604 | { | ||
605 | struct ntb_transport_qp *qp = container_of(work, | ||
606 | struct ntb_transport_qp, | ||
607 | link_cleanup); | ||
608 | struct ntb_transport *nt = qp->transport; | ||
609 | |||
610 | ntb_qp_link_cleanup(qp); | ||
605 | 611 | ||
606 | if (nt->transport_link == NTB_LINK_UP) | 612 | if (nt->transport_link == NTB_LINK_UP) |
607 | schedule_delayed_work(&qp->link_work, | 613 | schedule_delayed_work(&qp->link_work, |
@@ -613,22 +619,20 @@ static void ntb_qp_link_down(struct ntb_transport_qp *qp) | |||
613 | schedule_work(&qp->link_cleanup); | 619 | schedule_work(&qp->link_cleanup); |
614 | } | 620 | } |
615 | 621 | ||
616 | static void ntb_transport_link_cleanup(struct work_struct *work) | 622 | static void ntb_transport_link_cleanup(struct ntb_transport *nt) |
617 | { | 623 | { |
618 | struct ntb_transport *nt = container_of(work, struct ntb_transport, | ||
619 | link_cleanup); | ||
620 | int i; | 624 | int i; |
621 | 625 | ||
626 | /* Pass along the info to any clients */ | ||
627 | for (i = 0; i < nt->max_qps; i++) | ||
628 | if (!test_bit(i, &nt->qp_bitmap)) | ||
629 | ntb_qp_link_cleanup(&nt->qps[i]); | ||
630 | |||
622 | if (nt->transport_link == NTB_LINK_DOWN) | 631 | if (nt->transport_link == NTB_LINK_DOWN) |
623 | cancel_delayed_work_sync(&nt->link_work); | 632 | cancel_delayed_work_sync(&nt->link_work); |
624 | else | 633 | else |
625 | nt->transport_link = NTB_LINK_DOWN; | 634 | nt->transport_link = NTB_LINK_DOWN; |
626 | 635 | ||
627 | /* Pass along the info to any clients */ | ||
628 | for (i = 0; i < nt->max_qps; i++) | ||
629 | if (!test_bit(i, &nt->qp_bitmap)) | ||
630 | ntb_qp_link_down(&nt->qps[i]); | ||
631 | |||
632 | /* The scratchpad registers keep the values if the remote side | 636 | /* The scratchpad registers keep the values if the remote side |
633 | * goes down, blast them now to give them a sane value the next | 637 | * goes down, blast them now to give them a sane value the next |
634 | * time they are accessed | 638 | * time they are accessed |
@@ -637,6 +641,14 @@ static void ntb_transport_link_cleanup(struct work_struct *work) | |||
637 | ntb_write_local_spad(nt->ndev, i, 0); | 641 | ntb_write_local_spad(nt->ndev, i, 0); |
638 | } | 642 | } |
639 | 643 | ||
644 | static void ntb_transport_link_cleanup_work(struct work_struct *work) | ||
645 | { | ||
646 | struct ntb_transport *nt = container_of(work, struct ntb_transport, | ||
647 | link_cleanup); | ||
648 | |||
649 | ntb_transport_link_cleanup(nt); | ||
650 | } | ||
651 | |||
640 | static void ntb_transport_event_callback(void *data, enum ntb_hw_event event) | 652 | static void ntb_transport_event_callback(void *data, enum ntb_hw_event event) |
641 | { | 653 | { |
642 | struct ntb_transport *nt = data; | 654 | struct ntb_transport *nt = data; |
@@ -880,7 +892,7 @@ static int ntb_transport_init_queue(struct ntb_transport *nt, | |||
880 | } | 892 | } |
881 | 893 | ||
882 | INIT_DELAYED_WORK(&qp->link_work, ntb_qp_link_work); | 894 | INIT_DELAYED_WORK(&qp->link_work, ntb_qp_link_work); |
883 | INIT_WORK(&qp->link_cleanup, ntb_qp_link_cleanup); | 895 | INIT_WORK(&qp->link_cleanup, ntb_qp_link_cleanup_work); |
884 | 896 | ||
885 | spin_lock_init(&qp->ntb_rx_pend_q_lock); | 897 | spin_lock_init(&qp->ntb_rx_pend_q_lock); |
886 | spin_lock_init(&qp->ntb_rx_free_q_lock); | 898 | spin_lock_init(&qp->ntb_rx_free_q_lock); |
@@ -936,7 +948,7 @@ int ntb_transport_init(struct pci_dev *pdev) | |||
936 | } | 948 | } |
937 | 949 | ||
938 | INIT_DELAYED_WORK(&nt->link_work, ntb_transport_link_work); | 950 | INIT_DELAYED_WORK(&nt->link_work, ntb_transport_link_work); |
939 | INIT_WORK(&nt->link_cleanup, ntb_transport_link_cleanup); | 951 | INIT_WORK(&nt->link_cleanup, ntb_transport_link_cleanup_work); |
940 | 952 | ||
941 | rc = ntb_register_event_callback(nt->ndev, | 953 | rc = ntb_register_event_callback(nt->ndev, |
942 | ntb_transport_event_callback); | 954 | ntb_transport_event_callback); |
@@ -972,7 +984,7 @@ void ntb_transport_free(void *transport) | |||
972 | struct ntb_device *ndev = nt->ndev; | 984 | struct ntb_device *ndev = nt->ndev; |
973 | int i; | 985 | int i; |
974 | 986 | ||
975 | nt->transport_link = NTB_LINK_DOWN; | 987 | ntb_transport_link_cleanup(nt); |
976 | 988 | ||
977 | /* verify that all the qp's are freed */ | 989 | /* verify that all the qp's are freed */ |
978 | for (i = 0; i < nt->max_qps; i++) { | 990 | for (i = 0; i < nt->max_qps; i++) { |
@@ -1188,11 +1200,14 @@ err: | |||
1188 | goto out; | 1200 | goto out; |
1189 | } | 1201 | } |
1190 | 1202 | ||
1191 | static void ntb_transport_rx(unsigned long data) | 1203 | static int ntb_transport_rxc_db(void *data, int db_num) |
1192 | { | 1204 | { |
1193 | struct ntb_transport_qp *qp = (struct ntb_transport_qp *)data; | 1205 | struct ntb_transport_qp *qp = data; |
1194 | int rc, i; | 1206 | int rc, i; |
1195 | 1207 | ||
1208 | dev_dbg(&ntb_query_pdev(qp->ndev)->dev, "%s: doorbell %d received\n", | ||
1209 | __func__, db_num); | ||
1210 | |||
1196 | /* Limit the number of packets processed in a single interrupt to | 1211 | /* Limit the number of packets processed in a single interrupt to |
1197 | * provide fairness to others | 1212 | * provide fairness to others |
1198 | */ | 1213 | */ |
@@ -1204,16 +1219,8 @@ static void ntb_transport_rx(unsigned long data) | |||
1204 | 1219 | ||
1205 | if (qp->dma_chan) | 1220 | if (qp->dma_chan) |
1206 | dma_async_issue_pending(qp->dma_chan); | 1221 | dma_async_issue_pending(qp->dma_chan); |
1207 | } | ||
1208 | |||
1209 | static void ntb_transport_rxc_db(void *data, int db_num) | ||
1210 | { | ||
1211 | struct ntb_transport_qp *qp = data; | ||
1212 | |||
1213 | dev_dbg(&ntb_query_pdev(qp->ndev)->dev, "%s: doorbell %d received\n", | ||
1214 | __func__, db_num); | ||
1215 | 1222 | ||
1216 | tasklet_schedule(&qp->rx_work); | 1223 | return i; |
1217 | } | 1224 | } |
1218 | 1225 | ||
1219 | static void ntb_tx_copy_callback(void *data) | 1226 | static void ntb_tx_copy_callback(void *data) |
@@ -1432,11 +1439,12 @@ ntb_transport_create_queue(void *data, struct pci_dev *pdev, | |||
1432 | qp->tx_handler = handlers->tx_handler; | 1439 | qp->tx_handler = handlers->tx_handler; |
1433 | qp->event_handler = handlers->event_handler; | 1440 | qp->event_handler = handlers->event_handler; |
1434 | 1441 | ||
1442 | dmaengine_get(); | ||
1435 | qp->dma_chan = dma_find_channel(DMA_MEMCPY); | 1443 | qp->dma_chan = dma_find_channel(DMA_MEMCPY); |
1436 | if (!qp->dma_chan) | 1444 | if (!qp->dma_chan) { |
1445 | dmaengine_put(); | ||
1437 | dev_info(&pdev->dev, "Unable to allocate DMA channel, using CPU instead\n"); | 1446 | dev_info(&pdev->dev, "Unable to allocate DMA channel, using CPU instead\n"); |
1438 | else | 1447 | } |
1439 | dmaengine_get(); | ||
1440 | 1448 | ||
1441 | for (i = 0; i < NTB_QP_DEF_NUM_ENTRIES; i++) { | 1449 | for (i = 0; i < NTB_QP_DEF_NUM_ENTRIES; i++) { |
1442 | entry = kzalloc(sizeof(struct ntb_queue_entry), GFP_ATOMIC); | 1450 | entry = kzalloc(sizeof(struct ntb_queue_entry), GFP_ATOMIC); |
@@ -1458,25 +1466,23 @@ ntb_transport_create_queue(void *data, struct pci_dev *pdev, | |||
1458 | &qp->tx_free_q); | 1466 | &qp->tx_free_q); |
1459 | } | 1467 | } |
1460 | 1468 | ||
1461 | tasklet_init(&qp->rx_work, ntb_transport_rx, (unsigned long) qp); | ||
1462 | |||
1463 | rc = ntb_register_db_callback(qp->ndev, free_queue, qp, | 1469 | rc = ntb_register_db_callback(qp->ndev, free_queue, qp, |
1464 | ntb_transport_rxc_db); | 1470 | ntb_transport_rxc_db); |
1465 | if (rc) | 1471 | if (rc) |
1466 | goto err3; | 1472 | goto err2; |
1467 | 1473 | ||
1468 | dev_info(&pdev->dev, "NTB Transport QP %d created\n", qp->qp_num); | 1474 | dev_info(&pdev->dev, "NTB Transport QP %d created\n", qp->qp_num); |
1469 | 1475 | ||
1470 | return qp; | 1476 | return qp; |
1471 | 1477 | ||
1472 | err3: | ||
1473 | tasklet_disable(&qp->rx_work); | ||
1474 | err2: | 1478 | err2: |
1475 | while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q))) | 1479 | while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q))) |
1476 | kfree(entry); | 1480 | kfree(entry); |
1477 | err1: | 1481 | err1: |
1478 | while ((entry = ntb_list_rm(&qp->ntb_rx_free_q_lock, &qp->rx_free_q))) | 1482 | while ((entry = ntb_list_rm(&qp->ntb_rx_free_q_lock, &qp->rx_free_q))) |
1479 | kfree(entry); | 1483 | kfree(entry); |
1484 | if (qp->dma_chan) | ||
1485 | dmaengine_put(); | ||
1480 | set_bit(free_queue, &nt->qp_bitmap); | 1486 | set_bit(free_queue, &nt->qp_bitmap); |
1481 | err: | 1487 | err: |
1482 | return NULL; | 1488 | return NULL; |
@@ -1515,7 +1521,6 @@ void ntb_transport_free_queue(struct ntb_transport_qp *qp) | |||
1515 | } | 1521 | } |
1516 | 1522 | ||
1517 | ntb_unregister_db_callback(qp->ndev, qp->qp_num); | 1523 | ntb_unregister_db_callback(qp->ndev, qp->qp_num); |
1518 | tasklet_disable(&qp->rx_work); | ||
1519 | 1524 | ||
1520 | cancel_delayed_work_sync(&qp->link_work); | 1525 | cancel_delayed_work_sync(&qp->link_work); |
1521 | 1526 | ||
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index b3b1b9aa8863..3a02717473ad 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -9,10 +9,6 @@ | |||
9 | * | 9 | * |
10 | * Init/reset quirks for USB host controllers should be in the | 10 | * Init/reset quirks for USB host controllers should be in the |
11 | * USB quirks file, where their drivers can access reuse it. | 11 | * USB quirks file, where their drivers can access reuse it. |
12 | * | ||
13 | * The bridge optimization stuff has been removed. If you really | ||
14 | * have a silly BIOS which is unable to set your host bridge right, | ||
15 | * use the PowerTweak utility (see http://powertweak.sourceforge.net). | ||
16 | */ | 12 | */ |
17 | 13 | ||
18 | #include <linux/types.h> | 14 | #include <linux/types.h> |
diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c index 4780959e11d4..5183e7bb8de3 100644 --- a/drivers/pinctrl/pinctrl-abx500.c +++ b/drivers/pinctrl/pinctrl-abx500.c | |||
@@ -418,7 +418,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip, | |||
418 | ret = abx500_gpio_set_bits(chip, | 418 | ret = abx500_gpio_set_bits(chip, |
419 | AB8500_GPIO_ALTFUN_REG, | 419 | AB8500_GPIO_ALTFUN_REG, |
420 | af.alt_bit1, | 420 | af.alt_bit1, |
421 | !!(af.alta_val && BIT(0))); | 421 | !!(af.alta_val & BIT(0))); |
422 | if (ret < 0) | 422 | if (ret < 0) |
423 | goto out; | 423 | goto out; |
424 | 424 | ||
@@ -439,7 +439,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip, | |||
439 | goto out; | 439 | goto out; |
440 | 440 | ||
441 | ret = abx500_gpio_set_bits(chip, AB8500_GPIO_ALTFUN_REG, | 441 | ret = abx500_gpio_set_bits(chip, AB8500_GPIO_ALTFUN_REG, |
442 | af.alt_bit1, !!(af.altb_val && BIT(0))); | 442 | af.alt_bit1, !!(af.altb_val & BIT(0))); |
443 | if (ret < 0) | 443 | if (ret < 0) |
444 | goto out; | 444 | goto out; |
445 | 445 | ||
@@ -462,7 +462,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip, | |||
462 | goto out; | 462 | goto out; |
463 | 463 | ||
464 | ret = abx500_gpio_set_bits(chip, AB8500_GPIO_ALTFUN_REG, | 464 | ret = abx500_gpio_set_bits(chip, AB8500_GPIO_ALTFUN_REG, |
465 | af.alt_bit2, !!(af.altc_val && BIT(1))); | 465 | af.alt_bit2, !!(af.altc_val & BIT(1))); |
466 | break; | 466 | break; |
467 | 467 | ||
468 | default: | 468 | default: |
diff --git a/drivers/pinctrl/pinctrl-abx500.h b/drivers/pinctrl/pinctrl-abx500.h index eeca8f973999..82293806e842 100644 --- a/drivers/pinctrl/pinctrl-abx500.h +++ b/drivers/pinctrl/pinctrl-abx500.h | |||
@@ -1,4 +1,4 @@ | |||
1 | #ifndef PINCTRL_PINCTRL_ABx5O0_H | 1 | #ifndef PINCTRL_PINCTRL_ABx500_H |
2 | #define PINCTRL_PINCTRL_ABx500_H | 2 | #define PINCTRL_PINCTRL_ABx500_H |
3 | 3 | ||
4 | /* Package definitions */ | 4 | /* Package definitions */ |
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index e939c28cbf1f..46dddc159286 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c | |||
@@ -504,6 +504,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank, | |||
504 | data |= (3 << bit); | 504 | data |= (3 << bit); |
505 | break; | 505 | break; |
506 | default: | 506 | default: |
507 | spin_unlock_irqrestore(&bank->slock, flags); | ||
507 | dev_err(info->dev, "unsupported pull setting %d\n", | 508 | dev_err(info->dev, "unsupported pull setting %d\n", |
508 | pull); | 509 | pull); |
509 | return -EINVAL; | 510 | return -EINVAL; |
@@ -1453,8 +1454,8 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) | |||
1453 | if (ctrl->type == RK3188) { | 1454 | if (ctrl->type == RK3188) { |
1454 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1455 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
1455 | info->reg_pull = devm_ioremap_resource(&pdev->dev, res); | 1456 | info->reg_pull = devm_ioremap_resource(&pdev->dev, res); |
1456 | if (IS_ERR(info->reg_base)) | 1457 | if (IS_ERR(info->reg_pull)) |
1457 | return PTR_ERR(info->reg_base); | 1458 | return PTR_ERR(info->reg_pull); |
1458 | } | 1459 | } |
1459 | 1460 | ||
1460 | ret = rockchip_gpiolib_register(pdev, info); | 1461 | ret = rockchip_gpiolib_register(pdev, info); |
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7740.c b/drivers/pinctrl/sh-pfc/pfc-r8a7740.c index 009174d07767..bc5eb453a45c 100644 --- a/drivers/pinctrl/sh-pfc/pfc-r8a7740.c +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7740.c | |||
@@ -3720,7 +3720,7 @@ static void __iomem *r8a7740_pinmux_portcr(struct sh_pfc *pfc, unsigned int pin) | |||
3720 | const struct r8a7740_portcr_group *group = | 3720 | const struct r8a7740_portcr_group *group = |
3721 | &r8a7740_portcr_offsets[i]; | 3721 | &r8a7740_portcr_offsets[i]; |
3722 | 3722 | ||
3723 | if (i <= group->end_pin) | 3723 | if (pin <= group->end_pin) |
3724 | return pfc->window->virt + group->offset + pin; | 3724 | return pfc->window->virt + group->offset + pin; |
3725 | } | 3725 | } |
3726 | 3726 | ||
diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7372.c b/drivers/pinctrl/sh-pfc/pfc-sh7372.c index 70b522d34821..cc097b693820 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7372.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7372.c | |||
@@ -2584,7 +2584,7 @@ static void __iomem *sh7372_pinmux_portcr(struct sh_pfc *pfc, unsigned int pin) | |||
2584 | const struct sh7372_portcr_group *group = | 2584 | const struct sh7372_portcr_group *group = |
2585 | &sh7372_portcr_offsets[i]; | 2585 | &sh7372_portcr_offsets[i]; |
2586 | 2586 | ||
2587 | if (i <= group->end_pin) | 2587 | if (pin <= group->end_pin) |
2588 | return pfc->window->virt + group->offset + pin; | 2588 | return pfc->window->virt + group->offset + pin; |
2589 | } | 2589 | } |
2590 | 2590 | ||
diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig index 69616aeaa966..09fde58b12e0 100644 --- a/drivers/platform/Kconfig +++ b/drivers/platform/Kconfig | |||
@@ -5,3 +5,4 @@ if GOLDFISH | |||
5 | source "drivers/platform/goldfish/Kconfig" | 5 | source "drivers/platform/goldfish/Kconfig" |
6 | endif | 6 | endif |
7 | 7 | ||
8 | source "drivers/platform/chrome/Kconfig" | ||
diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile index 8a44a4cd6d1e..3656b7b17b99 100644 --- a/drivers/platform/Makefile +++ b/drivers/platform/Makefile | |||
@@ -5,3 +5,4 @@ | |||
5 | obj-$(CONFIG_X86) += x86/ | 5 | obj-$(CONFIG_X86) += x86/ |
6 | obj-$(CONFIG_OLPC) += olpc/ | 6 | obj-$(CONFIG_OLPC) += olpc/ |
7 | obj-$(CONFIG_GOLDFISH) += goldfish/ | 7 | obj-$(CONFIG_GOLDFISH) += goldfish/ |
8 | obj-$(CONFIG_CHROME_PLATFORMS) += chrome/ | ||
diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig new file mode 100644 index 000000000000..b13303e75a34 --- /dev/null +++ b/drivers/platform/chrome/Kconfig | |||
@@ -0,0 +1,28 @@ | |||
1 | # | ||
2 | # Platform support for Chrome OS hardware (Chromebooks and Chromeboxes) | ||
3 | # | ||
4 | |||
5 | menuconfig CHROME_PLATFORMS | ||
6 | bool "Platform support for Chrome hardware" | ||
7 | depends on X86 | ||
8 | ---help--- | ||
9 | Say Y here to get to see options for platform support for | ||
10 | various Chromebooks and Chromeboxes. This option alone does | ||
11 | not add any kernel code. | ||
12 | |||
13 | If you say N, all options in this submenu will be skipped and disabled. | ||
14 | |||
15 | if CHROME_PLATFORMS | ||
16 | |||
17 | config CHROMEOS_LAPTOP | ||
18 | tristate "Chrome OS Laptop" | ||
19 | depends on I2C | ||
20 | depends on DMI | ||
21 | ---help--- | ||
22 | This driver instantiates i2c and smbus devices such as | ||
23 | light sensors and touchpads. | ||
24 | |||
25 | If you have a supported Chromebook, choose Y or M here. | ||
26 | The module will be called chromeos_laptop. | ||
27 | |||
28 | endif # CHROMEOS_PLATFORMS | ||
diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile new file mode 100644 index 000000000000..015e9195e226 --- /dev/null +++ b/drivers/platform/chrome/Makefile | |||
@@ -0,0 +1,2 @@ | |||
1 | |||
2 | obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o | ||
diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c index 3e5b4497a1d0..3e5b4497a1d0 100644 --- a/drivers/platform/x86/chromeos_laptop.c +++ b/drivers/platform/chrome/chromeos_laptop.c | |||
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index b51a7460cc49..d9dcd37b5a52 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -79,17 +79,6 @@ config ASUS_LAPTOP | |||
79 | 79 | ||
80 | If you have an ACPI-compatible ASUS laptop, say Y or M here. | 80 | If you have an ACPI-compatible ASUS laptop, say Y or M here. |
81 | 81 | ||
82 | config CHROMEOS_LAPTOP | ||
83 | tristate "Chrome OS Laptop" | ||
84 | depends on I2C | ||
85 | depends on DMI | ||
86 | ---help--- | ||
87 | This driver instantiates i2c and smbus devices such as | ||
88 | light sensors and touchpads. | ||
89 | |||
90 | If you have a supported Chromebook, choose Y or M here. | ||
91 | The module will be called chromeos_laptop. | ||
92 | |||
93 | config DELL_LAPTOP | 82 | config DELL_LAPTOP |
94 | tristate "Dell Laptop Extras" | 83 | tristate "Dell Laptop Extras" |
95 | depends on X86 | 84 | depends on X86 |
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 5dbe19324351..f0e6aa407ffb 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile | |||
@@ -50,7 +50,6 @@ obj-$(CONFIG_INTEL_MID_POWER_BUTTON) += intel_mid_powerbtn.o | |||
50 | obj-$(CONFIG_INTEL_OAKTRAIL) += intel_oaktrail.o | 50 | obj-$(CONFIG_INTEL_OAKTRAIL) += intel_oaktrail.o |
51 | obj-$(CONFIG_SAMSUNG_Q10) += samsung-q10.o | 51 | obj-$(CONFIG_SAMSUNG_Q10) += samsung-q10.o |
52 | obj-$(CONFIG_APPLE_GMUX) += apple-gmux.o | 52 | obj-$(CONFIG_APPLE_GMUX) += apple-gmux.o |
53 | obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o | ||
54 | obj-$(CONFIG_INTEL_RST) += intel-rst.o | 53 | obj-$(CONFIG_INTEL_RST) += intel-rst.o |
55 | obj-$(CONFIG_INTEL_SMARTCONNECT) += intel-smartconnect.o | 54 | obj-$(CONFIG_INTEL_SMARTCONNECT) += intel-smartconnect.o |
56 | 55 | ||
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 0e9c169b42f8..594323a926cf 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
@@ -1494,10 +1494,9 @@ static int asus_input_init(struct asus_laptop *asus) | |||
1494 | int error; | 1494 | int error; |
1495 | 1495 | ||
1496 | input = input_allocate_device(); | 1496 | input = input_allocate_device(); |
1497 | if (!input) { | 1497 | if (!input) |
1498 | pr_warn("Unable to allocate input device\n"); | ||
1499 | return -ENOMEM; | 1498 | return -ENOMEM; |
1500 | } | 1499 | |
1501 | input->name = "Asus Laptop extra buttons"; | 1500 | input->name = "Asus Laptop extra buttons"; |
1502 | input->phys = ASUS_LAPTOP_FILE "/input0"; | 1501 | input->phys = ASUS_LAPTOP_FILE "/input0"; |
1503 | input->id.bustype = BUS_HOST; | 1502 | input->id.bustype = BUS_HOST; |
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index bb77e18b3dd4..c608b1d33f4a 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/dmi.h> | 22 | #include <linux/dmi.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/rfkill.h> | ||
24 | #include <linux/power_supply.h> | 25 | #include <linux/power_supply.h> |
25 | #include <linux/acpi.h> | 26 | #include <linux/acpi.h> |
26 | #include <linux/mm.h> | 27 | #include <linux/mm.h> |
@@ -89,6 +90,13 @@ static struct platform_driver platform_driver = { | |||
89 | 90 | ||
90 | static struct platform_device *platform_device; | 91 | static struct platform_device *platform_device; |
91 | static struct backlight_device *dell_backlight_device; | 92 | static struct backlight_device *dell_backlight_device; |
93 | static struct rfkill *wifi_rfkill; | ||
94 | static struct rfkill *bluetooth_rfkill; | ||
95 | static struct rfkill *wwan_rfkill; | ||
96 | static bool force_rfkill; | ||
97 | |||
98 | module_param(force_rfkill, bool, 0444); | ||
99 | MODULE_PARM_DESC(force_rfkill, "enable rfkill on non whitelisted models"); | ||
92 | 100 | ||
93 | static const struct dmi_system_id dell_device_table[] __initconst = { | 101 | static const struct dmi_system_id dell_device_table[] __initconst = { |
94 | { | 102 | { |
@@ -355,6 +363,108 @@ dell_send_request(struct calling_interface_buffer *buffer, int class, | |||
355 | return buffer; | 363 | return buffer; |
356 | } | 364 | } |
357 | 365 | ||
366 | /* Derived from information in DellWirelessCtl.cpp: | ||
367 | Class 17, select 11 is radio control. It returns an array of 32-bit values. | ||
368 | |||
369 | Input byte 0 = 0: Wireless information | ||
370 | |||
371 | result[0]: return code | ||
372 | result[1]: | ||
373 | Bit 0: Hardware switch supported | ||
374 | Bit 1: Wifi locator supported | ||
375 | Bit 2: Wifi is supported | ||
376 | Bit 3: Bluetooth is supported | ||
377 | Bit 4: WWAN is supported | ||
378 | Bit 5: Wireless keyboard supported | ||
379 | Bits 6-7: Reserved | ||
380 | Bit 8: Wifi is installed | ||
381 | Bit 9: Bluetooth is installed | ||
382 | Bit 10: WWAN is installed | ||
383 | Bits 11-15: Reserved | ||
384 | Bit 16: Hardware switch is on | ||
385 | Bit 17: Wifi is blocked | ||
386 | Bit 18: Bluetooth is blocked | ||
387 | Bit 19: WWAN is blocked | ||
388 | Bits 20-31: Reserved | ||
389 | result[2]: NVRAM size in bytes | ||
390 | result[3]: NVRAM format version number | ||
391 | |||
392 | Input byte 0 = 2: Wireless switch configuration | ||
393 | result[0]: return code | ||
394 | result[1]: | ||
395 | Bit 0: Wifi controlled by switch | ||
396 | Bit 1: Bluetooth controlled by switch | ||
397 | Bit 2: WWAN controlled by switch | ||
398 | Bits 3-6: Reserved | ||
399 | Bit 7: Wireless switch config locked | ||
400 | Bit 8: Wifi locator enabled | ||
401 | Bits 9-14: Reserved | ||
402 | Bit 15: Wifi locator setting locked | ||
403 | Bits 16-31: Reserved | ||
404 | */ | ||
405 | |||
406 | static int dell_rfkill_set(void *data, bool blocked) | ||
407 | { | ||
408 | int disable = blocked ? 1 : 0; | ||
409 | unsigned long radio = (unsigned long)data; | ||
410 | int hwswitch_bit = (unsigned long)data - 1; | ||
411 | |||
412 | get_buffer(); | ||
413 | dell_send_request(buffer, 17, 11); | ||
414 | |||
415 | /* If the hardware switch controls this radio, and the hardware | ||
416 | switch is disabled, always disable the radio */ | ||
417 | if ((hwswitch_state & BIT(hwswitch_bit)) && | ||
418 | !(buffer->output[1] & BIT(16))) | ||
419 | disable = 1; | ||
420 | |||
421 | buffer->input[0] = (1 | (radio<<8) | (disable << 16)); | ||
422 | dell_send_request(buffer, 17, 11); | ||
423 | |||
424 | release_buffer(); | ||
425 | return 0; | ||
426 | } | ||
427 | |||
428 | /* Must be called with the buffer held */ | ||
429 | static void dell_rfkill_update_sw_state(struct rfkill *rfkill, int radio, | ||
430 | int status) | ||
431 | { | ||
432 | if (status & BIT(0)) { | ||
433 | /* Has hw-switch, sync sw_state to BIOS */ | ||
434 | int block = rfkill_blocked(rfkill); | ||
435 | buffer->input[0] = (1 | (radio << 8) | (block << 16)); | ||
436 | dell_send_request(buffer, 17, 11); | ||
437 | } else { | ||
438 | /* No hw-switch, sync BIOS state to sw_state */ | ||
439 | rfkill_set_sw_state(rfkill, !!(status & BIT(radio + 16))); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | static void dell_rfkill_update_hw_state(struct rfkill *rfkill, int radio, | ||
444 | int status) | ||
445 | { | ||
446 | if (hwswitch_state & (BIT(radio - 1))) | ||
447 | rfkill_set_hw_state(rfkill, !(status & BIT(16))); | ||
448 | } | ||
449 | |||
450 | static void dell_rfkill_query(struct rfkill *rfkill, void *data) | ||
451 | { | ||
452 | int status; | ||
453 | |||
454 | get_buffer(); | ||
455 | dell_send_request(buffer, 17, 11); | ||
456 | status = buffer->output[1]; | ||
457 | |||
458 | dell_rfkill_update_hw_state(rfkill, (unsigned long)data, status); | ||
459 | |||
460 | release_buffer(); | ||
461 | } | ||
462 | |||
463 | static const struct rfkill_ops dell_rfkill_ops = { | ||
464 | .set_block = dell_rfkill_set, | ||
465 | .query = dell_rfkill_query, | ||
466 | }; | ||
467 | |||
358 | static struct dentry *dell_laptop_dir; | 468 | static struct dentry *dell_laptop_dir; |
359 | 469 | ||
360 | static int dell_debugfs_show(struct seq_file *s, void *data) | 470 | static int dell_debugfs_show(struct seq_file *s, void *data) |
@@ -424,6 +534,136 @@ static const struct file_operations dell_debugfs_fops = { | |||
424 | .release = single_release, | 534 | .release = single_release, |
425 | }; | 535 | }; |
426 | 536 | ||
537 | static void dell_update_rfkill(struct work_struct *ignored) | ||
538 | { | ||
539 | int status; | ||
540 | |||
541 | get_buffer(); | ||
542 | dell_send_request(buffer, 17, 11); | ||
543 | status = buffer->output[1]; | ||
544 | |||
545 | if (wifi_rfkill) { | ||
546 | dell_rfkill_update_hw_state(wifi_rfkill, 1, status); | ||
547 | dell_rfkill_update_sw_state(wifi_rfkill, 1, status); | ||
548 | } | ||
549 | if (bluetooth_rfkill) { | ||
550 | dell_rfkill_update_hw_state(bluetooth_rfkill, 2, status); | ||
551 | dell_rfkill_update_sw_state(bluetooth_rfkill, 2, status); | ||
552 | } | ||
553 | if (wwan_rfkill) { | ||
554 | dell_rfkill_update_hw_state(wwan_rfkill, 3, status); | ||
555 | dell_rfkill_update_sw_state(wwan_rfkill, 3, status); | ||
556 | } | ||
557 | |||
558 | release_buffer(); | ||
559 | } | ||
560 | static DECLARE_DELAYED_WORK(dell_rfkill_work, dell_update_rfkill); | ||
561 | |||
562 | |||
563 | static int __init dell_setup_rfkill(void) | ||
564 | { | ||
565 | int status; | ||
566 | int ret; | ||
567 | const char *product; | ||
568 | |||
569 | /* | ||
570 | * rfkill causes trouble on various non Latitudes, according to Dell | ||
571 | * actually testing the rfkill functionality is only done on Latitudes. | ||
572 | */ | ||
573 | product = dmi_get_system_info(DMI_PRODUCT_NAME); | ||
574 | if (!force_rfkill && (!product || strncmp(product, "Latitude", 8))) | ||
575 | return 0; | ||
576 | |||
577 | get_buffer(); | ||
578 | dell_send_request(buffer, 17, 11); | ||
579 | status = buffer->output[1]; | ||
580 | buffer->input[0] = 0x2; | ||
581 | dell_send_request(buffer, 17, 11); | ||
582 | hwswitch_state = buffer->output[1]; | ||
583 | release_buffer(); | ||
584 | |||
585 | if (!(status & BIT(0))) { | ||
586 | if (force_rfkill) { | ||
587 | /* No hwsitch, clear all hw-controlled bits */ | ||
588 | hwswitch_state &= ~7; | ||
589 | } else { | ||
590 | /* rfkill is only tested on laptops with a hwswitch */ | ||
591 | return 0; | ||
592 | } | ||
593 | } | ||
594 | |||
595 | if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) { | ||
596 | wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev, | ||
597 | RFKILL_TYPE_WLAN, | ||
598 | &dell_rfkill_ops, (void *) 1); | ||
599 | if (!wifi_rfkill) { | ||
600 | ret = -ENOMEM; | ||
601 | goto err_wifi; | ||
602 | } | ||
603 | ret = rfkill_register(wifi_rfkill); | ||
604 | if (ret) | ||
605 | goto err_wifi; | ||
606 | } | ||
607 | |||
608 | if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) { | ||
609 | bluetooth_rfkill = rfkill_alloc("dell-bluetooth", | ||
610 | &platform_device->dev, | ||
611 | RFKILL_TYPE_BLUETOOTH, | ||
612 | &dell_rfkill_ops, (void *) 2); | ||
613 | if (!bluetooth_rfkill) { | ||
614 | ret = -ENOMEM; | ||
615 | goto err_bluetooth; | ||
616 | } | ||
617 | ret = rfkill_register(bluetooth_rfkill); | ||
618 | if (ret) | ||
619 | goto err_bluetooth; | ||
620 | } | ||
621 | |||
622 | if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) { | ||
623 | wwan_rfkill = rfkill_alloc("dell-wwan", | ||
624 | &platform_device->dev, | ||
625 | RFKILL_TYPE_WWAN, | ||
626 | &dell_rfkill_ops, (void *) 3); | ||
627 | if (!wwan_rfkill) { | ||
628 | ret = -ENOMEM; | ||
629 | goto err_wwan; | ||
630 | } | ||
631 | ret = rfkill_register(wwan_rfkill); | ||
632 | if (ret) | ||
633 | goto err_wwan; | ||
634 | } | ||
635 | |||
636 | return 0; | ||
637 | err_wwan: | ||
638 | rfkill_destroy(wwan_rfkill); | ||
639 | if (bluetooth_rfkill) | ||
640 | rfkill_unregister(bluetooth_rfkill); | ||
641 | err_bluetooth: | ||
642 | rfkill_destroy(bluetooth_rfkill); | ||
643 | if (wifi_rfkill) | ||
644 | rfkill_unregister(wifi_rfkill); | ||
645 | err_wifi: | ||
646 | rfkill_destroy(wifi_rfkill); | ||
647 | |||
648 | return ret; | ||
649 | } | ||
650 | |||
651 | static void dell_cleanup_rfkill(void) | ||
652 | { | ||
653 | if (wifi_rfkill) { | ||
654 | rfkill_unregister(wifi_rfkill); | ||
655 | rfkill_destroy(wifi_rfkill); | ||
656 | } | ||
657 | if (bluetooth_rfkill) { | ||
658 | rfkill_unregister(bluetooth_rfkill); | ||
659 | rfkill_destroy(bluetooth_rfkill); | ||
660 | } | ||
661 | if (wwan_rfkill) { | ||
662 | rfkill_unregister(wwan_rfkill); | ||
663 | rfkill_destroy(wwan_rfkill); | ||
664 | } | ||
665 | } | ||
666 | |||
427 | static int dell_send_intensity(struct backlight_device *bd) | 667 | static int dell_send_intensity(struct backlight_device *bd) |
428 | { | 668 | { |
429 | int ret = 0; | 669 | int ret = 0; |
@@ -515,6 +755,30 @@ static void touchpad_led_exit(void) | |||
515 | led_classdev_unregister(&touchpad_led); | 755 | led_classdev_unregister(&touchpad_led); |
516 | } | 756 | } |
517 | 757 | ||
758 | static bool dell_laptop_i8042_filter(unsigned char data, unsigned char str, | ||
759 | struct serio *port) | ||
760 | { | ||
761 | static bool extended; | ||
762 | |||
763 | if (str & 0x20) | ||
764 | return false; | ||
765 | |||
766 | if (unlikely(data == 0xe0)) { | ||
767 | extended = true; | ||
768 | return false; | ||
769 | } else if (unlikely(extended)) { | ||
770 | switch (data) { | ||
771 | case 0x8: | ||
772 | schedule_delayed_work(&dell_rfkill_work, | ||
773 | round_jiffies_relative(HZ / 4)); | ||
774 | break; | ||
775 | } | ||
776 | extended = false; | ||
777 | } | ||
778 | |||
779 | return false; | ||
780 | } | ||
781 | |||
518 | static int __init dell_init(void) | 782 | static int __init dell_init(void) |
519 | { | 783 | { |
520 | int max_intensity = 0; | 784 | int max_intensity = 0; |
@@ -557,10 +821,26 @@ static int __init dell_init(void) | |||
557 | } | 821 | } |
558 | buffer = page_address(bufferpage); | 822 | buffer = page_address(bufferpage); |
559 | 823 | ||
824 | ret = dell_setup_rfkill(); | ||
825 | |||
826 | if (ret) { | ||
827 | pr_warn("Unable to setup rfkill\n"); | ||
828 | goto fail_rfkill; | ||
829 | } | ||
830 | |||
831 | ret = i8042_install_filter(dell_laptop_i8042_filter); | ||
832 | if (ret) { | ||
833 | pr_warn("Unable to install key filter\n"); | ||
834 | goto fail_filter; | ||
835 | } | ||
836 | |||
560 | if (quirks && quirks->touchpad_led) | 837 | if (quirks && quirks->touchpad_led) |
561 | touchpad_led_init(&platform_device->dev); | 838 | touchpad_led_init(&platform_device->dev); |
562 | 839 | ||
563 | dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL); | 840 | dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL); |
841 | if (dell_laptop_dir != NULL) | ||
842 | debugfs_create_file("rfkill", 0444, dell_laptop_dir, NULL, | ||
843 | &dell_debugfs_fops); | ||
564 | 844 | ||
565 | #ifdef CONFIG_ACPI | 845 | #ifdef CONFIG_ACPI |
566 | /* In the event of an ACPI backlight being available, don't | 846 | /* In the event of an ACPI backlight being available, don't |
@@ -603,6 +883,11 @@ static int __init dell_init(void) | |||
603 | return 0; | 883 | return 0; |
604 | 884 | ||
605 | fail_backlight: | 885 | fail_backlight: |
886 | i8042_remove_filter(dell_laptop_i8042_filter); | ||
887 | cancel_delayed_work_sync(&dell_rfkill_work); | ||
888 | fail_filter: | ||
889 | dell_cleanup_rfkill(); | ||
890 | fail_rfkill: | ||
606 | free_page((unsigned long)bufferpage); | 891 | free_page((unsigned long)bufferpage); |
607 | fail_buffer: | 892 | fail_buffer: |
608 | platform_device_del(platform_device); | 893 | platform_device_del(platform_device); |
@@ -620,7 +905,10 @@ static void __exit dell_exit(void) | |||
620 | debugfs_remove_recursive(dell_laptop_dir); | 905 | debugfs_remove_recursive(dell_laptop_dir); |
621 | if (quirks && quirks->touchpad_led) | 906 | if (quirks && quirks->touchpad_led) |
622 | touchpad_led_exit(); | 907 | touchpad_led_exit(); |
908 | i8042_remove_filter(dell_laptop_i8042_filter); | ||
909 | cancel_delayed_work_sync(&dell_rfkill_work); | ||
623 | backlight_device_unregister(dell_backlight_device); | 910 | backlight_device_unregister(dell_backlight_device); |
911 | dell_cleanup_rfkill(); | ||
624 | if (platform_device) { | 912 | if (platform_device) { |
625 | platform_device_unregister(platform_device); | 913 | platform_device_unregister(platform_device); |
626 | platform_driver_unregister(&platform_driver); | 914 | platform_driver_unregister(&platform_driver); |
diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c index fa9a2171cc13..60e0900bc117 100644 --- a/drivers/platform/x86/dell-wmi.c +++ b/drivers/platform/x86/dell-wmi.c | |||
@@ -130,7 +130,8 @@ static const u16 bios_to_linux_keycode[256] __initconst = { | |||
130 | KEY_BRIGHTNESSUP, KEY_UNKNOWN, KEY_KBDILLUMTOGGLE, | 130 | KEY_BRIGHTNESSUP, KEY_UNKNOWN, KEY_KBDILLUMTOGGLE, |
131 | KEY_UNKNOWN, KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, | 131 | KEY_UNKNOWN, KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, |
132 | KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, KEY_PROG2, | 132 | KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, KEY_PROG2, |
133 | KEY_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 133 | KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, |
134 | KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_MICMUTE, | ||
134 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 135 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
135 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 136 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
136 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 137 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
@@ -139,8 +140,8 @@ static const u16 bios_to_linux_keycode[256] __initconst = { | |||
139 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 140 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
140 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 141 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
141 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 142 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
142 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 143 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
143 | KEY_PROG3 | 144 | 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_PROG3 |
144 | }; | 145 | }; |
145 | 146 | ||
146 | static struct input_dev *dell_wmi_input_dev; | 147 | static struct input_dev *dell_wmi_input_dev; |
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index aefcc32e5634..dec68e7a99c7 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -1203,10 +1203,8 @@ static int eeepc_input_init(struct eeepc_laptop *eeepc) | |||
1203 | int error; | 1203 | int error; |
1204 | 1204 | ||
1205 | input = input_allocate_device(); | 1205 | input = input_allocate_device(); |
1206 | if (!input) { | 1206 | if (!input) |
1207 | pr_info("Unable to allocate input device\n"); | ||
1208 | return -ENOMEM; | 1207 | return -ENOMEM; |
1209 | } | ||
1210 | 1208 | ||
1211 | input->name = "Asus EeePC extra buttons"; | 1209 | input->name = "Asus EeePC extra buttons"; |
1212 | input->phys = EEEPC_LAPTOP_FILE "/input0"; | 1210 | input->phys = EEEPC_LAPTOP_FILE "/input0"; |
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 1c86fa0857c8..8ba8956b5a48 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c | |||
@@ -54,6 +54,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); | |||
54 | #define HPWMI_HARDWARE_QUERY 0x4 | 54 | #define HPWMI_HARDWARE_QUERY 0x4 |
55 | #define HPWMI_WIRELESS_QUERY 0x5 | 55 | #define HPWMI_WIRELESS_QUERY 0x5 |
56 | #define HPWMI_HOTKEY_QUERY 0xc | 56 | #define HPWMI_HOTKEY_QUERY 0xc |
57 | #define HPWMI_FEATURE_QUERY 0xd | ||
57 | #define HPWMI_WIRELESS2_QUERY 0x1b | 58 | #define HPWMI_WIRELESS2_QUERY 0x1b |
58 | #define HPWMI_POSTCODEERROR_QUERY 0x2a | 59 | #define HPWMI_POSTCODEERROR_QUERY 0x2a |
59 | 60 | ||
@@ -292,6 +293,17 @@ static int hp_wmi_tablet_state(void) | |||
292 | return (state & 0x4) ? 1 : 0; | 293 | return (state & 0x4) ? 1 : 0; |
293 | } | 294 | } |
294 | 295 | ||
296 | static int hp_wmi_bios_2009_later(void) | ||
297 | { | ||
298 | int state = 0; | ||
299 | int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, 0, &state, | ||
300 | sizeof(state), sizeof(state)); | ||
301 | if (ret) | ||
302 | return ret; | ||
303 | |||
304 | return (state & 0x10) ? 1 : 0; | ||
305 | } | ||
306 | |||
295 | static int hp_wmi_set_block(void *data, bool blocked) | 307 | static int hp_wmi_set_block(void *data, bool blocked) |
296 | { | 308 | { |
297 | enum hp_wmi_radio r = (enum hp_wmi_radio) data; | 309 | enum hp_wmi_radio r = (enum hp_wmi_radio) data; |
@@ -871,7 +883,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) | |||
871 | gps_rfkill = NULL; | 883 | gps_rfkill = NULL; |
872 | rfkill2_count = 0; | 884 | rfkill2_count = 0; |
873 | 885 | ||
874 | if (hp_wmi_rfkill_setup(device)) | 886 | if (hp_wmi_bios_2009_later() || hp_wmi_rfkill_setup(device)) |
875 | hp_wmi_rfkill2_setup(device); | 887 | hp_wmi_rfkill2_setup(device); |
876 | 888 | ||
877 | err = device_create_file(&device->dev, &dev_attr_display); | 889 | err = device_create_file(&device->dev, &dev_attr_display); |
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 6788acc22ab9..19ec95147f69 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c | |||
@@ -570,10 +570,8 @@ static int ideapad_input_init(struct ideapad_private *priv) | |||
570 | int error; | 570 | int error; |
571 | 571 | ||
572 | inputdev = input_allocate_device(); | 572 | inputdev = input_allocate_device(); |
573 | if (!inputdev) { | 573 | if (!inputdev) |
574 | pr_info("Unable to allocate input device\n"); | ||
575 | return -ENOMEM; | 574 | return -ENOMEM; |
576 | } | ||
577 | 575 | ||
578 | inputdev->name = "Ideapad extra buttons"; | 576 | inputdev->name = "Ideapad extra buttons"; |
579 | inputdev->phys = "ideapad/input0"; | 577 | inputdev->phys = "ideapad/input0"; |
diff --git a/drivers/platform/x86/intel_mid_powerbtn.c b/drivers/platform/x86/intel_mid_powerbtn.c index 6b18aba82cfa..8d6775266d66 100644 --- a/drivers/platform/x86/intel_mid_powerbtn.c +++ b/drivers/platform/x86/intel_mid_powerbtn.c | |||
@@ -66,10 +66,8 @@ static int mfld_pb_probe(struct platform_device *pdev) | |||
66 | return -EINVAL; | 66 | return -EINVAL; |
67 | 67 | ||
68 | input = input_allocate_device(); | 68 | input = input_allocate_device(); |
69 | if (!input) { | 69 | if (!input) |
70 | dev_err(&pdev->dev, "Input device allocation error\n"); | ||
71 | return -ENOMEM; | 70 | return -ENOMEM; |
72 | } | ||
73 | 71 | ||
74 | input->name = pdev->name; | 72 | input->name = pdev->name; |
75 | input->phys = "power-button/input0"; | 73 | input->phys = "power-button/input0"; |
diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c index d654f831410d..60ea476a9130 100644 --- a/drivers/platform/x86/intel_scu_ipc.c +++ b/drivers/platform/x86/intel_scu_ipc.c | |||
@@ -58,12 +58,56 @@ | |||
58 | * message handler is called within firmware. | 58 | * message handler is called within firmware. |
59 | */ | 59 | */ |
60 | 60 | ||
61 | #define IPC_BASE_ADDR 0xFF11C000 /* IPC1 base register address */ | ||
62 | #define IPC_MAX_ADDR 0x100 /* Maximum IPC regisers */ | ||
63 | #define IPC_WWBUF_SIZE 20 /* IPC Write buffer Size */ | 61 | #define IPC_WWBUF_SIZE 20 /* IPC Write buffer Size */ |
64 | #define IPC_RWBUF_SIZE 20 /* IPC Read buffer Size */ | 62 | #define IPC_RWBUF_SIZE 20 /* IPC Read buffer Size */ |
65 | #define IPC_I2C_BASE 0xFF12B000 /* I2C control register base address */ | 63 | #define IPC_IOC 0x100 /* IPC command register IOC bit */ |
66 | #define IPC_I2C_MAX_ADDR 0x10 /* Maximum I2C regisers */ | 64 | |
65 | enum { | ||
66 | SCU_IPC_LINCROFT, | ||
67 | SCU_IPC_PENWELL, | ||
68 | SCU_IPC_CLOVERVIEW, | ||
69 | SCU_IPC_TANGIER, | ||
70 | }; | ||
71 | |||
72 | /* intel scu ipc driver data*/ | ||
73 | struct intel_scu_ipc_pdata_t { | ||
74 | u32 ipc_base; | ||
75 | u32 i2c_base; | ||
76 | u32 ipc_len; | ||
77 | u32 i2c_len; | ||
78 | u8 irq_mode; | ||
79 | }; | ||
80 | |||
81 | static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = { | ||
82 | [SCU_IPC_LINCROFT] = { | ||
83 | .ipc_base = 0xff11c000, | ||
84 | .i2c_base = 0xff12b000, | ||
85 | .ipc_len = 0x100, | ||
86 | .i2c_len = 0x10, | ||
87 | .irq_mode = 0, | ||
88 | }, | ||
89 | [SCU_IPC_PENWELL] = { | ||
90 | .ipc_base = 0xff11c000, | ||
91 | .i2c_base = 0xff12b000, | ||
92 | .ipc_len = 0x100, | ||
93 | .i2c_len = 0x10, | ||
94 | .irq_mode = 1, | ||
95 | }, | ||
96 | [SCU_IPC_CLOVERVIEW] = { | ||
97 | .ipc_base = 0xff11c000, | ||
98 | .i2c_base = 0xff12b000, | ||
99 | .ipc_len = 0x100, | ||
100 | .i2c_len = 0x10, | ||
101 | .irq_mode = 1, | ||
102 | }, | ||
103 | [SCU_IPC_TANGIER] = { | ||
104 | .ipc_base = 0xff009000, | ||
105 | .i2c_base = 0xff00d000, | ||
106 | .ipc_len = 0x100, | ||
107 | .i2c_len = 0x10, | ||
108 | .irq_mode = 0, | ||
109 | }, | ||
110 | }; | ||
67 | 111 | ||
68 | static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id); | 112 | static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id); |
69 | static void ipc_remove(struct pci_dev *pdev); | 113 | static void ipc_remove(struct pci_dev *pdev); |
@@ -72,6 +116,8 @@ struct intel_scu_ipc_dev { | |||
72 | struct pci_dev *pdev; | 116 | struct pci_dev *pdev; |
73 | void __iomem *ipc_base; | 117 | void __iomem *ipc_base; |
74 | void __iomem *i2c_base; | 118 | void __iomem *i2c_base; |
119 | struct completion cmd_complete; | ||
120 | u8 irq_mode; | ||
75 | }; | 121 | }; |
76 | 122 | ||
77 | static struct intel_scu_ipc_dev ipcdev; /* Only one for now */ | 123 | static struct intel_scu_ipc_dev ipcdev; /* Only one for now */ |
@@ -98,6 +144,10 @@ static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */ | |||
98 | */ | 144 | */ |
99 | static inline void ipc_command(u32 cmd) /* Send ipc command */ | 145 | static inline void ipc_command(u32 cmd) /* Send ipc command */ |
100 | { | 146 | { |
147 | if (ipcdev.irq_mode) { | ||
148 | reinit_completion(&ipcdev.cmd_complete); | ||
149 | writel(cmd | IPC_IOC, ipcdev.ipc_base); | ||
150 | } | ||
101 | writel(cmd, ipcdev.ipc_base); | 151 | writel(cmd, ipcdev.ipc_base); |
102 | } | 152 | } |
103 | 153 | ||
@@ -156,6 +206,30 @@ static inline int busy_loop(void) /* Wait till scu status is busy */ | |||
156 | return 0; | 206 | return 0; |
157 | } | 207 | } |
158 | 208 | ||
209 | /* Wait till ipc ioc interrupt is received or timeout in 3 HZ */ | ||
210 | static inline int ipc_wait_for_interrupt(void) | ||
211 | { | ||
212 | int status; | ||
213 | |||
214 | if (!wait_for_completion_timeout(&ipcdev.cmd_complete, 3 * HZ)) { | ||
215 | struct device *dev = &ipcdev.pdev->dev; | ||
216 | dev_err(dev, "IPC timed out\n"); | ||
217 | return -ETIMEDOUT; | ||
218 | } | ||
219 | |||
220 | status = ipc_read_status(); | ||
221 | |||
222 | if ((status >> 1) & 1) | ||
223 | return -EIO; | ||
224 | |||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | int intel_scu_ipc_check_status(void) | ||
229 | { | ||
230 | return ipcdev.irq_mode ? ipc_wait_for_interrupt() : busy_loop(); | ||
231 | } | ||
232 | |||
159 | /* Read/Write power control(PMIC in Langwell, MSIC in PenWell) registers */ | 233 | /* Read/Write power control(PMIC in Langwell, MSIC in PenWell) registers */ |
160 | static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id) | 234 | static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id) |
161 | { | 235 | { |
@@ -196,8 +270,8 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id) | |||
196 | ipc_command(4 << 16 | id << 12 | 0 << 8 | op); | 270 | ipc_command(4 << 16 | id << 12 | 0 << 8 | op); |
197 | } | 271 | } |
198 | 272 | ||
199 | err = busy_loop(); | 273 | err = intel_scu_ipc_check_status(); |
200 | if (id == IPC_CMD_PCNTRL_R) { /* Read rbuf */ | 274 | if (!err && id == IPC_CMD_PCNTRL_R) { /* Read rbuf */ |
201 | /* Workaround: values are read as 0 without memcpy_fromio */ | 275 | /* Workaround: values are read as 0 without memcpy_fromio */ |
202 | memcpy_fromio(cbuf, ipcdev.ipc_base + 0x90, 16); | 276 | memcpy_fromio(cbuf, ipcdev.ipc_base + 0x90, 16); |
203 | for (nc = 0; nc < count; nc++) | 277 | for (nc = 0; nc < count; nc++) |
@@ -391,7 +465,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub) | |||
391 | return -ENODEV; | 465 | return -ENODEV; |
392 | } | 466 | } |
393 | ipc_command(sub << 12 | cmd); | 467 | ipc_command(sub << 12 | cmd); |
394 | err = busy_loop(); | 468 | err = intel_scu_ipc_check_status(); |
395 | mutex_unlock(&ipclock); | 469 | mutex_unlock(&ipclock); |
396 | return err; | 470 | return err; |
397 | } | 471 | } |
@@ -425,10 +499,12 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen, | |||
425 | ipc_data_writel(*in++, 4 * i); | 499 | ipc_data_writel(*in++, 4 * i); |
426 | 500 | ||
427 | ipc_command((inlen << 16) | (sub << 12) | cmd); | 501 | ipc_command((inlen << 16) | (sub << 12) | cmd); |
428 | err = busy_loop(); | 502 | err = intel_scu_ipc_check_status(); |
429 | 503 | ||
430 | for (i = 0; i < outlen; i++) | 504 | if (!err) { |
431 | *out++ = ipc_data_readl(4 * i); | 505 | for (i = 0; i < outlen; i++) |
506 | *out++ = ipc_data_readl(4 * i); | ||
507 | } | ||
432 | 508 | ||
433 | mutex_unlock(&ipclock); | 509 | mutex_unlock(&ipclock); |
434 | return err; | 510 | return err; |
@@ -491,6 +567,9 @@ EXPORT_SYMBOL(intel_scu_ipc_i2c_cntrl); | |||
491 | */ | 567 | */ |
492 | static irqreturn_t ioc(int irq, void *dev_id) | 568 | static irqreturn_t ioc(int irq, void *dev_id) |
493 | { | 569 | { |
570 | if (ipcdev.irq_mode) | ||
571 | complete(&ipcdev.cmd_complete); | ||
572 | |||
494 | return IRQ_HANDLED; | 573 | return IRQ_HANDLED; |
495 | } | 574 | } |
496 | 575 | ||
@@ -504,13 +583,18 @@ static irqreturn_t ioc(int irq, void *dev_id) | |||
504 | */ | 583 | */ |
505 | static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) | 584 | static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) |
506 | { | 585 | { |
507 | int err; | 586 | int err, pid; |
587 | struct intel_scu_ipc_pdata_t *pdata; | ||
508 | resource_size_t pci_resource; | 588 | resource_size_t pci_resource; |
509 | 589 | ||
510 | if (ipcdev.pdev) /* We support only one SCU */ | 590 | if (ipcdev.pdev) /* We support only one SCU */ |
511 | return -EBUSY; | 591 | return -EBUSY; |
512 | 592 | ||
593 | pid = id->driver_data; | ||
594 | pdata = &intel_scu_ipc_pdata[pid]; | ||
595 | |||
513 | ipcdev.pdev = pci_dev_get(dev); | 596 | ipcdev.pdev = pci_dev_get(dev); |
597 | ipcdev.irq_mode = pdata->irq_mode; | ||
514 | 598 | ||
515 | err = pci_enable_device(dev); | 599 | err = pci_enable_device(dev); |
516 | if (err) | 600 | if (err) |
@@ -524,14 +608,16 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
524 | if (!pci_resource) | 608 | if (!pci_resource) |
525 | return -ENOMEM; | 609 | return -ENOMEM; |
526 | 610 | ||
611 | init_completion(&ipcdev.cmd_complete); | ||
612 | |||
527 | if (request_irq(dev->irq, ioc, 0, "intel_scu_ipc", &ipcdev)) | 613 | if (request_irq(dev->irq, ioc, 0, "intel_scu_ipc", &ipcdev)) |
528 | return -EBUSY; | 614 | return -EBUSY; |
529 | 615 | ||
530 | ipcdev.ipc_base = ioremap_nocache(IPC_BASE_ADDR, IPC_MAX_ADDR); | 616 | ipcdev.ipc_base = ioremap_nocache(pdata->ipc_base, pdata->ipc_len); |
531 | if (!ipcdev.ipc_base) | 617 | if (!ipcdev.ipc_base) |
532 | return -ENOMEM; | 618 | return -ENOMEM; |
533 | 619 | ||
534 | ipcdev.i2c_base = ioremap_nocache(IPC_I2C_BASE, IPC_I2C_MAX_ADDR); | 620 | ipcdev.i2c_base = ioremap_nocache(pdata->i2c_base, pdata->i2c_len); |
535 | if (!ipcdev.i2c_base) { | 621 | if (!ipcdev.i2c_base) { |
536 | iounmap(ipcdev.ipc_base); | 622 | iounmap(ipcdev.ipc_base); |
537 | return -ENOMEM; | 623 | return -ENOMEM; |
@@ -564,7 +650,10 @@ static void ipc_remove(struct pci_dev *pdev) | |||
564 | } | 650 | } |
565 | 651 | ||
566 | static DEFINE_PCI_DEVICE_TABLE(pci_ids) = { | 652 | static DEFINE_PCI_DEVICE_TABLE(pci_ids) = { |
567 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x082a)}, | 653 | {PCI_VDEVICE(INTEL, 0x082a), SCU_IPC_LINCROFT}, |
654 | {PCI_VDEVICE(INTEL, 0x080e), SCU_IPC_PENWELL}, | ||
655 | {PCI_VDEVICE(INTEL, 0x08ea), SCU_IPC_CLOVERVIEW}, | ||
656 | {PCI_VDEVICE(INTEL, 0x11a0), SCU_IPC_TANGIER}, | ||
568 | { 0,} | 657 | { 0,} |
569 | }; | 658 | }; |
570 | MODULE_DEVICE_TABLE(pci, pci_ids); | 659 | MODULE_DEVICE_TABLE(pci, pci_ids); |
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c index 10d12b221601..3008fd20572e 100644 --- a/drivers/platform/x86/panasonic-laptop.c +++ b/drivers/platform/x86/panasonic-laptop.c | |||
@@ -490,11 +490,8 @@ static int acpi_pcc_init_input(struct pcc_acpi *pcc) | |||
490 | int error; | 490 | int error; |
491 | 491 | ||
492 | input_dev = input_allocate_device(); | 492 | input_dev = input_allocate_device(); |
493 | if (!input_dev) { | 493 | if (!input_dev) |
494 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
495 | "Couldn't allocate input device for hotkey")); | ||
496 | return -ENOMEM; | 494 | return -ENOMEM; |
497 | } | ||
498 | 495 | ||
499 | input_dev->name = ACPI_PCC_DRIVER_NAME; | 496 | input_dev->name = ACPI_PCC_DRIVER_NAME; |
500 | input_dev->phys = ACPI_PCC_INPUT_PHYS; | 497 | input_dev->phys = ACPI_PCC_INPUT_PHYS; |
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index 47caab0ea7a1..fb233ae7bb0e 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c | |||
@@ -140,12 +140,12 @@ MODULE_PARM_DESC(kbd_backlight_timeout, | |||
140 | "on the model (default: no change from current value)"); | 140 | "on the model (default: no change from current value)"); |
141 | 141 | ||
142 | #ifdef CONFIG_PM_SLEEP | 142 | #ifdef CONFIG_PM_SLEEP |
143 | static void sony_nc_kbd_backlight_resume(void); | ||
144 | static void sony_nc_thermal_resume(void); | 143 | static void sony_nc_thermal_resume(void); |
145 | #endif | 144 | #endif |
146 | static int sony_nc_kbd_backlight_setup(struct platform_device *pd, | 145 | static int sony_nc_kbd_backlight_setup(struct platform_device *pd, |
147 | unsigned int handle); | 146 | unsigned int handle); |
148 | static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd); | 147 | static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd, |
148 | unsigned int handle); | ||
149 | 149 | ||
150 | static int sony_nc_battery_care_setup(struct platform_device *pd, | 150 | static int sony_nc_battery_care_setup(struct platform_device *pd, |
151 | unsigned int handle); | 151 | unsigned int handle); |
@@ -304,8 +304,8 @@ static int sony_laptop_input_keycode_map[] = { | |||
304 | KEY_FN_F10, /* 14 SONYPI_EVENT_FNKEY_F10 */ | 304 | KEY_FN_F10, /* 14 SONYPI_EVENT_FNKEY_F10 */ |
305 | KEY_FN_F11, /* 15 SONYPI_EVENT_FNKEY_F11 */ | 305 | KEY_FN_F11, /* 15 SONYPI_EVENT_FNKEY_F11 */ |
306 | KEY_FN_F12, /* 16 SONYPI_EVENT_FNKEY_F12 */ | 306 | KEY_FN_F12, /* 16 SONYPI_EVENT_FNKEY_F12 */ |
307 | KEY_FN_F1, /* 17 SONYPI_EVENT_FNKEY_1 */ | 307 | KEY_FN_1, /* 17 SONYPI_EVENT_FNKEY_1 */ |
308 | KEY_FN_F2, /* 18 SONYPI_EVENT_FNKEY_2 */ | 308 | KEY_FN_2, /* 18 SONYPI_EVENT_FNKEY_2 */ |
309 | KEY_FN_D, /* 19 SONYPI_EVENT_FNKEY_D */ | 309 | KEY_FN_D, /* 19 SONYPI_EVENT_FNKEY_D */ |
310 | KEY_FN_E, /* 20 SONYPI_EVENT_FNKEY_E */ | 310 | KEY_FN_E, /* 20 SONYPI_EVENT_FNKEY_E */ |
311 | KEY_FN_F, /* 21 SONYPI_EVENT_FNKEY_F */ | 311 | KEY_FN_F, /* 21 SONYPI_EVENT_FNKEY_F */ |
@@ -1444,7 +1444,7 @@ static void sony_nc_function_cleanup(struct platform_device *pd) | |||
1444 | case 0x014b: | 1444 | case 0x014b: |
1445 | case 0x014c: | 1445 | case 0x014c: |
1446 | case 0x0163: | 1446 | case 0x0163: |
1447 | sony_nc_kbd_backlight_cleanup(pd); | 1447 | sony_nc_kbd_backlight_cleanup(pd, handle); |
1448 | break; | 1448 | break; |
1449 | default: | 1449 | default: |
1450 | continue; | 1450 | continue; |
@@ -1486,13 +1486,6 @@ static void sony_nc_function_resume(void) | |||
1486 | case 0x0135: | 1486 | case 0x0135: |
1487 | sony_nc_rfkill_update(); | 1487 | sony_nc_rfkill_update(); |
1488 | break; | 1488 | break; |
1489 | case 0x0137: | ||
1490 | case 0x0143: | ||
1491 | case 0x014b: | ||
1492 | case 0x014c: | ||
1493 | case 0x0163: | ||
1494 | sony_nc_kbd_backlight_resume(); | ||
1495 | break; | ||
1496 | default: | 1489 | default: |
1497 | continue; | 1490 | continue; |
1498 | } | 1491 | } |
@@ -1822,6 +1815,12 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd, | |||
1822 | int result; | 1815 | int result; |
1823 | int ret = 0; | 1816 | int ret = 0; |
1824 | 1817 | ||
1818 | if (kbdbl_ctl) { | ||
1819 | pr_warn("handle 0x%.4x: keyboard backlight setup already done for 0x%.4x\n", | ||
1820 | handle, kbdbl_ctl->handle); | ||
1821 | return -EBUSY; | ||
1822 | } | ||
1823 | |||
1825 | /* verify the kbd backlight presence, these handles are not used for | 1824 | /* verify the kbd backlight presence, these handles are not used for |
1826 | * keyboard backlight only | 1825 | * keyboard backlight only |
1827 | */ | 1826 | */ |
@@ -1881,9 +1880,10 @@ outkzalloc: | |||
1881 | return ret; | 1880 | return ret; |
1882 | } | 1881 | } |
1883 | 1882 | ||
1884 | static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd) | 1883 | static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd, |
1884 | unsigned int handle) | ||
1885 | { | 1885 | { |
1886 | if (kbdbl_ctl) { | 1886 | if (kbdbl_ctl && handle == kbdbl_ctl->handle) { |
1887 | device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); | 1887 | device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); |
1888 | device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr); | 1888 | device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr); |
1889 | kfree(kbdbl_ctl); | 1889 | kfree(kbdbl_ctl); |
@@ -1891,25 +1891,6 @@ static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd) | |||
1891 | } | 1891 | } |
1892 | } | 1892 | } |
1893 | 1893 | ||
1894 | #ifdef CONFIG_PM_SLEEP | ||
1895 | static void sony_nc_kbd_backlight_resume(void) | ||
1896 | { | ||
1897 | int ignore = 0; | ||
1898 | |||
1899 | if (!kbdbl_ctl) | ||
1900 | return; | ||
1901 | |||
1902 | if (kbdbl_ctl->mode == 0) | ||
1903 | sony_call_snc_handle(kbdbl_ctl->handle, kbdbl_ctl->base, | ||
1904 | &ignore); | ||
1905 | |||
1906 | if (kbdbl_ctl->timeout != 0) | ||
1907 | sony_call_snc_handle(kbdbl_ctl->handle, | ||
1908 | (kbdbl_ctl->base + 0x200) | | ||
1909 | (kbdbl_ctl->timeout << 0x10), &ignore); | ||
1910 | } | ||
1911 | #endif | ||
1912 | |||
1913 | struct battery_care_control { | 1894 | struct battery_care_control { |
1914 | struct device_attribute attrs[2]; | 1895 | struct device_attribute attrs[2]; |
1915 | unsigned int handle; | 1896 | unsigned int handle; |
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 05e046aa5e31..58b0274d24cc 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
@@ -6438,7 +6438,12 @@ static struct ibm_struct brightness_driver_data = { | |||
6438 | #define TPACPI_ALSA_SHRTNAME "ThinkPad Console Audio Control" | 6438 | #define TPACPI_ALSA_SHRTNAME "ThinkPad Console Audio Control" |
6439 | #define TPACPI_ALSA_MIXERNAME TPACPI_ALSA_SHRTNAME | 6439 | #define TPACPI_ALSA_MIXERNAME TPACPI_ALSA_SHRTNAME |
6440 | 6440 | ||
6441 | static int alsa_index = ~((1 << (SNDRV_CARDS - 3)) - 1); /* last three slots */ | 6441 | #if SNDRV_CARDS <= 32 |
6442 | #define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1) | ||
6443 | #else | ||
6444 | #define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1) | ||
6445 | #endif | ||
6446 | static int alsa_index = DEFAULT_ALSA_IDX; /* last three slots */ | ||
6442 | static char *alsa_id = "ThinkPadEC"; | 6447 | static char *alsa_id = "ThinkPadEC"; |
6443 | static bool alsa_enable = SNDRV_DEFAULT_ENABLE1; | 6448 | static bool alsa_enable = SNDRV_DEFAULT_ENABLE1; |
6444 | 6449 | ||
@@ -9163,7 +9168,6 @@ static int __init thinkpad_acpi_module_init(void) | |||
9163 | mutex_init(&tpacpi_inputdev_send_mutex); | 9168 | mutex_init(&tpacpi_inputdev_send_mutex); |
9164 | tpacpi_inputdev = input_allocate_device(); | 9169 | tpacpi_inputdev = input_allocate_device(); |
9165 | if (!tpacpi_inputdev) { | 9170 | if (!tpacpi_inputdev) { |
9166 | pr_err("unable to allocate input device\n"); | ||
9167 | thinkpad_acpi_module_exit(); | 9171 | thinkpad_acpi_module_exit(); |
9168 | return -ENOMEM; | 9172 | return -ENOMEM; |
9169 | } else { | 9173 | } else { |
diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c index 67897c8740ba..e597de05e6c2 100644 --- a/drivers/platform/x86/topstar-laptop.c +++ b/drivers/platform/x86/topstar-laptop.c | |||
@@ -97,10 +97,8 @@ static int acpi_topstar_init_hkey(struct topstar_hkey *hkey) | |||
97 | int error; | 97 | int error; |
98 | 98 | ||
99 | input = input_allocate_device(); | 99 | input = input_allocate_device(); |
100 | if (!input) { | 100 | if (!input) |
101 | pr_err("Unable to allocate input device\n"); | ||
102 | return -ENOMEM; | 101 | return -ENOMEM; |
103 | } | ||
104 | 102 | ||
105 | input->name = "Topstar Laptop extra buttons"; | 103 | input->name = "Topstar Laptop extra buttons"; |
106 | input->phys = "topstar/input0"; | 104 | input->phys = "topstar/input0"; |
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index 0cfadb65f7c6..7fce391818d3 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c | |||
@@ -975,10 +975,8 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) | |||
975 | u32 hci_result; | 975 | u32 hci_result; |
976 | 976 | ||
977 | dev->hotkey_dev = input_allocate_device(); | 977 | dev->hotkey_dev = input_allocate_device(); |
978 | if (!dev->hotkey_dev) { | 978 | if (!dev->hotkey_dev) |
979 | pr_info("Unable to register input device\n"); | ||
980 | return -ENOMEM; | 979 | return -ENOMEM; |
981 | } | ||
982 | 980 | ||
983 | dev->hotkey_dev->name = "Toshiba input device"; | 981 | dev->hotkey_dev->name = "Toshiba input device"; |
984 | dev->hotkey_dev->phys = "toshiba_acpi/input0"; | 982 | dev->hotkey_dev->phys = "toshiba_acpi/input0"; |
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 62e8c221d01e..c2e7b2657aeb 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c | |||
@@ -672,8 +672,10 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, | |||
672 | struct wmi_block *wblock; | 672 | struct wmi_block *wblock; |
673 | 673 | ||
674 | wblock = dev_get_drvdata(dev); | 674 | wblock = dev_get_drvdata(dev); |
675 | if (!wblock) | 675 | if (!wblock) { |
676 | return -ENOMEM; | 676 | strcat(buf, "\n"); |
677 | return strlen(buf); | ||
678 | } | ||
677 | 679 | ||
678 | wmi_gtoa(wblock->gblock.guid, guid_string); | 680 | wmi_gtoa(wblock->gblock.guid, guid_string); |
679 | 681 | ||
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 6936e0acedcd..f748cc8cbb03 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c | |||
@@ -197,6 +197,11 @@ static int pnp_bus_freeze(struct device *dev) | |||
197 | return __pnp_bus_suspend(dev, PMSG_FREEZE); | 197 | return __pnp_bus_suspend(dev, PMSG_FREEZE); |
198 | } | 198 | } |
199 | 199 | ||
200 | static int pnp_bus_poweroff(struct device *dev) | ||
201 | { | ||
202 | return __pnp_bus_suspend(dev, PMSG_HIBERNATE); | ||
203 | } | ||
204 | |||
200 | static int pnp_bus_resume(struct device *dev) | 205 | static int pnp_bus_resume(struct device *dev) |
201 | { | 206 | { |
202 | struct pnp_dev *pnp_dev = to_pnp_dev(dev); | 207 | struct pnp_dev *pnp_dev = to_pnp_dev(dev); |
@@ -234,9 +239,14 @@ static int pnp_bus_resume(struct device *dev) | |||
234 | } | 239 | } |
235 | 240 | ||
236 | static const struct dev_pm_ops pnp_bus_dev_pm_ops = { | 241 | static const struct dev_pm_ops pnp_bus_dev_pm_ops = { |
242 | /* Suspend callbacks */ | ||
237 | .suspend = pnp_bus_suspend, | 243 | .suspend = pnp_bus_suspend, |
238 | .freeze = pnp_bus_freeze, | ||
239 | .resume = pnp_bus_resume, | 244 | .resume = pnp_bus_resume, |
245 | /* Hibernate callbacks */ | ||
246 | .freeze = pnp_bus_freeze, | ||
247 | .thaw = pnp_bus_resume, | ||
248 | .poweroff = pnp_bus_poweroff, | ||
249 | .restore = pnp_bus_resume, | ||
240 | }; | 250 | }; |
241 | 251 | ||
242 | struct bus_type pnp_bus_type = { | 252 | struct bus_type pnp_bus_type = { |
diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c index 8d0fe431dbdd..84419af16f77 100644 --- a/drivers/powercap/powercap_sys.c +++ b/drivers/powercap/powercap_sys.c | |||
@@ -377,9 +377,14 @@ static void create_power_zone_common_attributes( | |||
377 | if (power_zone->ops->get_max_energy_range_uj) | 377 | if (power_zone->ops->get_max_energy_range_uj) |
378 | power_zone->zone_dev_attrs[count++] = | 378 | power_zone->zone_dev_attrs[count++] = |
379 | &dev_attr_max_energy_range_uj.attr; | 379 | &dev_attr_max_energy_range_uj.attr; |
380 | if (power_zone->ops->get_energy_uj) | 380 | if (power_zone->ops->get_energy_uj) { |
381 | if (power_zone->ops->reset_energy_uj) | ||
382 | dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO; | ||
383 | else | ||
384 | dev_attr_energy_uj.attr.mode = S_IRUGO; | ||
381 | power_zone->zone_dev_attrs[count++] = | 385 | power_zone->zone_dev_attrs[count++] = |
382 | &dev_attr_energy_uj.attr; | 386 | &dev_attr_energy_uj.attr; |
387 | } | ||
383 | if (power_zone->ops->get_power_uw) | 388 | if (power_zone->ops->get_power_uw) |
384 | power_zone->zone_dev_attrs[count++] = | 389 | power_zone->zone_dev_attrs[count++] = |
385 | &dev_attr_power_uw.attr; | 390 | &dev_attr_power_uw.attr; |
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index 724706a97dc4..fd3154d86901 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.c | |||
@@ -174,6 +174,33 @@ static const struct regulator_desc arizona_micsupp = { | |||
174 | .owner = THIS_MODULE, | 174 | .owner = THIS_MODULE, |
175 | }; | 175 | }; |
176 | 176 | ||
177 | static const struct regulator_linear_range arizona_micsupp_ext_ranges[] = { | ||
178 | REGULATOR_LINEAR_RANGE(900000, 0, 0x14, 25000), | ||
179 | REGULATOR_LINEAR_RANGE(1500000, 0x15, 0x27, 100000), | ||
180 | }; | ||
181 | |||
182 | static const struct regulator_desc arizona_micsupp_ext = { | ||
183 | .name = "MICVDD", | ||
184 | .supply_name = "CPVDD", | ||
185 | .type = REGULATOR_VOLTAGE, | ||
186 | .n_voltages = 40, | ||
187 | .ops = &arizona_micsupp_ops, | ||
188 | |||
189 | .vsel_reg = ARIZONA_LDO2_CONTROL_1, | ||
190 | .vsel_mask = ARIZONA_LDO2_VSEL_MASK, | ||
191 | .enable_reg = ARIZONA_MIC_CHARGE_PUMP_1, | ||
192 | .enable_mask = ARIZONA_CPMIC_ENA, | ||
193 | .bypass_reg = ARIZONA_MIC_CHARGE_PUMP_1, | ||
194 | .bypass_mask = ARIZONA_CPMIC_BYPASS, | ||
195 | |||
196 | .linear_ranges = arizona_micsupp_ext_ranges, | ||
197 | .n_linear_ranges = ARRAY_SIZE(arizona_micsupp_ext_ranges), | ||
198 | |||
199 | .enable_time = 3000, | ||
200 | |||
201 | .owner = THIS_MODULE, | ||
202 | }; | ||
203 | |||
177 | static const struct regulator_init_data arizona_micsupp_default = { | 204 | static const struct regulator_init_data arizona_micsupp_default = { |
178 | .constraints = { | 205 | .constraints = { |
179 | .valid_ops_mask = REGULATOR_CHANGE_STATUS | | 206 | .valid_ops_mask = REGULATOR_CHANGE_STATUS | |
@@ -186,9 +213,22 @@ static const struct regulator_init_data arizona_micsupp_default = { | |||
186 | .num_consumer_supplies = 1, | 213 | .num_consumer_supplies = 1, |
187 | }; | 214 | }; |
188 | 215 | ||
216 | static const struct regulator_init_data arizona_micsupp_ext_default = { | ||
217 | .constraints = { | ||
218 | .valid_ops_mask = REGULATOR_CHANGE_STATUS | | ||
219 | REGULATOR_CHANGE_VOLTAGE | | ||
220 | REGULATOR_CHANGE_BYPASS, | ||
221 | .min_uV = 900000, | ||
222 | .max_uV = 3300000, | ||
223 | }, | ||
224 | |||
225 | .num_consumer_supplies = 1, | ||
226 | }; | ||
227 | |||
189 | static int arizona_micsupp_probe(struct platform_device *pdev) | 228 | static int arizona_micsupp_probe(struct platform_device *pdev) |
190 | { | 229 | { |
191 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); | 230 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); |
231 | const struct regulator_desc *desc; | ||
192 | struct regulator_config config = { }; | 232 | struct regulator_config config = { }; |
193 | struct arizona_micsupp *micsupp; | 233 | struct arizona_micsupp *micsupp; |
194 | int ret; | 234 | int ret; |
@@ -207,7 +247,17 @@ static int arizona_micsupp_probe(struct platform_device *pdev) | |||
207 | * default init_data for it. This will be overridden with | 247 | * default init_data for it. This will be overridden with |
208 | * platform data if provided. | 248 | * platform data if provided. |
209 | */ | 249 | */ |
210 | micsupp->init_data = arizona_micsupp_default; | 250 | switch (arizona->type) { |
251 | case WM5110: | ||
252 | desc = &arizona_micsupp_ext; | ||
253 | micsupp->init_data = arizona_micsupp_ext_default; | ||
254 | break; | ||
255 | default: | ||
256 | desc = &arizona_micsupp; | ||
257 | micsupp->init_data = arizona_micsupp_default; | ||
258 | break; | ||
259 | } | ||
260 | |||
211 | micsupp->init_data.consumer_supplies = &micsupp->supply; | 261 | micsupp->init_data.consumer_supplies = &micsupp->supply; |
212 | micsupp->supply.supply = "MICVDD"; | 262 | micsupp->supply.supply = "MICVDD"; |
213 | micsupp->supply.dev_name = dev_name(arizona->dev); | 263 | micsupp->supply.dev_name = dev_name(arizona->dev); |
@@ -226,7 +276,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev) | |||
226 | ARIZONA_CPMIC_BYPASS, 0); | 276 | ARIZONA_CPMIC_BYPASS, 0); |
227 | 277 | ||
228 | micsupp->regulator = devm_regulator_register(&pdev->dev, | 278 | micsupp->regulator = devm_regulator_register(&pdev->dev, |
229 | &arizona_micsupp, | 279 | desc, |
230 | &config); | 280 | &config); |
231 | if (IS_ERR(micsupp->regulator)) { | 281 | if (IS_ERR(micsupp->regulator)) { |
232 | ret = PTR_ERR(micsupp->regulator); | 282 | ret = PTR_ERR(micsupp->regulator); |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 6382f0af353b..3fe13130baec 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -2184,6 +2184,9 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector) | |||
2184 | struct regulator_ops *ops = rdev->desc->ops; | 2184 | struct regulator_ops *ops = rdev->desc->ops; |
2185 | int ret; | 2185 | int ret; |
2186 | 2186 | ||
2187 | if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector) | ||
2188 | return rdev->desc->fixed_uV; | ||
2189 | |||
2187 | if (!ops->list_voltage || selector >= rdev->desc->n_voltages) | 2190 | if (!ops->list_voltage || selector >= rdev->desc->n_voltages) |
2188 | return -EINVAL; | 2191 | return -EINVAL; |
2189 | 2192 | ||
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 04406a918c04..234960dc9607 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
@@ -139,6 +139,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | |||
139 | struct property *prop; | 139 | struct property *prop; |
140 | const char *regtype; | 140 | const char *regtype; |
141 | int proplen, gpio, i; | 141 | int proplen, gpio, i; |
142 | int ret; | ||
142 | 143 | ||
143 | config = devm_kzalloc(dev, | 144 | config = devm_kzalloc(dev, |
144 | sizeof(struct gpio_regulator_config), | 145 | sizeof(struct gpio_regulator_config), |
@@ -202,7 +203,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | |||
202 | } | 203 | } |
203 | config->nr_states = i; | 204 | config->nr_states = i; |
204 | 205 | ||
205 | of_property_read_string(np, "regulator-type", ®type); | 206 | ret = of_property_read_string(np, "regulator-type", ®type); |
207 | if (ret < 0) { | ||
208 | dev_err(dev, "Missing 'regulator-type' property\n"); | ||
209 | return ERR_PTR(-EINVAL); | ||
210 | } | ||
206 | 211 | ||
207 | if (!strncmp("voltage", regtype, 7)) | 212 | if (!strncmp("voltage", regtype, 7)) |
208 | config->type = REGULATOR_VOLTAGE; | 213 | config->type = REGULATOR_VOLTAGE; |
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c index ba67b2c4e2e7..032df3799efb 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c | |||
@@ -308,9 +308,15 @@ static int pfuze_identify(struct pfuze_chip *pfuze_chip) | |||
308 | if (ret) | 308 | if (ret) |
309 | return ret; | 309 | return ret; |
310 | 310 | ||
311 | if (value & 0x0f) { | 311 | switch (value & 0x0f) { |
312 | dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value); | 312 | /* Freescale misprogrammed 1-3% of parts prior to week 8 of 2013 as ID=8 */ |
313 | return -ENODEV; | 313 | case 0x8: |
314 | dev_info(pfuze_chip->dev, "Assuming misprogrammed ID=0x8"); | ||
315 | case 0x0: | ||
316 | break; | ||
317 | default: | ||
318 | dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value); | ||
319 | return -ENODEV; | ||
314 | } | 320 | } |
315 | 321 | ||
316 | ret = regmap_read(pfuze_chip->regmap, PFUZE100_REVID, &value); | 322 | ret = regmap_read(pfuze_chip->regmap, PFUZE100_REVID, &value); |
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index cee7e2708a1f..95e45782692f 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c | |||
@@ -3224,6 +3224,8 @@ static struct dasd_ccw_req *dasd_eckd_build_cp(struct dasd_device *startdev, | |||
3224 | 3224 | ||
3225 | fcx_multitrack = private->features.feature[40] & 0x20; | 3225 | fcx_multitrack = private->features.feature[40] & 0x20; |
3226 | data_size = blk_rq_bytes(req); | 3226 | data_size = blk_rq_bytes(req); |
3227 | if (data_size % blksize) | ||
3228 | return ERR_PTR(-EINVAL); | ||
3227 | /* tpm write request add CBC data on each track boundary */ | 3229 | /* tpm write request add CBC data on each track boundary */ |
3228 | if (rq_data_dir(req) == WRITE) | 3230 | if (rq_data_dir(req) == WRITE) |
3229 | data_size += (last_trk - first_trk) * 4; | 3231 | data_size += (last_trk - first_trk) * 4; |
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 5e1e12c0cf42..0a7325361d29 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -2025,7 +2025,8 @@ static struct scsi_host_template driver_template = { | |||
2025 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, | 2025 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, |
2026 | .use_clustering = ENABLE_CLUSTERING, | 2026 | .use_clustering = ENABLE_CLUSTERING, |
2027 | .shost_attrs = twa_host_attrs, | 2027 | .shost_attrs = twa_host_attrs, |
2028 | .emulated = 1 | 2028 | .emulated = 1, |
2029 | .no_write_same = 1, | ||
2029 | }; | 2030 | }; |
2030 | 2031 | ||
2031 | /* This function will probe and initialize a card */ | 2032 | /* This function will probe and initialize a card */ |
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index c845bdbeb6c0..4de346017e9f 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c | |||
@@ -1600,7 +1600,8 @@ static struct scsi_host_template driver_template = { | |||
1600 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, | 1600 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, |
1601 | .use_clustering = ENABLE_CLUSTERING, | 1601 | .use_clustering = ENABLE_CLUSTERING, |
1602 | .shost_attrs = twl_host_attrs, | 1602 | .shost_attrs = twl_host_attrs, |
1603 | .emulated = 1 | 1603 | .emulated = 1, |
1604 | .no_write_same = 1, | ||
1604 | }; | 1605 | }; |
1605 | 1606 | ||
1606 | /* This function will probe and initialize a card */ | 1607 | /* This function will probe and initialize a card */ |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index b9276d10b25c..752624e6bc00 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
@@ -2279,7 +2279,8 @@ static struct scsi_host_template driver_template = { | |||
2279 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, | 2279 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, |
2280 | .use_clustering = ENABLE_CLUSTERING, | 2280 | .use_clustering = ENABLE_CLUSTERING, |
2281 | .shost_attrs = tw_host_attrs, | 2281 | .shost_attrs = tw_host_attrs, |
2282 | .emulated = 1 | 2282 | .emulated = 1, |
2283 | .no_write_same = 1, | ||
2283 | }; | 2284 | }; |
2284 | 2285 | ||
2285 | /* This function will probe and initialize a card */ | 2286 | /* This function will probe and initialize a card */ |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index f0d432c139d0..4921ed19a027 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -1081,6 +1081,7 @@ static struct scsi_host_template aac_driver_template = { | |||
1081 | #endif | 1081 | #endif |
1082 | .use_clustering = ENABLE_CLUSTERING, | 1082 | .use_clustering = ENABLE_CLUSTERING, |
1083 | .emulated = 1, | 1083 | .emulated = 1, |
1084 | .no_write_same = 1, | ||
1084 | }; | 1085 | }; |
1085 | 1086 | ||
1086 | static void __aac_shutdown(struct aac_dev * aac) | 1087 | static void __aac_shutdown(struct aac_dev * aac) |
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 97fd450aff09..4f6a30b8e5f9 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c | |||
@@ -137,6 +137,7 @@ static struct scsi_host_template arcmsr_scsi_host_template = { | |||
137 | .cmd_per_lun = ARCMSR_MAX_CMD_PERLUN, | 137 | .cmd_per_lun = ARCMSR_MAX_CMD_PERLUN, |
138 | .use_clustering = ENABLE_CLUSTERING, | 138 | .use_clustering = ENABLE_CLUSTERING, |
139 | .shost_attrs = arcmsr_host_attrs, | 139 | .shost_attrs = arcmsr_host_attrs, |
140 | .no_write_same = 1, | ||
140 | }; | 141 | }; |
141 | static struct pci_device_id arcmsr_device_id_table[] = { | 142 | static struct pci_device_id arcmsr_device_id_table[] = { |
142 | {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1110)}, | 143 | {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1110)}, |
diff --git a/drivers/scsi/bfa/bfa_fcs.h b/drivers/scsi/bfa/bfa_fcs.h index 94d5d0102f7d..42bcb970445a 100644 --- a/drivers/scsi/bfa/bfa_fcs.h +++ b/drivers/scsi/bfa/bfa_fcs.h | |||
@@ -296,6 +296,7 @@ wwn_t bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s *port, wwn_t wwn, | |||
296 | struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs, | 296 | struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs, |
297 | u16 vf_id, wwn_t lpwwn); | 297 | u16 vf_id, wwn_t lpwwn); |
298 | 298 | ||
299 | void bfa_fcs_lport_set_symname(struct bfa_fcs_lport_s *port, char *symname); | ||
299 | void bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port, | 300 | void bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port, |
300 | struct bfa_lport_info_s *port_info); | 301 | struct bfa_lport_info_s *port_info); |
301 | void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port, | 302 | void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port, |
diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c index 2f61a5af3658..f5e4e61a0fd7 100644 --- a/drivers/scsi/bfa/bfa_fcs_lport.c +++ b/drivers/scsi/bfa/bfa_fcs_lport.c | |||
@@ -1097,6 +1097,17 @@ bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport, | |||
1097 | bfa_sm_send_event(lport, BFA_FCS_PORT_SM_CREATE); | 1097 | bfa_sm_send_event(lport, BFA_FCS_PORT_SM_CREATE); |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | void | ||
1101 | bfa_fcs_lport_set_symname(struct bfa_fcs_lport_s *port, | ||
1102 | char *symname) | ||
1103 | { | ||
1104 | strcpy(port->port_cfg.sym_name.symname, symname); | ||
1105 | |||
1106 | if (bfa_sm_cmp_state(port, bfa_fcs_lport_sm_online)) | ||
1107 | bfa_fcs_lport_ns_util_send_rspn_id( | ||
1108 | BFA_FCS_GET_NS_FROM_PORT(port), NULL); | ||
1109 | } | ||
1110 | |||
1100 | /* | 1111 | /* |
1101 | * fcs_lport_api | 1112 | * fcs_lport_api |
1102 | */ | 1113 | */ |
@@ -5140,9 +5151,6 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced) | |||
5140 | u8 *psymbl = &symbl[0]; | 5151 | u8 *psymbl = &symbl[0]; |
5141 | int len; | 5152 | int len; |
5142 | 5153 | ||
5143 | if (!bfa_sm_cmp_state(port, bfa_fcs_lport_sm_online)) | ||
5144 | return; | ||
5145 | |||
5146 | /* Avoid sending RSPN in the following states. */ | 5154 | /* Avoid sending RSPN in the following states. */ |
5147 | if (bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_offline) || | 5155 | if (bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_offline) || |
5148 | bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_plogi_sending) || | 5156 | bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_plogi_sending) || |
diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c index e9a681d31223..40be670a1cbc 100644 --- a/drivers/scsi/bfa/bfad_attr.c +++ b/drivers/scsi/bfa/bfad_attr.c | |||
@@ -593,11 +593,8 @@ bfad_im_vport_set_symbolic_name(struct fc_vport *fc_vport) | |||
593 | return; | 593 | return; |
594 | 594 | ||
595 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 595 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
596 | if (strlen(sym_name) > 0) { | 596 | if (strlen(sym_name) > 0) |
597 | strcpy(fcs_vport->lport.port_cfg.sym_name.symname, sym_name); | 597 | bfa_fcs_lport_set_symname(&fcs_vport->lport, sym_name); |
598 | bfa_fcs_lport_ns_util_send_rspn_id( | ||
599 | BFA_FCS_GET_NS_FROM_PORT((&fcs_vport->lport)), NULL); | ||
600 | } | ||
601 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 598 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
602 | } | 599 | } |
603 | 600 | ||
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index ee4fa40a50b1..ce5ef0190bad 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -4684,6 +4684,7 @@ static struct scsi_host_template gdth_template = { | |||
4684 | .cmd_per_lun = GDTH_MAXC_P_L, | 4684 | .cmd_per_lun = GDTH_MAXC_P_L, |
4685 | .unchecked_isa_dma = 1, | 4685 | .unchecked_isa_dma = 1, |
4686 | .use_clustering = ENABLE_CLUSTERING, | 4686 | .use_clustering = ENABLE_CLUSTERING, |
4687 | .no_write_same = 1, | ||
4687 | }; | 4688 | }; |
4688 | 4689 | ||
4689 | #ifdef CONFIG_ISA | 4690 | #ifdef CONFIG_ISA |
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index f334859024c0..f2c5005f312a 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
@@ -395,6 +395,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
395 | shost->use_clustering = sht->use_clustering; | 395 | shost->use_clustering = sht->use_clustering; |
396 | shost->ordered_tag = sht->ordered_tag; | 396 | shost->ordered_tag = sht->ordered_tag; |
397 | shost->eh_deadline = shost_eh_deadline * HZ; | 397 | shost->eh_deadline = shost_eh_deadline * HZ; |
398 | shost->no_write_same = sht->no_write_same; | ||
398 | 399 | ||
399 | if (sht->supported_mode == MODE_UNKNOWN) | 400 | if (sht->supported_mode == MODE_UNKNOWN) |
400 | /* means we didn't set it ... default to INITIATOR */ | 401 | /* means we didn't set it ... default to INITIATOR */ |
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 22f6432eb475..20a5e6ecf945 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -561,6 +561,7 @@ static struct scsi_host_template hpsa_driver_template = { | |||
561 | .sdev_attrs = hpsa_sdev_attrs, | 561 | .sdev_attrs = hpsa_sdev_attrs, |
562 | .shost_attrs = hpsa_shost_attrs, | 562 | .shost_attrs = hpsa_shost_attrs, |
563 | .max_sectors = 8192, | 563 | .max_sectors = 8192, |
564 | .no_write_same = 1, | ||
564 | }; | 565 | }; |
565 | 566 | ||
566 | 567 | ||
@@ -1288,7 +1289,7 @@ static void complete_scsi_command(struct CommandList *cp) | |||
1288 | "has check condition: aborted command: " | 1289 | "has check condition: aborted command: " |
1289 | "ASC: 0x%x, ASCQ: 0x%x\n", | 1290 | "ASC: 0x%x, ASCQ: 0x%x\n", |
1290 | cp, asc, ascq); | 1291 | cp, asc, ascq); |
1291 | cmd->result = DID_SOFT_ERROR << 16; | 1292 | cmd->result |= DID_SOFT_ERROR << 16; |
1292 | break; | 1293 | break; |
1293 | } | 1294 | } |
1294 | /* Must be some other type of check condition */ | 1295 | /* Must be some other type of check condition */ |
@@ -4925,7 +4926,7 @@ reinit_after_soft_reset: | |||
4925 | hpsa_hba_inquiry(h); | 4926 | hpsa_hba_inquiry(h); |
4926 | hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */ | 4927 | hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */ |
4927 | start_controller_lockup_detector(h); | 4928 | start_controller_lockup_detector(h); |
4928 | return 1; | 4929 | return 0; |
4929 | 4930 | ||
4930 | clean4: | 4931 | clean4: |
4931 | hpsa_free_sg_chain_blocks(h); | 4932 | hpsa_free_sg_chain_blocks(h); |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 36ac1c34ce97..573f4128b6b6 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -6305,7 +6305,8 @@ static struct scsi_host_template driver_template = { | |||
6305 | .use_clustering = ENABLE_CLUSTERING, | 6305 | .use_clustering = ENABLE_CLUSTERING, |
6306 | .shost_attrs = ipr_ioa_attrs, | 6306 | .shost_attrs = ipr_ioa_attrs, |
6307 | .sdev_attrs = ipr_dev_attrs, | 6307 | .sdev_attrs = ipr_dev_attrs, |
6308 | .proc_name = IPR_NAME | 6308 | .proc_name = IPR_NAME, |
6309 | .no_write_same = 1, | ||
6309 | }; | 6310 | }; |
6310 | 6311 | ||
6311 | /** | 6312 | /** |
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 8d5ea8a1e5a6..52a216f21ae5 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c | |||
@@ -374,6 +374,7 @@ static struct scsi_host_template ips_driver_template = { | |||
374 | .sg_tablesize = IPS_MAX_SG, | 374 | .sg_tablesize = IPS_MAX_SG, |
375 | .cmd_per_lun = 3, | 375 | .cmd_per_lun = 3, |
376 | .use_clustering = ENABLE_CLUSTERING, | 376 | .use_clustering = ENABLE_CLUSTERING, |
377 | .no_write_same = 1, | ||
377 | }; | 378 | }; |
378 | 379 | ||
379 | 380 | ||
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 161c98efade9..d2895836f9fa 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c | |||
@@ -211,7 +211,7 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) | |||
211 | qc->tf.nsect = 0; | 211 | qc->tf.nsect = 0; |
212 | } | 212 | } |
213 | 213 | ||
214 | ata_tf_to_fis(&qc->tf, 1, 0, (u8*)&task->ata_task.fis); | 214 | ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, (u8 *)&task->ata_task.fis); |
215 | task->uldd_task = qc; | 215 | task->uldd_task = qc; |
216 | if (ata_is_atapi(qc->tf.protocol)) { | 216 | if (ata_is_atapi(qc->tf.protocol)) { |
217 | memcpy(task->ata_task.atapi_packet, qc->cdb, qc->dev->cdb_len); | 217 | memcpy(task->ata_task.atapi_packet, qc->cdb, qc->dev->cdb_len); |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 90c95a3385d1..816db12ef5d5 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -4244,6 +4244,7 @@ static struct scsi_host_template megaraid_template = { | |||
4244 | .eh_device_reset_handler = megaraid_reset, | 4244 | .eh_device_reset_handler = megaraid_reset, |
4245 | .eh_bus_reset_handler = megaraid_reset, | 4245 | .eh_bus_reset_handler = megaraid_reset, |
4246 | .eh_host_reset_handler = megaraid_reset, | 4246 | .eh_host_reset_handler = megaraid_reset, |
4247 | .no_write_same = 1, | ||
4247 | }; | 4248 | }; |
4248 | 4249 | ||
4249 | static int | 4250 | static int |
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index d1a4b82836ea..e2237a97cb9d 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c | |||
@@ -367,6 +367,7 @@ static struct scsi_host_template megaraid_template_g = { | |||
367 | .eh_host_reset_handler = megaraid_reset_handler, | 367 | .eh_host_reset_handler = megaraid_reset_handler, |
368 | .change_queue_depth = megaraid_change_queue_depth, | 368 | .change_queue_depth = megaraid_change_queue_depth, |
369 | .use_clustering = ENABLE_CLUSTERING, | 369 | .use_clustering = ENABLE_CLUSTERING, |
370 | .no_write_same = 1, | ||
370 | .sdev_attrs = megaraid_sdev_attrs, | 371 | .sdev_attrs = megaraid_sdev_attrs, |
371 | .shost_attrs = megaraid_shost_attrs, | 372 | .shost_attrs = megaraid_shost_attrs, |
372 | }; | 373 | }; |
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 0a743a5d1647..c99812bf2a73 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c | |||
@@ -2148,6 +2148,7 @@ static struct scsi_host_template megasas_template = { | |||
2148 | .bios_param = megasas_bios_param, | 2148 | .bios_param = megasas_bios_param, |
2149 | .use_clustering = ENABLE_CLUSTERING, | 2149 | .use_clustering = ENABLE_CLUSTERING, |
2150 | .change_queue_depth = megasas_change_queue_depth, | 2150 | .change_queue_depth = megasas_change_queue_depth, |
2151 | .no_write_same = 1, | ||
2151 | }; | 2152 | }; |
2152 | 2153 | ||
2153 | /** | 2154 | /** |
diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index f16ece91b94a..0a1296a87d66 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c | |||
@@ -3403,6 +3403,7 @@ hw_event_sas_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) | |||
3403 | unsigned long flags; | 3403 | unsigned long flags; |
3404 | u8 deviceType = pPayload->sas_identify.dev_type; | 3404 | u8 deviceType = pPayload->sas_identify.dev_type; |
3405 | port->port_state = portstate; | 3405 | port->port_state = portstate; |
3406 | phy->phy_state = PHY_STATE_LINK_UP_SPC; | ||
3406 | PM8001_MSG_DBG(pm8001_ha, | 3407 | PM8001_MSG_DBG(pm8001_ha, |
3407 | pm8001_printk("HW_EVENT_SAS_PHY_UP port id = %d, phy id = %d\n", | 3408 | pm8001_printk("HW_EVENT_SAS_PHY_UP port id = %d, phy id = %d\n", |
3408 | port_id, phy_id)); | 3409 | port_id, phy_id)); |
@@ -3483,6 +3484,7 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) | |||
3483 | pm8001_printk("HW_EVENT_SATA_PHY_UP port id = %d," | 3484 | pm8001_printk("HW_EVENT_SATA_PHY_UP port id = %d," |
3484 | " phy id = %d\n", port_id, phy_id)); | 3485 | " phy id = %d\n", port_id, phy_id)); |
3485 | port->port_state = portstate; | 3486 | port->port_state = portstate; |
3487 | phy->phy_state = PHY_STATE_LINK_UP_SPC; | ||
3486 | port->port_attached = 1; | 3488 | port->port_attached = 1; |
3487 | pm8001_get_lrate_mode(phy, link_rate); | 3489 | pm8001_get_lrate_mode(phy, link_rate); |
3488 | phy->phy_type |= PORT_TYPE_SATA; | 3490 | phy->phy_type |= PORT_TYPE_SATA; |
diff --git a/drivers/scsi/pm8001/pm8001_hwi.h b/drivers/scsi/pm8001/pm8001_hwi.h index 6d91e2446542..e4867e690c84 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.h +++ b/drivers/scsi/pm8001/pm8001_hwi.h | |||
@@ -131,6 +131,10 @@ | |||
131 | #define LINKRATE_30 (0x02 << 8) | 131 | #define LINKRATE_30 (0x02 << 8) |
132 | #define LINKRATE_60 (0x04 << 8) | 132 | #define LINKRATE_60 (0x04 << 8) |
133 | 133 | ||
134 | /* for phy state */ | ||
135 | |||
136 | #define PHY_STATE_LINK_UP_SPC 0x1 | ||
137 | |||
134 | /* for new SPC controllers MEMBASE III is shared between BIOS and DATA */ | 138 | /* for new SPC controllers MEMBASE III is shared between BIOS and DATA */ |
135 | #define GSM_SM_BASE 0x4F0000 | 139 | #define GSM_SM_BASE 0x4F0000 |
136 | struct mpi_msg_hdr{ | 140 | struct mpi_msg_hdr{ |
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 34f5f5ffef05..73a120d81b4d 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c | |||
@@ -175,20 +175,16 @@ static void pm8001_free(struct pm8001_hba_info *pm8001_ha) | |||
175 | static void pm8001_tasklet(unsigned long opaque) | 175 | static void pm8001_tasklet(unsigned long opaque) |
176 | { | 176 | { |
177 | struct pm8001_hba_info *pm8001_ha; | 177 | struct pm8001_hba_info *pm8001_ha; |
178 | u32 vec; | 178 | struct isr_param *irq_vector; |
179 | pm8001_ha = (struct pm8001_hba_info *)opaque; | 179 | |
180 | irq_vector = (struct isr_param *)opaque; | ||
181 | pm8001_ha = irq_vector->drv_inst; | ||
180 | if (unlikely(!pm8001_ha)) | 182 | if (unlikely(!pm8001_ha)) |
181 | BUG_ON(1); | 183 | BUG_ON(1); |
182 | vec = pm8001_ha->int_vector; | 184 | PM8001_CHIP_DISP->isr(pm8001_ha, irq_vector->irq_id); |
183 | PM8001_CHIP_DISP->isr(pm8001_ha, vec); | ||
184 | } | 185 | } |
185 | #endif | 186 | #endif |
186 | 187 | ||
187 | static struct pm8001_hba_info *outq_to_hba(u8 *outq) | ||
188 | { | ||
189 | return container_of((outq - *outq), struct pm8001_hba_info, outq[0]); | ||
190 | } | ||
191 | |||
192 | /** | 188 | /** |
193 | * pm8001_interrupt_handler_msix - main MSIX interrupt handler. | 189 | * pm8001_interrupt_handler_msix - main MSIX interrupt handler. |
194 | * It obtains the vector number and calls the equivalent bottom | 190 | * It obtains the vector number and calls the equivalent bottom |
@@ -198,18 +194,20 @@ static struct pm8001_hba_info *outq_to_hba(u8 *outq) | |||
198 | */ | 194 | */ |
199 | static irqreturn_t pm8001_interrupt_handler_msix(int irq, void *opaque) | 195 | static irqreturn_t pm8001_interrupt_handler_msix(int irq, void *opaque) |
200 | { | 196 | { |
201 | struct pm8001_hba_info *pm8001_ha = outq_to_hba(opaque); | 197 | struct isr_param *irq_vector; |
202 | u8 outq = *(u8 *)opaque; | 198 | struct pm8001_hba_info *pm8001_ha; |
203 | irqreturn_t ret = IRQ_HANDLED; | 199 | irqreturn_t ret = IRQ_HANDLED; |
200 | irq_vector = (struct isr_param *)opaque; | ||
201 | pm8001_ha = irq_vector->drv_inst; | ||
202 | |||
204 | if (unlikely(!pm8001_ha)) | 203 | if (unlikely(!pm8001_ha)) |
205 | return IRQ_NONE; | 204 | return IRQ_NONE; |
206 | if (!PM8001_CHIP_DISP->is_our_interupt(pm8001_ha)) | 205 | if (!PM8001_CHIP_DISP->is_our_interupt(pm8001_ha)) |
207 | return IRQ_NONE; | 206 | return IRQ_NONE; |
208 | pm8001_ha->int_vector = outq; | ||
209 | #ifdef PM8001_USE_TASKLET | 207 | #ifdef PM8001_USE_TASKLET |
210 | tasklet_schedule(&pm8001_ha->tasklet); | 208 | tasklet_schedule(&pm8001_ha->tasklet[irq_vector->irq_id]); |
211 | #else | 209 | #else |
212 | ret = PM8001_CHIP_DISP->isr(pm8001_ha, outq); | 210 | ret = PM8001_CHIP_DISP->isr(pm8001_ha, irq_vector->irq_id); |
213 | #endif | 211 | #endif |
214 | return ret; | 212 | return ret; |
215 | } | 213 | } |
@@ -230,9 +228,8 @@ static irqreturn_t pm8001_interrupt_handler_intx(int irq, void *dev_id) | |||
230 | if (!PM8001_CHIP_DISP->is_our_interupt(pm8001_ha)) | 228 | if (!PM8001_CHIP_DISP->is_our_interupt(pm8001_ha)) |
231 | return IRQ_NONE; | 229 | return IRQ_NONE; |
232 | 230 | ||
233 | pm8001_ha->int_vector = 0; | ||
234 | #ifdef PM8001_USE_TASKLET | 231 | #ifdef PM8001_USE_TASKLET |
235 | tasklet_schedule(&pm8001_ha->tasklet); | 232 | tasklet_schedule(&pm8001_ha->tasklet[0]); |
236 | #else | 233 | #else |
237 | ret = PM8001_CHIP_DISP->isr(pm8001_ha, 0); | 234 | ret = PM8001_CHIP_DISP->isr(pm8001_ha, 0); |
238 | #endif | 235 | #endif |
@@ -457,7 +454,7 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev, | |||
457 | { | 454 | { |
458 | struct pm8001_hba_info *pm8001_ha; | 455 | struct pm8001_hba_info *pm8001_ha; |
459 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); | 456 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
460 | 457 | int j; | |
461 | 458 | ||
462 | pm8001_ha = sha->lldd_ha; | 459 | pm8001_ha = sha->lldd_ha; |
463 | if (!pm8001_ha) | 460 | if (!pm8001_ha) |
@@ -480,12 +477,14 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev, | |||
480 | pm8001_ha->iomb_size = IOMB_SIZE_SPC; | 477 | pm8001_ha->iomb_size = IOMB_SIZE_SPC; |
481 | 478 | ||
482 | #ifdef PM8001_USE_TASKLET | 479 | #ifdef PM8001_USE_TASKLET |
483 | /** | 480 | /* Tasklet for non msi-x interrupt handler */ |
484 | * default tasklet for non msi-x interrupt handler/first msi-x | 481 | if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001)) |
485 | * interrupt handler | 482 | tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet, |
486 | **/ | 483 | (unsigned long)&(pm8001_ha->irq_vector[0])); |
487 | tasklet_init(&pm8001_ha->tasklet, pm8001_tasklet, | 484 | else |
488 | (unsigned long)pm8001_ha); | 485 | for (j = 0; j < PM8001_MAX_MSIX_VEC; j++) |
486 | tasklet_init(&pm8001_ha->tasklet[j], pm8001_tasklet, | ||
487 | (unsigned long)&(pm8001_ha->irq_vector[j])); | ||
489 | #endif | 488 | #endif |
490 | pm8001_ioremap(pm8001_ha); | 489 | pm8001_ioremap(pm8001_ha); |
491 | if (!pm8001_alloc(pm8001_ha, ent)) | 490 | if (!pm8001_alloc(pm8001_ha, ent)) |
@@ -733,19 +732,20 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha) | |||
733 | "pci_enable_msix request ret:%d no of intr %d\n", | 732 | "pci_enable_msix request ret:%d no of intr %d\n", |
734 | rc, pm8001_ha->number_of_intr)); | 733 | rc, pm8001_ha->number_of_intr)); |
735 | 734 | ||
736 | for (i = 0; i < number_of_intr; i++) | ||
737 | pm8001_ha->outq[i] = i; | ||
738 | 735 | ||
739 | for (i = 0; i < number_of_intr; i++) { | 736 | for (i = 0; i < number_of_intr; i++) { |
740 | snprintf(intr_drvname[i], sizeof(intr_drvname[0]), | 737 | snprintf(intr_drvname[i], sizeof(intr_drvname[0]), |
741 | DRV_NAME"%d", i); | 738 | DRV_NAME"%d", i); |
739 | pm8001_ha->irq_vector[i].irq_id = i; | ||
740 | pm8001_ha->irq_vector[i].drv_inst = pm8001_ha; | ||
741 | |||
742 | if (request_irq(pm8001_ha->msix_entries[i].vector, | 742 | if (request_irq(pm8001_ha->msix_entries[i].vector, |
743 | pm8001_interrupt_handler_msix, flag, | 743 | pm8001_interrupt_handler_msix, flag, |
744 | intr_drvname[i], &pm8001_ha->outq[i])) { | 744 | intr_drvname[i], &(pm8001_ha->irq_vector[i]))) { |
745 | for (j = 0; j < i; j++) | 745 | for (j = 0; j < i; j++) |
746 | free_irq( | 746 | free_irq( |
747 | pm8001_ha->msix_entries[j].vector, | 747 | pm8001_ha->msix_entries[j].vector, |
748 | &pm8001_ha->outq[j]); | 748 | &(pm8001_ha->irq_vector[i])); |
749 | pci_disable_msix(pm8001_ha->pdev); | 749 | pci_disable_msix(pm8001_ha->pdev); |
750 | break; | 750 | break; |
751 | } | 751 | } |
@@ -907,7 +907,7 @@ static void pm8001_pci_remove(struct pci_dev *pdev) | |||
907 | { | 907 | { |
908 | struct sas_ha_struct *sha = pci_get_drvdata(pdev); | 908 | struct sas_ha_struct *sha = pci_get_drvdata(pdev); |
909 | struct pm8001_hba_info *pm8001_ha; | 909 | struct pm8001_hba_info *pm8001_ha; |
910 | int i; | 910 | int i, j; |
911 | pm8001_ha = sha->lldd_ha; | 911 | pm8001_ha = sha->lldd_ha; |
912 | sas_unregister_ha(sha); | 912 | sas_unregister_ha(sha); |
913 | sas_remove_host(pm8001_ha->shost); | 913 | sas_remove_host(pm8001_ha->shost); |
@@ -921,13 +921,18 @@ static void pm8001_pci_remove(struct pci_dev *pdev) | |||
921 | synchronize_irq(pm8001_ha->msix_entries[i].vector); | 921 | synchronize_irq(pm8001_ha->msix_entries[i].vector); |
922 | for (i = 0; i < pm8001_ha->number_of_intr; i++) | 922 | for (i = 0; i < pm8001_ha->number_of_intr; i++) |
923 | free_irq(pm8001_ha->msix_entries[i].vector, | 923 | free_irq(pm8001_ha->msix_entries[i].vector, |
924 | &pm8001_ha->outq[i]); | 924 | &(pm8001_ha->irq_vector[i])); |
925 | pci_disable_msix(pdev); | 925 | pci_disable_msix(pdev); |
926 | #else | 926 | #else |
927 | free_irq(pm8001_ha->irq, sha); | 927 | free_irq(pm8001_ha->irq, sha); |
928 | #endif | 928 | #endif |
929 | #ifdef PM8001_USE_TASKLET | 929 | #ifdef PM8001_USE_TASKLET |
930 | tasklet_kill(&pm8001_ha->tasklet); | 930 | /* For non-msix and msix interrupts */ |
931 | if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001)) | ||
932 | tasklet_kill(&pm8001_ha->tasklet[0]); | ||
933 | else | ||
934 | for (j = 0; j < PM8001_MAX_MSIX_VEC; j++) | ||
935 | tasklet_kill(&pm8001_ha->tasklet[j]); | ||
931 | #endif | 936 | #endif |
932 | pm8001_free(pm8001_ha); | 937 | pm8001_free(pm8001_ha); |
933 | kfree(sha->sas_phy); | 938 | kfree(sha->sas_phy); |
@@ -948,7 +953,7 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
948 | { | 953 | { |
949 | struct sas_ha_struct *sha = pci_get_drvdata(pdev); | 954 | struct sas_ha_struct *sha = pci_get_drvdata(pdev); |
950 | struct pm8001_hba_info *pm8001_ha; | 955 | struct pm8001_hba_info *pm8001_ha; |
951 | int i; | 956 | int i, j; |
952 | u32 device_state; | 957 | u32 device_state; |
953 | pm8001_ha = sha->lldd_ha; | 958 | pm8001_ha = sha->lldd_ha; |
954 | flush_workqueue(pm8001_wq); | 959 | flush_workqueue(pm8001_wq); |
@@ -964,13 +969,18 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
964 | synchronize_irq(pm8001_ha->msix_entries[i].vector); | 969 | synchronize_irq(pm8001_ha->msix_entries[i].vector); |
965 | for (i = 0; i < pm8001_ha->number_of_intr; i++) | 970 | for (i = 0; i < pm8001_ha->number_of_intr; i++) |
966 | free_irq(pm8001_ha->msix_entries[i].vector, | 971 | free_irq(pm8001_ha->msix_entries[i].vector, |
967 | &pm8001_ha->outq[i]); | 972 | &(pm8001_ha->irq_vector[i])); |
968 | pci_disable_msix(pdev); | 973 | pci_disable_msix(pdev); |
969 | #else | 974 | #else |
970 | free_irq(pm8001_ha->irq, sha); | 975 | free_irq(pm8001_ha->irq, sha); |
971 | #endif | 976 | #endif |
972 | #ifdef PM8001_USE_TASKLET | 977 | #ifdef PM8001_USE_TASKLET |
973 | tasklet_kill(&pm8001_ha->tasklet); | 978 | /* For non-msix and msix interrupts */ |
979 | if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001)) | ||
980 | tasklet_kill(&pm8001_ha->tasklet[0]); | ||
981 | else | ||
982 | for (j = 0; j < PM8001_MAX_MSIX_VEC; j++) | ||
983 | tasklet_kill(&pm8001_ha->tasklet[j]); | ||
974 | #endif | 984 | #endif |
975 | device_state = pci_choose_state(pdev, state); | 985 | device_state = pci_choose_state(pdev, state); |
976 | pm8001_printk("pdev=0x%p, slot=%s, entering " | 986 | pm8001_printk("pdev=0x%p, slot=%s, entering " |
@@ -993,7 +1003,7 @@ static int pm8001_pci_resume(struct pci_dev *pdev) | |||
993 | struct sas_ha_struct *sha = pci_get_drvdata(pdev); | 1003 | struct sas_ha_struct *sha = pci_get_drvdata(pdev); |
994 | struct pm8001_hba_info *pm8001_ha; | 1004 | struct pm8001_hba_info *pm8001_ha; |
995 | int rc; | 1005 | int rc; |
996 | u8 i = 0; | 1006 | u8 i = 0, j; |
997 | u32 device_state; | 1007 | u32 device_state; |
998 | pm8001_ha = sha->lldd_ha; | 1008 | pm8001_ha = sha->lldd_ha; |
999 | device_state = pdev->current_state; | 1009 | device_state = pdev->current_state; |
@@ -1033,10 +1043,14 @@ static int pm8001_pci_resume(struct pci_dev *pdev) | |||
1033 | if (rc) | 1043 | if (rc) |
1034 | goto err_out_disable; | 1044 | goto err_out_disable; |
1035 | #ifdef PM8001_USE_TASKLET | 1045 | #ifdef PM8001_USE_TASKLET |
1036 | /* default tasklet for non msi-x interrupt handler/first msi-x | 1046 | /* Tasklet for non msi-x interrupt handler */ |
1037 | * interrupt handler */ | 1047 | if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001)) |
1038 | tasklet_init(&pm8001_ha->tasklet, pm8001_tasklet, | 1048 | tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet, |
1039 | (unsigned long)pm8001_ha); | 1049 | (unsigned long)&(pm8001_ha->irq_vector[0])); |
1050 | else | ||
1051 | for (j = 0; j < PM8001_MAX_MSIX_VEC; j++) | ||
1052 | tasklet_init(&pm8001_ha->tasklet[j], pm8001_tasklet, | ||
1053 | (unsigned long)&(pm8001_ha->irq_vector[j])); | ||
1040 | #endif | 1054 | #endif |
1041 | PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0); | 1055 | PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0); |
1042 | if (pm8001_ha->chip_id != chip_8001) { | 1056 | if (pm8001_ha->chip_id != chip_8001) { |
@@ -1169,6 +1183,7 @@ module_exit(pm8001_exit); | |||
1169 | MODULE_AUTHOR("Jack Wang <jack_wang@usish.com>"); | 1183 | MODULE_AUTHOR("Jack Wang <jack_wang@usish.com>"); |
1170 | MODULE_AUTHOR("Anand Kumar Santhanam <AnandKumar.Santhanam@pmcs.com>"); | 1184 | MODULE_AUTHOR("Anand Kumar Santhanam <AnandKumar.Santhanam@pmcs.com>"); |
1171 | MODULE_AUTHOR("Sangeetha Gnanasekaran <Sangeetha.Gnanasekaran@pmcs.com>"); | 1185 | MODULE_AUTHOR("Sangeetha Gnanasekaran <Sangeetha.Gnanasekaran@pmcs.com>"); |
1186 | MODULE_AUTHOR("Nikith Ganigarakoppal <Nikith.Ganigarakoppal@pmcs.com>"); | ||
1172 | MODULE_DESCRIPTION( | 1187 | MODULE_DESCRIPTION( |
1173 | "PMC-Sierra PM8001/8081/8088/8089/8074/8076/8077 " | 1188 | "PMC-Sierra PM8001/8081/8088/8089/8074/8076/8077 " |
1174 | "SAS/SATA controller driver"); | 1189 | "SAS/SATA controller driver"); |
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index f4eb18e51631..f50ac44b950e 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c | |||
@@ -1098,15 +1098,17 @@ int pm8001_lu_reset(struct domain_device *dev, u8 *lun) | |||
1098 | struct pm8001_tmf_task tmf_task; | 1098 | struct pm8001_tmf_task tmf_task; |
1099 | struct pm8001_device *pm8001_dev = dev->lldd_dev; | 1099 | struct pm8001_device *pm8001_dev = dev->lldd_dev; |
1100 | struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev); | 1100 | struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev); |
1101 | DECLARE_COMPLETION_ONSTACK(completion_setstate); | ||
1101 | if (dev_is_sata(dev)) { | 1102 | if (dev_is_sata(dev)) { |
1102 | struct sas_phy *phy = sas_get_local_phy(dev); | 1103 | struct sas_phy *phy = sas_get_local_phy(dev); |
1103 | rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev , | 1104 | rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev , |
1104 | dev, 1, 0); | 1105 | dev, 1, 0); |
1105 | rc = sas_phy_reset(phy, 1); | 1106 | rc = sas_phy_reset(phy, 1); |
1106 | sas_put_local_phy(phy); | 1107 | sas_put_local_phy(phy); |
1108 | pm8001_dev->setds_completion = &completion_setstate; | ||
1107 | rc = PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha, | 1109 | rc = PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha, |
1108 | pm8001_dev, 0x01); | 1110 | pm8001_dev, 0x01); |
1109 | msleep(2000); | 1111 | wait_for_completion(&completion_setstate); |
1110 | } else { | 1112 | } else { |
1111 | tmf_task.tmf = TMF_LU_RESET; | 1113 | tmf_task.tmf = TMF_LU_RESET; |
1112 | rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task); | 1114 | rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task); |
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 6037d477a183..6c5fd5ee22d3 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h | |||
@@ -466,6 +466,10 @@ struct pm8001_hba_memspace { | |||
466 | u64 membase; | 466 | u64 membase; |
467 | u32 memsize; | 467 | u32 memsize; |
468 | }; | 468 | }; |
469 | struct isr_param { | ||
470 | struct pm8001_hba_info *drv_inst; | ||
471 | u32 irq_id; | ||
472 | }; | ||
469 | struct pm8001_hba_info { | 473 | struct pm8001_hba_info { |
470 | char name[PM8001_NAME_LENGTH]; | 474 | char name[PM8001_NAME_LENGTH]; |
471 | struct list_head list; | 475 | struct list_head list; |
@@ -519,14 +523,13 @@ struct pm8001_hba_info { | |||
519 | int number_of_intr;/*will be used in remove()*/ | 523 | int number_of_intr;/*will be used in remove()*/ |
520 | #endif | 524 | #endif |
521 | #ifdef PM8001_USE_TASKLET | 525 | #ifdef PM8001_USE_TASKLET |
522 | struct tasklet_struct tasklet; | 526 | struct tasklet_struct tasklet[PM8001_MAX_MSIX_VEC]; |
523 | #endif | 527 | #endif |
524 | u32 logging_level; | 528 | u32 logging_level; |
525 | u32 fw_status; | 529 | u32 fw_status; |
526 | u32 smp_exp_mode; | 530 | u32 smp_exp_mode; |
527 | u32 int_vector; | ||
528 | const struct firmware *fw_image; | 531 | const struct firmware *fw_image; |
529 | u8 outq[PM8001_MAX_MSIX_VEC]; | 532 | struct isr_param irq_vector[PM8001_MAX_MSIX_VEC]; |
530 | }; | 533 | }; |
531 | 534 | ||
532 | struct pm8001_work { | 535 | struct pm8001_work { |
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 8987b1706216..c950dc5c9943 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c | |||
@@ -2894,6 +2894,7 @@ hw_event_sas_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) | |||
2894 | unsigned long flags; | 2894 | unsigned long flags; |
2895 | u8 deviceType = pPayload->sas_identify.dev_type; | 2895 | u8 deviceType = pPayload->sas_identify.dev_type; |
2896 | port->port_state = portstate; | 2896 | port->port_state = portstate; |
2897 | phy->phy_state = PHY_STATE_LINK_UP_SPCV; | ||
2897 | PM8001_MSG_DBG(pm8001_ha, pm8001_printk( | 2898 | PM8001_MSG_DBG(pm8001_ha, pm8001_printk( |
2898 | "portid:%d; phyid:%d; linkrate:%d; " | 2899 | "portid:%d; phyid:%d; linkrate:%d; " |
2899 | "portstate:%x; devicetype:%x\n", | 2900 | "portstate:%x; devicetype:%x\n", |
@@ -2978,6 +2979,7 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) | |||
2978 | port_id, phy_id, link_rate, portstate)); | 2979 | port_id, phy_id, link_rate, portstate)); |
2979 | 2980 | ||
2980 | port->port_state = portstate; | 2981 | port->port_state = portstate; |
2982 | phy->phy_state = PHY_STATE_LINK_UP_SPCV; | ||
2981 | port->port_attached = 1; | 2983 | port->port_attached = 1; |
2982 | pm8001_get_lrate_mode(phy, link_rate); | 2984 | pm8001_get_lrate_mode(phy, link_rate); |
2983 | phy->phy_type |= PORT_TYPE_SATA; | 2985 | phy->phy_type |= PORT_TYPE_SATA; |
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h index c86816bea424..9970a385795d 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.h +++ b/drivers/scsi/pm8001/pm80xx_hwi.h | |||
@@ -215,6 +215,8 @@ | |||
215 | #define SAS_DOPNRJT_RTRY_TMO 128 | 215 | #define SAS_DOPNRJT_RTRY_TMO 128 |
216 | #define SAS_COPNRJT_RTRY_TMO 128 | 216 | #define SAS_COPNRJT_RTRY_TMO 128 |
217 | 217 | ||
218 | /* for phy state */ | ||
219 | #define PHY_STATE_LINK_UP_SPCV 0x2 | ||
218 | /* | 220 | /* |
219 | Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second. | 221 | Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second. |
220 | Assuming a bigger value 3 second, 3000000/128 = 23437.5 where 128 | 222 | Assuming a bigger value 3 second, 3000000/128 = 23437.5 where 128 |
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index bd6f743d87a7..be8ce54f99b2 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c | |||
@@ -1404,11 +1404,22 @@ enum { | |||
1404 | }; | 1404 | }; |
1405 | #define PMCRAID_AEN_CMD_MAX (__PMCRAID_AEN_CMD_MAX - 1) | 1405 | #define PMCRAID_AEN_CMD_MAX (__PMCRAID_AEN_CMD_MAX - 1) |
1406 | 1406 | ||
1407 | static struct genl_multicast_group pmcraid_mcgrps[] = { | ||
1408 | { .name = "events", /* not really used - see ID discussion below */ }, | ||
1409 | }; | ||
1410 | |||
1407 | static struct genl_family pmcraid_event_family = { | 1411 | static struct genl_family pmcraid_event_family = { |
1408 | .id = GENL_ID_GENERATE, | 1412 | /* |
1413 | * Due to prior multicast group abuse (the code having assumed that | ||
1414 | * the family ID can be used as a multicast group ID) we need to | ||
1415 | * statically allocate a family (and thus group) ID. | ||
1416 | */ | ||
1417 | .id = GENL_ID_PMCRAID, | ||
1409 | .name = "pmcraid", | 1418 | .name = "pmcraid", |
1410 | .version = 1, | 1419 | .version = 1, |
1411 | .maxattr = PMCRAID_AEN_ATTR_MAX | 1420 | .maxattr = PMCRAID_AEN_ATTR_MAX, |
1421 | .mcgrps = pmcraid_mcgrps, | ||
1422 | .n_mcgrps = ARRAY_SIZE(pmcraid_mcgrps), | ||
1412 | }; | 1423 | }; |
1413 | 1424 | ||
1414 | /** | 1425 | /** |
@@ -1511,9 +1522,8 @@ static int pmcraid_notify_aen( | |||
1511 | return result; | 1522 | return result; |
1512 | } | 1523 | } |
1513 | 1524 | ||
1514 | result = | 1525 | result = genlmsg_multicast(&pmcraid_event_family, skb, |
1515 | genlmsg_multicast(&pmcraid_event_family, skb, 0, | 1526 | 0, 0, GFP_ATOMIC); |
1516 | pmcraid_event_family.id, GFP_ATOMIC); | ||
1517 | 1527 | ||
1518 | /* If there are no listeners, genlmsg_multicast may return non-zero | 1528 | /* If there are no listeners, genlmsg_multicast may return non-zero |
1519 | * value. | 1529 | * value. |
@@ -4315,6 +4325,7 @@ static struct scsi_host_template pmcraid_host_template = { | |||
4315 | .this_id = -1, | 4325 | .this_id = -1, |
4316 | .sg_tablesize = PMCRAID_MAX_IOADLS, | 4326 | .sg_tablesize = PMCRAID_MAX_IOADLS, |
4317 | .max_sectors = PMCRAID_IOA_MAX_SECTORS, | 4327 | .max_sectors = PMCRAID_IOA_MAX_SECTORS, |
4328 | .no_write_same = 1, | ||
4318 | .cmd_per_lun = PMCRAID_MAX_CMD_PER_LUN, | 4329 | .cmd_per_lun = PMCRAID_MAX_CMD_PER_LUN, |
4319 | .use_clustering = ENABLE_CLUSTERING, | 4330 | .use_clustering = ENABLE_CLUSTERING, |
4320 | .shost_attrs = pmcraid_host_attrs, | 4331 | .shost_attrs = pmcraid_host_attrs, |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index e6c4bff04339..69725f7c32c1 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -2659,6 +2659,12 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) | |||
2659 | { | 2659 | { |
2660 | struct scsi_device *sdev = sdkp->device; | 2660 | struct scsi_device *sdev = sdkp->device; |
2661 | 2661 | ||
2662 | if (sdev->host->no_write_same) { | ||
2663 | sdev->no_write_same = 1; | ||
2664 | |||
2665 | return; | ||
2666 | } | ||
2667 | |||
2662 | if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, INQUIRY) < 0) { | 2668 | if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, INQUIRY) < 0) { |
2663 | /* too large values might cause issues with arcmsr */ | 2669 | /* too large values might cause issues with arcmsr */ |
2664 | int vpd_buf_len = 64; | 2670 | int vpd_buf_len = 64; |
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 1a28f5632797..17d740427240 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c | |||
@@ -1697,6 +1697,7 @@ static struct scsi_host_template scsi_driver = { | |||
1697 | .use_clustering = DISABLE_CLUSTERING, | 1697 | .use_clustering = DISABLE_CLUSTERING, |
1698 | /* Make sure we dont get a sg segment crosses a page boundary */ | 1698 | /* Make sure we dont get a sg segment crosses a page boundary */ |
1699 | .dma_boundary = PAGE_SIZE-1, | 1699 | .dma_boundary = PAGE_SIZE-1, |
1700 | .no_write_same = 1, | ||
1700 | }; | 1701 | }; |
1701 | 1702 | ||
1702 | enum { | 1703 | enum { |
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index 3ed666fe840a..9025edd7dc45 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c | |||
@@ -377,7 +377,7 @@ out_master_put: | |||
377 | 377 | ||
378 | static int bcm2835_spi_remove(struct platform_device *pdev) | 378 | static int bcm2835_spi_remove(struct platform_device *pdev) |
379 | { | 379 | { |
380 | struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); | 380 | struct spi_master *master = platform_get_drvdata(pdev); |
381 | struct bcm2835_spi *bs = spi_master_get_devdata(master); | 381 | struct bcm2835_spi *bs = spi_master_get_devdata(master); |
382 | 382 | ||
383 | free_irq(bs->irq, master); | 383 | free_irq(bs->irq, master); |
diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c index 80d56b214eb5..469ecd876358 100644 --- a/drivers/spi/spi-bcm63xx.c +++ b/drivers/spi/spi-bcm63xx.c | |||
@@ -435,7 +435,7 @@ out: | |||
435 | 435 | ||
436 | static int bcm63xx_spi_remove(struct platform_device *pdev) | 436 | static int bcm63xx_spi_remove(struct platform_device *pdev) |
437 | { | 437 | { |
438 | struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); | 438 | struct spi_master *master = platform_get_drvdata(pdev); |
439 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); | 439 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
440 | 440 | ||
441 | /* reset spi block */ | 441 | /* reset spi block */ |
diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 9602bbd8d7ea..87676587d783 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c | |||
@@ -557,7 +557,7 @@ free_master: | |||
557 | 557 | ||
558 | static int mpc512x_psc_spi_do_remove(struct device *dev) | 558 | static int mpc512x_psc_spi_do_remove(struct device *dev) |
559 | { | 559 | { |
560 | struct spi_master *master = spi_master_get(dev_get_drvdata(dev)); | 560 | struct spi_master *master = dev_get_drvdata(dev); |
561 | struct mpc512x_psc_spi *mps = spi_master_get_devdata(master); | 561 | struct mpc512x_psc_spi *mps = spi_master_get_devdata(master); |
562 | 562 | ||
563 | clk_disable_unprepare(mps->clk_mclk); | 563 | clk_disable_unprepare(mps->clk_mclk); |
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c index 73afb56c08cc..3adebfa22e3d 100644 --- a/drivers/spi/spi-mxs.c +++ b/drivers/spi/spi-mxs.c | |||
@@ -565,7 +565,7 @@ static int mxs_spi_remove(struct platform_device *pdev) | |||
565 | struct mxs_spi *spi; | 565 | struct mxs_spi *spi; |
566 | struct mxs_ssp *ssp; | 566 | struct mxs_ssp *ssp; |
567 | 567 | ||
568 | master = spi_master_get(platform_get_drvdata(pdev)); | 568 | master = platform_get_drvdata(pdev); |
569 | spi = spi_master_get_devdata(master); | 569 | spi = spi_master_get_devdata(master); |
570 | ssp = &spi->ssp; | 570 | ssp = &spi->ssp; |
571 | 571 | ||
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index cb0e1f1137ad..7765b1999537 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c | |||
@@ -1073,6 +1073,8 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) | |||
1073 | static struct acpi_device_id pxa2xx_spi_acpi_match[] = { | 1073 | static struct acpi_device_id pxa2xx_spi_acpi_match[] = { |
1074 | { "INT33C0", 0 }, | 1074 | { "INT33C0", 0 }, |
1075 | { "INT33C1", 0 }, | 1075 | { "INT33C1", 0 }, |
1076 | { "INT3430", 0 }, | ||
1077 | { "INT3431", 0 }, | ||
1076 | { "80860F0E", 0 }, | 1078 | { "80860F0E", 0 }, |
1077 | { }, | 1079 | { }, |
1078 | }; | 1080 | }; |
@@ -1291,6 +1293,9 @@ static int pxa2xx_spi_resume(struct device *dev) | |||
1291 | /* Enable the SSP clock */ | 1293 | /* Enable the SSP clock */ |
1292 | clk_prepare_enable(ssp->clk); | 1294 | clk_prepare_enable(ssp->clk); |
1293 | 1295 | ||
1296 | /* Restore LPSS private register bits */ | ||
1297 | lpss_ssp_setup(drv_data); | ||
1298 | |||
1294 | /* Start the queue running */ | 1299 | /* Start the queue running */ |
1295 | status = spi_master_resume(drv_data->master); | 1300 | status = spi_master_resume(drv_data->master); |
1296 | if (status != 0) { | 1301 | if (status != 0) { |
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 58449ad4ad0d..9e829cee7357 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c | |||
@@ -885,14 +885,13 @@ static void rspi_release_dma(struct rspi_data *rspi) | |||
885 | 885 | ||
886 | static int rspi_remove(struct platform_device *pdev) | 886 | static int rspi_remove(struct platform_device *pdev) |
887 | { | 887 | { |
888 | struct rspi_data *rspi = spi_master_get(platform_get_drvdata(pdev)); | 888 | struct rspi_data *rspi = platform_get_drvdata(pdev); |
889 | 889 | ||
890 | spi_unregister_master(rspi->master); | 890 | spi_unregister_master(rspi->master); |
891 | rspi_release_dma(rspi); | 891 | rspi_release_dma(rspi); |
892 | free_irq(platform_get_irq(pdev, 0), rspi); | 892 | free_irq(platform_get_irq(pdev, 0), rspi); |
893 | clk_put(rspi->clk); | 893 | clk_put(rspi->clk); |
894 | iounmap(rspi->addr); | 894 | iounmap(rspi->addr); |
895 | spi_master_put(rspi->master); | ||
896 | 895 | ||
897 | return 0; | 896 | return 0; |
898 | } | 897 | } |
diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c index 0b71270fbf67..4396bd448540 100644 --- a/drivers/spi/spi-ti-qspi.c +++ b/drivers/spi/spi-ti-qspi.c | |||
@@ -161,7 +161,7 @@ static int ti_qspi_setup(struct spi_device *spi) | |||
161 | qspi->spi_max_frequency, clk_div); | 161 | qspi->spi_max_frequency, clk_div); |
162 | 162 | ||
163 | ret = pm_runtime_get_sync(qspi->dev); | 163 | ret = pm_runtime_get_sync(qspi->dev); |
164 | if (ret) { | 164 | if (ret < 0) { |
165 | dev_err(qspi->dev, "pm_runtime_get_sync() failed\n"); | 165 | dev_err(qspi->dev, "pm_runtime_get_sync() failed\n"); |
166 | return ret; | 166 | return ret; |
167 | } | 167 | } |
@@ -459,11 +459,10 @@ static int ti_qspi_probe(struct platform_device *pdev) | |||
459 | if (!of_property_read_u32(np, "num-cs", &num_cs)) | 459 | if (!of_property_read_u32(np, "num-cs", &num_cs)) |
460 | master->num_chipselect = num_cs; | 460 | master->num_chipselect = num_cs; |
461 | 461 | ||
462 | platform_set_drvdata(pdev, master); | ||
463 | |||
464 | qspi = spi_master_get_devdata(master); | 462 | qspi = spi_master_get_devdata(master); |
465 | qspi->master = master; | 463 | qspi->master = master; |
466 | qspi->dev = &pdev->dev; | 464 | qspi->dev = &pdev->dev; |
465 | platform_set_drvdata(pdev, qspi); | ||
467 | 466 | ||
468 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 467 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
469 | 468 | ||
@@ -517,10 +516,26 @@ free_master: | |||
517 | 516 | ||
518 | static int ti_qspi_remove(struct platform_device *pdev) | 517 | static int ti_qspi_remove(struct platform_device *pdev) |
519 | { | 518 | { |
520 | struct ti_qspi *qspi = platform_get_drvdata(pdev); | 519 | struct spi_master *master; |
520 | struct ti_qspi *qspi; | ||
521 | int ret; | ||
522 | |||
523 | master = platform_get_drvdata(pdev); | ||
524 | qspi = spi_master_get_devdata(master); | ||
525 | |||
526 | ret = pm_runtime_get_sync(qspi->dev); | ||
527 | if (ret < 0) { | ||
528 | dev_err(qspi->dev, "pm_runtime_get_sync() failed\n"); | ||
529 | return ret; | ||
530 | } | ||
521 | 531 | ||
522 | ti_qspi_write(qspi, QSPI_WC_INT_DISABLE, QSPI_INTR_ENABLE_CLEAR_REG); | 532 | ti_qspi_write(qspi, QSPI_WC_INT_DISABLE, QSPI_INTR_ENABLE_CLEAR_REG); |
523 | 533 | ||
534 | pm_runtime_put(qspi->dev); | ||
535 | pm_runtime_disable(&pdev->dev); | ||
536 | |||
537 | spi_unregister_master(master); | ||
538 | |||
524 | return 0; | 539 | return 0; |
525 | } | 540 | } |
526 | 541 | ||
diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c index 637cce2b8bdd..18c9bb2b5f39 100644 --- a/drivers/spi/spi-txx9.c +++ b/drivers/spi/spi-txx9.c | |||
@@ -425,7 +425,7 @@ exit: | |||
425 | 425 | ||
426 | static int txx9spi_remove(struct platform_device *dev) | 426 | static int txx9spi_remove(struct platform_device *dev) |
427 | { | 427 | { |
428 | struct spi_master *master = spi_master_get(platform_get_drvdata(dev)); | 428 | struct spi_master *master = platform_get_drvdata(dev); |
429 | struct txx9spi *c = spi_master_get_devdata(master); | 429 | struct txx9spi *c = spi_master_get_devdata(master); |
430 | 430 | ||
431 | destroy_workqueue(c->workqueue); | 431 | destroy_workqueue(c->workqueue); |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 18cc625d887f..349ebba4b199 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -1415,7 +1415,7 @@ int devm_spi_register_master(struct device *dev, struct spi_master *master) | |||
1415 | return -ENOMEM; | 1415 | return -ENOMEM; |
1416 | 1416 | ||
1417 | ret = spi_register_master(master); | 1417 | ret = spi_register_master(master); |
1418 | if (ret != 0) { | 1418 | if (!ret) { |
1419 | *ptr = master; | 1419 | *ptr = master; |
1420 | devres_add(dev, ptr); | 1420 | devres_add(dev, ptr); |
1421 | } else { | 1421 | } else { |
diff --git a/drivers/staging/btmtk_usb/btmtk_usb.c b/drivers/staging/btmtk_usb/btmtk_usb.c index 7a9bf3b57810..9a5ebd6cc512 100644 --- a/drivers/staging/btmtk_usb/btmtk_usb.c +++ b/drivers/staging/btmtk_usb/btmtk_usb.c | |||
@@ -1284,9 +1284,8 @@ done: | |||
1284 | kfree_skb(skb); | 1284 | kfree_skb(skb); |
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | static int btmtk_usb_send_frame(struct sk_buff *skb) | 1287 | static int btmtk_usb_send_frame(struct hci_dev *hdev, struct sk_buff *skb) |
1288 | { | 1288 | { |
1289 | struct hci_dev *hdev = (struct hci_dev *)skb->dev; | ||
1290 | struct btmtk_usb_data *data = hci_get_drvdata(hdev); | 1289 | struct btmtk_usb_data *data = hci_get_drvdata(hdev); |
1291 | struct usb_ctrlrequest *dr; | 1290 | struct usb_ctrlrequest *dr; |
1292 | struct urb *urb; | 1291 | struct urb *urb; |
diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c index d041b714db29..2baaf1db6fbf 100644 --- a/drivers/staging/comedi/drivers/pcl730.c +++ b/drivers/staging/comedi/drivers/pcl730.c | |||
@@ -173,11 +173,11 @@ static int pcl730_do_insn_bits(struct comedi_device *dev, | |||
173 | if (mask) { | 173 | if (mask) { |
174 | if (mask & 0x00ff) | 174 | if (mask & 0x00ff) |
175 | outb(s->state & 0xff, dev->iobase + reg); | 175 | outb(s->state & 0xff, dev->iobase + reg); |
176 | if ((mask & 0xff00) & (s->n_chan > 8)) | 176 | if ((mask & 0xff00) && (s->n_chan > 8)) |
177 | outb((s->state >> 8) & 0xff, dev->iobase + reg + 1); | 177 | outb((s->state >> 8) & 0xff, dev->iobase + reg + 1); |
178 | if ((mask & 0xff0000) & (s->n_chan > 16)) | 178 | if ((mask & 0xff0000) && (s->n_chan > 16)) |
179 | outb((s->state >> 16) & 0xff, dev->iobase + reg + 2); | 179 | outb((s->state >> 16) & 0xff, dev->iobase + reg + 2); |
180 | if ((mask & 0xff000000) & (s->n_chan > 24)) | 180 | if ((mask & 0xff000000) && (s->n_chan > 24)) |
181 | outb((s->state >> 24) & 0xff, dev->iobase + reg + 3); | 181 | outb((s->state >> 24) & 0xff, dev->iobase + reg + 3); |
182 | } | 182 | } |
183 | 183 | ||
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 6815cfe2664e..b486099b543d 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c | |||
@@ -494,7 +494,7 @@ static void s626_send_dac(struct comedi_device *dev, uint32_t val) | |||
494 | * Private helper function: Write setpoint to an application DAC channel. | 494 | * Private helper function: Write setpoint to an application DAC channel. |
495 | */ | 495 | */ |
496 | static void s626_set_dac(struct comedi_device *dev, uint16_t chan, | 496 | static void s626_set_dac(struct comedi_device *dev, uint16_t chan, |
497 | unsigned short dacdata) | 497 | int16_t dacdata) |
498 | { | 498 | { |
499 | struct s626_private *devpriv = dev->private; | 499 | struct s626_private *devpriv = dev->private; |
500 | uint16_t signmask; | 500 | uint16_t signmask; |
diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c index 933b01a0f03d..0adf3cffddb0 100644 --- a/drivers/staging/comedi/drivers/vmk80xx.c +++ b/drivers/staging/comedi/drivers/vmk80xx.c | |||
@@ -465,7 +465,7 @@ static int vmk80xx_do_insn_bits(struct comedi_device *dev, | |||
465 | unsigned char *rx_buf = devpriv->usb_rx_buf; | 465 | unsigned char *rx_buf = devpriv->usb_rx_buf; |
466 | unsigned char *tx_buf = devpriv->usb_tx_buf; | 466 | unsigned char *tx_buf = devpriv->usb_tx_buf; |
467 | int reg, cmd; | 467 | int reg, cmd; |
468 | int ret; | 468 | int ret = 0; |
469 | 469 | ||
470 | if (devpriv->model == VMK8061_MODEL) { | 470 | if (devpriv->model == VMK8061_MODEL) { |
471 | reg = VMK8061_DO_REG; | 471 | reg = VMK8061_DO_REG; |
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 68ded17c0f5c..12f333fa59b5 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c | |||
@@ -578,7 +578,7 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, | |||
578 | u8 **c_file, const u8 *endpoint, bool boot_case) | 578 | u8 **c_file, const u8 *endpoint, bool boot_case) |
579 | { | 579 | { |
580 | long word_length; | 580 | long word_length; |
581 | int status; | 581 | int status = 0; |
582 | 582 | ||
583 | /*DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");i*/ | 583 | /*DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");i*/ |
584 | word_length = get_request_value(ft1000dev); | 584 | word_length = get_request_value(ft1000dev); |
@@ -1074,4 +1074,3 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, | |||
1074 | 1074 | ||
1075 | return status; | 1075 | return status; |
1076 | } | 1076 | } |
1077 | |||
diff --git a/drivers/staging/iio/magnetometer/Kconfig b/drivers/staging/iio/magnetometer/Kconfig index a3ea69e9d800..34634da1f9f7 100644 --- a/drivers/staging/iio/magnetometer/Kconfig +++ b/drivers/staging/iio/magnetometer/Kconfig | |||
@@ -6,6 +6,8 @@ menu "Magnetometer sensors" | |||
6 | config SENSORS_HMC5843 | 6 | config SENSORS_HMC5843 |
7 | tristate "Honeywell HMC5843/5883/5883L 3-Axis Magnetometer" | 7 | tristate "Honeywell HMC5843/5883/5883L 3-Axis Magnetometer" |
8 | depends on I2C | 8 | depends on I2C |
9 | select IIO_BUFFER | ||
10 | select IIO_TRIGGERED_BUFFER | ||
9 | help | 11 | help |
10 | Say Y here to add support for the Honeywell HMC5843, HMC5883 and | 12 | Say Y here to add support for the Honeywell HMC5843, HMC5883 and |
11 | HMC5883L 3-Axis Magnetometer (digital compass). | 13 | HMC5883L 3-Axis Magnetometer (digital compass). |
diff --git a/drivers/staging/imx-drm/Makefile b/drivers/staging/imx-drm/Makefile index 2c3a9e178fb5..8742432d7b01 100644 --- a/drivers/staging/imx-drm/Makefile +++ b/drivers/staging/imx-drm/Makefile | |||
@@ -8,4 +8,6 @@ obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o | |||
8 | obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o | 8 | obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o |
9 | obj-$(CONFIG_DRM_IMX_FB_HELPER) += imx-fbdev.o | 9 | obj-$(CONFIG_DRM_IMX_FB_HELPER) += imx-fbdev.o |
10 | obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += ipu-v3/ | 10 | obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += ipu-v3/ |
11 | obj-$(CONFIG_DRM_IMX_IPUV3) += ipuv3-crtc.o ipuv3-plane.o | 11 | |
12 | imx-ipuv3-crtc-objs := ipuv3-crtc.o ipuv3-plane.o | ||
13 | obj-$(CONFIG_DRM_IMX_IPUV3) += imx-ipuv3-crtc.o | ||
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 51aa9772f959..6bd015ac9d68 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c | |||
@@ -72,6 +72,7 @@ int imx_drm_crtc_id(struct imx_drm_crtc *crtc) | |||
72 | { | 72 | { |
73 | return crtc->pipe; | 73 | return crtc->pipe; |
74 | } | 74 | } |
75 | EXPORT_SYMBOL_GPL(imx_drm_crtc_id); | ||
75 | 76 | ||
76 | static void imx_drm_driver_lastclose(struct drm_device *drm) | 77 | static void imx_drm_driver_lastclose(struct drm_device *drm) |
77 | { | 78 | { |
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 5dec771d70ee..4d340f4a2198 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c | |||
@@ -409,8 +409,8 @@ int ptlrpc_stop_pinger(void) | |||
409 | struct l_wait_info lwi = { 0 }; | 409 | struct l_wait_info lwi = { 0 }; |
410 | int rc = 0; | 410 | int rc = 0; |
411 | 411 | ||
412 | if (!thread_is_init(&pinger_thread) && | 412 | if (thread_is_init(&pinger_thread) || |
413 | !thread_is_stopped(&pinger_thread)) | 413 | thread_is_stopped(&pinger_thread)) |
414 | return -EALREADY; | 414 | return -EALREADY; |
415 | 415 | ||
416 | ptlrpc_pinger_remove_timeouts(); | 416 | ptlrpc_pinger_remove_timeouts(); |
diff --git a/drivers/staging/media/go7007/go7007-usb.c b/drivers/staging/media/go7007/go7007-usb.c index 58684da45e6c..b658c2316df3 100644 --- a/drivers/staging/media/go7007/go7007-usb.c +++ b/drivers/staging/media/go7007/go7007-usb.c | |||
@@ -15,6 +15,8 @@ | |||
15 | * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. | 15 | * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
19 | |||
18 | #include <linux/module.h> | 20 | #include <linux/module.h> |
19 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
20 | #include <linux/init.h> | 22 | #include <linux/init.h> |
@@ -661,7 +663,7 @@ static int go7007_usb_interface_reset(struct go7007 *go) | |||
661 | 663 | ||
662 | if (usb->board->flags & GO7007_USB_EZUSB) { | 664 | if (usb->board->flags & GO7007_USB_EZUSB) { |
663 | /* Reset buffer in EZ-USB */ | 665 | /* Reset buffer in EZ-USB */ |
664 | dev_dbg(go->dev, "resetting EZ-USB buffers\n"); | 666 | pr_debug("resetting EZ-USB buffers\n"); |
665 | if (go7007_usb_vendor_request(go, 0x10, 0, 0, NULL, 0, 0) < 0 || | 667 | if (go7007_usb_vendor_request(go, 0x10, 0, 0, NULL, 0, 0) < 0 || |
666 | go7007_usb_vendor_request(go, 0x10, 0, 0, NULL, 0, 0) < 0) | 668 | go7007_usb_vendor_request(go, 0x10, 0, 0, NULL, 0, 0) < 0) |
667 | return -1; | 669 | return -1; |
@@ -689,7 +691,7 @@ static int go7007_usb_ezusb_write_interrupt(struct go7007 *go, | |||
689 | u16 status_reg = 0; | 691 | u16 status_reg = 0; |
690 | int timeout = 500; | 692 | int timeout = 500; |
691 | 693 | ||
692 | dev_dbg(go->dev, "WriteInterrupt: %04x %04x\n", addr, data); | 694 | pr_debug("WriteInterrupt: %04x %04x\n", addr, data); |
693 | 695 | ||
694 | for (i = 0; i < 100; ++i) { | 696 | for (i = 0; i < 100; ++i) { |
695 | r = usb_control_msg(usb->usbdev, | 697 | r = usb_control_msg(usb->usbdev, |
@@ -734,7 +736,7 @@ static int go7007_usb_onboard_write_interrupt(struct go7007 *go, | |||
734 | int r; | 736 | int r; |
735 | int timeout = 500; | 737 | int timeout = 500; |
736 | 738 | ||
737 | dev_dbg(go->dev, "WriteInterrupt: %04x %04x\n", addr, data); | 739 | pr_debug("WriteInterrupt: %04x %04x\n", addr, data); |
738 | 740 | ||
739 | go->usb_buf[0] = data & 0xff; | 741 | go->usb_buf[0] = data & 0xff; |
740 | go->usb_buf[1] = data >> 8; | 742 | go->usb_buf[1] = data >> 8; |
@@ -771,7 +773,7 @@ static void go7007_usb_readinterrupt_complete(struct urb *urb) | |||
771 | go->interrupt_available = 1; | 773 | go->interrupt_available = 1; |
772 | go->interrupt_data = __le16_to_cpu(regs[0]); | 774 | go->interrupt_data = __le16_to_cpu(regs[0]); |
773 | go->interrupt_value = __le16_to_cpu(regs[1]); | 775 | go->interrupt_value = __le16_to_cpu(regs[1]); |
774 | dev_dbg(go->dev, "ReadInterrupt: %04x %04x\n", | 776 | pr_debug("ReadInterrupt: %04x %04x\n", |
775 | go->interrupt_value, go->interrupt_data); | 777 | go->interrupt_value, go->interrupt_data); |
776 | } | 778 | } |
777 | 779 | ||
@@ -891,7 +893,7 @@ static int go7007_usb_send_firmware(struct go7007 *go, u8 *data, int len) | |||
891 | int transferred, pipe; | 893 | int transferred, pipe; |
892 | int timeout = 500; | 894 | int timeout = 500; |
893 | 895 | ||
894 | dev_dbg(go->dev, "DownloadBuffer sending %d bytes\n", len); | 896 | pr_debug("DownloadBuffer sending %d bytes\n", len); |
895 | 897 | ||
896 | if (usb->board->flags & GO7007_USB_EZUSB) | 898 | if (usb->board->flags & GO7007_USB_EZUSB) |
897 | pipe = usb_sndbulkpipe(usb->usbdev, 2); | 899 | pipe = usb_sndbulkpipe(usb->usbdev, 2); |
@@ -977,7 +979,7 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter *adapter, | |||
977 | !(msgs[i].flags & I2C_M_RD) && | 979 | !(msgs[i].flags & I2C_M_RD) && |
978 | (msgs[i + 1].flags & I2C_M_RD)) { | 980 | (msgs[i + 1].flags & I2C_M_RD)) { |
979 | #ifdef GO7007_I2C_DEBUG | 981 | #ifdef GO7007_I2C_DEBUG |
980 | dev_dbg(go->dev, "i2c write/read %d/%d bytes on %02x\n", | 982 | pr_debug("i2c write/read %d/%d bytes on %02x\n", |
981 | msgs[i].len, msgs[i + 1].len, msgs[i].addr); | 983 | msgs[i].len, msgs[i + 1].len, msgs[i].addr); |
982 | #endif | 984 | #endif |
983 | buf[0] = 0x01; | 985 | buf[0] = 0x01; |
@@ -988,7 +990,7 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter *adapter, | |||
988 | buf[buf_len++] = msgs[++i].len; | 990 | buf[buf_len++] = msgs[++i].len; |
989 | } else if (msgs[i].flags & I2C_M_RD) { | 991 | } else if (msgs[i].flags & I2C_M_RD) { |
990 | #ifdef GO7007_I2C_DEBUG | 992 | #ifdef GO7007_I2C_DEBUG |
991 | dev_dbg(go->dev, "i2c read %d bytes on %02x\n", | 993 | pr_debug("i2c read %d bytes on %02x\n", |
992 | msgs[i].len, msgs[i].addr); | 994 | msgs[i].len, msgs[i].addr); |
993 | #endif | 995 | #endif |
994 | buf[0] = 0x01; | 996 | buf[0] = 0x01; |
@@ -998,7 +1000,7 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter *adapter, | |||
998 | buf_len = 4; | 1000 | buf_len = 4; |
999 | } else { | 1001 | } else { |
1000 | #ifdef GO7007_I2C_DEBUG | 1002 | #ifdef GO7007_I2C_DEBUG |
1001 | dev_dbg(go->dev, "i2c write %d bytes on %02x\n", | 1003 | pr_debug("i2c write %d bytes on %02x\n", |
1002 | msgs[i].len, msgs[i].addr); | 1004 | msgs[i].len, msgs[i].addr); |
1003 | #endif | 1005 | #endif |
1004 | buf[0] = 0x00; | 1006 | buf[0] = 0x00; |
@@ -1057,7 +1059,7 @@ static int go7007_usb_probe(struct usb_interface *intf, | |||
1057 | char *name; | 1059 | char *name; |
1058 | int video_pipe, i, v_urb_len; | 1060 | int video_pipe, i, v_urb_len; |
1059 | 1061 | ||
1060 | dev_dbg(go->dev, "probing new GO7007 USB board\n"); | 1062 | pr_debug("probing new GO7007 USB board\n"); |
1061 | 1063 | ||
1062 | switch (id->driver_info) { | 1064 | switch (id->driver_info) { |
1063 | case GO7007_BOARDID_MATRIX_II: | 1065 | case GO7007_BOARDID_MATRIX_II: |
@@ -1097,13 +1099,13 @@ static int go7007_usb_probe(struct usb_interface *intf, | |||
1097 | board = &board_px_tv402u; | 1099 | board = &board_px_tv402u; |
1098 | break; | 1100 | break; |
1099 | case GO7007_BOARDID_LIFEVIEW_LR192: | 1101 | case GO7007_BOARDID_LIFEVIEW_LR192: |
1100 | dev_err(go->dev, "The Lifeview TV Walker Ultra is not supported. Sorry!\n"); | 1102 | dev_err(&intf->dev, "The Lifeview TV Walker Ultra is not supported. Sorry!\n"); |
1101 | return -ENODEV; | 1103 | return -ENODEV; |
1102 | name = "Lifeview TV Walker Ultra"; | 1104 | name = "Lifeview TV Walker Ultra"; |
1103 | board = &board_lifeview_lr192; | 1105 | board = &board_lifeview_lr192; |
1104 | break; | 1106 | break; |
1105 | case GO7007_BOARDID_SENSORAY_2250: | 1107 | case GO7007_BOARDID_SENSORAY_2250: |
1106 | dev_info(go->dev, "Sensoray 2250 found\n"); | 1108 | dev_info(&intf->dev, "Sensoray 2250 found\n"); |
1107 | name = "Sensoray 2250/2251"; | 1109 | name = "Sensoray 2250/2251"; |
1108 | board = &board_sensoray_2250; | 1110 | board = &board_sensoray_2250; |
1109 | break; | 1111 | break; |
@@ -1112,7 +1114,7 @@ static int go7007_usb_probe(struct usb_interface *intf, | |||
1112 | board = &board_ads_usbav_709; | 1114 | board = &board_ads_usbav_709; |
1113 | break; | 1115 | break; |
1114 | default: | 1116 | default: |
1115 | dev_err(go->dev, "unknown board ID %d!\n", | 1117 | dev_err(&intf->dev, "unknown board ID %d!\n", |
1116 | (unsigned int)id->driver_info); | 1118 | (unsigned int)id->driver_info); |
1117 | return -ENODEV; | 1119 | return -ENODEV; |
1118 | } | 1120 | } |
@@ -1247,7 +1249,7 @@ static int go7007_usb_probe(struct usb_interface *intf, | |||
1247 | sizeof(go->name)); | 1249 | sizeof(go->name)); |
1248 | break; | 1250 | break; |
1249 | default: | 1251 | default: |
1250 | dev_dbg(go->dev, "unable to detect tuner type!\n"); | 1252 | pr_debug("unable to detect tuner type!\n"); |
1251 | break; | 1253 | break; |
1252 | } | 1254 | } |
1253 | /* Configure tuner mode selection inputs connected | 1255 | /* Configure tuner mode selection inputs connected |
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 3066ee2e753b..49ea76b3435d 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c | |||
@@ -681,7 +681,8 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) | |||
681 | dev_err(nvec->dev, | 681 | dev_err(nvec->dev, |
682 | "RX buffer overflow on %p: " | 682 | "RX buffer overflow on %p: " |
683 | "Trying to write byte %u of %u\n", | 683 | "Trying to write byte %u of %u\n", |
684 | nvec->rx, nvec->rx->pos, NVEC_MSG_SIZE); | 684 | nvec->rx, nvec->rx ? nvec->rx->pos : 0, |
685 | NVEC_MSG_SIZE); | ||
685 | break; | 686 | break; |
686 | default: | 687 | default: |
687 | nvec->state = 0; | 688 | nvec->state = 0; |
diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 2c678f409573..2f548ebada59 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c | |||
@@ -1115,6 +1115,9 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) | |||
1115 | return _FAIL; | 1115 | return _FAIL; |
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | /* fix bug of flush_cam_entry at STOP AP mode */ | ||
1119 | psta->state |= WIFI_AP_STATE; | ||
1120 | rtw_indicate_connect(padapter); | ||
1118 | pmlmepriv->cur_network.join_res = true;/* for check if already set beacon */ | 1121 | pmlmepriv->cur_network.join_res = true;/* for check if already set beacon */ |
1119 | return ret; | 1122 | return ret; |
1120 | } | 1123 | } |
diff --git a/drivers/staging/tidspbridge/Kconfig b/drivers/staging/tidspbridge/Kconfig index 165b918b8171..1b6d581c438b 100644 --- a/drivers/staging/tidspbridge/Kconfig +++ b/drivers/staging/tidspbridge/Kconfig | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | menuconfig TIDSPBRIDGE | 5 | menuconfig TIDSPBRIDGE |
6 | tristate "DSP Bridge driver" | 6 | tristate "DSP Bridge driver" |
7 | depends on ARCH_OMAP3 && !ARCH_MULTIPLATFORM | 7 | depends on ARCH_OMAP3 && !ARCH_MULTIPLATFORM && BROKEN |
8 | select MAILBOX | 8 | select MAILBOX |
9 | select OMAP2PLUS_MBOX | 9 | select OMAP2PLUS_MBOX |
10 | help | 10 | help |
diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index aab0012bba92..ab8b2ba6eedd 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c | |||
@@ -143,7 +143,8 @@ static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked) | |||
143 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n", | 143 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n", |
144 | pDevice->dev->name, pDevice->apdev->name); | 144 | pDevice->dev->name, pDevice->apdev->name); |
145 | } | 145 | } |
146 | free_netdev(pDevice->apdev); | 146 | if (pDevice->apdev) |
147 | free_netdev(pDevice->apdev); | ||
147 | pDevice->apdev = NULL; | 148 | pDevice->apdev = NULL; |
148 | pDevice->bEnable8021x = false; | 149 | pDevice->bEnable8021x = false; |
149 | pDevice->bEnableHostWEP = false; | 150 | pDevice->bEnableHostWEP = false; |
diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 1e8b8412e67e..4aa5ef54b683 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c | |||
@@ -939,6 +939,7 @@ int BBbVT3184Init(struct vnt_private *pDevice) | |||
939 | u8 * pbyAgc; | 939 | u8 * pbyAgc; |
940 | u16 wLengthAgc; | 940 | u16 wLengthAgc; |
941 | u8 abyArray[256]; | 941 | u8 abyArray[256]; |
942 | u8 data; | ||
942 | 943 | ||
943 | ntStatus = CONTROLnsRequestIn(pDevice, | 944 | ntStatus = CONTROLnsRequestIn(pDevice, |
944 | MESSAGE_TYPE_READ, | 945 | MESSAGE_TYPE_READ, |
@@ -1104,6 +1105,16 @@ else { | |||
1104 | ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01); | 1105 | ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01); |
1105 | 1106 | ||
1106 | RFbRFTableDownload(pDevice); | 1107 | RFbRFTableDownload(pDevice); |
1108 | |||
1109 | /* Fix for TX USB resets from vendors driver */ | ||
1110 | CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, USB_REG4, | ||
1111 | MESSAGE_REQUEST_MEM, sizeof(data), &data); | ||
1112 | |||
1113 | data |= 0x2; | ||
1114 | |||
1115 | CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, USB_REG4, | ||
1116 | MESSAGE_REQUEST_MEM, sizeof(data), &data); | ||
1117 | |||
1107 | return true;//ntStatus; | 1118 | return true;//ntStatus; |
1108 | } | 1119 | } |
1109 | 1120 | ||
diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c index ae1676d190c5..67ba48b9a8d9 100644 --- a/drivers/staging/vt6656/hostap.c +++ b/drivers/staging/vt6656/hostap.c | |||
@@ -133,7 +133,8 @@ static int hostap_disable_hostapd(struct vnt_private *pDevice, int rtnl_locked) | |||
133 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n", | 133 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n", |
134 | pDevice->dev->name, pDevice->apdev->name); | 134 | pDevice->dev->name, pDevice->apdev->name); |
135 | } | 135 | } |
136 | free_netdev(pDevice->apdev); | 136 | if (pDevice->apdev) |
137 | free_netdev(pDevice->apdev); | ||
137 | pDevice->apdev = NULL; | 138 | pDevice->apdev = NULL; |
138 | pDevice->bEnable8021x = false; | 139 | pDevice->bEnable8021x = false; |
139 | pDevice->bEnableHostWEP = false; | 140 | pDevice->bEnableHostWEP = false; |
diff --git a/drivers/staging/vt6656/rndis.h b/drivers/staging/vt6656/rndis.h index 5e073062017a..5cf5e732a36f 100644 --- a/drivers/staging/vt6656/rndis.h +++ b/drivers/staging/vt6656/rndis.h | |||
@@ -66,6 +66,8 @@ | |||
66 | 66 | ||
67 | #define VIAUSB20_PACKET_HEADER 0x04 | 67 | #define VIAUSB20_PACKET_HEADER 0x04 |
68 | 68 | ||
69 | #define USB_REG4 0x604 | ||
70 | |||
69 | typedef struct _CMD_MESSAGE | 71 | typedef struct _CMD_MESSAGE |
70 | { | 72 | { |
71 | u8 byData[256]; | 73 | u8 byData[256]; |
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 79ce363b2ea9..3277d9838f4e 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c | |||
@@ -652,21 +652,30 @@ static ssize_t reset_store(struct device *dev, | |||
652 | return -ENOMEM; | 652 | return -ENOMEM; |
653 | 653 | ||
654 | /* Do not reset an active device! */ | 654 | /* Do not reset an active device! */ |
655 | if (bdev->bd_holders) | 655 | if (bdev->bd_holders) { |
656 | return -EBUSY; | 656 | ret = -EBUSY; |
657 | goto out; | ||
658 | } | ||
657 | 659 | ||
658 | ret = kstrtou16(buf, 10, &do_reset); | 660 | ret = kstrtou16(buf, 10, &do_reset); |
659 | if (ret) | 661 | if (ret) |
660 | return ret; | 662 | goto out; |
661 | 663 | ||
662 | if (!do_reset) | 664 | if (!do_reset) { |
663 | return -EINVAL; | 665 | ret = -EINVAL; |
666 | goto out; | ||
667 | } | ||
664 | 668 | ||
665 | /* Make sure all pending I/O is finished */ | 669 | /* Make sure all pending I/O is finished */ |
666 | fsync_bdev(bdev); | 670 | fsync_bdev(bdev); |
671 | bdput(bdev); | ||
667 | 672 | ||
668 | zram_reset_device(zram, true); | 673 | zram_reset_device(zram, true); |
669 | return len; | 674 | return len; |
675 | |||
676 | out: | ||
677 | bdput(bdev); | ||
678 | return ret; | ||
670 | } | 679 | } |
671 | 680 | ||
672 | static void __zram_make_request(struct zram *zram, struct bio *bio, int rw) | 681 | static void __zram_make_request(struct zram *zram, struct bio *bio, int rw) |
diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c index 1a67537dbc56..3b950e5a918f 100644 --- a/drivers/staging/zsmalloc/zsmalloc-main.c +++ b/drivers/staging/zsmalloc/zsmalloc-main.c | |||
@@ -430,7 +430,12 @@ static struct page *get_next_page(struct page *page) | |||
430 | return next; | 430 | return next; |
431 | } | 431 | } |
432 | 432 | ||
433 | /* Encode <page, obj_idx> as a single handle value */ | 433 | /* |
434 | * Encode <page, obj_idx> as a single handle value. | ||
435 | * On hardware platforms with physical memory starting at 0x0 the pfn | ||
436 | * could be 0 so we ensure that the handle will never be 0 by adjusting the | ||
437 | * encoded obj_idx value before encoding. | ||
438 | */ | ||
434 | static void *obj_location_to_handle(struct page *page, unsigned long obj_idx) | 439 | static void *obj_location_to_handle(struct page *page, unsigned long obj_idx) |
435 | { | 440 | { |
436 | unsigned long handle; | 441 | unsigned long handle; |
@@ -441,17 +446,21 @@ static void *obj_location_to_handle(struct page *page, unsigned long obj_idx) | |||
441 | } | 446 | } |
442 | 447 | ||
443 | handle = page_to_pfn(page) << OBJ_INDEX_BITS; | 448 | handle = page_to_pfn(page) << OBJ_INDEX_BITS; |
444 | handle |= (obj_idx & OBJ_INDEX_MASK); | 449 | handle |= ((obj_idx + 1) & OBJ_INDEX_MASK); |
445 | 450 | ||
446 | return (void *)handle; | 451 | return (void *)handle; |
447 | } | 452 | } |
448 | 453 | ||
449 | /* Decode <page, obj_idx> pair from the given object handle */ | 454 | /* |
455 | * Decode <page, obj_idx> pair from the given object handle. We adjust the | ||
456 | * decoded obj_idx back to its original value since it was adjusted in | ||
457 | * obj_location_to_handle(). | ||
458 | */ | ||
450 | static void obj_handle_to_location(unsigned long handle, struct page **page, | 459 | static void obj_handle_to_location(unsigned long handle, struct page **page, |
451 | unsigned long *obj_idx) | 460 | unsigned long *obj_idx) |
452 | { | 461 | { |
453 | *page = pfn_to_page(handle >> OBJ_INDEX_BITS); | 462 | *page = pfn_to_page(handle >> OBJ_INDEX_BITS); |
454 | *obj_idx = handle & OBJ_INDEX_MASK; | 463 | *obj_idx = (handle & OBJ_INDEX_MASK) - 1; |
455 | } | 464 | } |
456 | 465 | ||
457 | static unsigned long obj_idx_to_offset(struct page *page, | 466 | static unsigned long obj_idx_to_offset(struct page *page, |
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 2b86f8e0fb58..71630a2af42c 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c | |||
@@ -1855,6 +1855,9 @@ static struct console sercons = { | |||
1855 | */ | 1855 | */ |
1856 | static int __init amiserial_console_init(void) | 1856 | static int __init amiserial_console_init(void) |
1857 | { | 1857 | { |
1858 | if (!MACH_IS_AMIGA) | ||
1859 | return -ENODEV; | ||
1860 | |||
1858 | register_console(&sercons); | 1861 | register_console(&sercons); |
1859 | return 0; | 1862 | return 0; |
1860 | } | 1863 | } |
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 7cdd1eb9406c..0f74945af624 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
@@ -768,7 +768,7 @@ static size_t __process_echoes(struct tty_struct *tty) | |||
768 | * data at the tail to prevent a subsequent overrun */ | 768 | * data at the tail to prevent a subsequent overrun */ |
769 | while (ldata->echo_commit - tail >= ECHO_DISCARD_WATERMARK) { | 769 | while (ldata->echo_commit - tail >= ECHO_DISCARD_WATERMARK) { |
770 | if (echo_buf(ldata, tail) == ECHO_OP_START) { | 770 | if (echo_buf(ldata, tail) == ECHO_OP_START) { |
771 | if (echo_buf(ldata, tail) == ECHO_OP_ERASE_TAB) | 771 | if (echo_buf(ldata, tail + 1) == ECHO_OP_ERASE_TAB) |
772 | tail += 3; | 772 | tail += 3; |
773 | else | 773 | else |
774 | tail += 2; | 774 | tail += 2; |
@@ -1998,7 +1998,10 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, | |||
1998 | found = 1; | 1998 | found = 1; |
1999 | 1999 | ||
2000 | size = N_TTY_BUF_SIZE - tail; | 2000 | size = N_TTY_BUF_SIZE - tail; |
2001 | n = (found + eol + size) & (N_TTY_BUF_SIZE - 1); | 2001 | n = eol - tail; |
2002 | if (n > 4096) | ||
2003 | n += 4096; | ||
2004 | n += found; | ||
2002 | c = n; | 2005 | c = n; |
2003 | 2006 | ||
2004 | if (found && read_buf(ldata, eol) == __DISABLED_CHAR) { | 2007 | if (found && read_buf(ldata, eol) == __DISABLED_CHAR) { |
@@ -2243,18 +2246,19 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, | |||
2243 | if (time) | 2246 | if (time) |
2244 | timeout = time; | 2247 | timeout = time; |
2245 | } | 2248 | } |
2246 | mutex_unlock(&ldata->atomic_read_lock); | 2249 | n_tty_set_room(tty); |
2247 | remove_wait_queue(&tty->read_wait, &wait); | 2250 | up_read(&tty->termios_rwsem); |
2248 | 2251 | ||
2252 | remove_wait_queue(&tty->read_wait, &wait); | ||
2249 | if (!waitqueue_active(&tty->read_wait)) | 2253 | if (!waitqueue_active(&tty->read_wait)) |
2250 | ldata->minimum_to_wake = minimum; | 2254 | ldata->minimum_to_wake = minimum; |
2251 | 2255 | ||
2256 | mutex_unlock(&ldata->atomic_read_lock); | ||
2257 | |||
2252 | __set_current_state(TASK_RUNNING); | 2258 | __set_current_state(TASK_RUNNING); |
2253 | if (b - buf) | 2259 | if (b - buf) |
2254 | retval = b - buf; | 2260 | retval = b - buf; |
2255 | 2261 | ||
2256 | n_tty_set_room(tty); | ||
2257 | up_read(&tty->termios_rwsem); | ||
2258 | return retval; | 2262 | return retval; |
2259 | } | 2263 | } |
2260 | 2264 | ||
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index f3b306efaa59..23329918f229 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig | |||
@@ -41,7 +41,7 @@ config SERIAL_8250_DEPRECATED_OPTIONS | |||
41 | accept kernel parameters in both forms like 8250_core.nr_uarts=4 and | 41 | accept kernel parameters in both forms like 8250_core.nr_uarts=4 and |
42 | 8250.nr_uarts=4. We now renamed the module back to 8250, but if | 42 | 8250.nr_uarts=4. We now renamed the module back to 8250, but if |
43 | anybody noticed in 3.7 and changed their userspace we still have to | 43 | anybody noticed in 3.7 and changed their userspace we still have to |
44 | keep the 8350_core.* options around until they revert the changes | 44 | keep the 8250_core.* options around until they revert the changes |
45 | they already did. | 45 | they already did. |
46 | 46 | ||
47 | If 8250 is built as a module, this adds 8250_core alias instead. | 47 | If 8250 is built as a module, this adds 8250_core alias instead. |
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c index 481b781b26e3..e9d420ff3931 100644 --- a/drivers/tty/serial/pmac_zilog.c +++ b/drivers/tty/serial/pmac_zilog.c | |||
@@ -2052,6 +2052,9 @@ static int __init pmz_console_init(void) | |||
2052 | /* Probe ports */ | 2052 | /* Probe ports */ |
2053 | pmz_probe(); | 2053 | pmz_probe(); |
2054 | 2054 | ||
2055 | if (pmz_ports_count == 0) | ||
2056 | return -ENODEV; | ||
2057 | |||
2055 | /* TODO: Autoprobe console based on OF */ | 2058 | /* TODO: Autoprobe console based on OF */ |
2056 | /* pmz_console.index = i; */ | 2059 | /* pmz_console.index = i; */ |
2057 | register_console(&pmz_console); | 2060 | register_console(&pmz_console); |
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 3a1a01af9a80..c74a00ad7add 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -2086,6 +2086,7 @@ retry_open: | |||
2086 | filp->f_op = &tty_fops; | 2086 | filp->f_op = &tty_fops; |
2087 | goto retry_open; | 2087 | goto retry_open; |
2088 | } | 2088 | } |
2089 | clear_bit(TTY_HUPPED, &tty->flags); | ||
2089 | tty_unlock(tty); | 2090 | tty_unlock(tty); |
2090 | 2091 | ||
2091 | 2092 | ||
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 67beb8444930..f7beb6eb40c7 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -653,6 +653,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma) | |||
653 | return -EINVAL; | 653 | return -EINVAL; |
654 | mem = idev->info->mem + mi; | 654 | mem = idev->info->mem + mi; |
655 | 655 | ||
656 | if (mem->addr & ~PAGE_MASK) | ||
657 | return -ENODEV; | ||
656 | if (vma->vm_end - vma->vm_start > mem->size) | 658 | if (vma->vm_end - vma->vm_start > mem->size) |
657 | return -EINVAL; | 659 | return -EINVAL; |
658 | 660 | ||
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 8521051cf946..cd961622f9c1 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c | |||
@@ -131,6 +131,7 @@ static const struct platform_device_id atmel_lcdfb_devtypes[] = { | |||
131 | /* terminator */ | 131 | /* terminator */ |
132 | } | 132 | } |
133 | }; | 133 | }; |
134 | MODULE_DEVICE_TABLE(platform, atmel_lcdfb_devtypes); | ||
134 | 135 | ||
135 | static struct atmel_lcdfb_config * | 136 | static struct atmel_lcdfb_config * |
136 | atmel_lcdfb_get_config(struct platform_device *pdev) | 137 | atmel_lcdfb_get_config(struct platform_device *pdev) |
diff --git a/drivers/video/kyro/fbdev.c b/drivers/video/kyro/fbdev.c index 50c857477e4f..65041e15fd59 100644 --- a/drivers/video/kyro/fbdev.c +++ b/drivers/video/kyro/fbdev.c | |||
@@ -624,15 +624,15 @@ static int kyrofb_ioctl(struct fb_info *info, | |||
624 | return -EINVAL; | 624 | return -EINVAL; |
625 | } | 625 | } |
626 | case KYRO_IOCTL_UVSTRIDE: | 626 | case KYRO_IOCTL_UVSTRIDE: |
627 | if (copy_to_user(argp, &deviceInfo.ulOverlayUVStride, sizeof(unsigned long))) | 627 | if (copy_to_user(argp, &deviceInfo.ulOverlayUVStride, sizeof(deviceInfo.ulOverlayUVStride))) |
628 | return -EFAULT; | 628 | return -EFAULT; |
629 | break; | 629 | break; |
630 | case KYRO_IOCTL_STRIDE: | 630 | case KYRO_IOCTL_STRIDE: |
631 | if (copy_to_user(argp, &deviceInfo.ulOverlayStride, sizeof(unsigned long))) | 631 | if (copy_to_user(argp, &deviceInfo.ulOverlayStride, sizeof(deviceInfo.ulOverlayStride))) |
632 | return -EFAULT; | 632 | return -EFAULT; |
633 | break; | 633 | break; |
634 | case KYRO_IOCTL_OVERLAY_OFFSET: | 634 | case KYRO_IOCTL_OVERLAY_OFFSET: |
635 | if (copy_to_user(argp, &deviceInfo.ulOverlayOffset, sizeof(unsigned long))) | 635 | if (copy_to_user(argp, &deviceInfo.ulOverlayOffset, sizeof(deviceInfo.ulOverlayOffset))) |
636 | return -EFAULT; | 636 | return -EFAULT; |
637 | break; | 637 | break; |
638 | } | 638 | } |
diff --git a/drivers/video/omap2/displays-new/panel-sony-acx565akm.c b/drivers/video/omap2/displays-new/panel-sony-acx565akm.c index e6d56f714ae4..d94f35dbd536 100644 --- a/drivers/video/omap2/displays-new/panel-sony-acx565akm.c +++ b/drivers/video/omap2/displays-new/panel-sony-acx565akm.c | |||
@@ -526,6 +526,8 @@ static int acx565akm_panel_power_on(struct omap_dss_device *dssdev) | |||
526 | struct omap_dss_device *in = ddata->in; | 526 | struct omap_dss_device *in = ddata->in; |
527 | int r; | 527 | int r; |
528 | 528 | ||
529 | mutex_lock(&ddata->mutex); | ||
530 | |||
529 | dev_dbg(&ddata->spi->dev, "%s\n", __func__); | 531 | dev_dbg(&ddata->spi->dev, "%s\n", __func__); |
530 | 532 | ||
531 | in->ops.sdi->set_timings(in, &ddata->videomode); | 533 | in->ops.sdi->set_timings(in, &ddata->videomode); |
@@ -614,10 +616,7 @@ static int acx565akm_enable(struct omap_dss_device *dssdev) | |||
614 | if (omapdss_device_is_enabled(dssdev)) | 616 | if (omapdss_device_is_enabled(dssdev)) |
615 | return 0; | 617 | return 0; |
616 | 618 | ||
617 | mutex_lock(&ddata->mutex); | ||
618 | r = acx565akm_panel_power_on(dssdev); | 619 | r = acx565akm_panel_power_on(dssdev); |
619 | mutex_unlock(&ddata->mutex); | ||
620 | |||
621 | if (r) | 620 | if (r) |
622 | return r; | 621 | return r; |
623 | 622 | ||
diff --git a/drivers/video/sh_mobile_meram.c b/drivers/video/sh_mobile_meram.c index e0f098562a74..a297de5cc859 100644 --- a/drivers/video/sh_mobile_meram.c +++ b/drivers/video/sh_mobile_meram.c | |||
@@ -569,6 +569,7 @@ EXPORT_SYMBOL_GPL(sh_mobile_meram_cache_update); | |||
569 | * Power management | 569 | * Power management |
570 | */ | 570 | */ |
571 | 571 | ||
572 | #if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME) | ||
572 | static int sh_mobile_meram_suspend(struct device *dev) | 573 | static int sh_mobile_meram_suspend(struct device *dev) |
573 | { | 574 | { |
574 | struct platform_device *pdev = to_platform_device(dev); | 575 | struct platform_device *pdev = to_platform_device(dev); |
@@ -611,6 +612,7 @@ static int sh_mobile_meram_resume(struct device *dev) | |||
611 | meram_write_reg(priv->base, common_regs[i], priv->regs[i]); | 612 | meram_write_reg(priv->base, common_regs[i], priv->regs[i]); |
612 | return 0; | 613 | return 0; |
613 | } | 614 | } |
615 | #endif /* CONFIG_PM_SLEEP || CONFIG_PM_RUNTIME */ | ||
614 | 616 | ||
615 | static UNIVERSAL_DEV_PM_OPS(sh_mobile_meram_dev_pm_ops, | 617 | static UNIVERSAL_DEV_PM_OPS(sh_mobile_meram_dev_pm_ops, |
616 | sh_mobile_meram_suspend, | 618 | sh_mobile_meram_suspend, |
diff --git a/drivers/video/vt8500lcdfb.c b/drivers/video/vt8500lcdfb.c index b30e5a439d1f..a8f2b280f796 100644 --- a/drivers/video/vt8500lcdfb.c +++ b/drivers/video/vt8500lcdfb.c | |||
@@ -293,8 +293,7 @@ static int vt8500lcd_probe(struct platform_device *pdev) | |||
293 | + sizeof(u32) * 16, GFP_KERNEL); | 293 | + sizeof(u32) * 16, GFP_KERNEL); |
294 | if (!fbi) { | 294 | if (!fbi) { |
295 | dev_err(&pdev->dev, "Failed to initialize framebuffer device\n"); | 295 | dev_err(&pdev->dev, "Failed to initialize framebuffer device\n"); |
296 | ret = -ENOMEM; | 296 | return -ENOMEM; |
297 | goto failed; | ||
298 | } | 297 | } |
299 | 298 | ||
300 | strcpy(fbi->fb.fix.id, "VT8500 LCD"); | 299 | strcpy(fbi->fb.fix.id, "VT8500 LCD"); |
@@ -327,15 +326,13 @@ static int vt8500lcd_probe(struct platform_device *pdev) | |||
327 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 326 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
328 | if (res == NULL) { | 327 | if (res == NULL) { |
329 | dev_err(&pdev->dev, "no I/O memory resource defined\n"); | 328 | dev_err(&pdev->dev, "no I/O memory resource defined\n"); |
330 | ret = -ENODEV; | 329 | return -ENODEV; |
331 | goto failed_fbi; | ||
332 | } | 330 | } |
333 | 331 | ||
334 | res = request_mem_region(res->start, resource_size(res), "vt8500lcd"); | 332 | res = request_mem_region(res->start, resource_size(res), "vt8500lcd"); |
335 | if (res == NULL) { | 333 | if (res == NULL) { |
336 | dev_err(&pdev->dev, "failed to request I/O memory\n"); | 334 | dev_err(&pdev->dev, "failed to request I/O memory\n"); |
337 | ret = -EBUSY; | 335 | return -EBUSY; |
338 | goto failed_fbi; | ||
339 | } | 336 | } |
340 | 337 | ||
341 | fbi->regbase = ioremap(res->start, resource_size(res)); | 338 | fbi->regbase = ioremap(res->start, resource_size(res)); |
@@ -346,17 +343,19 @@ static int vt8500lcd_probe(struct platform_device *pdev) | |||
346 | } | 343 | } |
347 | 344 | ||
348 | disp_timing = of_get_display_timings(pdev->dev.of_node); | 345 | disp_timing = of_get_display_timings(pdev->dev.of_node); |
349 | if (!disp_timing) | 346 | if (!disp_timing) { |
350 | return -EINVAL; | 347 | ret = -EINVAL; |
348 | goto failed_free_io; | ||
349 | } | ||
351 | 350 | ||
352 | ret = of_get_fb_videomode(pdev->dev.of_node, &of_mode, | 351 | ret = of_get_fb_videomode(pdev->dev.of_node, &of_mode, |
353 | OF_USE_NATIVE_MODE); | 352 | OF_USE_NATIVE_MODE); |
354 | if (ret) | 353 | if (ret) |
355 | return ret; | 354 | goto failed_free_io; |
356 | 355 | ||
357 | ret = of_property_read_u32(pdev->dev.of_node, "bits-per-pixel", &bpp); | 356 | ret = of_property_read_u32(pdev->dev.of_node, "bits-per-pixel", &bpp); |
358 | if (ret) | 357 | if (ret) |
359 | return ret; | 358 | goto failed_free_io; |
360 | 359 | ||
361 | /* try allocating the framebuffer */ | 360 | /* try allocating the framebuffer */ |
362 | fb_mem_len = of_mode.xres * of_mode.yres * 2 * (bpp / 8); | 361 | fb_mem_len = of_mode.xres * of_mode.yres * 2 * (bpp / 8); |
@@ -364,7 +363,8 @@ static int vt8500lcd_probe(struct platform_device *pdev) | |||
364 | GFP_KERNEL); | 363 | GFP_KERNEL); |
365 | if (!fb_mem_virt) { | 364 | if (!fb_mem_virt) { |
366 | pr_err("%s: Failed to allocate framebuffer\n", __func__); | 365 | pr_err("%s: Failed to allocate framebuffer\n", __func__); |
367 | return -ENOMEM; | 366 | ret = -ENOMEM; |
367 | goto failed_free_io; | ||
368 | } | 368 | } |
369 | 369 | ||
370 | fbi->fb.fix.smem_start = fb_mem_phys; | 370 | fbi->fb.fix.smem_start = fb_mem_phys; |
@@ -447,9 +447,6 @@ failed_free_io: | |||
447 | iounmap(fbi->regbase); | 447 | iounmap(fbi->regbase); |
448 | failed_free_res: | 448 | failed_free_res: |
449 | release_mem_region(res->start, resource_size(res)); | 449 | release_mem_region(res->start, resource_size(res)); |
450 | failed_fbi: | ||
451 | kfree(fbi); | ||
452 | failed: | ||
453 | return ret; | 450 | return ret; |
454 | } | 451 | } |
455 | 452 | ||
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 62ccf5424ba8..028387192b60 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -930,9 +930,10 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | |||
930 | ret = m2p_add_override(mfn, pages[i], kmap_ops ? | 930 | ret = m2p_add_override(mfn, pages[i], kmap_ops ? |
931 | &kmap_ops[i] : NULL); | 931 | &kmap_ops[i] : NULL); |
932 | if (ret) | 932 | if (ret) |
933 | return ret; | 933 | goto out; |
934 | } | 934 | } |
935 | 935 | ||
936 | out: | ||
936 | if (lazy) | 937 | if (lazy) |
937 | arch_leave_lazy_mmu_mode(); | 938 | arch_leave_lazy_mmu_mode(); |
938 | 939 | ||
@@ -969,9 +970,10 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | |||
969 | ret = m2p_remove_override(pages[i], kmap_ops ? | 970 | ret = m2p_remove_override(pages[i], kmap_ops ? |
970 | &kmap_ops[i] : NULL); | 971 | &kmap_ops[i] : NULL); |
971 | if (ret) | 972 | if (ret) |
972 | return ret; | 973 | goto out; |
973 | } | 974 | } |
974 | 975 | ||
976 | out: | ||
975 | if (lazy) | 977 | if (lazy) |
976 | arch_leave_lazy_mmu_mode(); | 978 | arch_leave_lazy_mmu_mode(); |
977 | 979 | ||
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index a224bc74b6b9..1eac0731c349 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c | |||
@@ -555,6 +555,11 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, | |||
555 | sg_dma_len(sgl) = 0; | 555 | sg_dma_len(sgl) = 0; |
556 | return 0; | 556 | return 0; |
557 | } | 557 | } |
558 | xen_dma_map_page(hwdev, pfn_to_page(map >> PAGE_SHIFT), | ||
559 | map & ~PAGE_MASK, | ||
560 | sg->length, | ||
561 | dir, | ||
562 | attrs); | ||
558 | sg->dma_address = xen_phys_to_bus(map); | 563 | sg->dma_address = xen_phys_to_bus(map); |
559 | } else { | 564 | } else { |
560 | /* we are not interested in the dma_addr returned by | 565 | /* we are not interested in the dma_addr returned by |