diff options
Diffstat (limited to 'drivers')
579 files changed, 15865 insertions, 1506 deletions
diff --git a/drivers/acorn/block/mfmhd.c b/drivers/acorn/block/mfmhd.c index 7fde8f4daebf..689a4c3542ba 100644 --- a/drivers/acorn/block/mfmhd.c +++ b/drivers/acorn/block/mfmhd.c | |||
@@ -99,7 +99,6 @@ | |||
99 | */ | 99 | */ |
100 | 100 | ||
101 | #include <linux/module.h> | 101 | #include <linux/module.h> |
102 | #include <linux/sched.h> | ||
103 | #include <linux/fs.h> | 102 | #include <linux/fs.h> |
104 | #include <linux/interrupt.h> | 103 | #include <linux/interrupt.h> |
105 | #include <linux/kernel.h> | 104 | #include <linux/kernel.h> |
diff --git a/drivers/acorn/char/i2c.c b/drivers/acorn/char/i2c.c index 157d8b73bb64..d276fd14d63a 100644 --- a/drivers/acorn/char/i2c.c +++ b/drivers/acorn/char/i2c.c | |||
@@ -14,7 +14,6 @@ | |||
14 | */ | 14 | */ |
15 | #include <linux/capability.h> | 15 | #include <linux/capability.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/time.h> | 17 | #include <linux/time.h> |
19 | #include <linux/miscdevice.h> | 18 | #include <linux/miscdevice.h> |
20 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
diff --git a/drivers/acpi/i2c_ec.c b/drivers/acpi/i2c_ec.c index 8338be0990bc..76ec8b63e69f 100644 --- a/drivers/acpi/i2c_ec.c +++ b/drivers/acpi/i2c_ec.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/stddef.h> | 16 | #include <linux/stddef.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
19 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
20 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
@@ -340,6 +339,7 @@ static int acpi_ec_hc_add(struct acpi_device *device) | |||
340 | smbus->adapter.owner = THIS_MODULE; | 339 | smbus->adapter.owner = THIS_MODULE; |
341 | smbus->adapter.algo = &acpi_ec_smbus_algorithm; | 340 | smbus->adapter.algo = &acpi_ec_smbus_algorithm; |
342 | smbus->adapter.algo_data = smbus; | 341 | smbus->adapter.algo_data = smbus; |
342 | smbus->adapter.dev.parent = &device->dev; | ||
343 | 343 | ||
344 | if (i2c_add_adapter(&smbus->adapter)) { | 344 | if (i2c_add_adapter(&smbus->adapter)) { |
345 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 345 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c index 326af8fc0ce7..33db2241044e 100644 --- a/drivers/acpi/namespace/nsinit.c +++ b/drivers/acpi/namespace/nsinit.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <acpi/acnamesp.h> | 45 | #include <acpi/acnamesp.h> |
46 | #include <acpi/acdispat.h> | 46 | #include <acpi/acdispat.h> |
47 | #include <acpi/acinterp.h> | 47 | #include <acpi/acinterp.h> |
48 | #include <linux/nmi.h> | ||
48 | 49 | ||
49 | #define _COMPONENT ACPI_NAMESPACE | 50 | #define _COMPONENT ACPI_NAMESPACE |
50 | ACPI_MODULE_NAME("nsinit") | 51 | ACPI_MODULE_NAME("nsinit") |
@@ -534,7 +535,15 @@ acpi_ns_init_one_device(acpi_handle obj_handle, | |||
534 | info->parameter_type = ACPI_PARAM_ARGS; | 535 | info->parameter_type = ACPI_PARAM_ARGS; |
535 | info->flags = ACPI_IGNORE_RETURN_VALUE; | 536 | info->flags = ACPI_IGNORE_RETURN_VALUE; |
536 | 537 | ||
538 | /* | ||
539 | * Some hardware relies on this being executed as atomically | ||
540 | * as possible (without an NMI being received in the middle of | ||
541 | * this) - so disable NMIs and initialize the device: | ||
542 | */ | ||
543 | acpi_nmi_disable(); | ||
537 | status = acpi_ns_evaluate(info); | 544 | status = acpi_ns_evaluate(info); |
545 | acpi_nmi_enable(); | ||
546 | |||
538 | if (ACPI_SUCCESS(status)) { | 547 | if (ACPI_SUCCESS(status)) { |
539 | walk_info->num_INI++; | 548 | walk_info->num_INI++; |
540 | 549 | ||
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 6c6751b1405b..8206fc1ecc58 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -39,6 +39,17 @@ | |||
39 | #include <linux/moduleparam.h> | 39 | #include <linux/moduleparam.h> |
40 | #include <linux/sched.h> /* need_resched() */ | 40 | #include <linux/sched.h> /* need_resched() */ |
41 | #include <linux/latency.h> | 41 | #include <linux/latency.h> |
42 | #include <linux/clockchips.h> | ||
43 | |||
44 | /* | ||
45 | * Include the apic definitions for x86 to have the APIC timer related defines | ||
46 | * available also for UP (on SMP it gets magically included via linux/smp.h). | ||
47 | * asm/acpi.h is not an option, as it would require more include magic. Also | ||
48 | * creating an empty asm-ia64/apic.h would just trade pest vs. cholera. | ||
49 | */ | ||
50 | #ifdef CONFIG_X86 | ||
51 | #include <asm/apic.h> | ||
52 | #endif | ||
42 | 53 | ||
43 | #include <asm/io.h> | 54 | #include <asm/io.h> |
44 | #include <asm/uaccess.h> | 55 | #include <asm/uaccess.h> |
@@ -238,6 +249,81 @@ static void acpi_cstate_enter(struct acpi_processor_cx *cstate) | |||
238 | } | 249 | } |
239 | } | 250 | } |
240 | 251 | ||
252 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | ||
253 | |||
254 | /* | ||
255 | * Some BIOS implementations switch to C3 in the published C2 state. | ||
256 | * This seems to be a common problem on AMD boxen, but other vendors | ||
257 | * are affected too. We pick the most conservative approach: we assume | ||
258 | * that the local APIC stops in both C2 and C3. | ||
259 | */ | ||
260 | static void acpi_timer_check_state(int state, struct acpi_processor *pr, | ||
261 | struct acpi_processor_cx *cx) | ||
262 | { | ||
263 | struct acpi_processor_power *pwr = &pr->power; | ||
264 | |||
265 | /* | ||
266 | * Check, if one of the previous states already marked the lapic | ||
267 | * unstable | ||
268 | */ | ||
269 | if (pwr->timer_broadcast_on_state < state) | ||
270 | return; | ||
271 | |||
272 | if (cx->type >= ACPI_STATE_C2) | ||
273 | pr->power.timer_broadcast_on_state = state; | ||
274 | } | ||
275 | |||
276 | static void acpi_propagate_timer_broadcast(struct acpi_processor *pr) | ||
277 | { | ||
278 | #ifdef CONFIG_GENERIC_CLOCKEVENTS | ||
279 | unsigned long reason; | ||
280 | |||
281 | reason = pr->power.timer_broadcast_on_state < INT_MAX ? | ||
282 | CLOCK_EVT_NOTIFY_BROADCAST_ON : CLOCK_EVT_NOTIFY_BROADCAST_OFF; | ||
283 | |||
284 | clockevents_notify(reason, &pr->id); | ||
285 | #else | ||
286 | cpumask_t mask = cpumask_of_cpu(pr->id); | ||
287 | |||
288 | if (pr->power.timer_broadcast_on_state < INT_MAX) | ||
289 | on_each_cpu(switch_APIC_timer_to_ipi, &mask, 1, 1); | ||
290 | else | ||
291 | on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1); | ||
292 | #endif | ||
293 | } | ||
294 | |||
295 | /* Power(C) State timer broadcast control */ | ||
296 | static void acpi_state_timer_broadcast(struct acpi_processor *pr, | ||
297 | struct acpi_processor_cx *cx, | ||
298 | int broadcast) | ||
299 | { | ||
300 | #ifdef CONFIG_GENERIC_CLOCKEVENTS | ||
301 | |||
302 | int state = cx - pr->power.states; | ||
303 | |||
304 | if (state >= pr->power.timer_broadcast_on_state) { | ||
305 | unsigned long reason; | ||
306 | |||
307 | reason = broadcast ? CLOCK_EVT_NOTIFY_BROADCAST_ENTER : | ||
308 | CLOCK_EVT_NOTIFY_BROADCAST_EXIT; | ||
309 | clockevents_notify(reason, &pr->id); | ||
310 | } | ||
311 | #endif | ||
312 | } | ||
313 | |||
314 | #else | ||
315 | |||
316 | static void acpi_timer_check_state(int state, struct acpi_processor *pr, | ||
317 | struct acpi_processor_cx *cstate) { } | ||
318 | static void acpi_propagate_timer_broadcast(struct acpi_processor *pr) { } | ||
319 | static void acpi_state_timer_broadcast(struct acpi_processor *pr, | ||
320 | struct acpi_processor_cx *cx, | ||
321 | int broadcast) | ||
322 | { | ||
323 | } | ||
324 | |||
325 | #endif | ||
326 | |||
241 | static void acpi_processor_idle(void) | 327 | static void acpi_processor_idle(void) |
242 | { | 328 | { |
243 | struct acpi_processor *pr = NULL; | 329 | struct acpi_processor *pr = NULL; |
@@ -382,6 +468,7 @@ static void acpi_processor_idle(void) | |||
382 | /* Get start time (ticks) */ | 468 | /* Get start time (ticks) */ |
383 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 469 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
384 | /* Invoke C2 */ | 470 | /* Invoke C2 */ |
471 | acpi_state_timer_broadcast(pr, cx, 1); | ||
385 | acpi_cstate_enter(cx); | 472 | acpi_cstate_enter(cx); |
386 | /* Get end time (ticks) */ | 473 | /* Get end time (ticks) */ |
387 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 474 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
@@ -396,6 +483,7 @@ static void acpi_processor_idle(void) | |||
396 | /* Compute time (ticks) that we were actually asleep */ | 483 | /* Compute time (ticks) that we were actually asleep */ |
397 | sleep_ticks = | 484 | sleep_ticks = |
398 | ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; | 485 | ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; |
486 | acpi_state_timer_broadcast(pr, cx, 0); | ||
399 | break; | 487 | break; |
400 | 488 | ||
401 | case ACPI_STATE_C3: | 489 | case ACPI_STATE_C3: |
@@ -417,6 +505,7 @@ static void acpi_processor_idle(void) | |||
417 | /* Get start time (ticks) */ | 505 | /* Get start time (ticks) */ |
418 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 506 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
419 | /* Invoke C3 */ | 507 | /* Invoke C3 */ |
508 | acpi_state_timer_broadcast(pr, cx, 1); | ||
420 | acpi_cstate_enter(cx); | 509 | acpi_cstate_enter(cx); |
421 | /* Get end time (ticks) */ | 510 | /* Get end time (ticks) */ |
422 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 511 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
@@ -436,6 +525,7 @@ static void acpi_processor_idle(void) | |||
436 | /* Compute time (ticks) that we were actually asleep */ | 525 | /* Compute time (ticks) that we were actually asleep */ |
437 | sleep_ticks = | 526 | sleep_ticks = |
438 | ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; | 527 | ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; |
528 | acpi_state_timer_broadcast(pr, cx, 0); | ||
439 | break; | 529 | break; |
440 | 530 | ||
441 | default: | 531 | default: |
@@ -904,11 +994,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) | |||
904 | unsigned int i; | 994 | unsigned int i; |
905 | unsigned int working = 0; | 995 | unsigned int working = 0; |
906 | 996 | ||
907 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | 997 | pr->power.timer_broadcast_on_state = INT_MAX; |
908 | int timer_broadcast = 0; | ||
909 | cpumask_t mask = cpumask_of_cpu(pr->id); | ||
910 | on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1); | ||
911 | #endif | ||
912 | 998 | ||
913 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { | 999 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { |
914 | struct acpi_processor_cx *cx = &pr->power.states[i]; | 1000 | struct acpi_processor_cx *cx = &pr->power.states[i]; |
@@ -920,21 +1006,14 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) | |||
920 | 1006 | ||
921 | case ACPI_STATE_C2: | 1007 | case ACPI_STATE_C2: |
922 | acpi_processor_power_verify_c2(cx); | 1008 | acpi_processor_power_verify_c2(cx); |
923 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | 1009 | if (cx->valid) |
924 | /* Some AMD systems fake C3 as C2, but still | 1010 | acpi_timer_check_state(i, pr, cx); |
925 | have timer troubles */ | ||
926 | if (cx->valid && | ||
927 | boot_cpu_data.x86_vendor == X86_VENDOR_AMD) | ||
928 | timer_broadcast++; | ||
929 | #endif | ||
930 | break; | 1011 | break; |
931 | 1012 | ||
932 | case ACPI_STATE_C3: | 1013 | case ACPI_STATE_C3: |
933 | acpi_processor_power_verify_c3(pr, cx); | 1014 | acpi_processor_power_verify_c3(pr, cx); |
934 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | ||
935 | if (cx->valid) | 1015 | if (cx->valid) |
936 | timer_broadcast++; | 1016 | acpi_timer_check_state(i, pr, cx); |
937 | #endif | ||
938 | break; | 1017 | break; |
939 | } | 1018 | } |
940 | 1019 | ||
@@ -942,10 +1021,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) | |||
942 | working++; | 1021 | working++; |
943 | } | 1022 | } |
944 | 1023 | ||
945 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | 1024 | acpi_propagate_timer_broadcast(pr); |
946 | if (timer_broadcast) | ||
947 | on_each_cpu(switch_APIC_timer_to_ipi, &mask, 1, 1); | ||
948 | #endif | ||
949 | 1025 | ||
950 | return (working); | 1026 | return (working); |
951 | } | 1027 | } |
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c index 47fb4b394eec..d9801eff6489 100644 --- a/drivers/acpi/sleep/poweroff.c +++ b/drivers/acpi/sleep/poweroff.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/pm.h> | 12 | #include <linux/pm.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <acpi/acpi_bus.h> | 14 | #include <acpi/acpi_bus.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/sysdev.h> | 15 | #include <linux/sysdev.h> |
17 | #include <asm/io.h> | 16 | #include <asm/io.h> |
18 | #include "sleep.h" | 17 | #include "sleep.h" |
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index ba4cb200314a..45bd17313c4a 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
@@ -25,7 +25,6 @@ | |||
25 | 25 | ||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/sched.h> | ||
29 | #include <linux/smp.h> | 28 | #include <linux/smp.h> |
30 | #include <linux/string.h> | 29 | #include <linux/string.h> |
31 | #include <linux/types.h> | 30 | #include <linux/types.h> |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index f76d3168c2b2..986afd470a14 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -36,7 +36,8 @@ | |||
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/types.h> | 37 | #include <linux/types.h> |
38 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
39 | #include <linux/sched.h> | 39 | #include <linux/timer.h> |
40 | #include <linux/jiffies.h> | ||
40 | #include <linux/kmod.h> | 41 | #include <linux/kmod.h> |
41 | #include <linux/seq_file.h> | 42 | #include <linux/seq_file.h> |
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 92cdb0c5171f..6a3543e06241 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/blkdev.h> | 39 | #include <linux/blkdev.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/sched.h> | ||
43 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
44 | #include <linux/device.h> | 43 | #include <linux/device.h> |
45 | #include <scsi/scsi_host.h> | 44 | #include <scsi/scsi_host.h> |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 25d8d3f778a1..2cf8251728d2 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1410,7 +1410,16 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | tf.protocol = ATA_PROT_PIO; | 1412 | tf.protocol = ATA_PROT_PIO; |
1413 | tf.flags |= ATA_TFLAG_POLLING; /* for polling presence detection */ | 1413 | |
1414 | /* Some devices choke if TF registers contain garbage. Make | ||
1415 | * sure those are properly initialized. | ||
1416 | */ | ||
1417 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | ||
1418 | |||
1419 | /* Device presence detection is unreliable on some | ||
1420 | * controllers. Always poll IDENTIFY if available. | ||
1421 | */ | ||
1422 | tf.flags |= ATA_TFLAG_POLLING; | ||
1414 | 1423 | ||
1415 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, | 1424 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, |
1416 | id, sizeof(id[0]) * ATA_ID_WORDS); | 1425 | id, sizeof(id[0]) * ATA_ID_WORDS); |
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index 4223e10de6a0..98c1fee4b305 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c | |||
@@ -89,9 +89,10 @@ static int probe_all; /* Set to check all ISA port ranges */ | |||
89 | static int ht6560a; /* HT 6560A on primary 1, secondary 2, both 3 */ | 89 | static int ht6560a; /* HT 6560A on primary 1, secondary 2, both 3 */ |
90 | static int ht6560b; /* HT 6560A on primary 1, secondary 2, both 3 */ | 90 | static int ht6560b; /* HT 6560A on primary 1, secondary 2, both 3 */ |
91 | static int opti82c611a; /* Opti82c611A on primary 1, secondary 2, both 3 */ | 91 | static int opti82c611a; /* Opti82c611A on primary 1, secondary 2, both 3 */ |
92 | static int opti82c46x; /* Opti 82c465MV present (pri/sec autodetect) */ | 92 | static int opti82c46x; /* Opti 82c465MV present (pri/sec autodetect) */ |
93 | static int autospeed; /* Chip present which snoops speed changes */ | 93 | static int autospeed; /* Chip present which snoops speed changes */ |
94 | static int pio_mask = 0x1F; /* PIO range for autospeed devices */ | 94 | static int pio_mask = 0x1F; /* PIO range for autospeed devices */ |
95 | static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */ | ||
95 | 96 | ||
96 | /** | 97 | /** |
97 | * legacy_set_mode - mode setting | 98 | * legacy_set_mode - mode setting |
@@ -113,6 +114,7 @@ static int legacy_set_mode(struct ata_port *ap, struct ata_device **unused) | |||
113 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 114 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
114 | struct ata_device *dev = &ap->device[i]; | 115 | struct ata_device *dev = &ap->device[i]; |
115 | if (ata_dev_enabled(dev)) { | 116 | if (ata_dev_enabled(dev)) { |
117 | ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); | ||
116 | dev->pio_mode = XFER_PIO_0; | 118 | dev->pio_mode = XFER_PIO_0; |
117 | dev->xfer_mode = XFER_PIO_0; | 119 | dev->xfer_mode = XFER_PIO_0; |
118 | dev->xfer_shift = ATA_SHIFT_PIO; | 120 | dev->xfer_shift = ATA_SHIFT_PIO; |
@@ -695,6 +697,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
695 | void __iomem *io_addr, *ctrl_addr; | 697 | void __iomem *io_addr, *ctrl_addr; |
696 | int pio_modes = pio_mask; | 698 | int pio_modes = pio_mask; |
697 | u32 mask = (1 << port); | 699 | u32 mask = (1 << port); |
700 | u32 iordy = (iordy_mask & mask) ? 0: ATA_FLAG_NO_IORDY; | ||
698 | int ret; | 701 | int ret; |
699 | 702 | ||
700 | pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); | 703 | pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); |
@@ -715,6 +718,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
715 | if (ht6560a & mask) { | 718 | if (ht6560a & mask) { |
716 | ops = &ht6560a_port_ops; | 719 | ops = &ht6560a_port_ops; |
717 | pio_modes = 0x07; | 720 | pio_modes = 0x07; |
721 | iordy = ATA_FLAG_NO_IORDY; | ||
718 | } | 722 | } |
719 | if (ht6560b & mask) { | 723 | if (ht6560b & mask) { |
720 | ops = &ht6560b_port_ops; | 724 | ops = &ht6560b_port_ops; |
@@ -750,6 +754,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
750 | printk(KERN_INFO "PDC20230-C/20630 VLB ATA controller detected.\n"); | 754 | printk(KERN_INFO "PDC20230-C/20630 VLB ATA controller detected.\n"); |
751 | pio_modes = 0x07; | 755 | pio_modes = 0x07; |
752 | ops = &pdc20230_port_ops; | 756 | ops = &pdc20230_port_ops; |
757 | iordy = ATA_FLAG_NO_IORDY; | ||
753 | udelay(100); | 758 | udelay(100); |
754 | inb(0x1F5); | 759 | inb(0x1F5); |
755 | } else { | 760 | } else { |
@@ -767,6 +772,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
767 | /* Chip does mode setting by command snooping */ | 772 | /* Chip does mode setting by command snooping */ |
768 | if (ops == &legacy_port_ops && (autospeed & mask)) | 773 | if (ops == &legacy_port_ops && (autospeed & mask)) |
769 | ops = &simple_port_ops; | 774 | ops = &simple_port_ops; |
775 | |||
770 | memset(&ae, 0, sizeof(struct ata_probe_ent)); | 776 | memset(&ae, 0, sizeof(struct ata_probe_ent)); |
771 | INIT_LIST_HEAD(&ae.node); | 777 | INIT_LIST_HEAD(&ae.node); |
772 | ae.dev = &pdev->dev; | 778 | ae.dev = &pdev->dev; |
@@ -776,7 +782,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
776 | ae.pio_mask = pio_modes; | 782 | ae.pio_mask = pio_modes; |
777 | ae.irq = irq; | 783 | ae.irq = irq; |
778 | ae.irq_flags = 0; | 784 | ae.irq_flags = 0; |
779 | ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST; | 785 | ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST|iordy; |
780 | ae.port[0].cmd_addr = io_addr; | 786 | ae.port[0].cmd_addr = io_addr; |
781 | ae.port[0].altstatus_addr = ctrl_addr; | 787 | ae.port[0].altstatus_addr = ctrl_addr; |
782 | ae.port[0].ctl_addr = ctrl_addr; | 788 | ae.port[0].ctl_addr = ctrl_addr; |
@@ -945,6 +951,7 @@ module_param(ht6560b, int, 0); | |||
945 | module_param(opti82c611a, int, 0); | 951 | module_param(opti82c611a, int, 0); |
946 | module_param(opti82c46x, int, 0); | 952 | module_param(opti82c46x, int, 0); |
947 | module_param(pio_mask, int, 0); | 953 | module_param(pio_mask, int, 0); |
954 | module_param(iordy_mask, int, 0); | ||
948 | 955 | ||
949 | module_init(legacy_init); | 956 | module_init(legacy_init); |
950 | module_exit(legacy_exit); | 957 | module_exit(legacy_exit); |
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c index d7378df44970..29e1809e5ecf 100644 --- a/drivers/ata/pata_mpc52xx.c +++ b/drivers/ata/pata_mpc52xx.c | |||
@@ -484,10 +484,8 @@ mpc52xx_ata_resume(struct of_device *op) | |||
484 | 484 | ||
485 | static struct of_device_id mpc52xx_ata_of_match[] = { | 485 | static struct of_device_id mpc52xx_ata_of_match[] = { |
486 | { | 486 | { |
487 | .compatible = "mpc5200-ata", | 487 | .type = "ata", |
488 | }, | 488 | .compatible = "mpc5200-ata", |
489 | { | ||
490 | .compatible = "mpc52xx-ata", | ||
491 | }, | 489 | }, |
492 | {}, | 490 | {}, |
493 | }; | 491 | }; |
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c index ca8c965179b1..f2e7115f7ab9 100644 --- a/drivers/ata/pata_mpiix.c +++ b/drivers/ata/pata_mpiix.c | |||
@@ -241,7 +241,7 @@ static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
241 | probe.port_ops = &mpiix_port_ops; | 241 | probe.port_ops = &mpiix_port_ops; |
242 | probe.sht = &mpiix_sht; | 242 | probe.sht = &mpiix_sht; |
243 | probe.pio_mask = 0x1F; | 243 | probe.pio_mask = 0x1F; |
244 | probe.irq_flags = SA_SHIRQ; | 244 | probe.irq_flags = IRQF_SHARED; |
245 | probe.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; | 245 | probe.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; |
246 | probe.n_ports = 1; | 246 | probe.n_ports = 1; |
247 | 247 | ||
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index acfc09f9abd9..36468ec6454c 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -264,7 +264,7 @@ next_entry: | |||
264 | ae.n_ports = 1; | 264 | ae.n_ports = 1; |
265 | ae.pio_mask = 1; /* ISA so PIO 0 cycles */ | 265 | ae.pio_mask = 1; /* ISA so PIO 0 cycles */ |
266 | ae.irq = pdev->irq.AssignedIRQ; | 266 | ae.irq = pdev->irq.AssignedIRQ; |
267 | ae.irq_flags = SA_SHIRQ; | 267 | ae.irq_flags = IRQF_SHARED; |
268 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; | 268 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; |
269 | ae.port[0].cmd_addr = io_addr; | 269 | ae.port[0].cmd_addr = io_addr; |
270 | ae.port[0].altstatus_addr = ctl_addr; | 270 | ae.port[0].altstatus_addr = ctl_addr; |
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c index ffa7f47fbb20..61537873d28e 100644 --- a/drivers/ata/pata_pdc2027x.c +++ b/drivers/ata/pata_pdc2027x.c | |||
@@ -796,7 +796,7 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de | |||
796 | probe_ent->port_ops = pdc2027x_port_info[board_idx].port_ops; | 796 | probe_ent->port_ops = pdc2027x_port_info[board_idx].port_ops; |
797 | 797 | ||
798 | probe_ent->irq = pdev->irq; | 798 | probe_ent->irq = pdev->irq; |
799 | probe_ent->irq_flags = SA_SHIRQ; | 799 | probe_ent->irq_flags = IRQF_SHARED; |
800 | probe_ent->iomap = pcim_iomap_table(pdev); | 800 | probe_ent->iomap = pcim_iomap_table(pdev); |
801 | 801 | ||
802 | mmio_base = probe_ent->iomap[PDC_MMIO_BAR]; | 802 | mmio_base = probe_ent->iomap[PDC_MMIO_BAR]; |
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c index 1b3b4ed8eb19..4362141976ad 100644 --- a/drivers/ata/pata_qdi.c +++ b/drivers/ata/pata_qdi.c | |||
@@ -264,16 +264,18 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i | |||
264 | if (type == 6580) { | 264 | if (type == 6580) { |
265 | ae.port_ops = &qdi6580_port_ops; | 265 | ae.port_ops = &qdi6580_port_ops; |
266 | ae.pio_mask = 0x1F; | 266 | ae.pio_mask = 0x1F; |
267 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; | ||
267 | } else { | 268 | } else { |
268 | ae.port_ops = &qdi6500_port_ops; | 269 | ae.port_ops = &qdi6500_port_ops; |
269 | ae.pio_mask = 0x07; /* Actually PIO3 !IORDY is possible */ | 270 | ae.pio_mask = 0x07; /* Actually PIO3 !IORDY is possible */ |
271 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | | ||
272 | ATA_FLAG_NO_IORDY; | ||
270 | } | 273 | } |
271 | 274 | ||
272 | ae.sht = &qdi_sht; | 275 | ae.sht = &qdi_sht; |
273 | ae.n_ports = 1; | 276 | ae.n_ports = 1; |
274 | ae.irq = irq; | 277 | ae.irq = irq; |
275 | ae.irq_flags = 0; | 278 | ae.irq_flags = 0; |
276 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; | ||
277 | ae.port[0].cmd_addr = io_addr; | 279 | ae.port[0].cmd_addr = io_addr; |
278 | ae.port[0].altstatus_addr = ctl_addr; | 280 | ae.port[0].altstatus_addr = ctl_addr; |
279 | ae.port[0].ctl_addr = ctl_addr; | 281 | ae.port[0].ctl_addr = ctl_addr; |
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c index f2fa158d07ca..96e890fd645b 100644 --- a/drivers/ata/pata_sl82c105.c +++ b/drivers/ata/pata_sl82c105.c | |||
@@ -187,7 +187,9 @@ static void sl82c105_bmdma_start(struct ata_queued_cmd *qc) | |||
187 | { | 187 | { |
188 | struct ata_port *ap = qc->ap; | 188 | struct ata_port *ap = qc->ap; |
189 | 189 | ||
190 | udelay(100); | ||
190 | sl82c105_reset_engine(ap); | 191 | sl82c105_reset_engine(ap); |
192 | udelay(100); | ||
191 | 193 | ||
192 | /* Set the clocks for DMA */ | 194 | /* Set the clocks for DMA */ |
193 | sl82c105_configure_dmamode(ap, qc->dev); | 195 | sl82c105_configure_dmamode(ap, qc->dev); |
@@ -216,6 +218,7 @@ static void sl82c105_bmdma_stop(struct ata_queued_cmd *qc) | |||
216 | 218 | ||
217 | ata_bmdma_stop(qc); | 219 | ata_bmdma_stop(qc); |
218 | sl82c105_reset_engine(ap); | 220 | sl82c105_reset_engine(ap); |
221 | udelay(100); | ||
219 | 222 | ||
220 | /* This will redo the initial setup of the DMA device to matching | 223 | /* This will redo the initial setup of the DMA device to matching |
221 | PIO timings */ | 224 | PIO timings */ |
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c index b4ed8ce553e6..857ac23217ab 100644 --- a/drivers/ata/pdc_adma.c +++ b/drivers/ata/pdc_adma.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/blkdev.h> | 39 | #include <linux/blkdev.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/sched.h> | ||
43 | #include <linux/device.h> | 42 | #include <linux/device.h> |
44 | #include <scsi/scsi_host.h> | 43 | #include <scsi/scsi_host.h> |
45 | #include <linux/libata.h> | 44 | #include <linux/libata.h> |
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c index c5335f422801..31b636fac98e 100644 --- a/drivers/ata/sata_inic162x.c +++ b/drivers/ata/sata_inic162x.c | |||
@@ -710,7 +710,7 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
710 | probe_ent->n_ports = NR_PORTS; | 710 | probe_ent->n_ports = NR_PORTS; |
711 | 711 | ||
712 | probe_ent->irq = pdev->irq; | 712 | probe_ent->irq = pdev->irq; |
713 | probe_ent->irq_flags = SA_SHIRQ; | 713 | probe_ent->irq_flags = IRQF_SHARED; |
714 | 714 | ||
715 | probe_ent->iomap = iomap; | 715 | probe_ent->iomap = iomap; |
716 | 716 | ||
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 769eca52442c..d689df52eae3 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/blkdev.h> | 28 | #include <linux/blkdev.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/sched.h> | ||
32 | #include <linux/dma-mapping.h> | 31 | #include <linux/dma-mapping.h> |
33 | #include <linux/device.h> | 32 | #include <linux/device.h> |
34 | #include <scsi/scsi_host.h> | 33 | #include <scsi/scsi_host.h> |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 095ef1b2cd0e..ab92f208dae2 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -827,7 +827,8 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
827 | /* freeze if hotplugged or controller error */ | 827 | /* freeze if hotplugged or controller error */ |
828 | if (unlikely(status & (NV_ADMA_STAT_HOTPLUG | | 828 | if (unlikely(status & (NV_ADMA_STAT_HOTPLUG | |
829 | NV_ADMA_STAT_HOTUNPLUG | | 829 | NV_ADMA_STAT_HOTUNPLUG | |
830 | NV_ADMA_STAT_TIMEOUT))) { | 830 | NV_ADMA_STAT_TIMEOUT | |
831 | NV_ADMA_STAT_SERROR))) { | ||
831 | struct ata_eh_info *ehi = &ap->eh_info; | 832 | struct ata_eh_info *ehi = &ap->eh_info; |
832 | 833 | ||
833 | ata_ehi_clear_desc(ehi); | 834 | ata_ehi_clear_desc(ehi); |
@@ -841,6 +842,9 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
841 | } else if (status & NV_ADMA_STAT_HOTUNPLUG) { | 842 | } else if (status & NV_ADMA_STAT_HOTUNPLUG) { |
842 | ata_ehi_hotplugged(ehi); | 843 | ata_ehi_hotplugged(ehi); |
843 | ata_ehi_push_desc(ehi, ": hot unplug"); | 844 | ata_ehi_push_desc(ehi, ": hot unplug"); |
845 | } else if (status & NV_ADMA_STAT_SERROR) { | ||
846 | /* let libata analyze SError and figure out the cause */ | ||
847 | ata_ehi_push_desc(ehi, ": SError"); | ||
844 | } | 848 | } |
845 | ata_port_freeze(ap); | 849 | ata_port_freeze(ap); |
846 | continue; | 850 | continue; |
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index 3be4cc338d7b..cf9ed8c39301 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/blkdev.h> | 37 | #include <linux/blkdev.h> |
38 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/sched.h> | ||
41 | #include <linux/device.h> | 40 | #include <linux/device.h> |
42 | #include <scsi/scsi.h> | 41 | #include <scsi/scsi.h> |
43 | #include <scsi/scsi_host.h> | 42 | #include <scsi/scsi_host.h> |
@@ -120,9 +119,7 @@ static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg); | |||
120 | static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); | 119 | static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); |
121 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 120 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); |
122 | static irqreturn_t pdc_interrupt (int irq, void *dev_instance); | 121 | static irqreturn_t pdc_interrupt (int irq, void *dev_instance); |
123 | static void pdc_eng_timeout(struct ata_port *ap); | ||
124 | static int pdc_port_start(struct ata_port *ap); | 122 | static int pdc_port_start(struct ata_port *ap); |
125 | static void pdc_pata_phy_reset(struct ata_port *ap); | ||
126 | static void pdc_qc_prep(struct ata_queued_cmd *qc); | 123 | static void pdc_qc_prep(struct ata_queued_cmd *qc); |
127 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 124 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
128 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 125 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
@@ -216,12 +213,12 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
216 | .dev_select = ata_std_dev_select, | 213 | .dev_select = ata_std_dev_select, |
217 | .check_atapi_dma = pdc_check_atapi_dma, | 214 | .check_atapi_dma = pdc_check_atapi_dma, |
218 | 215 | ||
219 | .phy_reset = pdc_pata_phy_reset, | ||
220 | |||
221 | .qc_prep = pdc_qc_prep, | 216 | .qc_prep = pdc_qc_prep, |
222 | .qc_issue = pdc_qc_issue_prot, | 217 | .qc_issue = pdc_qc_issue_prot, |
218 | .freeze = pdc_freeze, | ||
219 | .thaw = pdc_thaw, | ||
220 | .error_handler = pdc_error_handler, | ||
223 | .data_xfer = ata_data_xfer, | 221 | .data_xfer = ata_data_xfer, |
224 | .eng_timeout = pdc_eng_timeout, | ||
225 | .irq_handler = pdc_interrupt, | 222 | .irq_handler = pdc_interrupt, |
226 | .irq_clear = pdc_irq_clear, | 223 | .irq_clear = pdc_irq_clear, |
227 | .irq_on = ata_irq_on, | 224 | .irq_on = ata_irq_on, |
@@ -254,7 +251,7 @@ static const struct ata_port_info pdc_port_info[] = { | |||
254 | /* board_20619 */ | 251 | /* board_20619 */ |
255 | { | 252 | { |
256 | .sht = &pdc_ata_sht, | 253 | .sht = &pdc_ata_sht, |
257 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS, | 254 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, |
258 | .pio_mask = 0x1f, /* pio0-4 */ | 255 | .pio_mask = 0x1f, /* pio0-4 */ |
259 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 256 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
260 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | 257 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ |
@@ -390,14 +387,6 @@ static void pdc_pata_cbl_detect(struct ata_port *ap) | |||
390 | ap->cbl = ATA_CBL_PATA80; | 387 | ap->cbl = ATA_CBL_PATA80; |
391 | } | 388 | } |
392 | 389 | ||
393 | static void pdc_pata_phy_reset(struct ata_port *ap) | ||
394 | { | ||
395 | pdc_pata_cbl_detect(ap); | ||
396 | pdc_reset_port(ap); | ||
397 | ata_port_probe(ap); | ||
398 | ata_bus_reset(ap); | ||
399 | } | ||
400 | |||
401 | static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) | 390 | static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) |
402 | { | 391 | { |
403 | if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) | 392 | if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) |
@@ -565,6 +554,13 @@ static void pdc_thaw(struct ata_port *ap) | |||
565 | readl(mmio + PDC_CTLSTAT); /* flush */ | 554 | readl(mmio + PDC_CTLSTAT); /* flush */ |
566 | } | 555 | } |
567 | 556 | ||
557 | static int pdc_pre_reset(struct ata_port *ap) | ||
558 | { | ||
559 | if (!sata_scr_valid(ap)) | ||
560 | pdc_pata_cbl_detect(ap); | ||
561 | return ata_std_prereset(ap); | ||
562 | } | ||
563 | |||
568 | static void pdc_error_handler(struct ata_port *ap) | 564 | static void pdc_error_handler(struct ata_port *ap) |
569 | { | 565 | { |
570 | ata_reset_fn_t hardreset; | 566 | ata_reset_fn_t hardreset; |
@@ -577,7 +573,7 @@ static void pdc_error_handler(struct ata_port *ap) | |||
577 | hardreset = sata_std_hardreset; | 573 | hardreset = sata_std_hardreset; |
578 | 574 | ||
579 | /* perform recovery */ | 575 | /* perform recovery */ |
580 | ata_do_eh(ap, ata_std_prereset, ata_std_softreset, hardreset, | 576 | ata_do_eh(ap, pdc_pre_reset, ata_std_softreset, hardreset, |
581 | ata_std_postreset); | 577 | ata_std_postreset); |
582 | } | 578 | } |
583 | 579 | ||
@@ -593,43 +589,6 @@ static void pdc_post_internal_cmd(struct ata_queued_cmd *qc) | |||
593 | pdc_reset_port(ap); | 589 | pdc_reset_port(ap); |
594 | } | 590 | } |
595 | 591 | ||
596 | static void pdc_eng_timeout(struct ata_port *ap) | ||
597 | { | ||
598 | struct ata_host *host = ap->host; | ||
599 | u8 drv_stat; | ||
600 | struct ata_queued_cmd *qc; | ||
601 | unsigned long flags; | ||
602 | |||
603 | DPRINTK("ENTER\n"); | ||
604 | |||
605 | spin_lock_irqsave(&host->lock, flags); | ||
606 | |||
607 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
608 | |||
609 | switch (qc->tf.protocol) { | ||
610 | case ATA_PROT_DMA: | ||
611 | case ATA_PROT_NODATA: | ||
612 | ata_port_printk(ap, KERN_ERR, "command timeout\n"); | ||
613 | drv_stat = ata_wait_idle(ap); | ||
614 | qc->err_mask |= __ac_err_mask(drv_stat); | ||
615 | break; | ||
616 | |||
617 | default: | ||
618 | drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | ||
619 | |||
620 | ata_port_printk(ap, KERN_ERR, | ||
621 | "unknown timeout, cmd 0x%x stat 0x%x\n", | ||
622 | qc->tf.command, drv_stat); | ||
623 | |||
624 | qc->err_mask |= ac_err_mask(drv_stat); | ||
625 | break; | ||
626 | } | ||
627 | |||
628 | spin_unlock_irqrestore(&host->lock, flags); | ||
629 | ata_eh_qc_complete(qc); | ||
630 | DPRINTK("EXIT\n"); | ||
631 | } | ||
632 | |||
633 | static inline unsigned int pdc_host_intr( struct ata_port *ap, | 592 | static inline unsigned int pdc_host_intr( struct ata_port *ap, |
634 | struct ata_queued_cmd *qc) | 593 | struct ata_queued_cmd *qc) |
635 | { | 594 | { |
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c index bfa35ede6551..6097d8f2a0c0 100644 --- a/drivers/ata/sata_qstor.c +++ b/drivers/ata/sata_qstor.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/blkdev.h> | 34 | #include <linux/blkdev.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/interrupt.h> | 36 | #include <linux/interrupt.h> |
37 | #include <linux/sched.h> | ||
38 | #include <linux/device.h> | 37 | #include <linux/device.h> |
39 | #include <scsi/scsi_host.h> | 38 | #include <scsi/scsi_host.h> |
40 | #include <linux/libata.h> | 39 | #include <linux/libata.h> |
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c index 06e87a377382..0ebd77b080d6 100644 --- a/drivers/ata/sata_sx4.c +++ b/drivers/ata/sata_sx4.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/blkdev.h> | 37 | #include <linux/blkdev.h> |
38 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/sched.h> | ||
41 | #include <linux/device.h> | 40 | #include <linux/device.h> |
42 | #include <scsi/scsi_host.h> | 41 | #include <scsi/scsi_host.h> |
43 | #include <scsi/scsi_cmnd.h> | 42 | #include <scsi/scsi_cmnd.h> |
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c index 3d9daf231115..2fd037bde090 100644 --- a/drivers/ata/sata_vsc.c +++ b/drivers/ata/sata_vsc.c | |||
@@ -346,6 +346,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
346 | struct ata_probe_ent *probe_ent; | 346 | struct ata_probe_ent *probe_ent; |
347 | void __iomem *mmio_base; | 347 | void __iomem *mmio_base; |
348 | int rc; | 348 | int rc; |
349 | u8 cls; | ||
349 | 350 | ||
350 | if (!printed_version++) | 351 | if (!printed_version++) |
351 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 352 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
@@ -383,9 +384,12 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
383 | INIT_LIST_HEAD(&probe_ent->node); | 384 | INIT_LIST_HEAD(&probe_ent->node); |
384 | 385 | ||
385 | /* | 386 | /* |
386 | * Due to a bug in the chip, the default cache line size can't be used | 387 | * Due to a bug in the chip, the default cache line size can't be |
388 | * used (unless the default is non-zero). | ||
387 | */ | 389 | */ |
388 | pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80); | 390 | pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cls); |
391 | if (cls == 0x00) | ||
392 | pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80); | ||
389 | 393 | ||
390 | if (pci_enable_msi(pdev) == 0) | 394 | if (pci_enable_msi(pdev) == 0) |
391 | pci_intx(pdev, 0); | 395 | pci_intx(pdev, 0); |
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c index ac2c10822be0..8d60c4eb54fe 100644 --- a/drivers/atm/adummy.c +++ b/drivers/atm/adummy.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/timer.h> | 16 | #include <linux/timer.h> |
18 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
19 | #include <asm/io.h> | 18 | #include <asm/io.h> |
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index 4aeb3d062ff6..a7c0ed3107e3 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/capability.h> | 31 | #include <linux/capability.h> |
32 | #include <linux/sched.h> | ||
33 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
34 | #include <linux/bitops.h> | 33 | #include <linux/bitops.h> |
35 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c index 325325afabec..0bd657f5dd2a 100644 --- a/drivers/atm/idt77105.c +++ b/drivers/atm/idt77105.c | |||
@@ -4,7 +4,6 @@ | |||
4 | 4 | ||
5 | 5 | ||
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/sched.h> | ||
8 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
9 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
10 | #include <linux/errno.h> | 9 | #include <linux/errno.h> |
diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c index 9504cce51bfb..fc8cb07c2477 100644 --- a/drivers/atm/uPD98402.c +++ b/drivers/atm/uPD98402.c | |||
@@ -4,7 +4,6 @@ | |||
4 | 4 | ||
5 | 5 | ||
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/sched.h> /* for jiffies */ | ||
8 | #include <linux/mm.h> | 7 | #include <linux/mm.h> |
9 | #include <linux/errno.h> | 8 | #include <linux/errno.h> |
10 | #include <linux/atmdev.h> | 9 | #include <linux/atmdev.h> |
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index 756d4f760da3..0d7091e2077f 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c | |||
@@ -4,7 +4,6 @@ | |||
4 | 4 | ||
5 | 5 | ||
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/sched.h> | ||
8 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
9 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
10 | #include <linux/pci.h> | 9 | #include <linux/pci.h> |
diff --git a/drivers/block/acsi.c b/drivers/block/acsi.c index 706cdc6a69ec..e3d9152e231a 100644 --- a/drivers/block/acsi.c +++ b/drivers/block/acsi.c | |||
@@ -46,7 +46,6 @@ | |||
46 | #include <linux/module.h> | 46 | #include <linux/module.h> |
47 | #include <linux/errno.h> | 47 | #include <linux/errno.h> |
48 | #include <linux/signal.h> | 48 | #include <linux/signal.h> |
49 | #include <linux/sched.h> | ||
50 | #include <linux/timer.h> | 49 | #include <linux/timer.h> |
51 | #include <linux/fs.h> | 50 | #include <linux/fs.h> |
52 | #include <linux/kernel.h> | 51 | #include <linux/kernel.h> |
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 9d9bff23f426..99e2c8ce1cc4 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c | |||
@@ -153,7 +153,6 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV}; | |||
153 | #include <linux/blkpg.h> | 153 | #include <linux/blkpg.h> |
154 | #include <linux/kernel.h> | 154 | #include <linux/kernel.h> |
155 | #include <asm/uaccess.h> | 155 | #include <asm/uaccess.h> |
156 | #include <linux/sched.h> | ||
157 | #include <linux/workqueue.h> | 156 | #include <linux/workqueue.h> |
158 | 157 | ||
159 | static DEFINE_SPINLOCK(pd_lock); | 158 | static DEFINE_SPINLOCK(pd_lock); |
diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 30f16bd83650..dff3766f117f 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c | |||
@@ -35,7 +35,6 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | //#define DEBUG /* uncomment if you want debugging info (pr_debug) */ | 37 | //#define DEBUG /* uncomment if you want debugging info (pr_debug) */ |
38 | #include <linux/sched.h> | ||
39 | #include <linux/fs.h> | 38 | #include <linux/fs.h> |
40 | #include <linux/bio.h> | 39 | #include <linux/bio.h> |
41 | #include <linux/kernel.h> | 40 | #include <linux/kernel.h> |
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 31ade991aa91..27cceb6f5652 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
32 | #include <linux/skbuff.h> | 31 | #include <linux/skbuff.h> |
33 | 32 | ||
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index aae3abace586..34e5555cb917 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
32 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
33 | #include <linux/ptrace.h> | 32 | #include <linux/ptrace.h> |
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 92648ef2f5d0..c1bce75148fe 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
29 | #include <linux/sched.h> | ||
30 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
31 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
32 | #include <linux/ptrace.h> | 31 | #include <linux/ptrace.h> |
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 77b99eecbc49..459aa97937ab 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
29 | #include <linux/sched.h> | ||
30 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
31 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
32 | #include <linux/ptrace.h> | 31 | #include <linux/ptrace.h> |
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c index 5e2c31882003..d66064ccb31c 100644 --- a/drivers/bluetooth/hci_bcsp.c +++ b/drivers/bluetooth/hci_bcsp.c | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/sched.h> | ||
30 | #include <linux/types.h> | 29 | #include <linux/types.h> |
31 | #include <linux/fcntl.h> | 30 | #include <linux/fcntl.h> |
32 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c index ad62abbbb739..34f0afc42407 100644 --- a/drivers/bluetooth/hci_h4.c +++ b/drivers/bluetooth/hci_h4.c | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/types.h> | 30 | #include <linux/types.h> |
32 | #include <linux/fcntl.h> | 31 | #include <linux/fcntl.h> |
33 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 420b645c4c9f..0f4203b499af 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/types.h> | 30 | #include <linux/types.h> |
32 | #include <linux/fcntl.h> | 31 | #include <linux/fcntl.h> |
33 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c index 6bdf593081d8..406af579ac3a 100644 --- a/drivers/bluetooth/hci_usb.c +++ b/drivers/bluetooth/hci_usb.c | |||
@@ -35,7 +35,6 @@ | |||
35 | 35 | ||
36 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/unistd.h> | 38 | #include <linux/unistd.h> |
40 | #include <linux/types.h> | 39 | #include <linux/types.h> |
41 | #include <linux/interrupt.h> | 40 | #include <linux/interrupt.h> |
diff --git a/drivers/cdrom/aztcd.c b/drivers/cdrom/aztcd.c index ec469497c10f..1f9fb7a96703 100644 --- a/drivers/cdrom/aztcd.c +++ b/drivers/cdrom/aztcd.c | |||
@@ -170,7 +170,6 @@ | |||
170 | 170 | ||
171 | #include <linux/module.h> | 171 | #include <linux/module.h> |
172 | #include <linux/errno.h> | 172 | #include <linux/errno.h> |
173 | #include <linux/sched.h> | ||
174 | #include <linux/mm.h> | 173 | #include <linux/mm.h> |
175 | #include <linux/timer.h> | 174 | #include <linux/timer.h> |
176 | #include <linux/fs.h> | 175 | #include <linux/fs.h> |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 3105dddf59f1..b36f44d4d1bf 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -3553,9 +3553,7 @@ static void cdrom_sysctl_register(void) | |||
3553 | if (initialized == 1) | 3553 | if (initialized == 1) |
3554 | return; | 3554 | return; |
3555 | 3555 | ||
3556 | cdrom_sysctl_header = register_sysctl_table(cdrom_root_table, 1); | 3556 | cdrom_sysctl_header = register_sysctl_table(cdrom_root_table); |
3557 | if (cdrom_root_table->ctl_name && cdrom_root_table->child->de) | ||
3558 | cdrom_root_table->child->de->owner = THIS_MODULE; | ||
3559 | 3557 | ||
3560 | /* set the defaults */ | 3558 | /* set the defaults */ |
3561 | cdrom_sysctl_settings.autoclose = autoclose; | 3559 | cdrom_sysctl_settings.autoclose = autoclose; |
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c index b6c61bbb20e1..230131163240 100644 --- a/drivers/cdrom/cm206.c +++ b/drivers/cdrom/cm206.c | |||
@@ -183,7 +183,6 @@ History: | |||
183 | #include <linux/errno.h> /* These include what we really need */ | 183 | #include <linux/errno.h> /* These include what we really need */ |
184 | #include <linux/delay.h> | 184 | #include <linux/delay.h> |
185 | #include <linux/string.h> | 185 | #include <linux/string.h> |
186 | #include <linux/sched.h> | ||
187 | #include <linux/interrupt.h> | 186 | #include <linux/interrupt.h> |
188 | #include <linux/timer.h> | 187 | #include <linux/timer.h> |
189 | #include <linux/cdrom.h> | 188 | #include <linux/cdrom.h> |
diff --git a/drivers/cdrom/gscd.c b/drivers/cdrom/gscd.c index fa7082489765..b3ab6e9b8df1 100644 --- a/drivers/cdrom/gscd.c +++ b/drivers/cdrom/gscd.c | |||
@@ -53,7 +53,6 @@ | |||
53 | #include <linux/slab.h> | 53 | #include <linux/slab.h> |
54 | #include <linux/errno.h> | 54 | #include <linux/errno.h> |
55 | #include <linux/signal.h> | 55 | #include <linux/signal.h> |
56 | #include <linux/sched.h> | ||
57 | #include <linux/timer.h> | 56 | #include <linux/timer.h> |
58 | #include <linux/fs.h> | 57 | #include <linux/fs.h> |
59 | #include <linux/mm.h> | 58 | #include <linux/mm.h> |
diff --git a/drivers/cdrom/sjcd.c b/drivers/cdrom/sjcd.c index bf5aef4e555b..5409fca5bbfc 100644 --- a/drivers/cdrom/sjcd.c +++ b/drivers/cdrom/sjcd.c | |||
@@ -60,7 +60,6 @@ | |||
60 | 60 | ||
61 | #include <linux/module.h> | 61 | #include <linux/module.h> |
62 | #include <linux/errno.h> | 62 | #include <linux/errno.h> |
63 | #include <linux/sched.h> | ||
64 | #include <linux/mm.h> | 63 | #include <linux/mm.h> |
65 | #include <linux/timer.h> | 64 | #include <linux/timer.h> |
66 | #include <linux/fs.h> | 65 | #include <linux/fs.h> |
diff --git a/drivers/char/agp/Makefile b/drivers/char/agp/Makefile index 3e581603d0a8..a0d04a23dacd 100644 --- a/drivers/char/agp/Makefile +++ b/drivers/char/agp/Makefile | |||
@@ -1,6 +1,7 @@ | |||
1 | agpgart-y := backend.o frontend.o generic.o isoch.o | 1 | agpgart-y := backend.o frontend.o generic.o isoch.o |
2 | 2 | ||
3 | obj-$(CONFIG_AGP) += agpgart.o | 3 | obj-$(CONFIG_AGP) += agpgart.o |
4 | obj-$(CONFIG_COMPAT) += compat_ioctl.o | ||
4 | obj-$(CONFIG_AGP_ALI) += ali-agp.o | 5 | obj-$(CONFIG_AGP_ALI) += ali-agp.o |
5 | obj-$(CONFIG_AGP_ATI) += ati-agp.o | 6 | obj-$(CONFIG_AGP_ATI) += ati-agp.o |
6 | obj-$(CONFIG_AGP_AMD) += amd-k7-agp.o | 7 | obj-$(CONFIG_AGP_AMD) += amd-k7-agp.o |
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h index 1d59e2a5b9aa..9bd68d9f0f59 100644 --- a/drivers/char/agp/agp.h +++ b/drivers/char/agp/agp.h | |||
@@ -114,6 +114,7 @@ struct agp_bridge_driver { | |||
114 | void (*free_by_type)(struct agp_memory *); | 114 | void (*free_by_type)(struct agp_memory *); |
115 | void *(*agp_alloc_page)(struct agp_bridge_data *); | 115 | void *(*agp_alloc_page)(struct agp_bridge_data *); |
116 | void (*agp_destroy_page)(void *); | 116 | void (*agp_destroy_page)(void *); |
117 | int (*agp_type_to_mask_type) (struct agp_bridge_data *, int); | ||
117 | }; | 118 | }; |
118 | 119 | ||
119 | struct agp_bridge_data { | 120 | struct agp_bridge_data { |
@@ -218,6 +219,7 @@ struct agp_bridge_data { | |||
218 | #define I810_PTE_MAIN_UNCACHED 0x00000000 | 219 | #define I810_PTE_MAIN_UNCACHED 0x00000000 |
219 | #define I810_PTE_LOCAL 0x00000002 | 220 | #define I810_PTE_LOCAL 0x00000002 |
220 | #define I810_PTE_VALID 0x00000001 | 221 | #define I810_PTE_VALID 0x00000001 |
222 | #define I830_PTE_SYSTEM_CACHED 0x00000006 | ||
221 | #define I810_SMRAM_MISCC 0x70 | 223 | #define I810_SMRAM_MISCC 0x70 |
222 | #define I810_GFX_MEM_WIN_SIZE 0x00010000 | 224 | #define I810_GFX_MEM_WIN_SIZE 0x00010000 |
223 | #define I810_GFX_MEM_WIN_32M 0x00010000 | 225 | #define I810_GFX_MEM_WIN_32M 0x00010000 |
@@ -270,8 +272,16 @@ void global_cache_flush(void); | |||
270 | void get_agp_version(struct agp_bridge_data *bridge); | 272 | void get_agp_version(struct agp_bridge_data *bridge); |
271 | unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, | 273 | unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, |
272 | unsigned long addr, int type); | 274 | unsigned long addr, int type); |
275 | int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge, | ||
276 | int type); | ||
273 | struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev); | 277 | struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev); |
274 | 278 | ||
279 | /* generic functions for user-populated AGP memory types */ | ||
280 | struct agp_memory *agp_generic_alloc_user(size_t page_count, int type); | ||
281 | void agp_alloc_page_array(size_t size, struct agp_memory *mem); | ||
282 | void agp_free_page_array(struct agp_memory *mem); | ||
283 | |||
284 | |||
275 | /* generic routines for agp>=3 */ | 285 | /* generic routines for agp>=3 */ |
276 | int agp3_generic_fetch_size(void); | 286 | int agp3_generic_fetch_size(void); |
277 | void agp3_generic_tlbflush(struct agp_memory *mem); | 287 | void agp3_generic_tlbflush(struct agp_memory *mem); |
@@ -288,6 +298,8 @@ extern struct aper_size_info_16 agp3_generic_sizes[]; | |||
288 | extern int agp_off; | 298 | extern int agp_off; |
289 | extern int agp_try_unsupported_boot; | 299 | extern int agp_try_unsupported_boot; |
290 | 300 | ||
301 | long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg); | ||
302 | |||
291 | /* Chipset independant registers (from AGP Spec) */ | 303 | /* Chipset independant registers (from AGP Spec) */ |
292 | #define AGP_APBASE 0x10 | 304 | #define AGP_APBASE 0x10 |
293 | 305 | ||
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c index 5a31ec7c62fc..98177a93076f 100644 --- a/drivers/char/agp/ali-agp.c +++ b/drivers/char/agp/ali-agp.c | |||
@@ -214,6 +214,7 @@ static struct agp_bridge_driver ali_generic_bridge = { | |||
214 | .free_by_type = agp_generic_free_by_type, | 214 | .free_by_type = agp_generic_free_by_type, |
215 | .agp_alloc_page = agp_generic_alloc_page, | 215 | .agp_alloc_page = agp_generic_alloc_page, |
216 | .agp_destroy_page = ali_destroy_page, | 216 | .agp_destroy_page = ali_destroy_page, |
217 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
217 | }; | 218 | }; |
218 | 219 | ||
219 | static struct agp_bridge_driver ali_m1541_bridge = { | 220 | static struct agp_bridge_driver ali_m1541_bridge = { |
@@ -237,6 +238,7 @@ static struct agp_bridge_driver ali_m1541_bridge = { | |||
237 | .free_by_type = agp_generic_free_by_type, | 238 | .free_by_type = agp_generic_free_by_type, |
238 | .agp_alloc_page = m1541_alloc_page, | 239 | .agp_alloc_page = m1541_alloc_page, |
239 | .agp_destroy_page = m1541_destroy_page, | 240 | .agp_destroy_page = m1541_destroy_page, |
241 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
240 | }; | 242 | }; |
241 | 243 | ||
242 | 244 | ||
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c index b4e00a343da9..b0acf41c0db9 100644 --- a/drivers/char/agp/alpha-agp.c +++ b/drivers/char/agp/alpha-agp.c | |||
@@ -91,6 +91,9 @@ static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start, | |||
91 | int num_entries, status; | 91 | int num_entries, status; |
92 | void *temp; | 92 | void *temp; |
93 | 93 | ||
94 | if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES) | ||
95 | return -EINVAL; | ||
96 | |||
94 | temp = agp_bridge->current_size; | 97 | temp = agp_bridge->current_size; |
95 | num_entries = A_SIZE_FIX(temp)->num_entries; | 98 | num_entries = A_SIZE_FIX(temp)->num_entries; |
96 | if ((pg_start + mem->page_count) > num_entries) | 99 | if ((pg_start + mem->page_count) > num_entries) |
@@ -142,6 +145,7 @@ struct agp_bridge_driver alpha_core_agp_driver = { | |||
142 | .free_by_type = agp_generic_free_by_type, | 145 | .free_by_type = agp_generic_free_by_type, |
143 | .agp_alloc_page = agp_generic_alloc_page, | 146 | .agp_alloc_page = agp_generic_alloc_page, |
144 | .agp_destroy_page = agp_generic_destroy_page, | 147 | .agp_destroy_page = agp_generic_destroy_page, |
148 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
145 | }; | 149 | }; |
146 | 150 | ||
147 | struct agp_bridge_data *alpha_bridge; | 151 | struct agp_bridge_data *alpha_bridge; |
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c index c85c8cadb6df..3d8d448bf394 100644 --- a/drivers/char/agp/amd-k7-agp.c +++ b/drivers/char/agp/amd-k7-agp.c | |||
@@ -381,6 +381,7 @@ static struct agp_bridge_driver amd_irongate_driver = { | |||
381 | .free_by_type = agp_generic_free_by_type, | 381 | .free_by_type = agp_generic_free_by_type, |
382 | .agp_alloc_page = agp_generic_alloc_page, | 382 | .agp_alloc_page = agp_generic_alloc_page, |
383 | .agp_destroy_page = agp_generic_destroy_page, | 383 | .agp_destroy_page = agp_generic_destroy_page, |
384 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
384 | }; | 385 | }; |
385 | 386 | ||
386 | static struct agp_device_ids amd_agp_device_ids[] __devinitdata = | 387 | static struct agp_device_ids amd_agp_device_ids[] __devinitdata = |
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 93d2209fee4c..636d984ed4a6 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -62,12 +62,18 @@ static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
62 | { | 62 | { |
63 | int i, j, num_entries; | 63 | int i, j, num_entries; |
64 | long long tmp; | 64 | long long tmp; |
65 | int mask_type; | ||
66 | struct agp_bridge_data *bridge = mem->bridge; | ||
65 | u32 pte; | 67 | u32 pte; |
66 | 68 | ||
67 | num_entries = agp_num_entries(); | 69 | num_entries = agp_num_entries(); |
68 | 70 | ||
69 | if (type != 0 || mem->type != 0) | 71 | if (type != mem->type) |
70 | return -EINVAL; | 72 | return -EINVAL; |
73 | mask_type = bridge->driver->agp_type_to_mask_type(bridge, type); | ||
74 | if (mask_type != 0) | ||
75 | return -EINVAL; | ||
76 | |||
71 | 77 | ||
72 | /* Make sure we can fit the range in the gatt table. */ | 78 | /* Make sure we can fit the range in the gatt table. */ |
73 | /* FIXME: could wrap */ | 79 | /* FIXME: could wrap */ |
@@ -90,7 +96,7 @@ static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
90 | 96 | ||
91 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 97 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
92 | tmp = agp_bridge->driver->mask_memory(agp_bridge, | 98 | tmp = agp_bridge->driver->mask_memory(agp_bridge, |
93 | mem->memory[i], mem->type); | 99 | mem->memory[i], mask_type); |
94 | 100 | ||
95 | BUG_ON(tmp & 0xffffff0000000ffcULL); | 101 | BUG_ON(tmp & 0xffffff0000000ffcULL); |
96 | pte = (tmp & 0x000000ff00000000ULL) >> 28; | 102 | pte = (tmp & 0x000000ff00000000ULL) >> 28; |
@@ -247,6 +253,7 @@ static struct agp_bridge_driver amd_8151_driver = { | |||
247 | .free_by_type = agp_generic_free_by_type, | 253 | .free_by_type = agp_generic_free_by_type, |
248 | .agp_alloc_page = agp_generic_alloc_page, | 254 | .agp_alloc_page = agp_generic_alloc_page, |
249 | .agp_destroy_page = agp_generic_destroy_page, | 255 | .agp_destroy_page = agp_generic_destroy_page, |
256 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
250 | }; | 257 | }; |
251 | 258 | ||
252 | /* Some basic sanity checks for the aperture. */ | 259 | /* Some basic sanity checks for the aperture. */ |
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c index 9987dc2e0c3f..77c9ad68fba9 100644 --- a/drivers/char/agp/ati-agp.c +++ b/drivers/char/agp/ati-agp.c | |||
@@ -431,6 +431,7 @@ static struct agp_bridge_driver ati_generic_bridge = { | |||
431 | .free_by_type = agp_generic_free_by_type, | 431 | .free_by_type = agp_generic_free_by_type, |
432 | .agp_alloc_page = agp_generic_alloc_page, | 432 | .agp_alloc_page = agp_generic_alloc_page, |
433 | .agp_destroy_page = agp_generic_destroy_page, | 433 | .agp_destroy_page = agp_generic_destroy_page, |
434 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
434 | }; | 435 | }; |
435 | 436 | ||
436 | 437 | ||
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c index d59e037ddd12..ebdd6dd66edb 100644 --- a/drivers/char/agp/backend.c +++ b/drivers/char/agp/backend.c | |||
@@ -43,7 +43,7 @@ | |||
43 | * fix some real stupidity. It's only by chance we can bump | 43 | * fix some real stupidity. It's only by chance we can bump |
44 | * past 0.99 at all due to some boolean logic error. */ | 44 | * past 0.99 at all due to some boolean logic error. */ |
45 | #define AGPGART_VERSION_MAJOR 0 | 45 | #define AGPGART_VERSION_MAJOR 0 |
46 | #define AGPGART_VERSION_MINOR 101 | 46 | #define AGPGART_VERSION_MINOR 102 |
47 | static const struct agp_version agp_current_version = | 47 | static const struct agp_version agp_current_version = |
48 | { | 48 | { |
49 | .major = AGPGART_VERSION_MAJOR, | 49 | .major = AGPGART_VERSION_MAJOR, |
diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c new file mode 100644 index 000000000000..fcb4b1bf0d4e --- /dev/null +++ b/drivers/char/agp/compat_ioctl.c | |||
@@ -0,0 +1,282 @@ | |||
1 | /* | ||
2 | * AGPGART driver frontend compatibility ioctls | ||
3 | * Copyright (C) 2004 Silicon Graphics, Inc. | ||
4 | * Copyright (C) 2002-2003 Dave Jones | ||
5 | * Copyright (C) 1999 Jeff Hartmann | ||
6 | * Copyright (C) 1999 Precision Insight, Inc. | ||
7 | * Copyright (C) 1999 Xi Graphics, Inc. | ||
8 | * | ||
9 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
10 | * copy of this software and associated documentation files (the "Software"), | ||
11 | * to deal in the Software without restriction, including without limitation | ||
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
13 | * and/or sell copies of the Software, and to permit persons to whom the | ||
14 | * Software is furnished to do so, subject to the following conditions: | ||
15 | * | ||
16 | * The above copyright notice and this permission notice shall be included | ||
17 | * in all copies or substantial portions of the Software. | ||
18 | * | ||
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
22 | * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, | ||
23 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
24 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | ||
25 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | #include <linux/kernel.h> | ||
30 | #include <linux/pci.h> | ||
31 | #include <linux/agpgart.h> | ||
32 | #include <asm/uaccess.h> | ||
33 | #include "agp.h" | ||
34 | #include "compat_ioctl.h" | ||
35 | |||
36 | static int compat_agpioc_info_wrap(struct agp_file_private *priv, void __user *arg) | ||
37 | { | ||
38 | struct agp_info32 userinfo; | ||
39 | struct agp_kern_info kerninfo; | ||
40 | |||
41 | agp_copy_info(agp_bridge, &kerninfo); | ||
42 | |||
43 | userinfo.version.major = kerninfo.version.major; | ||
44 | userinfo.version.minor = kerninfo.version.minor; | ||
45 | userinfo.bridge_id = kerninfo.device->vendor | | ||
46 | (kerninfo.device->device << 16); | ||
47 | userinfo.agp_mode = kerninfo.mode; | ||
48 | userinfo.aper_base = (compat_long_t)kerninfo.aper_base; | ||
49 | userinfo.aper_size = kerninfo.aper_size; | ||
50 | userinfo.pg_total = userinfo.pg_system = kerninfo.max_memory; | ||
51 | userinfo.pg_used = kerninfo.current_memory; | ||
52 | |||
53 | if (copy_to_user(arg, &userinfo, sizeof(userinfo))) | ||
54 | return -EFAULT; | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg) | ||
60 | { | ||
61 | struct agp_region32 ureserve; | ||
62 | struct agp_region kreserve; | ||
63 | struct agp_client *client; | ||
64 | struct agp_file_private *client_priv; | ||
65 | |||
66 | DBG(""); | ||
67 | if (copy_from_user(&ureserve, arg, sizeof(ureserve))) | ||
68 | return -EFAULT; | ||
69 | |||
70 | if ((unsigned) ureserve.seg_count >= ~0U/sizeof(struct agp_segment32)) | ||
71 | return -EFAULT; | ||
72 | |||
73 | kreserve.pid = ureserve.pid; | ||
74 | kreserve.seg_count = ureserve.seg_count; | ||
75 | |||
76 | client = agp_find_client_by_pid(kreserve.pid); | ||
77 | |||
78 | if (kreserve.seg_count == 0) { | ||
79 | /* remove a client */ | ||
80 | client_priv = agp_find_private(kreserve.pid); | ||
81 | |||
82 | if (client_priv != NULL) { | ||
83 | set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags); | ||
84 | set_bit(AGP_FF_IS_VALID, &client_priv->access_flags); | ||
85 | } | ||
86 | if (client == NULL) { | ||
87 | /* client is already removed */ | ||
88 | return 0; | ||
89 | } | ||
90 | return agp_remove_client(kreserve.pid); | ||
91 | } else { | ||
92 | struct agp_segment32 *usegment; | ||
93 | struct agp_segment *ksegment; | ||
94 | int seg; | ||
95 | |||
96 | if (ureserve.seg_count >= 16384) | ||
97 | return -EINVAL; | ||
98 | |||
99 | usegment = kmalloc(sizeof(*usegment) * ureserve.seg_count, GFP_KERNEL); | ||
100 | if (!usegment) | ||
101 | return -ENOMEM; | ||
102 | |||
103 | ksegment = kmalloc(sizeof(*ksegment) * kreserve.seg_count, GFP_KERNEL); | ||
104 | if (!ksegment) { | ||
105 | kfree(usegment); | ||
106 | return -ENOMEM; | ||
107 | } | ||
108 | |||
109 | if (copy_from_user(usegment, (void __user *) ureserve.seg_list, | ||
110 | sizeof(*usegment) * ureserve.seg_count)) { | ||
111 | kfree(usegment); | ||
112 | kfree(ksegment); | ||
113 | return -EFAULT; | ||
114 | } | ||
115 | |||
116 | for (seg = 0; seg < ureserve.seg_count; seg++) { | ||
117 | ksegment[seg].pg_start = usegment[seg].pg_start; | ||
118 | ksegment[seg].pg_count = usegment[seg].pg_count; | ||
119 | ksegment[seg].prot = usegment[seg].prot; | ||
120 | } | ||
121 | |||
122 | kfree(usegment); | ||
123 | kreserve.seg_list = ksegment; | ||
124 | |||
125 | if (client == NULL) { | ||
126 | /* Create the client and add the segment */ | ||
127 | client = agp_create_client(kreserve.pid); | ||
128 | |||
129 | if (client == NULL) { | ||
130 | kfree(ksegment); | ||
131 | return -ENOMEM; | ||
132 | } | ||
133 | client_priv = agp_find_private(kreserve.pid); | ||
134 | |||
135 | if (client_priv != NULL) { | ||
136 | set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags); | ||
137 | set_bit(AGP_FF_IS_VALID, &client_priv->access_flags); | ||
138 | } | ||
139 | } | ||
140 | return agp_create_segment(client, &kreserve); | ||
141 | } | ||
142 | /* Will never really happen */ | ||
143 | return -EINVAL; | ||
144 | } | ||
145 | |||
146 | static int compat_agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg) | ||
147 | { | ||
148 | struct agp_memory *memory; | ||
149 | struct agp_allocate32 alloc; | ||
150 | |||
151 | DBG(""); | ||
152 | if (copy_from_user(&alloc, arg, sizeof(alloc))) | ||
153 | return -EFAULT; | ||
154 | |||
155 | memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type); | ||
156 | |||
157 | if (memory == NULL) | ||
158 | return -ENOMEM; | ||
159 | |||
160 | alloc.key = memory->key; | ||
161 | alloc.physical = memory->physical; | ||
162 | |||
163 | if (copy_to_user(arg, &alloc, sizeof(alloc))) { | ||
164 | agp_free_memory_wrap(memory); | ||
165 | return -EFAULT; | ||
166 | } | ||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | static int compat_agpioc_bind_wrap(struct agp_file_private *priv, void __user *arg) | ||
171 | { | ||
172 | struct agp_bind32 bind_info; | ||
173 | struct agp_memory *memory; | ||
174 | |||
175 | DBG(""); | ||
176 | if (copy_from_user(&bind_info, arg, sizeof(bind_info))) | ||
177 | return -EFAULT; | ||
178 | |||
179 | memory = agp_find_mem_by_key(bind_info.key); | ||
180 | |||
181 | if (memory == NULL) | ||
182 | return -EINVAL; | ||
183 | |||
184 | return agp_bind_memory(memory, bind_info.pg_start); | ||
185 | } | ||
186 | |||
187 | static int compat_agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg) | ||
188 | { | ||
189 | struct agp_memory *memory; | ||
190 | struct agp_unbind32 unbind; | ||
191 | |||
192 | DBG(""); | ||
193 | if (copy_from_user(&unbind, arg, sizeof(unbind))) | ||
194 | return -EFAULT; | ||
195 | |||
196 | memory = agp_find_mem_by_key(unbind.key); | ||
197 | |||
198 | if (memory == NULL) | ||
199 | return -EINVAL; | ||
200 | |||
201 | return agp_unbind_memory(memory); | ||
202 | } | ||
203 | |||
204 | long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
205 | { | ||
206 | struct agp_file_private *curr_priv = file->private_data; | ||
207 | int ret_val = -ENOTTY; | ||
208 | |||
209 | mutex_lock(&(agp_fe.agp_mutex)); | ||
210 | |||
211 | if ((agp_fe.current_controller == NULL) && | ||
212 | (cmd != AGPIOC_ACQUIRE32)) { | ||
213 | ret_val = -EINVAL; | ||
214 | goto ioctl_out; | ||
215 | } | ||
216 | if ((agp_fe.backend_acquired != TRUE) && | ||
217 | (cmd != AGPIOC_ACQUIRE32)) { | ||
218 | ret_val = -EBUSY; | ||
219 | goto ioctl_out; | ||
220 | } | ||
221 | if (cmd != AGPIOC_ACQUIRE32) { | ||
222 | if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) { | ||
223 | ret_val = -EPERM; | ||
224 | goto ioctl_out; | ||
225 | } | ||
226 | /* Use the original pid of the controller, | ||
227 | * in case it's threaded */ | ||
228 | |||
229 | if (agp_fe.current_controller->pid != curr_priv->my_pid) { | ||
230 | ret_val = -EBUSY; | ||
231 | goto ioctl_out; | ||
232 | } | ||
233 | } | ||
234 | |||
235 | switch (cmd) { | ||
236 | case AGPIOC_INFO32: | ||
237 | ret_val = compat_agpioc_info_wrap(curr_priv, (void __user *) arg); | ||
238 | break; | ||
239 | |||
240 | case AGPIOC_ACQUIRE32: | ||
241 | ret_val = agpioc_acquire_wrap(curr_priv); | ||
242 | break; | ||
243 | |||
244 | case AGPIOC_RELEASE32: | ||
245 | ret_val = agpioc_release_wrap(curr_priv); | ||
246 | break; | ||
247 | |||
248 | case AGPIOC_SETUP32: | ||
249 | ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg); | ||
250 | break; | ||
251 | |||
252 | case AGPIOC_RESERVE32: | ||
253 | ret_val = compat_agpioc_reserve_wrap(curr_priv, (void __user *) arg); | ||
254 | break; | ||
255 | |||
256 | case AGPIOC_PROTECT32: | ||
257 | ret_val = agpioc_protect_wrap(curr_priv); | ||
258 | break; | ||
259 | |||
260 | case AGPIOC_ALLOCATE32: | ||
261 | ret_val = compat_agpioc_allocate_wrap(curr_priv, (void __user *) arg); | ||
262 | break; | ||
263 | |||
264 | case AGPIOC_DEALLOCATE32: | ||
265 | ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg); | ||
266 | break; | ||
267 | |||
268 | case AGPIOC_BIND32: | ||
269 | ret_val = compat_agpioc_bind_wrap(curr_priv, (void __user *) arg); | ||
270 | break; | ||
271 | |||
272 | case AGPIOC_UNBIND32: | ||
273 | ret_val = compat_agpioc_unbind_wrap(curr_priv, (void __user *) arg); | ||
274 | break; | ||
275 | } | ||
276 | |||
277 | ioctl_out: | ||
278 | DBG("ioctl returns %d\n", ret_val); | ||
279 | mutex_unlock(&(agp_fe.agp_mutex)); | ||
280 | return ret_val; | ||
281 | } | ||
282 | |||
diff --git a/drivers/char/agp/compat_ioctl.h b/drivers/char/agp/compat_ioctl.h new file mode 100644 index 000000000000..71939d637236 --- /dev/null +++ b/drivers/char/agp/compat_ioctl.h | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1999 Jeff Hartmann | ||
3 | * Copyright (C) 1999 Precision Insight, Inc. | ||
4 | * Copyright (C) 1999 Xi Graphics, Inc. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | * copy of this software and associated documentation files (the "Software"), | ||
8 | * to deal in the Software without restriction, including without limitation | ||
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
10 | * and/or sell copies of the Software, and to permit persons to whom the | ||
11 | * Software is furnished to do so, subject to the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be included | ||
14 | * in all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
19 | * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, | ||
20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | ||
22 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #ifndef _AGP_COMPAT_IOCTL_H | ||
27 | #define _AGP_COMPAT_IOCTL_H | ||
28 | |||
29 | #include <linux/compat.h> | ||
30 | #include <linux/agpgart.h> | ||
31 | |||
32 | #define AGPIOC_INFO32 _IOR (AGPIOC_BASE, 0, compat_uptr_t) | ||
33 | #define AGPIOC_ACQUIRE32 _IO (AGPIOC_BASE, 1) | ||
34 | #define AGPIOC_RELEASE32 _IO (AGPIOC_BASE, 2) | ||
35 | #define AGPIOC_SETUP32 _IOW (AGPIOC_BASE, 3, compat_uptr_t) | ||
36 | #define AGPIOC_RESERVE32 _IOW (AGPIOC_BASE, 4, compat_uptr_t) | ||
37 | #define AGPIOC_PROTECT32 _IOW (AGPIOC_BASE, 5, compat_uptr_t) | ||
38 | #define AGPIOC_ALLOCATE32 _IOWR(AGPIOC_BASE, 6, compat_uptr_t) | ||
39 | #define AGPIOC_DEALLOCATE32 _IOW (AGPIOC_BASE, 7, compat_int_t) | ||
40 | #define AGPIOC_BIND32 _IOW (AGPIOC_BASE, 8, compat_uptr_t) | ||
41 | #define AGPIOC_UNBIND32 _IOW (AGPIOC_BASE, 9, compat_uptr_t) | ||
42 | |||
43 | struct agp_info32 { | ||
44 | struct agp_version version; /* version of the driver */ | ||
45 | u32 bridge_id; /* bridge vendor/device */ | ||
46 | u32 agp_mode; /* mode info of bridge */ | ||
47 | compat_long_t aper_base; /* base of aperture */ | ||
48 | compat_size_t aper_size; /* size of aperture */ | ||
49 | compat_size_t pg_total; /* max pages (swap + system) */ | ||
50 | compat_size_t pg_system; /* max pages (system) */ | ||
51 | compat_size_t pg_used; /* current pages used */ | ||
52 | }; | ||
53 | |||
54 | /* | ||
55 | * The "prot" down below needs still a "sleep" flag somehow ... | ||
56 | */ | ||
57 | struct agp_segment32 { | ||
58 | compat_off_t pg_start; /* starting page to populate */ | ||
59 | compat_size_t pg_count; /* number of pages */ | ||
60 | compat_int_t prot; /* prot flags for mmap */ | ||
61 | }; | ||
62 | |||
63 | struct agp_region32 { | ||
64 | compat_pid_t pid; /* pid of process */ | ||
65 | compat_size_t seg_count; /* number of segments */ | ||
66 | struct agp_segment32 *seg_list; | ||
67 | }; | ||
68 | |||
69 | struct agp_allocate32 { | ||
70 | compat_int_t key; /* tag of allocation */ | ||
71 | compat_size_t pg_count; /* number of pages */ | ||
72 | u32 type; /* 0 == normal, other devspec */ | ||
73 | u32 physical; /* device specific (some devices | ||
74 | * need a phys address of the | ||
75 | * actual page behind the gatt | ||
76 | * table) */ | ||
77 | }; | ||
78 | |||
79 | struct agp_bind32 { | ||
80 | compat_int_t key; /* tag of allocation */ | ||
81 | compat_off_t pg_start; /* starting page to populate */ | ||
82 | }; | ||
83 | |||
84 | struct agp_unbind32 { | ||
85 | compat_int_t key; /* tag of allocation */ | ||
86 | u32 priority; /* priority for paging out */ | ||
87 | }; | ||
88 | |||
89 | extern struct agp_front_data agp_fe; | ||
90 | |||
91 | int agpioc_acquire_wrap(struct agp_file_private *priv); | ||
92 | int agpioc_release_wrap(struct agp_file_private *priv); | ||
93 | int agpioc_protect_wrap(struct agp_file_private *priv); | ||
94 | int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg); | ||
95 | int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg); | ||
96 | struct agp_file_private *agp_find_private(pid_t pid); | ||
97 | struct agp_client *agp_create_client(pid_t id); | ||
98 | int agp_remove_client(pid_t id); | ||
99 | int agp_create_segment(struct agp_client *client, struct agp_region *region); | ||
100 | void agp_free_memory_wrap(struct agp_memory *memory); | ||
101 | struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type); | ||
102 | struct agp_memory *agp_find_mem_by_key(int key); | ||
103 | struct agp_client *agp_find_client_by_pid(pid_t id); | ||
104 | |||
105 | #endif /* _AGP_COMPAT_H */ | ||
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c index 30f730ff81c1..658cb1a72d2c 100644 --- a/drivers/char/agp/efficeon-agp.c +++ b/drivers/char/agp/efficeon-agp.c | |||
@@ -335,6 +335,7 @@ static struct agp_bridge_driver efficeon_driver = { | |||
335 | .free_by_type = agp_generic_free_by_type, | 335 | .free_by_type = agp_generic_free_by_type, |
336 | .agp_alloc_page = agp_generic_alloc_page, | 336 | .agp_alloc_page = agp_generic_alloc_page, |
337 | .agp_destroy_page = agp_generic_destroy_page, | 337 | .agp_destroy_page = agp_generic_destroy_page, |
338 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
338 | }; | 339 | }; |
339 | 340 | ||
340 | static int __devinit agp_efficeon_probe(struct pci_dev *pdev, | 341 | static int __devinit agp_efficeon_probe(struct pci_dev *pdev, |
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c index 0f2ed2aa2d81..679d7f972439 100644 --- a/drivers/char/agp/frontend.c +++ b/drivers/char/agp/frontend.c | |||
@@ -41,9 +41,9 @@ | |||
41 | #include <asm/pgtable.h> | 41 | #include <asm/pgtable.h> |
42 | #include "agp.h" | 42 | #include "agp.h" |
43 | 43 | ||
44 | static struct agp_front_data agp_fe; | 44 | struct agp_front_data agp_fe; |
45 | 45 | ||
46 | static struct agp_memory *agp_find_mem_by_key(int key) | 46 | struct agp_memory *agp_find_mem_by_key(int key) |
47 | { | 47 | { |
48 | struct agp_memory *curr; | 48 | struct agp_memory *curr; |
49 | 49 | ||
@@ -159,7 +159,7 @@ static pgprot_t agp_convert_mmap_flags(int prot) | |||
159 | return vm_get_page_prot(prot_bits); | 159 | return vm_get_page_prot(prot_bits); |
160 | } | 160 | } |
161 | 161 | ||
162 | static int agp_create_segment(struct agp_client *client, struct agp_region *region) | 162 | int agp_create_segment(struct agp_client *client, struct agp_region *region) |
163 | { | 163 | { |
164 | struct agp_segment_priv **ret_seg; | 164 | struct agp_segment_priv **ret_seg; |
165 | struct agp_segment_priv *seg; | 165 | struct agp_segment_priv *seg; |
@@ -211,7 +211,7 @@ static void agp_insert_into_pool(struct agp_memory * temp) | |||
211 | 211 | ||
212 | /* File private list routines */ | 212 | /* File private list routines */ |
213 | 213 | ||
214 | static struct agp_file_private *agp_find_private(pid_t pid) | 214 | struct agp_file_private *agp_find_private(pid_t pid) |
215 | { | 215 | { |
216 | struct agp_file_private *curr; | 216 | struct agp_file_private *curr; |
217 | 217 | ||
@@ -266,13 +266,13 @@ static void agp_remove_file_private(struct agp_file_private * priv) | |||
266 | * Wrappers for agp_free_memory & agp_allocate_memory | 266 | * Wrappers for agp_free_memory & agp_allocate_memory |
267 | * These make sure that internal lists are kept updated. | 267 | * These make sure that internal lists are kept updated. |
268 | */ | 268 | */ |
269 | static void agp_free_memory_wrap(struct agp_memory *memory) | 269 | void agp_free_memory_wrap(struct agp_memory *memory) |
270 | { | 270 | { |
271 | agp_remove_from_pool(memory); | 271 | agp_remove_from_pool(memory); |
272 | agp_free_memory(memory); | 272 | agp_free_memory(memory); |
273 | } | 273 | } |
274 | 274 | ||
275 | static struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type) | 275 | struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type) |
276 | { | 276 | { |
277 | struct agp_memory *memory; | 277 | struct agp_memory *memory; |
278 | 278 | ||
@@ -484,7 +484,7 @@ static struct agp_controller *agp_find_controller_for_client(pid_t id) | |||
484 | return NULL; | 484 | return NULL; |
485 | } | 485 | } |
486 | 486 | ||
487 | static struct agp_client *agp_find_client_by_pid(pid_t id) | 487 | struct agp_client *agp_find_client_by_pid(pid_t id) |
488 | { | 488 | { |
489 | struct agp_client *temp; | 489 | struct agp_client *temp; |
490 | 490 | ||
@@ -509,7 +509,7 @@ static void agp_insert_client(struct agp_client *client) | |||
509 | agp_fe.current_controller->num_clients++; | 509 | agp_fe.current_controller->num_clients++; |
510 | } | 510 | } |
511 | 511 | ||
512 | static struct agp_client *agp_create_client(pid_t id) | 512 | struct agp_client *agp_create_client(pid_t id) |
513 | { | 513 | { |
514 | struct agp_client *new_client; | 514 | struct agp_client *new_client; |
515 | 515 | ||
@@ -522,7 +522,7 @@ static struct agp_client *agp_create_client(pid_t id) | |||
522 | return new_client; | 522 | return new_client; |
523 | } | 523 | } |
524 | 524 | ||
525 | static int agp_remove_client(pid_t id) | 525 | int agp_remove_client(pid_t id) |
526 | { | 526 | { |
527 | struct agp_client *client; | 527 | struct agp_client *client; |
528 | struct agp_client *prev_client; | 528 | struct agp_client *prev_client; |
@@ -746,7 +746,7 @@ static int agpioc_info_wrap(struct agp_file_private *priv, void __user *arg) | |||
746 | return 0; | 746 | return 0; |
747 | } | 747 | } |
748 | 748 | ||
749 | static int agpioc_acquire_wrap(struct agp_file_private *priv) | 749 | int agpioc_acquire_wrap(struct agp_file_private *priv) |
750 | { | 750 | { |
751 | struct agp_controller *controller; | 751 | struct agp_controller *controller; |
752 | 752 | ||
@@ -789,14 +789,14 @@ static int agpioc_acquire_wrap(struct agp_file_private *priv) | |||
789 | return 0; | 789 | return 0; |
790 | } | 790 | } |
791 | 791 | ||
792 | static int agpioc_release_wrap(struct agp_file_private *priv) | 792 | int agpioc_release_wrap(struct agp_file_private *priv) |
793 | { | 793 | { |
794 | DBG(""); | 794 | DBG(""); |
795 | agp_controller_release_current(agp_fe.current_controller, priv); | 795 | agp_controller_release_current(agp_fe.current_controller, priv); |
796 | return 0; | 796 | return 0; |
797 | } | 797 | } |
798 | 798 | ||
799 | static int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg) | 799 | int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg) |
800 | { | 800 | { |
801 | struct agp_setup mode; | 801 | struct agp_setup mode; |
802 | 802 | ||
@@ -876,7 +876,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg) | |||
876 | return -EINVAL; | 876 | return -EINVAL; |
877 | } | 877 | } |
878 | 878 | ||
879 | static int agpioc_protect_wrap(struct agp_file_private *priv) | 879 | int agpioc_protect_wrap(struct agp_file_private *priv) |
880 | { | 880 | { |
881 | DBG(""); | 881 | DBG(""); |
882 | /* This function is not currently implemented */ | 882 | /* This function is not currently implemented */ |
@@ -892,6 +892,9 @@ static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg) | |||
892 | if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate))) | 892 | if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate))) |
893 | return -EFAULT; | 893 | return -EFAULT; |
894 | 894 | ||
895 | if (alloc.type >= AGP_USER_TYPES) | ||
896 | return -EINVAL; | ||
897 | |||
895 | memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type); | 898 | memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type); |
896 | 899 | ||
897 | if (memory == NULL) | 900 | if (memory == NULL) |
@@ -907,7 +910,7 @@ static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg) | |||
907 | return 0; | 910 | return 0; |
908 | } | 911 | } |
909 | 912 | ||
910 | static int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg) | 913 | int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg) |
911 | { | 914 | { |
912 | struct agp_memory *memory; | 915 | struct agp_memory *memory; |
913 | 916 | ||
@@ -1043,6 +1046,9 @@ static const struct file_operations agp_fops = | |||
1043 | .read = agp_read, | 1046 | .read = agp_read, |
1044 | .write = agp_write, | 1047 | .write = agp_write, |
1045 | .ioctl = agp_ioctl, | 1048 | .ioctl = agp_ioctl, |
1049 | #ifdef CONFIG_COMPAT | ||
1050 | .compat_ioctl = compat_agp_ioctl, | ||
1051 | #endif | ||
1046 | .mmap = agp_mmap, | 1052 | .mmap = agp_mmap, |
1047 | .open = agp_open, | 1053 | .open = agp_open, |
1048 | .release = agp_release, | 1054 | .release = agp_release, |
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index 3491d6f84bc6..7923337c3d26 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c | |||
@@ -101,6 +101,63 @@ static int agp_get_key(void) | |||
101 | return -1; | 101 | return -1; |
102 | } | 102 | } |
103 | 103 | ||
104 | /* | ||
105 | * Use kmalloc if possible for the page list. Otherwise fall back to | ||
106 | * vmalloc. This speeds things up and also saves memory for small AGP | ||
107 | * regions. | ||
108 | */ | ||
109 | |||
110 | void agp_alloc_page_array(size_t size, struct agp_memory *mem) | ||
111 | { | ||
112 | mem->memory = NULL; | ||
113 | mem->vmalloc_flag = 0; | ||
114 | |||
115 | if (size <= 2*PAGE_SIZE) | ||
116 | mem->memory = kmalloc(size, GFP_KERNEL | __GFP_NORETRY); | ||
117 | if (mem->memory == NULL) { | ||
118 | mem->memory = vmalloc(size); | ||
119 | mem->vmalloc_flag = 1; | ||
120 | } | ||
121 | } | ||
122 | EXPORT_SYMBOL(agp_alloc_page_array); | ||
123 | |||
124 | void agp_free_page_array(struct agp_memory *mem) | ||
125 | { | ||
126 | if (mem->vmalloc_flag) { | ||
127 | vfree(mem->memory); | ||
128 | } else { | ||
129 | kfree(mem->memory); | ||
130 | } | ||
131 | } | ||
132 | EXPORT_SYMBOL(agp_free_page_array); | ||
133 | |||
134 | |||
135 | static struct agp_memory *agp_create_user_memory(unsigned long num_agp_pages) | ||
136 | { | ||
137 | struct agp_memory *new; | ||
138 | unsigned long alloc_size = num_agp_pages*sizeof(struct page *); | ||
139 | |||
140 | new = kzalloc(sizeof(struct agp_memory), GFP_KERNEL); | ||
141 | if (new == NULL) | ||
142 | return NULL; | ||
143 | |||
144 | new->key = agp_get_key(); | ||
145 | |||
146 | if (new->key < 0) { | ||
147 | kfree(new); | ||
148 | return NULL; | ||
149 | } | ||
150 | |||
151 | agp_alloc_page_array(alloc_size, new); | ||
152 | |||
153 | if (new->memory == NULL) { | ||
154 | agp_free_key(new->key); | ||
155 | kfree(new); | ||
156 | return NULL; | ||
157 | } | ||
158 | new->num_scratch_pages = 0; | ||
159 | return new; | ||
160 | } | ||
104 | 161 | ||
105 | struct agp_memory *agp_create_memory(int scratch_pages) | 162 | struct agp_memory *agp_create_memory(int scratch_pages) |
106 | { | 163 | { |
@@ -116,7 +173,8 @@ struct agp_memory *agp_create_memory(int scratch_pages) | |||
116 | kfree(new); | 173 | kfree(new); |
117 | return NULL; | 174 | return NULL; |
118 | } | 175 | } |
119 | new->memory = vmalloc(PAGE_SIZE * scratch_pages); | 176 | |
177 | agp_alloc_page_array(PAGE_SIZE * scratch_pages, new); | ||
120 | 178 | ||
121 | if (new->memory == NULL) { | 179 | if (new->memory == NULL) { |
122 | agp_free_key(new->key); | 180 | agp_free_key(new->key); |
@@ -124,6 +182,7 @@ struct agp_memory *agp_create_memory(int scratch_pages) | |||
124 | return NULL; | 182 | return NULL; |
125 | } | 183 | } |
126 | new->num_scratch_pages = scratch_pages; | 184 | new->num_scratch_pages = scratch_pages; |
185 | new->type = AGP_NORMAL_MEMORY; | ||
127 | return new; | 186 | return new; |
128 | } | 187 | } |
129 | EXPORT_SYMBOL(agp_create_memory); | 188 | EXPORT_SYMBOL(agp_create_memory); |
@@ -146,6 +205,11 @@ void agp_free_memory(struct agp_memory *curr) | |||
146 | if (curr->is_bound == TRUE) | 205 | if (curr->is_bound == TRUE) |
147 | agp_unbind_memory(curr); | 206 | agp_unbind_memory(curr); |
148 | 207 | ||
208 | if (curr->type >= AGP_USER_TYPES) { | ||
209 | agp_generic_free_by_type(curr); | ||
210 | return; | ||
211 | } | ||
212 | |||
149 | if (curr->type != 0) { | 213 | if (curr->type != 0) { |
150 | curr->bridge->driver->free_by_type(curr); | 214 | curr->bridge->driver->free_by_type(curr); |
151 | return; | 215 | return; |
@@ -157,7 +221,7 @@ void agp_free_memory(struct agp_memory *curr) | |||
157 | flush_agp_mappings(); | 221 | flush_agp_mappings(); |
158 | } | 222 | } |
159 | agp_free_key(curr->key); | 223 | agp_free_key(curr->key); |
160 | vfree(curr->memory); | 224 | agp_free_page_array(curr); |
161 | kfree(curr); | 225 | kfree(curr); |
162 | } | 226 | } |
163 | EXPORT_SYMBOL(agp_free_memory); | 227 | EXPORT_SYMBOL(agp_free_memory); |
@@ -188,6 +252,13 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge, | |||
188 | if ((atomic_read(&bridge->current_memory_agp) + page_count) > bridge->max_memory_agp) | 252 | if ((atomic_read(&bridge->current_memory_agp) + page_count) > bridge->max_memory_agp) |
189 | return NULL; | 253 | return NULL; |
190 | 254 | ||
255 | if (type >= AGP_USER_TYPES) { | ||
256 | new = agp_generic_alloc_user(page_count, type); | ||
257 | if (new) | ||
258 | new->bridge = bridge; | ||
259 | return new; | ||
260 | } | ||
261 | |||
191 | if (type != 0) { | 262 | if (type != 0) { |
192 | new = bridge->driver->alloc_by_type(page_count, type); | 263 | new = bridge->driver->alloc_by_type(page_count, type); |
193 | if (new) | 264 | if (new) |
@@ -960,6 +1031,7 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type) | |||
960 | off_t j; | 1031 | off_t j; |
961 | void *temp; | 1032 | void *temp; |
962 | struct agp_bridge_data *bridge; | 1033 | struct agp_bridge_data *bridge; |
1034 | int mask_type; | ||
963 | 1035 | ||
964 | bridge = mem->bridge; | 1036 | bridge = mem->bridge; |
965 | if (!bridge) | 1037 | if (!bridge) |
@@ -995,7 +1067,11 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type) | |||
995 | num_entries -= agp_memory_reserved/PAGE_SIZE; | 1067 | num_entries -= agp_memory_reserved/PAGE_SIZE; |
996 | if (num_entries < 0) num_entries = 0; | 1068 | if (num_entries < 0) num_entries = 0; |
997 | 1069 | ||
998 | if (type != 0 || mem->type != 0) { | 1070 | if (type != mem->type) |
1071 | return -EINVAL; | ||
1072 | |||
1073 | mask_type = bridge->driver->agp_type_to_mask_type(bridge, type); | ||
1074 | if (mask_type != 0) { | ||
999 | /* The generic routines know nothing of memory types */ | 1075 | /* The generic routines know nothing of memory types */ |
1000 | return -EINVAL; | 1076 | return -EINVAL; |
1001 | } | 1077 | } |
@@ -1018,7 +1094,8 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type) | |||
1018 | } | 1094 | } |
1019 | 1095 | ||
1020 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 1096 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
1021 | writel(bridge->driver->mask_memory(bridge, mem->memory[i], mem->type), bridge->gatt_table+j); | 1097 | writel(bridge->driver->mask_memory(bridge, mem->memory[i], mask_type), |
1098 | bridge->gatt_table+j); | ||
1022 | } | 1099 | } |
1023 | readl(bridge->gatt_table+j-1); /* PCI Posting. */ | 1100 | readl(bridge->gatt_table+j-1); /* PCI Posting. */ |
1024 | 1101 | ||
@@ -1032,6 +1109,7 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
1032 | { | 1109 | { |
1033 | size_t i; | 1110 | size_t i; |
1034 | struct agp_bridge_data *bridge; | 1111 | struct agp_bridge_data *bridge; |
1112 | int mask_type; | ||
1035 | 1113 | ||
1036 | bridge = mem->bridge; | 1114 | bridge = mem->bridge; |
1037 | if (!bridge) | 1115 | if (!bridge) |
@@ -1040,7 +1118,11 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
1040 | if (mem->page_count == 0) | 1118 | if (mem->page_count == 0) |
1041 | return 0; | 1119 | return 0; |
1042 | 1120 | ||
1043 | if (type != 0 || mem->type != 0) { | 1121 | if (type != mem->type) |
1122 | return -EINVAL; | ||
1123 | |||
1124 | mask_type = bridge->driver->agp_type_to_mask_type(bridge, type); | ||
1125 | if (mask_type != 0) { | ||
1044 | /* The generic routines know nothing of memory types */ | 1126 | /* The generic routines know nothing of memory types */ |
1045 | return -EINVAL; | 1127 | return -EINVAL; |
1046 | } | 1128 | } |
@@ -1056,22 +1138,40 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
1056 | } | 1138 | } |
1057 | EXPORT_SYMBOL(agp_generic_remove_memory); | 1139 | EXPORT_SYMBOL(agp_generic_remove_memory); |
1058 | 1140 | ||
1059 | |||
1060 | struct agp_memory *agp_generic_alloc_by_type(size_t page_count, int type) | 1141 | struct agp_memory *agp_generic_alloc_by_type(size_t page_count, int type) |
1061 | { | 1142 | { |
1062 | return NULL; | 1143 | return NULL; |
1063 | } | 1144 | } |
1064 | EXPORT_SYMBOL(agp_generic_alloc_by_type); | 1145 | EXPORT_SYMBOL(agp_generic_alloc_by_type); |
1065 | 1146 | ||
1066 | |||
1067 | void agp_generic_free_by_type(struct agp_memory *curr) | 1147 | void agp_generic_free_by_type(struct agp_memory *curr) |
1068 | { | 1148 | { |
1069 | vfree(curr->memory); | 1149 | agp_free_page_array(curr); |
1070 | agp_free_key(curr->key); | 1150 | agp_free_key(curr->key); |
1071 | kfree(curr); | 1151 | kfree(curr); |
1072 | } | 1152 | } |
1073 | EXPORT_SYMBOL(agp_generic_free_by_type); | 1153 | EXPORT_SYMBOL(agp_generic_free_by_type); |
1074 | 1154 | ||
1155 | struct agp_memory *agp_generic_alloc_user(size_t page_count, int type) | ||
1156 | { | ||
1157 | struct agp_memory *new; | ||
1158 | int i; | ||
1159 | int pages; | ||
1160 | |||
1161 | pages = (page_count + ENTRIES_PER_PAGE - 1) / ENTRIES_PER_PAGE; | ||
1162 | new = agp_create_user_memory(page_count); | ||
1163 | if (new == NULL) | ||
1164 | return NULL; | ||
1165 | |||
1166 | for (i = 0; i < page_count; i++) | ||
1167 | new->memory[i] = 0; | ||
1168 | new->page_count = 0; | ||
1169 | new->type = type; | ||
1170 | new->num_scratch_pages = pages; | ||
1171 | |||
1172 | return new; | ||
1173 | } | ||
1174 | EXPORT_SYMBOL(agp_generic_alloc_user); | ||
1075 | 1175 | ||
1076 | /* | 1176 | /* |
1077 | * Basic Page Allocation Routines - | 1177 | * Basic Page Allocation Routines - |
@@ -1165,6 +1265,15 @@ unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, | |||
1165 | } | 1265 | } |
1166 | EXPORT_SYMBOL(agp_generic_mask_memory); | 1266 | EXPORT_SYMBOL(agp_generic_mask_memory); |
1167 | 1267 | ||
1268 | int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge, | ||
1269 | int type) | ||
1270 | { | ||
1271 | if (type >= AGP_USER_TYPES) | ||
1272 | return 0; | ||
1273 | return type; | ||
1274 | } | ||
1275 | EXPORT_SYMBOL(agp_generic_type_to_mask_type); | ||
1276 | |||
1168 | /* | 1277 | /* |
1169 | * These functions are implemented according to the AGPv3 spec, | 1278 | * These functions are implemented according to the AGPv3 spec, |
1170 | * which covers implementation details that had previously been | 1279 | * which covers implementation details that had previously been |
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c index 907fb66ec4a9..847deabf7f9b 100644 --- a/drivers/char/agp/hp-agp.c +++ b/drivers/char/agp/hp-agp.c | |||
@@ -438,6 +438,7 @@ struct agp_bridge_driver hp_zx1_driver = { | |||
438 | .free_by_type = agp_generic_free_by_type, | 438 | .free_by_type = agp_generic_free_by_type, |
439 | .agp_alloc_page = agp_generic_alloc_page, | 439 | .agp_alloc_page = agp_generic_alloc_page, |
440 | .agp_destroy_page = agp_generic_destroy_page, | 440 | .agp_destroy_page = agp_generic_destroy_page, |
441 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
441 | .cant_use_aperture = 1, | 442 | .cant_use_aperture = 1, |
442 | }; | 443 | }; |
443 | 444 | ||
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c index 91769443d8fe..3e7618653abd 100644 --- a/drivers/char/agp/i460-agp.c +++ b/drivers/char/agp/i460-agp.c | |||
@@ -293,6 +293,9 @@ static int i460_insert_memory_small_io_page (struct agp_memory *mem, | |||
293 | pr_debug("i460_insert_memory_small_io_page(mem=%p, pg_start=%ld, type=%d, paddr0=0x%lx)\n", | 293 | pr_debug("i460_insert_memory_small_io_page(mem=%p, pg_start=%ld, type=%d, paddr0=0x%lx)\n", |
294 | mem, pg_start, type, mem->memory[0]); | 294 | mem, pg_start, type, mem->memory[0]); |
295 | 295 | ||
296 | if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES) | ||
297 | return -EINVAL; | ||
298 | |||
296 | io_pg_start = I460_IOPAGES_PER_KPAGE * pg_start; | 299 | io_pg_start = I460_IOPAGES_PER_KPAGE * pg_start; |
297 | 300 | ||
298 | temp = agp_bridge->current_size; | 301 | temp = agp_bridge->current_size; |
@@ -396,6 +399,9 @@ static int i460_insert_memory_large_io_page (struct agp_memory *mem, | |||
396 | struct lp_desc *start, *end, *lp; | 399 | struct lp_desc *start, *end, *lp; |
397 | void *temp; | 400 | void *temp; |
398 | 401 | ||
402 | if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES) | ||
403 | return -EINVAL; | ||
404 | |||
399 | temp = agp_bridge->current_size; | 405 | temp = agp_bridge->current_size; |
400 | num_entries = A_SIZE_8(temp)->num_entries; | 406 | num_entries = A_SIZE_8(temp)->num_entries; |
401 | 407 | ||
@@ -572,6 +578,7 @@ struct agp_bridge_driver intel_i460_driver = { | |||
572 | #endif | 578 | #endif |
573 | .alloc_by_type = agp_generic_alloc_by_type, | 579 | .alloc_by_type = agp_generic_alloc_by_type, |
574 | .free_by_type = agp_generic_free_by_type, | 580 | .free_by_type = agp_generic_free_by_type, |
581 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
575 | .cant_use_aperture = 1, | 582 | .cant_use_aperture = 1, |
576 | }; | 583 | }; |
577 | 584 | ||
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index a3011de51f7c..06b0bb6d982f 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
6 | #include <linux/pci.h> | 6 | #include <linux/pci.h> |
7 | #include <linux/init.h> | 7 | #include <linux/init.h> |
8 | #include <linux/kernel.h> | ||
8 | #include <linux/pagemap.h> | 9 | #include <linux/pagemap.h> |
9 | #include <linux/agp_backend.h> | 10 | #include <linux/agp_backend.h> |
10 | #include "agp.h" | 11 | #include "agp.h" |
@@ -24,6 +25,9 @@ | |||
24 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB) | 25 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB) |
25 | 26 | ||
26 | 27 | ||
28 | extern int agp_memory_reserved; | ||
29 | |||
30 | |||
27 | /* Intel 815 register */ | 31 | /* Intel 815 register */ |
28 | #define INTEL_815_APCONT 0x51 | 32 | #define INTEL_815_APCONT 0x51 |
29 | #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF | 33 | #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF |
@@ -68,12 +72,15 @@ static struct aper_size_info_fixed intel_i810_sizes[] = | |||
68 | 72 | ||
69 | #define AGP_DCACHE_MEMORY 1 | 73 | #define AGP_DCACHE_MEMORY 1 |
70 | #define AGP_PHYS_MEMORY 2 | 74 | #define AGP_PHYS_MEMORY 2 |
75 | #define INTEL_AGP_CACHED_MEMORY 3 | ||
71 | 76 | ||
72 | static struct gatt_mask intel_i810_masks[] = | 77 | static struct gatt_mask intel_i810_masks[] = |
73 | { | 78 | { |
74 | {.mask = I810_PTE_VALID, .type = 0}, | 79 | {.mask = I810_PTE_VALID, .type = 0}, |
75 | {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY}, | 80 | {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY}, |
76 | {.mask = I810_PTE_VALID, .type = 0} | 81 | {.mask = I810_PTE_VALID, .type = 0}, |
82 | {.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED, | ||
83 | .type = INTEL_AGP_CACHED_MEMORY} | ||
77 | }; | 84 | }; |
78 | 85 | ||
79 | static struct _intel_i810_private { | 86 | static struct _intel_i810_private { |
@@ -117,13 +124,15 @@ static int intel_i810_configure(void) | |||
117 | 124 | ||
118 | current_size = A_SIZE_FIX(agp_bridge->current_size); | 125 | current_size = A_SIZE_FIX(agp_bridge->current_size); |
119 | 126 | ||
120 | pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp); | ||
121 | temp &= 0xfff80000; | ||
122 | |||
123 | intel_i810_private.registers = ioremap(temp, 128 * 4096); | ||
124 | if (!intel_i810_private.registers) { | 127 | if (!intel_i810_private.registers) { |
125 | printk(KERN_ERR PFX "Unable to remap memory.\n"); | 128 | pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp); |
126 | return -ENOMEM; | 129 | temp &= 0xfff80000; |
130 | |||
131 | intel_i810_private.registers = ioremap(temp, 128 * 4096); | ||
132 | if (!intel_i810_private.registers) { | ||
133 | printk(KERN_ERR PFX "Unable to remap memory.\n"); | ||
134 | return -ENOMEM; | ||
135 | } | ||
127 | } | 136 | } |
128 | 137 | ||
129 | if ((readl(intel_i810_private.registers+I810_DRAM_CTL) | 138 | if ((readl(intel_i810_private.registers+I810_DRAM_CTL) |
@@ -201,62 +210,79 @@ static void i8xx_destroy_pages(void *addr) | |||
201 | atomic_dec(&agp_bridge->current_memory_agp); | 210 | atomic_dec(&agp_bridge->current_memory_agp); |
202 | } | 211 | } |
203 | 212 | ||
213 | static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge, | ||
214 | int type) | ||
215 | { | ||
216 | if (type < AGP_USER_TYPES) | ||
217 | return type; | ||
218 | else if (type == AGP_USER_CACHED_MEMORY) | ||
219 | return INTEL_AGP_CACHED_MEMORY; | ||
220 | else | ||
221 | return 0; | ||
222 | } | ||
223 | |||
204 | static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, | 224 | static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, |
205 | int type) | 225 | int type) |
206 | { | 226 | { |
207 | int i, j, num_entries; | 227 | int i, j, num_entries; |
208 | void *temp; | 228 | void *temp; |
229 | int ret = -EINVAL; | ||
230 | int mask_type; | ||
209 | 231 | ||
210 | if (mem->page_count == 0) | 232 | if (mem->page_count == 0) |
211 | return 0; | 233 | goto out; |
212 | 234 | ||
213 | temp = agp_bridge->current_size; | 235 | temp = agp_bridge->current_size; |
214 | num_entries = A_SIZE_FIX(temp)->num_entries; | 236 | num_entries = A_SIZE_FIX(temp)->num_entries; |
215 | 237 | ||
216 | if ((pg_start + mem->page_count) > num_entries) | 238 | if ((pg_start + mem->page_count) > num_entries) |
217 | return -EINVAL; | 239 | goto out_err; |
218 | 240 | ||
219 | for (j = pg_start; j < (pg_start + mem->page_count); j++) { | ||
220 | if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) | ||
221 | return -EBUSY; | ||
222 | } | ||
223 | 241 | ||
224 | if (type != 0 || mem->type != 0) { | 242 | for (j = pg_start; j < (pg_start + mem->page_count); j++) { |
225 | if ((type == AGP_DCACHE_MEMORY) && (mem->type == AGP_DCACHE_MEMORY)) { | 243 | if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) { |
226 | /* special insert */ | 244 | ret = -EBUSY; |
227 | if (!mem->is_flushed) { | 245 | goto out_err; |
228 | global_cache_flush(); | ||
229 | mem->is_flushed = TRUE; | ||
230 | } | ||
231 | |||
232 | for (i = pg_start; i < (pg_start + mem->page_count); i++) { | ||
233 | writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, intel_i810_private.registers+I810_PTE_BASE+(i*4)); | ||
234 | } | ||
235 | readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI Posting. */ | ||
236 | |||
237 | agp_bridge->driver->tlb_flush(mem); | ||
238 | return 0; | ||
239 | } | 246 | } |
240 | if ((type == AGP_PHYS_MEMORY) && (mem->type == AGP_PHYS_MEMORY)) | ||
241 | goto insert; | ||
242 | return -EINVAL; | ||
243 | } | 247 | } |
244 | 248 | ||
245 | insert: | 249 | if (type != mem->type) |
246 | if (!mem->is_flushed) { | 250 | goto out_err; |
247 | global_cache_flush(); | ||
248 | mem->is_flushed = TRUE; | ||
249 | } | ||
250 | 251 | ||
251 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 252 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
252 | writel(agp_bridge->driver->mask_memory(agp_bridge, | 253 | |
253 | mem->memory[i], mem->type), | 254 | switch (mask_type) { |
254 | intel_i810_private.registers+I810_PTE_BASE+(j*4)); | 255 | case AGP_DCACHE_MEMORY: |
256 | if (!mem->is_flushed) | ||
257 | global_cache_flush(); | ||
258 | for (i = pg_start; i < (pg_start + mem->page_count); i++) { | ||
259 | writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, | ||
260 | intel_i810_private.registers+I810_PTE_BASE+(i*4)); | ||
261 | } | ||
262 | readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); | ||
263 | break; | ||
264 | case AGP_PHYS_MEMORY: | ||
265 | case AGP_NORMAL_MEMORY: | ||
266 | if (!mem->is_flushed) | ||
267 | global_cache_flush(); | ||
268 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | ||
269 | writel(agp_bridge->driver->mask_memory(agp_bridge, | ||
270 | mem->memory[i], | ||
271 | mask_type), | ||
272 | intel_i810_private.registers+I810_PTE_BASE+(j*4)); | ||
273 | } | ||
274 | readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4)); | ||
275 | break; | ||
276 | default: | ||
277 | goto out_err; | ||
255 | } | 278 | } |
256 | readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4)); /* PCI Posting. */ | ||
257 | 279 | ||
258 | agp_bridge->driver->tlb_flush(mem); | 280 | agp_bridge->driver->tlb_flush(mem); |
259 | return 0; | 281 | out: |
282 | ret = 0; | ||
283 | out_err: | ||
284 | mem->is_flushed = 1; | ||
285 | return ret; | ||
260 | } | 286 | } |
261 | 287 | ||
262 | static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start, | 288 | static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start, |
@@ -337,12 +363,11 @@ static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type) | |||
337 | new->type = AGP_DCACHE_MEMORY; | 363 | new->type = AGP_DCACHE_MEMORY; |
338 | new->page_count = pg_count; | 364 | new->page_count = pg_count; |
339 | new->num_scratch_pages = 0; | 365 | new->num_scratch_pages = 0; |
340 | vfree(new->memory); | 366 | agp_free_page_array(new); |
341 | return new; | 367 | return new; |
342 | } | 368 | } |
343 | if (type == AGP_PHYS_MEMORY) | 369 | if (type == AGP_PHYS_MEMORY) |
344 | return alloc_agpphysmem_i8xx(pg_count, type); | 370 | return alloc_agpphysmem_i8xx(pg_count, type); |
345 | |||
346 | return NULL; | 371 | return NULL; |
347 | } | 372 | } |
348 | 373 | ||
@@ -357,7 +382,7 @@ static void intel_i810_free_by_type(struct agp_memory *curr) | |||
357 | gart_to_virt(curr->memory[0])); | 382 | gart_to_virt(curr->memory[0])); |
358 | global_flush_tlb(); | 383 | global_flush_tlb(); |
359 | } | 384 | } |
360 | vfree(curr->memory); | 385 | agp_free_page_array(curr); |
361 | } | 386 | } |
362 | kfree(curr); | 387 | kfree(curr); |
363 | } | 388 | } |
@@ -619,9 +644,11 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int | |||
619 | { | 644 | { |
620 | int i,j,num_entries; | 645 | int i,j,num_entries; |
621 | void *temp; | 646 | void *temp; |
647 | int ret = -EINVAL; | ||
648 | int mask_type; | ||
622 | 649 | ||
623 | if (mem->page_count == 0) | 650 | if (mem->page_count == 0) |
624 | return 0; | 651 | goto out; |
625 | 652 | ||
626 | temp = agp_bridge->current_size; | 653 | temp = agp_bridge->current_size; |
627 | num_entries = A_SIZE_FIX(temp)->num_entries; | 654 | num_entries = A_SIZE_FIX(temp)->num_entries; |
@@ -631,34 +658,41 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int | |||
631 | pg_start,intel_i830_private.gtt_entries); | 658 | pg_start,intel_i830_private.gtt_entries); |
632 | 659 | ||
633 | printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); | 660 | printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); |
634 | return -EINVAL; | 661 | goto out_err; |
635 | } | 662 | } |
636 | 663 | ||
637 | if ((pg_start + mem->page_count) > num_entries) | 664 | if ((pg_start + mem->page_count) > num_entries) |
638 | return -EINVAL; | 665 | goto out_err; |
639 | 666 | ||
640 | /* The i830 can't check the GTT for entries since its read only, | 667 | /* The i830 can't check the GTT for entries since its read only, |
641 | * depend on the caller to make the correct offset decisions. | 668 | * depend on the caller to make the correct offset decisions. |
642 | */ | 669 | */ |
643 | 670 | ||
644 | if ((type != 0 && type != AGP_PHYS_MEMORY) || | 671 | if (type != mem->type) |
645 | (mem->type != 0 && mem->type != AGP_PHYS_MEMORY)) | 672 | goto out_err; |
646 | return -EINVAL; | 673 | |
674 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); | ||
647 | 675 | ||
648 | if (!mem->is_flushed) { | 676 | if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY && |
677 | mask_type != INTEL_AGP_CACHED_MEMORY) | ||
678 | goto out_err; | ||
679 | |||
680 | if (!mem->is_flushed) | ||
649 | global_cache_flush(); | 681 | global_cache_flush(); |
650 | mem->is_flushed = TRUE; | ||
651 | } | ||
652 | 682 | ||
653 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 683 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
654 | writel(agp_bridge->driver->mask_memory(agp_bridge, | 684 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
655 | mem->memory[i], mem->type), | 685 | mem->memory[i], mask_type), |
656 | intel_i830_private.registers+I810_PTE_BASE+(j*4)); | 686 | intel_i830_private.registers+I810_PTE_BASE+(j*4)); |
657 | } | 687 | } |
658 | readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4)); | 688 | readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4)); |
659 | |||
660 | agp_bridge->driver->tlb_flush(mem); | 689 | agp_bridge->driver->tlb_flush(mem); |
661 | return 0; | 690 | |
691 | out: | ||
692 | ret = 0; | ||
693 | out_err: | ||
694 | mem->is_flushed = 1; | ||
695 | return ret; | ||
662 | } | 696 | } |
663 | 697 | ||
664 | static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start, | 698 | static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start, |
@@ -687,7 +721,6 @@ static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count,int type) | |||
687 | { | 721 | { |
688 | if (type == AGP_PHYS_MEMORY) | 722 | if (type == AGP_PHYS_MEMORY) |
689 | return alloc_agpphysmem_i8xx(pg_count, type); | 723 | return alloc_agpphysmem_i8xx(pg_count, type); |
690 | |||
691 | /* always return NULL for other allocation types for now */ | 724 | /* always return NULL for other allocation types for now */ |
692 | return NULL; | 725 | return NULL; |
693 | } | 726 | } |
@@ -734,9 +767,11 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start, | |||
734 | { | 767 | { |
735 | int i,j,num_entries; | 768 | int i,j,num_entries; |
736 | void *temp; | 769 | void *temp; |
770 | int ret = -EINVAL; | ||
771 | int mask_type; | ||
737 | 772 | ||
738 | if (mem->page_count == 0) | 773 | if (mem->page_count == 0) |
739 | return 0; | 774 | goto out; |
740 | 775 | ||
741 | temp = agp_bridge->current_size; | 776 | temp = agp_bridge->current_size; |
742 | num_entries = A_SIZE_FIX(temp)->num_entries; | 777 | num_entries = A_SIZE_FIX(temp)->num_entries; |
@@ -746,33 +781,41 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start, | |||
746 | pg_start,intel_i830_private.gtt_entries); | 781 | pg_start,intel_i830_private.gtt_entries); |
747 | 782 | ||
748 | printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); | 783 | printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); |
749 | return -EINVAL; | 784 | goto out_err; |
750 | } | 785 | } |
751 | 786 | ||
752 | if ((pg_start + mem->page_count) > num_entries) | 787 | if ((pg_start + mem->page_count) > num_entries) |
753 | return -EINVAL; | 788 | goto out_err; |
754 | 789 | ||
755 | /* The i830 can't check the GTT for entries since its read only, | 790 | /* The i915 can't check the GTT for entries since its read only, |
756 | * depend on the caller to make the correct offset decisions. | 791 | * depend on the caller to make the correct offset decisions. |
757 | */ | 792 | */ |
758 | 793 | ||
759 | if ((type != 0 && type != AGP_PHYS_MEMORY) || | 794 | if (type != mem->type) |
760 | (mem->type != 0 && mem->type != AGP_PHYS_MEMORY)) | 795 | goto out_err; |
761 | return -EINVAL; | 796 | |
797 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); | ||
762 | 798 | ||
763 | if (!mem->is_flushed) { | 799 | if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY && |
800 | mask_type != INTEL_AGP_CACHED_MEMORY) | ||
801 | goto out_err; | ||
802 | |||
803 | if (!mem->is_flushed) | ||
764 | global_cache_flush(); | 804 | global_cache_flush(); |
765 | mem->is_flushed = TRUE; | ||
766 | } | ||
767 | 805 | ||
768 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 806 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
769 | writel(agp_bridge->driver->mask_memory(agp_bridge, | 807 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
770 | mem->memory[i], mem->type), intel_i830_private.gtt+j); | 808 | mem->memory[i], mask_type), intel_i830_private.gtt+j); |
771 | } | 809 | } |
772 | readl(intel_i830_private.gtt+j-1); | ||
773 | 810 | ||
811 | readl(intel_i830_private.gtt+j-1); | ||
774 | agp_bridge->driver->tlb_flush(mem); | 812 | agp_bridge->driver->tlb_flush(mem); |
775 | return 0; | 813 | |
814 | out: | ||
815 | ret = 0; | ||
816 | out_err: | ||
817 | mem->is_flushed = 1; | ||
818 | return ret; | ||
776 | } | 819 | } |
777 | 820 | ||
778 | static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start, | 821 | static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start, |
@@ -803,7 +846,7 @@ static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start, | |||
803 | */ | 846 | */ |
804 | static int intel_i9xx_fetch_size(void) | 847 | static int intel_i9xx_fetch_size(void) |
805 | { | 848 | { |
806 | int num_sizes = sizeof(intel_i830_sizes) / sizeof(*intel_i830_sizes); | 849 | int num_sizes = ARRAY_SIZE(intel_i830_sizes); |
807 | int aper_size; /* size in megabytes */ | 850 | int aper_size; /* size in megabytes */ |
808 | int i; | 851 | int i; |
809 | 852 | ||
@@ -1384,6 +1427,7 @@ static struct agp_bridge_driver intel_generic_driver = { | |||
1384 | .free_by_type = agp_generic_free_by_type, | 1427 | .free_by_type = agp_generic_free_by_type, |
1385 | .agp_alloc_page = agp_generic_alloc_page, | 1428 | .agp_alloc_page = agp_generic_alloc_page, |
1386 | .agp_destroy_page = agp_generic_destroy_page, | 1429 | .agp_destroy_page = agp_generic_destroy_page, |
1430 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1387 | }; | 1431 | }; |
1388 | 1432 | ||
1389 | static struct agp_bridge_driver intel_810_driver = { | 1433 | static struct agp_bridge_driver intel_810_driver = { |
@@ -1408,6 +1452,7 @@ static struct agp_bridge_driver intel_810_driver = { | |||
1408 | .free_by_type = intel_i810_free_by_type, | 1452 | .free_by_type = intel_i810_free_by_type, |
1409 | .agp_alloc_page = agp_generic_alloc_page, | 1453 | .agp_alloc_page = agp_generic_alloc_page, |
1410 | .agp_destroy_page = agp_generic_destroy_page, | 1454 | .agp_destroy_page = agp_generic_destroy_page, |
1455 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1411 | }; | 1456 | }; |
1412 | 1457 | ||
1413 | static struct agp_bridge_driver intel_815_driver = { | 1458 | static struct agp_bridge_driver intel_815_driver = { |
@@ -1431,6 +1476,7 @@ static struct agp_bridge_driver intel_815_driver = { | |||
1431 | .free_by_type = agp_generic_free_by_type, | 1476 | .free_by_type = agp_generic_free_by_type, |
1432 | .agp_alloc_page = agp_generic_alloc_page, | 1477 | .agp_alloc_page = agp_generic_alloc_page, |
1433 | .agp_destroy_page = agp_generic_destroy_page, | 1478 | .agp_destroy_page = agp_generic_destroy_page, |
1479 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1434 | }; | 1480 | }; |
1435 | 1481 | ||
1436 | static struct agp_bridge_driver intel_830_driver = { | 1482 | static struct agp_bridge_driver intel_830_driver = { |
@@ -1455,6 +1501,7 @@ static struct agp_bridge_driver intel_830_driver = { | |||
1455 | .free_by_type = intel_i810_free_by_type, | 1501 | .free_by_type = intel_i810_free_by_type, |
1456 | .agp_alloc_page = agp_generic_alloc_page, | 1502 | .agp_alloc_page = agp_generic_alloc_page, |
1457 | .agp_destroy_page = agp_generic_destroy_page, | 1503 | .agp_destroy_page = agp_generic_destroy_page, |
1504 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1458 | }; | 1505 | }; |
1459 | 1506 | ||
1460 | static struct agp_bridge_driver intel_820_driver = { | 1507 | static struct agp_bridge_driver intel_820_driver = { |
@@ -1478,6 +1525,7 @@ static struct agp_bridge_driver intel_820_driver = { | |||
1478 | .free_by_type = agp_generic_free_by_type, | 1525 | .free_by_type = agp_generic_free_by_type, |
1479 | .agp_alloc_page = agp_generic_alloc_page, | 1526 | .agp_alloc_page = agp_generic_alloc_page, |
1480 | .agp_destroy_page = agp_generic_destroy_page, | 1527 | .agp_destroy_page = agp_generic_destroy_page, |
1528 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1481 | }; | 1529 | }; |
1482 | 1530 | ||
1483 | static struct agp_bridge_driver intel_830mp_driver = { | 1531 | static struct agp_bridge_driver intel_830mp_driver = { |
@@ -1501,6 +1549,7 @@ static struct agp_bridge_driver intel_830mp_driver = { | |||
1501 | .free_by_type = agp_generic_free_by_type, | 1549 | .free_by_type = agp_generic_free_by_type, |
1502 | .agp_alloc_page = agp_generic_alloc_page, | 1550 | .agp_alloc_page = agp_generic_alloc_page, |
1503 | .agp_destroy_page = agp_generic_destroy_page, | 1551 | .agp_destroy_page = agp_generic_destroy_page, |
1552 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1504 | }; | 1553 | }; |
1505 | 1554 | ||
1506 | static struct agp_bridge_driver intel_840_driver = { | 1555 | static struct agp_bridge_driver intel_840_driver = { |
@@ -1524,6 +1573,7 @@ static struct agp_bridge_driver intel_840_driver = { | |||
1524 | .free_by_type = agp_generic_free_by_type, | 1573 | .free_by_type = agp_generic_free_by_type, |
1525 | .agp_alloc_page = agp_generic_alloc_page, | 1574 | .agp_alloc_page = agp_generic_alloc_page, |
1526 | .agp_destroy_page = agp_generic_destroy_page, | 1575 | .agp_destroy_page = agp_generic_destroy_page, |
1576 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1527 | }; | 1577 | }; |
1528 | 1578 | ||
1529 | static struct agp_bridge_driver intel_845_driver = { | 1579 | static struct agp_bridge_driver intel_845_driver = { |
@@ -1547,6 +1597,7 @@ static struct agp_bridge_driver intel_845_driver = { | |||
1547 | .free_by_type = agp_generic_free_by_type, | 1597 | .free_by_type = agp_generic_free_by_type, |
1548 | .agp_alloc_page = agp_generic_alloc_page, | 1598 | .agp_alloc_page = agp_generic_alloc_page, |
1549 | .agp_destroy_page = agp_generic_destroy_page, | 1599 | .agp_destroy_page = agp_generic_destroy_page, |
1600 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1550 | }; | 1601 | }; |
1551 | 1602 | ||
1552 | static struct agp_bridge_driver intel_850_driver = { | 1603 | static struct agp_bridge_driver intel_850_driver = { |
@@ -1570,6 +1621,7 @@ static struct agp_bridge_driver intel_850_driver = { | |||
1570 | .free_by_type = agp_generic_free_by_type, | 1621 | .free_by_type = agp_generic_free_by_type, |
1571 | .agp_alloc_page = agp_generic_alloc_page, | 1622 | .agp_alloc_page = agp_generic_alloc_page, |
1572 | .agp_destroy_page = agp_generic_destroy_page, | 1623 | .agp_destroy_page = agp_generic_destroy_page, |
1624 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1573 | }; | 1625 | }; |
1574 | 1626 | ||
1575 | static struct agp_bridge_driver intel_860_driver = { | 1627 | static struct agp_bridge_driver intel_860_driver = { |
@@ -1593,6 +1645,7 @@ static struct agp_bridge_driver intel_860_driver = { | |||
1593 | .free_by_type = agp_generic_free_by_type, | 1645 | .free_by_type = agp_generic_free_by_type, |
1594 | .agp_alloc_page = agp_generic_alloc_page, | 1646 | .agp_alloc_page = agp_generic_alloc_page, |
1595 | .agp_destroy_page = agp_generic_destroy_page, | 1647 | .agp_destroy_page = agp_generic_destroy_page, |
1648 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1596 | }; | 1649 | }; |
1597 | 1650 | ||
1598 | static struct agp_bridge_driver intel_915_driver = { | 1651 | static struct agp_bridge_driver intel_915_driver = { |
@@ -1617,6 +1670,7 @@ static struct agp_bridge_driver intel_915_driver = { | |||
1617 | .free_by_type = intel_i810_free_by_type, | 1670 | .free_by_type = intel_i810_free_by_type, |
1618 | .agp_alloc_page = agp_generic_alloc_page, | 1671 | .agp_alloc_page = agp_generic_alloc_page, |
1619 | .agp_destroy_page = agp_generic_destroy_page, | 1672 | .agp_destroy_page = agp_generic_destroy_page, |
1673 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1620 | }; | 1674 | }; |
1621 | 1675 | ||
1622 | static struct agp_bridge_driver intel_i965_driver = { | 1676 | static struct agp_bridge_driver intel_i965_driver = { |
@@ -1641,6 +1695,7 @@ static struct agp_bridge_driver intel_i965_driver = { | |||
1641 | .free_by_type = intel_i810_free_by_type, | 1695 | .free_by_type = intel_i810_free_by_type, |
1642 | .agp_alloc_page = agp_generic_alloc_page, | 1696 | .agp_alloc_page = agp_generic_alloc_page, |
1643 | .agp_destroy_page = agp_generic_destroy_page, | 1697 | .agp_destroy_page = agp_generic_destroy_page, |
1698 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1644 | }; | 1699 | }; |
1645 | 1700 | ||
1646 | static struct agp_bridge_driver intel_7505_driver = { | 1701 | static struct agp_bridge_driver intel_7505_driver = { |
@@ -1664,6 +1719,7 @@ static struct agp_bridge_driver intel_7505_driver = { | |||
1664 | .free_by_type = agp_generic_free_by_type, | 1719 | .free_by_type = agp_generic_free_by_type, |
1665 | .agp_alloc_page = agp_generic_alloc_page, | 1720 | .agp_alloc_page = agp_generic_alloc_page, |
1666 | .agp_destroy_page = agp_generic_destroy_page, | 1721 | .agp_destroy_page = agp_generic_destroy_page, |
1722 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1667 | }; | 1723 | }; |
1668 | 1724 | ||
1669 | static int find_i810(u16 device) | 1725 | static int find_i810(u16 device) |
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c index df7f37b2739a..2563286b2fcf 100644 --- a/drivers/char/agp/nvidia-agp.c +++ b/drivers/char/agp/nvidia-agp.c | |||
@@ -310,6 +310,7 @@ static struct agp_bridge_driver nvidia_driver = { | |||
310 | .free_by_type = agp_generic_free_by_type, | 310 | .free_by_type = agp_generic_free_by_type, |
311 | .agp_alloc_page = agp_generic_alloc_page, | 311 | .agp_alloc_page = agp_generic_alloc_page, |
312 | .agp_destroy_page = agp_generic_destroy_page, | 312 | .agp_destroy_page = agp_generic_destroy_page, |
313 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
313 | }; | 314 | }; |
314 | 315 | ||
315 | static int __devinit agp_nvidia_probe(struct pci_dev *pdev, | 316 | static int __devinit agp_nvidia_probe(struct pci_dev *pdev, |
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c index 17c50b0f83f0..b7b4590673ae 100644 --- a/drivers/char/agp/parisc-agp.c +++ b/drivers/char/agp/parisc-agp.c | |||
@@ -228,6 +228,7 @@ struct agp_bridge_driver parisc_agp_driver = { | |||
228 | .free_by_type = agp_generic_free_by_type, | 228 | .free_by_type = agp_generic_free_by_type, |
229 | .agp_alloc_page = agp_generic_alloc_page, | 229 | .agp_alloc_page = agp_generic_alloc_page, |
230 | .agp_destroy_page = agp_generic_destroy_page, | 230 | .agp_destroy_page = agp_generic_destroy_page, |
231 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
231 | .cant_use_aperture = 1, | 232 | .cant_use_aperture = 1, |
232 | }; | 233 | }; |
233 | 234 | ||
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c index 902648db7efa..92d1dc45b9be 100644 --- a/drivers/char/agp/sgi-agp.c +++ b/drivers/char/agp/sgi-agp.c | |||
@@ -265,6 +265,7 @@ struct agp_bridge_driver sgi_tioca_driver = { | |||
265 | .free_by_type = agp_generic_free_by_type, | 265 | .free_by_type = agp_generic_free_by_type, |
266 | .agp_alloc_page = sgi_tioca_alloc_page, | 266 | .agp_alloc_page = sgi_tioca_alloc_page, |
267 | .agp_destroy_page = agp_generic_destroy_page, | 267 | .agp_destroy_page = agp_generic_destroy_page, |
268 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
268 | .cant_use_aperture = 1, | 269 | .cant_use_aperture = 1, |
269 | .needs_scratch_page = 0, | 270 | .needs_scratch_page = 0, |
270 | .num_aperture_sizes = 1, | 271 | .num_aperture_sizes = 1, |
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c index a00fd48a6f05..60342b708152 100644 --- a/drivers/char/agp/sis-agp.c +++ b/drivers/char/agp/sis-agp.c | |||
@@ -140,6 +140,7 @@ static struct agp_bridge_driver sis_driver = { | |||
140 | .free_by_type = agp_generic_free_by_type, | 140 | .free_by_type = agp_generic_free_by_type, |
141 | .agp_alloc_page = agp_generic_alloc_page, | 141 | .agp_alloc_page = agp_generic_alloc_page, |
142 | .agp_destroy_page = agp_generic_destroy_page, | 142 | .agp_destroy_page = agp_generic_destroy_page, |
143 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
143 | }; | 144 | }; |
144 | 145 | ||
145 | static struct agp_device_ids sis_agp_device_ids[] __devinitdata = | 146 | static struct agp_device_ids sis_agp_device_ids[] __devinitdata = |
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c index 4f2d7d99902f..9f5ae7714f85 100644 --- a/drivers/char/agp/sworks-agp.c +++ b/drivers/char/agp/sworks-agp.c | |||
@@ -444,6 +444,7 @@ static struct agp_bridge_driver sworks_driver = { | |||
444 | .free_by_type = agp_generic_free_by_type, | 444 | .free_by_type = agp_generic_free_by_type, |
445 | .agp_alloc_page = agp_generic_alloc_page, | 445 | .agp_alloc_page = agp_generic_alloc_page, |
446 | .agp_destroy_page = agp_generic_destroy_page, | 446 | .agp_destroy_page = agp_generic_destroy_page, |
447 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
447 | }; | 448 | }; |
448 | 449 | ||
449 | static int __devinit agp_serverworks_probe(struct pci_dev *pdev, | 450 | static int __devinit agp_serverworks_probe(struct pci_dev *pdev, |
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index dffc19382f7e..6c45702e542c 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c | |||
@@ -510,6 +510,7 @@ struct agp_bridge_driver uninorth_agp_driver = { | |||
510 | .free_by_type = agp_generic_free_by_type, | 510 | .free_by_type = agp_generic_free_by_type, |
511 | .agp_alloc_page = agp_generic_alloc_page, | 511 | .agp_alloc_page = agp_generic_alloc_page, |
512 | .agp_destroy_page = agp_generic_destroy_page, | 512 | .agp_destroy_page = agp_generic_destroy_page, |
513 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
513 | .cant_use_aperture = 1, | 514 | .cant_use_aperture = 1, |
514 | }; | 515 | }; |
515 | 516 | ||
@@ -534,6 +535,7 @@ struct agp_bridge_driver u3_agp_driver = { | |||
534 | .free_by_type = agp_generic_free_by_type, | 535 | .free_by_type = agp_generic_free_by_type, |
535 | .agp_alloc_page = agp_generic_alloc_page, | 536 | .agp_alloc_page = agp_generic_alloc_page, |
536 | .agp_destroy_page = agp_generic_destroy_page, | 537 | .agp_destroy_page = agp_generic_destroy_page, |
538 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
537 | .cant_use_aperture = 1, | 539 | .cant_use_aperture = 1, |
538 | .needs_scratch_page = 1, | 540 | .needs_scratch_page = 1, |
539 | }; | 541 | }; |
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c index 2ded7a280d7f..2e7c04370cd9 100644 --- a/drivers/char/agp/via-agp.c +++ b/drivers/char/agp/via-agp.c | |||
@@ -191,6 +191,7 @@ static struct agp_bridge_driver via_agp3_driver = { | |||
191 | .free_by_type = agp_generic_free_by_type, | 191 | .free_by_type = agp_generic_free_by_type, |
192 | .agp_alloc_page = agp_generic_alloc_page, | 192 | .agp_alloc_page = agp_generic_alloc_page, |
193 | .agp_destroy_page = agp_generic_destroy_page, | 193 | .agp_destroy_page = agp_generic_destroy_page, |
194 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
194 | }; | 195 | }; |
195 | 196 | ||
196 | static struct agp_bridge_driver via_driver = { | 197 | static struct agp_bridge_driver via_driver = { |
@@ -214,6 +215,7 @@ static struct agp_bridge_driver via_driver = { | |||
214 | .free_by_type = agp_generic_free_by_type, | 215 | .free_by_type = agp_generic_free_by_type, |
215 | .agp_alloc_page = agp_generic_alloc_page, | 216 | .agp_alloc_page = agp_generic_alloc_page, |
216 | .agp_destroy_page = agp_generic_destroy_page, | 217 | .agp_destroy_page = agp_generic_destroy_page, |
218 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
217 | }; | 219 | }; |
218 | 220 | ||
219 | static struct agp_device_ids via_agp_device_ids[] __devinitdata = | 221 | static struct agp_device_ids via_agp_device_ids[] __devinitdata = |
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c index 7f60a18ef76b..8dcf9d20f449 100644 --- a/drivers/char/briq_panel.c +++ b/drivers/char/briq_panel.c | |||
@@ -8,7 +8,6 @@ | |||
8 | 8 | ||
9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
11 | #include <linux/sched.h> | ||
12 | #include <linux/tty.h> | 11 | #include <linux/tty.h> |
13 | #include <linux/timer.h> | 12 | #include <linux/timer.h> |
14 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
diff --git a/drivers/char/drm/ffb_context.c b/drivers/char/drm/ffb_context.c index 1383727b443a..ac9ab40d57aa 100644 --- a/drivers/char/drm/ffb_context.c +++ b/drivers/char/drm/ffb_context.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * for authors. | 7 | * for authors. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/sched.h> | ||
11 | #include <asm/upa.h> | 10 | #include <asm/upa.h> |
12 | 11 | ||
13 | #include "ffb.h" | 12 | #include "ffb.h" |
diff --git a/drivers/char/drm/ffb_drv.c b/drivers/char/drm/ffb_drv.c index dd45111a4854..9a19879e3b68 100644 --- a/drivers/char/drm/ffb_drv.c +++ b/drivers/char/drm/ffb_drv.c | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | #include "ffb_drv.h" | 10 | #include "ffb_drv.h" |
11 | 11 | ||
12 | #include <linux/sched.h> | ||
13 | #include <linux/smp_lock.h> | 12 | #include <linux/smp_lock.h> |
14 | #include <asm/shmparam.h> | 13 | #include <asm/shmparam.h> |
15 | #include <asm/oplib.h> | 14 | #include <asm/oplib.h> |
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c index 48cb8f0e8ebf..3d7efc26aad6 100644 --- a/drivers/char/ds1620.c +++ b/drivers/char/ds1620.c | |||
@@ -3,7 +3,6 @@ | |||
3 | * thermometer driver (as used in the Rebel.com NetWinder) | 3 | * thermometer driver (as used in the Rebel.com NetWinder) |
4 | */ | 4 | */ |
5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
6 | #include <linux/sched.h> | ||
7 | #include <linux/miscdevice.h> | 6 | #include <linux/miscdevice.h> |
8 | #include <linux/smp_lock.h> | 7 | #include <linux/smp_lock.h> |
9 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index 06f2dbf17710..db984e481d4c 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c | |||
@@ -25,7 +25,6 @@ | |||
25 | 25 | ||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/slab.h> /* for kmalloc() and kfree() */ | 27 | #include <linux/slab.h> /* for kmalloc() and kfree() */ |
28 | #include <linux/sched.h> /* for struct wait_queue etc */ | ||
29 | #include <linux/major.h> | 28 | #include <linux/major.h> |
30 | #include <linux/types.h> | 29 | #include <linux/types.h> |
31 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c index 1aa93a752a9c..ae76a9ffe89f 100644 --- a/drivers/char/hangcheck-timer.c +++ b/drivers/char/hangcheck-timer.c | |||
@@ -117,7 +117,7 @@ __setup("hcheck_reboot", hangcheck_parse_reboot); | |||
117 | __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); | 117 | __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); |
118 | #endif /* not MODULE */ | 118 | #endif /* not MODULE */ |
119 | 119 | ||
120 | #if defined(CONFIG_X86_64) || defined(CONFIG_S390) | 120 | #if defined(CONFIG_S390) |
121 | # define HAVE_MONOTONIC | 121 | # define HAVE_MONOTONIC |
122 | # define TIMER_FREQ 1000000000ULL | 122 | # define TIMER_FREQ 1000000000ULL |
123 | #elif defined(CONFIG_IA64) | 123 | #elif defined(CONFIG_IA64) |
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 20dc3be5ecfc..0be700f4e8fd 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c | |||
@@ -703,7 +703,7 @@ int hpet_control(struct hpet_task *tp, unsigned int cmd, unsigned long arg) | |||
703 | 703 | ||
704 | static ctl_table hpet_table[] = { | 704 | static ctl_table hpet_table[] = { |
705 | { | 705 | { |
706 | .ctl_name = 1, | 706 | .ctl_name = CTL_UNNUMBERED, |
707 | .procname = "max-user-freq", | 707 | .procname = "max-user-freq", |
708 | .data = &hpet_max_freq, | 708 | .data = &hpet_max_freq, |
709 | .maxlen = sizeof(int), | 709 | .maxlen = sizeof(int), |
@@ -715,7 +715,7 @@ static ctl_table hpet_table[] = { | |||
715 | 715 | ||
716 | static ctl_table hpet_root[] = { | 716 | static ctl_table hpet_root[] = { |
717 | { | 717 | { |
718 | .ctl_name = 1, | 718 | .ctl_name = CTL_UNNUMBERED, |
719 | .procname = "hpet", | 719 | .procname = "hpet", |
720 | .maxlen = 0, | 720 | .maxlen = 0, |
721 | .mode = 0555, | 721 | .mode = 0555, |
@@ -1018,7 +1018,7 @@ static int __init hpet_init(void) | |||
1018 | if (result < 0) | 1018 | if (result < 0) |
1019 | return -ENODEV; | 1019 | return -ENODEV; |
1020 | 1020 | ||
1021 | sysctl_header = register_sysctl_table(dev_root, 0); | 1021 | sysctl_header = register_sysctl_table(dev_root); |
1022 | 1022 | ||
1023 | result = acpi_bus_register_driver(&hpet_acpi_driver); | 1023 | result = acpi_bus_register_driver(&hpet_acpi_driver); |
1024 | if (result < 0) { | 1024 | if (result < 0) { |
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c index d7806834fc17..50315d6364fd 100644 --- a/drivers/char/hvsi.c +++ b/drivers/char/hvsi.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/module.h> | 39 | #include <linux/module.h> |
40 | #include <linux/major.h> | 40 | #include <linux/major.h> |
41 | #include <linux/kernel.h> | 41 | #include <linux/kernel.h> |
42 | #include <linux/sched.h> | ||
43 | #include <linux/spinlock.h> | 42 | #include <linux/spinlock.h> |
44 | #include <linux/sysrq.h> | 43 | #include <linux/sysrq.h> |
45 | #include <linux/tty.h> | 44 | #include <linux/tty.h> |
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index ff2d052177cb..c2aa44ee6eb6 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/moduleparam.h> | 35 | #include <linux/moduleparam.h> |
36 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
37 | #include <asm/system.h> | 37 | #include <asm/system.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/poll.h> | 38 | #include <linux/poll.h> |
40 | #include <linux/spinlock.h> | 39 | #include <linux/spinlock.h> |
41 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 3aff5e99b674..8e222f2b80cc 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
36 | #include <asm/system.h> | 36 | #include <asm/system.h> |
37 | #include <linux/sched.h> | ||
38 | #include <linux/poll.h> | 37 | #include <linux/poll.h> |
39 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
40 | #include <linux/mutex.h> | 39 | #include <linux/mutex.h> |
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c index 9d23136e598a..e02893b7b300 100644 --- a/drivers/char/ipmi/ipmi_poweroff.c +++ b/drivers/char/ipmi/ipmi_poweroff.c | |||
@@ -686,7 +686,7 @@ static int ipmi_poweroff_init (void) | |||
686 | printk(KERN_INFO PFX "Power cycle is enabled.\n"); | 686 | printk(KERN_INFO PFX "Power cycle is enabled.\n"); |
687 | 687 | ||
688 | #ifdef CONFIG_PROC_FS | 688 | #ifdef CONFIG_PROC_FS |
689 | ipmi_table_header = register_sysctl_table(ipmi_root_table, 1); | 689 | ipmi_table_header = register_sysctl_table(ipmi_root_table); |
690 | if (!ipmi_table_header) { | 690 | if (!ipmi_table_header) { |
691 | printk(KERN_ERR PFX "Unable to register powercycle sysctl\n"); | 691 | printk(KERN_ERR PFX "Unable to register powercycle sysctl\n"); |
692 | rv = -ENOMEM; | 692 | rv = -ENOMEM; |
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index c654a3e0c697..cb8d691576da 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c | |||
@@ -596,7 +596,6 @@ static void fn_spawn_con(struct vc_data *vc) | |||
596 | static void fn_SAK(struct vc_data *vc) | 596 | static void fn_SAK(struct vc_data *vc) |
597 | { | 597 | { |
598 | struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work; | 598 | struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work; |
599 | PREPARE_WORK(SAK_work, vc_SAK); | ||
600 | schedule_work(SAK_work); | 599 | schedule_work(SAK_work); |
601 | } | 600 | } |
602 | 601 | ||
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index a39f19c35a6a..204deaa0de80 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #define NVRAM_VERSION "1.2" | 37 | #define NVRAM_VERSION "1.2" |
38 | 38 | ||
39 | #include <linux/module.h> | 39 | #include <linux/module.h> |
40 | #include <linux/sched.h> | ||
41 | #include <linux/smp_lock.h> | 40 | #include <linux/smp_lock.h> |
42 | #include <linux/nvram.h> | 41 | #include <linux/nvram.h> |
43 | 42 | ||
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c index 206cf6f50695..ba012c2bdf7a 100644 --- a/drivers/char/nwflash.c +++ b/drivers/char/nwflash.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/proc_fs.h> | 23 | #include <linux/proc_fs.h> |
24 | #include <linux/sched.h> | ||
25 | #include <linux/miscdevice.h> | 24 | #include <linux/miscdevice.h> |
26 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
27 | #include <linux/rwsem.h> | 26 | #include <linux/rwsem.h> |
diff --git a/drivers/char/pty.c b/drivers/char/pty.c index c07a1b5cd05d..de14aea34e11 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/module.h> /* For EXPORT_SYMBOL */ | 14 | #include <linux/module.h> /* For EXPORT_SYMBOL */ |
15 | 15 | ||
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
19 | #include <linux/tty.h> | 18 | #include <linux/tty.h> |
20 | #include <linux/tty_flip.h> | 19 | #include <linux/tty_flip.h> |
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index b6d3072dce5a..c7dac9b13351 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -282,7 +282,7 @@ irqreturn_t rtc_interrupt(int irq, void *dev_id) | |||
282 | */ | 282 | */ |
283 | static ctl_table rtc_table[] = { | 283 | static ctl_table rtc_table[] = { |
284 | { | 284 | { |
285 | .ctl_name = 1, | 285 | .ctl_name = CTL_UNNUMBERED, |
286 | .procname = "max-user-freq", | 286 | .procname = "max-user-freq", |
287 | .data = &rtc_max_user_freq, | 287 | .data = &rtc_max_user_freq, |
288 | .maxlen = sizeof(int), | 288 | .maxlen = sizeof(int), |
@@ -294,9 +294,8 @@ static ctl_table rtc_table[] = { | |||
294 | 294 | ||
295 | static ctl_table rtc_root[] = { | 295 | static ctl_table rtc_root[] = { |
296 | { | 296 | { |
297 | .ctl_name = 1, | 297 | .ctl_name = CTL_UNNUMBERED, |
298 | .procname = "rtc", | 298 | .procname = "rtc", |
299 | .maxlen = 0, | ||
300 | .mode = 0555, | 299 | .mode = 0555, |
301 | .child = rtc_table, | 300 | .child = rtc_table, |
302 | }, | 301 | }, |
@@ -307,7 +306,6 @@ static ctl_table dev_root[] = { | |||
307 | { | 306 | { |
308 | .ctl_name = CTL_DEV, | 307 | .ctl_name = CTL_DEV, |
309 | .procname = "dev", | 308 | .procname = "dev", |
310 | .maxlen = 0, | ||
311 | .mode = 0555, | 309 | .mode = 0555, |
312 | .child = rtc_root, | 310 | .child = rtc_root, |
313 | }, | 311 | }, |
@@ -318,7 +316,7 @@ static struct ctl_table_header *sysctl_header; | |||
318 | 316 | ||
319 | static int __init init_sysctl(void) | 317 | static int __init init_sysctl(void) |
320 | { | 318 | { |
321 | sysctl_header = register_sysctl_table(dev_root, 0); | 319 | sysctl_header = register_sysctl_table(dev_root); |
322 | return 0; | 320 | return 0; |
323 | } | 321 | } |
324 | 322 | ||
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c index 75de5f66517a..3c869145bfdc 100644 --- a/drivers/char/ser_a2232.c +++ b/drivers/char/ser_a2232.c | |||
@@ -86,7 +86,6 @@ | |||
86 | #include <linux/module.h> | 86 | #include <linux/module.h> |
87 | 87 | ||
88 | #include <linux/types.h> | 88 | #include <linux/types.h> |
89 | #include <linux/sched.h> | ||
90 | #include <linux/interrupt.h> | 89 | #include <linux/interrupt.h> |
91 | #include <linux/kernel.h> | 90 | #include <linux/kernel.h> |
92 | #include <linux/errno.h> | 91 | #include <linux/errno.h> |
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 17d54e1331b2..78237577b05a 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <linux/module.h> | 36 | #include <linux/module.h> |
37 | #include <linux/input.h> | 37 | #include <linux/input.h> |
38 | #include <linux/pci.h> | 38 | #include <linux/pci.h> |
39 | #include <linux/sched.h> | ||
40 | #include <linux/init.h> | 39 | #include <linux/init.h> |
41 | #include <linux/interrupt.h> | 40 | #include <linux/interrupt.h> |
42 | #include <linux/miscdevice.h> | 41 | #include <linux/miscdevice.h> |
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index 3757610b7835..1d8c4ae61551 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/workqueue.h> | 36 | #include <linux/workqueue.h> |
37 | #include <linux/kexec.h> | 37 | #include <linux/kexec.h> |
38 | #include <linux/irq.h> | 38 | #include <linux/irq.h> |
39 | #include <linux/hrtimer.h> | ||
39 | 40 | ||
40 | #include <asm/ptrace.h> | 41 | #include <asm/ptrace.h> |
41 | #include <asm/irq_regs.h> | 42 | #include <asm/irq_regs.h> |
@@ -89,7 +90,6 @@ static struct sysrq_key_op sysrq_loglevel_op = { | |||
89 | static void sysrq_handle_SAK(int key, struct tty_struct *tty) | 90 | static void sysrq_handle_SAK(int key, struct tty_struct *tty) |
90 | { | 91 | { |
91 | struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work; | 92 | struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work; |
92 | PREPARE_WORK(SAK_work, vc_SAK); | ||
93 | schedule_work(SAK_work); | 93 | schedule_work(SAK_work); |
94 | } | 94 | } |
95 | static struct sysrq_key_op sysrq_SAK_op = { | 95 | static struct sysrq_key_op sysrq_SAK_op = { |
@@ -159,6 +159,17 @@ static struct sysrq_key_op sysrq_sync_op = { | |||
159 | .enable_mask = SYSRQ_ENABLE_SYNC, | 159 | .enable_mask = SYSRQ_ENABLE_SYNC, |
160 | }; | 160 | }; |
161 | 161 | ||
162 | static void sysrq_handle_show_timers(int key, struct tty_struct *tty) | ||
163 | { | ||
164 | sysrq_timer_list_show(); | ||
165 | } | ||
166 | |||
167 | static struct sysrq_key_op sysrq_show_timers_op = { | ||
168 | .handler = sysrq_handle_show_timers, | ||
169 | .help_msg = "show-all-timers(Q)", | ||
170 | .action_msg = "Show Pending Timers", | ||
171 | }; | ||
172 | |||
162 | static void sysrq_handle_mountro(int key, struct tty_struct *tty) | 173 | static void sysrq_handle_mountro(int key, struct tty_struct *tty) |
163 | { | 174 | { |
164 | emergency_remount(); | 175 | emergency_remount(); |
@@ -336,7 +347,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = { | |||
336 | /* o: This will often be registered as 'Off' at init time */ | 347 | /* o: This will often be registered as 'Off' at init time */ |
337 | NULL, /* o */ | 348 | NULL, /* o */ |
338 | &sysrq_showregs_op, /* p */ | 349 | &sysrq_showregs_op, /* p */ |
339 | NULL, /* q */ | 350 | &sysrq_show_timers_op, /* q */ |
340 | &sysrq_unraw_op, /* r */ | 351 | &sysrq_unraw_op, /* r */ |
341 | &sysrq_sync_op, /* s */ | 352 | &sysrq_sync_op, /* s */ |
342 | &sysrq_showstate_op, /* t */ | 353 | &sysrq_showstate_op, /* t */ |
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c index 4fac2bdf6215..35e58030d296 100644 --- a/drivers/char/tlclk.c +++ b/drivers/char/tlclk.c | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/sched.h> | ||
33 | #include <linux/kernel.h> /* printk() */ | 32 | #include <linux/kernel.h> /* printk() */ |
34 | #include <linux/fs.h> /* everything... */ | 33 | #include <linux/fs.h> /* everything... */ |
35 | #include <linux/errno.h> /* error codes */ | 34 | #include <linux/errno.h> /* error codes */ |
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c index c346ec5a3dc9..5422f999636f 100644 --- a/drivers/char/toshiba.c +++ b/drivers/char/toshiba.c | |||
@@ -58,7 +58,6 @@ | |||
58 | 58 | ||
59 | #include <linux/module.h> | 59 | #include <linux/module.h> |
60 | #include <linux/kernel.h> | 60 | #include <linux/kernel.h> |
61 | #include <linux/sched.h> | ||
62 | #include <linux/types.h> | 61 | #include <linux/types.h> |
63 | #include <linux/fcntl.h> | 62 | #include <linux/fcntl.h> |
64 | #include <linux/miscdevice.h> | 63 | #include <linux/miscdevice.h> |
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 2f572b97c16d..e5a254a434f8 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -23,7 +23,6 @@ | |||
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/sched.h> | ||
27 | #include <linux/poll.h> | 26 | #include <linux/poll.h> |
28 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
29 | #include "tpm.h" | 28 | #include "tpm.h" |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 65672c57470b..5289254e7ab3 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -3442,7 +3442,6 @@ void do_SAK(struct tty_struct *tty) | |||
3442 | { | 3442 | { |
3443 | if (!tty) | 3443 | if (!tty) |
3444 | return; | 3444 | return; |
3445 | PREPARE_WORK(&tty->SAK_work, do_SAK_work); | ||
3446 | schedule_work(&tty->SAK_work); | 3445 | schedule_work(&tty->SAK_work); |
3447 | } | 3446 | } |
3448 | 3447 | ||
@@ -3568,7 +3567,7 @@ static void initialize_tty_struct(struct tty_struct *tty) | |||
3568 | mutex_init(&tty->atomic_write_lock); | 3567 | mutex_init(&tty->atomic_write_lock); |
3569 | spin_lock_init(&tty->read_lock); | 3568 | spin_lock_init(&tty->read_lock); |
3570 | INIT_LIST_HEAD(&tty->tty_files); | 3569 | INIT_LIST_HEAD(&tty->tty_files); |
3571 | INIT_WORK(&tty->SAK_work, NULL); | 3570 | INIT_WORK(&tty->SAK_work, do_SAK_work); |
3572 | } | 3571 | } |
3573 | 3572 | ||
3574 | /* | 3573 | /* |
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c index 26776517f04c..791930320a13 100644 --- a/drivers/char/vc_screen.c +++ b/drivers/char/vc_screen.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/major.h> | 25 | #include <linux/major.h> |
26 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
27 | #include <linux/tty.h> | 27 | #include <linux/tty.h> |
28 | #include <linux/sched.h> | ||
29 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
30 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c index e01317cb1a0e..bef6d886d4fb 100644 --- a/drivers/char/vme_scc.c +++ b/drivers/char/vme_scc.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/kdev_t.h> | 17 | #include <linux/kdev_t.h> |
18 | #include <asm/io.h> | 18 | #include <asm/io.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/ioport.h> | 20 | #include <linux/ioport.h> |
22 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
23 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 94ce3e7fc9e4..c3f8e383933b 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -2635,6 +2635,7 @@ static int __init con_init(void) | |||
2635 | */ | 2635 | */ |
2636 | for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) { | 2636 | for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) { |
2637 | vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data)); | 2637 | vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data)); |
2638 | INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); | ||
2638 | visual_init(vc, currcons, 1); | 2639 | visual_init(vc, currcons, 1); |
2639 | vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size); | 2640 | vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size); |
2640 | vc->vc_kmalloced = 0; | 2641 | vc->vc_kmalloced = 0; |
diff --git a/drivers/char/watchdog/acquirewdt.c b/drivers/char/watchdog/acquirewdt.c index 154d67e591e5..85269c365a10 100644 --- a/drivers/char/watchdog/acquirewdt.c +++ b/drivers/char/watchdog/acquirewdt.c | |||
@@ -48,46 +48,52 @@ | |||
48 | * It can be 1, 2, 10, 20, 110 or 220 seconds. | 48 | * It can be 1, 2, 10, 20, 110 or 220 seconds. |
49 | */ | 49 | */ |
50 | 50 | ||
51 | #include <linux/module.h> | 51 | /* |
52 | #include <linux/moduleparam.h> | 52 | * Includes, defines, variables, module parameters, ... |
53 | #include <linux/types.h> | 53 | */ |
54 | #include <linux/miscdevice.h> | ||
55 | #include <linux/watchdog.h> | ||
56 | #include <linux/fs.h> | ||
57 | #include <linux/ioport.h> | ||
58 | #include <linux/notifier.h> | ||
59 | #include <linux/reboot.h> | ||
60 | #include <linux/init.h> | ||
61 | |||
62 | #include <asm/io.h> | ||
63 | #include <asm/uaccess.h> | ||
64 | #include <asm/system.h> | ||
65 | 54 | ||
55 | /* Includes */ | ||
56 | #include <linux/module.h> /* For module specific items */ | ||
57 | #include <linux/moduleparam.h> /* For new moduleparam's */ | ||
58 | #include <linux/types.h> /* For standard types (like size_t) */ | ||
59 | #include <linux/errno.h> /* For the -ENODEV/... values */ | ||
60 | #include <linux/kernel.h> /* For printk/panic/... */ | ||
61 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ | ||
62 | #include <linux/watchdog.h> /* For the watchdog specific items */ | ||
63 | #include <linux/fs.h> /* For file operations */ | ||
64 | #include <linux/ioport.h> /* For io-port access */ | ||
65 | #include <linux/platform_device.h> /* For platform_driver framework */ | ||
66 | #include <linux/init.h> /* For __init/__exit/... */ | ||
67 | |||
68 | #include <asm/uaccess.h> /* For copy_to_user/put_user/... */ | ||
69 | #include <asm/io.h> /* For inb/outb/... */ | ||
70 | |||
71 | /* Module information */ | ||
72 | #define DRV_NAME "acquirewdt" | ||
73 | #define PFX DRV_NAME ": " | ||
66 | #define WATCHDOG_NAME "Acquire WDT" | 74 | #define WATCHDOG_NAME "Acquire WDT" |
67 | #define PFX WATCHDOG_NAME ": " | ||
68 | #define WATCHDOG_HEARTBEAT 0 /* There is no way to see what the correct time-out period is */ | 75 | #define WATCHDOG_HEARTBEAT 0 /* There is no way to see what the correct time-out period is */ |
69 | 76 | ||
77 | /* internal variables */ | ||
78 | static struct platform_device *acq_platform_device; /* the watchdog platform device */ | ||
70 | static unsigned long acq_is_open; | 79 | static unsigned long acq_is_open; |
71 | static char expect_close; | 80 | static char expect_close; |
72 | 81 | ||
73 | /* | 82 | /* module parameters */ |
74 | * You must set these - there is no sane way to probe for this board. | 83 | static int wdt_stop = 0x43; /* You must set this - there is no sane way to probe for this board. */ |
75 | */ | ||
76 | |||
77 | static int wdt_stop = 0x43; | ||
78 | module_param(wdt_stop, int, 0); | 84 | module_param(wdt_stop, int, 0); |
79 | MODULE_PARM_DESC(wdt_stop, "Acquire WDT 'stop' io port (default 0x43)"); | 85 | MODULE_PARM_DESC(wdt_stop, "Acquire WDT 'stop' io port (default 0x43)"); |
80 | 86 | ||
81 | static int wdt_start = 0x443; | 87 | static int wdt_start = 0x443; /* You must set this - there is no sane way to probe for this board. */ |
82 | module_param(wdt_start, int, 0); | 88 | module_param(wdt_start, int, 0); |
83 | MODULE_PARM_DESC(wdt_start, "Acquire WDT 'start' io port (default 0x443)"); | 89 | MODULE_PARM_DESC(wdt_start, "Acquire WDT 'start' io port (default 0x443)"); |
84 | 90 | ||
85 | static int nowayout = WATCHDOG_NOWAYOUT; | 91 | static int nowayout = WATCHDOG_NOWAYOUT; |
86 | module_param(nowayout, int, 0); | 92 | module_param(nowayout, int, 0); |
87 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 93 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
88 | 94 | ||
89 | /* | 95 | /* |
90 | * Kernel methods. | 96 | * Watchdog Operations |
91 | */ | 97 | */ |
92 | 98 | ||
93 | static void acq_keepalive(void) | 99 | static void acq_keepalive(void) |
@@ -103,7 +109,7 @@ static void acq_stop(void) | |||
103 | } | 109 | } |
104 | 110 | ||
105 | /* | 111 | /* |
106 | * /dev/watchdog handling. | 112 | * /dev/watchdog handling |
107 | */ | 113 | */ |
108 | 114 | ||
109 | static ssize_t acq_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | 115 | static ssize_t acq_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) |
@@ -143,7 +149,7 @@ static int acq_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
143 | { | 149 | { |
144 | .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, | 150 | .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, |
145 | .firmware_version = 1, | 151 | .firmware_version = 1, |
146 | .identity = "Acquire WDT", | 152 | .identity = WATCHDOG_NAME, |
147 | }; | 153 | }; |
148 | 154 | ||
149 | switch(cmd) | 155 | switch(cmd) |
@@ -214,20 +220,6 @@ static int acq_close(struct inode *inode, struct file *file) | |||
214 | } | 220 | } |
215 | 221 | ||
216 | /* | 222 | /* |
217 | * Notifier for system down | ||
218 | */ | ||
219 | |||
220 | static int acq_notify_sys(struct notifier_block *this, unsigned long code, | ||
221 | void *unused) | ||
222 | { | ||
223 | if(code==SYS_DOWN || code==SYS_HALT) { | ||
224 | /* Turn the WDT off */ | ||
225 | acq_stop(); | ||
226 | } | ||
227 | return NOTIFY_DONE; | ||
228 | } | ||
229 | |||
230 | /* | ||
231 | * Kernel Interfaces | 223 | * Kernel Interfaces |
232 | */ | 224 | */ |
233 | 225 | ||
@@ -240,29 +232,20 @@ static const struct file_operations acq_fops = { | |||
240 | .release = acq_close, | 232 | .release = acq_close, |
241 | }; | 233 | }; |
242 | 234 | ||
243 | static struct miscdevice acq_miscdev= | 235 | static struct miscdevice acq_miscdev = { |
244 | { | 236 | .minor = WATCHDOG_MINOR, |
245 | .minor = WATCHDOG_MINOR, | 237 | .name = "watchdog", |
246 | .name = "watchdog", | 238 | .fops = &acq_fops, |
247 | .fops = &acq_fops, | ||
248 | }; | 239 | }; |
249 | 240 | ||
250 | /* | 241 | /* |
251 | * The WDT card needs to learn about soft shutdowns in order to | 242 | * Init & exit routines |
252 | * turn the timebomb registers off. | ||
253 | */ | 243 | */ |
254 | 244 | ||
255 | static struct notifier_block acq_notifier = | 245 | static int __devinit acq_probe(struct platform_device *dev) |
256 | { | ||
257 | .notifier_call = acq_notify_sys, | ||
258 | }; | ||
259 | |||
260 | static int __init acq_init(void) | ||
261 | { | 246 | { |
262 | int ret; | 247 | int ret; |
263 | 248 | ||
264 | printk(KERN_INFO "WDT driver for Acquire single board computer initialising.\n"); | ||
265 | |||
266 | if (wdt_stop != wdt_start) { | 249 | if (wdt_stop != wdt_start) { |
267 | if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { | 250 | if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { |
268 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", | 251 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", |
@@ -279,18 +262,11 @@ static int __init acq_init(void) | |||
279 | goto unreg_stop; | 262 | goto unreg_stop; |
280 | } | 263 | } |
281 | 264 | ||
282 | ret = register_reboot_notifier(&acq_notifier); | ||
283 | if (ret != 0) { | ||
284 | printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", | ||
285 | ret); | ||
286 | goto unreg_regions; | ||
287 | } | ||
288 | |||
289 | ret = misc_register(&acq_miscdev); | 265 | ret = misc_register(&acq_miscdev); |
290 | if (ret != 0) { | 266 | if (ret != 0) { |
291 | printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | 267 | printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", |
292 | WATCHDOG_MINOR, ret); | 268 | WATCHDOG_MINOR, ret); |
293 | goto unreg_reboot; | 269 | goto unreg_regions; |
294 | } | 270 | } |
295 | 271 | ||
296 | printk (KERN_INFO PFX "initialized. (nowayout=%d)\n", | 272 | printk (KERN_INFO PFX "initialized. (nowayout=%d)\n", |
@@ -298,8 +274,6 @@ static int __init acq_init(void) | |||
298 | 274 | ||
299 | return 0; | 275 | return 0; |
300 | 276 | ||
301 | unreg_reboot: | ||
302 | unregister_reboot_notifier(&acq_notifier); | ||
303 | unreg_regions: | 277 | unreg_regions: |
304 | release_region(wdt_start, 1); | 278 | release_region(wdt_start, 1); |
305 | unreg_stop: | 279 | unreg_stop: |
@@ -309,13 +283,60 @@ out: | |||
309 | return ret; | 283 | return ret; |
310 | } | 284 | } |
311 | 285 | ||
312 | static void __exit acq_exit(void) | 286 | static int __devexit acq_remove(struct platform_device *dev) |
313 | { | 287 | { |
314 | misc_deregister(&acq_miscdev); | 288 | misc_deregister(&acq_miscdev); |
315 | unregister_reboot_notifier(&acq_notifier); | 289 | release_region(wdt_start,1); |
316 | if(wdt_stop != wdt_start) | 290 | if(wdt_stop != wdt_start) |
317 | release_region(wdt_stop,1); | 291 | release_region(wdt_stop,1); |
318 | release_region(wdt_start,1); | 292 | |
293 | return 0; | ||
294 | } | ||
295 | |||
296 | static void acq_shutdown(struct platform_device *dev) | ||
297 | { | ||
298 | /* Turn the WDT off if we have a soft shutdown */ | ||
299 | acq_stop(); | ||
300 | } | ||
301 | |||
302 | static struct platform_driver acquirewdt_driver = { | ||
303 | .probe = acq_probe, | ||
304 | .remove = __devexit_p(acq_remove), | ||
305 | .shutdown = acq_shutdown, | ||
306 | .driver = { | ||
307 | .owner = THIS_MODULE, | ||
308 | .name = DRV_NAME, | ||
309 | }, | ||
310 | }; | ||
311 | |||
312 | static int __init acq_init(void) | ||
313 | { | ||
314 | int err; | ||
315 | |||
316 | printk(KERN_INFO "WDT driver for Acquire single board computer initialising.\n"); | ||
317 | |||
318 | err = platform_driver_register(&acquirewdt_driver); | ||
319 | if (err) | ||
320 | return err; | ||
321 | |||
322 | acq_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0); | ||
323 | if (IS_ERR(acq_platform_device)) { | ||
324 | err = PTR_ERR(acq_platform_device); | ||
325 | goto unreg_platform_driver; | ||
326 | } | ||
327 | |||
328 | return 0; | ||
329 | |||
330 | unreg_platform_driver: | ||
331 | platform_driver_unregister(&acquirewdt_driver); | ||
332 | return err; | ||
333 | } | ||
334 | |||
335 | static void __exit acq_exit(void) | ||
336 | { | ||
337 | platform_device_unregister(acq_platform_device); | ||
338 | platform_driver_unregister(&acquirewdt_driver); | ||
339 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | ||
319 | } | 340 | } |
320 | 341 | ||
321 | module_init(acq_init); | 342 | module_init(acq_init); |
diff --git a/drivers/char/watchdog/advantechwdt.c b/drivers/char/watchdog/advantechwdt.c index 9d732769ba01..8121cc247343 100644 --- a/drivers/char/watchdog/advantechwdt.c +++ b/drivers/char/watchdog/advantechwdt.c | |||
@@ -35,18 +35,19 @@ | |||
35 | #include <linux/watchdog.h> | 35 | #include <linux/watchdog.h> |
36 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
37 | #include <linux/ioport.h> | 37 | #include <linux/ioport.h> |
38 | #include <linux/notifier.h> | 38 | #include <linux/platform_device.h> |
39 | #include <linux/reboot.h> | ||
40 | #include <linux/init.h> | 39 | #include <linux/init.h> |
41 | 40 | ||
42 | #include <asm/io.h> | 41 | #include <asm/io.h> |
43 | #include <asm/uaccess.h> | 42 | #include <asm/uaccess.h> |
44 | #include <asm/system.h> | 43 | #include <asm/system.h> |
45 | 44 | ||
45 | #define DRV_NAME "advantechwdt" | ||
46 | #define PFX DRV_NAME ": " | ||
46 | #define WATCHDOG_NAME "Advantech WDT" | 47 | #define WATCHDOG_NAME "Advantech WDT" |
47 | #define PFX WATCHDOG_NAME ": " | ||
48 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ | 48 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ |
49 | 49 | ||
50 | static struct platform_device *advwdt_platform_device; /* the watchdog platform device */ | ||
50 | static unsigned long advwdt_is_open; | 51 | static unsigned long advwdt_is_open; |
51 | static char adv_expect_close; | 52 | static char adv_expect_close; |
52 | 53 | ||
@@ -75,10 +76,10 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=63, defaul | |||
75 | 76 | ||
76 | static int nowayout = WATCHDOG_NOWAYOUT; | 77 | static int nowayout = WATCHDOG_NOWAYOUT; |
77 | module_param(nowayout, int, 0); | 78 | module_param(nowayout, int, 0); |
78 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 79 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
79 | 80 | ||
80 | /* | 81 | /* |
81 | * Kernel methods. | 82 | * Watchdog Operations |
82 | */ | 83 | */ |
83 | 84 | ||
84 | static void | 85 | static void |
@@ -94,6 +95,20 @@ advwdt_disable(void) | |||
94 | inb_p(wdt_stop); | 95 | inb_p(wdt_stop); |
95 | } | 96 | } |
96 | 97 | ||
98 | static int | ||
99 | advwdt_set_heartbeat(int t) | ||
100 | { | ||
101 | if ((t < 1) || (t > 63)) | ||
102 | return -EINVAL; | ||
103 | |||
104 | timeout = t; | ||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | /* | ||
109 | * /dev/watchdog handling | ||
110 | */ | ||
111 | |||
97 | static ssize_t | 112 | static ssize_t |
98 | advwdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | 113 | advwdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) |
99 | { | 114 | { |
@@ -126,7 +141,7 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
126 | static struct watchdog_info ident = { | 141 | static struct watchdog_info ident = { |
127 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, | 142 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, |
128 | .firmware_version = 1, | 143 | .firmware_version = 1, |
129 | .identity = "Advantech WDT", | 144 | .identity = WATCHDOG_NAME, |
130 | }; | 145 | }; |
131 | 146 | ||
132 | switch (cmd) { | 147 | switch (cmd) { |
@@ -146,9 +161,8 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
146 | case WDIOC_SETTIMEOUT: | 161 | case WDIOC_SETTIMEOUT: |
147 | if (get_user(new_timeout, p)) | 162 | if (get_user(new_timeout, p)) |
148 | return -EFAULT; | 163 | return -EFAULT; |
149 | if ((new_timeout < 1) || (new_timeout > 63)) | 164 | if (advwdt_set_heartbeat(new_timeout)) |
150 | return -EINVAL; | 165 | return -EINVAL; |
151 | timeout = new_timeout; | ||
152 | advwdt_ping(); | 166 | advwdt_ping(); |
153 | /* Fall */ | 167 | /* Fall */ |
154 | 168 | ||
@@ -209,21 +223,6 @@ advwdt_close(struct inode *inode, struct file *file) | |||
209 | } | 223 | } |
210 | 224 | ||
211 | /* | 225 | /* |
212 | * Notifier for system down | ||
213 | */ | ||
214 | |||
215 | static int | ||
216 | advwdt_notify_sys(struct notifier_block *this, unsigned long code, | ||
217 | void *unused) | ||
218 | { | ||
219 | if (code == SYS_DOWN || code == SYS_HALT) { | ||
220 | /* Turn the WDT off */ | ||
221 | advwdt_disable(); | ||
222 | } | ||
223 | return NOTIFY_DONE; | ||
224 | } | ||
225 | |||
226 | /* | ||
227 | * Kernel Interfaces | 226 | * Kernel Interfaces |
228 | */ | 227 | */ |
229 | 228 | ||
@@ -237,33 +236,20 @@ static const struct file_operations advwdt_fops = { | |||
237 | }; | 236 | }; |
238 | 237 | ||
239 | static struct miscdevice advwdt_miscdev = { | 238 | static struct miscdevice advwdt_miscdev = { |
240 | .minor = WATCHDOG_MINOR, | 239 | .minor = WATCHDOG_MINOR, |
241 | .name = "watchdog", | 240 | .name = "watchdog", |
242 | .fops = &advwdt_fops, | 241 | .fops = &advwdt_fops, |
243 | }; | 242 | }; |
244 | 243 | ||
245 | /* | 244 | /* |
246 | * The WDT needs to learn about soft shutdowns in order to | 245 | * Init & exit routines |
247 | * turn the timebomb registers off. | ||
248 | */ | 246 | */ |
249 | 247 | ||
250 | static struct notifier_block advwdt_notifier = { | 248 | static int __devinit |
251 | .notifier_call = advwdt_notify_sys, | 249 | advwdt_probe(struct platform_device *dev) |
252 | }; | ||
253 | |||
254 | static int __init | ||
255 | advwdt_init(void) | ||
256 | { | 250 | { |
257 | int ret; | 251 | int ret; |
258 | 252 | ||
259 | printk(KERN_INFO "WDT driver for Advantech single board computer initialising.\n"); | ||
260 | |||
261 | if (timeout < 1 || timeout > 63) { | ||
262 | timeout = WATCHDOG_TIMEOUT; | ||
263 | printk (KERN_INFO PFX "timeout value must be 1<=x<=63, using %d\n", | ||
264 | timeout); | ||
265 | } | ||
266 | |||
267 | if (wdt_stop != wdt_start) { | 253 | if (wdt_stop != wdt_start) { |
268 | if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { | 254 | if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { |
269 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", | 255 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", |
@@ -280,18 +266,18 @@ advwdt_init(void) | |||
280 | goto unreg_stop; | 266 | goto unreg_stop; |
281 | } | 267 | } |
282 | 268 | ||
283 | ret = register_reboot_notifier(&advwdt_notifier); | 269 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ |
284 | if (ret != 0) { | 270 | if (advwdt_set_heartbeat(timeout)) { |
285 | printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", | 271 | advwdt_set_heartbeat(WATCHDOG_TIMEOUT); |
286 | ret); | 272 | printk (KERN_INFO PFX "timeout value must be 1<=x<=63, using %d\n", |
287 | goto unreg_regions; | 273 | timeout); |
288 | } | 274 | } |
289 | 275 | ||
290 | ret = misc_register(&advwdt_miscdev); | 276 | ret = misc_register(&advwdt_miscdev); |
291 | if (ret != 0) { | 277 | if (ret != 0) { |
292 | printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | 278 | printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", |
293 | WATCHDOG_MINOR, ret); | 279 | WATCHDOG_MINOR, ret); |
294 | goto unreg_reboot; | 280 | goto unreg_regions; |
295 | } | 281 | } |
296 | 282 | ||
297 | printk (KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n", | 283 | printk (KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n", |
@@ -299,8 +285,6 @@ advwdt_init(void) | |||
299 | 285 | ||
300 | out: | 286 | out: |
301 | return ret; | 287 | return ret; |
302 | unreg_reboot: | ||
303 | unregister_reboot_notifier(&advwdt_notifier); | ||
304 | unreg_regions: | 288 | unreg_regions: |
305 | release_region(wdt_start, 1); | 289 | release_region(wdt_start, 1); |
306 | unreg_stop: | 290 | unreg_stop: |
@@ -309,14 +293,64 @@ unreg_stop: | |||
309 | goto out; | 293 | goto out; |
310 | } | 294 | } |
311 | 295 | ||
312 | static void __exit | 296 | static int __devexit |
313 | advwdt_exit(void) | 297 | advwdt_remove(struct platform_device *dev) |
314 | { | 298 | { |
315 | misc_deregister(&advwdt_miscdev); | 299 | misc_deregister(&advwdt_miscdev); |
316 | unregister_reboot_notifier(&advwdt_notifier); | 300 | release_region(wdt_start,1); |
317 | if(wdt_stop != wdt_start) | 301 | if(wdt_stop != wdt_start) |
318 | release_region(wdt_stop,1); | 302 | release_region(wdt_stop,1); |
319 | release_region(wdt_start,1); | 303 | |
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static void | ||
308 | advwdt_shutdown(struct platform_device *dev) | ||
309 | { | ||
310 | /* Turn the WDT off if we have a soft shutdown */ | ||
311 | advwdt_disable(); | ||
312 | } | ||
313 | |||
314 | static struct platform_driver advwdt_driver = { | ||
315 | .probe = advwdt_probe, | ||
316 | .remove = __devexit_p(advwdt_remove), | ||
317 | .shutdown = advwdt_shutdown, | ||
318 | .driver = { | ||
319 | .owner = THIS_MODULE, | ||
320 | .name = DRV_NAME, | ||
321 | }, | ||
322 | }; | ||
323 | |||
324 | static int __init | ||
325 | advwdt_init(void) | ||
326 | { | ||
327 | int err; | ||
328 | |||
329 | printk(KERN_INFO "WDT driver for Advantech single board computer initialising.\n"); | ||
330 | |||
331 | err = platform_driver_register(&advwdt_driver); | ||
332 | if (err) | ||
333 | return err; | ||
334 | |||
335 | advwdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0); | ||
336 | if (IS_ERR(advwdt_platform_device)) { | ||
337 | err = PTR_ERR(advwdt_platform_device); | ||
338 | goto unreg_platform_driver; | ||
339 | } | ||
340 | |||
341 | return 0; | ||
342 | |||
343 | unreg_platform_driver: | ||
344 | platform_driver_unregister(&advwdt_driver); | ||
345 | return err; | ||
346 | } | ||
347 | |||
348 | static void __exit | ||
349 | advwdt_exit(void) | ||
350 | { | ||
351 | platform_device_unregister(advwdt_platform_device); | ||
352 | platform_driver_unregister(&advwdt_driver); | ||
353 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | ||
320 | } | 354 | } |
321 | 355 | ||
322 | module_init(advwdt_init); | 356 | module_init(advwdt_init); |
diff --git a/drivers/char/watchdog/alim1535_wdt.c b/drivers/char/watchdog/alim1535_wdt.c index 01b0d132ee41..e3f6a7d0c83d 100644 --- a/drivers/char/watchdog/alim1535_wdt.c +++ b/drivers/char/watchdog/alim1535_wdt.c | |||
@@ -40,7 +40,7 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (0<timeout<18000, defaul | |||
40 | 40 | ||
41 | static int nowayout = WATCHDOG_NOWAYOUT; | 41 | static int nowayout = WATCHDOG_NOWAYOUT; |
42 | module_param(nowayout, int, 0); | 42 | module_param(nowayout, int, 0); |
43 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 43 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * ali_start - start watchdog countdown | 46 | * ali_start - start watchdog countdown |
diff --git a/drivers/char/watchdog/alim7101_wdt.c b/drivers/char/watchdog/alim7101_wdt.c index e5b2c2ee292c..67aed9f8c362 100644 --- a/drivers/char/watchdog/alim7101_wdt.c +++ b/drivers/char/watchdog/alim7101_wdt.c | |||
@@ -69,7 +69,7 @@ module_param(use_gpio, int, 0); | |||
69 | MODULE_PARM_DESC(use_gpio, "Use the gpio watchdog. (required by old cobalt boards)"); | 69 | MODULE_PARM_DESC(use_gpio, "Use the gpio watchdog. (required by old cobalt boards)"); |
70 | 70 | ||
71 | static void wdt_timer_ping(unsigned long); | 71 | static void wdt_timer_ping(unsigned long); |
72 | static struct timer_list timer; | 72 | static DEFINE_TIMER(timer, wdt_timer_ping, 0, 1); |
73 | static unsigned long next_heartbeat; | 73 | static unsigned long next_heartbeat; |
74 | static unsigned long wdt_is_open; | 74 | static unsigned long wdt_is_open; |
75 | static char wdt_expect_close; | 75 | static char wdt_expect_close; |
@@ -78,7 +78,7 @@ static struct pci_dev *alim7101_pmu; | |||
78 | static int nowayout = WATCHDOG_NOWAYOUT; | 78 | static int nowayout = WATCHDOG_NOWAYOUT; |
79 | module_param(nowayout, int, 0); | 79 | module_param(nowayout, int, 0); |
80 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | 80 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" |
81 | __stringify(CONFIG_WATCHDOG_NOWAYOUT) ")"); | 81 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
82 | 82 | ||
83 | /* | 83 | /* |
84 | * Whack the dog | 84 | * Whack the dog |
@@ -108,8 +108,7 @@ static void wdt_timer_ping(unsigned long data) | |||
108 | printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); | 108 | printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); |
109 | } | 109 | } |
110 | /* Re-set the timer interval */ | 110 | /* Re-set the timer interval */ |
111 | timer.expires = jiffies + WDT_INTERVAL; | 111 | mod_timer(&timer, jiffies + WDT_INTERVAL); |
112 | add_timer(&timer); | ||
113 | } | 112 | } |
114 | 113 | ||
115 | /* | 114 | /* |
@@ -147,9 +146,7 @@ static void wdt_startup(void) | |||
147 | wdt_change(WDT_ENABLE); | 146 | wdt_change(WDT_ENABLE); |
148 | 147 | ||
149 | /* Start the timer */ | 148 | /* Start the timer */ |
150 | timer.expires = jiffies + WDT_INTERVAL; | 149 | mod_timer(&timer, jiffies + WDT_INTERVAL); |
151 | add_timer(&timer); | ||
152 | |||
153 | 150 | ||
154 | printk(KERN_INFO PFX "Watchdog timer is now enabled.\n"); | 151 | printk(KERN_INFO PFX "Watchdog timer is now enabled.\n"); |
155 | } | 152 | } |
@@ -380,10 +377,6 @@ static int __init alim7101_wdt_init(void) | |||
380 | timeout); | 377 | timeout); |
381 | } | 378 | } |
382 | 379 | ||
383 | init_timer(&timer); | ||
384 | timer.function = wdt_timer_ping; | ||
385 | timer.data = 1; | ||
386 | |||
387 | rc = misc_register(&wdt_miscdev); | 380 | rc = misc_register(&wdt_miscdev); |
388 | if (rc) { | 381 | if (rc) { |
389 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | 382 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", |
diff --git a/drivers/char/watchdog/cpu5wdt.c b/drivers/char/watchdog/cpu5wdt.c index 00bdabb90f27..bcd7e36ca0aa 100644 --- a/drivers/char/watchdog/cpu5wdt.c +++ b/drivers/char/watchdog/cpu5wdt.c | |||
@@ -80,10 +80,8 @@ static void cpu5wdt_trigger(unsigned long unused) | |||
80 | outb(1, port + CPU5WDT_TRIGGER_REG); | 80 | outb(1, port + CPU5WDT_TRIGGER_REG); |
81 | 81 | ||
82 | /* requeue?? */ | 82 | /* requeue?? */ |
83 | if( cpu5wdt_device.queue && ticks ) { | 83 | if (cpu5wdt_device.queue && ticks) |
84 | cpu5wdt_device.timer.expires = jiffies + CPU5WDT_INTERVAL; | 84 | mod_timer(&cpu5wdt_device.timer, jiffies + CPU5WDT_INTERVAL); |
85 | add_timer(&cpu5wdt_device.timer); | ||
86 | } | ||
87 | else { | 85 | else { |
88 | /* ticks doesn't matter anyway */ | 86 | /* ticks doesn't matter anyway */ |
89 | complete(&cpu5wdt_device.stop); | 87 | complete(&cpu5wdt_device.stop); |
@@ -109,8 +107,7 @@ static void cpu5wdt_start(void) | |||
109 | outb(1, port + CPU5WDT_MODE_REG); | 107 | outb(1, port + CPU5WDT_MODE_REG); |
110 | outb(0, port + CPU5WDT_RESET_REG); | 108 | outb(0, port + CPU5WDT_RESET_REG); |
111 | outb(0, port + CPU5WDT_ENABLE_REG); | 109 | outb(0, port + CPU5WDT_ENABLE_REG); |
112 | cpu5wdt_device.timer.expires = jiffies + CPU5WDT_INTERVAL; | 110 | mod_timer(&cpu5wdt_device.timer, jiffies + CPU5WDT_INTERVAL); |
113 | add_timer(&cpu5wdt_device.timer); | ||
114 | } | 111 | } |
115 | /* if process dies, counter is not decremented */ | 112 | /* if process dies, counter is not decremented */ |
116 | cpu5wdt_device.running++; | 113 | cpu5wdt_device.running++; |
@@ -245,9 +242,7 @@ static int __devinit cpu5wdt_init(void) | |||
245 | 242 | ||
246 | clear_bit(0, &cpu5wdt_device.inuse); | 243 | clear_bit(0, &cpu5wdt_device.inuse); |
247 | 244 | ||
248 | init_timer(&cpu5wdt_device.timer); | 245 | setup_timer(&cpu5wdt_device.timer, cpu5wdt_trigger, 0); |
249 | cpu5wdt_device.timer.function = cpu5wdt_trigger; | ||
250 | cpu5wdt_device.timer.data = 0; | ||
251 | 246 | ||
252 | cpu5wdt_device.default_ticks = ticks; | 247 | cpu5wdt_device.default_ticks = ticks; |
253 | 248 | ||
diff --git a/drivers/char/watchdog/eurotechwdt.c b/drivers/char/watchdog/eurotechwdt.c index e228d6e173ce..f70387f01b2b 100644 --- a/drivers/char/watchdog/eurotechwdt.c +++ b/drivers/char/watchdog/eurotechwdt.c | |||
@@ -73,7 +73,7 @@ static char *ev = "int"; | |||
73 | 73 | ||
74 | static int nowayout = WATCHDOG_NOWAYOUT; | 74 | static int nowayout = WATCHDOG_NOWAYOUT; |
75 | module_param(nowayout, int, 0); | 75 | module_param(nowayout, int, 0); |
76 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 76 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
77 | 77 | ||
78 | /* | 78 | /* |
79 | * Some symbolic names | 79 | * Some symbolic names |
diff --git a/drivers/char/watchdog/i6300esb.c b/drivers/char/watchdog/i6300esb.c index fb64df4d7c87..c5982502c03d 100644 --- a/drivers/char/watchdog/i6300esb.c +++ b/drivers/char/watchdog/i6300esb.c | |||
@@ -91,7 +91,7 @@ MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<heartbeat<2046, d | |||
91 | 91 | ||
92 | static int nowayout = WATCHDOG_NOWAYOUT; | 92 | static int nowayout = WATCHDOG_NOWAYOUT; |
93 | module_param(nowayout, int, 0); | 93 | module_param(nowayout, int, 0); |
94 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 94 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * Some i6300ESB specific functions | 97 | * Some i6300ESB specific functions |
diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c index e0627d79707b..a62ef48a15ae 100644 --- a/drivers/char/watchdog/i8xx_tco.c +++ b/drivers/char/watchdog/i8xx_tco.c | |||
@@ -109,7 +109,7 @@ MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<heartbeat<39, def | |||
109 | 109 | ||
110 | static int nowayout = WATCHDOG_NOWAYOUT; | 110 | static int nowayout = WATCHDOG_NOWAYOUT; |
111 | module_param(nowayout, int, 0); | 111 | module_param(nowayout, int, 0); |
112 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 112 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
113 | 113 | ||
114 | /* | 114 | /* |
115 | * Some TCO specific functions | 115 | * Some TCO specific functions |
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c index fd8a44a08cd3..3c9684ccd2f9 100644 --- a/drivers/char/watchdog/iTCO_wdt.c +++ b/drivers/char/watchdog/iTCO_wdt.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * intel TCO Watchdog Driver (Used in i82801 and i6300ESB chipsets) | 2 | * intel TCO Watchdog Driver (Used in i82801 and i6300ESB chipsets) |
3 | * | 3 | * |
4 | * (c) Copyright 2006 Wim Van Sebroeck <wim@iguana.be>. | 4 | * (c) Copyright 2006-2007 Wim Van Sebroeck <wim@iguana.be>. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or | 6 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License | 7 | * modify it under the terms of the GNU General Public License |
@@ -49,7 +49,7 @@ | |||
49 | /* Module and version information */ | 49 | /* Module and version information */ |
50 | #define DRV_NAME "iTCO_wdt" | 50 | #define DRV_NAME "iTCO_wdt" |
51 | #define DRV_VERSION "1.01" | 51 | #define DRV_VERSION "1.01" |
52 | #define DRV_RELDATE "11-Nov-2006" | 52 | #define DRV_RELDATE "21-Jan-2007" |
53 | #define PFX DRV_NAME ": " | 53 | #define PFX DRV_NAME ": " |
54 | 54 | ||
55 | /* Includes */ | 55 | /* Includes */ |
@@ -187,7 +187,7 @@ MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<heartbeat<39 (TCO | |||
187 | 187 | ||
188 | static int nowayout = WATCHDOG_NOWAYOUT; | 188 | static int nowayout = WATCHDOG_NOWAYOUT; |
189 | module_param(nowayout, int, 0); | 189 | module_param(nowayout, int, 0); |
190 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 190 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
191 | 191 | ||
192 | /* iTCO Vendor Specific Support hooks */ | 192 | /* iTCO Vendor Specific Support hooks */ |
193 | #ifdef CONFIG_ITCO_VENDOR_SUPPORT | 193 | #ifdef CONFIG_ITCO_VENDOR_SUPPORT |
diff --git a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c index c1ed209a138c..c3a60f52ccb9 100644 --- a/drivers/char/watchdog/ib700wdt.c +++ b/drivers/char/watchdog/ib700wdt.c | |||
@@ -3,8 +3,8 @@ | |||
3 | * | 3 | * |
4 | * (c) Copyright 2001 Charles Howes <chowes@vsol.net> | 4 | * (c) Copyright 2001 Charles Howes <chowes@vsol.net> |
5 | * | 5 | * |
6 | * Based on advantechwdt.c which is based on acquirewdt.c which | 6 | * Based on advantechwdt.c which is based on acquirewdt.c which |
7 | * is based on wdt.c. | 7 | * is based on wdt.c. |
8 | * | 8 | * |
9 | * (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl> | 9 | * (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl> |
10 | * | 10 | * |
@@ -25,9 +25,9 @@ | |||
25 | * | 25 | * |
26 | * (c) Copyright 1995 Alan Cox <alan@redhat.com> | 26 | * (c) Copyright 1995 Alan Cox <alan@redhat.com> |
27 | * | 27 | * |
28 | * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> | 28 | * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> |
29 | * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT | 29 | * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT |
30 | * Added timeout module option to override default | 30 | * Added timeout module option to override default |
31 | * | 31 | * |
32 | */ | 32 | */ |
33 | 33 | ||
@@ -36,22 +36,24 @@ | |||
36 | #include <linux/miscdevice.h> | 36 | #include <linux/miscdevice.h> |
37 | #include <linux/watchdog.h> | 37 | #include <linux/watchdog.h> |
38 | #include <linux/ioport.h> | 38 | #include <linux/ioport.h> |
39 | #include <linux/notifier.h> | ||
40 | #include <linux/fs.h> | 39 | #include <linux/fs.h> |
41 | #include <linux/reboot.h> | ||
42 | #include <linux/init.h> | 40 | #include <linux/init.h> |
43 | #include <linux/spinlock.h> | 41 | #include <linux/spinlock.h> |
44 | #include <linux/moduleparam.h> | 42 | #include <linux/moduleparam.h> |
43 | #include <linux/platform_device.h> | ||
45 | 44 | ||
46 | #include <asm/io.h> | 45 | #include <asm/io.h> |
47 | #include <asm/uaccess.h> | 46 | #include <asm/uaccess.h> |
48 | #include <asm/system.h> | 47 | #include <asm/system.h> |
49 | 48 | ||
49 | static struct platform_device *ibwdt_platform_device; | ||
50 | static unsigned long ibwdt_is_open; | 50 | static unsigned long ibwdt_is_open; |
51 | static spinlock_t ibwdt_lock; | 51 | static spinlock_t ibwdt_lock; |
52 | static char expect_close; | 52 | static char expect_close; |
53 | 53 | ||
54 | #define PFX "ib700wdt: " | 54 | /* Module information */ |
55 | #define DRV_NAME "ib700wdt" | ||
56 | #define PFX DRV_NAME ": " | ||
55 | 57 | ||
56 | /* | 58 | /* |
57 | * | 59 | * |
@@ -118,20 +120,51 @@ static int wd_margin = WD_TIMO; | |||
118 | 120 | ||
119 | static int nowayout = WATCHDOG_NOWAYOUT; | 121 | static int nowayout = WATCHDOG_NOWAYOUT; |
120 | module_param(nowayout, int, 0); | 122 | module_param(nowayout, int, 0); |
121 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 123 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
122 | 124 | ||
123 | 125 | ||
124 | /* | 126 | /* |
125 | * Kernel methods. | 127 | * Watchdog Operations |
126 | */ | 128 | */ |
127 | 129 | ||
128 | static void | 130 | static void |
129 | ibwdt_ping(void) | 131 | ibwdt_ping(void) |
130 | { | 132 | { |
133 | spin_lock(&ibwdt_lock); | ||
134 | |||
131 | /* Write a watchdog value */ | 135 | /* Write a watchdog value */ |
132 | outb_p(wd_margin, WDT_START); | 136 | outb_p(wd_margin, WDT_START); |
137 | |||
138 | spin_unlock(&ibwdt_lock); | ||
133 | } | 139 | } |
134 | 140 | ||
141 | static void | ||
142 | ibwdt_disable(void) | ||
143 | { | ||
144 | spin_lock(&ibwdt_lock); | ||
145 | outb_p(0, WDT_STOP); | ||
146 | spin_unlock(&ibwdt_lock); | ||
147 | } | ||
148 | |||
149 | static int | ||
150 | ibwdt_set_heartbeat(int t) | ||
151 | { | ||
152 | int i; | ||
153 | |||
154 | if ((t < 0) || (t > 30)) | ||
155 | return -EINVAL; | ||
156 | |||
157 | for (i = 0x0F; i > -1; i--) | ||
158 | if (wd_times[i] > t) | ||
159 | break; | ||
160 | wd_margin = i; | ||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | /* | ||
165 | * /dev/watchdog handling | ||
166 | */ | ||
167 | |||
135 | static ssize_t | 168 | static ssize_t |
136 | ibwdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | 169 | ibwdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) |
137 | { | 170 | { |
@@ -159,7 +192,7 @@ static int | |||
159 | ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 192 | ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, |
160 | unsigned long arg) | 193 | unsigned long arg) |
161 | { | 194 | { |
162 | int i, new_margin; | 195 | int new_margin; |
163 | void __user *argp = (void __user *)arg; | 196 | void __user *argp = (void __user *)arg; |
164 | int __user *p = argp; | 197 | int __user *p = argp; |
165 | 198 | ||
@@ -176,6 +209,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
176 | break; | 209 | break; |
177 | 210 | ||
178 | case WDIOC_GETSTATUS: | 211 | case WDIOC_GETSTATUS: |
212 | case WDIOC_GETBOOTSTATUS: | ||
179 | return put_user(0, p); | 213 | return put_user(0, p); |
180 | 214 | ||
181 | case WDIOC_KEEPALIVE: | 215 | case WDIOC_KEEPALIVE: |
@@ -185,18 +219,33 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
185 | case WDIOC_SETTIMEOUT: | 219 | case WDIOC_SETTIMEOUT: |
186 | if (get_user(new_margin, p)) | 220 | if (get_user(new_margin, p)) |
187 | return -EFAULT; | 221 | return -EFAULT; |
188 | if ((new_margin < 0) || (new_margin > 30)) | 222 | if (ibwdt_set_heartbeat(new_margin)) |
189 | return -EINVAL; | 223 | return -EINVAL; |
190 | for (i = 0x0F; i > -1; i--) | ||
191 | if (wd_times[i] > new_margin) | ||
192 | break; | ||
193 | wd_margin = i; | ||
194 | ibwdt_ping(); | 224 | ibwdt_ping(); |
195 | /* Fall */ | 225 | /* Fall */ |
196 | 226 | ||
197 | case WDIOC_GETTIMEOUT: | 227 | case WDIOC_GETTIMEOUT: |
198 | return put_user(wd_times[wd_margin], p); | 228 | return put_user(wd_times[wd_margin], p); |
199 | break; | 229 | |
230 | case WDIOC_SETOPTIONS: | ||
231 | { | ||
232 | int options, retval = -EINVAL; | ||
233 | |||
234 | if (get_user(options, p)) | ||
235 | return -EFAULT; | ||
236 | |||
237 | if (options & WDIOS_DISABLECARD) { | ||
238 | ibwdt_disable(); | ||
239 | retval = 0; | ||
240 | } | ||
241 | |||
242 | if (options & WDIOS_ENABLECARD) { | ||
243 | ibwdt_ping(); | ||
244 | retval = 0; | ||
245 | } | ||
246 | |||
247 | return retval; | ||
248 | } | ||
200 | 249 | ||
201 | default: | 250 | default: |
202 | return -ENOTTY; | 251 | return -ENOTTY; |
@@ -207,9 +256,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
207 | static int | 256 | static int |
208 | ibwdt_open(struct inode *inode, struct file *file) | 257 | ibwdt_open(struct inode *inode, struct file *file) |
209 | { | 258 | { |
210 | spin_lock(&ibwdt_lock); | ||
211 | if (test_and_set_bit(0, &ibwdt_is_open)) { | 259 | if (test_and_set_bit(0, &ibwdt_is_open)) { |
212 | spin_unlock(&ibwdt_lock); | ||
213 | return -EBUSY; | 260 | return -EBUSY; |
214 | } | 261 | } |
215 | if (nowayout) | 262 | if (nowayout) |
@@ -217,41 +264,24 @@ ibwdt_open(struct inode *inode, struct file *file) | |||
217 | 264 | ||
218 | /* Activate */ | 265 | /* Activate */ |
219 | ibwdt_ping(); | 266 | ibwdt_ping(); |
220 | spin_unlock(&ibwdt_lock); | ||
221 | return nonseekable_open(inode, file); | 267 | return nonseekable_open(inode, file); |
222 | } | 268 | } |
223 | 269 | ||
224 | static int | 270 | static int |
225 | ibwdt_close(struct inode *inode, struct file *file) | 271 | ibwdt_close(struct inode *inode, struct file *file) |
226 | { | 272 | { |
227 | spin_lock(&ibwdt_lock); | 273 | if (expect_close == 42) { |
228 | if (expect_close == 42) | 274 | ibwdt_disable(); |
229 | outb_p(0, WDT_STOP); | 275 | } else { |
230 | else | ||
231 | printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); | 276 | printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); |
232 | 277 | ibwdt_ping(); | |
278 | } | ||
233 | clear_bit(0, &ibwdt_is_open); | 279 | clear_bit(0, &ibwdt_is_open); |
234 | expect_close = 0; | 280 | expect_close = 0; |
235 | spin_unlock(&ibwdt_lock); | ||
236 | return 0; | 281 | return 0; |
237 | } | 282 | } |
238 | 283 | ||
239 | /* | 284 | /* |
240 | * Notifier for system down | ||
241 | */ | ||
242 | |||
243 | static int | ||
244 | ibwdt_notify_sys(struct notifier_block *this, unsigned long code, | ||
245 | void *unused) | ||
246 | { | ||
247 | if (code == SYS_DOWN || code == SYS_HALT) { | ||
248 | /* Turn the WDT off */ | ||
249 | outb_p(0, WDT_STOP); | ||
250 | } | ||
251 | return NOTIFY_DONE; | ||
252 | } | ||
253 | |||
254 | /* | ||
255 | * Kernel Interfaces | 285 | * Kernel Interfaces |
256 | */ | 286 | */ |
257 | 287 | ||
@@ -271,26 +301,14 @@ static struct miscdevice ibwdt_miscdev = { | |||
271 | }; | 301 | }; |
272 | 302 | ||
273 | /* | 303 | /* |
274 | * The WDT needs to learn about soft shutdowns in order to | 304 | * Init & exit routines |
275 | * turn the timebomb registers off. | ||
276 | */ | 305 | */ |
277 | 306 | ||
278 | static struct notifier_block ibwdt_notifier = { | 307 | static int __devinit ibwdt_probe(struct platform_device *dev) |
279 | .notifier_call = ibwdt_notify_sys, | ||
280 | }; | ||
281 | |||
282 | static int __init ibwdt_init(void) | ||
283 | { | 308 | { |
284 | int res; | 309 | int res; |
285 | 310 | ||
286 | printk(KERN_INFO PFX "WDT driver for IB700 single board computer initialising.\n"); | ||
287 | |||
288 | spin_lock_init(&ibwdt_lock); | 311 | spin_lock_init(&ibwdt_lock); |
289 | res = misc_register(&ibwdt_miscdev); | ||
290 | if (res) { | ||
291 | printk (KERN_ERR PFX "failed to register misc device\n"); | ||
292 | goto out_nomisc; | ||
293 | } | ||
294 | 312 | ||
295 | #if WDT_START != WDT_STOP | 313 | #if WDT_START != WDT_STOP |
296 | if (!request_region(WDT_STOP, 1, "IB700 WDT")) { | 314 | if (!request_region(WDT_STOP, 1, "IB700 WDT")) { |
@@ -305,34 +323,78 @@ static int __init ibwdt_init(void) | |||
305 | res = -EIO; | 323 | res = -EIO; |
306 | goto out_nostartreg; | 324 | goto out_nostartreg; |
307 | } | 325 | } |
308 | res = register_reboot_notifier(&ibwdt_notifier); | 326 | |
327 | res = misc_register(&ibwdt_miscdev); | ||
309 | if (res) { | 328 | if (res) { |
310 | printk (KERN_ERR PFX "Failed to register reboot notifier.\n"); | 329 | printk (KERN_ERR PFX "failed to register misc device\n"); |
311 | goto out_noreboot; | 330 | goto out_nomisc; |
312 | } | 331 | } |
313 | return 0; | 332 | return 0; |
314 | 333 | ||
315 | out_noreboot: | 334 | out_nomisc: |
316 | release_region(WDT_START, 1); | 335 | release_region(WDT_START, 1); |
317 | out_nostartreg: | 336 | out_nostartreg: |
318 | #if WDT_START != WDT_STOP | 337 | #if WDT_START != WDT_STOP |
319 | release_region(WDT_STOP, 1); | 338 | release_region(WDT_STOP, 1); |
320 | #endif | 339 | #endif |
321 | out_nostopreg: | 340 | out_nostopreg: |
322 | misc_deregister(&ibwdt_miscdev); | ||
323 | out_nomisc: | ||
324 | return res; | 341 | return res; |
325 | } | 342 | } |
326 | 343 | ||
327 | static void __exit | 344 | static int __devexit ibwdt_remove(struct platform_device *dev) |
328 | ibwdt_exit(void) | ||
329 | { | 345 | { |
330 | misc_deregister(&ibwdt_miscdev); | 346 | misc_deregister(&ibwdt_miscdev); |
331 | unregister_reboot_notifier(&ibwdt_notifier); | 347 | release_region(WDT_START,1); |
332 | #if WDT_START != WDT_STOP | 348 | #if WDT_START != WDT_STOP |
333 | release_region(WDT_STOP,1); | 349 | release_region(WDT_STOP,1); |
334 | #endif | 350 | #endif |
335 | release_region(WDT_START,1); | 351 | return 0; |
352 | } | ||
353 | |||
354 | static void ibwdt_shutdown(struct platform_device *dev) | ||
355 | { | ||
356 | /* Turn the WDT off if we have a soft shutdown */ | ||
357 | ibwdt_disable(); | ||
358 | } | ||
359 | |||
360 | static struct platform_driver ibwdt_driver = { | ||
361 | .probe = ibwdt_probe, | ||
362 | .remove = __devexit_p(ibwdt_remove), | ||
363 | .shutdown = ibwdt_shutdown, | ||
364 | .driver = { | ||
365 | .owner = THIS_MODULE, | ||
366 | .name = DRV_NAME, | ||
367 | }, | ||
368 | }; | ||
369 | |||
370 | static int __init ibwdt_init(void) | ||
371 | { | ||
372 | int err; | ||
373 | |||
374 | printk(KERN_INFO PFX "WDT driver for IB700 single board computer initialising.\n"); | ||
375 | |||
376 | err = platform_driver_register(&ibwdt_driver); | ||
377 | if (err) | ||
378 | return err; | ||
379 | |||
380 | ibwdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0); | ||
381 | if (IS_ERR(ibwdt_platform_device)) { | ||
382 | err = PTR_ERR(ibwdt_platform_device); | ||
383 | goto unreg_platform_driver; | ||
384 | } | ||
385 | |||
386 | return 0; | ||
387 | |||
388 | unreg_platform_driver: | ||
389 | platform_driver_unregister(&ibwdt_driver); | ||
390 | return err; | ||
391 | } | ||
392 | |||
393 | static void __exit ibwdt_exit(void) | ||
394 | { | ||
395 | platform_device_unregister(ibwdt_platform_device); | ||
396 | platform_driver_unregister(&ibwdt_driver); | ||
397 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | ||
336 | } | 398 | } |
337 | 399 | ||
338 | module_init(ibwdt_init); | 400 | module_init(ibwdt_init); |
diff --git a/drivers/char/watchdog/ibmasr.c b/drivers/char/watchdog/ibmasr.c index dd6760f1a23b..8195f5023d85 100644 --- a/drivers/char/watchdog/ibmasr.c +++ b/drivers/char/watchdog/ibmasr.c | |||
@@ -396,7 +396,7 @@ module_init(ibmasr_init); | |||
396 | module_exit(ibmasr_exit); | 396 | module_exit(ibmasr_exit); |
397 | 397 | ||
398 | module_param(nowayout, int, 0); | 398 | module_param(nowayout, int, 0); |
399 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 399 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
400 | 400 | ||
401 | MODULE_DESCRIPTION("IBM Automatic Server Restart driver"); | 401 | MODULE_DESCRIPTION("IBM Automatic Server Restart driver"); |
402 | MODULE_AUTHOR("Andrey Panin"); | 402 | MODULE_AUTHOR("Andrey Panin"); |
diff --git a/drivers/char/watchdog/indydog.c b/drivers/char/watchdog/indydog.c index 0bc239308989..788245bdaa7f 100644 --- a/drivers/char/watchdog/indydog.c +++ b/drivers/char/watchdog/indydog.c | |||
@@ -32,7 +32,7 @@ static int indydog_alive; | |||
32 | 32 | ||
33 | static int nowayout = WATCHDOG_NOWAYOUT; | 33 | static int nowayout = WATCHDOG_NOWAYOUT; |
34 | module_param(nowayout, int, 0); | 34 | module_param(nowayout, int, 0); |
35 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 35 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
36 | 36 | ||
37 | static void indydog_start(void) | 37 | static void indydog_start(void) |
38 | { | 38 | { |
diff --git a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c index 4d730fdbd528..81fb3dec180f 100644 --- a/drivers/char/watchdog/machzwd.c +++ b/drivers/char/watchdog/machzwd.c | |||
@@ -95,7 +95,7 @@ MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | |||
95 | 95 | ||
96 | static int nowayout = WATCHDOG_NOWAYOUT; | 96 | static int nowayout = WATCHDOG_NOWAYOUT; |
97 | module_param(nowayout, int, 0); | 97 | module_param(nowayout, int, 0); |
98 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 98 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
99 | 99 | ||
100 | #define PFX "machzwd" | 100 | #define PFX "machzwd" |
101 | 101 | ||
@@ -118,12 +118,14 @@ static int action = 0; | |||
118 | module_param(action, int, 0); | 118 | module_param(action, int, 0); |
119 | MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*) 1 = SMI 2 = NMI 3 = SCI"); | 119 | MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*) 1 = SMI 2 = NMI 3 = SCI"); |
120 | 120 | ||
121 | static void zf_ping(unsigned long data); | ||
122 | |||
121 | static int zf_action = GEN_RESET; | 123 | static int zf_action = GEN_RESET; |
122 | static unsigned long zf_is_open; | 124 | static unsigned long zf_is_open; |
123 | static char zf_expect_close; | 125 | static char zf_expect_close; |
124 | static spinlock_t zf_lock; | 126 | static spinlock_t zf_lock; |
125 | static spinlock_t zf_port_lock; | 127 | static spinlock_t zf_port_lock; |
126 | static struct timer_list zf_timer; | 128 | static DEFINE_TIMER(zf_timer, zf_ping, 0, 0); |
127 | static unsigned long next_heartbeat = 0; | 129 | static unsigned long next_heartbeat = 0; |
128 | 130 | ||
129 | 131 | ||
@@ -220,9 +222,7 @@ static void zf_timer_on(void) | |||
220 | next_heartbeat = jiffies + ZF_USER_TIMEO; | 222 | next_heartbeat = jiffies + ZF_USER_TIMEO; |
221 | 223 | ||
222 | /* start the timer for internal ping */ | 224 | /* start the timer for internal ping */ |
223 | zf_timer.expires = jiffies + ZF_HW_TIMEO; | 225 | mod_timer(&zf_timer, jiffies + ZF_HW_TIMEO); |
224 | |||
225 | add_timer(&zf_timer); | ||
226 | 226 | ||
227 | /* start watchdog timer */ | 227 | /* start watchdog timer */ |
228 | ctrl_reg = zf_get_control(); | 228 | ctrl_reg = zf_get_control(); |
@@ -260,8 +260,7 @@ static void zf_ping(unsigned long data) | |||
260 | zf_set_control(ctrl_reg); | 260 | zf_set_control(ctrl_reg); |
261 | spin_unlock_irqrestore(&zf_port_lock, flags); | 261 | spin_unlock_irqrestore(&zf_port_lock, flags); |
262 | 262 | ||
263 | zf_timer.expires = jiffies + ZF_HW_TIMEO; | 263 | mod_timer(&zf_timer, jiffies + ZF_HW_TIMEO); |
264 | add_timer(&zf_timer); | ||
265 | }else{ | 264 | }else{ |
266 | printk(KERN_CRIT PFX ": I will reset your machine\n"); | 265 | printk(KERN_CRIT PFX ": I will reset your machine\n"); |
267 | } | 266 | } |
@@ -465,11 +464,6 @@ static int __init zf_init(void) | |||
465 | zf_set_status(0); | 464 | zf_set_status(0); |
466 | zf_set_control(0); | 465 | zf_set_control(0); |
467 | 466 | ||
468 | /* this is the timer that will do the hard work */ | ||
469 | init_timer(&zf_timer); | ||
470 | zf_timer.function = zf_ping; | ||
471 | zf_timer.data = 0; | ||
472 | |||
473 | return 0; | 467 | return 0; |
474 | 468 | ||
475 | no_reboot: | 469 | no_reboot: |
diff --git a/drivers/char/watchdog/mixcomwd.c b/drivers/char/watchdog/mixcomwd.c index c2dac0aa1d62..f35e2848aa3e 100644 --- a/drivers/char/watchdog/mixcomwd.c +++ b/drivers/char/watchdog/mixcomwd.c | |||
@@ -56,16 +56,18 @@ static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 }; | |||
56 | #define FLASHCOM_WATCHDOG_OFFSET 0x4 | 56 | #define FLASHCOM_WATCHDOG_OFFSET 0x4 |
57 | #define FLASHCOM_ID 0x18 | 57 | #define FLASHCOM_ID 0x18 |
58 | 58 | ||
59 | static void mixcomwd_timerfun(unsigned long d); | ||
60 | |||
59 | static unsigned long mixcomwd_opened; /* long req'd for setbit --RR */ | 61 | static unsigned long mixcomwd_opened; /* long req'd for setbit --RR */ |
60 | 62 | ||
61 | static int watchdog_port; | 63 | static int watchdog_port; |
62 | static int mixcomwd_timer_alive; | 64 | static int mixcomwd_timer_alive; |
63 | static DEFINE_TIMER(mixcomwd_timer, NULL, 0, 0); | 65 | static DEFINE_TIMER(mixcomwd_timer, mixcomwd_timerfun, 0, 0); |
64 | static char expect_close; | 66 | static char expect_close; |
65 | 67 | ||
66 | static int nowayout = WATCHDOG_NOWAYOUT; | 68 | static int nowayout = WATCHDOG_NOWAYOUT; |
67 | module_param(nowayout, int, 0); | 69 | module_param(nowayout, int, 0); |
68 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 70 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
69 | 71 | ||
70 | static void mixcomwd_ping(void) | 72 | static void mixcomwd_ping(void) |
71 | { | 73 | { |
@@ -77,7 +79,7 @@ static void mixcomwd_timerfun(unsigned long d) | |||
77 | { | 79 | { |
78 | mixcomwd_ping(); | 80 | mixcomwd_ping(); |
79 | 81 | ||
80 | mod_timer(&mixcomwd_timer,jiffies+ 5*HZ); | 82 | mod_timer(&mixcomwd_timer, jiffies + 5 * HZ); |
81 | } | 83 | } |
82 | 84 | ||
83 | /* | 85 | /* |
@@ -114,12 +116,8 @@ static int mixcomwd_release(struct inode *inode, struct file *file) | |||
114 | printk(KERN_ERR "mixcomwd: release called while internal timer alive"); | 116 | printk(KERN_ERR "mixcomwd: release called while internal timer alive"); |
115 | return -EBUSY; | 117 | return -EBUSY; |
116 | } | 118 | } |
117 | init_timer(&mixcomwd_timer); | ||
118 | mixcomwd_timer.expires=jiffies + 5 * HZ; | ||
119 | mixcomwd_timer.function=mixcomwd_timerfun; | ||
120 | mixcomwd_timer.data=0; | ||
121 | mixcomwd_timer_alive=1; | 119 | mixcomwd_timer_alive=1; |
122 | add_timer(&mixcomwd_timer); | 120 | mod_timer(&mixcomwd_timer, jiffies + 5 * HZ); |
123 | } else { | 121 | } else { |
124 | printk(KERN_CRIT "mixcomwd: WDT device closed unexpectedly. WDT will not stop!\n"); | 122 | printk(KERN_CRIT "mixcomwd: WDT device closed unexpectedly. WDT will not stop!\n"); |
125 | } | 123 | } |
@@ -285,7 +283,7 @@ static void __exit mixcomwd_exit(void) | |||
285 | if(mixcomwd_timer_alive) { | 283 | if(mixcomwd_timer_alive) { |
286 | printk(KERN_WARNING "mixcomwd: I quit now, hardware will" | 284 | printk(KERN_WARNING "mixcomwd: I quit now, hardware will" |
287 | " probably reboot!\n"); | 285 | " probably reboot!\n"); |
288 | del_timer(&mixcomwd_timer); | 286 | del_timer_sync(&mixcomwd_timer); |
289 | mixcomwd_timer_alive=0; | 287 | mixcomwd_timer_alive=0; |
290 | } | 288 | } |
291 | } | 289 | } |
diff --git a/drivers/char/watchdog/pc87413_wdt.c b/drivers/char/watchdog/pc87413_wdt.c index a77a90717ad2..3d3deae0d64b 100644 --- a/drivers/char/watchdog/pc87413_wdt.c +++ b/drivers/char/watchdog/pc87413_wdt.c | |||
@@ -631,5 +631,5 @@ module_param(timeout, int, 0); | |||
631 | MODULE_PARM_DESC(timeout, "Watchdog timeout in minutes (default=" __MODULE_STRING(timeout) ")."); | 631 | MODULE_PARM_DESC(timeout, "Watchdog timeout in minutes (default=" __MODULE_STRING(timeout) ")."); |
632 | 632 | ||
633 | module_param(nowayout, int, 0); | 633 | module_param(nowayout, int, 0); |
634 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 634 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
635 | 635 | ||
diff --git a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c index 8e1e6e48e0a7..6e8b5705b5b7 100644 --- a/drivers/char/watchdog/pcwd.c +++ b/drivers/char/watchdog/pcwd.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * PC Watchdog Driver | 2 | * PC Watchdog Driver |
3 | * by Ken Hollis (khollis@bitgate.com) | 3 | * by Ken Hollis (khollis@bitgate.com) |
4 | * | 4 | * |
5 | * Permission granted from Simon Machell (73244.1270@compuserve.com) | 5 | * Permission granted from Simon Machell (smachell@berkprod.com) |
6 | * Written for the Linux Kernel, and GPLed by Ken Hollis | 6 | * Written for the Linux Kernel, and GPLed by Ken Hollis |
7 | * | 7 | * |
8 | * 960107 Added request_region routines, modulized the whole thing. | 8 | * 960107 Added request_region routines, modulized the whole thing. |
@@ -70,8 +70,8 @@ | |||
70 | #include <asm/io.h> /* For inb/outb/... */ | 70 | #include <asm/io.h> /* For inb/outb/... */ |
71 | 71 | ||
72 | /* Module and version information */ | 72 | /* Module and version information */ |
73 | #define WATCHDOG_VERSION "1.17" | 73 | #define WATCHDOG_VERSION "1.18" |
74 | #define WATCHDOG_DATE "12 Feb 2006" | 74 | #define WATCHDOG_DATE "21 Jan 2007" |
75 | #define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog" | 75 | #define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog" |
76 | #define WATCHDOG_NAME "pcwd" | 76 | #define WATCHDOG_NAME "pcwd" |
77 | #define PFX WATCHDOG_NAME ": " | 77 | #define PFX WATCHDOG_NAME ": " |
@@ -132,6 +132,18 @@ | |||
132 | #define CMD_ISA_DELAY_TIME_8SECS 0x0C | 132 | #define CMD_ISA_DELAY_TIME_8SECS 0x0C |
133 | #define CMD_ISA_RESET_RELAYS 0x0D | 133 | #define CMD_ISA_RESET_RELAYS 0x0D |
134 | 134 | ||
135 | /* Watchdog's Dip Switch heartbeat values */ | ||
136 | static const int heartbeat_tbl [] = { | ||
137 | 20, /* OFF-OFF-OFF = 20 Sec */ | ||
138 | 40, /* OFF-OFF-ON = 40 Sec */ | ||
139 | 60, /* OFF-ON-OFF = 1 Min */ | ||
140 | 300, /* OFF-ON-ON = 5 Min */ | ||
141 | 600, /* ON-OFF-OFF = 10 Min */ | ||
142 | 1800, /* ON-OFF-ON = 30 Min */ | ||
143 | 3600, /* ON-ON-OFF = 1 Hour */ | ||
144 | 7200, /* ON-ON-ON = 2 hour */ | ||
145 | }; | ||
146 | |||
135 | /* | 147 | /* |
136 | * We are using an kernel timer to do the pinging of the watchdog | 148 | * We are using an kernel timer to do the pinging of the watchdog |
137 | * every ~500ms. We try to set the internal heartbeat of the | 149 | * every ~500ms. We try to set the internal heartbeat of the |
@@ -167,14 +179,14 @@ static int debug = QUIET; | |||
167 | module_param(debug, int, 0); | 179 | module_param(debug, int, 0); |
168 | MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); | 180 | MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); |
169 | 181 | ||
170 | #define WATCHDOG_HEARTBEAT 60 /* 60 sec default heartbeat */ | 182 | #define WATCHDOG_HEARTBEAT 0 /* default heartbeat = delay-time from dip-switches */ |
171 | static int heartbeat = WATCHDOG_HEARTBEAT; | 183 | static int heartbeat = WATCHDOG_HEARTBEAT; |
172 | module_param(heartbeat, int, 0); | 184 | module_param(heartbeat, int, 0); |
173 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<=heartbeat<=7200, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); | 185 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<=heartbeat<=7200 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); |
174 | 186 | ||
175 | static int nowayout = WATCHDOG_NOWAYOUT; | 187 | static int nowayout = WATCHDOG_NOWAYOUT; |
176 | module_param(nowayout, int, 0); | 188 | module_param(nowayout, int, 0); |
177 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 189 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
178 | 190 | ||
179 | /* | 191 | /* |
180 | * Internal functions | 192 | * Internal functions |
@@ -831,9 +843,7 @@ static int __devinit pcwatchdog_init(int base_addr) | |||
831 | /* clear the "card caused reboot" flag */ | 843 | /* clear the "card caused reboot" flag */ |
832 | pcwd_clear_status(); | 844 | pcwd_clear_status(); |
833 | 845 | ||
834 | init_timer(&pcwd_private.timer); | 846 | setup_timer(&pcwd_private.timer, pcwd_timer_ping, 0); |
835 | pcwd_private.timer.function = pcwd_timer_ping; | ||
836 | pcwd_private.timer.data = 0; | ||
837 | 847 | ||
838 | /* Disable the board */ | 848 | /* Disable the board */ |
839 | pcwd_stop(); | 849 | pcwd_stop(); |
@@ -844,6 +854,10 @@ static int __devinit pcwatchdog_init(int base_addr) | |||
844 | /* Show info about the card itself */ | 854 | /* Show info about the card itself */ |
845 | pcwd_show_card_info(); | 855 | pcwd_show_card_info(); |
846 | 856 | ||
857 | /* If heartbeat = 0 then we use the heartbeat from the dip-switches */ | ||
858 | if (heartbeat == 0) | ||
859 | heartbeat = heartbeat_tbl[(pcwd_get_option_switches() & 0x07)]; | ||
860 | |||
847 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ | 861 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ |
848 | if (pcwd_set_heartbeat(heartbeat)) { | 862 | if (pcwd_set_heartbeat(heartbeat)) { |
849 | pcwd_set_heartbeat(WATCHDOG_HEARTBEAT); | 863 | pcwd_set_heartbeat(WATCHDOG_HEARTBEAT); |
diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c index f4872c871063..61a89e959642 100644 --- a/drivers/char/watchdog/pcwd_pci.c +++ b/drivers/char/watchdog/pcwd_pci.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Berkshire PCI-PC Watchdog Card Driver | 2 | * Berkshire PCI-PC Watchdog Card Driver |
3 | * | 3 | * |
4 | * (c) Copyright 2003-2005 Wim Van Sebroeck <wim@iguana.be>. | 4 | * (c) Copyright 2003-2007 Wim Van Sebroeck <wim@iguana.be>. |
5 | * | 5 | * |
6 | * Based on source code of the following authors: | 6 | * Based on source code of the following authors: |
7 | * Ken Hollis <kenji@bitgate.com>, | 7 | * Ken Hollis <kenji@bitgate.com>, |
@@ -51,8 +51,8 @@ | |||
51 | #include <asm/io.h> /* For inb/outb/... */ | 51 | #include <asm/io.h> /* For inb/outb/... */ |
52 | 52 | ||
53 | /* Module and version information */ | 53 | /* Module and version information */ |
54 | #define WATCHDOG_VERSION "1.02" | 54 | #define WATCHDOG_VERSION "1.03" |
55 | #define WATCHDOG_DATE "03 Sep 2005" | 55 | #define WATCHDOG_DATE "21 Jan 2007" |
56 | #define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" | 56 | #define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" |
57 | #define WATCHDOG_NAME "pcwd_pci" | 57 | #define WATCHDOG_NAME "pcwd_pci" |
58 | #define PFX WATCHDOG_NAME ": " | 58 | #define PFX WATCHDOG_NAME ": " |
@@ -96,6 +96,18 @@ | |||
96 | #define CMD_WRITE_WATCHDOG_TIMEOUT 0x19 | 96 | #define CMD_WRITE_WATCHDOG_TIMEOUT 0x19 |
97 | #define CMD_GET_CLEAR_RESET_COUNT 0x84 | 97 | #define CMD_GET_CLEAR_RESET_COUNT 0x84 |
98 | 98 | ||
99 | /* Watchdog's Dip Switch heartbeat values */ | ||
100 | static const int heartbeat_tbl [] = { | ||
101 | 5, /* OFF-OFF-OFF = 5 Sec */ | ||
102 | 10, /* OFF-OFF-ON = 10 Sec */ | ||
103 | 30, /* OFF-ON-OFF = 30 Sec */ | ||
104 | 60, /* OFF-ON-ON = 1 Min */ | ||
105 | 300, /* ON-OFF-OFF = 5 Min */ | ||
106 | 600, /* ON-OFF-ON = 10 Min */ | ||
107 | 1800, /* ON-ON-OFF = 30 Min */ | ||
108 | 3600, /* ON-ON-ON = 1 hour */ | ||
109 | }; | ||
110 | |||
99 | /* We can only use 1 card due to the /dev/watchdog restriction */ | 111 | /* We can only use 1 card due to the /dev/watchdog restriction */ |
100 | static int cards_found; | 112 | static int cards_found; |
101 | 113 | ||
@@ -119,14 +131,14 @@ static int debug = QUIET; | |||
119 | module_param(debug, int, 0); | 131 | module_param(debug, int, 0); |
120 | MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); | 132 | MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); |
121 | 133 | ||
122 | #define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */ | 134 | #define WATCHDOG_HEARTBEAT 0 /* default heartbeat = delay-time from dip-switches */ |
123 | static int heartbeat = WATCHDOG_HEARTBEAT; | 135 | static int heartbeat = WATCHDOG_HEARTBEAT; |
124 | module_param(heartbeat, int, 0); | 136 | module_param(heartbeat, int, 0); |
125 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); | 137 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); |
126 | 138 | ||
127 | static int nowayout = WATCHDOG_NOWAYOUT; | 139 | static int nowayout = WATCHDOG_NOWAYOUT; |
128 | module_param(nowayout, int, 0); | 140 | module_param(nowayout, int, 0); |
129 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 141 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
130 | 142 | ||
131 | /* | 143 | /* |
132 | * Internal functions | 144 | * Internal functions |
@@ -286,7 +298,9 @@ static int pcipcwd_stop(void) | |||
286 | static int pcipcwd_keepalive(void) | 298 | static int pcipcwd_keepalive(void) |
287 | { | 299 | { |
288 | /* Re-trigger watchdog by writing to port 0 */ | 300 | /* Re-trigger watchdog by writing to port 0 */ |
301 | spin_lock(&pcipcwd_private.io_lock); | ||
289 | outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */ | 302 | outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */ |
303 | spin_unlock(&pcipcwd_private.io_lock); | ||
290 | 304 | ||
291 | if (debug >= DEBUG) | 305 | if (debug >= DEBUG) |
292 | printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n"); | 306 | printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n"); |
@@ -373,7 +387,9 @@ static int pcipcwd_get_temperature(int *temperature) | |||
373 | if (!pcipcwd_private.supports_temp) | 387 | if (!pcipcwd_private.supports_temp) |
374 | return -ENODEV; | 388 | return -ENODEV; |
375 | 389 | ||
390 | spin_lock(&pcipcwd_private.io_lock); | ||
376 | *temperature = inb_p(pcipcwd_private.io_addr); | 391 | *temperature = inb_p(pcipcwd_private.io_addr); |
392 | spin_unlock(&pcipcwd_private.io_lock); | ||
377 | 393 | ||
378 | /* | 394 | /* |
379 | * Convert celsius to fahrenheit, since this was | 395 | * Convert celsius to fahrenheit, since this was |
@@ -711,6 +727,10 @@ static int __devinit pcipcwd_card_init(struct pci_dev *pdev, | |||
711 | /* Show info about the card itself */ | 727 | /* Show info about the card itself */ |
712 | pcipcwd_show_card_info(); | 728 | pcipcwd_show_card_info(); |
713 | 729 | ||
730 | /* If heartbeat = 0 then we use the heartbeat from the dip-switches */ | ||
731 | if (heartbeat == 0) | ||
732 | heartbeat = heartbeat_tbl[(pcipcwd_get_option_switches() & 0x07)]; | ||
733 | |||
714 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ | 734 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ |
715 | if (pcipcwd_set_heartbeat(heartbeat)) { | 735 | if (pcipcwd_set_heartbeat(heartbeat)) { |
716 | pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT); | 736 | pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT); |
@@ -798,6 +818,8 @@ static int __init pcipcwd_init_module(void) | |||
798 | static void __exit pcipcwd_cleanup_module(void) | 818 | static void __exit pcipcwd_cleanup_module(void) |
799 | { | 819 | { |
800 | pci_unregister_driver(&pcipcwd_driver); | 820 | pci_unregister_driver(&pcipcwd_driver); |
821 | |||
822 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | ||
801 | } | 823 | } |
802 | 824 | ||
803 | module_init(pcipcwd_init_module); | 825 | module_init(pcipcwd_init_module); |
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c index 2da5ac99687c..31037f9c9ffe 100644 --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Berkshire USB-PC Watchdog Card Driver | 2 | * Berkshire USB-PC Watchdog Card Driver |
3 | * | 3 | * |
4 | * (c) Copyright 2004 Wim Van Sebroeck <wim@iguana.be>. | 4 | * (c) Copyright 2004-2007 Wim Van Sebroeck <wim@iguana.be>. |
5 | * | 5 | * |
6 | * Based on source code of the following authors: | 6 | * Based on source code of the following authors: |
7 | * Ken Hollis <kenji@bitgate.com>, | 7 | * Ken Hollis <kenji@bitgate.com>, |
@@ -24,26 +24,25 @@ | |||
24 | * http://www.berkprod.com/ or http://www.pcwatchdog.com/ | 24 | * http://www.berkprod.com/ or http://www.pcwatchdog.com/ |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/kernel.h> | 27 | #include <linux/module.h> /* For module specific items */ |
28 | #include <linux/errno.h> | 28 | #include <linux/moduleparam.h> /* For new moduleparam's */ |
29 | #include <linux/init.h> | 29 | #include <linux/types.h> /* For standard types (like size_t) */ |
30 | #include <linux/slab.h> | 30 | #include <linux/errno.h> /* For the -ENODEV/... values */ |
31 | #include <linux/module.h> | 31 | #include <linux/kernel.h> /* For printk/panic/... */ |
32 | #include <linux/moduleparam.h> | 32 | #include <linux/delay.h> /* For mdelay function */ |
33 | #include <linux/types.h> | 33 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ |
34 | #include <linux/delay.h> | 34 | #include <linux/watchdog.h> /* For the watchdog specific items */ |
35 | #include <linux/miscdevice.h> | 35 | #include <linux/notifier.h> /* For notifier support */ |
36 | #include <linux/watchdog.h> | 36 | #include <linux/reboot.h> /* For reboot_notifier stuff */ |
37 | #include <linux/notifier.h> | 37 | #include <linux/init.h> /* For __init/__exit/... */ |
38 | #include <linux/reboot.h> | 38 | #include <linux/fs.h> /* For file operations */ |
39 | #include <linux/fs.h> | 39 | #include <linux/usb.h> /* For USB functions */ |
40 | #include <linux/smp_lock.h> | 40 | #include <linux/slab.h> /* For kmalloc, ... */ |
41 | #include <linux/completion.h> | 41 | #include <linux/mutex.h> /* For mutex locking */ |
42 | #include <asm/uaccess.h> | ||
43 | #include <linux/usb.h> | ||
44 | #include <linux/mutex.h> | ||
45 | #include <linux/hid.h> /* For HID_REQ_SET_REPORT & HID_DT_REPORT */ | 42 | #include <linux/hid.h> /* For HID_REQ_SET_REPORT & HID_DT_REPORT */ |
46 | 43 | ||
44 | #include <asm/uaccess.h> /* For copy_to_user/put_user/... */ | ||
45 | |||
47 | 46 | ||
48 | #ifdef CONFIG_USB_DEBUG | 47 | #ifdef CONFIG_USB_DEBUG |
49 | static int debug = 1; | 48 | static int debug = 1; |
@@ -57,8 +56,8 @@ | |||
57 | 56 | ||
58 | 57 | ||
59 | /* Module and Version Information */ | 58 | /* Module and Version Information */ |
60 | #define DRIVER_VERSION "1.01" | 59 | #define DRIVER_VERSION "1.02" |
61 | #define DRIVER_DATE "15 Mar 2005" | 60 | #define DRIVER_DATE "21 Jan 2007" |
62 | #define DRIVER_AUTHOR "Wim Van Sebroeck <wim@iguana.be>" | 61 | #define DRIVER_AUTHOR "Wim Van Sebroeck <wim@iguana.be>" |
63 | #define DRIVER_DESC "Berkshire USB-PC Watchdog driver" | 62 | #define DRIVER_DESC "Berkshire USB-PC Watchdog driver" |
64 | #define DRIVER_LICENSE "GPL" | 63 | #define DRIVER_LICENSE "GPL" |
@@ -75,14 +74,14 @@ MODULE_ALIAS_MISCDEV(TEMP_MINOR); | |||
75 | module_param(debug, int, 0); | 74 | module_param(debug, int, 0); |
76 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | 75 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
77 | 76 | ||
78 | #define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */ | 77 | #define WATCHDOG_HEARTBEAT 0 /* default heartbeat = delay-time from dip-switches */ |
79 | static int heartbeat = WATCHDOG_HEARTBEAT; | 78 | static int heartbeat = WATCHDOG_HEARTBEAT; |
80 | module_param(heartbeat, int, 0); | 79 | module_param(heartbeat, int, 0); |
81 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); | 80 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); |
82 | 81 | ||
83 | static int nowayout = WATCHDOG_NOWAYOUT; | 82 | static int nowayout = WATCHDOG_NOWAYOUT; |
84 | module_param(nowayout, int, 0); | 83 | module_param(nowayout, int, 0); |
85 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 84 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
86 | 85 | ||
87 | /* The vendor and product id's for the USB-PC Watchdog card */ | 86 | /* The vendor and product id's for the USB-PC Watchdog card */ |
88 | #define USB_PCWD_VENDOR_ID 0x0c98 | 87 | #define USB_PCWD_VENDOR_ID 0x0c98 |
@@ -110,6 +109,18 @@ MODULE_DEVICE_TABLE (usb, usb_pcwd_table); | |||
110 | #define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */ | 109 | #define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */ |
111 | #define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG | 110 | #define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG |
112 | 111 | ||
112 | /* Watchdog's Dip Switch heartbeat values */ | ||
113 | static const int heartbeat_tbl [] = { | ||
114 | 5, /* OFF-OFF-OFF = 5 Sec */ | ||
115 | 10, /* OFF-OFF-ON = 10 Sec */ | ||
116 | 30, /* OFF-ON-OFF = 30 Sec */ | ||
117 | 60, /* OFF-ON-ON = 1 Min */ | ||
118 | 300, /* ON-OFF-OFF = 5 Min */ | ||
119 | 600, /* ON-OFF-ON = 10 Min */ | ||
120 | 1800, /* ON-ON-OFF = 30 Min */ | ||
121 | 3600, /* ON-ON-ON = 1 hour */ | ||
122 | }; | ||
123 | |||
113 | /* We can only use 1 card due to the /dev/watchdog restriction */ | 124 | /* We can only use 1 card due to the /dev/watchdog restriction */ |
114 | static int cards_found; | 125 | static int cards_found; |
115 | 126 | ||
@@ -682,6 +693,10 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi | |||
682 | ((option_switches & 0x10) ? "ON" : "OFF"), | 693 | ((option_switches & 0x10) ? "ON" : "OFF"), |
683 | ((option_switches & 0x08) ? "ON" : "OFF")); | 694 | ((option_switches & 0x08) ? "ON" : "OFF")); |
684 | 695 | ||
696 | /* If heartbeat = 0 then we use the heartbeat from the dip-switches */ | ||
697 | if (heartbeat == 0) | ||
698 | heartbeat = heartbeat_tbl[(option_switches & 0x07)]; | ||
699 | |||
685 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ | 700 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ |
686 | if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) { | 701 | if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) { |
687 | usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT); | 702 | usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT); |
diff --git a/drivers/char/watchdog/pnx4008_wdt.c b/drivers/char/watchdog/pnx4008_wdt.c index ff6f1ca1e5e7..5991add702b0 100644 --- a/drivers/char/watchdog/pnx4008_wdt.c +++ b/drivers/char/watchdog/pnx4008_wdt.c | |||
@@ -283,7 +283,8 @@ static int pnx4008_wdt_probe(struct platform_device *pdev) | |||
283 | wdt_base = (void __iomem *)IO_ADDRESS(res->start); | 283 | wdt_base = (void __iomem *)IO_ADDRESS(res->start); |
284 | 284 | ||
285 | wdt_clk = clk_get(&pdev->dev, "wdt_ck"); | 285 | wdt_clk = clk_get(&pdev->dev, "wdt_ck"); |
286 | if (!wdt_clk) { | 286 | if (IS_ERR(wdt_clk)) { |
287 | ret = PTR_ERR(wdt_clk); | ||
287 | release_resource(wdt_mem); | 288 | release_resource(wdt_mem); |
288 | kfree(wdt_mem); | 289 | kfree(wdt_mem); |
289 | goto out; | 290 | goto out; |
diff --git a/drivers/char/watchdog/rm9k_wdt.c b/drivers/char/watchdog/rm9k_wdt.c index b4678839d3bb..5c921e471564 100644 --- a/drivers/char/watchdog/rm9k_wdt.c +++ b/drivers/char/watchdog/rm9k_wdt.c | |||
@@ -192,7 +192,7 @@ static int wdt_gpi_open(struct inode *inode, struct file *file) | |||
192 | locked = 0; | 192 | locked = 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | res = request_irq(wd_irq, wdt_gpi_irqhdl, SA_SHIRQ | SA_INTERRUPT, | 195 | res = request_irq(wd_irq, wdt_gpi_irqhdl, IRQF_SHARED | IRQF_DISABLED, |
196 | wdt_gpi_name, &miscdev); | 196 | wdt_gpi_name, &miscdev); |
197 | if (unlikely(res)) | 197 | if (unlikely(res)) |
198 | return res; | 198 | return res; |
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index 18cb050c3862..dff6cb5dc9a7 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c | |||
@@ -78,7 +78,7 @@ MODULE_PARM_DESC(tmr_margin, "Watchdog tmr_margin in seconds. default=" __MODULE | |||
78 | 78 | ||
79 | MODULE_PARM_DESC(tmr_atboot, "Watchdog is started at boot time if set to 1, default=" __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT)); | 79 | MODULE_PARM_DESC(tmr_atboot, "Watchdog is started at boot time if set to 1, default=" __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT)); |
80 | 80 | ||
81 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 81 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
82 | 82 | ||
83 | MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to reboot (default depends on ONLY_TESTING)"); | 83 | MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to reboot (default depends on ONLY_TESTING)"); |
84 | 84 | ||
@@ -366,13 +366,15 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
366 | wdt_mem = request_mem_region(res->start, size, pdev->name); | 366 | wdt_mem = request_mem_region(res->start, size, pdev->name); |
367 | if (wdt_mem == NULL) { | 367 | if (wdt_mem == NULL) { |
368 | printk(KERN_INFO PFX "failed to get memory region\n"); | 368 | printk(KERN_INFO PFX "failed to get memory region\n"); |
369 | return -ENOENT; | 369 | ret = -ENOENT; |
370 | goto err_req; | ||
370 | } | 371 | } |
371 | 372 | ||
372 | wdt_base = ioremap(res->start, size); | 373 | wdt_base = ioremap(res->start, size); |
373 | if (wdt_base == 0) { | 374 | if (wdt_base == 0) { |
374 | printk(KERN_INFO PFX "failed to ioremap() region\n"); | 375 | printk(KERN_INFO PFX "failed to ioremap() region\n"); |
375 | return -EINVAL; | 376 | ret = -EINVAL; |
377 | goto err_req; | ||
376 | } | 378 | } |
377 | 379 | ||
378 | DBG("probe: mapped wdt_base=%p\n", wdt_base); | 380 | DBG("probe: mapped wdt_base=%p\n", wdt_base); |
@@ -380,22 +382,21 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
380 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 382 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
381 | if (res == NULL) { | 383 | if (res == NULL) { |
382 | printk(KERN_INFO PFX "failed to get irq resource\n"); | 384 | printk(KERN_INFO PFX "failed to get irq resource\n"); |
383 | iounmap(wdt_base); | 385 | ret = -ENOENT; |
384 | return -ENOENT; | 386 | goto err_map; |
385 | } | 387 | } |
386 | 388 | ||
387 | ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, pdev); | 389 | ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, pdev); |
388 | if (ret != 0) { | 390 | if (ret != 0) { |
389 | printk(KERN_INFO PFX "failed to install irq (%d)\n", ret); | 391 | printk(KERN_INFO PFX "failed to install irq (%d)\n", ret); |
390 | iounmap(wdt_base); | 392 | goto err_map; |
391 | return ret; | ||
392 | } | 393 | } |
393 | 394 | ||
394 | wdt_clock = clk_get(&pdev->dev, "watchdog"); | 395 | wdt_clock = clk_get(&pdev->dev, "watchdog"); |
395 | if (wdt_clock == NULL) { | 396 | if (IS_ERR(wdt_clock)) { |
396 | printk(KERN_INFO PFX "failed to find watchdog clock source\n"); | 397 | printk(KERN_INFO PFX "failed to find watchdog clock source\n"); |
397 | iounmap(wdt_base); | 398 | ret = PTR_ERR(wdt_clock); |
398 | return -ENOENT; | 399 | goto err_irq; |
399 | } | 400 | } |
400 | 401 | ||
401 | clk_enable(wdt_clock); | 402 | clk_enable(wdt_clock); |
@@ -418,8 +419,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
418 | if (ret) { | 419 | if (ret) { |
419 | printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n", | 420 | printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n", |
420 | WATCHDOG_MINOR, ret); | 421 | WATCHDOG_MINOR, ret); |
421 | iounmap(wdt_base); | 422 | goto err_clk; |
422 | return ret; | ||
423 | } | 423 | } |
424 | 424 | ||
425 | if (tmr_atboot && started == 0) { | 425 | if (tmr_atboot && started == 0) { |
@@ -434,26 +434,36 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
434 | } | 434 | } |
435 | 435 | ||
436 | return 0; | 436 | return 0; |
437 | |||
438 | err_clk: | ||
439 | clk_disable(wdt_clock); | ||
440 | clk_put(wdt_clock); | ||
441 | |||
442 | err_irq: | ||
443 | free_irq(wdt_irq->start, pdev); | ||
444 | |||
445 | err_map: | ||
446 | iounmap(wdt_base); | ||
447 | |||
448 | err_req: | ||
449 | release_resource(wdt_mem); | ||
450 | kfree(wdt_mem); | ||
451 | |||
452 | return ret; | ||
437 | } | 453 | } |
438 | 454 | ||
439 | static int s3c2410wdt_remove(struct platform_device *dev) | 455 | static int s3c2410wdt_remove(struct platform_device *dev) |
440 | { | 456 | { |
441 | if (wdt_mem != NULL) { | 457 | release_resource(wdt_mem); |
442 | release_resource(wdt_mem); | 458 | kfree(wdt_mem); |
443 | kfree(wdt_mem); | 459 | wdt_mem = NULL; |
444 | wdt_mem = NULL; | ||
445 | } | ||
446 | 460 | ||
447 | if (wdt_irq != NULL) { | 461 | free_irq(wdt_irq->start, dev); |
448 | free_irq(wdt_irq->start, dev); | 462 | wdt_irq = NULL; |
449 | wdt_irq = NULL; | ||
450 | } | ||
451 | 463 | ||
452 | if (wdt_clock != NULL) { | 464 | clk_disable(wdt_clock); |
453 | clk_disable(wdt_clock); | 465 | clk_put(wdt_clock); |
454 | clk_put(wdt_clock); | 466 | wdt_clock = NULL; |
455 | wdt_clock = NULL; | ||
456 | } | ||
457 | 467 | ||
458 | iounmap(wdt_base); | 468 | iounmap(wdt_base); |
459 | misc_deregister(&s3c2410wdt_miscdev); | 469 | misc_deregister(&s3c2410wdt_miscdev); |
diff --git a/drivers/char/watchdog/sbc60xxwdt.c b/drivers/char/watchdog/sbc60xxwdt.c index c7b2045bc76b..b6282039198c 100644 --- a/drivers/char/watchdog/sbc60xxwdt.c +++ b/drivers/char/watchdog/sbc60xxwdt.c | |||
@@ -100,10 +100,10 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, defau | |||
100 | 100 | ||
101 | static int nowayout = WATCHDOG_NOWAYOUT; | 101 | static int nowayout = WATCHDOG_NOWAYOUT; |
102 | module_param(nowayout, int, 0); | 102 | module_param(nowayout, int, 0); |
103 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 103 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
104 | 104 | ||
105 | static void wdt_timer_ping(unsigned long); | 105 | static void wdt_timer_ping(unsigned long); |
106 | static struct timer_list timer; | 106 | static DEFINE_TIMER(timer, wdt_timer_ping, 0, 0); |
107 | static unsigned long next_heartbeat; | 107 | static unsigned long next_heartbeat; |
108 | static unsigned long wdt_is_open; | 108 | static unsigned long wdt_is_open; |
109 | static char wdt_expect_close; | 109 | static char wdt_expect_close; |
@@ -122,8 +122,7 @@ static void wdt_timer_ping(unsigned long data) | |||
122 | /* Ping the WDT by reading from wdt_start */ | 122 | /* Ping the WDT by reading from wdt_start */ |
123 | inb_p(wdt_start); | 123 | inb_p(wdt_start); |
124 | /* Re-set the timer interval */ | 124 | /* Re-set the timer interval */ |
125 | timer.expires = jiffies + WDT_INTERVAL; | 125 | mod_timer(&timer, jiffies + WDT_INTERVAL); |
126 | add_timer(&timer); | ||
127 | } else { | 126 | } else { |
128 | printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); | 127 | printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); |
129 | } | 128 | } |
@@ -138,8 +137,7 @@ static void wdt_startup(void) | |||
138 | next_heartbeat = jiffies + (timeout * HZ); | 137 | next_heartbeat = jiffies + (timeout * HZ); |
139 | 138 | ||
140 | /* Start the timer */ | 139 | /* Start the timer */ |
141 | timer.expires = jiffies + WDT_INTERVAL; | 140 | mod_timer(&timer, jiffies + WDT_INTERVAL); |
142 | add_timer(&timer); | ||
143 | printk(KERN_INFO PFX "Watchdog timer is now enabled.\n"); | 141 | printk(KERN_INFO PFX "Watchdog timer is now enabled.\n"); |
144 | } | 142 | } |
145 | 143 | ||
@@ -363,10 +361,6 @@ static int __init sbc60xxwdt_init(void) | |||
363 | } | 361 | } |
364 | } | 362 | } |
365 | 363 | ||
366 | init_timer(&timer); | ||
367 | timer.function = wdt_timer_ping; | ||
368 | timer.data = 0; | ||
369 | |||
370 | rc = misc_register(&wdt_miscdev); | 364 | rc = misc_register(&wdt_miscdev); |
371 | if (rc) | 365 | if (rc) |
372 | { | 366 | { |
diff --git a/drivers/char/watchdog/sbc8360.c b/drivers/char/watchdog/sbc8360.c index 41fc6f80c493..67ae42685e75 100644 --- a/drivers/char/watchdog/sbc8360.c +++ b/drivers/char/watchdog/sbc8360.c | |||
@@ -204,7 +204,7 @@ module_param(timeout, int, 0); | |||
204 | MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))"); | 204 | MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))"); |
205 | module_param(nowayout, int, 0); | 205 | module_param(nowayout, int, 0); |
206 | MODULE_PARM_DESC(nowayout, | 206 | MODULE_PARM_DESC(nowayout, |
207 | "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 207 | "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
208 | 208 | ||
209 | /* | 209 | /* |
210 | * Kernel methods. | 210 | * Kernel methods. |
diff --git a/drivers/char/watchdog/sbc_epx_c3.c b/drivers/char/watchdog/sbc_epx_c3.c index 8882b427d24f..82cbd8809a69 100644 --- a/drivers/char/watchdog/sbc_epx_c3.c +++ b/drivers/char/watchdog/sbc_epx_c3.c | |||
@@ -35,7 +35,7 @@ static int epx_c3_alive; | |||
35 | 35 | ||
36 | static int nowayout = WATCHDOG_NOWAYOUT; | 36 | static int nowayout = WATCHDOG_NOWAYOUT; |
37 | module_param(nowayout, int, 0); | 37 | module_param(nowayout, int, 0); |
38 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 38 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
39 | 39 | ||
40 | #define EPXC3_WATCHDOG_CTL_REG 0x1ee /* write 1 to enable, 0 to disable */ | 40 | #define EPXC3_WATCHDOG_CTL_REG 0x1ee /* write 1 to enable, 0 to disable */ |
41 | #define EPXC3_WATCHDOG_PET_REG 0x1ef /* write anything to pet once enabled */ | 41 | #define EPXC3_WATCHDOG_PET_REG 0x1ef /* write anything to pet once enabled */ |
diff --git a/drivers/char/watchdog/sc1200wdt.c b/drivers/char/watchdog/sc1200wdt.c index e3239833e4b0..1e4a8d751a71 100644 --- a/drivers/char/watchdog/sc1200wdt.c +++ b/drivers/char/watchdog/sc1200wdt.c | |||
@@ -92,7 +92,7 @@ MODULE_PARM_DESC(timeout, "range is 0-255 minutes, default is 1"); | |||
92 | 92 | ||
93 | static int nowayout = WATCHDOG_NOWAYOUT; | 93 | static int nowayout = WATCHDOG_NOWAYOUT; |
94 | module_param(nowayout, int, 0); | 94 | module_param(nowayout, int, 0); |
95 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 95 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
96 | 96 | ||
97 | 97 | ||
98 | 98 | ||
diff --git a/drivers/char/watchdog/sc520_wdt.c b/drivers/char/watchdog/sc520_wdt.c index caec37ba750a..2676a43895a7 100644 --- a/drivers/char/watchdog/sc520_wdt.c +++ b/drivers/char/watchdog/sc520_wdt.c | |||
@@ -97,7 +97,7 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, defau | |||
97 | 97 | ||
98 | static int nowayout = WATCHDOG_NOWAYOUT; | 98 | static int nowayout = WATCHDOG_NOWAYOUT; |
99 | module_param(nowayout, int, 0); | 99 | module_param(nowayout, int, 0); |
100 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 100 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
101 | 101 | ||
102 | /* | 102 | /* |
103 | * AMD Elan SC520 - Watchdog Timer Registers | 103 | * AMD Elan SC520 - Watchdog Timer Registers |
@@ -121,7 +121,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CON | |||
121 | static __u16 __iomem *wdtmrctl; | 121 | static __u16 __iomem *wdtmrctl; |
122 | 122 | ||
123 | static void wdt_timer_ping(unsigned long); | 123 | static void wdt_timer_ping(unsigned long); |
124 | static struct timer_list timer; | 124 | static DEFINE_TIMER(timer, wdt_timer_ping, 0, 0); |
125 | static unsigned long next_heartbeat; | 125 | static unsigned long next_heartbeat; |
126 | static unsigned long wdt_is_open; | 126 | static unsigned long wdt_is_open; |
127 | static char wdt_expect_close; | 127 | static char wdt_expect_close; |
@@ -145,8 +145,7 @@ static void wdt_timer_ping(unsigned long data) | |||
145 | spin_unlock(&wdt_spinlock); | 145 | spin_unlock(&wdt_spinlock); |
146 | 146 | ||
147 | /* Re-set the timer interval */ | 147 | /* Re-set the timer interval */ |
148 | timer.expires = jiffies + WDT_INTERVAL; | 148 | mod_timer(&timer, jiffies + WDT_INTERVAL); |
149 | add_timer(&timer); | ||
150 | } else { | 149 | } else { |
151 | printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); | 150 | printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); |
152 | } | 151 | } |
@@ -179,8 +178,7 @@ static int wdt_startup(void) | |||
179 | next_heartbeat = jiffies + (timeout * HZ); | 178 | next_heartbeat = jiffies + (timeout * HZ); |
180 | 179 | ||
181 | /* Start the timer */ | 180 | /* Start the timer */ |
182 | timer.expires = jiffies + WDT_INTERVAL; | 181 | mod_timer(&timer, jiffies + WDT_INTERVAL); |
183 | add_timer(&timer); | ||
184 | 182 | ||
185 | /* Start the watchdog */ | 183 | /* Start the watchdog */ |
186 | wdt_config(WDT_ENB | WDT_WRST_ENB | WDT_EXP_SEL_04); | 184 | wdt_config(WDT_ENB | WDT_WRST_ENB | WDT_EXP_SEL_04); |
@@ -389,10 +387,6 @@ static int __init sc520_wdt_init(void) | |||
389 | 387 | ||
390 | spin_lock_init(&wdt_spinlock); | 388 | spin_lock_init(&wdt_spinlock); |
391 | 389 | ||
392 | init_timer(&timer); | ||
393 | timer.function = wdt_timer_ping; | ||
394 | timer.data = 0; | ||
395 | |||
396 | /* Check that the timeout value is within it's range ; if not reset to the default */ | 390 | /* Check that the timeout value is within it's range ; if not reset to the default */ |
397 | if (wdt_set_heartbeat(timeout)) { | 391 | if (wdt_set_heartbeat(timeout)) { |
398 | wdt_set_heartbeat(WATCHDOG_TIMEOUT); | 392 | wdt_set_heartbeat(WATCHDOG_TIMEOUT); |
diff --git a/drivers/char/watchdog/shwdt.c b/drivers/char/watchdog/shwdt.c index dc403629aeb3..cecbedd473a4 100644 --- a/drivers/char/watchdog/shwdt.c +++ b/drivers/char/watchdog/shwdt.c | |||
@@ -65,10 +65,12 @@ static int clock_division_ratio = WTCSR_CKS_4096; | |||
65 | 65 | ||
66 | #define next_ping_period(cks) msecs_to_jiffies(cks - 4) | 66 | #define next_ping_period(cks) msecs_to_jiffies(cks - 4) |
67 | 67 | ||
68 | static void sh_wdt_ping(unsigned long data); | ||
69 | |||
68 | static unsigned long shwdt_is_open; | 70 | static unsigned long shwdt_is_open; |
69 | static struct watchdog_info sh_wdt_info; | 71 | static struct watchdog_info sh_wdt_info; |
70 | static char shwdt_expect_close; | 72 | static char shwdt_expect_close; |
71 | static struct timer_list timer; | 73 | static DEFINE_TIMER(timer, sh_wdt_ping, 0, 0); |
72 | static unsigned long next_heartbeat; | 74 | static unsigned long next_heartbeat; |
73 | 75 | ||
74 | #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ | 76 | #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ |
@@ -433,10 +435,6 @@ static int __init sh_wdt_init(void) | |||
433 | "be 1<=x<=3600, using %d\n", heartbeat); | 435 | "be 1<=x<=3600, using %d\n", heartbeat); |
434 | } | 436 | } |
435 | 437 | ||
436 | init_timer(&timer); | ||
437 | timer.function = sh_wdt_ping; | ||
438 | timer.data = 0; | ||
439 | |||
440 | rc = register_reboot_notifier(&sh_wdt_notifier); | 438 | rc = register_reboot_notifier(&sh_wdt_notifier); |
441 | if (unlikely(rc)) { | 439 | if (unlikely(rc)) { |
442 | printk(KERN_ERR PFX "Can't register reboot notifier (err=%d)\n", | 440 | printk(KERN_ERR PFX "Can't register reboot notifier (err=%d)\n", |
diff --git a/drivers/char/watchdog/smsc37b787_wdt.c b/drivers/char/watchdog/smsc37b787_wdt.c index a9681d580dd3..d3cb0a766020 100644 --- a/drivers/char/watchdog/smsc37b787_wdt.c +++ b/drivers/char/watchdog/smsc37b787_wdt.c | |||
@@ -624,4 +624,4 @@ module_param(timeout, int, 0); | |||
624 | MODULE_PARM_DESC(timeout, "range is 1-255 units, default is 60"); | 624 | MODULE_PARM_DESC(timeout, "range is 1-255 units, default is 60"); |
625 | 625 | ||
626 | module_param(nowayout, int, 0); | 626 | module_param(nowayout, int, 0); |
627 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 627 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
diff --git a/drivers/char/watchdog/softdog.c b/drivers/char/watchdog/softdog.c index 4067e1f8a368..9c3694909243 100644 --- a/drivers/char/watchdog/softdog.c +++ b/drivers/char/watchdog/softdog.c | |||
@@ -59,7 +59,7 @@ MODULE_PARM_DESC(soft_margin, "Watchdog soft_margin in seconds. (0<soft_margin<6 | |||
59 | 59 | ||
60 | static int nowayout = WATCHDOG_NOWAYOUT; | 60 | static int nowayout = WATCHDOG_NOWAYOUT; |
61 | module_param(nowayout, int, 0); | 61 | module_param(nowayout, int, 0); |
62 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 62 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
63 | 63 | ||
64 | #ifdef ONLY_TESTING | 64 | #ifdef ONLY_TESTING |
65 | static int soft_noboot = 1; | 65 | static int soft_noboot = 1; |
diff --git a/drivers/char/watchdog/w83627hf_wdt.c b/drivers/char/watchdog/w83627hf_wdt.c index 07d4bff27226..337ee42c90dd 100644 --- a/drivers/char/watchdog/w83627hf_wdt.c +++ b/drivers/char/watchdog/w83627hf_wdt.c | |||
@@ -58,7 +58,7 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=63, defaul | |||
58 | 58 | ||
59 | static int nowayout = WATCHDOG_NOWAYOUT; | 59 | static int nowayout = WATCHDOG_NOWAYOUT; |
60 | module_param(nowayout, int, 0); | 60 | module_param(nowayout, int, 0); |
61 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 61 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
62 | 62 | ||
63 | /* | 63 | /* |
64 | * Kernel methods. | 64 | * Kernel methods. |
diff --git a/drivers/char/watchdog/w83697hf_wdt.c b/drivers/char/watchdog/w83697hf_wdt.c index c960ec110dd7..d9e821d08deb 100644 --- a/drivers/char/watchdog/w83697hf_wdt.c +++ b/drivers/char/watchdog/w83697hf_wdt.c | |||
@@ -60,7 +60,7 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, defau | |||
60 | 60 | ||
61 | static int nowayout = WATCHDOG_NOWAYOUT; | 61 | static int nowayout = WATCHDOG_NOWAYOUT; |
62 | module_param(nowayout, int, 0); | 62 | module_param(nowayout, int, 0); |
63 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 63 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
64 | 64 | ||
65 | /* | 65 | /* |
66 | * Kernel methods. | 66 | * Kernel methods. |
diff --git a/drivers/char/watchdog/w83877f_wdt.c b/drivers/char/watchdog/w83877f_wdt.c index b0e5f84d6baf..3c88fe18f4f4 100644 --- a/drivers/char/watchdog/w83877f_wdt.c +++ b/drivers/char/watchdog/w83877f_wdt.c | |||
@@ -87,10 +87,10 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, defau | |||
87 | 87 | ||
88 | static int nowayout = WATCHDOG_NOWAYOUT; | 88 | static int nowayout = WATCHDOG_NOWAYOUT; |
89 | module_param(nowayout, int, 0); | 89 | module_param(nowayout, int, 0); |
90 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 90 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
91 | 91 | ||
92 | static void wdt_timer_ping(unsigned long); | 92 | static void wdt_timer_ping(unsigned long); |
93 | static struct timer_list timer; | 93 | static DEFINE_TIMER(timer, wdt_timer_ping, 0, 0); |
94 | static unsigned long next_heartbeat; | 94 | static unsigned long next_heartbeat; |
95 | static unsigned long wdt_is_open; | 95 | static unsigned long wdt_is_open; |
96 | static char wdt_expect_close; | 96 | static char wdt_expect_close; |
@@ -114,8 +114,7 @@ static void wdt_timer_ping(unsigned long data) | |||
114 | inb_p(WDT_PING); | 114 | inb_p(WDT_PING); |
115 | 115 | ||
116 | /* Re-set the timer interval */ | 116 | /* Re-set the timer interval */ |
117 | timer.expires = jiffies + WDT_INTERVAL; | 117 | mod_timer(&timer, jiffies + WDT_INTERVAL); |
118 | add_timer(&timer); | ||
119 | 118 | ||
120 | spin_unlock(&wdt_spinlock); | 119 | spin_unlock(&wdt_spinlock); |
121 | 120 | ||
@@ -155,8 +154,7 @@ static void wdt_startup(void) | |||
155 | next_heartbeat = jiffies + (timeout * HZ); | 154 | next_heartbeat = jiffies + (timeout * HZ); |
156 | 155 | ||
157 | /* Start the timer */ | 156 | /* Start the timer */ |
158 | timer.expires = jiffies + WDT_INTERVAL; | 157 | mod_timer(&timer, jiffies + WDT_INTERVAL); |
159 | add_timer(&timer); | ||
160 | 158 | ||
161 | wdt_change(WDT_ENABLE); | 159 | wdt_change(WDT_ENABLE); |
162 | 160 | ||
@@ -377,10 +375,6 @@ static int __init w83877f_wdt_init(void) | |||
377 | goto err_out_region1; | 375 | goto err_out_region1; |
378 | } | 376 | } |
379 | 377 | ||
380 | init_timer(&timer); | ||
381 | timer.function = wdt_timer_ping; | ||
382 | timer.data = 0; | ||
383 | |||
384 | rc = misc_register(&wdt_miscdev); | 378 | rc = misc_register(&wdt_miscdev); |
385 | if (rc) | 379 | if (rc) |
386 | { | 380 | { |
diff --git a/drivers/char/watchdog/w83977f_wdt.c b/drivers/char/watchdog/w83977f_wdt.c index 2c8d5d8bd4e8..157968442891 100644 --- a/drivers/char/watchdog/w83977f_wdt.c +++ b/drivers/char/watchdog/w83977f_wdt.c | |||
@@ -59,7 +59,7 @@ MODULE_PARM_DESC(testmode,"Watchdog testmode (1 = no reboot), default=0"); | |||
59 | 59 | ||
60 | static int nowayout = WATCHDOG_NOWAYOUT; | 60 | static int nowayout = WATCHDOG_NOWAYOUT; |
61 | module_param(nowayout, int, 0); | 61 | module_param(nowayout, int, 0); |
62 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 62 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Start the watchdog | 65 | * Start the watchdog |
diff --git a/drivers/char/watchdog/wafer5823wdt.c b/drivers/char/watchdog/wafer5823wdt.c index 163e028ef9ed..950905d3c39f 100644 --- a/drivers/char/watchdog/wafer5823wdt.c +++ b/drivers/char/watchdog/wafer5823wdt.c | |||
@@ -65,7 +65,7 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, defau | |||
65 | 65 | ||
66 | static int nowayout = WATCHDOG_NOWAYOUT; | 66 | static int nowayout = WATCHDOG_NOWAYOUT; |
67 | module_param(nowayout, int, 0); | 67 | module_param(nowayout, int, 0); |
68 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 68 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
69 | 69 | ||
70 | static void wafwdt_ping(void) | 70 | static void wafwdt_ping(void) |
71 | { | 71 | { |
diff --git a/drivers/char/watchdog/wdt.c b/drivers/char/watchdog/wdt.c index 517fbd8643f8..0a3de6a02442 100644 --- a/drivers/char/watchdog/wdt.c +++ b/drivers/char/watchdog/wdt.c | |||
@@ -64,7 +64,7 @@ MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, | |||
64 | 64 | ||
65 | static int nowayout = WATCHDOG_NOWAYOUT; | 65 | static int nowayout = WATCHDOG_NOWAYOUT; |
66 | module_param(nowayout, int, 0); | 66 | module_param(nowayout, int, 0); |
67 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 67 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
68 | 68 | ||
69 | /* You must set these - there is no sane way to probe for this board. */ | 69 | /* You must set these - there is no sane way to probe for this board. */ |
70 | static int io=0x240; | 70 | static int io=0x240; |
diff --git a/drivers/char/watchdog/wdt977.c b/drivers/char/watchdog/wdt977.c index 6253041b235b..7d300ff7ab07 100644 --- a/drivers/char/watchdog/wdt977.c +++ b/drivers/char/watchdog/wdt977.c | |||
@@ -68,7 +68,7 @@ MODULE_PARM_DESC(testmode,"Watchdog testmode (1 = no reboot), default=0"); | |||
68 | 68 | ||
69 | static int nowayout = WATCHDOG_NOWAYOUT; | 69 | static int nowayout = WATCHDOG_NOWAYOUT; |
70 | module_param(nowayout, int, 0); | 70 | module_param(nowayout, int, 0); |
71 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 71 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
72 | 72 | ||
73 | /* | 73 | /* |
74 | * Start the watchdog | 74 | * Start the watchdog |
diff --git a/drivers/char/watchdog/wdt_pci.c b/drivers/char/watchdog/wdt_pci.c index ce1261c5cbce..6baf4ae42c9d 100644 --- a/drivers/char/watchdog/wdt_pci.c +++ b/drivers/char/watchdog/wdt_pci.c | |||
@@ -90,7 +90,7 @@ MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, | |||
90 | 90 | ||
91 | static int nowayout = WATCHDOG_NOWAYOUT; | 91 | static int nowayout = WATCHDOG_NOWAYOUT; |
92 | module_param(nowayout, int, 0); | 92 | module_param(nowayout, int, 0); |
93 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | 93 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
94 | 94 | ||
95 | #ifdef CONFIG_WDT_501_PCI | 95 | #ifdef CONFIG_WDT_501_PCI |
96 | /* Support for the Fan Tachometer on the PCI-WDT501 */ | 96 | /* Support for the Fan Tachometer on the PCI-WDT501 */ |
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c index b6bcdbbf57b3..ccaa6a39cb4b 100644 --- a/drivers/clocksource/acpi_pm.c +++ b/drivers/clocksource/acpi_pm.c | |||
@@ -16,15 +16,13 @@ | |||
16 | * This file is licensed under the GPL v2. | 16 | * This file is licensed under the GPL v2. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/acpi_pmtmr.h> | ||
19 | #include <linux/clocksource.h> | 20 | #include <linux/clocksource.h> |
20 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
21 | #include <linux/init.h> | 22 | #include <linux/init.h> |
22 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
23 | #include <asm/io.h> | 24 | #include <asm/io.h> |
24 | 25 | ||
25 | /* Number of PMTMR ticks expected during calibration run */ | ||
26 | #define PMTMR_TICKS_PER_SEC 3579545 | ||
27 | |||
28 | /* | 26 | /* |
29 | * The I/O port the PMTMR resides at. | 27 | * The I/O port the PMTMR resides at. |
30 | * The location is detected during setup_arch(), | 28 | * The location is detected during setup_arch(), |
@@ -32,15 +30,13 @@ | |||
32 | */ | 30 | */ |
33 | u32 pmtmr_ioport __read_mostly; | 31 | u32 pmtmr_ioport __read_mostly; |
34 | 32 | ||
35 | #define ACPI_PM_MASK CLOCKSOURCE_MASK(24) /* limit it to 24 bits */ | ||
36 | |||
37 | static inline u32 read_pmtmr(void) | 33 | static inline u32 read_pmtmr(void) |
38 | { | 34 | { |
39 | /* mask the output to 24 bits */ | 35 | /* mask the output to 24 bits */ |
40 | return inl(pmtmr_ioport) & ACPI_PM_MASK; | 36 | return inl(pmtmr_ioport) & ACPI_PM_MASK; |
41 | } | 37 | } |
42 | 38 | ||
43 | static cycle_t acpi_pm_read_verified(void) | 39 | u32 acpi_pm_read_verified(void) |
44 | { | 40 | { |
45 | u32 v1 = 0, v2 = 0, v3 = 0; | 41 | u32 v1 = 0, v2 = 0, v3 = 0; |
46 | 42 | ||
@@ -57,7 +53,12 @@ static cycle_t acpi_pm_read_verified(void) | |||
57 | } while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) | 53 | } while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) |
58 | || (v3 > v1 && v3 < v2))); | 54 | || (v3 > v1 && v3 < v2))); |
59 | 55 | ||
60 | return (cycle_t)v2; | 56 | return v2; |
57 | } | ||
58 | |||
59 | static cycle_t acpi_pm_read_slow(void) | ||
60 | { | ||
61 | return (cycle_t)acpi_pm_read_verified(); | ||
61 | } | 62 | } |
62 | 63 | ||
63 | static cycle_t acpi_pm_read(void) | 64 | static cycle_t acpi_pm_read(void) |
@@ -72,7 +73,8 @@ static struct clocksource clocksource_acpi_pm = { | |||
72 | .mask = (cycle_t)ACPI_PM_MASK, | 73 | .mask = (cycle_t)ACPI_PM_MASK, |
73 | .mult = 0, /*to be caluclated*/ | 74 | .mult = 0, /*to be caluclated*/ |
74 | .shift = 22, | 75 | .shift = 22, |
75 | .is_continuous = 1, | 76 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
77 | |||
76 | }; | 78 | }; |
77 | 79 | ||
78 | 80 | ||
@@ -87,7 +89,7 @@ __setup("acpi_pm_good", acpi_pm_good_setup); | |||
87 | 89 | ||
88 | static inline void acpi_pm_need_workaround(void) | 90 | static inline void acpi_pm_need_workaround(void) |
89 | { | 91 | { |
90 | clocksource_acpi_pm.read = acpi_pm_read_verified; | 92 | clocksource_acpi_pm.read = acpi_pm_read_slow; |
91 | clocksource_acpi_pm.rating = 110; | 93 | clocksource_acpi_pm.rating = 110; |
92 | } | 94 | } |
93 | 95 | ||
diff --git a/drivers/clocksource/cyclone.c b/drivers/clocksource/cyclone.c index bf4d3d50d1c4..4f3925ceb360 100644 --- a/drivers/clocksource/cyclone.c +++ b/drivers/clocksource/cyclone.c | |||
@@ -31,7 +31,7 @@ static struct clocksource clocksource_cyclone = { | |||
31 | .mask = CYCLONE_TIMER_MASK, | 31 | .mask = CYCLONE_TIMER_MASK, |
32 | .mult = 10, | 32 | .mult = 10, |
33 | .shift = 0, | 33 | .shift = 0, |
34 | .is_continuous = 1, | 34 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static int __init init_cyclone_clocksource(void) | 37 | static int __init init_cyclone_clocksource(void) |
diff --git a/drivers/clocksource/scx200_hrt.c b/drivers/clocksource/scx200_hrt.c index 22915cc46ba7..b92da677aa5d 100644 --- a/drivers/clocksource/scx200_hrt.c +++ b/drivers/clocksource/scx200_hrt.c | |||
@@ -57,7 +57,7 @@ static struct clocksource cs_hrt = { | |||
57 | .rating = 250, | 57 | .rating = 250, |
58 | .read = read_hrt, | 58 | .read = read_hrt, |
59 | .mask = CLOCKSOURCE_MASK(32), | 59 | .mask = CLOCKSOURCE_MASK(32), |
60 | .is_continuous = 1, | 60 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
61 | /* mult, shift are set based on mhz27 flag */ | 61 | /* mult, shift are set based on mhz27 flag */ |
62 | }; | 62 | }; |
63 | 63 | ||
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index 491779af8d55..d155e81b5c97 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig | |||
@@ -16,7 +16,7 @@ config CPU_FREQ | |||
16 | if CPU_FREQ | 16 | if CPU_FREQ |
17 | 17 | ||
18 | config CPU_FREQ_TABLE | 18 | config CPU_FREQ_TABLE |
19 | def_tristate m | 19 | tristate |
20 | 20 | ||
21 | config CPU_FREQ_DEBUG | 21 | config CPU_FREQ_DEBUG |
22 | bool "Enable CPUfreq debugging" | 22 | bool "Enable CPUfreq debugging" |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a45cc89e387a..f52facc570f5 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -41,8 +41,67 @@ static struct cpufreq_driver *cpufreq_driver; | |||
41 | static struct cpufreq_policy *cpufreq_cpu_data[NR_CPUS]; | 41 | static struct cpufreq_policy *cpufreq_cpu_data[NR_CPUS]; |
42 | static DEFINE_SPINLOCK(cpufreq_driver_lock); | 42 | static DEFINE_SPINLOCK(cpufreq_driver_lock); |
43 | 43 | ||
44 | /* | ||
45 | * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure | ||
46 | * all cpufreq/hotplug/workqueue/etc related lock issues. | ||
47 | * | ||
48 | * The rules for this semaphore: | ||
49 | * - Any routine that wants to read from the policy structure will | ||
50 | * do a down_read on this semaphore. | ||
51 | * - Any routine that will write to the policy structure and/or may take away | ||
52 | * the policy altogether (eg. CPU hotplug), will hold this lock in write | ||
53 | * mode before doing so. | ||
54 | * | ||
55 | * Additional rules: | ||
56 | * - All holders of the lock should check to make sure that the CPU they | ||
57 | * are concerned with are online after they get the lock. | ||
58 | * - Governor routines that can be called in cpufreq hotplug path should not | ||
59 | * take this sem as top level hotplug notifier handler takes this. | ||
60 | */ | ||
61 | static DEFINE_PER_CPU(int, policy_cpu); | ||
62 | static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); | ||
63 | |||
64 | #define lock_policy_rwsem(mode, cpu) \ | ||
65 | int lock_policy_rwsem_##mode \ | ||
66 | (int cpu) \ | ||
67 | { \ | ||
68 | int policy_cpu = per_cpu(policy_cpu, cpu); \ | ||
69 | BUG_ON(policy_cpu == -1); \ | ||
70 | down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ | ||
71 | if (unlikely(!cpu_online(cpu))) { \ | ||
72 | up_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ | ||
73 | return -1; \ | ||
74 | } \ | ||
75 | \ | ||
76 | return 0; \ | ||
77 | } | ||
78 | |||
79 | lock_policy_rwsem(read, cpu); | ||
80 | EXPORT_SYMBOL_GPL(lock_policy_rwsem_read); | ||
81 | |||
82 | lock_policy_rwsem(write, cpu); | ||
83 | EXPORT_SYMBOL_GPL(lock_policy_rwsem_write); | ||
84 | |||
85 | void unlock_policy_rwsem_read(int cpu) | ||
86 | { | ||
87 | int policy_cpu = per_cpu(policy_cpu, cpu); | ||
88 | BUG_ON(policy_cpu == -1); | ||
89 | up_read(&per_cpu(cpu_policy_rwsem, policy_cpu)); | ||
90 | } | ||
91 | EXPORT_SYMBOL_GPL(unlock_policy_rwsem_read); | ||
92 | |||
93 | void unlock_policy_rwsem_write(int cpu) | ||
94 | { | ||
95 | int policy_cpu = per_cpu(policy_cpu, cpu); | ||
96 | BUG_ON(policy_cpu == -1); | ||
97 | up_write(&per_cpu(cpu_policy_rwsem, policy_cpu)); | ||
98 | } | ||
99 | EXPORT_SYMBOL_GPL(unlock_policy_rwsem_write); | ||
100 | |||
101 | |||
44 | /* internal prototypes */ | 102 | /* internal prototypes */ |
45 | static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); | 103 | static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); |
104 | static unsigned int __cpufreq_get(unsigned int cpu); | ||
46 | static void handle_update(struct work_struct *work); | 105 | static void handle_update(struct work_struct *work); |
47 | 106 | ||
48 | /** | 107 | /** |
@@ -415,12 +474,8 @@ static ssize_t store_##file_name \ | |||
415 | if (ret != 1) \ | 474 | if (ret != 1) \ |
416 | return -EINVAL; \ | 475 | return -EINVAL; \ |
417 | \ | 476 | \ |
418 | lock_cpu_hotplug(); \ | ||
419 | mutex_lock(&policy->lock); \ | ||
420 | ret = __cpufreq_set_policy(policy, &new_policy); \ | 477 | ret = __cpufreq_set_policy(policy, &new_policy); \ |
421 | policy->user_policy.object = policy->object; \ | 478 | policy->user_policy.object = policy->object; \ |
422 | mutex_unlock(&policy->lock); \ | ||
423 | unlock_cpu_hotplug(); \ | ||
424 | \ | 479 | \ |
425 | return ret ? ret : count; \ | 480 | return ret ? ret : count; \ |
426 | } | 481 | } |
@@ -434,7 +489,7 @@ store_one(scaling_max_freq,max); | |||
434 | static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy, | 489 | static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy, |
435 | char *buf) | 490 | char *buf) |
436 | { | 491 | { |
437 | unsigned int cur_freq = cpufreq_get(policy->cpu); | 492 | unsigned int cur_freq = __cpufreq_get(policy->cpu); |
438 | if (!cur_freq) | 493 | if (!cur_freq) |
439 | return sprintf(buf, "<unknown>"); | 494 | return sprintf(buf, "<unknown>"); |
440 | return sprintf(buf, "%u\n", cur_freq); | 495 | return sprintf(buf, "%u\n", cur_freq); |
@@ -479,18 +534,12 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy, | |||
479 | &new_policy.governor)) | 534 | &new_policy.governor)) |
480 | return -EINVAL; | 535 | return -EINVAL; |
481 | 536 | ||
482 | lock_cpu_hotplug(); | ||
483 | |||
484 | /* Do not use cpufreq_set_policy here or the user_policy.max | 537 | /* Do not use cpufreq_set_policy here or the user_policy.max |
485 | will be wrongly overridden */ | 538 | will be wrongly overridden */ |
486 | mutex_lock(&policy->lock); | ||
487 | ret = __cpufreq_set_policy(policy, &new_policy); | 539 | ret = __cpufreq_set_policy(policy, &new_policy); |
488 | 540 | ||
489 | policy->user_policy.policy = policy->policy; | 541 | policy->user_policy.policy = policy->policy; |
490 | policy->user_policy.governor = policy->governor; | 542 | policy->user_policy.governor = policy->governor; |
491 | mutex_unlock(&policy->lock); | ||
492 | |||
493 | unlock_cpu_hotplug(); | ||
494 | 543 | ||
495 | if (ret) | 544 | if (ret) |
496 | return ret; | 545 | return ret; |
@@ -595,11 +644,17 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf) | |||
595 | policy = cpufreq_cpu_get(policy->cpu); | 644 | policy = cpufreq_cpu_get(policy->cpu); |
596 | if (!policy) | 645 | if (!policy) |
597 | return -EINVAL; | 646 | return -EINVAL; |
647 | |||
648 | if (lock_policy_rwsem_read(policy->cpu) < 0) | ||
649 | return -EINVAL; | ||
650 | |||
598 | if (fattr->show) | 651 | if (fattr->show) |
599 | ret = fattr->show(policy, buf); | 652 | ret = fattr->show(policy, buf); |
600 | else | 653 | else |
601 | ret = -EIO; | 654 | ret = -EIO; |
602 | 655 | ||
656 | unlock_policy_rwsem_read(policy->cpu); | ||
657 | |||
603 | cpufreq_cpu_put(policy); | 658 | cpufreq_cpu_put(policy); |
604 | return ret; | 659 | return ret; |
605 | } | 660 | } |
@@ -613,11 +668,17 @@ static ssize_t store(struct kobject * kobj, struct attribute * attr, | |||
613 | policy = cpufreq_cpu_get(policy->cpu); | 668 | policy = cpufreq_cpu_get(policy->cpu); |
614 | if (!policy) | 669 | if (!policy) |
615 | return -EINVAL; | 670 | return -EINVAL; |
671 | |||
672 | if (lock_policy_rwsem_write(policy->cpu) < 0) | ||
673 | return -EINVAL; | ||
674 | |||
616 | if (fattr->store) | 675 | if (fattr->store) |
617 | ret = fattr->store(policy, buf, count); | 676 | ret = fattr->store(policy, buf, count); |
618 | else | 677 | else |
619 | ret = -EIO; | 678 | ret = -EIO; |
620 | 679 | ||
680 | unlock_policy_rwsem_write(policy->cpu); | ||
681 | |||
621 | cpufreq_cpu_put(policy); | 682 | cpufreq_cpu_put(policy); |
622 | return ret; | 683 | return ret; |
623 | } | 684 | } |
@@ -691,8 +752,10 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
691 | policy->cpu = cpu; | 752 | policy->cpu = cpu; |
692 | policy->cpus = cpumask_of_cpu(cpu); | 753 | policy->cpus = cpumask_of_cpu(cpu); |
693 | 754 | ||
694 | mutex_init(&policy->lock); | 755 | /* Initially set CPU itself as the policy_cpu */ |
695 | mutex_lock(&policy->lock); | 756 | per_cpu(policy_cpu, cpu) = cpu; |
757 | lock_policy_rwsem_write(cpu); | ||
758 | |||
696 | init_completion(&policy->kobj_unregister); | 759 | init_completion(&policy->kobj_unregister); |
697 | INIT_WORK(&policy->update, handle_update); | 760 | INIT_WORK(&policy->update, handle_update); |
698 | 761 | ||
@@ -702,7 +765,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
702 | ret = cpufreq_driver->init(policy); | 765 | ret = cpufreq_driver->init(policy); |
703 | if (ret) { | 766 | if (ret) { |
704 | dprintk("initialization failed\n"); | 767 | dprintk("initialization failed\n"); |
705 | mutex_unlock(&policy->lock); | 768 | unlock_policy_rwsem_write(cpu); |
706 | goto err_out; | 769 | goto err_out; |
707 | } | 770 | } |
708 | 771 | ||
@@ -716,6 +779,14 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
716 | */ | 779 | */ |
717 | managed_policy = cpufreq_cpu_get(j); | 780 | managed_policy = cpufreq_cpu_get(j); |
718 | if (unlikely(managed_policy)) { | 781 | if (unlikely(managed_policy)) { |
782 | |||
783 | /* Set proper policy_cpu */ | ||
784 | unlock_policy_rwsem_write(cpu); | ||
785 | per_cpu(policy_cpu, cpu) = managed_policy->cpu; | ||
786 | |||
787 | if (lock_policy_rwsem_write(cpu) < 0) | ||
788 | goto err_out_driver_exit; | ||
789 | |||
719 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 790 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
720 | managed_policy->cpus = policy->cpus; | 791 | managed_policy->cpus = policy->cpus; |
721 | cpufreq_cpu_data[cpu] = managed_policy; | 792 | cpufreq_cpu_data[cpu] = managed_policy; |
@@ -726,13 +797,13 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
726 | &managed_policy->kobj, | 797 | &managed_policy->kobj, |
727 | "cpufreq"); | 798 | "cpufreq"); |
728 | if (ret) { | 799 | if (ret) { |
729 | mutex_unlock(&policy->lock); | 800 | unlock_policy_rwsem_write(cpu); |
730 | goto err_out_driver_exit; | 801 | goto err_out_driver_exit; |
731 | } | 802 | } |
732 | 803 | ||
733 | cpufreq_debug_enable_ratelimit(); | 804 | cpufreq_debug_enable_ratelimit(); |
734 | mutex_unlock(&policy->lock); | ||
735 | ret = 0; | 805 | ret = 0; |
806 | unlock_policy_rwsem_write(cpu); | ||
736 | goto err_out_driver_exit; /* call driver->exit() */ | 807 | goto err_out_driver_exit; /* call driver->exit() */ |
737 | } | 808 | } |
738 | } | 809 | } |
@@ -746,7 +817,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
746 | 817 | ||
747 | ret = kobject_register(&policy->kobj); | 818 | ret = kobject_register(&policy->kobj); |
748 | if (ret) { | 819 | if (ret) { |
749 | mutex_unlock(&policy->lock); | 820 | unlock_policy_rwsem_write(cpu); |
750 | goto err_out_driver_exit; | 821 | goto err_out_driver_exit; |
751 | } | 822 | } |
752 | /* set up files for this cpu device */ | 823 | /* set up files for this cpu device */ |
@@ -761,8 +832,10 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
761 | sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); | 832 | sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); |
762 | 833 | ||
763 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 834 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
764 | for_each_cpu_mask(j, policy->cpus) | 835 | for_each_cpu_mask(j, policy->cpus) { |
765 | cpufreq_cpu_data[j] = policy; | 836 | cpufreq_cpu_data[j] = policy; |
837 | per_cpu(policy_cpu, j) = policy->cpu; | ||
838 | } | ||
766 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 839 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
767 | 840 | ||
768 | /* symlink affected CPUs */ | 841 | /* symlink affected CPUs */ |
@@ -778,14 +851,14 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
778 | ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, | 851 | ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, |
779 | "cpufreq"); | 852 | "cpufreq"); |
780 | if (ret) { | 853 | if (ret) { |
781 | mutex_unlock(&policy->lock); | 854 | unlock_policy_rwsem_write(cpu); |
782 | goto err_out_unregister; | 855 | goto err_out_unregister; |
783 | } | 856 | } |
784 | } | 857 | } |
785 | 858 | ||
786 | policy->governor = NULL; /* to assure that the starting sequence is | 859 | policy->governor = NULL; /* to assure that the starting sequence is |
787 | * run in cpufreq_set_policy */ | 860 | * run in cpufreq_set_policy */ |
788 | mutex_unlock(&policy->lock); | 861 | unlock_policy_rwsem_write(cpu); |
789 | 862 | ||
790 | /* set default policy */ | 863 | /* set default policy */ |
791 | ret = cpufreq_set_policy(&new_policy); | 864 | ret = cpufreq_set_policy(&new_policy); |
@@ -826,11 +899,13 @@ module_out: | |||
826 | 899 | ||
827 | 900 | ||
828 | /** | 901 | /** |
829 | * cpufreq_remove_dev - remove a CPU device | 902 | * __cpufreq_remove_dev - remove a CPU device |
830 | * | 903 | * |
831 | * Removes the cpufreq interface for a CPU device. | 904 | * Removes the cpufreq interface for a CPU device. |
905 | * Caller should already have policy_rwsem in write mode for this CPU. | ||
906 | * This routine frees the rwsem before returning. | ||
832 | */ | 907 | */ |
833 | static int cpufreq_remove_dev (struct sys_device * sys_dev) | 908 | static int __cpufreq_remove_dev (struct sys_device * sys_dev) |
834 | { | 909 | { |
835 | unsigned int cpu = sys_dev->id; | 910 | unsigned int cpu = sys_dev->id; |
836 | unsigned long flags; | 911 | unsigned long flags; |
@@ -849,6 +924,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
849 | if (!data) { | 924 | if (!data) { |
850 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 925 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
851 | cpufreq_debug_enable_ratelimit(); | 926 | cpufreq_debug_enable_ratelimit(); |
927 | unlock_policy_rwsem_write(cpu); | ||
852 | return -EINVAL; | 928 | return -EINVAL; |
853 | } | 929 | } |
854 | cpufreq_cpu_data[cpu] = NULL; | 930 | cpufreq_cpu_data[cpu] = NULL; |
@@ -865,6 +941,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
865 | sysfs_remove_link(&sys_dev->kobj, "cpufreq"); | 941 | sysfs_remove_link(&sys_dev->kobj, "cpufreq"); |
866 | cpufreq_cpu_put(data); | 942 | cpufreq_cpu_put(data); |
867 | cpufreq_debug_enable_ratelimit(); | 943 | cpufreq_debug_enable_ratelimit(); |
944 | unlock_policy_rwsem_write(cpu); | ||
868 | return 0; | 945 | return 0; |
869 | } | 946 | } |
870 | #endif | 947 | #endif |
@@ -873,6 +950,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
873 | if (!kobject_get(&data->kobj)) { | 950 | if (!kobject_get(&data->kobj)) { |
874 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 951 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
875 | cpufreq_debug_enable_ratelimit(); | 952 | cpufreq_debug_enable_ratelimit(); |
953 | unlock_policy_rwsem_write(cpu); | ||
876 | return -EFAULT; | 954 | return -EFAULT; |
877 | } | 955 | } |
878 | 956 | ||
@@ -906,10 +984,10 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
906 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 984 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
907 | #endif | 985 | #endif |
908 | 986 | ||
909 | mutex_lock(&data->lock); | ||
910 | if (cpufreq_driver->target) | 987 | if (cpufreq_driver->target) |
911 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 988 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); |
912 | mutex_unlock(&data->lock); | 989 | |
990 | unlock_policy_rwsem_write(cpu); | ||
913 | 991 | ||
914 | kobject_unregister(&data->kobj); | 992 | kobject_unregister(&data->kobj); |
915 | 993 | ||
@@ -933,6 +1011,18 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
933 | } | 1011 | } |
934 | 1012 | ||
935 | 1013 | ||
1014 | static int cpufreq_remove_dev (struct sys_device * sys_dev) | ||
1015 | { | ||
1016 | unsigned int cpu = sys_dev->id; | ||
1017 | int retval; | ||
1018 | if (unlikely(lock_policy_rwsem_write(cpu))) | ||
1019 | BUG(); | ||
1020 | |||
1021 | retval = __cpufreq_remove_dev(sys_dev); | ||
1022 | return retval; | ||
1023 | } | ||
1024 | |||
1025 | |||
936 | static void handle_update(struct work_struct *work) | 1026 | static void handle_update(struct work_struct *work) |
937 | { | 1027 | { |
938 | struct cpufreq_policy *policy = | 1028 | struct cpufreq_policy *policy = |
@@ -980,9 +1070,12 @@ unsigned int cpufreq_quick_get(unsigned int cpu) | |||
980 | unsigned int ret_freq = 0; | 1070 | unsigned int ret_freq = 0; |
981 | 1071 | ||
982 | if (policy) { | 1072 | if (policy) { |
983 | mutex_lock(&policy->lock); | 1073 | if (unlikely(lock_policy_rwsem_read(cpu))) |
1074 | return ret_freq; | ||
1075 | |||
984 | ret_freq = policy->cur; | 1076 | ret_freq = policy->cur; |
985 | mutex_unlock(&policy->lock); | 1077 | |
1078 | unlock_policy_rwsem_read(cpu); | ||
986 | cpufreq_cpu_put(policy); | 1079 | cpufreq_cpu_put(policy); |
987 | } | 1080 | } |
988 | 1081 | ||
@@ -991,24 +1084,13 @@ unsigned int cpufreq_quick_get(unsigned int cpu) | |||
991 | EXPORT_SYMBOL(cpufreq_quick_get); | 1084 | EXPORT_SYMBOL(cpufreq_quick_get); |
992 | 1085 | ||
993 | 1086 | ||
994 | /** | 1087 | static unsigned int __cpufreq_get(unsigned int cpu) |
995 | * cpufreq_get - get the current CPU frequency (in kHz) | ||
996 | * @cpu: CPU number | ||
997 | * | ||
998 | * Get the CPU current (static) CPU frequency | ||
999 | */ | ||
1000 | unsigned int cpufreq_get(unsigned int cpu) | ||
1001 | { | 1088 | { |
1002 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | 1089 | struct cpufreq_policy *policy = cpufreq_cpu_data[cpu]; |
1003 | unsigned int ret_freq = 0; | 1090 | unsigned int ret_freq = 0; |
1004 | 1091 | ||
1005 | if (!policy) | ||
1006 | return 0; | ||
1007 | |||
1008 | if (!cpufreq_driver->get) | 1092 | if (!cpufreq_driver->get) |
1009 | goto out; | 1093 | return (ret_freq); |
1010 | |||
1011 | mutex_lock(&policy->lock); | ||
1012 | 1094 | ||
1013 | ret_freq = cpufreq_driver->get(cpu); | 1095 | ret_freq = cpufreq_driver->get(cpu); |
1014 | 1096 | ||
@@ -1022,11 +1104,33 @@ unsigned int cpufreq_get(unsigned int cpu) | |||
1022 | } | 1104 | } |
1023 | } | 1105 | } |
1024 | 1106 | ||
1025 | mutex_unlock(&policy->lock); | 1107 | return (ret_freq); |
1108 | } | ||
1026 | 1109 | ||
1027 | out: | 1110 | /** |
1028 | cpufreq_cpu_put(policy); | 1111 | * cpufreq_get - get the current CPU frequency (in kHz) |
1112 | * @cpu: CPU number | ||
1113 | * | ||
1114 | * Get the CPU current (static) CPU frequency | ||
1115 | */ | ||
1116 | unsigned int cpufreq_get(unsigned int cpu) | ||
1117 | { | ||
1118 | unsigned int ret_freq = 0; | ||
1119 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | ||
1120 | |||
1121 | if (!policy) | ||
1122 | goto out; | ||
1123 | |||
1124 | if (unlikely(lock_policy_rwsem_read(cpu))) | ||
1125 | goto out_policy; | ||
1126 | |||
1127 | ret_freq = __cpufreq_get(cpu); | ||
1029 | 1128 | ||
1129 | unlock_policy_rwsem_read(cpu); | ||
1130 | |||
1131 | out_policy: | ||
1132 | cpufreq_cpu_put(policy); | ||
1133 | out: | ||
1030 | return (ret_freq); | 1134 | return (ret_freq); |
1031 | } | 1135 | } |
1032 | EXPORT_SYMBOL(cpufreq_get); | 1136 | EXPORT_SYMBOL(cpufreq_get); |
@@ -1278,7 +1382,6 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); | |||
1278 | *********************************************************************/ | 1382 | *********************************************************************/ |
1279 | 1383 | ||
1280 | 1384 | ||
1281 | /* Must be called with lock_cpu_hotplug held */ | ||
1282 | int __cpufreq_driver_target(struct cpufreq_policy *policy, | 1385 | int __cpufreq_driver_target(struct cpufreq_policy *policy, |
1283 | unsigned int target_freq, | 1386 | unsigned int target_freq, |
1284 | unsigned int relation) | 1387 | unsigned int relation) |
@@ -1304,20 +1407,19 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1304 | if (!policy) | 1407 | if (!policy) |
1305 | return -EINVAL; | 1408 | return -EINVAL; |
1306 | 1409 | ||
1307 | lock_cpu_hotplug(); | 1410 | if (unlikely(lock_policy_rwsem_write(policy->cpu))) |
1308 | mutex_lock(&policy->lock); | 1411 | return -EINVAL; |
1309 | 1412 | ||
1310 | ret = __cpufreq_driver_target(policy, target_freq, relation); | 1413 | ret = __cpufreq_driver_target(policy, target_freq, relation); |
1311 | 1414 | ||
1312 | mutex_unlock(&policy->lock); | 1415 | unlock_policy_rwsem_write(policy->cpu); |
1313 | unlock_cpu_hotplug(); | ||
1314 | 1416 | ||
1315 | cpufreq_cpu_put(policy); | 1417 | cpufreq_cpu_put(policy); |
1316 | return ret; | 1418 | return ret; |
1317 | } | 1419 | } |
1318 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); | 1420 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); |
1319 | 1421 | ||
1320 | int cpufreq_driver_getavg(struct cpufreq_policy *policy) | 1422 | int __cpufreq_driver_getavg(struct cpufreq_policy *policy) |
1321 | { | 1423 | { |
1322 | int ret = 0; | 1424 | int ret = 0; |
1323 | 1425 | ||
@@ -1325,20 +1427,15 @@ int cpufreq_driver_getavg(struct cpufreq_policy *policy) | |||
1325 | if (!policy) | 1427 | if (!policy) |
1326 | return -EINVAL; | 1428 | return -EINVAL; |
1327 | 1429 | ||
1328 | mutex_lock(&policy->lock); | ||
1329 | |||
1330 | if (cpu_online(policy->cpu) && cpufreq_driver->getavg) | 1430 | if (cpu_online(policy->cpu) && cpufreq_driver->getavg) |
1331 | ret = cpufreq_driver->getavg(policy->cpu); | 1431 | ret = cpufreq_driver->getavg(policy->cpu); |
1332 | 1432 | ||
1333 | mutex_unlock(&policy->lock); | ||
1334 | |||
1335 | cpufreq_cpu_put(policy); | 1433 | cpufreq_cpu_put(policy); |
1336 | return ret; | 1434 | return ret; |
1337 | } | 1435 | } |
1338 | EXPORT_SYMBOL_GPL(cpufreq_driver_getavg); | 1436 | EXPORT_SYMBOL_GPL(__cpufreq_driver_getavg); |
1339 | 1437 | ||
1340 | /* | 1438 | /* |
1341 | * Locking: Must be called with the lock_cpu_hotplug() lock held | ||
1342 | * when "event" is CPUFREQ_GOV_LIMITS | 1439 | * when "event" is CPUFREQ_GOV_LIMITS |
1343 | */ | 1440 | */ |
1344 | 1441 | ||
@@ -1420,9 +1517,7 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) | |||
1420 | if (!cpu_policy) | 1517 | if (!cpu_policy) |
1421 | return -EINVAL; | 1518 | return -EINVAL; |
1422 | 1519 | ||
1423 | mutex_lock(&cpu_policy->lock); | ||
1424 | memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy)); | 1520 | memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy)); |
1425 | mutex_unlock(&cpu_policy->lock); | ||
1426 | 1521 | ||
1427 | cpufreq_cpu_put(cpu_policy); | 1522 | cpufreq_cpu_put(cpu_policy); |
1428 | return 0; | 1523 | return 0; |
@@ -1433,7 +1528,6 @@ EXPORT_SYMBOL(cpufreq_get_policy); | |||
1433 | /* | 1528 | /* |
1434 | * data : current policy. | 1529 | * data : current policy. |
1435 | * policy : policy to be set. | 1530 | * policy : policy to be set. |
1436 | * Locking: Must be called with the lock_cpu_hotplug() lock held | ||
1437 | */ | 1531 | */ |
1438 | static int __cpufreq_set_policy(struct cpufreq_policy *data, | 1532 | static int __cpufreq_set_policy(struct cpufreq_policy *data, |
1439 | struct cpufreq_policy *policy) | 1533 | struct cpufreq_policy *policy) |
@@ -1539,10 +1633,9 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) | |||
1539 | if (!data) | 1633 | if (!data) |
1540 | return -EINVAL; | 1634 | return -EINVAL; |
1541 | 1635 | ||
1542 | lock_cpu_hotplug(); | 1636 | if (unlikely(lock_policy_rwsem_write(policy->cpu))) |
1637 | return -EINVAL; | ||
1543 | 1638 | ||
1544 | /* lock this CPU */ | ||
1545 | mutex_lock(&data->lock); | ||
1546 | 1639 | ||
1547 | ret = __cpufreq_set_policy(data, policy); | 1640 | ret = __cpufreq_set_policy(data, policy); |
1548 | data->user_policy.min = data->min; | 1641 | data->user_policy.min = data->min; |
@@ -1550,9 +1643,8 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) | |||
1550 | data->user_policy.policy = data->policy; | 1643 | data->user_policy.policy = data->policy; |
1551 | data->user_policy.governor = data->governor; | 1644 | data->user_policy.governor = data->governor; |
1552 | 1645 | ||
1553 | mutex_unlock(&data->lock); | 1646 | unlock_policy_rwsem_write(policy->cpu); |
1554 | 1647 | ||
1555 | unlock_cpu_hotplug(); | ||
1556 | cpufreq_cpu_put(data); | 1648 | cpufreq_cpu_put(data); |
1557 | 1649 | ||
1558 | return ret; | 1650 | return ret; |
@@ -1576,8 +1668,8 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1576 | if (!data) | 1668 | if (!data) |
1577 | return -ENODEV; | 1669 | return -ENODEV; |
1578 | 1670 | ||
1579 | lock_cpu_hotplug(); | 1671 | if (unlikely(lock_policy_rwsem_write(cpu))) |
1580 | mutex_lock(&data->lock); | 1672 | return -EINVAL; |
1581 | 1673 | ||
1582 | dprintk("updating policy for CPU %u\n", cpu); | 1674 | dprintk("updating policy for CPU %u\n", cpu); |
1583 | memcpy(&policy, data, sizeof(struct cpufreq_policy)); | 1675 | memcpy(&policy, data, sizeof(struct cpufreq_policy)); |
@@ -1602,8 +1694,8 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1602 | 1694 | ||
1603 | ret = __cpufreq_set_policy(data, &policy); | 1695 | ret = __cpufreq_set_policy(data, &policy); |
1604 | 1696 | ||
1605 | mutex_unlock(&data->lock); | 1697 | unlock_policy_rwsem_write(cpu); |
1606 | unlock_cpu_hotplug(); | 1698 | |
1607 | cpufreq_cpu_put(data); | 1699 | cpufreq_cpu_put(data); |
1608 | return ret; | 1700 | return ret; |
1609 | } | 1701 | } |
@@ -1613,31 +1705,28 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, | |||
1613 | unsigned long action, void *hcpu) | 1705 | unsigned long action, void *hcpu) |
1614 | { | 1706 | { |
1615 | unsigned int cpu = (unsigned long)hcpu; | 1707 | unsigned int cpu = (unsigned long)hcpu; |
1616 | struct cpufreq_policy *policy; | ||
1617 | struct sys_device *sys_dev; | 1708 | struct sys_device *sys_dev; |
1709 | struct cpufreq_policy *policy; | ||
1618 | 1710 | ||
1619 | sys_dev = get_cpu_sysdev(cpu); | 1711 | sys_dev = get_cpu_sysdev(cpu); |
1620 | |||
1621 | if (sys_dev) { | 1712 | if (sys_dev) { |
1622 | switch (action) { | 1713 | switch (action) { |
1623 | case CPU_ONLINE: | 1714 | case CPU_ONLINE: |
1624 | cpufreq_add_dev(sys_dev); | 1715 | cpufreq_add_dev(sys_dev); |
1625 | break; | 1716 | break; |
1626 | case CPU_DOWN_PREPARE: | 1717 | case CPU_DOWN_PREPARE: |
1627 | /* | 1718 | if (unlikely(lock_policy_rwsem_write(cpu))) |
1628 | * We attempt to put this cpu in lowest frequency | 1719 | BUG(); |
1629 | * possible before going down. This will permit | 1720 | |
1630 | * hardware-managed P-State to switch other related | ||
1631 | * threads to min or higher speeds if possible. | ||
1632 | */ | ||
1633 | policy = cpufreq_cpu_data[cpu]; | 1721 | policy = cpufreq_cpu_data[cpu]; |
1634 | if (policy) { | 1722 | if (policy) { |
1635 | cpufreq_driver_target(policy, policy->min, | 1723 | __cpufreq_driver_target(policy, policy->min, |
1636 | CPUFREQ_RELATION_H); | 1724 | CPUFREQ_RELATION_H); |
1637 | } | 1725 | } |
1726 | __cpufreq_remove_dev(sys_dev); | ||
1638 | break; | 1727 | break; |
1639 | case CPU_DEAD: | 1728 | case CPU_DOWN_FAILED: |
1640 | cpufreq_remove_dev(sys_dev); | 1729 | cpufreq_add_dev(sys_dev); |
1641 | break; | 1730 | break; |
1642 | } | 1731 | } |
1643 | } | 1732 | } |
@@ -1751,3 +1840,16 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) | |||
1751 | return 0; | 1840 | return 0; |
1752 | } | 1841 | } |
1753 | EXPORT_SYMBOL_GPL(cpufreq_unregister_driver); | 1842 | EXPORT_SYMBOL_GPL(cpufreq_unregister_driver); |
1843 | |||
1844 | static int __init cpufreq_core_init(void) | ||
1845 | { | ||
1846 | int cpu; | ||
1847 | |||
1848 | for_each_possible_cpu(cpu) { | ||
1849 | per_cpu(policy_cpu, cpu) = -1; | ||
1850 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); | ||
1851 | } | ||
1852 | return 0; | ||
1853 | } | ||
1854 | |||
1855 | core_initcall(cpufreq_core_init); | ||
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index eef0270c6f3d..26f440ccc3fb 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/fs.h> | 23 | #include <linux/fs.h> |
24 | #include <linux/sysfs.h> | 24 | #include <linux/sysfs.h> |
25 | #include <linux/cpu.h> | 25 | #include <linux/cpu.h> |
26 | #include <linux/sched.h> | ||
27 | #include <linux/kmod.h> | 26 | #include <linux/kmod.h> |
28 | #include <linux/workqueue.h> | 27 | #include <linux/workqueue.h> |
29 | #include <linux/jiffies.h> | 28 | #include <linux/jiffies.h> |
@@ -430,14 +429,12 @@ static void dbs_check_cpu(int cpu) | |||
430 | static void do_dbs_timer(struct work_struct *work) | 429 | static void do_dbs_timer(struct work_struct *work) |
431 | { | 430 | { |
432 | int i; | 431 | int i; |
433 | lock_cpu_hotplug(); | ||
434 | mutex_lock(&dbs_mutex); | 432 | mutex_lock(&dbs_mutex); |
435 | for_each_online_cpu(i) | 433 | for_each_online_cpu(i) |
436 | dbs_check_cpu(i); | 434 | dbs_check_cpu(i); |
437 | schedule_delayed_work(&dbs_work, | 435 | schedule_delayed_work(&dbs_work, |
438 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | 436 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); |
439 | mutex_unlock(&dbs_mutex); | 437 | mutex_unlock(&dbs_mutex); |
440 | unlock_cpu_hotplug(); | ||
441 | } | 438 | } |
442 | 439 | ||
443 | static inline void dbs_timer_init(void) | 440 | static inline void dbs_timer_init(void) |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index f697449327c6..d60bcb9d14cc 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -52,19 +52,20 @@ static unsigned int def_sampling_rate; | |||
52 | static void do_dbs_timer(struct work_struct *work); | 52 | static void do_dbs_timer(struct work_struct *work); |
53 | 53 | ||
54 | /* Sampling types */ | 54 | /* Sampling types */ |
55 | enum dbs_sample {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE}; | 55 | enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE}; |
56 | 56 | ||
57 | struct cpu_dbs_info_s { | 57 | struct cpu_dbs_info_s { |
58 | cputime64_t prev_cpu_idle; | 58 | cputime64_t prev_cpu_idle; |
59 | cputime64_t prev_cpu_wall; | 59 | cputime64_t prev_cpu_wall; |
60 | struct cpufreq_policy *cur_policy; | 60 | struct cpufreq_policy *cur_policy; |
61 | struct delayed_work work; | 61 | struct delayed_work work; |
62 | enum dbs_sample sample_type; | ||
63 | unsigned int enable; | ||
64 | struct cpufreq_frequency_table *freq_table; | 62 | struct cpufreq_frequency_table *freq_table; |
65 | unsigned int freq_lo; | 63 | unsigned int freq_lo; |
66 | unsigned int freq_lo_jiffies; | 64 | unsigned int freq_lo_jiffies; |
67 | unsigned int freq_hi_jiffies; | 65 | unsigned int freq_hi_jiffies; |
66 | int cpu; | ||
67 | unsigned int enable:1, | ||
68 | sample_type:1; | ||
68 | }; | 69 | }; |
69 | static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); | 70 | static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); |
70 | 71 | ||
@@ -402,7 +403,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
402 | if (load < (dbs_tuners_ins.up_threshold - 10)) { | 403 | if (load < (dbs_tuners_ins.up_threshold - 10)) { |
403 | unsigned int freq_next, freq_cur; | 404 | unsigned int freq_next, freq_cur; |
404 | 405 | ||
405 | freq_cur = cpufreq_driver_getavg(policy); | 406 | freq_cur = __cpufreq_driver_getavg(policy); |
406 | if (!freq_cur) | 407 | if (!freq_cur) |
407 | freq_cur = policy->cur; | 408 | freq_cur = policy->cur; |
408 | 409 | ||
@@ -423,9 +424,11 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
423 | 424 | ||
424 | static void do_dbs_timer(struct work_struct *work) | 425 | static void do_dbs_timer(struct work_struct *work) |
425 | { | 426 | { |
426 | unsigned int cpu = smp_processor_id(); | 427 | struct cpu_dbs_info_s *dbs_info = |
427 | struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); | 428 | container_of(work, struct cpu_dbs_info_s, work.work); |
428 | enum dbs_sample sample_type = dbs_info->sample_type; | 429 | unsigned int cpu = dbs_info->cpu; |
430 | int sample_type = dbs_info->sample_type; | ||
431 | |||
429 | /* We want all CPUs to do sampling nearly on same jiffy */ | 432 | /* We want all CPUs to do sampling nearly on same jiffy */ |
430 | int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); | 433 | int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); |
431 | 434 | ||
@@ -434,15 +437,19 @@ static void do_dbs_timer(struct work_struct *work) | |||
434 | 437 | ||
435 | delay -= jiffies % delay; | 438 | delay -= jiffies % delay; |
436 | 439 | ||
437 | if (!dbs_info->enable) | 440 | if (lock_policy_rwsem_write(cpu) < 0) |
441 | return; | ||
442 | |||
443 | if (!dbs_info->enable) { | ||
444 | unlock_policy_rwsem_write(cpu); | ||
438 | return; | 445 | return; |
446 | } | ||
447 | |||
439 | /* Common NORMAL_SAMPLE setup */ | 448 | /* Common NORMAL_SAMPLE setup */ |
440 | dbs_info->sample_type = DBS_NORMAL_SAMPLE; | 449 | dbs_info->sample_type = DBS_NORMAL_SAMPLE; |
441 | if (!dbs_tuners_ins.powersave_bias || | 450 | if (!dbs_tuners_ins.powersave_bias || |
442 | sample_type == DBS_NORMAL_SAMPLE) { | 451 | sample_type == DBS_NORMAL_SAMPLE) { |
443 | lock_cpu_hotplug(); | ||
444 | dbs_check_cpu(dbs_info); | 452 | dbs_check_cpu(dbs_info); |
445 | unlock_cpu_hotplug(); | ||
446 | if (dbs_info->freq_lo) { | 453 | if (dbs_info->freq_lo) { |
447 | /* Setup timer for SUB_SAMPLE */ | 454 | /* Setup timer for SUB_SAMPLE */ |
448 | dbs_info->sample_type = DBS_SUB_SAMPLE; | 455 | dbs_info->sample_type = DBS_SUB_SAMPLE; |
@@ -454,26 +461,27 @@ static void do_dbs_timer(struct work_struct *work) | |||
454 | CPUFREQ_RELATION_H); | 461 | CPUFREQ_RELATION_H); |
455 | } | 462 | } |
456 | queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); | 463 | queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); |
464 | unlock_policy_rwsem_write(cpu); | ||
457 | } | 465 | } |
458 | 466 | ||
459 | static inline void dbs_timer_init(unsigned int cpu) | 467 | static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info) |
460 | { | 468 | { |
461 | struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); | ||
462 | /* We want all CPUs to do sampling nearly on same jiffy */ | 469 | /* We want all CPUs to do sampling nearly on same jiffy */ |
463 | int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); | 470 | int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); |
464 | delay -= jiffies % delay; | 471 | delay -= jiffies % delay; |
465 | 472 | ||
473 | dbs_info->enable = 1; | ||
466 | ondemand_powersave_bias_init(); | 474 | ondemand_powersave_bias_init(); |
467 | INIT_DELAYED_WORK_NAR(&dbs_info->work, do_dbs_timer); | ||
468 | dbs_info->sample_type = DBS_NORMAL_SAMPLE; | 475 | dbs_info->sample_type = DBS_NORMAL_SAMPLE; |
469 | queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); | 476 | INIT_DELAYED_WORK_NAR(&dbs_info->work, do_dbs_timer); |
477 | queue_delayed_work_on(dbs_info->cpu, kondemand_wq, &dbs_info->work, | ||
478 | delay); | ||
470 | } | 479 | } |
471 | 480 | ||
472 | static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) | 481 | static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) |
473 | { | 482 | { |
474 | dbs_info->enable = 0; | 483 | dbs_info->enable = 0; |
475 | cancel_delayed_work(&dbs_info->work); | 484 | cancel_delayed_work(&dbs_info->work); |
476 | flush_workqueue(kondemand_wq); | ||
477 | } | 485 | } |
478 | 486 | ||
479 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | 487 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, |
@@ -502,21 +510,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
502 | 510 | ||
503 | mutex_lock(&dbs_mutex); | 511 | mutex_lock(&dbs_mutex); |
504 | dbs_enable++; | 512 | dbs_enable++; |
505 | if (dbs_enable == 1) { | ||
506 | kondemand_wq = create_workqueue("kondemand"); | ||
507 | if (!kondemand_wq) { | ||
508 | printk(KERN_ERR | ||
509 | "Creation of kondemand failed\n"); | ||
510 | dbs_enable--; | ||
511 | mutex_unlock(&dbs_mutex); | ||
512 | return -ENOSPC; | ||
513 | } | ||
514 | } | ||
515 | 513 | ||
516 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); | 514 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); |
517 | if (rc) { | 515 | if (rc) { |
518 | if (dbs_enable == 1) | ||
519 | destroy_workqueue(kondemand_wq); | ||
520 | dbs_enable--; | 516 | dbs_enable--; |
521 | mutex_unlock(&dbs_mutex); | 517 | mutex_unlock(&dbs_mutex); |
522 | return rc; | 518 | return rc; |
@@ -530,7 +526,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
530 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j); | 526 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j); |
531 | j_dbs_info->prev_cpu_wall = get_jiffies_64(); | 527 | j_dbs_info->prev_cpu_wall = get_jiffies_64(); |
532 | } | 528 | } |
533 | this_dbs_info->enable = 1; | 529 | this_dbs_info->cpu = cpu; |
534 | /* | 530 | /* |
535 | * Start the timerschedule work, when this governor | 531 | * Start the timerschedule work, when this governor |
536 | * is used for first time | 532 | * is used for first time |
@@ -550,7 +546,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
550 | 546 | ||
551 | dbs_tuners_ins.sampling_rate = def_sampling_rate; | 547 | dbs_tuners_ins.sampling_rate = def_sampling_rate; |
552 | } | 548 | } |
553 | dbs_timer_init(policy->cpu); | 549 | dbs_timer_init(this_dbs_info); |
554 | 550 | ||
555 | mutex_unlock(&dbs_mutex); | 551 | mutex_unlock(&dbs_mutex); |
556 | break; | 552 | break; |
@@ -560,9 +556,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
560 | dbs_timer_exit(this_dbs_info); | 556 | dbs_timer_exit(this_dbs_info); |
561 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); | 557 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); |
562 | dbs_enable--; | 558 | dbs_enable--; |
563 | if (dbs_enable == 0) | ||
564 | destroy_workqueue(kondemand_wq); | ||
565 | |||
566 | mutex_unlock(&dbs_mutex); | 559 | mutex_unlock(&dbs_mutex); |
567 | 560 | ||
568 | break; | 561 | break; |
@@ -591,12 +584,18 @@ static struct cpufreq_governor cpufreq_gov_dbs = { | |||
591 | 584 | ||
592 | static int __init cpufreq_gov_dbs_init(void) | 585 | static int __init cpufreq_gov_dbs_init(void) |
593 | { | 586 | { |
587 | kondemand_wq = create_workqueue("kondemand"); | ||
588 | if (!kondemand_wq) { | ||
589 | printk(KERN_ERR "Creation of kondemand failed\n"); | ||
590 | return -EFAULT; | ||
591 | } | ||
594 | return cpufreq_register_governor(&cpufreq_gov_dbs); | 592 | return cpufreq_register_governor(&cpufreq_gov_dbs); |
595 | } | 593 | } |
596 | 594 | ||
597 | static void __exit cpufreq_gov_dbs_exit(void) | 595 | static void __exit cpufreq_gov_dbs_exit(void) |
598 | { | 596 | { |
599 | cpufreq_unregister_governor(&cpufreq_gov_dbs); | 597 | cpufreq_unregister_governor(&cpufreq_gov_dbs); |
598 | destroy_workqueue(kondemand_wq); | ||
600 | } | 599 | } |
601 | 600 | ||
602 | 601 | ||
@@ -608,3 +607,4 @@ MODULE_LICENSE("GPL"); | |||
608 | 607 | ||
609 | module_init(cpufreq_gov_dbs_init); | 608 | module_init(cpufreq_gov_dbs_init); |
610 | module_exit(cpufreq_gov_dbs_exit); | 609 | module_exit(cpufreq_gov_dbs_exit); |
610 | |||
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 91ad342a6051..d1c7cac9316c 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -370,12 +370,10 @@ __exit cpufreq_stats_exit(void) | |||
370 | cpufreq_unregister_notifier(¬ifier_trans_block, | 370 | cpufreq_unregister_notifier(¬ifier_trans_block, |
371 | CPUFREQ_TRANSITION_NOTIFIER); | 371 | CPUFREQ_TRANSITION_NOTIFIER); |
372 | unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier); | 372 | unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier); |
373 | lock_cpu_hotplug(); | ||
374 | for_each_online_cpu(cpu) { | 373 | for_each_online_cpu(cpu) { |
375 | cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, | 374 | cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, |
376 | CPU_DEAD, (void *)(long)cpu); | 375 | CPU_DEAD, (void *)(long)cpu); |
377 | } | 376 | } |
378 | unlock_cpu_hotplug(); | ||
379 | } | 377 | } |
380 | 378 | ||
381 | MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>"); | 379 | MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>"); |
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index 2a4eb0bfaf30..860345c7799a 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c | |||
@@ -71,7 +71,6 @@ static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy) | |||
71 | 71 | ||
72 | dprintk("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); | 72 | dprintk("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); |
73 | 73 | ||
74 | lock_cpu_hotplug(); | ||
75 | mutex_lock(&userspace_mutex); | 74 | mutex_lock(&userspace_mutex); |
76 | if (!cpu_is_managed[policy->cpu]) | 75 | if (!cpu_is_managed[policy->cpu]) |
77 | goto err; | 76 | goto err; |
@@ -94,7 +93,6 @@ static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy) | |||
94 | 93 | ||
95 | err: | 94 | err: |
96 | mutex_unlock(&userspace_mutex); | 95 | mutex_unlock(&userspace_mutex); |
97 | unlock_cpu_hotplug(); | ||
98 | return ret; | 96 | return ret; |
99 | } | 97 | } |
100 | 98 | ||
diff --git a/drivers/crypto/geode-aes.c b/drivers/crypto/geode-aes.c index 31ea405f2eeb..0eb62841e9b0 100644 --- a/drivers/crypto/geode-aes.c +++ b/drivers/crypto/geode-aes.c | |||
@@ -8,7 +8,6 @@ | |||
8 | 8 | ||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/sched.h> | ||
12 | #include <linux/pci.h> | 11 | #include <linux/pci.h> |
13 | #include <linux/pci_ids.h> | 12 | #include <linux/pci_ids.h> |
14 | #include <linux/crypto.h> | 13 | #include <linux/crypto.h> |
diff --git a/drivers/fc4/fc_syms.c b/drivers/fc4/fc_syms.c index 8700a8076d04..bd3918ddf7ac 100644 --- a/drivers/fc4/fc_syms.c +++ b/drivers/fc4/fc_syms.c | |||
@@ -6,7 +6,6 @@ | |||
6 | 6 | ||
7 | #ifdef CONFIG_MODULES | 7 | #ifdef CONFIG_MODULES |
8 | 8 | ||
9 | #include <linux/sched.h> | ||
10 | #include <linux/types.h> | 9 | #include <linux/types.h> |
11 | #include <linux/string.h> | 10 | #include <linux/string.h> |
12 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
diff --git a/drivers/fc4/soc.c b/drivers/fc4/soc.c index b09dfc78e5a2..d517734462e6 100644 --- a/drivers/fc4/soc.c +++ b/drivers/fc4/soc.c | |||
@@ -22,7 +22,6 @@ static char *version = | |||
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/sched.h> | ||
26 | #include <linux/types.h> | 25 | #include <linux/types.h> |
27 | #include <linux/fcntl.h> | 26 | #include <linux/fcntl.h> |
28 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
diff --git a/drivers/fc4/socal.c b/drivers/fc4/socal.c index a6b1ae256e16..c903ebfab526 100644 --- a/drivers/fc4/socal.c +++ b/drivers/fc4/socal.c | |||
@@ -17,7 +17,6 @@ static char *version = | |||
17 | 17 | ||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/types.h> | 20 | #include <linux/types.h> |
22 | #include <linux/fcntl.h> | 21 | #include <linux/fcntl.h> |
23 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 8c7d48eff7b7..7452399501b4 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/sched.h> | ||
22 | #include <linux/list.h> | 21 | #include <linux/list.h> |
23 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
24 | #include <linux/smp_lock.h> | 23 | #include <linux/smp_lock.h> |
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index 93f93d4fb8ae..a6a4aa0eee16 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c | |||
@@ -727,7 +727,6 @@ int vt8231_detect(struct i2c_adapter *adapter) | |||
727 | client->addr = isa_address; | 727 | client->addr = isa_address; |
728 | client->adapter = adapter; | 728 | client->adapter = adapter; |
729 | client->driver = &vt8231_driver; | 729 | client->driver = &vt8231_driver; |
730 | client->dev.parent = &adapter->dev; | ||
731 | 730 | ||
732 | /* Fill in the remaining client fields and put into the global list */ | 731 | /* Fill in the remaining client fields and put into the global list */ |
733 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); | 732 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 9367c4cfe936..4d44a2db29dd 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -183,6 +183,7 @@ config I2C_PIIX4 | |||
183 | ATI IXP200 | 183 | ATI IXP200 |
184 | ATI IXP300 | 184 | ATI IXP300 |
185 | ATI IXP400 | 185 | ATI IXP400 |
186 | ATI SB600 | ||
186 | Serverworks OSB4 | 187 | Serverworks OSB4 |
187 | Serverworks CSB5 | 188 | Serverworks CSB5 |
188 | Serverworks CSB6 | 189 | Serverworks CSB6 |
@@ -341,6 +342,13 @@ config I2C_PARPORT_LIGHT | |||
341 | This support is also available as a module. If so, the module | 342 | This support is also available as a module. If so, the module |
342 | will be called i2c-parport-light. | 343 | will be called i2c-parport-light. |
343 | 344 | ||
345 | config I2C_PASEMI | ||
346 | tristate "PA Semi SMBus interface" | ||
347 | # depends on PPC_PASEMI && I2C && PCI | ||
348 | depends on I2C && PCI | ||
349 | help | ||
350 | Supports the PA Semi PWRficient on-chip SMBus interfaces. | ||
351 | |||
344 | config I2C_PROSAVAGE | 352 | config I2C_PROSAVAGE |
345 | tristate "S3/VIA (Pro)Savage" | 353 | tristate "S3/VIA (Pro)Savage" |
346 | depends on I2C && PCI | 354 | depends on I2C && PCI |
@@ -499,11 +507,11 @@ config I2C_VIA | |||
499 | will be called i2c-via. | 507 | will be called i2c-via. |
500 | 508 | ||
501 | config I2C_VIAPRO | 509 | config I2C_VIAPRO |
502 | tristate "VIA 82C596/82C686/82xx" | 510 | tristate "VIA VT82C596/82C686/82xx and CX700" |
503 | depends on I2C && PCI | 511 | depends on I2C && PCI |
504 | help | 512 | help |
505 | If you say yes to this option, support will be included for the VIA | 513 | If you say yes to this option, support will be included for the VIA |
506 | 82C596/82C686/82xx I2C interfaces. Specifically, the following | 514 | VT82C596 and later SMBus interface. Specifically, the following |
507 | chipsets are supported: | 515 | chipsets are supported: |
508 | VT82C596A/B | 516 | VT82C596A/B |
509 | VT82C686A/B | 517 | VT82C686A/B |
@@ -512,6 +520,7 @@ config I2C_VIAPRO | |||
512 | VT8235 | 520 | VT8235 |
513 | VT8237R/A | 521 | VT8237R/A |
514 | VT8251 | 522 | VT8251 |
523 | CX700 | ||
515 | 524 | ||
516 | This driver can also be built as a module. If so, the module | 525 | This driver can also be built as a module. If so, the module |
517 | will be called i2c-viapro. | 526 | will be called i2c-viapro. |
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 37196c1d0794..03505aa44bbf 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile | |||
@@ -27,6 +27,7 @@ obj-$(CONFIG_I2C_OCORES) += i2c-ocores.o | |||
27 | obj-$(CONFIG_I2C_OMAP) += i2c-omap.o | 27 | obj-$(CONFIG_I2C_OMAP) += i2c-omap.o |
28 | obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o | 28 | obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o |
29 | obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o | 29 | obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o |
30 | obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o | ||
30 | obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o | 31 | obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o |
31 | obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o | 32 | obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o |
32 | obj-$(CONFIG_I2C_PNX) += i2c-pnx.o | 33 | obj-$(CONFIG_I2C_PNX) += i2c-pnx.o |
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index e75d339a3481..6fd8ad7faa06 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -57,7 +57,6 @@ | |||
57 | #include <linux/pci.h> | 57 | #include <linux/pci.h> |
58 | #include <linux/kernel.h> | 58 | #include <linux/kernel.h> |
59 | #include <linux/stddef.h> | 59 | #include <linux/stddef.h> |
60 | #include <linux/sched.h> | ||
61 | #include <linux/delay.h> | 60 | #include <linux/delay.h> |
62 | #include <linux/ioport.h> | 61 | #include <linux/ioport.h> |
63 | #include <linux/i2c.h> | 62 | #include <linux/i2c.h> |
@@ -475,6 +474,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
475 | 474 | ||
476 | static struct i2c_adapter ali1535_adapter = { | 475 | static struct i2c_adapter ali1535_adapter = { |
477 | .owner = THIS_MODULE, | 476 | .owner = THIS_MODULE, |
477 | .id = I2C_HW_SMBUS_ALI1535, | ||
478 | .class = I2C_CLASS_HWMON, | 478 | .class = I2C_CLASS_HWMON, |
479 | .algo = &smbus_algorithm, | 479 | .algo = &smbus_algorithm, |
480 | }; | 480 | }; |
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index 8e1e3f8e40a4..6b68074e518a 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c | |||
@@ -314,35 +314,11 @@ static u32 ali1563_func(struct i2c_adapter * a) | |||
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | static void ali1563_enable(struct pci_dev * dev) | ||
318 | { | ||
319 | u16 ctrl; | ||
320 | |||
321 | pci_read_config_word(dev,ALI1563_SMBBA,&ctrl); | ||
322 | ctrl |= 0x7; | ||
323 | pci_write_config_word(dev,ALI1563_SMBBA,ctrl); | ||
324 | } | ||
325 | |||
326 | static int __devinit ali1563_setup(struct pci_dev * dev) | 317 | static int __devinit ali1563_setup(struct pci_dev * dev) |
327 | { | 318 | { |
328 | u16 ctrl; | 319 | u16 ctrl; |
329 | 320 | ||
330 | pci_read_config_word(dev,ALI1563_SMBBA,&ctrl); | 321 | pci_read_config_word(dev,ALI1563_SMBBA,&ctrl); |
331 | printk("ali1563: SMBus control = %04x\n",ctrl); | ||
332 | |||
333 | /* Check if device is even enabled first */ | ||
334 | if (!(ctrl & ALI1563_SMB_IOEN)) { | ||
335 | dev_warn(&dev->dev,"I/O space not enabled, trying manually\n"); | ||
336 | ali1563_enable(dev); | ||
337 | } | ||
338 | if (!(ctrl & ALI1563_SMB_IOEN)) { | ||
339 | dev_warn(&dev->dev,"I/O space still not enabled, giving up\n"); | ||
340 | goto Err; | ||
341 | } | ||
342 | if (!(ctrl & ALI1563_SMB_HOSTEN)) { | ||
343 | dev_warn(&dev->dev,"Host Controller not enabled\n"); | ||
344 | goto Err; | ||
345 | } | ||
346 | 322 | ||
347 | /* SMB I/O Base in high 12 bits and must be aligned with the | 323 | /* SMB I/O Base in high 12 bits and must be aligned with the |
348 | * size of the I/O space. */ | 324 | * size of the I/O space. */ |
@@ -351,11 +327,31 @@ static int __devinit ali1563_setup(struct pci_dev * dev) | |||
351 | dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); | 327 | dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); |
352 | goto Err; | 328 | goto Err; |
353 | } | 329 | } |
330 | |||
331 | /* Check if device is enabled */ | ||
332 | if (!(ctrl & ALI1563_SMB_HOSTEN)) { | ||
333 | dev_warn(&dev->dev, "Host Controller not enabled\n"); | ||
334 | goto Err; | ||
335 | } | ||
336 | if (!(ctrl & ALI1563_SMB_IOEN)) { | ||
337 | dev_warn(&dev->dev, "I/O space not enabled, trying manually\n"); | ||
338 | pci_write_config_word(dev, ALI1563_SMBBA, | ||
339 | ctrl | ALI1563_SMB_IOEN); | ||
340 | pci_read_config_word(dev, ALI1563_SMBBA, &ctrl); | ||
341 | if (!(ctrl & ALI1563_SMB_IOEN)) { | ||
342 | dev_err(&dev->dev, "I/O space still not enabled, " | ||
343 | "giving up\n"); | ||
344 | goto Err; | ||
345 | } | ||
346 | } | ||
347 | |||
354 | if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, | 348 | if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, |
355 | ali1563_pci_driver.name)) { | 349 | ali1563_pci_driver.name)) { |
356 | dev_warn(&dev->dev,"Could not allocate I/O space"); | 350 | dev_err(&dev->dev, "Could not allocate I/O space at 0x%04x\n", |
351 | ali1563_smba); | ||
357 | goto Err; | 352 | goto Err; |
358 | } | 353 | } |
354 | dev_info(&dev->dev, "Found ALi1563 SMBus at 0x%04x\n", ali1563_smba); | ||
359 | 355 | ||
360 | return 0; | 356 | return 0; |
361 | Err: | 357 | Err: |
@@ -374,6 +370,7 @@ static const struct i2c_algorithm ali1563_algorithm = { | |||
374 | 370 | ||
375 | static struct i2c_adapter ali1563_adapter = { | 371 | static struct i2c_adapter ali1563_adapter = { |
376 | .owner = THIS_MODULE, | 372 | .owner = THIS_MODULE, |
373 | .id = I2C_HW_SMBUS_ALI1563, | ||
377 | .class = I2C_CLASS_HWMON, | 374 | .class = I2C_CLASS_HWMON, |
378 | .algo = &ali1563_algorithm, | 375 | .algo = &ali1563_algorithm, |
379 | }; | 376 | }; |
@@ -384,13 +381,18 @@ static int __devinit ali1563_probe(struct pci_dev * dev, | |||
384 | int error; | 381 | int error; |
385 | 382 | ||
386 | if ((error = ali1563_setup(dev))) | 383 | if ((error = ali1563_setup(dev))) |
387 | return error; | 384 | goto exit; |
388 | ali1563_adapter.dev.parent = &dev->dev; | 385 | ali1563_adapter.dev.parent = &dev->dev; |
389 | sprintf(ali1563_adapter.name,"SMBus ALi 1563 Adapter @ %04x", | 386 | sprintf(ali1563_adapter.name,"SMBus ALi 1563 Adapter @ %04x", |
390 | ali1563_smba); | 387 | ali1563_smba); |
391 | if ((error = i2c_add_adapter(&ali1563_adapter))) | 388 | if ((error = i2c_add_adapter(&ali1563_adapter))) |
392 | ali1563_shutdown(dev); | 389 | goto exit_shutdown; |
393 | printk("%s: Returning %d\n",__FUNCTION__,error); | 390 | return 0; |
391 | |||
392 | exit_shutdown: | ||
393 | ali1563_shutdown(dev); | ||
394 | exit: | ||
395 | dev_warn(&dev->dev, "ALi1563 SMBus probe failed (%d)\n", error); | ||
394 | return error; | 396 | return error; |
395 | } | 397 | } |
396 | 398 | ||
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 3f11b6e1a341..e4e0df106812 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -64,7 +64,6 @@ | |||
64 | #include <linux/pci.h> | 64 | #include <linux/pci.h> |
65 | #include <linux/kernel.h> | 65 | #include <linux/kernel.h> |
66 | #include <linux/stddef.h> | 66 | #include <linux/stddef.h> |
67 | #include <linux/sched.h> | ||
68 | #include <linux/ioport.h> | 67 | #include <linux/ioport.h> |
69 | #include <linux/delay.h> | 68 | #include <linux/delay.h> |
70 | #include <linux/i2c.h> | 69 | #include <linux/i2c.h> |
@@ -470,6 +469,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
470 | 469 | ||
471 | static struct i2c_adapter ali15x3_adapter = { | 470 | static struct i2c_adapter ali15x3_adapter = { |
472 | .owner = THIS_MODULE, | 471 | .owner = THIS_MODULE, |
472 | .id = I2C_HW_SMBUS_ALI15X3, | ||
473 | .class = I2C_CLASS_HWMON, | 473 | .class = I2C_CLASS_HWMON, |
474 | .algo = &smbus_algorithm, | 474 | .algo = &smbus_algorithm, |
475 | }; | 475 | }; |
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index 08e915730caf..e5e96c817566 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
@@ -184,12 +184,14 @@ static int __init amd756_s4882_init(void) | |||
184 | s4882_algo[0].smbus_xfer = amd756_access_virt0; | 184 | s4882_algo[0].smbus_xfer = amd756_access_virt0; |
185 | s4882_adapter[0] = amd756_smbus; | 185 | s4882_adapter[0] = amd756_smbus; |
186 | s4882_adapter[0].algo = s4882_algo; | 186 | s4882_adapter[0].algo = s4882_algo; |
187 | s4882_adapter[0].dev.parent = amd756_smbus.dev.parent; | ||
187 | for (i = 1; i < 5; i++) { | 188 | for (i = 1; i < 5; i++) { |
188 | s4882_algo[i] = *(amd756_smbus.algo); | 189 | s4882_algo[i] = *(amd756_smbus.algo); |
189 | s4882_adapter[i] = amd756_smbus; | 190 | s4882_adapter[i] = amd756_smbus; |
190 | sprintf(s4882_adapter[i].name, | 191 | sprintf(s4882_adapter[i].name, |
191 | "SMBus 8111 adapter (CPU%d)", i-1); | 192 | "SMBus 8111 adapter (CPU%d)", i-1); |
192 | s4882_adapter[i].algo = s4882_algo+i; | 193 | s4882_adapter[i].algo = s4882_algo+i; |
194 | s4882_adapter[i].dev.parent = amd756_smbus.dev.parent; | ||
193 | } | 195 | } |
194 | s4882_algo[1].smbus_xfer = amd756_access_virt1; | 196 | s4882_algo[1].smbus_xfer = amd756_access_virt1; |
195 | s4882_algo[2].smbus_xfer = amd756_access_virt2; | 197 | s4882_algo[2].smbus_xfer = amd756_access_virt2; |
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 2d21afdc5b1c..fa6155a54cc3 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
43 | #include <linux/delay.h> | 43 | #include <linux/delay.h> |
44 | #include <linux/stddef.h> | 44 | #include <linux/stddef.h> |
45 | #include <linux/sched.h> | ||
46 | #include <linux/ioport.h> | 45 | #include <linux/ioport.h> |
47 | #include <linux/i2c.h> | 46 | #include <linux/i2c.h> |
48 | #include <linux/init.h> | 47 | #include <linux/init.h> |
@@ -301,6 +300,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
301 | 300 | ||
302 | struct i2c_adapter amd756_smbus = { | 301 | struct i2c_adapter amd756_smbus = { |
303 | .owner = THIS_MODULE, | 302 | .owner = THIS_MODULE, |
303 | .id = I2C_HW_SMBUS_AMD756, | ||
304 | .class = I2C_CLASS_HWMON, | 304 | .class = I2C_CLASS_HWMON, |
305 | .algo = &smbus_algorithm, | 305 | .algo = &smbus_algorithm, |
306 | }; | 306 | }; |
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index 0fbc7186c91a..5bba3fb50d71 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/stddef.h> | 14 | #include <linux/stddef.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/ioport.h> | 15 | #include <linux/ioport.h> |
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
18 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
@@ -76,7 +75,8 @@ static unsigned int amd_ec_wait_write(struct amd_smbus *smbus) | |||
76 | udelay(1); | 75 | udelay(1); |
77 | 76 | ||
78 | if (!timeout) { | 77 | if (!timeout) { |
79 | dev_warn(&smbus->dev->dev, "Timeout while waiting for IBF to clear\n"); | 78 | dev_warn(&smbus->dev->dev, |
79 | "Timeout while waiting for IBF to clear\n"); | ||
80 | return -1; | 80 | return -1; |
81 | } | 81 | } |
82 | 82 | ||
@@ -91,14 +91,16 @@ static unsigned int amd_ec_wait_read(struct amd_smbus *smbus) | |||
91 | udelay(1); | 91 | udelay(1); |
92 | 92 | ||
93 | if (!timeout) { | 93 | if (!timeout) { |
94 | dev_warn(&smbus->dev->dev, "Timeout while waiting for OBF to set\n"); | 94 | dev_warn(&smbus->dev->dev, |
95 | "Timeout while waiting for OBF to set\n"); | ||
95 | return -1; | 96 | return -1; |
96 | } | 97 | } |
97 | 98 | ||
98 | return 0; | 99 | return 0; |
99 | } | 100 | } |
100 | 101 | ||
101 | static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, unsigned char *data) | 102 | static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, |
103 | unsigned char *data) | ||
102 | { | 104 | { |
103 | if (amd_ec_wait_write(smbus)) | 105 | if (amd_ec_wait_write(smbus)) |
104 | return -1; | 106 | return -1; |
@@ -115,7 +117,8 @@ static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, | |||
115 | return 0; | 117 | return 0; |
116 | } | 118 | } |
117 | 119 | ||
118 | static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, unsigned char data) | 120 | static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, |
121 | unsigned char data) | ||
119 | { | 122 | { |
120 | if (amd_ec_wait_write(smbus)) | 123 | if (amd_ec_wait_write(smbus)) |
121 | return -1; | 124 | return -1; |
@@ -175,18 +178,19 @@ static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, | |||
175 | #define AMD_SMB_PRTCL_PEC 0x80 | 178 | #define AMD_SMB_PRTCL_PEC 0x80 |
176 | 179 | ||
177 | 180 | ||
178 | static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, | 181 | static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, |
179 | char read_write, u8 command, int size, union i2c_smbus_data * data) | 182 | unsigned short flags, char read_write, u8 command, int size, |
183 | union i2c_smbus_data * data) | ||
180 | { | 184 | { |
181 | struct amd_smbus *smbus = adap->algo_data; | 185 | struct amd_smbus *smbus = adap->algo_data; |
182 | unsigned char protocol, len, pec, temp[2]; | 186 | unsigned char protocol, len, pec, temp[2]; |
183 | int i; | 187 | int i; |
184 | 188 | ||
185 | protocol = (read_write == I2C_SMBUS_READ) ? AMD_SMB_PRTCL_READ : AMD_SMB_PRTCL_WRITE; | 189 | protocol = (read_write == I2C_SMBUS_READ) ? AMD_SMB_PRTCL_READ |
190 | : AMD_SMB_PRTCL_WRITE; | ||
186 | pec = (flags & I2C_CLIENT_PEC) ? AMD_SMB_PRTCL_PEC : 0; | 191 | pec = (flags & I2C_CLIENT_PEC) ? AMD_SMB_PRTCL_PEC : 0; |
187 | 192 | ||
188 | switch (size) { | 193 | switch (size) { |
189 | |||
190 | case I2C_SMBUS_QUICK: | 194 | case I2C_SMBUS_QUICK: |
191 | protocol |= AMD_SMB_PRTCL_QUICK; | 195 | protocol |= AMD_SMB_PRTCL_QUICK; |
192 | read_write = I2C_SMBUS_WRITE; | 196 | read_write = I2C_SMBUS_WRITE; |
@@ -208,8 +212,10 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
208 | case I2C_SMBUS_WORD_DATA: | 212 | case I2C_SMBUS_WORD_DATA: |
209 | amd_ec_write(smbus, AMD_SMB_CMD, command); | 213 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
210 | if (read_write == I2C_SMBUS_WRITE) { | 214 | if (read_write == I2C_SMBUS_WRITE) { |
211 | amd_ec_write(smbus, AMD_SMB_DATA, data->word); | 215 | amd_ec_write(smbus, AMD_SMB_DATA, |
212 | amd_ec_write(smbus, AMD_SMB_DATA + 1, data->word >> 8); | 216 | data->word & 0xff); |
217 | amd_ec_write(smbus, AMD_SMB_DATA + 1, | ||
218 | data->word >> 8); | ||
213 | } | 219 | } |
214 | protocol |= AMD_SMB_PRTCL_WORD_DATA | pec; | 220 | protocol |= AMD_SMB_PRTCL_WORD_DATA | pec; |
215 | break; | 221 | break; |
@@ -217,27 +223,31 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
217 | case I2C_SMBUS_BLOCK_DATA: | 223 | case I2C_SMBUS_BLOCK_DATA: |
218 | amd_ec_write(smbus, AMD_SMB_CMD, command); | 224 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
219 | if (read_write == I2C_SMBUS_WRITE) { | 225 | if (read_write == I2C_SMBUS_WRITE) { |
220 | len = min_t(u8, data->block[0], 32); | 226 | len = min_t(u8, data->block[0], |
227 | I2C_SMBUS_BLOCK_MAX); | ||
221 | amd_ec_write(smbus, AMD_SMB_BCNT, len); | 228 | amd_ec_write(smbus, AMD_SMB_BCNT, len); |
222 | for (i = 0; i < len; i++) | 229 | for (i = 0; i < len; i++) |
223 | amd_ec_write(smbus, AMD_SMB_DATA + i, data->block[i + 1]); | 230 | amd_ec_write(smbus, AMD_SMB_DATA + i, |
231 | data->block[i + 1]); | ||
224 | } | 232 | } |
225 | protocol |= AMD_SMB_PRTCL_BLOCK_DATA | pec; | 233 | protocol |= AMD_SMB_PRTCL_BLOCK_DATA | pec; |
226 | break; | 234 | break; |
227 | 235 | ||
228 | case I2C_SMBUS_I2C_BLOCK_DATA: | 236 | case I2C_SMBUS_I2C_BLOCK_DATA: |
229 | len = min_t(u8, data->block[0], 32); | 237 | len = min_t(u8, data->block[0], |
238 | I2C_SMBUS_BLOCK_MAX); | ||
230 | amd_ec_write(smbus, AMD_SMB_CMD, command); | 239 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
231 | amd_ec_write(smbus, AMD_SMB_BCNT, len); | 240 | amd_ec_write(smbus, AMD_SMB_BCNT, len); |
232 | if (read_write == I2C_SMBUS_WRITE) | 241 | if (read_write == I2C_SMBUS_WRITE) |
233 | for (i = 0; i < len; i++) | 242 | for (i = 0; i < len; i++) |
234 | amd_ec_write(smbus, AMD_SMB_DATA + i, data->block[i + 1]); | 243 | amd_ec_write(smbus, AMD_SMB_DATA + i, |
244 | data->block[i + 1]); | ||
235 | protocol |= AMD_SMB_PRTCL_I2C_BLOCK_DATA; | 245 | protocol |= AMD_SMB_PRTCL_I2C_BLOCK_DATA; |
236 | break; | 246 | break; |
237 | 247 | ||
238 | case I2C_SMBUS_PROC_CALL: | 248 | case I2C_SMBUS_PROC_CALL: |
239 | amd_ec_write(smbus, AMD_SMB_CMD, command); | 249 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
240 | amd_ec_write(smbus, AMD_SMB_DATA, data->word); | 250 | amd_ec_write(smbus, AMD_SMB_DATA, data->word & 0xff); |
241 | amd_ec_write(smbus, AMD_SMB_DATA + 1, data->word >> 8); | 251 | amd_ec_write(smbus, AMD_SMB_DATA + 1, data->word >> 8); |
242 | protocol = AMD_SMB_PRTCL_PROC_CALL | pec; | 252 | protocol = AMD_SMB_PRTCL_PROC_CALL | pec; |
243 | read_write = I2C_SMBUS_READ; | 253 | read_write = I2C_SMBUS_READ; |
@@ -248,7 +258,8 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
248 | amd_ec_write(smbus, AMD_SMB_CMD, command); | 258 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
249 | amd_ec_write(smbus, AMD_SMB_BCNT, len); | 259 | amd_ec_write(smbus, AMD_SMB_BCNT, len); |
250 | for (i = 0; i < len; i++) | 260 | for (i = 0; i < len; i++) |
251 | amd_ec_write(smbus, AMD_SMB_DATA + i, data->block[i + 1]); | 261 | amd_ec_write(smbus, AMD_SMB_DATA + i, |
262 | data->block[i + 1]); | ||
252 | protocol = AMD_SMB_PRTCL_BLOCK_PROC_CALL | pec; | 263 | protocol = AMD_SMB_PRTCL_BLOCK_PROC_CALL | pec; |
253 | read_write = I2C_SMBUS_READ; | 264 | read_write = I2C_SMBUS_READ; |
254 | break; | 265 | break; |
@@ -280,7 +291,6 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
280 | return 0; | 291 | return 0; |
281 | 292 | ||
282 | switch (size) { | 293 | switch (size) { |
283 | |||
284 | case I2C_SMBUS_BYTE: | 294 | case I2C_SMBUS_BYTE: |
285 | case I2C_SMBUS_BYTE_DATA: | 295 | case I2C_SMBUS_BYTE_DATA: |
286 | amd_ec_read(smbus, AMD_SMB_DATA, &data->byte); | 296 | amd_ec_read(smbus, AMD_SMB_DATA, &data->byte); |
@@ -296,10 +306,11 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
296 | case I2C_SMBUS_BLOCK_DATA: | 306 | case I2C_SMBUS_BLOCK_DATA: |
297 | case I2C_SMBUS_BLOCK_PROC_CALL: | 307 | case I2C_SMBUS_BLOCK_PROC_CALL: |
298 | amd_ec_read(smbus, AMD_SMB_BCNT, &len); | 308 | amd_ec_read(smbus, AMD_SMB_BCNT, &len); |
299 | len = min_t(u8, len, 32); | 309 | len = min_t(u8, len, I2C_SMBUS_BLOCK_MAX); |
300 | case I2C_SMBUS_I2C_BLOCK_DATA: | 310 | case I2C_SMBUS_I2C_BLOCK_DATA: |
301 | for (i = 0; i < len; i++) | 311 | for (i = 0; i < len; i++) |
302 | amd_ec_read(smbus, AMD_SMB_DATA + i, data->block + i + 1); | 312 | amd_ec_read(smbus, AMD_SMB_DATA + i, |
313 | data->block + i + 1); | ||
303 | data->block[0] = len; | 314 | data->block[0] = len; |
304 | break; | 315 | break; |
305 | } | 316 | } |
@@ -310,7 +321,8 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
310 | 321 | ||
311 | static u32 amd8111_func(struct i2c_adapter *adapter) | 322 | static u32 amd8111_func(struct i2c_adapter *adapter) |
312 | { | 323 | { |
313 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | | 324 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | |
325 | I2C_FUNC_SMBUS_BYTE_DATA | | ||
314 | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA | | 326 | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA | |
315 | I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_BLOCK_PROC_CALL | | 327 | I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_BLOCK_PROC_CALL | |
316 | I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC; | 328 | I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC; |
@@ -329,12 +341,13 @@ static struct pci_device_id amd8111_ids[] = { | |||
329 | 341 | ||
330 | MODULE_DEVICE_TABLE (pci, amd8111_ids); | 342 | MODULE_DEVICE_TABLE (pci, amd8111_ids); |
331 | 343 | ||
332 | static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id) | 344 | static int __devinit amd8111_probe(struct pci_dev *dev, |
345 | const struct pci_device_id *id) | ||
333 | { | 346 | { |
334 | struct amd_smbus *smbus; | 347 | struct amd_smbus *smbus; |
335 | int error = -ENODEV; | 348 | int error; |
336 | 349 | ||
337 | if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) | 350 | if (!(pci_resource_flags(dev, 0) & IORESOURCE_IO)) |
338 | return -ENODEV; | 351 | return -ENODEV; |
339 | 352 | ||
340 | smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL); | 353 | smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL); |
@@ -345,12 +358,15 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ | |||
345 | smbus->base = pci_resource_start(dev, 0); | 358 | smbus->base = pci_resource_start(dev, 0); |
346 | smbus->size = pci_resource_len(dev, 0); | 359 | smbus->size = pci_resource_len(dev, 0); |
347 | 360 | ||
348 | if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) | 361 | if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) { |
362 | error = -EBUSY; | ||
349 | goto out_kfree; | 363 | goto out_kfree; |
364 | } | ||
350 | 365 | ||
351 | smbus->adapter.owner = THIS_MODULE; | 366 | smbus->adapter.owner = THIS_MODULE; |
352 | snprintf(smbus->adapter.name, I2C_NAME_SIZE, | 367 | snprintf(smbus->adapter.name, I2C_NAME_SIZE, |
353 | "SMBus2 AMD8111 adapter at %04x", smbus->base); | 368 | "SMBus2 AMD8111 adapter at %04x", smbus->base); |
369 | smbus->adapter.id = I2C_HW_SMBUS_AMD8111; | ||
354 | smbus->adapter.class = I2C_CLASS_HWMON; | 370 | smbus->adapter.class = I2C_CLASS_HWMON; |
355 | smbus->adapter.algo = &smbus_algorithm; | 371 | smbus->adapter.algo = &smbus_algorithm; |
356 | smbus->adapter.algo_data = smbus; | 372 | smbus->adapter.algo_data = smbus; |
@@ -358,11 +374,11 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ | |||
358 | /* set up the driverfs linkage to our parent device */ | 374 | /* set up the driverfs linkage to our parent device */ |
359 | smbus->adapter.dev.parent = &dev->dev; | 375 | smbus->adapter.dev.parent = &dev->dev; |
360 | 376 | ||
377 | pci_write_config_dword(smbus->dev, AMD_PCI_MISC, 0); | ||
361 | error = i2c_add_adapter(&smbus->adapter); | 378 | error = i2c_add_adapter(&smbus->adapter); |
362 | if (error) | 379 | if (error) |
363 | goto out_release_region; | 380 | goto out_release_region; |
364 | 381 | ||
365 | pci_write_config_dword(smbus->dev, AMD_PCI_MISC, 0); | ||
366 | pci_set_drvdata(dev, smbus); | 382 | pci_set_drvdata(dev, smbus); |
367 | return 0; | 383 | return 0; |
368 | 384 | ||
@@ -370,10 +386,9 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ | |||
370 | release_region(smbus->base, smbus->size); | 386 | release_region(smbus->base, smbus->size); |
371 | out_kfree: | 387 | out_kfree: |
372 | kfree(smbus); | 388 | kfree(smbus); |
373 | return -1; | 389 | return error; |
374 | } | 390 | } |
375 | 391 | ||
376 | |||
377 | static void __devexit amd8111_remove(struct pci_dev *dev) | 392 | static void __devexit amd8111_remove(struct pci_dev *dev) |
378 | { | 393 | { |
379 | struct amd_smbus *smbus = pci_get_drvdata(dev); | 394 | struct amd_smbus *smbus = pci_get_drvdata(dev); |
@@ -395,7 +410,6 @@ static int __init i2c_amd8111_init(void) | |||
395 | return pci_register_driver(&amd8111_driver); | 410 | return pci_register_driver(&amd8111_driver); |
396 | } | 411 | } |
397 | 412 | ||
398 | |||
399 | static void __exit i2c_amd8111_exit(void) | 413 | static void __exit i2c_amd8111_exit(void) |
400 | { | 414 | { |
401 | pci_unregister_driver(&amd8111_driver); | 415 | pci_unregister_driver(&amd8111_driver); |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index ae625b854470..21f2671f7220 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -48,7 +48,6 @@ | |||
48 | #include <linux/kernel.h> | 48 | #include <linux/kernel.h> |
49 | #include <linux/stddef.h> | 49 | #include <linux/stddef.h> |
50 | #include <linux/delay.h> | 50 | #include <linux/delay.h> |
51 | #include <linux/sched.h> | ||
52 | #include <linux/ioport.h> | 51 | #include <linux/ioport.h> |
53 | #include <linux/init.h> | 52 | #include <linux/init.h> |
54 | #include <linux/i2c.h> | 53 | #include <linux/i2c.h> |
@@ -123,7 +122,7 @@ static int i801_transaction(void) | |||
123 | dev_dbg(&I801_dev->dev, "Failed! (%02x)\n", temp); | 122 | dev_dbg(&I801_dev->dev, "Failed! (%02x)\n", temp); |
124 | return -1; | 123 | return -1; |
125 | } else { | 124 | } else { |
126 | dev_dbg(&I801_dev->dev, "Successfull!\n"); | 125 | dev_dbg(&I801_dev->dev, "Successful!\n"); |
127 | } | 126 | } |
128 | } | 127 | } |
129 | 128 | ||
@@ -442,6 +441,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
442 | 441 | ||
443 | static struct i2c_adapter i801_adapter = { | 442 | static struct i2c_adapter i801_adapter = { |
444 | .owner = THIS_MODULE, | 443 | .owner = THIS_MODULE, |
444 | .id = I2C_HW_SMBUS_I801, | ||
445 | .class = I2C_CLASS_HWMON, | 445 | .class = I2C_CLASS_HWMON, |
446 | .algo = &smbus_algorithm, | 446 | .algo = &smbus_algorithm, |
447 | }; | 447 | }; |
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c index 10c98bc88aa6..42e8d94c276f 100644 --- a/drivers/i2c/busses/i2c-i810.c +++ b/drivers/i2c/busses/i2c-i810.c | |||
@@ -171,6 +171,7 @@ static struct i2c_algo_bit_data i810_i2c_bit_data = { | |||
171 | 171 | ||
172 | static struct i2c_adapter i810_i2c_adapter = { | 172 | static struct i2c_adapter i810_i2c_adapter = { |
173 | .owner = THIS_MODULE, | 173 | .owner = THIS_MODULE, |
174 | .id = I2C_HW_B_I810, | ||
174 | .name = "I810/I815 I2C Adapter", | 175 | .name = "I810/I815 I2C Adapter", |
175 | .algo_data = &i810_i2c_bit_data, | 176 | .algo_data = &i810_i2c_bit_data, |
176 | }; | 177 | }; |
@@ -186,6 +187,7 @@ static struct i2c_algo_bit_data i810_ddc_bit_data = { | |||
186 | 187 | ||
187 | static struct i2c_adapter i810_ddc_adapter = { | 188 | static struct i2c_adapter i810_ddc_adapter = { |
188 | .owner = THIS_MODULE, | 189 | .owner = THIS_MODULE, |
190 | .id = I2C_HW_B_I810, | ||
189 | .name = "I810/I815 DDC Adapter", | 191 | .name = "I810/I815 DDC Adapter", |
190 | .algo_data = &i810_ddc_bit_data, | 192 | .algo_data = &i810_ddc_bit_data, |
191 | }; | 193 | }; |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index 1898e9987021..8b14d14e60ca 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -727,6 +727,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ | |||
727 | 727 | ||
728 | /* Register it with i2c layer */ | 728 | /* Register it with i2c layer */ |
729 | adap = &dev->adap; | 729 | adap = &dev->adap; |
730 | adap->dev.parent = &ocp->dev; | ||
730 | strcpy(adap->name, "IBM IIC"); | 731 | strcpy(adap->name, "IBM IIC"); |
731 | i2c_set_adapdata(adap, dev); | 732 | i2c_set_adapdata(adap, dev); |
732 | adap->id = I2C_HW_OCP; | 733 | adap->id = I2C_HW_OCP; |
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index d108ab4974cc..20ee4f7c53a0 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
39 | #include <linux/sched.h> | ||
40 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
41 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
42 | 41 | ||
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 8ed59a2dff53..5f33bc9c1e02 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/i2c.h> | 39 | #include <linux/i2c.h> |
40 | #include <linux/i2c-isa.h> | 40 | #include <linux/i2c-isa.h> |
41 | #include <linux/platform_device.h> | 41 | #include <linux/platform_device.h> |
42 | #include <linux/completion.h> | ||
42 | 43 | ||
43 | static u32 isa_func(struct i2c_adapter *adapter); | 44 | static u32 isa_func(struct i2c_adapter *adapter); |
44 | 45 | ||
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 490173611d6b..a3283b907eb8 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -520,6 +520,7 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
520 | rc = -ENXIO; | 520 | rc = -ENXIO; |
521 | goto exit_unmap_regs; | 521 | goto exit_unmap_regs; |
522 | } | 522 | } |
523 | drv_data->adapter.dev.parent = &pd->dev; | ||
523 | drv_data->adapter.id = I2C_HW_MV64XXX; | 524 | drv_data->adapter.id = I2C_HW_MV64XXX; |
524 | drv_data->adapter.algo = &mv64xxx_i2c_algo; | 525 | drv_data->adapter.algo = &mv64xxx_i2c_algo; |
525 | drv_data->adapter.owner = THIS_MODULE; | 526 | drv_data->adapter.owner = THIS_MODULE; |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index ad37c10e7fec..1514ec5b77f8 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include <linux/pci.h> | 44 | #include <linux/pci.h> |
45 | #include <linux/kernel.h> | 45 | #include <linux/kernel.h> |
46 | #include <linux/stddef.h> | 46 | #include <linux/stddef.h> |
47 | #include <linux/sched.h> | ||
48 | #include <linux/ioport.h> | 47 | #include <linux/ioport.h> |
49 | #include <linux/init.h> | 48 | #include <linux/init.h> |
50 | #include <linux/i2c.h> | 49 | #include <linux/i2c.h> |
@@ -57,7 +56,6 @@ MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver"); | |||
57 | 56 | ||
58 | 57 | ||
59 | struct nforce2_smbus { | 58 | struct nforce2_smbus { |
60 | struct pci_dev *dev; | ||
61 | struct i2c_adapter adapter; | 59 | struct i2c_adapter adapter; |
62 | int base; | 60 | int base; |
63 | int size; | 61 | int size; |
@@ -230,7 +228,6 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar, | |||
230 | smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; | 228 | smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; |
231 | smbus->size = 64; | 229 | smbus->size = 64; |
232 | } | 230 | } |
233 | smbus->dev = dev; | ||
234 | 231 | ||
235 | if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { | 232 | if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { |
236 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", | 233 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", |
@@ -238,6 +235,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar, | |||
238 | return -1; | 235 | return -1; |
239 | } | 236 | } |
240 | smbus->adapter.owner = THIS_MODULE; | 237 | smbus->adapter.owner = THIS_MODULE; |
238 | smbus->adapter.id = I2C_HW_SMBUS_NFORCE2; | ||
241 | smbus->adapter.class = I2C_CLASS_HWMON; | 239 | smbus->adapter.class = I2C_CLASS_HWMON; |
242 | smbus->adapter.algo = &smbus_algorithm; | 240 | smbus->adapter.algo = &smbus_algorithm; |
243 | smbus->adapter.algo_data = smbus; | 241 | smbus->adapter.algo_data = smbus; |
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index f28a76d1c0af..e417c2c3ca22 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/sched.h> | ||
15 | #include <linux/init.h> | 14 | #include <linux/init.h> |
16 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
17 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
diff --git a/drivers/i2c/busses/i2c-parport.h b/drivers/i2c/busses/i2c-parport.h index 9ddd816d5d0f..ed69d846cb95 100644 --- a/drivers/i2c/busses/i2c-parport.h +++ b/drivers/i2c/busses/i2c-parport.h | |||
@@ -88,6 +88,13 @@ static struct adapter_parm adapter_parm[] = { | |||
88 | .getscl = { 0x40, STAT, 0 }, | 88 | .getscl = { 0x40, STAT, 0 }, |
89 | .init = { 0xfc, DATA, 0 }, | 89 | .init = { 0xfc, DATA, 0 }, |
90 | }, | 90 | }, |
91 | /* type 7: One For All JP1 parallel port adapter */ | ||
92 | { | ||
93 | .setsda = { 0x01, DATA, 0 }, | ||
94 | .setscl = { 0x02, DATA, 0 }, | ||
95 | .getsda = { 0x80, STAT, 1 }, | ||
96 | .init = { 0x04, DATA, 1 }, | ||
97 | }, | ||
91 | }; | 98 | }; |
92 | 99 | ||
93 | static int type = -1; | 100 | static int type = -1; |
@@ -101,4 +108,5 @@ MODULE_PARM_DESC(type, | |||
101 | " 4 = ADM1032 evaluation board\n" | 108 | " 4 = ADM1032 evaluation board\n" |
102 | " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n" | 109 | " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n" |
103 | " 6 = Barco LPT->DVI (K5800236) adapter\n" | 110 | " 6 = Barco LPT->DVI (K5800236) adapter\n" |
111 | " 7 = One For All JP1 parallel port adapter\n" | ||
104 | ); | 112 | ); |
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c new file mode 100644 index 000000000000..f54fb5d65cc4 --- /dev/null +++ b/drivers/i2c/busses/i2c-pasemi.c | |||
@@ -0,0 +1,426 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006-2007 PA Semi, Inc | ||
3 | * | ||
4 | * SMBus host driver for PA Semi PWRficient | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/module.h> | ||
21 | #include <linux/pci.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/stddef.h> | ||
24 | #include <linux/sched.h> | ||
25 | #include <linux/i2c.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <asm/io.h> | ||
28 | |||
29 | static struct pci_driver pasemi_smb_driver; | ||
30 | |||
31 | struct pasemi_smbus { | ||
32 | struct pci_dev *dev; | ||
33 | struct i2c_adapter adapter; | ||
34 | unsigned long base; | ||
35 | int size; | ||
36 | }; | ||
37 | |||
38 | /* Register offsets */ | ||
39 | #define REG_MTXFIFO 0x00 | ||
40 | #define REG_MRXFIFO 0x04 | ||
41 | #define REG_SMSTA 0x14 | ||
42 | #define REG_CTL 0x1c | ||
43 | |||
44 | /* Register defs */ | ||
45 | #define MTXFIFO_READ 0x00000400 | ||
46 | #define MTXFIFO_STOP 0x00000200 | ||
47 | #define MTXFIFO_START 0x00000100 | ||
48 | #define MTXFIFO_DATA_M 0x000000ff | ||
49 | |||
50 | #define MRXFIFO_EMPTY 0x00000100 | ||
51 | #define MRXFIFO_DATA_M 0x000000ff | ||
52 | |||
53 | #define SMSTA_XEN 0x08000000 | ||
54 | |||
55 | #define CTL_MRR 0x00000400 | ||
56 | #define CTL_MTR 0x00000200 | ||
57 | #define CTL_CLK_M 0x000000ff | ||
58 | |||
59 | #define CLK_100K_DIV 84 | ||
60 | #define CLK_400K_DIV 21 | ||
61 | |||
62 | static inline void reg_write(struct pasemi_smbus *smbus, int reg, int val) | ||
63 | { | ||
64 | dev_dbg(&smbus->dev->dev, "smbus write reg %lx val %08x\n", | ||
65 | smbus->base + reg, val); | ||
66 | outl(val, smbus->base + reg); | ||
67 | } | ||
68 | |||
69 | static inline int reg_read(struct pasemi_smbus *smbus, int reg) | ||
70 | { | ||
71 | int ret; | ||
72 | ret = inl(smbus->base + reg); | ||
73 | dev_dbg(&smbus->dev->dev, "smbus read reg %lx val %08x\n", | ||
74 | smbus->base + reg, ret); | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | #define TXFIFO_WR(smbus, reg) reg_write((smbus), REG_MTXFIFO, (reg)) | ||
79 | #define RXFIFO_RD(smbus) reg_read((smbus), REG_MRXFIFO) | ||
80 | |||
81 | static void pasemi_smb_clear(struct pasemi_smbus *smbus) | ||
82 | { | ||
83 | unsigned int status; | ||
84 | |||
85 | status = reg_read(smbus, REG_SMSTA); | ||
86 | reg_write(smbus, REG_SMSTA, status); | ||
87 | } | ||
88 | |||
89 | static unsigned int pasemi_smb_waitready(struct pasemi_smbus *smbus) | ||
90 | { | ||
91 | int timeout = 10; | ||
92 | unsigned int status; | ||
93 | |||
94 | status = reg_read(smbus, REG_SMSTA); | ||
95 | |||
96 | while (!(status & SMSTA_XEN) && timeout--) { | ||
97 | msleep(1); | ||
98 | status = reg_read(smbus, REG_SMSTA); | ||
99 | } | ||
100 | |||
101 | if (timeout < 0) { | ||
102 | dev_warn(&smbus->dev->dev, "Timeout, status 0x%08x\n", status); | ||
103 | reg_write(smbus, REG_SMSTA, status); | ||
104 | return -ETIME; | ||
105 | } | ||
106 | |||
107 | /* Clear XEN */ | ||
108 | reg_write(smbus, REG_SMSTA, SMSTA_XEN); | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static int pasemi_i2c_xfer_msg(struct i2c_adapter *adapter, | ||
114 | struct i2c_msg *msg, int stop) | ||
115 | { | ||
116 | struct pasemi_smbus *smbus = adapter->algo_data; | ||
117 | int read, i, err; | ||
118 | u32 rd; | ||
119 | |||
120 | read = msg->flags & I2C_M_RD ? 1 : 0; | ||
121 | |||
122 | TXFIFO_WR(smbus, MTXFIFO_START | (msg->addr << 1) | read); | ||
123 | |||
124 | if (read) { | ||
125 | TXFIFO_WR(smbus, msg->len | MTXFIFO_READ | | ||
126 | (stop ? MTXFIFO_STOP : 0)); | ||
127 | |||
128 | err = pasemi_smb_waitready(smbus); | ||
129 | if (err) | ||
130 | goto reset_out; | ||
131 | |||
132 | for (i = 0; i < msg->len; i++) { | ||
133 | rd = RXFIFO_RD(smbus); | ||
134 | if (rd & MRXFIFO_EMPTY) { | ||
135 | err = -ENODATA; | ||
136 | goto reset_out; | ||
137 | } | ||
138 | msg->buf[i] = rd & MRXFIFO_DATA_M; | ||
139 | } | ||
140 | } else { | ||
141 | for (i = 0; i < msg->len - 1; i++) | ||
142 | TXFIFO_WR(smbus, msg->buf[i]); | ||
143 | |||
144 | TXFIFO_WR(smbus, msg->buf[msg->len] | | ||
145 | (stop ? MTXFIFO_STOP : 0)); | ||
146 | } | ||
147 | |||
148 | return 0; | ||
149 | |||
150 | reset_out: | ||
151 | reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | | ||
152 | (CLK_100K_DIV & CTL_CLK_M))); | ||
153 | return err; | ||
154 | } | ||
155 | |||
156 | static int pasemi_i2c_xfer(struct i2c_adapter *adapter, | ||
157 | struct i2c_msg *msgs, int num) | ||
158 | { | ||
159 | struct pasemi_smbus *smbus = adapter->algo_data; | ||
160 | int ret, i; | ||
161 | |||
162 | pasemi_smb_clear(smbus); | ||
163 | |||
164 | ret = 0; | ||
165 | |||
166 | for (i = 0; i < num && !ret; i++) | ||
167 | ret = pasemi_i2c_xfer_msg(adapter, &msgs[i], (i == (num - 1))); | ||
168 | |||
169 | return ret ? ret : num; | ||
170 | } | ||
171 | |||
172 | static int pasemi_smb_xfer(struct i2c_adapter *adapter, | ||
173 | u16 addr, unsigned short flags, char read_write, u8 command, | ||
174 | int size, union i2c_smbus_data *data) | ||
175 | { | ||
176 | struct pasemi_smbus *smbus = adapter->algo_data; | ||
177 | unsigned int rd; | ||
178 | int read_flag, err; | ||
179 | int len = 0, i; | ||
180 | |||
181 | /* All our ops take 8-bit shifted addresses */ | ||
182 | addr <<= 1; | ||
183 | read_flag = read_write == I2C_SMBUS_READ; | ||
184 | |||
185 | pasemi_smb_clear(smbus); | ||
186 | |||
187 | switch (size) { | ||
188 | case I2C_SMBUS_QUICK: | ||
189 | TXFIFO_WR(smbus, addr | read_flag | MTXFIFO_START | | ||
190 | MTXFIFO_STOP); | ||
191 | break; | ||
192 | case I2C_SMBUS_BYTE: | ||
193 | TXFIFO_WR(smbus, addr | read_flag | MTXFIFO_START); | ||
194 | if (read_write) | ||
195 | TXFIFO_WR(smbus, 1 | MTXFIFO_STOP | MTXFIFO_READ); | ||
196 | else | ||
197 | TXFIFO_WR(smbus, MTXFIFO_STOP | command); | ||
198 | break; | ||
199 | case I2C_SMBUS_BYTE_DATA: | ||
200 | TXFIFO_WR(smbus, addr | MTXFIFO_START); | ||
201 | TXFIFO_WR(smbus, command); | ||
202 | if (read_write) { | ||
203 | TXFIFO_WR(smbus, addr | I2C_SMBUS_READ | MTXFIFO_START); | ||
204 | TXFIFO_WR(smbus, 1 | MTXFIFO_READ | MTXFIFO_STOP); | ||
205 | } else { | ||
206 | TXFIFO_WR(smbus, MTXFIFO_STOP | data->byte); | ||
207 | } | ||
208 | break; | ||
209 | case I2C_SMBUS_WORD_DATA: | ||
210 | TXFIFO_WR(smbus, addr | MTXFIFO_START); | ||
211 | TXFIFO_WR(smbus, command); | ||
212 | if (read_write) { | ||
213 | TXFIFO_WR(smbus, addr | I2C_SMBUS_READ | MTXFIFO_START); | ||
214 | TXFIFO_WR(smbus, 2 | MTXFIFO_READ | MTXFIFO_STOP); | ||
215 | } else { | ||
216 | TXFIFO_WR(smbus, data->word & MTXFIFO_DATA_M); | ||
217 | TXFIFO_WR(smbus, MTXFIFO_STOP | (data->word >> 8)); | ||
218 | } | ||
219 | break; | ||
220 | case I2C_SMBUS_BLOCK_DATA: | ||
221 | TXFIFO_WR(smbus, addr | MTXFIFO_START); | ||
222 | TXFIFO_WR(smbus, command); | ||
223 | if (read_write) { | ||
224 | TXFIFO_WR(smbus, addr | I2C_SMBUS_READ | MTXFIFO_START); | ||
225 | TXFIFO_WR(smbus, 1 | MTXFIFO_READ); | ||
226 | rd = RXFIFO_RD(smbus); | ||
227 | len = min_t(u8, (rd & MRXFIFO_DATA_M), | ||
228 | I2C_SMBUS_BLOCK_MAX); | ||
229 | TXFIFO_WR(smbus, (len + 1) | MTXFIFO_READ | | ||
230 | MTXFIFO_STOP); | ||
231 | } else { | ||
232 | len = min_t(u8, data->block[0], I2C_SMBUS_BLOCK_MAX); | ||
233 | TXFIFO_WR(smbus, len); | ||
234 | for (i = 1; i < len; i++) | ||
235 | TXFIFO_WR(smbus, data->block[i]); | ||
236 | TXFIFO_WR(smbus, data->block[len] | MTXFIFO_STOP); | ||
237 | } | ||
238 | break; | ||
239 | case I2C_SMBUS_PROC_CALL: | ||
240 | read_write = I2C_SMBUS_READ; | ||
241 | TXFIFO_WR(smbus, addr | MTXFIFO_START); | ||
242 | TXFIFO_WR(smbus, command); | ||
243 | TXFIFO_WR(smbus, data->word & MTXFIFO_DATA_M); | ||
244 | TXFIFO_WR(smbus, (data->word >> 8) & MTXFIFO_DATA_M); | ||
245 | TXFIFO_WR(smbus, addr | I2C_SMBUS_READ | MTXFIFO_START); | ||
246 | TXFIFO_WR(smbus, 2 | MTXFIFO_STOP | MTXFIFO_READ); | ||
247 | break; | ||
248 | case I2C_SMBUS_BLOCK_PROC_CALL: | ||
249 | len = min_t(u8, data->block[0], I2C_SMBUS_BLOCK_MAX - 1); | ||
250 | read_write = I2C_SMBUS_READ; | ||
251 | TXFIFO_WR(smbus, addr | MTXFIFO_START); | ||
252 | TXFIFO_WR(smbus, command); | ||
253 | TXFIFO_WR(smbus, len); | ||
254 | for (i = 1; i <= len; i++) | ||
255 | TXFIFO_WR(smbus, data->block[i]); | ||
256 | TXFIFO_WR(smbus, addr | I2C_SMBUS_READ); | ||
257 | TXFIFO_WR(smbus, MTXFIFO_READ | 1); | ||
258 | rd = RXFIFO_RD(smbus); | ||
259 | len = min_t(u8, (rd & MRXFIFO_DATA_M), | ||
260 | I2C_SMBUS_BLOCK_MAX - len); | ||
261 | TXFIFO_WR(smbus, (len + 1) | MTXFIFO_READ | MTXFIFO_STOP); | ||
262 | break; | ||
263 | |||
264 | default: | ||
265 | dev_warn(&adapter->dev, "Unsupported transaction %d\n", size); | ||
266 | return -EINVAL; | ||
267 | } | ||
268 | |||
269 | err = pasemi_smb_waitready(smbus); | ||
270 | if (err) | ||
271 | goto reset_out; | ||
272 | |||
273 | if (read_write == I2C_SMBUS_WRITE) | ||
274 | return 0; | ||
275 | |||
276 | switch (size) { | ||
277 | case I2C_SMBUS_BYTE: | ||
278 | case I2C_SMBUS_BYTE_DATA: | ||
279 | rd = RXFIFO_RD(smbus); | ||
280 | if (rd & MRXFIFO_EMPTY) { | ||
281 | err = -ENODATA; | ||
282 | goto reset_out; | ||
283 | } | ||
284 | data->byte = rd & MRXFIFO_DATA_M; | ||
285 | break; | ||
286 | case I2C_SMBUS_WORD_DATA: | ||
287 | case I2C_SMBUS_PROC_CALL: | ||
288 | rd = RXFIFO_RD(smbus); | ||
289 | if (rd & MRXFIFO_EMPTY) { | ||
290 | err = -ENODATA; | ||
291 | goto reset_out; | ||
292 | } | ||
293 | data->word = rd & MRXFIFO_DATA_M; | ||
294 | rd = RXFIFO_RD(smbus); | ||
295 | if (rd & MRXFIFO_EMPTY) { | ||
296 | err = -ENODATA; | ||
297 | goto reset_out; | ||
298 | } | ||
299 | data->word |= (rd & MRXFIFO_DATA_M) << 8; | ||
300 | break; | ||
301 | case I2C_SMBUS_BLOCK_DATA: | ||
302 | case I2C_SMBUS_BLOCK_PROC_CALL: | ||
303 | data->block[0] = len; | ||
304 | for (i = 1; i <= len; i ++) { | ||
305 | rd = RXFIFO_RD(smbus); | ||
306 | if (rd & MRXFIFO_EMPTY) { | ||
307 | err = -ENODATA; | ||
308 | goto reset_out; | ||
309 | } | ||
310 | data->block[i] = rd & MRXFIFO_DATA_M; | ||
311 | } | ||
312 | break; | ||
313 | } | ||
314 | |||
315 | return 0; | ||
316 | |||
317 | reset_out: | ||
318 | reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | | ||
319 | (CLK_100K_DIV & CTL_CLK_M))); | ||
320 | return err; | ||
321 | } | ||
322 | |||
323 | static u32 pasemi_smb_func(struct i2c_adapter *adapter) | ||
324 | { | ||
325 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | ||
326 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | | ||
327 | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL | | ||
328 | I2C_FUNC_SMBUS_BLOCK_PROC_CALL | I2C_FUNC_I2C; | ||
329 | } | ||
330 | |||
331 | static const struct i2c_algorithm smbus_algorithm = { | ||
332 | .master_xfer = pasemi_i2c_xfer, | ||
333 | .smbus_xfer = pasemi_smb_xfer, | ||
334 | .functionality = pasemi_smb_func, | ||
335 | }; | ||
336 | |||
337 | static int __devinit pasemi_smb_probe(struct pci_dev *dev, | ||
338 | const struct pci_device_id *id) | ||
339 | { | ||
340 | struct pasemi_smbus *smbus; | ||
341 | int error; | ||
342 | |||
343 | if (!(pci_resource_flags(dev, 0) & IORESOURCE_IO)) | ||
344 | return -ENODEV; | ||
345 | |||
346 | smbus = kzalloc(sizeof(struct pasemi_smbus), GFP_KERNEL); | ||
347 | if (!smbus) | ||
348 | return -ENOMEM; | ||
349 | |||
350 | smbus->dev = dev; | ||
351 | smbus->base = pci_resource_start(dev, 0); | ||
352 | smbus->size = pci_resource_len(dev, 0); | ||
353 | |||
354 | if (!request_region(smbus->base, smbus->size, | ||
355 | pasemi_smb_driver.name)) { | ||
356 | error = -EBUSY; | ||
357 | goto out_kfree; | ||
358 | } | ||
359 | |||
360 | smbus->adapter.owner = THIS_MODULE; | ||
361 | snprintf(smbus->adapter.name, I2C_NAME_SIZE, | ||
362 | "PA Semi SMBus adapter at 0x%lx", smbus->base); | ||
363 | smbus->adapter.class = I2C_CLASS_HWMON; | ||
364 | smbus->adapter.algo = &smbus_algorithm; | ||
365 | smbus->adapter.algo_data = smbus; | ||
366 | |||
367 | /* set up the driverfs linkage to our parent device */ | ||
368 | smbus->adapter.dev.parent = &dev->dev; | ||
369 | |||
370 | reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | | ||
371 | (CLK_100K_DIV & CTL_CLK_M))); | ||
372 | |||
373 | error = i2c_add_adapter(&smbus->adapter); | ||
374 | if (error) | ||
375 | goto out_release_region; | ||
376 | |||
377 | pci_set_drvdata(dev, smbus); | ||
378 | |||
379 | return 0; | ||
380 | |||
381 | out_release_region: | ||
382 | release_region(smbus->base, smbus->size); | ||
383 | out_kfree: | ||
384 | kfree(smbus); | ||
385 | return error; | ||
386 | } | ||
387 | |||
388 | static void __devexit pasemi_smb_remove(struct pci_dev *dev) | ||
389 | { | ||
390 | struct pasemi_smbus *smbus = pci_get_drvdata(dev); | ||
391 | |||
392 | i2c_del_adapter(&smbus->adapter); | ||
393 | release_region(smbus->base, smbus->size); | ||
394 | kfree(smbus); | ||
395 | } | ||
396 | |||
397 | static struct pci_device_id pasemi_smb_ids[] = { | ||
398 | { PCI_DEVICE(0x1959, 0xa003) }, | ||
399 | { 0, } | ||
400 | }; | ||
401 | |||
402 | MODULE_DEVICE_TABLE(pci, pasemi_smb_ids); | ||
403 | |||
404 | static struct pci_driver pasemi_smb_driver = { | ||
405 | .name = "i2c-pasemi", | ||
406 | .id_table = pasemi_smb_ids, | ||
407 | .probe = pasemi_smb_probe, | ||
408 | .remove = __devexit_p(pasemi_smb_remove), | ||
409 | }; | ||
410 | |||
411 | static int __init pasemi_smb_init(void) | ||
412 | { | ||
413 | return pci_register_driver(&pasemi_smb_driver); | ||
414 | } | ||
415 | |||
416 | static void __exit pasemi_smb_exit(void) | ||
417 | { | ||
418 | pci_unregister_driver(&pasemi_smb_driver); | ||
419 | } | ||
420 | |||
421 | MODULE_LICENSE("GPL"); | ||
422 | MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>"); | ||
423 | MODULE_DESCRIPTION("PA Semi PWRficient SMBus driver"); | ||
424 | |||
425 | module_init(pasemi_smb_init); | ||
426 | module_exit(pasemi_smb_exit); | ||
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 30c7a1b38cbd..d888293c1a9c 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -23,6 +23,7 @@ | |||
23 | Supports: | 23 | Supports: |
24 | Intel PIIX4, 440MX | 24 | Intel PIIX4, 440MX |
25 | Serverworks OSB4, CSB5, CSB6, HT-1000 | 25 | Serverworks OSB4, CSB5, CSB6, HT-1000 |
26 | ATI IXP200, IXP300, IXP400, SB600 | ||
26 | SMSC Victory66 | 27 | SMSC Victory66 |
27 | 28 | ||
28 | Note: we assume there can only be one device, with one SMBus interface. | 29 | Note: we assume there can only be one device, with one SMBus interface. |
@@ -34,7 +35,6 @@ | |||
34 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
35 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
36 | #include <linux/stddef.h> | 37 | #include <linux/stddef.h> |
37 | #include <linux/sched.h> | ||
38 | #include <linux/ioport.h> | 38 | #include <linux/ioport.h> |
39 | #include <linux/i2c.h> | 39 | #include <linux/i2c.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
@@ -383,6 +383,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
383 | 383 | ||
384 | static struct i2c_adapter piix4_adapter = { | 384 | static struct i2c_adapter piix4_adapter = { |
385 | .owner = THIS_MODULE, | 385 | .owner = THIS_MODULE, |
386 | .id = I2C_HW_SMBUS_PIIX4, | ||
386 | .class = I2C_CLASS_HWMON, | 387 | .class = I2C_CLASS_HWMON, |
387 | .algo = &smbus_algorithm, | 388 | .algo = &smbus_algorithm, |
388 | }; | 389 | }; |
@@ -396,6 +397,8 @@ static struct pci_device_id piix4_ids[] = { | |||
396 | .driver_data = 0 }, | 397 | .driver_data = 0 }, |
397 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS), | 398 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS), |
398 | .driver_data = 0 }, | 399 | .driver_data = 0 }, |
400 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SMBUS), | ||
401 | .driver_data = 0 }, | ||
399 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4), | 402 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4), |
400 | .driver_data = 0 }, | 403 | .driver_data = 0 }, |
401 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5), | 404 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5), |
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c index 648d55533d87..1425d2245c82 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/completion.h> | ||
29 | #include <linux/device.h> | 28 | #include <linux/device.h> |
30 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
31 | #include <asm/prom.h> | 30 | #include <asm/prom.h> |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 4ca6de209b8b..556f244aae76 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/time.h> | 29 | #include <linux/time.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/sched.h> | ||
32 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
33 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
34 | #include <linux/err.h> | 33 | #include <linux/err.h> |
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c index 844b4ff90893..b7fb65c30112 100644 --- a/drivers/i2c/busses/i2c-savage4.c +++ b/drivers/i2c/busses/i2c-savage4.c | |||
@@ -145,6 +145,7 @@ static struct i2c_algo_bit_data sav_i2c_bit_data = { | |||
145 | 145 | ||
146 | static struct i2c_adapter savage4_i2c_adapter = { | 146 | static struct i2c_adapter savage4_i2c_adapter = { |
147 | .owner = THIS_MODULE, | 147 | .owner = THIS_MODULE, |
148 | .id = I2C_HW_B_SAVAGE, | ||
148 | .name = "I2C Savage4 adapter", | 149 | .name = "I2C Savage4 adapter", |
149 | .algo_data = &sav_i2c_bit_data, | 150 | .algo_data = &sav_i2c_bit_data, |
150 | }; | 151 | }; |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 38bbfd840b6b..d333babe4ad3 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -365,6 +365,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
365 | 365 | ||
366 | static struct i2c_adapter sis5595_adapter = { | 366 | static struct i2c_adapter sis5595_adapter = { |
367 | .owner = THIS_MODULE, | 367 | .owner = THIS_MODULE, |
368 | .id = I2C_HW_SMBUS_SIS5595, | ||
368 | .class = I2C_CLASS_HWMON, | 369 | .class = I2C_CLASS_HWMON, |
369 | .algo = &smbus_algorithm, | 370 | .algo = &smbus_algorithm, |
370 | }; | 371 | }; |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index dec0bafb52ab..172bacf932a6 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -457,6 +457,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
457 | 457 | ||
458 | static struct i2c_adapter sis630_adapter = { | 458 | static struct i2c_adapter sis630_adapter = { |
459 | .owner = THIS_MODULE, | 459 | .owner = THIS_MODULE, |
460 | .id = I2C_HW_SMBUS_SIS630, | ||
460 | .class = I2C_CLASS_HWMON, | 461 | .class = I2C_CLASS_HWMON, |
461 | .algo = &smbus_algorithm, | 462 | .algo = &smbus_algorithm, |
462 | }; | 463 | }; |
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index 7fd07fbac336..73dae449fb23 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
39 | #include <linux/stddef.h> | 39 | #include <linux/stddef.h> |
40 | #include <linux/sched.h> | ||
41 | #include <linux/ioport.h> | 40 | #include <linux/ioport.h> |
42 | #include <linux/i2c.h> | 41 | #include <linux/i2c.h> |
43 | #include <linux/init.h> | 42 | #include <linux/init.h> |
@@ -249,6 +248,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
249 | 248 | ||
250 | static struct i2c_adapter sis96x_adapter = { | 249 | static struct i2c_adapter sis96x_adapter = { |
251 | .owner = THIS_MODULE, | 250 | .owner = THIS_MODULE, |
251 | .id = I2C_HW_SMBUS_SIS96X, | ||
252 | .class = I2C_CLASS_HWMON, | 252 | .class = I2C_CLASS_HWMON, |
253 | .algo = &smbus_algorithm, | 253 | .algo = &smbus_algorithm, |
254 | }; | 254 | }; |
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c index 15d7e00e47e6..bbcc62151f7c 100644 --- a/drivers/i2c/busses/i2c-via.c +++ b/drivers/i2c/busses/i2c-via.c | |||
@@ -86,6 +86,7 @@ static struct i2c_algo_bit_data bit_data = { | |||
86 | 86 | ||
87 | static struct i2c_adapter vt586b_adapter = { | 87 | static struct i2c_adapter vt586b_adapter = { |
88 | .owner = THIS_MODULE, | 88 | .owner = THIS_MODULE, |
89 | .id = I2C_HW_B_VIA, | ||
89 | .class = I2C_CLASS_HWMON, | 90 | .class = I2C_CLASS_HWMON, |
90 | .name = "VIA i2c", | 91 | .name = "VIA i2c", |
91 | .algo_data = &bit_data, | 92 | .algo_data = &bit_data, |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index efc6bbf0cc0a..03c5fc868548 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -4,7 +4,7 @@ | |||
4 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, | 4 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, |
5 | Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>, | 5 | Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>, |
6 | Mark D. Studebaker <mdsxyz123@yahoo.com> | 6 | Mark D. Studebaker <mdsxyz123@yahoo.com> |
7 | Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> | 7 | Copyright (C) 2005 - 2007 Jean Delvare <khali@linux-fr.org> |
8 | 8 | ||
9 | This program is free software; you can redistribute it and/or modify | 9 | This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | 10 | it under the terms of the GNU General Public License as published by |
@@ -36,6 +36,7 @@ | |||
36 | VT8237R 0x3227 yes | 36 | VT8237R 0x3227 yes |
37 | VT8237A 0x3337 yes | 37 | VT8237A 0x3337 yes |
38 | VT8251 0x3287 yes | 38 | VT8251 0x3287 yes |
39 | CX700 0x8324 yes | ||
39 | 40 | ||
40 | Note: we assume there can only be one device, with one SMBus interface. | 41 | Note: we assume there can only be one device, with one SMBus interface. |
41 | */ | 42 | */ |
@@ -306,6 +307,7 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
306 | 307 | ||
307 | static struct i2c_adapter vt596_adapter = { | 308 | static struct i2c_adapter vt596_adapter = { |
308 | .owner = THIS_MODULE, | 309 | .owner = THIS_MODULE, |
310 | .id = I2C_HW_SMBUS_VIA2, | ||
309 | .class = I2C_CLASS_HWMON, | 311 | .class = I2C_CLASS_HWMON, |
310 | .algo = &smbus_algorithm, | 312 | .algo = &smbus_algorithm, |
311 | }; | 313 | }; |
@@ -383,6 +385,7 @@ found: | |||
383 | dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); | 385 | dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); |
384 | 386 | ||
385 | switch (pdev->device) { | 387 | switch (pdev->device) { |
388 | case PCI_DEVICE_ID_VIA_CX700: | ||
386 | case PCI_DEVICE_ID_VIA_8251: | 389 | case PCI_DEVICE_ID_VIA_8251: |
387 | case PCI_DEVICE_ID_VIA_8237: | 390 | case PCI_DEVICE_ID_VIA_8237: |
388 | case PCI_DEVICE_ID_VIA_8237A: | 391 | case PCI_DEVICE_ID_VIA_8237A: |
@@ -442,6 +445,8 @@ static struct pci_device_id vt596_ids[] = { | |||
442 | .driver_data = SMBBA1 }, | 445 | .driver_data = SMBBA1 }, |
443 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8251), | 446 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8251), |
444 | .driver_data = SMBBA3 }, | 447 | .driver_data = SMBBA3 }, |
448 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700), | ||
449 | .driver_data = SMBBA3 }, | ||
445 | { 0, } | 450 | { 0, } |
446 | }; | 451 | }; |
447 | 452 | ||
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c index b0377b81744b..88a3447e11e1 100644 --- a/drivers/i2c/busses/i2c-voodoo3.c +++ b/drivers/i2c/busses/i2c-voodoo3.c | |||
@@ -165,6 +165,7 @@ static struct i2c_algo_bit_data voo_i2c_bit_data = { | |||
165 | 165 | ||
166 | static struct i2c_adapter voodoo3_i2c_adapter = { | 166 | static struct i2c_adapter voodoo3_i2c_adapter = { |
167 | .owner = THIS_MODULE, | 167 | .owner = THIS_MODULE, |
168 | .id = I2C_HW_B_VOO, | ||
168 | .class = I2C_CLASS_TV_ANALOG, | 169 | .class = I2C_CLASS_TV_ANALOG, |
169 | .name = "I2C Voodoo3/Banshee adapter", | 170 | .name = "I2C Voodoo3/Banshee adapter", |
170 | .algo_data = &voo_i2c_bit_data, | 171 | .algo_data = &voo_i2c_bit_data, |
@@ -181,6 +182,7 @@ static struct i2c_algo_bit_data voo_ddc_bit_data = { | |||
181 | 182 | ||
182 | static struct i2c_adapter voodoo3_ddc_adapter = { | 183 | static struct i2c_adapter voodoo3_ddc_adapter = { |
183 | .owner = THIS_MODULE, | 184 | .owner = THIS_MODULE, |
185 | .id = I2C_HW_B_VOO, | ||
184 | .class = I2C_CLASS_DDC, | 186 | .class = I2C_CLASS_DDC, |
185 | .name = "DDC Voodoo3/Banshee adapter", | 187 | .name = "DDC Voodoo3/Banshee adapter", |
186 | .algo_data = &voo_ddc_bit_data, | 188 | .algo_data = &voo_ddc_bit_data, |
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 714bae780953..0b082c5a0195 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -428,7 +428,7 @@ static __init int scx200_acb_probe(struct scx200_acb_iface *iface) | |||
428 | } | 428 | } |
429 | 429 | ||
430 | static __init struct scx200_acb_iface *scx200_create_iface(const char *text, | 430 | static __init struct scx200_acb_iface *scx200_create_iface(const char *text, |
431 | int index) | 431 | struct device *dev, int index) |
432 | { | 432 | { |
433 | struct scx200_acb_iface *iface; | 433 | struct scx200_acb_iface *iface; |
434 | struct i2c_adapter *adapter; | 434 | struct i2c_adapter *adapter; |
@@ -446,6 +446,7 @@ static __init struct scx200_acb_iface *scx200_create_iface(const char *text, | |||
446 | adapter->id = I2C_HW_SMBUS_SCX200; | 446 | adapter->id = I2C_HW_SMBUS_SCX200; |
447 | adapter->algo = &scx200_acb_algorithm; | 447 | adapter->algo = &scx200_acb_algorithm; |
448 | adapter->class = I2C_CLASS_HWMON; | 448 | adapter->class = I2C_CLASS_HWMON; |
449 | adapter->dev.parent = dev; | ||
449 | 450 | ||
450 | mutex_init(&iface->mutex); | 451 | mutex_init(&iface->mutex); |
451 | 452 | ||
@@ -486,7 +487,7 @@ static __init int scx200_create_pci(const char *text, struct pci_dev *pdev, | |||
486 | struct scx200_acb_iface *iface; | 487 | struct scx200_acb_iface *iface; |
487 | int rc; | 488 | int rc; |
488 | 489 | ||
489 | iface = scx200_create_iface(text, 0); | 490 | iface = scx200_create_iface(text, &pdev->dev, 0); |
490 | 491 | ||
491 | if (iface == NULL) | 492 | if (iface == NULL) |
492 | return -ENOMEM; | 493 | return -ENOMEM; |
@@ -524,7 +525,7 @@ static int __init scx200_create_isa(const char *text, unsigned long base, | |||
524 | struct scx200_acb_iface *iface; | 525 | struct scx200_acb_iface *iface; |
525 | int rc; | 526 | int rc; |
526 | 527 | ||
527 | iface = scx200_create_iface(text, index); | 528 | iface = scx200_create_iface(text, NULL, index); |
528 | 529 | ||
529 | if (iface == NULL) | 530 | if (iface == NULL) |
530 | return -ENOMEM; | 531 | return -ENOMEM; |
diff --git a/drivers/i2c/busses/scx200_i2c.c b/drivers/i2c/busses/scx200_i2c.c index 6cd96e43aa72..c3022a023449 100644 --- a/drivers/i2c/busses/scx200_i2c.c +++ b/drivers/i2c/busses/scx200_i2c.c | |||
@@ -81,6 +81,7 @@ static struct i2c_algo_bit_data scx200_i2c_data = { | |||
81 | 81 | ||
82 | static struct i2c_adapter scx200_i2c_ops = { | 82 | static struct i2c_adapter scx200_i2c_ops = { |
83 | .owner = THIS_MODULE, | 83 | .owner = THIS_MODULE, |
84 | .id = I2C_HW_B_SCX200, | ||
84 | .algo_data = &scx200_i2c_data, | 85 | .algo_data = &scx200_i2c_data, |
85 | .name = "NatSemi SCx200 I2C", | 86 | .name = "NatSemi SCx200 I2C", |
86 | }; | 87 | }; |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index cec3a0c3894d..bfce13c8f1ff 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/sched.h> | ||
34 | #include <linux/jiffies.h> | 33 | #include <linux/jiffies.h> |
35 | #include <linux/i2c.h> | 34 | #include <linux/i2c.h> |
36 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index b05378a3d673..21fe1406c8b4 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | #include <linux/completion.h> | ||
35 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
36 | 37 | ||
37 | 38 | ||
@@ -40,49 +41,72 @@ static LIST_HEAD(drivers); | |||
40 | static DEFINE_MUTEX(core_lists); | 41 | static DEFINE_MUTEX(core_lists); |
41 | static DEFINE_IDR(i2c_adapter_idr); | 42 | static DEFINE_IDR(i2c_adapter_idr); |
42 | 43 | ||
44 | |||
45 | /* ------------------------------------------------------------------------- */ | ||
46 | |||
43 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ | 47 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ |
44 | static int i2c_device_match(struct device *dev, struct device_driver *drv) | 48 | static int i2c_device_match(struct device *dev, struct device_driver *drv) |
45 | { | 49 | { |
46 | return 1; | 50 | return 1; |
47 | } | 51 | } |
48 | 52 | ||
49 | static int i2c_bus_suspend(struct device * dev, pm_message_t state) | 53 | static int i2c_device_probe(struct device *dev) |
50 | { | 54 | { |
51 | int rc = 0; | 55 | return -ENODEV; |
56 | } | ||
52 | 57 | ||
53 | if (dev->driver && dev->driver->suspend) | 58 | static int i2c_device_remove(struct device *dev) |
54 | rc = dev->driver->suspend(dev, state); | 59 | { |
55 | return rc; | 60 | return 0; |
56 | } | 61 | } |
57 | 62 | ||
58 | static int i2c_bus_resume(struct device * dev) | 63 | static void i2c_device_shutdown(struct device *dev) |
59 | { | 64 | { |
60 | int rc = 0; | 65 | struct i2c_driver *driver; |
61 | 66 | ||
62 | if (dev->driver && dev->driver->resume) | 67 | if (!dev->driver) |
63 | rc = dev->driver->resume(dev); | 68 | return; |
64 | return rc; | 69 | driver = to_i2c_driver(dev->driver); |
70 | if (driver->shutdown) | ||
71 | driver->shutdown(to_i2c_client(dev)); | ||
65 | } | 72 | } |
66 | 73 | ||
67 | static int i2c_device_probe(struct device *dev) | 74 | static int i2c_device_suspend(struct device * dev, pm_message_t mesg) |
68 | { | 75 | { |
69 | return -ENODEV; | 76 | struct i2c_driver *driver; |
77 | |||
78 | if (!dev->driver) | ||
79 | return 0; | ||
80 | driver = to_i2c_driver(dev->driver); | ||
81 | if (!driver->suspend) | ||
82 | return 0; | ||
83 | return driver->suspend(to_i2c_client(dev), mesg); | ||
70 | } | 84 | } |
71 | 85 | ||
72 | static int i2c_device_remove(struct device *dev) | 86 | static int i2c_device_resume(struct device * dev) |
73 | { | 87 | { |
74 | return 0; | 88 | struct i2c_driver *driver; |
89 | |||
90 | if (!dev->driver) | ||
91 | return 0; | ||
92 | driver = to_i2c_driver(dev->driver); | ||
93 | if (!driver->resume) | ||
94 | return 0; | ||
95 | return driver->resume(to_i2c_client(dev)); | ||
75 | } | 96 | } |
76 | 97 | ||
77 | struct bus_type i2c_bus_type = { | 98 | struct bus_type i2c_bus_type = { |
78 | .name = "i2c", | 99 | .name = "i2c", |
79 | .match = i2c_device_match, | 100 | .match = i2c_device_match, |
80 | .probe = i2c_device_probe, | 101 | .probe = i2c_device_probe, |
81 | .remove = i2c_device_remove, | 102 | .remove = i2c_device_remove, |
82 | .suspend = i2c_bus_suspend, | 103 | .shutdown = i2c_device_shutdown, |
83 | .resume = i2c_bus_resume, | 104 | .suspend = i2c_device_suspend, |
105 | .resume = i2c_device_resume, | ||
84 | }; | 106 | }; |
85 | 107 | ||
108 | /* ------------------------------------------------------------------------- */ | ||
109 | |||
86 | void i2c_adapter_dev_release(struct device *dev) | 110 | void i2c_adapter_dev_release(struct device *dev) |
87 | { | 111 | { |
88 | struct i2c_adapter *adap = dev_to_i2c_adapter(dev); | 112 | struct i2c_adapter *adap = dev_to_i2c_adapter(dev); |
@@ -193,9 +217,8 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
193 | */ | 217 | */ |
194 | if (adap->dev.parent == NULL) { | 218 | if (adap->dev.parent == NULL) { |
195 | adap->dev.parent = &platform_bus; | 219 | adap->dev.parent = &platform_bus; |
196 | printk(KERN_WARNING "**WARNING** I2C adapter driver [%s] " | 220 | pr_debug("I2C adapter driver [%s] forgot to specify " |
197 | "forgot to specify physical device; fix it!\n", | 221 | "physical device\n", adap->name); |
198 | adap->name); | ||
199 | } | 222 | } |
200 | sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); | 223 | sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); |
201 | adap->dev.driver = &i2c_adapter_driver; | 224 | adap->dev.driver = &i2c_adapter_driver; |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 30a5780f4185..afb71c66b6f3 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | #include <asm/uaccess.h> | 27 | #include <asm/uaccess.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include <linux/sched.h> | ||
30 | #include <linux/proc_fs.h> | 29 | #include <linux/proc_fs.h> |
31 | #include <linux/stat.h> | 30 | #include <linux/stat.h> |
32 | #include <linux/mm.h> | 31 | #include <linux/mm.h> |
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 7efd28ac21ed..a5023cdbdc58 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/sched.h> | ||
38 | #include <linux/ptrace.h> | 37 | #include <linux/ptrace.h> |
39 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
40 | #include <linux/string.h> | 39 | #include <linux/string.h> |
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c index 0ac9da3a7378..82de2d781f2e 100644 --- a/drivers/ide/ppc/mpc8xx.c +++ b/drivers/ide/ppc/mpc8xx.c | |||
@@ -12,7 +12,6 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
17 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
18 | #include <linux/stddef.h> | 17 | #include <linux/stddef.h> |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 91c5344a945d..d8ea23710bf0 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -24,7 +24,6 @@ | |||
24 | */ | 24 | */ |
25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/sched.h> | ||
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
30 | #include <linux/ide.h> | 29 | #include <linux/ide.h> |
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index 97e5c3dd044d..a95313521985 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | #include <linux/module.h> | 44 | #include <linux/module.h> |
45 | 45 | ||
46 | #include <linux/sched.h> | ||
47 | #include <linux/kernel.h> | 46 | #include <linux/kernel.h> |
48 | #include <linux/slab.h> | 47 | #include <linux/slab.h> |
49 | #include <linux/errno.h> | 48 | #include <linux/errno.h> |
diff --git a/drivers/ieee1394/iso.c b/drivers/ieee1394/iso.c index 08bd15d2a7b6..c6227e51136d 100644 --- a/drivers/ieee1394/iso.c +++ b/drivers/ieee1394/iso.c | |||
@@ -10,7 +10,6 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
13 | #include <linux/sched.h> | ||
14 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
15 | 14 | ||
16 | #include "hosts.h" | 15 | #include "hosts.h" |
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 5729e412cc4a..e982d60ac4b7 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c | |||
@@ -102,7 +102,6 @@ | |||
102 | #include <asm/pgtable.h> | 102 | #include <asm/pgtable.h> |
103 | #include <asm/page.h> | 103 | #include <asm/page.h> |
104 | #include <asm/irq.h> | 104 | #include <asm/irq.h> |
105 | #include <linux/sched.h> | ||
106 | #include <linux/types.h> | 105 | #include <linux/types.h> |
107 | #include <linux/vmalloc.h> | 106 | #include <linux/vmalloc.h> |
108 | #include <linux/init.h> | 107 | #include <linux/init.h> |
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c index fbb7f14ec509..0742befe9227 100644 --- a/drivers/ieee1394/pcilynx.c +++ b/drivers/ieee1394/pcilynx.c | |||
@@ -1434,6 +1434,7 @@ static int __devinit add_card(struct pci_dev *dev, | |||
1434 | i2c_adapter_data = bit_data; | 1434 | i2c_adapter_data = bit_data; |
1435 | i2c_ad->algo_data = &i2c_adapter_data; | 1435 | i2c_ad->algo_data = &i2c_adapter_data; |
1436 | i2c_adapter_data.data = lynx; | 1436 | i2c_adapter_data.data = lynx; |
1437 | i2c_ad->dev.parent = &dev->dev; | ||
1437 | 1438 | ||
1438 | PRINTD(KERN_DEBUG, lynx->id,"original eeprom control: %d", | 1439 | PRINTD(KERN_DEBUG, lynx->id,"original eeprom control: %d", |
1439 | reg_read(lynx, SERIAL_EEPROM_CONTROL)); | 1440 | reg_read(lynx, SERIAL_EEPROM_CONTROL)); |
diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig index 9edfacee7d84..66b36de9fa6f 100644 --- a/drivers/infiniband/Kconfig +++ b/drivers/infiniband/Kconfig | |||
@@ -38,6 +38,7 @@ source "drivers/infiniband/hw/mthca/Kconfig" | |||
38 | source "drivers/infiniband/hw/ipath/Kconfig" | 38 | source "drivers/infiniband/hw/ipath/Kconfig" |
39 | source "drivers/infiniband/hw/ehca/Kconfig" | 39 | source "drivers/infiniband/hw/ehca/Kconfig" |
40 | source "drivers/infiniband/hw/amso1100/Kconfig" | 40 | source "drivers/infiniband/hw/amso1100/Kconfig" |
41 | source "drivers/infiniband/hw/cxgb3/Kconfig" | ||
41 | 42 | ||
42 | source "drivers/infiniband/ulp/ipoib/Kconfig" | 43 | source "drivers/infiniband/ulp/ipoib/Kconfig" |
43 | 44 | ||
diff --git a/drivers/infiniband/Makefile b/drivers/infiniband/Makefile index 2b5d1098ef45..da2066c4f22c 100644 --- a/drivers/infiniband/Makefile +++ b/drivers/infiniband/Makefile | |||
@@ -3,6 +3,7 @@ obj-$(CONFIG_INFINIBAND_MTHCA) += hw/mthca/ | |||
3 | obj-$(CONFIG_INFINIBAND_IPATH) += hw/ipath/ | 3 | obj-$(CONFIG_INFINIBAND_IPATH) += hw/ipath/ |
4 | obj-$(CONFIG_INFINIBAND_EHCA) += hw/ehca/ | 4 | obj-$(CONFIG_INFINIBAND_EHCA) += hw/ehca/ |
5 | obj-$(CONFIG_INFINIBAND_AMSO1100) += hw/amso1100/ | 5 | obj-$(CONFIG_INFINIBAND_AMSO1100) += hw/amso1100/ |
6 | obj-$(CONFIG_INFINIBAND_CXGB3) += hw/cxgb3/ | ||
6 | obj-$(CONFIG_INFINIBAND_IPOIB) += ulp/ipoib/ | 7 | obj-$(CONFIG_INFINIBAND_IPOIB) += ulp/ipoib/ |
7 | obj-$(CONFIG_INFINIBAND_SRP) += ulp/srp/ | 8 | obj-$(CONFIG_INFINIBAND_SRP) += ulp/srp/ |
8 | obj-$(CONFIG_INFINIBAND_ISER) += ulp/iser/ | 9 | obj-$(CONFIG_INFINIBAND_ISER) += ulp/iser/ |
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index d2bb5a9a303f..a91001c59b69 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c | |||
@@ -373,7 +373,7 @@ static struct notifier_block nb = { | |||
373 | 373 | ||
374 | static int addr_init(void) | 374 | static int addr_init(void) |
375 | { | 375 | { |
376 | addr_wq = create_singlethread_workqueue("ib_addr_wq"); | 376 | addr_wq = create_singlethread_workqueue("ib_addr"); |
377 | if (!addr_wq) | 377 | if (!addr_wq) |
378 | return -ENOMEM; | 378 | return -ENOMEM; |
379 | 379 | ||
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 98272fbbfb31..558c9a0fc8b9 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
39 | #include <linux/errno.h> | 39 | #include <linux/errno.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/sched.h> /* INIT_WORK, schedule_work(), flush_scheduled_work() */ | ||
42 | 41 | ||
43 | #include <rdma/ib_cache.h> | 42 | #include <rdma/ib_cache.h> |
44 | 43 | ||
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 9e0ab048c878..db88e609bf42 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -71,6 +71,7 @@ static struct workqueue_struct *cma_wq; | |||
71 | static DEFINE_IDR(sdp_ps); | 71 | static DEFINE_IDR(sdp_ps); |
72 | static DEFINE_IDR(tcp_ps); | 72 | static DEFINE_IDR(tcp_ps); |
73 | static DEFINE_IDR(udp_ps); | 73 | static DEFINE_IDR(udp_ps); |
74 | static int next_port; | ||
74 | 75 | ||
75 | struct cma_device { | 76 | struct cma_device { |
76 | struct list_head list; | 77 | struct list_head list; |
@@ -1722,33 +1723,74 @@ static int cma_alloc_port(struct idr *ps, struct rdma_id_private *id_priv, | |||
1722 | unsigned short snum) | 1723 | unsigned short snum) |
1723 | { | 1724 | { |
1724 | struct rdma_bind_list *bind_list; | 1725 | struct rdma_bind_list *bind_list; |
1725 | int port, start, ret; | 1726 | int port, ret; |
1726 | 1727 | ||
1727 | bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL); | 1728 | bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL); |
1728 | if (!bind_list) | 1729 | if (!bind_list) |
1729 | return -ENOMEM; | 1730 | return -ENOMEM; |
1730 | 1731 | ||
1731 | start = snum ? snum : sysctl_local_port_range[0]; | 1732 | do { |
1733 | ret = idr_get_new_above(ps, bind_list, snum, &port); | ||
1734 | } while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL)); | ||
1735 | |||
1736 | if (ret) | ||
1737 | goto err1; | ||
1738 | |||
1739 | if (port != snum) { | ||
1740 | ret = -EADDRNOTAVAIL; | ||
1741 | goto err2; | ||
1742 | } | ||
1743 | |||
1744 | bind_list->ps = ps; | ||
1745 | bind_list->port = (unsigned short) port; | ||
1746 | cma_bind_port(bind_list, id_priv); | ||
1747 | return 0; | ||
1748 | err2: | ||
1749 | idr_remove(ps, port); | ||
1750 | err1: | ||
1751 | kfree(bind_list); | ||
1752 | return ret; | ||
1753 | } | ||
1732 | 1754 | ||
1755 | static int cma_alloc_any_port(struct idr *ps, struct rdma_id_private *id_priv) | ||
1756 | { | ||
1757 | struct rdma_bind_list *bind_list; | ||
1758 | int port, ret; | ||
1759 | |||
1760 | bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL); | ||
1761 | if (!bind_list) | ||
1762 | return -ENOMEM; | ||
1763 | |||
1764 | retry: | ||
1733 | do { | 1765 | do { |
1734 | ret = idr_get_new_above(ps, bind_list, start, &port); | 1766 | ret = idr_get_new_above(ps, bind_list, next_port, &port); |
1735 | } while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL)); | 1767 | } while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL)); |
1736 | 1768 | ||
1737 | if (ret) | 1769 | if (ret) |
1738 | goto err; | 1770 | goto err1; |
1739 | 1771 | ||
1740 | if ((snum && port != snum) || | 1772 | if (port > sysctl_local_port_range[1]) { |
1741 | (!snum && port > sysctl_local_port_range[1])) { | 1773 | if (next_port != sysctl_local_port_range[0]) { |
1742 | idr_remove(ps, port); | 1774 | idr_remove(ps, port); |
1775 | next_port = sysctl_local_port_range[0]; | ||
1776 | goto retry; | ||
1777 | } | ||
1743 | ret = -EADDRNOTAVAIL; | 1778 | ret = -EADDRNOTAVAIL; |
1744 | goto err; | 1779 | goto err2; |
1745 | } | 1780 | } |
1746 | 1781 | ||
1782 | if (port == sysctl_local_port_range[1]) | ||
1783 | next_port = sysctl_local_port_range[0]; | ||
1784 | else | ||
1785 | next_port = port + 1; | ||
1786 | |||
1747 | bind_list->ps = ps; | 1787 | bind_list->ps = ps; |
1748 | bind_list->port = (unsigned short) port; | 1788 | bind_list->port = (unsigned short) port; |
1749 | cma_bind_port(bind_list, id_priv); | 1789 | cma_bind_port(bind_list, id_priv); |
1750 | return 0; | 1790 | return 0; |
1751 | err: | 1791 | err2: |
1792 | idr_remove(ps, port); | ||
1793 | err1: | ||
1752 | kfree(bind_list); | 1794 | kfree(bind_list); |
1753 | return ret; | 1795 | return ret; |
1754 | } | 1796 | } |
@@ -1811,7 +1853,7 @@ static int cma_get_port(struct rdma_id_private *id_priv) | |||
1811 | 1853 | ||
1812 | mutex_lock(&lock); | 1854 | mutex_lock(&lock); |
1813 | if (cma_any_port(&id_priv->id.route.addr.src_addr)) | 1855 | if (cma_any_port(&id_priv->id.route.addr.src_addr)) |
1814 | ret = cma_alloc_port(ps, id_priv, 0); | 1856 | ret = cma_alloc_any_port(ps, id_priv); |
1815 | else | 1857 | else |
1816 | ret = cma_use_port(ps, id_priv); | 1858 | ret = cma_use_port(ps, id_priv); |
1817 | mutex_unlock(&lock); | 1859 | mutex_unlock(&lock); |
@@ -2448,7 +2490,11 @@ static int cma_init(void) | |||
2448 | { | 2490 | { |
2449 | int ret; | 2491 | int ret; |
2450 | 2492 | ||
2451 | cma_wq = create_singlethread_workqueue("rdma_cm_wq"); | 2493 | get_random_bytes(&next_port, sizeof next_port); |
2494 | next_port = (next_port % (sysctl_local_port_range[1] - | ||
2495 | sysctl_local_port_range[0])) + | ||
2496 | sysctl_local_port_range[0]; | ||
2497 | cma_wq = create_singlethread_workqueue("rdma_cm"); | ||
2452 | if (!cma_wq) | 2498 | if (!cma_wq) |
2453 | return -ENOMEM; | 2499 | return -ENOMEM; |
2454 | 2500 | ||
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 63d2a39fb82c..7fabb425b033 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/module.h> | 36 | #include <linux/module.h> |
37 | #include <linux/string.h> | 37 | #include <linux/string.h> |
38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
39 | #include <linux/kernel.h> | ||
39 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
40 | #include <linux/init.h> | 41 | #include <linux/init.h> |
41 | #include <linux/mutex.h> | 42 | #include <linux/mutex.h> |
@@ -93,7 +94,7 @@ static int ib_device_check_mandatory(struct ib_device *device) | |||
93 | }; | 94 | }; |
94 | int i; | 95 | int i; |
95 | 96 | ||
96 | for (i = 0; i < sizeof mandatory_table / sizeof mandatory_table[0]; ++i) { | 97 | for (i = 0; i < ARRAY_SIZE(mandatory_table); ++i) { |
97 | if (!*(void **) ((void *) device + mandatory_table[i].offset)) { | 98 | if (!*(void **) ((void *) device + mandatory_table[i].offset)) { |
98 | printk(KERN_WARNING "Device %s is missing mandatory function %s\n", | 99 | printk(KERN_WARNING "Device %s is missing mandatory function %s\n", |
99 | device->name, mandatory_table[i].name); | 100 | device->name, mandatory_table[i].name); |
diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c index 27fe242ed435..59243d9aedd6 100644 --- a/drivers/infiniband/hw/amso1100/c2.c +++ b/drivers/infiniband/hw/amso1100/c2.c | |||
@@ -1073,7 +1073,7 @@ static int __devinit c2_probe(struct pci_dev *pcidev, | |||
1073 | 0xffffc000) / sizeof(struct c2_rxp_desc); | 1073 | 0xffffc000) / sizeof(struct c2_rxp_desc); |
1074 | 1074 | ||
1075 | /* Request an interrupt line for the driver */ | 1075 | /* Request an interrupt line for the driver */ |
1076 | ret = request_irq(pcidev->irq, c2_interrupt, SA_SHIRQ, DRV_NAME, c2dev); | 1076 | ret = request_irq(pcidev->irq, c2_interrupt, IRQF_SHARED, DRV_NAME, c2dev); |
1077 | if (ret) { | 1077 | if (ret) { |
1078 | printk(KERN_ERR PFX "%s: requested IRQ %u is busy\n", | 1078 | printk(KERN_ERR PFX "%s: requested IRQ %u is busy\n", |
1079 | pci_name(pcidev), pcidev->irq); | 1079 | pci_name(pcidev), pcidev->irq); |
diff --git a/drivers/infiniband/hw/cxgb3/Kconfig b/drivers/infiniband/hw/cxgb3/Kconfig new file mode 100644 index 000000000000..77977f55dca3 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/Kconfig | |||
@@ -0,0 +1,27 @@ | |||
1 | config INFINIBAND_CXGB3 | ||
2 | tristate "Chelsio RDMA Driver" | ||
3 | depends on CHELSIO_T3 && INFINIBAND && INET | ||
4 | select GENERIC_ALLOCATOR | ||
5 | ---help--- | ||
6 | This is an iWARP/RDMA driver for the Chelsio T3 1GbE and | ||
7 | 10GbE adapters. | ||
8 | |||
9 | For general information about Chelsio and our products, visit | ||
10 | our website at <http://www.chelsio.com>. | ||
11 | |||
12 | For customer support, please visit our customer support page at | ||
13 | <http://www.chelsio.com/support.htm>. | ||
14 | |||
15 | Please send feedback to <linux-bugs@chelsio.com>. | ||
16 | |||
17 | To compile this driver as a module, choose M here: the module | ||
18 | will be called iw_cxgb3. | ||
19 | |||
20 | config INFINIBAND_CXGB3_DEBUG | ||
21 | bool "Verbose debugging output" | ||
22 | depends on INFINIBAND_CXGB3 | ||
23 | default n | ||
24 | ---help--- | ||
25 | This option causes the Chelsio RDMA driver to produce copious | ||
26 | amounts of debug messages. Select this if you are developing | ||
27 | the driver or trying to diagnose a problem. | ||
diff --git a/drivers/infiniband/hw/cxgb3/Makefile b/drivers/infiniband/hw/cxgb3/Makefile new file mode 100644 index 000000000000..0e110f32f128 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/Makefile | |||
@@ -0,0 +1,12 @@ | |||
1 | EXTRA_CFLAGS += -I$(TOPDIR)/drivers/net/cxgb3 \ | ||
2 | -I$(TOPDIR)/drivers/infiniband/hw/cxgb3/core | ||
3 | |||
4 | obj-$(CONFIG_INFINIBAND_CXGB3) += iw_cxgb3.o | ||
5 | |||
6 | iw_cxgb3-y := iwch_cm.o iwch_ev.o iwch_cq.o iwch_qp.o iwch_mem.o \ | ||
7 | iwch_provider.o iwch.o cxio_hal.o cxio_resource.o | ||
8 | |||
9 | ifdef CONFIG_INFINIBAND_CXGB3_DEBUG | ||
10 | EXTRA_CFLAGS += -DDEBUG | ||
11 | iw_cxgb3-y += cxio_dbg.o | ||
12 | endif | ||
diff --git a/drivers/infiniband/hw/cxgb3/cxio_dbg.c b/drivers/infiniband/hw/cxgb3/cxio_dbg.c new file mode 100644 index 000000000000..5a7306f5efae --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/cxio_dbg.c | |||
@@ -0,0 +1,207 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #ifdef DEBUG | ||
34 | #include <linux/types.h> | ||
35 | #include "common.h" | ||
36 | #include "cxgb3_ioctl.h" | ||
37 | #include "cxio_hal.h" | ||
38 | #include "cxio_wr.h" | ||
39 | |||
40 | void cxio_dump_tpt(struct cxio_rdev *rdev, u32 stag) | ||
41 | { | ||
42 | struct ch_mem_range *m; | ||
43 | u64 *data; | ||
44 | int rc; | ||
45 | int size = 32; | ||
46 | |||
47 | m = kmalloc(sizeof(*m) + size, GFP_ATOMIC); | ||
48 | if (!m) { | ||
49 | PDBG("%s couldn't allocate memory.\n", __FUNCTION__); | ||
50 | return; | ||
51 | } | ||
52 | m->mem_id = MEM_PMRX; | ||
53 | m->addr = (stag>>8) * 32 + rdev->rnic_info.tpt_base; | ||
54 | m->len = size; | ||
55 | PDBG("%s TPT addr 0x%x len %d\n", __FUNCTION__, m->addr, m->len); | ||
56 | rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m); | ||
57 | if (rc) { | ||
58 | PDBG("%s toectl returned error %d\n", __FUNCTION__, rc); | ||
59 | kfree(m); | ||
60 | return; | ||
61 | } | ||
62 | |||
63 | data = (u64 *)m->buf; | ||
64 | while (size > 0) { | ||
65 | PDBG("TPT %08x: %016llx\n", m->addr, (unsigned long long) *data); | ||
66 | size -= 8; | ||
67 | data++; | ||
68 | m->addr += 8; | ||
69 | } | ||
70 | kfree(m); | ||
71 | } | ||
72 | |||
73 | void cxio_dump_pbl(struct cxio_rdev *rdev, u32 pbl_addr, uint len, u8 shift) | ||
74 | { | ||
75 | struct ch_mem_range *m; | ||
76 | u64 *data; | ||
77 | int rc; | ||
78 | int size, npages; | ||
79 | |||
80 | shift += 12; | ||
81 | npages = (len + (1ULL << shift) - 1) >> shift; | ||
82 | size = npages * sizeof(u64); | ||
83 | |||
84 | m = kmalloc(sizeof(*m) + size, GFP_ATOMIC); | ||
85 | if (!m) { | ||
86 | PDBG("%s couldn't allocate memory.\n", __FUNCTION__); | ||
87 | return; | ||
88 | } | ||
89 | m->mem_id = MEM_PMRX; | ||
90 | m->addr = pbl_addr; | ||
91 | m->len = size; | ||
92 | PDBG("%s PBL addr 0x%x len %d depth %d\n", | ||
93 | __FUNCTION__, m->addr, m->len, npages); | ||
94 | rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m); | ||
95 | if (rc) { | ||
96 | PDBG("%s toectl returned error %d\n", __FUNCTION__, rc); | ||
97 | kfree(m); | ||
98 | return; | ||
99 | } | ||
100 | |||
101 | data = (u64 *)m->buf; | ||
102 | while (size > 0) { | ||
103 | PDBG("PBL %08x: %016llx\n", m->addr, (unsigned long long) *data); | ||
104 | size -= 8; | ||
105 | data++; | ||
106 | m->addr += 8; | ||
107 | } | ||
108 | kfree(m); | ||
109 | } | ||
110 | |||
111 | void cxio_dump_wqe(union t3_wr *wqe) | ||
112 | { | ||
113 | __be64 *data = (__be64 *)wqe; | ||
114 | uint size = (uint)(be64_to_cpu(*data) & 0xff); | ||
115 | |||
116 | if (size == 0) | ||
117 | size = 8; | ||
118 | while (size > 0) { | ||
119 | PDBG("WQE %p: %016llx\n", data, | ||
120 | (unsigned long long) be64_to_cpu(*data)); | ||
121 | size--; | ||
122 | data++; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | void cxio_dump_wce(struct t3_cqe *wce) | ||
127 | { | ||
128 | __be64 *data = (__be64 *)wce; | ||
129 | int size = sizeof(*wce); | ||
130 | |||
131 | while (size > 0) { | ||
132 | PDBG("WCE %p: %016llx\n", data, | ||
133 | (unsigned long long) be64_to_cpu(*data)); | ||
134 | size -= 8; | ||
135 | data++; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | void cxio_dump_rqt(struct cxio_rdev *rdev, u32 hwtid, int nents) | ||
140 | { | ||
141 | struct ch_mem_range *m; | ||
142 | int size = nents * 64; | ||
143 | u64 *data; | ||
144 | int rc; | ||
145 | |||
146 | m = kmalloc(sizeof(*m) + size, GFP_ATOMIC); | ||
147 | if (!m) { | ||
148 | PDBG("%s couldn't allocate memory.\n", __FUNCTION__); | ||
149 | return; | ||
150 | } | ||
151 | m->mem_id = MEM_PMRX; | ||
152 | m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base; | ||
153 | m->len = size; | ||
154 | PDBG("%s RQT addr 0x%x len %d\n", __FUNCTION__, m->addr, m->len); | ||
155 | rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m); | ||
156 | if (rc) { | ||
157 | PDBG("%s toectl returned error %d\n", __FUNCTION__, rc); | ||
158 | kfree(m); | ||
159 | return; | ||
160 | } | ||
161 | |||
162 | data = (u64 *)m->buf; | ||
163 | while (size > 0) { | ||
164 | PDBG("RQT %08x: %016llx\n", m->addr, (unsigned long long) *data); | ||
165 | size -= 8; | ||
166 | data++; | ||
167 | m->addr += 8; | ||
168 | } | ||
169 | kfree(m); | ||
170 | } | ||
171 | |||
172 | void cxio_dump_tcb(struct cxio_rdev *rdev, u32 hwtid) | ||
173 | { | ||
174 | struct ch_mem_range *m; | ||
175 | int size = TCB_SIZE; | ||
176 | u32 *data; | ||
177 | int rc; | ||
178 | |||
179 | m = kmalloc(sizeof(*m) + size, GFP_ATOMIC); | ||
180 | if (!m) { | ||
181 | PDBG("%s couldn't allocate memory.\n", __FUNCTION__); | ||
182 | return; | ||
183 | } | ||
184 | m->mem_id = MEM_CM; | ||
185 | m->addr = hwtid * size; | ||
186 | m->len = size; | ||
187 | PDBG("%s TCB %d len %d\n", __FUNCTION__, m->addr, m->len); | ||
188 | rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m); | ||
189 | if (rc) { | ||
190 | PDBG("%s toectl returned error %d\n", __FUNCTION__, rc); | ||
191 | kfree(m); | ||
192 | return; | ||
193 | } | ||
194 | |||
195 | data = (u32 *)m->buf; | ||
196 | while (size > 0) { | ||
197 | printk("%2u: %08x %08x %08x %08x %08x %08x %08x %08x\n", | ||
198 | m->addr, | ||
199 | *(data+2), *(data+3), *(data),*(data+1), | ||
200 | *(data+6), *(data+7), *(data+4), *(data+5)); | ||
201 | size -= 32; | ||
202 | data += 8; | ||
203 | m->addr += 32; | ||
204 | } | ||
205 | kfree(m); | ||
206 | } | ||
207 | #endif | ||
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c new file mode 100644 index 000000000000..82fa72041989 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c | |||
@@ -0,0 +1,1280 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #include <asm/delay.h> | ||
34 | |||
35 | #include <linux/mutex.h> | ||
36 | #include <linux/netdevice.h> | ||
37 | #include <linux/sched.h> | ||
38 | #include <linux/spinlock.h> | ||
39 | #include <linux/pci.h> | ||
40 | |||
41 | #include "cxio_resource.h" | ||
42 | #include "cxio_hal.h" | ||
43 | #include "cxgb3_offload.h" | ||
44 | #include "sge_defs.h" | ||
45 | |||
46 | static LIST_HEAD(rdev_list); | ||
47 | static cxio_hal_ev_callback_func_t cxio_ev_cb = NULL; | ||
48 | |||
49 | static inline struct cxio_rdev *cxio_hal_find_rdev_by_name(char *dev_name) | ||
50 | { | ||
51 | struct cxio_rdev *rdev; | ||
52 | |||
53 | list_for_each_entry(rdev, &rdev_list, entry) | ||
54 | if (!strcmp(rdev->dev_name, dev_name)) | ||
55 | return rdev; | ||
56 | return NULL; | ||
57 | } | ||
58 | |||
59 | static inline struct cxio_rdev *cxio_hal_find_rdev_by_t3cdev(struct t3cdev | ||
60 | *tdev) | ||
61 | { | ||
62 | struct cxio_rdev *rdev; | ||
63 | |||
64 | list_for_each_entry(rdev, &rdev_list, entry) | ||
65 | if (rdev->t3cdev_p == tdev) | ||
66 | return rdev; | ||
67 | return NULL; | ||
68 | } | ||
69 | |||
70 | int cxio_hal_cq_op(struct cxio_rdev *rdev_p, struct t3_cq *cq, | ||
71 | enum t3_cq_opcode op, u32 credit) | ||
72 | { | ||
73 | int ret; | ||
74 | struct t3_cqe *cqe; | ||
75 | u32 rptr; | ||
76 | |||
77 | struct rdma_cq_op setup; | ||
78 | setup.id = cq->cqid; | ||
79 | setup.credits = (op == CQ_CREDIT_UPDATE) ? credit : 0; | ||
80 | setup.op = op; | ||
81 | ret = rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_CQ_OP, &setup); | ||
82 | |||
83 | if ((ret < 0) || (op == CQ_CREDIT_UPDATE)) | ||
84 | return ret; | ||
85 | |||
86 | /* | ||
87 | * If the rearm returned an index other than our current index, | ||
88 | * then there might be CQE's in flight (being DMA'd). We must wait | ||
89 | * here for them to complete or the consumer can miss a notification. | ||
90 | */ | ||
91 | if (Q_PTR2IDX((cq->rptr), cq->size_log2) != ret) { | ||
92 | int i=0; | ||
93 | |||
94 | rptr = cq->rptr; | ||
95 | |||
96 | /* | ||
97 | * Keep the generation correct by bumping rptr until it | ||
98 | * matches the index returned by the rearm - 1. | ||
99 | */ | ||
100 | while (Q_PTR2IDX((rptr+1), cq->size_log2) != ret) | ||
101 | rptr++; | ||
102 | |||
103 | /* | ||
104 | * Now rptr is the index for the (last) cqe that was | ||
105 | * in-flight at the time the HW rearmed the CQ. We | ||
106 | * spin until that CQE is valid. | ||
107 | */ | ||
108 | cqe = cq->queue + Q_PTR2IDX(rptr, cq->size_log2); | ||
109 | while (!CQ_VLD_ENTRY(rptr, cq->size_log2, cqe)) { | ||
110 | udelay(1); | ||
111 | if (i++ > 1000000) { | ||
112 | BUG_ON(1); | ||
113 | printk(KERN_ERR "%s: stalled rnic\n", | ||
114 | rdev_p->dev_name); | ||
115 | return -EIO; | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | static inline int cxio_hal_clear_cq_ctx(struct cxio_rdev *rdev_p, u32 cqid) | ||
123 | { | ||
124 | struct rdma_cq_setup setup; | ||
125 | setup.id = cqid; | ||
126 | setup.base_addr = 0; /* NULL address */ | ||
127 | setup.size = 0; /* disaable the CQ */ | ||
128 | setup.credits = 0; | ||
129 | setup.credit_thres = 0; | ||
130 | setup.ovfl_mode = 0; | ||
131 | return (rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_CQ_SETUP, &setup)); | ||
132 | } | ||
133 | |||
134 | int cxio_hal_clear_qp_ctx(struct cxio_rdev *rdev_p, u32 qpid) | ||
135 | { | ||
136 | u64 sge_cmd; | ||
137 | struct t3_modify_qp_wr *wqe; | ||
138 | struct sk_buff *skb = alloc_skb(sizeof(*wqe), GFP_KERNEL); | ||
139 | if (!skb) { | ||
140 | PDBG("%s alloc_skb failed\n", __FUNCTION__); | ||
141 | return -ENOMEM; | ||
142 | } | ||
143 | wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); | ||
144 | memset(wqe, 0, sizeof(*wqe)); | ||
145 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 3, 1, qpid, 7); | ||
146 | wqe->flags = cpu_to_be32(MODQP_WRITE_EC); | ||
147 | sge_cmd = qpid << 8 | 3; | ||
148 | wqe->sge_cmd = cpu_to_be64(sge_cmd); | ||
149 | skb->priority = CPL_PRIORITY_CONTROL; | ||
150 | return (cxgb3_ofld_send(rdev_p->t3cdev_p, skb)); | ||
151 | } | ||
152 | |||
153 | int cxio_create_cq(struct cxio_rdev *rdev_p, struct t3_cq *cq) | ||
154 | { | ||
155 | struct rdma_cq_setup setup; | ||
156 | int size = (1UL << (cq->size_log2)) * sizeof(struct t3_cqe); | ||
157 | |||
158 | cq->cqid = cxio_hal_get_cqid(rdev_p->rscp); | ||
159 | if (!cq->cqid) | ||
160 | return -ENOMEM; | ||
161 | cq->sw_queue = kzalloc(size, GFP_KERNEL); | ||
162 | if (!cq->sw_queue) | ||
163 | return -ENOMEM; | ||
164 | cq->queue = dma_alloc_coherent(&(rdev_p->rnic_info.pdev->dev), | ||
165 | (1UL << (cq->size_log2)) * | ||
166 | sizeof(struct t3_cqe), | ||
167 | &(cq->dma_addr), GFP_KERNEL); | ||
168 | if (!cq->queue) { | ||
169 | kfree(cq->sw_queue); | ||
170 | return -ENOMEM; | ||
171 | } | ||
172 | pci_unmap_addr_set(cq, mapping, cq->dma_addr); | ||
173 | memset(cq->queue, 0, size); | ||
174 | setup.id = cq->cqid; | ||
175 | setup.base_addr = (u64) (cq->dma_addr); | ||
176 | setup.size = 1UL << cq->size_log2; | ||
177 | setup.credits = 65535; | ||
178 | setup.credit_thres = 1; | ||
179 | if (rdev_p->t3cdev_p->type == T3B) | ||
180 | setup.ovfl_mode = 0; | ||
181 | else | ||
182 | setup.ovfl_mode = 1; | ||
183 | return (rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_CQ_SETUP, &setup)); | ||
184 | } | ||
185 | |||
186 | int cxio_resize_cq(struct cxio_rdev *rdev_p, struct t3_cq *cq) | ||
187 | { | ||
188 | struct rdma_cq_setup setup; | ||
189 | setup.id = cq->cqid; | ||
190 | setup.base_addr = (u64) (cq->dma_addr); | ||
191 | setup.size = 1UL << cq->size_log2; | ||
192 | setup.credits = setup.size; | ||
193 | setup.credit_thres = setup.size; /* TBD: overflow recovery */ | ||
194 | setup.ovfl_mode = 1; | ||
195 | return (rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_CQ_SETUP, &setup)); | ||
196 | } | ||
197 | |||
198 | static u32 get_qpid(struct cxio_rdev *rdev_p, struct cxio_ucontext *uctx) | ||
199 | { | ||
200 | struct cxio_qpid_list *entry; | ||
201 | u32 qpid; | ||
202 | int i; | ||
203 | |||
204 | mutex_lock(&uctx->lock); | ||
205 | if (!list_empty(&uctx->qpids)) { | ||
206 | entry = list_entry(uctx->qpids.next, struct cxio_qpid_list, | ||
207 | entry); | ||
208 | list_del(&entry->entry); | ||
209 | qpid = entry->qpid; | ||
210 | kfree(entry); | ||
211 | } else { | ||
212 | qpid = cxio_hal_get_qpid(rdev_p->rscp); | ||
213 | if (!qpid) | ||
214 | goto out; | ||
215 | for (i = qpid+1; i & rdev_p->qpmask; i++) { | ||
216 | entry = kmalloc(sizeof *entry, GFP_KERNEL); | ||
217 | if (!entry) | ||
218 | break; | ||
219 | entry->qpid = i; | ||
220 | list_add_tail(&entry->entry, &uctx->qpids); | ||
221 | } | ||
222 | } | ||
223 | out: | ||
224 | mutex_unlock(&uctx->lock); | ||
225 | PDBG("%s qpid 0x%x\n", __FUNCTION__, qpid); | ||
226 | return qpid; | ||
227 | } | ||
228 | |||
229 | static void put_qpid(struct cxio_rdev *rdev_p, u32 qpid, | ||
230 | struct cxio_ucontext *uctx) | ||
231 | { | ||
232 | struct cxio_qpid_list *entry; | ||
233 | |||
234 | entry = kmalloc(sizeof *entry, GFP_KERNEL); | ||
235 | if (!entry) | ||
236 | return; | ||
237 | PDBG("%s qpid 0x%x\n", __FUNCTION__, qpid); | ||
238 | entry->qpid = qpid; | ||
239 | mutex_lock(&uctx->lock); | ||
240 | list_add_tail(&entry->entry, &uctx->qpids); | ||
241 | mutex_unlock(&uctx->lock); | ||
242 | } | ||
243 | |||
244 | void cxio_release_ucontext(struct cxio_rdev *rdev_p, struct cxio_ucontext *uctx) | ||
245 | { | ||
246 | struct list_head *pos, *nxt; | ||
247 | struct cxio_qpid_list *entry; | ||
248 | |||
249 | mutex_lock(&uctx->lock); | ||
250 | list_for_each_safe(pos, nxt, &uctx->qpids) { | ||
251 | entry = list_entry(pos, struct cxio_qpid_list, entry); | ||
252 | list_del_init(&entry->entry); | ||
253 | if (!(entry->qpid & rdev_p->qpmask)) | ||
254 | cxio_hal_put_qpid(rdev_p->rscp, entry->qpid); | ||
255 | kfree(entry); | ||
256 | } | ||
257 | mutex_unlock(&uctx->lock); | ||
258 | } | ||
259 | |||
260 | void cxio_init_ucontext(struct cxio_rdev *rdev_p, struct cxio_ucontext *uctx) | ||
261 | { | ||
262 | INIT_LIST_HEAD(&uctx->qpids); | ||
263 | mutex_init(&uctx->lock); | ||
264 | } | ||
265 | |||
266 | int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain, | ||
267 | struct t3_wq *wq, struct cxio_ucontext *uctx) | ||
268 | { | ||
269 | int depth = 1UL << wq->size_log2; | ||
270 | int rqsize = 1UL << wq->rq_size_log2; | ||
271 | |||
272 | wq->qpid = get_qpid(rdev_p, uctx); | ||
273 | if (!wq->qpid) | ||
274 | return -ENOMEM; | ||
275 | |||
276 | wq->rq = kzalloc(depth * sizeof(u64), GFP_KERNEL); | ||
277 | if (!wq->rq) | ||
278 | goto err1; | ||
279 | |||
280 | wq->rq_addr = cxio_hal_rqtpool_alloc(rdev_p, rqsize); | ||
281 | if (!wq->rq_addr) | ||
282 | goto err2; | ||
283 | |||
284 | wq->sq = kzalloc(depth * sizeof(struct t3_swsq), GFP_KERNEL); | ||
285 | if (!wq->sq) | ||
286 | goto err3; | ||
287 | |||
288 | wq->queue = dma_alloc_coherent(&(rdev_p->rnic_info.pdev->dev), | ||
289 | depth * sizeof(union t3_wr), | ||
290 | &(wq->dma_addr), GFP_KERNEL); | ||
291 | if (!wq->queue) | ||
292 | goto err4; | ||
293 | |||
294 | memset(wq->queue, 0, depth * sizeof(union t3_wr)); | ||
295 | pci_unmap_addr_set(wq, mapping, wq->dma_addr); | ||
296 | wq->doorbell = (void __iomem *)rdev_p->rnic_info.kdb_addr; | ||
297 | if (!kernel_domain) | ||
298 | wq->udb = (u64)rdev_p->rnic_info.udbell_physbase + | ||
299 | (wq->qpid << rdev_p->qpshift); | ||
300 | PDBG("%s qpid 0x%x doorbell 0x%p udb 0x%llx\n", __FUNCTION__, | ||
301 | wq->qpid, wq->doorbell, (unsigned long long) wq->udb); | ||
302 | return 0; | ||
303 | err4: | ||
304 | kfree(wq->sq); | ||
305 | err3: | ||
306 | cxio_hal_rqtpool_free(rdev_p, wq->rq_addr, rqsize); | ||
307 | err2: | ||
308 | kfree(wq->rq); | ||
309 | err1: | ||
310 | put_qpid(rdev_p, wq->qpid, uctx); | ||
311 | return -ENOMEM; | ||
312 | } | ||
313 | |||
314 | int cxio_destroy_cq(struct cxio_rdev *rdev_p, struct t3_cq *cq) | ||
315 | { | ||
316 | int err; | ||
317 | err = cxio_hal_clear_cq_ctx(rdev_p, cq->cqid); | ||
318 | kfree(cq->sw_queue); | ||
319 | dma_free_coherent(&(rdev_p->rnic_info.pdev->dev), | ||
320 | (1UL << (cq->size_log2)) | ||
321 | * sizeof(struct t3_cqe), cq->queue, | ||
322 | pci_unmap_addr(cq, mapping)); | ||
323 | cxio_hal_put_cqid(rdev_p->rscp, cq->cqid); | ||
324 | return err; | ||
325 | } | ||
326 | |||
327 | int cxio_destroy_qp(struct cxio_rdev *rdev_p, struct t3_wq *wq, | ||
328 | struct cxio_ucontext *uctx) | ||
329 | { | ||
330 | dma_free_coherent(&(rdev_p->rnic_info.pdev->dev), | ||
331 | (1UL << (wq->size_log2)) | ||
332 | * sizeof(union t3_wr), wq->queue, | ||
333 | pci_unmap_addr(wq, mapping)); | ||
334 | kfree(wq->sq); | ||
335 | cxio_hal_rqtpool_free(rdev_p, wq->rq_addr, (1UL << wq->rq_size_log2)); | ||
336 | kfree(wq->rq); | ||
337 | put_qpid(rdev_p, wq->qpid, uctx); | ||
338 | return 0; | ||
339 | } | ||
340 | |||
341 | static void insert_recv_cqe(struct t3_wq *wq, struct t3_cq *cq) | ||
342 | { | ||
343 | struct t3_cqe cqe; | ||
344 | |||
345 | PDBG("%s wq %p cq %p sw_rptr 0x%x sw_wptr 0x%x\n", __FUNCTION__, | ||
346 | wq, cq, cq->sw_rptr, cq->sw_wptr); | ||
347 | memset(&cqe, 0, sizeof(cqe)); | ||
348 | cqe.header = cpu_to_be32(V_CQE_STATUS(TPT_ERR_SWFLUSH) | | ||
349 | V_CQE_OPCODE(T3_SEND) | | ||
350 | V_CQE_TYPE(0) | | ||
351 | V_CQE_SWCQE(1) | | ||
352 | V_CQE_QPID(wq->qpid) | | ||
353 | V_CQE_GENBIT(Q_GENBIT(cq->sw_wptr, | ||
354 | cq->size_log2))); | ||
355 | *(cq->sw_queue + Q_PTR2IDX(cq->sw_wptr, cq->size_log2)) = cqe; | ||
356 | cq->sw_wptr++; | ||
357 | } | ||
358 | |||
359 | void cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count) | ||
360 | { | ||
361 | u32 ptr; | ||
362 | |||
363 | PDBG("%s wq %p cq %p\n", __FUNCTION__, wq, cq); | ||
364 | |||
365 | /* flush RQ */ | ||
366 | PDBG("%s rq_rptr %u rq_wptr %u skip count %u\n", __FUNCTION__, | ||
367 | wq->rq_rptr, wq->rq_wptr, count); | ||
368 | ptr = wq->rq_rptr + count; | ||
369 | while (ptr++ != wq->rq_wptr) | ||
370 | insert_recv_cqe(wq, cq); | ||
371 | } | ||
372 | |||
373 | static void insert_sq_cqe(struct t3_wq *wq, struct t3_cq *cq, | ||
374 | struct t3_swsq *sqp) | ||
375 | { | ||
376 | struct t3_cqe cqe; | ||
377 | |||
378 | PDBG("%s wq %p cq %p sw_rptr 0x%x sw_wptr 0x%x\n", __FUNCTION__, | ||
379 | wq, cq, cq->sw_rptr, cq->sw_wptr); | ||
380 | memset(&cqe, 0, sizeof(cqe)); | ||
381 | cqe.header = cpu_to_be32(V_CQE_STATUS(TPT_ERR_SWFLUSH) | | ||
382 | V_CQE_OPCODE(sqp->opcode) | | ||
383 | V_CQE_TYPE(1) | | ||
384 | V_CQE_SWCQE(1) | | ||
385 | V_CQE_QPID(wq->qpid) | | ||
386 | V_CQE_GENBIT(Q_GENBIT(cq->sw_wptr, | ||
387 | cq->size_log2))); | ||
388 | cqe.u.scqe.wrid_hi = sqp->sq_wptr; | ||
389 | |||
390 | *(cq->sw_queue + Q_PTR2IDX(cq->sw_wptr, cq->size_log2)) = cqe; | ||
391 | cq->sw_wptr++; | ||
392 | } | ||
393 | |||
394 | void cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count) | ||
395 | { | ||
396 | __u32 ptr; | ||
397 | struct t3_swsq *sqp = wq->sq + Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2); | ||
398 | |||
399 | ptr = wq->sq_rptr + count; | ||
400 | sqp += count; | ||
401 | while (ptr != wq->sq_wptr) { | ||
402 | insert_sq_cqe(wq, cq, sqp); | ||
403 | sqp++; | ||
404 | ptr++; | ||
405 | } | ||
406 | } | ||
407 | |||
408 | /* | ||
409 | * Move all CQEs from the HWCQ into the SWCQ. | ||
410 | */ | ||
411 | void cxio_flush_hw_cq(struct t3_cq *cq) | ||
412 | { | ||
413 | struct t3_cqe *cqe, *swcqe; | ||
414 | |||
415 | PDBG("%s cq %p cqid 0x%x\n", __FUNCTION__, cq, cq->cqid); | ||
416 | cqe = cxio_next_hw_cqe(cq); | ||
417 | while (cqe) { | ||
418 | PDBG("%s flushing hwcq rptr 0x%x to swcq wptr 0x%x\n", | ||
419 | __FUNCTION__, cq->rptr, cq->sw_wptr); | ||
420 | swcqe = cq->sw_queue + Q_PTR2IDX(cq->sw_wptr, cq->size_log2); | ||
421 | *swcqe = *cqe; | ||
422 | swcqe->header |= cpu_to_be32(V_CQE_SWCQE(1)); | ||
423 | cq->sw_wptr++; | ||
424 | cq->rptr++; | ||
425 | cqe = cxio_next_hw_cqe(cq); | ||
426 | } | ||
427 | } | ||
428 | |||
429 | static inline int cqe_completes_wr(struct t3_cqe *cqe, struct t3_wq *wq) | ||
430 | { | ||
431 | if (CQE_OPCODE(*cqe) == T3_TERMINATE) | ||
432 | return 0; | ||
433 | |||
434 | if ((CQE_OPCODE(*cqe) == T3_RDMA_WRITE) && RQ_TYPE(*cqe)) | ||
435 | return 0; | ||
436 | |||
437 | if ((CQE_OPCODE(*cqe) == T3_READ_RESP) && SQ_TYPE(*cqe)) | ||
438 | return 0; | ||
439 | |||
440 | if ((CQE_OPCODE(*cqe) == T3_SEND) && RQ_TYPE(*cqe) && | ||
441 | Q_EMPTY(wq->rq_rptr, wq->rq_wptr)) | ||
442 | return 0; | ||
443 | |||
444 | return 1; | ||
445 | } | ||
446 | |||
447 | void cxio_count_scqes(struct t3_cq *cq, struct t3_wq *wq, int *count) | ||
448 | { | ||
449 | struct t3_cqe *cqe; | ||
450 | u32 ptr; | ||
451 | |||
452 | *count = 0; | ||
453 | ptr = cq->sw_rptr; | ||
454 | while (!Q_EMPTY(ptr, cq->sw_wptr)) { | ||
455 | cqe = cq->sw_queue + (Q_PTR2IDX(ptr, cq->size_log2)); | ||
456 | if ((SQ_TYPE(*cqe) || (CQE_OPCODE(*cqe) == T3_READ_RESP)) && | ||
457 | (CQE_QPID(*cqe) == wq->qpid)) | ||
458 | (*count)++; | ||
459 | ptr++; | ||
460 | } | ||
461 | PDBG("%s cq %p count %d\n", __FUNCTION__, cq, *count); | ||
462 | } | ||
463 | |||
464 | void cxio_count_rcqes(struct t3_cq *cq, struct t3_wq *wq, int *count) | ||
465 | { | ||
466 | struct t3_cqe *cqe; | ||
467 | u32 ptr; | ||
468 | |||
469 | *count = 0; | ||
470 | PDBG("%s count zero %d\n", __FUNCTION__, *count); | ||
471 | ptr = cq->sw_rptr; | ||
472 | while (!Q_EMPTY(ptr, cq->sw_wptr)) { | ||
473 | cqe = cq->sw_queue + (Q_PTR2IDX(ptr, cq->size_log2)); | ||
474 | if (RQ_TYPE(*cqe) && (CQE_OPCODE(*cqe) != T3_READ_RESP) && | ||
475 | (CQE_QPID(*cqe) == wq->qpid) && cqe_completes_wr(cqe, wq)) | ||
476 | (*count)++; | ||
477 | ptr++; | ||
478 | } | ||
479 | PDBG("%s cq %p count %d\n", __FUNCTION__, cq, *count); | ||
480 | } | ||
481 | |||
482 | static int cxio_hal_init_ctrl_cq(struct cxio_rdev *rdev_p) | ||
483 | { | ||
484 | struct rdma_cq_setup setup; | ||
485 | setup.id = 0; | ||
486 | setup.base_addr = 0; /* NULL address */ | ||
487 | setup.size = 1; /* enable the CQ */ | ||
488 | setup.credits = 0; | ||
489 | |||
490 | /* force SGE to redirect to RspQ and interrupt */ | ||
491 | setup.credit_thres = 0; | ||
492 | setup.ovfl_mode = 1; | ||
493 | return (rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_CQ_SETUP, &setup)); | ||
494 | } | ||
495 | |||
496 | static int cxio_hal_init_ctrl_qp(struct cxio_rdev *rdev_p) | ||
497 | { | ||
498 | int err; | ||
499 | u64 sge_cmd, ctx0, ctx1; | ||
500 | u64 base_addr; | ||
501 | struct t3_modify_qp_wr *wqe; | ||
502 | struct sk_buff *skb = alloc_skb(sizeof(*wqe), GFP_KERNEL); | ||
503 | |||
504 | |||
505 | if (!skb) { | ||
506 | PDBG("%s alloc_skb failed\n", __FUNCTION__); | ||
507 | return -ENOMEM; | ||
508 | } | ||
509 | err = cxio_hal_init_ctrl_cq(rdev_p); | ||
510 | if (err) { | ||
511 | PDBG("%s err %d initializing ctrl_cq\n", __FUNCTION__, err); | ||
512 | return err; | ||
513 | } | ||
514 | rdev_p->ctrl_qp.workq = dma_alloc_coherent( | ||
515 | &(rdev_p->rnic_info.pdev->dev), | ||
516 | (1 << T3_CTRL_QP_SIZE_LOG2) * | ||
517 | sizeof(union t3_wr), | ||
518 | &(rdev_p->ctrl_qp.dma_addr), | ||
519 | GFP_KERNEL); | ||
520 | if (!rdev_p->ctrl_qp.workq) { | ||
521 | PDBG("%s dma_alloc_coherent failed\n", __FUNCTION__); | ||
522 | return -ENOMEM; | ||
523 | } | ||
524 | pci_unmap_addr_set(&rdev_p->ctrl_qp, mapping, | ||
525 | rdev_p->ctrl_qp.dma_addr); | ||
526 | rdev_p->ctrl_qp.doorbell = (void __iomem *)rdev_p->rnic_info.kdb_addr; | ||
527 | memset(rdev_p->ctrl_qp.workq, 0, | ||
528 | (1 << T3_CTRL_QP_SIZE_LOG2) * sizeof(union t3_wr)); | ||
529 | |||
530 | mutex_init(&rdev_p->ctrl_qp.lock); | ||
531 | init_waitqueue_head(&rdev_p->ctrl_qp.waitq); | ||
532 | |||
533 | /* update HW Ctrl QP context */ | ||
534 | base_addr = rdev_p->ctrl_qp.dma_addr; | ||
535 | base_addr >>= 12; | ||
536 | ctx0 = (V_EC_SIZE((1 << T3_CTRL_QP_SIZE_LOG2)) | | ||
537 | V_EC_BASE_LO((u32) base_addr & 0xffff)); | ||
538 | ctx0 <<= 32; | ||
539 | ctx0 |= V_EC_CREDITS(FW_WR_NUM); | ||
540 | base_addr >>= 16; | ||
541 | ctx1 = (u32) base_addr; | ||
542 | base_addr >>= 32; | ||
543 | ctx1 |= ((u64) (V_EC_BASE_HI((u32) base_addr & 0xf) | V_EC_RESPQ(0) | | ||
544 | V_EC_TYPE(0) | V_EC_GEN(1) | | ||
545 | V_EC_UP_TOKEN(T3_CTL_QP_TID) | F_EC_VALID)) << 32; | ||
546 | wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); | ||
547 | memset(wqe, 0, sizeof(*wqe)); | ||
548 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 1, | ||
549 | T3_CTL_QP_TID, 7); | ||
550 | wqe->flags = cpu_to_be32(MODQP_WRITE_EC); | ||
551 | sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3; | ||
552 | wqe->sge_cmd = cpu_to_be64(sge_cmd); | ||
553 | wqe->ctx1 = cpu_to_be64(ctx1); | ||
554 | wqe->ctx0 = cpu_to_be64(ctx0); | ||
555 | PDBG("CtrlQP dma_addr 0x%llx workq %p size %d\n", | ||
556 | (unsigned long long) rdev_p->ctrl_qp.dma_addr, | ||
557 | rdev_p->ctrl_qp.workq, 1 << T3_CTRL_QP_SIZE_LOG2); | ||
558 | skb->priority = CPL_PRIORITY_CONTROL; | ||
559 | return (cxgb3_ofld_send(rdev_p->t3cdev_p, skb)); | ||
560 | } | ||
561 | |||
562 | static int cxio_hal_destroy_ctrl_qp(struct cxio_rdev *rdev_p) | ||
563 | { | ||
564 | dma_free_coherent(&(rdev_p->rnic_info.pdev->dev), | ||
565 | (1UL << T3_CTRL_QP_SIZE_LOG2) | ||
566 | * sizeof(union t3_wr), rdev_p->ctrl_qp.workq, | ||
567 | pci_unmap_addr(&rdev_p->ctrl_qp, mapping)); | ||
568 | return cxio_hal_clear_qp_ctx(rdev_p, T3_CTRL_QP_ID); | ||
569 | } | ||
570 | |||
571 | /* write len bytes of data into addr (32B aligned address) | ||
572 | * If data is NULL, clear len byte of memory to zero. | ||
573 | * caller aquires the ctrl_qp lock before the call | ||
574 | */ | ||
575 | static int cxio_hal_ctrl_qp_write_mem(struct cxio_rdev *rdev_p, u32 addr, | ||
576 | u32 len, void *data, int completion) | ||
577 | { | ||
578 | u32 i, nr_wqe, copy_len; | ||
579 | u8 *copy_data; | ||
580 | u8 wr_len, utx_len; /* lenght in 8 byte flit */ | ||
581 | enum t3_wr_flags flag; | ||
582 | __be64 *wqe; | ||
583 | u64 utx_cmd; | ||
584 | addr &= 0x7FFFFFF; | ||
585 | nr_wqe = len % 96 ? len / 96 + 1 : len / 96; /* 96B max per WQE */ | ||
586 | PDBG("%s wptr 0x%x rptr 0x%x len %d, nr_wqe %d data %p addr 0x%0x\n", | ||
587 | __FUNCTION__, rdev_p->ctrl_qp.wptr, rdev_p->ctrl_qp.rptr, len, | ||
588 | nr_wqe, data, addr); | ||
589 | utx_len = 3; /* in 32B unit */ | ||
590 | for (i = 0; i < nr_wqe; i++) { | ||
591 | if (Q_FULL(rdev_p->ctrl_qp.rptr, rdev_p->ctrl_qp.wptr, | ||
592 | T3_CTRL_QP_SIZE_LOG2)) { | ||
593 | PDBG("%s ctrl_qp full wtpr 0x%0x rptr 0x%0x, " | ||
594 | "wait for more space i %d\n", __FUNCTION__, | ||
595 | rdev_p->ctrl_qp.wptr, rdev_p->ctrl_qp.rptr, i); | ||
596 | if (wait_event_interruptible(rdev_p->ctrl_qp.waitq, | ||
597 | !Q_FULL(rdev_p->ctrl_qp.rptr, | ||
598 | rdev_p->ctrl_qp.wptr, | ||
599 | T3_CTRL_QP_SIZE_LOG2))) { | ||
600 | PDBG("%s ctrl_qp workq interrupted\n", | ||
601 | __FUNCTION__); | ||
602 | return -ERESTARTSYS; | ||
603 | } | ||
604 | PDBG("%s ctrl_qp wakeup, continue posting work request " | ||
605 | "i %d\n", __FUNCTION__, i); | ||
606 | } | ||
607 | wqe = (__be64 *)(rdev_p->ctrl_qp.workq + (rdev_p->ctrl_qp.wptr % | ||
608 | (1 << T3_CTRL_QP_SIZE_LOG2))); | ||
609 | flag = 0; | ||
610 | if (i == (nr_wqe - 1)) { | ||
611 | /* last WQE */ | ||
612 | flag = completion ? T3_COMPLETION_FLAG : 0; | ||
613 | if (len % 32) | ||
614 | utx_len = len / 32 + 1; | ||
615 | else | ||
616 | utx_len = len / 32; | ||
617 | } | ||
618 | |||
619 | /* | ||
620 | * Force a CQE to return the credit to the workq in case | ||
621 | * we posted more than half the max QP size of WRs | ||
622 | */ | ||
623 | if ((i != 0) && | ||
624 | (i % (((1 << T3_CTRL_QP_SIZE_LOG2)) >> 1) == 0)) { | ||
625 | flag = T3_COMPLETION_FLAG; | ||
626 | PDBG("%s force completion at i %d\n", __FUNCTION__, i); | ||
627 | } | ||
628 | |||
629 | /* build the utx mem command */ | ||
630 | wqe += (sizeof(struct t3_bypass_wr) >> 3); | ||
631 | utx_cmd = (T3_UTX_MEM_WRITE << 28) | (addr + i * 3); | ||
632 | utx_cmd <<= 32; | ||
633 | utx_cmd |= (utx_len << 28) | ((utx_len << 2) + 1); | ||
634 | *wqe = cpu_to_be64(utx_cmd); | ||
635 | wqe++; | ||
636 | copy_data = (u8 *) data + i * 96; | ||
637 | copy_len = len > 96 ? 96 : len; | ||
638 | |||
639 | /* clear memory content if data is NULL */ | ||
640 | if (data) | ||
641 | memcpy(wqe, copy_data, copy_len); | ||
642 | else | ||
643 | memset(wqe, 0, copy_len); | ||
644 | if (copy_len % 32) | ||
645 | memset(((u8 *) wqe) + copy_len, 0, | ||
646 | 32 - (copy_len % 32)); | ||
647 | wr_len = ((sizeof(struct t3_bypass_wr)) >> 3) + 1 + | ||
648 | (utx_len << 2); | ||
649 | wqe = (__be64 *)(rdev_p->ctrl_qp.workq + (rdev_p->ctrl_qp.wptr % | ||
650 | (1 << T3_CTRL_QP_SIZE_LOG2))); | ||
651 | |||
652 | /* wptr in the WRID[31:0] */ | ||
653 | ((union t3_wrid *)(wqe+1))->id0.low = rdev_p->ctrl_qp.wptr; | ||
654 | |||
655 | /* | ||
656 | * This must be the last write with a memory barrier | ||
657 | * for the genbit | ||
658 | */ | ||
659 | build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_BP, flag, | ||
660 | Q_GENBIT(rdev_p->ctrl_qp.wptr, | ||
661 | T3_CTRL_QP_SIZE_LOG2), T3_CTRL_QP_ID, | ||
662 | wr_len); | ||
663 | if (flag == T3_COMPLETION_FLAG) | ||
664 | ring_doorbell(rdev_p->ctrl_qp.doorbell, T3_CTRL_QP_ID); | ||
665 | len -= 96; | ||
666 | rdev_p->ctrl_qp.wptr++; | ||
667 | } | ||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | /* IN: stag key, pdid, perm, zbva, to, len, page_size, pbl, and pbl_size | ||
672 | * OUT: stag index, actual pbl_size, pbl_addr allocated. | ||
673 | * TBD: shared memory region support | ||
674 | */ | ||
675 | static int __cxio_tpt_op(struct cxio_rdev *rdev_p, u32 reset_tpt_entry, | ||
676 | u32 *stag, u8 stag_state, u32 pdid, | ||
677 | enum tpt_mem_type type, enum tpt_mem_perm perm, | ||
678 | u32 zbva, u64 to, u32 len, u8 page_size, __be64 *pbl, | ||
679 | u32 *pbl_size, u32 *pbl_addr) | ||
680 | { | ||
681 | int err; | ||
682 | struct tpt_entry tpt; | ||
683 | u32 stag_idx; | ||
684 | u32 wptr; | ||
685 | int rereg = (*stag != T3_STAG_UNSET); | ||
686 | |||
687 | stag_state = stag_state > 0; | ||
688 | stag_idx = (*stag) >> 8; | ||
689 | |||
690 | if ((!reset_tpt_entry) && !(*stag != T3_STAG_UNSET)) { | ||
691 | stag_idx = cxio_hal_get_stag(rdev_p->rscp); | ||
692 | if (!stag_idx) | ||
693 | return -ENOMEM; | ||
694 | *stag = (stag_idx << 8) | ((*stag) & 0xFF); | ||
695 | } | ||
696 | PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n", | ||
697 | __FUNCTION__, stag_state, type, pdid, stag_idx); | ||
698 | |||
699 | if (reset_tpt_entry) | ||
700 | cxio_hal_pblpool_free(rdev_p, *pbl_addr, *pbl_size << 3); | ||
701 | else if (!rereg) { | ||
702 | *pbl_addr = cxio_hal_pblpool_alloc(rdev_p, *pbl_size << 3); | ||
703 | if (!*pbl_addr) { | ||
704 | return -ENOMEM; | ||
705 | } | ||
706 | } | ||
707 | |||
708 | mutex_lock(&rdev_p->ctrl_qp.lock); | ||
709 | |||
710 | /* write PBL first if any - update pbl only if pbl list exist */ | ||
711 | if (pbl) { | ||
712 | |||
713 | PDBG("%s *pdb_addr 0x%x, pbl_base 0x%x, pbl_size %d\n", | ||
714 | __FUNCTION__, *pbl_addr, rdev_p->rnic_info.pbl_base, | ||
715 | *pbl_size); | ||
716 | err = cxio_hal_ctrl_qp_write_mem(rdev_p, | ||
717 | (*pbl_addr >> 5), | ||
718 | (*pbl_size << 3), pbl, 0); | ||
719 | if (err) | ||
720 | goto ret; | ||
721 | } | ||
722 | |||
723 | /* write TPT entry */ | ||
724 | if (reset_tpt_entry) | ||
725 | memset(&tpt, 0, sizeof(tpt)); | ||
726 | else { | ||
727 | tpt.valid_stag_pdid = cpu_to_be32(F_TPT_VALID | | ||
728 | V_TPT_STAG_KEY((*stag) & M_TPT_STAG_KEY) | | ||
729 | V_TPT_STAG_STATE(stag_state) | | ||
730 | V_TPT_STAG_TYPE(type) | V_TPT_PDID(pdid)); | ||
731 | BUG_ON(page_size >= 28); | ||
732 | tpt.flags_pagesize_qpid = cpu_to_be32(V_TPT_PERM(perm) | | ||
733 | F_TPT_MW_BIND_ENABLE | | ||
734 | V_TPT_ADDR_TYPE((zbva ? TPT_ZBTO : TPT_VATO)) | | ||
735 | V_TPT_PAGE_SIZE(page_size)); | ||
736 | tpt.rsvd_pbl_addr = reset_tpt_entry ? 0 : | ||
737 | cpu_to_be32(V_TPT_PBL_ADDR(PBL_OFF(rdev_p, *pbl_addr)>>3)); | ||
738 | tpt.len = cpu_to_be32(len); | ||
739 | tpt.va_hi = cpu_to_be32((u32) (to >> 32)); | ||
740 | tpt.va_low_or_fbo = cpu_to_be32((u32) (to & 0xFFFFFFFFULL)); | ||
741 | tpt.rsvd_bind_cnt_or_pstag = 0; | ||
742 | tpt.rsvd_pbl_size = reset_tpt_entry ? 0 : | ||
743 | cpu_to_be32(V_TPT_PBL_SIZE((*pbl_size) >> 2)); | ||
744 | } | ||
745 | err = cxio_hal_ctrl_qp_write_mem(rdev_p, | ||
746 | stag_idx + | ||
747 | (rdev_p->rnic_info.tpt_base >> 5), | ||
748 | sizeof(tpt), &tpt, 1); | ||
749 | |||
750 | /* release the stag index to free pool */ | ||
751 | if (reset_tpt_entry) | ||
752 | cxio_hal_put_stag(rdev_p->rscp, stag_idx); | ||
753 | ret: | ||
754 | wptr = rdev_p->ctrl_qp.wptr; | ||
755 | mutex_unlock(&rdev_p->ctrl_qp.lock); | ||
756 | if (!err) | ||
757 | if (wait_event_interruptible(rdev_p->ctrl_qp.waitq, | ||
758 | SEQ32_GE(rdev_p->ctrl_qp.rptr, | ||
759 | wptr))) | ||
760 | return -ERESTARTSYS; | ||
761 | return err; | ||
762 | } | ||
763 | |||
764 | /* IN : stag key, pdid, pbl_size | ||
765 | * Out: stag index, actaul pbl_size, and pbl_addr allocated. | ||
766 | */ | ||
767 | int cxio_allocate_stag(struct cxio_rdev *rdev_p, u32 * stag, u32 pdid, | ||
768 | enum tpt_mem_perm perm, u32 * pbl_size, u32 * pbl_addr) | ||
769 | { | ||
770 | *stag = T3_STAG_UNSET; | ||
771 | return (__cxio_tpt_op(rdev_p, 0, stag, 0, pdid, TPT_NON_SHARED_MR, | ||
772 | perm, 0, 0ULL, 0, 0, NULL, pbl_size, pbl_addr)); | ||
773 | } | ||
774 | |||
775 | int cxio_register_phys_mem(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid, | ||
776 | enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len, | ||
777 | u8 page_size, __be64 *pbl, u32 *pbl_size, | ||
778 | u32 *pbl_addr) | ||
779 | { | ||
780 | *stag = T3_STAG_UNSET; | ||
781 | return __cxio_tpt_op(rdev_p, 0, stag, 1, pdid, TPT_NON_SHARED_MR, perm, | ||
782 | zbva, to, len, page_size, pbl, pbl_size, pbl_addr); | ||
783 | } | ||
784 | |||
785 | int cxio_reregister_phys_mem(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid, | ||
786 | enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len, | ||
787 | u8 page_size, __be64 *pbl, u32 *pbl_size, | ||
788 | u32 *pbl_addr) | ||
789 | { | ||
790 | return __cxio_tpt_op(rdev_p, 0, stag, 1, pdid, TPT_NON_SHARED_MR, perm, | ||
791 | zbva, to, len, page_size, pbl, pbl_size, pbl_addr); | ||
792 | } | ||
793 | |||
794 | int cxio_dereg_mem(struct cxio_rdev *rdev_p, u32 stag, u32 pbl_size, | ||
795 | u32 pbl_addr) | ||
796 | { | ||
797 | return __cxio_tpt_op(rdev_p, 1, &stag, 0, 0, 0, 0, 0, 0ULL, 0, 0, NULL, | ||
798 | &pbl_size, &pbl_addr); | ||
799 | } | ||
800 | |||
801 | int cxio_allocate_window(struct cxio_rdev *rdev_p, u32 * stag, u32 pdid) | ||
802 | { | ||
803 | u32 pbl_size = 0; | ||
804 | *stag = T3_STAG_UNSET; | ||
805 | return __cxio_tpt_op(rdev_p, 0, stag, 0, pdid, TPT_MW, 0, 0, 0ULL, 0, 0, | ||
806 | NULL, &pbl_size, NULL); | ||
807 | } | ||
808 | |||
809 | int cxio_deallocate_window(struct cxio_rdev *rdev_p, u32 stag) | ||
810 | { | ||
811 | return __cxio_tpt_op(rdev_p, 1, &stag, 0, 0, 0, 0, 0, 0ULL, 0, 0, NULL, | ||
812 | NULL, NULL); | ||
813 | } | ||
814 | |||
815 | int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr) | ||
816 | { | ||
817 | struct t3_rdma_init_wr *wqe; | ||
818 | struct sk_buff *skb = alloc_skb(sizeof(*wqe), GFP_ATOMIC); | ||
819 | if (!skb) | ||
820 | return -ENOMEM; | ||
821 | PDBG("%s rdev_p %p\n", __FUNCTION__, rdev_p); | ||
822 | wqe = (struct t3_rdma_init_wr *) __skb_put(skb, sizeof(*wqe)); | ||
823 | wqe->wrh.op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(T3_WR_INIT)); | ||
824 | wqe->wrh.gen_tid_len = cpu_to_be32(V_FW_RIWR_TID(attr->tid) | | ||
825 | V_FW_RIWR_LEN(sizeof(*wqe) >> 3)); | ||
826 | wqe->wrid.id1 = 0; | ||
827 | wqe->qpid = cpu_to_be32(attr->qpid); | ||
828 | wqe->pdid = cpu_to_be32(attr->pdid); | ||
829 | wqe->scqid = cpu_to_be32(attr->scqid); | ||
830 | wqe->rcqid = cpu_to_be32(attr->rcqid); | ||
831 | wqe->rq_addr = cpu_to_be32(attr->rq_addr - rdev_p->rnic_info.rqt_base); | ||
832 | wqe->rq_size = cpu_to_be32(attr->rq_size); | ||
833 | wqe->mpaattrs = attr->mpaattrs; | ||
834 | wqe->qpcaps = attr->qpcaps; | ||
835 | wqe->ulpdu_size = cpu_to_be16(attr->tcp_emss); | ||
836 | wqe->flags = cpu_to_be32(attr->flags); | ||
837 | wqe->ord = cpu_to_be32(attr->ord); | ||
838 | wqe->ird = cpu_to_be32(attr->ird); | ||
839 | wqe->qp_dma_addr = cpu_to_be64(attr->qp_dma_addr); | ||
840 | wqe->qp_dma_size = cpu_to_be32(attr->qp_dma_size); | ||
841 | wqe->rsvd = 0; | ||
842 | skb->priority = 0; /* 0=>ToeQ; 1=>CtrlQ */ | ||
843 | return (cxgb3_ofld_send(rdev_p->t3cdev_p, skb)); | ||
844 | } | ||
845 | |||
846 | void cxio_register_ev_cb(cxio_hal_ev_callback_func_t ev_cb) | ||
847 | { | ||
848 | cxio_ev_cb = ev_cb; | ||
849 | } | ||
850 | |||
851 | void cxio_unregister_ev_cb(cxio_hal_ev_callback_func_t ev_cb) | ||
852 | { | ||
853 | cxio_ev_cb = NULL; | ||
854 | } | ||
855 | |||
856 | static int cxio_hal_ev_handler(struct t3cdev *t3cdev_p, struct sk_buff *skb) | ||
857 | { | ||
858 | static int cnt; | ||
859 | struct cxio_rdev *rdev_p = NULL; | ||
860 | struct respQ_msg_t *rsp_msg = (struct respQ_msg_t *) skb->data; | ||
861 | PDBG("%d: %s cq_id 0x%x cq_ptr 0x%x genbit %0x overflow %0x an %0x" | ||
862 | " se %0x notify %0x cqbranch %0x creditth %0x\n", | ||
863 | cnt, __FUNCTION__, RSPQ_CQID(rsp_msg), RSPQ_CQPTR(rsp_msg), | ||
864 | RSPQ_GENBIT(rsp_msg), RSPQ_OVERFLOW(rsp_msg), RSPQ_AN(rsp_msg), | ||
865 | RSPQ_SE(rsp_msg), RSPQ_NOTIFY(rsp_msg), RSPQ_CQBRANCH(rsp_msg), | ||
866 | RSPQ_CREDIT_THRESH(rsp_msg)); | ||
867 | PDBG("CQE: QPID 0x%0x genbit %0x type 0x%0x status 0x%0x opcode %d " | ||
868 | "len 0x%0x wrid_hi_stag 0x%x wrid_low_msn 0x%x\n", | ||
869 | CQE_QPID(rsp_msg->cqe), CQE_GENBIT(rsp_msg->cqe), | ||
870 | CQE_TYPE(rsp_msg->cqe), CQE_STATUS(rsp_msg->cqe), | ||
871 | CQE_OPCODE(rsp_msg->cqe), CQE_LEN(rsp_msg->cqe), | ||
872 | CQE_WRID_HI(rsp_msg->cqe), CQE_WRID_LOW(rsp_msg->cqe)); | ||
873 | rdev_p = (struct cxio_rdev *)t3cdev_p->ulp; | ||
874 | if (!rdev_p) { | ||
875 | PDBG("%s called by t3cdev %p with null ulp\n", __FUNCTION__, | ||
876 | t3cdev_p); | ||
877 | return 0; | ||
878 | } | ||
879 | if (CQE_QPID(rsp_msg->cqe) == T3_CTRL_QP_ID) { | ||
880 | rdev_p->ctrl_qp.rptr = CQE_WRID_LOW(rsp_msg->cqe) + 1; | ||
881 | wake_up_interruptible(&rdev_p->ctrl_qp.waitq); | ||
882 | dev_kfree_skb_irq(skb); | ||
883 | } else if (CQE_QPID(rsp_msg->cqe) == 0xfff8) | ||
884 | dev_kfree_skb_irq(skb); | ||
885 | else if (cxio_ev_cb) | ||
886 | (*cxio_ev_cb) (rdev_p, skb); | ||
887 | else | ||
888 | dev_kfree_skb_irq(skb); | ||
889 | cnt++; | ||
890 | return 0; | ||
891 | } | ||
892 | |||
893 | /* Caller takes care of locking if needed */ | ||
894 | int cxio_rdev_open(struct cxio_rdev *rdev_p) | ||
895 | { | ||
896 | struct net_device *netdev_p = NULL; | ||
897 | int err = 0; | ||
898 | if (strlen(rdev_p->dev_name)) { | ||
899 | if (cxio_hal_find_rdev_by_name(rdev_p->dev_name)) { | ||
900 | return -EBUSY; | ||
901 | } | ||
902 | netdev_p = dev_get_by_name(rdev_p->dev_name); | ||
903 | if (!netdev_p) { | ||
904 | return -EINVAL; | ||
905 | } | ||
906 | dev_put(netdev_p); | ||
907 | } else if (rdev_p->t3cdev_p) { | ||
908 | if (cxio_hal_find_rdev_by_t3cdev(rdev_p->t3cdev_p)) { | ||
909 | return -EBUSY; | ||
910 | } | ||
911 | netdev_p = rdev_p->t3cdev_p->lldev; | ||
912 | strncpy(rdev_p->dev_name, rdev_p->t3cdev_p->name, | ||
913 | T3_MAX_DEV_NAME_LEN); | ||
914 | } else { | ||
915 | PDBG("%s t3cdev_p or dev_name must be set\n", __FUNCTION__); | ||
916 | return -EINVAL; | ||
917 | } | ||
918 | |||
919 | list_add_tail(&rdev_p->entry, &rdev_list); | ||
920 | |||
921 | PDBG("%s opening rnic dev %s\n", __FUNCTION__, rdev_p->dev_name); | ||
922 | memset(&rdev_p->ctrl_qp, 0, sizeof(rdev_p->ctrl_qp)); | ||
923 | if (!rdev_p->t3cdev_p) | ||
924 | rdev_p->t3cdev_p = T3CDEV(netdev_p); | ||
925 | rdev_p->t3cdev_p->ulp = (void *) rdev_p; | ||
926 | err = rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_GET_PARAMS, | ||
927 | &(rdev_p->rnic_info)); | ||
928 | if (err) { | ||
929 | printk(KERN_ERR "%s t3cdev_p(%p)->ctl returned error %d.\n", | ||
930 | __FUNCTION__, rdev_p->t3cdev_p, err); | ||
931 | goto err1; | ||
932 | } | ||
933 | err = rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, GET_PORTS, | ||
934 | &(rdev_p->port_info)); | ||
935 | if (err) { | ||
936 | printk(KERN_ERR "%s t3cdev_p(%p)->ctl returned error %d.\n", | ||
937 | __FUNCTION__, rdev_p->t3cdev_p, err); | ||
938 | goto err1; | ||
939 | } | ||
940 | |||
941 | /* | ||
942 | * qpshift is the number of bits to shift the qpid left in order | ||
943 | * to get the correct address of the doorbell for that qp. | ||
944 | */ | ||
945 | cxio_init_ucontext(rdev_p, &rdev_p->uctx); | ||
946 | rdev_p->qpshift = PAGE_SHIFT - | ||
947 | ilog2(65536 >> | ||
948 | ilog2(rdev_p->rnic_info.udbell_len >> | ||
949 | PAGE_SHIFT)); | ||
950 | rdev_p->qpnr = rdev_p->rnic_info.udbell_len >> PAGE_SHIFT; | ||
951 | rdev_p->qpmask = (65536 >> ilog2(rdev_p->qpnr)) - 1; | ||
952 | PDBG("%s rnic %s info: tpt_base 0x%0x tpt_top 0x%0x num stags %d " | ||
953 | "pbl_base 0x%0x pbl_top 0x%0x rqt_base 0x%0x, rqt_top 0x%0x\n", | ||
954 | __FUNCTION__, rdev_p->dev_name, rdev_p->rnic_info.tpt_base, | ||
955 | rdev_p->rnic_info.tpt_top, cxio_num_stags(rdev_p), | ||
956 | rdev_p->rnic_info.pbl_base, | ||
957 | rdev_p->rnic_info.pbl_top, rdev_p->rnic_info.rqt_base, | ||
958 | rdev_p->rnic_info.rqt_top); | ||
959 | PDBG("udbell_len 0x%0x udbell_physbase 0x%lx kdb_addr %p qpshift %lu " | ||
960 | "qpnr %d qpmask 0x%x\n", | ||
961 | rdev_p->rnic_info.udbell_len, | ||
962 | rdev_p->rnic_info.udbell_physbase, rdev_p->rnic_info.kdb_addr, | ||
963 | rdev_p->qpshift, rdev_p->qpnr, rdev_p->qpmask); | ||
964 | |||
965 | err = cxio_hal_init_ctrl_qp(rdev_p); | ||
966 | if (err) { | ||
967 | printk(KERN_ERR "%s error %d initializing ctrl_qp.\n", | ||
968 | __FUNCTION__, err); | ||
969 | goto err1; | ||
970 | } | ||
971 | err = cxio_hal_init_resource(rdev_p, cxio_num_stags(rdev_p), 0, | ||
972 | 0, T3_MAX_NUM_QP, T3_MAX_NUM_CQ, | ||
973 | T3_MAX_NUM_PD); | ||
974 | if (err) { | ||
975 | printk(KERN_ERR "%s error %d initializing hal resources.\n", | ||
976 | __FUNCTION__, err); | ||
977 | goto err2; | ||
978 | } | ||
979 | err = cxio_hal_pblpool_create(rdev_p); | ||
980 | if (err) { | ||
981 | printk(KERN_ERR "%s error %d initializing pbl mem pool.\n", | ||
982 | __FUNCTION__, err); | ||
983 | goto err3; | ||
984 | } | ||
985 | err = cxio_hal_rqtpool_create(rdev_p); | ||
986 | if (err) { | ||
987 | printk(KERN_ERR "%s error %d initializing rqt mem pool.\n", | ||
988 | __FUNCTION__, err); | ||
989 | goto err4; | ||
990 | } | ||
991 | return 0; | ||
992 | err4: | ||
993 | cxio_hal_pblpool_destroy(rdev_p); | ||
994 | err3: | ||
995 | cxio_hal_destroy_resource(rdev_p->rscp); | ||
996 | err2: | ||
997 | cxio_hal_destroy_ctrl_qp(rdev_p); | ||
998 | err1: | ||
999 | list_del(&rdev_p->entry); | ||
1000 | return err; | ||
1001 | } | ||
1002 | |||
1003 | void cxio_rdev_close(struct cxio_rdev *rdev_p) | ||
1004 | { | ||
1005 | if (rdev_p) { | ||
1006 | cxio_hal_pblpool_destroy(rdev_p); | ||
1007 | cxio_hal_rqtpool_destroy(rdev_p); | ||
1008 | list_del(&rdev_p->entry); | ||
1009 | rdev_p->t3cdev_p->ulp = NULL; | ||
1010 | cxio_hal_destroy_ctrl_qp(rdev_p); | ||
1011 | cxio_hal_destroy_resource(rdev_p->rscp); | ||
1012 | } | ||
1013 | } | ||
1014 | |||
1015 | int __init cxio_hal_init(void) | ||
1016 | { | ||
1017 | if (cxio_hal_init_rhdl_resource(T3_MAX_NUM_RI)) | ||
1018 | return -ENOMEM; | ||
1019 | t3_register_cpl_handler(CPL_ASYNC_NOTIF, cxio_hal_ev_handler); | ||
1020 | return 0; | ||
1021 | } | ||
1022 | |||
1023 | void __exit cxio_hal_exit(void) | ||
1024 | { | ||
1025 | struct cxio_rdev *rdev, *tmp; | ||
1026 | |||
1027 | t3_register_cpl_handler(CPL_ASYNC_NOTIF, NULL); | ||
1028 | list_for_each_entry_safe(rdev, tmp, &rdev_list, entry) | ||
1029 | cxio_rdev_close(rdev); | ||
1030 | cxio_hal_destroy_rhdl_resource(); | ||
1031 | } | ||
1032 | |||
1033 | static inline void flush_completed_wrs(struct t3_wq *wq, struct t3_cq *cq) | ||
1034 | { | ||
1035 | struct t3_swsq *sqp; | ||
1036 | __u32 ptr = wq->sq_rptr; | ||
1037 | int count = Q_COUNT(wq->sq_rptr, wq->sq_wptr); | ||
1038 | |||
1039 | sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2); | ||
1040 | while (count--) | ||
1041 | if (!sqp->signaled) { | ||
1042 | ptr++; | ||
1043 | sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2); | ||
1044 | } else if (sqp->complete) { | ||
1045 | |||
1046 | /* | ||
1047 | * Insert this completed cqe into the swcq. | ||
1048 | */ | ||
1049 | PDBG("%s moving cqe into swcq sq idx %ld cq idx %ld\n", | ||
1050 | __FUNCTION__, Q_PTR2IDX(ptr, wq->sq_size_log2), | ||
1051 | Q_PTR2IDX(cq->sw_wptr, cq->size_log2)); | ||
1052 | sqp->cqe.header |= htonl(V_CQE_SWCQE(1)); | ||
1053 | *(cq->sw_queue + Q_PTR2IDX(cq->sw_wptr, cq->size_log2)) | ||
1054 | = sqp->cqe; | ||
1055 | cq->sw_wptr++; | ||
1056 | sqp->signaled = 0; | ||
1057 | break; | ||
1058 | } else | ||
1059 | break; | ||
1060 | } | ||
1061 | |||
1062 | static inline void create_read_req_cqe(struct t3_wq *wq, | ||
1063 | struct t3_cqe *hw_cqe, | ||
1064 | struct t3_cqe *read_cqe) | ||
1065 | { | ||
1066 | read_cqe->u.scqe.wrid_hi = wq->oldest_read->sq_wptr; | ||
1067 | read_cqe->len = wq->oldest_read->read_len; | ||
1068 | read_cqe->header = htonl(V_CQE_QPID(CQE_QPID(*hw_cqe)) | | ||
1069 | V_CQE_SWCQE(SW_CQE(*hw_cqe)) | | ||
1070 | V_CQE_OPCODE(T3_READ_REQ) | | ||
1071 | V_CQE_TYPE(1)); | ||
1072 | } | ||
1073 | |||
1074 | /* | ||
1075 | * Return a ptr to the next read wr in the SWSQ or NULL. | ||
1076 | */ | ||
1077 | static inline void advance_oldest_read(struct t3_wq *wq) | ||
1078 | { | ||
1079 | |||
1080 | u32 rptr = wq->oldest_read - wq->sq + 1; | ||
1081 | u32 wptr = Q_PTR2IDX(wq->sq_wptr, wq->sq_size_log2); | ||
1082 | |||
1083 | while (Q_PTR2IDX(rptr, wq->sq_size_log2) != wptr) { | ||
1084 | wq->oldest_read = wq->sq + Q_PTR2IDX(rptr, wq->sq_size_log2); | ||
1085 | |||
1086 | if (wq->oldest_read->opcode == T3_READ_REQ) | ||
1087 | return; | ||
1088 | rptr++; | ||
1089 | } | ||
1090 | wq->oldest_read = NULL; | ||
1091 | } | ||
1092 | |||
1093 | /* | ||
1094 | * cxio_poll_cq | ||
1095 | * | ||
1096 | * Caller must: | ||
1097 | * check the validity of the first CQE, | ||
1098 | * supply the wq assicated with the qpid. | ||
1099 | * | ||
1100 | * credit: cq credit to return to sge. | ||
1101 | * cqe_flushed: 1 iff the CQE is flushed. | ||
1102 | * cqe: copy of the polled CQE. | ||
1103 | * | ||
1104 | * return value: | ||
1105 | * 0 CQE returned, | ||
1106 | * -1 CQE skipped, try again. | ||
1107 | */ | ||
1108 | int cxio_poll_cq(struct t3_wq *wq, struct t3_cq *cq, struct t3_cqe *cqe, | ||
1109 | u8 *cqe_flushed, u64 *cookie, u32 *credit) | ||
1110 | { | ||
1111 | int ret = 0; | ||
1112 | struct t3_cqe *hw_cqe, read_cqe; | ||
1113 | |||
1114 | *cqe_flushed = 0; | ||
1115 | *credit = 0; | ||
1116 | hw_cqe = cxio_next_cqe(cq); | ||
1117 | |||
1118 | PDBG("%s CQE OOO %d qpid 0x%0x genbit %d type %d status 0x%0x" | ||
1119 | " opcode 0x%0x len 0x%0x wrid_hi_stag 0x%x wrid_low_msn 0x%x\n", | ||
1120 | __FUNCTION__, CQE_OOO(*hw_cqe), CQE_QPID(*hw_cqe), | ||
1121 | CQE_GENBIT(*hw_cqe), CQE_TYPE(*hw_cqe), CQE_STATUS(*hw_cqe), | ||
1122 | CQE_OPCODE(*hw_cqe), CQE_LEN(*hw_cqe), CQE_WRID_HI(*hw_cqe), | ||
1123 | CQE_WRID_LOW(*hw_cqe)); | ||
1124 | |||
1125 | /* | ||
1126 | * skip cqe's not affiliated with a QP. | ||
1127 | */ | ||
1128 | if (wq == NULL) { | ||
1129 | ret = -1; | ||
1130 | goto skip_cqe; | ||
1131 | } | ||
1132 | |||
1133 | /* | ||
1134 | * Gotta tweak READ completions: | ||
1135 | * 1) the cqe doesn't contain the sq_wptr from the wr. | ||
1136 | * 2) opcode not reflected from the wr. | ||
1137 | * 3) read_len not reflected from the wr. | ||
1138 | * 4) cq_type is RQ_TYPE not SQ_TYPE. | ||
1139 | */ | ||
1140 | if (RQ_TYPE(*hw_cqe) && (CQE_OPCODE(*hw_cqe) == T3_READ_RESP)) { | ||
1141 | |||
1142 | /* | ||
1143 | * Don't write to the HWCQ, so create a new read req CQE | ||
1144 | * in local memory. | ||
1145 | */ | ||
1146 | create_read_req_cqe(wq, hw_cqe, &read_cqe); | ||
1147 | hw_cqe = &read_cqe; | ||
1148 | advance_oldest_read(wq); | ||
1149 | } | ||
1150 | |||
1151 | /* | ||
1152 | * T3A: Discard TERMINATE CQEs. | ||
1153 | */ | ||
1154 | if (CQE_OPCODE(*hw_cqe) == T3_TERMINATE) { | ||
1155 | ret = -1; | ||
1156 | wq->error = 1; | ||
1157 | goto skip_cqe; | ||
1158 | } | ||
1159 | |||
1160 | if (CQE_STATUS(*hw_cqe) || wq->error) { | ||
1161 | *cqe_flushed = wq->error; | ||
1162 | wq->error = 1; | ||
1163 | |||
1164 | /* | ||
1165 | * T3A inserts errors into the CQE. We cannot return | ||
1166 | * these as work completions. | ||
1167 | */ | ||
1168 | /* incoming write failures */ | ||
1169 | if ((CQE_OPCODE(*hw_cqe) == T3_RDMA_WRITE) | ||
1170 | && RQ_TYPE(*hw_cqe)) { | ||
1171 | ret = -1; | ||
1172 | goto skip_cqe; | ||
1173 | } | ||
1174 | /* incoming read request failures */ | ||
1175 | if ((CQE_OPCODE(*hw_cqe) == T3_READ_RESP) && SQ_TYPE(*hw_cqe)) { | ||
1176 | ret = -1; | ||
1177 | goto skip_cqe; | ||
1178 | } | ||
1179 | |||
1180 | /* incoming SEND with no receive posted failures */ | ||
1181 | if ((CQE_OPCODE(*hw_cqe) == T3_SEND) && RQ_TYPE(*hw_cqe) && | ||
1182 | Q_EMPTY(wq->rq_rptr, wq->rq_wptr)) { | ||
1183 | ret = -1; | ||
1184 | goto skip_cqe; | ||
1185 | } | ||
1186 | goto proc_cqe; | ||
1187 | } | ||
1188 | |||
1189 | /* | ||
1190 | * RECV completion. | ||
1191 | */ | ||
1192 | if (RQ_TYPE(*hw_cqe)) { | ||
1193 | |||
1194 | /* | ||
1195 | * HW only validates 4 bits of MSN. So we must validate that | ||
1196 | * the MSN in the SEND is the next expected MSN. If its not, | ||
1197 | * then we complete this with TPT_ERR_MSN and mark the wq in | ||
1198 | * error. | ||
1199 | */ | ||
1200 | if (unlikely((CQE_WRID_MSN(*hw_cqe) != (wq->rq_rptr + 1)))) { | ||
1201 | wq->error = 1; | ||
1202 | hw_cqe->header |= htonl(V_CQE_STATUS(TPT_ERR_MSN)); | ||
1203 | goto proc_cqe; | ||
1204 | } | ||
1205 | goto proc_cqe; | ||
1206 | } | ||
1207 | |||
1208 | /* | ||
1209 | * If we get here its a send completion. | ||
1210 | * | ||
1211 | * Handle out of order completion. These get stuffed | ||
1212 | * in the SW SQ. Then the SW SQ is walked to move any | ||
1213 | * now in-order completions into the SW CQ. This handles | ||
1214 | * 2 cases: | ||
1215 | * 1) reaping unsignaled WRs when the first subsequent | ||
1216 | * signaled WR is completed. | ||
1217 | * 2) out of order read completions. | ||
1218 | */ | ||
1219 | if (!SW_CQE(*hw_cqe) && (CQE_WRID_SQ_WPTR(*hw_cqe) != wq->sq_rptr)) { | ||
1220 | struct t3_swsq *sqp; | ||
1221 | |||
1222 | PDBG("%s out of order completion going in swsq at idx %ld\n", | ||
1223 | __FUNCTION__, | ||
1224 | Q_PTR2IDX(CQE_WRID_SQ_WPTR(*hw_cqe), wq->sq_size_log2)); | ||
1225 | sqp = wq->sq + | ||
1226 | Q_PTR2IDX(CQE_WRID_SQ_WPTR(*hw_cqe), wq->sq_size_log2); | ||
1227 | sqp->cqe = *hw_cqe; | ||
1228 | sqp->complete = 1; | ||
1229 | ret = -1; | ||
1230 | goto flush_wq; | ||
1231 | } | ||
1232 | |||
1233 | proc_cqe: | ||
1234 | *cqe = *hw_cqe; | ||
1235 | |||
1236 | /* | ||
1237 | * Reap the associated WR(s) that are freed up with this | ||
1238 | * completion. | ||
1239 | */ | ||
1240 | if (SQ_TYPE(*hw_cqe)) { | ||
1241 | wq->sq_rptr = CQE_WRID_SQ_WPTR(*hw_cqe); | ||
1242 | PDBG("%s completing sq idx %ld\n", __FUNCTION__, | ||
1243 | Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2)); | ||
1244 | *cookie = (wq->sq + | ||
1245 | Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2))->wr_id; | ||
1246 | wq->sq_rptr++; | ||
1247 | } else { | ||
1248 | PDBG("%s completing rq idx %ld\n", __FUNCTION__, | ||
1249 | Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); | ||
1250 | *cookie = *(wq->rq + Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); | ||
1251 | wq->rq_rptr++; | ||
1252 | } | ||
1253 | |||
1254 | flush_wq: | ||
1255 | /* | ||
1256 | * Flush any completed cqes that are now in-order. | ||
1257 | */ | ||
1258 | flush_completed_wrs(wq, cq); | ||
1259 | |||
1260 | skip_cqe: | ||
1261 | if (SW_CQE(*hw_cqe)) { | ||
1262 | PDBG("%s cq %p cqid 0x%x skip sw cqe sw_rptr 0x%x\n", | ||
1263 | __FUNCTION__, cq, cq->cqid, cq->sw_rptr); | ||
1264 | ++cq->sw_rptr; | ||
1265 | } else { | ||
1266 | PDBG("%s cq %p cqid 0x%x skip hw cqe rptr 0x%x\n", | ||
1267 | __FUNCTION__, cq, cq->cqid, cq->rptr); | ||
1268 | ++cq->rptr; | ||
1269 | |||
1270 | /* | ||
1271 | * T3A: compute credits. | ||
1272 | */ | ||
1273 | if (((cq->rptr - cq->wptr) > (1 << (cq->size_log2 - 1))) | ||
1274 | || ((cq->rptr - cq->wptr) >= 128)) { | ||
1275 | *credit = cq->rptr - cq->wptr; | ||
1276 | cq->wptr = cq->rptr; | ||
1277 | } | ||
1278 | } | ||
1279 | return ret; | ||
1280 | } | ||
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.h b/drivers/infiniband/hw/cxgb3/cxio_hal.h new file mode 100644 index 000000000000..1b97e80b8780 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.h | |||
@@ -0,0 +1,201 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #ifndef __CXIO_HAL_H__ | ||
34 | #define __CXIO_HAL_H__ | ||
35 | |||
36 | #include <linux/list.h> | ||
37 | #include <linux/mutex.h> | ||
38 | |||
39 | #include "t3_cpl.h" | ||
40 | #include "t3cdev.h" | ||
41 | #include "cxgb3_ctl_defs.h" | ||
42 | #include "cxio_wr.h" | ||
43 | |||
44 | #define T3_CTRL_QP_ID FW_RI_SGEEC_START | ||
45 | #define T3_CTL_QP_TID FW_RI_TID_START | ||
46 | #define T3_CTRL_QP_SIZE_LOG2 8 | ||
47 | #define T3_CTRL_CQ_ID 0 | ||
48 | |||
49 | /* TBD */ | ||
50 | #define T3_MAX_NUM_RI (1<<15) | ||
51 | #define T3_MAX_NUM_QP (1<<15) | ||
52 | #define T3_MAX_NUM_CQ (1<<15) | ||
53 | #define T3_MAX_NUM_PD (1<<15) | ||
54 | #define T3_MAX_PBL_SIZE 256 | ||
55 | #define T3_MAX_RQ_SIZE 1024 | ||
56 | #define T3_MAX_NUM_STAG (1<<15) | ||
57 | |||
58 | #define T3_STAG_UNSET 0xffffffff | ||
59 | |||
60 | #define T3_MAX_DEV_NAME_LEN 32 | ||
61 | |||
62 | struct cxio_hal_ctrl_qp { | ||
63 | u32 wptr; | ||
64 | u32 rptr; | ||
65 | struct mutex lock; /* for the wtpr, can sleep */ | ||
66 | wait_queue_head_t waitq;/* wait for RspQ/CQE msg */ | ||
67 | union t3_wr *workq; /* the work request queue */ | ||
68 | dma_addr_t dma_addr; /* pci bus address of the workq */ | ||
69 | DECLARE_PCI_UNMAP_ADDR(mapping) | ||
70 | void __iomem *doorbell; | ||
71 | }; | ||
72 | |||
73 | struct cxio_hal_resource { | ||
74 | struct kfifo *tpt_fifo; | ||
75 | spinlock_t tpt_fifo_lock; | ||
76 | struct kfifo *qpid_fifo; | ||
77 | spinlock_t qpid_fifo_lock; | ||
78 | struct kfifo *cqid_fifo; | ||
79 | spinlock_t cqid_fifo_lock; | ||
80 | struct kfifo *pdid_fifo; | ||
81 | spinlock_t pdid_fifo_lock; | ||
82 | }; | ||
83 | |||
84 | struct cxio_qpid_list { | ||
85 | struct list_head entry; | ||
86 | u32 qpid; | ||
87 | }; | ||
88 | |||
89 | struct cxio_ucontext { | ||
90 | struct list_head qpids; | ||
91 | struct mutex lock; | ||
92 | }; | ||
93 | |||
94 | struct cxio_rdev { | ||
95 | char dev_name[T3_MAX_DEV_NAME_LEN]; | ||
96 | struct t3cdev *t3cdev_p; | ||
97 | struct rdma_info rnic_info; | ||
98 | struct adap_ports port_info; | ||
99 | struct cxio_hal_resource *rscp; | ||
100 | struct cxio_hal_ctrl_qp ctrl_qp; | ||
101 | void *ulp; | ||
102 | unsigned long qpshift; | ||
103 | u32 qpnr; | ||
104 | u32 qpmask; | ||
105 | struct cxio_ucontext uctx; | ||
106 | struct gen_pool *pbl_pool; | ||
107 | struct gen_pool *rqt_pool; | ||
108 | struct list_head entry; | ||
109 | }; | ||
110 | |||
111 | static inline int cxio_num_stags(struct cxio_rdev *rdev_p) | ||
112 | { | ||
113 | return min((int)T3_MAX_NUM_STAG, (int)((rdev_p->rnic_info.tpt_top - rdev_p->rnic_info.tpt_base) >> 5)); | ||
114 | } | ||
115 | |||
116 | typedef void (*cxio_hal_ev_callback_func_t) (struct cxio_rdev * rdev_p, | ||
117 | struct sk_buff * skb); | ||
118 | |||
119 | #define RSPQ_CQID(rsp) (be32_to_cpu(rsp->cq_ptrid) & 0xffff) | ||
120 | #define RSPQ_CQPTR(rsp) ((be32_to_cpu(rsp->cq_ptrid) >> 16) & 0xffff) | ||
121 | #define RSPQ_GENBIT(rsp) ((be32_to_cpu(rsp->flags) >> 16) & 1) | ||
122 | #define RSPQ_OVERFLOW(rsp) ((be32_to_cpu(rsp->flags) >> 17) & 1) | ||
123 | #define RSPQ_AN(rsp) ((be32_to_cpu(rsp->flags) >> 18) & 1) | ||
124 | #define RSPQ_SE(rsp) ((be32_to_cpu(rsp->flags) >> 19) & 1) | ||
125 | #define RSPQ_NOTIFY(rsp) ((be32_to_cpu(rsp->flags) >> 20) & 1) | ||
126 | #define RSPQ_CQBRANCH(rsp) ((be32_to_cpu(rsp->flags) >> 21) & 1) | ||
127 | #define RSPQ_CREDIT_THRESH(rsp) ((be32_to_cpu(rsp->flags) >> 22) & 1) | ||
128 | |||
129 | struct respQ_msg_t { | ||
130 | __be32 flags; /* flit 0 */ | ||
131 | __be32 cq_ptrid; | ||
132 | __be64 rsvd; /* flit 1 */ | ||
133 | struct t3_cqe cqe; /* flits 2-3 */ | ||
134 | }; | ||
135 | |||
136 | enum t3_cq_opcode { | ||
137 | CQ_ARM_AN = 0x2, | ||
138 | CQ_ARM_SE = 0x6, | ||
139 | CQ_FORCE_AN = 0x3, | ||
140 | CQ_CREDIT_UPDATE = 0x7 | ||
141 | }; | ||
142 | |||
143 | int cxio_rdev_open(struct cxio_rdev *rdev); | ||
144 | void cxio_rdev_close(struct cxio_rdev *rdev); | ||
145 | int cxio_hal_cq_op(struct cxio_rdev *rdev, struct t3_cq *cq, | ||
146 | enum t3_cq_opcode op, u32 credit); | ||
147 | int cxio_hal_clear_qp_ctx(struct cxio_rdev *rdev, u32 qpid); | ||
148 | int cxio_create_cq(struct cxio_rdev *rdev, struct t3_cq *cq); | ||
149 | int cxio_destroy_cq(struct cxio_rdev *rdev, struct t3_cq *cq); | ||
150 | int cxio_resize_cq(struct cxio_rdev *rdev, struct t3_cq *cq); | ||
151 | void cxio_release_ucontext(struct cxio_rdev *rdev, struct cxio_ucontext *uctx); | ||
152 | void cxio_init_ucontext(struct cxio_rdev *rdev, struct cxio_ucontext *uctx); | ||
153 | int cxio_create_qp(struct cxio_rdev *rdev, u32 kernel_domain, struct t3_wq *wq, | ||
154 | struct cxio_ucontext *uctx); | ||
155 | int cxio_destroy_qp(struct cxio_rdev *rdev, struct t3_wq *wq, | ||
156 | struct cxio_ucontext *uctx); | ||
157 | int cxio_peek_cq(struct t3_wq *wr, struct t3_cq *cq, int opcode); | ||
158 | int cxio_allocate_stag(struct cxio_rdev *rdev, u32 * stag, u32 pdid, | ||
159 | enum tpt_mem_perm perm, u32 * pbl_size, u32 * pbl_addr); | ||
160 | int cxio_register_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid, | ||
161 | enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len, | ||
162 | u8 page_size, __be64 *pbl, u32 *pbl_size, | ||
163 | u32 *pbl_addr); | ||
164 | int cxio_reregister_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid, | ||
165 | enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len, | ||
166 | u8 page_size, __be64 *pbl, u32 *pbl_size, | ||
167 | u32 *pbl_addr); | ||
168 | int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size, | ||
169 | u32 pbl_addr); | ||
170 | int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid); | ||
171 | int cxio_deallocate_window(struct cxio_rdev *rdev, u32 stag); | ||
172 | int cxio_rdma_init(struct cxio_rdev *rdev, struct t3_rdma_init_attr *attr); | ||
173 | void cxio_register_ev_cb(cxio_hal_ev_callback_func_t ev_cb); | ||
174 | void cxio_unregister_ev_cb(cxio_hal_ev_callback_func_t ev_cb); | ||
175 | u32 cxio_hal_get_rhdl(void); | ||
176 | void cxio_hal_put_rhdl(u32 rhdl); | ||
177 | u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp); | ||
178 | void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid); | ||
179 | int __init cxio_hal_init(void); | ||
180 | void __exit cxio_hal_exit(void); | ||
181 | void cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count); | ||
182 | void cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count); | ||
183 | void cxio_count_rcqes(struct t3_cq *cq, struct t3_wq *wq, int *count); | ||
184 | void cxio_count_scqes(struct t3_cq *cq, struct t3_wq *wq, int *count); | ||
185 | void cxio_flush_hw_cq(struct t3_cq *cq); | ||
186 | int cxio_poll_cq(struct t3_wq *wq, struct t3_cq *cq, struct t3_cqe *cqe, | ||
187 | u8 *cqe_flushed, u64 *cookie, u32 *credit); | ||
188 | |||
189 | #define MOD "iw_cxgb3: " | ||
190 | #define PDBG(fmt, args...) pr_debug(MOD fmt, ## args) | ||
191 | |||
192 | #ifdef DEBUG | ||
193 | void cxio_dump_tpt(struct cxio_rdev *rev, u32 stag); | ||
194 | void cxio_dump_pbl(struct cxio_rdev *rev, u32 pbl_addr, uint len, u8 shift); | ||
195 | void cxio_dump_wqe(union t3_wr *wqe); | ||
196 | void cxio_dump_wce(struct t3_cqe *wce); | ||
197 | void cxio_dump_rqt(struct cxio_rdev *rdev, u32 hwtid, int nents); | ||
198 | void cxio_dump_tcb(struct cxio_rdev *rdev, u32 hwtid); | ||
199 | #endif | ||
200 | |||
201 | #endif | ||
diff --git a/drivers/infiniband/hw/cxgb3/cxio_resource.c b/drivers/infiniband/hw/cxgb3/cxio_resource.c new file mode 100644 index 000000000000..997aa32cbf07 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/cxio_resource.c | |||
@@ -0,0 +1,331 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | /* Crude resource management */ | ||
34 | #include <linux/kernel.h> | ||
35 | #include <linux/random.h> | ||
36 | #include <linux/slab.h> | ||
37 | #include <linux/kfifo.h> | ||
38 | #include <linux/spinlock.h> | ||
39 | #include <linux/errno.h> | ||
40 | #include "cxio_resource.h" | ||
41 | #include "cxio_hal.h" | ||
42 | |||
43 | static struct kfifo *rhdl_fifo; | ||
44 | static spinlock_t rhdl_fifo_lock; | ||
45 | |||
46 | #define RANDOM_SIZE 16 | ||
47 | |||
48 | static int __cxio_init_resource_fifo(struct kfifo **fifo, | ||
49 | spinlock_t *fifo_lock, | ||
50 | u32 nr, u32 skip_low, | ||
51 | u32 skip_high, | ||
52 | int random) | ||
53 | { | ||
54 | u32 i, j, entry = 0, idx; | ||
55 | u32 random_bytes; | ||
56 | u32 rarray[16]; | ||
57 | spin_lock_init(fifo_lock); | ||
58 | |||
59 | *fifo = kfifo_alloc(nr * sizeof(u32), GFP_KERNEL, fifo_lock); | ||
60 | if (IS_ERR(*fifo)) | ||
61 | return -ENOMEM; | ||
62 | |||
63 | for (i = 0; i < skip_low + skip_high; i++) | ||
64 | __kfifo_put(*fifo, (unsigned char *) &entry, sizeof(u32)); | ||
65 | if (random) { | ||
66 | j = 0; | ||
67 | random_bytes = random32(); | ||
68 | for (i = 0; i < RANDOM_SIZE; i++) | ||
69 | rarray[i] = i + skip_low; | ||
70 | for (i = skip_low + RANDOM_SIZE; i < nr - skip_high; i++) { | ||
71 | if (j >= RANDOM_SIZE) { | ||
72 | j = 0; | ||
73 | random_bytes = random32(); | ||
74 | } | ||
75 | idx = (random_bytes >> (j * 2)) & 0xF; | ||
76 | __kfifo_put(*fifo, | ||
77 | (unsigned char *) &rarray[idx], | ||
78 | sizeof(u32)); | ||
79 | rarray[idx] = i; | ||
80 | j++; | ||
81 | } | ||
82 | for (i = 0; i < RANDOM_SIZE; i++) | ||
83 | __kfifo_put(*fifo, | ||
84 | (unsigned char *) &rarray[i], | ||
85 | sizeof(u32)); | ||
86 | } else | ||
87 | for (i = skip_low; i < nr - skip_high; i++) | ||
88 | __kfifo_put(*fifo, (unsigned char *) &i, sizeof(u32)); | ||
89 | |||
90 | for (i = 0; i < skip_low + skip_high; i++) | ||
91 | kfifo_get(*fifo, (unsigned char *) &entry, sizeof(u32)); | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | static int cxio_init_resource_fifo(struct kfifo **fifo, spinlock_t * fifo_lock, | ||
96 | u32 nr, u32 skip_low, u32 skip_high) | ||
97 | { | ||
98 | return (__cxio_init_resource_fifo(fifo, fifo_lock, nr, skip_low, | ||
99 | skip_high, 0)); | ||
100 | } | ||
101 | |||
102 | static int cxio_init_resource_fifo_random(struct kfifo **fifo, | ||
103 | spinlock_t * fifo_lock, | ||
104 | u32 nr, u32 skip_low, u32 skip_high) | ||
105 | { | ||
106 | |||
107 | return (__cxio_init_resource_fifo(fifo, fifo_lock, nr, skip_low, | ||
108 | skip_high, 1)); | ||
109 | } | ||
110 | |||
111 | static int cxio_init_qpid_fifo(struct cxio_rdev *rdev_p) | ||
112 | { | ||
113 | u32 i; | ||
114 | |||
115 | spin_lock_init(&rdev_p->rscp->qpid_fifo_lock); | ||
116 | |||
117 | rdev_p->rscp->qpid_fifo = kfifo_alloc(T3_MAX_NUM_QP * sizeof(u32), | ||
118 | GFP_KERNEL, | ||
119 | &rdev_p->rscp->qpid_fifo_lock); | ||
120 | if (IS_ERR(rdev_p->rscp->qpid_fifo)) | ||
121 | return -ENOMEM; | ||
122 | |||
123 | for (i = 16; i < T3_MAX_NUM_QP; i++) | ||
124 | if (!(i & rdev_p->qpmask)) | ||
125 | __kfifo_put(rdev_p->rscp->qpid_fifo, | ||
126 | (unsigned char *) &i, sizeof(u32)); | ||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | int cxio_hal_init_rhdl_resource(u32 nr_rhdl) | ||
131 | { | ||
132 | return cxio_init_resource_fifo(&rhdl_fifo, &rhdl_fifo_lock, nr_rhdl, 1, | ||
133 | 0); | ||
134 | } | ||
135 | |||
136 | void cxio_hal_destroy_rhdl_resource(void) | ||
137 | { | ||
138 | kfifo_free(rhdl_fifo); | ||
139 | } | ||
140 | |||
141 | /* nr_* must be power of 2 */ | ||
142 | int cxio_hal_init_resource(struct cxio_rdev *rdev_p, | ||
143 | u32 nr_tpt, u32 nr_pbl, | ||
144 | u32 nr_rqt, u32 nr_qpid, u32 nr_cqid, u32 nr_pdid) | ||
145 | { | ||
146 | int err = 0; | ||
147 | struct cxio_hal_resource *rscp; | ||
148 | |||
149 | rscp = kmalloc(sizeof(*rscp), GFP_KERNEL); | ||
150 | if (!rscp) | ||
151 | return -ENOMEM; | ||
152 | rdev_p->rscp = rscp; | ||
153 | err = cxio_init_resource_fifo_random(&rscp->tpt_fifo, | ||
154 | &rscp->tpt_fifo_lock, | ||
155 | nr_tpt, 1, 0); | ||
156 | if (err) | ||
157 | goto tpt_err; | ||
158 | err = cxio_init_qpid_fifo(rdev_p); | ||
159 | if (err) | ||
160 | goto qpid_err; | ||
161 | err = cxio_init_resource_fifo(&rscp->cqid_fifo, &rscp->cqid_fifo_lock, | ||
162 | nr_cqid, 1, 0); | ||
163 | if (err) | ||
164 | goto cqid_err; | ||
165 | err = cxio_init_resource_fifo(&rscp->pdid_fifo, &rscp->pdid_fifo_lock, | ||
166 | nr_pdid, 1, 0); | ||
167 | if (err) | ||
168 | goto pdid_err; | ||
169 | return 0; | ||
170 | pdid_err: | ||
171 | kfifo_free(rscp->cqid_fifo); | ||
172 | cqid_err: | ||
173 | kfifo_free(rscp->qpid_fifo); | ||
174 | qpid_err: | ||
175 | kfifo_free(rscp->tpt_fifo); | ||
176 | tpt_err: | ||
177 | return -ENOMEM; | ||
178 | } | ||
179 | |||
180 | /* | ||
181 | * returns 0 if no resource available | ||
182 | */ | ||
183 | static inline u32 cxio_hal_get_resource(struct kfifo *fifo) | ||
184 | { | ||
185 | u32 entry; | ||
186 | if (kfifo_get(fifo, (unsigned char *) &entry, sizeof(u32))) | ||
187 | return entry; | ||
188 | else | ||
189 | return 0; /* fifo emptry */ | ||
190 | } | ||
191 | |||
192 | static inline void cxio_hal_put_resource(struct kfifo *fifo, u32 entry) | ||
193 | { | ||
194 | BUG_ON(kfifo_put(fifo, (unsigned char *) &entry, sizeof(u32)) == 0); | ||
195 | } | ||
196 | |||
197 | u32 cxio_hal_get_rhdl(void) | ||
198 | { | ||
199 | return cxio_hal_get_resource(rhdl_fifo); | ||
200 | } | ||
201 | |||
202 | void cxio_hal_put_rhdl(u32 rhdl) | ||
203 | { | ||
204 | cxio_hal_put_resource(rhdl_fifo, rhdl); | ||
205 | } | ||
206 | |||
207 | u32 cxio_hal_get_stag(struct cxio_hal_resource *rscp) | ||
208 | { | ||
209 | return cxio_hal_get_resource(rscp->tpt_fifo); | ||
210 | } | ||
211 | |||
212 | void cxio_hal_put_stag(struct cxio_hal_resource *rscp, u32 stag) | ||
213 | { | ||
214 | cxio_hal_put_resource(rscp->tpt_fifo, stag); | ||
215 | } | ||
216 | |||
217 | u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp) | ||
218 | { | ||
219 | u32 qpid = cxio_hal_get_resource(rscp->qpid_fifo); | ||
220 | PDBG("%s qpid 0x%x\n", __FUNCTION__, qpid); | ||
221 | return qpid; | ||
222 | } | ||
223 | |||
224 | void cxio_hal_put_qpid(struct cxio_hal_resource *rscp, u32 qpid) | ||
225 | { | ||
226 | PDBG("%s qpid 0x%x\n", __FUNCTION__, qpid); | ||
227 | cxio_hal_put_resource(rscp->qpid_fifo, qpid); | ||
228 | } | ||
229 | |||
230 | u32 cxio_hal_get_cqid(struct cxio_hal_resource *rscp) | ||
231 | { | ||
232 | return cxio_hal_get_resource(rscp->cqid_fifo); | ||
233 | } | ||
234 | |||
235 | void cxio_hal_put_cqid(struct cxio_hal_resource *rscp, u32 cqid) | ||
236 | { | ||
237 | cxio_hal_put_resource(rscp->cqid_fifo, cqid); | ||
238 | } | ||
239 | |||
240 | u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp) | ||
241 | { | ||
242 | return cxio_hal_get_resource(rscp->pdid_fifo); | ||
243 | } | ||
244 | |||
245 | void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid) | ||
246 | { | ||
247 | cxio_hal_put_resource(rscp->pdid_fifo, pdid); | ||
248 | } | ||
249 | |||
250 | void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp) | ||
251 | { | ||
252 | kfifo_free(rscp->tpt_fifo); | ||
253 | kfifo_free(rscp->cqid_fifo); | ||
254 | kfifo_free(rscp->qpid_fifo); | ||
255 | kfifo_free(rscp->pdid_fifo); | ||
256 | kfree(rscp); | ||
257 | } | ||
258 | |||
259 | /* | ||
260 | * PBL Memory Manager. Uses Linux generic allocator. | ||
261 | */ | ||
262 | |||
263 | #define MIN_PBL_SHIFT 8 /* 256B == min PBL size (32 entries) */ | ||
264 | #define PBL_CHUNK 2*1024*1024 | ||
265 | |||
266 | u32 cxio_hal_pblpool_alloc(struct cxio_rdev *rdev_p, int size) | ||
267 | { | ||
268 | unsigned long addr = gen_pool_alloc(rdev_p->pbl_pool, size); | ||
269 | PDBG("%s addr 0x%x size %d\n", __FUNCTION__, (u32)addr, size); | ||
270 | return (u32)addr; | ||
271 | } | ||
272 | |||
273 | void cxio_hal_pblpool_free(struct cxio_rdev *rdev_p, u32 addr, int size) | ||
274 | { | ||
275 | PDBG("%s addr 0x%x size %d\n", __FUNCTION__, addr, size); | ||
276 | gen_pool_free(rdev_p->pbl_pool, (unsigned long)addr, size); | ||
277 | } | ||
278 | |||
279 | int cxio_hal_pblpool_create(struct cxio_rdev *rdev_p) | ||
280 | { | ||
281 | unsigned long i; | ||
282 | rdev_p->pbl_pool = gen_pool_create(MIN_PBL_SHIFT, -1); | ||
283 | if (rdev_p->pbl_pool) | ||
284 | for (i = rdev_p->rnic_info.pbl_base; | ||
285 | i <= rdev_p->rnic_info.pbl_top - PBL_CHUNK + 1; | ||
286 | i += PBL_CHUNK) | ||
287 | gen_pool_add(rdev_p->pbl_pool, i, PBL_CHUNK, -1); | ||
288 | return rdev_p->pbl_pool ? 0 : -ENOMEM; | ||
289 | } | ||
290 | |||
291 | void cxio_hal_pblpool_destroy(struct cxio_rdev *rdev_p) | ||
292 | { | ||
293 | gen_pool_destroy(rdev_p->pbl_pool); | ||
294 | } | ||
295 | |||
296 | /* | ||
297 | * RQT Memory Manager. Uses Linux generic allocator. | ||
298 | */ | ||
299 | |||
300 | #define MIN_RQT_SHIFT 10 /* 1KB == mini RQT size (16 entries) */ | ||
301 | #define RQT_CHUNK 2*1024*1024 | ||
302 | |||
303 | u32 cxio_hal_rqtpool_alloc(struct cxio_rdev *rdev_p, int size) | ||
304 | { | ||
305 | unsigned long addr = gen_pool_alloc(rdev_p->rqt_pool, size << 6); | ||
306 | PDBG("%s addr 0x%x size %d\n", __FUNCTION__, (u32)addr, size << 6); | ||
307 | return (u32)addr; | ||
308 | } | ||
309 | |||
310 | void cxio_hal_rqtpool_free(struct cxio_rdev *rdev_p, u32 addr, int size) | ||
311 | { | ||
312 | PDBG("%s addr 0x%x size %d\n", __FUNCTION__, addr, size << 6); | ||
313 | gen_pool_free(rdev_p->rqt_pool, (unsigned long)addr, size << 6); | ||
314 | } | ||
315 | |||
316 | int cxio_hal_rqtpool_create(struct cxio_rdev *rdev_p) | ||
317 | { | ||
318 | unsigned long i; | ||
319 | rdev_p->rqt_pool = gen_pool_create(MIN_RQT_SHIFT, -1); | ||
320 | if (rdev_p->rqt_pool) | ||
321 | for (i = rdev_p->rnic_info.rqt_base; | ||
322 | i <= rdev_p->rnic_info.rqt_top - RQT_CHUNK + 1; | ||
323 | i += RQT_CHUNK) | ||
324 | gen_pool_add(rdev_p->rqt_pool, i, RQT_CHUNK, -1); | ||
325 | return rdev_p->rqt_pool ? 0 : -ENOMEM; | ||
326 | } | ||
327 | |||
328 | void cxio_hal_rqtpool_destroy(struct cxio_rdev *rdev_p) | ||
329 | { | ||
330 | gen_pool_destroy(rdev_p->rqt_pool); | ||
331 | } | ||
diff --git a/drivers/infiniband/hw/cxgb3/cxio_resource.h b/drivers/infiniband/hw/cxgb3/cxio_resource.h new file mode 100644 index 000000000000..a6bbe8370d81 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/cxio_resource.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #ifndef __CXIO_RESOURCE_H__ | ||
34 | #define __CXIO_RESOURCE_H__ | ||
35 | |||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/random.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/kfifo.h> | ||
40 | #include <linux/spinlock.h> | ||
41 | #include <linux/errno.h> | ||
42 | #include <linux/genalloc.h> | ||
43 | #include "cxio_hal.h" | ||
44 | |||
45 | extern int cxio_hal_init_rhdl_resource(u32 nr_rhdl); | ||
46 | extern void cxio_hal_destroy_rhdl_resource(void); | ||
47 | extern int cxio_hal_init_resource(struct cxio_rdev *rdev_p, | ||
48 | u32 nr_tpt, u32 nr_pbl, | ||
49 | u32 nr_rqt, u32 nr_qpid, u32 nr_cqid, | ||
50 | u32 nr_pdid); | ||
51 | extern u32 cxio_hal_get_stag(struct cxio_hal_resource *rscp); | ||
52 | extern void cxio_hal_put_stag(struct cxio_hal_resource *rscp, u32 stag); | ||
53 | extern u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp); | ||
54 | extern void cxio_hal_put_qpid(struct cxio_hal_resource *rscp, u32 qpid); | ||
55 | extern u32 cxio_hal_get_cqid(struct cxio_hal_resource *rscp); | ||
56 | extern void cxio_hal_put_cqid(struct cxio_hal_resource *rscp, u32 cqid); | ||
57 | extern void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp); | ||
58 | |||
59 | #define PBL_OFF(rdev_p, a) ( (a) - (rdev_p)->rnic_info.pbl_base ) | ||
60 | extern int cxio_hal_pblpool_create(struct cxio_rdev *rdev_p); | ||
61 | extern void cxio_hal_pblpool_destroy(struct cxio_rdev *rdev_p); | ||
62 | extern u32 cxio_hal_pblpool_alloc(struct cxio_rdev *rdev_p, int size); | ||
63 | extern void cxio_hal_pblpool_free(struct cxio_rdev *rdev_p, u32 addr, int size); | ||
64 | |||
65 | #define RQT_OFF(rdev_p, a) ( (a) - (rdev_p)->rnic_info.rqt_base ) | ||
66 | extern int cxio_hal_rqtpool_create(struct cxio_rdev *rdev_p); | ||
67 | extern void cxio_hal_rqtpool_destroy(struct cxio_rdev *rdev_p); | ||
68 | extern u32 cxio_hal_rqtpool_alloc(struct cxio_rdev *rdev_p, int size); | ||
69 | extern void cxio_hal_rqtpool_free(struct cxio_rdev *rdev_p, u32 addr, int size); | ||
70 | #endif | ||
diff --git a/drivers/infiniband/hw/cxgb3/cxio_wr.h b/drivers/infiniband/hw/cxgb3/cxio_wr.h new file mode 100644 index 000000000000..103fc42d6976 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/cxio_wr.h | |||
@@ -0,0 +1,685 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #ifndef __CXIO_WR_H__ | ||
34 | #define __CXIO_WR_H__ | ||
35 | |||
36 | #include <asm/io.h> | ||
37 | #include <linux/pci.h> | ||
38 | #include <linux/timer.h> | ||
39 | #include "firmware_exports.h" | ||
40 | |||
41 | #define T3_MAX_SGE 4 | ||
42 | |||
43 | #define Q_EMPTY(rptr,wptr) ((rptr)==(wptr)) | ||
44 | #define Q_FULL(rptr,wptr,size_log2) ( (((wptr)-(rptr))>>(size_log2)) && \ | ||
45 | ((rptr)!=(wptr)) ) | ||
46 | #define Q_GENBIT(ptr,size_log2) (!(((ptr)>>size_log2)&0x1)) | ||
47 | #define Q_FREECNT(rptr,wptr,size_log2) ((1UL<<size_log2)-((wptr)-(rptr))) | ||
48 | #define Q_COUNT(rptr,wptr) ((wptr)-(rptr)) | ||
49 | #define Q_PTR2IDX(ptr,size_log2) (ptr & ((1UL<<size_log2)-1)) | ||
50 | |||
51 | static inline void ring_doorbell(void __iomem *doorbell, u32 qpid) | ||
52 | { | ||
53 | writel(((1<<31) | qpid), doorbell); | ||
54 | } | ||
55 | |||
56 | #define SEQ32_GE(x,y) (!( (((u32) (x)) - ((u32) (y))) & 0x80000000 )) | ||
57 | |||
58 | enum t3_wr_flags { | ||
59 | T3_COMPLETION_FLAG = 0x01, | ||
60 | T3_NOTIFY_FLAG = 0x02, | ||
61 | T3_SOLICITED_EVENT_FLAG = 0x04, | ||
62 | T3_READ_FENCE_FLAG = 0x08, | ||
63 | T3_LOCAL_FENCE_FLAG = 0x10 | ||
64 | } __attribute__ ((packed)); | ||
65 | |||
66 | enum t3_wr_opcode { | ||
67 | T3_WR_BP = FW_WROPCODE_RI_BYPASS, | ||
68 | T3_WR_SEND = FW_WROPCODE_RI_SEND, | ||
69 | T3_WR_WRITE = FW_WROPCODE_RI_RDMA_WRITE, | ||
70 | T3_WR_READ = FW_WROPCODE_RI_RDMA_READ, | ||
71 | T3_WR_INV_STAG = FW_WROPCODE_RI_LOCAL_INV, | ||
72 | T3_WR_BIND = FW_WROPCODE_RI_BIND_MW, | ||
73 | T3_WR_RCV = FW_WROPCODE_RI_RECEIVE, | ||
74 | T3_WR_INIT = FW_WROPCODE_RI_RDMA_INIT, | ||
75 | T3_WR_QP_MOD = FW_WROPCODE_RI_MODIFY_QP | ||
76 | } __attribute__ ((packed)); | ||
77 | |||
78 | enum t3_rdma_opcode { | ||
79 | T3_RDMA_WRITE, /* IETF RDMAP v1.0 ... */ | ||
80 | T3_READ_REQ, | ||
81 | T3_READ_RESP, | ||
82 | T3_SEND, | ||
83 | T3_SEND_WITH_INV, | ||
84 | T3_SEND_WITH_SE, | ||
85 | T3_SEND_WITH_SE_INV, | ||
86 | T3_TERMINATE, | ||
87 | T3_RDMA_INIT, /* CHELSIO RI specific ... */ | ||
88 | T3_BIND_MW, | ||
89 | T3_FAST_REGISTER, | ||
90 | T3_LOCAL_INV, | ||
91 | T3_QP_MOD, | ||
92 | T3_BYPASS | ||
93 | } __attribute__ ((packed)); | ||
94 | |||
95 | static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop) | ||
96 | { | ||
97 | switch (wrop) { | ||
98 | case T3_WR_BP: return T3_BYPASS; | ||
99 | case T3_WR_SEND: return T3_SEND; | ||
100 | case T3_WR_WRITE: return T3_RDMA_WRITE; | ||
101 | case T3_WR_READ: return T3_READ_REQ; | ||
102 | case T3_WR_INV_STAG: return T3_LOCAL_INV; | ||
103 | case T3_WR_BIND: return T3_BIND_MW; | ||
104 | case T3_WR_INIT: return T3_RDMA_INIT; | ||
105 | case T3_WR_QP_MOD: return T3_QP_MOD; | ||
106 | default: break; | ||
107 | } | ||
108 | return -1; | ||
109 | } | ||
110 | |||
111 | |||
112 | /* Work request id */ | ||
113 | union t3_wrid { | ||
114 | struct { | ||
115 | u32 hi; | ||
116 | u32 low; | ||
117 | } id0; | ||
118 | u64 id1; | ||
119 | }; | ||
120 | |||
121 | #define WRID(wrid) (wrid.id1) | ||
122 | #define WRID_GEN(wrid) (wrid.id0.wr_gen) | ||
123 | #define WRID_IDX(wrid) (wrid.id0.wr_idx) | ||
124 | #define WRID_LO(wrid) (wrid.id0.wr_lo) | ||
125 | |||
126 | struct fw_riwrh { | ||
127 | __be32 op_seop_flags; | ||
128 | __be32 gen_tid_len; | ||
129 | }; | ||
130 | |||
131 | #define S_FW_RIWR_OP 24 | ||
132 | #define M_FW_RIWR_OP 0xff | ||
133 | #define V_FW_RIWR_OP(x) ((x) << S_FW_RIWR_OP) | ||
134 | #define G_FW_RIWR_OP(x) ((((x) >> S_FW_RIWR_OP)) & M_FW_RIWR_OP) | ||
135 | |||
136 | #define S_FW_RIWR_SOPEOP 22 | ||
137 | #define M_FW_RIWR_SOPEOP 0x3 | ||
138 | #define V_FW_RIWR_SOPEOP(x) ((x) << S_FW_RIWR_SOPEOP) | ||
139 | |||
140 | #define S_FW_RIWR_FLAGS 8 | ||
141 | #define M_FW_RIWR_FLAGS 0x3fffff | ||
142 | #define V_FW_RIWR_FLAGS(x) ((x) << S_FW_RIWR_FLAGS) | ||
143 | #define G_FW_RIWR_FLAGS(x) ((((x) >> S_FW_RIWR_FLAGS)) & M_FW_RIWR_FLAGS) | ||
144 | |||
145 | #define S_FW_RIWR_TID 8 | ||
146 | #define V_FW_RIWR_TID(x) ((x) << S_FW_RIWR_TID) | ||
147 | |||
148 | #define S_FW_RIWR_LEN 0 | ||
149 | #define V_FW_RIWR_LEN(x) ((x) << S_FW_RIWR_LEN) | ||
150 | |||
151 | #define S_FW_RIWR_GEN 31 | ||
152 | #define V_FW_RIWR_GEN(x) ((x) << S_FW_RIWR_GEN) | ||
153 | |||
154 | struct t3_sge { | ||
155 | __be32 stag; | ||
156 | __be32 len; | ||
157 | __be64 to; | ||
158 | }; | ||
159 | |||
160 | /* If num_sgle is zero, flit 5+ contains immediate data.*/ | ||
161 | struct t3_send_wr { | ||
162 | struct fw_riwrh wrh; /* 0 */ | ||
163 | union t3_wrid wrid; /* 1 */ | ||
164 | |||
165 | u8 rdmaop; /* 2 */ | ||
166 | u8 reserved[3]; | ||
167 | __be32 rem_stag; | ||
168 | __be32 plen; /* 3 */ | ||
169 | __be32 num_sgle; | ||
170 | struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */ | ||
171 | }; | ||
172 | |||
173 | struct t3_local_inv_wr { | ||
174 | struct fw_riwrh wrh; /* 0 */ | ||
175 | union t3_wrid wrid; /* 1 */ | ||
176 | __be32 stag; /* 2 */ | ||
177 | __be32 reserved3; | ||
178 | }; | ||
179 | |||
180 | struct t3_rdma_write_wr { | ||
181 | struct fw_riwrh wrh; /* 0 */ | ||
182 | union t3_wrid wrid; /* 1 */ | ||
183 | u8 rdmaop; /* 2 */ | ||
184 | u8 reserved[3]; | ||
185 | __be32 stag_sink; | ||
186 | __be64 to_sink; /* 3 */ | ||
187 | __be32 plen; /* 4 */ | ||
188 | __be32 num_sgle; | ||
189 | struct t3_sge sgl[T3_MAX_SGE]; /* 5+ */ | ||
190 | }; | ||
191 | |||
192 | struct t3_rdma_read_wr { | ||
193 | struct fw_riwrh wrh; /* 0 */ | ||
194 | union t3_wrid wrid; /* 1 */ | ||
195 | u8 rdmaop; /* 2 */ | ||
196 | u8 reserved[3]; | ||
197 | __be32 rem_stag; | ||
198 | __be64 rem_to; /* 3 */ | ||
199 | __be32 local_stag; /* 4 */ | ||
200 | __be32 local_len; | ||
201 | __be64 local_to; /* 5 */ | ||
202 | }; | ||
203 | |||
204 | enum t3_addr_type { | ||
205 | T3_VA_BASED_TO = 0x0, | ||
206 | T3_ZERO_BASED_TO = 0x1 | ||
207 | } __attribute__ ((packed)); | ||
208 | |||
209 | enum t3_mem_perms { | ||
210 | T3_MEM_ACCESS_LOCAL_READ = 0x1, | ||
211 | T3_MEM_ACCESS_LOCAL_WRITE = 0x2, | ||
212 | T3_MEM_ACCESS_REM_READ = 0x4, | ||
213 | T3_MEM_ACCESS_REM_WRITE = 0x8 | ||
214 | } __attribute__ ((packed)); | ||
215 | |||
216 | struct t3_bind_mw_wr { | ||
217 | struct fw_riwrh wrh; /* 0 */ | ||
218 | union t3_wrid wrid; /* 1 */ | ||
219 | u16 reserved; /* 2 */ | ||
220 | u8 type; | ||
221 | u8 perms; | ||
222 | __be32 mr_stag; | ||
223 | __be32 mw_stag; /* 3 */ | ||
224 | __be32 mw_len; | ||
225 | __be64 mw_va; /* 4 */ | ||
226 | __be32 mr_pbl_addr; /* 5 */ | ||
227 | u8 reserved2[3]; | ||
228 | u8 mr_pagesz; | ||
229 | }; | ||
230 | |||
231 | struct t3_receive_wr { | ||
232 | struct fw_riwrh wrh; /* 0 */ | ||
233 | union t3_wrid wrid; /* 1 */ | ||
234 | u8 pagesz[T3_MAX_SGE]; | ||
235 | __be32 num_sgle; /* 2 */ | ||
236 | struct t3_sge sgl[T3_MAX_SGE]; /* 3+ */ | ||
237 | __be32 pbl_addr[T3_MAX_SGE]; | ||
238 | }; | ||
239 | |||
240 | struct t3_bypass_wr { | ||
241 | struct fw_riwrh wrh; | ||
242 | union t3_wrid wrid; /* 1 */ | ||
243 | }; | ||
244 | |||
245 | struct t3_modify_qp_wr { | ||
246 | struct fw_riwrh wrh; /* 0 */ | ||
247 | union t3_wrid wrid; /* 1 */ | ||
248 | __be32 flags; /* 2 */ | ||
249 | __be32 quiesce; /* 2 */ | ||
250 | __be32 max_ird; /* 3 */ | ||
251 | __be32 max_ord; /* 3 */ | ||
252 | __be64 sge_cmd; /* 4 */ | ||
253 | __be64 ctx1; /* 5 */ | ||
254 | __be64 ctx0; /* 6 */ | ||
255 | }; | ||
256 | |||
257 | enum t3_modify_qp_flags { | ||
258 | MODQP_QUIESCE = 0x01, | ||
259 | MODQP_MAX_IRD = 0x02, | ||
260 | MODQP_MAX_ORD = 0x04, | ||
261 | MODQP_WRITE_EC = 0x08, | ||
262 | MODQP_READ_EC = 0x10, | ||
263 | }; | ||
264 | |||
265 | |||
266 | enum t3_mpa_attrs { | ||
267 | uP_RI_MPA_RX_MARKER_ENABLE = 0x1, | ||
268 | uP_RI_MPA_TX_MARKER_ENABLE = 0x2, | ||
269 | uP_RI_MPA_CRC_ENABLE = 0x4, | ||
270 | uP_RI_MPA_IETF_ENABLE = 0x8 | ||
271 | } __attribute__ ((packed)); | ||
272 | |||
273 | enum t3_qp_caps { | ||
274 | uP_RI_QP_RDMA_READ_ENABLE = 0x01, | ||
275 | uP_RI_QP_RDMA_WRITE_ENABLE = 0x02, | ||
276 | uP_RI_QP_BIND_ENABLE = 0x04, | ||
277 | uP_RI_QP_FAST_REGISTER_ENABLE = 0x08, | ||
278 | uP_RI_QP_STAG0_ENABLE = 0x10 | ||
279 | } __attribute__ ((packed)); | ||
280 | |||
281 | struct t3_rdma_init_attr { | ||
282 | u32 tid; | ||
283 | u32 qpid; | ||
284 | u32 pdid; | ||
285 | u32 scqid; | ||
286 | u32 rcqid; | ||
287 | u32 rq_addr; | ||
288 | u32 rq_size; | ||
289 | enum t3_mpa_attrs mpaattrs; | ||
290 | enum t3_qp_caps qpcaps; | ||
291 | u16 tcp_emss; | ||
292 | u32 ord; | ||
293 | u32 ird; | ||
294 | u64 qp_dma_addr; | ||
295 | u32 qp_dma_size; | ||
296 | u32 flags; | ||
297 | }; | ||
298 | |||
299 | struct t3_rdma_init_wr { | ||
300 | struct fw_riwrh wrh; /* 0 */ | ||
301 | union t3_wrid wrid; /* 1 */ | ||
302 | __be32 qpid; /* 2 */ | ||
303 | __be32 pdid; | ||
304 | __be32 scqid; /* 3 */ | ||
305 | __be32 rcqid; | ||
306 | __be32 rq_addr; /* 4 */ | ||
307 | __be32 rq_size; | ||
308 | u8 mpaattrs; /* 5 */ | ||
309 | u8 qpcaps; | ||
310 | __be16 ulpdu_size; | ||
311 | __be32 flags; /* bits 31-1 - reservered */ | ||
312 | /* bit 0 - set if RECV posted */ | ||
313 | __be32 ord; /* 6 */ | ||
314 | __be32 ird; | ||
315 | __be64 qp_dma_addr; /* 7 */ | ||
316 | __be32 qp_dma_size; /* 8 */ | ||
317 | u32 rsvd; | ||
318 | }; | ||
319 | |||
320 | struct t3_genbit { | ||
321 | u64 flit[15]; | ||
322 | __be64 genbit; | ||
323 | }; | ||
324 | |||
325 | enum rdma_init_wr_flags { | ||
326 | RECVS_POSTED = 1, | ||
327 | }; | ||
328 | |||
329 | union t3_wr { | ||
330 | struct t3_send_wr send; | ||
331 | struct t3_rdma_write_wr write; | ||
332 | struct t3_rdma_read_wr read; | ||
333 | struct t3_receive_wr recv; | ||
334 | struct t3_local_inv_wr local_inv; | ||
335 | struct t3_bind_mw_wr bind; | ||
336 | struct t3_bypass_wr bypass; | ||
337 | struct t3_rdma_init_wr init; | ||
338 | struct t3_modify_qp_wr qp_mod; | ||
339 | struct t3_genbit genbit; | ||
340 | u64 flit[16]; | ||
341 | }; | ||
342 | |||
343 | #define T3_SQ_CQE_FLIT 13 | ||
344 | #define T3_SQ_COOKIE_FLIT 14 | ||
345 | |||
346 | #define T3_RQ_COOKIE_FLIT 13 | ||
347 | #define T3_RQ_CQE_FLIT 14 | ||
348 | |||
349 | static inline enum t3_wr_opcode fw_riwrh_opcode(struct fw_riwrh *wqe) | ||
350 | { | ||
351 | return G_FW_RIWR_OP(be32_to_cpu(wqe->op_seop_flags)); | ||
352 | } | ||
353 | |||
354 | static inline void build_fw_riwrh(struct fw_riwrh *wqe, enum t3_wr_opcode op, | ||
355 | enum t3_wr_flags flags, u8 genbit, u32 tid, | ||
356 | u8 len) | ||
357 | { | ||
358 | wqe->op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(op) | | ||
359 | V_FW_RIWR_SOPEOP(M_FW_RIWR_SOPEOP) | | ||
360 | V_FW_RIWR_FLAGS(flags)); | ||
361 | wmb(); | ||
362 | wqe->gen_tid_len = cpu_to_be32(V_FW_RIWR_GEN(genbit) | | ||
363 | V_FW_RIWR_TID(tid) | | ||
364 | V_FW_RIWR_LEN(len)); | ||
365 | /* 2nd gen bit... */ | ||
366 | ((union t3_wr *)wqe)->genbit.genbit = cpu_to_be64(genbit); | ||
367 | } | ||
368 | |||
369 | /* | ||
370 | * T3 ULP2_TX commands | ||
371 | */ | ||
372 | enum t3_utx_mem_op { | ||
373 | T3_UTX_MEM_READ = 2, | ||
374 | T3_UTX_MEM_WRITE = 3 | ||
375 | }; | ||
376 | |||
377 | /* T3 MC7 RDMA TPT entry format */ | ||
378 | |||
379 | enum tpt_mem_type { | ||
380 | TPT_NON_SHARED_MR = 0x0, | ||
381 | TPT_SHARED_MR = 0x1, | ||
382 | TPT_MW = 0x2, | ||
383 | TPT_MW_RELAXED_PROTECTION = 0x3 | ||
384 | }; | ||
385 | |||
386 | enum tpt_addr_type { | ||
387 | TPT_ZBTO = 0, | ||
388 | TPT_VATO = 1 | ||
389 | }; | ||
390 | |||
391 | enum tpt_mem_perm { | ||
392 | TPT_LOCAL_READ = 0x8, | ||
393 | TPT_LOCAL_WRITE = 0x4, | ||
394 | TPT_REMOTE_READ = 0x2, | ||
395 | TPT_REMOTE_WRITE = 0x1 | ||
396 | }; | ||
397 | |||
398 | struct tpt_entry { | ||
399 | __be32 valid_stag_pdid; | ||
400 | __be32 flags_pagesize_qpid; | ||
401 | |||
402 | __be32 rsvd_pbl_addr; | ||
403 | __be32 len; | ||
404 | __be32 va_hi; | ||
405 | __be32 va_low_or_fbo; | ||
406 | |||
407 | __be32 rsvd_bind_cnt_or_pstag; | ||
408 | __be32 rsvd_pbl_size; | ||
409 | }; | ||
410 | |||
411 | #define S_TPT_VALID 31 | ||
412 | #define V_TPT_VALID(x) ((x) << S_TPT_VALID) | ||
413 | #define F_TPT_VALID V_TPT_VALID(1U) | ||
414 | |||
415 | #define S_TPT_STAG_KEY 23 | ||
416 | #define M_TPT_STAG_KEY 0xFF | ||
417 | #define V_TPT_STAG_KEY(x) ((x) << S_TPT_STAG_KEY) | ||
418 | #define G_TPT_STAG_KEY(x) (((x) >> S_TPT_STAG_KEY) & M_TPT_STAG_KEY) | ||
419 | |||
420 | #define S_TPT_STAG_STATE 22 | ||
421 | #define V_TPT_STAG_STATE(x) ((x) << S_TPT_STAG_STATE) | ||
422 | #define F_TPT_STAG_STATE V_TPT_STAG_STATE(1U) | ||
423 | |||
424 | #define S_TPT_STAG_TYPE 20 | ||
425 | #define M_TPT_STAG_TYPE 0x3 | ||
426 | #define V_TPT_STAG_TYPE(x) ((x) << S_TPT_STAG_TYPE) | ||
427 | #define G_TPT_STAG_TYPE(x) (((x) >> S_TPT_STAG_TYPE) & M_TPT_STAG_TYPE) | ||
428 | |||
429 | #define S_TPT_PDID 0 | ||
430 | #define M_TPT_PDID 0xFFFFF | ||
431 | #define V_TPT_PDID(x) ((x) << S_TPT_PDID) | ||
432 | #define G_TPT_PDID(x) (((x) >> S_TPT_PDID) & M_TPT_PDID) | ||
433 | |||
434 | #define S_TPT_PERM 28 | ||
435 | #define M_TPT_PERM 0xF | ||
436 | #define V_TPT_PERM(x) ((x) << S_TPT_PERM) | ||
437 | #define G_TPT_PERM(x) (((x) >> S_TPT_PERM) & M_TPT_PERM) | ||
438 | |||
439 | #define S_TPT_REM_INV_DIS 27 | ||
440 | #define V_TPT_REM_INV_DIS(x) ((x) << S_TPT_REM_INV_DIS) | ||
441 | #define F_TPT_REM_INV_DIS V_TPT_REM_INV_DIS(1U) | ||
442 | |||
443 | #define S_TPT_ADDR_TYPE 26 | ||
444 | #define V_TPT_ADDR_TYPE(x) ((x) << S_TPT_ADDR_TYPE) | ||
445 | #define F_TPT_ADDR_TYPE V_TPT_ADDR_TYPE(1U) | ||
446 | |||
447 | #define S_TPT_MW_BIND_ENABLE 25 | ||
448 | #define V_TPT_MW_BIND_ENABLE(x) ((x) << S_TPT_MW_BIND_ENABLE) | ||
449 | #define F_TPT_MW_BIND_ENABLE V_TPT_MW_BIND_ENABLE(1U) | ||
450 | |||
451 | #define S_TPT_PAGE_SIZE 20 | ||
452 | #define M_TPT_PAGE_SIZE 0x1F | ||
453 | #define V_TPT_PAGE_SIZE(x) ((x) << S_TPT_PAGE_SIZE) | ||
454 | #define G_TPT_PAGE_SIZE(x) (((x) >> S_TPT_PAGE_SIZE) & M_TPT_PAGE_SIZE) | ||
455 | |||
456 | #define S_TPT_PBL_ADDR 0 | ||
457 | #define M_TPT_PBL_ADDR 0x1FFFFFFF | ||
458 | #define V_TPT_PBL_ADDR(x) ((x) << S_TPT_PBL_ADDR) | ||
459 | #define G_TPT_PBL_ADDR(x) (((x) >> S_TPT_PBL_ADDR) & M_TPT_PBL_ADDR) | ||
460 | |||
461 | #define S_TPT_QPID 0 | ||
462 | #define M_TPT_QPID 0xFFFFF | ||
463 | #define V_TPT_QPID(x) ((x) << S_TPT_QPID) | ||
464 | #define G_TPT_QPID(x) (((x) >> S_TPT_QPID) & M_TPT_QPID) | ||
465 | |||
466 | #define S_TPT_PSTAG 0 | ||
467 | #define M_TPT_PSTAG 0xFFFFFF | ||
468 | #define V_TPT_PSTAG(x) ((x) << S_TPT_PSTAG) | ||
469 | #define G_TPT_PSTAG(x) (((x) >> S_TPT_PSTAG) & M_TPT_PSTAG) | ||
470 | |||
471 | #define S_TPT_PBL_SIZE 0 | ||
472 | #define M_TPT_PBL_SIZE 0xFFFFF | ||
473 | #define V_TPT_PBL_SIZE(x) ((x) << S_TPT_PBL_SIZE) | ||
474 | #define G_TPT_PBL_SIZE(x) (((x) >> S_TPT_PBL_SIZE) & M_TPT_PBL_SIZE) | ||
475 | |||
476 | /* | ||
477 | * CQE defs | ||
478 | */ | ||
479 | struct t3_cqe { | ||
480 | __be32 header; | ||
481 | __be32 len; | ||
482 | union { | ||
483 | struct { | ||
484 | __be32 stag; | ||
485 | __be32 msn; | ||
486 | } rcqe; | ||
487 | struct { | ||
488 | u32 wrid_hi; | ||
489 | u32 wrid_low; | ||
490 | } scqe; | ||
491 | } u; | ||
492 | }; | ||
493 | |||
494 | #define S_CQE_OOO 31 | ||
495 | #define M_CQE_OOO 0x1 | ||
496 | #define G_CQE_OOO(x) ((((x) >> S_CQE_OOO)) & M_CQE_OOO) | ||
497 | #define V_CEQ_OOO(x) ((x)<<S_CQE_OOO) | ||
498 | |||
499 | #define S_CQE_QPID 12 | ||
500 | #define M_CQE_QPID 0x7FFFF | ||
501 | #define G_CQE_QPID(x) ((((x) >> S_CQE_QPID)) & M_CQE_QPID) | ||
502 | #define V_CQE_QPID(x) ((x)<<S_CQE_QPID) | ||
503 | |||
504 | #define S_CQE_SWCQE 11 | ||
505 | #define M_CQE_SWCQE 0x1 | ||
506 | #define G_CQE_SWCQE(x) ((((x) >> S_CQE_SWCQE)) & M_CQE_SWCQE) | ||
507 | #define V_CQE_SWCQE(x) ((x)<<S_CQE_SWCQE) | ||
508 | |||
509 | #define S_CQE_GENBIT 10 | ||
510 | #define M_CQE_GENBIT 0x1 | ||
511 | #define G_CQE_GENBIT(x) (((x) >> S_CQE_GENBIT) & M_CQE_GENBIT) | ||
512 | #define V_CQE_GENBIT(x) ((x)<<S_CQE_GENBIT) | ||
513 | |||
514 | #define S_CQE_STATUS 5 | ||
515 | #define M_CQE_STATUS 0x1F | ||
516 | #define G_CQE_STATUS(x) ((((x) >> S_CQE_STATUS)) & M_CQE_STATUS) | ||
517 | #define V_CQE_STATUS(x) ((x)<<S_CQE_STATUS) | ||
518 | |||
519 | #define S_CQE_TYPE 4 | ||
520 | #define M_CQE_TYPE 0x1 | ||
521 | #define G_CQE_TYPE(x) ((((x) >> S_CQE_TYPE)) & M_CQE_TYPE) | ||
522 | #define V_CQE_TYPE(x) ((x)<<S_CQE_TYPE) | ||
523 | |||
524 | #define S_CQE_OPCODE 0 | ||
525 | #define M_CQE_OPCODE 0xF | ||
526 | #define G_CQE_OPCODE(x) ((((x) >> S_CQE_OPCODE)) & M_CQE_OPCODE) | ||
527 | #define V_CQE_OPCODE(x) ((x)<<S_CQE_OPCODE) | ||
528 | |||
529 | #define SW_CQE(x) (G_CQE_SWCQE(be32_to_cpu((x).header))) | ||
530 | #define CQE_OOO(x) (G_CQE_OOO(be32_to_cpu((x).header))) | ||
531 | #define CQE_QPID(x) (G_CQE_QPID(be32_to_cpu((x).header))) | ||
532 | #define CQE_GENBIT(x) (G_CQE_GENBIT(be32_to_cpu((x).header))) | ||
533 | #define CQE_TYPE(x) (G_CQE_TYPE(be32_to_cpu((x).header))) | ||
534 | #define SQ_TYPE(x) (CQE_TYPE((x))) | ||
535 | #define RQ_TYPE(x) (!CQE_TYPE((x))) | ||
536 | #define CQE_STATUS(x) (G_CQE_STATUS(be32_to_cpu((x).header))) | ||
537 | #define CQE_OPCODE(x) (G_CQE_OPCODE(be32_to_cpu((x).header))) | ||
538 | |||
539 | #define CQE_LEN(x) (be32_to_cpu((x).len)) | ||
540 | |||
541 | /* used for RQ completion processing */ | ||
542 | #define CQE_WRID_STAG(x) (be32_to_cpu((x).u.rcqe.stag)) | ||
543 | #define CQE_WRID_MSN(x) (be32_to_cpu((x).u.rcqe.msn)) | ||
544 | |||
545 | /* used for SQ completion processing */ | ||
546 | #define CQE_WRID_SQ_WPTR(x) ((x).u.scqe.wrid_hi) | ||
547 | #define CQE_WRID_WPTR(x) ((x).u.scqe.wrid_low) | ||
548 | |||
549 | /* generic accessor macros */ | ||
550 | #define CQE_WRID_HI(x) ((x).u.scqe.wrid_hi) | ||
551 | #define CQE_WRID_LOW(x) ((x).u.scqe.wrid_low) | ||
552 | |||
553 | #define TPT_ERR_SUCCESS 0x0 | ||
554 | #define TPT_ERR_STAG 0x1 /* STAG invalid: either the */ | ||
555 | /* STAG is offlimt, being 0, */ | ||
556 | /* or STAG_key mismatch */ | ||
557 | #define TPT_ERR_PDID 0x2 /* PDID mismatch */ | ||
558 | #define TPT_ERR_QPID 0x3 /* QPID mismatch */ | ||
559 | #define TPT_ERR_ACCESS 0x4 /* Invalid access right */ | ||
560 | #define TPT_ERR_WRAP 0x5 /* Wrap error */ | ||
561 | #define TPT_ERR_BOUND 0x6 /* base and bounds voilation */ | ||
562 | #define TPT_ERR_INVALIDATE_SHARED_MR 0x7 /* attempt to invalidate a */ | ||
563 | /* shared memory region */ | ||
564 | #define TPT_ERR_INVALIDATE_MR_WITH_MW_BOUND 0x8 /* attempt to invalidate a */ | ||
565 | /* shared memory region */ | ||
566 | #define TPT_ERR_ECC 0x9 /* ECC error detected */ | ||
567 | #define TPT_ERR_ECC_PSTAG 0xA /* ECC error detected when */ | ||
568 | /* reading PSTAG for a MW */ | ||
569 | /* Invalidate */ | ||
570 | #define TPT_ERR_PBL_ADDR_BOUND 0xB /* pbl addr out of bounds: */ | ||
571 | /* software error */ | ||
572 | #define TPT_ERR_SWFLUSH 0xC /* SW FLUSHED */ | ||
573 | #define TPT_ERR_CRC 0x10 /* CRC error */ | ||
574 | #define TPT_ERR_MARKER 0x11 /* Marker error */ | ||
575 | #define TPT_ERR_PDU_LEN_ERR 0x12 /* invalid PDU length */ | ||
576 | #define TPT_ERR_OUT_OF_RQE 0x13 /* out of RQE */ | ||
577 | #define TPT_ERR_DDP_VERSION 0x14 /* wrong DDP version */ | ||
578 | #define TPT_ERR_RDMA_VERSION 0x15 /* wrong RDMA version */ | ||
579 | #define TPT_ERR_OPCODE 0x16 /* invalid rdma opcode */ | ||
580 | #define TPT_ERR_DDP_QUEUE_NUM 0x17 /* invalid ddp queue number */ | ||
581 | #define TPT_ERR_MSN 0x18 /* MSN error */ | ||
582 | #define TPT_ERR_TBIT 0x19 /* tag bit not set correctly */ | ||
583 | #define TPT_ERR_MO 0x1A /* MO not 0 for TERMINATE */ | ||
584 | /* or READ_REQ */ | ||
585 | #define TPT_ERR_MSN_GAP 0x1B | ||
586 | #define TPT_ERR_MSN_RANGE 0x1C | ||
587 | #define TPT_ERR_IRD_OVERFLOW 0x1D | ||
588 | #define TPT_ERR_RQE_ADDR_BOUND 0x1E /* RQE addr out of bounds: */ | ||
589 | /* software error */ | ||
590 | #define TPT_ERR_INTERNAL_ERR 0x1F /* internal error (opcode */ | ||
591 | /* mismatch) */ | ||
592 | |||
593 | struct t3_swsq { | ||
594 | __u64 wr_id; | ||
595 | struct t3_cqe cqe; | ||
596 | __u32 sq_wptr; | ||
597 | __be32 read_len; | ||
598 | int opcode; | ||
599 | int complete; | ||
600 | int signaled; | ||
601 | }; | ||
602 | |||
603 | /* | ||
604 | * A T3 WQ implements both the SQ and RQ. | ||
605 | */ | ||
606 | struct t3_wq { | ||
607 | union t3_wr *queue; /* DMA accessable memory */ | ||
608 | dma_addr_t dma_addr; /* DMA address for HW */ | ||
609 | DECLARE_PCI_UNMAP_ADDR(mapping) /* unmap kruft */ | ||
610 | u32 error; /* 1 once we go to ERROR */ | ||
611 | u32 qpid; | ||
612 | u32 wptr; /* idx to next available WR slot */ | ||
613 | u32 size_log2; /* total wq size */ | ||
614 | struct t3_swsq *sq; /* SW SQ */ | ||
615 | struct t3_swsq *oldest_read; /* tracks oldest pending read */ | ||
616 | u32 sq_wptr; /* sq_wptr - sq_rptr == count of */ | ||
617 | u32 sq_rptr; /* pending wrs */ | ||
618 | u32 sq_size_log2; /* sq size */ | ||
619 | u64 *rq; /* SW RQ (holds consumer wr_ids */ | ||
620 | u32 rq_wptr; /* rq_wptr - rq_rptr == count of */ | ||
621 | u32 rq_rptr; /* pending wrs */ | ||
622 | u64 *rq_oldest_wr; /* oldest wr on the SW RQ */ | ||
623 | u32 rq_size_log2; /* rq size */ | ||
624 | u32 rq_addr; /* rq adapter address */ | ||
625 | void __iomem *doorbell; /* kernel db */ | ||
626 | u64 udb; /* user db if any */ | ||
627 | }; | ||
628 | |||
629 | struct t3_cq { | ||
630 | u32 cqid; | ||
631 | u32 rptr; | ||
632 | u32 wptr; | ||
633 | u32 size_log2; | ||
634 | dma_addr_t dma_addr; | ||
635 | DECLARE_PCI_UNMAP_ADDR(mapping) | ||
636 | struct t3_cqe *queue; | ||
637 | struct t3_cqe *sw_queue; | ||
638 | u32 sw_rptr; | ||
639 | u32 sw_wptr; | ||
640 | }; | ||
641 | |||
642 | #define CQ_VLD_ENTRY(ptr,size_log2,cqe) (Q_GENBIT(ptr,size_log2) == \ | ||
643 | CQE_GENBIT(*cqe)) | ||
644 | |||
645 | static inline void cxio_set_wq_in_error(struct t3_wq *wq) | ||
646 | { | ||
647 | wq->queue->flit[13] = 1; | ||
648 | } | ||
649 | |||
650 | static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq) | ||
651 | { | ||
652 | struct t3_cqe *cqe; | ||
653 | |||
654 | cqe = cq->queue + (Q_PTR2IDX(cq->rptr, cq->size_log2)); | ||
655 | if (CQ_VLD_ENTRY(cq->rptr, cq->size_log2, cqe)) | ||
656 | return cqe; | ||
657 | return NULL; | ||
658 | } | ||
659 | |||
660 | static inline struct t3_cqe *cxio_next_sw_cqe(struct t3_cq *cq) | ||
661 | { | ||
662 | struct t3_cqe *cqe; | ||
663 | |||
664 | if (!Q_EMPTY(cq->sw_rptr, cq->sw_wptr)) { | ||
665 | cqe = cq->sw_queue + (Q_PTR2IDX(cq->sw_rptr, cq->size_log2)); | ||
666 | return cqe; | ||
667 | } | ||
668 | return NULL; | ||
669 | } | ||
670 | |||
671 | static inline struct t3_cqe *cxio_next_cqe(struct t3_cq *cq) | ||
672 | { | ||
673 | struct t3_cqe *cqe; | ||
674 | |||
675 | if (!Q_EMPTY(cq->sw_rptr, cq->sw_wptr)) { | ||
676 | cqe = cq->sw_queue + (Q_PTR2IDX(cq->sw_rptr, cq->size_log2)); | ||
677 | return cqe; | ||
678 | } | ||
679 | cqe = cq->queue + (Q_PTR2IDX(cq->rptr, cq->size_log2)); | ||
680 | if (CQ_VLD_ENTRY(cq->rptr, cq->size_log2, cqe)) | ||
681 | return cqe; | ||
682 | return NULL; | ||
683 | } | ||
684 | |||
685 | #endif | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch.c b/drivers/infiniband/hw/cxgb3/iwch.c new file mode 100644 index 000000000000..4611afa52220 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch.c | |||
@@ -0,0 +1,189 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #include <linux/module.h> | ||
34 | #include <linux/moduleparam.h> | ||
35 | |||
36 | #include <rdma/ib_verbs.h> | ||
37 | |||
38 | #include "cxgb3_offload.h" | ||
39 | #include "iwch_provider.h" | ||
40 | #include "iwch_user.h" | ||
41 | #include "iwch.h" | ||
42 | #include "iwch_cm.h" | ||
43 | |||
44 | #define DRV_VERSION "1.1" | ||
45 | |||
46 | MODULE_AUTHOR("Boyd Faulkner, Steve Wise"); | ||
47 | MODULE_DESCRIPTION("Chelsio T3 RDMA Driver"); | ||
48 | MODULE_LICENSE("Dual BSD/GPL"); | ||
49 | MODULE_VERSION(DRV_VERSION); | ||
50 | |||
51 | cxgb3_cpl_handler_func t3c_handlers[NUM_CPL_CMDS]; | ||
52 | |||
53 | static void open_rnic_dev(struct t3cdev *); | ||
54 | static void close_rnic_dev(struct t3cdev *); | ||
55 | |||
56 | struct cxgb3_client t3c_client = { | ||
57 | .name = "iw_cxgb3", | ||
58 | .add = open_rnic_dev, | ||
59 | .remove = close_rnic_dev, | ||
60 | .handlers = t3c_handlers, | ||
61 | .redirect = iwch_ep_redirect | ||
62 | }; | ||
63 | |||
64 | static LIST_HEAD(dev_list); | ||
65 | static DEFINE_MUTEX(dev_mutex); | ||
66 | |||
67 | static void rnic_init(struct iwch_dev *rnicp) | ||
68 | { | ||
69 | PDBG("%s iwch_dev %p\n", __FUNCTION__, rnicp); | ||
70 | idr_init(&rnicp->cqidr); | ||
71 | idr_init(&rnicp->qpidr); | ||
72 | idr_init(&rnicp->mmidr); | ||
73 | spin_lock_init(&rnicp->lock); | ||
74 | |||
75 | rnicp->attr.vendor_id = 0x168; | ||
76 | rnicp->attr.vendor_part_id = 7; | ||
77 | rnicp->attr.max_qps = T3_MAX_NUM_QP - 32; | ||
78 | rnicp->attr.max_wrs = (1UL << 24) - 1; | ||
79 | rnicp->attr.max_sge_per_wr = T3_MAX_SGE; | ||
80 | rnicp->attr.max_sge_per_rdma_write_wr = T3_MAX_SGE; | ||
81 | rnicp->attr.max_cqs = T3_MAX_NUM_CQ - 1; | ||
82 | rnicp->attr.max_cqes_per_cq = (1UL << 24) - 1; | ||
83 | rnicp->attr.max_mem_regs = cxio_num_stags(&rnicp->rdev); | ||
84 | rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE; | ||
85 | rnicp->attr.max_pds = T3_MAX_NUM_PD - 1; | ||
86 | rnicp->attr.mem_pgsizes_bitmask = 0x7FFF; /* 4KB-128MB */ | ||
87 | rnicp->attr.can_resize_wq = 0; | ||
88 | rnicp->attr.max_rdma_reads_per_qp = 8; | ||
89 | rnicp->attr.max_rdma_read_resources = | ||
90 | rnicp->attr.max_rdma_reads_per_qp * rnicp->attr.max_qps; | ||
91 | rnicp->attr.max_rdma_read_qp_depth = 8; /* IRD */ | ||
92 | rnicp->attr.max_rdma_read_depth = | ||
93 | rnicp->attr.max_rdma_read_qp_depth * rnicp->attr.max_qps; | ||
94 | rnicp->attr.rq_overflow_handled = 0; | ||
95 | rnicp->attr.can_modify_ird = 0; | ||
96 | rnicp->attr.can_modify_ord = 0; | ||
97 | rnicp->attr.max_mem_windows = rnicp->attr.max_mem_regs - 1; | ||
98 | rnicp->attr.stag0_value = 1; | ||
99 | rnicp->attr.zbva_support = 1; | ||
100 | rnicp->attr.local_invalidate_fence = 1; | ||
101 | rnicp->attr.cq_overflow_detection = 1; | ||
102 | return; | ||
103 | } | ||
104 | |||
105 | static void open_rnic_dev(struct t3cdev *tdev) | ||
106 | { | ||
107 | struct iwch_dev *rnicp; | ||
108 | static int vers_printed; | ||
109 | |||
110 | PDBG("%s t3cdev %p\n", __FUNCTION__, tdev); | ||
111 | if (!vers_printed++) | ||
112 | printk(KERN_INFO MOD "Chelsio T3 RDMA Driver - version %s\n", | ||
113 | DRV_VERSION); | ||
114 | rnicp = (struct iwch_dev *)ib_alloc_device(sizeof(*rnicp)); | ||
115 | if (!rnicp) { | ||
116 | printk(KERN_ERR MOD "Cannot allocate ib device\n"); | ||
117 | return; | ||
118 | } | ||
119 | rnicp->rdev.ulp = rnicp; | ||
120 | rnicp->rdev.t3cdev_p = tdev; | ||
121 | |||
122 | mutex_lock(&dev_mutex); | ||
123 | |||
124 | if (cxio_rdev_open(&rnicp->rdev)) { | ||
125 | mutex_unlock(&dev_mutex); | ||
126 | printk(KERN_ERR MOD "Unable to open CXIO rdev\n"); | ||
127 | ib_dealloc_device(&rnicp->ibdev); | ||
128 | return; | ||
129 | } | ||
130 | |||
131 | rnic_init(rnicp); | ||
132 | |||
133 | list_add_tail(&rnicp->entry, &dev_list); | ||
134 | mutex_unlock(&dev_mutex); | ||
135 | |||
136 | if (iwch_register_device(rnicp)) { | ||
137 | printk(KERN_ERR MOD "Unable to register device\n"); | ||
138 | close_rnic_dev(tdev); | ||
139 | } | ||
140 | printk(KERN_INFO MOD "Initialized device %s\n", | ||
141 | pci_name(rnicp->rdev.rnic_info.pdev)); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | static void close_rnic_dev(struct t3cdev *tdev) | ||
146 | { | ||
147 | struct iwch_dev *dev, *tmp; | ||
148 | PDBG("%s t3cdev %p\n", __FUNCTION__, tdev); | ||
149 | mutex_lock(&dev_mutex); | ||
150 | list_for_each_entry_safe(dev, tmp, &dev_list, entry) { | ||
151 | if (dev->rdev.t3cdev_p == tdev) { | ||
152 | list_del(&dev->entry); | ||
153 | iwch_unregister_device(dev); | ||
154 | cxio_rdev_close(&dev->rdev); | ||
155 | idr_destroy(&dev->cqidr); | ||
156 | idr_destroy(&dev->qpidr); | ||
157 | idr_destroy(&dev->mmidr); | ||
158 | ib_dealloc_device(&dev->ibdev); | ||
159 | break; | ||
160 | } | ||
161 | } | ||
162 | mutex_unlock(&dev_mutex); | ||
163 | } | ||
164 | |||
165 | static int __init iwch_init_module(void) | ||
166 | { | ||
167 | int err; | ||
168 | |||
169 | err = cxio_hal_init(); | ||
170 | if (err) | ||
171 | return err; | ||
172 | err = iwch_cm_init(); | ||
173 | if (err) | ||
174 | return err; | ||
175 | cxio_register_ev_cb(iwch_ev_dispatch); | ||
176 | cxgb3_register_client(&t3c_client); | ||
177 | return 0; | ||
178 | } | ||
179 | |||
180 | static void __exit iwch_exit_module(void) | ||
181 | { | ||
182 | cxgb3_unregister_client(&t3c_client); | ||
183 | cxio_unregister_ev_cb(iwch_ev_dispatch); | ||
184 | iwch_cm_term(); | ||
185 | cxio_hal_exit(); | ||
186 | } | ||
187 | |||
188 | module_init(iwch_init_module); | ||
189 | module_exit(iwch_exit_module); | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch.h b/drivers/infiniband/hw/cxgb3/iwch.h new file mode 100644 index 000000000000..6517ef85026f --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch.h | |||
@@ -0,0 +1,177 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #ifndef __IWCH_H__ | ||
34 | #define __IWCH_H__ | ||
35 | |||
36 | #include <linux/mutex.h> | ||
37 | #include <linux/list.h> | ||
38 | #include <linux/spinlock.h> | ||
39 | #include <linux/idr.h> | ||
40 | |||
41 | #include <rdma/ib_verbs.h> | ||
42 | |||
43 | #include "cxio_hal.h" | ||
44 | #include "cxgb3_offload.h" | ||
45 | |||
46 | struct iwch_pd; | ||
47 | struct iwch_cq; | ||
48 | struct iwch_qp; | ||
49 | struct iwch_mr; | ||
50 | |||
51 | struct iwch_rnic_attributes { | ||
52 | u32 vendor_id; | ||
53 | u32 vendor_part_id; | ||
54 | u32 max_qps; | ||
55 | u32 max_wrs; /* Max for any SQ/RQ */ | ||
56 | u32 max_sge_per_wr; | ||
57 | u32 max_sge_per_rdma_write_wr; /* for RDMA Write WR */ | ||
58 | u32 max_cqs; | ||
59 | u32 max_cqes_per_cq; | ||
60 | u32 max_mem_regs; | ||
61 | u32 max_phys_buf_entries; /* for phys buf list */ | ||
62 | u32 max_pds; | ||
63 | |||
64 | /* | ||
65 | * The memory page sizes supported by this RNIC. | ||
66 | * Bit position i in bitmap indicates page of | ||
67 | * size (4k)^i. Phys block list mode unsupported. | ||
68 | */ | ||
69 | u32 mem_pgsizes_bitmask; | ||
70 | u8 can_resize_wq; | ||
71 | |||
72 | /* | ||
73 | * The maximum number of RDMA Reads that can be outstanding | ||
74 | * per QP with this RNIC as the target. | ||
75 | */ | ||
76 | u32 max_rdma_reads_per_qp; | ||
77 | |||
78 | /* | ||
79 | * The maximum number of resources used for RDMA Reads | ||
80 | * by this RNIC with this RNIC as the target. | ||
81 | */ | ||
82 | u32 max_rdma_read_resources; | ||
83 | |||
84 | /* | ||
85 | * The max depth per QP for initiation of RDMA Read | ||
86 | * by this RNIC. | ||
87 | */ | ||
88 | u32 max_rdma_read_qp_depth; | ||
89 | |||
90 | /* | ||
91 | * The maximum depth for initiation of RDMA Read | ||
92 | * operations by this RNIC on all QPs | ||
93 | */ | ||
94 | u32 max_rdma_read_depth; | ||
95 | u8 rq_overflow_handled; | ||
96 | u32 can_modify_ird; | ||
97 | u32 can_modify_ord; | ||
98 | u32 max_mem_windows; | ||
99 | u32 stag0_value; | ||
100 | u8 zbva_support; | ||
101 | u8 local_invalidate_fence; | ||
102 | u32 cq_overflow_detection; | ||
103 | }; | ||
104 | |||
105 | struct iwch_dev { | ||
106 | struct ib_device ibdev; | ||
107 | struct cxio_rdev rdev; | ||
108 | u32 device_cap_flags; | ||
109 | struct iwch_rnic_attributes attr; | ||
110 | struct idr cqidr; | ||
111 | struct idr qpidr; | ||
112 | struct idr mmidr; | ||
113 | spinlock_t lock; | ||
114 | struct list_head entry; | ||
115 | }; | ||
116 | |||
117 | static inline struct iwch_dev *to_iwch_dev(struct ib_device *ibdev) | ||
118 | { | ||
119 | return container_of(ibdev, struct iwch_dev, ibdev); | ||
120 | } | ||
121 | |||
122 | static inline int t3b_device(const struct iwch_dev *rhp) | ||
123 | { | ||
124 | return rhp->rdev.t3cdev_p->type == T3B; | ||
125 | } | ||
126 | |||
127 | static inline int t3a_device(const struct iwch_dev *rhp) | ||
128 | { | ||
129 | return rhp->rdev.t3cdev_p->type == T3A; | ||
130 | } | ||
131 | |||
132 | static inline struct iwch_cq *get_chp(struct iwch_dev *rhp, u32 cqid) | ||
133 | { | ||
134 | return idr_find(&rhp->cqidr, cqid); | ||
135 | } | ||
136 | |||
137 | static inline struct iwch_qp *get_qhp(struct iwch_dev *rhp, u32 qpid) | ||
138 | { | ||
139 | return idr_find(&rhp->qpidr, qpid); | ||
140 | } | ||
141 | |||
142 | static inline struct iwch_mr *get_mhp(struct iwch_dev *rhp, u32 mmid) | ||
143 | { | ||
144 | return idr_find(&rhp->mmidr, mmid); | ||
145 | } | ||
146 | |||
147 | static inline int insert_handle(struct iwch_dev *rhp, struct idr *idr, | ||
148 | void *handle, u32 id) | ||
149 | { | ||
150 | int ret; | ||
151 | u32 newid; | ||
152 | |||
153 | do { | ||
154 | if (!idr_pre_get(idr, GFP_KERNEL)) { | ||
155 | return -ENOMEM; | ||
156 | } | ||
157 | spin_lock_irq(&rhp->lock); | ||
158 | ret = idr_get_new_above(idr, handle, id, &newid); | ||
159 | BUG_ON(newid != id); | ||
160 | spin_unlock_irq(&rhp->lock); | ||
161 | } while (ret == -EAGAIN); | ||
162 | |||
163 | return ret; | ||
164 | } | ||
165 | |||
166 | static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id) | ||
167 | { | ||
168 | spin_lock_irq(&rhp->lock); | ||
169 | idr_remove(idr, id); | ||
170 | spin_unlock_irq(&rhp->lock); | ||
171 | } | ||
172 | |||
173 | extern struct cxgb3_client t3c_client; | ||
174 | extern cxgb3_cpl_handler_func t3c_handlers[NUM_CPL_CMDS]; | ||
175 | extern void iwch_ev_dispatch(struct cxio_rdev *rdev_p, struct sk_buff *skb); | ||
176 | |||
177 | #endif | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c new file mode 100644 index 000000000000..a522b1baa3b4 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c | |||
@@ -0,0 +1,2081 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #include <linux/module.h> | ||
34 | #include <linux/list.h> | ||
35 | #include <linux/workqueue.h> | ||
36 | #include <linux/skbuff.h> | ||
37 | #include <linux/timer.h> | ||
38 | #include <linux/notifier.h> | ||
39 | |||
40 | #include <net/neighbour.h> | ||
41 | #include <net/netevent.h> | ||
42 | #include <net/route.h> | ||
43 | |||
44 | #include "tcb.h" | ||
45 | #include "cxgb3_offload.h" | ||
46 | #include "iwch.h" | ||
47 | #include "iwch_provider.h" | ||
48 | #include "iwch_cm.h" | ||
49 | |||
50 | static char *states[] = { | ||
51 | "idle", | ||
52 | "listen", | ||
53 | "connecting", | ||
54 | "mpa_wait_req", | ||
55 | "mpa_req_sent", | ||
56 | "mpa_req_rcvd", | ||
57 | "mpa_rep_sent", | ||
58 | "fpdu_mode", | ||
59 | "aborting", | ||
60 | "closing", | ||
61 | "moribund", | ||
62 | "dead", | ||
63 | NULL, | ||
64 | }; | ||
65 | |||
66 | static int ep_timeout_secs = 10; | ||
67 | module_param(ep_timeout_secs, int, 0444); | ||
68 | MODULE_PARM_DESC(ep_timeout_secs, "CM Endpoint operation timeout " | ||
69 | "in seconds (default=10)"); | ||
70 | |||
71 | static int mpa_rev = 1; | ||
72 | module_param(mpa_rev, int, 0444); | ||
73 | MODULE_PARM_DESC(mpa_rev, "MPA Revision, 0 supports amso1100, " | ||
74 | "1 is spec compliant. (default=1)"); | ||
75 | |||
76 | static int markers_enabled = 0; | ||
77 | module_param(markers_enabled, int, 0444); | ||
78 | MODULE_PARM_DESC(markers_enabled, "Enable MPA MARKERS (default(0)=disabled)"); | ||
79 | |||
80 | static int crc_enabled = 1; | ||
81 | module_param(crc_enabled, int, 0444); | ||
82 | MODULE_PARM_DESC(crc_enabled, "Enable MPA CRC (default(1)=enabled)"); | ||
83 | |||
84 | static int rcv_win = 256 * 1024; | ||
85 | module_param(rcv_win, int, 0444); | ||
86 | MODULE_PARM_DESC(rcv_win, "TCP receive window in bytes (default=256)"); | ||
87 | |||
88 | static int snd_win = 32 * 1024; | ||
89 | module_param(snd_win, int, 0444); | ||
90 | MODULE_PARM_DESC(snd_win, "TCP send window in bytes (default=32KB)"); | ||
91 | |||
92 | static unsigned int nocong = 0; | ||
93 | module_param(nocong, uint, 0444); | ||
94 | MODULE_PARM_DESC(nocong, "Turn off congestion control (default=0)"); | ||
95 | |||
96 | static unsigned int cong_flavor = 1; | ||
97 | module_param(cong_flavor, uint, 0444); | ||
98 | MODULE_PARM_DESC(cong_flavor, "TCP Congestion control flavor (default=1)"); | ||
99 | |||
100 | static void process_work(struct work_struct *work); | ||
101 | static struct workqueue_struct *workq; | ||
102 | static DECLARE_WORK(skb_work, process_work); | ||
103 | |||
104 | static struct sk_buff_head rxq; | ||
105 | static cxgb3_cpl_handler_func work_handlers[NUM_CPL_CMDS]; | ||
106 | |||
107 | static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp); | ||
108 | static void ep_timeout(unsigned long arg); | ||
109 | static void connect_reply_upcall(struct iwch_ep *ep, int status); | ||
110 | |||
111 | static void start_ep_timer(struct iwch_ep *ep) | ||
112 | { | ||
113 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
114 | if (timer_pending(&ep->timer)) { | ||
115 | PDBG("%s stopped / restarted timer ep %p\n", __FUNCTION__, ep); | ||
116 | del_timer_sync(&ep->timer); | ||
117 | } else | ||
118 | get_ep(&ep->com); | ||
119 | ep->timer.expires = jiffies + ep_timeout_secs * HZ; | ||
120 | ep->timer.data = (unsigned long)ep; | ||
121 | ep->timer.function = ep_timeout; | ||
122 | add_timer(&ep->timer); | ||
123 | } | ||
124 | |||
125 | static void stop_ep_timer(struct iwch_ep *ep) | ||
126 | { | ||
127 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
128 | del_timer_sync(&ep->timer); | ||
129 | put_ep(&ep->com); | ||
130 | } | ||
131 | |||
132 | static void release_tid(struct t3cdev *tdev, u32 hwtid, struct sk_buff *skb) | ||
133 | { | ||
134 | struct cpl_tid_release *req; | ||
135 | |||
136 | skb = get_skb(skb, sizeof *req, GFP_KERNEL); | ||
137 | if (!skb) | ||
138 | return; | ||
139 | req = (struct cpl_tid_release *) skb_put(skb, sizeof(*req)); | ||
140 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | ||
141 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_TID_RELEASE, hwtid)); | ||
142 | skb->priority = CPL_PRIORITY_SETUP; | ||
143 | tdev->send(tdev, skb); | ||
144 | return; | ||
145 | } | ||
146 | |||
147 | int iwch_quiesce_tid(struct iwch_ep *ep) | ||
148 | { | ||
149 | struct cpl_set_tcb_field *req; | ||
150 | struct sk_buff *skb = get_skb(NULL, sizeof(*req), GFP_KERNEL); | ||
151 | |||
152 | if (!skb) | ||
153 | return -ENOMEM; | ||
154 | req = (struct cpl_set_tcb_field *) skb_put(skb, sizeof(*req)); | ||
155 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | ||
156 | req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid)); | ||
157 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SET_TCB_FIELD, ep->hwtid)); | ||
158 | req->reply = 0; | ||
159 | req->cpu_idx = 0; | ||
160 | req->word = htons(W_TCB_RX_QUIESCE); | ||
161 | req->mask = cpu_to_be64(1ULL << S_TCB_RX_QUIESCE); | ||
162 | req->val = cpu_to_be64(1 << S_TCB_RX_QUIESCE); | ||
163 | |||
164 | skb->priority = CPL_PRIORITY_DATA; | ||
165 | ep->com.tdev->send(ep->com.tdev, skb); | ||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | int iwch_resume_tid(struct iwch_ep *ep) | ||
170 | { | ||
171 | struct cpl_set_tcb_field *req; | ||
172 | struct sk_buff *skb = get_skb(NULL, sizeof(*req), GFP_KERNEL); | ||
173 | |||
174 | if (!skb) | ||
175 | return -ENOMEM; | ||
176 | req = (struct cpl_set_tcb_field *) skb_put(skb, sizeof(*req)); | ||
177 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | ||
178 | req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid)); | ||
179 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SET_TCB_FIELD, ep->hwtid)); | ||
180 | req->reply = 0; | ||
181 | req->cpu_idx = 0; | ||
182 | req->word = htons(W_TCB_RX_QUIESCE); | ||
183 | req->mask = cpu_to_be64(1ULL << S_TCB_RX_QUIESCE); | ||
184 | req->val = 0; | ||
185 | |||
186 | skb->priority = CPL_PRIORITY_DATA; | ||
187 | ep->com.tdev->send(ep->com.tdev, skb); | ||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | static void set_emss(struct iwch_ep *ep, u16 opt) | ||
192 | { | ||
193 | PDBG("%s ep %p opt %u\n", __FUNCTION__, ep, opt); | ||
194 | ep->emss = T3C_DATA(ep->com.tdev)->mtus[G_TCPOPT_MSS(opt)] - 40; | ||
195 | if (G_TCPOPT_TSTAMP(opt)) | ||
196 | ep->emss -= 12; | ||
197 | if (ep->emss < 128) | ||
198 | ep->emss = 128; | ||
199 | PDBG("emss=%d\n", ep->emss); | ||
200 | } | ||
201 | |||
202 | static enum iwch_ep_state state_read(struct iwch_ep_common *epc) | ||
203 | { | ||
204 | unsigned long flags; | ||
205 | enum iwch_ep_state state; | ||
206 | |||
207 | spin_lock_irqsave(&epc->lock, flags); | ||
208 | state = epc->state; | ||
209 | spin_unlock_irqrestore(&epc->lock, flags); | ||
210 | return state; | ||
211 | } | ||
212 | |||
213 | static inline void __state_set(struct iwch_ep_common *epc, | ||
214 | enum iwch_ep_state new) | ||
215 | { | ||
216 | epc->state = new; | ||
217 | } | ||
218 | |||
219 | static void state_set(struct iwch_ep_common *epc, enum iwch_ep_state new) | ||
220 | { | ||
221 | unsigned long flags; | ||
222 | |||
223 | spin_lock_irqsave(&epc->lock, flags); | ||
224 | PDBG("%s - %s -> %s\n", __FUNCTION__, states[epc->state], states[new]); | ||
225 | __state_set(epc, new); | ||
226 | spin_unlock_irqrestore(&epc->lock, flags); | ||
227 | return; | ||
228 | } | ||
229 | |||
230 | static void *alloc_ep(int size, gfp_t gfp) | ||
231 | { | ||
232 | struct iwch_ep_common *epc; | ||
233 | |||
234 | epc = kmalloc(size, gfp); | ||
235 | if (epc) { | ||
236 | memset(epc, 0, size); | ||
237 | kref_init(&epc->kref); | ||
238 | spin_lock_init(&epc->lock); | ||
239 | init_waitqueue_head(&epc->waitq); | ||
240 | } | ||
241 | PDBG("%s alloc ep %p\n", __FUNCTION__, epc); | ||
242 | return epc; | ||
243 | } | ||
244 | |||
245 | void __free_ep(struct kref *kref) | ||
246 | { | ||
247 | struct iwch_ep_common *epc; | ||
248 | epc = container_of(kref, struct iwch_ep_common, kref); | ||
249 | PDBG("%s ep %p state %s\n", __FUNCTION__, epc, states[state_read(epc)]); | ||
250 | kfree(epc); | ||
251 | } | ||
252 | |||
253 | static void release_ep_resources(struct iwch_ep *ep) | ||
254 | { | ||
255 | PDBG("%s ep %p tid %d\n", __FUNCTION__, ep, ep->hwtid); | ||
256 | cxgb3_remove_tid(ep->com.tdev, (void *)ep, ep->hwtid); | ||
257 | dst_release(ep->dst); | ||
258 | l2t_release(L2DATA(ep->com.tdev), ep->l2t); | ||
259 | if (ep->com.tdev->type == T3B) | ||
260 | release_tid(ep->com.tdev, ep->hwtid, NULL); | ||
261 | put_ep(&ep->com); | ||
262 | } | ||
263 | |||
264 | static void process_work(struct work_struct *work) | ||
265 | { | ||
266 | struct sk_buff *skb = NULL; | ||
267 | void *ep; | ||
268 | struct t3cdev *tdev; | ||
269 | int ret; | ||
270 | |||
271 | while ((skb = skb_dequeue(&rxq))) { | ||
272 | ep = *((void **) (skb->cb)); | ||
273 | tdev = *((struct t3cdev **) (skb->cb + sizeof(void *))); | ||
274 | ret = work_handlers[G_OPCODE(ntohl((__force __be32)skb->csum))](tdev, skb, ep); | ||
275 | if (ret & CPL_RET_BUF_DONE) | ||
276 | kfree_skb(skb); | ||
277 | |||
278 | /* | ||
279 | * ep was referenced in sched(), and is freed here. | ||
280 | */ | ||
281 | put_ep((struct iwch_ep_common *)ep); | ||
282 | } | ||
283 | } | ||
284 | |||
285 | static int status2errno(int status) | ||
286 | { | ||
287 | switch (status) { | ||
288 | case CPL_ERR_NONE: | ||
289 | return 0; | ||
290 | case CPL_ERR_CONN_RESET: | ||
291 | return -ECONNRESET; | ||
292 | case CPL_ERR_ARP_MISS: | ||
293 | return -EHOSTUNREACH; | ||
294 | case CPL_ERR_CONN_TIMEDOUT: | ||
295 | return -ETIMEDOUT; | ||
296 | case CPL_ERR_TCAM_FULL: | ||
297 | return -ENOMEM; | ||
298 | case CPL_ERR_CONN_EXIST: | ||
299 | return -EADDRINUSE; | ||
300 | default: | ||
301 | return -EIO; | ||
302 | } | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | * Try and reuse skbs already allocated... | ||
307 | */ | ||
308 | static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp) | ||
309 | { | ||
310 | if (skb) { | ||
311 | BUG_ON(skb_cloned(skb)); | ||
312 | skb_trim(skb, 0); | ||
313 | skb_get(skb); | ||
314 | } else { | ||
315 | skb = alloc_skb(len, gfp); | ||
316 | } | ||
317 | return skb; | ||
318 | } | ||
319 | |||
320 | static struct rtable *find_route(struct t3cdev *dev, __be32 local_ip, | ||
321 | __be32 peer_ip, __be16 local_port, | ||
322 | __be16 peer_port, u8 tos) | ||
323 | { | ||
324 | struct rtable *rt; | ||
325 | struct flowi fl = { | ||
326 | .oif = 0, | ||
327 | .nl_u = { | ||
328 | .ip4_u = { | ||
329 | .daddr = peer_ip, | ||
330 | .saddr = local_ip, | ||
331 | .tos = tos} | ||
332 | }, | ||
333 | .proto = IPPROTO_TCP, | ||
334 | .uli_u = { | ||
335 | .ports = { | ||
336 | .sport = local_port, | ||
337 | .dport = peer_port} | ||
338 | } | ||
339 | }; | ||
340 | |||
341 | if (ip_route_output_flow(&rt, &fl, NULL, 0)) | ||
342 | return NULL; | ||
343 | return rt; | ||
344 | } | ||
345 | |||
346 | static unsigned int find_best_mtu(const struct t3c_data *d, unsigned short mtu) | ||
347 | { | ||
348 | int i = 0; | ||
349 | |||
350 | while (i < d->nmtus - 1 && d->mtus[i + 1] <= mtu) | ||
351 | ++i; | ||
352 | return i; | ||
353 | } | ||
354 | |||
355 | static void arp_failure_discard(struct t3cdev *dev, struct sk_buff *skb) | ||
356 | { | ||
357 | PDBG("%s t3cdev %p\n", __FUNCTION__, dev); | ||
358 | kfree_skb(skb); | ||
359 | } | ||
360 | |||
361 | /* | ||
362 | * Handle an ARP failure for an active open. | ||
363 | */ | ||
364 | static void act_open_req_arp_failure(struct t3cdev *dev, struct sk_buff *skb) | ||
365 | { | ||
366 | printk(KERN_ERR MOD "ARP failure duing connect\n"); | ||
367 | kfree_skb(skb); | ||
368 | } | ||
369 | |||
370 | /* | ||
371 | * Handle an ARP failure for a CPL_ABORT_REQ. Change it into a no RST variant | ||
372 | * and send it along. | ||
373 | */ | ||
374 | static void abort_arp_failure(struct t3cdev *dev, struct sk_buff *skb) | ||
375 | { | ||
376 | struct cpl_abort_req *req = cplhdr(skb); | ||
377 | |||
378 | PDBG("%s t3cdev %p\n", __FUNCTION__, dev); | ||
379 | req->cmd = CPL_ABORT_NO_RST; | ||
380 | cxgb3_ofld_send(dev, skb); | ||
381 | } | ||
382 | |||
383 | static int send_halfclose(struct iwch_ep *ep, gfp_t gfp) | ||
384 | { | ||
385 | struct cpl_close_con_req *req; | ||
386 | struct sk_buff *skb; | ||
387 | |||
388 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
389 | skb = get_skb(NULL, sizeof(*req), gfp); | ||
390 | if (!skb) { | ||
391 | printk(KERN_ERR MOD "%s - failed to alloc skb\n", __FUNCTION__); | ||
392 | return -ENOMEM; | ||
393 | } | ||
394 | skb->priority = CPL_PRIORITY_DATA; | ||
395 | set_arp_failure_handler(skb, arp_failure_discard); | ||
396 | req = (struct cpl_close_con_req *) skb_put(skb, sizeof(*req)); | ||
397 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_CLOSE_CON)); | ||
398 | req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid)); | ||
399 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_CON_REQ, ep->hwtid)); | ||
400 | l2t_send(ep->com.tdev, skb, ep->l2t); | ||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | static int send_abort(struct iwch_ep *ep, struct sk_buff *skb, gfp_t gfp) | ||
405 | { | ||
406 | struct cpl_abort_req *req; | ||
407 | |||
408 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
409 | skb = get_skb(skb, sizeof(*req), gfp); | ||
410 | if (!skb) { | ||
411 | printk(KERN_ERR MOD "%s - failed to alloc skb.\n", | ||
412 | __FUNCTION__); | ||
413 | return -ENOMEM; | ||
414 | } | ||
415 | skb->priority = CPL_PRIORITY_DATA; | ||
416 | set_arp_failure_handler(skb, abort_arp_failure); | ||
417 | req = (struct cpl_abort_req *) skb_put(skb, sizeof(*req)); | ||
418 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_REQ)); | ||
419 | req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid)); | ||
420 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ABORT_REQ, ep->hwtid)); | ||
421 | req->cmd = CPL_ABORT_SEND_RST; | ||
422 | l2t_send(ep->com.tdev, skb, ep->l2t); | ||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | static int send_connect(struct iwch_ep *ep) | ||
427 | { | ||
428 | struct cpl_act_open_req *req; | ||
429 | struct sk_buff *skb; | ||
430 | u32 opt0h, opt0l, opt2; | ||
431 | unsigned int mtu_idx; | ||
432 | int wscale; | ||
433 | |||
434 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
435 | |||
436 | skb = get_skb(NULL, sizeof(*req), GFP_KERNEL); | ||
437 | if (!skb) { | ||
438 | printk(KERN_ERR MOD "%s - failed to alloc skb.\n", | ||
439 | __FUNCTION__); | ||
440 | return -ENOMEM; | ||
441 | } | ||
442 | mtu_idx = find_best_mtu(T3C_DATA(ep->com.tdev), dst_mtu(ep->dst)); | ||
443 | wscale = compute_wscale(rcv_win); | ||
444 | opt0h = V_NAGLE(0) | | ||
445 | V_NO_CONG(nocong) | | ||
446 | V_KEEP_ALIVE(1) | | ||
447 | F_TCAM_BYPASS | | ||
448 | V_WND_SCALE(wscale) | | ||
449 | V_MSS_IDX(mtu_idx) | | ||
450 | V_L2T_IDX(ep->l2t->idx) | V_TX_CHANNEL(ep->l2t->smt_idx); | ||
451 | opt0l = V_TOS((ep->tos >> 2) & M_TOS) | V_RCV_BUFSIZ(rcv_win>>10); | ||
452 | opt2 = V_FLAVORS_VALID(1) | V_CONG_CONTROL_FLAVOR(cong_flavor); | ||
453 | skb->priority = CPL_PRIORITY_SETUP; | ||
454 | set_arp_failure_handler(skb, act_open_req_arp_failure); | ||
455 | |||
456 | req = (struct cpl_act_open_req *) skb_put(skb, sizeof(*req)); | ||
457 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | ||
458 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ACT_OPEN_REQ, ep->atid)); | ||
459 | req->local_port = ep->com.local_addr.sin_port; | ||
460 | req->peer_port = ep->com.remote_addr.sin_port; | ||
461 | req->local_ip = ep->com.local_addr.sin_addr.s_addr; | ||
462 | req->peer_ip = ep->com.remote_addr.sin_addr.s_addr; | ||
463 | req->opt0h = htonl(opt0h); | ||
464 | req->opt0l = htonl(opt0l); | ||
465 | req->params = 0; | ||
466 | req->opt2 = htonl(opt2); | ||
467 | l2t_send(ep->com.tdev, skb, ep->l2t); | ||
468 | return 0; | ||
469 | } | ||
470 | |||
471 | static void send_mpa_req(struct iwch_ep *ep, struct sk_buff *skb) | ||
472 | { | ||
473 | int mpalen; | ||
474 | struct tx_data_wr *req; | ||
475 | struct mpa_message *mpa; | ||
476 | int len; | ||
477 | |||
478 | PDBG("%s ep %p pd_len %d\n", __FUNCTION__, ep, ep->plen); | ||
479 | |||
480 | BUG_ON(skb_cloned(skb)); | ||
481 | |||
482 | mpalen = sizeof(*mpa) + ep->plen; | ||
483 | if (skb->data + mpalen + sizeof(*req) > skb->end) { | ||
484 | kfree_skb(skb); | ||
485 | skb=alloc_skb(mpalen + sizeof(*req), GFP_KERNEL); | ||
486 | if (!skb) { | ||
487 | connect_reply_upcall(ep, -ENOMEM); | ||
488 | return; | ||
489 | } | ||
490 | } | ||
491 | skb_trim(skb, 0); | ||
492 | skb_reserve(skb, sizeof(*req)); | ||
493 | skb_put(skb, mpalen); | ||
494 | skb->priority = CPL_PRIORITY_DATA; | ||
495 | mpa = (struct mpa_message *) skb->data; | ||
496 | memset(mpa, 0, sizeof(*mpa)); | ||
497 | memcpy(mpa->key, MPA_KEY_REQ, sizeof(mpa->key)); | ||
498 | mpa->flags = (crc_enabled ? MPA_CRC : 0) | | ||
499 | (markers_enabled ? MPA_MARKERS : 0); | ||
500 | mpa->private_data_size = htons(ep->plen); | ||
501 | mpa->revision = mpa_rev; | ||
502 | |||
503 | if (ep->plen) | ||
504 | memcpy(mpa->private_data, ep->mpa_pkt + sizeof(*mpa), ep->plen); | ||
505 | |||
506 | /* | ||
507 | * Reference the mpa skb. This ensures the data area | ||
508 | * will remain in memory until the hw acks the tx. | ||
509 | * Function tx_ack() will deref it. | ||
510 | */ | ||
511 | skb_get(skb); | ||
512 | set_arp_failure_handler(skb, arp_failure_discard); | ||
513 | skb->h.raw = skb->data; | ||
514 | len = skb->len; | ||
515 | req = (struct tx_data_wr *) skb_push(skb, sizeof(*req)); | ||
516 | req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)); | ||
517 | req->wr_lo = htonl(V_WR_TID(ep->hwtid)); | ||
518 | req->len = htonl(len); | ||
519 | req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) | | ||
520 | V_TX_SNDBUF(snd_win>>15)); | ||
521 | req->flags = htonl(F_TX_IMM_ACK|F_TX_INIT); | ||
522 | req->sndseq = htonl(ep->snd_seq); | ||
523 | BUG_ON(ep->mpa_skb); | ||
524 | ep->mpa_skb = skb; | ||
525 | l2t_send(ep->com.tdev, skb, ep->l2t); | ||
526 | start_ep_timer(ep); | ||
527 | state_set(&ep->com, MPA_REQ_SENT); | ||
528 | return; | ||
529 | } | ||
530 | |||
531 | static int send_mpa_reject(struct iwch_ep *ep, const void *pdata, u8 plen) | ||
532 | { | ||
533 | int mpalen; | ||
534 | struct tx_data_wr *req; | ||
535 | struct mpa_message *mpa; | ||
536 | struct sk_buff *skb; | ||
537 | |||
538 | PDBG("%s ep %p plen %d\n", __FUNCTION__, ep, plen); | ||
539 | |||
540 | mpalen = sizeof(*mpa) + plen; | ||
541 | |||
542 | skb = get_skb(NULL, mpalen + sizeof(*req), GFP_KERNEL); | ||
543 | if (!skb) { | ||
544 | printk(KERN_ERR MOD "%s - cannot alloc skb!\n", __FUNCTION__); | ||
545 | return -ENOMEM; | ||
546 | } | ||
547 | skb_reserve(skb, sizeof(*req)); | ||
548 | mpa = (struct mpa_message *) skb_put(skb, mpalen); | ||
549 | memset(mpa, 0, sizeof(*mpa)); | ||
550 | memcpy(mpa->key, MPA_KEY_REP, sizeof(mpa->key)); | ||
551 | mpa->flags = MPA_REJECT; | ||
552 | mpa->revision = mpa_rev; | ||
553 | mpa->private_data_size = htons(plen); | ||
554 | if (plen) | ||
555 | memcpy(mpa->private_data, pdata, plen); | ||
556 | |||
557 | /* | ||
558 | * Reference the mpa skb again. This ensures the data area | ||
559 | * will remain in memory until the hw acks the tx. | ||
560 | * Function tx_ack() will deref it. | ||
561 | */ | ||
562 | skb_get(skb); | ||
563 | skb->priority = CPL_PRIORITY_DATA; | ||
564 | set_arp_failure_handler(skb, arp_failure_discard); | ||
565 | skb->h.raw = skb->data; | ||
566 | req = (struct tx_data_wr *) skb_push(skb, sizeof(*req)); | ||
567 | req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)); | ||
568 | req->wr_lo = htonl(V_WR_TID(ep->hwtid)); | ||
569 | req->len = htonl(mpalen); | ||
570 | req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) | | ||
571 | V_TX_SNDBUF(snd_win>>15)); | ||
572 | req->flags = htonl(F_TX_IMM_ACK|F_TX_INIT); | ||
573 | req->sndseq = htonl(ep->snd_seq); | ||
574 | BUG_ON(ep->mpa_skb); | ||
575 | ep->mpa_skb = skb; | ||
576 | l2t_send(ep->com.tdev, skb, ep->l2t); | ||
577 | return 0; | ||
578 | } | ||
579 | |||
580 | static int send_mpa_reply(struct iwch_ep *ep, const void *pdata, u8 plen) | ||
581 | { | ||
582 | int mpalen; | ||
583 | struct tx_data_wr *req; | ||
584 | struct mpa_message *mpa; | ||
585 | int len; | ||
586 | struct sk_buff *skb; | ||
587 | |||
588 | PDBG("%s ep %p plen %d\n", __FUNCTION__, ep, plen); | ||
589 | |||
590 | mpalen = sizeof(*mpa) + plen; | ||
591 | |||
592 | skb = get_skb(NULL, mpalen + sizeof(*req), GFP_KERNEL); | ||
593 | if (!skb) { | ||
594 | printk(KERN_ERR MOD "%s - cannot alloc skb!\n", __FUNCTION__); | ||
595 | return -ENOMEM; | ||
596 | } | ||
597 | skb->priority = CPL_PRIORITY_DATA; | ||
598 | skb_reserve(skb, sizeof(*req)); | ||
599 | mpa = (struct mpa_message *) skb_put(skb, mpalen); | ||
600 | memset(mpa, 0, sizeof(*mpa)); | ||
601 | memcpy(mpa->key, MPA_KEY_REP, sizeof(mpa->key)); | ||
602 | mpa->flags = (ep->mpa_attr.crc_enabled ? MPA_CRC : 0) | | ||
603 | (markers_enabled ? MPA_MARKERS : 0); | ||
604 | mpa->revision = mpa_rev; | ||
605 | mpa->private_data_size = htons(plen); | ||
606 | if (plen) | ||
607 | memcpy(mpa->private_data, pdata, plen); | ||
608 | |||
609 | /* | ||
610 | * Reference the mpa skb. This ensures the data area | ||
611 | * will remain in memory until the hw acks the tx. | ||
612 | * Function tx_ack() will deref it. | ||
613 | */ | ||
614 | skb_get(skb); | ||
615 | set_arp_failure_handler(skb, arp_failure_discard); | ||
616 | skb->h.raw = skb->data; | ||
617 | len = skb->len; | ||
618 | req = (struct tx_data_wr *) skb_push(skb, sizeof(*req)); | ||
619 | req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)); | ||
620 | req->wr_lo = htonl(V_WR_TID(ep->hwtid)); | ||
621 | req->len = htonl(len); | ||
622 | req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) | | ||
623 | V_TX_SNDBUF(snd_win>>15)); | ||
624 | req->flags = htonl(F_TX_MORE | F_TX_IMM_ACK | F_TX_INIT); | ||
625 | req->sndseq = htonl(ep->snd_seq); | ||
626 | ep->mpa_skb = skb; | ||
627 | state_set(&ep->com, MPA_REP_SENT); | ||
628 | l2t_send(ep->com.tdev, skb, ep->l2t); | ||
629 | return 0; | ||
630 | } | ||
631 | |||
632 | static int act_establish(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
633 | { | ||
634 | struct iwch_ep *ep = ctx; | ||
635 | struct cpl_act_establish *req = cplhdr(skb); | ||
636 | unsigned int tid = GET_TID(req); | ||
637 | |||
638 | PDBG("%s ep %p tid %d\n", __FUNCTION__, ep, tid); | ||
639 | |||
640 | dst_confirm(ep->dst); | ||
641 | |||
642 | /* setup the hwtid for this connection */ | ||
643 | ep->hwtid = tid; | ||
644 | cxgb3_insert_tid(ep->com.tdev, &t3c_client, ep, tid); | ||
645 | |||
646 | ep->snd_seq = ntohl(req->snd_isn); | ||
647 | |||
648 | set_emss(ep, ntohs(req->tcp_opt)); | ||
649 | |||
650 | /* dealloc the atid */ | ||
651 | cxgb3_free_atid(ep->com.tdev, ep->atid); | ||
652 | |||
653 | /* start MPA negotiation */ | ||
654 | send_mpa_req(ep, skb); | ||
655 | |||
656 | return 0; | ||
657 | } | ||
658 | |||
659 | static void abort_connection(struct iwch_ep *ep, struct sk_buff *skb, gfp_t gfp) | ||
660 | { | ||
661 | PDBG("%s ep %p\n", __FILE__, ep); | ||
662 | state_set(&ep->com, ABORTING); | ||
663 | send_abort(ep, skb, gfp); | ||
664 | } | ||
665 | |||
666 | static void close_complete_upcall(struct iwch_ep *ep) | ||
667 | { | ||
668 | struct iw_cm_event event; | ||
669 | |||
670 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
671 | memset(&event, 0, sizeof(event)); | ||
672 | event.event = IW_CM_EVENT_CLOSE; | ||
673 | if (ep->com.cm_id) { | ||
674 | PDBG("close complete delivered ep %p cm_id %p tid %d\n", | ||
675 | ep, ep->com.cm_id, ep->hwtid); | ||
676 | ep->com.cm_id->event_handler(ep->com.cm_id, &event); | ||
677 | ep->com.cm_id->rem_ref(ep->com.cm_id); | ||
678 | ep->com.cm_id = NULL; | ||
679 | ep->com.qp = NULL; | ||
680 | } | ||
681 | } | ||
682 | |||
683 | static void peer_close_upcall(struct iwch_ep *ep) | ||
684 | { | ||
685 | struct iw_cm_event event; | ||
686 | |||
687 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
688 | memset(&event, 0, sizeof(event)); | ||
689 | event.event = IW_CM_EVENT_DISCONNECT; | ||
690 | if (ep->com.cm_id) { | ||
691 | PDBG("peer close delivered ep %p cm_id %p tid %d\n", | ||
692 | ep, ep->com.cm_id, ep->hwtid); | ||
693 | ep->com.cm_id->event_handler(ep->com.cm_id, &event); | ||
694 | } | ||
695 | } | ||
696 | |||
697 | static void peer_abort_upcall(struct iwch_ep *ep) | ||
698 | { | ||
699 | struct iw_cm_event event; | ||
700 | |||
701 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
702 | memset(&event, 0, sizeof(event)); | ||
703 | event.event = IW_CM_EVENT_CLOSE; | ||
704 | event.status = -ECONNRESET; | ||
705 | if (ep->com.cm_id) { | ||
706 | PDBG("abort delivered ep %p cm_id %p tid %d\n", ep, | ||
707 | ep->com.cm_id, ep->hwtid); | ||
708 | ep->com.cm_id->event_handler(ep->com.cm_id, &event); | ||
709 | ep->com.cm_id->rem_ref(ep->com.cm_id); | ||
710 | ep->com.cm_id = NULL; | ||
711 | ep->com.qp = NULL; | ||
712 | } | ||
713 | } | ||
714 | |||
715 | static void connect_reply_upcall(struct iwch_ep *ep, int status) | ||
716 | { | ||
717 | struct iw_cm_event event; | ||
718 | |||
719 | PDBG("%s ep %p status %d\n", __FUNCTION__, ep, status); | ||
720 | memset(&event, 0, sizeof(event)); | ||
721 | event.event = IW_CM_EVENT_CONNECT_REPLY; | ||
722 | event.status = status; | ||
723 | event.local_addr = ep->com.local_addr; | ||
724 | event.remote_addr = ep->com.remote_addr; | ||
725 | |||
726 | if ((status == 0) || (status == -ECONNREFUSED)) { | ||
727 | event.private_data_len = ep->plen; | ||
728 | event.private_data = ep->mpa_pkt + sizeof(struct mpa_message); | ||
729 | } | ||
730 | if (ep->com.cm_id) { | ||
731 | PDBG("%s ep %p tid %d status %d\n", __FUNCTION__, ep, | ||
732 | ep->hwtid, status); | ||
733 | ep->com.cm_id->event_handler(ep->com.cm_id, &event); | ||
734 | } | ||
735 | if (status < 0) { | ||
736 | ep->com.cm_id->rem_ref(ep->com.cm_id); | ||
737 | ep->com.cm_id = NULL; | ||
738 | ep->com.qp = NULL; | ||
739 | } | ||
740 | } | ||
741 | |||
742 | static void connect_request_upcall(struct iwch_ep *ep) | ||
743 | { | ||
744 | struct iw_cm_event event; | ||
745 | |||
746 | PDBG("%s ep %p tid %d\n", __FUNCTION__, ep, ep->hwtid); | ||
747 | memset(&event, 0, sizeof(event)); | ||
748 | event.event = IW_CM_EVENT_CONNECT_REQUEST; | ||
749 | event.local_addr = ep->com.local_addr; | ||
750 | event.remote_addr = ep->com.remote_addr; | ||
751 | event.private_data_len = ep->plen; | ||
752 | event.private_data = ep->mpa_pkt + sizeof(struct mpa_message); | ||
753 | event.provider_data = ep; | ||
754 | if (state_read(&ep->parent_ep->com) != DEAD) | ||
755 | ep->parent_ep->com.cm_id->event_handler( | ||
756 | ep->parent_ep->com.cm_id, | ||
757 | &event); | ||
758 | put_ep(&ep->parent_ep->com); | ||
759 | ep->parent_ep = NULL; | ||
760 | } | ||
761 | |||
762 | static void established_upcall(struct iwch_ep *ep) | ||
763 | { | ||
764 | struct iw_cm_event event; | ||
765 | |||
766 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
767 | memset(&event, 0, sizeof(event)); | ||
768 | event.event = IW_CM_EVENT_ESTABLISHED; | ||
769 | if (ep->com.cm_id) { | ||
770 | PDBG("%s ep %p tid %d\n", __FUNCTION__, ep, ep->hwtid); | ||
771 | ep->com.cm_id->event_handler(ep->com.cm_id, &event); | ||
772 | } | ||
773 | } | ||
774 | |||
775 | static int update_rx_credits(struct iwch_ep *ep, u32 credits) | ||
776 | { | ||
777 | struct cpl_rx_data_ack *req; | ||
778 | struct sk_buff *skb; | ||
779 | |||
780 | PDBG("%s ep %p credits %u\n", __FUNCTION__, ep, credits); | ||
781 | skb = get_skb(NULL, sizeof(*req), GFP_KERNEL); | ||
782 | if (!skb) { | ||
783 | printk(KERN_ERR MOD "update_rx_credits - cannot alloc skb!\n"); | ||
784 | return 0; | ||
785 | } | ||
786 | |||
787 | req = (struct cpl_rx_data_ack *) skb_put(skb, sizeof(*req)); | ||
788 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | ||
789 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_RX_DATA_ACK, ep->hwtid)); | ||
790 | req->credit_dack = htonl(V_RX_CREDITS(credits) | V_RX_FORCE_ACK(1)); | ||
791 | skb->priority = CPL_PRIORITY_ACK; | ||
792 | ep->com.tdev->send(ep->com.tdev, skb); | ||
793 | return credits; | ||
794 | } | ||
795 | |||
796 | static void process_mpa_reply(struct iwch_ep *ep, struct sk_buff *skb) | ||
797 | { | ||
798 | struct mpa_message *mpa; | ||
799 | u16 plen; | ||
800 | struct iwch_qp_attributes attrs; | ||
801 | enum iwch_qp_attr_mask mask; | ||
802 | int err; | ||
803 | |||
804 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
805 | |||
806 | /* | ||
807 | * Stop mpa timer. If it expired, then the state has | ||
808 | * changed and we bail since ep_timeout already aborted | ||
809 | * the connection. | ||
810 | */ | ||
811 | stop_ep_timer(ep); | ||
812 | if (state_read(&ep->com) != MPA_REQ_SENT) | ||
813 | return; | ||
814 | |||
815 | /* | ||
816 | * If we get more than the supported amount of private data | ||
817 | * then we must fail this connection. | ||
818 | */ | ||
819 | if (ep->mpa_pkt_len + skb->len > sizeof(ep->mpa_pkt)) { | ||
820 | err = -EINVAL; | ||
821 | goto err; | ||
822 | } | ||
823 | |||
824 | /* | ||
825 | * copy the new data into our accumulation buffer. | ||
826 | */ | ||
827 | memcpy(&(ep->mpa_pkt[ep->mpa_pkt_len]), skb->data, skb->len); | ||
828 | ep->mpa_pkt_len += skb->len; | ||
829 | |||
830 | /* | ||
831 | * if we don't even have the mpa message, then bail. | ||
832 | */ | ||
833 | if (ep->mpa_pkt_len < sizeof(*mpa)) | ||
834 | return; | ||
835 | mpa = (struct mpa_message *) ep->mpa_pkt; | ||
836 | |||
837 | /* Validate MPA header. */ | ||
838 | if (mpa->revision != mpa_rev) { | ||
839 | err = -EPROTO; | ||
840 | goto err; | ||
841 | } | ||
842 | if (memcmp(mpa->key, MPA_KEY_REP, sizeof(mpa->key))) { | ||
843 | err = -EPROTO; | ||
844 | goto err; | ||
845 | } | ||
846 | |||
847 | plen = ntohs(mpa->private_data_size); | ||
848 | |||
849 | /* | ||
850 | * Fail if there's too much private data. | ||
851 | */ | ||
852 | if (plen > MPA_MAX_PRIVATE_DATA) { | ||
853 | err = -EPROTO; | ||
854 | goto err; | ||
855 | } | ||
856 | |||
857 | /* | ||
858 | * If plen does not account for pkt size | ||
859 | */ | ||
860 | if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) { | ||
861 | err = -EPROTO; | ||
862 | goto err; | ||
863 | } | ||
864 | |||
865 | ep->plen = (u8) plen; | ||
866 | |||
867 | /* | ||
868 | * If we don't have all the pdata yet, then bail. | ||
869 | * We'll continue process when more data arrives. | ||
870 | */ | ||
871 | if (ep->mpa_pkt_len < (sizeof(*mpa) + plen)) | ||
872 | return; | ||
873 | |||
874 | if (mpa->flags & MPA_REJECT) { | ||
875 | err = -ECONNREFUSED; | ||
876 | goto err; | ||
877 | } | ||
878 | |||
879 | /* | ||
880 | * If we get here we have accumulated the entire mpa | ||
881 | * start reply message including private data. And | ||
882 | * the MPA header is valid. | ||
883 | */ | ||
884 | state_set(&ep->com, FPDU_MODE); | ||
885 | ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0; | ||
886 | ep->mpa_attr.recv_marker_enabled = markers_enabled; | ||
887 | ep->mpa_attr.xmit_marker_enabled = mpa->flags & MPA_MARKERS ? 1 : 0; | ||
888 | ep->mpa_attr.version = mpa_rev; | ||
889 | PDBG("%s - crc_enabled=%d, recv_marker_enabled=%d, " | ||
890 | "xmit_marker_enabled=%d, version=%d\n", __FUNCTION__, | ||
891 | ep->mpa_attr.crc_enabled, ep->mpa_attr.recv_marker_enabled, | ||
892 | ep->mpa_attr.xmit_marker_enabled, ep->mpa_attr.version); | ||
893 | |||
894 | attrs.mpa_attr = ep->mpa_attr; | ||
895 | attrs.max_ird = ep->ird; | ||
896 | attrs.max_ord = ep->ord; | ||
897 | attrs.llp_stream_handle = ep; | ||
898 | attrs.next_state = IWCH_QP_STATE_RTS; | ||
899 | |||
900 | mask = IWCH_QP_ATTR_NEXT_STATE | | ||
901 | IWCH_QP_ATTR_LLP_STREAM_HANDLE | IWCH_QP_ATTR_MPA_ATTR | | ||
902 | IWCH_QP_ATTR_MAX_IRD | IWCH_QP_ATTR_MAX_ORD; | ||
903 | |||
904 | /* bind QP and TID with INIT_WR */ | ||
905 | err = iwch_modify_qp(ep->com.qp->rhp, | ||
906 | ep->com.qp, mask, &attrs, 1); | ||
907 | if (!err) | ||
908 | goto out; | ||
909 | err: | ||
910 | abort_connection(ep, skb, GFP_KERNEL); | ||
911 | out: | ||
912 | connect_reply_upcall(ep, err); | ||
913 | return; | ||
914 | } | ||
915 | |||
916 | static void process_mpa_request(struct iwch_ep *ep, struct sk_buff *skb) | ||
917 | { | ||
918 | struct mpa_message *mpa; | ||
919 | u16 plen; | ||
920 | |||
921 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
922 | |||
923 | /* | ||
924 | * Stop mpa timer. If it expired, then the state has | ||
925 | * changed and we bail since ep_timeout already aborted | ||
926 | * the connection. | ||
927 | */ | ||
928 | stop_ep_timer(ep); | ||
929 | if (state_read(&ep->com) != MPA_REQ_WAIT) | ||
930 | return; | ||
931 | |||
932 | /* | ||
933 | * If we get more than the supported amount of private data | ||
934 | * then we must fail this connection. | ||
935 | */ | ||
936 | if (ep->mpa_pkt_len + skb->len > sizeof(ep->mpa_pkt)) { | ||
937 | abort_connection(ep, skb, GFP_KERNEL); | ||
938 | return; | ||
939 | } | ||
940 | |||
941 | PDBG("%s enter (%s line %u)\n", __FUNCTION__, __FILE__, __LINE__); | ||
942 | |||
943 | /* | ||
944 | * Copy the new data into our accumulation buffer. | ||
945 | */ | ||
946 | memcpy(&(ep->mpa_pkt[ep->mpa_pkt_len]), skb->data, skb->len); | ||
947 | ep->mpa_pkt_len += skb->len; | ||
948 | |||
949 | /* | ||
950 | * If we don't even have the mpa message, then bail. | ||
951 | * We'll continue process when more data arrives. | ||
952 | */ | ||
953 | if (ep->mpa_pkt_len < sizeof(*mpa)) | ||
954 | return; | ||
955 | PDBG("%s enter (%s line %u)\n", __FUNCTION__, __FILE__, __LINE__); | ||
956 | mpa = (struct mpa_message *) ep->mpa_pkt; | ||
957 | |||
958 | /* | ||
959 | * Validate MPA Header. | ||
960 | */ | ||
961 | if (mpa->revision != mpa_rev) { | ||
962 | abort_connection(ep, skb, GFP_KERNEL); | ||
963 | return; | ||
964 | } | ||
965 | |||
966 | if (memcmp(mpa->key, MPA_KEY_REQ, sizeof(mpa->key))) { | ||
967 | abort_connection(ep, skb, GFP_KERNEL); | ||
968 | return; | ||
969 | } | ||
970 | |||
971 | plen = ntohs(mpa->private_data_size); | ||
972 | |||
973 | /* | ||
974 | * Fail if there's too much private data. | ||
975 | */ | ||
976 | if (plen > MPA_MAX_PRIVATE_DATA) { | ||
977 | abort_connection(ep, skb, GFP_KERNEL); | ||
978 | return; | ||
979 | } | ||
980 | |||
981 | /* | ||
982 | * If plen does not account for pkt size | ||
983 | */ | ||
984 | if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) { | ||
985 | abort_connection(ep, skb, GFP_KERNEL); | ||
986 | return; | ||
987 | } | ||
988 | ep->plen = (u8) plen; | ||
989 | |||
990 | /* | ||
991 | * If we don't have all the pdata yet, then bail. | ||
992 | */ | ||
993 | if (ep->mpa_pkt_len < (sizeof(*mpa) + plen)) | ||
994 | return; | ||
995 | |||
996 | /* | ||
997 | * If we get here we have accumulated the entire mpa | ||
998 | * start reply message including private data. | ||
999 | */ | ||
1000 | ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0; | ||
1001 | ep->mpa_attr.recv_marker_enabled = markers_enabled; | ||
1002 | ep->mpa_attr.xmit_marker_enabled = mpa->flags & MPA_MARKERS ? 1 : 0; | ||
1003 | ep->mpa_attr.version = mpa_rev; | ||
1004 | PDBG("%s - crc_enabled=%d, recv_marker_enabled=%d, " | ||
1005 | "xmit_marker_enabled=%d, version=%d\n", __FUNCTION__, | ||
1006 | ep->mpa_attr.crc_enabled, ep->mpa_attr.recv_marker_enabled, | ||
1007 | ep->mpa_attr.xmit_marker_enabled, ep->mpa_attr.version); | ||
1008 | |||
1009 | state_set(&ep->com, MPA_REQ_RCVD); | ||
1010 | |||
1011 | /* drive upcall */ | ||
1012 | connect_request_upcall(ep); | ||
1013 | return; | ||
1014 | } | ||
1015 | |||
1016 | static int rx_data(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1017 | { | ||
1018 | struct iwch_ep *ep = ctx; | ||
1019 | struct cpl_rx_data *hdr = cplhdr(skb); | ||
1020 | unsigned int dlen = ntohs(hdr->len); | ||
1021 | |||
1022 | PDBG("%s ep %p dlen %u\n", __FUNCTION__, ep, dlen); | ||
1023 | |||
1024 | skb_pull(skb, sizeof(*hdr)); | ||
1025 | skb_trim(skb, dlen); | ||
1026 | |||
1027 | switch (state_read(&ep->com)) { | ||
1028 | case MPA_REQ_SENT: | ||
1029 | process_mpa_reply(ep, skb); | ||
1030 | break; | ||
1031 | case MPA_REQ_WAIT: | ||
1032 | process_mpa_request(ep, skb); | ||
1033 | break; | ||
1034 | case MPA_REP_SENT: | ||
1035 | break; | ||
1036 | default: | ||
1037 | printk(KERN_ERR MOD "%s Unexpected streaming data." | ||
1038 | " ep %p state %d tid %d\n", | ||
1039 | __FUNCTION__, ep, state_read(&ep->com), ep->hwtid); | ||
1040 | |||
1041 | /* | ||
1042 | * The ep will timeout and inform the ULP of the failure. | ||
1043 | * See ep_timeout(). | ||
1044 | */ | ||
1045 | break; | ||
1046 | } | ||
1047 | |||
1048 | /* update RX credits */ | ||
1049 | update_rx_credits(ep, dlen); | ||
1050 | |||
1051 | return CPL_RET_BUF_DONE; | ||
1052 | } | ||
1053 | |||
1054 | /* | ||
1055 | * Upcall from the adapter indicating data has been transmitted. | ||
1056 | * For us its just the single MPA request or reply. We can now free | ||
1057 | * the skb holding the mpa message. | ||
1058 | */ | ||
1059 | static int tx_ack(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1060 | { | ||
1061 | struct iwch_ep *ep = ctx; | ||
1062 | struct cpl_wr_ack *hdr = cplhdr(skb); | ||
1063 | unsigned int credits = ntohs(hdr->credits); | ||
1064 | enum iwch_qp_attr_mask mask; | ||
1065 | |||
1066 | PDBG("%s ep %p credits %u\n", __FUNCTION__, ep, credits); | ||
1067 | |||
1068 | if (credits == 0) | ||
1069 | return CPL_RET_BUF_DONE; | ||
1070 | BUG_ON(credits != 1); | ||
1071 | BUG_ON(ep->mpa_skb == NULL); | ||
1072 | kfree_skb(ep->mpa_skb); | ||
1073 | ep->mpa_skb = NULL; | ||
1074 | dst_confirm(ep->dst); | ||
1075 | if (state_read(&ep->com) == MPA_REP_SENT) { | ||
1076 | struct iwch_qp_attributes attrs; | ||
1077 | |||
1078 | /* bind QP to EP and move to RTS */ | ||
1079 | attrs.mpa_attr = ep->mpa_attr; | ||
1080 | attrs.max_ird = ep->ord; | ||
1081 | attrs.max_ord = ep->ord; | ||
1082 | attrs.llp_stream_handle = ep; | ||
1083 | attrs.next_state = IWCH_QP_STATE_RTS; | ||
1084 | |||
1085 | /* bind QP and TID with INIT_WR */ | ||
1086 | mask = IWCH_QP_ATTR_NEXT_STATE | | ||
1087 | IWCH_QP_ATTR_LLP_STREAM_HANDLE | | ||
1088 | IWCH_QP_ATTR_MPA_ATTR | | ||
1089 | IWCH_QP_ATTR_MAX_IRD | | ||
1090 | IWCH_QP_ATTR_MAX_ORD; | ||
1091 | |||
1092 | ep->com.rpl_err = iwch_modify_qp(ep->com.qp->rhp, | ||
1093 | ep->com.qp, mask, &attrs, 1); | ||
1094 | |||
1095 | if (!ep->com.rpl_err) { | ||
1096 | state_set(&ep->com, FPDU_MODE); | ||
1097 | established_upcall(ep); | ||
1098 | } | ||
1099 | |||
1100 | ep->com.rpl_done = 1; | ||
1101 | PDBG("waking up ep %p\n", ep); | ||
1102 | wake_up(&ep->com.waitq); | ||
1103 | } | ||
1104 | return CPL_RET_BUF_DONE; | ||
1105 | } | ||
1106 | |||
1107 | static int abort_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1108 | { | ||
1109 | struct iwch_ep *ep = ctx; | ||
1110 | |||
1111 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1112 | |||
1113 | close_complete_upcall(ep); | ||
1114 | state_set(&ep->com, DEAD); | ||
1115 | release_ep_resources(ep); | ||
1116 | return CPL_RET_BUF_DONE; | ||
1117 | } | ||
1118 | |||
1119 | static int act_open_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1120 | { | ||
1121 | struct iwch_ep *ep = ctx; | ||
1122 | struct cpl_act_open_rpl *rpl = cplhdr(skb); | ||
1123 | |||
1124 | PDBG("%s ep %p status %u errno %d\n", __FUNCTION__, ep, rpl->status, | ||
1125 | status2errno(rpl->status)); | ||
1126 | connect_reply_upcall(ep, status2errno(rpl->status)); | ||
1127 | state_set(&ep->com, DEAD); | ||
1128 | if (ep->com.tdev->type == T3B) | ||
1129 | release_tid(ep->com.tdev, GET_TID(rpl), NULL); | ||
1130 | cxgb3_free_atid(ep->com.tdev, ep->atid); | ||
1131 | dst_release(ep->dst); | ||
1132 | l2t_release(L2DATA(ep->com.tdev), ep->l2t); | ||
1133 | put_ep(&ep->com); | ||
1134 | return CPL_RET_BUF_DONE; | ||
1135 | } | ||
1136 | |||
1137 | static int listen_start(struct iwch_listen_ep *ep) | ||
1138 | { | ||
1139 | struct sk_buff *skb; | ||
1140 | struct cpl_pass_open_req *req; | ||
1141 | |||
1142 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1143 | skb = get_skb(NULL, sizeof(*req), GFP_KERNEL); | ||
1144 | if (!skb) { | ||
1145 | printk(KERN_ERR MOD "t3c_listen_start failed to alloc skb!\n"); | ||
1146 | return -ENOMEM; | ||
1147 | } | ||
1148 | |||
1149 | req = (struct cpl_pass_open_req *) skb_put(skb, sizeof(*req)); | ||
1150 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | ||
1151 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ, ep->stid)); | ||
1152 | req->local_port = ep->com.local_addr.sin_port; | ||
1153 | req->local_ip = ep->com.local_addr.sin_addr.s_addr; | ||
1154 | req->peer_port = 0; | ||
1155 | req->peer_ip = 0; | ||
1156 | req->peer_netmask = 0; | ||
1157 | req->opt0h = htonl(F_DELACK | F_TCAM_BYPASS); | ||
1158 | req->opt0l = htonl(V_RCV_BUFSIZ(rcv_win>>10)); | ||
1159 | req->opt1 = htonl(V_CONN_POLICY(CPL_CONN_POLICY_ASK)); | ||
1160 | |||
1161 | skb->priority = 1; | ||
1162 | ep->com.tdev->send(ep->com.tdev, skb); | ||
1163 | return 0; | ||
1164 | } | ||
1165 | |||
1166 | static int pass_open_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1167 | { | ||
1168 | struct iwch_listen_ep *ep = ctx; | ||
1169 | struct cpl_pass_open_rpl *rpl = cplhdr(skb); | ||
1170 | |||
1171 | PDBG("%s ep %p status %d error %d\n", __FUNCTION__, ep, | ||
1172 | rpl->status, status2errno(rpl->status)); | ||
1173 | ep->com.rpl_err = status2errno(rpl->status); | ||
1174 | ep->com.rpl_done = 1; | ||
1175 | wake_up(&ep->com.waitq); | ||
1176 | |||
1177 | return CPL_RET_BUF_DONE; | ||
1178 | } | ||
1179 | |||
1180 | static int listen_stop(struct iwch_listen_ep *ep) | ||
1181 | { | ||
1182 | struct sk_buff *skb; | ||
1183 | struct cpl_close_listserv_req *req; | ||
1184 | |||
1185 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1186 | skb = get_skb(NULL, sizeof(*req), GFP_KERNEL); | ||
1187 | if (!skb) { | ||
1188 | printk(KERN_ERR MOD "%s - failed to alloc skb\n", __FUNCTION__); | ||
1189 | return -ENOMEM; | ||
1190 | } | ||
1191 | req = (struct cpl_close_listserv_req *) skb_put(skb, sizeof(*req)); | ||
1192 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | ||
1193 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_LISTSRV_REQ, ep->stid)); | ||
1194 | skb->priority = 1; | ||
1195 | ep->com.tdev->send(ep->com.tdev, skb); | ||
1196 | return 0; | ||
1197 | } | ||
1198 | |||
1199 | static int close_listsrv_rpl(struct t3cdev *tdev, struct sk_buff *skb, | ||
1200 | void *ctx) | ||
1201 | { | ||
1202 | struct iwch_listen_ep *ep = ctx; | ||
1203 | struct cpl_close_listserv_rpl *rpl = cplhdr(skb); | ||
1204 | |||
1205 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1206 | ep->com.rpl_err = status2errno(rpl->status); | ||
1207 | ep->com.rpl_done = 1; | ||
1208 | wake_up(&ep->com.waitq); | ||
1209 | return CPL_RET_BUF_DONE; | ||
1210 | } | ||
1211 | |||
1212 | static void accept_cr(struct iwch_ep *ep, __be32 peer_ip, struct sk_buff *skb) | ||
1213 | { | ||
1214 | struct cpl_pass_accept_rpl *rpl; | ||
1215 | unsigned int mtu_idx; | ||
1216 | u32 opt0h, opt0l, opt2; | ||
1217 | int wscale; | ||
1218 | |||
1219 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1220 | BUG_ON(skb_cloned(skb)); | ||
1221 | skb_trim(skb, sizeof(*rpl)); | ||
1222 | skb_get(skb); | ||
1223 | mtu_idx = find_best_mtu(T3C_DATA(ep->com.tdev), dst_mtu(ep->dst)); | ||
1224 | wscale = compute_wscale(rcv_win); | ||
1225 | opt0h = V_NAGLE(0) | | ||
1226 | V_NO_CONG(nocong) | | ||
1227 | V_KEEP_ALIVE(1) | | ||
1228 | F_TCAM_BYPASS | | ||
1229 | V_WND_SCALE(wscale) | | ||
1230 | V_MSS_IDX(mtu_idx) | | ||
1231 | V_L2T_IDX(ep->l2t->idx) | V_TX_CHANNEL(ep->l2t->smt_idx); | ||
1232 | opt0l = V_TOS((ep->tos >> 2) & M_TOS) | V_RCV_BUFSIZ(rcv_win>>10); | ||
1233 | opt2 = V_FLAVORS_VALID(1) | V_CONG_CONTROL_FLAVOR(cong_flavor); | ||
1234 | |||
1235 | rpl = cplhdr(skb); | ||
1236 | rpl->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | ||
1237 | OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL, ep->hwtid)); | ||
1238 | rpl->peer_ip = peer_ip; | ||
1239 | rpl->opt0h = htonl(opt0h); | ||
1240 | rpl->opt0l_status = htonl(opt0l | CPL_PASS_OPEN_ACCEPT); | ||
1241 | rpl->opt2 = htonl(opt2); | ||
1242 | rpl->rsvd = rpl->opt2; /* workaround for HW bug */ | ||
1243 | skb->priority = CPL_PRIORITY_SETUP; | ||
1244 | l2t_send(ep->com.tdev, skb, ep->l2t); | ||
1245 | |||
1246 | return; | ||
1247 | } | ||
1248 | |||
1249 | static void reject_cr(struct t3cdev *tdev, u32 hwtid, __be32 peer_ip, | ||
1250 | struct sk_buff *skb) | ||
1251 | { | ||
1252 | PDBG("%s t3cdev %p tid %u peer_ip %x\n", __FUNCTION__, tdev, hwtid, | ||
1253 | peer_ip); | ||
1254 | BUG_ON(skb_cloned(skb)); | ||
1255 | skb_trim(skb, sizeof(struct cpl_tid_release)); | ||
1256 | skb_get(skb); | ||
1257 | |||
1258 | if (tdev->type == T3B) | ||
1259 | release_tid(tdev, hwtid, skb); | ||
1260 | else { | ||
1261 | struct cpl_pass_accept_rpl *rpl; | ||
1262 | |||
1263 | rpl = cplhdr(skb); | ||
1264 | skb->priority = CPL_PRIORITY_SETUP; | ||
1265 | rpl->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | ||
1266 | OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL, | ||
1267 | hwtid)); | ||
1268 | rpl->peer_ip = peer_ip; | ||
1269 | rpl->opt0h = htonl(F_TCAM_BYPASS); | ||
1270 | rpl->opt0l_status = htonl(CPL_PASS_OPEN_REJECT); | ||
1271 | rpl->opt2 = 0; | ||
1272 | rpl->rsvd = rpl->opt2; | ||
1273 | tdev->send(tdev, skb); | ||
1274 | } | ||
1275 | } | ||
1276 | |||
1277 | static int pass_accept_req(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1278 | { | ||
1279 | struct iwch_ep *child_ep, *parent_ep = ctx; | ||
1280 | struct cpl_pass_accept_req *req = cplhdr(skb); | ||
1281 | unsigned int hwtid = GET_TID(req); | ||
1282 | struct dst_entry *dst; | ||
1283 | struct l2t_entry *l2t; | ||
1284 | struct rtable *rt; | ||
1285 | struct iff_mac tim; | ||
1286 | |||
1287 | PDBG("%s parent ep %p tid %u\n", __FUNCTION__, parent_ep, hwtid); | ||
1288 | |||
1289 | if (state_read(&parent_ep->com) != LISTEN) { | ||
1290 | printk(KERN_ERR "%s - listening ep not in LISTEN\n", | ||
1291 | __FUNCTION__); | ||
1292 | goto reject; | ||
1293 | } | ||
1294 | |||
1295 | /* | ||
1296 | * Find the netdev for this connection request. | ||
1297 | */ | ||
1298 | tim.mac_addr = req->dst_mac; | ||
1299 | tim.vlan_tag = ntohs(req->vlan_tag); | ||
1300 | if (tdev->ctl(tdev, GET_IFF_FROM_MAC, &tim) < 0 || !tim.dev) { | ||
1301 | printk(KERN_ERR | ||
1302 | "%s bad dst mac %02x %02x %02x %02x %02x %02x\n", | ||
1303 | __FUNCTION__, | ||
1304 | req->dst_mac[0], | ||
1305 | req->dst_mac[1], | ||
1306 | req->dst_mac[2], | ||
1307 | req->dst_mac[3], | ||
1308 | req->dst_mac[4], | ||
1309 | req->dst_mac[5]); | ||
1310 | goto reject; | ||
1311 | } | ||
1312 | |||
1313 | /* Find output route */ | ||
1314 | rt = find_route(tdev, | ||
1315 | req->local_ip, | ||
1316 | req->peer_ip, | ||
1317 | req->local_port, | ||
1318 | req->peer_port, G_PASS_OPEN_TOS(ntohl(req->tos_tid))); | ||
1319 | if (!rt) { | ||
1320 | printk(KERN_ERR MOD "%s - failed to find dst entry!\n", | ||
1321 | __FUNCTION__); | ||
1322 | goto reject; | ||
1323 | } | ||
1324 | dst = &rt->u.dst; | ||
1325 | l2t = t3_l2t_get(tdev, dst->neighbour, dst->neighbour->dev); | ||
1326 | if (!l2t) { | ||
1327 | printk(KERN_ERR MOD "%s - failed to allocate l2t entry!\n", | ||
1328 | __FUNCTION__); | ||
1329 | dst_release(dst); | ||
1330 | goto reject; | ||
1331 | } | ||
1332 | child_ep = alloc_ep(sizeof(*child_ep), GFP_KERNEL); | ||
1333 | if (!child_ep) { | ||
1334 | printk(KERN_ERR MOD "%s - failed to allocate ep entry!\n", | ||
1335 | __FUNCTION__); | ||
1336 | l2t_release(L2DATA(tdev), l2t); | ||
1337 | dst_release(dst); | ||
1338 | goto reject; | ||
1339 | } | ||
1340 | state_set(&child_ep->com, CONNECTING); | ||
1341 | child_ep->com.tdev = tdev; | ||
1342 | child_ep->com.cm_id = NULL; | ||
1343 | child_ep->com.local_addr.sin_family = PF_INET; | ||
1344 | child_ep->com.local_addr.sin_port = req->local_port; | ||
1345 | child_ep->com.local_addr.sin_addr.s_addr = req->local_ip; | ||
1346 | child_ep->com.remote_addr.sin_family = PF_INET; | ||
1347 | child_ep->com.remote_addr.sin_port = req->peer_port; | ||
1348 | child_ep->com.remote_addr.sin_addr.s_addr = req->peer_ip; | ||
1349 | get_ep(&parent_ep->com); | ||
1350 | child_ep->parent_ep = parent_ep; | ||
1351 | child_ep->tos = G_PASS_OPEN_TOS(ntohl(req->tos_tid)); | ||
1352 | child_ep->l2t = l2t; | ||
1353 | child_ep->dst = dst; | ||
1354 | child_ep->hwtid = hwtid; | ||
1355 | init_timer(&child_ep->timer); | ||
1356 | cxgb3_insert_tid(tdev, &t3c_client, child_ep, hwtid); | ||
1357 | accept_cr(child_ep, req->peer_ip, skb); | ||
1358 | goto out; | ||
1359 | reject: | ||
1360 | reject_cr(tdev, hwtid, req->peer_ip, skb); | ||
1361 | out: | ||
1362 | return CPL_RET_BUF_DONE; | ||
1363 | } | ||
1364 | |||
1365 | static int pass_establish(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1366 | { | ||
1367 | struct iwch_ep *ep = ctx; | ||
1368 | struct cpl_pass_establish *req = cplhdr(skb); | ||
1369 | |||
1370 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1371 | ep->snd_seq = ntohl(req->snd_isn); | ||
1372 | |||
1373 | set_emss(ep, ntohs(req->tcp_opt)); | ||
1374 | |||
1375 | dst_confirm(ep->dst); | ||
1376 | state_set(&ep->com, MPA_REQ_WAIT); | ||
1377 | start_ep_timer(ep); | ||
1378 | |||
1379 | return CPL_RET_BUF_DONE; | ||
1380 | } | ||
1381 | |||
1382 | static int peer_close(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1383 | { | ||
1384 | struct iwch_ep *ep = ctx; | ||
1385 | struct iwch_qp_attributes attrs; | ||
1386 | unsigned long flags; | ||
1387 | int disconnect = 1; | ||
1388 | int release = 0; | ||
1389 | |||
1390 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1391 | dst_confirm(ep->dst); | ||
1392 | |||
1393 | spin_lock_irqsave(&ep->com.lock, flags); | ||
1394 | switch (ep->com.state) { | ||
1395 | case MPA_REQ_WAIT: | ||
1396 | __state_set(&ep->com, CLOSING); | ||
1397 | break; | ||
1398 | case MPA_REQ_SENT: | ||
1399 | __state_set(&ep->com, CLOSING); | ||
1400 | connect_reply_upcall(ep, -ECONNRESET); | ||
1401 | break; | ||
1402 | case MPA_REQ_RCVD: | ||
1403 | |||
1404 | /* | ||
1405 | * We're gonna mark this puppy DEAD, but keep | ||
1406 | * the reference on it until the ULP accepts or | ||
1407 | * rejects the CR. | ||
1408 | */ | ||
1409 | __state_set(&ep->com, CLOSING); | ||
1410 | get_ep(&ep->com); | ||
1411 | break; | ||
1412 | case MPA_REP_SENT: | ||
1413 | __state_set(&ep->com, CLOSING); | ||
1414 | ep->com.rpl_done = 1; | ||
1415 | ep->com.rpl_err = -ECONNRESET; | ||
1416 | PDBG("waking up ep %p\n", ep); | ||
1417 | wake_up(&ep->com.waitq); | ||
1418 | break; | ||
1419 | case FPDU_MODE: | ||
1420 | __state_set(&ep->com, CLOSING); | ||
1421 | attrs.next_state = IWCH_QP_STATE_CLOSING; | ||
1422 | iwch_modify_qp(ep->com.qp->rhp, ep->com.qp, | ||
1423 | IWCH_QP_ATTR_NEXT_STATE, &attrs, 1); | ||
1424 | peer_close_upcall(ep); | ||
1425 | break; | ||
1426 | case ABORTING: | ||
1427 | disconnect = 0; | ||
1428 | break; | ||
1429 | case CLOSING: | ||
1430 | start_ep_timer(ep); | ||
1431 | __state_set(&ep->com, MORIBUND); | ||
1432 | disconnect = 0; | ||
1433 | break; | ||
1434 | case MORIBUND: | ||
1435 | stop_ep_timer(ep); | ||
1436 | if (ep->com.cm_id && ep->com.qp) { | ||
1437 | attrs.next_state = IWCH_QP_STATE_IDLE; | ||
1438 | iwch_modify_qp(ep->com.qp->rhp, ep->com.qp, | ||
1439 | IWCH_QP_ATTR_NEXT_STATE, &attrs, 1); | ||
1440 | } | ||
1441 | close_complete_upcall(ep); | ||
1442 | __state_set(&ep->com, DEAD); | ||
1443 | release = 1; | ||
1444 | disconnect = 0; | ||
1445 | break; | ||
1446 | case DEAD: | ||
1447 | disconnect = 0; | ||
1448 | break; | ||
1449 | default: | ||
1450 | BUG_ON(1); | ||
1451 | } | ||
1452 | spin_unlock_irqrestore(&ep->com.lock, flags); | ||
1453 | if (disconnect) | ||
1454 | iwch_ep_disconnect(ep, 0, GFP_KERNEL); | ||
1455 | if (release) | ||
1456 | release_ep_resources(ep); | ||
1457 | return CPL_RET_BUF_DONE; | ||
1458 | } | ||
1459 | |||
1460 | /* | ||
1461 | * Returns whether an ABORT_REQ_RSS message is a negative advice. | ||
1462 | */ | ||
1463 | static inline int is_neg_adv_abort(unsigned int status) | ||
1464 | { | ||
1465 | return status == CPL_ERR_RTX_NEG_ADVICE || | ||
1466 | status == CPL_ERR_PERSIST_NEG_ADVICE; | ||
1467 | } | ||
1468 | |||
1469 | static int peer_abort(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1470 | { | ||
1471 | struct cpl_abort_req_rss *req = cplhdr(skb); | ||
1472 | struct iwch_ep *ep = ctx; | ||
1473 | struct cpl_abort_rpl *rpl; | ||
1474 | struct sk_buff *rpl_skb; | ||
1475 | struct iwch_qp_attributes attrs; | ||
1476 | int ret; | ||
1477 | int state; | ||
1478 | |||
1479 | if (is_neg_adv_abort(req->status)) { | ||
1480 | PDBG("%s neg_adv_abort ep %p tid %d\n", __FUNCTION__, ep, | ||
1481 | ep->hwtid); | ||
1482 | t3_l2t_send_event(ep->com.tdev, ep->l2t); | ||
1483 | return CPL_RET_BUF_DONE; | ||
1484 | } | ||
1485 | |||
1486 | state = state_read(&ep->com); | ||
1487 | PDBG("%s ep %p state %u\n", __FUNCTION__, ep, state); | ||
1488 | switch (state) { | ||
1489 | case CONNECTING: | ||
1490 | break; | ||
1491 | case MPA_REQ_WAIT: | ||
1492 | break; | ||
1493 | case MPA_REQ_SENT: | ||
1494 | connect_reply_upcall(ep, -ECONNRESET); | ||
1495 | break; | ||
1496 | case MPA_REP_SENT: | ||
1497 | ep->com.rpl_done = 1; | ||
1498 | ep->com.rpl_err = -ECONNRESET; | ||
1499 | PDBG("waking up ep %p\n", ep); | ||
1500 | wake_up(&ep->com.waitq); | ||
1501 | break; | ||
1502 | case MPA_REQ_RCVD: | ||
1503 | |||
1504 | /* | ||
1505 | * We're gonna mark this puppy DEAD, but keep | ||
1506 | * the reference on it until the ULP accepts or | ||
1507 | * rejects the CR. | ||
1508 | */ | ||
1509 | get_ep(&ep->com); | ||
1510 | break; | ||
1511 | case MORIBUND: | ||
1512 | stop_ep_timer(ep); | ||
1513 | case FPDU_MODE: | ||
1514 | case CLOSING: | ||
1515 | if (ep->com.cm_id && ep->com.qp) { | ||
1516 | attrs.next_state = IWCH_QP_STATE_ERROR; | ||
1517 | ret = iwch_modify_qp(ep->com.qp->rhp, | ||
1518 | ep->com.qp, IWCH_QP_ATTR_NEXT_STATE, | ||
1519 | &attrs, 1); | ||
1520 | if (ret) | ||
1521 | printk(KERN_ERR MOD | ||
1522 | "%s - qp <- error failed!\n", | ||
1523 | __FUNCTION__); | ||
1524 | } | ||
1525 | peer_abort_upcall(ep); | ||
1526 | break; | ||
1527 | case ABORTING: | ||
1528 | break; | ||
1529 | case DEAD: | ||
1530 | PDBG("%s PEER_ABORT IN DEAD STATE!!!!\n", __FUNCTION__); | ||
1531 | return CPL_RET_BUF_DONE; | ||
1532 | default: | ||
1533 | BUG_ON(1); | ||
1534 | break; | ||
1535 | } | ||
1536 | dst_confirm(ep->dst); | ||
1537 | |||
1538 | rpl_skb = get_skb(skb, sizeof(*rpl), GFP_KERNEL); | ||
1539 | if (!rpl_skb) { | ||
1540 | printk(KERN_ERR MOD "%s - cannot allocate skb!\n", | ||
1541 | __FUNCTION__); | ||
1542 | dst_release(ep->dst); | ||
1543 | l2t_release(L2DATA(ep->com.tdev), ep->l2t); | ||
1544 | put_ep(&ep->com); | ||
1545 | return CPL_RET_BUF_DONE; | ||
1546 | } | ||
1547 | rpl_skb->priority = CPL_PRIORITY_DATA; | ||
1548 | rpl = (struct cpl_abort_rpl *) skb_put(rpl_skb, sizeof(*rpl)); | ||
1549 | rpl->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_RPL)); | ||
1550 | rpl->wr.wr_lo = htonl(V_WR_TID(ep->hwtid)); | ||
1551 | OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_ABORT_RPL, ep->hwtid)); | ||
1552 | rpl->cmd = CPL_ABORT_NO_RST; | ||
1553 | ep->com.tdev->send(ep->com.tdev, rpl_skb); | ||
1554 | if (state != ABORTING) { | ||
1555 | state_set(&ep->com, DEAD); | ||
1556 | release_ep_resources(ep); | ||
1557 | } | ||
1558 | return CPL_RET_BUF_DONE; | ||
1559 | } | ||
1560 | |||
1561 | static int close_con_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1562 | { | ||
1563 | struct iwch_ep *ep = ctx; | ||
1564 | struct iwch_qp_attributes attrs; | ||
1565 | unsigned long flags; | ||
1566 | int release = 0; | ||
1567 | |||
1568 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1569 | BUG_ON(!ep); | ||
1570 | |||
1571 | /* The cm_id may be null if we failed to connect */ | ||
1572 | spin_lock_irqsave(&ep->com.lock, flags); | ||
1573 | switch (ep->com.state) { | ||
1574 | case CLOSING: | ||
1575 | start_ep_timer(ep); | ||
1576 | __state_set(&ep->com, MORIBUND); | ||
1577 | break; | ||
1578 | case MORIBUND: | ||
1579 | stop_ep_timer(ep); | ||
1580 | if ((ep->com.cm_id) && (ep->com.qp)) { | ||
1581 | attrs.next_state = IWCH_QP_STATE_IDLE; | ||
1582 | iwch_modify_qp(ep->com.qp->rhp, | ||
1583 | ep->com.qp, | ||
1584 | IWCH_QP_ATTR_NEXT_STATE, | ||
1585 | &attrs, 1); | ||
1586 | } | ||
1587 | close_complete_upcall(ep); | ||
1588 | __state_set(&ep->com, DEAD); | ||
1589 | release = 1; | ||
1590 | break; | ||
1591 | case DEAD: | ||
1592 | default: | ||
1593 | BUG_ON(1); | ||
1594 | break; | ||
1595 | } | ||
1596 | spin_unlock_irqrestore(&ep->com.lock, flags); | ||
1597 | if (release) | ||
1598 | release_ep_resources(ep); | ||
1599 | return CPL_RET_BUF_DONE; | ||
1600 | } | ||
1601 | |||
1602 | /* | ||
1603 | * T3A does 3 things when a TERM is received: | ||
1604 | * 1) send up a CPL_RDMA_TERMINATE message with the TERM packet | ||
1605 | * 2) generate an async event on the QP with the TERMINATE opcode | ||
1606 | * 3) post a TERMINATE opcde cqe into the associated CQ. | ||
1607 | * | ||
1608 | * For (1), we save the message in the qp for later consumer consumption. | ||
1609 | * For (2), we move the QP into TERMINATE, post a QP event and disconnect. | ||
1610 | * For (3), we toss the CQE in cxio_poll_cq(). | ||
1611 | * | ||
1612 | * terminate() handles case (1)... | ||
1613 | */ | ||
1614 | static int terminate(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1615 | { | ||
1616 | struct iwch_ep *ep = ctx; | ||
1617 | |||
1618 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1619 | skb_pull(skb, sizeof(struct cpl_rdma_terminate)); | ||
1620 | PDBG("%s saving %d bytes of term msg\n", __FUNCTION__, skb->len); | ||
1621 | memcpy(ep->com.qp->attr.terminate_buffer, skb->data, skb->len); | ||
1622 | ep->com.qp->attr.terminate_msg_len = skb->len; | ||
1623 | ep->com.qp->attr.is_terminate_local = 0; | ||
1624 | return CPL_RET_BUF_DONE; | ||
1625 | } | ||
1626 | |||
1627 | static int ec_status(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
1628 | { | ||
1629 | struct cpl_rdma_ec_status *rep = cplhdr(skb); | ||
1630 | struct iwch_ep *ep = ctx; | ||
1631 | |||
1632 | PDBG("%s ep %p tid %u status %d\n", __FUNCTION__, ep, ep->hwtid, | ||
1633 | rep->status); | ||
1634 | if (rep->status) { | ||
1635 | struct iwch_qp_attributes attrs; | ||
1636 | |||
1637 | printk(KERN_ERR MOD "%s BAD CLOSE - Aborting tid %u\n", | ||
1638 | __FUNCTION__, ep->hwtid); | ||
1639 | attrs.next_state = IWCH_QP_STATE_ERROR; | ||
1640 | iwch_modify_qp(ep->com.qp->rhp, | ||
1641 | ep->com.qp, IWCH_QP_ATTR_NEXT_STATE, | ||
1642 | &attrs, 1); | ||
1643 | abort_connection(ep, NULL, GFP_KERNEL); | ||
1644 | } | ||
1645 | return CPL_RET_BUF_DONE; | ||
1646 | } | ||
1647 | |||
1648 | static void ep_timeout(unsigned long arg) | ||
1649 | { | ||
1650 | struct iwch_ep *ep = (struct iwch_ep *)arg; | ||
1651 | struct iwch_qp_attributes attrs; | ||
1652 | unsigned long flags; | ||
1653 | |||
1654 | spin_lock_irqsave(&ep->com.lock, flags); | ||
1655 | PDBG("%s ep %p tid %u state %d\n", __FUNCTION__, ep, ep->hwtid, | ||
1656 | ep->com.state); | ||
1657 | switch (ep->com.state) { | ||
1658 | case MPA_REQ_SENT: | ||
1659 | connect_reply_upcall(ep, -ETIMEDOUT); | ||
1660 | break; | ||
1661 | case MPA_REQ_WAIT: | ||
1662 | break; | ||
1663 | case MORIBUND: | ||
1664 | if (ep->com.cm_id && ep->com.qp) { | ||
1665 | attrs.next_state = IWCH_QP_STATE_ERROR; | ||
1666 | iwch_modify_qp(ep->com.qp->rhp, | ||
1667 | ep->com.qp, IWCH_QP_ATTR_NEXT_STATE, | ||
1668 | &attrs, 1); | ||
1669 | } | ||
1670 | break; | ||
1671 | default: | ||
1672 | BUG(); | ||
1673 | } | ||
1674 | __state_set(&ep->com, CLOSING); | ||
1675 | spin_unlock_irqrestore(&ep->com.lock, flags); | ||
1676 | abort_connection(ep, NULL, GFP_ATOMIC); | ||
1677 | put_ep(&ep->com); | ||
1678 | } | ||
1679 | |||
1680 | int iwch_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len) | ||
1681 | { | ||
1682 | int err; | ||
1683 | struct iwch_ep *ep = to_ep(cm_id); | ||
1684 | PDBG("%s ep %p tid %u\n", __FUNCTION__, ep, ep->hwtid); | ||
1685 | |||
1686 | if (state_read(&ep->com) == DEAD) { | ||
1687 | put_ep(&ep->com); | ||
1688 | return -ECONNRESET; | ||
1689 | } | ||
1690 | BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD); | ||
1691 | state_set(&ep->com, CLOSING); | ||
1692 | if (mpa_rev == 0) | ||
1693 | abort_connection(ep, NULL, GFP_KERNEL); | ||
1694 | else { | ||
1695 | err = send_mpa_reject(ep, pdata, pdata_len); | ||
1696 | err = send_halfclose(ep, GFP_KERNEL); | ||
1697 | } | ||
1698 | return 0; | ||
1699 | } | ||
1700 | |||
1701 | int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | ||
1702 | { | ||
1703 | int err; | ||
1704 | struct iwch_qp_attributes attrs; | ||
1705 | enum iwch_qp_attr_mask mask; | ||
1706 | struct iwch_ep *ep = to_ep(cm_id); | ||
1707 | struct iwch_dev *h = to_iwch_dev(cm_id->device); | ||
1708 | struct iwch_qp *qp = get_qhp(h, conn_param->qpn); | ||
1709 | |||
1710 | PDBG("%s ep %p tid %u\n", __FUNCTION__, ep, ep->hwtid); | ||
1711 | if (state_read(&ep->com) == DEAD) { | ||
1712 | put_ep(&ep->com); | ||
1713 | return -ECONNRESET; | ||
1714 | } | ||
1715 | |||
1716 | BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD); | ||
1717 | BUG_ON(!qp); | ||
1718 | |||
1719 | if ((conn_param->ord > qp->rhp->attr.max_rdma_read_qp_depth) || | ||
1720 | (conn_param->ird > qp->rhp->attr.max_rdma_reads_per_qp)) { | ||
1721 | abort_connection(ep, NULL, GFP_KERNEL); | ||
1722 | return -EINVAL; | ||
1723 | } | ||
1724 | |||
1725 | cm_id->add_ref(cm_id); | ||
1726 | ep->com.cm_id = cm_id; | ||
1727 | ep->com.qp = qp; | ||
1728 | |||
1729 | ep->com.rpl_done = 0; | ||
1730 | ep->com.rpl_err = 0; | ||
1731 | ep->ird = conn_param->ird; | ||
1732 | ep->ord = conn_param->ord; | ||
1733 | PDBG("%s %d ird %d ord %d\n", __FUNCTION__, __LINE__, ep->ird, ep->ord); | ||
1734 | get_ep(&ep->com); | ||
1735 | err = send_mpa_reply(ep, conn_param->private_data, | ||
1736 | conn_param->private_data_len); | ||
1737 | if (err) { | ||
1738 | ep->com.cm_id = NULL; | ||
1739 | ep->com.qp = NULL; | ||
1740 | cm_id->rem_ref(cm_id); | ||
1741 | abort_connection(ep, NULL, GFP_KERNEL); | ||
1742 | put_ep(&ep->com); | ||
1743 | return err; | ||
1744 | } | ||
1745 | |||
1746 | /* bind QP to EP and move to RTS */ | ||
1747 | attrs.mpa_attr = ep->mpa_attr; | ||
1748 | attrs.max_ird = ep->ord; | ||
1749 | attrs.max_ord = ep->ord; | ||
1750 | attrs.llp_stream_handle = ep; | ||
1751 | attrs.next_state = IWCH_QP_STATE_RTS; | ||
1752 | |||
1753 | /* bind QP and TID with INIT_WR */ | ||
1754 | mask = IWCH_QP_ATTR_NEXT_STATE | | ||
1755 | IWCH_QP_ATTR_LLP_STREAM_HANDLE | | ||
1756 | IWCH_QP_ATTR_MPA_ATTR | | ||
1757 | IWCH_QP_ATTR_MAX_IRD | | ||
1758 | IWCH_QP_ATTR_MAX_ORD; | ||
1759 | |||
1760 | err = iwch_modify_qp(ep->com.qp->rhp, | ||
1761 | ep->com.qp, mask, &attrs, 1); | ||
1762 | |||
1763 | if (err) { | ||
1764 | ep->com.cm_id = NULL; | ||
1765 | ep->com.qp = NULL; | ||
1766 | cm_id->rem_ref(cm_id); | ||
1767 | abort_connection(ep, NULL, GFP_KERNEL); | ||
1768 | } else { | ||
1769 | state_set(&ep->com, FPDU_MODE); | ||
1770 | established_upcall(ep); | ||
1771 | } | ||
1772 | put_ep(&ep->com); | ||
1773 | return err; | ||
1774 | } | ||
1775 | |||
1776 | int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | ||
1777 | { | ||
1778 | int err = 0; | ||
1779 | struct iwch_dev *h = to_iwch_dev(cm_id->device); | ||
1780 | struct iwch_ep *ep; | ||
1781 | struct rtable *rt; | ||
1782 | |||
1783 | ep = alloc_ep(sizeof(*ep), GFP_KERNEL); | ||
1784 | if (!ep) { | ||
1785 | printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__); | ||
1786 | err = -ENOMEM; | ||
1787 | goto out; | ||
1788 | } | ||
1789 | init_timer(&ep->timer); | ||
1790 | ep->plen = conn_param->private_data_len; | ||
1791 | if (ep->plen) | ||
1792 | memcpy(ep->mpa_pkt + sizeof(struct mpa_message), | ||
1793 | conn_param->private_data, ep->plen); | ||
1794 | ep->ird = conn_param->ird; | ||
1795 | ep->ord = conn_param->ord; | ||
1796 | ep->com.tdev = h->rdev.t3cdev_p; | ||
1797 | |||
1798 | cm_id->add_ref(cm_id); | ||
1799 | ep->com.cm_id = cm_id; | ||
1800 | ep->com.qp = get_qhp(h, conn_param->qpn); | ||
1801 | BUG_ON(!ep->com.qp); | ||
1802 | PDBG("%s qpn 0x%x qp %p cm_id %p\n", __FUNCTION__, conn_param->qpn, | ||
1803 | ep->com.qp, cm_id); | ||
1804 | |||
1805 | /* | ||
1806 | * Allocate an active TID to initiate a TCP connection. | ||
1807 | */ | ||
1808 | ep->atid = cxgb3_alloc_atid(h->rdev.t3cdev_p, &t3c_client, ep); | ||
1809 | if (ep->atid == -1) { | ||
1810 | printk(KERN_ERR MOD "%s - cannot alloc atid.\n", __FUNCTION__); | ||
1811 | err = -ENOMEM; | ||
1812 | goto fail2; | ||
1813 | } | ||
1814 | |||
1815 | /* find a route */ | ||
1816 | rt = find_route(h->rdev.t3cdev_p, | ||
1817 | cm_id->local_addr.sin_addr.s_addr, | ||
1818 | cm_id->remote_addr.sin_addr.s_addr, | ||
1819 | cm_id->local_addr.sin_port, | ||
1820 | cm_id->remote_addr.sin_port, IPTOS_LOWDELAY); | ||
1821 | if (!rt) { | ||
1822 | printk(KERN_ERR MOD "%s - cannot find route.\n", __FUNCTION__); | ||
1823 | err = -EHOSTUNREACH; | ||
1824 | goto fail3; | ||
1825 | } | ||
1826 | ep->dst = &rt->u.dst; | ||
1827 | |||
1828 | /* get a l2t entry */ | ||
1829 | ep->l2t = t3_l2t_get(ep->com.tdev, ep->dst->neighbour, | ||
1830 | ep->dst->neighbour->dev); | ||
1831 | if (!ep->l2t) { | ||
1832 | printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __FUNCTION__); | ||
1833 | err = -ENOMEM; | ||
1834 | goto fail4; | ||
1835 | } | ||
1836 | |||
1837 | state_set(&ep->com, CONNECTING); | ||
1838 | ep->tos = IPTOS_LOWDELAY; | ||
1839 | ep->com.local_addr = cm_id->local_addr; | ||
1840 | ep->com.remote_addr = cm_id->remote_addr; | ||
1841 | |||
1842 | /* send connect request to rnic */ | ||
1843 | err = send_connect(ep); | ||
1844 | if (!err) | ||
1845 | goto out; | ||
1846 | |||
1847 | l2t_release(L2DATA(h->rdev.t3cdev_p), ep->l2t); | ||
1848 | fail4: | ||
1849 | dst_release(ep->dst); | ||
1850 | fail3: | ||
1851 | cxgb3_free_atid(ep->com.tdev, ep->atid); | ||
1852 | fail2: | ||
1853 | put_ep(&ep->com); | ||
1854 | out: | ||
1855 | return err; | ||
1856 | } | ||
1857 | |||
1858 | int iwch_create_listen(struct iw_cm_id *cm_id, int backlog) | ||
1859 | { | ||
1860 | int err = 0; | ||
1861 | struct iwch_dev *h = to_iwch_dev(cm_id->device); | ||
1862 | struct iwch_listen_ep *ep; | ||
1863 | |||
1864 | |||
1865 | might_sleep(); | ||
1866 | |||
1867 | ep = alloc_ep(sizeof(*ep), GFP_KERNEL); | ||
1868 | if (!ep) { | ||
1869 | printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__); | ||
1870 | err = -ENOMEM; | ||
1871 | goto fail1; | ||
1872 | } | ||
1873 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1874 | ep->com.tdev = h->rdev.t3cdev_p; | ||
1875 | cm_id->add_ref(cm_id); | ||
1876 | ep->com.cm_id = cm_id; | ||
1877 | ep->backlog = backlog; | ||
1878 | ep->com.local_addr = cm_id->local_addr; | ||
1879 | |||
1880 | /* | ||
1881 | * Allocate a server TID. | ||
1882 | */ | ||
1883 | ep->stid = cxgb3_alloc_stid(h->rdev.t3cdev_p, &t3c_client, ep); | ||
1884 | if (ep->stid == -1) { | ||
1885 | printk(KERN_ERR MOD "%s - cannot alloc atid.\n", __FUNCTION__); | ||
1886 | err = -ENOMEM; | ||
1887 | goto fail2; | ||
1888 | } | ||
1889 | |||
1890 | state_set(&ep->com, LISTEN); | ||
1891 | err = listen_start(ep); | ||
1892 | if (err) | ||
1893 | goto fail3; | ||
1894 | |||
1895 | /* wait for pass_open_rpl */ | ||
1896 | wait_event(ep->com.waitq, ep->com.rpl_done); | ||
1897 | err = ep->com.rpl_err; | ||
1898 | if (!err) { | ||
1899 | cm_id->provider_data = ep; | ||
1900 | goto out; | ||
1901 | } | ||
1902 | fail3: | ||
1903 | cxgb3_free_stid(ep->com.tdev, ep->stid); | ||
1904 | fail2: | ||
1905 | put_ep(&ep->com); | ||
1906 | fail1: | ||
1907 | out: | ||
1908 | return err; | ||
1909 | } | ||
1910 | |||
1911 | int iwch_destroy_listen(struct iw_cm_id *cm_id) | ||
1912 | { | ||
1913 | int err; | ||
1914 | struct iwch_listen_ep *ep = to_listen_ep(cm_id); | ||
1915 | |||
1916 | PDBG("%s ep %p\n", __FUNCTION__, ep); | ||
1917 | |||
1918 | might_sleep(); | ||
1919 | state_set(&ep->com, DEAD); | ||
1920 | ep->com.rpl_done = 0; | ||
1921 | ep->com.rpl_err = 0; | ||
1922 | err = listen_stop(ep); | ||
1923 | wait_event(ep->com.waitq, ep->com.rpl_done); | ||
1924 | cxgb3_free_stid(ep->com.tdev, ep->stid); | ||
1925 | err = ep->com.rpl_err; | ||
1926 | cm_id->rem_ref(cm_id); | ||
1927 | put_ep(&ep->com); | ||
1928 | return err; | ||
1929 | } | ||
1930 | |||
1931 | int iwch_ep_disconnect(struct iwch_ep *ep, int abrupt, gfp_t gfp) | ||
1932 | { | ||
1933 | int ret=0; | ||
1934 | unsigned long flags; | ||
1935 | int close = 0; | ||
1936 | |||
1937 | spin_lock_irqsave(&ep->com.lock, flags); | ||
1938 | |||
1939 | PDBG("%s ep %p state %s, abrupt %d\n", __FUNCTION__, ep, | ||
1940 | states[ep->com.state], abrupt); | ||
1941 | |||
1942 | if (ep->com.state == DEAD) { | ||
1943 | PDBG("%s already dead ep %p\n", __FUNCTION__, ep); | ||
1944 | goto out; | ||
1945 | } | ||
1946 | |||
1947 | if (abrupt) { | ||
1948 | if (ep->com.state != ABORTING) { | ||
1949 | ep->com.state = ABORTING; | ||
1950 | close = 1; | ||
1951 | } | ||
1952 | goto out; | ||
1953 | } | ||
1954 | |||
1955 | switch (ep->com.state) { | ||
1956 | case MPA_REQ_WAIT: | ||
1957 | case MPA_REQ_SENT: | ||
1958 | case MPA_REQ_RCVD: | ||
1959 | case MPA_REP_SENT: | ||
1960 | case FPDU_MODE: | ||
1961 | ep->com.state = CLOSING; | ||
1962 | close = 1; | ||
1963 | break; | ||
1964 | case CLOSING: | ||
1965 | start_ep_timer(ep); | ||
1966 | ep->com.state = MORIBUND; | ||
1967 | close = 1; | ||
1968 | break; | ||
1969 | case MORIBUND: | ||
1970 | break; | ||
1971 | default: | ||
1972 | BUG(); | ||
1973 | break; | ||
1974 | } | ||
1975 | out: | ||
1976 | spin_unlock_irqrestore(&ep->com.lock, flags); | ||
1977 | if (close) { | ||
1978 | if (abrupt) | ||
1979 | ret = send_abort(ep, NULL, gfp); | ||
1980 | else | ||
1981 | ret = send_halfclose(ep, gfp); | ||
1982 | } | ||
1983 | return ret; | ||
1984 | } | ||
1985 | |||
1986 | int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, | ||
1987 | struct l2t_entry *l2t) | ||
1988 | { | ||
1989 | struct iwch_ep *ep = ctx; | ||
1990 | |||
1991 | if (ep->dst != old) | ||
1992 | return 0; | ||
1993 | |||
1994 | PDBG("%s ep %p redirect to dst %p l2t %p\n", __FUNCTION__, ep, new, | ||
1995 | l2t); | ||
1996 | dst_hold(new); | ||
1997 | l2t_release(L2DATA(ep->com.tdev), ep->l2t); | ||
1998 | ep->l2t = l2t; | ||
1999 | dst_release(old); | ||
2000 | ep->dst = new; | ||
2001 | return 1; | ||
2002 | } | ||
2003 | |||
2004 | /* | ||
2005 | * All the CM events are handled on a work queue to have a safe context. | ||
2006 | */ | ||
2007 | static int sched(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | ||
2008 | { | ||
2009 | struct iwch_ep_common *epc = ctx; | ||
2010 | |||
2011 | get_ep(epc); | ||
2012 | |||
2013 | /* | ||
2014 | * Save ctx and tdev in the skb->cb area. | ||
2015 | */ | ||
2016 | *((void **) skb->cb) = ctx; | ||
2017 | *((struct t3cdev **) (skb->cb + sizeof(void *))) = tdev; | ||
2018 | |||
2019 | /* | ||
2020 | * Queue the skb and schedule the worker thread. | ||
2021 | */ | ||
2022 | skb_queue_tail(&rxq, skb); | ||
2023 | queue_work(workq, &skb_work); | ||
2024 | return 0; | ||
2025 | } | ||
2026 | |||
2027 | int __init iwch_cm_init(void) | ||
2028 | { | ||
2029 | skb_queue_head_init(&rxq); | ||
2030 | |||
2031 | workq = create_singlethread_workqueue("iw_cxgb3"); | ||
2032 | if (!workq) | ||
2033 | return -ENOMEM; | ||
2034 | |||
2035 | /* | ||
2036 | * All upcalls from the T3 Core go to sched() to | ||
2037 | * schedule the processing on a work queue. | ||
2038 | */ | ||
2039 | t3c_handlers[CPL_ACT_ESTABLISH] = sched; | ||
2040 | t3c_handlers[CPL_ACT_OPEN_RPL] = sched; | ||
2041 | t3c_handlers[CPL_RX_DATA] = sched; | ||
2042 | t3c_handlers[CPL_TX_DMA_ACK] = sched; | ||
2043 | t3c_handlers[CPL_ABORT_RPL_RSS] = sched; | ||
2044 | t3c_handlers[CPL_ABORT_RPL] = sched; | ||
2045 | t3c_handlers[CPL_PASS_OPEN_RPL] = sched; | ||
2046 | t3c_handlers[CPL_CLOSE_LISTSRV_RPL] = sched; | ||
2047 | t3c_handlers[CPL_PASS_ACCEPT_REQ] = sched; | ||
2048 | t3c_handlers[CPL_PASS_ESTABLISH] = sched; | ||
2049 | t3c_handlers[CPL_PEER_CLOSE] = sched; | ||
2050 | t3c_handlers[CPL_CLOSE_CON_RPL] = sched; | ||
2051 | t3c_handlers[CPL_ABORT_REQ_RSS] = sched; | ||
2052 | t3c_handlers[CPL_RDMA_TERMINATE] = sched; | ||
2053 | t3c_handlers[CPL_RDMA_EC_STATUS] = sched; | ||
2054 | |||
2055 | /* | ||
2056 | * These are the real handlers that are called from a | ||
2057 | * work queue. | ||
2058 | */ | ||
2059 | work_handlers[CPL_ACT_ESTABLISH] = act_establish; | ||
2060 | work_handlers[CPL_ACT_OPEN_RPL] = act_open_rpl; | ||
2061 | work_handlers[CPL_RX_DATA] = rx_data; | ||
2062 | work_handlers[CPL_TX_DMA_ACK] = tx_ack; | ||
2063 | work_handlers[CPL_ABORT_RPL_RSS] = abort_rpl; | ||
2064 | work_handlers[CPL_ABORT_RPL] = abort_rpl; | ||
2065 | work_handlers[CPL_PASS_OPEN_RPL] = pass_open_rpl; | ||
2066 | work_handlers[CPL_CLOSE_LISTSRV_RPL] = close_listsrv_rpl; | ||
2067 | work_handlers[CPL_PASS_ACCEPT_REQ] = pass_accept_req; | ||
2068 | work_handlers[CPL_PASS_ESTABLISH] = pass_establish; | ||
2069 | work_handlers[CPL_PEER_CLOSE] = peer_close; | ||
2070 | work_handlers[CPL_ABORT_REQ_RSS] = peer_abort; | ||
2071 | work_handlers[CPL_CLOSE_CON_RPL] = close_con_rpl; | ||
2072 | work_handlers[CPL_RDMA_TERMINATE] = terminate; | ||
2073 | work_handlers[CPL_RDMA_EC_STATUS] = ec_status; | ||
2074 | return 0; | ||
2075 | } | ||
2076 | |||
2077 | void __exit iwch_cm_term(void) | ||
2078 | { | ||
2079 | flush_workqueue(workq); | ||
2080 | destroy_workqueue(workq); | ||
2081 | } | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.h b/drivers/infiniband/hw/cxgb3/iwch_cm.h new file mode 100644 index 000000000000..7c810d904279 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.h | |||
@@ -0,0 +1,223 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #ifndef _IWCH_CM_H_ | ||
34 | #define _IWCH_CM_H_ | ||
35 | |||
36 | #include <linux/inet.h> | ||
37 | #include <linux/wait.h> | ||
38 | #include <linux/spinlock.h> | ||
39 | #include <linux/kref.h> | ||
40 | |||
41 | #include <rdma/ib_verbs.h> | ||
42 | #include <rdma/iw_cm.h> | ||
43 | |||
44 | #include "cxgb3_offload.h" | ||
45 | #include "iwch_provider.h" | ||
46 | |||
47 | #define MPA_KEY_REQ "MPA ID Req Frame" | ||
48 | #define MPA_KEY_REP "MPA ID Rep Frame" | ||
49 | |||
50 | #define MPA_MAX_PRIVATE_DATA 256 | ||
51 | #define MPA_REV 0 /* XXX - amso1100 uses rev 0 ! */ | ||
52 | #define MPA_REJECT 0x20 | ||
53 | #define MPA_CRC 0x40 | ||
54 | #define MPA_MARKERS 0x80 | ||
55 | #define MPA_FLAGS_MASK 0xE0 | ||
56 | |||
57 | #define put_ep(ep) { \ | ||
58 | PDBG("put_ep (via %s:%u) ep %p refcnt %d\n", __FUNCTION__, __LINE__, \ | ||
59 | ep, atomic_read(&((ep)->kref.refcount))); \ | ||
60 | kref_put(&((ep)->kref), __free_ep); \ | ||
61 | } | ||
62 | |||
63 | #define get_ep(ep) { \ | ||
64 | PDBG("get_ep (via %s:%u) ep %p, refcnt %d\n", __FUNCTION__, __LINE__, \ | ||
65 | ep, atomic_read(&((ep)->kref.refcount))); \ | ||
66 | kref_get(&((ep)->kref)); \ | ||
67 | } | ||
68 | |||
69 | struct mpa_message { | ||
70 | u8 key[16]; | ||
71 | u8 flags; | ||
72 | u8 revision; | ||
73 | __be16 private_data_size; | ||
74 | u8 private_data[0]; | ||
75 | }; | ||
76 | |||
77 | struct terminate_message { | ||
78 | u8 layer_etype; | ||
79 | u8 ecode; | ||
80 | __be16 hdrct_rsvd; | ||
81 | u8 len_hdrs[0]; | ||
82 | }; | ||
83 | |||
84 | #define TERM_MAX_LENGTH (sizeof(struct terminate_message) + 2 + 18 + 28) | ||
85 | |||
86 | enum iwch_layers_types { | ||
87 | LAYER_RDMAP = 0x00, | ||
88 | LAYER_DDP = 0x10, | ||
89 | LAYER_MPA = 0x20, | ||
90 | RDMAP_LOCAL_CATA = 0x00, | ||
91 | RDMAP_REMOTE_PROT = 0x01, | ||
92 | RDMAP_REMOTE_OP = 0x02, | ||
93 | DDP_LOCAL_CATA = 0x00, | ||
94 | DDP_TAGGED_ERR = 0x01, | ||
95 | DDP_UNTAGGED_ERR = 0x02, | ||
96 | DDP_LLP = 0x03 | ||
97 | }; | ||
98 | |||
99 | enum iwch_rdma_ecodes { | ||
100 | RDMAP_INV_STAG = 0x00, | ||
101 | RDMAP_BASE_BOUNDS = 0x01, | ||
102 | RDMAP_ACC_VIOL = 0x02, | ||
103 | RDMAP_STAG_NOT_ASSOC = 0x03, | ||
104 | RDMAP_TO_WRAP = 0x04, | ||
105 | RDMAP_INV_VERS = 0x05, | ||
106 | RDMAP_INV_OPCODE = 0x06, | ||
107 | RDMAP_STREAM_CATA = 0x07, | ||
108 | RDMAP_GLOBAL_CATA = 0x08, | ||
109 | RDMAP_CANT_INV_STAG = 0x09, | ||
110 | RDMAP_UNSPECIFIED = 0xff | ||
111 | }; | ||
112 | |||
113 | enum iwch_ddp_ecodes { | ||
114 | DDPT_INV_STAG = 0x00, | ||
115 | DDPT_BASE_BOUNDS = 0x01, | ||
116 | DDPT_STAG_NOT_ASSOC = 0x02, | ||
117 | DDPT_TO_WRAP = 0x03, | ||
118 | DDPT_INV_VERS = 0x04, | ||
119 | DDPU_INV_QN = 0x01, | ||
120 | DDPU_INV_MSN_NOBUF = 0x02, | ||
121 | DDPU_INV_MSN_RANGE = 0x03, | ||
122 | DDPU_INV_MO = 0x04, | ||
123 | DDPU_MSG_TOOBIG = 0x05, | ||
124 | DDPU_INV_VERS = 0x06 | ||
125 | }; | ||
126 | |||
127 | enum iwch_mpa_ecodes { | ||
128 | MPA_CRC_ERR = 0x02, | ||
129 | MPA_MARKER_ERR = 0x03 | ||
130 | }; | ||
131 | |||
132 | enum iwch_ep_state { | ||
133 | IDLE = 0, | ||
134 | LISTEN, | ||
135 | CONNECTING, | ||
136 | MPA_REQ_WAIT, | ||
137 | MPA_REQ_SENT, | ||
138 | MPA_REQ_RCVD, | ||
139 | MPA_REP_SENT, | ||
140 | FPDU_MODE, | ||
141 | ABORTING, | ||
142 | CLOSING, | ||
143 | MORIBUND, | ||
144 | DEAD, | ||
145 | }; | ||
146 | |||
147 | struct iwch_ep_common { | ||
148 | struct iw_cm_id *cm_id; | ||
149 | struct iwch_qp *qp; | ||
150 | struct t3cdev *tdev; | ||
151 | enum iwch_ep_state state; | ||
152 | struct kref kref; | ||
153 | spinlock_t lock; | ||
154 | struct sockaddr_in local_addr; | ||
155 | struct sockaddr_in remote_addr; | ||
156 | wait_queue_head_t waitq; | ||
157 | int rpl_done; | ||
158 | int rpl_err; | ||
159 | }; | ||
160 | |||
161 | struct iwch_listen_ep { | ||
162 | struct iwch_ep_common com; | ||
163 | unsigned int stid; | ||
164 | int backlog; | ||
165 | }; | ||
166 | |||
167 | struct iwch_ep { | ||
168 | struct iwch_ep_common com; | ||
169 | struct iwch_ep *parent_ep; | ||
170 | struct timer_list timer; | ||
171 | unsigned int atid; | ||
172 | u32 hwtid; | ||
173 | u32 snd_seq; | ||
174 | struct l2t_entry *l2t; | ||
175 | struct dst_entry *dst; | ||
176 | struct sk_buff *mpa_skb; | ||
177 | struct iwch_mpa_attributes mpa_attr; | ||
178 | unsigned int mpa_pkt_len; | ||
179 | u8 mpa_pkt[sizeof(struct mpa_message) + MPA_MAX_PRIVATE_DATA]; | ||
180 | u8 tos; | ||
181 | u16 emss; | ||
182 | u16 plen; | ||
183 | u32 ird; | ||
184 | u32 ord; | ||
185 | }; | ||
186 | |||
187 | static inline struct iwch_ep *to_ep(struct iw_cm_id *cm_id) | ||
188 | { | ||
189 | return cm_id->provider_data; | ||
190 | } | ||
191 | |||
192 | static inline struct iwch_listen_ep *to_listen_ep(struct iw_cm_id *cm_id) | ||
193 | { | ||
194 | return cm_id->provider_data; | ||
195 | } | ||
196 | |||
197 | static inline int compute_wscale(int win) | ||
198 | { | ||
199 | int wscale = 0; | ||
200 | |||
201 | while (wscale < 14 && (65535<<wscale) < win) | ||
202 | wscale++; | ||
203 | return wscale; | ||
204 | } | ||
205 | |||
206 | /* CM prototypes */ | ||
207 | |||
208 | int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); | ||
209 | int iwch_create_listen(struct iw_cm_id *cm_id, int backlog); | ||
210 | int iwch_destroy_listen(struct iw_cm_id *cm_id); | ||
211 | int iwch_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len); | ||
212 | int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); | ||
213 | int iwch_ep_disconnect(struct iwch_ep *ep, int abrupt, gfp_t gfp); | ||
214 | int iwch_quiesce_tid(struct iwch_ep *ep); | ||
215 | int iwch_resume_tid(struct iwch_ep *ep); | ||
216 | void __free_ep(struct kref *kref); | ||
217 | void iwch_rearp(struct iwch_ep *ep); | ||
218 | int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, struct l2t_entry *l2t); | ||
219 | |||
220 | int __init iwch_cm_init(void); | ||
221 | void __exit iwch_cm_term(void); | ||
222 | |||
223 | #endif /* _IWCH_CM_H_ */ | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cq.c b/drivers/infiniband/hw/cxgb3/iwch_cq.c new file mode 100644 index 000000000000..98b3bdb5de9e --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_cq.c | |||
@@ -0,0 +1,225 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #include "iwch_provider.h" | ||
34 | #include "iwch.h" | ||
35 | |||
36 | /* | ||
37 | * Get one cq entry from cxio and map it to openib. | ||
38 | * | ||
39 | * Returns: | ||
40 | * 0 EMPTY; | ||
41 | * 1 cqe returned | ||
42 | * -EAGAIN caller must try again | ||
43 | * any other -errno fatal error | ||
44 | */ | ||
45 | static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp, | ||
46 | struct ib_wc *wc) | ||
47 | { | ||
48 | struct iwch_qp *qhp = NULL; | ||
49 | struct t3_cqe cqe, *rd_cqe; | ||
50 | struct t3_wq *wq; | ||
51 | u32 credit = 0; | ||
52 | u8 cqe_flushed; | ||
53 | u64 cookie; | ||
54 | int ret = 1; | ||
55 | |||
56 | rd_cqe = cxio_next_cqe(&chp->cq); | ||
57 | |||
58 | if (!rd_cqe) | ||
59 | return 0; | ||
60 | |||
61 | qhp = get_qhp(rhp, CQE_QPID(*rd_cqe)); | ||
62 | if (!qhp) | ||
63 | wq = NULL; | ||
64 | else { | ||
65 | spin_lock(&qhp->lock); | ||
66 | wq = &(qhp->wq); | ||
67 | } | ||
68 | ret = cxio_poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, | ||
69 | &credit); | ||
70 | if (t3a_device(chp->rhp) && credit) { | ||
71 | PDBG("%s updating %d cq credits on id %d\n", __FUNCTION__, | ||
72 | credit, chp->cq.cqid); | ||
73 | cxio_hal_cq_op(&rhp->rdev, &chp->cq, CQ_CREDIT_UPDATE, credit); | ||
74 | } | ||
75 | |||
76 | if (ret) { | ||
77 | ret = -EAGAIN; | ||
78 | goto out; | ||
79 | } | ||
80 | ret = 1; | ||
81 | |||
82 | wc->wr_id = cookie; | ||
83 | wc->qp = &qhp->ibqp; | ||
84 | wc->vendor_err = CQE_STATUS(cqe); | ||
85 | |||
86 | PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x " | ||
87 | "lo 0x%x cookie 0x%llx\n", __FUNCTION__, | ||
88 | CQE_QPID(cqe), CQE_TYPE(cqe), | ||
89 | CQE_OPCODE(cqe), CQE_STATUS(cqe), CQE_WRID_HI(cqe), | ||
90 | CQE_WRID_LOW(cqe), (unsigned long long) cookie); | ||
91 | |||
92 | if (CQE_TYPE(cqe) == 0) { | ||
93 | if (!CQE_STATUS(cqe)) | ||
94 | wc->byte_len = CQE_LEN(cqe); | ||
95 | else | ||
96 | wc->byte_len = 0; | ||
97 | wc->opcode = IB_WC_RECV; | ||
98 | } else { | ||
99 | switch (CQE_OPCODE(cqe)) { | ||
100 | case T3_RDMA_WRITE: | ||
101 | wc->opcode = IB_WC_RDMA_WRITE; | ||
102 | break; | ||
103 | case T3_READ_REQ: | ||
104 | wc->opcode = IB_WC_RDMA_READ; | ||
105 | wc->byte_len = CQE_LEN(cqe); | ||
106 | break; | ||
107 | case T3_SEND: | ||
108 | case T3_SEND_WITH_SE: | ||
109 | wc->opcode = IB_WC_SEND; | ||
110 | break; | ||
111 | case T3_BIND_MW: | ||
112 | wc->opcode = IB_WC_BIND_MW; | ||
113 | break; | ||
114 | |||
115 | /* these aren't supported yet */ | ||
116 | case T3_SEND_WITH_INV: | ||
117 | case T3_SEND_WITH_SE_INV: | ||
118 | case T3_LOCAL_INV: | ||
119 | case T3_FAST_REGISTER: | ||
120 | default: | ||
121 | printk(KERN_ERR MOD "Unexpected opcode %d " | ||
122 | "in the CQE received for QPID=0x%0x\n", | ||
123 | CQE_OPCODE(cqe), CQE_QPID(cqe)); | ||
124 | ret = -EINVAL; | ||
125 | goto out; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | if (cqe_flushed) | ||
130 | wc->status = IB_WC_WR_FLUSH_ERR; | ||
131 | else { | ||
132 | |||
133 | switch (CQE_STATUS(cqe)) { | ||
134 | case TPT_ERR_SUCCESS: | ||
135 | wc->status = IB_WC_SUCCESS; | ||
136 | break; | ||
137 | case TPT_ERR_STAG: | ||
138 | wc->status = IB_WC_LOC_ACCESS_ERR; | ||
139 | break; | ||
140 | case TPT_ERR_PDID: | ||
141 | wc->status = IB_WC_LOC_PROT_ERR; | ||
142 | break; | ||
143 | case TPT_ERR_QPID: | ||
144 | case TPT_ERR_ACCESS: | ||
145 | wc->status = IB_WC_LOC_ACCESS_ERR; | ||
146 | break; | ||
147 | case TPT_ERR_WRAP: | ||
148 | wc->status = IB_WC_GENERAL_ERR; | ||
149 | break; | ||
150 | case TPT_ERR_BOUND: | ||
151 | wc->status = IB_WC_LOC_LEN_ERR; | ||
152 | break; | ||
153 | case TPT_ERR_INVALIDATE_SHARED_MR: | ||
154 | case TPT_ERR_INVALIDATE_MR_WITH_MW_BOUND: | ||
155 | wc->status = IB_WC_MW_BIND_ERR; | ||
156 | break; | ||
157 | case TPT_ERR_CRC: | ||
158 | case TPT_ERR_MARKER: | ||
159 | case TPT_ERR_PDU_LEN_ERR: | ||
160 | case TPT_ERR_OUT_OF_RQE: | ||
161 | case TPT_ERR_DDP_VERSION: | ||
162 | case TPT_ERR_RDMA_VERSION: | ||
163 | case TPT_ERR_DDP_QUEUE_NUM: | ||
164 | case TPT_ERR_MSN: | ||
165 | case TPT_ERR_TBIT: | ||
166 | case TPT_ERR_MO: | ||
167 | case TPT_ERR_MSN_RANGE: | ||
168 | case TPT_ERR_IRD_OVERFLOW: | ||
169 | case TPT_ERR_OPCODE: | ||
170 | wc->status = IB_WC_FATAL_ERR; | ||
171 | break; | ||
172 | case TPT_ERR_SWFLUSH: | ||
173 | wc->status = IB_WC_WR_FLUSH_ERR; | ||
174 | break; | ||
175 | default: | ||
176 | printk(KERN_ERR MOD "Unexpected cqe_status 0x%x for " | ||
177 | "QPID=0x%0x\n", CQE_STATUS(cqe), CQE_QPID(cqe)); | ||
178 | ret = -EINVAL; | ||
179 | } | ||
180 | } | ||
181 | out: | ||
182 | if (wq) | ||
183 | spin_unlock(&qhp->lock); | ||
184 | return ret; | ||
185 | } | ||
186 | |||
187 | int iwch_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) | ||
188 | { | ||
189 | struct iwch_dev *rhp; | ||
190 | struct iwch_cq *chp; | ||
191 | unsigned long flags; | ||
192 | int npolled; | ||
193 | int err = 0; | ||
194 | |||
195 | chp = to_iwch_cq(ibcq); | ||
196 | rhp = chp->rhp; | ||
197 | |||
198 | spin_lock_irqsave(&chp->lock, flags); | ||
199 | for (npolled = 0; npolled < num_entries; ++npolled) { | ||
200 | #ifdef DEBUG | ||
201 | int i=0; | ||
202 | #endif | ||
203 | |||
204 | /* | ||
205 | * Because T3 can post CQEs that are _not_ associated | ||
206 | * with a WR, we might have to poll again after removing | ||
207 | * one of these. | ||
208 | */ | ||
209 | do { | ||
210 | err = iwch_poll_cq_one(rhp, chp, wc + npolled); | ||
211 | #ifdef DEBUG | ||
212 | BUG_ON(++i > 1000); | ||
213 | #endif | ||
214 | } while (err == -EAGAIN); | ||
215 | if (err <= 0) | ||
216 | break; | ||
217 | } | ||
218 | spin_unlock_irqrestore(&chp->lock, flags); | ||
219 | |||
220 | if (err < 0) | ||
221 | return err; | ||
222 | else { | ||
223 | return npolled; | ||
224 | } | ||
225 | } | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_ev.c b/drivers/infiniband/hw/cxgb3/iwch_ev.c new file mode 100644 index 000000000000..a6efa8fe15d8 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_ev.c | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #include <linux/slab.h> | ||
34 | #include <linux/mman.h> | ||
35 | #include <net/sock.h> | ||
36 | #include "iwch_provider.h" | ||
37 | #include "iwch.h" | ||
38 | #include "iwch_cm.h" | ||
39 | #include "cxio_hal.h" | ||
40 | #include "cxio_wr.h" | ||
41 | |||
42 | static void post_qp_event(struct iwch_dev *rnicp, struct iwch_cq *chp, | ||
43 | struct respQ_msg_t *rsp_msg, | ||
44 | enum ib_event_type ib_event, | ||
45 | int send_term) | ||
46 | { | ||
47 | struct ib_event event; | ||
48 | struct iwch_qp_attributes attrs; | ||
49 | struct iwch_qp *qhp; | ||
50 | |||
51 | printk(KERN_ERR "%s - AE qpid 0x%x opcode %d status 0x%x " | ||
52 | "type %d wrid.hi 0x%x wrid.lo 0x%x \n", __FUNCTION__, | ||
53 | CQE_QPID(rsp_msg->cqe), CQE_OPCODE(rsp_msg->cqe), | ||
54 | CQE_STATUS(rsp_msg->cqe), CQE_TYPE(rsp_msg->cqe), | ||
55 | CQE_WRID_HI(rsp_msg->cqe), CQE_WRID_LOW(rsp_msg->cqe)); | ||
56 | |||
57 | spin_lock(&rnicp->lock); | ||
58 | qhp = get_qhp(rnicp, CQE_QPID(rsp_msg->cqe)); | ||
59 | |||
60 | if (!qhp) { | ||
61 | printk(KERN_ERR "%s unaffiliated error 0x%x qpid 0x%x\n", | ||
62 | __FUNCTION__, CQE_STATUS(rsp_msg->cqe), | ||
63 | CQE_QPID(rsp_msg->cqe)); | ||
64 | spin_unlock(&rnicp->lock); | ||
65 | return; | ||
66 | } | ||
67 | |||
68 | if ((qhp->attr.state == IWCH_QP_STATE_ERROR) || | ||
69 | (qhp->attr.state == IWCH_QP_STATE_TERMINATE)) { | ||
70 | PDBG("%s AE received after RTS - " | ||
71 | "qp state %d qpid 0x%x status 0x%x\n", __FUNCTION__, | ||
72 | qhp->attr.state, qhp->wq.qpid, CQE_STATUS(rsp_msg->cqe)); | ||
73 | spin_unlock(&rnicp->lock); | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | atomic_inc(&qhp->refcnt); | ||
78 | spin_unlock(&rnicp->lock); | ||
79 | |||
80 | event.event = ib_event; | ||
81 | event.device = chp->ibcq.device; | ||
82 | if (ib_event == IB_EVENT_CQ_ERR) | ||
83 | event.element.cq = &chp->ibcq; | ||
84 | else | ||
85 | event.element.qp = &qhp->ibqp; | ||
86 | |||
87 | if (qhp->ibqp.event_handler) | ||
88 | (*qhp->ibqp.event_handler)(&event, qhp->ibqp.qp_context); | ||
89 | |||
90 | if (qhp->attr.state == IWCH_QP_STATE_RTS) { | ||
91 | attrs.next_state = IWCH_QP_STATE_TERMINATE; | ||
92 | iwch_modify_qp(qhp->rhp, qhp, IWCH_QP_ATTR_NEXT_STATE, | ||
93 | &attrs, 1); | ||
94 | if (send_term) | ||
95 | iwch_post_terminate(qhp, rsp_msg); | ||
96 | } | ||
97 | |||
98 | if (atomic_dec_and_test(&qhp->refcnt)) | ||
99 | wake_up(&qhp->wait); | ||
100 | } | ||
101 | |||
102 | void iwch_ev_dispatch(struct cxio_rdev *rdev_p, struct sk_buff *skb) | ||
103 | { | ||
104 | struct iwch_dev *rnicp; | ||
105 | struct respQ_msg_t *rsp_msg = (struct respQ_msg_t *) skb->data; | ||
106 | struct iwch_cq *chp; | ||
107 | struct iwch_qp *qhp; | ||
108 | u32 cqid = RSPQ_CQID(rsp_msg); | ||
109 | |||
110 | rnicp = (struct iwch_dev *) rdev_p->ulp; | ||
111 | spin_lock(&rnicp->lock); | ||
112 | chp = get_chp(rnicp, cqid); | ||
113 | qhp = get_qhp(rnicp, CQE_QPID(rsp_msg->cqe)); | ||
114 | if (!chp || !qhp) { | ||
115 | printk(KERN_ERR MOD "BAD AE cqid 0x%x qpid 0x%x opcode %d " | ||
116 | "status 0x%x type %d wrid.hi 0x%x wrid.lo 0x%x \n", | ||
117 | cqid, CQE_QPID(rsp_msg->cqe), | ||
118 | CQE_OPCODE(rsp_msg->cqe), CQE_STATUS(rsp_msg->cqe), | ||
119 | CQE_TYPE(rsp_msg->cqe), CQE_WRID_HI(rsp_msg->cqe), | ||
120 | CQE_WRID_LOW(rsp_msg->cqe)); | ||
121 | spin_unlock(&rnicp->lock); | ||
122 | goto out; | ||
123 | } | ||
124 | iwch_qp_add_ref(&qhp->ibqp); | ||
125 | atomic_inc(&chp->refcnt); | ||
126 | spin_unlock(&rnicp->lock); | ||
127 | |||
128 | /* | ||
129 | * 1) completion of our sending a TERMINATE. | ||
130 | * 2) incoming TERMINATE message. | ||
131 | */ | ||
132 | if ((CQE_OPCODE(rsp_msg->cqe) == T3_TERMINATE) && | ||
133 | (CQE_STATUS(rsp_msg->cqe) == 0)) { | ||
134 | if (SQ_TYPE(rsp_msg->cqe)) { | ||
135 | PDBG("%s QPID 0x%x ep %p disconnecting\n", | ||
136 | __FUNCTION__, qhp->wq.qpid, qhp->ep); | ||
137 | iwch_ep_disconnect(qhp->ep, 0, GFP_ATOMIC); | ||
138 | } else { | ||
139 | PDBG("%s post REQ_ERR AE QPID 0x%x\n", __FUNCTION__, | ||
140 | qhp->wq.qpid); | ||
141 | post_qp_event(rnicp, chp, rsp_msg, | ||
142 | IB_EVENT_QP_REQ_ERR, 0); | ||
143 | iwch_ep_disconnect(qhp->ep, 0, GFP_ATOMIC); | ||
144 | } | ||
145 | goto done; | ||
146 | } | ||
147 | |||
148 | /* Bad incoming Read request */ | ||
149 | if (SQ_TYPE(rsp_msg->cqe) && | ||
150 | (CQE_OPCODE(rsp_msg->cqe) == T3_READ_RESP)) { | ||
151 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_REQ_ERR, 1); | ||
152 | goto done; | ||
153 | } | ||
154 | |||
155 | /* Bad incoming write */ | ||
156 | if (RQ_TYPE(rsp_msg->cqe) && | ||
157 | (CQE_OPCODE(rsp_msg->cqe) == T3_RDMA_WRITE)) { | ||
158 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_REQ_ERR, 1); | ||
159 | goto done; | ||
160 | } | ||
161 | |||
162 | switch (CQE_STATUS(rsp_msg->cqe)) { | ||
163 | |||
164 | /* Completion Events */ | ||
165 | case TPT_ERR_SUCCESS: | ||
166 | |||
167 | /* | ||
168 | * Confirm the destination entry if this is a RECV completion. | ||
169 | */ | ||
170 | if (qhp->ep && SQ_TYPE(rsp_msg->cqe)) | ||
171 | dst_confirm(qhp->ep->dst); | ||
172 | (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context); | ||
173 | break; | ||
174 | |||
175 | case TPT_ERR_STAG: | ||
176 | case TPT_ERR_PDID: | ||
177 | case TPT_ERR_QPID: | ||
178 | case TPT_ERR_ACCESS: | ||
179 | case TPT_ERR_WRAP: | ||
180 | case TPT_ERR_BOUND: | ||
181 | case TPT_ERR_INVALIDATE_SHARED_MR: | ||
182 | case TPT_ERR_INVALIDATE_MR_WITH_MW_BOUND: | ||
183 | printk(KERN_ERR "%s - CQE Err qpid 0x%x opcode %d status 0x%x " | ||
184 | "type %d wrid.hi 0x%x wrid.lo 0x%x \n", __FUNCTION__, | ||
185 | CQE_QPID(rsp_msg->cqe), CQE_OPCODE(rsp_msg->cqe), | ||
186 | CQE_STATUS(rsp_msg->cqe), CQE_TYPE(rsp_msg->cqe), | ||
187 | CQE_WRID_HI(rsp_msg->cqe), CQE_WRID_LOW(rsp_msg->cqe)); | ||
188 | (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context); | ||
189 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_ACCESS_ERR, 1); | ||
190 | break; | ||
191 | |||
192 | /* Device Fatal Errors */ | ||
193 | case TPT_ERR_ECC: | ||
194 | case TPT_ERR_ECC_PSTAG: | ||
195 | case TPT_ERR_INTERNAL_ERR: | ||
196 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_DEVICE_FATAL, 1); | ||
197 | break; | ||
198 | |||
199 | /* QP Fatal Errors */ | ||
200 | case TPT_ERR_OUT_OF_RQE: | ||
201 | case TPT_ERR_PBL_ADDR_BOUND: | ||
202 | case TPT_ERR_CRC: | ||
203 | case TPT_ERR_MARKER: | ||
204 | case TPT_ERR_PDU_LEN_ERR: | ||
205 | case TPT_ERR_DDP_VERSION: | ||
206 | case TPT_ERR_RDMA_VERSION: | ||
207 | case TPT_ERR_OPCODE: | ||
208 | case TPT_ERR_DDP_QUEUE_NUM: | ||
209 | case TPT_ERR_MSN: | ||
210 | case TPT_ERR_TBIT: | ||
211 | case TPT_ERR_MO: | ||
212 | case TPT_ERR_MSN_GAP: | ||
213 | case TPT_ERR_MSN_RANGE: | ||
214 | case TPT_ERR_RQE_ADDR_BOUND: | ||
215 | case TPT_ERR_IRD_OVERFLOW: | ||
216 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_FATAL, 1); | ||
217 | break; | ||
218 | |||
219 | default: | ||
220 | printk(KERN_ERR MOD "Unknown T3 status 0x%x QPID 0x%x\n", | ||
221 | CQE_STATUS(rsp_msg->cqe), qhp->wq.qpid); | ||
222 | post_qp_event(rnicp, chp, rsp_msg, IB_EVENT_QP_FATAL, 1); | ||
223 | break; | ||
224 | } | ||
225 | done: | ||
226 | if (atomic_dec_and_test(&chp->refcnt)) | ||
227 | wake_up(&chp->wait); | ||
228 | iwch_qp_rem_ref(&qhp->ibqp); | ||
229 | out: | ||
230 | dev_kfree_skb_irq(skb); | ||
231 | } | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_mem.c b/drivers/infiniband/hw/cxgb3/iwch_mem.c new file mode 100644 index 000000000000..2b6cd53bb3fc --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_mem.c | |||
@@ -0,0 +1,172 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #include <asm/byteorder.h> | ||
34 | |||
35 | #include <rdma/iw_cm.h> | ||
36 | #include <rdma/ib_verbs.h> | ||
37 | |||
38 | #include "cxio_hal.h" | ||
39 | #include "iwch.h" | ||
40 | #include "iwch_provider.h" | ||
41 | |||
42 | int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php, | ||
43 | struct iwch_mr *mhp, | ||
44 | int shift, | ||
45 | __be64 *page_list) | ||
46 | { | ||
47 | u32 stag; | ||
48 | u32 mmid; | ||
49 | |||
50 | |||
51 | if (cxio_register_phys_mem(&rhp->rdev, | ||
52 | &stag, mhp->attr.pdid, | ||
53 | mhp->attr.perms, | ||
54 | mhp->attr.zbva, | ||
55 | mhp->attr.va_fbo, | ||
56 | mhp->attr.len, | ||
57 | shift-12, | ||
58 | page_list, | ||
59 | &mhp->attr.pbl_size, &mhp->attr.pbl_addr)) | ||
60 | return -ENOMEM; | ||
61 | mhp->attr.state = 1; | ||
62 | mhp->attr.stag = stag; | ||
63 | mmid = stag >> 8; | ||
64 | mhp->ibmr.rkey = mhp->ibmr.lkey = stag; | ||
65 | insert_handle(rhp, &rhp->mmidr, mhp, mmid); | ||
66 | PDBG("%s mmid 0x%x mhp %p\n", __FUNCTION__, mmid, mhp); | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php, | ||
71 | struct iwch_mr *mhp, | ||
72 | int shift, | ||
73 | __be64 *page_list, | ||
74 | int npages) | ||
75 | { | ||
76 | u32 stag; | ||
77 | u32 mmid; | ||
78 | |||
79 | |||
80 | /* We could support this... */ | ||
81 | if (npages > mhp->attr.pbl_size) | ||
82 | return -ENOMEM; | ||
83 | |||
84 | stag = mhp->attr.stag; | ||
85 | if (cxio_reregister_phys_mem(&rhp->rdev, | ||
86 | &stag, mhp->attr.pdid, | ||
87 | mhp->attr.perms, | ||
88 | mhp->attr.zbva, | ||
89 | mhp->attr.va_fbo, | ||
90 | mhp->attr.len, | ||
91 | shift-12, | ||
92 | page_list, | ||
93 | &mhp->attr.pbl_size, &mhp->attr.pbl_addr)) | ||
94 | return -ENOMEM; | ||
95 | mhp->attr.state = 1; | ||
96 | mhp->attr.stag = stag; | ||
97 | mmid = stag >> 8; | ||
98 | mhp->ibmr.rkey = mhp->ibmr.lkey = stag; | ||
99 | insert_handle(rhp, &rhp->mmidr, mhp, mmid); | ||
100 | PDBG("%s mmid 0x%x mhp %p\n", __FUNCTION__, mmid, mhp); | ||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | int build_phys_page_list(struct ib_phys_buf *buffer_list, | ||
105 | int num_phys_buf, | ||
106 | u64 *iova_start, | ||
107 | u64 *total_size, | ||
108 | int *npages, | ||
109 | int *shift, | ||
110 | __be64 **page_list) | ||
111 | { | ||
112 | u64 mask; | ||
113 | int i, j, n; | ||
114 | |||
115 | mask = 0; | ||
116 | *total_size = 0; | ||
117 | for (i = 0; i < num_phys_buf; ++i) { | ||
118 | if (i != 0 && buffer_list[i].addr & ~PAGE_MASK) | ||
119 | return -EINVAL; | ||
120 | if (i != 0 && i != num_phys_buf - 1 && | ||
121 | (buffer_list[i].size & ~PAGE_MASK)) | ||
122 | return -EINVAL; | ||
123 | *total_size += buffer_list[i].size; | ||
124 | if (i > 0) | ||
125 | mask |= buffer_list[i].addr; | ||
126 | } | ||
127 | |||
128 | if (*total_size > 0xFFFFFFFFULL) | ||
129 | return -ENOMEM; | ||
130 | |||
131 | /* Find largest page shift we can use to cover buffers */ | ||
132 | for (*shift = PAGE_SHIFT; *shift < 27; ++(*shift)) | ||
133 | if (num_phys_buf > 1) { | ||
134 | if ((1ULL << *shift) & mask) | ||
135 | break; | ||
136 | } else | ||
137 | if (1ULL << *shift >= | ||
138 | buffer_list[0].size + | ||
139 | (buffer_list[0].addr & ((1ULL << *shift) - 1))) | ||
140 | break; | ||
141 | |||
142 | buffer_list[0].size += buffer_list[0].addr & ((1ULL << *shift) - 1); | ||
143 | buffer_list[0].addr &= ~0ull << *shift; | ||
144 | |||
145 | *npages = 0; | ||
146 | for (i = 0; i < num_phys_buf; ++i) | ||
147 | *npages += (buffer_list[i].size + | ||
148 | (1ULL << *shift) - 1) >> *shift; | ||
149 | |||
150 | if (!*npages) | ||
151 | return -EINVAL; | ||
152 | |||
153 | *page_list = kmalloc(sizeof(u64) * *npages, GFP_KERNEL); | ||
154 | if (!*page_list) | ||
155 | return -ENOMEM; | ||
156 | |||
157 | n = 0; | ||
158 | for (i = 0; i < num_phys_buf; ++i) | ||
159 | for (j = 0; | ||
160 | j < (buffer_list[i].size + (1ULL << *shift) - 1) >> *shift; | ||
161 | ++j) | ||
162 | (*page_list)[n++] = cpu_to_be64(buffer_list[i].addr + | ||
163 | ((u64) j << *shift)); | ||
164 | |||
165 | PDBG("%s va 0x%llx mask 0x%llx shift %d len %lld pbl_size %d\n", | ||
166 | __FUNCTION__, (unsigned long long) *iova_start, | ||
167 | (unsigned long long) mask, *shift, (unsigned long long) *total_size, | ||
168 | *npages); | ||
169 | |||
170 | return 0; | ||
171 | |||
172 | } | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c new file mode 100644 index 000000000000..6861087d776c --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c | |||
@@ -0,0 +1,1203 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #include <linux/module.h> | ||
34 | #include <linux/moduleparam.h> | ||
35 | #include <linux/device.h> | ||
36 | #include <linux/netdevice.h> | ||
37 | #include <linux/etherdevice.h> | ||
38 | #include <linux/delay.h> | ||
39 | #include <linux/errno.h> | ||
40 | #include <linux/list.h> | ||
41 | #include <linux/spinlock.h> | ||
42 | #include <linux/ethtool.h> | ||
43 | |||
44 | #include <asm/io.h> | ||
45 | #include <asm/irq.h> | ||
46 | #include <asm/byteorder.h> | ||
47 | |||
48 | #include <rdma/iw_cm.h> | ||
49 | #include <rdma/ib_verbs.h> | ||
50 | #include <rdma/ib_smi.h> | ||
51 | #include <rdma/ib_user_verbs.h> | ||
52 | |||
53 | #include "cxio_hal.h" | ||
54 | #include "iwch.h" | ||
55 | #include "iwch_provider.h" | ||
56 | #include "iwch_cm.h" | ||
57 | #include "iwch_user.h" | ||
58 | |||
59 | static int iwch_modify_port(struct ib_device *ibdev, | ||
60 | u8 port, int port_modify_mask, | ||
61 | struct ib_port_modify *props) | ||
62 | { | ||
63 | return -ENOSYS; | ||
64 | } | ||
65 | |||
66 | static struct ib_ah *iwch_ah_create(struct ib_pd *pd, | ||
67 | struct ib_ah_attr *ah_attr) | ||
68 | { | ||
69 | return ERR_PTR(-ENOSYS); | ||
70 | } | ||
71 | |||
72 | static int iwch_ah_destroy(struct ib_ah *ah) | ||
73 | { | ||
74 | return -ENOSYS; | ||
75 | } | ||
76 | |||
77 | static int iwch_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | ||
78 | { | ||
79 | return -ENOSYS; | ||
80 | } | ||
81 | |||
82 | static int iwch_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | ||
83 | { | ||
84 | return -ENOSYS; | ||
85 | } | ||
86 | |||
87 | static int iwch_process_mad(struct ib_device *ibdev, | ||
88 | int mad_flags, | ||
89 | u8 port_num, | ||
90 | struct ib_wc *in_wc, | ||
91 | struct ib_grh *in_grh, | ||
92 | struct ib_mad *in_mad, struct ib_mad *out_mad) | ||
93 | { | ||
94 | return -ENOSYS; | ||
95 | } | ||
96 | |||
97 | static int iwch_dealloc_ucontext(struct ib_ucontext *context) | ||
98 | { | ||
99 | struct iwch_dev *rhp = to_iwch_dev(context->device); | ||
100 | struct iwch_ucontext *ucontext = to_iwch_ucontext(context); | ||
101 | struct iwch_mm_entry *mm, *tmp; | ||
102 | |||
103 | PDBG("%s context %p\n", __FUNCTION__, context); | ||
104 | list_for_each_entry_safe(mm, tmp, &ucontext->mmaps, entry) | ||
105 | kfree(mm); | ||
106 | cxio_release_ucontext(&rhp->rdev, &ucontext->uctx); | ||
107 | kfree(ucontext); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static struct ib_ucontext *iwch_alloc_ucontext(struct ib_device *ibdev, | ||
112 | struct ib_udata *udata) | ||
113 | { | ||
114 | struct iwch_ucontext *context; | ||
115 | struct iwch_dev *rhp = to_iwch_dev(ibdev); | ||
116 | |||
117 | PDBG("%s ibdev %p\n", __FUNCTION__, ibdev); | ||
118 | context = kzalloc(sizeof(*context), GFP_KERNEL); | ||
119 | if (!context) | ||
120 | return ERR_PTR(-ENOMEM); | ||
121 | cxio_init_ucontext(&rhp->rdev, &context->uctx); | ||
122 | INIT_LIST_HEAD(&context->mmaps); | ||
123 | spin_lock_init(&context->mmap_lock); | ||
124 | return &context->ibucontext; | ||
125 | } | ||
126 | |||
127 | static int iwch_destroy_cq(struct ib_cq *ib_cq) | ||
128 | { | ||
129 | struct iwch_cq *chp; | ||
130 | |||
131 | PDBG("%s ib_cq %p\n", __FUNCTION__, ib_cq); | ||
132 | chp = to_iwch_cq(ib_cq); | ||
133 | |||
134 | remove_handle(chp->rhp, &chp->rhp->cqidr, chp->cq.cqid); | ||
135 | atomic_dec(&chp->refcnt); | ||
136 | wait_event(chp->wait, !atomic_read(&chp->refcnt)); | ||
137 | |||
138 | cxio_destroy_cq(&chp->rhp->rdev, &chp->cq); | ||
139 | kfree(chp); | ||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, | ||
144 | struct ib_ucontext *ib_context, | ||
145 | struct ib_udata *udata) | ||
146 | { | ||
147 | struct iwch_dev *rhp; | ||
148 | struct iwch_cq *chp; | ||
149 | struct iwch_create_cq_resp uresp; | ||
150 | struct iwch_create_cq_req ureq; | ||
151 | struct iwch_ucontext *ucontext = NULL; | ||
152 | |||
153 | PDBG("%s ib_dev %p entries %d\n", __FUNCTION__, ibdev, entries); | ||
154 | rhp = to_iwch_dev(ibdev); | ||
155 | chp = kzalloc(sizeof(*chp), GFP_KERNEL); | ||
156 | if (!chp) | ||
157 | return ERR_PTR(-ENOMEM); | ||
158 | |||
159 | if (ib_context) { | ||
160 | ucontext = to_iwch_ucontext(ib_context); | ||
161 | if (!t3a_device(rhp)) { | ||
162 | if (ib_copy_from_udata(&ureq, udata, sizeof (ureq))) { | ||
163 | kfree(chp); | ||
164 | return ERR_PTR(-EFAULT); | ||
165 | } | ||
166 | chp->user_rptr_addr = (u32 __user *)(unsigned long)ureq.user_rptr_addr; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | if (t3a_device(rhp)) { | ||
171 | |||
172 | /* | ||
173 | * T3A: Add some fluff to handle extra CQEs inserted | ||
174 | * for various errors. | ||
175 | * Additional CQE possibilities: | ||
176 | * TERMINATE, | ||
177 | * incoming RDMA WRITE Failures | ||
178 | * incoming RDMA READ REQUEST FAILUREs | ||
179 | * NOTE: We cannot ensure the CQ won't overflow. | ||
180 | */ | ||
181 | entries += 16; | ||
182 | } | ||
183 | entries = roundup_pow_of_two(entries); | ||
184 | chp->cq.size_log2 = ilog2(entries); | ||
185 | |||
186 | if (cxio_create_cq(&rhp->rdev, &chp->cq)) { | ||
187 | kfree(chp); | ||
188 | return ERR_PTR(-ENOMEM); | ||
189 | } | ||
190 | chp->rhp = rhp; | ||
191 | chp->ibcq.cqe = (1 << chp->cq.size_log2) - 1; | ||
192 | spin_lock_init(&chp->lock); | ||
193 | atomic_set(&chp->refcnt, 1); | ||
194 | init_waitqueue_head(&chp->wait); | ||
195 | insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid); | ||
196 | |||
197 | if (ucontext) { | ||
198 | struct iwch_mm_entry *mm; | ||
199 | |||
200 | mm = kmalloc(sizeof *mm, GFP_KERNEL); | ||
201 | if (!mm) { | ||
202 | iwch_destroy_cq(&chp->ibcq); | ||
203 | return ERR_PTR(-ENOMEM); | ||
204 | } | ||
205 | uresp.cqid = chp->cq.cqid; | ||
206 | uresp.size_log2 = chp->cq.size_log2; | ||
207 | spin_lock(&ucontext->mmap_lock); | ||
208 | uresp.key = ucontext->key; | ||
209 | ucontext->key += PAGE_SIZE; | ||
210 | spin_unlock(&ucontext->mmap_lock); | ||
211 | if (ib_copy_to_udata(udata, &uresp, sizeof (uresp))) { | ||
212 | kfree(mm); | ||
213 | iwch_destroy_cq(&chp->ibcq); | ||
214 | return ERR_PTR(-EFAULT); | ||
215 | } | ||
216 | mm->key = uresp.key; | ||
217 | mm->addr = virt_to_phys(chp->cq.queue); | ||
218 | mm->len = PAGE_ALIGN((1UL << uresp.size_log2) * | ||
219 | sizeof (struct t3_cqe)); | ||
220 | insert_mmap(ucontext, mm); | ||
221 | } | ||
222 | PDBG("created cqid 0x%0x chp %p size 0x%0x, dma_addr 0x%0llx\n", | ||
223 | chp->cq.cqid, chp, (1 << chp->cq.size_log2), | ||
224 | (unsigned long long) chp->cq.dma_addr); | ||
225 | return &chp->ibcq; | ||
226 | } | ||
227 | |||
228 | static int iwch_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata) | ||
229 | { | ||
230 | #ifdef notyet | ||
231 | struct iwch_cq *chp = to_iwch_cq(cq); | ||
232 | struct t3_cq oldcq, newcq; | ||
233 | int ret; | ||
234 | |||
235 | PDBG("%s ib_cq %p cqe %d\n", __FUNCTION__, cq, cqe); | ||
236 | |||
237 | /* We don't downsize... */ | ||
238 | if (cqe <= cq->cqe) | ||
239 | return 0; | ||
240 | |||
241 | /* create new t3_cq with new size */ | ||
242 | cqe = roundup_pow_of_two(cqe+1); | ||
243 | newcq.size_log2 = ilog2(cqe); | ||
244 | |||
245 | /* Dont allow resize to less than the current wce count */ | ||
246 | if (cqe < Q_COUNT(chp->cq.rptr, chp->cq.wptr)) { | ||
247 | return -ENOMEM; | ||
248 | } | ||
249 | |||
250 | /* Quiesce all QPs using this CQ */ | ||
251 | ret = iwch_quiesce_qps(chp); | ||
252 | if (ret) { | ||
253 | return ret; | ||
254 | } | ||
255 | |||
256 | ret = cxio_create_cq(&chp->rhp->rdev, &newcq); | ||
257 | if (ret) { | ||
258 | return ret; | ||
259 | } | ||
260 | |||
261 | /* copy CQEs */ | ||
262 | memcpy(newcq.queue, chp->cq.queue, (1 << chp->cq.size_log2) * | ||
263 | sizeof(struct t3_cqe)); | ||
264 | |||
265 | /* old iwch_qp gets new t3_cq but keeps old cqid */ | ||
266 | oldcq = chp->cq; | ||
267 | chp->cq = newcq; | ||
268 | chp->cq.cqid = oldcq.cqid; | ||
269 | |||
270 | /* resize new t3_cq to update the HW context */ | ||
271 | ret = cxio_resize_cq(&chp->rhp->rdev, &chp->cq); | ||
272 | if (ret) { | ||
273 | chp->cq = oldcq; | ||
274 | return ret; | ||
275 | } | ||
276 | chp->ibcq.cqe = (1<<chp->cq.size_log2) - 1; | ||
277 | |||
278 | /* destroy old t3_cq */ | ||
279 | oldcq.cqid = newcq.cqid; | ||
280 | ret = cxio_destroy_cq(&chp->rhp->rdev, &oldcq); | ||
281 | if (ret) { | ||
282 | printk(KERN_ERR MOD "%s - cxio_destroy_cq failed %d\n", | ||
283 | __FUNCTION__, ret); | ||
284 | } | ||
285 | |||
286 | /* add user hooks here */ | ||
287 | |||
288 | /* resume qps */ | ||
289 | ret = iwch_resume_qps(chp); | ||
290 | return ret; | ||
291 | #else | ||
292 | return -ENOSYS; | ||
293 | #endif | ||
294 | } | ||
295 | |||
296 | static int iwch_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify notify) | ||
297 | { | ||
298 | struct iwch_dev *rhp; | ||
299 | struct iwch_cq *chp; | ||
300 | enum t3_cq_opcode cq_op; | ||
301 | int err; | ||
302 | unsigned long flag; | ||
303 | u32 rptr; | ||
304 | |||
305 | chp = to_iwch_cq(ibcq); | ||
306 | rhp = chp->rhp; | ||
307 | if (notify == IB_CQ_SOLICITED) | ||
308 | cq_op = CQ_ARM_SE; | ||
309 | else | ||
310 | cq_op = CQ_ARM_AN; | ||
311 | if (chp->user_rptr_addr) { | ||
312 | if (get_user(rptr, chp->user_rptr_addr)) | ||
313 | return -EFAULT; | ||
314 | spin_lock_irqsave(&chp->lock, flag); | ||
315 | chp->cq.rptr = rptr; | ||
316 | } else | ||
317 | spin_lock_irqsave(&chp->lock, flag); | ||
318 | PDBG("%s rptr 0x%x\n", __FUNCTION__, chp->cq.rptr); | ||
319 | err = cxio_hal_cq_op(&rhp->rdev, &chp->cq, cq_op, 0); | ||
320 | spin_unlock_irqrestore(&chp->lock, flag); | ||
321 | if (err) | ||
322 | printk(KERN_ERR MOD "Error %d rearming CQID 0x%x\n", err, | ||
323 | chp->cq.cqid); | ||
324 | return err; | ||
325 | } | ||
326 | |||
327 | static int iwch_mmap(struct ib_ucontext *context, struct vm_area_struct *vma) | ||
328 | { | ||
329 | int len = vma->vm_end - vma->vm_start; | ||
330 | u32 key = vma->vm_pgoff << PAGE_SHIFT; | ||
331 | struct cxio_rdev *rdev_p; | ||
332 | int ret = 0; | ||
333 | struct iwch_mm_entry *mm; | ||
334 | struct iwch_ucontext *ucontext; | ||
335 | |||
336 | PDBG("%s pgoff 0x%lx key 0x%x len %d\n", __FUNCTION__, vma->vm_pgoff, | ||
337 | key, len); | ||
338 | |||
339 | if (vma->vm_start & (PAGE_SIZE-1)) { | ||
340 | return -EINVAL; | ||
341 | } | ||
342 | |||
343 | rdev_p = &(to_iwch_dev(context->device)->rdev); | ||
344 | ucontext = to_iwch_ucontext(context); | ||
345 | |||
346 | mm = remove_mmap(ucontext, key, len); | ||
347 | if (!mm) | ||
348 | return -EINVAL; | ||
349 | kfree(mm); | ||
350 | |||
351 | if ((mm->addr >= rdev_p->rnic_info.udbell_physbase) && | ||
352 | (mm->addr < (rdev_p->rnic_info.udbell_physbase + | ||
353 | rdev_p->rnic_info.udbell_len))) { | ||
354 | |||
355 | /* | ||
356 | * Map T3 DB register. | ||
357 | */ | ||
358 | if (vma->vm_flags & VM_READ) { | ||
359 | return -EPERM; | ||
360 | } | ||
361 | |||
362 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | ||
363 | vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND; | ||
364 | vma->vm_flags &= ~VM_MAYREAD; | ||
365 | ret = io_remap_pfn_range(vma, vma->vm_start, | ||
366 | mm->addr >> PAGE_SHIFT, | ||
367 | len, vma->vm_page_prot); | ||
368 | } else { | ||
369 | |||
370 | /* | ||
371 | * Map WQ or CQ contig dma memory... | ||
372 | */ | ||
373 | ret = remap_pfn_range(vma, vma->vm_start, | ||
374 | mm->addr >> PAGE_SHIFT, | ||
375 | len, vma->vm_page_prot); | ||
376 | } | ||
377 | |||
378 | return ret; | ||
379 | } | ||
380 | |||
381 | static int iwch_deallocate_pd(struct ib_pd *pd) | ||
382 | { | ||
383 | struct iwch_dev *rhp; | ||
384 | struct iwch_pd *php; | ||
385 | |||
386 | php = to_iwch_pd(pd); | ||
387 | rhp = php->rhp; | ||
388 | PDBG("%s ibpd %p pdid 0x%x\n", __FUNCTION__, pd, php->pdid); | ||
389 | cxio_hal_put_pdid(rhp->rdev.rscp, php->pdid); | ||
390 | kfree(php); | ||
391 | return 0; | ||
392 | } | ||
393 | |||
394 | static struct ib_pd *iwch_allocate_pd(struct ib_device *ibdev, | ||
395 | struct ib_ucontext *context, | ||
396 | struct ib_udata *udata) | ||
397 | { | ||
398 | struct iwch_pd *php; | ||
399 | u32 pdid; | ||
400 | struct iwch_dev *rhp; | ||
401 | |||
402 | PDBG("%s ibdev %p\n", __FUNCTION__, ibdev); | ||
403 | rhp = (struct iwch_dev *) ibdev; | ||
404 | pdid = cxio_hal_get_pdid(rhp->rdev.rscp); | ||
405 | if (!pdid) | ||
406 | return ERR_PTR(-EINVAL); | ||
407 | php = kzalloc(sizeof(*php), GFP_KERNEL); | ||
408 | if (!php) { | ||
409 | cxio_hal_put_pdid(rhp->rdev.rscp, pdid); | ||
410 | return ERR_PTR(-ENOMEM); | ||
411 | } | ||
412 | php->pdid = pdid; | ||
413 | php->rhp = rhp; | ||
414 | if (context) { | ||
415 | if (ib_copy_to_udata(udata, &php->pdid, sizeof (__u32))) { | ||
416 | iwch_deallocate_pd(&php->ibpd); | ||
417 | return ERR_PTR(-EFAULT); | ||
418 | } | ||
419 | } | ||
420 | PDBG("%s pdid 0x%0x ptr 0x%p\n", __FUNCTION__, pdid, php); | ||
421 | return &php->ibpd; | ||
422 | } | ||
423 | |||
424 | static int iwch_dereg_mr(struct ib_mr *ib_mr) | ||
425 | { | ||
426 | struct iwch_dev *rhp; | ||
427 | struct iwch_mr *mhp; | ||
428 | u32 mmid; | ||
429 | |||
430 | PDBG("%s ib_mr %p\n", __FUNCTION__, ib_mr); | ||
431 | /* There can be no memory windows */ | ||
432 | if (atomic_read(&ib_mr->usecnt)) | ||
433 | return -EINVAL; | ||
434 | |||
435 | mhp = to_iwch_mr(ib_mr); | ||
436 | rhp = mhp->rhp; | ||
437 | mmid = mhp->attr.stag >> 8; | ||
438 | cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size, | ||
439 | mhp->attr.pbl_addr); | ||
440 | remove_handle(rhp, &rhp->mmidr, mmid); | ||
441 | if (mhp->kva) | ||
442 | kfree((void *) (unsigned long) mhp->kva); | ||
443 | PDBG("%s mmid 0x%x ptr %p\n", __FUNCTION__, mmid, mhp); | ||
444 | kfree(mhp); | ||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd, | ||
449 | struct ib_phys_buf *buffer_list, | ||
450 | int num_phys_buf, | ||
451 | int acc, | ||
452 | u64 *iova_start) | ||
453 | { | ||
454 | __be64 *page_list; | ||
455 | int shift; | ||
456 | u64 total_size; | ||
457 | int npages; | ||
458 | struct iwch_dev *rhp; | ||
459 | struct iwch_pd *php; | ||
460 | struct iwch_mr *mhp; | ||
461 | int ret; | ||
462 | |||
463 | PDBG("%s ib_pd %p\n", __FUNCTION__, pd); | ||
464 | php = to_iwch_pd(pd); | ||
465 | rhp = php->rhp; | ||
466 | |||
467 | acc = iwch_convert_access(acc); | ||
468 | |||
469 | |||
470 | mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); | ||
471 | if (!mhp) | ||
472 | return ERR_PTR(-ENOMEM); | ||
473 | |||
474 | /* First check that we have enough alignment */ | ||
475 | if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK)) { | ||
476 | ret = -EINVAL; | ||
477 | goto err; | ||
478 | } | ||
479 | |||
480 | if (num_phys_buf > 1 && | ||
481 | ((buffer_list[0].addr + buffer_list[0].size) & ~PAGE_MASK)) { | ||
482 | ret = -EINVAL; | ||
483 | goto err; | ||
484 | } | ||
485 | |||
486 | ret = build_phys_page_list(buffer_list, num_phys_buf, iova_start, | ||
487 | &total_size, &npages, &shift, &page_list); | ||
488 | if (ret) | ||
489 | goto err; | ||
490 | |||
491 | mhp->rhp = rhp; | ||
492 | mhp->attr.pdid = php->pdid; | ||
493 | mhp->attr.zbva = 0; | ||
494 | |||
495 | /* NOTE: TPT perms are backwards from BIND WR perms! */ | ||
496 | mhp->attr.perms = (acc & 0x1) << 3; | ||
497 | mhp->attr.perms |= (acc & 0x2) << 1; | ||
498 | mhp->attr.perms |= (acc & 0x4) >> 1; | ||
499 | mhp->attr.perms |= (acc & 0x8) >> 3; | ||
500 | |||
501 | mhp->attr.va_fbo = *iova_start; | ||
502 | mhp->attr.page_size = shift - 12; | ||
503 | |||
504 | mhp->attr.len = (u32) total_size; | ||
505 | mhp->attr.pbl_size = npages; | ||
506 | ret = iwch_register_mem(rhp, php, mhp, shift, page_list); | ||
507 | kfree(page_list); | ||
508 | if (ret) { | ||
509 | goto err; | ||
510 | } | ||
511 | return &mhp->ibmr; | ||
512 | err: | ||
513 | kfree(mhp); | ||
514 | return ERR_PTR(ret); | ||
515 | |||
516 | } | ||
517 | |||
518 | static int iwch_reregister_phys_mem(struct ib_mr *mr, | ||
519 | int mr_rereg_mask, | ||
520 | struct ib_pd *pd, | ||
521 | struct ib_phys_buf *buffer_list, | ||
522 | int num_phys_buf, | ||
523 | int acc, u64 * iova_start) | ||
524 | { | ||
525 | |||
526 | struct iwch_mr mh, *mhp; | ||
527 | struct iwch_pd *php; | ||
528 | struct iwch_dev *rhp; | ||
529 | int new_acc; | ||
530 | __be64 *page_list = NULL; | ||
531 | int shift = 0; | ||
532 | u64 total_size; | ||
533 | int npages; | ||
534 | int ret; | ||
535 | |||
536 | PDBG("%s ib_mr %p ib_pd %p\n", __FUNCTION__, mr, pd); | ||
537 | |||
538 | /* There can be no memory windows */ | ||
539 | if (atomic_read(&mr->usecnt)) | ||
540 | return -EINVAL; | ||
541 | |||
542 | mhp = to_iwch_mr(mr); | ||
543 | rhp = mhp->rhp; | ||
544 | php = to_iwch_pd(mr->pd); | ||
545 | |||
546 | /* make sure we are on the same adapter */ | ||
547 | if (rhp != php->rhp) | ||
548 | return -EINVAL; | ||
549 | |||
550 | new_acc = mhp->attr.perms; | ||
551 | |||
552 | memcpy(&mh, mhp, sizeof *mhp); | ||
553 | |||
554 | if (mr_rereg_mask & IB_MR_REREG_PD) | ||
555 | php = to_iwch_pd(pd); | ||
556 | if (mr_rereg_mask & IB_MR_REREG_ACCESS) | ||
557 | mh.attr.perms = iwch_convert_access(acc); | ||
558 | if (mr_rereg_mask & IB_MR_REREG_TRANS) | ||
559 | ret = build_phys_page_list(buffer_list, num_phys_buf, | ||
560 | iova_start, | ||
561 | &total_size, &npages, | ||
562 | &shift, &page_list); | ||
563 | |||
564 | ret = iwch_reregister_mem(rhp, php, &mh, shift, page_list, npages); | ||
565 | kfree(page_list); | ||
566 | if (ret) { | ||
567 | return ret; | ||
568 | } | ||
569 | if (mr_rereg_mask & IB_MR_REREG_PD) | ||
570 | mhp->attr.pdid = php->pdid; | ||
571 | if (mr_rereg_mask & IB_MR_REREG_ACCESS) | ||
572 | mhp->attr.perms = acc; | ||
573 | if (mr_rereg_mask & IB_MR_REREG_TRANS) { | ||
574 | mhp->attr.zbva = 0; | ||
575 | mhp->attr.va_fbo = *iova_start; | ||
576 | mhp->attr.page_size = shift - 12; | ||
577 | mhp->attr.len = (u32) total_size; | ||
578 | mhp->attr.pbl_size = npages; | ||
579 | } | ||
580 | |||
581 | return 0; | ||
582 | } | ||
583 | |||
584 | |||
585 | static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, struct ib_umem *region, | ||
586 | int acc, struct ib_udata *udata) | ||
587 | { | ||
588 | __be64 *pages; | ||
589 | int shift, n, len; | ||
590 | int i, j, k; | ||
591 | int err = 0; | ||
592 | struct ib_umem_chunk *chunk; | ||
593 | struct iwch_dev *rhp; | ||
594 | struct iwch_pd *php; | ||
595 | struct iwch_mr *mhp; | ||
596 | struct iwch_reg_user_mr_resp uresp; | ||
597 | |||
598 | PDBG("%s ib_pd %p\n", __FUNCTION__, pd); | ||
599 | shift = ffs(region->page_size) - 1; | ||
600 | |||
601 | php = to_iwch_pd(pd); | ||
602 | rhp = php->rhp; | ||
603 | mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); | ||
604 | if (!mhp) | ||
605 | return ERR_PTR(-ENOMEM); | ||
606 | |||
607 | n = 0; | ||
608 | list_for_each_entry(chunk, ®ion->chunk_list, list) | ||
609 | n += chunk->nents; | ||
610 | |||
611 | pages = kmalloc(n * sizeof(u64), GFP_KERNEL); | ||
612 | if (!pages) { | ||
613 | err = -ENOMEM; | ||
614 | goto err; | ||
615 | } | ||
616 | |||
617 | acc = iwch_convert_access(acc); | ||
618 | |||
619 | i = n = 0; | ||
620 | |||
621 | list_for_each_entry(chunk, ®ion->chunk_list, list) | ||
622 | for (j = 0; j < chunk->nmap; ++j) { | ||
623 | len = sg_dma_len(&chunk->page_list[j]) >> shift; | ||
624 | for (k = 0; k < len; ++k) { | ||
625 | pages[i++] = cpu_to_be64(sg_dma_address( | ||
626 | &chunk->page_list[j]) + | ||
627 | region->page_size * k); | ||
628 | } | ||
629 | } | ||
630 | |||
631 | mhp->rhp = rhp; | ||
632 | mhp->attr.pdid = php->pdid; | ||
633 | mhp->attr.zbva = 0; | ||
634 | mhp->attr.perms = (acc & 0x1) << 3; | ||
635 | mhp->attr.perms |= (acc & 0x2) << 1; | ||
636 | mhp->attr.perms |= (acc & 0x4) >> 1; | ||
637 | mhp->attr.perms |= (acc & 0x8) >> 3; | ||
638 | mhp->attr.va_fbo = region->virt_base; | ||
639 | mhp->attr.page_size = shift - 12; | ||
640 | mhp->attr.len = (u32) region->length; | ||
641 | mhp->attr.pbl_size = i; | ||
642 | err = iwch_register_mem(rhp, php, mhp, shift, pages); | ||
643 | kfree(pages); | ||
644 | if (err) | ||
645 | goto err; | ||
646 | |||
647 | if (udata && t3b_device(rhp)) { | ||
648 | uresp.pbl_addr = (mhp->attr.pbl_addr - | ||
649 | rhp->rdev.rnic_info.pbl_base) >> 3; | ||
650 | PDBG("%s user resp pbl_addr 0x%x\n", __FUNCTION__, | ||
651 | uresp.pbl_addr); | ||
652 | |||
653 | if (ib_copy_to_udata(udata, &uresp, sizeof (uresp))) { | ||
654 | iwch_dereg_mr(&mhp->ibmr); | ||
655 | err = -EFAULT; | ||
656 | goto err; | ||
657 | } | ||
658 | } | ||
659 | |||
660 | return &mhp->ibmr; | ||
661 | |||
662 | err: | ||
663 | kfree(mhp); | ||
664 | return ERR_PTR(err); | ||
665 | } | ||
666 | |||
667 | static struct ib_mr *iwch_get_dma_mr(struct ib_pd *pd, int acc) | ||
668 | { | ||
669 | struct ib_phys_buf bl; | ||
670 | u64 kva; | ||
671 | struct ib_mr *ibmr; | ||
672 | |||
673 | PDBG("%s ib_pd %p\n", __FUNCTION__, pd); | ||
674 | |||
675 | /* | ||
676 | * T3 only supports 32 bits of size. | ||
677 | */ | ||
678 | bl.size = 0xffffffff; | ||
679 | bl.addr = 0; | ||
680 | kva = 0; | ||
681 | ibmr = iwch_register_phys_mem(pd, &bl, 1, acc, &kva); | ||
682 | return ibmr; | ||
683 | } | ||
684 | |||
685 | static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd) | ||
686 | { | ||
687 | struct iwch_dev *rhp; | ||
688 | struct iwch_pd *php; | ||
689 | struct iwch_mw *mhp; | ||
690 | u32 mmid; | ||
691 | u32 stag = 0; | ||
692 | int ret; | ||
693 | |||
694 | php = to_iwch_pd(pd); | ||
695 | rhp = php->rhp; | ||
696 | mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); | ||
697 | if (!mhp) | ||
698 | return ERR_PTR(-ENOMEM); | ||
699 | ret = cxio_allocate_window(&rhp->rdev, &stag, php->pdid); | ||
700 | if (ret) { | ||
701 | kfree(mhp); | ||
702 | return ERR_PTR(ret); | ||
703 | } | ||
704 | mhp->rhp = rhp; | ||
705 | mhp->attr.pdid = php->pdid; | ||
706 | mhp->attr.type = TPT_MW; | ||
707 | mhp->attr.stag = stag; | ||
708 | mmid = (stag) >> 8; | ||
709 | insert_handle(rhp, &rhp->mmidr, mhp, mmid); | ||
710 | PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __FUNCTION__, mmid, mhp, stag); | ||
711 | return &(mhp->ibmw); | ||
712 | } | ||
713 | |||
714 | static int iwch_dealloc_mw(struct ib_mw *mw) | ||
715 | { | ||
716 | struct iwch_dev *rhp; | ||
717 | struct iwch_mw *mhp; | ||
718 | u32 mmid; | ||
719 | |||
720 | mhp = to_iwch_mw(mw); | ||
721 | rhp = mhp->rhp; | ||
722 | mmid = (mw->rkey) >> 8; | ||
723 | cxio_deallocate_window(&rhp->rdev, mhp->attr.stag); | ||
724 | remove_handle(rhp, &rhp->mmidr, mmid); | ||
725 | kfree(mhp); | ||
726 | PDBG("%s ib_mw %p mmid 0x%x ptr %p\n", __FUNCTION__, mw, mmid, mhp); | ||
727 | return 0; | ||
728 | } | ||
729 | |||
730 | static int iwch_destroy_qp(struct ib_qp *ib_qp) | ||
731 | { | ||
732 | struct iwch_dev *rhp; | ||
733 | struct iwch_qp *qhp; | ||
734 | struct iwch_qp_attributes attrs; | ||
735 | struct iwch_ucontext *ucontext; | ||
736 | |||
737 | qhp = to_iwch_qp(ib_qp); | ||
738 | rhp = qhp->rhp; | ||
739 | |||
740 | if (qhp->attr.state == IWCH_QP_STATE_RTS) { | ||
741 | attrs.next_state = IWCH_QP_STATE_ERROR; | ||
742 | iwch_modify_qp(rhp, qhp, IWCH_QP_ATTR_NEXT_STATE, &attrs, 0); | ||
743 | } | ||
744 | wait_event(qhp->wait, !qhp->ep); | ||
745 | |||
746 | remove_handle(rhp, &rhp->qpidr, qhp->wq.qpid); | ||
747 | |||
748 | atomic_dec(&qhp->refcnt); | ||
749 | wait_event(qhp->wait, !atomic_read(&qhp->refcnt)); | ||
750 | |||
751 | ucontext = ib_qp->uobject ? to_iwch_ucontext(ib_qp->uobject->context) | ||
752 | : NULL; | ||
753 | cxio_destroy_qp(&rhp->rdev, &qhp->wq, | ||
754 | ucontext ? &ucontext->uctx : &rhp->rdev.uctx); | ||
755 | |||
756 | PDBG("%s ib_qp %p qpid 0x%0x qhp %p\n", __FUNCTION__, | ||
757 | ib_qp, qhp->wq.qpid, qhp); | ||
758 | kfree(qhp); | ||
759 | return 0; | ||
760 | } | ||
761 | |||
762 | static struct ib_qp *iwch_create_qp(struct ib_pd *pd, | ||
763 | struct ib_qp_init_attr *attrs, | ||
764 | struct ib_udata *udata) | ||
765 | { | ||
766 | struct iwch_dev *rhp; | ||
767 | struct iwch_qp *qhp; | ||
768 | struct iwch_pd *php; | ||
769 | struct iwch_cq *schp; | ||
770 | struct iwch_cq *rchp; | ||
771 | struct iwch_create_qp_resp uresp; | ||
772 | int wqsize, sqsize, rqsize; | ||
773 | struct iwch_ucontext *ucontext; | ||
774 | |||
775 | PDBG("%s ib_pd %p\n", __FUNCTION__, pd); | ||
776 | if (attrs->qp_type != IB_QPT_RC) | ||
777 | return ERR_PTR(-EINVAL); | ||
778 | php = to_iwch_pd(pd); | ||
779 | rhp = php->rhp; | ||
780 | schp = get_chp(rhp, ((struct iwch_cq *) attrs->send_cq)->cq.cqid); | ||
781 | rchp = get_chp(rhp, ((struct iwch_cq *) attrs->recv_cq)->cq.cqid); | ||
782 | if (!schp || !rchp) | ||
783 | return ERR_PTR(-EINVAL); | ||
784 | |||
785 | /* The RQT size must be # of entries + 1 rounded up to a power of two */ | ||
786 | rqsize = roundup_pow_of_two(attrs->cap.max_recv_wr); | ||
787 | if (rqsize == attrs->cap.max_recv_wr) | ||
788 | rqsize = roundup_pow_of_two(attrs->cap.max_recv_wr+1); | ||
789 | |||
790 | /* T3 doesn't support RQT depth < 16 */ | ||
791 | if (rqsize < 16) | ||
792 | rqsize = 16; | ||
793 | |||
794 | if (rqsize > T3_MAX_RQ_SIZE) | ||
795 | return ERR_PTR(-EINVAL); | ||
796 | |||
797 | /* | ||
798 | * NOTE: The SQ and total WQ sizes don't need to be | ||
799 | * a power of two. However, all the code assumes | ||
800 | * they are. EG: Q_FREECNT() and friends. | ||
801 | */ | ||
802 | sqsize = roundup_pow_of_two(attrs->cap.max_send_wr); | ||
803 | wqsize = roundup_pow_of_two(rqsize + sqsize); | ||
804 | PDBG("%s wqsize %d sqsize %d rqsize %d\n", __FUNCTION__, | ||
805 | wqsize, sqsize, rqsize); | ||
806 | qhp = kzalloc(sizeof(*qhp), GFP_KERNEL); | ||
807 | if (!qhp) | ||
808 | return ERR_PTR(-ENOMEM); | ||
809 | qhp->wq.size_log2 = ilog2(wqsize); | ||
810 | qhp->wq.rq_size_log2 = ilog2(rqsize); | ||
811 | qhp->wq.sq_size_log2 = ilog2(sqsize); | ||
812 | ucontext = pd->uobject ? to_iwch_ucontext(pd->uobject->context) : NULL; | ||
813 | if (cxio_create_qp(&rhp->rdev, !udata, &qhp->wq, | ||
814 | ucontext ? &ucontext->uctx : &rhp->rdev.uctx)) { | ||
815 | kfree(qhp); | ||
816 | return ERR_PTR(-ENOMEM); | ||
817 | } | ||
818 | attrs->cap.max_recv_wr = rqsize - 1; | ||
819 | attrs->cap.max_send_wr = sqsize; | ||
820 | qhp->rhp = rhp; | ||
821 | qhp->attr.pd = php->pdid; | ||
822 | qhp->attr.scq = ((struct iwch_cq *) attrs->send_cq)->cq.cqid; | ||
823 | qhp->attr.rcq = ((struct iwch_cq *) attrs->recv_cq)->cq.cqid; | ||
824 | qhp->attr.sq_num_entries = attrs->cap.max_send_wr; | ||
825 | qhp->attr.rq_num_entries = attrs->cap.max_recv_wr; | ||
826 | qhp->attr.sq_max_sges = attrs->cap.max_send_sge; | ||
827 | qhp->attr.sq_max_sges_rdma_write = attrs->cap.max_send_sge; | ||
828 | qhp->attr.rq_max_sges = attrs->cap.max_recv_sge; | ||
829 | qhp->attr.state = IWCH_QP_STATE_IDLE; | ||
830 | qhp->attr.next_state = IWCH_QP_STATE_IDLE; | ||
831 | |||
832 | /* | ||
833 | * XXX - These don't get passed in from the openib user | ||
834 | * at create time. The CM sets them via a QP modify. | ||
835 | * Need to fix... I think the CM should | ||
836 | */ | ||
837 | qhp->attr.enable_rdma_read = 1; | ||
838 | qhp->attr.enable_rdma_write = 1; | ||
839 | qhp->attr.enable_bind = 1; | ||
840 | qhp->attr.max_ord = 1; | ||
841 | qhp->attr.max_ird = 1; | ||
842 | |||
843 | spin_lock_init(&qhp->lock); | ||
844 | init_waitqueue_head(&qhp->wait); | ||
845 | atomic_set(&qhp->refcnt, 1); | ||
846 | insert_handle(rhp, &rhp->qpidr, qhp, qhp->wq.qpid); | ||
847 | |||
848 | if (udata) { | ||
849 | |||
850 | struct iwch_mm_entry *mm1, *mm2; | ||
851 | |||
852 | mm1 = kmalloc(sizeof *mm1, GFP_KERNEL); | ||
853 | if (!mm1) { | ||
854 | iwch_destroy_qp(&qhp->ibqp); | ||
855 | return ERR_PTR(-ENOMEM); | ||
856 | } | ||
857 | |||
858 | mm2 = kmalloc(sizeof *mm2, GFP_KERNEL); | ||
859 | if (!mm2) { | ||
860 | kfree(mm1); | ||
861 | iwch_destroy_qp(&qhp->ibqp); | ||
862 | return ERR_PTR(-ENOMEM); | ||
863 | } | ||
864 | |||
865 | uresp.qpid = qhp->wq.qpid; | ||
866 | uresp.size_log2 = qhp->wq.size_log2; | ||
867 | uresp.sq_size_log2 = qhp->wq.sq_size_log2; | ||
868 | uresp.rq_size_log2 = qhp->wq.rq_size_log2; | ||
869 | spin_lock(&ucontext->mmap_lock); | ||
870 | uresp.key = ucontext->key; | ||
871 | ucontext->key += PAGE_SIZE; | ||
872 | uresp.db_key = ucontext->key; | ||
873 | ucontext->key += PAGE_SIZE; | ||
874 | spin_unlock(&ucontext->mmap_lock); | ||
875 | if (ib_copy_to_udata(udata, &uresp, sizeof (uresp))) { | ||
876 | kfree(mm1); | ||
877 | kfree(mm2); | ||
878 | iwch_destroy_qp(&qhp->ibqp); | ||
879 | return ERR_PTR(-EFAULT); | ||
880 | } | ||
881 | mm1->key = uresp.key; | ||
882 | mm1->addr = virt_to_phys(qhp->wq.queue); | ||
883 | mm1->len = PAGE_ALIGN(wqsize * sizeof (union t3_wr)); | ||
884 | insert_mmap(ucontext, mm1); | ||
885 | mm2->key = uresp.db_key; | ||
886 | mm2->addr = qhp->wq.udb & PAGE_MASK; | ||
887 | mm2->len = PAGE_SIZE; | ||
888 | insert_mmap(ucontext, mm2); | ||
889 | } | ||
890 | qhp->ibqp.qp_num = qhp->wq.qpid; | ||
891 | init_timer(&(qhp->timer)); | ||
892 | PDBG("%s sq_num_entries %d, rq_num_entries %d " | ||
893 | "qpid 0x%0x qhp %p dma_addr 0x%llx size %d\n", | ||
894 | __FUNCTION__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries, | ||
895 | qhp->wq.qpid, qhp, (unsigned long long) qhp->wq.dma_addr, | ||
896 | 1 << qhp->wq.size_log2); | ||
897 | return &qhp->ibqp; | ||
898 | } | ||
899 | |||
900 | static int iwch_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, | ||
901 | int attr_mask, struct ib_udata *udata) | ||
902 | { | ||
903 | struct iwch_dev *rhp; | ||
904 | struct iwch_qp *qhp; | ||
905 | enum iwch_qp_attr_mask mask = 0; | ||
906 | struct iwch_qp_attributes attrs; | ||
907 | |||
908 | PDBG("%s ib_qp %p\n", __FUNCTION__, ibqp); | ||
909 | |||
910 | /* iwarp does not support the RTR state */ | ||
911 | if ((attr_mask & IB_QP_STATE) && (attr->qp_state == IB_QPS_RTR)) | ||
912 | attr_mask &= ~IB_QP_STATE; | ||
913 | |||
914 | /* Make sure we still have something left to do */ | ||
915 | if (!attr_mask) | ||
916 | return 0; | ||
917 | |||
918 | memset(&attrs, 0, sizeof attrs); | ||
919 | qhp = to_iwch_qp(ibqp); | ||
920 | rhp = qhp->rhp; | ||
921 | |||
922 | attrs.next_state = iwch_convert_state(attr->qp_state); | ||
923 | attrs.enable_rdma_read = (attr->qp_access_flags & | ||
924 | IB_ACCESS_REMOTE_READ) ? 1 : 0; | ||
925 | attrs.enable_rdma_write = (attr->qp_access_flags & | ||
926 | IB_ACCESS_REMOTE_WRITE) ? 1 : 0; | ||
927 | attrs.enable_bind = (attr->qp_access_flags & IB_ACCESS_MW_BIND) ? 1 : 0; | ||
928 | |||
929 | |||
930 | mask |= (attr_mask & IB_QP_STATE) ? IWCH_QP_ATTR_NEXT_STATE : 0; | ||
931 | mask |= (attr_mask & IB_QP_ACCESS_FLAGS) ? | ||
932 | (IWCH_QP_ATTR_ENABLE_RDMA_READ | | ||
933 | IWCH_QP_ATTR_ENABLE_RDMA_WRITE | | ||
934 | IWCH_QP_ATTR_ENABLE_RDMA_BIND) : 0; | ||
935 | |||
936 | return iwch_modify_qp(rhp, qhp, mask, &attrs, 0); | ||
937 | } | ||
938 | |||
939 | void iwch_qp_add_ref(struct ib_qp *qp) | ||
940 | { | ||
941 | PDBG("%s ib_qp %p\n", __FUNCTION__, qp); | ||
942 | atomic_inc(&(to_iwch_qp(qp)->refcnt)); | ||
943 | } | ||
944 | |||
945 | void iwch_qp_rem_ref(struct ib_qp *qp) | ||
946 | { | ||
947 | PDBG("%s ib_qp %p\n", __FUNCTION__, qp); | ||
948 | if (atomic_dec_and_test(&(to_iwch_qp(qp)->refcnt))) | ||
949 | wake_up(&(to_iwch_qp(qp)->wait)); | ||
950 | } | ||
951 | |||
952 | struct ib_qp *iwch_get_qp(struct ib_device *dev, int qpn) | ||
953 | { | ||
954 | PDBG("%s ib_dev %p qpn 0x%x\n", __FUNCTION__, dev, qpn); | ||
955 | return (struct ib_qp *)get_qhp(to_iwch_dev(dev), qpn); | ||
956 | } | ||
957 | |||
958 | |||
959 | static int iwch_query_pkey(struct ib_device *ibdev, | ||
960 | u8 port, u16 index, u16 * pkey) | ||
961 | { | ||
962 | PDBG("%s ibdev %p\n", __FUNCTION__, ibdev); | ||
963 | *pkey = 0; | ||
964 | return 0; | ||
965 | } | ||
966 | |||
967 | static int iwch_query_gid(struct ib_device *ibdev, u8 port, | ||
968 | int index, union ib_gid *gid) | ||
969 | { | ||
970 | struct iwch_dev *dev; | ||
971 | |||
972 | PDBG("%s ibdev %p, port %d, index %d, gid %p\n", | ||
973 | __FUNCTION__, ibdev, port, index, gid); | ||
974 | dev = to_iwch_dev(ibdev); | ||
975 | BUG_ON(port == 0 || port > 2); | ||
976 | memset(&(gid->raw[0]), 0, sizeof(gid->raw)); | ||
977 | memcpy(&(gid->raw[0]), dev->rdev.port_info.lldevs[port-1]->dev_addr, 6); | ||
978 | return 0; | ||
979 | } | ||
980 | |||
981 | static int iwch_query_device(struct ib_device *ibdev, | ||
982 | struct ib_device_attr *props) | ||
983 | { | ||
984 | |||
985 | struct iwch_dev *dev; | ||
986 | PDBG("%s ibdev %p\n", __FUNCTION__, ibdev); | ||
987 | |||
988 | dev = to_iwch_dev(ibdev); | ||
989 | memset(props, 0, sizeof *props); | ||
990 | memcpy(&props->sys_image_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); | ||
991 | props->device_cap_flags = dev->device_cap_flags; | ||
992 | props->vendor_id = (u32)dev->rdev.rnic_info.pdev->vendor; | ||
993 | props->vendor_part_id = (u32)dev->rdev.rnic_info.pdev->device; | ||
994 | props->max_mr_size = ~0ull; | ||
995 | props->max_qp = dev->attr.max_qps; | ||
996 | props->max_qp_wr = dev->attr.max_wrs; | ||
997 | props->max_sge = dev->attr.max_sge_per_wr; | ||
998 | props->max_sge_rd = 1; | ||
999 | props->max_qp_rd_atom = dev->attr.max_rdma_reads_per_qp; | ||
1000 | props->max_cq = dev->attr.max_cqs; | ||
1001 | props->max_cqe = dev->attr.max_cqes_per_cq; | ||
1002 | props->max_mr = dev->attr.max_mem_regs; | ||
1003 | props->max_pd = dev->attr.max_pds; | ||
1004 | props->local_ca_ack_delay = 0; | ||
1005 | |||
1006 | return 0; | ||
1007 | } | ||
1008 | |||
1009 | static int iwch_query_port(struct ib_device *ibdev, | ||
1010 | u8 port, struct ib_port_attr *props) | ||
1011 | { | ||
1012 | PDBG("%s ibdev %p\n", __FUNCTION__, ibdev); | ||
1013 | props->max_mtu = IB_MTU_4096; | ||
1014 | props->lid = 0; | ||
1015 | props->lmc = 0; | ||
1016 | props->sm_lid = 0; | ||
1017 | props->sm_sl = 0; | ||
1018 | props->state = IB_PORT_ACTIVE; | ||
1019 | props->phys_state = 0; | ||
1020 | props->port_cap_flags = | ||
1021 | IB_PORT_CM_SUP | | ||
1022 | IB_PORT_SNMP_TUNNEL_SUP | | ||
1023 | IB_PORT_REINIT_SUP | | ||
1024 | IB_PORT_DEVICE_MGMT_SUP | | ||
1025 | IB_PORT_VENDOR_CLASS_SUP | IB_PORT_BOOT_MGMT_SUP; | ||
1026 | props->gid_tbl_len = 1; | ||
1027 | props->pkey_tbl_len = 1; | ||
1028 | props->qkey_viol_cntr = 0; | ||
1029 | props->active_width = 2; | ||
1030 | props->active_speed = 2; | ||
1031 | props->max_msg_sz = -1; | ||
1032 | |||
1033 | return 0; | ||
1034 | } | ||
1035 | |||
1036 | static ssize_t show_rev(struct class_device *cdev, char *buf) | ||
1037 | { | ||
1038 | struct iwch_dev *dev = container_of(cdev, struct iwch_dev, | ||
1039 | ibdev.class_dev); | ||
1040 | PDBG("%s class dev 0x%p\n", __FUNCTION__, cdev); | ||
1041 | return sprintf(buf, "%d\n", dev->rdev.t3cdev_p->type); | ||
1042 | } | ||
1043 | |||
1044 | static ssize_t show_fw_ver(struct class_device *cdev, char *buf) | ||
1045 | { | ||
1046 | struct iwch_dev *dev = container_of(cdev, struct iwch_dev, | ||
1047 | ibdev.class_dev); | ||
1048 | struct ethtool_drvinfo info; | ||
1049 | struct net_device *lldev = dev->rdev.t3cdev_p->lldev; | ||
1050 | |||
1051 | PDBG("%s class dev 0x%p\n", __FUNCTION__, cdev); | ||
1052 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | ||
1053 | return sprintf(buf, "%s\n", info.fw_version); | ||
1054 | } | ||
1055 | |||
1056 | static ssize_t show_hca(struct class_device *cdev, char *buf) | ||
1057 | { | ||
1058 | struct iwch_dev *dev = container_of(cdev, struct iwch_dev, | ||
1059 | ibdev.class_dev); | ||
1060 | struct ethtool_drvinfo info; | ||
1061 | struct net_device *lldev = dev->rdev.t3cdev_p->lldev; | ||
1062 | |||
1063 | PDBG("%s class dev 0x%p\n", __FUNCTION__, cdev); | ||
1064 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | ||
1065 | return sprintf(buf, "%s\n", info.driver); | ||
1066 | } | ||
1067 | |||
1068 | static ssize_t show_board(struct class_device *cdev, char *buf) | ||
1069 | { | ||
1070 | struct iwch_dev *dev = container_of(cdev, struct iwch_dev, | ||
1071 | ibdev.class_dev); | ||
1072 | PDBG("%s class dev 0x%p\n", __FUNCTION__, dev); | ||
1073 | return sprintf(buf, "%x.%x\n", dev->rdev.rnic_info.pdev->vendor, | ||
1074 | dev->rdev.rnic_info.pdev->device); | ||
1075 | } | ||
1076 | |||
1077 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | ||
1078 | static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); | ||
1079 | static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); | ||
1080 | static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); | ||
1081 | |||
1082 | static struct class_device_attribute *iwch_class_attributes[] = { | ||
1083 | &class_device_attr_hw_rev, | ||
1084 | &class_device_attr_fw_ver, | ||
1085 | &class_device_attr_hca_type, | ||
1086 | &class_device_attr_board_id | ||
1087 | }; | ||
1088 | |||
1089 | int iwch_register_device(struct iwch_dev *dev) | ||
1090 | { | ||
1091 | int ret; | ||
1092 | int i; | ||
1093 | |||
1094 | PDBG("%s iwch_dev %p\n", __FUNCTION__, dev); | ||
1095 | strlcpy(dev->ibdev.name, "cxgb3_%d", IB_DEVICE_NAME_MAX); | ||
1096 | memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); | ||
1097 | memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); | ||
1098 | dev->ibdev.owner = THIS_MODULE; | ||
1099 | dev->device_cap_flags = | ||
1100 | (IB_DEVICE_ZERO_STAG | | ||
1101 | IB_DEVICE_SEND_W_INV | IB_DEVICE_MEM_WINDOW); | ||
1102 | |||
1103 | dev->ibdev.uverbs_cmd_mask = | ||
1104 | (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | | ||
1105 | (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) | | ||
1106 | (1ull << IB_USER_VERBS_CMD_QUERY_PORT) | | ||
1107 | (1ull << IB_USER_VERBS_CMD_ALLOC_PD) | | ||
1108 | (1ull << IB_USER_VERBS_CMD_DEALLOC_PD) | | ||
1109 | (1ull << IB_USER_VERBS_CMD_REG_MR) | | ||
1110 | (1ull << IB_USER_VERBS_CMD_DEREG_MR) | | ||
1111 | (1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) | | ||
1112 | (1ull << IB_USER_VERBS_CMD_CREATE_CQ) | | ||
1113 | (1ull << IB_USER_VERBS_CMD_DESTROY_CQ) | | ||
1114 | (1ull << IB_USER_VERBS_CMD_REQ_NOTIFY_CQ) | | ||
1115 | (1ull << IB_USER_VERBS_CMD_CREATE_QP) | | ||
1116 | (1ull << IB_USER_VERBS_CMD_MODIFY_QP) | | ||
1117 | (1ull << IB_USER_VERBS_CMD_POLL_CQ) | | ||
1118 | (1ull << IB_USER_VERBS_CMD_DESTROY_QP) | | ||
1119 | (1ull << IB_USER_VERBS_CMD_POST_SEND) | | ||
1120 | (1ull << IB_USER_VERBS_CMD_POST_RECV); | ||
1121 | dev->ibdev.node_type = RDMA_NODE_RNIC; | ||
1122 | memcpy(dev->ibdev.node_desc, IWCH_NODE_DESC, sizeof(IWCH_NODE_DESC)); | ||
1123 | dev->ibdev.phys_port_cnt = dev->rdev.port_info.nports; | ||
1124 | dev->ibdev.dma_device = &(dev->rdev.rnic_info.pdev->dev); | ||
1125 | dev->ibdev.class_dev.dev = &(dev->rdev.rnic_info.pdev->dev); | ||
1126 | dev->ibdev.query_device = iwch_query_device; | ||
1127 | dev->ibdev.query_port = iwch_query_port; | ||
1128 | dev->ibdev.modify_port = iwch_modify_port; | ||
1129 | dev->ibdev.query_pkey = iwch_query_pkey; | ||
1130 | dev->ibdev.query_gid = iwch_query_gid; | ||
1131 | dev->ibdev.alloc_ucontext = iwch_alloc_ucontext; | ||
1132 | dev->ibdev.dealloc_ucontext = iwch_dealloc_ucontext; | ||
1133 | dev->ibdev.mmap = iwch_mmap; | ||
1134 | dev->ibdev.alloc_pd = iwch_allocate_pd; | ||
1135 | dev->ibdev.dealloc_pd = iwch_deallocate_pd; | ||
1136 | dev->ibdev.create_ah = iwch_ah_create; | ||
1137 | dev->ibdev.destroy_ah = iwch_ah_destroy; | ||
1138 | dev->ibdev.create_qp = iwch_create_qp; | ||
1139 | dev->ibdev.modify_qp = iwch_ib_modify_qp; | ||
1140 | dev->ibdev.destroy_qp = iwch_destroy_qp; | ||
1141 | dev->ibdev.create_cq = iwch_create_cq; | ||
1142 | dev->ibdev.destroy_cq = iwch_destroy_cq; | ||
1143 | dev->ibdev.resize_cq = iwch_resize_cq; | ||
1144 | dev->ibdev.poll_cq = iwch_poll_cq; | ||
1145 | dev->ibdev.get_dma_mr = iwch_get_dma_mr; | ||
1146 | dev->ibdev.reg_phys_mr = iwch_register_phys_mem; | ||
1147 | dev->ibdev.rereg_phys_mr = iwch_reregister_phys_mem; | ||
1148 | dev->ibdev.reg_user_mr = iwch_reg_user_mr; | ||
1149 | dev->ibdev.dereg_mr = iwch_dereg_mr; | ||
1150 | dev->ibdev.alloc_mw = iwch_alloc_mw; | ||
1151 | dev->ibdev.bind_mw = iwch_bind_mw; | ||
1152 | dev->ibdev.dealloc_mw = iwch_dealloc_mw; | ||
1153 | |||
1154 | dev->ibdev.attach_mcast = iwch_multicast_attach; | ||
1155 | dev->ibdev.detach_mcast = iwch_multicast_detach; | ||
1156 | dev->ibdev.process_mad = iwch_process_mad; | ||
1157 | |||
1158 | dev->ibdev.req_notify_cq = iwch_arm_cq; | ||
1159 | dev->ibdev.post_send = iwch_post_send; | ||
1160 | dev->ibdev.post_recv = iwch_post_receive; | ||
1161 | |||
1162 | |||
1163 | dev->ibdev.iwcm = | ||
1164 | (struct iw_cm_verbs *) kmalloc(sizeof(struct iw_cm_verbs), | ||
1165 | GFP_KERNEL); | ||
1166 | dev->ibdev.iwcm->connect = iwch_connect; | ||
1167 | dev->ibdev.iwcm->accept = iwch_accept_cr; | ||
1168 | dev->ibdev.iwcm->reject = iwch_reject_cr; | ||
1169 | dev->ibdev.iwcm->create_listen = iwch_create_listen; | ||
1170 | dev->ibdev.iwcm->destroy_listen = iwch_destroy_listen; | ||
1171 | dev->ibdev.iwcm->add_ref = iwch_qp_add_ref; | ||
1172 | dev->ibdev.iwcm->rem_ref = iwch_qp_rem_ref; | ||
1173 | dev->ibdev.iwcm->get_qp = iwch_get_qp; | ||
1174 | |||
1175 | ret = ib_register_device(&dev->ibdev); | ||
1176 | if (ret) | ||
1177 | goto bail1; | ||
1178 | |||
1179 | for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) { | ||
1180 | ret = class_device_create_file(&dev->ibdev.class_dev, | ||
1181 | iwch_class_attributes[i]); | ||
1182 | if (ret) { | ||
1183 | goto bail2; | ||
1184 | } | ||
1185 | } | ||
1186 | return 0; | ||
1187 | bail2: | ||
1188 | ib_unregister_device(&dev->ibdev); | ||
1189 | bail1: | ||
1190 | return ret; | ||
1191 | } | ||
1192 | |||
1193 | void iwch_unregister_device(struct iwch_dev *dev) | ||
1194 | { | ||
1195 | int i; | ||
1196 | |||
1197 | PDBG("%s iwch_dev %p\n", __FUNCTION__, dev); | ||
1198 | for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) | ||
1199 | class_device_remove_file(&dev->ibdev.class_dev, | ||
1200 | iwch_class_attributes[i]); | ||
1201 | ib_unregister_device(&dev->ibdev); | ||
1202 | return; | ||
1203 | } | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h new file mode 100644 index 000000000000..61e3278fd7a8 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h | |||
@@ -0,0 +1,367 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #ifndef __IWCH_PROVIDER_H__ | ||
34 | #define __IWCH_PROVIDER_H__ | ||
35 | |||
36 | #include <linux/list.h> | ||
37 | #include <linux/spinlock.h> | ||
38 | #include <rdma/ib_verbs.h> | ||
39 | #include <asm/types.h> | ||
40 | #include "t3cdev.h" | ||
41 | #include "iwch.h" | ||
42 | #include "cxio_wr.h" | ||
43 | #include "cxio_hal.h" | ||
44 | |||
45 | struct iwch_pd { | ||
46 | struct ib_pd ibpd; | ||
47 | u32 pdid; | ||
48 | struct iwch_dev *rhp; | ||
49 | }; | ||
50 | |||
51 | static inline struct iwch_pd *to_iwch_pd(struct ib_pd *ibpd) | ||
52 | { | ||
53 | return container_of(ibpd, struct iwch_pd, ibpd); | ||
54 | } | ||
55 | |||
56 | struct tpt_attributes { | ||
57 | u32 stag; | ||
58 | u32 state:1; | ||
59 | u32 type:2; | ||
60 | u32 rsvd:1; | ||
61 | enum tpt_mem_perm perms; | ||
62 | u32 remote_invaliate_disable:1; | ||
63 | u32 zbva:1; | ||
64 | u32 mw_bind_enable:1; | ||
65 | u32 page_size:5; | ||
66 | |||
67 | u32 pdid; | ||
68 | u32 qpid; | ||
69 | u32 pbl_addr; | ||
70 | u32 len; | ||
71 | u64 va_fbo; | ||
72 | u32 pbl_size; | ||
73 | }; | ||
74 | |||
75 | struct iwch_mr { | ||
76 | struct ib_mr ibmr; | ||
77 | struct iwch_dev *rhp; | ||
78 | u64 kva; | ||
79 | struct tpt_attributes attr; | ||
80 | }; | ||
81 | |||
82 | typedef struct iwch_mw iwch_mw_handle; | ||
83 | |||
84 | static inline struct iwch_mr *to_iwch_mr(struct ib_mr *ibmr) | ||
85 | { | ||
86 | return container_of(ibmr, struct iwch_mr, ibmr); | ||
87 | } | ||
88 | |||
89 | struct iwch_mw { | ||
90 | struct ib_mw ibmw; | ||
91 | struct iwch_dev *rhp; | ||
92 | u64 kva; | ||
93 | struct tpt_attributes attr; | ||
94 | }; | ||
95 | |||
96 | static inline struct iwch_mw *to_iwch_mw(struct ib_mw *ibmw) | ||
97 | { | ||
98 | return container_of(ibmw, struct iwch_mw, ibmw); | ||
99 | } | ||
100 | |||
101 | struct iwch_cq { | ||
102 | struct ib_cq ibcq; | ||
103 | struct iwch_dev *rhp; | ||
104 | struct t3_cq cq; | ||
105 | spinlock_t lock; | ||
106 | atomic_t refcnt; | ||
107 | wait_queue_head_t wait; | ||
108 | u32 __user *user_rptr_addr; | ||
109 | }; | ||
110 | |||
111 | static inline struct iwch_cq *to_iwch_cq(struct ib_cq *ibcq) | ||
112 | { | ||
113 | return container_of(ibcq, struct iwch_cq, ibcq); | ||
114 | } | ||
115 | |||
116 | enum IWCH_QP_FLAGS { | ||
117 | QP_QUIESCED = 0x01 | ||
118 | }; | ||
119 | |||
120 | struct iwch_mpa_attributes { | ||
121 | u8 recv_marker_enabled; | ||
122 | u8 xmit_marker_enabled; /* iWARP: enable inbound Read Resp. */ | ||
123 | u8 crc_enabled; | ||
124 | u8 version; /* 0 or 1 */ | ||
125 | }; | ||
126 | |||
127 | struct iwch_qp_attributes { | ||
128 | u32 scq; | ||
129 | u32 rcq; | ||
130 | u32 sq_num_entries; | ||
131 | u32 rq_num_entries; | ||
132 | u32 sq_max_sges; | ||
133 | u32 sq_max_sges_rdma_write; | ||
134 | u32 rq_max_sges; | ||
135 | u32 state; | ||
136 | u8 enable_rdma_read; | ||
137 | u8 enable_rdma_write; /* enable inbound Read Resp. */ | ||
138 | u8 enable_bind; | ||
139 | u8 enable_mmid0_fastreg; /* Enable STAG0 + Fast-register */ | ||
140 | /* | ||
141 | * Next QP state. If specify the current state, only the | ||
142 | * QP attributes will be modified. | ||
143 | */ | ||
144 | u32 max_ord; | ||
145 | u32 max_ird; | ||
146 | u32 pd; /* IN */ | ||
147 | u32 next_state; | ||
148 | char terminate_buffer[52]; | ||
149 | u32 terminate_msg_len; | ||
150 | u8 is_terminate_local; | ||
151 | struct iwch_mpa_attributes mpa_attr; /* IN-OUT */ | ||
152 | struct iwch_ep *llp_stream_handle; | ||
153 | char *stream_msg_buf; /* Last stream msg. before Idle -> RTS */ | ||
154 | u32 stream_msg_buf_len; /* Only on Idle -> RTS */ | ||
155 | }; | ||
156 | |||
157 | struct iwch_qp { | ||
158 | struct ib_qp ibqp; | ||
159 | struct iwch_dev *rhp; | ||
160 | struct iwch_ep *ep; | ||
161 | struct iwch_qp_attributes attr; | ||
162 | struct t3_wq wq; | ||
163 | spinlock_t lock; | ||
164 | atomic_t refcnt; | ||
165 | wait_queue_head_t wait; | ||
166 | enum IWCH_QP_FLAGS flags; | ||
167 | struct timer_list timer; | ||
168 | }; | ||
169 | |||
170 | static inline int qp_quiesced(struct iwch_qp *qhp) | ||
171 | { | ||
172 | return qhp->flags & QP_QUIESCED; | ||
173 | } | ||
174 | |||
175 | static inline struct iwch_qp *to_iwch_qp(struct ib_qp *ibqp) | ||
176 | { | ||
177 | return container_of(ibqp, struct iwch_qp, ibqp); | ||
178 | } | ||
179 | |||
180 | void iwch_qp_add_ref(struct ib_qp *qp); | ||
181 | void iwch_qp_rem_ref(struct ib_qp *qp); | ||
182 | struct ib_qp *iwch_get_qp(struct ib_device *dev, int qpn); | ||
183 | |||
184 | struct iwch_ucontext { | ||
185 | struct ib_ucontext ibucontext; | ||
186 | struct cxio_ucontext uctx; | ||
187 | u32 key; | ||
188 | spinlock_t mmap_lock; | ||
189 | struct list_head mmaps; | ||
190 | }; | ||
191 | |||
192 | static inline struct iwch_ucontext *to_iwch_ucontext(struct ib_ucontext *c) | ||
193 | { | ||
194 | return container_of(c, struct iwch_ucontext, ibucontext); | ||
195 | } | ||
196 | |||
197 | struct iwch_mm_entry { | ||
198 | struct list_head entry; | ||
199 | u64 addr; | ||
200 | u32 key; | ||
201 | unsigned len; | ||
202 | }; | ||
203 | |||
204 | static inline struct iwch_mm_entry *remove_mmap(struct iwch_ucontext *ucontext, | ||
205 | u32 key, unsigned len) | ||
206 | { | ||
207 | struct list_head *pos, *nxt; | ||
208 | struct iwch_mm_entry *mm; | ||
209 | |||
210 | spin_lock(&ucontext->mmap_lock); | ||
211 | list_for_each_safe(pos, nxt, &ucontext->mmaps) { | ||
212 | |||
213 | mm = list_entry(pos, struct iwch_mm_entry, entry); | ||
214 | if (mm->key == key && mm->len == len) { | ||
215 | list_del_init(&mm->entry); | ||
216 | spin_unlock(&ucontext->mmap_lock); | ||
217 | PDBG("%s key 0x%x addr 0x%llx len %d\n", __FUNCTION__, | ||
218 | key, (unsigned long long) mm->addr, mm->len); | ||
219 | return mm; | ||
220 | } | ||
221 | } | ||
222 | spin_unlock(&ucontext->mmap_lock); | ||
223 | return NULL; | ||
224 | } | ||
225 | |||
226 | static inline void insert_mmap(struct iwch_ucontext *ucontext, | ||
227 | struct iwch_mm_entry *mm) | ||
228 | { | ||
229 | spin_lock(&ucontext->mmap_lock); | ||
230 | PDBG("%s key 0x%x addr 0x%llx len %d\n", __FUNCTION__, | ||
231 | mm->key, (unsigned long long) mm->addr, mm->len); | ||
232 | list_add_tail(&mm->entry, &ucontext->mmaps); | ||
233 | spin_unlock(&ucontext->mmap_lock); | ||
234 | } | ||
235 | |||
236 | enum iwch_qp_attr_mask { | ||
237 | IWCH_QP_ATTR_NEXT_STATE = 1 << 0, | ||
238 | IWCH_QP_ATTR_ENABLE_RDMA_READ = 1 << 7, | ||
239 | IWCH_QP_ATTR_ENABLE_RDMA_WRITE = 1 << 8, | ||
240 | IWCH_QP_ATTR_ENABLE_RDMA_BIND = 1 << 9, | ||
241 | IWCH_QP_ATTR_MAX_ORD = 1 << 11, | ||
242 | IWCH_QP_ATTR_MAX_IRD = 1 << 12, | ||
243 | IWCH_QP_ATTR_LLP_STREAM_HANDLE = 1 << 22, | ||
244 | IWCH_QP_ATTR_STREAM_MSG_BUFFER = 1 << 23, | ||
245 | IWCH_QP_ATTR_MPA_ATTR = 1 << 24, | ||
246 | IWCH_QP_ATTR_QP_CONTEXT_ACTIVATE = 1 << 25, | ||
247 | IWCH_QP_ATTR_VALID_MODIFY = (IWCH_QP_ATTR_ENABLE_RDMA_READ | | ||
248 | IWCH_QP_ATTR_ENABLE_RDMA_WRITE | | ||
249 | IWCH_QP_ATTR_MAX_ORD | | ||
250 | IWCH_QP_ATTR_MAX_IRD | | ||
251 | IWCH_QP_ATTR_LLP_STREAM_HANDLE | | ||
252 | IWCH_QP_ATTR_STREAM_MSG_BUFFER | | ||
253 | IWCH_QP_ATTR_MPA_ATTR | | ||
254 | IWCH_QP_ATTR_QP_CONTEXT_ACTIVATE) | ||
255 | }; | ||
256 | |||
257 | int iwch_modify_qp(struct iwch_dev *rhp, | ||
258 | struct iwch_qp *qhp, | ||
259 | enum iwch_qp_attr_mask mask, | ||
260 | struct iwch_qp_attributes *attrs, | ||
261 | int internal); | ||
262 | |||
263 | enum iwch_qp_state { | ||
264 | IWCH_QP_STATE_IDLE, | ||
265 | IWCH_QP_STATE_RTS, | ||
266 | IWCH_QP_STATE_ERROR, | ||
267 | IWCH_QP_STATE_TERMINATE, | ||
268 | IWCH_QP_STATE_CLOSING, | ||
269 | IWCH_QP_STATE_TOT | ||
270 | }; | ||
271 | |||
272 | static inline int iwch_convert_state(enum ib_qp_state ib_state) | ||
273 | { | ||
274 | switch (ib_state) { | ||
275 | case IB_QPS_RESET: | ||
276 | case IB_QPS_INIT: | ||
277 | return IWCH_QP_STATE_IDLE; | ||
278 | case IB_QPS_RTS: | ||
279 | return IWCH_QP_STATE_RTS; | ||
280 | case IB_QPS_SQD: | ||
281 | return IWCH_QP_STATE_CLOSING; | ||
282 | case IB_QPS_SQE: | ||
283 | return IWCH_QP_STATE_TERMINATE; | ||
284 | case IB_QPS_ERR: | ||
285 | return IWCH_QP_STATE_ERROR; | ||
286 | default: | ||
287 | return -1; | ||
288 | } | ||
289 | } | ||
290 | |||
291 | enum iwch_mem_perms { | ||
292 | IWCH_MEM_ACCESS_LOCAL_READ = 1 << 0, | ||
293 | IWCH_MEM_ACCESS_LOCAL_WRITE = 1 << 1, | ||
294 | IWCH_MEM_ACCESS_REMOTE_READ = 1 << 2, | ||
295 | IWCH_MEM_ACCESS_REMOTE_WRITE = 1 << 3, | ||
296 | IWCH_MEM_ACCESS_ATOMICS = 1 << 4, | ||
297 | IWCH_MEM_ACCESS_BINDING = 1 << 5, | ||
298 | IWCH_MEM_ACCESS_LOCAL = | ||
299 | (IWCH_MEM_ACCESS_LOCAL_READ | IWCH_MEM_ACCESS_LOCAL_WRITE), | ||
300 | IWCH_MEM_ACCESS_REMOTE = | ||
301 | (IWCH_MEM_ACCESS_REMOTE_WRITE | IWCH_MEM_ACCESS_REMOTE_READ) | ||
302 | /* cannot go beyond 1 << 31 */ | ||
303 | } __attribute__ ((packed)); | ||
304 | |||
305 | static inline u32 iwch_convert_access(int acc) | ||
306 | { | ||
307 | return (acc & IB_ACCESS_REMOTE_WRITE ? IWCH_MEM_ACCESS_REMOTE_WRITE : 0) | ||
308 | | (acc & IB_ACCESS_REMOTE_READ ? IWCH_MEM_ACCESS_REMOTE_READ : 0) | | ||
309 | (acc & IB_ACCESS_LOCAL_WRITE ? IWCH_MEM_ACCESS_LOCAL_WRITE : 0) | | ||
310 | (acc & IB_ACCESS_MW_BIND ? IWCH_MEM_ACCESS_BINDING : 0) | | ||
311 | IWCH_MEM_ACCESS_LOCAL_READ; | ||
312 | } | ||
313 | |||
314 | enum iwch_mmid_state { | ||
315 | IWCH_STAG_STATE_VALID, | ||
316 | IWCH_STAG_STATE_INVALID | ||
317 | }; | ||
318 | |||
319 | enum iwch_qp_query_flags { | ||
320 | IWCH_QP_QUERY_CONTEXT_NONE = 0x0, /* No ctx; Only attrs */ | ||
321 | IWCH_QP_QUERY_CONTEXT_GET = 0x1, /* Get ctx + attrs */ | ||
322 | IWCH_QP_QUERY_CONTEXT_SUSPEND = 0x2, /* Not Supported */ | ||
323 | |||
324 | /* | ||
325 | * Quiesce QP context; Consumer | ||
326 | * will NOT replay outstanding WR | ||
327 | */ | ||
328 | IWCH_QP_QUERY_CONTEXT_QUIESCE = 0x4, | ||
329 | IWCH_QP_QUERY_CONTEXT_REMOVE = 0x8, | ||
330 | IWCH_QP_QUERY_TEST_USERWRITE = 0x32 /* Test special */ | ||
331 | }; | ||
332 | |||
333 | int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | ||
334 | struct ib_send_wr **bad_wr); | ||
335 | int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | ||
336 | struct ib_recv_wr **bad_wr); | ||
337 | int iwch_bind_mw(struct ib_qp *qp, | ||
338 | struct ib_mw *mw, | ||
339 | struct ib_mw_bind *mw_bind); | ||
340 | int iwch_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); | ||
341 | int iwch_post_terminate(struct iwch_qp *qhp, struct respQ_msg_t *rsp_msg); | ||
342 | int iwch_register_device(struct iwch_dev *dev); | ||
343 | void iwch_unregister_device(struct iwch_dev *dev); | ||
344 | int iwch_quiesce_qps(struct iwch_cq *chp); | ||
345 | int iwch_resume_qps(struct iwch_cq *chp); | ||
346 | void stop_read_rep_timer(struct iwch_qp *qhp); | ||
347 | int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php, | ||
348 | struct iwch_mr *mhp, | ||
349 | int shift, | ||
350 | __be64 *page_list); | ||
351 | int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php, | ||
352 | struct iwch_mr *mhp, | ||
353 | int shift, | ||
354 | __be64 *page_list, | ||
355 | int npages); | ||
356 | int build_phys_page_list(struct ib_phys_buf *buffer_list, | ||
357 | int num_phys_buf, | ||
358 | u64 *iova_start, | ||
359 | u64 *total_size, | ||
360 | int *npages, | ||
361 | int *shift, | ||
362 | __be64 **page_list); | ||
363 | |||
364 | |||
365 | #define IWCH_NODE_DESC "cxgb3 Chelsio Communications" | ||
366 | |||
367 | #endif | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c new file mode 100644 index 000000000000..e066727504b6 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c | |||
@@ -0,0 +1,1007 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #include "iwch_provider.h" | ||
34 | #include "iwch.h" | ||
35 | #include "iwch_cm.h" | ||
36 | #include "cxio_hal.h" | ||
37 | |||
38 | #define NO_SUPPORT -1 | ||
39 | |||
40 | static inline int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr, | ||
41 | u8 * flit_cnt) | ||
42 | { | ||
43 | int i; | ||
44 | u32 plen; | ||
45 | |||
46 | switch (wr->opcode) { | ||
47 | case IB_WR_SEND: | ||
48 | case IB_WR_SEND_WITH_IMM: | ||
49 | if (wr->send_flags & IB_SEND_SOLICITED) | ||
50 | wqe->send.rdmaop = T3_SEND_WITH_SE; | ||
51 | else | ||
52 | wqe->send.rdmaop = T3_SEND; | ||
53 | wqe->send.rem_stag = 0; | ||
54 | break; | ||
55 | #if 0 /* Not currently supported */ | ||
56 | case TYPE_SEND_INVALIDATE: | ||
57 | case TYPE_SEND_INVALIDATE_IMMEDIATE: | ||
58 | wqe->send.rdmaop = T3_SEND_WITH_INV; | ||
59 | wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); | ||
60 | break; | ||
61 | case TYPE_SEND_SE_INVALIDATE: | ||
62 | wqe->send.rdmaop = T3_SEND_WITH_SE_INV; | ||
63 | wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); | ||
64 | break; | ||
65 | #endif | ||
66 | default: | ||
67 | break; | ||
68 | } | ||
69 | if (wr->num_sge > T3_MAX_SGE) | ||
70 | return -EINVAL; | ||
71 | wqe->send.reserved[0] = 0; | ||
72 | wqe->send.reserved[1] = 0; | ||
73 | wqe->send.reserved[2] = 0; | ||
74 | if (wr->opcode == IB_WR_SEND_WITH_IMM) { | ||
75 | plen = 4; | ||
76 | wqe->send.sgl[0].stag = wr->imm_data; | ||
77 | wqe->send.sgl[0].len = __constant_cpu_to_be32(0); | ||
78 | wqe->send.num_sgle = __constant_cpu_to_be32(0); | ||
79 | *flit_cnt = 5; | ||
80 | } else { | ||
81 | plen = 0; | ||
82 | for (i = 0; i < wr->num_sge; i++) { | ||
83 | if ((plen + wr->sg_list[i].length) < plen) { | ||
84 | return -EMSGSIZE; | ||
85 | } | ||
86 | plen += wr->sg_list[i].length; | ||
87 | wqe->send.sgl[i].stag = | ||
88 | cpu_to_be32(wr->sg_list[i].lkey); | ||
89 | wqe->send.sgl[i].len = | ||
90 | cpu_to_be32(wr->sg_list[i].length); | ||
91 | wqe->send.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr); | ||
92 | } | ||
93 | wqe->send.num_sgle = cpu_to_be32(wr->num_sge); | ||
94 | *flit_cnt = 4 + ((wr->num_sge) << 1); | ||
95 | } | ||
96 | wqe->send.plen = cpu_to_be32(plen); | ||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | static inline int iwch_build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr, | ||
101 | u8 *flit_cnt) | ||
102 | { | ||
103 | int i; | ||
104 | u32 plen; | ||
105 | if (wr->num_sge > T3_MAX_SGE) | ||
106 | return -EINVAL; | ||
107 | wqe->write.rdmaop = T3_RDMA_WRITE; | ||
108 | wqe->write.reserved[0] = 0; | ||
109 | wqe->write.reserved[1] = 0; | ||
110 | wqe->write.reserved[2] = 0; | ||
111 | wqe->write.stag_sink = cpu_to_be32(wr->wr.rdma.rkey); | ||
112 | wqe->write.to_sink = cpu_to_be64(wr->wr.rdma.remote_addr); | ||
113 | |||
114 | if (wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) { | ||
115 | plen = 4; | ||
116 | wqe->write.sgl[0].stag = wr->imm_data; | ||
117 | wqe->write.sgl[0].len = __constant_cpu_to_be32(0); | ||
118 | wqe->write.num_sgle = __constant_cpu_to_be32(0); | ||
119 | *flit_cnt = 6; | ||
120 | } else { | ||
121 | plen = 0; | ||
122 | for (i = 0; i < wr->num_sge; i++) { | ||
123 | if ((plen + wr->sg_list[i].length) < plen) { | ||
124 | return -EMSGSIZE; | ||
125 | } | ||
126 | plen += wr->sg_list[i].length; | ||
127 | wqe->write.sgl[i].stag = | ||
128 | cpu_to_be32(wr->sg_list[i].lkey); | ||
129 | wqe->write.sgl[i].len = | ||
130 | cpu_to_be32(wr->sg_list[i].length); | ||
131 | wqe->write.sgl[i].to = | ||
132 | cpu_to_be64(wr->sg_list[i].addr); | ||
133 | } | ||
134 | wqe->write.num_sgle = cpu_to_be32(wr->num_sge); | ||
135 | *flit_cnt = 5 + ((wr->num_sge) << 1); | ||
136 | } | ||
137 | wqe->write.plen = cpu_to_be32(plen); | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static inline int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr, | ||
142 | u8 *flit_cnt) | ||
143 | { | ||
144 | if (wr->num_sge > 1) | ||
145 | return -EINVAL; | ||
146 | wqe->read.rdmaop = T3_READ_REQ; | ||
147 | wqe->read.reserved[0] = 0; | ||
148 | wqe->read.reserved[1] = 0; | ||
149 | wqe->read.reserved[2] = 0; | ||
150 | wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); | ||
151 | wqe->read.rem_to = cpu_to_be64(wr->wr.rdma.remote_addr); | ||
152 | wqe->read.local_stag = cpu_to_be32(wr->sg_list[0].lkey); | ||
153 | wqe->read.local_len = cpu_to_be32(wr->sg_list[0].length); | ||
154 | wqe->read.local_to = cpu_to_be64(wr->sg_list[0].addr); | ||
155 | *flit_cnt = sizeof(struct t3_rdma_read_wr) >> 3; | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | /* | ||
160 | * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now. | ||
161 | */ | ||
162 | static inline int iwch_sgl2pbl_map(struct iwch_dev *rhp, | ||
163 | struct ib_sge *sg_list, u32 num_sgle, | ||
164 | u32 * pbl_addr, u8 * page_size) | ||
165 | { | ||
166 | int i; | ||
167 | struct iwch_mr *mhp; | ||
168 | u32 offset; | ||
169 | for (i = 0; i < num_sgle; i++) { | ||
170 | |||
171 | mhp = get_mhp(rhp, (sg_list[i].lkey) >> 8); | ||
172 | if (!mhp) { | ||
173 | PDBG("%s %d\n", __FUNCTION__, __LINE__); | ||
174 | return -EIO; | ||
175 | } | ||
176 | if (!mhp->attr.state) { | ||
177 | PDBG("%s %d\n", __FUNCTION__, __LINE__); | ||
178 | return -EIO; | ||
179 | } | ||
180 | if (mhp->attr.zbva) { | ||
181 | PDBG("%s %d\n", __FUNCTION__, __LINE__); | ||
182 | return -EIO; | ||
183 | } | ||
184 | |||
185 | if (sg_list[i].addr < mhp->attr.va_fbo) { | ||
186 | PDBG("%s %d\n", __FUNCTION__, __LINE__); | ||
187 | return -EINVAL; | ||
188 | } | ||
189 | if (sg_list[i].addr + ((u64) sg_list[i].length) < | ||
190 | sg_list[i].addr) { | ||
191 | PDBG("%s %d\n", __FUNCTION__, __LINE__); | ||
192 | return -EINVAL; | ||
193 | } | ||
194 | if (sg_list[i].addr + ((u64) sg_list[i].length) > | ||
195 | mhp->attr.va_fbo + ((u64) mhp->attr.len)) { | ||
196 | PDBG("%s %d\n", __FUNCTION__, __LINE__); | ||
197 | return -EINVAL; | ||
198 | } | ||
199 | offset = sg_list[i].addr - mhp->attr.va_fbo; | ||
200 | offset += ((u32) mhp->attr.va_fbo) % | ||
201 | (1UL << (12 + mhp->attr.page_size)); | ||
202 | pbl_addr[i] = ((mhp->attr.pbl_addr - | ||
203 | rhp->rdev.rnic_info.pbl_base) >> 3) + | ||
204 | (offset >> (12 + mhp->attr.page_size)); | ||
205 | page_size[i] = mhp->attr.page_size; | ||
206 | } | ||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | static inline int iwch_build_rdma_recv(struct iwch_dev *rhp, | ||
211 | union t3_wr *wqe, | ||
212 | struct ib_recv_wr *wr) | ||
213 | { | ||
214 | int i, err = 0; | ||
215 | u32 pbl_addr[4]; | ||
216 | u8 page_size[4]; | ||
217 | if (wr->num_sge > T3_MAX_SGE) | ||
218 | return -EINVAL; | ||
219 | err = iwch_sgl2pbl_map(rhp, wr->sg_list, wr->num_sge, pbl_addr, | ||
220 | page_size); | ||
221 | if (err) | ||
222 | return err; | ||
223 | wqe->recv.pagesz[0] = page_size[0]; | ||
224 | wqe->recv.pagesz[1] = page_size[1]; | ||
225 | wqe->recv.pagesz[2] = page_size[2]; | ||
226 | wqe->recv.pagesz[3] = page_size[3]; | ||
227 | wqe->recv.num_sgle = cpu_to_be32(wr->num_sge); | ||
228 | for (i = 0; i < wr->num_sge; i++) { | ||
229 | wqe->recv.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey); | ||
230 | wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length); | ||
231 | |||
232 | /* to in the WQE == the offset into the page */ | ||
233 | wqe->recv.sgl[i].to = cpu_to_be64(((u32) wr->sg_list[i].addr) % | ||
234 | (1UL << (12 + page_size[i]))); | ||
235 | |||
236 | /* pbl_addr is the adapters address in the PBL */ | ||
237 | wqe->recv.pbl_addr[i] = cpu_to_be32(pbl_addr[i]); | ||
238 | } | ||
239 | for (; i < T3_MAX_SGE; i++) { | ||
240 | wqe->recv.sgl[i].stag = 0; | ||
241 | wqe->recv.sgl[i].len = 0; | ||
242 | wqe->recv.sgl[i].to = 0; | ||
243 | wqe->recv.pbl_addr[i] = 0; | ||
244 | } | ||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | ||
249 | struct ib_send_wr **bad_wr) | ||
250 | { | ||
251 | int err = 0; | ||
252 | u8 t3_wr_flit_cnt; | ||
253 | enum t3_wr_opcode t3_wr_opcode = 0; | ||
254 | enum t3_wr_flags t3_wr_flags; | ||
255 | struct iwch_qp *qhp; | ||
256 | u32 idx; | ||
257 | union t3_wr *wqe; | ||
258 | u32 num_wrs; | ||
259 | unsigned long flag; | ||
260 | struct t3_swsq *sqp; | ||
261 | |||
262 | qhp = to_iwch_qp(ibqp); | ||
263 | spin_lock_irqsave(&qhp->lock, flag); | ||
264 | if (qhp->attr.state > IWCH_QP_STATE_RTS) { | ||
265 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
266 | return -EINVAL; | ||
267 | } | ||
268 | num_wrs = Q_FREECNT(qhp->wq.sq_rptr, qhp->wq.sq_wptr, | ||
269 | qhp->wq.sq_size_log2); | ||
270 | if (num_wrs <= 0) { | ||
271 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
272 | return -ENOMEM; | ||
273 | } | ||
274 | while (wr) { | ||
275 | if (num_wrs == 0) { | ||
276 | err = -ENOMEM; | ||
277 | *bad_wr = wr; | ||
278 | break; | ||
279 | } | ||
280 | idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2); | ||
281 | wqe = (union t3_wr *) (qhp->wq.queue + idx); | ||
282 | t3_wr_flags = 0; | ||
283 | if (wr->send_flags & IB_SEND_SOLICITED) | ||
284 | t3_wr_flags |= T3_SOLICITED_EVENT_FLAG; | ||
285 | if (wr->send_flags & IB_SEND_FENCE) | ||
286 | t3_wr_flags |= T3_READ_FENCE_FLAG; | ||
287 | if (wr->send_flags & IB_SEND_SIGNALED) | ||
288 | t3_wr_flags |= T3_COMPLETION_FLAG; | ||
289 | sqp = qhp->wq.sq + | ||
290 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); | ||
291 | switch (wr->opcode) { | ||
292 | case IB_WR_SEND: | ||
293 | case IB_WR_SEND_WITH_IMM: | ||
294 | t3_wr_opcode = T3_WR_SEND; | ||
295 | err = iwch_build_rdma_send(wqe, wr, &t3_wr_flit_cnt); | ||
296 | break; | ||
297 | case IB_WR_RDMA_WRITE: | ||
298 | case IB_WR_RDMA_WRITE_WITH_IMM: | ||
299 | t3_wr_opcode = T3_WR_WRITE; | ||
300 | err = iwch_build_rdma_write(wqe, wr, &t3_wr_flit_cnt); | ||
301 | break; | ||
302 | case IB_WR_RDMA_READ: | ||
303 | t3_wr_opcode = T3_WR_READ; | ||
304 | t3_wr_flags = 0; /* T3 reads are always signaled */ | ||
305 | err = iwch_build_rdma_read(wqe, wr, &t3_wr_flit_cnt); | ||
306 | if (err) | ||
307 | break; | ||
308 | sqp->read_len = wqe->read.local_len; | ||
309 | if (!qhp->wq.oldest_read) | ||
310 | qhp->wq.oldest_read = sqp; | ||
311 | break; | ||
312 | default: | ||
313 | PDBG("%s post of type=%d TBD!\n", __FUNCTION__, | ||
314 | wr->opcode); | ||
315 | err = -EINVAL; | ||
316 | } | ||
317 | if (err) { | ||
318 | *bad_wr = wr; | ||
319 | break; | ||
320 | } | ||
321 | wqe->send.wrid.id0.hi = qhp->wq.sq_wptr; | ||
322 | sqp->wr_id = wr->wr_id; | ||
323 | sqp->opcode = wr2opcode(t3_wr_opcode); | ||
324 | sqp->sq_wptr = qhp->wq.sq_wptr; | ||
325 | sqp->complete = 0; | ||
326 | sqp->signaled = (wr->send_flags & IB_SEND_SIGNALED); | ||
327 | |||
328 | build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags, | ||
329 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), | ||
330 | 0, t3_wr_flit_cnt); | ||
331 | PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n", | ||
332 | __FUNCTION__, (unsigned long long) wr->wr_id, idx, | ||
333 | Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2), | ||
334 | sqp->opcode); | ||
335 | wr = wr->next; | ||
336 | num_wrs--; | ||
337 | ++(qhp->wq.wptr); | ||
338 | ++(qhp->wq.sq_wptr); | ||
339 | } | ||
340 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
341 | ring_doorbell(qhp->wq.doorbell, qhp->wq.qpid); | ||
342 | return err; | ||
343 | } | ||
344 | |||
345 | int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | ||
346 | struct ib_recv_wr **bad_wr) | ||
347 | { | ||
348 | int err = 0; | ||
349 | struct iwch_qp *qhp; | ||
350 | u32 idx; | ||
351 | union t3_wr *wqe; | ||
352 | u32 num_wrs; | ||
353 | unsigned long flag; | ||
354 | |||
355 | qhp = to_iwch_qp(ibqp); | ||
356 | spin_lock_irqsave(&qhp->lock, flag); | ||
357 | if (qhp->attr.state > IWCH_QP_STATE_RTS) { | ||
358 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
359 | return -EINVAL; | ||
360 | } | ||
361 | num_wrs = Q_FREECNT(qhp->wq.rq_rptr, qhp->wq.rq_wptr, | ||
362 | qhp->wq.rq_size_log2) - 1; | ||
363 | if (!wr) { | ||
364 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
365 | return -EINVAL; | ||
366 | } | ||
367 | while (wr) { | ||
368 | idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2); | ||
369 | wqe = (union t3_wr *) (qhp->wq.queue + idx); | ||
370 | if (num_wrs) | ||
371 | err = iwch_build_rdma_recv(qhp->rhp, wqe, wr); | ||
372 | else | ||
373 | err = -ENOMEM; | ||
374 | if (err) { | ||
375 | *bad_wr = wr; | ||
376 | break; | ||
377 | } | ||
378 | qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, qhp->wq.rq_size_log2)] = | ||
379 | wr->wr_id; | ||
380 | build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG, | ||
381 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), | ||
382 | 0, sizeof(struct t3_receive_wr) >> 3); | ||
383 | PDBG("%s cookie 0x%llx idx 0x%x rq_wptr 0x%x rw_rptr 0x%x " | ||
384 | "wqe %p \n", __FUNCTION__, (unsigned long long) wr->wr_id, | ||
385 | idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe); | ||
386 | ++(qhp->wq.rq_wptr); | ||
387 | ++(qhp->wq.wptr); | ||
388 | wr = wr->next; | ||
389 | num_wrs--; | ||
390 | } | ||
391 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
392 | ring_doorbell(qhp->wq.doorbell, qhp->wq.qpid); | ||
393 | return err; | ||
394 | } | ||
395 | |||
396 | int iwch_bind_mw(struct ib_qp *qp, | ||
397 | struct ib_mw *mw, | ||
398 | struct ib_mw_bind *mw_bind) | ||
399 | { | ||
400 | struct iwch_dev *rhp; | ||
401 | struct iwch_mw *mhp; | ||
402 | struct iwch_qp *qhp; | ||
403 | union t3_wr *wqe; | ||
404 | u32 pbl_addr; | ||
405 | u8 page_size; | ||
406 | u32 num_wrs; | ||
407 | unsigned long flag; | ||
408 | struct ib_sge sgl; | ||
409 | int err=0; | ||
410 | enum t3_wr_flags t3_wr_flags; | ||
411 | u32 idx; | ||
412 | struct t3_swsq *sqp; | ||
413 | |||
414 | qhp = to_iwch_qp(qp); | ||
415 | mhp = to_iwch_mw(mw); | ||
416 | rhp = qhp->rhp; | ||
417 | |||
418 | spin_lock_irqsave(&qhp->lock, flag); | ||
419 | if (qhp->attr.state > IWCH_QP_STATE_RTS) { | ||
420 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
421 | return -EINVAL; | ||
422 | } | ||
423 | num_wrs = Q_FREECNT(qhp->wq.sq_rptr, qhp->wq.sq_wptr, | ||
424 | qhp->wq.sq_size_log2); | ||
425 | if ((num_wrs) <= 0) { | ||
426 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
427 | return -ENOMEM; | ||
428 | } | ||
429 | idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2); | ||
430 | PDBG("%s: idx 0x%0x, mw 0x%p, mw_bind 0x%p\n", __FUNCTION__, idx, | ||
431 | mw, mw_bind); | ||
432 | wqe = (union t3_wr *) (qhp->wq.queue + idx); | ||
433 | |||
434 | t3_wr_flags = 0; | ||
435 | if (mw_bind->send_flags & IB_SEND_SIGNALED) | ||
436 | t3_wr_flags = T3_COMPLETION_FLAG; | ||
437 | |||
438 | sgl.addr = mw_bind->addr; | ||
439 | sgl.lkey = mw_bind->mr->lkey; | ||
440 | sgl.length = mw_bind->length; | ||
441 | wqe->bind.reserved = 0; | ||
442 | wqe->bind.type = T3_VA_BASED_TO; | ||
443 | |||
444 | /* TBD: check perms */ | ||
445 | wqe->bind.perms = iwch_convert_access(mw_bind->mw_access_flags); | ||
446 | wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey); | ||
447 | wqe->bind.mw_stag = cpu_to_be32(mw->rkey); | ||
448 | wqe->bind.mw_len = cpu_to_be32(mw_bind->length); | ||
449 | wqe->bind.mw_va = cpu_to_be64(mw_bind->addr); | ||
450 | err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size); | ||
451 | if (err) { | ||
452 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
453 | return err; | ||
454 | } | ||
455 | wqe->send.wrid.id0.hi = qhp->wq.sq_wptr; | ||
456 | sqp = qhp->wq.sq + Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); | ||
457 | sqp->wr_id = mw_bind->wr_id; | ||
458 | sqp->opcode = T3_BIND_MW; | ||
459 | sqp->sq_wptr = qhp->wq.sq_wptr; | ||
460 | sqp->complete = 0; | ||
461 | sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED); | ||
462 | wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr); | ||
463 | wqe->bind.mr_pagesz = page_size; | ||
464 | wqe->flit[T3_SQ_COOKIE_FLIT] = mw_bind->wr_id; | ||
465 | build_fw_riwrh((void *)wqe, T3_WR_BIND, t3_wr_flags, | ||
466 | Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0, | ||
467 | sizeof(struct t3_bind_mw_wr) >> 3); | ||
468 | ++(qhp->wq.wptr); | ||
469 | ++(qhp->wq.sq_wptr); | ||
470 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
471 | |||
472 | ring_doorbell(qhp->wq.doorbell, qhp->wq.qpid); | ||
473 | |||
474 | return err; | ||
475 | } | ||
476 | |||
477 | static inline void build_term_codes(int t3err, u8 *layer_type, u8 *ecode, | ||
478 | int tagged) | ||
479 | { | ||
480 | switch (t3err) { | ||
481 | case TPT_ERR_STAG: | ||
482 | if (tagged == 1) { | ||
483 | *layer_type = LAYER_DDP|DDP_TAGGED_ERR; | ||
484 | *ecode = DDPT_INV_STAG; | ||
485 | } else if (tagged == 2) { | ||
486 | *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT; | ||
487 | *ecode = RDMAP_INV_STAG; | ||
488 | } | ||
489 | break; | ||
490 | case TPT_ERR_PDID: | ||
491 | case TPT_ERR_QPID: | ||
492 | case TPT_ERR_ACCESS: | ||
493 | if (tagged == 1) { | ||
494 | *layer_type = LAYER_DDP|DDP_TAGGED_ERR; | ||
495 | *ecode = DDPT_STAG_NOT_ASSOC; | ||
496 | } else if (tagged == 2) { | ||
497 | *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT; | ||
498 | *ecode = RDMAP_STAG_NOT_ASSOC; | ||
499 | } | ||
500 | break; | ||
501 | case TPT_ERR_WRAP: | ||
502 | *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT; | ||
503 | *ecode = RDMAP_TO_WRAP; | ||
504 | break; | ||
505 | case TPT_ERR_BOUND: | ||
506 | if (tagged == 1) { | ||
507 | *layer_type = LAYER_DDP|DDP_TAGGED_ERR; | ||
508 | *ecode = DDPT_BASE_BOUNDS; | ||
509 | } else if (tagged == 2) { | ||
510 | *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT; | ||
511 | *ecode = RDMAP_BASE_BOUNDS; | ||
512 | } else { | ||
513 | *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR; | ||
514 | *ecode = DDPU_MSG_TOOBIG; | ||
515 | } | ||
516 | break; | ||
517 | case TPT_ERR_INVALIDATE_SHARED_MR: | ||
518 | case TPT_ERR_INVALIDATE_MR_WITH_MW_BOUND: | ||
519 | *layer_type = LAYER_RDMAP|RDMAP_REMOTE_OP; | ||
520 | *ecode = RDMAP_CANT_INV_STAG; | ||
521 | break; | ||
522 | case TPT_ERR_ECC: | ||
523 | case TPT_ERR_ECC_PSTAG: | ||
524 | case TPT_ERR_INTERNAL_ERR: | ||
525 | *layer_type = LAYER_RDMAP|RDMAP_LOCAL_CATA; | ||
526 | *ecode = 0; | ||
527 | break; | ||
528 | case TPT_ERR_OUT_OF_RQE: | ||
529 | *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR; | ||
530 | *ecode = DDPU_INV_MSN_NOBUF; | ||
531 | break; | ||
532 | case TPT_ERR_PBL_ADDR_BOUND: | ||
533 | *layer_type = LAYER_DDP|DDP_TAGGED_ERR; | ||
534 | *ecode = DDPT_BASE_BOUNDS; | ||
535 | break; | ||
536 | case TPT_ERR_CRC: | ||
537 | *layer_type = LAYER_MPA|DDP_LLP; | ||
538 | *ecode = MPA_CRC_ERR; | ||
539 | break; | ||
540 | case TPT_ERR_MARKER: | ||
541 | *layer_type = LAYER_MPA|DDP_LLP; | ||
542 | *ecode = MPA_MARKER_ERR; | ||
543 | break; | ||
544 | case TPT_ERR_PDU_LEN_ERR: | ||
545 | *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR; | ||
546 | *ecode = DDPU_MSG_TOOBIG; | ||
547 | break; | ||
548 | case TPT_ERR_DDP_VERSION: | ||
549 | if (tagged) { | ||
550 | *layer_type = LAYER_DDP|DDP_TAGGED_ERR; | ||
551 | *ecode = DDPT_INV_VERS; | ||
552 | } else { | ||
553 | *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR; | ||
554 | *ecode = DDPU_INV_VERS; | ||
555 | } | ||
556 | break; | ||
557 | case TPT_ERR_RDMA_VERSION: | ||
558 | *layer_type = LAYER_RDMAP|RDMAP_REMOTE_OP; | ||
559 | *ecode = RDMAP_INV_VERS; | ||
560 | break; | ||
561 | case TPT_ERR_OPCODE: | ||
562 | *layer_type = LAYER_RDMAP|RDMAP_REMOTE_OP; | ||
563 | *ecode = RDMAP_INV_OPCODE; | ||
564 | break; | ||
565 | case TPT_ERR_DDP_QUEUE_NUM: | ||
566 | *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR; | ||
567 | *ecode = DDPU_INV_QN; | ||
568 | break; | ||
569 | case TPT_ERR_MSN: | ||
570 | case TPT_ERR_MSN_GAP: | ||
571 | case TPT_ERR_MSN_RANGE: | ||
572 | case TPT_ERR_IRD_OVERFLOW: | ||
573 | *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR; | ||
574 | *ecode = DDPU_INV_MSN_RANGE; | ||
575 | break; | ||
576 | case TPT_ERR_TBIT: | ||
577 | *layer_type = LAYER_DDP|DDP_LOCAL_CATA; | ||
578 | *ecode = 0; | ||
579 | break; | ||
580 | case TPT_ERR_MO: | ||
581 | *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR; | ||
582 | *ecode = DDPU_INV_MO; | ||
583 | break; | ||
584 | default: | ||
585 | *layer_type = LAYER_RDMAP|DDP_LOCAL_CATA; | ||
586 | *ecode = 0; | ||
587 | break; | ||
588 | } | ||
589 | } | ||
590 | |||
591 | /* | ||
592 | * This posts a TERMINATE with layer=RDMA, type=catastrophic. | ||
593 | */ | ||
594 | int iwch_post_terminate(struct iwch_qp *qhp, struct respQ_msg_t *rsp_msg) | ||
595 | { | ||
596 | union t3_wr *wqe; | ||
597 | struct terminate_message *term; | ||
598 | int status; | ||
599 | int tagged = 0; | ||
600 | struct sk_buff *skb; | ||
601 | |||
602 | PDBG("%s %d\n", __FUNCTION__, __LINE__); | ||
603 | skb = alloc_skb(40, GFP_ATOMIC); | ||
604 | if (!skb) { | ||
605 | printk(KERN_ERR "%s cannot send TERMINATE!\n", __FUNCTION__); | ||
606 | return -ENOMEM; | ||
607 | } | ||
608 | wqe = (union t3_wr *)skb_put(skb, 40); | ||
609 | memset(wqe, 0, 40); | ||
610 | wqe->send.rdmaop = T3_TERMINATE; | ||
611 | |||
612 | /* immediate data length */ | ||
613 | wqe->send.plen = htonl(4); | ||
614 | |||
615 | /* immediate data starts here. */ | ||
616 | term = (struct terminate_message *)wqe->send.sgl; | ||
617 | if (rsp_msg) { | ||
618 | status = CQE_STATUS(rsp_msg->cqe); | ||
619 | if (CQE_OPCODE(rsp_msg->cqe) == T3_RDMA_WRITE) | ||
620 | tagged = 1; | ||
621 | if ((CQE_OPCODE(rsp_msg->cqe) == T3_READ_REQ) || | ||
622 | (CQE_OPCODE(rsp_msg->cqe) == T3_READ_RESP)) | ||
623 | tagged = 2; | ||
624 | } else { | ||
625 | status = TPT_ERR_INTERNAL_ERR; | ||
626 | } | ||
627 | build_term_codes(status, &term->layer_etype, &term->ecode, tagged); | ||
628 | build_fw_riwrh((void *)wqe, T3_WR_SEND, | ||
629 | T3_COMPLETION_FLAG | T3_NOTIFY_FLAG, 1, | ||
630 | qhp->ep->hwtid, 5); | ||
631 | skb->priority = CPL_PRIORITY_DATA; | ||
632 | return cxgb3_ofld_send(qhp->rhp->rdev.t3cdev_p, skb); | ||
633 | } | ||
634 | |||
635 | /* | ||
636 | * Assumes qhp lock is held. | ||
637 | */ | ||
638 | static void __flush_qp(struct iwch_qp *qhp, unsigned long *flag) | ||
639 | { | ||
640 | struct iwch_cq *rchp, *schp; | ||
641 | int count; | ||
642 | |||
643 | rchp = get_chp(qhp->rhp, qhp->attr.rcq); | ||
644 | schp = get_chp(qhp->rhp, qhp->attr.scq); | ||
645 | |||
646 | PDBG("%s qhp %p rchp %p schp %p\n", __FUNCTION__, qhp, rchp, schp); | ||
647 | /* take a ref on the qhp since we must release the lock */ | ||
648 | atomic_inc(&qhp->refcnt); | ||
649 | spin_unlock_irqrestore(&qhp->lock, *flag); | ||
650 | |||
651 | /* locking heirarchy: cq lock first, then qp lock. */ | ||
652 | spin_lock_irqsave(&rchp->lock, *flag); | ||
653 | spin_lock(&qhp->lock); | ||
654 | cxio_flush_hw_cq(&rchp->cq); | ||
655 | cxio_count_rcqes(&rchp->cq, &qhp->wq, &count); | ||
656 | cxio_flush_rq(&qhp->wq, &rchp->cq, count); | ||
657 | spin_unlock(&qhp->lock); | ||
658 | spin_unlock_irqrestore(&rchp->lock, *flag); | ||
659 | |||
660 | /* locking heirarchy: cq lock first, then qp lock. */ | ||
661 | spin_lock_irqsave(&schp->lock, *flag); | ||
662 | spin_lock(&qhp->lock); | ||
663 | cxio_flush_hw_cq(&schp->cq); | ||
664 | cxio_count_scqes(&schp->cq, &qhp->wq, &count); | ||
665 | cxio_flush_sq(&qhp->wq, &schp->cq, count); | ||
666 | spin_unlock(&qhp->lock); | ||
667 | spin_unlock_irqrestore(&schp->lock, *flag); | ||
668 | |||
669 | /* deref */ | ||
670 | if (atomic_dec_and_test(&qhp->refcnt)) | ||
671 | wake_up(&qhp->wait); | ||
672 | |||
673 | spin_lock_irqsave(&qhp->lock, *flag); | ||
674 | } | ||
675 | |||
676 | static inline void flush_qp(struct iwch_qp *qhp, unsigned long *flag) | ||
677 | { | ||
678 | if (t3b_device(qhp->rhp)) | ||
679 | cxio_set_wq_in_error(&qhp->wq); | ||
680 | else | ||
681 | __flush_qp(qhp, flag); | ||
682 | } | ||
683 | |||
684 | |||
685 | /* | ||
686 | * Return non zero if at least one RECV was pre-posted. | ||
687 | */ | ||
688 | static inline int rqes_posted(struct iwch_qp *qhp) | ||
689 | { | ||
690 | return fw_riwrh_opcode((struct fw_riwrh *)qhp->wq.queue) == T3_WR_RCV; | ||
691 | } | ||
692 | |||
693 | static int rdma_init(struct iwch_dev *rhp, struct iwch_qp *qhp, | ||
694 | enum iwch_qp_attr_mask mask, | ||
695 | struct iwch_qp_attributes *attrs) | ||
696 | { | ||
697 | struct t3_rdma_init_attr init_attr; | ||
698 | int ret; | ||
699 | |||
700 | init_attr.tid = qhp->ep->hwtid; | ||
701 | init_attr.qpid = qhp->wq.qpid; | ||
702 | init_attr.pdid = qhp->attr.pd; | ||
703 | init_attr.scqid = qhp->attr.scq; | ||
704 | init_attr.rcqid = qhp->attr.rcq; | ||
705 | init_attr.rq_addr = qhp->wq.rq_addr; | ||
706 | init_attr.rq_size = 1 << qhp->wq.rq_size_log2; | ||
707 | init_attr.mpaattrs = uP_RI_MPA_IETF_ENABLE | | ||
708 | qhp->attr.mpa_attr.recv_marker_enabled | | ||
709 | (qhp->attr.mpa_attr.xmit_marker_enabled << 1) | | ||
710 | (qhp->attr.mpa_attr.crc_enabled << 2); | ||
711 | |||
712 | /* | ||
713 | * XXX - The IWCM doesn't quite handle getting these | ||
714 | * attrs set before going into RTS. For now, just turn | ||
715 | * them on always... | ||
716 | */ | ||
717 | #if 0 | ||
718 | init_attr.qpcaps = qhp->attr.enableRdmaRead | | ||
719 | (qhp->attr.enableRdmaWrite << 1) | | ||
720 | (qhp->attr.enableBind << 2) | | ||
721 | (qhp->attr.enable_stag0_fastreg << 3) | | ||
722 | (qhp->attr.enable_stag0_fastreg << 4); | ||
723 | #else | ||
724 | init_attr.qpcaps = 0x1f; | ||
725 | #endif | ||
726 | init_attr.tcp_emss = qhp->ep->emss; | ||
727 | init_attr.ord = qhp->attr.max_ord; | ||
728 | init_attr.ird = qhp->attr.max_ird; | ||
729 | init_attr.qp_dma_addr = qhp->wq.dma_addr; | ||
730 | init_attr.qp_dma_size = (1UL << qhp->wq.size_log2); | ||
731 | init_attr.flags = rqes_posted(qhp) ? RECVS_POSTED : 0; | ||
732 | PDBG("%s init_attr.rq_addr 0x%x init_attr.rq_size = %d " | ||
733 | "flags 0x%x qpcaps 0x%x\n", __FUNCTION__, | ||
734 | init_attr.rq_addr, init_attr.rq_size, | ||
735 | init_attr.flags, init_attr.qpcaps); | ||
736 | ret = cxio_rdma_init(&rhp->rdev, &init_attr); | ||
737 | PDBG("%s ret %d\n", __FUNCTION__, ret); | ||
738 | return ret; | ||
739 | } | ||
740 | |||
741 | int iwch_modify_qp(struct iwch_dev *rhp, struct iwch_qp *qhp, | ||
742 | enum iwch_qp_attr_mask mask, | ||
743 | struct iwch_qp_attributes *attrs, | ||
744 | int internal) | ||
745 | { | ||
746 | int ret = 0; | ||
747 | struct iwch_qp_attributes newattr = qhp->attr; | ||
748 | unsigned long flag; | ||
749 | int disconnect = 0; | ||
750 | int terminate = 0; | ||
751 | int abort = 0; | ||
752 | int free = 0; | ||
753 | struct iwch_ep *ep = NULL; | ||
754 | |||
755 | PDBG("%s qhp %p qpid 0x%x ep %p state %d -> %d\n", __FUNCTION__, | ||
756 | qhp, qhp->wq.qpid, qhp->ep, qhp->attr.state, | ||
757 | (mask & IWCH_QP_ATTR_NEXT_STATE) ? attrs->next_state : -1); | ||
758 | |||
759 | spin_lock_irqsave(&qhp->lock, flag); | ||
760 | |||
761 | /* Process attr changes if in IDLE */ | ||
762 | if (mask & IWCH_QP_ATTR_VALID_MODIFY) { | ||
763 | if (qhp->attr.state != IWCH_QP_STATE_IDLE) { | ||
764 | ret = -EIO; | ||
765 | goto out; | ||
766 | } | ||
767 | if (mask & IWCH_QP_ATTR_ENABLE_RDMA_READ) | ||
768 | newattr.enable_rdma_read = attrs->enable_rdma_read; | ||
769 | if (mask & IWCH_QP_ATTR_ENABLE_RDMA_WRITE) | ||
770 | newattr.enable_rdma_write = attrs->enable_rdma_write; | ||
771 | if (mask & IWCH_QP_ATTR_ENABLE_RDMA_BIND) | ||
772 | newattr.enable_bind = attrs->enable_bind; | ||
773 | if (mask & IWCH_QP_ATTR_MAX_ORD) { | ||
774 | if (attrs->max_ord > | ||
775 | rhp->attr.max_rdma_read_qp_depth) { | ||
776 | ret = -EINVAL; | ||
777 | goto out; | ||
778 | } | ||
779 | newattr.max_ord = attrs->max_ord; | ||
780 | } | ||
781 | if (mask & IWCH_QP_ATTR_MAX_IRD) { | ||
782 | if (attrs->max_ird > | ||
783 | rhp->attr.max_rdma_reads_per_qp) { | ||
784 | ret = -EINVAL; | ||
785 | goto out; | ||
786 | } | ||
787 | newattr.max_ird = attrs->max_ird; | ||
788 | } | ||
789 | qhp->attr = newattr; | ||
790 | } | ||
791 | |||
792 | if (!(mask & IWCH_QP_ATTR_NEXT_STATE)) | ||
793 | goto out; | ||
794 | if (qhp->attr.state == attrs->next_state) | ||
795 | goto out; | ||
796 | |||
797 | switch (qhp->attr.state) { | ||
798 | case IWCH_QP_STATE_IDLE: | ||
799 | switch (attrs->next_state) { | ||
800 | case IWCH_QP_STATE_RTS: | ||
801 | if (!(mask & IWCH_QP_ATTR_LLP_STREAM_HANDLE)) { | ||
802 | ret = -EINVAL; | ||
803 | goto out; | ||
804 | } | ||
805 | if (!(mask & IWCH_QP_ATTR_MPA_ATTR)) { | ||
806 | ret = -EINVAL; | ||
807 | goto out; | ||
808 | } | ||
809 | qhp->attr.mpa_attr = attrs->mpa_attr; | ||
810 | qhp->attr.llp_stream_handle = attrs->llp_stream_handle; | ||
811 | qhp->ep = qhp->attr.llp_stream_handle; | ||
812 | qhp->attr.state = IWCH_QP_STATE_RTS; | ||
813 | |||
814 | /* | ||
815 | * Ref the endpoint here and deref when we | ||
816 | * disassociate the endpoint from the QP. This | ||
817 | * happens in CLOSING->IDLE transition or *->ERROR | ||
818 | * transition. | ||
819 | */ | ||
820 | get_ep(&qhp->ep->com); | ||
821 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
822 | ret = rdma_init(rhp, qhp, mask, attrs); | ||
823 | spin_lock_irqsave(&qhp->lock, flag); | ||
824 | if (ret) | ||
825 | goto err; | ||
826 | break; | ||
827 | case IWCH_QP_STATE_ERROR: | ||
828 | qhp->attr.state = IWCH_QP_STATE_ERROR; | ||
829 | flush_qp(qhp, &flag); | ||
830 | break; | ||
831 | default: | ||
832 | ret = -EINVAL; | ||
833 | goto out; | ||
834 | } | ||
835 | break; | ||
836 | case IWCH_QP_STATE_RTS: | ||
837 | switch (attrs->next_state) { | ||
838 | case IWCH_QP_STATE_CLOSING: | ||
839 | BUG_ON(atomic_read(&qhp->ep->com.kref.refcount) < 2); | ||
840 | qhp->attr.state = IWCH_QP_STATE_CLOSING; | ||
841 | if (!internal) { | ||
842 | abort=0; | ||
843 | disconnect = 1; | ||
844 | ep = qhp->ep; | ||
845 | } | ||
846 | break; | ||
847 | case IWCH_QP_STATE_TERMINATE: | ||
848 | qhp->attr.state = IWCH_QP_STATE_TERMINATE; | ||
849 | if (!internal) | ||
850 | terminate = 1; | ||
851 | break; | ||
852 | case IWCH_QP_STATE_ERROR: | ||
853 | qhp->attr.state = IWCH_QP_STATE_ERROR; | ||
854 | if (!internal) { | ||
855 | abort=1; | ||
856 | disconnect = 1; | ||
857 | ep = qhp->ep; | ||
858 | } | ||
859 | goto err; | ||
860 | break; | ||
861 | default: | ||
862 | ret = -EINVAL; | ||
863 | goto out; | ||
864 | } | ||
865 | break; | ||
866 | case IWCH_QP_STATE_CLOSING: | ||
867 | if (!internal) { | ||
868 | ret = -EINVAL; | ||
869 | goto out; | ||
870 | } | ||
871 | switch (attrs->next_state) { | ||
872 | case IWCH_QP_STATE_IDLE: | ||
873 | qhp->attr.state = IWCH_QP_STATE_IDLE; | ||
874 | qhp->attr.llp_stream_handle = NULL; | ||
875 | put_ep(&qhp->ep->com); | ||
876 | qhp->ep = NULL; | ||
877 | wake_up(&qhp->wait); | ||
878 | break; | ||
879 | case IWCH_QP_STATE_ERROR: | ||
880 | goto err; | ||
881 | default: | ||
882 | ret = -EINVAL; | ||
883 | goto err; | ||
884 | } | ||
885 | break; | ||
886 | case IWCH_QP_STATE_ERROR: | ||
887 | if (attrs->next_state != IWCH_QP_STATE_IDLE) { | ||
888 | ret = -EINVAL; | ||
889 | goto out; | ||
890 | } | ||
891 | |||
892 | if (!Q_EMPTY(qhp->wq.sq_rptr, qhp->wq.sq_wptr) || | ||
893 | !Q_EMPTY(qhp->wq.rq_rptr, qhp->wq.rq_wptr)) { | ||
894 | ret = -EINVAL; | ||
895 | goto out; | ||
896 | } | ||
897 | qhp->attr.state = IWCH_QP_STATE_IDLE; | ||
898 | memset(&qhp->attr, 0, sizeof(qhp->attr)); | ||
899 | break; | ||
900 | case IWCH_QP_STATE_TERMINATE: | ||
901 | if (!internal) { | ||
902 | ret = -EINVAL; | ||
903 | goto out; | ||
904 | } | ||
905 | goto err; | ||
906 | break; | ||
907 | default: | ||
908 | printk(KERN_ERR "%s in a bad state %d\n", | ||
909 | __FUNCTION__, qhp->attr.state); | ||
910 | ret = -EINVAL; | ||
911 | goto err; | ||
912 | break; | ||
913 | } | ||
914 | goto out; | ||
915 | err: | ||
916 | PDBG("%s disassociating ep %p qpid 0x%x\n", __FUNCTION__, qhp->ep, | ||
917 | qhp->wq.qpid); | ||
918 | |||
919 | /* disassociate the LLP connection */ | ||
920 | qhp->attr.llp_stream_handle = NULL; | ||
921 | ep = qhp->ep; | ||
922 | qhp->ep = NULL; | ||
923 | qhp->attr.state = IWCH_QP_STATE_ERROR; | ||
924 | free=1; | ||
925 | wake_up(&qhp->wait); | ||
926 | BUG_ON(!ep); | ||
927 | flush_qp(qhp, &flag); | ||
928 | out: | ||
929 | spin_unlock_irqrestore(&qhp->lock, flag); | ||
930 | |||
931 | if (terminate) | ||
932 | iwch_post_terminate(qhp, NULL); | ||
933 | |||
934 | /* | ||
935 | * If disconnect is 1, then we need to initiate a disconnect | ||
936 | * on the EP. This can be a normal close (RTS->CLOSING) or | ||
937 | * an abnormal close (RTS/CLOSING->ERROR). | ||
938 | */ | ||
939 | if (disconnect) | ||
940 | iwch_ep_disconnect(ep, abort, GFP_KERNEL); | ||
941 | |||
942 | /* | ||
943 | * If free is 1, then we've disassociated the EP from the QP | ||
944 | * and we need to dereference the EP. | ||
945 | */ | ||
946 | if (free) | ||
947 | put_ep(&ep->com); | ||
948 | |||
949 | PDBG("%s exit state %d\n", __FUNCTION__, qhp->attr.state); | ||
950 | return ret; | ||
951 | } | ||
952 | |||
953 | static int quiesce_qp(struct iwch_qp *qhp) | ||
954 | { | ||
955 | spin_lock_irq(&qhp->lock); | ||
956 | iwch_quiesce_tid(qhp->ep); | ||
957 | qhp->flags |= QP_QUIESCED; | ||
958 | spin_unlock_irq(&qhp->lock); | ||
959 | return 0; | ||
960 | } | ||
961 | |||
962 | static int resume_qp(struct iwch_qp *qhp) | ||
963 | { | ||
964 | spin_lock_irq(&qhp->lock); | ||
965 | iwch_resume_tid(qhp->ep); | ||
966 | qhp->flags &= ~QP_QUIESCED; | ||
967 | spin_unlock_irq(&qhp->lock); | ||
968 | return 0; | ||
969 | } | ||
970 | |||
971 | int iwch_quiesce_qps(struct iwch_cq *chp) | ||
972 | { | ||
973 | int i; | ||
974 | struct iwch_qp *qhp; | ||
975 | |||
976 | for (i=0; i < T3_MAX_NUM_QP; i++) { | ||
977 | qhp = get_qhp(chp->rhp, i); | ||
978 | if (!qhp) | ||
979 | continue; | ||
980 | if ((qhp->attr.rcq == chp->cq.cqid) && !qp_quiesced(qhp)) { | ||
981 | quiesce_qp(qhp); | ||
982 | continue; | ||
983 | } | ||
984 | if ((qhp->attr.scq == chp->cq.cqid) && !qp_quiesced(qhp)) | ||
985 | quiesce_qp(qhp); | ||
986 | } | ||
987 | return 0; | ||
988 | } | ||
989 | |||
990 | int iwch_resume_qps(struct iwch_cq *chp) | ||
991 | { | ||
992 | int i; | ||
993 | struct iwch_qp *qhp; | ||
994 | |||
995 | for (i=0; i < T3_MAX_NUM_QP; i++) { | ||
996 | qhp = get_qhp(chp->rhp, i); | ||
997 | if (!qhp) | ||
998 | continue; | ||
999 | if ((qhp->attr.rcq == chp->cq.cqid) && qp_quiesced(qhp)) { | ||
1000 | resume_qp(qhp); | ||
1001 | continue; | ||
1002 | } | ||
1003 | if ((qhp->attr.scq == chp->cq.cqid) && qp_quiesced(qhp)) | ||
1004 | resume_qp(qhp); | ||
1005 | } | ||
1006 | return 0; | ||
1007 | } | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_user.h b/drivers/infiniband/hw/cxgb3/iwch_user.h new file mode 100644 index 000000000000..c4e7fbea8bbd --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/iwch_user.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #ifndef __IWCH_USER_H__ | ||
34 | #define __IWCH_USER_H__ | ||
35 | |||
36 | #define IWCH_UVERBS_ABI_VERSION 1 | ||
37 | |||
38 | /* | ||
39 | * Make sure that all structs defined in this file remain laid out so | ||
40 | * that they pack the same way on 32-bit and 64-bit architectures (to | ||
41 | * avoid incompatibility between 32-bit userspace and 64-bit kernels). | ||
42 | * In particular do not use pointer types -- pass pointers in __u64 | ||
43 | * instead. | ||
44 | */ | ||
45 | struct iwch_create_cq_req { | ||
46 | __u64 user_rptr_addr; | ||
47 | }; | ||
48 | |||
49 | struct iwch_create_cq_resp { | ||
50 | __u64 key; | ||
51 | __u32 cqid; | ||
52 | __u32 size_log2; | ||
53 | }; | ||
54 | |||
55 | struct iwch_create_qp_resp { | ||
56 | __u64 key; | ||
57 | __u64 db_key; | ||
58 | __u32 qpid; | ||
59 | __u32 size_log2; | ||
60 | __u32 sq_size_log2; | ||
61 | __u32 rq_size_log2; | ||
62 | }; | ||
63 | |||
64 | struct iwch_reg_user_mr_resp { | ||
65 | __u32 pbl_addr; | ||
66 | }; | ||
67 | #endif | ||
diff --git a/drivers/infiniband/hw/cxgb3/tcb.h b/drivers/infiniband/hw/cxgb3/tcb.h new file mode 100644 index 000000000000..c702dc199e18 --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/tcb.h | |||
@@ -0,0 +1,632 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2007 Chelsio, Inc. All rights reserved. | ||
3 | * | ||
4 | * This software is available to you under a choice of one of two | ||
5 | * licenses. You may choose to be licensed under the terms of the GNU | ||
6 | * General Public License (GPL) Version 2, available from the file | ||
7 | * COPYING in the main directory of this source tree, or the | ||
8 | * OpenIB.org BSD license below: | ||
9 | * | ||
10 | * Redistribution and use in source and binary forms, with or | ||
11 | * without modification, are permitted provided that the following | ||
12 | * conditions are met: | ||
13 | * | ||
14 | * - Redistributions of source code must retain the above | ||
15 | * copyright notice, this list of conditions and the following | ||
16 | * disclaimer. | ||
17 | * | ||
18 | * - Redistributions in binary form must reproduce the above | ||
19 | * copyright notice, this list of conditions and the following | ||
20 | * disclaimer in the documentation and/or other materials | ||
21 | * provided with the distribution. | ||
22 | * | ||
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
27 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
28 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
30 | * SOFTWARE. | ||
31 | */ | ||
32 | #ifndef _TCB_DEFS_H | ||
33 | #define _TCB_DEFS_H | ||
34 | |||
35 | #define W_TCB_T_STATE 0 | ||
36 | #define S_TCB_T_STATE 0 | ||
37 | #define M_TCB_T_STATE 0xfULL | ||
38 | #define V_TCB_T_STATE(x) ((x) << S_TCB_T_STATE) | ||
39 | |||
40 | #define W_TCB_TIMER 0 | ||
41 | #define S_TCB_TIMER 4 | ||
42 | #define M_TCB_TIMER 0x1ULL | ||
43 | #define V_TCB_TIMER(x) ((x) << S_TCB_TIMER) | ||
44 | |||
45 | #define W_TCB_DACK_TIMER 0 | ||
46 | #define S_TCB_DACK_TIMER 5 | ||
47 | #define M_TCB_DACK_TIMER 0x1ULL | ||
48 | #define V_TCB_DACK_TIMER(x) ((x) << S_TCB_DACK_TIMER) | ||
49 | |||
50 | #define W_TCB_DEL_FLAG 0 | ||
51 | #define S_TCB_DEL_FLAG 6 | ||
52 | #define M_TCB_DEL_FLAG 0x1ULL | ||
53 | #define V_TCB_DEL_FLAG(x) ((x) << S_TCB_DEL_FLAG) | ||
54 | |||
55 | #define W_TCB_L2T_IX 0 | ||
56 | #define S_TCB_L2T_IX 7 | ||
57 | #define M_TCB_L2T_IX 0x7ffULL | ||
58 | #define V_TCB_L2T_IX(x) ((x) << S_TCB_L2T_IX) | ||
59 | |||
60 | #define W_TCB_SMAC_SEL 0 | ||
61 | #define S_TCB_SMAC_SEL 18 | ||
62 | #define M_TCB_SMAC_SEL 0x3ULL | ||
63 | #define V_TCB_SMAC_SEL(x) ((x) << S_TCB_SMAC_SEL) | ||
64 | |||
65 | #define W_TCB_TOS 0 | ||
66 | #define S_TCB_TOS 20 | ||
67 | #define M_TCB_TOS 0x3fULL | ||
68 | #define V_TCB_TOS(x) ((x) << S_TCB_TOS) | ||
69 | |||
70 | #define W_TCB_MAX_RT 0 | ||
71 | #define S_TCB_MAX_RT 26 | ||
72 | #define M_TCB_MAX_RT 0xfULL | ||
73 | #define V_TCB_MAX_RT(x) ((x) << S_TCB_MAX_RT) | ||
74 | |||
75 | #define W_TCB_T_RXTSHIFT 0 | ||
76 | #define S_TCB_T_RXTSHIFT 30 | ||
77 | #define M_TCB_T_RXTSHIFT 0xfULL | ||
78 | #define V_TCB_T_RXTSHIFT(x) ((x) << S_TCB_T_RXTSHIFT) | ||
79 | |||
80 | #define W_TCB_T_DUPACKS 1 | ||
81 | #define S_TCB_T_DUPACKS 2 | ||
82 | #define M_TCB_T_DUPACKS 0xfULL | ||
83 | #define V_TCB_T_DUPACKS(x) ((x) << S_TCB_T_DUPACKS) | ||
84 | |||
85 | #define W_TCB_T_MAXSEG 1 | ||
86 | #define S_TCB_T_MAXSEG 6 | ||
87 | #define M_TCB_T_MAXSEG 0xfULL | ||
88 | #define V_TCB_T_MAXSEG(x) ((x) << S_TCB_T_MAXSEG) | ||
89 | |||
90 | #define W_TCB_T_FLAGS1 1 | ||
91 | #define S_TCB_T_FLAGS1 10 | ||
92 | #define M_TCB_T_FLAGS1 0xffffffffULL | ||
93 | #define V_TCB_T_FLAGS1(x) ((x) << S_TCB_T_FLAGS1) | ||
94 | |||
95 | #define W_TCB_T_MIGRATION 1 | ||
96 | #define S_TCB_T_MIGRATION 20 | ||
97 | #define M_TCB_T_MIGRATION 0x1ULL | ||
98 | #define V_TCB_T_MIGRATION(x) ((x) << S_TCB_T_MIGRATION) | ||
99 | |||
100 | #define W_TCB_T_FLAGS2 2 | ||
101 | #define S_TCB_T_FLAGS2 10 | ||
102 | #define M_TCB_T_FLAGS2 0x7fULL | ||
103 | #define V_TCB_T_FLAGS2(x) ((x) << S_TCB_T_FLAGS2) | ||
104 | |||
105 | #define W_TCB_SND_SCALE 2 | ||
106 | #define S_TCB_SND_SCALE 17 | ||
107 | #define M_TCB_SND_SCALE 0xfULL | ||
108 | #define V_TCB_SND_SCALE(x) ((x) << S_TCB_SND_SCALE) | ||
109 | |||
110 | #define W_TCB_RCV_SCALE 2 | ||
111 | #define S_TCB_RCV_SCALE 21 | ||
112 | #define M_TCB_RCV_SCALE 0xfULL | ||
113 | #define V_TCB_RCV_SCALE(x) ((x) << S_TCB_RCV_SCALE) | ||
114 | |||
115 | #define W_TCB_SND_UNA_RAW 2 | ||
116 | #define S_TCB_SND_UNA_RAW 25 | ||
117 | #define M_TCB_SND_UNA_RAW 0x7ffffffULL | ||
118 | #define V_TCB_SND_UNA_RAW(x) ((x) << S_TCB_SND_UNA_RAW) | ||
119 | |||
120 | #define W_TCB_SND_NXT_RAW 3 | ||
121 | #define S_TCB_SND_NXT_RAW 20 | ||
122 | #define M_TCB_SND_NXT_RAW 0x7ffffffULL | ||
123 | #define V_TCB_SND_NXT_RAW(x) ((x) << S_TCB_SND_NXT_RAW) | ||
124 | |||
125 | #define W_TCB_RCV_NXT 4 | ||
126 | #define S_TCB_RCV_NXT 15 | ||
127 | #define M_TCB_RCV_NXT 0xffffffffULL | ||
128 | #define V_TCB_RCV_NXT(x) ((x) << S_TCB_RCV_NXT) | ||
129 | |||
130 | #define W_TCB_RCV_ADV 5 | ||
131 | #define S_TCB_RCV_ADV 15 | ||
132 | #define M_TCB_RCV_ADV 0xffffULL | ||
133 | #define V_TCB_RCV_ADV(x) ((x) << S_TCB_RCV_ADV) | ||
134 | |||
135 | #define W_TCB_SND_MAX_RAW 5 | ||
136 | #define S_TCB_SND_MAX_RAW 31 | ||
137 | #define M_TCB_SND_MAX_RAW 0x7ffffffULL | ||
138 | #define V_TCB_SND_MAX_RAW(x) ((x) << S_TCB_SND_MAX_RAW) | ||
139 | |||
140 | #define W_TCB_SND_CWND 6 | ||
141 | #define S_TCB_SND_CWND 26 | ||
142 | #define M_TCB_SND_CWND 0x7ffffffULL | ||
143 | #define V_TCB_SND_CWND(x) ((x) << S_TCB_SND_CWND) | ||
144 | |||
145 | #define W_TCB_SND_SSTHRESH 7 | ||
146 | #define S_TCB_SND_SSTHRESH 21 | ||
147 | #define M_TCB_SND_SSTHRESH 0x7ffffffULL | ||
148 | #define V_TCB_SND_SSTHRESH(x) ((x) << S_TCB_SND_SSTHRESH) | ||
149 | |||
150 | #define W_TCB_T_RTT_TS_RECENT_AGE 8 | ||
151 | #define S_TCB_T_RTT_TS_RECENT_AGE 16 | ||
152 | #define M_TCB_T_RTT_TS_RECENT_AGE 0xffffffffULL | ||
153 | #define V_TCB_T_RTT_TS_RECENT_AGE(x) ((x) << S_TCB_T_RTT_TS_RECENT_AGE) | ||
154 | |||
155 | #define W_TCB_T_RTSEQ_RECENT 9 | ||
156 | #define S_TCB_T_RTSEQ_RECENT 16 | ||
157 | #define M_TCB_T_RTSEQ_RECENT 0xffffffffULL | ||
158 | #define V_TCB_T_RTSEQ_RECENT(x) ((x) << S_TCB_T_RTSEQ_RECENT) | ||
159 | |||
160 | #define W_TCB_T_SRTT 10 | ||
161 | #define S_TCB_T_SRTT 16 | ||
162 | #define M_TCB_T_SRTT 0xffffULL | ||
163 | #define V_TCB_T_SRTT(x) ((x) << S_TCB_T_SRTT) | ||
164 | |||
165 | #define W_TCB_T_RTTVAR 11 | ||
166 | #define S_TCB_T_RTTVAR 0 | ||
167 | #define M_TCB_T_RTTVAR 0xffffULL | ||
168 | #define V_TCB_T_RTTVAR(x) ((x) << S_TCB_T_RTTVAR) | ||
169 | |||
170 | #define W_TCB_TS_LAST_ACK_SENT_RAW 11 | ||
171 | #define S_TCB_TS_LAST_ACK_SENT_RAW 16 | ||
172 | #define M_TCB_TS_LAST_ACK_SENT_RAW 0x7ffffffULL | ||
173 | #define V_TCB_TS_LAST_ACK_SENT_RAW(x) ((x) << S_TCB_TS_LAST_ACK_SENT_RAW) | ||
174 | |||
175 | #define W_TCB_DIP 12 | ||
176 | #define S_TCB_DIP 11 | ||
177 | #define M_TCB_DIP 0xffffffffULL | ||
178 | #define V_TCB_DIP(x) ((x) << S_TCB_DIP) | ||
179 | |||
180 | #define W_TCB_SIP 13 | ||
181 | #define S_TCB_SIP 11 | ||
182 | #define M_TCB_SIP 0xffffffffULL | ||
183 | #define V_TCB_SIP(x) ((x) << S_TCB_SIP) | ||
184 | |||
185 | #define W_TCB_DP 14 | ||
186 | #define S_TCB_DP 11 | ||
187 | #define M_TCB_DP 0xffffULL | ||
188 | #define V_TCB_DP(x) ((x) << S_TCB_DP) | ||
189 | |||
190 | #define W_TCB_SP 14 | ||
191 | #define S_TCB_SP 27 | ||
192 | #define M_TCB_SP 0xffffULL | ||
193 | #define V_TCB_SP(x) ((x) << S_TCB_SP) | ||
194 | |||
195 | #define W_TCB_TIMESTAMP 15 | ||
196 | #define S_TCB_TIMESTAMP 11 | ||
197 | #define M_TCB_TIMESTAMP 0xffffffffULL | ||
198 | #define V_TCB_TIMESTAMP(x) ((x) << S_TCB_TIMESTAMP) | ||
199 | |||
200 | #define W_TCB_TIMESTAMP_OFFSET 16 | ||
201 | #define S_TCB_TIMESTAMP_OFFSET 11 | ||
202 | #define M_TCB_TIMESTAMP_OFFSET 0xfULL | ||
203 | #define V_TCB_TIMESTAMP_OFFSET(x) ((x) << S_TCB_TIMESTAMP_OFFSET) | ||
204 | |||
205 | #define W_TCB_TX_MAX 16 | ||
206 | #define S_TCB_TX_MAX 15 | ||
207 | #define M_TCB_TX_MAX 0xffffffffULL | ||
208 | #define V_TCB_TX_MAX(x) ((x) << S_TCB_TX_MAX) | ||
209 | |||
210 | #define W_TCB_TX_HDR_PTR_RAW 17 | ||
211 | #define S_TCB_TX_HDR_PTR_RAW 15 | ||
212 | #define M_TCB_TX_HDR_PTR_RAW 0x1ffffULL | ||
213 | #define V_TCB_TX_HDR_PTR_RAW(x) ((x) << S_TCB_TX_HDR_PTR_RAW) | ||
214 | |||
215 | #define W_TCB_TX_LAST_PTR_RAW 18 | ||
216 | #define S_TCB_TX_LAST_PTR_RAW 0 | ||
217 | #define M_TCB_TX_LAST_PTR_RAW 0x1ffffULL | ||
218 | #define V_TCB_TX_LAST_PTR_RAW(x) ((x) << S_TCB_TX_LAST_PTR_RAW) | ||
219 | |||
220 | #define W_TCB_TX_COMPACT 18 | ||
221 | #define S_TCB_TX_COMPACT 17 | ||
222 | #define M_TCB_TX_COMPACT 0x1ULL | ||
223 | #define V_TCB_TX_COMPACT(x) ((x) << S_TCB_TX_COMPACT) | ||
224 | |||
225 | #define W_TCB_RX_COMPACT 18 | ||
226 | #define S_TCB_RX_COMPACT 18 | ||
227 | #define M_TCB_RX_COMPACT 0x1ULL | ||
228 | #define V_TCB_RX_COMPACT(x) ((x) << S_TCB_RX_COMPACT) | ||
229 | |||
230 | #define W_TCB_RCV_WND 18 | ||
231 | #define S_TCB_RCV_WND 19 | ||
232 | #define M_TCB_RCV_WND 0x7ffffffULL | ||
233 | #define V_TCB_RCV_WND(x) ((x) << S_TCB_RCV_WND) | ||
234 | |||
235 | #define W_TCB_RX_HDR_OFFSET 19 | ||
236 | #define S_TCB_RX_HDR_OFFSET 14 | ||
237 | #define M_TCB_RX_HDR_OFFSET 0x7ffffffULL | ||
238 | #define V_TCB_RX_HDR_OFFSET(x) ((x) << S_TCB_RX_HDR_OFFSET) | ||
239 | |||
240 | #define W_TCB_RX_FRAG0_START_IDX_RAW 20 | ||
241 | #define S_TCB_RX_FRAG0_START_IDX_RAW 9 | ||
242 | #define M_TCB_RX_FRAG0_START_IDX_RAW 0x7ffffffULL | ||
243 | #define V_TCB_RX_FRAG0_START_IDX_RAW(x) ((x) << S_TCB_RX_FRAG0_START_IDX_RAW) | ||
244 | |||
245 | #define W_TCB_RX_FRAG1_START_IDX_OFFSET 21 | ||
246 | #define S_TCB_RX_FRAG1_START_IDX_OFFSET 4 | ||
247 | #define M_TCB_RX_FRAG1_START_IDX_OFFSET 0x7ffffffULL | ||
248 | #define V_TCB_RX_FRAG1_START_IDX_OFFSET(x) ((x) << S_TCB_RX_FRAG1_START_IDX_OFFSET) | ||
249 | |||
250 | #define W_TCB_RX_FRAG0_LEN 21 | ||
251 | #define S_TCB_RX_FRAG0_LEN 31 | ||
252 | #define M_TCB_RX_FRAG0_LEN 0x7ffffffULL | ||
253 | #define V_TCB_RX_FRAG0_LEN(x) ((x) << S_TCB_RX_FRAG0_LEN) | ||
254 | |||
255 | #define W_TCB_RX_FRAG1_LEN 22 | ||
256 | #define S_TCB_RX_FRAG1_LEN 26 | ||
257 | #define M_TCB_RX_FRAG1_LEN 0x7ffffffULL | ||
258 | #define V_TCB_RX_FRAG1_LEN(x) ((x) << S_TCB_RX_FRAG1_LEN) | ||
259 | |||
260 | #define W_TCB_NEWRENO_RECOVER 23 | ||
261 | #define S_TCB_NEWRENO_RECOVER 21 | ||
262 | #define M_TCB_NEWRENO_RECOVER 0x7ffffffULL | ||
263 | #define V_TCB_NEWRENO_RECOVER(x) ((x) << S_TCB_NEWRENO_RECOVER) | ||
264 | |||
265 | #define W_TCB_PDU_HAVE_LEN 24 | ||
266 | #define S_TCB_PDU_HAVE_LEN 16 | ||
267 | #define M_TCB_PDU_HAVE_LEN 0x1ULL | ||
268 | #define V_TCB_PDU_HAVE_LEN(x) ((x) << S_TCB_PDU_HAVE_LEN) | ||
269 | |||
270 | #define W_TCB_PDU_LEN 24 | ||
271 | #define S_TCB_PDU_LEN 17 | ||
272 | #define M_TCB_PDU_LEN 0xffffULL | ||
273 | #define V_TCB_PDU_LEN(x) ((x) << S_TCB_PDU_LEN) | ||
274 | |||
275 | #define W_TCB_RX_QUIESCE 25 | ||
276 | #define S_TCB_RX_QUIESCE 1 | ||
277 | #define M_TCB_RX_QUIESCE 0x1ULL | ||
278 | #define V_TCB_RX_QUIESCE(x) ((x) << S_TCB_RX_QUIESCE) | ||
279 | |||
280 | #define W_TCB_RX_PTR_RAW 25 | ||
281 | #define S_TCB_RX_PTR_RAW 2 | ||
282 | #define M_TCB_RX_PTR_RAW 0x1ffffULL | ||
283 | #define V_TCB_RX_PTR_RAW(x) ((x) << S_TCB_RX_PTR_RAW) | ||
284 | |||
285 | #define W_TCB_CPU_NO 25 | ||
286 | #define S_TCB_CPU_NO 19 | ||
287 | #define M_TCB_CPU_NO 0x7fULL | ||
288 | #define V_TCB_CPU_NO(x) ((x) << S_TCB_CPU_NO) | ||
289 | |||
290 | #define W_TCB_ULP_TYPE 25 | ||
291 | #define S_TCB_ULP_TYPE 26 | ||
292 | #define M_TCB_ULP_TYPE 0xfULL | ||
293 | #define V_TCB_ULP_TYPE(x) ((x) << S_TCB_ULP_TYPE) | ||
294 | |||
295 | #define W_TCB_RX_FRAG1_PTR_RAW 25 | ||
296 | #define S_TCB_RX_FRAG1_PTR_RAW 30 | ||
297 | #define M_TCB_RX_FRAG1_PTR_RAW 0x1ffffULL | ||
298 | #define V_TCB_RX_FRAG1_PTR_RAW(x) ((x) << S_TCB_RX_FRAG1_PTR_RAW) | ||
299 | |||
300 | #define W_TCB_RX_FRAG2_START_IDX_OFFSET_RAW 26 | ||
301 | #define S_TCB_RX_FRAG2_START_IDX_OFFSET_RAW 15 | ||
302 | #define M_TCB_RX_FRAG2_START_IDX_OFFSET_RAW 0x7ffffffULL | ||
303 | #define V_TCB_RX_FRAG2_START_IDX_OFFSET_RAW(x) ((x) << S_TCB_RX_FRAG2_START_IDX_OFFSET_RAW) | ||
304 | |||
305 | #define W_TCB_RX_FRAG2_PTR_RAW 27 | ||
306 | #define S_TCB_RX_FRAG2_PTR_RAW 10 | ||
307 | #define M_TCB_RX_FRAG2_PTR_RAW 0x1ffffULL | ||
308 | #define V_TCB_RX_FRAG2_PTR_RAW(x) ((x) << S_TCB_RX_FRAG2_PTR_RAW) | ||
309 | |||
310 | #define W_TCB_RX_FRAG2_LEN_RAW 27 | ||
311 | #define S_TCB_RX_FRAG2_LEN_RAW 27 | ||
312 | #define M_TCB_RX_FRAG2_LEN_RAW 0x7ffffffULL | ||
313 | #define V_TCB_RX_FRAG2_LEN_RAW(x) ((x) << S_TCB_RX_FRAG2_LEN_RAW) | ||
314 | |||
315 | #define W_TCB_RX_FRAG3_PTR_RAW 28 | ||
316 | #define S_TCB_RX_FRAG3_PTR_RAW 22 | ||
317 | #define M_TCB_RX_FRAG3_PTR_RAW 0x1ffffULL | ||
318 | #define V_TCB_RX_FRAG3_PTR_RAW(x) ((x) << S_TCB_RX_FRAG3_PTR_RAW) | ||
319 | |||
320 | #define W_TCB_RX_FRAG3_LEN_RAW 29 | ||
321 | #define S_TCB_RX_FRAG3_LEN_RAW 7 | ||
322 | #define M_TCB_RX_FRAG3_LEN_RAW 0x7ffffffULL | ||
323 | #define V_TCB_RX_FRAG3_LEN_RAW(x) ((x) << S_TCB_RX_FRAG3_LEN_RAW) | ||
324 | |||
325 | #define W_TCB_RX_FRAG3_START_IDX_OFFSET_RAW 30 | ||
326 | #define S_TCB_RX_FRAG3_START_IDX_OFFSET_RAW 2 | ||
327 | #define M_TCB_RX_FRAG3_START_IDX_OFFSET_RAW 0x7ffffffULL | ||
328 | #define V_TCB_RX_FRAG3_START_IDX_OFFSET_RAW(x) ((x) << S_TCB_RX_FRAG3_START_IDX_OFFSET_RAW) | ||
329 | |||
330 | #define W_TCB_PDU_HDR_LEN 30 | ||
331 | #define S_TCB_PDU_HDR_LEN 29 | ||
332 | #define M_TCB_PDU_HDR_LEN 0xffULL | ||
333 | #define V_TCB_PDU_HDR_LEN(x) ((x) << S_TCB_PDU_HDR_LEN) | ||
334 | |||
335 | #define W_TCB_SLUSH1 31 | ||
336 | #define S_TCB_SLUSH1 5 | ||
337 | #define M_TCB_SLUSH1 0x7ffffULL | ||
338 | #define V_TCB_SLUSH1(x) ((x) << S_TCB_SLUSH1) | ||
339 | |||
340 | #define W_TCB_ULP_RAW 31 | ||
341 | #define S_TCB_ULP_RAW 24 | ||
342 | #define M_TCB_ULP_RAW 0xffULL | ||
343 | #define V_TCB_ULP_RAW(x) ((x) << S_TCB_ULP_RAW) | ||
344 | |||
345 | #define W_TCB_DDP_RDMAP_VERSION 25 | ||
346 | #define S_TCB_DDP_RDMAP_VERSION 30 | ||
347 | #define M_TCB_DDP_RDMAP_VERSION 0x1ULL | ||
348 | #define V_TCB_DDP_RDMAP_VERSION(x) ((x) << S_TCB_DDP_RDMAP_VERSION) | ||
349 | |||
350 | #define W_TCB_MARKER_ENABLE_RX 25 | ||
351 | #define S_TCB_MARKER_ENABLE_RX 31 | ||
352 | #define M_TCB_MARKER_ENABLE_RX 0x1ULL | ||
353 | #define V_TCB_MARKER_ENABLE_RX(x) ((x) << S_TCB_MARKER_ENABLE_RX) | ||
354 | |||
355 | #define W_TCB_MARKER_ENABLE_TX 26 | ||
356 | #define S_TCB_MARKER_ENABLE_TX 0 | ||
357 | #define M_TCB_MARKER_ENABLE_TX 0x1ULL | ||
358 | #define V_TCB_MARKER_ENABLE_TX(x) ((x) << S_TCB_MARKER_ENABLE_TX) | ||
359 | |||
360 | #define W_TCB_CRC_ENABLE 26 | ||
361 | #define S_TCB_CRC_ENABLE 1 | ||
362 | #define M_TCB_CRC_ENABLE 0x1ULL | ||
363 | #define V_TCB_CRC_ENABLE(x) ((x) << S_TCB_CRC_ENABLE) | ||
364 | |||
365 | #define W_TCB_IRS_ULP 26 | ||
366 | #define S_TCB_IRS_ULP 2 | ||
367 | #define M_TCB_IRS_ULP 0x1ffULL | ||
368 | #define V_TCB_IRS_ULP(x) ((x) << S_TCB_IRS_ULP) | ||
369 | |||
370 | #define W_TCB_ISS_ULP 26 | ||
371 | #define S_TCB_ISS_ULP 11 | ||
372 | #define M_TCB_ISS_ULP 0x1ffULL | ||
373 | #define V_TCB_ISS_ULP(x) ((x) << S_TCB_ISS_ULP) | ||
374 | |||
375 | #define W_TCB_TX_PDU_LEN 26 | ||
376 | #define S_TCB_TX_PDU_LEN 20 | ||
377 | #define M_TCB_TX_PDU_LEN 0x3fffULL | ||
378 | #define V_TCB_TX_PDU_LEN(x) ((x) << S_TCB_TX_PDU_LEN) | ||
379 | |||
380 | #define W_TCB_TX_PDU_OUT 27 | ||
381 | #define S_TCB_TX_PDU_OUT 2 | ||
382 | #define M_TCB_TX_PDU_OUT 0x1ULL | ||
383 | #define V_TCB_TX_PDU_OUT(x) ((x) << S_TCB_TX_PDU_OUT) | ||
384 | |||
385 | #define W_TCB_CQ_IDX_SQ 27 | ||
386 | #define S_TCB_CQ_IDX_SQ 3 | ||
387 | #define M_TCB_CQ_IDX_SQ 0xffffULL | ||
388 | #define V_TCB_CQ_IDX_SQ(x) ((x) << S_TCB_CQ_IDX_SQ) | ||
389 | |||
390 | #define W_TCB_CQ_IDX_RQ 27 | ||
391 | #define S_TCB_CQ_IDX_RQ 19 | ||
392 | #define M_TCB_CQ_IDX_RQ 0xffffULL | ||
393 | #define V_TCB_CQ_IDX_RQ(x) ((x) << S_TCB_CQ_IDX_RQ) | ||
394 | |||
395 | #define W_TCB_QP_ID 28 | ||
396 | #define S_TCB_QP_ID 3 | ||
397 | #define M_TCB_QP_ID 0xffffULL | ||
398 | #define V_TCB_QP_ID(x) ((x) << S_TCB_QP_ID) | ||
399 | |||
400 | #define W_TCB_PD_ID 28 | ||
401 | #define S_TCB_PD_ID 19 | ||
402 | #define M_TCB_PD_ID 0xffffULL | ||
403 | #define V_TCB_PD_ID(x) ((x) << S_TCB_PD_ID) | ||
404 | |||
405 | #define W_TCB_STAG 29 | ||
406 | #define S_TCB_STAG 3 | ||
407 | #define M_TCB_STAG 0xffffffffULL | ||
408 | #define V_TCB_STAG(x) ((x) << S_TCB_STAG) | ||
409 | |||
410 | #define W_TCB_RQ_START 30 | ||
411 | #define S_TCB_RQ_START 3 | ||
412 | #define M_TCB_RQ_START 0x3ffffffULL | ||
413 | #define V_TCB_RQ_START(x) ((x) << S_TCB_RQ_START) | ||
414 | |||
415 | #define W_TCB_RQ_MSN 30 | ||
416 | #define S_TCB_RQ_MSN 29 | ||
417 | #define M_TCB_RQ_MSN 0x3ffULL | ||
418 | #define V_TCB_RQ_MSN(x) ((x) << S_TCB_RQ_MSN) | ||
419 | |||
420 | #define W_TCB_RQ_MAX_OFFSET 31 | ||
421 | #define S_TCB_RQ_MAX_OFFSET 7 | ||
422 | #define M_TCB_RQ_MAX_OFFSET 0xfULL | ||
423 | #define V_TCB_RQ_MAX_OFFSET(x) ((x) << S_TCB_RQ_MAX_OFFSET) | ||
424 | |||
425 | #define W_TCB_RQ_WRITE_PTR 31 | ||
426 | #define S_TCB_RQ_WRITE_PTR 11 | ||
427 | #define M_TCB_RQ_WRITE_PTR 0x3ffULL | ||
428 | #define V_TCB_RQ_WRITE_PTR(x) ((x) << S_TCB_RQ_WRITE_PTR) | ||
429 | |||
430 | #define W_TCB_INB_WRITE_PERM 31 | ||
431 | #define S_TCB_INB_WRITE_PERM 21 | ||
432 | #define M_TCB_INB_WRITE_PERM 0x1ULL | ||
433 | #define V_TCB_INB_WRITE_PERM(x) ((x) << S_TCB_INB_WRITE_PERM) | ||
434 | |||
435 | #define W_TCB_INB_READ_PERM 31 | ||
436 | #define S_TCB_INB_READ_PERM 22 | ||
437 | #define M_TCB_INB_READ_PERM 0x1ULL | ||
438 | #define V_TCB_INB_READ_PERM(x) ((x) << S_TCB_INB_READ_PERM) | ||
439 | |||
440 | #define W_TCB_ORD_L_BIT_VLD 31 | ||
441 | #define S_TCB_ORD_L_BIT_VLD 23 | ||
442 | #define M_TCB_ORD_L_BIT_VLD 0x1ULL | ||
443 | #define V_TCB_ORD_L_BIT_VLD(x) ((x) << S_TCB_ORD_L_BIT_VLD) | ||
444 | |||
445 | #define W_TCB_RDMAP_OPCODE 31 | ||
446 | #define S_TCB_RDMAP_OPCODE 24 | ||
447 | #define M_TCB_RDMAP_OPCODE 0xfULL | ||
448 | #define V_TCB_RDMAP_OPCODE(x) ((x) << S_TCB_RDMAP_OPCODE) | ||
449 | |||
450 | #define W_TCB_TX_FLUSH 31 | ||
451 | #define S_TCB_TX_FLUSH 28 | ||
452 | #define M_TCB_TX_FLUSH 0x1ULL | ||
453 | #define V_TCB_TX_FLUSH(x) ((x) << S_TCB_TX_FLUSH) | ||
454 | |||
455 | #define W_TCB_TX_OOS_RXMT 31 | ||
456 | #define S_TCB_TX_OOS_RXMT 29 | ||
457 | #define M_TCB_TX_OOS_RXMT 0x1ULL | ||
458 | #define V_TCB_TX_OOS_RXMT(x) ((x) << S_TCB_TX_OOS_RXMT) | ||
459 | |||
460 | #define W_TCB_TX_OOS_TXMT 31 | ||
461 | #define S_TCB_TX_OOS_TXMT 30 | ||
462 | #define M_TCB_TX_OOS_TXMT 0x1ULL | ||
463 | #define V_TCB_TX_OOS_TXMT(x) ((x) << S_TCB_TX_OOS_TXMT) | ||
464 | |||
465 | #define W_TCB_SLUSH_AUX2 31 | ||
466 | #define S_TCB_SLUSH_AUX2 31 | ||
467 | #define M_TCB_SLUSH_AUX2 0x1ULL | ||
468 | #define V_TCB_SLUSH_AUX2(x) ((x) << S_TCB_SLUSH_AUX2) | ||
469 | |||
470 | #define W_TCB_RX_FRAG1_PTR_RAW2 25 | ||
471 | #define S_TCB_RX_FRAG1_PTR_RAW2 30 | ||
472 | #define M_TCB_RX_FRAG1_PTR_RAW2 0x1ffffULL | ||
473 | #define V_TCB_RX_FRAG1_PTR_RAW2(x) ((x) << S_TCB_RX_FRAG1_PTR_RAW2) | ||
474 | |||
475 | #define W_TCB_RX_DDP_FLAGS 26 | ||
476 | #define S_TCB_RX_DDP_FLAGS 15 | ||
477 | #define M_TCB_RX_DDP_FLAGS 0x3ffULL | ||
478 | #define V_TCB_RX_DDP_FLAGS(x) ((x) << S_TCB_RX_DDP_FLAGS) | ||
479 | |||
480 | #define W_TCB_SLUSH_AUX3 26 | ||
481 | #define S_TCB_SLUSH_AUX3 31 | ||
482 | #define M_TCB_SLUSH_AUX3 0x1ffULL | ||
483 | #define V_TCB_SLUSH_AUX3(x) ((x) << S_TCB_SLUSH_AUX3) | ||
484 | |||
485 | #define W_TCB_RX_DDP_BUF0_OFFSET 27 | ||
486 | #define S_TCB_RX_DDP_BUF0_OFFSET 8 | ||
487 | #define M_TCB_RX_DDP_BUF0_OFFSET 0x3fffffULL | ||
488 | #define V_TCB_RX_DDP_BUF0_OFFSET(x) ((x) << S_TCB_RX_DDP_BUF0_OFFSET) | ||
489 | |||
490 | #define W_TCB_RX_DDP_BUF0_LEN 27 | ||
491 | #define S_TCB_RX_DDP_BUF0_LEN 30 | ||
492 | #define M_TCB_RX_DDP_BUF0_LEN 0x3fffffULL | ||
493 | #define V_TCB_RX_DDP_BUF0_LEN(x) ((x) << S_TCB_RX_DDP_BUF0_LEN) | ||
494 | |||
495 | #define W_TCB_RX_DDP_BUF1_OFFSET 28 | ||
496 | #define S_TCB_RX_DDP_BUF1_OFFSET 20 | ||
497 | #define M_TCB_RX_DDP_BUF1_OFFSET 0x3fffffULL | ||
498 | #define V_TCB_RX_DDP_BUF1_OFFSET(x) ((x) << S_TCB_RX_DDP_BUF1_OFFSET) | ||
499 | |||
500 | #define W_TCB_RX_DDP_BUF1_LEN 29 | ||
501 | #define S_TCB_RX_DDP_BUF1_LEN 10 | ||
502 | #define M_TCB_RX_DDP_BUF1_LEN 0x3fffffULL | ||
503 | #define V_TCB_RX_DDP_BUF1_LEN(x) ((x) << S_TCB_RX_DDP_BUF1_LEN) | ||
504 | |||
505 | #define W_TCB_RX_DDP_BUF0_TAG 30 | ||
506 | #define S_TCB_RX_DDP_BUF0_TAG 0 | ||
507 | #define M_TCB_RX_DDP_BUF0_TAG 0xffffffffULL | ||
508 | #define V_TCB_RX_DDP_BUF0_TAG(x) ((x) << S_TCB_RX_DDP_BUF0_TAG) | ||
509 | |||
510 | #define W_TCB_RX_DDP_BUF1_TAG 31 | ||
511 | #define S_TCB_RX_DDP_BUF1_TAG 0 | ||
512 | #define M_TCB_RX_DDP_BUF1_TAG 0xffffffffULL | ||
513 | #define V_TCB_RX_DDP_BUF1_TAG(x) ((x) << S_TCB_RX_DDP_BUF1_TAG) | ||
514 | |||
515 | #define S_TF_DACK 10 | ||
516 | #define V_TF_DACK(x) ((x) << S_TF_DACK) | ||
517 | |||
518 | #define S_TF_NAGLE 11 | ||
519 | #define V_TF_NAGLE(x) ((x) << S_TF_NAGLE) | ||
520 | |||
521 | #define S_TF_RECV_SCALE 12 | ||
522 | #define V_TF_RECV_SCALE(x) ((x) << S_TF_RECV_SCALE) | ||
523 | |||
524 | #define S_TF_RECV_TSTMP 13 | ||
525 | #define V_TF_RECV_TSTMP(x) ((x) << S_TF_RECV_TSTMP) | ||
526 | |||
527 | #define S_TF_RECV_SACK 14 | ||
528 | #define V_TF_RECV_SACK(x) ((x) << S_TF_RECV_SACK) | ||
529 | |||
530 | #define S_TF_TURBO 15 | ||
531 | #define V_TF_TURBO(x) ((x) << S_TF_TURBO) | ||
532 | |||
533 | #define S_TF_KEEPALIVE 16 | ||
534 | #define V_TF_KEEPALIVE(x) ((x) << S_TF_KEEPALIVE) | ||
535 | |||
536 | #define S_TF_TCAM_BYPASS 17 | ||
537 | #define V_TF_TCAM_BYPASS(x) ((x) << S_TF_TCAM_BYPASS) | ||
538 | |||
539 | #define S_TF_CORE_FIN 18 | ||
540 | #define V_TF_CORE_FIN(x) ((x) << S_TF_CORE_FIN) | ||
541 | |||
542 | #define S_TF_CORE_MORE 19 | ||
543 | #define V_TF_CORE_MORE(x) ((x) << S_TF_CORE_MORE) | ||
544 | |||
545 | #define S_TF_MIGRATING 20 | ||
546 | #define V_TF_MIGRATING(x) ((x) << S_TF_MIGRATING) | ||
547 | |||
548 | #define S_TF_ACTIVE_OPEN 21 | ||
549 | #define V_TF_ACTIVE_OPEN(x) ((x) << S_TF_ACTIVE_OPEN) | ||
550 | |||
551 | #define S_TF_ASK_MODE 22 | ||
552 | #define V_TF_ASK_MODE(x) ((x) << S_TF_ASK_MODE) | ||
553 | |||
554 | #define S_TF_NON_OFFLOAD 23 | ||
555 | #define V_TF_NON_OFFLOAD(x) ((x) << S_TF_NON_OFFLOAD) | ||
556 | |||
557 | #define S_TF_MOD_SCHD 24 | ||
558 | #define V_TF_MOD_SCHD(x) ((x) << S_TF_MOD_SCHD) | ||
559 | |||
560 | #define S_TF_MOD_SCHD_REASON0 25 | ||
561 | #define V_TF_MOD_SCHD_REASON0(x) ((x) << S_TF_MOD_SCHD_REASON0) | ||
562 | |||
563 | #define S_TF_MOD_SCHD_REASON1 26 | ||
564 | #define V_TF_MOD_SCHD_REASON1(x) ((x) << S_TF_MOD_SCHD_REASON1) | ||
565 | |||
566 | #define S_TF_MOD_SCHD_RX 27 | ||
567 | #define V_TF_MOD_SCHD_RX(x) ((x) << S_TF_MOD_SCHD_RX) | ||
568 | |||
569 | #define S_TF_CORE_PUSH 28 | ||
570 | #define V_TF_CORE_PUSH(x) ((x) << S_TF_CORE_PUSH) | ||
571 | |||
572 | #define S_TF_RCV_COALESCE_ENABLE 29 | ||
573 | #define V_TF_RCV_COALESCE_ENABLE(x) ((x) << S_TF_RCV_COALESCE_ENABLE) | ||
574 | |||
575 | #define S_TF_RCV_COALESCE_PUSH 30 | ||
576 | #define V_TF_RCV_COALESCE_PUSH(x) ((x) << S_TF_RCV_COALESCE_PUSH) | ||
577 | |||
578 | #define S_TF_RCV_COALESCE_LAST_PSH 31 | ||
579 | #define V_TF_RCV_COALESCE_LAST_PSH(x) ((x) << S_TF_RCV_COALESCE_LAST_PSH) | ||
580 | |||
581 | #define S_TF_RCV_COALESCE_HEARTBEAT 32 | ||
582 | #define V_TF_RCV_COALESCE_HEARTBEAT(x) ((x) << S_TF_RCV_COALESCE_HEARTBEAT) | ||
583 | |||
584 | #define S_TF_HALF_CLOSE 33 | ||
585 | #define V_TF_HALF_CLOSE(x) ((x) << S_TF_HALF_CLOSE) | ||
586 | |||
587 | #define S_TF_DACK_MSS 34 | ||
588 | #define V_TF_DACK_MSS(x) ((x) << S_TF_DACK_MSS) | ||
589 | |||
590 | #define S_TF_CCTRL_SEL0 35 | ||
591 | #define V_TF_CCTRL_SEL0(x) ((x) << S_TF_CCTRL_SEL0) | ||
592 | |||
593 | #define S_TF_CCTRL_SEL1 36 | ||
594 | #define V_TF_CCTRL_SEL1(x) ((x) << S_TF_CCTRL_SEL1) | ||
595 | |||
596 | #define S_TF_TCP_NEWRENO_FAST_RECOVERY 37 | ||
597 | #define V_TF_TCP_NEWRENO_FAST_RECOVERY(x) ((x) << S_TF_TCP_NEWRENO_FAST_RECOVERY) | ||
598 | |||
599 | #define S_TF_TX_PACE_AUTO 38 | ||
600 | #define V_TF_TX_PACE_AUTO(x) ((x) << S_TF_TX_PACE_AUTO) | ||
601 | |||
602 | #define S_TF_PEER_FIN_HELD 39 | ||
603 | #define V_TF_PEER_FIN_HELD(x) ((x) << S_TF_PEER_FIN_HELD) | ||
604 | |||
605 | #define S_TF_CORE_URG 40 | ||
606 | #define V_TF_CORE_URG(x) ((x) << S_TF_CORE_URG) | ||
607 | |||
608 | #define S_TF_RDMA_ERROR 41 | ||
609 | #define V_TF_RDMA_ERROR(x) ((x) << S_TF_RDMA_ERROR) | ||
610 | |||
611 | #define S_TF_SSWS_DISABLED 42 | ||
612 | #define V_TF_SSWS_DISABLED(x) ((x) << S_TF_SSWS_DISABLED) | ||
613 | |||
614 | #define S_TF_DUPACK_COUNT_ODD 43 | ||
615 | #define V_TF_DUPACK_COUNT_ODD(x) ((x) << S_TF_DUPACK_COUNT_ODD) | ||
616 | |||
617 | #define S_TF_TX_CHANNEL 44 | ||
618 | #define V_TF_TX_CHANNEL(x) ((x) << S_TF_TX_CHANNEL) | ||
619 | |||
620 | #define S_TF_RX_CHANNEL 45 | ||
621 | #define V_TF_RX_CHANNEL(x) ((x) << S_TF_RX_CHANNEL) | ||
622 | |||
623 | #define S_TF_TX_PACE_FIXED 46 | ||
624 | #define V_TF_TX_PACE_FIXED(x) ((x) << S_TF_TX_PACE_FIXED) | ||
625 | |||
626 | #define S_TF_RDMA_FLM_ERROR 47 | ||
627 | #define V_TF_RDMA_FLM_ERROR(x) ((x) << S_TF_RDMA_FLM_ERROR) | ||
628 | |||
629 | #define S_TF_RX_FLOW_CONTROL_DISABLE 48 | ||
630 | #define V_TF_RX_FLOW_CONTROL_DISABLE(x) ((x) << S_TF_RX_FLOW_CONTROL_DISABLE) | ||
631 | |||
632 | #endif /* _TCB_DEFS_H */ | ||
diff --git a/drivers/infiniband/hw/ehca/ehca_eq.c b/drivers/infiniband/hw/ehca/ehca_eq.c index 5281dec66f12..24ceab0bae4a 100644 --- a/drivers/infiniband/hw/ehca/ehca_eq.c +++ b/drivers/infiniband/hw/ehca/ehca_eq.c | |||
@@ -122,7 +122,7 @@ int ehca_create_eq(struct ehca_shca *shca, | |||
122 | /* register interrupt handlers and initialize work queues */ | 122 | /* register interrupt handlers and initialize work queues */ |
123 | if (type == EHCA_EQ) { | 123 | if (type == EHCA_EQ) { |
124 | ret = ibmebus_request_irq(NULL, eq->ist, ehca_interrupt_eq, | 124 | ret = ibmebus_request_irq(NULL, eq->ist, ehca_interrupt_eq, |
125 | SA_INTERRUPT, "ehca_eq", | 125 | IRQF_DISABLED, "ehca_eq", |
126 | (void *)shca); | 126 | (void *)shca); |
127 | if (ret < 0) | 127 | if (ret < 0) |
128 | ehca_err(ib_dev, "Can't map interrupt handler."); | 128 | ehca_err(ib_dev, "Can't map interrupt handler."); |
@@ -130,7 +130,7 @@ int ehca_create_eq(struct ehca_shca *shca, | |||
130 | tasklet_init(&eq->interrupt_task, ehca_tasklet_eq, (long)shca); | 130 | tasklet_init(&eq->interrupt_task, ehca_tasklet_eq, (long)shca); |
131 | } else if (type == EHCA_NEQ) { | 131 | } else if (type == EHCA_NEQ) { |
132 | ret = ibmebus_request_irq(NULL, eq->ist, ehca_interrupt_neq, | 132 | ret = ibmebus_request_irq(NULL, eq->ist, ehca_interrupt_neq, |
133 | SA_INTERRUPT, "ehca_neq", | 133 | IRQF_DISABLED, "ehca_neq", |
134 | (void *)shca); | 134 | (void *)shca); |
135 | if (ret < 0) | 135 | if (ret < 0) |
136 | ehca_err(ib_dev, "Can't map interrupt handler."); | 136 | ehca_err(ib_dev, "Can't map interrupt handler."); |
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c index c069be8cbcb2..6c4f9f91b15d 100644 --- a/drivers/infiniband/hw/ehca/ehca_irq.c +++ b/drivers/infiniband/hw/ehca/ehca_irq.c | |||
@@ -756,6 +756,8 @@ void ehca_destroy_comp_pool(void) | |||
756 | if (cpu_online(i)) | 756 | if (cpu_online(i)) |
757 | destroy_comp_task(pool, i); | 757 | destroy_comp_task(pool, i); |
758 | } | 758 | } |
759 | free_percpu(pool->cpu_comp_tasks); | ||
760 | kfree(pool); | ||
759 | #endif | 761 | #endif |
760 | 762 | ||
761 | return; | 763 | return; |
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index 968d1519761c..71314460b11e 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c | |||
@@ -1051,7 +1051,11 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev, | |||
1051 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_EQ_OFFSET); | 1051 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_EQ_OFFSET); |
1052 | dev_lim->max_eqs = 1 << (field & 0x7); | 1052 | dev_lim->max_eqs = 1 << (field & 0x7); |
1053 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MTT_OFFSET); | 1053 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MTT_OFFSET); |
1054 | dev_lim->reserved_mtts = 1 << (field >> 4); | 1054 | if (mthca_is_memfree(dev)) |
1055 | dev_lim->reserved_mtts = ALIGN((1 << (field >> 4)) * sizeof(u64), | ||
1056 | MTHCA_MTT_SEG_SIZE) / MTHCA_MTT_SEG_SIZE; | ||
1057 | else | ||
1058 | dev_lim->reserved_mtts = 1 << (field >> 4); | ||
1055 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MRW_SZ_OFFSET); | 1059 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MRW_SZ_OFFSET); |
1056 | dev_lim->max_mrw_sz = 1 << field; | 1060 | dev_lim->max_mrw_sz = 1 << field; |
1057 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MRW_OFFSET); | 1061 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MRW_OFFSET); |
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index fe5cecf70fed..b7e42efaf43d 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h | |||
@@ -464,6 +464,8 @@ void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar); | |||
464 | int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd); | 464 | int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd); |
465 | void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd); | 465 | void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd); |
466 | 466 | ||
467 | int mthca_write_mtt_size(struct mthca_dev *dev); | ||
468 | |||
467 | struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size); | 469 | struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size); |
468 | void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt); | 470 | void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt); |
469 | int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, | 471 | int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, |
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index 44bc6cc734ab..0d9b7d06bbc2 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c | |||
@@ -379,7 +379,7 @@ static int mthca_load_fw(struct mthca_dev *mdev) | |||
379 | 379 | ||
380 | mdev->fw.arbel.fw_icm = | 380 | mdev->fw.arbel.fw_icm = |
381 | mthca_alloc_icm(mdev, mdev->fw.arbel.fw_pages, | 381 | mthca_alloc_icm(mdev, mdev->fw.arbel.fw_pages, |
382 | GFP_HIGHUSER | __GFP_NOWARN); | 382 | GFP_HIGHUSER | __GFP_NOWARN, 0); |
383 | if (!mdev->fw.arbel.fw_icm) { | 383 | if (!mdev->fw.arbel.fw_icm) { |
384 | mthca_err(mdev, "Couldn't allocate FW area, aborting.\n"); | 384 | mthca_err(mdev, "Couldn't allocate FW area, aborting.\n"); |
385 | return -ENOMEM; | 385 | return -ENOMEM; |
@@ -412,7 +412,7 @@ err_unmap_fa: | |||
412 | mthca_UNMAP_FA(mdev, &status); | 412 | mthca_UNMAP_FA(mdev, &status); |
413 | 413 | ||
414 | err_free: | 414 | err_free: |
415 | mthca_free_icm(mdev, mdev->fw.arbel.fw_icm); | 415 | mthca_free_icm(mdev, mdev->fw.arbel.fw_icm, 0); |
416 | return err; | 416 | return err; |
417 | } | 417 | } |
418 | 418 | ||
@@ -441,7 +441,7 @@ static int mthca_init_icm(struct mthca_dev *mdev, | |||
441 | (unsigned long long) aux_pages << 2); | 441 | (unsigned long long) aux_pages << 2); |
442 | 442 | ||
443 | mdev->fw.arbel.aux_icm = mthca_alloc_icm(mdev, aux_pages, | 443 | mdev->fw.arbel.aux_icm = mthca_alloc_icm(mdev, aux_pages, |
444 | GFP_HIGHUSER | __GFP_NOWARN); | 444 | GFP_HIGHUSER | __GFP_NOWARN, 0); |
445 | if (!mdev->fw.arbel.aux_icm) { | 445 | if (!mdev->fw.arbel.aux_icm) { |
446 | mthca_err(mdev, "Couldn't allocate aux memory, aborting.\n"); | 446 | mthca_err(mdev, "Couldn't allocate aux memory, aborting.\n"); |
447 | return -ENOMEM; | 447 | return -ENOMEM; |
@@ -464,10 +464,15 @@ static int mthca_init_icm(struct mthca_dev *mdev, | |||
464 | goto err_unmap_aux; | 464 | goto err_unmap_aux; |
465 | } | 465 | } |
466 | 466 | ||
467 | /* CPU writes to non-reserved MTTs, while HCA might DMA to reserved mtts */ | ||
468 | mdev->limits.reserved_mtts = ALIGN(mdev->limits.reserved_mtts * MTHCA_MTT_SEG_SIZE, | ||
469 | dma_get_cache_alignment()) / MTHCA_MTT_SEG_SIZE; | ||
470 | |||
467 | mdev->mr_table.mtt_table = mthca_alloc_icm_table(mdev, init_hca->mtt_base, | 471 | mdev->mr_table.mtt_table = mthca_alloc_icm_table(mdev, init_hca->mtt_base, |
468 | MTHCA_MTT_SEG_SIZE, | 472 | MTHCA_MTT_SEG_SIZE, |
469 | mdev->limits.num_mtt_segs, | 473 | mdev->limits.num_mtt_segs, |
470 | mdev->limits.reserved_mtts, 1); | 474 | mdev->limits.reserved_mtts, |
475 | 1, 0); | ||
471 | if (!mdev->mr_table.mtt_table) { | 476 | if (!mdev->mr_table.mtt_table) { |
472 | mthca_err(mdev, "Failed to map MTT context memory, aborting.\n"); | 477 | mthca_err(mdev, "Failed to map MTT context memory, aborting.\n"); |
473 | err = -ENOMEM; | 478 | err = -ENOMEM; |
@@ -477,7 +482,8 @@ static int mthca_init_icm(struct mthca_dev *mdev, | |||
477 | mdev->mr_table.mpt_table = mthca_alloc_icm_table(mdev, init_hca->mpt_base, | 482 | mdev->mr_table.mpt_table = mthca_alloc_icm_table(mdev, init_hca->mpt_base, |
478 | dev_lim->mpt_entry_sz, | 483 | dev_lim->mpt_entry_sz, |
479 | mdev->limits.num_mpts, | 484 | mdev->limits.num_mpts, |
480 | mdev->limits.reserved_mrws, 1); | 485 | mdev->limits.reserved_mrws, |
486 | 1, 1); | ||
481 | if (!mdev->mr_table.mpt_table) { | 487 | if (!mdev->mr_table.mpt_table) { |
482 | mthca_err(mdev, "Failed to map MPT context memory, aborting.\n"); | 488 | mthca_err(mdev, "Failed to map MPT context memory, aborting.\n"); |
483 | err = -ENOMEM; | 489 | err = -ENOMEM; |
@@ -487,7 +493,8 @@ static int mthca_init_icm(struct mthca_dev *mdev, | |||
487 | mdev->qp_table.qp_table = mthca_alloc_icm_table(mdev, init_hca->qpc_base, | 493 | mdev->qp_table.qp_table = mthca_alloc_icm_table(mdev, init_hca->qpc_base, |
488 | dev_lim->qpc_entry_sz, | 494 | dev_lim->qpc_entry_sz, |
489 | mdev->limits.num_qps, | 495 | mdev->limits.num_qps, |
490 | mdev->limits.reserved_qps, 0); | 496 | mdev->limits.reserved_qps, |
497 | 0, 0); | ||
491 | if (!mdev->qp_table.qp_table) { | 498 | if (!mdev->qp_table.qp_table) { |
492 | mthca_err(mdev, "Failed to map QP context memory, aborting.\n"); | 499 | mthca_err(mdev, "Failed to map QP context memory, aborting.\n"); |
493 | err = -ENOMEM; | 500 | err = -ENOMEM; |
@@ -497,7 +504,8 @@ static int mthca_init_icm(struct mthca_dev *mdev, | |||
497 | mdev->qp_table.eqp_table = mthca_alloc_icm_table(mdev, init_hca->eqpc_base, | 504 | mdev->qp_table.eqp_table = mthca_alloc_icm_table(mdev, init_hca->eqpc_base, |
498 | dev_lim->eqpc_entry_sz, | 505 | dev_lim->eqpc_entry_sz, |
499 | mdev->limits.num_qps, | 506 | mdev->limits.num_qps, |
500 | mdev->limits.reserved_qps, 0); | 507 | mdev->limits.reserved_qps, |
508 | 0, 0); | ||
501 | if (!mdev->qp_table.eqp_table) { | 509 | if (!mdev->qp_table.eqp_table) { |
502 | mthca_err(mdev, "Failed to map EQP context memory, aborting.\n"); | 510 | mthca_err(mdev, "Failed to map EQP context memory, aborting.\n"); |
503 | err = -ENOMEM; | 511 | err = -ENOMEM; |
@@ -507,7 +515,7 @@ static int mthca_init_icm(struct mthca_dev *mdev, | |||
507 | mdev->qp_table.rdb_table = mthca_alloc_icm_table(mdev, init_hca->rdb_base, | 515 | mdev->qp_table.rdb_table = mthca_alloc_icm_table(mdev, init_hca->rdb_base, |
508 | MTHCA_RDB_ENTRY_SIZE, | 516 | MTHCA_RDB_ENTRY_SIZE, |
509 | mdev->limits.num_qps << | 517 | mdev->limits.num_qps << |
510 | mdev->qp_table.rdb_shift, | 518 | mdev->qp_table.rdb_shift, 0, |
511 | 0, 0); | 519 | 0, 0); |
512 | if (!mdev->qp_table.rdb_table) { | 520 | if (!mdev->qp_table.rdb_table) { |
513 | mthca_err(mdev, "Failed to map RDB context memory, aborting\n"); | 521 | mthca_err(mdev, "Failed to map RDB context memory, aborting\n"); |
@@ -518,7 +526,8 @@ static int mthca_init_icm(struct mthca_dev *mdev, | |||
518 | mdev->cq_table.table = mthca_alloc_icm_table(mdev, init_hca->cqc_base, | 526 | mdev->cq_table.table = mthca_alloc_icm_table(mdev, init_hca->cqc_base, |
519 | dev_lim->cqc_entry_sz, | 527 | dev_lim->cqc_entry_sz, |
520 | mdev->limits.num_cqs, | 528 | mdev->limits.num_cqs, |
521 | mdev->limits.reserved_cqs, 0); | 529 | mdev->limits.reserved_cqs, |
530 | 0, 0); | ||
522 | if (!mdev->cq_table.table) { | 531 | if (!mdev->cq_table.table) { |
523 | mthca_err(mdev, "Failed to map CQ context memory, aborting.\n"); | 532 | mthca_err(mdev, "Failed to map CQ context memory, aborting.\n"); |
524 | err = -ENOMEM; | 533 | err = -ENOMEM; |
@@ -530,7 +539,8 @@ static int mthca_init_icm(struct mthca_dev *mdev, | |||
530 | mthca_alloc_icm_table(mdev, init_hca->srqc_base, | 539 | mthca_alloc_icm_table(mdev, init_hca->srqc_base, |
531 | dev_lim->srq_entry_sz, | 540 | dev_lim->srq_entry_sz, |
532 | mdev->limits.num_srqs, | 541 | mdev->limits.num_srqs, |
533 | mdev->limits.reserved_srqs, 0); | 542 | mdev->limits.reserved_srqs, |
543 | 0, 0); | ||
534 | if (!mdev->srq_table.table) { | 544 | if (!mdev->srq_table.table) { |
535 | mthca_err(mdev, "Failed to map SRQ context memory, " | 545 | mthca_err(mdev, "Failed to map SRQ context memory, " |
536 | "aborting.\n"); | 546 | "aborting.\n"); |
@@ -550,7 +560,7 @@ static int mthca_init_icm(struct mthca_dev *mdev, | |||
550 | mdev->limits.num_amgms, | 560 | mdev->limits.num_amgms, |
551 | mdev->limits.num_mgms + | 561 | mdev->limits.num_mgms + |
552 | mdev->limits.num_amgms, | 562 | mdev->limits.num_amgms, |
553 | 0); | 563 | 0, 0); |
554 | if (!mdev->mcg_table.table) { | 564 | if (!mdev->mcg_table.table) { |
555 | mthca_err(mdev, "Failed to map MCG context memory, aborting.\n"); | 565 | mthca_err(mdev, "Failed to map MCG context memory, aborting.\n"); |
556 | err = -ENOMEM; | 566 | err = -ENOMEM; |
@@ -588,7 +598,7 @@ err_unmap_aux: | |||
588 | mthca_UNMAP_ICM_AUX(mdev, &status); | 598 | mthca_UNMAP_ICM_AUX(mdev, &status); |
589 | 599 | ||
590 | err_free_aux: | 600 | err_free_aux: |
591 | mthca_free_icm(mdev, mdev->fw.arbel.aux_icm); | 601 | mthca_free_icm(mdev, mdev->fw.arbel.aux_icm, 0); |
592 | 602 | ||
593 | return err; | 603 | return err; |
594 | } | 604 | } |
@@ -609,7 +619,7 @@ static void mthca_free_icms(struct mthca_dev *mdev) | |||
609 | mthca_unmap_eq_icm(mdev); | 619 | mthca_unmap_eq_icm(mdev); |
610 | 620 | ||
611 | mthca_UNMAP_ICM_AUX(mdev, &status); | 621 | mthca_UNMAP_ICM_AUX(mdev, &status); |
612 | mthca_free_icm(mdev, mdev->fw.arbel.aux_icm); | 622 | mthca_free_icm(mdev, mdev->fw.arbel.aux_icm, 0); |
613 | } | 623 | } |
614 | 624 | ||
615 | static int mthca_init_arbel(struct mthca_dev *mdev) | 625 | static int mthca_init_arbel(struct mthca_dev *mdev) |
@@ -693,7 +703,7 @@ err_free_icm: | |||
693 | 703 | ||
694 | err_stop_fw: | 704 | err_stop_fw: |
695 | mthca_UNMAP_FA(mdev, &status); | 705 | mthca_UNMAP_FA(mdev, &status); |
696 | mthca_free_icm(mdev, mdev->fw.arbel.fw_icm); | 706 | mthca_free_icm(mdev, mdev->fw.arbel.fw_icm, 0); |
697 | 707 | ||
698 | err_disable: | 708 | err_disable: |
699 | if (!(mdev->mthca_flags & MTHCA_FLAG_NO_LAM)) | 709 | if (!(mdev->mthca_flags & MTHCA_FLAG_NO_LAM)) |
@@ -712,7 +722,7 @@ static void mthca_close_hca(struct mthca_dev *mdev) | |||
712 | mthca_free_icms(mdev); | 722 | mthca_free_icms(mdev); |
713 | 723 | ||
714 | mthca_UNMAP_FA(mdev, &status); | 724 | mthca_UNMAP_FA(mdev, &status); |
715 | mthca_free_icm(mdev, mdev->fw.arbel.fw_icm); | 725 | mthca_free_icm(mdev, mdev->fw.arbel.fw_icm, 0); |
716 | 726 | ||
717 | if (!(mdev->mthca_flags & MTHCA_FLAG_NO_LAM)) | 727 | if (!(mdev->mthca_flags & MTHCA_FLAG_NO_LAM)) |
718 | mthca_DISABLE_LAM(mdev, &status); | 728 | mthca_DISABLE_LAM(mdev, &status); |
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 6b19645d946c..0b9d053a599d 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
@@ -35,6 +35,9 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include <linux/mm.h> | 37 | #include <linux/mm.h> |
38 | #include <linux/scatterlist.h> | ||
39 | |||
40 | #include <asm/page.h> | ||
38 | 41 | ||
39 | #include "mthca_memfree.h" | 42 | #include "mthca_memfree.h" |
40 | #include "mthca_dev.h" | 43 | #include "mthca_dev.h" |
@@ -58,22 +61,42 @@ struct mthca_user_db_table { | |||
58 | } page[0]; | 61 | } page[0]; |
59 | }; | 62 | }; |
60 | 63 | ||
61 | void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm) | 64 | static void mthca_free_icm_pages(struct mthca_dev *dev, struct mthca_icm_chunk *chunk) |
65 | { | ||
66 | int i; | ||
67 | |||
68 | if (chunk->nsg > 0) | ||
69 | pci_unmap_sg(dev->pdev, chunk->mem, chunk->npages, | ||
70 | PCI_DMA_BIDIRECTIONAL); | ||
71 | |||
72 | for (i = 0; i < chunk->npages; ++i) | ||
73 | __free_pages(chunk->mem[i].page, | ||
74 | get_order(chunk->mem[i].length)); | ||
75 | } | ||
76 | |||
77 | static void mthca_free_icm_coherent(struct mthca_dev *dev, struct mthca_icm_chunk *chunk) | ||
62 | { | 78 | { |
63 | struct mthca_icm_chunk *chunk, *tmp; | ||
64 | int i; | 79 | int i; |
65 | 80 | ||
81 | for (i = 0; i < chunk->npages; ++i) { | ||
82 | dma_free_coherent(&dev->pdev->dev, chunk->mem[i].length, | ||
83 | lowmem_page_address(chunk->mem[i].page), | ||
84 | sg_dma_address(&chunk->mem[i])); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm, int coherent) | ||
89 | { | ||
90 | struct mthca_icm_chunk *chunk, *tmp; | ||
91 | |||
66 | if (!icm) | 92 | if (!icm) |
67 | return; | 93 | return; |
68 | 94 | ||
69 | list_for_each_entry_safe(chunk, tmp, &icm->chunk_list, list) { | 95 | list_for_each_entry_safe(chunk, tmp, &icm->chunk_list, list) { |
70 | if (chunk->nsg > 0) | 96 | if (coherent) |
71 | pci_unmap_sg(dev->pdev, chunk->mem, chunk->npages, | 97 | mthca_free_icm_coherent(dev, chunk); |
72 | PCI_DMA_BIDIRECTIONAL); | 98 | else |
73 | 99 | mthca_free_icm_pages(dev, chunk); | |
74 | for (i = 0; i < chunk->npages; ++i) | ||
75 | __free_pages(chunk->mem[i].page, | ||
76 | get_order(chunk->mem[i].length)); | ||
77 | 100 | ||
78 | kfree(chunk); | 101 | kfree(chunk); |
79 | } | 102 | } |
@@ -81,12 +104,41 @@ void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm) | |||
81 | kfree(icm); | 104 | kfree(icm); |
82 | } | 105 | } |
83 | 106 | ||
107 | static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_mask) | ||
108 | { | ||
109 | mem->page = alloc_pages(gfp_mask, order); | ||
110 | if (!mem->page) | ||
111 | return -ENOMEM; | ||
112 | |||
113 | mem->length = PAGE_SIZE << order; | ||
114 | mem->offset = 0; | ||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | static int mthca_alloc_icm_coherent(struct device *dev, struct scatterlist *mem, | ||
119 | int order, gfp_t gfp_mask) | ||
120 | { | ||
121 | void *buf = dma_alloc_coherent(dev, PAGE_SIZE << order, &sg_dma_address(mem), | ||
122 | gfp_mask); | ||
123 | if (!buf) | ||
124 | return -ENOMEM; | ||
125 | |||
126 | sg_set_buf(mem, buf, PAGE_SIZE << order); | ||
127 | BUG_ON(mem->offset); | ||
128 | sg_dma_len(mem) = PAGE_SIZE << order; | ||
129 | return 0; | ||
130 | } | ||
131 | |||
84 | struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, | 132 | struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, |
85 | gfp_t gfp_mask) | 133 | gfp_t gfp_mask, int coherent) |
86 | { | 134 | { |
87 | struct mthca_icm *icm; | 135 | struct mthca_icm *icm; |
88 | struct mthca_icm_chunk *chunk = NULL; | 136 | struct mthca_icm_chunk *chunk = NULL; |
89 | int cur_order; | 137 | int cur_order; |
138 | int ret; | ||
139 | |||
140 | /* We use sg_set_buf for coherent allocs, which assumes low memory */ | ||
141 | BUG_ON(coherent && (gfp_mask & __GFP_HIGHMEM)); | ||
90 | 142 | ||
91 | icm = kmalloc(sizeof *icm, gfp_mask & ~(__GFP_HIGHMEM | __GFP_NOWARN)); | 143 | icm = kmalloc(sizeof *icm, gfp_mask & ~(__GFP_HIGHMEM | __GFP_NOWARN)); |
92 | if (!icm) | 144 | if (!icm) |
@@ -112,21 +164,28 @@ struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, | |||
112 | while (1 << cur_order > npages) | 164 | while (1 << cur_order > npages) |
113 | --cur_order; | 165 | --cur_order; |
114 | 166 | ||
115 | chunk->mem[chunk->npages].page = alloc_pages(gfp_mask, cur_order); | 167 | if (coherent) |
116 | if (chunk->mem[chunk->npages].page) { | 168 | ret = mthca_alloc_icm_coherent(&dev->pdev->dev, |
117 | chunk->mem[chunk->npages].length = PAGE_SIZE << cur_order; | 169 | &chunk->mem[chunk->npages], |
118 | chunk->mem[chunk->npages].offset = 0; | 170 | cur_order, gfp_mask); |
171 | else | ||
172 | ret = mthca_alloc_icm_pages(&chunk->mem[chunk->npages], | ||
173 | cur_order, gfp_mask); | ||
119 | 174 | ||
120 | if (++chunk->npages == MTHCA_ICM_CHUNK_LEN) { | 175 | if (!ret) { |
176 | ++chunk->npages; | ||
177 | |||
178 | if (!coherent && chunk->npages == MTHCA_ICM_CHUNK_LEN) { | ||
121 | chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, | 179 | chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, |
122 | chunk->npages, | 180 | chunk->npages, |
123 | PCI_DMA_BIDIRECTIONAL); | 181 | PCI_DMA_BIDIRECTIONAL); |
124 | 182 | ||
125 | if (chunk->nsg <= 0) | 183 | if (chunk->nsg <= 0) |
126 | goto fail; | 184 | goto fail; |
185 | } | ||
127 | 186 | ||
187 | if (chunk->npages == MTHCA_ICM_CHUNK_LEN) | ||
128 | chunk = NULL; | 188 | chunk = NULL; |
129 | } | ||
130 | 189 | ||
131 | npages -= 1 << cur_order; | 190 | npages -= 1 << cur_order; |
132 | } else { | 191 | } else { |
@@ -136,7 +195,7 @@ struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, | |||
136 | } | 195 | } |
137 | } | 196 | } |
138 | 197 | ||
139 | if (chunk) { | 198 | if (!coherent && chunk) { |
140 | chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, | 199 | chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, |
141 | chunk->npages, | 200 | chunk->npages, |
142 | PCI_DMA_BIDIRECTIONAL); | 201 | PCI_DMA_BIDIRECTIONAL); |
@@ -148,7 +207,7 @@ struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, | |||
148 | return icm; | 207 | return icm; |
149 | 208 | ||
150 | fail: | 209 | fail: |
151 | mthca_free_icm(dev, icm); | 210 | mthca_free_icm(dev, icm, coherent); |
152 | return NULL; | 211 | return NULL; |
153 | } | 212 | } |
154 | 213 | ||
@@ -167,7 +226,7 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob | |||
167 | 226 | ||
168 | table->icm[i] = mthca_alloc_icm(dev, MTHCA_TABLE_CHUNK_SIZE >> PAGE_SHIFT, | 227 | table->icm[i] = mthca_alloc_icm(dev, MTHCA_TABLE_CHUNK_SIZE >> PAGE_SHIFT, |
169 | (table->lowmem ? GFP_KERNEL : GFP_HIGHUSER) | | 228 | (table->lowmem ? GFP_KERNEL : GFP_HIGHUSER) | |
170 | __GFP_NOWARN); | 229 | __GFP_NOWARN, table->coherent); |
171 | if (!table->icm[i]) { | 230 | if (!table->icm[i]) { |
172 | ret = -ENOMEM; | 231 | ret = -ENOMEM; |
173 | goto out; | 232 | goto out; |
@@ -175,7 +234,7 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob | |||
175 | 234 | ||
176 | if (mthca_MAP_ICM(dev, table->icm[i], table->virt + i * MTHCA_TABLE_CHUNK_SIZE, | 235 | if (mthca_MAP_ICM(dev, table->icm[i], table->virt + i * MTHCA_TABLE_CHUNK_SIZE, |
177 | &status) || status) { | 236 | &status) || status) { |
178 | mthca_free_icm(dev, table->icm[i]); | 237 | mthca_free_icm(dev, table->icm[i], table->coherent); |
179 | table->icm[i] = NULL; | 238 | table->icm[i] = NULL; |
180 | ret = -ENOMEM; | 239 | ret = -ENOMEM; |
181 | goto out; | 240 | goto out; |
@@ -204,16 +263,16 @@ void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int o | |||
204 | mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, | 263 | mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, |
205 | MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, | 264 | MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, |
206 | &status); | 265 | &status); |
207 | mthca_free_icm(dev, table->icm[i]); | 266 | mthca_free_icm(dev, table->icm[i], table->coherent); |
208 | table->icm[i] = NULL; | 267 | table->icm[i] = NULL; |
209 | } | 268 | } |
210 | 269 | ||
211 | mutex_unlock(&table->mutex); | 270 | mutex_unlock(&table->mutex); |
212 | } | 271 | } |
213 | 272 | ||
214 | void *mthca_table_find(struct mthca_icm_table *table, int obj) | 273 | void *mthca_table_find(struct mthca_icm_table *table, int obj, dma_addr_t *dma_handle) |
215 | { | 274 | { |
216 | int idx, offset, i; | 275 | int idx, offset, dma_offset, i; |
217 | struct mthca_icm_chunk *chunk; | 276 | struct mthca_icm_chunk *chunk; |
218 | struct mthca_icm *icm; | 277 | struct mthca_icm *icm; |
219 | struct page *page = NULL; | 278 | struct page *page = NULL; |
@@ -225,13 +284,22 @@ void *mthca_table_find(struct mthca_icm_table *table, int obj) | |||
225 | 284 | ||
226 | idx = (obj & (table->num_obj - 1)) * table->obj_size; | 285 | idx = (obj & (table->num_obj - 1)) * table->obj_size; |
227 | icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE]; | 286 | icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE]; |
228 | offset = idx % MTHCA_TABLE_CHUNK_SIZE; | 287 | dma_offset = offset = idx % MTHCA_TABLE_CHUNK_SIZE; |
229 | 288 | ||
230 | if (!icm) | 289 | if (!icm) |
231 | goto out; | 290 | goto out; |
232 | 291 | ||
233 | list_for_each_entry(chunk, &icm->chunk_list, list) { | 292 | list_for_each_entry(chunk, &icm->chunk_list, list) { |
234 | for (i = 0; i < chunk->npages; ++i) { | 293 | for (i = 0; i < chunk->npages; ++i) { |
294 | if (dma_handle && dma_offset >= 0) { | ||
295 | if (sg_dma_len(&chunk->mem[i]) > dma_offset) | ||
296 | *dma_handle = sg_dma_address(&chunk->mem[i]) + | ||
297 | dma_offset; | ||
298 | dma_offset -= sg_dma_len(&chunk->mem[i]); | ||
299 | } | ||
300 | /* DMA mapping can merge pages but not split them, | ||
301 | * so if we found the page, dma_handle has already | ||
302 | * been assigned to. */ | ||
235 | if (chunk->mem[i].length > offset) { | 303 | if (chunk->mem[i].length > offset) { |
236 | page = chunk->mem[i].page; | 304 | page = chunk->mem[i].page; |
237 | goto out; | 305 | goto out; |
@@ -283,7 +351,7 @@ void mthca_table_put_range(struct mthca_dev *dev, struct mthca_icm_table *table, | |||
283 | struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, | 351 | struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, |
284 | u64 virt, int obj_size, | 352 | u64 virt, int obj_size, |
285 | int nobj, int reserved, | 353 | int nobj, int reserved, |
286 | int use_lowmem) | 354 | int use_lowmem, int use_coherent) |
287 | { | 355 | { |
288 | struct mthca_icm_table *table; | 356 | struct mthca_icm_table *table; |
289 | int num_icm; | 357 | int num_icm; |
@@ -302,6 +370,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, | |||
302 | table->num_obj = nobj; | 370 | table->num_obj = nobj; |
303 | table->obj_size = obj_size; | 371 | table->obj_size = obj_size; |
304 | table->lowmem = use_lowmem; | 372 | table->lowmem = use_lowmem; |
373 | table->coherent = use_coherent; | ||
305 | mutex_init(&table->mutex); | 374 | mutex_init(&table->mutex); |
306 | 375 | ||
307 | for (i = 0; i < num_icm; ++i) | 376 | for (i = 0; i < num_icm; ++i) |
@@ -314,12 +383,12 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, | |||
314 | 383 | ||
315 | table->icm[i] = mthca_alloc_icm(dev, chunk_size >> PAGE_SHIFT, | 384 | table->icm[i] = mthca_alloc_icm(dev, chunk_size >> PAGE_SHIFT, |
316 | (use_lowmem ? GFP_KERNEL : GFP_HIGHUSER) | | 385 | (use_lowmem ? GFP_KERNEL : GFP_HIGHUSER) | |
317 | __GFP_NOWARN); | 386 | __GFP_NOWARN, use_coherent); |
318 | if (!table->icm[i]) | 387 | if (!table->icm[i]) |
319 | goto err; | 388 | goto err; |
320 | if (mthca_MAP_ICM(dev, table->icm[i], virt + i * MTHCA_TABLE_CHUNK_SIZE, | 389 | if (mthca_MAP_ICM(dev, table->icm[i], virt + i * MTHCA_TABLE_CHUNK_SIZE, |
321 | &status) || status) { | 390 | &status) || status) { |
322 | mthca_free_icm(dev, table->icm[i]); | 391 | mthca_free_icm(dev, table->icm[i], table->coherent); |
323 | table->icm[i] = NULL; | 392 | table->icm[i] = NULL; |
324 | goto err; | 393 | goto err; |
325 | } | 394 | } |
@@ -339,7 +408,7 @@ err: | |||
339 | mthca_UNMAP_ICM(dev, virt + i * MTHCA_TABLE_CHUNK_SIZE, | 408 | mthca_UNMAP_ICM(dev, virt + i * MTHCA_TABLE_CHUNK_SIZE, |
340 | MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, | 409 | MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, |
341 | &status); | 410 | &status); |
342 | mthca_free_icm(dev, table->icm[i]); | 411 | mthca_free_icm(dev, table->icm[i], table->coherent); |
343 | } | 412 | } |
344 | 413 | ||
345 | kfree(table); | 414 | kfree(table); |
@@ -357,7 +426,7 @@ void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table) | |||
357 | mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, | 426 | mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, |
358 | MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, | 427 | MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, |
359 | &status); | 428 | &status); |
360 | mthca_free_icm(dev, table->icm[i]); | 429 | mthca_free_icm(dev, table->icm[i], table->coherent); |
361 | } | 430 | } |
362 | 431 | ||
363 | kfree(table); | 432 | kfree(table); |
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.h b/drivers/infiniband/hw/mthca/mthca_memfree.h index 6d42947e1dc4..594144145f45 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.h +++ b/drivers/infiniband/hw/mthca/mthca_memfree.h | |||
@@ -69,6 +69,7 @@ struct mthca_icm_table { | |||
69 | int num_obj; | 69 | int num_obj; |
70 | int obj_size; | 70 | int obj_size; |
71 | int lowmem; | 71 | int lowmem; |
72 | int coherent; | ||
72 | struct mutex mutex; | 73 | struct mutex mutex; |
73 | struct mthca_icm *icm[0]; | 74 | struct mthca_icm *icm[0]; |
74 | }; | 75 | }; |
@@ -82,17 +83,17 @@ struct mthca_icm_iter { | |||
82 | struct mthca_dev; | 83 | struct mthca_dev; |
83 | 84 | ||
84 | struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, | 85 | struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, |
85 | gfp_t gfp_mask); | 86 | gfp_t gfp_mask, int coherent); |
86 | void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm); | 87 | void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm, int coherent); |
87 | 88 | ||
88 | struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, | 89 | struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, |
89 | u64 virt, int obj_size, | 90 | u64 virt, int obj_size, |
90 | int nobj, int reserved, | 91 | int nobj, int reserved, |
91 | int use_lowmem); | 92 | int use_lowmem, int use_coherent); |
92 | void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table); | 93 | void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table); |
93 | int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int obj); | 94 | int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int obj); |
94 | void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj); | 95 | void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj); |
95 | void *mthca_table_find(struct mthca_icm_table *table, int obj); | 96 | void *mthca_table_find(struct mthca_icm_table *table, int obj, dma_addr_t *dma_handle); |
96 | int mthca_table_get_range(struct mthca_dev *dev, struct mthca_icm_table *table, | 97 | int mthca_table_get_range(struct mthca_dev *dev, struct mthca_icm_table *table, |
97 | int start, int end); | 98 | int start, int end); |
98 | void mthca_table_put_range(struct mthca_dev *dev, struct mthca_icm_table *table, | 99 | void mthca_table_put_range(struct mthca_dev *dev, struct mthca_icm_table *table, |
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c index f71ffa88db3a..6037dd3f87df 100644 --- a/drivers/infiniband/hw/mthca/mthca_mr.c +++ b/drivers/infiniband/hw/mthca/mthca_mr.c | |||
@@ -243,8 +243,8 @@ void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt) | |||
243 | kfree(mtt); | 243 | kfree(mtt); |
244 | } | 244 | } |
245 | 245 | ||
246 | int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, | 246 | static int __mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, |
247 | int start_index, u64 *buffer_list, int list_len) | 247 | int start_index, u64 *buffer_list, int list_len) |
248 | { | 248 | { |
249 | struct mthca_mailbox *mailbox; | 249 | struct mthca_mailbox *mailbox; |
250 | __be64 *mtt_entry; | 250 | __be64 *mtt_entry; |
@@ -295,6 +295,84 @@ out: | |||
295 | return err; | 295 | return err; |
296 | } | 296 | } |
297 | 297 | ||
298 | int mthca_write_mtt_size(struct mthca_dev *dev) | ||
299 | { | ||
300 | if (dev->mr_table.fmr_mtt_buddy != &dev->mr_table.mtt_buddy) | ||
301 | /* | ||
302 | * Be friendly to WRITE_MTT command | ||
303 | * and leave two empty slots for the | ||
304 | * index and reserved fields of the | ||
305 | * mailbox. | ||
306 | */ | ||
307 | return PAGE_SIZE / sizeof (u64) - 2; | ||
308 | |||
309 | /* For Arbel, all MTTs must fit in the same page. */ | ||
310 | return mthca_is_memfree(dev) ? (PAGE_SIZE / sizeof (u64)) : 0x7ffffff; | ||
311 | } | ||
312 | |||
313 | void mthca_tavor_write_mtt_seg(struct mthca_dev *dev, struct mthca_mtt *mtt, | ||
314 | int start_index, u64 *buffer_list, int list_len) | ||
315 | { | ||
316 | u64 __iomem *mtts; | ||
317 | int i; | ||
318 | |||
319 | mtts = dev->mr_table.tavor_fmr.mtt_base + mtt->first_seg * MTHCA_MTT_SEG_SIZE + | ||
320 | start_index * sizeof (u64); | ||
321 | for (i = 0; i < list_len; ++i) | ||
322 | mthca_write64_raw(cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT), | ||
323 | mtts + i); | ||
324 | } | ||
325 | |||
326 | void mthca_arbel_write_mtt_seg(struct mthca_dev *dev, struct mthca_mtt *mtt, | ||
327 | int start_index, u64 *buffer_list, int list_len) | ||
328 | { | ||
329 | __be64 *mtts; | ||
330 | dma_addr_t dma_handle; | ||
331 | int i; | ||
332 | int s = start_index * sizeof (u64); | ||
333 | |||
334 | /* For Arbel, all MTTs must fit in the same page. */ | ||
335 | BUG_ON(s / PAGE_SIZE != (s + list_len * sizeof(u64) - 1) / PAGE_SIZE); | ||
336 | /* Require full segments */ | ||
337 | BUG_ON(s % MTHCA_MTT_SEG_SIZE); | ||
338 | |||
339 | mtts = mthca_table_find(dev->mr_table.mtt_table, mtt->first_seg + | ||
340 | s / MTHCA_MTT_SEG_SIZE, &dma_handle); | ||
341 | |||
342 | BUG_ON(!mtts); | ||
343 | |||
344 | for (i = 0; i < list_len; ++i) | ||
345 | mtts[i] = cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT); | ||
346 | |||
347 | dma_sync_single(&dev->pdev->dev, dma_handle, list_len * sizeof (u64), DMA_TO_DEVICE); | ||
348 | } | ||
349 | |||
350 | int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, | ||
351 | int start_index, u64 *buffer_list, int list_len) | ||
352 | { | ||
353 | int size = mthca_write_mtt_size(dev); | ||
354 | int chunk; | ||
355 | |||
356 | if (dev->mr_table.fmr_mtt_buddy != &dev->mr_table.mtt_buddy) | ||
357 | return __mthca_write_mtt(dev, mtt, start_index, buffer_list, list_len); | ||
358 | |||
359 | while (list_len > 0) { | ||
360 | chunk = min(size, list_len); | ||
361 | if (mthca_is_memfree(dev)) | ||
362 | mthca_arbel_write_mtt_seg(dev, mtt, start_index, | ||
363 | buffer_list, chunk); | ||
364 | else | ||
365 | mthca_tavor_write_mtt_seg(dev, mtt, start_index, | ||
366 | buffer_list, chunk); | ||
367 | |||
368 | list_len -= chunk; | ||
369 | start_index += chunk; | ||
370 | buffer_list += chunk; | ||
371 | } | ||
372 | |||
373 | return 0; | ||
374 | } | ||
375 | |||
298 | static inline u32 tavor_hw_index_to_key(u32 ind) | 376 | static inline u32 tavor_hw_index_to_key(u32 ind) |
299 | { | 377 | { |
300 | return ind; | 378 | return ind; |
@@ -524,7 +602,7 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd, | |||
524 | if (err) | 602 | if (err) |
525 | goto err_out_mpt_free; | 603 | goto err_out_mpt_free; |
526 | 604 | ||
527 | mr->mem.arbel.mpt = mthca_table_find(dev->mr_table.mpt_table, key); | 605 | mr->mem.arbel.mpt = mthca_table_find(dev->mr_table.mpt_table, key, NULL); |
528 | BUG_ON(!mr->mem.arbel.mpt); | 606 | BUG_ON(!mr->mem.arbel.mpt); |
529 | } else | 607 | } else |
530 | mr->mem.tavor.mpt = dev->mr_table.tavor_fmr.mpt_base + | 608 | mr->mem.tavor.mpt = dev->mr_table.tavor_fmr.mpt_base + |
@@ -538,7 +616,8 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd, | |||
538 | 616 | ||
539 | if (mthca_is_memfree(dev)) { | 617 | if (mthca_is_memfree(dev)) { |
540 | mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table, | 618 | mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table, |
541 | mr->mtt->first_seg); | 619 | mr->mtt->first_seg, |
620 | &mr->mem.arbel.dma_handle); | ||
542 | BUG_ON(!mr->mem.arbel.mtts); | 621 | BUG_ON(!mr->mem.arbel.mtts); |
543 | } else | 622 | } else |
544 | mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg; | 623 | mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg; |
@@ -712,6 +791,9 @@ int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, | |||
712 | fmr->mem.arbel.mtts[i] = cpu_to_be64(page_list[i] | | 791 | fmr->mem.arbel.mtts[i] = cpu_to_be64(page_list[i] | |
713 | MTHCA_MTT_FLAG_PRESENT); | 792 | MTHCA_MTT_FLAG_PRESENT); |
714 | 793 | ||
794 | dma_sync_single(&dev->pdev->dev, fmr->mem.arbel.dma_handle, | ||
795 | list_len * sizeof(u64), DMA_TO_DEVICE); | ||
796 | |||
715 | fmr->mem.arbel.mpt->key = cpu_to_be32(key); | 797 | fmr->mem.arbel.mpt->key = cpu_to_be32(key); |
716 | fmr->mem.arbel.mpt->lkey = cpu_to_be32(key); | 798 | fmr->mem.arbel.mpt->lkey = cpu_to_be32(key); |
717 | fmr->mem.arbel.mpt->length = cpu_to_be64(list_len * (1ull << fmr->attr.page_shift)); | 799 | fmr->mem.arbel.mpt->length = cpu_to_be64(list_len * (1ull << fmr->attr.page_shift)); |
@@ -761,7 +843,7 @@ void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr) | |||
761 | int mthca_init_mr_table(struct mthca_dev *dev) | 843 | int mthca_init_mr_table(struct mthca_dev *dev) |
762 | { | 844 | { |
763 | unsigned long addr; | 845 | unsigned long addr; |
764 | int err, i; | 846 | int mpts, mtts, err, i; |
765 | 847 | ||
766 | err = mthca_alloc_init(&dev->mr_table.mpt_alloc, | 848 | err = mthca_alloc_init(&dev->mr_table.mpt_alloc, |
767 | dev->limits.num_mpts, | 849 | dev->limits.num_mpts, |
@@ -795,13 +877,21 @@ int mthca_init_mr_table(struct mthca_dev *dev) | |||
795 | err = -EINVAL; | 877 | err = -EINVAL; |
796 | goto err_fmr_mpt; | 878 | goto err_fmr_mpt; |
797 | } | 879 | } |
880 | mpts = mtts = 1 << i; | ||
881 | } else { | ||
882 | mpts = dev->limits.num_mtt_segs; | ||
883 | mtts = dev->limits.num_mpts; | ||
884 | } | ||
885 | |||
886 | if (!mthca_is_memfree(dev) && | ||
887 | (dev->mthca_flags & MTHCA_FLAG_FMR)) { | ||
798 | 888 | ||
799 | addr = pci_resource_start(dev->pdev, 4) + | 889 | addr = pci_resource_start(dev->pdev, 4) + |
800 | ((pci_resource_len(dev->pdev, 4) - 1) & | 890 | ((pci_resource_len(dev->pdev, 4) - 1) & |
801 | dev->mr_table.mpt_base); | 891 | dev->mr_table.mpt_base); |
802 | 892 | ||
803 | dev->mr_table.tavor_fmr.mpt_base = | 893 | dev->mr_table.tavor_fmr.mpt_base = |
804 | ioremap(addr, (1 << i) * sizeof(struct mthca_mpt_entry)); | 894 | ioremap(addr, mpts * sizeof(struct mthca_mpt_entry)); |
805 | 895 | ||
806 | if (!dev->mr_table.tavor_fmr.mpt_base) { | 896 | if (!dev->mr_table.tavor_fmr.mpt_base) { |
807 | mthca_warn(dev, "MPT ioremap for FMR failed.\n"); | 897 | mthca_warn(dev, "MPT ioremap for FMR failed.\n"); |
@@ -814,19 +904,21 @@ int mthca_init_mr_table(struct mthca_dev *dev) | |||
814 | dev->mr_table.mtt_base); | 904 | dev->mr_table.mtt_base); |
815 | 905 | ||
816 | dev->mr_table.tavor_fmr.mtt_base = | 906 | dev->mr_table.tavor_fmr.mtt_base = |
817 | ioremap(addr, (1 << i) * MTHCA_MTT_SEG_SIZE); | 907 | ioremap(addr, mtts * MTHCA_MTT_SEG_SIZE); |
818 | if (!dev->mr_table.tavor_fmr.mtt_base) { | 908 | if (!dev->mr_table.tavor_fmr.mtt_base) { |
819 | mthca_warn(dev, "MTT ioremap for FMR failed.\n"); | 909 | mthca_warn(dev, "MTT ioremap for FMR failed.\n"); |
820 | err = -ENOMEM; | 910 | err = -ENOMEM; |
821 | goto err_fmr_mtt; | 911 | goto err_fmr_mtt; |
822 | } | 912 | } |
913 | } | ||
823 | 914 | ||
824 | err = mthca_buddy_init(&dev->mr_table.tavor_fmr.mtt_buddy, i); | 915 | if (dev->limits.fmr_reserved_mtts) { |
916 | err = mthca_buddy_init(&dev->mr_table.tavor_fmr.mtt_buddy, fls(mtts - 1)); | ||
825 | if (err) | 917 | if (err) |
826 | goto err_fmr_mtt_buddy; | 918 | goto err_fmr_mtt_buddy; |
827 | 919 | ||
828 | /* Prevent regular MRs from using FMR keys */ | 920 | /* Prevent regular MRs from using FMR keys */ |
829 | err = mthca_buddy_alloc(&dev->mr_table.mtt_buddy, i); | 921 | err = mthca_buddy_alloc(&dev->mr_table.mtt_buddy, fls(mtts - 1)); |
830 | if (err) | 922 | if (err) |
831 | goto err_reserve_fmr; | 923 | goto err_reserve_fmr; |
832 | 924 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_profile.c b/drivers/infiniband/hw/mthca/mthca_profile.c index 58d44aa3c302..26bf86d1cfcd 100644 --- a/drivers/infiniband/hw/mthca/mthca_profile.c +++ b/drivers/infiniband/hw/mthca/mthca_profile.c | |||
@@ -277,7 +277,7 @@ u64 mthca_make_profile(struct mthca_dev *dev, | |||
277 | * out of the MR pool. They don't use additional memory, but | 277 | * out of the MR pool. They don't use additional memory, but |
278 | * we assign them as part of the HCA profile anyway. | 278 | * we assign them as part of the HCA profile anyway. |
279 | */ | 279 | */ |
280 | if (mthca_is_memfree(dev)) | 280 | if (mthca_is_memfree(dev) || BITS_PER_LONG == 64) |
281 | dev->limits.fmr_reserved_mtts = 0; | 281 | dev->limits.fmr_reserved_mtts = 0; |
282 | else | 282 | else |
283 | dev->limits.fmr_reserved_mtts = request->fmr_reserved_mtts; | 283 | dev->limits.fmr_reserved_mtts = request->fmr_reserved_mtts; |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 7b96751695ea..0725ad7ad9bf 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -1015,6 +1015,7 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, struct ib_umem *region, | |||
1015 | int shift, n, len; | 1015 | int shift, n, len; |
1016 | int i, j, k; | 1016 | int i, j, k; |
1017 | int err = 0; | 1017 | int err = 0; |
1018 | int write_mtt_size; | ||
1018 | 1019 | ||
1019 | shift = ffs(region->page_size) - 1; | 1020 | shift = ffs(region->page_size) - 1; |
1020 | 1021 | ||
@@ -1040,6 +1041,8 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, struct ib_umem *region, | |||
1040 | 1041 | ||
1041 | i = n = 0; | 1042 | i = n = 0; |
1042 | 1043 | ||
1044 | write_mtt_size = min(mthca_write_mtt_size(dev), (int) (PAGE_SIZE / sizeof *pages)); | ||
1045 | |||
1043 | list_for_each_entry(chunk, ®ion->chunk_list, list) | 1046 | list_for_each_entry(chunk, ®ion->chunk_list, list) |
1044 | for (j = 0; j < chunk->nmap; ++j) { | 1047 | for (j = 0; j < chunk->nmap; ++j) { |
1045 | len = sg_dma_len(&chunk->page_list[j]) >> shift; | 1048 | len = sg_dma_len(&chunk->page_list[j]) >> shift; |
@@ -1047,14 +1050,11 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, struct ib_umem *region, | |||
1047 | pages[i++] = sg_dma_address(&chunk->page_list[j]) + | 1050 | pages[i++] = sg_dma_address(&chunk->page_list[j]) + |
1048 | region->page_size * k; | 1051 | region->page_size * k; |
1049 | /* | 1052 | /* |
1050 | * Be friendly to WRITE_MTT command | 1053 | * Be friendly to write_mtt and pass it chunks |
1051 | * and leave two empty slots for the | 1054 | * of appropriate size. |
1052 | * index and reserved fields of the | ||
1053 | * mailbox. | ||
1054 | */ | 1055 | */ |
1055 | if (i == PAGE_SIZE / sizeof (u64) - 2) { | 1056 | if (i == write_mtt_size) { |
1056 | err = mthca_write_mtt(dev, mr->mtt, | 1057 | err = mthca_write_mtt(dev, mr->mtt, n, pages, i); |
1057 | n, pages, i); | ||
1058 | if (err) | 1058 | if (err) |
1059 | goto mtt_done; | 1059 | goto mtt_done; |
1060 | n += i; | 1060 | n += i; |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h index 9a5bece3fa5c..1d266ac2e094 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.h +++ b/drivers/infiniband/hw/mthca/mthca_provider.h | |||
@@ -89,6 +89,7 @@ struct mthca_fmr { | |||
89 | struct { | 89 | struct { |
90 | struct mthca_mpt_entry *mpt; | 90 | struct mthca_mpt_entry *mpt; |
91 | __be64 *mtts; | 91 | __be64 *mtts; |
92 | dma_addr_t dma_handle; | ||
92 | } arbel; | 93 | } arbel; |
93 | } mem; | 94 | } mem; |
94 | }; | 95 | }; |
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 5f5214c0337d..224c93dd29eb 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c | |||
@@ -399,7 +399,7 @@ static int to_ib_qp_access_flags(int mthca_flags) | |||
399 | static void to_ib_ah_attr(struct mthca_dev *dev, struct ib_ah_attr *ib_ah_attr, | 399 | static void to_ib_ah_attr(struct mthca_dev *dev, struct ib_ah_attr *ib_ah_attr, |
400 | struct mthca_qp_path *path) | 400 | struct mthca_qp_path *path) |
401 | { | 401 | { |
402 | memset(ib_ah_attr, 0, sizeof *path); | 402 | memset(ib_ah_attr, 0, sizeof *ib_ah_attr); |
403 | ib_ah_attr->port_num = (be32_to_cpu(path->port_pkey) >> 24) & 0x3; | 403 | ib_ah_attr->port_num = (be32_to_cpu(path->port_pkey) >> 24) & 0x3; |
404 | 404 | ||
405 | if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->limits.num_ports) | 405 | if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->limits.num_ports) |
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c index 10684da33d58..61974b0296ca 100644 --- a/drivers/infiniband/hw/mthca/mthca_srq.c +++ b/drivers/infiniband/hw/mthca/mthca_srq.c | |||
@@ -116,11 +116,16 @@ static void mthca_arbel_init_srq_context(struct mthca_dev *dev, | |||
116 | struct mthca_srq *srq, | 116 | struct mthca_srq *srq, |
117 | struct mthca_arbel_srq_context *context) | 117 | struct mthca_arbel_srq_context *context) |
118 | { | 118 | { |
119 | int logsize; | 119 | int logsize, max; |
120 | 120 | ||
121 | memset(context, 0, sizeof *context); | 121 | memset(context, 0, sizeof *context); |
122 | 122 | ||
123 | logsize = ilog2(srq->max); | 123 | /* |
124 | * Put max in a temporary variable to work around gcc bug | ||
125 | * triggered by ilog2() on sparc64. | ||
126 | */ | ||
127 | max = srq->max; | ||
128 | logsize = ilog2(max); | ||
124 | context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn); | 129 | context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn); |
125 | context->lkey = cpu_to_be32(srq->mr.ibmr.lkey); | 130 | context->lkey = cpu_to_be32(srq->mr.ibmr.lkey); |
126 | context->db_index = cpu_to_be32(srq->db_index); | 131 | context->db_index = cpu_to_be32(srq->db_index); |
diff --git a/drivers/infiniband/ulp/ipoib/Kconfig b/drivers/infiniband/ulp/ipoib/Kconfig index c75322d820d4..af78ccc4ce71 100644 --- a/drivers/infiniband/ulp/ipoib/Kconfig +++ b/drivers/infiniband/ulp/ipoib/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config INFINIBAND_IPOIB | 1 | config INFINIBAND_IPOIB |
2 | tristate "IP-over-InfiniBand" | 2 | tristate "IP-over-InfiniBand" |
3 | depends on INFINIBAND && NETDEVICES && INET | 3 | depends on INFINIBAND && NETDEVICES && INET && (IPV6 || IPV6=n) |
4 | ---help--- | 4 | ---help--- |
5 | Support for the IP-over-InfiniBand protocol (IPoIB). This | 5 | Support for the IP-over-InfiniBand protocol (IPoIB). This |
6 | transports IP packets over InfiniBand so you can use your IB | 6 | transports IP packets over InfiniBand so you can use your IB |
@@ -8,6 +8,20 @@ config INFINIBAND_IPOIB | |||
8 | 8 | ||
9 | See Documentation/infiniband/ipoib.txt for more information | 9 | See Documentation/infiniband/ipoib.txt for more information |
10 | 10 | ||
11 | config INFINIBAND_IPOIB_CM | ||
12 | bool "IP-over-InfiniBand Connected Mode support" | ||
13 | depends on INFINIBAND_IPOIB && EXPERIMENTAL | ||
14 | default n | ||
15 | ---help--- | ||
16 | This option enables experimental support for IPoIB connected mode. | ||
17 | After enabling this option, you need to switch to connected mode through | ||
18 | /sys/class/net/ibXXX/mode to actually create connections, and then increase | ||
19 | the interface MTU with e.g. ifconfig ib0 mtu 65520. | ||
20 | |||
21 | WARNING: Enabling connected mode will trigger some | ||
22 | packet drops for multicast and UD mode traffic from this interface, | ||
23 | unless you limit mtu for these destinations to 2044. | ||
24 | |||
11 | config INFINIBAND_IPOIB_DEBUG | 25 | config INFINIBAND_IPOIB_DEBUG |
12 | bool "IP-over-InfiniBand debugging" if EMBEDDED | 26 | bool "IP-over-InfiniBand debugging" if EMBEDDED |
13 | depends on INFINIBAND_IPOIB | 27 | depends on INFINIBAND_IPOIB |
diff --git a/drivers/infiniband/ulp/ipoib/Makefile b/drivers/infiniband/ulp/ipoib/Makefile index 8935e74ae3f8..98ee38e8c2c4 100644 --- a/drivers/infiniband/ulp/ipoib/Makefile +++ b/drivers/infiniband/ulp/ipoib/Makefile | |||
@@ -5,5 +5,6 @@ ib_ipoib-y := ipoib_main.o \ | |||
5 | ipoib_multicast.o \ | 5 | ipoib_multicast.o \ |
6 | ipoib_verbs.o \ | 6 | ipoib_verbs.o \ |
7 | ipoib_vlan.o | 7 | ipoib_vlan.o |
8 | ib_ipoib-$(CONFIG_INFINIBAND_IPOIB_CM) += ipoib_cm.o | ||
8 | ib_ipoib-$(CONFIG_INFINIBAND_IPOIB_DEBUG) += ipoib_fs.o | 9 | ib_ipoib-$(CONFIG_INFINIBAND_IPOIB_DEBUG) += ipoib_fs.o |
9 | 10 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h index 07deee8f81ce..2594db2030b3 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/drivers/infiniband/ulp/ipoib/ipoib.h | |||
@@ -62,6 +62,10 @@ enum { | |||
62 | 62 | ||
63 | IPOIB_ENCAP_LEN = 4, | 63 | IPOIB_ENCAP_LEN = 4, |
64 | 64 | ||
65 | IPOIB_CM_MTU = 0x10000 - 0x10, /* padding to align header to 16 */ | ||
66 | IPOIB_CM_BUF_SIZE = IPOIB_CM_MTU + IPOIB_ENCAP_LEN, | ||
67 | IPOIB_CM_HEAD_SIZE = IPOIB_CM_BUF_SIZE % PAGE_SIZE, | ||
68 | IPOIB_CM_RX_SG = ALIGN(IPOIB_CM_BUF_SIZE, PAGE_SIZE) / PAGE_SIZE, | ||
65 | IPOIB_RX_RING_SIZE = 128, | 69 | IPOIB_RX_RING_SIZE = 128, |
66 | IPOIB_TX_RING_SIZE = 64, | 70 | IPOIB_TX_RING_SIZE = 64, |
67 | IPOIB_MAX_QUEUE_SIZE = 8192, | 71 | IPOIB_MAX_QUEUE_SIZE = 8192, |
@@ -81,6 +85,8 @@ enum { | |||
81 | IPOIB_MCAST_RUN = 6, | 85 | IPOIB_MCAST_RUN = 6, |
82 | IPOIB_STOP_REAPER = 7, | 86 | IPOIB_STOP_REAPER = 7, |
83 | IPOIB_MCAST_STARTED = 8, | 87 | IPOIB_MCAST_STARTED = 8, |
88 | IPOIB_FLAG_NETIF_STOPPED = 9, | ||
89 | IPOIB_FLAG_ADMIN_CM = 10, | ||
84 | 90 | ||
85 | IPOIB_MAX_BACKOFF_SECONDS = 16, | 91 | IPOIB_MAX_BACKOFF_SECONDS = 16, |
86 | 92 | ||
@@ -90,6 +96,13 @@ enum { | |||
90 | IPOIB_MCAST_FLAG_ATTACHED = 3, | 96 | IPOIB_MCAST_FLAG_ATTACHED = 3, |
91 | }; | 97 | }; |
92 | 98 | ||
99 | #define IPOIB_OP_RECV (1ul << 31) | ||
100 | #ifdef CONFIG_INFINIBAND_IPOIB_CM | ||
101 | #define IPOIB_CM_OP_SRQ (1ul << 30) | ||
102 | #else | ||
103 | #define IPOIB_CM_OP_SRQ (0) | ||
104 | #endif | ||
105 | |||
93 | /* structs */ | 106 | /* structs */ |
94 | 107 | ||
95 | struct ipoib_header { | 108 | struct ipoib_header { |
@@ -113,6 +126,59 @@ struct ipoib_tx_buf { | |||
113 | u64 mapping; | 126 | u64 mapping; |
114 | }; | 127 | }; |
115 | 128 | ||
129 | struct ib_cm_id; | ||
130 | |||
131 | struct ipoib_cm_data { | ||
132 | __be32 qpn; /* High byte MUST be ignored on receive */ | ||
133 | __be32 mtu; | ||
134 | }; | ||
135 | |||
136 | struct ipoib_cm_rx { | ||
137 | struct ib_cm_id *id; | ||
138 | struct ib_qp *qp; | ||
139 | struct list_head list; | ||
140 | struct net_device *dev; | ||
141 | unsigned long jiffies; | ||
142 | }; | ||
143 | |||
144 | struct ipoib_cm_tx { | ||
145 | struct ib_cm_id *id; | ||
146 | struct ib_cq *cq; | ||
147 | struct ib_qp *qp; | ||
148 | struct list_head list; | ||
149 | struct net_device *dev; | ||
150 | struct ipoib_neigh *neigh; | ||
151 | struct ipoib_path *path; | ||
152 | struct ipoib_tx_buf *tx_ring; | ||
153 | unsigned tx_head; | ||
154 | unsigned tx_tail; | ||
155 | unsigned long flags; | ||
156 | u32 mtu; | ||
157 | struct ib_wc ibwc[IPOIB_NUM_WC]; | ||
158 | }; | ||
159 | |||
160 | struct ipoib_cm_rx_buf { | ||
161 | struct sk_buff *skb; | ||
162 | u64 mapping[IPOIB_CM_RX_SG]; | ||
163 | }; | ||
164 | |||
165 | struct ipoib_cm_dev_priv { | ||
166 | struct ib_srq *srq; | ||
167 | struct ipoib_cm_rx_buf *srq_ring; | ||
168 | struct ib_cm_id *id; | ||
169 | struct list_head passive_ids; | ||
170 | struct work_struct start_task; | ||
171 | struct work_struct reap_task; | ||
172 | struct work_struct skb_task; | ||
173 | struct delayed_work stale_task; | ||
174 | struct sk_buff_head skb_queue; | ||
175 | struct list_head start_list; | ||
176 | struct list_head reap_list; | ||
177 | struct ib_wc ibwc[IPOIB_NUM_WC]; | ||
178 | struct ib_sge rx_sge[IPOIB_CM_RX_SG]; | ||
179 | struct ib_recv_wr rx_wr; | ||
180 | }; | ||
181 | |||
116 | /* | 182 | /* |
117 | * Device private locking: tx_lock protects members used in TX fast | 183 | * Device private locking: tx_lock protects members used in TX fast |
118 | * path (and we use LLTX so upper layers don't do extra locking). | 184 | * path (and we use LLTX so upper layers don't do extra locking). |
@@ -179,6 +245,10 @@ struct ipoib_dev_priv { | |||
179 | struct list_head child_intfs; | 245 | struct list_head child_intfs; |
180 | struct list_head list; | 246 | struct list_head list; |
181 | 247 | ||
248 | #ifdef CONFIG_INFINIBAND_IPOIB_CM | ||
249 | struct ipoib_cm_dev_priv cm; | ||
250 | #endif | ||
251 | |||
182 | #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG | 252 | #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG |
183 | struct list_head fs_list; | 253 | struct list_head fs_list; |
184 | struct dentry *mcg_dentry; | 254 | struct dentry *mcg_dentry; |
@@ -212,6 +282,9 @@ struct ipoib_path { | |||
212 | 282 | ||
213 | struct ipoib_neigh { | 283 | struct ipoib_neigh { |
214 | struct ipoib_ah *ah; | 284 | struct ipoib_ah *ah; |
285 | #ifdef CONFIG_INFINIBAND_IPOIB_CM | ||
286 | struct ipoib_cm_tx *cm; | ||
287 | #endif | ||
215 | union ib_gid dgid; | 288 | union ib_gid dgid; |
216 | struct sk_buff_head queue; | 289 | struct sk_buff_head queue; |
217 | 290 | ||
@@ -315,6 +388,146 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey); | |||
315 | void ipoib_pkey_poll(struct work_struct *work); | 388 | void ipoib_pkey_poll(struct work_struct *work); |
316 | int ipoib_pkey_dev_delay_open(struct net_device *dev); | 389 | int ipoib_pkey_dev_delay_open(struct net_device *dev); |
317 | 390 | ||
391 | #ifdef CONFIG_INFINIBAND_IPOIB_CM | ||
392 | |||
393 | #define IPOIB_FLAGS_RC 0x80 | ||
394 | #define IPOIB_FLAGS_UC 0x40 | ||
395 | |||
396 | /* We don't support UC connections at the moment */ | ||
397 | #define IPOIB_CM_SUPPORTED(ha) (ha[0] & (IPOIB_FLAGS_RC)) | ||
398 | |||
399 | static inline int ipoib_cm_admin_enabled(struct net_device *dev) | ||
400 | { | ||
401 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
402 | return IPOIB_CM_SUPPORTED(dev->dev_addr) && | ||
403 | test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); | ||
404 | } | ||
405 | |||
406 | static inline int ipoib_cm_enabled(struct net_device *dev, struct neighbour *n) | ||
407 | { | ||
408 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
409 | return IPOIB_CM_SUPPORTED(n->ha) && | ||
410 | test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); | ||
411 | } | ||
412 | |||
413 | static inline int ipoib_cm_up(struct ipoib_neigh *neigh) | ||
414 | |||
415 | { | ||
416 | return test_bit(IPOIB_FLAG_OPER_UP, &neigh->cm->flags); | ||
417 | } | ||
418 | |||
419 | static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh) | ||
420 | { | ||
421 | return neigh->cm; | ||
422 | } | ||
423 | |||
424 | static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx) | ||
425 | { | ||
426 | neigh->cm = tx; | ||
427 | } | ||
428 | |||
429 | void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx); | ||
430 | int ipoib_cm_dev_open(struct net_device *dev); | ||
431 | void ipoib_cm_dev_stop(struct net_device *dev); | ||
432 | int ipoib_cm_dev_init(struct net_device *dev); | ||
433 | int ipoib_cm_add_mode_attr(struct net_device *dev); | ||
434 | void ipoib_cm_dev_cleanup(struct net_device *dev); | ||
435 | struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path, | ||
436 | struct ipoib_neigh *neigh); | ||
437 | void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx); | ||
438 | void ipoib_cm_skb_too_long(struct net_device* dev, struct sk_buff *skb, | ||
439 | unsigned int mtu); | ||
440 | void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc); | ||
441 | #else | ||
442 | |||
443 | struct ipoib_cm_tx; | ||
444 | |||
445 | static inline int ipoib_cm_admin_enabled(struct net_device *dev) | ||
446 | { | ||
447 | return 0; | ||
448 | } | ||
449 | static inline int ipoib_cm_enabled(struct net_device *dev, struct neighbour *n) | ||
450 | |||
451 | { | ||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static inline int ipoib_cm_up(struct ipoib_neigh *neigh) | ||
456 | |||
457 | { | ||
458 | return 0; | ||
459 | } | ||
460 | |||
461 | static inline struct ipoib_cm_tx *ipoib_cm_get(struct ipoib_neigh *neigh) | ||
462 | { | ||
463 | return NULL; | ||
464 | } | ||
465 | |||
466 | static inline void ipoib_cm_set(struct ipoib_neigh *neigh, struct ipoib_cm_tx *tx) | ||
467 | { | ||
468 | } | ||
469 | |||
470 | static inline | ||
471 | void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx) | ||
472 | { | ||
473 | return; | ||
474 | } | ||
475 | |||
476 | static inline | ||
477 | int ipoib_cm_dev_open(struct net_device *dev) | ||
478 | { | ||
479 | return 0; | ||
480 | } | ||
481 | |||
482 | static inline | ||
483 | void ipoib_cm_dev_stop(struct net_device *dev) | ||
484 | { | ||
485 | return; | ||
486 | } | ||
487 | |||
488 | static inline | ||
489 | int ipoib_cm_dev_init(struct net_device *dev) | ||
490 | { | ||
491 | return -ENOSYS; | ||
492 | } | ||
493 | |||
494 | static inline | ||
495 | void ipoib_cm_dev_cleanup(struct net_device *dev) | ||
496 | { | ||
497 | return; | ||
498 | } | ||
499 | |||
500 | static inline | ||
501 | struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path, | ||
502 | struct ipoib_neigh *neigh) | ||
503 | { | ||
504 | return NULL; | ||
505 | } | ||
506 | |||
507 | static inline | ||
508 | void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx) | ||
509 | { | ||
510 | return; | ||
511 | } | ||
512 | |||
513 | static inline | ||
514 | int ipoib_cm_add_mode_attr(struct net_device *dev) | ||
515 | { | ||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | static inline void ipoib_cm_skb_too_long(struct net_device* dev, struct sk_buff *skb, | ||
520 | unsigned int mtu) | ||
521 | { | ||
522 | dev_kfree_skb_any(skb); | ||
523 | } | ||
524 | |||
525 | static inline void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc) | ||
526 | { | ||
527 | } | ||
528 | |||
529 | #endif | ||
530 | |||
318 | #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG | 531 | #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG |
319 | void ipoib_create_debug_files(struct net_device *dev); | 532 | void ipoib_create_debug_files(struct net_device *dev); |
320 | void ipoib_delete_debug_files(struct net_device *dev); | 533 | void ipoib_delete_debug_files(struct net_device *dev); |
@@ -392,4 +605,6 @@ extern int ipoib_debug_level; | |||
392 | 605 | ||
393 | #define IPOIB_GID_ARG(gid) IPOIB_GID_RAW_ARG((gid).raw) | 606 | #define IPOIB_GID_ARG(gid) IPOIB_GID_RAW_ARG((gid).raw) |
394 | 607 | ||
608 | #define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff) | ||
609 | |||
395 | #endif /* _IPOIB_H */ | 610 | #endif /* _IPOIB_H */ |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c new file mode 100644 index 000000000000..2d483874a589 --- /dev/null +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
@@ -0,0 +1,1237 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Mellanox Technologies. All rights reserved | ||
3 | * | ||
4 | * This software is available to you under a choice of one of two | ||
5 | * licenses. You may choose to be licensed under the terms of the GNU | ||
6 | * General Public License (GPL) Version 2, available from the file | ||
7 | * COPYING in the main directory of this source tree, or the | ||
8 | * OpenIB.org BSD license below: | ||
9 | * | ||
10 | * Redistribution and use in source and binary forms, with or | ||
11 | * without modification, are permitted provided that the following | ||
12 | * conditions are met: | ||
13 | * | ||
14 | * - Redistributions of source code must retain the above | ||
15 | * copyright notice, this list of conditions and the following | ||
16 | * disclaimer. | ||
17 | * | ||
18 | * - Redistributions in binary form must reproduce the above | ||
19 | * copyright notice, this list of conditions and the following | ||
20 | * disclaimer in the documentation and/or other materials | ||
21 | * provided with the distribution. | ||
22 | * | ||
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
27 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
28 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
30 | * SOFTWARE. | ||
31 | * | ||
32 | * $Id$ | ||
33 | */ | ||
34 | |||
35 | #include <rdma/ib_cm.h> | ||
36 | #include <rdma/ib_cache.h> | ||
37 | #include <net/dst.h> | ||
38 | #include <net/icmp.h> | ||
39 | #include <linux/icmpv6.h> | ||
40 | |||
41 | #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA | ||
42 | static int data_debug_level; | ||
43 | |||
44 | module_param_named(cm_data_debug_level, data_debug_level, int, 0644); | ||
45 | MODULE_PARM_DESC(cm_data_debug_level, | ||
46 | "Enable data path debug tracing for connected mode if > 0"); | ||
47 | #endif | ||
48 | |||
49 | #include "ipoib.h" | ||
50 | |||
51 | #define IPOIB_CM_IETF_ID 0x1000000000000000ULL | ||
52 | |||
53 | #define IPOIB_CM_RX_UPDATE_TIME (256 * HZ) | ||
54 | #define IPOIB_CM_RX_TIMEOUT (2 * 256 * HZ) | ||
55 | #define IPOIB_CM_RX_DELAY (3 * 256 * HZ) | ||
56 | #define IPOIB_CM_RX_UPDATE_MASK (0x3) | ||
57 | |||
58 | struct ipoib_cm_id { | ||
59 | struct ib_cm_id *id; | ||
60 | int flags; | ||
61 | u32 remote_qpn; | ||
62 | u32 remote_mtu; | ||
63 | }; | ||
64 | |||
65 | static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id, | ||
66 | struct ib_cm_event *event); | ||
67 | |||
68 | static void ipoib_cm_dma_unmap_rx(struct ipoib_dev_priv *priv, | ||
69 | u64 mapping[IPOIB_CM_RX_SG]) | ||
70 | { | ||
71 | int i; | ||
72 | |||
73 | ib_dma_unmap_single(priv->ca, mapping[0], IPOIB_CM_HEAD_SIZE, DMA_FROM_DEVICE); | ||
74 | |||
75 | for (i = 0; i < IPOIB_CM_RX_SG - 1; ++i) | ||
76 | ib_dma_unmap_single(priv->ca, mapping[i + 1], PAGE_SIZE, DMA_FROM_DEVICE); | ||
77 | } | ||
78 | |||
79 | static int ipoib_cm_post_receive(struct net_device *dev, int id) | ||
80 | { | ||
81 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
82 | struct ib_recv_wr *bad_wr; | ||
83 | int i, ret; | ||
84 | |||
85 | priv->cm.rx_wr.wr_id = id | IPOIB_CM_OP_SRQ; | ||
86 | |||
87 | for (i = 0; i < IPOIB_CM_RX_SG; ++i) | ||
88 | priv->cm.rx_sge[i].addr = priv->cm.srq_ring[id].mapping[i]; | ||
89 | |||
90 | ret = ib_post_srq_recv(priv->cm.srq, &priv->cm.rx_wr, &bad_wr); | ||
91 | if (unlikely(ret)) { | ||
92 | ipoib_warn(priv, "post srq failed for buf %d (%d)\n", id, ret); | ||
93 | ipoib_cm_dma_unmap_rx(priv, priv->cm.srq_ring[id].mapping); | ||
94 | dev_kfree_skb_any(priv->cm.srq_ring[id].skb); | ||
95 | priv->cm.srq_ring[id].skb = NULL; | ||
96 | } | ||
97 | |||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | static int ipoib_cm_alloc_rx_skb(struct net_device *dev, int id, | ||
102 | u64 mapping[IPOIB_CM_RX_SG]) | ||
103 | { | ||
104 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
105 | struct sk_buff *skb; | ||
106 | int i; | ||
107 | |||
108 | skb = dev_alloc_skb(IPOIB_CM_HEAD_SIZE + 12); | ||
109 | if (unlikely(!skb)) | ||
110 | return -ENOMEM; | ||
111 | |||
112 | /* | ||
113 | * IPoIB adds a 4 byte header. So we need 12 more bytes to align the | ||
114 | * IP header to a multiple of 16. | ||
115 | */ | ||
116 | skb_reserve(skb, 12); | ||
117 | |||
118 | mapping[0] = ib_dma_map_single(priv->ca, skb->data, IPOIB_CM_HEAD_SIZE, | ||
119 | DMA_FROM_DEVICE); | ||
120 | if (unlikely(ib_dma_mapping_error(priv->ca, mapping[0]))) { | ||
121 | dev_kfree_skb_any(skb); | ||
122 | return -EIO; | ||
123 | } | ||
124 | |||
125 | for (i = 0; i < IPOIB_CM_RX_SG - 1; i++) { | ||
126 | struct page *page = alloc_page(GFP_ATOMIC); | ||
127 | |||
128 | if (!page) | ||
129 | goto partial_error; | ||
130 | skb_fill_page_desc(skb, i, page, 0, PAGE_SIZE); | ||
131 | |||
132 | mapping[i + 1] = ib_dma_map_page(priv->ca, skb_shinfo(skb)->frags[i].page, | ||
133 | 0, PAGE_SIZE, DMA_TO_DEVICE); | ||
134 | if (unlikely(ib_dma_mapping_error(priv->ca, mapping[i + 1]))) | ||
135 | goto partial_error; | ||
136 | } | ||
137 | |||
138 | priv->cm.srq_ring[id].skb = skb; | ||
139 | return 0; | ||
140 | |||
141 | partial_error: | ||
142 | |||
143 | ib_dma_unmap_single(priv->ca, mapping[0], IPOIB_CM_HEAD_SIZE, DMA_FROM_DEVICE); | ||
144 | |||
145 | for (; i >= 0; --i) | ||
146 | ib_dma_unmap_single(priv->ca, mapping[i + 1], PAGE_SIZE, DMA_FROM_DEVICE); | ||
147 | |||
148 | kfree_skb(skb); | ||
149 | return -ENOMEM; | ||
150 | } | ||
151 | |||
152 | static struct ib_qp *ipoib_cm_create_rx_qp(struct net_device *dev, | ||
153 | struct ipoib_cm_rx *p) | ||
154 | { | ||
155 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
156 | struct ib_qp_init_attr attr = { | ||
157 | .send_cq = priv->cq, /* does not matter, we never send anything */ | ||
158 | .recv_cq = priv->cq, | ||
159 | .srq = priv->cm.srq, | ||
160 | .cap.max_send_wr = 1, /* FIXME: 0 Seems not to work */ | ||
161 | .cap.max_send_sge = 1, /* FIXME: 0 Seems not to work */ | ||
162 | .sq_sig_type = IB_SIGNAL_ALL_WR, | ||
163 | .qp_type = IB_QPT_RC, | ||
164 | .qp_context = p, | ||
165 | }; | ||
166 | return ib_create_qp(priv->pd, &attr); | ||
167 | } | ||
168 | |||
169 | static int ipoib_cm_modify_rx_qp(struct net_device *dev, | ||
170 | struct ib_cm_id *cm_id, struct ib_qp *qp, | ||
171 | unsigned psn) | ||
172 | { | ||
173 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
174 | struct ib_qp_attr qp_attr; | ||
175 | int qp_attr_mask, ret; | ||
176 | |||
177 | qp_attr.qp_state = IB_QPS_INIT; | ||
178 | ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask); | ||
179 | if (ret) { | ||
180 | ipoib_warn(priv, "failed to init QP attr for INIT: %d\n", ret); | ||
181 | return ret; | ||
182 | } | ||
183 | ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask); | ||
184 | if (ret) { | ||
185 | ipoib_warn(priv, "failed to modify QP to INIT: %d\n", ret); | ||
186 | return ret; | ||
187 | } | ||
188 | qp_attr.qp_state = IB_QPS_RTR; | ||
189 | ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask); | ||
190 | if (ret) { | ||
191 | ipoib_warn(priv, "failed to init QP attr for RTR: %d\n", ret); | ||
192 | return ret; | ||
193 | } | ||
194 | qp_attr.rq_psn = psn; | ||
195 | ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask); | ||
196 | if (ret) { | ||
197 | ipoib_warn(priv, "failed to modify QP to RTR: %d\n", ret); | ||
198 | return ret; | ||
199 | } | ||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static int ipoib_cm_send_rep(struct net_device *dev, struct ib_cm_id *cm_id, | ||
204 | struct ib_qp *qp, struct ib_cm_req_event_param *req, | ||
205 | unsigned psn) | ||
206 | { | ||
207 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
208 | struct ipoib_cm_data data = {}; | ||
209 | struct ib_cm_rep_param rep = {}; | ||
210 | |||
211 | data.qpn = cpu_to_be32(priv->qp->qp_num); | ||
212 | data.mtu = cpu_to_be32(IPOIB_CM_BUF_SIZE); | ||
213 | |||
214 | rep.private_data = &data; | ||
215 | rep.private_data_len = sizeof data; | ||
216 | rep.flow_control = 0; | ||
217 | rep.rnr_retry_count = req->rnr_retry_count; | ||
218 | rep.target_ack_delay = 20; /* FIXME */ | ||
219 | rep.srq = 1; | ||
220 | rep.qp_num = qp->qp_num; | ||
221 | rep.starting_psn = psn; | ||
222 | return ib_send_cm_rep(cm_id, &rep); | ||
223 | } | ||
224 | |||
225 | static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) | ||
226 | { | ||
227 | struct net_device *dev = cm_id->context; | ||
228 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
229 | struct ipoib_cm_rx *p; | ||
230 | unsigned long flags; | ||
231 | unsigned psn; | ||
232 | int ret; | ||
233 | |||
234 | ipoib_dbg(priv, "REQ arrived\n"); | ||
235 | p = kzalloc(sizeof *p, GFP_KERNEL); | ||
236 | if (!p) | ||
237 | return -ENOMEM; | ||
238 | p->dev = dev; | ||
239 | p->id = cm_id; | ||
240 | p->qp = ipoib_cm_create_rx_qp(dev, p); | ||
241 | if (IS_ERR(p->qp)) { | ||
242 | ret = PTR_ERR(p->qp); | ||
243 | goto err_qp; | ||
244 | } | ||
245 | |||
246 | psn = random32() & 0xffffff; | ||
247 | ret = ipoib_cm_modify_rx_qp(dev, cm_id, p->qp, psn); | ||
248 | if (ret) | ||
249 | goto err_modify; | ||
250 | |||
251 | ret = ipoib_cm_send_rep(dev, cm_id, p->qp, &event->param.req_rcvd, psn); | ||
252 | if (ret) { | ||
253 | ipoib_warn(priv, "failed to send REP: %d\n", ret); | ||
254 | goto err_rep; | ||
255 | } | ||
256 | |||
257 | cm_id->context = p; | ||
258 | p->jiffies = jiffies; | ||
259 | spin_lock_irqsave(&priv->lock, flags); | ||
260 | list_add(&p->list, &priv->cm.passive_ids); | ||
261 | spin_unlock_irqrestore(&priv->lock, flags); | ||
262 | queue_delayed_work(ipoib_workqueue, | ||
263 | &priv->cm.stale_task, IPOIB_CM_RX_DELAY); | ||
264 | return 0; | ||
265 | |||
266 | err_rep: | ||
267 | err_modify: | ||
268 | ib_destroy_qp(p->qp); | ||
269 | err_qp: | ||
270 | kfree(p); | ||
271 | return ret; | ||
272 | } | ||
273 | |||
274 | static int ipoib_cm_rx_handler(struct ib_cm_id *cm_id, | ||
275 | struct ib_cm_event *event) | ||
276 | { | ||
277 | struct ipoib_cm_rx *p; | ||
278 | struct ipoib_dev_priv *priv; | ||
279 | unsigned long flags; | ||
280 | int ret; | ||
281 | |||
282 | switch (event->event) { | ||
283 | case IB_CM_REQ_RECEIVED: | ||
284 | return ipoib_cm_req_handler(cm_id, event); | ||
285 | case IB_CM_DREQ_RECEIVED: | ||
286 | p = cm_id->context; | ||
287 | ib_send_cm_drep(cm_id, NULL, 0); | ||
288 | /* Fall through */ | ||
289 | case IB_CM_REJ_RECEIVED: | ||
290 | p = cm_id->context; | ||
291 | priv = netdev_priv(p->dev); | ||
292 | spin_lock_irqsave(&priv->lock, flags); | ||
293 | if (list_empty(&p->list)) | ||
294 | ret = 0; /* Connection is going away already. */ | ||
295 | else { | ||
296 | list_del_init(&p->list); | ||
297 | ret = -ECONNRESET; | ||
298 | } | ||
299 | spin_unlock_irqrestore(&priv->lock, flags); | ||
300 | if (ret) { | ||
301 | ib_destroy_qp(p->qp); | ||
302 | kfree(p); | ||
303 | return ret; | ||
304 | } | ||
305 | return 0; | ||
306 | default: | ||
307 | return 0; | ||
308 | } | ||
309 | } | ||
310 | /* Adjust length of skb with fragments to match received data */ | ||
311 | static void skb_put_frags(struct sk_buff *skb, unsigned int hdr_space, | ||
312 | unsigned int length) | ||
313 | { | ||
314 | int i, num_frags; | ||
315 | unsigned int size; | ||
316 | |||
317 | /* put header into skb */ | ||
318 | size = min(length, hdr_space); | ||
319 | skb->tail += size; | ||
320 | skb->len += size; | ||
321 | length -= size; | ||
322 | |||
323 | num_frags = skb_shinfo(skb)->nr_frags; | ||
324 | for (i = 0; i < num_frags; i++) { | ||
325 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
326 | |||
327 | if (length == 0) { | ||
328 | /* don't need this page */ | ||
329 | __free_page(frag->page); | ||
330 | --skb_shinfo(skb)->nr_frags; | ||
331 | } else { | ||
332 | size = min(length, (unsigned) PAGE_SIZE); | ||
333 | |||
334 | frag->size = size; | ||
335 | skb->data_len += size; | ||
336 | skb->truesize += size; | ||
337 | skb->len += size; | ||
338 | length -= size; | ||
339 | } | ||
340 | } | ||
341 | } | ||
342 | |||
343 | void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc) | ||
344 | { | ||
345 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
346 | unsigned int wr_id = wc->wr_id & ~IPOIB_CM_OP_SRQ; | ||
347 | struct sk_buff *skb; | ||
348 | struct ipoib_cm_rx *p; | ||
349 | unsigned long flags; | ||
350 | u64 mapping[IPOIB_CM_RX_SG]; | ||
351 | |||
352 | ipoib_dbg_data(priv, "cm recv completion: id %d, op %d, status: %d\n", | ||
353 | wr_id, wc->opcode, wc->status); | ||
354 | |||
355 | if (unlikely(wr_id >= ipoib_recvq_size)) { | ||
356 | ipoib_warn(priv, "cm recv completion event with wrid %d (> %d)\n", | ||
357 | wr_id, ipoib_recvq_size); | ||
358 | return; | ||
359 | } | ||
360 | |||
361 | skb = priv->cm.srq_ring[wr_id].skb; | ||
362 | |||
363 | if (unlikely(wc->status != IB_WC_SUCCESS)) { | ||
364 | ipoib_dbg(priv, "cm recv error " | ||
365 | "(status=%d, wrid=%d vend_err %x)\n", | ||
366 | wc->status, wr_id, wc->vendor_err); | ||
367 | ++priv->stats.rx_dropped; | ||
368 | goto repost; | ||
369 | } | ||
370 | |||
371 | if (!likely(wr_id & IPOIB_CM_RX_UPDATE_MASK)) { | ||
372 | p = wc->qp->qp_context; | ||
373 | if (time_after_eq(jiffies, p->jiffies + IPOIB_CM_RX_UPDATE_TIME)) { | ||
374 | spin_lock_irqsave(&priv->lock, flags); | ||
375 | p->jiffies = jiffies; | ||
376 | /* Move this entry to list head, but do | ||
377 | * not re-add it if it has been removed. */ | ||
378 | if (!list_empty(&p->list)) | ||
379 | list_move(&p->list, &priv->cm.passive_ids); | ||
380 | spin_unlock_irqrestore(&priv->lock, flags); | ||
381 | queue_delayed_work(ipoib_workqueue, | ||
382 | &priv->cm.stale_task, IPOIB_CM_RX_DELAY); | ||
383 | } | ||
384 | } | ||
385 | |||
386 | if (unlikely(ipoib_cm_alloc_rx_skb(dev, wr_id, mapping))) { | ||
387 | /* | ||
388 | * If we can't allocate a new RX buffer, dump | ||
389 | * this packet and reuse the old buffer. | ||
390 | */ | ||
391 | ipoib_dbg(priv, "failed to allocate receive buffer %d\n", wr_id); | ||
392 | ++priv->stats.rx_dropped; | ||
393 | goto repost; | ||
394 | } | ||
395 | |||
396 | ipoib_cm_dma_unmap_rx(priv, priv->cm.srq_ring[wr_id].mapping); | ||
397 | memcpy(priv->cm.srq_ring[wr_id].mapping, mapping, sizeof mapping); | ||
398 | |||
399 | ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n", | ||
400 | wc->byte_len, wc->slid); | ||
401 | |||
402 | skb_put_frags(skb, IPOIB_CM_HEAD_SIZE, wc->byte_len); | ||
403 | |||
404 | skb->protocol = ((struct ipoib_header *) skb->data)->proto; | ||
405 | skb->mac.raw = skb->data; | ||
406 | skb_pull(skb, IPOIB_ENCAP_LEN); | ||
407 | |||
408 | dev->last_rx = jiffies; | ||
409 | ++priv->stats.rx_packets; | ||
410 | priv->stats.rx_bytes += skb->len; | ||
411 | |||
412 | skb->dev = dev; | ||
413 | /* XXX get correct PACKET_ type here */ | ||
414 | skb->pkt_type = PACKET_HOST; | ||
415 | netif_rx_ni(skb); | ||
416 | |||
417 | repost: | ||
418 | if (unlikely(ipoib_cm_post_receive(dev, wr_id))) | ||
419 | ipoib_warn(priv, "ipoib_cm_post_receive failed " | ||
420 | "for buf %d\n", wr_id); | ||
421 | } | ||
422 | |||
423 | static inline int post_send(struct ipoib_dev_priv *priv, | ||
424 | struct ipoib_cm_tx *tx, | ||
425 | unsigned int wr_id, | ||
426 | u64 addr, int len) | ||
427 | { | ||
428 | struct ib_send_wr *bad_wr; | ||
429 | |||
430 | priv->tx_sge.addr = addr; | ||
431 | priv->tx_sge.length = len; | ||
432 | |||
433 | priv->tx_wr.wr_id = wr_id; | ||
434 | |||
435 | return ib_post_send(tx->qp, &priv->tx_wr, &bad_wr); | ||
436 | } | ||
437 | |||
438 | void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx) | ||
439 | { | ||
440 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
441 | struct ipoib_tx_buf *tx_req; | ||
442 | u64 addr; | ||
443 | |||
444 | if (unlikely(skb->len > tx->mtu)) { | ||
445 | ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n", | ||
446 | skb->len, tx->mtu); | ||
447 | ++priv->stats.tx_dropped; | ||
448 | ++priv->stats.tx_errors; | ||
449 | ipoib_cm_skb_too_long(dev, skb, tx->mtu - INFINIBAND_ALEN); | ||
450 | return; | ||
451 | } | ||
452 | |||
453 | ipoib_dbg_data(priv, "sending packet: head 0x%x length %d connection 0x%x\n", | ||
454 | tx->tx_head, skb->len, tx->qp->qp_num); | ||
455 | |||
456 | /* | ||
457 | * We put the skb into the tx_ring _before_ we call post_send() | ||
458 | * because it's entirely possible that the completion handler will | ||
459 | * run before we execute anything after the post_send(). That | ||
460 | * means we have to make sure everything is properly recorded and | ||
461 | * our state is consistent before we call post_send(). | ||
462 | */ | ||
463 | tx_req = &tx->tx_ring[tx->tx_head & (ipoib_sendq_size - 1)]; | ||
464 | tx_req->skb = skb; | ||
465 | addr = ib_dma_map_single(priv->ca, skb->data, skb->len, DMA_TO_DEVICE); | ||
466 | if (unlikely(ib_dma_mapping_error(priv->ca, addr))) { | ||
467 | ++priv->stats.tx_errors; | ||
468 | dev_kfree_skb_any(skb); | ||
469 | return; | ||
470 | } | ||
471 | |||
472 | tx_req->mapping = addr; | ||
473 | |||
474 | if (unlikely(post_send(priv, tx, tx->tx_head & (ipoib_sendq_size - 1), | ||
475 | addr, skb->len))) { | ||
476 | ipoib_warn(priv, "post_send failed\n"); | ||
477 | ++priv->stats.tx_errors; | ||
478 | ib_dma_unmap_single(priv->ca, addr, skb->len, DMA_TO_DEVICE); | ||
479 | dev_kfree_skb_any(skb); | ||
480 | } else { | ||
481 | dev->trans_start = jiffies; | ||
482 | ++tx->tx_head; | ||
483 | |||
484 | if (tx->tx_head - tx->tx_tail == ipoib_sendq_size) { | ||
485 | ipoib_dbg(priv, "TX ring 0x%x full, stopping kernel net queue\n", | ||
486 | tx->qp->qp_num); | ||
487 | netif_stop_queue(dev); | ||
488 | set_bit(IPOIB_FLAG_NETIF_STOPPED, &tx->flags); | ||
489 | } | ||
490 | } | ||
491 | } | ||
492 | |||
493 | static void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ipoib_cm_tx *tx, | ||
494 | struct ib_wc *wc) | ||
495 | { | ||
496 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
497 | unsigned int wr_id = wc->wr_id; | ||
498 | struct ipoib_tx_buf *tx_req; | ||
499 | unsigned long flags; | ||
500 | |||
501 | ipoib_dbg_data(priv, "cm send completion: id %d, op %d, status: %d\n", | ||
502 | wr_id, wc->opcode, wc->status); | ||
503 | |||
504 | if (unlikely(wr_id >= ipoib_sendq_size)) { | ||
505 | ipoib_warn(priv, "cm send completion event with wrid %d (> %d)\n", | ||
506 | wr_id, ipoib_sendq_size); | ||
507 | return; | ||
508 | } | ||
509 | |||
510 | tx_req = &tx->tx_ring[wr_id]; | ||
511 | |||
512 | ib_dma_unmap_single(priv->ca, tx_req->mapping, tx_req->skb->len, DMA_TO_DEVICE); | ||
513 | |||
514 | /* FIXME: is this right? Shouldn't we only increment on success? */ | ||
515 | ++priv->stats.tx_packets; | ||
516 | priv->stats.tx_bytes += tx_req->skb->len; | ||
517 | |||
518 | dev_kfree_skb_any(tx_req->skb); | ||
519 | |||
520 | spin_lock_irqsave(&priv->tx_lock, flags); | ||
521 | ++tx->tx_tail; | ||
522 | if (unlikely(test_bit(IPOIB_FLAG_NETIF_STOPPED, &tx->flags)) && | ||
523 | tx->tx_head - tx->tx_tail <= ipoib_sendq_size >> 1) { | ||
524 | clear_bit(IPOIB_FLAG_NETIF_STOPPED, &tx->flags); | ||
525 | netif_wake_queue(dev); | ||
526 | } | ||
527 | |||
528 | if (wc->status != IB_WC_SUCCESS && | ||
529 | wc->status != IB_WC_WR_FLUSH_ERR) { | ||
530 | struct ipoib_neigh *neigh; | ||
531 | |||
532 | ipoib_dbg(priv, "failed cm send event " | ||
533 | "(status=%d, wrid=%d vend_err %x)\n", | ||
534 | wc->status, wr_id, wc->vendor_err); | ||
535 | |||
536 | spin_lock(&priv->lock); | ||
537 | neigh = tx->neigh; | ||
538 | |||
539 | if (neigh) { | ||
540 | neigh->cm = NULL; | ||
541 | list_del(&neigh->list); | ||
542 | if (neigh->ah) | ||
543 | ipoib_put_ah(neigh->ah); | ||
544 | ipoib_neigh_free(dev, neigh); | ||
545 | |||
546 | tx->neigh = NULL; | ||
547 | } | ||
548 | |||
549 | /* queue would be re-started anyway when TX is destroyed, | ||
550 | * but it makes sense to do it ASAP here. */ | ||
551 | if (test_and_clear_bit(IPOIB_FLAG_NETIF_STOPPED, &tx->flags)) | ||
552 | netif_wake_queue(dev); | ||
553 | |||
554 | if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &tx->flags)) { | ||
555 | list_move(&tx->list, &priv->cm.reap_list); | ||
556 | queue_work(ipoib_workqueue, &priv->cm.reap_task); | ||
557 | } | ||
558 | |||
559 | clear_bit(IPOIB_FLAG_OPER_UP, &tx->flags); | ||
560 | |||
561 | spin_unlock(&priv->lock); | ||
562 | } | ||
563 | |||
564 | spin_unlock_irqrestore(&priv->tx_lock, flags); | ||
565 | } | ||
566 | |||
567 | static void ipoib_cm_tx_completion(struct ib_cq *cq, void *tx_ptr) | ||
568 | { | ||
569 | struct ipoib_cm_tx *tx = tx_ptr; | ||
570 | int n, i; | ||
571 | |||
572 | ib_req_notify_cq(cq, IB_CQ_NEXT_COMP); | ||
573 | do { | ||
574 | n = ib_poll_cq(cq, IPOIB_NUM_WC, tx->ibwc); | ||
575 | for (i = 0; i < n; ++i) | ||
576 | ipoib_cm_handle_tx_wc(tx->dev, tx, tx->ibwc + i); | ||
577 | } while (n == IPOIB_NUM_WC); | ||
578 | } | ||
579 | |||
580 | int ipoib_cm_dev_open(struct net_device *dev) | ||
581 | { | ||
582 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
583 | int ret; | ||
584 | |||
585 | if (!IPOIB_CM_SUPPORTED(dev->dev_addr)) | ||
586 | return 0; | ||
587 | |||
588 | priv->cm.id = ib_create_cm_id(priv->ca, ipoib_cm_rx_handler, dev); | ||
589 | if (IS_ERR(priv->cm.id)) { | ||
590 | printk(KERN_WARNING "%s: failed to create CM ID\n", priv->ca->name); | ||
591 | return IS_ERR(priv->cm.id); | ||
592 | } | ||
593 | |||
594 | ret = ib_cm_listen(priv->cm.id, cpu_to_be64(IPOIB_CM_IETF_ID | priv->qp->qp_num), | ||
595 | 0, NULL); | ||
596 | if (ret) { | ||
597 | printk(KERN_WARNING "%s: failed to listen on ID 0x%llx\n", priv->ca->name, | ||
598 | IPOIB_CM_IETF_ID | priv->qp->qp_num); | ||
599 | ib_destroy_cm_id(priv->cm.id); | ||
600 | return ret; | ||
601 | } | ||
602 | return 0; | ||
603 | } | ||
604 | |||
605 | void ipoib_cm_dev_stop(struct net_device *dev) | ||
606 | { | ||
607 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
608 | struct ipoib_cm_rx *p; | ||
609 | unsigned long flags; | ||
610 | |||
611 | if (!IPOIB_CM_SUPPORTED(dev->dev_addr)) | ||
612 | return; | ||
613 | |||
614 | ib_destroy_cm_id(priv->cm.id); | ||
615 | spin_lock_irqsave(&priv->lock, flags); | ||
616 | while (!list_empty(&priv->cm.passive_ids)) { | ||
617 | p = list_entry(priv->cm.passive_ids.next, typeof(*p), list); | ||
618 | list_del_init(&p->list); | ||
619 | spin_unlock_irqrestore(&priv->lock, flags); | ||
620 | ib_destroy_cm_id(p->id); | ||
621 | ib_destroy_qp(p->qp); | ||
622 | kfree(p); | ||
623 | spin_lock_irqsave(&priv->lock, flags); | ||
624 | } | ||
625 | spin_unlock_irqrestore(&priv->lock, flags); | ||
626 | |||
627 | cancel_delayed_work(&priv->cm.stale_task); | ||
628 | } | ||
629 | |||
630 | static int ipoib_cm_rep_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) | ||
631 | { | ||
632 | struct ipoib_cm_tx *p = cm_id->context; | ||
633 | struct ipoib_dev_priv *priv = netdev_priv(p->dev); | ||
634 | struct ipoib_cm_data *data = event->private_data; | ||
635 | struct sk_buff_head skqueue; | ||
636 | struct ib_qp_attr qp_attr; | ||
637 | int qp_attr_mask, ret; | ||
638 | struct sk_buff *skb; | ||
639 | unsigned long flags; | ||
640 | |||
641 | p->mtu = be32_to_cpu(data->mtu); | ||
642 | |||
643 | if (p->mtu < priv->dev->mtu + IPOIB_ENCAP_LEN) { | ||
644 | ipoib_warn(priv, "Rejecting connection: mtu %d < device mtu %d + 4\n", | ||
645 | p->mtu, priv->dev->mtu); | ||
646 | return -EINVAL; | ||
647 | } | ||
648 | |||
649 | qp_attr.qp_state = IB_QPS_RTR; | ||
650 | ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask); | ||
651 | if (ret) { | ||
652 | ipoib_warn(priv, "failed to init QP attr for RTR: %d\n", ret); | ||
653 | return ret; | ||
654 | } | ||
655 | |||
656 | qp_attr.rq_psn = 0 /* FIXME */; | ||
657 | ret = ib_modify_qp(p->qp, &qp_attr, qp_attr_mask); | ||
658 | if (ret) { | ||
659 | ipoib_warn(priv, "failed to modify QP to RTR: %d\n", ret); | ||
660 | return ret; | ||
661 | } | ||
662 | |||
663 | qp_attr.qp_state = IB_QPS_RTS; | ||
664 | ret = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask); | ||
665 | if (ret) { | ||
666 | ipoib_warn(priv, "failed to init QP attr for RTS: %d\n", ret); | ||
667 | return ret; | ||
668 | } | ||
669 | ret = ib_modify_qp(p->qp, &qp_attr, qp_attr_mask); | ||
670 | if (ret) { | ||
671 | ipoib_warn(priv, "failed to modify QP to RTS: %d\n", ret); | ||
672 | return ret; | ||
673 | } | ||
674 | |||
675 | skb_queue_head_init(&skqueue); | ||
676 | |||
677 | spin_lock_irqsave(&priv->lock, flags); | ||
678 | set_bit(IPOIB_FLAG_OPER_UP, &p->flags); | ||
679 | if (p->neigh) | ||
680 | while ((skb = __skb_dequeue(&p->neigh->queue))) | ||
681 | __skb_queue_tail(&skqueue, skb); | ||
682 | spin_unlock_irqrestore(&priv->lock, flags); | ||
683 | |||
684 | while ((skb = __skb_dequeue(&skqueue))) { | ||
685 | skb->dev = p->dev; | ||
686 | if (dev_queue_xmit(skb)) | ||
687 | ipoib_warn(priv, "dev_queue_xmit failed " | ||
688 | "to requeue packet\n"); | ||
689 | } | ||
690 | |||
691 | ret = ib_send_cm_rtu(cm_id, NULL, 0); | ||
692 | if (ret) { | ||
693 | ipoib_warn(priv, "failed to send RTU: %d\n", ret); | ||
694 | return ret; | ||
695 | } | ||
696 | return 0; | ||
697 | } | ||
698 | |||
699 | static struct ib_qp *ipoib_cm_create_tx_qp(struct net_device *dev, struct ib_cq *cq) | ||
700 | { | ||
701 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
702 | struct ib_qp_init_attr attr = {}; | ||
703 | attr.recv_cq = priv->cq; | ||
704 | attr.srq = priv->cm.srq; | ||
705 | attr.cap.max_send_wr = ipoib_sendq_size; | ||
706 | attr.cap.max_send_sge = 1; | ||
707 | attr.sq_sig_type = IB_SIGNAL_ALL_WR; | ||
708 | attr.qp_type = IB_QPT_RC; | ||
709 | attr.send_cq = cq; | ||
710 | return ib_create_qp(priv->pd, &attr); | ||
711 | } | ||
712 | |||
713 | static int ipoib_cm_send_req(struct net_device *dev, | ||
714 | struct ib_cm_id *id, struct ib_qp *qp, | ||
715 | u32 qpn, | ||
716 | struct ib_sa_path_rec *pathrec) | ||
717 | { | ||
718 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
719 | struct ipoib_cm_data data = {}; | ||
720 | struct ib_cm_req_param req = {}; | ||
721 | |||
722 | data.qpn = cpu_to_be32(priv->qp->qp_num); | ||
723 | data.mtu = cpu_to_be32(IPOIB_CM_BUF_SIZE); | ||
724 | |||
725 | req.primary_path = pathrec; | ||
726 | req.alternate_path = NULL; | ||
727 | req.service_id = cpu_to_be64(IPOIB_CM_IETF_ID | qpn); | ||
728 | req.qp_num = qp->qp_num; | ||
729 | req.qp_type = qp->qp_type; | ||
730 | req.private_data = &data; | ||
731 | req.private_data_len = sizeof data; | ||
732 | req.flow_control = 0; | ||
733 | |||
734 | req.starting_psn = 0; /* FIXME */ | ||
735 | |||
736 | /* | ||
737 | * Pick some arbitrary defaults here; we could make these | ||
738 | * module parameters if anyone cared about setting them. | ||
739 | */ | ||
740 | req.responder_resources = 4; | ||
741 | req.remote_cm_response_timeout = 20; | ||
742 | req.local_cm_response_timeout = 20; | ||
743 | req.retry_count = 0; /* RFC draft warns against retries */ | ||
744 | req.rnr_retry_count = 0; /* RFC draft warns against retries */ | ||
745 | req.max_cm_retries = 15; | ||
746 | req.srq = 1; | ||
747 | return ib_send_cm_req(id, &req); | ||
748 | } | ||
749 | |||
750 | static int ipoib_cm_modify_tx_init(struct net_device *dev, | ||
751 | struct ib_cm_id *cm_id, struct ib_qp *qp) | ||
752 | { | ||
753 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
754 | struct ib_qp_attr qp_attr; | ||
755 | int qp_attr_mask, ret; | ||
756 | ret = ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &qp_attr.pkey_index); | ||
757 | if (ret) { | ||
758 | ipoib_warn(priv, "pkey 0x%x not in cache: %d\n", priv->pkey, ret); | ||
759 | return ret; | ||
760 | } | ||
761 | |||
762 | qp_attr.qp_state = IB_QPS_INIT; | ||
763 | qp_attr.qp_access_flags = IB_ACCESS_LOCAL_WRITE; | ||
764 | qp_attr.port_num = priv->port; | ||
765 | qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS | IB_QP_PKEY_INDEX | IB_QP_PORT; | ||
766 | |||
767 | ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask); | ||
768 | if (ret) { | ||
769 | ipoib_warn(priv, "failed to modify tx QP to INIT: %d\n", ret); | ||
770 | return ret; | ||
771 | } | ||
772 | return 0; | ||
773 | } | ||
774 | |||
775 | static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, | ||
776 | struct ib_sa_path_rec *pathrec) | ||
777 | { | ||
778 | struct ipoib_dev_priv *priv = netdev_priv(p->dev); | ||
779 | int ret; | ||
780 | |||
781 | p->tx_ring = kzalloc(ipoib_sendq_size * sizeof *p->tx_ring, | ||
782 | GFP_KERNEL); | ||
783 | if (!p->tx_ring) { | ||
784 | ipoib_warn(priv, "failed to allocate tx ring\n"); | ||
785 | ret = -ENOMEM; | ||
786 | goto err_tx; | ||
787 | } | ||
788 | |||
789 | p->cq = ib_create_cq(priv->ca, ipoib_cm_tx_completion, NULL, p, | ||
790 | ipoib_sendq_size + 1); | ||
791 | if (IS_ERR(p->cq)) { | ||
792 | ret = PTR_ERR(p->cq); | ||
793 | ipoib_warn(priv, "failed to allocate tx cq: %d\n", ret); | ||
794 | goto err_cq; | ||
795 | } | ||
796 | |||
797 | ret = ib_req_notify_cq(p->cq, IB_CQ_NEXT_COMP); | ||
798 | if (ret) { | ||
799 | ipoib_warn(priv, "failed to request completion notification: %d\n", ret); | ||
800 | goto err_req_notify; | ||
801 | } | ||
802 | |||
803 | p->qp = ipoib_cm_create_tx_qp(p->dev, p->cq); | ||
804 | if (IS_ERR(p->qp)) { | ||
805 | ret = PTR_ERR(p->qp); | ||
806 | ipoib_warn(priv, "failed to allocate tx qp: %d\n", ret); | ||
807 | goto err_qp; | ||
808 | } | ||
809 | |||
810 | p->id = ib_create_cm_id(priv->ca, ipoib_cm_tx_handler, p); | ||
811 | if (IS_ERR(p->id)) { | ||
812 | ret = PTR_ERR(p->id); | ||
813 | ipoib_warn(priv, "failed to create tx cm id: %d\n", ret); | ||
814 | goto err_id; | ||
815 | } | ||
816 | |||
817 | ret = ipoib_cm_modify_tx_init(p->dev, p->id, p->qp); | ||
818 | if (ret) { | ||
819 | ipoib_warn(priv, "failed to modify tx qp to rtr: %d\n", ret); | ||
820 | goto err_modify; | ||
821 | } | ||
822 | |||
823 | ret = ipoib_cm_send_req(p->dev, p->id, p->qp, qpn, pathrec); | ||
824 | if (ret) { | ||
825 | ipoib_warn(priv, "failed to send cm req: %d\n", ret); | ||
826 | goto err_send_cm; | ||
827 | } | ||
828 | |||
829 | ipoib_dbg(priv, "Request connection 0x%x for gid " IPOIB_GID_FMT " qpn 0x%x\n", | ||
830 | p->qp->qp_num, IPOIB_GID_ARG(pathrec->dgid), qpn); | ||
831 | |||
832 | return 0; | ||
833 | |||
834 | err_send_cm: | ||
835 | err_modify: | ||
836 | ib_destroy_cm_id(p->id); | ||
837 | err_id: | ||
838 | p->id = NULL; | ||
839 | ib_destroy_qp(p->qp); | ||
840 | err_req_notify: | ||
841 | err_qp: | ||
842 | p->qp = NULL; | ||
843 | ib_destroy_cq(p->cq); | ||
844 | err_cq: | ||
845 | p->cq = NULL; | ||
846 | err_tx: | ||
847 | return ret; | ||
848 | } | ||
849 | |||
850 | static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p) | ||
851 | { | ||
852 | struct ipoib_dev_priv *priv = netdev_priv(p->dev); | ||
853 | struct ipoib_tx_buf *tx_req; | ||
854 | |||
855 | ipoib_dbg(priv, "Destroy active connection 0x%x head 0x%x tail 0x%x\n", | ||
856 | p->qp ? p->qp->qp_num : 0, p->tx_head, p->tx_tail); | ||
857 | |||
858 | if (p->id) | ||
859 | ib_destroy_cm_id(p->id); | ||
860 | |||
861 | if (p->qp) | ||
862 | ib_destroy_qp(p->qp); | ||
863 | |||
864 | if (p->cq) | ||
865 | ib_destroy_cq(p->cq); | ||
866 | |||
867 | if (test_bit(IPOIB_FLAG_NETIF_STOPPED, &p->flags)) | ||
868 | netif_wake_queue(p->dev); | ||
869 | |||
870 | if (p->tx_ring) { | ||
871 | while ((int) p->tx_tail - (int) p->tx_head < 0) { | ||
872 | tx_req = &p->tx_ring[p->tx_tail & (ipoib_sendq_size - 1)]; | ||
873 | ib_dma_unmap_single(priv->ca, tx_req->mapping, tx_req->skb->len, | ||
874 | DMA_TO_DEVICE); | ||
875 | dev_kfree_skb_any(tx_req->skb); | ||
876 | ++p->tx_tail; | ||
877 | } | ||
878 | |||
879 | kfree(p->tx_ring); | ||
880 | } | ||
881 | |||
882 | kfree(p); | ||
883 | } | ||
884 | |||
885 | static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id, | ||
886 | struct ib_cm_event *event) | ||
887 | { | ||
888 | struct ipoib_cm_tx *tx = cm_id->context; | ||
889 | struct ipoib_dev_priv *priv = netdev_priv(tx->dev); | ||
890 | struct net_device *dev = priv->dev; | ||
891 | struct ipoib_neigh *neigh; | ||
892 | unsigned long flags; | ||
893 | int ret; | ||
894 | |||
895 | switch (event->event) { | ||
896 | case IB_CM_DREQ_RECEIVED: | ||
897 | ipoib_dbg(priv, "DREQ received.\n"); | ||
898 | ib_send_cm_drep(cm_id, NULL, 0); | ||
899 | break; | ||
900 | case IB_CM_REP_RECEIVED: | ||
901 | ipoib_dbg(priv, "REP received.\n"); | ||
902 | ret = ipoib_cm_rep_handler(cm_id, event); | ||
903 | if (ret) | ||
904 | ib_send_cm_rej(cm_id, IB_CM_REJ_CONSUMER_DEFINED, | ||
905 | NULL, 0, NULL, 0); | ||
906 | break; | ||
907 | case IB_CM_REQ_ERROR: | ||
908 | case IB_CM_REJ_RECEIVED: | ||
909 | case IB_CM_TIMEWAIT_EXIT: | ||
910 | ipoib_dbg(priv, "CM error %d.\n", event->event); | ||
911 | spin_lock_irqsave(&priv->tx_lock, flags); | ||
912 | spin_lock(&priv->lock); | ||
913 | neigh = tx->neigh; | ||
914 | |||
915 | if (neigh) { | ||
916 | neigh->cm = NULL; | ||
917 | list_del(&neigh->list); | ||
918 | if (neigh->ah) | ||
919 | ipoib_put_ah(neigh->ah); | ||
920 | ipoib_neigh_free(dev, neigh); | ||
921 | |||
922 | tx->neigh = NULL; | ||
923 | } | ||
924 | |||
925 | if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &tx->flags)) { | ||
926 | list_move(&tx->list, &priv->cm.reap_list); | ||
927 | queue_work(ipoib_workqueue, &priv->cm.reap_task); | ||
928 | } | ||
929 | |||
930 | spin_unlock(&priv->lock); | ||
931 | spin_unlock_irqrestore(&priv->tx_lock, flags); | ||
932 | break; | ||
933 | default: | ||
934 | break; | ||
935 | } | ||
936 | |||
937 | return 0; | ||
938 | } | ||
939 | |||
940 | struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path *path, | ||
941 | struct ipoib_neigh *neigh) | ||
942 | { | ||
943 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
944 | struct ipoib_cm_tx *tx; | ||
945 | |||
946 | tx = kzalloc(sizeof *tx, GFP_ATOMIC); | ||
947 | if (!tx) | ||
948 | return NULL; | ||
949 | |||
950 | neigh->cm = tx; | ||
951 | tx->neigh = neigh; | ||
952 | tx->path = path; | ||
953 | tx->dev = dev; | ||
954 | list_add(&tx->list, &priv->cm.start_list); | ||
955 | set_bit(IPOIB_FLAG_INITIALIZED, &tx->flags); | ||
956 | queue_work(ipoib_workqueue, &priv->cm.start_task); | ||
957 | return tx; | ||
958 | } | ||
959 | |||
960 | void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx) | ||
961 | { | ||
962 | struct ipoib_dev_priv *priv = netdev_priv(tx->dev); | ||
963 | if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &tx->flags)) { | ||
964 | list_move(&tx->list, &priv->cm.reap_list); | ||
965 | queue_work(ipoib_workqueue, &priv->cm.reap_task); | ||
966 | ipoib_dbg(priv, "Reap connection for gid " IPOIB_GID_FMT "\n", | ||
967 | IPOIB_GID_ARG(tx->neigh->dgid)); | ||
968 | tx->neigh = NULL; | ||
969 | } | ||
970 | } | ||
971 | |||
972 | static void ipoib_cm_tx_start(struct work_struct *work) | ||
973 | { | ||
974 | struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, | ||
975 | cm.start_task); | ||
976 | struct net_device *dev = priv->dev; | ||
977 | struct ipoib_neigh *neigh; | ||
978 | struct ipoib_cm_tx *p; | ||
979 | unsigned long flags; | ||
980 | int ret; | ||
981 | |||
982 | struct ib_sa_path_rec pathrec; | ||
983 | u32 qpn; | ||
984 | |||
985 | spin_lock_irqsave(&priv->tx_lock, flags); | ||
986 | spin_lock(&priv->lock); | ||
987 | while (!list_empty(&priv->cm.start_list)) { | ||
988 | p = list_entry(priv->cm.start_list.next, typeof(*p), list); | ||
989 | list_del_init(&p->list); | ||
990 | neigh = p->neigh; | ||
991 | qpn = IPOIB_QPN(neigh->neighbour->ha); | ||
992 | memcpy(&pathrec, &p->path->pathrec, sizeof pathrec); | ||
993 | spin_unlock(&priv->lock); | ||
994 | spin_unlock_irqrestore(&priv->tx_lock, flags); | ||
995 | ret = ipoib_cm_tx_init(p, qpn, &pathrec); | ||
996 | spin_lock_irqsave(&priv->tx_lock, flags); | ||
997 | spin_lock(&priv->lock); | ||
998 | if (ret) { | ||
999 | neigh = p->neigh; | ||
1000 | if (neigh) { | ||
1001 | neigh->cm = NULL; | ||
1002 | list_del(&neigh->list); | ||
1003 | if (neigh->ah) | ||
1004 | ipoib_put_ah(neigh->ah); | ||
1005 | ipoib_neigh_free(dev, neigh); | ||
1006 | } | ||
1007 | list_del(&p->list); | ||
1008 | kfree(p); | ||
1009 | } | ||
1010 | } | ||
1011 | spin_unlock(&priv->lock); | ||
1012 | spin_unlock_irqrestore(&priv->tx_lock, flags); | ||
1013 | } | ||
1014 | |||
1015 | static void ipoib_cm_tx_reap(struct work_struct *work) | ||
1016 | { | ||
1017 | struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, | ||
1018 | cm.reap_task); | ||
1019 | struct ipoib_cm_tx *p; | ||
1020 | unsigned long flags; | ||
1021 | |||
1022 | spin_lock_irqsave(&priv->tx_lock, flags); | ||
1023 | spin_lock(&priv->lock); | ||
1024 | while (!list_empty(&priv->cm.reap_list)) { | ||
1025 | p = list_entry(priv->cm.reap_list.next, typeof(*p), list); | ||
1026 | list_del(&p->list); | ||
1027 | spin_unlock(&priv->lock); | ||
1028 | spin_unlock_irqrestore(&priv->tx_lock, flags); | ||
1029 | ipoib_cm_tx_destroy(p); | ||
1030 | spin_lock_irqsave(&priv->tx_lock, flags); | ||
1031 | spin_lock(&priv->lock); | ||
1032 | } | ||
1033 | spin_unlock(&priv->lock); | ||
1034 | spin_unlock_irqrestore(&priv->tx_lock, flags); | ||
1035 | } | ||
1036 | |||
1037 | static void ipoib_cm_skb_reap(struct work_struct *work) | ||
1038 | { | ||
1039 | struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, | ||
1040 | cm.skb_task); | ||
1041 | struct net_device *dev = priv->dev; | ||
1042 | struct sk_buff *skb; | ||
1043 | unsigned long flags; | ||
1044 | |||
1045 | unsigned mtu = priv->mcast_mtu; | ||
1046 | |||
1047 | spin_lock_irqsave(&priv->tx_lock, flags); | ||
1048 | spin_lock(&priv->lock); | ||
1049 | while ((skb = skb_dequeue(&priv->cm.skb_queue))) { | ||
1050 | spin_unlock(&priv->lock); | ||
1051 | spin_unlock_irqrestore(&priv->tx_lock, flags); | ||
1052 | if (skb->protocol == htons(ETH_P_IP)) | ||
1053 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); | ||
1054 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
1055 | else if (skb->protocol == htons(ETH_P_IPV6)) | ||
1056 | icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, dev); | ||
1057 | #endif | ||
1058 | dev_kfree_skb_any(skb); | ||
1059 | spin_lock_irqsave(&priv->tx_lock, flags); | ||
1060 | spin_lock(&priv->lock); | ||
1061 | } | ||
1062 | spin_unlock(&priv->lock); | ||
1063 | spin_unlock_irqrestore(&priv->tx_lock, flags); | ||
1064 | } | ||
1065 | |||
1066 | void ipoib_cm_skb_too_long(struct net_device* dev, struct sk_buff *skb, | ||
1067 | unsigned int mtu) | ||
1068 | { | ||
1069 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
1070 | int e = skb_queue_empty(&priv->cm.skb_queue); | ||
1071 | |||
1072 | if (skb->dst) | ||
1073 | skb->dst->ops->update_pmtu(skb->dst, mtu); | ||
1074 | |||
1075 | skb_queue_tail(&priv->cm.skb_queue, skb); | ||
1076 | if (e) | ||
1077 | queue_work(ipoib_workqueue, &priv->cm.skb_task); | ||
1078 | } | ||
1079 | |||
1080 | static void ipoib_cm_stale_task(struct work_struct *work) | ||
1081 | { | ||
1082 | struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, | ||
1083 | cm.stale_task.work); | ||
1084 | struct ipoib_cm_rx *p; | ||
1085 | unsigned long flags; | ||
1086 | |||
1087 | spin_lock_irqsave(&priv->lock, flags); | ||
1088 | while (!list_empty(&priv->cm.passive_ids)) { | ||
1089 | /* List if sorted by LRU, start from tail, | ||
1090 | * stop when we see a recently used entry */ | ||
1091 | p = list_entry(priv->cm.passive_ids.prev, typeof(*p), list); | ||
1092 | if (time_after_eq(jiffies, p->jiffies + IPOIB_CM_RX_TIMEOUT)) | ||
1093 | break; | ||
1094 | list_del_init(&p->list); | ||
1095 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1096 | ib_destroy_cm_id(p->id); | ||
1097 | ib_destroy_qp(p->qp); | ||
1098 | kfree(p); | ||
1099 | spin_lock_irqsave(&priv->lock, flags); | ||
1100 | } | ||
1101 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1102 | } | ||
1103 | |||
1104 | |||
1105 | static ssize_t show_mode(struct device *d, struct device_attribute *attr, | ||
1106 | char *buf) | ||
1107 | { | ||
1108 | struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(d)); | ||
1109 | |||
1110 | if (test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags)) | ||
1111 | return sprintf(buf, "connected\n"); | ||
1112 | else | ||
1113 | return sprintf(buf, "datagram\n"); | ||
1114 | } | ||
1115 | |||
1116 | static ssize_t set_mode(struct device *d, struct device_attribute *attr, | ||
1117 | const char *buf, size_t count) | ||
1118 | { | ||
1119 | struct net_device *dev = to_net_dev(d); | ||
1120 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
1121 | |||
1122 | /* flush paths if we switch modes so that connections are restarted */ | ||
1123 | if (IPOIB_CM_SUPPORTED(dev->dev_addr) && !strcmp(buf, "connected\n")) { | ||
1124 | set_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); | ||
1125 | ipoib_warn(priv, "enabling connected mode " | ||
1126 | "will cause multicast packet drops\n"); | ||
1127 | ipoib_flush_paths(dev); | ||
1128 | return count; | ||
1129 | } | ||
1130 | |||
1131 | if (!strcmp(buf, "datagram\n")) { | ||
1132 | clear_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); | ||
1133 | dev->mtu = min(priv->mcast_mtu, dev->mtu); | ||
1134 | ipoib_flush_paths(dev); | ||
1135 | return count; | ||
1136 | } | ||
1137 | |||
1138 | return -EINVAL; | ||
1139 | } | ||
1140 | |||
1141 | static DEVICE_ATTR(mode, S_IWUGO | S_IRUGO, show_mode, set_mode); | ||
1142 | |||
1143 | int ipoib_cm_add_mode_attr(struct net_device *dev) | ||
1144 | { | ||
1145 | return device_create_file(&dev->dev, &dev_attr_mode); | ||
1146 | } | ||
1147 | |||
1148 | int ipoib_cm_dev_init(struct net_device *dev) | ||
1149 | { | ||
1150 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
1151 | struct ib_srq_init_attr srq_init_attr = { | ||
1152 | .attr = { | ||
1153 | .max_wr = ipoib_recvq_size, | ||
1154 | .max_sge = IPOIB_CM_RX_SG | ||
1155 | } | ||
1156 | }; | ||
1157 | int ret, i; | ||
1158 | |||
1159 | INIT_LIST_HEAD(&priv->cm.passive_ids); | ||
1160 | INIT_LIST_HEAD(&priv->cm.reap_list); | ||
1161 | INIT_LIST_HEAD(&priv->cm.start_list); | ||
1162 | INIT_WORK(&priv->cm.start_task, ipoib_cm_tx_start); | ||
1163 | INIT_WORK(&priv->cm.reap_task, ipoib_cm_tx_reap); | ||
1164 | INIT_WORK(&priv->cm.skb_task, ipoib_cm_skb_reap); | ||
1165 | INIT_DELAYED_WORK(&priv->cm.stale_task, ipoib_cm_stale_task); | ||
1166 | |||
1167 | skb_queue_head_init(&priv->cm.skb_queue); | ||
1168 | |||
1169 | priv->cm.srq = ib_create_srq(priv->pd, &srq_init_attr); | ||
1170 | if (IS_ERR(priv->cm.srq)) { | ||
1171 | ret = PTR_ERR(priv->cm.srq); | ||
1172 | priv->cm.srq = NULL; | ||
1173 | return ret; | ||
1174 | } | ||
1175 | |||
1176 | priv->cm.srq_ring = kzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring, | ||
1177 | GFP_KERNEL); | ||
1178 | if (!priv->cm.srq_ring) { | ||
1179 | printk(KERN_WARNING "%s: failed to allocate CM ring (%d entries)\n", | ||
1180 | priv->ca->name, ipoib_recvq_size); | ||
1181 | ipoib_cm_dev_cleanup(dev); | ||
1182 | return -ENOMEM; | ||
1183 | } | ||
1184 | |||
1185 | for (i = 0; i < IPOIB_CM_RX_SG; ++i) | ||
1186 | priv->cm.rx_sge[i].lkey = priv->mr->lkey; | ||
1187 | |||
1188 | priv->cm.rx_sge[0].length = IPOIB_CM_HEAD_SIZE; | ||
1189 | for (i = 1; i < IPOIB_CM_RX_SG; ++i) | ||
1190 | priv->cm.rx_sge[i].length = PAGE_SIZE; | ||
1191 | priv->cm.rx_wr.next = NULL; | ||
1192 | priv->cm.rx_wr.sg_list = priv->cm.rx_sge; | ||
1193 | priv->cm.rx_wr.num_sge = IPOIB_CM_RX_SG; | ||
1194 | |||
1195 | for (i = 0; i < ipoib_recvq_size; ++i) { | ||
1196 | if (ipoib_cm_alloc_rx_skb(dev, i, priv->cm.srq_ring[i].mapping)) { | ||
1197 | ipoib_warn(priv, "failed to allocate receive buffer %d\n", i); | ||
1198 | ipoib_cm_dev_cleanup(dev); | ||
1199 | return -ENOMEM; | ||
1200 | } | ||
1201 | if (ipoib_cm_post_receive(dev, i)) { | ||
1202 | ipoib_warn(priv, "ipoib_ib_post_receive failed for buf %d\n", i); | ||
1203 | ipoib_cm_dev_cleanup(dev); | ||
1204 | return -EIO; | ||
1205 | } | ||
1206 | } | ||
1207 | |||
1208 | priv->dev->dev_addr[0] = IPOIB_FLAGS_RC; | ||
1209 | return 0; | ||
1210 | } | ||
1211 | |||
1212 | void ipoib_cm_dev_cleanup(struct net_device *dev) | ||
1213 | { | ||
1214 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
1215 | int i, ret; | ||
1216 | |||
1217 | if (!priv->cm.srq) | ||
1218 | return; | ||
1219 | |||
1220 | ipoib_dbg(priv, "Cleanup ipoib connected mode.\n"); | ||
1221 | |||
1222 | ret = ib_destroy_srq(priv->cm.srq); | ||
1223 | if (ret) | ||
1224 | ipoib_warn(priv, "ib_destroy_srq failed: %d\n", ret); | ||
1225 | |||
1226 | priv->cm.srq = NULL; | ||
1227 | if (!priv->cm.srq_ring) | ||
1228 | return; | ||
1229 | for (i = 0; i < ipoib_recvq_size; ++i) | ||
1230 | if (priv->cm.srq_ring[i].skb) { | ||
1231 | ipoib_cm_dma_unmap_rx(priv, priv->cm.srq_ring[i].mapping); | ||
1232 | dev_kfree_skb_any(priv->cm.srq_ring[i].skb); | ||
1233 | priv->cm.srq_ring[i].skb = NULL; | ||
1234 | } | ||
1235 | kfree(priv->cm.srq_ring); | ||
1236 | priv->cm.srq_ring = NULL; | ||
1237 | } | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 59d9594ed6d9..f2aa923ddbea 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
@@ -50,8 +50,6 @@ MODULE_PARM_DESC(data_debug_level, | |||
50 | "Enable data path debug tracing if > 0"); | 50 | "Enable data path debug tracing if > 0"); |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #define IPOIB_OP_RECV (1ul << 31) | ||
54 | |||
55 | static DEFINE_MUTEX(pkey_mutex); | 53 | static DEFINE_MUTEX(pkey_mutex); |
56 | 54 | ||
57 | struct ipoib_ah *ipoib_create_ah(struct net_device *dev, | 55 | struct ipoib_ah *ipoib_create_ah(struct net_device *dev, |
@@ -268,10 +266,11 @@ static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc) | |||
268 | 266 | ||
269 | spin_lock_irqsave(&priv->tx_lock, flags); | 267 | spin_lock_irqsave(&priv->tx_lock, flags); |
270 | ++priv->tx_tail; | 268 | ++priv->tx_tail; |
271 | if (netif_queue_stopped(dev) && | 269 | if (unlikely(test_bit(IPOIB_FLAG_NETIF_STOPPED, &priv->flags)) && |
272 | test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags) && | 270 | priv->tx_head - priv->tx_tail <= ipoib_sendq_size >> 1) { |
273 | priv->tx_head - priv->tx_tail <= ipoib_sendq_size >> 1) | 271 | clear_bit(IPOIB_FLAG_NETIF_STOPPED, &priv->flags); |
274 | netif_wake_queue(dev); | 272 | netif_wake_queue(dev); |
273 | } | ||
275 | spin_unlock_irqrestore(&priv->tx_lock, flags); | 274 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
276 | 275 | ||
277 | if (wc->status != IB_WC_SUCCESS && | 276 | if (wc->status != IB_WC_SUCCESS && |
@@ -283,7 +282,9 @@ static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc) | |||
283 | 282 | ||
284 | static void ipoib_ib_handle_wc(struct net_device *dev, struct ib_wc *wc) | 283 | static void ipoib_ib_handle_wc(struct net_device *dev, struct ib_wc *wc) |
285 | { | 284 | { |
286 | if (wc->wr_id & IPOIB_OP_RECV) | 285 | if (wc->wr_id & IPOIB_CM_OP_SRQ) |
286 | ipoib_cm_handle_rx_wc(dev, wc); | ||
287 | else if (wc->wr_id & IPOIB_OP_RECV) | ||
287 | ipoib_ib_handle_rx_wc(dev, wc); | 288 | ipoib_ib_handle_rx_wc(dev, wc); |
288 | else | 289 | else |
289 | ipoib_ib_handle_tx_wc(dev, wc); | 290 | ipoib_ib_handle_tx_wc(dev, wc); |
@@ -327,12 +328,12 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb, | |||
327 | struct ipoib_tx_buf *tx_req; | 328 | struct ipoib_tx_buf *tx_req; |
328 | u64 addr; | 329 | u64 addr; |
329 | 330 | ||
330 | if (unlikely(skb->len > dev->mtu + INFINIBAND_ALEN)) { | 331 | if (unlikely(skb->len > priv->mcast_mtu + INFINIBAND_ALEN)) { |
331 | ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n", | 332 | ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n", |
332 | skb->len, dev->mtu + INFINIBAND_ALEN); | 333 | skb->len, priv->mcast_mtu + INFINIBAND_ALEN); |
333 | ++priv->stats.tx_dropped; | 334 | ++priv->stats.tx_dropped; |
334 | ++priv->stats.tx_errors; | 335 | ++priv->stats.tx_errors; |
335 | dev_kfree_skb_any(skb); | 336 | ipoib_cm_skb_too_long(dev, skb, priv->mcast_mtu); |
336 | return; | 337 | return; |
337 | } | 338 | } |
338 | 339 | ||
@@ -372,6 +373,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb, | |||
372 | if (priv->tx_head - priv->tx_tail == ipoib_sendq_size) { | 373 | if (priv->tx_head - priv->tx_tail == ipoib_sendq_size) { |
373 | ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n"); | 374 | ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n"); |
374 | netif_stop_queue(dev); | 375 | netif_stop_queue(dev); |
376 | set_bit(IPOIB_FLAG_NETIF_STOPPED, &priv->flags); | ||
375 | } | 377 | } |
376 | } | 378 | } |
377 | } | 379 | } |
@@ -424,6 +426,13 @@ int ipoib_ib_dev_open(struct net_device *dev) | |||
424 | return -1; | 426 | return -1; |
425 | } | 427 | } |
426 | 428 | ||
429 | ret = ipoib_cm_dev_open(dev); | ||
430 | if (ret) { | ||
431 | ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret); | ||
432 | ipoib_ib_dev_stop(dev); | ||
433 | return -1; | ||
434 | } | ||
435 | |||
427 | clear_bit(IPOIB_STOP_REAPER, &priv->flags); | 436 | clear_bit(IPOIB_STOP_REAPER, &priv->flags); |
428 | queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ); | 437 | queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ); |
429 | 438 | ||
@@ -509,6 +518,8 @@ int ipoib_ib_dev_stop(struct net_device *dev) | |||
509 | 518 | ||
510 | clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); | 519 | clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); |
511 | 520 | ||
521 | ipoib_cm_dev_stop(dev); | ||
522 | |||
512 | /* | 523 | /* |
513 | * Move our QP to the error state and then reinitialize in | 524 | * Move our QP to the error state and then reinitialize in |
514 | * when all work requests have completed or have been flushed. | 525 | * when all work requests have completed or have been flushed. |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index af5ee2ec4499..18d27fd352ad 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -49,8 +49,6 @@ | |||
49 | 49 | ||
50 | #include <net/dst.h> | 50 | #include <net/dst.h> |
51 | 51 | ||
52 | #define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff) | ||
53 | |||
54 | MODULE_AUTHOR("Roland Dreier"); | 52 | MODULE_AUTHOR("Roland Dreier"); |
55 | MODULE_DESCRIPTION("IP-over-InfiniBand net driver"); | 53 | MODULE_DESCRIPTION("IP-over-InfiniBand net driver"); |
56 | MODULE_LICENSE("Dual BSD/GPL"); | 54 | MODULE_LICENSE("Dual BSD/GPL"); |
@@ -145,6 +143,8 @@ static int ipoib_stop(struct net_device *dev) | |||
145 | 143 | ||
146 | netif_stop_queue(dev); | 144 | netif_stop_queue(dev); |
147 | 145 | ||
146 | clear_bit(IPOIB_FLAG_NETIF_STOPPED, &priv->flags); | ||
147 | |||
148 | /* | 148 | /* |
149 | * Now flush workqueue to make sure a scheduled task doesn't | 149 | * Now flush workqueue to make sure a scheduled task doesn't |
150 | * bring our internal state back up. | 150 | * bring our internal state back up. |
@@ -178,8 +178,18 @@ static int ipoib_change_mtu(struct net_device *dev, int new_mtu) | |||
178 | { | 178 | { |
179 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 179 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
180 | 180 | ||
181 | if (new_mtu > IPOIB_PACKET_SIZE - IPOIB_ENCAP_LEN) | 181 | /* dev->mtu > 2K ==> connected mode */ |
182 | if (ipoib_cm_admin_enabled(dev) && new_mtu <= IPOIB_CM_MTU) { | ||
183 | if (new_mtu > priv->mcast_mtu) | ||
184 | ipoib_warn(priv, "mtu > %d will cause multicast packet drops.\n", | ||
185 | priv->mcast_mtu); | ||
186 | dev->mtu = new_mtu; | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | if (new_mtu > IPOIB_PACKET_SIZE - IPOIB_ENCAP_LEN) { | ||
182 | return -EINVAL; | 191 | return -EINVAL; |
192 | } | ||
183 | 193 | ||
184 | priv->admin_mtu = new_mtu; | 194 | priv->admin_mtu = new_mtu; |
185 | 195 | ||
@@ -414,6 +424,20 @@ static void path_rec_completion(int status, | |||
414 | memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, | 424 | memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, |
415 | sizeof(union ib_gid)); | 425 | sizeof(union ib_gid)); |
416 | 426 | ||
427 | if (ipoib_cm_enabled(dev, neigh->neighbour)) { | ||
428 | if (!ipoib_cm_get(neigh)) | ||
429 | ipoib_cm_set(neigh, ipoib_cm_create_tx(dev, | ||
430 | path, | ||
431 | neigh)); | ||
432 | if (!ipoib_cm_get(neigh)) { | ||
433 | list_del(&neigh->list); | ||
434 | if (neigh->ah) | ||
435 | ipoib_put_ah(neigh->ah); | ||
436 | ipoib_neigh_free(dev, neigh); | ||
437 | continue; | ||
438 | } | ||
439 | } | ||
440 | |||
417 | while ((skb = __skb_dequeue(&neigh->queue))) | 441 | while ((skb = __skb_dequeue(&neigh->queue))) |
418 | __skb_queue_tail(&skqueue, skb); | 442 | __skb_queue_tail(&skqueue, skb); |
419 | } | 443 | } |
@@ -520,7 +544,25 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev) | |||
520 | memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, | 544 | memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, |
521 | sizeof(union ib_gid)); | 545 | sizeof(union ib_gid)); |
522 | 546 | ||
523 | ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha)); | 547 | if (ipoib_cm_enabled(dev, neigh->neighbour)) { |
548 | if (!ipoib_cm_get(neigh)) | ||
549 | ipoib_cm_set(neigh, ipoib_cm_create_tx(dev, path, neigh)); | ||
550 | if (!ipoib_cm_get(neigh)) { | ||
551 | list_del(&neigh->list); | ||
552 | if (neigh->ah) | ||
553 | ipoib_put_ah(neigh->ah); | ||
554 | ipoib_neigh_free(dev, neigh); | ||
555 | goto err_drop; | ||
556 | } | ||
557 | if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) | ||
558 | __skb_queue_tail(&neigh->queue, skb); | ||
559 | else { | ||
560 | ipoib_warn(priv, "queue length limit %d. Packet drop.\n", | ||
561 | skb_queue_len(&neigh->queue)); | ||
562 | goto err_drop; | ||
563 | } | ||
564 | } else | ||
565 | ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha)); | ||
524 | } else { | 566 | } else { |
525 | neigh->ah = NULL; | 567 | neigh->ah = NULL; |
526 | 568 | ||
@@ -538,6 +580,7 @@ err_list: | |||
538 | 580 | ||
539 | err_path: | 581 | err_path: |
540 | ipoib_neigh_free(dev, neigh); | 582 | ipoib_neigh_free(dev, neigh); |
583 | err_drop: | ||
541 | ++priv->stats.tx_dropped; | 584 | ++priv->stats.tx_dropped; |
542 | dev_kfree_skb_any(skb); | 585 | dev_kfree_skb_any(skb); |
543 | 586 | ||
@@ -640,7 +683,12 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
640 | 683 | ||
641 | neigh = *to_ipoib_neigh(skb->dst->neighbour); | 684 | neigh = *to_ipoib_neigh(skb->dst->neighbour); |
642 | 685 | ||
643 | if (likely(neigh->ah)) { | 686 | if (ipoib_cm_get(neigh)) { |
687 | if (ipoib_cm_up(neigh)) { | ||
688 | ipoib_cm_send(dev, skb, ipoib_cm_get(neigh)); | ||
689 | goto out; | ||
690 | } | ||
691 | } else if (neigh->ah) { | ||
644 | if (unlikely(memcmp(&neigh->dgid.raw, | 692 | if (unlikely(memcmp(&neigh->dgid.raw, |
645 | skb->dst->neighbour->ha + 4, | 693 | skb->dst->neighbour->ha + 4, |
646 | sizeof(union ib_gid)))) { | 694 | sizeof(union ib_gid)))) { |
@@ -805,6 +853,7 @@ struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neighbour) | |||
805 | neigh->neighbour = neighbour; | 853 | neigh->neighbour = neighbour; |
806 | *to_ipoib_neigh(neighbour) = neigh; | 854 | *to_ipoib_neigh(neighbour) = neigh; |
807 | skb_queue_head_init(&neigh->queue); | 855 | skb_queue_head_init(&neigh->queue); |
856 | ipoib_cm_set(neigh, NULL); | ||
808 | 857 | ||
809 | return neigh; | 858 | return neigh; |
810 | } | 859 | } |
@@ -818,6 +867,8 @@ void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh) | |||
818 | ++priv->stats.tx_dropped; | 867 | ++priv->stats.tx_dropped; |
819 | dev_kfree_skb_any(skb); | 868 | dev_kfree_skb_any(skb); |
820 | } | 869 | } |
870 | if (ipoib_cm_get(neigh)) | ||
871 | ipoib_cm_destroy_tx(ipoib_cm_get(neigh)); | ||
821 | kfree(neigh); | 872 | kfree(neigh); |
822 | } | 873 | } |
823 | 874 | ||
@@ -1080,6 +1131,8 @@ static struct net_device *ipoib_add_port(const char *format, | |||
1080 | 1131 | ||
1081 | ipoib_create_debug_files(priv->dev); | 1132 | ipoib_create_debug_files(priv->dev); |
1082 | 1133 | ||
1134 | if (ipoib_cm_add_mode_attr(priv->dev)) | ||
1135 | goto sysfs_failed; | ||
1083 | if (ipoib_add_pkey_attr(priv->dev)) | 1136 | if (ipoib_add_pkey_attr(priv->dev)) |
1084 | goto sysfs_failed; | 1137 | goto sysfs_failed; |
1085 | if (device_create_file(&priv->dev->dev, &dev_attr_create_child)) | 1138 | if (device_create_file(&priv->dev->dev, &dev_attr_create_child)) |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c index b04b72ca32ed..fea737f520fd 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c | |||
@@ -597,7 +597,9 @@ void ipoib_mcast_join_task(struct work_struct *work) | |||
597 | 597 | ||
598 | priv->mcast_mtu = ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu) - | 598 | priv->mcast_mtu = ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu) - |
599 | IPOIB_ENCAP_LEN; | 599 | IPOIB_ENCAP_LEN; |
600 | dev->mtu = min(priv->mcast_mtu, priv->admin_mtu); | 600 | |
601 | if (!ipoib_cm_admin_enabled(dev)) | ||
602 | dev->mtu = min(priv->mcast_mtu, priv->admin_mtu); | ||
601 | 603 | ||
602 | ipoib_dbg_mcast(priv, "successfully joined all multicast groups\n"); | 604 | ipoib_dbg_mcast(priv, "successfully joined all multicast groups\n"); |
603 | 605 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c index 7b717c648f72..3cb551b88756 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c | |||
@@ -168,35 +168,41 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) | |||
168 | .qp_type = IB_QPT_UD | 168 | .qp_type = IB_QPT_UD |
169 | }; | 169 | }; |
170 | 170 | ||
171 | int ret, size; | ||
172 | |||
171 | priv->pd = ib_alloc_pd(priv->ca); | 173 | priv->pd = ib_alloc_pd(priv->ca); |
172 | if (IS_ERR(priv->pd)) { | 174 | if (IS_ERR(priv->pd)) { |
173 | printk(KERN_WARNING "%s: failed to allocate PD\n", ca->name); | 175 | printk(KERN_WARNING "%s: failed to allocate PD\n", ca->name); |
174 | return -ENODEV; | 176 | return -ENODEV; |
175 | } | 177 | } |
176 | 178 | ||
177 | priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, | 179 | priv->mr = ib_get_dma_mr(priv->pd, IB_ACCESS_LOCAL_WRITE); |
178 | ipoib_sendq_size + ipoib_recvq_size + 1); | 180 | if (IS_ERR(priv->mr)) { |
181 | printk(KERN_WARNING "%s: ib_get_dma_mr failed\n", ca->name); | ||
182 | goto out_free_pd; | ||
183 | } | ||
184 | |||
185 | size = ipoib_sendq_size + ipoib_recvq_size + 1; | ||
186 | ret = ipoib_cm_dev_init(dev); | ||
187 | if (!ret) | ||
188 | size += ipoib_recvq_size; | ||
189 | |||
190 | priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size); | ||
179 | if (IS_ERR(priv->cq)) { | 191 | if (IS_ERR(priv->cq)) { |
180 | printk(KERN_WARNING "%s: failed to create CQ\n", ca->name); | 192 | printk(KERN_WARNING "%s: failed to create CQ\n", ca->name); |
181 | goto out_free_pd; | 193 | goto out_free_mr; |
182 | } | 194 | } |
183 | 195 | ||
184 | if (ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP)) | 196 | if (ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP)) |
185 | goto out_free_cq; | 197 | goto out_free_cq; |
186 | 198 | ||
187 | priv->mr = ib_get_dma_mr(priv->pd, IB_ACCESS_LOCAL_WRITE); | ||
188 | if (IS_ERR(priv->mr)) { | ||
189 | printk(KERN_WARNING "%s: ib_get_dma_mr failed\n", ca->name); | ||
190 | goto out_free_cq; | ||
191 | } | ||
192 | |||
193 | init_attr.send_cq = priv->cq; | 199 | init_attr.send_cq = priv->cq; |
194 | init_attr.recv_cq = priv->cq, | 200 | init_attr.recv_cq = priv->cq, |
195 | 201 | ||
196 | priv->qp = ib_create_qp(priv->pd, &init_attr); | 202 | priv->qp = ib_create_qp(priv->pd, &init_attr); |
197 | if (IS_ERR(priv->qp)) { | 203 | if (IS_ERR(priv->qp)) { |
198 | printk(KERN_WARNING "%s: failed to create QP\n", ca->name); | 204 | printk(KERN_WARNING "%s: failed to create QP\n", ca->name); |
199 | goto out_free_mr; | 205 | goto out_free_cq; |
200 | } | 206 | } |
201 | 207 | ||
202 | priv->dev->dev_addr[1] = (priv->qp->qp_num >> 16) & 0xff; | 208 | priv->dev->dev_addr[1] = (priv->qp->qp_num >> 16) & 0xff; |
@@ -212,12 +218,12 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) | |||
212 | 218 | ||
213 | return 0; | 219 | return 0; |
214 | 220 | ||
215 | out_free_mr: | ||
216 | ib_dereg_mr(priv->mr); | ||
217 | |||
218 | out_free_cq: | 221 | out_free_cq: |
219 | ib_destroy_cq(priv->cq); | 222 | ib_destroy_cq(priv->cq); |
220 | 223 | ||
224 | out_free_mr: | ||
225 | ib_dereg_mr(priv->mr); | ||
226 | |||
221 | out_free_pd: | 227 | out_free_pd: |
222 | ib_dealloc_pd(priv->pd); | 228 | ib_dealloc_pd(priv->pd); |
223 | return -ENODEV; | 229 | return -ENODEV; |
@@ -235,12 +241,14 @@ void ipoib_transport_dev_cleanup(struct net_device *dev) | |||
235 | clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); | 241 | clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); |
236 | } | 242 | } |
237 | 243 | ||
238 | if (ib_dereg_mr(priv->mr)) | ||
239 | ipoib_warn(priv, "ib_dereg_mr failed\n"); | ||
240 | |||
241 | if (ib_destroy_cq(priv->cq)) | 244 | if (ib_destroy_cq(priv->cq)) |
242 | ipoib_warn(priv, "ib_cq_destroy failed\n"); | 245 | ipoib_warn(priv, "ib_cq_destroy failed\n"); |
243 | 246 | ||
247 | ipoib_cm_dev_cleanup(dev); | ||
248 | |||
249 | if (ib_dereg_mr(priv->mr)) | ||
250 | ipoib_warn(priv, "ib_dereg_mr failed\n"); | ||
251 | |||
244 | if (ib_dealloc_pd(priv->pd)) | 252 | if (ib_dealloc_pd(priv->pd)) |
245 | ipoib_warn(priv, "ib_dealloc_pd failed\n"); | 253 | ipoib_warn(priv, "ib_dealloc_pd failed\n"); |
246 | } | 254 | } |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c index 085eafe6667c..6762988439d1 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c | |||
@@ -115,6 +115,8 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) | |||
115 | 115 | ||
116 | ipoib_create_debug_files(priv->dev); | 116 | ipoib_create_debug_files(priv->dev); |
117 | 117 | ||
118 | if (ipoib_cm_add_mode_attr(priv->dev)) | ||
119 | goto sysfs_failed; | ||
118 | if (ipoib_add_pkey_attr(priv->dev)) | 120 | if (ipoib_add_pkey_attr(priv->dev)) |
119 | goto sysfs_failed; | 121 | goto sysfs_failed; |
120 | 122 | ||
diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c index eba18b6ac5e4..d226d935b0dc 100644 --- a/drivers/input/ff-memless.c +++ b/drivers/input/ff-memless.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/mutex.h> | 30 | #include <linux/mutex.h> |
31 | #include <linux/spinlock.h> | 31 | #include <linux/spinlock.h> |
32 | #include <linux/sched.h> | 32 | #include <linux/jiffies.h> |
33 | 33 | ||
34 | #include "fixp-arith.h" | 34 | #include "fixp-arith.h" |
35 | 35 | ||
diff --git a/drivers/input/input.c b/drivers/input/input.c index 14d4c0493c36..efa1b1f75393 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -11,7 +11,6 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/sched.h> | ||
15 | #include <linux/smp_lock.h> | 14 | #include <linux/smp_lock.h> |
16 | #include <linux/input.h> | 15 | #include <linux/input.h> |
17 | #include <linux/module.h> | 16 | #include <linux/module.h> |
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 3a8f1b427a7f..7ad479e4e3b3 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -78,7 +78,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
78 | int irq = IRQ_GPIO(pdata->buttons[i].gpio); | 78 | int irq = IRQ_GPIO(pdata->buttons[i].gpio); |
79 | 79 | ||
80 | set_irq_type(irq, IRQ_TYPE_EDGE_BOTH); | 80 | set_irq_type(irq, IRQ_TYPE_EDGE_BOTH); |
81 | error = request_irq(irq, gpio_keys_isr, SA_SAMPLE_RANDOM, | 81 | error = request_irq(irq, gpio_keys_isr, IRQF_SAMPLE_RANDOM, |
82 | pdata->buttons[i].desc ? pdata->buttons[i].desc : "gpio_keys", | 82 | pdata->buttons[i].desc ? pdata->buttons[i].desc : "gpio_keys", |
83 | pdev); | 83 | pdev); |
84 | if (error) { | 84 | if (error) { |
diff --git a/drivers/input/mouse/rpcmouse.c b/drivers/input/mouse/rpcmouse.c index fbdcfd8eb4e9..355efd0423e7 100644 --- a/drivers/input/mouse/rpcmouse.c +++ b/drivers/input/mouse/rpcmouse.c | |||
@@ -18,7 +18,6 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/sched.h> | ||
22 | #include <linux/ptrace.h> | 21 | #include <linux/ptrace.h> |
23 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c index 49e11e2c1d5d..4fa93ff30919 100644 --- a/drivers/input/serio/hil_mlc.c +++ b/drivers/input/serio/hil_mlc.c | |||
@@ -59,7 +59,6 @@ | |||
59 | #include <linux/init.h> | 59 | #include <linux/init.h> |
60 | #include <linux/interrupt.h> | 60 | #include <linux/interrupt.h> |
61 | #include <linux/timer.h> | 61 | #include <linux/timer.h> |
62 | #include <linux/sched.h> | ||
63 | #include <linux/list.h> | 62 | #include <linux/list.h> |
64 | 63 | ||
65 | MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); | 64 | MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); |
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index 9907ad3bea23..b57370dc4e3d 100644 --- a/drivers/input/serio/hp_sdc.c +++ b/drivers/input/serio/hp_sdc.c | |||
@@ -62,7 +62,6 @@ | |||
62 | */ | 62 | */ |
63 | 63 | ||
64 | #include <linux/hp_sdc.h> | 64 | #include <linux/hp_sdc.h> |
65 | #include <linux/sched.h> | ||
66 | #include <linux/errno.h> | 65 | #include <linux/errno.h> |
67 | #include <linux/init.h> | 66 | #include <linux/init.h> |
68 | #include <linux/module.h> | 67 | #include <linux/module.h> |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index cd251efda410..0a26e0663542 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -546,7 +546,7 @@ static void ads7846_rx(void *ads) | |||
546 | ts->spi->dev.bus_id, ts->tc.ignore, Rt); | 546 | ts->spi->dev.bus_id, ts->tc.ignore, Rt); |
547 | #endif | 547 | #endif |
548 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), | 548 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), |
549 | HRTIMER_REL); | 549 | HRTIMER_MODE_REL); |
550 | return; | 550 | return; |
551 | } | 551 | } |
552 | 552 | ||
@@ -578,7 +578,8 @@ static void ads7846_rx(void *ads) | |||
578 | #endif | 578 | #endif |
579 | } | 579 | } |
580 | 580 | ||
581 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), HRTIMER_REL); | 581 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), |
582 | HRTIMER_MODE_REL); | ||
582 | } | 583 | } |
583 | 584 | ||
584 | static int ads7846_debounce(void *ads, int data_idx, int *val) | 585 | static int ads7846_debounce(void *ads, int data_idx, int *val) |
@@ -667,7 +668,7 @@ static void ads7846_rx_val(void *ads) | |||
667 | status); | 668 | status); |
668 | } | 669 | } |
669 | 670 | ||
670 | static int ads7846_timer(struct hrtimer *handle) | 671 | static enum hrtimer_restart ads7846_timer(struct hrtimer *handle) |
671 | { | 672 | { |
672 | struct ads7846 *ts = container_of(handle, struct ads7846, timer); | 673 | struct ads7846 *ts = container_of(handle, struct ads7846, timer); |
673 | int status = 0; | 674 | int status = 0; |
@@ -724,7 +725,7 @@ static irqreturn_t ads7846_irq(int irq, void *handle) | |||
724 | disable_irq(ts->spi->irq); | 725 | disable_irq(ts->spi->irq); |
725 | ts->pending = 1; | 726 | ts->pending = 1; |
726 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_DELAY), | 727 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_DELAY), |
727 | HRTIMER_REL); | 728 | HRTIMER_MODE_REL); |
728 | } | 729 | } |
729 | } | 730 | } |
730 | spin_unlock_irqrestore(&ts->lock, flags); | 731 | spin_unlock_irqrestore(&ts->lock, flags); |
@@ -862,7 +863,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
862 | ts->spi = spi; | 863 | ts->spi = spi; |
863 | ts->input = input_dev; | 864 | ts->input = input_dev; |
864 | 865 | ||
865 | hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_REL); | 866 | hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
866 | ts->timer.function = ads7846_timer; | 867 | ts->timer.function = ads7846_timer; |
867 | 868 | ||
868 | spin_lock_init(&ts->lock); | 869 | spin_lock_init(&ts->lock); |
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index 8cec9c3898ec..2a49cea0a223 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/major.h> | 15 | #include <linux/major.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
18 | #include <linux/fcntl.h> | 17 | #include <linux/fcntl.h> |
19 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
diff --git a/drivers/isdn/gigaset/Makefile b/drivers/isdn/gigaset/Makefile index 835b806a9de7..077e297d8c72 100644 --- a/drivers/isdn/gigaset/Makefile +++ b/drivers/isdn/gigaset/Makefile | |||
@@ -5,4 +5,4 @@ ser_gigaset-y := ser-gigaset.o asyncdata.o | |||
5 | 5 | ||
6 | obj-$(CONFIG_GIGASET_M105) += usb_gigaset.o gigaset.o | 6 | obj-$(CONFIG_GIGASET_M105) += usb_gigaset.o gigaset.o |
7 | obj-$(CONFIG_GIGASET_BASE) += bas_gigaset.o gigaset.o | 7 | obj-$(CONFIG_GIGASET_BASE) += bas_gigaset.o gigaset.o |
8 | obj-$(CONFIG_GIGASET_M105) += ser_gigaset.o gigaset.o | 8 | obj-$(CONFIG_GIGASET_M101) += ser_gigaset.o gigaset.o |
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index eba10466ccc6..a5b941c327f7 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/ptrace.h> | 15 | #include <linux/ptrace.h> |
17 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
diff --git a/drivers/isdn/hardware/eicon/divamnt.c b/drivers/isdn/hardware/eicon/divamnt.c index 6b2940ed0776..4aba5c502d8e 100644 --- a/drivers/isdn/hardware/eicon/divamnt.c +++ b/drivers/isdn/hardware/eicon/divamnt.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/smp_lock.h> | 16 | #include <linux/smp_lock.h> |
18 | #include <linux/poll.h> | 17 | #include <linux/poll.h> |
19 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
diff --git a/drivers/isdn/hardware/eicon/divasmain.c b/drivers/isdn/hardware/eicon/divasmain.c index b365e44072c0..5e862e244117 100644 --- a/drivers/isdn/hardware/eicon/divasmain.c +++ b/drivers/isdn/hardware/eicon/divasmain.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | ||
16 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
17 | #include <asm/io.h> | 16 | #include <asm/io.h> |
18 | #include <linux/ioport.h> | 17 | #include <linux/ioport.h> |
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 9e70c206779e..fc6cc2c065b8 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/ptrace.h> | 17 | #include <linux/ptrace.h> |
19 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
20 | #include <linux/string.h> | 19 | #include <linux/string.h> |
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index 79ab9dda7d08..db7e64424afe 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | #include <linux/sched.h> | ||
42 | #include <linux/ptrace.h> | 41 | #include <linux/ptrace.h> |
43 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
44 | #include <linux/string.h> | 43 | #include <linux/string.h> |
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c index 42bbae2a646c..9f44d3e69fb0 100644 --- a/drivers/isdn/hisax/hfc_usb.c +++ b/drivers/isdn/hisax/hfc_usb.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/usb.h> | 38 | #include <linux/usb.h> |
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | #include <linux/smp_lock.h> | 40 | #include <linux/smp_lock.h> |
41 | #include <linux/sched.h> | ||
42 | #include "hisax.h" | 41 | #include "hisax.h" |
43 | #include "hisax_if.h" | 42 | #include "hisax_if.h" |
44 | #include "hfc_usb.h" | 43 | #include "hfc_usb.h" |
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 45debde05fbd..439cb530def8 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/kernel.h> | 38 | #include <linux/kernel.h> |
39 | #include <linux/module.h> | 39 | #include <linux/module.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | #include <linux/sched.h> | ||
42 | #include <linux/ptrace.h> | 41 | #include <linux/ptrace.h> |
43 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
44 | #include <linux/string.h> | 43 | #include <linux/string.h> |
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index 3e3e18239ec7..ab4bd455450e 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/sched.h> | ||
23 | #include <linux/ptrace.h> | 22 | #include <linux/ptrace.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
25 | #include <linux/string.h> | 24 | #include <linux/string.h> |
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c index a1206498a1cf..84dccd526ac0 100644 --- a/drivers/isdn/hysdn/boardergo.c +++ b/drivers/isdn/hysdn/boardergo.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/sched.h> | ||
18 | #include <linux/signal.h> | 17 | #include <linux/signal.h> |
19 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
20 | #include <linux/ioport.h> | 19 | #include <linux/ioport.h> |
diff --git a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c index 18758772b744..b7b5aa4748a0 100644 --- a/drivers/isdn/hysdn/hysdn_sched.c +++ b/drivers/isdn/hysdn/hysdn_sched.c | |||
@@ -11,7 +11,6 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/sched.h> | ||
15 | #include <linux/signal.h> | 14 | #include <linux/signal.h> |
16 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
17 | #include <linux/ioport.h> | 16 | #include <linux/ioport.h> |
diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c index a20f33b4a220..90a23795db7e 100644 --- a/drivers/isdn/i4l/isdn_bsdcomp.c +++ b/drivers/isdn/i4l/isdn_bsdcomp.c | |||
@@ -56,7 +56,6 @@ | |||
56 | #include <linux/module.h> | 56 | #include <linux/module.h> |
57 | #include <linux/init.h> | 57 | #include <linux/init.h> |
58 | #include <linux/kernel.h> | 58 | #include <linux/kernel.h> |
59 | #include <linux/sched.h> | ||
60 | #include <linux/types.h> | 59 | #include <linux/types.h> |
61 | #include <linux/fcntl.h> | 60 | #include <linux/fcntl.h> |
62 | #include <linux/interrupt.h> | 61 | #include <linux/interrupt.h> |
diff --git a/drivers/isdn/pcbit/callbacks.c b/drivers/isdn/pcbit/callbacks.c index f151f36c8255..43ecd0f54235 100644 --- a/drivers/isdn/pcbit/callbacks.c +++ b/drivers/isdn/pcbit/callbacks.c | |||
@@ -15,7 +15,6 @@ | |||
15 | * NULL pointer dereference in cb_in_1 (originally fixed in 2.0) | 15 | * NULL pointer dereference in cb_in_1 (originally fixed in 2.0) |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/sched.h> | ||
19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
20 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
21 | 20 | ||
diff --git a/drivers/isdn/pcbit/capi.c b/drivers/isdn/pcbit/capi.c index bef321d0e51d..47c59e95898d 100644 --- a/drivers/isdn/pcbit/capi.c +++ b/drivers/isdn/pcbit/capi.c | |||
@@ -27,7 +27,6 @@ | |||
27 | * encode our number in CallerPN and ConnectedPN | 27 | * encode our number in CallerPN and ConnectedPN |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/sched.h> | ||
31 | #include <linux/string.h> | 30 | #include <linux/string.h> |
32 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
33 | 32 | ||
diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c index 386c5ce64844..8c66bcb953a1 100644 --- a/drivers/isdn/pcbit/drv.c +++ b/drivers/isdn/pcbit/drv.c | |||
@@ -19,7 +19,6 @@ | |||
19 | 19 | ||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | 21 | ||
22 | #include <linux/sched.h> | ||
23 | 22 | ||
24 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
25 | 24 | ||
diff --git a/drivers/isdn/pcbit/edss1.c b/drivers/isdn/pcbit/edss1.c index 1ad8b07efd8b..37e9626cebf6 100644 --- a/drivers/isdn/pcbit/edss1.c +++ b/drivers/isdn/pcbit/edss1.c | |||
@@ -15,7 +15,6 @@ | |||
15 | * move state/event descriptions to a user space logger | 15 | * move state/event descriptions to a user space logger |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/sched.h> | ||
19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
20 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
21 | 20 | ||
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c index 58eee50c8e26..5ba2a879df14 100644 --- a/drivers/isdn/pcbit/layer2.c +++ b/drivers/isdn/pcbit/layer2.c | |||
@@ -24,7 +24,6 @@ | |||
24 | * re-write/remove debug printks | 24 | * re-write/remove debug printks |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/sched.h> | ||
28 | #include <linux/string.h> | 27 | #include <linux/string.h> |
29 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
30 | #include <linux/types.h> | 29 | #include <linux/types.h> |
diff --git a/drivers/isdn/pcbit/module.c b/drivers/isdn/pcbit/module.c index 7b7b1777f09b..04ea241ff176 100644 --- a/drivers/isdn/pcbit/module.c +++ b/drivers/isdn/pcbit/module.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/sched.h> | ||
15 | #include <linux/string.h> | 14 | #include <linux/string.h> |
16 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
17 | #include <linux/skbuff.h> | 16 | #include <linux/skbuff.h> |
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index 1e640b899175..fd4e91734388 100644 --- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c | |||
@@ -1879,12 +1879,6 @@ again: | |||
1879 | 1879 | ||
1880 | asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); | 1880 | asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); |
1881 | 1881 | ||
1882 | /* | ||
1883 | * Profile KVM exit RIPs: | ||
1884 | */ | ||
1885 | if (unlikely(prof_on == KVM_PROFILING)) | ||
1886 | profile_hit(KVM_PROFILING, (void *)vmcs_readl(GUEST_RIP)); | ||
1887 | |||
1888 | kvm_run->exit_type = 0; | 1882 | kvm_run->exit_type = 0; |
1889 | if (fail) { | 1883 | if (fail) { |
1890 | kvm_run->exit_type = KVM_EXIT_TYPE_FAIL_ENTRY; | 1884 | kvm_run->exit_type = KVM_EXIT_TYPE_FAIL_ENTRY; |
@@ -1907,6 +1901,12 @@ again: | |||
1907 | 1901 | ||
1908 | reload_tss(); | 1902 | reload_tss(); |
1909 | } | 1903 | } |
1904 | /* | ||
1905 | * Profile KVM exit RIPs: | ||
1906 | */ | ||
1907 | if (unlikely(prof_on == KVM_PROFILING)) | ||
1908 | profile_hit(KVM_PROFILING, (void *)vmcs_readl(GUEST_RIP)); | ||
1909 | |||
1910 | vcpu->launched = 1; | 1910 | vcpu->launched = 1; |
1911 | kvm_run->exit_type = KVM_EXIT_TYPE_VM_EXIT; | 1911 | kvm_run->exit_type = KVM_EXIT_TYPE_VM_EXIT; |
1912 | r = kvm_handle_exit(kvm_run, vcpu); | 1912 | r = kvm_handle_exit(kvm_run, vcpu); |
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c index 1c7d6f221b55..b77ef5187d6d 100644 --- a/drivers/macintosh/adbhid.c +++ b/drivers/macintosh/adbhid.c | |||
@@ -574,8 +574,8 @@ static struct adb_request led_request; | |||
574 | static int leds_pending[16]; | 574 | static int leds_pending[16]; |
575 | static int leds_req_pending; | 575 | static int leds_req_pending; |
576 | static int pending_devs[16]; | 576 | static int pending_devs[16]; |
577 | static int pending_led_start=0; | 577 | static int pending_led_start; |
578 | static int pending_led_end=0; | 578 | static int pending_led_end; |
579 | static DEFINE_SPINLOCK(leds_lock); | 579 | static DEFINE_SPINLOCK(leds_lock); |
580 | 580 | ||
581 | static void leds_done(struct adb_request *req) | 581 | static void leds_done(struct adb_request *req) |
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c index a6d50f4fabd7..c5e4d43f97fc 100644 --- a/drivers/macintosh/apm_emu.c +++ b/drivers/macintosh/apm_emu.c | |||
@@ -102,7 +102,7 @@ static struct pmu_sleep_notifier apm_sleep_notifier = { | |||
102 | SLEEP_LEVEL_USERLAND, | 102 | SLEEP_LEVEL_USERLAND, |
103 | }; | 103 | }; |
104 | 104 | ||
105 | static char driver_version[] = "0.5"; /* no spaces */ | 105 | static const char driver_version[] = "0.5"; /* no spaces */ |
106 | 106 | ||
107 | #ifdef DEBUG | 107 | #ifdef DEBUG |
108 | static char * apm_event_name[] = { | 108 | static char * apm_event_name[] = { |
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c index ee6b4ca69130..c1fd816e9f09 100644 --- a/drivers/macintosh/mac_hid.c +++ b/drivers/macintosh/mac_hid.c | |||
@@ -17,10 +17,10 @@ | |||
17 | 17 | ||
18 | static struct input_dev *emumousebtn; | 18 | static struct input_dev *emumousebtn; |
19 | static int emumousebtn_input_register(void); | 19 | static int emumousebtn_input_register(void); |
20 | static int mouse_emulate_buttons = 0; | 20 | static int mouse_emulate_buttons; |
21 | static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ | 21 | static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ |
22 | static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ | 22 | static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ |
23 | static int mouse_last_keycode = 0; | 23 | static int mouse_last_keycode; |
24 | 24 | ||
25 | #if defined(CONFIG_SYSCTL) | 25 | #if defined(CONFIG_SYSCTL) |
26 | /* file(s) in /proc/sys/dev/mac_hid */ | 26 | /* file(s) in /proc/sys/dev/mac_hid */ |
@@ -138,7 +138,7 @@ int __init mac_hid_init(void) | |||
138 | return err; | 138 | return err; |
139 | 139 | ||
140 | #if defined(CONFIG_SYSCTL) | 140 | #if defined(CONFIG_SYSCTL) |
141 | mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1); | 141 | mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir); |
142 | #endif /* CONFIG_SYSCTL */ | 142 | #endif /* CONFIG_SYSCTL */ |
143 | 143 | ||
144 | return 0; | 144 | return 0; |
diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c index 797cef72258f..026b67f4f659 100644 --- a/drivers/macintosh/macio-adb.c +++ b/drivers/macintosh/macio-adb.c | |||
@@ -6,7 +6,6 @@ | |||
6 | #include <linux/errno.h> | 6 | #include <linux/errno.h> |
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/sched.h> | ||
10 | #include <linux/spinlock.h> | 9 | #include <linux/spinlock.h> |
11 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
12 | #include <asm/prom.h> | 11 | #include <asm/prom.h> |
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index 3d3bf1643e73..a7ce55926638 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c | |||
@@ -48,11 +48,11 @@ static u8 FAN_SPD_SET[2] = {0x30, 0x31}; | |||
48 | 48 | ||
49 | static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */ | 49 | static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */ |
50 | static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */ | 50 | static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */ |
51 | static const char *sensor_location[3] = {NULL, NULL, NULL}; | 51 | static const char *sensor_location[3]; |
52 | 52 | ||
53 | static int limit_adjust = 0; | 53 | static int limit_adjust; |
54 | static int fan_speed = -1; | 54 | static int fan_speed = -1; |
55 | static int verbose = 0; | 55 | static int verbose; |
56 | 56 | ||
57 | MODULE_AUTHOR("Colin Leroy <colin@colino.net>"); | 57 | MODULE_AUTHOR("Colin Leroy <colin@colino.net>"); |
58 | MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and " | 58 | MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and " |
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c index df66291b1322..d58fcf6cca0a 100644 --- a/drivers/macintosh/via-cuda.c +++ b/drivers/macintosh/via-cuda.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/adb.h> | 16 | #include <linux/adb.h> |
18 | #include <linux/cuda.h> | 17 | #include <linux/cuda.h> |
19 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
@@ -86,7 +85,7 @@ static int data_index; | |||
86 | #ifdef CONFIG_PPC | 85 | #ifdef CONFIG_PPC |
87 | static struct device_node *vias; | 86 | static struct device_node *vias; |
88 | #endif | 87 | #endif |
89 | static int cuda_fully_inited = 0; | 88 | static int cuda_fully_inited; |
90 | 89 | ||
91 | #ifdef CONFIG_ADB | 90 | #ifdef CONFIG_ADB |
92 | static int cuda_probe(void); | 91 | static int cuda_probe(void); |
diff --git a/drivers/macintosh/via-macii.c b/drivers/macintosh/via-macii.c index 5d88d5b0ad99..1b3bad62a1be 100644 --- a/drivers/macintosh/via-macii.c +++ b/drivers/macintosh/via-macii.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/sched.h> | ||
23 | #include <linux/adb.h> | 22 | #include <linux/adb.h> |
24 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
@@ -107,10 +106,10 @@ static enum macii_state { | |||
107 | awaiting_reply | 106 | awaiting_reply |
108 | } macii_state; | 107 | } macii_state; |
109 | 108 | ||
110 | static int need_poll = 0; | 109 | static int need_poll; |
111 | static int command_byte = 0; | 110 | static int command_byte; |
112 | static int last_reply = 0; | 111 | static int last_reply; |
113 | static int last_active = 0; | 112 | static int last_active; |
114 | 113 | ||
115 | static struct adb_request *current_req; | 114 | static struct adb_request *current_req; |
116 | static struct adb_request *last_req; | 115 | static struct adb_request *last_req; |
@@ -124,7 +123,7 @@ static int first_byte; | |||
124 | static int prefix_len; | 123 | static int prefix_len; |
125 | static int status = ST_IDLE|TREQ; | 124 | static int status = ST_IDLE|TREQ; |
126 | static int last_status; | 125 | static int last_status; |
127 | static int driver_running = 0; | 126 | static int driver_running; |
128 | 127 | ||
129 | /* debug level 10 required for ADB logging (should be && debug_adb, ideally) */ | 128 | /* debug level 10 required for ADB logging (should be && debug_adb, ideally) */ |
130 | 129 | ||
diff --git a/drivers/macintosh/via-maciisi.c b/drivers/macintosh/via-maciisi.c index 1f0aa5dc9aa5..2dc788042707 100644 --- a/drivers/macintosh/via-maciisi.c +++ b/drivers/macintosh/via-maciisi.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/sched.h> | ||
22 | #include <linux/adb.h> | 21 | #include <linux/adb.h> |
23 | #include <linux/cuda.h> | 22 | #include <linux/cuda.h> |
24 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
@@ -63,10 +62,10 @@ static volatile unsigned char *via; | |||
63 | 62 | ||
64 | #undef DEBUG_MACIISI_ADB | 63 | #undef DEBUG_MACIISI_ADB |
65 | 64 | ||
66 | static struct adb_request* current_req = NULL; | 65 | static struct adb_request* current_req; |
67 | static struct adb_request* last_req = NULL; | 66 | static struct adb_request* last_req; |
68 | static unsigned char maciisi_rbuf[16]; | 67 | static unsigned char maciisi_rbuf[16]; |
69 | static unsigned char *reply_ptr = NULL; | 68 | static unsigned char *reply_ptr; |
70 | static int data_index; | 69 | static int data_index; |
71 | static int reading_reply; | 70 | static int reading_reply; |
72 | static int reply_len; | 71 | static int reply_len; |
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 96bea4b62c43..b6073bdb50c3 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -141,13 +141,13 @@ static volatile int adb_int_pending; | |||
141 | static volatile int disable_poll; | 141 | static volatile int disable_poll; |
142 | static struct device_node *vias; | 142 | static struct device_node *vias; |
143 | static int pmu_kind = PMU_UNKNOWN; | 143 | static int pmu_kind = PMU_UNKNOWN; |
144 | static int pmu_fully_inited = 0; | 144 | static int pmu_fully_inited; |
145 | static int pmu_has_adb; | 145 | static int pmu_has_adb; |
146 | static struct device_node *gpio_node; | 146 | static struct device_node *gpio_node; |
147 | static unsigned char __iomem *gpio_reg = NULL; | 147 | static unsigned char __iomem *gpio_reg; |
148 | static int gpio_irq = NO_IRQ; | 148 | static int gpio_irq = NO_IRQ; |
149 | static int gpio_irq_enabled = -1; | 149 | static int gpio_irq_enabled = -1; |
150 | static volatile int pmu_suspended = 0; | 150 | static volatile int pmu_suspended; |
151 | static spinlock_t pmu_lock; | 151 | static spinlock_t pmu_lock; |
152 | static u8 pmu_intr_mask; | 152 | static u8 pmu_intr_mask; |
153 | static int pmu_version; | 153 | static int pmu_version; |
@@ -169,7 +169,7 @@ static int option_server_mode; | |||
169 | 169 | ||
170 | int pmu_battery_count; | 170 | int pmu_battery_count; |
171 | int pmu_cur_battery; | 171 | int pmu_cur_battery; |
172 | unsigned int pmu_power_flags; | 172 | unsigned int pmu_power_flags = PMU_PWR_AC_PRESENT; |
173 | struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES]; | 173 | struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES]; |
174 | static int query_batt_timer = BATTERY_POLLING_COUNT; | 174 | static int query_batt_timer = BATTERY_POLLING_COUNT; |
175 | static struct adb_request batt_req; | 175 | static struct adb_request batt_req; |
@@ -180,7 +180,7 @@ int asleep; | |||
180 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); | 180 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); |
181 | 181 | ||
182 | #ifdef CONFIG_ADB | 182 | #ifdef CONFIG_ADB |
183 | static int adb_dev_map = 0; | 183 | static int adb_dev_map; |
184 | static int pmu_adb_flags; | 184 | static int pmu_adb_flags; |
185 | 185 | ||
186 | static int pmu_probe(void); | 186 | static int pmu_probe(void); |
@@ -2776,7 +2776,7 @@ pmu_polled_request(struct adb_request *req) | |||
2776 | 2776 | ||
2777 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) | 2777 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) |
2778 | 2778 | ||
2779 | static int pmu_sys_suspended = 0; | 2779 | static int pmu_sys_suspended; |
2780 | 2780 | ||
2781 | static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state) | 2781 | static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state) |
2782 | { | 2782 | { |
@@ -2816,7 +2816,6 @@ static struct sysdev_class pmu_sysclass = { | |||
2816 | }; | 2816 | }; |
2817 | 2817 | ||
2818 | static struct sys_device device_pmu = { | 2818 | static struct sys_device device_pmu = { |
2819 | .id = 0, | ||
2820 | .cls = &pmu_sysclass, | 2819 | .cls = &pmu_sysclass, |
2821 | }; | 2820 | }; |
2822 | 2821 | ||
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c index 4f5b6fa196c5..356c7216a179 100644 --- a/drivers/macintosh/via-pmu68k.c +++ b/drivers/macintosh/via-pmu68k.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/sched.h> | ||
26 | #include <linux/miscdevice.h> | 25 | #include <linux/miscdevice.h> |
27 | #include <linux/blkdev.h> | 26 | #include <linux/blkdev.h> |
28 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
@@ -96,10 +95,10 @@ static int data_index; | |||
96 | static int data_len; | 95 | static int data_len; |
97 | static int adb_int_pending; | 96 | static int adb_int_pending; |
98 | static int pmu_adb_flags; | 97 | static int pmu_adb_flags; |
99 | static int adb_dev_map = 0; | 98 | static int adb_dev_map; |
100 | static struct adb_request bright_req_1, bright_req_2, bright_req_3; | 99 | static struct adb_request bright_req_1, bright_req_2, bright_req_3; |
101 | static int pmu_kind = PMU_UNKNOWN; | 100 | static int pmu_kind = PMU_UNKNOWN; |
102 | static int pmu_fully_inited = 0; | 101 | static int pmu_fully_inited; |
103 | 102 | ||
104 | int asleep; | 103 | int asleep; |
105 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); | 104 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); |
diff --git a/drivers/md/md.c b/drivers/md/md.c index e85fa75a7912..05febfd9f071 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -5581,7 +5581,7 @@ static int __init md_init(void) | |||
5581 | md_probe, NULL, NULL); | 5581 | md_probe, NULL, NULL); |
5582 | 5582 | ||
5583 | register_reboot_notifier(&md_notifier); | 5583 | register_reboot_notifier(&md_notifier); |
5584 | raid_table_header = register_sysctl_table(raid_root_table, 1); | 5584 | raid_table_header = register_sysctl_table(raid_root_table); |
5585 | 5585 | ||
5586 | md_geninit(); | 5586 | md_geninit(); |
5587 | return (0); | 5587 | return (0); |
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c index e0bd2d8f0f0c..5347a406fff7 100644 --- a/drivers/media/dvb/b2c2/flexcop-i2c.c +++ b/drivers/media/dvb/b2c2/flexcop-i2c.c | |||
@@ -190,6 +190,7 @@ int flexcop_i2c_init(struct flexcop_device *fc) | |||
190 | fc->i2c_adap.class = I2C_CLASS_TV_DIGITAL; | 190 | fc->i2c_adap.class = I2C_CLASS_TV_DIGITAL; |
191 | fc->i2c_adap.algo = &flexcop_algo; | 191 | fc->i2c_adap.algo = &flexcop_algo; |
192 | fc->i2c_adap.algo_data = NULL; | 192 | fc->i2c_adap.algo_data = NULL; |
193 | fc->i2c_adap.dev.parent = fc->dev; | ||
193 | 194 | ||
194 | if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0) | 195 | if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0) |
195 | return ret; | 196 | return ret; |
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 988499dfddf8..fc77de45ca4d 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/vmalloc.h> | 25 | #include <linux/vmalloc.h> |
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/sched.h> | ||
29 | #include <linux/poll.h> | 28 | #include <linux/poll.h> |
30 | #include <linux/ioctl.h> | 29 | #include <linux/ioctl.h> |
31 | #include <linux/wait.h> | 30 | #include <linux/wait.h> |
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index 40774feb8953..826b47f155a0 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/moduleparam.h> | 28 | #include <linux/moduleparam.h> |
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
33 | #include <linux/device.h> | 32 | #include <linux/device.h> |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c index 55ba020386c9..70df31b0a8a9 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c | |||
@@ -27,6 +27,7 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d) | |||
27 | #endif | 27 | #endif |
28 | d->i2c_adap.algo = d->props.i2c_algo; | 28 | d->i2c_adap.algo = d->props.i2c_algo; |
29 | d->i2c_adap.algo_data = NULL; | 29 | d->i2c_adap.algo_data = NULL; |
30 | d->i2c_adap.dev.parent = &d->udev->dev; | ||
30 | 31 | ||
31 | i2c_set_adapdata(&d->i2c_adap, d); | 32 | i2c_set_adapdata(&d->i2c_adap, d); |
32 | 33 | ||
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c index 8c577cf30fb3..795e6e95915c 100644 --- a/drivers/media/dvb/ttpci/av7110_av.c +++ b/drivers/media/dvb/ttpci/av7110_av.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/string.h> | 33 | #include <linux/string.h> |
34 | #include <linux/sched.h> | ||
35 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
36 | #include <linux/smp_lock.h> | 35 | #include <linux/smp_lock.h> |
37 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c index dd9aee314e0a..4251a97d420e 100644 --- a/drivers/media/dvb/ttpci/av7110_ca.c +++ b/drivers/media/dvb/ttpci/av7110_ca.c | |||
@@ -29,7 +29,6 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
32 | #include <linux/sched.h> | ||
33 | #include <linux/types.h> | 32 | #include <linux/types.h> |
34 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
35 | #include <linux/fs.h> | 34 | #include <linux/fs.h> |
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 37de2e88a273..4d7150e15d1e 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/types.h> | 32 | #include <linux/types.h> |
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/string.h> | 34 | #include <linux/string.h> |
35 | #include <linux/sched.h> | ||
36 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
37 | #include <linux/smp_lock.h> | 36 | #include <linux/smp_lock.h> |
38 | #include <linux/fs.h> | 37 | #include <linux/fs.h> |
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c index 10cfe3131e72..dbfd5e7b4be0 100644 --- a/drivers/media/dvb/ttpci/av7110_v4l.c +++ b/drivers/media/dvb/ttpci/av7110_v4l.c | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/sched.h> | ||
30 | #include <linux/types.h> | 29 | #include <linux/types.h> |
31 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
32 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 60820deb900b..b60cdc93d6db 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | |||
@@ -1690,6 +1690,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
1690 | #endif | 1690 | #endif |
1691 | ttusb->i2c_adap.algo = &ttusb_dec_algo; | 1691 | ttusb->i2c_adap.algo = &ttusb_dec_algo; |
1692 | ttusb->i2c_adap.algo_data = NULL; | 1692 | ttusb->i2c_adap.algo_data = NULL; |
1693 | ttusb->i2c_adap.dev.parent = &udev->dev; | ||
1693 | 1694 | ||
1694 | result = i2c_add_adapter(&ttusb->i2c_adap); | 1695 | result = i2c_add_adapter(&ttusb->i2c_adap); |
1695 | if (result) { | 1696 | if (result) { |
diff --git a/drivers/media/radio/miropcm20-rds.c b/drivers/media/radio/miropcm20-rds.c index c93490ec96bb..aed11477378b 100644 --- a/drivers/media/radio/miropcm20-rds.c +++ b/drivers/media/radio/miropcm20-rds.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/fs.h> | 15 | #include <linux/fs.h> |
16 | #include <linux/miscdevice.h> | 16 | #include <linux/miscdevice.h> |
17 | #include <linux/sched.h> /* current, TASK_*, schedule_timeout() */ | ||
18 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
19 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
20 | #include "miropcm20-rds-core.h" | 19 | #include "miropcm20-rds-core.h" |
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c index 9bba6eb10925..e67b7f258029 100644 --- a/drivers/media/radio/radio-maestro.c +++ b/drivers/media/radio/radio-maestro.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/sched.h> | ||
26 | #include <asm/io.h> | 25 | #include <asm/io.h> |
27 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
28 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index 00a2f31d2af3..6beeb74004b1 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/ioport.h> | 36 | #include <linux/ioport.h> |
37 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
38 | #include <linux/sched.h> | ||
39 | #include <asm/io.h> | 38 | #include <asm/io.h> |
40 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
41 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 48709582a186..2aa9ce920607 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <asm/io.h> | 42 | #include <asm/io.h> |
43 | #include <asm/pgtable.h> | 43 | #include <asm/pgtable.h> |
44 | #include <asm/page.h> | 44 | #include <asm/page.h> |
45 | #include <linux/sched.h> | ||
46 | #include <linux/types.h> | 45 | #include <linux/types.h> |
47 | 46 | ||
48 | #include <linux/videodev.h> | 47 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 68e7d7aff5e6..a3246a283aa4 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <asm/io.h> | 38 | #include <asm/io.h> |
39 | #include <asm/pgtable.h> | 39 | #include <asm/pgtable.h> |
40 | #include <asm/page.h> | 40 | #include <asm/page.h> |
41 | #include <linux/sched.h> | ||
42 | #include <linux/types.h> | 41 | #include <linux/types.h> |
43 | 42 | ||
44 | #include <linux/videodev.h> | 43 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index e7b38fdd5e3c..68673863d5c9 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <asm/io.h> | 42 | #include <asm/io.h> |
43 | #include <asm/pgtable.h> | 43 | #include <asm/pgtable.h> |
44 | #include <asm/page.h> | 44 | #include <asm/page.h> |
45 | #include <linux/sched.h> | ||
46 | #include <linux/types.h> | 45 | #include <linux/types.h> |
47 | 46 | ||
48 | #include <linux/videodev.h> | 47 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index af3b61d4fa7d..42e2299dcb22 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <asm/io.h> | 42 | #include <asm/io.h> |
43 | #include <asm/pgtable.h> | 43 | #include <asm/pgtable.h> |
44 | #include <asm/page.h> | 44 | #include <asm/page.h> |
45 | #include <linux/sched.h> | ||
46 | #include <linux/types.h> | 45 | #include <linux/types.h> |
47 | 46 | ||
48 | #include <linux/videodev.h> | 47 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c index 63676e7bd635..6fc6b0260056 100644 --- a/drivers/media/video/bt8xx/bttv-vbi.c +++ b/drivers/media/video/bt8xx/bttv-vbi.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
26 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/sched.h> | ||
29 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
30 | #include <linux/kdev_t.h> | 29 | #include <linux/kdev_t.h> |
31 | #include <asm/io.h> | 30 | #include <asm/io.h> |
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c index fb1410c6f864..4dae8925667f 100644 --- a/drivers/media/video/cafe_ccic.c +++ b/drivers/media/video/cafe_ccic.c | |||
@@ -549,6 +549,7 @@ static int cafe_smbus_setup(struct cafe_camera *cam) | |||
549 | adap->client_unregister = cafe_smbus_detach; | 549 | adap->client_unregister = cafe_smbus_detach; |
550 | adap->algo = &cafe_smbus_algo; | 550 | adap->algo = &cafe_smbus_algo; |
551 | strcpy(adap->name, "cafe_ccic"); | 551 | strcpy(adap->name, "cafe_ccic"); |
552 | adap->dev.parent = &cam->pdev->dev; | ||
552 | i2c_set_adapdata(adap, cam); | 553 | i2c_set_adapdata(adap, cam); |
553 | ret = i2c_add_adapter(adap); | 554 | ret = i2c_add_adapter(adap); |
554 | if (ret) | 555 | if (ret) |
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c index 2bd84d351a18..063df03dcf2e 100644 --- a/drivers/media/video/cx88/cx88-tvaudio.c +++ b/drivers/media/video/cx88/cx88-tvaudio.c | |||
@@ -46,7 +46,6 @@ | |||
46 | #include <linux/pci.h> | 46 | #include <linux/pci.h> |
47 | #include <linux/signal.h> | 47 | #include <linux/signal.h> |
48 | #include <linux/ioport.h> | 48 | #include <linux/ioport.h> |
49 | #include <linux/sched.h> | ||
50 | #include <linux/types.h> | 49 | #include <linux/types.h> |
51 | #include <linux/interrupt.h> | 50 | #include <linux/interrupt.h> |
52 | #include <linux/vmalloc.h> | 51 | #include <linux/vmalloc.h> |
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c index 3ffb5684f127..55d45b0032cf 100644 --- a/drivers/media/video/em28xx/em28xx-input.c +++ b/drivers/media/video/em28xx/em28xx-input.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/moduleparam.h> | 25 | #include <linux/moduleparam.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/sched.h> | ||
29 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
30 | #include <linux/input.h> | 29 | #include <linux/input.h> |
31 | #include <linux/usb.h> | 30 | #include <linux/usb.h> |
diff --git a/drivers/media/video/indycam.c b/drivers/media/video/indycam.c index 7420b79e987a..5c2c4029ff86 100644 --- a/drivers/media/video/indycam.c +++ b/drivers/media/video/indycam.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/major.h> | 17 | #include <linux/major.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
22 | 21 | ||
23 | #include <linux/videodev.h> | 22 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 59edf58204de..210582d420f8 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/moduleparam.h> | 31 | #include <linux/moduleparam.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/sched.h> | ||
35 | #include <linux/string.h> | 34 | #include <linux/string.h> |
36 | #include <linux/timer.h> | 35 | #include <linux/timer.h> |
37 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c index 9528e10c2828..98681da5e3b9 100644 --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c | |||
@@ -28,7 +28,6 @@ | |||
28 | */ | 28 | */ |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/pci.h> | 30 | #include <linux/pci.h> |
31 | #include <linux/sched.h> | ||
32 | #include <linux/init.h> | 31 | #include <linux/init.h> |
33 | #include <linux/videodev.h> | 32 | #include <linux/videodev.h> |
34 | #include <media/v4l2-common.h> | 33 | #include <media/v4l2-common.h> |
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c index d38d3dc4a012..b5a67f0dd19f 100644 --- a/drivers/media/video/pms.c +++ b/drivers/media/video/pms.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/ioport.h> | 28 | #include <linux/ioport.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <asm/io.h> | 30 | #include <asm/io.h> |
31 | #include <linux/sched.h> | ||
32 | #include <linux/videodev.h> | 31 | #include <linux/videodev.h> |
33 | #include <media/v4l2-common.h> | 32 | #include <media/v4l2-common.h> |
34 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c index f9bb41d8f4f3..62a7cfca837d 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c +++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c | |||
@@ -977,6 +977,7 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw) | |||
977 | memcpy(&hdw->i2c_adap,&pvr2_i2c_adap_template,sizeof(hdw->i2c_adap)); | 977 | memcpy(&hdw->i2c_adap,&pvr2_i2c_adap_template,sizeof(hdw->i2c_adap)); |
978 | memcpy(&hdw->i2c_algo,&pvr2_i2c_algo_template,sizeof(hdw->i2c_algo)); | 978 | memcpy(&hdw->i2c_algo,&pvr2_i2c_algo_template,sizeof(hdw->i2c_algo)); |
979 | strlcpy(hdw->i2c_adap.name,hdw->name,sizeof(hdw->i2c_adap.name)); | 979 | strlcpy(hdw->i2c_adap.name,hdw->name,sizeof(hdw->i2c_adap.name)); |
980 | hdw->i2c_adap.dev.parent = &hdw->usb_dev->dev; | ||
980 | hdw->i2c_adap.algo = &hdw->i2c_algo; | 981 | hdw->i2c_adap.algo = &hdw->i2c_algo; |
981 | hdw->i2c_adap.algo_data = hdw; | 982 | hdw->i2c_adap.algo_data = hdw; |
982 | hdw->i2c_pend_mask = 0; | 983 | hdw->i2c_pend_mask = 0; |
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index 0b5d159895bf..76f5f5d49dae 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c | |||
@@ -40,7 +40,6 @@ | |||
40 | 40 | ||
41 | #include <linux/module.h> | 41 | #include <linux/module.h> |
42 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
43 | #include <linux/sched.h> | ||
44 | #include <linux/mm.h> | 43 | #include <linux/mm.h> |
45 | #include <linux/init.h> | 44 | #include <linux/init.h> |
46 | #include <linux/i2c.h> | 45 | #include <linux/i2c.h> |
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 686fd4746205..44dc7479119c 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <asm/io.h> | 41 | #include <asm/io.h> |
42 | #include <asm/pgtable.h> | 42 | #include <asm/pgtable.h> |
43 | #include <asm/page.h> | 43 | #include <asm/page.h> |
44 | #include <linux/sched.h> | ||
45 | #include <linux/types.h> | 44 | #include <linux/types.h> |
46 | 45 | ||
47 | #include <linux/videodev.h> | 46 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index 90398ab8252e..2ce3321ab995 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include <asm/io.h> | 44 | #include <asm/io.h> |
45 | #include <asm/pgtable.h> | 45 | #include <asm/pgtable.h> |
46 | #include <asm/page.h> | 46 | #include <asm/page.h> |
47 | #include <linux/sched.h> | ||
48 | #include <linux/types.h> | 47 | #include <linux/types.h> |
49 | 48 | ||
50 | #include <linux/videodev.h> | 49 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c index 708fae51e8ee..269d7114a93a 100644 --- a/drivers/media/video/saa711x.c +++ b/drivers/media/video/saa711x.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <asm/io.h> | 35 | #include <asm/io.h> |
36 | #include <asm/pgtable.h> | 36 | #include <asm/pgtable.h> |
37 | #include <asm/page.h> | 37 | #include <asm/page.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/types.h> | 38 | #include <linux/types.h> |
40 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
41 | #include <linux/videodev.h> | 40 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index afc8f352b8e7..57f1f5d409e0 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c | |||
@@ -1,6 +1,5 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
2 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
3 | #include <linux/sched.h> | ||
4 | #include <linux/string.h> | 3 | #include <linux/string.h> |
5 | #include <linux/timer.h> | 4 | #include <linux/timer.h> |
6 | #include <linux/delay.h> | 5 | #include <linux/delay.h> |
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 60b38defd9bc..e4252683a597 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/moduleparam.h> | 22 | #include <linux/moduleparam.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/sched.h> | ||
26 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
27 | #include <linux/input.h> | 26 | #include <linux/input.h> |
28 | 27 | ||
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 9c308410856d..e0fdb1ab7580 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <asm/io.h> | 38 | #include <asm/io.h> |
39 | #include <asm/pgtable.h> | 39 | #include <asm/pgtable.h> |
40 | #include <asm/page.h> | 40 | #include <asm/page.h> |
41 | #include <linux/sched.h> | ||
42 | #include <linux/types.h> | 41 | #include <linux/types.h> |
43 | 42 | ||
44 | #include <linux/videodev.h> | 43 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c index 746cadb8f1c4..8615a6081a5d 100644 --- a/drivers/media/video/saa7191.c +++ b/drivers/media/video/saa7191.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/major.h> | 17 | #include <linux/major.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
22 | 21 | ||
23 | #include <linux/videodev.h> | 22 | #include <linux/videodev.h> |
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c index 78e043ac9ea0..d1ccc064206f 100644 --- a/drivers/media/video/tda7432.c +++ b/drivers/media/video/tda7432.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/kernel.h> | 40 | #include <linux/kernel.h> |
41 | #include <linux/sched.h> | ||
42 | #include <linux/string.h> | 41 | #include <linux/string.h> |
43 | #include <linux/timer.h> | 42 | #include <linux/timer.h> |
44 | #include <linux/delay.h> | 43 | #include <linux/delay.h> |
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index 827633b3bb43..00f0e8b6e03b 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c | |||
@@ -19,7 +19,6 @@ | |||
19 | 19 | ||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/sched.h> | ||
23 | #include <linux/string.h> | 22 | #include <linux/string.h> |
24 | #include <linux/timer.h> | 23 | #include <linux/timer.h> |
25 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index ee4a493032d6..7be73e3763de 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/moduleparam.h> | 8 | #include <linux/moduleparam.h> |
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/sched.h> | ||
11 | #include <linux/string.h> | 10 | #include <linux/string.h> |
12 | #include <linux/timer.h> | 11 | #include <linux/timer.h> |
13 | #include <linux/delay.h> | 12 | #include <linux/delay.h> |
diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index e2747bd373fd..7ea9132a1965 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c | |||
@@ -4,7 +4,6 @@ | |||
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <linux/moduleparam.h> | 5 | #include <linux/moduleparam.h> |
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/sched.h> | ||
8 | #include <linux/string.h> | 7 | #include <linux/string.h> |
9 | #include <linux/timer.h> | 8 | #include <linux/timer.h> |
10 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
diff --git a/drivers/media/video/usbvideo/ibmcam.c b/drivers/media/video/usbvideo/ibmcam.c index 76f771b6a32f..14db95e10cfe 100644 --- a/drivers/media/video/usbvideo/ibmcam.c +++ b/drivers/media/video/usbvideo/ibmcam.c | |||
@@ -15,7 +15,6 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/sched.h> | ||
19 | #include <linux/module.h> | 18 | #include <linux/module.h> |
20 | #include <linux/init.h> | 19 | #include <linux/init.h> |
21 | 20 | ||
diff --git a/drivers/media/video/usbvideo/ultracam.c b/drivers/media/video/usbvideo/ultracam.c index 10c58b4a2e5b..95453c108d40 100644 --- a/drivers/media/video/usbvideo/ultracam.c +++ b/drivers/media/video/usbvideo/ultracam.c | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/sched.h> | ||
10 | #include <linux/module.h> | 9 | #include <linux/module.h> |
11 | #include <linux/init.h> | 10 | #include <linux/init.h> |
12 | 11 | ||
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c index a807d971e273..901f664dc6db 100644 --- a/drivers/media/video/usbvision/usbvision-core.c +++ b/drivers/media/video/usbvision/usbvision-core.c | |||
@@ -24,7 +24,6 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/sched.h> | ||
28 | #include <linux/list.h> | 27 | #include <linux/list.h> |
29 | #include <linux/timer.h> | 28 | #include <linux/timer.h> |
30 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c index 858252c15084..609e1fd9c784 100644 --- a/drivers/media/video/usbvision/usbvision-i2c.c +++ b/drivers/media/video/usbvision/usbvision-i2c.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
35 | #include <linux/ioport.h> | 35 | #include <linux/ioport.h> |
36 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
37 | #include <linux/sched.h> | ||
38 | #include <linux/usb.h> | 37 | #include <linux/usb.h> |
39 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
40 | #include "usbvision.h" | 39 | #include "usbvision.h" |
@@ -258,6 +257,7 @@ int usbvision_init_i2c(struct usb_usbvision *usbvision) | |||
258 | sprintf(usbvision->i2c_adap.name + strlen(usbvision->i2c_adap.name), | 257 | sprintf(usbvision->i2c_adap.name + strlen(usbvision->i2c_adap.name), |
259 | " #%d", usbvision->vdev->minor & 0x1f); | 258 | " #%d", usbvision->vdev->minor & 0x1f); |
260 | PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name); | 259 | PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name); |
260 | usbvision->i2c_adap.dev.parent = &usbvision->dev->dev; | ||
261 | 261 | ||
262 | i2c_set_adapdata(&usbvision->i2c_adap, usbvision); | 262 | i2c_set_adapdata(&usbvision->i2c_adap, usbvision); |
263 | i2c_set_clientdata(&usbvision->i2c_client, usbvision); | 263 | i2c_set_clientdata(&usbvision->i2c_client, usbvision); |
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index 4eb7330b96f8..af33653f0db8 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -46,7 +46,6 @@ | |||
46 | 46 | ||
47 | #include <linux/version.h> | 47 | #include <linux/version.h> |
48 | #include <linux/kernel.h> | 48 | #include <linux/kernel.h> |
49 | #include <linux/sched.h> | ||
50 | #include <linux/list.h> | 49 | #include <linux/list.h> |
51 | #include <linux/timer.h> | 50 | #include <linux/timer.h> |
52 | #include <linux/slab.h> | 51 | #include <linux/slab.h> |
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index b87d571e0463..b8ee37ded3c9 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #include <linux/module.h> | 47 | #include <linux/module.h> |
48 | #include <linux/types.h> | 48 | #include <linux/types.h> |
49 | #include <linux/kernel.h> | 49 | #include <linux/kernel.h> |
50 | #include <linux/sched.h> | ||
51 | #include <linux/smp_lock.h> | 50 | #include <linux/smp_lock.h> |
52 | #include <linux/mm.h> | 51 | #include <linux/mm.h> |
53 | #include <linux/string.h> | 52 | #include <linux/string.h> |
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 30c3822692fb..a786c1f5b960 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/sched.h> | ||
34 | #include <linux/smp_lock.h> | 33 | #include <linux/smp_lock.h> |
35 | #include <linux/mm.h> | 34 | #include <linux/mm.h> |
36 | #include <linux/string.h> | 35 | #include <linux/string.h> |
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c index 6e64af293be5..8f31613b9903 100644 --- a/drivers/media/video/w9968cf.c +++ b/drivers/media/video/w9968cf.c | |||
@@ -1573,6 +1573,7 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam) | |||
1573 | 1573 | ||
1574 | memcpy(&cam->i2c_adapter, &adap, sizeof(struct i2c_adapter)); | 1574 | memcpy(&cam->i2c_adapter, &adap, sizeof(struct i2c_adapter)); |
1575 | strcpy(cam->i2c_adapter.name, "w9968cf"); | 1575 | strcpy(cam->i2c_adapter.name, "w9968cf"); |
1576 | cam->i2c_adapter.dev.parent = &cam->usbdev->dev; | ||
1576 | i2c_set_adapdata(&cam->i2c_adapter, cam); | 1577 | i2c_set_adapdata(&cam->i2c_adapter, cam); |
1577 | 1578 | ||
1578 | DBG(6, "Registering I2C adapter with kernel...") | 1579 | DBG(6, "Registering I2C adapter with kernel...") |
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c index 4d1eb2fba34a..73162a3a61dd 100644 --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c | |||
@@ -843,6 +843,7 @@ zoran_register_i2c (struct zoran *zr) | |||
843 | sizeof(I2C_NAME(&zr->i2c_adapter)) - 1); | 843 | sizeof(I2C_NAME(&zr->i2c_adapter)) - 1); |
844 | i2c_set_adapdata(&zr->i2c_adapter, zr); | 844 | i2c_set_adapdata(&zr->i2c_adapter, zr); |
845 | zr->i2c_adapter.algo_data = &zr->i2c_algo; | 845 | zr->i2c_adapter.algo_data = &zr->i2c_algo; |
846 | zr->i2c_adapter.dev.parent = &zr->pci_dev->dev; | ||
846 | return i2c_bit_add_bus(&zr->i2c_adapter); | 847 | return i2c_bit_add_bus(&zr->i2c_adapter); |
847 | } | 848 | } |
848 | 849 | ||
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index b7d4c7265ec6..0caaf6403993 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c | |||
@@ -53,7 +53,6 @@ | |||
53 | #include <linux/delay.h> /* for mdelay */ | 53 | #include <linux/delay.h> /* for mdelay */ |
54 | #include <linux/interrupt.h> /* needed for in_interrupt() proto */ | 54 | #include <linux/interrupt.h> /* needed for in_interrupt() proto */ |
55 | #include <linux/reboot.h> /* notifier code */ | 55 | #include <linux/reboot.h> /* notifier code */ |
56 | #include <linux/sched.h> | ||
57 | #include <linux/workqueue.h> | 56 | #include <linux/workqueue.h> |
58 | #include <linux/sort.h> | 57 | #include <linux/sort.h> |
59 | 58 | ||
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 84b8b485e95b..404c014db1bd 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c | |||
@@ -48,7 +48,7 @@ | |||
48 | #include <linux/kernel.h> | 48 | #include <linux/kernel.h> |
49 | #include <linux/init.h> | 49 | #include <linux/init.h> |
50 | #include <linux/errno.h> | 50 | #include <linux/errno.h> |
51 | #include <linux/sched.h> | 51 | #include <linux/jiffies.h> |
52 | #include <linux/workqueue.h> | 52 | #include <linux/workqueue.h> |
53 | #include <linux/delay.h> /* for mdelay */ | 53 | #include <linux/delay.h> /* for mdelay */ |
54 | 54 | ||
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index c417ae0b5fe6..2a3e9e66d4ef 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c | |||
@@ -54,7 +54,6 @@ | |||
54 | #include <linux/delay.h> /* for mdelay */ | 54 | #include <linux/delay.h> /* for mdelay */ |
55 | #include <linux/interrupt.h> /* needed for in_interrupt() proto */ | 55 | #include <linux/interrupt.h> /* needed for in_interrupt() proto */ |
56 | #include <linux/reboot.h> /* notifier code */ | 56 | #include <linux/reboot.h> /* notifier code */ |
57 | #include <linux/sched.h> | ||
58 | #include <linux/workqueue.h> | 57 | #include <linux/workqueue.h> |
59 | 58 | ||
60 | #include <scsi/scsi.h> | 59 | #include <scsi/scsi.h> |
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index c31a9e3c8a26..85f21b54cb7d 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c | |||
@@ -54,7 +54,6 @@ | |||
54 | #include <linux/delay.h> /* for mdelay */ | 54 | #include <linux/delay.h> /* for mdelay */ |
55 | #include <linux/interrupt.h> /* needed for in_interrupt() proto */ | 55 | #include <linux/interrupt.h> /* needed for in_interrupt() proto */ |
56 | #include <linux/reboot.h> /* notifier code */ | 56 | #include <linux/reboot.h> /* notifier code */ |
57 | #include <linux/sched.h> | ||
58 | #include <linux/workqueue.h> | 57 | #include <linux/workqueue.h> |
59 | #include <linux/raid_class.h> | 58 | #include <linux/raid_class.h> |
60 | 59 | ||
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c index e21e490fedb0..bc60e2fc3c2c 100644 --- a/drivers/misc/tifm_7xx1.c +++ b/drivers/misc/tifm_7xx1.c | |||
@@ -367,7 +367,7 @@ static int tifm_7xx1_probe(struct pci_dev *dev, | |||
367 | if (!fm->addr) | 367 | if (!fm->addr) |
368 | goto err_out_free; | 368 | goto err_out_free; |
369 | 369 | ||
370 | rc = request_irq(dev->irq, tifm_7xx1_isr, SA_SHIRQ, DRIVER_NAME, fm); | 370 | rc = request_irq(dev->irq, tifm_7xx1_isr, IRQF_SHARED, DRIVER_NAME, fm); |
371 | if (rc) | 371 | if (rc) |
372 | goto err_out_unmap; | 372 | goto err_out_unmap; |
373 | 373 | ||
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c index 05ba8ace70e7..86439a0bb271 100644 --- a/drivers/mmc/mmc_block.c +++ b/drivers/mmc/mmc_block.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | 22 | ||
23 | #include <linux/sched.h> | ||
24 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
25 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
26 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
diff --git a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c index d8e7a026ba5a..2e51496c248e 100644 --- a/drivers/mtd/chips/cfi_util.c +++ b/drivers/mtd/chips/cfi_util.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <asm/io.h> | 17 | #include <asm/io.h> |
19 | #include <asm/byteorder.h> | 18 | #include <asm/byteorder.h> |
20 | 19 | ||
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c index 0e2a9326f717..fe71a12c2627 100644 --- a/drivers/mtd/devices/doc2001.c +++ b/drivers/mtd/devices/doc2001.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/init.h> | 19 | #include <linux/init.h> |
21 | #include <linux/types.h> | 20 | #include <linux/types.h> |
22 | #include <linux/bitops.h> | 21 | #include <linux/bitops.h> |
diff --git a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c index 92dbb47f2ac3..ba4db686285a 100644 --- a/drivers/mtd/devices/doc2001plus.c +++ b/drivers/mtd/devices/doc2001plus.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/sched.h> | ||
24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
25 | #include <linux/types.h> | 24 | #include <linux/types.h> |
26 | #include <linux/bitops.h> | 25 | #include <linux/bitops.h> |
diff --git a/drivers/mtd/devices/docecc.c b/drivers/mtd/devices/docecc.c index cd3db72bef96..52b5d638077f 100644 --- a/drivers/mtd/devices/docecc.c +++ b/drivers/mtd/devices/docecc.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/pci.h> | 32 | #include <linux/pci.h> |
33 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/sched.h> | ||
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
37 | #include <linux/types.h> | 36 | #include <linux/types.h> |
38 | 37 | ||
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c index 354e1657cc26..a4873ab84e6b 100644 --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c | |||
@@ -86,7 +86,6 @@ | |||
86 | #include <linux/module.h> | 86 | #include <linux/module.h> |
87 | #include <asm/uaccess.h> | 87 | #include <asm/uaccess.h> |
88 | #include <linux/types.h> | 88 | #include <linux/types.h> |
89 | #include <linux/sched.h> | ||
90 | #include <linux/init.h> | 89 | #include <linux/init.h> |
91 | #include <linux/ptrace.h> | 90 | #include <linux/ptrace.h> |
92 | #include <linux/slab.h> | 91 | #include <linux/slab.h> |
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index 5f49248a4856..d293add1857c 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
36 | #include <linux/types.h> | 36 | #include <linux/types.h> |
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/ptrace.h> | 38 | #include <linux/ptrace.h> |
40 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
41 | #include <linux/string.h> | 40 | #include <linux/string.h> |
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index 24235d4f1d23..c815d0f38577 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c | |||
@@ -61,7 +61,6 @@ | |||
61 | /*#define PSYCHO_DEBUG */ | 61 | /*#define PSYCHO_DEBUG */ |
62 | 62 | ||
63 | #include <linux/kernel.h> | 63 | #include <linux/kernel.h> |
64 | #include <linux/sched.h> | ||
65 | #include <linux/ptrace.h> | 64 | #include <linux/ptrace.h> |
66 | #include <linux/slab.h> | 65 | #include <linux/slab.h> |
67 | #include <linux/string.h> | 66 | #include <linux/string.h> |
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c index 8f6006f1a519..acf3ba223298 100644 --- a/drivers/mtd/inftlmount.c +++ b/drivers/mtd/inftlmount.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | #include <linux/sched.h> | ||
38 | #include <linux/init.h> | 37 | #include <linux/init.h> |
39 | #include <linux/mtd/mtd.h> | 38 | #include <linux/mtd/mtd.h> |
40 | #include <linux/mtd/nftl.h> | 39 | #include <linux/mtd/nftl.h> |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 7070110aba2a..c153b64a8300 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -8,7 +8,6 @@ | |||
8 | 8 | ||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/sched.h> | ||
12 | #include <linux/ptrace.h> | 11 | #include <linux/ptrace.h> |
13 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
14 | #include <linux/string.h> | 13 | #include <linux/string.h> |
diff --git a/drivers/mtd/nand/cafe.c b/drivers/mtd/nand/cafe.c index 65f9bd3ceebf..08cb060dfa3d 100644 --- a/drivers/mtd/nand/cafe.c +++ b/drivers/mtd/nand/cafe.c | |||
@@ -597,7 +597,8 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev, | |||
597 | cafe_writel(cafe, 0xffffffff, NAND_TIMING3); | 597 | cafe_writel(cafe, 0xffffffff, NAND_TIMING3); |
598 | } | 598 | } |
599 | cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK); | 599 | cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK); |
600 | err = request_irq(pdev->irq, &cafe_nand_interrupt, SA_SHIRQ, "CAFE NAND", mtd); | 600 | err = request_irq(pdev->irq, &cafe_nand_interrupt, IRQF_SHARED, |
601 | "CAFE NAND", mtd); | ||
601 | if (err) { | 602 | if (err) { |
602 | dev_warn(&pdev->dev, "Could not register IRQ %d\n", pdev->irq); | 603 | dev_warn(&pdev->dev, "Could not register IRQ %d\n", pdev->irq); |
603 | 604 | ||
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index 4b1ba4fcfcd3..e6ef7d7f9f14 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/sched.h> | ||
24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
25 | #include <linux/hdreg.h> | 24 | #include <linux/hdreg.h> |
26 | 25 | ||
diff --git a/drivers/net/7990.c b/drivers/net/7990.c index 2d5ba076471c..1b3d11ed6cff 100644 --- a/drivers/net/7990.c +++ b/drivers/net/7990.c | |||
@@ -500,7 +500,7 @@ int lance_open (struct net_device *dev) | |||
500 | int res; | 500 | int res; |
501 | 501 | ||
502 | /* Install the Interrupt handler. Or we could shunt this out to specific drivers? */ | 502 | /* Install the Interrupt handler. Or we could shunt this out to specific drivers? */ |
503 | if (request_irq(lp->irq, lance_interrupt, SA_SHIRQ, lp->name, dev)) | 503 | if (request_irq(lp->irq, lance_interrupt, IRQF_SHARED, lp->name, dev)) |
504 | return -EAGAIN; | 504 | return -EAGAIN; |
505 | 505 | ||
506 | res = lance_reset(dev); | 506 | res = lance_reset(dev); |
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c index d6da3ce9ad79..a2921882eba8 100644 --- a/drivers/net/arm/ether1.c +++ b/drivers/net/arm/ether1.c | |||
@@ -33,7 +33,6 @@ | |||
33 | 33 | ||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
36 | #include <linux/sched.h> | ||
37 | #include <linux/types.h> | 36 | #include <linux/types.h> |
38 | #include <linux/fcntl.h> | 37 | #include <linux/fcntl.h> |
39 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c index 4fc234785d56..841178343a07 100644 --- a/drivers/net/arm/ether3.c +++ b/drivers/net/arm/ether3.c | |||
@@ -48,7 +48,6 @@ | |||
48 | 48 | ||
49 | #include <linux/module.h> | 49 | #include <linux/module.h> |
50 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
51 | #include <linux/sched.h> | ||
52 | #include <linux/types.h> | 51 | #include <linux/types.h> |
53 | #include <linux/fcntl.h> | 52 | #include <linux/fcntl.h> |
54 | #include <linux/interrupt.h> | 53 | #include <linux/interrupt.h> |
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c index 72c41f5907f2..61f574aa3a99 100644 --- a/drivers/net/arm/etherh.c +++ b/drivers/net/arm/etherh.c | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
31 | #include <linux/sched.h> | ||
32 | #include <linux/types.h> | 31 | #include <linux/types.h> |
33 | #include <linux/fcntl.h> | 32 | #include <linux/fcntl.h> |
34 | #include <linux/interrupt.h> | 33 | #include <linux/interrupt.h> |
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index f0b6879a1c7d..69ae229b680e 100644 --- a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c | |||
@@ -37,7 +37,6 @@ | |||
37 | 37 | ||
38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | #include <linux/sched.h> | ||
41 | #include <linux/string.h> | 40 | #include <linux/string.h> |
42 | #include <linux/timer.h> | 41 | #include <linux/timer.h> |
43 | #include <linux/errno.h> | 42 | #include <linux/errno.h> |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 61a6fa465d71..a7c8f98a890c 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -35,7 +35,6 @@ | |||
35 | 35 | ||
36 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
37 | #include <linux/module.h> | 37 | #include <linux/module.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/types.h> | 38 | #include <linux/types.h> |
40 | #include <linux/fcntl.h> | 39 | #include <linux/fcntl.h> |
41 | #include <linux/interrupt.h> | 40 | #include <linux/interrupt.h> |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 878f7aabeeac..a122baa5c7bb 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -22,7 +22,6 @@ | |||
22 | */ | 22 | */ |
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/sched.h> | ||
26 | #include <linux/device.h> | 25 | #include <linux/device.h> |
27 | #include <linux/sysdev.h> | 26 | #include <linux/sysdev.h> |
28 | #include <linux/fs.h> | 27 | #include <linux/fs.h> |
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c index a03d781f6d0a..8eb571276000 100644 --- a/drivers/net/cris/eth_v10.c +++ b/drivers/net/cris/eth_v10.c | |||
@@ -222,7 +222,6 @@ | |||
222 | #include <linux/module.h> | 222 | #include <linux/module.h> |
223 | 223 | ||
224 | #include <linux/kernel.h> | 224 | #include <linux/kernel.h> |
225 | #include <linux/sched.h> | ||
226 | #include <linux/delay.h> | 225 | #include <linux/delay.h> |
227 | #include <linux/types.h> | 226 | #include <linux/types.h> |
228 | #include <linux/fcntl.h> | 227 | #include <linux/fcntl.h> |
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index c67f7d3c2f92..43583ed655ab 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -757,7 +757,8 @@ static int cxgb_up(struct adapter *adap) | |||
757 | t3_intr_handler(adap, | 757 | t3_intr_handler(adap, |
758 | adap->sge.qs[0].rspq. | 758 | adap->sge.qs[0].rspq. |
759 | polling), | 759 | polling), |
760 | (adap->flags & USING_MSI) ? 0 : SA_SHIRQ, | 760 | (adap->flags & USING_MSI) ? |
761 | 0 : IRQF_SHARED, | ||
761 | adap->name, adap))) | 762 | adap->name, adap))) |
762 | goto irq_err; | 763 | goto irq_err; |
763 | 764 | ||
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index 1ef3846a5ea0..88ad1c8bcee4 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -888,7 +888,7 @@ static int ehea_reg_interrupts(struct net_device *dev) | |||
888 | , "%s-recv%d", dev->name, i); | 888 | , "%s-recv%d", dev->name, i); |
889 | ret = ibmebus_request_irq(NULL, pr->recv_eq->attr.ist1, | 889 | ret = ibmebus_request_irq(NULL, pr->recv_eq->attr.ist1, |
890 | ehea_recv_irq_handler, | 890 | ehea_recv_irq_handler, |
891 | SA_INTERRUPT, pr->int_recv_name, pr); | 891 | IRQF_DISABLED, pr->int_recv_name, pr); |
892 | if (ret) { | 892 | if (ret) { |
893 | ehea_error("failed registering irq for ehea_recv_int:" | 893 | ehea_error("failed registering irq for ehea_recv_int:" |
894 | "port_res_nr:%d, ist=%X", i, | 894 | "port_res_nr:%d, ist=%X", i, |
@@ -905,7 +905,7 @@ static int ehea_reg_interrupts(struct net_device *dev) | |||
905 | 905 | ||
906 | ret = ibmebus_request_irq(NULL, port->qp_eq->attr.ist1, | 906 | ret = ibmebus_request_irq(NULL, port->qp_eq->attr.ist1, |
907 | ehea_qp_aff_irq_handler, | 907 | ehea_qp_aff_irq_handler, |
908 | SA_INTERRUPT, port->int_aff_name, port); | 908 | IRQF_DISABLED, port->int_aff_name, port); |
909 | if (ret) { | 909 | if (ret) { |
910 | ehea_error("failed registering irq for qp_aff_irq_handler:" | 910 | ehea_error("failed registering irq for qp_aff_irq_handler:" |
911 | "ist=%X", port->qp_eq->attr.ist1); | 911 | "ist=%X", port->qp_eq->attr.ist1); |
@@ -922,7 +922,7 @@ static int ehea_reg_interrupts(struct net_device *dev) | |||
922 | "%s-send%d", dev->name, i); | 922 | "%s-send%d", dev->name, i); |
923 | ret = ibmebus_request_irq(NULL, pr->send_eq->attr.ist1, | 923 | ret = ibmebus_request_irq(NULL, pr->send_eq->attr.ist1, |
924 | ehea_send_irq_handler, | 924 | ehea_send_irq_handler, |
925 | SA_INTERRUPT, pr->int_send_name, | 925 | IRQF_DISABLED, pr->int_send_name, |
926 | pr); | 926 | pr); |
927 | if (ret) { | 927 | if (ret) { |
928 | ehea_error("failed registering irq for ehea_send " | 928 | ehea_error("failed registering irq for ehea_send " |
@@ -2545,7 +2545,7 @@ static int __devinit ehea_probe(struct ibmebus_dev *dev, | |||
2545 | (unsigned long)adapter); | 2545 | (unsigned long)adapter); |
2546 | 2546 | ||
2547 | ret = ibmebus_request_irq(NULL, adapter->neq->attr.ist1, | 2547 | ret = ibmebus_request_irq(NULL, adapter->neq->attr.ist1, |
2548 | ehea_interrupt_neq, SA_INTERRUPT, | 2548 | ehea_interrupt_neq, IRQF_DISABLED, |
2549 | "ehea_neq", adapter); | 2549 | "ehea_neq", adapter); |
2550 | if (ret) { | 2550 | if (ret) { |
2551 | dev_err(&dev->ofdev.dev, "requesting NEQ IRQ failed"); | 2551 | dev_err(&dev->ofdev.dev, "requesting NEQ IRQ failed"); |
diff --git a/drivers/net/fec_8xx/fec_8xx-netta.c b/drivers/net/fec_8xx/fec_8xx-netta.c index 790d9dbe42dd..e492eb84f948 100644 --- a/drivers/net/fec_8xx/fec_8xx-netta.c +++ b/drivers/net/fec_8xx/fec_8xx-netta.c | |||
@@ -4,7 +4,6 @@ | |||
4 | 4 | ||
5 | #include <linux/kernel.h> | 5 | #include <linux/kernel.h> |
6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
7 | #include <linux/sched.h> | ||
8 | #include <linux/string.h> | 7 | #include <linux/string.h> |
9 | #include <linux/ptrace.h> | 8 | #include <linux/ptrace.h> |
10 | #include <linux/errno.h> | 9 | #include <linux/errno.h> |
diff --git a/drivers/net/fec_8xx/fec_main.c b/drivers/net/fec_8xx/fec_main.c index 8e7a56fadfd2..77f747a5afa7 100644 --- a/drivers/net/fec_8xx/fec_main.c +++ b/drivers/net/fec_8xx/fec_main.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/string.h> | 16 | #include <linux/string.h> |
18 | #include <linux/ptrace.h> | 17 | #include <linux/ptrace.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
diff --git a/drivers/net/fec_8xx/fec_mii.c b/drivers/net/fec_8xx/fec_mii.c index d3c16b85d9a4..e79700abf7b6 100644 --- a/drivers/net/fec_8xx/fec_mii.c +++ b/drivers/net/fec_8xx/fec_mii.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/string.h> | 16 | #include <linux/string.h> |
18 | #include <linux/ptrace.h> | 17 | #include <linux/ptrace.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index 889d3a13e95e..4a05c14bf7ec 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/types.h> | 20 | #include <linux/types.h> |
21 | #include <linux/sched.h> | ||
22 | #include <linux/string.h> | 21 | #include <linux/string.h> |
23 | #include <linux/ptrace.h> | 22 | #include <linux/ptrace.h> |
24 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c index 1ff2597b8495..8545e84fc9a0 100644 --- a/drivers/net/fs_enet/mac-fcc.c +++ b/drivers/net/fs_enet/mac-fcc.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/sched.h> | ||
19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
20 | #include <linux/ptrace.h> | 19 | #include <linux/ptrace.h> |
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c index ff6839477306..cdcfb96f360f 100644 --- a/drivers/net/fs_enet/mac-fec.c +++ b/drivers/net/fs_enet/mac-fec.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/sched.h> | ||
19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
20 | #include <linux/ptrace.h> | 19 | #include <linux/ptrace.h> |
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c index afd7fca7c6c4..65925b5a224f 100644 --- a/drivers/net/fs_enet/mac-scc.c +++ b/drivers/net/fs_enet/mac-scc.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/sched.h> | ||
19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
20 | #include <linux/ptrace.h> | 19 | #include <linux/ptrace.h> |
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c index 0b9b8b5c847c..f91447837fd4 100644 --- a/drivers/net/fs_enet/mii-bitbang.c +++ b/drivers/net/fs_enet/mii-bitbang.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/string.h> | 19 | #include <linux/string.h> |
21 | #include <linux/ptrace.h> | 20 | #include <linux/ptrace.h> |
22 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c index baaae3dbf2e6..235b177fb9ac 100644 --- a/drivers/net/fs_enet/mii-fec.c +++ b/drivers/net/fs_enet/mii-fec.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/sched.h> | ||
19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
20 | #include <linux/ptrace.h> | 19 | #include <linux/ptrace.h> |
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index baa35144134c..1be4a84dce0e 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -65,7 +65,6 @@ | |||
65 | */ | 65 | */ |
66 | 66 | ||
67 | #include <linux/kernel.h> | 67 | #include <linux/kernel.h> |
68 | #include <linux/sched.h> | ||
69 | #include <linux/string.h> | 68 | #include <linux/string.h> |
70 | #include <linux/errno.h> | 69 | #include <linux/errno.h> |
71 | #include <linux/unistd.h> | 70 | #include <linux/unistd.h> |
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c index 0d6943d67096..7b411c1514db 100644 --- a/drivers/net/gianfar_ethtool.c +++ b/drivers/net/gianfar_ethtool.c | |||
@@ -16,7 +16,6 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/string.h> | 19 | #include <linux/string.h> |
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
22 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c index ff684d4be96d..bcc6b82f4a33 100644 --- a/drivers/net/gianfar_mii.c +++ b/drivers/net/gianfar_mii.c | |||
@@ -17,7 +17,6 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/string.h> | 20 | #include <linux/string.h> |
22 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
23 | #include <linux/unistd.h> | 22 | #include <linux/unistd.h> |
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c index 6e2166a7601a..aec9ab17a9a5 100644 --- a/drivers/net/gianfar_sysfs.c +++ b/drivers/net/gianfar_sysfs.c | |||
@@ -20,7 +20,6 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/sched.h> | ||
24 | #include <linux/string.h> | 23 | #include <linux/string.h> |
25 | #include <linux/errno.h> | 24 | #include <linux/errno.h> |
26 | #include <linux/unistd.h> | 25 | #include <linux/unistd.h> |
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c index ffeafb28f782..dd8ad8746825 100644 --- a/drivers/net/ibm_emac/ibm_emac_core.c +++ b/drivers/net/ibm_emac/ibm_emac_core.c | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/sched.h> | ||
25 | #include <linux/string.h> | 24 | #include <linux/string.h> |
26 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
27 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
diff --git a/drivers/net/irda/ma600-sir.c b/drivers/net/irda/ma600-sir.c index ebed168b7da6..809906d94762 100644 --- a/drivers/net/irda/ma600-sir.c +++ b/drivers/net/irda/ma600-sir.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/sched.h> | ||
38 | 37 | ||
39 | #include <net/irda/irda.h> | 38 | #include <net/irda/irda.h> |
40 | 39 | ||
diff --git a/drivers/net/macb.c b/drivers/net/macb.c index e67361e2bf5d..a41418b3c518 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c | |||
@@ -1077,7 +1077,7 @@ static int __devinit macb_probe(struct platform_device *pdev) | |||
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | dev->irq = platform_get_irq(pdev, 0); | 1079 | dev->irq = platform_get_irq(pdev, 0); |
1080 | err = request_irq(dev->irq, macb_interrupt, SA_SAMPLE_RANDOM, | 1080 | err = request_irq(dev->irq, macb_interrupt, IRQF_SAMPLE_RANDOM, |
1081 | dev->name, dev); | 1081 | dev->name, dev); |
1082 | if (err) { | 1082 | if (err) { |
1083 | printk(KERN_ERR | 1083 | printk(KERN_ERR |
diff --git a/drivers/net/meth.c b/drivers/net/meth.c index e1d97cdf649e..d38b7c723620 100644 --- a/drivers/net/meth.c +++ b/drivers/net/meth.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | 13 | ||
14 | #include <linux/sched.h> | ||
15 | #include <linux/kernel.h> /* printk() */ | 14 | #include <linux/kernel.h> /* printk() */ |
16 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
17 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c index c9469985bd71..f42b9e201937 100644 --- a/drivers/net/mipsnet.c +++ b/drivers/net/mipsnet.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/netdevice.h> | 12 | #include <linux/netdevice.h> |
13 | #include <linux/sched.h> | ||
14 | #include <linux/etherdevice.h> | 13 | #include <linux/etherdevice.h> |
15 | #include <linux/netdevice.h> | 14 | #include <linux/netdevice.h> |
16 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index c2da7ec0248a..225ff55527c4 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -620,8 +620,8 @@ static int netxen_nic_open(struct net_device *netdev) | |||
620 | } | 620 | } |
621 | adapter->irq = adapter->ahw.pdev->irq; | 621 | adapter->irq = adapter->ahw.pdev->irq; |
622 | err = request_irq(adapter->ahw.pdev->irq, &netxen_intr, | 622 | err = request_irq(adapter->ahw.pdev->irq, &netxen_intr, |
623 | SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, | 623 | IRQF_SHARED | IRQF_SAMPLE_RANDOM, |
624 | adapter); | 624 | netdev->name, adapter); |
625 | if (err) { | 625 | if (err) { |
626 | printk(KERN_ERR "request_irq failed with: %d\n", err); | 626 | printk(KERN_ERR "request_irq failed with: %d\n", err); |
627 | netxen_free_hw_resources(adapter); | 627 | netxen_free_hw_resources(adapter); |
diff --git a/drivers/net/phy/cicada.c b/drivers/net/phy/cicada.c index ae60e6e4107c..a1bd599c8a5b 100644 --- a/drivers/net/phy/cicada.c +++ b/drivers/net/phy/cicada.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
20 | #include <linux/unistd.h> | 19 | #include <linux/unistd.h> |
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c index aa7983f55838..519baa38be8d 100644 --- a/drivers/net/phy/davicom.c +++ b/drivers/net/phy/davicom.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
20 | #include <linux/unistd.h> | 19 | #include <linux/unistd.h> |
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c index 86135397f430..66da91bb1388 100644 --- a/drivers/net/phy/fixed.c +++ b/drivers/net/phy/fixed.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
20 | #include <linux/unistd.h> | 19 | #include <linux/unistd.h> |
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c index 69d2325f848c..4cf3324ba166 100644 --- a/drivers/net/phy/lxt.c +++ b/drivers/net/phy/lxt.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
20 | #include <linux/unistd.h> | 19 | #include <linux/unistd.h> |
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 0ad253282d0d..f4d4eb659cad 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
20 | #include <linux/unistd.h> | 19 | #include <linux/unistd.h> |
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index cf6660c93ffa..b31ce278bf35 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
20 | #include <linux/unistd.h> | 19 | #include <linux/unistd.h> |
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 9765fa661467..c94a1fb3a4be 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
@@ -16,7 +16,6 @@ | |||
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/string.h> | 19 | #include <linux/string.h> |
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
22 | #include <linux/unistd.h> | 21 | #include <linux/unistd.h> |
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index deda210c844e..7d5b6d1838c8 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -15,7 +15,6 @@ | |||
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/sched.h> | ||
19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
20 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
21 | #include <linux/unistd.h> | 20 | #include <linux/unistd.h> |
diff --git a/drivers/net/phy/qsemi.c b/drivers/net/phy/qsemi.c index 2b50e1739aa5..23062d067231 100644 --- a/drivers/net/phy/qsemi.c +++ b/drivers/net/phy/qsemi.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
20 | #include <linux/unistd.h> | 19 | #include <linux/unistd.h> |
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c index 2429b274f0b0..a142cdfd947b 100755 --- a/drivers/net/qla3xxx.c +++ b/drivers/net/qla3xxx.c | |||
@@ -3228,7 +3228,7 @@ static int ql_adapter_up(struct ql3_adapter *qdev) | |||
3228 | { | 3228 | { |
3229 | struct net_device *ndev = qdev->ndev; | 3229 | struct net_device *ndev = qdev->ndev; |
3230 | int err; | 3230 | int err; |
3231 | unsigned long irq_flags = SA_SAMPLE_RANDOM | SA_SHIRQ; | 3231 | unsigned long irq_flags = IRQF_SAMPLE_RANDOM | IRQF_SHARED; |
3232 | unsigned long hw_flags; | 3232 | unsigned long hw_flags; |
3233 | 3233 | ||
3234 | if (ql_alloc_mem_resources(qdev)) { | 3234 | if (ql_alloc_mem_resources(qdev)) { |
@@ -3247,7 +3247,7 @@ static int ql_adapter_up(struct ql3_adapter *qdev) | |||
3247 | } else { | 3247 | } else { |
3248 | printk(KERN_INFO PFX "%s: MSI Enabled...\n", qdev->ndev->name); | 3248 | printk(KERN_INFO PFX "%s: MSI Enabled...\n", qdev->ndev->name); |
3249 | set_bit(QL_MSI_ENABLED,&qdev->flags); | 3249 | set_bit(QL_MSI_ENABLED,&qdev->flags); |
3250 | irq_flags &= ~SA_SHIRQ; | 3250 | irq_flags &= ~IRQF_SHARED; |
3251 | } | 3251 | } |
3252 | } | 3252 | } |
3253 | 3253 | ||
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 8646b64994ab..e8e0d94e9bdd 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -59,7 +59,6 @@ | |||
59 | #include <linux/stddef.h> | 59 | #include <linux/stddef.h> |
60 | #include <linux/ioctl.h> | 60 | #include <linux/ioctl.h> |
61 | #include <linux/timex.h> | 61 | #include <linux/timex.h> |
62 | #include <linux/sched.h> | ||
63 | #include <linux/ethtool.h> | 62 | #include <linux/ethtool.h> |
64 | #include <linux/workqueue.h> | 63 | #include <linux/workqueue.h> |
65 | #include <linux/if_vlan.h> | 64 | #include <linux/if_vlan.h> |
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c index 7f800feaa9a2..4a926f20b6ea 100644 --- a/drivers/net/sc92031.c +++ b/drivers/net/sc92031.c | |||
@@ -1035,7 +1035,7 @@ static int sc92031_open(struct net_device *dev) | |||
1035 | priv->tx_head = priv->tx_tail = 0; | 1035 | priv->tx_head = priv->tx_tail = 0; |
1036 | 1036 | ||
1037 | err = request_irq(pdev->irq, sc92031_interrupt, | 1037 | err = request_irq(pdev->irq, sc92031_interrupt, |
1038 | SA_SHIRQ, dev->name, dev); | 1038 | IRQF_SHARED, dev->name, dev); |
1039 | if (unlikely(err < 0)) | 1039 | if (unlikely(err < 0)) |
1040 | goto out_request_irq; | 1040 | goto out_request_irq; |
1041 | 1041 | ||
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c index d21991ee88c4..701ba4f3b69d 100644 --- a/drivers/net/sungem_phy.c +++ b/drivers/net/sungem_phy.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | 23 | ||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/sched.h> | ||
26 | #include <linux/types.h> | 25 | #include <linux/types.h> |
27 | #include <linux/netdevice.h> | 26 | #include <linux/netdevice.h> |
28 | #include <linux/etherdevice.h> | 27 | #include <linux/etherdevice.h> |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index e136bae61970..81a1c2e1a3f5 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright (C) 2001, 2002, 2003, 2004 David S. Miller (davem@redhat.com) | 4 | * Copyright (C) 2001, 2002, 2003, 2004 David S. Miller (davem@redhat.com) |
5 | * Copyright (C) 2001, 2002, 2003 Jeff Garzik (jgarzik@pobox.com) | 5 | * Copyright (C) 2001, 2002, 2003 Jeff Garzik (jgarzik@pobox.com) |
6 | * Copyright (C) 2004 Sun Microsystems Inc. | 6 | * Copyright (C) 2004 Sun Microsystems Inc. |
7 | * Copyright (C) 2005 Broadcom Corporation. | 7 | * Copyright (C) 2005-2007 Broadcom Corporation. |
8 | * | 8 | * |
9 | * Firmware is: | 9 | * Firmware is: |
10 | * Derived from proprietary unpublished source code, | 10 | * Derived from proprietary unpublished source code, |
@@ -64,8 +64,8 @@ | |||
64 | 64 | ||
65 | #define DRV_MODULE_NAME "tg3" | 65 | #define DRV_MODULE_NAME "tg3" |
66 | #define PFX DRV_MODULE_NAME ": " | 66 | #define PFX DRV_MODULE_NAME ": " |
67 | #define DRV_MODULE_VERSION "3.72" | 67 | #define DRV_MODULE_VERSION "3.73" |
68 | #define DRV_MODULE_RELDATE "January 8, 2007" | 68 | #define DRV_MODULE_RELDATE "February 12, 2007" |
69 | 69 | ||
70 | #define TG3_DEF_MAC_MODE 0 | 70 | #define TG3_DEF_MAC_MODE 0 |
71 | #define TG3_DEF_RX_MODE 0 | 71 | #define TG3_DEF_RX_MODE 0 |
@@ -1175,8 +1175,18 @@ static void tg3_nvram_unlock(struct tg3 *); | |||
1175 | 1175 | ||
1176 | static void tg3_power_down_phy(struct tg3 *tp) | 1176 | static void tg3_power_down_phy(struct tg3 *tp) |
1177 | { | 1177 | { |
1178 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) | 1178 | if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { |
1179 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { | ||
1180 | u32 sg_dig_ctrl = tr32(SG_DIG_CTRL); | ||
1181 | u32 serdes_cfg = tr32(MAC_SERDES_CFG); | ||
1182 | |||
1183 | sg_dig_ctrl |= | ||
1184 | SG_DIG_USING_HW_AUTONEG | SG_DIG_SOFT_RESET; | ||
1185 | tw32(SG_DIG_CTRL, sg_dig_ctrl); | ||
1186 | tw32(MAC_SERDES_CFG, serdes_cfg | (1 << 15)); | ||
1187 | } | ||
1179 | return; | 1188 | return; |
1189 | } | ||
1180 | 1190 | ||
1181 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { | 1191 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { |
1182 | u32 val; | 1192 | u32 val; |
@@ -1340,7 +1350,8 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) | |||
1340 | 1350 | ||
1341 | tw32_wait_f(TG3PCI_CLOCK_CTRL, base_val | CLOCK_CTRL_ALTCLK | | 1351 | tw32_wait_f(TG3PCI_CLOCK_CTRL, base_val | CLOCK_CTRL_ALTCLK | |
1342 | CLOCK_CTRL_PWRDOWN_PLL133, 40); | 1352 | CLOCK_CTRL_PWRDOWN_PLL133, 40); |
1343 | } else if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) { | 1353 | } else if ((tp->tg3_flags2 & TG3_FLG2_5780_CLASS) || |
1354 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906)) { | ||
1344 | /* do nothing */ | 1355 | /* do nothing */ |
1345 | } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && | 1356 | } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && |
1346 | (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) { | 1357 | (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) { |
@@ -3724,13 +3735,23 @@ out: | |||
3724 | tg3_full_unlock(tp); | 3735 | tg3_full_unlock(tp); |
3725 | } | 3736 | } |
3726 | 3737 | ||
3738 | static void tg3_dump_short_state(struct tg3 *tp) | ||
3739 | { | ||
3740 | printk(KERN_ERR PFX "DEBUG: MAC_TX_STATUS[%08x] MAC_RX_STATUS[%08x]\n", | ||
3741 | tr32(MAC_TX_STATUS), tr32(MAC_RX_STATUS)); | ||
3742 | printk(KERN_ERR PFX "DEBUG: RDMAC_STATUS[%08x] WDMAC_STATUS[%08x]\n", | ||
3743 | tr32(RDMAC_STATUS), tr32(WDMAC_STATUS)); | ||
3744 | } | ||
3745 | |||
3727 | static void tg3_tx_timeout(struct net_device *dev) | 3746 | static void tg3_tx_timeout(struct net_device *dev) |
3728 | { | 3747 | { |
3729 | struct tg3 *tp = netdev_priv(dev); | 3748 | struct tg3 *tp = netdev_priv(dev); |
3730 | 3749 | ||
3731 | if (netif_msg_tx_err(tp)) | 3750 | if (netif_msg_tx_err(tp)) { |
3732 | printk(KERN_ERR PFX "%s: transmit timed out, resetting\n", | 3751 | printk(KERN_ERR PFX "%s: transmit timed out, resetting\n", |
3733 | dev->name); | 3752 | dev->name); |
3753 | tg3_dump_short_state(tp); | ||
3754 | } | ||
3734 | 3755 | ||
3735 | schedule_work(&tp->reset_task); | 3756 | schedule_work(&tp->reset_task); |
3736 | } | 3757 | } |
@@ -6583,8 +6604,9 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | |||
6583 | u32 tmp; | 6604 | u32 tmp; |
6584 | 6605 | ||
6585 | /* Clear CRC stats. */ | 6606 | /* Clear CRC stats. */ |
6586 | if (!tg3_readphy(tp, 0x1e, &tmp)) { | 6607 | if (!tg3_readphy(tp, MII_TG3_TEST1, &tmp)) { |
6587 | tg3_writephy(tp, 0x1e, tmp | 0x8000); | 6608 | tg3_writephy(tp, MII_TG3_TEST1, |
6609 | tmp | MII_TG3_TEST1_CRC_EN); | ||
6588 | tg3_readphy(tp, 0x14, &tmp); | 6610 | tg3_readphy(tp, 0x14, &tmp); |
6589 | } | 6611 | } |
6590 | } | 6612 | } |
@@ -7408,8 +7430,9 @@ static unsigned long calc_crc_errors(struct tg3 *tp) | |||
7408 | u32 val; | 7430 | u32 val; |
7409 | 7431 | ||
7410 | spin_lock_bh(&tp->lock); | 7432 | spin_lock_bh(&tp->lock); |
7411 | if (!tg3_readphy(tp, 0x1e, &val)) { | 7433 | if (!tg3_readphy(tp, MII_TG3_TEST1, &val)) { |
7412 | tg3_writephy(tp, 0x1e, val | 0x8000); | 7434 | tg3_writephy(tp, MII_TG3_TEST1, |
7435 | val | MII_TG3_TEST1_CRC_EN); | ||
7413 | tg3_readphy(tp, 0x14, &val); | 7436 | tg3_readphy(tp, 0x14, &val); |
7414 | } else | 7437 | } else |
7415 | val = 0; | 7438 | val = 0; |
@@ -10779,7 +10802,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10779 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { | 10802 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { |
10780 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || | 10803 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
10781 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { | 10804 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { |
10782 | tp->tg3_flags2 |= TG3_FLG2_PHY_JITTER_BUG; | 10805 | if (tp->pdev->device != PCI_DEVICE_ID_TIGON3_5756 && |
10806 | tp->pdev->device != PCI_DEVICE_ID_TIGON3_5722) | ||
10807 | tp->tg3_flags2 |= TG3_FLG2_PHY_JITTER_BUG; | ||
10783 | if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5755M) | 10808 | if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5755M) |
10784 | tp->tg3_flags2 |= TG3_FLG2_PHY_ADJUST_TRIM; | 10809 | tp->tg3_flags2 |= TG3_FLG2_PHY_ADJUST_TRIM; |
10785 | } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5906) | 10810 | } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5906) |
@@ -11314,6 +11339,7 @@ static int __devinit tg3_test_dma(struct tg3 *tp) | |||
11314 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 || | 11339 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 || |
11315 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { | 11340 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { |
11316 | u32 ccval = (tr32(TG3PCI_CLOCK_CTRL) & 0x1f); | 11341 | u32 ccval = (tr32(TG3PCI_CLOCK_CTRL) & 0x1f); |
11342 | u32 read_water = 0x7; | ||
11317 | 11343 | ||
11318 | /* If the 5704 is behind the EPB bridge, we can | 11344 | /* If the 5704 is behind the EPB bridge, we can |
11319 | * do the less restrictive ONE_DMA workaround for | 11345 | * do the less restrictive ONE_DMA workaround for |
@@ -11325,8 +11351,13 @@ static int __devinit tg3_test_dma(struct tg3 *tp) | |||
11325 | else if (ccval == 0x6 || ccval == 0x7) | 11351 | else if (ccval == 0x6 || ccval == 0x7) |
11326 | tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA; | 11352 | tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA; |
11327 | 11353 | ||
11354 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) | ||
11355 | read_water = 4; | ||
11328 | /* Set bit 23 to enable PCIX hw bug fix */ | 11356 | /* Set bit 23 to enable PCIX hw bug fix */ |
11329 | tp->dma_rwctrl |= 0x009f0000; | 11357 | tp->dma_rwctrl |= |
11358 | (read_water << DMA_RWCTRL_READ_WATER_SHIFT) | | ||
11359 | (0x3 << DMA_RWCTRL_WRITE_WATER_SHIFT) | | ||
11360 | (1 << 23); | ||
11330 | } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780) { | 11361 | } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780) { |
11331 | /* 5780 always in PCIX mode */ | 11362 | /* 5780 always in PCIX mode */ |
11332 | tp->dma_rwctrl |= 0x00144000; | 11363 | tp->dma_rwctrl |= 0x00144000; |
@@ -12016,6 +12047,9 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state) | |||
12016 | tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; | 12047 | tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; |
12017 | tg3_full_unlock(tp); | 12048 | tg3_full_unlock(tp); |
12018 | 12049 | ||
12050 | /* Save MSI address and data for resume. */ | ||
12051 | pci_save_state(pdev); | ||
12052 | |||
12019 | err = tg3_set_power_state(tp, pci_choose_state(pdev, state)); | 12053 | err = tg3_set_power_state(tp, pci_choose_state(pdev, state)); |
12020 | if (err) { | 12054 | if (err) { |
12021 | tg3_full_lock(tp, 0); | 12055 | tg3_full_lock(tp, 0); |
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 80f59ac7ec58..45d477e8f374 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -1660,6 +1660,7 @@ | |||
1660 | 1660 | ||
1661 | #define MII_TG3_TEST1 0x1e | 1661 | #define MII_TG3_TEST1 0x1e |
1662 | #define MII_TG3_TEST1_TRIM_EN 0x0010 | 1662 | #define MII_TG3_TEST1_TRIM_EN 0x0010 |
1663 | #define MII_TG3_TEST1_CRC_EN 0x8000 | ||
1663 | 1664 | ||
1664 | /* There are two ways to manage the TX descriptors on the tigon3. | 1665 | /* There are two ways to manage the TX descriptors on the tigon3. |
1665 | * Either the descriptors are in host DMA'able memory, or they | 1666 | * Either the descriptors are in host DMA'able memory, or they |
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c index 893808ab3742..d92c5c597e16 100644 --- a/drivers/net/tsi108_eth.c +++ b/drivers/net/tsi108_eth.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/etherdevice.h> | 38 | #include <linux/etherdevice.h> |
39 | #include <linux/skbuff.h> | 39 | #include <linux/skbuff.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/sched.h> | ||
42 | #include <linux/spinlock.h> | 41 | #include <linux/spinlock.h> |
43 | #include <linux/delay.h> | 42 | #include <linux/delay.h> |
44 | #include <linux/crc32.h> | 43 | #include <linux/crc32.h> |
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 31c97a6591a4..a2fc2bbcf97f 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
@@ -3939,8 +3939,8 @@ static void ugeth_phy_startup_timer(unsigned long data) | |||
3939 | /* Grab the PHY interrupt, if necessary/possible */ | 3939 | /* Grab the PHY interrupt, if necessary/possible */ |
3940 | if (ugeth->ug_info->board_flags & FSL_UGETH_BRD_HAS_PHY_INTR) { | 3940 | if (ugeth->ug_info->board_flags & FSL_UGETH_BRD_HAS_PHY_INTR) { |
3941 | if (request_irq(ugeth->ug_info->phy_interrupt, | 3941 | if (request_irq(ugeth->ug_info->phy_interrupt, |
3942 | phy_interrupt, | 3942 | phy_interrupt, IRQF_SHARED, |
3943 | SA_SHIRQ, "phy_interrupt", mii_info->dev) < 0) { | 3943 | "phy_interrupt", mii_info->dev) < 0) { |
3944 | ugeth_err("%s: Can't get IRQ %d (PHY)", | 3944 | ugeth_err("%s: Can't get IRQ %d (PHY)", |
3945 | mii_info->dev->name, | 3945 | mii_info->dev->name, |
3946 | ugeth->ug_info->phy_interrupt); | 3946 | ugeth->ug_info->phy_interrupt); |
diff --git a/drivers/net/ucc_geth_phy.c b/drivers/net/ucc_geth_phy.c index 6fda6d88be49..9373d895b9ec 100644 --- a/drivers/net/ucc_geth_phy.c +++ b/drivers/net/ucc_geth_phy.c | |||
@@ -18,7 +18,6 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/sched.h> | ||
22 | #include <linux/string.h> | 21 | #include <linux/string.h> |
23 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
diff --git a/drivers/net/wan/cycx_drv.c b/drivers/net/wan/cycx_drv.c index e6d005726aad..d347d59db656 100644 --- a/drivers/net/wan/cycx_drv.c +++ b/drivers/net/wan/cycx_drv.c | |||
@@ -53,7 +53,6 @@ | |||
53 | #include <linux/kernel.h> /* printk(), and other useful stuff */ | 53 | #include <linux/kernel.h> /* printk(), and other useful stuff */ |
54 | #include <linux/stddef.h> /* offsetof(), etc. */ | 54 | #include <linux/stddef.h> /* offsetof(), etc. */ |
55 | #include <linux/errno.h> /* return codes */ | 55 | #include <linux/errno.h> /* return codes */ |
56 | #include <linux/sched.h> /* for jiffies, HZ, etc. */ | ||
57 | #include <linux/cycx_drv.h> /* API definitions */ | 56 | #include <linux/cycx_drv.h> /* API definitions */ |
58 | #include <linux/cycx_cfm.h> /* CYCX firmware module definitions */ | 57 | #include <linux/cycx_cfm.h> /* CYCX firmware module definitions */ |
59 | #include <linux/delay.h> /* udelay, msleep_interruptible */ | 58 | #include <linux/delay.h> /* udelay, msleep_interruptible */ |
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c index a6b9c33b68e4..ca06a00d9d86 100644 --- a/drivers/net/wan/pci200syn.c +++ b/drivers/net/wan/pci200syn.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/types.h> | 20 | #include <linux/types.h> |
22 | #include <linux/fcntl.h> | 21 | #include <linux/fcntl.h> |
23 | #include <linux/in.h> | 22 | #include <linux/in.h> |
diff --git a/drivers/net/wireless/arlan-proc.c b/drivers/net/wireless/arlan-proc.c index 5fa985435ffa..015abd928ab0 100644 --- a/drivers/net/wireless/arlan-proc.c +++ b/drivers/net/wireless/arlan-proc.c | |||
@@ -1216,7 +1216,7 @@ static ctl_table arlan_table[MAX_ARLANS + 1] = | |||
1216 | static ctl_table arlan_root_table[] = | 1216 | static ctl_table arlan_root_table[] = |
1217 | { | 1217 | { |
1218 | { | 1218 | { |
1219 | .ctl_name = 254, | 1219 | .ctl_name = CTL_ARLAN, |
1220 | .procname = "arlan", | 1220 | .procname = "arlan", |
1221 | .maxlen = 0, | 1221 | .maxlen = 0, |
1222 | .mode = 0555, | 1222 | .mode = 0555, |
@@ -1244,7 +1244,7 @@ int __init init_arlan_proc(void) | |||
1244 | return 0; | 1244 | return 0; |
1245 | for (i = 0; i < MAX_ARLANS && arlan_device[i]; i++) | 1245 | for (i = 0; i < MAX_ARLANS && arlan_device[i]; i++) |
1246 | arlan_table[i].ctl_name = i + 1; | 1246 | arlan_table[i].ctl_name = i + 1; |
1247 | arlan_device_sysctl_header = register_sysctl_table(arlan_root_table, 0); | 1247 | arlan_device_sysctl_header = register_sysctl_table(arlan_root_table); |
1248 | if (!arlan_device_sysctl_header) | 1248 | if (!arlan_device_sysctl_header) |
1249 | return -1; | 1249 | return -1; |
1250 | 1250 | ||
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index 10bcb48e80d0..23eba698aec5 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <linux/init.h> | 42 | #include <linux/init.h> |
43 | 43 | ||
44 | #include <linux/kernel.h> | 44 | #include <linux/kernel.h> |
45 | #include <linux/sched.h> | ||
46 | #include <linux/ptrace.h> | 45 | #include <linux/ptrace.h> |
47 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
48 | #include <linux/string.h> | 47 | #include <linux/string.h> |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c index 6961be682c9d..7b665e2386a8 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <net/ieee80211softmac.h> | 33 | #include <net/ieee80211softmac.h> |
34 | #include <net/ieee80211softmac_wx.h> | 34 | #include <net/ieee80211softmac_wx.h> |
35 | #include <linux/capability.h> | 35 | #include <linux/capability.h> |
36 | #include <linux/sched.h> /* for capable() */ | ||
37 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
38 | 37 | ||
39 | #include "bcm43xx.h" | 38 | #include "bcm43xx.h" |
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c index e97cecbc4d18..309076b39853 100644 --- a/drivers/parisc/eisa.c +++ b/drivers/parisc/eisa.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
36 | #include <linux/sched.h> | ||
37 | #include <linux/spinlock.h> | 36 | #include <linux/spinlock.h> |
38 | #include <linux/eisa.h> | 37 | #include <linux/eisa.h> |
39 | 38 | ||
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index e60b4bf6bae8..316c06f4423c 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/sched.h> | ||
41 | #include <linux/ptrace.h> | 40 | #include <linux/ptrace.h> |
42 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
43 | #include <linux/string.h> | 42 | #include <linux/string.h> |
diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c index a7c5ead9a3d3..17bf9937d276 100644 --- a/drivers/parport/parport_gsc.c +++ b/drivers/parport/parport_gsc.c | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/sched.h> | ||
27 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
28 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
29 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index 2e744a274517..bdbdab9285ca 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c | |||
@@ -233,12 +233,12 @@ static int do_hardware_modes (ctl_table *table, int write, | |||
233 | return copy_to_user(result, buffer, len) ? -EFAULT : 0; | 233 | return copy_to_user(result, buffer, len) ? -EFAULT : 0; |
234 | } | 234 | } |
235 | 235 | ||
236 | #define PARPORT_PORT_DIR(child) { 0, NULL, NULL, 0, 0555, child } | 236 | #define PARPORT_PORT_DIR(CHILD) { .ctl_name = 0, .procname = NULL, .mode = 0555, .child = CHILD } |
237 | #define PARPORT_PARPORT_DIR(child) { DEV_PARPORT, "parport", \ | 237 | #define PARPORT_PARPORT_DIR(CHILD) { .ctl_name = DEV_PARPORT, .procname = "parport", \ |
238 | NULL, 0, 0555, child } | 238 | .mode = 0555, .child = CHILD } |
239 | #define PARPORT_DEV_DIR(child) { CTL_DEV, "dev", NULL, 0, 0555, child } | 239 | #define PARPORT_DEV_DIR(CHILD) { .ctl_name = CTL_DEV, .procname = "dev", .mode = 0555, .child = CHILD } |
240 | #define PARPORT_DEVICES_ROOT_DIR { DEV_PARPORT_DEVICES, "devices", \ | 240 | #define PARPORT_DEVICES_ROOT_DIR { .ctl_name = DEV_PARPORT_DEVICES, .procname = "devices", \ |
241 | NULL, 0, 0555, NULL } | 241 | .mode = 0555, .child = NULL } |
242 | 242 | ||
243 | static const unsigned long parport_min_timeslice_value = | 243 | static const unsigned long parport_min_timeslice_value = |
244 | PARPORT_MIN_TIMESLICE_VALUE; | 244 | PARPORT_MIN_TIMESLICE_VALUE; |
@@ -263,50 +263,118 @@ struct parport_sysctl_table { | |||
263 | }; | 263 | }; |
264 | 264 | ||
265 | static const struct parport_sysctl_table parport_sysctl_template = { | 265 | static const struct parport_sysctl_table parport_sysctl_template = { |
266 | NULL, | 266 | .sysctl_header = NULL, |
267 | { | 267 | { |
268 | { DEV_PARPORT_SPINTIME, "spintime", | 268 | { |
269 | NULL, sizeof(int), 0644, NULL, | 269 | .ctl_name = DEV_PARPORT_SPINTIME, |
270 | &proc_dointvec_minmax, NULL, NULL, | 270 | .procname = "spintime", |
271 | (void*) &parport_min_spintime_value, | 271 | .data = NULL, |
272 | (void*) &parport_max_spintime_value }, | 272 | .maxlen = sizeof(int), |
273 | { DEV_PARPORT_BASE_ADDR, "base-addr", | 273 | .mode = 0644, |
274 | NULL, 0, 0444, NULL, | 274 | .proc_handler = &proc_dointvec_minmax, |
275 | &do_hardware_base_addr }, | 275 | .extra1 = (void*) &parport_min_spintime_value, |
276 | { DEV_PARPORT_IRQ, "irq", | 276 | .extra2 = (void*) &parport_max_spintime_value |
277 | NULL, 0, 0444, NULL, | 277 | }, |
278 | &do_hardware_irq }, | 278 | { |
279 | { DEV_PARPORT_DMA, "dma", | 279 | .ctl_name = DEV_PARPORT_BASE_ADDR, |
280 | NULL, 0, 0444, NULL, | 280 | .procname = "base-addr", |
281 | &do_hardware_dma }, | 281 | .data = NULL, |
282 | { DEV_PARPORT_MODES, "modes", | 282 | .maxlen = 0, |
283 | NULL, 0, 0444, NULL, | 283 | .mode = 0444, |
284 | &do_hardware_modes }, | 284 | .proc_handler = &do_hardware_base_addr |
285 | }, | ||
286 | { | ||
287 | .ctl_name = DEV_PARPORT_IRQ, | ||
288 | .procname = "irq", | ||
289 | .data = NULL, | ||
290 | .maxlen = 0, | ||
291 | .mode = 0444, | ||
292 | .proc_handler = &do_hardware_irq | ||
293 | }, | ||
294 | { | ||
295 | .ctl_name = DEV_PARPORT_DMA, | ||
296 | .procname = "dma", | ||
297 | .data = NULL, | ||
298 | .maxlen = 0, | ||
299 | .mode = 0444, | ||
300 | .proc_handler = &do_hardware_dma | ||
301 | }, | ||
302 | { | ||
303 | .ctl_name = DEV_PARPORT_MODES, | ||
304 | .procname = "modes", | ||
305 | .data = NULL, | ||
306 | .maxlen = 0, | ||
307 | .mode = 0444, | ||
308 | .proc_handler = &do_hardware_modes | ||
309 | }, | ||
285 | PARPORT_DEVICES_ROOT_DIR, | 310 | PARPORT_DEVICES_ROOT_DIR, |
286 | #ifdef CONFIG_PARPORT_1284 | 311 | #ifdef CONFIG_PARPORT_1284 |
287 | { DEV_PARPORT_AUTOPROBE, "autoprobe", | 312 | { |
288 | NULL, 0, 0444, NULL, | 313 | .ctl_name = DEV_PARPORT_AUTOPROBE, |
289 | &do_autoprobe }, | 314 | .procname = "autoprobe", |
290 | { DEV_PARPORT_AUTOPROBE + 1, "autoprobe0", | 315 | .data = NULL, |
291 | NULL, 0, 0444, NULL, | 316 | .maxlen = 0, |
292 | &do_autoprobe }, | 317 | .mode = 0444, |
293 | { DEV_PARPORT_AUTOPROBE + 2, "autoprobe1", | 318 | .proc_handler = &do_autoprobe |
294 | NULL, 0, 0444, NULL, | 319 | }, |
295 | &do_autoprobe }, | 320 | { |
296 | { DEV_PARPORT_AUTOPROBE + 3, "autoprobe2", | 321 | .ctl_name = DEV_PARPORT_AUTOPROBE + 1, |
297 | NULL, 0, 0444, NULL, | 322 | .procname = "autoprobe0", |
298 | &do_autoprobe }, | 323 | .data = NULL, |
299 | { DEV_PARPORT_AUTOPROBE + 4, "autoprobe3", | 324 | .maxlen = 0, |
300 | NULL, 0, 0444, NULL, | 325 | .mode = 0444, |
301 | &do_autoprobe }, | 326 | .proc_handler = &do_autoprobe |
327 | }, | ||
328 | { | ||
329 | .ctl_name = DEV_PARPORT_AUTOPROBE + 2, | ||
330 | .procname = "autoprobe1", | ||
331 | .data = NULL, | ||
332 | .maxlen = 0, | ||
333 | .mode = 0444, | ||
334 | .proc_handler = &do_autoprobe | ||
335 | }, | ||
336 | { | ||
337 | .ctl_name = DEV_PARPORT_AUTOPROBE + 3, | ||
338 | .procname = "autoprobe2", | ||
339 | .data = NULL, | ||
340 | .maxlen = 0, | ||
341 | .mode = 0444, | ||
342 | .proc_handler = &do_autoprobe | ||
343 | }, | ||
344 | { | ||
345 | .ctl_name = DEV_PARPORT_AUTOPROBE + 4, | ||
346 | .procname = "autoprobe3", | ||
347 | .data = NULL, | ||
348 | .maxlen = 0, | ||
349 | .mode = 0444, | ||
350 | .proc_handler = &do_autoprobe | ||
351 | }, | ||
302 | #endif /* IEEE 1284 support */ | 352 | #endif /* IEEE 1284 support */ |
303 | {0} | 353 | {} |
304 | }, | 354 | }, |
305 | { {DEV_PARPORT_DEVICES_ACTIVE, "active", NULL, 0, 0444, NULL, | 355 | { |
306 | &do_active_device }, {0}}, | 356 | { |
307 | { PARPORT_PORT_DIR(NULL), {0}}, | 357 | .ctl_name = DEV_PARPORT_DEVICES_ACTIVE, |
308 | { PARPORT_PARPORT_DIR(NULL), {0}}, | 358 | .procname = "active", |
309 | { PARPORT_DEV_DIR(NULL), {0}} | 359 | .data = NULL, |
360 | .maxlen = 0, | ||
361 | .mode = 0444, | ||
362 | .proc_handler = &do_active_device | ||
363 | }, | ||
364 | {} | ||
365 | }, | ||
366 | { | ||
367 | PARPORT_PORT_DIR(NULL), | ||
368 | {} | ||
369 | }, | ||
370 | { | ||
371 | PARPORT_PARPORT_DIR(NULL), | ||
372 | {} | ||
373 | }, | ||
374 | { | ||
375 | PARPORT_DEV_DIR(NULL), | ||
376 | {} | ||
377 | } | ||
310 | }; | 378 | }; |
311 | 379 | ||
312 | struct parport_device_sysctl_table | 380 | struct parport_device_sysctl_table |
@@ -322,19 +390,46 @@ struct parport_device_sysctl_table | |||
322 | 390 | ||
323 | static const struct parport_device_sysctl_table | 391 | static const struct parport_device_sysctl_table |
324 | parport_device_sysctl_template = { | 392 | parport_device_sysctl_template = { |
325 | NULL, | 393 | .sysctl_header = NULL, |
394 | { | ||
395 | { | ||
396 | .ctl_name = DEV_PARPORT_DEVICE_TIMESLICE, | ||
397 | .procname = "timeslice", | ||
398 | .data = NULL, | ||
399 | .maxlen = sizeof(int), | ||
400 | .mode = 0644, | ||
401 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, | ||
402 | .extra1 = (void*) &parport_min_timeslice_value, | ||
403 | .extra2 = (void*) &parport_max_timeslice_value | ||
404 | }, | ||
405 | }, | ||
406 | { | ||
407 | { | ||
408 | .ctl_name = 0, | ||
409 | .procname = NULL, | ||
410 | .data = NULL, | ||
411 | .maxlen = 0, | ||
412 | .mode = 0555, | ||
413 | .child = NULL | ||
414 | }, | ||
415 | {} | ||
416 | }, | ||
326 | { | 417 | { |
327 | { DEV_PARPORT_DEVICE_TIMESLICE, "timeslice", | 418 | PARPORT_DEVICES_ROOT_DIR, |
328 | NULL, sizeof(int), 0644, NULL, | 419 | {} |
329 | &proc_doulongvec_ms_jiffies_minmax, NULL, NULL, | 420 | }, |
330 | (void*) &parport_min_timeslice_value, | 421 | { |
331 | (void*) &parport_max_timeslice_value }, | 422 | PARPORT_PORT_DIR(NULL), |
423 | {} | ||
332 | }, | 424 | }, |
333 | { {0, NULL, NULL, 0, 0555, NULL}, {0}}, | 425 | { |
334 | { PARPORT_DEVICES_ROOT_DIR, {0}}, | 426 | PARPORT_PARPORT_DIR(NULL), |
335 | { PARPORT_PORT_DIR(NULL), {0}}, | 427 | {} |
336 | { PARPORT_PARPORT_DIR(NULL), {0}}, | 428 | }, |
337 | { PARPORT_DEV_DIR(NULL), {0}} | 429 | { |
430 | PARPORT_DEV_DIR(NULL), | ||
431 | {} | ||
432 | } | ||
338 | }; | 433 | }; |
339 | 434 | ||
340 | struct parport_default_sysctl_table | 435 | struct parport_default_sysctl_table |
@@ -351,28 +446,47 @@ extern int parport_default_spintime; | |||
351 | 446 | ||
352 | static struct parport_default_sysctl_table | 447 | static struct parport_default_sysctl_table |
353 | parport_default_sysctl_table = { | 448 | parport_default_sysctl_table = { |
354 | NULL, | 449 | .sysctl_header = NULL, |
450 | { | ||
451 | { | ||
452 | .ctl_name = DEV_PARPORT_DEFAULT_TIMESLICE, | ||
453 | .procname = "timeslice", | ||
454 | .data = &parport_default_timeslice, | ||
455 | .maxlen = sizeof(parport_default_timeslice), | ||
456 | .mode = 0644, | ||
457 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, | ||
458 | .extra1 = (void*) &parport_min_timeslice_value, | ||
459 | .extra2 = (void*) &parport_max_timeslice_value | ||
460 | }, | ||
461 | { | ||
462 | .ctl_name = DEV_PARPORT_DEFAULT_SPINTIME, | ||
463 | .procname = "spintime", | ||
464 | .data = &parport_default_spintime, | ||
465 | .maxlen = sizeof(parport_default_spintime), | ||
466 | .mode = 0644, | ||
467 | .proc_handler = &proc_dointvec_minmax, | ||
468 | .extra1 = (void*) &parport_min_spintime_value, | ||
469 | .extra2 = (void*) &parport_max_spintime_value | ||
470 | }, | ||
471 | {} | ||
472 | }, | ||
355 | { | 473 | { |
356 | { DEV_PARPORT_DEFAULT_TIMESLICE, "timeslice", | 474 | { |
357 | &parport_default_timeslice, | 475 | .ctl_name = DEV_PARPORT_DEFAULT, |
358 | sizeof(parport_default_timeslice), 0644, NULL, | 476 | .procname = "default", |
359 | &proc_doulongvec_ms_jiffies_minmax, NULL, NULL, | 477 | .mode = 0555, |
360 | (void*) &parport_min_timeslice_value, | 478 | .child = parport_default_sysctl_table.vars |
361 | (void*) &parport_max_timeslice_value }, | 479 | }, |
362 | { DEV_PARPORT_DEFAULT_SPINTIME, "spintime", | 480 | {} |
363 | &parport_default_spintime, | ||
364 | sizeof(parport_default_spintime), 0644, NULL, | ||
365 | &proc_dointvec_minmax, NULL, NULL, | ||
366 | (void*) &parport_min_spintime_value, | ||
367 | (void*) &parport_max_spintime_value }, | ||
368 | {0} | ||
369 | }, | 481 | }, |
370 | { { DEV_PARPORT_DEFAULT, "default", NULL, 0, 0555, | ||
371 | parport_default_sysctl_table.vars },{0}}, | ||
372 | { | 482 | { |
373 | PARPORT_PARPORT_DIR(parport_default_sysctl_table.default_dir), | 483 | PARPORT_PARPORT_DIR(parport_default_sysctl_table.default_dir), |
374 | {0}}, | 484 | {} |
375 | { PARPORT_DEV_DIR(parport_default_sysctl_table.parport_dir), {0}} | 485 | }, |
486 | { | ||
487 | PARPORT_DEV_DIR(parport_default_sysctl_table.parport_dir), | ||
488 | {} | ||
489 | } | ||
376 | }; | 490 | }; |
377 | 491 | ||
378 | 492 | ||
@@ -404,7 +518,7 @@ int parport_proc_register(struct parport *port) | |||
404 | t->parport_dir[0].child = t->port_dir; | 518 | t->parport_dir[0].child = t->port_dir; |
405 | t->dev_dir[0].child = t->parport_dir; | 519 | t->dev_dir[0].child = t->parport_dir; |
406 | 520 | ||
407 | t->sysctl_header = register_sysctl_table(t->dev_dir, 0); | 521 | t->sysctl_header = register_sysctl_table(t->dev_dir); |
408 | if (t->sysctl_header == NULL) { | 522 | if (t->sysctl_header == NULL) { |
409 | kfree(t); | 523 | kfree(t); |
410 | t = NULL; | 524 | t = NULL; |
@@ -460,7 +574,7 @@ int parport_device_proc_register(struct pardevice *device) | |||
460 | t->device_dir[0].child = t->vars; | 574 | t->device_dir[0].child = t->vars; |
461 | t->vars[0].data = &device->timeslice; | 575 | t->vars[0].data = &device->timeslice; |
462 | 576 | ||
463 | t->sysctl_header = register_sysctl_table(t->dev_dir, 0); | 577 | t->sysctl_header = register_sysctl_table(t->dev_dir); |
464 | if (t->sysctl_header == NULL) { | 578 | if (t->sysctl_header == NULL) { |
465 | kfree(t); | 579 | kfree(t); |
466 | t = NULL; | 580 | t = NULL; |
@@ -483,7 +597,7 @@ int parport_device_proc_unregister(struct pardevice *device) | |||
483 | static int __init parport_default_proc_register(void) | 597 | static int __init parport_default_proc_register(void) |
484 | { | 598 | { |
485 | parport_default_sysctl_table.sysctl_header = | 599 | parport_default_sysctl_table.sysctl_header = |
486 | register_sysctl_table(parport_default_sysctl_table.dev_dir, 0); | 600 | register_sysctl_table(parport_default_sysctl_table.dev_dir); |
487 | return 0; | 601 | return 0; |
488 | } | 602 | } |
489 | 603 | ||
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c index 05e4f5a1927a..600ed7b67ae7 100644 --- a/drivers/pci/hotplug/ibmphp_ebda.c +++ b/drivers/pci/hotplug/ibmphp_ebda.c | |||
@@ -28,7 +28,6 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/sched.h> | ||
32 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
33 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
34 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index 6f5fabbd14e5..b164de050d4f 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c | |||
@@ -220,7 +220,7 @@ static int __devinit aer_probe (struct pcie_device *dev, | |||
220 | } | 220 | } |
221 | 221 | ||
222 | /* Request IRQ ISR */ | 222 | /* Request IRQ ISR */ |
223 | if ((status = request_irq(dev->irq, aer_irq, SA_SHIRQ, "aerdrv", | 223 | if ((status = request_irq(dev->irq, aer_irq, IRQF_SHARED, "aerdrv", |
224 | dev))) { | 224 | dev))) { |
225 | printk(KERN_DEBUG "%s: Request ISR fails on PCIE device[%s]\n", | 225 | printk(KERN_DEBUG "%s: Request ISR fails on PCIE device[%s]\n", |
226 | __FUNCTION__, device->bus_id); | 226 | __FUNCTION__, device->bus_id); |
diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c index 87fafc08cb9d..9d37fec27f24 100644 --- a/drivers/pci/syscall.c +++ b/drivers/pci/syscall.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * magic northbridge registers.. | 7 | * magic northbridge registers.. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/sched.h> | ||
11 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
12 | #include <linux/pci.h> | 11 | #include <linux/pci.h> |
13 | #include <linux/smp_lock.h> | 12 | #include <linux/smp_lock.h> |
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c index 3334f22a86c0..b31862837534 100644 --- a/drivers/pcmcia/at91_cf.c +++ b/drivers/pcmcia/at91_cf.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/sched.h> | ||
15 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
16 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 912c03e5eb0a..d154dee76e7f 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/timer.h> | 21 | #include <linux/timer.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
24 | #include <linux/sched.h> | ||
25 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
26 | #include <linux/ioport.h> | 25 | #include <linux/ioport.h> |
27 | #include <asm/io.h> | 26 | #include <asm/io.h> |
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 72ff2f615b33..71b33707117f 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <linux/kernel.h> | 40 | #include <linux/kernel.h> |
41 | #include <linux/errno.h> | 41 | #include <linux/errno.h> |
42 | #include <linux/timer.h> | 42 | #include <linux/timer.h> |
43 | #include <linux/sched.h> | ||
44 | #include <linux/slab.h> | 43 | #include <linux/slab.h> |
45 | #include <linux/ioport.h> | 44 | #include <linux/ioport.h> |
46 | #include <linux/delay.h> | 45 | #include <linux/delay.h> |
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c index 3c22ac4625c2..e4a94108aab9 100644 --- a/drivers/pcmcia/m32r_cfc.c +++ b/drivers/pcmcia/m32r_cfc.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/timer.h> | 18 | #include <linux/timer.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
21 | #include <linux/ioport.h> | 20 | #include <linux/ioport.h> |
22 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c index 4dbef0762376..67d28ee80f22 100644 --- a/drivers/pcmcia/m32r_pcc.c +++ b/drivers/pcmcia/m32r_pcc.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/timer.h> | 18 | #include <linux/timer.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
21 | #include <linux/ioport.h> | 20 | #include <linux/ioport.h> |
22 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c index 3b72be880401..d059c9196172 100644 --- a/drivers/pcmcia/m8xx_pcmcia.c +++ b/drivers/pcmcia/m8xx_pcmcia.c | |||
@@ -46,7 +46,6 @@ | |||
46 | 46 | ||
47 | #include <linux/kernel.h> | 47 | #include <linux/kernel.h> |
48 | #include <linux/errno.h> | 48 | #include <linux/errno.h> |
49 | #include <linux/sched.h> | ||
50 | #include <linux/slab.h> | 49 | #include <linux/slab.h> |
51 | #include <linux/timer.h> | 50 | #include <linux/timer.h> |
52 | #include <linux/ioport.h> | 51 | #include <linux/ioport.h> |
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c index e65a6b8188f6..76f7cbc62a8b 100644 --- a/drivers/pcmcia/omap_cf.c +++ b/drivers/pcmcia/omap_cf.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/sched.h> | ||
15 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
16 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
diff --git a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c index a92f11143c43..5e9b9a3fd027 100644 --- a/drivers/pcmcia/pxa2xx_lubbock.c +++ b/drivers/pcmcia/pxa2xx_lubbock.c | |||
@@ -16,7 +16,6 @@ | |||
16 | */ | 16 | */ |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/device.h> | 19 | #include <linux/device.h> |
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
22 | #include <linux/init.h> | 21 | #include <linux/init.h> |
diff --git a/drivers/pcmcia/sa1100_badge4.c b/drivers/pcmcia/sa1100_badge4.c index 19b1e1276220..62bfc7566ec2 100644 --- a/drivers/pcmcia/sa1100_badge4.c +++ b/drivers/pcmcia/sa1100_badge4.c | |||
@@ -14,7 +14,6 @@ | |||
14 | */ | 14 | */ |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/device.h> | 17 | #include <linux/device.h> |
19 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
20 | #include <linux/init.h> | 19 | #include <linux/init.h> |
diff --git a/drivers/pcmcia/sa1100_cerf.c b/drivers/pcmcia/sa1100_cerf.c index eb89928f2338..549a1529fe35 100644 --- a/drivers/pcmcia/sa1100_cerf.c +++ b/drivers/pcmcia/sa1100_cerf.c | |||
@@ -7,7 +7,6 @@ | |||
7 | */ | 7 | */ |
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/sched.h> | ||
11 | #include <linux/device.h> | 10 | #include <linux/device.h> |
12 | #include <linux/init.h> | 11 | #include <linux/init.h> |
13 | #include <linux/delay.h> | 12 | #include <linux/delay.h> |
diff --git a/drivers/pcmcia/sa1100_h3600.c b/drivers/pcmcia/sa1100_h3600.c index 64fd5e37f2d2..e5491879acd9 100644 --- a/drivers/pcmcia/sa1100_h3600.c +++ b/drivers/pcmcia/sa1100_h3600.c | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/sched.h> | ||
10 | #include <linux/device.h> | 9 | #include <linux/device.h> |
11 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
12 | #include <linux/init.h> | 11 | #include <linux/init.h> |
diff --git a/drivers/pcmcia/sa1100_jornada720.c b/drivers/pcmcia/sa1100_jornada720.c index 7a87298bae99..af485ae38602 100644 --- a/drivers/pcmcia/sa1100_jornada720.c +++ b/drivers/pcmcia/sa1100_jornada720.c | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/sched.h> | ||
10 | #include <linux/device.h> | 9 | #include <linux/device.h> |
11 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
12 | #include <linux/init.h> | 11 | #include <linux/init.h> |
diff --git a/drivers/pcmcia/sa1100_neponset.c b/drivers/pcmcia/sa1100_neponset.c index 5e34b3e8e5db..5bc9e9532b9d 100644 --- a/drivers/pcmcia/sa1100_neponset.c +++ b/drivers/pcmcia/sa1100_neponset.c | |||
@@ -5,7 +5,6 @@ | |||
5 | */ | 5 | */ |
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/sched.h> | ||
9 | #include <linux/device.h> | 8 | #include <linux/device.h> |
10 | #include <linux/errno.h> | 9 | #include <linux/errno.h> |
11 | #include <linux/init.h> | 10 | #include <linux/init.h> |
diff --git a/drivers/pcmcia/sa1100_shannon.c b/drivers/pcmcia/sa1100_shannon.c index 7bc9e59c761f..9456f5478d09 100644 --- a/drivers/pcmcia/sa1100_shannon.c +++ b/drivers/pcmcia/sa1100_shannon.c | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/sched.h> | ||
10 | #include <linux/device.h> | 9 | #include <linux/device.h> |
11 | #include <linux/init.h> | 10 | #include <linux/init.h> |
12 | 11 | ||
diff --git a/drivers/pcmcia/sa1100_simpad.c b/drivers/pcmcia/sa1100_simpad.c index c2ecf1185e9e..04d6f7f75f78 100644 --- a/drivers/pcmcia/sa1100_simpad.c +++ b/drivers/pcmcia/sa1100_simpad.c | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/sched.h> | ||
10 | #include <linux/device.h> | 9 | #include <linux/device.h> |
11 | #include <linux/init.h> | 10 | #include <linux/init.h> |
12 | 11 | ||
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c index e90d8e8c5fd6..206e26c91807 100644 --- a/drivers/pcmcia/vrc4171_card.c +++ b/drivers/pcmcia/vrc4171_card.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
25 | #include <linux/sched.h> | ||
26 | #include <linux/types.h> | 25 | #include <linux/types.h> |
27 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
28 | 27 | ||
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index a61d768f6e0e..20853a03202d 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c | |||
@@ -12,7 +12,6 @@ | |||
12 | */ | 12 | */ |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/pci.h> | 14 | #include <linux/pci.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/workqueue.h> | 15 | #include <linux/workqueue.h> |
17 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
18 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c index 5687b8fcbf93..eed91434417d 100644 --- a/drivers/rapidio/rio-sysfs.c +++ b/drivers/rapidio/rio-sysfs.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/rio.h> | 14 | #include <linux/rio.h> |
15 | #include <linux/rio_drv.h> | 15 | #include <linux/rio_drv.h> |
16 | #include <linux/stat.h> | 16 | #include <linux/stat.h> |
17 | #include <linux/sched.h> /* for capable() */ | ||
18 | 17 | ||
19 | #include "rio.h" | 18 | #include "rio.h" |
20 | 19 | ||
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index 205fa28593b7..dfef1637bfb8 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c | |||
@@ -199,7 +199,7 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind) | |||
199 | struct i2c_client *client; | 199 | struct i2c_client *client; |
200 | struct rtc_device *rtc; | 200 | struct rtc_device *rtc; |
201 | 201 | ||
202 | dev_dbg(adapter->class_dev.dev, "%s\n", __FUNCTION__); | 202 | dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); |
203 | 203 | ||
204 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { | 204 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { |
205 | err = -ENODEV; | 205 | err = -ENODEV; |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index d59880d44fba..9de8d67f4f8d 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -417,13 +417,13 @@ static int __devinit omap_rtc_probe(struct platform_device *pdev) | |||
417 | rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); | 417 | rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); |
418 | 418 | ||
419 | /* handle periodic and alarm irqs */ | 419 | /* handle periodic and alarm irqs */ |
420 | if (request_irq(omap_rtc_timer, rtc_irq, SA_INTERRUPT, | 420 | if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED, |
421 | rtc->class_dev.class_id, &rtc->class_dev)) { | 421 | rtc->class_dev.class_id, &rtc->class_dev)) { |
422 | pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", | 422 | pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", |
423 | pdev->name, omap_rtc_timer); | 423 | pdev->name, omap_rtc_timer); |
424 | goto fail0; | 424 | goto fail0; |
425 | } | 425 | } |
426 | if (request_irq(omap_rtc_alarm, rtc_irq, SA_INTERRUPT, | 426 | if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED, |
427 | rtc->class_dev.class_id, &rtc->class_dev)) { | 427 | rtc->class_dev.class_id, &rtc->class_dev)) { |
428 | pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", | 428 | pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", |
429 | pdev->name, omap_rtc_alarm); | 429 | pdev->name, omap_rtc_alarm); |
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index 038118bbfaea..0242d803ebe5 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -279,7 +279,7 @@ static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind) | |||
279 | 279 | ||
280 | int err = 0; | 280 | int err = 0; |
281 | 281 | ||
282 | dev_dbg(adapter->class_dev.dev, "%s\n", __FUNCTION__); | 282 | dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); |
283 | 283 | ||
284 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { | 284 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { |
285 | err = -ENODEV; | 285 | err = -ENODEV; |
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index e7851e3739ab..09bbe575647b 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -499,7 +499,7 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind) | |||
499 | struct rs5c372 *rs5c372; | 499 | struct rs5c372 *rs5c372; |
500 | struct rtc_time tm; | 500 | struct rtc_time tm; |
501 | 501 | ||
502 | dev_dbg(adapter->class_dev.dev, "%s\n", __FUNCTION__); | 502 | dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); |
503 | 503 | ||
504 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { | 504 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { |
505 | err = -ENODEV; | 505 | err = -ENODEV; |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index f406a2b55aea..9a79a24a7487 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -350,7 +350,7 @@ static int s3c_rtc_open(struct device *dev) | |||
350 | int ret; | 350 | int ret; |
351 | 351 | ||
352 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | 352 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, |
353 | SA_INTERRUPT, "s3c2410-rtc alarm", rtc_dev); | 353 | IRQF_DISABLED, "s3c2410-rtc alarm", rtc_dev); |
354 | 354 | ||
355 | if (ret) { | 355 | if (ret) { |
356 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | 356 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); |
@@ -358,7 +358,7 @@ static int s3c_rtc_open(struct device *dev) | |||
358 | } | 358 | } |
359 | 359 | ||
360 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | 360 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, |
361 | SA_INTERRUPT, "s3c2410-rtc tick", rtc_dev); | 361 | IRQF_DISABLED, "s3c2410-rtc tick", rtc_dev); |
362 | 362 | ||
363 | if (ret) { | 363 | if (ret) { |
364 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | 364 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); |
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index 019ae255b0c8..513d1a611aab 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c | |||
@@ -506,7 +506,7 @@ static int x1205_probe(struct i2c_adapter *adapter, int address, int kind) | |||
506 | struct i2c_client *client; | 506 | struct i2c_client *client; |
507 | struct rtc_device *rtc; | 507 | struct rtc_device *rtc; |
508 | 508 | ||
509 | dev_dbg(adapter->class_dev.dev, "%s\n", __FUNCTION__); | 509 | dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); |
510 | 510 | ||
511 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { | 511 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { |
512 | err = -ENODEV; | 512 | err = -ENODEV; |
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 90536f60bf50..076816b9d528 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/tty.h> | 13 | #include <linux/tty.h> |
14 | #include <linux/tty_driver.h> | 14 | #include <linux/tty_driver.h> |
15 | #include <linux/tty_flip.h> | 15 | #include <linux/tty_flip.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/wait.h> | 16 | #include <linux/wait.h> |
18 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
19 | #include <linux/err.h> | 18 | #include <linux/err.h> |
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index 544f137d70d7..f77dc33b5f8d 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/tty.h> | 16 | #include <linux/tty.h> |
17 | #include <linux/tty_driver.h> | 17 | #include <linux/tty_driver.h> |
18 | #include <linux/tty_flip.h> | 18 | #include <linux/tty_flip.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
21 | #include <linux/mm.h> | 20 | #include <linux/mm.h> |
22 | #include <linux/major.h> | 21 | #include <linux/major.h> |
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c index 5a84fbbc6611..0d6d5fcc128b 100644 --- a/drivers/s390/net/ctcmain.c +++ b/drivers/s390/net/ctcmain.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <linux/types.h> | 45 | #include <linux/types.h> |
46 | #include <linux/interrupt.h> | 46 | #include <linux/interrupt.h> |
47 | #include <linux/timer.h> | 47 | #include <linux/timer.h> |
48 | #include <linux/sched.h> | ||
49 | #include <linux/bitops.h> | 48 | #include <linux/bitops.h> |
50 | 49 | ||
51 | #include <linux/signal.h> | 50 | #include <linux/signal.h> |
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c index 6387b483f2bf..594320ca1b7c 100644 --- a/drivers/s390/net/netiucv.c +++ b/drivers/s390/net/netiucv.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <linux/types.h> | 41 | #include <linux/types.h> |
42 | #include <linux/interrupt.h> | 42 | #include <linux/interrupt.h> |
43 | #include <linux/timer.h> | 43 | #include <linux/timer.h> |
44 | #include <linux/sched.h> | ||
45 | #include <linux/bitops.h> | 44 | #include <linux/bitops.h> |
46 | 45 | ||
47 | #include <linux/signal.h> | 46 | #include <linux/signal.h> |
diff --git a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c index 0cfd1e4c032c..022e869c44dd 100644 --- a/drivers/sbus/char/cpwatchdog.c +++ b/drivers/sbus/char/cpwatchdog.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/major.h> | 20 | #include <linux/major.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/miscdevice.h> | 22 | #include <linux/miscdevice.h> |
23 | #include <linux/sched.h> | ||
24 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
25 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
26 | #include <linux/timer.h> | 25 | #include <linux/timer.h> |
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c index e8776230782b..eec28c142a59 100644 --- a/drivers/sbus/char/openprom.c +++ b/drivers/sbus/char/openprom.c | |||
@@ -31,7 +31,6 @@ | |||
31 | 31 | ||
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/sched.h> | ||
35 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
36 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
37 | #include <linux/string.h> | 36 | #include <linux/string.h> |
diff --git a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c index 4d1a505e9e74..45cf5bc0bbee 100644 --- a/drivers/sbus/char/uctrl.c +++ b/drivers/sbus/char/uctrl.c | |||
@@ -5,7 +5,6 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/sched.h> | ||
9 | #include <linux/errno.h> | 8 | #include <linux/errno.h> |
10 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
11 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c index 37a04a0cecfa..8bfb67ccdcd4 100644 --- a/drivers/sbus/char/vfc_dev.c +++ b/drivers/sbus/char/vfc_dev.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
22 | #include <linux/sched.h> | ||
23 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
24 | #include <linux/smp_lock.h> | 23 | #include <linux/smp_lock.h> |
25 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 88e061d13d0b..cb02656eb54c 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c | |||
@@ -121,7 +121,6 @@ | |||
121 | #include <linux/delay.h> | 121 | #include <linux/delay.h> |
122 | #include <linux/spinlock.h> | 122 | #include <linux/spinlock.h> |
123 | #include <linux/completion.h> | 123 | #include <linux/completion.h> |
124 | #include <linux/sched.h> | ||
125 | #include <linux/init.h> | 124 | #include <linux/init.h> |
126 | #include <linux/proc_fs.h> | 125 | #include <linux/proc_fs.h> |
127 | #include <linux/blkdev.h> | 126 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c index 8578555d58fd..7c0b17f86903 100644 --- a/drivers/scsi/NCR53c406a.c +++ b/drivers/scsi/NCR53c406a.c | |||
@@ -41,7 +41,6 @@ | |||
41 | 41 | ||
42 | #include <linux/errno.h> | 42 | #include <linux/errno.h> |
43 | #include <linux/ioport.h> | 43 | #include <linux/ioport.h> |
44 | #include <linux/sched.h> | ||
45 | #include <linux/interrupt.h> | 44 | #include <linux/interrupt.h> |
46 | #include <linux/proc_fs.h> | 45 | #include <linux/proc_fs.h> |
47 | #include <linux/stat.h> | 46 | #include <linux/stat.h> |
diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c index f77016d31cab..b7c5385e2efe 100644 --- a/drivers/scsi/a2091.c +++ b/drivers/scsi/a2091.c | |||
@@ -1,7 +1,6 @@ | |||
1 | #include <linux/types.h> | 1 | #include <linux/types.h> |
2 | #include <linux/mm.h> | 2 | #include <linux/mm.h> |
3 | #include <linux/blkdev.h> | 3 | #include <linux/blkdev.h> |
4 | #include <linux/sched.h> | ||
5 | #include <linux/init.h> | 4 | #include <linux/init.h> |
6 | #include <linux/interrupt.h> | 5 | #include <linux/interrupt.h> |
7 | 6 | ||
diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c index 1299bc8edef1..796f1c4d772e 100644 --- a/drivers/scsi/a3000.c +++ b/drivers/scsi/a3000.c | |||
@@ -1,7 +1,6 @@ | |||
1 | #include <linux/types.h> | 1 | #include <linux/types.h> |
2 | #include <linux/mm.h> | 2 | #include <linux/mm.h> |
3 | #include <linux/blkdev.h> | 3 | #include <linux/blkdev.h> |
4 | #include <linux/sched.h> | ||
5 | #include <linux/ioport.h> | 4 | #include <linux/ioport.h> |
6 | #include <linux/init.h> | 5 | #include <linux/init.h> |
7 | #include <linux/spinlock.h> | 6 | #include <linux/spinlock.h> |
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index ddb33b06e0ef..d789e61bdc49 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
29 | #include <linux/sched.h> | ||
30 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
31 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index da1d3a9212f8..e21070f4eac1 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/types.h> | 33 | #include <linux/types.h> |
34 | #include <linux/sched.h> | ||
35 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
36 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index df67ba686023..ae34768987a4 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/types.h> | 34 | #include <linux/types.h> |
35 | #include <linux/sched.h> | ||
36 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
37 | #include <linux/spinlock.h> | 36 | #include <linux/spinlock.h> |
38 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c index 8335f07b7720..d38b628be1ad 100644 --- a/drivers/scsi/aacraid/dpcsup.c +++ b/drivers/scsi/aacraid/dpcsup.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/types.h> | 34 | #include <linux/types.h> |
35 | #include <linux/sched.h> | ||
36 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
37 | #include <linux/spinlock.h> | 36 | #include <linux/spinlock.h> |
38 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c index c632d9354a26..d242e2611d67 100644 --- a/drivers/scsi/aacraid/rx.c +++ b/drivers/scsi/aacraid/rx.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/types.h> | 33 | #include <linux/types.h> |
34 | #include <linux/sched.h> | ||
35 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
36 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c index 8535db068c2f..6f1a1780efce 100644 --- a/drivers/scsi/aacraid/sa.c +++ b/drivers/scsi/aacraid/sa.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/types.h> | 33 | #include <linux/types.h> |
34 | #include <linux/sched.h> | ||
35 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
36 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 0cec742d12e9..4b4d1233ce8a 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c | |||
@@ -236,7 +236,6 @@ | |||
236 | **************************************************************************/ | 236 | **************************************************************************/ |
237 | 237 | ||
238 | #include <linux/module.h> | 238 | #include <linux/module.h> |
239 | #include <linux/sched.h> | ||
240 | #include <asm/irq.h> | 239 | #include <asm/irq.h> |
241 | #include <linux/io.h> | 240 | #include <linux/io.h> |
242 | #include <linux/blkdev.h> | 241 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c index 7d1fec620948..a988d5abf702 100644 --- a/drivers/scsi/aic7xxx_old.c +++ b/drivers/scsi/aic7xxx_old.c | |||
@@ -229,7 +229,6 @@ | |||
229 | #include <linux/kernel.h> | 229 | #include <linux/kernel.h> |
230 | #include <linux/ioport.h> | 230 | #include <linux/ioport.h> |
231 | #include <linux/delay.h> | 231 | #include <linux/delay.h> |
232 | #include <linux/sched.h> | ||
233 | #include <linux/pci.h> | 232 | #include <linux/pci.h> |
234 | #include <linux/proc_fs.h> | 233 | #include <linux/proc_fs.h> |
235 | #include <linux/blkdev.h> | 234 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index bc7744e35ad0..27852b43b904 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c | |||
@@ -653,7 +653,7 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, | |||
653 | if (use_msi) | 653 | if (use_msi) |
654 | pci_enable_msi(asd_ha->pcidev); | 654 | pci_enable_msi(asd_ha->pcidev); |
655 | 655 | ||
656 | err = request_irq(asd_ha->pcidev->irq, asd_hw_isr, SA_SHIRQ, | 656 | err = request_irq(asd_ha->pcidev->irq, asd_hw_isr, IRQF_SHARED, |
657 | ASD_DRIVER_NAME, asd_ha); | 657 | ASD_DRIVER_NAME, asd_ha); |
658 | if (err) { | 658 | if (err) { |
659 | asd_printk("couldn't get irq %d for %s\n", | 659 | asd_printk("couldn't get irq %d for %s\n", |
diff --git a/drivers/scsi/amiga7xx.c b/drivers/scsi/amiga7xx.c index 9099d531d5a4..d5d3c4d5a253 100644 --- a/drivers/scsi/amiga7xx.c +++ b/drivers/scsi/amiga7xx.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
11 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
12 | #include <linux/blkdev.h> | 12 | #include <linux/blkdev.h> |
13 | #include <linux/sched.h> | ||
14 | #include <linux/zorro.h> | 13 | #include <linux/zorro.h> |
15 | #include <linux/stat.h> | 14 | #include <linux/stat.h> |
16 | 15 | ||
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 086cc97eee8c..8b46158cc045 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c | |||
@@ -322,7 +322,7 @@ static int arcmsr_probe(struct pci_dev *pdev, | |||
322 | goto out_iounmap; | 322 | goto out_iounmap; |
323 | 323 | ||
324 | error = request_irq(pdev->irq, arcmsr_do_interrupt, | 324 | error = request_irq(pdev->irq, arcmsr_do_interrupt, |
325 | SA_INTERRUPT | SA_SHIRQ, "arcmsr", acb); | 325 | IRQF_DISABLED | IRQF_SHARED, "arcmsr", acb); |
326 | if (error) | 326 | if (error) |
327 | goto out_free_ccb_pool; | 327 | goto out_free_ccb_pool; |
328 | 328 | ||
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index 9cf902b7a126..eceacf6d49ea 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c | |||
@@ -131,7 +131,6 @@ | |||
131 | 131 | ||
132 | #include <linux/module.h> | 132 | #include <linux/module.h> |
133 | #include <linux/kernel.h> | 133 | #include <linux/kernel.h> |
134 | #include <linux/sched.h> | ||
135 | #include <linux/string.h> | 134 | #include <linux/string.h> |
136 | #include <linux/signal.h> | 135 | #include <linux/signal.h> |
137 | #include <linux/errno.h> | 136 | #include <linux/errno.h> |
diff --git a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c index 4385e9e3ded6..7e132c5bacf8 100644 --- a/drivers/scsi/arm/arxescsi.c +++ b/drivers/scsi/arm/arxescsi.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/string.h> | 24 | #include <linux/string.h> |
25 | #include <linux/ioport.h> | 25 | #include <linux/ioport.h> |
26 | #include <linux/sched.h> | ||
27 | #include <linux/proc_fs.h> | 26 | #include <linux/proc_fs.h> |
28 | #include <linux/unistd.h> | 27 | #include <linux/unistd.h> |
29 | #include <linux/stat.h> | 28 | #include <linux/stat.h> |
diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c index 3bdfc36481ae..cf9a21cea6d9 100644 --- a/drivers/scsi/arm/cumana_1.c +++ b/drivers/scsi/arm/cumana_1.c | |||
@@ -5,7 +5,6 @@ | |||
5 | */ | 5 | */ |
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/signal.h> | 7 | #include <linux/signal.h> |
8 | #include <linux/sched.h> | ||
9 | #include <linux/ioport.h> | 8 | #include <linux/ioport.h> |
10 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
11 | #include <linux/blkdev.h> | 10 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c index 19edd9c853d9..d2d51dc51ab8 100644 --- a/drivers/scsi/arm/cumana_2.c +++ b/drivers/scsi/arm/cumana_2.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/string.h> | 22 | #include <linux/string.h> |
23 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
24 | #include <linux/sched.h> | ||
25 | #include <linux/proc_fs.h> | 24 | #include <linux/proc_fs.h> |
26 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
27 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
diff --git a/drivers/scsi/arm/ecoscsi.c b/drivers/scsi/arm/ecoscsi.c index 6adcccbf444b..378e7af0c5d6 100644 --- a/drivers/scsi/arm/ecoscsi.c +++ b/drivers/scsi/arm/ecoscsi.c | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/signal.h> | 25 | #include <linux/signal.h> |
26 | #include <linux/sched.h> | ||
27 | #include <linux/ioport.h> | 26 | #include <linux/ioport.h> |
28 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
29 | #include <linux/init.h> | 28 | #include <linux/init.h> |
diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c index 3f876fb75469..4677152142d9 100644 --- a/drivers/scsi/arm/eesox.c +++ b/drivers/scsi/arm/eesox.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/string.h> | 28 | #include <linux/string.h> |
29 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
32 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
33 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index e05f0c2fc912..2969cc0ff259 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | #include <linux/string.h> | 40 | #include <linux/string.h> |
41 | #include <linux/ioport.h> | 41 | #include <linux/ioport.h> |
42 | #include <linux/sched.h> | ||
43 | #include <linux/proc_fs.h> | 42 | #include <linux/proc_fs.h> |
44 | #include <linux/delay.h> | 43 | #include <linux/delay.h> |
45 | #include <linux/bitops.h> | 44 | #include <linux/bitops.h> |
diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c index d806b024c3bd..c21b8392c928 100644 --- a/drivers/scsi/arm/oak.c +++ b/drivers/scsi/arm/oak.c | |||
@@ -6,7 +6,6 @@ | |||
6 | 6 | ||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/signal.h> | 8 | #include <linux/signal.h> |
9 | #include <linux/sched.h> | ||
10 | #include <linux/ioport.h> | 9 | #include <linux/ioport.h> |
11 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
12 | #include <linux/blkdev.h> | 11 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c index ce159c15bc86..f9cd20bfb958 100644 --- a/drivers/scsi/arm/powertec.c +++ b/drivers/scsi/arm/powertec.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/string.h> | 13 | #include <linux/string.h> |
14 | #include <linux/ioport.h> | 14 | #include <linux/ioport.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/proc_fs.h> | 15 | #include <linux/proc_fs.h> |
17 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
18 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index dfb1bcfae82e..642de7b2b7a2 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c | |||
@@ -86,7 +86,6 @@ | |||
86 | #include <linux/delay.h> | 86 | #include <linux/delay.h> |
87 | #include <linux/mm.h> | 87 | #include <linux/mm.h> |
88 | #include <linux/blkdev.h> | 88 | #include <linux/blkdev.h> |
89 | #include <linux/sched.h> | ||
90 | #include <linux/interrupt.h> | 89 | #include <linux/interrupt.h> |
91 | #include <linux/init.h> | 90 | #include <linux/init.h> |
92 | #include <linux/nvram.h> | 91 | #include <linux/nvram.h> |
diff --git a/drivers/scsi/bvme6000.c b/drivers/scsi/bvme6000.c index 2958b8c2bfb7..599b400a3c43 100644 --- a/drivers/scsi/bvme6000.c +++ b/drivers/scsi/bvme6000.c | |||
@@ -6,7 +6,6 @@ | |||
6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
7 | #include <linux/mm.h> | 7 | #include <linux/mm.h> |
8 | #include <linux/blkdev.h> | 8 | #include <linux/blkdev.h> |
9 | #include <linux/sched.h> | ||
10 | #include <linux/zorro.h> | 9 | #include <linux/zorro.h> |
11 | 10 | ||
12 | #include <asm/setup.h> | 11 | #include <asm/setup.h> |
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index d02759f13469..2a2cc6cf1182 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/sched.h> | ||
15 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
16 | #include <linux/major.h> | 15 | #include <linux/major.h> |
17 | #include <linux/string.h> | 16 | #include <linux/string.h> |
diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c index 54756722dd5f..9d52e45c7d36 100644 --- a/drivers/scsi/dtc.c +++ b/drivers/scsi/dtc.c | |||
@@ -75,7 +75,6 @@ | |||
75 | #include <asm/system.h> | 75 | #include <asm/system.h> |
76 | #include <linux/module.h> | 76 | #include <linux/module.h> |
77 | #include <linux/signal.h> | 77 | #include <linux/signal.h> |
78 | #include <linux/sched.h> | ||
79 | #include <linux/blkdev.h> | 78 | #include <linux/blkdev.h> |
80 | #include <linux/delay.h> | 79 | #include <linux/delay.h> |
81 | #include <linux/stat.h> | 80 | #include <linux/stat.h> |
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c index 2dbb66d2f0a7..f33ad01064a9 100644 --- a/drivers/scsi/eata_pio.c +++ b/drivers/scsi/eata_pio.c | |||
@@ -48,7 +48,6 @@ | |||
48 | 48 | ||
49 | #include <linux/module.h> | 49 | #include <linux/module.h> |
50 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
51 | #include <linux/sched.h> | ||
52 | #include <linux/string.h> | 51 | #include <linux/string.h> |
53 | #include <linux/ioport.h> | 52 | #include <linux/ioport.h> |
54 | #include <linux/slab.h> | 53 | #include <linux/slab.h> |
diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index cdd893bb4e28..880f70d24e65 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c | |||
@@ -103,7 +103,6 @@ | |||
103 | #include <asm/system.h> | 103 | #include <asm/system.h> |
104 | #include <asm/io.h> | 104 | #include <asm/io.h> |
105 | #include <linux/signal.h> | 105 | #include <linux/signal.h> |
106 | #include <linux/sched.h> | ||
107 | #include <linux/blkdev.h> | 106 | #include <linux/blkdev.h> |
108 | #include "scsi.h" | 107 | #include "scsi.h" |
109 | #include <scsi/scsi_host.h> | 108 | #include <scsi/scsi_host.h> |
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index a1992928e671..8c81cec85298 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -387,7 +387,6 @@ | |||
387 | #include <linux/ctype.h> | 387 | #include <linux/ctype.h> |
388 | #include <linux/ioport.h> | 388 | #include <linux/ioport.h> |
389 | #include <linux/delay.h> | 389 | #include <linux/delay.h> |
390 | #include <linux/sched.h> | ||
391 | #include <linux/interrupt.h> | 390 | #include <linux/interrupt.h> |
392 | #include <linux/in.h> | 391 | #include <linux/in.h> |
393 | #include <linux/proc_fs.h> | 392 | #include <linux/proc_fs.h> |
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c index 2f6c1137a6e5..37741e9b5c3b 100644 --- a/drivers/scsi/gvp11.c +++ b/drivers/scsi/gvp11.c | |||
@@ -1,7 +1,6 @@ | |||
1 | #include <linux/types.h> | 1 | #include <linux/types.h> |
2 | #include <linux/mm.h> | 2 | #include <linux/mm.h> |
3 | #include <linux/blkdev.h> | 3 | #include <linux/blkdev.h> |
4 | #include <linux/sched.h> | ||
5 | #include <linux/init.h> | 4 | #include <linux/init.h> |
6 | #include <linux/interrupt.h> | 5 | #include <linux/interrupt.h> |
7 | 6 | ||
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c index e28260f05d6b..4368ca0e8270 100644 --- a/drivers/scsi/ibmvscsi/ibmvstgt.c +++ b/drivers/scsi/ibmvscsi/ibmvstgt.c | |||
@@ -580,7 +580,7 @@ static int crq_queue_create(struct crq_queue *queue, struct srp_target *target) | |||
580 | } | 580 | } |
581 | 581 | ||
582 | err = request_irq(vport->dma_dev->irq, &ibmvstgt_interrupt, | 582 | err = request_irq(vport->dma_dev->irq, &ibmvstgt_interrupt, |
583 | SA_INTERRUPT, "ibmvstgt", target); | 583 | IRQF_DISABLED, "ibmvstgt", target); |
584 | if (err) | 584 | if (err) |
585 | goto req_irq_failed; | 585 | goto req_irq_failed; |
586 | 586 | ||
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index d561663fb4e4..7e7635ca78f1 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c | |||
@@ -123,7 +123,6 @@ | |||
123 | #include <linux/string.h> | 123 | #include <linux/string.h> |
124 | #include <linux/interrupt.h> | 124 | #include <linux/interrupt.h> |
125 | #include <linux/ioport.h> | 125 | #include <linux/ioport.h> |
126 | #include <linux/sched.h> | ||
127 | #include <linux/slab.h> | 126 | #include <linux/slab.h> |
128 | #include <linux/jiffies.h> | 127 | #include <linux/jiffies.h> |
129 | #include <linux/dma-mapping.h> | 128 | #include <linux/dma-mapping.h> |
diff --git a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c index 2aae1b081fcf..5c32a69e41ba 100644 --- a/drivers/scsi/lasi700.c +++ b/drivers/scsi/lasi700.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/stat.h> | 38 | #include <linux/stat.h> |
39 | #include <linux/mm.h> | 39 | #include <linux/mm.h> |
40 | #include <linux/blkdev.h> | 40 | #include <linux/blkdev.h> |
41 | #include <linux/sched.h> | ||
42 | #include <linux/ioport.h> | 41 | #include <linux/ioport.h> |
43 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
44 | 43 | ||
diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index a942a21dd87e..cdbcaa5ad6cf 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c | |||
@@ -36,7 +36,6 @@ | |||
36 | 36 | ||
37 | #include <linux/module.h> | 37 | #include <linux/module.h> |
38 | #include <linux/signal.h> | 38 | #include <linux/signal.h> |
39 | #include <linux/sched.h> | ||
40 | #include <linux/ioport.h> | 39 | #include <linux/ioport.h> |
41 | #include <linux/init.h> | 40 | #include <linux/init.h> |
42 | #include <linux/blkdev.h> | 41 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c index 1ddd7a11a958..be41aadccae5 100644 --- a/drivers/scsi/mvme147.c +++ b/drivers/scsi/mvme147.c | |||
@@ -1,7 +1,6 @@ | |||
1 | #include <linux/types.h> | 1 | #include <linux/types.h> |
2 | #include <linux/mm.h> | 2 | #include <linux/mm.h> |
3 | #include <linux/blkdev.h> | 3 | #include <linux/blkdev.h> |
4 | #include <linux/sched.h> | ||
5 | #include <linux/interrupt.h> | 4 | #include <linux/interrupt.h> |
6 | 5 | ||
7 | #include <asm/page.h> | 6 | #include <asm/page.h> |
diff --git a/drivers/scsi/mvme16x.c b/drivers/scsi/mvme16x.c index 890e9e232dab..575fe6f7e0ec 100644 --- a/drivers/scsi/mvme16x.c +++ b/drivers/scsi/mvme16x.c | |||
@@ -6,7 +6,6 @@ | |||
6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
7 | #include <linux/mm.h> | 7 | #include <linux/mm.h> |
8 | #include <linux/blkdev.h> | 8 | #include <linux/blkdev.h> |
9 | #include <linux/sched.h> | ||
10 | 9 | ||
11 | #include <asm/page.h> | 10 | #include <asm/page.h> |
12 | #include <asm/pgtable.h> | 11 | #include <asm/pgtable.h> |
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index 7c13f6f4a4c6..f6f561d26bf0 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
32 | #include <linux/string.h> | 31 | #include <linux/string.h> |
33 | #include <linux/timer.h> | 32 | #include <linux/timer.h> |
diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c index 1434209a8ac5..ee5965659971 100644 --- a/drivers/scsi/pas16.c +++ b/drivers/scsi/pas16.c | |||
@@ -116,7 +116,6 @@ | |||
116 | #include <asm/system.h> | 116 | #include <asm/system.h> |
117 | #include <linux/signal.h> | 117 | #include <linux/signal.h> |
118 | #include <linux/proc_fs.h> | 118 | #include <linux/proc_fs.h> |
119 | #include <linux/sched.h> | ||
120 | #include <asm/io.h> | 119 | #include <asm/io.h> |
121 | #include <asm/dma.h> | 120 | #include <asm/dma.h> |
122 | #include <linux/blkdev.h> | 121 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index aad362ba02e0..370802d24acd 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/module.h> | 37 | #include <linux/module.h> |
38 | #include <linux/init.h> | 38 | #include <linux/init.h> |
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | #include <linux/sched.h> | ||
41 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
42 | #include <linux/string.h> | 41 | #include <linux/string.h> |
43 | #include <linux/ioport.h> | 42 | #include <linux/ioport.h> |
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index a1c5f265069f..4b82b2021981 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
37 | #include <linux/sched.h> | ||
38 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
39 | #include <linux/string.h> | 38 | #include <linux/string.h> |
40 | #include <linux/ioport.h> | 39 | #include <linux/ioport.h> |
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index e16fe361436e..c6f8c6e65e05 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/sched.h> | ||
35 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
36 | #include <linux/string.h> | 35 | #include <linux/string.h> |
37 | #include <linux/timer.h> | 36 | #include <linux/timer.h> |
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index 9d431fe7f47f..697cfb76c3a4 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
37 | #include <linux/sched.h> | ||
38 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
39 | #include <linux/string.h> | 38 | #include <linux/string.h> |
40 | #include <linux/ioport.h> | 39 | #include <linux/ioport.h> |
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 5b458d2478f7..ffe75c431b25 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c | |||
@@ -54,7 +54,6 @@ | |||
54 | #include <linux/init.h> | 54 | #include <linux/init.h> |
55 | #include <linux/interrupt.h> | 55 | #include <linux/interrupt.h> |
56 | #include <linux/kernel.h> | 56 | #include <linux/kernel.h> |
57 | #include <linux/sched.h> | ||
58 | #include <linux/slab.h> | 57 | #include <linux/slab.h> |
59 | #include <linux/string.h> | 58 | #include <linux/string.h> |
60 | #include <linux/ioport.h> | 59 | #include <linux/ioport.h> |
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 1548d42a3b43..6777e8a69153 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c | |||
@@ -341,7 +341,6 @@ | |||
341 | #include <linux/ioport.h> | 341 | #include <linux/ioport.h> |
342 | #include <linux/delay.h> | 342 | #include <linux/delay.h> |
343 | #include <linux/timer.h> | 343 | #include <linux/timer.h> |
344 | #include <linux/sched.h> | ||
345 | #include <linux/pci.h> | 344 | #include <linux/pci.h> |
346 | #include <linux/proc_fs.h> | 345 | #include <linux/proc_fs.h> |
347 | #include <linux/stat.h> | 346 | #include <linux/stat.h> |
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 81fb7bd44f01..0bfddf893ed0 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c | |||
@@ -1270,7 +1270,7 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev, | |||
1270 | INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc); | 1270 | INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc); |
1271 | 1271 | ||
1272 | ret = request_irq(pdev->irq, qla4xxx_intr_handler, | 1272 | ret = request_irq(pdev->irq, qla4xxx_intr_handler, |
1273 | SA_INTERRUPT|SA_SHIRQ, "qla4xxx", ha); | 1273 | IRQF_DISABLED | IRQF_SHARED, "qla4xxx", ha); |
1274 | if (ret) { | 1274 | if (ret) { |
1275 | dev_warn(&ha->pdev->dev, "Failed to reserve interrupt %d" | 1275 | dev_warn(&ha->pdev->dev, "Failed to reserve interrupt %d" |
1276 | " already in use.\n", pdev->irq); | 1276 | " already in use.\n", pdev->irq); |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index f33e2eb9f1b9..1c89ee3e69ba 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <linux/module.h> | 40 | #include <linux/module.h> |
41 | #include <linux/moduleparam.h> | 41 | #include <linux/moduleparam.h> |
42 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
43 | #include <linux/sched.h> | ||
44 | #include <linux/timer.h> | 43 | #include <linux/timer.h> |
45 | #include <linux/string.h> | 44 | #include <linux/string.h> |
46 | #include <linux/slab.h> | 45 | #include <linux/slab.h> |
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 5adbbeedec38..3e2930b7ee23 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | 29 | ||
30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
31 | #include <linux/sched.h> | ||
32 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
33 | #include <linux/timer.h> | 32 | #include <linux/timer.h> |
34 | #include <linux/types.h> | 33 | #include <linux/types.h> |
diff --git a/drivers/scsi/scsi_sysctl.c b/drivers/scsi/scsi_sysctl.c index 04d06c25132b..6cfaaa2d0c81 100644 --- a/drivers/scsi/scsi_sysctl.c +++ b/drivers/scsi/scsi_sysctl.c | |||
@@ -41,7 +41,7 @@ static struct ctl_table_header *scsi_table_header; | |||
41 | 41 | ||
42 | int __init scsi_init_sysctl(void) | 42 | int __init scsi_init_sysctl(void) |
43 | { | 43 | { |
44 | scsi_table_header = register_sysctl_table(scsi_root_table, 1); | 44 | scsi_table_header = register_sysctl_table(scsi_root_table); |
45 | if (!scsi_table_header) | 45 | if (!scsi_table_header) |
46 | return -ENOMEM; | 46 | return -ENOMEM; |
47 | return 0; | 47 | return 0; |
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 3571ce8934e7..0d3c10f2134c 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/sched.h> /* workqueue stuff, HZ */ | ||
30 | #include <scsi/scsi_device.h> | 29 | #include <scsi/scsi_device.h> |
31 | #include <scsi/scsi_host.h> | 30 | #include <scsi/scsi_host.h> |
32 | #include <scsi/scsi_transport.h> | 31 | #include <scsi/scsi_transport.h> |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index b781a90d6699..3f048bd6326d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/mm.h> | 38 | #include <linux/mm.h> |
40 | #include <linux/bio.h> | 39 | #include <linux/bio.h> |
41 | #include <linux/genhd.h> | 40 | #include <linux/genhd.h> |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 89e9b36b1788..1857d68e7195 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/mm.h> | 38 | #include <linux/mm.h> |
40 | #include <linux/bio.h> | 39 | #include <linux/bio.h> |
41 | #include <linux/string.h> | 40 | #include <linux/string.h> |
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index 0578ba42718b..e1589f91706a 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c | |||
@@ -1,5 +1,4 @@ | |||
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include <linux/sched.h> | ||
3 | #include <linux/mm.h> | 2 | #include <linux/mm.h> |
4 | #include <linux/fs.h> | 3 | #include <linux/fs.h> |
5 | #include <linux/errno.h> | 4 | #include <linux/errno.h> |
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index ba6bcdaf2a6a..69be1324b114 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/time.h> | 20 | #include <linux/time.h> |
22 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
23 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index 69ee3e4a820e..5e46d842c6f9 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c | |||
@@ -58,7 +58,6 @@ | |||
58 | 58 | ||
59 | #include <linux/module.h> | 59 | #include <linux/module.h> |
60 | #include <linux/signal.h> | 60 | #include <linux/signal.h> |
61 | #include <linux/sched.h> | ||
62 | #include <linux/ioport.h> | 61 | #include <linux/ioport.h> |
63 | #include <linux/init.h> | 62 | #include <linux/init.h> |
64 | #include <linux/blkdev.h> | 63 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/sun3_scsi_vme.c b/drivers/scsi/sun3_scsi_vme.c index bb0c9fd99e68..7cb4a31453e6 100644 --- a/drivers/scsi/sun3_scsi_vme.c +++ b/drivers/scsi/sun3_scsi_vme.c | |||
@@ -20,7 +20,6 @@ | |||
20 | 20 | ||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/signal.h> | 22 | #include <linux/signal.h> |
23 | #include <linux/sched.h> | ||
24 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
26 | #include <linux/blkdev.h> | 25 | #include <linux/blkdev.h> |
diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c index 32c883f1efa1..2ca950582bc3 100644 --- a/drivers/scsi/sym53c416.c +++ b/drivers/scsi/sym53c416.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/string.h> | 33 | #include <linux/string.h> |
34 | #include <linux/ioport.h> | 34 | #include <linux/ioport.h> |
35 | #include <linux/sched.h> | ||
36 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
37 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
38 | #include <linux/proc_fs.h> | 37 | #include <linux/proc_fs.h> |
diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c index 0b7a70f61e0d..248d60b8d899 100644 --- a/drivers/scsi/t128.c +++ b/drivers/scsi/t128.c | |||
@@ -108,7 +108,6 @@ | |||
108 | 108 | ||
109 | #include <asm/system.h> | 109 | #include <asm/system.h> |
110 | #include <linux/signal.h> | 110 | #include <linux/signal.h> |
111 | #include <linux/sched.h> | ||
112 | #include <linux/io.h> | 111 | #include <linux/io.h> |
113 | #include <linux/blkdev.h> | 112 | #include <linux/blkdev.h> |
114 | #include <linux/interrupt.h> | 113 | #include <linux/interrupt.h> |
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c index fa5382e354be..a583e89238fc 100644 --- a/drivers/scsi/tmscsim.c +++ b/drivers/scsi/tmscsim.c | |||
@@ -221,7 +221,6 @@ | |||
221 | #include <linux/module.h> | 221 | #include <linux/module.h> |
222 | #include <linux/delay.h> | 222 | #include <linux/delay.h> |
223 | #include <linux/signal.h> | 223 | #include <linux/signal.h> |
224 | #include <linux/sched.h> | ||
225 | #include <linux/errno.h> | 224 | #include <linux/errno.h> |
226 | #include <linux/kernel.h> | 225 | #include <linux/kernel.h> |
227 | #include <linux/ioport.h> | 226 | #include <linux/ioport.h> |
diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c index 2083454db511..835751600e93 100644 --- a/drivers/scsi/wd33c93.c +++ b/drivers/scsi/wd33c93.c | |||
@@ -73,7 +73,6 @@ | |||
73 | 73 | ||
74 | #include <linux/module.h> | 74 | #include <linux/module.h> |
75 | 75 | ||
76 | #include <linux/sched.h> | ||
77 | #include <linux/string.h> | 76 | #include <linux/string.h> |
78 | #include <linux/delay.h> | 77 | #include <linux/delay.h> |
79 | #include <linux/init.h> | 78 | #include <linux/init.h> |
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 2964ca9df5a0..98ec86185328 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -364,6 +364,23 @@ serial_out(struct uart_8250_port *up, int offset, int value) | |||
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | static void | ||
368 | serial_out_sync(struct uart_8250_port *up, int offset, int value) | ||
369 | { | ||
370 | switch (up->port.iotype) { | ||
371 | case UPIO_MEM: | ||
372 | case UPIO_MEM32: | ||
373 | #ifdef CONFIG_SERIAL_8250_AU1X00 | ||
374 | case UPIO_AU: | ||
375 | #endif | ||
376 | serial_out(up, offset, value); | ||
377 | serial_in(up, UART_LCR); /* safe, no side-effects */ | ||
378 | break; | ||
379 | default: | ||
380 | serial_out(up, offset, value); | ||
381 | } | ||
382 | } | ||
383 | |||
367 | /* | 384 | /* |
368 | * We used to support using pause I/O for certain machines. We | 385 | * We used to support using pause I/O for certain machines. We |
369 | * haven't supported this for a while, but just in case it's badly | 386 | * haven't supported this for a while, but just in case it's badly |
@@ -1045,7 +1062,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) | |||
1045 | #endif | 1062 | #endif |
1046 | serial_outp(up, UART_MCR, save_mcr); | 1063 | serial_outp(up, UART_MCR, save_mcr); |
1047 | serial8250_clear_fifos(up); | 1064 | serial8250_clear_fifos(up); |
1048 | (void)serial_in(up, UART_RX); | 1065 | serial_in(up, UART_RX); |
1049 | if (up->capabilities & UART_CAP_UUE) | 1066 | if (up->capabilities & UART_CAP_UUE) |
1050 | serial_outp(up, UART_IER, UART_IER_UUE); | 1067 | serial_outp(up, UART_IER, UART_IER_UUE); |
1051 | else | 1068 | else |
@@ -1451,6 +1468,12 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up) | |||
1451 | serial_do_unlink(i, up); | 1468 | serial_do_unlink(i, up); |
1452 | } | 1469 | } |
1453 | 1470 | ||
1471 | /* Base timer interval for polling */ | ||
1472 | static inline int poll_timeout(int timeout) | ||
1473 | { | ||
1474 | return timeout > 6 ? (timeout / 2 - 2) : 1; | ||
1475 | } | ||
1476 | |||
1454 | /* | 1477 | /* |
1455 | * This function is used to handle ports that do not have an | 1478 | * This function is used to handle ports that do not have an |
1456 | * interrupt. This doesn't work very well for 16450's, but gives | 1479 | * interrupt. This doesn't work very well for 16450's, but gives |
@@ -1460,16 +1483,51 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up) | |||
1460 | static void serial8250_timeout(unsigned long data) | 1483 | static void serial8250_timeout(unsigned long data) |
1461 | { | 1484 | { |
1462 | struct uart_8250_port *up = (struct uart_8250_port *)data; | 1485 | struct uart_8250_port *up = (struct uart_8250_port *)data; |
1463 | unsigned int timeout; | ||
1464 | unsigned int iir; | 1486 | unsigned int iir; |
1465 | 1487 | ||
1466 | iir = serial_in(up, UART_IIR); | 1488 | iir = serial_in(up, UART_IIR); |
1467 | if (!(iir & UART_IIR_NO_INT)) | 1489 | if (!(iir & UART_IIR_NO_INT)) |
1468 | serial8250_handle_port(up); | 1490 | serial8250_handle_port(up); |
1491 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); | ||
1492 | } | ||
1493 | |||
1494 | static void serial8250_backup_timeout(unsigned long data) | ||
1495 | { | ||
1496 | struct uart_8250_port *up = (struct uart_8250_port *)data; | ||
1497 | unsigned int iir, ier = 0; | ||
1498 | |||
1499 | /* | ||
1500 | * Must disable interrupts or else we risk racing with the interrupt | ||
1501 | * based handler. | ||
1502 | */ | ||
1503 | if (is_real_interrupt(up->port.irq)) { | ||
1504 | ier = serial_in(up, UART_IER); | ||
1505 | serial_out(up, UART_IER, 0); | ||
1506 | } | ||
1469 | 1507 | ||
1470 | timeout = up->port.timeout; | 1508 | iir = serial_in(up, UART_IIR); |
1471 | timeout = timeout > 6 ? (timeout / 2 - 2) : 1; | 1509 | |
1472 | mod_timer(&up->timer, jiffies + timeout); | 1510 | /* |
1511 | * This should be a safe test for anyone who doesn't trust the | ||
1512 | * IIR bits on their UART, but it's specifically designed for | ||
1513 | * the "Diva" UART used on the management processor on many HP | ||
1514 | * ia64 and parisc boxes. | ||
1515 | */ | ||
1516 | if ((iir & UART_IIR_NO_INT) && (up->ier & UART_IER_THRI) && | ||
1517 | (!uart_circ_empty(&up->port.info->xmit) || up->port.x_char) && | ||
1518 | (serial_in(up, UART_LSR) & UART_LSR_THRE)) { | ||
1519 | iir &= ~(UART_IIR_ID | UART_IIR_NO_INT); | ||
1520 | iir |= UART_IIR_THRI; | ||
1521 | } | ||
1522 | |||
1523 | if (!(iir & UART_IIR_NO_INT)) | ||
1524 | serial8250_handle_port(up); | ||
1525 | |||
1526 | if (is_real_interrupt(up->port.irq)) | ||
1527 | serial_out(up, UART_IER, ier); | ||
1528 | |||
1529 | /* Standard timer interval plus 0.2s to keep the port running */ | ||
1530 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout) + HZ/5); | ||
1473 | } | 1531 | } |
1474 | 1532 | ||
1475 | static unsigned int serial8250_tx_empty(struct uart_port *port) | 1533 | static unsigned int serial8250_tx_empty(struct uart_port *port) |
@@ -1540,6 +1598,37 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state) | |||
1540 | spin_unlock_irqrestore(&up->port.lock, flags); | 1598 | spin_unlock_irqrestore(&up->port.lock, flags); |
1541 | } | 1599 | } |
1542 | 1600 | ||
1601 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) | ||
1602 | |||
1603 | /* | ||
1604 | * Wait for transmitter & holding register to empty | ||
1605 | */ | ||
1606 | static inline void wait_for_xmitr(struct uart_8250_port *up, int bits) | ||
1607 | { | ||
1608 | unsigned int status, tmout = 10000; | ||
1609 | |||
1610 | /* Wait up to 10ms for the character(s) to be sent. */ | ||
1611 | do { | ||
1612 | status = serial_in(up, UART_LSR); | ||
1613 | |||
1614 | if (status & UART_LSR_BI) | ||
1615 | up->lsr_break_flag = UART_LSR_BI; | ||
1616 | |||
1617 | if (--tmout == 0) | ||
1618 | break; | ||
1619 | udelay(1); | ||
1620 | } while ((status & bits) != bits); | ||
1621 | |||
1622 | /* Wait up to 1s for flow control if necessary */ | ||
1623 | if (up->port.flags & UPF_CONS_FLOW) { | ||
1624 | tmout = 1000000; | ||
1625 | while (!(serial_in(up, UART_MSR) & UART_MSR_CTS) && --tmout) { | ||
1626 | udelay(1); | ||
1627 | touch_nmi_watchdog(); | ||
1628 | } | ||
1629 | } | ||
1630 | } | ||
1631 | |||
1543 | static int serial8250_startup(struct uart_port *port) | 1632 | static int serial8250_startup(struct uart_port *port) |
1544 | { | 1633 | { |
1545 | struct uart_8250_port *up = (struct uart_8250_port *)port; | 1634 | struct uart_8250_port *up = (struct uart_8250_port *)port; |
@@ -1613,18 +1702,50 @@ static int serial8250_startup(struct uart_port *port) | |||
1613 | serial_outp(up, UART_LCR, 0); | 1702 | serial_outp(up, UART_LCR, 0); |
1614 | } | 1703 | } |
1615 | 1704 | ||
1705 | if (is_real_interrupt(up->port.irq)) { | ||
1706 | /* | ||
1707 | * Test for UARTs that do not reassert THRE when the | ||
1708 | * transmitter is idle and the interrupt has already | ||
1709 | * been cleared. Real 16550s should always reassert | ||
1710 | * this interrupt whenever the transmitter is idle and | ||
1711 | * the interrupt is enabled. Delays are necessary to | ||
1712 | * allow register changes to become visible. | ||
1713 | */ | ||
1714 | spin_lock_irqsave(&up->port.lock, flags); | ||
1715 | |||
1716 | wait_for_xmitr(up, UART_LSR_THRE); | ||
1717 | serial_out_sync(up, UART_IER, UART_IER_THRI); | ||
1718 | udelay(1); /* allow THRE to set */ | ||
1719 | serial_in(up, UART_IIR); | ||
1720 | serial_out(up, UART_IER, 0); | ||
1721 | serial_out_sync(up, UART_IER, UART_IER_THRI); | ||
1722 | udelay(1); /* allow a working UART time to re-assert THRE */ | ||
1723 | iir = serial_in(up, UART_IIR); | ||
1724 | serial_out(up, UART_IER, 0); | ||
1725 | |||
1726 | spin_unlock_irqrestore(&up->port.lock, flags); | ||
1727 | |||
1728 | /* | ||
1729 | * If the interrupt is not reasserted, setup a timer to | ||
1730 | * kick the UART on a regular basis. | ||
1731 | */ | ||
1732 | if (iir & UART_IIR_NO_INT) { | ||
1733 | pr_debug("ttyS%d - using backup timer\n", port->line); | ||
1734 | up->timer.function = serial8250_backup_timeout; | ||
1735 | up->timer.data = (unsigned long)up; | ||
1736 | mod_timer(&up->timer, jiffies + | ||
1737 | poll_timeout(up->port.timeout) + HZ/5); | ||
1738 | } | ||
1739 | } | ||
1740 | |||
1616 | /* | 1741 | /* |
1617 | * If the "interrupt" for this port doesn't correspond with any | 1742 | * If the "interrupt" for this port doesn't correspond with any |
1618 | * hardware interrupt, we use a timer-based system. The original | 1743 | * hardware interrupt, we use a timer-based system. The original |
1619 | * driver used to do this with IRQ0. | 1744 | * driver used to do this with IRQ0. |
1620 | */ | 1745 | */ |
1621 | if (!is_real_interrupt(up->port.irq)) { | 1746 | if (!is_real_interrupt(up->port.irq)) { |
1622 | unsigned int timeout = up->port.timeout; | ||
1623 | |||
1624 | timeout = timeout > 6 ? (timeout / 2 - 2) : 1; | ||
1625 | |||
1626 | up->timer.data = (unsigned long)up; | 1747 | up->timer.data = (unsigned long)up; |
1627 | mod_timer(&up->timer, jiffies + timeout); | 1748 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); |
1628 | } else { | 1749 | } else { |
1629 | retval = serial_link_irq_chain(up); | 1750 | retval = serial_link_irq_chain(up); |
1630 | if (retval) | 1751 | if (retval) |
@@ -1740,9 +1861,9 @@ static void serial8250_shutdown(struct uart_port *port) | |||
1740 | */ | 1861 | */ |
1741 | (void) serial_in(up, UART_RX); | 1862 | (void) serial_in(up, UART_RX); |
1742 | 1863 | ||
1743 | if (!is_real_interrupt(up->port.irq)) | 1864 | del_timer_sync(&up->timer); |
1744 | del_timer_sync(&up->timer); | 1865 | up->timer.function = serial8250_timeout; |
1745 | else | 1866 | if (is_real_interrupt(up->port.irq)) |
1746 | serial_unlink_irq_chain(up); | 1867 | serial_unlink_irq_chain(up); |
1747 | } | 1868 | } |
1748 | 1869 | ||
@@ -2212,37 +2333,6 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev) | |||
2212 | 2333 | ||
2213 | #ifdef CONFIG_SERIAL_8250_CONSOLE | 2334 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
2214 | 2335 | ||
2215 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) | ||
2216 | |||
2217 | /* | ||
2218 | * Wait for transmitter & holding register to empty | ||
2219 | */ | ||
2220 | static inline void wait_for_xmitr(struct uart_8250_port *up, int bits) | ||
2221 | { | ||
2222 | unsigned int status, tmout = 10000; | ||
2223 | |||
2224 | /* Wait up to 10ms for the character(s) to be sent. */ | ||
2225 | do { | ||
2226 | status = serial_in(up, UART_LSR); | ||
2227 | |||
2228 | if (status & UART_LSR_BI) | ||
2229 | up->lsr_break_flag = UART_LSR_BI; | ||
2230 | |||
2231 | if (--tmout == 0) | ||
2232 | break; | ||
2233 | udelay(1); | ||
2234 | } while ((status & bits) != bits); | ||
2235 | |||
2236 | /* Wait up to 1s for flow control if necessary */ | ||
2237 | if (up->port.flags & UPF_CONS_FLOW) { | ||
2238 | tmout = 1000000; | ||
2239 | while (!(serial_in(up, UART_MSR) & UART_MSR_CTS) && --tmout) { | ||
2240 | udelay(1); | ||
2241 | touch_nmi_watchdog(); | ||
2242 | } | ||
2243 | } | ||
2244 | } | ||
2245 | |||
2246 | static void serial8250_console_putchar(struct uart_port *port, int ch) | 2336 | static void serial8250_console_putchar(struct uart_port *port, int ch) |
2247 | { | 2337 | { |
2248 | struct uart_8250_port *up = (struct uart_8250_port *)port; | 2338 | struct uart_8250_port *up = (struct uart_8250_port *)port; |
diff --git a/drivers/serial/8250_acorn.c b/drivers/serial/8250_acorn.c index ef8cc8a70c60..562ba745a044 100644 --- a/drivers/serial/8250_acorn.c +++ b/drivers/serial/8250_acorn.c | |||
@@ -47,11 +47,10 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
47 | unsigned long bus_addr; | 47 | unsigned long bus_addr; |
48 | unsigned int i; | 48 | unsigned int i; |
49 | 49 | ||
50 | info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL); | 50 | info = kzalloc(sizeof(struct serial_card_info), GFP_KERNEL); |
51 | if (!info) | 51 | if (!info) |
52 | return -ENOMEM; | 52 | return -ENOMEM; |
53 | 53 | ||
54 | memset(info, 0, sizeof(struct serial_card_info)); | ||
55 | info->num_ports = type->num_ports; | 54 | info->num_ports = type->num_ports; |
56 | 55 | ||
57 | bus_addr = ecard_resource_start(ec, type->type); | 56 | bus_addr = ecard_resource_start(ec, type->type); |
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index a2dac378bda9..6d7d616e9ccd 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/string.h> | 19 | #include <linux/string.h> |
21 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
22 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
@@ -1628,7 +1627,7 @@ pciserial_init_ports(struct pci_dev *dev, struct pciserial_board *board) | |||
1628 | nr_ports = rc; | 1627 | nr_ports = rc; |
1629 | } | 1628 | } |
1630 | 1629 | ||
1631 | priv = kmalloc(sizeof(struct serial_private) + | 1630 | priv = kzalloc(sizeof(struct serial_private) + |
1632 | sizeof(unsigned int) * nr_ports, | 1631 | sizeof(unsigned int) * nr_ports, |
1633 | GFP_KERNEL); | 1632 | GFP_KERNEL); |
1634 | if (!priv) { | 1633 | if (!priv) { |
@@ -1636,9 +1635,6 @@ pciserial_init_ports(struct pci_dev *dev, struct pciserial_board *board) | |||
1636 | goto err_deinit; | 1635 | goto err_deinit; |
1637 | } | 1636 | } |
1638 | 1637 | ||
1639 | memset(priv, 0, sizeof(struct serial_private) + | ||
1640 | sizeof(unsigned int) * nr_ports); | ||
1641 | |||
1642 | priv->dev = dev; | 1638 | priv->dev = dev; |
1643 | priv->quirk = quirk; | 1639 | priv->quirk = quirk; |
1644 | 1640 | ||
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c index d3d6b82706b5..cde5db44abf6 100644 --- a/drivers/serial/8250_pnp.c +++ b/drivers/serial/8250_pnp.c | |||
@@ -450,11 +450,11 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) | |||
450 | port.dev = &dev->dev; | 450 | port.dev = &dev->dev; |
451 | 451 | ||
452 | line = serial8250_register_port(&port); | 452 | line = serial8250_register_port(&port); |
453 | if (line < 0) | ||
454 | return -ENODEV; | ||
453 | 455 | ||
454 | if (line >= 0) | 456 | pnp_set_drvdata(dev, (void *)((long)line + 1)); |
455 | pnp_set_drvdata(dev, (void *)((long)line + 1)); | 457 | return 0; |
456 | return line >= 0 ? 0 : -ENODEV; | ||
457 | |||
458 | } | 458 | } |
459 | 459 | ||
460 | static void __devexit serial_pnp_remove(struct pnp_dev *dev) | 460 | static void __devexit serial_pnp_remove(struct pnp_dev *dev) |
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 5cc6b91f8408..e8dd71df9165 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -686,6 +686,22 @@ config SERIAL_SH_SCI_CONSOLE | |||
686 | depends on SERIAL_SH_SCI=y | 686 | depends on SERIAL_SH_SCI=y |
687 | select SERIAL_CORE_CONSOLE | 687 | select SERIAL_CORE_CONSOLE |
688 | 688 | ||
689 | config SERIAL_PNX8XXX | ||
690 | bool "Enable PNX8XXX SoCs' UART Support" | ||
691 | depends on MIPS && SOC_PNX8550 | ||
692 | select SERIAL_CORE | ||
693 | help | ||
694 | If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330 | ||
695 | and you want to use serial ports, say Y. Otherwise, say N. | ||
696 | |||
697 | config SERIAL_PNX8XXX_CONSOLE | ||
698 | bool "Enable PNX8XX0 serial console" | ||
699 | depends on SERIAL_PNX8XXX | ||
700 | select SERIAL_CORE_CONSOLE | ||
701 | help | ||
702 | If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330 | ||
703 | and you want to use serial console, say Y. Otherwise, say N. | ||
704 | |||
689 | config SERIAL_CORE | 705 | config SERIAL_CORE |
690 | tristate | 706 | tristate |
691 | 707 | ||
@@ -999,4 +1015,14 @@ config SERIAL_NETX_CONSOLE | |||
999 | If you have enabled the serial port on the Motorola IMX | 1015 | If you have enabled the serial port on the Motorola IMX |
1000 | CPU you can make it the console by answering Y to this option. | 1016 | CPU you can make it the console by answering Y to this option. |
1001 | 1017 | ||
1018 | config SERIAL_OF_PLATFORM | ||
1019 | tristate "Serial port on Open Firmware platform bus" | ||
1020 | depends on PPC_OF | ||
1021 | depends on SERIAL_8250 | ||
1022 | help | ||
1023 | If you have a PowerPC based system that has serial ports | ||
1024 | on a platform specific bus, you should enable this option. | ||
1025 | Currently, only 8250 compatible ports are supported, but | ||
1026 | others can easily be added. | ||
1027 | |||
1002 | endmenu | 1028 | endmenu |
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index df3632cd7df9..6b3560c5749a 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile | |||
@@ -25,6 +25,7 @@ obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o | |||
25 | obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o | 25 | obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o |
26 | obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o | 26 | obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o |
27 | obj-$(CONFIG_SERIAL_PXA) += pxa.o | 27 | obj-$(CONFIG_SERIAL_PXA) += pxa.o |
28 | obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o | ||
28 | obj-$(CONFIG_SERIAL_SA1100) += sa1100.o | 29 | obj-$(CONFIG_SERIAL_SA1100) += sa1100.o |
29 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o | 30 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o |
30 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o | 31 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o |
@@ -58,3 +59,4 @@ obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o | |||
58 | obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o | 59 | obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o |
59 | obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o | 60 | obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o |
60 | obj-$(CONFIG_SERIAL_NETX) += netx-serial.o | 61 | obj-$(CONFIG_SERIAL_NETX) += netx-serial.o |
62 | obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o | ||
diff --git a/drivers/serial/icom.c b/drivers/serial/icom.c index 71e6a24d8c28..41431d0d5512 100644 --- a/drivers/serial/icom.c +++ b/drivers/serial/icom.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include <linux/signal.h> | 29 | #include <linux/signal.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/timer.h> | 30 | #include <linux/timer.h> |
32 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
33 | #include <linux/tty.h> | 32 | #include <linux/tty.h> |
@@ -1417,14 +1416,12 @@ static int __devinit icom_alloc_adapter(struct icom_adapter | |||
1417 | struct list_head *tmp; | 1416 | struct list_head *tmp; |
1418 | 1417 | ||
1419 | icom_adapter = (struct icom_adapter *) | 1418 | icom_adapter = (struct icom_adapter *) |
1420 | kmalloc(sizeof(struct icom_adapter), GFP_KERNEL); | 1419 | kzalloc(sizeof(struct icom_adapter), GFP_KERNEL); |
1421 | 1420 | ||
1422 | if (!icom_adapter) { | 1421 | if (!icom_adapter) { |
1423 | return -ENOMEM; | 1422 | return -ENOMEM; |
1424 | } | 1423 | } |
1425 | 1424 | ||
1426 | memset(icom_adapter, 0, sizeof(struct icom_adapter)); | ||
1427 | |||
1428 | list_for_each(tmp, &icom_adapter_head) { | 1425 | list_for_each(tmp, &icom_adapter_head) { |
1429 | cur_adapter_entry = | 1426 | cur_adapter_entry = |
1430 | list_entry(tmp, struct icom_adapter, | 1427 | list_entry(tmp, struct icom_adapter, |
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c index 9cc0be932316..168073f12cec 100644 --- a/drivers/serial/ioc3_serial.c +++ b/drivers/serial/ioc3_serial.c | |||
@@ -2019,13 +2019,12 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd) | |||
2019 | 2019 | ||
2020 | DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd)); | 2020 | DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd)); |
2021 | 2021 | ||
2022 | card_ptr = kmalloc(sizeof(struct ioc3_card), GFP_KERNEL); | 2022 | card_ptr = kzalloc(sizeof(struct ioc3_card), GFP_KERNEL); |
2023 | if (!card_ptr) { | 2023 | if (!card_ptr) { |
2024 | printk(KERN_WARNING "ioc3_attach_one" | 2024 | printk(KERN_WARNING "ioc3_attach_one" |
2025 | ": unable to get memory for the IOC3\n"); | 2025 | ": unable to get memory for the IOC3\n"); |
2026 | return -ENOMEM; | 2026 | return -ENOMEM; |
2027 | } | 2027 | } |
2028 | memset(card_ptr, 0, sizeof(struct ioc3_card)); | ||
2029 | idd->data[is->id] = card_ptr; | 2028 | idd->data[is->id] = card_ptr; |
2030 | Submodule_slot = is->id; | 2029 | Submodule_slot = is->id; |
2031 | 2030 | ||
@@ -2040,13 +2039,12 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd) | |||
2040 | 2039 | ||
2041 | /* Create port structures for each port */ | 2040 | /* Create port structures for each port */ |
2042 | for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) { | 2041 | for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) { |
2043 | port = kmalloc(sizeof(struct ioc3_port), GFP_KERNEL); | 2042 | port = kzalloc(sizeof(struct ioc3_port), GFP_KERNEL); |
2044 | if (!port) { | 2043 | if (!port) { |
2045 | printk(KERN_WARNING | 2044 | printk(KERN_WARNING |
2046 | "IOC3 serial memory not available for port\n"); | 2045 | "IOC3 serial memory not available for port\n"); |
2047 | goto out4; | 2046 | goto out4; |
2048 | } | 2047 | } |
2049 | memset(port, 0, sizeof(struct ioc3_port)); | ||
2050 | spin_lock_init(&port->ip_lock); | 2048 | spin_lock_init(&port->ip_lock); |
2051 | 2049 | ||
2052 | /* we need to remember the previous ones, to point back to | 2050 | /* we need to remember the previous ones, to point back to |
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c index f540212e7409..0c179384fb0c 100644 --- a/drivers/serial/ioc4_serial.c +++ b/drivers/serial/ioc4_serial.c | |||
@@ -1076,13 +1076,12 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd) | |||
1076 | /* Create port structures for each port */ | 1076 | /* Create port structures for each port */ |
1077 | for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS; | 1077 | for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS; |
1078 | port_number++) { | 1078 | port_number++) { |
1079 | port = kmalloc(sizeof(struct ioc4_port), GFP_KERNEL); | 1079 | port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL); |
1080 | if (!port) { | 1080 | if (!port) { |
1081 | printk(KERN_WARNING | 1081 | printk(KERN_WARNING |
1082 | "IOC4 serial memory not available for port\n"); | 1082 | "IOC4 serial memory not available for port\n"); |
1083 | return -ENOMEM; | 1083 | return -ENOMEM; |
1084 | } | 1084 | } |
1085 | memset(port, 0, sizeof(struct ioc4_port)); | ||
1086 | spin_lock_init(&port->ip_lock); | 1085 | spin_lock_init(&port->ip_lock); |
1087 | 1086 | ||
1088 | /* we need to remember the previous ones, to point back to | 1087 | /* we need to remember the previous ones, to point back to |
@@ -2811,7 +2810,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd) | |||
2811 | (void *)serial)); | 2810 | (void *)serial)); |
2812 | 2811 | ||
2813 | /* Get memory for the new card */ | 2812 | /* Get memory for the new card */ |
2814 | control = kmalloc(sizeof(struct ioc4_control), GFP_KERNEL); | 2813 | control = kzalloc(sizeof(struct ioc4_control), GFP_KERNEL); |
2815 | 2814 | ||
2816 | if (!control) { | 2815 | if (!control) { |
2817 | printk(KERN_WARNING "ioc4_attach_one" | 2816 | printk(KERN_WARNING "ioc4_attach_one" |
@@ -2819,11 +2818,10 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd) | |||
2819 | ret = -ENOMEM; | 2818 | ret = -ENOMEM; |
2820 | goto out2; | 2819 | goto out2; |
2821 | } | 2820 | } |
2822 | memset(control, 0, sizeof(struct ioc4_control)); | ||
2823 | idd->idd_serial_data = control; | 2821 | idd->idd_serial_data = control; |
2824 | 2822 | ||
2825 | /* Allocate the soft structure */ | 2823 | /* Allocate the soft structure */ |
2826 | soft = kmalloc(sizeof(struct ioc4_soft), GFP_KERNEL); | 2824 | soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL); |
2827 | if (!soft) { | 2825 | if (!soft) { |
2828 | printk(KERN_WARNING | 2826 | printk(KERN_WARNING |
2829 | "ioc4 (%p): unable to get memory for the soft struct\n", | 2827 | "ioc4 (%p): unable to get memory for the soft struct\n", |
@@ -2831,7 +2829,6 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd) | |||
2831 | ret = -ENOMEM; | 2829 | ret = -ENOMEM; |
2832 | goto out3; | 2830 | goto out3; |
2833 | } | 2831 | } |
2834 | memset(soft, 0, sizeof(struct ioc4_soft)); | ||
2835 | 2832 | ||
2836 | spin_lock_init(&soft->is_ir_lock); | 2833 | spin_lock_init(&soft->is_ir_lock); |
2837 | soft->is_ioc4_misc_addr = idd->idd_misc_regs; | 2834 | soft->is_ioc4_misc_addr = idd->idd_misc_regs; |
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c index 0746c9446ae0..c3abfb39f316 100644 --- a/drivers/serial/ip22zilog.c +++ b/drivers/serial/ip22zilog.c | |||
@@ -14,7 +14,6 @@ | |||
14 | */ | 14 | */ |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
19 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
20 | #include <linux/tty.h> | 19 | #include <linux/tty.h> |
@@ -922,13 +921,7 @@ static int zilog_irq = -1; | |||
922 | 921 | ||
923 | static void * __init alloc_one_table(unsigned long size) | 922 | static void * __init alloc_one_table(unsigned long size) |
924 | { | 923 | { |
925 | void *ret; | 924 | return kzalloc(size, GFP_KERNEL); |
926 | |||
927 | ret = kmalloc(size, GFP_KERNEL); | ||
928 | if (ret != NULL) | ||
929 | memset(ret, 0, size); | ||
930 | |||
931 | return ret; | ||
932 | } | 925 | } |
933 | 926 | ||
934 | static void __init ip22zilog_alloc_tables(void) | 927 | static void __init ip22zilog_alloc_tables(void) |
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c index 244f63be3a03..81792e6eeb2d 100644 --- a/drivers/serial/jsm/jsm_driver.c +++ b/drivers/serial/jsm/jsm_driver.c | |||
@@ -71,14 +71,13 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
71 | goto out_disable_device; | 71 | goto out_disable_device; |
72 | } | 72 | } |
73 | 73 | ||
74 | brd = kmalloc(sizeof(struct jsm_board), GFP_KERNEL); | 74 | brd = kzalloc(sizeof(struct jsm_board), GFP_KERNEL); |
75 | if (!brd) { | 75 | if (!brd) { |
76 | dev_err(&pdev->dev, | 76 | dev_err(&pdev->dev, |
77 | "memory allocation for board structure failed\n"); | 77 | "memory allocation for board structure failed\n"); |
78 | rc = -ENOMEM; | 78 | rc = -ENOMEM; |
79 | goto out_release_regions; | 79 | goto out_release_regions; |
80 | } | 80 | } |
81 | memset(brd, 0, sizeof(struct jsm_board)); | ||
82 | 81 | ||
83 | /* store the info for the board we've found */ | 82 | /* store the info for the board we've found */ |
84 | brd->boardnum = adapter_count++; | 83 | brd->boardnum = adapter_count++; |
@@ -152,7 +151,7 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
152 | * Okay to malloc with GFP_KERNEL, we are not at interrupt | 151 | * Okay to malloc with GFP_KERNEL, we are not at interrupt |
153 | * context, and there are no locks held. | 152 | * context, and there are no locks held. |
154 | */ | 153 | */ |
155 | brd->flipbuf = kmalloc(MYFLIPLEN, GFP_KERNEL); | 154 | brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL); |
156 | if (!brd->flipbuf) { | 155 | if (!brd->flipbuf) { |
157 | /* XXX: leaking all resources from jsm_tty_init and | 156 | /* XXX: leaking all resources from jsm_tty_init and |
158 | jsm_uart_port_init here! */ | 157 | jsm_uart_port_init here! */ |
@@ -160,7 +159,6 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
160 | retval = -ENOMEM; | 159 | retval = -ENOMEM; |
161 | goto out_free_irq; | 160 | goto out_free_irq; |
162 | } | 161 | } |
163 | memset(brd->flipbuf, 0, MYFLIPLEN); | ||
164 | 162 | ||
165 | pci_set_drvdata(pdev, brd); | 163 | pci_set_drvdata(pdev, brd); |
166 | 164 | ||
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c index 7cf1c60027f8..be22bbdbc8e5 100644 --- a/drivers/serial/jsm/jsm_tty.c +++ b/drivers/serial/jsm/jsm_tty.c | |||
@@ -194,31 +194,28 @@ static int jsm_tty_open(struct uart_port *port) | |||
194 | /* Drop locks, as malloc with GFP_KERNEL can sleep */ | 194 | /* Drop locks, as malloc with GFP_KERNEL can sleep */ |
195 | 195 | ||
196 | if (!channel->ch_rqueue) { | 196 | if (!channel->ch_rqueue) { |
197 | channel->ch_rqueue = (u8 *) kmalloc(RQUEUESIZE, GFP_KERNEL); | 197 | channel->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL); |
198 | if (!channel->ch_rqueue) { | 198 | if (!channel->ch_rqueue) { |
199 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, | 199 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, |
200 | "unable to allocate read queue buf"); | 200 | "unable to allocate read queue buf"); |
201 | return -ENOMEM; | 201 | return -ENOMEM; |
202 | } | 202 | } |
203 | memset(channel->ch_rqueue, 0, RQUEUESIZE); | ||
204 | } | 203 | } |
205 | if (!channel->ch_equeue) { | 204 | if (!channel->ch_equeue) { |
206 | channel->ch_equeue = (u8 *) kmalloc(EQUEUESIZE, GFP_KERNEL); | 205 | channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL); |
207 | if (!channel->ch_equeue) { | 206 | if (!channel->ch_equeue) { |
208 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, | 207 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, |
209 | "unable to allocate error queue buf"); | 208 | "unable to allocate error queue buf"); |
210 | return -ENOMEM; | 209 | return -ENOMEM; |
211 | } | 210 | } |
212 | memset(channel->ch_equeue, 0, EQUEUESIZE); | ||
213 | } | 211 | } |
214 | if (!channel->ch_wqueue) { | 212 | if (!channel->ch_wqueue) { |
215 | channel->ch_wqueue = (u8 *) kmalloc(WQUEUESIZE, GFP_KERNEL); | 213 | channel->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL); |
216 | if (!channel->ch_wqueue) { | 214 | if (!channel->ch_wqueue) { |
217 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, | 215 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, |
218 | "unable to allocate write queue buf"); | 216 | "unable to allocate write queue buf"); |
219 | return -ENOMEM; | 217 | return -ENOMEM; |
220 | } | 218 | } |
221 | memset(channel->ch_wqueue, 0, WQUEUESIZE); | ||
222 | } | 219 | } |
223 | 220 | ||
224 | channel->ch_flags &= ~(CH_OPENING); | 221 | channel->ch_flags &= ~(CH_OPENING); |
@@ -392,13 +389,12 @@ int jsm_tty_init(struct jsm_board *brd) | |||
392 | * Okay to malloc with GFP_KERNEL, we are not at | 389 | * Okay to malloc with GFP_KERNEL, we are not at |
393 | * interrupt context, and there are no locks held. | 390 | * interrupt context, and there are no locks held. |
394 | */ | 391 | */ |
395 | brd->channels[i] = kmalloc(sizeof(struct jsm_channel), GFP_KERNEL); | 392 | brd->channels[i] = kzalloc(sizeof(struct jsm_channel), GFP_KERNEL); |
396 | if (!brd->channels[i]) { | 393 | if (!brd->channels[i]) { |
397 | jsm_printk(CORE, ERR, &brd->pci_dev, | 394 | jsm_printk(CORE, ERR, &brd->pci_dev, |
398 | "%s:%d Unable to allocate memory for channel struct\n", | 395 | "%s:%d Unable to allocate memory for channel struct\n", |
399 | __FILE__, __LINE__); | 396 | __FILE__, __LINE__); |
400 | } | 397 | } |
401 | memset(brd->channels[i], 0, sizeof(struct jsm_channel)); | ||
402 | } | 398 | } |
403 | } | 399 | } |
404 | 400 | ||
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 3c4b6c243712..955bbd653e22 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -127,8 +127,7 @@ static irqreturn_t mpc52xx_uart_int(int irq,void *dev_id); | |||
127 | 127 | ||
128 | #if defined(CONFIG_PPC_MERGE) | 128 | #if defined(CONFIG_PPC_MERGE) |
129 | static struct of_device_id mpc52xx_uart_of_match[] = { | 129 | static struct of_device_id mpc52xx_uart_of_match[] = { |
130 | { .type = "serial", .compatible = "mpc52xx-psc-uart", }, | 130 | { .type = "serial", .compatible = "mpc5200-psc-uart", }, |
131 | { .type = "serial", .compatible = "mpc5200-psc", }, /* Efika only! */ | ||
132 | {}, | 131 | {}, |
133 | }; | 132 | }; |
134 | #endif | 133 | #endif |
@@ -1068,7 +1067,7 @@ mpc52xx_uart_of_enumerate(void) | |||
1068 | continue; | 1067 | continue; |
1069 | 1068 | ||
1070 | /* Is a particular device number requested? */ | 1069 | /* Is a particular device number requested? */ |
1071 | devno = get_property(np, "device_no", NULL); | 1070 | devno = get_property(np, "port-number", NULL); |
1072 | mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1); | 1071 | mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1); |
1073 | } | 1072 | } |
1074 | 1073 | ||
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c new file mode 100644 index 000000000000..09b0b736a751 --- /dev/null +++ b/drivers/serial/of_serial.c | |||
@@ -0,0 +1,143 @@ | |||
1 | /* | ||
2 | * Serial Port driver for Open Firmware platform devices | ||
3 | * | ||
4 | * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/serial_core.h> | ||
15 | #include <linux/serial_8250.h> | ||
16 | |||
17 | #include <asm/of_platform.h> | ||
18 | #include <asm/prom.h> | ||
19 | |||
20 | /* | ||
21 | * Fill a struct uart_port for a given device node | ||
22 | */ | ||
23 | static int __devinit of_platform_serial_setup(struct of_device *ofdev, | ||
24 | int type, struct uart_port *port) | ||
25 | { | ||
26 | struct resource resource; | ||
27 | struct device_node *np = ofdev->node; | ||
28 | const unsigned int *clk, *spd; | ||
29 | int ret; | ||
30 | |||
31 | memset(port, 0, sizeof *port); | ||
32 | spd = get_property(np, "current-speed", NULL); | ||
33 | clk = get_property(np, "clock-frequency", NULL); | ||
34 | if (!clk) { | ||
35 | dev_warn(&ofdev->dev, "no clock-frequency property set\n"); | ||
36 | return -ENODEV; | ||
37 | } | ||
38 | |||
39 | ret = of_address_to_resource(np, 0, &resource); | ||
40 | if (ret) { | ||
41 | dev_warn(&ofdev->dev, "invalid address\n"); | ||
42 | return ret; | ||
43 | } | ||
44 | |||
45 | spin_lock_init(&port->lock); | ||
46 | port->mapbase = resource.start; | ||
47 | port->irq = irq_of_parse_and_map(np, 0); | ||
48 | port->iotype = UPIO_MEM; | ||
49 | port->type = type; | ||
50 | port->uartclk = *clk; | ||
51 | port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP; | ||
52 | port->dev = &ofdev->dev; | ||
53 | port->custom_divisor = *clk / (16 * (*spd)); | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | /* | ||
59 | * Try to register a serial port | ||
60 | */ | ||
61 | static int __devinit of_platform_serial_probe(struct of_device *ofdev, | ||
62 | const struct of_device_id *id) | ||
63 | { | ||
64 | struct uart_port port; | ||
65 | int port_type; | ||
66 | int ret; | ||
67 | |||
68 | if (of_find_property(ofdev->node, "used-by-rtas", NULL)) | ||
69 | return -EBUSY; | ||
70 | |||
71 | port_type = (unsigned long)id->data; | ||
72 | ret = of_platform_serial_setup(ofdev, port_type, &port); | ||
73 | if (ret) | ||
74 | goto out; | ||
75 | |||
76 | switch (port_type) { | ||
77 | case PORT_UNKNOWN: | ||
78 | dev_info(&ofdev->dev, "Unknown serial port found, " | ||
79 | "attempting to use 8250 driver\n"); | ||
80 | /* fallthrough */ | ||
81 | case PORT_8250 ... PORT_MAX_8250: | ||
82 | ret = serial8250_register_port(&port); | ||
83 | break; | ||
84 | default: | ||
85 | /* need to add code for these */ | ||
86 | ret = -ENODEV; | ||
87 | break; | ||
88 | } | ||
89 | if (ret < 0) | ||
90 | goto out; | ||
91 | |||
92 | ofdev->dev.driver_data = (void *)(unsigned long)ret; | ||
93 | return 0; | ||
94 | out: | ||
95 | irq_dispose_mapping(port.irq); | ||
96 | return ret; | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * Release a line | ||
101 | */ | ||
102 | static int of_platform_serial_remove(struct of_device *ofdev) | ||
103 | { | ||
104 | int line = (unsigned long)ofdev->dev.driver_data; | ||
105 | serial8250_unregister_port(line); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | /* | ||
110 | * A few common types, add more as needed. | ||
111 | */ | ||
112 | static struct of_device_id __devinitdata of_platform_serial_table[] = { | ||
113 | { .type = "serial", .compatible = "ns8250", .data = (void *)PORT_8250, }, | ||
114 | { .type = "serial", .compatible = "ns16450", .data = (void *)PORT_16450, }, | ||
115 | { .type = "serial", .compatible = "ns16550", .data = (void *)PORT_16550, }, | ||
116 | { .type = "serial", .compatible = "ns16750", .data = (void *)PORT_16750, }, | ||
117 | { .type = "serial", .data = (void *)PORT_UNKNOWN, }, | ||
118 | { /* end of list */ }, | ||
119 | }; | ||
120 | |||
121 | static struct of_platform_driver __devinitdata of_platform_serial_driver = { | ||
122 | .owner = THIS_MODULE, | ||
123 | .name = "of_serial", | ||
124 | .probe = of_platform_serial_probe, | ||
125 | .remove = of_platform_serial_remove, | ||
126 | .match_table = of_platform_serial_table, | ||
127 | }; | ||
128 | |||
129 | static int __init of_platform_serial_init(void) | ||
130 | { | ||
131 | return of_register_platform_driver(&of_platform_serial_driver); | ||
132 | } | ||
133 | module_init(of_platform_serial_init); | ||
134 | |||
135 | static void __exit of_platform_serial_exit(void) | ||
136 | { | ||
137 | return of_unregister_platform_driver(&of_platform_serial_driver); | ||
138 | }; | ||
139 | module_exit(of_platform_serial_exit); | ||
140 | |||
141 | MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>"); | ||
142 | MODULE_LICENSE("GPL"); | ||
143 | MODULE_DESCRIPTION("Serial Port driver for Open Firmware platform devices"); | ||
diff --git a/drivers/serial/pnx8xxx_uart.c b/drivers/serial/pnx8xxx_uart.c new file mode 100644 index 000000000000..8d01c59e8d04 --- /dev/null +++ b/drivers/serial/pnx8xxx_uart.c | |||
@@ -0,0 +1,852 @@ | |||
1 | /* | ||
2 | * UART driver for PNX8XXX SoCs | ||
3 | * | ||
4 | * Author: Per Hallsmark per.hallsmark@mvista.com | ||
5 | * Ported to 2.6 kernel by EmbeddedAlley | ||
6 | * Reworked by Vitaly Wool <vitalywool@gmail.com> | ||
7 | * | ||
8 | * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. | ||
9 | * Copyright (C) 2000 Deep Blue Solutions Ltd. | ||
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 | ||
13 | * any kind, whether express or implied. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #if defined(CONFIG_SERIAL_PNX8XXX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | ||
18 | #define SUPPORT_SYSRQ | ||
19 | #endif | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/ioport.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/console.h> | ||
25 | #include <linux/sysrq.h> | ||
26 | #include <linux/device.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/tty.h> | ||
29 | #include <linux/tty_flip.h> | ||
30 | #include <linux/serial_core.h> | ||
31 | #include <linux/serial.h> | ||
32 | #include <linux/serial_pnx8xxx.h> | ||
33 | |||
34 | #include <asm/io.h> | ||
35 | #include <asm/irq.h> | ||
36 | |||
37 | /* We'll be using StrongARM sa1100 serial port major/minor */ | ||
38 | #define SERIAL_PNX8XXX_MAJOR 204 | ||
39 | #define MINOR_START 5 | ||
40 | |||
41 | #define NR_PORTS 2 | ||
42 | |||
43 | #define PNX8XXX_ISR_PASS_LIMIT 256 | ||
44 | |||
45 | /* | ||
46 | * Convert from ignore_status_mask or read_status_mask to FIFO | ||
47 | * and interrupt status bits | ||
48 | */ | ||
49 | #define SM_TO_FIFO(x) ((x) >> 10) | ||
50 | #define SM_TO_ISTAT(x) ((x) & 0x000001ff) | ||
51 | #define FIFO_TO_SM(x) ((x) << 10) | ||
52 | #define ISTAT_TO_SM(x) ((x) & 0x000001ff) | ||
53 | |||
54 | /* | ||
55 | * This is the size of our serial port register set. | ||
56 | */ | ||
57 | #define UART_PORT_SIZE 0x1000 | ||
58 | |||
59 | /* | ||
60 | * This determines how often we check the modem status signals | ||
61 | * for any change. They generally aren't connected to an IRQ | ||
62 | * so we have to poll them. We also check immediately before | ||
63 | * filling the TX fifo incase CTS has been dropped. | ||
64 | */ | ||
65 | #define MCTRL_TIMEOUT (250*HZ/1000) | ||
66 | |||
67 | extern struct pnx8xxx_port pnx8xxx_ports[]; | ||
68 | |||
69 | static inline int serial_in(struct pnx8xxx_port *sport, int offset) | ||
70 | { | ||
71 | return (__raw_readl(sport->port.membase + offset)); | ||
72 | } | ||
73 | |||
74 | static inline void serial_out(struct pnx8xxx_port *sport, int offset, int value) | ||
75 | { | ||
76 | __raw_writel(value, sport->port.membase + offset); | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | * Handle any change of modem status signal since we were last called. | ||
81 | */ | ||
82 | static void pnx8xxx_mctrl_check(struct pnx8xxx_port *sport) | ||
83 | { | ||
84 | unsigned int status, changed; | ||
85 | |||
86 | status = sport->port.ops->get_mctrl(&sport->port); | ||
87 | changed = status ^ sport->old_status; | ||
88 | |||
89 | if (changed == 0) | ||
90 | return; | ||
91 | |||
92 | sport->old_status = status; | ||
93 | |||
94 | if (changed & TIOCM_RI) | ||
95 | sport->port.icount.rng++; | ||
96 | if (changed & TIOCM_DSR) | ||
97 | sport->port.icount.dsr++; | ||
98 | if (changed & TIOCM_CAR) | ||
99 | uart_handle_dcd_change(&sport->port, status & TIOCM_CAR); | ||
100 | if (changed & TIOCM_CTS) | ||
101 | uart_handle_cts_change(&sport->port, status & TIOCM_CTS); | ||
102 | |||
103 | wake_up_interruptible(&sport->port.info->delta_msr_wait); | ||
104 | } | ||
105 | |||
106 | /* | ||
107 | * This is our per-port timeout handler, for checking the | ||
108 | * modem status signals. | ||
109 | */ | ||
110 | static void pnx8xxx_timeout(unsigned long data) | ||
111 | { | ||
112 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)data; | ||
113 | unsigned long flags; | ||
114 | |||
115 | if (sport->port.info) { | ||
116 | spin_lock_irqsave(&sport->port.lock, flags); | ||
117 | pnx8xxx_mctrl_check(sport); | ||
118 | spin_unlock_irqrestore(&sport->port.lock, flags); | ||
119 | |||
120 | mod_timer(&sport->timer, jiffies + MCTRL_TIMEOUT); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | /* | ||
125 | * interrupts disabled on entry | ||
126 | */ | ||
127 | static void pnx8xxx_stop_tx(struct uart_port *port) | ||
128 | { | ||
129 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
130 | u32 ien; | ||
131 | |||
132 | /* Disable TX intr */ | ||
133 | ien = serial_in(sport, PNX8XXX_IEN); | ||
134 | serial_out(sport, PNX8XXX_IEN, ien & ~PNX8XXX_UART_INT_ALLTX); | ||
135 | |||
136 | /* Clear all pending TX intr */ | ||
137 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLTX); | ||
138 | } | ||
139 | |||
140 | /* | ||
141 | * interrupts may not be disabled on entry | ||
142 | */ | ||
143 | static void pnx8xxx_start_tx(struct uart_port *port) | ||
144 | { | ||
145 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
146 | u32 ien; | ||
147 | |||
148 | /* Clear all pending TX intr */ | ||
149 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLTX); | ||
150 | |||
151 | /* Enable TX intr */ | ||
152 | ien = serial_in(sport, PNX8XXX_IEN); | ||
153 | serial_out(sport, PNX8XXX_IEN, ien | PNX8XXX_UART_INT_ALLTX); | ||
154 | } | ||
155 | |||
156 | /* | ||
157 | * Interrupts enabled | ||
158 | */ | ||
159 | static void pnx8xxx_stop_rx(struct uart_port *port) | ||
160 | { | ||
161 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
162 | u32 ien; | ||
163 | |||
164 | /* Disable RX intr */ | ||
165 | ien = serial_in(sport, PNX8XXX_IEN); | ||
166 | serial_out(sport, PNX8XXX_IEN, ien & ~PNX8XXX_UART_INT_ALLRX); | ||
167 | |||
168 | /* Clear all pending RX intr */ | ||
169 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLRX); | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * Set the modem control timer to fire immediately. | ||
174 | */ | ||
175 | static void pnx8xxx_enable_ms(struct uart_port *port) | ||
176 | { | ||
177 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
178 | |||
179 | mod_timer(&sport->timer, jiffies); | ||
180 | } | ||
181 | |||
182 | static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport) | ||
183 | { | ||
184 | struct tty_struct *tty = sport->port.info->tty; | ||
185 | unsigned int status, ch, flg; | ||
186 | |||
187 | status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | | ||
188 | ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); | ||
189 | while (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFIFO)) { | ||
190 | ch = serial_in(sport, PNX8XXX_FIFO); | ||
191 | |||
192 | sport->port.icount.rx++; | ||
193 | |||
194 | flg = TTY_NORMAL; | ||
195 | |||
196 | /* | ||
197 | * note that the error handling code is | ||
198 | * out of the main execution path | ||
199 | */ | ||
200 | if (status & (FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE | | ||
201 | PNX8XXX_UART_FIFO_RXPAR) | | ||
202 | ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN))) { | ||
203 | if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR)) | ||
204 | sport->port.icount.parity++; | ||
205 | else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE)) | ||
206 | sport->port.icount.frame++; | ||
207 | if (status & ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN)) | ||
208 | sport->port.icount.overrun++; | ||
209 | |||
210 | status &= sport->port.read_status_mask; | ||
211 | |||
212 | if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR)) | ||
213 | flg = TTY_PARITY; | ||
214 | else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE)) | ||
215 | flg = TTY_FRAME; | ||
216 | |||
217 | #ifdef SUPPORT_SYSRQ | ||
218 | sport->port.sysrq = 0; | ||
219 | #endif | ||
220 | } | ||
221 | |||
222 | if (uart_handle_sysrq_char(&sport->port, ch)) | ||
223 | goto ignore_char; | ||
224 | |||
225 | uart_insert_char(&sport->port, status, | ||
226 | ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN), ch, flg); | ||
227 | |||
228 | ignore_char: | ||
229 | serial_out(sport, PNX8XXX_LCR, serial_in(sport, PNX8XXX_LCR) | | ||
230 | PNX8XXX_UART_LCR_RX_NEXT); | ||
231 | status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | | ||
232 | ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); | ||
233 | } | ||
234 | tty_flip_buffer_push(tty); | ||
235 | } | ||
236 | |||
237 | static void pnx8xxx_tx_chars(struct pnx8xxx_port *sport) | ||
238 | { | ||
239 | struct circ_buf *xmit = &sport->port.info->xmit; | ||
240 | |||
241 | if (sport->port.x_char) { | ||
242 | serial_out(sport, PNX8XXX_FIFO, sport->port.x_char); | ||
243 | sport->port.icount.tx++; | ||
244 | sport->port.x_char = 0; | ||
245 | return; | ||
246 | } | ||
247 | |||
248 | /* | ||
249 | * Check the modem control lines before | ||
250 | * transmitting anything. | ||
251 | */ | ||
252 | pnx8xxx_mctrl_check(sport); | ||
253 | |||
254 | if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) { | ||
255 | pnx8xxx_stop_tx(&sport->port); | ||
256 | return; | ||
257 | } | ||
258 | |||
259 | /* | ||
260 | * TX while bytes available | ||
261 | */ | ||
262 | while (((serial_in(sport, PNX8XXX_FIFO) & | ||
263 | PNX8XXX_UART_FIFO_TXFIFO) >> 16) < 16) { | ||
264 | serial_out(sport, PNX8XXX_FIFO, xmit->buf[xmit->tail]); | ||
265 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | ||
266 | sport->port.icount.tx++; | ||
267 | if (uart_circ_empty(xmit)) | ||
268 | break; | ||
269 | } | ||
270 | |||
271 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | ||
272 | uart_write_wakeup(&sport->port); | ||
273 | |||
274 | if (uart_circ_empty(xmit)) | ||
275 | pnx8xxx_stop_tx(&sport->port); | ||
276 | } | ||
277 | |||
278 | static irqreturn_t pnx8xxx_int(int irq, void *dev_id) | ||
279 | { | ||
280 | struct pnx8xxx_port *sport = dev_id; | ||
281 | unsigned int status; | ||
282 | |||
283 | spin_lock(&sport->port.lock); | ||
284 | /* Get the interrupts */ | ||
285 | status = serial_in(sport, PNX8XXX_ISTAT) & serial_in(sport, PNX8XXX_IEN); | ||
286 | |||
287 | /* Break signal received */ | ||
288 | if (status & PNX8XXX_UART_INT_BREAK) { | ||
289 | sport->port.icount.brk++; | ||
290 | uart_handle_break(&sport->port); | ||
291 | } | ||
292 | |||
293 | /* Byte received */ | ||
294 | if (status & PNX8XXX_UART_INT_RX) | ||
295 | pnx8xxx_rx_chars(sport); | ||
296 | |||
297 | /* TX holding register empty - transmit a byte */ | ||
298 | if (status & PNX8XXX_UART_INT_TX) | ||
299 | pnx8xxx_tx_chars(sport); | ||
300 | |||
301 | /* Clear the ISTAT register */ | ||
302 | serial_out(sport, PNX8XXX_ICLR, status); | ||
303 | |||
304 | spin_unlock(&sport->port.lock); | ||
305 | return IRQ_HANDLED; | ||
306 | } | ||
307 | |||
308 | /* | ||
309 | * Return TIOCSER_TEMT when transmitter is not busy. | ||
310 | */ | ||
311 | static unsigned int pnx8xxx_tx_empty(struct uart_port *port) | ||
312 | { | ||
313 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
314 | |||
315 | return serial_in(sport, PNX8XXX_FIFO) & PNX8XXX_UART_FIFO_TXFIFO_STA ? 0 : TIOCSER_TEMT; | ||
316 | } | ||
317 | |||
318 | static unsigned int pnx8xxx_get_mctrl(struct uart_port *port) | ||
319 | { | ||
320 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
321 | unsigned int mctrl = TIOCM_DSR; | ||
322 | unsigned int msr; | ||
323 | |||
324 | /* REVISIT */ | ||
325 | |||
326 | msr = serial_in(sport, PNX8XXX_MCR); | ||
327 | |||
328 | mctrl |= msr & PNX8XXX_UART_MCR_CTS ? TIOCM_CTS : 0; | ||
329 | mctrl |= msr & PNX8XXX_UART_MCR_DCD ? TIOCM_CAR : 0; | ||
330 | |||
331 | return mctrl; | ||
332 | } | ||
333 | |||
334 | static void pnx8xxx_set_mctrl(struct uart_port *port, unsigned int mctrl) | ||
335 | { | ||
336 | #if 0 /* FIXME */ | ||
337 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
338 | unsigned int msr; | ||
339 | #endif | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * Interrupts always disabled. | ||
344 | */ | ||
345 | static void pnx8xxx_break_ctl(struct uart_port *port, int break_state) | ||
346 | { | ||
347 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
348 | unsigned long flags; | ||
349 | unsigned int lcr; | ||
350 | |||
351 | spin_lock_irqsave(&sport->port.lock, flags); | ||
352 | lcr = serial_in(sport, PNX8XXX_LCR); | ||
353 | if (break_state == -1) | ||
354 | lcr |= PNX8XXX_UART_LCR_TXBREAK; | ||
355 | else | ||
356 | lcr &= ~PNX8XXX_UART_LCR_TXBREAK; | ||
357 | serial_out(sport, PNX8XXX_LCR, lcr); | ||
358 | spin_unlock_irqrestore(&sport->port.lock, flags); | ||
359 | } | ||
360 | |||
361 | static int pnx8xxx_startup(struct uart_port *port) | ||
362 | { | ||
363 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
364 | int retval; | ||
365 | |||
366 | /* | ||
367 | * Allocate the IRQ | ||
368 | */ | ||
369 | retval = request_irq(sport->port.irq, pnx8xxx_int, 0, | ||
370 | "pnx8xxx-uart", sport); | ||
371 | if (retval) | ||
372 | return retval; | ||
373 | |||
374 | /* | ||
375 | * Finally, clear and enable interrupts | ||
376 | */ | ||
377 | |||
378 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLRX | | ||
379 | PNX8XXX_UART_INT_ALLTX); | ||
380 | |||
381 | serial_out(sport, PNX8XXX_IEN, serial_in(sport, PNX8XXX_IEN) | | ||
382 | PNX8XXX_UART_INT_ALLRX | | ||
383 | PNX8XXX_UART_INT_ALLTX); | ||
384 | |||
385 | /* | ||
386 | * Enable modem status interrupts | ||
387 | */ | ||
388 | spin_lock_irq(&sport->port.lock); | ||
389 | pnx8xxx_enable_ms(&sport->port); | ||
390 | spin_unlock_irq(&sport->port.lock); | ||
391 | |||
392 | return 0; | ||
393 | } | ||
394 | |||
395 | static void pnx8xxx_shutdown(struct uart_port *port) | ||
396 | { | ||
397 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
398 | int lcr; | ||
399 | |||
400 | /* | ||
401 | * Stop our timer. | ||
402 | */ | ||
403 | del_timer_sync(&sport->timer); | ||
404 | |||
405 | /* | ||
406 | * Disable all interrupts | ||
407 | */ | ||
408 | serial_out(sport, PNX8XXX_IEN, 0); | ||
409 | |||
410 | /* | ||
411 | * Reset the Tx and Rx FIFOS, disable the break condition | ||
412 | */ | ||
413 | lcr = serial_in(sport, PNX8XXX_LCR); | ||
414 | lcr &= ~PNX8XXX_UART_LCR_TXBREAK; | ||
415 | lcr |= PNX8XXX_UART_LCR_TX_RST | PNX8XXX_UART_LCR_RX_RST; | ||
416 | serial_out(sport, PNX8XXX_LCR, lcr); | ||
417 | |||
418 | /* | ||
419 | * Clear all interrupts | ||
420 | */ | ||
421 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLRX | | ||
422 | PNX8XXX_UART_INT_ALLTX); | ||
423 | |||
424 | /* | ||
425 | * Free the interrupt | ||
426 | */ | ||
427 | free_irq(sport->port.irq, sport); | ||
428 | } | ||
429 | |||
430 | static void | ||
431 | pnx8xxx_set_termios(struct uart_port *port, struct ktermios *termios, | ||
432 | struct ktermios *old) | ||
433 | { | ||
434 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
435 | unsigned long flags; | ||
436 | unsigned int lcr_fcr, old_ien, baud, quot; | ||
437 | unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; | ||
438 | |||
439 | /* | ||
440 | * We only support CS7 and CS8. | ||
441 | */ | ||
442 | while ((termios->c_cflag & CSIZE) != CS7 && | ||
443 | (termios->c_cflag & CSIZE) != CS8) { | ||
444 | termios->c_cflag &= ~CSIZE; | ||
445 | termios->c_cflag |= old_csize; | ||
446 | old_csize = CS8; | ||
447 | } | ||
448 | |||
449 | if ((termios->c_cflag & CSIZE) == CS8) | ||
450 | lcr_fcr = PNX8XXX_UART_LCR_8BIT; | ||
451 | else | ||
452 | lcr_fcr = 0; | ||
453 | |||
454 | if (termios->c_cflag & CSTOPB) | ||
455 | lcr_fcr |= PNX8XXX_UART_LCR_2STOPB; | ||
456 | if (termios->c_cflag & PARENB) { | ||
457 | lcr_fcr |= PNX8XXX_UART_LCR_PAREN; | ||
458 | if (!(termios->c_cflag & PARODD)) | ||
459 | lcr_fcr |= PNX8XXX_UART_LCR_PAREVN; | ||
460 | } | ||
461 | |||
462 | /* | ||
463 | * Ask the core to calculate the divisor for us. | ||
464 | */ | ||
465 | baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); | ||
466 | quot = uart_get_divisor(port, baud); | ||
467 | |||
468 | spin_lock_irqsave(&sport->port.lock, flags); | ||
469 | |||
470 | sport->port.read_status_mask = ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN) | | ||
471 | ISTAT_TO_SM(PNX8XXX_UART_INT_EMPTY) | | ||
472 | ISTAT_TO_SM(PNX8XXX_UART_INT_RX); | ||
473 | if (termios->c_iflag & INPCK) | ||
474 | sport->port.read_status_mask |= | ||
475 | FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE) | | ||
476 | FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR); | ||
477 | if (termios->c_iflag & (BRKINT | PARMRK)) | ||
478 | sport->port.read_status_mask |= | ||
479 | ISTAT_TO_SM(PNX8XXX_UART_INT_BREAK); | ||
480 | |||
481 | /* | ||
482 | * Characters to ignore | ||
483 | */ | ||
484 | sport->port.ignore_status_mask = 0; | ||
485 | if (termios->c_iflag & IGNPAR) | ||
486 | sport->port.ignore_status_mask |= | ||
487 | FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE) | | ||
488 | FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR); | ||
489 | if (termios->c_iflag & IGNBRK) { | ||
490 | sport->port.ignore_status_mask |= | ||
491 | ISTAT_TO_SM(PNX8XXX_UART_INT_BREAK); | ||
492 | /* | ||
493 | * If we're ignoring parity and break indicators, | ||
494 | * ignore overruns too (for real raw support). | ||
495 | */ | ||
496 | if (termios->c_iflag & IGNPAR) | ||
497 | sport->port.ignore_status_mask |= | ||
498 | ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN); | ||
499 | } | ||
500 | |||
501 | /* | ||
502 | * ignore all characters if CREAD is not set | ||
503 | */ | ||
504 | if ((termios->c_cflag & CREAD) == 0) | ||
505 | sport->port.ignore_status_mask |= | ||
506 | ISTAT_TO_SM(PNX8XXX_UART_INT_RX); | ||
507 | |||
508 | del_timer_sync(&sport->timer); | ||
509 | |||
510 | /* | ||
511 | * Update the per-port timeout. | ||
512 | */ | ||
513 | uart_update_timeout(port, termios->c_cflag, baud); | ||
514 | |||
515 | /* | ||
516 | * disable interrupts and drain transmitter | ||
517 | */ | ||
518 | old_ien = serial_in(sport, PNX8XXX_IEN); | ||
519 | serial_out(sport, PNX8XXX_IEN, old_ien & ~(PNX8XXX_UART_INT_ALLTX | | ||
520 | PNX8XXX_UART_INT_ALLRX)); | ||
521 | |||
522 | while (serial_in(sport, PNX8XXX_FIFO) & PNX8XXX_UART_FIFO_TXFIFO_STA) | ||
523 | barrier(); | ||
524 | |||
525 | /* then, disable everything */ | ||
526 | serial_out(sport, PNX8XXX_IEN, 0); | ||
527 | |||
528 | /* Reset the Rx and Tx FIFOs too */ | ||
529 | lcr_fcr |= PNX8XXX_UART_LCR_TX_RST; | ||
530 | lcr_fcr |= PNX8XXX_UART_LCR_RX_RST; | ||
531 | |||
532 | /* set the parity, stop bits and data size */ | ||
533 | serial_out(sport, PNX8XXX_LCR, lcr_fcr); | ||
534 | |||
535 | /* set the baud rate */ | ||
536 | quot -= 1; | ||
537 | serial_out(sport, PNX8XXX_BAUD, quot); | ||
538 | |||
539 | serial_out(sport, PNX8XXX_ICLR, -1); | ||
540 | |||
541 | serial_out(sport, PNX8XXX_IEN, old_ien); | ||
542 | |||
543 | if (UART_ENABLE_MS(&sport->port, termios->c_cflag)) | ||
544 | pnx8xxx_enable_ms(&sport->port); | ||
545 | |||
546 | spin_unlock_irqrestore(&sport->port.lock, flags); | ||
547 | } | ||
548 | |||
549 | static const char *pnx8xxx_type(struct uart_port *port) | ||
550 | { | ||
551 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
552 | |||
553 | return sport->port.type == PORT_PNX8XXX ? "PNX8XXX" : NULL; | ||
554 | } | ||
555 | |||
556 | /* | ||
557 | * Release the memory region(s) being used by 'port'. | ||
558 | */ | ||
559 | static void pnx8xxx_release_port(struct uart_port *port) | ||
560 | { | ||
561 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
562 | |||
563 | release_mem_region(sport->port.mapbase, UART_PORT_SIZE); | ||
564 | } | ||
565 | |||
566 | /* | ||
567 | * Request the memory region(s) being used by 'port'. | ||
568 | */ | ||
569 | static int pnx8xxx_request_port(struct uart_port *port) | ||
570 | { | ||
571 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
572 | return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, | ||
573 | "pnx8xxx-uart") != NULL ? 0 : -EBUSY; | ||
574 | } | ||
575 | |||
576 | /* | ||
577 | * Configure/autoconfigure the port. | ||
578 | */ | ||
579 | static void pnx8xxx_config_port(struct uart_port *port, int flags) | ||
580 | { | ||
581 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
582 | |||
583 | if (flags & UART_CONFIG_TYPE && | ||
584 | pnx8xxx_request_port(&sport->port) == 0) | ||
585 | sport->port.type = PORT_PNX8XXX; | ||
586 | } | ||
587 | |||
588 | /* | ||
589 | * Verify the new serial_struct (for TIOCSSERIAL). | ||
590 | * The only change we allow are to the flags and type, and | ||
591 | * even then only between PORT_PNX8XXX and PORT_UNKNOWN | ||
592 | */ | ||
593 | static int | ||
594 | pnx8xxx_verify_port(struct uart_port *port, struct serial_struct *ser) | ||
595 | { | ||
596 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
597 | int ret = 0; | ||
598 | |||
599 | if (ser->type != PORT_UNKNOWN && ser->type != PORT_PNX8XXX) | ||
600 | ret = -EINVAL; | ||
601 | if (sport->port.irq != ser->irq) | ||
602 | ret = -EINVAL; | ||
603 | if (ser->io_type != SERIAL_IO_MEM) | ||
604 | ret = -EINVAL; | ||
605 | if (sport->port.uartclk / 16 != ser->baud_base) | ||
606 | ret = -EINVAL; | ||
607 | if ((void *)sport->port.mapbase != ser->iomem_base) | ||
608 | ret = -EINVAL; | ||
609 | if (sport->port.iobase != ser->port) | ||
610 | ret = -EINVAL; | ||
611 | if (ser->hub6 != 0) | ||
612 | ret = -EINVAL; | ||
613 | return ret; | ||
614 | } | ||
615 | |||
616 | static struct uart_ops pnx8xxx_pops = { | ||
617 | .tx_empty = pnx8xxx_tx_empty, | ||
618 | .set_mctrl = pnx8xxx_set_mctrl, | ||
619 | .get_mctrl = pnx8xxx_get_mctrl, | ||
620 | .stop_tx = pnx8xxx_stop_tx, | ||
621 | .start_tx = pnx8xxx_start_tx, | ||
622 | .stop_rx = pnx8xxx_stop_rx, | ||
623 | .enable_ms = pnx8xxx_enable_ms, | ||
624 | .break_ctl = pnx8xxx_break_ctl, | ||
625 | .startup = pnx8xxx_startup, | ||
626 | .shutdown = pnx8xxx_shutdown, | ||
627 | .set_termios = pnx8xxx_set_termios, | ||
628 | .type = pnx8xxx_type, | ||
629 | .release_port = pnx8xxx_release_port, | ||
630 | .request_port = pnx8xxx_request_port, | ||
631 | .config_port = pnx8xxx_config_port, | ||
632 | .verify_port = pnx8xxx_verify_port, | ||
633 | }; | ||
634 | |||
635 | |||
636 | /* | ||
637 | * Setup the PNX8XXX serial ports. | ||
638 | * | ||
639 | * Note also that we support "console=ttySx" where "x" is either 0 or 1. | ||
640 | */ | ||
641 | static void __init pnx8xxx_init_ports(void) | ||
642 | { | ||
643 | static int first = 1; | ||
644 | int i; | ||
645 | |||
646 | if (!first) | ||
647 | return; | ||
648 | first = 0; | ||
649 | |||
650 | for (i = 0; i < NR_PORTS; i++) { | ||
651 | init_timer(&pnx8xxx_ports[i].timer); | ||
652 | pnx8xxx_ports[i].timer.function = pnx8xxx_timeout; | ||
653 | pnx8xxx_ports[i].timer.data = (unsigned long)&pnx8xxx_ports[i]; | ||
654 | pnx8xxx_ports[i].port.ops = &pnx8xxx_pops; | ||
655 | } | ||
656 | } | ||
657 | |||
658 | #ifdef CONFIG_SERIAL_PNX8XXX_CONSOLE | ||
659 | |||
660 | static void pnx8xxx_console_putchar(struct uart_port *port, int ch) | ||
661 | { | ||
662 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
663 | int status; | ||
664 | |||
665 | do { | ||
666 | /* Wait for UART_TX register to empty */ | ||
667 | status = serial_in(sport, PNX8XXX_FIFO); | ||
668 | } while (status & PNX8XXX_UART_FIFO_TXFIFO); | ||
669 | serial_out(sport, PNX8XXX_FIFO, ch); | ||
670 | } | ||
671 | |||
672 | /* | ||
673 | * Interrupts are disabled on entering | ||
674 | */static void | ||
675 | pnx8xxx_console_write(struct console *co, const char *s, unsigned int count) | ||
676 | { | ||
677 | struct pnx8xxx_port *sport = &pnx8xxx_ports[co->index]; | ||
678 | unsigned int old_ien, status; | ||
679 | |||
680 | /* | ||
681 | * First, save IEN and then disable interrupts | ||
682 | */ | ||
683 | old_ien = serial_in(sport, PNX8XXX_IEN); | ||
684 | serial_out(sport, PNX8XXX_IEN, old_ien & ~(PNX8XXX_UART_INT_ALLTX | | ||
685 | PNX8XXX_UART_INT_ALLRX)); | ||
686 | |||
687 | uart_console_write(&sport->port, s, count, pnx8xxx_console_putchar); | ||
688 | |||
689 | /* | ||
690 | * Finally, wait for transmitter to become empty | ||
691 | * and restore IEN | ||
692 | */ | ||
693 | do { | ||
694 | /* Wait for UART_TX register to empty */ | ||
695 | status = serial_in(sport, PNX8XXX_FIFO); | ||
696 | } while (status & PNX8XXX_UART_FIFO_TXFIFO); | ||
697 | |||
698 | /* Clear TX and EMPTY interrupt */ | ||
699 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_TX | | ||
700 | PNX8XXX_UART_INT_EMPTY); | ||
701 | |||
702 | serial_out(sport, PNX8XXX_IEN, old_ien); | ||
703 | } | ||
704 | |||
705 | static int __init | ||
706 | pnx8xxx_console_setup(struct console *co, char *options) | ||
707 | { | ||
708 | struct pnx8xxx_port *sport; | ||
709 | int baud = 38400; | ||
710 | int bits = 8; | ||
711 | int parity = 'n'; | ||
712 | int flow = 'n'; | ||
713 | |||
714 | /* | ||
715 | * Check whether an invalid uart number has been specified, and | ||
716 | * if so, search for the first available port that does have | ||
717 | * console support. | ||
718 | */ | ||
719 | if (co->index == -1 || co->index >= NR_PORTS) | ||
720 | co->index = 0; | ||
721 | sport = &pnx8xxx_ports[co->index]; | ||
722 | |||
723 | if (options) | ||
724 | uart_parse_options(options, &baud, &parity, &bits, &flow); | ||
725 | |||
726 | return uart_set_options(&sport->port, co, baud, parity, bits, flow); | ||
727 | } | ||
728 | |||
729 | static struct uart_driver pnx8xxx_reg; | ||
730 | static struct console pnx8xxx_console = { | ||
731 | .name = "ttyS", | ||
732 | .write = pnx8xxx_console_write, | ||
733 | .device = uart_console_device, | ||
734 | .setup = pnx8xxx_console_setup, | ||
735 | .flags = CON_PRINTBUFFER, | ||
736 | .index = -1, | ||
737 | .data = &pnx8xxx_reg, | ||
738 | }; | ||
739 | |||
740 | static int __init pnx8xxx_rs_console_init(void) | ||
741 | { | ||
742 | pnx8xxx_init_ports(); | ||
743 | register_console(&pnx8xxx_console); | ||
744 | return 0; | ||
745 | } | ||
746 | console_initcall(pnx8xxx_rs_console_init); | ||
747 | |||
748 | #define PNX8XXX_CONSOLE &pnx8xxx_console | ||
749 | #else | ||
750 | #define PNX8XXX_CONSOLE NULL | ||
751 | #endif | ||
752 | |||
753 | static struct uart_driver pnx8xxx_reg = { | ||
754 | .owner = THIS_MODULE, | ||
755 | .driver_name = "ttyS", | ||
756 | .dev_name = "ttyS", | ||
757 | .major = SERIAL_PNX8XXX_MAJOR, | ||
758 | .minor = MINOR_START, | ||
759 | .nr = NR_PORTS, | ||
760 | .cons = PNX8XXX_CONSOLE, | ||
761 | }; | ||
762 | |||
763 | static int pnx8xxx_serial_suspend(struct platform_device *pdev, pm_message_t state) | ||
764 | { | ||
765 | struct pnx8xxx_port *sport = platform_get_drvdata(pdev); | ||
766 | |||
767 | return uart_suspend_port(&pnx8xxx_reg, &sport->port); | ||
768 | } | ||
769 | |||
770 | static int pnx8xxx_serial_resume(struct platform_device *pdev) | ||
771 | { | ||
772 | struct pnx8xxx_port *sport = platform_get_drvdata(pdev); | ||
773 | |||
774 | return uart_resume_port(&pnx8xxx_reg, &sport->port); | ||
775 | } | ||
776 | |||
777 | static int pnx8xxx_serial_probe(struct platform_device *pdev) | ||
778 | { | ||
779 | struct resource *res = pdev->resource; | ||
780 | int i; | ||
781 | |||
782 | for (i = 0; i < pdev->num_resources; i++, res++) { | ||
783 | if (!(res->flags & IORESOURCE_MEM)) | ||
784 | continue; | ||
785 | |||
786 | for (i = 0; i < NR_PORTS; i++) { | ||
787 | if (pnx8xxx_ports[i].port.mapbase != res->start) | ||
788 | continue; | ||
789 | |||
790 | pnx8xxx_ports[i].port.dev = &pdev->dev; | ||
791 | uart_add_one_port(&pnx8xxx_reg, &pnx8xxx_ports[i].port); | ||
792 | platform_set_drvdata(pdev, &pnx8xxx_ports[i]); | ||
793 | break; | ||
794 | } | ||
795 | } | ||
796 | |||
797 | return 0; | ||
798 | } | ||
799 | |||
800 | static int pnx8xxx_serial_remove(struct platform_device *pdev) | ||
801 | { | ||
802 | struct pnx8xxx_port *sport = platform_get_drvdata(pdev); | ||
803 | |||
804 | platform_set_drvdata(pdev, NULL); | ||
805 | |||
806 | if (sport) | ||
807 | uart_remove_one_port(&pnx8xxx_reg, &sport->port); | ||
808 | |||
809 | return 0; | ||
810 | } | ||
811 | |||
812 | static struct platform_driver pnx8xxx_serial_driver = { | ||
813 | .driver = { | ||
814 | .name = "pnx8xxx-uart", | ||
815 | .owner = THIS_MODULE, | ||
816 | }, | ||
817 | .probe = pnx8xxx_serial_probe, | ||
818 | .remove = pnx8xxx_serial_remove, | ||
819 | .suspend = pnx8xxx_serial_suspend, | ||
820 | .resume = pnx8xxx_serial_resume, | ||
821 | }; | ||
822 | |||
823 | static int __init pnx8xxx_serial_init(void) | ||
824 | { | ||
825 | int ret; | ||
826 | |||
827 | printk(KERN_INFO "Serial: PNX8XXX driver $Revision: 1.2 $\n"); | ||
828 | |||
829 | pnx8xxx_init_ports(); | ||
830 | |||
831 | ret = uart_register_driver(&pnx8xxx_reg); | ||
832 | if (ret == 0) { | ||
833 | ret = platform_driver_register(&pnx8xxx_serial_driver); | ||
834 | if (ret) | ||
835 | uart_unregister_driver(&pnx8xxx_reg); | ||
836 | } | ||
837 | return ret; | ||
838 | } | ||
839 | |||
840 | static void __exit pnx8xxx_serial_exit(void) | ||
841 | { | ||
842 | platform_driver_unregister(&pnx8xxx_serial_driver); | ||
843 | uart_unregister_driver(&pnx8xxx_reg); | ||
844 | } | ||
845 | |||
846 | module_init(pnx8xxx_serial_init); | ||
847 | module_exit(pnx8xxx_serial_exit); | ||
848 | |||
849 | MODULE_AUTHOR("Embedded Alley Solutions, Inc."); | ||
850 | MODULE_DESCRIPTION("PNX8XXX SoCs serial port driver"); | ||
851 | MODULE_LICENSE("GPL"); | ||
852 | MODULE_ALIAS_CHARDEV_MAJOR(SERIAL_PNX8XXX_MAJOR); | ||
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index f84982e508c7..0422c0f1f852 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -1523,9 +1523,8 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) | |||
1523 | } | 1523 | } |
1524 | 1524 | ||
1525 | if (!state->info) { | 1525 | if (!state->info) { |
1526 | state->info = kmalloc(sizeof(struct uart_info), GFP_KERNEL); | 1526 | state->info = kzalloc(sizeof(struct uart_info), GFP_KERNEL); |
1527 | if (state->info) { | 1527 | if (state->info) { |
1528 | memset(state->info, 0, sizeof(struct uart_info)); | ||
1529 | init_waitqueue_head(&state->info->open_wait); | 1528 | init_waitqueue_head(&state->info->open_wait); |
1530 | init_waitqueue_head(&state->info->delta_msr_wait); | 1529 | init_waitqueue_head(&state->info->delta_msr_wait); |
1531 | 1530 | ||
@@ -1660,6 +1659,7 @@ static const char *uart_type(struct uart_port *port) | |||
1660 | static int uart_line_info(char *buf, struct uart_driver *drv, int i) | 1659 | static int uart_line_info(char *buf, struct uart_driver *drv, int i) |
1661 | { | 1660 | { |
1662 | struct uart_state *state = drv->state + i; | 1661 | struct uart_state *state = drv->state + i; |
1662 | int pm_state; | ||
1663 | struct uart_port *port = state->port; | 1663 | struct uart_port *port = state->port; |
1664 | char stat_buf[32]; | 1664 | char stat_buf[32]; |
1665 | unsigned int status; | 1665 | unsigned int status; |
@@ -1682,9 +1682,16 @@ static int uart_line_info(char *buf, struct uart_driver *drv, int i) | |||
1682 | 1682 | ||
1683 | if(capable(CAP_SYS_ADMIN)) | 1683 | if(capable(CAP_SYS_ADMIN)) |
1684 | { | 1684 | { |
1685 | mutex_lock(&state->mutex); | ||
1686 | pm_state = state->pm_state; | ||
1687 | if (pm_state) | ||
1688 | uart_change_pm(state, 0); | ||
1685 | spin_lock_irq(&port->lock); | 1689 | spin_lock_irq(&port->lock); |
1686 | status = port->ops->get_mctrl(port); | 1690 | status = port->ops->get_mctrl(port); |
1687 | spin_unlock_irq(&port->lock); | 1691 | spin_unlock_irq(&port->lock); |
1692 | if (pm_state) | ||
1693 | uart_change_pm(state, pm_state); | ||
1694 | mutex_unlock(&state->mutex); | ||
1688 | 1695 | ||
1689 | ret += sprintf(buf + ret, " tx:%d rx:%d", | 1696 | ret += sprintf(buf + ret, " tx:%d rx:%d", |
1690 | port->icount.tx, port->icount.rx); | 1697 | port->icount.tx, port->icount.rx); |
@@ -2100,6 +2107,9 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, | |||
2100 | 2107 | ||
2101 | uart_report_port(drv, port); | 2108 | uart_report_port(drv, port); |
2102 | 2109 | ||
2110 | /* Power up port for set_mctrl() */ | ||
2111 | uart_change_pm(state, 0); | ||
2112 | |||
2103 | /* | 2113 | /* |
2104 | * Ensure that the modem control lines are de-activated. | 2114 | * Ensure that the modem control lines are de-activated. |
2105 | * We probably don't need a spinlock around this, but | 2115 | * We probably don't need a spinlock around this, but |
@@ -2167,13 +2177,11 @@ int uart_register_driver(struct uart_driver *drv) | |||
2167 | * Maybe we should be using a slab cache for this, especially if | 2177 | * Maybe we should be using a slab cache for this, especially if |
2168 | * we have a large number of ports to handle. | 2178 | * we have a large number of ports to handle. |
2169 | */ | 2179 | */ |
2170 | drv->state = kmalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL); | 2180 | drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL); |
2171 | retval = -ENOMEM; | 2181 | retval = -ENOMEM; |
2172 | if (!drv->state) | 2182 | if (!drv->state) |
2173 | goto out; | 2183 | goto out; |
2174 | 2184 | ||
2175 | memset(drv->state, 0, sizeof(struct uart_state) * drv->nr); | ||
2176 | |||
2177 | normal = alloc_tty_driver(drv->nr); | 2185 | normal = alloc_tty_driver(drv->nr); |
2178 | if (!normal) | 2186 | if (!normal) |
2179 | goto out; | 2187 | goto out; |
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 431433f4dd6d..c2f1012449da 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/moduleparam.h> | 35 | #include <linux/moduleparam.h> |
36 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/ptrace.h> | 38 | #include <linux/ptrace.h> |
40 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
41 | #include <linux/string.h> | 40 | #include <linux/string.h> |
@@ -334,10 +333,9 @@ static int serial_probe(struct pcmcia_device *link) | |||
334 | DEBUG(0, "serial_attach()\n"); | 333 | DEBUG(0, "serial_attach()\n"); |
335 | 334 | ||
336 | /* Create new serial device */ | 335 | /* Create new serial device */ |
337 | info = kmalloc(sizeof (*info), GFP_KERNEL); | 336 | info = kzalloc(sizeof (*info), GFP_KERNEL); |
338 | if (!info) | 337 | if (!info) |
339 | return -ENOMEM; | 338 | return -ENOMEM; |
340 | memset(info, 0, sizeof (*info)); | ||
341 | info->p_dev = link; | 339 | info->p_dev = link; |
342 | link->priv = info; | 340 | link->priv = info; |
343 | 341 | ||
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index 145d6236954b..deb9ab4b5a0b 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c | |||
@@ -17,7 +17,6 @@ | |||
17 | 17 | ||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
22 | #include <linux/tty.h> | 21 | #include <linux/tty.h> |
23 | #include <linux/tty_flip.h> | 22 | #include <linux/tty_flip.h> |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 3ec3df21816b..96a852aa1903 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -17,7 +17,6 @@ | |||
17 | 17 | ||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
22 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
23 | #include <linux/tty.h> | 22 | #include <linux/tty.h> |
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index 244f796dc625..da73205e54cd 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
19 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
20 | #include <linux/tty.h> | 19 | #include <linux/tty.h> |
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 9052f4c3493b..7e54e48efd5c 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -51,6 +51,13 @@ config SPI_MASTER | |||
51 | comment "SPI Master Controller Drivers" | 51 | comment "SPI Master Controller Drivers" |
52 | depends on SPI_MASTER | 52 | depends on SPI_MASTER |
53 | 53 | ||
54 | config SPI_ATMEL | ||
55 | tristate "Atmel SPI Controller" | ||
56 | depends on (ARCH_AT91 || AVR32) && SPI_MASTER | ||
57 | help | ||
58 | This selects a driver for the Atmel SPI Controller, present on | ||
59 | many AT32 (AVR32) and AT91 (ARM) chips. | ||
60 | |||
54 | config SPI_BITBANG | 61 | config SPI_BITBANG |
55 | tristate "Bitbanging SPI master" | 62 | tristate "Bitbanging SPI master" |
56 | depends on SPI_MASTER && EXPERIMENTAL | 63 | depends on SPI_MASTER && EXPERIMENTAL |
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index bf271fe4e536..3c280ad89202 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile | |||
@@ -12,6 +12,7 @@ obj-$(CONFIG_SPI_MASTER) += spi.o | |||
12 | 12 | ||
13 | # SPI master controller drivers (bus) | 13 | # SPI master controller drivers (bus) |
14 | obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o | 14 | obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o |
15 | obj-$(CONFIG_SPI_ATMEL) += atmel_spi.o | ||
15 | obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o | 16 | obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o |
16 | obj-$(CONFIG_SPI_IMX) += spi_imx.o | 17 | obj-$(CONFIG_SPI_IMX) += spi_imx.o |
17 | obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o | 18 | obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o |
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c new file mode 100644 index 000000000000..c2a9fef58edc --- /dev/null +++ b/drivers/spi/atmel_spi.c | |||
@@ -0,0 +1,678 @@ | |||
1 | /* | ||
2 | * Driver for Atmel AT32 and AT91 SPI Controllers | ||
3 | * | ||
4 | * Copyright (C) 2006 Atmel Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/clk.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/dma-mapping.h> | ||
18 | #include <linux/err.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/spi/spi.h> | ||
21 | |||
22 | #include <asm/io.h> | ||
23 | #include <asm/arch/board.h> | ||
24 | #include <asm/arch/gpio.h> | ||
25 | |||
26 | #include "atmel_spi.h" | ||
27 | |||
28 | /* | ||
29 | * The core SPI transfer engine just talks to a register bank to set up | ||
30 | * DMA transfers; transfer queue progress is driven by IRQs. The clock | ||
31 | * framework provides the base clock, subdivided for each spi_device. | ||
32 | * | ||
33 | * Newer controllers, marked with "new_1" flag, have: | ||
34 | * - CR.LASTXFER | ||
35 | * - SPI_MR.DIV32 may become FDIV or must-be-zero (here: always zero) | ||
36 | * - SPI_SR.TXEMPTY, SPI_SR.NSSR (and corresponding irqs) | ||
37 | * - SPI_CSRx.CSAAT | ||
38 | * - SPI_CSRx.SBCR allows faster clocking | ||
39 | */ | ||
40 | struct atmel_spi { | ||
41 | spinlock_t lock; | ||
42 | |||
43 | void __iomem *regs; | ||
44 | int irq; | ||
45 | struct clk *clk; | ||
46 | struct platform_device *pdev; | ||
47 | unsigned new_1:1; | ||
48 | |||
49 | u8 stopping; | ||
50 | struct list_head queue; | ||
51 | struct spi_transfer *current_transfer; | ||
52 | unsigned long remaining_bytes; | ||
53 | |||
54 | void *buffer; | ||
55 | dma_addr_t buffer_dma; | ||
56 | }; | ||
57 | |||
58 | #define BUFFER_SIZE PAGE_SIZE | ||
59 | #define INVALID_DMA_ADDRESS 0xffffffff | ||
60 | |||
61 | /* | ||
62 | * Earlier SPI controllers (e.g. on at91rm9200) have a design bug whereby | ||
63 | * they assume that spi slave device state will not change on deselect, so | ||
64 | * that automagic deselection is OK. Not so! Workaround uses nCSx pins | ||
65 | * as GPIOs; or newer controllers have CSAAT and friends. | ||
66 | * | ||
67 | * Since the CSAAT functionality is a bit weird on newer controllers | ||
68 | * as well, we use GPIO to control nCSx pins on all controllers. | ||
69 | */ | ||
70 | |||
71 | static inline void cs_activate(struct spi_device *spi) | ||
72 | { | ||
73 | unsigned gpio = (unsigned) spi->controller_data; | ||
74 | unsigned active = spi->mode & SPI_CS_HIGH; | ||
75 | |||
76 | dev_dbg(&spi->dev, "activate %u%s\n", gpio, active ? " (high)" : ""); | ||
77 | gpio_set_value(gpio, active); | ||
78 | } | ||
79 | |||
80 | static inline void cs_deactivate(struct spi_device *spi) | ||
81 | { | ||
82 | unsigned gpio = (unsigned) spi->controller_data; | ||
83 | unsigned active = spi->mode & SPI_CS_HIGH; | ||
84 | |||
85 | dev_dbg(&spi->dev, "DEactivate %u%s\n", gpio, active ? " (low)" : ""); | ||
86 | gpio_set_value(gpio, !active); | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * Submit next transfer for DMA. | ||
91 | * lock is held, spi irq is blocked | ||
92 | */ | ||
93 | static void atmel_spi_next_xfer(struct spi_master *master, | ||
94 | struct spi_message *msg) | ||
95 | { | ||
96 | struct atmel_spi *as = spi_master_get_devdata(master); | ||
97 | struct spi_transfer *xfer; | ||
98 | u32 len; | ||
99 | dma_addr_t tx_dma, rx_dma; | ||
100 | |||
101 | xfer = as->current_transfer; | ||
102 | if (!xfer || as->remaining_bytes == 0) { | ||
103 | if (xfer) | ||
104 | xfer = list_entry(xfer->transfer_list.next, | ||
105 | struct spi_transfer, transfer_list); | ||
106 | else | ||
107 | xfer = list_entry(msg->transfers.next, | ||
108 | struct spi_transfer, transfer_list); | ||
109 | as->remaining_bytes = xfer->len; | ||
110 | as->current_transfer = xfer; | ||
111 | } | ||
112 | |||
113 | len = as->remaining_bytes; | ||
114 | |||
115 | tx_dma = xfer->tx_dma; | ||
116 | rx_dma = xfer->rx_dma; | ||
117 | |||
118 | /* use scratch buffer only when rx or tx data is unspecified */ | ||
119 | if (rx_dma == INVALID_DMA_ADDRESS) { | ||
120 | rx_dma = as->buffer_dma; | ||
121 | if (len > BUFFER_SIZE) | ||
122 | len = BUFFER_SIZE; | ||
123 | } | ||
124 | if (tx_dma == INVALID_DMA_ADDRESS) { | ||
125 | tx_dma = as->buffer_dma; | ||
126 | if (len > BUFFER_SIZE) | ||
127 | len = BUFFER_SIZE; | ||
128 | memset(as->buffer, 0, len); | ||
129 | dma_sync_single_for_device(&as->pdev->dev, | ||
130 | as->buffer_dma, len, DMA_TO_DEVICE); | ||
131 | } | ||
132 | |||
133 | spi_writel(as, RPR, rx_dma); | ||
134 | spi_writel(as, TPR, tx_dma); | ||
135 | |||
136 | as->remaining_bytes -= len; | ||
137 | if (msg->spi->bits_per_word > 8) | ||
138 | len >>= 1; | ||
139 | |||
140 | /* REVISIT: when xfer->delay_usecs == 0, the PDC "next transfer" | ||
141 | * mechanism might help avoid the IRQ latency between transfers | ||
142 | * | ||
143 | * We're also waiting for ENDRX before we start the next | ||
144 | * transfer because we need to handle some difficult timing | ||
145 | * issues otherwise. If we wait for ENDTX in one transfer and | ||
146 | * then starts waiting for ENDRX in the next, it's difficult | ||
147 | * to tell the difference between the ENDRX interrupt we're | ||
148 | * actually waiting for and the ENDRX interrupt of the | ||
149 | * previous transfer. | ||
150 | * | ||
151 | * It should be doable, though. Just not now... | ||
152 | */ | ||
153 | spi_writel(as, TNCR, 0); | ||
154 | spi_writel(as, RNCR, 0); | ||
155 | spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES)); | ||
156 | |||
157 | dev_dbg(&msg->spi->dev, | ||
158 | " start xfer %p: len %u tx %p/%08x rx %p/%08x imr %03x\n", | ||
159 | xfer, xfer->len, xfer->tx_buf, xfer->tx_dma, | ||
160 | xfer->rx_buf, xfer->rx_dma, spi_readl(as, IMR)); | ||
161 | |||
162 | spi_writel(as, TCR, len); | ||
163 | spi_writel(as, RCR, len); | ||
164 | spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN)); | ||
165 | } | ||
166 | |||
167 | static void atmel_spi_next_message(struct spi_master *master) | ||
168 | { | ||
169 | struct atmel_spi *as = spi_master_get_devdata(master); | ||
170 | struct spi_message *msg; | ||
171 | u32 mr; | ||
172 | |||
173 | BUG_ON(as->current_transfer); | ||
174 | |||
175 | msg = list_entry(as->queue.next, struct spi_message, queue); | ||
176 | |||
177 | /* Select the chip */ | ||
178 | mr = spi_readl(as, MR); | ||
179 | mr = SPI_BFINS(PCS, ~(1 << msg->spi->chip_select), mr); | ||
180 | spi_writel(as, MR, mr); | ||
181 | cs_activate(msg->spi); | ||
182 | |||
183 | atmel_spi_next_xfer(master, msg); | ||
184 | } | ||
185 | |||
186 | static void | ||
187 | atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer) | ||
188 | { | ||
189 | xfer->tx_dma = xfer->rx_dma = INVALID_DMA_ADDRESS; | ||
190 | if (xfer->tx_buf) | ||
191 | xfer->tx_dma = dma_map_single(&as->pdev->dev, | ||
192 | (void *) xfer->tx_buf, xfer->len, | ||
193 | DMA_TO_DEVICE); | ||
194 | if (xfer->rx_buf) | ||
195 | xfer->rx_dma = dma_map_single(&as->pdev->dev, | ||
196 | xfer->rx_buf, xfer->len, | ||
197 | DMA_FROM_DEVICE); | ||
198 | } | ||
199 | |||
200 | static void atmel_spi_dma_unmap_xfer(struct spi_master *master, | ||
201 | struct spi_transfer *xfer) | ||
202 | { | ||
203 | if (xfer->tx_dma != INVALID_DMA_ADDRESS) | ||
204 | dma_unmap_single(master->cdev.dev, xfer->tx_dma, | ||
205 | xfer->len, DMA_TO_DEVICE); | ||
206 | if (xfer->rx_dma != INVALID_DMA_ADDRESS) | ||
207 | dma_unmap_single(master->cdev.dev, xfer->rx_dma, | ||
208 | xfer->len, DMA_FROM_DEVICE); | ||
209 | } | ||
210 | |||
211 | static void | ||
212 | atmel_spi_msg_done(struct spi_master *master, struct atmel_spi *as, | ||
213 | struct spi_message *msg, int status) | ||
214 | { | ||
215 | cs_deactivate(msg->spi); | ||
216 | list_del(&msg->queue); | ||
217 | msg->status = status; | ||
218 | |||
219 | dev_dbg(master->cdev.dev, | ||
220 | "xfer complete: %u bytes transferred\n", | ||
221 | msg->actual_length); | ||
222 | |||
223 | spin_unlock(&as->lock); | ||
224 | msg->complete(msg->context); | ||
225 | spin_lock(&as->lock); | ||
226 | |||
227 | as->current_transfer = NULL; | ||
228 | |||
229 | /* continue if needed */ | ||
230 | if (list_empty(&as->queue) || as->stopping) | ||
231 | spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); | ||
232 | else | ||
233 | atmel_spi_next_message(master); | ||
234 | } | ||
235 | |||
236 | static irqreturn_t | ||
237 | atmel_spi_interrupt(int irq, void *dev_id) | ||
238 | { | ||
239 | struct spi_master *master = dev_id; | ||
240 | struct atmel_spi *as = spi_master_get_devdata(master); | ||
241 | struct spi_message *msg; | ||
242 | struct spi_transfer *xfer; | ||
243 | u32 status, pending, imr; | ||
244 | int ret = IRQ_NONE; | ||
245 | |||
246 | spin_lock(&as->lock); | ||
247 | |||
248 | xfer = as->current_transfer; | ||
249 | msg = list_entry(as->queue.next, struct spi_message, queue); | ||
250 | |||
251 | imr = spi_readl(as, IMR); | ||
252 | status = spi_readl(as, SR); | ||
253 | pending = status & imr; | ||
254 | |||
255 | if (pending & SPI_BIT(OVRES)) { | ||
256 | int timeout; | ||
257 | |||
258 | ret = IRQ_HANDLED; | ||
259 | |||
260 | spi_writel(as, IDR, (SPI_BIT(ENDTX) | SPI_BIT(ENDRX) | ||
261 | | SPI_BIT(OVRES))); | ||
262 | |||
263 | /* | ||
264 | * When we get an overrun, we disregard the current | ||
265 | * transfer. Data will not be copied back from any | ||
266 | * bounce buffer and msg->actual_len will not be | ||
267 | * updated with the last xfer. | ||
268 | * | ||
269 | * We will also not process any remaning transfers in | ||
270 | * the message. | ||
271 | * | ||
272 | * First, stop the transfer and unmap the DMA buffers. | ||
273 | */ | ||
274 | spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); | ||
275 | if (!msg->is_dma_mapped) | ||
276 | atmel_spi_dma_unmap_xfer(master, xfer); | ||
277 | |||
278 | /* REVISIT: udelay in irq is unfriendly */ | ||
279 | if (xfer->delay_usecs) | ||
280 | udelay(xfer->delay_usecs); | ||
281 | |||
282 | dev_warn(master->cdev.dev, "fifo overrun (%u/%u remaining)\n", | ||
283 | spi_readl(as, TCR), spi_readl(as, RCR)); | ||
284 | |||
285 | /* | ||
286 | * Clean up DMA registers and make sure the data | ||
287 | * registers are empty. | ||
288 | */ | ||
289 | spi_writel(as, RNCR, 0); | ||
290 | spi_writel(as, TNCR, 0); | ||
291 | spi_writel(as, RCR, 0); | ||
292 | spi_writel(as, TCR, 0); | ||
293 | for (timeout = 1000; timeout; timeout--) | ||
294 | if (spi_readl(as, SR) & SPI_BIT(TXEMPTY)) | ||
295 | break; | ||
296 | if (!timeout) | ||
297 | dev_warn(master->cdev.dev, | ||
298 | "timeout waiting for TXEMPTY"); | ||
299 | while (spi_readl(as, SR) & SPI_BIT(RDRF)) | ||
300 | spi_readl(as, RDR); | ||
301 | |||
302 | /* Clear any overrun happening while cleaning up */ | ||
303 | spi_readl(as, SR); | ||
304 | |||
305 | atmel_spi_msg_done(master, as, msg, -EIO); | ||
306 | } else if (pending & SPI_BIT(ENDRX)) { | ||
307 | ret = IRQ_HANDLED; | ||
308 | |||
309 | spi_writel(as, IDR, pending); | ||
310 | |||
311 | if (as->remaining_bytes == 0) { | ||
312 | msg->actual_length += xfer->len; | ||
313 | |||
314 | if (!msg->is_dma_mapped) | ||
315 | atmel_spi_dma_unmap_xfer(master, xfer); | ||
316 | |||
317 | /* REVISIT: udelay in irq is unfriendly */ | ||
318 | if (xfer->delay_usecs) | ||
319 | udelay(xfer->delay_usecs); | ||
320 | |||
321 | if (msg->transfers.prev == &xfer->transfer_list) { | ||
322 | /* report completed message */ | ||
323 | atmel_spi_msg_done(master, as, msg, 0); | ||
324 | } else { | ||
325 | if (xfer->cs_change) { | ||
326 | cs_deactivate(msg->spi); | ||
327 | udelay(1); | ||
328 | cs_activate(msg->spi); | ||
329 | } | ||
330 | |||
331 | /* | ||
332 | * Not done yet. Submit the next transfer. | ||
333 | * | ||
334 | * FIXME handle protocol options for xfer | ||
335 | */ | ||
336 | atmel_spi_next_xfer(master, msg); | ||
337 | } | ||
338 | } else { | ||
339 | /* | ||
340 | * Keep going, we still have data to send in | ||
341 | * the current transfer. | ||
342 | */ | ||
343 | atmel_spi_next_xfer(master, msg); | ||
344 | } | ||
345 | } | ||
346 | |||
347 | spin_unlock(&as->lock); | ||
348 | |||
349 | return ret; | ||
350 | } | ||
351 | |||
352 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) | ||
353 | |||
354 | static int atmel_spi_setup(struct spi_device *spi) | ||
355 | { | ||
356 | struct atmel_spi *as; | ||
357 | u32 scbr, csr; | ||
358 | unsigned int bits = spi->bits_per_word; | ||
359 | unsigned long bus_hz, sck_hz; | ||
360 | unsigned int npcs_pin; | ||
361 | int ret; | ||
362 | |||
363 | as = spi_master_get_devdata(spi->master); | ||
364 | |||
365 | if (as->stopping) | ||
366 | return -ESHUTDOWN; | ||
367 | |||
368 | if (spi->chip_select > spi->master->num_chipselect) { | ||
369 | dev_dbg(&spi->dev, | ||
370 | "setup: invalid chipselect %u (%u defined)\n", | ||
371 | spi->chip_select, spi->master->num_chipselect); | ||
372 | return -EINVAL; | ||
373 | } | ||
374 | |||
375 | if (bits == 0) | ||
376 | bits = 8; | ||
377 | if (bits < 8 || bits > 16) { | ||
378 | dev_dbg(&spi->dev, | ||
379 | "setup: invalid bits_per_word %u (8 to 16)\n", | ||
380 | bits); | ||
381 | return -EINVAL; | ||
382 | } | ||
383 | |||
384 | if (spi->mode & ~MODEBITS) { | ||
385 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
386 | spi->mode & ~MODEBITS); | ||
387 | return -EINVAL; | ||
388 | } | ||
389 | |||
390 | /* speed zero convention is used by some upper layers */ | ||
391 | bus_hz = clk_get_rate(as->clk); | ||
392 | if (spi->max_speed_hz) { | ||
393 | /* assume div32/fdiv/mbz == 0 */ | ||
394 | if (!as->new_1) | ||
395 | bus_hz /= 2; | ||
396 | scbr = ((bus_hz + spi->max_speed_hz - 1) | ||
397 | / spi->max_speed_hz); | ||
398 | if (scbr >= (1 << SPI_SCBR_SIZE)) { | ||
399 | dev_dbg(&spi->dev, "setup: %d Hz too slow, scbr %u\n", | ||
400 | spi->max_speed_hz, scbr); | ||
401 | return -EINVAL; | ||
402 | } | ||
403 | } else | ||
404 | scbr = 0xff; | ||
405 | sck_hz = bus_hz / scbr; | ||
406 | |||
407 | csr = SPI_BF(SCBR, scbr) | SPI_BF(BITS, bits - 8); | ||
408 | if (spi->mode & SPI_CPOL) | ||
409 | csr |= SPI_BIT(CPOL); | ||
410 | if (!(spi->mode & SPI_CPHA)) | ||
411 | csr |= SPI_BIT(NCPHA); | ||
412 | |||
413 | /* TODO: DLYBS and DLYBCT */ | ||
414 | csr |= SPI_BF(DLYBS, 10); | ||
415 | csr |= SPI_BF(DLYBCT, 10); | ||
416 | |||
417 | /* chipselect must have been muxed as GPIO (e.g. in board setup) */ | ||
418 | npcs_pin = (unsigned int)spi->controller_data; | ||
419 | if (!spi->controller_state) { | ||
420 | ret = gpio_request(npcs_pin, "spi_npcs"); | ||
421 | if (ret) | ||
422 | return ret; | ||
423 | spi->controller_state = (void *)npcs_pin; | ||
424 | gpio_direction_output(npcs_pin); | ||
425 | } | ||
426 | |||
427 | dev_dbg(&spi->dev, | ||
428 | "setup: %lu Hz bpw %u mode 0x%x -> csr%d %08x\n", | ||
429 | sck_hz, bits, spi->mode, spi->chip_select, csr); | ||
430 | |||
431 | spi_writel(as, CSR0 + 4 * spi->chip_select, csr); | ||
432 | |||
433 | return 0; | ||
434 | } | ||
435 | |||
436 | static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg) | ||
437 | { | ||
438 | struct atmel_spi *as; | ||
439 | struct spi_transfer *xfer; | ||
440 | unsigned long flags; | ||
441 | struct device *controller = spi->master->cdev.dev; | ||
442 | |||
443 | as = spi_master_get_devdata(spi->master); | ||
444 | |||
445 | dev_dbg(controller, "new message %p submitted for %s\n", | ||
446 | msg, spi->dev.bus_id); | ||
447 | |||
448 | if (unlikely(list_empty(&msg->transfers) | ||
449 | || !spi->max_speed_hz)) | ||
450 | return -EINVAL; | ||
451 | |||
452 | if (as->stopping) | ||
453 | return -ESHUTDOWN; | ||
454 | |||
455 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | ||
456 | if (!(xfer->tx_buf || xfer->rx_buf)) { | ||
457 | dev_dbg(&spi->dev, "missing rx or tx buf\n"); | ||
458 | return -EINVAL; | ||
459 | } | ||
460 | |||
461 | /* FIXME implement these protocol options!! */ | ||
462 | if (xfer->bits_per_word || xfer->speed_hz) { | ||
463 | dev_dbg(&spi->dev, "no protocol options yet\n"); | ||
464 | return -ENOPROTOOPT; | ||
465 | } | ||
466 | } | ||
467 | |||
468 | /* scrub dcache "early" */ | ||
469 | if (!msg->is_dma_mapped) { | ||
470 | list_for_each_entry(xfer, &msg->transfers, transfer_list) | ||
471 | atmel_spi_dma_map_xfer(as, xfer); | ||
472 | } | ||
473 | |||
474 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | ||
475 | dev_dbg(controller, | ||
476 | " xfer %p: len %u tx %p/%08x rx %p/%08x\n", | ||
477 | xfer, xfer->len, | ||
478 | xfer->tx_buf, xfer->tx_dma, | ||
479 | xfer->rx_buf, xfer->rx_dma); | ||
480 | } | ||
481 | |||
482 | msg->status = -EINPROGRESS; | ||
483 | msg->actual_length = 0; | ||
484 | |||
485 | spin_lock_irqsave(&as->lock, flags); | ||
486 | list_add_tail(&msg->queue, &as->queue); | ||
487 | if (!as->current_transfer) | ||
488 | atmel_spi_next_message(spi->master); | ||
489 | spin_unlock_irqrestore(&as->lock, flags); | ||
490 | |||
491 | return 0; | ||
492 | } | ||
493 | |||
494 | static void atmel_spi_cleanup(const struct spi_device *spi) | ||
495 | { | ||
496 | if (spi->controller_state) | ||
497 | gpio_free((unsigned int)spi->controller_data); | ||
498 | } | ||
499 | |||
500 | /*-------------------------------------------------------------------------*/ | ||
501 | |||
502 | static int __init atmel_spi_probe(struct platform_device *pdev) | ||
503 | { | ||
504 | struct resource *regs; | ||
505 | int irq; | ||
506 | struct clk *clk; | ||
507 | int ret; | ||
508 | struct spi_master *master; | ||
509 | struct atmel_spi *as; | ||
510 | |||
511 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
512 | if (!regs) | ||
513 | return -ENXIO; | ||
514 | |||
515 | irq = platform_get_irq(pdev, 0); | ||
516 | if (irq < 0) | ||
517 | return irq; | ||
518 | |||
519 | clk = clk_get(&pdev->dev, "spi_clk"); | ||
520 | if (IS_ERR(clk)) | ||
521 | return PTR_ERR(clk); | ||
522 | |||
523 | /* setup spi core then atmel-specific driver state */ | ||
524 | ret = -ENOMEM; | ||
525 | master = spi_alloc_master(&pdev->dev, sizeof *as); | ||
526 | if (!master) | ||
527 | goto out_free; | ||
528 | |||
529 | master->bus_num = pdev->id; | ||
530 | master->num_chipselect = 4; | ||
531 | master->setup = atmel_spi_setup; | ||
532 | master->transfer = atmel_spi_transfer; | ||
533 | master->cleanup = atmel_spi_cleanup; | ||
534 | platform_set_drvdata(pdev, master); | ||
535 | |||
536 | as = spi_master_get_devdata(master); | ||
537 | |||
538 | as->buffer = dma_alloc_coherent(&pdev->dev, BUFFER_SIZE, | ||
539 | &as->buffer_dma, GFP_KERNEL); | ||
540 | if (!as->buffer) | ||
541 | goto out_free; | ||
542 | |||
543 | spin_lock_init(&as->lock); | ||
544 | INIT_LIST_HEAD(&as->queue); | ||
545 | as->pdev = pdev; | ||
546 | as->regs = ioremap(regs->start, (regs->end - regs->start) + 1); | ||
547 | if (!as->regs) | ||
548 | goto out_free_buffer; | ||
549 | as->irq = irq; | ||
550 | as->clk = clk; | ||
551 | #ifdef CONFIG_ARCH_AT91 | ||
552 | if (!cpu_is_at91rm9200()) | ||
553 | as->new_1 = 1; | ||
554 | #endif | ||
555 | |||
556 | ret = request_irq(irq, atmel_spi_interrupt, 0, | ||
557 | pdev->dev.bus_id, master); | ||
558 | if (ret) | ||
559 | goto out_unmap_regs; | ||
560 | |||
561 | /* Initialize the hardware */ | ||
562 | clk_enable(clk); | ||
563 | spi_writel(as, CR, SPI_BIT(SWRST)); | ||
564 | spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS)); | ||
565 | spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); | ||
566 | spi_writel(as, CR, SPI_BIT(SPIEN)); | ||
567 | |||
568 | /* go! */ | ||
569 | dev_info(&pdev->dev, "Atmel SPI Controller at 0x%08lx (irq %d)\n", | ||
570 | (unsigned long)regs->start, irq); | ||
571 | |||
572 | ret = spi_register_master(master); | ||
573 | if (ret) | ||
574 | goto out_reset_hw; | ||
575 | |||
576 | return 0; | ||
577 | |||
578 | out_reset_hw: | ||
579 | spi_writel(as, CR, SPI_BIT(SWRST)); | ||
580 | clk_disable(clk); | ||
581 | free_irq(irq, master); | ||
582 | out_unmap_regs: | ||
583 | iounmap(as->regs); | ||
584 | out_free_buffer: | ||
585 | dma_free_coherent(&pdev->dev, BUFFER_SIZE, as->buffer, | ||
586 | as->buffer_dma); | ||
587 | out_free: | ||
588 | clk_put(clk); | ||
589 | spi_master_put(master); | ||
590 | return ret; | ||
591 | } | ||
592 | |||
593 | static int __exit atmel_spi_remove(struct platform_device *pdev) | ||
594 | { | ||
595 | struct spi_master *master = platform_get_drvdata(pdev); | ||
596 | struct atmel_spi *as = spi_master_get_devdata(master); | ||
597 | struct spi_message *msg; | ||
598 | |||
599 | /* reset the hardware and block queue progress */ | ||
600 | spin_lock_irq(&as->lock); | ||
601 | as->stopping = 1; | ||
602 | spi_writel(as, CR, SPI_BIT(SWRST)); | ||
603 | spi_readl(as, SR); | ||
604 | spin_unlock_irq(&as->lock); | ||
605 | |||
606 | /* Terminate remaining queued transfers */ | ||
607 | list_for_each_entry(msg, &as->queue, queue) { | ||
608 | /* REVISIT unmapping the dma is a NOP on ARM and AVR32 | ||
609 | * but we shouldn't depend on that... | ||
610 | */ | ||
611 | msg->status = -ESHUTDOWN; | ||
612 | msg->complete(msg->context); | ||
613 | } | ||
614 | |||
615 | dma_free_coherent(&pdev->dev, BUFFER_SIZE, as->buffer, | ||
616 | as->buffer_dma); | ||
617 | |||
618 | clk_disable(as->clk); | ||
619 | clk_put(as->clk); | ||
620 | free_irq(as->irq, master); | ||
621 | iounmap(as->regs); | ||
622 | |||
623 | spi_unregister_master(master); | ||
624 | |||
625 | return 0; | ||
626 | } | ||
627 | |||
628 | #ifdef CONFIG_PM | ||
629 | |||
630 | static int atmel_spi_suspend(struct platform_device *pdev, pm_message_t mesg) | ||
631 | { | ||
632 | struct spi_master *master = platform_get_drvdata(pdev); | ||
633 | struct atmel_spi *as = spi_master_get_devdata(master); | ||
634 | |||
635 | clk_disable(as->clk); | ||
636 | return 0; | ||
637 | } | ||
638 | |||
639 | static int atmel_spi_resume(struct platform_device *pdev) | ||
640 | { | ||
641 | struct spi_master *master = platform_get_drvdata(pdev); | ||
642 | struct atmel_spi *as = spi_master_get_devdata(master); | ||
643 | |||
644 | clk_enable(as->clk); | ||
645 | return 0; | ||
646 | } | ||
647 | |||
648 | #else | ||
649 | #define atmel_spi_suspend NULL | ||
650 | #define atmel_spi_resume NULL | ||
651 | #endif | ||
652 | |||
653 | |||
654 | static struct platform_driver atmel_spi_driver = { | ||
655 | .driver = { | ||
656 | .name = "atmel_spi", | ||
657 | .owner = THIS_MODULE, | ||
658 | }, | ||
659 | .suspend = atmel_spi_suspend, | ||
660 | .resume = atmel_spi_resume, | ||
661 | .remove = __exit_p(atmel_spi_remove), | ||
662 | }; | ||
663 | |||
664 | static int __init atmel_spi_init(void) | ||
665 | { | ||
666 | return platform_driver_probe(&atmel_spi_driver, atmel_spi_probe); | ||
667 | } | ||
668 | module_init(atmel_spi_init); | ||
669 | |||
670 | static void __exit atmel_spi_exit(void) | ||
671 | { | ||
672 | platform_driver_unregister(&atmel_spi_driver); | ||
673 | } | ||
674 | module_exit(atmel_spi_exit); | ||
675 | |||
676 | MODULE_DESCRIPTION("Atmel AT32/AT91 SPI Controller driver"); | ||
677 | MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>"); | ||
678 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/spi/atmel_spi.h b/drivers/spi/atmel_spi.h new file mode 100644 index 000000000000..6e06b6ad3a45 --- /dev/null +++ b/drivers/spi/atmel_spi.h | |||
@@ -0,0 +1,167 @@ | |||
1 | /* | ||
2 | * Register definitions for Atmel Serial Peripheral Interface (SPI) | ||
3 | * | ||
4 | * Copyright (C) 2006 Atmel Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | #ifndef __ATMEL_SPI_H__ | ||
11 | #define __ATMEL_SPI_H__ | ||
12 | |||
13 | /* SPI register offsets */ | ||
14 | #define SPI_CR 0x0000 | ||
15 | #define SPI_MR 0x0004 | ||
16 | #define SPI_RDR 0x0008 | ||
17 | #define SPI_TDR 0x000c | ||
18 | #define SPI_SR 0x0010 | ||
19 | #define SPI_IER 0x0014 | ||
20 | #define SPI_IDR 0x0018 | ||
21 | #define SPI_IMR 0x001c | ||
22 | #define SPI_CSR0 0x0030 | ||
23 | #define SPI_CSR1 0x0034 | ||
24 | #define SPI_CSR2 0x0038 | ||
25 | #define SPI_CSR3 0x003c | ||
26 | #define SPI_RPR 0x0100 | ||
27 | #define SPI_RCR 0x0104 | ||
28 | #define SPI_TPR 0x0108 | ||
29 | #define SPI_TCR 0x010c | ||
30 | #define SPI_RNPR 0x0110 | ||
31 | #define SPI_RNCR 0x0114 | ||
32 | #define SPI_TNPR 0x0118 | ||
33 | #define SPI_TNCR 0x011c | ||
34 | #define SPI_PTCR 0x0120 | ||
35 | #define SPI_PTSR 0x0124 | ||
36 | |||
37 | /* Bitfields in CR */ | ||
38 | #define SPI_SPIEN_OFFSET 0 | ||
39 | #define SPI_SPIEN_SIZE 1 | ||
40 | #define SPI_SPIDIS_OFFSET 1 | ||
41 | #define SPI_SPIDIS_SIZE 1 | ||
42 | #define SPI_SWRST_OFFSET 7 | ||
43 | #define SPI_SWRST_SIZE 1 | ||
44 | #define SPI_LASTXFER_OFFSET 24 | ||
45 | #define SPI_LASTXFER_SIZE 1 | ||
46 | |||
47 | /* Bitfields in MR */ | ||
48 | #define SPI_MSTR_OFFSET 0 | ||
49 | #define SPI_MSTR_SIZE 1 | ||
50 | #define SPI_PS_OFFSET 1 | ||
51 | #define SPI_PS_SIZE 1 | ||
52 | #define SPI_PCSDEC_OFFSET 2 | ||
53 | #define SPI_PCSDEC_SIZE 1 | ||
54 | #define SPI_FDIV_OFFSET 3 | ||
55 | #define SPI_FDIV_SIZE 1 | ||
56 | #define SPI_MODFDIS_OFFSET 4 | ||
57 | #define SPI_MODFDIS_SIZE 1 | ||
58 | #define SPI_LLB_OFFSET 7 | ||
59 | #define SPI_LLB_SIZE 1 | ||
60 | #define SPI_PCS_OFFSET 16 | ||
61 | #define SPI_PCS_SIZE 4 | ||
62 | #define SPI_DLYBCS_OFFSET 24 | ||
63 | #define SPI_DLYBCS_SIZE 8 | ||
64 | |||
65 | /* Bitfields in RDR */ | ||
66 | #define SPI_RD_OFFSET 0 | ||
67 | #define SPI_RD_SIZE 16 | ||
68 | |||
69 | /* Bitfields in TDR */ | ||
70 | #define SPI_TD_OFFSET 0 | ||
71 | #define SPI_TD_SIZE 16 | ||
72 | |||
73 | /* Bitfields in SR */ | ||
74 | #define SPI_RDRF_OFFSET 0 | ||
75 | #define SPI_RDRF_SIZE 1 | ||
76 | #define SPI_TDRE_OFFSET 1 | ||
77 | #define SPI_TDRE_SIZE 1 | ||
78 | #define SPI_MODF_OFFSET 2 | ||
79 | #define SPI_MODF_SIZE 1 | ||
80 | #define SPI_OVRES_OFFSET 3 | ||
81 | #define SPI_OVRES_SIZE 1 | ||
82 | #define SPI_ENDRX_OFFSET 4 | ||
83 | #define SPI_ENDRX_SIZE 1 | ||
84 | #define SPI_ENDTX_OFFSET 5 | ||
85 | #define SPI_ENDTX_SIZE 1 | ||
86 | #define SPI_RXBUFF_OFFSET 6 | ||
87 | #define SPI_RXBUFF_SIZE 1 | ||
88 | #define SPI_TXBUFE_OFFSET 7 | ||
89 | #define SPI_TXBUFE_SIZE 1 | ||
90 | #define SPI_NSSR_OFFSET 8 | ||
91 | #define SPI_NSSR_SIZE 1 | ||
92 | #define SPI_TXEMPTY_OFFSET 9 | ||
93 | #define SPI_TXEMPTY_SIZE 1 | ||
94 | #define SPI_SPIENS_OFFSET 16 | ||
95 | #define SPI_SPIENS_SIZE 1 | ||
96 | |||
97 | /* Bitfields in CSR0 */ | ||
98 | #define SPI_CPOL_OFFSET 0 | ||
99 | #define SPI_CPOL_SIZE 1 | ||
100 | #define SPI_NCPHA_OFFSET 1 | ||
101 | #define SPI_NCPHA_SIZE 1 | ||
102 | #define SPI_CSAAT_OFFSET 3 | ||
103 | #define SPI_CSAAT_SIZE 1 | ||
104 | #define SPI_BITS_OFFSET 4 | ||
105 | #define SPI_BITS_SIZE 4 | ||
106 | #define SPI_SCBR_OFFSET 8 | ||
107 | #define SPI_SCBR_SIZE 8 | ||
108 | #define SPI_DLYBS_OFFSET 16 | ||
109 | #define SPI_DLYBS_SIZE 8 | ||
110 | #define SPI_DLYBCT_OFFSET 24 | ||
111 | #define SPI_DLYBCT_SIZE 8 | ||
112 | |||
113 | /* Bitfields in RCR */ | ||
114 | #define SPI_RXCTR_OFFSET 0 | ||
115 | #define SPI_RXCTR_SIZE 16 | ||
116 | |||
117 | /* Bitfields in TCR */ | ||
118 | #define SPI_TXCTR_OFFSET 0 | ||
119 | #define SPI_TXCTR_SIZE 16 | ||
120 | |||
121 | /* Bitfields in RNCR */ | ||
122 | #define SPI_RXNCR_OFFSET 0 | ||
123 | #define SPI_RXNCR_SIZE 16 | ||
124 | |||
125 | /* Bitfields in TNCR */ | ||
126 | #define SPI_TXNCR_OFFSET 0 | ||
127 | #define SPI_TXNCR_SIZE 16 | ||
128 | |||
129 | /* Bitfields in PTCR */ | ||
130 | #define SPI_RXTEN_OFFSET 0 | ||
131 | #define SPI_RXTEN_SIZE 1 | ||
132 | #define SPI_RXTDIS_OFFSET 1 | ||
133 | #define SPI_RXTDIS_SIZE 1 | ||
134 | #define SPI_TXTEN_OFFSET 8 | ||
135 | #define SPI_TXTEN_SIZE 1 | ||
136 | #define SPI_TXTDIS_OFFSET 9 | ||
137 | #define SPI_TXTDIS_SIZE 1 | ||
138 | |||
139 | /* Constants for BITS */ | ||
140 | #define SPI_BITS_8_BPT 0 | ||
141 | #define SPI_BITS_9_BPT 1 | ||
142 | #define SPI_BITS_10_BPT 2 | ||
143 | #define SPI_BITS_11_BPT 3 | ||
144 | #define SPI_BITS_12_BPT 4 | ||
145 | #define SPI_BITS_13_BPT 5 | ||
146 | #define SPI_BITS_14_BPT 6 | ||
147 | #define SPI_BITS_15_BPT 7 | ||
148 | #define SPI_BITS_16_BPT 8 | ||
149 | |||
150 | /* Bit manipulation macros */ | ||
151 | #define SPI_BIT(name) \ | ||
152 | (1 << SPI_##name##_OFFSET) | ||
153 | #define SPI_BF(name,value) \ | ||
154 | (((value) & ((1 << SPI_##name##_SIZE) - 1)) << SPI_##name##_OFFSET) | ||
155 | #define SPI_BFEXT(name,value) \ | ||
156 | (((value) >> SPI_##name##_OFFSET) & ((1 << SPI_##name##_SIZE) - 1)) | ||
157 | #define SPI_BFINS(name,value,old) \ | ||
158 | ( ((old) & ~(((1 << SPI_##name##_SIZE) - 1) << SPI_##name##_OFFSET)) \ | ||
159 | | SPI_BF(name,value)) | ||
160 | |||
161 | /* Register access macros */ | ||
162 | #define spi_readl(port,reg) \ | ||
163 | __raw_readl((port)->regs + SPI_##reg) | ||
164 | #define spi_writel(port,reg,value) \ | ||
165 | __raw_writel((value), (port)->regs + SPI_##reg) | ||
166 | |||
167 | #endif /* __ATMEL_SPI_H__ */ | ||
diff --git a/drivers/tc/lk201.c b/drivers/tc/lk201.c index 757dec9c7ee9..a90c255f079d 100644 --- a/drivers/tc/lk201.c +++ b/drivers/tc/lk201.c | |||
@@ -10,7 +10,6 @@ | |||
10 | 10 | ||
11 | 11 | ||
12 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
13 | #include <linux/sched.h> | ||
14 | #include <linux/tty.h> | 13 | #include <linux/tty.h> |
15 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 15 | #include <linux/init.h> |
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index 164a5dcf1f1e..3e658dc7c2d8 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c | |||
@@ -3,7 +3,6 @@ | |||
3 | #include <linux/module.h> | 3 | #include <linux/module.h> |
4 | 4 | ||
5 | #include <linux/init.h> | 5 | #include <linux/init.h> |
6 | #include <linux/sched.h> | ||
7 | #include <linux/kernel.h> /* printk() */ | 6 | #include <linux/kernel.h> /* printk() */ |
8 | #include <linux/fs.h> /* everything... */ | 7 | #include <linux/fs.h> /* everything... */ |
9 | #include <linux/errno.h> /* error codes */ | 8 | #include <linux/errno.h> /* error codes */ |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index f39050145f1f..36b36e0175fc 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/ioport.h> | 32 | #include <linux/ioport.h> |
33 | #include <linux/sched.h> | ||
34 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
35 | #include <linux/smp_lock.h> | 34 | #include <linux/smp_lock.h> |
36 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 3c2bc075ef4f..7d7909cf2558 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <linux/kernel.h> | 40 | #include <linux/kernel.h> |
41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
42 | #include <linux/ioport.h> | 42 | #include <linux/ioport.h> |
43 | #include <linux/sched.h> | ||
44 | #include <linux/slab.h> | 43 | #include <linux/slab.h> |
45 | #include <linux/smp_lock.h> | 44 | #include <linux/smp_lock.h> |
46 | #include <linux/errno.h> | 45 | #include <linux/errno.h> |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 22e3c9443641..04e6b8508fb6 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
32 | #include <linux/smp_lock.h> | 31 | #include <linux/smp_lock.h> |
33 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index e873cf488246..7b3a326b57ab 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <linux/ioport.h> | 31 | #include <linux/ioport.h> |
32 | #include <linux/sched.h> | ||
33 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
34 | #include <linux/smp_lock.h> | 33 | #include <linux/smp_lock.h> |
35 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 7617ff7bd5ac..49d737725f70 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -53,7 +53,6 @@ | |||
53 | #include <linux/kernel.h> | 53 | #include <linux/kernel.h> |
54 | #include <linux/delay.h> | 54 | #include <linux/delay.h> |
55 | #include <linux/ioport.h> | 55 | #include <linux/ioport.h> |
56 | #include <linux/sched.h> | ||
57 | #include <linux/slab.h> | 56 | #include <linux/slab.h> |
58 | #include <linux/smp_lock.h> | 57 | #include <linux/smp_lock.h> |
59 | #include <linux/errno.h> | 58 | #include <linux/errno.h> |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 140104341db4..8f9a2b615422 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
29 | #include <linux/errno.h> | 29 | #include <linux/errno.h> |
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <linux/sched.h> | ||
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
34 | #include <linux/timer.h> | 33 | #include <linux/timer.h> |
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index 0d225369847d..27904a56494b 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/types.h> | 33 | #include <linux/types.h> |
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/sched.h> | ||
37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
38 | #include <linux/init.h> | 37 | #include <linux/init.h> |
39 | #include <linux/timer.h> | 38 | #include <linux/timer.h> |
@@ -2614,7 +2613,7 @@ lubbock_fail0: | |||
2614 | #endif | 2613 | #endif |
2615 | if (vbus_irq) { | 2614 | if (vbus_irq) { |
2616 | retval = request_irq(vbus_irq, udc_vbus_irq, | 2615 | retval = request_irq(vbus_irq, udc_vbus_irq, |
2617 | SA_INTERRUPT | SA_SAMPLE_RANDOM, | 2616 | IRQF_DISABLED | IRQF_SAMPLE_RANDOM, |
2618 | driver_name, dev); | 2617 | driver_name, dev); |
2619 | if (retval != 0) { | 2618 | if (retval != 0) { |
2620 | printk(KERN_ERR "%s: can't get irq %i, err %d\n", | 2619 | printk(KERN_ERR "%s: can't get irq %i, err %d\n", |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 6c742a909225..e6c19aa4bef3 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
24 | #include <linux/sched.h> | ||
25 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
26 | #include <linux/smp_lock.h> | 25 | #include <linux/smp_lock.h> |
27 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index ebe04e0d2879..8c85e33f74a4 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -66,7 +66,6 @@ | |||
66 | #include <linux/kernel.h> | 66 | #include <linux/kernel.h> |
67 | #include <linux/delay.h> | 67 | #include <linux/delay.h> |
68 | #include <linux/ioport.h> | 68 | #include <linux/ioport.h> |
69 | #include <linux/sched.h> | ||
70 | #include <linux/slab.h> | 69 | #include <linux/slab.h> |
71 | #include <linux/smp_lock.h> | 70 | #include <linux/smp_lock.h> |
72 | #include <linux/errno.h> | 71 | #include <linux/errno.h> |
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index f0ffb8907f29..32f7caf24747 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/ioport.h> | 9 | #include <linux/ioport.h> |
10 | #include <linux/sched.h> | ||
11 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
12 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
13 | #include <linux/unistd.h> | 12 | #include <linux/unistd.h> |
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index 44c60fba76e1..a68ce9d3c525 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c | |||
@@ -78,7 +78,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver *driver, | |||
78 | 78 | ||
79 | ohci_hcd_init(hcd_to_ohci(hcd)); | 79 | ohci_hcd_init(hcd_to_ohci(hcd)); |
80 | 80 | ||
81 | retval = usb_add_hcd(hcd, pdev->resource[1].start, SA_INTERRUPT); | 81 | retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED); |
82 | if (retval == 0) | 82 | if (retval == 0) |
83 | return retval; | 83 | return retval; |
84 | 84 | ||
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c index 893b172384da..d601bbb9387b 100644 --- a/drivers/usb/host/ohci-pnx4008.c +++ b/drivers/usb/host/ohci-pnx4008.c | |||
@@ -421,7 +421,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
421 | ohci_hcd_init(ohci); | 421 | ohci_hcd_init(ohci); |
422 | 422 | ||
423 | dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); | 423 | dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); |
424 | ret = usb_add_hcd(hcd, irq, SA_INTERRUPT); | 424 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); |
425 | if (ret == 0) | 425 | if (ret == 0) |
426 | return ret; | 426 | return ret; |
427 | 427 | ||
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c index de45eb0051a7..85fdfd2a7ad0 100644 --- a/drivers/usb/host/ohci-pnx8550.c +++ b/drivers/usb/host/ohci-pnx8550.c | |||
@@ -107,7 +107,7 @@ int usb_hcd_pnx8550_probe (const struct hc_driver *driver, | |||
107 | 107 | ||
108 | ohci_hcd_init(hcd_to_ohci(hcd)); | 108 | ohci_hcd_init(hcd_to_ohci(hcd)); |
109 | 109 | ||
110 | retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT); | 110 | retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED); |
111 | if (retval == 0) | 111 | if (retval == 0) |
112 | return retval; | 112 | return retval; |
113 | 113 | ||
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index ac9f11d19817..2d0e73b20099 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/ptrace.h> | 16 | #include <linux/ptrace.h> |
18 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 49b9d390b95f..ded4df30a631 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/ioport.h> | 30 | #include <linux/ioport.h> |
31 | #include <linux/sched.h> | ||
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
33 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
34 | #include <linux/unistd.h> | 33 | #include <linux/unistd.h> |
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index 8ccddf74534a..896cb2b71020 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c | |||
@@ -121,7 +121,6 @@ | |||
121 | 121 | ||
122 | #include <linux/module.h> | 122 | #include <linux/module.h> |
123 | #include <linux/kernel.h> | 123 | #include <linux/kernel.h> |
124 | #include <linux/sched.h> | ||
125 | #include <linux/signal.h> | 124 | #include <linux/signal.h> |
126 | #include <linux/errno.h> | 125 | #include <linux/errno.h> |
127 | #include <linux/random.h> | 126 | #include <linux/random.h> |
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index 9f52429ce654..f857935e615c 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c | |||
@@ -76,7 +76,6 @@ | |||
76 | #include <linux/module.h> | 76 | #include <linux/module.h> |
77 | #include <linux/init.h> | 77 | #include <linux/init.h> |
78 | #include <linux/usb/input.h> | 78 | #include <linux/usb/input.h> |
79 | #include <linux/sched.h> | ||
80 | #include <asm/uaccess.h> | 79 | #include <asm/uaccess.h> |
81 | #include <asm/unaligned.h> | 80 | #include <asm/unaligned.h> |
82 | 81 | ||
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 84983d1b7164..4d8ed3d71a15 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/sched.h> | ||
22 | #include <linux/list.h> | 21 | #include <linux/list.h> |
23 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
24 | #include <linux/smp_lock.h> | 23 | #include <linux/smp_lock.h> |
diff --git a/drivers/usb/input/hid-pidff.c b/drivers/usb/input/hid-pidff.c index cbd2d53fefff..f5a90e950e6b 100644 --- a/drivers/usb/input/hid-pidff.c +++ b/drivers/usb/input/hid-pidff.c | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | #define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg) | 25 | #define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg) |
26 | 26 | ||
27 | #include <linux/sched.h> | ||
28 | #include <linux/input.h> | 27 | #include <linux/input.h> |
29 | #include <linux/usb.h> | 28 | #include <linux/usb.h> |
30 | 29 | ||
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 0398908b15d4..6f8b134a79cb 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <linux/module.h> | 40 | #include <linux/module.h> |
41 | #include <linux/kernel.h> | 41 | #include <linux/kernel.h> |
42 | #include <linux/signal.h> | 42 | #include <linux/signal.h> |
43 | #include <linux/sched.h> | ||
44 | #include <linux/errno.h> | 43 | #include <linux/errno.h> |
45 | #include <linux/poll.h> | 44 | #include <linux/poll.h> |
46 | #include <linux/init.h> | 45 | #include <linux/init.h> |
diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index 9148694627d5..1730d8642a47 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c | |||
@@ -51,7 +51,6 @@ | |||
51 | #include <linux/module.h> | 51 | #include <linux/module.h> |
52 | #include <linux/kernel.h> | 52 | #include <linux/kernel.h> |
53 | #include <linux/signal.h> | 53 | #include <linux/signal.h> |
54 | #include <linux/sched.h> | ||
55 | #include <linux/fs.h> | 54 | #include <linux/fs.h> |
56 | #include <linux/tty.h> | 55 | #include <linux/tty.h> |
57 | #include <linux/console.h> | 56 | #include <linux/console.h> |
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c index 4206df2d61b7..bd357e178e55 100644 --- a/drivers/usb/net/asix.c +++ b/drivers/usb/net/asix.c | |||
@@ -25,7 +25,6 @@ | |||
25 | 25 | ||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/kmod.h> | 27 | #include <linux/kmod.h> |
28 | #include <linux/sched.h> | ||
29 | #include <linux/init.h> | 28 | #include <linux/init.h> |
30 | #include <linux/netdevice.h> | 29 | #include <linux/netdevice.h> |
31 | #include <linux/etherdevice.h> | 30 | #include <linux/etherdevice.h> |
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c index e5cdafa258dd..5a21f06bf8a5 100644 --- a/drivers/usb/net/cdc_ether.c +++ b/drivers/usb/net/cdc_ether.c | |||
@@ -22,7 +22,6 @@ | |||
22 | // #define VERBOSE // more; success messages | 22 | // #define VERBOSE // more; success messages |
23 | 23 | ||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/sched.h> | ||
26 | #include <linux/init.h> | 25 | #include <linux/init.h> |
27 | #include <linux/netdevice.h> | 26 | #include <linux/netdevice.h> |
28 | #include <linux/etherdevice.h> | 27 | #include <linux/etherdevice.h> |
diff --git a/drivers/usb/net/cdc_subset.c b/drivers/usb/net/cdc_subset.c index e2fae85851a3..ae8fb06cf38e 100644 --- a/drivers/usb/net/cdc_subset.c +++ b/drivers/usb/net/cdc_subset.c | |||
@@ -19,7 +19,6 @@ | |||
19 | 19 | ||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/kmod.h> | 21 | #include <linux/kmod.h> |
22 | #include <linux/sched.h> | ||
23 | #include <linux/init.h> | 22 | #include <linux/init.h> |
24 | #include <linux/netdevice.h> | 23 | #include <linux/netdevice.h> |
25 | #include <linux/etherdevice.h> | 24 | #include <linux/etherdevice.h> |
diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c index 31e5fe363fdc..d257a8e026d6 100644 --- a/drivers/usb/net/gl620a.c +++ b/drivers/usb/net/gl620a.c | |||
@@ -22,7 +22,6 @@ | |||
22 | // #define VERBOSE // more; success messages | 22 | // #define VERBOSE // more; success messages |
23 | 23 | ||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/sched.h> | ||
26 | #include <linux/init.h> | 25 | #include <linux/init.h> |
27 | #include <linux/netdevice.h> | 26 | #include <linux/netdevice.h> |
28 | #include <linux/etherdevice.h> | 27 | #include <linux/etherdevice.h> |
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index 36a989160a68..de95268ae4b8 100644 --- a/drivers/usb/net/kaweth.c +++ b/drivers/usb/net/kaweth.c | |||
@@ -46,7 +46,6 @@ | |||
46 | */ | 46 | */ |
47 | 47 | ||
48 | #include <linux/module.h> | 48 | #include <linux/module.h> |
49 | #include <linux/sched.h> | ||
50 | #include <linux/slab.h> | 49 | #include <linux/slab.h> |
51 | #include <linux/string.h> | 50 | #include <linux/string.h> |
52 | #include <linux/init.h> | 51 | #include <linux/init.h> |
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c index 493635954513..ccebfdef4751 100644 --- a/drivers/usb/net/net1080.c +++ b/drivers/usb/net/net1080.c | |||
@@ -21,7 +21,6 @@ | |||
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/sched.h> | ||
25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
26 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
27 | #include <linux/etherdevice.h> | 26 | #include <linux/etherdevice.h> |
diff --git a/drivers/usb/net/plusb.c b/drivers/usb/net/plusb.c index 5d17cdfc7bab..45300939d185 100644 --- a/drivers/usb/net/plusb.c +++ b/drivers/usb/net/plusb.c | |||
@@ -21,7 +21,6 @@ | |||
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/sched.h> | ||
25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
26 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
27 | #include <linux/etherdevice.h> | 26 | #include <linux/etherdevice.h> |
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c index be888d2d813c..39a21c74fdf4 100644 --- a/drivers/usb/net/rndis_host.c +++ b/drivers/usb/net/rndis_host.c | |||
@@ -21,7 +21,6 @@ | |||
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/sched.h> | ||
25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
26 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
27 | #include <linux/etherdevice.h> | 26 | #include <linux/etherdevice.h> |
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c index 670262a38a0f..ea153dc9b0ac 100644 --- a/drivers/usb/net/rtl8150.c +++ b/drivers/usb/net/rtl8150.c | |||
@@ -6,7 +6,6 @@ | |||
6 | * version 2 as published by the Free Software Foundation. | 6 | * version 2 as published by the Free Software Foundation. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/sched.h> | ||
10 | #include <linux/init.h> | 9 | #include <linux/init.h> |
11 | #include <linux/signal.h> | 10 | #include <linux/signal.h> |
12 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 6e39e9988259..43ba61abfcc5 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c | |||
@@ -34,7 +34,6 @@ | |||
34 | // #define VERBOSE // more; success messages | 34 | // #define VERBOSE // more; success messages |
35 | 35 | ||
36 | #include <linux/module.h> | 36 | #include <linux/module.h> |
37 | #include <linux/sched.h> | ||
38 | #include <linux/init.h> | 37 | #include <linux/init.h> |
39 | #include <linux/netdevice.h> | 38 | #include <linux/netdevice.h> |
40 | #include <linux/etherdevice.h> | 39 | #include <linux/etherdevice.h> |
diff --git a/drivers/usb/net/zaurus.c b/drivers/usb/net/zaurus.c index 144566bda583..9f98e8ce487a 100644 --- a/drivers/usb/net/zaurus.c +++ b/drivers/usb/net/zaurus.c | |||
@@ -21,7 +21,6 @@ | |||
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/sched.h> | ||
25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
26 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
27 | #include <linux/ethtool.h> | 26 | #include <linux/ethtool.h> |
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index 01d8971ad7db..c87ad1bae1d6 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c | |||
@@ -50,7 +50,6 @@ | |||
50 | * in that routine. | 50 | * in that routine. |
51 | */ | 51 | */ |
52 | 52 | ||
53 | #include <linux/sched.h> | ||
54 | #include <linux/errno.h> | 53 | #include <linux/errno.h> |
55 | #include <linux/slab.h> | 54 | #include <linux/slab.h> |
56 | 55 | ||
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c index 5b06f9240d05..3a41740cad97 100644 --- a/drivers/usb/storage/initializers.c +++ b/drivers/usb/storage/initializers.c | |||
@@ -37,7 +37,6 @@ | |||
37 | * 675 Mass Ave, Cambridge, MA 02139, USA. | 37 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
38 | */ | 38 | */ |
39 | 39 | ||
40 | #include <linux/sched.h> | ||
41 | #include <linux/errno.h> | 40 | #include <linux/errno.h> |
42 | 41 | ||
43 | #include "usb.h" | 42 | #include "usb.h" |
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index 5031aa98f6a9..003fcf545888 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c | |||
@@ -47,7 +47,6 @@ | |||
47 | * in that routine. | 47 | * in that routine. |
48 | */ | 48 | */ |
49 | 49 | ||
50 | #include <linux/sched.h> | ||
51 | #include <linux/errno.h> | 50 | #include <linux/errno.h> |
52 | #include <linux/slab.h> | 51 | #include <linux/slab.h> |
53 | 52 | ||
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index e3528eca29a5..b2ed2a3e6fca 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c | |||
@@ -41,7 +41,6 @@ | |||
41 | * EF: compute checksum (?) | 41 | * EF: compute checksum (?) |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #include <linux/sched.h> | ||
45 | #include <linux/errno.h> | 44 | #include <linux/errno.h> |
46 | #include <linux/slab.h> | 45 | #include <linux/slab.h> |
47 | 46 | ||
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 8fcec01dc622..5e27297c0175 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c | |||
@@ -43,7 +43,6 @@ | |||
43 | * 675 Mass Ave, Cambridge, MA 02139, USA. | 43 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
44 | */ | 44 | */ |
45 | 45 | ||
46 | #include <linux/sched.h> | ||
47 | #include <linux/errno.h> | 46 | #include <linux/errno.h> |
48 | #include <linux/slab.h> | 47 | #include <linux/slab.h> |
49 | #include <linux/cdrom.h> | 48 | #include <linux/cdrom.h> |
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c index 602db660bc73..bffe2b946344 100644 --- a/drivers/video/atafb.c +++ b/drivers/video/atafb.c | |||
@@ -49,7 +49,6 @@ | |||
49 | 49 | ||
50 | #include <linux/module.h> | 50 | #include <linux/module.h> |
51 | #include <linux/kernel.h> | 51 | #include <linux/kernel.h> |
52 | #include <linux/sched.h> | ||
53 | #include <linux/errno.h> | 52 | #include <linux/errno.h> |
54 | #include <linux/string.h> | 53 | #include <linux/string.h> |
55 | #include <linux/mm.h> | 54 | #include <linux/mm.h> |
diff --git a/drivers/video/aty/mach64_accel.c b/drivers/video/aty/mach64_accel.c index 1490e5e1c232..a8f60c33863c 100644 --- a/drivers/video/aty/mach64_accel.c +++ b/drivers/video/aty/mach64_accel.c | |||
@@ -3,7 +3,6 @@ | |||
3 | * ATI Mach64 Hardware Acceleration | 3 | * ATI Mach64 Hardware Acceleration |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/sched.h> | ||
7 | #include <linux/delay.h> | 6 | #include <linux/delay.h> |
8 | #include <linux/fb.h> | 7 | #include <linux/fb.h> |
9 | #include <video/mach64.h> | 8 | #include <video/mach64.h> |
diff --git a/drivers/video/aty/mach64_gx.c b/drivers/video/aty/mach64_gx.c index 2045639cb671..10c988aef58e 100644 --- a/drivers/video/aty/mach64_gx.c +++ b/drivers/video/aty/mach64_gx.c | |||
@@ -5,7 +5,6 @@ | |||
5 | 5 | ||
6 | #include <linux/delay.h> | 6 | #include <linux/delay.h> |
7 | #include <linux/fb.h> | 7 | #include <linux/fb.h> |
8 | #include <linux/sched.h> | ||
9 | 8 | ||
10 | #include <asm/io.h> | 9 | #include <asm/io.h> |
11 | 10 | ||
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c index e7c5b219ad1b..508479920705 100644 --- a/drivers/video/aty/radeon_i2c.c +++ b/drivers/video/aty/radeon_i2c.c | |||
@@ -1,6 +1,5 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
2 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
3 | #include <linux/sched.h> | ||
4 | #include <linux/delay.h> | 3 | #include <linux/delay.h> |
5 | #include <linux/pci.h> | 4 | #include <linux/pci.h> |
6 | #include <linux/fb.h> | 5 | #include <linux/fb.h> |
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index ce5ac268074e..be3f2c3f132c 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c | |||
@@ -60,7 +60,6 @@ | |||
60 | 60 | ||
61 | #include <linux/module.h> | 61 | #include <linux/module.h> |
62 | #include <linux/types.h> | 62 | #include <linux/types.h> |
63 | #include <linux/sched.h> | ||
64 | #include <linux/fs.h> | 63 | #include <linux/fs.h> |
65 | #include <linux/kernel.h> | 64 | #include <linux/kernel.h> |
66 | #include <linux/delay.h> /* MSch: for IRQ probe */ | 65 | #include <linux/delay.h> /* MSch: for IRQ probe */ |
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index eb4d03fa5391..124ecbe6f88c 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c | |||
@@ -27,7 +27,6 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/fs.h> | 30 | #include <linux/fs.h> |
32 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
33 | #include <linux/module.h> | 32 | #include <linux/module.h> |
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 4a9bde2c839b..91a20785108a 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c | |||
@@ -35,7 +35,6 @@ | |||
35 | 35 | ||
36 | #include <linux/module.h> | 36 | #include <linux/module.h> |
37 | #include <linux/types.h> | 37 | #include <linux/types.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/fs.h> | 38 | #include <linux/fs.h> |
40 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
41 | #include <linux/console.h> | 40 | #include <linux/console.h> |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 3cfea315a48f..28225265159a 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/compat.h> | 16 | #include <linux/compat.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/smp_lock.h> | 19 | #include <linux/smp_lock.h> |
21 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
22 | #include <linux/major.h> | 21 | #include <linux/major.h> |
diff --git a/drivers/video/g364fb.c b/drivers/video/g364fb.c index 1b981b635675..ca93a75f2997 100644 --- a/drivers/video/g364fb.c +++ b/drivers/video/g364fb.c | |||
@@ -16,7 +16,6 @@ | |||
16 | 16 | ||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/console.h> | 18 | #include <linux/console.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
22 | #include <linux/string.h> | 21 | #include <linux/string.h> |
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c index 3dc49424dc75..756c0ce85911 100644 --- a/drivers/video/hitfb.c +++ b/drivers/video/hitfb.c | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
19 | #include <linux/mm.h> | 18 | #include <linux/mm.h> |
diff --git a/drivers/video/hpfb.c b/drivers/video/hpfb.c index 9ab9b839a0f5..b18486ad8e17 100644 --- a/drivers/video/hpfb.c +++ b/drivers/video/hpfb.c | |||
@@ -7,7 +7,6 @@ | |||
7 | 7 | ||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/sched.h> | ||
11 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
12 | #include <linux/string.h> | 11 | #include <linux/string.h> |
13 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c index 961f4d404467..7787c3322ffb 100644 --- a/drivers/video/i810/i810-i2c.c +++ b/drivers/video/i810/i810-i2c.c | |||
@@ -10,7 +10,6 @@ | |||
10 | */ | 10 | */ |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/sched.h> | ||
14 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
15 | #include <linux/pci.h> | 14 | #include <linux/pci.h> |
16 | #include <linux/fb.h> | 15 | #include <linux/fb.h> |
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index 0f9b2fdc28b1..267c1ff9ebd9 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c | |||
@@ -20,7 +20,6 @@ | |||
20 | 20 | ||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/sched.h> | ||
24 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
25 | #include <linux/string.h> | 24 | #include <linux/string.h> |
26 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
diff --git a/drivers/video/intelfb/intelfb_i2c.c b/drivers/video/intelfb/intelfb_i2c.c index 33bc41f50540..f4ede5f6b588 100644 --- a/drivers/video/intelfb/intelfb_i2c.c +++ b/drivers/video/intelfb/intelfb_i2c.c | |||
@@ -27,7 +27,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
27 | 27 | ||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
32 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
33 | #include <linux/fb.h> | 32 | #include <linux/fb.h> |
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c index a95836839e1e..c1eb18bf0883 100644 --- a/drivers/video/intelfb/intelfbhw.c +++ b/drivers/video/intelfb/intelfbhw.c | |||
@@ -1990,7 +1990,8 @@ int | |||
1990 | intelfbhw_enable_irq(struct intelfb_info *dinfo, int reenable) { | 1990 | intelfbhw_enable_irq(struct intelfb_info *dinfo, int reenable) { |
1991 | 1991 | ||
1992 | if (!test_and_set_bit(0, &dinfo->irq_flags)) { | 1992 | if (!test_and_set_bit(0, &dinfo->irq_flags)) { |
1993 | if (request_irq(dinfo->pdev->irq, intelfbhw_irq, SA_SHIRQ, "intelfb", dinfo)) { | 1993 | if (request_irq(dinfo->pdev->irq, intelfbhw_irq, IRQF_SHARED, |
1994 | "intelfb", dinfo)) { | ||
1994 | clear_bit(0, &dinfo->irq_flags); | 1995 | clear_bit(0, &dinfo->irq_flags); |
1995 | return -EINVAL; | 1996 | return -EINVAL; |
1996 | } | 1997 | } |
diff --git a/drivers/video/kyro/fbdev.c b/drivers/video/kyro/fbdev.c index f0d614a80f1f..1c5579907397 100644 --- a/drivers/video/kyro/fbdev.c +++ b/drivers/video/kyro/fbdev.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
17 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c index 180d94c2b4d2..f7d647dda978 100644 --- a/drivers/video/macfb.c +++ b/drivers/video/macfb.c | |||
@@ -20,7 +20,6 @@ | |||
20 | 20 | ||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/sched.h> | ||
24 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
25 | #include <linux/string.h> | 24 | #include <linux/string.h> |
26 | #include <linux/mm.h> | 25 | #include <linux/mm.h> |
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c index f64c4a0984cd..5ec718a5fe22 100644 --- a/drivers/video/matrox/i2c-matroxfb.c +++ b/drivers/video/matrox/i2c-matroxfb.c | |||
@@ -115,6 +115,7 @@ static int i2c_bus_reg(struct i2c_bit_adapter* b, struct matrox_fb_info* minfo, | |||
115 | minfo->fbcon.node); | 115 | minfo->fbcon.node); |
116 | i2c_set_adapdata(&b->adapter, b); | 116 | i2c_set_adapdata(&b->adapter, b); |
117 | b->adapter.algo_data = &b->bac; | 117 | b->adapter.algo_data = &b->bac; |
118 | b->adapter.dev.parent = &ACCESS_FBINFO(pcidev)->dev; | ||
118 | b->bac = matrox_i2c_algo_template; | 119 | b->bac = matrox_i2c_algo_template; |
119 | b->bac.data = b; | 120 | b->bac.data = b; |
120 | err = i2c_bit_add_bus(&b->adapter); | 121 | err = i2c_bit_add_bus(&b->adapter); |
diff --git a/drivers/video/maxinefb.c b/drivers/video/maxinefb.c index 38c8d38de4fd..5e91c2b30af9 100644 --- a/drivers/video/maxinefb.c +++ b/drivers/video/maxinefb.c | |||
@@ -25,7 +25,6 @@ | |||
25 | 25 | ||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/sched.h> | ||
29 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
30 | #include <linux/string.h> | 29 | #include <linux/string.h> |
31 | #include <linux/mm.h> | 30 | #include <linux/mm.h> |
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c index 5162eab95539..3e517940c5a5 100644 --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/fb.h> | 15 | #include <linux/fb.h> |
16 | #include <linux/sched.h> | ||
17 | 16 | ||
18 | #undef DEBUG | 17 | #undef DEBUG |
19 | 18 | ||
diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c index 8454adf2d178..b8588973e400 100644 --- a/drivers/video/nvidia/nv_i2c.c +++ b/drivers/video/nvidia/nv_i2c.c | |||
@@ -12,7 +12,6 @@ | |||
12 | 12 | ||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
17 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
18 | #include <linux/fb.h> | 17 | #include <linux/fb.h> |
diff --git a/drivers/video/nvidia/nv_of.c b/drivers/video/nvidia/nv_of.c index 181875fe35c6..163a774a1b30 100644 --- a/drivers/video/nvidia/nv_of.c +++ b/drivers/video/nvidia/nv_of.c | |||
@@ -12,7 +12,6 @@ | |||
12 | 12 | ||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
17 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
18 | #include <linux/fb.h> | 17 | #include <linux/fb.h> |
diff --git a/drivers/video/pmag-aa-fb.c b/drivers/video/pmag-aa-fb.c index 68ca3cc40770..a864438b6008 100644 --- a/drivers/video/pmag-aa-fb.c +++ b/drivers/video/pmag-aa-fb.c | |||
@@ -24,7 +24,6 @@ | |||
24 | */ | 24 | */ |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/sched.h> | ||
28 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
29 | #include <linux/string.h> | 28 | #include <linux/string.h> |
30 | #include <linux/timer.h> | 29 | #include <linux/timer.h> |
diff --git a/drivers/video/riva/rivafb-i2c.c b/drivers/video/riva/rivafb-i2c.c index 01b85e3b0ae1..0405e839ff93 100644 --- a/drivers/video/riva/rivafb-i2c.c +++ b/drivers/video/riva/rivafb-i2c.c | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
19 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
20 | #include <linux/fb.h> | 19 | #include <linux/fb.h> |
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index ccef56d0c157..ed3426062a8b 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c | |||
@@ -791,6 +791,8 @@ static int __init s3c2410fb_probe(struct platform_device *pdev) | |||
791 | 791 | ||
792 | info = fbinfo->par; | 792 | info = fbinfo->par; |
793 | info->fb = fbinfo; | 793 | info->fb = fbinfo; |
794 | info->dev = &pdev->dev; | ||
795 | |||
794 | platform_set_drvdata(pdev, fbinfo); | 796 | platform_set_drvdata(pdev, fbinfo); |
795 | 797 | ||
796 | dprintk("devinit\n"); | 798 | dprintk("devinit\n"); |
diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c index 1411f3b6a009..8db066ccca6b 100644 --- a/drivers/video/savage/savagefb-i2c.c +++ b/drivers/video/savage/savagefb-i2c.c | |||
@@ -12,7 +12,6 @@ | |||
12 | 12 | ||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | ||
16 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
17 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
18 | #include <linux/fb.h> | 17 | #include <linux/fb.h> |
diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c index b604859b4ddb..7478d0e3e211 100644 --- a/drivers/video/tgafb.c +++ b/drivers/video/tgafb.c | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/sched.h> | ||
17 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
19 | #include <linux/mm.h> | 18 | #include <linux/mm.h> |