diff options
Diffstat (limited to 'drivers')
236 files changed, 4772 insertions, 2242 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 5d0e26a5c34c..da3a08fa9e4f 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menuconfig ACPI | 5 | menuconfig ACPI |
6 | bool "ACPI Support (Advanced Configuration and Power Interface) Support" | 6 | bool "ACPI (Advanced Configuration and Power Interface) Support" |
7 | depends on !X86_NUMAQ | 7 | depends on !X86_NUMAQ |
8 | depends on !X86_VISWS | 8 | depends on !X86_VISWS |
9 | depends on !IA64_HP_SIM | 9 | depends on !IA64_HP_SIM |
@@ -88,7 +88,8 @@ config ACPI_PROC_EVENT | |||
88 | 88 | ||
89 | config ACPI_AC | 89 | config ACPI_AC |
90 | tristate "AC Adapter" | 90 | tristate "AC Adapter" |
91 | depends on X86 && POWER_SUPPLY | 91 | depends on X86 |
92 | select POWER_SUPPLY | ||
92 | default y | 93 | default y |
93 | help | 94 | help |
94 | This driver adds support for the AC Adapter object, which indicates | 95 | This driver adds support for the AC Adapter object, which indicates |
@@ -97,7 +98,8 @@ config ACPI_AC | |||
97 | 98 | ||
98 | config ACPI_BATTERY | 99 | config ACPI_BATTERY |
99 | tristate "Battery" | 100 | tristate "Battery" |
100 | depends on X86 && POWER_SUPPLY | 101 | depends on X86 |
102 | select POWER_SUPPLY | ||
101 | default y | 103 | default y |
102 | help | 104 | help |
103 | This driver adds support for battery information through | 105 | This driver adds support for battery information through |
@@ -352,7 +354,7 @@ config ACPI_HOTPLUG_MEMORY | |||
352 | config ACPI_SBS | 354 | config ACPI_SBS |
353 | tristate "Smart Battery System" | 355 | tristate "Smart Battery System" |
354 | depends on X86 | 356 | depends on X86 |
355 | depends on POWER_SUPPLY | 357 | select POWER_SUPPLY |
356 | help | 358 | help |
357 | This driver adds support for the Smart Battery System, another | 359 | This driver adds support for the Smart Battery System, another |
358 | type of access to battery information, found on some laptops. | 360 | type of access to battery information, found on some laptops. |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 681e26b56b11..c2ce0ad21693 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -125,11 +125,15 @@ static int acpi_battery_technology(struct acpi_battery *battery) | |||
125 | return POWER_SUPPLY_TECHNOLOGY_NiMH; | 125 | return POWER_SUPPLY_TECHNOLOGY_NiMH; |
126 | if (!strcasecmp("LION", battery->type)) | 126 | if (!strcasecmp("LION", battery->type)) |
127 | return POWER_SUPPLY_TECHNOLOGY_LION; | 127 | return POWER_SUPPLY_TECHNOLOGY_LION; |
128 | if (!strcasecmp("LI-ION", battery->type)) | ||
129 | return POWER_SUPPLY_TECHNOLOGY_LION; | ||
128 | if (!strcasecmp("LiP", battery->type)) | 130 | if (!strcasecmp("LiP", battery->type)) |
129 | return POWER_SUPPLY_TECHNOLOGY_LIPO; | 131 | return POWER_SUPPLY_TECHNOLOGY_LIPO; |
130 | return POWER_SUPPLY_TECHNOLOGY_UNKNOWN; | 132 | return POWER_SUPPLY_TECHNOLOGY_UNKNOWN; |
131 | } | 133 | } |
132 | 134 | ||
135 | static int acpi_battery_update(struct acpi_battery *battery); | ||
136 | |||
133 | static int acpi_battery_get_property(struct power_supply *psy, | 137 | static int acpi_battery_get_property(struct power_supply *psy, |
134 | enum power_supply_property psp, | 138 | enum power_supply_property psp, |
135 | union power_supply_propval *val) | 139 | union power_supply_propval *val) |
@@ -139,6 +143,7 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
139 | if ((!acpi_battery_present(battery)) && | 143 | if ((!acpi_battery_present(battery)) && |
140 | psp != POWER_SUPPLY_PROP_PRESENT) | 144 | psp != POWER_SUPPLY_PROP_PRESENT) |
141 | return -ENODEV; | 145 | return -ENODEV; |
146 | acpi_battery_update(battery); | ||
142 | switch (psp) { | 147 | switch (psp) { |
143 | case POWER_SUPPLY_PROP_STATUS: | 148 | case POWER_SUPPLY_PROP_STATUS: |
144 | if (battery->state & 0x01) | 149 | if (battery->state & 0x01) |
@@ -257,7 +262,7 @@ static int extract_package(struct acpi_battery *battery, | |||
257 | union acpi_object *package, | 262 | union acpi_object *package, |
258 | struct acpi_offsets *offsets, int num) | 263 | struct acpi_offsets *offsets, int num) |
259 | { | 264 | { |
260 | int i, *x; | 265 | int i; |
261 | union acpi_object *element; | 266 | union acpi_object *element; |
262 | if (package->type != ACPI_TYPE_PACKAGE) | 267 | if (package->type != ACPI_TYPE_PACKAGE) |
263 | return -EFAULT; | 268 | return -EFAULT; |
@@ -266,16 +271,21 @@ static int extract_package(struct acpi_battery *battery, | |||
266 | return -EFAULT; | 271 | return -EFAULT; |
267 | element = &package->package.elements[i]; | 272 | element = &package->package.elements[i]; |
268 | if (offsets[i].mode) { | 273 | if (offsets[i].mode) { |
269 | if (element->type != ACPI_TYPE_STRING && | 274 | u8 *ptr = (u8 *)battery + offsets[i].offset; |
270 | element->type != ACPI_TYPE_BUFFER) | 275 | if (element->type == ACPI_TYPE_STRING || |
271 | return -EFAULT; | 276 | element->type == ACPI_TYPE_BUFFER) |
272 | strncpy((u8 *)battery + offsets[i].offset, | 277 | strncpy(ptr, element->string.pointer, 32); |
273 | element->string.pointer, 32); | 278 | else if (element->type == ACPI_TYPE_INTEGER) { |
279 | strncpy(ptr, (u8 *)&element->integer.value, | ||
280 | sizeof(acpi_integer)); | ||
281 | ptr[sizeof(acpi_integer)] = 0; | ||
282 | } else return -EFAULT; | ||
274 | } else { | 283 | } else { |
275 | if (element->type != ACPI_TYPE_INTEGER) | 284 | if (element->type == ACPI_TYPE_INTEGER) { |
276 | return -EFAULT; | 285 | int *x = (int *)((u8 *)battery + |
277 | x = (int *)((u8 *)battery + offsets[i].offset); | 286 | offsets[i].offset); |
278 | *x = element->integer.value; | 287 | *x = element->integer.value; |
288 | } else return -EFAULT; | ||
279 | } | 289 | } |
280 | } | 290 | } |
281 | return 0; | 291 | return 0; |
@@ -385,29 +395,81 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery) | |||
385 | return acpi_battery_set_alarm(battery); | 395 | return acpi_battery_set_alarm(battery); |
386 | } | 396 | } |
387 | 397 | ||
398 | static ssize_t acpi_battery_alarm_show(struct device *dev, | ||
399 | struct device_attribute *attr, | ||
400 | char *buf) | ||
401 | { | ||
402 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
403 | return sprintf(buf, "%d\n", battery->alarm * 1000); | ||
404 | } | ||
405 | |||
406 | static ssize_t acpi_battery_alarm_store(struct device *dev, | ||
407 | struct device_attribute *attr, | ||
408 | const char *buf, size_t count) | ||
409 | { | ||
410 | unsigned long x; | ||
411 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
412 | if (sscanf(buf, "%ld\n", &x) == 1) | ||
413 | battery->alarm = x/1000; | ||
414 | if (acpi_battery_present(battery)) | ||
415 | acpi_battery_set_alarm(battery); | ||
416 | return count; | ||
417 | } | ||
418 | |||
419 | static struct device_attribute alarm_attr = { | ||
420 | .attr = {.name = "alarm", .mode = 0644, .owner = THIS_MODULE}, | ||
421 | .show = acpi_battery_alarm_show, | ||
422 | .store = acpi_battery_alarm_store, | ||
423 | }; | ||
424 | |||
425 | static int sysfs_add_battery(struct acpi_battery *battery) | ||
426 | { | ||
427 | int result; | ||
428 | |||
429 | battery->update_time = 0; | ||
430 | result = acpi_battery_get_info(battery); | ||
431 | acpi_battery_init_alarm(battery); | ||
432 | if (result) | ||
433 | return result; | ||
434 | if (battery->power_unit) { | ||
435 | battery->bat.properties = charge_battery_props; | ||
436 | battery->bat.num_properties = | ||
437 | ARRAY_SIZE(charge_battery_props); | ||
438 | } else { | ||
439 | battery->bat.properties = energy_battery_props; | ||
440 | battery->bat.num_properties = | ||
441 | ARRAY_SIZE(energy_battery_props); | ||
442 | } | ||
443 | |||
444 | battery->bat.name = acpi_device_bid(battery->device); | ||
445 | battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; | ||
446 | battery->bat.get_property = acpi_battery_get_property; | ||
447 | |||
448 | result = power_supply_register(&battery->device->dev, &battery->bat); | ||
449 | if (result) | ||
450 | return result; | ||
451 | return device_create_file(battery->bat.dev, &alarm_attr); | ||
452 | } | ||
453 | |||
454 | static void sysfs_remove_battery(struct acpi_battery *battery) | ||
455 | { | ||
456 | if (!battery->bat.dev) | ||
457 | return; | ||
458 | device_remove_file(battery->bat.dev, &alarm_attr); | ||
459 | power_supply_unregister(&battery->bat); | ||
460 | } | ||
461 | |||
388 | static int acpi_battery_update(struct acpi_battery *battery) | 462 | static int acpi_battery_update(struct acpi_battery *battery) |
389 | { | 463 | { |
390 | int saved_present = acpi_battery_present(battery); | ||
391 | int result = acpi_battery_get_status(battery); | 464 | int result = acpi_battery_get_status(battery); |
392 | if (result || !acpi_battery_present(battery)) | 465 | if (result) |
393 | return result; | 466 | return result; |
394 | if (saved_present != acpi_battery_present(battery) || | 467 | if (!acpi_battery_present(battery)) { |
395 | !battery->update_time) { | 468 | sysfs_remove_battery(battery); |
396 | battery->update_time = 0; | 469 | return 0; |
397 | result = acpi_battery_get_info(battery); | ||
398 | if (result) | ||
399 | return result; | ||
400 | if (battery->power_unit) { | ||
401 | battery->bat.properties = charge_battery_props; | ||
402 | battery->bat.num_properties = | ||
403 | ARRAY_SIZE(charge_battery_props); | ||
404 | } else { | ||
405 | battery->bat.properties = energy_battery_props; | ||
406 | battery->bat.num_properties = | ||
407 | ARRAY_SIZE(energy_battery_props); | ||
408 | } | ||
409 | acpi_battery_init_alarm(battery); | ||
410 | } | 470 | } |
471 | if (!battery->bat.dev) | ||
472 | sysfs_add_battery(battery); | ||
411 | return acpi_battery_get_state(battery); | 473 | return acpi_battery_get_state(battery); |
412 | } | 474 | } |
413 | 475 | ||
@@ -554,10 +616,6 @@ static ssize_t acpi_battery_write_alarm(struct file *file, | |||
554 | 616 | ||
555 | if (!battery || (count > sizeof(alarm_string) - 1)) | 617 | if (!battery || (count > sizeof(alarm_string) - 1)) |
556 | return -EINVAL; | 618 | return -EINVAL; |
557 | if (result) { | ||
558 | result = -ENODEV; | ||
559 | goto end; | ||
560 | } | ||
561 | if (!acpi_battery_present(battery)) { | 619 | if (!acpi_battery_present(battery)) { |
562 | result = -ENODEV; | 620 | result = -ENODEV; |
563 | goto end; | 621 | goto end; |
@@ -688,33 +746,6 @@ static void acpi_battery_remove_fs(struct acpi_device *device) | |||
688 | 746 | ||
689 | #endif | 747 | #endif |
690 | 748 | ||
691 | static ssize_t acpi_battery_alarm_show(struct device *dev, | ||
692 | struct device_attribute *attr, | ||
693 | char *buf) | ||
694 | { | ||
695 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
696 | return sprintf(buf, "%d\n", battery->alarm * 1000); | ||
697 | } | ||
698 | |||
699 | static ssize_t acpi_battery_alarm_store(struct device *dev, | ||
700 | struct device_attribute *attr, | ||
701 | const char *buf, size_t count) | ||
702 | { | ||
703 | unsigned long x; | ||
704 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
705 | if (sscanf(buf, "%ld\n", &x) == 1) | ||
706 | battery->alarm = x/1000; | ||
707 | if (acpi_battery_present(battery)) | ||
708 | acpi_battery_set_alarm(battery); | ||
709 | return count; | ||
710 | } | ||
711 | |||
712 | static struct device_attribute alarm_attr = { | ||
713 | .attr = {.name = "alarm", .mode = 0644, .owner = THIS_MODULE}, | ||
714 | .show = acpi_battery_alarm_show, | ||
715 | .store = acpi_battery_alarm_store, | ||
716 | }; | ||
717 | |||
718 | /* -------------------------------------------------------------------------- | 749 | /* -------------------------------------------------------------------------- |
719 | Driver Interface | 750 | Driver Interface |
720 | -------------------------------------------------------------------------- */ | 751 | -------------------------------------------------------------------------- */ |
@@ -732,7 +763,9 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) | |||
732 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 763 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
733 | device->dev.bus_id, event, | 764 | device->dev.bus_id, event, |
734 | acpi_battery_present(battery)); | 765 | acpi_battery_present(battery)); |
735 | kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); | 766 | /* acpi_batter_update could remove power_supply object */ |
767 | if (battery->bat.dev) | ||
768 | kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); | ||
736 | } | 769 | } |
737 | 770 | ||
738 | static int acpi_battery_add(struct acpi_device *device) | 771 | static int acpi_battery_add(struct acpi_device *device) |
@@ -756,11 +789,6 @@ static int acpi_battery_add(struct acpi_device *device) | |||
756 | if (result) | 789 | if (result) |
757 | goto end; | 790 | goto end; |
758 | #endif | 791 | #endif |
759 | battery->bat.name = acpi_device_bid(device); | ||
760 | battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; | ||
761 | battery->bat.get_property = acpi_battery_get_property; | ||
762 | result = power_supply_register(&battery->device->dev, &battery->bat); | ||
763 | result = device_create_file(battery->bat.dev, &alarm_attr); | ||
764 | status = acpi_install_notify_handler(device->handle, | 792 | status = acpi_install_notify_handler(device->handle, |
765 | ACPI_ALL_NOTIFY, | 793 | ACPI_ALL_NOTIFY, |
766 | acpi_battery_notify, battery); | 794 | acpi_battery_notify, battery); |
@@ -796,10 +824,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type) | |||
796 | #ifdef CONFIG_ACPI_PROCFS | 824 | #ifdef CONFIG_ACPI_PROCFS |
797 | acpi_battery_remove_fs(device); | 825 | acpi_battery_remove_fs(device); |
798 | #endif | 826 | #endif |
799 | if (battery->bat.dev) { | 827 | sysfs_remove_battery(battery); |
800 | device_remove_file(battery->bat.dev, &alarm_attr); | ||
801 | power_supply_unregister(&battery->bat); | ||
802 | } | ||
803 | mutex_destroy(&battery->lock); | 828 | mutex_destroy(&battery->lock); |
804 | kfree(battery); | 829 | kfree(battery); |
805 | return 0; | 830 | return 0; |
@@ -813,6 +838,7 @@ static int acpi_battery_resume(struct acpi_device *device) | |||
813 | return -EINVAL; | 838 | return -EINVAL; |
814 | battery = acpi_driver_data(device); | 839 | battery = acpi_driver_data(device); |
815 | battery->update_time = 0; | 840 | battery->update_time = 0; |
841 | acpi_battery_update(battery); | ||
816 | return 0; | 842 | return 0; |
817 | } | 843 | } |
818 | 844 | ||
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index fb2cff9a2d24..49d432d0a12c 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -198,12 +198,10 @@ int acpi_bus_set_power(acpi_handle handle, int state) | |||
198 | return -ENODEV; | 198 | return -ENODEV; |
199 | } | 199 | } |
200 | /* | 200 | /* |
201 | * Get device's current power state if it's unknown | 201 | * Get device's current power state |
202 | * This means device power state isn't initialized or previous setting failed | ||
203 | */ | 202 | */ |
204 | if ((device->power.state == ACPI_STATE_UNKNOWN) || device->flags.force_power_state) | 203 | acpi_bus_get_power(device->handle, &device->power.state); |
205 | acpi_bus_get_power(device->handle, &device->power.state); | 204 | if (state == device->power.state) { |
206 | if ((state == device->power.state) && !device->flags.force_power_state) { | ||
207 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", | 205 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", |
208 | state)); | 206 | state)); |
209 | return 0; | 207 | return 0; |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 301e832e6961..24a7865a57cb 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -78,6 +78,7 @@ MODULE_DEVICE_TABLE(acpi, button_device_ids); | |||
78 | 78 | ||
79 | static int acpi_button_add(struct acpi_device *device); | 79 | static int acpi_button_add(struct acpi_device *device); |
80 | static int acpi_button_remove(struct acpi_device *device, int type); | 80 | static int acpi_button_remove(struct acpi_device *device, int type); |
81 | static int acpi_button_resume(struct acpi_device *device); | ||
81 | static int acpi_button_info_open_fs(struct inode *inode, struct file *file); | 82 | static int acpi_button_info_open_fs(struct inode *inode, struct file *file); |
82 | static int acpi_button_state_open_fs(struct inode *inode, struct file *file); | 83 | static int acpi_button_state_open_fs(struct inode *inode, struct file *file); |
83 | 84 | ||
@@ -87,6 +88,7 @@ static struct acpi_driver acpi_button_driver = { | |||
87 | .ids = button_device_ids, | 88 | .ids = button_device_ids, |
88 | .ops = { | 89 | .ops = { |
89 | .add = acpi_button_add, | 90 | .add = acpi_button_add, |
91 | .resume = acpi_button_resume, | ||
90 | .remove = acpi_button_remove, | 92 | .remove = acpi_button_remove, |
91 | }, | 93 | }, |
92 | }; | 94 | }; |
@@ -253,6 +255,19 @@ static int acpi_button_remove_fs(struct acpi_device *device) | |||
253 | /* -------------------------------------------------------------------------- | 255 | /* -------------------------------------------------------------------------- |
254 | Driver Interface | 256 | Driver Interface |
255 | -------------------------------------------------------------------------- */ | 257 | -------------------------------------------------------------------------- */ |
258 | static int acpi_lid_send_state(struct acpi_button *button) | ||
259 | { | ||
260 | unsigned long state; | ||
261 | acpi_status status; | ||
262 | |||
263 | status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, | ||
264 | &state); | ||
265 | if (ACPI_FAILURE(status)) | ||
266 | return -ENODEV; | ||
267 | /* input layer checks if event is redundant */ | ||
268 | input_report_switch(button->input, SW_LID, !state); | ||
269 | return 0; | ||
270 | } | ||
256 | 271 | ||
257 | static void acpi_button_notify(acpi_handle handle, u32 event, void *data) | 272 | static void acpi_button_notify(acpi_handle handle, u32 event, void *data) |
258 | { | 273 | { |
@@ -265,15 +280,8 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) | |||
265 | switch (event) { | 280 | switch (event) { |
266 | case ACPI_BUTTON_NOTIFY_STATUS: | 281 | case ACPI_BUTTON_NOTIFY_STATUS: |
267 | input = button->input; | 282 | input = button->input; |
268 | |||
269 | if (button->type == ACPI_BUTTON_TYPE_LID) { | 283 | if (button->type == ACPI_BUTTON_TYPE_LID) { |
270 | struct acpi_handle *handle = button->device->handle; | 284 | acpi_lid_send_state(button); |
271 | unsigned long state; | ||
272 | |||
273 | if (!ACPI_FAILURE(acpi_evaluate_integer(handle, "_LID", | ||
274 | NULL, &state))) | ||
275 | input_report_switch(input, SW_LID, !state); | ||
276 | |||
277 | } else { | 285 | } else { |
278 | int keycode = test_bit(KEY_SLEEP, input->keybit) ? | 286 | int keycode = test_bit(KEY_SLEEP, input->keybit) ? |
279 | KEY_SLEEP : KEY_POWER; | 287 | KEY_SLEEP : KEY_POWER; |
@@ -336,6 +344,17 @@ static int acpi_button_install_notify_handlers(struct acpi_button *button) | |||
336 | return ACPI_FAILURE(status) ? -ENODEV : 0; | 344 | return ACPI_FAILURE(status) ? -ENODEV : 0; |
337 | } | 345 | } |
338 | 346 | ||
347 | static int acpi_button_resume(struct acpi_device *device) | ||
348 | { | ||
349 | struct acpi_button *button; | ||
350 | if (!device) | ||
351 | return -EINVAL; | ||
352 | button = acpi_driver_data(device); | ||
353 | if (button && button->type == ACPI_BUTTON_TYPE_LID) | ||
354 | return acpi_lid_send_state(button); | ||
355 | return 0; | ||
356 | } | ||
357 | |||
339 | static void acpi_button_remove_notify_handlers(struct acpi_button *button) | 358 | static void acpi_button_remove_notify_handlers(struct acpi_button *button) |
340 | { | 359 | { |
341 | switch (button->type) { | 360 | switch (button->type) { |
@@ -453,6 +472,8 @@ static int acpi_button_add(struct acpi_device *device) | |||
453 | error = input_register_device(input); | 472 | error = input_register_device(input); |
454 | if (error) | 473 | if (error) |
455 | goto err_remove_handlers; | 474 | goto err_remove_handlers; |
475 | if (button->type == ACPI_BUTTON_TYPE_LID) | ||
476 | acpi_lid_send_state(button); | ||
456 | 477 | ||
457 | if (device->wakeup.flags.valid) { | 478 | if (device->wakeup.flags.valid) { |
458 | /* Button's GPE is run-wake GPE */ | 479 | /* Button's GPE is run-wake GPE */ |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 7b4178393e34..06b78e5e33a1 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -65,16 +65,18 @@ enum ec_command { | |||
65 | /* EC events */ | 65 | /* EC events */ |
66 | enum ec_event { | 66 | enum ec_event { |
67 | ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */ | 67 | ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */ |
68 | ACPI_EC_EVENT_IBF_0, /* Input buffer empty */ | 68 | ACPI_EC_EVENT_IBF_0, /* Input buffer empty */ |
69 | }; | 69 | }; |
70 | 70 | ||
71 | #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ | 71 | #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ |
72 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ | 72 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ |
73 | 73 | ||
74 | static enum ec_mode { | 74 | enum { |
75 | EC_INTR = 1, /* Output buffer full */ | 75 | EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ |
76 | EC_POLL, /* Input buffer empty */ | 76 | EC_FLAGS_QUERY_PENDING, /* Query is pending */ |
77 | } acpi_ec_mode = EC_INTR; | 77 | EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ |
78 | EC_FLAGS_ONLY_IBF_GPE, /* Expect GPE only for IBF = 0 event */ | ||
79 | }; | ||
78 | 80 | ||
79 | static int acpi_ec_remove(struct acpi_device *device, int type); | 81 | static int acpi_ec_remove(struct acpi_device *device, int type); |
80 | static int acpi_ec_start(struct acpi_device *device); | 82 | static int acpi_ec_start(struct acpi_device *device); |
@@ -116,9 +118,8 @@ static struct acpi_ec { | |||
116 | unsigned long command_addr; | 118 | unsigned long command_addr; |
117 | unsigned long data_addr; | 119 | unsigned long data_addr; |
118 | unsigned long global_lock; | 120 | unsigned long global_lock; |
121 | unsigned long flags; | ||
119 | struct mutex lock; | 122 | struct mutex lock; |
120 | atomic_t query_pending; | ||
121 | atomic_t event_count; | ||
122 | wait_queue_head_t wait; | 123 | wait_queue_head_t wait; |
123 | struct list_head list; | 124 | struct list_head list; |
124 | u8 handlers_installed; | 125 | u8 handlers_installed; |
@@ -148,45 +149,54 @@ static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) | |||
148 | outb(data, ec->data_addr); | 149 | outb(data, ec->data_addr); |
149 | } | 150 | } |
150 | 151 | ||
151 | static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event, | 152 | static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) |
152 | unsigned old_count) | ||
153 | { | 153 | { |
154 | u8 status = acpi_ec_read_status(ec); | 154 | if (test_bit(EC_FLAGS_WAIT_GPE, &ec->flags)) |
155 | if (old_count == atomic_read(&ec->event_count)) | ||
156 | return 0; | 155 | return 0; |
157 | if (event == ACPI_EC_EVENT_OBF_1) { | 156 | if (event == ACPI_EC_EVENT_OBF_1) { |
158 | if (status & ACPI_EC_FLAG_OBF) | 157 | if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF) |
159 | return 1; | 158 | return 1; |
160 | } else if (event == ACPI_EC_EVENT_IBF_0) { | 159 | } else if (event == ACPI_EC_EVENT_IBF_0) { |
161 | if (!(status & ACPI_EC_FLAG_IBF)) | 160 | if (!(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)) |
162 | return 1; | 161 | return 1; |
163 | } | 162 | } |
164 | 163 | ||
165 | return 0; | 164 | return 0; |
166 | } | 165 | } |
167 | 166 | ||
168 | static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, | 167 | static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) |
169 | unsigned count, int force_poll) | ||
170 | { | 168 | { |
171 | if (unlikely(force_poll) || acpi_ec_mode == EC_POLL) { | 169 | if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && |
170 | likely(!force_poll)) { | ||
171 | if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), | ||
172 | msecs_to_jiffies(ACPI_EC_DELAY))) | ||
173 | return 0; | ||
174 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | ||
175 | if (acpi_ec_check_status(ec, event)) { | ||
176 | if (event == ACPI_EC_EVENT_OBF_1) { | ||
177 | /* miss OBF = 1 GPE, don't expect it anymore */ | ||
178 | printk(KERN_INFO PREFIX "missing OBF_1 confirmation," | ||
179 | "switching to degraded mode.\n"); | ||
180 | set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); | ||
181 | } else { | ||
182 | /* missing GPEs, switch back to poll mode */ | ||
183 | printk(KERN_INFO PREFIX "missing IBF_1 confirmations," | ||
184 | "switch off interrupt mode.\n"); | ||
185 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); | ||
186 | } | ||
187 | return 0; | ||
188 | } | ||
189 | } else { | ||
172 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); | 190 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); |
191 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | ||
173 | while (time_before(jiffies, delay)) { | 192 | while (time_before(jiffies, delay)) { |
174 | if (acpi_ec_check_status(ec, event, 0)) | 193 | if (acpi_ec_check_status(ec, event)) |
175 | return 0; | 194 | return 0; |
176 | } | 195 | } |
177 | } else { | 196 | } |
178 | if (wait_event_timeout(ec->wait, | 197 | printk(KERN_ERR PREFIX "acpi_ec_wait timeout," |
179 | acpi_ec_check_status(ec, event, count), | ||
180 | msecs_to_jiffies(ACPI_EC_DELAY)) || | ||
181 | acpi_ec_check_status(ec, event, 0)) { | ||
182 | return 0; | ||
183 | } else { | ||
184 | printk(KERN_ERR PREFIX "acpi_ec_wait timeout," | ||
185 | " status = %d, expect_event = %d\n", | 198 | " status = %d, expect_event = %d\n", |
186 | acpi_ec_read_status(ec), event); | 199 | acpi_ec_read_status(ec), event); |
187 | } | ||
188 | } | ||
189 | |||
190 | return -ETIME; | 200 | return -ETIME; |
191 | } | 201 | } |
192 | 202 | ||
@@ -196,39 +206,42 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | |||
196 | int force_poll) | 206 | int force_poll) |
197 | { | 207 | { |
198 | int result = 0; | 208 | int result = 0; |
199 | unsigned count = atomic_read(&ec->event_count); | 209 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); |
200 | acpi_ec_write_cmd(ec, command); | 210 | acpi_ec_write_cmd(ec, command); |
201 | 211 | ||
202 | for (; wdata_len > 0; --wdata_len) { | 212 | for (; wdata_len > 0; --wdata_len) { |
203 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count, force_poll); | 213 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); |
204 | if (result) { | 214 | if (result) { |
205 | printk(KERN_ERR PREFIX | 215 | printk(KERN_ERR PREFIX |
206 | "write_cmd timeout, command = %d\n", command); | 216 | "write_cmd timeout, command = %d\n", command); |
207 | goto end; | 217 | goto end; |
208 | } | 218 | } |
209 | count = atomic_read(&ec->event_count); | 219 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); |
210 | acpi_ec_write_data(ec, *(wdata++)); | 220 | acpi_ec_write_data(ec, *(wdata++)); |
211 | } | 221 | } |
212 | 222 | ||
213 | if (!rdata_len) { | 223 | if (!rdata_len) { |
214 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count, force_poll); | 224 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); |
215 | if (result) { | 225 | if (result) { |
216 | printk(KERN_ERR PREFIX | 226 | printk(KERN_ERR PREFIX |
217 | "finish-write timeout, command = %d\n", command); | 227 | "finish-write timeout, command = %d\n", command); |
218 | goto end; | 228 | goto end; |
219 | } | 229 | } |
220 | } else if (command == ACPI_EC_COMMAND_QUERY) { | 230 | } else if (command == ACPI_EC_COMMAND_QUERY) |
221 | atomic_set(&ec->query_pending, 0); | 231 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); |
222 | } | ||
223 | 232 | ||
224 | for (; rdata_len > 0; --rdata_len) { | 233 | for (; rdata_len > 0; --rdata_len) { |
225 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, count, force_poll); | 234 | if (test_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags)) |
235 | force_poll = 1; | ||
236 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); | ||
226 | if (result) { | 237 | if (result) { |
227 | printk(KERN_ERR PREFIX "read timeout, command = %d\n", | 238 | printk(KERN_ERR PREFIX "read timeout, command = %d\n", |
228 | command); | 239 | command); |
229 | goto end; | 240 | goto end; |
230 | } | 241 | } |
231 | count = atomic_read(&ec->event_count); | 242 | /* Don't expect GPE after last read */ |
243 | if (rdata_len > 1) | ||
244 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | ||
232 | *(rdata++) = acpi_ec_read_data(ec); | 245 | *(rdata++) = acpi_ec_read_data(ec); |
233 | } | 246 | } |
234 | end: | 247 | end: |
@@ -258,10 +271,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | |||
258 | } | 271 | } |
259 | } | 272 | } |
260 | 273 | ||
261 | /* Make sure GPE is enabled before doing transaction */ | 274 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); |
262 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | ||
263 | |||
264 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0, 0); | ||
265 | if (status) { | 275 | if (status) { |
266 | printk(KERN_ERR PREFIX | 276 | printk(KERN_ERR PREFIX |
267 | "input buffer is not empty, aborting transaction\n"); | 277 | "input buffer is not empty, aborting transaction\n"); |
@@ -435,9 +445,9 @@ EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler); | |||
435 | 445 | ||
436 | void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) | 446 | void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) |
437 | { | 447 | { |
438 | struct acpi_ec_query_handler *handler; | 448 | struct acpi_ec_query_handler *handler, *tmp; |
439 | mutex_lock(&ec->lock); | 449 | mutex_lock(&ec->lock); |
440 | list_for_each_entry(handler, &ec->list, node) { | 450 | list_for_each_entry_safe(handler, tmp, &ec->list, node) { |
441 | if (query_bit == handler->query_bit) { | 451 | if (query_bit == handler->query_bit) { |
442 | list_del(&handler->node); | 452 | list_del(&handler->node); |
443 | kfree(handler); | 453 | kfree(handler); |
@@ -476,23 +486,24 @@ static void acpi_ec_gpe_query(void *ec_cxt) | |||
476 | static u32 acpi_ec_gpe_handler(void *data) | 486 | static u32 acpi_ec_gpe_handler(void *data) |
477 | { | 487 | { |
478 | acpi_status status = AE_OK; | 488 | acpi_status status = AE_OK; |
479 | u8 value; | ||
480 | struct acpi_ec *ec = data; | 489 | struct acpi_ec *ec = data; |
481 | 490 | ||
482 | atomic_inc(&ec->event_count); | 491 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); |
483 | 492 | if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) | |
484 | if (acpi_ec_mode == EC_INTR) { | ||
485 | wake_up(&ec->wait); | 493 | wake_up(&ec->wait); |
486 | } | ||
487 | 494 | ||
488 | value = acpi_ec_read_status(ec); | 495 | if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) { |
489 | if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) { | 496 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) |
490 | atomic_set(&ec->query_pending, 1); | 497 | status = acpi_os_execute(OSL_EC_BURST_HANDLER, |
491 | status = | 498 | acpi_ec_gpe_query, ec); |
492 | acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec); | 499 | } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) { |
500 | /* this is non-query, must be confirmation */ | ||
501 | printk(KERN_INFO PREFIX "non-query interrupt received," | ||
502 | " switching to interrupt mode\n"); | ||
503 | set_bit(EC_FLAGS_GPE_MODE, &ec->flags); | ||
493 | } | 504 | } |
494 | 505 | ||
495 | return status == AE_OK ? | 506 | return ACPI_SUCCESS(status) ? |
496 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | 507 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; |
497 | } | 508 | } |
498 | 509 | ||
@@ -641,13 +652,10 @@ static struct acpi_ec *make_acpi_ec(void) | |||
641 | struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); | 652 | struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
642 | if (!ec) | 653 | if (!ec) |
643 | return NULL; | 654 | return NULL; |
644 | 655 | ec->flags = 1 << EC_FLAGS_QUERY_PENDING; | |
645 | atomic_set(&ec->query_pending, 1); | ||
646 | atomic_set(&ec->event_count, 1); | ||
647 | mutex_init(&ec->lock); | 656 | mutex_init(&ec->lock); |
648 | init_waitqueue_head(&ec->wait); | 657 | init_waitqueue_head(&ec->wait); |
649 | INIT_LIST_HEAD(&ec->list); | 658 | INIT_LIST_HEAD(&ec->list); |
650 | |||
651 | return ec; | 659 | return ec; |
652 | } | 660 | } |
653 | 661 | ||
@@ -741,6 +749,8 @@ static int acpi_ec_add(struct acpi_device *device) | |||
741 | acpi_ec_add_fs(device); | 749 | acpi_ec_add_fs(device); |
742 | printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", | 750 | printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", |
743 | ec->gpe, ec->command_addr, ec->data_addr); | 751 | ec->gpe, ec->command_addr, ec->data_addr); |
752 | printk(KERN_INFO PREFIX "driver started in %s mode\n", | ||
753 | (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll"); | ||
744 | return 0; | 754 | return 0; |
745 | } | 755 | } |
746 | 756 | ||
@@ -833,7 +843,7 @@ static int acpi_ec_start(struct acpi_device *device) | |||
833 | ret = ec_install_handlers(ec); | 843 | ret = ec_install_handlers(ec); |
834 | 844 | ||
835 | /* EC is fully operational, allow queries */ | 845 | /* EC is fully operational, allow queries */ |
836 | atomic_set(&ec->query_pending, 0); | 846 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); |
837 | return ret; | 847 | return ret; |
838 | } | 848 | } |
839 | 849 | ||
@@ -924,20 +934,4 @@ static void __exit acpi_ec_exit(void) | |||
924 | 934 | ||
925 | return; | 935 | return; |
926 | } | 936 | } |
927 | #endif /* 0 */ | 937 | #endif /* 0 */ |
928 | |||
929 | static int __init acpi_ec_set_intr_mode(char *str) | ||
930 | { | ||
931 | int intr; | ||
932 | |||
933 | if (!get_option(&str, &intr)) | ||
934 | return 0; | ||
935 | |||
936 | acpi_ec_mode = (intr) ? EC_INTR : EC_POLL; | ||
937 | |||
938 | printk(KERN_NOTICE PREFIX "%s mode.\n", intr ? "interrupt" : "polling"); | ||
939 | |||
940 | return 1; | ||
941 | } | ||
942 | |||
943 | __setup("ec_intr=", acpi_ec_set_intr_mode); | ||
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index c81f6bdb68b8..a5a5532db268 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -47,8 +47,6 @@ MODULE_LICENSE("GPL"); | |||
47 | 47 | ||
48 | static int acpi_fan_add(struct acpi_device *device); | 48 | static int acpi_fan_add(struct acpi_device *device); |
49 | static int acpi_fan_remove(struct acpi_device *device, int type); | 49 | static int acpi_fan_remove(struct acpi_device *device, int type); |
50 | static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state); | ||
51 | static int acpi_fan_resume(struct acpi_device *device); | ||
52 | 50 | ||
53 | static const struct acpi_device_id fan_device_ids[] = { | 51 | static const struct acpi_device_id fan_device_ids[] = { |
54 | {"PNP0C0B", 0}, | 52 | {"PNP0C0B", 0}, |
@@ -63,15 +61,9 @@ static struct acpi_driver acpi_fan_driver = { | |||
63 | .ops = { | 61 | .ops = { |
64 | .add = acpi_fan_add, | 62 | .add = acpi_fan_add, |
65 | .remove = acpi_fan_remove, | 63 | .remove = acpi_fan_remove, |
66 | .suspend = acpi_fan_suspend, | ||
67 | .resume = acpi_fan_resume, | ||
68 | }, | 64 | }, |
69 | }; | 65 | }; |
70 | 66 | ||
71 | struct acpi_fan { | ||
72 | struct acpi_device * device; | ||
73 | }; | ||
74 | |||
75 | /* -------------------------------------------------------------------------- | 67 | /* -------------------------------------------------------------------------- |
76 | FS Interface (/proc) | 68 | FS Interface (/proc) |
77 | -------------------------------------------------------------------------- */ | 69 | -------------------------------------------------------------------------- */ |
@@ -80,12 +72,12 @@ static struct proc_dir_entry *acpi_fan_dir; | |||
80 | 72 | ||
81 | static int acpi_fan_read_state(struct seq_file *seq, void *offset) | 73 | static int acpi_fan_read_state(struct seq_file *seq, void *offset) |
82 | { | 74 | { |
83 | struct acpi_fan *fan = seq->private; | 75 | struct acpi_device *device = seq->private; |
84 | int state = 0; | 76 | int state = 0; |
85 | 77 | ||
86 | 78 | ||
87 | if (fan) { | 79 | if (device) { |
88 | if (acpi_bus_get_power(fan->device->handle, &state)) | 80 | if (acpi_bus_get_power(device->handle, &state)) |
89 | seq_printf(seq, "status: ERROR\n"); | 81 | seq_printf(seq, "status: ERROR\n"); |
90 | else | 82 | else |
91 | seq_printf(seq, "status: %s\n", | 83 | seq_printf(seq, "status: %s\n", |
@@ -105,11 +97,10 @@ acpi_fan_write_state(struct file *file, const char __user * buffer, | |||
105 | { | 97 | { |
106 | int result = 0; | 98 | int result = 0; |
107 | struct seq_file *m = file->private_data; | 99 | struct seq_file *m = file->private_data; |
108 | struct acpi_fan *fan = m->private; | 100 | struct acpi_device *device = m->private; |
109 | char state_string[12] = { '\0' }; | 101 | char state_string[12] = { '\0' }; |
110 | 102 | ||
111 | 103 | if (count > sizeof(state_string) - 1) | |
112 | if (!fan || (count > sizeof(state_string) - 1)) | ||
113 | return -EINVAL; | 104 | return -EINVAL; |
114 | 105 | ||
115 | if (copy_from_user(state_string, buffer, count)) | 106 | if (copy_from_user(state_string, buffer, count)) |
@@ -117,7 +108,7 @@ acpi_fan_write_state(struct file *file, const char __user * buffer, | |||
117 | 108 | ||
118 | state_string[count] = '\0'; | 109 | state_string[count] = '\0'; |
119 | 110 | ||
120 | result = acpi_bus_set_power(fan->device->handle, | 111 | result = acpi_bus_set_power(device->handle, |
121 | simple_strtoul(state_string, NULL, 0)); | 112 | simple_strtoul(state_string, NULL, 0)); |
122 | if (result) | 113 | if (result) |
123 | return result; | 114 | return result; |
@@ -158,7 +149,7 @@ static int acpi_fan_add_fs(struct acpi_device *device) | |||
158 | return -ENODEV; | 149 | return -ENODEV; |
159 | else { | 150 | else { |
160 | entry->proc_fops = &acpi_fan_state_ops; | 151 | entry->proc_fops = &acpi_fan_state_ops; |
161 | entry->data = acpi_driver_data(device); | 152 | entry->data = device; |
162 | entry->owner = THIS_MODULE; | 153 | entry->owner = THIS_MODULE; |
163 | } | 154 | } |
164 | 155 | ||
@@ -191,14 +182,8 @@ static int acpi_fan_add(struct acpi_device *device) | |||
191 | if (!device) | 182 | if (!device) |
192 | return -EINVAL; | 183 | return -EINVAL; |
193 | 184 | ||
194 | fan = kzalloc(sizeof(struct acpi_fan), GFP_KERNEL); | ||
195 | if (!fan) | ||
196 | return -ENOMEM; | ||
197 | |||
198 | fan->device = device; | ||
199 | strcpy(acpi_device_name(device), "Fan"); | 185 | strcpy(acpi_device_name(device), "Fan"); |
200 | strcpy(acpi_device_class(device), ACPI_FAN_CLASS); | 186 | strcpy(acpi_device_class(device), ACPI_FAN_CLASS); |
201 | acpi_driver_data(device) = fan; | ||
202 | 187 | ||
203 | result = acpi_bus_get_power(device->handle, &state); | 188 | result = acpi_bus_get_power(device->handle, &state); |
204 | if (result) { | 189 | if (result) { |
@@ -206,10 +191,6 @@ static int acpi_fan_add(struct acpi_device *device) | |||
206 | goto end; | 191 | goto end; |
207 | } | 192 | } |
208 | 193 | ||
209 | device->flags.force_power_state = 1; | ||
210 | acpi_bus_set_power(device->handle, state); | ||
211 | device->flags.force_power_state = 0; | ||
212 | |||
213 | result = acpi_fan_add_fs(device); | 194 | result = acpi_fan_add_fs(device); |
214 | if (result) | 195 | if (result) |
215 | goto end; | 196 | goto end; |
@@ -227,53 +208,14 @@ static int acpi_fan_add(struct acpi_device *device) | |||
227 | 208 | ||
228 | static int acpi_fan_remove(struct acpi_device *device, int type) | 209 | static int acpi_fan_remove(struct acpi_device *device, int type) |
229 | { | 210 | { |
230 | struct acpi_fan *fan = NULL; | ||
231 | |||
232 | |||
233 | if (!device || !acpi_driver_data(device)) | 211 | if (!device || !acpi_driver_data(device)) |
234 | return -EINVAL; | 212 | return -EINVAL; |
235 | 213 | ||
236 | fan = acpi_driver_data(device); | ||
237 | |||
238 | acpi_fan_remove_fs(device); | 214 | acpi_fan_remove_fs(device); |
239 | 215 | ||
240 | kfree(fan); | ||
241 | |||
242 | return 0; | 216 | return 0; |
243 | } | 217 | } |
244 | 218 | ||
245 | static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state) | ||
246 | { | ||
247 | if (!device) | ||
248 | return -EINVAL; | ||
249 | |||
250 | acpi_bus_set_power(device->handle, ACPI_STATE_D0); | ||
251 | |||
252 | return AE_OK; | ||
253 | } | ||
254 | |||
255 | static int acpi_fan_resume(struct acpi_device *device) | ||
256 | { | ||
257 | int result = 0; | ||
258 | int power_state = 0; | ||
259 | |||
260 | if (!device) | ||
261 | return -EINVAL; | ||
262 | |||
263 | result = acpi_bus_get_power(device->handle, &power_state); | ||
264 | if (result) { | ||
265 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
266 | "Error reading fan power state\n")); | ||
267 | return result; | ||
268 | } | ||
269 | |||
270 | device->flags.force_power_state = 1; | ||
271 | acpi_bus_set_power(device->handle, power_state); | ||
272 | device->flags.force_power_state = 0; | ||
273 | |||
274 | return result; | ||
275 | } | ||
276 | |||
277 | static int __init acpi_fan_init(void) | 219 | static int __init acpi_fan_init(void) |
278 | { | 220 | { |
279 | int result = 0; | 221 | int result = 0; |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 57b9a2998fd0..af1769a20c7a 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -86,7 +86,6 @@ struct acpi_power_resource { | |||
86 | acpi_bus_id name; | 86 | acpi_bus_id name; |
87 | u32 system_level; | 87 | u32 system_level; |
88 | u32 order; | 88 | u32 order; |
89 | int state; | ||
90 | struct mutex resource_lock; | 89 | struct mutex resource_lock; |
91 | struct list_head reference; | 90 | struct list_head reference; |
92 | }; | 91 | }; |
@@ -128,33 +127,31 @@ acpi_power_get_context(acpi_handle handle, | |||
128 | return 0; | 127 | return 0; |
129 | } | 128 | } |
130 | 129 | ||
131 | static int acpi_power_get_state(struct acpi_power_resource *resource) | 130 | static int acpi_power_get_state(struct acpi_power_resource *resource, int *state) |
132 | { | 131 | { |
133 | acpi_status status = AE_OK; | 132 | acpi_status status = AE_OK; |
134 | unsigned long sta = 0; | 133 | unsigned long sta = 0; |
135 | 134 | ||
136 | 135 | ||
137 | if (!resource) | 136 | if (!resource || !state) |
138 | return -EINVAL; | 137 | return -EINVAL; |
139 | 138 | ||
140 | status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta); | 139 | status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta); |
141 | if (ACPI_FAILURE(status)) | 140 | if (ACPI_FAILURE(status)) |
142 | return -ENODEV; | 141 | return -ENODEV; |
143 | 142 | ||
144 | if (sta & 0x01) | 143 | *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON: |
145 | resource->state = ACPI_POWER_RESOURCE_STATE_ON; | 144 | ACPI_POWER_RESOURCE_STATE_OFF; |
146 | else | ||
147 | resource->state = ACPI_POWER_RESOURCE_STATE_OFF; | ||
148 | 145 | ||
149 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", | 146 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", |
150 | resource->name, resource->state ? "on" : "off")); | 147 | resource->name, state ? "on" : "off")); |
151 | 148 | ||
152 | return 0; | 149 | return 0; |
153 | } | 150 | } |
154 | 151 | ||
155 | static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) | 152 | static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) |
156 | { | 153 | { |
157 | int result = 0; | 154 | int result = 0, state1; |
158 | struct acpi_power_resource *resource = NULL; | 155 | struct acpi_power_resource *resource = NULL; |
159 | u32 i = 0; | 156 | u32 i = 0; |
160 | 157 | ||
@@ -168,11 +165,11 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) | |||
168 | result = acpi_power_get_context(list->handles[i], &resource); | 165 | result = acpi_power_get_context(list->handles[i], &resource); |
169 | if (result) | 166 | if (result) |
170 | return result; | 167 | return result; |
171 | result = acpi_power_get_state(resource); | 168 | result = acpi_power_get_state(resource, &state1); |
172 | if (result) | 169 | if (result) |
173 | return result; | 170 | return result; |
174 | 171 | ||
175 | *state = resource->state; | 172 | *state = state1; |
176 | 173 | ||
177 | if (*state != ACPI_POWER_RESOURCE_STATE_ON) | 174 | if (*state != ACPI_POWER_RESOURCE_STATE_ON) |
178 | break; | 175 | break; |
@@ -186,7 +183,7 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) | |||
186 | 183 | ||
187 | static int acpi_power_on(acpi_handle handle, struct acpi_device *dev) | 184 | static int acpi_power_on(acpi_handle handle, struct acpi_device *dev) |
188 | { | 185 | { |
189 | int result = 0; | 186 | int result = 0, state; |
190 | int found = 0; | 187 | int found = 0; |
191 | acpi_status status = AE_OK; | 188 | acpi_status status = AE_OK; |
192 | struct acpi_power_resource *resource = NULL; | 189 | struct acpi_power_resource *resource = NULL; |
@@ -224,20 +221,14 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev) | |||
224 | } | 221 | } |
225 | mutex_unlock(&resource->resource_lock); | 222 | mutex_unlock(&resource->resource_lock); |
226 | 223 | ||
227 | if (resource->state == ACPI_POWER_RESOURCE_STATE_ON) { | ||
228 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n", | ||
229 | resource->name)); | ||
230 | return 0; | ||
231 | } | ||
232 | |||
233 | status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL); | 224 | status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL); |
234 | if (ACPI_FAILURE(status)) | 225 | if (ACPI_FAILURE(status)) |
235 | return -ENODEV; | 226 | return -ENODEV; |
236 | 227 | ||
237 | result = acpi_power_get_state(resource); | 228 | result = acpi_power_get_state(resource, &state); |
238 | if (result) | 229 | if (result) |
239 | return result; | 230 | return result; |
240 | if (resource->state != ACPI_POWER_RESOURCE_STATE_ON) | 231 | if (state != ACPI_POWER_RESOURCE_STATE_ON) |
241 | return -ENOEXEC; | 232 | return -ENOEXEC; |
242 | 233 | ||
243 | /* Update the power resource's _device_ power state */ | 234 | /* Update the power resource's _device_ power state */ |
@@ -250,7 +241,7 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev) | |||
250 | 241 | ||
251 | static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev) | 242 | static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev) |
252 | { | 243 | { |
253 | int result = 0; | 244 | int result = 0, state; |
254 | acpi_status status = AE_OK; | 245 | acpi_status status = AE_OK; |
255 | struct acpi_power_resource *resource = NULL; | 246 | struct acpi_power_resource *resource = NULL; |
256 | struct list_head *node, *next; | 247 | struct list_head *node, *next; |
@@ -281,20 +272,14 @@ static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev) | |||
281 | } | 272 | } |
282 | mutex_unlock(&resource->resource_lock); | 273 | mutex_unlock(&resource->resource_lock); |
283 | 274 | ||
284 | if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { | ||
285 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", | ||
286 | resource->name)); | ||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | status = acpi_evaluate_object(resource->device->handle, "_OFF", NULL, NULL); | 275 | status = acpi_evaluate_object(resource->device->handle, "_OFF", NULL, NULL); |
291 | if (ACPI_FAILURE(status)) | 276 | if (ACPI_FAILURE(status)) |
292 | return -ENODEV; | 277 | return -ENODEV; |
293 | 278 | ||
294 | result = acpi_power_get_state(resource); | 279 | result = acpi_power_get_state(resource, &state); |
295 | if (result) | 280 | if (result) |
296 | return result; | 281 | return result; |
297 | if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF) | 282 | if (state != ACPI_POWER_RESOURCE_STATE_OFF) |
298 | return -ENOEXEC; | 283 | return -ENOEXEC; |
299 | 284 | ||
300 | /* Update the power resource's _device_ power state */ | 285 | /* Update the power resource's _device_ power state */ |
@@ -494,7 +479,7 @@ static struct proc_dir_entry *acpi_power_dir; | |||
494 | static int acpi_power_seq_show(struct seq_file *seq, void *offset) | 479 | static int acpi_power_seq_show(struct seq_file *seq, void *offset) |
495 | { | 480 | { |
496 | int count = 0; | 481 | int count = 0; |
497 | int result = 0; | 482 | int result = 0, state; |
498 | struct acpi_power_resource *resource = NULL; | 483 | struct acpi_power_resource *resource = NULL; |
499 | struct list_head *node, *next; | 484 | struct list_head *node, *next; |
500 | struct acpi_power_reference *ref; | 485 | struct acpi_power_reference *ref; |
@@ -505,12 +490,12 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset) | |||
505 | if (!resource) | 490 | if (!resource) |
506 | goto end; | 491 | goto end; |
507 | 492 | ||
508 | result = acpi_power_get_state(resource); | 493 | result = acpi_power_get_state(resource, &state); |
509 | if (result) | 494 | if (result) |
510 | goto end; | 495 | goto end; |
511 | 496 | ||
512 | seq_puts(seq, "state: "); | 497 | seq_puts(seq, "state: "); |
513 | switch (resource->state) { | 498 | switch (state) { |
514 | case ACPI_POWER_RESOURCE_STATE_ON: | 499 | case ACPI_POWER_RESOURCE_STATE_ON: |
515 | seq_puts(seq, "on\n"); | 500 | seq_puts(seq, "on\n"); |
516 | break; | 501 | break; |
@@ -591,7 +576,7 @@ static int acpi_power_remove_fs(struct acpi_device *device) | |||
591 | 576 | ||
592 | static int acpi_power_add(struct acpi_device *device) | 577 | static int acpi_power_add(struct acpi_device *device) |
593 | { | 578 | { |
594 | int result = 0; | 579 | int result = 0, state; |
595 | acpi_status status = AE_OK; | 580 | acpi_status status = AE_OK; |
596 | struct acpi_power_resource *resource = NULL; | 581 | struct acpi_power_resource *resource = NULL; |
597 | union acpi_object acpi_object; | 582 | union acpi_object acpi_object; |
@@ -622,11 +607,11 @@ static int acpi_power_add(struct acpi_device *device) | |||
622 | resource->system_level = acpi_object.power_resource.system_level; | 607 | resource->system_level = acpi_object.power_resource.system_level; |
623 | resource->order = acpi_object.power_resource.resource_order; | 608 | resource->order = acpi_object.power_resource.resource_order; |
624 | 609 | ||
625 | result = acpi_power_get_state(resource); | 610 | result = acpi_power_get_state(resource, &state); |
626 | if (result) | 611 | if (result) |
627 | goto end; | 612 | goto end; |
628 | 613 | ||
629 | switch (resource->state) { | 614 | switch (state) { |
630 | case ACPI_POWER_RESOURCE_STATE_ON: | 615 | case ACPI_POWER_RESOURCE_STATE_ON: |
631 | device->power.state = ACPI_STATE_D0; | 616 | device->power.state = ACPI_STATE_D0; |
632 | break; | 617 | break; |
@@ -643,7 +628,7 @@ static int acpi_power_add(struct acpi_device *device) | |||
643 | goto end; | 628 | goto end; |
644 | 629 | ||
645 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), | 630 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), |
646 | acpi_device_bid(device), resource->state ? "on" : "off"); | 631 | acpi_device_bid(device), state ? "on" : "off"); |
647 | 632 | ||
648 | end: | 633 | end: |
649 | if (result) | 634 | if (result) |
@@ -680,7 +665,7 @@ static int acpi_power_remove(struct acpi_device *device, int type) | |||
680 | 665 | ||
681 | static int acpi_power_resume(struct acpi_device *device) | 666 | static int acpi_power_resume(struct acpi_device *device) |
682 | { | 667 | { |
683 | int result = 0; | 668 | int result = 0, state; |
684 | struct acpi_power_resource *resource = NULL; | 669 | struct acpi_power_resource *resource = NULL; |
685 | struct acpi_power_reference *ref; | 670 | struct acpi_power_reference *ref; |
686 | 671 | ||
@@ -689,12 +674,12 @@ static int acpi_power_resume(struct acpi_device *device) | |||
689 | 674 | ||
690 | resource = (struct acpi_power_resource *)acpi_driver_data(device); | 675 | resource = (struct acpi_power_resource *)acpi_driver_data(device); |
691 | 676 | ||
692 | result = acpi_power_get_state(resource); | 677 | result = acpi_power_get_state(resource, &state); |
693 | if (result) | 678 | if (result) |
694 | return result; | 679 | return result; |
695 | 680 | ||
696 | mutex_lock(&resource->resource_lock); | 681 | mutex_lock(&resource->resource_lock); |
697 | if ((resource->state == ACPI_POWER_RESOURCE_STATE_OFF) && | 682 | if (state == ACPI_POWER_RESOURCE_STATE_OFF && |
698 | !list_empty(&resource->reference)) { | 683 | !list_empty(&resource->reference)) { |
699 | ref = container_of(resource->reference.next, struct acpi_power_reference, node); | 684 | ref = container_of(resource->reference.next, struct acpi_power_reference, node); |
700 | mutex_unlock(&resource->resource_lock); | 685 | mutex_unlock(&resource->resource_lock); |
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index f3d3867303ec..2c0b6630f8ba 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -167,8 +167,8 @@ static void acpi_pm_finish(void) | |||
167 | { | 167 | { |
168 | u32 acpi_state = acpi_target_sleep_state; | 168 | u32 acpi_state = acpi_target_sleep_state; |
169 | 169 | ||
170 | acpi_leave_sleep_state(acpi_state); | ||
171 | acpi_disable_wakeup_device(acpi_state); | 170 | acpi_disable_wakeup_device(acpi_state); |
171 | acpi_leave_sleep_state(acpi_state); | ||
172 | 172 | ||
173 | /* reset firmware waking vector */ | 173 | /* reset firmware waking vector */ |
174 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); | 174 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); |
@@ -272,8 +272,8 @@ static void acpi_hibernation_finish(void) | |||
272 | * enable it here. | 272 | * enable it here. |
273 | */ | 273 | */ |
274 | acpi_enable(); | 274 | acpi_enable(); |
275 | acpi_leave_sleep_state(ACPI_STATE_S4); | ||
276 | acpi_disable_wakeup_device(ACPI_STATE_S4); | 275 | acpi_disable_wakeup_device(ACPI_STATE_S4); |
276 | acpi_leave_sleep_state(ACPI_STATE_S4); | ||
277 | 277 | ||
278 | /* reset firmware waking vector */ | 278 | /* reset firmware waking vector */ |
279 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); | 279 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); |
@@ -410,6 +410,7 @@ static void acpi_power_off(void) | |||
410 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ | 410 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ |
411 | printk("%s called\n", __FUNCTION__); | 411 | printk("%s called\n", __FUNCTION__); |
412 | local_irq_disable(); | 412 | local_irq_disable(); |
413 | acpi_enable_wakeup_device(ACPI_STATE_S5); | ||
413 | acpi_enter_sleep_state(ACPI_STATE_S5); | 414 | acpi_enter_sleep_state(ACPI_STATE_S5); |
414 | } | 415 | } |
415 | 416 | ||
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 3839efd5eaea..1538355c266b 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c | |||
@@ -194,6 +194,23 @@ static int get_date_field(char **p, u32 * value) | |||
194 | return result; | 194 | return result; |
195 | } | 195 | } |
196 | 196 | ||
197 | /* Read a possibly BCD register, always return binary */ | ||
198 | static u32 cmos_bcd_read(int offset, int rtc_control) | ||
199 | { | ||
200 | u32 val = CMOS_READ(offset); | ||
201 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) | ||
202 | BCD_TO_BIN(val); | ||
203 | return val; | ||
204 | } | ||
205 | |||
206 | /* Write binary value into possibly BCD register */ | ||
207 | static void cmos_bcd_write(u32 val, int offset, int rtc_control) | ||
208 | { | ||
209 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) | ||
210 | BIN_TO_BCD(val); | ||
211 | CMOS_WRITE(val, offset); | ||
212 | } | ||
213 | |||
197 | static ssize_t | 214 | static ssize_t |
198 | acpi_system_write_alarm(struct file *file, | 215 | acpi_system_write_alarm(struct file *file, |
199 | const char __user * buffer, size_t count, loff_t * ppos) | 216 | const char __user * buffer, size_t count, loff_t * ppos) |
@@ -258,35 +275,18 @@ acpi_system_write_alarm(struct file *file, | |||
258 | spin_lock_irq(&rtc_lock); | 275 | spin_lock_irq(&rtc_lock); |
259 | 276 | ||
260 | rtc_control = CMOS_READ(RTC_CONTROL); | 277 | rtc_control = CMOS_READ(RTC_CONTROL); |
261 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
262 | BIN_TO_BCD(yr); | ||
263 | BIN_TO_BCD(mo); | ||
264 | BIN_TO_BCD(day); | ||
265 | BIN_TO_BCD(hr); | ||
266 | BIN_TO_BCD(min); | ||
267 | BIN_TO_BCD(sec); | ||
268 | } | ||
269 | 278 | ||
270 | if (adjust) { | 279 | if (adjust) { |
271 | yr += CMOS_READ(RTC_YEAR); | 280 | yr += cmos_bcd_read(RTC_YEAR, rtc_control); |
272 | mo += CMOS_READ(RTC_MONTH); | 281 | mo += cmos_bcd_read(RTC_MONTH, rtc_control); |
273 | day += CMOS_READ(RTC_DAY_OF_MONTH); | 282 | day += cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control); |
274 | hr += CMOS_READ(RTC_HOURS); | 283 | hr += cmos_bcd_read(RTC_HOURS, rtc_control); |
275 | min += CMOS_READ(RTC_MINUTES); | 284 | min += cmos_bcd_read(RTC_MINUTES, rtc_control); |
276 | sec += CMOS_READ(RTC_SECONDS); | 285 | sec += cmos_bcd_read(RTC_SECONDS, rtc_control); |
277 | } | 286 | } |
278 | 287 | ||
279 | spin_unlock_irq(&rtc_lock); | 288 | spin_unlock_irq(&rtc_lock); |
280 | 289 | ||
281 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
282 | BCD_TO_BIN(yr); | ||
283 | BCD_TO_BIN(mo); | ||
284 | BCD_TO_BIN(day); | ||
285 | BCD_TO_BIN(hr); | ||
286 | BCD_TO_BIN(min); | ||
287 | BCD_TO_BIN(sec); | ||
288 | } | ||
289 | |||
290 | if (sec > 59) { | 290 | if (sec > 59) { |
291 | min++; | 291 | min++; |
292 | sec -= 60; | 292 | sec -= 60; |
@@ -307,14 +307,6 @@ acpi_system_write_alarm(struct file *file, | |||
307 | yr++; | 307 | yr++; |
308 | mo -= 12; | 308 | mo -= 12; |
309 | } | 309 | } |
310 | if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
311 | BIN_TO_BCD(yr); | ||
312 | BIN_TO_BCD(mo); | ||
313 | BIN_TO_BCD(day); | ||
314 | BIN_TO_BCD(hr); | ||
315 | BIN_TO_BCD(min); | ||
316 | BIN_TO_BCD(sec); | ||
317 | } | ||
318 | 310 | ||
319 | spin_lock_irq(&rtc_lock); | 311 | spin_lock_irq(&rtc_lock); |
320 | /* | 312 | /* |
@@ -326,9 +318,9 @@ acpi_system_write_alarm(struct file *file, | |||
326 | CMOS_READ(RTC_INTR_FLAGS); | 318 | CMOS_READ(RTC_INTR_FLAGS); |
327 | 319 | ||
328 | /* write the fields the rtc knows about */ | 320 | /* write the fields the rtc knows about */ |
329 | CMOS_WRITE(hr, RTC_HOURS_ALARM); | 321 | cmos_bcd_write(hr, RTC_HOURS_ALARM, rtc_control); |
330 | CMOS_WRITE(min, RTC_MINUTES_ALARM); | 322 | cmos_bcd_write(min, RTC_MINUTES_ALARM, rtc_control); |
331 | CMOS_WRITE(sec, RTC_SECONDS_ALARM); | 323 | cmos_bcd_write(sec, RTC_SECONDS_ALARM, rtc_control); |
332 | 324 | ||
333 | /* | 325 | /* |
334 | * If the system supports an enhanced alarm it will have non-zero | 326 | * If the system supports an enhanced alarm it will have non-zero |
@@ -336,11 +328,11 @@ acpi_system_write_alarm(struct file *file, | |||
336 | * to the RTC area of memory. | 328 | * to the RTC area of memory. |
337 | */ | 329 | */ |
338 | if (acpi_gbl_FADT.day_alarm) | 330 | if (acpi_gbl_FADT.day_alarm) |
339 | CMOS_WRITE(day, acpi_gbl_FADT.day_alarm); | 331 | cmos_bcd_write(day, acpi_gbl_FADT.day_alarm, rtc_control); |
340 | if (acpi_gbl_FADT.month_alarm) | 332 | if (acpi_gbl_FADT.month_alarm) |
341 | CMOS_WRITE(mo, acpi_gbl_FADT.month_alarm); | 333 | cmos_bcd_write(mo, acpi_gbl_FADT.month_alarm, rtc_control); |
342 | if (acpi_gbl_FADT.century) | 334 | if (acpi_gbl_FADT.century) |
343 | CMOS_WRITE(yr / 100, acpi_gbl_FADT.century); | 335 | cmos_bcd_write(yr / 100, acpi_gbl_FADT.century, rtc_control); |
344 | /* enable the rtc alarm interrupt */ | 336 | /* enable the rtc alarm interrupt */ |
345 | rtc_control |= RTC_AIE; | 337 | rtc_control |= RTC_AIE; |
346 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 338 | CMOS_WRITE(rtc_control, RTC_CONTROL); |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 95229e77bffe..ed9b407e42d4 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
44 | #include <linux/dmi.h> | ||
44 | #include <scsi/scsi_host.h> | 45 | #include <scsi/scsi_host.h> |
45 | #include <scsi/scsi_cmnd.h> | 46 | #include <scsi/scsi_cmnd.h> |
46 | #include <linux/libata.h> | 47 | #include <linux/libata.h> |
@@ -48,6 +49,9 @@ | |||
48 | #define DRV_NAME "ahci" | 49 | #define DRV_NAME "ahci" |
49 | #define DRV_VERSION "3.0" | 50 | #define DRV_VERSION "3.0" |
50 | 51 | ||
52 | static int ahci_enable_alpm(struct ata_port *ap, | ||
53 | enum link_pm policy); | ||
54 | static void ahci_disable_alpm(struct ata_port *ap); | ||
51 | 55 | ||
52 | enum { | 56 | enum { |
53 | AHCI_PCI_BAR = 5, | 57 | AHCI_PCI_BAR = 5, |
@@ -98,6 +102,7 @@ enum { | |||
98 | HOST_CAP_SSC = (1 << 14), /* Slumber capable */ | 102 | HOST_CAP_SSC = (1 << 14), /* Slumber capable */ |
99 | HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */ | 103 | HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */ |
100 | HOST_CAP_CLO = (1 << 24), /* Command List Override support */ | 104 | HOST_CAP_CLO = (1 << 24), /* Command List Override support */ |
105 | HOST_CAP_ALPM = (1 << 26), /* Aggressive Link PM support */ | ||
101 | HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */ | 106 | HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */ |
102 | HOST_CAP_SNTF = (1 << 29), /* SNotification register */ | 107 | HOST_CAP_SNTF = (1 << 29), /* SNotification register */ |
103 | HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */ | 108 | HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */ |
@@ -154,6 +159,8 @@ enum { | |||
154 | PORT_IRQ_PIOS_FIS | PORT_IRQ_D2H_REG_FIS, | 159 | PORT_IRQ_PIOS_FIS | PORT_IRQ_D2H_REG_FIS, |
155 | 160 | ||
156 | /* PORT_CMD bits */ | 161 | /* PORT_CMD bits */ |
162 | PORT_CMD_ASP = (1 << 27), /* Aggressive Slumber/Partial */ | ||
163 | PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */ | ||
157 | PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */ | 164 | PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */ |
158 | PORT_CMD_PMP = (1 << 17), /* PMP attached */ | 165 | PORT_CMD_PMP = (1 << 17), /* PMP attached */ |
159 | PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ | 166 | PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ |
@@ -177,13 +184,14 @@ enum { | |||
177 | AHCI_HFLAG_MV_PATA = (1 << 4), /* PATA port */ | 184 | AHCI_HFLAG_MV_PATA = (1 << 4), /* PATA port */ |
178 | AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */ | 185 | AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */ |
179 | AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */ | 186 | AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */ |
187 | AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */ | ||
180 | 188 | ||
181 | /* ap->flags bits */ | 189 | /* ap->flags bits */ |
182 | AHCI_FLAG_NO_HOTPLUG = (1 << 24), /* ignore PxSERR.DIAG.N */ | ||
183 | 190 | ||
184 | AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 191 | AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
185 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | | 192 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | |
186 | ATA_FLAG_ACPI_SATA | ATA_FLAG_AN, | 193 | ATA_FLAG_ACPI_SATA | ATA_FLAG_AN | |
194 | ATA_FLAG_IPM, | ||
187 | AHCI_LFLAG_COMMON = ATA_LFLAG_SKIP_D2H_BSY, | 195 | AHCI_LFLAG_COMMON = ATA_LFLAG_SKIP_D2H_BSY, |
188 | }; | 196 | }; |
189 | 197 | ||
@@ -241,6 +249,7 @@ static void ahci_pmp_attach(struct ata_port *ap); | |||
241 | static void ahci_pmp_detach(struct ata_port *ap); | 249 | static void ahci_pmp_detach(struct ata_port *ap); |
242 | static void ahci_error_handler(struct ata_port *ap); | 250 | static void ahci_error_handler(struct ata_port *ap); |
243 | static void ahci_vt8251_error_handler(struct ata_port *ap); | 251 | static void ahci_vt8251_error_handler(struct ata_port *ap); |
252 | static void ahci_p5wdh_error_handler(struct ata_port *ap); | ||
244 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); | 253 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); |
245 | static int ahci_port_resume(struct ata_port *ap); | 254 | static int ahci_port_resume(struct ata_port *ap); |
246 | static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl); | 255 | static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl); |
@@ -252,6 +261,11 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | |||
252 | static int ahci_pci_device_resume(struct pci_dev *pdev); | 261 | static int ahci_pci_device_resume(struct pci_dev *pdev); |
253 | #endif | 262 | #endif |
254 | 263 | ||
264 | static struct class_device_attribute *ahci_shost_attrs[] = { | ||
265 | &class_device_attr_link_power_management_policy, | ||
266 | NULL | ||
267 | }; | ||
268 | |||
255 | static struct scsi_host_template ahci_sht = { | 269 | static struct scsi_host_template ahci_sht = { |
256 | .module = THIS_MODULE, | 270 | .module = THIS_MODULE, |
257 | .name = DRV_NAME, | 271 | .name = DRV_NAME, |
@@ -269,6 +283,7 @@ static struct scsi_host_template ahci_sht = { | |||
269 | .slave_configure = ata_scsi_slave_config, | 283 | .slave_configure = ata_scsi_slave_config, |
270 | .slave_destroy = ata_scsi_slave_destroy, | 284 | .slave_destroy = ata_scsi_slave_destroy, |
271 | .bios_param = ata_std_bios_param, | 285 | .bios_param = ata_std_bios_param, |
286 | .shost_attrs = ahci_shost_attrs, | ||
272 | }; | 287 | }; |
273 | 288 | ||
274 | static const struct ata_port_operations ahci_ops = { | 289 | static const struct ata_port_operations ahci_ops = { |
@@ -300,6 +315,8 @@ static const struct ata_port_operations ahci_ops = { | |||
300 | .port_suspend = ahci_port_suspend, | 315 | .port_suspend = ahci_port_suspend, |
301 | .port_resume = ahci_port_resume, | 316 | .port_resume = ahci_port_resume, |
302 | #endif | 317 | #endif |
318 | .enable_pm = ahci_enable_alpm, | ||
319 | .disable_pm = ahci_disable_alpm, | ||
303 | 320 | ||
304 | .port_start = ahci_port_start, | 321 | .port_start = ahci_port_start, |
305 | .port_stop = ahci_port_stop, | 322 | .port_stop = ahci_port_stop, |
@@ -339,6 +356,40 @@ static const struct ata_port_operations ahci_vt8251_ops = { | |||
339 | .port_stop = ahci_port_stop, | 356 | .port_stop = ahci_port_stop, |
340 | }; | 357 | }; |
341 | 358 | ||
359 | static const struct ata_port_operations ahci_p5wdh_ops = { | ||
360 | .check_status = ahci_check_status, | ||
361 | .check_altstatus = ahci_check_status, | ||
362 | .dev_select = ata_noop_dev_select, | ||
363 | |||
364 | .tf_read = ahci_tf_read, | ||
365 | |||
366 | .qc_defer = sata_pmp_qc_defer_cmd_switch, | ||
367 | .qc_prep = ahci_qc_prep, | ||
368 | .qc_issue = ahci_qc_issue, | ||
369 | |||
370 | .irq_clear = ahci_irq_clear, | ||
371 | |||
372 | .scr_read = ahci_scr_read, | ||
373 | .scr_write = ahci_scr_write, | ||
374 | |||
375 | .freeze = ahci_freeze, | ||
376 | .thaw = ahci_thaw, | ||
377 | |||
378 | .error_handler = ahci_p5wdh_error_handler, | ||
379 | .post_internal_cmd = ahci_post_internal_cmd, | ||
380 | |||
381 | .pmp_attach = ahci_pmp_attach, | ||
382 | .pmp_detach = ahci_pmp_detach, | ||
383 | |||
384 | #ifdef CONFIG_PM | ||
385 | .port_suspend = ahci_port_suspend, | ||
386 | .port_resume = ahci_port_resume, | ||
387 | #endif | ||
388 | |||
389 | .port_start = ahci_port_start, | ||
390 | .port_stop = ahci_port_stop, | ||
391 | }; | ||
392 | |||
342 | #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) | 393 | #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) |
343 | 394 | ||
344 | static const struct ata_port_info ahci_port_info[] = { | 395 | static const struct ata_port_info ahci_port_info[] = { |
@@ -800,6 +851,130 @@ static void ahci_power_up(struct ata_port *ap) | |||
800 | writel(cmd | PORT_CMD_ICC_ACTIVE, port_mmio + PORT_CMD); | 851 | writel(cmd | PORT_CMD_ICC_ACTIVE, port_mmio + PORT_CMD); |
801 | } | 852 | } |
802 | 853 | ||
854 | static void ahci_disable_alpm(struct ata_port *ap) | ||
855 | { | ||
856 | struct ahci_host_priv *hpriv = ap->host->private_data; | ||
857 | void __iomem *port_mmio = ahci_port_base(ap); | ||
858 | u32 cmd; | ||
859 | struct ahci_port_priv *pp = ap->private_data; | ||
860 | |||
861 | /* IPM bits should be disabled by libata-core */ | ||
862 | /* get the existing command bits */ | ||
863 | cmd = readl(port_mmio + PORT_CMD); | ||
864 | |||
865 | /* disable ALPM and ASP */ | ||
866 | cmd &= ~PORT_CMD_ASP; | ||
867 | cmd &= ~PORT_CMD_ALPE; | ||
868 | |||
869 | /* force the interface back to active */ | ||
870 | cmd |= PORT_CMD_ICC_ACTIVE; | ||
871 | |||
872 | /* write out new cmd value */ | ||
873 | writel(cmd, port_mmio + PORT_CMD); | ||
874 | cmd = readl(port_mmio + PORT_CMD); | ||
875 | |||
876 | /* wait 10ms to be sure we've come out of any low power state */ | ||
877 | msleep(10); | ||
878 | |||
879 | /* clear out any PhyRdy stuff from interrupt status */ | ||
880 | writel(PORT_IRQ_PHYRDY, port_mmio + PORT_IRQ_STAT); | ||
881 | |||
882 | /* go ahead and clean out PhyRdy Change from Serror too */ | ||
883 | ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18))); | ||
884 | |||
885 | /* | ||
886 | * Clear flag to indicate that we should ignore all PhyRdy | ||
887 | * state changes | ||
888 | */ | ||
889 | hpriv->flags &= ~AHCI_HFLAG_NO_HOTPLUG; | ||
890 | |||
891 | /* | ||
892 | * Enable interrupts on Phy Ready. | ||
893 | */ | ||
894 | pp->intr_mask |= PORT_IRQ_PHYRDY; | ||
895 | writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); | ||
896 | |||
897 | /* | ||
898 | * don't change the link pm policy - we can be called | ||
899 | * just to turn of link pm temporarily | ||
900 | */ | ||
901 | } | ||
902 | |||
903 | static int ahci_enable_alpm(struct ata_port *ap, | ||
904 | enum link_pm policy) | ||
905 | { | ||
906 | struct ahci_host_priv *hpriv = ap->host->private_data; | ||
907 | void __iomem *port_mmio = ahci_port_base(ap); | ||
908 | u32 cmd; | ||
909 | struct ahci_port_priv *pp = ap->private_data; | ||
910 | u32 asp; | ||
911 | |||
912 | /* Make sure the host is capable of link power management */ | ||
913 | if (!(hpriv->cap & HOST_CAP_ALPM)) | ||
914 | return -EINVAL; | ||
915 | |||
916 | switch (policy) { | ||
917 | case MAX_PERFORMANCE: | ||
918 | case NOT_AVAILABLE: | ||
919 | /* | ||
920 | * if we came here with NOT_AVAILABLE, | ||
921 | * it just means this is the first time we | ||
922 | * have tried to enable - default to max performance, | ||
923 | * and let the user go to lower power modes on request. | ||
924 | */ | ||
925 | ahci_disable_alpm(ap); | ||
926 | return 0; | ||
927 | case MIN_POWER: | ||
928 | /* configure HBA to enter SLUMBER */ | ||
929 | asp = PORT_CMD_ASP; | ||
930 | break; | ||
931 | case MEDIUM_POWER: | ||
932 | /* configure HBA to enter PARTIAL */ | ||
933 | asp = 0; | ||
934 | break; | ||
935 | default: | ||
936 | return -EINVAL; | ||
937 | } | ||
938 | |||
939 | /* | ||
940 | * Disable interrupts on Phy Ready. This keeps us from | ||
941 | * getting woken up due to spurious phy ready interrupts | ||
942 | * TBD - Hot plug should be done via polling now, is | ||
943 | * that even supported? | ||
944 | */ | ||
945 | pp->intr_mask &= ~PORT_IRQ_PHYRDY; | ||
946 | writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); | ||
947 | |||
948 | /* | ||
949 | * Set a flag to indicate that we should ignore all PhyRdy | ||
950 | * state changes since these can happen now whenever we | ||
951 | * change link state | ||
952 | */ | ||
953 | hpriv->flags |= AHCI_HFLAG_NO_HOTPLUG; | ||
954 | |||
955 | /* get the existing command bits */ | ||
956 | cmd = readl(port_mmio + PORT_CMD); | ||
957 | |||
958 | /* | ||
959 | * Set ASP based on Policy | ||
960 | */ | ||
961 | cmd |= asp; | ||
962 | |||
963 | /* | ||
964 | * Setting this bit will instruct the HBA to aggressively | ||
965 | * enter a lower power link state when it's appropriate and | ||
966 | * based on the value set above for ASP | ||
967 | */ | ||
968 | cmd |= PORT_CMD_ALPE; | ||
969 | |||
970 | /* write out new cmd value */ | ||
971 | writel(cmd, port_mmio + PORT_CMD); | ||
972 | cmd = readl(port_mmio + PORT_CMD); | ||
973 | |||
974 | /* IPM bits should be set by libata-core */ | ||
975 | return 0; | ||
976 | } | ||
977 | |||
803 | #ifdef CONFIG_PM | 978 | #ifdef CONFIG_PM |
804 | static void ahci_power_down(struct ata_port *ap) | 979 | static void ahci_power_down(struct ata_port *ap) |
805 | { | 980 | { |
@@ -862,8 +1037,10 @@ static int ahci_reset_controller(struct ata_host *host) | |||
862 | * AHCI-specific, such as HOST_RESET. | 1037 | * AHCI-specific, such as HOST_RESET. |
863 | */ | 1038 | */ |
864 | tmp = readl(mmio + HOST_CTL); | 1039 | tmp = readl(mmio + HOST_CTL); |
865 | if (!(tmp & HOST_AHCI_EN)) | 1040 | if (!(tmp & HOST_AHCI_EN)) { |
866 | writel(tmp | HOST_AHCI_EN, mmio + HOST_CTL); | 1041 | tmp |= HOST_AHCI_EN; |
1042 | writel(tmp, mmio + HOST_CTL); | ||
1043 | } | ||
867 | 1044 | ||
868 | /* global controller reset */ | 1045 | /* global controller reset */ |
869 | if ((tmp & HOST_RESET) == 0) { | 1046 | if ((tmp & HOST_RESET) == 0) { |
@@ -1117,15 +1294,8 @@ static int ahci_do_softreset(struct ata_link *link, unsigned int *class, | |||
1117 | tf.ctl &= ~ATA_SRST; | 1294 | tf.ctl &= ~ATA_SRST; |
1118 | ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0); | 1295 | ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0); |
1119 | 1296 | ||
1120 | /* spec mandates ">= 2ms" before checking status. | 1297 | /* wait a while before checking status */ |
1121 | * We wait 150ms, because that was the magic delay used for | 1298 | ata_wait_after_reset(ap, deadline); |
1122 | * ATAPI devices in Hale Landis's ATADRVR, for the period of time | ||
1123 | * between when the ATA command register is written, and then | ||
1124 | * status is checked. Because waiting for "a while" before | ||
1125 | * checking status is fine, post SRST, we perform this magic | ||
1126 | * delay here as well. | ||
1127 | */ | ||
1128 | msleep(150); | ||
1129 | 1299 | ||
1130 | rc = ata_wait_ready(ap, deadline); | 1300 | rc = ata_wait_ready(ap, deadline); |
1131 | /* link occupied, -ENODEV too is an error */ | 1301 | /* link occupied, -ENODEV too is an error */ |
@@ -1213,6 +1383,53 @@ static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, | |||
1213 | return rc ?: -EAGAIN; | 1383 | return rc ?: -EAGAIN; |
1214 | } | 1384 | } |
1215 | 1385 | ||
1386 | static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class, | ||
1387 | unsigned long deadline) | ||
1388 | { | ||
1389 | struct ata_port *ap = link->ap; | ||
1390 | struct ahci_port_priv *pp = ap->private_data; | ||
1391 | u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; | ||
1392 | struct ata_taskfile tf; | ||
1393 | int rc; | ||
1394 | |||
1395 | ahci_stop_engine(ap); | ||
1396 | |||
1397 | /* clear D2H reception area to properly wait for D2H FIS */ | ||
1398 | ata_tf_init(link->device, &tf); | ||
1399 | tf.command = 0x80; | ||
1400 | ata_tf_to_fis(&tf, 0, 0, d2h_fis); | ||
1401 | |||
1402 | rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context), | ||
1403 | deadline); | ||
1404 | |||
1405 | ahci_start_engine(ap); | ||
1406 | |||
1407 | if (rc || ata_link_offline(link)) | ||
1408 | return rc; | ||
1409 | |||
1410 | /* spec mandates ">= 2ms" before checking status */ | ||
1411 | msleep(150); | ||
1412 | |||
1413 | /* The pseudo configuration device on SIMG4726 attached to | ||
1414 | * ASUS P5W-DH Deluxe doesn't send signature FIS after | ||
1415 | * hardreset if no device is attached to the first downstream | ||
1416 | * port && the pseudo device locks up on SRST w/ PMP==0. To | ||
1417 | * work around this, wait for !BSY only briefly. If BSY isn't | ||
1418 | * cleared, perform CLO and proceed to IDENTIFY (achieved by | ||
1419 | * ATA_LFLAG_NO_SRST and ATA_LFLAG_ASSUME_ATA). | ||
1420 | * | ||
1421 | * Wait for two seconds. Devices attached to downstream port | ||
1422 | * which can't process the following IDENTIFY after this will | ||
1423 | * have to be reset again. For most cases, this should | ||
1424 | * suffice while making probing snappish enough. | ||
1425 | */ | ||
1426 | rc = ata_wait_ready(ap, jiffies + 2 * HZ); | ||
1427 | if (rc) | ||
1428 | ahci_kick_engine(ap, 0); | ||
1429 | |||
1430 | return 0; | ||
1431 | } | ||
1432 | |||
1216 | static void ahci_postreset(struct ata_link *link, unsigned int *class) | 1433 | static void ahci_postreset(struct ata_link *link, unsigned int *class) |
1217 | { | 1434 | { |
1218 | struct ata_port *ap = link->ap; | 1435 | struct ata_port *ap = link->ap; |
@@ -1426,6 +1643,17 @@ static void ahci_port_intr(struct ata_port *ap) | |||
1426 | if (unlikely(resetting)) | 1643 | if (unlikely(resetting)) |
1427 | status &= ~PORT_IRQ_BAD_PMP; | 1644 | status &= ~PORT_IRQ_BAD_PMP; |
1428 | 1645 | ||
1646 | /* If we are getting PhyRdy, this is | ||
1647 | * just a power state change, we should | ||
1648 | * clear out this, plus the PhyRdy/Comm | ||
1649 | * Wake bits from Serror | ||
1650 | */ | ||
1651 | if ((hpriv->flags & AHCI_HFLAG_NO_HOTPLUG) && | ||
1652 | (status & PORT_IRQ_PHYRDY)) { | ||
1653 | status &= ~PORT_IRQ_PHYRDY; | ||
1654 | ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18))); | ||
1655 | } | ||
1656 | |||
1429 | if (unlikely(status & PORT_IRQ_ERROR)) { | 1657 | if (unlikely(status & PORT_IRQ_ERROR)) { |
1430 | ahci_error_intr(ap, status); | 1658 | ahci_error_intr(ap, status); |
1431 | return; | 1659 | return; |
@@ -1670,6 +1898,19 @@ static void ahci_vt8251_error_handler(struct ata_port *ap) | |||
1670 | ahci_postreset); | 1898 | ahci_postreset); |
1671 | } | 1899 | } |
1672 | 1900 | ||
1901 | static void ahci_p5wdh_error_handler(struct ata_port *ap) | ||
1902 | { | ||
1903 | if (!(ap->pflags & ATA_PFLAG_FROZEN)) { | ||
1904 | /* restart engine */ | ||
1905 | ahci_stop_engine(ap); | ||
1906 | ahci_start_engine(ap); | ||
1907 | } | ||
1908 | |||
1909 | /* perform recovery */ | ||
1910 | ata_do_eh(ap, ata_std_prereset, ahci_softreset, ahci_p5wdh_hardreset, | ||
1911 | ahci_postreset); | ||
1912 | } | ||
1913 | |||
1673 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc) | 1914 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc) |
1674 | { | 1915 | { |
1675 | struct ata_port *ap = qc->ap; | 1916 | struct ata_port *ap = qc->ap; |
@@ -1955,6 +2196,51 @@ static void ahci_print_info(struct ata_host *host) | |||
1955 | ); | 2196 | ); |
1956 | } | 2197 | } |
1957 | 2198 | ||
2199 | /* On ASUS P5W DH Deluxe, the second port of PCI device 00:1f.2 is | ||
2200 | * hardwired to on-board SIMG 4726. The chipset is ICH8 and doesn't | ||
2201 | * support PMP and the 4726 either directly exports the device | ||
2202 | * attached to the first downstream port or acts as a hardware storage | ||
2203 | * controller and emulate a single ATA device (can be RAID 0/1 or some | ||
2204 | * other configuration). | ||
2205 | * | ||
2206 | * When there's no device attached to the first downstream port of the | ||
2207 | * 4726, "Config Disk" appears, which is a pseudo ATA device to | ||
2208 | * configure the 4726. However, ATA emulation of the device is very | ||
2209 | * lame. It doesn't send signature D2H Reg FIS after the initial | ||
2210 | * hardreset, pukes on SRST w/ PMP==0 and has bunch of other issues. | ||
2211 | * | ||
2212 | * The following function works around the problem by always using | ||
2213 | * hardreset on the port and not depending on receiving signature FIS | ||
2214 | * afterward. If signature FIS isn't received soon, ATA class is | ||
2215 | * assumed without follow-up softreset. | ||
2216 | */ | ||
2217 | static void ahci_p5wdh_workaround(struct ata_host *host) | ||
2218 | { | ||
2219 | static struct dmi_system_id sysids[] = { | ||
2220 | { | ||
2221 | .ident = "P5W DH Deluxe", | ||
2222 | .matches = { | ||
2223 | DMI_MATCH(DMI_SYS_VENDOR, | ||
2224 | "ASUSTEK COMPUTER INC"), | ||
2225 | DMI_MATCH(DMI_PRODUCT_NAME, "P5W DH Deluxe"), | ||
2226 | }, | ||
2227 | }, | ||
2228 | { } | ||
2229 | }; | ||
2230 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
2231 | |||
2232 | if (pdev->bus->number == 0 && pdev->devfn == PCI_DEVFN(0x1f, 2) && | ||
2233 | dmi_check_system(sysids)) { | ||
2234 | struct ata_port *ap = host->ports[1]; | ||
2235 | |||
2236 | dev_printk(KERN_INFO, &pdev->dev, "enabling ASUS P5W DH " | ||
2237 | "Deluxe on-board SIMG4726 workaround\n"); | ||
2238 | |||
2239 | ap->ops = &ahci_p5wdh_ops; | ||
2240 | ap->link.flags |= ATA_LFLAG_NO_SRST | ATA_LFLAG_ASSUME_ATA; | ||
2241 | } | ||
2242 | } | ||
2243 | |||
1958 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 2244 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
1959 | { | 2245 | { |
1960 | static int printed_version; | 2246 | static int printed_version; |
@@ -2015,6 +2301,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2015 | ata_port_pbar_desc(ap, AHCI_PCI_BAR, | 2301 | ata_port_pbar_desc(ap, AHCI_PCI_BAR, |
2016 | 0x100 + ap->port_no * 0x80, "port"); | 2302 | 0x100 + ap->port_no * 0x80, "port"); |
2017 | 2303 | ||
2304 | /* set initial link pm policy */ | ||
2305 | ap->pm_policy = NOT_AVAILABLE; | ||
2306 | |||
2018 | /* standard SATA port setup */ | 2307 | /* standard SATA port setup */ |
2019 | if (hpriv->port_map & (1 << i)) | 2308 | if (hpriv->port_map & (1 << i)) |
2020 | ap->ioaddr.cmd_addr = port_mmio; | 2309 | ap->ioaddr.cmd_addr = port_mmio; |
@@ -2024,6 +2313,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2024 | ap->ops = &ata_dummy_port_ops; | 2313 | ap->ops = &ata_dummy_port_ops; |
2025 | } | 2314 | } |
2026 | 2315 | ||
2316 | /* apply workaround for ASUS P5W DH Deluxe mainboard */ | ||
2317 | ahci_p5wdh_workaround(host); | ||
2318 | |||
2027 | /* initialize adapter */ | 2319 | /* initialize adapter */ |
2028 | rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64); | 2320 | rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64); |
2029 | if (rc) | 2321 | if (rc) |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 2d147b51c978..63035d71a61a 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -68,7 +68,8 @@ const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 }; | |||
68 | static unsigned int ata_dev_init_params(struct ata_device *dev, | 68 | static unsigned int ata_dev_init_params(struct ata_device *dev, |
69 | u16 heads, u16 sectors); | 69 | u16 heads, u16 sectors); |
70 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev); | 70 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev); |
71 | static unsigned int ata_dev_set_AN(struct ata_device *dev, u8 enable); | 71 | static unsigned int ata_dev_set_feature(struct ata_device *dev, |
72 | u8 enable, u8 feature); | ||
72 | static void ata_dev_xfermask(struct ata_device *dev); | 73 | static void ata_dev_xfermask(struct ata_device *dev); |
73 | static unsigned long ata_dev_blacklisted(const struct ata_device *dev); | 74 | static unsigned long ata_dev_blacklisted(const struct ata_device *dev); |
74 | 75 | ||
@@ -619,6 +620,177 @@ void ata_dev_disable(struct ata_device *dev) | |||
619 | } | 620 | } |
620 | } | 621 | } |
621 | 622 | ||
623 | static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy) | ||
624 | { | ||
625 | struct ata_link *link = dev->link; | ||
626 | struct ata_port *ap = link->ap; | ||
627 | u32 scontrol; | ||
628 | unsigned int err_mask; | ||
629 | int rc; | ||
630 | |||
631 | /* | ||
632 | * disallow DIPM for drivers which haven't set | ||
633 | * ATA_FLAG_IPM. This is because when DIPM is enabled, | ||
634 | * phy ready will be set in the interrupt status on | ||
635 | * state changes, which will cause some drivers to | ||
636 | * think there are errors - additionally drivers will | ||
637 | * need to disable hot plug. | ||
638 | */ | ||
639 | if (!(ap->flags & ATA_FLAG_IPM) || !ata_dev_enabled(dev)) { | ||
640 | ap->pm_policy = NOT_AVAILABLE; | ||
641 | return -EINVAL; | ||
642 | } | ||
643 | |||
644 | /* | ||
645 | * For DIPM, we will only enable it for the | ||
646 | * min_power setting. | ||
647 | * | ||
648 | * Why? Because Disks are too stupid to know that | ||
649 | * If the host rejects a request to go to SLUMBER | ||
650 | * they should retry at PARTIAL, and instead it | ||
651 | * just would give up. So, for medium_power to | ||
652 | * work at all, we need to only allow HIPM. | ||
653 | */ | ||
654 | rc = sata_scr_read(link, SCR_CONTROL, &scontrol); | ||
655 | if (rc) | ||
656 | return rc; | ||
657 | |||
658 | switch (policy) { | ||
659 | case MIN_POWER: | ||
660 | /* no restrictions on IPM transitions */ | ||
661 | scontrol &= ~(0x3 << 8); | ||
662 | rc = sata_scr_write(link, SCR_CONTROL, scontrol); | ||
663 | if (rc) | ||
664 | return rc; | ||
665 | |||
666 | /* enable DIPM */ | ||
667 | if (dev->flags & ATA_DFLAG_DIPM) | ||
668 | err_mask = ata_dev_set_feature(dev, | ||
669 | SETFEATURES_SATA_ENABLE, SATA_DIPM); | ||
670 | break; | ||
671 | case MEDIUM_POWER: | ||
672 | /* allow IPM to PARTIAL */ | ||
673 | scontrol &= ~(0x1 << 8); | ||
674 | scontrol |= (0x2 << 8); | ||
675 | rc = sata_scr_write(link, SCR_CONTROL, scontrol); | ||
676 | if (rc) | ||
677 | return rc; | ||
678 | |||
679 | /* disable DIPM */ | ||
680 | if (ata_dev_enabled(dev) && (dev->flags & ATA_DFLAG_DIPM)) | ||
681 | err_mask = ata_dev_set_feature(dev, | ||
682 | SETFEATURES_SATA_DISABLE, SATA_DIPM); | ||
683 | break; | ||
684 | case NOT_AVAILABLE: | ||
685 | case MAX_PERFORMANCE: | ||
686 | /* disable all IPM transitions */ | ||
687 | scontrol |= (0x3 << 8); | ||
688 | rc = sata_scr_write(link, SCR_CONTROL, scontrol); | ||
689 | if (rc) | ||
690 | return rc; | ||
691 | |||
692 | /* disable DIPM */ | ||
693 | if (ata_dev_enabled(dev) && (dev->flags & ATA_DFLAG_DIPM)) | ||
694 | err_mask = ata_dev_set_feature(dev, | ||
695 | SETFEATURES_SATA_DISABLE, SATA_DIPM); | ||
696 | break; | ||
697 | } | ||
698 | |||
699 | /* FIXME: handle SET FEATURES failure */ | ||
700 | (void) err_mask; | ||
701 | |||
702 | return 0; | ||
703 | } | ||
704 | |||
705 | /** | ||
706 | * ata_dev_enable_pm - enable SATA interface power management | ||
707 | * @device - device to enable ipm for | ||
708 | * @policy - the link power management policy | ||
709 | * | ||
710 | * Enable SATA Interface power management. This will enable | ||
711 | * Device Interface Power Management (DIPM) for min_power | ||
712 | * policy, and then call driver specific callbacks for | ||
713 | * enabling Host Initiated Power management. | ||
714 | * | ||
715 | * Locking: Caller. | ||
716 | * Returns: -EINVAL if IPM is not supported, 0 otherwise. | ||
717 | */ | ||
718 | void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy) | ||
719 | { | ||
720 | int rc = 0; | ||
721 | struct ata_port *ap = dev->link->ap; | ||
722 | |||
723 | /* set HIPM first, then DIPM */ | ||
724 | if (ap->ops->enable_pm) | ||
725 | rc = ap->ops->enable_pm(ap, policy); | ||
726 | if (rc) | ||
727 | goto enable_pm_out; | ||
728 | rc = ata_dev_set_dipm(dev, policy); | ||
729 | |||
730 | enable_pm_out: | ||
731 | if (rc) | ||
732 | ap->pm_policy = MAX_PERFORMANCE; | ||
733 | else | ||
734 | ap->pm_policy = policy; | ||
735 | return /* rc */; /* hopefully we can use 'rc' eventually */ | ||
736 | } | ||
737 | |||
738 | /** | ||
739 | * ata_dev_disable_pm - disable SATA interface power management | ||
740 | * @device - device to enable ipm for | ||
741 | * | ||
742 | * Disable SATA Interface power management. This will disable | ||
743 | * Device Interface Power Management (DIPM) without changing | ||
744 | * policy, call driver specific callbacks for disabling Host | ||
745 | * Initiated Power management. | ||
746 | * | ||
747 | * Locking: Caller. | ||
748 | * Returns: void | ||
749 | */ | ||
750 | static void ata_dev_disable_pm(struct ata_device *dev) | ||
751 | { | ||
752 | struct ata_port *ap = dev->link->ap; | ||
753 | |||
754 | ata_dev_set_dipm(dev, MAX_PERFORMANCE); | ||
755 | if (ap->ops->disable_pm) | ||
756 | ap->ops->disable_pm(ap); | ||
757 | } | ||
758 | |||
759 | void ata_lpm_schedule(struct ata_port *ap, enum link_pm policy) | ||
760 | { | ||
761 | ap->pm_policy = policy; | ||
762 | ap->link.eh_info.action |= ATA_EHI_LPM; | ||
763 | ap->link.eh_info.flags |= ATA_EHI_NO_AUTOPSY; | ||
764 | ata_port_schedule_eh(ap); | ||
765 | } | ||
766 | |||
767 | static void ata_lpm_enable(struct ata_host *host) | ||
768 | { | ||
769 | struct ata_link *link; | ||
770 | struct ata_port *ap; | ||
771 | struct ata_device *dev; | ||
772 | int i; | ||
773 | |||
774 | for (i = 0; i < host->n_ports; i++) { | ||
775 | ap = host->ports[i]; | ||
776 | ata_port_for_each_link(link, ap) { | ||
777 | ata_link_for_each_dev(dev, link) | ||
778 | ata_dev_disable_pm(dev); | ||
779 | } | ||
780 | } | ||
781 | } | ||
782 | |||
783 | static void ata_lpm_disable(struct ata_host *host) | ||
784 | { | ||
785 | int i; | ||
786 | |||
787 | for (i = 0; i < host->n_ports; i++) { | ||
788 | struct ata_port *ap = host->ports[i]; | ||
789 | ata_lpm_schedule(ap, ap->pm_policy); | ||
790 | } | ||
791 | } | ||
792 | |||
793 | |||
622 | /** | 794 | /** |
623 | * ata_devchk - PATA device presence detection | 795 | * ata_devchk - PATA device presence detection |
624 | * @ap: ATA channel to examine | 796 | * @ap: ATA channel to examine |
@@ -1799,13 +1971,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1799 | * SET_FEATURES spin-up subcommand before it will accept | 1971 | * SET_FEATURES spin-up subcommand before it will accept |
1800 | * anything other than the original IDENTIFY command. | 1972 | * anything other than the original IDENTIFY command. |
1801 | */ | 1973 | */ |
1802 | ata_tf_init(dev, &tf); | 1974 | err_mask = ata_dev_set_feature(dev, SETFEATURES_SPINUP, 0); |
1803 | tf.command = ATA_CMD_SET_FEATURES; | ||
1804 | tf.feature = SETFEATURES_SPINUP; | ||
1805 | tf.protocol = ATA_PROT_NODATA; | ||
1806 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | ||
1807 | err_mask = ata_exec_internal(dev, &tf, NULL, | ||
1808 | DMA_NONE, NULL, 0, 0); | ||
1809 | if (err_mask && id[2] != 0x738c) { | 1975 | if (err_mask && id[2] != 0x738c) { |
1810 | rc = -EIO; | 1976 | rc = -EIO; |
1811 | reason = "SPINUP failed"; | 1977 | reason = "SPINUP failed"; |
@@ -2075,7 +2241,8 @@ int ata_dev_configure(struct ata_device *dev) | |||
2075 | unsigned int err_mask; | 2241 | unsigned int err_mask; |
2076 | 2242 | ||
2077 | /* issue SET feature command to turn this on */ | 2243 | /* issue SET feature command to turn this on */ |
2078 | err_mask = ata_dev_set_AN(dev, SETFEATURES_SATA_ENABLE); | 2244 | err_mask = ata_dev_set_feature(dev, |
2245 | SETFEATURES_SATA_ENABLE, SATA_AN); | ||
2079 | if (err_mask) | 2246 | if (err_mask) |
2080 | ata_dev_printk(dev, KERN_ERR, | 2247 | ata_dev_printk(dev, KERN_ERR, |
2081 | "failed to enable ATAPI AN " | 2248 | "failed to enable ATAPI AN " |
@@ -2105,6 +2272,13 @@ int ata_dev_configure(struct ata_device *dev) | |||
2105 | if (dev->flags & ATA_DFLAG_LBA48) | 2272 | if (dev->flags & ATA_DFLAG_LBA48) |
2106 | dev->max_sectors = ATA_MAX_SECTORS_LBA48; | 2273 | dev->max_sectors = ATA_MAX_SECTORS_LBA48; |
2107 | 2274 | ||
2275 | if (!(dev->horkage & ATA_HORKAGE_IPM)) { | ||
2276 | if (ata_id_has_hipm(dev->id)) | ||
2277 | dev->flags |= ATA_DFLAG_HIPM; | ||
2278 | if (ata_id_has_dipm(dev->id)) | ||
2279 | dev->flags |= ATA_DFLAG_DIPM; | ||
2280 | } | ||
2281 | |||
2108 | if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) { | 2282 | if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) { |
2109 | /* Let the user know. We don't want to disallow opens for | 2283 | /* Let the user know. We don't want to disallow opens for |
2110 | rescue purposes, or in case the vendor is just a blithering | 2284 | rescue purposes, or in case the vendor is just a blithering |
@@ -2130,6 +2304,13 @@ int ata_dev_configure(struct ata_device *dev) | |||
2130 | dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128, | 2304 | dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128, |
2131 | dev->max_sectors); | 2305 | dev->max_sectors); |
2132 | 2306 | ||
2307 | if (ata_dev_blacklisted(dev) & ATA_HORKAGE_IPM) { | ||
2308 | dev->horkage |= ATA_HORKAGE_IPM; | ||
2309 | |||
2310 | /* reset link pm_policy for this port to no pm */ | ||
2311 | ap->pm_policy = MAX_PERFORMANCE; | ||
2312 | } | ||
2313 | |||
2133 | if (ap->ops->dev_config) | 2314 | if (ap->ops->dev_config) |
2134 | ap->ops->dev_config(dev); | 2315 | ap->ops->dev_config(dev); |
2135 | 2316 | ||
@@ -2223,6 +2404,25 @@ int ata_bus_probe(struct ata_port *ap) | |||
2223 | tries[dev->devno] = ATA_PROBE_MAX_TRIES; | 2404 | tries[dev->devno] = ATA_PROBE_MAX_TRIES; |
2224 | 2405 | ||
2225 | retry: | 2406 | retry: |
2407 | ata_link_for_each_dev(dev, &ap->link) { | ||
2408 | /* If we issue an SRST then an ATA drive (not ATAPI) | ||
2409 | * may change configuration and be in PIO0 timing. If | ||
2410 | * we do a hard reset (or are coming from power on) | ||
2411 | * this is true for ATA or ATAPI. Until we've set a | ||
2412 | * suitable controller mode we should not touch the | ||
2413 | * bus as we may be talking too fast. | ||
2414 | */ | ||
2415 | dev->pio_mode = XFER_PIO_0; | ||
2416 | |||
2417 | /* If the controller has a pio mode setup function | ||
2418 | * then use it to set the chipset to rights. Don't | ||
2419 | * touch the DMA setup as that will be dealt with when | ||
2420 | * configuring devices. | ||
2421 | */ | ||
2422 | if (ap->ops->set_piomode) | ||
2423 | ap->ops->set_piomode(ap, dev); | ||
2424 | } | ||
2425 | |||
2226 | /* reset and determine device classes */ | 2426 | /* reset and determine device classes */ |
2227 | ap->ops->phy_reset(ap); | 2427 | ap->ops->phy_reset(ap); |
2228 | 2428 | ||
@@ -2238,12 +2438,6 @@ int ata_bus_probe(struct ata_port *ap) | |||
2238 | 2438 | ||
2239 | ata_port_probe(ap); | 2439 | ata_port_probe(ap); |
2240 | 2440 | ||
2241 | /* after the reset the device state is PIO 0 and the controller | ||
2242 | state is undefined. Record the mode */ | ||
2243 | |||
2244 | ata_link_for_each_dev(dev, &ap->link) | ||
2245 | dev->pio_mode = XFER_PIO_0; | ||
2246 | |||
2247 | /* read IDENTIFY page and configure devices. We have to do the identify | 2441 | /* read IDENTIFY page and configure devices. We have to do the identify |
2248 | specific sequence bass-ackwards so that PDIAG- is released by | 2442 | specific sequence bass-ackwards so that PDIAG- is released by |
2249 | the slave device */ | 2443 | the slave device */ |
@@ -2886,6 +3080,13 @@ static int ata_dev_set_mode(struct ata_device *dev) | |||
2886 | dev->pio_mode <= XFER_PIO_2) | 3080 | dev->pio_mode <= XFER_PIO_2) |
2887 | err_mask &= ~AC_ERR_DEV; | 3081 | err_mask &= ~AC_ERR_DEV; |
2888 | 3082 | ||
3083 | /* Early MWDMA devices do DMA but don't allow DMA mode setting. | ||
3084 | Don't fail an MWDMA0 set IFF the device indicates it is in MWDMA0 */ | ||
3085 | if (dev->xfer_shift == ATA_SHIFT_MWDMA && | ||
3086 | dev->dma_mode == XFER_MW_DMA_0 && | ||
3087 | (dev->id[63] >> 8) & 1) | ||
3088 | err_mask &= ~AC_ERR_DEV; | ||
3089 | |||
2889 | if (err_mask) { | 3090 | if (err_mask) { |
2890 | ata_dev_printk(dev, KERN_ERR, "failed to set xfermode " | 3091 | ata_dev_printk(dev, KERN_ERR, "failed to set xfermode " |
2891 | "(err_mask=0x%x)\n", err_mask); | 3092 | "(err_mask=0x%x)\n", err_mask); |
@@ -3115,6 +3316,55 @@ int ata_busy_sleep(struct ata_port *ap, | |||
3115 | } | 3316 | } |
3116 | 3317 | ||
3117 | /** | 3318 | /** |
3319 | * ata_wait_after_reset - wait before checking status after reset | ||
3320 | * @ap: port containing status register to be polled | ||
3321 | * @deadline: deadline jiffies for the operation | ||
3322 | * | ||
3323 | * After reset, we need to pause a while before reading status. | ||
3324 | * Also, certain combination of controller and device report 0xff | ||
3325 | * for some duration (e.g. until SATA PHY is up and running) | ||
3326 | * which is interpreted as empty port in ATA world. This | ||
3327 | * function also waits for such devices to get out of 0xff | ||
3328 | * status. | ||
3329 | * | ||
3330 | * LOCKING: | ||
3331 | * Kernel thread context (may sleep). | ||
3332 | */ | ||
3333 | void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline) | ||
3334 | { | ||
3335 | unsigned long until = jiffies + ATA_TMOUT_FF_WAIT; | ||
3336 | |||
3337 | if (time_before(until, deadline)) | ||
3338 | deadline = until; | ||
3339 | |||
3340 | /* Spec mandates ">= 2ms" before checking status. We wait | ||
3341 | * 150ms, because that was the magic delay used for ATAPI | ||
3342 | * devices in Hale Landis's ATADRVR, for the period of time | ||
3343 | * between when the ATA command register is written, and then | ||
3344 | * status is checked. Because waiting for "a while" before | ||
3345 | * checking status is fine, post SRST, we perform this magic | ||
3346 | * delay here as well. | ||
3347 | * | ||
3348 | * Old drivers/ide uses the 2mS rule and then waits for ready. | ||
3349 | */ | ||
3350 | msleep(150); | ||
3351 | |||
3352 | /* Wait for 0xff to clear. Some SATA devices take a long time | ||
3353 | * to clear 0xff after reset. For example, HHD424020F7SV00 | ||
3354 | * iVDR needs >= 800ms while. Quantum GoVault needs even more | ||
3355 | * than that. | ||
3356 | */ | ||
3357 | while (1) { | ||
3358 | u8 status = ata_chk_status(ap); | ||
3359 | |||
3360 | if (status != 0xff || time_after(jiffies, deadline)) | ||
3361 | return; | ||
3362 | |||
3363 | msleep(50); | ||
3364 | } | ||
3365 | } | ||
3366 | |||
3367 | /** | ||
3118 | * ata_wait_ready - sleep until BSY clears, or timeout | 3368 | * ata_wait_ready - sleep until BSY clears, or timeout |
3119 | * @ap: port containing status register to be polled | 3369 | * @ap: port containing status register to be polled |
3120 | * @deadline: deadline jiffies for the operation | 3370 | * @deadline: deadline jiffies for the operation |
@@ -3220,8 +3470,6 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, | |||
3220 | unsigned long deadline) | 3470 | unsigned long deadline) |
3221 | { | 3471 | { |
3222 | struct ata_ioports *ioaddr = &ap->ioaddr; | 3472 | struct ata_ioports *ioaddr = &ap->ioaddr; |
3223 | struct ata_device *dev; | ||
3224 | int i = 0; | ||
3225 | 3473 | ||
3226 | DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); | 3474 | DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); |
3227 | 3475 | ||
@@ -3232,36 +3480,8 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, | |||
3232 | udelay(20); /* FIXME: flush */ | 3480 | udelay(20); /* FIXME: flush */ |
3233 | iowrite8(ap->ctl, ioaddr->ctl_addr); | 3481 | iowrite8(ap->ctl, ioaddr->ctl_addr); |
3234 | 3482 | ||
3235 | /* If we issued an SRST then an ATA drive (not ATAPI) | 3483 | /* wait a while before checking status */ |
3236 | * may have changed configuration and be in PIO0 timing. If | 3484 | ata_wait_after_reset(ap, deadline); |
3237 | * we did a hard reset (or are coming from power on) this is | ||
3238 | * true for ATA or ATAPI. Until we've set a suitable controller | ||
3239 | * mode we should not touch the bus as we may be talking too fast. | ||
3240 | */ | ||
3241 | |||
3242 | ata_link_for_each_dev(dev, &ap->link) | ||
3243 | dev->pio_mode = XFER_PIO_0; | ||
3244 | |||
3245 | /* If the controller has a pio mode setup function then use | ||
3246 | it to set the chipset to rights. Don't touch the DMA setup | ||
3247 | as that will be dealt with when revalidating */ | ||
3248 | if (ap->ops->set_piomode) { | ||
3249 | ata_link_for_each_dev(dev, &ap->link) | ||
3250 | if (devmask & (1 << i++)) | ||
3251 | ap->ops->set_piomode(ap, dev); | ||
3252 | } | ||
3253 | |||
3254 | /* spec mandates ">= 2ms" before checking status. | ||
3255 | * We wait 150ms, because that was the magic delay used for | ||
3256 | * ATAPI devices in Hale Landis's ATADRVR, for the period of time | ||
3257 | * between when the ATA command register is written, and then | ||
3258 | * status is checked. Because waiting for "a while" before | ||
3259 | * checking status is fine, post SRST, we perform this magic | ||
3260 | * delay here as well. | ||
3261 | * | ||
3262 | * Old drivers/ide uses the 2mS rule and then waits for ready | ||
3263 | */ | ||
3264 | msleep(150); | ||
3265 | 3485 | ||
3266 | /* Before we perform post reset processing we want to see if | 3486 | /* Before we perform post reset processing we want to see if |
3267 | * the bus shows 0xFF because the odd clown forgets the D7 | 3487 | * the bus shows 0xFF because the odd clown forgets the D7 |
@@ -3688,8 +3908,8 @@ int sata_std_hardreset(struct ata_link *link, unsigned int *class, | |||
3688 | return 0; | 3908 | return 0; |
3689 | } | 3909 | } |
3690 | 3910 | ||
3691 | /* wait a while before checking status, see SRST for more info */ | 3911 | /* wait a while before checking status */ |
3692 | msleep(150); | 3912 | ata_wait_after_reset(ap, deadline); |
3693 | 3913 | ||
3694 | /* If PMP is supported, we have to do follow-up SRST. Note | 3914 | /* If PMP is supported, we have to do follow-up SRST. Note |
3695 | * that some PMPs don't send D2H Reg FIS after hardreset at | 3915 | * that some PMPs don't send D2H Reg FIS after hardreset at |
@@ -3947,9 +4167,6 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
3947 | { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, | 4167 | { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, |
3948 | { "SAMSUNG CD-ROM SN-124", "N001", ATA_HORKAGE_NODMA }, | 4168 | { "SAMSUNG CD-ROM SN-124", "N001", ATA_HORKAGE_NODMA }, |
3949 | { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, | 4169 | { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, |
3950 | { "IOMEGA ZIP 250 ATAPI", NULL, ATA_HORKAGE_NODMA }, /* temporary fix */ | ||
3951 | { "IOMEGA ZIP 250 ATAPI Floppy", | ||
3952 | NULL, ATA_HORKAGE_NODMA }, | ||
3953 | /* Odd clown on sil3726/4726 PMPs */ | 4170 | /* Odd clown on sil3726/4726 PMPs */ |
3954 | { "Config Disk", NULL, ATA_HORKAGE_NODMA | | 4171 | { "Config Disk", NULL, ATA_HORKAGE_NODMA | |
3955 | ATA_HORKAGE_SKIP_PM }, | 4172 | ATA_HORKAGE_SKIP_PM }, |
@@ -3992,6 +4209,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
3992 | { "ST3160812AS", "3.ADJ", ATA_HORKAGE_NONCQ, }, | 4209 | { "ST3160812AS", "3.ADJ", ATA_HORKAGE_NONCQ, }, |
3993 | { "ST980813AS", "3.ADB", ATA_HORKAGE_NONCQ, }, | 4210 | { "ST980813AS", "3.ADB", ATA_HORKAGE_NONCQ, }, |
3994 | { "SAMSUNG HD401LJ", "ZZ100-15", ATA_HORKAGE_NONCQ, }, | 4211 | { "SAMSUNG HD401LJ", "ZZ100-15", ATA_HORKAGE_NONCQ, }, |
4212 | { "Maxtor 7V300F0", "VA111900", ATA_HORKAGE_NONCQ, }, | ||
3995 | 4213 | ||
3996 | /* devices which puke on READ_NATIVE_MAX */ | 4214 | /* devices which puke on READ_NATIVE_MAX */ |
3997 | { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, }, | 4215 | { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, }, |
@@ -4007,7 +4225,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
4007 | { } | 4225 | { } |
4008 | }; | 4226 | }; |
4009 | 4227 | ||
4010 | int strn_pattern_cmp(const char *patt, const char *name, int wildchar) | 4228 | static int strn_pattern_cmp(const char *patt, const char *name, int wildchar) |
4011 | { | 4229 | { |
4012 | const char *p; | 4230 | const char *p; |
4013 | int len; | 4231 | int len; |
@@ -4181,15 +4399,14 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev) | |||
4181 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 4399 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
4182 | return err_mask; | 4400 | return err_mask; |
4183 | } | 4401 | } |
4184 | |||
4185 | /** | 4402 | /** |
4186 | * ata_dev_set_AN - Issue SET FEATURES - SATA FEATURES | 4403 | * ata_dev_set_feature - Issue SET FEATURES - SATA FEATURES |
4187 | * @dev: Device to which command will be sent | 4404 | * @dev: Device to which command will be sent |
4188 | * @enable: Whether to enable or disable the feature | 4405 | * @enable: Whether to enable or disable the feature |
4406 | * @feature: The sector count represents the feature to set | ||
4189 | * | 4407 | * |
4190 | * Issue SET FEATURES - SATA FEATURES command to device @dev | 4408 | * Issue SET FEATURES - SATA FEATURES command to device @dev |
4191 | * on port @ap with sector count set to indicate Asynchronous | 4409 | * on port @ap with sector count |
4192 | * Notification feature | ||
4193 | * | 4410 | * |
4194 | * LOCKING: | 4411 | * LOCKING: |
4195 | * PCI/etc. bus probe sem. | 4412 | * PCI/etc. bus probe sem. |
@@ -4197,7 +4414,8 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev) | |||
4197 | * RETURNS: | 4414 | * RETURNS: |
4198 | * 0 on success, AC_ERR_* mask otherwise. | 4415 | * 0 on success, AC_ERR_* mask otherwise. |
4199 | */ | 4416 | */ |
4200 | static unsigned int ata_dev_set_AN(struct ata_device *dev, u8 enable) | 4417 | static unsigned int ata_dev_set_feature(struct ata_device *dev, u8 enable, |
4418 | u8 feature) | ||
4201 | { | 4419 | { |
4202 | struct ata_taskfile tf; | 4420 | struct ata_taskfile tf; |
4203 | unsigned int err_mask; | 4421 | unsigned int err_mask; |
@@ -4210,7 +4428,7 @@ static unsigned int ata_dev_set_AN(struct ata_device *dev, u8 enable) | |||
4210 | tf.feature = enable; | 4428 | tf.feature = enable; |
4211 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 4429 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
4212 | tf.protocol = ATA_PROT_NODATA; | 4430 | tf.protocol = ATA_PROT_NODATA; |
4213 | tf.nsect = SATA_AN; | 4431 | tf.nsect = feature; |
4214 | 4432 | ||
4215 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); | 4433 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); |
4216 | 4434 | ||
@@ -4689,8 +4907,9 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
4689 | * data in this function or read data in ata_sg_clean. | 4907 | * data in this function or read data in ata_sg_clean. |
4690 | */ | 4908 | */ |
4691 | offset = lsg->offset + lsg->length - qc->pad_len; | 4909 | offset = lsg->offset + lsg->length - qc->pad_len; |
4692 | sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT)); | 4910 | sg_init_table(psg, 1); |
4693 | psg->offset = offset_in_page(offset); | 4911 | sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT), |
4912 | qc->pad_len, offset_in_page(offset)); | ||
4694 | 4913 | ||
4695 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | 4914 | if (qc->tf.flags & ATA_TFLAG_WRITE) { |
4696 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); | 4915 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); |
@@ -5594,6 +5813,9 @@ void ata_qc_complete(struct ata_queued_cmd *qc) | |||
5594 | * taken care of. | 5813 | * taken care of. |
5595 | */ | 5814 | */ |
5596 | if (ap->ops->error_handler) { | 5815 | if (ap->ops->error_handler) { |
5816 | struct ata_device *dev = qc->dev; | ||
5817 | struct ata_eh_info *ehi = &dev->link->eh_info; | ||
5818 | |||
5597 | WARN_ON(ap->pflags & ATA_PFLAG_FROZEN); | 5819 | WARN_ON(ap->pflags & ATA_PFLAG_FROZEN); |
5598 | 5820 | ||
5599 | if (unlikely(qc->err_mask)) | 5821 | if (unlikely(qc->err_mask)) |
@@ -5612,6 +5834,27 @@ void ata_qc_complete(struct ata_queued_cmd *qc) | |||
5612 | if (qc->flags & ATA_QCFLAG_RESULT_TF) | 5834 | if (qc->flags & ATA_QCFLAG_RESULT_TF) |
5613 | fill_result_tf(qc); | 5835 | fill_result_tf(qc); |
5614 | 5836 | ||
5837 | /* Some commands need post-processing after successful | ||
5838 | * completion. | ||
5839 | */ | ||
5840 | switch (qc->tf.command) { | ||
5841 | case ATA_CMD_SET_FEATURES: | ||
5842 | if (qc->tf.feature != SETFEATURES_WC_ON && | ||
5843 | qc->tf.feature != SETFEATURES_WC_OFF) | ||
5844 | break; | ||
5845 | /* fall through */ | ||
5846 | case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ | ||
5847 | case ATA_CMD_SET_MULTI: /* multi_count changed */ | ||
5848 | /* revalidate device */ | ||
5849 | ehi->dev_action[dev->devno] |= ATA_EH_REVALIDATE; | ||
5850 | ata_port_schedule_eh(ap); | ||
5851 | break; | ||
5852 | |||
5853 | case ATA_CMD_SLEEP: | ||
5854 | dev->flags |= ATA_DFLAG_SLEEPING; | ||
5855 | break; | ||
5856 | } | ||
5857 | |||
5615 | __ata_qc_complete(qc); | 5858 | __ata_qc_complete(qc); |
5616 | } else { | 5859 | } else { |
5617 | if (qc->flags & ATA_QCFLAG_EH_SCHEDULED) | 5860 | if (qc->flags & ATA_QCFLAG_EH_SCHEDULED) |
@@ -5749,6 +5992,14 @@ void ata_qc_issue(struct ata_queued_cmd *qc) | |||
5749 | qc->flags &= ~ATA_QCFLAG_DMAMAP; | 5992 | qc->flags &= ~ATA_QCFLAG_DMAMAP; |
5750 | } | 5993 | } |
5751 | 5994 | ||
5995 | /* if device is sleeping, schedule softreset and abort the link */ | ||
5996 | if (unlikely(qc->dev->flags & ATA_DFLAG_SLEEPING)) { | ||
5997 | link->eh_info.action |= ATA_EH_SOFTRESET; | ||
5998 | ata_ehi_push_desc(&link->eh_info, "waking up from sleep"); | ||
5999 | ata_link_abort(link); | ||
6000 | return; | ||
6001 | } | ||
6002 | |||
5752 | ap->ops->qc_prep(qc); | 6003 | ap->ops->qc_prep(qc); |
5753 | 6004 | ||
5754 | qc->err_mask |= ap->ops->qc_issue(qc); | 6005 | qc->err_mask |= ap->ops->qc_issue(qc); |
@@ -6296,6 +6547,12 @@ int ata_host_suspend(struct ata_host *host, pm_message_t mesg) | |||
6296 | { | 6547 | { |
6297 | int rc; | 6548 | int rc; |
6298 | 6549 | ||
6550 | /* | ||
6551 | * disable link pm on all ports before requesting | ||
6552 | * any pm activity | ||
6553 | */ | ||
6554 | ata_lpm_enable(host); | ||
6555 | |||
6299 | rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); | 6556 | rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); |
6300 | if (rc == 0) | 6557 | if (rc == 0) |
6301 | host->dev->power.power_state = mesg; | 6558 | host->dev->power.power_state = mesg; |
@@ -6318,6 +6575,9 @@ void ata_host_resume(struct ata_host *host) | |||
6318 | ata_host_request_pm(host, PMSG_ON, ATA_EH_SOFTRESET, | 6575 | ata_host_request_pm(host, PMSG_ON, ATA_EH_SOFTRESET, |
6319 | ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0); | 6576 | ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0); |
6320 | host->dev->power.power_state = PMSG_ON; | 6577 | host->dev->power.power_state = PMSG_ON; |
6578 | |||
6579 | /* reenable link pm */ | ||
6580 | ata_lpm_disable(host); | ||
6321 | } | 6581 | } |
6322 | #endif | 6582 | #endif |
6323 | 6583 | ||
@@ -6860,6 +7120,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6860 | struct ata_port *ap = host->ports[i]; | 7120 | struct ata_port *ap = host->ports[i]; |
6861 | 7121 | ||
6862 | ata_scsi_scan_host(ap, 1); | 7122 | ata_scsi_scan_host(ap, 1); |
7123 | ata_lpm_schedule(ap, ap->pm_policy); | ||
6863 | } | 7124 | } |
6864 | 7125 | ||
6865 | return 0; | 7126 | return 0; |
@@ -6921,7 +7182,7 @@ int ata_host_activate(struct ata_host *host, int irq, | |||
6921 | * LOCKING: | 7182 | * LOCKING: |
6922 | * Kernel thread context (may sleep). | 7183 | * Kernel thread context (may sleep). |
6923 | */ | 7184 | */ |
6924 | void ata_port_detach(struct ata_port *ap) | 7185 | static void ata_port_detach(struct ata_port *ap) |
6925 | { | 7186 | { |
6926 | unsigned long flags; | 7187 | unsigned long flags; |
6927 | struct ata_link *link; | 7188 | struct ata_link *link; |
@@ -7256,7 +7517,6 @@ const struct ata_port_info ata_dummy_port_info = { | |||
7256 | * likely to change as new drivers are added and updated. | 7517 | * likely to change as new drivers are added and updated. |
7257 | * Do not depend on ABI/API stability. | 7518 | * Do not depend on ABI/API stability. |
7258 | */ | 7519 | */ |
7259 | |||
7260 | EXPORT_SYMBOL_GPL(sata_deb_timing_normal); | 7520 | EXPORT_SYMBOL_GPL(sata_deb_timing_normal); |
7261 | EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug); | 7521 | EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug); |
7262 | EXPORT_SYMBOL_GPL(sata_deb_timing_long); | 7522 | EXPORT_SYMBOL_GPL(sata_deb_timing_long); |
@@ -7326,6 +7586,7 @@ EXPORT_SYMBOL_GPL(ata_port_disable); | |||
7326 | EXPORT_SYMBOL_GPL(ata_ratelimit); | 7586 | EXPORT_SYMBOL_GPL(ata_ratelimit); |
7327 | EXPORT_SYMBOL_GPL(ata_wait_register); | 7587 | EXPORT_SYMBOL_GPL(ata_wait_register); |
7328 | EXPORT_SYMBOL_GPL(ata_busy_sleep); | 7588 | EXPORT_SYMBOL_GPL(ata_busy_sleep); |
7589 | EXPORT_SYMBOL_GPL(ata_wait_after_reset); | ||
7329 | EXPORT_SYMBOL_GPL(ata_wait_ready); | 7590 | EXPORT_SYMBOL_GPL(ata_wait_ready); |
7330 | EXPORT_SYMBOL_GPL(ata_port_queue_task); | 7591 | EXPORT_SYMBOL_GPL(ata_port_queue_task); |
7331 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | 7592 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 93e2b545b439..8d64f8fd8f1d 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -1800,10 +1800,8 @@ static void ata_eh_link_autopsy(struct ata_link *link) | |||
1800 | qc->err_mask &= ~AC_ERR_OTHER; | 1800 | qc->err_mask &= ~AC_ERR_OTHER; |
1801 | 1801 | ||
1802 | /* SENSE_VALID trumps dev/unknown error and revalidation */ | 1802 | /* SENSE_VALID trumps dev/unknown error and revalidation */ |
1803 | if (qc->flags & ATA_QCFLAG_SENSE_VALID) { | 1803 | if (qc->flags & ATA_QCFLAG_SENSE_VALID) |
1804 | qc->err_mask &= ~(AC_ERR_DEV | AC_ERR_OTHER); | 1804 | qc->err_mask &= ~(AC_ERR_DEV | AC_ERR_OTHER); |
1805 | ehc->i.action &= ~ATA_EH_REVALIDATE; | ||
1806 | } | ||
1807 | 1805 | ||
1808 | /* accumulate error info */ | 1806 | /* accumulate error info */ |
1809 | ehc->i.dev = qc->dev; | 1807 | ehc->i.dev = qc->dev; |
@@ -1816,7 +1814,8 @@ static void ata_eh_link_autopsy(struct ata_link *link) | |||
1816 | if (ap->pflags & ATA_PFLAG_FROZEN || | 1814 | if (ap->pflags & ATA_PFLAG_FROZEN || |
1817 | all_err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT)) | 1815 | all_err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT)) |
1818 | ehc->i.action |= ATA_EH_SOFTRESET; | 1816 | ehc->i.action |= ATA_EH_SOFTRESET; |
1819 | else if (all_err_mask) | 1817 | else if ((is_io && all_err_mask) || |
1818 | (!is_io && (all_err_mask & ~AC_ERR_DEV))) | ||
1820 | ehc->i.action |= ATA_EH_REVALIDATE; | 1819 | ehc->i.action |= ATA_EH_REVALIDATE; |
1821 | 1820 | ||
1822 | /* if we have offending qcs and the associated failed device */ | 1821 | /* if we have offending qcs and the associated failed device */ |
@@ -1879,7 +1878,9 @@ static void ata_eh_link_report(struct ata_link *link) | |||
1879 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 1878 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { |
1880 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | 1879 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); |
1881 | 1880 | ||
1882 | if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link) | 1881 | if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link || |
1882 | ((qc->flags & ATA_QCFLAG_QUIET) && | ||
1883 | qc->err_mask == AC_ERR_DEV)) | ||
1883 | continue; | 1884 | continue; |
1884 | if (qc->flags & ATA_QCFLAG_SENSE_VALID && !qc->err_mask) | 1885 | if (qc->flags & ATA_QCFLAG_SENSE_VALID && !qc->err_mask) |
1885 | continue; | 1886 | continue; |
@@ -2071,7 +2072,7 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2071 | int try = 0; | 2072 | int try = 0; |
2072 | struct ata_device *dev; | 2073 | struct ata_device *dev; |
2073 | unsigned long deadline; | 2074 | unsigned long deadline; |
2074 | unsigned int action; | 2075 | unsigned int tmp_action; |
2075 | ata_reset_fn_t reset; | 2076 | ata_reset_fn_t reset; |
2076 | unsigned long flags; | 2077 | unsigned long flags; |
2077 | int rc; | 2078 | int rc; |
@@ -2083,17 +2084,36 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2083 | 2084 | ||
2084 | ata_eh_about_to_do(link, NULL, ehc->i.action & ATA_EH_RESET_MASK); | 2085 | ata_eh_about_to_do(link, NULL, ehc->i.action & ATA_EH_RESET_MASK); |
2085 | 2086 | ||
2087 | ata_link_for_each_dev(dev, link) { | ||
2088 | /* If we issue an SRST then an ATA drive (not ATAPI) | ||
2089 | * may change configuration and be in PIO0 timing. If | ||
2090 | * we do a hard reset (or are coming from power on) | ||
2091 | * this is true for ATA or ATAPI. Until we've set a | ||
2092 | * suitable controller mode we should not touch the | ||
2093 | * bus as we may be talking too fast. | ||
2094 | */ | ||
2095 | dev->pio_mode = XFER_PIO_0; | ||
2096 | |||
2097 | /* If the controller has a pio mode setup function | ||
2098 | * then use it to set the chipset to rights. Don't | ||
2099 | * touch the DMA setup as that will be dealt with when | ||
2100 | * configuring devices. | ||
2101 | */ | ||
2102 | if (ap->ops->set_piomode) | ||
2103 | ap->ops->set_piomode(ap, dev); | ||
2104 | } | ||
2105 | |||
2086 | /* Determine which reset to use and record in ehc->i.action. | 2106 | /* Determine which reset to use and record in ehc->i.action. |
2087 | * prereset() may examine and modify it. | 2107 | * prereset() may examine and modify it. |
2088 | */ | 2108 | */ |
2089 | action = ehc->i.action; | ||
2090 | ehc->i.action &= ~ATA_EH_RESET_MASK; | ||
2091 | if (softreset && (!hardreset || (!(link->flags & ATA_LFLAG_NO_SRST) && | 2109 | if (softreset && (!hardreset || (!(link->flags & ATA_LFLAG_NO_SRST) && |
2092 | !sata_set_spd_needed(link) && | 2110 | !sata_set_spd_needed(link) && |
2093 | !(action & ATA_EH_HARDRESET)))) | 2111 | !(ehc->i.action & ATA_EH_HARDRESET)))) |
2094 | ehc->i.action |= ATA_EH_SOFTRESET; | 2112 | tmp_action = ATA_EH_SOFTRESET; |
2095 | else | 2113 | else |
2096 | ehc->i.action |= ATA_EH_HARDRESET; | 2114 | tmp_action = ATA_EH_HARDRESET; |
2115 | |||
2116 | ehc->i.action = (ehc->i.action & ~ATA_EH_RESET_MASK) | tmp_action; | ||
2097 | 2117 | ||
2098 | if (prereset) { | 2118 | if (prereset) { |
2099 | rc = prereset(link, jiffies + ATA_EH_PRERESET_TIMEOUT); | 2119 | rc = prereset(link, jiffies + ATA_EH_PRERESET_TIMEOUT); |
@@ -2208,9 +2228,11 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2208 | ata_link_for_each_dev(dev, link) { | 2228 | ata_link_for_each_dev(dev, link) { |
2209 | /* After the reset, the device state is PIO 0 | 2229 | /* After the reset, the device state is PIO 0 |
2210 | * and the controller state is undefined. | 2230 | * and the controller state is undefined. |
2211 | * Record the mode. | 2231 | * Reset also wakes up drives from sleeping |
2232 | * mode. | ||
2212 | */ | 2233 | */ |
2213 | dev->pio_mode = XFER_PIO_0; | 2234 | dev->pio_mode = XFER_PIO_0; |
2235 | dev->flags &= ~ATA_DFLAG_SLEEPING; | ||
2214 | 2236 | ||
2215 | if (ata_link_offline(link)) | 2237 | if (ata_link_offline(link)) |
2216 | continue; | 2238 | continue; |
@@ -2416,7 +2438,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err) | |||
2416 | /* give it just one more chance */ | 2438 | /* give it just one more chance */ |
2417 | ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); | 2439 | ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); |
2418 | case -EIO: | 2440 | case -EIO: |
2419 | if (ehc->tries[dev->devno] == 1) { | 2441 | if (ehc->tries[dev->devno] == 1 && dev->pio_mode > XFER_PIO_0) { |
2420 | /* This is the last chance, better to slow | 2442 | /* This is the last chance, better to slow |
2421 | * down than lose it. | 2443 | * down than lose it. |
2422 | */ | 2444 | */ |
@@ -2607,6 +2629,10 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2607 | ehc->i.flags &= ~ATA_EHI_SETMODE; | 2629 | ehc->i.flags &= ~ATA_EHI_SETMODE; |
2608 | } | 2630 | } |
2609 | 2631 | ||
2632 | if (ehc->i.action & ATA_EHI_LPM) | ||
2633 | ata_link_for_each_dev(dev, link) | ||
2634 | ata_dev_enable_pm(dev, ap->pm_policy); | ||
2635 | |||
2610 | /* this link is okay now */ | 2636 | /* this link is okay now */ |
2611 | ehc->i.flags = 0; | 2637 | ehc->i.flags = 0; |
2612 | continue; | 2638 | continue; |
@@ -2672,8 +2698,15 @@ void ata_eh_finish(struct ata_port *ap) | |||
2672 | /* FIXME: Once EH migration is complete, | 2698 | /* FIXME: Once EH migration is complete, |
2673 | * generate sense data in this function, | 2699 | * generate sense data in this function, |
2674 | * considering both err_mask and tf. | 2700 | * considering both err_mask and tf. |
2701 | * | ||
2702 | * There's no point in retrying invalid | ||
2703 | * (detected by libata) and non-IO device | ||
2704 | * errors (rejected by device). Finish them | ||
2705 | * immediately. | ||
2675 | */ | 2706 | */ |
2676 | if (qc->err_mask & AC_ERR_INVALID) | 2707 | if ((qc->err_mask & AC_ERR_INVALID) || |
2708 | (!(qc->flags & ATA_QCFLAG_IO) && | ||
2709 | qc->err_mask == AC_ERR_DEV)) | ||
2677 | ata_eh_qc_complete(qc); | 2710 | ata_eh_qc_complete(qc); |
2678 | else | 2711 | else |
2679 | ata_eh_qc_retry(qc); | 2712 | ata_eh_qc_retry(qc); |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index f5d5420a1ba2..fc89590d3772 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -110,6 +110,74 @@ static struct scsi_transport_template ata_scsi_transport_template = { | |||
110 | }; | 110 | }; |
111 | 111 | ||
112 | 112 | ||
113 | static const struct { | ||
114 | enum link_pm value; | ||
115 | const char *name; | ||
116 | } link_pm_policy[] = { | ||
117 | { NOT_AVAILABLE, "max_performance" }, | ||
118 | { MIN_POWER, "min_power" }, | ||
119 | { MAX_PERFORMANCE, "max_performance" }, | ||
120 | { MEDIUM_POWER, "medium_power" }, | ||
121 | }; | ||
122 | |||
123 | const char *ata_scsi_lpm_get(enum link_pm policy) | ||
124 | { | ||
125 | int i; | ||
126 | |||
127 | for (i = 0; i < ARRAY_SIZE(link_pm_policy); i++) | ||
128 | if (link_pm_policy[i].value == policy) | ||
129 | return link_pm_policy[i].name; | ||
130 | |||
131 | return NULL; | ||
132 | } | ||
133 | |||
134 | static ssize_t ata_scsi_lpm_put(struct class_device *class_dev, | ||
135 | const char *buf, size_t count) | ||
136 | { | ||
137 | struct Scsi_Host *shost = class_to_shost(class_dev); | ||
138 | struct ata_port *ap = ata_shost_to_port(shost); | ||
139 | enum link_pm policy = 0; | ||
140 | int i; | ||
141 | |||
142 | /* | ||
143 | * we are skipping array location 0 on purpose - this | ||
144 | * is because a value of NOT_AVAILABLE is displayed | ||
145 | * to the user as max_performance, but when the user | ||
146 | * writes "max_performance", they actually want the | ||
147 | * value to match MAX_PERFORMANCE. | ||
148 | */ | ||
149 | for (i = 1; i < ARRAY_SIZE(link_pm_policy); i++) { | ||
150 | const int len = strlen(link_pm_policy[i].name); | ||
151 | if (strncmp(link_pm_policy[i].name, buf, len) == 0 && | ||
152 | buf[len] == '\n') { | ||
153 | policy = link_pm_policy[i].value; | ||
154 | break; | ||
155 | } | ||
156 | } | ||
157 | if (!policy) | ||
158 | return -EINVAL; | ||
159 | |||
160 | ata_lpm_schedule(ap, policy); | ||
161 | return count; | ||
162 | } | ||
163 | |||
164 | static ssize_t | ||
165 | ata_scsi_lpm_show(struct class_device *class_dev, char *buf) | ||
166 | { | ||
167 | struct Scsi_Host *shost = class_to_shost(class_dev); | ||
168 | struct ata_port *ap = ata_shost_to_port(shost); | ||
169 | const char *policy = | ||
170 | ata_scsi_lpm_get(ap->pm_policy); | ||
171 | |||
172 | if (!policy) | ||
173 | return -EINVAL; | ||
174 | |||
175 | return snprintf(buf, 23, "%s\n", policy); | ||
176 | } | ||
177 | CLASS_DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, | ||
178 | ata_scsi_lpm_show, ata_scsi_lpm_put); | ||
179 | EXPORT_SYMBOL_GPL(class_device_attr_link_power_management_policy); | ||
180 | |||
113 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, | 181 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, |
114 | void (*done)(struct scsi_cmnd *)) | 182 | void (*done)(struct scsi_cmnd *)) |
115 | { | 183 | { |
@@ -1040,6 +1108,9 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) | |||
1040 | else | 1108 | else |
1041 | tf->command = ATA_CMD_FLUSH; | 1109 | tf->command = ATA_CMD_FLUSH; |
1042 | 1110 | ||
1111 | /* flush is critical for IO integrity, consider it an IO command */ | ||
1112 | qc->flags |= ATA_QCFLAG_IO; | ||
1113 | |||
1043 | return 0; | 1114 | return 0; |
1044 | } | 1115 | } |
1045 | 1116 | ||
@@ -1361,33 +1432,10 @@ nothing_to_do: | |||
1361 | static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | 1432 | static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) |
1362 | { | 1433 | { |
1363 | struct ata_port *ap = qc->ap; | 1434 | struct ata_port *ap = qc->ap; |
1364 | struct ata_eh_info *ehi = &qc->dev->link->eh_info; | ||
1365 | struct scsi_cmnd *cmd = qc->scsicmd; | 1435 | struct scsi_cmnd *cmd = qc->scsicmd; |
1366 | u8 *cdb = cmd->cmnd; | 1436 | u8 *cdb = cmd->cmnd; |
1367 | int need_sense = (qc->err_mask != 0); | 1437 | int need_sense = (qc->err_mask != 0); |
1368 | 1438 | ||
1369 | /* We snoop the SET_FEATURES - Write Cache ON/OFF command, and | ||
1370 | * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE | ||
1371 | * cache | ||
1372 | */ | ||
1373 | if (ap->ops->error_handler && !need_sense) { | ||
1374 | switch (qc->tf.command) { | ||
1375 | case ATA_CMD_SET_FEATURES: | ||
1376 | if ((qc->tf.feature == SETFEATURES_WC_ON) || | ||
1377 | (qc->tf.feature == SETFEATURES_WC_OFF)) { | ||
1378 | ehi->action |= ATA_EH_REVALIDATE; | ||
1379 | ata_port_schedule_eh(ap); | ||
1380 | } | ||
1381 | break; | ||
1382 | |||
1383 | case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ | ||
1384 | case ATA_CMD_SET_MULTI: /* multi_count changed */ | ||
1385 | ehi->action |= ATA_EH_REVALIDATE; | ||
1386 | ata_port_schedule_eh(ap); | ||
1387 | break; | ||
1388 | } | ||
1389 | } | ||
1390 | |||
1391 | /* For ATA pass thru (SAT) commands, generate a sense block if | 1439 | /* For ATA pass thru (SAT) commands, generate a sense block if |
1392 | * user mandated it or if there's an error. Note that if we | 1440 | * user mandated it or if there's an error. Note that if we |
1393 | * generate because the user forced us to, a check condition | 1441 | * generate because the user forced us to, a check condition |
@@ -2719,8 +2767,8 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) | |||
2719 | */ | 2767 | */ |
2720 | qc->nbytes = scsi_bufflen(scmd); | 2768 | qc->nbytes = scsi_bufflen(scmd); |
2721 | 2769 | ||
2722 | /* request result TF */ | 2770 | /* request result TF and be quiet about device error */ |
2723 | qc->flags |= ATA_QCFLAG_RESULT_TF; | 2771 | qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; |
2724 | 2772 | ||
2725 | return 0; | 2773 | return 0; |
2726 | 2774 | ||
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 90df58a3edc9..0e6cf3a484dc 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -101,6 +101,8 @@ extern int sata_link_init_spd(struct ata_link *link); | |||
101 | extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); | 101 | extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); |
102 | extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); | 102 | extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); |
103 | extern struct ata_port *ata_port_alloc(struct ata_host *host); | 103 | extern struct ata_port *ata_port_alloc(struct ata_host *host); |
104 | extern void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy); | ||
105 | extern void ata_lpm_schedule(struct ata_port *ap, enum link_pm); | ||
104 | 106 | ||
105 | /* libata-acpi.c */ | 107 | /* libata-acpi.c */ |
106 | #ifdef CONFIG_ATA_ACPI | 108 | #ifdef CONFIG_ATA_ACPI |
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c index 0f6f7bcc3def..e4542ab9c7f8 100644 --- a/drivers/ata/pata_acpi.c +++ b/drivers/ata/pata_acpi.c | |||
@@ -181,7 +181,7 @@ static void pacpi_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
181 | int unit = adev->devno; | 181 | int unit = adev->devno; |
182 | struct pata_acpi *acpi = ap->private_data; | 182 | struct pata_acpi *acpi = ap->private_data; |
183 | 183 | ||
184 | if(!(acpi->gtm.flags & 0x10)) | 184 | if (!(acpi->gtm.flags & 0x10)) |
185 | unit = 0; | 185 | unit = 0; |
186 | 186 | ||
187 | /* Now stuff the nS values into the structure */ | 187 | /* Now stuff the nS values into the structure */ |
@@ -202,7 +202,7 @@ static void pacpi_set_dmamode(struct ata_port *ap, struct ata_device *adev) | |||
202 | int unit = adev->devno; | 202 | int unit = adev->devno; |
203 | struct pata_acpi *acpi = ap->private_data; | 203 | struct pata_acpi *acpi = ap->private_data; |
204 | 204 | ||
205 | if(!(acpi->gtm.flags & 0x10)) | 205 | if (!(acpi->gtm.flags & 0x10)) |
206 | unit = 0; | 206 | unit = 0; |
207 | 207 | ||
208 | /* Now stuff the nS values into the structure */ | 208 | /* Now stuff the nS values into the structure */ |
diff --git a/drivers/ata/pata_icside.c b/drivers/ata/pata_icside.c index be30923566c5..842fe08a3c13 100644 --- a/drivers/ata/pata_icside.c +++ b/drivers/ata/pata_icside.c | |||
@@ -332,12 +332,13 @@ static void ata_dummy_noret(struct ata_port *port) | |||
332 | { | 332 | { |
333 | } | 333 | } |
334 | 334 | ||
335 | static void pata_icside_postreset(struct ata_port *ap, unsigned int *classes) | 335 | static void pata_icside_postreset(struct ata_link *link, unsigned int *classes) |
336 | { | 336 | { |
337 | struct ata_port *ap = link->ap; | ||
337 | struct pata_icside_state *state = ap->host->private_data; | 338 | struct pata_icside_state *state = ap->host->private_data; |
338 | 339 | ||
339 | if (classes[0] != ATA_DEV_NONE || classes[1] != ATA_DEV_NONE) | 340 | if (classes[0] != ATA_DEV_NONE || classes[1] != ATA_DEV_NONE) |
340 | return ata_std_postreset(ap, classes); | 341 | return ata_std_postreset(link, classes); |
341 | 342 | ||
342 | state->port[ap->port_no].disabled = 1; | 343 | state->port[ap->port_no].disabled = 1; |
343 | 344 | ||
@@ -395,29 +396,30 @@ static struct ata_port_operations pata_icside_port_ops = { | |||
395 | 396 | ||
396 | static void __devinit | 397 | static void __devinit |
397 | pata_icside_setup_ioaddr(struct ata_port *ap, void __iomem *base, | 398 | pata_icside_setup_ioaddr(struct ata_port *ap, void __iomem *base, |
398 | const struct portinfo *info) | 399 | struct pata_icside_info *info, |
400 | const struct portinfo *port) | ||
399 | { | 401 | { |
400 | struct ata_ioports *ioaddr = &ap->ioaddr; | 402 | struct ata_ioports *ioaddr = &ap->ioaddr; |
401 | void __iomem *cmd = base + info->dataoffset; | 403 | void __iomem *cmd = base + port->dataoffset; |
402 | 404 | ||
403 | ioaddr->cmd_addr = cmd; | 405 | ioaddr->cmd_addr = cmd; |
404 | ioaddr->data_addr = cmd + (ATA_REG_DATA << info->stepping); | 406 | ioaddr->data_addr = cmd + (ATA_REG_DATA << port->stepping); |
405 | ioaddr->error_addr = cmd + (ATA_REG_ERR << info->stepping); | 407 | ioaddr->error_addr = cmd + (ATA_REG_ERR << port->stepping); |
406 | ioaddr->feature_addr = cmd + (ATA_REG_FEATURE << info->stepping); | 408 | ioaddr->feature_addr = cmd + (ATA_REG_FEATURE << port->stepping); |
407 | ioaddr->nsect_addr = cmd + (ATA_REG_NSECT << info->stepping); | 409 | ioaddr->nsect_addr = cmd + (ATA_REG_NSECT << port->stepping); |
408 | ioaddr->lbal_addr = cmd + (ATA_REG_LBAL << info->stepping); | 410 | ioaddr->lbal_addr = cmd + (ATA_REG_LBAL << port->stepping); |
409 | ioaddr->lbam_addr = cmd + (ATA_REG_LBAM << info->stepping); | 411 | ioaddr->lbam_addr = cmd + (ATA_REG_LBAM << port->stepping); |
410 | ioaddr->lbah_addr = cmd + (ATA_REG_LBAH << info->stepping); | 412 | ioaddr->lbah_addr = cmd + (ATA_REG_LBAH << port->stepping); |
411 | ioaddr->device_addr = cmd + (ATA_REG_DEVICE << info->stepping); | 413 | ioaddr->device_addr = cmd + (ATA_REG_DEVICE << port->stepping); |
412 | ioaddr->status_addr = cmd + (ATA_REG_STATUS << info->stepping); | 414 | ioaddr->status_addr = cmd + (ATA_REG_STATUS << port->stepping); |
413 | ioaddr->command_addr = cmd + (ATA_REG_CMD << info->stepping); | 415 | ioaddr->command_addr = cmd + (ATA_REG_CMD << port->stepping); |
414 | 416 | ||
415 | ioaddr->ctl_addr = base + info->ctrloffset; | 417 | ioaddr->ctl_addr = base + port->ctrloffset; |
416 | ioaddr->altstatus_addr = ioaddr->ctl_addr; | 418 | ioaddr->altstatus_addr = ioaddr->ctl_addr; |
417 | 419 | ||
418 | ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", | 420 | ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", |
419 | info->raw_base + info->dataoffset, | 421 | info->raw_base + port->dataoffset, |
420 | info->raw_base + info->ctrloffset); | 422 | info->raw_base + port->ctrloffset); |
421 | 423 | ||
422 | if (info->raw_ioc_base) | 424 | if (info->raw_ioc_base) |
423 | ata_port_desc(ap, "iocbase 0x%lx", info->raw_ioc_base); | 425 | ata_port_desc(ap, "iocbase 0x%lx", info->raw_ioc_base); |
@@ -441,7 +443,7 @@ static int __devinit pata_icside_register_v5(struct pata_icside_info *info) | |||
441 | info->nr_ports = 1; | 443 | info->nr_ports = 1; |
442 | info->port[0] = &pata_icside_portinfo_v5; | 444 | info->port[0] = &pata_icside_portinfo_v5; |
443 | 445 | ||
444 | info->raw_base = ecard_resource_start(ec, ECARD_RES_MEMC); | 446 | info->raw_base = ecard_resource_start(info->ec, ECARD_RES_MEMC); |
445 | 447 | ||
446 | return 0; | 448 | return 0; |
447 | } | 449 | } |
@@ -522,7 +524,7 @@ static int __devinit pata_icside_add_ports(struct pata_icside_info *info) | |||
522 | ap->flags |= ATA_FLAG_SLAVE_POSS; | 524 | ap->flags |= ATA_FLAG_SLAVE_POSS; |
523 | ap->ops = &pata_icside_port_ops; | 525 | ap->ops = &pata_icside_port_ops; |
524 | 526 | ||
525 | pata_icside_setup_ioaddr(ap, info->base, info->port[i]); | 527 | pata_icside_setup_ioaddr(ap, info->base, info, info->port[i]); |
526 | } | 528 | } |
527 | 529 | ||
528 | return ata_host_activate(host, ec->irq, ata_interrupt, 0, | 530 | return ata_host_activate(host, ec->irq, ata_interrupt, 0, |
diff --git a/drivers/ata/pata_ns87415.c b/drivers/ata/pata_ns87415.c index b9a17eb100d0..d0e2e50823b1 100644 --- a/drivers/ata/pata_ns87415.c +++ b/drivers/ata/pata_ns87415.c | |||
@@ -215,6 +215,8 @@ static int ns87415_check_atapi_dma(struct ata_queued_cmd *qc) | |||
215 | 215 | ||
216 | #include <asm/superio.h> | 216 | #include <asm/superio.h> |
217 | 217 | ||
218 | #define SUPERIO_IDE_MAX_RETRIES 25 | ||
219 | |||
218 | /** | 220 | /** |
219 | * ns87560_read_buggy - workaround buggy Super I/O chip | 221 | * ns87560_read_buggy - workaround buggy Super I/O chip |
220 | * @port: Port to read | 222 | * @port: Port to read |
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c index 6b07b5b48532..f9b485a487ae 100644 --- a/drivers/ata/pata_optidma.c +++ b/drivers/ata/pata_optidma.c | |||
@@ -449,7 +449,7 @@ static int optiplus_with_udma(struct pci_dev *pdev) | |||
449 | 449 | ||
450 | /* Find function 1 */ | 450 | /* Find function 1 */ |
451 | dev1 = pci_get_device(0x1045, 0xC701, NULL); | 451 | dev1 = pci_get_device(0x1045, 0xC701, NULL); |
452 | if(dev1 == NULL) | 452 | if (dev1 == NULL) |
453 | return 0; | 453 | return 0; |
454 | 454 | ||
455 | /* Rev must be >= 0x10 */ | 455 | /* Rev must be >= 0x10 */ |
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 5db2013230b3..fd36099428a4 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -74,8 +74,7 @@ static int pcmcia_set_mode(struct ata_link *link, struct ata_device **r_failed_d | |||
74 | return ata_do_set_mode(link, r_failed_dev); | 74 | return ata_do_set_mode(link, r_failed_dev); |
75 | 75 | ||
76 | if (memcmp(master->id + ATA_ID_FW_REV, slave->id + ATA_ID_FW_REV, | 76 | if (memcmp(master->id + ATA_ID_FW_REV, slave->id + ATA_ID_FW_REV, |
77 | ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0) | 77 | ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0) { |
78 | { | ||
79 | /* Suspicious match, but could be two cards from | 78 | /* Suspicious match, but could be two cards from |
80 | the same vendor - check serial */ | 79 | the same vendor - check serial */ |
81 | if (memcmp(master->id + ATA_ID_SERNO, slave->id + ATA_ID_SERNO, | 80 | if (memcmp(master->id + ATA_ID_SERNO, slave->id + ATA_ID_SERNO, |
@@ -248,7 +247,8 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) | |||
248 | goto next_entry; | 247 | goto next_entry; |
249 | io_base = pdev->io.BasePort1; | 248 | io_base = pdev->io.BasePort1; |
250 | ctl_base = pdev->io.BasePort1 + 0x0e; | 249 | ctl_base = pdev->io.BasePort1 + 0x0e; |
251 | } else goto next_entry; | 250 | } else |
251 | goto next_entry; | ||
252 | /* If we've got this far, we're done */ | 252 | /* If we've got this far, we're done */ |
253 | break; | 253 | break; |
254 | } | 254 | } |
@@ -285,8 +285,8 @@ next_entry: | |||
285 | printk(KERN_WARNING DRV_NAME ": second channel not yet supported.\n"); | 285 | printk(KERN_WARNING DRV_NAME ": second channel not yet supported.\n"); |
286 | 286 | ||
287 | /* | 287 | /* |
288 | * Having done the PCMCIA plumbing the ATA side is relatively | 288 | * Having done the PCMCIA plumbing the ATA side is relatively |
289 | * sane. | 289 | * sane. |
290 | */ | 290 | */ |
291 | ret = -ENOMEM; | 291 | ret = -ENOMEM; |
292 | host = ata_host_alloc(&pdev->dev, 1); | 292 | host = ata_host_alloc(&pdev->dev, 1); |
@@ -363,7 +363,7 @@ static struct pcmcia_device_id pcmcia_devices[] = { | |||
363 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ | 363 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ |
364 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), | 364 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), |
365 | PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ | 365 | PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ |
366 | PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */ | 366 | PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */ |
367 | PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), | 367 | PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), |
368 | PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0100), /* Viking CFA */ | 368 | PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0100), /* Viking CFA */ |
369 | PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar, Viking CFA */ | 369 | PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar, Viking CFA */ |
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c index 3d3f1558cdee..2622577521a1 100644 --- a/drivers/ata/pata_pdc2027x.c +++ b/drivers/ata/pata_pdc2027x.c | |||
@@ -348,7 +348,7 @@ static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned long | |||
348 | ata_id_c_string(pair->id, model_num, ATA_ID_PROD, | 348 | ata_id_c_string(pair->id, model_num, ATA_ID_PROD, |
349 | ATA_ID_PROD_LEN + 1); | 349 | ATA_ID_PROD_LEN + 1); |
350 | /* If the master is a maxtor in UDMA6 then the slave should not use UDMA 6 */ | 350 | /* If the master is a maxtor in UDMA6 then the slave should not use UDMA 6 */ |
351 | if(strstr(model_num, "Maxtor") == 0 && pair->dma_mode == XFER_UDMA_6) | 351 | if (strstr(model_num, "Maxtor") == 0 && pair->dma_mode == XFER_UDMA_6) |
352 | mask &= ~ (1 << (6 + ATA_SHIFT_UDMA)); | 352 | mask &= ~ (1 << (6 + ATA_SHIFT_UDMA)); |
353 | 353 | ||
354 | return ata_pci_default_filter(adev, mask); | 354 | return ata_pci_default_filter(adev, mask); |
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c index 65d951618c60..bc7c2d5d8d5e 100644 --- a/drivers/ata/pata_pdc202xx_old.c +++ b/drivers/ata/pata_pdc202xx_old.c | |||
@@ -351,9 +351,9 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id | |||
351 | struct pci_dev *bridge = dev->bus->self; | 351 | struct pci_dev *bridge = dev->bus->self; |
352 | /* Don't grab anything behind a Promise I2O RAID */ | 352 | /* Don't grab anything behind a Promise I2O RAID */ |
353 | if (bridge && bridge->vendor == PCI_VENDOR_ID_INTEL) { | 353 | if (bridge && bridge->vendor == PCI_VENDOR_ID_INTEL) { |
354 | if( bridge->device == PCI_DEVICE_ID_INTEL_I960) | 354 | if (bridge->device == PCI_DEVICE_ID_INTEL_I960) |
355 | return -ENODEV; | 355 | return -ENODEV; |
356 | if( bridge->device == PCI_DEVICE_ID_INTEL_I960RM) | 356 | if (bridge->device == PCI_DEVICE_ID_INTEL_I960RM) |
357 | return -ENODEV; | 357 | return -ENODEV; |
358 | } | 358 | } |
359 | } | 359 | } |
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c index 55576138faea..ea2ef9fc15be 100644 --- a/drivers/ata/pata_scc.c +++ b/drivers/ata/pata_scc.c | |||
@@ -570,17 +570,8 @@ static unsigned int scc_bus_softreset(struct ata_port *ap, unsigned int devmask, | |||
570 | udelay(20); | 570 | udelay(20); |
571 | out_be32(ioaddr->ctl_addr, ap->ctl); | 571 | out_be32(ioaddr->ctl_addr, ap->ctl); |
572 | 572 | ||
573 | /* spec mandates ">= 2ms" before checking status. | 573 | /* wait a while before checking status */ |
574 | * We wait 150ms, because that was the magic delay used for | 574 | ata_wait_after_reset(ap, deadline); |
575 | * ATAPI devices in Hale Landis's ATADRVR, for the period of time | ||
576 | * between when the ATA command register is written, and then | ||
577 | * status is checked. Because waiting for "a while" before | ||
578 | * checking status is fine, post SRST, we perform this magic | ||
579 | * delay here as well. | ||
580 | * | ||
581 | * Old drivers/ide uses the 2mS rule and then waits for ready | ||
582 | */ | ||
583 | msleep(150); | ||
584 | 575 | ||
585 | /* Before we perform post reset processing we want to see if | 576 | /* Before we perform post reset processing we want to see if |
586 | * the bus shows 0xFF because the odd clown forgets the D7 | 577 | * the bus shows 0xFF because the odd clown forgets the D7 |
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index ea7a9a652e61..a4175fbdd170 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c | |||
@@ -176,7 +176,7 @@ static int via_cable_detect(struct ata_port *ap) { | |||
176 | if ((config->flags & VIA_UDMA) < VIA_UDMA_66) | 176 | if ((config->flags & VIA_UDMA) < VIA_UDMA_66) |
177 | return ATA_CBL_PATA40; | 177 | return ATA_CBL_PATA40; |
178 | /* UDMA 66 chips have only drive side logic */ | 178 | /* UDMA 66 chips have only drive side logic */ |
179 | else if((config->flags & VIA_UDMA) < VIA_UDMA_100) | 179 | else if ((config->flags & VIA_UDMA) < VIA_UDMA_100) |
180 | return ATA_CBL_PATA_UNK; | 180 | return ATA_CBL_PATA_UNK; |
181 | /* UDMA 100 or later */ | 181 | /* UDMA 100 or later */ |
182 | pci_read_config_dword(pdev, 0x50, &ata66); | 182 | pci_read_config_dword(pdev, 0x50, &ata66); |
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c index 549cbbe9fd07..311cdb3a5566 100644 --- a/drivers/ata/pata_winbond.c +++ b/drivers/ata/pata_winbond.c | |||
@@ -279,7 +279,7 @@ static __init int winbond_init(void) | |||
279 | 279 | ||
280 | if (request_region(port, 2, "pata_winbond")) { | 280 | if (request_region(port, 2, "pata_winbond")) { |
281 | ret = winbond_init_one(port); | 281 | ret = winbond_init_one(port); |
282 | if(ret <= 0) | 282 | if (ret <= 0) |
283 | release_region(port, 2); | 283 | release_region(port, 2); |
284 | else ct+= ret; | 284 | else ct+= ret; |
285 | } | 285 | } |
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c index 199f7e150eb3..bd4c2a3c88d7 100644 --- a/drivers/ata/pdc_adma.c +++ b/drivers/ata/pdc_adma.c | |||
@@ -47,10 +47,10 @@ | |||
47 | #define DRV_VERSION "1.0" | 47 | #define DRV_VERSION "1.0" |
48 | 48 | ||
49 | /* macro to calculate base address for ATA regs */ | 49 | /* macro to calculate base address for ATA regs */ |
50 | #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) | 50 | #define ADMA_ATA_REGS(base, port_no) ((base) + ((port_no) * 0x40)) |
51 | 51 | ||
52 | /* macro to calculate base address for ADMA regs */ | 52 | /* macro to calculate base address for ADMA regs */ |
53 | #define ADMA_REGS(base,port_no) ((base) + 0x80 + ((port_no) * 0x20)) | 53 | #define ADMA_REGS(base, port_no) ((base) + 0x80 + ((port_no) * 0x20)) |
54 | 54 | ||
55 | /* macro to obtain addresses from ata_port */ | 55 | /* macro to obtain addresses from ata_port */ |
56 | #define ADMA_PORT_REGS(ap) \ | 56 | #define ADMA_PORT_REGS(ap) \ |
@@ -128,7 +128,7 @@ struct adma_port_priv { | |||
128 | adma_state_t state; | 128 | adma_state_t state; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | static int adma_ata_init_one (struct pci_dev *pdev, | 131 | static int adma_ata_init_one(struct pci_dev *pdev, |
132 | const struct pci_device_id *ent); | 132 | const struct pci_device_id *ent); |
133 | static int adma_port_start(struct ata_port *ap); | 133 | static int adma_port_start(struct ata_port *ap); |
134 | static void adma_host_stop(struct ata_host *host); | 134 | static void adma_host_stop(struct ata_host *host); |
@@ -340,8 +340,8 @@ static int adma_fill_sg(struct ata_queued_cmd *qc) | |||
340 | buf[i++] = 0; /* pPKLW */ | 340 | buf[i++] = 0; /* pPKLW */ |
341 | buf[i++] = 0; /* reserved */ | 341 | buf[i++] = 0; /* reserved */ |
342 | 342 | ||
343 | *(__le32 *)(buf + i) | 343 | *(__le32 *)(buf + i) = |
344 | = (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4); | 344 | (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4); |
345 | i += 4; | 345 | i += 4; |
346 | 346 | ||
347 | VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4, | 347 | VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4, |
@@ -617,7 +617,7 @@ static int adma_port_start(struct ata_port *ap) | |||
617 | return -ENOMEM; | 617 | return -ENOMEM; |
618 | /* paranoia? */ | 618 | /* paranoia? */ |
619 | if ((pp->pkt_dma & 7) != 0) { | 619 | if ((pp->pkt_dma & 7) != 0) { |
620 | printk("bad alignment for pp->pkt_dma: %08x\n", | 620 | printk(KERN_ERR "bad alignment for pp->pkt_dma: %08x\n", |
621 | (u32)pp->pkt_dma); | 621 | (u32)pp->pkt_dma); |
622 | return -ENOMEM; | 622 | return -ENOMEM; |
623 | } | 623 | } |
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c index 08595f34b3e8..323c087e8cc1 100644 --- a/drivers/ata/sata_inic162x.c +++ b/drivers/ata/sata_inic162x.c | |||
@@ -143,7 +143,7 @@ static const int scr_map[] = { | |||
143 | [SCR_CONTROL] = 2, | 143 | [SCR_CONTROL] = 2, |
144 | }; | 144 | }; |
145 | 145 | ||
146 | static void __iomem * inic_port_base(struct ata_port *ap) | 146 | static void __iomem *inic_port_base(struct ata_port *ap) |
147 | { | 147 | { |
148 | return ap->host->iomap[MMIO_BAR] + ap->port_no * PORT_SIZE; | 148 | return ap->host->iomap[MMIO_BAR] + ap->port_no * PORT_SIZE; |
149 | } | 149 | } |
@@ -448,7 +448,7 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class, | |||
448 | struct ata_taskfile tf; | 448 | struct ata_taskfile tf; |
449 | 449 | ||
450 | /* wait a while before checking status */ | 450 | /* wait a while before checking status */ |
451 | msleep(150); | 451 | ata_wait_after_reset(ap, deadline); |
452 | 452 | ||
453 | rc = ata_wait_ready(ap, deadline); | 453 | rc = ata_wait_ready(ap, deadline); |
454 | /* link occupied, -ENODEV too is an error */ | 454 | /* link occupied, -ENODEV too is an error */ |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index b39648f0914b..a43f64d2775b 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -1156,7 +1156,7 @@ static void mv_fill_sg(struct ata_queued_cmd *qc) | |||
1156 | last_sg->flags_size |= cpu_to_le32(EPRD_FLAG_END_OF_TBL); | 1156 | last_sg->flags_size |= cpu_to_le32(EPRD_FLAG_END_OF_TBL); |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | static inline void mv_crqb_pack_cmd(__le16 *cmdw, u8 data, u8 addr, unsigned last) | 1159 | static void mv_crqb_pack_cmd(__le16 *cmdw, u8 data, u8 addr, unsigned last) |
1160 | { | 1160 | { |
1161 | u16 tmp = data | (addr << CRQB_CMD_ADDR_SHIFT) | CRQB_CMD_CS | | 1161 | u16 tmp = data | (addr << CRQB_CMD_ADDR_SHIFT) | CRQB_CMD_CS | |
1162 | (last ? CRQB_CMD_LAST : 0); | 1162 | (last ? CRQB_CMD_LAST : 0); |
@@ -2429,7 +2429,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx) | |||
2429 | struct mv_host_priv *hpriv = host->private_data; | 2429 | struct mv_host_priv *hpriv = host->private_data; |
2430 | u32 hp_flags = hpriv->hp_flags; | 2430 | u32 hp_flags = hpriv->hp_flags; |
2431 | 2431 | ||
2432 | switch(board_idx) { | 2432 | switch (board_idx) { |
2433 | case chip_5080: | 2433 | case chip_5080: |
2434 | hpriv->ops = &mv5xxx_ops; | 2434 | hpriv->ops = &mv5xxx_ops; |
2435 | hp_flags |= MV_HP_GEN_I; | 2435 | hp_flags |= MV_HP_GEN_I; |
@@ -2510,7 +2510,8 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx) | |||
2510 | break; | 2510 | break; |
2511 | 2511 | ||
2512 | default: | 2512 | default: |
2513 | printk(KERN_ERR DRV_NAME ": BUG: invalid board index %u\n", board_idx); | 2513 | dev_printk(KERN_ERR, &pdev->dev, |
2514 | "BUG: invalid board index %u\n", board_idx); | ||
2514 | return 1; | 2515 | return 1; |
2515 | } | 2516 | } |
2516 | 2517 | ||
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 2e0279fdd7aa..35b2df297527 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -291,7 +291,7 @@ struct nv_swncq_port_priv { | |||
291 | }; | 291 | }; |
292 | 292 | ||
293 | 293 | ||
294 | #define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & ( 1 << (19 + (12 * (PORT))))) | 294 | #define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & (1 << (19 + (12 * (PORT))))) |
295 | 295 | ||
296 | static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 296 | static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
297 | #ifdef CONFIG_PM | 297 | #ifdef CONFIG_PM |
@@ -365,9 +365,9 @@ static const struct pci_device_id nv_pci_tbl[] = { | |||
365 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2), SWNCQ }, | 365 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2), SWNCQ }, |
366 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA), SWNCQ }, | 366 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA), SWNCQ }, |
367 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2), SWNCQ }, | 367 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2), SWNCQ }, |
368 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), SWNCQ }, | 368 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC }, |
369 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), SWNCQ }, | 369 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC }, |
370 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), SWNCQ }, | 370 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC }, |
371 | 371 | ||
372 | { } /* terminate list */ | 372 | { } /* terminate list */ |
373 | }; | 373 | }; |
@@ -884,8 +884,9 @@ static int nv_adma_check_cpb(struct ata_port *ap, int cpb_num, int force_err) | |||
884 | /* Notifier bits set without a command may indicate the drive | 884 | /* Notifier bits set without a command may indicate the drive |
885 | is misbehaving. Raise host state machine violation on this | 885 | is misbehaving. Raise host state machine violation on this |
886 | condition. */ | 886 | condition. */ |
887 | ata_port_printk(ap, KERN_ERR, "notifier for tag %d with no command?\n", | 887 | ata_port_printk(ap, KERN_ERR, |
888 | cpb_num); | 888 | "notifier for tag %d with no cmd?\n", |
889 | cpb_num); | ||
889 | ehi->err_mask |= AC_ERR_HSM; | 890 | ehi->err_mask |= AC_ERR_HSM; |
890 | ehi->action |= ATA_EH_SOFTRESET; | 891 | ehi->action |= ATA_EH_SOFTRESET; |
891 | ata_port_freeze(ap); | 892 | ata_port_freeze(ap); |
@@ -1012,7 +1013,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
1012 | u32 check_commands; | 1013 | u32 check_commands; |
1013 | int pos, error = 0; | 1014 | int pos, error = 0; |
1014 | 1015 | ||
1015 | if(ata_tag_valid(ap->link.active_tag)) | 1016 | if (ata_tag_valid(ap->link.active_tag)) |
1016 | check_commands = 1 << ap->link.active_tag; | 1017 | check_commands = 1 << ap->link.active_tag; |
1017 | else | 1018 | else |
1018 | check_commands = ap->link.sactive; | 1019 | check_commands = ap->link.sactive; |
@@ -1021,14 +1022,14 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
1021 | while ((pos = ffs(check_commands)) && !error) { | 1022 | while ((pos = ffs(check_commands)) && !error) { |
1022 | pos--; | 1023 | pos--; |
1023 | error = nv_adma_check_cpb(ap, pos, | 1024 | error = nv_adma_check_cpb(ap, pos, |
1024 | notifier_error & (1 << pos) ); | 1025 | notifier_error & (1 << pos)); |
1025 | check_commands &= ~(1 << pos ); | 1026 | check_commands &= ~(1 << pos); |
1026 | } | 1027 | } |
1027 | } | 1028 | } |
1028 | } | 1029 | } |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | if(notifier_clears[0] || notifier_clears[1]) { | 1032 | if (notifier_clears[0] || notifier_clears[1]) { |
1032 | /* Note: Both notifier clear registers must be written | 1033 | /* Note: Both notifier clear registers must be written |
1033 | if either is set, even if one is zero, according to NVIDIA. */ | 1034 | if either is set, even if one is zero, according to NVIDIA. */ |
1034 | struct nv_adma_port_priv *pp = host->ports[0]->private_data; | 1035 | struct nv_adma_port_priv *pp = host->ports[0]->private_data; |
@@ -1061,7 +1062,7 @@ static void nv_adma_freeze(struct ata_port *ap) | |||
1061 | tmp = readw(mmio + NV_ADMA_CTL); | 1062 | tmp = readw(mmio + NV_ADMA_CTL); |
1062 | writew(tmp & ~(NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), | 1063 | writew(tmp & ~(NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), |
1063 | mmio + NV_ADMA_CTL); | 1064 | mmio + NV_ADMA_CTL); |
1064 | readw(mmio + NV_ADMA_CTL ); /* flush posted write */ | 1065 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1065 | } | 1066 | } |
1066 | 1067 | ||
1067 | static void nv_adma_thaw(struct ata_port *ap) | 1068 | static void nv_adma_thaw(struct ata_port *ap) |
@@ -1079,7 +1080,7 @@ static void nv_adma_thaw(struct ata_port *ap) | |||
1079 | tmp = readw(mmio + NV_ADMA_CTL); | 1080 | tmp = readw(mmio + NV_ADMA_CTL); |
1080 | writew(tmp | (NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), | 1081 | writew(tmp | (NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), |
1081 | mmio + NV_ADMA_CTL); | 1082 | mmio + NV_ADMA_CTL); |
1082 | readw(mmio + NV_ADMA_CTL ); /* flush posted write */ | 1083 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1083 | } | 1084 | } |
1084 | 1085 | ||
1085 | static void nv_adma_irq_clear(struct ata_port *ap) | 1086 | static void nv_adma_irq_clear(struct ata_port *ap) |
@@ -1119,7 +1120,7 @@ static void nv_adma_post_internal_cmd(struct ata_queued_cmd *qc) | |||
1119 | { | 1120 | { |
1120 | struct nv_adma_port_priv *pp = qc->ap->private_data; | 1121 | struct nv_adma_port_priv *pp = qc->ap->private_data; |
1121 | 1122 | ||
1122 | if(pp->flags & NV_ADMA_PORT_REGISTER_MODE) | 1123 | if (pp->flags & NV_ADMA_PORT_REGISTER_MODE) |
1123 | ata_bmdma_post_internal_cmd(qc); | 1124 | ata_bmdma_post_internal_cmd(qc); |
1124 | } | 1125 | } |
1125 | 1126 | ||
@@ -1165,7 +1166,7 @@ static int nv_adma_port_start(struct ata_port *ap) | |||
1165 | pp->cpb_dma = mem_dma; | 1166 | pp->cpb_dma = mem_dma; |
1166 | 1167 | ||
1167 | writel(mem_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); | 1168 | writel(mem_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); |
1168 | writel((mem_dma >> 16 ) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); | 1169 | writel((mem_dma >> 16) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); |
1169 | 1170 | ||
1170 | mem += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; | 1171 | mem += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; |
1171 | mem_dma += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; | 1172 | mem_dma += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; |
@@ -1189,15 +1190,15 @@ static int nv_adma_port_start(struct ata_port *ap) | |||
1189 | 1190 | ||
1190 | /* clear GO for register mode, enable interrupt */ | 1191 | /* clear GO for register mode, enable interrupt */ |
1191 | tmp = readw(mmio + NV_ADMA_CTL); | 1192 | tmp = readw(mmio + NV_ADMA_CTL); |
1192 | writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | | 1193 | writew((tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | |
1193 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); | 1194 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); |
1194 | 1195 | ||
1195 | tmp = readw(mmio + NV_ADMA_CTL); | 1196 | tmp = readw(mmio + NV_ADMA_CTL); |
1196 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1197 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1197 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1198 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1198 | udelay(1); | 1199 | udelay(1); |
1199 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1200 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1200 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1201 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1201 | 1202 | ||
1202 | return 0; | 1203 | return 0; |
1203 | } | 1204 | } |
@@ -1237,7 +1238,7 @@ static int nv_adma_port_resume(struct ata_port *ap) | |||
1237 | 1238 | ||
1238 | /* set CPB block location */ | 1239 | /* set CPB block location */ |
1239 | writel(pp->cpb_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); | 1240 | writel(pp->cpb_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); |
1240 | writel((pp->cpb_dma >> 16 ) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); | 1241 | writel((pp->cpb_dma >> 16) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); |
1241 | 1242 | ||
1242 | /* clear any outstanding interrupt conditions */ | 1243 | /* clear any outstanding interrupt conditions */ |
1243 | writew(0xffff, mmio + NV_ADMA_STAT); | 1244 | writew(0xffff, mmio + NV_ADMA_STAT); |
@@ -1250,15 +1251,15 @@ static int nv_adma_port_resume(struct ata_port *ap) | |||
1250 | 1251 | ||
1251 | /* clear GO for register mode, enable interrupt */ | 1252 | /* clear GO for register mode, enable interrupt */ |
1252 | tmp = readw(mmio + NV_ADMA_CTL); | 1253 | tmp = readw(mmio + NV_ADMA_CTL); |
1253 | writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | | 1254 | writew((tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | |
1254 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); | 1255 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); |
1255 | 1256 | ||
1256 | tmp = readw(mmio + NV_ADMA_CTL); | 1257 | tmp = readw(mmio + NV_ADMA_CTL); |
1257 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1258 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1258 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1259 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1259 | udelay(1); | 1260 | udelay(1); |
1260 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1261 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1261 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1262 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1262 | 1263 | ||
1263 | return 0; | 1264 | return 0; |
1264 | } | 1265 | } |
@@ -1342,7 +1343,8 @@ static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb) | |||
1342 | idx = 0; | 1343 | idx = 0; |
1343 | 1344 | ||
1344 | ata_for_each_sg(sg, qc) { | 1345 | ata_for_each_sg(sg, qc) { |
1345 | aprd = (idx < 5) ? &cpb->aprd[idx] : &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (idx-5)]; | 1346 | aprd = (idx < 5) ? &cpb->aprd[idx] : |
1347 | &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (idx-5)]; | ||
1346 | nv_adma_fill_aprd(qc, sg, idx, aprd); | 1348 | nv_adma_fill_aprd(qc, sg, idx, aprd); |
1347 | idx++; | 1349 | idx++; |
1348 | } | 1350 | } |
@@ -1359,12 +1361,12 @@ static int nv_adma_use_reg_mode(struct ata_queued_cmd *qc) | |||
1359 | /* ADMA engine can only be used for non-ATAPI DMA commands, | 1361 | /* ADMA engine can only be used for non-ATAPI DMA commands, |
1360 | or interrupt-driven no-data commands, where a result taskfile | 1362 | or interrupt-driven no-data commands, where a result taskfile |
1361 | is not required. */ | 1363 | is not required. */ |
1362 | if((pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) || | 1364 | if ((pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) || |
1363 | (qc->tf.flags & ATA_TFLAG_POLLING) || | 1365 | (qc->tf.flags & ATA_TFLAG_POLLING) || |
1364 | (qc->flags & ATA_QCFLAG_RESULT_TF)) | 1366 | (qc->flags & ATA_QCFLAG_RESULT_TF)) |
1365 | return 1; | 1367 | return 1; |
1366 | 1368 | ||
1367 | if((qc->flags & ATA_QCFLAG_DMAMAP) || | 1369 | if ((qc->flags & ATA_QCFLAG_DMAMAP) || |
1368 | (qc->tf.protocol == ATA_PROT_NODATA)) | 1370 | (qc->tf.protocol == ATA_PROT_NODATA)) |
1369 | return 0; | 1371 | return 0; |
1370 | 1372 | ||
@@ -1401,14 +1403,14 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc) | |||
1401 | 1403 | ||
1402 | nv_adma_tf_to_cpb(&qc->tf, cpb->tf); | 1404 | nv_adma_tf_to_cpb(&qc->tf, cpb->tf); |
1403 | 1405 | ||
1404 | if(qc->flags & ATA_QCFLAG_DMAMAP) { | 1406 | if (qc->flags & ATA_QCFLAG_DMAMAP) { |
1405 | nv_adma_fill_sg(qc, cpb); | 1407 | nv_adma_fill_sg(qc, cpb); |
1406 | ctl_flags |= NV_CPB_CTL_APRD_VALID; | 1408 | ctl_flags |= NV_CPB_CTL_APRD_VALID; |
1407 | } else | 1409 | } else |
1408 | memset(&cpb->aprd[0], 0, sizeof(struct nv_adma_prd) * 5); | 1410 | memset(&cpb->aprd[0], 0, sizeof(struct nv_adma_prd) * 5); |
1409 | 1411 | ||
1410 | /* Be paranoid and don't let the device see NV_CPB_CTL_CPB_VALID until we are | 1412 | /* Be paranoid and don't let the device see NV_CPB_CTL_CPB_VALID |
1411 | finished filling in all of the contents */ | 1413 | until we are finished filling in all of the contents */ |
1412 | wmb(); | 1414 | wmb(); |
1413 | cpb->ctl_flags = ctl_flags; | 1415 | cpb->ctl_flags = ctl_flags; |
1414 | wmb(); | 1416 | wmb(); |
@@ -1435,16 +1437,16 @@ static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc) | |||
1435 | and (number of cpbs to append -1) in top 8 bits */ | 1437 | and (number of cpbs to append -1) in top 8 bits */ |
1436 | wmb(); | 1438 | wmb(); |
1437 | 1439 | ||
1438 | if(curr_ncq != pp->last_issue_ncq) { | 1440 | if (curr_ncq != pp->last_issue_ncq) { |
1439 | /* Seems to need some delay before switching between NCQ and non-NCQ | 1441 | /* Seems to need some delay before switching between NCQ and |
1440 | commands, else we get command timeouts and such. */ | 1442 | non-NCQ commands, else we get command timeouts and such. */ |
1441 | udelay(20); | 1443 | udelay(20); |
1442 | pp->last_issue_ncq = curr_ncq; | 1444 | pp->last_issue_ncq = curr_ncq; |
1443 | } | 1445 | } |
1444 | 1446 | ||
1445 | writew(qc->tag, mmio + NV_ADMA_APPEND); | 1447 | writew(qc->tag, mmio + NV_ADMA_APPEND); |
1446 | 1448 | ||
1447 | DPRINTK("Issued tag %u\n",qc->tag); | 1449 | DPRINTK("Issued tag %u\n", qc->tag); |
1448 | 1450 | ||
1449 | return 0; | 1451 | return 0; |
1450 | } | 1452 | } |
@@ -1641,12 +1643,12 @@ static void nv_error_handler(struct ata_port *ap) | |||
1641 | static void nv_adma_error_handler(struct ata_port *ap) | 1643 | static void nv_adma_error_handler(struct ata_port *ap) |
1642 | { | 1644 | { |
1643 | struct nv_adma_port_priv *pp = ap->private_data; | 1645 | struct nv_adma_port_priv *pp = ap->private_data; |
1644 | if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) { | 1646 | if (!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) { |
1645 | void __iomem *mmio = pp->ctl_block; | 1647 | void __iomem *mmio = pp->ctl_block; |
1646 | int i; | 1648 | int i; |
1647 | u16 tmp; | 1649 | u16 tmp; |
1648 | 1650 | ||
1649 | if(ata_tag_valid(ap->link.active_tag) || ap->link.sactive) { | 1651 | if (ata_tag_valid(ap->link.active_tag) || ap->link.sactive) { |
1650 | u32 notifier = readl(mmio + NV_ADMA_NOTIFIER); | 1652 | u32 notifier = readl(mmio + NV_ADMA_NOTIFIER); |
1651 | u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR); | 1653 | u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR); |
1652 | u32 gen_ctl = readl(pp->gen_block + NV_ADMA_GEN_CTL); | 1654 | u32 gen_ctl = readl(pp->gen_block + NV_ADMA_GEN_CTL); |
@@ -1654,16 +1656,17 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1654 | u8 cpb_count = readb(mmio + NV_ADMA_CPB_COUNT); | 1656 | u8 cpb_count = readb(mmio + NV_ADMA_CPB_COUNT); |
1655 | u8 next_cpb_idx = readb(mmio + NV_ADMA_NEXT_CPB_IDX); | 1657 | u8 next_cpb_idx = readb(mmio + NV_ADMA_NEXT_CPB_IDX); |
1656 | 1658 | ||
1657 | ata_port_printk(ap, KERN_ERR, "EH in ADMA mode, notifier 0x%X " | 1659 | ata_port_printk(ap, KERN_ERR, |
1660 | "EH in ADMA mode, notifier 0x%X " | ||
1658 | "notifier_error 0x%X gen_ctl 0x%X status 0x%X " | 1661 | "notifier_error 0x%X gen_ctl 0x%X status 0x%X " |
1659 | "next cpb count 0x%X next cpb idx 0x%x\n", | 1662 | "next cpb count 0x%X next cpb idx 0x%x\n", |
1660 | notifier, notifier_error, gen_ctl, status, | 1663 | notifier, notifier_error, gen_ctl, status, |
1661 | cpb_count, next_cpb_idx); | 1664 | cpb_count, next_cpb_idx); |
1662 | 1665 | ||
1663 | for( i=0;i<NV_ADMA_MAX_CPBS;i++) { | 1666 | for (i = 0; i < NV_ADMA_MAX_CPBS; i++) { |
1664 | struct nv_adma_cpb *cpb = &pp->cpb[i]; | 1667 | struct nv_adma_cpb *cpb = &pp->cpb[i]; |
1665 | if( (ata_tag_valid(ap->link.active_tag) && i == ap->link.active_tag) || | 1668 | if ((ata_tag_valid(ap->link.active_tag) && i == ap->link.active_tag) || |
1666 | ap->link.sactive & (1 << i) ) | 1669 | ap->link.sactive & (1 << i)) |
1667 | ata_port_printk(ap, KERN_ERR, | 1670 | ata_port_printk(ap, KERN_ERR, |
1668 | "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n", | 1671 | "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n", |
1669 | i, cpb->ctl_flags, cpb->resp_flags); | 1672 | i, cpb->ctl_flags, cpb->resp_flags); |
@@ -1673,8 +1676,9 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1673 | /* Push us back into port register mode for error handling. */ | 1676 | /* Push us back into port register mode for error handling. */ |
1674 | nv_adma_register_mode(ap); | 1677 | nv_adma_register_mode(ap); |
1675 | 1678 | ||
1676 | /* Mark all of the CPBs as invalid to prevent them from being executed */ | 1679 | /* Mark all of the CPBs as invalid to prevent them from |
1677 | for( i=0;i<NV_ADMA_MAX_CPBS;i++) | 1680 | being executed */ |
1681 | for (i = 0; i < NV_ADMA_MAX_CPBS; i++) | ||
1678 | pp->cpb[i].ctl_flags &= ~NV_CPB_CTL_CPB_VALID; | 1682 | pp->cpb[i].ctl_flags &= ~NV_CPB_CTL_CPB_VALID; |
1679 | 1683 | ||
1680 | /* clear CPB fetch count */ | 1684 | /* clear CPB fetch count */ |
@@ -1683,10 +1687,10 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1683 | /* Reset channel */ | 1687 | /* Reset channel */ |
1684 | tmp = readw(mmio + NV_ADMA_CTL); | 1688 | tmp = readw(mmio + NV_ADMA_CTL); |
1685 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1689 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1686 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1690 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1687 | udelay(1); | 1691 | udelay(1); |
1688 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1692 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1689 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1693 | readw(mmio + NV_ADMA_CTL); /* flush posted write */ |
1690 | } | 1694 | } |
1691 | 1695 | ||
1692 | ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, | 1696 | ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, |
@@ -2350,9 +2354,9 @@ static irqreturn_t nv_swncq_interrupt(int irq, void *dev_instance) | |||
2350 | return IRQ_RETVAL(handled); | 2354 | return IRQ_RETVAL(handled); |
2351 | } | 2355 | } |
2352 | 2356 | ||
2353 | static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 2357 | static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
2354 | { | 2358 | { |
2355 | static int printed_version = 0; | 2359 | static int printed_version; |
2356 | const struct ata_port_info *ppi[] = { NULL, NULL }; | 2360 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
2357 | struct ata_host *host; | 2361 | struct ata_host *host; |
2358 | struct nv_host_priv *hpriv; | 2362 | struct nv_host_priv *hpriv; |
@@ -2364,7 +2368,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2364 | // Make sure this is a SATA controller by counting the number of bars | 2368 | // Make sure this is a SATA controller by counting the number of bars |
2365 | // (NVIDIA SATA controllers will always have six bars). Otherwise, | 2369 | // (NVIDIA SATA controllers will always have six bars). Otherwise, |
2366 | // it's an IDE controller and we ignore it. | 2370 | // it's an IDE controller and we ignore it. |
2367 | for (bar=0; bar<6; bar++) | 2371 | for (bar = 0; bar < 6; bar++) |
2368 | if (pci_resource_start(pdev, bar) == 0) | 2372 | if (pci_resource_start(pdev, bar) == 0) |
2369 | return -ENODEV; | 2373 | return -ENODEV; |
2370 | 2374 | ||
@@ -2381,6 +2385,14 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2381 | type = ADMA; | 2385 | type = ADMA; |
2382 | } | 2386 | } |
2383 | 2387 | ||
2388 | if (type == SWNCQ) { | ||
2389 | if (swncq_enabled) | ||
2390 | dev_printk(KERN_NOTICE, &pdev->dev, | ||
2391 | "Using SWNCQ mode\n"); | ||
2392 | else | ||
2393 | type = GENERIC; | ||
2394 | } | ||
2395 | |||
2384 | ppi[0] = &nv_port_info[type]; | 2396 | ppi[0] = &nv_port_info[type]; |
2385 | rc = ata_pci_prepare_sff_host(pdev, ppi, &host); | 2397 | rc = ata_pci_prepare_sff_host(pdev, ppi, &host); |
2386 | if (rc) | 2398 | if (rc) |
@@ -2422,10 +2434,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2422 | rc = nv_adma_host_init(host); | 2434 | rc = nv_adma_host_init(host); |
2423 | if (rc) | 2435 | if (rc) |
2424 | return rc; | 2436 | return rc; |
2425 | } else if (type == SWNCQ && swncq_enabled) { | 2437 | } else if (type == SWNCQ) |
2426 | dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ mode\n"); | ||
2427 | nv_swncq_host_init(host); | 2438 | nv_swncq_host_init(host); |
2428 | } | ||
2429 | 2439 | ||
2430 | pci_set_master(pdev); | 2440 | pci_set_master(pdev); |
2431 | return ata_host_activate(host, pdev->irq, ppi[0]->irq_handler, | 2441 | return ata_host_activate(host, pdev->irq, ppi[0]->irq_handler, |
@@ -2440,37 +2450,37 @@ static int nv_pci_device_resume(struct pci_dev *pdev) | |||
2440 | int rc; | 2450 | int rc; |
2441 | 2451 | ||
2442 | rc = ata_pci_device_do_resume(pdev); | 2452 | rc = ata_pci_device_do_resume(pdev); |
2443 | if(rc) | 2453 | if (rc) |
2444 | return rc; | 2454 | return rc; |
2445 | 2455 | ||
2446 | if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { | 2456 | if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { |
2447 | if(hpriv->type >= CK804) { | 2457 | if (hpriv->type >= CK804) { |
2448 | u8 regval; | 2458 | u8 regval; |
2449 | 2459 | ||
2450 | pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, ®val); | 2460 | pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, ®val); |
2451 | regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN; | 2461 | regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN; |
2452 | pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval); | 2462 | pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval); |
2453 | } | 2463 | } |
2454 | if(hpriv->type == ADMA) { | 2464 | if (hpriv->type == ADMA) { |
2455 | u32 tmp32; | 2465 | u32 tmp32; |
2456 | struct nv_adma_port_priv *pp; | 2466 | struct nv_adma_port_priv *pp; |
2457 | /* enable/disable ADMA on the ports appropriately */ | 2467 | /* enable/disable ADMA on the ports appropriately */ |
2458 | pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &tmp32); | 2468 | pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &tmp32); |
2459 | 2469 | ||
2460 | pp = host->ports[0]->private_data; | 2470 | pp = host->ports[0]->private_data; |
2461 | if(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) | 2471 | if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) |
2462 | tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT0_EN | | 2472 | tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT0_EN | |
2463 | NV_MCP_SATA_CFG_20_PORT0_PWB_EN); | 2473 | NV_MCP_SATA_CFG_20_PORT0_PWB_EN); |
2464 | else | 2474 | else |
2465 | tmp32 |= (NV_MCP_SATA_CFG_20_PORT0_EN | | 2475 | tmp32 |= (NV_MCP_SATA_CFG_20_PORT0_EN | |
2466 | NV_MCP_SATA_CFG_20_PORT0_PWB_EN); | 2476 | NV_MCP_SATA_CFG_20_PORT0_PWB_EN); |
2467 | pp = host->ports[1]->private_data; | 2477 | pp = host->ports[1]->private_data; |
2468 | if(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) | 2478 | if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) |
2469 | tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT1_EN | | 2479 | tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT1_EN | |
2470 | NV_MCP_SATA_CFG_20_PORT1_PWB_EN); | 2480 | NV_MCP_SATA_CFG_20_PORT1_PWB_EN); |
2471 | else | 2481 | else |
2472 | tmp32 |= (NV_MCP_SATA_CFG_20_PORT1_EN | | 2482 | tmp32 |= (NV_MCP_SATA_CFG_20_PORT1_EN | |
2473 | NV_MCP_SATA_CFG_20_PORT1_PWB_EN); | 2483 | NV_MCP_SATA_CFG_20_PORT1_PWB_EN); |
2474 | 2484 | ||
2475 | pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, tmp32); | 2485 | pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, tmp32); |
2476 | } | 2486 | } |
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index 903213153b5d..825e717bcef9 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * sata_promise.c - Promise SATA | 2 | * sata_promise.c - Promise SATA |
3 | * | 3 | * |
4 | * Maintained by: Jeff Garzik <jgarzik@pobox.com> | 4 | * Maintained by: Jeff Garzik <jgarzik@pobox.com> |
5 | * Mikael Pettersson <mikpe@it.uu.se> | ||
5 | * Please ALWAYS copy linux-ide@vger.kernel.org | 6 | * Please ALWAYS copy linux-ide@vger.kernel.org |
6 | * on emails. | 7 | * on emails. |
7 | * | 8 | * |
@@ -45,11 +46,12 @@ | |||
45 | #include "sata_promise.h" | 46 | #include "sata_promise.h" |
46 | 47 | ||
47 | #define DRV_NAME "sata_promise" | 48 | #define DRV_NAME "sata_promise" |
48 | #define DRV_VERSION "2.10" | 49 | #define DRV_VERSION "2.11" |
49 | 50 | ||
50 | enum { | 51 | enum { |
51 | PDC_MAX_PORTS = 4, | 52 | PDC_MAX_PORTS = 4, |
52 | PDC_MMIO_BAR = 3, | 53 | PDC_MMIO_BAR = 3, |
54 | PDC_MAX_PRD = LIBATA_MAX_PRD - 1, /* -1 for ASIC PRD bug workaround */ | ||
53 | 55 | ||
54 | /* register offsets */ | 56 | /* register offsets */ |
55 | PDC_FEATURE = 0x04, /* Feature/Error reg (per port) */ | 57 | PDC_FEATURE = 0x04, /* Feature/Error reg (per port) */ |
@@ -83,10 +85,12 @@ enum { | |||
83 | PDC_PCI_SYS_ERR = (1 << 22), /* PCI system error */ | 85 | PDC_PCI_SYS_ERR = (1 << 22), /* PCI system error */ |
84 | PDC1_PCI_PARITY_ERR = (1 << 23), /* PCI parity error (from SATA150 driver) */ | 86 | PDC1_PCI_PARITY_ERR = (1 << 23), /* PCI parity error (from SATA150 driver) */ |
85 | PDC1_ERR_MASK = PDC1_PCI_PARITY_ERR, | 87 | PDC1_ERR_MASK = PDC1_PCI_PARITY_ERR, |
86 | PDC2_ERR_MASK = PDC2_HTO_ERR | PDC2_ATA_HBA_ERR | PDC2_ATA_DMA_CNT_ERR, | 88 | PDC2_ERR_MASK = PDC2_HTO_ERR | PDC2_ATA_HBA_ERR | |
87 | PDC_ERR_MASK = (PDC_PH_ERR | PDC_SH_ERR | PDC_DH_ERR | PDC_OVERRUN_ERR | 89 | PDC2_ATA_DMA_CNT_ERR, |
88 | | PDC_UNDERRUN_ERR | PDC_DRIVE_ERR | PDC_PCI_SYS_ERR | 90 | PDC_ERR_MASK = PDC_PH_ERR | PDC_SH_ERR | PDC_DH_ERR | |
89 | | PDC1_ERR_MASK | PDC2_ERR_MASK), | 91 | PDC_OVERRUN_ERR | PDC_UNDERRUN_ERR | |
92 | PDC_DRIVE_ERR | PDC_PCI_SYS_ERR | | ||
93 | PDC1_ERR_MASK | PDC2_ERR_MASK, | ||
90 | 94 | ||
91 | board_2037x = 0, /* FastTrak S150 TX2plus */ | 95 | board_2037x = 0, /* FastTrak S150 TX2plus */ |
92 | board_2037x_pata = 1, /* FastTrak S150 TX2plus PATA port */ | 96 | board_2037x_pata = 1, /* FastTrak S150 TX2plus PATA port */ |
@@ -155,7 +159,7 @@ static struct scsi_host_template pdc_ata_sht = { | |||
155 | .queuecommand = ata_scsi_queuecmd, | 159 | .queuecommand = ata_scsi_queuecmd, |
156 | .can_queue = ATA_DEF_QUEUE, | 160 | .can_queue = ATA_DEF_QUEUE, |
157 | .this_id = ATA_SHT_THIS_ID, | 161 | .this_id = ATA_SHT_THIS_ID, |
158 | .sg_tablesize = LIBATA_MAX_PRD, | 162 | .sg_tablesize = PDC_MAX_PRD, |
159 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | 163 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, |
160 | .emulated = ATA_SHT_EMULATED, | 164 | .emulated = ATA_SHT_EMULATED, |
161 | .use_clustering = ATA_SHT_USE_CLUSTERING, | 165 | .use_clustering = ATA_SHT_USE_CLUSTERING, |
@@ -238,7 +242,7 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
238 | }; | 242 | }; |
239 | 243 | ||
240 | static const struct ata_port_info pdc_port_info[] = { | 244 | static const struct ata_port_info pdc_port_info[] = { |
241 | /* board_2037x */ | 245 | [board_2037x] = |
242 | { | 246 | { |
243 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | | 247 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | |
244 | PDC_FLAG_SATA_PATA, | 248 | PDC_FLAG_SATA_PATA, |
@@ -248,7 +252,7 @@ static const struct ata_port_info pdc_port_info[] = { | |||
248 | .port_ops = &pdc_old_sata_ops, | 252 | .port_ops = &pdc_old_sata_ops, |
249 | }, | 253 | }, |
250 | 254 | ||
251 | /* board_2037x_pata */ | 255 | [board_2037x_pata] = |
252 | { | 256 | { |
253 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, | 257 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, |
254 | .pio_mask = 0x1f, /* pio0-4 */ | 258 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -257,7 +261,7 @@ static const struct ata_port_info pdc_port_info[] = { | |||
257 | .port_ops = &pdc_pata_ops, | 261 | .port_ops = &pdc_pata_ops, |
258 | }, | 262 | }, |
259 | 263 | ||
260 | /* board_20319 */ | 264 | [board_20319] = |
261 | { | 265 | { |
262 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | | 266 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | |
263 | PDC_FLAG_4_PORTS, | 267 | PDC_FLAG_4_PORTS, |
@@ -267,7 +271,7 @@ static const struct ata_port_info pdc_port_info[] = { | |||
267 | .port_ops = &pdc_old_sata_ops, | 271 | .port_ops = &pdc_old_sata_ops, |
268 | }, | 272 | }, |
269 | 273 | ||
270 | /* board_20619 */ | 274 | [board_20619] = |
271 | { | 275 | { |
272 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS | | 276 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS | |
273 | PDC_FLAG_4_PORTS, | 277 | PDC_FLAG_4_PORTS, |
@@ -277,7 +281,7 @@ static const struct ata_port_info pdc_port_info[] = { | |||
277 | .port_ops = &pdc_pata_ops, | 281 | .port_ops = &pdc_pata_ops, |
278 | }, | 282 | }, |
279 | 283 | ||
280 | /* board_2057x */ | 284 | [board_2057x] = |
281 | { | 285 | { |
282 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | | 286 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | |
283 | PDC_FLAG_GEN_II | PDC_FLAG_SATA_PATA, | 287 | PDC_FLAG_GEN_II | PDC_FLAG_SATA_PATA, |
@@ -287,7 +291,7 @@ static const struct ata_port_info pdc_port_info[] = { | |||
287 | .port_ops = &pdc_sata_ops, | 291 | .port_ops = &pdc_sata_ops, |
288 | }, | 292 | }, |
289 | 293 | ||
290 | /* board_2057x_pata */ | 294 | [board_2057x_pata] = |
291 | { | 295 | { |
292 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS | | 296 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS | |
293 | PDC_FLAG_GEN_II, | 297 | PDC_FLAG_GEN_II, |
@@ -297,7 +301,7 @@ static const struct ata_port_info pdc_port_info[] = { | |||
297 | .port_ops = &pdc_pata_ops, | 301 | .port_ops = &pdc_pata_ops, |
298 | }, | 302 | }, |
299 | 303 | ||
300 | /* board_40518 */ | 304 | [board_40518] = |
301 | { | 305 | { |
302 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | | 306 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | |
303 | PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS, | 307 | PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS, |
@@ -521,6 +525,84 @@ static void pdc_atapi_pkt(struct ata_queued_cmd *qc) | |||
521 | memcpy(buf+31, cdb, cdb_len); | 525 | memcpy(buf+31, cdb, cdb_len); |
522 | } | 526 | } |
523 | 527 | ||
528 | /** | ||
529 | * pdc_fill_sg - Fill PCI IDE PRD table | ||
530 | * @qc: Metadata associated with taskfile to be transferred | ||
531 | * | ||
532 | * Fill PCI IDE PRD (scatter-gather) table with segments | ||
533 | * associated with the current disk command. | ||
534 | * Make sure hardware does not choke on it. | ||
535 | * | ||
536 | * LOCKING: | ||
537 | * spin_lock_irqsave(host lock) | ||
538 | * | ||
539 | */ | ||
540 | static void pdc_fill_sg(struct ata_queued_cmd *qc) | ||
541 | { | ||
542 | struct ata_port *ap = qc->ap; | ||
543 | struct scatterlist *sg; | ||
544 | unsigned int idx; | ||
545 | const u32 SG_COUNT_ASIC_BUG = 41*4; | ||
546 | |||
547 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) | ||
548 | return; | ||
549 | |||
550 | WARN_ON(qc->__sg == NULL); | ||
551 | WARN_ON(qc->n_elem == 0 && qc->pad_len == 0); | ||
552 | |||
553 | idx = 0; | ||
554 | ata_for_each_sg(sg, qc) { | ||
555 | u32 addr, offset; | ||
556 | u32 sg_len, len; | ||
557 | |||
558 | /* determine if physical DMA addr spans 64K boundary. | ||
559 | * Note h/w doesn't support 64-bit, so we unconditionally | ||
560 | * truncate dma_addr_t to u32. | ||
561 | */ | ||
562 | addr = (u32) sg_dma_address(sg); | ||
563 | sg_len = sg_dma_len(sg); | ||
564 | |||
565 | while (sg_len) { | ||
566 | offset = addr & 0xffff; | ||
567 | len = sg_len; | ||
568 | if ((offset + sg_len) > 0x10000) | ||
569 | len = 0x10000 - offset; | ||
570 | |||
571 | ap->prd[idx].addr = cpu_to_le32(addr); | ||
572 | ap->prd[idx].flags_len = cpu_to_le32(len & 0xffff); | ||
573 | VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx, addr, len); | ||
574 | |||
575 | idx++; | ||
576 | sg_len -= len; | ||
577 | addr += len; | ||
578 | } | ||
579 | } | ||
580 | |||
581 | if (idx) { | ||
582 | u32 len = le32_to_cpu(ap->prd[idx - 1].flags_len); | ||
583 | |||
584 | if (len > SG_COUNT_ASIC_BUG) { | ||
585 | u32 addr; | ||
586 | |||
587 | VPRINTK("Splitting last PRD.\n"); | ||
588 | |||
589 | addr = le32_to_cpu(ap->prd[idx - 1].addr); | ||
590 | ap->prd[idx - 1].flags_len -= cpu_to_le32(SG_COUNT_ASIC_BUG); | ||
591 | VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx - 1, addr, SG_COUNT_ASIC_BUG); | ||
592 | |||
593 | addr = addr + len - SG_COUNT_ASIC_BUG; | ||
594 | len = SG_COUNT_ASIC_BUG; | ||
595 | ap->prd[idx].addr = cpu_to_le32(addr); | ||
596 | ap->prd[idx].flags_len = cpu_to_le32(len); | ||
597 | VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx, addr, len); | ||
598 | |||
599 | idx++; | ||
600 | } | ||
601 | |||
602 | ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT); | ||
603 | } | ||
604 | } | ||
605 | |||
524 | static void pdc_qc_prep(struct ata_queued_cmd *qc) | 606 | static void pdc_qc_prep(struct ata_queued_cmd *qc) |
525 | { | 607 | { |
526 | struct pdc_port_priv *pp = qc->ap->private_data; | 608 | struct pdc_port_priv *pp = qc->ap->private_data; |
@@ -530,7 +612,7 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc) | |||
530 | 612 | ||
531 | switch (qc->tf.protocol) { | 613 | switch (qc->tf.protocol) { |
532 | case ATA_PROT_DMA: | 614 | case ATA_PROT_DMA: |
533 | ata_qc_prep(qc); | 615 | pdc_fill_sg(qc); |
534 | /* fall through */ | 616 | /* fall through */ |
535 | 617 | ||
536 | case ATA_PROT_NODATA: | 618 | case ATA_PROT_NODATA: |
@@ -546,11 +628,11 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc) | |||
546 | break; | 628 | break; |
547 | 629 | ||
548 | case ATA_PROT_ATAPI: | 630 | case ATA_PROT_ATAPI: |
549 | ata_qc_prep(qc); | 631 | pdc_fill_sg(qc); |
550 | break; | 632 | break; |
551 | 633 | ||
552 | case ATA_PROT_ATAPI_DMA: | 634 | case ATA_PROT_ATAPI_DMA: |
553 | ata_qc_prep(qc); | 635 | pdc_fill_sg(qc); |
554 | /*FALLTHROUGH*/ | 636 | /*FALLTHROUGH*/ |
555 | case ATA_PROT_ATAPI_NODATA: | 637 | case ATA_PROT_ATAPI_NODATA: |
556 | pdc_atapi_pkt(qc); | 638 | pdc_atapi_pkt(qc); |
@@ -695,19 +777,20 @@ static void pdc_irq_clear(struct ata_port *ap) | |||
695 | readl(mmio + PDC_INT_SEQMASK); | 777 | readl(mmio + PDC_INT_SEQMASK); |
696 | } | 778 | } |
697 | 779 | ||
698 | static inline int pdc_is_sataii_tx4(unsigned long flags) | 780 | static int pdc_is_sataii_tx4(unsigned long flags) |
699 | { | 781 | { |
700 | const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS; | 782 | const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS; |
701 | return (flags & mask) == mask; | 783 | return (flags & mask) == mask; |
702 | } | 784 | } |
703 | 785 | ||
704 | static inline unsigned int pdc_port_no_to_ata_no(unsigned int port_no, int is_sataii_tx4) | 786 | static unsigned int pdc_port_no_to_ata_no(unsigned int port_no, |
787 | int is_sataii_tx4) | ||
705 | { | 788 | { |
706 | static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2}; | 789 | static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2}; |
707 | return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no; | 790 | return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no; |
708 | } | 791 | } |
709 | 792 | ||
710 | static irqreturn_t pdc_interrupt (int irq, void *dev_instance) | 793 | static irqreturn_t pdc_interrupt(int irq, void *dev_instance) |
711 | { | 794 | { |
712 | struct ata_host *host = dev_instance; | 795 | struct ata_host *host = dev_instance; |
713 | struct ata_port *ap; | 796 | struct ata_port *ap; |
@@ -839,15 +922,16 @@ static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc) | |||
839 | 922 | ||
840 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) | 923 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) |
841 | { | 924 | { |
842 | WARN_ON (tf->protocol == ATA_PROT_DMA || | 925 | WARN_ON(tf->protocol == ATA_PROT_DMA || |
843 | tf->protocol == ATA_PROT_ATAPI_DMA); | 926 | tf->protocol == ATA_PROT_ATAPI_DMA); |
844 | ata_tf_load(ap, tf); | 927 | ata_tf_load(ap, tf); |
845 | } | 928 | } |
846 | 929 | ||
847 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) | 930 | static void pdc_exec_command_mmio(struct ata_port *ap, |
931 | const struct ata_taskfile *tf) | ||
848 | { | 932 | { |
849 | WARN_ON (tf->protocol == ATA_PROT_DMA || | 933 | WARN_ON(tf->protocol == ATA_PROT_DMA || |
850 | tf->protocol == ATA_PROT_ATAPI_DMA); | 934 | tf->protocol == ATA_PROT_ATAPI_DMA); |
851 | ata_exec_command(ap, tf); | 935 | ata_exec_command(ap, tf); |
852 | } | 936 | } |
853 | 937 | ||
@@ -870,8 +954,11 @@ static int pdc_check_atapi_dma(struct ata_queued_cmd *qc) | |||
870 | } | 954 | } |
871 | /* -45150 (FFFF4FA2) to -1 (FFFFFFFF) shall use PIO mode */ | 955 | /* -45150 (FFFF4FA2) to -1 (FFFFFFFF) shall use PIO mode */ |
872 | if (scsicmd[0] == WRITE_10) { | 956 | if (scsicmd[0] == WRITE_10) { |
873 | unsigned int lba; | 957 | unsigned int lba = |
874 | lba = (scsicmd[2] << 24) | (scsicmd[3] << 16) | (scsicmd[4] << 8) | scsicmd[5]; | 958 | (scsicmd[2] << 24) | |
959 | (scsicmd[3] << 16) | | ||
960 | (scsicmd[4] << 8) | | ||
961 | scsicmd[5]; | ||
875 | if (lba >= 0xFFFF4FA2) | 962 | if (lba >= 0xFFFF4FA2) |
876 | pio = 1; | 963 | pio = 1; |
877 | } | 964 | } |
@@ -956,7 +1043,8 @@ static void pdc_host_init(struct ata_host *host) | |||
956 | writel(tmp, mmio + PDC_SLEW_CTL); | 1043 | writel(tmp, mmio + PDC_SLEW_CTL); |
957 | } | 1044 | } |
958 | 1045 | ||
959 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 1046 | static int pdc_ata_init_one(struct pci_dev *pdev, |
1047 | const struct pci_device_id *ent) | ||
960 | { | 1048 | { |
961 | static int printed_version; | 1049 | static int printed_version; |
962 | const struct ata_port_info *pi = &pdc_port_info[ent->driver_data]; | 1050 | const struct ata_port_info *pi = &pdc_port_info[ent->driver_data]; |
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c index c4c4cd29eebb..6d43ba79e154 100644 --- a/drivers/ata/sata_qstor.c +++ b/drivers/ata/sata_qstor.c | |||
@@ -113,7 +113,7 @@ struct qs_port_priv { | |||
113 | 113 | ||
114 | static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 114 | static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); |
115 | static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 115 | static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); |
116 | static int qs_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 116 | static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
117 | static int qs_port_start(struct ata_port *ap); | 117 | static int qs_port_start(struct ata_port *ap); |
118 | static void qs_host_stop(struct ata_host *host); | 118 | static void qs_host_stop(struct ata_host *host); |
119 | static void qs_phy_reset(struct ata_port *ap); | 119 | static void qs_phy_reset(struct ata_port *ap); |
@@ -135,7 +135,6 @@ static struct scsi_host_template qs_ata_sht = { | |||
135 | .sg_tablesize = QS_MAX_PRD, | 135 | .sg_tablesize = QS_MAX_PRD, |
136 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | 136 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, |
137 | .emulated = ATA_SHT_EMULATED, | 137 | .emulated = ATA_SHT_EMULATED, |
138 | //FIXME .use_clustering = ATA_SHT_USE_CLUSTERING, | ||
139 | .use_clustering = ENABLE_CLUSTERING, | 138 | .use_clustering = ENABLE_CLUSTERING, |
140 | .proc_name = DRV_NAME, | 139 | .proc_name = DRV_NAME, |
141 | .dma_boundary = QS_DMA_BOUNDARY, | 140 | .dma_boundary = QS_DMA_BOUNDARY, |
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index ea3a0ab7e027..4e6e381279cc 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c | |||
@@ -111,7 +111,7 @@ enum { | |||
111 | SIL_QUIRK_UDMA5MAX = (1 << 1), | 111 | SIL_QUIRK_UDMA5MAX = (1 << 1), |
112 | }; | 112 | }; |
113 | 113 | ||
114 | static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 114 | static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
115 | #ifdef CONFIG_PM | 115 | #ifdef CONFIG_PM |
116 | static int sil_pci_device_resume(struct pci_dev *pdev); | 116 | static int sil_pci_device_resume(struct pci_dev *pdev); |
117 | #endif | 117 | #endif |
@@ -138,7 +138,7 @@ static const struct pci_device_id sil_pci_tbl[] = { | |||
138 | 138 | ||
139 | /* TODO firmware versions should be added - eric */ | 139 | /* TODO firmware versions should be added - eric */ |
140 | static const struct sil_drivelist { | 140 | static const struct sil_drivelist { |
141 | const char * product; | 141 | const char *product; |
142 | unsigned int quirk; | 142 | unsigned int quirk; |
143 | } sil_blacklist [] = { | 143 | } sil_blacklist [] = { |
144 | { "ST320012AS", SIL_QUIRK_MOD15WRITE }, | 144 | { "ST320012AS", SIL_QUIRK_MOD15WRITE }, |
@@ -279,7 +279,7 @@ MODULE_LICENSE("GPL"); | |||
279 | MODULE_DEVICE_TABLE(pci, sil_pci_tbl); | 279 | MODULE_DEVICE_TABLE(pci, sil_pci_tbl); |
280 | MODULE_VERSION(DRV_VERSION); | 280 | MODULE_VERSION(DRV_VERSION); |
281 | 281 | ||
282 | static int slow_down = 0; | 282 | static int slow_down; |
283 | module_param(slow_down, int, 0444); | 283 | module_param(slow_down, int, 0444); |
284 | MODULE_PARM_DESC(slow_down, "Sledgehammer used to work around random problems, by limiting commands to 15 sectors (0=off, 1=on)"); | 284 | MODULE_PARM_DESC(slow_down, "Sledgehammer used to work around random problems, by limiting commands to 15 sectors (0=off, 1=on)"); |
285 | 285 | ||
@@ -332,7 +332,8 @@ static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed) | |||
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | static inline void __iomem *sil_scr_addr(struct ata_port *ap, unsigned int sc_reg) | 335 | static inline void __iomem *sil_scr_addr(struct ata_port *ap, |
336 | unsigned int sc_reg) | ||
336 | { | 337 | { |
337 | void __iomem *offset = ap->ioaddr.scr_addr; | 338 | void __iomem *offset = ap->ioaddr.scr_addr; |
338 | 339 | ||
@@ -643,7 +644,7 @@ static void sil_init_controller(struct ata_host *host) | |||
643 | } | 644 | } |
644 | } | 645 | } |
645 | 646 | ||
646 | static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 647 | static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
647 | { | 648 | { |
648 | static int printed_version; | 649 | static int printed_version; |
649 | int board_id = ent->driver_data; | 650 | int board_id = ent->driver_data; |
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index 26ebffc10f3e..187dcb02c681 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -265,11 +265,11 @@ static struct sil24_cerr_info { | |||
265 | unsigned int err_mask, action; | 265 | unsigned int err_mask, action; |
266 | const char *desc; | 266 | const char *desc; |
267 | } sil24_cerr_db[] = { | 267 | } sil24_cerr_db[] = { |
268 | [0] = { AC_ERR_DEV, ATA_EH_REVALIDATE, | 268 | [0] = { AC_ERR_DEV, 0, |
269 | "device error" }, | 269 | "device error" }, |
270 | [PORT_CERR_DEV] = { AC_ERR_DEV, ATA_EH_REVALIDATE, | 270 | [PORT_CERR_DEV] = { AC_ERR_DEV, 0, |
271 | "device error via D2H FIS" }, | 271 | "device error via D2H FIS" }, |
272 | [PORT_CERR_SDB] = { AC_ERR_DEV, ATA_EH_REVALIDATE, | 272 | [PORT_CERR_SDB] = { AC_ERR_DEV, 0, |
273 | "device error via SDB FIS" }, | 273 | "device error via SDB FIS" }, |
274 | [PORT_CERR_DATA] = { AC_ERR_ATA_BUS, ATA_EH_SOFTRESET, | 274 | [PORT_CERR_DATA] = { AC_ERR_ATA_BUS, ATA_EH_SOFTRESET, |
275 | "error in data FIS" }, | 275 | "error in data FIS" }, |
@@ -674,7 +674,7 @@ static int sil24_do_softreset(struct ata_link *link, unsigned int *class, | |||
674 | 674 | ||
675 | /* put the port into known state */ | 675 | /* put the port into known state */ |
676 | if (sil24_init_port(ap)) { | 676 | if (sil24_init_port(ap)) { |
677 | reason ="port not ready"; | 677 | reason = "port not ready"; |
678 | goto err; | 678 | goto err; |
679 | } | 679 | } |
680 | 680 | ||
@@ -756,7 +756,8 @@ static int sil24_hardreset(struct ata_link *link, unsigned int *class, | |||
756 | 756 | ||
757 | writel(PORT_CS_DEV_RST, port + PORT_CTRL_STAT); | 757 | writel(PORT_CS_DEV_RST, port + PORT_CTRL_STAT); |
758 | tmp = ata_wait_register(port + PORT_CTRL_STAT, | 758 | tmp = ata_wait_register(port + PORT_CTRL_STAT, |
759 | PORT_CS_DEV_RST, PORT_CS_DEV_RST, 10, tout_msec); | 759 | PORT_CS_DEV_RST, PORT_CS_DEV_RST, 10, |
760 | tout_msec); | ||
760 | 761 | ||
761 | /* SStatus oscillates between zero and valid status after | 762 | /* SStatus oscillates between zero and valid status after |
762 | * DEV_RST, debounce it. | 763 | * DEV_RST, debounce it. |
@@ -1270,7 +1271,7 @@ static void sil24_init_controller(struct ata_host *host) | |||
1270 | PORT_CS_PORT_RST, 10, 100); | 1271 | PORT_CS_PORT_RST, 10, 100); |
1271 | if (tmp & PORT_CS_PORT_RST) | 1272 | if (tmp & PORT_CS_PORT_RST) |
1272 | dev_printk(KERN_ERR, host->dev, | 1273 | dev_printk(KERN_ERR, host->dev, |
1273 | "failed to clear port RST\n"); | 1274 | "failed to clear port RST\n"); |
1274 | } | 1275 | } |
1275 | 1276 | ||
1276 | /* configure port */ | 1277 | /* configure port */ |
@@ -1283,7 +1284,7 @@ static void sil24_init_controller(struct ata_host *host) | |||
1283 | 1284 | ||
1284 | static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 1285 | static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
1285 | { | 1286 | { |
1286 | static int printed_version = 0; | 1287 | static int printed_version; |
1287 | struct ata_port_info pi = sil24_port_info[ent->driver_data]; | 1288 | struct ata_port_info pi = sil24_port_info[ent->driver_data]; |
1288 | const struct ata_port_info *ppi[] = { &pi, NULL }; | 1289 | const struct ata_port_info *ppi[] = { &pi, NULL }; |
1289 | void __iomem * const *iomap; | 1290 | void __iomem * const *iomap; |
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c index f147dc7bf464..a01260a56432 100644 --- a/drivers/ata/sata_sis.c +++ b/drivers/ata/sata_sis.c | |||
@@ -63,17 +63,17 @@ enum { | |||
63 | GENCTL_IOMAPPED_SCR = (1 << 26), /* if set, SCRs are in IO space */ | 63 | GENCTL_IOMAPPED_SCR = (1 << 26), /* if set, SCRs are in IO space */ |
64 | }; | 64 | }; |
65 | 65 | ||
66 | static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 66 | static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
67 | static int sis_scr_read (struct ata_port *ap, unsigned int sc_reg, u32 *val); | 67 | static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); |
68 | static int sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); | 68 | static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); |
69 | 69 | ||
70 | static const struct pci_device_id sis_pci_tbl[] = { | 70 | static const struct pci_device_id sis_pci_tbl[] = { |
71 | { PCI_VDEVICE(SI, 0x0180), sis_180 }, /* SiS 964/180 */ | 71 | { PCI_VDEVICE(SI, 0x0180), sis_180 }, /* SiS 964/180 */ |
72 | { PCI_VDEVICE(SI, 0x0181), sis_180 }, /* SiS 964/180 */ | 72 | { PCI_VDEVICE(SI, 0x0181), sis_180 }, /* SiS 964/180 */ |
73 | { PCI_VDEVICE(SI, 0x0182), sis_180 }, /* SiS 965/965L */ | 73 | { PCI_VDEVICE(SI, 0x0182), sis_180 }, /* SiS 965/965L */ |
74 | { PCI_VDEVICE(SI, 0x0183), sis_180 }, /* SiS 965/965L */ | 74 | { PCI_VDEVICE(SI, 0x0183), sis_180 }, /* SiS 965/965L */ |
75 | { PCI_VDEVICE(SI, 0x1182), sis_180 }, /* SiS 966/680 */ | 75 | { PCI_VDEVICE(SI, 0x1182), sis_180 }, /* SiS 966/680 */ |
76 | { PCI_VDEVICE(SI, 0x1183), sis_180 }, /* SiS 966/966L/968/680 */ | 76 | { PCI_VDEVICE(SI, 0x1183), sis_180 }, /* SiS 966/966L/968/680 */ |
77 | 77 | ||
78 | { } /* terminate list */ | 78 | { } /* terminate list */ |
79 | }; | 79 | }; |
@@ -149,24 +149,24 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) | |||
149 | 149 | ||
150 | if (ap->port_no) { | 150 | if (ap->port_no) { |
151 | switch (pdev->device) { | 151 | switch (pdev->device) { |
152 | case 0x0180: | 152 | case 0x0180: |
153 | case 0x0181: | 153 | case 0x0181: |
154 | pci_read_config_byte(pdev, SIS_PMR, &pmr); | 154 | pci_read_config_byte(pdev, SIS_PMR, &pmr); |
155 | if ((pmr & SIS_PMR_COMBINED) == 0) | 155 | if ((pmr & SIS_PMR_COMBINED) == 0) |
156 | addr += SIS180_SATA1_OFS; | 156 | addr += SIS180_SATA1_OFS; |
157 | break; | 157 | break; |
158 | 158 | ||
159 | case 0x0182: | 159 | case 0x0182: |
160 | case 0x0183: | 160 | case 0x0183: |
161 | case 0x1182: | 161 | case 0x1182: |
162 | addr += SIS182_SATA1_OFS; | 162 | addr += SIS182_SATA1_OFS; |
163 | break; | 163 | break; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | return addr; | 166 | return addr; |
167 | } | 167 | } |
168 | 168 | ||
169 | static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg, u32 *val) | 169 | static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) |
170 | { | 170 | { |
171 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 171 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
172 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); | 172 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); |
@@ -190,7 +190,7 @@ static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
190 | return 0; | 190 | return 0; |
191 | } | 191 | } |
192 | 192 | ||
193 | static void sis_scr_cfg_write (struct ata_port *ap, unsigned int sc_reg, u32 val) | 193 | static void sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val) |
194 | { | 194 | { |
195 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 195 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
196 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); | 196 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); |
@@ -253,7 +253,7 @@ static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | |||
253 | return 0; | 253 | return 0; |
254 | } | 254 | } |
255 | 255 | ||
256 | static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 256 | static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
257 | { | 257 | { |
258 | static int printed_version; | 258 | static int printed_version; |
259 | struct ata_port_info pi = sis_port_info; | 259 | struct ata_port_info pi = sis_port_info; |
@@ -309,29 +309,33 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
309 | } else { | 309 | } else { |
310 | dev_printk(KERN_INFO, &pdev->dev, | 310 | dev_printk(KERN_INFO, &pdev->dev, |
311 | "Detected SiS 180/181 chipset in combined mode\n"); | 311 | "Detected SiS 180/181 chipset in combined mode\n"); |
312 | port2_start=0; | 312 | port2_start = 0; |
313 | pi.flags |= ATA_FLAG_SLAVE_POSS; | 313 | pi.flags |= ATA_FLAG_SLAVE_POSS; |
314 | } | 314 | } |
315 | break; | 315 | break; |
316 | 316 | ||
317 | case 0x0182: | 317 | case 0x0182: |
318 | case 0x0183: | 318 | case 0x0183: |
319 | pci_read_config_dword ( pdev, 0x6C, &val); | 319 | pci_read_config_dword(pdev, 0x6C, &val); |
320 | if (val & (1L << 31)) { | 320 | if (val & (1L << 31)) { |
321 | dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182/965 chipset\n"); | 321 | dev_printk(KERN_INFO, &pdev->dev, |
322 | "Detected SiS 182/965 chipset\n"); | ||
322 | pi.flags |= ATA_FLAG_SLAVE_POSS; | 323 | pi.flags |= ATA_FLAG_SLAVE_POSS; |
323 | } else { | 324 | } else { |
324 | dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182/965L chipset\n"); | 325 | dev_printk(KERN_INFO, &pdev->dev, |
326 | "Detected SiS 182/965L chipset\n"); | ||
325 | } | 327 | } |
326 | break; | 328 | break; |
327 | 329 | ||
328 | case 0x1182: | 330 | case 0x1182: |
329 | dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 1182/966/680 SATA controller\n"); | 331 | dev_printk(KERN_INFO, &pdev->dev, |
332 | "Detected SiS 1182/966/680 SATA controller\n"); | ||
330 | pi.flags |= ATA_FLAG_SLAVE_POSS; | 333 | pi.flags |= ATA_FLAG_SLAVE_POSS; |
331 | break; | 334 | break; |
332 | 335 | ||
333 | case 0x1183: | 336 | case 0x1183: |
334 | dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 1183/966/966L/968/680 controller in PATA mode\n"); | 337 | dev_printk(KERN_INFO, &pdev->dev, |
338 | "Detected SiS 1183/966/966L/968/680 controller in PATA mode\n"); | ||
335 | ppi[0] = &sis_info133_for_sata; | 339 | ppi[0] = &sis_info133_for_sata; |
336 | ppi[1] = &sis_info133_for_sata; | 340 | ppi[1] = &sis_info133_for_sata; |
337 | break; | 341 | break; |
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index 12d613c48c19..69f651e0bc98 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c | |||
@@ -182,7 +182,7 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
182 | tf->hob_lbal = lbal >> 8; | 182 | tf->hob_lbal = lbal >> 8; |
183 | tf->hob_lbam = lbam >> 8; | 183 | tf->hob_lbam = lbam >> 8; |
184 | tf->hob_lbah = lbah >> 8; | 184 | tf->hob_lbah = lbah >> 8; |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | /** | 188 | /** |
@@ -193,7 +193,7 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
193 | * spin_lock_irqsave(host lock) | 193 | * spin_lock_irqsave(host lock) |
194 | */ | 194 | */ |
195 | 195 | ||
196 | static void k2_bmdma_setup_mmio (struct ata_queued_cmd *qc) | 196 | static void k2_bmdma_setup_mmio(struct ata_queued_cmd *qc) |
197 | { | 197 | { |
198 | struct ata_port *ap = qc->ap; | 198 | struct ata_port *ap = qc->ap; |
199 | unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); | 199 | unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); |
@@ -224,7 +224,7 @@ static void k2_bmdma_setup_mmio (struct ata_queued_cmd *qc) | |||
224 | * spin_lock_irqsave(host lock) | 224 | * spin_lock_irqsave(host lock) |
225 | */ | 225 | */ |
226 | 226 | ||
227 | static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc) | 227 | static void k2_bmdma_start_mmio(struct ata_queued_cmd *qc) |
228 | { | 228 | { |
229 | struct ata_port *ap = qc->ap; | 229 | struct ata_port *ap = qc->ap; |
230 | void __iomem *mmio = ap->ioaddr.bmdma_addr; | 230 | void __iomem *mmio = ap->ioaddr.bmdma_addr; |
@@ -255,7 +255,7 @@ static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc) | |||
255 | 255 | ||
256 | static u8 k2_stat_check_status(struct ata_port *ap) | 256 | static u8 k2_stat_check_status(struct ata_port *ap) |
257 | { | 257 | { |
258 | return readl(ap->ioaddr.status_addr); | 258 | return readl(ap->ioaddr.status_addr); |
259 | } | 259 | } |
260 | 260 | ||
261 | #ifdef CONFIG_PPC_OF | 261 | #ifdef CONFIG_PPC_OF |
@@ -395,7 +395,7 @@ static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base) | |||
395 | } | 395 | } |
396 | 396 | ||
397 | 397 | ||
398 | static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 398 | static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
399 | { | 399 | { |
400 | static int printed_version; | 400 | static int printed_version; |
401 | const struct ata_port_info *ppi[] = | 401 | const struct ata_port_info *ppi[] = |
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c index b6026bceccd1..4d857185f33b 100644 --- a/drivers/ata/sata_sx4.c +++ b/drivers/ata/sata_sx4.c | |||
@@ -212,9 +212,9 @@ struct pdc_host_priv { | |||
212 | }; | 212 | }; |
213 | 213 | ||
214 | 214 | ||
215 | static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 215 | static int pdc_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
216 | static void pdc_eng_timeout(struct ata_port *ap); | 216 | static void pdc_eng_timeout(struct ata_port *ap); |
217 | static void pdc_20621_phy_reset (struct ata_port *ap); | 217 | static void pdc_20621_phy_reset(struct ata_port *ap); |
218 | static int pdc_port_start(struct ata_port *ap); | 218 | static int pdc_port_start(struct ata_port *ap); |
219 | static void pdc20621_qc_prep(struct ata_queued_cmd *qc); | 219 | static void pdc20621_qc_prep(struct ata_queued_cmd *qc); |
220 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 220 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
@@ -320,16 +320,16 @@ static int pdc_port_start(struct ata_port *ap) | |||
320 | return 0; | 320 | return 0; |
321 | } | 321 | } |
322 | 322 | ||
323 | static void pdc_20621_phy_reset (struct ata_port *ap) | 323 | static void pdc_20621_phy_reset(struct ata_port *ap) |
324 | { | 324 | { |
325 | VPRINTK("ENTER\n"); | 325 | VPRINTK("ENTER\n"); |
326 | ap->cbl = ATA_CBL_SATA; | 326 | ap->cbl = ATA_CBL_SATA; |
327 | ata_port_probe(ap); | 327 | ata_port_probe(ap); |
328 | ata_bus_reset(ap); | 328 | ata_bus_reset(ap); |
329 | } | 329 | } |
330 | 330 | ||
331 | static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, | 331 | static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, |
332 | unsigned int portno, | 332 | unsigned int portno, |
333 | unsigned int total_len) | 333 | unsigned int total_len) |
334 | { | 334 | { |
335 | u32 addr; | 335 | u32 addr; |
@@ -351,7 +351,7 @@ static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, | |||
351 | } | 351 | } |
352 | 352 | ||
353 | static inline void pdc20621_host_sg(struct ata_taskfile *tf, u8 *buf, | 353 | static inline void pdc20621_host_sg(struct ata_taskfile *tf, u8 *buf, |
354 | unsigned int portno, | 354 | unsigned int portno, |
355 | unsigned int total_len) | 355 | unsigned int total_len) |
356 | { | 356 | { |
357 | u32 addr; | 357 | u32 addr; |
@@ -711,8 +711,8 @@ static unsigned int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc) | |||
711 | return ata_qc_issue_prot(qc); | 711 | return ata_qc_issue_prot(qc); |
712 | } | 712 | } |
713 | 713 | ||
714 | static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | 714 | static inline unsigned int pdc20621_host_intr(struct ata_port *ap, |
715 | struct ata_queued_cmd *qc, | 715 | struct ata_queued_cmd *qc, |
716 | unsigned int doing_hdma, | 716 | unsigned int doing_hdma, |
717 | void __iomem *mmio) | 717 | void __iomem *mmio) |
718 | { | 718 | { |
@@ -803,7 +803,7 @@ static void pdc20621_irq_clear(struct ata_port *ap) | |||
803 | readl(mmio + PDC_20621_SEQMASK); | 803 | readl(mmio + PDC_20621_SEQMASK); |
804 | } | 804 | } |
805 | 805 | ||
806 | static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance) | 806 | static irqreturn_t pdc20621_interrupt(int irq, void *dev_instance) |
807 | { | 807 | { |
808 | struct ata_host *host = dev_instance; | 808 | struct ata_host *host = dev_instance; |
809 | struct ata_port *ap; | 809 | struct ata_port *ap; |
@@ -836,9 +836,9 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance) | |||
836 | return IRQ_NONE; | 836 | return IRQ_NONE; |
837 | } | 837 | } |
838 | 838 | ||
839 | spin_lock(&host->lock); | 839 | spin_lock(&host->lock); |
840 | 840 | ||
841 | for (i = 1; i < 9; i++) { | 841 | for (i = 1; i < 9; i++) { |
842 | port_no = i - 1; | 842 | port_no = i - 1; |
843 | if (port_no > 3) | 843 | if (port_no > 3) |
844 | port_no -= 4; | 844 | port_no -= 4; |
@@ -859,7 +859,7 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance) | |||
859 | } | 859 | } |
860 | } | 860 | } |
861 | 861 | ||
862 | spin_unlock(&host->lock); | 862 | spin_unlock(&host->lock); |
863 | 863 | ||
864 | VPRINTK("mask == 0x%x\n", mask); | 864 | VPRINTK("mask == 0x%x\n", mask); |
865 | 865 | ||
@@ -906,16 +906,16 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
906 | 906 | ||
907 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) | 907 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) |
908 | { | 908 | { |
909 | WARN_ON (tf->protocol == ATA_PROT_DMA || | 909 | WARN_ON(tf->protocol == ATA_PROT_DMA || |
910 | tf->protocol == ATA_PROT_NODATA); | 910 | tf->protocol == ATA_PROT_NODATA); |
911 | ata_tf_load(ap, tf); | 911 | ata_tf_load(ap, tf); |
912 | } | 912 | } |
913 | 913 | ||
914 | 914 | ||
915 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) | 915 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) |
916 | { | 916 | { |
917 | WARN_ON (tf->protocol == ATA_PROT_DMA || | 917 | WARN_ON(tf->protocol == ATA_PROT_DMA || |
918 | tf->protocol == ATA_PROT_NODATA); | 918 | tf->protocol == ATA_PROT_NODATA); |
919 | ata_exec_command(ap, tf); | 919 | ata_exec_command(ap, tf); |
920 | } | 920 | } |
921 | 921 | ||
@@ -953,7 +953,7 @@ static void pdc20621_get_from_dimm(struct ata_host *host, void *psource, | |||
953 | mmio += PDC_CHIP0_OFS; | 953 | mmio += PDC_CHIP0_OFS; |
954 | 954 | ||
955 | page_mask = 0x00; | 955 | page_mask = 0x00; |
956 | window_size = 0x2000 * 4; /* 32K byte uchar size */ | 956 | window_size = 0x2000 * 4; /* 32K byte uchar size */ |
957 | idx = (u16) (offset / window_size); | 957 | idx = (u16) (offset / window_size); |
958 | 958 | ||
959 | writel(0x01, mmio + PDC_GENERAL_CTLR); | 959 | writel(0x01, mmio + PDC_GENERAL_CTLR); |
@@ -979,7 +979,7 @@ static void pdc20621_get_from_dimm(struct ata_host *host, void *psource, | |||
979 | window_size / 4); | 979 | window_size / 4); |
980 | psource += window_size; | 980 | psource += window_size; |
981 | size -= window_size; | 981 | size -= window_size; |
982 | idx ++; | 982 | idx++; |
983 | } | 983 | } |
984 | 984 | ||
985 | if (size) { | 985 | if (size) { |
@@ -1008,7 +1008,7 @@ static void pdc20621_put_to_dimm(struct ata_host *host, void *psource, | |||
1008 | mmio += PDC_CHIP0_OFS; | 1008 | mmio += PDC_CHIP0_OFS; |
1009 | 1009 | ||
1010 | page_mask = 0x00; | 1010 | page_mask = 0x00; |
1011 | window_size = 0x2000 * 4; /* 32K byte uchar size */ | 1011 | window_size = 0x2000 * 4; /* 32K byte uchar size */ |
1012 | idx = (u16) (offset / window_size); | 1012 | idx = (u16) (offset / window_size); |
1013 | 1013 | ||
1014 | writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); | 1014 | writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); |
@@ -1031,7 +1031,7 @@ static void pdc20621_put_to_dimm(struct ata_host *host, void *psource, | |||
1031 | readl(mmio + PDC_GENERAL_CTLR); | 1031 | readl(mmio + PDC_GENERAL_CTLR); |
1032 | psource += window_size; | 1032 | psource += window_size; |
1033 | size -= window_size; | 1033 | size -= window_size; |
1034 | idx ++; | 1034 | idx++; |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | if (size) { | 1037 | if (size) { |
@@ -1050,7 +1050,7 @@ static unsigned int pdc20621_i2c_read(struct ata_host *host, u32 device, | |||
1050 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; | 1050 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; |
1051 | u32 i2creg = 0; | 1051 | u32 i2creg = 0; |
1052 | u32 status; | 1052 | u32 status; |
1053 | u32 count =0; | 1053 | u32 count = 0; |
1054 | 1054 | ||
1055 | /* hard-code chip #0 */ | 1055 | /* hard-code chip #0 */ |
1056 | mmio += PDC_CHIP0_OFS; | 1056 | mmio += PDC_CHIP0_OFS; |
@@ -1082,21 +1082,21 @@ static unsigned int pdc20621_i2c_read(struct ata_host *host, u32 device, | |||
1082 | 1082 | ||
1083 | static int pdc20621_detect_dimm(struct ata_host *host) | 1083 | static int pdc20621_detect_dimm(struct ata_host *host) |
1084 | { | 1084 | { |
1085 | u32 data=0 ; | 1085 | u32 data = 0; |
1086 | if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, | 1086 | if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, |
1087 | PDC_DIMM_SPD_SYSTEM_FREQ, &data)) { | 1087 | PDC_DIMM_SPD_SYSTEM_FREQ, &data)) { |
1088 | if (data == 100) | 1088 | if (data == 100) |
1089 | return 100; | 1089 | return 100; |
1090 | } else | 1090 | } else |
1091 | return 0; | 1091 | return 0; |
1092 | 1092 | ||
1093 | if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 9, &data)) { | 1093 | if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 9, &data)) { |
1094 | if(data <= 0x75) | 1094 | if (data <= 0x75) |
1095 | return 133; | 1095 | return 133; |
1096 | } else | 1096 | } else |
1097 | return 0; | 1097 | return 0; |
1098 | 1098 | ||
1099 | return 0; | 1099 | return 0; |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | 1102 | ||
@@ -1104,8 +1104,8 @@ static int pdc20621_prog_dimm0(struct ata_host *host) | |||
1104 | { | 1104 | { |
1105 | u32 spd0[50]; | 1105 | u32 spd0[50]; |
1106 | u32 data = 0; | 1106 | u32 data = 0; |
1107 | int size, i; | 1107 | int size, i; |
1108 | u8 bdimmsize; | 1108 | u8 bdimmsize; |
1109 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; | 1109 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; |
1110 | static const struct { | 1110 | static const struct { |
1111 | unsigned int reg; | 1111 | unsigned int reg; |
@@ -1128,40 +1128,40 @@ static int pdc20621_prog_dimm0(struct ata_host *host) | |||
1128 | /* hard-code chip #0 */ | 1128 | /* hard-code chip #0 */ |
1129 | mmio += PDC_CHIP0_OFS; | 1129 | mmio += PDC_CHIP0_OFS; |
1130 | 1130 | ||
1131 | for(i=0; i<ARRAY_SIZE(pdc_i2c_read_data); i++) | 1131 | for (i = 0; i < ARRAY_SIZE(pdc_i2c_read_data); i++) |
1132 | pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, | 1132 | pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, |
1133 | pdc_i2c_read_data[i].reg, | 1133 | pdc_i2c_read_data[i].reg, |
1134 | &spd0[pdc_i2c_read_data[i].ofs]); | 1134 | &spd0[pdc_i2c_read_data[i].ofs]); |
1135 | 1135 | ||
1136 | data |= (spd0[4] - 8) | ((spd0[21] != 0) << 3) | ((spd0[3]-11) << 4); | 1136 | data |= (spd0[4] - 8) | ((spd0[21] != 0) << 3) | ((spd0[3]-11) << 4); |
1137 | data |= ((spd0[17] / 4) << 6) | ((spd0[5] / 2) << 7) | | 1137 | data |= ((spd0[17] / 4) << 6) | ((spd0[5] / 2) << 7) | |
1138 | ((((spd0[27] + 9) / 10) - 1) << 8) ; | 1138 | ((((spd0[27] + 9) / 10) - 1) << 8) ; |
1139 | data |= (((((spd0[29] > spd0[28]) | 1139 | data |= (((((spd0[29] > spd0[28]) |
1140 | ? spd0[29] : spd0[28]) + 9) / 10) - 1) << 10; | 1140 | ? spd0[29] : spd0[28]) + 9) / 10) - 1) << 10; |
1141 | data |= ((spd0[30] - spd0[29] + 9) / 10 - 2) << 12; | 1141 | data |= ((spd0[30] - spd0[29] + 9) / 10 - 2) << 12; |
1142 | 1142 | ||
1143 | if (spd0[18] & 0x08) | 1143 | if (spd0[18] & 0x08) |
1144 | data |= ((0x03) << 14); | 1144 | data |= ((0x03) << 14); |
1145 | else if (spd0[18] & 0x04) | 1145 | else if (spd0[18] & 0x04) |
1146 | data |= ((0x02) << 14); | 1146 | data |= ((0x02) << 14); |
1147 | else if (spd0[18] & 0x01) | 1147 | else if (spd0[18] & 0x01) |
1148 | data |= ((0x01) << 14); | 1148 | data |= ((0x01) << 14); |
1149 | else | 1149 | else |
1150 | data |= (0 << 14); | 1150 | data |= (0 << 14); |
1151 | 1151 | ||
1152 | /* | 1152 | /* |
1153 | Calculate the size of bDIMMSize (power of 2) and | 1153 | Calculate the size of bDIMMSize (power of 2) and |
1154 | merge the DIMM size by program start/end address. | 1154 | merge the DIMM size by program start/end address. |
1155 | */ | 1155 | */ |
1156 | 1156 | ||
1157 | bdimmsize = spd0[4] + (spd0[5] / 2) + spd0[3] + (spd0[17] / 2) + 3; | 1157 | bdimmsize = spd0[4] + (spd0[5] / 2) + spd0[3] + (spd0[17] / 2) + 3; |
1158 | size = (1 << bdimmsize) >> 20; /* size = xxx(MB) */ | 1158 | size = (1 << bdimmsize) >> 20; /* size = xxx(MB) */ |
1159 | data |= (((size / 16) - 1) << 16); | 1159 | data |= (((size / 16) - 1) << 16); |
1160 | data |= (0 << 23); | 1160 | data |= (0 << 23); |
1161 | data |= 8; | 1161 | data |= 8; |
1162 | writel(data, mmio + PDC_DIMM0_CONTROL); | 1162 | writel(data, mmio + PDC_DIMM0_CONTROL); |
1163 | readl(mmio + PDC_DIMM0_CONTROL); | 1163 | readl(mmio + PDC_DIMM0_CONTROL); |
1164 | return size; | 1164 | return size; |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | 1167 | ||
@@ -1172,9 +1172,9 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host) | |||
1172 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; | 1172 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; |
1173 | 1173 | ||
1174 | /* hard-code chip #0 */ | 1174 | /* hard-code chip #0 */ |
1175 | mmio += PDC_CHIP0_OFS; | 1175 | mmio += PDC_CHIP0_OFS; |
1176 | 1176 | ||
1177 | /* | 1177 | /* |
1178 | Set To Default : DIMM Module Global Control Register (0x022259F1) | 1178 | Set To Default : DIMM Module Global Control Register (0x022259F1) |
1179 | DIMM Arbitration Disable (bit 20) | 1179 | DIMM Arbitration Disable (bit 20) |
1180 | DIMM Data/Control Output Driving Selection (bit12 - bit15) | 1180 | DIMM Data/Control Output Driving Selection (bit12 - bit15) |
@@ -1193,40 +1193,40 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host) | |||
1193 | writel(data, mmio + PDC_SDRAM_CONTROL); | 1193 | writel(data, mmio + PDC_SDRAM_CONTROL); |
1194 | readl(mmio + PDC_SDRAM_CONTROL); | 1194 | readl(mmio + PDC_SDRAM_CONTROL); |
1195 | printk(KERN_ERR "Local DIMM ECC Enabled\n"); | 1195 | printk(KERN_ERR "Local DIMM ECC Enabled\n"); |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | /* DIMM Initialization Select/Enable (bit 18/19) */ | 1198 | /* DIMM Initialization Select/Enable (bit 18/19) */ |
1199 | data &= (~(1<<18)); | 1199 | data &= (~(1<<18)); |
1200 | data |= (1<<19); | 1200 | data |= (1<<19); |
1201 | writel(data, mmio + PDC_SDRAM_CONTROL); | 1201 | writel(data, mmio + PDC_SDRAM_CONTROL); |
1202 | 1202 | ||
1203 | error = 1; | 1203 | error = 1; |
1204 | for (i = 1; i <= 10; i++) { /* polling ~5 secs */ | 1204 | for (i = 1; i <= 10; i++) { /* polling ~5 secs */ |
1205 | data = readl(mmio + PDC_SDRAM_CONTROL); | 1205 | data = readl(mmio + PDC_SDRAM_CONTROL); |
1206 | if (!(data & (1<<19))) { | 1206 | if (!(data & (1<<19))) { |
1207 | error = 0; | 1207 | error = 0; |
1208 | break; | 1208 | break; |
1209 | } | 1209 | } |
1210 | msleep(i*100); | 1210 | msleep(i*100); |
1211 | } | 1211 | } |
1212 | return error; | 1212 | return error; |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | 1215 | ||
1216 | static unsigned int pdc20621_dimm_init(struct ata_host *host) | 1216 | static unsigned int pdc20621_dimm_init(struct ata_host *host) |
1217 | { | 1217 | { |
1218 | int speed, size, length; | 1218 | int speed, size, length; |
1219 | u32 addr,spd0,pci_status; | 1219 | u32 addr, spd0, pci_status; |
1220 | u32 tmp=0; | 1220 | u32 tmp = 0; |
1221 | u32 time_period=0; | 1221 | u32 time_period = 0; |
1222 | u32 tcount=0; | 1222 | u32 tcount = 0; |
1223 | u32 ticks=0; | 1223 | u32 ticks = 0; |
1224 | u32 clock=0; | 1224 | u32 clock = 0; |
1225 | u32 fparam=0; | 1225 | u32 fparam = 0; |
1226 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; | 1226 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; |
1227 | 1227 | ||
1228 | /* hard-code chip #0 */ | 1228 | /* hard-code chip #0 */ |
1229 | mmio += PDC_CHIP0_OFS; | 1229 | mmio += PDC_CHIP0_OFS; |
1230 | 1230 | ||
1231 | /* Initialize PLL based upon PCI Bus Frequency */ | 1231 | /* Initialize PLL based upon PCI Bus Frequency */ |
1232 | 1232 | ||
@@ -1254,7 +1254,7 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host) | |||
1254 | If SX4 is on PCI-X bus, after 3 seconds, the timer counter | 1254 | If SX4 is on PCI-X bus, after 3 seconds, the timer counter |
1255 | register should be >= (0xffffffff - 3x10^8). | 1255 | register should be >= (0xffffffff - 3x10^8). |
1256 | */ | 1256 | */ |
1257 | if(tcount >= PCI_X_TCOUNT) { | 1257 | if (tcount >= PCI_X_TCOUNT) { |
1258 | ticks = (time_period - tcount); | 1258 | ticks = (time_period - tcount); |
1259 | VPRINTK("Num counters 0x%x (%d)\n", ticks, ticks); | 1259 | VPRINTK("Num counters 0x%x (%d)\n", ticks, ticks); |
1260 | 1260 | ||
@@ -1285,41 +1285,43 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host) | |||
1285 | if (!(speed = pdc20621_detect_dimm(host))) { | 1285 | if (!(speed = pdc20621_detect_dimm(host))) { |
1286 | printk(KERN_ERR "Detect Local DIMM Fail\n"); | 1286 | printk(KERN_ERR "Detect Local DIMM Fail\n"); |
1287 | return 1; /* DIMM error */ | 1287 | return 1; /* DIMM error */ |
1288 | } | 1288 | } |
1289 | VPRINTK("Local DIMM Speed = %d\n", speed); | 1289 | VPRINTK("Local DIMM Speed = %d\n", speed); |
1290 | 1290 | ||
1291 | /* Programming DIMM0 Module Control Register (index_CID0:80h) */ | 1291 | /* Programming DIMM0 Module Control Register (index_CID0:80h) */ |
1292 | size = pdc20621_prog_dimm0(host); | 1292 | size = pdc20621_prog_dimm0(host); |
1293 | VPRINTK("Local DIMM Size = %dMB\n",size); | 1293 | VPRINTK("Local DIMM Size = %dMB\n", size); |
1294 | 1294 | ||
1295 | /* Programming DIMM Module Global Control Register (index_CID0:88h) */ | 1295 | /* Programming DIMM Module Global Control Register (index_CID0:88h) */ |
1296 | if (pdc20621_prog_dimm_global(host)) { | 1296 | if (pdc20621_prog_dimm_global(host)) { |
1297 | printk(KERN_ERR "Programming DIMM Module Global Control Register Fail\n"); | 1297 | printk(KERN_ERR "Programming DIMM Module Global Control Register Fail\n"); |
1298 | return 1; | 1298 | return 1; |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | #ifdef ATA_VERBOSE_DEBUG | 1301 | #ifdef ATA_VERBOSE_DEBUG |
1302 | { | 1302 | { |
1303 | u8 test_parttern1[40] = {0x55,0xAA,'P','r','o','m','i','s','e',' ', | 1303 | u8 test_parttern1[40] = |
1304 | 'N','o','t',' ','Y','e','t',' ','D','e','f','i','n','e','d',' ', | 1304 | {0x55,0xAA,'P','r','o','m','i','s','e',' ', |
1305 | '1','.','1','0', | 1305 | 'N','o','t',' ','Y','e','t',' ', |
1306 | '9','8','0','3','1','6','1','2',0,0}; | 1306 | 'D','e','f','i','n','e','d',' ', |
1307 | '1','.','1','0', | ||
1308 | '9','8','0','3','1','6','1','2',0,0}; | ||
1307 | u8 test_parttern2[40] = {0}; | 1309 | u8 test_parttern2[40] = {0}; |
1308 | 1310 | ||
1309 | pdc20621_put_to_dimm(host, (void *) test_parttern2, 0x10040, 40); | 1311 | pdc20621_put_to_dimm(host, test_parttern2, 0x10040, 40); |
1310 | pdc20621_put_to_dimm(host, (void *) test_parttern2, 0x40, 40); | 1312 | pdc20621_put_to_dimm(host, test_parttern2, 0x40, 40); |
1311 | 1313 | ||
1312 | pdc20621_put_to_dimm(host, (void *) test_parttern1, 0x10040, 40); | 1314 | pdc20621_put_to_dimm(host, test_parttern1, 0x10040, 40); |
1313 | pdc20621_get_from_dimm(host, (void *) test_parttern2, 0x40, 40); | 1315 | pdc20621_get_from_dimm(host, test_parttern2, 0x40, 40); |
1314 | printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], | 1316 | printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], |
1315 | test_parttern2[1], &(test_parttern2[2])); | 1317 | test_parttern2[1], &(test_parttern2[2])); |
1316 | pdc20621_get_from_dimm(host, (void *) test_parttern2, 0x10040, | 1318 | pdc20621_get_from_dimm(host, test_parttern2, 0x10040, |
1317 | 40); | 1319 | 40); |
1318 | printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], | 1320 | printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], |
1319 | test_parttern2[1], &(test_parttern2[2])); | 1321 | test_parttern2[1], &(test_parttern2[2])); |
1320 | 1322 | ||
1321 | pdc20621_put_to_dimm(host, (void *) test_parttern1, 0x40, 40); | 1323 | pdc20621_put_to_dimm(host, test_parttern1, 0x40, 40); |
1322 | pdc20621_get_from_dimm(host, (void *) test_parttern2, 0x40, 40); | 1324 | pdc20621_get_from_dimm(host, test_parttern2, 0x40, 40); |
1323 | printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], | 1325 | printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], |
1324 | test_parttern2[1], &(test_parttern2[2])); | 1326 | test_parttern2[1], &(test_parttern2[2])); |
1325 | } | 1327 | } |
@@ -1375,7 +1377,8 @@ static void pdc_20621_init(struct ata_host *host) | |||
1375 | readl(mmio + PDC_HDMA_CTLSTAT); /* flush */ | 1377 | readl(mmio + PDC_HDMA_CTLSTAT); /* flush */ |
1376 | } | 1378 | } |
1377 | 1379 | ||
1378 | static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 1380 | static int pdc_sata_init_one(struct pci_dev *pdev, |
1381 | const struct pci_device_id *ent) | ||
1379 | { | 1382 | { |
1380 | static int printed_version; | 1383 | static int printed_version; |
1381 | const struct ata_port_info *ppi[] = | 1384 | const struct ata_port_info *ppi[] = |
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index d394da085ae4..e710e71b7b92 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c | |||
@@ -56,9 +56,9 @@ struct uli_priv { | |||
56 | unsigned int scr_cfg_addr[uli_max_ports]; | 56 | unsigned int scr_cfg_addr[uli_max_ports]; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 59 | static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
60 | static int uli_scr_read (struct ata_port *ap, unsigned int sc_reg, u32 *val); | 60 | static int uli_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); |
61 | static int uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); | 61 | static int uli_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); |
62 | 62 | ||
63 | static const struct pci_device_id uli_pci_tbl[] = { | 63 | static const struct pci_device_id uli_pci_tbl[] = { |
64 | { PCI_VDEVICE(AL, 0x5289), uli_5289 }, | 64 | { PCI_VDEVICE(AL, 0x5289), uli_5289 }, |
@@ -143,7 +143,7 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) | |||
143 | return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg); | 143 | return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg); |
144 | } | 144 | } |
145 | 145 | ||
146 | static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) | 146 | static u32 uli_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg) |
147 | { | 147 | { |
148 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 148 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
149 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); | 149 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); |
@@ -153,7 +153,7 @@ static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) | |||
153 | return val; | 153 | return val; |
154 | } | 154 | } |
155 | 155 | ||
156 | static void uli_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val) | 156 | static void uli_scr_cfg_write(struct ata_port *ap, unsigned int scr, u32 val) |
157 | { | 157 | { |
158 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 158 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
159 | unsigned int cfg_addr = get_scr_cfg_addr(ap, scr); | 159 | unsigned int cfg_addr = get_scr_cfg_addr(ap, scr); |
@@ -161,7 +161,7 @@ static void uli_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val) | |||
161 | pci_write_config_dword(pdev, cfg_addr, val); | 161 | pci_write_config_dword(pdev, cfg_addr, val); |
162 | } | 162 | } |
163 | 163 | ||
164 | static int uli_scr_read (struct ata_port *ap, unsigned int sc_reg, u32 *val) | 164 | static int uli_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) |
165 | { | 165 | { |
166 | if (sc_reg > SCR_CONTROL) | 166 | if (sc_reg > SCR_CONTROL) |
167 | return -EINVAL; | 167 | return -EINVAL; |
@@ -170,16 +170,16 @@ static int uli_scr_read (struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
170 | return 0; | 170 | return 0; |
171 | } | 171 | } |
172 | 172 | ||
173 | static int uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) | 173 | static int uli_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) |
174 | { | 174 | { |
175 | if (sc_reg > SCR_CONTROL) //SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0 | 175 | if (sc_reg > SCR_CONTROL) //SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0 |
176 | return -EINVAL; | 176 | return -EINVAL; |
177 | 177 | ||
178 | uli_scr_cfg_write(ap, sc_reg, val); | 178 | uli_scr_cfg_write(ap, sc_reg, val); |
179 | return 0; | 179 | return 0; |
180 | } | 180 | } |
181 | 181 | ||
182 | static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 182 | static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
183 | { | 183 | { |
184 | static int printed_version; | 184 | static int printed_version; |
185 | const struct ata_port_info *ppi[] = { &uli_port_info, NULL }; | 185 | const struct ata_port_info *ppi[] = { &uli_port_info, NULL }; |
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index cc6ee0890f56..3ef072ff319d 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Maintained by: Jeff Garzik <jgarzik@pobox.com> | 4 | * Maintained by: Jeff Garzik <jgarzik@pobox.com> |
5 | * Please ALWAYS copy linux-ide@vger.kernel.org | 5 | * Please ALWAYS copy linux-ide@vger.kernel.org |
6 | on emails. | 6 | * on emails. |
7 | * | 7 | * |
8 | * Copyright 2003-2004 Red Hat, Inc. All rights reserved. | 8 | * Copyright 2003-2004 Red Hat, Inc. All rights reserved. |
9 | * Copyright 2003-2004 Jeff Garzik | 9 | * Copyright 2003-2004 Jeff Garzik |
@@ -69,7 +69,7 @@ enum { | |||
69 | SATA_EXT_PHY = (1 << 6), /* 0==use PATA, 1==ext phy */ | 69 | SATA_EXT_PHY = (1 << 6), /* 0==use PATA, 1==ext phy */ |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 72 | static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
73 | static int svia_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 73 | static int svia_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); |
74 | static int svia_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 74 | static int svia_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); |
75 | static void svia_noop_freeze(struct ata_port *ap); | 75 | static void svia_noop_freeze(struct ata_port *ap); |
@@ -372,12 +372,12 @@ static const unsigned int vt6421_bar_sizes[] = { | |||
372 | 16, 16, 16, 16, 32, 128 | 372 | 16, 16, 16, 16, 32, 128 |
373 | }; | 373 | }; |
374 | 374 | ||
375 | static void __iomem * svia_scr_addr(void __iomem *addr, unsigned int port) | 375 | static void __iomem *svia_scr_addr(void __iomem *addr, unsigned int port) |
376 | { | 376 | { |
377 | return addr + (port * 128); | 377 | return addr + (port * 128); |
378 | } | 378 | } |
379 | 379 | ||
380 | static void __iomem * vt6421_scr_addr(void __iomem *addr, unsigned int port) | 380 | static void __iomem *vt6421_scr_addr(void __iomem *addr, unsigned int port) |
381 | { | 381 | { |
382 | return addr + (port * 64); | 382 | return addr + (port * 64); |
383 | } | 383 | } |
@@ -472,7 +472,7 @@ static void svia_configure(struct pci_dev *pdev) | |||
472 | if ((tmp8 & ALL_PORTS) != ALL_PORTS) { | 472 | if ((tmp8 & ALL_PORTS) != ALL_PORTS) { |
473 | dev_printk(KERN_DEBUG, &pdev->dev, | 473 | dev_printk(KERN_DEBUG, &pdev->dev, |
474 | "enabling SATA channels (0x%x)\n", | 474 | "enabling SATA channels (0x%x)\n", |
475 | (int) tmp8); | 475 | (int) tmp8); |
476 | tmp8 |= ALL_PORTS; | 476 | tmp8 |= ALL_PORTS; |
477 | pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); | 477 | pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); |
478 | } | 478 | } |
@@ -482,7 +482,7 @@ static void svia_configure(struct pci_dev *pdev) | |||
482 | if ((tmp8 & ALL_PORTS) != ALL_PORTS) { | 482 | if ((tmp8 & ALL_PORTS) != ALL_PORTS) { |
483 | dev_printk(KERN_DEBUG, &pdev->dev, | 483 | dev_printk(KERN_DEBUG, &pdev->dev, |
484 | "enabling SATA channel interrupts (0x%x)\n", | 484 | "enabling SATA channel interrupts (0x%x)\n", |
485 | (int) tmp8); | 485 | (int) tmp8); |
486 | tmp8 |= ALL_PORTS; | 486 | tmp8 |= ALL_PORTS; |
487 | pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); | 487 | pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); |
488 | } | 488 | } |
@@ -492,13 +492,13 @@ static void svia_configure(struct pci_dev *pdev) | |||
492 | if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { | 492 | if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { |
493 | dev_printk(KERN_DEBUG, &pdev->dev, | 493 | dev_printk(KERN_DEBUG, &pdev->dev, |
494 | "enabling SATA channel native mode (0x%x)\n", | 494 | "enabling SATA channel native mode (0x%x)\n", |
495 | (int) tmp8); | 495 | (int) tmp8); |
496 | tmp8 |= NATIVE_MODE_ALL; | 496 | tmp8 |= NATIVE_MODE_ALL; |
497 | pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); | 497 | pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 501 | static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
502 | { | 502 | { |
503 | static int printed_version; | 503 | static int printed_version; |
504 | unsigned int i; | 504 | unsigned int i; |
@@ -525,8 +525,8 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
525 | dev_printk(KERN_ERR, &pdev->dev, | 525 | dev_printk(KERN_ERR, &pdev->dev, |
526 | "invalid PCI BAR %u (sz 0x%llx, val 0x%llx)\n", | 526 | "invalid PCI BAR %u (sz 0x%llx, val 0x%llx)\n", |
527 | i, | 527 | i, |
528 | (unsigned long long)pci_resource_start(pdev, i), | 528 | (unsigned long long)pci_resource_start(pdev, i), |
529 | (unsigned long long)pci_resource_len(pdev, i)); | 529 | (unsigned long long)pci_resource_len(pdev, i)); |
530 | return -ENODEV; | 530 | return -ENODEV; |
531 | } | 531 | } |
532 | 532 | ||
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c index 0d9be1684873..95ae3ed24a9d 100644 --- a/drivers/ata/sata_vsc.c +++ b/drivers/ata/sata_vsc.c | |||
@@ -162,7 +162,8 @@ static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | |||
162 | /* | 162 | /* |
163 | * The only thing the ctl register is used for is SRST. | 163 | * The only thing the ctl register is used for is SRST. |
164 | * That is not enabled or disabled via tf_load. | 164 | * That is not enabled or disabled via tf_load. |
165 | * However, if ATA_NIEN is changed, then we need to change the interrupt register. | 165 | * However, if ATA_NIEN is changed, then we need to change |
166 | * the interrupt register. | ||
166 | */ | 167 | */ |
167 | if ((tf->ctl & ATA_NIEN) != (ap->last_ctl & ATA_NIEN)) { | 168 | if ((tf->ctl & ATA_NIEN) != (ap->last_ctl & ATA_NIEN)) { |
168 | ap->last_ctl = tf->ctl; | 169 | ap->last_ctl = tf->ctl; |
@@ -219,7 +220,7 @@ static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
219 | tf->hob_lbal = lbal >> 8; | 220 | tf->hob_lbal = lbal >> 8; |
220 | tf->hob_lbam = lbam >> 8; | 221 | tf->hob_lbam = lbam >> 8; |
221 | tf->hob_lbah = lbah >> 8; | 222 | tf->hob_lbah = lbah >> 8; |
222 | } | 223 | } |
223 | } | 224 | } |
224 | 225 | ||
225 | static inline void vsc_error_intr(u8 port_status, struct ata_port *ap) | 226 | static inline void vsc_error_intr(u8 port_status, struct ata_port *ap) |
@@ -256,9 +257,10 @@ static void vsc_port_intr(u8 port_status, struct ata_port *ap) | |||
256 | /* | 257 | /* |
257 | * vsc_sata_interrupt | 258 | * vsc_sata_interrupt |
258 | * | 259 | * |
259 | * Read the interrupt register and process for the devices that have them pending. | 260 | * Read the interrupt register and process for the devices that have |
261 | * them pending. | ||
260 | */ | 262 | */ |
261 | static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance) | 263 | static irqreturn_t vsc_sata_interrupt(int irq, void *dev_instance) |
262 | { | 264 | { |
263 | struct ata_host *host = dev_instance; | 265 | struct ata_host *host = dev_instance; |
264 | unsigned int i; | 266 | unsigned int i; |
@@ -287,7 +289,7 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance) | |||
287 | handled++; | 289 | handled++; |
288 | } else | 290 | } else |
289 | dev_printk(KERN_ERR, host->dev, | 291 | dev_printk(KERN_ERR, host->dev, |
290 | ": interrupt from disabled port %d\n", i); | 292 | "interrupt from disabled port %d\n", i); |
291 | } | 293 | } |
292 | } | 294 | } |
293 | 295 | ||
@@ -363,7 +365,8 @@ static void __devinit vsc_sata_setup_port(struct ata_ioports *port, | |||
363 | } | 365 | } |
364 | 366 | ||
365 | 367 | ||
366 | static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 368 | static int __devinit vsc_sata_init_one(struct pci_dev *pdev, |
369 | const struct pci_device_id *ent) | ||
367 | { | 370 | { |
368 | static const struct ata_port_info pi = { | 371 | static const struct ata_port_info pi = { |
369 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 372 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
diff --git a/drivers/base/core.c b/drivers/base/core.c index c1343414d285..3f4d6aa13990 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -1228,18 +1228,18 @@ int device_rename(struct device *dev, char *new_name) | |||
1228 | sysfs_remove_link(&dev->parent->kobj, old_class_name); | 1228 | sysfs_remove_link(&dev->parent->kobj, old_class_name); |
1229 | } | 1229 | } |
1230 | } | 1230 | } |
1231 | #endif | 1231 | #else |
1232 | |||
1233 | if (dev->class) { | 1232 | if (dev->class) { |
1234 | sysfs_remove_link(&dev->class->subsys.kobj, old_device_name); | 1233 | sysfs_remove_link(&dev->class->subsys.kobj, old_device_name); |
1235 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | 1234 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, |
1236 | dev->bus_id); | 1235 | dev->bus_id); |
1237 | if (error) { | 1236 | if (error) { |
1238 | /* Uh... how to unravel this if restoring can fail? */ | ||
1239 | dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n", | 1237 | dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n", |
1240 | __FUNCTION__, error); | 1238 | __FUNCTION__, error); |
1241 | } | 1239 | } |
1242 | } | 1240 | } |
1241 | #endif | ||
1242 | |||
1243 | out: | 1243 | out: |
1244 | put_device(dev); | 1244 | put_device(dev); |
1245 | 1245 | ||
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 5a6fe17fc638..7d704968765f 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -1,20 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Disk Array driver for HP SA 5xxx and 6xxx Controllers | 2 | * Disk Array driver for HP Smart Array controllers. |
3 | * Copyright 2000, 2006 Hewlett-Packard Development Company, L.P. | 3 | * (C) Copyright 2000, 2007 Hewlett-Packard Development Company, L.P. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; version 2 of the License. |
8 | * (at your option) any later version. | ||
9 | * | 8 | * |
10 | * This program is distributed in the hope that it will be useful, | 9 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | 11 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * NON INFRINGEMENT. See the GNU General Public License for more details. | 12 | * General Public License for more details. |
14 | * | 13 | * |
15 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
17 | * 02111-1307, USA. | ||
18 | * | 18 | * |
19 | * Questions/Comments/Bugfixes to iss_storagedev@hp.com | 19 | * Questions/Comments/Bugfixes to iss_storagedev@hp.com |
20 | * | 20 | * |
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index 4aca7ddfdddf..63ee6c076cb3 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c | |||
@@ -1,20 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Disk Array driver for Compaq SA53xx Controllers, SCSI Tape module | 2 | * Disk Array driver for HP Smart Array controllers, SCSI Tape module. |
3 | * Copyright 2001 Compaq Computer Corporation | 3 | * (C) Copyright 2001, 2007 Hewlett-Packard Development Company, L.P. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; version 2 of the License. |
8 | * (at your option) any later version. | ||
9 | * | 8 | * |
10 | * This program is distributed in the hope that it will be useful, | 9 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | 11 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * NON INFRINGEMENT. See the GNU General Public License for more details. | 12 | * General Public License for more details. |
14 | * | 13 | * |
15 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 16 | * Foundation, Inc., 59 Temple Place, Suite 300, Boston, MA |
17 | * 02111-1307, USA. | ||
18 | * | 18 | * |
19 | * Questions/Comments/Bugfixes to iss_storagedev@hp.com | 19 | * Questions/Comments/Bugfixes to iss_storagedev@hp.com |
20 | * | 20 | * |
diff --git a/drivers/block/cciss_scsi.h b/drivers/block/cciss_scsi.h index 5e7e06c07d6c..d9c2c586502f 100644 --- a/drivers/block/cciss_scsi.h +++ b/drivers/block/cciss_scsi.h | |||
@@ -1,20 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Disk Array driver for Compaq SA53xx Controllers, SCSI Tape module | 2 | * Disk Array driver for HP Smart Array controllers, SCSI Tape module. |
3 | * Copyright 2001 Compaq Computer Corporation | 3 | * (C) Copyright 2001, 2007 Hewlett-Packard Development Company, L.P. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; version 2 of the License. |
8 | * (at your option) any later version. | ||
9 | * | 8 | * |
10 | * This program is distributed in the hope that it will be useful, | 9 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | 11 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * NON INFRINGEMENT. See the GNU General Public License for more details. | 12 | * General Public License for more details. |
14 | * | 13 | * |
15 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 16 | * Foundation, Inc., 59 Temple Place, Suite 300, Boston, MA |
17 | * 02111-1307, USA. | ||
18 | * | 18 | * |
19 | * Questions/Comments/Bugfixes to iss_storagedev@hp.com | 19 | * Questions/Comments/Bugfixes to iss_storagedev@hp.com |
20 | * | 20 | * |
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c index 1b58b010797f..241167878edf 100644 --- a/drivers/block/cryptoloop.c +++ b/drivers/block/cryptoloop.c | |||
@@ -150,13 +150,8 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
150 | u32 iv[4] = { 0, }; | 150 | u32 iv[4] = { 0, }; |
151 | iv[0] = cpu_to_le32(IV & 0xffffffff); | 151 | iv[0] = cpu_to_le32(IV & 0xffffffff); |
152 | 152 | ||
153 | sg_set_page(&sg_in, in_page); | 153 | sg_set_page(&sg_in, in_page, sz, in_offs); |
154 | sg_in.offset = in_offs; | 154 | sg_set_page(&sg_out, out_page, sz, out_offs); |
155 | sg_in.length = sz; | ||
156 | |||
157 | sg_set_page(&sg_out, out_page); | ||
158 | sg_out.offset = out_offs; | ||
159 | sg_out.length = sz; | ||
160 | 155 | ||
161 | desc.info = iv; | 156 | desc.info = iv; |
162 | err = encdecfunc(&desc, &sg_out, &sg_in, sz); | 157 | err = encdecfunc(&desc, &sg_out, &sg_in, sz); |
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 7276f7d207c2..fac4c6cd04f7 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <linux/scatterlist.h> | ||
18 | 19 | ||
19 | #include <asm/vio.h> | 20 | #include <asm/vio.h> |
20 | #include <asm/ldc.h> | 21 | #include <asm/ldc.h> |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 14143f2c484d..08e909dc7944 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -1428,9 +1428,9 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1428 | scmd->state = UB_CMDST_INIT; | 1428 | scmd->state = UB_CMDST_INIT; |
1429 | scmd->nsg = 1; | 1429 | scmd->nsg = 1; |
1430 | sg = &scmd->sgv[0]; | 1430 | sg = &scmd->sgv[0]; |
1431 | sg_set_page(sg, virt_to_page(sc->top_sense)); | 1431 | sg_init_table(sg, UB_MAX_REQ_SG); |
1432 | sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1); | 1432 | sg_set_page(sg, virt_to_page(sc->top_sense), UB_SENSE_SIZE, |
1433 | sg->length = UB_SENSE_SIZE; | 1433 | (unsigned long)sc->top_sense & (PAGE_SIZE-1)); |
1434 | scmd->len = UB_SENSE_SIZE; | 1434 | scmd->len = UB_SENSE_SIZE; |
1435 | scmd->lun = cmd->lun; | 1435 | scmd->lun = cmd->lun; |
1436 | scmd->done = ub_top_sense_done; | 1436 | scmd->done = ub_top_sense_done; |
@@ -1864,9 +1864,8 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, | |||
1864 | cmd->state = UB_CMDST_INIT; | 1864 | cmd->state = UB_CMDST_INIT; |
1865 | cmd->nsg = 1; | 1865 | cmd->nsg = 1; |
1866 | sg = &cmd->sgv[0]; | 1866 | sg = &cmd->sgv[0]; |
1867 | sg_set_page(sg, virt_to_page(p)); | 1867 | sg_init_table(sg, UB_MAX_REQ_SG); |
1868 | sg->offset = (unsigned long)p & (PAGE_SIZE-1); | 1868 | sg_set_page(sg, virt_to_page(p), 8, (unsigned long)p & (PAGE_SIZE-1)); |
1869 | sg->length = 8; | ||
1870 | cmd->len = 8; | 1869 | cmd->len = 8; |
1871 | cmd->lun = lun; | 1870 | cmd->lun = lun; |
1872 | cmd->done = ub_probe_done; | 1871 | cmd->done = ub_probe_done; |
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index a901eee64ba5..3cf7129d83e6 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -4,7 +4,9 @@ | |||
4 | #include <linux/hdreg.h> | 4 | #include <linux/hdreg.h> |
5 | #include <linux/virtio.h> | 5 | #include <linux/virtio.h> |
6 | #include <linux/virtio_blk.h> | 6 | #include <linux/virtio_blk.h> |
7 | #include <linux/virtio_blk.h> | 7 | #include <linux/scatterlist.h> |
8 | |||
9 | #define VIRTIO_MAX_SG (3+MAX_PHYS_SEGMENTS) | ||
8 | 10 | ||
9 | static unsigned char virtblk_index = 'a'; | 11 | static unsigned char virtblk_index = 'a'; |
10 | struct virtio_blk | 12 | struct virtio_blk |
@@ -23,7 +25,7 @@ struct virtio_blk | |||
23 | mempool_t *pool; | 25 | mempool_t *pool; |
24 | 26 | ||
25 | /* Scatterlist: can be too big for stack. */ | 27 | /* Scatterlist: can be too big for stack. */ |
26 | struct scatterlist sg[3+MAX_PHYS_SEGMENTS]; | 28 | struct scatterlist sg[VIRTIO_MAX_SG]; |
27 | }; | 29 | }; |
28 | 30 | ||
29 | struct virtblk_req | 31 | struct virtblk_req |
@@ -94,8 +96,8 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk, | |||
94 | if (blk_barrier_rq(vbr->req)) | 96 | if (blk_barrier_rq(vbr->req)) |
95 | vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER; | 97 | vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER; |
96 | 98 | ||
97 | /* We have to zero this, otherwise blk_rq_map_sg gets upset. */ | 99 | /* This init could be done at vblk creation time */ |
98 | memset(vblk->sg, 0, sizeof(vblk->sg)); | 100 | sg_init_table(vblk->sg, VIRTIO_MAX_SG); |
99 | sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); | 101 | sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); |
100 | num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); | 102 | num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); |
101 | sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr)); | 103 | sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr)); |
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c index 880b5dce3a62..d8bb44b98a6a 100644 --- a/drivers/cdrom/viocd.c +++ b/drivers/cdrom/viocd.c | |||
@@ -41,9 +41,9 @@ | |||
41 | #include <linux/completion.h> | 41 | #include <linux/completion.h> |
42 | #include <linux/proc_fs.h> | 42 | #include <linux/proc_fs.h> |
43 | #include <linux/seq_file.h> | 43 | #include <linux/seq_file.h> |
44 | #include <linux/scatterlist.h> | ||
44 | 45 | ||
45 | #include <asm/vio.h> | 46 | #include <asm/vio.h> |
46 | #include <asm/scatterlist.h> | ||
47 | #include <asm/iseries/hv_types.h> | 47 | #include <asm/iseries/hv_types.h> |
48 | #include <asm/iseries/hv_lp_event.h> | 48 | #include <asm/iseries/hv_lp_event.h> |
49 | #include <asm/iseries/vio.h> | 49 | #include <asm/iseries/vio.h> |
@@ -258,6 +258,7 @@ static int send_request(struct request *req) | |||
258 | cmd = viomajorsubtype_cdio | viocdwrite; | 258 | cmd = viomajorsubtype_cdio | viocdwrite; |
259 | } | 259 | } |
260 | 260 | ||
261 | sg_init_table(&sg, 1); | ||
261 | if (blk_rq_map_sg(req->q, req, &sg) == 0) { | 262 | if (blk_rq_map_sg(req->q, req, &sg) == 0) { |
262 | printk(VIOCD_KERN_WARNING | 263 | printk(VIOCD_KERN_WARNING |
263 | "error setting up scatter/gather list\n"); | 264 | "error setting up scatter/gather list\n"); |
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig index f22c253bc09f..ccb1fa89de29 100644 --- a/drivers/char/agp/Kconfig +++ b/drivers/char/agp/Kconfig | |||
@@ -56,9 +56,9 @@ config AGP_AMD | |||
56 | X on AMD Irongate, 761, and 762 chipsets. | 56 | X on AMD Irongate, 761, and 762 chipsets. |
57 | 57 | ||
58 | config AGP_AMD64 | 58 | config AGP_AMD64 |
59 | tristate "AMD Opteron/Athlon64 on-CPU GART support" if !IOMMU | 59 | tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU |
60 | depends on AGP && X86 | 60 | depends on AGP && X86 |
61 | default y if IOMMU | 61 | default y if GART_IOMMU |
62 | help | 62 | help |
63 | This option gives you AGP support for the GLX component of | 63 | This option gives you AGP support for the GLX component of |
64 | X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. | 64 | X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. |
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index d95662e96326..d8200ac8f8cb 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -787,7 +787,7 @@ static void __exit agp_amd64_cleanup(void) | |||
787 | 787 | ||
788 | /* On AMD64 the PCI driver needs to initialize this driver early | 788 | /* On AMD64 the PCI driver needs to initialize this driver early |
789 | for the IOMMU, so it has to be called via a backdoor. */ | 789 | for the IOMMU, so it has to be called via a backdoor. */ |
790 | #ifndef CONFIG_IOMMU | 790 | #ifndef CONFIG_GART_IOMMU |
791 | module_init(agp_amd64_init); | 791 | module_init(agp_amd64_init); |
792 | module_exit(agp_amd64_cleanup); | 792 | module_exit(agp_amd64_cleanup); |
793 | #endif | 793 | #endif |
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 0e937f64a789..20070b7c573d 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -41,7 +41,7 @@ | |||
41 | */ | 41 | */ |
42 | static inline int uncached_access(struct file *file, unsigned long addr) | 42 | static inline int uncached_access(struct file *file, unsigned long addr) |
43 | { | 43 | { |
44 | #if defined(__i386__) | 44 | #if defined(__i386__) && !defined(__arch_um__) |
45 | /* | 45 | /* |
46 | * On the PPro and successors, the MTRRs are used to set | 46 | * On the PPro and successors, the MTRRs are used to set |
47 | * memory types for physical addresses outside main memory, | 47 | * memory types for physical addresses outside main memory, |
@@ -57,7 +57,7 @@ static inline int uncached_access(struct file *file, unsigned long addr) | |||
57 | test_bit(X86_FEATURE_CYRIX_ARR, boot_cpu_data.x86_capability) || | 57 | test_bit(X86_FEATURE_CYRIX_ARR, boot_cpu_data.x86_capability) || |
58 | test_bit(X86_FEATURE_CENTAUR_MCR, boot_cpu_data.x86_capability) ) | 58 | test_bit(X86_FEATURE_CENTAUR_MCR, boot_cpu_data.x86_capability) ) |
59 | && addr >= __pa(high_memory); | 59 | && addr >= __pa(high_memory); |
60 | #elif defined(__x86_64__) | 60 | #elif defined(__x86_64__) && !defined(__arch_um__) |
61 | /* | 61 | /* |
62 | * This is broken because it can generate memory type aliases, | 62 | * This is broken because it can generate memory type aliases, |
63 | * which can cause cache corruptions | 63 | * which can cause cache corruptions |
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c index 0e328d387af4..6883fcb79ad3 100644 --- a/drivers/connector/connector.c +++ b/drivers/connector/connector.c | |||
@@ -218,7 +218,7 @@ static void cn_rx_skb(struct sk_buff *__skb) | |||
218 | skb->len < nlh->nlmsg_len || | 218 | skb->len < nlh->nlmsg_len || |
219 | nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) { | 219 | nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) { |
220 | kfree_skb(skb); | 220 | kfree_skb(skb); |
221 | goto out; | 221 | return; |
222 | } | 222 | } |
223 | 223 | ||
224 | len = NLMSG_ALIGN(nlh->nlmsg_len); | 224 | len = NLMSG_ALIGN(nlh->nlmsg_len); |
@@ -229,9 +229,6 @@ static void cn_rx_skb(struct sk_buff *__skb) | |||
229 | if (err < 0) | 229 | if (err < 0) |
230 | kfree_skb(skb); | 230 | kfree_skb(skb); |
231 | } | 231 | } |
232 | |||
233 | out: | ||
234 | kfree_skb(__skb); | ||
235 | } | 232 | } |
236 | 233 | ||
237 | /* | 234 | /* |
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index fdf4106b817b..d2fabe7863a9 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include "cpuidle.h" | 19 | #include "cpuidle.h" |
20 | 20 | ||
21 | DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); | 21 | DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); |
22 | EXPORT_PER_CPU_SYMBOL_GPL(cpuidle_devices); | ||
23 | 22 | ||
24 | DEFINE_MUTEX(cpuidle_lock); | 23 | DEFINE_MUTEX(cpuidle_lock); |
25 | LIST_HEAD(cpuidle_detected_devices); | 24 | LIST_HEAD(cpuidle_detected_devices); |
diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c index bb699cb2dc5a..70b59642a708 100644 --- a/drivers/cpuidle/governor.c +++ b/drivers/cpuidle/governor.c | |||
@@ -94,8 +94,6 @@ int cpuidle_register_governor(struct cpuidle_governor *gov) | |||
94 | return ret; | 94 | return ret; |
95 | } | 95 | } |
96 | 96 | ||
97 | EXPORT_SYMBOL_GPL(cpuidle_register_governor); | ||
98 | |||
99 | /** | 97 | /** |
100 | * cpuidle_replace_governor - find a replacement governor | 98 | * cpuidle_replace_governor - find a replacement governor |
101 | * @exclude_rating: the rating that will be skipped while looking for | 99 | * @exclude_rating: the rating that will be skipped while looking for |
@@ -138,4 +136,3 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov) | |||
138 | mutex_unlock(&cpuidle_lock); | 136 | mutex_unlock(&cpuidle_lock); |
139 | } | 137 | } |
140 | 138 | ||
141 | EXPORT_SYMBOL_GPL(cpuidle_unregister_governor); | ||
diff --git a/drivers/crypto/padlock-sha.c b/drivers/crypto/padlock-sha.c index 4e8de162fc12..c666b4e0933e 100644 --- a/drivers/crypto/padlock-sha.c +++ b/drivers/crypto/padlock-sha.c | |||
@@ -55,7 +55,7 @@ static void padlock_sha_bypass(struct crypto_tfm *tfm) | |||
55 | if (ctx(tfm)->data && ctx(tfm)->used) { | 55 | if (ctx(tfm)->data && ctx(tfm)->used) { |
56 | struct scatterlist sg; | 56 | struct scatterlist sg; |
57 | 57 | ||
58 | sg_set_buf(&sg, ctx(tfm)->data, ctx(tfm)->used); | 58 | sg_init_one(&sg, ctx(tfm)->data, ctx(tfm)->used); |
59 | crypto_hash_update(&ctx(tfm)->fallback, &sg, sg.length); | 59 | crypto_hash_update(&ctx(tfm)->fallback, &sg, sg.length); |
60 | } | 60 | } |
61 | 61 | ||
@@ -79,7 +79,7 @@ static void padlock_sha_update(struct crypto_tfm *tfm, | |||
79 | 79 | ||
80 | if (unlikely(ctx(tfm)->bypass)) { | 80 | if (unlikely(ctx(tfm)->bypass)) { |
81 | struct scatterlist sg; | 81 | struct scatterlist sg; |
82 | sg_set_buf(&sg, (uint8_t *)data, length); | 82 | sg_init_one(&sg, (uint8_t *)data, length); |
83 | crypto_hash_update(&ctx(tfm)->fallback, &sg, length); | 83 | crypto_hash_update(&ctx(tfm)->fallback, &sg, length); |
84 | return; | 84 | return; |
85 | } | 85 | } |
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 9c91b0fd134f..6a7d25fc2470 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig | |||
@@ -43,7 +43,6 @@ comment "DMA Clients" | |||
43 | config NET_DMA | 43 | config NET_DMA |
44 | bool "Network: TCP receive copy offload" | 44 | bool "Network: TCP receive copy offload" |
45 | depends on DMA_ENGINE && NET | 45 | depends on DMA_ENGINE && NET |
46 | default y | ||
47 | help | 46 | help |
48 | This enables the use of DMA engines in the network stack to | 47 | This enables the use of DMA engines in the network stack to |
49 | offload receive copy-to-user operations, freeing CPU cycles. | 48 | offload receive copy-to-user operations, freeing CPU cycles. |
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c index 67588326ae56..c9b9081831da 100644 --- a/drivers/firewire/fw-ohci.c +++ b/drivers/firewire/fw-ohci.c | |||
@@ -984,8 +984,10 @@ static void bus_reset_tasklet(unsigned long data) | |||
984 | */ | 984 | */ |
985 | 985 | ||
986 | if (ohci->next_config_rom != NULL) { | 986 | if (ohci->next_config_rom != NULL) { |
987 | free_rom = ohci->config_rom; | 987 | if (ohci->next_config_rom != ohci->config_rom) { |
988 | free_rom_bus = ohci->config_rom_bus; | 988 | free_rom = ohci->config_rom; |
989 | free_rom_bus = ohci->config_rom_bus; | ||
990 | } | ||
989 | ohci->config_rom = ohci->next_config_rom; | 991 | ohci->config_rom = ohci->next_config_rom; |
990 | ohci->config_rom_bus = ohci->next_config_rom_bus; | 992 | ohci->config_rom_bus = ohci->next_config_rom_bus; |
991 | ohci->next_config_rom = NULL; | 993 | ohci->next_config_rom = NULL; |
@@ -1161,19 +1163,30 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) | |||
1161 | * the right values in the bus reset tasklet. | 1163 | * the right values in the bus reset tasklet. |
1162 | */ | 1164 | */ |
1163 | 1165 | ||
1164 | ohci->next_config_rom = | 1166 | if (config_rom) { |
1165 | dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, | 1167 | ohci->next_config_rom = |
1166 | &ohci->next_config_rom_bus, GFP_KERNEL); | 1168 | dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, |
1167 | if (ohci->next_config_rom == NULL) | 1169 | &ohci->next_config_rom_bus, |
1168 | return -ENOMEM; | 1170 | GFP_KERNEL); |
1171 | if (ohci->next_config_rom == NULL) | ||
1172 | return -ENOMEM; | ||
1169 | 1173 | ||
1170 | memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); | 1174 | memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); |
1171 | fw_memcpy_to_be32(ohci->next_config_rom, config_rom, length * 4); | 1175 | fw_memcpy_to_be32(ohci->next_config_rom, config_rom, length * 4); |
1176 | } else { | ||
1177 | /* | ||
1178 | * In the suspend case, config_rom is NULL, which | ||
1179 | * means that we just reuse the old config rom. | ||
1180 | */ | ||
1181 | ohci->next_config_rom = ohci->config_rom; | ||
1182 | ohci->next_config_rom_bus = ohci->config_rom_bus; | ||
1183 | } | ||
1172 | 1184 | ||
1173 | ohci->next_header = config_rom[0]; | 1185 | ohci->next_header = be32_to_cpu(ohci->next_config_rom[0]); |
1174 | ohci->next_config_rom[0] = 0; | 1186 | ohci->next_config_rom[0] = 0; |
1175 | reg_write(ohci, OHCI1394_ConfigROMhdr, 0); | 1187 | reg_write(ohci, OHCI1394_ConfigROMhdr, 0); |
1176 | reg_write(ohci, OHCI1394_BusOptions, config_rom[2]); | 1188 | reg_write(ohci, OHCI1394_BusOptions, |
1189 | be32_to_cpu(ohci->next_config_rom[2])); | ||
1177 | reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); | 1190 | reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); |
1178 | 1191 | ||
1179 | reg_write(ohci, OHCI1394_AsReqFilterHiSet, 0x80000000); | 1192 | reg_write(ohci, OHCI1394_AsReqFilterHiSet, 0x80000000); |
@@ -1984,7 +1997,7 @@ static int pci_resume(struct pci_dev *pdev) | |||
1984 | return err; | 1997 | return err; |
1985 | } | 1998 | } |
1986 | 1999 | ||
1987 | return ohci_enable(&ohci->card, ohci->config_rom, CONFIG_ROM_SIZE); | 2000 | return ohci_enable(&ohci->card, NULL, 0); |
1988 | } | 2001 | } |
1989 | #endif | 2002 | #endif |
1990 | 2003 | ||
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 410a0d13e35e..93f71fcfc04d 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -316,13 +316,13 @@ static int icside_dma_end(ide_drive_t *drive) | |||
316 | 316 | ||
317 | drive->waiting_for_dma = 0; | 317 | drive->waiting_for_dma = 0; |
318 | 318 | ||
319 | disable_dma(state->dev->dma); | 319 | disable_dma(ECARD_DEV(state->dev)->dma); |
320 | 320 | ||
321 | /* Teardown mappings after DMA has completed. */ | 321 | /* Teardown mappings after DMA has completed. */ |
322 | dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, | 322 | dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, |
323 | hwif->sg_dma_direction); | 323 | hwif->sg_dma_direction); |
324 | 324 | ||
325 | return get_dma_residue(state->dev->dma) != 0; | 325 | return get_dma_residue(ECARD_DEV(state->dev)->dma) != 0; |
326 | } | 326 | } |
327 | 327 | ||
328 | static void icside_dma_start(ide_drive_t *drive) | 328 | static void icside_dma_start(ide_drive_t *drive) |
@@ -331,8 +331,8 @@ static void icside_dma_start(ide_drive_t *drive) | |||
331 | struct icside_state *state = hwif->hwif_data; | 331 | struct icside_state *state = hwif->hwif_data; |
332 | 332 | ||
333 | /* We can not enable DMA on both channels simultaneously. */ | 333 | /* We can not enable DMA on both channels simultaneously. */ |
334 | BUG_ON(dma_channel_active(state->dev->dma)); | 334 | BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); |
335 | enable_dma(state->dev->dma); | 335 | enable_dma(ECARD_DEV(state->dev)->dma); |
336 | } | 336 | } |
337 | 337 | ||
338 | static int icside_dma_setup(ide_drive_t *drive) | 338 | static int icside_dma_setup(ide_drive_t *drive) |
@@ -350,7 +350,7 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
350 | /* | 350 | /* |
351 | * We can not enable DMA on both channels. | 351 | * We can not enable DMA on both channels. |
352 | */ | 352 | */ |
353 | BUG_ON(dma_channel_active(state->dev->dma)); | 353 | BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); |
354 | 354 | ||
355 | icside_build_sglist(drive, rq); | 355 | icside_build_sglist(drive, rq); |
356 | 356 | ||
@@ -367,14 +367,14 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
367 | /* | 367 | /* |
368 | * Select the correct timing for this drive. | 368 | * Select the correct timing for this drive. |
369 | */ | 369 | */ |
370 | set_dma_speed(state->dev->dma, drive->drive_data); | 370 | set_dma_speed(ECARD_DEV(state->dev)->dma, drive->drive_data); |
371 | 371 | ||
372 | /* | 372 | /* |
373 | * Tell the DMA engine about the SG table and | 373 | * Tell the DMA engine about the SG table and |
374 | * data direction. | 374 | * data direction. |
375 | */ | 375 | */ |
376 | set_dma_sg(state->dev->dma, hwif->sg_table, hwif->sg_nents); | 376 | set_dma_sg(ECARD_DEV(state->dev)->dma, hwif->sg_table, hwif->sg_nents); |
377 | set_dma_mode(state->dev->dma, dma_mode); | 377 | set_dma_mode(ECARD_DEV(state->dev)->dma, dma_mode); |
378 | 378 | ||
379 | drive->waiting_for_dma = 1; | 379 | drive->waiting_for_dma = 1; |
380 | 380 | ||
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 95168833d069..dcda0f109df5 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -582,9 +582,12 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list); | |||
582 | /* | 582 | /* |
583 | * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid. | 583 | * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid. |
584 | * We list them here and depend on the device side cable detection for them. | 584 | * We list them here and depend on the device side cable detection for them. |
585 | * | ||
586 | * Some optical devices with the buggy firmwares have the same problem. | ||
585 | */ | 587 | */ |
586 | static const struct drive_list_entry ivb_list[] = { | 588 | static const struct drive_list_entry ivb_list[] = { |
587 | { "QUANTUM FIREBALLlct10 05" , "A03.0900" }, | 589 | { "QUANTUM FIREBALLlct10 05" , "A03.0900" }, |
590 | { "TSSTcorp CDDVDW SH-S202J" , "SB00" }, | ||
588 | { NULL , NULL } | 591 | { NULL , NULL } |
589 | }; | 592 | }; |
590 | 593 | ||
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index 3ef4fc10fe2c..1cd4e9cb0521 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/cy82c693.c Version 0.41 Aug 27, 2007 | 2 | * linux/drivers/ide/pci/cy82c693.c Version 0.42 Oct 23, 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer | 4 | * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer |
5 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator | 5 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator |
@@ -436,10 +436,10 @@ static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) | |||
436 | hwif->ide_dma_on = &cy82c693_ide_dma_on; | 436 | hwif->ide_dma_on = &cy82c693_ide_dma_on; |
437 | } | 437 | } |
438 | 438 | ||
439 | static __devinitdata ide_hwif_t *primary; | ||
440 | |||
441 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) | 439 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) |
442 | { | 440 | { |
441 | static ide_hwif_t *primary; | ||
442 | |||
443 | if (PCI_FUNC(hwif->pci_dev->devfn) == 1) | 443 | if (PCI_FUNC(hwif->pci_dev->devfn) == 1) |
444 | primary = hwif; | 444 | primary = hwif; |
445 | else { | 445 | else { |
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c index f44d70852c3c..06885697ed7b 100644 --- a/drivers/ide/pci/generic.c +++ b/drivers/ide/pci/generic.c | |||
@@ -49,7 +49,7 @@ static int __init ide_generic_all_on(char *unused) | |||
49 | printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n"); | 49 | printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n"); |
50 | return 1; | 50 | return 1; |
51 | } | 51 | } |
52 | __setup("all-generic-ide", ide_generic_all_on); | 52 | const __setup("all-generic-ide", ide_generic_all_on); |
53 | #endif | 53 | #endif |
54 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); | 54 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); |
55 | MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); | 55 | MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 612b795241bf..5682895d36d9 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/hpt366.c Version 1.20 Oct 1, 2007 | 2 | * linux/drivers/ide/pci/hpt366.c Version 1.21 Oct 23, 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> |
5 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. | 5 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. |
@@ -433,7 +433,7 @@ static u32 *hpt37x_settings[NUM_ATA_CLOCKS] = { | |||
433 | sixty_six_base_hpt37x | 433 | sixty_six_base_hpt37x |
434 | }; | 434 | }; |
435 | 435 | ||
436 | static struct hpt_info hpt36x __devinitdata = { | 436 | static const struct hpt_info hpt36x __devinitdata = { |
437 | .chip_name = "HPT36x", | 437 | .chip_name = "HPT36x", |
438 | .chip_type = HPT36x, | 438 | .chip_type = HPT36x, |
439 | .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2, | 439 | .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2, |
@@ -441,7 +441,7 @@ static struct hpt_info hpt36x __devinitdata = { | |||
441 | .settings = hpt36x_settings | 441 | .settings = hpt36x_settings |
442 | }; | 442 | }; |
443 | 443 | ||
444 | static struct hpt_info hpt370 __devinitdata = { | 444 | static const struct hpt_info hpt370 __devinitdata = { |
445 | .chip_name = "HPT370", | 445 | .chip_name = "HPT370", |
446 | .chip_type = HPT370, | 446 | .chip_type = HPT370, |
447 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, | 447 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, |
@@ -449,7 +449,7 @@ static struct hpt_info hpt370 __devinitdata = { | |||
449 | .settings = hpt37x_settings | 449 | .settings = hpt37x_settings |
450 | }; | 450 | }; |
451 | 451 | ||
452 | static struct hpt_info hpt370a __devinitdata = { | 452 | static const struct hpt_info hpt370a __devinitdata = { |
453 | .chip_name = "HPT370A", | 453 | .chip_name = "HPT370A", |
454 | .chip_type = HPT370A, | 454 | .chip_type = HPT370A, |
455 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, | 455 | .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, |
@@ -457,7 +457,7 @@ static struct hpt_info hpt370a __devinitdata = { | |||
457 | .settings = hpt37x_settings | 457 | .settings = hpt37x_settings |
458 | }; | 458 | }; |
459 | 459 | ||
460 | static struct hpt_info hpt374 __devinitdata = { | 460 | static const struct hpt_info hpt374 __devinitdata = { |
461 | .chip_name = "HPT374", | 461 | .chip_name = "HPT374", |
462 | .chip_type = HPT374, | 462 | .chip_type = HPT374, |
463 | .udma_mask = ATA_UDMA5, | 463 | .udma_mask = ATA_UDMA5, |
@@ -465,7 +465,7 @@ static struct hpt_info hpt374 __devinitdata = { | |||
465 | .settings = hpt37x_settings | 465 | .settings = hpt37x_settings |
466 | }; | 466 | }; |
467 | 467 | ||
468 | static struct hpt_info hpt372 __devinitdata = { | 468 | static const struct hpt_info hpt372 __devinitdata = { |
469 | .chip_name = "HPT372", | 469 | .chip_name = "HPT372", |
470 | .chip_type = HPT372, | 470 | .chip_type = HPT372, |
471 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 471 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -473,7 +473,7 @@ static struct hpt_info hpt372 __devinitdata = { | |||
473 | .settings = hpt37x_settings | 473 | .settings = hpt37x_settings |
474 | }; | 474 | }; |
475 | 475 | ||
476 | static struct hpt_info hpt372a __devinitdata = { | 476 | static const struct hpt_info hpt372a __devinitdata = { |
477 | .chip_name = "HPT372A", | 477 | .chip_name = "HPT372A", |
478 | .chip_type = HPT372A, | 478 | .chip_type = HPT372A, |
479 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 479 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -481,7 +481,7 @@ static struct hpt_info hpt372a __devinitdata = { | |||
481 | .settings = hpt37x_settings | 481 | .settings = hpt37x_settings |
482 | }; | 482 | }; |
483 | 483 | ||
484 | static struct hpt_info hpt302 __devinitdata = { | 484 | static const struct hpt_info hpt302 __devinitdata = { |
485 | .chip_name = "HPT302", | 485 | .chip_name = "HPT302", |
486 | .chip_type = HPT302, | 486 | .chip_type = HPT302, |
487 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 487 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -489,7 +489,7 @@ static struct hpt_info hpt302 __devinitdata = { | |||
489 | .settings = hpt37x_settings | 489 | .settings = hpt37x_settings |
490 | }; | 490 | }; |
491 | 491 | ||
492 | static struct hpt_info hpt371 __devinitdata = { | 492 | static const struct hpt_info hpt371 __devinitdata = { |
493 | .chip_name = "HPT371", | 493 | .chip_name = "HPT371", |
494 | .chip_type = HPT371, | 494 | .chip_type = HPT371, |
495 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 495 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -497,7 +497,7 @@ static struct hpt_info hpt371 __devinitdata = { | |||
497 | .settings = hpt37x_settings | 497 | .settings = hpt37x_settings |
498 | }; | 498 | }; |
499 | 499 | ||
500 | static struct hpt_info hpt372n __devinitdata = { | 500 | static const struct hpt_info hpt372n __devinitdata = { |
501 | .chip_name = "HPT372N", | 501 | .chip_name = "HPT372N", |
502 | .chip_type = HPT372N, | 502 | .chip_type = HPT372N, |
503 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 503 | .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -505,7 +505,7 @@ static struct hpt_info hpt372n __devinitdata = { | |||
505 | .settings = hpt37x_settings | 505 | .settings = hpt37x_settings |
506 | }; | 506 | }; |
507 | 507 | ||
508 | static struct hpt_info hpt302n __devinitdata = { | 508 | static const struct hpt_info hpt302n __devinitdata = { |
509 | .chip_name = "HPT302N", | 509 | .chip_name = "HPT302N", |
510 | .chip_type = HPT302N, | 510 | .chip_type = HPT302N, |
511 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 511 | .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -513,7 +513,7 @@ static struct hpt_info hpt302n __devinitdata = { | |||
513 | .settings = hpt37x_settings | 513 | .settings = hpt37x_settings |
514 | }; | 514 | }; |
515 | 515 | ||
516 | static struct hpt_info hpt371n __devinitdata = { | 516 | static const struct hpt_info hpt371n __devinitdata = { |
517 | .chip_name = "HPT371N", | 517 | .chip_name = "HPT371N", |
518 | .chip_type = HPT371N, | 518 | .chip_type = HPT371N, |
519 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, | 519 | .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, |
@@ -1508,7 +1508,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1508 | */ | 1508 | */ |
1509 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 1509 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
1510 | { | 1510 | { |
1511 | struct hpt_info *info = NULL; | 1511 | const struct hpt_info *info = NULL; |
1512 | struct pci_dev *dev2 = NULL; | 1512 | struct pci_dev *dev2 = NULL; |
1513 | struct ide_port_info d; | 1513 | struct ide_port_info d; |
1514 | u8 idx = id->driver_data; | 1514 | u8 idx = id->driver_data; |
@@ -1522,7 +1522,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1522 | if (rev < 3) | 1522 | if (rev < 3) |
1523 | info = &hpt36x; | 1523 | info = &hpt36x; |
1524 | else { | 1524 | else { |
1525 | static struct hpt_info *hpt37x_info[] = | 1525 | static const struct hpt_info *hpt37x_info[] = |
1526 | { &hpt370, &hpt370a, &hpt372, &hpt372n }; | 1526 | { &hpt370, &hpt370a, &hpt372, &hpt372n }; |
1527 | 1527 | ||
1528 | info = hpt37x_info[min_t(u8, rev, 6) - 3]; | 1528 | info = hpt37x_info[min_t(u8, rev, 6) - 3]; |
@@ -1552,7 +1552,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1552 | d.name = info->chip_name; | 1552 | d.name = info->chip_name; |
1553 | d.udma_mask = info->udma_mask; | 1553 | d.udma_mask = info->udma_mask; |
1554 | 1554 | ||
1555 | pci_set_drvdata(dev, info); | 1555 | pci_set_drvdata(dev, (void *)info); |
1556 | 1556 | ||
1557 | if (info == &hpt36x || info == &hpt374) | 1557 | if (info == &hpt36x || info == &hpt374) |
1558 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); | 1558 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); |
@@ -1560,7 +1560,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1560 | if (dev2) { | 1560 | if (dev2) { |
1561 | int ret; | 1561 | int ret; |
1562 | 1562 | ||
1563 | pci_set_drvdata(dev2, info); | 1563 | pci_set_drvdata(dev2, (void *)info); |
1564 | 1564 | ||
1565 | if (info == &hpt374) | 1565 | if (info == &hpt374) |
1566 | hpt374_init(dev, dev2); | 1566 | hpt374_init(dev, dev2); |
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index d2c8b5524f28..0a7b3202066d 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
@@ -324,17 +324,18 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) | |||
324 | 324 | ||
325 | pci_disable_device(dev); | 325 | pci_disable_device(dev); |
326 | pci_set_power_state(dev, pci_choose_state(dev, state)); | 326 | pci_set_power_state(dev, pci_choose_state(dev, state)); |
327 | dev->current_state = state.event; | ||
328 | return 0; | 327 | return 0; |
329 | } | 328 | } |
330 | 329 | ||
331 | static int sc1200_resume (struct pci_dev *dev) | 330 | static int sc1200_resume (struct pci_dev *dev) |
332 | { | 331 | { |
333 | ide_hwif_t *hwif = NULL; | 332 | ide_hwif_t *hwif = NULL; |
333 | int i; | ||
334 | |||
335 | i = pci_enable_device(dev); | ||
336 | if (i) | ||
337 | return i; | ||
334 | 338 | ||
335 | pci_set_power_state(dev, PCI_D0); // bring chip back from sleep state | ||
336 | dev->current_state = PM_EVENT_ON; | ||
337 | pci_enable_device(dev); | ||
338 | // | 339 | // |
339 | // loop over all interfaces that are part of this pci device: | 340 | // loop over all interfaces that are part of this pci device: |
340 | // | 341 | // |
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c index 3051e312fdc8..f5f4983dfbf3 100644 --- a/drivers/ieee1394/dma.c +++ b/drivers/ieee1394/dma.c | |||
@@ -111,8 +111,8 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, | |||
111 | unsigned long va = | 111 | unsigned long va = |
112 | (unsigned long)dma->kvirt + (i << PAGE_SHIFT); | 112 | (unsigned long)dma->kvirt + (i << PAGE_SHIFT); |
113 | 113 | ||
114 | sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va)); | 114 | sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va), |
115 | dma->sglist[i].length = PAGE_SIZE; | 115 | PAGE_SIZE, 0); |
116 | } | 116 | } |
117 | 117 | ||
118 | /* map sglist to the IOMMU */ | 118 | /* map sglist to the IOMMU */ |
diff --git a/drivers/ieee1394/ieee1394_transactions.c b/drivers/ieee1394/ieee1394_transactions.c index c39c70a8aa9f..677989320951 100644 --- a/drivers/ieee1394/ieee1394_transactions.c +++ b/drivers/ieee1394/ieee1394_transactions.c | |||
@@ -235,7 +235,6 @@ int hpsb_packet_success(struct hpsb_packet *packet) | |||
235 | packet->node_id); | 235 | packet->node_id); |
236 | return -EAGAIN; | 236 | return -EAGAIN; |
237 | } | 237 | } |
238 | BUG(); | ||
239 | 238 | ||
240 | case ACK_BUSY_X: | 239 | case ACK_BUSY_X: |
241 | case ACK_BUSY_A: | 240 | case ACK_BUSY_A: |
@@ -282,7 +281,6 @@ int hpsb_packet_success(struct hpsb_packet *packet) | |||
282 | packet->ack_code, packet->node_id, packet->tcode); | 281 | packet->ack_code, packet->node_id, packet->tcode); |
283 | return -EAGAIN; | 282 | return -EAGAIN; |
284 | } | 283 | } |
285 | BUG(); | ||
286 | } | 284 | } |
287 | 285 | ||
288 | struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node, | 286 | struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node, |
diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c index d7f64525469b..e8d5f6b64998 100644 --- a/drivers/infiniband/core/fmr_pool.c +++ b/drivers/infiniband/core/fmr_pool.c | |||
@@ -291,10 +291,10 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd, | |||
291 | atomic_set(&pool->flush_ser, 0); | 291 | atomic_set(&pool->flush_ser, 0); |
292 | init_waitqueue_head(&pool->force_wait); | 292 | init_waitqueue_head(&pool->force_wait); |
293 | 293 | ||
294 | pool->thread = kthread_create(ib_fmr_cleanup_thread, | 294 | pool->thread = kthread_run(ib_fmr_cleanup_thread, |
295 | pool, | 295 | pool, |
296 | "ib_fmr(%s)", | 296 | "ib_fmr(%s)", |
297 | device->name); | 297 | device->name); |
298 | if (IS_ERR(pool->thread)) { | 298 | if (IS_ERR(pool->thread)) { |
299 | printk(KERN_WARNING PFX "couldn't start cleanup thread\n"); | 299 | printk(KERN_WARNING PFX "couldn't start cleanup thread\n"); |
300 | ret = PTR_ERR(pool->thread); | 300 | ret = PTR_ERR(pool->thread); |
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 14159ff29408..4e3128ff73c1 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c | |||
@@ -171,9 +171,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, | |||
171 | if (vma_list && | 171 | if (vma_list && |
172 | !is_vm_hugetlb_page(vma_list[i + off])) | 172 | !is_vm_hugetlb_page(vma_list[i + off])) |
173 | umem->hugetlb = 0; | 173 | umem->hugetlb = 0; |
174 | sg_set_page(&chunk->page_list[i], page_list[i + off]); | 174 | sg_set_page(&chunk->page_list[i], page_list[i + off], PAGE_SIZE, 0); |
175 | chunk->page_list[i].offset = 0; | ||
176 | chunk->page_list[i].length = PAGE_SIZE; | ||
177 | } | 175 | } |
178 | 176 | ||
179 | chunk->nmap = ib_dma_map_sg(context->device, | 177 | chunk->nmap = ib_dma_map_sg(context->device, |
diff --git a/drivers/infiniband/hw/ipath/ipath_eeprom.c b/drivers/infiniband/hw/ipath/ipath_eeprom.c index bcfa3ccb555f..e7c25dbbcdc9 100644 --- a/drivers/infiniband/hw/ipath/ipath_eeprom.c +++ b/drivers/infiniband/hw/ipath/ipath_eeprom.c | |||
@@ -538,7 +538,15 @@ static u8 flash_csum(struct ipath_flash *ifp, int adjust) | |||
538 | u8 *ip = (u8 *) ifp; | 538 | u8 *ip = (u8 *) ifp; |
539 | u8 csum = 0, len; | 539 | u8 csum = 0, len; |
540 | 540 | ||
541 | for (len = 0; len < ifp->if_length; len++) | 541 | /* |
542 | * Limit length checksummed to max length of actual data. | ||
543 | * Checksum of erased eeprom will still be bad, but we avoid | ||
544 | * reading past the end of the buffer we were passed. | ||
545 | */ | ||
546 | len = ifp->if_length; | ||
547 | if (len > sizeof(struct ipath_flash)) | ||
548 | len = sizeof(struct ipath_flash); | ||
549 | while (len--) | ||
542 | csum += *ip++; | 550 | csum += *ip++; |
543 | csum -= ifp->if_csum; | 551 | csum -= ifp->if_csum; |
544 | csum = ~csum; | 552 | csum = ~csum; |
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c index 6a5dd5cd773d..c61f9da2964a 100644 --- a/drivers/infiniband/hw/ipath/ipath_intr.c +++ b/drivers/infiniband/hw/ipath/ipath_intr.c | |||
@@ -453,7 +453,7 @@ skip_ibchange: | |||
453 | } | 453 | } |
454 | 454 | ||
455 | static void handle_supp_msgs(struct ipath_devdata *dd, | 455 | static void handle_supp_msgs(struct ipath_devdata *dd, |
456 | unsigned supp_msgs, char msg[512]) | 456 | unsigned supp_msgs, char *msg, int msgsz) |
457 | { | 457 | { |
458 | /* | 458 | /* |
459 | * Print the message unless it's ibc status change only, which | 459 | * Print the message unless it's ibc status change only, which |
@@ -461,9 +461,9 @@ static void handle_supp_msgs(struct ipath_devdata *dd, | |||
461 | */ | 461 | */ |
462 | if (dd->ipath_lasterror & ~INFINIPATH_E_IBSTATUSCHANGED) { | 462 | if (dd->ipath_lasterror & ~INFINIPATH_E_IBSTATUSCHANGED) { |
463 | int iserr; | 463 | int iserr; |
464 | iserr = ipath_decode_err(msg, sizeof msg, | 464 | iserr = ipath_decode_err(msg, msgsz, |
465 | dd->ipath_lasterror & | 465 | dd->ipath_lasterror & |
466 | ~INFINIPATH_E_IBSTATUSCHANGED); | 466 | ~INFINIPATH_E_IBSTATUSCHANGED); |
467 | if (dd->ipath_lasterror & | 467 | if (dd->ipath_lasterror & |
468 | ~(INFINIPATH_E_RRCVEGRFULL | | 468 | ~(INFINIPATH_E_RRCVEGRFULL | |
469 | INFINIPATH_E_RRCVHDRFULL | INFINIPATH_E_PKTERRS)) | 469 | INFINIPATH_E_RRCVHDRFULL | INFINIPATH_E_PKTERRS)) |
@@ -492,8 +492,8 @@ static void handle_supp_msgs(struct ipath_devdata *dd, | |||
492 | } | 492 | } |
493 | 493 | ||
494 | static unsigned handle_frequent_errors(struct ipath_devdata *dd, | 494 | static unsigned handle_frequent_errors(struct ipath_devdata *dd, |
495 | ipath_err_t errs, char msg[512], | 495 | ipath_err_t errs, char *msg, |
496 | int *noprint) | 496 | int msgsz, int *noprint) |
497 | { | 497 | { |
498 | unsigned long nc; | 498 | unsigned long nc; |
499 | static unsigned long nextmsg_time; | 499 | static unsigned long nextmsg_time; |
@@ -512,7 +512,7 @@ static unsigned handle_frequent_errors(struct ipath_devdata *dd, | |||
512 | nextmsg_time = nc + HZ * 3; | 512 | nextmsg_time = nc + HZ * 3; |
513 | } | 513 | } |
514 | else if (supp_msgs) { | 514 | else if (supp_msgs) { |
515 | handle_supp_msgs(dd, supp_msgs, msg); | 515 | handle_supp_msgs(dd, supp_msgs, msg, msgsz); |
516 | supp_msgs = 0; | 516 | supp_msgs = 0; |
517 | nmsgs = 0; | 517 | nmsgs = 0; |
518 | } | 518 | } |
@@ -525,14 +525,14 @@ static unsigned handle_frequent_errors(struct ipath_devdata *dd, | |||
525 | 525 | ||
526 | static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs) | 526 | static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs) |
527 | { | 527 | { |
528 | char msg[512]; | 528 | char msg[128]; |
529 | u64 ignore_this_time = 0; | 529 | u64 ignore_this_time = 0; |
530 | int i, iserr = 0; | 530 | int i, iserr = 0; |
531 | int chkerrpkts = 0, noprint = 0; | 531 | int chkerrpkts = 0, noprint = 0; |
532 | unsigned supp_msgs; | 532 | unsigned supp_msgs; |
533 | int log_idx; | 533 | int log_idx; |
534 | 534 | ||
535 | supp_msgs = handle_frequent_errors(dd, errs, msg, &noprint); | 535 | supp_msgs = handle_frequent_errors(dd, errs, msg, sizeof msg, &noprint); |
536 | 536 | ||
537 | /* don't report errors that are masked */ | 537 | /* don't report errors that are masked */ |
538 | errs &= ~dd->ipath_maskederrs; | 538 | errs &= ~dd->ipath_maskederrs; |
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c index 4b6b7ee8e5c1..54c61a972de2 100644 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c | |||
@@ -630,11 +630,8 @@ bail:; | |||
630 | void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe, | 630 | void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe, |
631 | enum ib_wc_status status) | 631 | enum ib_wc_status status) |
632 | { | 632 | { |
633 | u32 last = qp->s_last; | 633 | unsigned long flags; |
634 | 634 | u32 last; | |
635 | if (++last == qp->s_size) | ||
636 | last = 0; | ||
637 | qp->s_last = last; | ||
638 | 635 | ||
639 | /* See ch. 11.2.4.1 and 10.7.3.1 */ | 636 | /* See ch. 11.2.4.1 and 10.7.3.1 */ |
640 | if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) || | 637 | if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) || |
@@ -658,4 +655,11 @@ void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe, | |||
658 | wc.port_num = 0; | 655 | wc.port_num = 0; |
659 | ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 0); | 656 | ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 0); |
660 | } | 657 | } |
658 | |||
659 | spin_lock_irqsave(&qp->s_lock, flags); | ||
660 | last = qp->s_last; | ||
661 | if (++last >= qp->s_size) | ||
662 | last = 0; | ||
663 | qp->s_last = last; | ||
664 | spin_unlock_irqrestore(&qp->s_lock, flags); | ||
661 | } | 665 | } |
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 6b3322486b5e..8cba9c532e64 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c | |||
@@ -1282,7 +1282,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1282 | int size; | 1282 | int size; |
1283 | int i; | 1283 | int i; |
1284 | 1284 | ||
1285 | spin_lock_irqsave(&qp->rq.lock, flags); | 1285 | spin_lock_irqsave(&qp->sq.lock, flags); |
1286 | 1286 | ||
1287 | ind = qp->sq.head; | 1287 | ind = qp->sq.head; |
1288 | 1288 | ||
@@ -1448,7 +1448,7 @@ out: | |||
1448 | (qp->sq.wqe_cnt - 1)); | 1448 | (qp->sq.wqe_cnt - 1)); |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | spin_unlock_irqrestore(&qp->rq.lock, flags); | 1451 | spin_unlock_irqrestore(&qp->sq.lock, flags); |
1452 | 1452 | ||
1453 | return err; | 1453 | return err; |
1454 | } | 1454 | } |
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 007b38157fc4..1f4d27d7c16d 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
@@ -113,9 +113,7 @@ static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_m | |||
113 | if (!page) | 113 | if (!page) |
114 | return -ENOMEM; | 114 | return -ENOMEM; |
115 | 115 | ||
116 | sg_set_page(mem, page); | 116 | sg_set_page(mem, page, PAGE_SIZE << order, 0); |
117 | mem->length = PAGE_SIZE << order; | ||
118 | mem->offset = 0; | ||
119 | return 0; | 117 | return 0; |
120 | } | 118 | } |
121 | 119 | ||
@@ -481,9 +479,8 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, | |||
481 | if (ret < 0) | 479 | if (ret < 0) |
482 | goto out; | 480 | goto out; |
483 | 481 | ||
484 | sg_set_page(&db_tab->page[i].mem, pages[0]); | 482 | sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE, |
485 | db_tab->page[i].mem.length = MTHCA_ICM_PAGE_SIZE; | 483 | uaddr & ~PAGE_MASK); |
486 | db_tab->page[i].mem.offset = uaddr & ~PAGE_MASK; | ||
487 | 484 | ||
488 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); | 485 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); |
489 | if (ret < 0) { | 486 | if (ret < 0) { |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 87610772a979..059cf92b60a5 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
@@ -60,7 +60,7 @@ static struct ib_qp_attr ipoib_cm_err_attr = { | |||
60 | .qp_state = IB_QPS_ERR | 60 | .qp_state = IB_QPS_ERR |
61 | }; | 61 | }; |
62 | 62 | ||
63 | #define IPOIB_CM_RX_DRAIN_WRID 0x7fffffff | 63 | #define IPOIB_CM_RX_DRAIN_WRID 0xffffffff |
64 | 64 | ||
65 | static struct ib_send_wr ipoib_cm_rx_drain_wr = { | 65 | static struct ib_send_wr ipoib_cm_rx_drain_wr = { |
66 | .wr_id = IPOIB_CM_RX_DRAIN_WRID, | 66 | .wr_id = IPOIB_CM_RX_DRAIN_WRID, |
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index 476012b6dfac..48c1775ef5b3 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c | |||
@@ -1843,6 +1843,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) | |||
1843 | int msglen; | 1843 | int msglen; |
1844 | u16 errcode; | 1844 | u16 errcode; |
1845 | u16 datahandle; | 1845 | u16 datahandle; |
1846 | u32 data; | ||
1846 | 1847 | ||
1847 | if (!card) { | 1848 | if (!card) { |
1848 | printk(KERN_ERR "capidrv: if_sendbuf called with invalid driverId %d!\n", | 1849 | printk(KERN_ERR "capidrv: if_sendbuf called with invalid driverId %d!\n", |
@@ -1860,9 +1861,26 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) | |||
1860 | return 0; | 1861 | return 0; |
1861 | } | 1862 | } |
1862 | datahandle = nccip->datahandle; | 1863 | datahandle = nccip->datahandle; |
1864 | |||
1865 | /* | ||
1866 | * Here we copy pointer skb->data into the 32-bit 'Data' field. | ||
1867 | * The 'Data' field is not used in practice in linux kernel | ||
1868 | * (neither in 32 or 64 bit), but should have some value, | ||
1869 | * since a CAPI message trace will display it. | ||
1870 | * | ||
1871 | * The correct value in the 32 bit case is the address of the | ||
1872 | * data, in 64 bit it makes no sense, we use 0 there. | ||
1873 | */ | ||
1874 | |||
1875 | #ifdef CONFIG_64BIT | ||
1876 | data = 0; | ||
1877 | #else | ||
1878 | data = (unsigned long) skb->data; | ||
1879 | #endif | ||
1880 | |||
1863 | capi_fill_DATA_B3_REQ(&sendcmsg, global.ap.applid, card->msgid++, | 1881 | capi_fill_DATA_B3_REQ(&sendcmsg, global.ap.applid, card->msgid++, |
1864 | nccip->ncci, /* adr */ | 1882 | nccip->ncci, /* adr */ |
1865 | (u32) skb->data, /* Data */ | 1883 | data, /* Data */ |
1866 | skb->len, /* DataLength */ | 1884 | skb->len, /* DataLength */ |
1867 | datahandle, /* DataHandle */ | 1885 | datahandle, /* DataHandle */ |
1868 | 0 /* Flags */ | 1886 | 0 /* Flags */ |
@@ -2123,7 +2141,10 @@ static int capidrv_delcontr(u16 contr) | |||
2123 | printk(KERN_ERR "capidrv: delcontr: no contr %u\n", contr); | 2141 | printk(KERN_ERR "capidrv: delcontr: no contr %u\n", contr); |
2124 | return -1; | 2142 | return -1; |
2125 | } | 2143 | } |
2126 | #warning FIXME: maybe a race condition the card should be removed here from global list /kkeil | 2144 | |
2145 | /* FIXME: maybe a race condition the card should be removed | ||
2146 | * here from global list /kkeil | ||
2147 | */ | ||
2127 | spin_unlock_irqrestore(&global_lock, flags); | 2148 | spin_unlock_irqrestore(&global_lock, flags); |
2128 | 2149 | ||
2129 | del_timer(&card->listentimer); | 2150 | del_timer(&card->listentimer); |
diff --git a/drivers/isdn/sc/shmem.c b/drivers/isdn/sc/shmem.c index 034d41a61ae1..e0331e0094f1 100644 --- a/drivers/isdn/sc/shmem.c +++ b/drivers/isdn/sc/shmem.c | |||
@@ -28,15 +28,15 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n) | |||
28 | { | 28 | { |
29 | unsigned long flags; | 29 | unsigned long flags; |
30 | unsigned char ch; | 30 | unsigned char ch; |
31 | unsigned long dest_rem = ((unsigned long) dest) % 0x4000; | ||
31 | 32 | ||
32 | if(!IS_VALID_CARD(card)) { | 33 | if (!IS_VALID_CARD(card)) { |
33 | pr_debug("Invalid param: %d is not a valid card id\n", card); | 34 | pr_debug("Invalid param: %d is not a valid card id\n", card); |
34 | return; | 35 | return; |
35 | } | 36 | } |
36 | 37 | ||
37 | if(n > SRAM_PAGESIZE) { | 38 | if (n > SRAM_PAGESIZE) |
38 | return; | 39 | return; |
39 | } | ||
40 | 40 | ||
41 | /* | 41 | /* |
42 | * determine the page to load from the address | 42 | * determine the page to load from the address |
@@ -50,8 +50,7 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n) | |||
50 | 50 | ||
51 | outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, | 51 | outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, |
52 | sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); | 52 | sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); |
53 | memcpy_toio(sc_adapter[card]->rambase + | 53 | memcpy_toio(sc_adapter[card]->rambase + dest_rem, src, n); |
54 | ((unsigned long) dest % 0x4000), src, n); | ||
55 | spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); | 54 | spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); |
56 | pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, | 55 | pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, |
57 | ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); | 56 | ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); |
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c index 35d19ae58de7..cb4c67025d52 100644 --- a/drivers/lguest/core.c +++ b/drivers/lguest/core.c | |||
@@ -128,9 +128,12 @@ static void unmap_switcher(void) | |||
128 | __free_pages(switcher_page[i], 0); | 128 | __free_pages(switcher_page[i], 0); |
129 | } | 129 | } |
130 | 130 | ||
131 | /*L:305 | 131 | /*H:032 |
132 | * Dealing With Guest Memory. | 132 | * Dealing With Guest Memory. |
133 | * | 133 | * |
134 | * Before we go too much further into the Host, we need to grok the routines | ||
135 | * we use to deal with Guest memory. | ||
136 | * | ||
134 | * When the Guest gives us (what it thinks is) a physical address, we can use | 137 | * When the Guest gives us (what it thinks is) a physical address, we can use |
135 | * the normal copy_from_user() & copy_to_user() on the corresponding place in | 138 | * the normal copy_from_user() & copy_to_user() on the corresponding place in |
136 | * the memory region allocated by the Launcher. | 139 | * the memory region allocated by the Launcher. |
diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c index 9d5184c7c14a..b478affe8f91 100644 --- a/drivers/lguest/hypercalls.c +++ b/drivers/lguest/hypercalls.c | |||
@@ -90,6 +90,7 @@ static void do_hcall(struct lguest *lg, struct hcall_args *args) | |||
90 | lg->pending_notify = args->arg1; | 90 | lg->pending_notify = args->arg1; |
91 | break; | 91 | break; |
92 | default: | 92 | default: |
93 | /* It should be an architecture-specific hypercall. */ | ||
93 | if (lguest_arch_do_hcall(lg, args)) | 94 | if (lguest_arch_do_hcall(lg, args)) |
94 | kill_guest(lg, "Bad hypercall %li\n", args->arg0); | 95 | kill_guest(lg, "Bad hypercall %li\n", args->arg0); |
95 | } | 96 | } |
@@ -157,7 +158,6 @@ static void do_async_hcalls(struct lguest *lg) | |||
157 | * Guest makes a hypercall, we end up here to set things up: */ | 158 | * Guest makes a hypercall, we end up here to set things up: */ |
158 | static void initialize(struct lguest *lg) | 159 | static void initialize(struct lguest *lg) |
159 | { | 160 | { |
160 | |||
161 | /* You can't do anything until you're initialized. The Guest knows the | 161 | /* You can't do anything until you're initialized. The Guest knows the |
162 | * rules, so we're unforgiving here. */ | 162 | * rules, so we're unforgiving here. */ |
163 | if (lg->hcall->arg0 != LHCALL_LGUEST_INIT) { | 163 | if (lg->hcall->arg0 != LHCALL_LGUEST_INIT) { |
@@ -174,7 +174,8 @@ static void initialize(struct lguest *lg) | |||
174 | || get_user(lg->noirq_end, &lg->lguest_data->noirq_end)) | 174 | || get_user(lg->noirq_end, &lg->lguest_data->noirq_end)) |
175 | kill_guest(lg, "bad guest page %p", lg->lguest_data); | 175 | kill_guest(lg, "bad guest page %p", lg->lguest_data); |
176 | 176 | ||
177 | /* We write the current time into the Guest's data page once now. */ | 177 | /* We write the current time into the Guest's data page once so it can |
178 | * set its clock. */ | ||
178 | write_timestamp(lg); | 179 | write_timestamp(lg); |
179 | 180 | ||
180 | /* page_tables.c will also do some setup. */ | 181 | /* page_tables.c will also do some setup. */ |
@@ -182,8 +183,8 @@ static void initialize(struct lguest *lg) | |||
182 | 183 | ||
183 | /* This is the one case where the above accesses might have been the | 184 | /* This is the one case where the above accesses might have been the |
184 | * first write to a Guest page. This may have caused a copy-on-write | 185 | * first write to a Guest page. This may have caused a copy-on-write |
185 | * fault, but the Guest might be referring to the old (read-only) | 186 | * fault, but the old page might be (read-only) in the Guest |
186 | * page. */ | 187 | * pagetable. */ |
187 | guest_pagetable_clear_all(lg); | 188 | guest_pagetable_clear_all(lg); |
188 | } | 189 | } |
189 | 190 | ||
@@ -220,7 +221,7 @@ void do_hypercalls(struct lguest *lg) | |||
220 | * Normally it doesn't matter: the Guest will run again and | 221 | * Normally it doesn't matter: the Guest will run again and |
221 | * update the trap number before we come back here. | 222 | * update the trap number before we come back here. |
222 | * | 223 | * |
223 | * However, if we are signalled or the Guest sends DMA to the | 224 | * However, if we are signalled or the Guest sends I/O to the |
224 | * Launcher, the run_guest() loop will exit without running the | 225 | * Launcher, the run_guest() loop will exit without running the |
225 | * Guest. When it comes back it would try to re-run the | 226 | * Guest. When it comes back it would try to re-run the |
226 | * hypercall. */ | 227 | * hypercall. */ |
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c index 82966982cb38..2b66f79c208b 100644 --- a/drivers/lguest/interrupts_and_traps.c +++ b/drivers/lguest/interrupts_and_traps.c | |||
@@ -92,8 +92,8 @@ static void set_guest_interrupt(struct lguest *lg, u32 lo, u32 hi, int has_err) | |||
92 | 92 | ||
93 | /* Remember that we never let the Guest actually disable interrupts, so | 93 | /* Remember that we never let the Guest actually disable interrupts, so |
94 | * the "Interrupt Flag" bit is always set. We copy that bit from the | 94 | * the "Interrupt Flag" bit is always set. We copy that bit from the |
95 | * Guest's "irq_enabled" field into the eflags word: the Guest copies | 95 | * Guest's "irq_enabled" field into the eflags word: we saw the Guest |
96 | * it back in "lguest_iret". */ | 96 | * copy it back in "lguest_iret". */ |
97 | eflags = lg->regs->eflags; | 97 | eflags = lg->regs->eflags; |
98 | if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0 | 98 | if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0 |
99 | && !(irq_enable & X86_EFLAGS_IF)) | 99 | && !(irq_enable & X86_EFLAGS_IF)) |
@@ -124,7 +124,7 @@ static void set_guest_interrupt(struct lguest *lg, u32 lo, u32 hi, int has_err) | |||
124 | kill_guest(lg, "Disabling interrupts"); | 124 | kill_guest(lg, "Disabling interrupts"); |
125 | } | 125 | } |
126 | 126 | ||
127 | /*H:200 | 127 | /*H:205 |
128 | * Virtual Interrupts. | 128 | * Virtual Interrupts. |
129 | * | 129 | * |
130 | * maybe_do_interrupt() gets called before every entry to the Guest, to see if | 130 | * maybe_do_interrupt() gets called before every entry to the Guest, to see if |
@@ -256,19 +256,21 @@ int deliver_trap(struct lguest *lg, unsigned int num) | |||
256 | * bogus one in): if we fail here, the Guest will be killed. */ | 256 | * bogus one in): if we fail here, the Guest will be killed. */ |
257 | if (!idt_present(lg->arch.idt[num].a, lg->arch.idt[num].b)) | 257 | if (!idt_present(lg->arch.idt[num].a, lg->arch.idt[num].b)) |
258 | return 0; | 258 | return 0; |
259 | set_guest_interrupt(lg, lg->arch.idt[num].a, lg->arch.idt[num].b, has_err(num)); | 259 | set_guest_interrupt(lg, lg->arch.idt[num].a, lg->arch.idt[num].b, |
260 | has_err(num)); | ||
260 | return 1; | 261 | return 1; |
261 | } | 262 | } |
262 | 263 | ||
263 | /*H:250 Here's the hard part: returning to the Host every time a trap happens | 264 | /*H:250 Here's the hard part: returning to the Host every time a trap happens |
264 | * and then calling deliver_trap() and re-entering the Guest is slow. | 265 | * and then calling deliver_trap() and re-entering the Guest is slow. |
265 | * Particularly because Guest userspace system calls are traps (trap 128). | 266 | * Particularly because Guest userspace system calls are traps (usually trap |
267 | * 128). | ||
266 | * | 268 | * |
267 | * So we'd like to set up the IDT to tell the CPU to deliver traps directly | 269 | * So we'd like to set up the IDT to tell the CPU to deliver traps directly |
268 | * into the Guest. This is possible, but the complexities cause the size of | 270 | * into the Guest. This is possible, but the complexities cause the size of |
269 | * this file to double! However, 150 lines of code is worth writing for taking | 271 | * this file to double! However, 150 lines of code is worth writing for taking |
270 | * system calls down from 1750ns to 270ns. Plus, if lguest didn't do it, all | 272 | * system calls down from 1750ns to 270ns. Plus, if lguest didn't do it, all |
271 | * the other hypervisors would tease it. | 273 | * the other hypervisors would beat it up at lunchtime. |
272 | * | 274 | * |
273 | * This routine indicates if a particular trap number could be delivered | 275 | * This routine indicates if a particular trap number could be delivered |
274 | * directly. */ | 276 | * directly. */ |
@@ -331,7 +333,7 @@ void pin_stack_pages(struct lguest *lg) | |||
331 | * change stacks on each context switch. */ | 333 | * change stacks on each context switch. */ |
332 | void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) | 334 | void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) |
333 | { | 335 | { |
334 | /* You are not allowd have a stack segment with privilege level 0: bad | 336 | /* You are not allowed have a stack segment with privilege level 0: bad |
335 | * Guest! */ | 337 | * Guest! */ |
336 | if ((seg & 0x3) != GUEST_PL) | 338 | if ((seg & 0x3) != GUEST_PL) |
337 | kill_guest(lg, "bad stack segment %i", seg); | 339 | kill_guest(lg, "bad stack segment %i", seg); |
@@ -350,7 +352,7 @@ void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) | |||
350 | * part of the Host: page table handling. */ | 352 | * part of the Host: page table handling. */ |
351 | 353 | ||
352 | /*H:235 This is the routine which actually checks the Guest's IDT entry and | 354 | /*H:235 This is the routine which actually checks the Guest's IDT entry and |
353 | * transfers it into our entry in "struct lguest": */ | 355 | * transfers it into the entry in "struct lguest": */ |
354 | static void set_trap(struct lguest *lg, struct desc_struct *trap, | 356 | static void set_trap(struct lguest *lg, struct desc_struct *trap, |
355 | unsigned int num, u32 lo, u32 hi) | 357 | unsigned int num, u32 lo, u32 hi) |
356 | { | 358 | { |
@@ -456,6 +458,18 @@ void copy_traps(const struct lguest *lg, struct desc_struct *idt, | |||
456 | } | 458 | } |
457 | } | 459 | } |
458 | 460 | ||
461 | /*H:200 | ||
462 | * The Guest Clock. | ||
463 | * | ||
464 | * There are two sources of virtual interrupts. We saw one in lguest_user.c: | ||
465 | * the Launcher sending interrupts for virtual devices. The other is the Guest | ||
466 | * timer interrupt. | ||
467 | * | ||
468 | * The Guest uses the LHCALL_SET_CLOCKEVENT hypercall to tell us how long to | ||
469 | * the next timer interrupt (in nanoseconds). We use the high-resolution timer | ||
470 | * infrastructure to set a callback at that time. | ||
471 | * | ||
472 | * 0 means "turn off the clock". */ | ||
459 | void guest_set_clockevent(struct lguest *lg, unsigned long delta) | 473 | void guest_set_clockevent(struct lguest *lg, unsigned long delta) |
460 | { | 474 | { |
461 | ktime_t expires; | 475 | ktime_t expires; |
@@ -466,20 +480,27 @@ void guest_set_clockevent(struct lguest *lg, unsigned long delta) | |||
466 | return; | 480 | return; |
467 | } | 481 | } |
468 | 482 | ||
483 | /* We use wallclock time here, so the Guest might not be running for | ||
484 | * all the time between now and the timer interrupt it asked for. This | ||
485 | * is almost always the right thing to do. */ | ||
469 | expires = ktime_add_ns(ktime_get_real(), delta); | 486 | expires = ktime_add_ns(ktime_get_real(), delta); |
470 | hrtimer_start(&lg->hrt, expires, HRTIMER_MODE_ABS); | 487 | hrtimer_start(&lg->hrt, expires, HRTIMER_MODE_ABS); |
471 | } | 488 | } |
472 | 489 | ||
490 | /* This is the function called when the Guest's timer expires. */ | ||
473 | static enum hrtimer_restart clockdev_fn(struct hrtimer *timer) | 491 | static enum hrtimer_restart clockdev_fn(struct hrtimer *timer) |
474 | { | 492 | { |
475 | struct lguest *lg = container_of(timer, struct lguest, hrt); | 493 | struct lguest *lg = container_of(timer, struct lguest, hrt); |
476 | 494 | ||
495 | /* Remember the first interrupt is the timer interrupt. */ | ||
477 | set_bit(0, lg->irqs_pending); | 496 | set_bit(0, lg->irqs_pending); |
497 | /* If the Guest is actually stopped, we need to wake it up. */ | ||
478 | if (lg->halted) | 498 | if (lg->halted) |
479 | wake_up_process(lg->tsk); | 499 | wake_up_process(lg->tsk); |
480 | return HRTIMER_NORESTART; | 500 | return HRTIMER_NORESTART; |
481 | } | 501 | } |
482 | 502 | ||
503 | /* This sets up the timer for this Guest. */ | ||
483 | void init_clockdev(struct lguest *lg) | 504 | void init_clockdev(struct lguest *lg) |
484 | { | 505 | { |
485 | hrtimer_init(&lg->hrt, CLOCK_REALTIME, HRTIMER_MODE_ABS); | 506 | hrtimer_init(&lg->hrt, CLOCK_REALTIME, HRTIMER_MODE_ABS); |
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h index d9144beca82c..86924891b5eb 100644 --- a/drivers/lguest/lg.h +++ b/drivers/lguest/lg.h | |||
@@ -74,9 +74,6 @@ struct lguest | |||
74 | u32 pgdidx; | 74 | u32 pgdidx; |
75 | struct pgdir pgdirs[4]; | 75 | struct pgdir pgdirs[4]; |
76 | 76 | ||
77 | /* Cached wakeup: we hold a reference to this task. */ | ||
78 | struct task_struct *wake; | ||
79 | |||
80 | unsigned long noirq_start, noirq_end; | 77 | unsigned long noirq_start, noirq_end; |
81 | unsigned long pending_notify; /* pfn from LHCALL_NOTIFY */ | 78 | unsigned long pending_notify; /* pfn from LHCALL_NOTIFY */ |
82 | 79 | ||
@@ -103,7 +100,7 @@ int lguest_address_ok(const struct lguest *lg, | |||
103 | void __lgread(struct lguest *, void *, unsigned long, unsigned); | 100 | void __lgread(struct lguest *, void *, unsigned long, unsigned); |
104 | void __lgwrite(struct lguest *, unsigned long, const void *, unsigned); | 101 | void __lgwrite(struct lguest *, unsigned long, const void *, unsigned); |
105 | 102 | ||
106 | /*L:306 Using memory-copy operations like that is usually inconvient, so we | 103 | /*H:035 Using memory-copy operations like that is usually inconvient, so we |
107 | * have the following helper macros which read and write a specific type (often | 104 | * have the following helper macros which read and write a specific type (often |
108 | * an unsigned long). | 105 | * an unsigned long). |
109 | * | 106 | * |
@@ -191,7 +188,7 @@ void write_timestamp(struct lguest *lg); | |||
191 | * Let's step aside for the moment, to study one important routine that's used | 188 | * Let's step aside for the moment, to study one important routine that's used |
192 | * widely in the Host code. | 189 | * widely in the Host code. |
193 | * | 190 | * |
194 | * There are many cases where the Guest does something invalid, like pass crap | 191 | * There are many cases where the Guest can do something invalid, like pass crap |
195 | * to a hypercall. Since only the Guest kernel can make hypercalls, it's quite | 192 | * to a hypercall. Since only the Guest kernel can make hypercalls, it's quite |
196 | * acceptable to simply terminate the Guest and give the Launcher a nicely | 193 | * acceptable to simply terminate the Guest and give the Launcher a nicely |
197 | * formatted reason. It's also simpler for the Guest itself, which doesn't | 194 | * formatted reason. It's also simpler for the Guest itself, which doesn't |
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 71c64837b437..8904f72f97c6 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -53,7 +53,8 @@ struct lguest_device { | |||
53 | * Device configurations | 53 | * Device configurations |
54 | * | 54 | * |
55 | * The configuration information for a device consists of a series of fields. | 55 | * The configuration information for a device consists of a series of fields. |
56 | * The device will look for these fields during setup. | 56 | * We don't really care what they are: the Launcher set them up, and the driver |
57 | * will look at them during setup. | ||
57 | * | 58 | * |
58 | * For us these fields come immediately after that device's descriptor in the | 59 | * For us these fields come immediately after that device's descriptor in the |
59 | * lguest_devices page. | 60 | * lguest_devices page. |
@@ -122,8 +123,8 @@ static void lg_set_status(struct virtio_device *vdev, u8 status) | |||
122 | * The other piece of infrastructure virtio needs is a "virtqueue": a way of | 123 | * The other piece of infrastructure virtio needs is a "virtqueue": a way of |
123 | * the Guest device registering buffers for the other side to read from or | 124 | * the Guest device registering buffers for the other side to read from or |
124 | * write into (ie. send and receive buffers). Each device can have multiple | 125 | * write into (ie. send and receive buffers). Each device can have multiple |
125 | * virtqueues: for example the console has one queue for sending and one for | 126 | * virtqueues: for example the console driver uses one queue for sending and |
126 | * receiving. | 127 | * another for receiving. |
127 | * | 128 | * |
128 | * Fortunately for us, a very fast shared-memory-plus-descriptors virtqueue | 129 | * Fortunately for us, a very fast shared-memory-plus-descriptors virtqueue |
129 | * already exists in virtio_ring.c. We just need to connect it up. | 130 | * already exists in virtio_ring.c. We just need to connect it up. |
@@ -158,7 +159,7 @@ static void lg_notify(struct virtqueue *vq) | |||
158 | * | 159 | * |
159 | * This is kind of an ugly duckling. It'd be nicer to have a standard | 160 | * This is kind of an ugly duckling. It'd be nicer to have a standard |
160 | * representation of a virtqueue in the configuration space, but it seems that | 161 | * representation of a virtqueue in the configuration space, but it seems that |
161 | * everyone wants to do it differently. The KVM guys want the Guest to | 162 | * everyone wants to do it differently. The KVM coders want the Guest to |
162 | * allocate its own pages and tell the Host where they are, but for lguest it's | 163 | * allocate its own pages and tell the Host where they are, but for lguest it's |
163 | * simpler for the Host to simply tell us where the pages are. | 164 | * simpler for the Host to simply tell us where the pages are. |
164 | * | 165 | * |
@@ -284,6 +285,8 @@ static void add_lguest_device(struct lguest_device_desc *d) | |||
284 | { | 285 | { |
285 | struct lguest_device *ldev; | 286 | struct lguest_device *ldev; |
286 | 287 | ||
288 | /* Start with zeroed memory; Linux's device layer seems to count on | ||
289 | * it. */ | ||
287 | ldev = kzalloc(sizeof(*ldev), GFP_KERNEL); | 290 | ldev = kzalloc(sizeof(*ldev), GFP_KERNEL); |
288 | if (!ldev) { | 291 | if (!ldev) { |
289 | printk(KERN_EMERG "Cannot allocate lguest dev %u\n", | 292 | printk(KERN_EMERG "Cannot allocate lguest dev %u\n", |
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c index ee405b38383d..9d716fa42cad 100644 --- a/drivers/lguest/lguest_user.c +++ b/drivers/lguest/lguest_user.c | |||
@@ -8,20 +8,22 @@ | |||
8 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
9 | #include "lg.h" | 9 | #include "lg.h" |
10 | 10 | ||
11 | /*L:315 To force the Guest to stop running and return to the Launcher, the | 11 | /*L:055 When something happens, the Waker process needs a way to stop the |
12 | * Waker sets writes LHREQ_BREAK and the value "1" to /dev/lguest. The | 12 | * kernel running the Guest and return to the Launcher. So the Waker writes |
13 | * Launcher then writes LHREQ_BREAK and "0" to release the Waker. */ | 13 | * LHREQ_BREAK and the value "1" to /dev/lguest to do this. Once the Launcher |
14 | * has done whatever needs attention, it writes LHREQ_BREAK and "0" to release | ||
15 | * the Waker. */ | ||
14 | static int break_guest_out(struct lguest *lg, const unsigned long __user *input) | 16 | static int break_guest_out(struct lguest *lg, const unsigned long __user *input) |
15 | { | 17 | { |
16 | unsigned long on; | 18 | unsigned long on; |
17 | 19 | ||
18 | /* Fetch whether they're turning break on or off.. */ | 20 | /* Fetch whether they're turning break on or off. */ |
19 | if (get_user(on, input) != 0) | 21 | if (get_user(on, input) != 0) |
20 | return -EFAULT; | 22 | return -EFAULT; |
21 | 23 | ||
22 | if (on) { | 24 | if (on) { |
23 | lg->break_out = 1; | 25 | lg->break_out = 1; |
24 | /* Pop it out (may be running on different CPU) */ | 26 | /* Pop it out of the Guest (may be running on different CPU) */ |
25 | wake_up_process(lg->tsk); | 27 | wake_up_process(lg->tsk); |
26 | /* Wait for them to reset it */ | 28 | /* Wait for them to reset it */ |
27 | return wait_event_interruptible(lg->break_wq, !lg->break_out); | 29 | return wait_event_interruptible(lg->break_wq, !lg->break_out); |
@@ -58,7 +60,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o) | |||
58 | if (!lg) | 60 | if (!lg) |
59 | return -EINVAL; | 61 | return -EINVAL; |
60 | 62 | ||
61 | /* If you're not the task which owns the guest, go away. */ | 63 | /* If you're not the task which owns the Guest, go away. */ |
62 | if (current != lg->tsk) | 64 | if (current != lg->tsk) |
63 | return -EPERM; | 65 | return -EPERM; |
64 | 66 | ||
@@ -92,8 +94,8 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o) | |||
92 | * base: The start of the Guest-physical memory inside the Launcher memory. | 94 | * base: The start of the Guest-physical memory inside the Launcher memory. |
93 | * | 95 | * |
94 | * pfnlimit: The highest (Guest-physical) page number the Guest should be | 96 | * pfnlimit: The highest (Guest-physical) page number the Guest should be |
95 | * allowed to access. The Launcher has to live in Guest memory, so it sets | 97 | * allowed to access. The Guest memory lives inside the Launcher, so it sets |
96 | * this to ensure the Guest can't reach it. | 98 | * this to ensure the Guest can only reach its own memory. |
97 | * | 99 | * |
98 | * pgdir: The (Guest-physical) address of the top of the initial Guest | 100 | * pgdir: The (Guest-physical) address of the top of the initial Guest |
99 | * pagetables (which are set up by the Launcher). | 101 | * pagetables (which are set up by the Launcher). |
@@ -189,7 +191,7 @@ unlock: | |||
189 | } | 191 | } |
190 | 192 | ||
191 | /*L:010 The first operation the Launcher does must be a write. All writes | 193 | /*L:010 The first operation the Launcher does must be a write. All writes |
192 | * start with a 32 bit number: for the first write this must be | 194 | * start with an unsigned long number: for the first write this must be |
193 | * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use | 195 | * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use |
194 | * writes of other values to send interrupts. */ | 196 | * writes of other values to send interrupts. */ |
195 | static ssize_t write(struct file *file, const char __user *in, | 197 | static ssize_t write(struct file *file, const char __user *in, |
@@ -275,8 +277,7 @@ static int close(struct inode *inode, struct file *file) | |||
275 | * The Launcher is the Host userspace program which sets up, runs and services | 277 | * The Launcher is the Host userspace program which sets up, runs and services |
276 | * the Guest. In fact, many comments in the Drivers which refer to "the Host" | 278 | * the Guest. In fact, many comments in the Drivers which refer to "the Host" |
277 | * doing things are inaccurate: the Launcher does all the device handling for | 279 | * doing things are inaccurate: the Launcher does all the device handling for |
278 | * the Guest. The Guest can't tell what's done by the the Launcher and what by | 280 | * the Guest, but the Guest can't know that. |
279 | * the Host. | ||
280 | * | 281 | * |
281 | * Just to confuse you: to the Host kernel, the Launcher *is* the Guest and we | 282 | * Just to confuse you: to the Host kernel, the Launcher *is* the Guest and we |
282 | * shall see more of that later. | 283 | * shall see more of that later. |
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c index 2a45f0691c9b..fffabb327157 100644 --- a/drivers/lguest/page_tables.c +++ b/drivers/lguest/page_tables.c | |||
@@ -26,7 +26,8 @@ | |||
26 | * | 26 | * |
27 | * We use two-level page tables for the Guest. If you're not entirely | 27 | * We use two-level page tables for the Guest. If you're not entirely |
28 | * comfortable with virtual addresses, physical addresses and page tables then | 28 | * comfortable with virtual addresses, physical addresses and page tables then |
29 | * I recommend you review lguest.c's "Page Table Handling" (with diagrams!). | 29 | * I recommend you review arch/x86/lguest/boot.c's "Page Table Handling" (with |
30 | * diagrams!). | ||
30 | * | 31 | * |
31 | * The Guest keeps page tables, but we maintain the actual ones here: these are | 32 | * The Guest keeps page tables, but we maintain the actual ones here: these are |
32 | * called "shadow" page tables. Which is a very Guest-centric name: these are | 33 | * called "shadow" page tables. Which is a very Guest-centric name: these are |
@@ -36,11 +37,11 @@ | |||
36 | * | 37 | * |
37 | * Anyway, this is the most complicated part of the Host code. There are seven | 38 | * Anyway, this is the most complicated part of the Host code. There are seven |
38 | * parts to this: | 39 | * parts to this: |
39 | * (i) Setting up a page table entry for the Guest when it faults, | 40 | * (i) Looking up a page table entry when the Guest faults, |
40 | * (ii) Setting up the page table entry for the Guest stack, | 41 | * (ii) Making sure the Guest stack is mapped, |
41 | * (iii) Setting up a page table entry when the Guest tells us it has changed, | 42 | * (iii) Setting up a page table entry when the Guest tells us one has changed, |
42 | * (iv) Switching page tables, | 43 | * (iv) Switching page tables, |
43 | * (v) Flushing (thowing away) page tables, | 44 | * (v) Flushing (throwing away) page tables, |
44 | * (vi) Mapping the Switcher when the Guest is about to run, | 45 | * (vi) Mapping the Switcher when the Guest is about to run, |
45 | * (vii) Setting up the page tables initially. | 46 | * (vii) Setting up the page tables initially. |
46 | :*/ | 47 | :*/ |
@@ -57,16 +58,15 @@ | |||
57 | static DEFINE_PER_CPU(pte_t *, switcher_pte_pages); | 58 | static DEFINE_PER_CPU(pte_t *, switcher_pte_pages); |
58 | #define switcher_pte_page(cpu) per_cpu(switcher_pte_pages, cpu) | 59 | #define switcher_pte_page(cpu) per_cpu(switcher_pte_pages, cpu) |
59 | 60 | ||
60 | /*H:320 With our shadow and Guest types established, we need to deal with | 61 | /*H:320 The page table code is curly enough to need helper functions to keep it |
61 | * them: the page table code is curly enough to need helper functions to keep | 62 | * clear and clean. |
62 | * it clear and clean. | ||
63 | * | 63 | * |
64 | * There are two functions which return pointers to the shadow (aka "real") | 64 | * There are two functions which return pointers to the shadow (aka "real") |
65 | * page tables. | 65 | * page tables. |
66 | * | 66 | * |
67 | * spgd_addr() takes the virtual address and returns a pointer to the top-level | 67 | * spgd_addr() takes the virtual address and returns a pointer to the top-level |
68 | * page directory entry for that address. Since we keep track of several page | 68 | * page directory entry (PGD) for that address. Since we keep track of several |
69 | * tables, the "i" argument tells us which one we're interested in (it's | 69 | * page tables, the "i" argument tells us which one we're interested in (it's |
70 | * usually the current one). */ | 70 | * usually the current one). */ |
71 | static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) | 71 | static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) |
72 | { | 72 | { |
@@ -81,9 +81,9 @@ static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) | |||
81 | return &lg->pgdirs[i].pgdir[index]; | 81 | return &lg->pgdirs[i].pgdir[index]; |
82 | } | 82 | } |
83 | 83 | ||
84 | /* This routine then takes the PGD entry given above, which contains the | 84 | /* This routine then takes the page directory entry returned above, which |
85 | * address of the PTE page. It then returns a pointer to the PTE entry for the | 85 | * contains the address of the page table entry (PTE) page. It then returns a |
86 | * given address. */ | 86 | * pointer to the PTE entry for the given address. */ |
87 | static pte_t *spte_addr(struct lguest *lg, pgd_t spgd, unsigned long vaddr) | 87 | static pte_t *spte_addr(struct lguest *lg, pgd_t spgd, unsigned long vaddr) |
88 | { | 88 | { |
89 | pte_t *page = __va(pgd_pfn(spgd) << PAGE_SHIFT); | 89 | pte_t *page = __va(pgd_pfn(spgd) << PAGE_SHIFT); |
@@ -191,7 +191,7 @@ static void check_gpgd(struct lguest *lg, pgd_t gpgd) | |||
191 | } | 191 | } |
192 | 192 | ||
193 | /*H:330 | 193 | /*H:330 |
194 | * (i) Setting up a page table entry for the Guest when it faults | 194 | * (i) Looking up a page table entry when the Guest faults. |
195 | * | 195 | * |
196 | * We saw this call in run_guest(): when we see a page fault in the Guest, we | 196 | * We saw this call in run_guest(): when we see a page fault in the Guest, we |
197 | * come here. That's because we only set up the shadow page tables lazily as | 197 | * come here. That's because we only set up the shadow page tables lazily as |
@@ -199,7 +199,7 @@ static void check_gpgd(struct lguest *lg, pgd_t gpgd) | |||
199 | * and return to the Guest without it knowing. | 199 | * and return to the Guest without it knowing. |
200 | * | 200 | * |
201 | * If we fixed up the fault (ie. we mapped the address), this routine returns | 201 | * If we fixed up the fault (ie. we mapped the address), this routine returns |
202 | * true. */ | 202 | * true. Otherwise, it was a real fault and we need to tell the Guest. */ |
203 | int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) | 203 | int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) |
204 | { | 204 | { |
205 | pgd_t gpgd; | 205 | pgd_t gpgd; |
@@ -246,16 +246,16 @@ int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) | |||
246 | if ((errcode & 2) && !(pte_flags(gpte) & _PAGE_RW)) | 246 | if ((errcode & 2) && !(pte_flags(gpte) & _PAGE_RW)) |
247 | return 0; | 247 | return 0; |
248 | 248 | ||
249 | /* User access to a kernel page? (bit 3 == user access) */ | 249 | /* User access to a kernel-only page? (bit 3 == user access) */ |
250 | if ((errcode & 4) && !(pte_flags(gpte) & _PAGE_USER)) | 250 | if ((errcode & 4) && !(pte_flags(gpte) & _PAGE_USER)) |
251 | return 0; | 251 | return 0; |
252 | 252 | ||
253 | /* Check that the Guest PTE flags are OK, and the page number is below | 253 | /* Check that the Guest PTE flags are OK, and the page number is below |
254 | * the pfn_limit (ie. not mapping the Launcher binary). */ | 254 | * the pfn_limit (ie. not mapping the Launcher binary). */ |
255 | check_gpte(lg, gpte); | 255 | check_gpte(lg, gpte); |
256 | |||
256 | /* Add the _PAGE_ACCESSED and (for a write) _PAGE_DIRTY flag */ | 257 | /* Add the _PAGE_ACCESSED and (for a write) _PAGE_DIRTY flag */ |
257 | gpte = pte_mkyoung(gpte); | 258 | gpte = pte_mkyoung(gpte); |
258 | |||
259 | if (errcode & 2) | 259 | if (errcode & 2) |
260 | gpte = pte_mkdirty(gpte); | 260 | gpte = pte_mkdirty(gpte); |
261 | 261 | ||
@@ -272,23 +272,28 @@ int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) | |||
272 | else | 272 | else |
273 | /* If this is a read, don't set the "writable" bit in the page | 273 | /* If this is a read, don't set the "writable" bit in the page |
274 | * table entry, even if the Guest says it's writable. That way | 274 | * table entry, even if the Guest says it's writable. That way |
275 | * we come back here when a write does actually ocur, so we can | 275 | * we will come back here when a write does actually occur, so |
276 | * update the Guest's _PAGE_DIRTY flag. */ | 276 | * we can update the Guest's _PAGE_DIRTY flag. */ |
277 | *spte = gpte_to_spte(lg, pte_wrprotect(gpte), 0); | 277 | *spte = gpte_to_spte(lg, pte_wrprotect(gpte), 0); |
278 | 278 | ||
279 | /* Finally, we write the Guest PTE entry back: we've set the | 279 | /* Finally, we write the Guest PTE entry back: we've set the |
280 | * _PAGE_ACCESSED and maybe the _PAGE_DIRTY flags. */ | 280 | * _PAGE_ACCESSED and maybe the _PAGE_DIRTY flags. */ |
281 | lgwrite(lg, gpte_ptr, pte_t, gpte); | 281 | lgwrite(lg, gpte_ptr, pte_t, gpte); |
282 | 282 | ||
283 | /* We succeeded in mapping the page! */ | 283 | /* The fault is fixed, the page table is populated, the mapping |
284 | * manipulated, the result returned and the code complete. A small | ||
285 | * delay and a trace of alliteration are the only indications the Guest | ||
286 | * has that a page fault occurred at all. */ | ||
284 | return 1; | 287 | return 1; |
285 | } | 288 | } |
286 | 289 | ||
287 | /*H:360 (ii) Setting up the page table entry for the Guest stack. | 290 | /*H:360 |
291 | * (ii) Making sure the Guest stack is mapped. | ||
288 | * | 292 | * |
289 | * Remember pin_stack_pages() which makes sure the stack is mapped? It could | 293 | * Remember that direct traps into the Guest need a mapped Guest kernel stack. |
290 | * simply call demand_page(), but as we've seen that logic is quite long, and | 294 | * pin_stack_pages() calls us here: we could simply call demand_page(), but as |
291 | * usually the stack pages are already mapped anyway, so it's not required. | 295 | * we've seen that logic is quite long, and usually the stack pages are already |
296 | * mapped, so it's overkill. | ||
292 | * | 297 | * |
293 | * This is a quick version which answers the question: is this virtual address | 298 | * This is a quick version which answers the question: is this virtual address |
294 | * mapped by the shadow page tables, and is it writable? */ | 299 | * mapped by the shadow page tables, and is it writable? */ |
@@ -297,7 +302,7 @@ static int page_writable(struct lguest *lg, unsigned long vaddr) | |||
297 | pgd_t *spgd; | 302 | pgd_t *spgd; |
298 | unsigned long flags; | 303 | unsigned long flags; |
299 | 304 | ||
300 | /* Look at the top level entry: is it present? */ | 305 | /* Look at the current top level entry: is it present? */ |
301 | spgd = spgd_addr(lg, lg->pgdidx, vaddr); | 306 | spgd = spgd_addr(lg, lg->pgdidx, vaddr); |
302 | if (!(pgd_flags(*spgd) & _PAGE_PRESENT)) | 307 | if (!(pgd_flags(*spgd) & _PAGE_PRESENT)) |
303 | return 0; | 308 | return 0; |
@@ -333,15 +338,14 @@ static void release_pgd(struct lguest *lg, pgd_t *spgd) | |||
333 | release_pte(ptepage[i]); | 338 | release_pte(ptepage[i]); |
334 | /* Now we can free the page of PTEs */ | 339 | /* Now we can free the page of PTEs */ |
335 | free_page((long)ptepage); | 340 | free_page((long)ptepage); |
336 | /* And zero out the PGD entry we we never release it twice. */ | 341 | /* And zero out the PGD entry so we never release it twice. */ |
337 | *spgd = __pgd(0); | 342 | *spgd = __pgd(0); |
338 | } | 343 | } |
339 | } | 344 | } |
340 | 345 | ||
341 | /*H:440 (v) Flushing (thowing away) page tables, | 346 | /*H:445 We saw flush_user_mappings() twice: once from the flush_user_mappings() |
342 | * | 347 | * hypercall and once in new_pgdir() when we re-used a top-level pgdir page. |
343 | * We saw flush_user_mappings() called when we re-used a top-level pgdir page. | 348 | * It simply releases every PTE page from 0 up to the Guest's kernel address. */ |
344 | * It simply releases every PTE page from 0 up to the kernel address. */ | ||
345 | static void flush_user_mappings(struct lguest *lg, int idx) | 349 | static void flush_user_mappings(struct lguest *lg, int idx) |
346 | { | 350 | { |
347 | unsigned int i; | 351 | unsigned int i; |
@@ -350,8 +354,10 @@ static void flush_user_mappings(struct lguest *lg, int idx) | |||
350 | release_pgd(lg, lg->pgdirs[idx].pgdir + i); | 354 | release_pgd(lg, lg->pgdirs[idx].pgdir + i); |
351 | } | 355 | } |
352 | 356 | ||
353 | /* The Guest also has a hypercall to do this manually: it's used when a large | 357 | /*H:440 (v) Flushing (throwing away) page tables, |
354 | * number of mappings have been changed. */ | 358 | * |
359 | * The Guest has a hypercall to throw away the page tables: it's used when a | ||
360 | * large number of mappings have been changed. */ | ||
355 | void guest_pagetable_flush_user(struct lguest *lg) | 361 | void guest_pagetable_flush_user(struct lguest *lg) |
356 | { | 362 | { |
357 | /* Drop the userspace part of the current page table. */ | 363 | /* Drop the userspace part of the current page table. */ |
@@ -423,8 +429,9 @@ static unsigned int new_pgdir(struct lguest *lg, | |||
423 | 429 | ||
424 | /*H:430 (iv) Switching page tables | 430 | /*H:430 (iv) Switching page tables |
425 | * | 431 | * |
426 | * This is what happens when the Guest changes page tables (ie. changes the | 432 | * Now we've seen all the page table setting and manipulation, let's see what |
427 | * top-level pgdir). This happens on almost every context switch. */ | 433 | * what happens when the Guest changes page tables (ie. changes the top-level |
434 | * pgdir). This occurs on almost every context switch. */ | ||
428 | void guest_new_pagetable(struct lguest *lg, unsigned long pgtable) | 435 | void guest_new_pagetable(struct lguest *lg, unsigned long pgtable) |
429 | { | 436 | { |
430 | int newpgdir, repin = 0; | 437 | int newpgdir, repin = 0; |
@@ -443,7 +450,8 @@ void guest_new_pagetable(struct lguest *lg, unsigned long pgtable) | |||
443 | } | 450 | } |
444 | 451 | ||
445 | /*H:470 Finally, a routine which throws away everything: all PGD entries in all | 452 | /*H:470 Finally, a routine which throws away everything: all PGD entries in all |
446 | * the shadow page tables. This is used when we destroy the Guest. */ | 453 | * the shadow page tables, including the Guest's kernel mappings. This is used |
454 | * when we destroy the Guest. */ | ||
447 | static void release_all_pagetables(struct lguest *lg) | 455 | static void release_all_pagetables(struct lguest *lg) |
448 | { | 456 | { |
449 | unsigned int i, j; | 457 | unsigned int i, j; |
@@ -458,13 +466,22 @@ static void release_all_pagetables(struct lguest *lg) | |||
458 | 466 | ||
459 | /* We also throw away everything when a Guest tells us it's changed a kernel | 467 | /* We also throw away everything when a Guest tells us it's changed a kernel |
460 | * mapping. Since kernel mappings are in every page table, it's easiest to | 468 | * mapping. Since kernel mappings are in every page table, it's easiest to |
461 | * throw them all away. This is amazingly slow, but thankfully rare. */ | 469 | * throw them all away. This traps the Guest in amber for a while as |
470 | * everything faults back in, but it's rare. */ | ||
462 | void guest_pagetable_clear_all(struct lguest *lg) | 471 | void guest_pagetable_clear_all(struct lguest *lg) |
463 | { | 472 | { |
464 | release_all_pagetables(lg); | 473 | release_all_pagetables(lg); |
465 | /* We need the Guest kernel stack mapped again. */ | 474 | /* We need the Guest kernel stack mapped again. */ |
466 | pin_stack_pages(lg); | 475 | pin_stack_pages(lg); |
467 | } | 476 | } |
477 | /*:*/ | ||
478 | /*M:009 Since we throw away all mappings when a kernel mapping changes, our | ||
479 | * performance sucks for guests using highmem. In fact, a guest with | ||
480 | * PAGE_OFFSET 0xc0000000 (the default) and more than about 700MB of RAM is | ||
481 | * usually slower than a Guest with less memory. | ||
482 | * | ||
483 | * This, of course, cannot be fixed. It would take some kind of... well, I | ||
484 | * don't know, but the term "puissant code-fu" comes to mind. :*/ | ||
468 | 485 | ||
469 | /*H:420 This is the routine which actually sets the page table entry for then | 486 | /*H:420 This is the routine which actually sets the page table entry for then |
470 | * "idx"'th shadow page table. | 487 | * "idx"'th shadow page table. |
@@ -483,7 +500,7 @@ void guest_pagetable_clear_all(struct lguest *lg) | |||
483 | static void do_set_pte(struct lguest *lg, int idx, | 500 | static void do_set_pte(struct lguest *lg, int idx, |
484 | unsigned long vaddr, pte_t gpte) | 501 | unsigned long vaddr, pte_t gpte) |
485 | { | 502 | { |
486 | /* Look up the matching shadow page directot entry. */ | 503 | /* Look up the matching shadow page directory entry. */ |
487 | pgd_t *spgd = spgd_addr(lg, idx, vaddr); | 504 | pgd_t *spgd = spgd_addr(lg, idx, vaddr); |
488 | 505 | ||
489 | /* If the top level isn't present, there's no entry to update. */ | 506 | /* If the top level isn't present, there's no entry to update. */ |
@@ -500,7 +517,8 @@ static void do_set_pte(struct lguest *lg, int idx, | |||
500 | *spte = gpte_to_spte(lg, gpte, | 517 | *spte = gpte_to_spte(lg, gpte, |
501 | pte_flags(gpte) & _PAGE_DIRTY); | 518 | pte_flags(gpte) & _PAGE_DIRTY); |
502 | } else | 519 | } else |
503 | /* Otherwise we can demand_page() it in later. */ | 520 | /* Otherwise kill it and we can demand_page() it in |
521 | * later. */ | ||
504 | *spte = __pte(0); | 522 | *spte = __pte(0); |
505 | } | 523 | } |
506 | } | 524 | } |
@@ -535,7 +553,7 @@ void guest_set_pte(struct lguest *lg, | |||
535 | } | 553 | } |
536 | 554 | ||
537 | /*H:400 | 555 | /*H:400 |
538 | * (iii) Setting up a page table entry when the Guest tells us it has changed. | 556 | * (iii) Setting up a page table entry when the Guest tells us one has changed. |
539 | * | 557 | * |
540 | * Just like we did in interrupts_and_traps.c, it makes sense for us to deal | 558 | * Just like we did in interrupts_and_traps.c, it makes sense for us to deal |
541 | * with the other side of page tables while we're here: what happens when the | 559 | * with the other side of page tables while we're here: what happens when the |
@@ -612,9 +630,10 @@ void free_guest_pagetable(struct lguest *lg) | |||
612 | 630 | ||
613 | /*H:480 (vi) Mapping the Switcher when the Guest is about to run. | 631 | /*H:480 (vi) Mapping the Switcher when the Guest is about to run. |
614 | * | 632 | * |
615 | * The Switcher and the two pages for this CPU need to be available to the | 633 | * The Switcher and the two pages for this CPU need to be visible in the |
616 | * Guest (and not the pages for other CPUs). We have the appropriate PTE pages | 634 | * Guest (and not the pages for other CPUs). We have the appropriate PTE pages |
617 | * for each CPU already set up, we just need to hook them in. */ | 635 | * for each CPU already set up, we just need to hook them in now we know which |
636 | * Guest is about to run on this CPU. */ | ||
618 | void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages) | 637 | void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages) |
619 | { | 638 | { |
620 | pte_t *switcher_pte_page = __get_cpu_var(switcher_pte_pages); | 639 | pte_t *switcher_pte_page = __get_cpu_var(switcher_pte_pages); |
@@ -677,6 +696,18 @@ static __init void populate_switcher_pte_page(unsigned int cpu, | |||
677 | __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED)); | 696 | __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED)); |
678 | } | 697 | } |
679 | 698 | ||
699 | /* We've made it through the page table code. Perhaps our tired brains are | ||
700 | * still processing the details, or perhaps we're simply glad it's over. | ||
701 | * | ||
702 | * If nothing else, note that all this complexity in juggling shadow page | ||
703 | * tables in sync with the Guest's page tables is for one reason: for most | ||
704 | * Guests this page table dance determines how bad performance will be. This | ||
705 | * is why Xen uses exotic direct Guest pagetable manipulation, and why both | ||
706 | * Intel and AMD have implemented shadow page table support directly into | ||
707 | * hardware. | ||
708 | * | ||
709 | * There is just one file remaining in the Host. */ | ||
710 | |||
680 | /*H:510 At boot or module load time, init_pagetables() allocates and populates | 711 | /*H:510 At boot or module load time, init_pagetables() allocates and populates |
681 | * the Switcher PTE page for each CPU. */ | 712 | * the Switcher PTE page for each CPU. */ |
682 | __init int init_pagetables(struct page **switcher_page, unsigned int pages) | 713 | __init int init_pagetables(struct page **switcher_page, unsigned int pages) |
diff --git a/drivers/lguest/segments.c b/drivers/lguest/segments.c index c2434ec99f7b..9e189cbec7dd 100644 --- a/drivers/lguest/segments.c +++ b/drivers/lguest/segments.c | |||
@@ -12,8 +12,6 @@ | |||
12 | #include "lg.h" | 12 | #include "lg.h" |
13 | 13 | ||
14 | /*H:600 | 14 | /*H:600 |
15 | * We've almost completed the Host; there's just one file to go! | ||
16 | * | ||
17 | * Segments & The Global Descriptor Table | 15 | * Segments & The Global Descriptor Table |
18 | * | 16 | * |
19 | * (That title sounds like a bad Nerdcore group. Not to suggest that there are | 17 | * (That title sounds like a bad Nerdcore group. Not to suggest that there are |
@@ -55,7 +53,7 @@ static int ignored_gdt(unsigned int num) | |||
55 | || num == GDT_ENTRY_DOUBLEFAULT_TSS); | 53 | || num == GDT_ENTRY_DOUBLEFAULT_TSS); |
56 | } | 54 | } |
57 | 55 | ||
58 | /*H:610 Once the GDT has been changed, we fix the new entries up a little. We | 56 | /*H:630 Once the Guest gave us new GDT entries, we fix them up a little. We |
59 | * don't care if they're invalid: the worst that can happen is a General | 57 | * don't care if they're invalid: the worst that can happen is a General |
60 | * Protection Fault in the Switcher when it restores a Guest segment register | 58 | * Protection Fault in the Switcher when it restores a Guest segment register |
61 | * which tries to use that entry. Then we kill the Guest for causing such a | 59 | * which tries to use that entry. Then we kill the Guest for causing such a |
@@ -84,25 +82,33 @@ static void fixup_gdt_table(struct lguest *lg, unsigned start, unsigned end) | |||
84 | } | 82 | } |
85 | } | 83 | } |
86 | 84 | ||
87 | /* This routine is called at boot or modprobe time for each CPU to set up the | 85 | /*H:610 Like the IDT, we never simply use the GDT the Guest gives us. We keep |
88 | * "constant" GDT entries for Guests running on that CPU. */ | 86 | * a GDT for each CPU, and copy across the Guest's entries each time we want to |
87 | * run the Guest on that CPU. | ||
88 | * | ||
89 | * This routine is called at boot or modprobe time for each CPU to set up the | ||
90 | * constant GDT entries: the ones which are the same no matter what Guest we're | ||
91 | * running. */ | ||
89 | void setup_default_gdt_entries(struct lguest_ro_state *state) | 92 | void setup_default_gdt_entries(struct lguest_ro_state *state) |
90 | { | 93 | { |
91 | struct desc_struct *gdt = state->guest_gdt; | 94 | struct desc_struct *gdt = state->guest_gdt; |
92 | unsigned long tss = (unsigned long)&state->guest_tss; | 95 | unsigned long tss = (unsigned long)&state->guest_tss; |
93 | 96 | ||
94 | /* The hypervisor segments are full 0-4G segments, privilege level 0 */ | 97 | /* The Switcher segments are full 0-4G segments, privilege level 0 */ |
95 | gdt[GDT_ENTRY_LGUEST_CS] = FULL_EXEC_SEGMENT; | 98 | gdt[GDT_ENTRY_LGUEST_CS] = FULL_EXEC_SEGMENT; |
96 | gdt[GDT_ENTRY_LGUEST_DS] = FULL_SEGMENT; | 99 | gdt[GDT_ENTRY_LGUEST_DS] = FULL_SEGMENT; |
97 | 100 | ||
98 | /* The TSS segment refers to the TSS entry for this CPU, so we cannot | 101 | /* The TSS segment refers to the TSS entry for this particular CPU. |
99 | * copy it from the Guest. Forgive the magic flags */ | 102 | * Forgive the magic flags: the 0x8900 means the entry is Present, it's |
103 | * privilege level 0 Available 386 TSS system segment, and the 0x67 | ||
104 | * means Saturn is eclipsed by Mercury in the twelfth house. */ | ||
100 | gdt[GDT_ENTRY_TSS].a = 0x00000067 | (tss << 16); | 105 | gdt[GDT_ENTRY_TSS].a = 0x00000067 | (tss << 16); |
101 | gdt[GDT_ENTRY_TSS].b = 0x00008900 | (tss & 0xFF000000) | 106 | gdt[GDT_ENTRY_TSS].b = 0x00008900 | (tss & 0xFF000000) |
102 | | ((tss >> 16) & 0x000000FF); | 107 | | ((tss >> 16) & 0x000000FF); |
103 | } | 108 | } |
104 | 109 | ||
105 | /* This routine is called before the Guest is run for the first time. */ | 110 | /* This routine sets up the initial Guest GDT for booting. All entries start |
111 | * as 0 (unusable). */ | ||
106 | void setup_guest_gdt(struct lguest *lg) | 112 | void setup_guest_gdt(struct lguest *lg) |
107 | { | 113 | { |
108 | /* Start with full 0-4G segments... */ | 114 | /* Start with full 0-4G segments... */ |
@@ -114,13 +120,8 @@ void setup_guest_gdt(struct lguest *lg) | |||
114 | lg->arch.gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13); | 120 | lg->arch.gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13); |
115 | } | 121 | } |
116 | 122 | ||
117 | /* Like the IDT, we never simply use the GDT the Guest gives us. We set up the | 123 | /*H:650 An optimization of copy_gdt(), for just the three "thead-local storage" |
118 | * GDTs for each CPU, then we copy across the entries each time we want to run | 124 | * entries. */ |
119 | * a different Guest on that CPU. */ | ||
120 | |||
121 | /* A partial GDT load, for the three "thead-local storage" entries. Otherwise | ||
122 | * it's just like load_guest_gdt(). So much, in fact, it would probably be | ||
123 | * neater to have a single hypercall to cover both. */ | ||
124 | void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) | 125 | void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) |
125 | { | 126 | { |
126 | unsigned int i; | 127 | unsigned int i; |
@@ -129,7 +130,9 @@ void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) | |||
129 | gdt[i] = lg->arch.gdt[i]; | 130 | gdt[i] = lg->arch.gdt[i]; |
130 | } | 131 | } |
131 | 132 | ||
132 | /* This is the full version */ | 133 | /*H:640 When the Guest is run on a different CPU, or the GDT entries have |
134 | * changed, copy_gdt() is called to copy the Guest's GDT entries across to this | ||
135 | * CPU's GDT. */ | ||
133 | void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) | 136 | void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) |
134 | { | 137 | { |
135 | unsigned int i; | 138 | unsigned int i; |
@@ -141,7 +144,8 @@ void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) | |||
141 | gdt[i] = lg->arch.gdt[i]; | 144 | gdt[i] = lg->arch.gdt[i]; |
142 | } | 145 | } |
143 | 146 | ||
144 | /* This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). */ | 147 | /*H:620 This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). |
148 | * We copy it from the Guest and tweak the entries. */ | ||
145 | void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) | 149 | void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) |
146 | { | 150 | { |
147 | /* We assume the Guest has the same number of GDT entries as the | 151 | /* We assume the Guest has the same number of GDT entries as the |
@@ -157,16 +161,22 @@ void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) | |||
157 | lg->changed |= CHANGED_GDT; | 161 | lg->changed |= CHANGED_GDT; |
158 | } | 162 | } |
159 | 163 | ||
164 | /* This is the fast-track version for just changing the three TLS entries. | ||
165 | * Remember that this happens on every context switch, so it's worth | ||
166 | * optimizing. But wouldn't it be neater to have a single hypercall to cover | ||
167 | * both cases? */ | ||
160 | void guest_load_tls(struct lguest *lg, unsigned long gtls) | 168 | void guest_load_tls(struct lguest *lg, unsigned long gtls) |
161 | { | 169 | { |
162 | struct desc_struct *tls = &lg->arch.gdt[GDT_ENTRY_TLS_MIN]; | 170 | struct desc_struct *tls = &lg->arch.gdt[GDT_ENTRY_TLS_MIN]; |
163 | 171 | ||
164 | __lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); | 172 | __lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); |
165 | fixup_gdt_table(lg, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); | 173 | fixup_gdt_table(lg, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); |
174 | /* Note that just the TLS entries have changed. */ | ||
166 | lg->changed |= CHANGED_GDT_TLS; | 175 | lg->changed |= CHANGED_GDT_TLS; |
167 | } | 176 | } |
177 | /*:*/ | ||
168 | 178 | ||
169 | /* | 179 | /*H:660 |
170 | * With this, we have finished the Host. | 180 | * With this, we have finished the Host. |
171 | * | 181 | * |
172 | * Five of the seven parts of our task are complete. You have made it through | 182 | * Five of the seven parts of our task are complete. You have made it through |
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index 9eed12d5a395..482aec2a9631 100644 --- a/drivers/lguest/x86/core.c +++ b/drivers/lguest/x86/core.c | |||
@@ -63,7 +63,7 @@ static struct lguest_pages *lguest_pages(unsigned int cpu) | |||
63 | static DEFINE_PER_CPU(struct lguest *, last_guest); | 63 | static DEFINE_PER_CPU(struct lguest *, last_guest); |
64 | 64 | ||
65 | /*S:010 | 65 | /*S:010 |
66 | * We are getting close to the Switcher. | 66 | * We approach the Switcher. |
67 | * | 67 | * |
68 | * Remember that each CPU has two pages which are visible to the Guest when it | 68 | * Remember that each CPU has two pages which are visible to the Guest when it |
69 | * runs on that CPU. This has to contain the state for that Guest: we copy the | 69 | * runs on that CPU. This has to contain the state for that Guest: we copy the |
@@ -134,7 +134,7 @@ static void run_guest_once(struct lguest *lg, struct lguest_pages *pages) | |||
134 | * | 134 | * |
135 | * The lcall also pushes the old code segment (KERNEL_CS) onto the | 135 | * The lcall also pushes the old code segment (KERNEL_CS) onto the |
136 | * stack, then the address of this call. This stack layout happens to | 136 | * stack, then the address of this call. This stack layout happens to |
137 | * exactly match the stack of an interrupt... */ | 137 | * exactly match the stack layout created by an interrupt... */ |
138 | asm volatile("pushf; lcall *lguest_entry" | 138 | asm volatile("pushf; lcall *lguest_entry" |
139 | /* This is how we tell GCC that %eax ("a") and %ebx ("b") | 139 | /* This is how we tell GCC that %eax ("a") and %ebx ("b") |
140 | * are changed by this routine. The "=" means output. */ | 140 | * are changed by this routine. The "=" means output. */ |
@@ -151,40 +151,46 @@ static void run_guest_once(struct lguest *lg, struct lguest_pages *pages) | |||
151 | } | 151 | } |
152 | /*:*/ | 152 | /*:*/ |
153 | 153 | ||
154 | /*M:002 There are hooks in the scheduler which we can register to tell when we | ||
155 | * get kicked off the CPU (preempt_notifier_register()). This would allow us | ||
156 | * to lazily disable SYSENTER which would regain some performance, and should | ||
157 | * also simplify copy_in_guest_info(). Note that we'd still need to restore | ||
158 | * things when we exit to Launcher userspace, but that's fairly easy. | ||
159 | * | ||
160 | * The hooks were designed for KVM, but we can also put them to good use. :*/ | ||
161 | |||
154 | /*H:040 This is the i386-specific code to setup and run the Guest. Interrupts | 162 | /*H:040 This is the i386-specific code to setup and run the Guest. Interrupts |
155 | * are disabled: we own the CPU. */ | 163 | * are disabled: we own the CPU. */ |
156 | void lguest_arch_run_guest(struct lguest *lg) | 164 | void lguest_arch_run_guest(struct lguest *lg) |
157 | { | 165 | { |
158 | /* Remember the awfully-named TS bit? If the Guest has asked | 166 | /* Remember the awfully-named TS bit? If the Guest has asked to set it |
159 | * to set it we set it now, so we can trap and pass that trap | 167 | * we set it now, so we can trap and pass that trap to the Guest if it |
160 | * to the Guest if it uses the FPU. */ | 168 | * uses the FPU. */ |
161 | if (lg->ts) | 169 | if (lg->ts) |
162 | lguest_set_ts(); | 170 | lguest_set_ts(); |
163 | 171 | ||
164 | /* SYSENTER is an optimized way of doing system calls. We | 172 | /* SYSENTER is an optimized way of doing system calls. We can't allow |
165 | * can't allow it because it always jumps to privilege level 0. | 173 | * it because it always jumps to privilege level 0. A normal Guest |
166 | * A normal Guest won't try it because we don't advertise it in | 174 | * won't try it because we don't advertise it in CPUID, but a malicious |
167 | * CPUID, but a malicious Guest (or malicious Guest userspace | 175 | * Guest (or malicious Guest userspace program) could, so we tell the |
168 | * program) could, so we tell the CPU to disable it before | 176 | * CPU to disable it before running the Guest. */ |
169 | * running the Guest. */ | ||
170 | if (boot_cpu_has(X86_FEATURE_SEP)) | 177 | if (boot_cpu_has(X86_FEATURE_SEP)) |
171 | wrmsr(MSR_IA32_SYSENTER_CS, 0, 0); | 178 | wrmsr(MSR_IA32_SYSENTER_CS, 0, 0); |
172 | 179 | ||
173 | /* Now we actually run the Guest. It will pop back out when | 180 | /* Now we actually run the Guest. It will return when something |
174 | * something interesting happens, and we can examine its | 181 | * interesting happens, and we can examine its registers to see what it |
175 | * registers to see what it was doing. */ | 182 | * was doing. */ |
176 | run_guest_once(lg, lguest_pages(raw_smp_processor_id())); | 183 | run_guest_once(lg, lguest_pages(raw_smp_processor_id())); |
177 | 184 | ||
178 | /* The "regs" pointer contains two extra entries which are not | 185 | /* Note that the "regs" pointer contains two extra entries which are |
179 | * really registers: a trap number which says what interrupt or | 186 | * not really registers: a trap number which says what interrupt or |
180 | * trap made the switcher code come back, and an error code | 187 | * trap made the switcher code come back, and an error code which some |
181 | * which some traps set. */ | 188 | * traps set. */ |
182 | 189 | ||
183 | /* If the Guest page faulted, then the cr2 register will tell | 190 | /* If the Guest page faulted, then the cr2 register will tell us the |
184 | * us the bad virtual address. We have to grab this now, | 191 | * bad virtual address. We have to grab this now, because once we |
185 | * because once we re-enable interrupts an interrupt could | 192 | * re-enable interrupts an interrupt could fault and thus overwrite |
186 | * fault and thus overwrite cr2, or we could even move off to a | 193 | * cr2, or we could even move off to a different CPU. */ |
187 | * different CPU. */ | ||
188 | if (lg->regs->trapnum == 14) | 194 | if (lg->regs->trapnum == 14) |
189 | lg->arch.last_pagefault = read_cr2(); | 195 | lg->arch.last_pagefault = read_cr2(); |
190 | /* Similarly, if we took a trap because the Guest used the FPU, | 196 | /* Similarly, if we took a trap because the Guest used the FPU, |
@@ -197,14 +203,15 @@ void lguest_arch_run_guest(struct lguest *lg) | |||
197 | wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0); | 203 | wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0); |
198 | } | 204 | } |
199 | 205 | ||
200 | /*H:130 Our Guest is usually so well behaved; it never tries to do things it | 206 | /*H:130 Now we've examined the hypercall code; our Guest can make requests. |
201 | * isn't allowed to. Unfortunately, Linux's paravirtual infrastructure isn't | 207 | * Our Guest is usually so well behaved; it never tries to do things it isn't |
202 | * quite complete, because it doesn't contain replacements for the Intel I/O | 208 | * allowed to, and uses hypercalls instead. Unfortunately, Linux's paravirtual |
203 | * instructions. As a result, the Guest sometimes fumbles across one during | 209 | * infrastructure isn't quite complete, because it doesn't contain replacements |
204 | * the boot process as it probes for various things which are usually attached | 210 | * for the Intel I/O instructions. As a result, the Guest sometimes fumbles |
205 | * to a PC. | 211 | * across one during the boot process as it probes for various things which are |
212 | * usually attached to a PC. | ||
206 | * | 213 | * |
207 | * When the Guest uses one of these instructions, we get trap #13 (General | 214 | * When the Guest uses one of these instructions, we get a trap (General |
208 | * Protection Fault) and come here. We see if it's one of those troublesome | 215 | * Protection Fault) and come here. We see if it's one of those troublesome |
209 | * instructions and skip over it. We return true if we did. */ | 216 | * instructions and skip over it. We return true if we did. */ |
210 | static int emulate_insn(struct lguest *lg) | 217 | static int emulate_insn(struct lguest *lg) |
@@ -275,43 +282,43 @@ static int emulate_insn(struct lguest *lg) | |||
275 | void lguest_arch_handle_trap(struct lguest *lg) | 282 | void lguest_arch_handle_trap(struct lguest *lg) |
276 | { | 283 | { |
277 | switch (lg->regs->trapnum) { | 284 | switch (lg->regs->trapnum) { |
278 | case 13: /* We've intercepted a GPF. */ | 285 | case 13: /* We've intercepted a General Protection Fault. */ |
279 | /* Check if this was one of those annoying IN or OUT | 286 | /* Check if this was one of those annoying IN or OUT |
280 | * instructions which we need to emulate. If so, we | 287 | * instructions which we need to emulate. If so, we just go |
281 | * just go back into the Guest after we've done it. */ | 288 | * back into the Guest after we've done it. */ |
282 | if (lg->regs->errcode == 0) { | 289 | if (lg->regs->errcode == 0) { |
283 | if (emulate_insn(lg)) | 290 | if (emulate_insn(lg)) |
284 | return; | 291 | return; |
285 | } | 292 | } |
286 | break; | 293 | break; |
287 | case 14: /* We've intercepted a page fault. */ | 294 | case 14: /* We've intercepted a Page Fault. */ |
288 | /* The Guest accessed a virtual address that wasn't | 295 | /* The Guest accessed a virtual address that wasn't mapped. |
289 | * mapped. This happens a lot: we don't actually set | 296 | * This happens a lot: we don't actually set up most of the |
290 | * up most of the page tables for the Guest at all when | 297 | * page tables for the Guest at all when we start: as it runs |
291 | * we start: as it runs it asks for more and more, and | 298 | * it asks for more and more, and we set them up as |
292 | * we set them up as required. In this case, we don't | 299 | * required. In this case, we don't even tell the Guest that |
293 | * even tell the Guest that the fault happened. | 300 | * the fault happened. |
294 | * | 301 | * |
295 | * The errcode tells whether this was a read or a | 302 | * The errcode tells whether this was a read or a write, and |
296 | * write, and whether kernel or userspace code. */ | 303 | * whether kernel or userspace code. */ |
297 | if (demand_page(lg, lg->arch.last_pagefault, lg->regs->errcode)) | 304 | if (demand_page(lg, lg->arch.last_pagefault, lg->regs->errcode)) |
298 | return; | 305 | return; |
299 | 306 | ||
300 | /* OK, it's really not there (or not OK): the Guest | 307 | /* OK, it's really not there (or not OK): the Guest needs to |
301 | * needs to know. We write out the cr2 value so it | 308 | * know. We write out the cr2 value so it knows where the |
302 | * knows where the fault occurred. | 309 | * fault occurred. |
303 | * | 310 | * |
304 | * Note that if the Guest were really messed up, this | 311 | * Note that if the Guest were really messed up, this could |
305 | * could happen before it's done the INITIALIZE | 312 | * happen before it's done the LHCALL_LGUEST_INIT hypercall, so |
306 | * hypercall, so lg->lguest_data will be NULL */ | 313 | * lg->lguest_data could be NULL */ |
307 | if (lg->lguest_data && | 314 | if (lg->lguest_data && |
308 | put_user(lg->arch.last_pagefault, &lg->lguest_data->cr2)) | 315 | put_user(lg->arch.last_pagefault, &lg->lguest_data->cr2)) |
309 | kill_guest(lg, "Writing cr2"); | 316 | kill_guest(lg, "Writing cr2"); |
310 | break; | 317 | break; |
311 | case 7: /* We've intercepted a Device Not Available fault. */ | 318 | case 7: /* We've intercepted a Device Not Available fault. */ |
312 | /* If the Guest doesn't want to know, we already | 319 | /* If the Guest doesn't want to know, we already restored the |
313 | * restored the Floating Point Unit, so we just | 320 | * Floating Point Unit, so we just continue without telling |
314 | * continue without telling it. */ | 321 | * it. */ |
315 | if (!lg->ts) | 322 | if (!lg->ts) |
316 | return; | 323 | return; |
317 | break; | 324 | break; |
@@ -536,9 +543,6 @@ int lguest_arch_init_hypercalls(struct lguest *lg) | |||
536 | 543 | ||
537 | return 0; | 544 | return 0; |
538 | } | 545 | } |
539 | /* Now we've examined the hypercall code; our Guest can make requests. There | ||
540 | * is one other way we can do things for the Guest, as we see in | ||
541 | * emulate_insn(). :*/ | ||
542 | 546 | ||
543 | /*L:030 lguest_arch_setup_regs() | 547 | /*L:030 lguest_arch_setup_regs() |
544 | * | 548 | * |
@@ -562,7 +566,7 @@ void lguest_arch_setup_regs(struct lguest *lg, unsigned long start) | |||
562 | * is supposed to always be "1". Bit 9 (0x200) controls whether | 566 | * is supposed to always be "1". Bit 9 (0x200) controls whether |
563 | * interrupts are enabled. We always leave interrupts enabled while | 567 | * interrupts are enabled. We always leave interrupts enabled while |
564 | * running the Guest. */ | 568 | * running the Guest. */ |
565 | regs->eflags = 0x202; | 569 | regs->eflags = X86_EFLAGS_IF | 0x2; |
566 | 570 | ||
567 | /* The "Extended Instruction Pointer" register says where the Guest is | 571 | /* The "Extended Instruction Pointer" register says where the Guest is |
568 | * running. */ | 572 | * running. */ |
@@ -570,8 +574,8 @@ void lguest_arch_setup_regs(struct lguest *lg, unsigned long start) | |||
570 | 574 | ||
571 | /* %esi points to our boot information, at physical address 0, so don't | 575 | /* %esi points to our boot information, at physical address 0, so don't |
572 | * touch it. */ | 576 | * touch it. */ |
577 | |||
573 | /* There are a couple of GDT entries the Guest expects when first | 578 | /* There are a couple of GDT entries the Guest expects when first |
574 | * booting. */ | 579 | * booting. */ |
575 | |||
576 | setup_guest_gdt(lg); | 580 | setup_guest_gdt(lg); |
577 | } | 581 | } |
diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S index 1010b90b11fc..0af8baaa0d4a 100644 --- a/drivers/lguest/x86/switcher_32.S +++ b/drivers/lguest/x86/switcher_32.S | |||
@@ -6,6 +6,37 @@ | |||
6 | * are feeling invigorated and refreshed then the next, more challenging stage | 6 | * are feeling invigorated and refreshed then the next, more challenging stage |
7 | * can be found in "make Guest". :*/ | 7 | * can be found in "make Guest". :*/ |
8 | 8 | ||
9 | /*M:012 Lguest is meant to be simple: my rule of thumb is that 1% more LOC must | ||
10 | * gain at least 1% more performance. Since neither LOC nor performance can be | ||
11 | * measured beforehand, it generally means implementing a feature then deciding | ||
12 | * if it's worth it. And once it's implemented, who can say no? | ||
13 | * | ||
14 | * This is why I haven't implemented this idea myself. I want to, but I | ||
15 | * haven't. You could, though. | ||
16 | * | ||
17 | * The main place where lguest performance sucks is Guest page faulting. When | ||
18 | * a Guest userspace process hits an unmapped page we switch back to the Host, | ||
19 | * walk the page tables, find it's not mapped, switch back to the Guest page | ||
20 | * fault handler, which calls a hypercall to set the page table entry, then | ||
21 | * finally returns to userspace. That's two round-trips. | ||
22 | * | ||
23 | * If we had a small walker in the Switcher, we could quickly check the Guest | ||
24 | * page table and if the page isn't mapped, immediately reflect the fault back | ||
25 | * into the Guest. This means the Switcher would have to know the top of the | ||
26 | * Guest page table and the page fault handler address. | ||
27 | * | ||
28 | * For simplicity, the Guest should only handle the case where the privilege | ||
29 | * level of the fault is 3 and probably only not present or write faults. It | ||
30 | * should also detect recursive faults, and hand the original fault to the | ||
31 | * Host (which is actually really easy). | ||
32 | * | ||
33 | * Two questions remain. Would the performance gain outweigh the complexity? | ||
34 | * And who would write the verse documenting it? :*/ | ||
35 | |||
36 | /*M:011 Lguest64 handles NMI. This gave me NMI envy (until I looked at their | ||
37 | * code). It's worth doing though, since it would let us use oprofile in the | ||
38 | * Host when a Guest is running. :*/ | ||
39 | |||
9 | /*S:100 | 40 | /*S:100 |
10 | * Welcome to the Switcher itself! | 41 | * Welcome to the Switcher itself! |
11 | * | 42 | * |
@@ -88,7 +119,7 @@ ENTRY(switch_to_guest) | |||
88 | 119 | ||
89 | // All saved and there's now five steps before us: | 120 | // All saved and there's now five steps before us: |
90 | // Stack, GDT, IDT, TSS | 121 | // Stack, GDT, IDT, TSS |
91 | // And last of all the page tables are flipped. | 122 | // Then last of all the page tables are flipped. |
92 | 123 | ||
93 | // Yet beware that our stack pointer must be | 124 | // Yet beware that our stack pointer must be |
94 | // Always valid lest an NMI hits | 125 | // Always valid lest an NMI hits |
@@ -103,25 +134,25 @@ ENTRY(switch_to_guest) | |||
103 | lgdt LGUEST_PAGES_guest_gdt_desc(%eax) | 134 | lgdt LGUEST_PAGES_guest_gdt_desc(%eax) |
104 | 135 | ||
105 | // The Guest's IDT we did partially | 136 | // The Guest's IDT we did partially |
106 | // Move to the "struct lguest_pages" as well. | 137 | // Copy to "struct lguest_pages" as well. |
107 | lidt LGUEST_PAGES_guest_idt_desc(%eax) | 138 | lidt LGUEST_PAGES_guest_idt_desc(%eax) |
108 | 139 | ||
109 | // The TSS entry which controls traps | 140 | // The TSS entry which controls traps |
110 | // Must be loaded up with "ltr" now: | 141 | // Must be loaded up with "ltr" now: |
142 | // The GDT entry that TSS uses | ||
143 | // Changes type when we load it: damn Intel! | ||
111 | // For after we switch over our page tables | 144 | // For after we switch over our page tables |
112 | // It (as the rest) will be writable no more. | 145 | // That entry will be read-only: we'd crash. |
113 | // (The GDT entry TSS needs | ||
114 | // Changes type when we load it: damn Intel!) | ||
115 | movl $(GDT_ENTRY_TSS*8), %edx | 146 | movl $(GDT_ENTRY_TSS*8), %edx |
116 | ltr %dx | 147 | ltr %dx |
117 | 148 | ||
118 | // Look back now, before we take this last step! | 149 | // Look back now, before we take this last step! |
119 | // The Host's TSS entry was also marked used; | 150 | // The Host's TSS entry was also marked used; |
120 | // Let's clear it again, ere we return. | 151 | // Let's clear it again for our return. |
121 | // The GDT descriptor of the Host | 152 | // The GDT descriptor of the Host |
122 | // Points to the table after two "size" bytes | 153 | // Points to the table after two "size" bytes |
123 | movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx | 154 | movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx |
124 | // Clear the type field of "used" (byte 5, bit 2) | 155 | // Clear "used" from type field (byte 5, bit 2) |
125 | andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx) | 156 | andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx) |
126 | 157 | ||
127 | // Once our page table's switched, the Guest is live! | 158 | // Once our page table's switched, the Guest is live! |
@@ -131,7 +162,7 @@ ENTRY(switch_to_guest) | |||
131 | 162 | ||
132 | // The page table change did one tricky thing: | 163 | // The page table change did one tricky thing: |
133 | // The Guest's register page has been mapped | 164 | // The Guest's register page has been mapped |
134 | // Writable onto our %esp (stack) -- | 165 | // Writable under our %esp (stack) -- |
135 | // We can simply pop off all Guest regs. | 166 | // We can simply pop off all Guest regs. |
136 | popl %eax | 167 | popl %eax |
137 | popl %ebx | 168 | popl %ebx |
@@ -152,16 +183,15 @@ ENTRY(switch_to_guest) | |||
152 | addl $8, %esp | 183 | addl $8, %esp |
153 | 184 | ||
154 | // The last five stack slots hold return address | 185 | // The last five stack slots hold return address |
155 | // And everything needed to change privilege | 186 | // And everything needed to switch privilege |
156 | // Into the Guest privilege level of 1, | 187 | // From Switcher's level 0 to Guest's 1, |
157 | // And the stack where the Guest had last left it. | 188 | // And the stack where the Guest had last left it. |
158 | // Interrupts are turned back on: we are Guest. | 189 | // Interrupts are turned back on: we are Guest. |
159 | iret | 190 | iret |
160 | 191 | ||
161 | // There are two paths where we switch to the Host | 192 | // We treat two paths to switch back to the Host |
193 | // Yet both must save Guest state and restore Host | ||
162 | // So we put the routine in a macro. | 194 | // So we put the routine in a macro. |
163 | // We are on our way home, back to the Host | ||
164 | // Interrupted out of the Guest, we come here. | ||
165 | #define SWITCH_TO_HOST \ | 195 | #define SWITCH_TO_HOST \ |
166 | /* We save the Guest state: all registers first \ | 196 | /* We save the Guest state: all registers first \ |
167 | * Laid out just as "struct lguest_regs" defines */ \ | 197 | * Laid out just as "struct lguest_regs" defines */ \ |
@@ -194,7 +224,7 @@ ENTRY(switch_to_guest) | |||
194 | movl %esp, %eax; \ | 224 | movl %esp, %eax; \ |
195 | andl $(~(1 << PAGE_SHIFT - 1)), %eax; \ | 225 | andl $(~(1 << PAGE_SHIFT - 1)), %eax; \ |
196 | /* Save our trap number: the switch will obscure it \ | 226 | /* Save our trap number: the switch will obscure it \ |
197 | * (The Guest regs are not mapped here in the Host) \ | 227 | * (In the Host the Guest regs are not mapped here) \ |
198 | * %ebx holds it safe for deliver_to_host */ \ | 228 | * %ebx holds it safe for deliver_to_host */ \ |
199 | movl LGUEST_PAGES_regs_trapnum(%eax), %ebx; \ | 229 | movl LGUEST_PAGES_regs_trapnum(%eax), %ebx; \ |
200 | /* The Host GDT, IDT and stack! \ | 230 | /* The Host GDT, IDT and stack! \ |
@@ -210,9 +240,9 @@ ENTRY(switch_to_guest) | |||
210 | /* Switch to Host's GDT, IDT. */ \ | 240 | /* Switch to Host's GDT, IDT. */ \ |
211 | lgdt LGUEST_PAGES_host_gdt_desc(%eax); \ | 241 | lgdt LGUEST_PAGES_host_gdt_desc(%eax); \ |
212 | lidt LGUEST_PAGES_host_idt_desc(%eax); \ | 242 | lidt LGUEST_PAGES_host_idt_desc(%eax); \ |
213 | /* Restore the Host's stack where it's saved regs lie */ \ | 243 | /* Restore the Host's stack where its saved regs lie */ \ |
214 | movl LGUEST_PAGES_host_sp(%eax), %esp; \ | 244 | movl LGUEST_PAGES_host_sp(%eax), %esp; \ |
215 | /* Last the TSS: our Host is complete */ \ | 245 | /* Last the TSS: our Host is returned */ \ |
216 | movl $(GDT_ENTRY_TSS*8), %edx; \ | 246 | movl $(GDT_ENTRY_TSS*8), %edx; \ |
217 | ltr %dx; \ | 247 | ltr %dx; \ |
218 | /* Restore now the regs saved right at the first. */ \ | 248 | /* Restore now the regs saved right at the first. */ \ |
@@ -222,14 +252,15 @@ ENTRY(switch_to_guest) | |||
222 | popl %ds; \ | 252 | popl %ds; \ |
223 | popl %es | 253 | popl %es |
224 | 254 | ||
225 | // Here's where we come when the Guest has just trapped: | 255 | // The first path is trod when the Guest has trapped: |
226 | // (Which trap we'll see has been pushed on the stack). | 256 | // (Which trap it was has been pushed on the stack). |
227 | // We need only switch back, and the Host will decode | 257 | // We need only switch back, and the Host will decode |
228 | // Why we came home, and what needs to be done. | 258 | // Why we came home, and what needs to be done. |
229 | return_to_host: | 259 | return_to_host: |
230 | SWITCH_TO_HOST | 260 | SWITCH_TO_HOST |
231 | iret | 261 | iret |
232 | 262 | ||
263 | // We are lead to the second path like so: | ||
233 | // An interrupt, with some cause external | 264 | // An interrupt, with some cause external |
234 | // Has ajerked us rudely from the Guest's code | 265 | // Has ajerked us rudely from the Guest's code |
235 | // Again we must return home to the Host | 266 | // Again we must return home to the Host |
@@ -238,7 +269,7 @@ deliver_to_host: | |||
238 | // But now we must go home via that place | 269 | // But now we must go home via that place |
239 | // Where that interrupt was supposed to go | 270 | // Where that interrupt was supposed to go |
240 | // Had we not been ensconced, running the Guest. | 271 | // Had we not been ensconced, running the Guest. |
241 | // Here we see the cleverness of our stack: | 272 | // Here we see the trickness of run_guest_once(): |
242 | // The Host stack is formed like an interrupt | 273 | // The Host stack is formed like an interrupt |
243 | // With EIP, CS and EFLAGS layered. | 274 | // With EIP, CS and EFLAGS layered. |
244 | // Interrupt handlers end with "iret" | 275 | // Interrupt handlers end with "iret" |
@@ -263,7 +294,7 @@ deliver_to_host: | |||
263 | xorw %ax, %ax | 294 | xorw %ax, %ax |
264 | orl %eax, %edx | 295 | orl %eax, %edx |
265 | // Now the address of the handler's in %edx | 296 | // Now the address of the handler's in %edx |
266 | // We call it now: its "iret" takes us home. | 297 | // We call it now: its "iret" drops us home. |
267 | jmp *%edx | 298 | jmp *%edx |
268 | 299 | ||
269 | // Every interrupt can come to us here | 300 | // Every interrupt can come to us here |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index ac54f697c508..28c6ae095c56 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -168,7 +168,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, | |||
168 | return -ENOMEM; | 168 | return -ENOMEM; |
169 | } | 169 | } |
170 | 170 | ||
171 | sg_set_buf(&sg, cc->key, cc->key_size); | 171 | sg_init_one(&sg, cc->key, cc->key_size); |
172 | desc.tfm = hash_tfm; | 172 | desc.tfm = hash_tfm; |
173 | desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; | 173 | desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; |
174 | err = crypto_hash_digest(&desc, &sg, cc->key_size, salt); | 174 | err = crypto_hash_digest(&desc, &sg, cc->key_size, salt); |
@@ -351,14 +351,10 @@ static int crypt_convert(struct crypt_config *cc, | |||
351 | struct scatterlist sg_in, sg_out; | 351 | struct scatterlist sg_in, sg_out; |
352 | 352 | ||
353 | sg_init_table(&sg_in, 1); | 353 | sg_init_table(&sg_in, 1); |
354 | sg_set_page(&sg_in, bv_in->bv_page); | 354 | sg_set_page(&sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT, bv_in->bv_offset + ctx->offset_in); |
355 | sg_in.offset = bv_in->bv_offset + ctx->offset_in; | ||
356 | sg_in.length = 1 << SECTOR_SHIFT; | ||
357 | 355 | ||
358 | sg_init_table(&sg_out, 1); | 356 | sg_init_table(&sg_out, 1); |
359 | sg_set_page(&sg_out, bv_out->bv_page); | 357 | sg_set_page(&sg_out, bv_out->bv_page, 1 << SECTOR_SHIFT, bv_out->bv_offset + ctx->offset_out); |
360 | sg_out.offset = bv_out->bv_offset + ctx->offset_out; | ||
361 | sg_out.length = 1 << SECTOR_SHIFT; | ||
362 | 358 | ||
363 | ctx->offset_in += sg_in.length; | 359 | ctx->offset_in += sg_in.length; |
364 | if (ctx->offset_in >= bv_in->bv_len) { | 360 | if (ctx->offset_in >= bv_in->bv_len) { |
diff --git a/drivers/md/raid6algos.c b/drivers/md/raid6algos.c index 926576156578..77a6e4bf503d 100644 --- a/drivers/md/raid6algos.c +++ b/drivers/md/raid6algos.c | |||
@@ -52,7 +52,7 @@ const struct raid6_calls * const raid6_algos[] = { | |||
52 | &raid6_intx16, | 52 | &raid6_intx16, |
53 | &raid6_intx32, | 53 | &raid6_intx32, |
54 | #endif | 54 | #endif |
55 | #if defined(__i386__) | 55 | #if defined(__i386__) && !defined(__arch_um__) |
56 | &raid6_mmxx1, | 56 | &raid6_mmxx1, |
57 | &raid6_mmxx2, | 57 | &raid6_mmxx2, |
58 | &raid6_sse1x1, | 58 | &raid6_sse1x1, |
@@ -60,7 +60,7 @@ const struct raid6_calls * const raid6_algos[] = { | |||
60 | &raid6_sse2x1, | 60 | &raid6_sse2x1, |
61 | &raid6_sse2x2, | 61 | &raid6_sse2x2, |
62 | #endif | 62 | #endif |
63 | #if defined(__x86_64__) | 63 | #if defined(__x86_64__) && !defined(__arch_um__) |
64 | &raid6_sse2x1, | 64 | &raid6_sse2x1, |
65 | &raid6_sse2x2, | 65 | &raid6_sse2x2, |
66 | &raid6_sse2x4, | 66 | &raid6_sse2x4, |
diff --git a/drivers/md/raid6mmx.c b/drivers/md/raid6mmx.c index 6181a5a3365a..d4e4a1bd70ad 100644 --- a/drivers/md/raid6mmx.c +++ b/drivers/md/raid6mmx.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * MMX implementation of RAID-6 syndrome functions | 16 | * MMX implementation of RAID-6 syndrome functions |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #if defined(__i386__) | 19 | #if defined(__i386__) && !defined(__arch_um__) |
20 | 20 | ||
21 | #include "raid6.h" | 21 | #include "raid6.h" |
22 | #include "raid6x86.h" | 22 | #include "raid6x86.h" |
diff --git a/drivers/md/raid6sse1.c b/drivers/md/raid6sse1.c index f0a1ba8f40ba..0666237276ff 100644 --- a/drivers/md/raid6sse1.c +++ b/drivers/md/raid6sse1.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * worthwhile as a separate implementation. | 21 | * worthwhile as a separate implementation. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #if defined(__i386__) | 24 | #if defined(__i386__) && !defined(__arch_um__) |
25 | 25 | ||
26 | #include "raid6.h" | 26 | #include "raid6.h" |
27 | #include "raid6x86.h" | 27 | #include "raid6x86.h" |
diff --git a/drivers/md/raid6sse2.c b/drivers/md/raid6sse2.c index 0f019762a7c3..b034ad868039 100644 --- a/drivers/md/raid6sse2.c +++ b/drivers/md/raid6sse2.c | |||
@@ -17,7 +17,7 @@ | |||
17 | * | 17 | * |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #if defined(__i386__) || defined(__x86_64__) | 20 | #if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) |
21 | 21 | ||
22 | #include "raid6.h" | 22 | #include "raid6.h" |
23 | #include "raid6x86.h" | 23 | #include "raid6x86.h" |
@@ -161,7 +161,7 @@ const struct raid6_calls raid6_sse2x2 = { | |||
161 | 161 | ||
162 | #endif | 162 | #endif |
163 | 163 | ||
164 | #ifdef __x86_64__ | 164 | #if defined(__x86_64__) && !defined(__arch_um__) |
165 | 165 | ||
166 | /* | 166 | /* |
167 | * Unrolled-by-4 SSE2 implementation | 167 | * Unrolled-by-4 SSE2 implementation |
diff --git a/drivers/md/raid6x86.h b/drivers/md/raid6x86.h index 9111950414ff..99fea7a70ca7 100644 --- a/drivers/md/raid6x86.h +++ b/drivers/md/raid6x86.h | |||
@@ -19,7 +19,7 @@ | |||
19 | #ifndef LINUX_RAID_RAID6X86_H | 19 | #ifndef LINUX_RAID_RAID6X86_H |
20 | #define LINUX_RAID_RAID6X86_H | 20 | #define LINUX_RAID_RAID6X86_H |
21 | 21 | ||
22 | #if defined(__i386__) || defined(__x86_64__) | 22 | #if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) |
23 | 23 | ||
24 | #ifdef __KERNEL__ /* Real code */ | 24 | #ifdef __KERNEL__ /* Real code */ |
25 | 25 | ||
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c index 2b1f8b4be00a..cb034ead95ab 100644 --- a/drivers/media/common/saa7146_core.c +++ b/drivers/media/common/saa7146_core.c | |||
@@ -118,8 +118,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) | |||
118 | if (NULL == pg) | 118 | if (NULL == pg) |
119 | goto err; | 119 | goto err; |
120 | BUG_ON(PageHighMem(pg)); | 120 | BUG_ON(PageHighMem(pg)); |
121 | sg_set_page(&sglist[i], pg); | 121 | sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); |
122 | sglist[i].length = PAGE_SIZE; | ||
123 | } | 122 | } |
124 | return sglist; | 123 | return sglist; |
125 | 124 | ||
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c index 285fca676a69..623eea2652ca 100644 --- a/drivers/media/video/ivtv/ivtv-i2c.c +++ b/drivers/media/video/ivtv/ivtv-i2c.c | |||
@@ -741,7 +741,7 @@ int __devinit init_ivtv_i2c(struct ivtv *itv) | |||
741 | return i2c_bit_add_bus(&itv->i2c_adap); | 741 | return i2c_bit_add_bus(&itv->i2c_adap); |
742 | } | 742 | } |
743 | 743 | ||
744 | void __devexit exit_ivtv_i2c(struct ivtv *itv) | 744 | void exit_ivtv_i2c(struct ivtv *itv) |
745 | { | 745 | { |
746 | IVTV_DEBUG_I2C("i2c exit\n"); | 746 | IVTV_DEBUG_I2C("i2c exit\n"); |
747 | 747 | ||
diff --git a/drivers/media/video/ivtv/ivtv-i2c.h b/drivers/media/video/ivtv/ivtv-i2c.h index 677c3292855e..de6a07442298 100644 --- a/drivers/media/video/ivtv/ivtv-i2c.h +++ b/drivers/media/video/ivtv/ivtv-i2c.h | |||
@@ -36,6 +36,6 @@ void ivtv_call_i2c_clients(struct ivtv *itv, unsigned int cmd, void *arg); | |||
36 | 36 | ||
37 | /* init + register i2c algo-bit adapter */ | 37 | /* init + register i2c algo-bit adapter */ |
38 | int __devinit init_ivtv_i2c(struct ivtv *itv); | 38 | int __devinit init_ivtv_i2c(struct ivtv *itv); |
39 | void __devexit exit_ivtv_i2c(struct ivtv *itv); | 39 | void exit_ivtv_i2c(struct ivtv *itv); |
40 | 40 | ||
41 | #endif | 41 | #endif |
diff --git a/drivers/media/video/ivtv/ivtv-udma.c b/drivers/media/video/ivtv/ivtv-udma.c index 912b424e5204..460db03b0ba0 100644 --- a/drivers/media/video/ivtv/ivtv-udma.c +++ b/drivers/media/video/ivtv/ivtv-udma.c | |||
@@ -49,8 +49,6 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info | |||
49 | unsigned int len = (i == dma_page->page_count - 1) ? | 49 | unsigned int len = (i == dma_page->page_count - 1) ? |
50 | dma_page->tail : PAGE_SIZE - offset; | 50 | dma_page->tail : PAGE_SIZE - offset; |
51 | 51 | ||
52 | dma->SGlist[map_offset].length = len; | ||
53 | dma->SGlist[map_offset].offset = offset; | ||
54 | if (PageHighMem(dma->map[map_offset])) { | 52 | if (PageHighMem(dma->map[map_offset])) { |
55 | void *src; | 53 | void *src; |
56 | 54 | ||
@@ -63,10 +61,10 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info | |||
63 | memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); | 61 | memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); |
64 | kunmap_atomic(src, KM_BOUNCE_READ); | 62 | kunmap_atomic(src, KM_BOUNCE_READ); |
65 | local_irq_restore(flags); | 63 | local_irq_restore(flags); |
66 | sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset]); | 64 | sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset], len, offset); |
67 | } | 65 | } |
68 | else { | 66 | else { |
69 | sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset]); | 67 | sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset], len, offset); |
70 | } | 68 | } |
71 | offset = 0; | 69 | offset = 0; |
72 | map_offset++; | 70 | map_offset++; |
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 9ab94a749d81..44ee408e145f 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
@@ -67,8 +67,7 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages) | |||
67 | if (NULL == pg) | 67 | if (NULL == pg) |
68 | goto err; | 68 | goto err; |
69 | BUG_ON(PageHighMem(pg)); | 69 | BUG_ON(PageHighMem(pg)); |
70 | sg_set_page(&sglist[i], pg); | 70 | sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); |
71 | sglist[i].length = PAGE_SIZE; | ||
72 | } | 71 | } |
73 | return sglist; | 72 | return sglist; |
74 | 73 | ||
@@ -95,16 +94,13 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset) | |||
95 | if (PageHighMem(pages[0])) | 94 | if (PageHighMem(pages[0])) |
96 | /* DMA to highmem pages might not work */ | 95 | /* DMA to highmem pages might not work */ |
97 | goto highmem; | 96 | goto highmem; |
98 | sg_set_page(&sglist[0], pages[0]); | 97 | sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset); |
99 | sglist[0].offset = offset; | ||
100 | sglist[0].length = PAGE_SIZE - offset; | ||
101 | for (i = 1; i < nr_pages; i++) { | 98 | for (i = 1; i < nr_pages; i++) { |
102 | if (NULL == pages[i]) | 99 | if (NULL == pages[i]) |
103 | goto nopage; | 100 | goto nopage; |
104 | if (PageHighMem(pages[i])) | 101 | if (PageHighMem(pages[i])) |
105 | goto highmem; | 102 | goto highmem; |
106 | sg_set_page(&sglist[i], pages[i]); | 103 | sg_set_page(&sglist[i], pages[i], PAGE_SIZE, 0); |
107 | sglist[i].length = PAGE_SIZE; | ||
108 | } | 104 | } |
109 | return sglist; | 105 | return sglist; |
110 | 106 | ||
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index d602ba6d5417..682406168de9 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c | |||
@@ -284,6 +284,7 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void) | |||
284 | return ERR_PTR(-ENOMEM); | 284 | return ERR_PTR(-ENOMEM); |
285 | 285 | ||
286 | INIT_LIST_HEAD(&ireq->queue); | 286 | INIT_LIST_HEAD(&ireq->queue); |
287 | sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS); | ||
287 | 288 | ||
288 | return ireq; | 289 | return ireq; |
289 | }; | 290 | }; |
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/misc/fujitsu-laptop.c index d366a6cc1fd9..c8d62c268b11 100644 --- a/drivers/misc/fujitsu-laptop.c +++ b/drivers/misc/fujitsu-laptop.c | |||
@@ -122,9 +122,6 @@ static int get_lcd_level(void) | |||
122 | else | 122 | else |
123 | fujitsu->brightness_changed = 0; | 123 | fujitsu->brightness_changed = 0; |
124 | 124 | ||
125 | if (status < 0) | ||
126 | return status; | ||
127 | |||
128 | return fujitsu->brightness_level; | 125 | return fujitsu->brightness_level; |
129 | } | 126 | } |
130 | 127 | ||
@@ -198,7 +195,7 @@ static struct platform_driver fujitsupf_driver = { | |||
198 | 195 | ||
199 | /* ACPI device */ | 196 | /* ACPI device */ |
200 | 197 | ||
201 | int acpi_fujitsu_add(struct acpi_device *device) | 198 | static int acpi_fujitsu_add(struct acpi_device *device) |
202 | { | 199 | { |
203 | int result = 0; | 200 | int result = 0; |
204 | int state = 0; | 201 | int state = 0; |
@@ -229,7 +226,7 @@ int acpi_fujitsu_add(struct acpi_device *device) | |||
229 | return result; | 226 | return result; |
230 | } | 227 | } |
231 | 228 | ||
232 | int acpi_fujitsu_remove(struct acpi_device *device, int type) | 229 | static int acpi_fujitsu_remove(struct acpi_device *device, int type) |
233 | { | 230 | { |
234 | ACPI_FUNCTION_TRACE("acpi_fujitsu_remove"); | 231 | ACPI_FUNCTION_TRACE("acpi_fujitsu_remove"); |
235 | 232 | ||
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index bf4bc6adcfef..7471d49909b2 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -267,15 +267,26 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, | |||
267 | 267 | ||
268 | int mmc_send_csd(struct mmc_card *card, u32 *csd) | 268 | int mmc_send_csd(struct mmc_card *card, u32 *csd) |
269 | { | 269 | { |
270 | int ret, i; | ||
271 | |||
270 | if (!mmc_host_is_spi(card->host)) | 272 | if (!mmc_host_is_spi(card->host)) |
271 | return mmc_send_cxd_native(card->host, card->rca << 16, | 273 | return mmc_send_cxd_native(card->host, card->rca << 16, |
272 | csd, MMC_SEND_CSD); | 274 | csd, MMC_SEND_CSD); |
273 | 275 | ||
274 | return mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); | 276 | ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); |
277 | if (ret) | ||
278 | return ret; | ||
279 | |||
280 | for (i = 0;i < 4;i++) | ||
281 | csd[i] = be32_to_cpu(csd[i]); | ||
282 | |||
283 | return 0; | ||
275 | } | 284 | } |
276 | 285 | ||
277 | int mmc_send_cid(struct mmc_host *host, u32 *cid) | 286 | int mmc_send_cid(struct mmc_host *host, u32 *cid) |
278 | { | 287 | { |
288 | int ret, i; | ||
289 | |||
279 | if (!mmc_host_is_spi(host)) { | 290 | if (!mmc_host_is_spi(host)) { |
280 | if (!host->card) | 291 | if (!host->card) |
281 | return -EINVAL; | 292 | return -EINVAL; |
@@ -283,7 +294,14 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid) | |||
283 | cid, MMC_SEND_CID); | 294 | cid, MMC_SEND_CID); |
284 | } | 295 | } |
285 | 296 | ||
286 | return mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); | 297 | ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); |
298 | if (ret) | ||
299 | return ret; | ||
300 | |||
301 | for (i = 0;i < 4;i++) | ||
302 | cid[i] = be32_to_cpu(cid[i]); | ||
303 | |||
304 | return 0; | ||
287 | } | 305 | } |
288 | 306 | ||
289 | int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) | 307 | int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) |
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index ee4029a24efd..a6dafe62b992 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c | |||
@@ -294,8 +294,8 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
294 | if (data.error) | 294 | if (data.error) |
295 | return data.error; | 295 | return data.error; |
296 | 296 | ||
297 | scr[0] = ntohl(scr[0]); | 297 | scr[0] = be32_to_cpu(scr[0]); |
298 | scr[1] = ntohl(scr[1]); | 298 | scr[1] = be32_to_cpu(scr[1]); |
299 | 299 | ||
300 | return 0; | 300 | return 0; |
301 | } | 301 | } |
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index bcbb6d247bf7..c3926eb3bf43 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c | |||
@@ -40,13 +40,13 @@ | |||
40 | #include <linux/mm.h> | 40 | #include <linux/mm.h> |
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
43 | #include <linux/scatterlist.h> | ||
43 | 44 | ||
44 | #include <linux/mmc/host.h> | 45 | #include <linux/mmc/host.h> |
45 | #include <asm/io.h> | 46 | #include <asm/io.h> |
46 | #include <asm/mach-au1x00/au1000.h> | 47 | #include <asm/mach-au1x00/au1000.h> |
47 | #include <asm/mach-au1x00/au1xxx_dbdma.h> | 48 | #include <asm/mach-au1x00/au1xxx_dbdma.h> |
48 | #include <asm/mach-au1x00/au1100_mmc.h> | 49 | #include <asm/mach-au1x00/au1100_mmc.h> |
49 | #include <asm/scatterlist.h> | ||
50 | 50 | ||
51 | #include <au1xxx.h> | 51 | #include <au1xxx.h> |
52 | #include "au1xmmc.h" | 52 | #include "au1xmmc.h" |
@@ -212,12 +212,12 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait, | |||
212 | } | 212 | } |
213 | 213 | ||
214 | if (data) { | 214 | if (data) { |
215 | if (flags & MMC_DATA_READ) { | 215 | if (data->flags & MMC_DATA_READ) { |
216 | if (data->blocks > 1) | 216 | if (data->blocks > 1) |
217 | mmccmd |= SD_CMD_CT_4; | 217 | mmccmd |= SD_CMD_CT_4; |
218 | else | 218 | else |
219 | mmccmd |= SD_CMD_CT_2; | 219 | mmccmd |= SD_CMD_CT_2; |
220 | } else if (flags & MMC_DATA_WRITE) { | 220 | } else if (data->flags & MMC_DATA_WRITE) { |
221 | if (data->blocks > 1) | 221 | if (data->blocks > 1) |
222 | mmccmd |= SD_CMD_CT_3; | 222 | mmccmd |= SD_CMD_CT_3; |
223 | else | 223 | else |
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c index fc72e1fadb6a..f2070a19cfa7 100644 --- a/drivers/mmc/host/imxmmc.c +++ b/drivers/mmc/host/imxmmc.c | |||
@@ -262,7 +262,7 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
262 | } | 262 | } |
263 | 263 | ||
264 | /* Convert back to virtual address */ | 264 | /* Convert back to virtual address */ |
265 | host->data_ptr = (u16*)sg_virt(sg); | 265 | host->data_ptr = (u16*)sg_virt(data->sg); |
266 | host->data_cnt = 0; | 266 | host->data_cnt = 0; |
267 | 267 | ||
268 | clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); | 268 | clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); |
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 12c2d807c145..a6469218f194 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
@@ -1165,6 +1165,23 @@ mmc_spi_detect_irq(int irq, void *mmc) | |||
1165 | return IRQ_HANDLED; | 1165 | return IRQ_HANDLED; |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | struct count_children { | ||
1169 | unsigned n; | ||
1170 | struct bus_type *bus; | ||
1171 | }; | ||
1172 | |||
1173 | static int maybe_count_child(struct device *dev, void *c) | ||
1174 | { | ||
1175 | struct count_children *ccp = c; | ||
1176 | |||
1177 | if (dev->bus == ccp->bus) { | ||
1178 | if (ccp->n) | ||
1179 | return -EBUSY; | ||
1180 | ccp->n++; | ||
1181 | } | ||
1182 | return 0; | ||
1183 | } | ||
1184 | |||
1168 | static int mmc_spi_probe(struct spi_device *spi) | 1185 | static int mmc_spi_probe(struct spi_device *spi) |
1169 | { | 1186 | { |
1170 | void *ones; | 1187 | void *ones; |
@@ -1188,33 +1205,30 @@ static int mmc_spi_probe(struct spi_device *spi) | |||
1188 | return status; | 1205 | return status; |
1189 | } | 1206 | } |
1190 | 1207 | ||
1191 | /* We can use the bus safely iff nobody else will interfere with | 1208 | /* We can use the bus safely iff nobody else will interfere with us. |
1192 | * us. That is, either we have the experimental exclusive access | 1209 | * Most commands consist of one SPI message to issue a command, then |
1193 | * primitives ... or else there's nobody to share it with. | 1210 | * several more to collect its response, then possibly more for data |
1211 | * transfer. Clocking access to other devices during that period will | ||
1212 | * corrupt the command execution. | ||
1213 | * | ||
1214 | * Until we have software primitives which guarantee non-interference, | ||
1215 | * we'll aim for a hardware-level guarantee. | ||
1216 | * | ||
1217 | * REVISIT we can't guarantee another device won't be added later... | ||
1194 | */ | 1218 | */ |
1195 | if (spi->master->num_chipselect > 1) { | 1219 | if (spi->master->num_chipselect > 1) { |
1196 | struct device *parent = spi->dev.parent; | 1220 | struct count_children cc; |
1197 | 1221 | ||
1198 | /* If there are multiple devices on this bus, we | 1222 | cc.n = 0; |
1199 | * can't proceed. | 1223 | cc.bus = spi->dev.bus; |
1200 | */ | 1224 | status = device_for_each_child(spi->dev.parent, &cc, |
1201 | spin_lock(&parent->klist_children.k_lock); | 1225 | maybe_count_child); |
1202 | if (parent->klist_children.k_list.next | ||
1203 | != parent->klist_children.k_list.prev) | ||
1204 | status = -EMLINK; | ||
1205 | else | ||
1206 | status = 0; | ||
1207 | spin_unlock(&parent->klist_children.k_lock); | ||
1208 | if (status < 0) { | 1226 | if (status < 0) { |
1209 | dev_err(&spi->dev, "can't share SPI bus\n"); | 1227 | dev_err(&spi->dev, "can't share SPI bus\n"); |
1210 | return status; | 1228 | return status; |
1211 | } | 1229 | } |
1212 | 1230 | ||
1213 | /* REVISIT we can't guarantee another device won't | 1231 | dev_warn(&spi->dev, "ASSUMING SPI bus stays unshared!\n"); |
1214 | * be added later. It's uncommon though ... for now, | ||
1215 | * work as if this is safe. | ||
1216 | */ | ||
1217 | dev_warn(&spi->dev, "ASSUMING unshared SPI bus!\n"); | ||
1218 | } | 1232 | } |
1219 | 1233 | ||
1220 | /* We need a supply of ones to transmit. This is the only time | 1234 | /* We need a supply of ones to transmit. This is the only time |
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index d0eb0a2abf4d..95244a7e7353 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c | |||
@@ -20,11 +20,11 @@ | |||
20 | #include <linux/mmc/host.h> | 20 | #include <linux/mmc/host.h> |
21 | #include <linux/amba/bus.h> | 21 | #include <linux/amba/bus.h> |
22 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
23 | #include <linux/scatterlist.h> | ||
23 | 24 | ||
24 | #include <asm/cacheflush.h> | 25 | #include <asm/cacheflush.h> |
25 | #include <asm/div64.h> | 26 | #include <asm/div64.h> |
26 | #include <asm/io.h> | 27 | #include <asm/io.h> |
27 | #include <asm/scatterlist.h> | ||
28 | #include <asm/sizes.h> | 28 | #include <asm/sizes.h> |
29 | #include <asm/mach/mmc.h> | 29 | #include <asm/mach/mmc.h> |
30 | 30 | ||
@@ -167,7 +167,7 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, | |||
167 | * partially written to a page is properly coherent. | 167 | * partially written to a page is properly coherent. |
168 | */ | 168 | */ |
169 | if (host->sg_len && data->flags & MMC_DATA_READ) | 169 | if (host->sg_len && data->flags & MMC_DATA_READ) |
170 | flush_dcache_page(host->sg_ptr->page); | 170 | flush_dcache_page(sg_page(host->sg_ptr)); |
171 | } | 171 | } |
172 | if (status & MCI_DATAEND) { | 172 | if (status & MCI_DATAEND) { |
173 | mmci_stop_data(host); | 173 | mmci_stop_data(host); |
@@ -319,7 +319,7 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id) | |||
319 | * page, ensure that the data cache is coherent. | 319 | * page, ensure that the data cache is coherent. |
320 | */ | 320 | */ |
321 | if (status & MCI_RXACTIVE) | 321 | if (status & MCI_RXACTIVE) |
322 | flush_dcache_page(host->sg_ptr->page); | 322 | flush_dcache_page(sg_page(host->sg_ptr)); |
323 | 323 | ||
324 | if (!mmci_next_sg(host)) | 324 | if (!mmci_next_sg(host)) |
325 | break; | 325 | break; |
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index 0601e01aa2c2..1654a3330340 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #include <asm/dma.h> | 30 | #include <asm/dma.h> |
31 | #include <asm/io.h> | 31 | #include <asm/io.h> |
32 | #include <asm/scatterlist.h> | ||
33 | #include <asm/sizes.h> | 32 | #include <asm/sizes.h> |
34 | 33 | ||
35 | #include <asm/arch/pxa-regs.h> | 34 | #include <asm/arch/pxa-regs.h> |
@@ -40,6 +39,7 @@ | |||
40 | #define DRIVER_NAME "pxa2xx-mci" | 39 | #define DRIVER_NAME "pxa2xx-mci" |
41 | 40 | ||
42 | #define NR_SG 1 | 41 | #define NR_SG 1 |
42 | #define CLKRT_OFF (~0) | ||
43 | 43 | ||
44 | struct pxamci_host { | 44 | struct pxamci_host { |
45 | struct mmc_host *mmc; | 45 | struct mmc_host *mmc; |
@@ -372,6 +372,9 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
372 | unsigned long rate = host->clkrate; | 372 | unsigned long rate = host->clkrate; |
373 | unsigned int clk = rate / ios->clock; | 373 | unsigned int clk = rate / ios->clock; |
374 | 374 | ||
375 | if (host->clkrt == CLKRT_OFF) | ||
376 | clk_enable(host->clk); | ||
377 | |||
375 | /* | 378 | /* |
376 | * clk might result in a lower divisor than we | 379 | * clk might result in a lower divisor than we |
377 | * desire. check for that condition and adjust | 380 | * desire. check for that condition and adjust |
@@ -380,14 +383,16 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
380 | if (rate / clk > ios->clock) | 383 | if (rate / clk > ios->clock) |
381 | clk <<= 1; | 384 | clk <<= 1; |
382 | host->clkrt = fls(clk) - 1; | 385 | host->clkrt = fls(clk) - 1; |
383 | clk_enable(host->clk); | ||
384 | 386 | ||
385 | /* | 387 | /* |
386 | * we write clkrt on the next command | 388 | * we write clkrt on the next command |
387 | */ | 389 | */ |
388 | } else { | 390 | } else { |
389 | pxamci_stop_clock(host); | 391 | pxamci_stop_clock(host); |
390 | clk_disable(host->clk); | 392 | if (host->clkrt != CLKRT_OFF) { |
393 | host->clkrt = CLKRT_OFF; | ||
394 | clk_disable(host->clk); | ||
395 | } | ||
391 | } | 396 | } |
392 | 397 | ||
393 | if (host->power_mode != ios->power_mode) { | 398 | if (host->power_mode != ios->power_mode) { |
@@ -499,6 +504,7 @@ static int pxamci_probe(struct platform_device *pdev) | |||
499 | host->mmc = mmc; | 504 | host->mmc = mmc; |
500 | host->dma = -1; | 505 | host->dma = -1; |
501 | host->pdata = pdev->dev.platform_data; | 506 | host->pdata = pdev->dev.platform_data; |
507 | host->clkrt = CLKRT_OFF; | ||
502 | 508 | ||
503 | host->clk = clk_get(&pdev->dev, "MMCCLK"); | 509 | host->clk = clk_get(&pdev->dev, "MMCCLK"); |
504 | if (IS_ERR(host->clk)) { | 510 | if (IS_ERR(host->clk)) { |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index d7c5b94d8c58..6b80bf77a4ef 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -17,8 +17,6 @@ | |||
17 | 17 | ||
18 | #include <linux/mmc/host.h> | 18 | #include <linux/mmc/host.h> |
19 | 19 | ||
20 | #include <asm/scatterlist.h> | ||
21 | |||
22 | #include "sdhci.h" | 20 | #include "sdhci.h" |
23 | 21 | ||
24 | #define DRIVER_NAME "sdhci" | 22 | #define DRIVER_NAME "sdhci" |
diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c index fa4c8c53cc7a..4d5f37421874 100644 --- a/drivers/mmc/host/wbsd.c +++ b/drivers/mmc/host/wbsd.c | |||
@@ -33,10 +33,10 @@ | |||
33 | #include <linux/pnp.h> | 33 | #include <linux/pnp.h> |
34 | #include <linux/highmem.h> | 34 | #include <linux/highmem.h> |
35 | #include <linux/mmc/host.h> | 35 | #include <linux/mmc/host.h> |
36 | #include <linux/scatterlist.h> | ||
36 | 37 | ||
37 | #include <asm/io.h> | 38 | #include <asm/io.h> |
38 | #include <asm/dma.h> | 39 | #include <asm/dma.h> |
39 | #include <asm/scatterlist.h> | ||
40 | 40 | ||
41 | #include "wbsd.h" | 41 | #include "wbsd.h" |
42 | 42 | ||
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 86b8641b4664..5f800a6dd978 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -166,13 +166,14 @@ config NET_SB1000 | |||
166 | If you don't have this card, of course say N. | 166 | If you don't have this card, of course say N. |
167 | 167 | ||
168 | config IP1000 | 168 | config IP1000 |
169 | tristate "IP1000 Gigabit Ethernet support" | 169 | tristate "IP1000 Gigabit Ethernet support" |
170 | depends on PCI && EXPERIMENTAL | 170 | depends on PCI && EXPERIMENTAL |
171 | ---help--- | 171 | select MII |
172 | This driver supports IP1000 gigabit Ethernet cards. | 172 | ---help--- |
173 | This driver supports IP1000 gigabit Ethernet cards. | ||
173 | 174 | ||
174 | To compile this driver as a module, choose M here: the module | 175 | To compile this driver as a module, choose M here: the module |
175 | will be called ipg. This is recommended. | 176 | will be called ipg. This is recommended. |
176 | 177 | ||
177 | source "drivers/net/arcnet/Kconfig" | 178 | source "drivers/net/arcnet/Kconfig" |
178 | 179 | ||
@@ -1880,6 +1881,28 @@ config FEC2 | |||
1880 | Say Y here if you want to use the second built-in 10/100 Fast | 1881 | Say Y here if you want to use the second built-in 10/100 Fast |
1881 | ethernet controller on some Motorola ColdFire processors. | 1882 | ethernet controller on some Motorola ColdFire processors. |
1882 | 1883 | ||
1884 | config FEC_MPC52xx | ||
1885 | tristate "MPC52xx FEC driver" | ||
1886 | depends on PPC_MERGE && PPC_MPC52xx && PPC_BESTCOMM_FEC | ||
1887 | select CRC32 | ||
1888 | select PHYLIB | ||
1889 | ---help--- | ||
1890 | This option enables support for the MPC5200's on-chip | ||
1891 | Fast Ethernet Controller | ||
1892 | If compiled as module, it will be called 'fec_mpc52xx.ko'. | ||
1893 | |||
1894 | config FEC_MPC52xx_MDIO | ||
1895 | bool "MPC52xx FEC MDIO bus driver" | ||
1896 | depends on FEC_MPC52xx | ||
1897 | default y | ||
1898 | ---help--- | ||
1899 | The MPC5200's FEC can connect to the Ethernet either with | ||
1900 | an external MII PHY chip or 10 Mbps 7-wire interface | ||
1901 | (Motorola? industry standard). | ||
1902 | If your board uses an external PHY connected to FEC, enable this. | ||
1903 | If not sure, enable. | ||
1904 | If compiled as module, it will be called 'fec_mpc52xx_phy.ko'. | ||
1905 | |||
1883 | config NE_H8300 | 1906 | config NE_H8300 |
1884 | tristate "NE2000 compatible support for H8/300" | 1907 | tristate "NE2000 compatible support for H8/300" |
1885 | depends on H8300 | 1908 | depends on H8300 |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 593262065c9b..0e5fde4a1b2c 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -96,6 +96,10 @@ obj-$(CONFIG_SHAPER) += shaper.o | |||
96 | obj-$(CONFIG_HP100) += hp100.o | 96 | obj-$(CONFIG_HP100) += hp100.o |
97 | obj-$(CONFIG_SMC9194) += smc9194.o | 97 | obj-$(CONFIG_SMC9194) += smc9194.o |
98 | obj-$(CONFIG_FEC) += fec.o | 98 | obj-$(CONFIG_FEC) += fec.o |
99 | obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx.o | ||
100 | ifeq ($(CONFIG_FEC_MPC52xx_MDIO),y) | ||
101 | obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx_phy.o | ||
102 | endif | ||
99 | obj-$(CONFIG_68360_ENET) += 68360enet.o | 103 | obj-$(CONFIG_68360_ENET) += 68360enet.o |
100 | obj-$(CONFIG_WD80x3) += wd.o 8390.o | 104 | obj-$(CONFIG_WD80x3) += wd.o 8390.o |
101 | obj-$(CONFIG_EL2) += 3c503.o 8390.o | 105 | obj-$(CONFIG_EL2) += 3c503.o 8390.o |
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c index 53fe7ded5d50..084acfd6fc5f 100644 --- a/drivers/net/bfin_mac.c +++ b/drivers/net/bfin_mac.c | |||
@@ -371,7 +371,6 @@ static void bf537_adjust_link(struct net_device *dev) | |||
371 | if (phydev->speed != lp->old_speed) { | 371 | if (phydev->speed != lp->old_speed) { |
372 | #if defined(CONFIG_BFIN_MAC_RMII) | 372 | #if defined(CONFIG_BFIN_MAC_RMII) |
373 | u32 opmode = bfin_read_EMAC_OPMODE(); | 373 | u32 opmode = bfin_read_EMAC_OPMODE(); |
374 | bf537mac_disable(); | ||
375 | switch (phydev->speed) { | 374 | switch (phydev->speed) { |
376 | case 10: | 375 | case 10: |
377 | opmode |= RMII_10; | 376 | opmode |= RMII_10; |
@@ -386,7 +385,6 @@ static void bf537_adjust_link(struct net_device *dev) | |||
386 | break; | 385 | break; |
387 | } | 386 | } |
388 | bfin_write_EMAC_OPMODE(opmode); | 387 | bfin_write_EMAC_OPMODE(opmode); |
389 | bf537mac_enable(); | ||
390 | #endif | 388 | #endif |
391 | 389 | ||
392 | new_state = 1; | 390 | new_state = 1; |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 6909becb10f6..6937ef0e7275 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -188,6 +188,7 @@ struct bond_parm_tbl arp_validate_tbl[] = { | |||
188 | /*-------------------------- Forward declarations ---------------------------*/ | 188 | /*-------------------------- Forward declarations ---------------------------*/ |
189 | 189 | ||
190 | static void bond_send_gratuitous_arp(struct bonding *bond); | 190 | static void bond_send_gratuitous_arp(struct bonding *bond); |
191 | static void bond_deinit(struct net_device *bond_dev); | ||
191 | 192 | ||
192 | /*---------------------------- General routines -----------------------------*/ | 193 | /*---------------------------- General routines -----------------------------*/ |
193 | 194 | ||
@@ -3681,7 +3682,7 @@ static int bond_open(struct net_device *bond_dev) | |||
3681 | } | 3682 | } |
3682 | 3683 | ||
3683 | if (bond->params.mode == BOND_MODE_8023AD) { | 3684 | if (bond->params.mode == BOND_MODE_8023AD) { |
3684 | INIT_DELAYED_WORK(&bond->ad_work, bond_alb_monitor); | 3685 | INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); |
3685 | queue_delayed_work(bond->wq, &bond->ad_work, 0); | 3686 | queue_delayed_work(bond->wq, &bond->ad_work, 0); |
3686 | /* register to receive LACPDUs */ | 3687 | /* register to receive LACPDUs */ |
3687 | bond_register_lacpdu(bond); | 3688 | bond_register_lacpdu(bond); |
@@ -4449,7 +4450,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params) | |||
4449 | /* De-initialize device specific data. | 4450 | /* De-initialize device specific data. |
4450 | * Caller must hold rtnl_lock. | 4451 | * Caller must hold rtnl_lock. |
4451 | */ | 4452 | */ |
4452 | void bond_deinit(struct net_device *bond_dev) | 4453 | static void bond_deinit(struct net_device *bond_dev) |
4453 | { | 4454 | { |
4454 | struct bonding *bond = bond_dev->priv; | 4455 | struct bonding *bond = bond_dev->priv; |
4455 | 4456 | ||
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index d1ed14bf1ccb..61c1b4536d34 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -302,7 +302,6 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_de | |||
302 | int bond_create(char *name, struct bond_params *params, struct bonding **newbond); | 302 | int bond_create(char *name, struct bond_params *params, struct bonding **newbond); |
303 | void bond_destroy(struct bonding *bond); | 303 | void bond_destroy(struct bonding *bond); |
304 | int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev); | 304 | int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev); |
305 | void bond_deinit(struct net_device *bond_dev); | ||
306 | int bond_create_sysfs(void); | 305 | int bond_create_sysfs(void); |
307 | void bond_destroy_sysfs(void); | 306 | void bond_destroy_sysfs(void); |
308 | void bond_destroy_sysfs_entry(struct bonding *bond); | 307 | void bond_destroy_sysfs_entry(struct bonding *bond); |
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c index 57541d2d9e1e..6fd95a2c8cec 100644 --- a/drivers/net/cpmac.c +++ b/drivers/net/cpmac.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/skbuff.h> | 34 | #include <linux/skbuff.h> |
35 | #include <linux/mii.h> | 35 | #include <linux/mii.h> |
36 | #include <linux/phy.h> | 36 | #include <linux/phy.h> |
37 | #include <linux/phy_fixed.h> | ||
37 | #include <linux/platform_device.h> | 38 | #include <linux/platform_device.h> |
38 | #include <linux/dma-mapping.h> | 39 | #include <linux/dma-mapping.h> |
39 | #include <asm/gpio.h> | 40 | #include <asm/gpio.h> |
@@ -53,12 +54,6 @@ MODULE_PARM_DESC(debug_level, "Number of NETIF_MSG bits to enable"); | |||
53 | MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus"); | 54 | MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus"); |
54 | 55 | ||
55 | #define CPMAC_VERSION "0.5.0" | 56 | #define CPMAC_VERSION "0.5.0" |
56 | /* stolen from net/ieee80211.h */ | ||
57 | #ifndef MAC_FMT | ||
58 | #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" | ||
59 | #define MAC_ARG(x) ((u8*)(x))[0], ((u8*)(x))[1], ((u8*)(x))[2], \ | ||
60 | ((u8*)(x))[3], ((u8*)(x))[4], ((u8*)(x))[5] | ||
61 | #endif | ||
62 | /* frame size + 802.1q tag */ | 57 | /* frame size + 802.1q tag */ |
63 | #define CPMAC_SKB_SIZE (ETH_FRAME_LEN + 4) | 58 | #define CPMAC_SKB_SIZE (ETH_FRAME_LEN + 4) |
64 | #define CPMAC_QUEUES 8 | 59 | #define CPMAC_QUEUES 8 |
@@ -211,6 +206,7 @@ struct cpmac_priv { | |||
211 | struct net_device *dev; | 206 | struct net_device *dev; |
212 | struct work_struct reset_work; | 207 | struct work_struct reset_work; |
213 | struct platform_device *pdev; | 208 | struct platform_device *pdev; |
209 | struct napi_struct napi; | ||
214 | }; | 210 | }; |
215 | 211 | ||
216 | static irqreturn_t cpmac_irq(int, void *); | 212 | static irqreturn_t cpmac_irq(int, void *); |
@@ -362,47 +358,48 @@ static void cpmac_set_multicast_list(struct net_device *dev) | |||
362 | } | 358 | } |
363 | } | 359 | } |
364 | 360 | ||
365 | static struct sk_buff *cpmac_rx_one(struct net_device *dev, | 361 | static struct sk_buff *cpmac_rx_one(struct cpmac_priv *priv, |
366 | struct cpmac_priv *priv, | ||
367 | struct cpmac_desc *desc) | 362 | struct cpmac_desc *desc) |
368 | { | 363 | { |
369 | struct sk_buff *skb, *result = NULL; | 364 | struct sk_buff *skb, *result = NULL; |
370 | 365 | ||
371 | if (unlikely(netif_msg_hw(priv))) | 366 | if (unlikely(netif_msg_hw(priv))) |
372 | cpmac_dump_desc(dev, desc); | 367 | cpmac_dump_desc(priv->dev, desc); |
373 | cpmac_write(priv->regs, CPMAC_RX_ACK(0), (u32)desc->mapping); | 368 | cpmac_write(priv->regs, CPMAC_RX_ACK(0), (u32)desc->mapping); |
374 | if (unlikely(!desc->datalen)) { | 369 | if (unlikely(!desc->datalen)) { |
375 | if (netif_msg_rx_err(priv) && net_ratelimit()) | 370 | if (netif_msg_rx_err(priv) && net_ratelimit()) |
376 | printk(KERN_WARNING "%s: rx: spurious interrupt\n", | 371 | printk(KERN_WARNING "%s: rx: spurious interrupt\n", |
377 | dev->name); | 372 | priv->dev->name); |
378 | return NULL; | 373 | return NULL; |
379 | } | 374 | } |
380 | 375 | ||
381 | skb = netdev_alloc_skb(dev, CPMAC_SKB_SIZE); | 376 | skb = netdev_alloc_skb(priv->dev, CPMAC_SKB_SIZE); |
382 | if (likely(skb)) { | 377 | if (likely(skb)) { |
383 | skb_reserve(skb, 2); | 378 | skb_reserve(skb, 2); |
384 | skb_put(desc->skb, desc->datalen); | 379 | skb_put(desc->skb, desc->datalen); |
385 | desc->skb->protocol = eth_type_trans(desc->skb, dev); | 380 | desc->skb->protocol = eth_type_trans(desc->skb, priv->dev); |
386 | desc->skb->ip_summed = CHECKSUM_NONE; | 381 | desc->skb->ip_summed = CHECKSUM_NONE; |
387 | dev->stats.rx_packets++; | 382 | priv->dev->stats.rx_packets++; |
388 | dev->stats.rx_bytes += desc->datalen; | 383 | priv->dev->stats.rx_bytes += desc->datalen; |
389 | result = desc->skb; | 384 | result = desc->skb; |
390 | dma_unmap_single(&dev->dev, desc->data_mapping, CPMAC_SKB_SIZE, | 385 | dma_unmap_single(&priv->dev->dev, desc->data_mapping, |
391 | DMA_FROM_DEVICE); | 386 | CPMAC_SKB_SIZE, DMA_FROM_DEVICE); |
392 | desc->skb = skb; | 387 | desc->skb = skb; |
393 | desc->data_mapping = dma_map_single(&dev->dev, skb->data, | 388 | desc->data_mapping = dma_map_single(&priv->dev->dev, skb->data, |
394 | CPMAC_SKB_SIZE, | 389 | CPMAC_SKB_SIZE, |
395 | DMA_FROM_DEVICE); | 390 | DMA_FROM_DEVICE); |
396 | desc->hw_data = (u32)desc->data_mapping; | 391 | desc->hw_data = (u32)desc->data_mapping; |
397 | if (unlikely(netif_msg_pktdata(priv))) { | 392 | if (unlikely(netif_msg_pktdata(priv))) { |
398 | printk(KERN_DEBUG "%s: received packet:\n", dev->name); | 393 | printk(KERN_DEBUG "%s: received packet:\n", |
399 | cpmac_dump_skb(dev, result); | 394 | priv->dev->name); |
395 | cpmac_dump_skb(priv->dev, result); | ||
400 | } | 396 | } |
401 | } else { | 397 | } else { |
402 | if (netif_msg_rx_err(priv) && net_ratelimit()) | 398 | if (netif_msg_rx_err(priv) && net_ratelimit()) |
403 | printk(KERN_WARNING | 399 | printk(KERN_WARNING |
404 | "%s: low on skbs, dropping packet\n", dev->name); | 400 | "%s: low on skbs, dropping packet\n", |
405 | dev->stats.rx_dropped++; | 401 | priv->dev->name); |
402 | priv->dev->stats.rx_dropped++; | ||
406 | } | 403 | } |
407 | 404 | ||
408 | desc->buflen = CPMAC_SKB_SIZE; | 405 | desc->buflen = CPMAC_SKB_SIZE; |
@@ -411,25 +408,25 @@ static struct sk_buff *cpmac_rx_one(struct net_device *dev, | |||
411 | return result; | 408 | return result; |
412 | } | 409 | } |
413 | 410 | ||
414 | static int cpmac_poll(struct net_device *dev, int *budget) | 411 | static int cpmac_poll(struct napi_struct *napi, int budget) |
415 | { | 412 | { |
416 | struct sk_buff *skb; | 413 | struct sk_buff *skb; |
417 | struct cpmac_desc *desc; | 414 | struct cpmac_desc *desc; |
418 | int received = 0, quota = min(dev->quota, *budget); | 415 | int received = 0; |
419 | struct cpmac_priv *priv = netdev_priv(dev); | 416 | struct cpmac_priv *priv = container_of(napi, struct cpmac_priv, napi); |
420 | 417 | ||
421 | spin_lock(&priv->rx_lock); | 418 | spin_lock(&priv->rx_lock); |
422 | if (unlikely(!priv->rx_head)) { | 419 | if (unlikely(!priv->rx_head)) { |
423 | if (netif_msg_rx_err(priv) && net_ratelimit()) | 420 | if (netif_msg_rx_err(priv) && net_ratelimit()) |
424 | printk(KERN_WARNING "%s: rx: polling, but no queue\n", | 421 | printk(KERN_WARNING "%s: rx: polling, but no queue\n", |
425 | dev->name); | 422 | priv->dev->name); |
426 | netif_rx_complete(dev); | 423 | netif_rx_complete(priv->dev, napi); |
427 | return 0; | 424 | return 0; |
428 | } | 425 | } |
429 | 426 | ||
430 | desc = priv->rx_head; | 427 | desc = priv->rx_head; |
431 | while ((received < quota) && ((desc->dataflags & CPMAC_OWN) == 0)) { | 428 | while (((desc->dataflags & CPMAC_OWN) == 0) && (received < budget)) { |
432 | skb = cpmac_rx_one(dev, priv, desc); | 429 | skb = cpmac_rx_one(priv, desc); |
433 | if (likely(skb)) { | 430 | if (likely(skb)) { |
434 | netif_receive_skb(skb); | 431 | netif_receive_skb(skb); |
435 | received++; | 432 | received++; |
@@ -439,13 +436,11 @@ static int cpmac_poll(struct net_device *dev, int *budget) | |||
439 | 436 | ||
440 | priv->rx_head = desc; | 437 | priv->rx_head = desc; |
441 | spin_unlock(&priv->rx_lock); | 438 | spin_unlock(&priv->rx_lock); |
442 | *budget -= received; | ||
443 | dev->quota -= received; | ||
444 | if (unlikely(netif_msg_rx_status(priv))) | 439 | if (unlikely(netif_msg_rx_status(priv))) |
445 | printk(KERN_DEBUG "%s: poll processed %d packets\n", dev->name, | 440 | printk(KERN_DEBUG "%s: poll processed %d packets\n", |
446 | received); | 441 | priv->dev->name, received); |
447 | if (desc->dataflags & CPMAC_OWN) { | 442 | if (desc->dataflags & CPMAC_OWN) { |
448 | netif_rx_complete(dev); | 443 | netif_rx_complete(priv->dev, napi); |
449 | cpmac_write(priv->regs, CPMAC_RX_PTR(0), (u32)desc->mapping); | 444 | cpmac_write(priv->regs, CPMAC_RX_PTR(0), (u32)desc->mapping); |
450 | cpmac_write(priv->regs, CPMAC_RX_INT_ENABLE, 1); | 445 | cpmac_write(priv->regs, CPMAC_RX_INT_ENABLE, 1); |
451 | return 0; | 446 | return 0; |
@@ -655,6 +650,7 @@ static void cpmac_hw_error(struct work_struct *work) | |||
655 | spin_unlock(&priv->rx_lock); | 650 | spin_unlock(&priv->rx_lock); |
656 | cpmac_clear_tx(priv->dev); | 651 | cpmac_clear_tx(priv->dev); |
657 | cpmac_hw_start(priv->dev); | 652 | cpmac_hw_start(priv->dev); |
653 | napi_enable(&priv->napi); | ||
658 | netif_start_queue(priv->dev); | 654 | netif_start_queue(priv->dev); |
659 | } | 655 | } |
660 | 656 | ||
@@ -681,8 +677,10 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id) | |||
681 | 677 | ||
682 | if (status & MAC_INT_RX) { | 678 | if (status & MAC_INT_RX) { |
683 | queue = (status >> 8) & 7; | 679 | queue = (status >> 8) & 7; |
684 | netif_rx_schedule(dev); | 680 | if (netif_rx_schedule_prep(dev, &priv->napi)) { |
685 | cpmac_write(priv->regs, CPMAC_RX_INT_CLEAR, 1 << queue); | 681 | cpmac_write(priv->regs, CPMAC_RX_INT_CLEAR, 1 << queue); |
682 | __netif_rx_schedule(dev, &priv->napi); | ||
683 | } | ||
686 | } | 684 | } |
687 | 685 | ||
688 | cpmac_write(priv->regs, CPMAC_MAC_EOI_VECTOR, 0); | 686 | cpmac_write(priv->regs, CPMAC_MAC_EOI_VECTOR, 0); |
@@ -692,6 +690,7 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id) | |||
692 | printk(KERN_ERR "%s: hw error, resetting...\n", | 690 | printk(KERN_ERR "%s: hw error, resetting...\n", |
693 | dev->name); | 691 | dev->name); |
694 | netif_stop_queue(dev); | 692 | netif_stop_queue(dev); |
693 | napi_disable(&priv->napi); | ||
695 | cpmac_hw_stop(dev); | 694 | cpmac_hw_stop(dev); |
696 | schedule_work(&priv->reset_work); | 695 | schedule_work(&priv->reset_work); |
697 | if (unlikely(netif_msg_hw(priv))) | 696 | if (unlikely(netif_msg_hw(priv))) |
@@ -849,6 +848,15 @@ static void cpmac_adjust_link(struct net_device *dev) | |||
849 | spin_unlock(&priv->lock); | 848 | spin_unlock(&priv->lock); |
850 | } | 849 | } |
851 | 850 | ||
851 | static int cpmac_link_update(struct net_device *dev, | ||
852 | struct fixed_phy_status *status) | ||
853 | { | ||
854 | status->link = 1; | ||
855 | status->speed = 100; | ||
856 | status->duplex = 1; | ||
857 | return 0; | ||
858 | } | ||
859 | |||
852 | static int cpmac_open(struct net_device *dev) | 860 | static int cpmac_open(struct net_device *dev) |
853 | { | 861 | { |
854 | int i, size, res; | 862 | int i, size, res; |
@@ -857,15 +865,6 @@ static int cpmac_open(struct net_device *dev) | |||
857 | struct cpmac_desc *desc; | 865 | struct cpmac_desc *desc; |
858 | struct sk_buff *skb; | 866 | struct sk_buff *skb; |
859 | 867 | ||
860 | priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, | ||
861 | 0, PHY_INTERFACE_MODE_MII); | ||
862 | if (IS_ERR(priv->phy)) { | ||
863 | if (netif_msg_drv(priv)) | ||
864 | printk(KERN_ERR "%s: Could not attach to PHY\n", | ||
865 | dev->name); | ||
866 | return PTR_ERR(priv->phy); | ||
867 | } | ||
868 | |||
869 | mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs"); | 868 | mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs"); |
870 | if (!request_mem_region(mem->start, mem->end - mem->start, dev->name)) { | 869 | if (!request_mem_region(mem->start, mem->end - mem->start, dev->name)) { |
871 | if (netif_msg_drv(priv)) | 870 | if (netif_msg_drv(priv)) |
@@ -927,6 +926,7 @@ static int cpmac_open(struct net_device *dev) | |||
927 | INIT_WORK(&priv->reset_work, cpmac_hw_error); | 926 | INIT_WORK(&priv->reset_work, cpmac_hw_error); |
928 | cpmac_hw_start(dev); | 927 | cpmac_hw_start(dev); |
929 | 928 | ||
929 | napi_enable(&priv->napi); | ||
930 | priv->phy->state = PHY_CHANGELINK; | 930 | priv->phy->state = PHY_CHANGELINK; |
931 | phy_start(priv->phy); | 931 | phy_start(priv->phy); |
932 | 932 | ||
@@ -951,8 +951,6 @@ fail_remap: | |||
951 | release_mem_region(mem->start, mem->end - mem->start); | 951 | release_mem_region(mem->start, mem->end - mem->start); |
952 | 952 | ||
953 | fail_reserve: | 953 | fail_reserve: |
954 | phy_disconnect(priv->phy); | ||
955 | |||
956 | return res; | 954 | return res; |
957 | } | 955 | } |
958 | 956 | ||
@@ -965,9 +963,8 @@ static int cpmac_stop(struct net_device *dev) | |||
965 | netif_stop_queue(dev); | 963 | netif_stop_queue(dev); |
966 | 964 | ||
967 | cancel_work_sync(&priv->reset_work); | 965 | cancel_work_sync(&priv->reset_work); |
966 | napi_disable(&priv->napi); | ||
968 | phy_stop(priv->phy); | 967 | phy_stop(priv->phy); |
969 | phy_disconnect(priv->phy); | ||
970 | priv->phy = NULL; | ||
971 | 968 | ||
972 | cpmac_hw_stop(dev); | 969 | cpmac_hw_stop(dev); |
973 | 970 | ||
@@ -1001,11 +998,13 @@ static int external_switch; | |||
1001 | 998 | ||
1002 | static int __devinit cpmac_probe(struct platform_device *pdev) | 999 | static int __devinit cpmac_probe(struct platform_device *pdev) |
1003 | { | 1000 | { |
1004 | int rc, phy_id; | 1001 | int rc, phy_id, i; |
1005 | struct resource *mem; | 1002 | struct resource *mem; |
1006 | struct cpmac_priv *priv; | 1003 | struct cpmac_priv *priv; |
1007 | struct net_device *dev; | 1004 | struct net_device *dev; |
1008 | struct plat_cpmac_data *pdata; | 1005 | struct plat_cpmac_data *pdata; |
1006 | struct fixed_info *fixed_phy; | ||
1007 | DECLARE_MAC_BUF(mac); | ||
1009 | 1008 | ||
1010 | pdata = pdev->dev.platform_data; | 1009 | pdata = pdev->dev.platform_data; |
1011 | 1010 | ||
@@ -1053,21 +1052,51 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1053 | dev->set_multicast_list = cpmac_set_multicast_list; | 1052 | dev->set_multicast_list = cpmac_set_multicast_list; |
1054 | dev->tx_timeout = cpmac_tx_timeout; | 1053 | dev->tx_timeout = cpmac_tx_timeout; |
1055 | dev->ethtool_ops = &cpmac_ethtool_ops; | 1054 | dev->ethtool_ops = &cpmac_ethtool_ops; |
1056 | dev->poll = cpmac_poll; | ||
1057 | dev->weight = 64; | ||
1058 | dev->features |= NETIF_F_MULTI_QUEUE; | 1055 | dev->features |= NETIF_F_MULTI_QUEUE; |
1059 | 1056 | ||
1057 | netif_napi_add(dev, &priv->napi, cpmac_poll, 64); | ||
1058 | |||
1060 | spin_lock_init(&priv->lock); | 1059 | spin_lock_init(&priv->lock); |
1061 | spin_lock_init(&priv->rx_lock); | 1060 | spin_lock_init(&priv->rx_lock); |
1062 | priv->dev = dev; | 1061 | priv->dev = dev; |
1063 | priv->ring_size = 64; | 1062 | priv->ring_size = 64; |
1064 | priv->msg_enable = netif_msg_init(debug_level, 0xff); | 1063 | priv->msg_enable = netif_msg_init(debug_level, 0xff); |
1065 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); | 1064 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); |
1065 | |||
1066 | if (phy_id == 31) { | 1066 | if (phy_id == 31) { |
1067 | snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, | 1067 | snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, cpmac_mii.id, |
1068 | cpmac_mii.id, phy_id); | 1068 | phy_id); |
1069 | } else | 1069 | } else { |
1070 | snprintf(priv->phy_name, BUS_ID_SIZE, "fixed@%d:%d", 100, 1); | 1070 | /* Let's try to get a free fixed phy... */ |
1071 | for (i = 0; i < MAX_PHY_AMNT; i++) { | ||
1072 | fixed_phy = fixed_mdio_get_phydev(i); | ||
1073 | if (!fixed_phy) | ||
1074 | continue; | ||
1075 | if (!fixed_phy->phydev->attached_dev) { | ||
1076 | strncpy(priv->phy_name, | ||
1077 | fixed_phy->phydev->dev.bus_id, | ||
1078 | BUS_ID_SIZE); | ||
1079 | fixed_mdio_set_link_update(fixed_phy->phydev, | ||
1080 | &cpmac_link_update); | ||
1081 | goto phy_found; | ||
1082 | } | ||
1083 | } | ||
1084 | if (netif_msg_drv(priv)) | ||
1085 | printk(KERN_ERR "%s: Could not find fixed PHY\n", | ||
1086 | dev->name); | ||
1087 | rc = -ENODEV; | ||
1088 | goto fail; | ||
1089 | } | ||
1090 | |||
1091 | phy_found: | ||
1092 | priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, | ||
1093 | PHY_INTERFACE_MODE_MII); | ||
1094 | if (IS_ERR(priv->phy)) { | ||
1095 | if (netif_msg_drv(priv)) | ||
1096 | printk(KERN_ERR "%s: Could not attach to PHY\n", | ||
1097 | dev->name); | ||
1098 | return PTR_ERR(priv->phy); | ||
1099 | } | ||
1071 | 1100 | ||
1072 | if ((rc = register_netdev(dev))) { | 1101 | if ((rc = register_netdev(dev))) { |
1073 | printk(KERN_ERR "cpmac: error %i registering device %s\n", rc, | 1102 | printk(KERN_ERR "cpmac: error %i registering device %s\n", rc, |
@@ -1077,9 +1106,9 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1077 | 1106 | ||
1078 | if (netif_msg_probe(priv)) { | 1107 | if (netif_msg_probe(priv)) { |
1079 | printk(KERN_INFO | 1108 | printk(KERN_INFO |
1080 | "cpmac: device %s (regs: %p, irq: %d, phy: %s, mac: " | 1109 | "cpmac: device %s (regs: %p, irq: %d, phy: %s, " |
1081 | MAC_FMT ")\n", dev->name, (void *)mem->start, dev->irq, | 1110 | "mac: %s)\n", dev->name, (void *)mem->start, dev->irq, |
1082 | priv->phy_name, MAC_ARG(dev->dev_addr)); | 1111 | priv->phy_name, print_mac(mac, dev->dev_addr)); |
1083 | } | 1112 | } |
1084 | return 0; | 1113 | return 0; |
1085 | 1114 | ||
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h index 781ed9968489..3b840283a9c3 100644 --- a/drivers/net/e1000/e1000.h +++ b/drivers/net/e1000/e1000.h | |||
@@ -351,4 +351,12 @@ enum e1000_state_t { | |||
351 | __E1000_DOWN | 351 | __E1000_DOWN |
352 | }; | 352 | }; |
353 | 353 | ||
354 | extern char e1000_driver_name[]; | ||
355 | extern const char e1000_driver_version[]; | ||
356 | |||
357 | extern void e1000_power_up_phy(struct e1000_adapter *); | ||
358 | extern void e1000_set_ethtool_ops(struct net_device *netdev); | ||
359 | extern void e1000_check_options(struct e1000_adapter *adapter); | ||
360 | |||
361 | |||
354 | #endif /* _E1000_H_ */ | 362 | #endif /* _E1000_H_ */ |
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index 6c9a643426f5..667f18bcc172 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c | |||
@@ -32,9 +32,6 @@ | |||
32 | 32 | ||
33 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
34 | 34 | ||
35 | extern char e1000_driver_name[]; | ||
36 | extern char e1000_driver_version[]; | ||
37 | |||
38 | extern int e1000_up(struct e1000_adapter *adapter); | 35 | extern int e1000_up(struct e1000_adapter *adapter); |
39 | extern void e1000_down(struct e1000_adapter *adapter); | 36 | extern void e1000_down(struct e1000_adapter *adapter); |
40 | extern void e1000_reinit_locked(struct e1000_adapter *adapter); | 37 | extern void e1000_reinit_locked(struct e1000_adapter *adapter); |
@@ -733,16 +730,16 @@ err_setup: | |||
733 | 730 | ||
734 | #define REG_PATTERN_TEST(R, M, W) \ | 731 | #define REG_PATTERN_TEST(R, M, W) \ |
735 | { \ | 732 | { \ |
736 | uint32_t pat, value; \ | 733 | uint32_t pat, val; \ |
737 | uint32_t test[] = \ | 734 | const uint32_t test[] = \ |
738 | {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \ | 735 | {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \ |
739 | for (pat = 0; pat < ARRAY_SIZE(test); pat++) { \ | 736 | for (pat = 0; pat < ARRAY_SIZE(test); pat++) { \ |
740 | E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \ | 737 | E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \ |
741 | value = E1000_READ_REG(&adapter->hw, R); \ | 738 | val = E1000_READ_REG(&adapter->hw, R); \ |
742 | if (value != (test[pat] & W & M)) { \ | 739 | if (val != (test[pat] & W & M)) { \ |
743 | DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \ | 740 | DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \ |
744 | "0x%08X expected 0x%08X\n", \ | 741 | "0x%08X expected 0x%08X\n", \ |
745 | E1000_##R, value, (test[pat] & W & M)); \ | 742 | E1000_##R, val, (test[pat] & W & M)); \ |
746 | *data = (adapter->hw.mac_type < e1000_82543) ? \ | 743 | *data = (adapter->hw.mac_type < e1000_82543) ? \ |
747 | E1000_82542_##R : E1000_##R; \ | 744 | E1000_82542_##R : E1000_##R; \ |
748 | return 1; \ | 745 | return 1; \ |
@@ -752,12 +749,12 @@ err_setup: | |||
752 | 749 | ||
753 | #define REG_SET_AND_CHECK(R, M, W) \ | 750 | #define REG_SET_AND_CHECK(R, M, W) \ |
754 | { \ | 751 | { \ |
755 | uint32_t value; \ | 752 | uint32_t val; \ |
756 | E1000_WRITE_REG(&adapter->hw, R, W & M); \ | 753 | E1000_WRITE_REG(&adapter->hw, R, W & M); \ |
757 | value = E1000_READ_REG(&adapter->hw, R); \ | 754 | val = E1000_READ_REG(&adapter->hw, R); \ |
758 | if ((W & M) != (value & M)) { \ | 755 | if ((W & M) != (val & M)) { \ |
759 | DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\ | 756 | DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\ |
760 | "expected 0x%08X\n", E1000_##R, (value & M), (W & M)); \ | 757 | "expected 0x%08X\n", E1000_##R, (val & M), (W & M)); \ |
761 | *data = (adapter->hw.mac_type < e1000_82543) ? \ | 758 | *data = (adapter->hw.mac_type < e1000_82543) ? \ |
762 | E1000_82542_##R : E1000_##R; \ | 759 | E1000_82542_##R : E1000_##R; \ |
763 | return 1; \ | 760 | return 1; \ |
@@ -1621,8 +1618,6 @@ e1000_get_sset_count(struct net_device *netdev, int sset) | |||
1621 | } | 1618 | } |
1622 | } | 1619 | } |
1623 | 1620 | ||
1624 | extern void e1000_power_up_phy(struct e1000_adapter *); | ||
1625 | |||
1626 | static void | 1621 | static void |
1627 | e1000_diag_test(struct net_device *netdev, | 1622 | e1000_diag_test(struct net_device *netdev, |
1628 | struct ethtool_test *eth_test, uint64_t *data) | 1623 | struct ethtool_test *eth_test, uint64_t *data) |
@@ -1859,8 +1854,8 @@ e1000_phys_id(struct net_device *netdev, uint32_t data) | |||
1859 | { | 1854 | { |
1860 | struct e1000_adapter *adapter = netdev_priv(netdev); | 1855 | struct e1000_adapter *adapter = netdev_priv(netdev); |
1861 | 1856 | ||
1862 | if (!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ)) | 1857 | if (!data) |
1863 | data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ); | 1858 | data = INT_MAX; |
1864 | 1859 | ||
1865 | if (adapter->hw.mac_type < e1000_82571) { | 1860 | if (adapter->hw.mac_type < e1000_82571) { |
1866 | if (!adapter->blink_timer.function) { | 1861 | if (!adapter->blink_timer.function) { |
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c index 8fa0fe4009d5..7c6888c58c21 100644 --- a/drivers/net/e1000/e1000_hw.c +++ b/drivers/net/e1000/e1000_hw.c | |||
@@ -8607,7 +8607,7 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index, | |||
8607 | 8607 | ||
8608 | DEBUGFUNC("e1000_read_ich8_data"); | 8608 | DEBUGFUNC("e1000_read_ich8_data"); |
8609 | 8609 | ||
8610 | if (size < 1 || size > 2 || data == 0x0 || | 8610 | if (size < 1 || size > 2 || data == NULL || |
8611 | index > ICH_FLASH_LINEAR_ADDR_MASK) | 8611 | index > ICH_FLASH_LINEAR_ADDR_MASK) |
8612 | return error; | 8612 | return error; |
8613 | 8613 | ||
@@ -8841,7 +8841,7 @@ e1000_read_ich8_word(struct e1000_hw *hw, uint32_t index, uint16_t *data) | |||
8841 | * amount of NVM used in each bank is a *minimum* of 4 KBytes, but in fact the | 8841 | * amount of NVM used in each bank is a *minimum* of 4 KBytes, but in fact the |
8842 | * bank size may be 4, 8 or 64 KBytes | 8842 | * bank size may be 4, 8 or 64 KBytes |
8843 | *****************************************************************************/ | 8843 | *****************************************************************************/ |
8844 | int32_t | 8844 | static int32_t |
8845 | e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank) | 8845 | e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank) |
8846 | { | 8846 | { |
8847 | union ich8_hws_flash_status hsfsts; | 8847 | union ich8_hws_flash_status hsfsts; |
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index f1ce348470cc..72deff0d4d90 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c | |||
@@ -37,8 +37,8 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; | |||
37 | #define DRIVERNAPI "-NAPI" | 37 | #define DRIVERNAPI "-NAPI" |
38 | #endif | 38 | #endif |
39 | #define DRV_VERSION "7.3.20-k2"DRIVERNAPI | 39 | #define DRV_VERSION "7.3.20-k2"DRIVERNAPI |
40 | char e1000_driver_version[] = DRV_VERSION; | 40 | const char e1000_driver_version[] = DRV_VERSION; |
41 | static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; | 41 | static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; |
42 | 42 | ||
43 | /* e1000_pci_tbl - PCI Device ID Table | 43 | /* e1000_pci_tbl - PCI Device ID Table |
44 | * | 44 | * |
@@ -188,7 +188,6 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, | |||
188 | static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); | 188 | static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); |
189 | static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, | 189 | static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, |
190 | int cmd); | 190 | int cmd); |
191 | void e1000_set_ethtool_ops(struct net_device *netdev); | ||
192 | static void e1000_enter_82542_rst(struct e1000_adapter *adapter); | 191 | static void e1000_enter_82542_rst(struct e1000_adapter *adapter); |
193 | static void e1000_leave_82542_rst(struct e1000_adapter *adapter); | 192 | static void e1000_leave_82542_rst(struct e1000_adapter *adapter); |
194 | static void e1000_tx_timeout(struct net_device *dev); | 193 | static void e1000_tx_timeout(struct net_device *dev); |
@@ -213,8 +212,6 @@ static void e1000_shutdown(struct pci_dev *pdev); | |||
213 | static void e1000_netpoll (struct net_device *netdev); | 212 | static void e1000_netpoll (struct net_device *netdev); |
214 | #endif | 213 | #endif |
215 | 214 | ||
216 | extern void e1000_check_options(struct e1000_adapter *adapter); | ||
217 | |||
218 | #define COPYBREAK_DEFAULT 256 | 215 | #define COPYBREAK_DEFAULT 256 |
219 | static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT; | 216 | static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT; |
220 | module_param(copybreak, uint, 0644); | 217 | module_param(copybreak, uint, 0644); |
diff --git a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c index f485874a63f5..e6565ce686bc 100644 --- a/drivers/net/e1000/e1000_param.c +++ b/drivers/net/e1000/e1000_param.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } | 46 | #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } |
47 | #define E1000_PARAM(X, desc) \ | 47 | #define E1000_PARAM(X, desc) \ |
48 | static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ | 48 | static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ |
49 | static int num_##X = 0; \ | 49 | static unsigned int num_##X; \ |
50 | module_param_array_named(X, X, int, &num_##X, 0); \ | 50 | module_param_array_named(X, X, int, &num_##X, 0); \ |
51 | MODULE_PARM_DESC(X, desc); | 51 | MODULE_PARM_DESC(X, desc); |
52 | 52 | ||
@@ -198,9 +198,9 @@ E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); | |||
198 | 198 | ||
199 | struct e1000_option { | 199 | struct e1000_option { |
200 | enum { enable_option, range_option, list_option } type; | 200 | enum { enable_option, range_option, list_option } type; |
201 | char *name; | 201 | const char *name; |
202 | char *err; | 202 | const char *err; |
203 | int def; | 203 | int def; |
204 | union { | 204 | union { |
205 | struct { /* range_option info */ | 205 | struct { /* range_option info */ |
206 | int min; | 206 | int min; |
@@ -214,8 +214,9 @@ struct e1000_option { | |||
214 | }; | 214 | }; |
215 | 215 | ||
216 | static int __devinit | 216 | static int __devinit |
217 | e1000_validate_option(int *value, struct e1000_option *opt, | 217 | e1000_validate_option(unsigned int *value, |
218 | struct e1000_adapter *adapter) | 218 | const struct e1000_option *opt, |
219 | struct e1000_adapter *adapter) | ||
219 | { | 220 | { |
220 | if (*value == OPTION_UNSET) { | 221 | if (*value == OPTION_UNSET) { |
221 | *value = opt->def; | 222 | *value = opt->def; |
@@ -348,7 +349,7 @@ e1000_check_options(struct e1000_adapter *adapter) | |||
348 | }; | 349 | }; |
349 | 350 | ||
350 | if (num_XsumRX > bd) { | 351 | if (num_XsumRX > bd) { |
351 | int rx_csum = XsumRX[bd]; | 352 | unsigned int rx_csum = XsumRX[bd]; |
352 | e1000_validate_option(&rx_csum, &opt, adapter); | 353 | e1000_validate_option(&rx_csum, &opt, adapter); |
353 | adapter->rx_csum = rx_csum; | 354 | adapter->rx_csum = rx_csum; |
354 | } else { | 355 | } else { |
@@ -374,7 +375,7 @@ e1000_check_options(struct e1000_adapter *adapter) | |||
374 | }; | 375 | }; |
375 | 376 | ||
376 | if (num_FlowControl > bd) { | 377 | if (num_FlowControl > bd) { |
377 | int fc = FlowControl[bd]; | 378 | unsigned int fc = FlowControl[bd]; |
378 | e1000_validate_option(&fc, &opt, adapter); | 379 | e1000_validate_option(&fc, &opt, adapter); |
379 | adapter->hw.fc = adapter->hw.original_fc = fc; | 380 | adapter->hw.fc = adapter->hw.original_fc = fc; |
380 | } else { | 381 | } else { |
@@ -506,7 +507,7 @@ e1000_check_options(struct e1000_adapter *adapter) | |||
506 | }; | 507 | }; |
507 | 508 | ||
508 | if (num_SmartPowerDownEnable > bd) { | 509 | if (num_SmartPowerDownEnable > bd) { |
509 | int spd = SmartPowerDownEnable[bd]; | 510 | unsigned int spd = SmartPowerDownEnable[bd]; |
510 | e1000_validate_option(&spd, &opt, adapter); | 511 | e1000_validate_option(&spd, &opt, adapter); |
511 | adapter->smart_power_down = spd; | 512 | adapter->smart_power_down = spd; |
512 | } else { | 513 | } else { |
@@ -522,7 +523,7 @@ e1000_check_options(struct e1000_adapter *adapter) | |||
522 | }; | 523 | }; |
523 | 524 | ||
524 | if (num_KumeranLockLoss > bd) { | 525 | if (num_KumeranLockLoss > bd) { |
525 | int kmrn_lock_loss = KumeranLockLoss[bd]; | 526 | unsigned int kmrn_lock_loss = KumeranLockLoss[bd]; |
526 | e1000_validate_option(&kmrn_lock_loss, &opt, adapter); | 527 | e1000_validate_option(&kmrn_lock_loss, &opt, adapter); |
527 | adapter->hw.kmrn_lock_loss_workaround_disabled = !kmrn_lock_loss; | 528 | adapter->hw.kmrn_lock_loss_workaround_disabled = !kmrn_lock_loss; |
528 | } else { | 529 | } else { |
@@ -581,7 +582,7 @@ e1000_check_fiber_options(struct e1000_adapter *adapter) | |||
581 | static void __devinit | 582 | static void __devinit |
582 | e1000_check_copper_options(struct e1000_adapter *adapter) | 583 | e1000_check_copper_options(struct e1000_adapter *adapter) |
583 | { | 584 | { |
584 | int speed, dplx, an; | 585 | unsigned int speed, dplx, an; |
585 | int bd = adapter->bd_number; | 586 | int bd = adapter->bd_number; |
586 | 587 | ||
587 | { /* Speed */ | 588 | { /* Speed */ |
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c index cf70522fc851..14141a55eaa6 100644 --- a/drivers/net/e1000e/82571.c +++ b/drivers/net/e1000e/82571.c | |||
@@ -283,7 +283,7 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter *adapter) | |||
283 | adapter->flags &= ~FLAG_HAS_WOL; | 283 | adapter->flags &= ~FLAG_HAS_WOL; |
284 | /* quad ports only support WoL on port A */ | 284 | /* quad ports only support WoL on port A */ |
285 | if (adapter->flags & FLAG_IS_QUAD_PORT && | 285 | if (adapter->flags & FLAG_IS_QUAD_PORT && |
286 | (!adapter->flags & FLAG_IS_QUAD_PORT_A)) | 286 | (!(adapter->flags & FLAG_IS_QUAD_PORT_A))) |
287 | adapter->flags &= ~FLAG_HAS_WOL; | 287 | adapter->flags &= ~FLAG_HAS_WOL; |
288 | break; | 288 | break; |
289 | 289 | ||
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h index d2499bb07c13..473f78de4be0 100644 --- a/drivers/net/e1000e/e1000.h +++ b/drivers/net/e1000e/e1000.h | |||
@@ -122,7 +122,8 @@ struct e1000_buffer { | |||
122 | u16 next_to_watch; | 122 | u16 next_to_watch; |
123 | }; | 123 | }; |
124 | /* RX */ | 124 | /* RX */ |
125 | struct page *page; | 125 | /* arrays of page information for packet split */ |
126 | struct e1000_ps_page *ps_pages; | ||
126 | }; | 127 | }; |
127 | 128 | ||
128 | }; | 129 | }; |
@@ -142,8 +143,6 @@ struct e1000_ring { | |||
142 | /* array of buffer information structs */ | 143 | /* array of buffer information structs */ |
143 | struct e1000_buffer *buffer_info; | 144 | struct e1000_buffer *buffer_info; |
144 | 145 | ||
145 | /* arrays of page information for packet split */ | ||
146 | struct e1000_ps_page *ps_pages; | ||
147 | struct sk_buff *rx_skb_top; | 146 | struct sk_buff *rx_skb_top; |
148 | 147 | ||
149 | struct e1000_queue_stats stats; | 148 | struct e1000_queue_stats stats; |
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c index 0666e62e9ad2..6a39784e7ee2 100644 --- a/drivers/net/e1000e/ethtool.c +++ b/drivers/net/e1000e/ethtool.c | |||
@@ -1680,8 +1680,8 @@ static int e1000_phys_id(struct net_device *netdev, u32 data) | |||
1680 | { | 1680 | { |
1681 | struct e1000_adapter *adapter = netdev_priv(netdev); | 1681 | struct e1000_adapter *adapter = netdev_priv(netdev); |
1682 | 1682 | ||
1683 | if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) | 1683 | if (!data) |
1684 | data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); | 1684 | data = INT_MAX; |
1685 | 1685 | ||
1686 | if (adapter->hw.phy.type == e1000_phy_ife) { | 1686 | if (adapter->hw.phy.type == e1000_phy_ife) { |
1687 | if (!adapter->blink_timer.function) { | 1687 | if (!adapter->blink_timer.function) { |
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 033e124d1c1f..4fd2e23720b6 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -245,37 +245,36 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, | |||
245 | rx_desc = E1000_RX_DESC_PS(*rx_ring, i); | 245 | rx_desc = E1000_RX_DESC_PS(*rx_ring, i); |
246 | 246 | ||
247 | for (j = 0; j < PS_PAGE_BUFFERS; j++) { | 247 | for (j = 0; j < PS_PAGE_BUFFERS; j++) { |
248 | ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) | 248 | ps_page = &buffer_info->ps_pages[j]; |
249 | + j]; | 249 | if (j >= adapter->rx_ps_pages) { |
250 | if (j < adapter->rx_ps_pages) { | 250 | /* all unused desc entries get hw null ptr */ |
251 | rx_desc->read.buffer_addr[j+1] = ~0; | ||
252 | continue; | ||
253 | } | ||
254 | if (!ps_page->page) { | ||
255 | ps_page->page = alloc_page(GFP_ATOMIC); | ||
251 | if (!ps_page->page) { | 256 | if (!ps_page->page) { |
252 | ps_page->page = alloc_page(GFP_ATOMIC); | 257 | adapter->alloc_rx_buff_failed++; |
253 | if (!ps_page->page) { | 258 | goto no_buffers; |
254 | adapter->alloc_rx_buff_failed++; | 259 | } |
255 | goto no_buffers; | 260 | ps_page->dma = pci_map_page(pdev, |
256 | } | 261 | ps_page->page, |
257 | ps_page->dma = pci_map_page(pdev, | 262 | 0, PAGE_SIZE, |
258 | ps_page->page, | 263 | PCI_DMA_FROMDEVICE); |
259 | 0, PAGE_SIZE, | 264 | if (pci_dma_mapping_error(ps_page->dma)) { |
260 | PCI_DMA_FROMDEVICE); | 265 | dev_err(&adapter->pdev->dev, |
261 | if (pci_dma_mapping_error( | 266 | "RX DMA page map failed\n"); |
262 | ps_page->dma)) { | 267 | adapter->rx_dma_failed++; |
263 | dev_err(&adapter->pdev->dev, | 268 | goto no_buffers; |
264 | "RX DMA page map failed\n"); | ||
265 | adapter->rx_dma_failed++; | ||
266 | goto no_buffers; | ||
267 | } | ||
268 | } | 269 | } |
269 | /* | ||
270 | * Refresh the desc even if buffer_addrs | ||
271 | * didn't change because each write-back | ||
272 | * erases this info. | ||
273 | */ | ||
274 | rx_desc->read.buffer_addr[j+1] = | ||
275 | cpu_to_le64(ps_page->dma); | ||
276 | } else { | ||
277 | rx_desc->read.buffer_addr[j+1] = ~0; | ||
278 | } | 270 | } |
271 | /* | ||
272 | * Refresh the desc even if buffer_addrs | ||
273 | * didn't change because each write-back | ||
274 | * erases this info. | ||
275 | */ | ||
276 | rx_desc->read.buffer_addr[j+1] = | ||
277 | cpu_to_le64(ps_page->dma); | ||
279 | } | 278 | } |
280 | 279 | ||
281 | skb = netdev_alloc_skb(netdev, | 280 | skb = netdev_alloc_skb(netdev, |
@@ -334,94 +333,6 @@ no_buffers: | |||
334 | } | 333 | } |
335 | 334 | ||
336 | /** | 335 | /** |
337 | * e1000_alloc_rx_buffers_jumbo - Replace used jumbo receive buffers | ||
338 | * | ||
339 | * @adapter: address of board private structure | ||
340 | * @cleaned_count: number of buffers to allocate this pass | ||
341 | **/ | ||
342 | static void e1000_alloc_rx_buffers_jumbo(struct e1000_adapter *adapter, | ||
343 | int cleaned_count) | ||
344 | { | ||
345 | struct net_device *netdev = adapter->netdev; | ||
346 | struct pci_dev *pdev = adapter->pdev; | ||
347 | struct e1000_ring *rx_ring = adapter->rx_ring; | ||
348 | struct e1000_rx_desc *rx_desc; | ||
349 | struct e1000_buffer *buffer_info; | ||
350 | struct sk_buff *skb; | ||
351 | unsigned int i; | ||
352 | unsigned int bufsz = 256 - | ||
353 | 16 /*for skb_reserve */ - | ||
354 | NET_IP_ALIGN; | ||
355 | |||
356 | i = rx_ring->next_to_use; | ||
357 | buffer_info = &rx_ring->buffer_info[i]; | ||
358 | |||
359 | while (cleaned_count--) { | ||
360 | skb = buffer_info->skb; | ||
361 | if (skb) { | ||
362 | skb_trim(skb, 0); | ||
363 | goto check_page; | ||
364 | } | ||
365 | |||
366 | skb = netdev_alloc_skb(netdev, bufsz); | ||
367 | if (!skb) { | ||
368 | /* Better luck next round */ | ||
369 | adapter->alloc_rx_buff_failed++; | ||
370 | break; | ||
371 | } | ||
372 | |||
373 | /* Make buffer alignment 2 beyond a 16 byte boundary | ||
374 | * this will result in a 16 byte aligned IP header after | ||
375 | * the 14 byte MAC header is removed | ||
376 | */ | ||
377 | skb_reserve(skb, NET_IP_ALIGN); | ||
378 | |||
379 | buffer_info->skb = skb; | ||
380 | check_page: | ||
381 | /* allocate a new page if necessary */ | ||
382 | if (!buffer_info->page) { | ||
383 | buffer_info->page = alloc_page(GFP_ATOMIC); | ||
384 | if (!buffer_info->page) { | ||
385 | adapter->alloc_rx_buff_failed++; | ||
386 | break; | ||
387 | } | ||
388 | } | ||
389 | |||
390 | if (!buffer_info->dma) | ||
391 | buffer_info->dma = pci_map_page(pdev, | ||
392 | buffer_info->page, 0, | ||
393 | PAGE_SIZE, | ||
394 | PCI_DMA_FROMDEVICE); | ||
395 | if (pci_dma_mapping_error(buffer_info->dma)) { | ||
396 | dev_err(&adapter->pdev->dev, "RX DMA page map failed\n"); | ||
397 | adapter->rx_dma_failed++; | ||
398 | break; | ||
399 | } | ||
400 | |||
401 | rx_desc = E1000_RX_DESC(*rx_ring, i); | ||
402 | rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); | ||
403 | |||
404 | i++; | ||
405 | if (i == rx_ring->count) | ||
406 | i = 0; | ||
407 | buffer_info = &rx_ring->buffer_info[i]; | ||
408 | } | ||
409 | |||
410 | if (rx_ring->next_to_use != i) { | ||
411 | rx_ring->next_to_use = i; | ||
412 | if (i-- == 0) | ||
413 | i = (rx_ring->count - 1); | ||
414 | |||
415 | /* Force memory writes to complete before letting h/w | ||
416 | * know there are new descriptors to fetch. (Only | ||
417 | * applicable for weak-ordered memory model archs, | ||
418 | * such as IA-64). */ | ||
419 | wmb(); | ||
420 | writel(i, adapter->hw.hw_addr + rx_ring->tail); | ||
421 | } | ||
422 | } | ||
423 | |||
424 | /** | ||
425 | * e1000_clean_rx_irq - Send received data up the network stack; legacy | 336 | * e1000_clean_rx_irq - Send received data up the network stack; legacy |
426 | * @adapter: board private structure | 337 | * @adapter: board private structure |
427 | * | 338 | * |
@@ -495,10 +406,6 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
495 | goto next_desc; | 406 | goto next_desc; |
496 | } | 407 | } |
497 | 408 | ||
498 | /* adjust length to remove Ethernet CRC */ | ||
499 | length -= 4; | ||
500 | |||
501 | /* probably a little skewed due to removing CRC */ | ||
502 | total_rx_bytes += length; | 409 | total_rx_bytes += length; |
503 | total_rx_packets++; | 410 | total_rx_packets++; |
504 | 411 | ||
@@ -554,15 +461,6 @@ next_desc: | |||
554 | return cleaned; | 461 | return cleaned; |
555 | } | 462 | } |
556 | 463 | ||
557 | static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb, | ||
558 | u16 length) | ||
559 | { | ||
560 | bi->page = NULL; | ||
561 | skb->len += length; | ||
562 | skb->data_len += length; | ||
563 | skb->truesize += length; | ||
564 | } | ||
565 | |||
566 | static void e1000_put_txbuf(struct e1000_adapter *adapter, | 464 | static void e1000_put_txbuf(struct e1000_adapter *adapter, |
567 | struct e1000_buffer *buffer_info) | 465 | struct e1000_buffer *buffer_info) |
568 | { | 466 | { |
@@ -699,174 +597,6 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) | |||
699 | } | 597 | } |
700 | 598 | ||
701 | /** | 599 | /** |
702 | * e1000_clean_rx_irq_jumbo - Send received data up the network stack; legacy | ||
703 | * @adapter: board private structure | ||
704 | * | ||
705 | * the return value indicates whether actual cleaning was done, there | ||
706 | * is no guarantee that everything was cleaned | ||
707 | **/ | ||
708 | static bool e1000_clean_rx_irq_jumbo(struct e1000_adapter *adapter, | ||
709 | int *work_done, int work_to_do) | ||
710 | { | ||
711 | struct net_device *netdev = adapter->netdev; | ||
712 | struct pci_dev *pdev = adapter->pdev; | ||
713 | struct e1000_ring *rx_ring = adapter->rx_ring; | ||
714 | struct e1000_rx_desc *rx_desc, *next_rxd; | ||
715 | struct e1000_buffer *buffer_info, *next_buffer; | ||
716 | u32 length; | ||
717 | unsigned int i; | ||
718 | int cleaned_count = 0; | ||
719 | bool cleaned = 0; | ||
720 | unsigned int total_rx_bytes = 0, total_rx_packets = 0; | ||
721 | |||
722 | i = rx_ring->next_to_clean; | ||
723 | rx_desc = E1000_RX_DESC(*rx_ring, i); | ||
724 | buffer_info = &rx_ring->buffer_info[i]; | ||
725 | |||
726 | while (rx_desc->status & E1000_RXD_STAT_DD) { | ||
727 | struct sk_buff *skb; | ||
728 | u8 status; | ||
729 | |||
730 | if (*work_done >= work_to_do) | ||
731 | break; | ||
732 | (*work_done)++; | ||
733 | |||
734 | status = rx_desc->status; | ||
735 | skb = buffer_info->skb; | ||
736 | buffer_info->skb = NULL; | ||
737 | |||
738 | i++; | ||
739 | if (i == rx_ring->count) | ||
740 | i = 0; | ||
741 | next_rxd = E1000_RX_DESC(*rx_ring, i); | ||
742 | prefetch(next_rxd); | ||
743 | |||
744 | next_buffer = &rx_ring->buffer_info[i]; | ||
745 | |||
746 | cleaned = 1; | ||
747 | cleaned_count++; | ||
748 | pci_unmap_page(pdev, | ||
749 | buffer_info->dma, | ||
750 | PAGE_SIZE, | ||
751 | PCI_DMA_FROMDEVICE); | ||
752 | buffer_info->dma = 0; | ||
753 | |||
754 | length = le16_to_cpu(rx_desc->length); | ||
755 | |||
756 | /* errors is only valid for DD + EOP descriptors */ | ||
757 | if ((status & E1000_RXD_STAT_EOP) && | ||
758 | (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) { | ||
759 | /* recycle both page and skb */ | ||
760 | buffer_info->skb = skb; | ||
761 | /* an error means any chain goes out the window too */ | ||
762 | if (rx_ring->rx_skb_top) | ||
763 | dev_kfree_skb(rx_ring->rx_skb_top); | ||
764 | rx_ring->rx_skb_top = NULL; | ||
765 | goto next_desc; | ||
766 | } | ||
767 | |||
768 | #define rxtop rx_ring->rx_skb_top | ||
769 | if (!(status & E1000_RXD_STAT_EOP)) { | ||
770 | /* this descriptor is only the beginning (or middle) */ | ||
771 | if (!rxtop) { | ||
772 | /* this is the beginning of a chain */ | ||
773 | rxtop = skb; | ||
774 | skb_fill_page_desc(rxtop, 0, buffer_info->page, | ||
775 | 0, length); | ||
776 | } else { | ||
777 | /* this is the middle of a chain */ | ||
778 | skb_fill_page_desc(rxtop, | ||
779 | skb_shinfo(rxtop)->nr_frags, | ||
780 | buffer_info->page, 0, | ||
781 | length); | ||
782 | /* re-use the skb, only consumed the page */ | ||
783 | buffer_info->skb = skb; | ||
784 | } | ||
785 | e1000_consume_page(buffer_info, rxtop, length); | ||
786 | goto next_desc; | ||
787 | } else { | ||
788 | if (rxtop) { | ||
789 | /* end of the chain */ | ||
790 | skb_fill_page_desc(rxtop, | ||
791 | skb_shinfo(rxtop)->nr_frags, | ||
792 | buffer_info->page, 0, length); | ||
793 | /* re-use the current skb, we only consumed the | ||
794 | * page */ | ||
795 | buffer_info->skb = skb; | ||
796 | skb = rxtop; | ||
797 | rxtop = NULL; | ||
798 | e1000_consume_page(buffer_info, skb, length); | ||
799 | } else { | ||
800 | /* no chain, got EOP, this buf is the packet | ||
801 | * copybreak to save the put_page/alloc_page */ | ||
802 | if (length <= copybreak && | ||
803 | skb_tailroom(skb) >= length) { | ||
804 | u8 *vaddr; | ||
805 | vaddr = kmap_atomic(buffer_info->page, | ||
806 | KM_SKB_DATA_SOFTIRQ); | ||
807 | memcpy(skb_tail_pointer(skb), | ||
808 | vaddr, length); | ||
809 | kunmap_atomic(vaddr, | ||
810 | KM_SKB_DATA_SOFTIRQ); | ||
811 | /* re-use the page, so don't erase | ||
812 | * buffer_info->page */ | ||
813 | skb_put(skb, length); | ||
814 | } else { | ||
815 | skb_fill_page_desc(skb, 0, | ||
816 | buffer_info->page, 0, | ||
817 | length); | ||
818 | e1000_consume_page(buffer_info, skb, | ||
819 | length); | ||
820 | } | ||
821 | } | ||
822 | } | ||
823 | |||
824 | /* Receive Checksum Offload XXX recompute due to CRC strip? */ | ||
825 | e1000_rx_checksum(adapter, | ||
826 | (u32)(status) | | ||
827 | ((u32)(rx_desc->errors) << 24), | ||
828 | le16_to_cpu(rx_desc->csum), skb); | ||
829 | |||
830 | pskb_trim(skb, skb->len - 4); | ||
831 | |||
832 | /* probably a little skewed due to removing CRC */ | ||
833 | total_rx_bytes += skb->len; | ||
834 | total_rx_packets++; | ||
835 | |||
836 | /* eth type trans needs skb->data to point to something */ | ||
837 | if (!pskb_may_pull(skb, ETH_HLEN)) { | ||
838 | ndev_err(netdev, "__pskb_pull_tail failed.\n"); | ||
839 | dev_kfree_skb(skb); | ||
840 | goto next_desc; | ||
841 | } | ||
842 | |||
843 | e1000_receive_skb(adapter, netdev, skb,status,rx_desc->special); | ||
844 | |||
845 | next_desc: | ||
846 | rx_desc->status = 0; | ||
847 | |||
848 | /* return some buffers to hardware, one at a time is too slow */ | ||
849 | if (cleaned_count >= E1000_RX_BUFFER_WRITE) { | ||
850 | adapter->alloc_rx_buf(adapter, cleaned_count); | ||
851 | cleaned_count = 0; | ||
852 | } | ||
853 | |||
854 | /* use prefetched values */ | ||
855 | rx_desc = next_rxd; | ||
856 | buffer_info = next_buffer; | ||
857 | } | ||
858 | rx_ring->next_to_clean = i; | ||
859 | |||
860 | cleaned_count = e1000_desc_unused(rx_ring); | ||
861 | if (cleaned_count) | ||
862 | adapter->alloc_rx_buf(adapter, cleaned_count); | ||
863 | |||
864 | adapter->total_rx_packets += total_rx_packets; | ||
865 | adapter->total_rx_bytes += total_rx_bytes; | ||
866 | return cleaned; | ||
867 | } | ||
868 | |||
869 | /** | ||
870 | * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split | 600 | * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split |
871 | * @adapter: board private structure | 601 | * @adapter: board private structure |
872 | * | 602 | * |
@@ -953,7 +683,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
953 | ((length + l1) <= adapter->rx_ps_bsize0)) { | 683 | ((length + l1) <= adapter->rx_ps_bsize0)) { |
954 | u8 *vaddr; | 684 | u8 *vaddr; |
955 | 685 | ||
956 | ps_page = &rx_ring->ps_pages[i * PS_PAGE_BUFFERS]; | 686 | ps_page = &buffer_info->ps_pages[0]; |
957 | 687 | ||
958 | /* there is no documentation about how to call | 688 | /* there is no documentation about how to call |
959 | * kmap_atomic, so we can't hold the mapping | 689 | * kmap_atomic, so we can't hold the mapping |
@@ -965,8 +695,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
965 | kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); | 695 | kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); |
966 | pci_dma_sync_single_for_device(pdev, ps_page->dma, | 696 | pci_dma_sync_single_for_device(pdev, ps_page->dma, |
967 | PAGE_SIZE, PCI_DMA_FROMDEVICE); | 697 | PAGE_SIZE, PCI_DMA_FROMDEVICE); |
968 | /* remove the CRC */ | 698 | |
969 | l1 -= 4; | ||
970 | skb_put(skb, l1); | 699 | skb_put(skb, l1); |
971 | goto copydone; | 700 | goto copydone; |
972 | } /* if */ | 701 | } /* if */ |
@@ -977,7 +706,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
977 | if (!length) | 706 | if (!length) |
978 | break; | 707 | break; |
979 | 708 | ||
980 | ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) + j]; | 709 | ps_page = &buffer_info->ps_pages[j]; |
981 | pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, | 710 | pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, |
982 | PCI_DMA_FROMDEVICE); | 711 | PCI_DMA_FROMDEVICE); |
983 | ps_page->dma = 0; | 712 | ps_page->dma = 0; |
@@ -988,10 +717,6 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
988 | skb->truesize += length; | 717 | skb->truesize += length; |
989 | } | 718 | } |
990 | 719 | ||
991 | /* strip the ethernet crc, problem is we're using pages now so | ||
992 | * this whole operation can get a little cpu intensive */ | ||
993 | pskb_trim(skb, skb->len - 4); | ||
994 | |||
995 | copydone: | 720 | copydone: |
996 | total_rx_bytes += skb->len; | 721 | total_rx_bytes += skb->len; |
997 | total_rx_packets++; | 722 | total_rx_packets++; |
@@ -1043,7 +768,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1043 | struct e1000_buffer *buffer_info; | 768 | struct e1000_buffer *buffer_info; |
1044 | struct e1000_ps_page *ps_page; | 769 | struct e1000_ps_page *ps_page; |
1045 | struct pci_dev *pdev = adapter->pdev; | 770 | struct pci_dev *pdev = adapter->pdev; |
1046 | unsigned long size; | ||
1047 | unsigned int i, j; | 771 | unsigned int i, j; |
1048 | 772 | ||
1049 | /* Free all the Rx ring sk_buffs */ | 773 | /* Free all the Rx ring sk_buffs */ |
@@ -1054,9 +778,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1054 | pci_unmap_single(pdev, buffer_info->dma, | 778 | pci_unmap_single(pdev, buffer_info->dma, |
1055 | adapter->rx_buffer_len, | 779 | adapter->rx_buffer_len, |
1056 | PCI_DMA_FROMDEVICE); | 780 | PCI_DMA_FROMDEVICE); |
1057 | else if (adapter->clean_rx == e1000_clean_rx_irq_jumbo) | ||
1058 | pci_unmap_page(pdev, buffer_info->dma, | ||
1059 | PAGE_SIZE, PCI_DMA_FROMDEVICE); | ||
1060 | else if (adapter->clean_rx == e1000_clean_rx_irq_ps) | 781 | else if (adapter->clean_rx == e1000_clean_rx_irq_ps) |
1061 | pci_unmap_single(pdev, buffer_info->dma, | 782 | pci_unmap_single(pdev, buffer_info->dma, |
1062 | adapter->rx_ps_bsize0, | 783 | adapter->rx_ps_bsize0, |
@@ -1064,19 +785,13 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1064 | buffer_info->dma = 0; | 785 | buffer_info->dma = 0; |
1065 | } | 786 | } |
1066 | 787 | ||
1067 | if (buffer_info->page) { | ||
1068 | put_page(buffer_info->page); | ||
1069 | buffer_info->page = NULL; | ||
1070 | } | ||
1071 | |||
1072 | if (buffer_info->skb) { | 788 | if (buffer_info->skb) { |
1073 | dev_kfree_skb(buffer_info->skb); | 789 | dev_kfree_skb(buffer_info->skb); |
1074 | buffer_info->skb = NULL; | 790 | buffer_info->skb = NULL; |
1075 | } | 791 | } |
1076 | 792 | ||
1077 | for (j = 0; j < PS_PAGE_BUFFERS; j++) { | 793 | for (j = 0; j < PS_PAGE_BUFFERS; j++) { |
1078 | ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) | 794 | ps_page = &buffer_info->ps_pages[j]; |
1079 | + j]; | ||
1080 | if (!ps_page->page) | 795 | if (!ps_page->page) |
1081 | break; | 796 | break; |
1082 | pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, | 797 | pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, |
@@ -1093,12 +808,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1093 | rx_ring->rx_skb_top = NULL; | 808 | rx_ring->rx_skb_top = NULL; |
1094 | } | 809 | } |
1095 | 810 | ||
1096 | size = sizeof(struct e1000_buffer) * rx_ring->count; | ||
1097 | memset(rx_ring->buffer_info, 0, size); | ||
1098 | size = sizeof(struct e1000_ps_page) | ||
1099 | * (rx_ring->count * PS_PAGE_BUFFERS); | ||
1100 | memset(rx_ring->ps_pages, 0, size); | ||
1101 | |||
1102 | /* Zero out the descriptor ring */ | 811 | /* Zero out the descriptor ring */ |
1103 | memset(rx_ring->desc, 0, rx_ring->size); | 812 | memset(rx_ring->desc, 0, rx_ring->size); |
1104 | 813 | ||
@@ -1421,7 +1130,8 @@ err: | |||
1421 | int e1000e_setup_rx_resources(struct e1000_adapter *adapter) | 1130 | int e1000e_setup_rx_resources(struct e1000_adapter *adapter) |
1422 | { | 1131 | { |
1423 | struct e1000_ring *rx_ring = adapter->rx_ring; | 1132 | struct e1000_ring *rx_ring = adapter->rx_ring; |
1424 | int size, desc_len, err = -ENOMEM; | 1133 | struct e1000_buffer *buffer_info; |
1134 | int i, size, desc_len, err = -ENOMEM; | ||
1425 | 1135 | ||
1426 | size = sizeof(struct e1000_buffer) * rx_ring->count; | 1136 | size = sizeof(struct e1000_buffer) * rx_ring->count; |
1427 | rx_ring->buffer_info = vmalloc(size); | 1137 | rx_ring->buffer_info = vmalloc(size); |
@@ -1429,11 +1139,14 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter) | |||
1429 | goto err; | 1139 | goto err; |
1430 | memset(rx_ring->buffer_info, 0, size); | 1140 | memset(rx_ring->buffer_info, 0, size); |
1431 | 1141 | ||
1432 | rx_ring->ps_pages = kcalloc(rx_ring->count * PS_PAGE_BUFFERS, | 1142 | for (i = 0; i < rx_ring->count; i++) { |
1433 | sizeof(struct e1000_ps_page), | 1143 | buffer_info = &rx_ring->buffer_info[i]; |
1434 | GFP_KERNEL); | 1144 | buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS, |
1435 | if (!rx_ring->ps_pages) | 1145 | sizeof(struct e1000_ps_page), |
1436 | goto err; | 1146 | GFP_KERNEL); |
1147 | if (!buffer_info->ps_pages) | ||
1148 | goto err_pages; | ||
1149 | } | ||
1437 | 1150 | ||
1438 | desc_len = sizeof(union e1000_rx_desc_packet_split); | 1151 | desc_len = sizeof(union e1000_rx_desc_packet_split); |
1439 | 1152 | ||
@@ -1443,16 +1156,21 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter) | |||
1443 | 1156 | ||
1444 | err = e1000_alloc_ring_dma(adapter, rx_ring); | 1157 | err = e1000_alloc_ring_dma(adapter, rx_ring); |
1445 | if (err) | 1158 | if (err) |
1446 | goto err; | 1159 | goto err_pages; |
1447 | 1160 | ||
1448 | rx_ring->next_to_clean = 0; | 1161 | rx_ring->next_to_clean = 0; |
1449 | rx_ring->next_to_use = 0; | 1162 | rx_ring->next_to_use = 0; |
1450 | rx_ring->rx_skb_top = NULL; | 1163 | rx_ring->rx_skb_top = NULL; |
1451 | 1164 | ||
1452 | return 0; | 1165 | return 0; |
1166 | |||
1167 | err_pages: | ||
1168 | for (i = 0; i < rx_ring->count; i++) { | ||
1169 | buffer_info = &rx_ring->buffer_info[i]; | ||
1170 | kfree(buffer_info->ps_pages); | ||
1171 | } | ||
1453 | err: | 1172 | err: |
1454 | vfree(rx_ring->buffer_info); | 1173 | vfree(rx_ring->buffer_info); |
1455 | kfree(rx_ring->ps_pages); | ||
1456 | ndev_err(adapter->netdev, | 1174 | ndev_err(adapter->netdev, |
1457 | "Unable to allocate memory for the transmit descriptor ring\n"); | 1175 | "Unable to allocate memory for the transmit descriptor ring\n"); |
1458 | return err; | 1176 | return err; |
@@ -1518,15 +1236,17 @@ void e1000e_free_rx_resources(struct e1000_adapter *adapter) | |||
1518 | { | 1236 | { |
1519 | struct pci_dev *pdev = adapter->pdev; | 1237 | struct pci_dev *pdev = adapter->pdev; |
1520 | struct e1000_ring *rx_ring = adapter->rx_ring; | 1238 | struct e1000_ring *rx_ring = adapter->rx_ring; |
1239 | int i; | ||
1521 | 1240 | ||
1522 | e1000_clean_rx_ring(adapter); | 1241 | e1000_clean_rx_ring(adapter); |
1523 | 1242 | ||
1243 | for (i = 0; i < rx_ring->count; i++) { | ||
1244 | kfree(rx_ring->buffer_info[i].ps_pages); | ||
1245 | } | ||
1246 | |||
1524 | vfree(rx_ring->buffer_info); | 1247 | vfree(rx_ring->buffer_info); |
1525 | rx_ring->buffer_info = NULL; | 1248 | rx_ring->buffer_info = NULL; |
1526 | 1249 | ||
1527 | kfree(rx_ring->ps_pages); | ||
1528 | rx_ring->ps_pages = NULL; | ||
1529 | |||
1530 | dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, | 1250 | dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, |
1531 | rx_ring->dma); | 1251 | rx_ring->dma); |
1532 | rx_ring->desc = NULL; | 1252 | rx_ring->desc = NULL; |
@@ -2032,9 +1752,11 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) | |||
2032 | 1752 | ||
2033 | ew32(RFCTL, rfctl); | 1753 | ew32(RFCTL, rfctl); |
2034 | 1754 | ||
2035 | /* disable the stripping of CRC because it breaks | 1755 | /* Enable Packet split descriptors */ |
2036 | * BMC firmware connected over SMBUS */ | 1756 | rctl |= E1000_RCTL_DTYP_PS; |
2037 | rctl |= E1000_RCTL_DTYP_PS /* | E1000_RCTL_SECRC */; | 1757 | |
1758 | /* Enable hardware CRC frame stripping */ | ||
1759 | rctl |= E1000_RCTL_SECRC; | ||
2038 | 1760 | ||
2039 | psrctl |= adapter->rx_ps_bsize0 >> | 1761 | psrctl |= adapter->rx_ps_bsize0 >> |
2040 | E1000_PSRCTL_BSIZE0_SHIFT; | 1762 | E1000_PSRCTL_BSIZE0_SHIFT; |
@@ -2077,11 +1799,6 @@ static void e1000_configure_rx(struct e1000_adapter *adapter) | |||
2077 | sizeof(union e1000_rx_desc_packet_split); | 1799 | sizeof(union e1000_rx_desc_packet_split); |
2078 | adapter->clean_rx = e1000_clean_rx_irq_ps; | 1800 | adapter->clean_rx = e1000_clean_rx_irq_ps; |
2079 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; | 1801 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; |
2080 | } else if (adapter->netdev->mtu > ETH_FRAME_LEN + VLAN_HLEN + 4) { | ||
2081 | rdlen = rx_ring->count * | ||
2082 | sizeof(struct e1000_rx_desc); | ||
2083 | adapter->clean_rx = e1000_clean_rx_irq_jumbo; | ||
2084 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers_jumbo; | ||
2085 | } else { | 1802 | } else { |
2086 | rdlen = rx_ring->count * | 1803 | rdlen = rx_ring->count * |
2087 | sizeof(struct e1000_rx_desc); | 1804 | sizeof(struct e1000_rx_desc); |
@@ -2326,8 +2043,11 @@ void e1000e_reset(struct e1000_adapter *adapter) | |||
2326 | struct e1000_mac_info *mac = &adapter->hw.mac; | 2043 | struct e1000_mac_info *mac = &adapter->hw.mac; |
2327 | struct e1000_hw *hw = &adapter->hw; | 2044 | struct e1000_hw *hw = &adapter->hw; |
2328 | u32 tx_space, min_tx_space, min_rx_space; | 2045 | u32 tx_space, min_tx_space, min_rx_space; |
2046 | u32 pba; | ||
2329 | u16 hwm; | 2047 | u16 hwm; |
2330 | 2048 | ||
2049 | ew32(PBA, adapter->pba); | ||
2050 | |||
2331 | if (mac->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN ) { | 2051 | if (mac->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN ) { |
2332 | /* To maintain wire speed transmits, the Tx FIFO should be | 2052 | /* To maintain wire speed transmits, the Tx FIFO should be |
2333 | * large enough to accommodate two full transmit packets, | 2053 | * large enough to accommodate two full transmit packets, |
@@ -2335,11 +2055,11 @@ void e1000e_reset(struct e1000_adapter *adapter) | |||
2335 | * the Rx FIFO should be large enough to accommodate at least | 2055 | * the Rx FIFO should be large enough to accommodate at least |
2336 | * one full receive packet and is similarly rounded up and | 2056 | * one full receive packet and is similarly rounded up and |
2337 | * expressed in KB. */ | 2057 | * expressed in KB. */ |
2338 | adapter->pba = er32(PBA); | 2058 | pba = er32(PBA); |
2339 | /* upper 16 bits has Tx packet buffer allocation size in KB */ | 2059 | /* upper 16 bits has Tx packet buffer allocation size in KB */ |
2340 | tx_space = adapter->pba >> 16; | 2060 | tx_space = pba >> 16; |
2341 | /* lower 16 bits has Rx packet buffer allocation size in KB */ | 2061 | /* lower 16 bits has Rx packet buffer allocation size in KB */ |
2342 | adapter->pba &= 0xffff; | 2062 | pba &= 0xffff; |
2343 | /* the tx fifo also stores 16 bytes of information about the tx | 2063 | /* the tx fifo also stores 16 bytes of information about the tx |
2344 | * but don't include ethernet FCS because hardware appends it */ | 2064 | * but don't include ethernet FCS because hardware appends it */ |
2345 | min_tx_space = (mac->max_frame_size + | 2065 | min_tx_space = (mac->max_frame_size + |
@@ -2355,20 +2075,21 @@ void e1000e_reset(struct e1000_adapter *adapter) | |||
2355 | /* If current Tx allocation is less than the min Tx FIFO size, | 2075 | /* If current Tx allocation is less than the min Tx FIFO size, |
2356 | * and the min Tx FIFO size is less than the current Rx FIFO | 2076 | * and the min Tx FIFO size is less than the current Rx FIFO |
2357 | * allocation, take space away from current Rx allocation */ | 2077 | * allocation, take space away from current Rx allocation */ |
2358 | if (tx_space < min_tx_space && | 2078 | if ((tx_space < min_tx_space) && |
2359 | ((min_tx_space - tx_space) < adapter->pba)) { | 2079 | ((min_tx_space - tx_space) < pba)) { |
2360 | adapter->pba -= - (min_tx_space - tx_space); | 2080 | pba -= min_tx_space - tx_space; |
2361 | 2081 | ||
2362 | /* if short on rx space, rx wins and must trump tx | 2082 | /* if short on rx space, rx wins and must trump tx |
2363 | * adjustment or use Early Receive if available */ | 2083 | * adjustment or use Early Receive if available */ |
2364 | if ((adapter->pba < min_rx_space) && | 2084 | if ((pba < min_rx_space) && |
2365 | (!(adapter->flags & FLAG_HAS_ERT))) | 2085 | (!(adapter->flags & FLAG_HAS_ERT))) |
2366 | /* ERT enabled in e1000_configure_rx */ | 2086 | /* ERT enabled in e1000_configure_rx */ |
2367 | adapter->pba = min_rx_space; | 2087 | pba = min_rx_space; |
2368 | } | 2088 | } |
2089 | |||
2090 | ew32(PBA, pba); | ||
2369 | } | 2091 | } |
2370 | 2092 | ||
2371 | ew32(PBA, adapter->pba); | ||
2372 | 2093 | ||
2373 | /* flow control settings */ | 2094 | /* flow control settings */ |
2374 | /* The high water mark must be low enough to fit one full frame | 2095 | /* The high water mark must be low enough to fit one full frame |
@@ -3624,9 +3345,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
3624 | /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN | 3345 | /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN |
3625 | * means we reserve 2 more, this pushes us to allocate from the next | 3346 | * means we reserve 2 more, this pushes us to allocate from the next |
3626 | * larger slab size. | 3347 | * larger slab size. |
3627 | * i.e. RXBUFFER_2048 --> size-4096 slab | 3348 | * i.e. RXBUFFER_2048 --> size-4096 slab */ |
3628 | * however with the new *_jumbo* routines, jumbo receives will use | ||
3629 | * fragmented skbs */ | ||
3630 | 3349 | ||
3631 | if (max_frame <= 256) | 3350 | if (max_frame <= 256) |
3632 | adapter->rx_buffer_len = 256; | 3351 | adapter->rx_buffer_len = 256; |
diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c index e4e655efb23c..332789238b9c 100644 --- a/drivers/net/e1000e/param.c +++ b/drivers/net/e1000e/param.c | |||
@@ -52,10 +52,11 @@ MODULE_PARM_DESC(copybreak, | |||
52 | */ | 52 | */ |
53 | 53 | ||
54 | #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } | 54 | #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } |
55 | #define E1000_PARAM(X, desc) \ | 55 | #define E1000_PARAM(X, desc) \ |
56 | static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ | 56 | static int __devinitdata X[E1000_MAX_NIC+1] \ |
57 | static int num_##X; \ | 57 | = E1000_PARAM_INIT; \ |
58 | module_param_array_named(X, X, int, &num_##X, 0); \ | 58 | static unsigned int num_##X; \ |
59 | module_param_array_named(X, X, int, &num_##X, 0); \ | ||
59 | MODULE_PARM_DESC(X, desc); | 60 | MODULE_PARM_DESC(X, desc); |
60 | 61 | ||
61 | 62 | ||
@@ -124,9 +125,9 @@ E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); | |||
124 | 125 | ||
125 | struct e1000_option { | 126 | struct e1000_option { |
126 | enum { enable_option, range_option, list_option } type; | 127 | enum { enable_option, range_option, list_option } type; |
127 | char *name; | 128 | const char *name; |
128 | char *err; | 129 | const char *err; |
129 | int def; | 130 | int def; |
130 | union { | 131 | union { |
131 | struct { /* range_option info */ | 132 | struct { /* range_option info */ |
132 | int min; | 133 | int min; |
@@ -139,8 +140,8 @@ struct e1000_option { | |||
139 | } arg; | 140 | } arg; |
140 | }; | 141 | }; |
141 | 142 | ||
142 | static int __devinit e1000_validate_option(int *value, | 143 | static int __devinit e1000_validate_option(unsigned int *value, |
143 | struct e1000_option *opt, | 144 | const struct e1000_option *opt, |
144 | struct e1000_adapter *adapter) | 145 | struct e1000_adapter *adapter) |
145 | { | 146 | { |
146 | if (*value == OPTION_UNSET) { | 147 | if (*value == OPTION_UNSET) { |
@@ -213,7 +214,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |||
213 | } | 214 | } |
214 | 215 | ||
215 | { /* Transmit Interrupt Delay */ | 216 | { /* Transmit Interrupt Delay */ |
216 | struct e1000_option opt = { | 217 | const struct e1000_option opt = { |
217 | .type = range_option, | 218 | .type = range_option, |
218 | .name = "Transmit Interrupt Delay", | 219 | .name = "Transmit Interrupt Delay", |
219 | .err = "using default of " | 220 | .err = "using default of " |
@@ -232,7 +233,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |||
232 | } | 233 | } |
233 | } | 234 | } |
234 | { /* Transmit Absolute Interrupt Delay */ | 235 | { /* Transmit Absolute Interrupt Delay */ |
235 | struct e1000_option opt = { | 236 | const struct e1000_option opt = { |
236 | .type = range_option, | 237 | .type = range_option, |
237 | .name = "Transmit Absolute Interrupt Delay", | 238 | .name = "Transmit Absolute Interrupt Delay", |
238 | .err = "using default of " | 239 | .err = "using default of " |
@@ -277,7 +278,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |||
277 | } | 278 | } |
278 | } | 279 | } |
279 | { /* Receive Absolute Interrupt Delay */ | 280 | { /* Receive Absolute Interrupt Delay */ |
280 | struct e1000_option opt = { | 281 | const struct e1000_option opt = { |
281 | .type = range_option, | 282 | .type = range_option, |
282 | .name = "Receive Absolute Interrupt Delay", | 283 | .name = "Receive Absolute Interrupt Delay", |
283 | .err = "using default of " | 284 | .err = "using default of " |
@@ -296,7 +297,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |||
296 | } | 297 | } |
297 | } | 298 | } |
298 | { /* Interrupt Throttling Rate */ | 299 | { /* Interrupt Throttling Rate */ |
299 | struct e1000_option opt = { | 300 | const struct e1000_option opt = { |
300 | .type = range_option, | 301 | .type = range_option, |
301 | .name = "Interrupt Throttling Rate (ints/sec)", | 302 | .name = "Interrupt Throttling Rate (ints/sec)", |
302 | .err = "using default of " | 303 | .err = "using default of " |
@@ -344,7 +345,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |||
344 | } | 345 | } |
345 | } | 346 | } |
346 | { /* Smart Power Down */ | 347 | { /* Smart Power Down */ |
347 | struct e1000_option opt = { | 348 | const struct e1000_option opt = { |
348 | .type = enable_option, | 349 | .type = enable_option, |
349 | .name = "PHY Smart Power Down", | 350 | .name = "PHY Smart Power Down", |
350 | .err = "defaulting to Disabled", | 351 | .err = "defaulting to Disabled", |
@@ -352,7 +353,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |||
352 | }; | 353 | }; |
353 | 354 | ||
354 | if (num_SmartPowerDownEnable > bd) { | 355 | if (num_SmartPowerDownEnable > bd) { |
355 | int spd = SmartPowerDownEnable[bd]; | 356 | unsigned int spd = SmartPowerDownEnable[bd]; |
356 | e1000_validate_option(&spd, &opt, adapter); | 357 | e1000_validate_option(&spd, &opt, adapter); |
357 | if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) | 358 | if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) |
358 | && spd) | 359 | && spd) |
@@ -360,7 +361,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |||
360 | } | 361 | } |
361 | } | 362 | } |
362 | { /* Kumeran Lock Loss Workaround */ | 363 | { /* Kumeran Lock Loss Workaround */ |
363 | struct e1000_option opt = { | 364 | const struct e1000_option opt = { |
364 | .type = enable_option, | 365 | .type = enable_option, |
365 | .name = "Kumeran Lock Loss Workaround", | 366 | .name = "Kumeran Lock Loss Workaround", |
366 | .err = "defaulting to Enabled", | 367 | .err = "defaulting to Enabled", |
@@ -368,7 +369,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |||
368 | }; | 369 | }; |
369 | 370 | ||
370 | if (num_KumeranLockLoss > bd) { | 371 | if (num_KumeranLockLoss > bd) { |
371 | int kmrn_lock_loss = KumeranLockLoss[bd]; | 372 | unsigned int kmrn_lock_loss = KumeranLockLoss[bd]; |
372 | e1000_validate_option(&kmrn_lock_loss, &opt, adapter); | 373 | e1000_validate_option(&kmrn_lock_loss, &opt, adapter); |
373 | if (hw->mac.type == e1000_ich8lan) | 374 | if (hw->mac.type == e1000_ich8lan) |
374 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, | 375 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, |
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h index b557bb44a36f..f78e5bf7cb33 100644 --- a/drivers/net/ehea/ehea.h +++ b/drivers/net/ehea/ehea.h | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | 41 | ||
42 | #define DRV_NAME "ehea" | 42 | #define DRV_NAME "ehea" |
43 | #define DRV_VERSION "EHEA_0078" | 43 | #define DRV_VERSION "EHEA_0080" |
44 | 44 | ||
45 | /* eHEA capability flags */ | 45 | /* eHEA capability flags */ |
46 | #define DLPAR_PORT_ADD_REM 1 | 46 | #define DLPAR_PORT_ADD_REM 1 |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index 2809c99906e0..f0319f1e8e05 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -33,6 +33,9 @@ | |||
33 | #include <linux/if.h> | 33 | #include <linux/if.h> |
34 | #include <linux/list.h> | 34 | #include <linux/list.h> |
35 | #include <linux/if_ether.h> | 35 | #include <linux/if_ether.h> |
36 | #include <linux/notifier.h> | ||
37 | #include <linux/reboot.h> | ||
38 | |||
36 | #include <net/ip.h> | 39 | #include <net/ip.h> |
37 | 40 | ||
38 | #include "ehea.h" | 41 | #include "ehea.h" |
@@ -2329,7 +2332,7 @@ static void port_napi_disable(struct ehea_port *port) | |||
2329 | { | 2332 | { |
2330 | int i; | 2333 | int i; |
2331 | 2334 | ||
2332 | for (i = 0; i < port->num_def_qps; i++) | 2335 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) |
2333 | napi_disable(&port->port_res[i].napi); | 2336 | napi_disable(&port->port_res[i].napi); |
2334 | } | 2337 | } |
2335 | 2338 | ||
@@ -2337,7 +2340,7 @@ static void port_napi_enable(struct ehea_port *port) | |||
2337 | { | 2340 | { |
2338 | int i; | 2341 | int i; |
2339 | 2342 | ||
2340 | for (i = 0; i < port->num_def_qps; i++) | 2343 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) |
2341 | napi_enable(&port->port_res[i].napi); | 2344 | napi_enable(&port->port_res[i].napi); |
2342 | } | 2345 | } |
2343 | 2346 | ||
@@ -2373,8 +2376,6 @@ static int ehea_down(struct net_device *dev) | |||
2373 | ehea_drop_multicast_list(dev); | 2376 | ehea_drop_multicast_list(dev); |
2374 | ehea_free_interrupts(dev); | 2377 | ehea_free_interrupts(dev); |
2375 | 2378 | ||
2376 | port_napi_disable(port); | ||
2377 | |||
2378 | port->state = EHEA_PORT_DOWN; | 2379 | port->state = EHEA_PORT_DOWN; |
2379 | 2380 | ||
2380 | ret = ehea_clean_all_portres(port); | 2381 | ret = ehea_clean_all_portres(port); |
@@ -2396,6 +2397,7 @@ static int ehea_stop(struct net_device *dev) | |||
2396 | flush_scheduled_work(); | 2397 | flush_scheduled_work(); |
2397 | down(&port->port_lock); | 2398 | down(&port->port_lock); |
2398 | netif_stop_queue(dev); | 2399 | netif_stop_queue(dev); |
2400 | port_napi_disable(port); | ||
2399 | ret = ehea_down(dev); | 2401 | ret = ehea_down(dev); |
2400 | up(&port->port_lock); | 2402 | up(&port->port_lock); |
2401 | return ret; | 2403 | return ret; |
@@ -3296,6 +3298,20 @@ static int __devexit ehea_remove(struct of_device *dev) | |||
3296 | return 0; | 3298 | return 0; |
3297 | } | 3299 | } |
3298 | 3300 | ||
3301 | static int ehea_reboot_notifier(struct notifier_block *nb, | ||
3302 | unsigned long action, void *unused) | ||
3303 | { | ||
3304 | if (action == SYS_RESTART) { | ||
3305 | ehea_info("Reboot: freeing all eHEA resources"); | ||
3306 | ibmebus_unregister_driver(&ehea_driver); | ||
3307 | } | ||
3308 | return NOTIFY_DONE; | ||
3309 | } | ||
3310 | |||
3311 | static struct notifier_block ehea_reboot_nb = { | ||
3312 | .notifier_call = ehea_reboot_notifier, | ||
3313 | }; | ||
3314 | |||
3299 | static int check_module_parm(void) | 3315 | static int check_module_parm(void) |
3300 | { | 3316 | { |
3301 | int ret = 0; | 3317 | int ret = 0; |
@@ -3352,6 +3368,8 @@ int __init ehea_module_init(void) | |||
3352 | if (ret) | 3368 | if (ret) |
3353 | goto out; | 3369 | goto out; |
3354 | 3370 | ||
3371 | register_reboot_notifier(&ehea_reboot_nb); | ||
3372 | |||
3355 | ret = ibmebus_register_driver(&ehea_driver); | 3373 | ret = ibmebus_register_driver(&ehea_driver); |
3356 | if (ret) { | 3374 | if (ret) { |
3357 | ehea_error("failed registering eHEA device driver on ebus"); | 3375 | ehea_error("failed registering eHEA device driver on ebus"); |
@@ -3363,6 +3381,7 @@ int __init ehea_module_init(void) | |||
3363 | if (ret) { | 3381 | if (ret) { |
3364 | ehea_error("failed to register capabilities attribute, ret=%d", | 3382 | ehea_error("failed to register capabilities attribute, ret=%d", |
3365 | ret); | 3383 | ret); |
3384 | unregister_reboot_notifier(&ehea_reboot_nb); | ||
3366 | ibmebus_unregister_driver(&ehea_driver); | 3385 | ibmebus_unregister_driver(&ehea_driver); |
3367 | goto out; | 3386 | goto out; |
3368 | } | 3387 | } |
@@ -3376,6 +3395,7 @@ static void __exit ehea_module_exit(void) | |||
3376 | flush_scheduled_work(); | 3395 | flush_scheduled_work(); |
3377 | driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities); | 3396 | driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities); |
3378 | ibmebus_unregister_driver(&ehea_driver); | 3397 | ibmebus_unregister_driver(&ehea_driver); |
3398 | unregister_reboot_notifier(&ehea_reboot_nb); | ||
3379 | ehea_destroy_busmap(); | 3399 | ehea_destroy_busmap(); |
3380 | } | 3400 | } |
3381 | 3401 | ||
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c new file mode 100644 index 000000000000..a8a0ee220da6 --- /dev/null +++ b/drivers/net/fec_mpc52xx.c | |||
@@ -0,0 +1,1112 @@ | |||
1 | /* | ||
2 | * Driver for the MPC5200 Fast Ethernet Controller | ||
3 | * | ||
4 | * Originally written by Dale Farnsworth <dfarnsworth@mvista.com> and | ||
5 | * now maintained by Sylvain Munaut <tnt@246tNt.com> | ||
6 | * | ||
7 | * Copyright (C) 2007 Domen Puncer, Telargo, Inc. | ||
8 | * Copyright (C) 2007 Sylvain Munaut <tnt@246tNt.com> | ||
9 | * Copyright (C) 2003-2004 MontaVista, Software, Inc. | ||
10 | * | ||
11 | * This file is licensed under the terms of the GNU General Public License | ||
12 | * version 2. This program is licensed "as is" without any warranty of any | ||
13 | * kind, whether express or implied. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/types.h> | ||
21 | #include <linux/spinlock.h> | ||
22 | #include <linux/errno.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/crc32.h> | ||
25 | #include <linux/hardirq.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/of_device.h> | ||
28 | #include <linux/of_platform.h> | ||
29 | |||
30 | #include <linux/netdevice.h> | ||
31 | #include <linux/etherdevice.h> | ||
32 | #include <linux/ethtool.h> | ||
33 | #include <linux/skbuff.h> | ||
34 | |||
35 | #include <asm/io.h> | ||
36 | #include <asm/delay.h> | ||
37 | #include <asm/mpc52xx.h> | ||
38 | |||
39 | #include <sysdev/bestcomm/bestcomm.h> | ||
40 | #include <sysdev/bestcomm/fec.h> | ||
41 | |||
42 | #include "fec_mpc52xx.h" | ||
43 | |||
44 | #define DRIVER_NAME "mpc52xx-fec" | ||
45 | |||
46 | static irqreturn_t mpc52xx_fec_interrupt(int, void *); | ||
47 | static irqreturn_t mpc52xx_fec_rx_interrupt(int, void *); | ||
48 | static irqreturn_t mpc52xx_fec_tx_interrupt(int, void *); | ||
49 | static void mpc52xx_fec_stop(struct net_device *dev); | ||
50 | static void mpc52xx_fec_start(struct net_device *dev); | ||
51 | static void mpc52xx_fec_reset(struct net_device *dev); | ||
52 | |||
53 | static u8 mpc52xx_fec_mac_addr[6]; | ||
54 | module_param_array_named(mac, mpc52xx_fec_mac_addr, byte, NULL, 0); | ||
55 | MODULE_PARM_DESC(mac, "six hex digits, ie. 0x1,0x2,0xc0,0x01,0xba,0xbe"); | ||
56 | |||
57 | #define MPC52xx_MESSAGES_DEFAULT ( NETIF_MSG_DRV | NETIF_MSG_PROBE | \ | ||
58 | NETIF_MSG_LINK | NETIF_MSG_IFDOWN | NETIF_MSG_IFDOWN ) | ||
59 | static int debug = -1; /* the above default */ | ||
60 | module_param(debug, int, 0); | ||
61 | MODULE_PARM_DESC(debug, "debugging messages level"); | ||
62 | |||
63 | static void mpc52xx_fec_tx_timeout(struct net_device *dev) | ||
64 | { | ||
65 | dev_warn(&dev->dev, "transmit timed out\n"); | ||
66 | |||
67 | mpc52xx_fec_reset(dev); | ||
68 | |||
69 | dev->stats.tx_errors++; | ||
70 | |||
71 | netif_wake_queue(dev); | ||
72 | } | ||
73 | |||
74 | static void mpc52xx_fec_set_paddr(struct net_device *dev, u8 *mac) | ||
75 | { | ||
76 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
77 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
78 | |||
79 | out_be32(&fec->paddr1, *(u32 *)(&mac[0])); | ||
80 | out_be32(&fec->paddr2, (*(u16 *)(&mac[4]) << 16) | FEC_PADDR2_TYPE); | ||
81 | } | ||
82 | |||
83 | static void mpc52xx_fec_get_paddr(struct net_device *dev, u8 *mac) | ||
84 | { | ||
85 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
86 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
87 | |||
88 | *(u32 *)(&mac[0]) = in_be32(&fec->paddr1); | ||
89 | *(u16 *)(&mac[4]) = in_be32(&fec->paddr2) >> 16; | ||
90 | } | ||
91 | |||
92 | static int mpc52xx_fec_set_mac_address(struct net_device *dev, void *addr) | ||
93 | { | ||
94 | struct sockaddr *sock = addr; | ||
95 | |||
96 | memcpy(dev->dev_addr, sock->sa_data, dev->addr_len); | ||
97 | |||
98 | mpc52xx_fec_set_paddr(dev, sock->sa_data); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static void mpc52xx_fec_free_rx_buffers(struct net_device *dev, struct bcom_task *s) | ||
103 | { | ||
104 | while (!bcom_queue_empty(s)) { | ||
105 | struct bcom_fec_bd *bd; | ||
106 | struct sk_buff *skb; | ||
107 | |||
108 | skb = bcom_retrieve_buffer(s, NULL, (struct bcom_bd **)&bd); | ||
109 | dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_FROM_DEVICE); | ||
110 | kfree_skb(skb); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | static int mpc52xx_fec_alloc_rx_buffers(struct net_device *dev, struct bcom_task *rxtsk) | ||
115 | { | ||
116 | while (!bcom_queue_full(rxtsk)) { | ||
117 | struct sk_buff *skb; | ||
118 | struct bcom_fec_bd *bd; | ||
119 | |||
120 | skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); | ||
121 | if (skb == NULL) | ||
122 | return -EAGAIN; | ||
123 | |||
124 | /* zero out the initial receive buffers to aid debugging */ | ||
125 | memset(skb->data, 0, FEC_RX_BUFFER_SIZE); | ||
126 | |||
127 | bd = (struct bcom_fec_bd *)bcom_prepare_next_buffer(rxtsk); | ||
128 | |||
129 | bd->status = FEC_RX_BUFFER_SIZE; | ||
130 | bd->skb_pa = dma_map_single(&dev->dev, skb->data, | ||
131 | FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); | ||
132 | |||
133 | bcom_submit_next_buffer(rxtsk, skb); | ||
134 | } | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | /* based on generic_adjust_link from fs_enet-main.c */ | ||
140 | static void mpc52xx_fec_adjust_link(struct net_device *dev) | ||
141 | { | ||
142 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
143 | struct phy_device *phydev = priv->phydev; | ||
144 | int new_state = 0; | ||
145 | |||
146 | if (phydev->link != PHY_DOWN) { | ||
147 | if (phydev->duplex != priv->duplex) { | ||
148 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
149 | u32 rcntrl; | ||
150 | u32 tcntrl; | ||
151 | |||
152 | new_state = 1; | ||
153 | priv->duplex = phydev->duplex; | ||
154 | |||
155 | rcntrl = in_be32(&fec->r_cntrl); | ||
156 | tcntrl = in_be32(&fec->x_cntrl); | ||
157 | |||
158 | rcntrl &= ~FEC_RCNTRL_DRT; | ||
159 | tcntrl &= ~FEC_TCNTRL_FDEN; | ||
160 | if (phydev->duplex == DUPLEX_FULL) | ||
161 | tcntrl |= FEC_TCNTRL_FDEN; /* FD enable */ | ||
162 | else | ||
163 | rcntrl |= FEC_RCNTRL_DRT; /* disable Rx on Tx (HD) */ | ||
164 | |||
165 | out_be32(&fec->r_cntrl, rcntrl); | ||
166 | out_be32(&fec->x_cntrl, tcntrl); | ||
167 | } | ||
168 | |||
169 | if (phydev->speed != priv->speed) { | ||
170 | new_state = 1; | ||
171 | priv->speed = phydev->speed; | ||
172 | } | ||
173 | |||
174 | if (priv->link == PHY_DOWN) { | ||
175 | new_state = 1; | ||
176 | priv->link = phydev->link; | ||
177 | netif_schedule(dev); | ||
178 | netif_carrier_on(dev); | ||
179 | netif_start_queue(dev); | ||
180 | } | ||
181 | |||
182 | } else if (priv->link) { | ||
183 | new_state = 1; | ||
184 | priv->link = PHY_DOWN; | ||
185 | priv->speed = 0; | ||
186 | priv->duplex = -1; | ||
187 | netif_stop_queue(dev); | ||
188 | netif_carrier_off(dev); | ||
189 | } | ||
190 | |||
191 | if (new_state && netif_msg_link(priv)) | ||
192 | phy_print_status(phydev); | ||
193 | } | ||
194 | |||
195 | static int mpc52xx_fec_init_phy(struct net_device *dev) | ||
196 | { | ||
197 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
198 | struct phy_device *phydev; | ||
199 | char phy_id[BUS_ID_SIZE]; | ||
200 | |||
201 | snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, | ||
202 | (unsigned int)dev->base_addr, priv->phy_addr); | ||
203 | |||
204 | priv->link = PHY_DOWN; | ||
205 | priv->speed = 0; | ||
206 | priv->duplex = -1; | ||
207 | |||
208 | phydev = phy_connect(dev, phy_id, &mpc52xx_fec_adjust_link, 0, PHY_INTERFACE_MODE_MII); | ||
209 | if (IS_ERR(phydev)) { | ||
210 | dev_err(&dev->dev, "phy_connect failed\n"); | ||
211 | return PTR_ERR(phydev); | ||
212 | } | ||
213 | dev_info(&dev->dev, "attached phy %i to driver %s\n", | ||
214 | phydev->addr, phydev->drv->name); | ||
215 | |||
216 | priv->phydev = phydev; | ||
217 | |||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | static int mpc52xx_fec_phy_start(struct net_device *dev) | ||
222 | { | ||
223 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
224 | int err; | ||
225 | |||
226 | if (!priv->has_phy) | ||
227 | return 0; | ||
228 | |||
229 | err = mpc52xx_fec_init_phy(dev); | ||
230 | if (err) { | ||
231 | dev_err(&dev->dev, "mpc52xx_fec_init_phy failed\n"); | ||
232 | return err; | ||
233 | } | ||
234 | |||
235 | /* reset phy - this also wakes it from PDOWN */ | ||
236 | phy_write(priv->phydev, MII_BMCR, BMCR_RESET); | ||
237 | phy_start(priv->phydev); | ||
238 | |||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static void mpc52xx_fec_phy_stop(struct net_device *dev) | ||
243 | { | ||
244 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
245 | |||
246 | if (!priv->has_phy) | ||
247 | return; | ||
248 | |||
249 | phy_disconnect(priv->phydev); | ||
250 | /* power down phy */ | ||
251 | phy_stop(priv->phydev); | ||
252 | phy_write(priv->phydev, MII_BMCR, BMCR_PDOWN); | ||
253 | } | ||
254 | |||
255 | static int mpc52xx_fec_phy_mii_ioctl(struct mpc52xx_fec_priv *priv, | ||
256 | struct mii_ioctl_data *mii_data, int cmd) | ||
257 | { | ||
258 | if (!priv->has_phy) | ||
259 | return -ENOTSUPP; | ||
260 | |||
261 | return phy_mii_ioctl(priv->phydev, mii_data, cmd); | ||
262 | } | ||
263 | |||
264 | static void mpc52xx_fec_phy_hw_init(struct mpc52xx_fec_priv *priv) | ||
265 | { | ||
266 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
267 | |||
268 | if (!priv->has_phy) | ||
269 | return; | ||
270 | |||
271 | out_be32(&fec->mii_speed, priv->phy_speed); | ||
272 | } | ||
273 | |||
274 | static int mpc52xx_fec_open(struct net_device *dev) | ||
275 | { | ||
276 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
277 | int err = -EBUSY; | ||
278 | |||
279 | if (request_irq(dev->irq, &mpc52xx_fec_interrupt, IRQF_SHARED, | ||
280 | DRIVER_NAME "_ctrl", dev)) { | ||
281 | dev_err(&dev->dev, "ctrl interrupt request failed\n"); | ||
282 | goto out; | ||
283 | } | ||
284 | if (request_irq(priv->r_irq, &mpc52xx_fec_rx_interrupt, 0, | ||
285 | DRIVER_NAME "_rx", dev)) { | ||
286 | dev_err(&dev->dev, "rx interrupt request failed\n"); | ||
287 | goto free_ctrl_irq; | ||
288 | } | ||
289 | if (request_irq(priv->t_irq, &mpc52xx_fec_tx_interrupt, 0, | ||
290 | DRIVER_NAME "_tx", dev)) { | ||
291 | dev_err(&dev->dev, "tx interrupt request failed\n"); | ||
292 | goto free_2irqs; | ||
293 | } | ||
294 | |||
295 | bcom_fec_rx_reset(priv->rx_dmatsk); | ||
296 | bcom_fec_tx_reset(priv->tx_dmatsk); | ||
297 | |||
298 | err = mpc52xx_fec_alloc_rx_buffers(dev, priv->rx_dmatsk); | ||
299 | if (err) { | ||
300 | dev_err(&dev->dev, "mpc52xx_fec_alloc_rx_buffers failed\n"); | ||
301 | goto free_irqs; | ||
302 | } | ||
303 | |||
304 | err = mpc52xx_fec_phy_start(dev); | ||
305 | if (err) | ||
306 | goto free_skbs; | ||
307 | |||
308 | bcom_enable(priv->rx_dmatsk); | ||
309 | bcom_enable(priv->tx_dmatsk); | ||
310 | |||
311 | mpc52xx_fec_start(dev); | ||
312 | |||
313 | netif_start_queue(dev); | ||
314 | |||
315 | return 0; | ||
316 | |||
317 | free_skbs: | ||
318 | mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk); | ||
319 | |||
320 | free_irqs: | ||
321 | free_irq(priv->t_irq, dev); | ||
322 | free_2irqs: | ||
323 | free_irq(priv->r_irq, dev); | ||
324 | free_ctrl_irq: | ||
325 | free_irq(dev->irq, dev); | ||
326 | out: | ||
327 | |||
328 | return err; | ||
329 | } | ||
330 | |||
331 | static int mpc52xx_fec_close(struct net_device *dev) | ||
332 | { | ||
333 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
334 | |||
335 | netif_stop_queue(dev); | ||
336 | |||
337 | mpc52xx_fec_stop(dev); | ||
338 | |||
339 | mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk); | ||
340 | |||
341 | free_irq(dev->irq, dev); | ||
342 | free_irq(priv->r_irq, dev); | ||
343 | free_irq(priv->t_irq, dev); | ||
344 | |||
345 | mpc52xx_fec_phy_stop(dev); | ||
346 | |||
347 | return 0; | ||
348 | } | ||
349 | |||
350 | /* This will only be invoked if your driver is _not_ in XOFF state. | ||
351 | * What this means is that you need not check it, and that this | ||
352 | * invariant will hold if you make sure that the netif_*_queue() | ||
353 | * calls are done at the proper times. | ||
354 | */ | ||
355 | static int mpc52xx_fec_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
356 | { | ||
357 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
358 | struct bcom_fec_bd *bd; | ||
359 | |||
360 | if (bcom_queue_full(priv->tx_dmatsk)) { | ||
361 | if (net_ratelimit()) | ||
362 | dev_err(&dev->dev, "transmit queue overrun\n"); | ||
363 | return 1; | ||
364 | } | ||
365 | |||
366 | spin_lock_irq(&priv->lock); | ||
367 | dev->trans_start = jiffies; | ||
368 | |||
369 | bd = (struct bcom_fec_bd *) | ||
370 | bcom_prepare_next_buffer(priv->tx_dmatsk); | ||
371 | |||
372 | bd->status = skb->len | BCOM_FEC_TX_BD_TFD | BCOM_FEC_TX_BD_TC; | ||
373 | bd->skb_pa = dma_map_single(&dev->dev, skb->data, skb->len, DMA_TO_DEVICE); | ||
374 | |||
375 | bcom_submit_next_buffer(priv->tx_dmatsk, skb); | ||
376 | |||
377 | if (bcom_queue_full(priv->tx_dmatsk)) { | ||
378 | netif_stop_queue(dev); | ||
379 | } | ||
380 | |||
381 | spin_unlock_irq(&priv->lock); | ||
382 | |||
383 | return 0; | ||
384 | } | ||
385 | |||
386 | /* This handles BestComm transmit task interrupts | ||
387 | */ | ||
388 | static irqreturn_t mpc52xx_fec_tx_interrupt(int irq, void *dev_id) | ||
389 | { | ||
390 | struct net_device *dev = dev_id; | ||
391 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
392 | |||
393 | spin_lock(&priv->lock); | ||
394 | |||
395 | while (bcom_buffer_done(priv->tx_dmatsk)) { | ||
396 | struct sk_buff *skb; | ||
397 | struct bcom_fec_bd *bd; | ||
398 | skb = bcom_retrieve_buffer(priv->tx_dmatsk, NULL, | ||
399 | (struct bcom_bd **)&bd); | ||
400 | dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_TO_DEVICE); | ||
401 | |||
402 | dev_kfree_skb_irq(skb); | ||
403 | } | ||
404 | |||
405 | netif_wake_queue(dev); | ||
406 | |||
407 | spin_unlock(&priv->lock); | ||
408 | |||
409 | return IRQ_HANDLED; | ||
410 | } | ||
411 | |||
412 | static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id) | ||
413 | { | ||
414 | struct net_device *dev = dev_id; | ||
415 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
416 | |||
417 | while (bcom_buffer_done(priv->rx_dmatsk)) { | ||
418 | struct sk_buff *skb; | ||
419 | struct sk_buff *rskb; | ||
420 | struct bcom_fec_bd *bd; | ||
421 | u32 status; | ||
422 | |||
423 | rskb = bcom_retrieve_buffer(priv->rx_dmatsk, &status, | ||
424 | (struct bcom_bd **)&bd); | ||
425 | dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_FROM_DEVICE); | ||
426 | |||
427 | /* Test for errors in received frame */ | ||
428 | if (status & BCOM_FEC_RX_BD_ERRORS) { | ||
429 | /* Drop packet and reuse the buffer */ | ||
430 | bd = (struct bcom_fec_bd *) | ||
431 | bcom_prepare_next_buffer(priv->rx_dmatsk); | ||
432 | |||
433 | bd->status = FEC_RX_BUFFER_SIZE; | ||
434 | bd->skb_pa = dma_map_single(&dev->dev, rskb->data, | ||
435 | FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); | ||
436 | |||
437 | bcom_submit_next_buffer(priv->rx_dmatsk, rskb); | ||
438 | |||
439 | dev->stats.rx_dropped++; | ||
440 | |||
441 | continue; | ||
442 | } | ||
443 | |||
444 | /* skbs are allocated on open, so now we allocate a new one, | ||
445 | * and remove the old (with the packet) */ | ||
446 | skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); | ||
447 | if (skb) { | ||
448 | /* Process the received skb */ | ||
449 | int length = status & BCOM_FEC_RX_BD_LEN_MASK; | ||
450 | |||
451 | skb_put(rskb, length - 4); /* length without CRC32 */ | ||
452 | |||
453 | rskb->dev = dev; | ||
454 | rskb->protocol = eth_type_trans(rskb, dev); | ||
455 | |||
456 | netif_rx(rskb); | ||
457 | dev->last_rx = jiffies; | ||
458 | } else { | ||
459 | /* Can't get a new one : reuse the same & drop pkt */ | ||
460 | dev_notice(&dev->dev, "Memory squeeze, dropping packet.\n"); | ||
461 | dev->stats.rx_dropped++; | ||
462 | |||
463 | skb = rskb; | ||
464 | } | ||
465 | |||
466 | bd = (struct bcom_fec_bd *) | ||
467 | bcom_prepare_next_buffer(priv->rx_dmatsk); | ||
468 | |||
469 | bd->status = FEC_RX_BUFFER_SIZE; | ||
470 | bd->skb_pa = dma_map_single(&dev->dev, rskb->data, | ||
471 | FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); | ||
472 | |||
473 | bcom_submit_next_buffer(priv->rx_dmatsk, skb); | ||
474 | } | ||
475 | |||
476 | return IRQ_HANDLED; | ||
477 | } | ||
478 | |||
479 | static irqreturn_t mpc52xx_fec_interrupt(int irq, void *dev_id) | ||
480 | { | ||
481 | struct net_device *dev = dev_id; | ||
482 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
483 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
484 | u32 ievent; | ||
485 | |||
486 | ievent = in_be32(&fec->ievent); | ||
487 | |||
488 | ievent &= ~FEC_IEVENT_MII; /* mii is handled separately */ | ||
489 | if (!ievent) | ||
490 | return IRQ_NONE; | ||
491 | |||
492 | out_be32(&fec->ievent, ievent); /* clear pending events */ | ||
493 | |||
494 | if (ievent & ~(FEC_IEVENT_RFIFO_ERROR | FEC_IEVENT_XFIFO_ERROR)) { | ||
495 | if (ievent & ~FEC_IEVENT_TFINT) | ||
496 | dev_dbg(&dev->dev, "ievent: %08x\n", ievent); | ||
497 | return IRQ_HANDLED; | ||
498 | } | ||
499 | |||
500 | if (net_ratelimit() && (ievent & FEC_IEVENT_RFIFO_ERROR)) | ||
501 | dev_warn(&dev->dev, "FEC_IEVENT_RFIFO_ERROR\n"); | ||
502 | if (net_ratelimit() && (ievent & FEC_IEVENT_XFIFO_ERROR)) | ||
503 | dev_warn(&dev->dev, "FEC_IEVENT_XFIFO_ERROR\n"); | ||
504 | |||
505 | mpc52xx_fec_reset(dev); | ||
506 | |||
507 | netif_wake_queue(dev); | ||
508 | return IRQ_HANDLED; | ||
509 | } | ||
510 | |||
511 | /* | ||
512 | * Get the current statistics. | ||
513 | * This may be called with the card open or closed. | ||
514 | */ | ||
515 | static struct net_device_stats *mpc52xx_fec_get_stats(struct net_device *dev) | ||
516 | { | ||
517 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
518 | struct net_device_stats *stats = &dev->stats; | ||
519 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
520 | |||
521 | stats->rx_bytes = in_be32(&fec->rmon_r_octets); | ||
522 | stats->rx_packets = in_be32(&fec->rmon_r_packets); | ||
523 | stats->rx_errors = in_be32(&fec->rmon_r_crc_align) + | ||
524 | in_be32(&fec->rmon_r_undersize) + | ||
525 | in_be32(&fec->rmon_r_oversize) + | ||
526 | in_be32(&fec->rmon_r_frag) + | ||
527 | in_be32(&fec->rmon_r_jab); | ||
528 | |||
529 | stats->tx_bytes = in_be32(&fec->rmon_t_octets); | ||
530 | stats->tx_packets = in_be32(&fec->rmon_t_packets); | ||
531 | stats->tx_errors = in_be32(&fec->rmon_t_crc_align) + | ||
532 | in_be32(&fec->rmon_t_undersize) + | ||
533 | in_be32(&fec->rmon_t_oversize) + | ||
534 | in_be32(&fec->rmon_t_frag) + | ||
535 | in_be32(&fec->rmon_t_jab); | ||
536 | |||
537 | stats->multicast = in_be32(&fec->rmon_r_mc_pkt); | ||
538 | stats->collisions = in_be32(&fec->rmon_t_col); | ||
539 | |||
540 | /* detailed rx_errors: */ | ||
541 | stats->rx_length_errors = in_be32(&fec->rmon_r_undersize) | ||
542 | + in_be32(&fec->rmon_r_oversize) | ||
543 | + in_be32(&fec->rmon_r_frag) | ||
544 | + in_be32(&fec->rmon_r_jab); | ||
545 | stats->rx_over_errors = in_be32(&fec->r_macerr); | ||
546 | stats->rx_crc_errors = in_be32(&fec->ieee_r_crc); | ||
547 | stats->rx_frame_errors = in_be32(&fec->ieee_r_align); | ||
548 | stats->rx_fifo_errors = in_be32(&fec->rmon_r_drop); | ||
549 | stats->rx_missed_errors = in_be32(&fec->rmon_r_drop); | ||
550 | |||
551 | /* detailed tx_errors: */ | ||
552 | stats->tx_aborted_errors = 0; | ||
553 | stats->tx_carrier_errors = in_be32(&fec->ieee_t_cserr); | ||
554 | stats->tx_fifo_errors = in_be32(&fec->rmon_t_drop); | ||
555 | stats->tx_heartbeat_errors = in_be32(&fec->ieee_t_sqe); | ||
556 | stats->tx_window_errors = in_be32(&fec->ieee_t_lcol); | ||
557 | |||
558 | return stats; | ||
559 | } | ||
560 | |||
561 | /* | ||
562 | * Read MIB counters in order to reset them, | ||
563 | * then zero all the stats fields in memory | ||
564 | */ | ||
565 | static void mpc52xx_fec_reset_stats(struct net_device *dev) | ||
566 | { | ||
567 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
568 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
569 | |||
570 | out_be32(&fec->mib_control, FEC_MIB_DISABLE); | ||
571 | memset_io(&fec->rmon_t_drop, 0, (__force u32)&fec->reserved10 - | ||
572 | (__force u32)&fec->rmon_t_drop); | ||
573 | out_be32(&fec->mib_control, 0); | ||
574 | |||
575 | memset(&dev->stats, 0, sizeof(dev->stats)); | ||
576 | } | ||
577 | |||
578 | /* | ||
579 | * Set or clear the multicast filter for this adaptor. | ||
580 | */ | ||
581 | static void mpc52xx_fec_set_multicast_list(struct net_device *dev) | ||
582 | { | ||
583 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
584 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
585 | u32 rx_control; | ||
586 | |||
587 | rx_control = in_be32(&fec->r_cntrl); | ||
588 | |||
589 | if (dev->flags & IFF_PROMISC) { | ||
590 | rx_control |= FEC_RCNTRL_PROM; | ||
591 | out_be32(&fec->r_cntrl, rx_control); | ||
592 | } else { | ||
593 | rx_control &= ~FEC_RCNTRL_PROM; | ||
594 | out_be32(&fec->r_cntrl, rx_control); | ||
595 | |||
596 | if (dev->flags & IFF_ALLMULTI) { | ||
597 | out_be32(&fec->gaddr1, 0xffffffff); | ||
598 | out_be32(&fec->gaddr2, 0xffffffff); | ||
599 | } else { | ||
600 | u32 crc; | ||
601 | int i; | ||
602 | struct dev_mc_list *dmi; | ||
603 | u32 gaddr1 = 0x00000000; | ||
604 | u32 gaddr2 = 0x00000000; | ||
605 | |||
606 | dmi = dev->mc_list; | ||
607 | for (i=0; i<dev->mc_count; i++) { | ||
608 | crc = ether_crc_le(6, dmi->dmi_addr) >> 26; | ||
609 | if (crc >= 32) | ||
610 | gaddr1 |= 1 << (crc-32); | ||
611 | else | ||
612 | gaddr2 |= 1 << crc; | ||
613 | dmi = dmi->next; | ||
614 | } | ||
615 | out_be32(&fec->gaddr1, gaddr1); | ||
616 | out_be32(&fec->gaddr2, gaddr2); | ||
617 | } | ||
618 | } | ||
619 | } | ||
620 | |||
621 | /** | ||
622 | * mpc52xx_fec_hw_init | ||
623 | * @dev: network device | ||
624 | * | ||
625 | * Setup various hardware setting, only needed once on start | ||
626 | */ | ||
627 | static void mpc52xx_fec_hw_init(struct net_device *dev) | ||
628 | { | ||
629 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
630 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
631 | int i; | ||
632 | |||
633 | /* Whack a reset. We should wait for this. */ | ||
634 | out_be32(&fec->ecntrl, FEC_ECNTRL_RESET); | ||
635 | for (i = 0; i < FEC_RESET_DELAY; ++i) { | ||
636 | if ((in_be32(&fec->ecntrl) & FEC_ECNTRL_RESET) == 0) | ||
637 | break; | ||
638 | udelay(1); | ||
639 | } | ||
640 | if (i == FEC_RESET_DELAY) | ||
641 | dev_err(&dev->dev, "FEC Reset timeout!\n"); | ||
642 | |||
643 | /* set pause to 0x20 frames */ | ||
644 | out_be32(&fec->op_pause, FEC_OP_PAUSE_OPCODE | 0x20); | ||
645 | |||
646 | /* high service request will be deasserted when there's < 7 bytes in fifo | ||
647 | * low service request will be deasserted when there's < 4*7 bytes in fifo | ||
648 | */ | ||
649 | out_be32(&fec->rfifo_cntrl, FEC_FIFO_CNTRL_FRAME | FEC_FIFO_CNTRL_LTG_7); | ||
650 | out_be32(&fec->tfifo_cntrl, FEC_FIFO_CNTRL_FRAME | FEC_FIFO_CNTRL_LTG_7); | ||
651 | |||
652 | /* alarm when <= x bytes in FIFO */ | ||
653 | out_be32(&fec->rfifo_alarm, 0x0000030c); | ||
654 | out_be32(&fec->tfifo_alarm, 0x00000100); | ||
655 | |||
656 | /* begin transmittion when 256 bytes are in FIFO (or EOF or FIFO full) */ | ||
657 | out_be32(&fec->x_wmrk, FEC_FIFO_WMRK_256B); | ||
658 | |||
659 | /* enable crc generation */ | ||
660 | out_be32(&fec->xmit_fsm, FEC_XMIT_FSM_APPEND_CRC | FEC_XMIT_FSM_ENABLE_CRC); | ||
661 | out_be32(&fec->iaddr1, 0x00000000); /* No individual filter */ | ||
662 | out_be32(&fec->iaddr2, 0x00000000); /* No individual filter */ | ||
663 | |||
664 | /* set phy speed. | ||
665 | * this can't be done in phy driver, since it needs to be called | ||
666 | * before fec stuff (even on resume) */ | ||
667 | mpc52xx_fec_phy_hw_init(priv); | ||
668 | } | ||
669 | |||
670 | /** | ||
671 | * mpc52xx_fec_start | ||
672 | * @dev: network device | ||
673 | * | ||
674 | * This function is called to start or restart the FEC during a link | ||
675 | * change. This happens on fifo errors or when switching between half | ||
676 | * and full duplex. | ||
677 | */ | ||
678 | static void mpc52xx_fec_start(struct net_device *dev) | ||
679 | { | ||
680 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
681 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
682 | u32 rcntrl; | ||
683 | u32 tcntrl; | ||
684 | u32 tmp; | ||
685 | |||
686 | /* clear sticky error bits */ | ||
687 | tmp = FEC_FIFO_STATUS_ERR | FEC_FIFO_STATUS_UF | FEC_FIFO_STATUS_OF; | ||
688 | out_be32(&fec->rfifo_status, in_be32(&fec->rfifo_status) & tmp); | ||
689 | out_be32(&fec->tfifo_status, in_be32(&fec->tfifo_status) & tmp); | ||
690 | |||
691 | /* FIFOs will reset on mpc52xx_fec_enable */ | ||
692 | out_be32(&fec->reset_cntrl, FEC_RESET_CNTRL_ENABLE_IS_RESET); | ||
693 | |||
694 | /* Set station address. */ | ||
695 | mpc52xx_fec_set_paddr(dev, dev->dev_addr); | ||
696 | |||
697 | mpc52xx_fec_set_multicast_list(dev); | ||
698 | |||
699 | /* set max frame len, enable flow control, select mii mode */ | ||
700 | rcntrl = FEC_RX_BUFFER_SIZE << 16; /* max frame length */ | ||
701 | rcntrl |= FEC_RCNTRL_FCE; | ||
702 | |||
703 | if (priv->has_phy) | ||
704 | rcntrl |= FEC_RCNTRL_MII_MODE; | ||
705 | |||
706 | if (priv->duplex == DUPLEX_FULL) | ||
707 | tcntrl = FEC_TCNTRL_FDEN; /* FD enable */ | ||
708 | else { | ||
709 | rcntrl |= FEC_RCNTRL_DRT; /* disable Rx on Tx (HD) */ | ||
710 | tcntrl = 0; | ||
711 | } | ||
712 | out_be32(&fec->r_cntrl, rcntrl); | ||
713 | out_be32(&fec->x_cntrl, tcntrl); | ||
714 | |||
715 | /* Clear any outstanding interrupt. */ | ||
716 | out_be32(&fec->ievent, 0xffffffff); | ||
717 | |||
718 | /* Enable interrupts we wish to service. */ | ||
719 | out_be32(&fec->imask, FEC_IMASK_ENABLE); | ||
720 | |||
721 | /* And last, enable the transmit and receive processing. */ | ||
722 | out_be32(&fec->ecntrl, FEC_ECNTRL_ETHER_EN); | ||
723 | out_be32(&fec->r_des_active, 0x01000000); | ||
724 | } | ||
725 | |||
726 | /** | ||
727 | * mpc52xx_fec_stop | ||
728 | * @dev: network device | ||
729 | * | ||
730 | * stop all activity on fec and empty dma buffers | ||
731 | */ | ||
732 | static void mpc52xx_fec_stop(struct net_device *dev) | ||
733 | { | ||
734 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
735 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
736 | unsigned long timeout; | ||
737 | |||
738 | /* disable all interrupts */ | ||
739 | out_be32(&fec->imask, 0); | ||
740 | |||
741 | /* Disable the rx task. */ | ||
742 | bcom_disable(priv->rx_dmatsk); | ||
743 | |||
744 | /* Wait for tx queue to drain, but only if we're in process context */ | ||
745 | if (!in_interrupt()) { | ||
746 | timeout = jiffies + msecs_to_jiffies(2000); | ||
747 | while (time_before(jiffies, timeout) && | ||
748 | !bcom_queue_empty(priv->tx_dmatsk)) | ||
749 | msleep(100); | ||
750 | |||
751 | if (time_after_eq(jiffies, timeout)) | ||
752 | dev_err(&dev->dev, "queues didn't drain\n"); | ||
753 | #if 1 | ||
754 | if (time_after_eq(jiffies, timeout)) { | ||
755 | dev_err(&dev->dev, " tx: index: %i, outdex: %i\n", | ||
756 | priv->tx_dmatsk->index, | ||
757 | priv->tx_dmatsk->outdex); | ||
758 | dev_err(&dev->dev, " rx: index: %i, outdex: %i\n", | ||
759 | priv->rx_dmatsk->index, | ||
760 | priv->rx_dmatsk->outdex); | ||
761 | } | ||
762 | #endif | ||
763 | } | ||
764 | |||
765 | bcom_disable(priv->tx_dmatsk); | ||
766 | |||
767 | /* Stop FEC */ | ||
768 | out_be32(&fec->ecntrl, in_be32(&fec->ecntrl) & ~FEC_ECNTRL_ETHER_EN); | ||
769 | |||
770 | return; | ||
771 | } | ||
772 | |||
773 | /* reset fec and bestcomm tasks */ | ||
774 | static void mpc52xx_fec_reset(struct net_device *dev) | ||
775 | { | ||
776 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
777 | struct mpc52xx_fec __iomem *fec = priv->fec; | ||
778 | |||
779 | mpc52xx_fec_stop(dev); | ||
780 | |||
781 | out_be32(&fec->rfifo_status, in_be32(&fec->rfifo_status)); | ||
782 | out_be32(&fec->reset_cntrl, FEC_RESET_CNTRL_RESET_FIFO); | ||
783 | |||
784 | mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk); | ||
785 | |||
786 | mpc52xx_fec_hw_init(dev); | ||
787 | |||
788 | phy_stop(priv->phydev); | ||
789 | phy_write(priv->phydev, MII_BMCR, BMCR_RESET); | ||
790 | phy_start(priv->phydev); | ||
791 | |||
792 | bcom_fec_rx_reset(priv->rx_dmatsk); | ||
793 | bcom_fec_tx_reset(priv->tx_dmatsk); | ||
794 | |||
795 | mpc52xx_fec_alloc_rx_buffers(dev, priv->rx_dmatsk); | ||
796 | |||
797 | bcom_enable(priv->rx_dmatsk); | ||
798 | bcom_enable(priv->tx_dmatsk); | ||
799 | |||
800 | mpc52xx_fec_start(dev); | ||
801 | } | ||
802 | |||
803 | |||
804 | /* ethtool interface */ | ||
805 | static void mpc52xx_fec_get_drvinfo(struct net_device *dev, | ||
806 | struct ethtool_drvinfo *info) | ||
807 | { | ||
808 | strcpy(info->driver, DRIVER_NAME); | ||
809 | } | ||
810 | |||
811 | static int mpc52xx_fec_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | ||
812 | { | ||
813 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
814 | return phy_ethtool_gset(priv->phydev, cmd); | ||
815 | } | ||
816 | |||
817 | static int mpc52xx_fec_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | ||
818 | { | ||
819 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
820 | return phy_ethtool_sset(priv->phydev, cmd); | ||
821 | } | ||
822 | |||
823 | static u32 mpc52xx_fec_get_msglevel(struct net_device *dev) | ||
824 | { | ||
825 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
826 | return priv->msg_enable; | ||
827 | } | ||
828 | |||
829 | static void mpc52xx_fec_set_msglevel(struct net_device *dev, u32 level) | ||
830 | { | ||
831 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
832 | priv->msg_enable = level; | ||
833 | } | ||
834 | |||
835 | static const struct ethtool_ops mpc52xx_fec_ethtool_ops = { | ||
836 | .get_drvinfo = mpc52xx_fec_get_drvinfo, | ||
837 | .get_settings = mpc52xx_fec_get_settings, | ||
838 | .set_settings = mpc52xx_fec_set_settings, | ||
839 | .get_link = ethtool_op_get_link, | ||
840 | .get_msglevel = mpc52xx_fec_get_msglevel, | ||
841 | .set_msglevel = mpc52xx_fec_set_msglevel, | ||
842 | }; | ||
843 | |||
844 | |||
845 | static int mpc52xx_fec_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | ||
846 | { | ||
847 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | ||
848 | |||
849 | return mpc52xx_fec_phy_mii_ioctl(priv, if_mii(rq), cmd); | ||
850 | } | ||
851 | |||
852 | /* ======================================================================== */ | ||
853 | /* OF Driver */ | ||
854 | /* ======================================================================== */ | ||
855 | |||
856 | static int __devinit | ||
857 | mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) | ||
858 | { | ||
859 | int rv; | ||
860 | struct net_device *ndev; | ||
861 | struct mpc52xx_fec_priv *priv = NULL; | ||
862 | struct resource mem; | ||
863 | const phandle *ph; | ||
864 | |||
865 | phys_addr_t rx_fifo; | ||
866 | phys_addr_t tx_fifo; | ||
867 | |||
868 | /* Get the ether ndev & it's private zone */ | ||
869 | ndev = alloc_etherdev(sizeof(struct mpc52xx_fec_priv)); | ||
870 | if (!ndev) | ||
871 | return -ENOMEM; | ||
872 | |||
873 | priv = netdev_priv(ndev); | ||
874 | |||
875 | /* Reserve FEC control zone */ | ||
876 | rv = of_address_to_resource(op->node, 0, &mem); | ||
877 | if (rv) { | ||
878 | printk(KERN_ERR DRIVER_NAME ": " | ||
879 | "Error while parsing device node resource\n" ); | ||
880 | return rv; | ||
881 | } | ||
882 | if ((mem.end - mem.start + 1) < sizeof(struct mpc52xx_fec)) { | ||
883 | printk(KERN_ERR DRIVER_NAME | ||
884 | " - invalid resource size (%lx < %x), check mpc52xx_devices.c\n", | ||
885 | (unsigned long)(mem.end - mem.start + 1), sizeof(struct mpc52xx_fec)); | ||
886 | return -EINVAL; | ||
887 | } | ||
888 | |||
889 | if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec), DRIVER_NAME)) | ||
890 | return -EBUSY; | ||
891 | |||
892 | /* Init ether ndev with what we have */ | ||
893 | ndev->open = mpc52xx_fec_open; | ||
894 | ndev->stop = mpc52xx_fec_close; | ||
895 | ndev->hard_start_xmit = mpc52xx_fec_hard_start_xmit; | ||
896 | ndev->do_ioctl = mpc52xx_fec_ioctl; | ||
897 | ndev->ethtool_ops = &mpc52xx_fec_ethtool_ops; | ||
898 | ndev->get_stats = mpc52xx_fec_get_stats; | ||
899 | ndev->set_mac_address = mpc52xx_fec_set_mac_address; | ||
900 | ndev->set_multicast_list = mpc52xx_fec_set_multicast_list; | ||
901 | ndev->tx_timeout = mpc52xx_fec_tx_timeout; | ||
902 | ndev->watchdog_timeo = FEC_WATCHDOG_TIMEOUT; | ||
903 | ndev->base_addr = mem.start; | ||
904 | |||
905 | priv->t_irq = priv->r_irq = ndev->irq = NO_IRQ; /* IRQ are free for now */ | ||
906 | |||
907 | spin_lock_init(&priv->lock); | ||
908 | |||
909 | /* ioremap the zones */ | ||
910 | priv->fec = ioremap(mem.start, sizeof(struct mpc52xx_fec)); | ||
911 | |||
912 | if (!priv->fec) { | ||
913 | rv = -ENOMEM; | ||
914 | goto probe_error; | ||
915 | } | ||
916 | |||
917 | /* Bestcomm init */ | ||
918 | rx_fifo = ndev->base_addr + offsetof(struct mpc52xx_fec, rfifo_data); | ||
919 | tx_fifo = ndev->base_addr + offsetof(struct mpc52xx_fec, tfifo_data); | ||
920 | |||
921 | priv->rx_dmatsk = bcom_fec_rx_init(FEC_RX_NUM_BD, rx_fifo, FEC_RX_BUFFER_SIZE); | ||
922 | priv->tx_dmatsk = bcom_fec_tx_init(FEC_TX_NUM_BD, tx_fifo); | ||
923 | |||
924 | if (!priv->rx_dmatsk || !priv->tx_dmatsk) { | ||
925 | printk(KERN_ERR DRIVER_NAME ": Can not init SDMA tasks\n" ); | ||
926 | rv = -ENOMEM; | ||
927 | goto probe_error; | ||
928 | } | ||
929 | |||
930 | /* Get the IRQ we need one by one */ | ||
931 | /* Control */ | ||
932 | ndev->irq = irq_of_parse_and_map(op->node, 0); | ||
933 | |||
934 | /* RX */ | ||
935 | priv->r_irq = bcom_get_task_irq(priv->rx_dmatsk); | ||
936 | |||
937 | /* TX */ | ||
938 | priv->t_irq = bcom_get_task_irq(priv->tx_dmatsk); | ||
939 | |||
940 | /* MAC address init */ | ||
941 | if (!is_zero_ether_addr(mpc52xx_fec_mac_addr)) | ||
942 | memcpy(ndev->dev_addr, mpc52xx_fec_mac_addr, 6); | ||
943 | else | ||
944 | mpc52xx_fec_get_paddr(ndev, ndev->dev_addr); | ||
945 | |||
946 | priv->msg_enable = netif_msg_init(debug, MPC52xx_MESSAGES_DEFAULT); | ||
947 | priv->duplex = DUPLEX_FULL; | ||
948 | |||
949 | /* is the phy present in device tree? */ | ||
950 | ph = of_get_property(op->node, "phy-handle", NULL); | ||
951 | if (ph) { | ||
952 | const unsigned int *prop; | ||
953 | struct device_node *phy_dn; | ||
954 | priv->has_phy = 1; | ||
955 | |||
956 | phy_dn = of_find_node_by_phandle(*ph); | ||
957 | prop = of_get_property(phy_dn, "reg", NULL); | ||
958 | priv->phy_addr = *prop; | ||
959 | |||
960 | of_node_put(phy_dn); | ||
961 | |||
962 | /* Phy speed */ | ||
963 | priv->phy_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1; | ||
964 | } else { | ||
965 | dev_info(&ndev->dev, "can't find \"phy-handle\" in device" | ||
966 | " tree, using 7-wire mode\n"); | ||
967 | } | ||
968 | |||
969 | /* Hardware init */ | ||
970 | mpc52xx_fec_hw_init(ndev); | ||
971 | |||
972 | mpc52xx_fec_reset_stats(ndev); | ||
973 | |||
974 | /* Register the new network device */ | ||
975 | rv = register_netdev(ndev); | ||
976 | if (rv < 0) | ||
977 | goto probe_error; | ||
978 | |||
979 | /* We're done ! */ | ||
980 | dev_set_drvdata(&op->dev, ndev); | ||
981 | |||
982 | return 0; | ||
983 | |||
984 | |||
985 | /* Error handling - free everything that might be allocated */ | ||
986 | probe_error: | ||
987 | |||
988 | irq_dispose_mapping(ndev->irq); | ||
989 | |||
990 | if (priv->rx_dmatsk) | ||
991 | bcom_fec_rx_release(priv->rx_dmatsk); | ||
992 | if (priv->tx_dmatsk) | ||
993 | bcom_fec_tx_release(priv->tx_dmatsk); | ||
994 | |||
995 | if (priv->fec) | ||
996 | iounmap(priv->fec); | ||
997 | |||
998 | release_mem_region(mem.start, sizeof(struct mpc52xx_fec)); | ||
999 | |||
1000 | free_netdev(ndev); | ||
1001 | |||
1002 | return rv; | ||
1003 | } | ||
1004 | |||
1005 | static int | ||
1006 | mpc52xx_fec_remove(struct of_device *op) | ||
1007 | { | ||
1008 | struct net_device *ndev; | ||
1009 | struct mpc52xx_fec_priv *priv; | ||
1010 | |||
1011 | ndev = dev_get_drvdata(&op->dev); | ||
1012 | priv = netdev_priv(ndev); | ||
1013 | |||
1014 | unregister_netdev(ndev); | ||
1015 | |||
1016 | irq_dispose_mapping(ndev->irq); | ||
1017 | |||
1018 | bcom_fec_rx_release(priv->rx_dmatsk); | ||
1019 | bcom_fec_tx_release(priv->tx_dmatsk); | ||
1020 | |||
1021 | iounmap(priv->fec); | ||
1022 | |||
1023 | release_mem_region(ndev->base_addr, sizeof(struct mpc52xx_fec)); | ||
1024 | |||
1025 | free_netdev(ndev); | ||
1026 | |||
1027 | dev_set_drvdata(&op->dev, NULL); | ||
1028 | return 0; | ||
1029 | } | ||
1030 | |||
1031 | #ifdef CONFIG_PM | ||
1032 | static int mpc52xx_fec_of_suspend(struct of_device *op, pm_message_t state) | ||
1033 | { | ||
1034 | struct net_device *dev = dev_get_drvdata(&op->dev); | ||
1035 | |||
1036 | if (netif_running(dev)) | ||
1037 | mpc52xx_fec_close(dev); | ||
1038 | |||
1039 | return 0; | ||
1040 | } | ||
1041 | |||
1042 | static int mpc52xx_fec_of_resume(struct of_device *op) | ||
1043 | { | ||
1044 | struct net_device *dev = dev_get_drvdata(&op->dev); | ||
1045 | |||
1046 | mpc52xx_fec_hw_init(dev); | ||
1047 | mpc52xx_fec_reset_stats(dev); | ||
1048 | |||
1049 | if (netif_running(dev)) | ||
1050 | mpc52xx_fec_open(dev); | ||
1051 | |||
1052 | return 0; | ||
1053 | } | ||
1054 | #endif | ||
1055 | |||
1056 | static struct of_device_id mpc52xx_fec_match[] = { | ||
1057 | { | ||
1058 | .type = "network", | ||
1059 | .compatible = "mpc5200-fec", | ||
1060 | }, | ||
1061 | { } | ||
1062 | }; | ||
1063 | |||
1064 | MODULE_DEVICE_TABLE(of, mpc52xx_fec_match); | ||
1065 | |||
1066 | static struct of_platform_driver mpc52xx_fec_driver = { | ||
1067 | .owner = THIS_MODULE, | ||
1068 | .name = DRIVER_NAME, | ||
1069 | .match_table = mpc52xx_fec_match, | ||
1070 | .probe = mpc52xx_fec_probe, | ||
1071 | .remove = mpc52xx_fec_remove, | ||
1072 | #ifdef CONFIG_PM | ||
1073 | .suspend = mpc52xx_fec_of_suspend, | ||
1074 | .resume = mpc52xx_fec_of_resume, | ||
1075 | #endif | ||
1076 | }; | ||
1077 | |||
1078 | |||
1079 | /* ======================================================================== */ | ||
1080 | /* Module */ | ||
1081 | /* ======================================================================== */ | ||
1082 | |||
1083 | static int __init | ||
1084 | mpc52xx_fec_init(void) | ||
1085 | { | ||
1086 | #ifdef CONFIG_FEC_MPC52xx_MDIO | ||
1087 | int ret; | ||
1088 | ret = of_register_platform_driver(&mpc52xx_fec_mdio_driver); | ||
1089 | if (ret) { | ||
1090 | printk(KERN_ERR DRIVER_NAME ": failed to register mdio driver\n"); | ||
1091 | return ret; | ||
1092 | } | ||
1093 | #endif | ||
1094 | return of_register_platform_driver(&mpc52xx_fec_driver); | ||
1095 | } | ||
1096 | |||
1097 | static void __exit | ||
1098 | mpc52xx_fec_exit(void) | ||
1099 | { | ||
1100 | of_unregister_platform_driver(&mpc52xx_fec_driver); | ||
1101 | #ifdef CONFIG_FEC_MPC52xx_MDIO | ||
1102 | of_unregister_platform_driver(&mpc52xx_fec_mdio_driver); | ||
1103 | #endif | ||
1104 | } | ||
1105 | |||
1106 | |||
1107 | module_init(mpc52xx_fec_init); | ||
1108 | module_exit(mpc52xx_fec_exit); | ||
1109 | |||
1110 | MODULE_LICENSE("GPL"); | ||
1111 | MODULE_AUTHOR("Dale Farnsworth"); | ||
1112 | MODULE_DESCRIPTION("Ethernet driver for the Freescale MPC52xx FEC"); | ||
diff --git a/drivers/net/fec_mpc52xx.h b/drivers/net/fec_mpc52xx.h new file mode 100644 index 000000000000..8b1f75397b9a --- /dev/null +++ b/drivers/net/fec_mpc52xx.h | |||
@@ -0,0 +1,313 @@ | |||
1 | /* | ||
2 | * drivers/drivers/net/fec_mpc52xx/fec.h | ||
3 | * | ||
4 | * Driver for the MPC5200 Fast Ethernet Controller | ||
5 | * | ||
6 | * Author: Dale Farnsworth <dfarnsworth@mvista.com> | ||
7 | * | ||
8 | * 2003-2004 (c) MontaVista, Software, Inc. This file is licensed under | ||
9 | * the terms of the GNU General Public License version 2. This program | ||
10 | * is licensed "as is" without any warranty of any kind, whether express | ||
11 | * or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __DRIVERS_NET_MPC52XX_FEC_H__ | ||
15 | #define __DRIVERS_NET_MPC52XX_FEC_H__ | ||
16 | |||
17 | #include <linux/phy.h> | ||
18 | |||
19 | /* Tunable constant */ | ||
20 | /* FEC_RX_BUFFER_SIZE includes 4 bytes for CRC32 */ | ||
21 | #define FEC_RX_BUFFER_SIZE 1522 /* max receive packet size */ | ||
22 | #define FEC_RX_NUM_BD 256 | ||
23 | #define FEC_TX_NUM_BD 64 | ||
24 | |||
25 | #define FEC_RESET_DELAY 50 /* uS */ | ||
26 | |||
27 | #define FEC_WATCHDOG_TIMEOUT ((400*HZ)/1000) | ||
28 | |||
29 | struct mpc52xx_fec_priv { | ||
30 | int duplex; | ||
31 | int r_irq; | ||
32 | int t_irq; | ||
33 | struct mpc52xx_fec __iomem *fec; | ||
34 | struct bcom_task *rx_dmatsk; | ||
35 | struct bcom_task *tx_dmatsk; | ||
36 | spinlock_t lock; | ||
37 | int msg_enable; | ||
38 | |||
39 | int has_phy; | ||
40 | unsigned int phy_speed; | ||
41 | unsigned int phy_addr; | ||
42 | struct phy_device *phydev; | ||
43 | enum phy_state link; | ||
44 | int speed; | ||
45 | }; | ||
46 | |||
47 | |||
48 | /* ======================================================================== */ | ||
49 | /* Hardware register sets & bits */ | ||
50 | /* ======================================================================== */ | ||
51 | |||
52 | struct mpc52xx_fec { | ||
53 | u32 fec_id; /* FEC + 0x000 */ | ||
54 | u32 ievent; /* FEC + 0x004 */ | ||
55 | u32 imask; /* FEC + 0x008 */ | ||
56 | |||
57 | u32 reserved0[1]; /* FEC + 0x00C */ | ||
58 | u32 r_des_active; /* FEC + 0x010 */ | ||
59 | u32 x_des_active; /* FEC + 0x014 */ | ||
60 | u32 r_des_active_cl; /* FEC + 0x018 */ | ||
61 | u32 x_des_active_cl; /* FEC + 0x01C */ | ||
62 | u32 ivent_set; /* FEC + 0x020 */ | ||
63 | u32 ecntrl; /* FEC + 0x024 */ | ||
64 | |||
65 | u32 reserved1[6]; /* FEC + 0x028-03C */ | ||
66 | u32 mii_data; /* FEC + 0x040 */ | ||
67 | u32 mii_speed; /* FEC + 0x044 */ | ||
68 | u32 mii_status; /* FEC + 0x048 */ | ||
69 | |||
70 | u32 reserved2[5]; /* FEC + 0x04C-05C */ | ||
71 | u32 mib_data; /* FEC + 0x060 */ | ||
72 | u32 mib_control; /* FEC + 0x064 */ | ||
73 | |||
74 | u32 reserved3[6]; /* FEC + 0x068-7C */ | ||
75 | u32 r_activate; /* FEC + 0x080 */ | ||
76 | u32 r_cntrl; /* FEC + 0x084 */ | ||
77 | u32 r_hash; /* FEC + 0x088 */ | ||
78 | u32 r_data; /* FEC + 0x08C */ | ||
79 | u32 ar_done; /* FEC + 0x090 */ | ||
80 | u32 r_test; /* FEC + 0x094 */ | ||
81 | u32 r_mib; /* FEC + 0x098 */ | ||
82 | u32 r_da_low; /* FEC + 0x09C */ | ||
83 | u32 r_da_high; /* FEC + 0x0A0 */ | ||
84 | |||
85 | u32 reserved4[7]; /* FEC + 0x0A4-0BC */ | ||
86 | u32 x_activate; /* FEC + 0x0C0 */ | ||
87 | u32 x_cntrl; /* FEC + 0x0C4 */ | ||
88 | u32 backoff; /* FEC + 0x0C8 */ | ||
89 | u32 x_data; /* FEC + 0x0CC */ | ||
90 | u32 x_status; /* FEC + 0x0D0 */ | ||
91 | u32 x_mib; /* FEC + 0x0D4 */ | ||
92 | u32 x_test; /* FEC + 0x0D8 */ | ||
93 | u32 fdxfc_da1; /* FEC + 0x0DC */ | ||
94 | u32 fdxfc_da2; /* FEC + 0x0E0 */ | ||
95 | u32 paddr1; /* FEC + 0x0E4 */ | ||
96 | u32 paddr2; /* FEC + 0x0E8 */ | ||
97 | u32 op_pause; /* FEC + 0x0EC */ | ||
98 | |||
99 | u32 reserved5[4]; /* FEC + 0x0F0-0FC */ | ||
100 | u32 instr_reg; /* FEC + 0x100 */ | ||
101 | u32 context_reg; /* FEC + 0x104 */ | ||
102 | u32 test_cntrl; /* FEC + 0x108 */ | ||
103 | u32 acc_reg; /* FEC + 0x10C */ | ||
104 | u32 ones; /* FEC + 0x110 */ | ||
105 | u32 zeros; /* FEC + 0x114 */ | ||
106 | u32 iaddr1; /* FEC + 0x118 */ | ||
107 | u32 iaddr2; /* FEC + 0x11C */ | ||
108 | u32 gaddr1; /* FEC + 0x120 */ | ||
109 | u32 gaddr2; /* FEC + 0x124 */ | ||
110 | u32 random; /* FEC + 0x128 */ | ||
111 | u32 rand1; /* FEC + 0x12C */ | ||
112 | u32 tmp; /* FEC + 0x130 */ | ||
113 | |||
114 | u32 reserved6[3]; /* FEC + 0x134-13C */ | ||
115 | u32 fifo_id; /* FEC + 0x140 */ | ||
116 | u32 x_wmrk; /* FEC + 0x144 */ | ||
117 | u32 fcntrl; /* FEC + 0x148 */ | ||
118 | u32 r_bound; /* FEC + 0x14C */ | ||
119 | u32 r_fstart; /* FEC + 0x150 */ | ||
120 | u32 r_count; /* FEC + 0x154 */ | ||
121 | u32 r_lag; /* FEC + 0x158 */ | ||
122 | u32 r_read; /* FEC + 0x15C */ | ||
123 | u32 r_write; /* FEC + 0x160 */ | ||
124 | u32 x_count; /* FEC + 0x164 */ | ||
125 | u32 x_lag; /* FEC + 0x168 */ | ||
126 | u32 x_retry; /* FEC + 0x16C */ | ||
127 | u32 x_write; /* FEC + 0x170 */ | ||
128 | u32 x_read; /* FEC + 0x174 */ | ||
129 | |||
130 | u32 reserved7[2]; /* FEC + 0x178-17C */ | ||
131 | u32 fm_cntrl; /* FEC + 0x180 */ | ||
132 | u32 rfifo_data; /* FEC + 0x184 */ | ||
133 | u32 rfifo_status; /* FEC + 0x188 */ | ||
134 | u32 rfifo_cntrl; /* FEC + 0x18C */ | ||
135 | u32 rfifo_lrf_ptr; /* FEC + 0x190 */ | ||
136 | u32 rfifo_lwf_ptr; /* FEC + 0x194 */ | ||
137 | u32 rfifo_alarm; /* FEC + 0x198 */ | ||
138 | u32 rfifo_rdptr; /* FEC + 0x19C */ | ||
139 | u32 rfifo_wrptr; /* FEC + 0x1A0 */ | ||
140 | u32 tfifo_data; /* FEC + 0x1A4 */ | ||
141 | u32 tfifo_status; /* FEC + 0x1A8 */ | ||
142 | u32 tfifo_cntrl; /* FEC + 0x1AC */ | ||
143 | u32 tfifo_lrf_ptr; /* FEC + 0x1B0 */ | ||
144 | u32 tfifo_lwf_ptr; /* FEC + 0x1B4 */ | ||
145 | u32 tfifo_alarm; /* FEC + 0x1B8 */ | ||
146 | u32 tfifo_rdptr; /* FEC + 0x1BC */ | ||
147 | u32 tfifo_wrptr; /* FEC + 0x1C0 */ | ||
148 | |||
149 | u32 reset_cntrl; /* FEC + 0x1C4 */ | ||
150 | u32 xmit_fsm; /* FEC + 0x1C8 */ | ||
151 | |||
152 | u32 reserved8[3]; /* FEC + 0x1CC-1D4 */ | ||
153 | u32 rdes_data0; /* FEC + 0x1D8 */ | ||
154 | u32 rdes_data1; /* FEC + 0x1DC */ | ||
155 | u32 r_length; /* FEC + 0x1E0 */ | ||
156 | u32 x_length; /* FEC + 0x1E4 */ | ||
157 | u32 x_addr; /* FEC + 0x1E8 */ | ||
158 | u32 cdes_data; /* FEC + 0x1EC */ | ||
159 | u32 status; /* FEC + 0x1F0 */ | ||
160 | u32 dma_control; /* FEC + 0x1F4 */ | ||
161 | u32 des_cmnd; /* FEC + 0x1F8 */ | ||
162 | u32 data; /* FEC + 0x1FC */ | ||
163 | |||
164 | u32 rmon_t_drop; /* FEC + 0x200 */ | ||
165 | u32 rmon_t_packets; /* FEC + 0x204 */ | ||
166 | u32 rmon_t_bc_pkt; /* FEC + 0x208 */ | ||
167 | u32 rmon_t_mc_pkt; /* FEC + 0x20C */ | ||
168 | u32 rmon_t_crc_align; /* FEC + 0x210 */ | ||
169 | u32 rmon_t_undersize; /* FEC + 0x214 */ | ||
170 | u32 rmon_t_oversize; /* FEC + 0x218 */ | ||
171 | u32 rmon_t_frag; /* FEC + 0x21C */ | ||
172 | u32 rmon_t_jab; /* FEC + 0x220 */ | ||
173 | u32 rmon_t_col; /* FEC + 0x224 */ | ||
174 | u32 rmon_t_p64; /* FEC + 0x228 */ | ||
175 | u32 rmon_t_p65to127; /* FEC + 0x22C */ | ||
176 | u32 rmon_t_p128to255; /* FEC + 0x230 */ | ||
177 | u32 rmon_t_p256to511; /* FEC + 0x234 */ | ||
178 | u32 rmon_t_p512to1023; /* FEC + 0x238 */ | ||
179 | u32 rmon_t_p1024to2047; /* FEC + 0x23C */ | ||
180 | u32 rmon_t_p_gte2048; /* FEC + 0x240 */ | ||
181 | u32 rmon_t_octets; /* FEC + 0x244 */ | ||
182 | u32 ieee_t_drop; /* FEC + 0x248 */ | ||
183 | u32 ieee_t_frame_ok; /* FEC + 0x24C */ | ||
184 | u32 ieee_t_1col; /* FEC + 0x250 */ | ||
185 | u32 ieee_t_mcol; /* FEC + 0x254 */ | ||
186 | u32 ieee_t_def; /* FEC + 0x258 */ | ||
187 | u32 ieee_t_lcol; /* FEC + 0x25C */ | ||
188 | u32 ieee_t_excol; /* FEC + 0x260 */ | ||
189 | u32 ieee_t_macerr; /* FEC + 0x264 */ | ||
190 | u32 ieee_t_cserr; /* FEC + 0x268 */ | ||
191 | u32 ieee_t_sqe; /* FEC + 0x26C */ | ||
192 | u32 t_fdxfc; /* FEC + 0x270 */ | ||
193 | u32 ieee_t_octets_ok; /* FEC + 0x274 */ | ||
194 | |||
195 | u32 reserved9[2]; /* FEC + 0x278-27C */ | ||
196 | u32 rmon_r_drop; /* FEC + 0x280 */ | ||
197 | u32 rmon_r_packets; /* FEC + 0x284 */ | ||
198 | u32 rmon_r_bc_pkt; /* FEC + 0x288 */ | ||
199 | u32 rmon_r_mc_pkt; /* FEC + 0x28C */ | ||
200 | u32 rmon_r_crc_align; /* FEC + 0x290 */ | ||
201 | u32 rmon_r_undersize; /* FEC + 0x294 */ | ||
202 | u32 rmon_r_oversize; /* FEC + 0x298 */ | ||
203 | u32 rmon_r_frag; /* FEC + 0x29C */ | ||
204 | u32 rmon_r_jab; /* FEC + 0x2A0 */ | ||
205 | |||
206 | u32 rmon_r_resvd_0; /* FEC + 0x2A4 */ | ||
207 | |||
208 | u32 rmon_r_p64; /* FEC + 0x2A8 */ | ||
209 | u32 rmon_r_p65to127; /* FEC + 0x2AC */ | ||
210 | u32 rmon_r_p128to255; /* FEC + 0x2B0 */ | ||
211 | u32 rmon_r_p256to511; /* FEC + 0x2B4 */ | ||
212 | u32 rmon_r_p512to1023; /* FEC + 0x2B8 */ | ||
213 | u32 rmon_r_p1024to2047; /* FEC + 0x2BC */ | ||
214 | u32 rmon_r_p_gte2048; /* FEC + 0x2C0 */ | ||
215 | u32 rmon_r_octets; /* FEC + 0x2C4 */ | ||
216 | u32 ieee_r_drop; /* FEC + 0x2C8 */ | ||
217 | u32 ieee_r_frame_ok; /* FEC + 0x2CC */ | ||
218 | u32 ieee_r_crc; /* FEC + 0x2D0 */ | ||
219 | u32 ieee_r_align; /* FEC + 0x2D4 */ | ||
220 | u32 r_macerr; /* FEC + 0x2D8 */ | ||
221 | u32 r_fdxfc; /* FEC + 0x2DC */ | ||
222 | u32 ieee_r_octets_ok; /* FEC + 0x2E0 */ | ||
223 | |||
224 | u32 reserved10[7]; /* FEC + 0x2E4-2FC */ | ||
225 | |||
226 | u32 reserved11[64]; /* FEC + 0x300-3FF */ | ||
227 | }; | ||
228 | |||
229 | #define FEC_MIB_DISABLE 0x80000000 | ||
230 | |||
231 | #define FEC_IEVENT_HBERR 0x80000000 | ||
232 | #define FEC_IEVENT_BABR 0x40000000 | ||
233 | #define FEC_IEVENT_BABT 0x20000000 | ||
234 | #define FEC_IEVENT_GRA 0x10000000 | ||
235 | #define FEC_IEVENT_TFINT 0x08000000 | ||
236 | #define FEC_IEVENT_MII 0x00800000 | ||
237 | #define FEC_IEVENT_LATE_COL 0x00200000 | ||
238 | #define FEC_IEVENT_COL_RETRY_LIM 0x00100000 | ||
239 | #define FEC_IEVENT_XFIFO_UN 0x00080000 | ||
240 | #define FEC_IEVENT_XFIFO_ERROR 0x00040000 | ||
241 | #define FEC_IEVENT_RFIFO_ERROR 0x00020000 | ||
242 | |||
243 | #define FEC_IMASK_HBERR 0x80000000 | ||
244 | #define FEC_IMASK_BABR 0x40000000 | ||
245 | #define FEC_IMASK_BABT 0x20000000 | ||
246 | #define FEC_IMASK_GRA 0x10000000 | ||
247 | #define FEC_IMASK_MII 0x00800000 | ||
248 | #define FEC_IMASK_LATE_COL 0x00200000 | ||
249 | #define FEC_IMASK_COL_RETRY_LIM 0x00100000 | ||
250 | #define FEC_IMASK_XFIFO_UN 0x00080000 | ||
251 | #define FEC_IMASK_XFIFO_ERROR 0x00040000 | ||
252 | #define FEC_IMASK_RFIFO_ERROR 0x00020000 | ||
253 | |||
254 | /* all but MII, which is enabled separately */ | ||
255 | #define FEC_IMASK_ENABLE (FEC_IMASK_HBERR | FEC_IMASK_BABR | \ | ||
256 | FEC_IMASK_BABT | FEC_IMASK_GRA | FEC_IMASK_LATE_COL | \ | ||
257 | FEC_IMASK_COL_RETRY_LIM | FEC_IMASK_XFIFO_UN | \ | ||
258 | FEC_IMASK_XFIFO_ERROR | FEC_IMASK_RFIFO_ERROR) | ||
259 | |||
260 | #define FEC_RCNTRL_MAX_FL_SHIFT 16 | ||
261 | #define FEC_RCNTRL_LOOP 0x01 | ||
262 | #define FEC_RCNTRL_DRT 0x02 | ||
263 | #define FEC_RCNTRL_MII_MODE 0x04 | ||
264 | #define FEC_RCNTRL_PROM 0x08 | ||
265 | #define FEC_RCNTRL_BC_REJ 0x10 | ||
266 | #define FEC_RCNTRL_FCE 0x20 | ||
267 | |||
268 | #define FEC_TCNTRL_GTS 0x00000001 | ||
269 | #define FEC_TCNTRL_HBC 0x00000002 | ||
270 | #define FEC_TCNTRL_FDEN 0x00000004 | ||
271 | #define FEC_TCNTRL_TFC_PAUSE 0x00000008 | ||
272 | #define FEC_TCNTRL_RFC_PAUSE 0x00000010 | ||
273 | |||
274 | #define FEC_ECNTRL_RESET 0x00000001 | ||
275 | #define FEC_ECNTRL_ETHER_EN 0x00000002 | ||
276 | |||
277 | #define FEC_MII_DATA_ST 0x40000000 /* Start frame */ | ||
278 | #define FEC_MII_DATA_OP_RD 0x20000000 /* Perform read */ | ||
279 | #define FEC_MII_DATA_OP_WR 0x10000000 /* Perform write */ | ||
280 | #define FEC_MII_DATA_PA_MSK 0x0f800000 /* PHY Address mask */ | ||
281 | #define FEC_MII_DATA_RA_MSK 0x007c0000 /* PHY Register mask */ | ||
282 | #define FEC_MII_DATA_TA 0x00020000 /* Turnaround */ | ||
283 | #define FEC_MII_DATA_DATAMSK 0x0000ffff /* PHY data mask */ | ||
284 | |||
285 | #define FEC_MII_READ_FRAME (FEC_MII_DATA_ST | FEC_MII_DATA_OP_RD | FEC_MII_DATA_TA) | ||
286 | #define FEC_MII_WRITE_FRAME (FEC_MII_DATA_ST | FEC_MII_DATA_OP_WR | FEC_MII_DATA_TA) | ||
287 | |||
288 | #define FEC_MII_DATA_RA_SHIFT 0x12 /* MII reg addr bits */ | ||
289 | #define FEC_MII_DATA_PA_SHIFT 0x17 /* MII PHY addr bits */ | ||
290 | |||
291 | #define FEC_PADDR2_TYPE 0x8808 | ||
292 | |||
293 | #define FEC_OP_PAUSE_OPCODE 0x00010000 | ||
294 | |||
295 | #define FEC_FIFO_WMRK_256B 0x3 | ||
296 | |||
297 | #define FEC_FIFO_STATUS_ERR 0x00400000 | ||
298 | #define FEC_FIFO_STATUS_UF 0x00200000 | ||
299 | #define FEC_FIFO_STATUS_OF 0x00100000 | ||
300 | |||
301 | #define FEC_FIFO_CNTRL_FRAME 0x08000000 | ||
302 | #define FEC_FIFO_CNTRL_LTG_7 0x07000000 | ||
303 | |||
304 | #define FEC_RESET_CNTRL_RESET_FIFO 0x02000000 | ||
305 | #define FEC_RESET_CNTRL_ENABLE_IS_RESET 0x01000000 | ||
306 | |||
307 | #define FEC_XMIT_FSM_APPEND_CRC 0x02000000 | ||
308 | #define FEC_XMIT_FSM_ENABLE_CRC 0x01000000 | ||
309 | |||
310 | |||
311 | extern struct of_platform_driver mpc52xx_fec_mdio_driver; | ||
312 | |||
313 | #endif /* __DRIVERS_NET_MPC52XX_FEC_H__ */ | ||
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c new file mode 100644 index 000000000000..ba6e8b218e0a --- /dev/null +++ b/drivers/net/fec_mpc52xx_phy.c | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | * Driver for the MPC5200 Fast Ethernet Controller - MDIO bus driver | ||
3 | * | ||
4 | * Copyright (C) 2007 Domen Puncer, Telargo, Inc. | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public License | ||
7 | * version 2. This program is licensed "as is" without any warranty of any | ||
8 | * kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/netdevice.h> | ||
14 | #include <linux/phy.h> | ||
15 | #include <linux/of_platform.h> | ||
16 | #include <asm/io.h> | ||
17 | #include <asm/mpc52xx.h> | ||
18 | #include "fec_mpc52xx.h" | ||
19 | |||
20 | struct mpc52xx_fec_mdio_priv { | ||
21 | struct mpc52xx_fec __iomem *regs; | ||
22 | }; | ||
23 | |||
24 | static int mpc52xx_fec_mdio_read(struct mii_bus *bus, int phy_id, int reg) | ||
25 | { | ||
26 | struct mpc52xx_fec_mdio_priv *priv = bus->priv; | ||
27 | struct mpc52xx_fec __iomem *fec; | ||
28 | int tries = 100; | ||
29 | u32 request = FEC_MII_READ_FRAME; | ||
30 | |||
31 | fec = priv->regs; | ||
32 | out_be32(&fec->ievent, FEC_IEVENT_MII); | ||
33 | |||
34 | request |= (phy_id << FEC_MII_DATA_PA_SHIFT) & FEC_MII_DATA_PA_MSK; | ||
35 | request |= (reg << FEC_MII_DATA_RA_SHIFT) & FEC_MII_DATA_RA_MSK; | ||
36 | |||
37 | out_be32(&priv->regs->mii_data, request); | ||
38 | |||
39 | /* wait for it to finish, this takes about 23 us on lite5200b */ | ||
40 | while (!(in_be32(&fec->ievent) & FEC_IEVENT_MII) && --tries) | ||
41 | udelay(5); | ||
42 | |||
43 | if (tries == 0) | ||
44 | return -ETIMEDOUT; | ||
45 | |||
46 | return in_be32(&priv->regs->mii_data) & FEC_MII_DATA_DATAMSK; | ||
47 | } | ||
48 | |||
49 | static int mpc52xx_fec_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 data) | ||
50 | { | ||
51 | struct mpc52xx_fec_mdio_priv *priv = bus->priv; | ||
52 | struct mpc52xx_fec __iomem *fec; | ||
53 | u32 value = data; | ||
54 | int tries = 100; | ||
55 | |||
56 | fec = priv->regs; | ||
57 | out_be32(&fec->ievent, FEC_IEVENT_MII); | ||
58 | |||
59 | value |= FEC_MII_WRITE_FRAME; | ||
60 | value |= (phy_id << FEC_MII_DATA_PA_SHIFT) & FEC_MII_DATA_PA_MSK; | ||
61 | value |= (reg << FEC_MII_DATA_RA_SHIFT) & FEC_MII_DATA_RA_MSK; | ||
62 | |||
63 | out_be32(&priv->regs->mii_data, value); | ||
64 | |||
65 | /* wait for request to finish */ | ||
66 | while (!(in_be32(&fec->ievent) & FEC_IEVENT_MII) && --tries) | ||
67 | udelay(5); | ||
68 | |||
69 | if (tries == 0) | ||
70 | return -ETIMEDOUT; | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static int mpc52xx_fec_mdio_probe(struct of_device *of, const struct of_device_id *match) | ||
76 | { | ||
77 | struct device *dev = &of->dev; | ||
78 | struct device_node *np = of->node; | ||
79 | struct device_node *child = NULL; | ||
80 | struct mii_bus *bus; | ||
81 | struct mpc52xx_fec_mdio_priv *priv; | ||
82 | struct resource res = {}; | ||
83 | int err; | ||
84 | int i; | ||
85 | |||
86 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); | ||
87 | if (bus == NULL) | ||
88 | return -ENOMEM; | ||
89 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
90 | if (priv == NULL) { | ||
91 | err = -ENOMEM; | ||
92 | goto out_free; | ||
93 | } | ||
94 | |||
95 | bus->name = "mpc52xx MII bus"; | ||
96 | bus->read = mpc52xx_fec_mdio_read; | ||
97 | bus->write = mpc52xx_fec_mdio_write; | ||
98 | |||
99 | /* setup irqs */ | ||
100 | bus->irq = kmalloc(sizeof(bus->irq[0]) * PHY_MAX_ADDR, GFP_KERNEL); | ||
101 | if (bus->irq == NULL) { | ||
102 | err = -ENOMEM; | ||
103 | goto out_free; | ||
104 | } | ||
105 | for (i=0; i<PHY_MAX_ADDR; i++) | ||
106 | bus->irq[i] = PHY_POLL; | ||
107 | |||
108 | while ((child = of_get_next_child(np, child)) != NULL) { | ||
109 | int irq = irq_of_parse_and_map(child, 0); | ||
110 | if (irq != NO_IRQ) { | ||
111 | const u32 *id = of_get_property(child, "reg", NULL); | ||
112 | bus->irq[*id] = irq; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | /* setup registers */ | ||
117 | err = of_address_to_resource(np, 0, &res); | ||
118 | if (err) | ||
119 | goto out_free; | ||
120 | priv->regs = ioremap(res.start, res.end - res.start + 1); | ||
121 | if (priv->regs == NULL) { | ||
122 | err = -ENOMEM; | ||
123 | goto out_free; | ||
124 | } | ||
125 | |||
126 | bus->id = res.start; | ||
127 | bus->priv = priv; | ||
128 | |||
129 | bus->dev = dev; | ||
130 | dev_set_drvdata(dev, bus); | ||
131 | |||
132 | /* set MII speed */ | ||
133 | out_be32(&priv->regs->mii_speed, ((mpc52xx_find_ipb_freq(of->node) >> 20) / 5) << 1); | ||
134 | |||
135 | /* enable MII interrupt */ | ||
136 | out_be32(&priv->regs->imask, in_be32(&priv->regs->imask) | FEC_IMASK_MII); | ||
137 | |||
138 | err = mdiobus_register(bus); | ||
139 | if (err) | ||
140 | goto out_unmap; | ||
141 | |||
142 | return 0; | ||
143 | |||
144 | out_unmap: | ||
145 | iounmap(priv->regs); | ||
146 | out_free: | ||
147 | for (i=0; i<PHY_MAX_ADDR; i++) | ||
148 | if (bus->irq[i] != PHY_POLL) | ||
149 | irq_dispose_mapping(bus->irq[i]); | ||
150 | kfree(bus->irq); | ||
151 | kfree(priv); | ||
152 | kfree(bus); | ||
153 | |||
154 | return err; | ||
155 | } | ||
156 | |||
157 | static int mpc52xx_fec_mdio_remove(struct of_device *of) | ||
158 | { | ||
159 | struct device *dev = &of->dev; | ||
160 | struct mii_bus *bus = dev_get_drvdata(dev); | ||
161 | struct mpc52xx_fec_mdio_priv *priv = bus->priv; | ||
162 | int i; | ||
163 | |||
164 | mdiobus_unregister(bus); | ||
165 | dev_set_drvdata(dev, NULL); | ||
166 | |||
167 | iounmap(priv->regs); | ||
168 | for (i=0; i<PHY_MAX_ADDR; i++) | ||
169 | if (bus->irq[i]) | ||
170 | irq_dispose_mapping(bus->irq[i]); | ||
171 | kfree(priv); | ||
172 | kfree(bus->irq); | ||
173 | kfree(bus); | ||
174 | |||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | |||
179 | static struct of_device_id mpc52xx_fec_mdio_match[] = { | ||
180 | { | ||
181 | .type = "mdio", | ||
182 | .compatible = "mpc5200b-fec-phy", | ||
183 | }, | ||
184 | {}, | ||
185 | }; | ||
186 | |||
187 | struct of_platform_driver mpc52xx_fec_mdio_driver = { | ||
188 | .name = "mpc5200b-fec-phy", | ||
189 | .probe = mpc52xx_fec_mdio_probe, | ||
190 | .remove = mpc52xx_fec_mdio_remove, | ||
191 | .match_table = mpc52xx_fec_mdio_match, | ||
192 | }; | ||
193 | |||
194 | /* let fec driver call it, since this has to be registered before it */ | ||
195 | EXPORT_SYMBOL_GPL(mpc52xx_fec_mdio_driver); | ||
196 | |||
197 | |||
198 | MODULE_LICENSE("Dual BSD/GPL"); | ||
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 70ddf1acfd88..92ce2e38f0d5 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -5597,6 +5597,22 @@ static struct pci_device_id pci_tbl[] = { | |||
5597 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_31), | 5597 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_31), |
5598 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, | 5598 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, |
5599 | }, | 5599 | }, |
5600 | { /* MCP77 Ethernet Controller */ | ||
5601 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_32), | ||
5602 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, | ||
5603 | }, | ||
5604 | { /* MCP77 Ethernet Controller */ | ||
5605 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_33), | ||
5606 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, | ||
5607 | }, | ||
5608 | { /* MCP77 Ethernet Controller */ | ||
5609 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_34), | ||
5610 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, | ||
5611 | }, | ||
5612 | { /* MCP77 Ethernet Controller */ | ||
5613 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_35), | ||
5614 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, | ||
5615 | }, | ||
5600 | {0,}, | 5616 | {0,}, |
5601 | }; | 5617 | }; |
5602 | 5618 | ||
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c index 68887235d7e9..dbd23bb65d1e 100644 --- a/drivers/net/ipg.c +++ b/drivers/net/ipg.c | |||
@@ -55,6 +55,26 @@ MODULE_DESCRIPTION("IC Plus IP1000 Gigabit Ethernet Adapter Linux Driver " | |||
55 | DrvVer); | 55 | DrvVer); |
56 | MODULE_LICENSE("GPL"); | 56 | MODULE_LICENSE("GPL"); |
57 | 57 | ||
58 | //variable record -- index by leading revision/length | ||
59 | //Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN | ||
60 | static unsigned short DefaultPhyParam[] = { | ||
61 | // 11/12/03 IP1000A v1-3 rev=0x40 | ||
62 | /*-------------------------------------------------------------------------- | ||
63 | (0x4000|(15*4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 22, 0x85bd, 24, 0xfff2, | ||
64 | 27, 0x0c10, 28, 0x0c10, 29, 0x2c10, 31, 0x0003, 23, 0x92f6, | ||
65 | 31, 0x0000, 23, 0x003d, 30, 0x00de, 20, 0x20e7, 9, 0x0700, | ||
66 | --------------------------------------------------------------------------*/ | ||
67 | // 12/17/03 IP1000A v1-4 rev=0x40 | ||
68 | (0x4000 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, | ||
69 | 0x0000, | ||
70 | 30, 0x005e, 9, 0x0700, | ||
71 | // 01/09/04 IP1000A v1-5 rev=0x41 | ||
72 | (0x4100 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, | ||
73 | 0x0000, | ||
74 | 30, 0x005e, 9, 0x0700, | ||
75 | 0x0000 | ||
76 | }; | ||
77 | |||
58 | static const char *ipg_brand_name[] = { | 78 | static const char *ipg_brand_name[] = { |
59 | "IC PLUS IP1000 1000/100/10 based NIC", | 79 | "IC PLUS IP1000 1000/100/10 based NIC", |
60 | "Sundance Technology ST2021 based NIC", | 80 | "Sundance Technology ST2021 based NIC", |
@@ -990,7 +1010,7 @@ static void ipg_nic_txcleanup(struct net_device *dev) | |||
990 | } | 1010 | } |
991 | 1011 | ||
992 | /* Provides statistical information about the IPG NIC. */ | 1012 | /* Provides statistical information about the IPG NIC. */ |
993 | struct net_device_stats *ipg_nic_get_stats(struct net_device *dev) | 1013 | static struct net_device_stats *ipg_nic_get_stats(struct net_device *dev) |
994 | { | 1014 | { |
995 | struct ipg_nic_private *sp = netdev_priv(dev); | 1015 | struct ipg_nic_private *sp = netdev_priv(dev); |
996 | void __iomem *ioaddr = sp->ioaddr; | 1016 | void __iomem *ioaddr = sp->ioaddr; |
diff --git a/drivers/net/ipg.h b/drivers/net/ipg.h index e418b9035cac..d5d092c9d0af 100644 --- a/drivers/net/ipg.h +++ b/drivers/net/ipg.h | |||
@@ -833,24 +833,4 @@ struct ipg_nic_private { | |||
833 | struct delayed_work task; | 833 | struct delayed_work task; |
834 | }; | 834 | }; |
835 | 835 | ||
836 | //variable record -- index by leading revision/length | ||
837 | //Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN | ||
838 | unsigned short DefaultPhyParam[] = { | ||
839 | // 11/12/03 IP1000A v1-3 rev=0x40 | ||
840 | /*-------------------------------------------------------------------------- | ||
841 | (0x4000|(15*4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 22, 0x85bd, 24, 0xfff2, | ||
842 | 27, 0x0c10, 28, 0x0c10, 29, 0x2c10, 31, 0x0003, 23, 0x92f6, | ||
843 | 31, 0x0000, 23, 0x003d, 30, 0x00de, 20, 0x20e7, 9, 0x0700, | ||
844 | --------------------------------------------------------------------------*/ | ||
845 | // 12/17/03 IP1000A v1-4 rev=0x40 | ||
846 | (0x4000 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, | ||
847 | 0x0000, | ||
848 | 30, 0x005e, 9, 0x0700, | ||
849 | // 01/09/04 IP1000A v1-5 rev=0x41 | ||
850 | (0x4100 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, | ||
851 | 0x0000, | ||
852 | 30, 0x005e, 9, 0x0700, | ||
853 | 0x0000 | ||
854 | }; | ||
855 | |||
856 | #endif /* __LINUX_IPG_H */ | 836 | #endif /* __LINUX_IPG_H */ |
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c index 4dbdfaaf37bf..a1e4508717c8 100644 --- a/drivers/net/irda/au1k_ir.c +++ b/drivers/net/irda/au1k_ir.c | |||
@@ -627,19 +627,16 @@ static int au1k_irda_rx(struct net_device *dev) | |||
627 | } | 627 | } |
628 | 628 | ||
629 | 629 | ||
630 | void au1k_irda_interrupt(int irq, void *dev_id) | 630 | static irqreturn_t au1k_irda_interrupt(int dummy, void *dev_id) |
631 | { | 631 | { |
632 | struct net_device *dev = (struct net_device *) dev_id; | 632 | struct net_device *dev = dev_id; |
633 | |||
634 | if (dev == NULL) { | ||
635 | printk(KERN_ERR "%s: isr: null dev ptr\n", dev->name); | ||
636 | return; | ||
637 | } | ||
638 | 633 | ||
639 | writel(0, IR_INT_CLEAR); /* ack irda interrupts */ | 634 | writel(0, IR_INT_CLEAR); /* ack irda interrupts */ |
640 | 635 | ||
641 | au1k_irda_rx(dev); | 636 | au1k_irda_rx(dev); |
642 | au1k_tx_ack(dev); | 637 | au1k_tx_ack(dev); |
638 | |||
639 | return IRQ_HANDLED; | ||
643 | } | 640 | } |
644 | 641 | ||
645 | 642 | ||
diff --git a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h index 1eee8894c732..3d2e7217e9af 100644 --- a/drivers/net/ixgb/ixgb.h +++ b/drivers/net/ixgb/ixgb.h | |||
@@ -196,4 +196,11 @@ struct ixgb_adapter { | |||
196 | uint32_t alloc_rx_buff_failed; | 196 | uint32_t alloc_rx_buff_failed; |
197 | boolean_t have_msi; | 197 | boolean_t have_msi; |
198 | }; | 198 | }; |
199 | |||
200 | /* Exported from other modules */ | ||
201 | extern void ixgb_check_options(struct ixgb_adapter *adapter); | ||
202 | extern void ixgb_set_ethtool_ops(struct net_device *netdev); | ||
203 | extern char ixgb_driver_name[]; | ||
204 | extern const char ixgb_driver_version[]; | ||
205 | |||
199 | #endif /* _IXGB_H_ */ | 206 | #endif /* _IXGB_H_ */ |
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c index fddd5844168d..a267dd862520 100644 --- a/drivers/net/ixgb/ixgb_ethtool.c +++ b/drivers/net/ixgb/ixgb_ethtool.c | |||
@@ -32,9 +32,6 @@ | |||
32 | 32 | ||
33 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
34 | 34 | ||
35 | extern char ixgb_driver_name[]; | ||
36 | extern char ixgb_driver_version[]; | ||
37 | |||
38 | extern int ixgb_up(struct ixgb_adapter *adapter); | 35 | extern int ixgb_up(struct ixgb_adapter *adapter); |
39 | extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog); | 36 | extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog); |
40 | extern void ixgb_reset(struct ixgb_adapter *adapter); | 37 | extern void ixgb_reset(struct ixgb_adapter *adapter); |
@@ -639,8 +636,8 @@ ixgb_phys_id(struct net_device *netdev, uint32_t data) | |||
639 | { | 636 | { |
640 | struct ixgb_adapter *adapter = netdev_priv(netdev); | 637 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
641 | 638 | ||
642 | if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ)) | 639 | if (!data) |
643 | data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ); | 640 | data = INT_MAX; |
644 | 641 | ||
645 | if(!adapter->blink_timer.function) { | 642 | if(!adapter->blink_timer.function) { |
646 | init_timer(&adapter->blink_timer); | 643 | init_timer(&adapter->blink_timer); |
diff --git a/drivers/net/ixgb/ixgb_hw.c b/drivers/net/ixgb/ixgb_hw.c index ecbf45861c68..2c6367ace3cd 100644 --- a/drivers/net/ixgb/ixgb_hw.c +++ b/drivers/net/ixgb/ixgb_hw.c | |||
@@ -1174,7 +1174,7 @@ mac_addr_valid(uint8_t *mac_addr) | |||
1174 | * | 1174 | * |
1175 | * hw - Struct containing variables accessed by shared code | 1175 | * hw - Struct containing variables accessed by shared code |
1176 | *****************************************************************************/ | 1176 | *****************************************************************************/ |
1177 | boolean_t | 1177 | static boolean_t |
1178 | ixgb_link_reset(struct ixgb_hw *hw) | 1178 | ixgb_link_reset(struct ixgb_hw *hw) |
1179 | { | 1179 | { |
1180 | boolean_t link_status = FALSE; | 1180 | boolean_t link_status = FALSE; |
@@ -1205,7 +1205,7 @@ ixgb_link_reset(struct ixgb_hw *hw) | |||
1205 | * | 1205 | * |
1206 | * hw - Struct containing variables accessed by shared code | 1206 | * hw - Struct containing variables accessed by shared code |
1207 | *****************************************************************************/ | 1207 | *****************************************************************************/ |
1208 | void | 1208 | static void |
1209 | ixgb_optics_reset(struct ixgb_hw *hw) | 1209 | ixgb_optics_reset(struct ixgb_hw *hw) |
1210 | { | 1210 | { |
1211 | if (hw->phy_type == ixgb_phy_type_txn17401) { | 1211 | if (hw->phy_type == ixgb_phy_type_txn17401) { |
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c index d444de58ba34..3021234b1e17 100644 --- a/drivers/net/ixgb/ixgb_main.c +++ b/drivers/net/ixgb/ixgb_main.c | |||
@@ -37,8 +37,8 @@ static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver"; | |||
37 | #define DRIVERNAPI "-NAPI" | 37 | #define DRIVERNAPI "-NAPI" |
38 | #endif | 38 | #endif |
39 | #define DRV_VERSION "1.0.126-k2"DRIVERNAPI | 39 | #define DRV_VERSION "1.0.126-k2"DRIVERNAPI |
40 | char ixgb_driver_version[] = DRV_VERSION; | 40 | const char ixgb_driver_version[] = DRV_VERSION; |
41 | static char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; | 41 | static const char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; |
42 | 42 | ||
43 | /* ixgb_pci_tbl - PCI Device ID Table | 43 | /* ixgb_pci_tbl - PCI Device ID Table |
44 | * | 44 | * |
@@ -104,7 +104,6 @@ static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter, | |||
104 | static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter); | 104 | static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter); |
105 | #endif | 105 | #endif |
106 | static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter); | 106 | static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter); |
107 | void ixgb_set_ethtool_ops(struct net_device *netdev); | ||
108 | static void ixgb_tx_timeout(struct net_device *dev); | 107 | static void ixgb_tx_timeout(struct net_device *dev); |
109 | static void ixgb_tx_timeout_task(struct work_struct *work); | 108 | static void ixgb_tx_timeout_task(struct work_struct *work); |
110 | static void ixgb_vlan_rx_register(struct net_device *netdev, | 109 | static void ixgb_vlan_rx_register(struct net_device *netdev, |
@@ -123,9 +122,6 @@ static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev, | |||
123 | static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev); | 122 | static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev); |
124 | static void ixgb_io_resume (struct pci_dev *pdev); | 123 | static void ixgb_io_resume (struct pci_dev *pdev); |
125 | 124 | ||
126 | /* Exported from other modules */ | ||
127 | extern void ixgb_check_options(struct ixgb_adapter *adapter); | ||
128 | |||
129 | static struct pci_error_handlers ixgb_err_handler = { | 125 | static struct pci_error_handlers ixgb_err_handler = { |
130 | .error_detected = ixgb_io_error_detected, | 126 | .error_detected = ixgb_io_error_detected, |
131 | .slot_reset = ixgb_io_slot_reset, | 127 | .slot_reset = ixgb_io_slot_reset, |
@@ -1085,7 +1081,8 @@ ixgb_set_multi(struct net_device *netdev) | |||
1085 | rctl |= IXGB_RCTL_MPE; | 1081 | rctl |= IXGB_RCTL_MPE; |
1086 | IXGB_WRITE_REG(hw, RCTL, rctl); | 1082 | IXGB_WRITE_REG(hw, RCTL, rctl); |
1087 | } else { | 1083 | } else { |
1088 | uint8_t mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS]; | 1084 | uint8_t mta[IXGB_MAX_NUM_MULTICAST_ADDRESSES * |
1085 | IXGB_ETH_LENGTH_OF_ADDRESS]; | ||
1089 | 1086 | ||
1090 | IXGB_WRITE_REG(hw, RCTL, rctl); | 1087 | IXGB_WRITE_REG(hw, RCTL, rctl); |
1091 | 1088 | ||
@@ -1324,8 +1321,8 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb, | |||
1324 | 1321 | ||
1325 | /* Workaround for premature desc write-backs | 1322 | /* Workaround for premature desc write-backs |
1326 | * in TSO mode. Append 4-byte sentinel desc */ | 1323 | * in TSO mode. Append 4-byte sentinel desc */ |
1327 | if (unlikely(mss && !nr_frags && size == len | 1324 | if (unlikely(mss && (f == (nr_frags - 1)) |
1328 | && size > 8)) | 1325 | && size == len && size > 8)) |
1329 | size -= 4; | 1326 | size -= 4; |
1330 | 1327 | ||
1331 | buffer_info->length = size; | 1328 | buffer_info->length = size; |
diff --git a/drivers/net/ixgb/ixgb_param.c b/drivers/net/ixgb/ixgb_param.c index 5d5ddabf4360..865d14d6e5a7 100644 --- a/drivers/net/ixgb/ixgb_param.c +++ b/drivers/net/ixgb/ixgb_param.c | |||
@@ -44,10 +44,11 @@ | |||
44 | */ | 44 | */ |
45 | 45 | ||
46 | #define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET } | 46 | #define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET } |
47 | #define IXGB_PARAM(X, desc) \ | 47 | #define IXGB_PARAM(X, desc) \ |
48 | static int __devinitdata X[IXGB_MAX_NIC+1] = IXGB_PARAM_INIT; \ | 48 | static int __devinitdata X[IXGB_MAX_NIC+1] \ |
49 | static int num_##X = 0; \ | 49 | = IXGB_PARAM_INIT; \ |
50 | module_param_array_named(X, X, int, &num_##X, 0); \ | 50 | static unsigned int num_##X = 0; \ |
51 | module_param_array_named(X, X, int, &num_##X, 0); \ | ||
51 | MODULE_PARM_DESC(X, desc); | 52 | MODULE_PARM_DESC(X, desc); |
52 | 53 | ||
53 | /* Transmit Descriptor Count | 54 | /* Transmit Descriptor Count |
@@ -178,8 +179,8 @@ IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable"); | |||
178 | 179 | ||
179 | struct ixgb_option { | 180 | struct ixgb_option { |
180 | enum { enable_option, range_option, list_option } type; | 181 | enum { enable_option, range_option, list_option } type; |
181 | char *name; | 182 | const char *name; |
182 | char *err; | 183 | const char *err; |
183 | int def; | 184 | int def; |
184 | union { | 185 | union { |
185 | struct { /* range_option info */ | 186 | struct { /* range_option info */ |
@@ -197,7 +198,7 @@ struct ixgb_option { | |||
197 | }; | 198 | }; |
198 | 199 | ||
199 | static int __devinit | 200 | static int __devinit |
200 | ixgb_validate_option(int *value, struct ixgb_option *opt) | 201 | ixgb_validate_option(unsigned int *value, const struct ixgb_option *opt) |
201 | { | 202 | { |
202 | if(*value == OPTION_UNSET) { | 203 | if(*value == OPTION_UNSET) { |
203 | *value = opt->def; | 204 | *value = opt->def; |
@@ -266,7 +267,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
266 | } | 267 | } |
267 | 268 | ||
268 | { /* Transmit Descriptor Count */ | 269 | { /* Transmit Descriptor Count */ |
269 | struct ixgb_option opt = { | 270 | const struct ixgb_option opt = { |
270 | .type = range_option, | 271 | .type = range_option, |
271 | .name = "Transmit Descriptors", | 272 | .name = "Transmit Descriptors", |
272 | .err = "using default of " __MODULE_STRING(DEFAULT_TXD), | 273 | .err = "using default of " __MODULE_STRING(DEFAULT_TXD), |
@@ -285,7 +286,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
285 | tx_ring->count = ALIGN(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE); | 286 | tx_ring->count = ALIGN(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE); |
286 | } | 287 | } |
287 | { /* Receive Descriptor Count */ | 288 | { /* Receive Descriptor Count */ |
288 | struct ixgb_option opt = { | 289 | const struct ixgb_option opt = { |
289 | .type = range_option, | 290 | .type = range_option, |
290 | .name = "Receive Descriptors", | 291 | .name = "Receive Descriptors", |
291 | .err = "using default of " __MODULE_STRING(DEFAULT_RXD), | 292 | .err = "using default of " __MODULE_STRING(DEFAULT_RXD), |
@@ -304,7 +305,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
304 | rx_ring->count = ALIGN(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE); | 305 | rx_ring->count = ALIGN(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE); |
305 | } | 306 | } |
306 | { /* Receive Checksum Offload Enable */ | 307 | { /* Receive Checksum Offload Enable */ |
307 | struct ixgb_option opt = { | 308 | const struct ixgb_option opt = { |
308 | .type = enable_option, | 309 | .type = enable_option, |
309 | .name = "Receive Checksum Offload", | 310 | .name = "Receive Checksum Offload", |
310 | .err = "defaulting to Enabled", | 311 | .err = "defaulting to Enabled", |
@@ -312,7 +313,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
312 | }; | 313 | }; |
313 | 314 | ||
314 | if(num_XsumRX > bd) { | 315 | if(num_XsumRX > bd) { |
315 | int rx_csum = XsumRX[bd]; | 316 | unsigned int rx_csum = XsumRX[bd]; |
316 | ixgb_validate_option(&rx_csum, &opt); | 317 | ixgb_validate_option(&rx_csum, &opt); |
317 | adapter->rx_csum = rx_csum; | 318 | adapter->rx_csum = rx_csum; |
318 | } else { | 319 | } else { |
@@ -328,7 +329,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
328 | { ixgb_fc_full, "Flow Control Enabled" }, | 329 | { ixgb_fc_full, "Flow Control Enabled" }, |
329 | { ixgb_fc_default, "Flow Control Hardware Default" }}; | 330 | { ixgb_fc_default, "Flow Control Hardware Default" }}; |
330 | 331 | ||
331 | struct ixgb_option opt = { | 332 | const struct ixgb_option opt = { |
332 | .type = list_option, | 333 | .type = list_option, |
333 | .name = "Flow Control", | 334 | .name = "Flow Control", |
334 | .err = "reading default settings from EEPROM", | 335 | .err = "reading default settings from EEPROM", |
@@ -338,7 +339,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
338 | }; | 339 | }; |
339 | 340 | ||
340 | if(num_FlowControl > bd) { | 341 | if(num_FlowControl > bd) { |
341 | int fc = FlowControl[bd]; | 342 | unsigned int fc = FlowControl[bd]; |
342 | ixgb_validate_option(&fc, &opt); | 343 | ixgb_validate_option(&fc, &opt); |
343 | adapter->hw.fc.type = fc; | 344 | adapter->hw.fc.type = fc; |
344 | } else { | 345 | } else { |
@@ -346,7 +347,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
346 | } | 347 | } |
347 | } | 348 | } |
348 | { /* Receive Flow Control High Threshold */ | 349 | { /* Receive Flow Control High Threshold */ |
349 | struct ixgb_option opt = { | 350 | const struct ixgb_option opt = { |
350 | .type = range_option, | 351 | .type = range_option, |
351 | .name = "Rx Flow Control High Threshold", | 352 | .name = "Rx Flow Control High Threshold", |
352 | .err = "using default of " __MODULE_STRING(DEFAULT_FCRTH), | 353 | .err = "using default of " __MODULE_STRING(DEFAULT_FCRTH), |
@@ -366,7 +367,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
366 | "Ignoring RxFCHighThresh when no RxFC\n"); | 367 | "Ignoring RxFCHighThresh when no RxFC\n"); |
367 | } | 368 | } |
368 | { /* Receive Flow Control Low Threshold */ | 369 | { /* Receive Flow Control Low Threshold */ |
369 | struct ixgb_option opt = { | 370 | const struct ixgb_option opt = { |
370 | .type = range_option, | 371 | .type = range_option, |
371 | .name = "Rx Flow Control Low Threshold", | 372 | .name = "Rx Flow Control Low Threshold", |
372 | .err = "using default of " __MODULE_STRING(DEFAULT_FCRTL), | 373 | .err = "using default of " __MODULE_STRING(DEFAULT_FCRTL), |
@@ -386,7 +387,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
386 | "Ignoring RxFCLowThresh when no RxFC\n"); | 387 | "Ignoring RxFCLowThresh when no RxFC\n"); |
387 | } | 388 | } |
388 | { /* Flow Control Pause Time Request*/ | 389 | { /* Flow Control Pause Time Request*/ |
389 | struct ixgb_option opt = { | 390 | const struct ixgb_option opt = { |
390 | .type = range_option, | 391 | .type = range_option, |
391 | .name = "Flow Control Pause Time Request", | 392 | .name = "Flow Control Pause Time Request", |
392 | .err = "using default of "__MODULE_STRING(DEFAULT_FCPAUSE), | 393 | .err = "using default of "__MODULE_STRING(DEFAULT_FCPAUSE), |
@@ -396,7 +397,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
396 | }; | 397 | }; |
397 | 398 | ||
398 | if(num_FCReqTimeout > bd) { | 399 | if(num_FCReqTimeout > bd) { |
399 | int pause_time = FCReqTimeout[bd]; | 400 | unsigned int pause_time = FCReqTimeout[bd]; |
400 | ixgb_validate_option(&pause_time, &opt); | 401 | ixgb_validate_option(&pause_time, &opt); |
401 | adapter->hw.fc.pause_time = pause_time; | 402 | adapter->hw.fc.pause_time = pause_time; |
402 | } else { | 403 | } else { |
@@ -419,7 +420,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
419 | } | 420 | } |
420 | } | 421 | } |
421 | { /* Receive Interrupt Delay */ | 422 | { /* Receive Interrupt Delay */ |
422 | struct ixgb_option opt = { | 423 | const struct ixgb_option opt = { |
423 | .type = range_option, | 424 | .type = range_option, |
424 | .name = "Receive Interrupt Delay", | 425 | .name = "Receive Interrupt Delay", |
425 | .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), | 426 | .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), |
@@ -436,7 +437,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
436 | } | 437 | } |
437 | } | 438 | } |
438 | { /* Transmit Interrupt Delay */ | 439 | { /* Transmit Interrupt Delay */ |
439 | struct ixgb_option opt = { | 440 | const struct ixgb_option opt = { |
440 | .type = range_option, | 441 | .type = range_option, |
441 | .name = "Transmit Interrupt Delay", | 442 | .name = "Transmit Interrupt Delay", |
442 | .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), | 443 | .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), |
@@ -454,7 +455,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
454 | } | 455 | } |
455 | 456 | ||
456 | { /* Transmit Interrupt Delay Enable */ | 457 | { /* Transmit Interrupt Delay Enable */ |
457 | struct ixgb_option opt = { | 458 | const struct ixgb_option opt = { |
458 | .type = enable_option, | 459 | .type = enable_option, |
459 | .name = "Tx Interrupt Delay Enable", | 460 | .name = "Tx Interrupt Delay Enable", |
460 | .err = "defaulting to Enabled", | 461 | .err = "defaulting to Enabled", |
@@ -462,7 +463,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) | |||
462 | }; | 463 | }; |
463 | 464 | ||
464 | if(num_IntDelayEnable > bd) { | 465 | if(num_IntDelayEnable > bd) { |
465 | int ide = IntDelayEnable[bd]; | 466 | unsigned int ide = IntDelayEnable[bd]; |
466 | ixgb_validate_option(&ide, &opt); | 467 | ixgb_validate_option(&ide, &opt); |
467 | adapter->tx_int_delay_enable = ide; | 468 | adapter->tx_int_delay_enable = ide; |
468 | } else { | 469 | } else { |
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h index c160a7d91e21..bc51432b8d26 100644 --- a/drivers/net/ixgbe/ixgbe.h +++ b/drivers/net/ixgbe/ixgbe.h | |||
@@ -244,7 +244,7 @@ extern struct ixgbe_info ixgbe_82598EB_info; | |||
244 | extern struct ixgbe_info ixgbe_82598AT_info; | 244 | extern struct ixgbe_info ixgbe_82598AT_info; |
245 | 245 | ||
246 | extern char ixgbe_driver_name[]; | 246 | extern char ixgbe_driver_name[]; |
247 | extern char ixgbe_driver_version[]; | 247 | extern const char ixgbe_driver_version[]; |
248 | 248 | ||
249 | extern int ixgbe_up(struct ixgbe_adapter *adapter); | 249 | extern int ixgbe_up(struct ixgbe_adapter *adapter); |
250 | extern void ixgbe_down(struct ixgbe_adapter *adapter); | 250 | extern void ixgbe_down(struct ixgbe_adapter *adapter); |
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c index 00ee20125ca9..4d64673164ca 100644 --- a/drivers/net/ixgbe/ixgbe_82598.c +++ b/drivers/net/ixgbe/ixgbe_82598.c | |||
@@ -30,8 +30,7 @@ | |||
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <linux/sched.h> | 31 | #include <linux/sched.h> |
32 | 32 | ||
33 | #include "ixgbe_type.h" | 33 | #include "ixgbe.h" |
34 | #include "ixgbe_common.h" | ||
35 | #include "ixgbe_phy.h" | 34 | #include "ixgbe_phy.h" |
36 | 35 | ||
37 | #define IXGBE_82598_MAX_TX_QUEUES 32 | 36 | #define IXGBE_82598_MAX_TX_QUEUES 32 |
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index b75f1c6efc42..00bc525c6560 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -45,12 +45,13 @@ | |||
45 | #include "ixgbe_common.h" | 45 | #include "ixgbe_common.h" |
46 | 46 | ||
47 | char ixgbe_driver_name[] = "ixgbe"; | 47 | char ixgbe_driver_name[] = "ixgbe"; |
48 | static char ixgbe_driver_string[] = | 48 | static const char ixgbe_driver_string[] = |
49 | "Intel(R) 10 Gigabit PCI Express Network Driver"; | 49 | "Intel(R) 10 Gigabit PCI Express Network Driver"; |
50 | 50 | ||
51 | #define DRV_VERSION "1.1.18" | 51 | #define DRV_VERSION "1.1.18" |
52 | char ixgbe_driver_version[] = DRV_VERSION; | 52 | const char ixgbe_driver_version[] = DRV_VERSION; |
53 | static char ixgbe_copyright[] = "Copyright (c) 1999-2007 Intel Corporation."; | 53 | static const char ixgbe_copyright[] = |
54 | "Copyright (c) 1999-2007 Intel Corporation."; | ||
54 | 55 | ||
55 | static const struct ixgbe_info *ixgbe_info_tbl[] = { | 56 | static const struct ixgbe_info *ixgbe_info_tbl[] = { |
56 | [board_82598AF] = &ixgbe_82598AF_info, | 57 | [board_82598AF] = &ixgbe_82598AF_info, |
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 662b8d16803c..45f30a2974b8 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -284,7 +284,7 @@ static __net_exit void loopback_net_exit(struct net *net) | |||
284 | unregister_netdev(dev); | 284 | unregister_netdev(dev); |
285 | } | 285 | } |
286 | 286 | ||
287 | static struct pernet_operations __net_initdata loopback_net_ops = { | 287 | static struct pernet_operations loopback_net_ops = { |
288 | .init = loopback_net_init, | 288 | .init = loopback_net_init, |
289 | .exit = loopback_net_exit, | 289 | .exit = loopback_net_exit, |
290 | }; | 290 | }; |
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c index 887633b207d9..2a5bef6388fe 100644 --- a/drivers/net/mlx4/icm.c +++ b/drivers/net/mlx4/icm.c | |||
@@ -101,9 +101,7 @@ static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_ma | |||
101 | if (!page) | 101 | if (!page) |
102 | return -ENOMEM; | 102 | return -ENOMEM; |
103 | 103 | ||
104 | sg_set_page(mem, page); | 104 | sg_set_page(mem, page, PAGE_SIZE << order, 0); |
105 | mem->length = PAGE_SIZE << order; | ||
106 | mem->offset = 0; | ||
107 | return 0; | 105 | return 0; |
108 | } | 106 | } |
109 | 107 | ||
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index 366e62a2b1e5..0f306ddb5630 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -1151,7 +1151,7 @@ static inline int myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int budget) | |||
1151 | u16 length; | 1151 | u16 length; |
1152 | __wsum checksum; | 1152 | __wsum checksum; |
1153 | 1153 | ||
1154 | while (rx_done->entry[idx].length != 0 && work_done++ < budget) { | 1154 | while (rx_done->entry[idx].length != 0 && work_done < budget) { |
1155 | length = ntohs(rx_done->entry[idx].length); | 1155 | length = ntohs(rx_done->entry[idx].length); |
1156 | rx_done->entry[idx].length = 0; | 1156 | rx_done->entry[idx].length = 0; |
1157 | checksum = csum_unfold(rx_done->entry[idx].checksum); | 1157 | checksum = csum_unfold(rx_done->entry[idx].checksum); |
@@ -1167,6 +1167,7 @@ static inline int myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int budget) | |||
1167 | rx_bytes += rx_ok * (unsigned long)length; | 1167 | rx_bytes += rx_ok * (unsigned long)length; |
1168 | cnt++; | 1168 | cnt++; |
1169 | idx = cnt & (myri10ge_max_intr_slots - 1); | 1169 | idx = cnt & (myri10ge_max_intr_slots - 1); |
1170 | work_done++; | ||
1170 | } | 1171 | } |
1171 | rx_done->idx = idx; | 1172 | rx_done->idx = idx; |
1172 | rx_done->cnt = cnt; | 1173 | rx_done->cnt = cnt; |
@@ -1233,13 +1234,12 @@ static int myri10ge_poll(struct napi_struct *napi, int budget) | |||
1233 | struct myri10ge_priv *mgp = | 1234 | struct myri10ge_priv *mgp = |
1234 | container_of(napi, struct myri10ge_priv, napi); | 1235 | container_of(napi, struct myri10ge_priv, napi); |
1235 | struct net_device *netdev = mgp->dev; | 1236 | struct net_device *netdev = mgp->dev; |
1236 | struct myri10ge_rx_done *rx_done = &mgp->rx_done; | ||
1237 | int work_done; | 1237 | int work_done; |
1238 | 1238 | ||
1239 | /* process as many rx events as NAPI will allow */ | 1239 | /* process as many rx events as NAPI will allow */ |
1240 | work_done = myri10ge_clean_rx_done(mgp, budget); | 1240 | work_done = myri10ge_clean_rx_done(mgp, budget); |
1241 | 1241 | ||
1242 | if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) { | 1242 | if (work_done < budget || !netif_running(netdev)) { |
1243 | netif_rx_complete(netdev, napi); | 1243 | netif_rx_complete(netdev, napi); |
1244 | put_be32(htonl(3), mgp->irq_claim); | 1244 | put_be32(htonl(3), mgp->irq_claim); |
1245 | } | 1245 | } |
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c index 953117152bbd..87cde062fd63 100644 --- a/drivers/net/natsemi.c +++ b/drivers/net/natsemi.c | |||
@@ -864,6 +864,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev, | |||
864 | 864 | ||
865 | np = netdev_priv(dev); | 865 | np = netdev_priv(dev); |
866 | netif_napi_add(dev, &np->napi, natsemi_poll, 64); | 866 | netif_napi_add(dev, &np->napi, natsemi_poll, 64); |
867 | np->dev = dev; | ||
867 | 868 | ||
868 | np->pci_dev = pdev; | 869 | np->pci_dev = pdev; |
869 | pci_set_drvdata(pdev, dev); | 870 | pci_set_drvdata(pdev, dev); |
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 73dcbb7296da..ad134a61302a 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c | |||
@@ -274,7 +274,7 @@ static int tc574_probe(struct pcmcia_device *link) | |||
274 | spin_lock_init(&lp->window_lock); | 274 | spin_lock_init(&lp->window_lock); |
275 | link->io.NumPorts1 = 32; | 275 | link->io.NumPorts1 = 32; |
276 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | 276 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; |
277 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; | 277 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; |
278 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 278 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
279 | link->irq.Handler = &el3_interrupt; | 279 | link->irq.Handler = &el3_interrupt; |
280 | link->irq.Instance = dev; | 280 | link->irq.Instance = dev; |
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index 32076ca6a9e1..a98fe07cce70 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c | |||
@@ -188,7 +188,7 @@ static int tc589_probe(struct pcmcia_device *link) | |||
188 | spin_lock_init(&lp->lock); | 188 | spin_lock_init(&lp->lock); |
189 | link->io.NumPorts1 = 16; | 189 | link->io.NumPorts1 = 16; |
190 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | 190 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; |
191 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; | 191 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; |
192 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 192 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
193 | link->irq.Handler = &el3_interrupt; | 193 | link->irq.Handler = &el3_interrupt; |
194 | link->irq.Instance = dev; | 194 | link->irq.Instance = dev; |
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index a95a2cae6b23..8d910a372f89 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c | |||
@@ -158,7 +158,7 @@ static int axnet_probe(struct pcmcia_device *link) | |||
158 | info = PRIV(dev); | 158 | info = PRIV(dev); |
159 | info->p_dev = link; | 159 | info->p_dev = link; |
160 | link->priv = dev; | 160 | link->priv = dev; |
161 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; | 161 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
162 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 162 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
163 | link->conf.Attributes = CONF_ENABLE_IRQ; | 163 | link->conf.Attributes = CONF_ENABLE_IRQ; |
164 | link->conf.IntType = INT_MEMORY_AND_IO; | 164 | link->conf.IntType = INT_MEMORY_AND_IO; |
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 62844677c784..8c719b4df544 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c | |||
@@ -249,7 +249,7 @@ static int fmvj18x_probe(struct pcmcia_device *link) | |||
249 | link->io.IOAddrLines = 5; | 249 | link->io.IOAddrLines = 5; |
250 | 250 | ||
251 | /* Interrupt setup */ | 251 | /* Interrupt setup */ |
252 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; | 252 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; |
253 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 253 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
254 | link->irq.Handler = &fjn_interrupt; | 254 | link->irq.Handler = &fjn_interrupt; |
255 | link->irq.Instance = dev; | 255 | link->irq.Instance = dev; |
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 9d45e9696e16..db6a97d1d7b1 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -254,7 +254,7 @@ static int pcnet_probe(struct pcmcia_device *link) | |||
254 | info->p_dev = link; | 254 | info->p_dev = link; |
255 | link->priv = dev; | 255 | link->priv = dev; |
256 | 256 | ||
257 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; | 257 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
258 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 258 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
259 | link->conf.Attributes = CONF_ENABLE_IRQ; | 259 | link->conf.Attributes = CONF_ENABLE_IRQ; |
260 | link->conf.IntType = INT_MEMORY_AND_IO; | 260 | link->conf.IntType = INT_MEMORY_AND_IO; |
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 58d716fd17cf..c9868e9dac4c 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -328,7 +328,7 @@ static int smc91c92_probe(struct pcmcia_device *link) | |||
328 | link->io.NumPorts1 = 16; | 328 | link->io.NumPorts1 = 16; |
329 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | 329 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
330 | link->io.IOAddrLines = 4; | 330 | link->io.IOAddrLines = 4; |
331 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; | 331 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; |
332 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 332 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
333 | link->irq.Handler = &smc_interrupt; | 333 | link->irq.Handler = &smc_interrupt; |
334 | link->irq.Instance = dev; | 334 | link->irq.Instance = dev; |
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index c3b69602e275..1f09bea6db5a 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -886,7 +886,7 @@ xirc2ps_config(struct pcmcia_device * link) | |||
886 | } | 886 | } |
887 | printk(KNOT_XIRC "no ports available\n"); | 887 | printk(KNOT_XIRC "no ports available\n"); |
888 | } else { | 888 | } else { |
889 | link->irq.Attributes |= IRQ_TYPE_EXCLUSIVE; | 889 | link->irq.Attributes |= IRQ_TYPE_DYNAMIC_SHARING; |
890 | link->io.NumPorts1 = 16; | 890 | link->io.NumPorts1 = 16; |
891 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { | 891 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { |
892 | link->io.BasePort1 = ioaddr; | 892 | link->io.BasePort1 = ioaddr; |
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c index bcb0885011c8..b35d79449500 100644 --- a/drivers/net/ppp_mppe.c +++ b/drivers/net/ppp_mppe.c | |||
@@ -68,7 +68,7 @@ MODULE_VERSION("1.0.2"); | |||
68 | static unsigned int | 68 | static unsigned int |
69 | setup_sg(struct scatterlist *sg, const void *address, unsigned int length) | 69 | setup_sg(struct scatterlist *sg, const void *address, unsigned int length) |
70 | { | 70 | { |
71 | sg_init_one(sg, address, length); | 71 | sg_set_buf(sg, address, length); |
72 | return length; | 72 | return length; |
73 | } | 73 | } |
74 | 74 | ||
@@ -140,6 +140,8 @@ static void get_new_key_from_sha(struct ppp_mppe_state * state) | |||
140 | struct scatterlist sg[4]; | 140 | struct scatterlist sg[4]; |
141 | unsigned int nbytes; | 141 | unsigned int nbytes; |
142 | 142 | ||
143 | sg_init_table(sg, 4); | ||
144 | |||
143 | nbytes = setup_sg(&sg[0], state->master_key, state->keylen); | 145 | nbytes = setup_sg(&sg[0], state->master_key, state->keylen); |
144 | nbytes += setup_sg(&sg[1], sha_pad->sha_pad1, | 146 | nbytes += setup_sg(&sg[1], sha_pad->sha_pad1, |
145 | sizeof(sha_pad->sha_pad1)); | 147 | sizeof(sha_pad->sha_pad1)); |
@@ -166,6 +168,8 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key) | |||
166 | if (!initial_key) { | 168 | if (!initial_key) { |
167 | crypto_blkcipher_setkey(state->arc4, state->sha1_digest, | 169 | crypto_blkcipher_setkey(state->arc4, state->sha1_digest, |
168 | state->keylen); | 170 | state->keylen); |
171 | sg_init_table(sg_in, 1); | ||
172 | sg_init_table(sg_out, 1); | ||
169 | setup_sg(sg_in, state->sha1_digest, state->keylen); | 173 | setup_sg(sg_in, state->sha1_digest, state->keylen); |
170 | setup_sg(sg_out, state->session_key, state->keylen); | 174 | setup_sg(sg_out, state->session_key, state->keylen); |
171 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, | 175 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, |
@@ -421,6 +425,8 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf, | |||
421 | isize -= 2; | 425 | isize -= 2; |
422 | 426 | ||
423 | /* Encrypt packet */ | 427 | /* Encrypt packet */ |
428 | sg_init_table(sg_in, 1); | ||
429 | sg_init_table(sg_out, 1); | ||
424 | setup_sg(sg_in, ibuf, isize); | 430 | setup_sg(sg_in, ibuf, isize); |
425 | setup_sg(sg_out, obuf, osize); | 431 | setup_sg(sg_out, obuf, osize); |
426 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, isize) != 0) { | 432 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, isize) != 0) { |
@@ -608,6 +614,8 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, | |||
608 | * Decrypt the first byte in order to check if it is | 614 | * Decrypt the first byte in order to check if it is |
609 | * a compressed or uncompressed protocol field. | 615 | * a compressed or uncompressed protocol field. |
610 | */ | 616 | */ |
617 | sg_init_table(sg_in, 1); | ||
618 | sg_init_table(sg_out, 1); | ||
611 | setup_sg(sg_in, ibuf, 1); | 619 | setup_sg(sg_in, ibuf, 1); |
612 | setup_sg(sg_out, obuf, 1); | 620 | setup_sg(sg_out, obuf, 1); |
613 | if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, 1) != 0) { | 621 | if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, 1) != 0) { |
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 8936ed3469cf..a005d8f4c38e 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c | |||
@@ -491,7 +491,7 @@ static int pppoe_create(struct net *net, struct socket *sock) | |||
491 | int error = -ENOMEM; | 491 | int error = -ENOMEM; |
492 | struct sock *sk; | 492 | struct sock *sk; |
493 | 493 | ||
494 | sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto, 1); | 494 | sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto); |
495 | if (!sk) | 495 | if (!sk) |
496 | goto out; | 496 | goto out; |
497 | 497 | ||
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c index 921d4ef6d14b..f8904fd92369 100644 --- a/drivers/net/pppol2tp.c +++ b/drivers/net/pppol2tp.c | |||
@@ -1416,7 +1416,7 @@ static int pppol2tp_create(struct net *net, struct socket *sock) | |||
1416 | int error = -ENOMEM; | 1416 | int error = -ENOMEM; |
1417 | struct sock *sk; | 1417 | struct sock *sk; |
1418 | 1418 | ||
1419 | sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppol2tp_sk_proto, 1); | 1419 | sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppol2tp_sk_proto); |
1420 | if (!sk) | 1420 | if (!sk) |
1421 | goto out; | 1421 | goto out; |
1422 | 1422 | ||
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index e8960f294a6e..b94fa7ef1955 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -392,7 +392,9 @@ struct rtl8169_private { | |||
392 | void __iomem *mmio_addr; /* memory map physical address */ | 392 | void __iomem *mmio_addr; /* memory map physical address */ |
393 | struct pci_dev *pci_dev; /* Index of PCI device */ | 393 | struct pci_dev *pci_dev; /* Index of PCI device */ |
394 | struct net_device *dev; | 394 | struct net_device *dev; |
395 | #ifdef CONFIG_R8169_NAPI | ||
395 | struct napi_struct napi; | 396 | struct napi_struct napi; |
397 | #endif | ||
396 | spinlock_t lock; /* spin lock flag */ | 398 | spinlock_t lock; /* spin lock flag */ |
397 | u32 msg_enable; | 399 | u32 msg_enable; |
398 | int chipset; | 400 | int chipset; |
@@ -2989,13 +2991,16 @@ static void rtl8169_down(struct net_device *dev) | |||
2989 | { | 2991 | { |
2990 | struct rtl8169_private *tp = netdev_priv(dev); | 2992 | struct rtl8169_private *tp = netdev_priv(dev); |
2991 | void __iomem *ioaddr = tp->mmio_addr; | 2993 | void __iomem *ioaddr = tp->mmio_addr; |
2992 | unsigned int poll_locked = 0; | ||
2993 | unsigned int intrmask; | 2994 | unsigned int intrmask; |
2994 | 2995 | ||
2995 | rtl8169_delete_timer(dev); | 2996 | rtl8169_delete_timer(dev); |
2996 | 2997 | ||
2997 | netif_stop_queue(dev); | 2998 | netif_stop_queue(dev); |
2998 | 2999 | ||
3000 | #ifdef CONFIG_R8169_NAPI | ||
3001 | napi_disable(&tp->napi); | ||
3002 | #endif | ||
3003 | |||
2999 | core_down: | 3004 | core_down: |
3000 | spin_lock_irq(&tp->lock); | 3005 | spin_lock_irq(&tp->lock); |
3001 | 3006 | ||
@@ -3009,11 +3014,6 @@ core_down: | |||
3009 | 3014 | ||
3010 | synchronize_irq(dev->irq); | 3015 | synchronize_irq(dev->irq); |
3011 | 3016 | ||
3012 | if (!poll_locked) { | ||
3013 | napi_disable(&tp->napi); | ||
3014 | poll_locked++; | ||
3015 | } | ||
3016 | |||
3017 | /* Give a racing hard_start_xmit a few cycles to complete. */ | 3017 | /* Give a racing hard_start_xmit a few cycles to complete. */ |
3018 | synchronize_sched(); /* FIXME: should this be synchronize_irq()? */ | 3018 | synchronize_sched(); /* FIXME: should this be synchronize_irq()? */ |
3019 | 3019 | ||
diff --git a/drivers/net/rrunner.c b/drivers/net/rrunner.c index 19152f54ef2b..b822859c8de3 100644 --- a/drivers/net/rrunner.c +++ b/drivers/net/rrunner.c | |||
@@ -79,12 +79,10 @@ static char version[] __devinitdata = "rrunner.c: v0.50 11/11/2002 Jes Sorensen | |||
79 | */ | 79 | */ |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * These are checked at init time to see if they are at least 256KB | 82 | * sysctl_[wr]mem_max are checked at init time to see if they are at |
83 | * and increased to 256KB if they are not. This is done to avoid ending | 83 | * least 256KB and increased to 256KB if they are not. This is done to |
84 | * up with socket buffers smaller than the MTU size, | 84 | * avoid ending up with socket buffers smaller than the MTU size, |
85 | */ | 85 | */ |
86 | extern __u32 sysctl_wmem_max; | ||
87 | extern __u32 sysctl_rmem_max; | ||
88 | 86 | ||
89 | static int __devinit rr_init_one(struct pci_dev *pdev, | 87 | static int __devinit rr_init_one(struct pci_dev *pdev, |
90 | const struct pci_device_id *ent) | 88 | const struct pci_device_id *ent) |
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 9741d613ba6f..a3ff270593f1 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
@@ -2214,9 +2214,7 @@ static void ucc_geth_set_multi(struct net_device *dev) | |||
2214 | struct dev_mc_list *dmi; | 2214 | struct dev_mc_list *dmi; |
2215 | struct ucc_fast *uf_regs; | 2215 | struct ucc_fast *uf_regs; |
2216 | struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; | 2216 | struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; |
2217 | u8 tempaddr[6]; | 2217 | int i; |
2218 | u8 *mcptr, *tdptr; | ||
2219 | int i, j; | ||
2220 | 2218 | ||
2221 | ugeth = netdev_priv(dev); | 2219 | ugeth = netdev_priv(dev); |
2222 | 2220 | ||
@@ -2255,19 +2253,10 @@ static void ucc_geth_set_multi(struct net_device *dev) | |||
2255 | if (!(dmi->dmi_addr[0] & 1)) | 2253 | if (!(dmi->dmi_addr[0] & 1)) |
2256 | continue; | 2254 | continue; |
2257 | 2255 | ||
2258 | /* The address in dmi_addr is LSB first, | ||
2259 | * and taddr is MSB first. We have to | ||
2260 | * copy bytes MSB first from dmi_addr. | ||
2261 | */ | ||
2262 | mcptr = (u8 *) dmi->dmi_addr + 5; | ||
2263 | tdptr = (u8 *) tempaddr; | ||
2264 | for (j = 0; j < 6; j++) | ||
2265 | *tdptr++ = *mcptr--; | ||
2266 | |||
2267 | /* Ask CPM to run CRC and set bit in | 2256 | /* Ask CPM to run CRC and set bit in |
2268 | * filter mask. | 2257 | * filter mask. |
2269 | */ | 2258 | */ |
2270 | hw_add_addr_in_hash(ugeth, tempaddr); | 2259 | hw_add_addr_in_hash(ugeth, dmi->dmi_addr); |
2271 | } | 2260 | } |
2272 | } | 2261 | } |
2273 | } | 2262 | } |
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c index a2de32fabc17..2c685734b7a4 100644 --- a/drivers/net/usb/dm9601.c +++ b/drivers/net/usb/dm9601.c | |||
@@ -586,6 +586,10 @@ static const struct usb_device_id products[] = { | |||
586 | USB_DEVICE(0x0a46, 0x0268), /* ShanTou ST268 USB NIC */ | 586 | USB_DEVICE(0x0a46, 0x0268), /* ShanTou ST268 USB NIC */ |
587 | .driver_info = (unsigned long)&dm9601_info, | 587 | .driver_info = (unsigned long)&dm9601_info, |
588 | }, | 588 | }, |
589 | { | ||
590 | USB_DEVICE(0x0a46, 0x8515), /* ADMtek ADM8515 USB NIC */ | ||
591 | .driver_info = (unsigned long)&dm9601_info, | ||
592 | }, | ||
589 | {}, // END | 593 | {}, // END |
590 | }; | 594 | }; |
591 | 595 | ||
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c index cd991a0f75bb..1ebe3259be0d 100644 --- a/drivers/net/usb/rndis_host.c +++ b/drivers/net/usb/rndis_host.c | |||
@@ -512,11 +512,19 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf) | |||
512 | } | 512 | } |
513 | tmp = le32_to_cpu(u.init_c->max_transfer_size); | 513 | tmp = le32_to_cpu(u.init_c->max_transfer_size); |
514 | if (tmp < dev->hard_mtu) { | 514 | if (tmp < dev->hard_mtu) { |
515 | dev_err(&intf->dev, | 515 | if (tmp <= net->hard_header_len) { |
516 | "dev can't take %u byte packets (max %u)\n", | 516 | dev_err(&intf->dev, |
517 | dev->hard_mtu, tmp); | 517 | "dev can't take %u byte packets (max %u)\n", |
518 | retval = -EINVAL; | 518 | dev->hard_mtu, tmp); |
519 | goto fail_and_release; | 519 | retval = -EINVAL; |
520 | goto fail_and_release; | ||
521 | } | ||
522 | dev->hard_mtu = tmp; | ||
523 | net->mtu = dev->hard_mtu - net->hard_header_len; | ||
524 | dev_warn(&intf->dev, | ||
525 | "dev can't take %u byte packets (max %u), " | ||
526 | "adjusting MTU to %u\n", | ||
527 | dev->hard_mtu, tmp, net->mtu); | ||
520 | } | 528 | } |
521 | 529 | ||
522 | /* REVISIT: peripheral "alignment" request is ignored ... */ | 530 | /* REVISIT: peripheral "alignment" request is ignored ... */ |
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c index 5ea877221f46..37c52e131750 100644 --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c | |||
@@ -142,9 +142,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ | |||
142 | * To date internally, just copy this out to the user. | 142 | * To date internally, just copy this out to the user. |
143 | */ | 143 | */ |
144 | case LMCIOCGINFO: /*fold01*/ | 144 | case LMCIOCGINFO: /*fold01*/ |
145 | if (copy_to_user(ifr->ifr_data, &sc->ictl, sizeof (lmc_ctl_t))) | 145 | if (copy_to_user(ifr->ifr_data, &sc->ictl, sizeof(lmc_ctl_t))) |
146 | return -EFAULT; | 146 | ret = -EFAULT; |
147 | ret = 0; | 147 | else |
148 | ret = 0; | ||
148 | break; | 149 | break; |
149 | 150 | ||
150 | case LMCIOCSINFO: /*fold01*/ | 151 | case LMCIOCSINFO: /*fold01*/ |
@@ -159,8 +160,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ | |||
159 | break; | 160 | break; |
160 | } | 161 | } |
161 | 162 | ||
162 | if (copy_from_user(&ctl, ifr->ifr_data, sizeof (lmc_ctl_t))) | 163 | if (copy_from_user(&ctl, ifr->ifr_data, sizeof(lmc_ctl_t))) { |
163 | return -EFAULT; | 164 | ret = -EFAULT; |
165 | break; | ||
166 | } | ||
164 | 167 | ||
165 | sc->lmc_media->set_status (sc, &ctl); | 168 | sc->lmc_media->set_status (sc, &ctl); |
166 | 169 | ||
@@ -190,8 +193,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ | |||
190 | break; | 193 | break; |
191 | } | 194 | } |
192 | 195 | ||
193 | if (copy_from_user(&new_type, ifr->ifr_data, sizeof(u_int16_t))) | 196 | if (copy_from_user(&new_type, ifr->ifr_data, sizeof(u_int16_t))) { |
194 | return -EFAULT; | 197 | ret = -EFAULT; |
198 | break; | ||
199 | } | ||
195 | 200 | ||
196 | 201 | ||
197 | if (new_type == old_type) | 202 | if (new_type == old_type) |
@@ -229,9 +234,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ | |||
229 | sc->lmc_xinfo.Magic1 = 0xDEADBEEF; | 234 | sc->lmc_xinfo.Magic1 = 0xDEADBEEF; |
230 | 235 | ||
231 | if (copy_to_user(ifr->ifr_data, &sc->lmc_xinfo, | 236 | if (copy_to_user(ifr->ifr_data, &sc->lmc_xinfo, |
232 | sizeof (struct lmc_xinfo))) | 237 | sizeof(struct lmc_xinfo))) |
233 | return -EFAULT; | 238 | ret = -EFAULT; |
234 | ret = 0; | 239 | else |
240 | ret = 0; | ||
235 | 241 | ||
236 | break; | 242 | break; |
237 | 243 | ||
@@ -262,9 +268,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ | |||
262 | 268 | ||
263 | if (copy_to_user(ifr->ifr_data, &sc->stats, | 269 | if (copy_to_user(ifr->ifr_data, &sc->stats, |
264 | sizeof (struct lmc_statistics))) | 270 | sizeof (struct lmc_statistics))) |
265 | return -EFAULT; | 271 | ret = -EFAULT; |
266 | 272 | else | |
267 | ret = 0; | 273 | ret = 0; |
268 | break; | 274 | break; |
269 | 275 | ||
270 | case LMCIOCCLEARLMCSTATS: /*fold01*/ | 276 | case LMCIOCCLEARLMCSTATS: /*fold01*/ |
@@ -292,8 +298,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ | |||
292 | break; | 298 | break; |
293 | } | 299 | } |
294 | 300 | ||
295 | if (copy_from_user(&ctl, ifr->ifr_data, sizeof (lmc_ctl_t))) | 301 | if (copy_from_user(&ctl, ifr->ifr_data, sizeof(lmc_ctl_t))) { |
296 | return -EFAULT; | 302 | ret = -EFAULT; |
303 | break; | ||
304 | } | ||
297 | sc->lmc_media->set_circuit_type(sc, ctl.circuit_type); | 305 | sc->lmc_media->set_circuit_type(sc, ctl.circuit_type); |
298 | sc->ictl.circuit_type = ctl.circuit_type; | 306 | sc->ictl.circuit_type = ctl.circuit_type; |
299 | ret = 0; | 307 | ret = 0; |
@@ -318,12 +326,15 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ | |||
318 | 326 | ||
319 | #ifdef DEBUG | 327 | #ifdef DEBUG |
320 | case LMCIOCDUMPEVENTLOG: | 328 | case LMCIOCDUMPEVENTLOG: |
321 | if (copy_to_user(ifr->ifr_data, &lmcEventLogIndex, sizeof (u32))) | 329 | if (copy_to_user(ifr->ifr_data, &lmcEventLogIndex, sizeof(u32))) { |
322 | return -EFAULT; | 330 | ret = -EFAULT; |
331 | break; | ||
332 | } | ||
323 | if (copy_to_user(ifr->ifr_data + sizeof (u32), lmcEventLogBuf, sizeof (lmcEventLogBuf))) | 333 | if (copy_to_user(ifr->ifr_data + sizeof (u32), lmcEventLogBuf, sizeof (lmcEventLogBuf))) |
324 | return -EFAULT; | 334 | ret = -EFAULT; |
335 | else | ||
336 | ret = 0; | ||
325 | 337 | ||
326 | ret = 0; | ||
327 | break; | 338 | break; |
328 | #endif /* end ifdef _DBG_EVENTLOG */ | 339 | #endif /* end ifdef _DBG_EVENTLOG */ |
329 | case LMCIOCT1CONTROL: /*fold01*/ | 340 | case LMCIOCT1CONTROL: /*fold01*/ |
@@ -346,8 +357,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ | |||
346 | */ | 357 | */ |
347 | netif_stop_queue(dev); | 358 | netif_stop_queue(dev); |
348 | 359 | ||
349 | if (copy_from_user(&xc, ifr->ifr_data, sizeof (struct lmc_xilinx_control))) | 360 | if (copy_from_user(&xc, ifr->ifr_data, sizeof(struct lmc_xilinx_control))) { |
350 | return -EFAULT; | 361 | ret = -EFAULT; |
362 | break; | ||
363 | } | ||
351 | switch(xc.command){ | 364 | switch(xc.command){ |
352 | case lmc_xilinx_reset: /*fold02*/ | 365 | case lmc_xilinx_reset: /*fold02*/ |
353 | { | 366 | { |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 9d9ff76a9bc6..5058e60e5703 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -2391,7 +2391,7 @@ out_requeue: | |||
2391 | if (b43_debug(dev, B43_DBG_PWORK_FAST)) | 2391 | if (b43_debug(dev, B43_DBG_PWORK_FAST)) |
2392 | delay = msecs_to_jiffies(50); | 2392 | delay = msecs_to_jiffies(50); |
2393 | else | 2393 | else |
2394 | delay = round_jiffies(HZ * 15); | 2394 | delay = round_jiffies_relative(HZ * 15); |
2395 | queue_delayed_work(wl->hw->workqueue, &dev->periodic_work, delay); | 2395 | queue_delayed_work(wl->hw->workqueue, &dev->periodic_work, delay); |
2396 | out: | 2396 | out: |
2397 | mutex_unlock(&wl->mutex); | 2397 | mutex_unlock(&wl->mutex); |
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index d09479e816cd..f0e56dfc9ecf 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c | |||
@@ -2260,7 +2260,7 @@ out_requeue: | |||
2260 | if (b43legacy_debug(dev, B43legacy_DBG_PWORK_FAST)) | 2260 | if (b43legacy_debug(dev, B43legacy_DBG_PWORK_FAST)) |
2261 | delay = msecs_to_jiffies(50); | 2261 | delay = msecs_to_jiffies(50); |
2262 | else | 2262 | else |
2263 | delay = round_jiffies(HZ); | 2263 | delay = round_jiffies_relative(HZ); |
2264 | queue_delayed_work(dev->wl->hw->workqueue, | 2264 | queue_delayed_work(dev->wl->hw->workqueue, |
2265 | &dev->periodic_work, delay); | 2265 | &dev->periodic_work, delay); |
2266 | out: | 2266 | out: |
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c index a6c7904de282..8d53d08b9691 100644 --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c | |||
@@ -1769,7 +1769,7 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) | |||
1769 | if (priv->stop_rf_kill) { | 1769 | if (priv->stop_rf_kill) { |
1770 | priv->stop_rf_kill = 0; | 1770 | priv->stop_rf_kill = 0; |
1771 | queue_delayed_work(priv->workqueue, &priv->rf_kill, | 1771 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
1772 | round_jiffies(HZ)); | 1772 | round_jiffies_relative(HZ)); |
1773 | } | 1773 | } |
1774 | 1774 | ||
1775 | deferred = 1; | 1775 | deferred = 1; |
@@ -2086,7 +2086,8 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) | |||
2086 | /* Make sure the RF Kill check timer is running */ | 2086 | /* Make sure the RF Kill check timer is running */ |
2087 | priv->stop_rf_kill = 0; | 2087 | priv->stop_rf_kill = 0; |
2088 | cancel_delayed_work(&priv->rf_kill); | 2088 | cancel_delayed_work(&priv->rf_kill); |
2089 | queue_delayed_work(priv->workqueue, &priv->rf_kill, round_jiffies(HZ)); | 2089 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
2090 | round_jiffies_relative(HZ)); | ||
2090 | } | 2091 | } |
2091 | 2092 | ||
2092 | static void send_scan_event(void *data) | 2093 | static void send_scan_event(void *data) |
@@ -2123,7 +2124,7 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) | |||
2123 | if (!delayed_work_pending(&priv->scan_event_later)) | 2124 | if (!delayed_work_pending(&priv->scan_event_later)) |
2124 | queue_delayed_work(priv->workqueue, | 2125 | queue_delayed_work(priv->workqueue, |
2125 | &priv->scan_event_later, | 2126 | &priv->scan_event_later, |
2126 | round_jiffies(msecs_to_jiffies(4000))); | 2127 | round_jiffies_relative(msecs_to_jiffies(4000))); |
2127 | } else { | 2128 | } else { |
2128 | priv->user_requested_scan = 0; | 2129 | priv->user_requested_scan = 0; |
2129 | cancel_delayed_work(&priv->scan_event_later); | 2130 | cancel_delayed_work(&priv->scan_event_later); |
@@ -4242,7 +4243,7 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio) | |||
4242 | priv->stop_rf_kill = 0; | 4243 | priv->stop_rf_kill = 0; |
4243 | cancel_delayed_work(&priv->rf_kill); | 4244 | cancel_delayed_work(&priv->rf_kill); |
4244 | queue_delayed_work(priv->workqueue, &priv->rf_kill, | 4245 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
4245 | round_jiffies(HZ)); | 4246 | round_jiffies_relative(HZ)); |
4246 | } else | 4247 | } else |
4247 | schedule_reset(priv); | 4248 | schedule_reset(priv); |
4248 | } | 4249 | } |
@@ -5981,7 +5982,7 @@ static void ipw2100_rf_kill(struct work_struct *work) | |||
5981 | IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n"); | 5982 | IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n"); |
5982 | if (!priv->stop_rf_kill) | 5983 | if (!priv->stop_rf_kill) |
5983 | queue_delayed_work(priv->workqueue, &priv->rf_kill, | 5984 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
5984 | round_jiffies(HZ)); | 5985 | round_jiffies_relative(HZ)); |
5985 | goto exit_unlock; | 5986 | goto exit_unlock; |
5986 | } | 5987 | } |
5987 | 5988 | ||
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index e3c828401b9a..54f44e5473c0 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c | |||
@@ -1753,7 +1753,7 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio) | |||
1753 | /* Make sure the RF_KILL check timer is running */ | 1753 | /* Make sure the RF_KILL check timer is running */ |
1754 | cancel_delayed_work(&priv->rf_kill); | 1754 | cancel_delayed_work(&priv->rf_kill); |
1755 | queue_delayed_work(priv->workqueue, &priv->rf_kill, | 1755 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
1756 | round_jiffies(2 * HZ)); | 1756 | round_jiffies_relative(2 * HZ)); |
1757 | } else | 1757 | } else |
1758 | queue_work(priv->workqueue, &priv->up); | 1758 | queue_work(priv->workqueue, &priv->up); |
1759 | } | 1759 | } |
@@ -4364,7 +4364,7 @@ static void handle_scan_event(struct ipw_priv *priv) | |||
4364 | if (!priv->user_requested_scan) { | 4364 | if (!priv->user_requested_scan) { |
4365 | if (!delayed_work_pending(&priv->scan_event)) | 4365 | if (!delayed_work_pending(&priv->scan_event)) |
4366 | queue_delayed_work(priv->workqueue, &priv->scan_event, | 4366 | queue_delayed_work(priv->workqueue, &priv->scan_event, |
4367 | round_jiffies(msecs_to_jiffies(4000))); | 4367 | round_jiffies_relative(msecs_to_jiffies(4000))); |
4368 | } else { | 4368 | } else { |
4369 | union iwreq_data wrqu; | 4369 | union iwreq_data wrqu; |
4370 | 4370 | ||
@@ -4728,7 +4728,7 @@ static void ipw_rx_notification(struct ipw_priv *priv, | |||
4728 | && priv->status & STATUS_ASSOCIATED) | 4728 | && priv->status & STATUS_ASSOCIATED) |
4729 | queue_delayed_work(priv->workqueue, | 4729 | queue_delayed_work(priv->workqueue, |
4730 | &priv->request_scan, | 4730 | &priv->request_scan, |
4731 | round_jiffies(HZ)); | 4731 | round_jiffies_relative(HZ)); |
4732 | 4732 | ||
4733 | /* Send an empty event to user space. | 4733 | /* Send an empty event to user space. |
4734 | * We don't send the received data on the event because | 4734 | * We don't send the received data on the event because |
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig index 25cfc6c32509..8d52a26c248a 100644 --- a/drivers/net/wireless/iwlwifi/Kconfig +++ b/drivers/net/wireless/iwlwifi/Kconfig | |||
@@ -96,8 +96,8 @@ config IWL4965 | |||
96 | 96 | ||
97 | If you want to compile the driver as a module ( = code which can be | 97 | If you want to compile the driver as a module ( = code which can be |
98 | inserted in and remvoed from the running kernel whenever you want), | 98 | inserted in and remvoed from the running kernel whenever you want), |
99 | say M here and read <file:Documentation/modules.txt>. The module | 99 | say M here and read <file:Documentation/kbuild/modules.txt>. The |
100 | will be called iwl4965.ko. | 100 | module will be called iwl4965.ko. |
101 | 101 | ||
102 | config IWL3945 | 102 | config IWL3945 |
103 | tristate "Intel PRO/Wireless 3945ABG/BG Network Connection" | 103 | tristate "Intel PRO/Wireless 3945ABG/BG Network Connection" |
@@ -124,5 +124,5 @@ config IWL3945 | |||
124 | 124 | ||
125 | If you want to compile the driver as a module ( = code which can be | 125 | If you want to compile the driver as a module ( = code which can be |
126 | inserted in and remvoed from the running kernel whenever you want), | 126 | inserted in and remvoed from the running kernel whenever you want), |
127 | say M here and read <file:Documentation/modules.txt>. The module | 127 | say M here and read <file:Documentation/kbuild/modules.txt>. The |
128 | will be called iwl3945.ko. | 128 | module will be called iwl3945.ko. |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index 557deebca1b9..891f90d2f019 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -3232,9 +3232,7 @@ int iwl4965_tx_cmd(struct iwl_priv *priv, struct iwl_cmd *out_cmd, | |||
3232 | tx->rate_n_flags = iwl_hw_set_rate_n_flags(iwl_rates[rate_index].plcp, | 3232 | tx->rate_n_flags = iwl_hw_set_rate_n_flags(iwl_rates[rate_index].plcp, |
3233 | rate_flags); | 3233 | rate_flags); |
3234 | 3234 | ||
3235 | if (ieee80211_is_probe_request(fc)) | 3235 | if (ieee80211_is_back_request(fc)) |
3236 | tx->tx_flags |= TX_CMD_FLG_TSF_MSK; | ||
3237 | else if (ieee80211_is_back_request(fc)) | ||
3238 | tx->tx_flags |= TX_CMD_FLG_ACK_MSK | | 3236 | tx->tx_flags |= TX_CMD_FLG_ACK_MSK | |
3239 | TX_CMD_FLG_IMM_BA_RSP_MASK; | 3237 | TX_CMD_FLG_IMM_BA_RSP_MASK; |
3240 | #ifdef CONFIG_IWLWIFI_HT | 3238 | #ifdef CONFIG_IWLWIFI_HT |
@@ -3872,7 +3870,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, | |||
3872 | */ | 3870 | */ |
3873 | case IEEE80211_STYPE_ASSOC_RESP: | 3871 | case IEEE80211_STYPE_ASSOC_RESP: |
3874 | case IEEE80211_STYPE_REASSOC_RESP: | 3872 | case IEEE80211_STYPE_REASSOC_RESP: |
3875 | if (network_packet && iwl_is_associated(priv)) { | 3873 | if (network_packet) { |
3876 | #ifdef CONFIG_IWLWIFI_HT | 3874 | #ifdef CONFIG_IWLWIFI_HT |
3877 | u8 *pos = NULL; | 3875 | u8 *pos = NULL; |
3878 | struct ieee802_11_elems elems; | 3876 | struct ieee802_11_elems elems; |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 83019d1d7ccc..4f22a7174caf 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -6478,8 +6478,9 @@ static void iwl_bg_scan_check(struct work_struct *data) | |||
6478 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, | 6478 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, |
6479 | "Scan completion watchdog resetting adapter (%dms)\n", | 6479 | "Scan completion watchdog resetting adapter (%dms)\n", |
6480 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); | 6480 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); |
6481 | |||
6481 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) | 6482 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) |
6482 | queue_work(priv->workqueue, &priv->restart); | 6483 | iwl_send_scan_abort(priv); |
6483 | } | 6484 | } |
6484 | mutex_unlock(&priv->mutex); | 6485 | mutex_unlock(&priv->mutex); |
6485 | } | 6486 | } |
@@ -6575,7 +6576,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
6575 | spin_unlock_irqrestore(&priv->lock, flags); | 6576 | spin_unlock_irqrestore(&priv->lock, flags); |
6576 | 6577 | ||
6577 | scan->suspend_time = 0; | 6578 | scan->suspend_time = 0; |
6578 | scan->max_out_time = cpu_to_le32(600 * 1024); | 6579 | scan->max_out_time = cpu_to_le32(200 * 1024); |
6579 | if (!interval) | 6580 | if (!interval) |
6580 | interval = suspend_time; | 6581 | interval = suspend_time; |
6581 | /* | 6582 | /* |
@@ -6605,7 +6606,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
6605 | memcpy(scan->direct_scan[0].ssid, | 6606 | memcpy(scan->direct_scan[0].ssid, |
6606 | priv->direct_ssid, priv->direct_ssid_len); | 6607 | priv->direct_ssid, priv->direct_ssid_len); |
6607 | direct_mask = 1; | 6608 | direct_mask = 1; |
6608 | } else if (!iwl_is_associated(priv)) { | 6609 | } else if (!iwl_is_associated(priv) && priv->essid_len) { |
6609 | scan->direct_scan[0].id = WLAN_EID_SSID; | 6610 | scan->direct_scan[0].id = WLAN_EID_SSID; |
6610 | scan->direct_scan[0].len = priv->essid_len; | 6611 | scan->direct_scan[0].len = priv->essid_len; |
6611 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); | 6612 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); |
@@ -6744,6 +6745,12 @@ static void iwl_bg_post_associate(struct work_struct *data) | |||
6744 | 6745 | ||
6745 | mutex_lock(&priv->mutex); | 6746 | mutex_lock(&priv->mutex); |
6746 | 6747 | ||
6748 | if (!priv->interface_id || !priv->is_open) { | ||
6749 | mutex_unlock(&priv->mutex); | ||
6750 | return; | ||
6751 | } | ||
6752 | iwl_scan_cancel_timeout(priv, 200); | ||
6753 | |||
6747 | conf = ieee80211_get_hw_conf(priv->hw); | 6754 | conf = ieee80211_get_hw_conf(priv->hw); |
6748 | 6755 | ||
6749 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 6756 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
@@ -6882,9 +6889,19 @@ static void iwl_mac_stop(struct ieee80211_hw *hw) | |||
6882 | struct iwl_priv *priv = hw->priv; | 6889 | struct iwl_priv *priv = hw->priv; |
6883 | 6890 | ||
6884 | IWL_DEBUG_MAC80211("enter\n"); | 6891 | IWL_DEBUG_MAC80211("enter\n"); |
6892 | |||
6893 | |||
6894 | mutex_lock(&priv->mutex); | ||
6895 | /* stop mac, cancel any scan request and clear | ||
6896 | * RXON_FILTER_ASSOC_MSK BIT | ||
6897 | */ | ||
6885 | priv->is_open = 0; | 6898 | priv->is_open = 0; |
6886 | /*netif_stop_queue(dev); */ | 6899 | iwl_scan_cancel_timeout(priv, 100); |
6887 | flush_workqueue(priv->workqueue); | 6900 | cancel_delayed_work(&priv->post_associate); |
6901 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
6902 | iwl_commit_rxon(priv); | ||
6903 | mutex_unlock(&priv->mutex); | ||
6904 | |||
6888 | IWL_DEBUG_MAC80211("leave\n"); | 6905 | IWL_DEBUG_MAC80211("leave\n"); |
6889 | } | 6906 | } |
6890 | 6907 | ||
@@ -7169,8 +7186,6 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, | |||
7169 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) | 7186 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) |
7170 | iwl_config_ap(priv); | 7187 | iwl_config_ap(priv); |
7171 | else { | 7188 | else { |
7172 | priv->staging_rxon.filter_flags |= | ||
7173 | RXON_FILTER_ASSOC_MSK; | ||
7174 | rc = iwl_commit_rxon(priv); | 7189 | rc = iwl_commit_rxon(priv); |
7175 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) | 7190 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) |
7176 | iwl_add_station(priv, | 7191 | iwl_add_station(priv, |
@@ -7178,6 +7193,7 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, | |||
7178 | } | 7193 | } |
7179 | 7194 | ||
7180 | } else { | 7195 | } else { |
7196 | iwl_scan_cancel_timeout(priv, 100); | ||
7181 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 7197 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
7182 | iwl_commit_rxon(priv); | 7198 | iwl_commit_rxon(priv); |
7183 | } | 7199 | } |
@@ -7217,6 +7233,12 @@ static void iwl_mac_remove_interface(struct ieee80211_hw *hw, | |||
7217 | IWL_DEBUG_MAC80211("enter\n"); | 7233 | IWL_DEBUG_MAC80211("enter\n"); |
7218 | 7234 | ||
7219 | mutex_lock(&priv->mutex); | 7235 | mutex_lock(&priv->mutex); |
7236 | |||
7237 | iwl_scan_cancel_timeout(priv, 100); | ||
7238 | cancel_delayed_work(&priv->post_associate); | ||
7239 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7240 | iwl_commit_rxon(priv); | ||
7241 | |||
7220 | if (priv->interface_id == conf->if_id) { | 7242 | if (priv->interface_id == conf->if_id) { |
7221 | priv->interface_id = 0; | 7243 | priv->interface_id = 0; |
7222 | memset(priv->bssid, 0, ETH_ALEN); | 7244 | memset(priv->bssid, 0, ETH_ALEN); |
@@ -7238,6 +7260,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7238 | 7260 | ||
7239 | IWL_DEBUG_MAC80211("enter\n"); | 7261 | IWL_DEBUG_MAC80211("enter\n"); |
7240 | 7262 | ||
7263 | mutex_lock(&priv->mutex); | ||
7241 | spin_lock_irqsave(&priv->lock, flags); | 7264 | spin_lock_irqsave(&priv->lock, flags); |
7242 | 7265 | ||
7243 | if (!iwl_is_ready_rf(priv)) { | 7266 | if (!iwl_is_ready_rf(priv)) { |
@@ -7268,7 +7291,8 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7268 | priv->direct_ssid_len = (u8) | 7291 | priv->direct_ssid_len = (u8) |
7269 | min((u8) len, (u8) IW_ESSID_MAX_SIZE); | 7292 | min((u8) len, (u8) IW_ESSID_MAX_SIZE); |
7270 | memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); | 7293 | memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); |
7271 | } | 7294 | } else |
7295 | priv->one_direct_scan = 0; | ||
7272 | 7296 | ||
7273 | rc = iwl_scan_initiate(priv); | 7297 | rc = iwl_scan_initiate(priv); |
7274 | 7298 | ||
@@ -7276,6 +7300,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7276 | 7300 | ||
7277 | out_unlock: | 7301 | out_unlock: |
7278 | spin_unlock_irqrestore(&priv->lock, flags); | 7302 | spin_unlock_irqrestore(&priv->lock, flags); |
7303 | mutex_unlock(&priv->mutex); | ||
7279 | 7304 | ||
7280 | return rc; | 7305 | return rc; |
7281 | } | 7306 | } |
@@ -7310,6 +7335,8 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
7310 | 7335 | ||
7311 | mutex_lock(&priv->mutex); | 7336 | mutex_lock(&priv->mutex); |
7312 | 7337 | ||
7338 | iwl_scan_cancel_timeout(priv, 100); | ||
7339 | |||
7313 | switch (cmd) { | 7340 | switch (cmd) { |
7314 | case SET_KEY: | 7341 | case SET_KEY: |
7315 | rc = iwl_update_sta_key_info(priv, key, sta_id); | 7342 | rc = iwl_update_sta_key_info(priv, key, sta_id); |
@@ -7479,8 +7506,18 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw) | |||
7479 | 7506 | ||
7480 | spin_unlock_irqrestore(&priv->lock, flags); | 7507 | spin_unlock_irqrestore(&priv->lock, flags); |
7481 | 7508 | ||
7509 | /* we are restarting association process | ||
7510 | * clear RXON_FILTER_ASSOC_MSK bit | ||
7511 | */ | ||
7512 | if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { | ||
7513 | iwl_scan_cancel_timeout(priv, 100); | ||
7514 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7515 | iwl_commit_rxon(priv); | ||
7516 | } | ||
7517 | |||
7482 | /* Per mac80211.h: This is only used in IBSS mode... */ | 7518 | /* Per mac80211.h: This is only used in IBSS mode... */ |
7483 | if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { | 7519 | if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { |
7520 | |||
7484 | IWL_DEBUG_MAC80211("leave - not in IBSS\n"); | 7521 | IWL_DEBUG_MAC80211("leave - not in IBSS\n"); |
7485 | mutex_unlock(&priv->mutex); | 7522 | mutex_unlock(&priv->mutex); |
7486 | return; | 7523 | return; |
@@ -8558,6 +8595,9 @@ static void iwl_pci_remove(struct pci_dev *pdev) | |||
8558 | iwl_rate_control_unregister(priv->hw); | 8595 | iwl_rate_control_unregister(priv->hw); |
8559 | } | 8596 | } |
8560 | 8597 | ||
8598 | /*netif_stop_queue(dev); */ | ||
8599 | flush_workqueue(priv->workqueue); | ||
8600 | |||
8561 | /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes | 8601 | /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes |
8562 | * priv->workqueue... so we can't take down the workqueue | 8602 | * priv->workqueue... so we can't take down the workqueue |
8563 | * until now... */ | 8603 | * until now... */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 5e1279263b22..d60adcb9bd4a 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c | |||
@@ -6845,8 +6845,9 @@ static void iwl_bg_scan_check(struct work_struct *data) | |||
6845 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, | 6845 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, |
6846 | "Scan completion watchdog resetting adapter (%dms)\n", | 6846 | "Scan completion watchdog resetting adapter (%dms)\n", |
6847 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); | 6847 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); |
6848 | |||
6848 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) | 6849 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) |
6849 | queue_work(priv->workqueue, &priv->restart); | 6850 | iwl_send_scan_abort(priv); |
6850 | } | 6851 | } |
6851 | mutex_unlock(&priv->mutex); | 6852 | mutex_unlock(&priv->mutex); |
6852 | } | 6853 | } |
@@ -6942,7 +6943,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
6942 | spin_unlock_irqrestore(&priv->lock, flags); | 6943 | spin_unlock_irqrestore(&priv->lock, flags); |
6943 | 6944 | ||
6944 | scan->suspend_time = 0; | 6945 | scan->suspend_time = 0; |
6945 | scan->max_out_time = cpu_to_le32(600 * 1024); | 6946 | scan->max_out_time = cpu_to_le32(200 * 1024); |
6946 | if (!interval) | 6947 | if (!interval) |
6947 | interval = suspend_time; | 6948 | interval = suspend_time; |
6948 | 6949 | ||
@@ -6965,7 +6966,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
6965 | memcpy(scan->direct_scan[0].ssid, | 6966 | memcpy(scan->direct_scan[0].ssid, |
6966 | priv->direct_ssid, priv->direct_ssid_len); | 6967 | priv->direct_ssid, priv->direct_ssid_len); |
6967 | direct_mask = 1; | 6968 | direct_mask = 1; |
6968 | } else if (!iwl_is_associated(priv)) { | 6969 | } else if (!iwl_is_associated(priv) && priv->essid_len) { |
6969 | scan->direct_scan[0].id = WLAN_EID_SSID; | 6970 | scan->direct_scan[0].id = WLAN_EID_SSID; |
6970 | scan->direct_scan[0].len = priv->essid_len; | 6971 | scan->direct_scan[0].len = priv->essid_len; |
6971 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); | 6972 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); |
@@ -7118,6 +7119,12 @@ static void iwl_bg_post_associate(struct work_struct *data) | |||
7118 | 7119 | ||
7119 | mutex_lock(&priv->mutex); | 7120 | mutex_lock(&priv->mutex); |
7120 | 7121 | ||
7122 | if (!priv->interface_id || !priv->is_open) { | ||
7123 | mutex_unlock(&priv->mutex); | ||
7124 | return; | ||
7125 | } | ||
7126 | iwl_scan_cancel_timeout(priv, 200); | ||
7127 | |||
7121 | conf = ieee80211_get_hw_conf(priv->hw); | 7128 | conf = ieee80211_get_hw_conf(priv->hw); |
7122 | 7129 | ||
7123 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 7130 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
@@ -7271,9 +7278,19 @@ static void iwl_mac_stop(struct ieee80211_hw *hw) | |||
7271 | struct iwl_priv *priv = hw->priv; | 7278 | struct iwl_priv *priv = hw->priv; |
7272 | 7279 | ||
7273 | IWL_DEBUG_MAC80211("enter\n"); | 7280 | IWL_DEBUG_MAC80211("enter\n"); |
7281 | |||
7282 | |||
7283 | mutex_lock(&priv->mutex); | ||
7284 | /* stop mac, cancel any scan request and clear | ||
7285 | * RXON_FILTER_ASSOC_MSK BIT | ||
7286 | */ | ||
7274 | priv->is_open = 0; | 7287 | priv->is_open = 0; |
7275 | /*netif_stop_queue(dev); */ | 7288 | iwl_scan_cancel_timeout(priv, 100); |
7276 | flush_workqueue(priv->workqueue); | 7289 | cancel_delayed_work(&priv->post_associate); |
7290 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7291 | iwl_commit_rxon(priv); | ||
7292 | mutex_unlock(&priv->mutex); | ||
7293 | |||
7277 | IWL_DEBUG_MAC80211("leave\n"); | 7294 | IWL_DEBUG_MAC80211("leave\n"); |
7278 | } | 7295 | } |
7279 | 7296 | ||
@@ -7573,8 +7590,6 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, | |||
7573 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) | 7590 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) |
7574 | iwl_config_ap(priv); | 7591 | iwl_config_ap(priv); |
7575 | else { | 7592 | else { |
7576 | priv->staging_rxon.filter_flags |= | ||
7577 | RXON_FILTER_ASSOC_MSK; | ||
7578 | rc = iwl_commit_rxon(priv); | 7593 | rc = iwl_commit_rxon(priv); |
7579 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) | 7594 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) |
7580 | iwl_rxon_add_station( | 7595 | iwl_rxon_add_station( |
@@ -7582,6 +7597,7 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, | |||
7582 | } | 7597 | } |
7583 | 7598 | ||
7584 | } else { | 7599 | } else { |
7600 | iwl_scan_cancel_timeout(priv, 100); | ||
7585 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 7601 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
7586 | iwl_commit_rxon(priv); | 7602 | iwl_commit_rxon(priv); |
7587 | } | 7603 | } |
@@ -7621,6 +7637,12 @@ static void iwl_mac_remove_interface(struct ieee80211_hw *hw, | |||
7621 | IWL_DEBUG_MAC80211("enter\n"); | 7637 | IWL_DEBUG_MAC80211("enter\n"); |
7622 | 7638 | ||
7623 | mutex_lock(&priv->mutex); | 7639 | mutex_lock(&priv->mutex); |
7640 | |||
7641 | iwl_scan_cancel_timeout(priv, 100); | ||
7642 | cancel_delayed_work(&priv->post_associate); | ||
7643 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7644 | iwl_commit_rxon(priv); | ||
7645 | |||
7624 | if (priv->interface_id == conf->if_id) { | 7646 | if (priv->interface_id == conf->if_id) { |
7625 | priv->interface_id = 0; | 7647 | priv->interface_id = 0; |
7626 | memset(priv->bssid, 0, ETH_ALEN); | 7648 | memset(priv->bssid, 0, ETH_ALEN); |
@@ -7642,6 +7664,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7642 | 7664 | ||
7643 | IWL_DEBUG_MAC80211("enter\n"); | 7665 | IWL_DEBUG_MAC80211("enter\n"); |
7644 | 7666 | ||
7667 | mutex_lock(&priv->mutex); | ||
7645 | spin_lock_irqsave(&priv->lock, flags); | 7668 | spin_lock_irqsave(&priv->lock, flags); |
7646 | 7669 | ||
7647 | if (!iwl_is_ready_rf(priv)) { | 7670 | if (!iwl_is_ready_rf(priv)) { |
@@ -7672,7 +7695,8 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7672 | priv->direct_ssid_len = (u8) | 7695 | priv->direct_ssid_len = (u8) |
7673 | min((u8) len, (u8) IW_ESSID_MAX_SIZE); | 7696 | min((u8) len, (u8) IW_ESSID_MAX_SIZE); |
7674 | memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); | 7697 | memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); |
7675 | } | 7698 | } else |
7699 | priv->one_direct_scan = 0; | ||
7676 | 7700 | ||
7677 | rc = iwl_scan_initiate(priv); | 7701 | rc = iwl_scan_initiate(priv); |
7678 | 7702 | ||
@@ -7680,6 +7704,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7680 | 7704 | ||
7681 | out_unlock: | 7705 | out_unlock: |
7682 | spin_unlock_irqrestore(&priv->lock, flags); | 7706 | spin_unlock_irqrestore(&priv->lock, flags); |
7707 | mutex_unlock(&priv->mutex); | ||
7683 | 7708 | ||
7684 | return rc; | 7709 | return rc; |
7685 | } | 7710 | } |
@@ -7713,6 +7738,8 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
7713 | 7738 | ||
7714 | mutex_lock(&priv->mutex); | 7739 | mutex_lock(&priv->mutex); |
7715 | 7740 | ||
7741 | iwl_scan_cancel_timeout(priv, 100); | ||
7742 | |||
7716 | switch (cmd) { | 7743 | switch (cmd) { |
7717 | case SET_KEY: | 7744 | case SET_KEY: |
7718 | rc = iwl_update_sta_key_info(priv, key, sta_id); | 7745 | rc = iwl_update_sta_key_info(priv, key, sta_id); |
@@ -7903,8 +7930,18 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw) | |||
7903 | 7930 | ||
7904 | spin_unlock_irqrestore(&priv->lock, flags); | 7931 | spin_unlock_irqrestore(&priv->lock, flags); |
7905 | 7932 | ||
7933 | /* we are restarting association process | ||
7934 | * clear RXON_FILTER_ASSOC_MSK bit | ||
7935 | */ | ||
7936 | if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { | ||
7937 | iwl_scan_cancel_timeout(priv, 100); | ||
7938 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | ||
7939 | iwl_commit_rxon(priv); | ||
7940 | } | ||
7941 | |||
7906 | /* Per mac80211.h: This is only used in IBSS mode... */ | 7942 | /* Per mac80211.h: This is only used in IBSS mode... */ |
7907 | if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { | 7943 | if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { |
7944 | |||
7908 | IWL_DEBUG_MAC80211("leave - not in IBSS\n"); | 7945 | IWL_DEBUG_MAC80211("leave - not in IBSS\n"); |
7909 | mutex_unlock(&priv->mutex); | 7946 | mutex_unlock(&priv->mutex); |
7910 | return; | 7947 | return; |
@@ -9152,6 +9189,9 @@ static void iwl_pci_remove(struct pci_dev *pdev) | |||
9152 | iwl_rate_control_unregister(priv->hw); | 9189 | iwl_rate_control_unregister(priv->hw); |
9153 | } | 9190 | } |
9154 | 9191 | ||
9192 | /*netif_stop_queue(dev); */ | ||
9193 | flush_workqueue(priv->workqueue); | ||
9194 | |||
9155 | /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes | 9195 | /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes |
9156 | * priv->workqueue... so we can't take down the workqueue | 9196 | * priv->workqueue... so we can't take down the workqueue |
9157 | * until now... */ | 9197 | * until now... */ |
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h index 298faa9d3f61..06d9bc0015c0 100644 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h | |||
@@ -30,7 +30,7 @@ | |||
30 | * Interval defines | 30 | * Interval defines |
31 | * Both the link tuner as the rfkill will be called once per second. | 31 | * Both the link tuner as the rfkill will be called once per second. |
32 | */ | 32 | */ |
33 | #define LINK_TUNE_INTERVAL ( round_jiffies(HZ) ) | 33 | #define LINK_TUNE_INTERVAL ( round_jiffies_relative(HZ) ) |
34 | #define RFKILL_POLL_INTERVAL ( 1000 ) | 34 | #define RFKILL_POLL_INTERVAL ( 1000 ) |
35 | 35 | ||
36 | /* | 36 | /* |
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c index de61c8fe6492..e454ae83e97a 100644 --- a/drivers/net/wireless/rtl8187_dev.c +++ b/drivers/net/wireless/rtl8187_dev.c | |||
@@ -433,6 +433,9 @@ static int rtl8187_start(struct ieee80211_hw *dev) | |||
433 | 433 | ||
434 | rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0xFFFF); | 434 | rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0xFFFF); |
435 | 435 | ||
436 | rtl818x_iowrite32(priv, &priv->map->MAR[0], ~0); | ||
437 | rtl818x_iowrite32(priv, &priv->map->MAR[1], ~0); | ||
438 | |||
436 | rtl8187_init_urbs(dev); | 439 | rtl8187_init_urbs(dev); |
437 | 440 | ||
438 | reg = RTL818X_RX_CONF_ONLYERLPKT | | 441 | reg = RTL818X_RX_CONF_ONLYERLPKT | |
@@ -582,32 +585,31 @@ static int rtl8187_config_interface(struct ieee80211_hw *dev, int if_id, | |||
582 | static void rtl8187_configure_filter(struct ieee80211_hw *dev, | 585 | static void rtl8187_configure_filter(struct ieee80211_hw *dev, |
583 | unsigned int changed_flags, | 586 | unsigned int changed_flags, |
584 | unsigned int *total_flags, | 587 | unsigned int *total_flags, |
585 | int mc_count, struct dev_addr_list *mc_list) | 588 | int mc_count, struct dev_addr_list *mclist) |
586 | { | 589 | { |
587 | struct rtl8187_priv *priv = dev->priv; | 590 | struct rtl8187_priv *priv = dev->priv; |
588 | 591 | ||
589 | *total_flags = 0; | ||
590 | |||
591 | if (changed_flags & FIF_ALLMULTI) | ||
592 | priv->rx_conf ^= RTL818X_RX_CONF_MULTICAST; | ||
593 | if (changed_flags & FIF_FCSFAIL) | 592 | if (changed_flags & FIF_FCSFAIL) |
594 | priv->rx_conf ^= RTL818X_RX_CONF_FCS; | 593 | priv->rx_conf ^= RTL818X_RX_CONF_FCS; |
595 | if (changed_flags & FIF_CONTROL) | 594 | if (changed_flags & FIF_CONTROL) |
596 | priv->rx_conf ^= RTL818X_RX_CONF_CTRL; | 595 | priv->rx_conf ^= RTL818X_RX_CONF_CTRL; |
597 | if (changed_flags & FIF_OTHER_BSS) | 596 | if (changed_flags & FIF_OTHER_BSS) |
598 | priv->rx_conf ^= RTL818X_RX_CONF_MONITOR; | 597 | priv->rx_conf ^= RTL818X_RX_CONF_MONITOR; |
599 | 598 | if (*total_flags & FIF_ALLMULTI || mc_count > 0) | |
600 | if (mc_count > 0) | ||
601 | priv->rx_conf |= RTL818X_RX_CONF_MULTICAST; | 599 | priv->rx_conf |= RTL818X_RX_CONF_MULTICAST; |
600 | else | ||
601 | priv->rx_conf &= ~RTL818X_RX_CONF_MULTICAST; | ||
602 | |||
603 | *total_flags = 0; | ||
602 | 604 | ||
603 | if (priv->rx_conf & RTL818X_RX_CONF_MULTICAST) | ||
604 | *total_flags |= FIF_ALLMULTI; | ||
605 | if (priv->rx_conf & RTL818X_RX_CONF_FCS) | 605 | if (priv->rx_conf & RTL818X_RX_CONF_FCS) |
606 | *total_flags |= FIF_FCSFAIL; | 606 | *total_flags |= FIF_FCSFAIL; |
607 | if (priv->rx_conf & RTL818X_RX_CONF_CTRL) | 607 | if (priv->rx_conf & RTL818X_RX_CONF_CTRL) |
608 | *total_flags |= FIF_CONTROL; | 608 | *total_flags |= FIF_CONTROL; |
609 | if (priv->rx_conf & RTL818X_RX_CONF_MONITOR) | 609 | if (priv->rx_conf & RTL818X_RX_CONF_MONITOR) |
610 | *total_flags |= FIF_OTHER_BSS; | 610 | *total_flags |= FIF_OTHER_BSS; |
611 | if (priv->rx_conf & RTL818X_RX_CONF_MULTICAST) | ||
612 | *total_flags |= FIF_ALLMULTI; | ||
611 | 613 | ||
612 | rtl818x_iowrite32_async(priv, &priv->map->RX_CONF, priv->rx_conf); | 614 | rtl818x_iowrite32_async(priv, &priv->map->RX_CONF, priv->rx_conf); |
613 | } | 615 | } |
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index 0c4ab3b07274..e079a5237c94 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "intel-iommu.h" | 34 | #include "intel-iommu.h" |
35 | #include <asm/proto.h> /* force_iommu in this header in x86-64*/ | 35 | #include <asm/proto.h> /* force_iommu in this header in x86-64*/ |
36 | #include <asm/cacheflush.h> | 36 | #include <asm/cacheflush.h> |
37 | #include <asm/iommu.h> | 37 | #include <asm/gart.h> |
38 | #include "pci.h" | 38 | #include "pci.h" |
39 | 39 | ||
40 | #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) | 40 | #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) |
@@ -745,12 +745,12 @@ static char *fault_reason_strings[] = | |||
745 | "non-zero reserved fields in PTE", | 745 | "non-zero reserved fields in PTE", |
746 | "Unknown" | 746 | "Unknown" |
747 | }; | 747 | }; |
748 | #define MAX_FAULT_REASON_IDX ARRAY_SIZE(fault_reason_strings) | 748 | #define MAX_FAULT_REASON_IDX ARRAY_SIZE(fault_reason_strings) - 1 |
749 | 749 | ||
750 | char *dmar_get_fault_reason(u8 fault_reason) | 750 | char *dmar_get_fault_reason(u8 fault_reason) |
751 | { | 751 | { |
752 | if (fault_reason > MAX_FAULT_REASON_IDX) | 752 | if (fault_reason >= MAX_FAULT_REASON_IDX) |
753 | return fault_reason_strings[MAX_FAULT_REASON_IDX]; | 753 | return fault_reason_strings[MAX_FAULT_REASON_IDX - 1]; |
754 | else | 754 | else |
755 | return fault_reason_strings[fault_reason]; | 755 | return fault_reason_strings[fault_reason]; |
756 | } | 756 | } |
@@ -995,7 +995,6 @@ static struct intel_iommu *alloc_iommu(struct dmar_drhd_unit *drhd) | |||
995 | return iommu; | 995 | return iommu; |
996 | error_unmap: | 996 | error_unmap: |
997 | iounmap(iommu->reg); | 997 | iounmap(iommu->reg); |
998 | iommu->reg = 0; | ||
999 | error: | 998 | error: |
1000 | kfree(iommu); | 999 | kfree(iommu); |
1001 | return NULL; | 1000 | return NULL; |
@@ -1808,7 +1807,7 @@ get_valid_domain_for_dev(struct pci_dev *pdev) | |||
1808 | if (!domain) { | 1807 | if (!domain) { |
1809 | printk(KERN_ERR | 1808 | printk(KERN_ERR |
1810 | "Allocating domain for %s failed", pci_name(pdev)); | 1809 | "Allocating domain for %s failed", pci_name(pdev)); |
1811 | return 0; | 1810 | return NULL; |
1812 | } | 1811 | } |
1813 | 1812 | ||
1814 | /* make sure context mapping is ok */ | 1813 | /* make sure context mapping is ok */ |
@@ -1818,7 +1817,7 @@ get_valid_domain_for_dev(struct pci_dev *pdev) | |||
1818 | printk(KERN_ERR | 1817 | printk(KERN_ERR |
1819 | "Domain context map for %s failed", | 1818 | "Domain context map for %s failed", |
1820 | pci_name(pdev)); | 1819 | pci_name(pdev)); |
1821 | return 0; | 1820 | return NULL; |
1822 | } | 1821 | } |
1823 | } | 1822 | } |
1824 | 1823 | ||
diff --git a/drivers/pci/intel-iommu.h b/drivers/pci/intel-iommu.h index ee88dd2400cb..459ad1f9dc54 100644 --- a/drivers/pci/intel-iommu.h +++ b/drivers/pci/intel-iommu.h | |||
@@ -58,7 +58,7 @@ | |||
58 | hi = readl(dmar + reg + 4); \ | 58 | hi = readl(dmar + reg + 4); \ |
59 | (((u64) hi) << 32) + lo; }) | 59 | (((u64) hi) << 32) + lo; }) |
60 | */ | 60 | */ |
61 | static inline u64 dmar_readq(void *addr) | 61 | static inline u64 dmar_readq(void __iomem *addr) |
62 | { | 62 | { |
63 | u32 lo, hi; | 63 | u32 lo, hi; |
64 | lo = readl(addr); | 64 | lo = readl(addr); |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 8c1012b432bb..e2041b4d0c85 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -542,8 +542,6 @@ static int s3c_rtc_probe(struct platform_device *pdev) | |||
542 | 542 | ||
543 | /* RTC Power management control */ | 543 | /* RTC Power management control */ |
544 | 544 | ||
545 | static struct timespec s3c_rtc_delta; | ||
546 | |||
547 | static int ticnt_save; | 545 | static int ticnt_save; |
548 | 546 | ||
549 | static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 547 | static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state) |
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index fd5d0c1570df..00118499018b 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c | |||
@@ -562,8 +562,6 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size) | |||
562 | sg_init_table(sg_list->sg, sg_list->count); | 562 | sg_init_table(sg_list->sg, sg_list->count); |
563 | 563 | ||
564 | for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { | 564 | for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { |
565 | sg->length = min(size, PAGE_SIZE); | ||
566 | sg->offset = 0; | ||
567 | address = (void *) get_zeroed_page(GFP_KERNEL); | 565 | address = (void *) get_zeroed_page(GFP_KERNEL); |
568 | if (address == NULL) { | 566 | if (address == NULL) { |
569 | sg_list->count = i; | 567 | sg_list->count = i; |
@@ -571,7 +569,7 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size) | |||
571 | retval = -ENOMEM; | 569 | retval = -ENOMEM; |
572 | goto out; | 570 | goto out; |
573 | } | 571 | } |
574 | zfcp_address_to_sg(address, sg); | 572 | zfcp_address_to_sg(address, sg, min(size, PAGE_SIZE)); |
575 | size -= sg->length; | 573 | size -= sg->length; |
576 | } | 574 | } |
577 | 575 | ||
@@ -1518,13 +1516,13 @@ zfcp_gid_pn_buffers_alloc(struct zfcp_gid_pn_data **gid_pn, mempool_t *pool) | |||
1518 | return -ENOMEM; | 1516 | return -ENOMEM; |
1519 | 1517 | ||
1520 | memset(data, 0, sizeof(*data)); | 1518 | memset(data, 0, sizeof(*data)); |
1519 | sg_init_table(&data->req , 1); | ||
1520 | sg_init_table(&data->resp , 1); | ||
1521 | data->ct.req = &data->req; | 1521 | data->ct.req = &data->req; |
1522 | data->ct.resp = &data->resp; | 1522 | data->ct.resp = &data->resp; |
1523 | data->ct.req_count = data->ct.resp_count = 1; | 1523 | data->ct.req_count = data->ct.resp_count = 1; |
1524 | zfcp_address_to_sg(&data->ct_iu_req, &data->req); | 1524 | zfcp_address_to_sg(&data->ct_iu_req, &data->req, sizeof(struct ct_iu_gid_pn_req)); |
1525 | zfcp_address_to_sg(&data->ct_iu_resp, &data->resp); | 1525 | zfcp_address_to_sg(&data->ct_iu_resp, &data->resp, sizeof(struct ct_iu_gid_pn_resp)); |
1526 | data->req.length = sizeof(struct ct_iu_gid_pn_req); | ||
1527 | data->resp.length = sizeof(struct ct_iu_gid_pn_resp); | ||
1528 | 1526 | ||
1529 | *gid_pn = data; | 1527 | *gid_pn = data; |
1530 | return 0; | 1528 | return 0; |
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index 326e7ee232cb..e268f79bdbd2 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h | |||
@@ -70,12 +70,12 @@ zfcp_sg_to_address(struct scatterlist *list) | |||
70 | * zfcp_address_to_sg - set up struct scatterlist from kernel address | 70 | * zfcp_address_to_sg - set up struct scatterlist from kernel address |
71 | * @address: kernel address | 71 | * @address: kernel address |
72 | * @list: struct scatterlist | 72 | * @list: struct scatterlist |
73 | * @size: buffer size | ||
73 | */ | 74 | */ |
74 | static inline void | 75 | static inline void |
75 | zfcp_address_to_sg(void *address, struct scatterlist *list) | 76 | zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size) |
76 | { | 77 | { |
77 | sg_set_page(list, virt_to_page(address)); | 78 | sg_set_buf(list, address, size); |
78 | list->offset = ((unsigned long) address) & (PAGE_SIZE - 1); | ||
79 | } | 79 | } |
80 | 80 | ||
81 | #define REQUEST_LIST_SIZE 128 | 81 | #define REQUEST_LIST_SIZE 128 |
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index 9438d0b28799..5552b755c08a 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c | |||
@@ -322,9 +322,9 @@ zfcp_erp_adisc(struct zfcp_port *port) | |||
322 | if (address == NULL) | 322 | if (address == NULL) |
323 | goto nomem; | 323 | goto nomem; |
324 | 324 | ||
325 | zfcp_address_to_sg(address, send_els->req); | 325 | zfcp_address_to_sg(address, send_els->req, sizeof(struct zfcp_ls_adisc)); |
326 | address += PAGE_SIZE >> 1; | 326 | address += PAGE_SIZE >> 1; |
327 | zfcp_address_to_sg(address, send_els->resp); | 327 | zfcp_address_to_sg(address, send_els->resp, sizeof(struct zfcp_ls_adisc_acc)); |
328 | send_els->req_count = send_els->resp_count = 1; | 328 | send_els->req_count = send_els->resp_count = 1; |
329 | 329 | ||
330 | send_els->adapter = adapter; | 330 | send_els->adapter = adapter; |
@@ -336,9 +336,6 @@ zfcp_erp_adisc(struct zfcp_port *port) | |||
336 | adisc = zfcp_sg_to_address(send_els->req); | 336 | adisc = zfcp_sg_to_address(send_els->req); |
337 | send_els->ls_code = adisc->code = ZFCP_LS_ADISC; | 337 | send_els->ls_code = adisc->code = ZFCP_LS_ADISC; |
338 | 338 | ||
339 | send_els->req->length = sizeof(struct zfcp_ls_adisc); | ||
340 | send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc); | ||
341 | |||
342 | /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports | 339 | /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports |
343 | without FC-AL-2 capability, so we don't set it */ | 340 | without FC-AL-2 capability, so we don't set it */ |
344 | adisc->wwpn = fc_host_port_name(adapter->scsi_host); | 341 | adisc->wwpn = fc_host_port_name(adapter->scsi_host); |
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index a5763c6e9362..86cf10efb0c1 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -172,12 +172,12 @@ config CHR_DEV_SCH | |||
172 | don't need this for those tiny 6-slot cdrom changers. Media | 172 | don't need this for those tiny 6-slot cdrom changers. Media |
173 | changers are listed as "Type: Medium Changer" in /proc/scsi/scsi. | 173 | changers are listed as "Type: Medium Changer" in /proc/scsi/scsi. |
174 | If you have such hardware and want to use it with linux, say Y | 174 | If you have such hardware and want to use it with linux, say Y |
175 | here. Check <file:Documentation/scsi-changer.txt> for details. | 175 | here. Check <file:Documentation/scsi/scsi-changer.txt> for details. |
176 | 176 | ||
177 | If you want to compile this as a module ( = code which can be | 177 | If you want to compile this as a module ( = code which can be |
178 | inserted in and removed from the running kernel whenever you want), | 178 | inserted in and removed from the running kernel whenever you want), |
179 | say M here and read <file:Documentation/kbuild/modules.txt> and | 179 | say M here and read <file:Documentation/kbuild/modules.txt> and |
180 | <file:Documentation/scsi.txt>. The module will be called ch.o. | 180 | <file:Documentation/scsi/scsi.txt>. The module will be called ch.o. |
181 | If unsure, say N. | 181 | If unsure, say N. |
182 | 182 | ||
183 | 183 | ||
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 72b0393b4596..1e6d7a9c75bf 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c | |||
@@ -391,7 +391,7 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) | |||
391 | /* | 391 | /* |
392 | * Extract the fibctx from the input parameters | 392 | * Extract the fibctx from the input parameters |
393 | */ | 393 | */ |
394 | if (fibctx->unique == (u32)(ptrdiff_t)arg) /* We found a winner */ | 394 | if (fibctx->unique == (u32)(uintptr_t)arg) /* We found a winner */ |
395 | break; | 395 | break; |
396 | entry = entry->next; | 396 | entry = entry->next; |
397 | fibctx = NULL; | 397 | fibctx = NULL; |
@@ -590,7 +590,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
590 | } | 590 | } |
591 | addr = (u64)upsg->sg[i].addr[0]; | 591 | addr = (u64)upsg->sg[i].addr[0]; |
592 | addr += ((u64)upsg->sg[i].addr[1]) << 32; | 592 | addr += ((u64)upsg->sg[i].addr[1]) << 32; |
593 | sg_user[i] = (void __user *)(ptrdiff_t)addr; | 593 | sg_user[i] = (void __user *)(uintptr_t)addr; |
594 | sg_list[i] = p; // save so we can clean up later | 594 | sg_list[i] = p; // save so we can clean up later |
595 | sg_indx = i; | 595 | sg_indx = i; |
596 | 596 | ||
@@ -633,7 +633,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
633 | rcode = -ENOMEM; | 633 | rcode = -ENOMEM; |
634 | goto cleanup; | 634 | goto cleanup; |
635 | } | 635 | } |
636 | sg_user[i] = (void __user *)(ptrdiff_t)usg->sg[i].addr; | 636 | sg_user[i] = (void __user *)(uintptr_t)usg->sg[i].addr; |
637 | sg_list[i] = p; // save so we can clean up later | 637 | sg_list[i] = p; // save so we can clean up later |
638 | sg_indx = i; | 638 | sg_indx = i; |
639 | 639 | ||
@@ -664,7 +664,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
664 | if (actual_fibsize64 == fibsize) { | 664 | if (actual_fibsize64 == fibsize) { |
665 | struct user_sgmap64* usg = (struct user_sgmap64 *)upsg; | 665 | struct user_sgmap64* usg = (struct user_sgmap64 *)upsg; |
666 | for (i = 0; i < upsg->count; i++) { | 666 | for (i = 0; i < upsg->count; i++) { |
667 | u64 addr; | 667 | uintptr_t addr; |
668 | void* p; | 668 | void* p; |
669 | /* Does this really need to be GFP_DMA? */ | 669 | /* Does this really need to be GFP_DMA? */ |
670 | p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); | 670 | p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); |
@@ -676,7 +676,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
676 | } | 676 | } |
677 | addr = (u64)usg->sg[i].addr[0]; | 677 | addr = (u64)usg->sg[i].addr[0]; |
678 | addr += ((u64)usg->sg[i].addr[1]) << 32; | 678 | addr += ((u64)usg->sg[i].addr[1]) << 32; |
679 | sg_user[i] = (void __user *)(ptrdiff_t)addr; | 679 | sg_user[i] = (void __user *)addr; |
680 | sg_list[i] = p; // save so we can clean up later | 680 | sg_list[i] = p; // save so we can clean up later |
681 | sg_indx = i; | 681 | sg_indx = i; |
682 | 682 | ||
@@ -704,7 +704,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
704 | rcode = -ENOMEM; | 704 | rcode = -ENOMEM; |
705 | goto cleanup; | 705 | goto cleanup; |
706 | } | 706 | } |
707 | sg_user[i] = (void __user *)(ptrdiff_t)upsg->sg[i].addr; | 707 | sg_user[i] = (void __user *)(uintptr_t)upsg->sg[i].addr; |
708 | sg_list[i] = p; // save so we can clean up later | 708 | sg_list[i] = p; // save so we can clean up later |
709 | sg_indx = i; | 709 | sg_indx = i; |
710 | 710 | ||
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 3009ad8c4073..8736813a0296 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c | |||
@@ -110,7 +110,7 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co | |||
110 | /* | 110 | /* |
111 | * Align the beginning of Headers to commalign | 111 | * Align the beginning of Headers to commalign |
112 | */ | 112 | */ |
113 | align = (commalign - ((ptrdiff_t)(base) & (commalign - 1))); | 113 | align = (commalign - ((uintptr_t)(base) & (commalign - 1))); |
114 | base = base + align; | 114 | base = base + align; |
115 | phys = phys + align; | 115 | phys = phys + align; |
116 | /* | 116 | /* |
diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c index fcd25f7d0bc6..e6032ffc66a6 100644 --- a/drivers/scsi/aacraid/dpcsup.c +++ b/drivers/scsi/aacraid/dpcsup.c | |||
@@ -254,7 +254,7 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index) | |||
254 | kfree (fib); | 254 | kfree (fib); |
255 | return 1; | 255 | return 1; |
256 | } | 256 | } |
257 | memcpy(hw_fib, (struct hw_fib *)(((ptrdiff_t)(dev->regs.sa)) + | 257 | memcpy(hw_fib, (struct hw_fib *)(((uintptr_t)(dev->regs.sa)) + |
258 | (index & ~0x00000002L)), sizeof(struct hw_fib)); | 258 | (index & ~0x00000002L)), sizeof(struct hw_fib)); |
259 | INIT_LIST_HEAD(&fib->fiblink); | 259 | INIT_LIST_HEAD(&fib->fiblink); |
260 | fib->type = FSAFS_NTC_FIB_CONTEXT; | 260 | fib->type = FSAFS_NTC_FIB_CONTEXT; |
diff --git a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h index ace7a15b413e..a67e29f83ae5 100644 --- a/drivers/scsi/arcmsr/arcmsr.h +++ b/drivers/scsi/arcmsr/arcmsr.h | |||
@@ -141,14 +141,14 @@ struct CMD_MESSAGE_FIELD | |||
141 | #define IS_SG64_ADDR 0x01000000 /* bit24 */ | 141 | #define IS_SG64_ADDR 0x01000000 /* bit24 */ |
142 | struct SG32ENTRY | 142 | struct SG32ENTRY |
143 | { | 143 | { |
144 | uint32_t length; | 144 | __le32 length; |
145 | uint32_t address; | 145 | __le32 address; |
146 | }; | 146 | }; |
147 | struct SG64ENTRY | 147 | struct SG64ENTRY |
148 | { | 148 | { |
149 | uint32_t length; | 149 | __le32 length; |
150 | uint32_t address; | 150 | __le32 address; |
151 | uint32_t addresshigh; | 151 | __le32 addresshigh; |
152 | }; | 152 | }; |
153 | struct SGENTRY_UNION | 153 | struct SGENTRY_UNION |
154 | { | 154 | { |
@@ -339,23 +339,15 @@ struct MessageUnit_B | |||
339 | uint32_t done_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE]; | 339 | uint32_t done_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE]; |
340 | uint32_t postq_index; | 340 | uint32_t postq_index; |
341 | uint32_t doneq_index; | 341 | uint32_t doneq_index; |
342 | uint32_t *drv2iop_doorbell_reg; | 342 | uint32_t __iomem *drv2iop_doorbell_reg; |
343 | uint32_t *drv2iop_doorbell_mask_reg; | 343 | uint32_t __iomem *drv2iop_doorbell_mask_reg; |
344 | uint32_t *iop2drv_doorbell_reg; | 344 | uint32_t __iomem *iop2drv_doorbell_reg; |
345 | uint32_t *iop2drv_doorbell_mask_reg; | 345 | uint32_t __iomem *iop2drv_doorbell_mask_reg; |
346 | uint32_t *msgcode_rwbuffer_reg; | 346 | uint32_t __iomem *msgcode_rwbuffer_reg; |
347 | uint32_t *ioctl_wbuffer_reg; | 347 | uint32_t __iomem *ioctl_wbuffer_reg; |
348 | uint32_t *ioctl_rbuffer_reg; | 348 | uint32_t __iomem *ioctl_rbuffer_reg; |
349 | }; | 349 | }; |
350 | 350 | ||
351 | struct MessageUnit | ||
352 | { | ||
353 | union | ||
354 | { | ||
355 | struct MessageUnit_A pmu_A; | ||
356 | struct MessageUnit_B pmu_B; | ||
357 | } u; | ||
358 | }; | ||
359 | /* | 351 | /* |
360 | ******************************************************************************* | 352 | ******************************************************************************* |
361 | ** Adapter Control Block | 353 | ** Adapter Control Block |
@@ -374,7 +366,10 @@ struct AdapterControlBlock | |||
374 | /* Offset is used in making arc cdb physical to virtual calculations */ | 366 | /* Offset is used in making arc cdb physical to virtual calculations */ |
375 | uint32_t outbound_int_enable; | 367 | uint32_t outbound_int_enable; |
376 | 368 | ||
377 | struct MessageUnit * pmu; | 369 | union { |
370 | struct MessageUnit_A __iomem * pmuA; | ||
371 | struct MessageUnit_B * pmuB; | ||
372 | }; | ||
378 | /* message unit ATU inbound base address0 */ | 373 | /* message unit ATU inbound base address0 */ |
379 | 374 | ||
380 | uint32_t acb_flags; | 375 | uint32_t acb_flags; |
@@ -558,7 +553,7 @@ struct SENSE_DATA | |||
558 | 553 | ||
559 | extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *); | 554 | extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *); |
560 | extern void arcmsr_iop_message_read(struct AdapterControlBlock *); | 555 | extern void arcmsr_iop_message_read(struct AdapterControlBlock *); |
561 | extern struct QBUFFER *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *); | 556 | extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *); |
562 | extern struct class_device_attribute *arcmsr_host_attrs[]; | 557 | extern struct class_device_attribute *arcmsr_host_attrs[]; |
563 | extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *); | 558 | extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *); |
564 | void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb); | 559 | void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb); |
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c index d04d1aa28fa4..7d7b0a554276 100644 --- a/drivers/scsi/arcmsr/arcmsr_attr.c +++ b/drivers/scsi/arcmsr/arcmsr_attr.c | |||
@@ -85,13 +85,13 @@ static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj, | |||
85 | allxfer_len++; | 85 | allxfer_len++; |
86 | } | 86 | } |
87 | if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { | 87 | if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { |
88 | struct QBUFFER *prbuffer; | 88 | struct QBUFFER __iomem *prbuffer; |
89 | uint8_t *iop_data; | 89 | uint8_t __iomem *iop_data; |
90 | int32_t iop_len; | 90 | int32_t iop_len; |
91 | 91 | ||
92 | acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; | 92 | acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; |
93 | prbuffer = arcmsr_get_iop_rqbuffer(acb); | 93 | prbuffer = arcmsr_get_iop_rqbuffer(acb); |
94 | iop_data = (uint8_t *)prbuffer->data; | 94 | iop_data = prbuffer->data; |
95 | iop_len = readl(&prbuffer->data_len); | 95 | iop_len = readl(&prbuffer->data_len); |
96 | while (iop_len > 0) { | 96 | while (iop_len > 0) { |
97 | acb->rqbuffer[acb->rqbuf_lastindex] = readb(iop_data); | 97 | acb->rqbuffer[acb->rqbuf_lastindex] = readb(iop_data); |
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index f7a252885a5c..d466a2dac1db 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c | |||
@@ -236,18 +236,22 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) | |||
236 | uint32_t intmask_org; | 236 | uint32_t intmask_org; |
237 | int i, j; | 237 | int i, j; |
238 | 238 | ||
239 | acb->pmu = ioremap(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); | 239 | acb->pmuA = ioremap(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); |
240 | if (!acb->pmu) { | 240 | if (!acb->pmuA) { |
241 | printk(KERN_NOTICE "arcmsr%d: memory mapping region fail \n", | 241 | printk(KERN_NOTICE "arcmsr%d: memory mapping region fail \n", |
242 | acb->host->host_no); | 242 | acb->host->host_no); |
243 | return -ENOMEM; | ||
243 | } | 244 | } |
244 | 245 | ||
245 | dma_coherent = dma_alloc_coherent(&pdev->dev, | 246 | dma_coherent = dma_alloc_coherent(&pdev->dev, |
246 | ARCMSR_MAX_FREECCB_NUM * | 247 | ARCMSR_MAX_FREECCB_NUM * |
247 | sizeof (struct CommandControlBlock) + 0x20, | 248 | sizeof (struct CommandControlBlock) + 0x20, |
248 | &dma_coherent_handle, GFP_KERNEL); | 249 | &dma_coherent_handle, GFP_KERNEL); |
249 | if (!dma_coherent) | 250 | |
251 | if (!dma_coherent) { | ||
252 | iounmap(acb->pmuA); | ||
250 | return -ENOMEM; | 253 | return -ENOMEM; |
254 | } | ||
251 | 255 | ||
252 | acb->dma_coherent = dma_coherent; | 256 | acb->dma_coherent = dma_coherent; |
253 | acb->dma_coherent_handle = dma_coherent_handle; | 257 | acb->dma_coherent_handle = dma_coherent_handle; |
@@ -287,7 +291,7 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) | |||
287 | 291 | ||
288 | struct pci_dev *pdev = acb->pdev; | 292 | struct pci_dev *pdev = acb->pdev; |
289 | struct MessageUnit_B *reg; | 293 | struct MessageUnit_B *reg; |
290 | void *mem_base0, *mem_base1; | 294 | void __iomem *mem_base0, *mem_base1; |
291 | void *dma_coherent; | 295 | void *dma_coherent; |
292 | dma_addr_t dma_coherent_handle, dma_addr; | 296 | dma_addr_t dma_coherent_handle, dma_addr; |
293 | uint32_t intmask_org; | 297 | uint32_t intmask_org; |
@@ -328,25 +332,28 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) | |||
328 | 332 | ||
329 | reg = (struct MessageUnit_B *)(dma_coherent + | 333 | reg = (struct MessageUnit_B *)(dma_coherent + |
330 | ARCMSR_MAX_FREECCB_NUM * sizeof(struct CommandControlBlock)); | 334 | ARCMSR_MAX_FREECCB_NUM * sizeof(struct CommandControlBlock)); |
331 | acb->pmu = (struct MessageUnit *)reg; | 335 | acb->pmuB = reg; |
332 | mem_base0 = ioremap(pci_resource_start(pdev, 0), | 336 | mem_base0 = ioremap(pci_resource_start(pdev, 0), |
333 | pci_resource_len(pdev, 0)); | 337 | pci_resource_len(pdev, 0)); |
338 | if (!mem_base0) | ||
339 | goto out; | ||
340 | |||
334 | mem_base1 = ioremap(pci_resource_start(pdev, 2), | 341 | mem_base1 = ioremap(pci_resource_start(pdev, 2), |
335 | pci_resource_len(pdev, 2)); | 342 | pci_resource_len(pdev, 2)); |
336 | reg->drv2iop_doorbell_reg = (uint32_t *)((char *)mem_base0 + | 343 | if (!mem_base1) { |
337 | ARCMSR_DRV2IOP_DOORBELL); | 344 | iounmap(mem_base0); |
338 | reg->drv2iop_doorbell_mask_reg = (uint32_t *)((char *)mem_base0 + | 345 | goto out; |
339 | ARCMSR_DRV2IOP_DOORBELL_MASK); | 346 | } |
340 | reg->iop2drv_doorbell_reg = (uint32_t *)((char *)mem_base0 + | 347 | |
341 | ARCMSR_IOP2DRV_DOORBELL); | 348 | reg->drv2iop_doorbell_reg = mem_base0 + ARCMSR_DRV2IOP_DOORBELL; |
342 | reg->iop2drv_doorbell_mask_reg = (uint32_t *)((char *)mem_base0 + | 349 | reg->drv2iop_doorbell_mask_reg = mem_base0 + |
343 | ARCMSR_IOP2DRV_DOORBELL_MASK); | 350 | ARCMSR_DRV2IOP_DOORBELL_MASK; |
344 | reg->ioctl_wbuffer_reg = (uint32_t *)((char *)mem_base1 + | 351 | reg->iop2drv_doorbell_reg = mem_base0 + ARCMSR_IOP2DRV_DOORBELL; |
345 | ARCMSR_IOCTL_WBUFFER); | 352 | reg->iop2drv_doorbell_mask_reg = mem_base0 + |
346 | reg->ioctl_rbuffer_reg = (uint32_t *)((char *)mem_base1 + | 353 | ARCMSR_IOP2DRV_DOORBELL_MASK; |
347 | ARCMSR_IOCTL_RBUFFER); | 354 | reg->ioctl_wbuffer_reg = mem_base1 + ARCMSR_IOCTL_WBUFFER; |
348 | reg->msgcode_rwbuffer_reg = (uint32_t *)((char *)mem_base1 + | 355 | reg->ioctl_rbuffer_reg = mem_base1 + ARCMSR_IOCTL_RBUFFER; |
349 | ARCMSR_MSGCODE_RWBUFFER); | 356 | reg->msgcode_rwbuffer_reg = mem_base1 + ARCMSR_MSGCODE_RWBUFFER; |
350 | 357 | ||
351 | acb->vir2phy_offset = (unsigned long)ccb_tmp -(unsigned long)dma_addr; | 358 | acb->vir2phy_offset = (unsigned long)ccb_tmp -(unsigned long)dma_addr; |
352 | for (i = 0; i < ARCMSR_MAX_TARGETID; i++) | 359 | for (i = 0; i < ARCMSR_MAX_TARGETID; i++) |
@@ -362,6 +369,12 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) | |||
362 | break; | 369 | break; |
363 | } | 370 | } |
364 | return 0; | 371 | return 0; |
372 | |||
373 | out: | ||
374 | dma_free_coherent(&acb->pdev->dev, | ||
375 | ARCMSR_MAX_FREECCB_NUM * sizeof(struct CommandControlBlock) + 0x20, | ||
376 | acb->dma_coherent, acb->dma_coherent_handle); | ||
377 | return -ENOMEM; | ||
365 | } | 378 | } |
366 | 379 | ||
367 | static int arcmsr_probe(struct pci_dev *pdev, | 380 | static int arcmsr_probe(struct pci_dev *pdev, |
@@ -454,7 +467,6 @@ static int arcmsr_probe(struct pci_dev *pdev, | |||
454 | free_irq(pdev->irq, acb); | 467 | free_irq(pdev->irq, acb); |
455 | out_free_ccb_pool: | 468 | out_free_ccb_pool: |
456 | arcmsr_free_ccb_pool(acb); | 469 | arcmsr_free_ccb_pool(acb); |
457 | iounmap(acb->pmu); | ||
458 | out_release_regions: | 470 | out_release_regions: |
459 | pci_release_regions(pdev); | 471 | pci_release_regions(pdev); |
460 | out_host_put: | 472 | out_host_put: |
@@ -467,7 +479,7 @@ static int arcmsr_probe(struct pci_dev *pdev, | |||
467 | 479 | ||
468 | static uint8_t arcmsr_hba_wait_msgint_ready(struct AdapterControlBlock *acb) | 480 | static uint8_t arcmsr_hba_wait_msgint_ready(struct AdapterControlBlock *acb) |
469 | { | 481 | { |
470 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 482 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
471 | uint32_t Index; | 483 | uint32_t Index; |
472 | uint8_t Retries = 0x00; | 484 | uint8_t Retries = 0x00; |
473 | 485 | ||
@@ -488,7 +500,7 @@ static uint8_t arcmsr_hba_wait_msgint_ready(struct AdapterControlBlock *acb) | |||
488 | 500 | ||
489 | static uint8_t arcmsr_hbb_wait_msgint_ready(struct AdapterControlBlock *acb) | 501 | static uint8_t arcmsr_hbb_wait_msgint_ready(struct AdapterControlBlock *acb) |
490 | { | 502 | { |
491 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 503 | struct MessageUnit_B *reg = acb->pmuB; |
492 | uint32_t Index; | 504 | uint32_t Index; |
493 | uint8_t Retries = 0x00; | 505 | uint8_t Retries = 0x00; |
494 | 506 | ||
@@ -509,7 +521,7 @@ static uint8_t arcmsr_hbb_wait_msgint_ready(struct AdapterControlBlock *acb) | |||
509 | 521 | ||
510 | static void arcmsr_abort_hba_allcmd(struct AdapterControlBlock *acb) | 522 | static void arcmsr_abort_hba_allcmd(struct AdapterControlBlock *acb) |
511 | { | 523 | { |
512 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 524 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
513 | 525 | ||
514 | writel(ARCMSR_INBOUND_MESG0_ABORT_CMD, ®->inbound_msgaddr0); | 526 | writel(ARCMSR_INBOUND_MESG0_ABORT_CMD, ®->inbound_msgaddr0); |
515 | if (arcmsr_hba_wait_msgint_ready(acb)) | 527 | if (arcmsr_hba_wait_msgint_ready(acb)) |
@@ -520,7 +532,7 @@ static void arcmsr_abort_hba_allcmd(struct AdapterControlBlock *acb) | |||
520 | 532 | ||
521 | static void arcmsr_abort_hbb_allcmd(struct AdapterControlBlock *acb) | 533 | static void arcmsr_abort_hbb_allcmd(struct AdapterControlBlock *acb) |
522 | { | 534 | { |
523 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 535 | struct MessageUnit_B *reg = acb->pmuB; |
524 | 536 | ||
525 | writel(ARCMSR_MESSAGE_ABORT_CMD, reg->drv2iop_doorbell_reg); | 537 | writel(ARCMSR_MESSAGE_ABORT_CMD, reg->drv2iop_doorbell_reg); |
526 | if (arcmsr_hbb_wait_msgint_ready(acb)) | 538 | if (arcmsr_hbb_wait_msgint_ready(acb)) |
@@ -566,7 +578,7 @@ static void arcmsr_ccb_complete(struct CommandControlBlock *ccb, int stand_flag) | |||
566 | 578 | ||
567 | static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb) | 579 | static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb) |
568 | { | 580 | { |
569 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 581 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
570 | int retry_count = 30; | 582 | int retry_count = 30; |
571 | 583 | ||
572 | writel(ARCMSR_INBOUND_MESG0_FLUSH_CACHE, ®->inbound_msgaddr0); | 584 | writel(ARCMSR_INBOUND_MESG0_FLUSH_CACHE, ®->inbound_msgaddr0); |
@@ -583,7 +595,7 @@ static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb) | |||
583 | 595 | ||
584 | static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb) | 596 | static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb) |
585 | { | 597 | { |
586 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 598 | struct MessageUnit_B *reg = acb->pmuB; |
587 | int retry_count = 30; | 599 | int retry_count = 30; |
588 | 600 | ||
589 | writel(ARCMSR_MESSAGE_FLUSH_CACHE, reg->drv2iop_doorbell_reg); | 601 | writel(ARCMSR_MESSAGE_FLUSH_CACHE, reg->drv2iop_doorbell_reg); |
@@ -637,7 +649,7 @@ static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb) | |||
637 | switch (acb->adapter_type) { | 649 | switch (acb->adapter_type) { |
638 | 650 | ||
639 | case ACB_ADAPTER_TYPE_A : { | 651 | case ACB_ADAPTER_TYPE_A : { |
640 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 652 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
641 | orig_mask = readl(®->outbound_intmask)|\ | 653 | orig_mask = readl(®->outbound_intmask)|\ |
642 | ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE; | 654 | ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE; |
643 | writel(orig_mask|ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE, \ | 655 | writel(orig_mask|ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE, \ |
@@ -646,7 +658,7 @@ static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb) | |||
646 | break; | 658 | break; |
647 | 659 | ||
648 | case ACB_ADAPTER_TYPE_B : { | 660 | case ACB_ADAPTER_TYPE_B : { |
649 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 661 | struct MessageUnit_B *reg = acb->pmuB; |
650 | orig_mask = readl(reg->iop2drv_doorbell_mask_reg) & \ | 662 | orig_mask = readl(reg->iop2drv_doorbell_mask_reg) & \ |
651 | (~ARCMSR_IOP2DRV_MESSAGE_CMD_DONE); | 663 | (~ARCMSR_IOP2DRV_MESSAGE_CMD_DONE); |
652 | writel(0, reg->iop2drv_doorbell_mask_reg); | 664 | writel(0, reg->iop2drv_doorbell_mask_reg); |
@@ -748,14 +760,13 @@ static void arcmsr_done4abort_postqueue(struct AdapterControlBlock *acb) | |||
748 | switch (acb->adapter_type) { | 760 | switch (acb->adapter_type) { |
749 | 761 | ||
750 | case ACB_ADAPTER_TYPE_A: { | 762 | case ACB_ADAPTER_TYPE_A: { |
751 | struct MessageUnit_A __iomem *reg = \ | 763 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
752 | (struct MessageUnit_A *)acb->pmu; | ||
753 | uint32_t outbound_intstatus; | 764 | uint32_t outbound_intstatus; |
754 | outbound_intstatus = readl(®->outbound_intstatus) & \ | 765 | outbound_intstatus = readl(®->outbound_intstatus) & |
755 | acb->outbound_int_enable; | 766 | acb->outbound_int_enable; |
756 | /*clear and abort all outbound posted Q*/ | 767 | /*clear and abort all outbound posted Q*/ |
757 | writel(outbound_intstatus, ®->outbound_intstatus);/*clear interrupt*/ | 768 | writel(outbound_intstatus, ®->outbound_intstatus);/*clear interrupt*/ |
758 | while (((flag_ccb = readl(®->outbound_queueport)) != 0xFFFFFFFF) \ | 769 | while (((flag_ccb = readl(®->outbound_queueport)) != 0xFFFFFFFF) |
759 | && (i++ < ARCMSR_MAX_OUTSTANDING_CMD)) { | 770 | && (i++ < ARCMSR_MAX_OUTSTANDING_CMD)) { |
760 | arcmsr_drain_donequeue(acb, flag_ccb); | 771 | arcmsr_drain_donequeue(acb, flag_ccb); |
761 | } | 772 | } |
@@ -763,7 +774,7 @@ static void arcmsr_done4abort_postqueue(struct AdapterControlBlock *acb) | |||
763 | break; | 774 | break; |
764 | 775 | ||
765 | case ACB_ADAPTER_TYPE_B: { | 776 | case ACB_ADAPTER_TYPE_B: { |
766 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 777 | struct MessageUnit_B *reg = acb->pmuB; |
767 | /*clear all outbound posted Q*/ | 778 | /*clear all outbound posted Q*/ |
768 | for (i = 0; i < ARCMSR_MAX_HBB_POSTQUEUE; i++) { | 779 | for (i = 0; i < ARCMSR_MAX_HBB_POSTQUEUE; i++) { |
769 | if ((flag_ccb = readl(®->done_qbuffer[i])) != 0) { | 780 | if ((flag_ccb = readl(®->done_qbuffer[i])) != 0) { |
@@ -816,7 +827,6 @@ static void arcmsr_remove(struct pci_dev *pdev) | |||
816 | } | 827 | } |
817 | 828 | ||
818 | free_irq(pdev->irq, acb); | 829 | free_irq(pdev->irq, acb); |
819 | iounmap(acb->pmu); | ||
820 | arcmsr_free_ccb_pool(acb); | 830 | arcmsr_free_ccb_pool(acb); |
821 | pci_release_regions(pdev); | 831 | pci_release_regions(pdev); |
822 | 832 | ||
@@ -859,7 +869,7 @@ static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb, \ | |||
859 | switch (acb->adapter_type) { | 869 | switch (acb->adapter_type) { |
860 | 870 | ||
861 | case ACB_ADAPTER_TYPE_A : { | 871 | case ACB_ADAPTER_TYPE_A : { |
862 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 872 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
863 | mask = intmask_org & ~(ARCMSR_MU_OUTBOUND_POSTQUEUE_INTMASKENABLE | | 873 | mask = intmask_org & ~(ARCMSR_MU_OUTBOUND_POSTQUEUE_INTMASKENABLE | |
864 | ARCMSR_MU_OUTBOUND_DOORBELL_INTMASKENABLE); | 874 | ARCMSR_MU_OUTBOUND_DOORBELL_INTMASKENABLE); |
865 | writel(mask, ®->outbound_intmask); | 875 | writel(mask, ®->outbound_intmask); |
@@ -868,7 +878,7 @@ static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb, \ | |||
868 | break; | 878 | break; |
869 | 879 | ||
870 | case ACB_ADAPTER_TYPE_B : { | 880 | case ACB_ADAPTER_TYPE_B : { |
871 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 881 | struct MessageUnit_B *reg = acb->pmuB; |
872 | mask = intmask_org | (ARCMSR_IOP2DRV_DATA_WRITE_OK | \ | 882 | mask = intmask_org | (ARCMSR_IOP2DRV_DATA_WRITE_OK | \ |
873 | ARCMSR_IOP2DRV_DATA_READ_OK | ARCMSR_IOP2DRV_CDB_DONE); | 883 | ARCMSR_IOP2DRV_DATA_READ_OK | ARCMSR_IOP2DRV_CDB_DONE); |
874 | writel(mask, reg->iop2drv_doorbell_mask_reg); | 884 | writel(mask, reg->iop2drv_doorbell_mask_reg); |
@@ -882,7 +892,7 @@ static void arcmsr_build_ccb(struct AdapterControlBlock *acb, | |||
882 | { | 892 | { |
883 | struct ARCMSR_CDB *arcmsr_cdb = (struct ARCMSR_CDB *)&ccb->arcmsr_cdb; | 893 | struct ARCMSR_CDB *arcmsr_cdb = (struct ARCMSR_CDB *)&ccb->arcmsr_cdb; |
884 | int8_t *psge = (int8_t *)&arcmsr_cdb->u; | 894 | int8_t *psge = (int8_t *)&arcmsr_cdb->u; |
885 | uint32_t address_lo, address_hi; | 895 | __le32 address_lo, address_hi; |
886 | int arccdbsize = 0x30; | 896 | int arccdbsize = 0x30; |
887 | int nseg; | 897 | int nseg; |
888 | 898 | ||
@@ -900,7 +910,8 @@ static void arcmsr_build_ccb(struct AdapterControlBlock *acb, | |||
900 | BUG_ON(nseg < 0); | 910 | BUG_ON(nseg < 0); |
901 | 911 | ||
902 | if (nseg) { | 912 | if (nseg) { |
903 | int length, i, cdb_sgcount = 0; | 913 | __le32 length; |
914 | int i, cdb_sgcount = 0; | ||
904 | struct scatterlist *sg; | 915 | struct scatterlist *sg; |
905 | 916 | ||
906 | /* map stor port SG list to our iop SG List. */ | 917 | /* map stor port SG list to our iop SG List. */ |
@@ -921,7 +932,7 @@ static void arcmsr_build_ccb(struct AdapterControlBlock *acb, | |||
921 | 932 | ||
922 | pdma_sg->addresshigh = address_hi; | 933 | pdma_sg->addresshigh = address_hi; |
923 | pdma_sg->address = address_lo; | 934 | pdma_sg->address = address_lo; |
924 | pdma_sg->length = length|IS_SG64_ADDR; | 935 | pdma_sg->length = length|cpu_to_le32(IS_SG64_ADDR); |
925 | psge += sizeof (struct SG64ENTRY); | 936 | psge += sizeof (struct SG64ENTRY); |
926 | arccdbsize += sizeof (struct SG64ENTRY); | 937 | arccdbsize += sizeof (struct SG64ENTRY); |
927 | } | 938 | } |
@@ -947,7 +958,7 @@ static void arcmsr_post_ccb(struct AdapterControlBlock *acb, struct CommandContr | |||
947 | 958 | ||
948 | switch (acb->adapter_type) { | 959 | switch (acb->adapter_type) { |
949 | case ACB_ADAPTER_TYPE_A: { | 960 | case ACB_ADAPTER_TYPE_A: { |
950 | struct MessageUnit_A *reg = (struct MessageUnit_A *)acb->pmu; | 961 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
951 | 962 | ||
952 | if (arcmsr_cdb->Flags & ARCMSR_CDB_FLAG_SGL_BSIZE) | 963 | if (arcmsr_cdb->Flags & ARCMSR_CDB_FLAG_SGL_BSIZE) |
953 | writel(cdb_shifted_phyaddr | ARCMSR_CCBPOST_FLAG_SGL_BSIZE, | 964 | writel(cdb_shifted_phyaddr | ARCMSR_CCBPOST_FLAG_SGL_BSIZE, |
@@ -959,7 +970,7 @@ static void arcmsr_post_ccb(struct AdapterControlBlock *acb, struct CommandContr | |||
959 | break; | 970 | break; |
960 | 971 | ||
961 | case ACB_ADAPTER_TYPE_B: { | 972 | case ACB_ADAPTER_TYPE_B: { |
962 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 973 | struct MessageUnit_B *reg = acb->pmuB; |
963 | uint32_t ending_index, index = reg->postq_index; | 974 | uint32_t ending_index, index = reg->postq_index; |
964 | 975 | ||
965 | ending_index = ((index + 1) % ARCMSR_MAX_HBB_POSTQUEUE); | 976 | ending_index = ((index + 1) % ARCMSR_MAX_HBB_POSTQUEUE); |
@@ -982,7 +993,7 @@ static void arcmsr_post_ccb(struct AdapterControlBlock *acb, struct CommandContr | |||
982 | 993 | ||
983 | static void arcmsr_stop_hba_bgrb(struct AdapterControlBlock *acb) | 994 | static void arcmsr_stop_hba_bgrb(struct AdapterControlBlock *acb) |
984 | { | 995 | { |
985 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 996 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
986 | acb->acb_flags &= ~ACB_F_MSG_START_BGRB; | 997 | acb->acb_flags &= ~ACB_F_MSG_START_BGRB; |
987 | writel(ARCMSR_INBOUND_MESG0_STOP_BGRB, ®->inbound_msgaddr0); | 998 | writel(ARCMSR_INBOUND_MESG0_STOP_BGRB, ®->inbound_msgaddr0); |
988 | 999 | ||
@@ -995,7 +1006,7 @@ static void arcmsr_stop_hba_bgrb(struct AdapterControlBlock *acb) | |||
995 | 1006 | ||
996 | static void arcmsr_stop_hbb_bgrb(struct AdapterControlBlock *acb) | 1007 | static void arcmsr_stop_hbb_bgrb(struct AdapterControlBlock *acb) |
997 | { | 1008 | { |
998 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1009 | struct MessageUnit_B *reg = acb->pmuB; |
999 | acb->acb_flags &= ~ACB_F_MSG_START_BGRB; | 1010 | acb->acb_flags &= ~ACB_F_MSG_START_BGRB; |
1000 | writel(ARCMSR_MESSAGE_STOP_BGRB, reg->drv2iop_doorbell_reg); | 1011 | writel(ARCMSR_MESSAGE_STOP_BGRB, reg->drv2iop_doorbell_reg); |
1001 | 1012 | ||
@@ -1023,6 +1034,17 @@ static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb) | |||
1023 | 1034 | ||
1024 | static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb) | 1035 | static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb) |
1025 | { | 1036 | { |
1037 | switch (acb->adapter_type) { | ||
1038 | case ACB_ADAPTER_TYPE_A: { | ||
1039 | iounmap(acb->pmuA); | ||
1040 | break; | ||
1041 | } | ||
1042 | case ACB_ADAPTER_TYPE_B: { | ||
1043 | struct MessageUnit_B *reg = acb->pmuB; | ||
1044 | iounmap(reg->drv2iop_doorbell_reg - ARCMSR_DRV2IOP_DOORBELL); | ||
1045 | iounmap(reg->ioctl_wbuffer_reg - ARCMSR_IOCTL_WBUFFER); | ||
1046 | } | ||
1047 | } | ||
1026 | dma_free_coherent(&acb->pdev->dev, | 1048 | dma_free_coherent(&acb->pdev->dev, |
1027 | ARCMSR_MAX_FREECCB_NUM * sizeof (struct CommandControlBlock) + 0x20, | 1049 | ARCMSR_MAX_FREECCB_NUM * sizeof (struct CommandControlBlock) + 0x20, |
1028 | acb->dma_coherent, | 1050 | acb->dma_coherent, |
@@ -1033,13 +1055,13 @@ void arcmsr_iop_message_read(struct AdapterControlBlock *acb) | |||
1033 | { | 1055 | { |
1034 | switch (acb->adapter_type) { | 1056 | switch (acb->adapter_type) { |
1035 | case ACB_ADAPTER_TYPE_A: { | 1057 | case ACB_ADAPTER_TYPE_A: { |
1036 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 1058 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1037 | writel(ARCMSR_INBOUND_DRIVER_DATA_READ_OK, ®->inbound_doorbell); | 1059 | writel(ARCMSR_INBOUND_DRIVER_DATA_READ_OK, ®->inbound_doorbell); |
1038 | } | 1060 | } |
1039 | break; | 1061 | break; |
1040 | 1062 | ||
1041 | case ACB_ADAPTER_TYPE_B: { | 1063 | case ACB_ADAPTER_TYPE_B: { |
1042 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1064 | struct MessageUnit_B *reg = acb->pmuB; |
1043 | writel(ARCMSR_DRV2IOP_DATA_READ_OK, reg->drv2iop_doorbell_reg); | 1065 | writel(ARCMSR_DRV2IOP_DATA_READ_OK, reg->drv2iop_doorbell_reg); |
1044 | } | 1066 | } |
1045 | break; | 1067 | break; |
@@ -1050,7 +1072,7 @@ static void arcmsr_iop_message_wrote(struct AdapterControlBlock *acb) | |||
1050 | { | 1072 | { |
1051 | switch (acb->adapter_type) { | 1073 | switch (acb->adapter_type) { |
1052 | case ACB_ADAPTER_TYPE_A: { | 1074 | case ACB_ADAPTER_TYPE_A: { |
1053 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 1075 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1054 | /* | 1076 | /* |
1055 | ** push inbound doorbell tell iop, driver data write ok | 1077 | ** push inbound doorbell tell iop, driver data write ok |
1056 | ** and wait reply on next hwinterrupt for next Qbuffer post | 1078 | ** and wait reply on next hwinterrupt for next Qbuffer post |
@@ -1060,7 +1082,7 @@ static void arcmsr_iop_message_wrote(struct AdapterControlBlock *acb) | |||
1060 | break; | 1082 | break; |
1061 | 1083 | ||
1062 | case ACB_ADAPTER_TYPE_B: { | 1084 | case ACB_ADAPTER_TYPE_B: { |
1063 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1085 | struct MessageUnit_B *reg = acb->pmuB; |
1064 | /* | 1086 | /* |
1065 | ** push inbound doorbell tell iop, driver data write ok | 1087 | ** push inbound doorbell tell iop, driver data write ok |
1066 | ** and wait reply on next hwinterrupt for next Qbuffer post | 1088 | ** and wait reply on next hwinterrupt for next Qbuffer post |
@@ -1071,41 +1093,41 @@ static void arcmsr_iop_message_wrote(struct AdapterControlBlock *acb) | |||
1071 | } | 1093 | } |
1072 | } | 1094 | } |
1073 | 1095 | ||
1074 | struct QBUFFER *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *acb) | 1096 | struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *acb) |
1075 | { | 1097 | { |
1076 | static struct QBUFFER *qbuffer; | 1098 | struct QBUFFER __iomem *qbuffer = NULL; |
1077 | 1099 | ||
1078 | switch (acb->adapter_type) { | 1100 | switch (acb->adapter_type) { |
1079 | 1101 | ||
1080 | case ACB_ADAPTER_TYPE_A: { | 1102 | case ACB_ADAPTER_TYPE_A: { |
1081 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 1103 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1082 | qbuffer = (struct QBUFFER __iomem *) ®->message_rbuffer; | 1104 | qbuffer = (struct QBUFFER __iomem *)®->message_rbuffer; |
1083 | } | 1105 | } |
1084 | break; | 1106 | break; |
1085 | 1107 | ||
1086 | case ACB_ADAPTER_TYPE_B: { | 1108 | case ACB_ADAPTER_TYPE_B: { |
1087 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1109 | struct MessageUnit_B *reg = acb->pmuB; |
1088 | qbuffer = (struct QBUFFER __iomem *) reg->ioctl_rbuffer_reg; | 1110 | qbuffer = (struct QBUFFER __iomem *)reg->ioctl_rbuffer_reg; |
1089 | } | 1111 | } |
1090 | break; | 1112 | break; |
1091 | } | 1113 | } |
1092 | return qbuffer; | 1114 | return qbuffer; |
1093 | } | 1115 | } |
1094 | 1116 | ||
1095 | static struct QBUFFER *arcmsr_get_iop_wqbuffer(struct AdapterControlBlock *acb) | 1117 | static struct QBUFFER __iomem *arcmsr_get_iop_wqbuffer(struct AdapterControlBlock *acb) |
1096 | { | 1118 | { |
1097 | static struct QBUFFER *pqbuffer; | 1119 | struct QBUFFER __iomem *pqbuffer = NULL; |
1098 | 1120 | ||
1099 | switch (acb->adapter_type) { | 1121 | switch (acb->adapter_type) { |
1100 | 1122 | ||
1101 | case ACB_ADAPTER_TYPE_A: { | 1123 | case ACB_ADAPTER_TYPE_A: { |
1102 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 1124 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1103 | pqbuffer = (struct QBUFFER *) ®->message_wbuffer; | 1125 | pqbuffer = (struct QBUFFER __iomem *) ®->message_wbuffer; |
1104 | } | 1126 | } |
1105 | break; | 1127 | break; |
1106 | 1128 | ||
1107 | case ACB_ADAPTER_TYPE_B: { | 1129 | case ACB_ADAPTER_TYPE_B: { |
1108 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1130 | struct MessageUnit_B *reg = acb->pmuB; |
1109 | pqbuffer = (struct QBUFFER __iomem *)reg->ioctl_wbuffer_reg; | 1131 | pqbuffer = (struct QBUFFER __iomem *)reg->ioctl_wbuffer_reg; |
1110 | } | 1132 | } |
1111 | break; | 1133 | break; |
@@ -1115,15 +1137,15 @@ static struct QBUFFER *arcmsr_get_iop_wqbuffer(struct AdapterControlBlock *acb) | |||
1115 | 1137 | ||
1116 | static void arcmsr_iop2drv_data_wrote_handle(struct AdapterControlBlock *acb) | 1138 | static void arcmsr_iop2drv_data_wrote_handle(struct AdapterControlBlock *acb) |
1117 | { | 1139 | { |
1118 | struct QBUFFER *prbuffer; | 1140 | struct QBUFFER __iomem *prbuffer; |
1119 | struct QBUFFER *pQbuffer; | 1141 | struct QBUFFER *pQbuffer; |
1120 | uint8_t *iop_data; | 1142 | uint8_t __iomem *iop_data; |
1121 | int32_t my_empty_len, iop_len, rqbuf_firstindex, rqbuf_lastindex; | 1143 | int32_t my_empty_len, iop_len, rqbuf_firstindex, rqbuf_lastindex; |
1122 | 1144 | ||
1123 | rqbuf_lastindex = acb->rqbuf_lastindex; | 1145 | rqbuf_lastindex = acb->rqbuf_lastindex; |
1124 | rqbuf_firstindex = acb->rqbuf_firstindex; | 1146 | rqbuf_firstindex = acb->rqbuf_firstindex; |
1125 | prbuffer = arcmsr_get_iop_rqbuffer(acb); | 1147 | prbuffer = arcmsr_get_iop_rqbuffer(acb); |
1126 | iop_data = (uint8_t *)prbuffer->data; | 1148 | iop_data = (uint8_t __iomem *)prbuffer->data; |
1127 | iop_len = prbuffer->data_len; | 1149 | iop_len = prbuffer->data_len; |
1128 | my_empty_len = (rqbuf_firstindex - rqbuf_lastindex -1)&(ARCMSR_MAX_QBUFFER -1); | 1150 | my_empty_len = (rqbuf_firstindex - rqbuf_lastindex -1)&(ARCMSR_MAX_QBUFFER -1); |
1129 | 1151 | ||
@@ -1151,8 +1173,8 @@ static void arcmsr_iop2drv_data_read_handle(struct AdapterControlBlock *acb) | |||
1151 | acb->acb_flags |= ACB_F_MESSAGE_WQBUFFER_READED; | 1173 | acb->acb_flags |= ACB_F_MESSAGE_WQBUFFER_READED; |
1152 | if (acb->wqbuf_firstindex != acb->wqbuf_lastindex) { | 1174 | if (acb->wqbuf_firstindex != acb->wqbuf_lastindex) { |
1153 | uint8_t *pQbuffer; | 1175 | uint8_t *pQbuffer; |
1154 | struct QBUFFER *pwbuffer; | 1176 | struct QBUFFER __iomem *pwbuffer; |
1155 | uint8_t *iop_data; | 1177 | uint8_t __iomem *iop_data; |
1156 | int32_t allxfer_len = 0; | 1178 | int32_t allxfer_len = 0; |
1157 | 1179 | ||
1158 | acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READED); | 1180 | acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READED); |
@@ -1181,7 +1203,7 @@ static void arcmsr_iop2drv_data_read_handle(struct AdapterControlBlock *acb) | |||
1181 | static void arcmsr_hba_doorbell_isr(struct AdapterControlBlock *acb) | 1203 | static void arcmsr_hba_doorbell_isr(struct AdapterControlBlock *acb) |
1182 | { | 1204 | { |
1183 | uint32_t outbound_doorbell; | 1205 | uint32_t outbound_doorbell; |
1184 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 1206 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1185 | 1207 | ||
1186 | outbound_doorbell = readl(®->outbound_doorbell); | 1208 | outbound_doorbell = readl(®->outbound_doorbell); |
1187 | writel(outbound_doorbell, ®->outbound_doorbell); | 1209 | writel(outbound_doorbell, ®->outbound_doorbell); |
@@ -1197,7 +1219,7 @@ static void arcmsr_hba_doorbell_isr(struct AdapterControlBlock *acb) | |||
1197 | static void arcmsr_hba_postqueue_isr(struct AdapterControlBlock *acb) | 1219 | static void arcmsr_hba_postqueue_isr(struct AdapterControlBlock *acb) |
1198 | { | 1220 | { |
1199 | uint32_t flag_ccb; | 1221 | uint32_t flag_ccb; |
1200 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 1222 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1201 | 1223 | ||
1202 | while ((flag_ccb = readl(®->outbound_queueport)) != 0xFFFFFFFF) { | 1224 | while ((flag_ccb = readl(®->outbound_queueport)) != 0xFFFFFFFF) { |
1203 | arcmsr_drain_donequeue(acb, flag_ccb); | 1225 | arcmsr_drain_donequeue(acb, flag_ccb); |
@@ -1208,7 +1230,7 @@ static void arcmsr_hbb_postqueue_isr(struct AdapterControlBlock *acb) | |||
1208 | { | 1230 | { |
1209 | uint32_t index; | 1231 | uint32_t index; |
1210 | uint32_t flag_ccb; | 1232 | uint32_t flag_ccb; |
1211 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1233 | struct MessageUnit_B *reg = acb->pmuB; |
1212 | 1234 | ||
1213 | index = reg->doneq_index; | 1235 | index = reg->doneq_index; |
1214 | 1236 | ||
@@ -1224,7 +1246,7 @@ static void arcmsr_hbb_postqueue_isr(struct AdapterControlBlock *acb) | |||
1224 | static int arcmsr_handle_hba_isr(struct AdapterControlBlock *acb) | 1246 | static int arcmsr_handle_hba_isr(struct AdapterControlBlock *acb) |
1225 | { | 1247 | { |
1226 | uint32_t outbound_intstatus; | 1248 | uint32_t outbound_intstatus; |
1227 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 1249 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1228 | 1250 | ||
1229 | outbound_intstatus = readl(®->outbound_intstatus) & \ | 1251 | outbound_intstatus = readl(®->outbound_intstatus) & \ |
1230 | acb->outbound_int_enable; | 1252 | acb->outbound_int_enable; |
@@ -1244,7 +1266,7 @@ static int arcmsr_handle_hba_isr(struct AdapterControlBlock *acb) | |||
1244 | static int arcmsr_handle_hbb_isr(struct AdapterControlBlock *acb) | 1266 | static int arcmsr_handle_hbb_isr(struct AdapterControlBlock *acb) |
1245 | { | 1267 | { |
1246 | uint32_t outbound_doorbell; | 1268 | uint32_t outbound_doorbell; |
1247 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1269 | struct MessageUnit_B *reg = acb->pmuB; |
1248 | 1270 | ||
1249 | outbound_doorbell = readl(reg->iop2drv_doorbell_reg) & \ | 1271 | outbound_doorbell = readl(reg->iop2drv_doorbell_reg) & \ |
1250 | acb->outbound_int_enable; | 1272 | acb->outbound_int_enable; |
@@ -1305,8 +1327,8 @@ void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *acb) | |||
1305 | { | 1327 | { |
1306 | int32_t wqbuf_firstindex, wqbuf_lastindex; | 1328 | int32_t wqbuf_firstindex, wqbuf_lastindex; |
1307 | uint8_t *pQbuffer; | 1329 | uint8_t *pQbuffer; |
1308 | struct QBUFFER *pwbuffer; | 1330 | struct QBUFFER __iomem *pwbuffer; |
1309 | uint8_t *iop_data; | 1331 | uint8_t __iomem *iop_data; |
1310 | int32_t allxfer_len = 0; | 1332 | int32_t allxfer_len = 0; |
1311 | 1333 | ||
1312 | pwbuffer = arcmsr_get_iop_wqbuffer(acb); | 1334 | pwbuffer = arcmsr_get_iop_wqbuffer(acb); |
@@ -1380,13 +1402,13 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \ | |||
1380 | } | 1402 | } |
1381 | if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { | 1403 | if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { |
1382 | 1404 | ||
1383 | struct QBUFFER *prbuffer; | 1405 | struct QBUFFER __iomem *prbuffer; |
1384 | uint8_t *iop_data; | 1406 | uint8_t __iomem *iop_data; |
1385 | int32_t iop_len; | 1407 | int32_t iop_len; |
1386 | 1408 | ||
1387 | acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; | 1409 | acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; |
1388 | prbuffer = arcmsr_get_iop_rqbuffer(acb); | 1410 | prbuffer = arcmsr_get_iop_rqbuffer(acb); |
1389 | iop_data = (uint8_t *)prbuffer->data; | 1411 | iop_data = prbuffer->data; |
1390 | iop_len = readl(&prbuffer->data_len); | 1412 | iop_len = readl(&prbuffer->data_len); |
1391 | while (iop_len > 0) { | 1413 | while (iop_len > 0) { |
1392 | acb->rqbuffer[acb->rqbuf_lastindex] = readb(iop_data); | 1414 | acb->rqbuffer[acb->rqbuf_lastindex] = readb(iop_data); |
@@ -1669,11 +1691,11 @@ static int arcmsr_queue_command(struct scsi_cmnd *cmd, | |||
1669 | 1691 | ||
1670 | static void arcmsr_get_hba_config(struct AdapterControlBlock *acb) | 1692 | static void arcmsr_get_hba_config(struct AdapterControlBlock *acb) |
1671 | { | 1693 | { |
1672 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 1694 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1673 | char *acb_firm_model = acb->firm_model; | 1695 | char *acb_firm_model = acb->firm_model; |
1674 | char *acb_firm_version = acb->firm_version; | 1696 | char *acb_firm_version = acb->firm_version; |
1675 | char *iop_firm_model = (char *) (®->message_rwbuffer[15]); | 1697 | char __iomem *iop_firm_model = (char __iomem *)(®->message_rwbuffer[15]); |
1676 | char *iop_firm_version = (char *) (®->message_rwbuffer[17]); | 1698 | char __iomem *iop_firm_version = (char __iomem *)(®->message_rwbuffer[17]); |
1677 | int count; | 1699 | int count; |
1678 | 1700 | ||
1679 | writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); | 1701 | writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); |
@@ -1710,13 +1732,13 @@ static void arcmsr_get_hba_config(struct AdapterControlBlock *acb) | |||
1710 | 1732 | ||
1711 | static void arcmsr_get_hbb_config(struct AdapterControlBlock *acb) | 1733 | static void arcmsr_get_hbb_config(struct AdapterControlBlock *acb) |
1712 | { | 1734 | { |
1713 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1735 | struct MessageUnit_B *reg = acb->pmuB; |
1714 | uint32_t *lrwbuffer = reg->msgcode_rwbuffer_reg; | 1736 | uint32_t __iomem *lrwbuffer = reg->msgcode_rwbuffer_reg; |
1715 | char *acb_firm_model = acb->firm_model; | 1737 | char *acb_firm_model = acb->firm_model; |
1716 | char *acb_firm_version = acb->firm_version; | 1738 | char *acb_firm_version = acb->firm_version; |
1717 | char *iop_firm_model = (char *) (&lrwbuffer[15]); | 1739 | char __iomem *iop_firm_model = (char __iomem *)(&lrwbuffer[15]); |
1718 | /*firm_model,15,60-67*/ | 1740 | /*firm_model,15,60-67*/ |
1719 | char *iop_firm_version = (char *) (&lrwbuffer[17]); | 1741 | char __iomem *iop_firm_version = (char __iomem *)(&lrwbuffer[17]); |
1720 | /*firm_version,17,68-83*/ | 1742 | /*firm_version,17,68-83*/ |
1721 | int count; | 1743 | int count; |
1722 | 1744 | ||
@@ -1777,7 +1799,7 @@ static void arcmsr_get_firmware_spec(struct AdapterControlBlock *acb) | |||
1777 | static void arcmsr_polling_hba_ccbdone(struct AdapterControlBlock *acb, | 1799 | static void arcmsr_polling_hba_ccbdone(struct AdapterControlBlock *acb, |
1778 | struct CommandControlBlock *poll_ccb) | 1800 | struct CommandControlBlock *poll_ccb) |
1779 | { | 1801 | { |
1780 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 1802 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1781 | struct CommandControlBlock *ccb; | 1803 | struct CommandControlBlock *ccb; |
1782 | uint32_t flag_ccb, outbound_intstatus, poll_ccb_done = 0, poll_count = 0; | 1804 | uint32_t flag_ccb, outbound_intstatus, poll_ccb_done = 0, poll_count = 0; |
1783 | 1805 | ||
@@ -1826,7 +1848,7 @@ static void arcmsr_polling_hba_ccbdone(struct AdapterControlBlock *acb, | |||
1826 | static void arcmsr_polling_hbb_ccbdone(struct AdapterControlBlock *acb, \ | 1848 | static void arcmsr_polling_hbb_ccbdone(struct AdapterControlBlock *acb, \ |
1827 | struct CommandControlBlock *poll_ccb) | 1849 | struct CommandControlBlock *poll_ccb) |
1828 | { | 1850 | { |
1829 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1851 | struct MessageUnit_B *reg = acb->pmuB; |
1830 | struct CommandControlBlock *ccb; | 1852 | struct CommandControlBlock *ccb; |
1831 | uint32_t flag_ccb, poll_ccb_done = 0, poll_count = 0; | 1853 | uint32_t flag_ccb, poll_ccb_done = 0, poll_count = 0; |
1832 | int index; | 1854 | int index; |
@@ -1918,8 +1940,7 @@ static int arcmsr_iop_confirm(struct AdapterControlBlock *acb) | |||
1918 | 1940 | ||
1919 | case ACB_ADAPTER_TYPE_A: { | 1941 | case ACB_ADAPTER_TYPE_A: { |
1920 | if (ccb_phyaddr_hi32 != 0) { | 1942 | if (ccb_phyaddr_hi32 != 0) { |
1921 | struct MessageUnit_A __iomem *reg = \ | 1943 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1922 | (struct MessageUnit_A *)acb->pmu; | ||
1923 | uint32_t intmask_org; | 1944 | uint32_t intmask_org; |
1924 | intmask_org = arcmsr_disable_outbound_ints(acb); | 1945 | intmask_org = arcmsr_disable_outbound_ints(acb); |
1925 | writel(ARCMSR_SIGNATURE_SET_CONFIG, \ | 1946 | writel(ARCMSR_SIGNATURE_SET_CONFIG, \ |
@@ -1940,9 +1961,9 @@ static int arcmsr_iop_confirm(struct AdapterControlBlock *acb) | |||
1940 | 1961 | ||
1941 | case ACB_ADAPTER_TYPE_B: { | 1962 | case ACB_ADAPTER_TYPE_B: { |
1942 | unsigned long post_queue_phyaddr; | 1963 | unsigned long post_queue_phyaddr; |
1943 | uint32_t *rwbuffer; | 1964 | uint32_t __iomem *rwbuffer; |
1944 | 1965 | ||
1945 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 1966 | struct MessageUnit_B *reg = acb->pmuB; |
1946 | uint32_t intmask_org; | 1967 | uint32_t intmask_org; |
1947 | intmask_org = arcmsr_disable_outbound_ints(acb); | 1968 | intmask_org = arcmsr_disable_outbound_ints(acb); |
1948 | reg->postq_index = 0; | 1969 | reg->postq_index = 0; |
@@ -1994,7 +2015,7 @@ static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb) | |||
1994 | switch (acb->adapter_type) { | 2015 | switch (acb->adapter_type) { |
1995 | 2016 | ||
1996 | case ACB_ADAPTER_TYPE_A: { | 2017 | case ACB_ADAPTER_TYPE_A: { |
1997 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 2018 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
1998 | do { | 2019 | do { |
1999 | firmware_state = readl(®->outbound_msgaddr1); | 2020 | firmware_state = readl(®->outbound_msgaddr1); |
2000 | } while ((firmware_state & ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK) == 0); | 2021 | } while ((firmware_state & ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK) == 0); |
@@ -2002,7 +2023,7 @@ static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb) | |||
2002 | break; | 2023 | break; |
2003 | 2024 | ||
2004 | case ACB_ADAPTER_TYPE_B: { | 2025 | case ACB_ADAPTER_TYPE_B: { |
2005 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 2026 | struct MessageUnit_B *reg = acb->pmuB; |
2006 | do { | 2027 | do { |
2007 | firmware_state = readl(reg->iop2drv_doorbell_reg); | 2028 | firmware_state = readl(reg->iop2drv_doorbell_reg); |
2008 | } while ((firmware_state & ARCMSR_MESSAGE_FIRMWARE_OK) == 0); | 2029 | } while ((firmware_state & ARCMSR_MESSAGE_FIRMWARE_OK) == 0); |
@@ -2013,7 +2034,7 @@ static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb) | |||
2013 | 2034 | ||
2014 | static void arcmsr_start_hba_bgrb(struct AdapterControlBlock *acb) | 2035 | static void arcmsr_start_hba_bgrb(struct AdapterControlBlock *acb) |
2015 | { | 2036 | { |
2016 | struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; | 2037 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
2017 | acb->acb_flags |= ACB_F_MSG_START_BGRB; | 2038 | acb->acb_flags |= ACB_F_MSG_START_BGRB; |
2018 | writel(ARCMSR_INBOUND_MESG0_START_BGRB, ®->inbound_msgaddr0); | 2039 | writel(ARCMSR_INBOUND_MESG0_START_BGRB, ®->inbound_msgaddr0); |
2019 | if (arcmsr_hba_wait_msgint_ready(acb)) { | 2040 | if (arcmsr_hba_wait_msgint_ready(acb)) { |
@@ -2024,7 +2045,7 @@ static void arcmsr_start_hba_bgrb(struct AdapterControlBlock *acb) | |||
2024 | 2045 | ||
2025 | static void arcmsr_start_hbb_bgrb(struct AdapterControlBlock *acb) | 2046 | static void arcmsr_start_hbb_bgrb(struct AdapterControlBlock *acb) |
2026 | { | 2047 | { |
2027 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 2048 | struct MessageUnit_B *reg = acb->pmuB; |
2028 | acb->acb_flags |= ACB_F_MSG_START_BGRB; | 2049 | acb->acb_flags |= ACB_F_MSG_START_BGRB; |
2029 | writel(ARCMSR_MESSAGE_START_BGRB, reg->drv2iop_doorbell_reg); | 2050 | writel(ARCMSR_MESSAGE_START_BGRB, reg->drv2iop_doorbell_reg); |
2030 | if (arcmsr_hbb_wait_msgint_ready(acb)) { | 2051 | if (arcmsr_hbb_wait_msgint_ready(acb)) { |
@@ -2049,7 +2070,7 @@ static void arcmsr_clear_doorbell_queue_buffer(struct AdapterControlBlock *acb) | |||
2049 | { | 2070 | { |
2050 | switch (acb->adapter_type) { | 2071 | switch (acb->adapter_type) { |
2051 | case ACB_ADAPTER_TYPE_A: { | 2072 | case ACB_ADAPTER_TYPE_A: { |
2052 | struct MessageUnit_A *reg = (struct MessageUnit_A *)acb->pmu; | 2073 | struct MessageUnit_A __iomem *reg = acb->pmuA; |
2053 | uint32_t outbound_doorbell; | 2074 | uint32_t outbound_doorbell; |
2054 | /* empty doorbell Qbuffer if door bell ringed */ | 2075 | /* empty doorbell Qbuffer if door bell ringed */ |
2055 | outbound_doorbell = readl(®->outbound_doorbell); | 2076 | outbound_doorbell = readl(®->outbound_doorbell); |
@@ -2060,7 +2081,7 @@ static void arcmsr_clear_doorbell_queue_buffer(struct AdapterControlBlock *acb) | |||
2060 | break; | 2081 | break; |
2061 | 2082 | ||
2062 | case ACB_ADAPTER_TYPE_B: { | 2083 | case ACB_ADAPTER_TYPE_B: { |
2063 | struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; | 2084 | struct MessageUnit_B *reg = acb->pmuB; |
2064 | /*clear interrupt and message state*/ | 2085 | /*clear interrupt and message state*/ |
2065 | writel(ARCMSR_MESSAGE_INT_CLEAR_PATTERN, reg->iop2drv_doorbell_reg); | 2086 | writel(ARCMSR_MESSAGE_INT_CLEAR_PATTERN, reg->iop2drv_doorbell_reg); |
2066 | writel(ARCMSR_DRV2IOP_DATA_READ_OK, reg->drv2iop_doorbell_reg); | 2087 | writel(ARCMSR_DRV2IOP_DATA_READ_OK, reg->drv2iop_doorbell_reg); |
diff --git a/drivers/scsi/arm/scsi.h b/drivers/scsi/arm/scsi.h index 21ba57155bea..bb6550e31926 100644 --- a/drivers/scsi/arm/scsi.h +++ b/drivers/scsi/arm/scsi.h | |||
@@ -38,9 +38,7 @@ static inline int next_SCp(struct scsi_pointer *SCp) | |||
38 | if (ret) { | 38 | if (ret) { |
39 | SCp->buffer++; | 39 | SCp->buffer++; |
40 | SCp->buffers_residual--; | 40 | SCp->buffers_residual--; |
41 | SCp->ptr = (char *) | 41 | SCp->ptr = sg_virt(SCp->buffer); |
42 | (page_address(SCp->buffer->page) + | ||
43 | SCp->buffer->offset); | ||
44 | SCp->this_residual = SCp->buffer->length; | 42 | SCp->this_residual = SCp->buffer->length; |
45 | } else { | 43 | } else { |
46 | SCp->ptr = NULL; | 44 | SCp->ptr = NULL; |
@@ -76,9 +74,7 @@ static inline void init_SCp(struct scsi_cmnd *SCpnt) | |||
76 | 74 | ||
77 | SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->request_buffer; | 75 | SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->request_buffer; |
78 | SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1; | 76 | SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1; |
79 | SCpnt->SCp.ptr = (char *) | 77 | SCpnt->SCp.ptr = sg_virt(SCpnt->SCp.buffer); |
80 | (page_address(SCpnt->SCp.buffer->page) + | ||
81 | SCpnt->SCp.buffer->offset); | ||
82 | SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; | 78 | SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; |
83 | SCpnt->SCp.phase = SCpnt->request_bufflen; | 79 | SCpnt->SCp.phase = SCpnt->request_bufflen; |
84 | 80 | ||
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index d1780980fb20..a9680b5e8ac6 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c | |||
@@ -477,10 +477,9 @@ static void merge_contiguous_buffers(Scsi_Cmnd *cmd) | |||
477 | 477 | ||
478 | for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; | 478 | for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; |
479 | cmd->SCp.buffers_residual && | 479 | cmd->SCp.buffers_residual && |
480 | virt_to_phys(page_address(cmd->SCp.buffer[1].page) + | 480 | virt_to_phys(sg_virt(&cmd->SCp.buffer[1])) == endaddr;) { |
481 | cmd->SCp.buffer[1].offset) == endaddr;) { | ||
482 | MER_PRINTK("VTOP(%p) == %08lx -> merging\n", | 481 | MER_PRINTK("VTOP(%p) == %08lx -> merging\n", |
483 | page_address(cmd->SCp.buffer[1].page), endaddr); | 482 | page_address(sg_page(&cmd->SCp.buffer[1])), endaddr); |
484 | #if (NDEBUG & NDEBUG_MERGING) | 483 | #if (NDEBUG & NDEBUG_MERGING) |
485 | ++cnt; | 484 | ++cnt; |
486 | #endif | 485 | #endif |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 439b97a6a269..0841df01bc19 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -2890,7 +2890,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len) | |||
2890 | return NULL; | 2890 | return NULL; |
2891 | } | 2891 | } |
2892 | 2892 | ||
2893 | sg_set_page(&scatterlist[i], page); | 2893 | sg_set_page(&scatterlist[i], page, 0, 0); |
2894 | } | 2894 | } |
2895 | 2895 | ||
2896 | return sglist; | 2896 | return sglist; |
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 6ce4109efdf3..4bcf916c21a7 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
@@ -79,9 +79,7 @@ static inline void | |||
79 | iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) | 79 | iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) |
80 | { | 80 | { |
81 | sg_init_table(&ibuf->sg, 1); | 81 | sg_init_table(&ibuf->sg, 1); |
82 | sg_set_page(&ibuf->sg, sg_page(sg)); | 82 | sg_set_page(&ibuf->sg, sg_page(sg), sg->length, sg->offset); |
83 | ibuf->sg.offset = sg->offset; | ||
84 | ibuf->sg.length = sg->length; | ||
85 | /* | 83 | /* |
86 | * Fastpath: sg element fits into single page | 84 | * Fastpath: sg element fits into single page |
87 | */ | 85 | */ |
@@ -676,9 +674,8 @@ partial_sg_digest_update(struct hash_desc *desc, struct scatterlist *sg, | |||
676 | { | 674 | { |
677 | struct scatterlist temp; | 675 | struct scatterlist temp; |
678 | 676 | ||
679 | memcpy(&temp, sg, sizeof(struct scatterlist)); | 677 | sg_init_table(&temp, 1); |
680 | temp.offset = offset; | 678 | sg_set_page(&temp, sg_page(sg), length, offset); |
681 | temp.length = length; | ||
682 | crypto_hash_update(desc, &temp, length); | 679 | crypto_hash_update(desc, &temp, length); |
683 | } | 680 | } |
684 | 681 | ||
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 1c5c4b68f20f..4652ad22516b 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -5256,8 +5256,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
5256 | 5256 | ||
5257 | STbuffer->sg[0].offset = 0; | 5257 | STbuffer->sg[0].offset = 0; |
5258 | if (page != NULL) { | 5258 | if (page != NULL) { |
5259 | sg_set_page(&STbuffer->sg[0], page); | 5259 | sg_set_page(&STbuffer->sg[0], page, b_size, 0); |
5260 | STbuffer->sg[0].length = b_size; | ||
5261 | STbuffer->b_data = page_address(page); | 5260 | STbuffer->b_data = page_address(page); |
5262 | break; | 5261 | break; |
5263 | } | 5262 | } |
@@ -5285,8 +5284,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
5285 | normalize_buffer(STbuffer); | 5284 | normalize_buffer(STbuffer); |
5286 | return 0; | 5285 | return 0; |
5287 | } | 5286 | } |
5288 | sg_set_page(&STbuffer->sg[segs], page); | 5287 | sg_set_page(&STbuffer->sg[segs], page, (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size, 0); |
5289 | STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size; | ||
5290 | got += STbuffer->sg[segs].length; | 5288 | got += STbuffer->sg[segs].length; |
5291 | STbuffer->buffer_size = got; | 5289 | STbuffer->buffer_size = got; |
5292 | STbuffer->sg_segs = ++segs; | 5290 | STbuffer->sg_segs = ++segs; |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index cc1971002846..f1871ea04045 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -1652,6 +1652,7 @@ sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize) | |||
1652 | schp->buffer = kzalloc(sg_bufflen, gfp_flags); | 1652 | schp->buffer = kzalloc(sg_bufflen, gfp_flags); |
1653 | if (!schp->buffer) | 1653 | if (!schp->buffer) |
1654 | return -ENOMEM; | 1654 | return -ENOMEM; |
1655 | sg_init_table(schp->buffer, tablesize); | ||
1655 | schp->sglist_len = sg_bufflen; | 1656 | schp->sglist_len = sg_bufflen; |
1656 | return tablesize; /* number of scat_gath elements allocated */ | 1657 | return tablesize; /* number of scat_gath elements allocated */ |
1657 | } | 1658 | } |
@@ -1717,16 +1718,12 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, | |||
1717 | goto out_unlock; */ | 1718 | goto out_unlock; */ |
1718 | } | 1719 | } |
1719 | 1720 | ||
1720 | sg_set_page(sgl, pages[0]); | 1721 | sg_set_page(sgl, pages[0], 0, uaddr & ~PAGE_MASK); |
1721 | sgl[0].offset = uaddr & ~PAGE_MASK; | ||
1722 | if (nr_pages > 1) { | 1722 | if (nr_pages > 1) { |
1723 | sgl[0].length = PAGE_SIZE - sgl[0].offset; | 1723 | sgl[0].length = PAGE_SIZE - sgl[0].offset; |
1724 | count -= sgl[0].length; | 1724 | count -= sgl[0].length; |
1725 | for (i=1; i < nr_pages ; i++) { | 1725 | for (i=1; i < nr_pages ; i++) |
1726 | sg_set_page(&sgl[i], pages[i]); | 1726 | sg_set_page(&sgl[i], pages[i], count < PAGE_SIZE ? count : PAGE_SIZE, 0); |
1727 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; | ||
1728 | count -= PAGE_SIZE; | ||
1729 | } | ||
1730 | } | 1727 | } |
1731 | else { | 1728 | else { |
1732 | sgl[0].length = count; | 1729 | sgl[0].length = count; |
@@ -1854,8 +1851,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
1854 | scatter_elem_sz_prev = ret_sz; | 1851 | scatter_elem_sz_prev = ret_sz; |
1855 | } | 1852 | } |
1856 | } | 1853 | } |
1857 | sg_set_page(sg, p); | 1854 | sg_set_page(sg, p, (ret_sz > num) ? num : ret_sz, 0); |
1858 | sg->length = (ret_sz > num) ? num : ret_sz; | ||
1859 | 1855 | ||
1860 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " | 1856 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " |
1861 | "ret_sz=%d\n", k, num, ret_sz)); | 1857 | "ret_sz=%d\n", k, num, ret_sz)); |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index ce69b9efc102..98dfd6ea209c 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -3797,13 +3797,11 @@ static void buf_to_sg(struct st_buffer *STbp, unsigned int length) | |||
3797 | sg = &(STbp->sg[0]); | 3797 | sg = &(STbp->sg[0]); |
3798 | frp = STbp->frp; | 3798 | frp = STbp->frp; |
3799 | for (i=count=0; count < length; i++) { | 3799 | for (i=count=0; count < length; i++) { |
3800 | sg_set_page(&sg[i], frp[i].page); | ||
3801 | if (length - count > frp[i].length) | 3800 | if (length - count > frp[i].length) |
3802 | sg[i].length = frp[i].length; | 3801 | sg_set_page(&sg[i], frp[i].page, frp[i].length, 0); |
3803 | else | 3802 | else |
3804 | sg[i].length = length - count; | 3803 | sg_set_page(&sg[i], frp[i].page, length - count, 0); |
3805 | count += sg[i].length; | 3804 | count += sg[i].length; |
3806 | sg[i].offset = 0; | ||
3807 | } | 3805 | } |
3808 | STbp->sg_segs = i; | 3806 | STbp->sg_segs = i; |
3809 | STbp->frp_sg_current = length; | 3807 | STbp->frp_sg_current = length; |
@@ -4446,15 +4444,13 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa | |||
4446 | } | 4444 | } |
4447 | 4445 | ||
4448 | /* Populate the scatter/gather list */ | 4446 | /* Populate the scatter/gather list */ |
4449 | sg_set_page(&sgl[0], pages[0]); | 4447 | sg_set_page(&sgl[0], pages[0], 0, uaddr & ~PAGE_MASK); |
4450 | sgl[0].offset = uaddr & ~PAGE_MASK; | ||
4451 | if (nr_pages > 1) { | 4448 | if (nr_pages > 1) { |
4452 | sgl[0].length = PAGE_SIZE - sgl[0].offset; | 4449 | sgl[0].length = PAGE_SIZE - sgl[0].offset; |
4453 | count -= sgl[0].length; | 4450 | count -= sgl[0].length; |
4454 | for (i=1; i < nr_pages ; i++) { | 4451 | for (i=1; i < nr_pages ; i++) { |
4455 | sg_set_page(&sgl[i], pages[i]);; | 4452 | sg_set_page(&sgl[i], pages[i], |
4456 | sgl[i].offset = 0; | 4453 | count < PAGE_SIZE ? count : PAGE_SIZE, 0);; |
4457 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; | ||
4458 | count -= PAGE_SIZE; | 4454 | count -= PAGE_SIZE; |
4459 | } | 4455 | } |
4460 | } | 4456 | } |
diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c index 80fb3f88af2e..1bc41907a038 100644 --- a/drivers/scsi/sun3x_esp.c +++ b/drivers/scsi/sun3x_esp.c | |||
@@ -332,8 +332,8 @@ static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp) | |||
332 | struct scatterlist *sg = sp->SCp.buffer; | 332 | struct scatterlist *sg = sp->SCp.buffer; |
333 | 333 | ||
334 | while (sz >= 0) { | 334 | while (sz >= 0) { |
335 | sg[sz].dma_address = dvma_map((unsigned long)page_address(sg[sz].page) + | 335 | sg[sz].dma_address = dvma_map((unsigned long)sg_virt(&sg[sz]), |
336 | sg[sz].offset, sg[sz].length); | 336 | sg[sz].length); |
337 | sz--; | 337 | sz--; |
338 | } | 338 | } |
339 | sp->SCp.ptr=(char *)((unsigned long)sp->SCp.buffer->dma_address); | 339 | sp->SCp.ptr=(char *)((unsigned long)sp->SCp.buffer->dma_address); |
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 103189095c80..3bb5d241dd40 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -1875,6 +1875,7 @@ uart_set_options(struct uart_port *port, struct console *co, | |||
1875 | int baud, int parity, int bits, int flow) | 1875 | int baud, int parity, int bits, int flow) |
1876 | { | 1876 | { |
1877 | struct ktermios termios; | 1877 | struct ktermios termios; |
1878 | static struct ktermios dummy; | ||
1878 | int i; | 1879 | int i; |
1879 | 1880 | ||
1880 | /* | 1881 | /* |
@@ -1920,7 +1921,7 @@ uart_set_options(struct uart_port *port, struct console *co, | |||
1920 | */ | 1921 | */ |
1921 | port->mctrl |= TIOCM_DTR; | 1922 | port->mctrl |= TIOCM_DTR; |
1922 | 1923 | ||
1923 | port->ops->set_termios(port, &termios, NULL); | 1924 | port->ops->set_termios(port, &termios, &dummy); |
1924 | co->cflag = termios.c_cflag; | 1925 | co->cflag = termios.c_cflag; |
1925 | 1926 | ||
1926 | return 0; | 1927 | return 0; |
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 5afcb2fa7cd3..d8b660061c13 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c | |||
@@ -345,7 +345,7 @@ static int serial_probe(struct pcmcia_device *link) | |||
345 | 345 | ||
346 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 346 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
347 | link->io.NumPorts1 = 8; | 347 | link->io.NumPorts1 = 8; |
348 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; | 348 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
349 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 349 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
350 | link->conf.Attributes = CONF_ENABLE_IRQ; | 350 | link->conf.Attributes = CONF_ENABLE_IRQ; |
351 | if (do_sound) { | 351 | if (do_sound) { |
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c index 6846a6c38b6d..7ad21925869a 100644 --- a/drivers/serial/serial_txx9.c +++ b/drivers/serial/serial_txx9.c | |||
@@ -657,7 +657,15 @@ static void | |||
657 | serial_txx9_pm(struct uart_port *port, unsigned int state, | 657 | serial_txx9_pm(struct uart_port *port, unsigned int state, |
658 | unsigned int oldstate) | 658 | unsigned int oldstate) |
659 | { | 659 | { |
660 | if (state == 0) | 660 | /* |
661 | * If oldstate was -1 this is called from | ||
662 | * uart_configure_port(). In this case do not initialize the | ||
663 | * port now, because the port was already initialized (for | ||
664 | * non-console port) or should not be initialized here (for | ||
665 | * console port). If we initialized the port here we lose | ||
666 | * serial console settings. | ||
667 | */ | ||
668 | if (state == 0 && oldstate != -1) | ||
661 | serial_txx9_initialize(port); | 669 | serial_txx9_initialize(port); |
662 | } | 670 | } |
663 | 671 | ||
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index c55459c592b8..b3518ca9f04e 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -184,14 +184,14 @@ static int spidev_message(struct spidev_data *spidev, | |||
184 | if (u_tmp->rx_buf) { | 184 | if (u_tmp->rx_buf) { |
185 | k_tmp->rx_buf = buf; | 185 | k_tmp->rx_buf = buf; |
186 | if (!access_ok(VERIFY_WRITE, (u8 __user *) | 186 | if (!access_ok(VERIFY_WRITE, (u8 __user *) |
187 | (ptrdiff_t) u_tmp->rx_buf, | 187 | (uintptr_t) u_tmp->rx_buf, |
188 | u_tmp->len)) | 188 | u_tmp->len)) |
189 | goto done; | 189 | goto done; |
190 | } | 190 | } |
191 | if (u_tmp->tx_buf) { | 191 | if (u_tmp->tx_buf) { |
192 | k_tmp->tx_buf = buf; | 192 | k_tmp->tx_buf = buf; |
193 | if (copy_from_user(buf, (const u8 __user *) | 193 | if (copy_from_user(buf, (const u8 __user *) |
194 | (ptrdiff_t) u_tmp->tx_buf, | 194 | (uintptr_t) u_tmp->tx_buf, |
195 | u_tmp->len)) | 195 | u_tmp->len)) |
196 | goto done; | 196 | goto done; |
197 | } | 197 | } |
@@ -224,7 +224,7 @@ static int spidev_message(struct spidev_data *spidev, | |||
224 | for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) { | 224 | for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) { |
225 | if (u_tmp->rx_buf) { | 225 | if (u_tmp->rx_buf) { |
226 | if (__copy_to_user((u8 __user *) | 226 | if (__copy_to_user((u8 __user *) |
227 | (ptrdiff_t) u_tmp->rx_buf, buf, | 227 | (uintptr_t) u_tmp->rx_buf, buf, |
228 | u_tmp->len)) { | 228 | u_tmp->len)) { |
229 | status = -EFAULT; | 229 | status = -EFAULT; |
230 | goto done; | 230 | goto done; |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 8bdaa157ffe7..316a746e0080 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -434,7 +434,7 @@ int usb_sg_init ( | |||
434 | if (dma) { | 434 | if (dma) { |
435 | io->urbs [i]->transfer_dma = sg_dma_address (sg + i); | 435 | io->urbs [i]->transfer_dma = sg_dma_address (sg + i); |
436 | len = sg_dma_len (sg + i); | 436 | len = sg_dma_len (sg + i); |
437 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_IOMMU) | 437 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) |
438 | io->urbs[i]->transfer_buffer = NULL; | 438 | io->urbs[i]->transfer_buffer = NULL; |
439 | #else | 439 | #else |
440 | io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); | 440 | io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); |
@@ -1641,7 +1641,13 @@ free_interfaces: | |||
1641 | intf->dev.bus_id, ret); | 1641 | intf->dev.bus_id, ret); |
1642 | continue; | 1642 | continue; |
1643 | } | 1643 | } |
1644 | usb_create_sysfs_intf_files (intf); | 1644 | |
1645 | /* The driver's probe method can call usb_set_interface(), | ||
1646 | * which would mean the interface's sysfs files are already | ||
1647 | * created. Just in case, we'll remove them first. | ||
1648 | */ | ||
1649 | usb_remove_sysfs_intf_files(intf); | ||
1650 | usb_create_sysfs_intf_files(intf); | ||
1645 | } | 1651 | } |
1646 | 1652 | ||
1647 | usb_autosuspend_device(dev); | 1653 | usb_autosuspend_device(dev); |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index c20c03aaf012..d05ead20081c 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -372,7 +372,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
372 | 372 | ||
373 | /* enforce simple/standard policy */ | 373 | /* enforce simple/standard policy */ |
374 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | | 374 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | |
375 | URB_NO_INTERRUPT | URB_DIR_MASK); | 375 | URB_NO_INTERRUPT | URB_DIR_MASK | URB_FREE_BUFFER); |
376 | switch (xfertype) { | 376 | switch (xfertype) { |
377 | case USB_ENDPOINT_XFER_BULK: | 377 | case USB_ENDPOINT_XFER_BULK: |
378 | if (is_out) | 378 | if (is_out) |
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index 1c8040602525..c72e9620bf8d 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -3289,7 +3289,7 @@ static int udc_pci_probe( | |||
3289 | dev->chiprev = pdev->revision; | 3289 | dev->chiprev = pdev->revision; |
3290 | 3290 | ||
3291 | pci_set_master(pdev); | 3291 | pci_set_master(pdev); |
3292 | pci_set_mwi(pdev); | 3292 | pci_try_set_mwi(pdev); |
3293 | 3293 | ||
3294 | /* init dma pools */ | 3294 | /* init dma pools */ |
3295 | if (use_dma) { | 3295 | if (use_dma) { |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index c978d622fa8a..177e78ed241b 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -156,7 +156,7 @@ config USB_OHCI_HCD_PCI | |||
156 | 156 | ||
157 | config USB_OHCI_HCD_SSB | 157 | config USB_OHCI_HCD_SSB |
158 | bool "OHCI support for Broadcom SSB OHCI core" | 158 | bool "OHCI support for Broadcom SSB OHCI core" |
159 | depends on USB_OHCI_HCD && SSB && EXPERIMENTAL | 159 | depends on USB_OHCI_HCD && (SSB = y || SSB = CONFIG_USB_OHCI_HCD) && EXPERIMENTAL |
160 | default n | 160 | default n |
161 | ---help--- | 161 | ---help--- |
162 | Support for the Sonics Silicon Backplane (SSB) attached | 162 | Support for the Sonics Silicon Backplane (SSB) attached |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 240c7f507541..704f33fdd2f1 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -80,7 +80,10 @@ static const char hcd_name [] = "ohci_hcd"; | |||
80 | static void ohci_dump (struct ohci_hcd *ohci, int verbose); | 80 | static void ohci_dump (struct ohci_hcd *ohci, int verbose); |
81 | static int ohci_init (struct ohci_hcd *ohci); | 81 | static int ohci_init (struct ohci_hcd *ohci); |
82 | static void ohci_stop (struct usb_hcd *hcd); | 82 | static void ohci_stop (struct usb_hcd *hcd); |
83 | |||
84 | #if defined(CONFIG_PM) || defined(CONFIG_PCI) | ||
83 | static int ohci_restart (struct ohci_hcd *ohci); | 85 | static int ohci_restart (struct ohci_hcd *ohci); |
86 | #endif | ||
84 | 87 | ||
85 | #include "ohci-hub.c" | 88 | #include "ohci-hub.c" |
86 | #include "ohci-dbg.c" | 89 | #include "ohci-dbg.c" |
@@ -396,7 +399,7 @@ static int check_ed(struct ohci_hcd *ohci, struct ed *ed) | |||
396 | */ | 399 | */ |
397 | static void unlink_watchdog_func(unsigned long _ohci) | 400 | static void unlink_watchdog_func(unsigned long _ohci) |
398 | { | 401 | { |
399 | long flags; | 402 | unsigned long flags; |
400 | unsigned max; | 403 | unsigned max; |
401 | unsigned seen_count = 0; | 404 | unsigned seen_count = 0; |
402 | unsigned i; | 405 | unsigned i; |
@@ -893,6 +896,8 @@ static void ohci_stop (struct usb_hcd *hcd) | |||
893 | 896 | ||
894 | /*-------------------------------------------------------------------------*/ | 897 | /*-------------------------------------------------------------------------*/ |
895 | 898 | ||
899 | #if defined(CONFIG_PM) || defined(CONFIG_PCI) | ||
900 | |||
896 | /* must not be called from interrupt context */ | 901 | /* must not be called from interrupt context */ |
897 | static int ohci_restart (struct ohci_hcd *ohci) | 902 | static int ohci_restart (struct ohci_hcd *ohci) |
898 | { | 903 | { |
@@ -954,6 +959,8 @@ static int ohci_restart (struct ohci_hcd *ohci) | |||
954 | return 0; | 959 | return 0; |
955 | } | 960 | } |
956 | 961 | ||
962 | #endif | ||
963 | |||
957 | /*-------------------------------------------------------------------------*/ | 964 | /*-------------------------------------------------------------------------*/ |
958 | 965 | ||
959 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC | 966 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index e5d60d5b105a..60379b17bbc1 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -1271,7 +1271,8 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, | |||
1271 | } else if (qh->period != urb->interval) { | 1271 | } else if (qh->period != urb->interval) { |
1272 | return -EINVAL; /* Can't change the period */ | 1272 | return -EINVAL; /* Can't change the period */ |
1273 | 1273 | ||
1274 | } else { /* Pick up where the last URB leaves off */ | 1274 | } else { |
1275 | /* Find the next unused frame */ | ||
1275 | if (list_empty(&qh->queue)) { | 1276 | if (list_empty(&qh->queue)) { |
1276 | frame = qh->iso_frame; | 1277 | frame = qh->iso_frame; |
1277 | } else { | 1278 | } else { |
@@ -1283,10 +1284,18 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, | |||
1283 | lurb->number_of_packets * | 1284 | lurb->number_of_packets * |
1284 | lurb->interval; | 1285 | lurb->interval; |
1285 | } | 1286 | } |
1286 | if (urb->transfer_flags & URB_ISO_ASAP) | 1287 | if (urb->transfer_flags & URB_ISO_ASAP) { |
1287 | urb->start_frame = frame; | 1288 | /* Skip some frames if necessary to insure |
1288 | else if (urb->start_frame != frame) | 1289 | * the start frame is in the future. |
1289 | return -EINVAL; | 1290 | */ |
1291 | uhci_get_current_frame_number(uhci); | ||
1292 | if (uhci_frame_before_eq(frame, uhci->frame_number)) { | ||
1293 | frame = uhci->frame_number + 1; | ||
1294 | frame += ((qh->phase - frame) & | ||
1295 | (qh->period - 1)); | ||
1296 | } | ||
1297 | } /* Otherwise pick up where the last URB leaves off */ | ||
1298 | urb->start_frame = frame; | ||
1290 | } | 1299 | } |
1291 | 1300 | ||
1292 | /* Make sure we won't have to go too far into the future */ | 1301 | /* Make sure we won't have to go too far into the future */ |
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 2677fea147d9..1cd9e7eba93b 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c | |||
@@ -399,7 +399,6 @@ static void cytherm_disconnect(struct usb_interface *interface) | |||
399 | struct usb_cytherm *dev; | 399 | struct usb_cytherm *dev; |
400 | 400 | ||
401 | dev = usb_get_intfdata (interface); | 401 | dev = usb_get_intfdata (interface); |
402 | usb_set_intfdata (interface, NULL); | ||
403 | 402 | ||
404 | device_remove_file(&interface->dev, &dev_attr_brightness); | 403 | device_remove_file(&interface->dev, &dev_attr_brightness); |
405 | device_remove_file(&interface->dev, &dev_attr_temp); | 404 | device_remove_file(&interface->dev, &dev_attr_temp); |
@@ -407,6 +406,9 @@ static void cytherm_disconnect(struct usb_interface *interface) | |||
407 | device_remove_file(&interface->dev, &dev_attr_port0); | 406 | device_remove_file(&interface->dev, &dev_attr_port0); |
408 | device_remove_file(&interface->dev, &dev_attr_port1); | 407 | device_remove_file(&interface->dev, &dev_attr_port1); |
409 | 408 | ||
409 | /* first remove the files, then NULL the pointer */ | ||
410 | usb_set_intfdata (interface, NULL); | ||
411 | |||
410 | usb_put_dev(dev->udev); | 412 | usb_put_dev(dev->udev); |
411 | 413 | ||
412 | kfree(dev); | 414 | kfree(dev); |
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index cd137577bb2d..4a09b87bdd28 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
@@ -114,6 +114,10 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
114 | 114 | ||
115 | /* De-assert reset (let the CPU run) */ | 115 | /* De-assert reset (let the CPU run) */ |
116 | err = emi26_set_reset(dev,0); | 116 | err = emi26_set_reset(dev,0); |
117 | if (err < 0) { | ||
118 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); | ||
119 | goto wraperr; | ||
120 | } | ||
117 | msleep(250); /* let device settle */ | 121 | msleep(250); /* let device settle */ |
118 | 122 | ||
119 | /* 2. We upload the FPGA firmware into the EMI | 123 | /* 2. We upload the FPGA firmware into the EMI |
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 4758cc5ccebc..d1362415922c 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c | |||
@@ -123,6 +123,10 @@ static int emi62_load_firmware (struct usb_device *dev) | |||
123 | 123 | ||
124 | /* De-assert reset (let the CPU run) */ | 124 | /* De-assert reset (let the CPU run) */ |
125 | err = emi62_set_reset(dev,0); | 125 | err = emi62_set_reset(dev,0); |
126 | if (err < 0) { | ||
127 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); | ||
128 | goto wraperr; | ||
129 | } | ||
126 | msleep(250); /* let device settle */ | 130 | msleep(250); /* let device settle */ |
127 | 131 | ||
128 | /* 2. We upload the FPGA firmware into the EMI | 132 | /* 2. We upload the FPGA firmware into the EMI |
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index d3d8cd6ff103..148b7fe639b2 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -147,7 +147,7 @@ struct u132_target { | |||
147 | /* Structure to hold all of our device specific stuff*/ | 147 | /* Structure to hold all of our device specific stuff*/ |
148 | struct usb_ftdi { | 148 | struct usb_ftdi { |
149 | struct list_head ftdi_list; | 149 | struct list_head ftdi_list; |
150 | struct semaphore u132_lock; | 150 | struct mutex u132_lock; |
151 | int command_next; | 151 | int command_next; |
152 | int command_head; | 152 | int command_head; |
153 | struct u132_command command[COMMAND_SIZE]; | 153 | struct u132_command command[COMMAND_SIZE]; |
@@ -330,39 +330,39 @@ static int ftdi_elan_hcd_init(struct usb_ftdi *ftdi) | |||
330 | 330 | ||
331 | static void ftdi_elan_abandon_completions(struct usb_ftdi *ftdi) | 331 | static void ftdi_elan_abandon_completions(struct usb_ftdi *ftdi) |
332 | { | 332 | { |
333 | down(&ftdi->u132_lock); | 333 | mutex_lock(&ftdi->u132_lock); |
334 | while (ftdi->respond_next > ftdi->respond_head) { | 334 | while (ftdi->respond_next > ftdi->respond_head) { |
335 | struct u132_respond *respond = &ftdi->respond[RESPOND_MASK & | 335 | struct u132_respond *respond = &ftdi->respond[RESPOND_MASK & |
336 | ftdi->respond_head++]; | 336 | ftdi->respond_head++]; |
337 | *respond->result = -ESHUTDOWN; | 337 | *respond->result = -ESHUTDOWN; |
338 | *respond->value = 0; | 338 | *respond->value = 0; |
339 | complete(&respond->wait_completion); | 339 | complete(&respond->wait_completion); |
340 | } up(&ftdi->u132_lock); | 340 | } mutex_unlock(&ftdi->u132_lock); |
341 | } | 341 | } |
342 | 342 | ||
343 | static void ftdi_elan_abandon_targets(struct usb_ftdi *ftdi) | 343 | static void ftdi_elan_abandon_targets(struct usb_ftdi *ftdi) |
344 | { | 344 | { |
345 | int ed_number = 4; | 345 | int ed_number = 4; |
346 | down(&ftdi->u132_lock); | 346 | mutex_lock(&ftdi->u132_lock); |
347 | while (ed_number-- > 0) { | 347 | while (ed_number-- > 0) { |
348 | struct u132_target *target = &ftdi->target[ed_number]; | 348 | struct u132_target *target = &ftdi->target[ed_number]; |
349 | if (target->active == 1) { | 349 | if (target->active == 1) { |
350 | target->condition_code = TD_DEVNOTRESP; | 350 | target->condition_code = TD_DEVNOTRESP; |
351 | up(&ftdi->u132_lock); | 351 | mutex_unlock(&ftdi->u132_lock); |
352 | ftdi_elan_do_callback(ftdi, target, NULL, 0); | 352 | ftdi_elan_do_callback(ftdi, target, NULL, 0); |
353 | down(&ftdi->u132_lock); | 353 | mutex_lock(&ftdi->u132_lock); |
354 | } | 354 | } |
355 | } | 355 | } |
356 | ftdi->recieved = 0; | 356 | ftdi->recieved = 0; |
357 | ftdi->expected = 4; | 357 | ftdi->expected = 4; |
358 | ftdi->ed_found = 0; | 358 | ftdi->ed_found = 0; |
359 | up(&ftdi->u132_lock); | 359 | mutex_unlock(&ftdi->u132_lock); |
360 | } | 360 | } |
361 | 361 | ||
362 | static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) | 362 | static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) |
363 | { | 363 | { |
364 | int ed_number = 4; | 364 | int ed_number = 4; |
365 | down(&ftdi->u132_lock); | 365 | mutex_lock(&ftdi->u132_lock); |
366 | while (ed_number-- > 0) { | 366 | while (ed_number-- > 0) { |
367 | struct u132_target *target = &ftdi->target[ed_number]; | 367 | struct u132_target *target = &ftdi->target[ed_number]; |
368 | target->abandoning = 1; | 368 | target->abandoning = 1; |
@@ -382,9 +382,9 @@ static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) | |||
382 | ftdi->command_next += 1; | 382 | ftdi->command_next += 1; |
383 | ftdi_elan_kick_command_queue(ftdi); | 383 | ftdi_elan_kick_command_queue(ftdi); |
384 | } else { | 384 | } else { |
385 | up(&ftdi->u132_lock); | 385 | mutex_unlock(&ftdi->u132_lock); |
386 | msleep(100); | 386 | msleep(100); |
387 | down(&ftdi->u132_lock); | 387 | mutex_lock(&ftdi->u132_lock); |
388 | goto wait_1; | 388 | goto wait_1; |
389 | } | 389 | } |
390 | } | 390 | } |
@@ -404,9 +404,9 @@ static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) | |||
404 | ftdi->command_next += 1; | 404 | ftdi->command_next += 1; |
405 | ftdi_elan_kick_command_queue(ftdi); | 405 | ftdi_elan_kick_command_queue(ftdi); |
406 | } else { | 406 | } else { |
407 | up(&ftdi->u132_lock); | 407 | mutex_unlock(&ftdi->u132_lock); |
408 | msleep(100); | 408 | msleep(100); |
409 | down(&ftdi->u132_lock); | 409 | mutex_lock(&ftdi->u132_lock); |
410 | goto wait_2; | 410 | goto wait_2; |
411 | } | 411 | } |
412 | } | 412 | } |
@@ -414,13 +414,13 @@ static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) | |||
414 | ftdi->recieved = 0; | 414 | ftdi->recieved = 0; |
415 | ftdi->expected = 4; | 415 | ftdi->expected = 4; |
416 | ftdi->ed_found = 0; | 416 | ftdi->ed_found = 0; |
417 | up(&ftdi->u132_lock); | 417 | mutex_unlock(&ftdi->u132_lock); |
418 | } | 418 | } |
419 | 419 | ||
420 | static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) | 420 | static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) |
421 | { | 421 | { |
422 | int ed_number = 4; | 422 | int ed_number = 4; |
423 | down(&ftdi->u132_lock); | 423 | mutex_lock(&ftdi->u132_lock); |
424 | while (ed_number-- > 0) { | 424 | while (ed_number-- > 0) { |
425 | struct u132_target *target = &ftdi->target[ed_number]; | 425 | struct u132_target *target = &ftdi->target[ed_number]; |
426 | target->abandoning = 1; | 426 | target->abandoning = 1; |
@@ -440,9 +440,9 @@ static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) | |||
440 | ftdi->command_next += 1; | 440 | ftdi->command_next += 1; |
441 | ftdi_elan_kick_command_queue(ftdi); | 441 | ftdi_elan_kick_command_queue(ftdi); |
442 | } else { | 442 | } else { |
443 | up(&ftdi->u132_lock); | 443 | mutex_unlock(&ftdi->u132_lock); |
444 | msleep(100); | 444 | msleep(100); |
445 | down(&ftdi->u132_lock); | 445 | mutex_lock(&ftdi->u132_lock); |
446 | goto wait; | 446 | goto wait; |
447 | } | 447 | } |
448 | } | 448 | } |
@@ -450,7 +450,7 @@ static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) | |||
450 | ftdi->recieved = 0; | 450 | ftdi->recieved = 0; |
451 | ftdi->expected = 4; | 451 | ftdi->expected = 4; |
452 | ftdi->ed_found = 0; | 452 | ftdi->ed_found = 0; |
453 | up(&ftdi->u132_lock); | 453 | mutex_unlock(&ftdi->u132_lock); |
454 | } | 454 | } |
455 | 455 | ||
456 | static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi) | 456 | static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi) |
@@ -886,14 +886,14 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, | |||
886 | char *b) | 886 | char *b) |
887 | { | 887 | { |
888 | int payload = (ed_length >> 0) & 0x07FF; | 888 | int payload = (ed_length >> 0) & 0x07FF; |
889 | down(&ftdi->u132_lock); | 889 | mutex_lock(&ftdi->u132_lock); |
890 | target->actual = 0; | 890 | target->actual = 0; |
891 | target->non_null = (ed_length >> 15) & 0x0001; | 891 | target->non_null = (ed_length >> 15) & 0x0001; |
892 | target->repeat_number = (ed_length >> 11) & 0x000F; | 892 | target->repeat_number = (ed_length >> 11) & 0x000F; |
893 | if (ed_type == 0x02) { | 893 | if (ed_type == 0x02) { |
894 | if (payload == 0 || target->abandoning > 0) { | 894 | if (payload == 0 || target->abandoning > 0) { |
895 | target->abandoning = 0; | 895 | target->abandoning = 0; |
896 | up(&ftdi->u132_lock); | 896 | mutex_unlock(&ftdi->u132_lock); |
897 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, | 897 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, |
898 | payload); | 898 | payload); |
899 | ftdi->recieved = 0; | 899 | ftdi->recieved = 0; |
@@ -903,13 +903,13 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, | |||
903 | } else { | 903 | } else { |
904 | ftdi->expected = 4 + payload; | 904 | ftdi->expected = 4 + payload; |
905 | ftdi->ed_found = 1; | 905 | ftdi->ed_found = 1; |
906 | up(&ftdi->u132_lock); | 906 | mutex_unlock(&ftdi->u132_lock); |
907 | return b; | 907 | return b; |
908 | } | 908 | } |
909 | } else if (ed_type == 0x03) { | 909 | } else if (ed_type == 0x03) { |
910 | if (payload == 0 || target->abandoning > 0) { | 910 | if (payload == 0 || target->abandoning > 0) { |
911 | target->abandoning = 0; | 911 | target->abandoning = 0; |
912 | up(&ftdi->u132_lock); | 912 | mutex_unlock(&ftdi->u132_lock); |
913 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, | 913 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, |
914 | payload); | 914 | payload); |
915 | ftdi->recieved = 0; | 915 | ftdi->recieved = 0; |
@@ -919,12 +919,12 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, | |||
919 | } else { | 919 | } else { |
920 | ftdi->expected = 4 + payload; | 920 | ftdi->expected = 4 + payload; |
921 | ftdi->ed_found = 1; | 921 | ftdi->ed_found = 1; |
922 | up(&ftdi->u132_lock); | 922 | mutex_unlock(&ftdi->u132_lock); |
923 | return b; | 923 | return b; |
924 | } | 924 | } |
925 | } else if (ed_type == 0x01) { | 925 | } else if (ed_type == 0x01) { |
926 | target->abandoning = 0; | 926 | target->abandoning = 0; |
927 | up(&ftdi->u132_lock); | 927 | mutex_unlock(&ftdi->u132_lock); |
928 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, | 928 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, |
929 | payload); | 929 | payload); |
930 | ftdi->recieved = 0; | 930 | ftdi->recieved = 0; |
@@ -933,7 +933,7 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, | |||
933 | return ftdi->response; | 933 | return ftdi->response; |
934 | } else { | 934 | } else { |
935 | target->abandoning = 0; | 935 | target->abandoning = 0; |
936 | up(&ftdi->u132_lock); | 936 | mutex_unlock(&ftdi->u132_lock); |
937 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, | 937 | ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, |
938 | payload); | 938 | payload); |
939 | ftdi->recieved = 0; | 939 | ftdi->recieved = 0; |
@@ -947,12 +947,12 @@ static char *have_ed_get_response(struct usb_ftdi *ftdi, | |||
947 | struct u132_target *target, u16 ed_length, int ed_number, int ed_type, | 947 | struct u132_target *target, u16 ed_length, int ed_number, int ed_type, |
948 | char *b) | 948 | char *b) |
949 | { | 949 | { |
950 | down(&ftdi->u132_lock); | 950 | mutex_lock(&ftdi->u132_lock); |
951 | target->condition_code = TD_DEVNOTRESP; | 951 | target->condition_code = TD_DEVNOTRESP; |
952 | target->actual = (ed_length >> 0) & 0x01FF; | 952 | target->actual = (ed_length >> 0) & 0x01FF; |
953 | target->non_null = (ed_length >> 15) & 0x0001; | 953 | target->non_null = (ed_length >> 15) & 0x0001; |
954 | target->repeat_number = (ed_length >> 11) & 0x000F; | 954 | target->repeat_number = (ed_length >> 11) & 0x000F; |
955 | up(&ftdi->u132_lock); | 955 | mutex_unlock(&ftdi->u132_lock); |
956 | if (target->active) | 956 | if (target->active) |
957 | ftdi_elan_do_callback(ftdi, target, NULL, 0); | 957 | ftdi_elan_do_callback(ftdi, target, NULL, 0); |
958 | target->abandoning = 0; | 958 | target->abandoning = 0; |
@@ -1278,7 +1278,7 @@ static int ftdi_elan_write_reg(struct usb_ftdi *ftdi, u32 data) | |||
1278 | return -ENODEV; | 1278 | return -ENODEV; |
1279 | } else { | 1279 | } else { |
1280 | int command_size; | 1280 | int command_size; |
1281 | down(&ftdi->u132_lock); | 1281 | mutex_lock(&ftdi->u132_lock); |
1282 | command_size = ftdi->command_next - ftdi->command_head; | 1282 | command_size = ftdi->command_next - ftdi->command_head; |
1283 | if (command_size < COMMAND_SIZE) { | 1283 | if (command_size < COMMAND_SIZE) { |
1284 | struct u132_command *command = &ftdi->command[ | 1284 | struct u132_command *command = &ftdi->command[ |
@@ -1292,10 +1292,10 @@ static int ftdi_elan_write_reg(struct usb_ftdi *ftdi, u32 data) | |||
1292 | command->buffer = &command->value; | 1292 | command->buffer = &command->value; |
1293 | ftdi->command_next += 1; | 1293 | ftdi->command_next += 1; |
1294 | ftdi_elan_kick_command_queue(ftdi); | 1294 | ftdi_elan_kick_command_queue(ftdi); |
1295 | up(&ftdi->u132_lock); | 1295 | mutex_unlock(&ftdi->u132_lock); |
1296 | return 0; | 1296 | return 0; |
1297 | } else { | 1297 | } else { |
1298 | up(&ftdi->u132_lock); | 1298 | mutex_unlock(&ftdi->u132_lock); |
1299 | msleep(100); | 1299 | msleep(100); |
1300 | goto wait; | 1300 | goto wait; |
1301 | } | 1301 | } |
@@ -1310,7 +1310,7 @@ static int ftdi_elan_write_config(struct usb_ftdi *ftdi, int config_offset, | |||
1310 | return -ENODEV; | 1310 | return -ENODEV; |
1311 | } else { | 1311 | } else { |
1312 | int command_size; | 1312 | int command_size; |
1313 | down(&ftdi->u132_lock); | 1313 | mutex_lock(&ftdi->u132_lock); |
1314 | command_size = ftdi->command_next - ftdi->command_head; | 1314 | command_size = ftdi->command_next - ftdi->command_head; |
1315 | if (command_size < COMMAND_SIZE) { | 1315 | if (command_size < COMMAND_SIZE) { |
1316 | struct u132_command *command = &ftdi->command[ | 1316 | struct u132_command *command = &ftdi->command[ |
@@ -1324,10 +1324,10 @@ static int ftdi_elan_write_config(struct usb_ftdi *ftdi, int config_offset, | |||
1324 | command->buffer = &command->value; | 1324 | command->buffer = &command->value; |
1325 | ftdi->command_next += 1; | 1325 | ftdi->command_next += 1; |
1326 | ftdi_elan_kick_command_queue(ftdi); | 1326 | ftdi_elan_kick_command_queue(ftdi); |
1327 | up(&ftdi->u132_lock); | 1327 | mutex_unlock(&ftdi->u132_lock); |
1328 | return 0; | 1328 | return 0; |
1329 | } else { | 1329 | } else { |
1330 | up(&ftdi->u132_lock); | 1330 | mutex_unlock(&ftdi->u132_lock); |
1331 | msleep(100); | 1331 | msleep(100); |
1332 | goto wait; | 1332 | goto wait; |
1333 | } | 1333 | } |
@@ -1342,7 +1342,7 @@ static int ftdi_elan_write_pcimem(struct usb_ftdi *ftdi, int mem_offset, | |||
1342 | return -ENODEV; | 1342 | return -ENODEV; |
1343 | } else { | 1343 | } else { |
1344 | int command_size; | 1344 | int command_size; |
1345 | down(&ftdi->u132_lock); | 1345 | mutex_lock(&ftdi->u132_lock); |
1346 | command_size = ftdi->command_next - ftdi->command_head; | 1346 | command_size = ftdi->command_next - ftdi->command_head; |
1347 | if (command_size < COMMAND_SIZE) { | 1347 | if (command_size < COMMAND_SIZE) { |
1348 | struct u132_command *command = &ftdi->command[ | 1348 | struct u132_command *command = &ftdi->command[ |
@@ -1356,10 +1356,10 @@ static int ftdi_elan_write_pcimem(struct usb_ftdi *ftdi, int mem_offset, | |||
1356 | command->buffer = &command->value; | 1356 | command->buffer = &command->value; |
1357 | ftdi->command_next += 1; | 1357 | ftdi->command_next += 1; |
1358 | ftdi_elan_kick_command_queue(ftdi); | 1358 | ftdi_elan_kick_command_queue(ftdi); |
1359 | up(&ftdi->u132_lock); | 1359 | mutex_unlock(&ftdi->u132_lock); |
1360 | return 0; | 1360 | return 0; |
1361 | } else { | 1361 | } else { |
1362 | up(&ftdi->u132_lock); | 1362 | mutex_unlock(&ftdi->u132_lock); |
1363 | msleep(100); | 1363 | msleep(100); |
1364 | goto wait; | 1364 | goto wait; |
1365 | } | 1365 | } |
@@ -1382,7 +1382,7 @@ static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data) | |||
1382 | } else { | 1382 | } else { |
1383 | int command_size; | 1383 | int command_size; |
1384 | int respond_size; | 1384 | int respond_size; |
1385 | down(&ftdi->u132_lock); | 1385 | mutex_lock(&ftdi->u132_lock); |
1386 | command_size = ftdi->command_next - ftdi->command_head; | 1386 | command_size = ftdi->command_next - ftdi->command_head; |
1387 | respond_size = ftdi->respond_next - ftdi->respond_head; | 1387 | respond_size = ftdi->respond_next - ftdi->respond_head; |
1388 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) | 1388 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) |
@@ -1405,11 +1405,11 @@ static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data) | |||
1405 | ftdi->command_next += 1; | 1405 | ftdi->command_next += 1; |
1406 | ftdi->respond_next += 1; | 1406 | ftdi->respond_next += 1; |
1407 | ftdi_elan_kick_command_queue(ftdi); | 1407 | ftdi_elan_kick_command_queue(ftdi); |
1408 | up(&ftdi->u132_lock); | 1408 | mutex_unlock(&ftdi->u132_lock); |
1409 | wait_for_completion(&respond->wait_completion); | 1409 | wait_for_completion(&respond->wait_completion); |
1410 | return result; | 1410 | return result; |
1411 | } else { | 1411 | } else { |
1412 | up(&ftdi->u132_lock); | 1412 | mutex_unlock(&ftdi->u132_lock); |
1413 | msleep(100); | 1413 | msleep(100); |
1414 | goto wait; | 1414 | goto wait; |
1415 | } | 1415 | } |
@@ -1425,7 +1425,7 @@ static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, | |||
1425 | } else { | 1425 | } else { |
1426 | int command_size; | 1426 | int command_size; |
1427 | int respond_size; | 1427 | int respond_size; |
1428 | down(&ftdi->u132_lock); | 1428 | mutex_lock(&ftdi->u132_lock); |
1429 | command_size = ftdi->command_next - ftdi->command_head; | 1429 | command_size = ftdi->command_next - ftdi->command_head; |
1430 | respond_size = ftdi->respond_next - ftdi->respond_head; | 1430 | respond_size = ftdi->respond_next - ftdi->respond_head; |
1431 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) | 1431 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) |
@@ -1449,11 +1449,11 @@ static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, | |||
1449 | ftdi->command_next += 1; | 1449 | ftdi->command_next += 1; |
1450 | ftdi->respond_next += 1; | 1450 | ftdi->respond_next += 1; |
1451 | ftdi_elan_kick_command_queue(ftdi); | 1451 | ftdi_elan_kick_command_queue(ftdi); |
1452 | up(&ftdi->u132_lock); | 1452 | mutex_unlock(&ftdi->u132_lock); |
1453 | wait_for_completion(&respond->wait_completion); | 1453 | wait_for_completion(&respond->wait_completion); |
1454 | return result; | 1454 | return result; |
1455 | } else { | 1455 | } else { |
1456 | up(&ftdi->u132_lock); | 1456 | mutex_unlock(&ftdi->u132_lock); |
1457 | msleep(100); | 1457 | msleep(100); |
1458 | goto wait; | 1458 | goto wait; |
1459 | } | 1459 | } |
@@ -1469,7 +1469,7 @@ static int ftdi_elan_read_pcimem(struct usb_ftdi *ftdi, int mem_offset, | |||
1469 | } else { | 1469 | } else { |
1470 | int command_size; | 1470 | int command_size; |
1471 | int respond_size; | 1471 | int respond_size; |
1472 | down(&ftdi->u132_lock); | 1472 | mutex_lock(&ftdi->u132_lock); |
1473 | command_size = ftdi->command_next - ftdi->command_head; | 1473 | command_size = ftdi->command_next - ftdi->command_head; |
1474 | respond_size = ftdi->respond_next - ftdi->respond_head; | 1474 | respond_size = ftdi->respond_next - ftdi->respond_head; |
1475 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) | 1475 | if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) |
@@ -1493,11 +1493,11 @@ static int ftdi_elan_read_pcimem(struct usb_ftdi *ftdi, int mem_offset, | |||
1493 | ftdi->command_next += 1; | 1493 | ftdi->command_next += 1; |
1494 | ftdi->respond_next += 1; | 1494 | ftdi->respond_next += 1; |
1495 | ftdi_elan_kick_command_queue(ftdi); | 1495 | ftdi_elan_kick_command_queue(ftdi); |
1496 | up(&ftdi->u132_lock); | 1496 | mutex_unlock(&ftdi->u132_lock); |
1497 | wait_for_completion(&respond->wait_completion); | 1497 | wait_for_completion(&respond->wait_completion); |
1498 | return result; | 1498 | return result; |
1499 | } else { | 1499 | } else { |
1500 | up(&ftdi->u132_lock); | 1500 | mutex_unlock(&ftdi->u132_lock); |
1501 | msleep(100); | 1501 | msleep(100); |
1502 | goto wait; | 1502 | goto wait; |
1503 | } | 1503 | } |
@@ -1529,7 +1529,7 @@ static int ftdi_elan_edset_setup(struct usb_ftdi *ftdi, u8 ed_number, | |||
1529 | return -ENODEV; | 1529 | return -ENODEV; |
1530 | } else { | 1530 | } else { |
1531 | int command_size; | 1531 | int command_size; |
1532 | down(&ftdi->u132_lock); | 1532 | mutex_lock(&ftdi->u132_lock); |
1533 | command_size = ftdi->command_next - ftdi->command_head; | 1533 | command_size = ftdi->command_next - ftdi->command_head; |
1534 | if (command_size < COMMAND_SIZE) { | 1534 | if (command_size < COMMAND_SIZE) { |
1535 | struct u132_target *target = &ftdi->target[ed]; | 1535 | struct u132_target *target = &ftdi->target[ed]; |
@@ -1550,10 +1550,10 @@ static int ftdi_elan_edset_setup(struct usb_ftdi *ftdi, u8 ed_number, | |||
1550 | target->active = 1; | 1550 | target->active = 1; |
1551 | ftdi->command_next += 1; | 1551 | ftdi->command_next += 1; |
1552 | ftdi_elan_kick_command_queue(ftdi); | 1552 | ftdi_elan_kick_command_queue(ftdi); |
1553 | up(&ftdi->u132_lock); | 1553 | mutex_unlock(&ftdi->u132_lock); |
1554 | return 0; | 1554 | return 0; |
1555 | } else { | 1555 | } else { |
1556 | up(&ftdi->u132_lock); | 1556 | mutex_unlock(&ftdi->u132_lock); |
1557 | msleep(100); | 1557 | msleep(100); |
1558 | goto wait; | 1558 | goto wait; |
1559 | } | 1559 | } |
@@ -1586,7 +1586,7 @@ static int ftdi_elan_edset_input(struct usb_ftdi *ftdi, u8 ed_number, | |||
1586 | return -ENODEV; | 1586 | return -ENODEV; |
1587 | } else { | 1587 | } else { |
1588 | int command_size; | 1588 | int command_size; |
1589 | down(&ftdi->u132_lock); | 1589 | mutex_lock(&ftdi->u132_lock); |
1590 | command_size = ftdi->command_next - ftdi->command_head; | 1590 | command_size = ftdi->command_next - ftdi->command_head; |
1591 | if (command_size < COMMAND_SIZE) { | 1591 | if (command_size < COMMAND_SIZE) { |
1592 | struct u132_target *target = &ftdi->target[ed]; | 1592 | struct u132_target *target = &ftdi->target[ed]; |
@@ -1615,10 +1615,10 @@ static int ftdi_elan_edset_input(struct usb_ftdi *ftdi, u8 ed_number, | |||
1615 | target->active = 1; | 1615 | target->active = 1; |
1616 | ftdi->command_next += 1; | 1616 | ftdi->command_next += 1; |
1617 | ftdi_elan_kick_command_queue(ftdi); | 1617 | ftdi_elan_kick_command_queue(ftdi); |
1618 | up(&ftdi->u132_lock); | 1618 | mutex_unlock(&ftdi->u132_lock); |
1619 | return 0; | 1619 | return 0; |
1620 | } else { | 1620 | } else { |
1621 | up(&ftdi->u132_lock); | 1621 | mutex_unlock(&ftdi->u132_lock); |
1622 | msleep(100); | 1622 | msleep(100); |
1623 | goto wait; | 1623 | goto wait; |
1624 | } | 1624 | } |
@@ -1651,7 +1651,7 @@ static int ftdi_elan_edset_empty(struct usb_ftdi *ftdi, u8 ed_number, | |||
1651 | return -ENODEV; | 1651 | return -ENODEV; |
1652 | } else { | 1652 | } else { |
1653 | int command_size; | 1653 | int command_size; |
1654 | down(&ftdi->u132_lock); | 1654 | mutex_lock(&ftdi->u132_lock); |
1655 | command_size = ftdi->command_next - ftdi->command_head; | 1655 | command_size = ftdi->command_next - ftdi->command_head; |
1656 | if (command_size < COMMAND_SIZE) { | 1656 | if (command_size < COMMAND_SIZE) { |
1657 | struct u132_target *target = &ftdi->target[ed]; | 1657 | struct u132_target *target = &ftdi->target[ed]; |
@@ -1672,10 +1672,10 @@ static int ftdi_elan_edset_empty(struct usb_ftdi *ftdi, u8 ed_number, | |||
1672 | target->active = 1; | 1672 | target->active = 1; |
1673 | ftdi->command_next += 1; | 1673 | ftdi->command_next += 1; |
1674 | ftdi_elan_kick_command_queue(ftdi); | 1674 | ftdi_elan_kick_command_queue(ftdi); |
1675 | up(&ftdi->u132_lock); | 1675 | mutex_unlock(&ftdi->u132_lock); |
1676 | return 0; | 1676 | return 0; |
1677 | } else { | 1677 | } else { |
1678 | up(&ftdi->u132_lock); | 1678 | mutex_unlock(&ftdi->u132_lock); |
1679 | msleep(100); | 1679 | msleep(100); |
1680 | goto wait; | 1680 | goto wait; |
1681 | } | 1681 | } |
@@ -1708,7 +1708,7 @@ static int ftdi_elan_edset_output(struct usb_ftdi *ftdi, u8 ed_number, | |||
1708 | return -ENODEV; | 1708 | return -ENODEV; |
1709 | } else { | 1709 | } else { |
1710 | int command_size; | 1710 | int command_size; |
1711 | down(&ftdi->u132_lock); | 1711 | mutex_lock(&ftdi->u132_lock); |
1712 | command_size = ftdi->command_next - ftdi->command_head; | 1712 | command_size = ftdi->command_next - ftdi->command_head; |
1713 | if (command_size < COMMAND_SIZE) { | 1713 | if (command_size < COMMAND_SIZE) { |
1714 | u8 *b; | 1714 | u8 *b; |
@@ -1751,10 +1751,10 @@ static int ftdi_elan_edset_output(struct usb_ftdi *ftdi, u8 ed_number, | |||
1751 | target->active = 1; | 1751 | target->active = 1; |
1752 | ftdi->command_next += 1; | 1752 | ftdi->command_next += 1; |
1753 | ftdi_elan_kick_command_queue(ftdi); | 1753 | ftdi_elan_kick_command_queue(ftdi); |
1754 | up(&ftdi->u132_lock); | 1754 | mutex_unlock(&ftdi->u132_lock); |
1755 | return 0; | 1755 | return 0; |
1756 | } else { | 1756 | } else { |
1757 | up(&ftdi->u132_lock); | 1757 | mutex_unlock(&ftdi->u132_lock); |
1758 | msleep(100); | 1758 | msleep(100); |
1759 | goto wait; | 1759 | goto wait; |
1760 | } | 1760 | } |
@@ -1787,7 +1787,7 @@ static int ftdi_elan_edset_single(struct usb_ftdi *ftdi, u8 ed_number, | |||
1787 | return -ENODEV; | 1787 | return -ENODEV; |
1788 | } else { | 1788 | } else { |
1789 | int command_size; | 1789 | int command_size; |
1790 | down(&ftdi->u132_lock); | 1790 | mutex_lock(&ftdi->u132_lock); |
1791 | command_size = ftdi->command_next - ftdi->command_head; | 1791 | command_size = ftdi->command_next - ftdi->command_head; |
1792 | if (command_size < COMMAND_SIZE) { | 1792 | if (command_size < COMMAND_SIZE) { |
1793 | int remaining_length = urb->transfer_buffer_length - | 1793 | int remaining_length = urb->transfer_buffer_length - |
@@ -1816,10 +1816,10 @@ static int ftdi_elan_edset_single(struct usb_ftdi *ftdi, u8 ed_number, | |||
1816 | target->active = 1; | 1816 | target->active = 1; |
1817 | ftdi->command_next += 1; | 1817 | ftdi->command_next += 1; |
1818 | ftdi_elan_kick_command_queue(ftdi); | 1818 | ftdi_elan_kick_command_queue(ftdi); |
1819 | up(&ftdi->u132_lock); | 1819 | mutex_unlock(&ftdi->u132_lock); |
1820 | return 0; | 1820 | return 0; |
1821 | } else { | 1821 | } else { |
1822 | up(&ftdi->u132_lock); | 1822 | mutex_unlock(&ftdi->u132_lock); |
1823 | msleep(100); | 1823 | msleep(100); |
1824 | goto wait; | 1824 | goto wait; |
1825 | } | 1825 | } |
@@ -1849,9 +1849,9 @@ static int ftdi_elan_edset_flush(struct usb_ftdi *ftdi, u8 ed_number, | |||
1849 | return -ENODEV; | 1849 | return -ENODEV; |
1850 | } else { | 1850 | } else { |
1851 | struct u132_target *target = &ftdi->target[ed]; | 1851 | struct u132_target *target = &ftdi->target[ed]; |
1852 | down(&ftdi->u132_lock); | 1852 | mutex_lock(&ftdi->u132_lock); |
1853 | if (target->abandoning > 0) { | 1853 | if (target->abandoning > 0) { |
1854 | up(&ftdi->u132_lock); | 1854 | mutex_unlock(&ftdi->u132_lock); |
1855 | return 0; | 1855 | return 0; |
1856 | } else { | 1856 | } else { |
1857 | target->abandoning = 1; | 1857 | target->abandoning = 1; |
@@ -1873,13 +1873,13 @@ static int ftdi_elan_edset_flush(struct usb_ftdi *ftdi, u8 ed_number, | |||
1873 | ftdi->command_next += 1; | 1873 | ftdi->command_next += 1; |
1874 | ftdi_elan_kick_command_queue(ftdi); | 1874 | ftdi_elan_kick_command_queue(ftdi); |
1875 | } else { | 1875 | } else { |
1876 | up(&ftdi->u132_lock); | 1876 | mutex_unlock(&ftdi->u132_lock); |
1877 | msleep(100); | 1877 | msleep(100); |
1878 | down(&ftdi->u132_lock); | 1878 | mutex_lock(&ftdi->u132_lock); |
1879 | goto wait_1; | 1879 | goto wait_1; |
1880 | } | 1880 | } |
1881 | } | 1881 | } |
1882 | up(&ftdi->u132_lock); | 1882 | mutex_unlock(&ftdi->u132_lock); |
1883 | return 0; | 1883 | return 0; |
1884 | } | 1884 | } |
1885 | } | 1885 | } |
@@ -2793,7 +2793,7 @@ static int ftdi_elan_probe(struct usb_interface *interface, | |||
2793 | init_MUTEX(&ftdi->sw_lock); | 2793 | init_MUTEX(&ftdi->sw_lock); |
2794 | ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); | 2794 | ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); |
2795 | ftdi->interface = interface; | 2795 | ftdi->interface = interface; |
2796 | init_MUTEX(&ftdi->u132_lock); | 2796 | mutex_init(&ftdi->u132_lock); |
2797 | ftdi->expected = 4; | 2797 | ftdi->expected = 4; |
2798 | iface_desc = interface->cur_altsetting; | 2798 | iface_desc = interface->cur_altsetting; |
2799 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 2799 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index e6fd024024f5..4bcf7fb4e5da 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -66,6 +66,7 @@ static struct usb_device_id idmouse_table[] = { | |||
66 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, value, index, NULL, 0, 1000) | 66 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, value, index, NULL, 0, 1000) |
67 | 67 | ||
68 | MODULE_DEVICE_TABLE(usb, idmouse_table); | 68 | MODULE_DEVICE_TABLE(usb, idmouse_table); |
69 | static DEFINE_MUTEX(open_disc_mutex); | ||
69 | 70 | ||
70 | /* structure to hold all of our device specific stuff */ | 71 | /* structure to hold all of our device specific stuff */ |
71 | struct usb_idmouse { | 72 | struct usb_idmouse { |
@@ -80,7 +81,7 @@ struct usb_idmouse { | |||
80 | 81 | ||
81 | int open; /* if the port is open or not */ | 82 | int open; /* if the port is open or not */ |
82 | int present; /* if the device is not disconnected */ | 83 | int present; /* if the device is not disconnected */ |
83 | struct semaphore sem; /* locks this structure */ | 84 | struct mutex lock; /* locks this structure */ |
84 | 85 | ||
85 | }; | 86 | }; |
86 | 87 | ||
@@ -213,13 +214,17 @@ static int idmouse_open(struct inode *inode, struct file *file) | |||
213 | if (!interface) | 214 | if (!interface) |
214 | return -ENODEV; | 215 | return -ENODEV; |
215 | 216 | ||
217 | mutex_lock(&open_disc_mutex); | ||
216 | /* get the device information block from the interface */ | 218 | /* get the device information block from the interface */ |
217 | dev = usb_get_intfdata(interface); | 219 | dev = usb_get_intfdata(interface); |
218 | if (!dev) | 220 | if (!dev) { |
221 | mutex_unlock(&open_disc_mutex); | ||
219 | return -ENODEV; | 222 | return -ENODEV; |
223 | } | ||
220 | 224 | ||
221 | /* lock this device */ | 225 | /* lock this device */ |
222 | down(&dev->sem); | 226 | mutex_lock(&dev->lock); |
227 | mutex_unlock(&open_disc_mutex); | ||
223 | 228 | ||
224 | /* check if already open */ | 229 | /* check if already open */ |
225 | if (dev->open) { | 230 | if (dev->open) { |
@@ -245,7 +250,7 @@ static int idmouse_open(struct inode *inode, struct file *file) | |||
245 | error: | 250 | error: |
246 | 251 | ||
247 | /* unlock this device */ | 252 | /* unlock this device */ |
248 | up(&dev->sem); | 253 | mutex_unlock(&dev->lock); |
249 | return result; | 254 | return result; |
250 | } | 255 | } |
251 | 256 | ||
@@ -258,12 +263,14 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
258 | if (dev == NULL) | 263 | if (dev == NULL) |
259 | return -ENODEV; | 264 | return -ENODEV; |
260 | 265 | ||
266 | mutex_lock(&open_disc_mutex); | ||
261 | /* lock our device */ | 267 | /* lock our device */ |
262 | down(&dev->sem); | 268 | mutex_lock(&dev->lock); |
263 | 269 | ||
264 | /* are we really open? */ | 270 | /* are we really open? */ |
265 | if (dev->open <= 0) { | 271 | if (dev->open <= 0) { |
266 | up(&dev->sem); | 272 | mutex_unlock(&dev->lock); |
273 | mutex_unlock(&open_disc_mutex); | ||
267 | return -ENODEV; | 274 | return -ENODEV; |
268 | } | 275 | } |
269 | 276 | ||
@@ -271,10 +278,12 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
271 | 278 | ||
272 | if (!dev->present) { | 279 | if (!dev->present) { |
273 | /* the device was unplugged before the file was released */ | 280 | /* the device was unplugged before the file was released */ |
274 | up(&dev->sem); | 281 | mutex_unlock(&dev->lock); |
282 | mutex_unlock(&open_disc_mutex); | ||
275 | idmouse_delete(dev); | 283 | idmouse_delete(dev); |
276 | } else { | 284 | } else { |
277 | up(&dev->sem); | 285 | mutex_unlock(&dev->lock); |
286 | mutex_unlock(&open_disc_mutex); | ||
278 | } | 287 | } |
279 | return 0; | 288 | return 0; |
280 | } | 289 | } |
@@ -286,18 +295,18 @@ static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count | |||
286 | int result; | 295 | int result; |
287 | 296 | ||
288 | /* lock this object */ | 297 | /* lock this object */ |
289 | down(&dev->sem); | 298 | mutex_lock(&dev->lock); |
290 | 299 | ||
291 | /* verify that the device wasn't unplugged */ | 300 | /* verify that the device wasn't unplugged */ |
292 | if (!dev->present) { | 301 | if (!dev->present) { |
293 | up(&dev->sem); | 302 | mutex_unlock(&dev->lock); |
294 | return -ENODEV; | 303 | return -ENODEV; |
295 | } | 304 | } |
296 | 305 | ||
297 | result = simple_read_from_buffer(buffer, count, ppos, | 306 | result = simple_read_from_buffer(buffer, count, ppos, |
298 | dev->bulk_in_buffer, IMGSIZE); | 307 | dev->bulk_in_buffer, IMGSIZE); |
299 | /* unlock the device */ | 308 | /* unlock the device */ |
300 | up(&dev->sem); | 309 | mutex_unlock(&dev->lock); |
301 | return result; | 310 | return result; |
302 | } | 311 | } |
303 | 312 | ||
@@ -320,7 +329,7 @@ static int idmouse_probe(struct usb_interface *interface, | |||
320 | if (dev == NULL) | 329 | if (dev == NULL) |
321 | return -ENOMEM; | 330 | return -ENOMEM; |
322 | 331 | ||
323 | init_MUTEX(&dev->sem); | 332 | mutex_init(&dev->lock); |
324 | dev->udev = udev; | 333 | dev->udev = udev; |
325 | dev->interface = interface; | 334 | dev->interface = interface; |
326 | 335 | ||
@@ -372,24 +381,26 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
372 | 381 | ||
373 | /* get device structure */ | 382 | /* get device structure */ |
374 | dev = usb_get_intfdata(interface); | 383 | dev = usb_get_intfdata(interface); |
375 | usb_set_intfdata(interface, NULL); | ||
376 | 384 | ||
377 | /* give back our minor */ | 385 | /* give back our minor */ |
378 | usb_deregister_dev(interface, &idmouse_class); | 386 | usb_deregister_dev(interface, &idmouse_class); |
379 | 387 | ||
380 | /* lock it */ | 388 | mutex_lock(&open_disc_mutex); |
381 | down(&dev->sem); | 389 | usb_set_intfdata(interface, NULL); |
390 | /* lock the device */ | ||
391 | mutex_lock(&dev->lock); | ||
392 | mutex_unlock(&open_disc_mutex); | ||
382 | 393 | ||
383 | /* prevent device read, write and ioctl */ | 394 | /* prevent device read, write and ioctl */ |
384 | dev->present = 0; | 395 | dev->present = 0; |
385 | 396 | ||
386 | /* if the device is opened, idmouse_release will clean this up */ | 397 | /* if the device is opened, idmouse_release will clean this up */ |
387 | if (!dev->open) { | 398 | if (!dev->open) { |
388 | up(&dev->sem); | 399 | mutex_unlock(&dev->lock); |
389 | idmouse_delete(dev); | 400 | idmouse_delete(dev); |
390 | } else { | 401 | } else { |
391 | /* unlock */ | 402 | /* unlock */ |
392 | up(&dev->sem); | 403 | mutex_unlock(&dev->lock); |
393 | } | 404 | } |
394 | 405 | ||
395 | info("%s disconnected", DRIVER_DESC); | 406 | info("%s disconnected", DRIVER_DESC); |
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index d372fbc4effb..764696ff1e8e 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -66,6 +66,7 @@ module_param(debug, bool, 0644); | |||
66 | MODULE_PARM_DESC(debug, "debug=1 enables debugging messages"); | 66 | MODULE_PARM_DESC(debug, "debug=1 enables debugging messages"); |
67 | 67 | ||
68 | static struct usb_driver iowarrior_driver; | 68 | static struct usb_driver iowarrior_driver; |
69 | static DEFINE_MUTEX(iowarrior_open_disc_lock); | ||
69 | 70 | ||
70 | /*--------------*/ | 71 | /*--------------*/ |
71 | /* data */ | 72 | /* data */ |
@@ -351,7 +352,7 @@ static ssize_t iowarrior_write(struct file *file, | |||
351 | 352 | ||
352 | mutex_lock(&dev->mutex); | 353 | mutex_lock(&dev->mutex); |
353 | /* verify that the device wasn't unplugged */ | 354 | /* verify that the device wasn't unplugged */ |
354 | if (dev == NULL || !dev->present) { | 355 | if (!dev->present) { |
355 | retval = -ENODEV; | 356 | retval = -ENODEV; |
356 | goto exit; | 357 | goto exit; |
357 | } | 358 | } |
@@ -608,11 +609,15 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
608 | return -ENODEV; | 609 | return -ENODEV; |
609 | } | 610 | } |
610 | 611 | ||
612 | mutex_lock(&iowarrior_open_disc_lock); | ||
611 | dev = usb_get_intfdata(interface); | 613 | dev = usb_get_intfdata(interface); |
612 | if (!dev) | 614 | if (!dev) { |
615 | mutex_unlock(&iowarrior_open_disc_lock); | ||
613 | return -ENODEV; | 616 | return -ENODEV; |
617 | } | ||
614 | 618 | ||
615 | mutex_lock(&dev->mutex); | 619 | mutex_lock(&dev->mutex); |
620 | mutex_unlock(&iowarrior_open_disc_lock); | ||
616 | 621 | ||
617 | /* Only one process can open each device, no sharing. */ | 622 | /* Only one process can open each device, no sharing. */ |
618 | if (dev->opened) { | 623 | if (dev->opened) { |
@@ -866,6 +871,7 @@ static void iowarrior_disconnect(struct usb_interface *interface) | |||
866 | int minor; | 871 | int minor; |
867 | 872 | ||
868 | dev = usb_get_intfdata(interface); | 873 | dev = usb_get_intfdata(interface); |
874 | mutex_lock(&iowarrior_open_disc_lock); | ||
869 | usb_set_intfdata(interface, NULL); | 875 | usb_set_intfdata(interface, NULL); |
870 | 876 | ||
871 | minor = dev->minor; | 877 | minor = dev->minor; |
@@ -879,6 +885,7 @@ static void iowarrior_disconnect(struct usb_interface *interface) | |||
879 | dev->present = 0; | 885 | dev->present = 0; |
880 | 886 | ||
881 | mutex_unlock(&dev->mutex); | 887 | mutex_unlock(&dev->mutex); |
888 | mutex_unlock(&iowarrior_open_disc_lock); | ||
882 | 889 | ||
883 | if (dev->opened) { | 890 | if (dev->opened) { |
884 | /* There is a process that holds a filedescriptor to the device , | 891 | /* There is a process that holds a filedescriptor to the device , |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 561970b889a5..aab320085ebf 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -198,6 +198,7 @@ static struct usb_device_id tower_table [] = { | |||
198 | }; | 198 | }; |
199 | 199 | ||
200 | MODULE_DEVICE_TABLE (usb, tower_table); | 200 | MODULE_DEVICE_TABLE (usb, tower_table); |
201 | static DEFINE_MUTEX(open_disc_mutex); | ||
201 | 202 | ||
202 | #define LEGO_USB_TOWER_MINOR_BASE 160 | 203 | #define LEGO_USB_TOWER_MINOR_BASE 160 |
203 | 204 | ||
@@ -350,25 +351,31 @@ static int tower_open (struct inode *inode, struct file *file) | |||
350 | goto exit; | 351 | goto exit; |
351 | } | 352 | } |
352 | 353 | ||
354 | mutex_lock(&open_disc_mutex); | ||
353 | dev = usb_get_intfdata(interface); | 355 | dev = usb_get_intfdata(interface); |
354 | 356 | ||
355 | if (!dev) { | 357 | if (!dev) { |
358 | mutex_unlock(&open_disc_mutex); | ||
356 | retval = -ENODEV; | 359 | retval = -ENODEV; |
357 | goto exit; | 360 | goto exit; |
358 | } | 361 | } |
359 | 362 | ||
360 | /* lock this device */ | 363 | /* lock this device */ |
361 | if (down_interruptible (&dev->sem)) { | 364 | if (down_interruptible (&dev->sem)) { |
365 | mutex_unlock(&open_disc_mutex); | ||
362 | retval = -ERESTARTSYS; | 366 | retval = -ERESTARTSYS; |
363 | goto exit; | 367 | goto exit; |
364 | } | 368 | } |
365 | 369 | ||
370 | |||
366 | /* allow opening only once */ | 371 | /* allow opening only once */ |
367 | if (dev->open_count) { | 372 | if (dev->open_count) { |
373 | mutex_unlock(&open_disc_mutex); | ||
368 | retval = -EBUSY; | 374 | retval = -EBUSY; |
369 | goto unlock_exit; | 375 | goto unlock_exit; |
370 | } | 376 | } |
371 | dev->open_count = 1; | 377 | dev->open_count = 1; |
378 | mutex_unlock(&open_disc_mutex); | ||
372 | 379 | ||
373 | /* reset the tower */ | 380 | /* reset the tower */ |
374 | result = usb_control_msg (dev->udev, | 381 | result = usb_control_msg (dev->udev, |
@@ -437,9 +444,10 @@ static int tower_release (struct inode *inode, struct file *file) | |||
437 | if (dev == NULL) { | 444 | if (dev == NULL) { |
438 | dbg(1, "%s: object is NULL", __FUNCTION__); | 445 | dbg(1, "%s: object is NULL", __FUNCTION__); |
439 | retval = -ENODEV; | 446 | retval = -ENODEV; |
440 | goto exit; | 447 | goto exit_nolock; |
441 | } | 448 | } |
442 | 449 | ||
450 | mutex_lock(&open_disc_mutex); | ||
443 | if (down_interruptible (&dev->sem)) { | 451 | if (down_interruptible (&dev->sem)) { |
444 | retval = -ERESTARTSYS; | 452 | retval = -ERESTARTSYS; |
445 | goto exit; | 453 | goto exit; |
@@ -468,6 +476,8 @@ unlock_exit: | |||
468 | up (&dev->sem); | 476 | up (&dev->sem); |
469 | 477 | ||
470 | exit: | 478 | exit: |
479 | mutex_unlock(&open_disc_mutex); | ||
480 | exit_nolock: | ||
471 | dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); | 481 | dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); |
472 | return retval; | 482 | return retval; |
473 | } | 483 | } |
@@ -989,6 +999,7 @@ static void tower_disconnect (struct usb_interface *interface) | |||
989 | dbg(2, "%s: enter", __FUNCTION__); | 999 | dbg(2, "%s: enter", __FUNCTION__); |
990 | 1000 | ||
991 | dev = usb_get_intfdata (interface); | 1001 | dev = usb_get_intfdata (interface); |
1002 | mutex_lock(&open_disc_mutex); | ||
992 | usb_set_intfdata (interface, NULL); | 1003 | usb_set_intfdata (interface, NULL); |
993 | 1004 | ||
994 | minor = dev->minor; | 1005 | minor = dev->minor; |
@@ -997,6 +1008,7 @@ static void tower_disconnect (struct usb_interface *interface) | |||
997 | usb_deregister_dev (interface, &tower_class); | 1008 | usb_deregister_dev (interface, &tower_class); |
998 | 1009 | ||
999 | down (&dev->sem); | 1010 | down (&dev->sem); |
1011 | mutex_unlock(&open_disc_mutex); | ||
1000 | 1012 | ||
1001 | /* if the device is not opened, then we clean up right now */ | 1013 | /* if the device is not opened, then we clean up right now */ |
1002 | if (!dev->open_count) { | 1014 | if (!dev->open_count) { |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 88f6abe73624..330c18e390b8 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -118,10 +118,7 @@ ioctl_rio(struct inode *inode, struct file *file, unsigned int cmd, | |||
118 | 118 | ||
119 | mutex_lock(&(rio->lock)); | 119 | mutex_lock(&(rio->lock)); |
120 | /* Sanity check to make sure rio is connected, powered, etc */ | 120 | /* Sanity check to make sure rio is connected, powered, etc */ |
121 | if ( rio == NULL || | 121 | if (rio->present == 0 || rio->rio_dev == NULL) { |
122 | rio->present == 0 || | ||
123 | rio->rio_dev == NULL ) | ||
124 | { | ||
125 | retval = -ENODEV; | 122 | retval = -ENODEV; |
126 | goto err_out; | 123 | goto err_out; |
127 | } | 124 | } |
@@ -280,10 +277,7 @@ write_rio(struct file *file, const char __user *buffer, | |||
280 | if (intr) | 277 | if (intr) |
281 | return -EINTR; | 278 | return -EINTR; |
282 | /* Sanity check to make sure rio is connected, powered, etc */ | 279 | /* Sanity check to make sure rio is connected, powered, etc */ |
283 | if ( rio == NULL || | 280 | if (rio->present == 0 || rio->rio_dev == NULL) { |
284 | rio->present == 0 || | ||
285 | rio->rio_dev == NULL ) | ||
286 | { | ||
287 | mutex_unlock(&(rio->lock)); | 281 | mutex_unlock(&(rio->lock)); |
288 | return -ENODEV; | 282 | return -ENODEV; |
289 | } | 283 | } |
@@ -369,10 +363,7 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) | |||
369 | if (intr) | 363 | if (intr) |
370 | return -EINTR; | 364 | return -EINTR; |
371 | /* Sanity check to make sure rio is connected, powered, etc */ | 365 | /* Sanity check to make sure rio is connected, powered, etc */ |
372 | if ( rio == NULL || | 366 | if (rio->present == 0 || rio->rio_dev == NULL) { |
373 | rio->present == 0 || | ||
374 | rio->rio_dev == NULL ) | ||
375 | { | ||
376 | mutex_unlock(&(rio->lock)); | 367 | mutex_unlock(&(rio->lock)); |
377 | return -ENODEV; | 368 | return -ENODEV; |
378 | } | 369 | } |
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 719842032712..20777d01db62 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/mutex.h> | ||
20 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
21 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
22 | 23 | ||
@@ -34,6 +35,8 @@ static struct usb_device_id id_table [] = { | |||
34 | }; | 35 | }; |
35 | MODULE_DEVICE_TABLE (usb, id_table); | 36 | MODULE_DEVICE_TABLE (usb, id_table); |
36 | 37 | ||
38 | static DEFINE_MUTEX(open_disc_mutex); | ||
39 | |||
37 | 40 | ||
38 | struct usb_lcd { | 41 | struct usb_lcd { |
39 | struct usb_device * udev; /* init: probe_lcd */ | 42 | struct usb_device * udev; /* init: probe_lcd */ |
@@ -79,12 +82,16 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
79 | return -ENODEV; | 82 | return -ENODEV; |
80 | } | 83 | } |
81 | 84 | ||
85 | mutex_lock(&open_disc_mutex); | ||
82 | dev = usb_get_intfdata(interface); | 86 | dev = usb_get_intfdata(interface); |
83 | if (!dev) | 87 | if (!dev) { |
88 | mutex_unlock(&open_disc_mutex); | ||
84 | return -ENODEV; | 89 | return -ENODEV; |
90 | } | ||
85 | 91 | ||
86 | /* increment our usage count for the device */ | 92 | /* increment our usage count for the device */ |
87 | kref_get(&dev->kref); | 93 | kref_get(&dev->kref); |
94 | mutex_unlock(&open_disc_mutex); | ||
88 | 95 | ||
89 | /* grab a power reference */ | 96 | /* grab a power reference */ |
90 | r = usb_autopm_get_interface(interface); | 97 | r = usb_autopm_get_interface(interface); |
@@ -393,8 +400,10 @@ static void lcd_disconnect(struct usb_interface *interface) | |||
393 | struct usb_lcd *dev; | 400 | struct usb_lcd *dev; |
394 | int minor = interface->minor; | 401 | int minor = interface->minor; |
395 | 402 | ||
403 | mutex_lock(&open_disc_mutex); | ||
396 | dev = usb_get_intfdata(interface); | 404 | dev = usb_get_intfdata(interface); |
397 | usb_set_intfdata(interface, NULL); | 405 | usb_set_intfdata(interface, NULL); |
406 | mutex_unlock(&open_disc_mutex); | ||
398 | 407 | ||
399 | /* give back our minor */ | 408 | /* give back our minor */ |
400 | usb_deregister_dev(interface, &lcd_class); | 409 | usb_deregister_dev(interface, &lcd_class); |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 2a8e537cb046..ddfee918000d 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -161,7 +161,8 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
161 | { | 161 | { |
162 | struct usb_serial *serial = port->serial; | 162 | struct usb_serial *serial = port->serial; |
163 | struct ark3116_private *priv = usb_get_serial_port_data(port); | 163 | struct ark3116_private *priv = usb_get_serial_port_data(port); |
164 | unsigned int cflag = port->tty->termios->c_cflag; | 164 | struct ktermios *termios = port->tty->termios; |
165 | unsigned int cflag = termios->c_cflag; | ||
165 | unsigned long flags; | 166 | unsigned long flags; |
166 | int baud; | 167 | int baud; |
167 | int ark3116_baud; | 168 | int ark3116_baud; |
@@ -177,11 +178,14 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
177 | *(port->tty->termios) = tty_std_termios; | 178 | *(port->tty->termios) = tty_std_termios; |
178 | port->tty->termios->c_cflag = B9600 | CS8 | 179 | port->tty->termios->c_cflag = B9600 | CS8 |
179 | | CREAD | HUPCL | CLOCAL; | 180 | | CREAD | HUPCL | CLOCAL; |
181 | termios->c_ispeed = 9600; | ||
182 | termios->c_ospeed = 9600; | ||
180 | priv->termios_initialized = 1; | 183 | priv->termios_initialized = 1; |
181 | } | 184 | } |
182 | spin_unlock_irqrestore(&priv->lock, flags); | 185 | spin_unlock_irqrestore(&priv->lock, flags); |
183 | 186 | ||
184 | cflag = port->tty->termios->c_cflag; | 187 | cflag = termios->c_cflag; |
188 | termios->c_cflag &= ~(CMSPAR|CRTSCTS); | ||
185 | 189 | ||
186 | buf = kmalloc(1, GFP_KERNEL); | 190 | buf = kmalloc(1, GFP_KERNEL); |
187 | if (!buf) { | 191 | if (!buf) { |
@@ -254,9 +258,13 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
254 | case 115200: | 258 | case 115200: |
255 | case 230400: | 259 | case 230400: |
256 | case 460800: | 260 | case 460800: |
261 | /* Report the resulting rate back to the caller */ | ||
262 | tty_encode_baud_rate(port->tty, baud, baud); | ||
257 | break; | 263 | break; |
258 | /* set 9600 as default (if given baudrate is invalid for example) */ | 264 | /* set 9600 as default (if given baudrate is invalid for example) */ |
259 | default: | 265 | default: |
266 | tty_encode_baud_rate(port->tty, 9600, 9600); | ||
267 | case 0: | ||
260 | baud = 9600; | 268 | baud = 9600; |
261 | } | 269 | } |
262 | 270 | ||
@@ -302,6 +310,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
302 | /* TEST ARK3116_SND(154, 0xFE, 0x40, 0xFFFF, 0x0006); */ | 310 | /* TEST ARK3116_SND(154, 0xFE, 0x40, 0xFFFF, 0x0006); */ |
303 | 311 | ||
304 | kfree(buf); | 312 | kfree(buf); |
313 | |||
305 | return; | 314 | return; |
306 | } | 315 | } |
307 | 316 | ||
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 6b252ceb39a8..42582d49b69c 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
@@ -272,9 +272,6 @@ static void ch341_set_termios(struct usb_serial_port *port, | |||
272 | 272 | ||
273 | dbg("ch341_set_termios()"); | 273 | dbg("ch341_set_termios()"); |
274 | 274 | ||
275 | if (!tty || !tty->termios) | ||
276 | return; | ||
277 | |||
278 | baud_rate = tty_get_baud_rate(tty); | 275 | baud_rate = tty_get_baud_rate(tty); |
279 | 276 | ||
280 | switch (baud_rate) { | 277 | switch (baud_rate) { |
@@ -299,6 +296,11 @@ static void ch341_set_termios(struct usb_serial_port *port, | |||
299 | * (cflag & PARENB) : parity {NONE, EVEN, ODD} | 296 | * (cflag & PARENB) : parity {NONE, EVEN, ODD} |
300 | * (cflag & CSTOPB) : stop bits [1, 2] | 297 | * (cflag & CSTOPB) : stop bits [1, 2] |
301 | */ | 298 | */ |
299 | |||
300 | /* Copy back the old hardware settings */ | ||
301 | tty_termios_copy_hw(tty->termios, old_termios); | ||
302 | /* And re-encode with the new baud */ | ||
303 | tty_encode_baud_rate(tty, baud_rate, baud_rate); | ||
302 | } | 304 | } |
303 | 305 | ||
304 | static struct usb_driver ch341_driver = { | 306 | static struct usb_driver ch341_driver = { |
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 9386e216d681..0362654d3b52 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c | |||
@@ -164,6 +164,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
164 | } | 164 | } |
165 | 165 | ||
166 | if (serial->type->set_termios) { | 166 | if (serial->type->set_termios) { |
167 | struct ktermios dummy; | ||
167 | /* build up a fake tty structure so that the open call has something | 168 | /* build up a fake tty structure so that the open call has something |
168 | * to look at to get the cflag value */ | 169 | * to look at to get the cflag value */ |
169 | tty = kzalloc(sizeof(*tty), GFP_KERNEL); | 170 | tty = kzalloc(sizeof(*tty), GFP_KERNEL); |
@@ -177,12 +178,13 @@ static int usb_console_setup(struct console *co, char *options) | |||
177 | kfree (tty); | 178 | kfree (tty); |
178 | return -ENOMEM; | 179 | return -ENOMEM; |
179 | } | 180 | } |
181 | memset(&dummy, 0, sizeof(struct ktermios)); | ||
180 | termios->c_cflag = cflag; | 182 | termios->c_cflag = cflag; |
181 | tty->termios = termios; | 183 | tty->termios = termios; |
182 | port->tty = tty; | 184 | port->tty = tty; |
183 | 185 | ||
184 | /* set up the initial termios settings */ | 186 | /* set up the initial termios settings */ |
185 | serial->type->set_termios(port, NULL); | 187 | serial->type->set_termios(port, &dummy); |
186 | port->tty = NULL; | 188 | port->tty = NULL; |
187 | kfree (termios); | 189 | kfree (termios); |
188 | kfree (tty); | 190 | kfree (tty); |
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index eb7df1835c11..3a83cb4c4bc2 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -361,7 +361,6 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
361 | dbg("%s - no tty structures", __FUNCTION__); | 361 | dbg("%s - no tty structures", __FUNCTION__); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | cflag = port->tty->termios->c_cflag; | ||
365 | 364 | ||
366 | cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); | 365 | cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); |
367 | /* Convert to baudrate */ | 366 | /* Convert to baudrate */ |
@@ -369,40 +368,9 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
369 | baud = BAUD_RATE_GEN_FREQ / baud; | 368 | baud = BAUD_RATE_GEN_FREQ / baud; |
370 | 369 | ||
371 | dbg("%s - baud rate = %d", __FUNCTION__, baud); | 370 | dbg("%s - baud rate = %d", __FUNCTION__, baud); |
372 | cflag &= ~CBAUD; | 371 | |
373 | switch (baud) { | 372 | tty_encode_baud_rate(port->tty, baud, baud); |
374 | /* | 373 | cflag = port->tty->termios->c_cflag; |
375 | * The baud rates which are commented out below | ||
376 | * appear to be supported by the device | ||
377 | * but are non-standard | ||
378 | */ | ||
379 | case 600: cflag |= B600; break; | ||
380 | case 1200: cflag |= B1200; break; | ||
381 | case 1800: cflag |= B1800; break; | ||
382 | case 2400: cflag |= B2400; break; | ||
383 | case 4800: cflag |= B4800; break; | ||
384 | /*case 7200: cflag |= B7200; break;*/ | ||
385 | case 9600: cflag |= B9600; break; | ||
386 | /*case 14400: cflag |= B14400; break;*/ | ||
387 | case 19200: cflag |= B19200; break; | ||
388 | /*case 28800: cflag |= B28800; break;*/ | ||
389 | case 38400: cflag |= B38400; break; | ||
390 | /*case 55854: cflag |= B55054; break;*/ | ||
391 | case 57600: cflag |= B57600; break; | ||
392 | case 115200: cflag |= B115200; break; | ||
393 | /*case 127117: cflag |= B127117; break;*/ | ||
394 | case 230400: cflag |= B230400; break; | ||
395 | case 460800: cflag |= B460800; break; | ||
396 | case 921600: cflag |= B921600; break; | ||
397 | /*case 3686400: cflag |= B3686400; break;*/ | ||
398 | default: | ||
399 | dbg("%s - Baud rate is not supported, " | ||
400 | "using 9600 baud", __FUNCTION__); | ||
401 | cflag |= B9600; | ||
402 | cp2101_set_config_single(port, CP2101_BAUDRATE, | ||
403 | (BAUD_RATE_GEN_FREQ/9600)); | ||
404 | break; | ||
405 | } | ||
406 | 374 | ||
407 | cp2101_get_config(port, CP2101_BITS, &bits, 2); | 375 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
408 | cflag &= ~CSIZE; | 376 | cflag &= ~CSIZE; |
@@ -516,7 +484,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
516 | static void cp2101_set_termios (struct usb_serial_port *port, | 484 | static void cp2101_set_termios (struct usb_serial_port *port, |
517 | struct ktermios *old_termios) | 485 | struct ktermios *old_termios) |
518 | { | 486 | { |
519 | unsigned int cflag, old_cflag=0; | 487 | unsigned int cflag, old_cflag; |
520 | int baud=0, bits; | 488 | int baud=0, bits; |
521 | unsigned int modem_ctl[4]; | 489 | unsigned int modem_ctl[4]; |
522 | 490 | ||
@@ -526,6 +494,8 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
526 | dbg("%s - no tty structures", __FUNCTION__); | 494 | dbg("%s - no tty structures", __FUNCTION__); |
527 | return; | 495 | return; |
528 | } | 496 | } |
497 | port->tty->termios->c_cflag &= ~CMSPAR; | ||
498 | |||
529 | cflag = port->tty->termios->c_cflag; | 499 | cflag = port->tty->termios->c_cflag; |
530 | old_cflag = old_termios->c_cflag; | 500 | old_cflag = old_termios->c_cflag; |
531 | baud = tty_get_baud_rate(port->tty); | 501 | baud = tty_get_baud_rate(port->tty); |
@@ -563,11 +533,15 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
563 | dbg("%s - Setting baud rate to %d baud", __FUNCTION__, | 533 | dbg("%s - Setting baud rate to %d baud", __FUNCTION__, |
564 | baud); | 534 | baud); |
565 | if (cp2101_set_config_single(port, CP2101_BAUDRATE, | 535 | if (cp2101_set_config_single(port, CP2101_BAUDRATE, |
566 | (BAUD_RATE_GEN_FREQ / baud))) | 536 | (BAUD_RATE_GEN_FREQ / baud))) { |
567 | dev_err(&port->dev, "Baud rate requested not " | 537 | dev_err(&port->dev, "Baud rate requested not " |
568 | "supported by device\n"); | 538 | "supported by device\n"); |
539 | baud = tty_termios_baud_rate(old_termios); | ||
540 | } | ||
569 | } | 541 | } |
570 | } | 542 | } |
543 | /* Report back the resulting baud rate */ | ||
544 | tty_encode_baud_rate(port->tty, baud, baud); | ||
571 | 545 | ||
572 | /* If the number of data bits is to be updated */ | 546 | /* If the number of data bits is to be updated */ |
573 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { | 547 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index dab2e66d111d..ae410c4678ea 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -973,6 +973,8 @@ static void digi_set_termios(struct usb_serial_port *port, | |||
973 | } | 973 | } |
974 | } | 974 | } |
975 | /* set parity */ | 975 | /* set parity */ |
976 | tty->termios->c_cflag &= ~CMSPAR; | ||
977 | |||
976 | if ((cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD))) { | 978 | if ((cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD))) { |
977 | if (cflag&PARENB) { | 979 | if (cflag&PARENB) { |
978 | if (cflag&PARODD) | 980 | if (cflag&PARODD) |
@@ -1054,15 +1056,15 @@ static void digi_set_termios(struct usb_serial_port *port, | |||
1054 | } | 1056 | } |
1055 | 1057 | ||
1056 | /* set output flow control */ | 1058 | /* set output flow control */ |
1057 | if ((iflag&IXON) != (old_iflag&IXON) | 1059 | if ((iflag & IXON) != (old_iflag & IXON) |
1058 | || (cflag&CRTSCTS) != (old_cflag&CRTSCTS)) { | 1060 | || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { |
1059 | arg = 0; | 1061 | arg = 0; |
1060 | if (iflag&IXON) | 1062 | if (iflag & IXON) |
1061 | arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; | 1063 | arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; |
1062 | else | 1064 | else |
1063 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; | 1065 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; |
1064 | 1066 | ||
1065 | if (cflag&CRTSCTS) { | 1067 | if (cflag & CRTSCTS) { |
1066 | arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS; | 1068 | arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS; |
1067 | } else { | 1069 | } else { |
1068 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS; | 1070 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS; |
@@ -1076,8 +1078,8 @@ static void digi_set_termios(struct usb_serial_port *port, | |||
1076 | } | 1078 | } |
1077 | 1079 | ||
1078 | /* set receive enable/disable */ | 1080 | /* set receive enable/disable */ |
1079 | if ((cflag&CREAD) != (old_cflag&CREAD)) { | 1081 | if ((cflag & CREAD) != (old_cflag & CREAD)) { |
1080 | if (cflag&CREAD) | 1082 | if (cflag & CREAD) |
1081 | arg = DIGI_ENABLE; | 1083 | arg = DIGI_ENABLE; |
1082 | else | 1084 | else |
1083 | arg = DIGI_DISABLE; | 1085 | arg = DIGI_DISABLE; |
@@ -1089,7 +1091,7 @@ static void digi_set_termios(struct usb_serial_port *port, | |||
1089 | } | 1091 | } |
1090 | if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0) | 1092 | if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0) |
1091 | dbg("digi_set_termios: write oob failed, ret=%d", ret); | 1093 | dbg("digi_set_termios: write oob failed, ret=%d", ret); |
1092 | 1094 | tty_encode_baud_rate(tty, baud, baud); | |
1093 | } | 1095 | } |
1094 | 1096 | ||
1095 | 1097 | ||
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 050fcc996f56..a5c8e1e17ea5 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -449,14 +449,9 @@ static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsign | |||
449 | 449 | ||
450 | static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 450 | static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) |
451 | { | 451 | { |
452 | 452 | struct ktermios *termios = port->tty->termios; | |
453 | dbg("%s - port %d", __FUNCTION__, port->number); | 453 | dbg("%s - port %d", __FUNCTION__, port->number); |
454 | 454 | ||
455 | if ((!port->tty) || (!port->tty->termios)) { | ||
456 | dbg("%s - no tty structures", __FUNCTION__); | ||
457 | return; | ||
458 | } | ||
459 | |||
460 | /* | 455 | /* |
461 | * The empeg-car player wants these particular tty settings. | 456 | * The empeg-car player wants these particular tty settings. |
462 | * You could, for example, change the baud rate, however the | 457 | * You could, for example, change the baud rate, however the |
@@ -466,7 +461,7 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol | |||
466 | * | 461 | * |
467 | * The default requirements for this device are: | 462 | * The default requirements for this device are: |
468 | */ | 463 | */ |
469 | port->tty->termios->c_iflag | 464 | termios->c_iflag |
470 | &= ~(IGNBRK /* disable ignore break */ | 465 | &= ~(IGNBRK /* disable ignore break */ |
471 | | BRKINT /* disable break causes interrupt */ | 466 | | BRKINT /* disable break causes interrupt */ |
472 | | PARMRK /* disable mark parity errors */ | 467 | | PARMRK /* disable mark parity errors */ |
@@ -476,24 +471,23 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol | |||
476 | | ICRNL /* disable translate CR to NL */ | 471 | | ICRNL /* disable translate CR to NL */ |
477 | | IXON); /* disable enable XON/XOFF flow control */ | 472 | | IXON); /* disable enable XON/XOFF flow control */ |
478 | 473 | ||
479 | port->tty->termios->c_oflag | 474 | termios->c_oflag |
480 | &= ~OPOST; /* disable postprocess output characters */ | 475 | &= ~OPOST; /* disable postprocess output characters */ |
481 | 476 | ||
482 | port->tty->termios->c_lflag | 477 | termios->c_lflag |
483 | &= ~(ECHO /* disable echo input characters */ | 478 | &= ~(ECHO /* disable echo input characters */ |
484 | | ECHONL /* disable echo new line */ | 479 | | ECHONL /* disable echo new line */ |
485 | | ICANON /* disable erase, kill, werase, and rprnt special characters */ | 480 | | ICANON /* disable erase, kill, werase, and rprnt special characters */ |
486 | | ISIG /* disable interrupt, quit, and suspend special characters */ | 481 | | ISIG /* disable interrupt, quit, and suspend special characters */ |
487 | | IEXTEN); /* disable non-POSIX special characters */ | 482 | | IEXTEN); /* disable non-POSIX special characters */ |
488 | 483 | ||
489 | port->tty->termios->c_cflag | 484 | termios->c_cflag |
490 | &= ~(CSIZE /* no size */ | 485 | &= ~(CSIZE /* no size */ |
491 | | PARENB /* disable parity bit */ | 486 | | PARENB /* disable parity bit */ |
492 | | CBAUD); /* clear current baud rate */ | 487 | | CBAUD); /* clear current baud rate */ |
493 | 488 | ||
494 | port->tty->termios->c_cflag | 489 | termios->c_cflag |
495 | |= (CS8 /* character size 8 bits */ | 490 | |= CS8; /* character size 8 bits */ |
496 | | B115200); /* baud rate 115200 */ | ||
497 | 491 | ||
498 | /* | 492 | /* |
499 | * Force low_latency on; otherwise the pushes are scheduled; | 493 | * Force low_latency on; otherwise the pushes are scheduled; |
@@ -501,8 +495,7 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol | |||
501 | * on the floor. We don't want to drop bytes on the floor. :) | 495 | * on the floor. We don't want to drop bytes on the floor. :) |
502 | */ | 496 | */ |
503 | port->tty->low_latency = 1; | 497 | port->tty->low_latency = 1; |
504 | 498 | tty_encode_baud_rate(port->tty, 115200, 115200); | |
505 | return; | ||
506 | } | 499 | } |
507 | 500 | ||
508 | 501 | ||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 8a8a6b9fb05b..c40e77dccf8e 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -294,7 +294,7 @@ struct ftdi_private { | |||
294 | 294 | ||
295 | __u16 interface; /* FT2232C port interface (0 for FT232/245) */ | 295 | __u16 interface; /* FT2232C port interface (0 for FT232/245) */ |
296 | 296 | ||
297 | int force_baud; /* if non-zero, force the baud rate to this value */ | 297 | speed_t force_baud; /* if non-zero, force the baud rate to this value */ |
298 | int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ | 298 | int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ |
299 | 299 | ||
300 | spinlock_t tx_lock; /* spinlock for transmit state */ | 300 | spinlock_t tx_lock; /* spinlock for transmit state */ |
@@ -878,6 +878,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
878 | if (div_value == 0) { | 878 | if (div_value == 0) { |
879 | dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); | 879 | dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); |
880 | div_value = ftdi_sio_b9600; | 880 | div_value = ftdi_sio_b9600; |
881 | baud = 9600; | ||
881 | div_okay = 0; | 882 | div_okay = 0; |
882 | } | 883 | } |
883 | break; | 884 | break; |
@@ -886,6 +887,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
886 | div_value = ftdi_232am_baud_to_divisor(baud); | 887 | div_value = ftdi_232am_baud_to_divisor(baud); |
887 | } else { | 888 | } else { |
888 | dbg("%s - Baud rate too high!", __FUNCTION__); | 889 | dbg("%s - Baud rate too high!", __FUNCTION__); |
890 | baud = 9600; | ||
889 | div_value = ftdi_232am_baud_to_divisor(9600); | 891 | div_value = ftdi_232am_baud_to_divisor(9600); |
890 | div_okay = 0; | 892 | div_okay = 0; |
891 | } | 893 | } |
@@ -899,6 +901,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
899 | dbg("%s - Baud rate too high!", __FUNCTION__); | 901 | dbg("%s - Baud rate too high!", __FUNCTION__); |
900 | div_value = ftdi_232bm_baud_to_divisor(9600); | 902 | div_value = ftdi_232bm_baud_to_divisor(9600); |
901 | div_okay = 0; | 903 | div_okay = 0; |
904 | baud = 9600; | ||
902 | } | 905 | } |
903 | break; | 906 | break; |
904 | } /* priv->chip_type */ | 907 | } /* priv->chip_type */ |
@@ -909,6 +912,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
909 | ftdi_chip_name[priv->chip_type]); | 912 | ftdi_chip_name[priv->chip_type]); |
910 | } | 913 | } |
911 | 914 | ||
915 | tty_encode_baud_rate(port->tty, baud, baud); | ||
912 | return(div_value); | 916 | return(div_value); |
913 | } | 917 | } |
914 | 918 | ||
@@ -1263,7 +1267,7 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) | |||
1263 | 1267 | ||
1264 | priv->flags |= ASYNC_SPD_CUST; | 1268 | priv->flags |= ASYNC_SPD_CUST; |
1265 | priv->custom_divisor = 77; | 1269 | priv->custom_divisor = 77; |
1266 | priv->force_baud = B38400; | 1270 | priv->force_baud = 38400; |
1267 | } /* ftdi_USB_UIRT_setup */ | 1271 | } /* ftdi_USB_UIRT_setup */ |
1268 | 1272 | ||
1269 | /* Setup for the HE-TIRA1 device, which requires hardwired | 1273 | /* Setup for the HE-TIRA1 device, which requires hardwired |
@@ -1274,7 +1278,7 @@ static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) | |||
1274 | 1278 | ||
1275 | priv->flags |= ASYNC_SPD_CUST; | 1279 | priv->flags |= ASYNC_SPD_CUST; |
1276 | priv->custom_divisor = 240; | 1280 | priv->custom_divisor = 240; |
1277 | priv->force_baud = B38400; | 1281 | priv->force_baud = 38400; |
1278 | priv->force_rtscts = 1; | 1282 | priv->force_rtscts = 1; |
1279 | } /* ftdi_HE_TIRA1_setup */ | 1283 | } /* ftdi_HE_TIRA1_setup */ |
1280 | 1284 | ||
@@ -1363,7 +1367,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) | |||
1363 | 1367 | ||
1364 | /* ftdi_set_termios will send usb control messages */ | 1368 | /* ftdi_set_termios will send usb control messages */ |
1365 | if (port->tty) | 1369 | if (port->tty) |
1366 | ftdi_set_termios(port, NULL); | 1370 | ftdi_set_termios(port, port->tty->termios); |
1367 | 1371 | ||
1368 | /* FIXME: Flow control might be enabled, so it should be checked - | 1372 | /* FIXME: Flow control might be enabled, so it should be checked - |
1369 | we have no control of defaults! */ | 1373 | we have no control of defaults! */ |
@@ -1933,32 +1937,33 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) | |||
1933 | static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 1937 | static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) |
1934 | { /* ftdi_termios */ | 1938 | { /* ftdi_termios */ |
1935 | struct usb_device *dev = port->serial->dev; | 1939 | struct usb_device *dev = port->serial->dev; |
1936 | unsigned int cflag = port->tty->termios->c_cflag; | ||
1937 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1940 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1941 | struct ktermios *termios = port->tty->termios; | ||
1942 | unsigned int cflag = termios->c_cflag; | ||
1938 | __u16 urb_value; /* will hold the new flags */ | 1943 | __u16 urb_value; /* will hold the new flags */ |
1939 | char buf[1]; /* Perhaps I should dynamically alloc this? */ | 1944 | char buf[1]; /* Perhaps I should dynamically alloc this? */ |
1940 | 1945 | ||
1941 | // Added for xon/xoff support | 1946 | // Added for xon/xoff support |
1942 | unsigned int iflag = port->tty->termios->c_iflag; | 1947 | unsigned int iflag = termios->c_iflag; |
1943 | unsigned char vstop; | 1948 | unsigned char vstop; |
1944 | unsigned char vstart; | 1949 | unsigned char vstart; |
1945 | 1950 | ||
1946 | dbg("%s", __FUNCTION__); | 1951 | dbg("%s", __FUNCTION__); |
1947 | 1952 | ||
1948 | /* Force baud rate if this device requires it, unless it is set to B0. */ | 1953 | /* Force baud rate if this device requires it, unless it is set to B0. */ |
1949 | if (priv->force_baud && ((port->tty->termios->c_cflag & CBAUD) != B0)) { | 1954 | if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { |
1950 | dbg("%s: forcing baud rate for this device", __FUNCTION__); | 1955 | dbg("%s: forcing baud rate for this device", __FUNCTION__); |
1951 | port->tty->termios->c_cflag &= ~CBAUD; | 1956 | tty_encode_baud_rate(port->tty, priv->force_baud, |
1952 | port->tty->termios->c_cflag |= priv->force_baud; | 1957 | priv->force_baud); |
1953 | } | 1958 | } |
1954 | 1959 | ||
1955 | /* Force RTS-CTS if this device requires it. */ | 1960 | /* Force RTS-CTS if this device requires it. */ |
1956 | if (priv->force_rtscts) { | 1961 | if (priv->force_rtscts) { |
1957 | dbg("%s: forcing rtscts for this device", __FUNCTION__); | 1962 | dbg("%s: forcing rtscts for this device", __FUNCTION__); |
1958 | port->tty->termios->c_cflag |= CRTSCTS; | 1963 | termios->c_cflag |= CRTSCTS; |
1959 | } | 1964 | } |
1960 | 1965 | ||
1961 | cflag = port->tty->termios->c_cflag; | 1966 | cflag = termios->c_cflag; |
1962 | 1967 | ||
1963 | /* FIXME -For this cut I don't care if the line is really changing or | 1968 | /* FIXME -For this cut I don't care if the line is really changing or |
1964 | not - so just do the change regardless - should be able to | 1969 | not - so just do the change regardless - should be able to |
@@ -1969,6 +1974,8 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
1969 | 1974 | ||
1970 | /* Set number of data bits, parity, stop bits */ | 1975 | /* Set number of data bits, parity, stop bits */ |
1971 | 1976 | ||
1977 | termios->c_cflag &= ~CMSPAR; | ||
1978 | |||
1972 | urb_value = 0; | 1979 | urb_value = 0; |
1973 | urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : | 1980 | urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : |
1974 | FTDI_SIO_SET_DATA_STOP_BITS_1); | 1981 | FTDI_SIO_SET_DATA_STOP_BITS_1); |
@@ -2048,8 +2055,8 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
2048 | // Set the vstart and vstop -- could have been done up above where | 2055 | // Set the vstart and vstop -- could have been done up above where |
2049 | // a lot of other dereferencing is done but that would be very | 2056 | // a lot of other dereferencing is done but that would be very |
2050 | // inefficient as vstart and vstop are not always needed | 2057 | // inefficient as vstart and vstop are not always needed |
2051 | vstart=port->tty->termios->c_cc[VSTART]; | 2058 | vstart = termios->c_cc[VSTART]; |
2052 | vstop=port->tty->termios->c_cc[VSTOP]; | 2059 | vstop = termios->c_cc[VSTOP]; |
2053 | urb_value=(vstop << 8) | (vstart); | 2060 | urb_value=(vstop << 8) | (vstart); |
2054 | 2061 | ||
2055 | if (usb_control_msg(dev, | 2062 | if (usb_control_msg(dev, |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 88a2c7dce335..9eb4a65ee4d9 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -208,14 +208,15 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * | |||
208 | 208 | ||
209 | /* only do something if we have a bulk out endpoint */ | 209 | /* only do something if we have a bulk out endpoint */ |
210 | if (serial->num_bulk_out) { | 210 | if (serial->num_bulk_out) { |
211 | spin_lock_bh(&port->lock); | 211 | unsigned long flags; |
212 | spin_lock_irqsave(&port->lock, flags); | ||
212 | if (port->write_urb_busy) { | 213 | if (port->write_urb_busy) { |
213 | spin_unlock_bh(&port->lock); | 214 | spin_unlock_irqrestore(&port->lock, flags); |
214 | dbg("%s - already writing", __FUNCTION__); | 215 | dbg("%s - already writing", __FUNCTION__); |
215 | return 0; | 216 | return 0; |
216 | } | 217 | } |
217 | port->write_urb_busy = 1; | 218 | port->write_urb_busy = 1; |
218 | spin_unlock_bh(&port->lock); | 219 | spin_unlock_irqrestore(&port->lock, flags); |
219 | 220 | ||
220 | count = (count > port->bulk_out_size) ? port->bulk_out_size : count; | 221 | count = (count > port->bulk_out_size) ? port->bulk_out_size : count; |
221 | 222 | ||
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 8dd3abc99d63..a5d2e115e167 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -1503,22 +1503,16 @@ static void edge_unthrottle (struct usb_serial_port *port) | |||
1503 | *****************************************************************************/ | 1503 | *****************************************************************************/ |
1504 | static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 1504 | static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) |
1505 | { | 1505 | { |
1506 | /* FIXME: This function appears unused ?? */ | ||
1506 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 1507 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
1507 | struct tty_struct *tty = port->tty; | 1508 | struct tty_struct *tty = port->tty; |
1508 | unsigned int cflag; | 1509 | unsigned int cflag; |
1509 | 1510 | ||
1510 | if (!port->tty || !port->tty->termios) { | ||
1511 | dbg ("%s - no tty or termios", __FUNCTION__); | ||
1512 | return; | ||
1513 | } | ||
1514 | |||
1515 | cflag = tty->termios->c_cflag; | 1511 | cflag = tty->termios->c_cflag; |
1516 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, | 1512 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, |
1517 | tty->termios->c_cflag, tty->termios->c_iflag); | 1513 | tty->termios->c_cflag, tty->termios->c_iflag); |
1518 | if (old_termios) { | 1514 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, |
1519 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, | 1515 | old_termios->c_cflag, old_termios->c_iflag); |
1520 | old_termios->c_cflag, old_termios->c_iflag); | ||
1521 | } | ||
1522 | 1516 | ||
1523 | dbg("%s - port %d", __FUNCTION__, port->number); | 1517 | dbg("%s - port %d", __FUNCTION__, port->number); |
1524 | 1518 | ||
@@ -2653,7 +2647,11 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi | |||
2653 | 2647 | ||
2654 | dbg("%s - baud rate = %d", __FUNCTION__, baud); | 2648 | dbg("%s - baud rate = %d", __FUNCTION__, baud); |
2655 | status = send_cmd_write_baud_rate (edge_port, baud); | 2649 | status = send_cmd_write_baud_rate (edge_port, baud); |
2656 | 2650 | if (status == -1) { | |
2651 | /* Speed change was not possible - put back the old speed */ | ||
2652 | baud = tty_termios_baud_rate(old_termios); | ||
2653 | tty_encode_baud_rate(tty, baud, baud); | ||
2654 | } | ||
2657 | return; | 2655 | return; |
2658 | } | 2656 | } |
2659 | 2657 | ||
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 5ab6a0c5ac52..6b803ab98543 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
@@ -504,11 +504,6 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t | |||
504 | 504 | ||
505 | dbg("%s - port %d", __FUNCTION__, port->number); | 505 | dbg("%s - port %d", __FUNCTION__, port->number); |
506 | 506 | ||
507 | if ((!port->tty) || (!port->tty->termios)) { | ||
508 | dbg("%s - no tty structures", __FUNCTION__); | ||
509 | return; | ||
510 | } | ||
511 | |||
512 | baud = tty_get_baud_rate(port->tty); | 507 | baud = tty_get_baud_rate(port->tty); |
513 | 508 | ||
514 | /* | 509 | /* |
@@ -531,8 +526,6 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t | |||
531 | default: | 526 | default: |
532 | ir_baud = SPEED_9600; | 527 | ir_baud = SPEED_9600; |
533 | baud = 9600; | 528 | baud = 9600; |
534 | /* And once the new tty stuff is all done we need to | ||
535 | call back to correct the baud bits */ | ||
536 | } | 529 | } |
537 | 530 | ||
538 | if (xbof == -1) | 531 | if (xbof == -1) |
@@ -562,6 +555,10 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t | |||
562 | result = usb_submit_urb (port->write_urb, GFP_KERNEL); | 555 | result = usb_submit_urb (port->write_urb, GFP_KERNEL); |
563 | if (result) | 556 | if (result) |
564 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); | 557 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); |
558 | |||
559 | /* Only speed changes are supported */ | ||
560 | tty_termios_copy_hw(port->tty->termios, old_termios); | ||
561 | tty_encode_baud_rate(port->tty, baud, baud); | ||
565 | } | 562 | } |
566 | 563 | ||
567 | 564 | ||
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index f2a6fce5de1e..6bfdba6a213f 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -278,29 +278,35 @@ static void keyspan_set_termios (struct usb_serial_port *port, | |||
278 | struct keyspan_port_private *p_priv; | 278 | struct keyspan_port_private *p_priv; |
279 | const struct keyspan_device_details *d_details; | 279 | const struct keyspan_device_details *d_details; |
280 | unsigned int cflag; | 280 | unsigned int cflag; |
281 | struct tty_struct *tty = port->tty; | ||
281 | 282 | ||
282 | dbg("%s", __FUNCTION__); | 283 | dbg("%s", __FUNCTION__); |
283 | 284 | ||
284 | p_priv = usb_get_serial_port_data(port); | 285 | p_priv = usb_get_serial_port_data(port); |
285 | d_details = p_priv->device_details; | 286 | d_details = p_priv->device_details; |
286 | cflag = port->tty->termios->c_cflag; | 287 | cflag = tty->termios->c_cflag; |
287 | device_port = port->number - port->serial->minor; | 288 | device_port = port->number - port->serial->minor; |
288 | 289 | ||
289 | /* Baud rate calculation takes baud rate as an integer | 290 | /* Baud rate calculation takes baud rate as an integer |
290 | so other rates can be generated if desired. */ | 291 | so other rates can be generated if desired. */ |
291 | baud_rate = tty_get_baud_rate(port->tty); | 292 | baud_rate = tty_get_baud_rate(tty); |
292 | /* If no match or invalid, don't change */ | 293 | /* If no match or invalid, don't change */ |
293 | if (baud_rate >= 0 | 294 | if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk, |
294 | && d_details->calculate_baud_rate(baud_rate, d_details->baudclk, | ||
295 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { | 295 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { |
296 | /* FIXME - more to do here to ensure rate changes cleanly */ | 296 | /* FIXME - more to do here to ensure rate changes cleanly */ |
297 | /* FIXME - calcuate exact rate from divisor ? */ | ||
297 | p_priv->baud = baud_rate; | 298 | p_priv->baud = baud_rate; |
298 | } | 299 | } else |
300 | baud_rate = tty_termios_baud_rate(old_termios); | ||
299 | 301 | ||
302 | tty_encode_baud_rate(tty, baud_rate, baud_rate); | ||
300 | /* set CTS/RTS handshake etc. */ | 303 | /* set CTS/RTS handshake etc. */ |
301 | p_priv->cflag = cflag; | 304 | p_priv->cflag = cflag; |
302 | p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; | 305 | p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; |
303 | 306 | ||
307 | /* Mark/Space not supported */ | ||
308 | tty->termios->c_cflag &= ~CMSPAR; | ||
309 | |||
304 | keyspan_send_setup(port, 0); | 310 | keyspan_send_setup(port, 0); |
305 | } | 311 | } |
306 | 312 | ||
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 6f224195bd25..aee450246bfd 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -616,8 +616,9 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old | |||
616 | case 1200: | 616 | case 1200: |
617 | urb_val = SUSBCR_SBR_1200; | 617 | urb_val = SUSBCR_SBR_1200; |
618 | break; | 618 | break; |
619 | case 9600: | ||
620 | default: | 619 | default: |
620 | speed = 9600; | ||
621 | case 9600: | ||
621 | urb_val = SUSBCR_SBR_9600; | 622 | urb_val = SUSBCR_SBR_9600; |
622 | break; | 623 | break; |
623 | } | 624 | } |
@@ -641,6 +642,8 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old | |||
641 | urb_val |= SUSBCR_SPASB_NoParity; | 642 | urb_val |= SUSBCR_SPASB_NoParity; |
642 | strcat(settings, "No Parity"); | 643 | strcat(settings, "No Parity"); |
643 | } | 644 | } |
645 | port->tty->termios->c_cflag &= ~CMSPAR; | ||
646 | tty_encode_baud_rate(port->tty, speed, speed); | ||
644 | 647 | ||
645 | result = usb_control_msg( port->serial->dev, | 648 | result = usb_control_msg( port->serial->dev, |
646 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 649 | usb_rcvctrlpipe(port->serial->dev, 0 ), |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index f76480f1455d..a5ced7e08cbf 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -1977,11 +1977,6 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port, | |||
1977 | 1977 | ||
1978 | tty = mos7840_port->port->tty; | 1978 | tty = mos7840_port->port->tty; |
1979 | 1979 | ||
1980 | if ((!tty) || (!tty->termios)) { | ||
1981 | dbg("%s - no tty structures", __FUNCTION__); | ||
1982 | return; | ||
1983 | } | ||
1984 | |||
1985 | dbg("%s", "Entering .......... \n"); | 1980 | dbg("%s", "Entering .......... \n"); |
1986 | 1981 | ||
1987 | lData = LCR_BITS_8; | 1982 | lData = LCR_BITS_8; |
@@ -2151,11 +2146,6 @@ static void mos7840_set_termios(struct usb_serial_port *port, | |||
2151 | 2146 | ||
2152 | tty = port->tty; | 2147 | tty = port->tty; |
2153 | 2148 | ||
2154 | if (!port->tty || !port->tty->termios) { | ||
2155 | dbg("%s - no tty or termios", __FUNCTION__); | ||
2156 | return; | ||
2157 | } | ||
2158 | |||
2159 | if (!mos7840_port->open) { | 2149 | if (!mos7840_port->open) { |
2160 | dbg("%s - port not opened", __FUNCTION__); | 2150 | dbg("%s - port not opened", __FUNCTION__); |
2161 | return; | 2151 | return; |
@@ -2165,19 +2155,10 @@ static void mos7840_set_termios(struct usb_serial_port *port, | |||
2165 | 2155 | ||
2166 | cflag = tty->termios->c_cflag; | 2156 | cflag = tty->termios->c_cflag; |
2167 | 2157 | ||
2168 | if (!cflag) { | ||
2169 | dbg("%s %s\n", __FUNCTION__, "cflag is NULL"); | ||
2170 | return; | ||
2171 | } | ||
2172 | |||
2173 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, | 2158 | dbg("%s - clfag %08x iflag %08x", __FUNCTION__, |
2174 | tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); | 2159 | tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); |
2175 | 2160 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, | |
2176 | if (old_termios) { | 2161 | old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); |
2177 | dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, | ||
2178 | old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); | ||
2179 | } | ||
2180 | |||
2181 | dbg("%s - port %d", __FUNCTION__, port->number); | 2162 | dbg("%s - port %d", __FUNCTION__, port->number); |
2182 | 2163 | ||
2183 | /* change the port settings to the new ones specified */ | 2164 | /* change the port settings to the new ones specified */ |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index a18659e0700c..4590124cf888 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -172,6 +172,8 @@ static struct usb_device_id option_ids[] = { | |||
172 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */ | 172 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */ |
173 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ | 173 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ |
174 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ | 174 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ |
175 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4100) }, /* Novatel U727 */ | ||
176 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4400) }, /* Novatel MC950 */ | ||
175 | { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ | 177 | { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ |
176 | { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ | 178 | { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ |
177 | { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ | 179 | { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ |
@@ -311,7 +313,8 @@ static void option_set_termios(struct usb_serial_port *port, | |||
311 | struct ktermios *old_termios) | 313 | struct ktermios *old_termios) |
312 | { | 314 | { |
313 | dbg("%s", __FUNCTION__); | 315 | dbg("%s", __FUNCTION__); |
314 | 316 | /* Doesn't support option setting */ | |
317 | tty_termios_copy_hw(port->tty->termios, old_termios); | ||
315 | option_send_setup(port); | 318 | option_send_setup(port); |
316 | } | 319 | } |
317 | 320 | ||
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 1da57fd9ea23..2cd3f1d4b687 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -56,6 +56,7 @@ static struct usb_device_id id_table [] = { | |||
56 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, | 56 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, |
57 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, | 57 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, |
58 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, | 58 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, |
59 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, | ||
59 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, | 60 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, |
60 | { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, | 61 | { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, |
61 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, | 62 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, |
@@ -470,16 +471,13 @@ static void pl2303_set_termios(struct usb_serial_port *port, | |||
470 | 471 | ||
471 | dbg("%s - port %d", __FUNCTION__, port->number); | 472 | dbg("%s - port %d", __FUNCTION__, port->number); |
472 | 473 | ||
473 | if ((!port->tty) || (!port->tty->termios)) { | ||
474 | dbg("%s - no tty structures", __FUNCTION__); | ||
475 | return; | ||
476 | } | ||
477 | |||
478 | spin_lock_irqsave(&priv->lock, flags); | 474 | spin_lock_irqsave(&priv->lock, flags); |
479 | if (!priv->termios_initialized) { | 475 | if (!priv->termios_initialized) { |
480 | *(port->tty->termios) = tty_std_termios; | 476 | *(port->tty->termios) = tty_std_termios; |
481 | port->tty->termios->c_cflag = B9600 | CS8 | CREAD | | 477 | port->tty->termios->c_cflag = B9600 | CS8 | CREAD | |
482 | HUPCL | CLOCAL; | 478 | HUPCL | CLOCAL; |
479 | port->tty->termios->c_ispeed = 9600; | ||
480 | port->tty->termios->c_ospeed = 9600; | ||
483 | priv->termios_initialized = 1; | 481 | priv->termios_initialized = 1; |
484 | } | 482 | } |
485 | spin_unlock_irqrestore(&priv->lock, flags); | 483 | spin_unlock_irqrestore(&priv->lock, flags); |
@@ -596,6 +594,10 @@ static void pl2303_set_termios(struct usb_serial_port *port, | |||
596 | dbg ("0x40:0x1:0x0:0x0 %d", i); | 594 | dbg ("0x40:0x1:0x0:0x0 %d", i); |
597 | } | 595 | } |
598 | 596 | ||
597 | /* FIXME: Need to read back resulting baud rate */ | ||
598 | if (baud) | ||
599 | tty_encode_baud_rate(port->tty, baud, baud); | ||
600 | |||
599 | kfree(buf); | 601 | kfree(buf); |
600 | } | 602 | } |
601 | 603 | ||
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index c39bace5cbcc..ed603e3decd6 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #define IODATA_VENDOR_ID 0x04bb | 21 | #define IODATA_VENDOR_ID 0x04bb |
22 | #define IODATA_PRODUCT_ID 0x0a03 | 22 | #define IODATA_PRODUCT_ID 0x0a03 |
23 | #define IODATA_PRODUCT_ID_RSAQ5 0x0a0e | ||
23 | 24 | ||
24 | #define ELCOM_VENDOR_ID 0x056e | 25 | #define ELCOM_VENDOR_ID 0x056e |
25 | #define ELCOM_PRODUCT_ID 0x5003 | 26 | #define ELCOM_PRODUCT_ID 0x5003 |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 959b3e4e9077..833f6e1e3721 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -224,7 +224,7 @@ static void sierra_set_termios(struct usb_serial_port *port, | |||
224 | struct ktermios *old_termios) | 224 | struct ktermios *old_termios) |
225 | { | 225 | { |
226 | dbg("%s", __FUNCTION__); | 226 | dbg("%s", __FUNCTION__); |
227 | 227 | tty_termios_copy_hw(port->tty->termios, old_termios); | |
228 | sierra_send_setup(port); | 228 | sierra_send_setup(port); |
229 | } | 229 | } |
230 | 230 | ||
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 4b1bd7def4a5..497e29a700ca 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -429,6 +429,8 @@ static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) | |||
429 | /* pass on to the driver specific version of this function if it is available */ | 429 | /* pass on to the driver specific version of this function if it is available */ |
430 | if (port->serial->type->set_termios) | 430 | if (port->serial->type->set_termios) |
431 | port->serial->type->set_termios(port, old); | 431 | port->serial->type->set_termios(port, old); |
432 | else | ||
433 | tty_termios_copy_hw(tty->termios, old); | ||
432 | } | 434 | } |
433 | 435 | ||
434 | static void serial_break (struct tty_struct *tty, int break_state) | 436 | static void serial_break (struct tty_struct *tty, int break_state) |
@@ -1121,7 +1123,9 @@ int usb_serial_resume(struct usb_interface *intf) | |||
1121 | { | 1123 | { |
1122 | struct usb_serial *serial = usb_get_intfdata(intf); | 1124 | struct usb_serial *serial = usb_get_intfdata(intf); |
1123 | 1125 | ||
1124 | return serial->type->resume(serial); | 1126 | if (serial->type->resume) |
1127 | return serial->type->resume(serial); | ||
1128 | return 0; | ||
1125 | } | 1129 | } |
1126 | EXPORT_SYMBOL(usb_serial_resume); | 1130 | EXPORT_SYMBOL(usb_serial_resume); |
1127 | 1131 | ||
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index cc8b44c08712..ee5dd8b5a713 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -885,16 +885,7 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un | |||
885 | static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) | 885 | static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) |
886 | { | 886 | { |
887 | dbg("%s -port %d", __FUNCTION__, port->number); | 887 | dbg("%s -port %d", __FUNCTION__, port->number); |
888 | |||
889 | if ((!port->tty) || (!port->tty->termios)) { | ||
890 | dbg("%s - no tty structures", __FUNCTION__); | ||
891 | goto exit; | ||
892 | } | ||
893 | |||
894 | firm_setup_port(port); | 888 | firm_setup_port(port); |
895 | |||
896 | exit: | ||
897 | return; | ||
898 | } | 889 | } |
899 | 890 | ||
900 | 891 | ||
@@ -1244,6 +1235,8 @@ static int firm_setup_port(struct usb_serial_port *port) { | |||
1244 | port_settings.baud = tty_get_baud_rate(port->tty); | 1235 | port_settings.baud = tty_get_baud_rate(port->tty); |
1245 | dbg("%s - baud rate = %d", __FUNCTION__, port_settings.baud); | 1236 | dbg("%s - baud rate = %d", __FUNCTION__, port_settings.baud); |
1246 | 1237 | ||
1238 | /* fixme: should set validated settings */ | ||
1239 | tty_encode_baud_rate(port->tty, port_settings.baud, port_settings.baud); | ||
1247 | /* handle any settings that aren't specified in the tty structure */ | 1240 | /* handle any settings that aren't specified in the tty structure */ |
1248 | port_settings.lloop = 0; | 1241 | port_settings.lloop = 0; |
1249 | 1242 | ||
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index fe2c4cd53f5a..7e53333be013 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig | |||
@@ -48,7 +48,6 @@ config USB_STORAGE_FREECOM | |||
48 | config USB_STORAGE_ISD200 | 48 | config USB_STORAGE_ISD200 |
49 | bool "ISD-200 USB/ATA Bridge support" | 49 | bool "ISD-200 USB/ATA Bridge support" |
50 | depends on USB_STORAGE | 50 | depends on USB_STORAGE |
51 | depends on BLK_DEV_IDE=y || BLK_DEV_IDE=USB_STORAGE | ||
52 | ---help--- | 51 | ---help--- |
53 | Say Y here if you want to use USB Mass Store devices based | 52 | Say Y here if you want to use USB Mass Store devices based |
54 | on the In-Systems Design ISD-200 USB/ATA bridge. | 53 | on the In-Systems Design ISD-200 USB/ATA bridge. |
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index 93a7724e167a..49ba6c0ff1e8 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c | |||
@@ -977,6 +977,109 @@ static int isd200_manual_enum(struct us_data *us) | |||
977 | return(retStatus); | 977 | return(retStatus); |
978 | } | 978 | } |
979 | 979 | ||
980 | /* | ||
981 | * We are the last non IDE user of the legacy IDE ident structures | ||
982 | * and we thus want to keep a private copy of this function so the | ||
983 | * driver can be used without the obsolete drivers/ide layer | ||
984 | */ | ||
985 | |||
986 | static void isd200_fix_driveid (struct hd_driveid *id) | ||
987 | { | ||
988 | #ifndef __LITTLE_ENDIAN | ||
989 | # ifdef __BIG_ENDIAN | ||
990 | int i; | ||
991 | u16 *stringcast; | ||
992 | |||
993 | id->config = __le16_to_cpu(id->config); | ||
994 | id->cyls = __le16_to_cpu(id->cyls); | ||
995 | id->reserved2 = __le16_to_cpu(id->reserved2); | ||
996 | id->heads = __le16_to_cpu(id->heads); | ||
997 | id->track_bytes = __le16_to_cpu(id->track_bytes); | ||
998 | id->sector_bytes = __le16_to_cpu(id->sector_bytes); | ||
999 | id->sectors = __le16_to_cpu(id->sectors); | ||
1000 | id->vendor0 = __le16_to_cpu(id->vendor0); | ||
1001 | id->vendor1 = __le16_to_cpu(id->vendor1); | ||
1002 | id->vendor2 = __le16_to_cpu(id->vendor2); | ||
1003 | stringcast = (u16 *)&id->serial_no[0]; | ||
1004 | for (i = 0; i < (20/2); i++) | ||
1005 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
1006 | id->buf_type = __le16_to_cpu(id->buf_type); | ||
1007 | id->buf_size = __le16_to_cpu(id->buf_size); | ||
1008 | id->ecc_bytes = __le16_to_cpu(id->ecc_bytes); | ||
1009 | stringcast = (u16 *)&id->fw_rev[0]; | ||
1010 | for (i = 0; i < (8/2); i++) | ||
1011 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
1012 | stringcast = (u16 *)&id->model[0]; | ||
1013 | for (i = 0; i < (40/2); i++) | ||
1014 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
1015 | id->dword_io = __le16_to_cpu(id->dword_io); | ||
1016 | id->reserved50 = __le16_to_cpu(id->reserved50); | ||
1017 | id->field_valid = __le16_to_cpu(id->field_valid); | ||
1018 | id->cur_cyls = __le16_to_cpu(id->cur_cyls); | ||
1019 | id->cur_heads = __le16_to_cpu(id->cur_heads); | ||
1020 | id->cur_sectors = __le16_to_cpu(id->cur_sectors); | ||
1021 | id->cur_capacity0 = __le16_to_cpu(id->cur_capacity0); | ||
1022 | id->cur_capacity1 = __le16_to_cpu(id->cur_capacity1); | ||
1023 | id->lba_capacity = __le32_to_cpu(id->lba_capacity); | ||
1024 | id->dma_1word = __le16_to_cpu(id->dma_1word); | ||
1025 | id->dma_mword = __le16_to_cpu(id->dma_mword); | ||
1026 | id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes); | ||
1027 | id->eide_dma_min = __le16_to_cpu(id->eide_dma_min); | ||
1028 | id->eide_dma_time = __le16_to_cpu(id->eide_dma_time); | ||
1029 | id->eide_pio = __le16_to_cpu(id->eide_pio); | ||
1030 | id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy); | ||
1031 | for (i = 0; i < 2; ++i) | ||
1032 | id->words69_70[i] = __le16_to_cpu(id->words69_70[i]); | ||
1033 | for (i = 0; i < 4; ++i) | ||
1034 | id->words71_74[i] = __le16_to_cpu(id->words71_74[i]); | ||
1035 | id->queue_depth = __le16_to_cpu(id->queue_depth); | ||
1036 | for (i = 0; i < 4; ++i) | ||
1037 | id->words76_79[i] = __le16_to_cpu(id->words76_79[i]); | ||
1038 | id->major_rev_num = __le16_to_cpu(id->major_rev_num); | ||
1039 | id->minor_rev_num = __le16_to_cpu(id->minor_rev_num); | ||
1040 | id->command_set_1 = __le16_to_cpu(id->command_set_1); | ||
1041 | id->command_set_2 = __le16_to_cpu(id->command_set_2); | ||
1042 | id->cfsse = __le16_to_cpu(id->cfsse); | ||
1043 | id->cfs_enable_1 = __le16_to_cpu(id->cfs_enable_1); | ||
1044 | id->cfs_enable_2 = __le16_to_cpu(id->cfs_enable_2); | ||
1045 | id->csf_default = __le16_to_cpu(id->csf_default); | ||
1046 | id->dma_ultra = __le16_to_cpu(id->dma_ultra); | ||
1047 | id->trseuc = __le16_to_cpu(id->trseuc); | ||
1048 | id->trsEuc = __le16_to_cpu(id->trsEuc); | ||
1049 | id->CurAPMvalues = __le16_to_cpu(id->CurAPMvalues); | ||
1050 | id->mprc = __le16_to_cpu(id->mprc); | ||
1051 | id->hw_config = __le16_to_cpu(id->hw_config); | ||
1052 | id->acoustic = __le16_to_cpu(id->acoustic); | ||
1053 | id->msrqs = __le16_to_cpu(id->msrqs); | ||
1054 | id->sxfert = __le16_to_cpu(id->sxfert); | ||
1055 | id->sal = __le16_to_cpu(id->sal); | ||
1056 | id->spg = __le32_to_cpu(id->spg); | ||
1057 | id->lba_capacity_2 = __le64_to_cpu(id->lba_capacity_2); | ||
1058 | for (i = 0; i < 22; i++) | ||
1059 | id->words104_125[i] = __le16_to_cpu(id->words104_125[i]); | ||
1060 | id->last_lun = __le16_to_cpu(id->last_lun); | ||
1061 | id->word127 = __le16_to_cpu(id->word127); | ||
1062 | id->dlf = __le16_to_cpu(id->dlf); | ||
1063 | id->csfo = __le16_to_cpu(id->csfo); | ||
1064 | for (i = 0; i < 26; i++) | ||
1065 | id->words130_155[i] = __le16_to_cpu(id->words130_155[i]); | ||
1066 | id->word156 = __le16_to_cpu(id->word156); | ||
1067 | for (i = 0; i < 3; i++) | ||
1068 | id->words157_159[i] = __le16_to_cpu(id->words157_159[i]); | ||
1069 | id->cfa_power = __le16_to_cpu(id->cfa_power); | ||
1070 | for (i = 0; i < 14; i++) | ||
1071 | id->words161_175[i] = __le16_to_cpu(id->words161_175[i]); | ||
1072 | for (i = 0; i < 31; i++) | ||
1073 | id->words176_205[i] = __le16_to_cpu(id->words176_205[i]); | ||
1074 | for (i = 0; i < 48; i++) | ||
1075 | id->words206_254[i] = __le16_to_cpu(id->words206_254[i]); | ||
1076 | id->integrity_word = __le16_to_cpu(id->integrity_word); | ||
1077 | # else | ||
1078 | # error "Please fix <asm/byteorder.h>" | ||
1079 | # endif | ||
1080 | #endif | ||
1081 | } | ||
1082 | |||
980 | 1083 | ||
981 | /************************************************************************** | 1084 | /************************************************************************** |
982 | * isd200_get_inquiry_data | 1085 | * isd200_get_inquiry_data |
@@ -1018,7 +1121,7 @@ static int isd200_get_inquiry_data( struct us_data *us ) | |||
1018 | int i; | 1121 | int i; |
1019 | __be16 *src; | 1122 | __be16 *src; |
1020 | __u16 *dest; | 1123 | __u16 *dest; |
1021 | ide_fix_driveid(id); | 1124 | isd200_fix_driveid(id); |
1022 | 1125 | ||
1023 | US_DEBUGP(" Identify Data Structure:\n"); | 1126 | US_DEBUGP(" Identify Data Structure:\n"); |
1024 | US_DEBUGP(" config = 0x%x\n", id->config); | 1127 | US_DEBUGP(" config = 0x%x\n", id->config); |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index fb9d8d0b2c04..cc4b60f899ca 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -1509,7 +1509,7 @@ config FB_VOODOO1 | |||
1509 | 1509 | ||
1510 | WARNING: Do not use any application that uses the 3D engine | 1510 | WARNING: Do not use any application that uses the 3D engine |
1511 | (namely glide) while using this driver. | 1511 | (namely glide) while using this driver. |
1512 | Please read the <file:Documentation/fb/README-sstfb.txt> for supported | 1512 | Please read the <file:Documentation/fb/sstfb.txt> for supported |
1513 | options and other important info support. | 1513 | options and other important info support. |
1514 | 1514 | ||
1515 | config FB_VT8623 | 1515 | config FB_VT8623 |
@@ -1807,7 +1807,7 @@ config FB_SM501 | |||
1807 | This driver is also available as a module ( = code which can be | 1807 | This driver is also available as a module ( = code which can be |
1808 | inserted and removed from the running kernel whenever you want). The | 1808 | inserted and removed from the running kernel whenever you want). The |
1809 | module will be called sm501fb. If you want to compile it as a module, | 1809 | module will be called sm501fb. If you want to compile it as a module, |
1810 | say M here and read <file:Documentation/modules.txt>. | 1810 | say M here and read <file:Documentation/kbuild/modules.txt>. |
1811 | 1811 | ||
1812 | If unsure, say N. | 1812 | If unsure, say N. |
1813 | 1813 | ||
@@ -1892,9 +1892,7 @@ config FB_VIRTUAL | |||
1892 | 1892 | ||
1893 | If unsure, say N. | 1893 | If unsure, say N. |
1894 | 1894 | ||
1895 | if ARCH_OMAP | 1895 | source "drivers/video/omap/Kconfig" |
1896 | source "drivers/video/omap/Kconfig" | ||
1897 | endif | ||
1898 | 1896 | ||
1899 | source "drivers/video/backlight/Kconfig" | 1897 | source "drivers/video/backlight/Kconfig" |
1900 | source "drivers/video/display/Kconfig" | 1898 | source "drivers/video/display/Kconfig" |
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c index be1d57bf9dc8..83ee3e75386c 100644 --- a/drivers/video/aty/radeon_pm.c +++ b/drivers/video/aty/radeon_pm.c | |||
@@ -27,8 +27,6 @@ | |||
27 | 27 | ||
28 | #include "ati_ids.h" | 28 | #include "ati_ids.h" |
29 | 29 | ||
30 | static void radeon_reinitialize_M10(struct radeonfb_info *rinfo); | ||
31 | |||
32 | /* | 30 | /* |
33 | * Workarounds for bugs in PC laptops: | 31 | * Workarounds for bugs in PC laptops: |
34 | * - enable D2 sleep in some IBM Thinkpads | 32 | * - enable D2 sleep in some IBM Thinkpads |
@@ -39,6 +37,8 @@ static void radeon_reinitialize_M10(struct radeonfb_info *rinfo); | |||
39 | */ | 37 | */ |
40 | 38 | ||
41 | #if defined(CONFIG_PM) && defined(CONFIG_X86) | 39 | #if defined(CONFIG_PM) && defined(CONFIG_X86) |
40 | static void radeon_reinitialize_M10(struct radeonfb_info *rinfo); | ||
41 | |||
42 | struct radeon_device_id { | 42 | struct radeon_device_id { |
43 | const char *ident; /* (arbitrary) Name */ | 43 | const char *ident; /* (arbitrary) Name */ |
44 | const unsigned short subsystem_vendor; /* Subsystem Vendor ID */ | 44 | const unsigned short subsystem_vendor; /* Subsystem Vendor ID */ |
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c index f99cb77e7b42..f7e2d5add831 100644 --- a/drivers/video/cirrusfb.c +++ b/drivers/video/cirrusfb.c | |||
@@ -2509,8 +2509,7 @@ static int cirrusfb_zorro_register(struct zorro_dev *z, | |||
2509 | cinfo = info->par; | 2509 | cinfo = info->par; |
2510 | cinfo->btype = btype; | 2510 | cinfo->btype = btype; |
2511 | 2511 | ||
2512 | assert(z > 0); | 2512 | assert(z); |
2513 | assert(z2 >= 0); | ||
2514 | assert(btype != BT_NONE); | 2513 | assert(btype != BT_NONE); |
2515 | 2514 | ||
2516 | cinfo->zdev = z; | 2515 | cinfo->zdev = z; |
diff --git a/drivers/video/omap/Kconfig b/drivers/video/omap/Kconfig index f4fcf11b290d..44408850e2eb 100644 --- a/drivers/video/omap/Kconfig +++ b/drivers/video/omap/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config FB_OMAP | 1 | config FB_OMAP |
2 | tristate "OMAP frame buffer support (EXPERIMENTAL)" | 2 | tristate "OMAP frame buffer support (EXPERIMENTAL)" |
3 | depends on FB | 3 | depends on FB && ARCH_OMAP |
4 | select FB_CFB_FILLRECT | 4 | select FB_CFB_FILLRECT |
5 | select FB_CFB_COPYAREA | 5 | select FB_CFB_COPYAREA |
6 | select FB_CFB_IMAGEBLIT | 6 | select FB_CFB_IMAGEBLIT |
diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig index 6854fd6b9714..9adbb4f90479 100644 --- a/drivers/w1/Kconfig +++ b/drivers/w1/Kconfig | |||
@@ -17,7 +17,8 @@ config W1_CON | |||
17 | bool "Userspace communication over connector" | 17 | bool "Userspace communication over connector" |
18 | default y | 18 | default y |
19 | --- help --- | 19 | --- help --- |
20 | This allows to communicate with userspace using connector [Documentation/connector]. | 20 | This allows to communicate with userspace using connector. For more |
21 | information see <file:Documentation/connector/connector.txt>. | ||
21 | There are three types of messages between w1 core and userspace: | 22 | There are three types of messages between w1 core and userspace: |
22 | 1. Events. They are generated each time new master or slave device found | 23 | 1. Events. They are generated each time new master or slave device found |
23 | either due to automatic or requested search. | 24 | either due to automatic or requested search. |
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 81db48f07ca1..2792bc1a7269 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -15,8 +15,8 @@ menuconfig WATCHDOG | |||
15 | implementation entirely in software (which can sometimes fail to | 15 | implementation entirely in software (which can sometimes fail to |
16 | reboot the machine) and a driver for hardware watchdog boards, which | 16 | reboot the machine) and a driver for hardware watchdog boards, which |
17 | are more robust and can also keep track of the temperature inside | 17 | are more robust and can also keep track of the temperature inside |
18 | your computer. For details, read <file:Documentation/watchdog/watchdog.txt> | 18 | your computer. For details, read |
19 | in the kernel source. | 19 | <file:Documentation/watchdog/watchdog-api.txt> in the kernel source. |
20 | 20 | ||
21 | The watchdog is usually used together with the watchdog daemon | 21 | The watchdog is usually used together with the watchdog daemon |
22 | which is available from | 22 | which is available from |