diff options
488 files changed, 14556 insertions, 6055 deletions
diff --git a/Documentation/DocBook/kgdb.tmpl b/Documentation/DocBook/kgdb.tmpl index 97618bed4d65..028a8444d95e 100644 --- a/Documentation/DocBook/kgdb.tmpl +++ b/Documentation/DocBook/kgdb.tmpl | |||
@@ -72,7 +72,7 @@ | |||
72 | kgdb is a source level debugger for linux kernel. It is used along | 72 | kgdb is a source level debugger for linux kernel. It is used along |
73 | with gdb to debug a linux kernel. The expectation is that gdb can | 73 | with gdb to debug a linux kernel. The expectation is that gdb can |
74 | be used to "break in" to the kernel to inspect memory, variables | 74 | be used to "break in" to the kernel to inspect memory, variables |
75 | and look through a cal stack information similar to what an | 75 | and look through call stack information similar to what an |
76 | application developer would use gdb for. It is possible to place | 76 | application developer would use gdb for. It is possible to place |
77 | breakpoints in kernel code and perform some limited execution | 77 | breakpoints in kernel code and perform some limited execution |
78 | stepping. | 78 | stepping. |
@@ -93,8 +93,10 @@ | |||
93 | <chapter id="CompilingAKernel"> | 93 | <chapter id="CompilingAKernel"> |
94 | <title>Compiling a kernel</title> | 94 | <title>Compiling a kernel</title> |
95 | <para> | 95 | <para> |
96 | To enable <symbol>CONFIG_KGDB</symbol>, look under the "Kernel debugging" | 96 | To enable <symbol>CONFIG_KGDB</symbol> you should first turn on |
97 | and then select "KGDB: kernel debugging with remote gdb". | 97 | "Prompt for development and/or incomplete code/drivers" |
98 | (CONFIG_EXPERIMENTAL) in "General setup", then under the | ||
99 | "Kernel debugging" select "KGDB: kernel debugging with remote gdb". | ||
98 | </para> | 100 | </para> |
99 | <para> | 101 | <para> |
100 | Next you should choose one of more I/O drivers to interconnect debugging | 102 | Next you should choose one of more I/O drivers to interconnect debugging |
diff --git a/Documentation/hwmon/w83l785ts b/Documentation/hwmon/w83l785ts index 1841cedc25b2..bd1fa9d4468d 100644 --- a/Documentation/hwmon/w83l785ts +++ b/Documentation/hwmon/w83l785ts | |||
@@ -33,7 +33,8 @@ Known Issues | |||
33 | ------------ | 33 | ------------ |
34 | 34 | ||
35 | On some systems (Asus), the BIOS is known to interfere with the driver | 35 | On some systems (Asus), the BIOS is known to interfere with the driver |
36 | and cause read errors. The driver will retry a given number of times | 36 | and cause read errors. Or maybe the W83L785TS-S chip is simply unreliable, |
37 | we don't really know. The driver will retry a given number of times | ||
37 | (5 by default) and then give up, returning the old value (or 0 if | 38 | (5 by default) and then give up, returning the old value (or 0 if |
38 | there is no old value). It seems to work well enough so that you should | 39 | there is no old value). It seems to work well enough so that you should |
39 | not notice anything. Thanks to James Bolt for helping test this feature. | 40 | not notice anything. Thanks to James Bolt for helping test this feature. |
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index 00b950d1c193..c412c245848f 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt | |||
@@ -377,27 +377,3 @@ config FOO | |||
377 | 377 | ||
378 | limits FOO to module (=m) or disabled (=n). | 378 | limits FOO to module (=m) or disabled (=n). |
379 | 379 | ||
380 | |||
381 | Build limited by a third config symbol which may be =y or =m | ||
382 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
383 | A common idiom that we see (and sometimes have problems with) is this: | ||
384 | |||
385 | When option C in B (module or subsystem) uses interfaces from A (module | ||
386 | or subsystem), and both A and B are tristate (could be =y or =m if they | ||
387 | were independent of each other, but they aren't), then we need to limit | ||
388 | C such that it cannot be built statically if A is built as a loadable | ||
389 | module. (C already depends on B, so there is no dependency issue to | ||
390 | take care of here.) | ||
391 | |||
392 | If A is linked statically into the kernel image, C can be built | ||
393 | statically or as loadable module(s). However, if A is built as loadable | ||
394 | module(s), then C must be restricted to loadable module(s) also. This | ||
395 | can be expressed in kconfig language as: | ||
396 | |||
397 | config C | ||
398 | depends on A = y || A = B | ||
399 | |||
400 | or for real examples, use this command in a kernel tree: | ||
401 | |||
402 | $ find . -name Kconfig\* | xargs grep -ns "depends on.*=.*||.*=" | grep -v orig | ||
403 | |||
diff --git a/Documentation/kdump/kdump.txt b/Documentation/kdump/kdump.txt index d0ac72cc19ff..b8e52c0355d3 100644 --- a/Documentation/kdump/kdump.txt +++ b/Documentation/kdump/kdump.txt | |||
@@ -245,6 +245,8 @@ The syntax is: | |||
245 | crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset] | 245 | crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset] |
246 | range=start-[end] | 246 | range=start-[end] |
247 | 247 | ||
248 | 'start' is inclusive and 'end' is exclusive. | ||
249 | |||
248 | For example: | 250 | For example: |
249 | 251 | ||
250 | crashkernel=512M-2G:64M,2G-:128M | 252 | crashkernel=512M-2G:64M,2G-:128M |
@@ -253,10 +255,11 @@ This would mean: | |||
253 | 255 | ||
254 | 1) if the RAM is smaller than 512M, then don't reserve anything | 256 | 1) if the RAM is smaller than 512M, then don't reserve anything |
255 | (this is the "rescue" case) | 257 | (this is the "rescue" case) |
256 | 2) if the RAM size is between 512M and 2G, then reserve 64M | 258 | 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M |
257 | 3) if the RAM size is larger than 2G, then reserve 128M | 259 | 3) if the RAM size is larger than 2G, then reserve 128M |
258 | 260 | ||
259 | 261 | ||
262 | |||
260 | Boot into System Kernel | 263 | Boot into System Kernel |
261 | ======================= | 264 | ======================= |
262 | 265 | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index a3c35446e755..cdd5b934f43e 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -1094,9 +1094,6 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1094 | mac5380= [HW,SCSI] Format: | 1094 | mac5380= [HW,SCSI] Format: |
1095 | <can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags> | 1095 | <can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags> |
1096 | 1096 | ||
1097 | mac53c9x= [HW,SCSI] Format: | ||
1098 | <num_esps>,<disconnect>,<nosync>,<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags> | ||
1099 | |||
1100 | machvec= [IA64] Force the use of a particular machine-vector | 1097 | machvec= [IA64] Force the use of a particular machine-vector |
1101 | (machvec) in a generic kernel. | 1098 | (machvec) in a generic kernel. |
1102 | Example: machvec=hpzx1_swiotlb | 1099 | Example: machvec=hpzx1_swiotlb |
@@ -1525,6 +1522,8 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1525 | This is normally done in pci_enable_device(), | 1522 | This is normally done in pci_enable_device(), |
1526 | so this option is a temporary workaround | 1523 | so this option is a temporary workaround |
1527 | for broken drivers that don't call it. | 1524 | for broken drivers that don't call it. |
1525 | skip_isa_align [X86] do not align io start addr, so can | ||
1526 | handle more pci cards | ||
1528 | firmware [ARM] Do not re-enumerate the bus but instead | 1527 | firmware [ARM] Do not re-enumerate the bus but instead |
1529 | just use the configuration from the | 1528 | just use the configuration from the |
1530 | bootloader. This is currently used on | 1529 | bootloader. This is currently used on |
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c index 4c1fc65a8b3d..3be8ab2a886a 100644 --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c | |||
@@ -131,6 +131,9 @@ struct device | |||
131 | /* Any queues attached to this device */ | 131 | /* Any queues attached to this device */ |
132 | struct virtqueue *vq; | 132 | struct virtqueue *vq; |
133 | 133 | ||
134 | /* Handle status being finalized (ie. feature bits stable). */ | ||
135 | void (*ready)(struct device *me); | ||
136 | |||
134 | /* Device-specific data. */ | 137 | /* Device-specific data. */ |
135 | void *priv; | 138 | void *priv; |
136 | }; | 139 | }; |
@@ -925,24 +928,40 @@ static void enable_fd(int fd, struct virtqueue *vq) | |||
925 | write(waker_fd, &vq->dev->fd, sizeof(vq->dev->fd)); | 928 | write(waker_fd, &vq->dev->fd, sizeof(vq->dev->fd)); |
926 | } | 929 | } |
927 | 930 | ||
928 | /* When the Guest asks us to reset a device, it's is fairly easy. */ | 931 | /* When the Guest tells us they updated the status field, we handle it. */ |
929 | static void reset_device(struct device *dev) | 932 | static void update_device_status(struct device *dev) |
930 | { | 933 | { |
931 | struct virtqueue *vq; | 934 | struct virtqueue *vq; |
932 | 935 | ||
933 | verbose("Resetting device %s\n", dev->name); | 936 | /* This is a reset. */ |
934 | /* Clear the status. */ | 937 | if (dev->desc->status == 0) { |
935 | dev->desc->status = 0; | 938 | verbose("Resetting device %s\n", dev->name); |
936 | 939 | ||
937 | /* Clear any features they've acked. */ | 940 | /* Clear any features they've acked. */ |
938 | memset(get_feature_bits(dev) + dev->desc->feature_len, 0, | 941 | memset(get_feature_bits(dev) + dev->desc->feature_len, 0, |
939 | dev->desc->feature_len); | 942 | dev->desc->feature_len); |
940 | 943 | ||
941 | /* Zero out the virtqueues. */ | 944 | /* Zero out the virtqueues. */ |
942 | for (vq = dev->vq; vq; vq = vq->next) { | 945 | for (vq = dev->vq; vq; vq = vq->next) { |
943 | memset(vq->vring.desc, 0, | 946 | memset(vq->vring.desc, 0, |
944 | vring_size(vq->config.num, getpagesize())); | 947 | vring_size(vq->config.num, getpagesize())); |
945 | vq->last_avail_idx = 0; | 948 | vq->last_avail_idx = 0; |
949 | } | ||
950 | } else if (dev->desc->status & VIRTIO_CONFIG_S_FAILED) { | ||
951 | warnx("Device %s configuration FAILED", dev->name); | ||
952 | } else if (dev->desc->status & VIRTIO_CONFIG_S_DRIVER_OK) { | ||
953 | unsigned int i; | ||
954 | |||
955 | verbose("Device %s OK: offered", dev->name); | ||
956 | for (i = 0; i < dev->desc->feature_len; i++) | ||
957 | verbose(" %08x", get_feature_bits(dev)[i]); | ||
958 | verbose(", accepted"); | ||
959 | for (i = 0; i < dev->desc->feature_len; i++) | ||
960 | verbose(" %08x", get_feature_bits(dev) | ||
961 | [dev->desc->feature_len+i]); | ||
962 | |||
963 | if (dev->ready) | ||
964 | dev->ready(dev); | ||
946 | } | 965 | } |
947 | } | 966 | } |
948 | 967 | ||
@@ -954,9 +973,9 @@ static void handle_output(int fd, unsigned long addr) | |||
954 | 973 | ||
955 | /* Check each device and virtqueue. */ | 974 | /* Check each device and virtqueue. */ |
956 | for (i = devices.dev; i; i = i->next) { | 975 | for (i = devices.dev; i; i = i->next) { |
957 | /* Notifications to device descriptors reset the device. */ | 976 | /* Notifications to device descriptors update device status. */ |
958 | if (from_guest_phys(addr) == i->desc) { | 977 | if (from_guest_phys(addr) == i->desc) { |
959 | reset_device(i); | 978 | update_device_status(i); |
960 | return; | 979 | return; |
961 | } | 980 | } |
962 | 981 | ||
@@ -1170,6 +1189,7 @@ static struct device *new_device(const char *name, u16 type, int fd, | |||
1170 | dev->handle_input = handle_input; | 1189 | dev->handle_input = handle_input; |
1171 | dev->name = name; | 1190 | dev->name = name; |
1172 | dev->vq = NULL; | 1191 | dev->vq = NULL; |
1192 | dev->ready = NULL; | ||
1173 | 1193 | ||
1174 | /* Append to device list. Prepending to a single-linked list is | 1194 | /* Append to device list. Prepending to a single-linked list is |
1175 | * easier, but the user expects the devices to be arranged on the bus | 1195 | * easier, but the user expects the devices to be arranged on the bus |
@@ -1398,7 +1418,7 @@ static bool service_io(struct device *dev) | |||
1398 | struct vblk_info *vblk = dev->priv; | 1418 | struct vblk_info *vblk = dev->priv; |
1399 | unsigned int head, out_num, in_num, wlen; | 1419 | unsigned int head, out_num, in_num, wlen; |
1400 | int ret; | 1420 | int ret; |
1401 | struct virtio_blk_inhdr *in; | 1421 | u8 *in; |
1402 | struct virtio_blk_outhdr *out; | 1422 | struct virtio_blk_outhdr *out; |
1403 | struct iovec iov[dev->vq->vring.num]; | 1423 | struct iovec iov[dev->vq->vring.num]; |
1404 | off64_t off; | 1424 | off64_t off; |
@@ -1416,7 +1436,7 @@ static bool service_io(struct device *dev) | |||
1416 | head, out_num, in_num); | 1436 | head, out_num, in_num); |
1417 | 1437 | ||
1418 | out = convert(&iov[0], struct virtio_blk_outhdr); | 1438 | out = convert(&iov[0], struct virtio_blk_outhdr); |
1419 | in = convert(&iov[out_num+in_num-1], struct virtio_blk_inhdr); | 1439 | in = convert(&iov[out_num+in_num-1], u8); |
1420 | off = out->sector * 512; | 1440 | off = out->sector * 512; |
1421 | 1441 | ||
1422 | /* The block device implements "barriers", where the Guest indicates | 1442 | /* The block device implements "barriers", where the Guest indicates |
@@ -1430,7 +1450,7 @@ static bool service_io(struct device *dev) | |||
1430 | * It'd be nice if we supported eject, for example, but we don't. */ | 1450 | * It'd be nice if we supported eject, for example, but we don't. */ |
1431 | if (out->type & VIRTIO_BLK_T_SCSI_CMD) { | 1451 | if (out->type & VIRTIO_BLK_T_SCSI_CMD) { |
1432 | fprintf(stderr, "Scsi commands unsupported\n"); | 1452 | fprintf(stderr, "Scsi commands unsupported\n"); |
1433 | in->status = VIRTIO_BLK_S_UNSUPP; | 1453 | *in = VIRTIO_BLK_S_UNSUPP; |
1434 | wlen = sizeof(*in); | 1454 | wlen = sizeof(*in); |
1435 | } else if (out->type & VIRTIO_BLK_T_OUT) { | 1455 | } else if (out->type & VIRTIO_BLK_T_OUT) { |
1436 | /* Write */ | 1456 | /* Write */ |
@@ -1453,7 +1473,7 @@ static bool service_io(struct device *dev) | |||
1453 | errx(1, "Write past end %llu+%u", off, ret); | 1473 | errx(1, "Write past end %llu+%u", off, ret); |
1454 | } | 1474 | } |
1455 | wlen = sizeof(*in); | 1475 | wlen = sizeof(*in); |
1456 | in->status = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); | 1476 | *in = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); |
1457 | } else { | 1477 | } else { |
1458 | /* Read */ | 1478 | /* Read */ |
1459 | 1479 | ||
@@ -1466,10 +1486,10 @@ static bool service_io(struct device *dev) | |||
1466 | verbose("READ from sector %llu: %i\n", out->sector, ret); | 1486 | verbose("READ from sector %llu: %i\n", out->sector, ret); |
1467 | if (ret >= 0) { | 1487 | if (ret >= 0) { |
1468 | wlen = sizeof(*in) + ret; | 1488 | wlen = sizeof(*in) + ret; |
1469 | in->status = VIRTIO_BLK_S_OK; | 1489 | *in = VIRTIO_BLK_S_OK; |
1470 | } else { | 1490 | } else { |
1471 | wlen = sizeof(*in); | 1491 | wlen = sizeof(*in); |
1472 | in->status = VIRTIO_BLK_S_IOERR; | 1492 | *in = VIRTIO_BLK_S_IOERR; |
1473 | } | 1493 | } |
1474 | } | 1494 | } |
1475 | 1495 | ||
diff --git a/Documentation/powerpc/mpc52xx-device-tree-bindings.txt b/Documentation/powerpc/mpc52xx-device-tree-bindings.txt index cda7a7dffa6d..6f12f1c79c0c 100644 --- a/Documentation/powerpc/mpc52xx-device-tree-bindings.txt +++ b/Documentation/powerpc/mpc52xx-device-tree-bindings.txt | |||
@@ -237,6 +237,17 @@ Each GPIO controller node should have the empty property gpio-controller and | |||
237 | according to the bit numbers in the GPIO control registers. The second cell | 237 | according to the bit numbers in the GPIO control registers. The second cell |
238 | is for flags which is currently unsused. | 238 | is for flags which is currently unsused. |
239 | 239 | ||
240 | 8) FEC nodes | ||
241 | The FEC node can specify one of the following properties to configure | ||
242 | the MII link: | ||
243 | "fsl,7-wire-mode" - An empty property that specifies the link uses 7-wire | ||
244 | mode instead of MII | ||
245 | "current-speed" - Specifies that the MII should be configured for a fixed | ||
246 | speed. This property should contain two cells. The | ||
247 | first cell specifies the speed in Mbps and the second | ||
248 | should be '0' for half duplex and '1' for full duplex | ||
249 | "phy-handle" - Contains a phandle to an Ethernet PHY. | ||
250 | |||
240 | IV - Extra Notes | 251 | IV - Extra Notes |
241 | ================ | 252 | ================ |
242 | 253 | ||
diff --git a/Documentation/scheduler/sched-design.txt b/Documentation/scheduler/sched-design.txt deleted file mode 100644 index 1605bf0cba8b..000000000000 --- a/Documentation/scheduler/sched-design.txt +++ /dev/null | |||
@@ -1,165 +0,0 @@ | |||
1 | Goals, Design and Implementation of the | ||
2 | new ultra-scalable O(1) scheduler | ||
3 | |||
4 | |||
5 | This is an edited version of an email Ingo Molnar sent to | ||
6 | lkml on 4 Jan 2002. It describes the goals, design, and | ||
7 | implementation of Ingo's new ultra-scalable O(1) scheduler. | ||
8 | Last Updated: 18 April 2002. | ||
9 | |||
10 | |||
11 | Goal | ||
12 | ==== | ||
13 | |||
14 | The main goal of the new scheduler is to keep all the good things we know | ||
15 | and love about the current Linux scheduler: | ||
16 | |||
17 | - good interactive performance even during high load: if the user | ||
18 | types or clicks then the system must react instantly and must execute | ||
19 | the user tasks smoothly, even during considerable background load. | ||
20 | |||
21 | - good scheduling/wakeup performance with 1-2 runnable processes. | ||
22 | |||
23 | - fairness: no process should stay without any timeslice for any | ||
24 | unreasonable amount of time. No process should get an unjustly high | ||
25 | amount of CPU time. | ||
26 | |||
27 | - priorities: less important tasks can be started with lower priority, | ||
28 | more important tasks with higher priority. | ||
29 | |||
30 | - SMP efficiency: no CPU should stay idle if there is work to do. | ||
31 | |||
32 | - SMP affinity: processes which run on one CPU should stay affine to | ||
33 | that CPU. Processes should not bounce between CPUs too frequently. | ||
34 | |||
35 | - plus additional scheduler features: RT scheduling, CPU binding. | ||
36 | |||
37 | and the goal is also to add a few new things: | ||
38 | |||
39 | - fully O(1) scheduling. Are you tired of the recalculation loop | ||
40 | blowing the L1 cache away every now and then? Do you think the goodness | ||
41 | loop is taking a bit too long to finish if there are lots of runnable | ||
42 | processes? This new scheduler takes no prisoners: wakeup(), schedule(), | ||
43 | the timer interrupt are all O(1) algorithms. There is no recalculation | ||
44 | loop. There is no goodness loop either. | ||
45 | |||
46 | - 'perfect' SMP scalability. With the new scheduler there is no 'big' | ||
47 | runqueue_lock anymore - it's all per-CPU runqueues and locks - two | ||
48 | tasks on two separate CPUs can wake up, schedule and context-switch | ||
49 | completely in parallel, without any interlocking. All | ||
50 | scheduling-relevant data is structured for maximum scalability. | ||
51 | |||
52 | - better SMP affinity. The old scheduler has a particular weakness that | ||
53 | causes the random bouncing of tasks between CPUs if/when higher | ||
54 | priority/interactive tasks, this was observed and reported by many | ||
55 | people. The reason is that the timeslice recalculation loop first needs | ||
56 | every currently running task to consume its timeslice. But when this | ||
57 | happens on eg. an 8-way system, then this property starves an | ||
58 | increasing number of CPUs from executing any process. Once the last | ||
59 | task that has a timeslice left has finished using up that timeslice, | ||
60 | the recalculation loop is triggered and other CPUs can start executing | ||
61 | tasks again - after having idled around for a number of timer ticks. | ||
62 | The more CPUs, the worse this effect. | ||
63 | |||
64 | Furthermore, this same effect causes the bouncing effect as well: | ||
65 | whenever there is such a 'timeslice squeeze' of the global runqueue, | ||
66 | idle processors start executing tasks which are not affine to that CPU. | ||
67 | (because the affine tasks have finished off their timeslices already.) | ||
68 | |||
69 | The new scheduler solves this problem by distributing timeslices on a | ||
70 | per-CPU basis, without having any global synchronization or | ||
71 | recalculation. | ||
72 | |||
73 | - batch scheduling. A significant proportion of computing-intensive tasks | ||
74 | benefit from batch-scheduling, where timeslices are long and processes | ||
75 | are roundrobin scheduled. The new scheduler does such batch-scheduling | ||
76 | of the lowest priority tasks - so nice +19 jobs will get | ||
77 | 'batch-scheduled' automatically. With this scheduler, nice +19 jobs are | ||
78 | in essence SCHED_IDLE, from an interactiveness point of view. | ||
79 | |||
80 | - handle extreme loads more smoothly, without breakdown and scheduling | ||
81 | storms. | ||
82 | |||
83 | - O(1) RT scheduling. For those RT folks who are paranoid about the | ||
84 | O(nr_running) property of the goodness loop and the recalculation loop. | ||
85 | |||
86 | - run fork()ed children before the parent. Andrea has pointed out the | ||
87 | advantages of this a few months ago, but patches for this feature | ||
88 | do not work with the old scheduler as well as they should, | ||
89 | because idle processes often steal the new child before the fork()ing | ||
90 | CPU gets to execute it. | ||
91 | |||
92 | |||
93 | Design | ||
94 | ====== | ||
95 | |||
96 | The core of the new scheduler contains the following mechanisms: | ||
97 | |||
98 | - *two* priority-ordered 'priority arrays' per CPU. There is an 'active' | ||
99 | array and an 'expired' array. The active array contains all tasks that | ||
100 | are affine to this CPU and have timeslices left. The expired array | ||
101 | contains all tasks which have used up their timeslices - but this array | ||
102 | is kept sorted as well. The active and expired array is not accessed | ||
103 | directly, it's accessed through two pointers in the per-CPU runqueue | ||
104 | structure. If all active tasks are used up then we 'switch' the two | ||
105 | pointers and from now on the ready-to-go (former-) expired array is the | ||
106 | active array - and the empty active array serves as the new collector | ||
107 | for expired tasks. | ||
108 | |||
109 | - there is a 64-bit bitmap cache for array indices. Finding the highest | ||
110 | priority task is thus a matter of two x86 BSFL bit-search instructions. | ||
111 | |||
112 | the split-array solution enables us to have an arbitrary number of active | ||
113 | and expired tasks, and the recalculation of timeslices can be done | ||
114 | immediately when the timeslice expires. Because the arrays are always | ||
115 | access through the pointers in the runqueue, switching the two arrays can | ||
116 | be done very quickly. | ||
117 | |||
118 | this is a hybride priority-list approach coupled with roundrobin | ||
119 | scheduling and the array-switch method of distributing timeslices. | ||
120 | |||
121 | - there is a per-task 'load estimator'. | ||
122 | |||
123 | one of the toughest things to get right is good interactive feel during | ||
124 | heavy system load. While playing with various scheduler variants i found | ||
125 | that the best interactive feel is achieved not by 'boosting' interactive | ||
126 | tasks, but by 'punishing' tasks that want to use more CPU time than there | ||
127 | is available. This method is also much easier to do in an O(1) fashion. | ||
128 | |||
129 | to establish the actual 'load' the task contributes to the system, a | ||
130 | complex-looking but pretty accurate method is used: there is a 4-entry | ||
131 | 'history' ringbuffer of the task's activities during the last 4 seconds. | ||
132 | This ringbuffer is operated without much overhead. The entries tell the | ||
133 | scheduler a pretty accurate load-history of the task: has it used up more | ||
134 | CPU time or less during the past N seconds. [the size '4' and the interval | ||
135 | of 4x 1 seconds was found by lots of experimentation - this part is | ||
136 | flexible and can be changed in both directions.] | ||
137 | |||
138 | the penalty a task gets for generating more load than the CPU can handle | ||
139 | is a priority decrease - there is a maximum amount to this penalty | ||
140 | relative to their static priority, so even fully CPU-bound tasks will | ||
141 | observe each other's priorities, and will share the CPU accordingly. | ||
142 | |||
143 | the SMP load-balancer can be extended/switched with additional parallel | ||
144 | computing and cache hierarchy concepts: NUMA scheduling, multi-core CPUs | ||
145 | can be supported easily by changing the load-balancer. Right now it's | ||
146 | tuned for my SMP systems. | ||
147 | |||
148 | i skipped the prev->mm == next->mm advantage - no workload i know of shows | ||
149 | any sensitivity to this. It can be added back by sacrificing O(1) | ||
150 | schedule() [the current and one-lower priority list can be searched for a | ||
151 | that->mm == current->mm condition], but costs a fair number of cycles | ||
152 | during a number of important workloads, so i wanted to avoid this as much | ||
153 | as possible. | ||
154 | |||
155 | - the SMP idle-task startup code was still racy and the new scheduler | ||
156 | triggered this. So i streamlined the idle-setup code a bit. We do not call | ||
157 | into schedule() before all processors have started up fully and all idle | ||
158 | threads are in place. | ||
159 | |||
160 | - the patch also cleans up a number of aspects of sched.c - moves code | ||
161 | into other areas of the kernel where it's appropriate, and simplifies | ||
162 | certain code paths and data constructs. As a result, the new scheduler's | ||
163 | code is smaller than the old one. | ||
164 | |||
165 | Ingo | ||
diff --git a/Documentation/scsi/ChangeLog.megaraid_sas b/Documentation/scsi/ChangeLog.megaraid_sas index 91c81db0ba71..716fcc1cafb5 100644 --- a/Documentation/scsi/ChangeLog.megaraid_sas +++ b/Documentation/scsi/ChangeLog.megaraid_sas | |||
@@ -1,3 +1,25 @@ | |||
1 | 1 Release Date : Mon. March 10 11:02:31 PDT 2008 - | ||
2 | (emaild-id:megaraidlinux@lsi.com) | ||
3 | Sumant Patro | ||
4 | Bo Yang | ||
5 | |||
6 | 2 Current Version : 00.00.03.20-RC1 | ||
7 | 3 Older Version : 00.00.03.16 | ||
8 | |||
9 | 1. Rollback the sense info implementation | ||
10 | Sense buffer ptr data type in the ioctl path is reverted back | ||
11 | to u32 * as in previous versions of driver. | ||
12 | |||
13 | 2. Fixed the driver frame count. | ||
14 | When Driver sent wrong frame count to firmware. As this | ||
15 | particular command is sent to drive, FW is seeing continuous | ||
16 | chip resets and so the command will timeout. | ||
17 | |||
18 | 3. Add the new controller(1078DE) support to the driver | ||
19 | and Increase the max_wait to 60 from 10 in the controller | ||
20 | operational status. With this max_wait increase, driver will | ||
21 | make sure the FW will finish the pending cmd for KDUMP case. | ||
22 | |||
1 | 1 Release Date : Thur. Nov. 07 16:30:43 PST 2007 - | 23 | 1 Release Date : Thur. Nov. 07 16:30:43 PST 2007 - |
2 | (emaild-id:megaraidlinux@lsi.com) | 24 | (emaild-id:megaraidlinux@lsi.com) |
3 | Sumant Patro | 25 | Sumant Patro |
diff --git a/Documentation/vm/slabinfo.c b/Documentation/vm/slabinfo.c index d3ce295bffac..e4230ed16ee7 100644 --- a/Documentation/vm/slabinfo.c +++ b/Documentation/vm/slabinfo.c | |||
@@ -38,7 +38,7 @@ struct slabinfo { | |||
38 | unsigned long alloc_from_partial, alloc_slab, free_slab, alloc_refill; | 38 | unsigned long alloc_from_partial, alloc_slab, free_slab, alloc_refill; |
39 | unsigned long cpuslab_flush, deactivate_full, deactivate_empty; | 39 | unsigned long cpuslab_flush, deactivate_full, deactivate_empty; |
40 | unsigned long deactivate_to_head, deactivate_to_tail; | 40 | unsigned long deactivate_to_head, deactivate_to_tail; |
41 | unsigned long deactivate_remote_frees; | 41 | unsigned long deactivate_remote_frees, order_fallback; |
42 | int numa[MAX_NODES]; | 42 | int numa[MAX_NODES]; |
43 | int numa_partial[MAX_NODES]; | 43 | int numa_partial[MAX_NODES]; |
44 | } slabinfo[MAX_SLABS]; | 44 | } slabinfo[MAX_SLABS]; |
@@ -293,7 +293,7 @@ int line = 0; | |||
293 | void first_line(void) | 293 | void first_line(void) |
294 | { | 294 | { |
295 | if (show_activity) | 295 | if (show_activity) |
296 | printf("Name Objects Alloc Free %%Fast\n"); | 296 | printf("Name Objects Alloc Free %%Fast Fallb O\n"); |
297 | else | 297 | else |
298 | printf("Name Objects Objsize Space " | 298 | printf("Name Objects Objsize Space " |
299 | "Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n"); | 299 | "Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n"); |
@@ -573,11 +573,12 @@ void slabcache(struct slabinfo *s) | |||
573 | total_alloc = s->alloc_fastpath + s->alloc_slowpath; | 573 | total_alloc = s->alloc_fastpath + s->alloc_slowpath; |
574 | total_free = s->free_fastpath + s->free_slowpath; | 574 | total_free = s->free_fastpath + s->free_slowpath; |
575 | 575 | ||
576 | printf("%-21s %8ld %8ld %8ld %3ld %3ld \n", | 576 | printf("%-21s %8ld %10ld %10ld %3ld %3ld %5ld %1d\n", |
577 | s->name, s->objects, | 577 | s->name, s->objects, |
578 | total_alloc, total_free, | 578 | total_alloc, total_free, |
579 | total_alloc ? (s->alloc_fastpath * 100 / total_alloc) : 0, | 579 | total_alloc ? (s->alloc_fastpath * 100 / total_alloc) : 0, |
580 | total_free ? (s->free_fastpath * 100 / total_free) : 0); | 580 | total_free ? (s->free_fastpath * 100 / total_free) : 0, |
581 | s->order_fallback, s->order); | ||
581 | } | 582 | } |
582 | else | 583 | else |
583 | printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n", | 584 | printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n", |
@@ -1188,6 +1189,7 @@ void read_slab_dir(void) | |||
1188 | slab->deactivate_to_head = get_obj("deactivate_to_head"); | 1189 | slab->deactivate_to_head = get_obj("deactivate_to_head"); |
1189 | slab->deactivate_to_tail = get_obj("deactivate_to_tail"); | 1190 | slab->deactivate_to_tail = get_obj("deactivate_to_tail"); |
1190 | slab->deactivate_remote_frees = get_obj("deactivate_remote_frees"); | 1191 | slab->deactivate_remote_frees = get_obj("deactivate_remote_frees"); |
1192 | slab->order_fallback = get_obj("order_fallback"); | ||
1191 | chdir(".."); | 1193 | chdir(".."); |
1192 | if (slab->name[0] == ':') | 1194 | if (slab->name[0] == ':') |
1193 | alias_targets++; | 1195 | alias_targets++; |
diff --git a/MAINTAINERS b/MAINTAINERS index c3a533d5d382..abe27871ad6a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -1196,9 +1196,9 @@ S: Maintained | |||
1196 | 1196 | ||
1197 | CPUSETS | 1197 | CPUSETS |
1198 | P: Paul Jackson | 1198 | P: Paul Jackson |
1199 | P: Simon Derr | 1199 | P: Paul Menage |
1200 | M: pj@sgi.com | 1200 | M: pj@sgi.com |
1201 | M: simon.derr@bull.net | 1201 | M: menage@google.com |
1202 | L: linux-kernel@vger.kernel.org | 1202 | L: linux-kernel@vger.kernel.org |
1203 | W: http://www.bullopensource.org/cpuset/ | 1203 | W: http://www.bullopensource.org/cpuset/ |
1204 | S: Supported | 1204 | S: Supported |
@@ -1557,6 +1557,14 @@ M: raisch@de.ibm.com | |||
1557 | L: general@lists.openfabrics.org | 1557 | L: general@lists.openfabrics.org |
1558 | S: Supported | 1558 | S: Supported |
1559 | 1559 | ||
1560 | EMBEDDED LINUX | ||
1561 | P: Paul Gortmaker | ||
1562 | M: paul.gortmaker@windriver.com | ||
1563 | P David Woodhouse | ||
1564 | M: dwmw2@infradead.org | ||
1565 | L: linux-embedded@vger.kernel.org | ||
1566 | S: Maintained | ||
1567 | |||
1560 | EMULEX LPFC FC SCSI DRIVER | 1568 | EMULEX LPFC FC SCSI DRIVER |
1561 | P: James Smart | 1569 | P: James Smart |
1562 | M: james.smart@emulex.com | 1570 | M: james.smart@emulex.com |
@@ -3122,7 +3130,7 @@ PCI SUBSYSTEM | |||
3122 | P: Jesse Barnes | 3130 | P: Jesse Barnes |
3123 | M: jbarnes@virtuousgeek.org | 3131 | M: jbarnes@virtuousgeek.org |
3124 | L: linux-kernel@vger.kernel.org | 3132 | L: linux-kernel@vger.kernel.org |
3125 | L: linux-pci@atrey.karlin.mff.cuni.cz | 3133 | L: linux-pci@vger.kernel.org |
3126 | T: git kernel.org:/pub/scm/linux/kernel/git/jbarnes/pci-2.6.git | 3134 | T: git kernel.org:/pub/scm/linux/kernel/git/jbarnes/pci-2.6.git |
3127 | S: Supported | 3135 | S: Supported |
3128 | 3136 | ||
@@ -4043,6 +4051,12 @@ L: linux-usb@vger.kernel.org | |||
4043 | S: Maintained | 4051 | S: Maintained |
4044 | W: http://www.kroah.com/linux-usb/ | 4052 | W: http://www.kroah.com/linux-usb/ |
4045 | 4053 | ||
4054 | USB CYPRESS C67X00 DRIVER | ||
4055 | P: Peter Korsgaard | ||
4056 | M: jacmet@sunsite.dk | ||
4057 | L: linux-usb@vger.kernel.org | ||
4058 | S: Maintained | ||
4059 | |||
4046 | USB DAVICOM DM9601 DRIVER | 4060 | USB DAVICOM DM9601 DRIVER |
4047 | P: Peter Korsgaard | 4061 | P: Peter Korsgaard |
4048 | M: jacmet@sunsite.dk | 4062 | M: jacmet@sunsite.dk |
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 2 | 1 | VERSION = 2 |
2 | PATCHLEVEL = 6 | 2 | PATCHLEVEL = 6 |
3 | SUBLEVEL = 25 | 3 | SUBLEVEL = 26 |
4 | EXTRAVERSION = | 4 | EXTRAVERSION = -rc1 |
5 | NAME = Funky Weasel is Jiggy wit it | 5 | NAME = Funky Weasel is Jiggy wit it |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
@@ -794,7 +794,7 @@ endif # ifdef CONFIG_KALLSYMS | |||
794 | quiet_cmd_vmlinux-modpost = LD $@ | 794 | quiet_cmd_vmlinux-modpost = LD $@ |
795 | cmd_vmlinux-modpost = $(LD) $(LDFLAGS) -r -o $@ \ | 795 | cmd_vmlinux-modpost = $(LD) $(LDFLAGS) -r -o $@ \ |
796 | $(vmlinux-init) --start-group $(vmlinux-main) --end-group \ | 796 | $(vmlinux-init) --start-group $(vmlinux-main) --end-group \ |
797 | $(filter-out $(vmlinux-init) $(vmlinux-main) $(vmlinux-lds) FORCE ,$^) | 797 | $(filter-out $(vmlinux-init) $(vmlinux-main) FORCE ,$^) |
798 | define rule_vmlinux-modpost | 798 | define rule_vmlinux-modpost |
799 | : | 799 | : |
800 | +$(call cmd,vmlinux-modpost) | 800 | +$(call cmd,vmlinux-modpost) |
@@ -818,7 +818,9 @@ endif | |||
818 | ifdef CONFIG_KALLSYMS | 818 | ifdef CONFIG_KALLSYMS |
819 | .tmp_vmlinux1: vmlinux.o | 819 | .tmp_vmlinux1: vmlinux.o |
820 | endif | 820 | endif |
821 | vmlinux.o: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) FORCE | 821 | |
822 | modpost-init := $(filter-out init/built-in.o, $(vmlinux-init)) | ||
823 | vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE | ||
822 | $(call if_changed_rule,vmlinux-modpost) | 824 | $(call if_changed_rule,vmlinux-modpost) |
823 | 825 | ||
824 | # The actual objects are generated when descending, | 826 | # The actual objects are generated when descending, |
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 9fee37e2596f..32ca1b927307 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c | |||
@@ -981,27 +981,18 @@ asmlinkage int | |||
981 | osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, | 981 | osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, |
982 | struct timeval32 __user *tvp) | 982 | struct timeval32 __user *tvp) |
983 | { | 983 | { |
984 | fd_set_bits fds; | 984 | s64 timeout = MAX_SCHEDULE_TIMEOUT; |
985 | char *bits; | ||
986 | size_t size; | ||
987 | long timeout; | ||
988 | int ret = -EINVAL; | ||
989 | struct fdtable *fdt; | ||
990 | int max_fds; | ||
991 | |||
992 | timeout = MAX_SCHEDULE_TIMEOUT; | ||
993 | if (tvp) { | 985 | if (tvp) { |
994 | time_t sec, usec; | 986 | time_t sec, usec; |
995 | 987 | ||
996 | if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp)) | 988 | if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp)) |
997 | || __get_user(sec, &tvp->tv_sec) | 989 | || __get_user(sec, &tvp->tv_sec) |
998 | || __get_user(usec, &tvp->tv_usec)) { | 990 | || __get_user(usec, &tvp->tv_usec)) { |
999 | ret = -EFAULT; | 991 | return -EFAULT; |
1000 | goto out_nofds; | ||
1001 | } | 992 | } |
1002 | 993 | ||
1003 | if (sec < 0 || usec < 0) | 994 | if (sec < 0 || usec < 0) |
1004 | goto out_nofds; | 995 | return -EINVAL; |
1005 | 996 | ||
1006 | if ((unsigned long) sec < MAX_SELECT_SECONDS) { | 997 | if ((unsigned long) sec < MAX_SELECT_SECONDS) { |
1007 | timeout = (usec + 1000000/HZ - 1) / (1000000/HZ); | 998 | timeout = (usec + 1000000/HZ - 1) / (1000000/HZ); |
@@ -1009,60 +1000,8 @@ osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, | |||
1009 | } | 1000 | } |
1010 | } | 1001 | } |
1011 | 1002 | ||
1012 | rcu_read_lock(); | ||
1013 | fdt = files_fdtable(current->files); | ||
1014 | max_fds = fdt->max_fds; | ||
1015 | rcu_read_unlock(); | ||
1016 | if (n < 0 || n > max_fds) | ||
1017 | goto out_nofds; | ||
1018 | |||
1019 | /* | ||
1020 | * We need 6 bitmaps (in/out/ex for both incoming and outgoing), | ||
1021 | * since we used fdset we need to allocate memory in units of | ||
1022 | * long-words. | ||
1023 | */ | ||
1024 | ret = -ENOMEM; | ||
1025 | size = FDS_BYTES(n); | ||
1026 | bits = kmalloc(6 * size, GFP_KERNEL); | ||
1027 | if (!bits) | ||
1028 | goto out_nofds; | ||
1029 | fds.in = (unsigned long *) bits; | ||
1030 | fds.out = (unsigned long *) (bits + size); | ||
1031 | fds.ex = (unsigned long *) (bits + 2*size); | ||
1032 | fds.res_in = (unsigned long *) (bits + 3*size); | ||
1033 | fds.res_out = (unsigned long *) (bits + 4*size); | ||
1034 | fds.res_ex = (unsigned long *) (bits + 5*size); | ||
1035 | |||
1036 | if ((ret = get_fd_set(n, inp->fds_bits, fds.in)) || | ||
1037 | (ret = get_fd_set(n, outp->fds_bits, fds.out)) || | ||
1038 | (ret = get_fd_set(n, exp->fds_bits, fds.ex))) | ||
1039 | goto out; | ||
1040 | zero_fd_set(n, fds.res_in); | ||
1041 | zero_fd_set(n, fds.res_out); | ||
1042 | zero_fd_set(n, fds.res_ex); | ||
1043 | |||
1044 | ret = do_select(n, &fds, &timeout); | ||
1045 | |||
1046 | /* OSF does not copy back the remaining time. */ | 1003 | /* OSF does not copy back the remaining time. */ |
1047 | 1004 | return core_sys_select(n, inp, outp, exp, &timeout); | |
1048 | if (ret < 0) | ||
1049 | goto out; | ||
1050 | if (!ret) { | ||
1051 | ret = -ERESTARTNOHAND; | ||
1052 | if (signal_pending(current)) | ||
1053 | goto out; | ||
1054 | ret = 0; | ||
1055 | } | ||
1056 | |||
1057 | if (set_fd_set(n, inp->fds_bits, fds.res_in) || | ||
1058 | set_fd_set(n, outp->fds_bits, fds.res_out) || | ||
1059 | set_fd_set(n, exp->fds_bits, fds.res_ex)) | ||
1060 | ret = -EFAULT; | ||
1061 | |||
1062 | out: | ||
1063 | kfree(bits); | ||
1064 | out_nofds: | ||
1065 | return ret; | ||
1066 | } | 1005 | } |
1067 | 1006 | ||
1068 | struct rusage32 { | 1007 | struct rusage32 { |
diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c index 9bd1870d980e..0128687ba0f7 100644 --- a/arch/arm/kernel/sys_arm.c +++ b/arch/arm/kernel/sys_arm.c | |||
@@ -34,23 +34,6 @@ extern unsigned long do_mremap(unsigned long addr, unsigned long old_len, | |||
34 | unsigned long new_len, unsigned long flags, | 34 | unsigned long new_len, unsigned long flags, |
35 | unsigned long new_addr); | 35 | unsigned long new_addr); |
36 | 36 | ||
37 | /* | ||
38 | * sys_pipe() is the normal C calling standard for creating | ||
39 | * a pipe. It's not the way unix traditionally does this, though. | ||
40 | */ | ||
41 | asmlinkage int sys_pipe(unsigned long __user *fildes) | ||
42 | { | ||
43 | int fd[2]; | ||
44 | int error; | ||
45 | |||
46 | error = do_pipe(fd); | ||
47 | if (!error) { | ||
48 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
49 | error = -EFAULT; | ||
50 | } | ||
51 | return error; | ||
52 | } | ||
53 | |||
54 | /* common code for old and new mmaps */ | 37 | /* common code for old and new mmaps */ |
55 | inline long do_mmap2( | 38 | inline long do_mmap2( |
56 | unsigned long addr, unsigned long len, | 39 | unsigned long addr, unsigned long len, |
diff --git a/arch/avr32/kernel/sys_avr32.c b/arch/avr32/kernel/sys_avr32.c index 8deb6003ee62..8e8911e55c8f 100644 --- a/arch/avr32/kernel/sys_avr32.c +++ b/arch/avr32/kernel/sys_avr32.c | |||
@@ -14,19 +14,6 @@ | |||
14 | #include <asm/mman.h> | 14 | #include <asm/mman.h> |
15 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
16 | 16 | ||
17 | asmlinkage int sys_pipe(unsigned long __user *filedes) | ||
18 | { | ||
19 | int fd[2]; | ||
20 | int error; | ||
21 | |||
22 | error = do_pipe(fd); | ||
23 | if (!error) { | ||
24 | if (copy_to_user(filedes, fd, sizeof(fd))) | ||
25 | error = -EFAULT; | ||
26 | } | ||
27 | return error; | ||
28 | } | ||
29 | |||
30 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | 17 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, |
31 | unsigned long prot, unsigned long flags, | 18 | unsigned long prot, unsigned long flags, |
32 | unsigned long fd, off_t offset) | 19 | unsigned long fd, off_t offset) |
diff --git a/arch/blackfin/kernel/sys_bfin.c b/arch/blackfin/kernel/sys_bfin.c index efb7b25a2633..fce49d7cf001 100644 --- a/arch/blackfin/kernel/sys_bfin.c +++ b/arch/blackfin/kernel/sys_bfin.c | |||
@@ -45,23 +45,6 @@ | |||
45 | #include <asm/cacheflush.h> | 45 | #include <asm/cacheflush.h> |
46 | #include <asm/dma.h> | 46 | #include <asm/dma.h> |
47 | 47 | ||
48 | /* | ||
49 | * sys_pipe() is the normal C calling standard for creating | ||
50 | * a pipe. It's not the way unix traditionally does this, though. | ||
51 | */ | ||
52 | asmlinkage int sys_pipe(unsigned long __user *fildes) | ||
53 | { | ||
54 | int fd[2]; | ||
55 | int error; | ||
56 | |||
57 | error = do_pipe(fd); | ||
58 | if (!error) { | ||
59 | if (copy_to_user(fildes, fd, 2 * sizeof(int))) | ||
60 | error = -EFAULT; | ||
61 | } | ||
62 | return error; | ||
63 | } | ||
64 | |||
65 | /* common code for old and new mmaps */ | 48 | /* common code for old and new mmaps */ |
66 | static inline long | 49 | static inline long |
67 | do_mmap2(unsigned long addr, unsigned long len, | 50 | do_mmap2(unsigned long addr, unsigned long len, |
diff --git a/arch/frv/kernel/sys_frv.c b/arch/frv/kernel/sys_frv.c index 04c6b1677ccf..49b2cf2c38f3 100644 --- a/arch/frv/kernel/sys_frv.c +++ b/arch/frv/kernel/sys_frv.c | |||
@@ -28,23 +28,6 @@ | |||
28 | #include <asm/setup.h> | 28 | #include <asm/setup.h> |
29 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
30 | 30 | ||
31 | /* | ||
32 | * sys_pipe() is the normal C calling standard for creating | ||
33 | * a pipe. It's not the way unix traditionally does this, though. | ||
34 | */ | ||
35 | asmlinkage long sys_pipe(unsigned long __user * fildes) | ||
36 | { | ||
37 | int fd[2]; | ||
38 | int error; | ||
39 | |||
40 | error = do_pipe(fd); | ||
41 | if (!error) { | ||
42 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
43 | error = -EFAULT; | ||
44 | } | ||
45 | return error; | ||
46 | } | ||
47 | |||
48 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | 31 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, |
49 | unsigned long prot, unsigned long flags, | 32 | unsigned long prot, unsigned long flags, |
50 | unsigned long fd, unsigned long pgoff) | 33 | unsigned long fd, unsigned long pgoff) |
diff --git a/arch/frv/mm/Makefile b/arch/frv/mm/Makefile index fb8b1d860f46..1bca5ab8a6ab 100644 --- a/arch/frv/mm/Makefile +++ b/arch/frv/mm/Makefile | |||
@@ -6,4 +6,4 @@ obj-y := init.o kmap.o | |||
6 | 6 | ||
7 | obj-$(CONFIG_MMU) += \ | 7 | obj-$(CONFIG_MMU) += \ |
8 | pgalloc.o highmem.o fault.o extable.o cache-page.o tlb-flush.o tlb-miss.o \ | 8 | pgalloc.o highmem.o fault.o extable.o cache-page.o tlb-flush.o tlb-miss.o \ |
9 | mmu-context.o dma-alloc.o unaligned.o elf-fdpic.o | 9 | mmu-context.o dma-alloc.o elf-fdpic.o |
diff --git a/arch/h8300/kernel/sys_h8300.c b/arch/h8300/kernel/sys_h8300.c index 00608be6d567..2745656dcc52 100644 --- a/arch/h8300/kernel/sys_h8300.c +++ b/arch/h8300/kernel/sys_h8300.c | |||
@@ -27,23 +27,6 @@ | |||
27 | #include <asm/traps.h> | 27 | #include <asm/traps.h> |
28 | #include <asm/unistd.h> | 28 | #include <asm/unistd.h> |
29 | 29 | ||
30 | /* | ||
31 | * sys_pipe() is the normal C calling standard for creating | ||
32 | * a pipe. It's not the way unix traditionally does this, though. | ||
33 | */ | ||
34 | asmlinkage int sys_pipe(unsigned long * fildes) | ||
35 | { | ||
36 | int fd[2]; | ||
37 | int error; | ||
38 | |||
39 | error = do_pipe(fd); | ||
40 | if (!error) { | ||
41 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
42 | error = -EFAULT; | ||
43 | } | ||
44 | return error; | ||
45 | } | ||
46 | |||
47 | /* common code for old and new mmaps */ | 30 | /* common code for old and new mmaps */ |
48 | static inline long do_mmap2( | 31 | static inline long do_mmap2( |
49 | unsigned long addr, unsigned long len, | 32 | unsigned long addr, unsigned long len, |
diff --git a/arch/ia64/ia32/ia32_signal.c b/arch/ia64/ia32/ia32_signal.c index 256a7faeda07..b763ca19ef17 100644 --- a/arch/ia64/ia32/ia32_signal.c +++ b/arch/ia64/ia32/ia32_signal.c | |||
@@ -463,7 +463,7 @@ sys32_sigsuspend (int history0, int history1, old_sigset_t mask) | |||
463 | 463 | ||
464 | current->state = TASK_INTERRUPTIBLE; | 464 | current->state = TASK_INTERRUPTIBLE; |
465 | schedule(); | 465 | schedule(); |
466 | set_thread_flag(TIF_RESTORE_SIGMASK); | 466 | set_restore_sigmask(); |
467 | return -ERESTARTNOHAND; | 467 | return -ERESTARTNOHAND; |
468 | } | 468 | } |
469 | 469 | ||
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index c7467f863c7a..19709a079635 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c | |||
@@ -966,7 +966,7 @@ acpi_map_iosapics (void) | |||
966 | fs_initcall(acpi_map_iosapics); | 966 | fs_initcall(acpi_map_iosapics); |
967 | #endif /* CONFIG_ACPI_NUMA */ | 967 | #endif /* CONFIG_ACPI_NUMA */ |
968 | 968 | ||
969 | int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) | 969 | int __ref acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) |
970 | { | 970 | { |
971 | int err; | 971 | int err; |
972 | 972 | ||
diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c index 6dee579f205f..7fd18f54c056 100644 --- a/arch/ia64/kernel/irq.c +++ b/arch/ia64/kernel/irq.c | |||
@@ -183,10 +183,10 @@ void fixup_irqs(void) | |||
183 | { | 183 | { |
184 | unsigned int irq; | 184 | unsigned int irq; |
185 | extern void ia64_process_pending_intr(void); | 185 | extern void ia64_process_pending_intr(void); |
186 | extern void ia64_disable_timer(void); | ||
187 | extern volatile int time_keeper_id; | 186 | extern volatile int time_keeper_id; |
188 | 187 | ||
189 | ia64_disable_timer(); | 188 | /* Mask ITV to disable timer */ |
189 | ia64_set_itv(1 << 16); | ||
190 | 190 | ||
191 | /* | 191 | /* |
192 | * Find a new timesync master | 192 | * Find a new timesync master |
diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c index 396004e8cd14..4547a2092af9 100644 --- a/arch/ia64/kernel/palinfo.c +++ b/arch/ia64/kernel/palinfo.c | |||
@@ -1053,7 +1053,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb, | |||
1053 | return NOTIFY_OK; | 1053 | return NOTIFY_OK; |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | static struct notifier_block palinfo_cpu_notifier __cpuinitdata = | 1056 | static struct notifier_block __refdata palinfo_cpu_notifier = |
1057 | { | 1057 | { |
1058 | .notifier_call = palinfo_cpu_callback, | 1058 | .notifier_call = palinfo_cpu_callback, |
1059 | .priority = 0, | 1059 | .priority = 0, |
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index 7fbb51e10bbe..c1ad27de2dd2 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c | |||
@@ -867,7 +867,7 @@ pfm_rvfree(void *mem, unsigned long size) | |||
867 | } | 867 | } |
868 | 868 | ||
869 | static pfm_context_t * | 869 | static pfm_context_t * |
870 | pfm_context_alloc(void) | 870 | pfm_context_alloc(int ctx_flags) |
871 | { | 871 | { |
872 | pfm_context_t *ctx; | 872 | pfm_context_t *ctx; |
873 | 873 | ||
@@ -878,6 +878,46 @@ pfm_context_alloc(void) | |||
878 | ctx = kzalloc(sizeof(pfm_context_t), GFP_KERNEL); | 878 | ctx = kzalloc(sizeof(pfm_context_t), GFP_KERNEL); |
879 | if (ctx) { | 879 | if (ctx) { |
880 | DPRINT(("alloc ctx @%p\n", ctx)); | 880 | DPRINT(("alloc ctx @%p\n", ctx)); |
881 | |||
882 | /* | ||
883 | * init context protection lock | ||
884 | */ | ||
885 | spin_lock_init(&ctx->ctx_lock); | ||
886 | |||
887 | /* | ||
888 | * context is unloaded | ||
889 | */ | ||
890 | ctx->ctx_state = PFM_CTX_UNLOADED; | ||
891 | |||
892 | /* | ||
893 | * initialization of context's flags | ||
894 | */ | ||
895 | ctx->ctx_fl_block = (ctx_flags & PFM_FL_NOTIFY_BLOCK) ? 1 : 0; | ||
896 | ctx->ctx_fl_system = (ctx_flags & PFM_FL_SYSTEM_WIDE) ? 1: 0; | ||
897 | ctx->ctx_fl_no_msg = (ctx_flags & PFM_FL_OVFL_NO_MSG) ? 1: 0; | ||
898 | /* | ||
899 | * will move to set properties | ||
900 | * ctx->ctx_fl_excl_idle = (ctx_flags & PFM_FL_EXCL_IDLE) ? 1: 0; | ||
901 | */ | ||
902 | |||
903 | /* | ||
904 | * init restart semaphore to locked | ||
905 | */ | ||
906 | init_completion(&ctx->ctx_restart_done); | ||
907 | |||
908 | /* | ||
909 | * activation is used in SMP only | ||
910 | */ | ||
911 | ctx->ctx_last_activation = PFM_INVALID_ACTIVATION; | ||
912 | SET_LAST_CPU(ctx, -1); | ||
913 | |||
914 | /* | ||
915 | * initialize notification message queue | ||
916 | */ | ||
917 | ctx->ctx_msgq_head = ctx->ctx_msgq_tail = 0; | ||
918 | init_waitqueue_head(&ctx->ctx_msgq_wait); | ||
919 | init_waitqueue_head(&ctx->ctx_zombieq); | ||
920 | |||
881 | } | 921 | } |
882 | return ctx; | 922 | return ctx; |
883 | } | 923 | } |
@@ -2165,28 +2205,21 @@ static struct dentry_operations pfmfs_dentry_operations = { | |||
2165 | }; | 2205 | }; |
2166 | 2206 | ||
2167 | 2207 | ||
2168 | static int | 2208 | static struct file * |
2169 | pfm_alloc_fd(struct file **cfile) | 2209 | pfm_alloc_file(pfm_context_t *ctx) |
2170 | { | 2210 | { |
2171 | int fd, ret = 0; | 2211 | struct file *file; |
2172 | struct file *file = NULL; | 2212 | struct inode *inode; |
2173 | struct inode * inode; | 2213 | struct dentry *dentry; |
2174 | char name[32]; | 2214 | char name[32]; |
2175 | struct qstr this; | 2215 | struct qstr this; |
2176 | 2216 | ||
2177 | fd = get_unused_fd(); | ||
2178 | if (fd < 0) return -ENFILE; | ||
2179 | |||
2180 | ret = -ENFILE; | ||
2181 | |||
2182 | file = get_empty_filp(); | ||
2183 | if (!file) goto out; | ||
2184 | |||
2185 | /* | 2217 | /* |
2186 | * allocate a new inode | 2218 | * allocate a new inode |
2187 | */ | 2219 | */ |
2188 | inode = new_inode(pfmfs_mnt->mnt_sb); | 2220 | inode = new_inode(pfmfs_mnt->mnt_sb); |
2189 | if (!inode) goto out; | 2221 | if (!inode) |
2222 | return ERR_PTR(-ENOMEM); | ||
2190 | 2223 | ||
2191 | DPRINT(("new inode ino=%ld @%p\n", inode->i_ino, inode)); | 2224 | DPRINT(("new inode ino=%ld @%p\n", inode->i_ino, inode)); |
2192 | 2225 | ||
@@ -2199,59 +2232,28 @@ pfm_alloc_fd(struct file **cfile) | |||
2199 | this.len = strlen(name); | 2232 | this.len = strlen(name); |
2200 | this.hash = inode->i_ino; | 2233 | this.hash = inode->i_ino; |
2201 | 2234 | ||
2202 | ret = -ENOMEM; | ||
2203 | |||
2204 | /* | 2235 | /* |
2205 | * allocate a new dcache entry | 2236 | * allocate a new dcache entry |
2206 | */ | 2237 | */ |
2207 | file->f_path.dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this); | 2238 | dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this); |
2208 | if (!file->f_path.dentry) goto out; | 2239 | if (!dentry) { |
2240 | iput(inode); | ||
2241 | return ERR_PTR(-ENOMEM); | ||
2242 | } | ||
2209 | 2243 | ||
2210 | file->f_path.dentry->d_op = &pfmfs_dentry_operations; | 2244 | dentry->d_op = &pfmfs_dentry_operations; |
2245 | d_add(dentry, inode); | ||
2211 | 2246 | ||
2212 | d_add(file->f_path.dentry, inode); | 2247 | file = alloc_file(pfmfs_mnt, dentry, FMODE_READ, &pfm_file_ops); |
2213 | file->f_path.mnt = mntget(pfmfs_mnt); | 2248 | if (!file) { |
2214 | file->f_mapping = inode->i_mapping; | 2249 | dput(dentry); |
2250 | return ERR_PTR(-ENFILE); | ||
2251 | } | ||
2215 | 2252 | ||
2216 | file->f_op = &pfm_file_ops; | ||
2217 | file->f_mode = FMODE_READ; | ||
2218 | file->f_flags = O_RDONLY; | 2253 | file->f_flags = O_RDONLY; |
2219 | file->f_pos = 0; | 2254 | file->private_data = ctx; |
2220 | |||
2221 | /* | ||
2222 | * may have to delay until context is attached? | ||
2223 | */ | ||
2224 | fd_install(fd, file); | ||
2225 | |||
2226 | /* | ||
2227 | * the file structure we will use | ||
2228 | */ | ||
2229 | *cfile = file; | ||
2230 | |||
2231 | return fd; | ||
2232 | out: | ||
2233 | if (file) put_filp(file); | ||
2234 | put_unused_fd(fd); | ||
2235 | return ret; | ||
2236 | } | ||
2237 | |||
2238 | static void | ||
2239 | pfm_free_fd(int fd, struct file *file) | ||
2240 | { | ||
2241 | struct files_struct *files = current->files; | ||
2242 | struct fdtable *fdt; | ||
2243 | 2255 | ||
2244 | /* | 2256 | return file; |
2245 | * there ie no fd_uninstall(), so we do it here | ||
2246 | */ | ||
2247 | spin_lock(&files->file_lock); | ||
2248 | fdt = files_fdtable(files); | ||
2249 | rcu_assign_pointer(fdt->fd[fd], NULL); | ||
2250 | spin_unlock(&files->file_lock); | ||
2251 | |||
2252 | if (file) | ||
2253 | put_filp(file); | ||
2254 | put_unused_fd(fd); | ||
2255 | } | 2257 | } |
2256 | 2258 | ||
2257 | static int | 2259 | static int |
@@ -2475,6 +2477,7 @@ pfm_setup_buffer_fmt(struct task_struct *task, struct file *filp, pfm_context_t | |||
2475 | 2477 | ||
2476 | /* link buffer format and context */ | 2478 | /* link buffer format and context */ |
2477 | ctx->ctx_buf_fmt = fmt; | 2479 | ctx->ctx_buf_fmt = fmt; |
2480 | ctx->ctx_fl_is_sampling = 1; /* assume record() is defined */ | ||
2478 | 2481 | ||
2479 | /* | 2482 | /* |
2480 | * check if buffer format wants to use perfmon buffer allocation/mapping service | 2483 | * check if buffer format wants to use perfmon buffer allocation/mapping service |
@@ -2669,78 +2672,45 @@ pfm_context_create(pfm_context_t *ctx, void *arg, int count, struct pt_regs *reg | |||
2669 | { | 2672 | { |
2670 | pfarg_context_t *req = (pfarg_context_t *)arg; | 2673 | pfarg_context_t *req = (pfarg_context_t *)arg; |
2671 | struct file *filp; | 2674 | struct file *filp; |
2675 | struct path path; | ||
2672 | int ctx_flags; | 2676 | int ctx_flags; |
2677 | int fd; | ||
2673 | int ret; | 2678 | int ret; |
2674 | 2679 | ||
2675 | /* let's check the arguments first */ | 2680 | /* let's check the arguments first */ |
2676 | ret = pfarg_is_sane(current, req); | 2681 | ret = pfarg_is_sane(current, req); |
2677 | if (ret < 0) return ret; | 2682 | if (ret < 0) |
2683 | return ret; | ||
2678 | 2684 | ||
2679 | ctx_flags = req->ctx_flags; | 2685 | ctx_flags = req->ctx_flags; |
2680 | 2686 | ||
2681 | ret = -ENOMEM; | 2687 | ret = -ENOMEM; |
2682 | 2688 | ||
2683 | ctx = pfm_context_alloc(); | 2689 | fd = get_unused_fd(); |
2684 | if (!ctx) goto error; | 2690 | if (fd < 0) |
2691 | return fd; | ||
2685 | 2692 | ||
2686 | ret = pfm_alloc_fd(&filp); | 2693 | ctx = pfm_context_alloc(ctx_flags); |
2687 | if (ret < 0) goto error_file; | 2694 | if (!ctx) |
2695 | goto error; | ||
2688 | 2696 | ||
2689 | req->ctx_fd = ctx->ctx_fd = ret; | 2697 | filp = pfm_alloc_file(ctx); |
2698 | if (IS_ERR(filp)) { | ||
2699 | ret = PTR_ERR(filp); | ||
2700 | goto error_file; | ||
2701 | } | ||
2690 | 2702 | ||
2691 | /* | 2703 | req->ctx_fd = ctx->ctx_fd = fd; |
2692 | * attach context to file | ||
2693 | */ | ||
2694 | filp->private_data = ctx; | ||
2695 | 2704 | ||
2696 | /* | 2705 | /* |
2697 | * does the user want to sample? | 2706 | * does the user want to sample? |
2698 | */ | 2707 | */ |
2699 | if (pfm_uuid_cmp(req->ctx_smpl_buf_id, pfm_null_uuid)) { | 2708 | if (pfm_uuid_cmp(req->ctx_smpl_buf_id, pfm_null_uuid)) { |
2700 | ret = pfm_setup_buffer_fmt(current, filp, ctx, ctx_flags, 0, req); | 2709 | ret = pfm_setup_buffer_fmt(current, filp, ctx, ctx_flags, 0, req); |
2701 | if (ret) goto buffer_error; | 2710 | if (ret) |
2711 | goto buffer_error; | ||
2702 | } | 2712 | } |
2703 | 2713 | ||
2704 | /* | ||
2705 | * init context protection lock | ||
2706 | */ | ||
2707 | spin_lock_init(&ctx->ctx_lock); | ||
2708 | |||
2709 | /* | ||
2710 | * context is unloaded | ||
2711 | */ | ||
2712 | ctx->ctx_state = PFM_CTX_UNLOADED; | ||
2713 | |||
2714 | /* | ||
2715 | * initialization of context's flags | ||
2716 | */ | ||
2717 | ctx->ctx_fl_block = (ctx_flags & PFM_FL_NOTIFY_BLOCK) ? 1 : 0; | ||
2718 | ctx->ctx_fl_system = (ctx_flags & PFM_FL_SYSTEM_WIDE) ? 1: 0; | ||
2719 | ctx->ctx_fl_is_sampling = ctx->ctx_buf_fmt ? 1 : 0; /* assume record() is defined */ | ||
2720 | ctx->ctx_fl_no_msg = (ctx_flags & PFM_FL_OVFL_NO_MSG) ? 1: 0; | ||
2721 | /* | ||
2722 | * will move to set properties | ||
2723 | * ctx->ctx_fl_excl_idle = (ctx_flags & PFM_FL_EXCL_IDLE) ? 1: 0; | ||
2724 | */ | ||
2725 | |||
2726 | /* | ||
2727 | * init restart semaphore to locked | ||
2728 | */ | ||
2729 | init_completion(&ctx->ctx_restart_done); | ||
2730 | |||
2731 | /* | ||
2732 | * activation is used in SMP only | ||
2733 | */ | ||
2734 | ctx->ctx_last_activation = PFM_INVALID_ACTIVATION; | ||
2735 | SET_LAST_CPU(ctx, -1); | ||
2736 | |||
2737 | /* | ||
2738 | * initialize notification message queue | ||
2739 | */ | ||
2740 | ctx->ctx_msgq_head = ctx->ctx_msgq_tail = 0; | ||
2741 | init_waitqueue_head(&ctx->ctx_msgq_wait); | ||
2742 | init_waitqueue_head(&ctx->ctx_zombieq); | ||
2743 | |||
2744 | DPRINT(("ctx=%p flags=0x%x system=%d notify_block=%d excl_idle=%d no_msg=%d ctx_fd=%d \n", | 2714 | DPRINT(("ctx=%p flags=0x%x system=%d notify_block=%d excl_idle=%d no_msg=%d ctx_fd=%d \n", |
2745 | ctx, | 2715 | ctx, |
2746 | ctx_flags, | 2716 | ctx_flags, |
@@ -2755,10 +2725,14 @@ pfm_context_create(pfm_context_t *ctx, void *arg, int count, struct pt_regs *reg | |||
2755 | */ | 2725 | */ |
2756 | pfm_reset_pmu_state(ctx); | 2726 | pfm_reset_pmu_state(ctx); |
2757 | 2727 | ||
2728 | fd_install(fd, filp); | ||
2729 | |||
2758 | return 0; | 2730 | return 0; |
2759 | 2731 | ||
2760 | buffer_error: | 2732 | buffer_error: |
2761 | pfm_free_fd(ctx->ctx_fd, filp); | 2733 | path = filp->f_path; |
2734 | put_filp(filp); | ||
2735 | path_put(&path); | ||
2762 | 2736 | ||
2763 | if (ctx->ctx_buf_fmt) { | 2737 | if (ctx->ctx_buf_fmt) { |
2764 | pfm_buf_fmt_exit(ctx->ctx_buf_fmt, current, NULL, regs); | 2738 | pfm_buf_fmt_exit(ctx->ctx_buf_fmt, current, NULL, regs); |
@@ -2767,6 +2741,7 @@ error_file: | |||
2767 | pfm_context_free(ctx); | 2741 | pfm_context_free(ctx); |
2768 | 2742 | ||
2769 | error: | 2743 | error: |
2744 | put_unused_fd(fd); | ||
2770 | return ret; | 2745 | return ret; |
2771 | } | 2746 | } |
2772 | 2747 | ||
diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c index 5740296c35af..19c5a78636fc 100644 --- a/arch/ia64/kernel/signal.c +++ b/arch/ia64/kernel/signal.c | |||
@@ -464,7 +464,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) | |||
464 | if (!user_mode(&scr->pt)) | 464 | if (!user_mode(&scr->pt)) |
465 | return; | 465 | return; |
466 | 466 | ||
467 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) | 467 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) |
468 | oldset = ¤t->saved_sigmask; | 468 | oldset = ¤t->saved_sigmask; |
469 | else | 469 | else |
470 | oldset = ¤t->blocked; | 470 | oldset = ¤t->blocked; |
@@ -530,12 +530,13 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) | |||
530 | * continue to iterate in this loop so we can deliver the SIGSEGV... | 530 | * continue to iterate in this loop so we can deliver the SIGSEGV... |
531 | */ | 531 | */ |
532 | if (handle_signal(signr, &ka, &info, oldset, scr)) { | 532 | if (handle_signal(signr, &ka, &info, oldset, scr)) { |
533 | /* a signal was successfully delivered; the saved | 533 | /* |
534 | * A signal was successfully delivered; the saved | ||
534 | * sigmask will have been stored in the signal frame, | 535 | * sigmask will have been stored in the signal frame, |
535 | * and will be restored by sigreturn, so we can simply | 536 | * and will be restored by sigreturn, so we can simply |
536 | * clear the TIF_RESTORE_SIGMASK flag */ | 537 | * clear the TS_RESTORE_SIGMASK flag. |
537 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) | 538 | */ |
538 | clear_thread_flag(TIF_RESTORE_SIGMASK); | 539 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; |
539 | return; | 540 | return; |
540 | } | 541 | } |
541 | } | 542 | } |
@@ -566,8 +567,8 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) | |||
566 | 567 | ||
567 | /* if there's no signal to deliver, we just put the saved sigmask | 568 | /* if there's no signal to deliver, we just put the saved sigmask |
568 | * back */ | 569 | * back */ |
569 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) { | 570 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) { |
570 | clear_thread_flag(TIF_RESTORE_SIGMASK); | 571 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; |
571 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); | 572 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); |
572 | } | 573 | } |
573 | } | 574 | } |
diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c index 9a9d4c489330..983296f1c813 100644 --- a/arch/ia64/kernel/smp.c +++ b/arch/ia64/kernel/smp.c | |||
@@ -98,8 +98,33 @@ unlock_ipi_calllock(void) | |||
98 | spin_unlock_irq(&call_lock); | 98 | spin_unlock_irq(&call_lock); |
99 | } | 99 | } |
100 | 100 | ||
101 | static inline void | ||
102 | handle_call_data(void) | ||
103 | { | ||
104 | struct call_data_struct *data; | ||
105 | void (*func)(void *info); | ||
106 | void *info; | ||
107 | int wait; | ||
108 | |||
109 | /* release the 'pointer lock' */ | ||
110 | data = (struct call_data_struct *)call_data; | ||
111 | func = data->func; | ||
112 | info = data->info; | ||
113 | wait = data->wait; | ||
114 | |||
115 | mb(); | ||
116 | atomic_inc(&data->started); | ||
117 | /* At this point the structure may be gone unless wait is true. */ | ||
118 | (*func)(info); | ||
119 | |||
120 | /* Notify the sending CPU that the task is done. */ | ||
121 | mb(); | ||
122 | if (wait) | ||
123 | atomic_inc(&data->finished); | ||
124 | } | ||
125 | |||
101 | static void | 126 | static void |
102 | stop_this_cpu (void) | 127 | stop_this_cpu(void) |
103 | { | 128 | { |
104 | /* | 129 | /* |
105 | * Remove this CPU: | 130 | * Remove this CPU: |
@@ -138,44 +163,21 @@ handle_IPI (int irq, void *dev_id) | |||
138 | ops &= ~(1 << which); | 163 | ops &= ~(1 << which); |
139 | 164 | ||
140 | switch (which) { | 165 | switch (which) { |
141 | case IPI_CALL_FUNC: | 166 | case IPI_CALL_FUNC: |
142 | { | 167 | handle_call_data(); |
143 | struct call_data_struct *data; | 168 | break; |
144 | void (*func)(void *info); | 169 | |
145 | void *info; | 170 | case IPI_CPU_STOP: |
146 | int wait; | ||
147 | |||
148 | /* release the 'pointer lock' */ | ||
149 | data = (struct call_data_struct *) call_data; | ||
150 | func = data->func; | ||
151 | info = data->info; | ||
152 | wait = data->wait; | ||
153 | |||
154 | mb(); | ||
155 | atomic_inc(&data->started); | ||
156 | /* | ||
157 | * At this point the structure may be gone unless | ||
158 | * wait is true. | ||
159 | */ | ||
160 | (*func)(info); | ||
161 | |||
162 | /* Notify the sending CPU that the task is done. */ | ||
163 | mb(); | ||
164 | if (wait) | ||
165 | atomic_inc(&data->finished); | ||
166 | } | ||
167 | break; | ||
168 | |||
169 | case IPI_CPU_STOP: | ||
170 | stop_this_cpu(); | 171 | stop_this_cpu(); |
171 | break; | 172 | break; |
172 | #ifdef CONFIG_KEXEC | 173 | #ifdef CONFIG_KEXEC |
173 | case IPI_KDUMP_CPU_STOP: | 174 | case IPI_KDUMP_CPU_STOP: |
174 | unw_init_running(kdump_cpu_freeze, NULL); | 175 | unw_init_running(kdump_cpu_freeze, NULL); |
175 | break; | 176 | break; |
176 | #endif | 177 | #endif |
177 | default: | 178 | default: |
178 | printk(KERN_CRIT "Unknown IPI on CPU %d: %lu\n", this_cpu, which); | 179 | printk(KERN_CRIT "Unknown IPI on CPU %d: %lu\n", |
180 | this_cpu, which); | ||
179 | break; | 181 | break; |
180 | } | 182 | } |
181 | } while (ops); | 183 | } while (ops); |
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index 48e15a51782f..8c73643f2d66 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c | |||
@@ -379,11 +379,6 @@ static struct irqaction timer_irqaction = { | |||
379 | .name = "timer" | 379 | .name = "timer" |
380 | }; | 380 | }; |
381 | 381 | ||
382 | void __devinit ia64_disable_timer(void) | ||
383 | { | ||
384 | ia64_set_itv(1 << 16); | ||
385 | } | ||
386 | |||
387 | void __init | 382 | void __init |
388 | time_init (void) | 383 | time_init (void) |
389 | { | 384 | { |
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c index abb17a613b17..26228e2d01ae 100644 --- a/arch/ia64/kernel/topology.c +++ b/arch/ia64/kernel/topology.c | |||
@@ -36,9 +36,11 @@ void arch_fix_phys_package_id(int num, u32 slot) | |||
36 | } | 36 | } |
37 | EXPORT_SYMBOL_GPL(arch_fix_phys_package_id); | 37 | EXPORT_SYMBOL_GPL(arch_fix_phys_package_id); |
38 | 38 | ||
39 | int arch_register_cpu(int num) | 39 | |
40 | #ifdef CONFIG_HOTPLUG_CPU | ||
41 | int __ref arch_register_cpu(int num) | ||
40 | { | 42 | { |
41 | #if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU) | 43 | #ifdef CONFIG_ACPI |
42 | /* | 44 | /* |
43 | * If CPEI can be re-targetted or if this is not | 45 | * If CPEI can be re-targetted or if this is not |
44 | * CPEI target, then it is hotpluggable | 46 | * CPEI target, then it is hotpluggable |
@@ -47,19 +49,21 @@ int arch_register_cpu(int num) | |||
47 | sysfs_cpus[num].cpu.hotpluggable = 1; | 49 | sysfs_cpus[num].cpu.hotpluggable = 1; |
48 | map_cpu_to_node(num, node_cpuid[num].nid); | 50 | map_cpu_to_node(num, node_cpuid[num].nid); |
49 | #endif | 51 | #endif |
50 | |||
51 | return register_cpu(&sysfs_cpus[num].cpu, num); | 52 | return register_cpu(&sysfs_cpus[num].cpu, num); |
52 | } | 53 | } |
53 | 54 | EXPORT_SYMBOL(arch_register_cpu); | |
54 | #ifdef CONFIG_HOTPLUG_CPU | ||
55 | 55 | ||
56 | void arch_unregister_cpu(int num) | 56 | void arch_unregister_cpu(int num) |
57 | { | 57 | { |
58 | unregister_cpu(&sysfs_cpus[num].cpu); | 58 | unregister_cpu(&sysfs_cpus[num].cpu); |
59 | unmap_cpu_from_node(num, cpu_to_node(num)); | 59 | unmap_cpu_from_node(num, cpu_to_node(num)); |
60 | } | 60 | } |
61 | EXPORT_SYMBOL(arch_register_cpu); | ||
62 | EXPORT_SYMBOL(arch_unregister_cpu); | 61 | EXPORT_SYMBOL(arch_unregister_cpu); |
62 | #else | ||
63 | static int __init arch_register_cpu(int num) | ||
64 | { | ||
65 | return register_cpu(&sysfs_cpus[num].cpu, num); | ||
66 | } | ||
63 | #endif /*CONFIG_HOTPLUG_CPU*/ | 67 | #endif /*CONFIG_HOTPLUG_CPU*/ |
64 | 68 | ||
65 | 69 | ||
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 6df073240135..318b81100623 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /* | 1 | /* |
3 | * kvm_ia64.c: Basic KVM suppport On Itanium series processors | 2 | * kvm_ia64.c: Basic KVM suppport On Itanium series processors |
4 | * | 3 | * |
@@ -431,7 +430,7 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) | |||
431 | if (itc_diff < 0) | 430 | if (itc_diff < 0) |
432 | itc_diff = -itc_diff; | 431 | itc_diff = -itc_diff; |
433 | 432 | ||
434 | expires = div64_64(itc_diff, cyc_per_usec); | 433 | expires = div64_u64(itc_diff, cyc_per_usec); |
435 | kt = ktime_set(0, 1000 * expires); | 434 | kt = ktime_set(0, 1000 * expires); |
436 | vcpu->arch.ht_active = 1; | 435 | vcpu->arch.ht_active = 1; |
437 | hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS); | 436 | hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS); |
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile index 4072a07ebf8e..469766b24e22 100644 --- a/arch/m32r/Makefile +++ b/arch/m32r/Makefile | |||
@@ -5,6 +5,8 @@ | |||
5 | # architecture-specific flags and dependencies. | 5 | # architecture-specific flags and dependencies. |
6 | # | 6 | # |
7 | 7 | ||
8 | KBUILD_DEFCONFIG := m32700ut.smp_defconfig | ||
9 | |||
8 | LDFLAGS := | 10 | LDFLAGS := |
9 | OBJCOPYFLAGS := -O binary -R .note -R .comment -S | 11 | OBJCOPYFLAGS := -O binary -R .note -R .comment -S |
10 | LDFLAGS_vmlinux := | 12 | LDFLAGS_vmlinux := |
diff --git a/arch/m32r/defconfig b/arch/m32r/defconfig deleted file mode 100644 index af3b98179113..000000000000 --- a/arch/m32r/defconfig +++ /dev/null | |||
@@ -1,863 +0,0 @@ | |||
1 | # | ||
2 | # Automatically generated make config: don't edit | ||
3 | # Linux kernel version: 2.6.23-rc1 | ||
4 | # Wed Aug 1 17:22:35 2007 | ||
5 | # | ||
6 | CONFIG_M32R=y | ||
7 | CONFIG_GENERIC_ISA_DMA=y | ||
8 | CONFIG_ZONE_DMA=y | ||
9 | CONFIG_GENERIC_HARDIRQS=y | ||
10 | CONFIG_GENERIC_IRQ_PROBE=y | ||
11 | CONFIG_NO_IOPORT=y | ||
12 | CONFIG_NO_DMA=y | ||
13 | CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" | ||
14 | |||
15 | # | ||
16 | # Code maturity level options | ||
17 | # | ||
18 | CONFIG_EXPERIMENTAL=y | ||
19 | CONFIG_LOCK_KERNEL=y | ||
20 | CONFIG_INIT_ENV_ARG_LIMIT=32 | ||
21 | |||
22 | # | ||
23 | # General setup | ||
24 | # | ||
25 | CONFIG_LOCALVERSION="" | ||
26 | CONFIG_LOCALVERSION_AUTO=y | ||
27 | CONFIG_SWAP=y | ||
28 | CONFIG_SYSVIPC=y | ||
29 | CONFIG_SYSVIPC_SYSCTL=y | ||
30 | # CONFIG_POSIX_MQUEUE is not set | ||
31 | CONFIG_BSD_PROCESS_ACCT=y | ||
32 | # CONFIG_BSD_PROCESS_ACCT_V3 is not set | ||
33 | # CONFIG_TASKSTATS is not set | ||
34 | # CONFIG_USER_NS is not set | ||
35 | # CONFIG_AUDIT is not set | ||
36 | CONFIG_IKCONFIG=y | ||
37 | CONFIG_IKCONFIG_PROC=y | ||
38 | CONFIG_LOG_BUF_SHIFT=15 | ||
39 | # CONFIG_CPUSETS is not set | ||
40 | CONFIG_SYSFS_DEPRECATED=y | ||
41 | # CONFIG_RELAY is not set | ||
42 | # CONFIG_BLK_DEV_INITRD is not set | ||
43 | # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set | ||
44 | CONFIG_SYSCTL=y | ||
45 | CONFIG_EMBEDDED=y | ||
46 | CONFIG_SYSCTL_SYSCALL=y | ||
47 | # CONFIG_KALLSYMS is not set | ||
48 | CONFIG_HOTPLUG=y | ||
49 | CONFIG_PRINTK=y | ||
50 | CONFIG_BUG=y | ||
51 | CONFIG_ELF_CORE=y | ||
52 | CONFIG_BASE_FULL=y | ||
53 | # CONFIG_FUTEX is not set | ||
54 | CONFIG_ANON_INODES=y | ||
55 | # CONFIG_EPOLL is not set | ||
56 | CONFIG_SIGNALFD=y | ||
57 | CONFIG_TIMERFD=y | ||
58 | CONFIG_EVENTFD=y | ||
59 | CONFIG_SHMEM=y | ||
60 | CONFIG_VM_EVENT_COUNTERS=y | ||
61 | CONFIG_SLAB=y | ||
62 | # CONFIG_SLUB is not set | ||
63 | # CONFIG_SLOB is not set | ||
64 | # CONFIG_TINY_SHMEM is not set | ||
65 | CONFIG_BASE_SMALL=0 | ||
66 | CONFIG_MODULES=y | ||
67 | CONFIG_MODULE_UNLOAD=y | ||
68 | # CONFIG_MODULE_FORCE_UNLOAD is not set | ||
69 | # CONFIG_MODVERSIONS is not set | ||
70 | # CONFIG_MODULE_SRCVERSION_ALL is not set | ||
71 | CONFIG_KMOD=y | ||
72 | CONFIG_STOP_MACHINE=y | ||
73 | CONFIG_BLOCK=y | ||
74 | # CONFIG_LBD is not set | ||
75 | # CONFIG_BLK_DEV_IO_TRACE is not set | ||
76 | # CONFIG_LSF is not set | ||
77 | # CONFIG_BLK_DEV_BSG is not set | ||
78 | |||
79 | # | ||
80 | # IO Schedulers | ||
81 | # | ||
82 | CONFIG_IOSCHED_NOOP=y | ||
83 | # CONFIG_IOSCHED_AS is not set | ||
84 | CONFIG_IOSCHED_DEADLINE=y | ||
85 | CONFIG_IOSCHED_CFQ=y | ||
86 | # CONFIG_DEFAULT_AS is not set | ||
87 | # CONFIG_DEFAULT_DEADLINE is not set | ||
88 | CONFIG_DEFAULT_CFQ=y | ||
89 | # CONFIG_DEFAULT_NOOP is not set | ||
90 | CONFIG_DEFAULT_IOSCHED="cfq" | ||
91 | |||
92 | # | ||
93 | # Processor type and features | ||
94 | # | ||
95 | # CONFIG_PLAT_MAPPI is not set | ||
96 | # CONFIG_PLAT_USRV is not set | ||
97 | CONFIG_PLAT_M32700UT=y | ||
98 | # CONFIG_PLAT_OPSPUT is not set | ||
99 | # CONFIG_PLAT_OAKS32R is not set | ||
100 | # CONFIG_PLAT_MAPPI2 is not set | ||
101 | # CONFIG_PLAT_MAPPI3 is not set | ||
102 | # CONFIG_PLAT_M32104UT is not set | ||
103 | CONFIG_CHIP_M32700=y | ||
104 | # CONFIG_CHIP_M32102 is not set | ||
105 | # CONFIG_CHIP_M32104 is not set | ||
106 | # CONFIG_CHIP_VDEC2 is not set | ||
107 | # CONFIG_CHIP_OPSP is not set | ||
108 | CONFIG_MMU=y | ||
109 | CONFIG_TLB_ENTRIES=32 | ||
110 | CONFIG_ISA_M32R2=y | ||
111 | CONFIG_ISA_DSP_LEVEL2=y | ||
112 | CONFIG_ISA_DUAL_ISSUE=y | ||
113 | CONFIG_BUS_CLOCK=50000000 | ||
114 | CONFIG_TIMER_DIVIDE=128 | ||
115 | # CONFIG_CPU_LITTLE_ENDIAN is not set | ||
116 | CONFIG_MEMORY_START=0x08000000 | ||
117 | CONFIG_MEMORY_SIZE=0x01000000 | ||
118 | CONFIG_NOHIGHMEM=y | ||
119 | CONFIG_ARCH_DISCONTIGMEM_ENABLE=y | ||
120 | CONFIG_SELECT_MEMORY_MODEL=y | ||
121 | # CONFIG_FLATMEM_MANUAL is not set | ||
122 | CONFIG_DISCONTIGMEM_MANUAL=y | ||
123 | # CONFIG_SPARSEMEM_MANUAL is not set | ||
124 | CONFIG_DISCONTIGMEM=y | ||
125 | CONFIG_FLAT_NODE_MEM_MAP=y | ||
126 | CONFIG_NEED_MULTIPLE_NODES=y | ||
127 | # CONFIG_SPARSEMEM_STATIC is not set | ||
128 | CONFIG_SPLIT_PTLOCK_CPUS=4 | ||
129 | # CONFIG_RESOURCES_64BIT is not set | ||
130 | CONFIG_ZONE_DMA_FLAG=1 | ||
131 | CONFIG_BOUNCE=y | ||
132 | CONFIG_VIRT_TO_BUS=y | ||
133 | CONFIG_IRAM_START=0x00f00000 | ||
134 | CONFIG_IRAM_SIZE=0x00080000 | ||
135 | CONFIG_RWSEM_GENERIC_SPINLOCK=y | ||
136 | # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set | ||
137 | # CONFIG_ARCH_HAS_ILOG2_U32 is not set | ||
138 | # CONFIG_ARCH_HAS_ILOG2_U64 is not set | ||
139 | CONFIG_GENERIC_FIND_NEXT_BIT=y | ||
140 | CONFIG_GENERIC_HWEIGHT=y | ||
141 | CONFIG_GENERIC_CALIBRATE_DELAY=y | ||
142 | CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y | ||
143 | CONFIG_PREEMPT=y | ||
144 | CONFIG_SMP=y | ||
145 | # CONFIG_CHIP_M32700_TS1 is not set | ||
146 | CONFIG_NR_CPUS=2 | ||
147 | CONFIG_NODES_SHIFT=1 | ||
148 | |||
149 | # | ||
150 | # Bus options (PCI, PCMCIA, EISA, MCA, ISA) | ||
151 | # | ||
152 | # CONFIG_ARCH_SUPPORTS_MSI is not set | ||
153 | # CONFIG_ISA is not set | ||
154 | |||
155 | # | ||
156 | # PCCARD (PCMCIA/CardBus) support | ||
157 | # | ||
158 | # CONFIG_PCCARD is not set | ||
159 | |||
160 | # | ||
161 | # Executable file formats | ||
162 | # | ||
163 | CONFIG_BINFMT_ELF=y | ||
164 | # CONFIG_BINFMT_MISC is not set | ||
165 | |||
166 | # | ||
167 | # Networking | ||
168 | # | ||
169 | CONFIG_NET=y | ||
170 | |||
171 | # | ||
172 | # Networking options | ||
173 | # | ||
174 | CONFIG_PACKET=y | ||
175 | # CONFIG_PACKET_MMAP is not set | ||
176 | CONFIG_UNIX=y | ||
177 | CONFIG_XFRM=y | ||
178 | # CONFIG_XFRM_USER is not set | ||
179 | # CONFIG_XFRM_SUB_POLICY is not set | ||
180 | # CONFIG_XFRM_MIGRATE is not set | ||
181 | # CONFIG_NET_KEY is not set | ||
182 | CONFIG_INET=y | ||
183 | # CONFIG_IP_MULTICAST is not set | ||
184 | # CONFIG_IP_ADVANCED_ROUTER is not set | ||
185 | CONFIG_IP_FIB_HASH=y | ||
186 | CONFIG_IP_PNP=y | ||
187 | CONFIG_IP_PNP_DHCP=y | ||
188 | # CONFIG_IP_PNP_BOOTP is not set | ||
189 | # CONFIG_IP_PNP_RARP is not set | ||
190 | # CONFIG_NET_IPIP is not set | ||
191 | # CONFIG_NET_IPGRE is not set | ||
192 | # CONFIG_ARPD is not set | ||
193 | # CONFIG_SYN_COOKIES is not set | ||
194 | # CONFIG_INET_AH is not set | ||
195 | # CONFIG_INET_ESP is not set | ||
196 | # CONFIG_INET_IPCOMP is not set | ||
197 | # CONFIG_INET_XFRM_TUNNEL is not set | ||
198 | # CONFIG_INET_TUNNEL is not set | ||
199 | CONFIG_INET_XFRM_MODE_TRANSPORT=y | ||
200 | CONFIG_INET_XFRM_MODE_TUNNEL=y | ||
201 | CONFIG_INET_XFRM_MODE_BEET=y | ||
202 | CONFIG_INET_DIAG=y | ||
203 | CONFIG_INET_TCP_DIAG=y | ||
204 | # CONFIG_TCP_CONG_ADVANCED is not set | ||
205 | CONFIG_TCP_CONG_CUBIC=y | ||
206 | CONFIG_DEFAULT_TCP_CONG="cubic" | ||
207 | # CONFIG_TCP_MD5SIG is not set | ||
208 | # CONFIG_IPV6 is not set | ||
209 | # CONFIG_INET6_XFRM_TUNNEL is not set | ||
210 | # CONFIG_INET6_TUNNEL is not set | ||
211 | # CONFIG_NETWORK_SECMARK is not set | ||
212 | # CONFIG_NETFILTER is not set | ||
213 | # CONFIG_IP_DCCP is not set | ||
214 | # CONFIG_IP_SCTP is not set | ||
215 | # CONFIG_TIPC is not set | ||
216 | # CONFIG_ATM is not set | ||
217 | # CONFIG_BRIDGE is not set | ||
218 | # CONFIG_VLAN_8021Q is not set | ||
219 | # CONFIG_DECNET is not set | ||
220 | # CONFIG_LLC2 is not set | ||
221 | # CONFIG_IPX is not set | ||
222 | # CONFIG_ATALK is not set | ||
223 | # CONFIG_X25 is not set | ||
224 | # CONFIG_LAPB is not set | ||
225 | # CONFIG_ECONET is not set | ||
226 | # CONFIG_WAN_ROUTER is not set | ||
227 | |||
228 | # | ||
229 | # QoS and/or fair queueing | ||
230 | # | ||
231 | # CONFIG_NET_SCHED is not set | ||
232 | |||
233 | # | ||
234 | # Network testing | ||
235 | # | ||
236 | # CONFIG_NET_PKTGEN is not set | ||
237 | # CONFIG_HAMRADIO is not set | ||
238 | # CONFIG_IRDA is not set | ||
239 | # CONFIG_BT is not set | ||
240 | # CONFIG_AF_RXRPC is not set | ||
241 | |||
242 | # | ||
243 | # Wireless | ||
244 | # | ||
245 | # CONFIG_CFG80211 is not set | ||
246 | # CONFIG_WIRELESS_EXT is not set | ||
247 | # CONFIG_MAC80211 is not set | ||
248 | # CONFIG_IEEE80211 is not set | ||
249 | # CONFIG_RFKILL is not set | ||
250 | # CONFIG_NET_9P is not set | ||
251 | |||
252 | # | ||
253 | # Device Drivers | ||
254 | # | ||
255 | |||
256 | # | ||
257 | # Generic Driver Options | ||
258 | # | ||
259 | CONFIG_STANDALONE=y | ||
260 | CONFIG_PREVENT_FIRMWARE_BUILD=y | ||
261 | CONFIG_FW_LOADER=y | ||
262 | # CONFIG_SYS_HYPERVISOR is not set | ||
263 | # CONFIG_CONNECTOR is not set | ||
264 | CONFIG_MTD=y | ||
265 | # CONFIG_MTD_DEBUG is not set | ||
266 | # CONFIG_MTD_CONCAT is not set | ||
267 | CONFIG_MTD_PARTITIONS=y | ||
268 | CONFIG_MTD_REDBOOT_PARTS=y | ||
269 | CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1 | ||
270 | # CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set | ||
271 | # CONFIG_MTD_REDBOOT_PARTS_READONLY is not set | ||
272 | # CONFIG_MTD_CMDLINE_PARTS is not set | ||
273 | |||
274 | # | ||
275 | # User Modules And Translation Layers | ||
276 | # | ||
277 | # CONFIG_MTD_CHAR is not set | ||
278 | CONFIG_MTD_BLKDEVS=y | ||
279 | CONFIG_MTD_BLOCK=y | ||
280 | # CONFIG_FTL is not set | ||
281 | # CONFIG_NFTL is not set | ||
282 | # CONFIG_INFTL is not set | ||
283 | # CONFIG_RFD_FTL is not set | ||
284 | # CONFIG_SSFDC is not set | ||
285 | |||
286 | # | ||
287 | # RAM/ROM/Flash chip drivers | ||
288 | # | ||
289 | CONFIG_MTD_CFI=m | ||
290 | CONFIG_MTD_JEDECPROBE=m | ||
291 | CONFIG_MTD_GEN_PROBE=m | ||
292 | CONFIG_MTD_CFI_ADV_OPTIONS=y | ||
293 | # CONFIG_MTD_CFI_NOSWAP is not set | ||
294 | CONFIG_MTD_CFI_BE_BYTE_SWAP=y | ||
295 | # CONFIG_MTD_CFI_LE_BYTE_SWAP is not set | ||
296 | CONFIG_MTD_CFI_GEOMETRY=y | ||
297 | CONFIG_MTD_MAP_BANK_WIDTH_1=y | ||
298 | CONFIG_MTD_MAP_BANK_WIDTH_2=y | ||
299 | CONFIG_MTD_MAP_BANK_WIDTH_4=y | ||
300 | # CONFIG_MTD_MAP_BANK_WIDTH_8 is not set | ||
301 | # CONFIG_MTD_MAP_BANK_WIDTH_16 is not set | ||
302 | # CONFIG_MTD_MAP_BANK_WIDTH_32 is not set | ||
303 | CONFIG_MTD_CFI_I1=y | ||
304 | # CONFIG_MTD_CFI_I2 is not set | ||
305 | # CONFIG_MTD_CFI_I4 is not set | ||
306 | # CONFIG_MTD_CFI_I8 is not set | ||
307 | # CONFIG_MTD_OTP is not set | ||
308 | # CONFIG_MTD_CFI_INTELEXT is not set | ||
309 | CONFIG_MTD_CFI_AMDSTD=m | ||
310 | # CONFIG_MTD_CFI_STAA is not set | ||
311 | CONFIG_MTD_CFI_UTIL=m | ||
312 | # CONFIG_MTD_RAM is not set | ||
313 | # CONFIG_MTD_ROM is not set | ||
314 | # CONFIG_MTD_ABSENT is not set | ||
315 | |||
316 | # | ||
317 | # Mapping drivers for chip access | ||
318 | # | ||
319 | # CONFIG_MTD_COMPLEX_MAPPINGS is not set | ||
320 | # CONFIG_MTD_PHYSMAP is not set | ||
321 | # CONFIG_MTD_PLATRAM is not set | ||
322 | |||
323 | # | ||
324 | # Self-contained MTD device drivers | ||
325 | # | ||
326 | # CONFIG_MTD_SLRAM is not set | ||
327 | # CONFIG_MTD_PHRAM is not set | ||
328 | # CONFIG_MTD_MTDRAM is not set | ||
329 | # CONFIG_MTD_BLOCK2MTD is not set | ||
330 | |||
331 | # | ||
332 | # Disk-On-Chip Device Drivers | ||
333 | # | ||
334 | # CONFIG_MTD_DOC2000 is not set | ||
335 | # CONFIG_MTD_DOC2001 is not set | ||
336 | # CONFIG_MTD_DOC2001PLUS is not set | ||
337 | # CONFIG_MTD_NAND is not set | ||
338 | # CONFIG_MTD_ONENAND is not set | ||
339 | |||
340 | # | ||
341 | # UBI - Unsorted block images | ||
342 | # | ||
343 | # CONFIG_MTD_UBI is not set | ||
344 | # CONFIG_PARPORT is not set | ||
345 | CONFIG_BLK_DEV=y | ||
346 | # CONFIG_BLK_DEV_COW_COMMON is not set | ||
347 | CONFIG_BLK_DEV_LOOP=y | ||
348 | # CONFIG_BLK_DEV_CRYPTOLOOP is not set | ||
349 | CONFIG_BLK_DEV_NBD=y | ||
350 | CONFIG_BLK_DEV_RAM=y | ||
351 | CONFIG_BLK_DEV_RAM_COUNT=16 | ||
352 | CONFIG_BLK_DEV_RAM_SIZE=4096 | ||
353 | CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 | ||
354 | # CONFIG_CDROM_PKTCDVD is not set | ||
355 | CONFIG_ATA_OVER_ETH=m | ||
356 | CONFIG_MISC_DEVICES=y | ||
357 | # CONFIG_EEPROM_93CX6 is not set | ||
358 | CONFIG_IDE=y | ||
359 | CONFIG_IDE_MAX_HWIFS=4 | ||
360 | CONFIG_BLK_DEV_IDE=y | ||
361 | |||
362 | # | ||
363 | # Please see Documentation/ide.txt for help/info on IDE drives | ||
364 | # | ||
365 | # CONFIG_BLK_DEV_IDE_SATA is not set | ||
366 | CONFIG_BLK_DEV_IDEDISK=y | ||
367 | # CONFIG_IDEDISK_MULTI_MODE is not set | ||
368 | CONFIG_BLK_DEV_IDECD=m | ||
369 | # CONFIG_BLK_DEV_IDETAPE is not set | ||
370 | # CONFIG_BLK_DEV_IDEFLOPPY is not set | ||
371 | # CONFIG_BLK_DEV_IDESCSI is not set | ||
372 | # CONFIG_IDE_TASK_IOCTL is not set | ||
373 | CONFIG_IDE_PROC_FS=y | ||
374 | |||
375 | # | ||
376 | # IDE chipset support/bugfixes | ||
377 | # | ||
378 | CONFIG_IDE_GENERIC=y | ||
379 | # CONFIG_IDEPCI_PCIBUS_ORDER is not set | ||
380 | # CONFIG_IDE_ARM is not set | ||
381 | # CONFIG_BLK_DEV_IDEDMA is not set | ||
382 | # CONFIG_BLK_DEV_HD is not set | ||
383 | |||
384 | # | ||
385 | # SCSI device support | ||
386 | # | ||
387 | # CONFIG_RAID_ATTRS is not set | ||
388 | CONFIG_SCSI=m | ||
389 | # CONFIG_SCSI_DMA is not set | ||
390 | # CONFIG_SCSI_TGT is not set | ||
391 | # CONFIG_SCSI_NETLINK is not set | ||
392 | CONFIG_SCSI_PROC_FS=y | ||
393 | |||
394 | # | ||
395 | # SCSI support type (disk, tape, CD-ROM) | ||
396 | # | ||
397 | CONFIG_BLK_DEV_SD=m | ||
398 | # CONFIG_CHR_DEV_ST is not set | ||
399 | # CONFIG_CHR_DEV_OSST is not set | ||
400 | CONFIG_BLK_DEV_SR=m | ||
401 | # CONFIG_BLK_DEV_SR_VENDOR is not set | ||
402 | CONFIG_CHR_DEV_SG=m | ||
403 | # CONFIG_CHR_DEV_SCH is not set | ||
404 | |||
405 | # | ||
406 | # Some SCSI devices (e.g. CD jukebox) support multiple LUNs | ||
407 | # | ||
408 | CONFIG_SCSI_MULTI_LUN=y | ||
409 | # CONFIG_SCSI_CONSTANTS is not set | ||
410 | # CONFIG_SCSI_LOGGING is not set | ||
411 | # CONFIG_SCSI_SCAN_ASYNC is not set | ||
412 | CONFIG_SCSI_WAIT_SCAN=m | ||
413 | |||
414 | # | ||
415 | # SCSI Transports | ||
416 | # | ||
417 | # CONFIG_SCSI_SPI_ATTRS is not set | ||
418 | # CONFIG_SCSI_FC_ATTRS is not set | ||
419 | # CONFIG_SCSI_ISCSI_ATTRS is not set | ||
420 | # CONFIG_SCSI_SAS_LIBSAS is not set | ||
421 | CONFIG_SCSI_LOWLEVEL=y | ||
422 | # CONFIG_ISCSI_TCP is not set | ||
423 | # CONFIG_SCSI_DEBUG is not set | ||
424 | # CONFIG_MD is not set | ||
425 | CONFIG_NETDEVICES=y | ||
426 | # CONFIG_NETDEVICES_MULTIQUEUE is not set | ||
427 | # CONFIG_DUMMY is not set | ||
428 | # CONFIG_BONDING is not set | ||
429 | # CONFIG_MACVLAN is not set | ||
430 | # CONFIG_EQUALIZER is not set | ||
431 | # CONFIG_TUN is not set | ||
432 | # CONFIG_PHYLIB is not set | ||
433 | CONFIG_NET_ETHERNET=y | ||
434 | CONFIG_MII=y | ||
435 | CONFIG_SMC91X=y | ||
436 | # CONFIG_NE2000 is not set | ||
437 | CONFIG_NETDEV_1000=y | ||
438 | CONFIG_NETDEV_10000=y | ||
439 | |||
440 | # | ||
441 | # Wireless LAN | ||
442 | # | ||
443 | # CONFIG_WLAN_PRE80211 is not set | ||
444 | # CONFIG_WLAN_80211 is not set | ||
445 | # CONFIG_WAN is not set | ||
446 | # CONFIG_PPP is not set | ||
447 | # CONFIG_SLIP is not set | ||
448 | # CONFIG_SHAPER is not set | ||
449 | # CONFIG_NETCONSOLE is not set | ||
450 | # CONFIG_NETPOLL is not set | ||
451 | # CONFIG_NET_POLL_CONTROLLER is not set | ||
452 | # CONFIG_ISDN is not set | ||
453 | # CONFIG_PHONE is not set | ||
454 | |||
455 | # | ||
456 | # Input device support | ||
457 | # | ||
458 | CONFIG_INPUT=y | ||
459 | # CONFIG_INPUT_FF_MEMLESS is not set | ||
460 | # CONFIG_INPUT_POLLDEV is not set | ||
461 | |||
462 | # | ||
463 | # Userland interfaces | ||
464 | # | ||
465 | # CONFIG_INPUT_MOUSEDEV is not set | ||
466 | # CONFIG_INPUT_JOYDEV is not set | ||
467 | # CONFIG_INPUT_TSDEV is not set | ||
468 | # CONFIG_INPUT_EVDEV is not set | ||
469 | # CONFIG_INPUT_EVBUG is not set | ||
470 | |||
471 | # | ||
472 | # Input Device Drivers | ||
473 | # | ||
474 | # CONFIG_INPUT_KEYBOARD is not set | ||
475 | # CONFIG_INPUT_MOUSE is not set | ||
476 | # CONFIG_INPUT_JOYSTICK is not set | ||
477 | # CONFIG_INPUT_TABLET is not set | ||
478 | # CONFIG_INPUT_TOUCHSCREEN is not set | ||
479 | # CONFIG_INPUT_MISC is not set | ||
480 | |||
481 | # | ||
482 | # Hardware I/O ports | ||
483 | # | ||
484 | CONFIG_SERIO=y | ||
485 | # CONFIG_SERIO_I8042 is not set | ||
486 | CONFIG_SERIO_SERPORT=y | ||
487 | # CONFIG_SERIO_LIBPS2 is not set | ||
488 | # CONFIG_SERIO_RAW is not set | ||
489 | # CONFIG_GAMEPORT is not set | ||
490 | |||
491 | # | ||
492 | # Character devices | ||
493 | # | ||
494 | CONFIG_VT=y | ||
495 | CONFIG_VT_CONSOLE=y | ||
496 | CONFIG_HW_CONSOLE=y | ||
497 | # CONFIG_VT_HW_CONSOLE_BINDING is not set | ||
498 | # CONFIG_SERIAL_NONSTANDARD is not set | ||
499 | |||
500 | # | ||
501 | # Serial drivers | ||
502 | # | ||
503 | # CONFIG_SERIAL_8250 is not set | ||
504 | |||
505 | # | ||
506 | # Non-8250 serial port support | ||
507 | # | ||
508 | CONFIG_SERIAL_CORE=y | ||
509 | CONFIG_SERIAL_CORE_CONSOLE=y | ||
510 | CONFIG_SERIAL_M32R_SIO=y | ||
511 | CONFIG_SERIAL_M32R_SIO_CONSOLE=y | ||
512 | CONFIG_SERIAL_M32R_PLDSIO=y | ||
513 | CONFIG_UNIX98_PTYS=y | ||
514 | CONFIG_LEGACY_PTYS=y | ||
515 | CONFIG_LEGACY_PTY_COUNT=256 | ||
516 | # CONFIG_IPMI_HANDLER is not set | ||
517 | # CONFIG_WATCHDOG is not set | ||
518 | CONFIG_HW_RANDOM=y | ||
519 | # CONFIG_RTC is not set | ||
520 | CONFIG_DS1302=y | ||
521 | # CONFIG_R3964 is not set | ||
522 | # CONFIG_RAW_DRIVER is not set | ||
523 | # CONFIG_TCG_TPM is not set | ||
524 | # CONFIG_I2C is not set | ||
525 | |||
526 | # | ||
527 | # SPI support | ||
528 | # | ||
529 | # CONFIG_SPI is not set | ||
530 | # CONFIG_SPI_MASTER is not set | ||
531 | # CONFIG_W1 is not set | ||
532 | # CONFIG_POWER_SUPPLY is not set | ||
533 | CONFIG_HWMON=y | ||
534 | # CONFIG_HWMON_VID is not set | ||
535 | # CONFIG_SENSORS_ABITUGURU is not set | ||
536 | # CONFIG_SENSORS_ABITUGURU3 is not set | ||
537 | # CONFIG_SENSORS_F71805F is not set | ||
538 | # CONFIG_SENSORS_IT87 is not set | ||
539 | # CONFIG_SENSORS_PC87360 is not set | ||
540 | # CONFIG_SENSORS_PC87427 is not set | ||
541 | # CONFIG_SENSORS_SMSC47M1 is not set | ||
542 | # CONFIG_SENSORS_SMSC47B397 is not set | ||
543 | # CONFIG_SENSORS_VT1211 is not set | ||
544 | # CONFIG_SENSORS_W83627HF is not set | ||
545 | # CONFIG_SENSORS_W83627EHF is not set | ||
546 | # CONFIG_HWMON_DEBUG_CHIP is not set | ||
547 | |||
548 | # | ||
549 | # Multifunction device drivers | ||
550 | # | ||
551 | # CONFIG_MFD_SM501 is not set | ||
552 | |||
553 | # | ||
554 | # Multimedia devices | ||
555 | # | ||
556 | CONFIG_VIDEO_DEV=m | ||
557 | CONFIG_VIDEO_V4L1=y | ||
558 | CONFIG_VIDEO_V4L1_COMPAT=y | ||
559 | CONFIG_VIDEO_V4L2=y | ||
560 | CONFIG_VIDEO_CAPTURE_DRIVERS=y | ||
561 | # CONFIG_VIDEO_ADV_DEBUG is not set | ||
562 | CONFIG_VIDEO_HELPER_CHIPS_AUTO=y | ||
563 | # CONFIG_VIDEO_CPIA is not set | ||
564 | CONFIG_VIDEO_M32R_AR=m | ||
565 | CONFIG_VIDEO_M32R_AR_M64278=m | ||
566 | CONFIG_RADIO_ADAPTERS=y | ||
567 | # CONFIG_DVB_CORE is not set | ||
568 | CONFIG_DAB=y | ||
569 | |||
570 | # | ||
571 | # Graphics support | ||
572 | # | ||
573 | # CONFIG_BACKLIGHT_LCD_SUPPORT is not set | ||
574 | |||
575 | # | ||
576 | # Display device support | ||
577 | # | ||
578 | # CONFIG_DISPLAY_SUPPORT is not set | ||
579 | # CONFIG_VGASTATE is not set | ||
580 | CONFIG_VIDEO_OUTPUT_CONTROL=m | ||
581 | CONFIG_FB=y | ||
582 | CONFIG_FIRMWARE_EDID=y | ||
583 | # CONFIG_FB_DDC is not set | ||
584 | CONFIG_FB_CFB_FILLRECT=y | ||
585 | CONFIG_FB_CFB_COPYAREA=y | ||
586 | CONFIG_FB_CFB_IMAGEBLIT=y | ||
587 | # CONFIG_FB_SYS_FILLRECT is not set | ||
588 | # CONFIG_FB_SYS_COPYAREA is not set | ||
589 | # CONFIG_FB_SYS_IMAGEBLIT is not set | ||
590 | # CONFIG_FB_SYS_FOPS is not set | ||
591 | CONFIG_FB_DEFERRED_IO=y | ||
592 | # CONFIG_FB_SVGALIB is not set | ||
593 | # CONFIG_FB_MACMODES is not set | ||
594 | # CONFIG_FB_BACKLIGHT is not set | ||
595 | # CONFIG_FB_MODE_HELPERS is not set | ||
596 | # CONFIG_FB_TILEBLITTING is not set | ||
597 | |||
598 | # | ||
599 | # Frame buffer hardware drivers | ||
600 | # | ||
601 | CONFIG_FB_S1D13XXX=y | ||
602 | # CONFIG_FB_VIRTUAL is not set | ||
603 | |||
604 | # | ||
605 | # Console display driver support | ||
606 | # | ||
607 | # CONFIG_VGA_CONSOLE is not set | ||
608 | CONFIG_DUMMY_CONSOLE=y | ||
609 | CONFIG_FRAMEBUFFER_CONSOLE=y | ||
610 | # CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set | ||
611 | # CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set | ||
612 | # CONFIG_FONTS is not set | ||
613 | CONFIG_FONT_8x8=y | ||
614 | CONFIG_FONT_8x16=y | ||
615 | CONFIG_LOGO=y | ||
616 | CONFIG_LOGO_LINUX_MONO=y | ||
617 | CONFIG_LOGO_LINUX_VGA16=y | ||
618 | CONFIG_LOGO_LINUX_CLUT224=y | ||
619 | CONFIG_LOGO_M32R_CLUT224=y | ||
620 | |||
621 | # | ||
622 | # Sound | ||
623 | # | ||
624 | # CONFIG_SOUND is not set | ||
625 | CONFIG_HID_SUPPORT=y | ||
626 | CONFIG_HID=y | ||
627 | # CONFIG_HID_DEBUG is not set | ||
628 | CONFIG_USB_SUPPORT=y | ||
629 | # CONFIG_USB_ARCH_HAS_HCD is not set | ||
630 | # CONFIG_USB_ARCH_HAS_OHCI is not set | ||
631 | # CONFIG_USB_ARCH_HAS_EHCI is not set | ||
632 | |||
633 | # | ||
634 | # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' | ||
635 | # | ||
636 | |||
637 | # | ||
638 | # USB Gadget Support | ||
639 | # | ||
640 | # CONFIG_USB_GADGET is not set | ||
641 | CONFIG_MMC=y | ||
642 | CONFIG_MMC_DEBUG=y | ||
643 | # CONFIG_MMC_UNSAFE_RESUME is not set | ||
644 | |||
645 | # | ||
646 | # MMC/SD Card Drivers | ||
647 | # | ||
648 | CONFIG_MMC_BLOCK=y | ||
649 | CONFIG_MMC_BLOCK_BOUNCE=y | ||
650 | |||
651 | # | ||
652 | # MMC/SD Host Controller Drivers | ||
653 | # | ||
654 | # CONFIG_NEW_LEDS is not set | ||
655 | |||
656 | # | ||
657 | # Real Time Clock | ||
658 | # | ||
659 | # CONFIG_RTC_CLASS is not set | ||
660 | |||
661 | # | ||
662 | # Userspace I/O | ||
663 | # | ||
664 | # CONFIG_UIO is not set | ||
665 | |||
666 | # | ||
667 | # File systems | ||
668 | # | ||
669 | CONFIG_EXT2_FS=y | ||
670 | # CONFIG_EXT2_FS_XATTR is not set | ||
671 | # CONFIG_EXT2_FS_XIP is not set | ||
672 | CONFIG_EXT3_FS=y | ||
673 | CONFIG_EXT3_FS_XATTR=y | ||
674 | # CONFIG_EXT3_FS_POSIX_ACL is not set | ||
675 | # CONFIG_EXT3_FS_SECURITY is not set | ||
676 | # CONFIG_EXT4DEV_FS is not set | ||
677 | CONFIG_JBD=y | ||
678 | CONFIG_JBD_DEBUG=y | ||
679 | CONFIG_FS_MBCACHE=y | ||
680 | CONFIG_REISERFS_FS=m | ||
681 | # CONFIG_REISERFS_CHECK is not set | ||
682 | # CONFIG_REISERFS_PROC_INFO is not set | ||
683 | # CONFIG_REISERFS_FS_XATTR is not set | ||
684 | # CONFIG_JFS_FS is not set | ||
685 | # CONFIG_FS_POSIX_ACL is not set | ||
686 | # CONFIG_XFS_FS is not set | ||
687 | # CONFIG_GFS2_FS is not set | ||
688 | # CONFIG_OCFS2_FS is not set | ||
689 | # CONFIG_MINIX_FS is not set | ||
690 | # CONFIG_ROMFS_FS is not set | ||
691 | CONFIG_INOTIFY=y | ||
692 | CONFIG_INOTIFY_USER=y | ||
693 | # CONFIG_QUOTA is not set | ||
694 | CONFIG_DNOTIFY=y | ||
695 | # CONFIG_AUTOFS_FS is not set | ||
696 | # CONFIG_AUTOFS4_FS is not set | ||
697 | # CONFIG_FUSE_FS is not set | ||
698 | |||
699 | # | ||
700 | # CD-ROM/DVD Filesystems | ||
701 | # | ||
702 | CONFIG_ISO9660_FS=m | ||
703 | CONFIG_JOLIET=y | ||
704 | # CONFIG_ZISOFS is not set | ||
705 | CONFIG_UDF_FS=m | ||
706 | CONFIG_UDF_NLS=y | ||
707 | |||
708 | # | ||
709 | # DOS/FAT/NT Filesystems | ||
710 | # | ||
711 | CONFIG_FAT_FS=m | ||
712 | CONFIG_MSDOS_FS=m | ||
713 | CONFIG_VFAT_FS=m | ||
714 | CONFIG_FAT_DEFAULT_CODEPAGE=437 | ||
715 | CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" | ||
716 | # CONFIG_NTFS_FS is not set | ||
717 | |||
718 | # | ||
719 | # Pseudo filesystems | ||
720 | # | ||
721 | CONFIG_PROC_FS=y | ||
722 | CONFIG_PROC_KCORE=y | ||
723 | CONFIG_PROC_SYSCTL=y | ||
724 | CONFIG_SYSFS=y | ||
725 | CONFIG_TMPFS=y | ||
726 | # CONFIG_TMPFS_POSIX_ACL is not set | ||
727 | # CONFIG_HUGETLB_PAGE is not set | ||
728 | CONFIG_RAMFS=y | ||
729 | # CONFIG_CONFIGFS_FS is not set | ||
730 | |||
731 | # | ||
732 | # Miscellaneous filesystems | ||
733 | # | ||
734 | # CONFIG_ADFS_FS is not set | ||
735 | # CONFIG_AFFS_FS is not set | ||
736 | # CONFIG_HFS_FS is not set | ||
737 | # CONFIG_HFSPLUS_FS is not set | ||
738 | # CONFIG_BEFS_FS is not set | ||
739 | # CONFIG_BFS_FS is not set | ||
740 | # CONFIG_EFS_FS is not set | ||
741 | # CONFIG_JFFS2_FS is not set | ||
742 | # CONFIG_CRAMFS is not set | ||
743 | # CONFIG_VXFS_FS is not set | ||
744 | # CONFIG_HPFS_FS is not set | ||
745 | # CONFIG_QNX4FS_FS is not set | ||
746 | # CONFIG_SYSV_FS is not set | ||
747 | # CONFIG_UFS_FS is not set | ||
748 | |||
749 | # | ||
750 | # Network File Systems | ||
751 | # | ||
752 | CONFIG_NFS_FS=y | ||
753 | CONFIG_NFS_V3=y | ||
754 | # CONFIG_NFS_V3_ACL is not set | ||
755 | # CONFIG_NFS_V4 is not set | ||
756 | # CONFIG_NFS_DIRECTIO is not set | ||
757 | # CONFIG_NFSD is not set | ||
758 | CONFIG_ROOT_NFS=y | ||
759 | CONFIG_LOCKD=y | ||
760 | CONFIG_LOCKD_V4=y | ||
761 | CONFIG_NFS_COMMON=y | ||
762 | CONFIG_SUNRPC=y | ||
763 | # CONFIG_SUNRPC_BIND34 is not set | ||
764 | # CONFIG_RPCSEC_GSS_KRB5 is not set | ||
765 | # CONFIG_RPCSEC_GSS_SPKM3 is not set | ||
766 | # CONFIG_SMB_FS is not set | ||
767 | # CONFIG_CIFS is not set | ||
768 | # CONFIG_NCP_FS is not set | ||
769 | # CONFIG_CODA_FS is not set | ||
770 | # CONFIG_AFS_FS is not set | ||
771 | |||
772 | # | ||
773 | # Partition Types | ||
774 | # | ||
775 | # CONFIG_PARTITION_ADVANCED is not set | ||
776 | CONFIG_MSDOS_PARTITION=y | ||
777 | |||
778 | # | ||
779 | # Native Language Support | ||
780 | # | ||
781 | CONFIG_NLS=y | ||
782 | CONFIG_NLS_DEFAULT="iso8859-1" | ||
783 | # CONFIG_NLS_CODEPAGE_437 is not set | ||
784 | # CONFIG_NLS_CODEPAGE_737 is not set | ||
785 | # CONFIG_NLS_CODEPAGE_775 is not set | ||
786 | # CONFIG_NLS_CODEPAGE_850 is not set | ||
787 | # CONFIG_NLS_CODEPAGE_852 is not set | ||
788 | # CONFIG_NLS_CODEPAGE_855 is not set | ||
789 | # CONFIG_NLS_CODEPAGE_857 is not set | ||
790 | # CONFIG_NLS_CODEPAGE_860 is not set | ||
791 | # CONFIG_NLS_CODEPAGE_861 is not set | ||
792 | # CONFIG_NLS_CODEPAGE_862 is not set | ||
793 | # CONFIG_NLS_CODEPAGE_863 is not set | ||
794 | # CONFIG_NLS_CODEPAGE_864 is not set | ||
795 | # CONFIG_NLS_CODEPAGE_865 is not set | ||
796 | # CONFIG_NLS_CODEPAGE_866 is not set | ||
797 | # CONFIG_NLS_CODEPAGE_869 is not set | ||
798 | # CONFIG_NLS_CODEPAGE_936 is not set | ||
799 | # CONFIG_NLS_CODEPAGE_950 is not set | ||
800 | # CONFIG_NLS_CODEPAGE_932 is not set | ||
801 | # CONFIG_NLS_CODEPAGE_949 is not set | ||
802 | # CONFIG_NLS_CODEPAGE_874 is not set | ||
803 | # CONFIG_NLS_ISO8859_8 is not set | ||
804 | # CONFIG_NLS_CODEPAGE_1250 is not set | ||
805 | # CONFIG_NLS_CODEPAGE_1251 is not set | ||
806 | # CONFIG_NLS_ASCII is not set | ||
807 | # CONFIG_NLS_ISO8859_1 is not set | ||
808 | # CONFIG_NLS_ISO8859_2 is not set | ||
809 | # CONFIG_NLS_ISO8859_3 is not set | ||
810 | # CONFIG_NLS_ISO8859_4 is not set | ||
811 | # CONFIG_NLS_ISO8859_5 is not set | ||
812 | # CONFIG_NLS_ISO8859_6 is not set | ||
813 | # CONFIG_NLS_ISO8859_7 is not set | ||
814 | # CONFIG_NLS_ISO8859_9 is not set | ||
815 | # CONFIG_NLS_ISO8859_13 is not set | ||
816 | # CONFIG_NLS_ISO8859_14 is not set | ||
817 | # CONFIG_NLS_ISO8859_15 is not set | ||
818 | # CONFIG_NLS_KOI8_R is not set | ||
819 | # CONFIG_NLS_KOI8_U is not set | ||
820 | # CONFIG_NLS_UTF8 is not set | ||
821 | |||
822 | # | ||
823 | # Distributed Lock Manager | ||
824 | # | ||
825 | # CONFIG_DLM is not set | ||
826 | |||
827 | # | ||
828 | # Profiling support | ||
829 | # | ||
830 | CONFIG_PROFILING=y | ||
831 | CONFIG_OPROFILE=y | ||
832 | |||
833 | # | ||
834 | # Kernel hacking | ||
835 | # | ||
836 | # CONFIG_PRINTK_TIME is not set | ||
837 | CONFIG_ENABLE_MUST_CHECK=y | ||
838 | # CONFIG_MAGIC_SYSRQ is not set | ||
839 | # CONFIG_UNUSED_SYMBOLS is not set | ||
840 | # CONFIG_DEBUG_FS is not set | ||
841 | # CONFIG_HEADERS_CHECK is not set | ||
842 | # CONFIG_DEBUG_KERNEL is not set | ||
843 | # CONFIG_DEBUG_BUGVERBOSE is not set | ||
844 | # CONFIG_FRAME_POINTER is not set | ||
845 | |||
846 | # | ||
847 | # Security options | ||
848 | # | ||
849 | # CONFIG_KEYS is not set | ||
850 | # CONFIG_SECURITY is not set | ||
851 | # CONFIG_CRYPTO is not set | ||
852 | |||
853 | # | ||
854 | # Library routines | ||
855 | # | ||
856 | CONFIG_BITREVERSE=y | ||
857 | # CONFIG_CRC_CCITT is not set | ||
858 | # CONFIG_CRC16 is not set | ||
859 | # CONFIG_CRC_ITU_T is not set | ||
860 | CONFIG_CRC32=y | ||
861 | # CONFIG_CRC7 is not set | ||
862 | # CONFIG_LIBCRC32C is not set | ||
863 | CONFIG_HAS_IOMEM=y | ||
diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S index 41b07854fcc6..15a6f36c06db 100644 --- a/arch/m32r/kernel/vmlinux.lds.S +++ b/arch/m32r/kernel/vmlinux.lds.S | |||
@@ -60,9 +60,6 @@ SECTIONS | |||
60 | . = ALIGN(4096); | 60 | . = ALIGN(4096); |
61 | __nosave_end = .; | 61 | __nosave_end = .; |
62 | 62 | ||
63 | . = ALIGN(4096); | ||
64 | .data.page_aligned : { *(.data.idt) } | ||
65 | |||
66 | . = ALIGN(32); | 63 | . = ALIGN(32); |
67 | .data.cacheline_aligned : { *(.data.cacheline_aligned) } | 64 | .data.cacheline_aligned : { *(.data.cacheline_aligned) } |
68 | 65 | ||
diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c index e892f17ba3fa..7f54efaf60bb 100644 --- a/arch/m68k/kernel/sys_m68k.c +++ b/arch/m68k/kernel/sys_m68k.c | |||
@@ -30,23 +30,6 @@ | |||
30 | #include <asm/page.h> | 30 | #include <asm/page.h> |
31 | #include <asm/unistd.h> | 31 | #include <asm/unistd.h> |
32 | 32 | ||
33 | /* | ||
34 | * sys_pipe() is the normal C calling standard for creating | ||
35 | * a pipe. It's not the way unix traditionally does this, though. | ||
36 | */ | ||
37 | asmlinkage int sys_pipe(unsigned long __user * fildes) | ||
38 | { | ||
39 | int fd[2]; | ||
40 | int error; | ||
41 | |||
42 | error = do_pipe(fd); | ||
43 | if (!error) { | ||
44 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
45 | error = -EFAULT; | ||
46 | } | ||
47 | return error; | ||
48 | } | ||
49 | |||
50 | /* common code for old and new mmaps */ | 33 | /* common code for old and new mmaps */ |
51 | static inline long do_mmap2( | 34 | static inline long do_mmap2( |
52 | unsigned long addr, unsigned long len, | 35 | unsigned long addr, unsigned long len, |
diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c index fd4858e2dd63..75b8340b254b 100644 --- a/arch/m68k/kernel/traps.c +++ b/arch/m68k/kernel/traps.c | |||
@@ -468,15 +468,26 @@ static inline void access_error040(struct frame *fp) | |||
468 | * (if do_page_fault didn't fix the mapping, | 468 | * (if do_page_fault didn't fix the mapping, |
469 | * the writeback won't do good) | 469 | * the writeback won't do good) |
470 | */ | 470 | */ |
471 | disable_wb: | ||
471 | #ifdef DEBUG | 472 | #ifdef DEBUG |
472 | printk(".. disabling wb2\n"); | 473 | printk(".. disabling wb2\n"); |
473 | #endif | 474 | #endif |
474 | if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr) | 475 | if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr) |
475 | fp->un.fmt7.wb2s &= ~WBV_040; | 476 | fp->un.fmt7.wb2s &= ~WBV_040; |
477 | if (fp->un.fmt7.wb3a == fp->un.fmt7.faddr) | ||
478 | fp->un.fmt7.wb3s &= ~WBV_040; | ||
476 | } | 479 | } |
477 | } else if (send_fault_sig(&fp->ptregs) > 0) { | 480 | } else { |
478 | printk("68040 access error, ssw=%x\n", ssw); | 481 | /* In case of a bus error we either kill the process or expect |
479 | trap_c(fp); | 482 | * the kernel to catch the fault, which then is also responsible |
483 | * for cleaning up the mess. | ||
484 | */ | ||
485 | current->thread.signo = SIGBUS; | ||
486 | current->thread.faddr = fp->un.fmt7.faddr; | ||
487 | if (send_fault_sig(&fp->ptregs) >= 0) | ||
488 | printk("68040 bus error (ssw=%x, faddr=%lx)\n", ssw, | ||
489 | fp->un.fmt7.faddr); | ||
490 | goto disable_wb; | ||
480 | } | 491 | } |
481 | 492 | ||
482 | do_040writebacks(fp); | 493 | do_040writebacks(fp); |
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index 735a49b4b936..ad3e3bacae39 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c | |||
@@ -48,9 +48,6 @@ | |||
48 | struct mac_booter_data mac_bi_data; | 48 | struct mac_booter_data mac_bi_data; |
49 | int mac_bisize = sizeof mac_bi_data; | 49 | int mac_bisize = sizeof mac_bi_data; |
50 | 50 | ||
51 | struct mac_hw_present mac_hw_present; | ||
52 | EXPORT_SYMBOL(mac_hw_present); | ||
53 | |||
54 | /* New m68k bootinfo stuff and videobase */ | 51 | /* New m68k bootinfo stuff and videobase */ |
55 | 52 | ||
56 | extern int m68k_num_memory; | 53 | extern int m68k_num_memory; |
@@ -817,27 +814,6 @@ void __init mac_identify(void) | |||
817 | m68k_ramdisk.addr, m68k_ramdisk.size); | 814 | m68k_ramdisk.addr, m68k_ramdisk.size); |
818 | #endif | 815 | #endif |
819 | 816 | ||
820 | /* | ||
821 | * TODO: set the various fields in macintosh_config->hw_present here! | ||
822 | */ | ||
823 | switch (macintosh_config->scsi_type) { | ||
824 | case MAC_SCSI_OLD: | ||
825 | MACHW_SET(MAC_SCSI_80); | ||
826 | break; | ||
827 | case MAC_SCSI_QUADRA: | ||
828 | case MAC_SCSI_QUADRA2: | ||
829 | case MAC_SCSI_QUADRA3: | ||
830 | MACHW_SET(MAC_SCSI_96); | ||
831 | if ((macintosh_config->ident == MAC_MODEL_Q900) || | ||
832 | (macintosh_config->ident == MAC_MODEL_Q950)) | ||
833 | MACHW_SET(MAC_SCSI_96_2); | ||
834 | break; | ||
835 | default: | ||
836 | printk(KERN_WARNING "config.c: wtf: unknown scsi, using 53c80\n"); | ||
837 | MACHW_SET(MAC_SCSI_80); | ||
838 | break; | ||
839 | } | ||
840 | |||
841 | iop_init(); | 817 | iop_init(); |
842 | via_init(); | 818 | via_init(); |
843 | oss_init(); | 819 | oss_init(); |
diff --git a/arch/m68knommu/kernel/asm-offsets.c b/arch/m68knommu/kernel/asm-offsets.c index fd0c685a7f11..c785d07c02cc 100644 --- a/arch/m68knommu/kernel/asm-offsets.c +++ b/arch/m68knommu/kernel/asm-offsets.c | |||
@@ -87,6 +87,7 @@ int main(void) | |||
87 | DEFINE(TI_TASK, offsetof(struct thread_info, task)); | 87 | DEFINE(TI_TASK, offsetof(struct thread_info, task)); |
88 | DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain)); | 88 | DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain)); |
89 | DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); | 89 | DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); |
90 | DEFINE(TI_PREEMPTCOUNT, offsetof(struct thread_info, preempt_count)); | ||
90 | DEFINE(TI_CPU, offsetof(struct thread_info, cpu)); | 91 | DEFINE(TI_CPU, offsetof(struct thread_info, cpu)); |
91 | 92 | ||
92 | return 0; | 93 | return 0; |
diff --git a/arch/m68knommu/kernel/entry.S b/arch/m68knommu/kernel/entry.S index 1e7ea6a3e1a1..f4782d2dce8f 100644 --- a/arch/m68knommu/kernel/entry.S +++ b/arch/m68knommu/kernel/entry.S | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <asm/segment.h> | 32 | #include <asm/segment.h> |
33 | #include <asm/asm-offsets.h> | 33 | #include <asm/asm-offsets.h> |
34 | #include <asm/entry.h> | 34 | #include <asm/entry.h> |
35 | #include <asm/unistd.h> | ||
35 | 36 | ||
36 | .text | 37 | .text |
37 | 38 | ||
@@ -140,3 +141,11 @@ ENTRY(sys_rt_sigreturn) | |||
140 | RESTORE_SWITCH_STACK | 141 | RESTORE_SWITCH_STACK |
141 | rts | 142 | rts |
142 | 143 | ||
144 | ENTRY(ret_from_user_signal) | ||
145 | moveq #__NR_sigreturn,%d0 | ||
146 | trap #0 | ||
147 | |||
148 | ENTRY(ret_from_user_rt_signal) | ||
149 | move #__NR_rt_sigreturn,%d0 | ||
150 | trap #0 | ||
151 | |||
diff --git a/arch/m68knommu/kernel/setup.c b/arch/m68knommu/kernel/setup.c index d6f0200316fe..03f4fe6a2fc0 100644 --- a/arch/m68knommu/kernel/setup.c +++ b/arch/m68knommu/kernel/setup.c | |||
@@ -162,7 +162,7 @@ void __init setup_arch(char **cmdline_p) | |||
162 | printk(KERN_INFO "DragonEngine II board support by Georges Menie\n"); | 162 | printk(KERN_INFO "DragonEngine II board support by Georges Menie\n"); |
163 | #endif | 163 | #endif |
164 | #ifdef CONFIG_M5235EVB | 164 | #ifdef CONFIG_M5235EVB |
165 | printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)"); | 165 | printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)\n"); |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | #ifdef DEBUG | 168 | #ifdef DEBUG |
diff --git a/arch/m68knommu/kernel/signal.c b/arch/m68knommu/kernel/signal.c index 70371378db86..bbfcae9e52b4 100644 --- a/arch/m68knommu/kernel/signal.c +++ b/arch/m68knommu/kernel/signal.c | |||
@@ -51,6 +51,8 @@ | |||
51 | 51 | ||
52 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | 52 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
53 | 53 | ||
54 | void ret_from_user_signal(void); | ||
55 | void ret_from_user_rt_signal(void); | ||
54 | asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs); | 56 | asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs); |
55 | 57 | ||
56 | /* | 58 | /* |
@@ -539,10 +541,6 @@ static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs) | |||
539 | return err; | 541 | return err; |
540 | } | 542 | } |
541 | 543 | ||
542 | static inline void push_cache (unsigned long vaddr) | ||
543 | { | ||
544 | } | ||
545 | |||
546 | static inline void * | 544 | static inline void * |
547 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) | 545 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) |
548 | { | 546 | { |
@@ -586,16 +584,11 @@ static void setup_frame (int sig, struct k_sigaction *ka, | |||
586 | err |= copy_to_user (&frame->sc, &context, sizeof(context)); | 584 | err |= copy_to_user (&frame->sc, &context, sizeof(context)); |
587 | 585 | ||
588 | /* Set up to return from userspace. */ | 586 | /* Set up to return from userspace. */ |
589 | err |= __put_user(frame->retcode, &frame->pretcode); | 587 | err |= __put_user((void *) ret_from_user_signal, &frame->pretcode); |
590 | /* moveq #,d0; trap #0 */ | ||
591 | err |= __put_user(0x70004e40 + (__NR_sigreturn << 16), | ||
592 | (long *)(frame->retcode)); | ||
593 | 588 | ||
594 | if (err) | 589 | if (err) |
595 | goto give_sigsegv; | 590 | goto give_sigsegv; |
596 | 591 | ||
597 | push_cache ((unsigned long) &frame->retcode); | ||
598 | |||
599 | /* Set up registers for signal handler */ | 592 | /* Set up registers for signal handler */ |
600 | wrusp ((unsigned long) frame); | 593 | wrusp ((unsigned long) frame); |
601 | regs->pc = (unsigned long) ka->sa.sa_handler; | 594 | regs->pc = (unsigned long) ka->sa.sa_handler; |
@@ -655,17 +648,11 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info, | |||
655 | err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set)); | 648 | err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set)); |
656 | 649 | ||
657 | /* Set up to return from userspace. */ | 650 | /* Set up to return from userspace. */ |
658 | err |= __put_user(frame->retcode, &frame->pretcode); | 651 | err |= __put_user((void *) ret_from_user_rt_signal, &frame->pretcode); |
659 | /* moveq #,d0; notb d0; trap #0 */ | ||
660 | err |= __put_user(0x70004600 + ((__NR_rt_sigreturn ^ 0xff) << 16), | ||
661 | (long *)(frame->retcode + 0)); | ||
662 | err |= __put_user(0x4e40, (short *)(frame->retcode + 4)); | ||
663 | 652 | ||
664 | if (err) | 653 | if (err) |
665 | goto give_sigsegv; | 654 | goto give_sigsegv; |
666 | 655 | ||
667 | push_cache ((unsigned long) &frame->retcode); | ||
668 | |||
669 | /* Set up registers for signal handler */ | 656 | /* Set up registers for signal handler */ |
670 | wrusp ((unsigned long) frame); | 657 | wrusp ((unsigned long) frame); |
671 | regs->pc = (unsigned long) ka->sa.sa_handler; | 658 | regs->pc = (unsigned long) ka->sa.sa_handler; |
diff --git a/arch/m68knommu/kernel/sys_m68k.c b/arch/m68knommu/kernel/sys_m68k.c index 65f7a95f056e..700281638629 100644 --- a/arch/m68knommu/kernel/sys_m68k.c +++ b/arch/m68knommu/kernel/sys_m68k.c | |||
@@ -28,23 +28,6 @@ | |||
28 | #include <asm/cacheflush.h> | 28 | #include <asm/cacheflush.h> |
29 | #include <asm/unistd.h> | 29 | #include <asm/unistd.h> |
30 | 30 | ||
31 | /* | ||
32 | * sys_pipe() is the normal C calling standard for creating | ||
33 | * a pipe. It's not the way unix traditionally does this, though. | ||
34 | */ | ||
35 | asmlinkage int sys_pipe(unsigned long * fildes) | ||
36 | { | ||
37 | int fd[2]; | ||
38 | int error; | ||
39 | |||
40 | error = do_pipe(fd); | ||
41 | if (!error) { | ||
42 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
43 | error = -EFAULT; | ||
44 | } | ||
45 | return error; | ||
46 | } | ||
47 | |||
48 | /* common code for old and new mmaps */ | 31 | /* common code for old and new mmaps */ |
49 | static inline long do_mmap2( | 32 | static inline long do_mmap2( |
50 | unsigned long addr, unsigned long len, | 33 | unsigned long addr, unsigned long len, |
diff --git a/arch/m68knommu/kernel/traps.c b/arch/m68knommu/kernel/traps.c index 437a061d8b94..ec9aea652e79 100644 --- a/arch/m68knommu/kernel/traps.c +++ b/arch/m68knommu/kernel/traps.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/linkage.h> | 28 | #include <linux/linkage.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/ptrace.h> | 30 | #include <linux/ptrace.h> |
31 | #include <linux/kallsyms.h> | ||
31 | 32 | ||
32 | #include <asm/setup.h> | 33 | #include <asm/setup.h> |
33 | #include <asm/fpu.h> | 34 | #include <asm/fpu.h> |
@@ -102,56 +103,47 @@ asmlinkage void buserr_c(struct frame *fp) | |||
102 | force_sig(SIGSEGV, current); | 103 | force_sig(SIGSEGV, current); |
103 | } | 104 | } |
104 | 105 | ||
105 | |||
106 | int kstack_depth_to_print = 48; | 106 | int kstack_depth_to_print = 48; |
107 | 107 | ||
108 | void show_stack(struct task_struct *task, unsigned long *stack) | 108 | static void __show_stack(struct task_struct *task, unsigned long *stack) |
109 | { | 109 | { |
110 | unsigned long *endstack, addr; | 110 | unsigned long *endstack, addr; |
111 | extern char _start, _etext; | 111 | unsigned long *last_stack; |
112 | int i; | 112 | int i; |
113 | 113 | ||
114 | if (!stack) { | 114 | if (!stack) |
115 | if (task) | 115 | stack = (unsigned long *)task->thread.ksp; |
116 | stack = (unsigned long *)task->thread.ksp; | ||
117 | else | ||
118 | stack = (unsigned long *)&stack; | ||
119 | } | ||
120 | 116 | ||
121 | addr = (unsigned long) stack; | 117 | addr = (unsigned long) stack; |
122 | endstack = (unsigned long *) PAGE_ALIGN(addr); | 118 | endstack = (unsigned long *) PAGE_ALIGN(addr); |
123 | 119 | ||
124 | printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack); | 120 | printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack); |
125 | for (i = 0; i < kstack_depth_to_print; i++) { | 121 | for (i = 0; i < kstack_depth_to_print; i++) { |
126 | if (stack + 1 > endstack) | 122 | if (stack + 1 + i > endstack) |
127 | break; | 123 | break; |
128 | if (i % 8 == 0) | 124 | if (i % 8 == 0) |
129 | printk("\n" KERN_EMERG " "); | 125 | printk("\n" KERN_EMERG " "); |
130 | printk(" %08lx", *stack++); | 126 | printk(" %08lx", *(stack + i)); |
131 | } | 127 | } |
132 | printk("\n"); | 128 | printk("\n"); |
133 | 129 | ||
134 | printk(KERN_EMERG "Call Trace:"); | 130 | #ifdef CONFIG_FRAME_POINTER |
135 | i = 0; | 131 | printk(KERN_EMERG "Call Trace:\n"); |
136 | while (stack + 1 <= endstack) { | 132 | |
137 | addr = *stack++; | 133 | last_stack = stack - 1; |
138 | /* | 134 | while (stack <= endstack && stack > last_stack) { |
139 | * If the address is either in the text segment of the | 135 | |
140 | * kernel, or in the region which contains vmalloc'ed | 136 | addr = *(stack + 1); |
141 | * memory, it *may* be the address of a calling | 137 | printk(KERN_EMERG " [%08lx] ", addr); |
142 | * routine; if so, print it so that someone tracing | 138 | print_symbol(KERN_CONT "%s\n", addr); |
143 | * down the cause of the crash will be able to figure | 139 | |
144 | * out the call path that was taken. | 140 | last_stack = stack; |
145 | */ | 141 | stack = (unsigned long *)*stack; |
146 | if (((addr >= (unsigned long) &_start) && | ||
147 | (addr <= (unsigned long) &_etext))) { | ||
148 | if (i % 4 == 0) | ||
149 | printk("\n" KERN_EMERG " "); | ||
150 | printk(" [<%08lx>]", addr); | ||
151 | i++; | ||
152 | } | ||
153 | } | 142 | } |
154 | printk("\n"); | 143 | printk("\n"); |
144 | #else | ||
145 | printk(KERN_EMERG "CONFIG_FRAME_POINTER disabled, no symbolic call trace\n"); | ||
146 | #endif | ||
155 | } | 147 | } |
156 | 148 | ||
157 | void bad_super_trap(struct frame *fp) | 149 | void bad_super_trap(struct frame *fp) |
@@ -298,19 +290,47 @@ asmlinkage void set_esp0(unsigned long ssp) | |||
298 | current->thread.esp0 = ssp; | 290 | current->thread.esp0 = ssp; |
299 | } | 291 | } |
300 | 292 | ||
301 | |||
302 | /* | 293 | /* |
303 | * The architecture-independent backtrace generator | 294 | * The architecture-independent backtrace generator |
304 | */ | 295 | */ |
305 | void dump_stack(void) | 296 | void dump_stack(void) |
306 | { | 297 | { |
307 | unsigned long stack; | 298 | /* |
299 | * We need frame pointers for this little trick, which works as follows: | ||
300 | * | ||
301 | * +------------+ 0x00 | ||
302 | * | Next SP | -> 0x0c | ||
303 | * +------------+ 0x04 | ||
304 | * | Caller | | ||
305 | * +------------+ 0x08 | ||
306 | * | Local vars | -> our stack var | ||
307 | * +------------+ 0x0c | ||
308 | * | Next SP | -> 0x18, that is what we pass to show_stack() | ||
309 | * +------------+ 0x10 | ||
310 | * | Caller | | ||
311 | * +------------+ 0x14 | ||
312 | * | Local vars | | ||
313 | * +------------+ 0x18 | ||
314 | * | ... | | ||
315 | * +------------+ | ||
316 | */ | ||
308 | 317 | ||
309 | show_stack(current, &stack); | 318 | unsigned long *stack; |
310 | } | ||
311 | 319 | ||
320 | stack = (unsigned long *)&stack; | ||
321 | stack++; | ||
322 | __show_stack(current, stack); | ||
323 | } | ||
312 | EXPORT_SYMBOL(dump_stack); | 324 | EXPORT_SYMBOL(dump_stack); |
313 | 325 | ||
326 | void show_stack(struct task_struct *task, unsigned long *stack) | ||
327 | { | ||
328 | if (!stack && !task) | ||
329 | dump_stack(); | ||
330 | else | ||
331 | __show_stack(task, stack); | ||
332 | } | ||
333 | |||
314 | #ifdef CONFIG_M68KFPU_EMU | 334 | #ifdef CONFIG_M68KFPU_EMU |
315 | asmlinkage void fpemu_signal(int signal, int code, void *addr) | 335 | asmlinkage void fpemu_signal(int signal, int code, void *addr) |
316 | { | 336 | { |
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S index b44edb08e212..5592e0bf951f 100644 --- a/arch/m68knommu/kernel/vmlinux.lds.S +++ b/arch/m68knommu/kernel/vmlinux.lds.S | |||
@@ -64,6 +64,7 @@ SECTIONS { | |||
64 | _stext = . ; | 64 | _stext = . ; |
65 | TEXT_TEXT | 65 | TEXT_TEXT |
66 | SCHED_TEXT | 66 | SCHED_TEXT |
67 | LOCK_TEXT | ||
67 | *(.text.lock) | 68 | *(.text.lock) |
68 | 69 | ||
69 | . = ALIGN(16); /* Exception table */ | 70 | . = ALIGN(16); /* Exception table */ |
@@ -73,6 +74,7 @@ SECTIONS { | |||
73 | 74 | ||
74 | *(.rodata) *(.rodata.*) | 75 | *(.rodata) *(.rodata.*) |
75 | *(__vermagic) /* Kernel version magic */ | 76 | *(__vermagic) /* Kernel version magic */ |
77 | *(__markers_strings) | ||
76 | *(.rodata1) | 78 | *(.rodata1) |
77 | *(.rodata.str1.1) | 79 | *(.rodata.str1.1) |
78 | 80 | ||
@@ -182,6 +184,7 @@ SECTIONS { | |||
182 | *(COMMON) | 184 | *(COMMON) |
183 | . = ALIGN(4) ; | 185 | . = ALIGN(4) ; |
184 | _ebss = . ; | 186 | _ebss = . ; |
187 | _end = . ; | ||
185 | } > BSS | 188 | } > BSS |
186 | 189 | ||
187 | } | 190 | } |
diff --git a/arch/m68knommu/platform/5206e/config.c b/arch/m68knommu/platform/5206e/config.c index a6692e958f6b..d01a5d2b7557 100644 --- a/arch/m68knommu/platform/5206e/config.c +++ b/arch/m68knommu/platform/5206e/config.c | |||
@@ -48,7 +48,7 @@ static struct platform_device *m5206e_devices[] __initdata = { | |||
48 | 48 | ||
49 | /***************************************************************************/ | 49 | /***************************************************************************/ |
50 | 50 | ||
51 | static void __init m5206_uart_init_line(int line, int irq) | 51 | static void __init m5206e_uart_init_line(int line, int irq) |
52 | { | 52 | { |
53 | if (line == 0) { | 53 | if (line == 0) { |
54 | writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); | 54 | writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); |
diff --git a/arch/m68knommu/platform/5272/config.c b/arch/m68knommu/platform/5272/config.c index 2aca599a1ca7..230bae691a7f 100644 --- a/arch/m68knommu/platform/5272/config.c +++ b/arch/m68knommu/platform/5272/config.c | |||
@@ -139,10 +139,6 @@ void __init config_BSP(char *commandp, int size) | |||
139 | /* Copy command line from FLASH to local buffer... */ | 139 | /* Copy command line from FLASH to local buffer... */ |
140 | memcpy(commandp, (char *) 0xf0004000, size); | 140 | memcpy(commandp, (char *) 0xf0004000, size); |
141 | commandp[size-1] = 0; | 141 | commandp[size-1] = 0; |
142 | #elif defined(CONFIG_MTD_KeyTechnology) | ||
143 | /* Copy command line from FLASH to local buffer... */ | ||
144 | memcpy(commandp, (char *) 0xffe06000, size); | ||
145 | commandp[size-1] = 0; | ||
146 | #elif defined(CONFIG_CANCam) | 142 | #elif defined(CONFIG_CANCam) |
147 | /* Copy command line from FLASH to local buffer... */ | 143 | /* Copy command line from FLASH to local buffer... */ |
148 | memcpy(commandp, (char *) 0xf0010000, size); | 144 | memcpy(commandp, (char *) 0xf0010000, size); |
diff --git a/arch/m68knommu/platform/528x/config.c b/arch/m68knommu/platform/528x/config.c index 036e1b73d944..dfdb5c2ed8e6 100644 --- a/arch/m68knommu/platform/528x/config.c +++ b/arch/m68knommu/platform/528x/config.c | |||
@@ -26,9 +26,240 @@ | |||
26 | #include <asm/mcfuart.h> | 26 | #include <asm/mcfuart.h> |
27 | #include <asm/mcfqspi.h> | 27 | #include <asm/mcfqspi.h> |
28 | 28 | ||
29 | #ifdef CONFIG_MTD_PARTITIONS | ||
30 | #include <linux/mtd/partitions.h> | ||
31 | #endif | ||
32 | |||
29 | /***************************************************************************/ | 33 | /***************************************************************************/ |
30 | 34 | ||
31 | void coldfire_reset(void); | 35 | void coldfire_reset(void); |
36 | static void coldfire_qspi_cs_control(u8 cs, u8 command); | ||
37 | |||
38 | /***************************************************************************/ | ||
39 | |||
40 | #if defined(CONFIG_SPI) | ||
41 | |||
42 | #if defined(CONFIG_WILDFIRE) | ||
43 | #define SPI_NUM_CHIPSELECTS 0x02 | ||
44 | #define SPI_PAR_VAL 0x07 /* Enable DIN, DOUT, CLK */ | ||
45 | #define SPI_CS_MASK 0x18 | ||
46 | |||
47 | #define FLASH_BLOCKSIZE (1024*64) | ||
48 | #define FLASH_NUMBLOCKS 16 | ||
49 | #define FLASH_TYPE "m25p80" | ||
50 | |||
51 | #define M25P80_CS 0 | ||
52 | #define MMC_CS 1 | ||
53 | |||
54 | #ifdef CONFIG_MTD_PARTITIONS | ||
55 | static struct mtd_partition stm25p_partitions[] = { | ||
56 | /* sflash */ | ||
57 | [0] = { | ||
58 | .name = "stm25p80", | ||
59 | .offset = 0x00000000, | ||
60 | .size = FLASH_BLOCKSIZE * FLASH_NUMBLOCKS, | ||
61 | .mask_flags = 0 | ||
62 | } | ||
63 | }; | ||
64 | |||
65 | #endif | ||
66 | |||
67 | #elif defined(CONFIG_WILDFIREMOD) | ||
68 | |||
69 | #define SPI_NUM_CHIPSELECTS 0x08 | ||
70 | #define SPI_PAR_VAL 0x07 /* Enable DIN, DOUT, CLK */ | ||
71 | #define SPI_CS_MASK 0x78 | ||
72 | |||
73 | #define FLASH_BLOCKSIZE (1024*64) | ||
74 | #define FLASH_NUMBLOCKS 64 | ||
75 | #define FLASH_TYPE "m25p32" | ||
76 | /* Reserve 1M for the kernel parition */ | ||
77 | #define FLASH_KERNEL_SIZE (1024 * 1024) | ||
78 | |||
79 | #define M25P80_CS 5 | ||
80 | #define MMC_CS 6 | ||
81 | |||
82 | #ifdef CONFIG_MTD_PARTITIONS | ||
83 | static struct mtd_partition stm25p_partitions[] = { | ||
84 | /* sflash */ | ||
85 | [0] = { | ||
86 | .name = "kernel", | ||
87 | .offset = FLASH_BLOCKSIZE * FLASH_NUMBLOCKS - FLASH_KERNEL_SIZE, | ||
88 | .size = FLASH_KERNEL_SIZE, | ||
89 | .mask_flags = 0 | ||
90 | }, | ||
91 | [1] = { | ||
92 | .name = "image", | ||
93 | .offset = 0x00000000, | ||
94 | .size = FLASH_BLOCKSIZE * FLASH_NUMBLOCKS - FLASH_KERNEL_SIZE, | ||
95 | .mask_flags = 0 | ||
96 | }, | ||
97 | [2] = { | ||
98 | .name = "all", | ||
99 | .offset = 0x00000000, | ||
100 | .size = FLASH_BLOCKSIZE * FLASH_NUMBLOCKS, | ||
101 | .mask_flags = 0 | ||
102 | } | ||
103 | }; | ||
104 | #endif | ||
105 | |||
106 | #else | ||
107 | #define SPI_NUM_CHIPSELECTS 0x04 | ||
108 | #define SPI_PAR_VAL 0x7F /* Enable DIN, DOUT, CLK, CS0 - CS4 */ | ||
109 | #endif | ||
110 | |||
111 | #ifdef MMC_CS | ||
112 | static struct coldfire_spi_chip flash_chip_info = { | ||
113 | .mode = SPI_MODE_0, | ||
114 | .bits_per_word = 16, | ||
115 | .del_cs_to_clk = 17, | ||
116 | .del_after_trans = 1, | ||
117 | .void_write_data = 0 | ||
118 | }; | ||
119 | |||
120 | static struct coldfire_spi_chip mmc_chip_info = { | ||
121 | .mode = SPI_MODE_0, | ||
122 | .bits_per_word = 16, | ||
123 | .del_cs_to_clk = 17, | ||
124 | .del_after_trans = 1, | ||
125 | .void_write_data = 0xFFFF | ||
126 | }; | ||
127 | #endif | ||
128 | |||
129 | #ifdef M25P80_CS | ||
130 | static struct flash_platform_data stm25p80_platform_data = { | ||
131 | .name = "ST M25P80 SPI Flash chip", | ||
132 | #ifdef CONFIG_MTD_PARTITIONS | ||
133 | .parts = stm25p_partitions, | ||
134 | .nr_parts = sizeof(stm25p_partitions) / sizeof(*stm25p_partitions), | ||
135 | #endif | ||
136 | .type = FLASH_TYPE | ||
137 | }; | ||
138 | #endif | ||
139 | |||
140 | static struct spi_board_info spi_board_info[] __initdata = { | ||
141 | #ifdef M25P80_CS | ||
142 | { | ||
143 | .modalias = "m25p80", | ||
144 | .max_speed_hz = 16000000, | ||
145 | .bus_num = 1, | ||
146 | .chip_select = M25P80_CS, | ||
147 | .platform_data = &stm25p80_platform_data, | ||
148 | .controller_data = &flash_chip_info | ||
149 | }, | ||
150 | #endif | ||
151 | #ifdef MMC_CS | ||
152 | { | ||
153 | .modalias = "mmc_spi", | ||
154 | .max_speed_hz = 16000000, | ||
155 | .bus_num = 1, | ||
156 | .chip_select = MMC_CS, | ||
157 | .controller_data = &mmc_chip_info | ||
158 | } | ||
159 | #endif | ||
160 | }; | ||
161 | |||
162 | static struct coldfire_spi_master coldfire_master_info = { | ||
163 | .bus_num = 1, | ||
164 | .num_chipselect = SPI_NUM_CHIPSELECTS, | ||
165 | .irq_source = MCF5282_QSPI_IRQ_SOURCE, | ||
166 | .irq_vector = MCF5282_QSPI_IRQ_VECTOR, | ||
167 | .irq_mask = ((0x01 << MCF5282_QSPI_IRQ_SOURCE) | 0x01), | ||
168 | .irq_lp = 0x2B, /* Level 5 and Priority 3 */ | ||
169 | .par_val = SPI_PAR_VAL, | ||
170 | .cs_control = coldfire_qspi_cs_control, | ||
171 | }; | ||
172 | |||
173 | static struct resource coldfire_spi_resources[] = { | ||
174 | [0] = { | ||
175 | .name = "qspi-par", | ||
176 | .start = MCF5282_QSPI_PAR, | ||
177 | .end = MCF5282_QSPI_PAR, | ||
178 | .flags = IORESOURCE_MEM | ||
179 | }, | ||
180 | |||
181 | [1] = { | ||
182 | .name = "qspi-module", | ||
183 | .start = MCF5282_QSPI_QMR, | ||
184 | .end = MCF5282_QSPI_QMR + 0x18, | ||
185 | .flags = IORESOURCE_MEM | ||
186 | }, | ||
187 | |||
188 | [2] = { | ||
189 | .name = "qspi-int-level", | ||
190 | .start = MCF5282_INTC0 + MCFINTC_ICR0 + MCF5282_QSPI_IRQ_SOURCE, | ||
191 | .end = MCF5282_INTC0 + MCFINTC_ICR0 + MCF5282_QSPI_IRQ_SOURCE, | ||
192 | .flags = IORESOURCE_MEM | ||
193 | }, | ||
194 | |||
195 | [3] = { | ||
196 | .name = "qspi-int-mask", | ||
197 | .start = MCF5282_INTC0 + MCFINTC_IMRL, | ||
198 | .end = MCF5282_INTC0 + MCFINTC_IMRL, | ||
199 | .flags = IORESOURCE_MEM | ||
200 | } | ||
201 | }; | ||
202 | |||
203 | static struct platform_device coldfire_spi = { | ||
204 | .name = "spi_coldfire", | ||
205 | .id = -1, | ||
206 | .resource = coldfire_spi_resources, | ||
207 | .num_resources = ARRAY_SIZE(coldfire_spi_resources), | ||
208 | .dev = { | ||
209 | .platform_data = &coldfire_master_info, | ||
210 | } | ||
211 | }; | ||
212 | |||
213 | static void coldfire_qspi_cs_control(u8 cs, u8 command) | ||
214 | { | ||
215 | u8 cs_bit = ((0x01 << cs) << 3) & SPI_CS_MASK; | ||
216 | |||
217 | #if defined(CONFIG_WILDFIRE) | ||
218 | u8 cs_mask = ~(((0x01 << cs) << 3) & SPI_CS_MASK); | ||
219 | #endif | ||
220 | #if defined(CONFIG_WILDFIREMOD) | ||
221 | u8 cs_mask = (cs << 3) & SPI_CS_MASK; | ||
222 | #endif | ||
223 | |||
224 | /* | ||
225 | * Don't do anything if the chip select is not | ||
226 | * one of the port qs pins. | ||
227 | */ | ||
228 | if (command & QSPI_CS_INIT) { | ||
229 | #if defined(CONFIG_WILDFIRE) | ||
230 | MCF5282_GPIO_DDRQS |= cs_bit; | ||
231 | MCF5282_GPIO_PQSPAR &= ~cs_bit; | ||
232 | #endif | ||
233 | |||
234 | #if defined(CONFIG_WILDFIREMOD) | ||
235 | MCF5282_GPIO_DDRQS |= SPI_CS_MASK; | ||
236 | MCF5282_GPIO_PQSPAR &= ~SPI_CS_MASK; | ||
237 | #endif | ||
238 | } | ||
239 | |||
240 | if (command & QSPI_CS_ASSERT) { | ||
241 | MCF5282_GPIO_PORTQS &= ~SPI_CS_MASK; | ||
242 | MCF5282_GPIO_PORTQS |= cs_mask; | ||
243 | } else if (command & QSPI_CS_DROP) { | ||
244 | MCF5282_GPIO_PORTQS |= SPI_CS_MASK; | ||
245 | } | ||
246 | } | ||
247 | |||
248 | static int __init spi_dev_init(void) | ||
249 | { | ||
250 | int retval; | ||
251 | |||
252 | retval = platform_device_register(&coldfire_spi); | ||
253 | if (retval < 0) | ||
254 | return retval; | ||
255 | |||
256 | if (ARRAY_SIZE(spi_board_info)) | ||
257 | retval = spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); | ||
258 | |||
259 | return retval; | ||
260 | } | ||
261 | |||
262 | #endif /* CONFIG_SPI */ | ||
32 | 263 | ||
33 | /***************************************************************************/ | 264 | /***************************************************************************/ |
34 | 265 | ||
@@ -111,10 +342,43 @@ void mcf_autovector(unsigned int vec) | |||
111 | 342 | ||
112 | /***************************************************************************/ | 343 | /***************************************************************************/ |
113 | 344 | ||
345 | #ifdef CONFIG_WILDFIRE | ||
346 | void wildfire_halt(void) | ||
347 | { | ||
348 | writeb(0, 0x30000007); | ||
349 | writeb(0x2, 0x30000007); | ||
350 | } | ||
351 | #endif | ||
352 | |||
353 | #ifdef CONFIG_WILDFIREMOD | ||
354 | void wildfiremod_halt(void) | ||
355 | { | ||
356 | printk(KERN_INFO "WildFireMod hibernating...\n"); | ||
357 | |||
358 | /* Set portE.5 to Digital IO */ | ||
359 | MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2)); | ||
360 | |||
361 | /* Make portE.5 an output */ | ||
362 | MCF5282_GPIO_DDRE |= (1 << 5); | ||
363 | |||
364 | /* Now toggle portE.5 from low to high */ | ||
365 | MCF5282_GPIO_PORTE &= ~(1 << 5); | ||
366 | MCF5282_GPIO_PORTE |= (1 << 5); | ||
367 | |||
368 | printk(KERN_EMERG "Failed to hibernate. Halting!\n"); | ||
369 | } | ||
370 | #endif | ||
371 | |||
114 | void __init config_BSP(char *commandp, int size) | 372 | void __init config_BSP(char *commandp, int size) |
115 | { | 373 | { |
116 | mcf_disableall(); | 374 | mcf_disableall(); |
117 | mach_reset = coldfire_reset; | 375 | |
376 | #ifdef CONFIG_WILDFIRE | ||
377 | mach_halt = wildfire_halt; | ||
378 | #endif | ||
379 | #ifdef CONFIG_WILDFIREMOD | ||
380 | mach_halt = wildfiremod_halt; | ||
381 | #endif | ||
118 | } | 382 | } |
119 | 383 | ||
120 | /***************************************************************************/ | 384 | /***************************************************************************/ |
diff --git a/arch/m68knommu/platform/5307/config.c b/arch/m68knommu/platform/5307/config.c index 92dc862fa826..11cff6625dcc 100644 --- a/arch/m68knommu/platform/5307/config.c +++ b/arch/m68knommu/platform/5307/config.c | |||
@@ -124,8 +124,7 @@ void __init config_BSP(char *commandp, int size) | |||
124 | mcf_setimr(MCFSIM_IMR_MASKALL); | 124 | mcf_setimr(MCFSIM_IMR_MASKALL); |
125 | 125 | ||
126 | #if defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \ | 126 | #if defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \ |
127 | defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \ | 127 | defined(CONFIG_SECUREEDGEMP3) || defined(CONFIG_CLEOPATRA) |
128 | defined(CONFIG_CLEOPATRA) | ||
129 | /* Copy command line from FLASH to local buffer... */ | 128 | /* Copy command line from FLASH to local buffer... */ |
130 | memcpy(commandp, (char *) 0xf0004000, size); | 129 | memcpy(commandp, (char *) 0xf0004000, size); |
131 | commandp[size-1] = 0; | 130 | commandp[size-1] = 0; |
diff --git a/arch/m68knommu/platform/coldfire/entry.S b/arch/m68knommu/platform/coldfire/entry.S index 111b66dc737b..1e3c0dcbd7ac 100644 --- a/arch/m68knommu/platform/coldfire/entry.S +++ b/arch/m68knommu/platform/coldfire/entry.S | |||
@@ -103,9 +103,26 @@ ret_from_signal: | |||
103 | addql #4,%sp | 103 | addql #4,%sp |
104 | 104 | ||
105 | ret_from_exception: | 105 | ret_from_exception: |
106 | move #0x2700,%sr /* disable intrs */ | ||
106 | btst #5,%sp@(PT_SR) /* check if returning to kernel */ | 107 | btst #5,%sp@(PT_SR) /* check if returning to kernel */ |
107 | jeq Luser_return /* if so, skip resched, signals */ | 108 | jeq Luser_return /* if so, skip resched, signals */ |
108 | 109 | ||
110 | #ifdef CONFIG_PREEMPT | ||
111 | movel %sp,%d1 /* get thread_info pointer */ | ||
112 | andl #-THREAD_SIZE,%d1 /* at base of kernel stack */ | ||
113 | movel %d1,%a0 | ||
114 | movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */ | ||
115 | andl #_TIF_NEED_RESCHED,%d1 | ||
116 | jeq Lkernel_return | ||
117 | |||
118 | movel %a0@(TI_PREEMPTCOUNT),%d1 | ||
119 | cmpl #0,%d1 | ||
120 | jne Lkernel_return | ||
121 | |||
122 | pea Lkernel_return | ||
123 | jmp preempt_schedule_irq /* preempt the kernel */ | ||
124 | #endif | ||
125 | |||
109 | Lkernel_return: | 126 | Lkernel_return: |
110 | moveml %sp@,%d1-%d5/%a0-%a2 | 127 | moveml %sp@,%d1-%d5/%a0-%a2 |
111 | lea %sp@(32),%sp /* space for 8 regs */ | 128 | lea %sp@(32),%sp /* space for 8 regs */ |
@@ -140,6 +157,7 @@ Lreturn: | |||
140 | 157 | ||
141 | Lwork_to_do: | 158 | Lwork_to_do: |
142 | movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */ | 159 | movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */ |
160 | move #0x2000,%sr /* enable intrs again */ | ||
143 | btst #TIF_NEED_RESCHED,%d1 | 161 | btst #TIF_NEED_RESCHED,%d1 |
144 | jne reschedule | 162 | jne reschedule |
145 | 163 | ||
diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c index 77db3473deab..9fdd8bcdd21e 100644 --- a/arch/mips/kernel/binfmt_elfn32.c +++ b/arch/mips/kernel/binfmt_elfn32.c | |||
@@ -54,6 +54,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; | |||
54 | #include <linux/module.h> | 54 | #include <linux/module.h> |
55 | #include <linux/elfcore.h> | 55 | #include <linux/elfcore.h> |
56 | #include <linux/compat.h> | 56 | #include <linux/compat.h> |
57 | #include <linux/math64.h> | ||
57 | 58 | ||
58 | #define elf_prstatus elf_prstatus32 | 59 | #define elf_prstatus elf_prstatus32 |
59 | struct elf_prstatus32 | 60 | struct elf_prstatus32 |
@@ -102,8 +103,8 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value) | |||
102 | * one divide. | 103 | * one divide. |
103 | */ | 104 | */ |
104 | u64 nsec = (u64)jiffies * TICK_NSEC; | 105 | u64 nsec = (u64)jiffies * TICK_NSEC; |
105 | long rem; | 106 | u32 rem; |
106 | value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &rem); | 107 | value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem); |
107 | value->tv_usec = rem / NSEC_PER_USEC; | 108 | value->tv_usec = rem / NSEC_PER_USEC; |
108 | } | 109 | } |
109 | 110 | ||
diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c index 08f4cd781ee3..e1333d7319e2 100644 --- a/arch/mips/kernel/binfmt_elfo32.c +++ b/arch/mips/kernel/binfmt_elfo32.c | |||
@@ -56,6 +56,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; | |||
56 | #include <linux/module.h> | 56 | #include <linux/module.h> |
57 | #include <linux/elfcore.h> | 57 | #include <linux/elfcore.h> |
58 | #include <linux/compat.h> | 58 | #include <linux/compat.h> |
59 | #include <linux/math64.h> | ||
59 | 60 | ||
60 | #define elf_prstatus elf_prstatus32 | 61 | #define elf_prstatus elf_prstatus32 |
61 | struct elf_prstatus32 | 62 | struct elf_prstatus32 |
@@ -104,8 +105,8 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value) | |||
104 | * one divide. | 105 | * one divide. |
105 | */ | 106 | */ |
106 | u64 nsec = (u64)jiffies * TICK_NSEC; | 107 | u64 nsec = (u64)jiffies * TICK_NSEC; |
107 | long rem; | 108 | u32 rem; |
108 | value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &rem); | 109 | value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem); |
109 | value->tv_usec = rem / NSEC_PER_USEC; | 110 | value->tv_usec = rem / NSEC_PER_USEC; |
110 | } | 111 | } |
111 | 112 | ||
diff --git a/arch/mips/kernel/irixioctl.c b/arch/mips/kernel/irixioctl.c index 2bde200d5ad0..b39bdba82e02 100644 --- a/arch/mips/kernel/irixioctl.c +++ b/arch/mips/kernel/irixioctl.c | |||
@@ -27,33 +27,6 @@ struct irix_termios { | |||
27 | cc_t c_cc[NCCS]; | 27 | cc_t c_cc[NCCS]; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | extern void start_tty(struct tty_struct *tty); | ||
31 | static struct tty_struct *get_tty(int fd) | ||
32 | { | ||
33 | struct file *filp; | ||
34 | struct tty_struct *ttyp = NULL; | ||
35 | |||
36 | rcu_read_lock(); | ||
37 | filp = fcheck(fd); | ||
38 | if(filp && filp->private_data) { | ||
39 | ttyp = (struct tty_struct *) filp->private_data; | ||
40 | |||
41 | if(ttyp->magic != TTY_MAGIC) | ||
42 | ttyp =NULL; | ||
43 | } | ||
44 | rcu_read_unlock(); | ||
45 | return ttyp; | ||
46 | } | ||
47 | |||
48 | static struct tty_struct *get_real_tty(struct tty_struct *tp) | ||
49 | { | ||
50 | if (tp->driver->type == TTY_DRIVER_TYPE_PTY && | ||
51 | tp->driver->subtype == PTY_TYPE_MASTER) | ||
52 | return tp->link; | ||
53 | else | ||
54 | return tp; | ||
55 | } | ||
56 | |||
57 | asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) | 30 | asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) |
58 | { | 31 | { |
59 | struct tty_struct *tp, *rtp; | 32 | struct tty_struct *tp, *rtp; |
@@ -146,34 +119,24 @@ asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) | |||
146 | error = sys_ioctl(fd, TIOCNOTTY, arg); | 119 | error = sys_ioctl(fd, TIOCNOTTY, arg); |
147 | break; | 120 | break; |
148 | 121 | ||
149 | case 0x00007416: | 122 | case 0x00007416: { |
123 | pid_t pid; | ||
150 | #ifdef DEBUG_IOCTLS | 124 | #ifdef DEBUG_IOCTLS |
151 | printk("TIOCGSID, %08lx) ", arg); | 125 | printk("TIOCGSID, %08lx) ", arg); |
152 | #endif | 126 | #endif |
153 | tp = get_tty(fd); | 127 | old_fs = get_fs(); set_fs(get_ds()); |
154 | if(!tp) { | 128 | error = sys_ioctl(fd, TIOCGSID, (unsigned long)&pid); |
155 | error = -EINVAL; | 129 | set_fs(old_fs); |
156 | break; | 130 | if (!error) |
157 | } | 131 | error = put_user(pid, (unsigned long __user *) arg); |
158 | rtp = get_real_tty(tp); | ||
159 | #ifdef DEBUG_IOCTLS | ||
160 | printk("rtp->session=%d ", rtp->session); | ||
161 | #endif | ||
162 | error = put_user(rtp->session, (unsigned long __user *) arg); | ||
163 | break; | 132 | break; |
164 | 133 | } | |
165 | case 0x746e: | 134 | case 0x746e: |
166 | /* TIOCSTART, same effect as hitting ^Q */ | 135 | /* TIOCSTART, same effect as hitting ^Q */ |
167 | #ifdef DEBUG_IOCTLS | 136 | #ifdef DEBUG_IOCTLS |
168 | printk("TIOCSTART, %08lx) ", arg); | 137 | printk("TIOCSTART, %08lx) ", arg); |
169 | #endif | 138 | #endif |
170 | tp = get_tty(fd); | 139 | error = sys_ioctl(fd, TCXONC, TCOON); |
171 | if(!tp) { | ||
172 | error = -EINVAL; | ||
173 | break; | ||
174 | } | ||
175 | rtp = get_real_tty(tp); | ||
176 | start_tty(rtp); | ||
177 | break; | 140 | break; |
178 | 141 | ||
179 | case 0x20006968: | 142 | case 0x20006968: |
diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c index 998c4efcce88..ceb62dce1c9c 100644 --- a/arch/mips/kernel/kspd.c +++ b/arch/mips/kernel/kspd.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/unistd.h> | 21 | #include <linux/unistd.h> |
22 | #include <linux/file.h> | 22 | #include <linux/file.h> |
23 | #include <linux/fdtable.h> | ||
23 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
24 | #include <linux/syscalls.h> | 25 | #include <linux/syscalls.h> |
25 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
diff --git a/arch/mn10300/kernel/sys_mn10300.c b/arch/mn10300/kernel/sys_mn10300.c index 5f17a1ebc825..bca5a84dc72c 100644 --- a/arch/mn10300/kernel/sys_mn10300.c +++ b/arch/mn10300/kernel/sys_mn10300.c | |||
@@ -29,23 +29,6 @@ | |||
29 | #define MIN_MAP_ADDR PAGE_SIZE /* minimum fixed mmap address */ | 29 | #define MIN_MAP_ADDR PAGE_SIZE /* minimum fixed mmap address */ |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * sys_pipe() is the normal C calling standard for creating | ||
33 | * a pipe. It's not the way Unix traditionally does this, though. | ||
34 | */ | ||
35 | asmlinkage long sys_pipe(unsigned long __user *fildes) | ||
36 | { | ||
37 | int fd[2]; | ||
38 | int error; | ||
39 | |||
40 | error = do_pipe(fd); | ||
41 | if (!error) { | ||
42 | if (copy_to_user(fildes, fd, 2 * sizeof(int))) | ||
43 | error = -EFAULT; | ||
44 | } | ||
45 | return error; | ||
46 | } | ||
47 | |||
48 | /* | ||
49 | * memory mapping syscall | 32 | * memory mapping syscall |
50 | */ | 33 | */ |
51 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | 34 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, |
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c index 4f589216b39e..71b31957c8f1 100644 --- a/arch/parisc/kernel/sys_parisc.c +++ b/arch/parisc/kernel/sys_parisc.c | |||
@@ -33,19 +33,6 @@ | |||
33 | #include <linux/utsname.h> | 33 | #include <linux/utsname.h> |
34 | #include <linux/personality.h> | 34 | #include <linux/personality.h> |
35 | 35 | ||
36 | int sys_pipe(int __user *fildes) | ||
37 | { | ||
38 | int fd[2]; | ||
39 | int error; | ||
40 | |||
41 | error = do_pipe(fd); | ||
42 | if (!error) { | ||
43 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
44 | error = -EFAULT; | ||
45 | } | ||
46 | return error; | ||
47 | } | ||
48 | |||
49 | static unsigned long get_unshared_area(unsigned long addr, unsigned long len) | 36 | static unsigned long get_unshared_area(unsigned long addr, unsigned long len) |
50 | { | 37 | { |
51 | struct vm_area_struct *vma; | 38 | struct vm_area_struct *vma; |
diff --git a/arch/powerpc/boot/dts/mpc8610_hpcd.dts b/arch/powerpc/boot/dts/mpc8610_hpcd.dts index 1f2f1e0a5571..bba234eb14a9 100644 --- a/arch/powerpc/boot/dts/mpc8610_hpcd.dts +++ b/arch/powerpc/boot/dts/mpc8610_hpcd.dts | |||
@@ -21,6 +21,7 @@ | |||
21 | serial1 = &serial1; | 21 | serial1 = &serial1; |
22 | pci0 = &pci0; | 22 | pci0 = &pci0; |
23 | pci1 = &pci1; | 23 | pci1 = &pci1; |
24 | pci2 = &pci2; | ||
24 | }; | 25 | }; |
25 | 26 | ||
26 | cpus { | 27 | cpus { |
@@ -105,7 +106,7 @@ | |||
105 | compatible = "ns16550"; | 106 | compatible = "ns16550"; |
106 | reg = <0x4600 0x100>; | 107 | reg = <0x4600 0x100>; |
107 | clock-frequency = <0>; | 108 | clock-frequency = <0>; |
108 | interrupts = <28 2>; | 109 | interrupts = <42 2>; |
109 | interrupt-parent = <&mpic>; | 110 | interrupt-parent = <&mpic>; |
110 | }; | 111 | }; |
111 | 112 | ||
@@ -322,4 +323,24 @@ | |||
322 | }; | 323 | }; |
323 | }; | 324 | }; |
324 | }; | 325 | }; |
326 | |||
327 | pci2: pcie@e0009000 { | ||
328 | #address-cells = <3>; | ||
329 | #size-cells = <2>; | ||
330 | #interrupt-cells = <1>; | ||
331 | device_type = "pci"; | ||
332 | compatible = "fsl,mpc8641-pcie"; | ||
333 | reg = <0xe0009000 0x00001000>; | ||
334 | ranges = <0x02000000 0 0x90000000 0x90000000 0 0x10000000 | ||
335 | 0x01000000 0 0x00000000 0xe2000000 0 0x00100000>; | ||
336 | bus-range = <0 255>; | ||
337 | interrupt-map-mask = <0xf800 0 0 7>; | ||
338 | interrupt-map = <0x0000 0 0 1 &mpic 4 1 | ||
339 | 0x0000 0 0 2 &mpic 5 1 | ||
340 | 0x0000 0 0 3 &mpic 6 1 | ||
341 | 0x0000 0 0 4 &mpic 7 1>; | ||
342 | interrupt-parent = <&mpic>; | ||
343 | interrupts = <25 2>; | ||
344 | clock-frequency = <33333333>; | ||
345 | }; | ||
325 | }; | 346 | }; |
diff --git a/arch/powerpc/configs/ps3_defconfig b/arch/powerpc/configs/ps3_defconfig index 7a64c564f6e6..71d79e428d20 100644 --- a/arch/powerpc/configs/ps3_defconfig +++ b/arch/powerpc/configs/ps3_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Linux kernel version: 2.6.25-rc6 | 3 | # Linux kernel version: 2.6.25 |
4 | # Thu Mar 20 11:07:04 2008 | 4 | # Mon Apr 28 12:39:10 2008 |
5 | # | 5 | # |
6 | CONFIG_PPC64=y | 6 | CONFIG_PPC64=y |
7 | 7 | ||
@@ -30,6 +30,9 @@ CONFIG_GENERIC_CLOCKEVENTS=y | |||
30 | CONFIG_GENERIC_HARDIRQS=y | 30 | CONFIG_GENERIC_HARDIRQS=y |
31 | CONFIG_HAVE_SETUP_PER_CPU_AREA=y | 31 | CONFIG_HAVE_SETUP_PER_CPU_AREA=y |
32 | CONFIG_IRQ_PER_CPU=y | 32 | CONFIG_IRQ_PER_CPU=y |
33 | CONFIG_STACKTRACE_SUPPORT=y | ||
34 | CONFIG_TRACE_IRQFLAGS_SUPPORT=y | ||
35 | CONFIG_LOCKDEP_SUPPORT=y | ||
33 | CONFIG_RWSEM_XCHGADD_ALGORITHM=y | 36 | CONFIG_RWSEM_XCHGADD_ALGORITHM=y |
34 | CONFIG_ARCH_HAS_ILOG2_U32=y | 37 | CONFIG_ARCH_HAS_ILOG2_U32=y |
35 | CONFIG_ARCH_HAS_ILOG2_U64=y | 38 | CONFIG_ARCH_HAS_ILOG2_U64=y |
@@ -73,8 +76,6 @@ CONFIG_POSIX_MQUEUE=y | |||
73 | CONFIG_LOG_BUF_SHIFT=17 | 76 | CONFIG_LOG_BUF_SHIFT=17 |
74 | # CONFIG_CGROUPS is not set | 77 | # CONFIG_CGROUPS is not set |
75 | # CONFIG_GROUP_SCHED is not set | 78 | # CONFIG_GROUP_SCHED is not set |
76 | # CONFIG_USER_SCHED is not set | ||
77 | # CONFIG_CGROUP_SCHED is not set | ||
78 | CONFIG_SYSFS_DEPRECATED=y | 79 | CONFIG_SYSFS_DEPRECATED=y |
79 | CONFIG_SYSFS_DEPRECATED_V2=y | 80 | CONFIG_SYSFS_DEPRECATED_V2=y |
80 | # CONFIG_RELAY is not set | 81 | # CONFIG_RELAY is not set |
@@ -161,7 +162,6 @@ CONFIG_PPC_MULTIPLATFORM=y | |||
161 | # CONFIG_PPC_PMAC is not set | 162 | # CONFIG_PPC_PMAC is not set |
162 | # CONFIG_PPC_MAPLE is not set | 163 | # CONFIG_PPC_MAPLE is not set |
163 | # CONFIG_PPC_PASEMI is not set | 164 | # CONFIG_PPC_PASEMI is not set |
164 | # CONFIG_PPC_CELLEB is not set | ||
165 | CONFIG_PPC_PS3=y | 165 | CONFIG_PPC_PS3=y |
166 | 166 | ||
167 | # | 167 | # |
@@ -181,6 +181,7 @@ CONFIG_PS3_LPM=m | |||
181 | CONFIG_PPC_CELL=y | 181 | CONFIG_PPC_CELL=y |
182 | # CONFIG_PPC_CELL_NATIVE is not set | 182 | # CONFIG_PPC_CELL_NATIVE is not set |
183 | # CONFIG_PPC_IBM_CELL_BLADE is not set | 183 | # CONFIG_PPC_IBM_CELL_BLADE is not set |
184 | # CONFIG_PPC_CELLEB is not set | ||
184 | 185 | ||
185 | # | 186 | # |
186 | # Cell Broadband Engine options | 187 | # Cell Broadband Engine options |
@@ -205,9 +206,9 @@ CONFIG_SPU_BASE=y | |||
205 | # | 206 | # |
206 | # Kernel options | 207 | # Kernel options |
207 | # | 208 | # |
208 | # CONFIG_TICK_ONESHOT is not set | 209 | CONFIG_TICK_ONESHOT=y |
209 | # CONFIG_NO_HZ is not set | 210 | # CONFIG_NO_HZ is not set |
210 | # CONFIG_HIGH_RES_TIMERS is not set | 211 | CONFIG_HIGH_RES_TIMERS=y |
211 | CONFIG_GENERIC_CLOCKEVENTS_BUILD=y | 212 | CONFIG_GENERIC_CLOCKEVENTS_BUILD=y |
212 | # CONFIG_HZ_100 is not set | 213 | # CONFIG_HZ_100 is not set |
213 | CONFIG_HZ_250=y | 214 | CONFIG_HZ_250=y |
@@ -221,7 +222,6 @@ CONFIG_PREEMPT_NONE=y | |||
221 | CONFIG_BINFMT_ELF=y | 222 | CONFIG_BINFMT_ELF=y |
222 | CONFIG_COMPAT_BINFMT_ELF=y | 223 | CONFIG_COMPAT_BINFMT_ELF=y |
223 | CONFIG_BINFMT_MISC=y | 224 | CONFIG_BINFMT_MISC=y |
224 | CONFIG_FORCE_MAX_ZONEORDER=13 | ||
225 | # CONFIG_IOMMU_VMERGE is not set | 225 | # CONFIG_IOMMU_VMERGE is not set |
226 | CONFIG_IOMMU_HELPER=y | 226 | CONFIG_IOMMU_HELPER=y |
227 | CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y | 227 | CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y |
@@ -255,6 +255,7 @@ CONFIG_BOUNCE=y | |||
255 | CONFIG_ARCH_MEMORY_PROBE=y | 255 | CONFIG_ARCH_MEMORY_PROBE=y |
256 | # CONFIG_PPC_HAS_HASH_64K is not set | 256 | # CONFIG_PPC_HAS_HASH_64K is not set |
257 | # CONFIG_PPC_64K_PAGES is not set | 257 | # CONFIG_PPC_64K_PAGES is not set |
258 | CONFIG_FORCE_MAX_ZONEORDER=13 | ||
258 | # CONFIG_SCHED_SMT is not set | 259 | # CONFIG_SCHED_SMT is not set |
259 | CONFIG_PROC_DEVICETREE=y | 260 | CONFIG_PROC_DEVICETREE=y |
260 | # CONFIG_CMDLINE_BOOL is not set | 261 | # CONFIG_CMDLINE_BOOL is not set |
@@ -272,7 +273,9 @@ CONFIG_GENERIC_ISA_DMA=y | |||
272 | # CONFIG_PCI_SYSCALL is not set | 273 | # CONFIG_PCI_SYSCALL is not set |
273 | # CONFIG_ARCH_SUPPORTS_MSI is not set | 274 | # CONFIG_ARCH_SUPPORTS_MSI is not set |
274 | # CONFIG_PCCARD is not set | 275 | # CONFIG_PCCARD is not set |
276 | CONFIG_PAGE_OFFSET=0xc000000000000000 | ||
275 | CONFIG_KERNEL_START=0xc000000000000000 | 277 | CONFIG_KERNEL_START=0xc000000000000000 |
278 | CONFIG_PHYSICAL_START=0x00000000 | ||
276 | 279 | ||
277 | # | 280 | # |
278 | # Networking | 281 | # Networking |
@@ -292,7 +295,7 @@ CONFIG_XFRM=y | |||
292 | # CONFIG_XFRM_STATISTICS is not set | 295 | # CONFIG_XFRM_STATISTICS is not set |
293 | # CONFIG_NET_KEY is not set | 296 | # CONFIG_NET_KEY is not set |
294 | CONFIG_INET=y | 297 | CONFIG_INET=y |
295 | # CONFIG_IP_MULTICAST is not set | 298 | CONFIG_IP_MULTICAST=y |
296 | # CONFIG_IP_ADVANCED_ROUTER is not set | 299 | # CONFIG_IP_ADVANCED_ROUTER is not set |
297 | CONFIG_IP_FIB_HASH=y | 300 | CONFIG_IP_FIB_HASH=y |
298 | CONFIG_IP_PNP=y | 301 | CONFIG_IP_PNP=y |
@@ -301,6 +304,7 @@ CONFIG_IP_PNP_DHCP=y | |||
301 | # CONFIG_IP_PNP_RARP is not set | 304 | # CONFIG_IP_PNP_RARP is not set |
302 | # CONFIG_NET_IPIP is not set | 305 | # CONFIG_NET_IPIP is not set |
303 | # CONFIG_NET_IPGRE is not set | 306 | # CONFIG_NET_IPGRE is not set |
307 | # CONFIG_IP_MROUTE is not set | ||
304 | # CONFIG_ARPD is not set | 308 | # CONFIG_ARPD is not set |
305 | # CONFIG_SYN_COOKIES is not set | 309 | # CONFIG_SYN_COOKIES is not set |
306 | # CONFIG_INET_AH is not set | 310 | # CONFIG_INET_AH is not set |
@@ -332,8 +336,10 @@ CONFIG_INET6_XFRM_MODE_TUNNEL=y | |||
332 | CONFIG_INET6_XFRM_MODE_BEET=y | 336 | CONFIG_INET6_XFRM_MODE_BEET=y |
333 | # CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set | 337 | # CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set |
334 | CONFIG_IPV6_SIT=y | 338 | CONFIG_IPV6_SIT=y |
339 | CONFIG_IPV6_NDISC_NODETYPE=y | ||
335 | # CONFIG_IPV6_TUNNEL is not set | 340 | # CONFIG_IPV6_TUNNEL is not set |
336 | # CONFIG_IPV6_MULTIPLE_TABLES is not set | 341 | # CONFIG_IPV6_MULTIPLE_TABLES is not set |
342 | # CONFIG_IPV6_MROUTE is not set | ||
337 | # CONFIG_NETWORK_SECMARK is not set | 343 | # CONFIG_NETWORK_SECMARK is not set |
338 | # CONFIG_NETFILTER is not set | 344 | # CONFIG_NETFILTER is not set |
339 | # CONFIG_IP_DCCP is not set | 345 | # CONFIG_IP_DCCP is not set |
@@ -392,8 +398,6 @@ CONFIG_IEEE80211=m | |||
392 | CONFIG_IEEE80211_CRYPT_WEP=m | 398 | CONFIG_IEEE80211_CRYPT_WEP=m |
393 | CONFIG_IEEE80211_CRYPT_CCMP=m | 399 | CONFIG_IEEE80211_CRYPT_CCMP=m |
394 | CONFIG_IEEE80211_CRYPT_TKIP=m | 400 | CONFIG_IEEE80211_CRYPT_TKIP=m |
395 | CONFIG_IEEE80211_SOFTMAC=m | ||
396 | # CONFIG_IEEE80211_SOFTMAC_DEBUG is not set | ||
397 | # CONFIG_RFKILL is not set | 401 | # CONFIG_RFKILL is not set |
398 | # CONFIG_NET_9P is not set | 402 | # CONFIG_NET_9P is not set |
399 | 403 | ||
@@ -507,6 +511,7 @@ CONFIG_WLAN_80211=y | |||
507 | # CONFIG_LIBERTAS is not set | 511 | # CONFIG_LIBERTAS is not set |
508 | # CONFIG_USB_ZD1201 is not set | 512 | # CONFIG_USB_ZD1201 is not set |
509 | # CONFIG_USB_NET_RNDIS_WLAN is not set | 513 | # CONFIG_USB_NET_RNDIS_WLAN is not set |
514 | # CONFIG_IWLWIFI_LEDS is not set | ||
510 | # CONFIG_HOSTAP is not set | 515 | # CONFIG_HOSTAP is not set |
511 | 516 | ||
512 | # | 517 | # |
@@ -578,6 +583,7 @@ CONFIG_INPUT_JOYSTICK=y | |||
578 | # CONFIG_JOYSTICK_SPACEBALL is not set | 583 | # CONFIG_JOYSTICK_SPACEBALL is not set |
579 | # CONFIG_JOYSTICK_STINGER is not set | 584 | # CONFIG_JOYSTICK_STINGER is not set |
580 | # CONFIG_JOYSTICK_TWIDJOY is not set | 585 | # CONFIG_JOYSTICK_TWIDJOY is not set |
586 | # CONFIG_JOYSTICK_ZHENHUA is not set | ||
581 | # CONFIG_JOYSTICK_JOYDUMP is not set | 587 | # CONFIG_JOYSTICK_JOYDUMP is not set |
582 | # CONFIG_JOYSTICK_XPAD is not set | 588 | # CONFIG_JOYSTICK_XPAD is not set |
583 | # CONFIG_INPUT_TABLET is not set | 589 | # CONFIG_INPUT_TABLET is not set |
@@ -641,6 +647,7 @@ CONFIG_SSB_POSSIBLE=y | |||
641 | # Multifunction device drivers | 647 | # Multifunction device drivers |
642 | # | 648 | # |
643 | # CONFIG_MFD_SM501 is not set | 649 | # CONFIG_MFD_SM501 is not set |
650 | # CONFIG_HTC_PASIC3 is not set | ||
644 | 651 | ||
645 | # | 652 | # |
646 | # Multimedia devices | 653 | # Multimedia devices |
@@ -761,10 +768,6 @@ CONFIG_SND_PS3_DEFAULT_START_DELAY=2000 | |||
761 | # CONFIG_SND_SOC is not set | 768 | # CONFIG_SND_SOC is not set |
762 | 769 | ||
763 | # | 770 | # |
764 | # SoC Audio support for SuperH | ||
765 | # | ||
766 | |||
767 | # | ||
768 | # ALSA SoC audio for Freescale SOCs | 771 | # ALSA SoC audio for Freescale SOCs |
769 | # | 772 | # |
770 | 773 | ||
@@ -849,6 +852,7 @@ CONFIG_USB_STORAGE=m | |||
849 | # CONFIG_USB_STORAGE_ALAUDA is not set | 852 | # CONFIG_USB_STORAGE_ALAUDA is not set |
850 | # CONFIG_USB_STORAGE_ONETOUCH is not set | 853 | # CONFIG_USB_STORAGE_ONETOUCH is not set |
851 | # CONFIG_USB_STORAGE_KARMA is not set | 854 | # CONFIG_USB_STORAGE_KARMA is not set |
855 | # CONFIG_USB_STORAGE_CYPRESS_ATACB is not set | ||
852 | # CONFIG_USB_LIBUSUAL is not set | 856 | # CONFIG_USB_LIBUSUAL is not set |
853 | 857 | ||
854 | # | 858 | # |
@@ -893,10 +897,6 @@ CONFIG_USB_MON=y | |||
893 | # CONFIG_EDAC is not set | 897 | # CONFIG_EDAC is not set |
894 | # CONFIG_RTC_CLASS is not set | 898 | # CONFIG_RTC_CLASS is not set |
895 | # CONFIG_DMADEVICES is not set | 899 | # CONFIG_DMADEVICES is not set |
896 | |||
897 | # | ||
898 | # Userspace I/O | ||
899 | # | ||
900 | # CONFIG_UIO is not set | 900 | # CONFIG_UIO is not set |
901 | 901 | ||
902 | # | 902 | # |
@@ -986,7 +986,6 @@ CONFIG_NFS_FS=y | |||
986 | CONFIG_NFS_V3=y | 986 | CONFIG_NFS_V3=y |
987 | # CONFIG_NFS_V3_ACL is not set | 987 | # CONFIG_NFS_V3_ACL is not set |
988 | CONFIG_NFS_V4=y | 988 | CONFIG_NFS_V4=y |
989 | # CONFIG_NFS_DIRECTIO is not set | ||
990 | # CONFIG_NFSD is not set | 989 | # CONFIG_NFSD is not set |
991 | CONFIG_ROOT_NFS=y | 990 | CONFIG_ROOT_NFS=y |
992 | CONFIG_LOCKD=y | 991 | CONFIG_LOCKD=y |
@@ -1059,9 +1058,10 @@ CONFIG_NLS_ISO8859_1=y | |||
1059 | # Library routines | 1058 | # Library routines |
1060 | # | 1059 | # |
1061 | CONFIG_BITREVERSE=y | 1060 | CONFIG_BITREVERSE=y |
1061 | # CONFIG_GENERIC_FIND_FIRST_BIT is not set | ||
1062 | # CONFIG_CRC_CCITT is not set | 1062 | # CONFIG_CRC_CCITT is not set |
1063 | # CONFIG_CRC16 is not set | 1063 | # CONFIG_CRC16 is not set |
1064 | # CONFIG_CRC_ITU_T is not set | 1064 | CONFIG_CRC_ITU_T=m |
1065 | CONFIG_CRC32=y | 1065 | CONFIG_CRC32=y |
1066 | # CONFIG_CRC7 is not set | 1066 | # CONFIG_CRC7 is not set |
1067 | # CONFIG_LIBCRC32C is not set | 1067 | # CONFIG_LIBCRC32C is not set |
@@ -1071,6 +1071,7 @@ CONFIG_PLIST=y | |||
1071 | CONFIG_HAS_IOMEM=y | 1071 | CONFIG_HAS_IOMEM=y |
1072 | CONFIG_HAS_IOPORT=y | 1072 | CONFIG_HAS_IOPORT=y |
1073 | CONFIG_HAS_DMA=y | 1073 | CONFIG_HAS_DMA=y |
1074 | CONFIG_HAVE_LMB=y | ||
1074 | 1075 | ||
1075 | # | 1076 | # |
1076 | # Kernel hacking | 1077 | # Kernel hacking |
@@ -1078,6 +1079,7 @@ CONFIG_HAS_DMA=y | |||
1078 | # CONFIG_PRINTK_TIME is not set | 1079 | # CONFIG_PRINTK_TIME is not set |
1079 | CONFIG_ENABLE_WARN_DEPRECATED=y | 1080 | CONFIG_ENABLE_WARN_DEPRECATED=y |
1080 | CONFIG_ENABLE_MUST_CHECK=y | 1081 | CONFIG_ENABLE_MUST_CHECK=y |
1082 | CONFIG_FRAME_WARN=2048 | ||
1081 | CONFIG_MAGIC_SYSRQ=y | 1083 | CONFIG_MAGIC_SYSRQ=y |
1082 | # CONFIG_UNUSED_SYMBOLS is not set | 1084 | # CONFIG_UNUSED_SYMBOLS is not set |
1083 | # CONFIG_DEBUG_FS is not set | 1085 | # CONFIG_DEBUG_FS is not set |
@@ -1093,12 +1095,16 @@ CONFIG_SCHED_DEBUG=y | |||
1093 | # CONFIG_RT_MUTEX_TESTER is not set | 1095 | # CONFIG_RT_MUTEX_TESTER is not set |
1094 | CONFIG_DEBUG_SPINLOCK=y | 1096 | CONFIG_DEBUG_SPINLOCK=y |
1095 | CONFIG_DEBUG_MUTEXES=y | 1097 | CONFIG_DEBUG_MUTEXES=y |
1098 | # CONFIG_DEBUG_LOCK_ALLOC is not set | ||
1099 | # CONFIG_PROVE_LOCKING is not set | ||
1100 | # CONFIG_LOCK_STAT is not set | ||
1096 | CONFIG_DEBUG_SPINLOCK_SLEEP=y | 1101 | CONFIG_DEBUG_SPINLOCK_SLEEP=y |
1097 | # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set | 1102 | # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set |
1098 | # CONFIG_DEBUG_KOBJECT is not set | 1103 | # CONFIG_DEBUG_KOBJECT is not set |
1099 | CONFIG_DEBUG_BUGVERBOSE=y | 1104 | CONFIG_DEBUG_BUGVERBOSE=y |
1100 | CONFIG_DEBUG_INFO=y | 1105 | CONFIG_DEBUG_INFO=y |
1101 | # CONFIG_DEBUG_VM is not set | 1106 | # CONFIG_DEBUG_VM is not set |
1107 | # CONFIG_DEBUG_WRITECOUNT is not set | ||
1102 | CONFIG_DEBUG_LIST=y | 1108 | CONFIG_DEBUG_LIST=y |
1103 | # CONFIG_DEBUG_SG is not set | 1109 | # CONFIG_DEBUG_SG is not set |
1104 | # CONFIG_BOOT_PRINTK_DELAY is not set | 1110 | # CONFIG_BOOT_PRINTK_DELAY is not set |
@@ -1121,51 +1127,81 @@ CONFIG_IRQSTACKS=y | |||
1121 | # CONFIG_SECURITY is not set | 1127 | # CONFIG_SECURITY is not set |
1122 | # CONFIG_SECURITY_FILE_CAPABILITIES is not set | 1128 | # CONFIG_SECURITY_FILE_CAPABILITIES is not set |
1123 | CONFIG_CRYPTO=y | 1129 | CONFIG_CRYPTO=y |
1130 | |||
1131 | # | ||
1132 | # Crypto core or helper | ||
1133 | # | ||
1124 | CONFIG_CRYPTO_ALGAPI=y | 1134 | CONFIG_CRYPTO_ALGAPI=y |
1125 | CONFIG_CRYPTO_AEAD=m | 1135 | CONFIG_CRYPTO_AEAD=m |
1126 | CONFIG_CRYPTO_BLKCIPHER=y | 1136 | CONFIG_CRYPTO_BLKCIPHER=y |
1127 | CONFIG_CRYPTO_SEQIV=m | ||
1128 | CONFIG_CRYPTO_MANAGER=y | 1137 | CONFIG_CRYPTO_MANAGER=y |
1138 | CONFIG_CRYPTO_GF128MUL=m | ||
1139 | # CONFIG_CRYPTO_NULL is not set | ||
1140 | # CONFIG_CRYPTO_CRYPTD is not set | ||
1141 | # CONFIG_CRYPTO_AUTHENC is not set | ||
1142 | # CONFIG_CRYPTO_TEST is not set | ||
1143 | |||
1144 | # | ||
1145 | # Authenticated Encryption with Associated Data | ||
1146 | # | ||
1147 | CONFIG_CRYPTO_CCM=m | ||
1148 | CONFIG_CRYPTO_GCM=m | ||
1149 | CONFIG_CRYPTO_SEQIV=m | ||
1150 | |||
1151 | # | ||
1152 | # Block modes | ||
1153 | # | ||
1154 | CONFIG_CRYPTO_CBC=y | ||
1155 | CONFIG_CRYPTO_CTR=m | ||
1156 | # CONFIG_CRYPTO_CTS is not set | ||
1157 | CONFIG_CRYPTO_ECB=m | ||
1158 | # CONFIG_CRYPTO_LRW is not set | ||
1159 | CONFIG_CRYPTO_PCBC=m | ||
1160 | # CONFIG_CRYPTO_XTS is not set | ||
1161 | |||
1162 | # | ||
1163 | # Hash modes | ||
1164 | # | ||
1129 | # CONFIG_CRYPTO_HMAC is not set | 1165 | # CONFIG_CRYPTO_HMAC is not set |
1130 | # CONFIG_CRYPTO_XCBC is not set | 1166 | # CONFIG_CRYPTO_XCBC is not set |
1131 | # CONFIG_CRYPTO_NULL is not set | 1167 | |
1168 | # | ||
1169 | # Digest | ||
1170 | # | ||
1171 | # CONFIG_CRYPTO_CRC32C is not set | ||
1132 | # CONFIG_CRYPTO_MD4 is not set | 1172 | # CONFIG_CRYPTO_MD4 is not set |
1133 | CONFIG_CRYPTO_MD5=y | 1173 | CONFIG_CRYPTO_MD5=y |
1174 | CONFIG_CRYPTO_MICHAEL_MIC=m | ||
1134 | # CONFIG_CRYPTO_SHA1 is not set | 1175 | # CONFIG_CRYPTO_SHA1 is not set |
1135 | # CONFIG_CRYPTO_SHA256 is not set | 1176 | # CONFIG_CRYPTO_SHA256 is not set |
1136 | # CONFIG_CRYPTO_SHA512 is not set | 1177 | # CONFIG_CRYPTO_SHA512 is not set |
1137 | # CONFIG_CRYPTO_WP512 is not set | ||
1138 | # CONFIG_CRYPTO_TGR192 is not set | 1178 | # CONFIG_CRYPTO_TGR192 is not set |
1139 | CONFIG_CRYPTO_GF128MUL=m | 1179 | # CONFIG_CRYPTO_WP512 is not set |
1140 | CONFIG_CRYPTO_ECB=m | 1180 | |
1141 | CONFIG_CRYPTO_CBC=y | 1181 | # |
1142 | CONFIG_CRYPTO_PCBC=m | 1182 | # Ciphers |
1143 | # CONFIG_CRYPTO_LRW is not set | 1183 | # |
1144 | # CONFIG_CRYPTO_XTS is not set | ||
1145 | CONFIG_CRYPTO_CTR=m | ||
1146 | CONFIG_CRYPTO_GCM=m | ||
1147 | CONFIG_CRYPTO_CCM=m | ||
1148 | # CONFIG_CRYPTO_CRYPTD is not set | ||
1149 | CONFIG_CRYPTO_DES=y | ||
1150 | # CONFIG_CRYPTO_FCRYPT is not set | ||
1151 | # CONFIG_CRYPTO_BLOWFISH is not set | ||
1152 | # CONFIG_CRYPTO_TWOFISH is not set | ||
1153 | # CONFIG_CRYPTO_SERPENT is not set | ||
1154 | CONFIG_CRYPTO_AES=m | 1184 | CONFIG_CRYPTO_AES=m |
1185 | # CONFIG_CRYPTO_ANUBIS is not set | ||
1186 | CONFIG_CRYPTO_ARC4=m | ||
1187 | # CONFIG_CRYPTO_BLOWFISH is not set | ||
1188 | # CONFIG_CRYPTO_CAMELLIA is not set | ||
1155 | # CONFIG_CRYPTO_CAST5 is not set | 1189 | # CONFIG_CRYPTO_CAST5 is not set |
1156 | # CONFIG_CRYPTO_CAST6 is not set | 1190 | # CONFIG_CRYPTO_CAST6 is not set |
1157 | # CONFIG_CRYPTO_TEA is not set | 1191 | CONFIG_CRYPTO_DES=y |
1158 | CONFIG_CRYPTO_ARC4=m | 1192 | # CONFIG_CRYPTO_FCRYPT is not set |
1159 | # CONFIG_CRYPTO_KHAZAD is not set | 1193 | # CONFIG_CRYPTO_KHAZAD is not set |
1160 | # CONFIG_CRYPTO_ANUBIS is not set | ||
1161 | # CONFIG_CRYPTO_SEED is not set | ||
1162 | CONFIG_CRYPTO_SALSA20=m | 1194 | CONFIG_CRYPTO_SALSA20=m |
1195 | # CONFIG_CRYPTO_SEED is not set | ||
1196 | # CONFIG_CRYPTO_SERPENT is not set | ||
1197 | # CONFIG_CRYPTO_TEA is not set | ||
1198 | # CONFIG_CRYPTO_TWOFISH is not set | ||
1199 | |||
1200 | # | ||
1201 | # Compression | ||
1202 | # | ||
1163 | # CONFIG_CRYPTO_DEFLATE is not set | 1203 | # CONFIG_CRYPTO_DEFLATE is not set |
1164 | CONFIG_CRYPTO_MICHAEL_MIC=m | ||
1165 | # CONFIG_CRYPTO_CRC32C is not set | ||
1166 | # CONFIG_CRYPTO_CAMELLIA is not set | ||
1167 | # CONFIG_CRYPTO_TEST is not set | ||
1168 | # CONFIG_CRYPTO_AUTHENC is not set | ||
1169 | CONFIG_CRYPTO_LZO=m | 1204 | CONFIG_CRYPTO_LZO=m |
1170 | CONFIG_CRYPTO_HW=y | 1205 | CONFIG_CRYPTO_HW=y |
1171 | # CONFIG_PPC_CLOCK is not set | 1206 | # CONFIG_PPC_CLOCK is not set |
1207 | # CONFIG_VIRTUALIZATION is not set | ||
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index be35ffae10f0..1457aa0a08f1 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c | |||
@@ -386,6 +386,8 @@ static void __init smp_create_idle(unsigned int cpu) | |||
386 | panic("failed fork for CPU %u: %li", cpu, PTR_ERR(p)); | 386 | panic("failed fork for CPU %u: %li", cpu, PTR_ERR(p)); |
387 | #ifdef CONFIG_PPC64 | 387 | #ifdef CONFIG_PPC64 |
388 | paca[cpu].__current = p; | 388 | paca[cpu].__current = p; |
389 | paca[cpu].kstack = (unsigned long) task_thread_info(p) | ||
390 | + THREAD_SIZE - STACK_FRAME_OVERHEAD; | ||
389 | #endif | 391 | #endif |
390 | current_set[cpu] = task_thread_info(p); | 392 | current_set[cpu] = task_thread_info(p); |
391 | task_thread_info(p)->cpu = cpu; | 393 | task_thread_info(p)->cpu = cpu; |
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c index e722a4eeb5d0..4fe69ca24481 100644 --- a/arch/powerpc/kernel/syscalls.c +++ b/arch/powerpc/kernel/syscalls.c | |||
@@ -136,23 +136,6 @@ int sys_ipc(uint call, int first, unsigned long second, long third, | |||
136 | return ret; | 136 | return ret; |
137 | } | 137 | } |
138 | 138 | ||
139 | /* | ||
140 | * sys_pipe() is the normal C calling standard for creating | ||
141 | * a pipe. It's not the way unix traditionally does this, though. | ||
142 | */ | ||
143 | int sys_pipe(int __user *fildes) | ||
144 | { | ||
145 | int fd[2]; | ||
146 | int error; | ||
147 | |||
148 | error = do_pipe(fd); | ||
149 | if (!error) { | ||
150 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
151 | error = -EFAULT; | ||
152 | } | ||
153 | return error; | ||
154 | } | ||
155 | |||
156 | static inline unsigned long do_mmap2(unsigned long addr, size_t len, | 139 | static inline unsigned long do_mmap2(unsigned long addr, size_t len, |
157 | unsigned long prot, unsigned long flags, | 140 | unsigned long prot, unsigned long flags, |
158 | unsigned long fd, unsigned long off, int shift) | 141 | unsigned long fd, unsigned long off, int shift) |
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 3b26fbd6bec9..73401e83739a 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -149,7 +149,7 @@ EXPORT_SYMBOL(tb_ticks_per_sec); /* for cputime_t conversions */ | |||
149 | u64 tb_to_xs; | 149 | u64 tb_to_xs; |
150 | unsigned tb_to_us; | 150 | unsigned tb_to_us; |
151 | 151 | ||
152 | #define TICKLEN_SCALE TICK_LENGTH_SHIFT | 152 | #define TICKLEN_SCALE NTP_SCALE_SHIFT |
153 | u64 last_tick_len; /* units are ns / 2^TICKLEN_SCALE */ | 153 | u64 last_tick_len; /* units are ns / 2^TICKLEN_SCALE */ |
154 | u64 ticklen_to_xs; /* 0.64 fraction */ | 154 | u64 ticklen_to_xs; /* 0.64 fraction */ |
155 | 155 | ||
@@ -1007,8 +1007,6 @@ void __init time_init(void) | |||
1007 | vdso_data->stamp_xsec = (u64) xtime.tv_sec * XSEC_PER_SEC; | 1007 | vdso_data->stamp_xsec = (u64) xtime.tv_sec * XSEC_PER_SEC; |
1008 | vdso_data->tb_to_xs = tb_to_xs; | 1008 | vdso_data->tb_to_xs = tb_to_xs; |
1009 | 1009 | ||
1010 | time_freq = 0; | ||
1011 | |||
1012 | write_sequnlock_irqrestore(&xtime_lock, flags); | 1010 | write_sequnlock_irqrestore(&xtime_lock, flags); |
1013 | 1011 | ||
1014 | /* Register the clocksource, if we're not running on iSeries */ | 1012 | /* Register the clocksource, if we're not running on iSeries */ |
diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c index 6d9884a6884a..712d89a28c46 100644 --- a/arch/powerpc/kvm/booke_guest.c +++ b/arch/powerpc/kvm/booke_guest.c | |||
@@ -49,6 +49,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
49 | { "inst_emu", VCPU_STAT(emulated_inst_exits) }, | 49 | { "inst_emu", VCPU_STAT(emulated_inst_exits) }, |
50 | { "dec", VCPU_STAT(dec_exits) }, | 50 | { "dec", VCPU_STAT(dec_exits) }, |
51 | { "ext_intr", VCPU_STAT(ext_intr_exits) }, | 51 | { "ext_intr", VCPU_STAT(ext_intr_exits) }, |
52 | { "halt_wakeup", VCPU_STAT(halt_wakeup) }, | ||
52 | { NULL } | 53 | { NULL } |
53 | }; | 54 | }; |
54 | 55 | ||
@@ -338,6 +339,11 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
338 | } | 339 | } |
339 | break; | 340 | break; |
340 | 341 | ||
342 | case BOOKE_INTERRUPT_FP_UNAVAIL: | ||
343 | kvmppc_queue_exception(vcpu, exit_nr); | ||
344 | r = RESUME_GUEST; | ||
345 | break; | ||
346 | |||
341 | case BOOKE_INTERRUPT_DATA_STORAGE: | 347 | case BOOKE_INTERRUPT_DATA_STORAGE: |
342 | vcpu->arch.dear = vcpu->arch.fault_dear; | 348 | vcpu->arch.dear = vcpu->arch.fault_dear; |
343 | vcpu->arch.esr = vcpu->arch.fault_esr; | 349 | vcpu->arch.esr = vcpu->arch.fault_esr; |
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index bad40bd2d3ac..777e0f34e0ea 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
@@ -36,13 +36,12 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) | |||
36 | 36 | ||
37 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v) | 37 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v) |
38 | { | 38 | { |
39 | /* XXX implement me */ | 39 | return !!(v->arch.pending_exceptions); |
40 | return 0; | ||
41 | } | 40 | } |
42 | 41 | ||
43 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) | 42 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) |
44 | { | 43 | { |
45 | return 1; | 44 | return !(v->arch.msr & MSR_WE); |
46 | } | 45 | } |
47 | 46 | ||
48 | 47 | ||
@@ -214,6 +213,11 @@ static void kvmppc_decrementer_func(unsigned long data) | |||
214 | struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data; | 213 | struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data; |
215 | 214 | ||
216 | kvmppc_queue_exception(vcpu, BOOKE_INTERRUPT_DECREMENTER); | 215 | kvmppc_queue_exception(vcpu, BOOKE_INTERRUPT_DECREMENTER); |
216 | |||
217 | if (waitqueue_active(&vcpu->wq)) { | ||
218 | wake_up_interruptible(&vcpu->wq); | ||
219 | vcpu->stat.halt_wakeup++; | ||
220 | } | ||
217 | } | 221 | } |
218 | 222 | ||
219 | int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) | 223 | int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) |
@@ -339,6 +343,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) | |||
339 | int r; | 343 | int r; |
340 | sigset_t sigsaved; | 344 | sigset_t sigsaved; |
341 | 345 | ||
346 | vcpu_load(vcpu); | ||
347 | |||
342 | if (vcpu->sigset_active) | 348 | if (vcpu->sigset_active) |
343 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); | 349 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); |
344 | 350 | ||
@@ -363,12 +369,20 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) | |||
363 | if (vcpu->sigset_active) | 369 | if (vcpu->sigset_active) |
364 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | 370 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); |
365 | 371 | ||
372 | vcpu_put(vcpu); | ||
373 | |||
366 | return r; | 374 | return r; |
367 | } | 375 | } |
368 | 376 | ||
369 | int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq) | 377 | int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq) |
370 | { | 378 | { |
371 | kvmppc_queue_exception(vcpu, BOOKE_INTERRUPT_EXTERNAL); | 379 | kvmppc_queue_exception(vcpu, BOOKE_INTERRUPT_EXTERNAL); |
380 | |||
381 | if (waitqueue_active(&vcpu->wq)) { | ||
382 | wake_up_interruptible(&vcpu->wq); | ||
383 | vcpu->stat.halt_wakeup++; | ||
384 | } | ||
385 | |||
372 | return 0; | 386 | return 0; |
373 | } | 387 | } |
374 | 388 | ||
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index 4bb023f4c869..f1d2cdc5331b 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile | |||
@@ -23,3 +23,4 @@ obj-$(CONFIG_SMP) += locks.o | |||
23 | endif | 23 | endif |
24 | 24 | ||
25 | obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o | 25 | obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o |
26 | obj-$(CONFIG_HAS_IOMEM) += devres.o | ||
diff --git a/arch/powerpc/lib/devres.c b/arch/powerpc/lib/devres.c new file mode 100644 index 000000000000..292115d98ea9 --- /dev/null +++ b/arch/powerpc/lib/devres.c | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2008 Freescale Semiconductor, Inc. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | */ | ||
9 | |||
10 | #include <linux/device.h> /* devres_*(), devm_ioremap_release() */ | ||
11 | #include <linux/io.h> /* ioremap_flags() */ | ||
12 | #include <linux/module.h> /* EXPORT_SYMBOL() */ | ||
13 | |||
14 | /** | ||
15 | * devm_ioremap_prot - Managed ioremap_flags() | ||
16 | * @dev: Generic device to remap IO address for | ||
17 | * @offset: BUS offset to map | ||
18 | * @size: Size of map | ||
19 | * @flags: Page flags | ||
20 | * | ||
21 | * Managed ioremap_prot(). Map is automatically unmapped on driver | ||
22 | * detach. | ||
23 | */ | ||
24 | void __iomem *devm_ioremap_prot(struct device *dev, resource_size_t offset, | ||
25 | size_t size, unsigned long flags) | ||
26 | { | ||
27 | void __iomem **ptr, *addr; | ||
28 | |||
29 | ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL); | ||
30 | if (!ptr) | ||
31 | return NULL; | ||
32 | |||
33 | addr = ioremap_flags(offset, size, flags); | ||
34 | if (addr) { | ||
35 | *ptr = addr; | ||
36 | devres_add(dev, ptr); | ||
37 | } else | ||
38 | devres_free(ptr); | ||
39 | |||
40 | return addr; | ||
41 | } | ||
42 | EXPORT_SYMBOL(devm_ioremap_prot); | ||
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c index 906daeda59a8..cf8705e32d60 100644 --- a/arch/powerpc/mm/slb.c +++ b/arch/powerpc/mm/slb.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #ifdef DEBUG | 30 | #ifdef DEBUG |
31 | #define DBG(fmt...) udbg_printf(fmt) | 31 | #define DBG(fmt...) udbg_printf(fmt) |
32 | #else | 32 | #else |
33 | #define DBG(fmt...) | 33 | #define DBG pr_debug |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | extern void slb_allocate_realmode(unsigned long ea); | 36 | extern void slb_allocate_realmode(unsigned long ea); |
@@ -44,13 +44,13 @@ static void slb_allocate(unsigned long ea) | |||
44 | slb_allocate_realmode(ea); | 44 | slb_allocate_realmode(ea); |
45 | } | 45 | } |
46 | 46 | ||
47 | #define slb_esid_mask(ssize) \ | ||
48 | (((ssize) == MMU_SEGSIZE_256M)? ESID_MASK: ESID_MASK_1T) | ||
49 | |||
47 | static inline unsigned long mk_esid_data(unsigned long ea, int ssize, | 50 | static inline unsigned long mk_esid_data(unsigned long ea, int ssize, |
48 | unsigned long slot) | 51 | unsigned long slot) |
49 | { | 52 | { |
50 | unsigned long mask; | 53 | return (ea & slb_esid_mask(ssize)) | SLB_ESID_V | slot; |
51 | |||
52 | mask = (ssize == MMU_SEGSIZE_256M)? ESID_MASK: ESID_MASK_1T; | ||
53 | return (ea & mask) | SLB_ESID_V | slot; | ||
54 | } | 54 | } |
55 | 55 | ||
56 | #define slb_vsid_shift(ssize) \ | 56 | #define slb_vsid_shift(ssize) \ |
@@ -279,8 +279,8 @@ void slb_initialize(void) | |||
279 | patch_slb_encoding(slb_compare_rr_to_size, | 279 | patch_slb_encoding(slb_compare_rr_to_size, |
280 | mmu_slb_size); | 280 | mmu_slb_size); |
281 | 281 | ||
282 | DBG("SLB: linear LLP = %04x\n", linear_llp); | 282 | DBG("SLB: linear LLP = %04lx\n", linear_llp); |
283 | DBG("SLB: io LLP = %04x\n", io_llp); | 283 | DBG("SLB: io LLP = %04lx\n", io_llp); |
284 | } | 284 | } |
285 | 285 | ||
286 | get_paca()->stab_rr = SLB_NUM_BOLTED; | 286 | get_paca()->stab_rr = SLB_NUM_BOLTED; |
@@ -301,11 +301,16 @@ void slb_initialize(void) | |||
301 | 301 | ||
302 | create_shadowed_slbe(VMALLOC_START, mmu_kernel_ssize, vflags, 1); | 302 | create_shadowed_slbe(VMALLOC_START, mmu_kernel_ssize, vflags, 1); |
303 | 303 | ||
304 | /* For the boot cpu, we're running on the stack in init_thread_union, | ||
305 | * which is in the first segment of the linear mapping, and also | ||
306 | * get_paca()->kstack hasn't been initialized yet. | ||
307 | * For secondary cpus, we need to bolt the kernel stack entry now. | ||
308 | */ | ||
304 | slb_shadow_clear(2); | 309 | slb_shadow_clear(2); |
310 | if (raw_smp_processor_id() != boot_cpuid && | ||
311 | (get_paca()->kstack & slb_esid_mask(mmu_kernel_ssize)) > PAGE_OFFSET) | ||
312 | create_shadowed_slbe(get_paca()->kstack, | ||
313 | mmu_kernel_ssize, lflags, 2); | ||
305 | 314 | ||
306 | /* We don't bolt the stack for the time being - we're in boot, | ||
307 | * so the stack is in the bolted segment. By the time it goes | ||
308 | * elsewhere, we'll call _switch() which will bolt in the new | ||
309 | * one. */ | ||
310 | asm volatile("isync":::"memory"); | 315 | asm volatile("isync":::"memory"); |
311 | } | 316 | } |
diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c index b962c3ab470c..af116aadba10 100644 --- a/arch/powerpc/platforms/cell/spufs/coredump.c +++ b/arch/powerpc/platforms/cell/spufs/coredump.c | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/elf.h> | 23 | #include <linux/elf.h> |
24 | #include <linux/file.h> | 24 | #include <linux/file.h> |
25 | #include <linux/fdtable.h> | ||
25 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
26 | #include <linux/list.h> | 27 | #include <linux/list.h> |
27 | #include <linux/module.h> | 28 | #include <linux/module.h> |
diff --git a/arch/powerpc/platforms/ps3/interrupt.c b/arch/powerpc/platforms/ps3/interrupt.c index a14e5cdc2fed..e59634f7af96 100644 --- a/arch/powerpc/platforms/ps3/interrupt.c +++ b/arch/powerpc/platforms/ps3/interrupt.c | |||
@@ -167,8 +167,8 @@ static struct irq_chip ps3_irq_chip = { | |||
167 | * ps3_private data. | 167 | * ps3_private data. |
168 | */ | 168 | */ |
169 | 169 | ||
170 | int ps3_virq_setup(enum ps3_cpu_binding cpu, unsigned long outlet, | 170 | static int ps3_virq_setup(enum ps3_cpu_binding cpu, unsigned long outlet, |
171 | unsigned int *virq) | 171 | unsigned int *virq) |
172 | { | 172 | { |
173 | int result; | 173 | int result; |
174 | struct ps3_private *pd; | 174 | struct ps3_private *pd; |
@@ -217,7 +217,7 @@ fail_create: | |||
217 | * Clears chip data and calls irq_dispose_mapping() for the virq. | 217 | * Clears chip data and calls irq_dispose_mapping() for the virq. |
218 | */ | 218 | */ |
219 | 219 | ||
220 | int ps3_virq_destroy(unsigned int virq) | 220 | static int ps3_virq_destroy(unsigned int virq) |
221 | { | 221 | { |
222 | const struct ps3_private *pd = get_irq_chip_data(virq); | 222 | const struct ps3_private *pd = get_irq_chip_data(virq); |
223 | 223 | ||
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c index bec3803f0618..417eca79df69 100644 --- a/arch/powerpc/platforms/pseries/scanlog.c +++ b/arch/powerpc/platforms/pseries/scanlog.c | |||
@@ -55,11 +55,6 @@ static ssize_t scanlog_read(struct file *file, char __user *buf, | |||
55 | dp = PDE(inode); | 55 | dp = PDE(inode); |
56 | data = (unsigned int *)dp->data; | 56 | data = (unsigned int *)dp->data; |
57 | 57 | ||
58 | if (!data) { | ||
59 | printk(KERN_ERR "scanlog: read failed no data\n"); | ||
60 | return -EIO; | ||
61 | } | ||
62 | |||
63 | if (count > RTAS_DATA_BUF_SIZE) | 58 | if (count > RTAS_DATA_BUF_SIZE) |
64 | count = RTAS_DATA_BUF_SIZE; | 59 | count = RTAS_DATA_BUF_SIZE; |
65 | 60 | ||
@@ -146,11 +141,6 @@ static int scanlog_open(struct inode * inode, struct file * file) | |||
146 | struct proc_dir_entry *dp = PDE(inode); | 141 | struct proc_dir_entry *dp = PDE(inode); |
147 | unsigned int *data = (unsigned int *)dp->data; | 142 | unsigned int *data = (unsigned int *)dp->data; |
148 | 143 | ||
149 | if (!data) { | ||
150 | printk(KERN_ERR "scanlog: open failed no data\n"); | ||
151 | return -EIO; | ||
152 | } | ||
153 | |||
154 | if (data[0] != 0) { | 144 | if (data[0] != 0) { |
155 | /* This imperfect test stops a second copy of the | 145 | /* This imperfect test stops a second copy of the |
156 | * data (or a reset while data is being copied) | 146 | * data (or a reset while data is being copied) |
@@ -168,10 +158,6 @@ static int scanlog_release(struct inode * inode, struct file * file) | |||
168 | struct proc_dir_entry *dp = PDE(inode); | 158 | struct proc_dir_entry *dp = PDE(inode); |
169 | unsigned int *data = (unsigned int *)dp->data; | 159 | unsigned int *data = (unsigned int *)dp->data; |
170 | 160 | ||
171 | if (!data) { | ||
172 | printk(KERN_ERR "scanlog: release failed no data\n"); | ||
173 | return -EIO; | ||
174 | } | ||
175 | data[0] = 0; | 161 | data[0] = 0; |
176 | 162 | ||
177 | return 0; | 163 | return 0; |
@@ -200,12 +186,11 @@ static int __init scanlog_init(void) | |||
200 | if (!data) | 186 | if (!data) |
201 | goto err; | 187 | goto err; |
202 | 188 | ||
203 | ent = proc_create("ppc64/rtas/scan-log-dump", S_IRUSR, NULL, | 189 | ent = proc_create_data("ppc64/rtas/scan-log-dump", S_IRUSR, NULL, |
204 | &scanlog_fops); | 190 | &scanlog_fops, data); |
205 | if (!ent) | 191 | if (!ent) |
206 | goto err; | 192 | goto err; |
207 | 193 | ||
208 | ent->data = data; | ||
209 | proc_ppc64_scan_log_dump = ent; | 194 | proc_ppc64_scan_log_dump = ent; |
210 | 195 | ||
211 | return 0; | 196 | return 0; |
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c index 3d920376f58e..a0fa4ebb39c6 100644 --- a/arch/powerpc/sysdev/fsl_rio.c +++ b/arch/powerpc/sysdev/fsl_rio.c | |||
@@ -176,6 +176,7 @@ struct rio_priv { | |||
176 | 176 | ||
177 | /** | 177 | /** |
178 | * fsl_rio_doorbell_send - Send a MPC85xx doorbell message | 178 | * fsl_rio_doorbell_send - Send a MPC85xx doorbell message |
179 | * @mport: RapidIO master port info | ||
179 | * @index: ID of RapidIO interface | 180 | * @index: ID of RapidIO interface |
180 | * @destid: Destination ID of target device | 181 | * @destid: Destination ID of target device |
181 | * @data: 16-bit info field of RapidIO doorbell message | 182 | * @data: 16-bit info field of RapidIO doorbell message |
@@ -211,6 +212,7 @@ static int fsl_rio_doorbell_send(struct rio_mport *mport, | |||
211 | 212 | ||
212 | /** | 213 | /** |
213 | * fsl_local_config_read - Generate a MPC85xx local config space read | 214 | * fsl_local_config_read - Generate a MPC85xx local config space read |
215 | * @mport: RapidIO master port info | ||
214 | * @index: ID of RapdiIO interface | 216 | * @index: ID of RapdiIO interface |
215 | * @offset: Offset into configuration space | 217 | * @offset: Offset into configuration space |
216 | * @len: Length (in bytes) of the maintenance transaction | 218 | * @len: Length (in bytes) of the maintenance transaction |
@@ -232,6 +234,7 @@ static int fsl_local_config_read(struct rio_mport *mport, | |||
232 | 234 | ||
233 | /** | 235 | /** |
234 | * fsl_local_config_write - Generate a MPC85xx local config space write | 236 | * fsl_local_config_write - Generate a MPC85xx local config space write |
237 | * @mport: RapidIO master port info | ||
235 | * @index: ID of RapdiIO interface | 238 | * @index: ID of RapdiIO interface |
236 | * @offset: Offset into configuration space | 239 | * @offset: Offset into configuration space |
237 | * @len: Length (in bytes) of the maintenance transaction | 240 | * @len: Length (in bytes) of the maintenance transaction |
@@ -254,6 +257,7 @@ static int fsl_local_config_write(struct rio_mport *mport, | |||
254 | 257 | ||
255 | /** | 258 | /** |
256 | * fsl_rio_config_read - Generate a MPC85xx read maintenance transaction | 259 | * fsl_rio_config_read - Generate a MPC85xx read maintenance transaction |
260 | * @mport: RapidIO master port info | ||
257 | * @index: ID of RapdiIO interface | 261 | * @index: ID of RapdiIO interface |
258 | * @destid: Destination ID of transaction | 262 | * @destid: Destination ID of transaction |
259 | * @hopcount: Number of hops to target device | 263 | * @hopcount: Number of hops to target device |
@@ -295,6 +299,7 @@ fsl_rio_config_read(struct rio_mport *mport, int index, u16 destid, | |||
295 | 299 | ||
296 | /** | 300 | /** |
297 | * fsl_rio_config_write - Generate a MPC85xx write maintenance transaction | 301 | * fsl_rio_config_write - Generate a MPC85xx write maintenance transaction |
302 | * @mport: RapidIO master port info | ||
298 | * @index: ID of RapdiIO interface | 303 | * @index: ID of RapdiIO interface |
299 | * @destid: Destination ID of transaction | 304 | * @destid: Destination ID of transaction |
300 | * @hopcount: Number of hops to target device | 305 | * @hopcount: Number of hops to target device |
@@ -985,8 +990,8 @@ static inline void fsl_rio_info(struct device *dev, u32 ccsr) | |||
985 | } | 990 | } |
986 | 991 | ||
987 | /** | 992 | /** |
988 | * fsl_rio_setup - Setup MPC85xx RapidIO interface | 993 | * fsl_rio_setup - Setup Freescale PowerPC RapidIO interface |
989 | * @fsl_rio_setup - Setup Freescale PowerPC RapidIO interface | 994 | * @dev: of_device pointer |
990 | * | 995 | * |
991 | * Initializes MPC85xx RapidIO hardware interface, configures | 996 | * Initializes MPC85xx RapidIO hardware interface, configures |
992 | * master port with system-specific info, and registers the | 997 | * master port with system-specific info, and registers the |
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index 324c01b70ddd..3a7054e2bb75 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c | |||
@@ -389,8 +389,8 @@ static int __init gfar_of_init(void) | |||
389 | } | 389 | } |
390 | 390 | ||
391 | gfar_data.phy_id = *id; | 391 | gfar_data.phy_id = *id; |
392 | snprintf(gfar_data.bus_id, MII_BUS_ID_SIZE, "%x", | 392 | snprintf(gfar_data.bus_id, MII_BUS_ID_SIZE, "%llx", |
393 | res.start); | 393 | (unsigned long long)res.start); |
394 | 394 | ||
395 | of_node_put(phy); | 395 | of_node_put(phy); |
396 | of_node_put(mdio); | 396 | of_node_put(mdio); |
diff --git a/arch/powerpc/sysdev/xilinx_intc.c b/arch/powerpc/sysdev/xilinx_intc.c index ba8eea2bcce0..b7aefd0d45cb 100644 --- a/arch/powerpc/sysdev/xilinx_intc.c +++ b/arch/powerpc/sysdev/xilinx_intc.c | |||
@@ -107,7 +107,7 @@ xilinx_intc_init(struct device_node *np) | |||
107 | } | 107 | } |
108 | regs = ioremap(res.start, 32); | 108 | regs = ioremap(res.start, 32); |
109 | 109 | ||
110 | printk(KERN_INFO "Xilinx intc at 0x%08X mapped to 0x%p\n", | 110 | printk(KERN_INFO "Xilinx intc at 0x%08LX mapped to 0x%p\n", |
111 | res.start, regs); | 111 | res.start, regs); |
112 | 112 | ||
113 | /* Setup interrupt controller */ | 113 | /* Setup interrupt controller */ |
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c index 988d0d64c2c8..5fdb799062b7 100644 --- a/arch/s390/kernel/sys_s390.c +++ b/arch/s390/kernel/sys_s390.c | |||
@@ -32,23 +32,6 @@ | |||
32 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
33 | #include "entry.h" | 33 | #include "entry.h" |
34 | 34 | ||
35 | /* | ||
36 | * sys_pipe() is the normal C calling standard for creating | ||
37 | * a pipe. It's not the way Unix traditionally does this, though. | ||
38 | */ | ||
39 | asmlinkage long sys_pipe(unsigned long __user *fildes) | ||
40 | { | ||
41 | int fd[2]; | ||
42 | int error; | ||
43 | |||
44 | error = do_pipe(fd); | ||
45 | if (!error) { | ||
46 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
47 | error = -EFAULT; | ||
48 | } | ||
49 | return error; | ||
50 | } | ||
51 | |||
52 | /* common code for old and new mmaps */ | 35 | /* common code for old and new mmaps */ |
53 | static inline long do_mmap2( | 36 | static inline long do_mmap2( |
54 | unsigned long addr, unsigned long len, | 37 | unsigned long addr, unsigned long len, |
diff --git a/arch/sh/kernel/sys_sh64.c b/arch/sh/kernel/sys_sh64.c index 578004d71e02..91fb8445a5a0 100644 --- a/arch/sh/kernel/sys_sh64.c +++ b/arch/sh/kernel/sys_sh64.c | |||
@@ -31,23 +31,6 @@ | |||
31 | #include <asm/unistd.h> | 31 | #include <asm/unistd.h> |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * sys_pipe() is the normal C calling standard for creating | ||
35 | * a pipe. It's not the way Unix traditionally does this, though. | ||
36 | */ | ||
37 | asmlinkage int sys_pipe(unsigned long * fildes) | ||
38 | { | ||
39 | int fd[2]; | ||
40 | int error; | ||
41 | |||
42 | error = do_pipe(fd); | ||
43 | if (!error) { | ||
44 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
45 | error = -EFAULT; | ||
46 | } | ||
47 | return error; | ||
48 | } | ||
49 | |||
50 | /* | ||
51 | * Do a system call from kernel instead of calling sys_execve so we | 34 | * Do a system call from kernel instead of calling sys_execve so we |
52 | * end up with proper pt_regs. | 35 | * end up with proper pt_regs. |
53 | */ | 36 | */ |
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c index 3c13137685da..8a55c4f0df84 100644 --- a/arch/sparc/kernel/setup.c +++ b/arch/sparc/kernel/setup.c | |||
@@ -180,11 +180,9 @@ static void __init boot_flags_init(char *commands) | |||
180 | 180 | ||
181 | /* This routine will in the future do all the nasty prom stuff | 181 | /* This routine will in the future do all the nasty prom stuff |
182 | * to probe for the mmu type and its parameters, etc. This will | 182 | * to probe for the mmu type and its parameters, etc. This will |
183 | * also be where SMP things happen plus the Sparc specific memory | 183 | * also be where SMP things happen. |
184 | * physical memory probe as on the alpha. | ||
185 | */ | 184 | */ |
186 | 185 | ||
187 | extern int prom_probe_memory(void); | ||
188 | extern void sun4c_probe_vac(void); | 186 | extern void sun4c_probe_vac(void); |
189 | extern char cputypval; | 187 | extern char cputypval; |
190 | extern unsigned long start, end; | 188 | extern unsigned long start, end; |
@@ -268,7 +266,6 @@ void __init setup_arch(char **cmdline_p) | |||
268 | if (ARCH_SUN4C_SUN4) | 266 | if (ARCH_SUN4C_SUN4) |
269 | sun4c_probe_vac(); | 267 | sun4c_probe_vac(); |
270 | load_mmu(); | 268 | load_mmu(); |
271 | (void) prom_probe_memory(); | ||
272 | 269 | ||
273 | phys_base = 0xffffffffUL; | 270 | phys_base = 0xffffffffUL; |
274 | highest_paddr = 0UL; | 271 | highest_paddr = 0UL; |
diff --git a/arch/sparc/mm/fault.c b/arch/sparc/mm/fault.c index e4d9c8e19df5..abd50795a7b6 100644 --- a/arch/sparc/mm/fault.c +++ b/arch/sparc/mm/fault.c | |||
@@ -47,64 +47,15 @@ int vac_size, vac_linesize, vac_do_hw_vac_flushes; | |||
47 | int vac_entries_per_context, vac_entries_per_segment; | 47 | int vac_entries_per_context, vac_entries_per_segment; |
48 | int vac_entries_per_page; | 48 | int vac_entries_per_page; |
49 | 49 | ||
50 | /* Nice, simple, prom library does all the sweating for us. ;) */ | 50 | /* Return how much physical memory we have. */ |
51 | int prom_probe_memory (void) | 51 | unsigned long probe_memory(void) |
52 | { | 52 | { |
53 | register struct linux_mlist_v0 *mlist; | 53 | unsigned long total = 0; |
54 | register unsigned long bytes, base_paddr, tally; | 54 | int i; |
55 | register int i; | ||
56 | |||
57 | i = 0; | ||
58 | mlist= *prom_meminfo()->v0_available; | ||
59 | bytes = tally = mlist->num_bytes; | ||
60 | base_paddr = (unsigned long) mlist->start_adr; | ||
61 | |||
62 | sp_banks[0].base_addr = base_paddr; | ||
63 | sp_banks[0].num_bytes = bytes; | ||
64 | |||
65 | while (mlist->theres_more != (void *) 0){ | ||
66 | i++; | ||
67 | mlist = mlist->theres_more; | ||
68 | bytes = mlist->num_bytes; | ||
69 | tally += bytes; | ||
70 | if (i > SPARC_PHYS_BANKS-1) { | ||
71 | printk ("The machine has more banks than " | ||
72 | "this kernel can support\n" | ||
73 | "Increase the SPARC_PHYS_BANKS " | ||
74 | "setting (currently %d)\n", | ||
75 | SPARC_PHYS_BANKS); | ||
76 | i = SPARC_PHYS_BANKS-1; | ||
77 | break; | ||
78 | } | ||
79 | |||
80 | sp_banks[i].base_addr = (unsigned long) mlist->start_adr; | ||
81 | sp_banks[i].num_bytes = mlist->num_bytes; | ||
82 | } | ||
83 | |||
84 | i++; | ||
85 | sp_banks[i].base_addr = 0xdeadbeef; | ||
86 | sp_banks[i].num_bytes = 0; | ||
87 | |||
88 | /* Now mask all bank sizes on a page boundary, it is all we can | ||
89 | * use anyways. | ||
90 | */ | ||
91 | for(i=0; sp_banks[i].num_bytes != 0; i++) | ||
92 | sp_banks[i].num_bytes &= PAGE_MASK; | ||
93 | |||
94 | return tally; | ||
95 | } | ||
96 | |||
97 | /* Traverse the memory lists in the prom to see how much physical we | ||
98 | * have. | ||
99 | */ | ||
100 | unsigned long | ||
101 | probe_memory(void) | ||
102 | { | ||
103 | int total; | ||
104 | 55 | ||
105 | total = prom_probe_memory(); | 56 | for (i = 0; sp_banks[i].num_bytes; i++) |
57 | total += sp_banks[i].num_bytes; | ||
106 | 58 | ||
107 | /* Oh man, much nicer, keep the dirt in promlib. */ | ||
108 | return total; | 59 | return total; |
109 | } | 60 | } |
110 | 61 | ||
diff --git a/arch/sparc/prom/init.c b/arch/sparc/prom/init.c index 50abfb1b880e..2fa3a474e3a2 100644 --- a/arch/sparc/prom/init.c +++ b/arch/sparc/prom/init.c | |||
@@ -21,8 +21,6 @@ linux_sun4_romvec *sun4_romvec; | |||
21 | /* The root node of the prom device tree. */ | 21 | /* The root node of the prom device tree. */ |
22 | int prom_root_node; | 22 | int prom_root_node; |
23 | 23 | ||
24 | int prom_stdin, prom_stdout; | ||
25 | |||
26 | /* Pointer to the device tree operations structure. */ | 24 | /* Pointer to the device tree operations structure. */ |
27 | struct linux_nodeops *prom_nodeops; | 25 | struct linux_nodeops *prom_nodeops; |
28 | 26 | ||
@@ -74,11 +72,6 @@ void __init prom_init(struct linux_romvec *rp) | |||
74 | (((unsigned long) prom_nodeops) == -1)) | 72 | (((unsigned long) prom_nodeops) == -1)) |
75 | prom_halt(); | 73 | prom_halt(); |
76 | 74 | ||
77 | if(prom_vers == PROM_V2 || prom_vers == PROM_V3) { | ||
78 | prom_stdout = *romvec->pv_v2bootargs.fd_stdout; | ||
79 | prom_stdin = *romvec->pv_v2bootargs.fd_stdin; | ||
80 | } | ||
81 | |||
82 | prom_meminit(); | 75 | prom_meminit(); |
83 | 76 | ||
84 | prom_ranges_init(); | 77 | prom_ranges_init(); |
diff --git a/arch/sparc/prom/memory.c b/arch/sparc/prom/memory.c index b0c0f9c4fc14..947f047dc95a 100644 --- a/arch/sparc/prom/memory.c +++ b/arch/sparc/prom/memory.c | |||
@@ -1,215 +1,100 @@ | |||
1 | /* $Id: memory.c,v 1.15 2000/01/29 01:09:12 anton Exp $ | 1 | /* memory.c: Prom routine for acquiring various bits of information |
2 | * memory.c: Prom routine for acquiring various bits of information | ||
3 | * about RAM on the machine, both virtual and physical. | 2 | * about RAM on the machine, both virtual and physical. |
4 | * | 3 | * |
5 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) | 4 | * Copyright (C) 1995, 2008 David S. Miller (davem@davemloft.net) |
6 | * Copyright (C) 1997 Michael A. Griffith (grif@acm.org) | 5 | * Copyright (C) 1997 Michael A. Griffith (grif@acm.org) |
7 | */ | 6 | */ |
8 | 7 | ||
9 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/sort.h> | ||
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | 11 | ||
12 | #include <asm/openprom.h> | 12 | #include <asm/openprom.h> |
13 | #include <asm/sun4prom.h> | 13 | #include <asm/sun4prom.h> |
14 | #include <asm/oplib.h> | 14 | #include <asm/oplib.h> |
15 | #include <asm/page.h> | ||
15 | 16 | ||
16 | /* This routine, for consistency, returns the ram parameters in the | 17 | static int __init prom_meminit_v0(void) |
17 | * V0 prom memory descriptor format. I choose this format because I | 18 | { |
18 | * think it was the easiest to work with. I feel the religious | 19 | struct linux_mlist_v0 *p; |
19 | * arguments now... ;) Also, I return the linked lists sorted to | 20 | int index; |
20 | * prevent paging_init() upset stomach as I have not yet written | 21 | |
21 | * the pepto-bismol kernel module yet. | 22 | index = 0; |
22 | */ | 23 | for (p = *(romvec->pv_v0mem.v0_available); p; p = p->theres_more) { |
24 | sp_banks[index].base_addr = (unsigned long) p->start_adr; | ||
25 | sp_banks[index].num_bytes = p->num_bytes; | ||
26 | index++; | ||
27 | } | ||
23 | 28 | ||
24 | struct linux_prom_registers prom_reg_memlist[64]; | 29 | return index; |
25 | struct linux_prom_registers prom_reg_tmp[64]; | 30 | } |
26 | 31 | ||
27 | struct linux_mlist_v0 prom_phys_total[64]; | 32 | static int __init prom_meminit_v2(void) |
28 | struct linux_mlist_v0 prom_prom_taken[64]; | 33 | { |
29 | struct linux_mlist_v0 prom_phys_avail[64]; | 34 | struct linux_prom_registers reg[64]; |
35 | int node, size, num_ents, i; | ||
30 | 36 | ||
31 | struct linux_mlist_v0 *prom_ptot_ptr = prom_phys_total; | 37 | node = prom_searchsiblings(prom_getchild(prom_root_node), "memory"); |
32 | struct linux_mlist_v0 *prom_ptak_ptr = prom_prom_taken; | 38 | size = prom_getproperty(node, "available", (char *) reg, sizeof(reg)); |
33 | struct linux_mlist_v0 *prom_pavl_ptr = prom_phys_avail; | 39 | num_ents = size / sizeof(struct linux_prom_registers); |
34 | 40 | ||
35 | struct linux_mem_v0 prom_memlist; | 41 | for (i = 0; i < num_ents; i++) { |
42 | sp_banks[i].base_addr = reg[i].phys_addr; | ||
43 | sp_banks[i].num_bytes = reg[i].reg_size; | ||
44 | } | ||
36 | 45 | ||
46 | return num_ents; | ||
47 | } | ||
37 | 48 | ||
38 | /* Internal Prom library routine to sort a linux_mlist_v0 memory | 49 | static int __init prom_meminit_sun4(void) |
39 | * list. Used below in initialization. | ||
40 | */ | ||
41 | static void __init | ||
42 | prom_sortmemlist(struct linux_mlist_v0 *thislist) | ||
43 | { | 50 | { |
44 | int swapi = 0; | 51 | #ifdef CONFIG_SUN4 |
45 | int i, mitr, tmpsize; | 52 | sp_banks[0].base_addr = 0; |
46 | char *tmpaddr; | 53 | sp_banks[0].num_bytes = *(sun4_romvec->memoryavail); |
47 | char *lowest; | 54 | #endif |
48 | 55 | return 1; | |
49 | for(i=0; thislist[i].theres_more; i++) { | 56 | } |
50 | lowest = thislist[i].start_adr; | 57 | |
51 | for(mitr = i+1; thislist[mitr-1].theres_more; mitr++) | 58 | static int sp_banks_cmp(const void *a, const void *b) |
52 | if(thislist[mitr].start_adr < lowest) { | 59 | { |
53 | lowest = thislist[mitr].start_adr; | 60 | const struct sparc_phys_banks *x = a, *y = b; |
54 | swapi = mitr; | ||
55 | } | ||
56 | if(lowest == thislist[i].start_adr) continue; | ||
57 | tmpaddr = thislist[swapi].start_adr; | ||
58 | tmpsize = thislist[swapi].num_bytes; | ||
59 | for(mitr = swapi; mitr > i; mitr--) { | ||
60 | thislist[mitr].start_adr = thislist[mitr-1].start_adr; | ||
61 | thislist[mitr].num_bytes = thislist[mitr-1].num_bytes; | ||
62 | } | ||
63 | thislist[i].start_adr = tmpaddr; | ||
64 | thislist[i].num_bytes = tmpsize; | ||
65 | } | ||
66 | 61 | ||
67 | return; | 62 | if (x->base_addr > y->base_addr) |
63 | return 1; | ||
64 | if (x->base_addr < y->base_addr) | ||
65 | return -1; | ||
66 | return 0; | ||
68 | } | 67 | } |
69 | 68 | ||
70 | /* Initialize the memory lists based upon the prom version. */ | 69 | /* Initialize the memory lists based upon the prom version. */ |
71 | void __init prom_meminit(void) | 70 | void __init prom_meminit(void) |
72 | { | 71 | { |
73 | int node = 0; | 72 | int i, num_ents = 0; |
74 | unsigned int iter, num_regs; | ||
75 | struct linux_mlist_v0 *mptr; /* ptr for traversal */ | ||
76 | 73 | ||
77 | switch(prom_vers) { | 74 | switch (prom_vers) { |
78 | case PROM_V0: | 75 | case PROM_V0: |
79 | /* Nice, kind of easier to do in this case. */ | 76 | num_ents = prom_meminit_v0(); |
80 | /* First, the total physical descriptors. */ | ||
81 | for(mptr = (*(romvec->pv_v0mem.v0_totphys)), iter=0; | ||
82 | mptr; mptr=mptr->theres_more, iter++) { | ||
83 | prom_phys_total[iter].start_adr = mptr->start_adr; | ||
84 | prom_phys_total[iter].num_bytes = mptr->num_bytes; | ||
85 | prom_phys_total[iter].theres_more = &prom_phys_total[iter+1]; | ||
86 | } | ||
87 | prom_phys_total[iter-1].theres_more = NULL; | ||
88 | /* Second, the total prom taken descriptors. */ | ||
89 | for(mptr = (*(romvec->pv_v0mem.v0_prommap)), iter=0; | ||
90 | mptr; mptr=mptr->theres_more, iter++) { | ||
91 | prom_prom_taken[iter].start_adr = mptr->start_adr; | ||
92 | prom_prom_taken[iter].num_bytes = mptr->num_bytes; | ||
93 | prom_prom_taken[iter].theres_more = &prom_prom_taken[iter+1]; | ||
94 | } | ||
95 | prom_prom_taken[iter-1].theres_more = NULL; | ||
96 | /* Last, the available physical descriptors. */ | ||
97 | for(mptr = (*(romvec->pv_v0mem.v0_available)), iter=0; | ||
98 | mptr; mptr=mptr->theres_more, iter++) { | ||
99 | prom_phys_avail[iter].start_adr = mptr->start_adr; | ||
100 | prom_phys_avail[iter].num_bytes = mptr->num_bytes; | ||
101 | prom_phys_avail[iter].theres_more = &prom_phys_avail[iter+1]; | ||
102 | } | ||
103 | prom_phys_avail[iter-1].theres_more = NULL; | ||
104 | /* Sort all the lists. */ | ||
105 | prom_sortmemlist(prom_phys_total); | ||
106 | prom_sortmemlist(prom_prom_taken); | ||
107 | prom_sortmemlist(prom_phys_avail); | ||
108 | break; | 77 | break; |
78 | |||
109 | case PROM_V2: | 79 | case PROM_V2: |
110 | case PROM_V3: | 80 | case PROM_V3: |
111 | /* Grrr, have to traverse the prom device tree ;( */ | 81 | num_ents = prom_meminit_v2(); |
112 | node = prom_getchild(prom_root_node); | ||
113 | node = prom_searchsiblings(node, "memory"); | ||
114 | num_regs = prom_getproperty(node, "available", | ||
115 | (char *) prom_reg_memlist, | ||
116 | sizeof(prom_reg_memlist)); | ||
117 | num_regs = (num_regs/sizeof(struct linux_prom_registers)); | ||
118 | for(iter=0; iter<num_regs; iter++) { | ||
119 | prom_phys_avail[iter].start_adr = | ||
120 | (char *) prom_reg_memlist[iter].phys_addr; | ||
121 | prom_phys_avail[iter].num_bytes = | ||
122 | (unsigned long) prom_reg_memlist[iter].reg_size; | ||
123 | prom_phys_avail[iter].theres_more = | ||
124 | &prom_phys_avail[iter+1]; | ||
125 | } | ||
126 | prom_phys_avail[iter-1].theres_more = NULL; | ||
127 | |||
128 | num_regs = prom_getproperty(node, "reg", | ||
129 | (char *) prom_reg_memlist, | ||
130 | sizeof(prom_reg_memlist)); | ||
131 | num_regs = (num_regs/sizeof(struct linux_prom_registers)); | ||
132 | for(iter=0; iter<num_regs; iter++) { | ||
133 | prom_phys_total[iter].start_adr = | ||
134 | (char *) prom_reg_memlist[iter].phys_addr; | ||
135 | prom_phys_total[iter].num_bytes = | ||
136 | (unsigned long) prom_reg_memlist[iter].reg_size; | ||
137 | prom_phys_total[iter].theres_more = | ||
138 | &prom_phys_total[iter+1]; | ||
139 | } | ||
140 | prom_phys_total[iter-1].theres_more = NULL; | ||
141 | |||
142 | node = prom_getchild(prom_root_node); | ||
143 | node = prom_searchsiblings(node, "virtual-memory"); | ||
144 | num_regs = prom_getproperty(node, "available", | ||
145 | (char *) prom_reg_memlist, | ||
146 | sizeof(prom_reg_memlist)); | ||
147 | num_regs = (num_regs/sizeof(struct linux_prom_registers)); | ||
148 | |||
149 | /* Convert available virtual areas to taken virtual | ||
150 | * areas. First sort, then convert. | ||
151 | */ | ||
152 | for(iter=0; iter<num_regs; iter++) { | ||
153 | prom_prom_taken[iter].start_adr = | ||
154 | (char *) prom_reg_memlist[iter].phys_addr; | ||
155 | prom_prom_taken[iter].num_bytes = | ||
156 | (unsigned long) prom_reg_memlist[iter].reg_size; | ||
157 | prom_prom_taken[iter].theres_more = | ||
158 | &prom_prom_taken[iter+1]; | ||
159 | } | ||
160 | prom_prom_taken[iter-1].theres_more = NULL; | ||
161 | |||
162 | prom_sortmemlist(prom_prom_taken); | ||
163 | |||
164 | /* Finally, convert. */ | ||
165 | for(iter=0; iter<num_regs; iter++) { | ||
166 | prom_prom_taken[iter].start_adr = | ||
167 | prom_prom_taken[iter].start_adr + | ||
168 | prom_prom_taken[iter].num_bytes; | ||
169 | prom_prom_taken[iter].num_bytes = | ||
170 | prom_prom_taken[iter+1].start_adr - | ||
171 | prom_prom_taken[iter].start_adr; | ||
172 | } | ||
173 | prom_prom_taken[iter-1].num_bytes = | ||
174 | 0xffffffff - (unsigned long) prom_prom_taken[iter-1].start_adr; | ||
175 | |||
176 | /* Sort the other two lists. */ | ||
177 | prom_sortmemlist(prom_phys_total); | ||
178 | prom_sortmemlist(prom_phys_avail); | ||
179 | break; | 82 | break; |
180 | 83 | ||
181 | case PROM_SUN4: | 84 | case PROM_SUN4: |
182 | #ifdef CONFIG_SUN4 | 85 | num_ents = prom_meminit_sun4(); |
183 | /* how simple :) */ | ||
184 | prom_phys_total[0].start_adr = NULL; | ||
185 | prom_phys_total[0].num_bytes = *(sun4_romvec->memorysize); | ||
186 | prom_phys_total[0].theres_more = NULL; | ||
187 | prom_prom_taken[0].start_adr = NULL; | ||
188 | prom_prom_taken[0].num_bytes = 0x0; | ||
189 | prom_prom_taken[0].theres_more = NULL; | ||
190 | prom_phys_avail[0].start_adr = NULL; | ||
191 | prom_phys_avail[0].num_bytes = *(sun4_romvec->memoryavail); | ||
192 | prom_phys_avail[0].theres_more = NULL; | ||
193 | #endif | ||
194 | break; | 86 | break; |
195 | 87 | ||
196 | default: | 88 | default: |
197 | break; | 89 | break; |
198 | }; | 90 | } |
199 | 91 | sort(sp_banks, num_ents, sizeof(struct sparc_phys_banks), | |
200 | /* Link all the lists into the top-level descriptor. */ | 92 | sp_banks_cmp, NULL); |
201 | prom_memlist.v0_totphys=&prom_ptot_ptr; | ||
202 | prom_memlist.v0_prommap=&prom_ptak_ptr; | ||
203 | prom_memlist.v0_available=&prom_pavl_ptr; | ||
204 | 93 | ||
205 | return; | 94 | /* Sentinel. */ |
206 | } | 95 | sp_banks[num_ents].base_addr = 0xdeadbeef; |
96 | sp_banks[num_ents].num_bytes = 0; | ||
207 | 97 | ||
208 | /* This returns a pointer to our libraries internal v0 format | 98 | for (i = 0; i < num_ents; i++) |
209 | * memory descriptor. | 99 | sp_banks[i].num_bytes &= PAGE_MASK; |
210 | */ | ||
211 | struct linux_mem_v0 * | ||
212 | prom_meminfo(void) | ||
213 | { | ||
214 | return &prom_memlist; | ||
215 | } | 100 | } |
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c index dbf2fc2f4d87..112b09f16f36 100644 --- a/arch/sparc64/kernel/pci.c +++ b/arch/sparc64/kernel/pci.c | |||
@@ -350,8 +350,7 @@ static void pci_parse_of_addrs(struct of_device *op, | |||
350 | 350 | ||
351 | struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, | 351 | struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, |
352 | struct device_node *node, | 352 | struct device_node *node, |
353 | struct pci_bus *bus, int devfn, | 353 | struct pci_bus *bus, int devfn) |
354 | int host_controller) | ||
355 | { | 354 | { |
356 | struct dev_archdata *sd; | 355 | struct dev_archdata *sd; |
357 | struct pci_dev *dev; | 356 | struct pci_dev *dev; |
@@ -390,43 +389,28 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, | |||
390 | dev->devfn = devfn; | 389 | dev->devfn = devfn; |
391 | dev->multifunction = 0; /* maybe a lie? */ | 390 | dev->multifunction = 0; /* maybe a lie? */ |
392 | 391 | ||
393 | if (host_controller) { | 392 | dev->vendor = of_getintprop_default(node, "vendor-id", 0xffff); |
394 | if (tlb_type != hypervisor) { | 393 | dev->device = of_getintprop_default(node, "device-id", 0xffff); |
395 | pci_read_config_word(dev, PCI_VENDOR_ID, | 394 | dev->subsystem_vendor = |
396 | &dev->vendor); | 395 | of_getintprop_default(node, "subsystem-vendor-id", 0); |
397 | pci_read_config_word(dev, PCI_DEVICE_ID, | 396 | dev->subsystem_device = |
398 | &dev->device); | 397 | of_getintprop_default(node, "subsystem-id", 0); |
399 | } else { | 398 | |
400 | dev->vendor = PCI_VENDOR_ID_SUN; | 399 | dev->cfg_size = pci_cfg_space_size(dev); |
401 | dev->device = 0x80f0; | 400 | |
402 | } | 401 | /* We can't actually use the firmware value, we have |
403 | dev->cfg_size = 256; | 402 | * to read what is in the register right now. One |
404 | dev->class = PCI_CLASS_BRIDGE_HOST << 8; | 403 | * reason is that in the case of IDE interfaces the |
405 | sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus), | 404 | * firmware can sample the value before the the IDE |
406 | 0x00, PCI_SLOT(devfn), PCI_FUNC(devfn)); | 405 | * interface is programmed into native mode. |
407 | } else { | 406 | */ |
408 | dev->vendor = of_getintprop_default(node, "vendor-id", 0xffff); | 407 | pci_read_config_dword(dev, PCI_CLASS_REVISION, &class); |
409 | dev->device = of_getintprop_default(node, "device-id", 0xffff); | 408 | dev->class = class >> 8; |
410 | dev->subsystem_vendor = | 409 | dev->revision = class & 0xff; |
411 | of_getintprop_default(node, "subsystem-vendor-id", 0); | 410 | |
412 | dev->subsystem_device = | 411 | sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus), |
413 | of_getintprop_default(node, "subsystem-id", 0); | 412 | dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); |
414 | |||
415 | dev->cfg_size = pci_cfg_space_size(dev); | ||
416 | |||
417 | /* We can't actually use the firmware value, we have | ||
418 | * to read what is in the register right now. One | ||
419 | * reason is that in the case of IDE interfaces the | ||
420 | * firmware can sample the value before the the IDE | ||
421 | * interface is programmed into native mode. | ||
422 | */ | ||
423 | pci_read_config_dword(dev, PCI_CLASS_REVISION, &class); | ||
424 | dev->class = class >> 8; | ||
425 | dev->revision = class & 0xff; | ||
426 | 413 | ||
427 | sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus), | ||
428 | dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); | ||
429 | } | ||
430 | if (ofpci_verbose) | 414 | if (ofpci_verbose) |
431 | printk(" class: 0x%x device name: %s\n", | 415 | printk(" class: 0x%x device name: %s\n", |
432 | dev->class, pci_name(dev)); | 416 | dev->class, pci_name(dev)); |
@@ -441,26 +425,21 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, | |||
441 | dev->current_state = 4; /* unknown power state */ | 425 | dev->current_state = 4; /* unknown power state */ |
442 | dev->error_state = pci_channel_io_normal; | 426 | dev->error_state = pci_channel_io_normal; |
443 | 427 | ||
444 | if (host_controller) { | 428 | if (!strcmp(type, "pci") || !strcmp(type, "pciex")) { |
429 | /* a PCI-PCI bridge */ | ||
445 | dev->hdr_type = PCI_HEADER_TYPE_BRIDGE; | 430 | dev->hdr_type = PCI_HEADER_TYPE_BRIDGE; |
446 | dev->rom_base_reg = PCI_ROM_ADDRESS1; | 431 | dev->rom_base_reg = PCI_ROM_ADDRESS1; |
447 | dev->irq = PCI_IRQ_NONE; | 432 | } else if (!strcmp(type, "cardbus")) { |
433 | dev->hdr_type = PCI_HEADER_TYPE_CARDBUS; | ||
448 | } else { | 434 | } else { |
449 | if (!strcmp(type, "pci") || !strcmp(type, "pciex")) { | 435 | dev->hdr_type = PCI_HEADER_TYPE_NORMAL; |
450 | /* a PCI-PCI bridge */ | 436 | dev->rom_base_reg = PCI_ROM_ADDRESS; |
451 | dev->hdr_type = PCI_HEADER_TYPE_BRIDGE; | ||
452 | dev->rom_base_reg = PCI_ROM_ADDRESS1; | ||
453 | } else if (!strcmp(type, "cardbus")) { | ||
454 | dev->hdr_type = PCI_HEADER_TYPE_CARDBUS; | ||
455 | } else { | ||
456 | dev->hdr_type = PCI_HEADER_TYPE_NORMAL; | ||
457 | dev->rom_base_reg = PCI_ROM_ADDRESS; | ||
458 | 437 | ||
459 | dev->irq = sd->op->irqs[0]; | 438 | dev->irq = sd->op->irqs[0]; |
460 | if (dev->irq == 0xffffffff) | 439 | if (dev->irq == 0xffffffff) |
461 | dev->irq = PCI_IRQ_NONE; | 440 | dev->irq = PCI_IRQ_NONE; |
462 | } | ||
463 | } | 441 | } |
442 | |||
464 | pci_parse_of_addrs(sd->op, node, dev); | 443 | pci_parse_of_addrs(sd->op, node, dev); |
465 | 444 | ||
466 | if (ofpci_verbose) | 445 | if (ofpci_verbose) |
@@ -749,7 +728,7 @@ static void __devinit pci_of_scan_bus(struct pci_pbm_info *pbm, | |||
749 | prev_devfn = devfn; | 728 | prev_devfn = devfn; |
750 | 729 | ||
751 | /* create a new pci_dev for this device */ | 730 | /* create a new pci_dev for this device */ |
752 | dev = of_create_pci_dev(pbm, child, bus, devfn, 0); | 731 | dev = of_create_pci_dev(pbm, child, bus, devfn); |
753 | if (!dev) | 732 | if (!dev) |
754 | continue; | 733 | continue; |
755 | if (ofpci_verbose) | 734 | if (ofpci_verbose) |
@@ -796,48 +775,9 @@ static void __devinit pci_bus_register_of_sysfs(struct pci_bus *bus) | |||
796 | pci_bus_register_of_sysfs(child_bus); | 775 | pci_bus_register_of_sysfs(child_bus); |
797 | } | 776 | } |
798 | 777 | ||
799 | int pci_host_bridge_read_pci_cfg(struct pci_bus *bus_dev, | ||
800 | unsigned int devfn, | ||
801 | int where, int size, | ||
802 | u32 *value) | ||
803 | { | ||
804 | static u8 fake_pci_config[] = { | ||
805 | 0x8e, 0x10, /* Vendor: 0x108e (Sun) */ | ||
806 | 0xf0, 0x80, /* Device: 0x80f0 (Fire) */ | ||
807 | 0x46, 0x01, /* Command: 0x0146 (SERR, PARITY, MASTER, MEM) */ | ||
808 | 0xa0, 0x22, /* Status: 0x02a0 (DEVSEL_MED, FB2B, 66MHZ) */ | ||
809 | 0x00, 0x00, 0x00, 0x06, /* Class: 0x06000000 host bridge */ | ||
810 | 0x00, /* Cacheline: 0x00 */ | ||
811 | 0x40, /* Latency: 0x40 */ | ||
812 | 0x00, /* Header-Type: 0x00 normal */ | ||
813 | }; | ||
814 | |||
815 | *value = 0; | ||
816 | if (where >= 0 && where < sizeof(fake_pci_config) && | ||
817 | (where + size) >= 0 && | ||
818 | (where + size) < sizeof(fake_pci_config) && | ||
819 | size <= sizeof(u32)) { | ||
820 | while (size--) { | ||
821 | *value <<= 8; | ||
822 | *value |= fake_pci_config[where + size]; | ||
823 | } | ||
824 | } | ||
825 | |||
826 | return PCIBIOS_SUCCESSFUL; | ||
827 | } | ||
828 | |||
829 | int pci_host_bridge_write_pci_cfg(struct pci_bus *bus_dev, | ||
830 | unsigned int devfn, | ||
831 | int where, int size, | ||
832 | u32 value) | ||
833 | { | ||
834 | return PCIBIOS_SUCCESSFUL; | ||
835 | } | ||
836 | |||
837 | struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm) | 778 | struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm) |
838 | { | 779 | { |
839 | struct device_node *node = pbm->prom_node; | 780 | struct device_node *node = pbm->prom_node; |
840 | struct pci_dev *host_pdev; | ||
841 | struct pci_bus *bus; | 781 | struct pci_bus *bus; |
842 | 782 | ||
843 | printk("PCI: Scanning PBM %s\n", node->full_name); | 783 | printk("PCI: Scanning PBM %s\n", node->full_name); |
@@ -855,10 +795,6 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm) | |||
855 | bus->resource[0] = &pbm->io_space; | 795 | bus->resource[0] = &pbm->io_space; |
856 | bus->resource[1] = &pbm->mem_space; | 796 | bus->resource[1] = &pbm->mem_space; |
857 | 797 | ||
858 | /* Create the dummy host bridge and link it in. */ | ||
859 | host_pdev = of_create_pci_dev(pbm, node, bus, 0x00, 1); | ||
860 | bus->self = host_pdev; | ||
861 | |||
862 | pci_of_scan_bus(pbm, node, bus); | 798 | pci_of_scan_bus(pbm, node, bus); |
863 | pci_bus_add_devices(bus); | 799 | pci_bus_add_devices(bus); |
864 | pci_bus_register_of_sysfs(bus); | 800 | pci_bus_register_of_sysfs(bus); |
diff --git a/arch/sparc64/kernel/pci_common.c b/arch/sparc64/kernel/pci_common.c index 923e0bcc3bfd..19fa621d6a60 100644 --- a/arch/sparc64/kernel/pci_common.c +++ b/arch/sparc64/kernel/pci_common.c | |||
@@ -264,9 +264,6 @@ static int sun4v_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn, | |||
264 | unsigned int func = PCI_FUNC(devfn); | 264 | unsigned int func = PCI_FUNC(devfn); |
265 | unsigned long ret; | 265 | unsigned long ret; |
266 | 266 | ||
267 | if (!bus && devfn == 0x00) | ||
268 | return pci_host_bridge_read_pci_cfg(bus_dev, devfn, where, | ||
269 | size, value); | ||
270 | if (config_out_of_range(pbm, bus, devfn, where)) { | 267 | if (config_out_of_range(pbm, bus, devfn, where)) { |
271 | ret = ~0UL; | 268 | ret = ~0UL; |
272 | } else { | 269 | } else { |
@@ -300,9 +297,6 @@ static int sun4v_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn, | |||
300 | unsigned int func = PCI_FUNC(devfn); | 297 | unsigned int func = PCI_FUNC(devfn); |
301 | unsigned long ret; | 298 | unsigned long ret; |
302 | 299 | ||
303 | if (!bus && devfn == 0x00) | ||
304 | return pci_host_bridge_write_pci_cfg(bus_dev, devfn, where, | ||
305 | size, value); | ||
306 | if (config_out_of_range(pbm, bus, devfn, where)) { | 300 | if (config_out_of_range(pbm, bus, devfn, where)) { |
307 | /* Do nothing. */ | 301 | /* Do nothing. */ |
308 | } else { | 302 | } else { |
diff --git a/arch/sparc64/kernel/pci_impl.h b/arch/sparc64/kernel/pci_impl.h index 218bac4ff79b..c385d126be11 100644 --- a/arch/sparc64/kernel/pci_impl.h +++ b/arch/sparc64/kernel/pci_impl.h | |||
@@ -167,15 +167,6 @@ extern void pci_get_pbm_props(struct pci_pbm_info *pbm); | |||
167 | extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm); | 167 | extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm); |
168 | extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm); | 168 | extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm); |
169 | 169 | ||
170 | extern int pci_host_bridge_read_pci_cfg(struct pci_bus *bus_dev, | ||
171 | unsigned int devfn, | ||
172 | int where, int size, | ||
173 | u32 *value); | ||
174 | extern int pci_host_bridge_write_pci_cfg(struct pci_bus *bus_dev, | ||
175 | unsigned int devfn, | ||
176 | int where, int size, | ||
177 | u32 value); | ||
178 | |||
179 | /* Error reporting support. */ | 170 | /* Error reporting support. */ |
180 | extern void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *); | 171 | extern void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *); |
181 | extern void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *); | 172 | extern void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *); |
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c index 056013749157..500ac6d483a0 100644 --- a/arch/sparc64/kernel/process.c +++ b/arch/sparc64/kernel/process.c | |||
@@ -591,12 +591,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, | |||
591 | if (clone_flags & CLONE_SETTLS) | 591 | if (clone_flags & CLONE_SETTLS) |
592 | t->kregs->u_regs[UREG_G7] = regs->u_regs[UREG_I3]; | 592 | t->kregs->u_regs[UREG_G7] = regs->u_regs[UREG_I3]; |
593 | 593 | ||
594 | /* We do not want to accidently trigger system call restart | ||
595 | * handling in the new thread. Therefore, clear out the trap | ||
596 | * type, which will make pt_regs_regs_is_syscall() return false. | ||
597 | */ | ||
598 | pt_regs_clear_trap_type(t->kregs); | ||
599 | |||
600 | return 0; | 594 | return 0; |
601 | } | 595 | } |
602 | 596 | ||
diff --git a/arch/sparc64/kernel/signal.c b/arch/sparc64/kernel/signal.c index f2d88d8f7a42..45d6bf632daa 100644 --- a/arch/sparc64/kernel/signal.c +++ b/arch/sparc64/kernel/signal.c | |||
@@ -332,6 +332,9 @@ void do_rt_sigreturn(struct pt_regs *regs) | |||
332 | regs->tpc = tpc; | 332 | regs->tpc = tpc; |
333 | regs->tnpc = tnpc; | 333 | regs->tnpc = tnpc; |
334 | 334 | ||
335 | /* Prevent syscall restart. */ | ||
336 | pt_regs_clear_trap_type(regs); | ||
337 | |||
335 | sigdelsetmask(&set, ~_BLOCKABLE); | 338 | sigdelsetmask(&set, ~_BLOCKABLE); |
336 | spin_lock_irq(¤t->sighand->siglock); | 339 | spin_lock_irq(¤t->sighand->siglock); |
337 | current->blocked = set; | 340 | current->blocked = set; |
@@ -515,7 +518,8 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) | |||
515 | siginfo_t info; | 518 | siginfo_t info; |
516 | int signr; | 519 | int signr; |
517 | 520 | ||
518 | if (pt_regs_is_syscall(regs)) { | 521 | if (pt_regs_is_syscall(regs) && |
522 | (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) { | ||
519 | pt_regs_clear_trap_type(regs); | 523 | pt_regs_clear_trap_type(regs); |
520 | cookie.restart_syscall = 1; | 524 | cookie.restart_syscall = 1; |
521 | } else | 525 | } else |
diff --git a/arch/sparc64/kernel/signal32.c b/arch/sparc64/kernel/signal32.c index 91f8d0826db1..9415d2c918c5 100644 --- a/arch/sparc64/kernel/signal32.c +++ b/arch/sparc64/kernel/signal32.c | |||
@@ -268,6 +268,9 @@ void do_sigreturn32(struct pt_regs *regs) | |||
268 | regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC); | 268 | regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC); |
269 | regs->tstate |= psr_to_tstate_icc(psr); | 269 | regs->tstate |= psr_to_tstate_icc(psr); |
270 | 270 | ||
271 | /* Prevent syscall restart. */ | ||
272 | pt_regs_clear_trap_type(regs); | ||
273 | |||
271 | err |= __get_user(fpu_save, &sf->fpu_save); | 274 | err |= __get_user(fpu_save, &sf->fpu_save); |
272 | if (fpu_save) | 275 | if (fpu_save) |
273 | err |= restore_fpu_state32(regs, &sf->fpu_state); | 276 | err |= restore_fpu_state32(regs, &sf->fpu_state); |
@@ -351,6 +354,9 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) | |||
351 | regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC); | 354 | regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC); |
352 | regs->tstate |= psr_to_tstate_icc(psr); | 355 | regs->tstate |= psr_to_tstate_icc(psr); |
353 | 356 | ||
357 | /* Prevent syscall restart. */ | ||
358 | pt_regs_clear_trap_type(regs); | ||
359 | |||
354 | err |= __get_user(fpu_save, &sf->fpu_save); | 360 | err |= __get_user(fpu_save, &sf->fpu_save); |
355 | if (fpu_save) | 361 | if (fpu_save) |
356 | err |= restore_fpu_state32(regs, &sf->fpu_state); | 362 | err |= restore_fpu_state32(regs, &sf->fpu_state); |
diff --git a/arch/um/Makefile b/arch/um/Makefile index dbeab15e7bb7..01b97c19a8ba 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile | |||
@@ -77,7 +77,10 @@ include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS) | |||
77 | KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ | 77 | KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ |
78 | -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) | 78 | -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) |
79 | KBUILD_CFLAGS += $(KERNEL_DEFINES) | 79 | KBUILD_CFLAGS += $(KERNEL_DEFINES) |
80 | KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,) | 80 | # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use |
81 | # a lot more stack due to the lack of sharing of stacklots: | ||
82 | KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then \ | ||
83 | echo $(call cc-option,-fno-unit-at-a-time); fi ;) | ||
81 | 84 | ||
82 | PHONY += linux | 85 | PHONY += linux |
83 | 86 | ||
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c index 9cffc628a37e..128ee85bc8d9 100644 --- a/arch/um/kernel/syscall.c +++ b/arch/um/kernel/syscall.c | |||
@@ -73,23 +73,6 @@ long old_mmap(unsigned long addr, unsigned long len, | |||
73 | out: | 73 | out: |
74 | return err; | 74 | return err; |
75 | } | 75 | } |
76 | /* | ||
77 | * sys_pipe() is the normal C calling standard for creating | ||
78 | * a pipe. It's not the way unix traditionally does this, though. | ||
79 | */ | ||
80 | long sys_pipe(unsigned long __user * fildes) | ||
81 | { | ||
82 | int fd[2]; | ||
83 | long error; | ||
84 | |||
85 | error = do_pipe(fd); | ||
86 | if (!error) { | ||
87 | if (copy_to_user(fildes, fd, sizeof(fd))) | ||
88 | error = -EFAULT; | ||
89 | } | ||
90 | return error; | ||
91 | } | ||
92 | |||
93 | 76 | ||
94 | long sys_uname(struct old_utsname __user * name) | 77 | long sys_uname(struct old_utsname __user * name) |
95 | { | 78 | { |
diff --git a/arch/v850/kernel/syscalls.c b/arch/v850/kernel/syscalls.c index 003db9c8c44a..1a83daf8e24f 100644 --- a/arch/v850/kernel/syscalls.c +++ b/arch/v850/kernel/syscalls.c | |||
@@ -132,23 +132,6 @@ sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth) | |||
132 | return ret; | 132 | return ret; |
133 | } | 133 | } |
134 | 134 | ||
135 | /* | ||
136 | * sys_pipe() is the normal C calling standard for creating | ||
137 | * a pipe. It's not the way unix traditionally does this, though. | ||
138 | */ | ||
139 | int sys_pipe (int *fildes) | ||
140 | { | ||
141 | int fd[2]; | ||
142 | int error; | ||
143 | |||
144 | error = do_pipe (fd); | ||
145 | if (!error) { | ||
146 | if (copy_to_user (fildes, fd, 2*sizeof (int))) | ||
147 | error = -EFAULT; | ||
148 | } | ||
149 | return error; | ||
150 | } | ||
151 | |||
152 | static inline unsigned long | 135 | static inline unsigned long |
153 | do_mmap2 (unsigned long addr, size_t len, | 136 | do_mmap2 (unsigned long addr, size_t len, |
154 | unsigned long prot, unsigned long flags, | 137 | unsigned long prot, unsigned long flags, |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c3f880902d66..bbcafaa160c0 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -18,6 +18,7 @@ config X86_64 | |||
18 | ### Arch settings | 18 | ### Arch settings |
19 | config X86 | 19 | config X86 |
20 | def_bool y | 20 | def_bool y |
21 | select HAVE_UNSTABLE_SCHED_CLOCK | ||
21 | select HAVE_IDE | 22 | select HAVE_IDE |
22 | select HAVE_OPROFILE | 23 | select HAVE_OPROFILE |
23 | select HAVE_KPROBES | 24 | select HAVE_KPROBES |
@@ -1661,6 +1662,7 @@ config GEODE_MFGPT_TIMER | |||
1661 | 1662 | ||
1662 | config OLPC | 1663 | config OLPC |
1663 | bool "One Laptop Per Child support" | 1664 | bool "One Laptop Per Child support" |
1665 | depends on MGEODE_LX | ||
1664 | default n | 1666 | default n |
1665 | help | 1667 | help |
1666 | Add support for detecting the unique features of the OLPC | 1668 | Add support for detecting the unique features of the OLPC |
diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c index d01ea42187e6..edaadea90aaf 100644 --- a/arch/x86/boot/compressed/relocs.c +++ b/arch/x86/boot/compressed/relocs.c | |||
@@ -191,7 +191,7 @@ static void read_ehdr(FILE *fp) | |||
191 | die("Cannot read ELF header: %s\n", | 191 | die("Cannot read ELF header: %s\n", |
192 | strerror(errno)); | 192 | strerror(errno)); |
193 | } | 193 | } |
194 | if (memcmp(ehdr.e_ident, ELFMAG, 4) != 0) { | 194 | if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) { |
195 | die("No ELF magic\n"); | 195 | die("No ELF magic\n"); |
196 | } | 196 | } |
197 | if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) { | 197 | if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) { |
diff --git a/arch/x86/kernel/acpi/Makefile b/arch/x86/kernel/acpi/Makefile index 7335959b6aff..fd5ca97a2ad5 100644 --- a/arch/x86/kernel/acpi/Makefile +++ b/arch/x86/kernel/acpi/Makefile | |||
@@ -10,5 +10,5 @@ endif | |||
10 | $(obj)/wakeup_rm.o: $(obj)/realmode/wakeup.bin | 10 | $(obj)/wakeup_rm.o: $(obj)/realmode/wakeup.bin |
11 | 11 | ||
12 | $(obj)/realmode/wakeup.bin: FORCE | 12 | $(obj)/realmode/wakeup.bin: FORCE |
13 | $(Q)$(MAKE) $(build)=$(obj)/realmode $@ | 13 | $(Q)$(MAKE) $(build)=$(obj)/realmode |
14 | 14 | ||
diff --git a/arch/x86/kernel/acpi/realmode/Makefile b/arch/x86/kernel/acpi/realmode/Makefile index 092900854acc..1c31cc0e9def 100644 --- a/arch/x86/kernel/acpi/realmode/Makefile +++ b/arch/x86/kernel/acpi/realmode/Makefile | |||
@@ -6,7 +6,8 @@ | |||
6 | # for more details. | 6 | # for more details. |
7 | # | 7 | # |
8 | 8 | ||
9 | targets := wakeup.bin wakeup.elf | 9 | always := wakeup.bin |
10 | targets := wakeup.elf wakeup.lds | ||
10 | 11 | ||
11 | wakeup-y += wakeup.o wakemain.o video-mode.o copy.o | 12 | wakeup-y += wakeup.o wakemain.o video-mode.o copy.o |
12 | 13 | ||
@@ -48,7 +49,7 @@ LDFLAGS_wakeup.elf := -T | |||
48 | 49 | ||
49 | CPPFLAGS_wakeup.lds += -P -C | 50 | CPPFLAGS_wakeup.lds += -P -C |
50 | 51 | ||
51 | $(obj)/wakeup.elf: $(src)/wakeup.lds $(WAKEUP_OBJS) FORCE | 52 | $(obj)/wakeup.elf: $(obj)/wakeup.lds $(WAKEUP_OBJS) FORCE |
52 | $(call if_changed,ld) | 53 | $(call if_changed,ld) |
53 | 54 | ||
54 | OBJCOPYFLAGS_wakeup.bin := -O binary | 55 | OBJCOPYFLAGS_wakeup.bin := -O binary |
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index ddee04043aeb..4bc1be5d5472 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c | |||
@@ -133,6 +133,7 @@ static int kvm_register_clock(void) | |||
133 | return native_write_msr_safe(MSR_KVM_SYSTEM_TIME, low, high); | 133 | return native_write_msr_safe(MSR_KVM_SYSTEM_TIME, low, high); |
134 | } | 134 | } |
135 | 135 | ||
136 | #ifdef CONFIG_X86_LOCAL_APIC | ||
136 | static void kvm_setup_secondary_clock(void) | 137 | static void kvm_setup_secondary_clock(void) |
137 | { | 138 | { |
138 | /* | 139 | /* |
@@ -143,6 +144,7 @@ static void kvm_setup_secondary_clock(void) | |||
143 | /* ok, done with our trickery, call native */ | 144 | /* ok, done with our trickery, call native */ |
144 | setup_secondary_APIC_clock(); | 145 | setup_secondary_APIC_clock(); |
145 | } | 146 | } |
147 | #endif | ||
146 | 148 | ||
147 | /* | 149 | /* |
148 | * After the clock is registered, the host will keep writing to the | 150 | * After the clock is registered, the host will keep writing to the |
@@ -177,7 +179,9 @@ void __init kvmclock_init(void) | |||
177 | pv_time_ops.get_wallclock = kvm_get_wallclock; | 179 | pv_time_ops.get_wallclock = kvm_get_wallclock; |
178 | pv_time_ops.set_wallclock = kvm_set_wallclock; | 180 | pv_time_ops.set_wallclock = kvm_set_wallclock; |
179 | pv_time_ops.sched_clock = kvm_clock_read; | 181 | pv_time_ops.sched_clock = kvm_clock_read; |
182 | #ifdef CONFIG_X86_LOCAL_APIC | ||
180 | pv_apic_ops.setup_secondary_clock = kvm_setup_secondary_clock; | 183 | pv_apic_ops.setup_secondary_clock = kvm_setup_secondary_clock; |
184 | #endif | ||
181 | machine_ops.shutdown = kvm_shutdown; | 185 | machine_ops.shutdown = kvm_shutdown; |
182 | #ifdef CONFIG_KEXEC | 186 | #ifdef CONFIG_KEXEC |
183 | machine_ops.crash_shutdown = kvm_crash_shutdown; | 187 | machine_ops.crash_shutdown = kvm_crash_shutdown; |
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index 3e2c54dc8b29..404683b94e79 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c | |||
@@ -794,6 +794,11 @@ void __init find_smp_config(void) | |||
794 | ACPI-based MP Configuration | 794 | ACPI-based MP Configuration |
795 | -------------------------------------------------------------------------- */ | 795 | -------------------------------------------------------------------------- */ |
796 | 796 | ||
797 | /* | ||
798 | * Keep this outside and initialized to 0, for !CONFIG_ACPI builds: | ||
799 | */ | ||
800 | int es7000_plat; | ||
801 | |||
797 | #ifdef CONFIG_ACPI | 802 | #ifdef CONFIG_ACPI |
798 | 803 | ||
799 | #ifdef CONFIG_X86_IO_APIC | 804 | #ifdef CONFIG_X86_IO_APIC |
@@ -909,8 +914,6 @@ void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi) | |||
909 | MP_intsrc_info(&intsrc); | 914 | MP_intsrc_info(&intsrc); |
910 | } | 915 | } |
911 | 916 | ||
912 | int es7000_plat; | ||
913 | |||
914 | void __init mp_config_acpi_legacy_irqs(void) | 917 | void __init mp_config_acpi_legacy_irqs(void) |
915 | { | 918 | { |
916 | struct mpc_config_intsrc intsrc; | 919 | struct mpc_config_intsrc intsrc; |
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 07c6d42ab5ff..f6be7d5f82f8 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c | |||
@@ -149,7 +149,6 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = { | |||
149 | .matches = { | 149 | .matches = { |
150 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | 150 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
151 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), | 151 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), |
152 | DMI_MATCH(DMI_BOARD_NAME, "0WF810"), | ||
153 | }, | 152 | }, |
154 | }, | 153 | }, |
155 | { /* Handle problems with rebooting on Dell Optiplex 745's DFF*/ | 154 | { /* Handle problems with rebooting on Dell Optiplex 745's DFF*/ |
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index c0c68c18a788..cc6f5eb20b24 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -95,7 +95,7 @@ void __init setup_per_cpu_areas(void) | |||
95 | 95 | ||
96 | /* Copy section for each CPU (we discard the original) */ | 96 | /* Copy section for each CPU (we discard the original) */ |
97 | size = PERCPU_ENOUGH_ROOM; | 97 | size = PERCPU_ENOUGH_ROOM; |
98 | printk(KERN_INFO "PERCPU: Allocating %lu bytes of per cpu data\n", | 98 | printk(KERN_INFO "PERCPU: Allocating %zd bytes of per cpu data\n", |
99 | size); | 99 | size); |
100 | 100 | ||
101 | for_each_possible_cpu(i) { | 101 | for_each_possible_cpu(i) { |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 84241a256dc8..6b087ab6cd8f 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -299,7 +299,7 @@ static void __cpuinit smp_callin(void) | |||
299 | /* | 299 | /* |
300 | * Activate a secondary processor. | 300 | * Activate a secondary processor. |
301 | */ | 301 | */ |
302 | void __cpuinit start_secondary(void *unused) | 302 | static void __cpuinit start_secondary(void *unused) |
303 | { | 303 | { |
304 | /* | 304 | /* |
305 | * Don't put *anything* before cpu_init(), SMP booting is too | 305 | * Don't put *anything* before cpu_init(), SMP booting is too |
@@ -1306,7 +1306,7 @@ static void remove_siblinginfo(int cpu) | |||
1306 | cpu_clear(cpu, cpu_sibling_setup_map); | 1306 | cpu_clear(cpu, cpu_sibling_setup_map); |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | int additional_cpus __initdata = -1; | 1309 | static int additional_cpus __initdata = -1; |
1310 | 1310 | ||
1311 | static __init int setup_additional_cpus(char *s) | 1311 | static __init int setup_additional_cpus(char *s) |
1312 | { | 1312 | { |
diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c index a86d26f036e1..d2ab52cc1d6b 100644 --- a/arch/x86/kernel/sys_i386_32.c +++ b/arch/x86/kernel/sys_i386_32.c | |||
@@ -22,23 +22,6 @@ | |||
22 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
23 | #include <asm/unistd.h> | 23 | #include <asm/unistd.h> |
24 | 24 | ||
25 | /* | ||
26 | * sys_pipe() is the normal C calling standard for creating | ||
27 | * a pipe. It's not the way Unix traditionally does this, though. | ||
28 | */ | ||
29 | asmlinkage int sys_pipe(unsigned long __user * fildes) | ||
30 | { | ||
31 | int fd[2]; | ||
32 | int error; | ||
33 | |||
34 | error = do_pipe(fd); | ||
35 | if (!error) { | ||
36 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
37 | error = -EFAULT; | ||
38 | } | ||
39 | return error; | ||
40 | } | ||
41 | |||
42 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | 25 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, |
43 | unsigned long prot, unsigned long flags, | 26 | unsigned long prot, unsigned long flags, |
44 | unsigned long fd, unsigned long pgoff) | 27 | unsigned long fd, unsigned long pgoff) |
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c index bd802a5e1aa3..3b360ef33817 100644 --- a/arch/x86/kernel/sys_x86_64.c +++ b/arch/x86/kernel/sys_x86_64.c | |||
@@ -17,23 +17,6 @@ | |||
17 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
18 | #include <asm/ia32.h> | 18 | #include <asm/ia32.h> |
19 | 19 | ||
20 | /* | ||
21 | * sys_pipe() is the normal C calling standard for creating | ||
22 | * a pipe. It's not the way Unix traditionally does this, though. | ||
23 | */ | ||
24 | asmlinkage long sys_pipe(int __user *fildes) | ||
25 | { | ||
26 | int fd[2]; | ||
27 | int error; | ||
28 | |||
29 | error = do_pipe(fd); | ||
30 | if (!error) { | ||
31 | if (copy_to_user(fildes, fd, 2*sizeof(int))) | ||
32 | error = -EFAULT; | ||
33 | } | ||
34 | return error; | ||
35 | } | ||
36 | |||
37 | asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, | 20 | asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, |
38 | unsigned long fd, unsigned long off) | 21 | unsigned long fd, unsigned long off) |
39 | { | 22 | { |
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 361e31611276..3324d90038e4 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include "i8254.h" | 35 | #include "i8254.h" |
36 | 36 | ||
37 | #ifndef CONFIG_X86_64 | 37 | #ifndef CONFIG_X86_64 |
38 | #define mod_64(x, y) ((x) - (y) * div64_64(x, y)) | 38 | #define mod_64(x, y) ((x) - (y) * div64_u64(x, y)) |
39 | #else | 39 | #else |
40 | #define mod_64(x, y) ((x) % (y)) | 40 | #define mod_64(x, y) ((x) % (y)) |
41 | #endif | 41 | #endif |
@@ -60,8 +60,8 @@ static u64 muldiv64(u64 a, u32 b, u32 c) | |||
60 | rl = (u64)u.l.low * (u64)b; | 60 | rl = (u64)u.l.low * (u64)b; |
61 | rh = (u64)u.l.high * (u64)b; | 61 | rh = (u64)u.l.high * (u64)b; |
62 | rh += (rl >> 32); | 62 | rh += (rl >> 32); |
63 | res.l.high = div64_64(rh, c); | 63 | res.l.high = div64_u64(rh, c); |
64 | res.l.low = div64_64(((mod_64(rh, c) << 32) + (rl & 0xffffffff)), c); | 64 | res.l.low = div64_u64(((mod_64(rh, c) << 32) + (rl & 0xffffffff)), c); |
65 | return res.ll; | 65 | return res.ll; |
66 | } | 66 | } |
67 | 67 | ||
@@ -288,6 +288,8 @@ static void pit_load_count(struct kvm *kvm, int channel, u32 val) | |||
288 | * mode 1 is one shot, mode 2 is period, otherwise del timer */ | 288 | * mode 1 is one shot, mode 2 is period, otherwise del timer */ |
289 | switch (ps->channels[0].mode) { | 289 | switch (ps->channels[0].mode) { |
290 | case 1: | 290 | case 1: |
291 | /* FIXME: enhance mode 4 precision */ | ||
292 | case 4: | ||
291 | create_pit_timer(&ps->pit_timer, val, 0); | 293 | create_pit_timer(&ps->pit_timer, val, 0); |
292 | break; | 294 | break; |
293 | case 2: | 295 | case 2: |
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 57ac4e4c556a..36809d79788b 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -25,13 +25,13 @@ | |||
25 | #include <linux/hrtimer.h> | 25 | #include <linux/hrtimer.h> |
26 | #include <linux/io.h> | 26 | #include <linux/io.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/math64.h> | ||
28 | #include <asm/processor.h> | 29 | #include <asm/processor.h> |
29 | #include <asm/msr.h> | 30 | #include <asm/msr.h> |
30 | #include <asm/page.h> | 31 | #include <asm/page.h> |
31 | #include <asm/current.h> | 32 | #include <asm/current.h> |
32 | #include <asm/apicdef.h> | 33 | #include <asm/apicdef.h> |
33 | #include <asm/atomic.h> | 34 | #include <asm/atomic.h> |
34 | #include <asm/div64.h> | ||
35 | #include "irq.h" | 35 | #include "irq.h" |
36 | 36 | ||
37 | #define PRId64 "d" | 37 | #define PRId64 "d" |
@@ -526,8 +526,8 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic) | |||
526 | } else | 526 | } else |
527 | passed = ktime_sub(now, apic->timer.last_update); | 527 | passed = ktime_sub(now, apic->timer.last_update); |
528 | 528 | ||
529 | counter_passed = div64_64(ktime_to_ns(passed), | 529 | counter_passed = div64_u64(ktime_to_ns(passed), |
530 | (APIC_BUS_CYCLE_NS * apic->timer.divide_count)); | 530 | (APIC_BUS_CYCLE_NS * apic->timer.divide_count)); |
531 | 531 | ||
532 | if (counter_passed > tmcct) { | 532 | if (counter_passed > tmcct) { |
533 | if (unlikely(!apic_lvtt_period(apic))) { | 533 | if (unlikely(!apic_lvtt_period(apic))) { |
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 2ad6f5481671..36c5406b1813 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -79,36 +79,6 @@ static int dbg = 1; | |||
79 | } | 79 | } |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | #define PT64_PT_BITS 9 | ||
83 | #define PT64_ENT_PER_PAGE (1 << PT64_PT_BITS) | ||
84 | #define PT32_PT_BITS 10 | ||
85 | #define PT32_ENT_PER_PAGE (1 << PT32_PT_BITS) | ||
86 | |||
87 | #define PT_WRITABLE_SHIFT 1 | ||
88 | |||
89 | #define PT_PRESENT_MASK (1ULL << 0) | ||
90 | #define PT_WRITABLE_MASK (1ULL << PT_WRITABLE_SHIFT) | ||
91 | #define PT_USER_MASK (1ULL << 2) | ||
92 | #define PT_PWT_MASK (1ULL << 3) | ||
93 | #define PT_PCD_MASK (1ULL << 4) | ||
94 | #define PT_ACCESSED_MASK (1ULL << 5) | ||
95 | #define PT_DIRTY_MASK (1ULL << 6) | ||
96 | #define PT_PAGE_SIZE_MASK (1ULL << 7) | ||
97 | #define PT_PAT_MASK (1ULL << 7) | ||
98 | #define PT_GLOBAL_MASK (1ULL << 8) | ||
99 | #define PT64_NX_SHIFT 63 | ||
100 | #define PT64_NX_MASK (1ULL << PT64_NX_SHIFT) | ||
101 | |||
102 | #define PT_PAT_SHIFT 7 | ||
103 | #define PT_DIR_PAT_SHIFT 12 | ||
104 | #define PT_DIR_PAT_MASK (1ULL << PT_DIR_PAT_SHIFT) | ||
105 | |||
106 | #define PT32_DIR_PSE36_SIZE 4 | ||
107 | #define PT32_DIR_PSE36_SHIFT 13 | ||
108 | #define PT32_DIR_PSE36_MASK \ | ||
109 | (((1ULL << PT32_DIR_PSE36_SIZE) - 1) << PT32_DIR_PSE36_SHIFT) | ||
110 | |||
111 | |||
112 | #define PT_FIRST_AVAIL_BITS_SHIFT 9 | 82 | #define PT_FIRST_AVAIL_BITS_SHIFT 9 |
113 | #define PT64_SECOND_AVAIL_BITS_SHIFT 52 | 83 | #define PT64_SECOND_AVAIL_BITS_SHIFT 52 |
114 | 84 | ||
@@ -154,10 +124,6 @@ static int dbg = 1; | |||
154 | #define PFERR_USER_MASK (1U << 2) | 124 | #define PFERR_USER_MASK (1U << 2) |
155 | #define PFERR_FETCH_MASK (1U << 4) | 125 | #define PFERR_FETCH_MASK (1U << 4) |
156 | 126 | ||
157 | #define PT64_ROOT_LEVEL 4 | ||
158 | #define PT32_ROOT_LEVEL 2 | ||
159 | #define PT32E_ROOT_LEVEL 3 | ||
160 | |||
161 | #define PT_DIRECTORY_LEVEL 2 | 127 | #define PT_DIRECTORY_LEVEL 2 |
162 | #define PT_PAGE_TABLE_LEVEL 1 | 128 | #define PT_PAGE_TABLE_LEVEL 1 |
163 | 129 | ||
@@ -186,6 +152,12 @@ static struct kmem_cache *mmu_page_header_cache; | |||
186 | 152 | ||
187 | static u64 __read_mostly shadow_trap_nonpresent_pte; | 153 | static u64 __read_mostly shadow_trap_nonpresent_pte; |
188 | static u64 __read_mostly shadow_notrap_nonpresent_pte; | 154 | static u64 __read_mostly shadow_notrap_nonpresent_pte; |
155 | static u64 __read_mostly shadow_base_present_pte; | ||
156 | static u64 __read_mostly shadow_nx_mask; | ||
157 | static u64 __read_mostly shadow_x_mask; /* mutual exclusive with nx_mask */ | ||
158 | static u64 __read_mostly shadow_user_mask; | ||
159 | static u64 __read_mostly shadow_accessed_mask; | ||
160 | static u64 __read_mostly shadow_dirty_mask; | ||
189 | 161 | ||
190 | void kvm_mmu_set_nonpresent_ptes(u64 trap_pte, u64 notrap_pte) | 162 | void kvm_mmu_set_nonpresent_ptes(u64 trap_pte, u64 notrap_pte) |
191 | { | 163 | { |
@@ -194,6 +166,23 @@ void kvm_mmu_set_nonpresent_ptes(u64 trap_pte, u64 notrap_pte) | |||
194 | } | 166 | } |
195 | EXPORT_SYMBOL_GPL(kvm_mmu_set_nonpresent_ptes); | 167 | EXPORT_SYMBOL_GPL(kvm_mmu_set_nonpresent_ptes); |
196 | 168 | ||
169 | void kvm_mmu_set_base_ptes(u64 base_pte) | ||
170 | { | ||
171 | shadow_base_present_pte = base_pte; | ||
172 | } | ||
173 | EXPORT_SYMBOL_GPL(kvm_mmu_set_base_ptes); | ||
174 | |||
175 | void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, | ||
176 | u64 dirty_mask, u64 nx_mask, u64 x_mask) | ||
177 | { | ||
178 | shadow_user_mask = user_mask; | ||
179 | shadow_accessed_mask = accessed_mask; | ||
180 | shadow_dirty_mask = dirty_mask; | ||
181 | shadow_nx_mask = nx_mask; | ||
182 | shadow_x_mask = x_mask; | ||
183 | } | ||
184 | EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes); | ||
185 | |||
197 | static int is_write_protection(struct kvm_vcpu *vcpu) | 186 | static int is_write_protection(struct kvm_vcpu *vcpu) |
198 | { | 187 | { |
199 | return vcpu->arch.cr0 & X86_CR0_WP; | 188 | return vcpu->arch.cr0 & X86_CR0_WP; |
@@ -232,7 +221,7 @@ static int is_writeble_pte(unsigned long pte) | |||
232 | 221 | ||
233 | static int is_dirty_pte(unsigned long pte) | 222 | static int is_dirty_pte(unsigned long pte) |
234 | { | 223 | { |
235 | return pte & PT_DIRTY_MASK; | 224 | return pte & shadow_dirty_mask; |
236 | } | 225 | } |
237 | 226 | ||
238 | static int is_rmap_pte(u64 pte) | 227 | static int is_rmap_pte(u64 pte) |
@@ -387,7 +376,6 @@ static void account_shadowed(struct kvm *kvm, gfn_t gfn) | |||
387 | 376 | ||
388 | write_count = slot_largepage_idx(gfn, gfn_to_memslot(kvm, gfn)); | 377 | write_count = slot_largepage_idx(gfn, gfn_to_memslot(kvm, gfn)); |
389 | *write_count += 1; | 378 | *write_count += 1; |
390 | WARN_ON(*write_count > KVM_PAGES_PER_HPAGE); | ||
391 | } | 379 | } |
392 | 380 | ||
393 | static void unaccount_shadowed(struct kvm *kvm, gfn_t gfn) | 381 | static void unaccount_shadowed(struct kvm *kvm, gfn_t gfn) |
@@ -547,7 +535,7 @@ static void rmap_remove(struct kvm *kvm, u64 *spte) | |||
547 | return; | 535 | return; |
548 | sp = page_header(__pa(spte)); | 536 | sp = page_header(__pa(spte)); |
549 | pfn = spte_to_pfn(*spte); | 537 | pfn = spte_to_pfn(*spte); |
550 | if (*spte & PT_ACCESSED_MASK) | 538 | if (*spte & shadow_accessed_mask) |
551 | kvm_set_pfn_accessed(pfn); | 539 | kvm_set_pfn_accessed(pfn); |
552 | if (is_writeble_pte(*spte)) | 540 | if (is_writeble_pte(*spte)) |
553 | kvm_release_pfn_dirty(pfn); | 541 | kvm_release_pfn_dirty(pfn); |
@@ -1073,17 +1061,17 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte, | |||
1073 | * whether the guest actually used the pte (in order to detect | 1061 | * whether the guest actually used the pte (in order to detect |
1074 | * demand paging). | 1062 | * demand paging). |
1075 | */ | 1063 | */ |
1076 | spte = PT_PRESENT_MASK | PT_DIRTY_MASK; | 1064 | spte = shadow_base_present_pte | shadow_dirty_mask; |
1077 | if (!speculative) | 1065 | if (!speculative) |
1078 | pte_access |= PT_ACCESSED_MASK; | 1066 | pte_access |= PT_ACCESSED_MASK; |
1079 | if (!dirty) | 1067 | if (!dirty) |
1080 | pte_access &= ~ACC_WRITE_MASK; | 1068 | pte_access &= ~ACC_WRITE_MASK; |
1081 | if (!(pte_access & ACC_EXEC_MASK)) | 1069 | if (pte_access & ACC_EXEC_MASK) |
1082 | spte |= PT64_NX_MASK; | 1070 | spte |= shadow_x_mask; |
1083 | 1071 | else | |
1084 | spte |= PT_PRESENT_MASK; | 1072 | spte |= shadow_nx_mask; |
1085 | if (pte_access & ACC_USER_MASK) | 1073 | if (pte_access & ACC_USER_MASK) |
1086 | spte |= PT_USER_MASK; | 1074 | spte |= shadow_user_mask; |
1087 | if (largepage) | 1075 | if (largepage) |
1088 | spte |= PT_PAGE_SIZE_MASK; | 1076 | spte |= PT_PAGE_SIZE_MASK; |
1089 | 1077 | ||
@@ -1188,8 +1176,9 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write, | |||
1188 | return -ENOMEM; | 1176 | return -ENOMEM; |
1189 | } | 1177 | } |
1190 | 1178 | ||
1191 | table[index] = __pa(new_table->spt) | PT_PRESENT_MASK | 1179 | table[index] = __pa(new_table->spt) |
1192 | | PT_WRITABLE_MASK | PT_USER_MASK; | 1180 | | PT_PRESENT_MASK | PT_WRITABLE_MASK |
1181 | | shadow_user_mask | shadow_x_mask; | ||
1193 | } | 1182 | } |
1194 | table_addr = table[index] & PT64_BASE_ADDR_MASK; | 1183 | table_addr = table[index] & PT64_BASE_ADDR_MASK; |
1195 | } | 1184 | } |
@@ -1244,7 +1233,6 @@ static void mmu_free_roots(struct kvm_vcpu *vcpu) | |||
1244 | if (!VALID_PAGE(vcpu->arch.mmu.root_hpa)) | 1233 | if (!VALID_PAGE(vcpu->arch.mmu.root_hpa)) |
1245 | return; | 1234 | return; |
1246 | spin_lock(&vcpu->kvm->mmu_lock); | 1235 | spin_lock(&vcpu->kvm->mmu_lock); |
1247 | #ifdef CONFIG_X86_64 | ||
1248 | if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { | 1236 | if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { |
1249 | hpa_t root = vcpu->arch.mmu.root_hpa; | 1237 | hpa_t root = vcpu->arch.mmu.root_hpa; |
1250 | 1238 | ||
@@ -1256,7 +1244,6 @@ static void mmu_free_roots(struct kvm_vcpu *vcpu) | |||
1256 | spin_unlock(&vcpu->kvm->mmu_lock); | 1244 | spin_unlock(&vcpu->kvm->mmu_lock); |
1257 | return; | 1245 | return; |
1258 | } | 1246 | } |
1259 | #endif | ||
1260 | for (i = 0; i < 4; ++i) { | 1247 | for (i = 0; i < 4; ++i) { |
1261 | hpa_t root = vcpu->arch.mmu.pae_root[i]; | 1248 | hpa_t root = vcpu->arch.mmu.pae_root[i]; |
1262 | 1249 | ||
@@ -1282,7 +1269,6 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu) | |||
1282 | 1269 | ||
1283 | root_gfn = vcpu->arch.cr3 >> PAGE_SHIFT; | 1270 | root_gfn = vcpu->arch.cr3 >> PAGE_SHIFT; |
1284 | 1271 | ||
1285 | #ifdef CONFIG_X86_64 | ||
1286 | if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { | 1272 | if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { |
1287 | hpa_t root = vcpu->arch.mmu.root_hpa; | 1273 | hpa_t root = vcpu->arch.mmu.root_hpa; |
1288 | 1274 | ||
@@ -1297,7 +1283,6 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu) | |||
1297 | vcpu->arch.mmu.root_hpa = root; | 1283 | vcpu->arch.mmu.root_hpa = root; |
1298 | return; | 1284 | return; |
1299 | } | 1285 | } |
1300 | #endif | ||
1301 | metaphysical = !is_paging(vcpu); | 1286 | metaphysical = !is_paging(vcpu); |
1302 | if (tdp_enabled) | 1287 | if (tdp_enabled) |
1303 | metaphysical = 1; | 1288 | metaphysical = 1; |
@@ -1377,7 +1362,7 @@ static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t gpa, | |||
1377 | spin_lock(&vcpu->kvm->mmu_lock); | 1362 | spin_lock(&vcpu->kvm->mmu_lock); |
1378 | kvm_mmu_free_some_pages(vcpu); | 1363 | kvm_mmu_free_some_pages(vcpu); |
1379 | r = __direct_map(vcpu, gpa, error_code & PFERR_WRITE_MASK, | 1364 | r = __direct_map(vcpu, gpa, error_code & PFERR_WRITE_MASK, |
1380 | largepage, gfn, pfn, TDP_ROOT_LEVEL); | 1365 | largepage, gfn, pfn, kvm_x86_ops->get_tdp_level()); |
1381 | spin_unlock(&vcpu->kvm->mmu_lock); | 1366 | spin_unlock(&vcpu->kvm->mmu_lock); |
1382 | 1367 | ||
1383 | return r; | 1368 | return r; |
@@ -1484,7 +1469,7 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu) | |||
1484 | context->page_fault = tdp_page_fault; | 1469 | context->page_fault = tdp_page_fault; |
1485 | context->free = nonpaging_free; | 1470 | context->free = nonpaging_free; |
1486 | context->prefetch_page = nonpaging_prefetch_page; | 1471 | context->prefetch_page = nonpaging_prefetch_page; |
1487 | context->shadow_root_level = TDP_ROOT_LEVEL; | 1472 | context->shadow_root_level = kvm_x86_ops->get_tdp_level(); |
1488 | context->root_hpa = INVALID_PAGE; | 1473 | context->root_hpa = INVALID_PAGE; |
1489 | 1474 | ||
1490 | if (!is_paging(vcpu)) { | 1475 | if (!is_paging(vcpu)) { |
@@ -1633,7 +1618,7 @@ static bool last_updated_pte_accessed(struct kvm_vcpu *vcpu) | |||
1633 | { | 1618 | { |
1634 | u64 *spte = vcpu->arch.last_pte_updated; | 1619 | u64 *spte = vcpu->arch.last_pte_updated; |
1635 | 1620 | ||
1636 | return !!(spte && (*spte & PT_ACCESSED_MASK)); | 1621 | return !!(spte && (*spte & shadow_accessed_mask)); |
1637 | } | 1622 | } |
1638 | 1623 | ||
1639 | static void mmu_guess_page_from_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, | 1624 | static void mmu_guess_page_from_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, |
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index e64e9f56a65e..1730757bbc7a 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h | |||
@@ -3,11 +3,38 @@ | |||
3 | 3 | ||
4 | #include <linux/kvm_host.h> | 4 | #include <linux/kvm_host.h> |
5 | 5 | ||
6 | #ifdef CONFIG_X86_64 | 6 | #define PT64_PT_BITS 9 |
7 | #define TDP_ROOT_LEVEL PT64_ROOT_LEVEL | 7 | #define PT64_ENT_PER_PAGE (1 << PT64_PT_BITS) |
8 | #else | 8 | #define PT32_PT_BITS 10 |
9 | #define TDP_ROOT_LEVEL PT32E_ROOT_LEVEL | 9 | #define PT32_ENT_PER_PAGE (1 << PT32_PT_BITS) |
10 | #endif | 10 | |
11 | #define PT_WRITABLE_SHIFT 1 | ||
12 | |||
13 | #define PT_PRESENT_MASK (1ULL << 0) | ||
14 | #define PT_WRITABLE_MASK (1ULL << PT_WRITABLE_SHIFT) | ||
15 | #define PT_USER_MASK (1ULL << 2) | ||
16 | #define PT_PWT_MASK (1ULL << 3) | ||
17 | #define PT_PCD_MASK (1ULL << 4) | ||
18 | #define PT_ACCESSED_MASK (1ULL << 5) | ||
19 | #define PT_DIRTY_MASK (1ULL << 6) | ||
20 | #define PT_PAGE_SIZE_MASK (1ULL << 7) | ||
21 | #define PT_PAT_MASK (1ULL << 7) | ||
22 | #define PT_GLOBAL_MASK (1ULL << 8) | ||
23 | #define PT64_NX_SHIFT 63 | ||
24 | #define PT64_NX_MASK (1ULL << PT64_NX_SHIFT) | ||
25 | |||
26 | #define PT_PAT_SHIFT 7 | ||
27 | #define PT_DIR_PAT_SHIFT 12 | ||
28 | #define PT_DIR_PAT_MASK (1ULL << PT_DIR_PAT_SHIFT) | ||
29 | |||
30 | #define PT32_DIR_PSE36_SIZE 4 | ||
31 | #define PT32_DIR_PSE36_SHIFT 13 | ||
32 | #define PT32_DIR_PSE36_MASK \ | ||
33 | (((1ULL << PT32_DIR_PSE36_SIZE) - 1) << PT32_DIR_PSE36_SHIFT) | ||
34 | |||
35 | #define PT64_ROOT_LEVEL 4 | ||
36 | #define PT32_ROOT_LEVEL 2 | ||
37 | #define PT32E_ROOT_LEVEL 3 | ||
11 | 38 | ||
12 | static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) | 39 | static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) |
13 | { | 40 | { |
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 89e0be2c10d0..ab22615eee89 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -1863,6 +1863,15 @@ static bool svm_cpu_has_accelerated_tpr(void) | |||
1863 | return false; | 1863 | return false; |
1864 | } | 1864 | } |
1865 | 1865 | ||
1866 | static int get_npt_level(void) | ||
1867 | { | ||
1868 | #ifdef CONFIG_X86_64 | ||
1869 | return PT64_ROOT_LEVEL; | ||
1870 | #else | ||
1871 | return PT32E_ROOT_LEVEL; | ||
1872 | #endif | ||
1873 | } | ||
1874 | |||
1866 | static struct kvm_x86_ops svm_x86_ops = { | 1875 | static struct kvm_x86_ops svm_x86_ops = { |
1867 | .cpu_has_kvm_support = has_svm, | 1876 | .cpu_has_kvm_support = has_svm, |
1868 | .disabled_by_bios = is_disabled, | 1877 | .disabled_by_bios = is_disabled, |
@@ -1920,6 +1929,7 @@ static struct kvm_x86_ops svm_x86_ops = { | |||
1920 | .inject_pending_vectors = do_interrupt_requests, | 1929 | .inject_pending_vectors = do_interrupt_requests, |
1921 | 1930 | ||
1922 | .set_tss_addr = svm_set_tss_addr, | 1931 | .set_tss_addr = svm_set_tss_addr, |
1932 | .get_tdp_level = get_npt_level, | ||
1923 | }; | 1933 | }; |
1924 | 1934 | ||
1925 | static int __init svm_init(void) | 1935 | static int __init svm_init(void) |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 8e5d6645b90d..bfe4db11989c 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -42,6 +42,9 @@ module_param(enable_vpid, bool, 0); | |||
42 | static int flexpriority_enabled = 1; | 42 | static int flexpriority_enabled = 1; |
43 | module_param(flexpriority_enabled, bool, 0); | 43 | module_param(flexpriority_enabled, bool, 0); |
44 | 44 | ||
45 | static int enable_ept = 1; | ||
46 | module_param(enable_ept, bool, 0); | ||
47 | |||
45 | struct vmcs { | 48 | struct vmcs { |
46 | u32 revision_id; | 49 | u32 revision_id; |
47 | u32 abort; | 50 | u32 abort; |
@@ -84,7 +87,7 @@ static inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu) | |||
84 | return container_of(vcpu, struct vcpu_vmx, vcpu); | 87 | return container_of(vcpu, struct vcpu_vmx, vcpu); |
85 | } | 88 | } |
86 | 89 | ||
87 | static int init_rmode_tss(struct kvm *kvm); | 90 | static int init_rmode(struct kvm *kvm); |
88 | 91 | ||
89 | static DEFINE_PER_CPU(struct vmcs *, vmxarea); | 92 | static DEFINE_PER_CPU(struct vmcs *, vmxarea); |
90 | static DEFINE_PER_CPU(struct vmcs *, current_vmcs); | 93 | static DEFINE_PER_CPU(struct vmcs *, current_vmcs); |
@@ -107,6 +110,11 @@ static struct vmcs_config { | |||
107 | u32 vmentry_ctrl; | 110 | u32 vmentry_ctrl; |
108 | } vmcs_config; | 111 | } vmcs_config; |
109 | 112 | ||
113 | struct vmx_capability { | ||
114 | u32 ept; | ||
115 | u32 vpid; | ||
116 | } vmx_capability; | ||
117 | |||
110 | #define VMX_SEGMENT_FIELD(seg) \ | 118 | #define VMX_SEGMENT_FIELD(seg) \ |
111 | [VCPU_SREG_##seg] = { \ | 119 | [VCPU_SREG_##seg] = { \ |
112 | .selector = GUEST_##seg##_SELECTOR, \ | 120 | .selector = GUEST_##seg##_SELECTOR, \ |
@@ -214,6 +222,32 @@ static inline bool cpu_has_vmx_virtualize_apic_accesses(void) | |||
214 | SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES); | 222 | SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES); |
215 | } | 223 | } |
216 | 224 | ||
225 | static inline int cpu_has_vmx_invept_individual_addr(void) | ||
226 | { | ||
227 | return (!!(vmx_capability.ept & VMX_EPT_EXTENT_INDIVIDUAL_BIT)); | ||
228 | } | ||
229 | |||
230 | static inline int cpu_has_vmx_invept_context(void) | ||
231 | { | ||
232 | return (!!(vmx_capability.ept & VMX_EPT_EXTENT_CONTEXT_BIT)); | ||
233 | } | ||
234 | |||
235 | static inline int cpu_has_vmx_invept_global(void) | ||
236 | { | ||
237 | return (!!(vmx_capability.ept & VMX_EPT_EXTENT_GLOBAL_BIT)); | ||
238 | } | ||
239 | |||
240 | static inline int cpu_has_vmx_ept(void) | ||
241 | { | ||
242 | return (vmcs_config.cpu_based_2nd_exec_ctrl & | ||
243 | SECONDARY_EXEC_ENABLE_EPT); | ||
244 | } | ||
245 | |||
246 | static inline int vm_need_ept(void) | ||
247 | { | ||
248 | return (cpu_has_vmx_ept() && enable_ept); | ||
249 | } | ||
250 | |||
217 | static inline int vm_need_virtualize_apic_accesses(struct kvm *kvm) | 251 | static inline int vm_need_virtualize_apic_accesses(struct kvm *kvm) |
218 | { | 252 | { |
219 | return ((cpu_has_vmx_virtualize_apic_accesses()) && | 253 | return ((cpu_has_vmx_virtualize_apic_accesses()) && |
@@ -250,6 +284,18 @@ static inline void __invvpid(int ext, u16 vpid, gva_t gva) | |||
250 | : : "a"(&operand), "c"(ext) : "cc", "memory"); | 284 | : : "a"(&operand), "c"(ext) : "cc", "memory"); |
251 | } | 285 | } |
252 | 286 | ||
287 | static inline void __invept(int ext, u64 eptp, gpa_t gpa) | ||
288 | { | ||
289 | struct { | ||
290 | u64 eptp, gpa; | ||
291 | } operand = {eptp, gpa}; | ||
292 | |||
293 | asm volatile (ASM_VMX_INVEPT | ||
294 | /* CF==1 or ZF==1 --> rc = -1 */ | ||
295 | "; ja 1f ; ud2 ; 1:\n" | ||
296 | : : "a" (&operand), "c" (ext) : "cc", "memory"); | ||
297 | } | ||
298 | |||
253 | static struct kvm_msr_entry *find_msr_entry(struct vcpu_vmx *vmx, u32 msr) | 299 | static struct kvm_msr_entry *find_msr_entry(struct vcpu_vmx *vmx, u32 msr) |
254 | { | 300 | { |
255 | int i; | 301 | int i; |
@@ -301,6 +347,33 @@ static inline void vpid_sync_vcpu_all(struct vcpu_vmx *vmx) | |||
301 | __invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vmx->vpid, 0); | 347 | __invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vmx->vpid, 0); |
302 | } | 348 | } |
303 | 349 | ||
350 | static inline void ept_sync_global(void) | ||
351 | { | ||
352 | if (cpu_has_vmx_invept_global()) | ||
353 | __invept(VMX_EPT_EXTENT_GLOBAL, 0, 0); | ||
354 | } | ||
355 | |||
356 | static inline void ept_sync_context(u64 eptp) | ||
357 | { | ||
358 | if (vm_need_ept()) { | ||
359 | if (cpu_has_vmx_invept_context()) | ||
360 | __invept(VMX_EPT_EXTENT_CONTEXT, eptp, 0); | ||
361 | else | ||
362 | ept_sync_global(); | ||
363 | } | ||
364 | } | ||
365 | |||
366 | static inline void ept_sync_individual_addr(u64 eptp, gpa_t gpa) | ||
367 | { | ||
368 | if (vm_need_ept()) { | ||
369 | if (cpu_has_vmx_invept_individual_addr()) | ||
370 | __invept(VMX_EPT_EXTENT_INDIVIDUAL_ADDR, | ||
371 | eptp, gpa); | ||
372 | else | ||
373 | ept_sync_context(eptp); | ||
374 | } | ||
375 | } | ||
376 | |||
304 | static unsigned long vmcs_readl(unsigned long field) | 377 | static unsigned long vmcs_readl(unsigned long field) |
305 | { | 378 | { |
306 | unsigned long value; | 379 | unsigned long value; |
@@ -388,6 +461,8 @@ static void update_exception_bitmap(struct kvm_vcpu *vcpu) | |||
388 | eb |= 1u << 1; | 461 | eb |= 1u << 1; |
389 | if (vcpu->arch.rmode.active) | 462 | if (vcpu->arch.rmode.active) |
390 | eb = ~0; | 463 | eb = ~0; |
464 | if (vm_need_ept()) | ||
465 | eb &= ~(1u << PF_VECTOR); /* bypass_guest_pf = 0 */ | ||
391 | vmcs_write32(EXCEPTION_BITMAP, eb); | 466 | vmcs_write32(EXCEPTION_BITMAP, eb); |
392 | } | 467 | } |
393 | 468 | ||
@@ -985,7 +1060,7 @@ static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, | |||
985 | static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf) | 1060 | static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf) |
986 | { | 1061 | { |
987 | u32 vmx_msr_low, vmx_msr_high; | 1062 | u32 vmx_msr_low, vmx_msr_high; |
988 | u32 min, opt; | 1063 | u32 min, opt, min2, opt2; |
989 | u32 _pin_based_exec_control = 0; | 1064 | u32 _pin_based_exec_control = 0; |
990 | u32 _cpu_based_exec_control = 0; | 1065 | u32 _cpu_based_exec_control = 0; |
991 | u32 _cpu_based_2nd_exec_control = 0; | 1066 | u32 _cpu_based_2nd_exec_control = 0; |
@@ -1003,6 +1078,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf) | |||
1003 | CPU_BASED_CR8_LOAD_EXITING | | 1078 | CPU_BASED_CR8_LOAD_EXITING | |
1004 | CPU_BASED_CR8_STORE_EXITING | | 1079 | CPU_BASED_CR8_STORE_EXITING | |
1005 | #endif | 1080 | #endif |
1081 | CPU_BASED_CR3_LOAD_EXITING | | ||
1082 | CPU_BASED_CR3_STORE_EXITING | | ||
1006 | CPU_BASED_USE_IO_BITMAPS | | 1083 | CPU_BASED_USE_IO_BITMAPS | |
1007 | CPU_BASED_MOV_DR_EXITING | | 1084 | CPU_BASED_MOV_DR_EXITING | |
1008 | CPU_BASED_USE_TSC_OFFSETING; | 1085 | CPU_BASED_USE_TSC_OFFSETING; |
@@ -1018,11 +1095,13 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf) | |||
1018 | ~CPU_BASED_CR8_STORE_EXITING; | 1095 | ~CPU_BASED_CR8_STORE_EXITING; |
1019 | #endif | 1096 | #endif |
1020 | if (_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) { | 1097 | if (_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) { |
1021 | min = 0; | 1098 | min2 = 0; |
1022 | opt = SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | | 1099 | opt2 = SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | |
1023 | SECONDARY_EXEC_WBINVD_EXITING | | 1100 | SECONDARY_EXEC_WBINVD_EXITING | |
1024 | SECONDARY_EXEC_ENABLE_VPID; | 1101 | SECONDARY_EXEC_ENABLE_VPID | |
1025 | if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PROCBASED_CTLS2, | 1102 | SECONDARY_EXEC_ENABLE_EPT; |
1103 | if (adjust_vmx_controls(min2, opt2, | ||
1104 | MSR_IA32_VMX_PROCBASED_CTLS2, | ||
1026 | &_cpu_based_2nd_exec_control) < 0) | 1105 | &_cpu_based_2nd_exec_control) < 0) |
1027 | return -EIO; | 1106 | return -EIO; |
1028 | } | 1107 | } |
@@ -1031,6 +1110,16 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf) | |||
1031 | SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) | 1110 | SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) |
1032 | _cpu_based_exec_control &= ~CPU_BASED_TPR_SHADOW; | 1111 | _cpu_based_exec_control &= ~CPU_BASED_TPR_SHADOW; |
1033 | #endif | 1112 | #endif |
1113 | if (_cpu_based_2nd_exec_control & SECONDARY_EXEC_ENABLE_EPT) { | ||
1114 | /* CR3 accesses don't need to cause VM Exits when EPT enabled */ | ||
1115 | min &= ~(CPU_BASED_CR3_LOAD_EXITING | | ||
1116 | CPU_BASED_CR3_STORE_EXITING); | ||
1117 | if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PROCBASED_CTLS, | ||
1118 | &_cpu_based_exec_control) < 0) | ||
1119 | return -EIO; | ||
1120 | rdmsr(MSR_IA32_VMX_EPT_VPID_CAP, | ||
1121 | vmx_capability.ept, vmx_capability.vpid); | ||
1122 | } | ||
1034 | 1123 | ||
1035 | min = 0; | 1124 | min = 0; |
1036 | #ifdef CONFIG_X86_64 | 1125 | #ifdef CONFIG_X86_64 |
@@ -1256,7 +1345,7 @@ static void enter_rmode(struct kvm_vcpu *vcpu) | |||
1256 | fix_rmode_seg(VCPU_SREG_FS, &vcpu->arch.rmode.fs); | 1345 | fix_rmode_seg(VCPU_SREG_FS, &vcpu->arch.rmode.fs); |
1257 | 1346 | ||
1258 | kvm_mmu_reset_context(vcpu); | 1347 | kvm_mmu_reset_context(vcpu); |
1259 | init_rmode_tss(vcpu->kvm); | 1348 | init_rmode(vcpu->kvm); |
1260 | } | 1349 | } |
1261 | 1350 | ||
1262 | #ifdef CONFIG_X86_64 | 1351 | #ifdef CONFIG_X86_64 |
@@ -1304,8 +1393,64 @@ static void vmx_decache_cr4_guest_bits(struct kvm_vcpu *vcpu) | |||
1304 | vcpu->arch.cr4 |= vmcs_readl(GUEST_CR4) & ~KVM_GUEST_CR4_MASK; | 1393 | vcpu->arch.cr4 |= vmcs_readl(GUEST_CR4) & ~KVM_GUEST_CR4_MASK; |
1305 | } | 1394 | } |
1306 | 1395 | ||
1396 | static void ept_load_pdptrs(struct kvm_vcpu *vcpu) | ||
1397 | { | ||
1398 | if (is_paging(vcpu) && is_pae(vcpu) && !is_long_mode(vcpu)) { | ||
1399 | if (!load_pdptrs(vcpu, vcpu->arch.cr3)) { | ||
1400 | printk(KERN_ERR "EPT: Fail to load pdptrs!\n"); | ||
1401 | return; | ||
1402 | } | ||
1403 | vmcs_write64(GUEST_PDPTR0, vcpu->arch.pdptrs[0]); | ||
1404 | vmcs_write64(GUEST_PDPTR1, vcpu->arch.pdptrs[1]); | ||
1405 | vmcs_write64(GUEST_PDPTR2, vcpu->arch.pdptrs[2]); | ||
1406 | vmcs_write64(GUEST_PDPTR3, vcpu->arch.pdptrs[3]); | ||
1407 | } | ||
1408 | } | ||
1409 | |||
1410 | static void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4); | ||
1411 | |||
1412 | static void ept_update_paging_mode_cr0(unsigned long *hw_cr0, | ||
1413 | unsigned long cr0, | ||
1414 | struct kvm_vcpu *vcpu) | ||
1415 | { | ||
1416 | if (!(cr0 & X86_CR0_PG)) { | ||
1417 | /* From paging/starting to nonpaging */ | ||
1418 | vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, | ||
1419 | vmcs_config.cpu_based_exec_ctrl | | ||
1420 | (CPU_BASED_CR3_LOAD_EXITING | | ||
1421 | CPU_BASED_CR3_STORE_EXITING)); | ||
1422 | vcpu->arch.cr0 = cr0; | ||
1423 | vmx_set_cr4(vcpu, vcpu->arch.cr4); | ||
1424 | *hw_cr0 |= X86_CR0_PE | X86_CR0_PG; | ||
1425 | *hw_cr0 &= ~X86_CR0_WP; | ||
1426 | } else if (!is_paging(vcpu)) { | ||
1427 | /* From nonpaging to paging */ | ||
1428 | vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, | ||
1429 | vmcs_config.cpu_based_exec_ctrl & | ||
1430 | ~(CPU_BASED_CR3_LOAD_EXITING | | ||
1431 | CPU_BASED_CR3_STORE_EXITING)); | ||
1432 | vcpu->arch.cr0 = cr0; | ||
1433 | vmx_set_cr4(vcpu, vcpu->arch.cr4); | ||
1434 | if (!(vcpu->arch.cr0 & X86_CR0_WP)) | ||
1435 | *hw_cr0 &= ~X86_CR0_WP; | ||
1436 | } | ||
1437 | } | ||
1438 | |||
1439 | static void ept_update_paging_mode_cr4(unsigned long *hw_cr4, | ||
1440 | struct kvm_vcpu *vcpu) | ||
1441 | { | ||
1442 | if (!is_paging(vcpu)) { | ||
1443 | *hw_cr4 &= ~X86_CR4_PAE; | ||
1444 | *hw_cr4 |= X86_CR4_PSE; | ||
1445 | } else if (!(vcpu->arch.cr4 & X86_CR4_PAE)) | ||
1446 | *hw_cr4 &= ~X86_CR4_PAE; | ||
1447 | } | ||
1448 | |||
1307 | static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) | 1449 | static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) |
1308 | { | 1450 | { |
1451 | unsigned long hw_cr0 = (cr0 & ~KVM_GUEST_CR0_MASK) | | ||
1452 | KVM_VM_CR0_ALWAYS_ON; | ||
1453 | |||
1309 | vmx_fpu_deactivate(vcpu); | 1454 | vmx_fpu_deactivate(vcpu); |
1310 | 1455 | ||
1311 | if (vcpu->arch.rmode.active && (cr0 & X86_CR0_PE)) | 1456 | if (vcpu->arch.rmode.active && (cr0 & X86_CR0_PE)) |
@@ -1323,29 +1468,61 @@ static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) | |||
1323 | } | 1468 | } |
1324 | #endif | 1469 | #endif |
1325 | 1470 | ||
1471 | if (vm_need_ept()) | ||
1472 | ept_update_paging_mode_cr0(&hw_cr0, cr0, vcpu); | ||
1473 | |||
1326 | vmcs_writel(CR0_READ_SHADOW, cr0); | 1474 | vmcs_writel(CR0_READ_SHADOW, cr0); |
1327 | vmcs_writel(GUEST_CR0, | 1475 | vmcs_writel(GUEST_CR0, hw_cr0); |
1328 | (cr0 & ~KVM_GUEST_CR0_MASK) | KVM_VM_CR0_ALWAYS_ON); | ||
1329 | vcpu->arch.cr0 = cr0; | 1476 | vcpu->arch.cr0 = cr0; |
1330 | 1477 | ||
1331 | if (!(cr0 & X86_CR0_TS) || !(cr0 & X86_CR0_PE)) | 1478 | if (!(cr0 & X86_CR0_TS) || !(cr0 & X86_CR0_PE)) |
1332 | vmx_fpu_activate(vcpu); | 1479 | vmx_fpu_activate(vcpu); |
1333 | } | 1480 | } |
1334 | 1481 | ||
1482 | static u64 construct_eptp(unsigned long root_hpa) | ||
1483 | { | ||
1484 | u64 eptp; | ||
1485 | |||
1486 | /* TODO write the value reading from MSR */ | ||
1487 | eptp = VMX_EPT_DEFAULT_MT | | ||
1488 | VMX_EPT_DEFAULT_GAW << VMX_EPT_GAW_EPTP_SHIFT; | ||
1489 | eptp |= (root_hpa & PAGE_MASK); | ||
1490 | |||
1491 | return eptp; | ||
1492 | } | ||
1493 | |||
1335 | static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) | 1494 | static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) |
1336 | { | 1495 | { |
1496 | unsigned long guest_cr3; | ||
1497 | u64 eptp; | ||
1498 | |||
1499 | guest_cr3 = cr3; | ||
1500 | if (vm_need_ept()) { | ||
1501 | eptp = construct_eptp(cr3); | ||
1502 | vmcs_write64(EPT_POINTER, eptp); | ||
1503 | ept_sync_context(eptp); | ||
1504 | ept_load_pdptrs(vcpu); | ||
1505 | guest_cr3 = is_paging(vcpu) ? vcpu->arch.cr3 : | ||
1506 | VMX_EPT_IDENTITY_PAGETABLE_ADDR; | ||
1507 | } | ||
1508 | |||
1337 | vmx_flush_tlb(vcpu); | 1509 | vmx_flush_tlb(vcpu); |
1338 | vmcs_writel(GUEST_CR3, cr3); | 1510 | vmcs_writel(GUEST_CR3, guest_cr3); |
1339 | if (vcpu->arch.cr0 & X86_CR0_PE) | 1511 | if (vcpu->arch.cr0 & X86_CR0_PE) |
1340 | vmx_fpu_deactivate(vcpu); | 1512 | vmx_fpu_deactivate(vcpu); |
1341 | } | 1513 | } |
1342 | 1514 | ||
1343 | static void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) | 1515 | static void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) |
1344 | { | 1516 | { |
1345 | vmcs_writel(CR4_READ_SHADOW, cr4); | 1517 | unsigned long hw_cr4 = cr4 | (vcpu->arch.rmode.active ? |
1346 | vmcs_writel(GUEST_CR4, cr4 | (vcpu->arch.rmode.active ? | 1518 | KVM_RMODE_VM_CR4_ALWAYS_ON : KVM_PMODE_VM_CR4_ALWAYS_ON); |
1347 | KVM_RMODE_VM_CR4_ALWAYS_ON : KVM_PMODE_VM_CR4_ALWAYS_ON)); | 1519 | |
1348 | vcpu->arch.cr4 = cr4; | 1520 | vcpu->arch.cr4 = cr4; |
1521 | if (vm_need_ept()) | ||
1522 | ept_update_paging_mode_cr4(&hw_cr4, vcpu); | ||
1523 | |||
1524 | vmcs_writel(CR4_READ_SHADOW, cr4); | ||
1525 | vmcs_writel(GUEST_CR4, hw_cr4); | ||
1349 | } | 1526 | } |
1350 | 1527 | ||
1351 | static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer) | 1528 | static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer) |
@@ -1530,6 +1707,41 @@ out: | |||
1530 | return ret; | 1707 | return ret; |
1531 | } | 1708 | } |
1532 | 1709 | ||
1710 | static int init_rmode_identity_map(struct kvm *kvm) | ||
1711 | { | ||
1712 | int i, r, ret; | ||
1713 | pfn_t identity_map_pfn; | ||
1714 | u32 tmp; | ||
1715 | |||
1716 | if (!vm_need_ept()) | ||
1717 | return 1; | ||
1718 | if (unlikely(!kvm->arch.ept_identity_pagetable)) { | ||
1719 | printk(KERN_ERR "EPT: identity-mapping pagetable " | ||
1720 | "haven't been allocated!\n"); | ||
1721 | return 0; | ||
1722 | } | ||
1723 | if (likely(kvm->arch.ept_identity_pagetable_done)) | ||
1724 | return 1; | ||
1725 | ret = 0; | ||
1726 | identity_map_pfn = VMX_EPT_IDENTITY_PAGETABLE_ADDR >> PAGE_SHIFT; | ||
1727 | r = kvm_clear_guest_page(kvm, identity_map_pfn, 0, PAGE_SIZE); | ||
1728 | if (r < 0) | ||
1729 | goto out; | ||
1730 | /* Set up identity-mapping pagetable for EPT in real mode */ | ||
1731 | for (i = 0; i < PT32_ENT_PER_PAGE; i++) { | ||
1732 | tmp = (i << 22) + (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | | ||
1733 | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_PSE); | ||
1734 | r = kvm_write_guest_page(kvm, identity_map_pfn, | ||
1735 | &tmp, i * sizeof(tmp), sizeof(tmp)); | ||
1736 | if (r < 0) | ||
1737 | goto out; | ||
1738 | } | ||
1739 | kvm->arch.ept_identity_pagetable_done = true; | ||
1740 | ret = 1; | ||
1741 | out: | ||
1742 | return ret; | ||
1743 | } | ||
1744 | |||
1533 | static void seg_setup(int seg) | 1745 | static void seg_setup(int seg) |
1534 | { | 1746 | { |
1535 | struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; | 1747 | struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; |
@@ -1564,6 +1776,31 @@ out: | |||
1564 | return r; | 1776 | return r; |
1565 | } | 1777 | } |
1566 | 1778 | ||
1779 | static int alloc_identity_pagetable(struct kvm *kvm) | ||
1780 | { | ||
1781 | struct kvm_userspace_memory_region kvm_userspace_mem; | ||
1782 | int r = 0; | ||
1783 | |||
1784 | down_write(&kvm->slots_lock); | ||
1785 | if (kvm->arch.ept_identity_pagetable) | ||
1786 | goto out; | ||
1787 | kvm_userspace_mem.slot = IDENTITY_PAGETABLE_PRIVATE_MEMSLOT; | ||
1788 | kvm_userspace_mem.flags = 0; | ||
1789 | kvm_userspace_mem.guest_phys_addr = VMX_EPT_IDENTITY_PAGETABLE_ADDR; | ||
1790 | kvm_userspace_mem.memory_size = PAGE_SIZE; | ||
1791 | r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0); | ||
1792 | if (r) | ||
1793 | goto out; | ||
1794 | |||
1795 | down_read(¤t->mm->mmap_sem); | ||
1796 | kvm->arch.ept_identity_pagetable = gfn_to_page(kvm, | ||
1797 | VMX_EPT_IDENTITY_PAGETABLE_ADDR >> PAGE_SHIFT); | ||
1798 | up_read(¤t->mm->mmap_sem); | ||
1799 | out: | ||
1800 | up_write(&kvm->slots_lock); | ||
1801 | return r; | ||
1802 | } | ||
1803 | |||
1567 | static void allocate_vpid(struct vcpu_vmx *vmx) | 1804 | static void allocate_vpid(struct vcpu_vmx *vmx) |
1568 | { | 1805 | { |
1569 | int vpid; | 1806 | int vpid; |
@@ -1638,6 +1875,9 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx) | |||
1638 | CPU_BASED_CR8_LOAD_EXITING; | 1875 | CPU_BASED_CR8_LOAD_EXITING; |
1639 | #endif | 1876 | #endif |
1640 | } | 1877 | } |
1878 | if (!vm_need_ept()) | ||
1879 | exec_control |= CPU_BASED_CR3_STORE_EXITING | | ||
1880 | CPU_BASED_CR3_LOAD_EXITING; | ||
1641 | vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, exec_control); | 1881 | vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, exec_control); |
1642 | 1882 | ||
1643 | if (cpu_has_secondary_exec_ctrls()) { | 1883 | if (cpu_has_secondary_exec_ctrls()) { |
@@ -1647,6 +1887,8 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx) | |||
1647 | ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; | 1887 | ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; |
1648 | if (vmx->vpid == 0) | 1888 | if (vmx->vpid == 0) |
1649 | exec_control &= ~SECONDARY_EXEC_ENABLE_VPID; | 1889 | exec_control &= ~SECONDARY_EXEC_ENABLE_VPID; |
1890 | if (!vm_need_ept()) | ||
1891 | exec_control &= ~SECONDARY_EXEC_ENABLE_EPT; | ||
1650 | vmcs_write32(SECONDARY_VM_EXEC_CONTROL, exec_control); | 1892 | vmcs_write32(SECONDARY_VM_EXEC_CONTROL, exec_control); |
1651 | } | 1893 | } |
1652 | 1894 | ||
@@ -1722,6 +1964,15 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx) | |||
1722 | return 0; | 1964 | return 0; |
1723 | } | 1965 | } |
1724 | 1966 | ||
1967 | static int init_rmode(struct kvm *kvm) | ||
1968 | { | ||
1969 | if (!init_rmode_tss(kvm)) | ||
1970 | return 0; | ||
1971 | if (!init_rmode_identity_map(kvm)) | ||
1972 | return 0; | ||
1973 | return 1; | ||
1974 | } | ||
1975 | |||
1725 | static int vmx_vcpu_reset(struct kvm_vcpu *vcpu) | 1976 | static int vmx_vcpu_reset(struct kvm_vcpu *vcpu) |
1726 | { | 1977 | { |
1727 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 1978 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
@@ -1729,7 +1980,7 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu) | |||
1729 | int ret; | 1980 | int ret; |
1730 | 1981 | ||
1731 | down_read(&vcpu->kvm->slots_lock); | 1982 | down_read(&vcpu->kvm->slots_lock); |
1732 | if (!init_rmode_tss(vmx->vcpu.kvm)) { | 1983 | if (!init_rmode(vmx->vcpu.kvm)) { |
1733 | ret = -ENOMEM; | 1984 | ret = -ENOMEM; |
1734 | goto out; | 1985 | goto out; |
1735 | } | 1986 | } |
@@ -1994,6 +2245,9 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
1994 | if (intr_info & INTR_INFO_DELIVER_CODE_MASK) | 2245 | if (intr_info & INTR_INFO_DELIVER_CODE_MASK) |
1995 | error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); | 2246 | error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); |
1996 | if (is_page_fault(intr_info)) { | 2247 | if (is_page_fault(intr_info)) { |
2248 | /* EPT won't cause page fault directly */ | ||
2249 | if (vm_need_ept()) | ||
2250 | BUG(); | ||
1997 | cr2 = vmcs_readl(EXIT_QUALIFICATION); | 2251 | cr2 = vmcs_readl(EXIT_QUALIFICATION); |
1998 | KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2, | 2252 | KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2, |
1999 | (u32)((u64)cr2 >> 32), handler); | 2253 | (u32)((u64)cr2 >> 32), handler); |
@@ -2323,6 +2577,64 @@ static int handle_task_switch(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
2323 | return kvm_task_switch(vcpu, tss_selector, reason); | 2577 | return kvm_task_switch(vcpu, tss_selector, reason); |
2324 | } | 2578 | } |
2325 | 2579 | ||
2580 | static int handle_ept_violation(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | ||
2581 | { | ||
2582 | u64 exit_qualification; | ||
2583 | enum emulation_result er; | ||
2584 | gpa_t gpa; | ||
2585 | unsigned long hva; | ||
2586 | int gla_validity; | ||
2587 | int r; | ||
2588 | |||
2589 | exit_qualification = vmcs_read64(EXIT_QUALIFICATION); | ||
2590 | |||
2591 | if (exit_qualification & (1 << 6)) { | ||
2592 | printk(KERN_ERR "EPT: GPA exceeds GAW!\n"); | ||
2593 | return -ENOTSUPP; | ||
2594 | } | ||
2595 | |||
2596 | gla_validity = (exit_qualification >> 7) & 0x3; | ||
2597 | if (gla_validity != 0x3 && gla_validity != 0x1 && gla_validity != 0) { | ||
2598 | printk(KERN_ERR "EPT: Handling EPT violation failed!\n"); | ||
2599 | printk(KERN_ERR "EPT: GPA: 0x%lx, GVA: 0x%lx\n", | ||
2600 | (long unsigned int)vmcs_read64(GUEST_PHYSICAL_ADDRESS), | ||
2601 | (long unsigned int)vmcs_read64(GUEST_LINEAR_ADDRESS)); | ||
2602 | printk(KERN_ERR "EPT: Exit qualification is 0x%lx\n", | ||
2603 | (long unsigned int)exit_qualification); | ||
2604 | kvm_run->exit_reason = KVM_EXIT_UNKNOWN; | ||
2605 | kvm_run->hw.hardware_exit_reason = 0; | ||
2606 | return -ENOTSUPP; | ||
2607 | } | ||
2608 | |||
2609 | gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS); | ||
2610 | hva = gfn_to_hva(vcpu->kvm, gpa >> PAGE_SHIFT); | ||
2611 | if (!kvm_is_error_hva(hva)) { | ||
2612 | r = kvm_mmu_page_fault(vcpu, gpa & PAGE_MASK, 0); | ||
2613 | if (r < 0) { | ||
2614 | printk(KERN_ERR "EPT: Not enough memory!\n"); | ||
2615 | return -ENOMEM; | ||
2616 | } | ||
2617 | return 1; | ||
2618 | } else { | ||
2619 | /* must be MMIO */ | ||
2620 | er = emulate_instruction(vcpu, kvm_run, 0, 0, 0); | ||
2621 | |||
2622 | if (er == EMULATE_FAIL) { | ||
2623 | printk(KERN_ERR | ||
2624 | "EPT: Fail to handle EPT violation vmexit!er is %d\n", | ||
2625 | er); | ||
2626 | printk(KERN_ERR "EPT: GPA: 0x%lx, GVA: 0x%lx\n", | ||
2627 | (long unsigned int)vmcs_read64(GUEST_PHYSICAL_ADDRESS), | ||
2628 | (long unsigned int)vmcs_read64(GUEST_LINEAR_ADDRESS)); | ||
2629 | printk(KERN_ERR "EPT: Exit qualification is 0x%lx\n", | ||
2630 | (long unsigned int)exit_qualification); | ||
2631 | return -ENOTSUPP; | ||
2632 | } else if (er == EMULATE_DO_MMIO) | ||
2633 | return 0; | ||
2634 | } | ||
2635 | return 1; | ||
2636 | } | ||
2637 | |||
2326 | /* | 2638 | /* |
2327 | * The exit handlers return 1 if the exit was handled fully and guest execution | 2639 | * The exit handlers return 1 if the exit was handled fully and guest execution |
2328 | * may resume. Otherwise they set the kvm_run parameter to indicate what needs | 2640 | * may resume. Otherwise they set the kvm_run parameter to indicate what needs |
@@ -2346,6 +2658,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu, | |||
2346 | [EXIT_REASON_APIC_ACCESS] = handle_apic_access, | 2658 | [EXIT_REASON_APIC_ACCESS] = handle_apic_access, |
2347 | [EXIT_REASON_WBINVD] = handle_wbinvd, | 2659 | [EXIT_REASON_WBINVD] = handle_wbinvd, |
2348 | [EXIT_REASON_TASK_SWITCH] = handle_task_switch, | 2660 | [EXIT_REASON_TASK_SWITCH] = handle_task_switch, |
2661 | [EXIT_REASON_EPT_VIOLATION] = handle_ept_violation, | ||
2349 | }; | 2662 | }; |
2350 | 2663 | ||
2351 | static const int kvm_vmx_max_exit_handlers = | 2664 | static const int kvm_vmx_max_exit_handlers = |
@@ -2364,6 +2677,13 @@ static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
2364 | KVMTRACE_3D(VMEXIT, vcpu, exit_reason, (u32)vmcs_readl(GUEST_RIP), | 2677 | KVMTRACE_3D(VMEXIT, vcpu, exit_reason, (u32)vmcs_readl(GUEST_RIP), |
2365 | (u32)((u64)vmcs_readl(GUEST_RIP) >> 32), entryexit); | 2678 | (u32)((u64)vmcs_readl(GUEST_RIP) >> 32), entryexit); |
2366 | 2679 | ||
2680 | /* Access CR3 don't cause VMExit in paging mode, so we need | ||
2681 | * to sync with guest real CR3. */ | ||
2682 | if (vm_need_ept() && is_paging(vcpu)) { | ||
2683 | vcpu->arch.cr3 = vmcs_readl(GUEST_CR3); | ||
2684 | ept_load_pdptrs(vcpu); | ||
2685 | } | ||
2686 | |||
2367 | if (unlikely(vmx->fail)) { | 2687 | if (unlikely(vmx->fail)) { |
2368 | kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY; | 2688 | kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY; |
2369 | kvm_run->fail_entry.hardware_entry_failure_reason | 2689 | kvm_run->fail_entry.hardware_entry_failure_reason |
@@ -2372,7 +2692,8 @@ static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
2372 | } | 2692 | } |
2373 | 2693 | ||
2374 | if ((vectoring_info & VECTORING_INFO_VALID_MASK) && | 2694 | if ((vectoring_info & VECTORING_INFO_VALID_MASK) && |
2375 | exit_reason != EXIT_REASON_EXCEPTION_NMI) | 2695 | (exit_reason != EXIT_REASON_EXCEPTION_NMI && |
2696 | exit_reason != EXIT_REASON_EPT_VIOLATION)) | ||
2376 | printk(KERN_WARNING "%s: unexpected, valid vectoring info and " | 2697 | printk(KERN_WARNING "%s: unexpected, valid vectoring info and " |
2377 | "exit reason is 0x%x\n", __func__, exit_reason); | 2698 | "exit reason is 0x%x\n", __func__, exit_reason); |
2378 | if (exit_reason < kvm_vmx_max_exit_handlers | 2699 | if (exit_reason < kvm_vmx_max_exit_handlers |
@@ -2674,6 +2995,15 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) | |||
2674 | return ERR_PTR(-ENOMEM); | 2995 | return ERR_PTR(-ENOMEM); |
2675 | 2996 | ||
2676 | allocate_vpid(vmx); | 2997 | allocate_vpid(vmx); |
2998 | if (id == 0 && vm_need_ept()) { | ||
2999 | kvm_mmu_set_base_ptes(VMX_EPT_READABLE_MASK | | ||
3000 | VMX_EPT_WRITABLE_MASK | | ||
3001 | VMX_EPT_DEFAULT_MT << VMX_EPT_MT_EPTE_SHIFT); | ||
3002 | kvm_mmu_set_mask_ptes(0ull, VMX_EPT_FAKE_ACCESSED_MASK, | ||
3003 | VMX_EPT_FAKE_DIRTY_MASK, 0ull, | ||
3004 | VMX_EPT_EXECUTABLE_MASK); | ||
3005 | kvm_enable_tdp(); | ||
3006 | } | ||
2677 | 3007 | ||
2678 | err = kvm_vcpu_init(&vmx->vcpu, kvm, id); | 3008 | err = kvm_vcpu_init(&vmx->vcpu, kvm, id); |
2679 | if (err) | 3009 | if (err) |
@@ -2706,6 +3036,10 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) | |||
2706 | if (alloc_apic_access_page(kvm) != 0) | 3036 | if (alloc_apic_access_page(kvm) != 0) |
2707 | goto free_vmcs; | 3037 | goto free_vmcs; |
2708 | 3038 | ||
3039 | if (vm_need_ept()) | ||
3040 | if (alloc_identity_pagetable(kvm) != 0) | ||
3041 | goto free_vmcs; | ||
3042 | |||
2709 | return &vmx->vcpu; | 3043 | return &vmx->vcpu; |
2710 | 3044 | ||
2711 | free_vmcs: | 3045 | free_vmcs: |
@@ -2735,6 +3069,11 @@ static void __init vmx_check_processor_compat(void *rtn) | |||
2735 | } | 3069 | } |
2736 | } | 3070 | } |
2737 | 3071 | ||
3072 | static int get_ept_level(void) | ||
3073 | { | ||
3074 | return VMX_EPT_DEFAULT_GAW + 1; | ||
3075 | } | ||
3076 | |||
2738 | static struct kvm_x86_ops vmx_x86_ops = { | 3077 | static struct kvm_x86_ops vmx_x86_ops = { |
2739 | .cpu_has_kvm_support = cpu_has_kvm_support, | 3078 | .cpu_has_kvm_support = cpu_has_kvm_support, |
2740 | .disabled_by_bios = vmx_disabled_by_bios, | 3079 | .disabled_by_bios = vmx_disabled_by_bios, |
@@ -2791,6 +3130,7 @@ static struct kvm_x86_ops vmx_x86_ops = { | |||
2791 | .inject_pending_vectors = do_interrupt_requests, | 3130 | .inject_pending_vectors = do_interrupt_requests, |
2792 | 3131 | ||
2793 | .set_tss_addr = vmx_set_tss_addr, | 3132 | .set_tss_addr = vmx_set_tss_addr, |
3133 | .get_tdp_level = get_ept_level, | ||
2794 | }; | 3134 | }; |
2795 | 3135 | ||
2796 | static int __init vmx_init(void) | 3136 | static int __init vmx_init(void) |
@@ -2843,9 +3183,14 @@ static int __init vmx_init(void) | |||
2843 | vmx_disable_intercept_for_msr(vmx_msr_bitmap, MSR_IA32_SYSENTER_ESP); | 3183 | vmx_disable_intercept_for_msr(vmx_msr_bitmap, MSR_IA32_SYSENTER_ESP); |
2844 | vmx_disable_intercept_for_msr(vmx_msr_bitmap, MSR_IA32_SYSENTER_EIP); | 3184 | vmx_disable_intercept_for_msr(vmx_msr_bitmap, MSR_IA32_SYSENTER_EIP); |
2845 | 3185 | ||
3186 | if (cpu_has_vmx_ept()) | ||
3187 | bypass_guest_pf = 0; | ||
3188 | |||
2846 | if (bypass_guest_pf) | 3189 | if (bypass_guest_pf) |
2847 | kvm_mmu_set_nonpresent_ptes(~0xffeull, 0ull); | 3190 | kvm_mmu_set_nonpresent_ptes(~0xffeull, 0ull); |
2848 | 3191 | ||
3192 | ept_sync_global(); | ||
3193 | |||
2849 | return 0; | 3194 | return 0; |
2850 | 3195 | ||
2851 | out2: | 3196 | out2: |
diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h index 5dff4606b988..79d94c610dfe 100644 --- a/arch/x86/kvm/vmx.h +++ b/arch/x86/kvm/vmx.h | |||
@@ -35,6 +35,8 @@ | |||
35 | #define CPU_BASED_MWAIT_EXITING 0x00000400 | 35 | #define CPU_BASED_MWAIT_EXITING 0x00000400 |
36 | #define CPU_BASED_RDPMC_EXITING 0x00000800 | 36 | #define CPU_BASED_RDPMC_EXITING 0x00000800 |
37 | #define CPU_BASED_RDTSC_EXITING 0x00001000 | 37 | #define CPU_BASED_RDTSC_EXITING 0x00001000 |
38 | #define CPU_BASED_CR3_LOAD_EXITING 0x00008000 | ||
39 | #define CPU_BASED_CR3_STORE_EXITING 0x00010000 | ||
38 | #define CPU_BASED_CR8_LOAD_EXITING 0x00080000 | 40 | #define CPU_BASED_CR8_LOAD_EXITING 0x00080000 |
39 | #define CPU_BASED_CR8_STORE_EXITING 0x00100000 | 41 | #define CPU_BASED_CR8_STORE_EXITING 0x00100000 |
40 | #define CPU_BASED_TPR_SHADOW 0x00200000 | 42 | #define CPU_BASED_TPR_SHADOW 0x00200000 |
@@ -49,6 +51,7 @@ | |||
49 | * Definitions of Secondary Processor-Based VM-Execution Controls. | 51 | * Definitions of Secondary Processor-Based VM-Execution Controls. |
50 | */ | 52 | */ |
51 | #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001 | 53 | #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001 |
54 | #define SECONDARY_EXEC_ENABLE_EPT 0x00000002 | ||
52 | #define SECONDARY_EXEC_ENABLE_VPID 0x00000020 | 55 | #define SECONDARY_EXEC_ENABLE_VPID 0x00000020 |
53 | #define SECONDARY_EXEC_WBINVD_EXITING 0x00000040 | 56 | #define SECONDARY_EXEC_WBINVD_EXITING 0x00000040 |
54 | 57 | ||
@@ -100,10 +103,22 @@ enum vmcs_field { | |||
100 | VIRTUAL_APIC_PAGE_ADDR_HIGH = 0x00002013, | 103 | VIRTUAL_APIC_PAGE_ADDR_HIGH = 0x00002013, |
101 | APIC_ACCESS_ADDR = 0x00002014, | 104 | APIC_ACCESS_ADDR = 0x00002014, |
102 | APIC_ACCESS_ADDR_HIGH = 0x00002015, | 105 | APIC_ACCESS_ADDR_HIGH = 0x00002015, |
106 | EPT_POINTER = 0x0000201a, | ||
107 | EPT_POINTER_HIGH = 0x0000201b, | ||
108 | GUEST_PHYSICAL_ADDRESS = 0x00002400, | ||
109 | GUEST_PHYSICAL_ADDRESS_HIGH = 0x00002401, | ||
103 | VMCS_LINK_POINTER = 0x00002800, | 110 | VMCS_LINK_POINTER = 0x00002800, |
104 | VMCS_LINK_POINTER_HIGH = 0x00002801, | 111 | VMCS_LINK_POINTER_HIGH = 0x00002801, |
105 | GUEST_IA32_DEBUGCTL = 0x00002802, | 112 | GUEST_IA32_DEBUGCTL = 0x00002802, |
106 | GUEST_IA32_DEBUGCTL_HIGH = 0x00002803, | 113 | GUEST_IA32_DEBUGCTL_HIGH = 0x00002803, |
114 | GUEST_PDPTR0 = 0x0000280a, | ||
115 | GUEST_PDPTR0_HIGH = 0x0000280b, | ||
116 | GUEST_PDPTR1 = 0x0000280c, | ||
117 | GUEST_PDPTR1_HIGH = 0x0000280d, | ||
118 | GUEST_PDPTR2 = 0x0000280e, | ||
119 | GUEST_PDPTR2_HIGH = 0x0000280f, | ||
120 | GUEST_PDPTR3 = 0x00002810, | ||
121 | GUEST_PDPTR3_HIGH = 0x00002811, | ||
107 | PIN_BASED_VM_EXEC_CONTROL = 0x00004000, | 122 | PIN_BASED_VM_EXEC_CONTROL = 0x00004000, |
108 | CPU_BASED_VM_EXEC_CONTROL = 0x00004002, | 123 | CPU_BASED_VM_EXEC_CONTROL = 0x00004002, |
109 | EXCEPTION_BITMAP = 0x00004004, | 124 | EXCEPTION_BITMAP = 0x00004004, |
@@ -226,6 +241,8 @@ enum vmcs_field { | |||
226 | #define EXIT_REASON_MWAIT_INSTRUCTION 36 | 241 | #define EXIT_REASON_MWAIT_INSTRUCTION 36 |
227 | #define EXIT_REASON_TPR_BELOW_THRESHOLD 43 | 242 | #define EXIT_REASON_TPR_BELOW_THRESHOLD 43 |
228 | #define EXIT_REASON_APIC_ACCESS 44 | 243 | #define EXIT_REASON_APIC_ACCESS 44 |
244 | #define EXIT_REASON_EPT_VIOLATION 48 | ||
245 | #define EXIT_REASON_EPT_MISCONFIG 49 | ||
229 | #define EXIT_REASON_WBINVD 54 | 246 | #define EXIT_REASON_WBINVD 54 |
230 | 247 | ||
231 | /* | 248 | /* |
@@ -316,15 +333,36 @@ enum vmcs_field { | |||
316 | #define MSR_IA32_VMX_CR4_FIXED1 0x489 | 333 | #define MSR_IA32_VMX_CR4_FIXED1 0x489 |
317 | #define MSR_IA32_VMX_VMCS_ENUM 0x48a | 334 | #define MSR_IA32_VMX_VMCS_ENUM 0x48a |
318 | #define MSR_IA32_VMX_PROCBASED_CTLS2 0x48b | 335 | #define MSR_IA32_VMX_PROCBASED_CTLS2 0x48b |
336 | #define MSR_IA32_VMX_EPT_VPID_CAP 0x48c | ||
319 | 337 | ||
320 | #define MSR_IA32_FEATURE_CONTROL 0x3a | 338 | #define MSR_IA32_FEATURE_CONTROL 0x3a |
321 | #define MSR_IA32_FEATURE_CONTROL_LOCKED 0x1 | 339 | #define MSR_IA32_FEATURE_CONTROL_LOCKED 0x1 |
322 | #define MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED 0x4 | 340 | #define MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED 0x4 |
323 | 341 | ||
324 | #define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT 9 | 342 | #define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT 9 |
343 | #define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT 10 | ||
325 | 344 | ||
326 | #define VMX_NR_VPIDS (1 << 16) | 345 | #define VMX_NR_VPIDS (1 << 16) |
327 | #define VMX_VPID_EXTENT_SINGLE_CONTEXT 1 | 346 | #define VMX_VPID_EXTENT_SINGLE_CONTEXT 1 |
328 | #define VMX_VPID_EXTENT_ALL_CONTEXT 2 | 347 | #define VMX_VPID_EXTENT_ALL_CONTEXT 2 |
329 | 348 | ||
349 | #define VMX_EPT_EXTENT_INDIVIDUAL_ADDR 0 | ||
350 | #define VMX_EPT_EXTENT_CONTEXT 1 | ||
351 | #define VMX_EPT_EXTENT_GLOBAL 2 | ||
352 | #define VMX_EPT_EXTENT_INDIVIDUAL_BIT (1ull << 24) | ||
353 | #define VMX_EPT_EXTENT_CONTEXT_BIT (1ull << 25) | ||
354 | #define VMX_EPT_EXTENT_GLOBAL_BIT (1ull << 26) | ||
355 | #define VMX_EPT_DEFAULT_GAW 3 | ||
356 | #define VMX_EPT_MAX_GAW 0x4 | ||
357 | #define VMX_EPT_MT_EPTE_SHIFT 3 | ||
358 | #define VMX_EPT_GAW_EPTP_SHIFT 3 | ||
359 | #define VMX_EPT_DEFAULT_MT 0x6ull | ||
360 | #define VMX_EPT_READABLE_MASK 0x1ull | ||
361 | #define VMX_EPT_WRITABLE_MASK 0x2ull | ||
362 | #define VMX_EPT_EXECUTABLE_MASK 0x4ull | ||
363 | #define VMX_EPT_FAKE_ACCESSED_MASK (1ull << 62) | ||
364 | #define VMX_EPT_FAKE_DIRTY_MASK (1ull << 63) | ||
365 | |||
366 | #define VMX_EPT_IDENTITY_PAGETABLE_ADDR 0xfffbc000ul | ||
367 | |||
330 | #endif | 368 | #endif |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0ce556372a4d..21338bdb28ff 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -2417,6 +2417,9 @@ int kvm_arch_init(void *opaque) | |||
2417 | 2417 | ||
2418 | kvm_x86_ops = ops; | 2418 | kvm_x86_ops = ops; |
2419 | kvm_mmu_set_nonpresent_ptes(0ull, 0ull); | 2419 | kvm_mmu_set_nonpresent_ptes(0ull, 0ull); |
2420 | kvm_mmu_set_base_ptes(PT_PRESENT_MASK); | ||
2421 | kvm_mmu_set_mask_ptes(PT_USER_MASK, PT_ACCESSED_MASK, | ||
2422 | PT_DIRTY_MASK, PT64_NX_MASK, 0); | ||
2420 | return 0; | 2423 | return 0; |
2421 | 2424 | ||
2422 | out: | 2425 | out: |
@@ -3019,6 +3022,8 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
3019 | 3022 | ||
3020 | kvm_x86_ops->decache_regs(vcpu); | 3023 | kvm_x86_ops->decache_regs(vcpu); |
3021 | 3024 | ||
3025 | vcpu->arch.exception.pending = false; | ||
3026 | |||
3022 | vcpu_put(vcpu); | 3027 | vcpu_put(vcpu); |
3023 | 3028 | ||
3024 | return 0; | 3029 | return 0; |
@@ -3481,7 +3486,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason) | |||
3481 | } | 3486 | } |
3482 | 3487 | ||
3483 | if (reason == TASK_SWITCH_IRET || reason == TASK_SWITCH_JMP) { | 3488 | if (reason == TASK_SWITCH_IRET || reason == TASK_SWITCH_JMP) { |
3484 | cseg_desc.type &= ~(1 << 8); //clear the B flag | 3489 | cseg_desc.type &= ~(1 << 1); //clear the B flag |
3485 | save_guest_segment_descriptor(vcpu, tr_seg.selector, | 3490 | save_guest_segment_descriptor(vcpu, tr_seg.selector, |
3486 | &cseg_desc); | 3491 | &cseg_desc); |
3487 | } | 3492 | } |
@@ -3507,7 +3512,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason) | |||
3507 | } | 3512 | } |
3508 | 3513 | ||
3509 | if (reason != TASK_SWITCH_IRET) { | 3514 | if (reason != TASK_SWITCH_IRET) { |
3510 | nseg_desc.type |= (1 << 8); | 3515 | nseg_desc.type |= (1 << 1); |
3511 | save_guest_segment_descriptor(vcpu, tss_selector, | 3516 | save_guest_segment_descriptor(vcpu, tss_selector, |
3512 | &nseg_desc); | 3517 | &nseg_desc); |
3513 | } | 3518 | } |
@@ -3698,10 +3703,19 @@ void fx_init(struct kvm_vcpu *vcpu) | |||
3698 | { | 3703 | { |
3699 | unsigned after_mxcsr_mask; | 3704 | unsigned after_mxcsr_mask; |
3700 | 3705 | ||
3706 | /* | ||
3707 | * Touch the fpu the first time in non atomic context as if | ||
3708 | * this is the first fpu instruction the exception handler | ||
3709 | * will fire before the instruction returns and it'll have to | ||
3710 | * allocate ram with GFP_KERNEL. | ||
3711 | */ | ||
3712 | if (!used_math()) | ||
3713 | fx_save(&vcpu->arch.host_fx_image); | ||
3714 | |||
3701 | /* Initialize guest FPU by resetting ours and saving into guest's */ | 3715 | /* Initialize guest FPU by resetting ours and saving into guest's */ |
3702 | preempt_disable(); | 3716 | preempt_disable(); |
3703 | fx_save(&vcpu->arch.host_fx_image); | 3717 | fx_save(&vcpu->arch.host_fx_image); |
3704 | fpu_init(); | 3718 | fx_finit(); |
3705 | fx_save(&vcpu->arch.guest_fx_image); | 3719 | fx_save(&vcpu->arch.guest_fx_image); |
3706 | fx_restore(&vcpu->arch.host_fx_image); | 3720 | fx_restore(&vcpu->arch.host_fx_image); |
3707 | preempt_enable(); | 3721 | preempt_enable(); |
@@ -3906,6 +3920,8 @@ void kvm_arch_destroy_vm(struct kvm *kvm) | |||
3906 | kvm_free_physmem(kvm); | 3920 | kvm_free_physmem(kvm); |
3907 | if (kvm->arch.apic_access_page) | 3921 | if (kvm->arch.apic_access_page) |
3908 | put_page(kvm->arch.apic_access_page); | 3922 | put_page(kvm->arch.apic_access_page); |
3923 | if (kvm->arch.ept_identity_pagetable) | ||
3924 | put_page(kvm->arch.ept_identity_pagetable); | ||
3909 | kfree(kvm); | 3925 | kfree(kvm); |
3910 | } | 3926 | } |
3911 | 3927 | ||
diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c index 2ca08386f993..f2a696d6a243 100644 --- a/arch/x86/kvm/x86_emulate.c +++ b/arch/x86/kvm/x86_emulate.c | |||
@@ -1761,6 +1761,7 @@ twobyte_insn: | |||
1761 | case 6: /* lmsw */ | 1761 | case 6: /* lmsw */ |
1762 | realmode_lmsw(ctxt->vcpu, (u16)c->src.val, | 1762 | realmode_lmsw(ctxt->vcpu, (u16)c->src.val, |
1763 | &ctxt->eflags); | 1763 | &ctxt->eflags); |
1764 | c->dst.type = OP_NONE; | ||
1764 | break; | 1765 | break; |
1765 | case 7: /* invlpg*/ | 1766 | case 7: /* invlpg*/ |
1766 | emulate_invlpg(ctxt->vcpu, memop); | 1767 | emulate_invlpg(ctxt->vcpu, memop); |
diff --git a/arch/x86/mm/discontig_32.c b/arch/x86/mm/discontig_32.c index 18378850e25a..914ccf983687 100644 --- a/arch/x86/mm/discontig_32.c +++ b/arch/x86/mm/discontig_32.c | |||
@@ -476,29 +476,3 @@ int memory_add_physaddr_to_nid(u64 addr) | |||
476 | 476 | ||
477 | EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); | 477 | EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); |
478 | #endif | 478 | #endif |
479 | |||
480 | #ifndef CONFIG_HAVE_ARCH_PARSE_SRAT | ||
481 | /* | ||
482 | * XXX FIXME: Make SLIT table parsing available to 32-bit NUMA | ||
483 | * | ||
484 | * These stub functions are needed to compile 32-bit NUMA when SRAT is | ||
485 | * not set. There are functions in srat_64.c for parsing this table | ||
486 | * and it may be possible to make them common functions. | ||
487 | */ | ||
488 | void acpi_numa_slit_init (struct acpi_table_slit *slit) | ||
489 | { | ||
490 | printk(KERN_INFO "ACPI: No support for parsing SLIT table\n"); | ||
491 | } | ||
492 | |||
493 | void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa) | ||
494 | { | ||
495 | } | ||
496 | |||
497 | void acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma) | ||
498 | { | ||
499 | } | ||
500 | |||
501 | void acpi_numa_arch_fixup(void) | ||
502 | { | ||
503 | } | ||
504 | #endif /* CONFIG_HAVE_ARCH_PARSE_SRAT */ | ||
diff --git a/arch/x86/pci/Makefile_32 b/arch/x86/pci/Makefile_32 index 7fa519868d70..89ec35d00efd 100644 --- a/arch/x86/pci/Makefile_32 +++ b/arch/x86/pci/Makefile_32 | |||
@@ -6,11 +6,19 @@ obj-$(CONFIG_PCI_DIRECT) += direct.o | |||
6 | obj-$(CONFIG_PCI_OLPC) += olpc.o | 6 | obj-$(CONFIG_PCI_OLPC) += olpc.o |
7 | 7 | ||
8 | pci-y := fixup.o | 8 | pci-y := fixup.o |
9 | |||
10 | # Do not change the ordering here. There is a nasty init function | ||
11 | # ordering dependency which breaks when you move acpi.o below | ||
12 | # legacy/irq.o | ||
9 | pci-$(CONFIG_ACPI) += acpi.o | 13 | pci-$(CONFIG_ACPI) += acpi.o |
10 | pci-y += legacy.o irq.o | 14 | pci-y += legacy.o irq.o |
11 | 15 | ||
12 | pci-$(CONFIG_X86_VISWS) += visws.o fixup.o | 16 | # Careful: VISWS and NUMAQ overrule the pci-y above. The colons are |
13 | pci-$(CONFIG_X86_NUMAQ) += numa.o irq.o | 17 | # therefor correct. This needs a proper fix by distangling the code. |
18 | pci-$(CONFIG_X86_VISWS) := visws.o fixup.o | ||
19 | pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o | ||
20 | |||
21 | # Necessary for NUMAQ as well | ||
14 | pci-$(CONFIG_NUMA) += mp_bus_to_node.o | 22 | pci-$(CONFIG_NUMA) += mp_bus_to_node.o |
15 | 23 | ||
16 | obj-y += $(pci-y) common.o early.o | 24 | obj-y += $(pci-y) common.o early.o |
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 1a9c0c6a1a18..d95de2f199cd 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -6,45 +6,6 @@ | |||
6 | #include <asm/numa.h> | 6 | #include <asm/numa.h> |
7 | #include "pci.h" | 7 | #include "pci.h" |
8 | 8 | ||
9 | static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d) | ||
10 | { | ||
11 | pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; | ||
12 | printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident); | ||
13 | return 0; | ||
14 | } | ||
15 | |||
16 | static struct dmi_system_id acpi_pciprobe_dmi_table[] __devinitdata = { | ||
17 | /* | ||
18 | * Systems where PCI IO resource ISA alignment can be skipped | ||
19 | * when the ISA enable bit in the bridge control is not set | ||
20 | */ | ||
21 | { | ||
22 | .callback = can_skip_ioresource_align, | ||
23 | .ident = "IBM System x3800", | ||
24 | .matches = { | ||
25 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), | ||
26 | DMI_MATCH(DMI_PRODUCT_NAME, "x3800"), | ||
27 | }, | ||
28 | }, | ||
29 | { | ||
30 | .callback = can_skip_ioresource_align, | ||
31 | .ident = "IBM System x3850", | ||
32 | .matches = { | ||
33 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), | ||
34 | DMI_MATCH(DMI_PRODUCT_NAME, "x3850"), | ||
35 | }, | ||
36 | }, | ||
37 | { | ||
38 | .callback = can_skip_ioresource_align, | ||
39 | .ident = "IBM System x3950", | ||
40 | .matches = { | ||
41 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), | ||
42 | DMI_MATCH(DMI_PRODUCT_NAME, "x3950"), | ||
43 | }, | ||
44 | }, | ||
45 | {} | ||
46 | }; | ||
47 | |||
48 | struct pci_root_info { | 9 | struct pci_root_info { |
49 | char *name; | 10 | char *name; |
50 | unsigned int res_num; | 11 | unsigned int res_num; |
@@ -196,8 +157,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do | |||
196 | int pxm; | 157 | int pxm; |
197 | #endif | 158 | #endif |
198 | 159 | ||
199 | dmi_check_system(acpi_pciprobe_dmi_table); | ||
200 | |||
201 | if (domain && !pci_domains_supported) { | 160 | if (domain && !pci_domains_supported) { |
202 | printk(KERN_WARNING "PCI: Multiple domains not supported " | 161 | printk(KERN_WARNING "PCI: Multiple domains not supported " |
203 | "(dom %d, bus %d)\n", domain, busnum); | 162 | "(dom %d, bus %d)\n", domain, busnum); |
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 2a4d751818b7..bfa72a9475b3 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c | |||
@@ -90,6 +90,50 @@ static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) | |||
90 | rom_r->start = rom_r->end = rom_r->flags = 0; | 90 | rom_r->start = rom_r->end = rom_r->flags = 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d) | ||
94 | { | ||
95 | pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; | ||
96 | printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident); | ||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | static struct dmi_system_id can_skip_pciprobe_dmi_table[] __devinitdata = { | ||
101 | /* | ||
102 | * Systems where PCI IO resource ISA alignment can be skipped | ||
103 | * when the ISA enable bit in the bridge control is not set | ||
104 | */ | ||
105 | { | ||
106 | .callback = can_skip_ioresource_align, | ||
107 | .ident = "IBM System x3800", | ||
108 | .matches = { | ||
109 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), | ||
110 | DMI_MATCH(DMI_PRODUCT_NAME, "x3800"), | ||
111 | }, | ||
112 | }, | ||
113 | { | ||
114 | .callback = can_skip_ioresource_align, | ||
115 | .ident = "IBM System x3850", | ||
116 | .matches = { | ||
117 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), | ||
118 | DMI_MATCH(DMI_PRODUCT_NAME, "x3850"), | ||
119 | }, | ||
120 | }, | ||
121 | { | ||
122 | .callback = can_skip_ioresource_align, | ||
123 | .ident = "IBM System x3950", | ||
124 | .matches = { | ||
125 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), | ||
126 | DMI_MATCH(DMI_PRODUCT_NAME, "x3950"), | ||
127 | }, | ||
128 | }, | ||
129 | {} | ||
130 | }; | ||
131 | |||
132 | void __init dmi_check_skip_isa_align(void) | ||
133 | { | ||
134 | dmi_check_system(can_skip_pciprobe_dmi_table); | ||
135 | } | ||
136 | |||
93 | /* | 137 | /* |
94 | * Called after each bus is probed, but before its children | 138 | * Called after each bus is probed, but before its children |
95 | * are examined. | 139 | * are examined. |
@@ -318,13 +362,16 @@ static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = { | |||
318 | {} | 362 | {} |
319 | }; | 363 | }; |
320 | 364 | ||
365 | void __init dmi_check_pciprobe(void) | ||
366 | { | ||
367 | dmi_check_system(pciprobe_dmi_table); | ||
368 | } | ||
369 | |||
321 | struct pci_bus * __devinit pcibios_scan_root(int busnum) | 370 | struct pci_bus * __devinit pcibios_scan_root(int busnum) |
322 | { | 371 | { |
323 | struct pci_bus *bus = NULL; | 372 | struct pci_bus *bus = NULL; |
324 | struct pci_sysdata *sd; | 373 | struct pci_sysdata *sd; |
325 | 374 | ||
326 | dmi_check_system(pciprobe_dmi_table); | ||
327 | |||
328 | while ((bus = pci_find_next_bus(bus)) != NULL) { | 375 | while ((bus = pci_find_next_bus(bus)) != NULL) { |
329 | if (bus->number == busnum) { | 376 | if (bus->number == busnum) { |
330 | /* Already scanned */ | 377 | /* Already scanned */ |
@@ -462,6 +509,9 @@ char * __devinit pcibios_setup(char *str) | |||
462 | } else if (!strcmp(str, "routeirq")) { | 509 | } else if (!strcmp(str, "routeirq")) { |
463 | pci_routeirq = 1; | 510 | pci_routeirq = 1; |
464 | return NULL; | 511 | return NULL; |
512 | } else if (!strcmp(str, "skip_isa_align")) { | ||
513 | pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; | ||
514 | return NULL; | ||
465 | } | 515 | } |
466 | return str; | 516 | return str; |
467 | } | 517 | } |
@@ -489,7 +539,7 @@ void pcibios_disable_device (struct pci_dev *dev) | |||
489 | pcibios_disable_irq(dev); | 539 | pcibios_disable_irq(dev); |
490 | } | 540 | } |
491 | 541 | ||
492 | struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) | 542 | struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) |
493 | { | 543 | { |
494 | struct pci_bus *bus = NULL; | 544 | struct pci_bus *bus = NULL; |
495 | struct pci_sysdata *sd; | 545 | struct pci_sysdata *sd; |
@@ -512,7 +562,7 @@ struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) | |||
512 | return bus; | 562 | return bus; |
513 | } | 563 | } |
514 | 564 | ||
515 | struct pci_bus *pci_scan_bus_with_sysdata(int busno) | 565 | struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno) |
516 | { | 566 | { |
517 | return pci_scan_bus_on_node(busno, &pci_root_ops, -1); | 567 | return pci_scan_bus_on_node(busno, &pci_root_ops, -1); |
518 | } | 568 | } |
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index b60b2abd480c..ff3a6a336342 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c | |||
@@ -502,7 +502,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SIEMENS, 0x0015, | |||
502 | */ | 502 | */ |
503 | static void fam10h_pci_cfg_space_size(struct pci_dev *dev) | 503 | static void fam10h_pci_cfg_space_size(struct pci_dev *dev) |
504 | { | 504 | { |
505 | dev->cfg_size = pci_cfg_space_size_ext(dev, 0); | 505 | dev->cfg_size = pci_cfg_space_size_ext(dev); |
506 | } | 506 | } |
507 | 507 | ||
508 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x1200, fam10h_pci_cfg_space_size); | 508 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x1200, fam10h_pci_cfg_space_size); |
diff --git a/arch/x86/pci/init.c b/arch/x86/pci/init.c index dd30c6076b5d..e70b9c57b88e 100644 --- a/arch/x86/pci/init.c +++ b/arch/x86/pci/init.c | |||
@@ -33,6 +33,10 @@ static __init int pci_access_init(void) | |||
33 | printk(KERN_ERR | 33 | printk(KERN_ERR |
34 | "PCI: Fatal: No config space access function found\n"); | 34 | "PCI: Fatal: No config space access function found\n"); |
35 | 35 | ||
36 | dmi_check_pciprobe(); | ||
37 | |||
38 | dmi_check_skip_isa_align(); | ||
39 | |||
36 | return 0; | 40 | return 0; |
37 | } | 41 | } |
38 | arch_initcall(pci_access_init); | 42 | arch_initcall(pci_access_init); |
diff --git a/arch/x86/pci/pci.h b/arch/x86/pci/pci.h index c58805a92db5..f3972b12c60a 100644 --- a/arch/x86/pci/pci.h +++ b/arch/x86/pci/pci.h | |||
@@ -38,6 +38,9 @@ enum pci_bf_sort_state { | |||
38 | pci_dmi_bf, | 38 | pci_dmi_bf, |
39 | }; | 39 | }; |
40 | 40 | ||
41 | extern void __init dmi_check_pciprobe(void); | ||
42 | extern void __init dmi_check_skip_isa_align(void); | ||
43 | |||
41 | /* pci-i386.c */ | 44 | /* pci-i386.c */ |
42 | 45 | ||
43 | extern unsigned int pcibios_max_latency; | 46 | extern unsigned int pcibios_max_latency; |
diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c index 4dceeb1fc5e0..cf058fecfcee 100644 --- a/arch/x86/vdso/vdso32-setup.c +++ b/arch/x86/vdso/vdso32-setup.c | |||
@@ -162,7 +162,7 @@ static __init void relocate_vdso(Elf32_Ehdr *ehdr) | |||
162 | Elf32_Shdr *shdr; | 162 | Elf32_Shdr *shdr; |
163 | int i; | 163 | int i; |
164 | 164 | ||
165 | BUG_ON(memcmp(ehdr->e_ident, ELFMAG, 4) != 0 || | 165 | BUG_ON(memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0 || |
166 | !elf_check_arch_ia32(ehdr) || | 166 | !elf_check_arch_ia32(ehdr) || |
167 | ehdr->e_type != ET_DYN); | 167 | ehdr->e_type != ET_DYN); |
168 | 168 | ||
diff --git a/arch/x86/video/fbdev.c b/arch/x86/video/fbdev.c index 4db42bff8c60..69527688f794 100644 --- a/arch/x86/video/fbdev.c +++ b/arch/x86/video/fbdev.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * | ||
3 | * Copyright (C) 2007 Antonino Daplas <adaplas@gmail.com> | 2 | * Copyright (C) 2007 Antonino Daplas <adaplas@gmail.com> |
4 | * | 3 | * |
5 | * This file is subject to the terms and conditions of the GNU General Public | 4 | * This file is subject to the terms and conditions of the GNU General Public |
@@ -29,3 +28,4 @@ int fb_is_primary_device(struct fb_info *info) | |||
29 | return retval; | 28 | return retval; |
30 | } | 29 | } |
31 | EXPORT_SYMBOL(fb_is_primary_device); | 30 | EXPORT_SYMBOL(fb_is_primary_device); |
31 | MODULE_LICENSE("GPL"); | ||
diff --git a/block/blk-barrier.c b/block/blk-barrier.c index 66e55288178c..a09ead19f9c5 100644 --- a/block/blk-barrier.c +++ b/block/blk-barrier.c | |||
@@ -26,8 +26,7 @@ int blk_queue_ordered(struct request_queue *q, unsigned ordered, | |||
26 | { | 26 | { |
27 | if (ordered & (QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH) && | 27 | if (ordered & (QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH) && |
28 | prepare_flush_fn == NULL) { | 28 | prepare_flush_fn == NULL) { |
29 | printk(KERN_ERR "%s: prepare_flush_fn required\n", | 29 | printk(KERN_ERR "%s: prepare_flush_fn required\n", __func__); |
30 | __FUNCTION__); | ||
31 | return -EINVAL; | 30 | return -EINVAL; |
32 | } | 31 | } |
33 | 32 | ||
diff --git a/block/blk-core.c b/block/blk-core.c index 5d09f8c56024..b754a4a2f9bd 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -136,7 +136,7 @@ static void req_bio_endio(struct request *rq, struct bio *bio, | |||
136 | 136 | ||
137 | if (unlikely(nbytes > bio->bi_size)) { | 137 | if (unlikely(nbytes > bio->bi_size)) { |
138 | printk(KERN_ERR "%s: want %u bytes done, %u left\n", | 138 | printk(KERN_ERR "%s: want %u bytes done, %u left\n", |
139 | __FUNCTION__, nbytes, bio->bi_size); | 139 | __func__, nbytes, bio->bi_size); |
140 | nbytes = bio->bi_size; | 140 | nbytes = bio->bi_size; |
141 | } | 141 | } |
142 | 142 | ||
@@ -1566,8 +1566,7 @@ static int __end_that_request_first(struct request *req, int error, | |||
1566 | if (unlikely(bio->bi_idx >= bio->bi_vcnt)) { | 1566 | if (unlikely(bio->bi_idx >= bio->bi_vcnt)) { |
1567 | blk_dump_rq_flags(req, "__end_that"); | 1567 | blk_dump_rq_flags(req, "__end_that"); |
1568 | printk(KERN_ERR "%s: bio idx %d >= vcnt %d\n", | 1568 | printk(KERN_ERR "%s: bio idx %d >= vcnt %d\n", |
1569 | __FUNCTION__, bio->bi_idx, | 1569 | __func__, bio->bi_idx, bio->bi_vcnt); |
1570 | bio->bi_vcnt); | ||
1571 | break; | 1570 | break; |
1572 | } | 1571 | } |
1573 | 1572 | ||
diff --git a/block/blk-settings.c b/block/blk-settings.c index 6089384ab064..bb93d4c32775 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c | |||
@@ -168,8 +168,8 @@ void blk_queue_max_sectors(struct request_queue *q, unsigned int max_sectors) | |||
168 | { | 168 | { |
169 | if ((max_sectors << 9) < PAGE_CACHE_SIZE) { | 169 | if ((max_sectors << 9) < PAGE_CACHE_SIZE) { |
170 | max_sectors = 1 << (PAGE_CACHE_SHIFT - 9); | 170 | max_sectors = 1 << (PAGE_CACHE_SHIFT - 9); |
171 | printk(KERN_INFO "%s: set to minimum %d\n", __FUNCTION__, | 171 | printk(KERN_INFO "%s: set to minimum %d\n", |
172 | max_sectors); | 172 | __func__, max_sectors); |
173 | } | 173 | } |
174 | 174 | ||
175 | if (BLK_DEF_MAX_SECTORS > max_sectors) | 175 | if (BLK_DEF_MAX_SECTORS > max_sectors) |
@@ -196,8 +196,8 @@ void blk_queue_max_phys_segments(struct request_queue *q, | |||
196 | { | 196 | { |
197 | if (!max_segments) { | 197 | if (!max_segments) { |
198 | max_segments = 1; | 198 | max_segments = 1; |
199 | printk(KERN_INFO "%s: set to minimum %d\n", __FUNCTION__, | 199 | printk(KERN_INFO "%s: set to minimum %d\n", |
200 | max_segments); | 200 | __func__, max_segments); |
201 | } | 201 | } |
202 | 202 | ||
203 | q->max_phys_segments = max_segments; | 203 | q->max_phys_segments = max_segments; |
@@ -220,8 +220,8 @@ void blk_queue_max_hw_segments(struct request_queue *q, | |||
220 | { | 220 | { |
221 | if (!max_segments) { | 221 | if (!max_segments) { |
222 | max_segments = 1; | 222 | max_segments = 1; |
223 | printk(KERN_INFO "%s: set to minimum %d\n", __FUNCTION__, | 223 | printk(KERN_INFO "%s: set to minimum %d\n", |
224 | max_segments); | 224 | __func__, max_segments); |
225 | } | 225 | } |
226 | 226 | ||
227 | q->max_hw_segments = max_segments; | 227 | q->max_hw_segments = max_segments; |
@@ -241,8 +241,8 @@ void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size) | |||
241 | { | 241 | { |
242 | if (max_size < PAGE_CACHE_SIZE) { | 242 | if (max_size < PAGE_CACHE_SIZE) { |
243 | max_size = PAGE_CACHE_SIZE; | 243 | max_size = PAGE_CACHE_SIZE; |
244 | printk(KERN_INFO "%s: set to minimum %d\n", __FUNCTION__, | 244 | printk(KERN_INFO "%s: set to minimum %d\n", |
245 | max_size); | 245 | __func__, max_size); |
246 | } | 246 | } |
247 | 247 | ||
248 | q->max_segment_size = max_size; | 248 | q->max_segment_size = max_size; |
@@ -357,8 +357,8 @@ void blk_queue_segment_boundary(struct request_queue *q, unsigned long mask) | |||
357 | { | 357 | { |
358 | if (mask < PAGE_CACHE_SIZE - 1) { | 358 | if (mask < PAGE_CACHE_SIZE - 1) { |
359 | mask = PAGE_CACHE_SIZE - 1; | 359 | mask = PAGE_CACHE_SIZE - 1; |
360 | printk(KERN_INFO "%s: set to minimum %lx\n", __FUNCTION__, | 360 | printk(KERN_INFO "%s: set to minimum %lx\n", |
361 | mask); | 361 | __func__, mask); |
362 | } | 362 | } |
363 | 363 | ||
364 | q->seg_boundary_mask = mask; | 364 | q->seg_boundary_mask = mask; |
diff --git a/block/blk-tag.c b/block/blk-tag.c index e176ddbe599e..de64e0429977 100644 --- a/block/blk-tag.c +++ b/block/blk-tag.c | |||
@@ -112,7 +112,7 @@ init_tag_map(struct request_queue *q, struct blk_queue_tag *tags, int depth) | |||
112 | if (q && depth > q->nr_requests * 2) { | 112 | if (q && depth > q->nr_requests * 2) { |
113 | depth = q->nr_requests * 2; | 113 | depth = q->nr_requests * 2; |
114 | printk(KERN_ERR "%s: adjusted depth to %d\n", | 114 | printk(KERN_ERR "%s: adjusted depth to %d\n", |
115 | __FUNCTION__, depth); | 115 | __func__, depth); |
116 | } | 116 | } |
117 | 117 | ||
118 | tag_index = kzalloc(depth * sizeof(struct request *), GFP_ATOMIC); | 118 | tag_index = kzalloc(depth * sizeof(struct request *), GFP_ATOMIC); |
@@ -296,13 +296,13 @@ void blk_queue_end_tag(struct request_queue *q, struct request *rq) | |||
296 | 296 | ||
297 | if (unlikely(bqt->tag_index[tag] == NULL)) | 297 | if (unlikely(bqt->tag_index[tag] == NULL)) |
298 | printk(KERN_ERR "%s: tag %d is missing\n", | 298 | printk(KERN_ERR "%s: tag %d is missing\n", |
299 | __FUNCTION__, tag); | 299 | __func__, tag); |
300 | 300 | ||
301 | bqt->tag_index[tag] = NULL; | 301 | bqt->tag_index[tag] = NULL; |
302 | 302 | ||
303 | if (unlikely(!test_bit(tag, bqt->tag_map))) { | 303 | if (unlikely(!test_bit(tag, bqt->tag_map))) { |
304 | printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n", | 304 | printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n", |
305 | __FUNCTION__, tag); | 305 | __func__, tag); |
306 | return; | 306 | return; |
307 | } | 307 | } |
308 | /* | 308 | /* |
@@ -340,7 +340,7 @@ int blk_queue_start_tag(struct request_queue *q, struct request *rq) | |||
340 | if (unlikely((rq->cmd_flags & REQ_QUEUED))) { | 340 | if (unlikely((rq->cmd_flags & REQ_QUEUED))) { |
341 | printk(KERN_ERR | 341 | printk(KERN_ERR |
342 | "%s: request %p for device [%s] already tagged %d", | 342 | "%s: request %p for device [%s] already tagged %d", |
343 | __FUNCTION__, rq, | 343 | __func__, rq, |
344 | rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->tag); | 344 | rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->tag); |
345 | BUG(); | 345 | BUG(); |
346 | } | 346 | } |
diff --git a/block/bsg.c b/block/bsg.c index 23ea4fd1a66d..f0b7cd343216 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -57,7 +57,7 @@ enum { | |||
57 | #undef BSG_DEBUG | 57 | #undef BSG_DEBUG |
58 | 58 | ||
59 | #ifdef BSG_DEBUG | 59 | #ifdef BSG_DEBUG |
60 | #define dprintk(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ##args) | 60 | #define dprintk(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ##args) |
61 | #else | 61 | #else |
62 | #define dprintk(fmt, args...) | 62 | #define dprintk(fmt, args...) |
63 | #endif | 63 | #endif |
@@ -174,7 +174,11 @@ unlock: | |||
174 | static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq, | 174 | static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq, |
175 | struct sg_io_v4 *hdr, int has_write_perm) | 175 | struct sg_io_v4 *hdr, int has_write_perm) |
176 | { | 176 | { |
177 | memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ | 177 | if (hdr->request_len > BLK_MAX_CDB) { |
178 | rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL); | ||
179 | if (!rq->cmd) | ||
180 | return -ENOMEM; | ||
181 | } | ||
178 | 182 | ||
179 | if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request, | 183 | if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request, |
180 | hdr->request_len)) | 184 | hdr->request_len)) |
@@ -211,8 +215,6 @@ bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw) | |||
211 | 215 | ||
212 | if (hdr->guard != 'Q') | 216 | if (hdr->guard != 'Q') |
213 | return -EINVAL; | 217 | return -EINVAL; |
214 | if (hdr->request_len > BLK_MAX_CDB) | ||
215 | return -EINVAL; | ||
216 | if (hdr->dout_xfer_len > (q->max_sectors << 9) || | 218 | if (hdr->dout_xfer_len > (q->max_sectors << 9) || |
217 | hdr->din_xfer_len > (q->max_sectors << 9)) | 219 | hdr->din_xfer_len > (q->max_sectors << 9)) |
218 | return -EIO; | 220 | return -EIO; |
@@ -302,6 +304,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr) | |||
302 | } | 304 | } |
303 | return rq; | 305 | return rq; |
304 | out: | 306 | out: |
307 | if (rq->cmd != rq->__cmd) | ||
308 | kfree(rq->cmd); | ||
305 | blk_put_request(rq); | 309 | blk_put_request(rq); |
306 | if (next_rq) { | 310 | if (next_rq) { |
307 | blk_rq_unmap_user(next_rq->bio); | 311 | blk_rq_unmap_user(next_rq->bio); |
@@ -455,6 +459,8 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr, | |||
455 | ret = rq->errors; | 459 | ret = rq->errors; |
456 | 460 | ||
457 | blk_rq_unmap_user(bio); | 461 | blk_rq_unmap_user(bio); |
462 | if (rq->cmd != rq->__cmd) | ||
463 | kfree(rq->cmd); | ||
458 | blk_put_request(rq); | 464 | blk_put_request(rq); |
459 | 465 | ||
460 | return ret; | 466 | return ret; |
diff --git a/block/elevator.c b/block/elevator.c index ac5310ef8270..980f8ae147b4 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -650,7 +650,7 @@ void elv_insert(struct request_queue *q, struct request *rq, int where) | |||
650 | 650 | ||
651 | default: | 651 | default: |
652 | printk(KERN_ERR "%s: bad insertion point %d\n", | 652 | printk(KERN_ERR "%s: bad insertion point %d\n", |
653 | __FUNCTION__, where); | 653 | __func__, where); |
654 | BUG(); | 654 | BUG(); |
655 | } | 655 | } |
656 | 656 | ||
@@ -808,8 +808,7 @@ struct request *elv_next_request(struct request_queue *q) | |||
808 | rq->cmd_flags |= REQ_QUIET; | 808 | rq->cmd_flags |= REQ_QUIET; |
809 | end_queued_request(rq, 0); | 809 | end_queued_request(rq, 0); |
810 | } else { | 810 | } else { |
811 | printk(KERN_ERR "%s: bad return=%d\n", __FUNCTION__, | 811 | printk(KERN_ERR "%s: bad return=%d\n", __func__, ret); |
812 | ret); | ||
813 | break; | 812 | break; |
814 | } | 813 | } |
815 | } | 814 | } |
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index ffa3720e6ca0..78199c08ec92 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c | |||
@@ -33,13 +33,12 @@ | |||
33 | #include <scsi/scsi_cmnd.h> | 33 | #include <scsi/scsi_cmnd.h> |
34 | 34 | ||
35 | /* Command group 3 is reserved and should never be used. */ | 35 | /* Command group 3 is reserved and should never be used. */ |
36 | const unsigned char scsi_command_size[8] = | 36 | const unsigned char scsi_command_size_tbl[8] = |
37 | { | 37 | { |
38 | 6, 10, 10, 12, | 38 | 6, 10, 10, 12, |
39 | 16, 12, 10, 10 | 39 | 16, 12, 10, 10 |
40 | }; | 40 | }; |
41 | 41 | EXPORT_SYMBOL(scsi_command_size_tbl); | |
42 | EXPORT_SYMBOL(scsi_command_size); | ||
43 | 42 | ||
44 | #include <scsi/sg.h> | 43 | #include <scsi/sg.h> |
45 | 44 | ||
diff --git a/crypto/authenc.c b/crypto/authenc.c index ed8ac5a6fa5f..4b226768752a 100644 --- a/crypto/authenc.c +++ b/crypto/authenc.c | |||
@@ -217,9 +217,10 @@ static void crypto_authenc_givencrypt_done(struct crypto_async_request *req, | |||
217 | int err) | 217 | int err) |
218 | { | 218 | { |
219 | if (!err) { | 219 | if (!err) { |
220 | struct aead_givcrypt_request *greq = req->data; | 220 | struct aead_request *areq = req->data; |
221 | struct skcipher_givcrypt_request *greq = aead_request_ctx(areq); | ||
221 | 222 | ||
222 | err = crypto_authenc_genicv(&greq->areq, greq->giv, 0); | 223 | err = crypto_authenc_genicv(areq, greq->giv, 0); |
223 | } | 224 | } |
224 | 225 | ||
225 | aead_request_complete(req->data, err); | 226 | aead_request_complete(req->data, err); |
diff --git a/crypto/cryptd.c b/crypto/cryptd.c index 250425263e00..b150de562057 100644 --- a/crypto/cryptd.c +++ b/crypto/cryptd.c | |||
@@ -190,8 +190,10 @@ static struct crypto_instance *cryptd_alloc_instance(struct crypto_alg *alg, | |||
190 | int err; | 190 | int err; |
191 | 191 | ||
192 | inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL); | 192 | inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL); |
193 | if (IS_ERR(inst)) | 193 | if (!inst) { |
194 | inst = ERR_PTR(-ENOMEM); | ||
194 | goto out; | 195 | goto out; |
196 | } | ||
195 | 197 | ||
196 | err = -ENAMETOOLONG; | 198 | err = -ENAMETOOLONG; |
197 | if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, | 199 | if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, |
diff --git a/crypto/eseqiv.c b/crypto/eseqiv.c index b14f14e314b6..881d30910434 100644 --- a/crypto/eseqiv.c +++ b/crypto/eseqiv.c | |||
@@ -136,7 +136,8 @@ static int eseqiv_givencrypt(struct skcipher_givcrypt_request *req) | |||
136 | } | 136 | } |
137 | 137 | ||
138 | ablkcipher_request_set_crypt(subreq, reqctx->src, dst, | 138 | ablkcipher_request_set_crypt(subreq, reqctx->src, dst, |
139 | req->creq.nbytes, req->creq.info); | 139 | req->creq.nbytes + ivsize, |
140 | req->creq.info); | ||
140 | 141 | ||
141 | memcpy(req->creq.info, ctx->salt, ivsize); | 142 | memcpy(req->creq.info, ctx->salt, ivsize); |
142 | 143 | ||
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 6fe417429977..e38dfed41d80 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -18,7 +18,7 @@ struct sysdev_class cpu_sysdev_class = { | |||
18 | }; | 18 | }; |
19 | EXPORT_SYMBOL(cpu_sysdev_class); | 19 | EXPORT_SYMBOL(cpu_sysdev_class); |
20 | 20 | ||
21 | static struct sys_device *cpu_sys_devices[NR_CPUS]; | 21 | static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices); |
22 | 22 | ||
23 | #ifdef CONFIG_HOTPLUG_CPU | 23 | #ifdef CONFIG_HOTPLUG_CPU |
24 | static ssize_t show_online(struct sys_device *dev, char *buf) | 24 | static ssize_t show_online(struct sys_device *dev, char *buf) |
@@ -68,7 +68,7 @@ void unregister_cpu(struct cpu *cpu) | |||
68 | sysdev_remove_file(&cpu->sysdev, &attr_online); | 68 | sysdev_remove_file(&cpu->sysdev, &attr_online); |
69 | 69 | ||
70 | sysdev_unregister(&cpu->sysdev); | 70 | sysdev_unregister(&cpu->sysdev); |
71 | cpu_sys_devices[logical_cpu] = NULL; | 71 | per_cpu(cpu_sys_devices, logical_cpu) = NULL; |
72 | return; | 72 | return; |
73 | } | 73 | } |
74 | #else /* ... !CONFIG_HOTPLUG_CPU */ | 74 | #else /* ... !CONFIG_HOTPLUG_CPU */ |
@@ -167,7 +167,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) | |||
167 | if (!error && cpu->hotpluggable) | 167 | if (!error && cpu->hotpluggable) |
168 | register_cpu_control(cpu); | 168 | register_cpu_control(cpu); |
169 | if (!error) | 169 | if (!error) |
170 | cpu_sys_devices[num] = &cpu->sysdev; | 170 | per_cpu(cpu_sys_devices, num) = &cpu->sysdev; |
171 | if (!error) | 171 | if (!error) |
172 | register_cpu_under_node(num, cpu_to_node(num)); | 172 | register_cpu_under_node(num, cpu_to_node(num)); |
173 | 173 | ||
@@ -180,8 +180,8 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) | |||
180 | 180 | ||
181 | struct sys_device *get_cpu_sysdev(unsigned cpu) | 181 | struct sys_device *get_cpu_sysdev(unsigned cpu) |
182 | { | 182 | { |
183 | if (cpu < NR_CPUS) | 183 | if (cpu < nr_cpu_ids && cpu_possible(cpu)) |
184 | return cpu_sys_devices[cpu]; | 184 | return per_cpu(cpu_sys_devices, cpu); |
185 | else | 185 | else |
186 | return NULL; | 186 | return NULL; |
187 | } | 187 | } |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index e539be5750dc..e336b05fe4a7 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -428,13 +428,9 @@ static void __devinit cciss_procinit(int i) | |||
428 | proc_cciss = proc_mkdir("driver/cciss", NULL); | 428 | proc_cciss = proc_mkdir("driver/cciss", NULL); |
429 | if (!proc_cciss) | 429 | if (!proc_cciss) |
430 | return; | 430 | return; |
431 | pde = proc_create(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP | | 431 | pde = proc_create_data(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP | |
432 | S_IROTH, proc_cciss, | 432 | S_IROTH, proc_cciss, |
433 | &cciss_proc_fops); | 433 | &cciss_proc_fops, hba[i]); |
434 | if (!pde) | ||
435 | return; | ||
436 | |||
437 | pde->data = hba[i]; | ||
438 | } | 434 | } |
439 | #endif /* CONFIG_PROC_FS */ | 435 | #endif /* CONFIG_PROC_FS */ |
440 | 436 | ||
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index e322cce8c12d..3a281ef11ffa 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -205,6 +205,7 @@ struct ub_scsi_cmd { | |||
205 | unsigned char key, asc, ascq; /* May be valid if error==-EIO */ | 205 | unsigned char key, asc, ascq; /* May be valid if error==-EIO */ |
206 | 206 | ||
207 | int stat_count; /* Retries getting status. */ | 207 | int stat_count; /* Retries getting status. */ |
208 | unsigned int timeo; /* jiffies until rq->timeout changes */ | ||
208 | 209 | ||
209 | unsigned int len; /* Requested length */ | 210 | unsigned int len; /* Requested length */ |
210 | unsigned int current_sg; | 211 | unsigned int current_sg; |
@@ -318,6 +319,7 @@ struct ub_dev { | |||
318 | int openc; /* protected by ub_lock! */ | 319 | int openc; /* protected by ub_lock! */ |
319 | /* kref is too implicit for our taste */ | 320 | /* kref is too implicit for our taste */ |
320 | int reset; /* Reset is running */ | 321 | int reset; /* Reset is running */ |
322 | int bad_resid; | ||
321 | unsigned int tagcnt; | 323 | unsigned int tagcnt; |
322 | char name[12]; | 324 | char name[12]; |
323 | struct usb_device *dev; | 325 | struct usb_device *dev; |
@@ -764,6 +766,12 @@ static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, | |||
764 | cmd->cdb_len = rq->cmd_len; | 766 | cmd->cdb_len = rq->cmd_len; |
765 | 767 | ||
766 | cmd->len = rq->data_len; | 768 | cmd->len = rq->data_len; |
769 | |||
770 | /* | ||
771 | * To reapply this to every URB is not as incorrect as it looks. | ||
772 | * In return, we avoid any complicated tracking calculations. | ||
773 | */ | ||
774 | cmd->timeo = rq->timeout; | ||
767 | } | 775 | } |
768 | 776 | ||
769 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | 777 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) |
@@ -785,10 +793,6 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
785 | scsi_status = 0; | 793 | scsi_status = 0; |
786 | } else { | 794 | } else { |
787 | if (cmd->act_len != cmd->len) { | 795 | if (cmd->act_len != cmd->len) { |
788 | if ((cmd->key == MEDIUM_ERROR || | ||
789 | cmd->key == UNIT_ATTENTION) && | ||
790 | ub_rw_cmd_retry(sc, lun, urq, cmd) == 0) | ||
791 | return; | ||
792 | scsi_status = SAM_STAT_CHECK_CONDITION; | 796 | scsi_status = SAM_STAT_CHECK_CONDITION; |
793 | } else { | 797 | } else { |
794 | scsi_status = 0; | 798 | scsi_status = 0; |
@@ -804,7 +808,10 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
804 | else | 808 | else |
805 | scsi_status = DID_ERROR << 16; | 809 | scsi_status = DID_ERROR << 16; |
806 | } else { | 810 | } else { |
807 | if (cmd->error == -EIO) { | 811 | if (cmd->error == -EIO && |
812 | (cmd->key == 0 || | ||
813 | cmd->key == MEDIUM_ERROR || | ||
814 | cmd->key == UNIT_ATTENTION)) { | ||
808 | if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0) | 815 | if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0) |
809 | return; | 816 | return; |
810 | } | 817 | } |
@@ -1259,14 +1266,19 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1259 | return; | 1266 | return; |
1260 | } | 1267 | } |
1261 | 1268 | ||
1262 | len = le32_to_cpu(bcs->Residue); | 1269 | if (!sc->bad_resid) { |
1263 | if (len != cmd->len - cmd->act_len) { | 1270 | len = le32_to_cpu(bcs->Residue); |
1264 | /* | 1271 | if (len != cmd->len - cmd->act_len) { |
1265 | * It is all right to transfer less, the caller has | 1272 | /* |
1266 | * to check. But it's not all right if the device | 1273 | * Only start ignoring if this cmd ended well. |
1267 | * counts disagree with our counts. | 1274 | */ |
1268 | */ | 1275 | if (cmd->len == cmd->act_len) { |
1269 | goto Bad_End; | 1276 | printk(KERN_NOTICE "%s: " |
1277 | "bad residual %d of %d, ignoring\n", | ||
1278 | sc->name, len, cmd->len); | ||
1279 | sc->bad_resid = 1; | ||
1280 | } | ||
1281 | } | ||
1270 | } | 1282 | } |
1271 | 1283 | ||
1272 | switch (bcs->Status) { | 1284 | switch (bcs->Status) { |
@@ -1297,8 +1309,7 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1297 | ub_state_done(sc, cmd, -EIO); | 1309 | ub_state_done(sc, cmd, -EIO); |
1298 | 1310 | ||
1299 | } else { | 1311 | } else { |
1300 | printk(KERN_WARNING "%s: " | 1312 | printk(KERN_WARNING "%s: wrong command state %d\n", |
1301 | "wrong command state %d\n", | ||
1302 | sc->name, cmd->state); | 1313 | sc->name, cmd->state); |
1303 | ub_state_done(sc, cmd, -EINVAL); | 1314 | ub_state_done(sc, cmd, -EINVAL); |
1304 | return; | 1315 | return; |
@@ -1336,7 +1347,10 @@ static void ub_data_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1336 | return; | 1347 | return; |
1337 | } | 1348 | } |
1338 | 1349 | ||
1339 | sc->work_timer.expires = jiffies + UB_DATA_TIMEOUT; | 1350 | if (cmd->timeo) |
1351 | sc->work_timer.expires = jiffies + cmd->timeo; | ||
1352 | else | ||
1353 | sc->work_timer.expires = jiffies + UB_DATA_TIMEOUT; | ||
1340 | add_timer(&sc->work_timer); | 1354 | add_timer(&sc->work_timer); |
1341 | 1355 | ||
1342 | cmd->state = UB_CMDST_DATA; | 1356 | cmd->state = UB_CMDST_DATA; |
@@ -1376,7 +1390,10 @@ static int __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1376 | return -1; | 1390 | return -1; |
1377 | } | 1391 | } |
1378 | 1392 | ||
1379 | sc->work_timer.expires = jiffies + UB_STAT_TIMEOUT; | 1393 | if (cmd->timeo) |
1394 | sc->work_timer.expires = jiffies + cmd->timeo; | ||
1395 | else | ||
1396 | sc->work_timer.expires = jiffies + UB_STAT_TIMEOUT; | ||
1380 | add_timer(&sc->work_timer); | 1397 | add_timer(&sc->work_timer); |
1381 | return 0; | 1398 | return 0; |
1382 | } | 1399 | } |
@@ -1515,8 +1532,7 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd) | |||
1515 | return; | 1532 | return; |
1516 | } | 1533 | } |
1517 | if (cmd->state != UB_CMDST_SENSE) { | 1534 | if (cmd->state != UB_CMDST_SENSE) { |
1518 | printk(KERN_WARNING "%s: " | 1535 | printk(KERN_WARNING "%s: sense done with bad cmd state %d\n", |
1519 | "sense done with bad cmd state %d\n", | ||
1520 | sc->name, cmd->state); | 1536 | sc->name, cmd->state); |
1521 | return; | 1537 | return; |
1522 | } | 1538 | } |
@@ -1720,7 +1736,7 @@ static int ub_bd_ioctl(struct inode *inode, struct file *filp, | |||
1720 | } | 1736 | } |
1721 | 1737 | ||
1722 | /* | 1738 | /* |
1723 | * This is called once a new disk was seen by the block layer or by ub_probe(). | 1739 | * This is called by check_disk_change if we reported a media change. |
1724 | * The main onjective here is to discover the features of the media such as | 1740 | * The main onjective here is to discover the features of the media such as |
1725 | * the capacity, read-only status, etc. USB storage generally does not | 1741 | * the capacity, read-only status, etc. USB storage generally does not |
1726 | * need to be spun up, but if we needed it, this would be the place. | 1742 | * need to be spun up, but if we needed it, this would be the place. |
@@ -2136,8 +2152,7 @@ static int ub_get_pipes(struct ub_dev *sc, struct usb_device *dev, | |||
2136 | } | 2152 | } |
2137 | 2153 | ||
2138 | if (ep_in == NULL || ep_out == NULL) { | 2154 | if (ep_in == NULL || ep_out == NULL) { |
2139 | printk(KERN_NOTICE "%s: failed endpoint check\n", | 2155 | printk(KERN_NOTICE "%s: failed endpoint check\n", sc->name); |
2140 | sc->name); | ||
2141 | return -ENODEV; | 2156 | return -ENODEV; |
2142 | } | 2157 | } |
2143 | 2158 | ||
@@ -2354,7 +2369,7 @@ static void ub_disconnect(struct usb_interface *intf) | |||
2354 | spin_unlock_irqrestore(&ub_lock, flags); | 2369 | spin_unlock_irqrestore(&ub_lock, flags); |
2355 | 2370 | ||
2356 | /* | 2371 | /* |
2357 | * Fence stall clearnings, operations triggered by unlinkings and so on. | 2372 | * Fence stall clearings, operations triggered by unlinkings and so on. |
2358 | * We do not attempt to unlink any URBs, because we do not trust the | 2373 | * We do not attempt to unlink any URBs, because we do not trust the |
2359 | * unlink paths in HC drivers. Also, we get -84 upon disconnect anyway. | 2374 | * unlink paths in HC drivers. Also, we get -84 upon disconnect anyway. |
2360 | */ | 2375 | */ |
@@ -2417,7 +2432,7 @@ static void ub_disconnect(struct usb_interface *intf) | |||
2417 | spin_unlock_irqrestore(sc->lock, flags); | 2432 | spin_unlock_irqrestore(sc->lock, flags); |
2418 | 2433 | ||
2419 | /* | 2434 | /* |
2420 | * There is virtually no chance that other CPU runs times so long | 2435 | * There is virtually no chance that other CPU runs a timeout so long |
2421 | * after ub_urb_complete should have called del_timer, but only if HCD | 2436 | * after ub_urb_complete should have called del_timer, but only if HCD |
2422 | * didn't forget to deliver a callback on unlink. | 2437 | * didn't forget to deliver a callback on unlink. |
2423 | */ | 2438 | */ |
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 0cfbe8c594a5..84e064ffee52 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -35,7 +35,7 @@ struct virtblk_req | |||
35 | struct list_head list; | 35 | struct list_head list; |
36 | struct request *req; | 36 | struct request *req; |
37 | struct virtio_blk_outhdr out_hdr; | 37 | struct virtio_blk_outhdr out_hdr; |
38 | struct virtio_blk_inhdr in_hdr; | 38 | u8 status; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static void blk_done(struct virtqueue *vq) | 41 | static void blk_done(struct virtqueue *vq) |
@@ -48,7 +48,7 @@ static void blk_done(struct virtqueue *vq) | |||
48 | spin_lock_irqsave(&vblk->lock, flags); | 48 | spin_lock_irqsave(&vblk->lock, flags); |
49 | while ((vbr = vblk->vq->vq_ops->get_buf(vblk->vq, &len)) != NULL) { | 49 | while ((vbr = vblk->vq->vq_ops->get_buf(vblk->vq, &len)) != NULL) { |
50 | int uptodate; | 50 | int uptodate; |
51 | switch (vbr->in_hdr.status) { | 51 | switch (vbr->status) { |
52 | case VIRTIO_BLK_S_OK: | 52 | case VIRTIO_BLK_S_OK: |
53 | uptodate = 1; | 53 | uptodate = 1; |
54 | break; | 54 | break; |
@@ -101,7 +101,7 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk, | |||
101 | sg_init_table(vblk->sg, VIRTIO_MAX_SG); | 101 | sg_init_table(vblk->sg, VIRTIO_MAX_SG); |
102 | sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); | 102 | sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); |
103 | num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); | 103 | num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); |
104 | sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr)); | 104 | sg_set_buf(&vblk->sg[num+1], &vbr->status, sizeof(vbr->status)); |
105 | 105 | ||
106 | if (rq_data_dir(vbr->req) == WRITE) { | 106 | if (rq_data_dir(vbr->req) == WRITE) { |
107 | vbr->out_hdr.type |= VIRTIO_BLK_T_OUT; | 107 | vbr->out_hdr.type |= VIRTIO_BLK_T_OUT; |
@@ -157,10 +157,25 @@ static int virtblk_ioctl(struct inode *inode, struct file *filp, | |||
157 | /* We provide getgeo only to please some old bootloader/partitioning tools */ | 157 | /* We provide getgeo only to please some old bootloader/partitioning tools */ |
158 | static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) | 158 | static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) |
159 | { | 159 | { |
160 | /* some standard values, similar to sd */ | 160 | struct virtio_blk *vblk = bd->bd_disk->private_data; |
161 | geo->heads = 1 << 6; | 161 | struct virtio_blk_geometry vgeo; |
162 | geo->sectors = 1 << 5; | 162 | int err; |
163 | geo->cylinders = get_capacity(bd->bd_disk) >> 11; | 163 | |
164 | /* see if the host passed in geometry config */ | ||
165 | err = virtio_config_val(vblk->vdev, VIRTIO_BLK_F_GEOMETRY, | ||
166 | offsetof(struct virtio_blk_config, geometry), | ||
167 | &vgeo); | ||
168 | |||
169 | if (!err) { | ||
170 | geo->heads = vgeo.heads; | ||
171 | geo->sectors = vgeo.sectors; | ||
172 | geo->cylinders = vgeo.cylinders; | ||
173 | } else { | ||
174 | /* some standard values, similar to sd */ | ||
175 | geo->heads = 1 << 6; | ||
176 | geo->sectors = 1 << 5; | ||
177 | geo->cylinders = get_capacity(bd->bd_disk) >> 11; | ||
178 | } | ||
164 | return 0; | 179 | return 0; |
165 | } | 180 | } |
166 | 181 | ||
@@ -242,12 +257,12 @@ static int virtblk_probe(struct virtio_device *vdev) | |||
242 | index++; | 257 | index++; |
243 | 258 | ||
244 | /* If barriers are supported, tell block layer that queue is ordered */ | 259 | /* If barriers are supported, tell block layer that queue is ordered */ |
245 | if (vdev->config->feature(vdev, VIRTIO_BLK_F_BARRIER)) | 260 | if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER)) |
246 | blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL); | 261 | blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL); |
247 | 262 | ||
248 | /* Host must always specify the capacity. */ | 263 | /* Host must always specify the capacity. */ |
249 | __virtio_config_val(vdev, offsetof(struct virtio_blk_config, capacity), | 264 | vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity), |
250 | &cap); | 265 | &cap, sizeof(cap)); |
251 | 266 | ||
252 | /* If capacity is too big, truncate with warning. */ | 267 | /* If capacity is too big, truncate with warning. */ |
253 | if ((sector_t)cap != cap) { | 268 | if ((sector_t)cap != cap) { |
@@ -289,7 +304,6 @@ out: | |||
289 | static void virtblk_remove(struct virtio_device *vdev) | 304 | static void virtblk_remove(struct virtio_device *vdev) |
290 | { | 305 | { |
291 | struct virtio_blk *vblk = vdev->priv; | 306 | struct virtio_blk *vblk = vdev->priv; |
292 | int major = vblk->disk->major; | ||
293 | 307 | ||
294 | /* Nothing should be pending. */ | 308 | /* Nothing should be pending. */ |
295 | BUG_ON(!list_empty(&vblk->reqs)); | 309 | BUG_ON(!list_empty(&vblk->reqs)); |
@@ -299,7 +313,6 @@ static void virtblk_remove(struct virtio_device *vdev) | |||
299 | 313 | ||
300 | blk_cleanup_queue(vblk->disk->queue); | 314 | blk_cleanup_queue(vblk->disk->queue); |
301 | put_disk(vblk->disk); | 315 | put_disk(vblk->disk); |
302 | unregister_blkdev(major, "virtblk"); | ||
303 | mempool_destroy(vblk->pool); | 316 | mempool_destroy(vblk->pool); |
304 | vdev->config->del_vq(vblk->vq); | 317 | vdev->config->del_vq(vblk->vq); |
305 | kfree(vblk); | 318 | kfree(vblk); |
@@ -310,7 +323,14 @@ static struct virtio_device_id id_table[] = { | |||
310 | { 0 }, | 323 | { 0 }, |
311 | }; | 324 | }; |
312 | 325 | ||
326 | static unsigned int features[] = { | ||
327 | VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, | ||
328 | VIRTIO_BLK_F_GEOMETRY, | ||
329 | }; | ||
330 | |||
313 | static struct virtio_driver virtio_blk = { | 331 | static struct virtio_driver virtio_blk = { |
332 | .feature_table = features, | ||
333 | .feature_table_size = ARRAY_SIZE(features), | ||
314 | .driver.name = KBUILD_MODNAME, | 334 | .driver.name = KBUILD_MODNAME, |
315 | .driver.owner = THIS_MODULE, | 335 | .driver.owner = THIS_MODULE, |
316 | .id_table = id_table, | 336 | .id_table = id_table, |
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c index f49037b744f9..b60d425ce8d1 100644 --- a/drivers/char/i8k.c +++ b/drivers/char/i8k.c | |||
@@ -77,6 +77,10 @@ static int power_status; | |||
77 | module_param(power_status, bool, 0600); | 77 | module_param(power_status, bool, 0600); |
78 | MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k"); | 78 | MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k"); |
79 | 79 | ||
80 | static int fan_mult = I8K_FAN_MULT; | ||
81 | module_param(fan_mult, int, 0); | ||
82 | MODULE_PARM_DESC(fan_mult, "Factor to multiply fan speed with"); | ||
83 | |||
80 | static int i8k_open_fs(struct inode *inode, struct file *file); | 84 | static int i8k_open_fs(struct inode *inode, struct file *file); |
81 | static int i8k_ioctl(struct inode *, struct file *, unsigned int, | 85 | static int i8k_ioctl(struct inode *, struct file *, unsigned int, |
82 | unsigned long); | 86 | unsigned long); |
@@ -239,7 +243,7 @@ static int i8k_get_fan_speed(int fan) | |||
239 | struct smm_regs regs = { .eax = I8K_SMM_GET_SPEED, }; | 243 | struct smm_regs regs = { .eax = I8K_SMM_GET_SPEED, }; |
240 | 244 | ||
241 | regs.ebx = fan & 0xff; | 245 | regs.ebx = fan & 0xff; |
242 | return i8k_smm(®s) ? : (regs.eax & 0xffff) * I8K_FAN_MULT; | 246 | return i8k_smm(®s) ? : (regs.eax & 0xffff) * fan_mult; |
243 | } | 247 | } |
244 | 248 | ||
245 | /* | 249 | /* |
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index d83db5d880e0..192961fd7173 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <linux/miscdevice.h> | 30 | #include <linux/miscdevice.h> |
31 | #include <linux/posix-timers.h> | 31 | #include <linux/posix-timers.h> |
32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
33 | #include <linux/time.h> | ||
34 | #include <linux/math64.h> | ||
33 | 35 | ||
34 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
35 | #include <asm/sn/addrs.h> | 37 | #include <asm/sn/addrs.h> |
@@ -472,8 +474,8 @@ static int sgi_clock_get(clockid_t clockid, struct timespec *tp) | |||
472 | 474 | ||
473 | nsec = rtc_time() * sgi_clock_period | 475 | nsec = rtc_time() * sgi_clock_period |
474 | + sgi_clock_offset.tv_nsec; | 476 | + sgi_clock_offset.tv_nsec; |
475 | tp->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &tp->tv_nsec) | 477 | *tp = ns_to_timespec(nsec); |
476 | + sgi_clock_offset.tv_sec; | 478 | tp->tv_sec += sgi_clock_offset.tv_sec; |
477 | return 0; | 479 | return 0; |
478 | }; | 480 | }; |
479 | 481 | ||
@@ -481,11 +483,11 @@ static int sgi_clock_set(clockid_t clockid, struct timespec *tp) | |||
481 | { | 483 | { |
482 | 484 | ||
483 | u64 nsec; | 485 | u64 nsec; |
484 | u64 rem; | 486 | u32 rem; |
485 | 487 | ||
486 | nsec = rtc_time() * sgi_clock_period; | 488 | nsec = rtc_time() * sgi_clock_period; |
487 | 489 | ||
488 | sgi_clock_offset.tv_sec = tp->tv_sec - div_long_long_rem(nsec, NSEC_PER_SEC, &rem); | 490 | sgi_clock_offset.tv_sec = tp->tv_sec - div_u64_rem(nsec, NSEC_PER_SEC, &rem); |
489 | 491 | ||
490 | if (rem <= tp->tv_nsec) | 492 | if (rem <= tp->tv_nsec) |
491 | sgi_clock_offset.tv_nsec = tp->tv_sec - rem; | 493 | sgi_clock_offset.tv_nsec = tp->tv_sec - rem; |
@@ -644,9 +646,6 @@ static int sgi_timer_del(struct k_itimer *timr) | |||
644 | return 0; | 646 | return 0; |
645 | } | 647 | } |
646 | 648 | ||
647 | #define timespec_to_ns(x) ((x).tv_nsec + (x).tv_sec * NSEC_PER_SEC) | ||
648 | #define ns_to_timespec(ts, nsec) (ts).tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &(ts).tv_nsec) | ||
649 | |||
650 | /* Assumption: it_lock is already held with irq's disabled */ | 649 | /* Assumption: it_lock is already held with irq's disabled */ |
651 | static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) | 650 | static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) |
652 | { | 651 | { |
@@ -659,9 +658,8 @@ static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) | |||
659 | return; | 658 | return; |
660 | } | 659 | } |
661 | 660 | ||
662 | ns_to_timespec(cur_setting->it_interval, timr->it.mmtimer.incr * sgi_clock_period); | 661 | cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * sgi_clock_period); |
663 | ns_to_timespec(cur_setting->it_value, (timr->it.mmtimer.expires - rtc_time())* sgi_clock_period); | 662 | cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - rtc_time()) * sgi_clock_period); |
664 | return; | ||
665 | } | 663 | } |
666 | 664 | ||
667 | 665 | ||
@@ -679,8 +677,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, | |||
679 | sgi_timer_get(timr, old_setting); | 677 | sgi_timer_get(timr, old_setting); |
680 | 678 | ||
681 | sgi_timer_del(timr); | 679 | sgi_timer_del(timr); |
682 | when = timespec_to_ns(new_setting->it_value); | 680 | when = timespec_to_ns(&new_setting->it_value); |
683 | period = timespec_to_ns(new_setting->it_interval); | 681 | period = timespec_to_ns(&new_setting->it_interval); |
684 | 682 | ||
685 | if (when == 0) | 683 | if (when == 0) |
686 | /* Clear timer */ | 684 | /* Clear timer */ |
@@ -695,7 +693,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, | |||
695 | unsigned long now; | 693 | unsigned long now; |
696 | 694 | ||
697 | getnstimeofday(&n); | 695 | getnstimeofday(&n); |
698 | now = timespec_to_ns(n); | 696 | now = timespec_to_ns(&n); |
699 | if (when > now) | 697 | if (when > now) |
700 | when -= now; | 698 | when -= now; |
701 | else | 699 | else |
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c index fd2db07a50fc..3b23270eaa65 100644 --- a/drivers/char/serial167.c +++ b/drivers/char/serial167.c | |||
@@ -1073,7 +1073,7 @@ static int cy_put_char(struct tty_struct *tty, unsigned char ch) | |||
1073 | return 0; | 1073 | return 0; |
1074 | 1074 | ||
1075 | if (!info->xmit_buf) | 1075 | if (!info->xmit_buf) |
1076 | return; | 1076 | return 0; |
1077 | 1077 | ||
1078 | local_irq_save(flags); | 1078 | local_irq_save(flags); |
1079 | if (info->xmit_cnt >= PAGE_SIZE - 1) { | 1079 | if (info->xmit_cnt >= PAGE_SIZE - 1) { |
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 513b7c2f3e26..ac5080df2565 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c | |||
@@ -2028,13 +2028,13 @@ static void mgsl_change_params(struct mgsl_struct *info) | |||
2028 | */ | 2028 | */ |
2029 | static int mgsl_put_char(struct tty_struct *tty, unsigned char ch) | 2029 | static int mgsl_put_char(struct tty_struct *tty, unsigned char ch) |
2030 | { | 2030 | { |
2031 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2031 | struct mgsl_struct *info = tty->driver_data; |
2032 | unsigned long flags; | 2032 | unsigned long flags; |
2033 | int ret; | 2033 | int ret = 0; |
2034 | 2034 | ||
2035 | if ( debug_level >= DEBUG_LEVEL_INFO ) { | 2035 | if (debug_level >= DEBUG_LEVEL_INFO) { |
2036 | printk( "%s(%d):mgsl_put_char(%d) on %s\n", | 2036 | printk(KERN_DEBUG "%s(%d):mgsl_put_char(%d) on %s\n", |
2037 | __FILE__,__LINE__,ch,info->device_name); | 2037 | __FILE__, __LINE__, ch, info->device_name); |
2038 | } | 2038 | } |
2039 | 2039 | ||
2040 | if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char")) | 2040 | if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char")) |
@@ -2043,9 +2043,9 @@ static int mgsl_put_char(struct tty_struct *tty, unsigned char ch) | |||
2043 | if (!tty || !info->xmit_buf) | 2043 | if (!tty || !info->xmit_buf) |
2044 | return 0; | 2044 | return 0; |
2045 | 2045 | ||
2046 | spin_lock_irqsave(&info->irq_spinlock,flags); | 2046 | spin_lock_irqsave(&info->irq_spinlock, flags); |
2047 | 2047 | ||
2048 | if ( (info->params.mode == MGSL_MODE_ASYNC ) || !info->tx_active ) { | 2048 | if ((info->params.mode == MGSL_MODE_ASYNC ) || !info->tx_active) { |
2049 | if (info->xmit_cnt < SERIAL_XMIT_SIZE - 1) { | 2049 | if (info->xmit_cnt < SERIAL_XMIT_SIZE - 1) { |
2050 | info->xmit_buf[info->xmit_head++] = ch; | 2050 | info->xmit_buf[info->xmit_head++] = ch; |
2051 | info->xmit_head &= SERIAL_XMIT_SIZE-1; | 2051 | info->xmit_head &= SERIAL_XMIT_SIZE-1; |
@@ -2053,7 +2053,7 @@ static int mgsl_put_char(struct tty_struct *tty, unsigned char ch) | |||
2053 | ret = 1; | 2053 | ret = 1; |
2054 | } | 2054 | } |
2055 | } | 2055 | } |
2056 | spin_unlock_irqrestore(&info->irq_spinlock,flags); | 2056 | spin_unlock_irqrestore(&info->irq_spinlock, flags); |
2057 | return ret; | 2057 | return ret; |
2058 | 2058 | ||
2059 | } /* end of mgsl_put_char() */ | 2059 | } /* end of mgsl_put_char() */ |
diff --git a/drivers/char/tty_audit.c b/drivers/char/tty_audit.c index 6342b0534f4d..3582f43345a8 100644 --- a/drivers/char/tty_audit.c +++ b/drivers/char/tty_audit.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/audit.h> | 12 | #include <linux/audit.h> |
13 | #include <linux/file.h> | 13 | #include <linux/file.h> |
14 | #include <linux/fdtable.h> | ||
14 | #include <linux/tty.h> | 15 | #include <linux/tty.h> |
15 | 16 | ||
16 | struct tty_audit_buf { | 17 | struct tty_audit_buf { |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 1d298c2cf930..49c1a2267a55 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -78,6 +78,7 @@ | |||
78 | #include <linux/tty_flip.h> | 78 | #include <linux/tty_flip.h> |
79 | #include <linux/devpts_fs.h> | 79 | #include <linux/devpts_fs.h> |
80 | #include <linux/file.h> | 80 | #include <linux/file.h> |
81 | #include <linux/fdtable.h> | ||
81 | #include <linux/console.h> | 82 | #include <linux/console.h> |
82 | #include <linux/timer.h> | 83 | #include <linux/timer.h> |
83 | #include <linux/ctype.h> | 84 | #include <linux/ctype.h> |
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index dfe6907ae15b..3edf1fc12963 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c | |||
@@ -623,8 +623,8 @@ static int __devinit hwicap_setup(struct device *dev, int id, | |||
623 | 623 | ||
624 | if (!request_mem_region(drvdata->mem_start, | 624 | if (!request_mem_region(drvdata->mem_start, |
625 | drvdata->mem_size, DRIVER_NAME)) { | 625 | drvdata->mem_size, DRIVER_NAME)) { |
626 | dev_err(dev, "Couldn't lock memory region at %p\n", | 626 | dev_err(dev, "Couldn't lock memory region at %Lx\n", |
627 | (void *)regs_res->start); | 627 | regs_res->start); |
628 | retval = -EBUSY; | 628 | retval = -EBUSY; |
629 | goto failed1; | 629 | goto failed1; |
630 | } | 630 | } |
@@ -643,7 +643,7 @@ static int __devinit hwicap_setup(struct device *dev, int id, | |||
643 | mutex_init(&drvdata->sem); | 643 | mutex_init(&drvdata->sem); |
644 | drvdata->is_open = 0; | 644 | drvdata->is_open = 0; |
645 | 645 | ||
646 | dev_info(dev, "ioremap %lx to %p with size %x\n", | 646 | dev_info(dev, "ioremap %lx to %p with size %Lx\n", |
647 | (unsigned long int)drvdata->mem_start, | 647 | (unsigned long int)drvdata->mem_start, |
648 | drvdata->base_address, drvdata->mem_size); | 648 | drvdata->base_address, drvdata->mem_size); |
649 | 649 | ||
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h index a9aa845dbe74..b27b13c5eb5a 100644 --- a/drivers/edac/edac_core.h +++ b/drivers/edac/edac_core.h | |||
@@ -97,7 +97,7 @@ extern int edac_debug_level; | |||
97 | #define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \ | 97 | #define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \ |
98 | PCI_DEVICE_ID_ ## vend ## _ ## dev | 98 | PCI_DEVICE_ID_ ## vend ## _ ## dev |
99 | 99 | ||
100 | #define dev_name(dev) (dev)->dev_name | 100 | #define edac_dev_name(dev) (dev)->dev_name |
101 | 101 | ||
102 | /* memory devices */ | 102 | /* memory devices */ |
103 | enum dev_type { | 103 | enum dev_type { |
diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c index 63372fa7ecfe..5fcd3d89c75d 100644 --- a/drivers/edac/edac_device.c +++ b/drivers/edac/edac_device.c | |||
@@ -333,7 +333,7 @@ static int add_edac_dev_to_global_list(struct edac_device_ctl_info *edac_dev) | |||
333 | fail0: | 333 | fail0: |
334 | edac_printk(KERN_WARNING, EDAC_MC, | 334 | edac_printk(KERN_WARNING, EDAC_MC, |
335 | "%s (%s) %s %s already assigned %d\n", | 335 | "%s (%s) %s %s already assigned %d\n", |
336 | rover->dev->bus_id, dev_name(rover), | 336 | rover->dev->bus_id, edac_dev_name(rover), |
337 | rover->mod_name, rover->ctl_name, rover->dev_idx); | 337 | rover->mod_name, rover->ctl_name, rover->dev_idx); |
338 | return 1; | 338 | return 1; |
339 | 339 | ||
@@ -538,7 +538,7 @@ int edac_device_add_device(struct edac_device_ctl_info *edac_dev) | |||
538 | "'%s': DEV '%s' (%s)\n", | 538 | "'%s': DEV '%s' (%s)\n", |
539 | edac_dev->mod_name, | 539 | edac_dev->mod_name, |
540 | edac_dev->ctl_name, | 540 | edac_dev->ctl_name, |
541 | dev_name(edac_dev), | 541 | edac_dev_name(edac_dev), |
542 | edac_op_state_to_string(edac_dev->op_state)); | 542 | edac_op_state_to_string(edac_dev->op_state)); |
543 | 543 | ||
544 | mutex_unlock(&device_ctls_mutex); | 544 | mutex_unlock(&device_ctls_mutex); |
@@ -599,7 +599,7 @@ struct edac_device_ctl_info *edac_device_del_device(struct device *dev) | |||
599 | edac_printk(KERN_INFO, EDAC_MC, | 599 | edac_printk(KERN_INFO, EDAC_MC, |
600 | "Removed device %d for %s %s: DEV %s\n", | 600 | "Removed device %d for %s %s: DEV %s\n", |
601 | edac_dev->dev_idx, | 601 | edac_dev->dev_idx, |
602 | edac_dev->mod_name, edac_dev->ctl_name, dev_name(edac_dev)); | 602 | edac_dev->mod_name, edac_dev->ctl_name, edac_dev_name(edac_dev)); |
603 | 603 | ||
604 | return edac_dev; | 604 | return edac_dev; |
605 | } | 605 | } |
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index a4cf1645f588..d110392d48f4 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c | |||
@@ -402,7 +402,7 @@ static int add_mc_to_global_list(struct mem_ctl_info *mci) | |||
402 | fail0: | 402 | fail0: |
403 | edac_printk(KERN_WARNING, EDAC_MC, | 403 | edac_printk(KERN_WARNING, EDAC_MC, |
404 | "%s (%s) %s %s already assigned %d\n", p->dev->bus_id, | 404 | "%s (%s) %s %s already assigned %d\n", p->dev->bus_id, |
405 | dev_name(mci), p->mod_name, p->ctl_name, p->mc_idx); | 405 | edac_dev_name(mci), p->mod_name, p->ctl_name, p->mc_idx); |
406 | return 1; | 406 | return 1; |
407 | 407 | ||
408 | fail1: | 408 | fail1: |
@@ -517,7 +517,7 @@ int edac_mc_add_mc(struct mem_ctl_info *mci) | |||
517 | 517 | ||
518 | /* Report action taken */ | 518 | /* Report action taken */ |
519 | edac_mc_printk(mci, KERN_INFO, "Giving out device to '%s' '%s':" | 519 | edac_mc_printk(mci, KERN_INFO, "Giving out device to '%s' '%s':" |
520 | " DEV %s\n", mci->mod_name, mci->ctl_name, dev_name(mci)); | 520 | " DEV %s\n", mci->mod_name, mci->ctl_name, edac_dev_name(mci)); |
521 | 521 | ||
522 | mutex_unlock(&mem_ctls_mutex); | 522 | mutex_unlock(&mem_ctls_mutex); |
523 | return 0; | 523 | return 0; |
@@ -565,7 +565,7 @@ struct mem_ctl_info *edac_mc_del_mc(struct device *dev) | |||
565 | 565 | ||
566 | edac_printk(KERN_INFO, EDAC_MC, | 566 | edac_printk(KERN_INFO, EDAC_MC, |
567 | "Removed device %d for %s %s: DEV %s\n", mci->mc_idx, | 567 | "Removed device %d for %s %s: DEV %s\n", mci->mc_idx, |
568 | mci->mod_name, mci->ctl_name, dev_name(mci)); | 568 | mci->mod_name, mci->ctl_name, edac_dev_name(mci)); |
569 | 569 | ||
570 | return mci; | 570 | return mci; |
571 | } | 571 | } |
diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c index 9b24340b52e1..22ec9d5d4312 100644 --- a/drivers/edac/edac_pci.c +++ b/drivers/edac/edac_pci.c | |||
@@ -150,7 +150,7 @@ static int add_edac_pci_to_global_list(struct edac_pci_ctl_info *pci) | |||
150 | fail0: | 150 | fail0: |
151 | edac_printk(KERN_WARNING, EDAC_PCI, | 151 | edac_printk(KERN_WARNING, EDAC_PCI, |
152 | "%s (%s) %s %s already assigned %d\n", | 152 | "%s (%s) %s %s already assigned %d\n", |
153 | rover->dev->bus_id, dev_name(rover), | 153 | rover->dev->bus_id, edac_dev_name(rover), |
154 | rover->mod_name, rover->ctl_name, rover->pci_idx); | 154 | rover->mod_name, rover->ctl_name, rover->pci_idx); |
155 | return 1; | 155 | return 1; |
156 | 156 | ||
@@ -360,7 +360,7 @@ int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx) | |||
360 | " DEV '%s' (%s)\n", | 360 | " DEV '%s' (%s)\n", |
361 | pci->mod_name, | 361 | pci->mod_name, |
362 | pci->ctl_name, | 362 | pci->ctl_name, |
363 | dev_name(pci), edac_op_state_to_string(pci->op_state)); | 363 | edac_dev_name(pci), edac_op_state_to_string(pci->op_state)); |
364 | 364 | ||
365 | mutex_unlock(&edac_pci_ctls_mutex); | 365 | mutex_unlock(&edac_pci_ctls_mutex); |
366 | return 0; | 366 | return 0; |
@@ -415,7 +415,7 @@ struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev) | |||
415 | 415 | ||
416 | edac_printk(KERN_INFO, EDAC_PCI, | 416 | edac_printk(KERN_INFO, EDAC_PCI, |
417 | "Removed device %d for %s %s: DEV %s\n", | 417 | "Removed device %d for %s %s: DEV %s\n", |
418 | pci->pci_idx, pci->mod_name, pci->ctl_name, dev_name(pci)); | 418 | pci->pci_idx, pci->mod_name, pci->ctl_name, edac_dev_name(pci)); |
419 | 419 | ||
420 | return pci; | 420 | return pci; |
421 | } | 421 | } |
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index 2a999373863e..b2458bb8e9ca 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c | |||
@@ -784,7 +784,7 @@ static void sbp2_release_target(struct kref *kref) | |||
784 | kfree(lu); | 784 | kfree(lu); |
785 | } | 785 | } |
786 | scsi_remove_host(shost); | 786 | scsi_remove_host(shost); |
787 | fw_notify("released %s\n", tgt->bus_id); | 787 | fw_notify("released %s, target %d:0:0\n", tgt->bus_id, shost->host_no); |
788 | 788 | ||
789 | fw_unit_put(tgt->unit); | 789 | fw_unit_put(tgt->unit); |
790 | scsi_host_put(shost); | 790 | scsi_host_put(shost); |
@@ -1487,7 +1487,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) | |||
1487 | if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0) | 1487 | if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0) |
1488 | goto out; | 1488 | goto out; |
1489 | 1489 | ||
1490 | memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd)); | 1490 | memcpy(orb->request.command_block, cmd->cmnd, cmd->cmd_len); |
1491 | 1491 | ||
1492 | orb->base.callback = complete_command_orb; | 1492 | orb->base.callback = complete_command_orb; |
1493 | orb->base.request_bus = | 1493 | orb->base.request_bus = |
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c index 5a99e81d2784..93f916720b13 100644 --- a/drivers/gpio/pca953x.c +++ b/drivers/gpio/pca953x.c | |||
@@ -30,6 +30,8 @@ static const struct i2c_device_id pca953x_id[] = { | |||
30 | { "pca9537", 4, }, | 30 | { "pca9537", 4, }, |
31 | { "pca9538", 8, }, | 31 | { "pca9538", 8, }, |
32 | { "pca9539", 16, }, | 32 | { "pca9539", 16, }, |
33 | { "pca9555", 16, }, | ||
34 | { "pca9557", 8, }, | ||
33 | /* REVISIT several pca955x parts should work here too */ | 35 | /* REVISIT several pca955x parts should work here too */ |
34 | { } | 36 | { } |
35 | }; | 37 | }; |
@@ -193,7 +195,7 @@ static int __devinit pca953x_probe(struct i2c_client *client, | |||
193 | { | 195 | { |
194 | struct pca953x_platform_data *pdata; | 196 | struct pca953x_platform_data *pdata; |
195 | struct pca953x_chip *chip; | 197 | struct pca953x_chip *chip; |
196 | int ret, i; | 198 | int ret; |
197 | 199 | ||
198 | pdata = client->dev.platform_data; | 200 | pdata = client->dev.platform_data; |
199 | if (pdata == NULL) | 201 | if (pdata == NULL) |
diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c index 9587869bdba0..c1009d6f9796 100644 --- a/drivers/hwmon/adt7473.c +++ b/drivers/hwmon/adt7473.c | |||
@@ -422,18 +422,14 @@ static ssize_t show_volt(struct device *dev, struct device_attribute *devattr, | |||
422 | * number in the range -128 to 127, or as an unsigned number that must | 422 | * number in the range -128 to 127, or as an unsigned number that must |
423 | * be offset by 64. | 423 | * be offset by 64. |
424 | */ | 424 | */ |
425 | static int decode_temp(struct adt7473_data *data, u8 raw) | 425 | static int decode_temp(u8 twos_complement, u8 raw) |
426 | { | 426 | { |
427 | if (data->temp_twos_complement) | 427 | return twos_complement ? (s8)raw : raw - 64; |
428 | return (s8)raw; | ||
429 | return raw - 64; | ||
430 | } | 428 | } |
431 | 429 | ||
432 | static u8 encode_temp(struct adt7473_data *data, int cooked) | 430 | static u8 encode_temp(u8 twos_complement, int cooked) |
433 | { | 431 | { |
434 | if (data->temp_twos_complement) | 432 | return twos_complement ? cooked & 0xFF : cooked + 64; |
435 | return (cooked & 0xFF); | ||
436 | return cooked + 64; | ||
437 | } | 433 | } |
438 | 434 | ||
439 | static ssize_t show_temp_min(struct device *dev, | 435 | static ssize_t show_temp_min(struct device *dev, |
@@ -442,8 +438,9 @@ static ssize_t show_temp_min(struct device *dev, | |||
442 | { | 438 | { |
443 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 439 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
444 | struct adt7473_data *data = adt7473_update_device(dev); | 440 | struct adt7473_data *data = adt7473_update_device(dev); |
445 | return sprintf(buf, "%d\n", | 441 | return sprintf(buf, "%d\n", 1000 * decode_temp( |
446 | 1000 * decode_temp(data, data->temp_min[attr->index])); | 442 | data->temp_twos_complement, |
443 | data->temp_min[attr->index])); | ||
447 | } | 444 | } |
448 | 445 | ||
449 | static ssize_t set_temp_min(struct device *dev, | 446 | static ssize_t set_temp_min(struct device *dev, |
@@ -455,7 +452,7 @@ static ssize_t set_temp_min(struct device *dev, | |||
455 | struct i2c_client *client = to_i2c_client(dev); | 452 | struct i2c_client *client = to_i2c_client(dev); |
456 | struct adt7473_data *data = i2c_get_clientdata(client); | 453 | struct adt7473_data *data = i2c_get_clientdata(client); |
457 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 454 | int temp = simple_strtol(buf, NULL, 10) / 1000; |
458 | temp = encode_temp(data, temp); | 455 | temp = encode_temp(data->temp_twos_complement, temp); |
459 | 456 | ||
460 | mutex_lock(&data->lock); | 457 | mutex_lock(&data->lock); |
461 | data->temp_min[attr->index] = temp; | 458 | data->temp_min[attr->index] = temp; |
@@ -472,8 +469,9 @@ static ssize_t show_temp_max(struct device *dev, | |||
472 | { | 469 | { |
473 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 470 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
474 | struct adt7473_data *data = adt7473_update_device(dev); | 471 | struct adt7473_data *data = adt7473_update_device(dev); |
475 | return sprintf(buf, "%d\n", | 472 | return sprintf(buf, "%d\n", 1000 * decode_temp( |
476 | 1000 * decode_temp(data, data->temp_max[attr->index])); | 473 | data->temp_twos_complement, |
474 | data->temp_max[attr->index])); | ||
477 | } | 475 | } |
478 | 476 | ||
479 | static ssize_t set_temp_max(struct device *dev, | 477 | static ssize_t set_temp_max(struct device *dev, |
@@ -485,7 +483,7 @@ static ssize_t set_temp_max(struct device *dev, | |||
485 | struct i2c_client *client = to_i2c_client(dev); | 483 | struct i2c_client *client = to_i2c_client(dev); |
486 | struct adt7473_data *data = i2c_get_clientdata(client); | 484 | struct adt7473_data *data = i2c_get_clientdata(client); |
487 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 485 | int temp = simple_strtol(buf, NULL, 10) / 1000; |
488 | temp = encode_temp(data, temp); | 486 | temp = encode_temp(data->temp_twos_complement, temp); |
489 | 487 | ||
490 | mutex_lock(&data->lock); | 488 | mutex_lock(&data->lock); |
491 | data->temp_max[attr->index] = temp; | 489 | data->temp_max[attr->index] = temp; |
@@ -501,8 +499,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, | |||
501 | { | 499 | { |
502 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 500 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
503 | struct adt7473_data *data = adt7473_update_device(dev); | 501 | struct adt7473_data *data = adt7473_update_device(dev); |
504 | return sprintf(buf, "%d\n", | 502 | return sprintf(buf, "%d\n", 1000 * decode_temp( |
505 | 1000 * decode_temp(data, data->temp[attr->index])); | 503 | data->temp_twos_complement, |
504 | data->temp[attr->index])); | ||
506 | } | 505 | } |
507 | 506 | ||
508 | static ssize_t show_fan_min(struct device *dev, | 507 | static ssize_t show_fan_min(struct device *dev, |
@@ -671,8 +670,9 @@ static ssize_t show_temp_tmax(struct device *dev, | |||
671 | { | 670 | { |
672 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 671 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
673 | struct adt7473_data *data = adt7473_update_device(dev); | 672 | struct adt7473_data *data = adt7473_update_device(dev); |
674 | return sprintf(buf, "%d\n", | 673 | return sprintf(buf, "%d\n", 1000 * decode_temp( |
675 | 1000 * decode_temp(data, data->temp_tmax[attr->index])); | 674 | data->temp_twos_complement, |
675 | data->temp_tmax[attr->index])); | ||
676 | } | 676 | } |
677 | 677 | ||
678 | static ssize_t set_temp_tmax(struct device *dev, | 678 | static ssize_t set_temp_tmax(struct device *dev, |
@@ -684,7 +684,7 @@ static ssize_t set_temp_tmax(struct device *dev, | |||
684 | struct i2c_client *client = to_i2c_client(dev); | 684 | struct i2c_client *client = to_i2c_client(dev); |
685 | struct adt7473_data *data = i2c_get_clientdata(client); | 685 | struct adt7473_data *data = i2c_get_clientdata(client); |
686 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 686 | int temp = simple_strtol(buf, NULL, 10) / 1000; |
687 | temp = encode_temp(data, temp); | 687 | temp = encode_temp(data->temp_twos_complement, temp); |
688 | 688 | ||
689 | mutex_lock(&data->lock); | 689 | mutex_lock(&data->lock); |
690 | data->temp_tmax[attr->index] = temp; | 690 | data->temp_tmax[attr->index] = temp; |
@@ -701,8 +701,9 @@ static ssize_t show_temp_tmin(struct device *dev, | |||
701 | { | 701 | { |
702 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 702 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
703 | struct adt7473_data *data = adt7473_update_device(dev); | 703 | struct adt7473_data *data = adt7473_update_device(dev); |
704 | return sprintf(buf, "%d\n", | 704 | return sprintf(buf, "%d\n", 1000 * decode_temp( |
705 | 1000 * decode_temp(data, data->temp_tmin[attr->index])); | 705 | data->temp_twos_complement, |
706 | data->temp_tmin[attr->index])); | ||
706 | } | 707 | } |
707 | 708 | ||
708 | static ssize_t set_temp_tmin(struct device *dev, | 709 | static ssize_t set_temp_tmin(struct device *dev, |
@@ -714,7 +715,7 @@ static ssize_t set_temp_tmin(struct device *dev, | |||
714 | struct i2c_client *client = to_i2c_client(dev); | 715 | struct i2c_client *client = to_i2c_client(dev); |
715 | struct adt7473_data *data = i2c_get_clientdata(client); | 716 | struct adt7473_data *data = i2c_get_clientdata(client); |
716 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 717 | int temp = simple_strtol(buf, NULL, 10) / 1000; |
717 | temp = encode_temp(data, temp); | 718 | temp = encode_temp(data->temp_twos_complement, temp); |
718 | 719 | ||
719 | mutex_lock(&data->lock); | 720 | mutex_lock(&data->lock); |
720 | data->temp_tmin[attr->index] = temp; | 721 | data->temp_tmin[attr->index] = temp; |
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 84712a22acea..fe2eea4d799b 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -953,12 +953,8 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
953 | static void asb100_init_client(struct i2c_client *client) | 953 | static void asb100_init_client(struct i2c_client *client) |
954 | { | 954 | { |
955 | struct asb100_data *data = i2c_get_clientdata(client); | 955 | struct asb100_data *data = i2c_get_clientdata(client); |
956 | int vid = 0; | ||
957 | 956 | ||
958 | vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f; | ||
959 | vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4; | ||
960 | data->vrm = vid_which_vrm(); | 957 | data->vrm = vid_which_vrm(); |
961 | vid = vid_from_reg(vid, data->vrm); | ||
962 | 958 | ||
963 | /* Start monitoring */ | 959 | /* Start monitoring */ |
964 | asb100_write_value(client, ASB100_REG_CONFIG, | 960 | asb100_write_value(client, ASB100_REG_CONFIG, |
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 115f4090b98e..fa7696905154 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -248,7 +248,7 @@ static int lm75_detach_client(struct i2c_client *client) | |||
248 | 248 | ||
249 | /* All registers are word-sized, except for the configuration register. | 249 | /* All registers are word-sized, except for the configuration register. |
250 | LM75 uses a high-byte first convention, which is exactly opposite to | 250 | LM75 uses a high-byte first convention, which is exactly opposite to |
251 | the usual practice. */ | 251 | the SMBus standard. */ |
252 | static int lm75_read_value(struct i2c_client *client, u8 reg) | 252 | static int lm75_read_value(struct i2c_client *client, u8 reg) |
253 | { | 253 | { |
254 | if (reg == LM75_REG_CONF) | 254 | if (reg == LM75_REG_CONF) |
@@ -257,9 +257,6 @@ static int lm75_read_value(struct i2c_client *client, u8 reg) | |||
257 | return swab16(i2c_smbus_read_word_data(client, reg)); | 257 | return swab16(i2c_smbus_read_word_data(client, reg)); |
258 | } | 258 | } |
259 | 259 | ||
260 | /* All registers are word-sized, except for the configuration register. | ||
261 | LM75 uses a high-byte first convention, which is exactly opposite to | ||
262 | the usual practice. */ | ||
263 | static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) | 260 | static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) |
264 | { | 261 | { |
265 | if (reg == LM75_REG_CONF) | 262 | if (reg == LM75_REG_CONF) |
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index f61d8f4185b2..eb03544c731c 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c | |||
@@ -335,11 +335,23 @@ exit: | |||
335 | static int __init smsc47b397_find(unsigned short *addr) | 335 | static int __init smsc47b397_find(unsigned short *addr) |
336 | { | 336 | { |
337 | u8 id, rev; | 337 | u8 id, rev; |
338 | char *name; | ||
338 | 339 | ||
339 | superio_enter(); | 340 | superio_enter(); |
340 | id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); | 341 | id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); |
341 | 342 | ||
342 | if ((id != 0x6f) && (id != 0x81) && (id != 0x85)) { | 343 | switch(id) { |
344 | case 0x81: | ||
345 | name = "SCH5307-NS"; | ||
346 | break; | ||
347 | case 0x6f: | ||
348 | name = "LPC47B397-NC"; | ||
349 | break; | ||
350 | case 0x85: | ||
351 | case 0x8c: | ||
352 | name = "SCH5317"; | ||
353 | break; | ||
354 | default: | ||
343 | superio_exit(); | 355 | superio_exit(); |
344 | return -ENODEV; | 356 | return -ENODEV; |
345 | } | 357 | } |
@@ -352,8 +364,7 @@ static int __init smsc47b397_find(unsigned short *addr) | |||
352 | 364 | ||
353 | printk(KERN_INFO DRVNAME ": found SMSC %s " | 365 | printk(KERN_INFO DRVNAME ": found SMSC %s " |
354 | "(base address 0x%04x, revision %u)\n", | 366 | "(base address 0x%04x, revision %u)\n", |
355 | id == 0x81 ? "SCH5307-NS" : id == 0x85 ? "SCH5317" : | 367 | name, *addr, rev); |
356 | "LPC47B397-NC", *addr, rev); | ||
357 | 368 | ||
358 | superio_exit(); | 369 | superio_exit(); |
359 | return 0; | 370 | return 0; |
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c index ee35af93b574..ed3c019b78c7 100644 --- a/drivers/hwmon/w83793.c +++ b/drivers/hwmon/w83793.c | |||
@@ -1024,10 +1024,9 @@ static struct sensor_device_attribute_2 w83793_vid[] = { | |||
1024 | SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0), | 1024 | SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0), |
1025 | SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1), | 1025 | SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1), |
1026 | }; | 1026 | }; |
1027 | static DEVICE_ATTR(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm); | ||
1027 | 1028 | ||
1028 | static struct sensor_device_attribute_2 sda_single_files[] = { | 1029 | static struct sensor_device_attribute_2 sda_single_files[] = { |
1029 | SENSOR_ATTR_2(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm, | ||
1030 | NOT_USED, NOT_USED), | ||
1031 | SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, | 1030 | SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, |
1032 | store_chassis_clear, ALARM_STATUS, 30), | 1031 | store_chassis_clear, ALARM_STATUS, 30), |
1033 | SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, | 1032 | SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, |
@@ -1080,6 +1079,7 @@ static int w83793_detach_client(struct i2c_client *client) | |||
1080 | 1079 | ||
1081 | for (i = 0; i < ARRAY_SIZE(w83793_vid); i++) | 1080 | for (i = 0; i < ARRAY_SIZE(w83793_vid); i++) |
1082 | device_remove_file(dev, &w83793_vid[i].dev_attr); | 1081 | device_remove_file(dev, &w83793_vid[i].dev_attr); |
1082 | device_remove_file(dev, &dev_attr_vrm); | ||
1083 | 1083 | ||
1084 | for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) | 1084 | for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) |
1085 | device_remove_file(dev, &w83793_left_fan[i].dev_attr); | 1085 | device_remove_file(dev, &w83793_left_fan[i].dev_attr); |
@@ -1282,7 +1282,6 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1282 | /* Initialize the chip */ | 1282 | /* Initialize the chip */ |
1283 | w83793_init_client(client); | 1283 | w83793_init_client(client); |
1284 | 1284 | ||
1285 | data->vrm = vid_which_vrm(); | ||
1286 | /* | 1285 | /* |
1287 | Only fan 1-5 has their own input pins, | 1286 | Only fan 1-5 has their own input pins, |
1288 | Pwm 1-3 has their own pins | 1287 | Pwm 1-3 has their own pins |
@@ -1293,7 +1292,9 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1293 | val = w83793_read_value(client, W83793_REG_FANIN_CTRL); | 1292 | val = w83793_read_value(client, W83793_REG_FANIN_CTRL); |
1294 | 1293 | ||
1295 | /* check the function of pins 49-56 */ | 1294 | /* check the function of pins 49-56 */ |
1296 | if (!(tmp & 0x80)) { | 1295 | if (tmp & 0x80) { |
1296 | data->has_vid |= 0x2; /* has VIDB */ | ||
1297 | } else { | ||
1297 | data->has_pwm |= 0x18; /* pwm 4,5 */ | 1298 | data->has_pwm |= 0x18; /* pwm 4,5 */ |
1298 | if (val & 0x01) { /* fan 6 */ | 1299 | if (val & 0x01) { /* fan 6 */ |
1299 | data->has_fan |= 0x20; | 1300 | data->has_fan |= 0x20; |
@@ -1309,13 +1310,15 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1309 | } | 1310 | } |
1310 | } | 1311 | } |
1311 | 1312 | ||
1313 | /* check the function of pins 37-40 */ | ||
1314 | if (!(tmp & 0x29)) | ||
1315 | data->has_vid |= 0x1; /* has VIDA */ | ||
1312 | if (0x08 == (tmp & 0x0c)) { | 1316 | if (0x08 == (tmp & 0x0c)) { |
1313 | if (val & 0x08) /* fan 9 */ | 1317 | if (val & 0x08) /* fan 9 */ |
1314 | data->has_fan |= 0x100; | 1318 | data->has_fan |= 0x100; |
1315 | if (val & 0x10) /* fan 10 */ | 1319 | if (val & 0x10) /* fan 10 */ |
1316 | data->has_fan |= 0x200; | 1320 | data->has_fan |= 0x200; |
1317 | } | 1321 | } |
1318 | |||
1319 | if (0x20 == (tmp & 0x30)) { | 1322 | if (0x20 == (tmp & 0x30)) { |
1320 | if (val & 0x20) /* fan 11 */ | 1323 | if (val & 0x20) /* fan 11 */ |
1321 | data->has_fan |= 0x400; | 1324 | data->has_fan |= 0x400; |
@@ -1359,13 +1362,6 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1359 | if (tmp & 0x02) | 1362 | if (tmp & 0x02) |
1360 | data->has_temp |= 0x20; | 1363 | data->has_temp |= 0x20; |
1361 | 1364 | ||
1362 | /* Detect the VID usage and ignore unused input */ | ||
1363 | tmp = w83793_read_value(client, W83793_REG_MFC); | ||
1364 | if (!(tmp & 0x29)) | ||
1365 | data->has_vid |= 0x1; /* has VIDA */ | ||
1366 | if (tmp & 0x80) | ||
1367 | data->has_vid |= 0x2; /* has VIDB */ | ||
1368 | |||
1369 | /* Register sysfs hooks */ | 1365 | /* Register sysfs hooks */ |
1370 | for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) { | 1366 | for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) { |
1371 | err = device_create_file(dev, | 1367 | err = device_create_file(dev, |
@@ -1381,6 +1377,12 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1381 | if (err) | 1377 | if (err) |
1382 | goto exit_remove; | 1378 | goto exit_remove; |
1383 | } | 1379 | } |
1380 | if (data->has_vid) { | ||
1381 | data->vrm = vid_which_vrm(); | ||
1382 | err = device_create_file(dev, &dev_attr_vrm); | ||
1383 | if (err) | ||
1384 | goto exit_remove; | ||
1385 | } | ||
1384 | 1386 | ||
1385 | for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { | 1387 | for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { |
1386 | err = device_create_file(dev, &sda_single_files[i].dev_attr); | 1388 | err = device_create_file(dev, &sda_single_files[i].dev_attr); |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 77f2d482888b..52e268e25dab 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -301,8 +301,8 @@ static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval) | |||
301 | msleep(i); | 301 | msleep(i); |
302 | } | 302 | } |
303 | 303 | ||
304 | dev_err(&client->dev, "Couldn't read value from register 0x%02x. " | 304 | dev_err(&client->dev, "Couldn't read value from register 0x%02x.\n", |
305 | "Please report.\n", reg); | 305 | reg); |
306 | return defval; | 306 | return defval; |
307 | } | 307 | } |
308 | 308 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 099a0fe1745b..34b0d4f26b58 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -1347,19 +1347,14 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1347 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) | 1347 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) |
1348 | hwif->irq = port ? 15 : 14; | 1348 | hwif->irq = port ? 15 : 14; |
1349 | 1349 | ||
1350 | hwif->host_flags = d->host_flags; | 1350 | /* ->host_flags may be set by ->init_iops (or even earlier...) */ |
1351 | hwif->host_flags |= d->host_flags; | ||
1351 | hwif->pio_mask = d->pio_mask; | 1352 | hwif->pio_mask = d->pio_mask; |
1352 | 1353 | ||
1353 | /* ->set_pio_mode for DTC2278 is currently limited to port 0 */ | 1354 | /* ->set_pio_mode for DTC2278 is currently limited to port 0 */ |
1354 | if (hwif->chipset != ide_dtc2278 || hwif->channel == 0) | 1355 | if (hwif->chipset != ide_dtc2278 || hwif->channel == 0) |
1355 | hwif->port_ops = d->port_ops; | 1356 | hwif->port_ops = d->port_ops; |
1356 | 1357 | ||
1357 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) || | ||
1358 | ((d->host_flags & IDE_HFLAG_SERIALIZE_DMA) && hwif->dma_base)) { | ||
1359 | if (hwif->mate) | ||
1360 | hwif->mate->serialized = hwif->serialized = 1; | ||
1361 | } | ||
1362 | |||
1363 | hwif->swdma_mask = d->swdma_mask; | 1358 | hwif->swdma_mask = d->swdma_mask; |
1364 | hwif->mwdma_mask = d->mwdma_mask; | 1359 | hwif->mwdma_mask = d->mwdma_mask; |
1365 | hwif->ultra_mask = d->udma_mask; | 1360 | hwif->ultra_mask = d->udma_mask; |
@@ -1381,6 +1376,12 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1381 | hwif->dma_ops = d->dma_ops; | 1376 | hwif->dma_ops = d->dma_ops; |
1382 | } | 1377 | } |
1383 | 1378 | ||
1379 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) || | ||
1380 | ((d->host_flags & IDE_HFLAG_SERIALIZE_DMA) && hwif->dma_base)) { | ||
1381 | if (hwif->mate) | ||
1382 | hwif->mate->serialized = hwif->serialized = 1; | ||
1383 | } | ||
1384 | |||
1384 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) | 1385 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) |
1385 | hwif->rqsize = 256; | 1386 | hwif->rqsize = 256; |
1386 | 1387 | ||
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index 83555ca513b5..9e449a0c623f 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
@@ -61,7 +61,7 @@ static void falconide_output_data(ide_drive_t *drive, struct request *rq, | |||
61 | unsigned long data_addr = drive->hwif->io_ports.data_addr; | 61 | unsigned long data_addr = drive->hwif->io_ports.data_addr; |
62 | 62 | ||
63 | if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS) | 63 | if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS) |
64 | return outsw(data_adr, buf, (len + 1) / 2); | 64 | return outsw(data_addr, buf, (len + 1) / 2); |
65 | 65 | ||
66 | outsw_swapw(data_addr, buf, (len + 1) / 2); | 66 | outsw_swapw(data_addr, buf, (len + 1) / 2); |
67 | } | 67 | } |
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 29d833e71cbf..05710c7c1220 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c | |||
@@ -520,8 +520,11 @@ static ssize_t fw_show_drv_device_ids(struct device_driver *drv, char *buf) | |||
520 | char *scratch = buf; | 520 | char *scratch = buf; |
521 | 521 | ||
522 | driver = container_of(drv, struct hpsb_protocol_driver, driver); | 522 | driver = container_of(drv, struct hpsb_protocol_driver, driver); |
523 | id = driver->id_table; | ||
524 | if (!id) | ||
525 | return 0; | ||
523 | 526 | ||
524 | for (id = driver->id_table; id->match_flags != 0; id++) { | 527 | for (; id->match_flags != 0; id++) { |
525 | int need_coma = 0; | 528 | int need_coma = 0; |
526 | 529 | ||
527 | if (id->match_flags & IEEE1394_MATCH_VENDOR_ID) { | 530 | if (id->match_flags & IEEE1394_MATCH_VENDOR_ID) { |
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c index ed2ee4ba4b7c..5fd8506a8657 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_hal.c +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c | |||
@@ -359,9 +359,10 @@ static void insert_recv_cqe(struct t3_wq *wq, struct t3_cq *cq) | |||
359 | cq->sw_wptr++; | 359 | cq->sw_wptr++; |
360 | } | 360 | } |
361 | 361 | ||
362 | void cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count) | 362 | int cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count) |
363 | { | 363 | { |
364 | u32 ptr; | 364 | u32 ptr; |
365 | int flushed = 0; | ||
365 | 366 | ||
366 | PDBG("%s wq %p cq %p\n", __func__, wq, cq); | 367 | PDBG("%s wq %p cq %p\n", __func__, wq, cq); |
367 | 368 | ||
@@ -369,8 +370,11 @@ void cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count) | |||
369 | PDBG("%s rq_rptr %u rq_wptr %u skip count %u\n", __func__, | 370 | PDBG("%s rq_rptr %u rq_wptr %u skip count %u\n", __func__, |
370 | wq->rq_rptr, wq->rq_wptr, count); | 371 | wq->rq_rptr, wq->rq_wptr, count); |
371 | ptr = wq->rq_rptr + count; | 372 | ptr = wq->rq_rptr + count; |
372 | while (ptr++ != wq->rq_wptr) | 373 | while (ptr++ != wq->rq_wptr) { |
373 | insert_recv_cqe(wq, cq); | 374 | insert_recv_cqe(wq, cq); |
375 | flushed++; | ||
376 | } | ||
377 | return flushed; | ||
374 | } | 378 | } |
375 | 379 | ||
376 | static void insert_sq_cqe(struct t3_wq *wq, struct t3_cq *cq, | 380 | static void insert_sq_cqe(struct t3_wq *wq, struct t3_cq *cq, |
@@ -394,9 +398,10 @@ static void insert_sq_cqe(struct t3_wq *wq, struct t3_cq *cq, | |||
394 | cq->sw_wptr++; | 398 | cq->sw_wptr++; |
395 | } | 399 | } |
396 | 400 | ||
397 | void cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count) | 401 | int cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count) |
398 | { | 402 | { |
399 | __u32 ptr; | 403 | __u32 ptr; |
404 | int flushed = 0; | ||
400 | struct t3_swsq *sqp = wq->sq + Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2); | 405 | struct t3_swsq *sqp = wq->sq + Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2); |
401 | 406 | ||
402 | ptr = wq->sq_rptr + count; | 407 | ptr = wq->sq_rptr + count; |
@@ -405,7 +410,9 @@ void cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count) | |||
405 | insert_sq_cqe(wq, cq, sqp); | 410 | insert_sq_cqe(wq, cq, sqp); |
406 | sqp++; | 411 | sqp++; |
407 | ptr++; | 412 | ptr++; |
413 | flushed++; | ||
408 | } | 414 | } |
415 | return flushed; | ||
409 | } | 416 | } |
410 | 417 | ||
411 | /* | 418 | /* |
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.h b/drivers/infiniband/hw/cxgb3/cxio_hal.h index 2bcff7f5046e..69ab08ebc680 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_hal.h +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.h | |||
@@ -173,8 +173,8 @@ u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp); | |||
173 | void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid); | 173 | void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid); |
174 | int __init cxio_hal_init(void); | 174 | int __init cxio_hal_init(void); |
175 | void __exit cxio_hal_exit(void); | 175 | void __exit cxio_hal_exit(void); |
176 | void cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count); | 176 | int cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count); |
177 | void cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count); | 177 | int cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count); |
178 | void cxio_count_rcqes(struct t3_cq *cq, struct t3_wq *wq, int *count); | 178 | void cxio_count_rcqes(struct t3_cq *cq, struct t3_wq *wq, int *count); |
179 | void cxio_count_scqes(struct t3_cq *cq, struct t3_wq *wq, int *count); | 179 | void cxio_count_scqes(struct t3_cq *cq, struct t3_wq *wq, int *count); |
180 | void cxio_flush_hw_cq(struct t3_cq *cq); | 180 | void cxio_flush_hw_cq(struct t3_cq *cq); |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c index d44a6df9ad8c..c325c44807e8 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_cm.c +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c | |||
@@ -67,10 +67,10 @@ int peer2peer = 0; | |||
67 | module_param(peer2peer, int, 0644); | 67 | module_param(peer2peer, int, 0644); |
68 | MODULE_PARM_DESC(peer2peer, "Support peer2peer ULPs (default=0)"); | 68 | MODULE_PARM_DESC(peer2peer, "Support peer2peer ULPs (default=0)"); |
69 | 69 | ||
70 | static int ep_timeout_secs = 10; | 70 | static int ep_timeout_secs = 60; |
71 | module_param(ep_timeout_secs, int, 0644); | 71 | module_param(ep_timeout_secs, int, 0644); |
72 | MODULE_PARM_DESC(ep_timeout_secs, "CM Endpoint operation timeout " | 72 | MODULE_PARM_DESC(ep_timeout_secs, "CM Endpoint operation timeout " |
73 | "in seconds (default=10)"); | 73 | "in seconds (default=60)"); |
74 | 74 | ||
75 | static int mpa_rev = 1; | 75 | static int mpa_rev = 1; |
76 | module_param(mpa_rev, int, 0644); | 76 | module_param(mpa_rev, int, 0644); |
@@ -1650,8 +1650,8 @@ static int close_con_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) | |||
1650 | release = 1; | 1650 | release = 1; |
1651 | break; | 1651 | break; |
1652 | case ABORTING: | 1652 | case ABORTING: |
1653 | break; | ||
1654 | case DEAD: | 1653 | case DEAD: |
1654 | break; | ||
1655 | default: | 1655 | default: |
1656 | BUG_ON(1); | 1656 | BUG_ON(1); |
1657 | break; | 1657 | break; |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c index 9b4be889c58e..79dbe5beae52 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_qp.c +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c | |||
@@ -655,6 +655,7 @@ static void __flush_qp(struct iwch_qp *qhp, unsigned long *flag) | |||
655 | { | 655 | { |
656 | struct iwch_cq *rchp, *schp; | 656 | struct iwch_cq *rchp, *schp; |
657 | int count; | 657 | int count; |
658 | int flushed; | ||
658 | 659 | ||
659 | rchp = get_chp(qhp->rhp, qhp->attr.rcq); | 660 | rchp = get_chp(qhp->rhp, qhp->attr.rcq); |
660 | schp = get_chp(qhp->rhp, qhp->attr.scq); | 661 | schp = get_chp(qhp->rhp, qhp->attr.scq); |
@@ -669,20 +670,22 @@ static void __flush_qp(struct iwch_qp *qhp, unsigned long *flag) | |||
669 | spin_lock(&qhp->lock); | 670 | spin_lock(&qhp->lock); |
670 | cxio_flush_hw_cq(&rchp->cq); | 671 | cxio_flush_hw_cq(&rchp->cq); |
671 | cxio_count_rcqes(&rchp->cq, &qhp->wq, &count); | 672 | cxio_count_rcqes(&rchp->cq, &qhp->wq, &count); |
672 | cxio_flush_rq(&qhp->wq, &rchp->cq, count); | 673 | flushed = cxio_flush_rq(&qhp->wq, &rchp->cq, count); |
673 | spin_unlock(&qhp->lock); | 674 | spin_unlock(&qhp->lock); |
674 | spin_unlock_irqrestore(&rchp->lock, *flag); | 675 | spin_unlock_irqrestore(&rchp->lock, *flag); |
675 | (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context); | 676 | if (flushed) |
677 | (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context); | ||
676 | 678 | ||
677 | /* locking heirarchy: cq lock first, then qp lock. */ | 679 | /* locking heirarchy: cq lock first, then qp lock. */ |
678 | spin_lock_irqsave(&schp->lock, *flag); | 680 | spin_lock_irqsave(&schp->lock, *flag); |
679 | spin_lock(&qhp->lock); | 681 | spin_lock(&qhp->lock); |
680 | cxio_flush_hw_cq(&schp->cq); | 682 | cxio_flush_hw_cq(&schp->cq); |
681 | cxio_count_scqes(&schp->cq, &qhp->wq, &count); | 683 | cxio_count_scqes(&schp->cq, &qhp->wq, &count); |
682 | cxio_flush_sq(&qhp->wq, &schp->cq, count); | 684 | flushed = cxio_flush_sq(&qhp->wq, &schp->cq, count); |
683 | spin_unlock(&qhp->lock); | 685 | spin_unlock(&qhp->lock); |
684 | spin_unlock_irqrestore(&schp->lock, *flag); | 686 | spin_unlock_irqrestore(&schp->lock, *flag); |
685 | (*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context); | 687 | if (flushed) |
688 | (*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context); | ||
686 | 689 | ||
687 | /* deref */ | 690 | /* deref */ |
688 | if (atomic_dec_and_test(&qhp->refcnt)) | 691 | if (atomic_dec_and_test(&qhp->refcnt)) |
@@ -880,7 +883,6 @@ int iwch_modify_qp(struct iwch_dev *rhp, struct iwch_qp *qhp, | |||
880 | ep = qhp->ep; | 883 | ep = qhp->ep; |
881 | get_ep(&ep->com); | 884 | get_ep(&ep->com); |
882 | } | 885 | } |
883 | flush_qp(qhp, &flag); | ||
884 | break; | 886 | break; |
885 | case IWCH_QP_STATE_TERMINATE: | 887 | case IWCH_QP_STATE_TERMINATE: |
886 | qhp->attr.state = IWCH_QP_STATE_TERMINATE; | 888 | qhp->attr.state = IWCH_QP_STATE_TERMINATE; |
@@ -911,6 +913,7 @@ int iwch_modify_qp(struct iwch_dev *rhp, struct iwch_qp *qhp, | |||
911 | } | 913 | } |
912 | switch (attrs->next_state) { | 914 | switch (attrs->next_state) { |
913 | case IWCH_QP_STATE_IDLE: | 915 | case IWCH_QP_STATE_IDLE: |
916 | flush_qp(qhp, &flag); | ||
914 | qhp->attr.state = IWCH_QP_STATE_IDLE; | 917 | qhp->attr.state = IWCH_QP_STATE_IDLE; |
915 | qhp->attr.llp_stream_handle = NULL; | 918 | qhp->attr.llp_stream_handle = NULL; |
916 | put_ep(&qhp->ep->com); | 919 | put_ep(&qhp->ep->com); |
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c index 2515cbde7e65..bc3b37d2070f 100644 --- a/drivers/infiniband/hw/ehca/ehca_hca.c +++ b/drivers/infiniband/hw/ehca/ehca_hca.c | |||
@@ -101,7 +101,6 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) | |||
101 | props->max_ee = limit_uint(rblock->max_rd_ee_context); | 101 | props->max_ee = limit_uint(rblock->max_rd_ee_context); |
102 | props->max_rdd = limit_uint(rblock->max_rd_domain); | 102 | props->max_rdd = limit_uint(rblock->max_rd_domain); |
103 | props->max_fmr = limit_uint(rblock->max_mr); | 103 | props->max_fmr = limit_uint(rblock->max_mr); |
104 | props->local_ca_ack_delay = limit_uint(rblock->local_ca_ack_delay); | ||
105 | props->max_qp_rd_atom = limit_uint(rblock->max_rr_qp); | 104 | props->max_qp_rd_atom = limit_uint(rblock->max_rr_qp); |
106 | props->max_ee_rd_atom = limit_uint(rblock->max_rr_ee_context); | 105 | props->max_ee_rd_atom = limit_uint(rblock->max_rr_ee_context); |
107 | props->max_res_rd_atom = limit_uint(rblock->max_rr_hca); | 106 | props->max_res_rd_atom = limit_uint(rblock->max_rr_hca); |
@@ -115,7 +114,7 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) | |||
115 | } | 114 | } |
116 | 115 | ||
117 | props->max_pkeys = 16; | 116 | props->max_pkeys = 16; |
118 | props->local_ca_ack_delay = limit_uint(rblock->local_ca_ack_delay); | 117 | props->local_ca_ack_delay = min_t(u8, rblock->local_ca_ack_delay, 255); |
119 | props->max_raw_ipv6_qp = limit_uint(rblock->max_raw_ipv6_qp); | 118 | props->max_raw_ipv6_qp = limit_uint(rblock->max_raw_ipv6_qp); |
120 | props->max_raw_ethy_qp = limit_uint(rblock->max_raw_ethy_qp); | 119 | props->max_raw_ethy_qp = limit_uint(rblock->max_raw_ethy_qp); |
121 | props->max_mcast_grp = limit_uint(rblock->max_mcast_grp); | 120 | props->max_mcast_grp = limit_uint(rblock->max_mcast_grp); |
@@ -136,7 +135,7 @@ query_device1: | |||
136 | return ret; | 135 | return ret; |
137 | } | 136 | } |
138 | 137 | ||
139 | static int map_mtu(struct ehca_shca *shca, u32 fw_mtu) | 138 | static enum ib_mtu map_mtu(struct ehca_shca *shca, u32 fw_mtu) |
140 | { | 139 | { |
141 | switch (fw_mtu) { | 140 | switch (fw_mtu) { |
142 | case 0x1: | 141 | case 0x1: |
@@ -156,7 +155,7 @@ static int map_mtu(struct ehca_shca *shca, u32 fw_mtu) | |||
156 | } | 155 | } |
157 | } | 156 | } |
158 | 157 | ||
159 | static int map_number_of_vls(struct ehca_shca *shca, u32 vl_cap) | 158 | static u8 map_number_of_vls(struct ehca_shca *shca, u32 vl_cap) |
160 | { | 159 | { |
161 | switch (vl_cap) { | 160 | switch (vl_cap) { |
162 | case 0x1: | 161 | case 0x1: |
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c index 2f199c5c4a72..4521319b1406 100644 --- a/drivers/infiniband/hw/mlx4/cq.c +++ b/drivers/infiniband/hw/mlx4/cq.c | |||
@@ -246,7 +246,7 @@ err_mtt: | |||
246 | if (context) | 246 | if (context) |
247 | ib_umem_release(cq->umem); | 247 | ib_umem_release(cq->umem); |
248 | else | 248 | else |
249 | mlx4_ib_free_cq_buf(dev, &cq->buf, entries); | 249 | mlx4_ib_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe); |
250 | 250 | ||
251 | err_db: | 251 | err_db: |
252 | if (!context) | 252 | if (!context) |
@@ -434,7 +434,7 @@ int mlx4_ib_destroy_cq(struct ib_cq *cq) | |||
434 | mlx4_ib_db_unmap_user(to_mucontext(cq->uobject->context), &mcq->db); | 434 | mlx4_ib_db_unmap_user(to_mucontext(cq->uobject->context), &mcq->db); |
435 | ib_umem_release(mcq->umem); | 435 | ib_umem_release(mcq->umem); |
436 | } else { | 436 | } else { |
437 | mlx4_ib_free_cq_buf(dev, &mcq->buf, cq->cqe + 1); | 437 | mlx4_ib_free_cq_buf(dev, &mcq->buf, cq->cqe); |
438 | mlx4_db_free(dev->dev, &mcq->db); | 438 | mlx4_db_free(dev->dev, &mcq->db); |
439 | } | 439 | } |
440 | 440 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h index 9044f8803532..ca126fc2b853 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/drivers/infiniband/ulp/ipoib/ipoib.h | |||
@@ -334,6 +334,7 @@ struct ipoib_dev_priv { | |||
334 | #endif | 334 | #endif |
335 | int hca_caps; | 335 | int hca_caps; |
336 | struct ipoib_ethtool_st ethtool; | 336 | struct ipoib_ethtool_st ethtool; |
337 | struct timer_list poll_timer; | ||
337 | }; | 338 | }; |
338 | 339 | ||
339 | struct ipoib_ah { | 340 | struct ipoib_ah { |
@@ -404,6 +405,7 @@ extern struct workqueue_struct *ipoib_workqueue; | |||
404 | 405 | ||
405 | int ipoib_poll(struct napi_struct *napi, int budget); | 406 | int ipoib_poll(struct napi_struct *napi, int budget); |
406 | void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr); | 407 | void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr); |
408 | void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr); | ||
407 | 409 | ||
408 | struct ipoib_ah *ipoib_create_ah(struct net_device *dev, | 410 | struct ipoib_ah *ipoib_create_ah(struct net_device *dev, |
409 | struct ib_pd *pd, struct ib_ah_attr *attr); | 411 | struct ib_pd *pd, struct ib_ah_attr *attr); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 97b815c1a3fc..f429bce24c20 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
@@ -461,6 +461,26 @@ void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr) | |||
461 | netif_rx_schedule(dev, &priv->napi); | 461 | netif_rx_schedule(dev, &priv->napi); |
462 | } | 462 | } |
463 | 463 | ||
464 | static void drain_tx_cq(struct net_device *dev) | ||
465 | { | ||
466 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
467 | unsigned long flags; | ||
468 | |||
469 | spin_lock_irqsave(&priv->tx_lock, flags); | ||
470 | while (poll_tx(priv)) | ||
471 | ; /* nothing */ | ||
472 | |||
473 | if (netif_queue_stopped(dev)) | ||
474 | mod_timer(&priv->poll_timer, jiffies + 1); | ||
475 | |||
476 | spin_unlock_irqrestore(&priv->tx_lock, flags); | ||
477 | } | ||
478 | |||
479 | void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr) | ||
480 | { | ||
481 | drain_tx_cq((struct net_device *)dev_ptr); | ||
482 | } | ||
483 | |||
464 | static inline int post_send(struct ipoib_dev_priv *priv, | 484 | static inline int post_send(struct ipoib_dev_priv *priv, |
465 | unsigned int wr_id, | 485 | unsigned int wr_id, |
466 | struct ib_ah *address, u32 qpn, | 486 | struct ib_ah *address, u32 qpn, |
@@ -555,12 +575,22 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb, | |||
555 | else | 575 | else |
556 | priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM; | 576 | priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM; |
557 | 577 | ||
578 | if (++priv->tx_outstanding == ipoib_sendq_size) { | ||
579 | ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n"); | ||
580 | if (ib_req_notify_cq(priv->send_cq, IB_CQ_NEXT_COMP)) | ||
581 | ipoib_warn(priv, "request notify on send CQ failed\n"); | ||
582 | netif_stop_queue(dev); | ||
583 | } | ||
584 | |||
558 | if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size - 1), | 585 | if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size - 1), |
559 | address->ah, qpn, tx_req, phead, hlen))) { | 586 | address->ah, qpn, tx_req, phead, hlen))) { |
560 | ipoib_warn(priv, "post_send failed\n"); | 587 | ipoib_warn(priv, "post_send failed\n"); |
561 | ++dev->stats.tx_errors; | 588 | ++dev->stats.tx_errors; |
589 | --priv->tx_outstanding; | ||
562 | ipoib_dma_unmap_tx(priv->ca, tx_req); | 590 | ipoib_dma_unmap_tx(priv->ca, tx_req); |
563 | dev_kfree_skb_any(skb); | 591 | dev_kfree_skb_any(skb); |
592 | if (netif_queue_stopped(dev)) | ||
593 | netif_wake_queue(dev); | ||
564 | } else { | 594 | } else { |
565 | dev->trans_start = jiffies; | 595 | dev->trans_start = jiffies; |
566 | 596 | ||
@@ -568,14 +598,11 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb, | |||
568 | ++priv->tx_head; | 598 | ++priv->tx_head; |
569 | skb_orphan(skb); | 599 | skb_orphan(skb); |
570 | 600 | ||
571 | if (++priv->tx_outstanding == ipoib_sendq_size) { | ||
572 | ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n"); | ||
573 | netif_stop_queue(dev); | ||
574 | } | ||
575 | } | 601 | } |
576 | 602 | ||
577 | if (unlikely(priv->tx_outstanding > MAX_SEND_CQE)) | 603 | if (unlikely(priv->tx_outstanding > MAX_SEND_CQE)) |
578 | poll_tx(priv); | 604 | while (poll_tx(priv)) |
605 | ; /* nothing */ | ||
579 | } | 606 | } |
580 | 607 | ||
581 | static void __ipoib_reap_ah(struct net_device *dev) | 608 | static void __ipoib_reap_ah(struct net_device *dev) |
@@ -609,6 +636,11 @@ void ipoib_reap_ah(struct work_struct *work) | |||
609 | round_jiffies_relative(HZ)); | 636 | round_jiffies_relative(HZ)); |
610 | } | 637 | } |
611 | 638 | ||
639 | static void ipoib_ib_tx_timer_func(unsigned long ctx) | ||
640 | { | ||
641 | drain_tx_cq((struct net_device *)ctx); | ||
642 | } | ||
643 | |||
612 | int ipoib_ib_dev_open(struct net_device *dev) | 644 | int ipoib_ib_dev_open(struct net_device *dev) |
613 | { | 645 | { |
614 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 646 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
@@ -645,6 +677,10 @@ int ipoib_ib_dev_open(struct net_device *dev) | |||
645 | queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, | 677 | queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, |
646 | round_jiffies_relative(HZ)); | 678 | round_jiffies_relative(HZ)); |
647 | 679 | ||
680 | init_timer(&priv->poll_timer); | ||
681 | priv->poll_timer.function = ipoib_ib_tx_timer_func; | ||
682 | priv->poll_timer.data = (unsigned long)dev; | ||
683 | |||
648 | set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); | 684 | set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); |
649 | 685 | ||
650 | return 0; | 686 | return 0; |
@@ -810,6 +846,7 @@ int ipoib_ib_dev_stop(struct net_device *dev, int flush) | |||
810 | ipoib_dbg(priv, "All sends and receives done.\n"); | 846 | ipoib_dbg(priv, "All sends and receives done.\n"); |
811 | 847 | ||
812 | timeout: | 848 | timeout: |
849 | del_timer_sync(&priv->poll_timer); | ||
813 | qp_attr.qp_state = IB_QPS_RESET; | 850 | qp_attr.qp_state = IB_QPS_RESET; |
814 | if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE)) | 851 | if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE)) |
815 | ipoib_warn(priv, "Failed to modify QP to RESET state\n"); | 852 | ipoib_warn(priv, "Failed to modify QP to RESET state\n"); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c index c1e7ece1fd44..8766d29ce3b7 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c | |||
@@ -187,7 +187,8 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) | |||
187 | goto out_free_mr; | 187 | goto out_free_mr; |
188 | } | 188 | } |
189 | 189 | ||
190 | priv->send_cq = ib_create_cq(priv->ca, NULL, NULL, dev, ipoib_sendq_size, 0); | 190 | priv->send_cq = ib_create_cq(priv->ca, ipoib_send_comp_handler, NULL, |
191 | dev, ipoib_sendq_size, 0); | ||
191 | if (IS_ERR(priv->send_cq)) { | 192 | if (IS_ERR(priv->send_cq)) { |
192 | printk(KERN_WARNING "%s: failed to create send CQ\n", ca->name); | 193 | printk(KERN_WARNING "%s: failed to create send CQ\n", ca->name); |
193 | goto out_free_recv_cq; | 194 | goto out_free_recv_cq; |
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index 02b3ad8c0826..edfedd9a166c 100644 --- a/drivers/input/serio/hp_sdc.c +++ b/drivers/input/serio/hp_sdc.c | |||
@@ -69,6 +69,7 @@ | |||
69 | #include <linux/time.h> | 69 | #include <linux/time.h> |
70 | #include <linux/slab.h> | 70 | #include <linux/slab.h> |
71 | #include <linux/hil.h> | 71 | #include <linux/hil.h> |
72 | #include <linux/semaphore.h> | ||
72 | #include <asm/io.h> | 73 | #include <asm/io.h> |
73 | #include <asm/system.h> | 74 | #include <asm/system.h> |
74 | 75 | ||
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c index 877be9922c3d..15906d005b05 100644 --- a/drivers/isdn/hysdn/hysdn_procconf.c +++ b/drivers/isdn/hysdn/hysdn_procconf.c | |||
@@ -405,7 +405,8 @@ hysdn_procconf_init(void) | |||
405 | sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); | 405 | sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); |
406 | if ((card->procconf = (void *) proc_create(conf_name, | 406 | if ((card->procconf = (void *) proc_create(conf_name, |
407 | S_IFREG | S_IRUGO | S_IWUSR, | 407 | S_IFREG | S_IRUGO | S_IWUSR, |
408 | hysdn_proc_entry)) != NULL) { | 408 | hysdn_proc_entry, |
409 | &conf_fops)) != NULL) { | ||
409 | hysdn_proclog_init(card); /* init the log file entry */ | 410 | hysdn_proclog_init(card); /* init the log file entry */ |
410 | } | 411 | } |
411 | card = card->next; /* next entry */ | 412 | card = card->next; /* next entry */ |
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 2bc9bf7e88e5..8080249957af 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -85,27 +85,34 @@ static unsigned desc_size(const struct lguest_device_desc *desc) | |||
85 | + desc->config_len; | 85 | + desc->config_len; |
86 | } | 86 | } |
87 | 87 | ||
88 | /* This tests (and acknowleges) a feature bit. */ | 88 | /* This gets the device's feature bits. */ |
89 | static bool lg_feature(struct virtio_device *vdev, unsigned fbit) | 89 | static u32 lg_get_features(struct virtio_device *vdev) |
90 | { | 90 | { |
91 | unsigned int i; | ||
92 | u32 features = 0; | ||
91 | struct lguest_device_desc *desc = to_lgdev(vdev)->desc; | 93 | struct lguest_device_desc *desc = to_lgdev(vdev)->desc; |
92 | u8 *features; | 94 | u8 *in_features = lg_features(desc); |
93 | 95 | ||
94 | /* Obviously if they ask for a feature off the end of our feature | 96 | /* We do this the slow but generic way. */ |
95 | * bitmap, it's not set. */ | 97 | for (i = 0; i < min(desc->feature_len * 8, 32); i++) |
96 | if (fbit / 8 > desc->feature_len) | 98 | if (in_features[i / 8] & (1 << (i % 8))) |
97 | return false; | 99 | features |= (1 << i); |
98 | 100 | ||
99 | /* The feature bitmap comes after the virtqueues. */ | 101 | return features; |
100 | features = lg_features(desc); | 102 | } |
101 | if (!(features[fbit / 8] & (1 << (fbit % 8)))) | 103 | |
102 | return false; | 104 | static void lg_set_features(struct virtio_device *vdev, u32 features) |
103 | 105 | { | |
104 | /* We set the matching bit in the other half of the bitmap to tell the | 106 | unsigned int i; |
105 | * Host we want to use this feature. We don't use this yet, but we | 107 | struct lguest_device_desc *desc = to_lgdev(vdev)->desc; |
106 | * could in future. */ | 108 | /* Second half of bitmap is features we accept. */ |
107 | features[desc->feature_len + fbit / 8] |= (1 << (fbit % 8)); | 109 | u8 *out_features = lg_features(desc) + desc->feature_len; |
108 | return true; | 110 | |
111 | memset(out_features, 0, desc->feature_len); | ||
112 | for (i = 0; i < min(desc->feature_len * 8, 32); i++) { | ||
113 | if (features & (1 << i)) | ||
114 | out_features[i / 8] |= (1 << (i % 8)); | ||
115 | } | ||
109 | } | 116 | } |
110 | 117 | ||
111 | /* Once they've found a field, getting a copy of it is easy. */ | 118 | /* Once they've found a field, getting a copy of it is easy. */ |
@@ -137,20 +144,26 @@ static u8 lg_get_status(struct virtio_device *vdev) | |||
137 | return to_lgdev(vdev)->desc->status; | 144 | return to_lgdev(vdev)->desc->status; |
138 | } | 145 | } |
139 | 146 | ||
147 | /* To notify on status updates, we (ab)use the NOTIFY hypercall, with the | ||
148 | * descriptor address of the device. A zero status means "reset". */ | ||
149 | static void set_status(struct virtio_device *vdev, u8 status) | ||
150 | { | ||
151 | unsigned long offset = (void *)to_lgdev(vdev)->desc - lguest_devices; | ||
152 | |||
153 | /* We set the status. */ | ||
154 | to_lgdev(vdev)->desc->status = status; | ||
155 | hcall(LHCALL_NOTIFY, (max_pfn<<PAGE_SHIFT) + offset, 0, 0); | ||
156 | } | ||
157 | |||
140 | static void lg_set_status(struct virtio_device *vdev, u8 status) | 158 | static void lg_set_status(struct virtio_device *vdev, u8 status) |
141 | { | 159 | { |
142 | BUG_ON(!status); | 160 | BUG_ON(!status); |
143 | to_lgdev(vdev)->desc->status = status; | 161 | set_status(vdev, status); |
144 | } | 162 | } |
145 | 163 | ||
146 | /* To reset the device, we (ab)use the NOTIFY hypercall, with the descriptor | ||
147 | * address of the device. The Host will zero the status and all the | ||
148 | * features. */ | ||
149 | static void lg_reset(struct virtio_device *vdev) | 164 | static void lg_reset(struct virtio_device *vdev) |
150 | { | 165 | { |
151 | unsigned long offset = (void *)to_lgdev(vdev)->desc - lguest_devices; | 166 | set_status(vdev, 0); |
152 | |||
153 | hcall(LHCALL_NOTIFY, (max_pfn<<PAGE_SHIFT) + offset, 0, 0); | ||
154 | } | 167 | } |
155 | 168 | ||
156 | /* | 169 | /* |
@@ -286,7 +299,8 @@ static void lg_del_vq(struct virtqueue *vq) | |||
286 | 299 | ||
287 | /* The ops structure which hooks everything together. */ | 300 | /* The ops structure which hooks everything together. */ |
288 | static struct virtio_config_ops lguest_config_ops = { | 301 | static struct virtio_config_ops lguest_config_ops = { |
289 | .feature = lg_feature, | 302 | .get_features = lg_get_features, |
303 | .set_features = lg_set_features, | ||
290 | .get = lg_get, | 304 | .get = lg_get, |
291 | .set = lg_set, | 305 | .set = lg_set, |
292 | .get_status = lg_get_status, | 306 | .get_status = lg_get_status, |
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c index 645e6e040bfb..e73a000473cc 100644 --- a/drivers/lguest/lguest_user.c +++ b/drivers/lguest/lguest_user.c | |||
@@ -102,7 +102,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o) | |||
102 | static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip) | 102 | static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip) |
103 | { | 103 | { |
104 | /* We have a limited number the number of CPUs in the lguest struct. */ | 104 | /* We have a limited number the number of CPUs in the lguest struct. */ |
105 | if (id >= NR_CPUS) | 105 | if (id >= ARRAY_SIZE(cpu->lg->cpus)) |
106 | return -EINVAL; | 106 | return -EINVAL; |
107 | 107 | ||
108 | /* Set up this CPU's id, and pointer back to the lguest struct. */ | 108 | /* Set up this CPU's id, and pointer back to the lguest struct. */ |
@@ -251,8 +251,6 @@ static ssize_t write(struct file *file, const char __user *in, | |||
251 | if (!lg || (cpu_id >= lg->nr_cpus)) | 251 | if (!lg || (cpu_id >= lg->nr_cpus)) |
252 | return -EINVAL; | 252 | return -EINVAL; |
253 | cpu = &lg->cpus[cpu_id]; | 253 | cpu = &lg->cpus[cpu_id]; |
254 | if (!cpu) | ||
255 | return -EINVAL; | ||
256 | 254 | ||
257 | /* Once the Guest is dead, you can only read() why it died. */ | 255 | /* Once the Guest is dead, you can only read() why it died. */ |
258 | if (lg->dead) | 256 | if (lg->dead) |
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index 20978205cd02..b8b9e44f7f4e 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/device.h> | 37 | #include <linux/device.h> |
38 | #include <linux/kthread.h> | 38 | #include <linux/kthread.h> |
39 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
40 | #include <linux/semaphore.h> | 40 | #include <linux/mutex.h> |
41 | 41 | ||
42 | #include <asm/uaccess.h> | 42 | #include <asm/uaccess.h> |
43 | #ifdef CONFIG_PPC | 43 | #ifdef CONFIG_PPC |
@@ -102,7 +102,7 @@ static struct adb_handler { | |||
102 | } adb_handler[16]; | 102 | } adb_handler[16]; |
103 | 103 | ||
104 | /* | 104 | /* |
105 | * The adb_handler_sem mutex protects all accesses to the original_address | 105 | * The adb_handler_mutex mutex protects all accesses to the original_address |
106 | * and handler_id fields of adb_handler[i] for all i, and changes to the | 106 | * and handler_id fields of adb_handler[i] for all i, and changes to the |
107 | * handler field. | 107 | * handler field. |
108 | * Accesses to the handler field are protected by the adb_handler_lock | 108 | * Accesses to the handler field are protected by the adb_handler_lock |
@@ -110,7 +110,7 @@ static struct adb_handler { | |||
110 | * time adb_unregister returns, we know that the old handler isn't being | 110 | * time adb_unregister returns, we know that the old handler isn't being |
111 | * called. | 111 | * called. |
112 | */ | 112 | */ |
113 | static DECLARE_MUTEX(adb_handler_sem); | 113 | static DEFINE_MUTEX(adb_handler_mutex); |
114 | static DEFINE_RWLOCK(adb_handler_lock); | 114 | static DEFINE_RWLOCK(adb_handler_lock); |
115 | 115 | ||
116 | #if 0 | 116 | #if 0 |
@@ -355,7 +355,7 @@ do_adb_reset_bus(void) | |||
355 | msleep(500); | 355 | msleep(500); |
356 | } | 356 | } |
357 | 357 | ||
358 | down(&adb_handler_sem); | 358 | mutex_lock(&adb_handler_mutex); |
359 | write_lock_irq(&adb_handler_lock); | 359 | write_lock_irq(&adb_handler_lock); |
360 | memset(adb_handler, 0, sizeof(adb_handler)); | 360 | memset(adb_handler, 0, sizeof(adb_handler)); |
361 | write_unlock_irq(&adb_handler_lock); | 361 | write_unlock_irq(&adb_handler_lock); |
@@ -376,7 +376,7 @@ do_adb_reset_bus(void) | |||
376 | if (adb_controller->autopoll) | 376 | if (adb_controller->autopoll) |
377 | adb_controller->autopoll(autopoll_devs); | 377 | adb_controller->autopoll(autopoll_devs); |
378 | } | 378 | } |
379 | up(&adb_handler_sem); | 379 | mutex_unlock(&adb_handler_mutex); |
380 | 380 | ||
381 | blocking_notifier_call_chain(&adb_client_list, | 381 | blocking_notifier_call_chain(&adb_client_list, |
382 | ADB_MSG_POST_RESET, NULL); | 382 | ADB_MSG_POST_RESET, NULL); |
@@ -454,7 +454,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids, | |||
454 | { | 454 | { |
455 | int i; | 455 | int i; |
456 | 456 | ||
457 | down(&adb_handler_sem); | 457 | mutex_lock(&adb_handler_mutex); |
458 | ids->nids = 0; | 458 | ids->nids = 0; |
459 | for (i = 1; i < 16; i++) { | 459 | for (i = 1; i < 16; i++) { |
460 | if ((adb_handler[i].original_address == default_id) && | 460 | if ((adb_handler[i].original_address == default_id) && |
@@ -472,7 +472,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids, | |||
472 | ids->id[ids->nids++] = i; | 472 | ids->id[ids->nids++] = i; |
473 | } | 473 | } |
474 | } | 474 | } |
475 | up(&adb_handler_sem); | 475 | mutex_unlock(&adb_handler_mutex); |
476 | return ids->nids; | 476 | return ids->nids; |
477 | } | 477 | } |
478 | 478 | ||
@@ -481,7 +481,7 @@ adb_unregister(int index) | |||
481 | { | 481 | { |
482 | int ret = -ENODEV; | 482 | int ret = -ENODEV; |
483 | 483 | ||
484 | down(&adb_handler_sem); | 484 | mutex_lock(&adb_handler_mutex); |
485 | write_lock_irq(&adb_handler_lock); | 485 | write_lock_irq(&adb_handler_lock); |
486 | if (adb_handler[index].handler) { | 486 | if (adb_handler[index].handler) { |
487 | while(adb_handler[index].busy) { | 487 | while(adb_handler[index].busy) { |
@@ -493,7 +493,7 @@ adb_unregister(int index) | |||
493 | adb_handler[index].handler = NULL; | 493 | adb_handler[index].handler = NULL; |
494 | } | 494 | } |
495 | write_unlock_irq(&adb_handler_lock); | 495 | write_unlock_irq(&adb_handler_lock); |
496 | up(&adb_handler_sem); | 496 | mutex_unlock(&adb_handler_mutex); |
497 | return ret; | 497 | return ret; |
498 | } | 498 | } |
499 | 499 | ||
@@ -557,19 +557,19 @@ adb_try_handler_change(int address, int new_id) | |||
557 | { | 557 | { |
558 | int ret; | 558 | int ret; |
559 | 559 | ||
560 | down(&adb_handler_sem); | 560 | mutex_lock(&adb_handler_mutex); |
561 | ret = try_handler_change(address, new_id); | 561 | ret = try_handler_change(address, new_id); |
562 | up(&adb_handler_sem); | 562 | mutex_unlock(&adb_handler_mutex); |
563 | return ret; | 563 | return ret; |
564 | } | 564 | } |
565 | 565 | ||
566 | int | 566 | int |
567 | adb_get_infos(int address, int *original_address, int *handler_id) | 567 | adb_get_infos(int address, int *original_address, int *handler_id) |
568 | { | 568 | { |
569 | down(&adb_handler_sem); | 569 | mutex_lock(&adb_handler_mutex); |
570 | *original_address = adb_handler[address].original_address; | 570 | *original_address = adb_handler[address].original_address; |
571 | *handler_id = adb_handler[address].handler_id; | 571 | *handler_id = adb_handler[address].handler_id; |
572 | up(&adb_handler_sem); | 572 | mutex_unlock(&adb_handler_mutex); |
573 | 573 | ||
574 | return (*original_address != 0); | 574 | return (*original_address != 0); |
575 | } | 575 | } |
@@ -628,10 +628,10 @@ do_adb_query(struct adb_request *req) | |||
628 | case ADB_QUERY_GETDEVINFO: | 628 | case ADB_QUERY_GETDEVINFO: |
629 | if (req->nbytes < 3) | 629 | if (req->nbytes < 3) |
630 | break; | 630 | break; |
631 | down(&adb_handler_sem); | 631 | mutex_lock(&adb_handler_mutex); |
632 | req->reply[0] = adb_handler[req->data[2]].original_address; | 632 | req->reply[0] = adb_handler[req->data[2]].original_address; |
633 | req->reply[1] = adb_handler[req->data[2]].handler_id; | 633 | req->reply[1] = adb_handler[req->data[2]].handler_id; |
634 | up(&adb_handler_sem); | 634 | mutex_unlock(&adb_handler_mutex); |
635 | req->complete = 1; | 635 | req->complete = 1; |
636 | req->reply_len = 2; | 636 | req->reply_len = 2; |
637 | adb_write_done(req); | 637 | adb_write_done(req); |
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index 1e0a69a5e815..ddfb426a9abd 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c | |||
@@ -122,6 +122,7 @@ | |||
122 | #include <linux/kmod.h> | 122 | #include <linux/kmod.h> |
123 | #include <linux/i2c.h> | 123 | #include <linux/i2c.h> |
124 | #include <linux/kthread.h> | 124 | #include <linux/kthread.h> |
125 | #include <linux/mutex.h> | ||
125 | #include <asm/prom.h> | 126 | #include <asm/prom.h> |
126 | #include <asm/machdep.h> | 127 | #include <asm/machdep.h> |
127 | #include <asm/io.h> | 128 | #include <asm/io.h> |
@@ -169,7 +170,7 @@ static int rackmac; | |||
169 | static s32 dimm_output_clamp; | 170 | static s32 dimm_output_clamp; |
170 | static int fcu_rpm_shift; | 171 | static int fcu_rpm_shift; |
171 | static int fcu_tickle_ticks; | 172 | static int fcu_tickle_ticks; |
172 | static DECLARE_MUTEX(driver_lock); | 173 | static DEFINE_MUTEX(driver_lock); |
173 | 174 | ||
174 | /* | 175 | /* |
175 | * We have 3 types of CPU PID control. One is "split" old style control | 176 | * We have 3 types of CPU PID control. One is "split" old style control |
@@ -729,9 +730,9 @@ static void fetch_cpu_pumps_minmax(void) | |||
729 | static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ | 730 | static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ |
730 | { \ | 731 | { \ |
731 | ssize_t r; \ | 732 | ssize_t r; \ |
732 | down(&driver_lock); \ | 733 | mutex_lock(&driver_lock); \ |
733 | r = sprintf(buf, "%d.%03d", FIX32TOPRINT(data)); \ | 734 | r = sprintf(buf, "%d.%03d", FIX32TOPRINT(data)); \ |
734 | up(&driver_lock); \ | 735 | mutex_unlock(&driver_lock); \ |
735 | return r; \ | 736 | return r; \ |
736 | } | 737 | } |
737 | #define BUILD_SHOW_FUNC_INT(name, data) \ | 738 | #define BUILD_SHOW_FUNC_INT(name, data) \ |
@@ -1803,11 +1804,11 @@ static int main_control_loop(void *x) | |||
1803 | { | 1804 | { |
1804 | DBG("main_control_loop started\n"); | 1805 | DBG("main_control_loop started\n"); |
1805 | 1806 | ||
1806 | down(&driver_lock); | 1807 | mutex_lock(&driver_lock); |
1807 | 1808 | ||
1808 | if (start_fcu() < 0) { | 1809 | if (start_fcu() < 0) { |
1809 | printk(KERN_ERR "kfand: failed to start FCU\n"); | 1810 | printk(KERN_ERR "kfand: failed to start FCU\n"); |
1810 | up(&driver_lock); | 1811 | mutex_unlock(&driver_lock); |
1811 | goto out; | 1812 | goto out; |
1812 | } | 1813 | } |
1813 | 1814 | ||
@@ -1822,14 +1823,14 @@ static int main_control_loop(void *x) | |||
1822 | 1823 | ||
1823 | fcu_tickle_ticks = FCU_TICKLE_TICKS; | 1824 | fcu_tickle_ticks = FCU_TICKLE_TICKS; |
1824 | 1825 | ||
1825 | up(&driver_lock); | 1826 | mutex_unlock(&driver_lock); |
1826 | 1827 | ||
1827 | while (state == state_attached) { | 1828 | while (state == state_attached) { |
1828 | unsigned long elapsed, start; | 1829 | unsigned long elapsed, start; |
1829 | 1830 | ||
1830 | start = jiffies; | 1831 | start = jiffies; |
1831 | 1832 | ||
1832 | down(&driver_lock); | 1833 | mutex_lock(&driver_lock); |
1833 | 1834 | ||
1834 | /* Tickle the FCU just in case */ | 1835 | /* Tickle the FCU just in case */ |
1835 | if (--fcu_tickle_ticks < 0) { | 1836 | if (--fcu_tickle_ticks < 0) { |
@@ -1861,7 +1862,7 @@ static int main_control_loop(void *x) | |||
1861 | do_monitor_slots(&slots_state); | 1862 | do_monitor_slots(&slots_state); |
1862 | else | 1863 | else |
1863 | do_monitor_drives(&drives_state); | 1864 | do_monitor_drives(&drives_state); |
1864 | up(&driver_lock); | 1865 | mutex_unlock(&driver_lock); |
1865 | 1866 | ||
1866 | if (critical_state == 1) { | 1867 | if (critical_state == 1) { |
1867 | printk(KERN_WARNING "Temperature control detected a critical condition\n"); | 1868 | printk(KERN_WARNING "Temperature control detected a critical condition\n"); |
@@ -2019,13 +2020,13 @@ static void detach_fcu(void) | |||
2019 | */ | 2020 | */ |
2020 | static int therm_pm72_attach(struct i2c_adapter *adapter) | 2021 | static int therm_pm72_attach(struct i2c_adapter *adapter) |
2021 | { | 2022 | { |
2022 | down(&driver_lock); | 2023 | mutex_lock(&driver_lock); |
2023 | 2024 | ||
2024 | /* Check state */ | 2025 | /* Check state */ |
2025 | if (state == state_detached) | 2026 | if (state == state_detached) |
2026 | state = state_attaching; | 2027 | state = state_attaching; |
2027 | if (state != state_attaching) { | 2028 | if (state != state_attaching) { |
2028 | up(&driver_lock); | 2029 | mutex_unlock(&driver_lock); |
2029 | return 0; | 2030 | return 0; |
2030 | } | 2031 | } |
2031 | 2032 | ||
@@ -2054,7 +2055,7 @@ static int therm_pm72_attach(struct i2c_adapter *adapter) | |||
2054 | state = state_attached; | 2055 | state = state_attached; |
2055 | start_control_loops(); | 2056 | start_control_loops(); |
2056 | } | 2057 | } |
2057 | up(&driver_lock); | 2058 | mutex_unlock(&driver_lock); |
2058 | 2059 | ||
2059 | return 0; | 2060 | return 0; |
2060 | } | 2061 | } |
@@ -2065,16 +2066,16 @@ static int therm_pm72_attach(struct i2c_adapter *adapter) | |||
2065 | */ | 2066 | */ |
2066 | static int therm_pm72_detach(struct i2c_adapter *adapter) | 2067 | static int therm_pm72_detach(struct i2c_adapter *adapter) |
2067 | { | 2068 | { |
2068 | down(&driver_lock); | 2069 | mutex_lock(&driver_lock); |
2069 | 2070 | ||
2070 | if (state != state_detached) | 2071 | if (state != state_detached) |
2071 | state = state_detaching; | 2072 | state = state_detaching; |
2072 | 2073 | ||
2073 | /* Stop control loops if any */ | 2074 | /* Stop control loops if any */ |
2074 | DBG("stopping control loops\n"); | 2075 | DBG("stopping control loops\n"); |
2075 | up(&driver_lock); | 2076 | mutex_unlock(&driver_lock); |
2076 | stop_control_loops(); | 2077 | stop_control_loops(); |
2077 | down(&driver_lock); | 2078 | mutex_lock(&driver_lock); |
2078 | 2079 | ||
2079 | if (u3_0 != NULL && !strcmp(adapter->name, "u3 0")) { | 2080 | if (u3_0 != NULL && !strcmp(adapter->name, "u3 0")) { |
2080 | DBG("lost U3-0, disposing control loops\n"); | 2081 | DBG("lost U3-0, disposing control loops\n"); |
@@ -2090,7 +2091,7 @@ static int therm_pm72_detach(struct i2c_adapter *adapter) | |||
2090 | if (u3_0 == NULL && u3_1 == NULL) | 2091 | if (u3_0 == NULL && u3_1 == NULL) |
2091 | state = state_detached; | 2092 | state = state_detached; |
2092 | 2093 | ||
2093 | up(&driver_lock); | 2094 | mutex_unlock(&driver_lock); |
2094 | 2095 | ||
2095 | return 0; | 2096 | return 0; |
2096 | } | 2097 | } |
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c index 797918d0e59c..7f2be4baaeda 100644 --- a/drivers/macintosh/windfarm_smu_sat.c +++ b/drivers/macintosh/windfarm_smu_sat.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/wait.h> | 14 | #include <linux/wait.h> |
15 | #include <linux/i2c.h> | 15 | #include <linux/i2c.h> |
16 | #include <linux/semaphore.h> | 16 | #include <linux/mutex.h> |
17 | #include <asm/prom.h> | 17 | #include <asm/prom.h> |
18 | #include <asm/smu.h> | 18 | #include <asm/smu.h> |
19 | #include <asm/pmac_low_i2c.h> | 19 | #include <asm/pmac_low_i2c.h> |
@@ -36,7 +36,7 @@ | |||
36 | struct wf_sat { | 36 | struct wf_sat { |
37 | int nr; | 37 | int nr; |
38 | atomic_t refcnt; | 38 | atomic_t refcnt; |
39 | struct semaphore mutex; | 39 | struct mutex mutex; |
40 | unsigned long last_read; /* jiffies when cache last updated */ | 40 | unsigned long last_read; /* jiffies when cache last updated */ |
41 | u8 cache[16]; | 41 | u8 cache[16]; |
42 | struct i2c_client i2c; | 42 | struct i2c_client i2c; |
@@ -163,7 +163,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value) | |||
163 | if (sat->i2c.adapter == NULL) | 163 | if (sat->i2c.adapter == NULL) |
164 | return -ENODEV; | 164 | return -ENODEV; |
165 | 165 | ||
166 | down(&sat->mutex); | 166 | mutex_lock(&sat->mutex); |
167 | if (time_after(jiffies, (sat->last_read + MAX_AGE))) { | 167 | if (time_after(jiffies, (sat->last_read + MAX_AGE))) { |
168 | err = wf_sat_read_cache(sat); | 168 | err = wf_sat_read_cache(sat); |
169 | if (err) | 169 | if (err) |
@@ -182,7 +182,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value) | |||
182 | err = 0; | 182 | err = 0; |
183 | 183 | ||
184 | fail: | 184 | fail: |
185 | up(&sat->mutex); | 185 | mutex_unlock(&sat->mutex); |
186 | return err; | 186 | return err; |
187 | } | 187 | } |
188 | 188 | ||
@@ -233,7 +233,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev) | |||
233 | sat->nr = -1; | 233 | sat->nr = -1; |
234 | sat->node = of_node_get(dev); | 234 | sat->node = of_node_get(dev); |
235 | atomic_set(&sat->refcnt, 0); | 235 | atomic_set(&sat->refcnt, 0); |
236 | init_MUTEX(&sat->mutex); | 236 | mutex_init(&sat->mutex); |
237 | sat->i2c.addr = (addr >> 1) & 0x7f; | 237 | sat->i2c.addr = (addr >> 1) & 0x7f; |
238 | sat->i2c.adapter = adapter; | 238 | sat->i2c.adapter = adapter; |
239 | sat->i2c.driver = &wf_sat_driver; | 239 | sat->i2c.driver = &wf_sat_driver; |
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c index 30a1af857c7a..fa394104339c 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c | |||
@@ -47,6 +47,7 @@ | |||
47 | * to test the HW NMI watchdog | 47 | * to test the HW NMI watchdog |
48 | * F## = Break at do_fork for ## iterations | 48 | * F## = Break at do_fork for ## iterations |
49 | * S## = Break at sys_open for ## iterations | 49 | * S## = Break at sys_open for ## iterations |
50 | * I## = Run the single step test ## iterations | ||
50 | * | 51 | * |
51 | * NOTE: that the do_fork and sys_open tests are mutually exclusive. | 52 | * NOTE: that the do_fork and sys_open tests are mutually exclusive. |
52 | * | 53 | * |
@@ -375,7 +376,7 @@ static void emul_sstep_get(char *arg) | |||
375 | break; | 376 | break; |
376 | case 1: | 377 | case 1: |
377 | /* set breakpoint */ | 378 | /* set breakpoint */ |
378 | break_helper("Z0", 0, sstep_addr); | 379 | break_helper("Z0", NULL, sstep_addr); |
379 | break; | 380 | break; |
380 | case 2: | 381 | case 2: |
381 | /* Continue */ | 382 | /* Continue */ |
@@ -383,7 +384,7 @@ static void emul_sstep_get(char *arg) | |||
383 | break; | 384 | break; |
384 | case 3: | 385 | case 3: |
385 | /* Clear breakpoint */ | 386 | /* Clear breakpoint */ |
386 | break_helper("z0", 0, sstep_addr); | 387 | break_helper("z0", NULL, sstep_addr); |
387 | break; | 388 | break; |
388 | default: | 389 | default: |
389 | eprintk("kgdbts: ERROR failed sstep get emulation\n"); | 390 | eprintk("kgdbts: ERROR failed sstep get emulation\n"); |
@@ -465,11 +466,11 @@ static struct test_struct sw_breakpoint_test[] = { | |||
465 | { "?", "S0*" }, /* Clear break points */ | 466 | { "?", "S0*" }, /* Clear break points */ |
466 | { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ | 467 | { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ |
467 | { "c", "T0*", }, /* Continue */ | 468 | { "c", "T0*", }, /* Continue */ |
468 | { "g", "kgdbts_break_test", 0, check_and_rewind_pc }, | 469 | { "g", "kgdbts_break_test", NULL, check_and_rewind_pc }, |
469 | { "write", "OK", write_regs }, | 470 | { "write", "OK", write_regs }, |
470 | { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */ | 471 | { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */ |
471 | { "D", "OK" }, /* Detach */ | 472 | { "D", "OK" }, /* Detach */ |
472 | { "D", "OK", 0, got_break }, /* If the test worked we made it here */ | 473 | { "D", "OK", NULL, got_break }, /* On success we made it here */ |
473 | { "", "" }, | 474 | { "", "" }, |
474 | }; | 475 | }; |
475 | 476 | ||
@@ -499,14 +500,14 @@ static struct test_struct singlestep_break_test[] = { | |||
499 | { "?", "S0*" }, /* Clear break points */ | 500 | { "?", "S0*" }, /* Clear break points */ |
500 | { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ | 501 | { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ |
501 | { "c", "T0*", }, /* Continue */ | 502 | { "c", "T0*", }, /* Continue */ |
502 | { "g", "kgdbts_break_test", 0, check_and_rewind_pc }, | 503 | { "g", "kgdbts_break_test", NULL, check_and_rewind_pc }, |
503 | { "write", "OK", write_regs }, /* Write registers */ | 504 | { "write", "OK", write_regs }, /* Write registers */ |
504 | { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */ | 505 | { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */ |
505 | { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ | 506 | { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ |
506 | { "g", "kgdbts_break_test", 0, check_single_step }, | 507 | { "g", "kgdbts_break_test", NULL, check_single_step }, |
507 | { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ | 508 | { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ |
508 | { "c", "T0*", }, /* Continue */ | 509 | { "c", "T0*", }, /* Continue */ |
509 | { "g", "kgdbts_break_test", 0, check_and_rewind_pc }, | 510 | { "g", "kgdbts_break_test", NULL, check_and_rewind_pc }, |
510 | { "write", "OK", write_regs }, /* Write registers */ | 511 | { "write", "OK", write_regs }, /* Write registers */ |
511 | { "D", "OK" }, /* Remove all breakpoints and continues */ | 512 | { "D", "OK" }, /* Remove all breakpoints and continues */ |
512 | { "", "" }, | 513 | { "", "" }, |
@@ -520,14 +521,14 @@ static struct test_struct do_fork_test[] = { | |||
520 | { "?", "S0*" }, /* Clear break points */ | 521 | { "?", "S0*" }, /* Clear break points */ |
521 | { "do_fork", "OK", sw_break, }, /* set sw breakpoint */ | 522 | { "do_fork", "OK", sw_break, }, /* set sw breakpoint */ |
522 | { "c", "T0*", }, /* Continue */ | 523 | { "c", "T0*", }, /* Continue */ |
523 | { "g", "do_fork", 0, check_and_rewind_pc }, /* check location */ | 524 | { "g", "do_fork", NULL, check_and_rewind_pc }, /* check location */ |
524 | { "write", "OK", write_regs }, /* Write registers */ | 525 | { "write", "OK", write_regs }, /* Write registers */ |
525 | { "do_fork", "OK", sw_rem_break }, /*remove breakpoint */ | 526 | { "do_fork", "OK", sw_rem_break }, /*remove breakpoint */ |
526 | { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ | 527 | { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ |
527 | { "g", "do_fork", 0, check_single_step }, | 528 | { "g", "do_fork", NULL, check_single_step }, |
528 | { "do_fork", "OK", sw_break, }, /* set sw breakpoint */ | 529 | { "do_fork", "OK", sw_break, }, /* set sw breakpoint */ |
529 | { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */ | 530 | { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */ |
530 | { "D", "OK", 0, final_ack_set }, /* detach and unregister I/O */ | 531 | { "D", "OK", NULL, final_ack_set }, /* detach and unregister I/O */ |
531 | { "", "" }, | 532 | { "", "" }, |
532 | }; | 533 | }; |
533 | 534 | ||
@@ -538,14 +539,14 @@ static struct test_struct sys_open_test[] = { | |||
538 | { "?", "S0*" }, /* Clear break points */ | 539 | { "?", "S0*" }, /* Clear break points */ |
539 | { "sys_open", "OK", sw_break, }, /* set sw breakpoint */ | 540 | { "sys_open", "OK", sw_break, }, /* set sw breakpoint */ |
540 | { "c", "T0*", }, /* Continue */ | 541 | { "c", "T0*", }, /* Continue */ |
541 | { "g", "sys_open", 0, check_and_rewind_pc }, /* check location */ | 542 | { "g", "sys_open", NULL, check_and_rewind_pc }, /* check location */ |
542 | { "write", "OK", write_regs }, /* Write registers */ | 543 | { "write", "OK", write_regs }, /* Write registers */ |
543 | { "sys_open", "OK", sw_rem_break }, /*remove breakpoint */ | 544 | { "sys_open", "OK", sw_rem_break }, /*remove breakpoint */ |
544 | { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ | 545 | { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ |
545 | { "g", "sys_open", 0, check_single_step }, | 546 | { "g", "sys_open", NULL, check_single_step }, |
546 | { "sys_open", "OK", sw_break, }, /* set sw breakpoint */ | 547 | { "sys_open", "OK", sw_break, }, /* set sw breakpoint */ |
547 | { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */ | 548 | { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */ |
548 | { "D", "OK", 0, final_ack_set }, /* detach and unregister I/O */ | 549 | { "D", "OK", NULL, final_ack_set }, /* detach and unregister I/O */ |
549 | { "", "" }, | 550 | { "", "" }, |
550 | }; | 551 | }; |
551 | 552 | ||
@@ -556,11 +557,11 @@ static struct test_struct hw_breakpoint_test[] = { | |||
556 | { "?", "S0*" }, /* Clear break points */ | 557 | { "?", "S0*" }, /* Clear break points */ |
557 | { "kgdbts_break_test", "OK", hw_break, }, /* set hw breakpoint */ | 558 | { "kgdbts_break_test", "OK", hw_break, }, /* set hw breakpoint */ |
558 | { "c", "T0*", }, /* Continue */ | 559 | { "c", "T0*", }, /* Continue */ |
559 | { "g", "kgdbts_break_test", 0, check_and_rewind_pc }, | 560 | { "g", "kgdbts_break_test", NULL, check_and_rewind_pc }, |
560 | { "write", "OK", write_regs }, | 561 | { "write", "OK", write_regs }, |
561 | { "kgdbts_break_test", "OK", hw_rem_break }, /*remove breakpoint */ | 562 | { "kgdbts_break_test", "OK", hw_rem_break }, /*remove breakpoint */ |
562 | { "D", "OK" }, /* Detach */ | 563 | { "D", "OK" }, /* Detach */ |
563 | { "D", "OK", 0, got_break }, /* If the test worked we made it here */ | 564 | { "D", "OK", NULL, got_break }, /* On success we made it here */ |
564 | { "", "" }, | 565 | { "", "" }, |
565 | }; | 566 | }; |
566 | 567 | ||
@@ -570,12 +571,12 @@ static struct test_struct hw_breakpoint_test[] = { | |||
570 | static struct test_struct hw_write_break_test[] = { | 571 | static struct test_struct hw_write_break_test[] = { |
571 | { "?", "S0*" }, /* Clear break points */ | 572 | { "?", "S0*" }, /* Clear break points */ |
572 | { "hw_break_val", "OK", hw_write_break, }, /* set hw breakpoint */ | 573 | { "hw_break_val", "OK", hw_write_break, }, /* set hw breakpoint */ |
573 | { "c", "T0*", 0, got_break }, /* Continue */ | 574 | { "c", "T0*", NULL, got_break }, /* Continue */ |
574 | { "g", "silent", 0, check_and_rewind_pc }, | 575 | { "g", "silent", NULL, check_and_rewind_pc }, |
575 | { "write", "OK", write_regs }, | 576 | { "write", "OK", write_regs }, |
576 | { "hw_break_val", "OK", hw_rem_write_break }, /*remove breakpoint */ | 577 | { "hw_break_val", "OK", hw_rem_write_break }, /*remove breakpoint */ |
577 | { "D", "OK" }, /* Detach */ | 578 | { "D", "OK" }, /* Detach */ |
578 | { "D", "OK", 0, got_break }, /* If the test worked we made it here */ | 579 | { "D", "OK", NULL, got_break }, /* On success we made it here */ |
579 | { "", "" }, | 580 | { "", "" }, |
580 | }; | 581 | }; |
581 | 582 | ||
@@ -585,12 +586,12 @@ static struct test_struct hw_write_break_test[] = { | |||
585 | static struct test_struct hw_access_break_test[] = { | 586 | static struct test_struct hw_access_break_test[] = { |
586 | { "?", "S0*" }, /* Clear break points */ | 587 | { "?", "S0*" }, /* Clear break points */ |
587 | { "hw_break_val", "OK", hw_access_break, }, /* set hw breakpoint */ | 588 | { "hw_break_val", "OK", hw_access_break, }, /* set hw breakpoint */ |
588 | { "c", "T0*", 0, got_break }, /* Continue */ | 589 | { "c", "T0*", NULL, got_break }, /* Continue */ |
589 | { "g", "silent", 0, check_and_rewind_pc }, | 590 | { "g", "silent", NULL, check_and_rewind_pc }, |
590 | { "write", "OK", write_regs }, | 591 | { "write", "OK", write_regs }, |
591 | { "hw_break_val", "OK", hw_rem_access_break }, /*remove breakpoint */ | 592 | { "hw_break_val", "OK", hw_rem_access_break }, /*remove breakpoint */ |
592 | { "D", "OK" }, /* Detach */ | 593 | { "D", "OK" }, /* Detach */ |
593 | { "D", "OK", 0, got_break }, /* If the test worked we made it here */ | 594 | { "D", "OK", NULL, got_break }, /* On success we made it here */ |
594 | { "", "" }, | 595 | { "", "" }, |
595 | }; | 596 | }; |
596 | 597 | ||
@@ -599,9 +600,9 @@ static struct test_struct hw_access_break_test[] = { | |||
599 | */ | 600 | */ |
600 | static struct test_struct nmi_sleep_test[] = { | 601 | static struct test_struct nmi_sleep_test[] = { |
601 | { "?", "S0*" }, /* Clear break points */ | 602 | { "?", "S0*" }, /* Clear break points */ |
602 | { "c", "T0*", 0, got_break }, /* Continue */ | 603 | { "c", "T0*", NULL, got_break }, /* Continue */ |
603 | { "D", "OK" }, /* Detach */ | 604 | { "D", "OK" }, /* Detach */ |
604 | { "D", "OK", 0, got_break }, /* If the test worked we made it here */ | 605 | { "D", "OK", NULL, got_break }, /* On success we made it here */ |
605 | { "", "" }, | 606 | { "", "" }, |
606 | }; | 607 | }; |
607 | 608 | ||
@@ -874,18 +875,23 @@ static void kgdbts_run_tests(void) | |||
874 | { | 875 | { |
875 | char *ptr; | 876 | char *ptr; |
876 | int fork_test = 0; | 877 | int fork_test = 0; |
877 | int sys_open_test = 0; | 878 | int do_sys_open_test = 0; |
879 | int sstep_test = 1000; | ||
878 | int nmi_sleep = 0; | 880 | int nmi_sleep = 0; |
881 | int i; | ||
879 | 882 | ||
880 | ptr = strstr(config, "F"); | 883 | ptr = strstr(config, "F"); |
881 | if (ptr) | 884 | if (ptr) |
882 | fork_test = simple_strtol(ptr+1, NULL, 10); | 885 | fork_test = simple_strtol(ptr + 1, NULL, 10); |
883 | ptr = strstr(config, "S"); | 886 | ptr = strstr(config, "S"); |
884 | if (ptr) | 887 | if (ptr) |
885 | sys_open_test = simple_strtol(ptr+1, NULL, 10); | 888 | do_sys_open_test = simple_strtol(ptr + 1, NULL, 10); |
886 | ptr = strstr(config, "N"); | 889 | ptr = strstr(config, "N"); |
887 | if (ptr) | 890 | if (ptr) |
888 | nmi_sleep = simple_strtol(ptr+1, NULL, 10); | 891 | nmi_sleep = simple_strtol(ptr+1, NULL, 10); |
892 | ptr = strstr(config, "I"); | ||
893 | if (ptr) | ||
894 | sstep_test = simple_strtol(ptr+1, NULL, 10); | ||
889 | 895 | ||
890 | /* required internal KGDB tests */ | 896 | /* required internal KGDB tests */ |
891 | v1printk("kgdbts:RUN plant and detach test\n"); | 897 | v1printk("kgdbts:RUN plant and detach test\n"); |
@@ -894,8 +900,13 @@ static void kgdbts_run_tests(void) | |||
894 | run_breakpoint_test(0); | 900 | run_breakpoint_test(0); |
895 | v1printk("kgdbts:RUN bad memory access test\n"); | 901 | v1printk("kgdbts:RUN bad memory access test\n"); |
896 | run_bad_read_test(); | 902 | run_bad_read_test(); |
897 | v1printk("kgdbts:RUN singlestep breakpoint test\n"); | 903 | v1printk("kgdbts:RUN singlestep test %i iterations\n", sstep_test); |
898 | run_singlestep_break_test(); | 904 | for (i = 0; i < sstep_test; i++) { |
905 | run_singlestep_break_test(); | ||
906 | if (i % 100 == 0) | ||
907 | v1printk("kgdbts:RUN singlestep [%i/%i]\n", | ||
908 | i, sstep_test); | ||
909 | } | ||
899 | 910 | ||
900 | /* ===Optional tests=== */ | 911 | /* ===Optional tests=== */ |
901 | 912 | ||
@@ -922,7 +933,7 @@ static void kgdbts_run_tests(void) | |||
922 | repeat_test = fork_test; | 933 | repeat_test = fork_test; |
923 | printk(KERN_INFO "kgdbts:RUN do_fork for %i breakpoints\n", | 934 | printk(KERN_INFO "kgdbts:RUN do_fork for %i breakpoints\n", |
924 | repeat_test); | 935 | repeat_test); |
925 | kthread_run(kgdbts_unreg_thread, 0, "kgdbts_unreg"); | 936 | kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg"); |
926 | run_do_fork_test(); | 937 | run_do_fork_test(); |
927 | return; | 938 | return; |
928 | } | 939 | } |
@@ -931,11 +942,11 @@ static void kgdbts_run_tests(void) | |||
931 | * executed because a kernel thread will be spawned at the very | 942 | * executed because a kernel thread will be spawned at the very |
932 | * end to unregister the debug hooks. | 943 | * end to unregister the debug hooks. |
933 | */ | 944 | */ |
934 | if (sys_open_test) { | 945 | if (do_sys_open_test) { |
935 | repeat_test = sys_open_test; | 946 | repeat_test = do_sys_open_test; |
936 | printk(KERN_INFO "kgdbts:RUN sys_open for %i breakpoints\n", | 947 | printk(KERN_INFO "kgdbts:RUN sys_open for %i breakpoints\n", |
937 | repeat_test); | 948 | repeat_test); |
938 | kthread_run(kgdbts_unreg_thread, 0, "kgdbts_unreg"); | 949 | kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg"); |
939 | run_sys_open_test(); | 950 | run_sys_open_test(); |
940 | return; | 951 | return; |
941 | } | 952 | } |
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index e812df607a5c..fcd1aeccdf93 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
@@ -82,9 +82,8 @@ static struct mtd_info *cfi_intelext_setup (struct mtd_info *); | |||
82 | static int cfi_intelext_partition_fixup(struct mtd_info *, struct cfi_private **); | 82 | static int cfi_intelext_partition_fixup(struct mtd_info *, struct cfi_private **); |
83 | 83 | ||
84 | static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, | 84 | static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, |
85 | size_t *retlen, u_char **mtdbuf); | 85 | size_t *retlen, void **virt, resource_size_t *phys); |
86 | static void cfi_intelext_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, | 86 | static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len); |
87 | size_t len); | ||
88 | 87 | ||
89 | static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); | 88 | static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); |
90 | static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); | 89 | static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); |
@@ -1240,7 +1239,8 @@ static int do_point_onechip (struct map_info *map, struct flchip *chip, loff_t a | |||
1240 | return ret; | 1239 | return ret; |
1241 | } | 1240 | } |
1242 | 1241 | ||
1243 | static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf) | 1242 | static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len, |
1243 | size_t *retlen, void **virt, resource_size_t *phys) | ||
1244 | { | 1244 | { |
1245 | struct map_info *map = mtd->priv; | 1245 | struct map_info *map = mtd->priv; |
1246 | struct cfi_private *cfi = map->fldrv_priv; | 1246 | struct cfi_private *cfi = map->fldrv_priv; |
@@ -1257,8 +1257,10 @@ static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, si | |||
1257 | chipnum = (from >> cfi->chipshift); | 1257 | chipnum = (from >> cfi->chipshift); |
1258 | ofs = from - (chipnum << cfi->chipshift); | 1258 | ofs = from - (chipnum << cfi->chipshift); |
1259 | 1259 | ||
1260 | *mtdbuf = (void *)map->virt + cfi->chips[chipnum].start + ofs; | 1260 | *virt = map->virt + cfi->chips[chipnum].start + ofs; |
1261 | *retlen = 0; | 1261 | *retlen = 0; |
1262 | if (phys) | ||
1263 | *phys = map->phys + cfi->chips[chipnum].start + ofs; | ||
1262 | 1264 | ||
1263 | while (len) { | 1265 | while (len) { |
1264 | unsigned long thislen; | 1266 | unsigned long thislen; |
@@ -1291,7 +1293,7 @@ static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, si | |||
1291 | return 0; | 1293 | return 0; |
1292 | } | 1294 | } |
1293 | 1295 | ||
1294 | static void cfi_intelext_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, size_t len) | 1296 | static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
1295 | { | 1297 | { |
1296 | struct map_info *map = mtd->priv; | 1298 | struct map_info *map = mtd->priv; |
1297 | struct cfi_private *cfi = map->fldrv_priv; | 1299 | struct cfi_private *cfi = map->fldrv_priv; |
diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index bf485ff49457..0399be178620 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c | |||
@@ -48,18 +48,21 @@ static int ram_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
48 | } | 48 | } |
49 | 49 | ||
50 | static int ram_point(struct mtd_info *mtd, loff_t from, size_t len, | 50 | static int ram_point(struct mtd_info *mtd, loff_t from, size_t len, |
51 | size_t *retlen, u_char **mtdbuf) | 51 | size_t *retlen, void **virt, resource_size_t *phys) |
52 | { | 52 | { |
53 | if (from + len > mtd->size) | 53 | if (from + len > mtd->size) |
54 | return -EINVAL; | 54 | return -EINVAL; |
55 | 55 | ||
56 | *mtdbuf = mtd->priv + from; | 56 | /* can we return a physical address with this driver? */ |
57 | if (phys) | ||
58 | return -EINVAL; | ||
59 | |||
60 | *virt = mtd->priv + from; | ||
57 | *retlen = len; | 61 | *retlen = len; |
58 | return 0; | 62 | return 0; |
59 | } | 63 | } |
60 | 64 | ||
61 | static void ram_unpoint(struct mtd_info *mtd, u_char * addr, loff_t from, | 65 | static void ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
62 | size_t len) | ||
63 | { | 66 | { |
64 | } | 67 | } |
65 | 68 | ||
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 5f960182da95..c7987b1c5e01 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c | |||
@@ -57,20 +57,21 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
57 | } | 57 | } |
58 | 58 | ||
59 | static int phram_point(struct mtd_info *mtd, loff_t from, size_t len, | 59 | static int phram_point(struct mtd_info *mtd, loff_t from, size_t len, |
60 | size_t *retlen, u_char **mtdbuf) | 60 | size_t *retlen, void **virt, resource_size_t *phys) |
61 | { | 61 | { |
62 | u_char *start = mtd->priv; | ||
63 | |||
64 | if (from + len > mtd->size) | 62 | if (from + len > mtd->size) |
65 | return -EINVAL; | 63 | return -EINVAL; |
66 | 64 | ||
67 | *mtdbuf = start + from; | 65 | /* can we return a physical address with this driver? */ |
66 | if (phys) | ||
67 | return -EINVAL; | ||
68 | |||
69 | *virt = mtd->priv + from; | ||
68 | *retlen = len; | 70 | *retlen = len; |
69 | return 0; | 71 | return 0; |
70 | } | 72 | } |
71 | 73 | ||
72 | static void phram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, | 74 | static void phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
73 | size_t len) | ||
74 | { | 75 | { |
75 | } | 76 | } |
76 | 77 | ||
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c index 7060a0895ce2..bc9981749064 100644 --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c | |||
@@ -134,7 +134,8 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
134 | eoff_lo = end & (priv->asize - 1); | 134 | eoff_lo = end & (priv->asize - 1); |
135 | soff_lo = instr->addr & (priv->asize - 1); | 135 | soff_lo = instr->addr & (priv->asize - 1); |
136 | 136 | ||
137 | pmc551_point(mtd, instr->addr, instr->len, &retlen, &ptr); | 137 | pmc551_point(mtd, instr->addr, instr->len, &retlen, |
138 | (void **)&ptr, NULL); | ||
138 | 139 | ||
139 | if (soff_hi == eoff_hi || mtd->size == priv->asize) { | 140 | if (soff_hi == eoff_hi || mtd->size == priv->asize) { |
140 | /* The whole thing fits within one access, so just one shot | 141 | /* The whole thing fits within one access, so just one shot |
@@ -154,7 +155,8 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
154 | } | 155 | } |
155 | soff_hi += priv->asize; | 156 | soff_hi += priv->asize; |
156 | pmc551_point(mtd, (priv->base_map0 | soff_hi), | 157 | pmc551_point(mtd, (priv->base_map0 | soff_hi), |
157 | priv->asize, &retlen, &ptr); | 158 | priv->asize, &retlen, |
159 | (void **)&ptr, NULL); | ||
158 | } | 160 | } |
159 | memset(ptr, 0xff, eoff_lo); | 161 | memset(ptr, 0xff, eoff_lo); |
160 | } | 162 | } |
@@ -170,7 +172,7 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
170 | } | 172 | } |
171 | 173 | ||
172 | static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, | 174 | static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, |
173 | size_t * retlen, u_char ** mtdbuf) | 175 | size_t *retlen, void **virt, resource_size_t *phys) |
174 | { | 176 | { |
175 | struct mypriv *priv = mtd->priv; | 177 | struct mypriv *priv = mtd->priv; |
176 | u32 soff_hi; | 178 | u32 soff_hi; |
@@ -188,6 +190,10 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
188 | return -EINVAL; | 190 | return -EINVAL; |
189 | } | 191 | } |
190 | 192 | ||
193 | /* can we return a physical address with this driver? */ | ||
194 | if (phys) | ||
195 | return -EINVAL; | ||
196 | |||
191 | soff_hi = from & ~(priv->asize - 1); | 197 | soff_hi = from & ~(priv->asize - 1); |
192 | soff_lo = from & (priv->asize - 1); | 198 | soff_lo = from & (priv->asize - 1); |
193 | 199 | ||
@@ -198,13 +204,12 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
198 | priv->curr_map0 = soff_hi; | 204 | priv->curr_map0 = soff_hi; |
199 | } | 205 | } |
200 | 206 | ||
201 | *mtdbuf = priv->start + soff_lo; | 207 | *virt = priv->start + soff_lo; |
202 | *retlen = len; | 208 | *retlen = len; |
203 | return 0; | 209 | return 0; |
204 | } | 210 | } |
205 | 211 | ||
206 | static void pmc551_unpoint(struct mtd_info *mtd, u_char * addr, loff_t from, | 212 | static void pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
207 | size_t len) | ||
208 | { | 213 | { |
209 | #ifdef CONFIG_MTD_PMC551_DEBUG | 214 | #ifdef CONFIG_MTD_PMC551_DEBUG |
210 | printk(KERN_DEBUG "pmc551_unpoint()\n"); | 215 | printk(KERN_DEBUG "pmc551_unpoint()\n"); |
@@ -242,7 +247,7 @@ static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
242 | soff_lo = from & (priv->asize - 1); | 247 | soff_lo = from & (priv->asize - 1); |
243 | eoff_lo = end & (priv->asize - 1); | 248 | eoff_lo = end & (priv->asize - 1); |
244 | 249 | ||
245 | pmc551_point(mtd, from, len, retlen, &ptr); | 250 | pmc551_point(mtd, from, len, retlen, (void **)&ptr, NULL); |
246 | 251 | ||
247 | if (soff_hi == eoff_hi) { | 252 | if (soff_hi == eoff_hi) { |
248 | /* The whole thing fits within one access, so just one shot | 253 | /* The whole thing fits within one access, so just one shot |
@@ -263,7 +268,8 @@ static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
263 | goto out; | 268 | goto out; |
264 | } | 269 | } |
265 | soff_hi += priv->asize; | 270 | soff_hi += priv->asize; |
266 | pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr); | 271 | pmc551_point(mtd, soff_hi, priv->asize, retlen, |
272 | (void **)&ptr, NULL); | ||
267 | } | 273 | } |
268 | memcpy(copyto, ptr, eoff_lo); | 274 | memcpy(copyto, ptr, eoff_lo); |
269 | copyto += eoff_lo; | 275 | copyto += eoff_lo; |
@@ -308,7 +314,7 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
308 | soff_lo = to & (priv->asize - 1); | 314 | soff_lo = to & (priv->asize - 1); |
309 | eoff_lo = end & (priv->asize - 1); | 315 | eoff_lo = end & (priv->asize - 1); |
310 | 316 | ||
311 | pmc551_point(mtd, to, len, retlen, &ptr); | 317 | pmc551_point(mtd, to, len, retlen, (void **)&ptr, NULL); |
312 | 318 | ||
313 | if (soff_hi == eoff_hi) { | 319 | if (soff_hi == eoff_hi) { |
314 | /* The whole thing fits within one access, so just one shot | 320 | /* The whole thing fits within one access, so just one shot |
@@ -329,7 +335,8 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
329 | goto out; | 335 | goto out; |
330 | } | 336 | } |
331 | soff_hi += priv->asize; | 337 | soff_hi += priv->asize; |
332 | pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr); | 338 | pmc551_point(mtd, soff_hi, priv->asize, retlen, |
339 | (void **)&ptr, NULL); | ||
333 | } | 340 | } |
334 | memcpy(ptr, copyfrom, eoff_lo); | 341 | memcpy(ptr, copyfrom, eoff_lo); |
335 | copyfrom += eoff_lo; | 342 | copyfrom += eoff_lo; |
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index d293add1857c..cb86db746f28 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c | |||
@@ -76,8 +76,9 @@ static char *map; | |||
76 | static slram_mtd_list_t *slram_mtdlist = NULL; | 76 | static slram_mtd_list_t *slram_mtdlist = NULL; |
77 | 77 | ||
78 | static int slram_erase(struct mtd_info *, struct erase_info *); | 78 | static int slram_erase(struct mtd_info *, struct erase_info *); |
79 | static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, u_char **); | 79 | static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, void **, |
80 | static void slram_unpoint(struct mtd_info *, u_char *, loff_t, size_t); | 80 | resource_size_t *); |
81 | static void slram_unpoint(struct mtd_info *, loff_t, size_t); | ||
81 | static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); | 82 | static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); |
82 | static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); | 83 | static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); |
83 | 84 | ||
@@ -104,19 +105,23 @@ static int slram_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
104 | } | 105 | } |
105 | 106 | ||
106 | static int slram_point(struct mtd_info *mtd, loff_t from, size_t len, | 107 | static int slram_point(struct mtd_info *mtd, loff_t from, size_t len, |
107 | size_t *retlen, u_char **mtdbuf) | 108 | size_t *retlen, void **virt, resource_size_t *phys) |
108 | { | 109 | { |
109 | slram_priv_t *priv = mtd->priv; | 110 | slram_priv_t *priv = mtd->priv; |
110 | 111 | ||
112 | /* can we return a physical address with this driver? */ | ||
113 | if (phys) | ||
114 | return -EINVAL; | ||
115 | |||
111 | if (from + len > mtd->size) | 116 | if (from + len > mtd->size) |
112 | return -EINVAL; | 117 | return -EINVAL; |
113 | 118 | ||
114 | *mtdbuf = priv->start + from; | 119 | *virt = priv->start + from; |
115 | *retlen = len; | 120 | *retlen = len; |
116 | return(0); | 121 | return(0); |
117 | } | 122 | } |
118 | 123 | ||
119 | static void slram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, size_t len) | 124 | static void slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
120 | { | 125 | { |
121 | } | 126 | } |
122 | 127 | ||
diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c index 14ffb1a9302a..c42f4b83f686 100644 --- a/drivers/mtd/maps/uclinux.c +++ b/drivers/mtd/maps/uclinux.c | |||
@@ -40,10 +40,12 @@ struct mtd_partition uclinux_romfs[] = { | |||
40 | /****************************************************************************/ | 40 | /****************************************************************************/ |
41 | 41 | ||
42 | int uclinux_point(struct mtd_info *mtd, loff_t from, size_t len, | 42 | int uclinux_point(struct mtd_info *mtd, loff_t from, size_t len, |
43 | size_t *retlen, u_char **mtdbuf) | 43 | size_t *retlen, void **virt, resource_size_t *phys) |
44 | { | 44 | { |
45 | struct map_info *map = mtd->priv; | 45 | struct map_info *map = mtd->priv; |
46 | *mtdbuf = (u_char *) (map->virt + ((int) from)); | 46 | *virt = map->virt + from; |
47 | if (phys) | ||
48 | *phys = map->phys + from; | ||
47 | *retlen = len; | 49 | *retlen = len; |
48 | return(0); | 50 | return(0); |
49 | } | 51 | } |
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index c66902df3171..07c701169344 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -68,7 +68,7 @@ static int part_read (struct mtd_info *mtd, loff_t from, size_t len, | |||
68 | } | 68 | } |
69 | 69 | ||
70 | static int part_point (struct mtd_info *mtd, loff_t from, size_t len, | 70 | static int part_point (struct mtd_info *mtd, loff_t from, size_t len, |
71 | size_t *retlen, u_char **buf) | 71 | size_t *retlen, void **virt, resource_size_t *phys) |
72 | { | 72 | { |
73 | struct mtd_part *part = PART(mtd); | 73 | struct mtd_part *part = PART(mtd); |
74 | if (from >= mtd->size) | 74 | if (from >= mtd->size) |
@@ -76,14 +76,14 @@ static int part_point (struct mtd_info *mtd, loff_t from, size_t len, | |||
76 | else if (from + len > mtd->size) | 76 | else if (from + len > mtd->size) |
77 | len = mtd->size - from; | 77 | len = mtd->size - from; |
78 | return part->master->point (part->master, from + part->offset, | 78 | return part->master->point (part->master, from + part->offset, |
79 | len, retlen, buf); | 79 | len, retlen, virt, phys); |
80 | } | 80 | } |
81 | 81 | ||
82 | static void part_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, size_t len) | 82 | static void part_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
83 | { | 83 | { |
84 | struct mtd_part *part = PART(mtd); | 84 | struct mtd_part *part = PART(mtd); |
85 | 85 | ||
86 | part->master->unpoint (part->master, addr, from + part->offset, len); | 86 | part->master->unpoint(part->master, from + part->offset, len); |
87 | } | 87 | } |
88 | 88 | ||
89 | static int part_read_oob(struct mtd_info *mtd, loff_t from, | 89 | static int part_read_oob(struct mtd_info *mtd, loff_t from, |
diff --git a/drivers/mtd/nand/at91_nand.c b/drivers/mtd/nand/at91_nand.c index 414ceaecdb3a..0adb287027a2 100644 --- a/drivers/mtd/nand/at91_nand.c +++ b/drivers/mtd/nand/at91_nand.c | |||
@@ -94,6 +94,24 @@ struct at91_nand_host { | |||
94 | }; | 94 | }; |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * Enable NAND. | ||
98 | */ | ||
99 | static void at91_nand_enable(struct at91_nand_host *host) | ||
100 | { | ||
101 | if (host->board->enable_pin) | ||
102 | at91_set_gpio_value(host->board->enable_pin, 0); | ||
103 | } | ||
104 | |||
105 | /* | ||
106 | * Disable NAND. | ||
107 | */ | ||
108 | static void at91_nand_disable(struct at91_nand_host *host) | ||
109 | { | ||
110 | if (host->board->enable_pin) | ||
111 | at91_set_gpio_value(host->board->enable_pin, 1); | ||
112 | } | ||
113 | |||
114 | /* | ||
97 | * Hardware specific access to control-lines | 115 | * Hardware specific access to control-lines |
98 | */ | 116 | */ |
99 | static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) | 117 | static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
@@ -101,11 +119,11 @@ static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) | |||
101 | struct nand_chip *nand_chip = mtd->priv; | 119 | struct nand_chip *nand_chip = mtd->priv; |
102 | struct at91_nand_host *host = nand_chip->priv; | 120 | struct at91_nand_host *host = nand_chip->priv; |
103 | 121 | ||
104 | if (host->board->enable_pin && (ctrl & NAND_CTRL_CHANGE)) { | 122 | if (ctrl & NAND_CTRL_CHANGE) { |
105 | if (ctrl & NAND_NCE) | 123 | if (ctrl & NAND_NCE) |
106 | at91_set_gpio_value(host->board->enable_pin, 0); | 124 | at91_nand_enable(host); |
107 | else | 125 | else |
108 | at91_set_gpio_value(host->board->enable_pin, 1); | 126 | at91_nand_disable(host); |
109 | } | 127 | } |
110 | if (cmd == NAND_CMD_NONE) | 128 | if (cmd == NAND_CMD_NONE) |
111 | return; | 129 | return; |
@@ -128,24 +146,6 @@ static int at91_nand_device_ready(struct mtd_info *mtd) | |||
128 | } | 146 | } |
129 | 147 | ||
130 | /* | 148 | /* |
131 | * Enable NAND. | ||
132 | */ | ||
133 | static void at91_nand_enable(struct at91_nand_host *host) | ||
134 | { | ||
135 | if (host->board->enable_pin) | ||
136 | at91_set_gpio_value(host->board->enable_pin, 0); | ||
137 | } | ||
138 | |||
139 | /* | ||
140 | * Disable NAND. | ||
141 | */ | ||
142 | static void at91_nand_disable(struct at91_nand_host *host) | ||
143 | { | ||
144 | if (host->board->enable_pin) | ||
145 | at91_set_gpio_value(host->board->enable_pin, 1); | ||
146 | } | ||
147 | |||
148 | /* | ||
149 | * write oob for small pages | 149 | * write oob for small pages |
150 | */ | 150 | */ |
151 | static int at91_nand_write_oob_512(struct mtd_info *mtd, | 151 | static int at91_nand_write_oob_512(struct mtd_info *mtd, |
diff --git a/drivers/net/fec.c b/drivers/net/fec.c index d7a3ea88eddb..32a4f17d35fc 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c | |||
@@ -67,6 +67,10 @@ | |||
67 | #define FEC_MAX_PORTS 1 | 67 | #define FEC_MAX_PORTS 1 |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | #if defined(CONFIG_FADS) || defined(CONFIG_RPXCLASSIC) || defined(CONFIG_M5272) | ||
71 | #define HAVE_mii_link_interrupt | ||
72 | #endif | ||
73 | |||
70 | /* | 74 | /* |
71 | * Define the fixed address of the FEC hardware. | 75 | * Define the fixed address of the FEC hardware. |
72 | */ | 76 | */ |
@@ -205,7 +209,10 @@ struct fec_enet_private { | |||
205 | cbd_t *cur_rx, *cur_tx; /* The next free ring entry */ | 209 | cbd_t *cur_rx, *cur_tx; /* The next free ring entry */ |
206 | cbd_t *dirty_tx; /* The ring entries to be free()ed. */ | 210 | cbd_t *dirty_tx; /* The ring entries to be free()ed. */ |
207 | uint tx_full; | 211 | uint tx_full; |
208 | spinlock_t lock; | 212 | /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */ |
213 | spinlock_t hw_lock; | ||
214 | /* hold while accessing the mii_list_t() elements */ | ||
215 | spinlock_t mii_lock; | ||
209 | 216 | ||
210 | uint phy_id; | 217 | uint phy_id; |
211 | uint phy_id_done; | 218 | uint phy_id_done; |
@@ -309,6 +316,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
309 | volatile fec_t *fecp; | 316 | volatile fec_t *fecp; |
310 | volatile cbd_t *bdp; | 317 | volatile cbd_t *bdp; |
311 | unsigned short status; | 318 | unsigned short status; |
319 | unsigned long flags; | ||
312 | 320 | ||
313 | fep = netdev_priv(dev); | 321 | fep = netdev_priv(dev); |
314 | fecp = (volatile fec_t*)dev->base_addr; | 322 | fecp = (volatile fec_t*)dev->base_addr; |
@@ -318,6 +326,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
318 | return 1; | 326 | return 1; |
319 | } | 327 | } |
320 | 328 | ||
329 | spin_lock_irqsave(&fep->hw_lock, flags); | ||
321 | /* Fill in a Tx ring entry */ | 330 | /* Fill in a Tx ring entry */ |
322 | bdp = fep->cur_tx; | 331 | bdp = fep->cur_tx; |
323 | 332 | ||
@@ -328,6 +337,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
328 | * This should not happen, since dev->tbusy should be set. | 337 | * This should not happen, since dev->tbusy should be set. |
329 | */ | 338 | */ |
330 | printk("%s: tx queue full!.\n", dev->name); | 339 | printk("%s: tx queue full!.\n", dev->name); |
340 | spin_unlock_irqrestore(&fep->hw_lock, flags); | ||
331 | return 1; | 341 | return 1; |
332 | } | 342 | } |
333 | #endif | 343 | #endif |
@@ -366,8 +376,6 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
366 | flush_dcache_range((unsigned long)skb->data, | 376 | flush_dcache_range((unsigned long)skb->data, |
367 | (unsigned long)skb->data + skb->len); | 377 | (unsigned long)skb->data + skb->len); |
368 | 378 | ||
369 | spin_lock_irq(&fep->lock); | ||
370 | |||
371 | /* Send it on its way. Tell FEC it's ready, interrupt when done, | 379 | /* Send it on its way. Tell FEC it's ready, interrupt when done, |
372 | * it's the last BD of the frame, and to put the CRC on the end. | 380 | * it's the last BD of the frame, and to put the CRC on the end. |
373 | */ | 381 | */ |
@@ -396,7 +404,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
396 | 404 | ||
397 | fep->cur_tx = (cbd_t *)bdp; | 405 | fep->cur_tx = (cbd_t *)bdp; |
398 | 406 | ||
399 | spin_unlock_irq(&fep->lock); | 407 | spin_unlock_irqrestore(&fep->hw_lock, flags); |
400 | 408 | ||
401 | return 0; | 409 | return 0; |
402 | } | 410 | } |
@@ -454,19 +462,20 @@ fec_enet_interrupt(int irq, void * dev_id) | |||
454 | struct net_device *dev = dev_id; | 462 | struct net_device *dev = dev_id; |
455 | volatile fec_t *fecp; | 463 | volatile fec_t *fecp; |
456 | uint int_events; | 464 | uint int_events; |
457 | int handled = 0; | 465 | irqreturn_t ret = IRQ_NONE; |
458 | 466 | ||
459 | fecp = (volatile fec_t*)dev->base_addr; | 467 | fecp = (volatile fec_t*)dev->base_addr; |
460 | 468 | ||
461 | /* Get the interrupt events that caused us to be here. | 469 | /* Get the interrupt events that caused us to be here. |
462 | */ | 470 | */ |
463 | while ((int_events = fecp->fec_ievent) != 0) { | 471 | do { |
472 | int_events = fecp->fec_ievent; | ||
464 | fecp->fec_ievent = int_events; | 473 | fecp->fec_ievent = int_events; |
465 | 474 | ||
466 | /* Handle receive event in its own function. | 475 | /* Handle receive event in its own function. |
467 | */ | 476 | */ |
468 | if (int_events & FEC_ENET_RXF) { | 477 | if (int_events & FEC_ENET_RXF) { |
469 | handled = 1; | 478 | ret = IRQ_HANDLED; |
470 | fec_enet_rx(dev); | 479 | fec_enet_rx(dev); |
471 | } | 480 | } |
472 | 481 | ||
@@ -475,17 +484,18 @@ fec_enet_interrupt(int irq, void * dev_id) | |||
475 | them as part of the transmit process. | 484 | them as part of the transmit process. |
476 | */ | 485 | */ |
477 | if (int_events & FEC_ENET_TXF) { | 486 | if (int_events & FEC_ENET_TXF) { |
478 | handled = 1; | 487 | ret = IRQ_HANDLED; |
479 | fec_enet_tx(dev); | 488 | fec_enet_tx(dev); |
480 | } | 489 | } |
481 | 490 | ||
482 | if (int_events & FEC_ENET_MII) { | 491 | if (int_events & FEC_ENET_MII) { |
483 | handled = 1; | 492 | ret = IRQ_HANDLED; |
484 | fec_enet_mii(dev); | 493 | fec_enet_mii(dev); |
485 | } | 494 | } |
486 | 495 | ||
487 | } | 496 | } while (int_events); |
488 | return IRQ_RETVAL(handled); | 497 | |
498 | return ret; | ||
489 | } | 499 | } |
490 | 500 | ||
491 | 501 | ||
@@ -498,7 +508,7 @@ fec_enet_tx(struct net_device *dev) | |||
498 | struct sk_buff *skb; | 508 | struct sk_buff *skb; |
499 | 509 | ||
500 | fep = netdev_priv(dev); | 510 | fep = netdev_priv(dev); |
501 | spin_lock(&fep->lock); | 511 | spin_lock_irq(&fep->hw_lock); |
502 | bdp = fep->dirty_tx; | 512 | bdp = fep->dirty_tx; |
503 | 513 | ||
504 | while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) { | 514 | while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) { |
@@ -557,7 +567,7 @@ fec_enet_tx(struct net_device *dev) | |||
557 | } | 567 | } |
558 | } | 568 | } |
559 | fep->dirty_tx = (cbd_t *)bdp; | 569 | fep->dirty_tx = (cbd_t *)bdp; |
560 | spin_unlock(&fep->lock); | 570 | spin_unlock_irq(&fep->hw_lock); |
561 | } | 571 | } |
562 | 572 | ||
563 | 573 | ||
@@ -584,6 +594,8 @@ fec_enet_rx(struct net_device *dev) | |||
584 | fep = netdev_priv(dev); | 594 | fep = netdev_priv(dev); |
585 | fecp = (volatile fec_t*)dev->base_addr; | 595 | fecp = (volatile fec_t*)dev->base_addr; |
586 | 596 | ||
597 | spin_lock_irq(&fep->hw_lock); | ||
598 | |||
587 | /* First, grab all of the stats for the incoming packet. | 599 | /* First, grab all of the stats for the incoming packet. |
588 | * These get messed up if we get called due to a busy condition. | 600 | * These get messed up if we get called due to a busy condition. |
589 | */ | 601 | */ |
@@ -689,6 +701,8 @@ while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) { | |||
689 | */ | 701 | */ |
690 | fecp->fec_r_des_active = 0; | 702 | fecp->fec_r_des_active = 0; |
691 | #endif | 703 | #endif |
704 | |||
705 | spin_unlock_irq(&fep->hw_lock); | ||
692 | } | 706 | } |
693 | 707 | ||
694 | 708 | ||
@@ -702,11 +716,11 @@ fec_enet_mii(struct net_device *dev) | |||
702 | uint mii_reg; | 716 | uint mii_reg; |
703 | 717 | ||
704 | fep = netdev_priv(dev); | 718 | fep = netdev_priv(dev); |
719 | spin_lock_irq(&fep->mii_lock); | ||
720 | |||
705 | ep = fep->hwp; | 721 | ep = fep->hwp; |
706 | mii_reg = ep->fec_mii_data; | 722 | mii_reg = ep->fec_mii_data; |
707 | 723 | ||
708 | spin_lock(&fep->lock); | ||
709 | |||
710 | if ((mip = mii_head) == NULL) { | 724 | if ((mip = mii_head) == NULL) { |
711 | printk("MII and no head!\n"); | 725 | printk("MII and no head!\n"); |
712 | goto unlock; | 726 | goto unlock; |
@@ -723,7 +737,7 @@ fec_enet_mii(struct net_device *dev) | |||
723 | ep->fec_mii_data = mip->mii_regval; | 737 | ep->fec_mii_data = mip->mii_regval; |
724 | 738 | ||
725 | unlock: | 739 | unlock: |
726 | spin_unlock(&fep->lock); | 740 | spin_unlock_irq(&fep->mii_lock); |
727 | } | 741 | } |
728 | 742 | ||
729 | static int | 743 | static int |
@@ -737,12 +751,11 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi | |||
737 | /* Add PHY address to register command. | 751 | /* Add PHY address to register command. |
738 | */ | 752 | */ |
739 | fep = netdev_priv(dev); | 753 | fep = netdev_priv(dev); |
740 | regval |= fep->phy_addr << 23; | 754 | spin_lock_irqsave(&fep->mii_lock, flags); |
741 | 755 | ||
756 | regval |= fep->phy_addr << 23; | ||
742 | retval = 0; | 757 | retval = 0; |
743 | 758 | ||
744 | spin_lock_irqsave(&fep->lock,flags); | ||
745 | |||
746 | if ((mip = mii_free) != NULL) { | 759 | if ((mip = mii_free) != NULL) { |
747 | mii_free = mip->mii_next; | 760 | mii_free = mip->mii_next; |
748 | mip->mii_regval = regval; | 761 | mip->mii_regval = regval; |
@@ -759,9 +772,8 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi | |||
759 | retval = 1; | 772 | retval = 1; |
760 | } | 773 | } |
761 | 774 | ||
762 | spin_unlock_irqrestore(&fep->lock,flags); | 775 | spin_unlock_irqrestore(&fep->mii_lock, flags); |
763 | 776 | return retval; | |
764 | return(retval); | ||
765 | } | 777 | } |
766 | 778 | ||
767 | static void mii_do_cmd(struct net_device *dev, const phy_cmd_t *c) | 779 | static void mii_do_cmd(struct net_device *dev, const phy_cmd_t *c) |
@@ -1222,7 +1234,7 @@ static phy_info_t const * const phy_info[] = { | |||
1222 | }; | 1234 | }; |
1223 | 1235 | ||
1224 | /* ------------------------------------------------------------------------- */ | 1236 | /* ------------------------------------------------------------------------- */ |
1225 | #if !defined(CONFIG_M532x) | 1237 | #ifdef HAVE_mii_link_interrupt |
1226 | #ifdef CONFIG_RPXCLASSIC | 1238 | #ifdef CONFIG_RPXCLASSIC |
1227 | static void | 1239 | static void |
1228 | mii_link_interrupt(void *dev_id); | 1240 | mii_link_interrupt(void *dev_id); |
@@ -1362,18 +1374,8 @@ static void __inline__ fec_request_intrs(struct net_device *dev) | |||
1362 | unsigned short irq; | 1374 | unsigned short irq; |
1363 | } *idp, id[] = { | 1375 | } *idp, id[] = { |
1364 | { "fec(TXF)", 23 }, | 1376 | { "fec(TXF)", 23 }, |
1365 | { "fec(TXB)", 24 }, | ||
1366 | { "fec(TXFIFO)", 25 }, | ||
1367 | { "fec(TXCR)", 26 }, | ||
1368 | { "fec(RXF)", 27 }, | 1377 | { "fec(RXF)", 27 }, |
1369 | { "fec(RXB)", 28 }, | ||
1370 | { "fec(MII)", 29 }, | 1378 | { "fec(MII)", 29 }, |
1371 | { "fec(LC)", 30 }, | ||
1372 | { "fec(HBERR)", 31 }, | ||
1373 | { "fec(GRA)", 32 }, | ||
1374 | { "fec(EBERR)", 33 }, | ||
1375 | { "fec(BABT)", 34 }, | ||
1376 | { "fec(BABR)", 35 }, | ||
1377 | { NULL }, | 1379 | { NULL }, |
1378 | }; | 1380 | }; |
1379 | 1381 | ||
@@ -1533,18 +1535,8 @@ static void __inline__ fec_request_intrs(struct net_device *dev) | |||
1533 | unsigned short irq; | 1535 | unsigned short irq; |
1534 | } *idp, id[] = { | 1536 | } *idp, id[] = { |
1535 | { "fec(TXF)", 23 }, | 1537 | { "fec(TXF)", 23 }, |
1536 | { "fec(TXB)", 24 }, | ||
1537 | { "fec(TXFIFO)", 25 }, | ||
1538 | { "fec(TXCR)", 26 }, | ||
1539 | { "fec(RXF)", 27 }, | 1538 | { "fec(RXF)", 27 }, |
1540 | { "fec(RXB)", 28 }, | ||
1541 | { "fec(MII)", 29 }, | 1539 | { "fec(MII)", 29 }, |
1542 | { "fec(LC)", 30 }, | ||
1543 | { "fec(HBERR)", 31 }, | ||
1544 | { "fec(GRA)", 32 }, | ||
1545 | { "fec(EBERR)", 33 }, | ||
1546 | { "fec(BABT)", 34 }, | ||
1547 | { "fec(BABR)", 35 }, | ||
1548 | { NULL }, | 1540 | { NULL }, |
1549 | }; | 1541 | }; |
1550 | 1542 | ||
@@ -1660,18 +1652,8 @@ static void __inline__ fec_request_intrs(struct net_device *dev) | |||
1660 | unsigned short irq; | 1652 | unsigned short irq; |
1661 | } *idp, id[] = { | 1653 | } *idp, id[] = { |
1662 | { "fec(TXF)", 36 }, | 1654 | { "fec(TXF)", 36 }, |
1663 | { "fec(TXB)", 37 }, | ||
1664 | { "fec(TXFIFO)", 38 }, | ||
1665 | { "fec(TXCR)", 39 }, | ||
1666 | { "fec(RXF)", 40 }, | 1655 | { "fec(RXF)", 40 }, |
1667 | { "fec(RXB)", 41 }, | ||
1668 | { "fec(MII)", 42 }, | 1656 | { "fec(MII)", 42 }, |
1669 | { "fec(LC)", 43 }, | ||
1670 | { "fec(HBERR)", 44 }, | ||
1671 | { "fec(GRA)", 45 }, | ||
1672 | { "fec(EBERR)", 46 }, | ||
1673 | { "fec(BABT)", 47 }, | ||
1674 | { "fec(BABR)", 48 }, | ||
1675 | { NULL }, | 1657 | { NULL }, |
1676 | }; | 1658 | }; |
1677 | 1659 | ||
@@ -2126,6 +2108,7 @@ mii_discover_phy(uint mii_reg, struct net_device *dev) | |||
2126 | 2108 | ||
2127 | /* This interrupt occurs when the PHY detects a link change. | 2109 | /* This interrupt occurs when the PHY detects a link change. |
2128 | */ | 2110 | */ |
2111 | #ifdef HAVE_mii_link_interrupt | ||
2129 | #ifdef CONFIG_RPXCLASSIC | 2112 | #ifdef CONFIG_RPXCLASSIC |
2130 | static void | 2113 | static void |
2131 | mii_link_interrupt(void *dev_id) | 2114 | mii_link_interrupt(void *dev_id) |
@@ -2148,6 +2131,7 @@ mii_link_interrupt(int irq, void * dev_id) | |||
2148 | 2131 | ||
2149 | return IRQ_HANDLED; | 2132 | return IRQ_HANDLED; |
2150 | } | 2133 | } |
2134 | #endif | ||
2151 | 2135 | ||
2152 | static int | 2136 | static int |
2153 | fec_enet_open(struct net_device *dev) | 2137 | fec_enet_open(struct net_device *dev) |
@@ -2243,13 +2227,13 @@ static void set_multicast_list(struct net_device *dev) | |||
2243 | /* Catch all multicast addresses, so set the | 2227 | /* Catch all multicast addresses, so set the |
2244 | * filter to all 1's. | 2228 | * filter to all 1's. |
2245 | */ | 2229 | */ |
2246 | ep->fec_hash_table_high = 0xffffffff; | 2230 | ep->fec_grp_hash_table_high = 0xffffffff; |
2247 | ep->fec_hash_table_low = 0xffffffff; | 2231 | ep->fec_grp_hash_table_low = 0xffffffff; |
2248 | } else { | 2232 | } else { |
2249 | /* Clear filter and add the addresses in hash register. | 2233 | /* Clear filter and add the addresses in hash register. |
2250 | */ | 2234 | */ |
2251 | ep->fec_hash_table_high = 0; | 2235 | ep->fec_grp_hash_table_high = 0; |
2252 | ep->fec_hash_table_low = 0; | 2236 | ep->fec_grp_hash_table_low = 0; |
2253 | 2237 | ||
2254 | dmi = dev->mc_list; | 2238 | dmi = dev->mc_list; |
2255 | 2239 | ||
@@ -2280,9 +2264,9 @@ static void set_multicast_list(struct net_device *dev) | |||
2280 | hash = (crc >> (32 - HASH_BITS)) & 0x3f; | 2264 | hash = (crc >> (32 - HASH_BITS)) & 0x3f; |
2281 | 2265 | ||
2282 | if (hash > 31) | 2266 | if (hash > 31) |
2283 | ep->fec_hash_table_high |= 1 << (hash - 32); | 2267 | ep->fec_grp_hash_table_high |= 1 << (hash - 32); |
2284 | else | 2268 | else |
2285 | ep->fec_hash_table_low |= 1 << hash; | 2269 | ep->fec_grp_hash_table_low |= 1 << hash; |
2286 | } | 2270 | } |
2287 | } | 2271 | } |
2288 | } | 2272 | } |
@@ -2332,6 +2316,9 @@ int __init fec_enet_init(struct net_device *dev) | |||
2332 | return -ENOMEM; | 2316 | return -ENOMEM; |
2333 | } | 2317 | } |
2334 | 2318 | ||
2319 | spin_lock_init(&fep->hw_lock); | ||
2320 | spin_lock_init(&fep->mii_lock); | ||
2321 | |||
2335 | /* Create an Ethernet device instance. | 2322 | /* Create an Ethernet device instance. |
2336 | */ | 2323 | */ |
2337 | fecp = (volatile fec_t *) fec_hw[index]; | 2324 | fecp = (volatile fec_t *) fec_hw[index]; |
@@ -2430,11 +2417,15 @@ int __init fec_enet_init(struct net_device *dev) | |||
2430 | */ | 2417 | */ |
2431 | fec_request_intrs(dev); | 2418 | fec_request_intrs(dev); |
2432 | 2419 | ||
2433 | fecp->fec_hash_table_high = 0; | 2420 | fecp->fec_grp_hash_table_high = 0; |
2434 | fecp->fec_hash_table_low = 0; | 2421 | fecp->fec_grp_hash_table_low = 0; |
2435 | fecp->fec_r_buff_size = PKT_MAXBLR_SIZE; | 2422 | fecp->fec_r_buff_size = PKT_MAXBLR_SIZE; |
2436 | fecp->fec_ecntrl = 2; | 2423 | fecp->fec_ecntrl = 2; |
2437 | fecp->fec_r_des_active = 0; | 2424 | fecp->fec_r_des_active = 0; |
2425 | #ifndef CONFIG_M5272 | ||
2426 | fecp->fec_hash_table_high = 0; | ||
2427 | fecp->fec_hash_table_low = 0; | ||
2428 | #endif | ||
2438 | 2429 | ||
2439 | dev->base_addr = (unsigned long)fecp; | 2430 | dev->base_addr = (unsigned long)fecp; |
2440 | 2431 | ||
@@ -2455,8 +2446,7 @@ int __init fec_enet_init(struct net_device *dev) | |||
2455 | 2446 | ||
2456 | /* Clear and enable interrupts */ | 2447 | /* Clear and enable interrupts */ |
2457 | fecp->fec_ievent = 0xffc00000; | 2448 | fecp->fec_ievent = 0xffc00000; |
2458 | fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB | | 2449 | fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII); |
2459 | FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII); | ||
2460 | 2450 | ||
2461 | /* Queue up command to detect the PHY and initialize the | 2451 | /* Queue up command to detect the PHY and initialize the |
2462 | * remainder of the interface. | 2452 | * remainder of the interface. |
@@ -2500,8 +2490,8 @@ fec_restart(struct net_device *dev, int duplex) | |||
2500 | 2490 | ||
2501 | /* Reset all multicast. | 2491 | /* Reset all multicast. |
2502 | */ | 2492 | */ |
2503 | fecp->fec_hash_table_high = 0; | 2493 | fecp->fec_grp_hash_table_high = 0; |
2504 | fecp->fec_hash_table_low = 0; | 2494 | fecp->fec_grp_hash_table_low = 0; |
2505 | 2495 | ||
2506 | /* Set maximum receive buffer size. | 2496 | /* Set maximum receive buffer size. |
2507 | */ | 2497 | */ |
@@ -2583,8 +2573,7 @@ fec_restart(struct net_device *dev, int duplex) | |||
2583 | 2573 | ||
2584 | /* Enable interrupts we wish to service. | 2574 | /* Enable interrupts we wish to service. |
2585 | */ | 2575 | */ |
2586 | fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB | | 2576 | fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII); |
2587 | FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII); | ||
2588 | } | 2577 | } |
2589 | 2578 | ||
2590 | static void | 2579 | static void |
@@ -2624,7 +2613,7 @@ fec_stop(struct net_device *dev) | |||
2624 | static int __init fec_enet_module_init(void) | 2613 | static int __init fec_enet_module_init(void) |
2625 | { | 2614 | { |
2626 | struct net_device *dev; | 2615 | struct net_device *dev; |
2627 | int i, j, err; | 2616 | int i, err; |
2628 | DECLARE_MAC_BUF(mac); | 2617 | DECLARE_MAC_BUF(mac); |
2629 | 2618 | ||
2630 | printk("FEC ENET Version 0.2\n"); | 2619 | printk("FEC ENET Version 0.2\n"); |
diff --git a/drivers/net/fec.h b/drivers/net/fec.h index 1d421606984f..292719daceff 100644 --- a/drivers/net/fec.h +++ b/drivers/net/fec.h | |||
@@ -88,8 +88,8 @@ typedef struct fec { | |||
88 | unsigned long fec_reserved7[158]; | 88 | unsigned long fec_reserved7[158]; |
89 | unsigned long fec_addr_low; /* Low 32bits MAC address */ | 89 | unsigned long fec_addr_low; /* Low 32bits MAC address */ |
90 | unsigned long fec_addr_high; /* High 16bits MAC address */ | 90 | unsigned long fec_addr_high; /* High 16bits MAC address */ |
91 | unsigned long fec_hash_table_high; /* High 32bits hash table */ | 91 | unsigned long fec_grp_hash_table_high;/* High 32bits hash table */ |
92 | unsigned long fec_hash_table_low; /* Low 32bits hash table */ | 92 | unsigned long fec_grp_hash_table_low; /* Low 32bits hash table */ |
93 | unsigned long fec_r_des_start; /* Receive descriptor ring */ | 93 | unsigned long fec_r_des_start; /* Receive descriptor ring */ |
94 | unsigned long fec_x_des_start; /* Transmit descriptor ring */ | 94 | unsigned long fec_x_des_start; /* Transmit descriptor ring */ |
95 | unsigned long fec_r_buff_size; /* Maximum receive buff size */ | 95 | unsigned long fec_r_buff_size; /* Maximum receive buff size */ |
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c index d21b7ab64bd1..5f9c42e7a7f1 100644 --- a/drivers/net/fec_mpc52xx.c +++ b/drivers/net/fec_mpc52xx.c | |||
@@ -43,6 +43,29 @@ | |||
43 | 43 | ||
44 | #define DRIVER_NAME "mpc52xx-fec" | 44 | #define DRIVER_NAME "mpc52xx-fec" |
45 | 45 | ||
46 | #define FEC5200_PHYADDR_NONE (-1) | ||
47 | #define FEC5200_PHYADDR_7WIRE (-2) | ||
48 | |||
49 | /* Private driver data structure */ | ||
50 | struct mpc52xx_fec_priv { | ||
51 | int duplex; | ||
52 | int speed; | ||
53 | int r_irq; | ||
54 | int t_irq; | ||
55 | struct mpc52xx_fec __iomem *fec; | ||
56 | struct bcom_task *rx_dmatsk; | ||
57 | struct bcom_task *tx_dmatsk; | ||
58 | spinlock_t lock; | ||
59 | int msg_enable; | ||
60 | |||
61 | /* MDIO link details */ | ||
62 | int phy_addr; | ||
63 | unsigned int phy_speed; | ||
64 | struct phy_device *phydev; | ||
65 | enum phy_state link; | ||
66 | }; | ||
67 | |||
68 | |||
46 | static irqreturn_t mpc52xx_fec_interrupt(int, void *); | 69 | static irqreturn_t mpc52xx_fec_interrupt(int, void *); |
47 | static irqreturn_t mpc52xx_fec_rx_interrupt(int, void *); | 70 | static irqreturn_t mpc52xx_fec_rx_interrupt(int, void *); |
48 | static irqreturn_t mpc52xx_fec_tx_interrupt(int, void *); | 71 | static irqreturn_t mpc52xx_fec_tx_interrupt(int, void *); |
@@ -223,7 +246,7 @@ static int mpc52xx_fec_phy_start(struct net_device *dev) | |||
223 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | 246 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); |
224 | int err; | 247 | int err; |
225 | 248 | ||
226 | if (!priv->has_phy) | 249 | if (priv->phy_addr < 0) |
227 | return 0; | 250 | return 0; |
228 | 251 | ||
229 | err = mpc52xx_fec_init_phy(dev); | 252 | err = mpc52xx_fec_init_phy(dev); |
@@ -243,7 +266,7 @@ static void mpc52xx_fec_phy_stop(struct net_device *dev) | |||
243 | { | 266 | { |
244 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); | 267 | struct mpc52xx_fec_priv *priv = netdev_priv(dev); |
245 | 268 | ||
246 | if (!priv->has_phy) | 269 | if (!priv->phydev) |
247 | return; | 270 | return; |
248 | 271 | ||
249 | phy_disconnect(priv->phydev); | 272 | phy_disconnect(priv->phydev); |
@@ -255,7 +278,7 @@ static void mpc52xx_fec_phy_stop(struct net_device *dev) | |||
255 | static int mpc52xx_fec_phy_mii_ioctl(struct mpc52xx_fec_priv *priv, | 278 | static int mpc52xx_fec_phy_mii_ioctl(struct mpc52xx_fec_priv *priv, |
256 | struct mii_ioctl_data *mii_data, int cmd) | 279 | struct mii_ioctl_data *mii_data, int cmd) |
257 | { | 280 | { |
258 | if (!priv->has_phy) | 281 | if (!priv->phydev) |
259 | return -ENOTSUPP; | 282 | return -ENOTSUPP; |
260 | 283 | ||
261 | return phy_mii_ioctl(priv->phydev, mii_data, cmd); | 284 | return phy_mii_ioctl(priv->phydev, mii_data, cmd); |
@@ -265,7 +288,7 @@ static void mpc52xx_fec_phy_hw_init(struct mpc52xx_fec_priv *priv) | |||
265 | { | 288 | { |
266 | struct mpc52xx_fec __iomem *fec = priv->fec; | 289 | struct mpc52xx_fec __iomem *fec = priv->fec; |
267 | 290 | ||
268 | if (!priv->has_phy) | 291 | if (priv->phydev) |
269 | return; | 292 | return; |
270 | 293 | ||
271 | out_be32(&fec->mii_speed, priv->phy_speed); | 294 | out_be32(&fec->mii_speed, priv->phy_speed); |
@@ -704,7 +727,7 @@ static void mpc52xx_fec_start(struct net_device *dev) | |||
704 | rcntrl = FEC_RX_BUFFER_SIZE << 16; /* max frame length */ | 727 | rcntrl = FEC_RX_BUFFER_SIZE << 16; /* max frame length */ |
705 | rcntrl |= FEC_RCNTRL_FCE; | 728 | rcntrl |= FEC_RCNTRL_FCE; |
706 | 729 | ||
707 | if (priv->has_phy) | 730 | if (priv->phy_addr != FEC5200_PHYADDR_7WIRE) |
708 | rcntrl |= FEC_RCNTRL_MII_MODE; | 731 | rcntrl |= FEC_RCNTRL_MII_MODE; |
709 | 732 | ||
710 | if (priv->duplex == DUPLEX_FULL) | 733 | if (priv->duplex == DUPLEX_FULL) |
@@ -864,7 +887,10 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) | |||
864 | struct net_device *ndev; | 887 | struct net_device *ndev; |
865 | struct mpc52xx_fec_priv *priv = NULL; | 888 | struct mpc52xx_fec_priv *priv = NULL; |
866 | struct resource mem; | 889 | struct resource mem; |
867 | const phandle *ph; | 890 | struct device_node *phy_node; |
891 | const phandle *phy_handle; | ||
892 | const u32 *prop; | ||
893 | int prop_size; | ||
868 | 894 | ||
869 | phys_addr_t rx_fifo; | 895 | phys_addr_t rx_fifo; |
870 | phys_addr_t tx_fifo; | 896 | phys_addr_t tx_fifo; |
@@ -948,26 +974,37 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) | |||
948 | mpc52xx_fec_get_paddr(ndev, ndev->dev_addr); | 974 | mpc52xx_fec_get_paddr(ndev, ndev->dev_addr); |
949 | 975 | ||
950 | priv->msg_enable = netif_msg_init(debug, MPC52xx_MESSAGES_DEFAULT); | 976 | priv->msg_enable = netif_msg_init(debug, MPC52xx_MESSAGES_DEFAULT); |
951 | priv->duplex = DUPLEX_FULL; | ||
952 | |||
953 | /* is the phy present in device tree? */ | ||
954 | ph = of_get_property(op->node, "phy-handle", NULL); | ||
955 | if (ph) { | ||
956 | const unsigned int *prop; | ||
957 | struct device_node *phy_dn; | ||
958 | priv->has_phy = 1; | ||
959 | 977 | ||
960 | phy_dn = of_find_node_by_phandle(*ph); | 978 | /* |
961 | prop = of_get_property(phy_dn, "reg", NULL); | 979 | * Link mode configuration |
962 | priv->phy_addr = *prop; | 980 | */ |
963 | 981 | ||
964 | of_node_put(phy_dn); | 982 | /* Start with safe defaults for link connection */ |
983 | priv->phy_addr = FEC5200_PHYADDR_NONE; | ||
984 | priv->speed = 100; | ||
985 | priv->duplex = DUPLEX_HALF; | ||
986 | priv->phy_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1; | ||
987 | |||
988 | /* the 7-wire property means don't use MII mode */ | ||
989 | if (of_find_property(op->node, "fsl,7-wire-mode", NULL)) | ||
990 | priv->phy_addr = FEC5200_PHYADDR_7WIRE; | ||
991 | |||
992 | /* The current speed preconfigures the speed of the MII link */ | ||
993 | prop = of_get_property(op->node, "current-speed", &prop_size); | ||
994 | if (prop && (prop_size >= sizeof(u32) * 2)) { | ||
995 | priv->speed = prop[0]; | ||
996 | priv->duplex = prop[1] ? DUPLEX_FULL : DUPLEX_HALF; | ||
997 | } | ||
965 | 998 | ||
966 | /* Phy speed */ | 999 | /* If there is a phy handle, setup link to that phy */ |
967 | priv->phy_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1; | 1000 | phy_handle = of_get_property(op->node, "phy-handle", &prop_size); |
968 | } else { | 1001 | if (phy_handle && (prop_size >= sizeof(phandle))) { |
969 | dev_info(&ndev->dev, "can't find \"phy-handle\" in device" | 1002 | phy_node = of_find_node_by_phandle(*phy_handle); |
970 | " tree, using 7-wire mode\n"); | 1003 | prop = of_get_property(phy_node, "reg", &prop_size); |
1004 | if (prop && (prop_size >= sizeof(u32))) | ||
1005 | if ((*prop >= 0) && (*prop < PHY_MAX_ADDR)) | ||
1006 | priv->phy_addr = *prop; | ||
1007 | of_node_put(phy_node); | ||
971 | } | 1008 | } |
972 | 1009 | ||
973 | /* Hardware init */ | 1010 | /* Hardware init */ |
@@ -982,6 +1019,20 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) | |||
982 | if (rv < 0) | 1019 | if (rv < 0) |
983 | goto probe_error; | 1020 | goto probe_error; |
984 | 1021 | ||
1022 | /* Now report the link setup */ | ||
1023 | switch (priv->phy_addr) { | ||
1024 | case FEC5200_PHYADDR_NONE: | ||
1025 | dev_info(&ndev->dev, "Fixed speed MII link: %i%cD\n", | ||
1026 | priv->speed, priv->duplex ? 'F' : 'H'); | ||
1027 | break; | ||
1028 | case FEC5200_PHYADDR_7WIRE: | ||
1029 | dev_info(&ndev->dev, "using 7-wire PHY mode\n"); | ||
1030 | break; | ||
1031 | default: | ||
1032 | dev_info(&ndev->dev, "Using PHY at MDIO address %i\n", | ||
1033 | priv->phy_addr); | ||
1034 | } | ||
1035 | |||
985 | /* We're done ! */ | 1036 | /* We're done ! */ |
986 | dev_set_drvdata(&op->dev, ndev); | 1037 | dev_set_drvdata(&op->dev, ndev); |
987 | 1038 | ||
diff --git a/drivers/net/fec_mpc52xx.h b/drivers/net/fec_mpc52xx.h index 8b1f75397b9a..a227a525bdbb 100644 --- a/drivers/net/fec_mpc52xx.h +++ b/drivers/net/fec_mpc52xx.h | |||
@@ -26,25 +26,6 @@ | |||
26 | 26 | ||
27 | #define FEC_WATCHDOG_TIMEOUT ((400*HZ)/1000) | 27 | #define FEC_WATCHDOG_TIMEOUT ((400*HZ)/1000) |
28 | 28 | ||
29 | struct mpc52xx_fec_priv { | ||
30 | int duplex; | ||
31 | int r_irq; | ||
32 | int t_irq; | ||
33 | struct mpc52xx_fec __iomem *fec; | ||
34 | struct bcom_task *rx_dmatsk; | ||
35 | struct bcom_task *tx_dmatsk; | ||
36 | spinlock_t lock; | ||
37 | int msg_enable; | ||
38 | |||
39 | int has_phy; | ||
40 | unsigned int phy_speed; | ||
41 | unsigned int phy_addr; | ||
42 | struct phy_device *phydev; | ||
43 | enum phy_state link; | ||
44 | int speed; | ||
45 | }; | ||
46 | |||
47 | |||
48 | /* ======================================================================== */ | 29 | /* ======================================================================== */ |
49 | /* Hardware register sets & bits */ | 30 | /* Hardware register sets & bits */ |
50 | /* ======================================================================== */ | 31 | /* ======================================================================== */ |
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c index cb46446b2691..03a9abcce524 100644 --- a/drivers/net/mlx4/mr.c +++ b/drivers/net/mlx4/mr.c | |||
@@ -551,7 +551,7 @@ int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages, | |||
551 | u64 mtt_seg; | 551 | u64 mtt_seg; |
552 | int err = -ENOMEM; | 552 | int err = -ENOMEM; |
553 | 553 | ||
554 | if (page_shift < 12 || page_shift >= 32) | 554 | if (page_shift < (ffs(dev->caps.page_size_cap) - 1) || page_shift >= 32) |
555 | return -EINVAL; | 555 | return -EINVAL; |
556 | 556 | ||
557 | /* All MTTs must fit in the same page */ | 557 | /* All MTTs must fit in the same page */ |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 555b70c8b863..f926b5ab3d09 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -41,6 +41,9 @@ struct virtnet_info | |||
41 | struct net_device *dev; | 41 | struct net_device *dev; |
42 | struct napi_struct napi; | 42 | struct napi_struct napi; |
43 | 43 | ||
44 | /* The skb we couldn't send because buffers were full. */ | ||
45 | struct sk_buff *last_xmit_skb; | ||
46 | |||
44 | /* Number of input buffers, and max we've ever had. */ | 47 | /* Number of input buffers, and max we've ever had. */ |
45 | unsigned int num, max; | 48 | unsigned int num, max; |
46 | 49 | ||
@@ -142,10 +145,10 @@ drop: | |||
142 | static void try_fill_recv(struct virtnet_info *vi) | 145 | static void try_fill_recv(struct virtnet_info *vi) |
143 | { | 146 | { |
144 | struct sk_buff *skb; | 147 | struct sk_buff *skb; |
145 | struct scatterlist sg[1+MAX_SKB_FRAGS]; | 148 | struct scatterlist sg[2+MAX_SKB_FRAGS]; |
146 | int num, err; | 149 | int num, err; |
147 | 150 | ||
148 | sg_init_table(sg, 1+MAX_SKB_FRAGS); | 151 | sg_init_table(sg, 2+MAX_SKB_FRAGS); |
149 | for (;;) { | 152 | for (;;) { |
150 | skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN); | 153 | skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN); |
151 | if (unlikely(!skb)) | 154 | if (unlikely(!skb)) |
@@ -221,23 +224,22 @@ static void free_old_xmit_skbs(struct virtnet_info *vi) | |||
221 | while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { | 224 | while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { |
222 | pr_debug("Sent skb %p\n", skb); | 225 | pr_debug("Sent skb %p\n", skb); |
223 | __skb_unlink(skb, &vi->send); | 226 | __skb_unlink(skb, &vi->send); |
224 | vi->dev->stats.tx_bytes += len; | 227 | vi->dev->stats.tx_bytes += skb->len; |
225 | vi->dev->stats.tx_packets++; | 228 | vi->dev->stats.tx_packets++; |
226 | kfree_skb(skb); | 229 | kfree_skb(skb); |
227 | } | 230 | } |
228 | } | 231 | } |
229 | 232 | ||
230 | static int start_xmit(struct sk_buff *skb, struct net_device *dev) | 233 | static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb) |
231 | { | 234 | { |
232 | struct virtnet_info *vi = netdev_priv(dev); | 235 | int num; |
233 | int num, err; | 236 | struct scatterlist sg[2+MAX_SKB_FRAGS]; |
234 | struct scatterlist sg[1+MAX_SKB_FRAGS]; | ||
235 | struct virtio_net_hdr *hdr; | 237 | struct virtio_net_hdr *hdr; |
236 | const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest; | 238 | const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest; |
237 | 239 | ||
238 | sg_init_table(sg, 1+MAX_SKB_FRAGS); | 240 | sg_init_table(sg, 2+MAX_SKB_FRAGS); |
239 | 241 | ||
240 | pr_debug("%s: xmit %p " MAC_FMT "\n", dev->name, skb, | 242 | pr_debug("%s: xmit %p " MAC_FMT "\n", vi->dev->name, skb, |
241 | dest[0], dest[1], dest[2], | 243 | dest[0], dest[1], dest[2], |
242 | dest[3], dest[4], dest[5]); | 244 | dest[3], dest[4], dest[5]); |
243 | 245 | ||
@@ -272,30 +274,51 @@ static int start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
272 | 274 | ||
273 | vnet_hdr_to_sg(sg, skb); | 275 | vnet_hdr_to_sg(sg, skb); |
274 | num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; | 276 | num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; |
275 | __skb_queue_head(&vi->send, skb); | 277 | |
278 | return vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb); | ||
279 | } | ||
280 | |||
281 | static int start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
282 | { | ||
283 | struct virtnet_info *vi = netdev_priv(dev); | ||
276 | 284 | ||
277 | again: | 285 | again: |
278 | /* Free up any pending old buffers before queueing new ones. */ | 286 | /* Free up any pending old buffers before queueing new ones. */ |
279 | free_old_xmit_skbs(vi); | 287 | free_old_xmit_skbs(vi); |
280 | err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb); | 288 | |
281 | if (err) { | 289 | /* If we has a buffer left over from last time, send it now. */ |
282 | pr_debug("%s: virtio not prepared to send\n", dev->name); | 290 | if (vi->last_xmit_skb) { |
283 | netif_stop_queue(dev); | 291 | if (xmit_skb(vi, vi->last_xmit_skb) != 0) { |
284 | 292 | /* Drop this skb: we only queue one. */ | |
285 | /* Activate callback for using skbs: if this returns false it | 293 | vi->dev->stats.tx_dropped++; |
286 | * means some were used in the meantime. */ | 294 | kfree_skb(skb); |
287 | if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { | 295 | goto stop_queue; |
288 | vi->svq->vq_ops->disable_cb(vi->svq); | ||
289 | netif_start_queue(dev); | ||
290 | goto again; | ||
291 | } | 296 | } |
292 | __skb_unlink(skb, &vi->send); | 297 | vi->last_xmit_skb = NULL; |
298 | } | ||
293 | 299 | ||
294 | return NETDEV_TX_BUSY; | 300 | /* Put new one in send queue and do transmit */ |
301 | __skb_queue_head(&vi->send, skb); | ||
302 | if (xmit_skb(vi, skb) != 0) { | ||
303 | vi->last_xmit_skb = skb; | ||
304 | goto stop_queue; | ||
295 | } | 305 | } |
306 | done: | ||
296 | vi->svq->vq_ops->kick(vi->svq); | 307 | vi->svq->vq_ops->kick(vi->svq); |
297 | 308 | return NETDEV_TX_OK; | |
298 | return 0; | 309 | |
310 | stop_queue: | ||
311 | pr_debug("%s: virtio not prepared to send\n", dev->name); | ||
312 | netif_stop_queue(dev); | ||
313 | |||
314 | /* Activate callback for using skbs: if this returns false it | ||
315 | * means some were used in the meantime. */ | ||
316 | if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { | ||
317 | vi->svq->vq_ops->disable_cb(vi->svq); | ||
318 | netif_start_queue(dev); | ||
319 | goto again; | ||
320 | } | ||
321 | goto done; | ||
299 | } | 322 | } |
300 | 323 | ||
301 | #ifdef CONFIG_NET_POLL_CONTROLLER | 324 | #ifdef CONFIG_NET_POLL_CONTROLLER |
@@ -355,17 +378,26 @@ static int virtnet_probe(struct virtio_device *vdev) | |||
355 | SET_NETDEV_DEV(dev, &vdev->dev); | 378 | SET_NETDEV_DEV(dev, &vdev->dev); |
356 | 379 | ||
357 | /* Do we support "hardware" checksums? */ | 380 | /* Do we support "hardware" checksums? */ |
358 | if (csum && vdev->config->feature(vdev, VIRTIO_NET_F_CSUM)) { | 381 | if (csum && virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) { |
359 | /* This opens up the world of extra features. */ | 382 | /* This opens up the world of extra features. */ |
360 | dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; | 383 | dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; |
361 | if (gso && vdev->config->feature(vdev, VIRTIO_NET_F_GSO)) { | 384 | if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) { |
362 | dev->features |= NETIF_F_TSO | NETIF_F_UFO | 385 | dev->features |= NETIF_F_TSO | NETIF_F_UFO |
363 | | NETIF_F_TSO_ECN | NETIF_F_TSO6; | 386 | | NETIF_F_TSO_ECN | NETIF_F_TSO6; |
364 | } | 387 | } |
388 | /* Individual feature bits: what can host handle? */ | ||
389 | if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO4)) | ||
390 | dev->features |= NETIF_F_TSO; | ||
391 | if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO6)) | ||
392 | dev->features |= NETIF_F_TSO6; | ||
393 | if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN)) | ||
394 | dev->features |= NETIF_F_TSO_ECN; | ||
395 | if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO)) | ||
396 | dev->features |= NETIF_F_UFO; | ||
365 | } | 397 | } |
366 | 398 | ||
367 | /* Configuration may specify what MAC to use. Otherwise random. */ | 399 | /* Configuration may specify what MAC to use. Otherwise random. */ |
368 | if (vdev->config->feature(vdev, VIRTIO_NET_F_MAC)) { | 400 | if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) { |
369 | vdev->config->get(vdev, | 401 | vdev->config->get(vdev, |
370 | offsetof(struct virtio_net_config, mac), | 402 | offsetof(struct virtio_net_config, mac), |
371 | dev->dev_addr, dev->addr_len); | 403 | dev->dev_addr, dev->addr_len); |
@@ -454,7 +486,15 @@ static struct virtio_device_id id_table[] = { | |||
454 | { 0 }, | 486 | { 0 }, |
455 | }; | 487 | }; |
456 | 488 | ||
489 | static unsigned int features[] = { | ||
490 | VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC, | ||
491 | VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, | ||
492 | VIRTIO_NET_F_HOST_ECN, | ||
493 | }; | ||
494 | |||
457 | static struct virtio_driver virtio_net = { | 495 | static struct virtio_driver virtio_net = { |
496 | .feature_table = features, | ||
497 | .feature_table_size = ARRAY_SIZE(features), | ||
458 | .driver.name = KBUILD_MODNAME, | 498 | .driver.name = KBUILD_MODNAME, |
459 | .driver.owner = THIS_MODULE, | 499 | .driver.owner = THIS_MODULE, |
460 | .id_table = id_table, | 500 | .id_table = id_table, |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4a55bf380957..3706ce7972dd 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -842,13 +842,25 @@ static void set_pcie_port_type(struct pci_dev *pdev) | |||
842 | * reading the dword at 0x100 which must either be 0 or a valid extended | 842 | * reading the dword at 0x100 which must either be 0 or a valid extended |
843 | * capability header. | 843 | * capability header. |
844 | */ | 844 | */ |
845 | int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix) | 845 | int pci_cfg_space_size_ext(struct pci_dev *dev) |
846 | { | 846 | { |
847 | int pos; | ||
848 | u32 status; | 847 | u32 status; |
849 | 848 | ||
850 | if (!check_exp_pcix) | 849 | if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL) |
851 | goto skip; | 850 | goto fail; |
851 | if (status == 0xffffffff) | ||
852 | goto fail; | ||
853 | |||
854 | return PCI_CFG_SPACE_EXP_SIZE; | ||
855 | |||
856 | fail: | ||
857 | return PCI_CFG_SPACE_SIZE; | ||
858 | } | ||
859 | |||
860 | int pci_cfg_space_size(struct pci_dev *dev) | ||
861 | { | ||
862 | int pos; | ||
863 | u32 status; | ||
852 | 864 | ||
853 | pos = pci_find_capability(dev, PCI_CAP_ID_EXP); | 865 | pos = pci_find_capability(dev, PCI_CAP_ID_EXP); |
854 | if (!pos) { | 866 | if (!pos) { |
@@ -861,23 +873,12 @@ int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix) | |||
861 | goto fail; | 873 | goto fail; |
862 | } | 874 | } |
863 | 875 | ||
864 | skip: | 876 | return pci_cfg_space_size_ext(dev); |
865 | if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL) | ||
866 | goto fail; | ||
867 | if (status == 0xffffffff) | ||
868 | goto fail; | ||
869 | |||
870 | return PCI_CFG_SPACE_EXP_SIZE; | ||
871 | 877 | ||
872 | fail: | 878 | fail: |
873 | return PCI_CFG_SPACE_SIZE; | 879 | return PCI_CFG_SPACE_SIZE; |
874 | } | 880 | } |
875 | 881 | ||
876 | int pci_cfg_space_size(struct pci_dev *dev) | ||
877 | { | ||
878 | return pci_cfg_space_size_ext(dev, 1); | ||
879 | } | ||
880 | |||
881 | static void pci_release_bus_bridge_dev(struct device *dev) | 882 | static void pci_release_bus_bridge_dev(struct device *dev) |
882 | { | 883 | { |
883 | kfree(dev); | 884 | kfree(dev); |
diff --git a/drivers/pcmcia/au1000_db1x00.c b/drivers/pcmcia/au1000_db1x00.c index 74e051535d6c..c78d77fd7e3b 100644 --- a/drivers/pcmcia/au1000_db1x00.c +++ b/drivers/pcmcia/au1000_db1x00.c | |||
@@ -194,7 +194,7 @@ db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_s | |||
194 | default: | 194 | default: |
195 | pwr |= SET_VCC_VPP(0,0,sock); | 195 | pwr |= SET_VCC_VPP(0,0,sock); |
196 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | 196 | printk("%s: bad Vcc/Vpp (%d:%d)\n", |
197 | __FUNCTION__, | 197 | __func__, |
198 | state->Vcc, | 198 | state->Vcc, |
199 | state->Vpp); | 199 | state->Vpp); |
200 | break; | 200 | break; |
@@ -215,7 +215,7 @@ db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_s | |||
215 | default: | 215 | default: |
216 | pwr |= SET_VCC_VPP(0,0,sock); | 216 | pwr |= SET_VCC_VPP(0,0,sock); |
217 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | 217 | printk("%s: bad Vcc/Vpp (%d:%d)\n", |
218 | __FUNCTION__, | 218 | __func__, |
219 | state->Vcc, | 219 | state->Vcc, |
220 | state->Vpp); | 220 | state->Vpp); |
221 | break; | 221 | break; |
@@ -224,7 +224,7 @@ db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_s | |||
224 | default: /* what's this ? */ | 224 | default: /* what's this ? */ |
225 | pwr |= SET_VCC_VPP(0,0,sock); | 225 | pwr |= SET_VCC_VPP(0,0,sock); |
226 | printk(KERN_ERR "%s: bad Vcc %d\n", | 226 | printk(KERN_ERR "%s: bad Vcc %d\n", |
227 | __FUNCTION__, state->Vcc); | 227 | __func__, state->Vcc); |
228 | break; | 228 | break; |
229 | } | 229 | } |
230 | 230 | ||
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c index b693367d38cd..75e8f8505e47 100644 --- a/drivers/pcmcia/au1000_generic.c +++ b/drivers/pcmcia/au1000_generic.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/notifier.h> | 41 | #include <linux/notifier.h> |
42 | #include <linux/interrupt.h> | 42 | #include <linux/interrupt.h> |
43 | #include <linux/spinlock.h> | 43 | #include <linux/spinlock.h> |
44 | #include <linux/mutex.h> | ||
44 | #include <linux/platform_device.h> | 45 | #include <linux/platform_device.h> |
45 | 46 | ||
46 | #include <asm/io.h> | 47 | #include <asm/io.h> |
@@ -71,7 +72,7 @@ extern struct au1000_pcmcia_socket au1000_pcmcia_socket[]; | |||
71 | u32 *pcmcia_base_vaddrs[2]; | 72 | u32 *pcmcia_base_vaddrs[2]; |
72 | extern const unsigned long mips_io_port_base; | 73 | extern const unsigned long mips_io_port_base; |
73 | 74 | ||
74 | DECLARE_MUTEX(pcmcia_sockets_lock); | 75 | static DEFINE_MUTEX(pcmcia_sockets_lock); |
75 | 76 | ||
76 | static int (*au1x00_pcmcia_hw_init[])(struct device *dev) = { | 77 | static int (*au1x00_pcmcia_hw_init[])(struct device *dev) = { |
77 | au1x_board_init, | 78 | au1x_board_init, |
@@ -472,7 +473,7 @@ int au1x00_drv_pcmcia_remove(struct device *dev) | |||
472 | struct skt_dev_info *sinfo = dev_get_drvdata(dev); | 473 | struct skt_dev_info *sinfo = dev_get_drvdata(dev); |
473 | int i; | 474 | int i; |
474 | 475 | ||
475 | down(&pcmcia_sockets_lock); | 476 | mutex_lock(&pcmcia_sockets_lock); |
476 | dev_set_drvdata(dev, NULL); | 477 | dev_set_drvdata(dev, NULL); |
477 | 478 | ||
478 | for (i = 0; i < sinfo->nskt; i++) { | 479 | for (i = 0; i < sinfo->nskt; i++) { |
@@ -488,7 +489,7 @@ int au1x00_drv_pcmcia_remove(struct device *dev) | |||
488 | } | 489 | } |
489 | 490 | ||
490 | kfree(sinfo); | 491 | kfree(sinfo); |
491 | up(&pcmcia_sockets_lock); | 492 | mutex_unlock(&pcmcia_sockets_lock); |
492 | return 0; | 493 | return 0; |
493 | } | 494 | } |
494 | 495 | ||
@@ -501,13 +502,13 @@ static int au1x00_drv_pcmcia_probe(struct device *dev) | |||
501 | { | 502 | { |
502 | int i, ret = -ENODEV; | 503 | int i, ret = -ENODEV; |
503 | 504 | ||
504 | down(&pcmcia_sockets_lock); | 505 | mutex_lock(&pcmcia_sockets_lock); |
505 | for (i=0; i < ARRAY_SIZE(au1x00_pcmcia_hw_init); i++) { | 506 | for (i=0; i < ARRAY_SIZE(au1x00_pcmcia_hw_init); i++) { |
506 | ret = au1x00_pcmcia_hw_init[i](dev); | 507 | ret = au1x00_pcmcia_hw_init[i](dev); |
507 | if (ret == 0) | 508 | if (ret == 0) |
508 | break; | 509 | break; |
509 | } | 510 | } |
510 | up(&pcmcia_sockets_lock); | 511 | mutex_unlock(&pcmcia_sockets_lock); |
511 | return ret; | 512 | return ret; |
512 | } | 513 | } |
513 | 514 | ||
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c index 86c0808d6a05..157e41423a0a 100644 --- a/drivers/pcmcia/au1000_pb1x00.c +++ b/drivers/pcmcia/au1000_pb1x00.c | |||
@@ -244,7 +244,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) | |||
244 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, | 244 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, |
245 | configure->sock); | 245 | configure->sock); |
246 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | 246 | printk("%s: bad Vcc/Vpp (%d:%d)\n", |
247 | __FUNCTION__, | 247 | __func__, |
248 | configure->vcc, | 248 | configure->vcc, |
249 | configure->vpp); | 249 | configure->vpp); |
250 | break; | 250 | break; |
@@ -272,7 +272,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) | |||
272 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, | 272 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, |
273 | configure->sock); | 273 | configure->sock); |
274 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | 274 | printk("%s: bad Vcc/Vpp (%d:%d)\n", |
275 | __FUNCTION__, | 275 | __func__, |
276 | configure->vcc, | 276 | configure->vcc, |
277 | configure->vpp); | 277 | configure->vpp); |
278 | break; | 278 | break; |
@@ -300,7 +300,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) | |||
300 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, | 300 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, |
301 | configure->sock); | 301 | configure->sock); |
302 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | 302 | printk("%s: bad Vcc/Vpp (%d:%d)\n", |
303 | __FUNCTION__, | 303 | __func__, |
304 | configure->vcc, | 304 | configure->vcc, |
305 | configure->vpp); | 305 | configure->vpp); |
306 | break; | 306 | break; |
@@ -309,7 +309,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) | |||
309 | default: /* what's this ? */ | 309 | default: /* what's this ? */ |
310 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,configure->sock); | 310 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,configure->sock); |
311 | printk(KERN_ERR "%s: bad Vcc %d\n", | 311 | printk(KERN_ERR "%s: bad Vcc %d\n", |
312 | __FUNCTION__, configure->vcc); | 312 | __func__, configure->vcc); |
313 | break; | 313 | break; |
314 | } | 314 | } |
315 | 315 | ||
@@ -353,7 +353,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) | |||
353 | default: | 353 | default: |
354 | pcr |= SET_VCC_VPP(0,0); | 354 | pcr |= SET_VCC_VPP(0,0); |
355 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | 355 | printk("%s: bad Vcc/Vpp (%d:%d)\n", |
356 | __FUNCTION__, | 356 | __func__, |
357 | configure->vcc, | 357 | configure->vcc, |
358 | configure->vpp); | 358 | configure->vpp); |
359 | break; | 359 | break; |
@@ -374,7 +374,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) | |||
374 | default: | 374 | default: |
375 | pcr |= SET_VCC_VPP(0,0); | 375 | pcr |= SET_VCC_VPP(0,0); |
376 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | 376 | printk("%s: bad Vcc/Vpp (%d:%d)\n", |
377 | __FUNCTION__, | 377 | __func__, |
378 | configure->vcc, | 378 | configure->vcc, |
379 | configure->vpp); | 379 | configure->vpp); |
380 | break; | 380 | break; |
@@ -383,7 +383,7 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) | |||
383 | default: /* what's this ? */ | 383 | default: /* what's this ? */ |
384 | pcr |= SET_VCC_VPP(0,0); | 384 | pcr |= SET_VCC_VPP(0,0); |
385 | printk(KERN_ERR "%s: bad Vcc %d\n", | 385 | printk(KERN_ERR "%s: bad Vcc %d\n", |
386 | __FUNCTION__, configure->vcc); | 386 | __func__, configure->vcc); |
387 | break; | 387 | break; |
388 | } | 388 | } |
389 | 389 | ||
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c index ce9d5c44a7b5..c78ed5347510 100644 --- a/drivers/pcmcia/au1000_xxs1500.c +++ b/drivers/pcmcia/au1000_xxs1500.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #define PCMCIA_IRQ AU1000_GPIO_4 | 56 | #define PCMCIA_IRQ AU1000_GPIO_4 |
57 | 57 | ||
58 | #if 0 | 58 | #if 0 |
59 | #define DEBUG(x,args...) printk(__FUNCTION__ ": " x,##args) | 59 | #define DEBUG(x, args...) printk(__func__ ": " x, ##args) |
60 | #else | 60 | #else |
61 | #define DEBUG(x,args...) | 61 | #define DEBUG(x,args...) |
62 | #endif | 62 | #endif |
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c index 714baaeb6da1..fb2f38dc92c5 100644 --- a/drivers/pcmcia/cardbus.c +++ b/drivers/pcmcia/cardbus.c | |||
@@ -209,7 +209,7 @@ static void cardbus_assign_irqs(struct pci_bus *bus, int irq) | |||
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | int cb_alloc(struct pcmcia_socket * s) | 212 | int __ref cb_alloc(struct pcmcia_socket * s) |
213 | { | 213 | { |
214 | struct pci_bus *bus = s->cb_dev->subordinate; | 214 | struct pci_bus *bus = s->cb_dev->subordinate; |
215 | struct pci_dev *dev; | 215 | struct pci_dev *dev; |
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 5a85871f5ee9..e40775443d04 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -1520,7 +1520,7 @@ static void pcmcia_bus_remove_socket(struct device *dev, | |||
1520 | 1520 | ||
1521 | 1521 | ||
1522 | /* the pcmcia_bus_interface is used to handle pcmcia socket devices */ | 1522 | /* the pcmcia_bus_interface is used to handle pcmcia socket devices */ |
1523 | static struct class_interface pcmcia_bus_interface = { | 1523 | static struct class_interface pcmcia_bus_interface __refdata = { |
1524 | .class = &pcmcia_socket_class, | 1524 | .class = &pcmcia_socket_class, |
1525 | .add_dev = &pcmcia_bus_add_socket, | 1525 | .add_dev = &pcmcia_bus_add_socket, |
1526 | .remove_dev = &pcmcia_bus_remove_socket, | 1526 | .remove_dev = &pcmcia_bus_remove_socket, |
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c index e54ecc580d9e..e13618656ff7 100644 --- a/drivers/pcmcia/i82092.c +++ b/drivers/pcmcia/i82092.c | |||
@@ -53,7 +53,7 @@ static int i82092aa_socket_resume (struct pci_dev *dev) | |||
53 | } | 53 | } |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | static struct pci_driver i82092aa_pci_drv = { | 56 | static struct pci_driver i82092aa_pci_driver = { |
57 | .name = "i82092aa", | 57 | .name = "i82092aa", |
58 | .id_table = i82092aa_pci_ids, | 58 | .id_table = i82092aa_pci_ids, |
59 | .probe = i82092aa_pci_probe, | 59 | .probe = i82092aa_pci_probe, |
@@ -714,13 +714,13 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_ | |||
714 | 714 | ||
715 | static int i82092aa_module_init(void) | 715 | static int i82092aa_module_init(void) |
716 | { | 716 | { |
717 | return pci_register_driver(&i82092aa_pci_drv); | 717 | return pci_register_driver(&i82092aa_pci_driver); |
718 | } | 718 | } |
719 | 719 | ||
720 | static void i82092aa_module_exit(void) | 720 | static void i82092aa_module_exit(void) |
721 | { | 721 | { |
722 | enter("i82092aa_module_exit"); | 722 | enter("i82092aa_module_exit"); |
723 | pci_unregister_driver(&i82092aa_pci_drv); | 723 | pci_unregister_driver(&i82092aa_pci_driver); |
724 | if (sockets[0].io_base>0) | 724 | if (sockets[0].io_base>0) |
725 | release_region(sockets[0].io_base, 2); | 725 | release_region(sockets[0].io_base, 2); |
726 | leave("i82092aa_module_exit"); | 726 | leave("i82092aa_module_exit"); |
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c index bb6db3a582b2..46314b420765 100644 --- a/drivers/pcmcia/omap_cf.c +++ b/drivers/pcmcia/omap_cf.c | |||
@@ -153,7 +153,7 @@ omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s) | |||
153 | 153 | ||
154 | static int omap_cf_ss_suspend(struct pcmcia_socket *s) | 154 | static int omap_cf_ss_suspend(struct pcmcia_socket *s) |
155 | { | 155 | { |
156 | pr_debug("%s: %s\n", driver_name, __FUNCTION__); | 156 | pr_debug("%s: %s\n", driver_name, __func__); |
157 | return omap_cf_set_socket(s, &dead_socket); | 157 | return omap_cf_set_socket(s, &dead_socket); |
158 | } | 158 | } |
159 | 159 | ||
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c index abc10fe49bd8..8bed1dab9039 100644 --- a/drivers/pcmcia/pd6729.c +++ b/drivers/pcmcia/pd6729.c | |||
@@ -778,7 +778,7 @@ static struct pci_device_id pd6729_pci_ids[] = { | |||
778 | }; | 778 | }; |
779 | MODULE_DEVICE_TABLE(pci, pd6729_pci_ids); | 779 | MODULE_DEVICE_TABLE(pci, pd6729_pci_ids); |
780 | 780 | ||
781 | static struct pci_driver pd6729_pci_drv = { | 781 | static struct pci_driver pd6729_pci_driver = { |
782 | .name = "pd6729", | 782 | .name = "pd6729", |
783 | .id_table = pd6729_pci_ids, | 783 | .id_table = pd6729_pci_ids, |
784 | .probe = pd6729_pci_probe, | 784 | .probe = pd6729_pci_probe, |
@@ -791,12 +791,12 @@ static struct pci_driver pd6729_pci_drv = { | |||
791 | 791 | ||
792 | static int pd6729_module_init(void) | 792 | static int pd6729_module_init(void) |
793 | { | 793 | { |
794 | return pci_register_driver(&pd6729_pci_drv); | 794 | return pci_register_driver(&pd6729_pci_driver); |
795 | } | 795 | } |
796 | 796 | ||
797 | static void pd6729_module_exit(void) | 797 | static void pd6729_module_exit(void) |
798 | { | 798 | { |
799 | pci_unregister_driver(&pd6729_pci_drv); | 799 | pci_unregister_driver(&pd6729_pci_driver); |
800 | } | 800 | } |
801 | 801 | ||
802 | module_init(pd6729_module_init); | 802 | module_init(pd6729_module_init); |
diff --git a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c index 4a05802213c8..881ec8a8e389 100644 --- a/drivers/pcmcia/pxa2xx_lubbock.c +++ b/drivers/pcmcia/pxa2xx_lubbock.c | |||
@@ -87,7 +87,7 @@ lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | |||
87 | 87 | ||
88 | default: | 88 | default: |
89 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", | 89 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
90 | __FUNCTION__, state->Vcc); | 90 | __func__, state->Vcc); |
91 | ret = -1; | 91 | ret = -1; |
92 | } | 92 | } |
93 | 93 | ||
@@ -104,7 +104,7 @@ lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | |||
104 | pa_dwr_set |= GPIO_A0; | 104 | pa_dwr_set |= GPIO_A0; |
105 | else { | 105 | else { |
106 | printk(KERN_ERR "%s(): unrecognized Vpp %u\n", | 106 | printk(KERN_ERR "%s(): unrecognized Vpp %u\n", |
107 | __FUNCTION__, state->Vpp); | 107 | __func__, state->Vpp); |
108 | ret = -1; | 108 | ret = -1; |
109 | break; | 109 | break; |
110 | } | 110 | } |
@@ -128,14 +128,14 @@ lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | |||
128 | 128 | ||
129 | default: | 129 | default: |
130 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", | 130 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
131 | __FUNCTION__, state->Vcc); | 131 | __func__, state->Vcc); |
132 | ret = -1; | 132 | ret = -1; |
133 | break; | 133 | break; |
134 | } | 134 | } |
135 | 135 | ||
136 | if (state->Vpp != state->Vcc && state->Vpp != 0) { | 136 | if (state->Vpp != state->Vcc && state->Vpp != 0) { |
137 | printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n", | 137 | printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n", |
138 | __FUNCTION__, state->Vpp); | 138 | __func__, state->Vpp); |
139 | ret = -1; | 139 | ret = -1; |
140 | break; | 140 | break; |
141 | } | 141 | } |
diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c index 6fa5eaaab8af..145b85e0f02c 100644 --- a/drivers/pcmcia/pxa2xx_mainstone.c +++ b/drivers/pcmcia/pxa2xx_mainstone.c | |||
@@ -99,7 +99,7 @@ static int mst_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | |||
99 | case 50: power |= MST_PCMCIA_PWR_VCC_50; break; | 99 | case 50: power |= MST_PCMCIA_PWR_VCC_50; break; |
100 | default: | 100 | default: |
101 | printk(KERN_ERR "%s(): bad Vcc %u\n", | 101 | printk(KERN_ERR "%s(): bad Vcc %u\n", |
102 | __FUNCTION__, state->Vcc); | 102 | __func__, state->Vcc); |
103 | ret = -1; | 103 | ret = -1; |
104 | } | 104 | } |
105 | 105 | ||
@@ -111,7 +111,7 @@ static int mst_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | |||
111 | power |= MST_PCMCIA_PWR_VPP_VCC; | 111 | power |= MST_PCMCIA_PWR_VPP_VCC; |
112 | } else { | 112 | } else { |
113 | printk(KERN_ERR "%s(): bad Vpp %u\n", | 113 | printk(KERN_ERR "%s(): bad Vpp %u\n", |
114 | __FUNCTION__, state->Vpp); | 114 | __func__, state->Vpp); |
115 | ret = -1; | 115 | ret = -1; |
116 | } | 116 | } |
117 | } | 117 | } |
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index a8d100707721..0fcf763b9175 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
@@ -1045,7 +1045,7 @@ static void __devexit pccard_sysfs_remove_rsrc(struct device *dev, | |||
1045 | device_remove_file(dev, *attr); | 1045 | device_remove_file(dev, *attr); |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | static struct class_interface pccard_rsrc_interface = { | 1048 | static struct class_interface pccard_rsrc_interface __refdata = { |
1049 | .class = &pcmcia_socket_class, | 1049 | .class = &pcmcia_socket_class, |
1050 | .add_dev = &pccard_sysfs_add_rsrc, | 1050 | .add_dev = &pccard_sysfs_add_rsrc, |
1051 | .remove_dev = __devexit_p(&pccard_sysfs_remove_rsrc), | 1051 | .remove_dev = __devexit_p(&pccard_sysfs_remove_rsrc), |
diff --git a/drivers/pcmcia/sa1100_assabet.c b/drivers/pcmcia/sa1100_assabet.c index 7c57fdd3c8d7..ce133ce81c10 100644 --- a/drivers/pcmcia/sa1100_assabet.c +++ b/drivers/pcmcia/sa1100_assabet.c | |||
@@ -66,14 +66,14 @@ assabet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_stat | |||
66 | 66 | ||
67 | case 50: | 67 | case 50: |
68 | printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n", | 68 | printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n", |
69 | __FUNCTION__); | 69 | __func__); |
70 | 70 | ||
71 | case 33: /* Can only apply 3.3V to the CF slot. */ | 71 | case 33: /* Can only apply 3.3V to the CF slot. */ |
72 | mask = ASSABET_BCR_CF_PWR; | 72 | mask = ASSABET_BCR_CF_PWR; |
73 | break; | 73 | break; |
74 | 74 | ||
75 | default: | 75 | default: |
76 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__, | 76 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __func__, |
77 | state->Vcc); | 77 | state->Vcc); |
78 | return -1; | 78 | return -1; |
79 | } | 79 | } |
diff --git a/drivers/pcmcia/sa1100_badge4.c b/drivers/pcmcia/sa1100_badge4.c index 62bfc7566ec2..607c3f326eca 100644 --- a/drivers/pcmcia/sa1100_badge4.c +++ b/drivers/pcmcia/sa1100_badge4.c | |||
@@ -82,14 +82,14 @@ badge4_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state | |||
82 | case 0: | 82 | case 0: |
83 | if ((state->Vcc != 0) && | 83 | if ((state->Vcc != 0) && |
84 | (state->Vcc != badge4_pcmvcc)) { | 84 | (state->Vcc != badge4_pcmvcc)) { |
85 | complain_about_jumpering(__FUNCTION__, "pcmvcc", | 85 | complain_about_jumpering(__func__, "pcmvcc", |
86 | badge4_pcmvcc, state->Vcc); | 86 | badge4_pcmvcc, state->Vcc); |
87 | // Apply power regardless of the jumpering. | 87 | // Apply power regardless of the jumpering. |
88 | // return -1; | 88 | // return -1; |
89 | } | 89 | } |
90 | if ((state->Vpp != 0) && | 90 | if ((state->Vpp != 0) && |
91 | (state->Vpp != badge4_pcmvpp)) { | 91 | (state->Vpp != badge4_pcmvpp)) { |
92 | complain_about_jumpering(__FUNCTION__, "pcmvpp", | 92 | complain_about_jumpering(__func__, "pcmvpp", |
93 | badge4_pcmvpp, state->Vpp); | 93 | badge4_pcmvpp, state->Vpp); |
94 | return -1; | 94 | return -1; |
95 | } | 95 | } |
@@ -98,7 +98,7 @@ badge4_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state | |||
98 | case 1: | 98 | case 1: |
99 | if ((state->Vcc != 0) && | 99 | if ((state->Vcc != 0) && |
100 | (state->Vcc != badge4_cfvcc)) { | 100 | (state->Vcc != badge4_cfvcc)) { |
101 | complain_about_jumpering(__FUNCTION__, "cfvcc", | 101 | complain_about_jumpering(__func__, "cfvcc", |
102 | badge4_cfvcc, state->Vcc); | 102 | badge4_cfvcc, state->Vcc); |
103 | return -1; | 103 | return -1; |
104 | } | 104 | } |
@@ -143,7 +143,7 @@ int pcmcia_badge4_init(struct device *dev) | |||
143 | if (machine_is_badge4()) { | 143 | if (machine_is_badge4()) { |
144 | printk(KERN_INFO | 144 | printk(KERN_INFO |
145 | "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n", | 145 | "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n", |
146 | __FUNCTION__, | 146 | __func__, |
147 | badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc); | 147 | badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc); |
148 | 148 | ||
149 | ret = sa11xx_drv_pcmcia_probe(dev, &badge4_pcmcia_ops, 0, 2); | 149 | ret = sa11xx_drv_pcmcia_probe(dev, &badge4_pcmcia_ops, 0, 2); |
diff --git a/drivers/pcmcia/sa1100_cerf.c b/drivers/pcmcia/sa1100_cerf.c index 549a1529fe35..7c3951a2675d 100644 --- a/drivers/pcmcia/sa1100_cerf.c +++ b/drivers/pcmcia/sa1100_cerf.c | |||
@@ -63,7 +63,7 @@ cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | |||
63 | 63 | ||
64 | default: | 64 | default: |
65 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", | 65 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
66 | __FUNCTION__, state->Vcc); | 66 | __func__, state->Vcc); |
67 | return -1; | 67 | return -1; |
68 | } | 68 | } |
69 | 69 | ||
diff --git a/drivers/pcmcia/sa1100_jornada720.c b/drivers/pcmcia/sa1100_jornada720.c index 6284c35dabc6..2167e6714d2d 100644 --- a/drivers/pcmcia/sa1100_jornada720.c +++ b/drivers/pcmcia/sa1100_jornada720.c | |||
@@ -42,7 +42,7 @@ jornada720_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_s | |||
42 | unsigned int pa_dwr_mask, pa_dwr_set; | 42 | unsigned int pa_dwr_mask, pa_dwr_set; |
43 | int ret; | 43 | int ret; |
44 | 44 | ||
45 | printk("%s(): config socket %d vcc %d vpp %d\n", __FUNCTION__, | 45 | printk("%s(): config socket %d vcc %d vpp %d\n", __func__, |
46 | skt->nr, state->Vcc, state->Vpp); | 46 | skt->nr, state->Vcc, state->Vpp); |
47 | 47 | ||
48 | switch (skt->nr) { | 48 | switch (skt->nr) { |
@@ -74,7 +74,7 @@ printk("%s(): config socket %d vcc %d vpp %d\n", __FUNCTION__, | |||
74 | 74 | ||
75 | if (state->Vpp != state->Vcc && state->Vpp != 0) { | 75 | if (state->Vpp != state->Vcc && state->Vpp != 0) { |
76 | printk(KERN_ERR "%s(): slot cannot support VPP %u\n", | 76 | printk(KERN_ERR "%s(): slot cannot support VPP %u\n", |
77 | __FUNCTION__, state->Vpp); | 77 | __func__, state->Vpp); |
78 | return -1; | 78 | return -1; |
79 | } | 79 | } |
80 | 80 | ||
diff --git a/drivers/pcmcia/sa1100_neponset.c b/drivers/pcmcia/sa1100_neponset.c index 5bc9e9532b9d..687492fcd5b4 100644 --- a/drivers/pcmcia/sa1100_neponset.c +++ b/drivers/pcmcia/sa1100_neponset.c | |||
@@ -59,7 +59,7 @@ neponset_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_sta | |||
59 | ncr_set = NCR_A0VPP; | 59 | ncr_set = NCR_A0VPP; |
60 | else { | 60 | else { |
61 | printk(KERN_ERR "%s(): unrecognized VPP %u\n", | 61 | printk(KERN_ERR "%s(): unrecognized VPP %u\n", |
62 | __FUNCTION__, state->Vpp); | 62 | __func__, state->Vpp); |
63 | return -1; | 63 | return -1; |
64 | } | 64 | } |
65 | break; | 65 | break; |
@@ -71,7 +71,7 @@ neponset_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_sta | |||
71 | 71 | ||
72 | if (state->Vpp != state->Vcc && state->Vpp != 0) { | 72 | if (state->Vpp != state->Vcc && state->Vpp != 0) { |
73 | printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n", | 73 | printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n", |
74 | __FUNCTION__, state->Vpp); | 74 | __func__, state->Vpp); |
75 | return -1; | 75 | return -1; |
76 | } | 76 | } |
77 | break; | 77 | break; |
diff --git a/drivers/pcmcia/sa1100_shannon.c b/drivers/pcmcia/sa1100_shannon.c index 9456f5478d09..494912fccc0d 100644 --- a/drivers/pcmcia/sa1100_shannon.c +++ b/drivers/pcmcia/sa1100_shannon.c | |||
@@ -73,19 +73,19 @@ shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | |||
73 | { | 73 | { |
74 | switch (state->Vcc) { | 74 | switch (state->Vcc) { |
75 | case 0: /* power off */ | 75 | case 0: /* power off */ |
76 | printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __FUNCTION__); | 76 | printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__); |
77 | break; | 77 | break; |
78 | case 50: | 78 | case 50: |
79 | printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __FUNCTION__); | 79 | printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__); |
80 | case 33: | 80 | case 33: |
81 | break; | 81 | break; |
82 | default: | 82 | default: |
83 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", | 83 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
84 | __FUNCTION__, state->Vcc); | 84 | __func__, state->Vcc); |
85 | return -1; | 85 | return -1; |
86 | } | 86 | } |
87 | 87 | ||
88 | printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __FUNCTION__); | 88 | printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__); |
89 | 89 | ||
90 | /* Silently ignore Vpp, output enable, speaker enable. */ | 90 | /* Silently ignore Vpp, output enable, speaker enable. */ |
91 | 91 | ||
diff --git a/drivers/pcmcia/sa1100_simpad.c b/drivers/pcmcia/sa1100_simpad.c index 04d6f7f75f78..42567de894b9 100644 --- a/drivers/pcmcia/sa1100_simpad.c +++ b/drivers/pcmcia/sa1100_simpad.c | |||
@@ -90,7 +90,7 @@ simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | |||
90 | 90 | ||
91 | default: | 91 | default: |
92 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", | 92 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
93 | __FUNCTION__, state->Vcc); | 93 | __func__, state->Vcc); |
94 | clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1); | 94 | clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1); |
95 | local_irq_restore(flags); | 95 | local_irq_restore(flags); |
96 | return -1; | 96 | return -1; |
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c index aa7779d89752..420a77540f41 100644 --- a/drivers/pcmcia/soc_common.c +++ b/drivers/pcmcia/soc_common.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/timer.h> | 38 | #include <linux/timer.h> |
39 | #include <linux/mm.h> | 39 | #include <linux/mm.h> |
40 | #include <linux/mutex.h> | ||
40 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
41 | #include <linux/irq.h> | 42 | #include <linux/irq.h> |
42 | #include <linux/spinlock.h> | 43 | #include <linux/spinlock.h> |
@@ -353,7 +354,7 @@ soc_common_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *m | |||
353 | (map->flags&MAP_PREFETCH)?"PREFETCH ":""); | 354 | (map->flags&MAP_PREFETCH)?"PREFETCH ":""); |
354 | 355 | ||
355 | if (map->map >= MAX_IO_WIN) { | 356 | if (map->map >= MAX_IO_WIN) { |
356 | printk(KERN_ERR "%s(): map (%d) out of range\n", __FUNCTION__, | 357 | printk(KERN_ERR "%s(): map (%d) out of range\n", __func__, |
357 | map->map); | 358 | map->map); |
358 | return -1; | 359 | return -1; |
359 | } | 360 | } |
@@ -578,7 +579,7 @@ EXPORT_SYMBOL(soc_pcmcia_enable_irqs); | |||
578 | 579 | ||
579 | 580 | ||
580 | LIST_HEAD(soc_pcmcia_sockets); | 581 | LIST_HEAD(soc_pcmcia_sockets); |
581 | DECLARE_MUTEX(soc_pcmcia_sockets_lock); | 582 | static DEFINE_MUTEX(soc_pcmcia_sockets_lock); |
582 | 583 | ||
583 | static const char *skt_names[] = { | 584 | static const char *skt_names[] = { |
584 | "PCMCIA socket 0", | 585 | "PCMCIA socket 0", |
@@ -601,11 +602,11 @@ soc_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data) | |||
601 | struct cpufreq_freqs *freqs = data; | 602 | struct cpufreq_freqs *freqs = data; |
602 | int ret = 0; | 603 | int ret = 0; |
603 | 604 | ||
604 | down(&soc_pcmcia_sockets_lock); | 605 | mutex_lock(&soc_pcmcia_sockets_lock); |
605 | list_for_each_entry(skt, &soc_pcmcia_sockets, node) | 606 | list_for_each_entry(skt, &soc_pcmcia_sockets, node) |
606 | if ( skt->ops->frequency_change ) | 607 | if ( skt->ops->frequency_change ) |
607 | ret += skt->ops->frequency_change(skt, val, freqs); | 608 | ret += skt->ops->frequency_change(skt, val, freqs); |
608 | up(&soc_pcmcia_sockets_lock); | 609 | mutex_unlock(&soc_pcmcia_sockets_lock); |
609 | 610 | ||
610 | return ret; | 611 | return ret; |
611 | } | 612 | } |
@@ -642,7 +643,7 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops | |||
642 | struct soc_pcmcia_socket *skt; | 643 | struct soc_pcmcia_socket *skt; |
643 | int ret, i; | 644 | int ret, i; |
644 | 645 | ||
645 | down(&soc_pcmcia_sockets_lock); | 646 | mutex_lock(&soc_pcmcia_sockets_lock); |
646 | 647 | ||
647 | sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); | 648 | sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); |
648 | if (!sinfo) { | 649 | if (!sinfo) { |
@@ -782,7 +783,7 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops | |||
782 | kfree(sinfo); | 783 | kfree(sinfo); |
783 | 784 | ||
784 | out: | 785 | out: |
785 | up(&soc_pcmcia_sockets_lock); | 786 | mutex_unlock(&soc_pcmcia_sockets_lock); |
786 | return ret; | 787 | return ret; |
787 | } | 788 | } |
788 | 789 | ||
@@ -793,7 +794,7 @@ int soc_common_drv_pcmcia_remove(struct device *dev) | |||
793 | 794 | ||
794 | dev_set_drvdata(dev, NULL); | 795 | dev_set_drvdata(dev, NULL); |
795 | 796 | ||
796 | down(&soc_pcmcia_sockets_lock); | 797 | mutex_lock(&soc_pcmcia_sockets_lock); |
797 | for (i = 0; i < sinfo->nskt; i++) { | 798 | for (i = 0; i < sinfo->nskt; i++) { |
798 | struct soc_pcmcia_socket *skt = &sinfo->skt[i]; | 799 | struct soc_pcmcia_socket *skt = &sinfo->skt[i]; |
799 | 800 | ||
@@ -818,7 +819,7 @@ int soc_common_drv_pcmcia_remove(struct device *dev) | |||
818 | if (list_empty(&soc_pcmcia_sockets)) | 819 | if (list_empty(&soc_pcmcia_sockets)) |
819 | soc_pcmcia_cpufreq_unregister(); | 820 | soc_pcmcia_cpufreq_unregister(); |
820 | 821 | ||
821 | up(&soc_pcmcia_sockets_lock); | 822 | mutex_unlock(&soc_pcmcia_sockets_lock); |
822 | 823 | ||
823 | kfree(sinfo); | 824 | kfree(sinfo); |
824 | 825 | ||
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h index 6f14126889b3..1edc1da9d353 100644 --- a/drivers/pcmcia/soc_common.h +++ b/drivers/pcmcia/soc_common.h | |||
@@ -133,7 +133,6 @@ extern void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *, struct soc_ | |||
133 | 133 | ||
134 | 134 | ||
135 | extern struct list_head soc_pcmcia_sockets; | 135 | extern struct list_head soc_pcmcia_sockets; |
136 | extern struct semaphore soc_pcmcia_sockets_lock; | ||
137 | 136 | ||
138 | extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr); | 137 | extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr); |
139 | extern int soc_common_drv_pcmcia_remove(struct device *dev); | 138 | extern int soc_common_drv_pcmcia_remove(struct device *dev); |
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 2e2c457a0fea..5ff9a4c0447e 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c | |||
@@ -591,7 +591,8 @@ static void pnpbios_encode_irq(struct pnp_dev *dev, unsigned char *p, | |||
591 | p[1] = map & 0xff; | 591 | p[1] = map & 0xff; |
592 | p[2] = (map >> 8) & 0xff; | 592 | p[2] = (map >> 8) & 0xff; |
593 | 593 | ||
594 | dev_dbg(&dev->dev, " encode irq %d\n", res->start); | 594 | dev_dbg(&dev->dev, " encode irq %llu\n", |
595 | (unsigned long long)res->start); | ||
595 | } | 596 | } |
596 | 597 | ||
597 | static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p, | 598 | static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p, |
@@ -602,7 +603,8 @@ static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p, | |||
602 | map = 1 << res->start; | 603 | map = 1 << res->start; |
603 | p[1] = map & 0xff; | 604 | p[1] = map & 0xff; |
604 | 605 | ||
605 | dev_dbg(&dev->dev, " encode dma %d\n", res->start); | 606 | dev_dbg(&dev->dev, " encode dma %llu\n", |
607 | (unsigned long long)res->start); | ||
606 | } | 608 | } |
607 | 609 | ||
608 | static void pnpbios_encode_port(struct pnp_dev *dev, unsigned char *p, | 610 | static void pnpbios_encode_port(struct pnp_dev *dev, unsigned char *p, |
diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c index c8aa55b81fd8..82810b7bff9c 100644 --- a/drivers/power/pda_power.c +++ b/drivers/power/pda_power.c | |||
@@ -209,6 +209,12 @@ static int pda_power_probe(struct platform_device *pdev) | |||
209 | 209 | ||
210 | pdata = pdev->dev.platform_data; | 210 | pdata = pdev->dev.platform_data; |
211 | 211 | ||
212 | if (pdata->init) { | ||
213 | ret = pdata->init(dev); | ||
214 | if (ret < 0) | ||
215 | goto init_failed; | ||
216 | } | ||
217 | |||
212 | update_status(); | 218 | update_status(); |
213 | update_charger(); | 219 | update_charger(); |
214 | 220 | ||
@@ -298,6 +304,9 @@ ac_irq_failed: | |||
298 | if (pdata->is_ac_online) | 304 | if (pdata->is_ac_online) |
299 | power_supply_unregister(&pda_psy_ac); | 305 | power_supply_unregister(&pda_psy_ac); |
300 | ac_supply_failed: | 306 | ac_supply_failed: |
307 | if (pdata->exit) | ||
308 | pdata->exit(dev); | ||
309 | init_failed: | ||
301 | wrongid: | 310 | wrongid: |
302 | return ret; | 311 | return ret; |
303 | } | 312 | } |
@@ -318,6 +327,8 @@ static int pda_power_remove(struct platform_device *pdev) | |||
318 | power_supply_unregister(&pda_psy_usb); | 327 | power_supply_unregister(&pda_psy_usb); |
319 | if (pdata->is_ac_online) | 328 | if (pdata->is_ac_online) |
320 | power_supply_unregister(&pda_psy_ac); | 329 | power_supply_unregister(&pda_psy_ac); |
330 | if (pdata->exit) | ||
331 | pdata->exit(dev); | ||
321 | 332 | ||
322 | return 0; | 333 | return 0; |
323 | } | 334 | } |
diff --git a/drivers/power/pmu_battery.c b/drivers/power/pmu_battery.c index 60a8cf3a0431..9346a862f1f2 100644 --- a/drivers/power/pmu_battery.c +++ b/drivers/power/pmu_battery.c | |||
@@ -159,7 +159,7 @@ static int __init pmu_bat_init(void) | |||
159 | if (!pbat) | 159 | if (!pbat) |
160 | break; | 160 | break; |
161 | 161 | ||
162 | sprintf(pbat->name, "PMU battery %d", i); | 162 | sprintf(pbat->name, "PMU_battery_%d", i); |
163 | pbat->bat.name = pbat->name; | 163 | pbat->bat.name = pbat->name; |
164 | pbat->bat.properties = pmu_bat_props; | 164 | pbat->bat.properties = pmu_bat_props; |
165 | pbat->bat.num_properties = ARRAY_SIZE(pmu_bat_props); | 165 | pbat->bat.num_properties = ARRAY_SIZE(pmu_bat_props); |
diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c index 6c9592ce4996..85edf945ab86 100644 --- a/drivers/ps3/ps3-lpm.c +++ b/drivers/ps3/ps3-lpm.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/uaccess.h> | 24 | #include <linux/uaccess.h> |
25 | #include <asm/time.h> | ||
25 | #include <asm/ps3.h> | 26 | #include <asm/ps3.h> |
26 | #include <asm/lv1call.h> | 27 | #include <asm/lv1call.h> |
27 | #include <asm/cell-pmu.h> | 28 | #include <asm/cell-pmu.h> |
diff --git a/drivers/ps3/ps3-sys-manager.c b/drivers/ps3/ps3-sys-manager.c index 7605453b74fd..f17513dd9d4b 100644 --- a/drivers/ps3/ps3-sys-manager.c +++ b/drivers/ps3/ps3-sys-manager.c | |||
@@ -184,10 +184,7 @@ enum ps3_sys_manager_next_op { | |||
184 | 184 | ||
185 | /** | 185 | /** |
186 | * enum ps3_sys_manager_wake_source - Next-op wakeup source (bit position mask). | 186 | * enum ps3_sys_manager_wake_source - Next-op wakeup source (bit position mask). |
187 | * @PS3_SM_WAKE_DEFAULT: Disk insert, power button, eject button, IR | 187 | * @PS3_SM_WAKE_DEFAULT: Disk insert, power button, eject button. |
188 | * controller, and bluetooth controller. | ||
189 | * @PS3_SM_WAKE_RTC: | ||
190 | * @PS3_SM_WAKE_RTC_ERROR: | ||
191 | * @PS3_SM_WAKE_W_O_L: Ether or wireless LAN. | 188 | * @PS3_SM_WAKE_W_O_L: Ether or wireless LAN. |
192 | * @PS3_SM_WAKE_P_O_R: Power on reset. | 189 | * @PS3_SM_WAKE_P_O_R: Power on reset. |
193 | * | 190 | * |
@@ -200,8 +197,6 @@ enum ps3_sys_manager_next_op { | |||
200 | enum ps3_sys_manager_wake_source { | 197 | enum ps3_sys_manager_wake_source { |
201 | /* version 3 */ | 198 | /* version 3 */ |
202 | PS3_SM_WAKE_DEFAULT = 0, | 199 | PS3_SM_WAKE_DEFAULT = 0, |
203 | PS3_SM_WAKE_RTC = 0x00000040, | ||
204 | PS3_SM_WAKE_RTC_ERROR = 0x00000080, | ||
205 | PS3_SM_WAKE_W_O_L = 0x00000400, | 200 | PS3_SM_WAKE_W_O_L = 0x00000400, |
206 | PS3_SM_WAKE_P_O_R = 0x80000000, | 201 | PS3_SM_WAKE_P_O_R = 0x80000000, |
207 | }; | 202 | }; |
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c index 37b85c67b11d..c8bad675dbd1 100644 --- a/drivers/s390/scsi/zfcp_dbf.c +++ b/drivers/s390/scsi/zfcp_dbf.c | |||
@@ -1055,7 +1055,7 @@ static void zfcp_scsi_dbf_event(const char *tag, const char *tag2, int level, | |||
1055 | rec->scsi_result = scsi_cmnd->result; | 1055 | rec->scsi_result = scsi_cmnd->result; |
1056 | rec->scsi_cmnd = (unsigned long)scsi_cmnd; | 1056 | rec->scsi_cmnd = (unsigned long)scsi_cmnd; |
1057 | rec->scsi_serial = scsi_cmnd->serial_number; | 1057 | rec->scsi_serial = scsi_cmnd->serial_number; |
1058 | memcpy(rec->scsi_opcode, &scsi_cmnd->cmnd, | 1058 | memcpy(rec->scsi_opcode, scsi_cmnd->cmnd, |
1059 | min((int)scsi_cmnd->cmd_len, | 1059 | min((int)scsi_cmnd->cmd_len, |
1060 | ZFCP_DBF_SCSI_OPCODE)); | 1060 | ZFCP_DBF_SCSI_OPCODE)); |
1061 | rec->scsi_retries = scsi_cmnd->retries; | 1061 | rec->scsi_retries = scsi_cmnd->retries; |
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 9af2330f07a2..b2ea4ea051f5 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c | |||
@@ -4014,7 +4014,7 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req) | |||
4014 | ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n", | 4014 | ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n", |
4015 | scpnt->result); | 4015 | scpnt->result); |
4016 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, | 4016 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, |
4017 | (void *) &scpnt->cmnd, scpnt->cmd_len); | 4017 | scpnt->cmnd, scpnt->cmd_len); |
4018 | 4018 | ||
4019 | ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n", | 4019 | ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n", |
4020 | fcp_rsp_iu->fcp_sns_len); | 4020 | fcp_rsp_iu->fcp_sns_len); |
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index f4c4fe90240a..f5a9addb7050 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c | |||
@@ -599,7 +599,7 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata, | |||
599 | (struct NCR_700_command_slot *)SCp->host_scribble; | 599 | (struct NCR_700_command_slot *)SCp->host_scribble; |
600 | 600 | ||
601 | dma_unmap_single(hostdata->dev, slot->pCmd, | 601 | dma_unmap_single(hostdata->dev, slot->pCmd, |
602 | sizeof(SCp->cmnd), DMA_TO_DEVICE); | 602 | MAX_COMMAND_SIZE, DMA_TO_DEVICE); |
603 | if (slot->flags == NCR_700_FLAG_AUTOSENSE) { | 603 | if (slot->flags == NCR_700_FLAG_AUTOSENSE) { |
604 | char *cmnd = NCR_700_get_sense_cmnd(SCp->device); | 604 | char *cmnd = NCR_700_get_sense_cmnd(SCp->device); |
605 | #ifdef NCR_700_DEBUG | 605 | #ifdef NCR_700_DEBUG |
@@ -1004,7 +1004,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, | |||
1004 | * here */ | 1004 | * here */ |
1005 | NCR_700_unmap(hostdata, SCp, slot); | 1005 | NCR_700_unmap(hostdata, SCp, slot); |
1006 | dma_unmap_single(hostdata->dev, slot->pCmd, | 1006 | dma_unmap_single(hostdata->dev, slot->pCmd, |
1007 | sizeof(SCp->cmnd), | 1007 | MAX_COMMAND_SIZE, |
1008 | DMA_TO_DEVICE); | 1008 | DMA_TO_DEVICE); |
1009 | 1009 | ||
1010 | cmnd[0] = REQUEST_SENSE; | 1010 | cmnd[0] = REQUEST_SENSE; |
@@ -1901,7 +1901,7 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)) | |||
1901 | } | 1901 | } |
1902 | slot->resume_offset = 0; | 1902 | slot->resume_offset = 0; |
1903 | slot->pCmd = dma_map_single(hostdata->dev, SCp->cmnd, | 1903 | slot->pCmd = dma_map_single(hostdata->dev, SCp->cmnd, |
1904 | sizeof(SCp->cmnd), DMA_TO_DEVICE); | 1904 | MAX_COMMAND_SIZE, DMA_TO_DEVICE); |
1905 | NCR_700_start_command(SCp); | 1905 | NCR_700_start_command(SCp); |
1906 | return 0; | 1906 | return 0; |
1907 | } | 1907 | } |
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 99c57b0c1d54..81ccbd7f9e34 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -504,10 +504,9 @@ config SCSI_AIC7XXX_OLD | |||
504 | source "drivers/scsi/aic7xxx/Kconfig.aic79xx" | 504 | source "drivers/scsi/aic7xxx/Kconfig.aic79xx" |
505 | source "drivers/scsi/aic94xx/Kconfig" | 505 | source "drivers/scsi/aic94xx/Kconfig" |
506 | 506 | ||
507 | # All the I2O code and drivers do not seem to be 64bit safe. | ||
508 | config SCSI_DPT_I2O | 507 | config SCSI_DPT_I2O |
509 | tristate "Adaptec I2O RAID support " | 508 | tristate "Adaptec I2O RAID support " |
510 | depends on !64BIT && SCSI && PCI && VIRT_TO_BUS | 509 | depends on SCSI && PCI && VIRT_TO_BUS |
511 | help | 510 | help |
512 | This driver supports all of Adaptec's I2O based RAID controllers as | 511 | This driver supports all of Adaptec's I2O based RAID controllers as |
513 | well as the DPT SmartRaid V cards. This is an Adaptec maintained | 512 | well as the DPT SmartRaid V cards. This is an Adaptec maintained |
@@ -1680,6 +1679,7 @@ config MAC_SCSI | |||
1680 | config SCSI_MAC_ESP | 1679 | config SCSI_MAC_ESP |
1681 | tristate "Macintosh NCR53c9[46] SCSI" | 1680 | tristate "Macintosh NCR53c9[46] SCSI" |
1682 | depends on MAC && SCSI | 1681 | depends on MAC && SCSI |
1682 | select SCSI_SPI_ATTRS | ||
1683 | help | 1683 | help |
1684 | This is the NCR 53c9x SCSI controller found on most of the 68040 | 1684 | This is the NCR 53c9x SCSI controller found on most of the 68040 |
1685 | based Macintoshes. | 1685 | based Macintoshes. |
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c index 792b2e807bf3..ced3eebe252c 100644 --- a/drivers/scsi/a100u2w.c +++ b/drivers/scsi/a100u2w.c | |||
@@ -895,7 +895,7 @@ static void inia100_build_scb(struct orc_host * host, struct orc_scb * scb, stru | |||
895 | } else { | 895 | } else { |
896 | scb->tag_msg = 0; /* No tag support */ | 896 | scb->tag_msg = 0; /* No tag support */ |
897 | } | 897 | } |
898 | memcpy(&scb->cdb[0], &cmd->cmnd, scb->cdb_len); | 898 | memcpy(scb->cdb, cmd->cmnd, scb->cdb_len); |
899 | } | 899 | } |
900 | 900 | ||
901 | /** | 901 | /** |
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 460d4024c46c..aa4e77c25273 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -498,6 +498,11 @@ static void _aac_probe_container2(void * context, struct fib * fibptr) | |||
498 | (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && | 498 | (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && |
499 | (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { | 499 | (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { |
500 | fsa_dev_ptr->valid = 1; | 500 | fsa_dev_ptr->valid = 1; |
501 | /* sense_key holds the current state of the spin-up */ | ||
502 | if (dresp->mnt[0].state & cpu_to_le32(FSCS_NOT_READY)) | ||
503 | fsa_dev_ptr->sense_data.sense_key = NOT_READY; | ||
504 | else if (fsa_dev_ptr->sense_data.sense_key == NOT_READY) | ||
505 | fsa_dev_ptr->sense_data.sense_key = NO_SENSE; | ||
501 | fsa_dev_ptr->type = le32_to_cpu(dresp->mnt[0].vol); | 506 | fsa_dev_ptr->type = le32_to_cpu(dresp->mnt[0].vol); |
502 | fsa_dev_ptr->size | 507 | fsa_dev_ptr->size |
503 | = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + | 508 | = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + |
@@ -1509,20 +1514,35 @@ static void io_callback(void *context, struct fib * fibptr) | |||
1509 | scsi_dma_unmap(scsicmd); | 1514 | scsi_dma_unmap(scsicmd); |
1510 | 1515 | ||
1511 | readreply = (struct aac_read_reply *)fib_data(fibptr); | 1516 | readreply = (struct aac_read_reply *)fib_data(fibptr); |
1512 | if (le32_to_cpu(readreply->status) == ST_OK) | 1517 | switch (le32_to_cpu(readreply->status)) { |
1513 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; | 1518 | case ST_OK: |
1514 | else { | 1519 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
1520 | SAM_STAT_GOOD; | ||
1521 | dev->fsa_dev[cid].sense_data.sense_key = NO_SENSE; | ||
1522 | break; | ||
1523 | case ST_NOT_READY: | ||
1524 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | | ||
1525 | SAM_STAT_CHECK_CONDITION; | ||
1526 | set_sense(&dev->fsa_dev[cid].sense_data, NOT_READY, | ||
1527 | SENCODE_BECOMING_READY, ASENCODE_BECOMING_READY, 0, 0); | ||
1528 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | ||
1529 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), | ||
1530 | SCSI_SENSE_BUFFERSIZE)); | ||
1531 | break; | ||
1532 | default: | ||
1515 | #ifdef AAC_DETAILED_STATUS_INFO | 1533 | #ifdef AAC_DETAILED_STATUS_INFO |
1516 | printk(KERN_WARNING "io_callback: io failed, status = %d\n", | 1534 | printk(KERN_WARNING "io_callback: io failed, status = %d\n", |
1517 | le32_to_cpu(readreply->status)); | 1535 | le32_to_cpu(readreply->status)); |
1518 | #endif | 1536 | #endif |
1519 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; | 1537 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
1538 | SAM_STAT_CHECK_CONDITION; | ||
1520 | set_sense(&dev->fsa_dev[cid].sense_data, | 1539 | set_sense(&dev->fsa_dev[cid].sense_data, |
1521 | HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, | 1540 | HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, |
1522 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); | 1541 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); |
1523 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | 1542 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
1524 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), | 1543 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
1525 | SCSI_SENSE_BUFFERSIZE)); | 1544 | SCSI_SENSE_BUFFERSIZE)); |
1545 | break; | ||
1526 | } | 1546 | } |
1527 | aac_fib_complete(fibptr); | 1547 | aac_fib_complete(fibptr); |
1528 | aac_fib_free(fibptr); | 1548 | aac_fib_free(fibptr); |
@@ -1863,6 +1883,84 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd) | |||
1863 | return SCSI_MLQUEUE_HOST_BUSY; | 1883 | return SCSI_MLQUEUE_HOST_BUSY; |
1864 | } | 1884 | } |
1865 | 1885 | ||
1886 | static void aac_start_stop_callback(void *context, struct fib *fibptr) | ||
1887 | { | ||
1888 | struct scsi_cmnd *scsicmd = context; | ||
1889 | |||
1890 | if (!aac_valid_context(scsicmd, fibptr)) | ||
1891 | return; | ||
1892 | |||
1893 | BUG_ON(fibptr == NULL); | ||
1894 | |||
1895 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; | ||
1896 | |||
1897 | aac_fib_complete(fibptr); | ||
1898 | aac_fib_free(fibptr); | ||
1899 | scsicmd->scsi_done(scsicmd); | ||
1900 | } | ||
1901 | |||
1902 | static int aac_start_stop(struct scsi_cmnd *scsicmd) | ||
1903 | { | ||
1904 | int status; | ||
1905 | struct fib *cmd_fibcontext; | ||
1906 | struct aac_power_management *pmcmd; | ||
1907 | struct scsi_device *sdev = scsicmd->device; | ||
1908 | struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata; | ||
1909 | |||
1910 | if (!(aac->supplement_adapter_info.SupportedOptions2 & | ||
1911 | AAC_OPTION_POWER_MANAGEMENT)) { | ||
1912 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | | ||
1913 | SAM_STAT_GOOD; | ||
1914 | scsicmd->scsi_done(scsicmd); | ||
1915 | return 0; | ||
1916 | } | ||
1917 | |||
1918 | if (aac->in_reset) | ||
1919 | return SCSI_MLQUEUE_HOST_BUSY; | ||
1920 | |||
1921 | /* | ||
1922 | * Allocate and initialize a Fib | ||
1923 | */ | ||
1924 | cmd_fibcontext = aac_fib_alloc(aac); | ||
1925 | if (!cmd_fibcontext) | ||
1926 | return SCSI_MLQUEUE_HOST_BUSY; | ||
1927 | |||
1928 | aac_fib_init(cmd_fibcontext); | ||
1929 | |||
1930 | pmcmd = fib_data(cmd_fibcontext); | ||
1931 | pmcmd->command = cpu_to_le32(VM_ContainerConfig); | ||
1932 | pmcmd->type = cpu_to_le32(CT_POWER_MANAGEMENT); | ||
1933 | /* Eject bit ignored, not relevant */ | ||
1934 | pmcmd->sub = (scsicmd->cmnd[4] & 1) ? | ||
1935 | cpu_to_le32(CT_PM_START_UNIT) : cpu_to_le32(CT_PM_STOP_UNIT); | ||
1936 | pmcmd->cid = cpu_to_le32(sdev_id(sdev)); | ||
1937 | pmcmd->parm = (scsicmd->cmnd[1] & 1) ? | ||
1938 | cpu_to_le32(CT_PM_UNIT_IMMEDIATE) : 0; | ||
1939 | |||
1940 | /* | ||
1941 | * Now send the Fib to the adapter | ||
1942 | */ | ||
1943 | status = aac_fib_send(ContainerCommand, | ||
1944 | cmd_fibcontext, | ||
1945 | sizeof(struct aac_power_management), | ||
1946 | FsaNormal, | ||
1947 | 0, 1, | ||
1948 | (fib_callback)aac_start_stop_callback, | ||
1949 | (void *)scsicmd); | ||
1950 | |||
1951 | /* | ||
1952 | * Check that the command queued to the controller | ||
1953 | */ | ||
1954 | if (status == -EINPROGRESS) { | ||
1955 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; | ||
1956 | return 0; | ||
1957 | } | ||
1958 | |||
1959 | aac_fib_complete(cmd_fibcontext); | ||
1960 | aac_fib_free(cmd_fibcontext); | ||
1961 | return SCSI_MLQUEUE_HOST_BUSY; | ||
1962 | } | ||
1963 | |||
1866 | /** | 1964 | /** |
1867 | * aac_scsi_cmd() - Process SCSI command | 1965 | * aac_scsi_cmd() - Process SCSI command |
1868 | * @scsicmd: SCSI command block | 1966 | * @scsicmd: SCSI command block |
@@ -1899,7 +1997,9 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) | |||
1899 | * If the target container doesn't exist, it may have | 1997 | * If the target container doesn't exist, it may have |
1900 | * been newly created | 1998 | * been newly created |
1901 | */ | 1999 | */ |
1902 | if ((fsa_dev_ptr[cid].valid & 1) == 0) { | 2000 | if (((fsa_dev_ptr[cid].valid & 1) == 0) || |
2001 | (fsa_dev_ptr[cid].sense_data.sense_key == | ||
2002 | NOT_READY)) { | ||
1903 | switch (scsicmd->cmnd[0]) { | 2003 | switch (scsicmd->cmnd[0]) { |
1904 | case SERVICE_ACTION_IN: | 2004 | case SERVICE_ACTION_IN: |
1905 | if (!(dev->raw_io_interface) || | 2005 | if (!(dev->raw_io_interface) || |
@@ -2091,8 +2191,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) | |||
2091 | scsi_sg_copy_from_buffer(scsicmd, cp, sizeof(cp)); | 2191 | scsi_sg_copy_from_buffer(scsicmd, cp, sizeof(cp)); |
2092 | /* Do not cache partition table for arrays */ | 2192 | /* Do not cache partition table for arrays */ |
2093 | scsicmd->device->removable = 1; | 2193 | scsicmd->device->removable = 1; |
2094 | 2194 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | | |
2095 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; | 2195 | SAM_STAT_GOOD; |
2096 | scsicmd->scsi_done(scsicmd); | 2196 | scsicmd->scsi_done(scsicmd); |
2097 | 2197 | ||
2098 | return 0; | 2198 | return 0; |
@@ -2187,15 +2287,32 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) | |||
2187 | * These commands are all No-Ops | 2287 | * These commands are all No-Ops |
2188 | */ | 2288 | */ |
2189 | case TEST_UNIT_READY: | 2289 | case TEST_UNIT_READY: |
2290 | if (fsa_dev_ptr[cid].sense_data.sense_key == NOT_READY) { | ||
2291 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | | ||
2292 | SAM_STAT_CHECK_CONDITION; | ||
2293 | set_sense(&dev->fsa_dev[cid].sense_data, | ||
2294 | NOT_READY, SENCODE_BECOMING_READY, | ||
2295 | ASENCODE_BECOMING_READY, 0, 0); | ||
2296 | memcpy(scsicmd->sense_buffer, | ||
2297 | &dev->fsa_dev[cid].sense_data, | ||
2298 | min_t(size_t, | ||
2299 | sizeof(dev->fsa_dev[cid].sense_data), | ||
2300 | SCSI_SENSE_BUFFERSIZE)); | ||
2301 | scsicmd->scsi_done(scsicmd); | ||
2302 | return 0; | ||
2303 | } | ||
2304 | /* FALLTHRU */ | ||
2190 | case RESERVE: | 2305 | case RESERVE: |
2191 | case RELEASE: | 2306 | case RELEASE: |
2192 | case REZERO_UNIT: | 2307 | case REZERO_UNIT: |
2193 | case REASSIGN_BLOCKS: | 2308 | case REASSIGN_BLOCKS: |
2194 | case SEEK_10: | 2309 | case SEEK_10: |
2195 | case START_STOP: | ||
2196 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; | 2310 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
2197 | scsicmd->scsi_done(scsicmd); | 2311 | scsicmd->scsi_done(scsicmd); |
2198 | return 0; | 2312 | return 0; |
2313 | |||
2314 | case START_STOP: | ||
2315 | return aac_start_stop(scsicmd); | ||
2199 | } | 2316 | } |
2200 | 2317 | ||
2201 | switch (scsicmd->cmnd[0]) | 2318 | switch (scsicmd->cmnd[0]) |
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 113ca9c8934c..73916adb8f80 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h | |||
@@ -12,7 +12,7 @@ | |||
12 | *----------------------------------------------------------------------------*/ | 12 | *----------------------------------------------------------------------------*/ |
13 | 13 | ||
14 | #ifndef AAC_DRIVER_BUILD | 14 | #ifndef AAC_DRIVER_BUILD |
15 | # define AAC_DRIVER_BUILD 2455 | 15 | # define AAC_DRIVER_BUILD 2456 |
16 | # define AAC_DRIVER_BRANCH "-ms" | 16 | # define AAC_DRIVER_BRANCH "-ms" |
17 | #endif | 17 | #endif |
18 | #define MAXIMUM_NUM_CONTAINERS 32 | 18 | #define MAXIMUM_NUM_CONTAINERS 32 |
@@ -34,8 +34,8 @@ | |||
34 | #define CONTAINER_TO_ID(cont) (cont) | 34 | #define CONTAINER_TO_ID(cont) (cont) |
35 | #define CONTAINER_TO_LUN(cont) (0) | 35 | #define CONTAINER_TO_LUN(cont) (0) |
36 | 36 | ||
37 | #define aac_phys_to_logical(x) (x+1) | 37 | #define aac_phys_to_logical(x) ((x)+1) |
38 | #define aac_logical_to_phys(x) (x?x-1:0) | 38 | #define aac_logical_to_phys(x) ((x)?(x)-1:0) |
39 | 39 | ||
40 | /* #define AAC_DETAILED_STATUS_INFO */ | 40 | /* #define AAC_DETAILED_STATUS_INFO */ |
41 | 41 | ||
@@ -424,6 +424,8 @@ struct aac_init | |||
424 | */ | 424 | */ |
425 | __le32 InitFlags; /* flags for supported features */ | 425 | __le32 InitFlags; /* flags for supported features */ |
426 | #define INITFLAGS_NEW_COMM_SUPPORTED 0x00000001 | 426 | #define INITFLAGS_NEW_COMM_SUPPORTED 0x00000001 |
427 | #define INITFLAGS_DRIVER_USES_UTC_TIME 0x00000010 | ||
428 | #define INITFLAGS_DRIVER_SUPPORTS_PM 0x00000020 | ||
427 | __le32 MaxIoCommands; /* max outstanding commands */ | 429 | __le32 MaxIoCommands; /* max outstanding commands */ |
428 | __le32 MaxIoSize; /* largest I/O command */ | 430 | __le32 MaxIoSize; /* largest I/O command */ |
429 | __le32 MaxFibSize; /* largest FIB to adapter */ | 431 | __le32 MaxFibSize; /* largest FIB to adapter */ |
@@ -867,8 +869,10 @@ struct aac_supplement_adapter_info | |||
867 | }; | 869 | }; |
868 | #define AAC_FEATURE_FALCON cpu_to_le32(0x00000010) | 870 | #define AAC_FEATURE_FALCON cpu_to_le32(0x00000010) |
869 | #define AAC_FEATURE_JBOD cpu_to_le32(0x08000000) | 871 | #define AAC_FEATURE_JBOD cpu_to_le32(0x08000000) |
870 | #define AAC_OPTION_MU_RESET cpu_to_le32(0x00000001) | 872 | /* SupportedOptions2 */ |
871 | #define AAC_OPTION_IGNORE_RESET cpu_to_le32(0x00000002) | 873 | #define AAC_OPTION_MU_RESET cpu_to_le32(0x00000001) |
874 | #define AAC_OPTION_IGNORE_RESET cpu_to_le32(0x00000002) | ||
875 | #define AAC_OPTION_POWER_MANAGEMENT cpu_to_le32(0x00000004) | ||
872 | #define AAC_SIS_VERSION_V3 3 | 876 | #define AAC_SIS_VERSION_V3 3 |
873 | #define AAC_SIS_SLOT_UNKNOWN 0xFF | 877 | #define AAC_SIS_SLOT_UNKNOWN 0xFF |
874 | 878 | ||
@@ -1148,6 +1152,7 @@ struct aac_dev | |||
1148 | #define ST_DQUOT 69 | 1152 | #define ST_DQUOT 69 |
1149 | #define ST_STALE 70 | 1153 | #define ST_STALE 70 |
1150 | #define ST_REMOTE 71 | 1154 | #define ST_REMOTE 71 |
1155 | #define ST_NOT_READY 72 | ||
1151 | #define ST_BADHANDLE 10001 | 1156 | #define ST_BADHANDLE 10001 |
1152 | #define ST_NOT_SYNC 10002 | 1157 | #define ST_NOT_SYNC 10002 |
1153 | #define ST_BAD_COOKIE 10003 | 1158 | #define ST_BAD_COOKIE 10003 |
@@ -1269,6 +1274,18 @@ struct aac_synchronize_reply { | |||
1269 | u8 data[16]; | 1274 | u8 data[16]; |
1270 | }; | 1275 | }; |
1271 | 1276 | ||
1277 | #define CT_POWER_MANAGEMENT 245 | ||
1278 | #define CT_PM_START_UNIT 2 | ||
1279 | #define CT_PM_STOP_UNIT 3 | ||
1280 | #define CT_PM_UNIT_IMMEDIATE 1 | ||
1281 | struct aac_power_management { | ||
1282 | __le32 command; /* VM_ContainerConfig */ | ||
1283 | __le32 type; /* CT_POWER_MANAGEMENT */ | ||
1284 | __le32 sub; /* CT_PM_* */ | ||
1285 | __le32 cid; | ||
1286 | __le32 parm; /* CT_PM_sub_* */ | ||
1287 | }; | ||
1288 | |||
1272 | #define CT_PAUSE_IO 65 | 1289 | #define CT_PAUSE_IO 65 |
1273 | #define CT_RELEASE_IO 66 | 1290 | #define CT_RELEASE_IO 66 |
1274 | struct aac_pause { | 1291 | struct aac_pause { |
@@ -1536,6 +1553,7 @@ struct aac_mntent { | |||
1536 | #define FSCS_NOTCLEAN 0x0001 /* fsck is necessary before mounting */ | 1553 | #define FSCS_NOTCLEAN 0x0001 /* fsck is necessary before mounting */ |
1537 | #define FSCS_READONLY 0x0002 /* possible result of broken mirror */ | 1554 | #define FSCS_READONLY 0x0002 /* possible result of broken mirror */ |
1538 | #define FSCS_HIDDEN 0x0004 /* should be ignored - set during a clear */ | 1555 | #define FSCS_HIDDEN 0x0004 /* should be ignored - set during a clear */ |
1556 | #define FSCS_NOT_READY 0x0008 /* Array spinning up to fulfil request */ | ||
1539 | 1557 | ||
1540 | struct aac_query_mount { | 1558 | struct aac_query_mount { |
1541 | __le32 command; | 1559 | __le32 command; |
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 294a802450be..cbac06355107 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c | |||
@@ -97,6 +97,8 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co | |||
97 | init->InitFlags = cpu_to_le32(INITFLAGS_NEW_COMM_SUPPORTED); | 97 | init->InitFlags = cpu_to_le32(INITFLAGS_NEW_COMM_SUPPORTED); |
98 | dprintk((KERN_WARNING"aacraid: New Comm Interface enabled\n")); | 98 | dprintk((KERN_WARNING"aacraid: New Comm Interface enabled\n")); |
99 | } | 99 | } |
100 | init->InitFlags |= cpu_to_le32(INITFLAGS_DRIVER_USES_UTC_TIME | | ||
101 | INITFLAGS_DRIVER_SUPPORTS_PM); | ||
100 | init->MaxIoCommands = cpu_to_le32(dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); | 102 | init->MaxIoCommands = cpu_to_le32(dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); |
101 | init->MaxIoSize = cpu_to_le32(dev->scsi_host_ptr->max_sectors << 9); | 103 | init->MaxIoSize = cpu_to_le32(dev->scsi_host_ptr->max_sectors << 9); |
102 | init->MaxFibSize = cpu_to_le32(dev->max_fib_size); | 104 | init->MaxFibSize = cpu_to_le32(dev->max_fib_size); |
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index ef67816a6fe5..289304aab690 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c | |||
@@ -515,7 +515,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, | |||
515 | } | 515 | } |
516 | udelay(5); | 516 | udelay(5); |
517 | } | 517 | } |
518 | } else if (down_interruptible(&fibptr->event_wait) == 0) { | 518 | } else if (down_interruptible(&fibptr->event_wait)) { |
519 | fibptr->done = 2; | 519 | fibptr->done = 2; |
520 | up(&fibptr->event_wait); | 520 | up(&fibptr->event_wait); |
521 | } | 521 | } |
@@ -906,15 +906,22 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) | |||
906 | case AifEnAddJBOD: | 906 | case AifEnAddJBOD: |
907 | case AifEnDeleteJBOD: | 907 | case AifEnDeleteJBOD: |
908 | container = le32_to_cpu(((__le32 *)aifcmd->data)[1]); | 908 | container = le32_to_cpu(((__le32 *)aifcmd->data)[1]); |
909 | if ((container >> 28)) | 909 | if ((container >> 28)) { |
910 | container = (u32)-1; | ||
910 | break; | 911 | break; |
912 | } | ||
911 | channel = (container >> 24) & 0xF; | 913 | channel = (container >> 24) & 0xF; |
912 | if (channel >= dev->maximum_num_channels) | 914 | if (channel >= dev->maximum_num_channels) { |
915 | container = (u32)-1; | ||
913 | break; | 916 | break; |
917 | } | ||
914 | id = container & 0xFFFF; | 918 | id = container & 0xFFFF; |
915 | if (id >= dev->maximum_num_physicals) | 919 | if (id >= dev->maximum_num_physicals) { |
920 | container = (u32)-1; | ||
916 | break; | 921 | break; |
922 | } | ||
917 | lun = (container >> 16) & 0xFF; | 923 | lun = (container >> 16) & 0xFF; |
924 | container = (u32)-1; | ||
918 | channel = aac_phys_to_logical(channel); | 925 | channel = aac_phys_to_logical(channel); |
919 | device_config_needed = | 926 | device_config_needed = |
920 | (((__le32 *)aifcmd->data)[0] == | 927 | (((__le32 *)aifcmd->data)[0] == |
@@ -933,13 +940,18 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) | |||
933 | case EM_DRIVE_REMOVAL: | 940 | case EM_DRIVE_REMOVAL: |
934 | container = le32_to_cpu( | 941 | container = le32_to_cpu( |
935 | ((__le32 *)aifcmd->data)[2]); | 942 | ((__le32 *)aifcmd->data)[2]); |
936 | if ((container >> 28)) | 943 | if ((container >> 28)) { |
944 | container = (u32)-1; | ||
937 | break; | 945 | break; |
946 | } | ||
938 | channel = (container >> 24) & 0xF; | 947 | channel = (container >> 24) & 0xF; |
939 | if (channel >= dev->maximum_num_channels) | 948 | if (channel >= dev->maximum_num_channels) { |
949 | container = (u32)-1; | ||
940 | break; | 950 | break; |
951 | } | ||
941 | id = container & 0xFFFF; | 952 | id = container & 0xFFFF; |
942 | lun = (container >> 16) & 0xFF; | 953 | lun = (container >> 16) & 0xFF; |
954 | container = (u32)-1; | ||
943 | if (id >= dev->maximum_num_physicals) { | 955 | if (id >= dev->maximum_num_physicals) { |
944 | /* legacy dev_t ? */ | 956 | /* legacy dev_t ? */ |
945 | if ((0x2000 <= id) || lun || channel || | 957 | if ((0x2000 <= id) || lun || channel || |
@@ -1025,9 +1037,10 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) | |||
1025 | break; | 1037 | break; |
1026 | } | 1038 | } |
1027 | 1039 | ||
1040 | container = 0; | ||
1041 | retry_next: | ||
1028 | if (device_config_needed == NOTHING) | 1042 | if (device_config_needed == NOTHING) |
1029 | for (container = 0; container < dev->maximum_num_containers; | 1043 | for (; container < dev->maximum_num_containers; ++container) { |
1030 | ++container) { | ||
1031 | if ((dev->fsa_dev[container].config_waiting_on == 0) && | 1044 | if ((dev->fsa_dev[container].config_waiting_on == 0) && |
1032 | (dev->fsa_dev[container].config_needed != NOTHING) && | 1045 | (dev->fsa_dev[container].config_needed != NOTHING) && |
1033 | time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT)) { | 1046 | time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT)) { |
@@ -1110,6 +1123,11 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) | |||
1110 | } | 1123 | } |
1111 | if (device_config_needed == ADD) | 1124 | if (device_config_needed == ADD) |
1112 | scsi_add_device(dev->scsi_host_ptr, channel, id, lun); | 1125 | scsi_add_device(dev->scsi_host_ptr, channel, id, lun); |
1126 | if (channel == CONTAINER_CHANNEL) { | ||
1127 | container++; | ||
1128 | device_config_needed = NOTHING; | ||
1129 | goto retry_next; | ||
1130 | } | ||
1113 | } | 1131 | } |
1114 | 1132 | ||
1115 | static int _aac_reset_adapter(struct aac_dev *aac, int forced) | 1133 | static int _aac_reset_adapter(struct aac_dev *aac, int forced) |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index c109f63f8279..1f7c83607f84 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -401,6 +401,8 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev, | |||
401 | static int aac_slave_configure(struct scsi_device *sdev) | 401 | static int aac_slave_configure(struct scsi_device *sdev) |
402 | { | 402 | { |
403 | struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata; | 403 | struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata; |
404 | if (aac->jbod && (sdev->type == TYPE_DISK)) | ||
405 | sdev->removable = 1; | ||
404 | if ((sdev->type == TYPE_DISK) && | 406 | if ((sdev->type == TYPE_DISK) && |
405 | (sdev_channel(sdev) != CONTAINER_CHANNEL) && | 407 | (sdev_channel(sdev) != CONTAINER_CHANNEL) && |
406 | (!aac->jbod || sdev->inq_periph_qual) && | 408 | (!aac->jbod || sdev->inq_periph_qual) && |
@@ -809,6 +811,12 @@ static ssize_t aac_show_flags(struct device *cdev, | |||
809 | "SAI_READ_CAPACITY_16\n"); | 811 | "SAI_READ_CAPACITY_16\n"); |
810 | if (dev->jbod) | 812 | if (dev->jbod) |
811 | len += snprintf(buf + len, PAGE_SIZE - len, "SUPPORTED_JBOD\n"); | 813 | len += snprintf(buf + len, PAGE_SIZE - len, "SUPPORTED_JBOD\n"); |
814 | if (dev->supplement_adapter_info.SupportedOptions2 & | ||
815 | AAC_OPTION_POWER_MANAGEMENT) | ||
816 | len += snprintf(buf + len, PAGE_SIZE - len, | ||
817 | "SUPPORTED_POWER_MANAGEMENT\n"); | ||
818 | if (dev->msi) | ||
819 | len += snprintf(buf + len, PAGE_SIZE - len, "PCI_HAS_MSI\n"); | ||
812 | return len; | 820 | return len; |
813 | } | 821 | } |
814 | 822 | ||
@@ -1106,7 +1114,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, | |||
1106 | aac->pdev = pdev; | 1114 | aac->pdev = pdev; |
1107 | aac->name = aac_driver_template.name; | 1115 | aac->name = aac_driver_template.name; |
1108 | aac->id = shost->unique_id; | 1116 | aac->id = shost->unique_id; |
1109 | aac->cardtype = index; | 1117 | aac->cardtype = index; |
1110 | INIT_LIST_HEAD(&aac->entry); | 1118 | INIT_LIST_HEAD(&aac->entry); |
1111 | 1119 | ||
1112 | aac->fibs = kmalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL); | 1120 | aac->fibs = kmalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL); |
@@ -1146,19 +1154,19 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, | |||
1146 | goto out_deinit; | 1154 | goto out_deinit; |
1147 | 1155 | ||
1148 | /* | 1156 | /* |
1149 | * Lets override negotiations and drop the maximum SG limit to 34 | 1157 | * Lets override negotiations and drop the maximum SG limit to 34 |
1150 | */ | 1158 | */ |
1151 | if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) && | 1159 | if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) && |
1152 | (shost->sg_tablesize > 34)) { | 1160 | (shost->sg_tablesize > 34)) { |
1153 | shost->sg_tablesize = 34; | 1161 | shost->sg_tablesize = 34; |
1154 | shost->max_sectors = (shost->sg_tablesize * 8) + 112; | 1162 | shost->max_sectors = (shost->sg_tablesize * 8) + 112; |
1155 | } | 1163 | } |
1156 | 1164 | ||
1157 | if ((aac_drivers[index].quirks & AAC_QUIRK_17SG) && | 1165 | if ((aac_drivers[index].quirks & AAC_QUIRK_17SG) && |
1158 | (shost->sg_tablesize > 17)) { | 1166 | (shost->sg_tablesize > 17)) { |
1159 | shost->sg_tablesize = 17; | 1167 | shost->sg_tablesize = 17; |
1160 | shost->max_sectors = (shost->sg_tablesize * 8) + 112; | 1168 | shost->max_sectors = (shost->sg_tablesize * 8) + 112; |
1161 | } | 1169 | } |
1162 | 1170 | ||
1163 | error = pci_set_dma_max_seg_size(pdev, | 1171 | error = pci_set_dma_max_seg_size(pdev, |
1164 | (aac->adapter_info.options & AAC_OPT_NEW_COMM) ? | 1172 | (aac->adapter_info.options & AAC_OPT_NEW_COMM) ? |
@@ -1174,7 +1182,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, | |||
1174 | else | 1182 | else |
1175 | aac->printf_enabled = 0; | 1183 | aac->printf_enabled = 0; |
1176 | 1184 | ||
1177 | /* | 1185 | /* |
1178 | * max channel will be the physical channels plus 1 virtual channel | 1186 | * max channel will be the physical channels plus 1 virtual channel |
1179 | * all containers are on the virtual channel 0 (CONTAINER_CHANNEL) | 1187 | * all containers are on the virtual channel 0 (CONTAINER_CHANNEL) |
1180 | * physical channels are address by their actual physical number+1 | 1188 | * physical channels are address by their actual physical number+1 |
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index 90f5e0a6f2e3..2a730c470f62 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c | |||
@@ -529,10 +529,10 @@ static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) | |||
529 | /* The first entry, 0, is used for dynamic ids, the rest for devices | 529 | /* The first entry, 0, is used for dynamic ids, the rest for devices |
530 | * we know about. | 530 | * we know about. |
531 | */ | 531 | */ |
532 | static struct asd_pcidev_struct { | 532 | static const struct asd_pcidev_struct { |
533 | const char * name; | 533 | const char * name; |
534 | int (*setup)(struct asd_ha_struct *asd_ha); | 534 | int (*setup)(struct asd_ha_struct *asd_ha); |
535 | } asd_pcidev_data[] = { | 535 | } asd_pcidev_data[] __devinitconst = { |
536 | /* Id 0 is used for dynamic ids. */ | 536 | /* Id 0 is used for dynamic ids. */ |
537 | { .name = "Adaptec AIC-94xx SAS/SATA Host Adapter", | 537 | { .name = "Adaptec AIC-94xx SAS/SATA Host Adapter", |
538 | .setup = asd_aic9410_setup | 538 | .setup = asd_aic9410_setup |
@@ -735,7 +735,7 @@ static int asd_unregister_sas_ha(struct asd_ha_struct *asd_ha) | |||
735 | static int __devinit asd_pci_probe(struct pci_dev *dev, | 735 | static int __devinit asd_pci_probe(struct pci_dev *dev, |
736 | const struct pci_device_id *id) | 736 | const struct pci_device_id *id) |
737 | { | 737 | { |
738 | struct asd_pcidev_struct *asd_dev; | 738 | const struct asd_pcidev_struct *asd_dev; |
739 | unsigned asd_id = (unsigned) id->driver_data; | 739 | unsigned asd_id = (unsigned) id->driver_data; |
740 | struct asd_ha_struct *asd_ha; | 740 | struct asd_ha_struct *asd_ha; |
741 | struct Scsi_Host *shost; | 741 | struct Scsi_Host *shost; |
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 403a7f2d8f9b..9785d7384199 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #define SERVICE_ACTION_OUT_12 0xa9 | 28 | #define SERVICE_ACTION_OUT_12 0xa9 |
29 | #define SERVICE_ACTION_IN_16 0x9e | 29 | #define SERVICE_ACTION_IN_16 0x9e |
30 | #define SERVICE_ACTION_OUT_16 0x9f | 30 | #define SERVICE_ACTION_OUT_16 0x9f |
31 | #define VARIABLE_LENGTH_CMD 0x7f | ||
32 | 31 | ||
33 | 32 | ||
34 | 33 | ||
@@ -210,7 +209,7 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) | |||
210 | cdb0 = cdbp[0]; | 209 | cdb0 = cdbp[0]; |
211 | switch(cdb0) { | 210 | switch(cdb0) { |
212 | case VARIABLE_LENGTH_CMD: | 211 | case VARIABLE_LENGTH_CMD: |
213 | len = cdbp[7] + 8; | 212 | len = scsi_varlen_cdb_length(cdbp); |
214 | if (len < 10) { | 213 | if (len < 10) { |
215 | printk("short variable length command, " | 214 | printk("short variable length command, " |
216 | "len=%d ext_len=%d", len, cdb_len); | 215 | "len=%d ext_len=%d", len, cdb_len); |
@@ -300,7 +299,7 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) | |||
300 | cdb0 = cdbp[0]; | 299 | cdb0 = cdbp[0]; |
301 | switch(cdb0) { | 300 | switch(cdb0) { |
302 | case VARIABLE_LENGTH_CMD: | 301 | case VARIABLE_LENGTH_CMD: |
303 | len = cdbp[7] + 8; | 302 | len = scsi_varlen_cdb_length(cdbp); |
304 | if (len < 10) { | 303 | if (len < 10) { |
305 | printk("short opcode=0x%x command, len=%d " | 304 | printk("short opcode=0x%x command, len=%d " |
306 | "ext_len=%d", cdb0, len, cdb_len); | 305 | "ext_len=%d", cdb0, len, cdb_len); |
@@ -335,10 +334,7 @@ void __scsi_print_command(unsigned char *cdb) | |||
335 | int k, len; | 334 | int k, len; |
336 | 335 | ||
337 | print_opcode_name(cdb, 0); | 336 | print_opcode_name(cdb, 0); |
338 | if (VARIABLE_LENGTH_CMD == cdb[0]) | 337 | len = scsi_command_size(cdb); |
339 | len = cdb[7] + 8; | ||
340 | else | ||
341 | len = COMMAND_SIZE(cdb[0]); | ||
342 | /* print out all bytes in cdb */ | 338 | /* print out all bytes in cdb */ |
343 | for (k = 0; k < len; ++k) | 339 | for (k = 0; k < len; ++k) |
344 | printk(" %02x", cdb[k]); | 340 | printk(" %02x", cdb[k]); |
diff --git a/drivers/scsi/dpt/dpti_ioctl.h b/drivers/scsi/dpt/dpti_ioctl.h index cc784e8f6e9d..f60236721e0d 100644 --- a/drivers/scsi/dpt/dpti_ioctl.h +++ b/drivers/scsi/dpt/dpti_ioctl.h | |||
@@ -89,7 +89,7 @@ typedef struct { | |||
89 | int njobs; /* # of jobs sent to HA */ | 89 | int njobs; /* # of jobs sent to HA */ |
90 | int qdepth; /* Controller queue depth. */ | 90 | int qdepth; /* Controller queue depth. */ |
91 | int wakebase; /* mpx wakeup base index. */ | 91 | int wakebase; /* mpx wakeup base index. */ |
92 | uLONG SGsize; /* Scatter/Gather list size. */ | 92 | uINT SGsize; /* Scatter/Gather list size. */ |
93 | unsigned heads; /* heads for drives on cntlr. */ | 93 | unsigned heads; /* heads for drives on cntlr. */ |
94 | unsigned sectors; /* sectors for drives on cntlr. */ | 94 | unsigned sectors; /* sectors for drives on cntlr. */ |
95 | uCHAR do_drive32; /* Flag for Above 16 MB Ability */ | 95 | uCHAR do_drive32; /* Flag for Above 16 MB Ability */ |
@@ -97,8 +97,8 @@ typedef struct { | |||
97 | char idPAL[4]; /* 4 Bytes Of The ID Pal */ | 97 | char idPAL[4]; /* 4 Bytes Of The ID Pal */ |
98 | uCHAR primary; /* 1 For Primary, 0 For Secondary */ | 98 | uCHAR primary; /* 1 For Primary, 0 For Secondary */ |
99 | uCHAR eataVersion; /* EATA Version */ | 99 | uCHAR eataVersion; /* EATA Version */ |
100 | uLONG cpLength; /* EATA Command Packet Length */ | 100 | uINT cpLength; /* EATA Command Packet Length */ |
101 | uLONG spLength; /* EATA Status Packet Length */ | 101 | uINT spLength; /* EATA Status Packet Length */ |
102 | uCHAR drqNum; /* DRQ Index (0,5,6,7) */ | 102 | uCHAR drqNum; /* DRQ Index (0,5,6,7) */ |
103 | uCHAR flag1; /* EATA Flags 1 (Byte 9) */ | 103 | uCHAR flag1; /* EATA Flags 1 (Byte 9) */ |
104 | uCHAR flag2; /* EATA Flags 2 (Byte 30) */ | 104 | uCHAR flag2; /* EATA Flags 2 (Byte 30) */ |
@@ -107,23 +107,23 @@ typedef struct { | |||
107 | typedef struct { | 107 | typedef struct { |
108 | uSHORT length; // Remaining length of this | 108 | uSHORT length; // Remaining length of this |
109 | uSHORT drvrHBAnum; // Relative HBA # used by the driver | 109 | uSHORT drvrHBAnum; // Relative HBA # used by the driver |
110 | uLONG baseAddr; // Base I/O address | 110 | uINT baseAddr; // Base I/O address |
111 | uSHORT blinkState; // Blink LED state (0=Not in blink LED) | 111 | uSHORT blinkState; // Blink LED state (0=Not in blink LED) |
112 | uCHAR pciBusNum; // PCI Bus # (Optional) | 112 | uCHAR pciBusNum; // PCI Bus # (Optional) |
113 | uCHAR pciDeviceNum; // PCI Device # (Optional) | 113 | uCHAR pciDeviceNum; // PCI Device # (Optional) |
114 | uSHORT hbaFlags; // Miscellaneous HBA flags | 114 | uSHORT hbaFlags; // Miscellaneous HBA flags |
115 | uSHORT Interrupt; // Interrupt set for this device. | 115 | uSHORT Interrupt; // Interrupt set for this device. |
116 | # if (defined(_DPT_ARC)) | 116 | # if (defined(_DPT_ARC)) |
117 | uLONG baseLength; | 117 | uINT baseLength; |
118 | ADAPTER_OBJECT *AdapterObject; | 118 | ADAPTER_OBJECT *AdapterObject; |
119 | LARGE_INTEGER DmaLogicalAddress; | 119 | LARGE_INTEGER DmaLogicalAddress; |
120 | PVOID DmaVirtualAddress; | 120 | PVOID DmaVirtualAddress; |
121 | LARGE_INTEGER ReplyLogicalAddress; | 121 | LARGE_INTEGER ReplyLogicalAddress; |
122 | PVOID ReplyVirtualAddress; | 122 | PVOID ReplyVirtualAddress; |
123 | # else | 123 | # else |
124 | uLONG reserved1; // Reserved for future expansion | 124 | uINT reserved1; // Reserved for future expansion |
125 | uLONG reserved2; // Reserved for future expansion | 125 | uINT reserved2; // Reserved for future expansion |
126 | uLONG reserved3; // Reserved for future expansion | 126 | uINT reserved3; // Reserved for future expansion |
127 | # endif | 127 | # endif |
128 | } drvrHBAinfo_S; | 128 | } drvrHBAinfo_S; |
129 | 129 | ||
diff --git a/drivers/scsi/dpt/dptsig.h b/drivers/scsi/dpt/dptsig.h index 94bc894d1200..72c8992fdf21 100644 --- a/drivers/scsi/dpt/dptsig.h +++ b/drivers/scsi/dpt/dptsig.h | |||
@@ -33,11 +33,7 @@ | |||
33 | /* to make sure we are talking the same size under all OS's */ | 33 | /* to make sure we are talking the same size under all OS's */ |
34 | typedef unsigned char sigBYTE; | 34 | typedef unsigned char sigBYTE; |
35 | typedef unsigned short sigWORD; | 35 | typedef unsigned short sigWORD; |
36 | #if (defined(_MULTI_DATAMODEL) && defined(sun) && !defined(_ILP32)) | 36 | typedef unsigned int sigINT; |
37 | typedef uint32_t sigLONG; | ||
38 | #else | ||
39 | typedef unsigned long sigLONG; | ||
40 | #endif | ||
41 | 37 | ||
42 | /* | 38 | /* |
43 | * use sigWORDLittleEndian for: | 39 | * use sigWORDLittleEndian for: |
@@ -300,7 +296,7 @@ typedef struct dpt_sig { | |||
300 | sigBYTE dsFiletype; /* type of file */ | 296 | sigBYTE dsFiletype; /* type of file */ |
301 | sigBYTE dsFiletypeFlags; /* flags to specify load type, etc. */ | 297 | sigBYTE dsFiletypeFlags; /* flags to specify load type, etc. */ |
302 | sigBYTE dsOEM; /* OEM file was created for */ | 298 | sigBYTE dsOEM; /* OEM file was created for */ |
303 | sigLONG dsOS; /* which Operating systems */ | 299 | sigINT dsOS; /* which Operating systems */ |
304 | sigWORD dsCapabilities; /* RAID levels, etc. */ | 300 | sigWORD dsCapabilities; /* RAID levels, etc. */ |
305 | sigWORD dsDeviceSupp; /* Types of SCSI devices supported */ | 301 | sigWORD dsDeviceSupp; /* Types of SCSI devices supported */ |
306 | sigWORD dsAdapterSupp; /* DPT adapter families supported */ | 302 | sigWORD dsAdapterSupp; /* DPT adapter families supported */ |
diff --git a/drivers/scsi/dpt/sys_info.h b/drivers/scsi/dpt/sys_info.h index d23b70c8c768..a90c4cb8ea8b 100644 --- a/drivers/scsi/dpt/sys_info.h +++ b/drivers/scsi/dpt/sys_info.h | |||
@@ -145,8 +145,8 @@ | |||
145 | uCHAR smartROMRevision; | 145 | uCHAR smartROMRevision; |
146 | uSHORT flags; /* See bit definitions above */ | 146 | uSHORT flags; /* See bit definitions above */ |
147 | uSHORT conventionalMemSize; /* in KB */ | 147 | uSHORT conventionalMemSize; /* in KB */ |
148 | uLONG extendedMemSize; /* in KB */ | 148 | uINT extendedMemSize; /* in KB */ |
149 | uLONG osType; /* Same as DPTSIG's definition */ | 149 | uINT osType; /* Same as DPTSIG's definition */ |
150 | uCHAR osMajorVersion; | 150 | uCHAR osMajorVersion; |
151 | uCHAR osMinorVersion; /* The OS version */ | 151 | uCHAR osMinorVersion; /* The OS version */ |
152 | uCHAR osRevision; | 152 | uCHAR osRevision; |
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index ac92ac143b46..0fb5bf4c43ac 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c | |||
@@ -29,11 +29,6 @@ | |||
29 | /*#define DEBUG 1 */ | 29 | /*#define DEBUG 1 */ |
30 | /*#define UARTDELAY 1 */ | 30 | /*#define UARTDELAY 1 */ |
31 | 31 | ||
32 | /* On the real kernel ADDR32 should always be zero for 2.4. GFP_HIGH allocates | ||
33 | high pages. Keep the macro around because of the broken unmerged ia64 tree */ | ||
34 | |||
35 | #define ADDR32 (0) | ||
36 | |||
37 | #include <linux/module.h> | 32 | #include <linux/module.h> |
38 | 33 | ||
39 | MODULE_AUTHOR("Deanna Bonds, with _lots_ of help from Mark Salyzyn"); | 34 | MODULE_AUTHOR("Deanna Bonds, with _lots_ of help from Mark Salyzyn"); |
@@ -108,27 +103,28 @@ static dpt_sig_S DPTI_sig = { | |||
108 | 103 | ||
109 | static DEFINE_MUTEX(adpt_configuration_lock); | 104 | static DEFINE_MUTEX(adpt_configuration_lock); |
110 | 105 | ||
111 | static struct i2o_sys_tbl *sys_tbl = NULL; | 106 | static struct i2o_sys_tbl *sys_tbl; |
112 | static int sys_tbl_ind = 0; | 107 | static dma_addr_t sys_tbl_pa; |
113 | static int sys_tbl_len = 0; | 108 | static int sys_tbl_ind; |
109 | static int sys_tbl_len; | ||
114 | 110 | ||
115 | static adpt_hba* hba_chain = NULL; | 111 | static adpt_hba* hba_chain = NULL; |
116 | static int hba_count = 0; | 112 | static int hba_count = 0; |
117 | 113 | ||
114 | static struct class *adpt_sysfs_class; | ||
115 | |||
116 | #ifdef CONFIG_COMPAT | ||
117 | static long compat_adpt_ioctl(struct file *, unsigned int, unsigned long); | ||
118 | #endif | ||
119 | |||
118 | static const struct file_operations adpt_fops = { | 120 | static const struct file_operations adpt_fops = { |
119 | .ioctl = adpt_ioctl, | 121 | .ioctl = adpt_ioctl, |
120 | .open = adpt_open, | 122 | .open = adpt_open, |
121 | .release = adpt_close | 123 | .release = adpt_close, |
122 | }; | 124 | #ifdef CONFIG_COMPAT |
123 | 125 | .compat_ioctl = compat_adpt_ioctl, | |
124 | #ifdef REBOOT_NOTIFIER | ||
125 | static struct notifier_block adpt_reboot_notifier = | ||
126 | { | ||
127 | adpt_reboot_event, | ||
128 | NULL, | ||
129 | 0 | ||
130 | }; | ||
131 | #endif | 126 | #endif |
127 | }; | ||
132 | 128 | ||
133 | /* Structures and definitions for synchronous message posting. | 129 | /* Structures and definitions for synchronous message posting. |
134 | * See adpt_i2o_post_wait() for description | 130 | * See adpt_i2o_post_wait() for description |
@@ -151,6 +147,21 @@ static DEFINE_SPINLOCK(adpt_post_wait_lock); | |||
151 | *============================================================================ | 147 | *============================================================================ |
152 | */ | 148 | */ |
153 | 149 | ||
150 | static inline int dpt_dma64(adpt_hba *pHba) | ||
151 | { | ||
152 | return (sizeof(dma_addr_t) > 4 && (pHba)->dma64); | ||
153 | } | ||
154 | |||
155 | static inline u32 dma_high(dma_addr_t addr) | ||
156 | { | ||
157 | return upper_32_bits(addr); | ||
158 | } | ||
159 | |||
160 | static inline u32 dma_low(dma_addr_t addr) | ||
161 | { | ||
162 | return (u32)addr; | ||
163 | } | ||
164 | |||
154 | static u8 adpt_read_blink_led(adpt_hba* host) | 165 | static u8 adpt_read_blink_led(adpt_hba* host) |
155 | { | 166 | { |
156 | if (host->FwDebugBLEDflag_P) { | 167 | if (host->FwDebugBLEDflag_P) { |
@@ -178,8 +189,6 @@ static int adpt_detect(struct scsi_host_template* sht) | |||
178 | struct pci_dev *pDev = NULL; | 189 | struct pci_dev *pDev = NULL; |
179 | adpt_hba* pHba; | 190 | adpt_hba* pHba; |
180 | 191 | ||
181 | adpt_init(); | ||
182 | |||
183 | PINFO("Detecting Adaptec I2O RAID controllers...\n"); | 192 | PINFO("Detecting Adaptec I2O RAID controllers...\n"); |
184 | 193 | ||
185 | /* search for all Adatpec I2O RAID cards */ | 194 | /* search for all Adatpec I2O RAID cards */ |
@@ -247,13 +256,29 @@ rebuild_sys_tab: | |||
247 | adpt_inquiry(pHba); | 256 | adpt_inquiry(pHba); |
248 | } | 257 | } |
249 | 258 | ||
259 | adpt_sysfs_class = class_create(THIS_MODULE, "dpt_i2o"); | ||
260 | if (IS_ERR(adpt_sysfs_class)) { | ||
261 | printk(KERN_WARNING"dpti: unable to create dpt_i2o class\n"); | ||
262 | adpt_sysfs_class = NULL; | ||
263 | } | ||
264 | |||
250 | for (pHba = hba_chain; pHba; pHba = pHba->next) { | 265 | for (pHba = hba_chain; pHba; pHba = pHba->next) { |
251 | if( adpt_scsi_register(pHba,sht) < 0){ | 266 | if (adpt_scsi_host_alloc(pHba, sht) < 0){ |
252 | adpt_i2o_delete_hba(pHba); | 267 | adpt_i2o_delete_hba(pHba); |
253 | continue; | 268 | continue; |
254 | } | 269 | } |
255 | pHba->initialized = TRUE; | 270 | pHba->initialized = TRUE; |
256 | pHba->state &= ~DPTI_STATE_RESET; | 271 | pHba->state &= ~DPTI_STATE_RESET; |
272 | if (adpt_sysfs_class) { | ||
273 | struct device *dev = device_create(adpt_sysfs_class, | ||
274 | NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), | ||
275 | "dpti%d", pHba->unit); | ||
276 | if (IS_ERR(dev)) { | ||
277 | printk(KERN_WARNING"dpti%d: unable to " | ||
278 | "create device in dpt_i2o class\n", | ||
279 | pHba->unit); | ||
280 | } | ||
281 | } | ||
257 | } | 282 | } |
258 | 283 | ||
259 | // Register our control device node | 284 | // Register our control device node |
@@ -282,7 +307,7 @@ static int adpt_release(struct Scsi_Host *host) | |||
282 | 307 | ||
283 | static void adpt_inquiry(adpt_hba* pHba) | 308 | static void adpt_inquiry(adpt_hba* pHba) |
284 | { | 309 | { |
285 | u32 msg[14]; | 310 | u32 msg[17]; |
286 | u32 *mptr; | 311 | u32 *mptr; |
287 | u32 *lenptr; | 312 | u32 *lenptr; |
288 | int direction; | 313 | int direction; |
@@ -290,11 +315,12 @@ static void adpt_inquiry(adpt_hba* pHba) | |||
290 | u32 len; | 315 | u32 len; |
291 | u32 reqlen; | 316 | u32 reqlen; |
292 | u8* buf; | 317 | u8* buf; |
318 | dma_addr_t addr; | ||
293 | u8 scb[16]; | 319 | u8 scb[16]; |
294 | s32 rcode; | 320 | s32 rcode; |
295 | 321 | ||
296 | memset(msg, 0, sizeof(msg)); | 322 | memset(msg, 0, sizeof(msg)); |
297 | buf = kmalloc(80,GFP_KERNEL|ADDR32); | 323 | buf = dma_alloc_coherent(&pHba->pDev->dev, 80, &addr, GFP_KERNEL); |
298 | if(!buf){ | 324 | if(!buf){ |
299 | printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name); | 325 | printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name); |
300 | return; | 326 | return; |
@@ -305,7 +331,10 @@ static void adpt_inquiry(adpt_hba* pHba) | |||
305 | direction = 0x00000000; | 331 | direction = 0x00000000; |
306 | scsidir =0x40000000; // DATA IN (iop<--dev) | 332 | scsidir =0x40000000; // DATA IN (iop<--dev) |
307 | 333 | ||
308 | reqlen = 14; // SINGLE SGE | 334 | if (dpt_dma64(pHba)) |
335 | reqlen = 17; // SINGLE SGE, 64 bit | ||
336 | else | ||
337 | reqlen = 14; // SINGLE SGE, 32 bit | ||
309 | /* Stick the headers on */ | 338 | /* Stick the headers on */ |
310 | msg[0] = reqlen<<16 | SGL_OFFSET_12; | 339 | msg[0] = reqlen<<16 | SGL_OFFSET_12; |
311 | msg[1] = (0xff<<24|HOST_TID<<12|ADAPTER_TID); | 340 | msg[1] = (0xff<<24|HOST_TID<<12|ADAPTER_TID); |
@@ -338,8 +367,16 @@ static void adpt_inquiry(adpt_hba* pHba) | |||
338 | 367 | ||
339 | /* Now fill in the SGList and command */ | 368 | /* Now fill in the SGList and command */ |
340 | *lenptr = len; | 369 | *lenptr = len; |
341 | *mptr++ = 0xD0000000|direction|len; | 370 | if (dpt_dma64(pHba)) { |
342 | *mptr++ = virt_to_bus(buf); | 371 | *mptr++ = (0x7C<<24)+(2<<16)+0x02; /* Enable 64 bit */ |
372 | *mptr++ = 1 << PAGE_SHIFT; | ||
373 | *mptr++ = 0xD0000000|direction|len; | ||
374 | *mptr++ = dma_low(addr); | ||
375 | *mptr++ = dma_high(addr); | ||
376 | } else { | ||
377 | *mptr++ = 0xD0000000|direction|len; | ||
378 | *mptr++ = addr; | ||
379 | } | ||
343 | 380 | ||
344 | // Send it on it's way | 381 | // Send it on it's way |
345 | rcode = adpt_i2o_post_wait(pHba, msg, reqlen<<2, 120); | 382 | rcode = adpt_i2o_post_wait(pHba, msg, reqlen<<2, 120); |
@@ -347,7 +384,7 @@ static void adpt_inquiry(adpt_hba* pHba) | |||
347 | sprintf(pHba->detail, "Adaptec I2O RAID"); | 384 | sprintf(pHba->detail, "Adaptec I2O RAID"); |
348 | printk(KERN_INFO "%s: Inquiry Error (%d)\n",pHba->name,rcode); | 385 | printk(KERN_INFO "%s: Inquiry Error (%d)\n",pHba->name,rcode); |
349 | if (rcode != -ETIME && rcode != -EINTR) | 386 | if (rcode != -ETIME && rcode != -EINTR) |
350 | kfree(buf); | 387 | dma_free_coherent(&pHba->pDev->dev, 80, buf, addr); |
351 | } else { | 388 | } else { |
352 | memset(pHba->detail, 0, sizeof(pHba->detail)); | 389 | memset(pHba->detail, 0, sizeof(pHba->detail)); |
353 | memcpy(&(pHba->detail), "Vendor: Adaptec ", 16); | 390 | memcpy(&(pHba->detail), "Vendor: Adaptec ", 16); |
@@ -356,7 +393,7 @@ static void adpt_inquiry(adpt_hba* pHba) | |||
356 | memcpy(&(pHba->detail[40]), " FW: ", 4); | 393 | memcpy(&(pHba->detail[40]), " FW: ", 4); |
357 | memcpy(&(pHba->detail[44]), (u8*) &buf[32], 4); | 394 | memcpy(&(pHba->detail[44]), (u8*) &buf[32], 4); |
358 | pHba->detail[48] = '\0'; /* precautionary */ | 395 | pHba->detail[48] = '\0'; /* precautionary */ |
359 | kfree(buf); | 396 | dma_free_coherent(&pHba->pDev->dev, 80, buf, addr); |
360 | } | 397 | } |
361 | adpt_i2o_status_get(pHba); | 398 | adpt_i2o_status_get(pHba); |
362 | return ; | 399 | return ; |
@@ -632,6 +669,91 @@ stop_output: | |||
632 | return len; | 669 | return len; |
633 | } | 670 | } |
634 | 671 | ||
672 | /* | ||
673 | * Turn a struct scsi_cmnd * into a unique 32 bit 'context'. | ||
674 | */ | ||
675 | static u32 adpt_cmd_to_context(struct scsi_cmnd *cmd) | ||
676 | { | ||
677 | return (u32)cmd->serial_number; | ||
678 | } | ||
679 | |||
680 | /* | ||
681 | * Go from a u32 'context' to a struct scsi_cmnd * . | ||
682 | * This could probably be made more efficient. | ||
683 | */ | ||
684 | static struct scsi_cmnd * | ||
685 | adpt_cmd_from_context(adpt_hba * pHba, u32 context) | ||
686 | { | ||
687 | struct scsi_cmnd * cmd; | ||
688 | struct scsi_device * d; | ||
689 | |||
690 | if (context == 0) | ||
691 | return NULL; | ||
692 | |||
693 | spin_unlock(pHba->host->host_lock); | ||
694 | shost_for_each_device(d, pHba->host) { | ||
695 | unsigned long flags; | ||
696 | spin_lock_irqsave(&d->list_lock, flags); | ||
697 | list_for_each_entry(cmd, &d->cmd_list, list) { | ||
698 | if (((u32)cmd->serial_number == context)) { | ||
699 | spin_unlock_irqrestore(&d->list_lock, flags); | ||
700 | scsi_device_put(d); | ||
701 | spin_lock(pHba->host->host_lock); | ||
702 | return cmd; | ||
703 | } | ||
704 | } | ||
705 | spin_unlock_irqrestore(&d->list_lock, flags); | ||
706 | } | ||
707 | spin_lock(pHba->host->host_lock); | ||
708 | |||
709 | return NULL; | ||
710 | } | ||
711 | |||
712 | /* | ||
713 | * Turn a pointer to ioctl reply data into an u32 'context' | ||
714 | */ | ||
715 | static u32 adpt_ioctl_to_context(adpt_hba * pHba, void *reply) | ||
716 | { | ||
717 | #if BITS_PER_LONG == 32 | ||
718 | return (u32)(unsigned long)reply; | ||
719 | #else | ||
720 | ulong flags = 0; | ||
721 | u32 nr, i; | ||
722 | |||
723 | spin_lock_irqsave(pHba->host->host_lock, flags); | ||
724 | nr = ARRAY_SIZE(pHba->ioctl_reply_context); | ||
725 | for (i = 0; i < nr; i++) { | ||
726 | if (pHba->ioctl_reply_context[i] == NULL) { | ||
727 | pHba->ioctl_reply_context[i] = reply; | ||
728 | break; | ||
729 | } | ||
730 | } | ||
731 | spin_unlock_irqrestore(pHba->host->host_lock, flags); | ||
732 | if (i >= nr) { | ||
733 | kfree (reply); | ||
734 | printk(KERN_WARNING"%s: Too many outstanding " | ||
735 | "ioctl commands\n", pHba->name); | ||
736 | return (u32)-1; | ||
737 | } | ||
738 | |||
739 | return i; | ||
740 | #endif | ||
741 | } | ||
742 | |||
743 | /* | ||
744 | * Go from an u32 'context' to a pointer to ioctl reply data. | ||
745 | */ | ||
746 | static void *adpt_ioctl_from_context(adpt_hba *pHba, u32 context) | ||
747 | { | ||
748 | #if BITS_PER_LONG == 32 | ||
749 | return (void *)(unsigned long)context; | ||
750 | #else | ||
751 | void *p = pHba->ioctl_reply_context[context]; | ||
752 | pHba->ioctl_reply_context[context] = NULL; | ||
753 | |||
754 | return p; | ||
755 | #endif | ||
756 | } | ||
635 | 757 | ||
636 | /*=========================================================================== | 758 | /*=========================================================================== |
637 | * Error Handling routines | 759 | * Error Handling routines |
@@ -660,7 +782,7 @@ static int adpt_abort(struct scsi_cmnd * cmd) | |||
660 | msg[1] = I2O_CMD_SCSI_ABORT<<24|HOST_TID<<12|dptdevice->tid; | 782 | msg[1] = I2O_CMD_SCSI_ABORT<<24|HOST_TID<<12|dptdevice->tid; |
661 | msg[2] = 0; | 783 | msg[2] = 0; |
662 | msg[3]= 0; | 784 | msg[3]= 0; |
663 | msg[4] = (u32)cmd; | 785 | msg[4] = adpt_cmd_to_context(cmd); |
664 | if (pHba->host) | 786 | if (pHba->host) |
665 | spin_lock_irq(pHba->host->host_lock); | 787 | spin_lock_irq(pHba->host->host_lock); |
666 | rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER); | 788 | rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER); |
@@ -861,27 +983,6 @@ static void adpt_i2o_sys_shutdown(void) | |||
861 | printk(KERN_INFO "Adaptec I2O controllers down.\n"); | 983 | printk(KERN_INFO "Adaptec I2O controllers down.\n"); |
862 | } | 984 | } |
863 | 985 | ||
864 | /* | ||
865 | * reboot/shutdown notification. | ||
866 | * | ||
867 | * - Quiesce each IOP in the system | ||
868 | * | ||
869 | */ | ||
870 | |||
871 | #ifdef REBOOT_NOTIFIER | ||
872 | static int adpt_reboot_event(struct notifier_block *n, ulong code, void *p) | ||
873 | { | ||
874 | |||
875 | if(code != SYS_RESTART && code != SYS_HALT && code != SYS_POWER_OFF) | ||
876 | return NOTIFY_DONE; | ||
877 | |||
878 | adpt_i2o_sys_shutdown(); | ||
879 | |||
880 | return NOTIFY_DONE; | ||
881 | } | ||
882 | #endif | ||
883 | |||
884 | |||
885 | static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) | 986 | static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) |
886 | { | 987 | { |
887 | 988 | ||
@@ -893,6 +994,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev | |||
893 | u32 hba_map1_area_size = 0; | 994 | u32 hba_map1_area_size = 0; |
894 | void __iomem *base_addr_virt = NULL; | 995 | void __iomem *base_addr_virt = NULL; |
895 | void __iomem *msg_addr_virt = NULL; | 996 | void __iomem *msg_addr_virt = NULL; |
997 | int dma64 = 0; | ||
896 | 998 | ||
897 | int raptorFlag = FALSE; | 999 | int raptorFlag = FALSE; |
898 | 1000 | ||
@@ -906,9 +1008,21 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev | |||
906 | } | 1008 | } |
907 | 1009 | ||
908 | pci_set_master(pDev); | 1010 | pci_set_master(pDev); |
909 | if (pci_set_dma_mask(pDev, DMA_32BIT_MASK)) | 1011 | |
1012 | /* | ||
1013 | * See if we should enable dma64 mode. | ||
1014 | */ | ||
1015 | if (sizeof(dma_addr_t) > 4 && | ||
1016 | pci_set_dma_mask(pDev, DMA_64BIT_MASK) == 0) { | ||
1017 | if (dma_get_required_mask(&pDev->dev) > DMA_32BIT_MASK) | ||
1018 | dma64 = 1; | ||
1019 | } | ||
1020 | if (!dma64 && pci_set_dma_mask(pDev, DMA_32BIT_MASK) != 0) | ||
910 | return -EINVAL; | 1021 | return -EINVAL; |
911 | 1022 | ||
1023 | /* adapter only supports message blocks below 4GB */ | ||
1024 | pci_set_consistent_dma_mask(pDev, DMA_32BIT_MASK); | ||
1025 | |||
912 | base_addr0_phys = pci_resource_start(pDev,0); | 1026 | base_addr0_phys = pci_resource_start(pDev,0); |
913 | hba_map0_area_size = pci_resource_len(pDev,0); | 1027 | hba_map0_area_size = pci_resource_len(pDev,0); |
914 | 1028 | ||
@@ -929,6 +1043,25 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev | |||
929 | raptorFlag = TRUE; | 1043 | raptorFlag = TRUE; |
930 | } | 1044 | } |
931 | 1045 | ||
1046 | #if BITS_PER_LONG == 64 | ||
1047 | /* | ||
1048 | * The original Adaptec 64 bit driver has this comment here: | ||
1049 | * "x86_64 machines need more optimal mappings" | ||
1050 | * | ||
1051 | * I assume some HBAs report ridiculously large mappings | ||
1052 | * and we need to limit them on platforms with IOMMUs. | ||
1053 | */ | ||
1054 | if (raptorFlag == TRUE) { | ||
1055 | if (hba_map0_area_size > 128) | ||
1056 | hba_map0_area_size = 128; | ||
1057 | if (hba_map1_area_size > 524288) | ||
1058 | hba_map1_area_size = 524288; | ||
1059 | } else { | ||
1060 | if (hba_map0_area_size > 524288) | ||
1061 | hba_map0_area_size = 524288; | ||
1062 | } | ||
1063 | #endif | ||
1064 | |||
932 | base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size); | 1065 | base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size); |
933 | if (!base_addr_virt) { | 1066 | if (!base_addr_virt) { |
934 | pci_release_regions(pDev); | 1067 | pci_release_regions(pDev); |
@@ -991,16 +1124,22 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev | |||
991 | pHba->state = DPTI_STATE_RESET; | 1124 | pHba->state = DPTI_STATE_RESET; |
992 | pHba->pDev = pDev; | 1125 | pHba->pDev = pDev; |
993 | pHba->devices = NULL; | 1126 | pHba->devices = NULL; |
1127 | pHba->dma64 = dma64; | ||
994 | 1128 | ||
995 | // Initializing the spinlocks | 1129 | // Initializing the spinlocks |
996 | spin_lock_init(&pHba->state_lock); | 1130 | spin_lock_init(&pHba->state_lock); |
997 | spin_lock_init(&adpt_post_wait_lock); | 1131 | spin_lock_init(&adpt_post_wait_lock); |
998 | 1132 | ||
999 | if(raptorFlag == 0){ | 1133 | if(raptorFlag == 0){ |
1000 | printk(KERN_INFO"Adaptec I2O RAID controller %d at %p size=%x irq=%d\n", | 1134 | printk(KERN_INFO "Adaptec I2O RAID controller" |
1001 | hba_count-1, base_addr_virt, hba_map0_area_size, pDev->irq); | 1135 | " %d at %p size=%x irq=%d%s\n", |
1136 | hba_count-1, base_addr_virt, | ||
1137 | hba_map0_area_size, pDev->irq, | ||
1138 | dma64 ? " (64-bit DMA)" : ""); | ||
1002 | } else { | 1139 | } else { |
1003 | printk(KERN_INFO"Adaptec I2O RAID controller %d irq=%d\n",hba_count-1, pDev->irq); | 1140 | printk(KERN_INFO"Adaptec I2O RAID controller %d irq=%d%s\n", |
1141 | hba_count-1, pDev->irq, | ||
1142 | dma64 ? " (64-bit DMA)" : ""); | ||
1004 | printk(KERN_INFO" BAR0 %p - size= %x\n",base_addr_virt,hba_map0_area_size); | 1143 | printk(KERN_INFO" BAR0 %p - size= %x\n",base_addr_virt,hba_map0_area_size); |
1005 | printk(KERN_INFO" BAR1 %p - size= %x\n",msg_addr_virt,hba_map1_area_size); | 1144 | printk(KERN_INFO" BAR1 %p - size= %x\n",msg_addr_virt,hba_map1_area_size); |
1006 | } | 1145 | } |
@@ -1053,10 +1192,26 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba) | |||
1053 | if(pHba->msg_addr_virt != pHba->base_addr_virt){ | 1192 | if(pHba->msg_addr_virt != pHba->base_addr_virt){ |
1054 | iounmap(pHba->msg_addr_virt); | 1193 | iounmap(pHba->msg_addr_virt); |
1055 | } | 1194 | } |
1056 | kfree(pHba->hrt); | 1195 | if(pHba->FwDebugBuffer_P) |
1057 | kfree(pHba->lct); | 1196 | iounmap(pHba->FwDebugBuffer_P); |
1058 | kfree(pHba->status_block); | 1197 | if(pHba->hrt) { |
1059 | kfree(pHba->reply_pool); | 1198 | dma_free_coherent(&pHba->pDev->dev, |
1199 | pHba->hrt->num_entries * pHba->hrt->entry_len << 2, | ||
1200 | pHba->hrt, pHba->hrt_pa); | ||
1201 | } | ||
1202 | if(pHba->lct) { | ||
1203 | dma_free_coherent(&pHba->pDev->dev, pHba->lct_size, | ||
1204 | pHba->lct, pHba->lct_pa); | ||
1205 | } | ||
1206 | if(pHba->status_block) { | ||
1207 | dma_free_coherent(&pHba->pDev->dev, sizeof(i2o_status_block), | ||
1208 | pHba->status_block, pHba->status_block_pa); | ||
1209 | } | ||
1210 | if(pHba->reply_pool) { | ||
1211 | dma_free_coherent(&pHba->pDev->dev, | ||
1212 | pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, | ||
1213 | pHba->reply_pool, pHba->reply_pool_pa); | ||
1214 | } | ||
1060 | 1215 | ||
1061 | for(d = pHba->devices; d ; d = next){ | 1216 | for(d = pHba->devices; d ; d = next){ |
1062 | next = d->next; | 1217 | next = d->next; |
@@ -1075,23 +1230,19 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba) | |||
1075 | pci_dev_put(pHba->pDev); | 1230 | pci_dev_put(pHba->pDev); |
1076 | kfree(pHba); | 1231 | kfree(pHba); |
1077 | 1232 | ||
1233 | if (adpt_sysfs_class) | ||
1234 | device_destroy(adpt_sysfs_class, | ||
1235 | MKDEV(DPTI_I2O_MAJOR, pHba->unit)); | ||
1236 | |||
1078 | if(hba_count <= 0){ | 1237 | if(hba_count <= 0){ |
1079 | unregister_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER); | 1238 | unregister_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER); |
1239 | if (adpt_sysfs_class) { | ||
1240 | class_destroy(adpt_sysfs_class); | ||
1241 | adpt_sysfs_class = NULL; | ||
1242 | } | ||
1080 | } | 1243 | } |
1081 | } | 1244 | } |
1082 | 1245 | ||
1083 | |||
1084 | static int adpt_init(void) | ||
1085 | { | ||
1086 | printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n"); | ||
1087 | #ifdef REBOOT_NOTIFIER | ||
1088 | register_reboot_notifier(&adpt_reboot_notifier); | ||
1089 | #endif | ||
1090 | |||
1091 | return 0; | ||
1092 | } | ||
1093 | |||
1094 | |||
1095 | static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun) | 1246 | static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun) |
1096 | { | 1247 | { |
1097 | struct adpt_device* d; | 1248 | struct adpt_device* d; |
@@ -1283,6 +1434,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba) | |||
1283 | { | 1434 | { |
1284 | u32 msg[8]; | 1435 | u32 msg[8]; |
1285 | u8* status; | 1436 | u8* status; |
1437 | dma_addr_t addr; | ||
1286 | u32 m = EMPTY_QUEUE ; | 1438 | u32 m = EMPTY_QUEUE ; |
1287 | ulong timeout = jiffies + (TMOUT_IOPRESET*HZ); | 1439 | ulong timeout = jiffies + (TMOUT_IOPRESET*HZ); |
1288 | 1440 | ||
@@ -1305,12 +1457,13 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba) | |||
1305 | schedule_timeout_uninterruptible(1); | 1457 | schedule_timeout_uninterruptible(1); |
1306 | } while (m == EMPTY_QUEUE); | 1458 | } while (m == EMPTY_QUEUE); |
1307 | 1459 | ||
1308 | status = kzalloc(4, GFP_KERNEL|ADDR32); | 1460 | status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); |
1309 | if(status == NULL) { | 1461 | if(status == NULL) { |
1310 | adpt_send_nop(pHba, m); | 1462 | adpt_send_nop(pHba, m); |
1311 | printk(KERN_ERR"IOP reset failed - no free memory.\n"); | 1463 | printk(KERN_ERR"IOP reset failed - no free memory.\n"); |
1312 | return -ENOMEM; | 1464 | return -ENOMEM; |
1313 | } | 1465 | } |
1466 | memset(status,0,4); | ||
1314 | 1467 | ||
1315 | msg[0]=EIGHT_WORD_MSG_SIZE|SGL_OFFSET_0; | 1468 | msg[0]=EIGHT_WORD_MSG_SIZE|SGL_OFFSET_0; |
1316 | msg[1]=I2O_CMD_ADAPTER_RESET<<24|HOST_TID<<12|ADAPTER_TID; | 1469 | msg[1]=I2O_CMD_ADAPTER_RESET<<24|HOST_TID<<12|ADAPTER_TID; |
@@ -1318,8 +1471,8 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba) | |||
1318 | msg[3]=0; | 1471 | msg[3]=0; |
1319 | msg[4]=0; | 1472 | msg[4]=0; |
1320 | msg[5]=0; | 1473 | msg[5]=0; |
1321 | msg[6]=virt_to_bus(status); | 1474 | msg[6]=dma_low(addr); |
1322 | msg[7]=0; | 1475 | msg[7]=dma_high(addr); |
1323 | 1476 | ||
1324 | memcpy_toio(pHba->msg_addr_virt+m, msg, sizeof(msg)); | 1477 | memcpy_toio(pHba->msg_addr_virt+m, msg, sizeof(msg)); |
1325 | wmb(); | 1478 | wmb(); |
@@ -1329,7 +1482,10 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba) | |||
1329 | while(*status == 0){ | 1482 | while(*status == 0){ |
1330 | if(time_after(jiffies,timeout)){ | 1483 | if(time_after(jiffies,timeout)){ |
1331 | printk(KERN_WARNING"%s: IOP Reset Timeout\n",pHba->name); | 1484 | printk(KERN_WARNING"%s: IOP Reset Timeout\n",pHba->name); |
1332 | kfree(status); | 1485 | /* We lose 4 bytes of "status" here, but we cannot |
1486 | free these because controller may awake and corrupt | ||
1487 | those bytes at any time */ | ||
1488 | /* dma_free_coherent(&pHba->pDev->dev, 4, buf, addr); */ | ||
1333 | return -ETIMEDOUT; | 1489 | return -ETIMEDOUT; |
1334 | } | 1490 | } |
1335 | rmb(); | 1491 | rmb(); |
@@ -1348,6 +1504,10 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba) | |||
1348 | } | 1504 | } |
1349 | if(time_after(jiffies,timeout)){ | 1505 | if(time_after(jiffies,timeout)){ |
1350 | printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name); | 1506 | printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name); |
1507 | /* We lose 4 bytes of "status" here, but we | ||
1508 | cannot free these because controller may | ||
1509 | awake and corrupt those bytes at any time */ | ||
1510 | /* dma_free_coherent(&pHba->pDev->dev, 4, buf, addr); */ | ||
1351 | return -ETIMEDOUT; | 1511 | return -ETIMEDOUT; |
1352 | } | 1512 | } |
1353 | schedule_timeout_uninterruptible(1); | 1513 | schedule_timeout_uninterruptible(1); |
@@ -1364,7 +1524,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba) | |||
1364 | PDEBUG("%s: Reset completed.\n", pHba->name); | 1524 | PDEBUG("%s: Reset completed.\n", pHba->name); |
1365 | } | 1525 | } |
1366 | 1526 | ||
1367 | kfree(status); | 1527 | dma_free_coherent(&pHba->pDev->dev, 4, status, addr); |
1368 | #ifdef UARTDELAY | 1528 | #ifdef UARTDELAY |
1369 | // This delay is to allow someone attached to the card through the debug UART to | 1529 | // This delay is to allow someone attached to the card through the debug UART to |
1370 | // set up the dump levels that they want before the rest of the initialization sequence | 1530 | // set up the dump levels that they want before the rest of the initialization sequence |
@@ -1636,6 +1796,7 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg) | |||
1636 | u32 i = 0; | 1796 | u32 i = 0; |
1637 | u32 rcode = 0; | 1797 | u32 rcode = 0; |
1638 | void *p = NULL; | 1798 | void *p = NULL; |
1799 | dma_addr_t addr; | ||
1639 | ulong flags = 0; | 1800 | ulong flags = 0; |
1640 | 1801 | ||
1641 | memset(&msg, 0, MAX_MESSAGE_SIZE*4); | 1802 | memset(&msg, 0, MAX_MESSAGE_SIZE*4); |
@@ -1668,10 +1829,13 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg) | |||
1668 | } | 1829 | } |
1669 | sg_offset = (msg[0]>>4)&0xf; | 1830 | sg_offset = (msg[0]>>4)&0xf; |
1670 | msg[2] = 0x40000000; // IOCTL context | 1831 | msg[2] = 0x40000000; // IOCTL context |
1671 | msg[3] = (u32)reply; | 1832 | msg[3] = adpt_ioctl_to_context(pHba, reply); |
1833 | if (msg[3] == (u32)-1) | ||
1834 | return -EBUSY; | ||
1835 | |||
1672 | memset(sg_list,0, sizeof(sg_list[0])*pHba->sg_tablesize); | 1836 | memset(sg_list,0, sizeof(sg_list[0])*pHba->sg_tablesize); |
1673 | if(sg_offset) { | 1837 | if(sg_offset) { |
1674 | // TODO 64bit fix | 1838 | // TODO add 64 bit API |
1675 | struct sg_simple_element *sg = (struct sg_simple_element*) (msg+sg_offset); | 1839 | struct sg_simple_element *sg = (struct sg_simple_element*) (msg+sg_offset); |
1676 | sg_count = (size - sg_offset*4) / sizeof(struct sg_simple_element); | 1840 | sg_count = (size - sg_offset*4) / sizeof(struct sg_simple_element); |
1677 | if (sg_count > pHba->sg_tablesize){ | 1841 | if (sg_count > pHba->sg_tablesize){ |
@@ -1690,7 +1854,7 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg) | |||
1690 | } | 1854 | } |
1691 | sg_size = sg[i].flag_count & 0xffffff; | 1855 | sg_size = sg[i].flag_count & 0xffffff; |
1692 | /* Allocate memory for the transfer */ | 1856 | /* Allocate memory for the transfer */ |
1693 | p = kmalloc(sg_size, GFP_KERNEL|ADDR32); | 1857 | p = dma_alloc_coherent(&pHba->pDev->dev, sg_size, &addr, GFP_KERNEL); |
1694 | if(!p) { | 1858 | if(!p) { |
1695 | printk(KERN_DEBUG"%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n", | 1859 | printk(KERN_DEBUG"%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n", |
1696 | pHba->name,sg_size,i,sg_count); | 1860 | pHba->name,sg_size,i,sg_count); |
@@ -1700,15 +1864,15 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg) | |||
1700 | sg_list[sg_index++] = p; // sglist indexed with input frame, not our internal frame. | 1864 | sg_list[sg_index++] = p; // sglist indexed with input frame, not our internal frame. |
1701 | /* Copy in the user's SG buffer if necessary */ | 1865 | /* Copy in the user's SG buffer if necessary */ |
1702 | if(sg[i].flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR*/) { | 1866 | if(sg[i].flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR*/) { |
1703 | // TODO 64bit fix | 1867 | // sg_simple_element API is 32 bit |
1704 | if (copy_from_user(p,(void __user *)sg[i].addr_bus, sg_size)) { | 1868 | if (copy_from_user(p,(void __user *)(ulong)sg[i].addr_bus, sg_size)) { |
1705 | printk(KERN_DEBUG"%s: Could not copy SG buf %d FROM user\n",pHba->name,i); | 1869 | printk(KERN_DEBUG"%s: Could not copy SG buf %d FROM user\n",pHba->name,i); |
1706 | rcode = -EFAULT; | 1870 | rcode = -EFAULT; |
1707 | goto cleanup; | 1871 | goto cleanup; |
1708 | } | 1872 | } |
1709 | } | 1873 | } |
1710 | //TODO 64bit fix | 1874 | /* sg_simple_element API is 32 bit, but addr < 4GB */ |
1711 | sg[i].addr_bus = (u32)virt_to_bus(p); | 1875 | sg[i].addr_bus = addr; |
1712 | } | 1876 | } |
1713 | } | 1877 | } |
1714 | 1878 | ||
@@ -1736,7 +1900,7 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg) | |||
1736 | if(sg_offset) { | 1900 | if(sg_offset) { |
1737 | /* Copy back the Scatter Gather buffers back to user space */ | 1901 | /* Copy back the Scatter Gather buffers back to user space */ |
1738 | u32 j; | 1902 | u32 j; |
1739 | // TODO 64bit fix | 1903 | // TODO add 64 bit API |
1740 | struct sg_simple_element* sg; | 1904 | struct sg_simple_element* sg; |
1741 | int sg_size; | 1905 | int sg_size; |
1742 | 1906 | ||
@@ -1756,14 +1920,14 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg) | |||
1756 | } | 1920 | } |
1757 | sg_count = (size - sg_offset*4) / sizeof(struct sg_simple_element); | 1921 | sg_count = (size - sg_offset*4) / sizeof(struct sg_simple_element); |
1758 | 1922 | ||
1759 | // TODO 64bit fix | 1923 | // TODO add 64 bit API |
1760 | sg = (struct sg_simple_element*)(msg + sg_offset); | 1924 | sg = (struct sg_simple_element*)(msg + sg_offset); |
1761 | for (j = 0; j < sg_count; j++) { | 1925 | for (j = 0; j < sg_count; j++) { |
1762 | /* Copy out the SG list to user's buffer if necessary */ | 1926 | /* Copy out the SG list to user's buffer if necessary */ |
1763 | if(! (sg[j].flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR*/)) { | 1927 | if(! (sg[j].flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR*/)) { |
1764 | sg_size = sg[j].flag_count & 0xffffff; | 1928 | sg_size = sg[j].flag_count & 0xffffff; |
1765 | // TODO 64bit fix | 1929 | // sg_simple_element API is 32 bit |
1766 | if (copy_to_user((void __user *)sg[j].addr_bus,sg_list[j], sg_size)) { | 1930 | if (copy_to_user((void __user *)(ulong)sg[j].addr_bus,sg_list[j], sg_size)) { |
1767 | printk(KERN_WARNING"%s: Could not copy %p TO user %x\n",pHba->name, sg_list[j], sg[j].addr_bus); | 1931 | printk(KERN_WARNING"%s: Could not copy %p TO user %x\n",pHba->name, sg_list[j], sg[j].addr_bus); |
1768 | rcode = -EFAULT; | 1932 | rcode = -EFAULT; |
1769 | goto cleanup; | 1933 | goto cleanup; |
@@ -1787,12 +1951,17 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg) | |||
1787 | 1951 | ||
1788 | 1952 | ||
1789 | cleanup: | 1953 | cleanup: |
1790 | if (rcode != -ETIME && rcode != -EINTR) | 1954 | if (rcode != -ETIME && rcode != -EINTR) { |
1955 | struct sg_simple_element *sg = | ||
1956 | (struct sg_simple_element*) (msg +sg_offset); | ||
1791 | kfree (reply); | 1957 | kfree (reply); |
1792 | while(sg_index) { | 1958 | while(sg_index) { |
1793 | if(sg_list[--sg_index]) { | 1959 | if(sg_list[--sg_index]) { |
1794 | if (rcode != -ETIME && rcode != -EINTR) | 1960 | dma_free_coherent(&pHba->pDev->dev, |
1795 | kfree(sg_list[sg_index]); | 1961 | sg[sg_index].flag_count & 0xffffff, |
1962 | sg_list[sg_index], | ||
1963 | sg[sg_index].addr_bus); | ||
1964 | } | ||
1796 | } | 1965 | } |
1797 | } | 1966 | } |
1798 | return rcode; | 1967 | return rcode; |
@@ -1978,6 +2147,38 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, | |||
1978 | return error; | 2147 | return error; |
1979 | } | 2148 | } |
1980 | 2149 | ||
2150 | #ifdef CONFIG_COMPAT | ||
2151 | static long compat_adpt_ioctl(struct file *file, | ||
2152 | unsigned int cmd, unsigned long arg) | ||
2153 | { | ||
2154 | struct inode *inode; | ||
2155 | long ret; | ||
2156 | |||
2157 | inode = file->f_dentry->d_inode; | ||
2158 | |||
2159 | lock_kernel(); | ||
2160 | |||
2161 | switch(cmd) { | ||
2162 | case DPT_SIGNATURE: | ||
2163 | case I2OUSRCMD: | ||
2164 | case DPT_CTRLINFO: | ||
2165 | case DPT_SYSINFO: | ||
2166 | case DPT_BLINKLED: | ||
2167 | case I2ORESETCMD: | ||
2168 | case I2ORESCANCMD: | ||
2169 | case (DPT_TARGET_BUSY & 0xFFFF): | ||
2170 | case DPT_TARGET_BUSY: | ||
2171 | ret = adpt_ioctl(inode, file, cmd, arg); | ||
2172 | break; | ||
2173 | default: | ||
2174 | ret = -ENOIOCTLCMD; | ||
2175 | } | ||
2176 | |||
2177 | unlock_kernel(); | ||
2178 | |||
2179 | return ret; | ||
2180 | } | ||
2181 | #endif | ||
1981 | 2182 | ||
1982 | static irqreturn_t adpt_isr(int irq, void *dev_id) | 2183 | static irqreturn_t adpt_isr(int irq, void *dev_id) |
1983 | { | 2184 | { |
@@ -2009,7 +2210,16 @@ static irqreturn_t adpt_isr(int irq, void *dev_id) | |||
2009 | goto out; | 2210 | goto out; |
2010 | } | 2211 | } |
2011 | } | 2212 | } |
2012 | reply = bus_to_virt(m); | 2213 | if (pHba->reply_pool_pa <= m && |
2214 | m < pHba->reply_pool_pa + | ||
2215 | (pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4)) { | ||
2216 | reply = (u8 *)pHba->reply_pool + | ||
2217 | (m - pHba->reply_pool_pa); | ||
2218 | } else { | ||
2219 | /* Ick, we should *never* be here */ | ||
2220 | printk(KERN_ERR "dpti: reply frame not from pool\n"); | ||
2221 | reply = (u8 *)bus_to_virt(m); | ||
2222 | } | ||
2013 | 2223 | ||
2014 | if (readl(reply) & MSG_FAIL) { | 2224 | if (readl(reply) & MSG_FAIL) { |
2015 | u32 old_m = readl(reply+28); | 2225 | u32 old_m = readl(reply+28); |
@@ -2029,7 +2239,7 @@ static irqreturn_t adpt_isr(int irq, void *dev_id) | |||
2029 | } | 2239 | } |
2030 | context = readl(reply+8); | 2240 | context = readl(reply+8); |
2031 | if(context & 0x40000000){ // IOCTL | 2241 | if(context & 0x40000000){ // IOCTL |
2032 | void *p = (void *)readl(reply+12); | 2242 | void *p = adpt_ioctl_from_context(pHba, readl(reply+12)); |
2033 | if( p != NULL) { | 2243 | if( p != NULL) { |
2034 | memcpy_fromio(p, reply, REPLY_FRAME_SIZE * 4); | 2244 | memcpy_fromio(p, reply, REPLY_FRAME_SIZE * 4); |
2035 | } | 2245 | } |
@@ -2043,15 +2253,17 @@ static irqreturn_t adpt_isr(int irq, void *dev_id) | |||
2043 | status = I2O_POST_WAIT_OK; | 2253 | status = I2O_POST_WAIT_OK; |
2044 | } | 2254 | } |
2045 | if(!(context & 0x40000000)) { | 2255 | if(!(context & 0x40000000)) { |
2046 | cmd = (struct scsi_cmnd*) readl(reply+12); | 2256 | cmd = adpt_cmd_from_context(pHba, |
2257 | readl(reply+12)); | ||
2047 | if(cmd != NULL) { | 2258 | if(cmd != NULL) { |
2048 | printk(KERN_WARNING"%s: Apparent SCSI cmd in Post Wait Context - cmd=%p context=%x\n", pHba->name, cmd, context); | 2259 | printk(KERN_WARNING"%s: Apparent SCSI cmd in Post Wait Context - cmd=%p context=%x\n", pHba->name, cmd, context); |
2049 | } | 2260 | } |
2050 | } | 2261 | } |
2051 | adpt_i2o_post_wait_complete(context, status); | 2262 | adpt_i2o_post_wait_complete(context, status); |
2052 | } else { // SCSI message | 2263 | } else { // SCSI message |
2053 | cmd = (struct scsi_cmnd*) readl(reply+12); | 2264 | cmd = adpt_cmd_from_context (pHba, readl(reply+12)); |
2054 | if(cmd != NULL){ | 2265 | if(cmd != NULL){ |
2266 | scsi_dma_unmap(cmd); | ||
2055 | if(cmd->serial_number != 0) { // If not timedout | 2267 | if(cmd->serial_number != 0) { // If not timedout |
2056 | adpt_i2o_to_scsi(reply, cmd); | 2268 | adpt_i2o_to_scsi(reply, cmd); |
2057 | } | 2269 | } |
@@ -2072,6 +2284,7 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d | |||
2072 | int i; | 2284 | int i; |
2073 | u32 msg[MAX_MESSAGE_SIZE]; | 2285 | u32 msg[MAX_MESSAGE_SIZE]; |
2074 | u32* mptr; | 2286 | u32* mptr; |
2287 | u32* lptr; | ||
2075 | u32 *lenptr; | 2288 | u32 *lenptr; |
2076 | int direction; | 2289 | int direction; |
2077 | int scsidir; | 2290 | int scsidir; |
@@ -2079,6 +2292,7 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d | |||
2079 | u32 len; | 2292 | u32 len; |
2080 | u32 reqlen; | 2293 | u32 reqlen; |
2081 | s32 rcode; | 2294 | s32 rcode; |
2295 | dma_addr_t addr; | ||
2082 | 2296 | ||
2083 | memset(msg, 0 , sizeof(msg)); | 2297 | memset(msg, 0 , sizeof(msg)); |
2084 | len = scsi_bufflen(cmd); | 2298 | len = scsi_bufflen(cmd); |
@@ -2118,7 +2332,7 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d | |||
2118 | // I2O_CMD_SCSI_EXEC | 2332 | // I2O_CMD_SCSI_EXEC |
2119 | msg[1] = ((0xff<<24)|(HOST_TID<<12)|d->tid); | 2333 | msg[1] = ((0xff<<24)|(HOST_TID<<12)|d->tid); |
2120 | msg[2] = 0; | 2334 | msg[2] = 0; |
2121 | msg[3] = (u32)cmd; /* We want the SCSI control block back */ | 2335 | msg[3] = adpt_cmd_to_context(cmd); /* Want SCSI control block back */ |
2122 | // Our cards use the transaction context as the tag for queueing | 2336 | // Our cards use the transaction context as the tag for queueing |
2123 | // Adaptec/DPT Private stuff | 2337 | // Adaptec/DPT Private stuff |
2124 | msg[4] = I2O_CMD_SCSI_EXEC|(DPT_ORGANIZATION_ID<<16); | 2338 | msg[4] = I2O_CMD_SCSI_EXEC|(DPT_ORGANIZATION_ID<<16); |
@@ -2136,7 +2350,13 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d | |||
2136 | memcpy(mptr, cmd->cmnd, cmd->cmd_len); | 2350 | memcpy(mptr, cmd->cmnd, cmd->cmd_len); |
2137 | mptr+=4; | 2351 | mptr+=4; |
2138 | lenptr=mptr++; /* Remember me - fill in when we know */ | 2352 | lenptr=mptr++; /* Remember me - fill in when we know */ |
2139 | reqlen = 14; // SINGLE SGE | 2353 | if (dpt_dma64(pHba)) { |
2354 | reqlen = 16; // SINGLE SGE | ||
2355 | *mptr++ = (0x7C<<24)+(2<<16)+0x02; /* Enable 64 bit */ | ||
2356 | *mptr++ = 1 << PAGE_SHIFT; | ||
2357 | } else { | ||
2358 | reqlen = 14; // SINGLE SGE | ||
2359 | } | ||
2140 | /* Now fill in the SGList and command */ | 2360 | /* Now fill in the SGList and command */ |
2141 | 2361 | ||
2142 | nseg = scsi_dma_map(cmd); | 2362 | nseg = scsi_dma_map(cmd); |
@@ -2146,12 +2366,16 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d | |||
2146 | 2366 | ||
2147 | len = 0; | 2367 | len = 0; |
2148 | scsi_for_each_sg(cmd, sg, nseg, i) { | 2368 | scsi_for_each_sg(cmd, sg, nseg, i) { |
2369 | lptr = mptr; | ||
2149 | *mptr++ = direction|0x10000000|sg_dma_len(sg); | 2370 | *mptr++ = direction|0x10000000|sg_dma_len(sg); |
2150 | len+=sg_dma_len(sg); | 2371 | len+=sg_dma_len(sg); |
2151 | *mptr++ = sg_dma_address(sg); | 2372 | addr = sg_dma_address(sg); |
2373 | *mptr++ = dma_low(addr); | ||
2374 | if (dpt_dma64(pHba)) | ||
2375 | *mptr++ = dma_high(addr); | ||
2152 | /* Make this an end of list */ | 2376 | /* Make this an end of list */ |
2153 | if (i == nseg - 1) | 2377 | if (i == nseg - 1) |
2154 | mptr[-2] = direction|0xD0000000|sg_dma_len(sg); | 2378 | *lptr = direction|0xD0000000|sg_dma_len(sg); |
2155 | } | 2379 | } |
2156 | reqlen = mptr - msg; | 2380 | reqlen = mptr - msg; |
2157 | *lenptr = len; | 2381 | *lenptr = len; |
@@ -2177,13 +2401,13 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d | |||
2177 | } | 2401 | } |
2178 | 2402 | ||
2179 | 2403 | ||
2180 | static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht) | 2404 | static s32 adpt_scsi_host_alloc(adpt_hba* pHba, struct scsi_host_template *sht) |
2181 | { | 2405 | { |
2182 | struct Scsi_Host *host = NULL; | 2406 | struct Scsi_Host *host; |
2183 | 2407 | ||
2184 | host = scsi_register(sht, sizeof(adpt_hba*)); | 2408 | host = scsi_host_alloc(sht, sizeof(adpt_hba*)); |
2185 | if (host == NULL) { | 2409 | if (host == NULL) { |
2186 | printk ("%s: scsi_register returned NULL\n",pHba->name); | 2410 | printk("%s: scsi_host_alloc returned NULL\n", pHba->name); |
2187 | return -1; | 2411 | return -1; |
2188 | } | 2412 | } |
2189 | host->hostdata[0] = (unsigned long)pHba; | 2413 | host->hostdata[0] = (unsigned long)pHba; |
@@ -2200,7 +2424,7 @@ static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht) | |||
2200 | host->max_lun = 256; | 2424 | host->max_lun = 256; |
2201 | host->max_channel = pHba->top_scsi_channel + 1; | 2425 | host->max_channel = pHba->top_scsi_channel + 1; |
2202 | host->cmd_per_lun = 1; | 2426 | host->cmd_per_lun = 1; |
2203 | host->unique_id = (uint) pHba; | 2427 | host->unique_id = (u32)sys_tbl_pa + pHba->unit; |
2204 | host->sg_tablesize = pHba->sg_tablesize; | 2428 | host->sg_tablesize = pHba->sg_tablesize; |
2205 | host->can_queue = pHba->post_fifo_size; | 2429 | host->can_queue = pHba->post_fifo_size; |
2206 | 2430 | ||
@@ -2640,11 +2864,10 @@ static s32 adpt_send_nop(adpt_hba*pHba,u32 m) | |||
2640 | static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) | 2864 | static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) |
2641 | { | 2865 | { |
2642 | u8 *status; | 2866 | u8 *status; |
2867 | dma_addr_t addr; | ||
2643 | u32 __iomem *msg = NULL; | 2868 | u32 __iomem *msg = NULL; |
2644 | int i; | 2869 | int i; |
2645 | ulong timeout = jiffies + TMOUT_INITOUTBOUND*HZ; | 2870 | ulong timeout = jiffies + TMOUT_INITOUTBOUND*HZ; |
2646 | u32* ptr; | ||
2647 | u32 outbound_frame; // This had to be a 32 bit address | ||
2648 | u32 m; | 2871 | u32 m; |
2649 | 2872 | ||
2650 | do { | 2873 | do { |
@@ -2663,13 +2886,14 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) | |||
2663 | 2886 | ||
2664 | msg=(u32 __iomem *)(pHba->msg_addr_virt+m); | 2887 | msg=(u32 __iomem *)(pHba->msg_addr_virt+m); |
2665 | 2888 | ||
2666 | status = kzalloc(4, GFP_KERNEL|ADDR32); | 2889 | status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL); |
2667 | if (!status) { | 2890 | if (!status) { |
2668 | adpt_send_nop(pHba, m); | 2891 | adpt_send_nop(pHba, m); |
2669 | printk(KERN_WARNING"%s: IOP reset failed - no free memory.\n", | 2892 | printk(KERN_WARNING"%s: IOP reset failed - no free memory.\n", |
2670 | pHba->name); | 2893 | pHba->name); |
2671 | return -ENOMEM; | 2894 | return -ENOMEM; |
2672 | } | 2895 | } |
2896 | memset(status, 0, 4); | ||
2673 | 2897 | ||
2674 | writel(EIGHT_WORD_MSG_SIZE| SGL_OFFSET_6, &msg[0]); | 2898 | writel(EIGHT_WORD_MSG_SIZE| SGL_OFFSET_6, &msg[0]); |
2675 | writel(I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID, &msg[1]); | 2899 | writel(I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID, &msg[1]); |
@@ -2678,7 +2902,7 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) | |||
2678 | writel(4096, &msg[4]); /* Host page frame size */ | 2902 | writel(4096, &msg[4]); /* Host page frame size */ |
2679 | writel((REPLY_FRAME_SIZE)<<16|0x80, &msg[5]); /* Outbound msg frame size and Initcode */ | 2903 | writel((REPLY_FRAME_SIZE)<<16|0x80, &msg[5]); /* Outbound msg frame size and Initcode */ |
2680 | writel(0xD0000004, &msg[6]); /* Simple SG LE, EOB */ | 2904 | writel(0xD0000004, &msg[6]); /* Simple SG LE, EOB */ |
2681 | writel(virt_to_bus(status), &msg[7]); | 2905 | writel((u32)addr, &msg[7]); |
2682 | 2906 | ||
2683 | writel(m, pHba->post_port); | 2907 | writel(m, pHba->post_port); |
2684 | wmb(); | 2908 | wmb(); |
@@ -2693,6 +2917,10 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) | |||
2693 | rmb(); | 2917 | rmb(); |
2694 | if(time_after(jiffies,timeout)){ | 2918 | if(time_after(jiffies,timeout)){ |
2695 | printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name); | 2919 | printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name); |
2920 | /* We lose 4 bytes of "status" here, but we | ||
2921 | cannot free these because controller may | ||
2922 | awake and corrupt those bytes at any time */ | ||
2923 | /* dma_free_coherent(&pHba->pDev->dev, 4, status, addr); */ | ||
2696 | return -ETIMEDOUT; | 2924 | return -ETIMEDOUT; |
2697 | } | 2925 | } |
2698 | schedule_timeout_uninterruptible(1); | 2926 | schedule_timeout_uninterruptible(1); |
@@ -2701,25 +2929,30 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba) | |||
2701 | // If the command was successful, fill the fifo with our reply | 2929 | // If the command was successful, fill the fifo with our reply |
2702 | // message packets | 2930 | // message packets |
2703 | if(*status != 0x04 /*I2O_EXEC_OUTBOUND_INIT_COMPLETE*/) { | 2931 | if(*status != 0x04 /*I2O_EXEC_OUTBOUND_INIT_COMPLETE*/) { |
2704 | kfree(status); | 2932 | dma_free_coherent(&pHba->pDev->dev, 4, status, addr); |
2705 | return -2; | 2933 | return -2; |
2706 | } | 2934 | } |
2707 | kfree(status); | 2935 | dma_free_coherent(&pHba->pDev->dev, 4, status, addr); |
2708 | 2936 | ||
2709 | kfree(pHba->reply_pool); | 2937 | if(pHba->reply_pool != NULL) { |
2938 | dma_free_coherent(&pHba->pDev->dev, | ||
2939 | pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, | ||
2940 | pHba->reply_pool, pHba->reply_pool_pa); | ||
2941 | } | ||
2710 | 2942 | ||
2711 | pHba->reply_pool = kzalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); | 2943 | pHba->reply_pool = dma_alloc_coherent(&pHba->pDev->dev, |
2944 | pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, | ||
2945 | &pHba->reply_pool_pa, GFP_KERNEL); | ||
2712 | if (!pHba->reply_pool) { | 2946 | if (!pHba->reply_pool) { |
2713 | printk(KERN_ERR "%s: Could not allocate reply pool\n", pHba->name); | 2947 | printk(KERN_ERR "%s: Could not allocate reply pool\n", pHba->name); |
2714 | return -ENOMEM; | 2948 | return -ENOMEM; |
2715 | } | 2949 | } |
2950 | memset(pHba->reply_pool, 0 , pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4); | ||
2716 | 2951 | ||
2717 | ptr = pHba->reply_pool; | ||
2718 | for(i = 0; i < pHba->reply_fifo_size; i++) { | 2952 | for(i = 0; i < pHba->reply_fifo_size; i++) { |
2719 | outbound_frame = (u32)virt_to_bus(ptr); | 2953 | writel(pHba->reply_pool_pa + (i * REPLY_FRAME_SIZE * 4), |
2720 | writel(outbound_frame, pHba->reply_port); | 2954 | pHba->reply_port); |
2721 | wmb(); | 2955 | wmb(); |
2722 | ptr += REPLY_FRAME_SIZE; | ||
2723 | } | 2956 | } |
2724 | adpt_i2o_status_get(pHba); | 2957 | adpt_i2o_status_get(pHba); |
2725 | return 0; | 2958 | return 0; |
@@ -2743,11 +2976,11 @@ static s32 adpt_i2o_status_get(adpt_hba* pHba) | |||
2743 | u32 m; | 2976 | u32 m; |
2744 | u32 __iomem *msg; | 2977 | u32 __iomem *msg; |
2745 | u8 *status_block=NULL; | 2978 | u8 *status_block=NULL; |
2746 | ulong status_block_bus; | ||
2747 | 2979 | ||
2748 | if(pHba->status_block == NULL) { | 2980 | if(pHba->status_block == NULL) { |
2749 | pHba->status_block = (i2o_status_block*) | 2981 | pHba->status_block = dma_alloc_coherent(&pHba->pDev->dev, |
2750 | kmalloc(sizeof(i2o_status_block),GFP_KERNEL|ADDR32); | 2982 | sizeof(i2o_status_block), |
2983 | &pHba->status_block_pa, GFP_KERNEL); | ||
2751 | if(pHba->status_block == NULL) { | 2984 | if(pHba->status_block == NULL) { |
2752 | printk(KERN_ERR | 2985 | printk(KERN_ERR |
2753 | "dpti%d: Get Status Block failed; Out of memory. \n", | 2986 | "dpti%d: Get Status Block failed; Out of memory. \n", |
@@ -2757,7 +2990,6 @@ static s32 adpt_i2o_status_get(adpt_hba* pHba) | |||
2757 | } | 2990 | } |
2758 | memset(pHba->status_block, 0, sizeof(i2o_status_block)); | 2991 | memset(pHba->status_block, 0, sizeof(i2o_status_block)); |
2759 | status_block = (u8*)(pHba->status_block); | 2992 | status_block = (u8*)(pHba->status_block); |
2760 | status_block_bus = virt_to_bus(pHba->status_block); | ||
2761 | timeout = jiffies+TMOUT_GETSTATUS*HZ; | 2993 | timeout = jiffies+TMOUT_GETSTATUS*HZ; |
2762 | do { | 2994 | do { |
2763 | rmb(); | 2995 | rmb(); |
@@ -2782,8 +3014,8 @@ static s32 adpt_i2o_status_get(adpt_hba* pHba) | |||
2782 | writel(0, &msg[3]); | 3014 | writel(0, &msg[3]); |
2783 | writel(0, &msg[4]); | 3015 | writel(0, &msg[4]); |
2784 | writel(0, &msg[5]); | 3016 | writel(0, &msg[5]); |
2785 | writel(((u32)status_block_bus)&0xffffffff, &msg[6]); | 3017 | writel( dma_low(pHba->status_block_pa), &msg[6]); |
2786 | writel(0, &msg[7]); | 3018 | writel( dma_high(pHba->status_block_pa), &msg[7]); |
2787 | writel(sizeof(i2o_status_block), &msg[8]); // 88 bytes | 3019 | writel(sizeof(i2o_status_block), &msg[8]); // 88 bytes |
2788 | 3020 | ||
2789 | //post message | 3021 | //post message |
@@ -2812,7 +3044,17 @@ static s32 adpt_i2o_status_get(adpt_hba* pHba) | |||
2812 | } | 3044 | } |
2813 | 3045 | ||
2814 | // Calculate the Scatter Gather list size | 3046 | // Calculate the Scatter Gather list size |
2815 | pHba->sg_tablesize = (pHba->status_block->inbound_frame_size * 4 -40)/ sizeof(struct sg_simple_element); | 3047 | if (dpt_dma64(pHba)) { |
3048 | pHba->sg_tablesize | ||
3049 | = ((pHba->status_block->inbound_frame_size * 4 | ||
3050 | - 14 * sizeof(u32)) | ||
3051 | / (sizeof(struct sg_simple_element) + sizeof(u32))); | ||
3052 | } else { | ||
3053 | pHba->sg_tablesize | ||
3054 | = ((pHba->status_block->inbound_frame_size * 4 | ||
3055 | - 12 * sizeof(u32)) | ||
3056 | / sizeof(struct sg_simple_element)); | ||
3057 | } | ||
2816 | if (pHba->sg_tablesize > SG_LIST_ELEMENTS) { | 3058 | if (pHba->sg_tablesize > SG_LIST_ELEMENTS) { |
2817 | pHba->sg_tablesize = SG_LIST_ELEMENTS; | 3059 | pHba->sg_tablesize = SG_LIST_ELEMENTS; |
2818 | } | 3060 | } |
@@ -2863,7 +3105,9 @@ static int adpt_i2o_lct_get(adpt_hba* pHba) | |||
2863 | } | 3105 | } |
2864 | do { | 3106 | do { |
2865 | if (pHba->lct == NULL) { | 3107 | if (pHba->lct == NULL) { |
2866 | pHba->lct = kmalloc(pHba->lct_size, GFP_KERNEL|ADDR32); | 3108 | pHba->lct = dma_alloc_coherent(&pHba->pDev->dev, |
3109 | pHba->lct_size, &pHba->lct_pa, | ||
3110 | GFP_KERNEL); | ||
2867 | if(pHba->lct == NULL) { | 3111 | if(pHba->lct == NULL) { |
2868 | printk(KERN_CRIT "%s: Lct Get failed. Out of memory.\n", | 3112 | printk(KERN_CRIT "%s: Lct Get failed. Out of memory.\n", |
2869 | pHba->name); | 3113 | pHba->name); |
@@ -2879,7 +3123,7 @@ static int adpt_i2o_lct_get(adpt_hba* pHba) | |||
2879 | msg[4] = 0xFFFFFFFF; /* All devices */ | 3123 | msg[4] = 0xFFFFFFFF; /* All devices */ |
2880 | msg[5] = 0x00000000; /* Report now */ | 3124 | msg[5] = 0x00000000; /* Report now */ |
2881 | msg[6] = 0xD0000000|pHba->lct_size; | 3125 | msg[6] = 0xD0000000|pHba->lct_size; |
2882 | msg[7] = virt_to_bus(pHba->lct); | 3126 | msg[7] = (u32)pHba->lct_pa; |
2883 | 3127 | ||
2884 | if ((ret=adpt_i2o_post_wait(pHba, msg, sizeof(msg), 360))) { | 3128 | if ((ret=adpt_i2o_post_wait(pHba, msg, sizeof(msg), 360))) { |
2885 | printk(KERN_ERR "%s: LCT Get failed (status=%#10x.\n", | 3129 | printk(KERN_ERR "%s: LCT Get failed (status=%#10x.\n", |
@@ -2890,7 +3134,8 @@ static int adpt_i2o_lct_get(adpt_hba* pHba) | |||
2890 | 3134 | ||
2891 | if ((pHba->lct->table_size << 2) > pHba->lct_size) { | 3135 | if ((pHba->lct->table_size << 2) > pHba->lct_size) { |
2892 | pHba->lct_size = pHba->lct->table_size << 2; | 3136 | pHba->lct_size = pHba->lct->table_size << 2; |
2893 | kfree(pHba->lct); | 3137 | dma_free_coherent(&pHba->pDev->dev, pHba->lct_size, |
3138 | pHba->lct, pHba->lct_pa); | ||
2894 | pHba->lct = NULL; | 3139 | pHba->lct = NULL; |
2895 | } | 3140 | } |
2896 | } while (pHba->lct == NULL); | 3141 | } while (pHba->lct == NULL); |
@@ -2901,13 +3146,19 @@ static int adpt_i2o_lct_get(adpt_hba* pHba) | |||
2901 | // I2O_DPT_EXEC_IOP_BUFFERS_GROUP_NO; | 3146 | // I2O_DPT_EXEC_IOP_BUFFERS_GROUP_NO; |
2902 | if(adpt_i2o_query_scalar(pHba, 0 , 0x8000, -1, buf, sizeof(buf))>=0) { | 3147 | if(adpt_i2o_query_scalar(pHba, 0 , 0x8000, -1, buf, sizeof(buf))>=0) { |
2903 | pHba->FwDebugBufferSize = buf[1]; | 3148 | pHba->FwDebugBufferSize = buf[1]; |
2904 | pHba->FwDebugBuffer_P = pHba->base_addr_virt + buf[0]; | 3149 | pHba->FwDebugBuffer_P = ioremap(pHba->base_addr_phys + buf[0], |
2905 | pHba->FwDebugFlags_P = pHba->FwDebugBuffer_P + FW_DEBUG_FLAGS_OFFSET; | 3150 | pHba->FwDebugBufferSize); |
2906 | pHba->FwDebugBLEDvalue_P = pHba->FwDebugBuffer_P + FW_DEBUG_BLED_OFFSET; | 3151 | if (pHba->FwDebugBuffer_P) { |
2907 | pHba->FwDebugBLEDflag_P = pHba->FwDebugBLEDvalue_P + 1; | 3152 | pHba->FwDebugFlags_P = pHba->FwDebugBuffer_P + |
2908 | pHba->FwDebugStrLength_P = pHba->FwDebugBuffer_P + FW_DEBUG_STR_LENGTH_OFFSET; | 3153 | FW_DEBUG_FLAGS_OFFSET; |
2909 | pHba->FwDebugBuffer_P += buf[2]; | 3154 | pHba->FwDebugBLEDvalue_P = pHba->FwDebugBuffer_P + |
2910 | pHba->FwDebugFlags = 0; | 3155 | FW_DEBUG_BLED_OFFSET; |
3156 | pHba->FwDebugBLEDflag_P = pHba->FwDebugBLEDvalue_P + 1; | ||
3157 | pHba->FwDebugStrLength_P = pHba->FwDebugBuffer_P + | ||
3158 | FW_DEBUG_STR_LENGTH_OFFSET; | ||
3159 | pHba->FwDebugBuffer_P += buf[2]; | ||
3160 | pHba->FwDebugFlags = 0; | ||
3161 | } | ||
2911 | } | 3162 | } |
2912 | 3163 | ||
2913 | return 0; | 3164 | return 0; |
@@ -2915,25 +3166,30 @@ static int adpt_i2o_lct_get(adpt_hba* pHba) | |||
2915 | 3166 | ||
2916 | static int adpt_i2o_build_sys_table(void) | 3167 | static int adpt_i2o_build_sys_table(void) |
2917 | { | 3168 | { |
2918 | adpt_hba* pHba = NULL; | 3169 | adpt_hba* pHba = hba_chain; |
2919 | int count = 0; | 3170 | int count = 0; |
2920 | 3171 | ||
3172 | if (sys_tbl) | ||
3173 | dma_free_coherent(&pHba->pDev->dev, sys_tbl_len, | ||
3174 | sys_tbl, sys_tbl_pa); | ||
3175 | |||
2921 | sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs | 3176 | sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs |
2922 | (hba_count) * sizeof(struct i2o_sys_tbl_entry); | 3177 | (hba_count) * sizeof(struct i2o_sys_tbl_entry); |
2923 | 3178 | ||
2924 | kfree(sys_tbl); | 3179 | sys_tbl = dma_alloc_coherent(&pHba->pDev->dev, |
2925 | 3180 | sys_tbl_len, &sys_tbl_pa, GFP_KERNEL); | |
2926 | sys_tbl = kzalloc(sys_tbl_len, GFP_KERNEL|ADDR32); | ||
2927 | if (!sys_tbl) { | 3181 | if (!sys_tbl) { |
2928 | printk(KERN_WARNING "SysTab Set failed. Out of memory.\n"); | 3182 | printk(KERN_WARNING "SysTab Set failed. Out of memory.\n"); |
2929 | return -ENOMEM; | 3183 | return -ENOMEM; |
2930 | } | 3184 | } |
3185 | memset(sys_tbl, 0, sys_tbl_len); | ||
2931 | 3186 | ||
2932 | sys_tbl->num_entries = hba_count; | 3187 | sys_tbl->num_entries = hba_count; |
2933 | sys_tbl->version = I2OVERSION; | 3188 | sys_tbl->version = I2OVERSION; |
2934 | sys_tbl->change_ind = sys_tbl_ind++; | 3189 | sys_tbl->change_ind = sys_tbl_ind++; |
2935 | 3190 | ||
2936 | for(pHba = hba_chain; pHba; pHba = pHba->next) { | 3191 | for(pHba = hba_chain; pHba; pHba = pHba->next) { |
3192 | u64 addr; | ||
2937 | // Get updated Status Block so we have the latest information | 3193 | // Get updated Status Block so we have the latest information |
2938 | if (adpt_i2o_status_get(pHba)) { | 3194 | if (adpt_i2o_status_get(pHba)) { |
2939 | sys_tbl->num_entries--; | 3195 | sys_tbl->num_entries--; |
@@ -2949,8 +3205,9 @@ static int adpt_i2o_build_sys_table(void) | |||
2949 | sys_tbl->iops[count].frame_size = pHba->status_block->inbound_frame_size; | 3205 | sys_tbl->iops[count].frame_size = pHba->status_block->inbound_frame_size; |
2950 | sys_tbl->iops[count].last_changed = sys_tbl_ind - 1; // ?? | 3206 | sys_tbl->iops[count].last_changed = sys_tbl_ind - 1; // ?? |
2951 | sys_tbl->iops[count].iop_capabilities = pHba->status_block->iop_capabilities; | 3207 | sys_tbl->iops[count].iop_capabilities = pHba->status_block->iop_capabilities; |
2952 | sys_tbl->iops[count].inbound_low = (u32)virt_to_bus(pHba->post_port); | 3208 | addr = pHba->base_addr_phys + 0x40; |
2953 | sys_tbl->iops[count].inbound_high = (u32)((u64)virt_to_bus(pHba->post_port)>>32); | 3209 | sys_tbl->iops[count].inbound_low = dma_low(addr); |
3210 | sys_tbl->iops[count].inbound_high = dma_high(addr); | ||
2954 | 3211 | ||
2955 | count++; | 3212 | count++; |
2956 | } | 3213 | } |
@@ -3086,7 +3343,8 @@ static s32 adpt_i2o_hrt_get(adpt_hba* pHba) | |||
3086 | 3343 | ||
3087 | do { | 3344 | do { |
3088 | if (pHba->hrt == NULL) { | 3345 | if (pHba->hrt == NULL) { |
3089 | pHba->hrt=kmalloc(size, GFP_KERNEL|ADDR32); | 3346 | pHba->hrt = dma_alloc_coherent(&pHba->pDev->dev, |
3347 | size, &pHba->hrt_pa, GFP_KERNEL); | ||
3090 | if (pHba->hrt == NULL) { | 3348 | if (pHba->hrt == NULL) { |
3091 | printk(KERN_CRIT "%s: Hrt Get failed; Out of memory.\n", pHba->name); | 3349 | printk(KERN_CRIT "%s: Hrt Get failed; Out of memory.\n", pHba->name); |
3092 | return -ENOMEM; | 3350 | return -ENOMEM; |
@@ -3098,7 +3356,7 @@ static s32 adpt_i2o_hrt_get(adpt_hba* pHba) | |||
3098 | msg[2]= 0; | 3356 | msg[2]= 0; |
3099 | msg[3]= 0; | 3357 | msg[3]= 0; |
3100 | msg[4]= (0xD0000000 | size); /* Simple transaction */ | 3358 | msg[4]= (0xD0000000 | size); /* Simple transaction */ |
3101 | msg[5]= virt_to_bus(pHba->hrt); /* Dump it here */ | 3359 | msg[5]= (u32)pHba->hrt_pa; /* Dump it here */ |
3102 | 3360 | ||
3103 | if ((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg),20))) { | 3361 | if ((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg),20))) { |
3104 | printk(KERN_ERR "%s: Unable to get HRT (status=%#10x)\n", pHba->name, ret); | 3362 | printk(KERN_ERR "%s: Unable to get HRT (status=%#10x)\n", pHba->name, ret); |
@@ -3106,8 +3364,10 @@ static s32 adpt_i2o_hrt_get(adpt_hba* pHba) | |||
3106 | } | 3364 | } |
3107 | 3365 | ||
3108 | if (pHba->hrt->num_entries * pHba->hrt->entry_len << 2 > size) { | 3366 | if (pHba->hrt->num_entries * pHba->hrt->entry_len << 2 > size) { |
3109 | size = pHba->hrt->num_entries * pHba->hrt->entry_len << 2; | 3367 | int newsize = pHba->hrt->num_entries * pHba->hrt->entry_len << 2; |
3110 | kfree(pHba->hrt); | 3368 | dma_free_coherent(&pHba->pDev->dev, size, |
3369 | pHba->hrt, pHba->hrt_pa); | ||
3370 | size = newsize; | ||
3111 | pHba->hrt = NULL; | 3371 | pHba->hrt = NULL; |
3112 | } | 3372 | } |
3113 | } while(pHba->hrt == NULL); | 3373 | } while(pHba->hrt == NULL); |
@@ -3121,33 +3381,54 @@ static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid, | |||
3121 | int group, int field, void *buf, int buflen) | 3381 | int group, int field, void *buf, int buflen) |
3122 | { | 3382 | { |
3123 | u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field }; | 3383 | u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field }; |
3124 | u8 *resblk; | 3384 | u8 *opblk_va; |
3385 | dma_addr_t opblk_pa; | ||
3386 | u8 *resblk_va; | ||
3387 | dma_addr_t resblk_pa; | ||
3125 | 3388 | ||
3126 | int size; | 3389 | int size; |
3127 | 3390 | ||
3128 | /* 8 bytes for header */ | 3391 | /* 8 bytes for header */ |
3129 | resblk = kmalloc(sizeof(u8) * (8+buflen), GFP_KERNEL|ADDR32); | 3392 | resblk_va = dma_alloc_coherent(&pHba->pDev->dev, |
3130 | if (resblk == NULL) { | 3393 | sizeof(u8) * (8 + buflen), &resblk_pa, GFP_KERNEL); |
3394 | if (resblk_va == NULL) { | ||
3131 | printk(KERN_CRIT "%s: query scalar failed; Out of memory.\n", pHba->name); | 3395 | printk(KERN_CRIT "%s: query scalar failed; Out of memory.\n", pHba->name); |
3132 | return -ENOMEM; | 3396 | return -ENOMEM; |
3133 | } | 3397 | } |
3134 | 3398 | ||
3399 | opblk_va = dma_alloc_coherent(&pHba->pDev->dev, | ||
3400 | sizeof(opblk), &opblk_pa, GFP_KERNEL); | ||
3401 | if (opblk_va == NULL) { | ||
3402 | dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), | ||
3403 | resblk_va, resblk_pa); | ||
3404 | printk(KERN_CRIT "%s: query operatio failed; Out of memory.\n", | ||
3405 | pHba->name); | ||
3406 | return -ENOMEM; | ||
3407 | } | ||
3135 | if (field == -1) /* whole group */ | 3408 | if (field == -1) /* whole group */ |
3136 | opblk[4] = -1; | 3409 | opblk[4] = -1; |
3137 | 3410 | ||
3411 | memcpy(opblk_va, opblk, sizeof(opblk)); | ||
3138 | size = adpt_i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET, pHba, tid, | 3412 | size = adpt_i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET, pHba, tid, |
3139 | opblk, sizeof(opblk), resblk, sizeof(u8)*(8+buflen)); | 3413 | opblk_va, opblk_pa, sizeof(opblk), |
3414 | resblk_va, resblk_pa, sizeof(u8)*(8+buflen)); | ||
3415 | dma_free_coherent(&pHba->pDev->dev, sizeof(opblk), opblk_va, opblk_pa); | ||
3140 | if (size == -ETIME) { | 3416 | if (size == -ETIME) { |
3417 | dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), | ||
3418 | resblk_va, resblk_pa); | ||
3141 | printk(KERN_WARNING "%s: issue params failed; Timed out.\n", pHba->name); | 3419 | printk(KERN_WARNING "%s: issue params failed; Timed out.\n", pHba->name); |
3142 | return -ETIME; | 3420 | return -ETIME; |
3143 | } else if (size == -EINTR) { | 3421 | } else if (size == -EINTR) { |
3422 | dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), | ||
3423 | resblk_va, resblk_pa); | ||
3144 | printk(KERN_WARNING "%s: issue params failed; Interrupted.\n", pHba->name); | 3424 | printk(KERN_WARNING "%s: issue params failed; Interrupted.\n", pHba->name); |
3145 | return -EINTR; | 3425 | return -EINTR; |
3146 | } | 3426 | } |
3147 | 3427 | ||
3148 | memcpy(buf, resblk+8, buflen); /* cut off header */ | 3428 | memcpy(buf, resblk_va+8, buflen); /* cut off header */ |
3149 | 3429 | ||
3150 | kfree(resblk); | 3430 | dma_free_coherent(&pHba->pDev->dev, sizeof(u8) * (8+buflen), |
3431 | resblk_va, resblk_pa); | ||
3151 | if (size < 0) | 3432 | if (size < 0) |
3152 | return size; | 3433 | return size; |
3153 | 3434 | ||
@@ -3164,10 +3445,11 @@ static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid, | |||
3164 | * ResultCount, ErrorInfoSize, BlockStatus and BlockSize. | 3445 | * ResultCount, ErrorInfoSize, BlockStatus and BlockSize. |
3165 | */ | 3446 | */ |
3166 | static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid, | 3447 | static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid, |
3167 | void *opblk, int oplen, void *resblk, int reslen) | 3448 | void *opblk_va, dma_addr_t opblk_pa, int oplen, |
3449 | void *resblk_va, dma_addr_t resblk_pa, int reslen) | ||
3168 | { | 3450 | { |
3169 | u32 msg[9]; | 3451 | u32 msg[9]; |
3170 | u32 *res = (u32 *)resblk; | 3452 | u32 *res = (u32 *)resblk_va; |
3171 | int wait_status; | 3453 | int wait_status; |
3172 | 3454 | ||
3173 | msg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_5; | 3455 | msg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_5; |
@@ -3176,12 +3458,12 @@ static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid, | |||
3176 | msg[3] = 0; | 3458 | msg[3] = 0; |
3177 | msg[4] = 0; | 3459 | msg[4] = 0; |
3178 | msg[5] = 0x54000000 | oplen; /* OperationBlock */ | 3460 | msg[5] = 0x54000000 | oplen; /* OperationBlock */ |
3179 | msg[6] = virt_to_bus(opblk); | 3461 | msg[6] = (u32)opblk_pa; |
3180 | msg[7] = 0xD0000000 | reslen; /* ResultBlock */ | 3462 | msg[7] = 0xD0000000 | reslen; /* ResultBlock */ |
3181 | msg[8] = virt_to_bus(resblk); | 3463 | msg[8] = (u32)resblk_pa; |
3182 | 3464 | ||
3183 | if ((wait_status = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 20))) { | 3465 | if ((wait_status = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 20))) { |
3184 | printk("adpt_i2o_issue_params: post_wait failed (%p)\n", resblk); | 3466 | printk("adpt_i2o_issue_params: post_wait failed (%p)\n", resblk_va); |
3185 | return wait_status; /* -DetailedStatus */ | 3467 | return wait_status; /* -DetailedStatus */ |
3186 | } | 3468 | } |
3187 | 3469 | ||
@@ -3284,7 +3566,7 @@ static int adpt_i2o_systab_send(adpt_hba* pHba) | |||
3284 | * Private i/o space declaration | 3566 | * Private i/o space declaration |
3285 | */ | 3567 | */ |
3286 | msg[6] = 0x54000000 | sys_tbl_len; | 3568 | msg[6] = 0x54000000 | sys_tbl_len; |
3287 | msg[7] = virt_to_phys(sys_tbl); | 3569 | msg[7] = (u32)sys_tbl_pa; |
3288 | msg[8] = 0x54000000 | 0; | 3570 | msg[8] = 0x54000000 | 0; |
3289 | msg[9] = 0; | 3571 | msg[9] = 0; |
3290 | msg[10] = 0xD4000000 | 0; | 3572 | msg[10] = 0xD4000000 | 0; |
@@ -3323,11 +3605,10 @@ static static void adpt_delay(int millisec) | |||
3323 | #endif | 3605 | #endif |
3324 | 3606 | ||
3325 | static struct scsi_host_template driver_template = { | 3607 | static struct scsi_host_template driver_template = { |
3608 | .module = THIS_MODULE, | ||
3326 | .name = "dpt_i2o", | 3609 | .name = "dpt_i2o", |
3327 | .proc_name = "dpt_i2o", | 3610 | .proc_name = "dpt_i2o", |
3328 | .proc_info = adpt_proc_info, | 3611 | .proc_info = adpt_proc_info, |
3329 | .detect = adpt_detect, | ||
3330 | .release = adpt_release, | ||
3331 | .info = adpt_info, | 3612 | .info = adpt_info, |
3332 | .queuecommand = adpt_queue, | 3613 | .queuecommand = adpt_queue, |
3333 | .eh_abort_handler = adpt_abort, | 3614 | .eh_abort_handler = adpt_abort, |
@@ -3341,5 +3622,48 @@ static struct scsi_host_template driver_template = { | |||
3341 | .cmd_per_lun = 1, | 3622 | .cmd_per_lun = 1, |
3342 | .use_clustering = ENABLE_CLUSTERING, | 3623 | .use_clustering = ENABLE_CLUSTERING, |
3343 | }; | 3624 | }; |
3344 | #include "scsi_module.c" | 3625 | |
3626 | static int __init adpt_init(void) | ||
3627 | { | ||
3628 | int error; | ||
3629 | adpt_hba *pHba, *next; | ||
3630 | |||
3631 | printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n"); | ||
3632 | |||
3633 | error = adpt_detect(&driver_template); | ||
3634 | if (error < 0) | ||
3635 | return error; | ||
3636 | if (hba_chain == NULL) | ||
3637 | return -ENODEV; | ||
3638 | |||
3639 | for (pHba = hba_chain; pHba; pHba = pHba->next) { | ||
3640 | error = scsi_add_host(pHba->host, &pHba->pDev->dev); | ||
3641 | if (error) | ||
3642 | goto fail; | ||
3643 | scsi_scan_host(pHba->host); | ||
3644 | } | ||
3645 | return 0; | ||
3646 | fail: | ||
3647 | for (pHba = hba_chain; pHba; pHba = next) { | ||
3648 | next = pHba->next; | ||
3649 | scsi_remove_host(pHba->host); | ||
3650 | } | ||
3651 | return error; | ||
3652 | } | ||
3653 | |||
3654 | static void __exit adpt_exit(void) | ||
3655 | { | ||
3656 | adpt_hba *pHba, *next; | ||
3657 | |||
3658 | for (pHba = hba_chain; pHba; pHba = pHba->next) | ||
3659 | scsi_remove_host(pHba->host); | ||
3660 | for (pHba = hba_chain; pHba; pHba = next) { | ||
3661 | next = pHba->next; | ||
3662 | adpt_release(pHba->host); | ||
3663 | } | ||
3664 | } | ||
3665 | |||
3666 | module_init(adpt_init); | ||
3667 | module_exit(adpt_exit); | ||
3668 | |||
3345 | MODULE_LICENSE("GPL"); | 3669 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h index fd79068c5869..924cd5a51676 100644 --- a/drivers/scsi/dpti.h +++ b/drivers/scsi/dpti.h | |||
@@ -84,7 +84,6 @@ static int adpt_device_reset(struct scsi_cmnd* cmd); | |||
84 | #define PCI_DPT_DEVICE_ID (0xA501) // DPT PCI I2O Device ID | 84 | #define PCI_DPT_DEVICE_ID (0xA501) // DPT PCI I2O Device ID |
85 | #define PCI_DPT_RAPTOR_DEVICE_ID (0xA511) | 85 | #define PCI_DPT_RAPTOR_DEVICE_ID (0xA511) |
86 | 86 | ||
87 | //#define REBOOT_NOTIFIER 1 | ||
88 | /* Debugging macro from Linux Device Drivers - Rubini */ | 87 | /* Debugging macro from Linux Device Drivers - Rubini */ |
89 | #undef PDEBUG | 88 | #undef PDEBUG |
90 | #ifdef DEBUG | 89 | #ifdef DEBUG |
@@ -229,14 +228,19 @@ typedef struct _adpt_hba { | |||
229 | u32 post_fifo_size; | 228 | u32 post_fifo_size; |
230 | u32 reply_fifo_size; | 229 | u32 reply_fifo_size; |
231 | u32* reply_pool; | 230 | u32* reply_pool; |
231 | dma_addr_t reply_pool_pa; | ||
232 | u32 sg_tablesize; // Scatter/Gather List Size. | 232 | u32 sg_tablesize; // Scatter/Gather List Size. |
233 | u8 top_scsi_channel; | 233 | u8 top_scsi_channel; |
234 | u8 top_scsi_id; | 234 | u8 top_scsi_id; |
235 | u8 top_scsi_lun; | 235 | u8 top_scsi_lun; |
236 | u8 dma64; | ||
236 | 237 | ||
237 | i2o_status_block* status_block; | 238 | i2o_status_block* status_block; |
239 | dma_addr_t status_block_pa; | ||
238 | i2o_hrt* hrt; | 240 | i2o_hrt* hrt; |
241 | dma_addr_t hrt_pa; | ||
239 | i2o_lct* lct; | 242 | i2o_lct* lct; |
243 | dma_addr_t lct_pa; | ||
240 | uint lct_size; | 244 | uint lct_size; |
241 | struct i2o_device* devices; | 245 | struct i2o_device* devices; |
242 | struct adpt_channel channel[MAX_CHANNEL]; | 246 | struct adpt_channel channel[MAX_CHANNEL]; |
@@ -249,6 +253,7 @@ typedef struct _adpt_hba { | |||
249 | void __iomem *FwDebugBLEDflag_P;// Virtual Addr Of FW Debug BLED | 253 | void __iomem *FwDebugBLEDflag_P;// Virtual Addr Of FW Debug BLED |
250 | void __iomem *FwDebugBLEDvalue_P;// Virtual Addr Of FW Debug BLED | 254 | void __iomem *FwDebugBLEDvalue_P;// Virtual Addr Of FW Debug BLED |
251 | u32 FwDebugFlags; | 255 | u32 FwDebugFlags; |
256 | u32 *ioctl_reply_context[4]; | ||
252 | } adpt_hba; | 257 | } adpt_hba; |
253 | 258 | ||
254 | struct sg_simple_element { | 259 | struct sg_simple_element { |
@@ -264,9 +269,6 @@ static void adpt_i2o_sys_shutdown(void); | |||
264 | static int adpt_init(void); | 269 | static int adpt_init(void); |
265 | static int adpt_i2o_build_sys_table(void); | 270 | static int adpt_i2o_build_sys_table(void); |
266 | static irqreturn_t adpt_isr(int irq, void *dev_id); | 271 | static irqreturn_t adpt_isr(int irq, void *dev_id); |
267 | #ifdef REBOOT_NOTIFIER | ||
268 | static int adpt_reboot_event(struct notifier_block *n, ulong code, void *p); | ||
269 | #endif | ||
270 | 272 | ||
271 | static void adpt_i2o_report_hba_unit(adpt_hba* pHba, struct i2o_device *d); | 273 | static void adpt_i2o_report_hba_unit(adpt_hba* pHba, struct i2o_device *d); |
272 | static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid, | 274 | static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid, |
@@ -275,7 +277,8 @@ static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid, | |||
275 | static const char *adpt_i2o_get_class_name(int class); | 277 | static const char *adpt_i2o_get_class_name(int class); |
276 | #endif | 278 | #endif |
277 | static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid, | 279 | static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid, |
278 | void *opblk, int oplen, void *resblk, int reslen); | 280 | void *opblk, dma_addr_t opblk_pa, int oplen, |
281 | void *resblk, dma_addr_t resblk_pa, int reslen); | ||
279 | static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout); | 282 | static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout); |
280 | static int adpt_i2o_lct_get(adpt_hba* pHba); | 283 | static int adpt_i2o_lct_get(adpt_hba* pHba); |
281 | static int adpt_i2o_parse_lct(adpt_hba* pHba); | 284 | static int adpt_i2o_parse_lct(adpt_hba* pHba); |
@@ -289,7 +292,7 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba); | |||
289 | static s32 adpt_i2o_hrt_get(adpt_hba* pHba); | 292 | static s32 adpt_i2o_hrt_get(adpt_hba* pHba); |
290 | static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice); | 293 | static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice); |
291 | static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd); | 294 | static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd); |
292 | static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht); | 295 | static s32 adpt_scsi_host_alloc(adpt_hba* pHba,struct scsi_host_template * sht); |
293 | static s32 adpt_hba_reset(adpt_hba* pHba); | 296 | static s32 adpt_hba_reset(adpt_hba* pHba); |
294 | static s32 adpt_i2o_reset_hba(adpt_hba* pHba); | 297 | static s32 adpt_i2o_reset_hba(adpt_hba* pHba); |
295 | static s32 adpt_rescan(adpt_hba* pHba); | 298 | static s32 adpt_rescan(adpt_hba* pHba); |
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index c6d6e7c6559a..8e2e964af668 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -465,7 +465,7 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd, | |||
465 | scp->request = (struct request *)&wait; | 465 | scp->request = (struct request *)&wait; |
466 | scp->timeout_per_command = timeout*HZ; | 466 | scp->timeout_per_command = timeout*HZ; |
467 | scp->cmd_len = 12; | 467 | scp->cmd_len = 12; |
468 | memcpy(scp->cmnd, cmnd, 12); | 468 | scp->cmnd = cmnd; |
469 | cmndinfo.priority = IOCTL_PRI; | 469 | cmndinfo.priority = IOCTL_PRI; |
470 | cmndinfo.internal_cmd_str = gdtcmd; | 470 | cmndinfo.internal_cmd_str = gdtcmd; |
471 | cmndinfo.internal_command = 1; | 471 | cmndinfo.internal_command = 1; |
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index 5b7be1e9841c..aaa48e0c8ed0 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c | |||
@@ -763,9 +763,9 @@ static int hptiop_queuecommand(struct scsi_cmnd *scp, | |||
763 | scp, | 763 | scp, |
764 | host->host_no, scp->device->channel, | 764 | host->host_no, scp->device->channel, |
765 | scp->device->id, scp->device->lun, | 765 | scp->device->id, scp->device->lun, |
766 | *((u32 *)&scp->cmnd), | 766 | ((u32 *)scp->cmnd)[0], |
767 | *((u32 *)&scp->cmnd + 1), | 767 | ((u32 *)scp->cmnd)[1], |
768 | *((u32 *)&scp->cmnd + 2), | 768 | ((u32 *)scp->cmnd)[2], |
769 | _req->index, _req->req_virt); | 769 | _req->index, _req->req_virt); |
770 | 770 | ||
771 | scp->result = 0; | 771 | scp->result = 0; |
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 4a922c57125e..ccfd8aca3765 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c | |||
@@ -686,7 +686,7 @@ static void handle_cmd_rsp(struct srp_event_struct *evt_struct) | |||
686 | } | 686 | } |
687 | 687 | ||
688 | if (cmnd) { | 688 | if (cmnd) { |
689 | cmnd->result = rsp->status; | 689 | cmnd->result |= rsp->status; |
690 | if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION) | 690 | if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION) |
691 | memcpy(cmnd->sense_buffer, | 691 | memcpy(cmnd->sense_buffer, |
692 | rsp->data, | 692 | rsp->data, |
@@ -730,6 +730,7 @@ static int ibmvscsi_queuecommand(struct scsi_cmnd *cmnd, | |||
730 | u16 lun = lun_from_dev(cmnd->device); | 730 | u16 lun = lun_from_dev(cmnd->device); |
731 | u8 out_fmt, in_fmt; | 731 | u8 out_fmt, in_fmt; |
732 | 732 | ||
733 | cmnd->result = (DID_OK << 16); | ||
733 | evt_struct = get_event_struct(&hostdata->pool); | 734 | evt_struct = get_event_struct(&hostdata->pool); |
734 | if (!evt_struct) | 735 | if (!evt_struct) |
735 | return SCSI_MLQUEUE_HOST_BUSY; | 736 | return SCSI_MLQUEUE_HOST_BUSY; |
@@ -738,7 +739,7 @@ static int ibmvscsi_queuecommand(struct scsi_cmnd *cmnd, | |||
738 | srp_cmd = &evt_struct->iu.srp.cmd; | 739 | srp_cmd = &evt_struct->iu.srp.cmd; |
739 | memset(srp_cmd, 0x00, SRP_MAX_IU_LEN); | 740 | memset(srp_cmd, 0x00, SRP_MAX_IU_LEN); |
740 | srp_cmd->opcode = SRP_CMD; | 741 | srp_cmd->opcode = SRP_CMD; |
741 | memcpy(srp_cmd->cdb, cmnd->cmnd, sizeof(cmnd->cmnd)); | 742 | memcpy(srp_cmd->cdb, cmnd->cmnd, sizeof(srp_cmd->cdb)); |
742 | srp_cmd->lun = ((u64) lun) << 48; | 743 | srp_cmd->lun = ((u64) lun) << 48; |
743 | 744 | ||
744 | if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { | 745 | if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { |
@@ -1347,6 +1348,8 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq, | |||
1347 | 1348 | ||
1348 | del_timer(&evt_struct->timer); | 1349 | del_timer(&evt_struct->timer); |
1349 | 1350 | ||
1351 | if (crq->status != VIOSRP_OK && evt_struct->cmnd) | ||
1352 | evt_struct->cmnd->result = DID_ERROR << 16; | ||
1350 | if (evt_struct->done) | 1353 | if (evt_struct->done) |
1351 | evt_struct->done(evt_struct); | 1354 | evt_struct->done(evt_struct); |
1352 | else | 1355 | else |
diff --git a/drivers/scsi/ibmvscsi/viosrp.h b/drivers/scsi/ibmvscsi/viosrp.h index 90f1a61283ad..4c4aadb3e405 100644 --- a/drivers/scsi/ibmvscsi/viosrp.h +++ b/drivers/scsi/ibmvscsi/viosrp.h | |||
@@ -59,6 +59,15 @@ enum viosrp_crq_formats { | |||
59 | VIOSRP_INLINE_FORMAT = 0x07 | 59 | VIOSRP_INLINE_FORMAT = 0x07 |
60 | }; | 60 | }; |
61 | 61 | ||
62 | enum viosrp_crq_status { | ||
63 | VIOSRP_OK = 0x0, | ||
64 | VIOSRP_NONRECOVERABLE_ERR = 0x1, | ||
65 | VIOSRP_VIOLATES_MAX_XFER = 0x2, | ||
66 | VIOSRP_PARTNER_PANIC = 0x3, | ||
67 | VIOSRP_DEVICE_BUSY = 0x8, | ||
68 | VIOSRP_ADAPTER_FAIL = 0x10 | ||
69 | }; | ||
70 | |||
62 | struct viosrp_crq { | 71 | struct viosrp_crq { |
63 | u8 valid; /* used by RPA */ | 72 | u8 valid; /* used by RPA */ |
64 | u8 format; /* SCSI vs out-of-band */ | 73 | u8 format; /* SCSI vs out-of-band */ |
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index dbae3fdb8506..e3f739776bad 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c | |||
@@ -2590,7 +2590,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c | |||
2590 | cblk->hastat = 0; | 2590 | cblk->hastat = 0; |
2591 | cblk->tastat = 0; | 2591 | cblk->tastat = 0; |
2592 | /* Command the command */ | 2592 | /* Command the command */ |
2593 | memcpy(&cblk->cdb[0], &cmnd->cmnd, cmnd->cmd_len); | 2593 | memcpy(cblk->cdb, cmnd->cmnd, cmnd->cmd_len); |
2594 | 2594 | ||
2595 | /* Set up tags */ | 2595 | /* Set up tags */ |
2596 | if (cmnd->device->tagged_supported) { /* Tag Support */ | 2596 | if (cmnd->device->tagged_supported) { /* Tag Support */ |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index de5ae6a65029..999e91ea7451 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -2791,7 +2791,7 @@ static ssize_t ipr_store_adapter_state(struct device *dev, | |||
2791 | 2791 | ||
2792 | static struct device_attribute ipr_ioa_state_attr = { | 2792 | static struct device_attribute ipr_ioa_state_attr = { |
2793 | .attr = { | 2793 | .attr = { |
2794 | .name = "state", | 2794 | .name = "online_state", |
2795 | .mode = S_IRUGO | S_IWUSR, | 2795 | .mode = S_IRUGO | S_IWUSR, |
2796 | }, | 2796 | }, |
2797 | .show = ipr_show_adapter_state, | 2797 | .show = ipr_show_adapter_state, |
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 820f91fb63ba..70a0f11f48b2 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c | |||
@@ -3168,6 +3168,23 @@ megaraid_mbox_support_random_del(adapter_t *adapter) | |||
3168 | uint8_t raw_mbox[sizeof(mbox_t)]; | 3168 | uint8_t raw_mbox[sizeof(mbox_t)]; |
3169 | int rval; | 3169 | int rval; |
3170 | 3170 | ||
3171 | /* | ||
3172 | * Newer firmware on Dell CERC expect a different | ||
3173 | * random deletion handling, so disable it. | ||
3174 | */ | ||
3175 | if (adapter->pdev->vendor == PCI_VENDOR_ID_AMI && | ||
3176 | adapter->pdev->device == PCI_DEVICE_ID_AMI_MEGARAID3 && | ||
3177 | adapter->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL && | ||
3178 | adapter->pdev->subsystem_device == PCI_SUBSYS_ID_CERC_ATA100_4CH && | ||
3179 | (adapter->fw_version[0] > '6' || | ||
3180 | (adapter->fw_version[0] == '6' && | ||
3181 | adapter->fw_version[2] > '6') || | ||
3182 | (adapter->fw_version[0] == '6' | ||
3183 | && adapter->fw_version[2] == '6' | ||
3184 | && adapter->fw_version[3] > '1'))) { | ||
3185 | con_log(CL_DLEVEL1, ("megaraid: disable random deletion\n")); | ||
3186 | return 0; | ||
3187 | } | ||
3171 | 3188 | ||
3172 | mbox = (mbox_t *)raw_mbox; | 3189 | mbox = (mbox_t *)raw_mbox; |
3173 | 3190 | ||
diff --git a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h index 626459d1e902..c1d86d961a92 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.h +++ b/drivers/scsi/megaraid/megaraid_mbox.h | |||
@@ -88,6 +88,7 @@ | |||
88 | #define PCI_SUBSYS_ID_PERC3_QC 0x0471 | 88 | #define PCI_SUBSYS_ID_PERC3_QC 0x0471 |
89 | #define PCI_SUBSYS_ID_PERC3_DC 0x0493 | 89 | #define PCI_SUBSYS_ID_PERC3_DC 0x0493 |
90 | #define PCI_SUBSYS_ID_PERC3_SC 0x0475 | 90 | #define PCI_SUBSYS_ID_PERC3_SC 0x0475 |
91 | #define PCI_SUBSYS_ID_CERC_ATA100_4CH 0x0511 | ||
91 | 92 | ||
92 | 93 | ||
93 | #define MBOX_MAX_SCSI_CMDS 128 // number of cmds reserved for kernel | 94 | #define MBOX_MAX_SCSI_CMDS 128 // number of cmds reserved for kernel |
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index b937e9cddb23..7d84c8bbcf3f 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * 2 of the License, or (at your option) any later version. | 10 | * 2 of the License, or (at your option) any later version. |
11 | * | 11 | * |
12 | * FILE : megaraid_sas.c | 12 | * FILE : megaraid_sas.c |
13 | * Version : v00.00.03.16-rc1 | 13 | * Version : v00.00.03.20-rc1 |
14 | * | 14 | * |
15 | * Authors: | 15 | * Authors: |
16 | * (email-id : megaraidlinux@lsi.com) | 16 | * (email-id : megaraidlinux@lsi.com) |
@@ -2650,12 +2650,13 @@ static void megasas_shutdown_controller(struct megasas_instance *instance, | |||
2650 | return; | 2650 | return; |
2651 | } | 2651 | } |
2652 | 2652 | ||
2653 | #ifdef CONFIG_PM | ||
2653 | /** | 2654 | /** |
2654 | * megasas_suspend - driver suspend entry point | 2655 | * megasas_suspend - driver suspend entry point |
2655 | * @pdev: PCI device structure | 2656 | * @pdev: PCI device structure |
2656 | * @state: PCI power state to suspend routine | 2657 | * @state: PCI power state to suspend routine |
2657 | */ | 2658 | */ |
2658 | static int __devinit | 2659 | static int |
2659 | megasas_suspend(struct pci_dev *pdev, pm_message_t state) | 2660 | megasas_suspend(struct pci_dev *pdev, pm_message_t state) |
2660 | { | 2661 | { |
2661 | struct Scsi_Host *host; | 2662 | struct Scsi_Host *host; |
@@ -2687,7 +2688,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2687 | * megasas_resume- driver resume entry point | 2688 | * megasas_resume- driver resume entry point |
2688 | * @pdev: PCI device structure | 2689 | * @pdev: PCI device structure |
2689 | */ | 2690 | */ |
2690 | static int __devinit | 2691 | static int |
2691 | megasas_resume(struct pci_dev *pdev) | 2692 | megasas_resume(struct pci_dev *pdev) |
2692 | { | 2693 | { |
2693 | int rval; | 2694 | int rval; |
@@ -2782,12 +2783,16 @@ fail_ready_state: | |||
2782 | 2783 | ||
2783 | return -ENODEV; | 2784 | return -ENODEV; |
2784 | } | 2785 | } |
2786 | #else | ||
2787 | #define megasas_suspend NULL | ||
2788 | #define megasas_resume NULL | ||
2789 | #endif | ||
2785 | 2790 | ||
2786 | /** | 2791 | /** |
2787 | * megasas_detach_one - PCI hot"un"plug entry point | 2792 | * megasas_detach_one - PCI hot"un"plug entry point |
2788 | * @pdev: PCI device structure | 2793 | * @pdev: PCI device structure |
2789 | */ | 2794 | */ |
2790 | static void megasas_detach_one(struct pci_dev *pdev) | 2795 | static void __devexit megasas_detach_one(struct pci_dev *pdev) |
2791 | { | 2796 | { |
2792 | int i; | 2797 | int i; |
2793 | struct Scsi_Host *host; | 2798 | struct Scsi_Host *host; |
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 3a997eb457bf..b0c41e671702 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h | |||
@@ -18,9 +18,9 @@ | |||
18 | /* | 18 | /* |
19 | * MegaRAID SAS Driver meta data | 19 | * MegaRAID SAS Driver meta data |
20 | */ | 20 | */ |
21 | #define MEGASAS_VERSION "00.00.03.16-rc1" | 21 | #define MEGASAS_VERSION "00.00.03.20-rc1" |
22 | #define MEGASAS_RELDATE "Nov. 07, 2007" | 22 | #define MEGASAS_RELDATE "March 10, 2008" |
23 | #define MEGASAS_EXT_VERSION "Thu. Nov. 07 10:09:32 PDT 2007" | 23 | #define MEGASAS_EXT_VERSION "Mon. March 10 11:02:31 PDT 2008" |
24 | 24 | ||
25 | /* | 25 | /* |
26 | * Device IDs | 26 | * Device IDs |
diff --git a/drivers/scsi/mvsas.c b/drivers/scsi/mvsas.c index e55b9037adb2..1dd70d7a4947 100644 --- a/drivers/scsi/mvsas.c +++ b/drivers/scsi/mvsas.c | |||
@@ -2822,7 +2822,9 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i, | |||
2822 | dev_printk(KERN_DEBUG, &pdev->dev, | 2822 | dev_printk(KERN_DEBUG, &pdev->dev, |
2823 | "phy[%d] Get Attached Address 0x%llX ," | 2823 | "phy[%d] Get Attached Address 0x%llX ," |
2824 | " SAS Address 0x%llX\n", | 2824 | " SAS Address 0x%llX\n", |
2825 | i, phy->att_dev_sas_addr, phy->dev_sas_addr); | 2825 | i, |
2826 | (unsigned long long)phy->att_dev_sas_addr, | ||
2827 | (unsigned long long)phy->dev_sas_addr); | ||
2826 | dev_printk(KERN_DEBUG, &pdev->dev, | 2828 | dev_printk(KERN_DEBUG, &pdev->dev, |
2827 | "Rate = %x , type = %d\n", | 2829 | "Rate = %x , type = %d\n", |
2828 | sas_phy->linkrate, phy->phy_type); | 2830 | sas_phy->linkrate, phy->phy_type); |
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index ceab4f73caf1..c57c94c0ffd2 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c | |||
@@ -8222,7 +8222,7 @@ static void process_waiting_list(struct ncb *np, int sts) | |||
8222 | #ifdef DEBUG_WAITING_LIST | 8222 | #ifdef DEBUG_WAITING_LIST |
8223 | if (waiting_list) printk("%s: waiting_list=%lx processing sts=%d\n", ncr_name(np), (u_long) waiting_list, sts); | 8223 | if (waiting_list) printk("%s: waiting_list=%lx processing sts=%d\n", ncr_name(np), (u_long) waiting_list, sts); |
8224 | #endif | 8224 | #endif |
8225 | while (wcmd = waiting_list) { | 8225 | while ((wcmd = waiting_list) != NULL) { |
8226 | waiting_list = (struct scsi_cmnd *) wcmd->next_wcmd; | 8226 | waiting_list = (struct scsi_cmnd *) wcmd->next_wcmd; |
8227 | wcmd->next_wcmd = NULL; | 8227 | wcmd->next_wcmd = NULL; |
8228 | if (sts == DID_OK) { | 8228 | if (sts == DID_OK) { |
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 09ab3eac1c1a..fa060932d2b4 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c | |||
@@ -2858,7 +2858,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2858 | 2858 | ||
2859 | /* Load SCSI command packet. */ | 2859 | /* Load SCSI command packet. */ |
2860 | pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd)); | 2860 | pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd)); |
2861 | memcpy(pkt->scsi_cdb, &(CMD_CDBP(cmd)), CMD_CDBLEN(cmd)); | 2861 | memcpy(pkt->scsi_cdb, CMD_CDBP(cmd), CMD_CDBLEN(cmd)); |
2862 | /* dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */ | 2862 | /* dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */ |
2863 | 2863 | ||
2864 | /* Set transfer direction. */ | 2864 | /* Set transfer direction. */ |
@@ -3127,7 +3127,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3127 | 3127 | ||
3128 | /* Load SCSI command packet. */ | 3128 | /* Load SCSI command packet. */ |
3129 | pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd)); | 3129 | pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd)); |
3130 | memcpy(pkt->scsi_cdb, &(CMD_CDBP(cmd)), CMD_CDBLEN(cmd)); | 3130 | memcpy(pkt->scsi_cdb, CMD_CDBP(cmd), CMD_CDBLEN(cmd)); |
3131 | 3131 | ||
3132 | /*dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */ | 3132 | /*dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */ |
3133 | /* Set transfer direction. */ | 3133 | /* Set transfer direction. */ |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 12d69d7c8577..110e776d1a07 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -79,15 +79,6 @@ static void scsi_done(struct scsi_cmnd *cmd); | |||
79 | #define MIN_RESET_PERIOD (15*HZ) | 79 | #define MIN_RESET_PERIOD (15*HZ) |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Macro to determine the size of SCSI command. This macro takes vendor | ||
83 | * unique commands into account. SCSI commands in groups 6 and 7 are | ||
84 | * vendor unique and we will depend upon the command length being | ||
85 | * supplied correctly in cmd_len. | ||
86 | */ | ||
87 | #define CDB_SIZE(cmd) (((((cmd)->cmnd[0] >> 5) & 7) < 6) ? \ | ||
88 | COMMAND_SIZE((cmd)->cmnd[0]) : (cmd)->cmd_len) | ||
89 | |||
90 | /* | ||
91 | * Note - the initial logging level can be set here to log events at boot time. | 82 | * Note - the initial logging level can be set here to log events at boot time. |
92 | * After the system is up, you may enable logging via the /proc interface. | 83 | * After the system is up, you may enable logging via the /proc interface. |
93 | */ | 84 | */ |
@@ -469,6 +460,7 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost) | |||
469 | cmd = scsi_pool_alloc_command(shost->cmd_pool, gfp_mask); | 460 | cmd = scsi_pool_alloc_command(shost->cmd_pool, gfp_mask); |
470 | if (!cmd) { | 461 | if (!cmd) { |
471 | scsi_put_host_cmd_pool(gfp_mask); | 462 | scsi_put_host_cmd_pool(gfp_mask); |
463 | shost->cmd_pool = NULL; | ||
472 | return -ENOMEM; | 464 | return -ENOMEM; |
473 | } | 465 | } |
474 | list_add(&cmd->list, &shost->free_list); | 466 | list_add(&cmd->list, &shost->free_list); |
@@ -481,6 +473,13 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost) | |||
481 | */ | 473 | */ |
482 | void scsi_destroy_command_freelist(struct Scsi_Host *shost) | 474 | void scsi_destroy_command_freelist(struct Scsi_Host *shost) |
483 | { | 475 | { |
476 | /* | ||
477 | * If cmd_pool is NULL the free list was not initialized, so | ||
478 | * do not attempt to release resources. | ||
479 | */ | ||
480 | if (!shost->cmd_pool) | ||
481 | return; | ||
482 | |||
484 | while (!list_empty(&shost->free_list)) { | 483 | while (!list_empty(&shost->free_list)) { |
485 | struct scsi_cmnd *cmd; | 484 | struct scsi_cmnd *cmd; |
486 | 485 | ||
@@ -701,9 +700,11 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
701 | * Before we queue this command, check if the command | 700 | * Before we queue this command, check if the command |
702 | * length exceeds what the host adapter can handle. | 701 | * length exceeds what the host adapter can handle. |
703 | */ | 702 | */ |
704 | if (CDB_SIZE(cmd) > cmd->device->host->max_cmd_len) { | 703 | if (cmd->cmd_len > cmd->device->host->max_cmd_len) { |
705 | SCSI_LOG_MLQUEUE(3, | 704 | SCSI_LOG_MLQUEUE(3, |
706 | printk("queuecommand : command too long.\n")); | 705 | printk("queuecommand : command too long. " |
706 | "cdb_size=%d host->max_cmd_len=%d\n", | ||
707 | cmd->cmd_len, cmd->device->host->max_cmd_len)); | ||
707 | cmd->result = (DID_ABORT << 16); | 708 | cmd->result = (DID_ABORT << 16); |
708 | 709 | ||
709 | scsi_done(cmd); | 710 | scsi_done(cmd); |
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 1eaba6cd80f4..eaf5a8add1ba 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c | |||
@@ -626,7 +626,7 @@ static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd) | |||
626 | * @scmd: SCSI command structure to hijack | 626 | * @scmd: SCSI command structure to hijack |
627 | * @ses: structure to save restore information | 627 | * @ses: structure to save restore information |
628 | * @cmnd: CDB to send. Can be NULL if no new cmnd is needed | 628 | * @cmnd: CDB to send. Can be NULL if no new cmnd is needed |
629 | * @cmnd_size: size in bytes of @cmnd | 629 | * @cmnd_size: size in bytes of @cmnd (must be <= BLK_MAX_CDB) |
630 | * @sense_bytes: size of sense data to copy. or 0 (if != 0 @cmnd is ignored) | 630 | * @sense_bytes: size of sense data to copy. or 0 (if != 0 @cmnd is ignored) |
631 | * | 631 | * |
632 | * This function is used to save a scsi command information before re-execution | 632 | * This function is used to save a scsi command information before re-execution |
@@ -648,12 +648,14 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses, | |||
648 | * command. | 648 | * command. |
649 | */ | 649 | */ |
650 | ses->cmd_len = scmd->cmd_len; | 650 | ses->cmd_len = scmd->cmd_len; |
651 | memcpy(ses->cmnd, scmd->cmnd, sizeof(scmd->cmnd)); | 651 | ses->cmnd = scmd->cmnd; |
652 | ses->data_direction = scmd->sc_data_direction; | 652 | ses->data_direction = scmd->sc_data_direction; |
653 | ses->sdb = scmd->sdb; | 653 | ses->sdb = scmd->sdb; |
654 | ses->next_rq = scmd->request->next_rq; | 654 | ses->next_rq = scmd->request->next_rq; |
655 | ses->result = scmd->result; | 655 | ses->result = scmd->result; |
656 | 656 | ||
657 | scmd->cmnd = ses->eh_cmnd; | ||
658 | memset(scmd->cmnd, 0, BLK_MAX_CDB); | ||
657 | memset(&scmd->sdb, 0, sizeof(scmd->sdb)); | 659 | memset(&scmd->sdb, 0, sizeof(scmd->sdb)); |
658 | scmd->request->next_rq = NULL; | 660 | scmd->request->next_rq = NULL; |
659 | 661 | ||
@@ -665,14 +667,13 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses, | |||
665 | scmd->sdb.table.sgl = &ses->sense_sgl; | 667 | scmd->sdb.table.sgl = &ses->sense_sgl; |
666 | scmd->sc_data_direction = DMA_FROM_DEVICE; | 668 | scmd->sc_data_direction = DMA_FROM_DEVICE; |
667 | scmd->sdb.table.nents = 1; | 669 | scmd->sdb.table.nents = 1; |
668 | memset(scmd->cmnd, 0, sizeof(scmd->cmnd)); | ||
669 | scmd->cmnd[0] = REQUEST_SENSE; | 670 | scmd->cmnd[0] = REQUEST_SENSE; |
670 | scmd->cmnd[4] = scmd->sdb.length; | 671 | scmd->cmnd[4] = scmd->sdb.length; |
671 | scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); | 672 | scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); |
672 | } else { | 673 | } else { |
673 | scmd->sc_data_direction = DMA_NONE; | 674 | scmd->sc_data_direction = DMA_NONE; |
674 | if (cmnd) { | 675 | if (cmnd) { |
675 | memset(scmd->cmnd, 0, sizeof(scmd->cmnd)); | 676 | BUG_ON(cmnd_size > BLK_MAX_CDB); |
676 | memcpy(scmd->cmnd, cmnd, cmnd_size); | 677 | memcpy(scmd->cmnd, cmnd, cmnd_size); |
677 | scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); | 678 | scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); |
678 | } | 679 | } |
@@ -705,7 +706,7 @@ void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses) | |||
705 | * Restore original data | 706 | * Restore original data |
706 | */ | 707 | */ |
707 | scmd->cmd_len = ses->cmd_len; | 708 | scmd->cmd_len = ses->cmd_len; |
708 | memcpy(scmd->cmnd, ses->cmnd, sizeof(scmd->cmnd)); | 709 | scmd->cmnd = ses->cmnd; |
709 | scmd->sc_data_direction = ses->data_direction; | 710 | scmd->sc_data_direction = ses->data_direction; |
710 | scmd->sdb = ses->sdb; | 711 | scmd->sdb = ses->sdb; |
711 | scmd->request->next_rq = ses->next_rq; | 712 | scmd->request->next_rq = ses->next_rq; |
@@ -1775,8 +1776,8 @@ scsi_reset_provider(struct scsi_device *dev, int flag) | |||
1775 | scmd->request = &req; | 1776 | scmd->request = &req; |
1776 | memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout)); | 1777 | memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout)); |
1777 | 1778 | ||
1778 | memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd)); | 1779 | scmd->cmnd = req.cmd; |
1779 | 1780 | ||
1780 | scmd->scsi_done = scsi_reset_provider_done_command; | 1781 | scmd->scsi_done = scsi_reset_provider_done_command; |
1781 | memset(&scmd->sdb, 0, sizeof(scmd->sdb)); | 1782 | memset(&scmd->sdb, 0, sizeof(scmd->sdb)); |
1782 | 1783 | ||
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index d545ad1cf47a..a82d2fe80fb5 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -445,7 +445,7 @@ static void scsi_init_cmd_errh(struct scsi_cmnd *cmd) | |||
445 | scsi_set_resid(cmd, 0); | 445 | scsi_set_resid(cmd, 0); |
446 | memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); | 446 | memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
447 | if (cmd->cmd_len == 0) | 447 | if (cmd->cmd_len == 0) |
448 | cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]); | 448 | cmd->cmd_len = scsi_command_size(cmd->cmnd); |
449 | } | 449 | } |
450 | 450 | ||
451 | void scsi_device_unbusy(struct scsi_device *sdev) | 451 | void scsi_device_unbusy(struct scsi_device *sdev) |
@@ -1094,6 +1094,8 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev, | |||
1094 | cmd->tag = req->tag; | 1094 | cmd->tag = req->tag; |
1095 | cmd->request = req; | 1095 | cmd->request = req; |
1096 | 1096 | ||
1097 | cmd->cmnd = req->cmd; | ||
1098 | |||
1097 | return cmd; | 1099 | return cmd; |
1098 | } | 1100 | } |
1099 | 1101 | ||
@@ -1131,8 +1133,6 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) | |||
1131 | req->buffer = NULL; | 1133 | req->buffer = NULL; |
1132 | } | 1134 | } |
1133 | 1135 | ||
1134 | BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); | ||
1135 | memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); | ||
1136 | cmd->cmd_len = req->cmd_len; | 1136 | cmd->cmd_len = req->cmd_len; |
1137 | if (!req->data_len) | 1137 | if (!req->data_len) |
1138 | cmd->sc_data_direction = DMA_NONE; | 1138 | cmd->sc_data_direction = DMA_NONE; |
@@ -1169,6 +1169,7 @@ int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req) | |||
1169 | if (unlikely(!cmd)) | 1169 | if (unlikely(!cmd)) |
1170 | return BLKPREP_DEFER; | 1170 | return BLKPREP_DEFER; |
1171 | 1171 | ||
1172 | memset(cmd->cmnd, 0, BLK_MAX_CDB); | ||
1172 | return scsi_init_io(cmd, GFP_ATOMIC); | 1173 | return scsi_init_io(cmd, GFP_ATOMIC); |
1173 | } | 1174 | } |
1174 | EXPORT_SYMBOL(scsi_setup_fs_cmnd); | 1175 | EXPORT_SYMBOL(scsi_setup_fs_cmnd); |
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c index ee8496aa0336..257e097c39af 100644 --- a/drivers/scsi/scsi_tgt_lib.c +++ b/drivers/scsi/scsi_tgt_lib.c | |||
@@ -107,6 +107,8 @@ struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *shost, | |||
107 | cmd->jiffies_at_alloc = jiffies; | 107 | cmd->jiffies_at_alloc = jiffies; |
108 | cmd->request = rq; | 108 | cmd->request = rq; |
109 | 109 | ||
110 | cmd->cmnd = rq->cmd; | ||
111 | |||
110 | rq->special = cmd; | 112 | rq->special = cmd; |
111 | rq->cmd_type = REQ_TYPE_SPECIAL; | 113 | rq->cmd_type = REQ_TYPE_SPECIAL; |
112 | rq->cmd_flags |= REQ_TYPE_BLOCK_PC; | 114 | rq->cmd_flags |= REQ_TYPE_BLOCK_PC; |
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c index 640333b1e75c..329eb8780e74 100644 --- a/drivers/scsi/u14-34f.c +++ b/drivers/scsi/u14-34f.c | |||
@@ -744,7 +744,8 @@ static int wait_on_busy(unsigned long iobase, unsigned int loop) { | |||
744 | static int board_inquiry(unsigned int j) { | 744 | static int board_inquiry(unsigned int j) { |
745 | struct mscp *cpp; | 745 | struct mscp *cpp; |
746 | dma_addr_t id_dma_addr; | 746 | dma_addr_t id_dma_addr; |
747 | unsigned int time, limit = 0; | 747 | unsigned int limit = 0; |
748 | unsigned long time; | ||
748 | 749 | ||
749 | id_dma_addr = pci_map_single(HD(j)->pdev, HD(j)->board_id, | 750 | id_dma_addr = pci_map_single(HD(j)->pdev, HD(j)->board_id, |
750 | sizeof(HD(j)->board_id), PCI_DMA_BIDIRECTIONAL); | 751 | sizeof(HD(j)->board_id), PCI_DMA_BIDIRECTIONAL); |
@@ -1392,7 +1393,8 @@ static int u14_34f_eh_abort(struct scsi_cmnd *SCarg) { | |||
1392 | } | 1393 | } |
1393 | 1394 | ||
1394 | static int u14_34f_eh_host_reset(struct scsi_cmnd *SCarg) { | 1395 | static int u14_34f_eh_host_reset(struct scsi_cmnd *SCarg) { |
1395 | unsigned int i, j, time, k, c, limit = 0; | 1396 | unsigned int i, j, k, c, limit = 0; |
1397 | unsigned long time; | ||
1396 | int arg_done = FALSE; | 1398 | int arg_done = FALSE; |
1397 | struct scsi_cmnd *SCpnt; | 1399 | struct scsi_cmnd *SCpnt; |
1398 | 1400 | ||
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index ea41f2626458..a1ca9b7bf2d5 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -2271,7 +2271,8 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) | |||
2271 | } | 2271 | } |
2272 | 2272 | ||
2273 | if (up->port.flags & UPF_IOREMAP) { | 2273 | if (up->port.flags & UPF_IOREMAP) { |
2274 | up->port.membase = ioremap(up->port.mapbase, size); | 2274 | up->port.membase = ioremap_nocache(up->port.mapbase, |
2275 | size); | ||
2275 | if (!up->port.membase) { | 2276 | if (!up->port.membase) { |
2276 | release_mem_region(up->port.mapbase, size); | 2277 | release_mem_region(up->port.mapbase, size); |
2277 | ret = -ENOMEM; | 2278 | ret = -ENOMEM; |
diff --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c index cd898704ba4f..f279745e9fef 100644 --- a/drivers/serial/8250_early.c +++ b/drivers/serial/8250_early.c | |||
@@ -153,7 +153,7 @@ static int __init parse_options(struct early_serial8250_device *device, | |||
153 | (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE); | 153 | (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE); |
154 | port->membase += port->mapbase & ~PAGE_MASK; | 154 | port->membase += port->mapbase & ~PAGE_MASK; |
155 | #else | 155 | #else |
156 | port->membase = ioremap(port->mapbase, 64); | 156 | port->membase = ioremap_nocache(port->mapbase, 64); |
157 | if (!port->membase) { | 157 | if (!port->membase) { |
158 | printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n", | 158 | printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n", |
159 | __func__, | 159 | __func__, |
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index 6e57382b9137..53fa19cf2f06 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c | |||
@@ -86,7 +86,7 @@ setup_port(struct serial_private *priv, struct uart_port *port, | |||
86 | len = pci_resource_len(dev, bar); | 86 | len = pci_resource_len(dev, bar); |
87 | 87 | ||
88 | if (!priv->remapped_bar[bar]) | 88 | if (!priv->remapped_bar[bar]) |
89 | priv->remapped_bar[bar] = ioremap(base, len); | 89 | priv->remapped_bar[bar] = ioremap_nocache(base, len); |
90 | if (!priv->remapped_bar[bar]) | 90 | if (!priv->remapped_bar[bar]) |
91 | return -ENOMEM; | 91 | return -ENOMEM; |
92 | 92 | ||
@@ -270,7 +270,7 @@ static int pci_plx9050_init(struct pci_dev *dev) | |||
270 | /* | 270 | /* |
271 | * enable/disable interrupts | 271 | * enable/disable interrupts |
272 | */ | 272 | */ |
273 | p = ioremap(pci_resource_start(dev, 0), 0x80); | 273 | p = ioremap_nocache(pci_resource_start(dev, 0), 0x80); |
274 | if (p == NULL) | 274 | if (p == NULL) |
275 | return -ENOMEM; | 275 | return -ENOMEM; |
276 | writel(irq_config, p + 0x4c); | 276 | writel(irq_config, p + 0x4c); |
@@ -294,7 +294,7 @@ static void __devexit pci_plx9050_exit(struct pci_dev *dev) | |||
294 | /* | 294 | /* |
295 | * disable interrupts | 295 | * disable interrupts |
296 | */ | 296 | */ |
297 | p = ioremap(pci_resource_start(dev, 0), 0x80); | 297 | p = ioremap_nocache(pci_resource_start(dev, 0), 0x80); |
298 | if (p != NULL) { | 298 | if (p != NULL) { |
299 | writel(0, p + 0x4c); | 299 | writel(0, p + 0x4c); |
300 | 300 | ||
@@ -341,7 +341,8 @@ static int sbs_init(struct pci_dev *dev) | |||
341 | { | 341 | { |
342 | u8 __iomem *p; | 342 | u8 __iomem *p; |
343 | 343 | ||
344 | p = ioremap(pci_resource_start(dev, 0), pci_resource_len(dev, 0)); | 344 | p = ioremap_nocache(pci_resource_start(dev, 0), |
345 | pci_resource_len(dev, 0)); | ||
345 | 346 | ||
346 | if (p == NULL) | 347 | if (p == NULL) |
347 | return -ENOMEM; | 348 | return -ENOMEM; |
@@ -365,7 +366,8 @@ static void __devexit sbs_exit(struct pci_dev *dev) | |||
365 | { | 366 | { |
366 | u8 __iomem *p; | 367 | u8 __iomem *p; |
367 | 368 | ||
368 | p = ioremap(pci_resource_start(dev, 0), pci_resource_len(dev, 0)); | 369 | p = ioremap_nocache(pci_resource_start(dev, 0), |
370 | pci_resource_len(dev, 0)); | ||
369 | /* FIXME: What if resource_len < OCT_REG_CR_OFF */ | 371 | /* FIXME: What if resource_len < OCT_REG_CR_OFF */ |
370 | if (p != NULL) | 372 | if (p != NULL) |
371 | writeb(0, p + OCT_REG_CR_OFF); | 373 | writeb(0, p + OCT_REG_CR_OFF); |
@@ -419,7 +421,7 @@ static int pci_siig10x_init(struct pci_dev *dev) | |||
419 | break; | 421 | break; |
420 | } | 422 | } |
421 | 423 | ||
422 | p = ioremap(pci_resource_start(dev, 0), 0x80); | 424 | p = ioremap_nocache(pci_resource_start(dev, 0), 0x80); |
423 | if (p == NULL) | 425 | if (p == NULL) |
424 | return -ENOMEM; | 426 | return -ENOMEM; |
425 | 427 | ||
diff --git a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h index 12c934a1f274..8871aaa3dba6 100644 --- a/drivers/serial/jsm/jsm.h +++ b/drivers/serial/jsm/jsm.h | |||
@@ -373,6 +373,7 @@ struct neo_uart_struct { | |||
373 | #define PCI_DEVICE_NEO_2DB9PRI_PCI_NAME "Neo 2 - DB9 Universal PCI - Powered Ring Indicator" | 373 | #define PCI_DEVICE_NEO_2DB9PRI_PCI_NAME "Neo 2 - DB9 Universal PCI - Powered Ring Indicator" |
374 | #define PCI_DEVICE_NEO_2RJ45_PCI_NAME "Neo 2 - RJ45 Universal PCI" | 374 | #define PCI_DEVICE_NEO_2RJ45_PCI_NAME "Neo 2 - RJ45 Universal PCI" |
375 | #define PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME "Neo 2 - RJ45 Universal PCI - Powered Ring Indicator" | 375 | #define PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME "Neo 2 - RJ45 Universal PCI - Powered Ring Indicator" |
376 | #define PCIE_DEVICE_NEO_IBM_PCI_NAME "Neo 4 - PCI Express - IBM" | ||
376 | 377 | ||
377 | /* | 378 | /* |
378 | * Our Global Variables. | 379 | * Our Global Variables. |
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c index 6767ee381cd1..338cf8a08b43 100644 --- a/drivers/serial/jsm/jsm_driver.c +++ b/drivers/serial/jsm/jsm_driver.c | |||
@@ -82,7 +82,10 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
82 | /* store the info for the board we've found */ | 82 | /* store the info for the board we've found */ |
83 | brd->boardnum = adapter_count++; | 83 | brd->boardnum = adapter_count++; |
84 | brd->pci_dev = pdev; | 84 | brd->pci_dev = pdev; |
85 | brd->maxports = 2; | 85 | if (pdev->device == PCIE_DEVICE_ID_NEO_4_IBM) |
86 | brd->maxports = 4; | ||
87 | else | ||
88 | brd->maxports = 2; | ||
86 | 89 | ||
87 | spin_lock_init(&brd->bd_lock); | 90 | spin_lock_init(&brd->bd_lock); |
88 | spin_lock_init(&brd->bd_intr_lock); | 91 | spin_lock_init(&brd->bd_intr_lock); |
@@ -208,6 +211,7 @@ static struct pci_device_id jsm_pci_tbl[] = { | |||
208 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2DB9PRI), 0, 0, 1 }, | 211 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2DB9PRI), 0, 0, 1 }, |
209 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45), 0, 0, 2 }, | 212 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45), 0, 0, 2 }, |
210 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45PRI), 0, 0, 3 }, | 213 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45PRI), 0, 0, 3 }, |
214 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCIE_DEVICE_ID_NEO_4_IBM), 0, 0, 4 }, | ||
211 | { 0, } | 215 | { 0, } |
212 | }; | 216 | }; |
213 | MODULE_DEVICE_TABLE(pci, jsm_pci_tbl); | 217 | MODULE_DEVICE_TABLE(pci, jsm_pci_tbl); |
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 7a3625f52a03..efc971d9647b 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -783,7 +783,9 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
783 | } | 783 | } |
784 | } | 784 | } |
785 | 785 | ||
786 | spin_unlock(&port->lock); | ||
786 | tty_flip_buffer_push(tty); | 787 | tty_flip_buffer_push(tty); |
788 | spin_lock(&port->lock); | ||
787 | 789 | ||
788 | return psc_ops->raw_rx_rdy(port); | 790 | return psc_ops->raw_rx_rdy(port); |
789 | } | 791 | } |
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c index be0fe152891b..145c0281495d 100644 --- a/drivers/serial/sunhv.c +++ b/drivers/serial/sunhv.c | |||
@@ -392,7 +392,7 @@ static struct uart_ops sunhv_pops = { | |||
392 | 392 | ||
393 | static struct uart_driver sunhv_reg = { | 393 | static struct uart_driver sunhv_reg = { |
394 | .owner = THIS_MODULE, | 394 | .owner = THIS_MODULE, |
395 | .driver_name = "serial", | 395 | .driver_name = "sunhv", |
396 | .dev_name = "ttyS", | 396 | .dev_name = "ttyS", |
397 | .major = TTY_MAJOR, | 397 | .major = TTY_MAJOR, |
398 | }; | 398 | }; |
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index 543f93741e6f..9ff5b38f3bee 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c | |||
@@ -826,7 +826,7 @@ static struct uart_ops sunsab_pops = { | |||
826 | 826 | ||
827 | static struct uart_driver sunsab_reg = { | 827 | static struct uart_driver sunsab_reg = { |
828 | .owner = THIS_MODULE, | 828 | .owner = THIS_MODULE, |
829 | .driver_name = "serial", | 829 | .driver_name = "sunsab", |
830 | .dev_name = "ttyS", | 830 | .dev_name = "ttyS", |
831 | .major = TTY_MAJOR, | 831 | .major = TTY_MAJOR, |
832 | }; | 832 | }; |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 4e2302d43ab1..03806a935209 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -1173,7 +1173,7 @@ out: | |||
1173 | 1173 | ||
1174 | static struct uart_driver sunsu_reg = { | 1174 | static struct uart_driver sunsu_reg = { |
1175 | .owner = THIS_MODULE, | 1175 | .owner = THIS_MODULE, |
1176 | .driver_name = "serial", | 1176 | .driver_name = "sunsu", |
1177 | .dev_name = "ttyS", | 1177 | .dev_name = "ttyS", |
1178 | .major = TTY_MAJOR, | 1178 | .major = TTY_MAJOR, |
1179 | }; | 1179 | }; |
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index 90a20a152ebf..7e9fa5ef0eb7 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c | |||
@@ -1023,7 +1023,7 @@ static struct uart_sunzilog_port *sunzilog_irq_chain; | |||
1023 | 1023 | ||
1024 | static struct uart_driver sunzilog_reg = { | 1024 | static struct uart_driver sunzilog_reg = { |
1025 | .owner = THIS_MODULE, | 1025 | .owner = THIS_MODULE, |
1026 | .driver_name = "ttyS", | 1026 | .driver_name = "sunzilog", |
1027 | .dev_name = "ttyS", | 1027 | .dev_name = "ttyS", |
1028 | .major = TTY_MAJOR, | 1028 | .major = TTY_MAJOR, |
1029 | }; | 1029 | }; |
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c index a9ac1fdb3094..7fea3cf4588a 100644 --- a/drivers/spi/spi_bfin5xx.c +++ b/drivers/spi/spi_bfin5xx.c | |||
@@ -608,6 +608,7 @@ static void pump_transfers(unsigned long data) | |||
608 | u8 width; | 608 | u8 width; |
609 | u16 cr, dma_width, dma_config; | 609 | u16 cr, dma_width, dma_config; |
610 | u32 tranf_success = 1; | 610 | u32 tranf_success = 1; |
611 | u8 full_duplex = 0; | ||
611 | 612 | ||
612 | /* Get current state information */ | 613 | /* Get current state information */ |
613 | message = drv_data->cur_msg; | 614 | message = drv_data->cur_msg; |
@@ -658,6 +659,7 @@ static void pump_transfers(unsigned long data) | |||
658 | } | 659 | } |
659 | 660 | ||
660 | if (transfer->rx_buf != NULL) { | 661 | if (transfer->rx_buf != NULL) { |
662 | full_duplex = transfer->tx_buf != NULL; | ||
661 | drv_data->rx = transfer->rx_buf; | 663 | drv_data->rx = transfer->rx_buf; |
662 | drv_data->rx_end = drv_data->rx + transfer->len; | 664 | drv_data->rx_end = drv_data->rx + transfer->len; |
663 | dev_dbg(&drv_data->pdev->dev, "rx_buf is %p, rx_end is %p\n", | 665 | dev_dbg(&drv_data->pdev->dev, "rx_buf is %p, rx_end is %p\n", |
@@ -740,7 +742,8 @@ static void pump_transfers(unsigned long data) | |||
740 | * successful use different way to r/w according to | 742 | * successful use different way to r/w according to |
741 | * drv_data->cur_chip->enable_dma | 743 | * drv_data->cur_chip->enable_dma |
742 | */ | 744 | */ |
743 | if (drv_data->cur_chip->enable_dma && drv_data->len > 6) { | 745 | if (!full_duplex && drv_data->cur_chip->enable_dma |
746 | && drv_data->len > 6) { | ||
744 | 747 | ||
745 | disable_dma(drv_data->dma_channel); | 748 | disable_dma(drv_data->dma_channel); |
746 | clear_dma_irqstat(drv_data->dma_channel); | 749 | clear_dma_irqstat(drv_data->dma_channel); |
@@ -828,7 +831,7 @@ static void pump_transfers(unsigned long data) | |||
828 | /* IO mode write then read */ | 831 | /* IO mode write then read */ |
829 | dev_dbg(&drv_data->pdev->dev, "doing IO transfer\n"); | 832 | dev_dbg(&drv_data->pdev->dev, "doing IO transfer\n"); |
830 | 833 | ||
831 | if (drv_data->tx != NULL && drv_data->rx != NULL) { | 834 | if (full_duplex) { |
832 | /* full duplex mode */ | 835 | /* full duplex mode */ |
833 | BUG_ON((drv_data->tx_end - drv_data->tx) != | 836 | BUG_ON((drv_data->tx_end - drv_data->tx) != |
834 | (drv_data->rx_end - drv_data->rx)); | 837 | (drv_data->rx_end - drv_data->rx)); |
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c index 34bfb7dd7764..0885cc357a37 100644 --- a/drivers/spi/spi_s3c24xx.c +++ b/drivers/spi/spi_s3c24xx.c | |||
@@ -125,10 +125,10 @@ static int s3c24xx_spi_setupxfer(struct spi_device *spi, | |||
125 | /* is clk = pclk / (2 * (pre+1)), or is it | 125 | /* is clk = pclk / (2 * (pre+1)), or is it |
126 | * clk = (pclk * 2) / ( pre + 1) */ | 126 | * clk = (pclk * 2) / ( pre + 1) */ |
127 | 127 | ||
128 | div = (div / 2) - 1; | 128 | div /= 2; |
129 | 129 | ||
130 | if (div < 0) | 130 | if (div > 0) |
131 | div = 1; | 131 | div -= 1; |
132 | 132 | ||
133 | if (div > 255) | 133 | if (div > 255) |
134 | div = 255; | 134 | div = 255; |
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile index 516a6400db43..a419c42e880e 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile | |||
@@ -17,6 +17,8 @@ obj-$(CONFIG_USB_SL811_HCD) += host/ | |||
17 | obj-$(CONFIG_USB_U132_HCD) += host/ | 17 | obj-$(CONFIG_USB_U132_HCD) += host/ |
18 | obj-$(CONFIG_USB_R8A66597_HCD) += host/ | 18 | obj-$(CONFIG_USB_R8A66597_HCD) += host/ |
19 | 19 | ||
20 | obj-$(CONFIG_USB_C67X00_HCD) += c67x00/ | ||
21 | |||
20 | obj-$(CONFIG_USB_ACM) += class/ | 22 | obj-$(CONFIG_USB_ACM) += class/ |
21 | obj-$(CONFIG_USB_PRINTER) += class/ | 23 | obj-$(CONFIG_USB_PRINTER) += class/ |
22 | 24 | ||
diff --git a/drivers/usb/atm/Kconfig b/drivers/usb/atm/Kconfig index 86e64035edb0..be0b8daac9c7 100644 --- a/drivers/usb/atm/Kconfig +++ b/drivers/usb/atm/Kconfig | |||
@@ -19,7 +19,6 @@ if USB_ATM | |||
19 | 19 | ||
20 | config USB_SPEEDTOUCH | 20 | config USB_SPEEDTOUCH |
21 | tristate "Speedtouch USB support" | 21 | tristate "Speedtouch USB support" |
22 | depends on USB_ATM | ||
23 | select FW_LOADER | 22 | select FW_LOADER |
24 | help | 23 | help |
25 | Say Y here if you have an SpeedTouch USB or SpeedTouch 330 | 24 | Say Y here if you have an SpeedTouch USB or SpeedTouch 330 |
@@ -32,7 +31,6 @@ config USB_SPEEDTOUCH | |||
32 | 31 | ||
33 | config USB_CXACRU | 32 | config USB_CXACRU |
34 | tristate "Conexant AccessRunner USB support" | 33 | tristate "Conexant AccessRunner USB support" |
35 | depends on USB_ATM | ||
36 | select FW_LOADER | 34 | select FW_LOADER |
37 | help | 35 | help |
38 | Say Y here if you have an ADSL USB modem based on the Conexant | 36 | Say Y here if you have an ADSL USB modem based on the Conexant |
@@ -45,7 +43,6 @@ config USB_CXACRU | |||
45 | 43 | ||
46 | config USB_UEAGLEATM | 44 | config USB_UEAGLEATM |
47 | tristate "ADI 930 and eagle USB DSL modem" | 45 | tristate "ADI 930 and eagle USB DSL modem" |
48 | depends on USB_ATM | ||
49 | select FW_LOADER | 46 | select FW_LOADER |
50 | help | 47 | help |
51 | Say Y here if you have an ADSL USB modem based on the ADI 930 | 48 | Say Y here if you have an ADSL USB modem based on the ADI 930 |
@@ -58,7 +55,6 @@ config USB_UEAGLEATM | |||
58 | 55 | ||
59 | config USB_XUSBATM | 56 | config USB_XUSBATM |
60 | tristate "Other USB DSL modem support" | 57 | tristate "Other USB DSL modem support" |
61 | depends on USB_ATM | ||
62 | help | 58 | help |
63 | Say Y here if you have a DSL USB modem not explicitly supported by | 59 | Say Y here if you have a DSL USB modem not explicitly supported by |
64 | another USB DSL drivers. In order to use your modem you will need to | 60 | another USB DSL drivers. In order to use your modem you will need to |
diff --git a/drivers/usb/c67x00/Makefile b/drivers/usb/c67x00/Makefile new file mode 100644 index 000000000000..868bc41b5980 --- /dev/null +++ b/drivers/usb/c67x00/Makefile | |||
@@ -0,0 +1,9 @@ | |||
1 | # | ||
2 | # Makefile for Cypress C67X00 USB Controller | ||
3 | # | ||
4 | |||
5 | ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG | ||
6 | |||
7 | obj-$(CONFIG_USB_C67X00_HCD) += c67x00.o | ||
8 | |||
9 | c67x00-objs := c67x00-drv.o c67x00-ll-hpi.o c67x00-hcd.o c67x00-sched.o | ||
diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c new file mode 100644 index 000000000000..5633bc5c8bf2 --- /dev/null +++ b/drivers/usb/c67x00/c67x00-drv.c | |||
@@ -0,0 +1,243 @@ | |||
1 | /* | ||
2 | * c67x00-drv.c: Cypress C67X00 USB Common infrastructure | ||
3 | * | ||
4 | * Copyright (C) 2006-2008 Barco N.V. | ||
5 | * Derived from the Cypress cy7c67200/300 ezusb linux driver and | ||
6 | * based on multiple host controller drivers inside the linux kernel. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
21 | * MA 02110-1301 USA. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | * This file implements the common infrastructure for using the c67x00. | ||
26 | * It is both the link between the platform configuration and subdrivers and | ||
27 | * the link between the common hardware parts and the subdrivers (e.g. | ||
28 | * interrupt handling). | ||
29 | * | ||
30 | * The c67x00 has 2 SIE's (serial interface engine) wich can be configured | ||
31 | * to be host, device or OTG (with some limitations, E.G. only SIE1 can be OTG). | ||
32 | * | ||
33 | * Depending on the platform configuration, the SIE's are created and | ||
34 | * the corresponding subdriver is initialized (c67x00_probe_sie). | ||
35 | */ | ||
36 | |||
37 | #include <linux/device.h> | ||
38 | #include <linux/io.h> | ||
39 | #include <linux/list.h> | ||
40 | #include <linux/usb.h> | ||
41 | #include <linux/usb/c67x00.h> | ||
42 | |||
43 | #include "c67x00.h" | ||
44 | #include "c67x00-hcd.h" | ||
45 | |||
46 | static void c67x00_probe_sie(struct c67x00_sie *sie, | ||
47 | struct c67x00_device *dev, int sie_num) | ||
48 | { | ||
49 | spin_lock_init(&sie->lock); | ||
50 | sie->dev = dev; | ||
51 | sie->sie_num = sie_num; | ||
52 | sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num); | ||
53 | |||
54 | switch (sie->mode) { | ||
55 | case C67X00_SIE_HOST: | ||
56 | c67x00_hcd_probe(sie); | ||
57 | break; | ||
58 | |||
59 | case C67X00_SIE_UNUSED: | ||
60 | dev_info(sie_dev(sie), | ||
61 | "Not using SIE %d as requested\n", sie->sie_num); | ||
62 | break; | ||
63 | |||
64 | default: | ||
65 | dev_err(sie_dev(sie), | ||
66 | "Unsupported configuration: 0x%x for SIE %d\n", | ||
67 | sie->mode, sie->sie_num); | ||
68 | break; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | static void c67x00_remove_sie(struct c67x00_sie *sie) | ||
73 | { | ||
74 | switch (sie->mode) { | ||
75 | case C67X00_SIE_HOST: | ||
76 | c67x00_hcd_remove(sie); | ||
77 | break; | ||
78 | |||
79 | default: | ||
80 | break; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | static irqreturn_t c67x00_irq(int irq, void *__dev) | ||
85 | { | ||
86 | struct c67x00_device *c67x00 = __dev; | ||
87 | struct c67x00_sie *sie; | ||
88 | u16 msg, int_status; | ||
89 | int i, count = 8; | ||
90 | |||
91 | int_status = c67x00_ll_hpi_status(c67x00); | ||
92 | if (!int_status) | ||
93 | return IRQ_NONE; | ||
94 | |||
95 | while (int_status != 0 && (count-- >= 0)) { | ||
96 | c67x00_ll_irq(c67x00, int_status); | ||
97 | for (i = 0; i < C67X00_SIES; i++) { | ||
98 | sie = &c67x00->sie[i]; | ||
99 | msg = 0; | ||
100 | if (int_status & SIEMSG_FLG(i)) | ||
101 | msg = c67x00_ll_fetch_siemsg(c67x00, i); | ||
102 | if (sie->irq) | ||
103 | sie->irq(sie, int_status, msg); | ||
104 | } | ||
105 | int_status = c67x00_ll_hpi_status(c67x00); | ||
106 | } | ||
107 | |||
108 | if (int_status) | ||
109 | dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! " | ||
110 | "status = 0x%04x\n", int_status); | ||
111 | |||
112 | return IRQ_HANDLED; | ||
113 | } | ||
114 | |||
115 | /* ------------------------------------------------------------------------- */ | ||
116 | |||
117 | static int __devinit c67x00_drv_probe(struct platform_device *pdev) | ||
118 | { | ||
119 | struct c67x00_device *c67x00; | ||
120 | struct c67x00_platform_data *pdata; | ||
121 | struct resource *res, *res2; | ||
122 | int ret, i; | ||
123 | |||
124 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
125 | if (!res) | ||
126 | return -ENODEV; | ||
127 | |||
128 | res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
129 | if (!res2) | ||
130 | return -ENODEV; | ||
131 | |||
132 | pdata = pdev->dev.platform_data; | ||
133 | if (!pdata) | ||
134 | return -ENODEV; | ||
135 | |||
136 | c67x00 = kzalloc(sizeof(*c67x00), GFP_KERNEL); | ||
137 | if (!c67x00) | ||
138 | return -ENOMEM; | ||
139 | |||
140 | if (!request_mem_region(res->start, res->end - res->start + 1, | ||
141 | pdev->name)) { | ||
142 | dev_err(&pdev->dev, "Memory region busy\n"); | ||
143 | ret = -EBUSY; | ||
144 | goto request_mem_failed; | ||
145 | } | ||
146 | c67x00->hpi.base = ioremap(res->start, res->end - res->start + 1); | ||
147 | if (!c67x00->hpi.base) { | ||
148 | dev_err(&pdev->dev, "Unable to map HPI registers\n"); | ||
149 | ret = -EIO; | ||
150 | goto map_failed; | ||
151 | } | ||
152 | |||
153 | spin_lock_init(&c67x00->hpi.lock); | ||
154 | c67x00->hpi.regstep = pdata->hpi_regstep; | ||
155 | c67x00->pdata = pdev->dev.platform_data; | ||
156 | c67x00->pdev = pdev; | ||
157 | |||
158 | c67x00_ll_init(c67x00); | ||
159 | c67x00_ll_hpi_reg_init(c67x00); | ||
160 | |||
161 | ret = request_irq(res2->start, c67x00_irq, 0, pdev->name, c67x00); | ||
162 | if (ret) { | ||
163 | dev_err(&pdev->dev, "Cannot claim IRQ\n"); | ||
164 | goto request_irq_failed; | ||
165 | } | ||
166 | |||
167 | ret = c67x00_ll_reset(c67x00); | ||
168 | if (ret) { | ||
169 | dev_err(&pdev->dev, "Device reset failed\n"); | ||
170 | goto reset_failed; | ||
171 | } | ||
172 | |||
173 | for (i = 0; i < C67X00_SIES; i++) | ||
174 | c67x00_probe_sie(&c67x00->sie[i], c67x00, i); | ||
175 | |||
176 | platform_set_drvdata(pdev, c67x00); | ||
177 | |||
178 | return 0; | ||
179 | |||
180 | reset_failed: | ||
181 | free_irq(res2->start, c67x00); | ||
182 | request_irq_failed: | ||
183 | iounmap(c67x00->hpi.base); | ||
184 | map_failed: | ||
185 | release_mem_region(res->start, res->end - res->start + 1); | ||
186 | request_mem_failed: | ||
187 | kfree(c67x00); | ||
188 | |||
189 | return ret; | ||
190 | } | ||
191 | |||
192 | static int __devexit c67x00_drv_remove(struct platform_device *pdev) | ||
193 | { | ||
194 | struct c67x00_device *c67x00 = platform_get_drvdata(pdev); | ||
195 | struct resource *res; | ||
196 | int i; | ||
197 | |||
198 | for (i = 0; i < C67X00_SIES; i++) | ||
199 | c67x00_remove_sie(&c67x00->sie[i]); | ||
200 | |||
201 | c67x00_ll_release(c67x00); | ||
202 | |||
203 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
204 | if (res) | ||
205 | free_irq(res->start, c67x00); | ||
206 | |||
207 | iounmap(c67x00->hpi.base); | ||
208 | |||
209 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
210 | if (res) | ||
211 | release_mem_region(res->start, res->end - res->start + 1); | ||
212 | |||
213 | kfree(c67x00); | ||
214 | |||
215 | return 0; | ||
216 | } | ||
217 | |||
218 | static struct platform_driver c67x00_driver = { | ||
219 | .probe = c67x00_drv_probe, | ||
220 | .remove = __devexit_p(c67x00_drv_remove), | ||
221 | .driver = { | ||
222 | .owner = THIS_MODULE, | ||
223 | .name = "c67x00", | ||
224 | }, | ||
225 | }; | ||
226 | MODULE_ALIAS("platform:c67x00"); | ||
227 | |||
228 | static int __init c67x00_init(void) | ||
229 | { | ||
230 | return platform_driver_register(&c67x00_driver); | ||
231 | } | ||
232 | |||
233 | static void __exit c67x00_exit(void) | ||
234 | { | ||
235 | platform_driver_unregister(&c67x00_driver); | ||
236 | } | ||
237 | |||
238 | module_init(c67x00_init); | ||
239 | module_exit(c67x00_exit); | ||
240 | |||
241 | MODULE_AUTHOR("Peter Korsgaard, Jan Veldeman, Grant Likely"); | ||
242 | MODULE_DESCRIPTION("Cypress C67X00 USB Controller Driver"); | ||
243 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/c67x00/c67x00-hcd.c b/drivers/usb/c67x00/c67x00-hcd.c new file mode 100644 index 000000000000..a22b887f4e9e --- /dev/null +++ b/drivers/usb/c67x00/c67x00-hcd.c | |||
@@ -0,0 +1,412 @@ | |||
1 | /* | ||
2 | * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver | ||
3 | * | ||
4 | * Copyright (C) 2006-2008 Barco N.V. | ||
5 | * Derived from the Cypress cy7c67200/300 ezusb linux driver and | ||
6 | * based on multiple host controller drivers inside the linux kernel. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
21 | * MA 02110-1301 USA. | ||
22 | */ | ||
23 | |||
24 | #include <linux/device.h> | ||
25 | #include <linux/platform_device.h> | ||
26 | #include <linux/usb.h> | ||
27 | |||
28 | #include "c67x00.h" | ||
29 | #include "c67x00-hcd.h" | ||
30 | |||
31 | /* -------------------------------------------------------------------------- | ||
32 | * Root Hub Support | ||
33 | */ | ||
34 | |||
35 | static __u8 c67x00_hub_des[] = { | ||
36 | 0x09, /* __u8 bLength; */ | ||
37 | 0x29, /* __u8 bDescriptorType; Hub-descriptor */ | ||
38 | 0x02, /* __u8 bNbrPorts; */ | ||
39 | 0x00, /* __u16 wHubCharacteristics; */ | ||
40 | 0x00, /* (per-port OC, no power switching) */ | ||
41 | 0x32, /* __u8 bPwrOn2pwrGood; 2ms */ | ||
42 | 0x00, /* __u8 bHubContrCurrent; 0 mA */ | ||
43 | 0x00, /* __u8 DeviceRemovable; ** 7 Ports max ** */ | ||
44 | 0xff, /* __u8 PortPwrCtrlMask; ** 7 ports max ** */ | ||
45 | }; | ||
46 | |||
47 | static void c67x00_hub_reset_host_port(struct c67x00_sie *sie, int port) | ||
48 | { | ||
49 | struct c67x00_hcd *c67x00 = sie->private_data; | ||
50 | unsigned long flags; | ||
51 | |||
52 | c67x00_ll_husb_reset(sie, port); | ||
53 | |||
54 | spin_lock_irqsave(&c67x00->lock, flags); | ||
55 | c67x00_ll_husb_reset_port(sie, port); | ||
56 | spin_unlock_irqrestore(&c67x00->lock, flags); | ||
57 | |||
58 | c67x00_ll_set_husb_eot(sie->dev, DEFAULT_EOT); | ||
59 | } | ||
60 | |||
61 | static int c67x00_hub_status_data(struct usb_hcd *hcd, char *buf) | ||
62 | { | ||
63 | struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd); | ||
64 | struct c67x00_sie *sie = c67x00->sie; | ||
65 | u16 status; | ||
66 | int i; | ||
67 | |||
68 | *buf = 0; | ||
69 | status = c67x00_ll_usb_get_status(sie); | ||
70 | for (i = 0; i < C67X00_PORTS; i++) | ||
71 | if (status & PORT_CONNECT_CHANGE(i)) | ||
72 | *buf |= (1 << i); | ||
73 | |||
74 | /* bit 0 denotes hub change, b1..n port change */ | ||
75 | *buf <<= 1; | ||
76 | |||
77 | return !!*buf; | ||
78 | } | ||
79 | |||
80 | static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | ||
81 | u16 wIndex, char *buf, u16 wLength) | ||
82 | { | ||
83 | struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd); | ||
84 | struct c67x00_sie *sie = c67x00->sie; | ||
85 | u16 status, usb_status; | ||
86 | int len = 0; | ||
87 | unsigned int port = wIndex-1; | ||
88 | u16 wPortChange, wPortStatus; | ||
89 | |||
90 | switch (typeReq) { | ||
91 | |||
92 | case GetHubStatus: | ||
93 | *(__le32 *) buf = cpu_to_le32(0); | ||
94 | len = 4; /* hub power */ | ||
95 | break; | ||
96 | |||
97 | case GetPortStatus: | ||
98 | if (wIndex > C67X00_PORTS) | ||
99 | return -EPIPE; | ||
100 | |||
101 | status = c67x00_ll_usb_get_status(sie); | ||
102 | usb_status = c67x00_ll_get_usb_ctl(sie); | ||
103 | |||
104 | wPortChange = 0; | ||
105 | if (status & PORT_CONNECT_CHANGE(port)) | ||
106 | wPortChange |= USB_PORT_STAT_C_CONNECTION; | ||
107 | |||
108 | wPortStatus = USB_PORT_STAT_POWER; | ||
109 | if (!(status & PORT_SE0_STATUS(port))) | ||
110 | wPortStatus |= USB_PORT_STAT_CONNECTION; | ||
111 | if (usb_status & LOW_SPEED_PORT(port)) { | ||
112 | wPortStatus |= USB_PORT_STAT_LOW_SPEED; | ||
113 | c67x00->low_speed_ports |= (1 << port); | ||
114 | } else | ||
115 | c67x00->low_speed_ports &= ~(1 << port); | ||
116 | |||
117 | if (usb_status & SOF_EOP_EN(port)) | ||
118 | wPortStatus |= USB_PORT_STAT_ENABLE; | ||
119 | |||
120 | *(__le16 *) buf = cpu_to_le16(wPortStatus); | ||
121 | *(__le16 *) (buf + 2) = cpu_to_le16(wPortChange); | ||
122 | len = 4; | ||
123 | break; | ||
124 | |||
125 | case SetHubFeature: /* We don't implement these */ | ||
126 | case ClearHubFeature: | ||
127 | switch (wValue) { | ||
128 | case C_HUB_OVER_CURRENT: | ||
129 | case C_HUB_LOCAL_POWER: | ||
130 | len = 0; | ||
131 | break; | ||
132 | |||
133 | default: | ||
134 | return -EPIPE; | ||
135 | } | ||
136 | break; | ||
137 | |||
138 | case SetPortFeature: | ||
139 | if (wIndex > C67X00_PORTS) | ||
140 | return -EPIPE; | ||
141 | |||
142 | switch (wValue) { | ||
143 | case USB_PORT_FEAT_SUSPEND: | ||
144 | dev_dbg(c67x00_hcd_dev(c67x00), | ||
145 | "SetPortFeature %d (SUSPEND)\n", port); | ||
146 | len = 0; | ||
147 | break; | ||
148 | |||
149 | case USB_PORT_FEAT_RESET: | ||
150 | c67x00_hub_reset_host_port(sie, port); | ||
151 | len = 0; | ||
152 | break; | ||
153 | |||
154 | case USB_PORT_FEAT_POWER: | ||
155 | /* Power always enabled */ | ||
156 | len = 0; | ||
157 | break; | ||
158 | |||
159 | default: | ||
160 | dev_dbg(c67x00_hcd_dev(c67x00), | ||
161 | "%s: SetPortFeature %d (0x%04x) Error!\n", | ||
162 | __func__, port, wValue); | ||
163 | return -EPIPE; | ||
164 | } | ||
165 | break; | ||
166 | |||
167 | case ClearPortFeature: | ||
168 | if (wIndex > C67X00_PORTS) | ||
169 | return -EPIPE; | ||
170 | |||
171 | switch (wValue) { | ||
172 | case USB_PORT_FEAT_ENABLE: | ||
173 | /* Reset the port so that the c67x00 also notices the | ||
174 | * disconnect */ | ||
175 | c67x00_hub_reset_host_port(sie, port); | ||
176 | len = 0; | ||
177 | break; | ||
178 | |||
179 | case USB_PORT_FEAT_C_ENABLE: | ||
180 | dev_dbg(c67x00_hcd_dev(c67x00), | ||
181 | "ClearPortFeature (%d): C_ENABLE\n", port); | ||
182 | len = 0; | ||
183 | break; | ||
184 | |||
185 | case USB_PORT_FEAT_SUSPEND: | ||
186 | dev_dbg(c67x00_hcd_dev(c67x00), | ||
187 | "ClearPortFeature (%d): SUSPEND\n", port); | ||
188 | len = 0; | ||
189 | break; | ||
190 | |||
191 | case USB_PORT_FEAT_C_SUSPEND: | ||
192 | dev_dbg(c67x00_hcd_dev(c67x00), | ||
193 | "ClearPortFeature (%d): C_SUSPEND\n", port); | ||
194 | len = 0; | ||
195 | break; | ||
196 | |||
197 | case USB_PORT_FEAT_POWER: | ||
198 | dev_dbg(c67x00_hcd_dev(c67x00), | ||
199 | "ClearPortFeature (%d): POWER\n", port); | ||
200 | return -EPIPE; | ||
201 | |||
202 | case USB_PORT_FEAT_C_CONNECTION: | ||
203 | c67x00_ll_usb_clear_status(sie, | ||
204 | PORT_CONNECT_CHANGE(port)); | ||
205 | len = 0; | ||
206 | break; | ||
207 | |||
208 | case USB_PORT_FEAT_C_OVER_CURRENT: | ||
209 | dev_dbg(c67x00_hcd_dev(c67x00), | ||
210 | "ClearPortFeature (%d): OVER_CURRENT\n", port); | ||
211 | len = 0; | ||
212 | break; | ||
213 | |||
214 | case USB_PORT_FEAT_C_RESET: | ||
215 | dev_dbg(c67x00_hcd_dev(c67x00), | ||
216 | "ClearPortFeature (%d): C_RESET\n", port); | ||
217 | len = 0; | ||
218 | break; | ||
219 | |||
220 | default: | ||
221 | dev_dbg(c67x00_hcd_dev(c67x00), | ||
222 | "%s: ClearPortFeature %d (0x%04x) Error!\n", | ||
223 | __func__, port, wValue); | ||
224 | return -EPIPE; | ||
225 | } | ||
226 | break; | ||
227 | |||
228 | case GetHubDescriptor: | ||
229 | len = min_t(unsigned int, sizeof(c67x00_hub_des), wLength); | ||
230 | memcpy(buf, c67x00_hub_des, len); | ||
231 | break; | ||
232 | |||
233 | default: | ||
234 | dev_dbg(c67x00_hcd_dev(c67x00), "%s: unknown\n", __func__); | ||
235 | return -EPIPE; | ||
236 | } | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | /* --------------------------------------------------------------------- | ||
242 | * Main part of host controller driver | ||
243 | */ | ||
244 | |||
245 | /** | ||
246 | * c67x00_hcd_irq | ||
247 | * | ||
248 | * This function is called from the interrupt handler in c67x00-drv.c | ||
249 | */ | ||
250 | static void c67x00_hcd_irq(struct c67x00_sie *sie, u16 int_status, u16 msg) | ||
251 | { | ||
252 | struct c67x00_hcd *c67x00 = sie->private_data; | ||
253 | struct usb_hcd *hcd = c67x00_hcd_to_hcd(c67x00); | ||
254 | |||
255 | /* Handle sie message flags */ | ||
256 | if (msg) { | ||
257 | if (msg & HUSB_TDListDone) | ||
258 | c67x00_sched_kick(c67x00); | ||
259 | else | ||
260 | dev_warn(c67x00_hcd_dev(c67x00), | ||
261 | "Unknown SIE msg flag(s): 0x%04x\n", msg); | ||
262 | } | ||
263 | |||
264 | if (unlikely(hcd->state == HC_STATE_HALT)) | ||
265 | return; | ||
266 | |||
267 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | ||
268 | return; | ||
269 | |||
270 | /* Handle Start of frame events */ | ||
271 | if (int_status & SOFEOP_FLG(sie->sie_num)) { | ||
272 | c67x00_ll_usb_clear_status(sie, SOF_EOP_IRQ_FLG); | ||
273 | c67x00_sched_kick(c67x00); | ||
274 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
275 | } | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * c67x00_hcd_start: Host controller start hook | ||
280 | */ | ||
281 | static int c67x00_hcd_start(struct usb_hcd *hcd) | ||
282 | { | ||
283 | hcd->uses_new_polling = 1; | ||
284 | hcd->state = HC_STATE_RUNNING; | ||
285 | hcd->poll_rh = 1; | ||
286 | |||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | /** | ||
291 | * c67x00_hcd_stop: Host controller stop hook | ||
292 | */ | ||
293 | static void c67x00_hcd_stop(struct usb_hcd *hcd) | ||
294 | { | ||
295 | /* Nothing to do */ | ||
296 | } | ||
297 | |||
298 | static int c67x00_hcd_get_frame(struct usb_hcd *hcd) | ||
299 | { | ||
300 | struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd); | ||
301 | u16 temp_val; | ||
302 | |||
303 | dev_dbg(c67x00_hcd_dev(c67x00), "%s\n", __func__); | ||
304 | temp_val = c67x00_ll_husb_get_frame(c67x00->sie); | ||
305 | temp_val &= HOST_FRAME_MASK; | ||
306 | return temp_val ? (temp_val - 1) : HOST_FRAME_MASK; | ||
307 | } | ||
308 | |||
309 | static struct hc_driver c67x00_hc_driver = { | ||
310 | .description = "c67x00-hcd", | ||
311 | .product_desc = "Cypress C67X00 Host Controller", | ||
312 | .hcd_priv_size = sizeof(struct c67x00_hcd), | ||
313 | .flags = HCD_USB11 | HCD_MEMORY, | ||
314 | |||
315 | /* | ||
316 | * basic lifecycle operations | ||
317 | */ | ||
318 | .start = c67x00_hcd_start, | ||
319 | .stop = c67x00_hcd_stop, | ||
320 | |||
321 | /* | ||
322 | * managing i/o requests and associated device resources | ||
323 | */ | ||
324 | .urb_enqueue = c67x00_urb_enqueue, | ||
325 | .urb_dequeue = c67x00_urb_dequeue, | ||
326 | .endpoint_disable = c67x00_endpoint_disable, | ||
327 | |||
328 | /* | ||
329 | * scheduling support | ||
330 | */ | ||
331 | .get_frame_number = c67x00_hcd_get_frame, | ||
332 | |||
333 | /* | ||
334 | * root hub support | ||
335 | */ | ||
336 | .hub_status_data = c67x00_hub_status_data, | ||
337 | .hub_control = c67x00_hub_control, | ||
338 | }; | ||
339 | |||
340 | /* --------------------------------------------------------------------- | ||
341 | * Setup/Teardown routines | ||
342 | */ | ||
343 | |||
344 | int c67x00_hcd_probe(struct c67x00_sie *sie) | ||
345 | { | ||
346 | struct c67x00_hcd *c67x00; | ||
347 | struct usb_hcd *hcd; | ||
348 | unsigned long flags; | ||
349 | int retval; | ||
350 | |||
351 | if (usb_disabled()) | ||
352 | return -ENODEV; | ||
353 | |||
354 | hcd = usb_create_hcd(&c67x00_hc_driver, sie_dev(sie), "c67x00_sie"); | ||
355 | if (!hcd) { | ||
356 | retval = -ENOMEM; | ||
357 | goto err0; | ||
358 | } | ||
359 | c67x00 = hcd_to_c67x00_hcd(hcd); | ||
360 | |||
361 | spin_lock_init(&c67x00->lock); | ||
362 | c67x00->sie = sie; | ||
363 | |||
364 | INIT_LIST_HEAD(&c67x00->list[PIPE_ISOCHRONOUS]); | ||
365 | INIT_LIST_HEAD(&c67x00->list[PIPE_INTERRUPT]); | ||
366 | INIT_LIST_HEAD(&c67x00->list[PIPE_CONTROL]); | ||
367 | INIT_LIST_HEAD(&c67x00->list[PIPE_BULK]); | ||
368 | c67x00->urb_count = 0; | ||
369 | INIT_LIST_HEAD(&c67x00->td_list); | ||
370 | c67x00->td_base_addr = CY_HCD_BUF_ADDR + SIE_TD_OFFSET(sie->sie_num); | ||
371 | c67x00->buf_base_addr = CY_HCD_BUF_ADDR + SIE_BUF_OFFSET(sie->sie_num); | ||
372 | c67x00->max_frame_bw = MAX_FRAME_BW_STD; | ||
373 | |||
374 | c67x00_ll_husb_init_host_port(sie); | ||
375 | |||
376 | init_completion(&c67x00->endpoint_disable); | ||
377 | retval = c67x00_sched_start_scheduler(c67x00); | ||
378 | if (retval) | ||
379 | goto err1; | ||
380 | |||
381 | retval = usb_add_hcd(hcd, 0, 0); | ||
382 | if (retval) { | ||
383 | dev_dbg(sie_dev(sie), "%s: usb_add_hcd returned %d\n", | ||
384 | __func__, retval); | ||
385 | goto err2; | ||
386 | } | ||
387 | |||
388 | spin_lock_irqsave(&sie->lock, flags); | ||
389 | sie->private_data = c67x00; | ||
390 | sie->irq = c67x00_hcd_irq; | ||
391 | spin_unlock_irqrestore(&sie->lock, flags); | ||
392 | |||
393 | return retval; | ||
394 | |||
395 | err2: | ||
396 | c67x00_sched_stop_scheduler(c67x00); | ||
397 | err1: | ||
398 | usb_put_hcd(hcd); | ||
399 | err0: | ||
400 | return retval; | ||
401 | } | ||
402 | |||
403 | /* may be called with controller, bus, and devices active */ | ||
404 | void c67x00_hcd_remove(struct c67x00_sie *sie) | ||
405 | { | ||
406 | struct c67x00_hcd *c67x00 = sie->private_data; | ||
407 | struct usb_hcd *hcd = c67x00_hcd_to_hcd(c67x00); | ||
408 | |||
409 | c67x00_sched_stop_scheduler(c67x00); | ||
410 | usb_remove_hcd(hcd); | ||
411 | usb_put_hcd(hcd); | ||
412 | } | ||
diff --git a/drivers/usb/c67x00/c67x00-hcd.h b/drivers/usb/c67x00/c67x00-hcd.h new file mode 100644 index 000000000000..e8c6d94b2514 --- /dev/null +++ b/drivers/usb/c67x00/c67x00-hcd.h | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * c67x00-hcd.h: Cypress C67X00 USB HCD | ||
3 | * | ||
4 | * Copyright (C) 2006-2008 Barco N.V. | ||
5 | * Derived from the Cypress cy7c67200/300 ezusb linux driver and | ||
6 | * based on multiple host controller drivers inside the linux kernel. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
21 | * MA 02110-1301 USA. | ||
22 | */ | ||
23 | |||
24 | #ifndef _USB_C67X00_HCD_H | ||
25 | #define _USB_C67X00_HCD_H | ||
26 | |||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/spinlock.h> | ||
29 | #include <linux/list.h> | ||
30 | #include <linux/usb.h> | ||
31 | #include "../core/hcd.h" | ||
32 | #include "c67x00.h" | ||
33 | |||
34 | /* | ||
35 | * The following parameters depend on the CPU speed, bus speed, ... | ||
36 | * These can be tuned for specific use cases, e.g. if isochronous transfers | ||
37 | * are very important, bandwith can be sacrificed to guarantee that the | ||
38 | * 1ms deadline will be met. | ||
39 | * If bulk transfers are important, the MAX_FRAME_BW can be increased, | ||
40 | * but some (or many) isochronous deadlines might not be met. | ||
41 | * | ||
42 | * The values are specified in bittime. | ||
43 | */ | ||
44 | |||
45 | /* | ||
46 | * The current implementation switches between _STD (default) and _ISO (when | ||
47 | * isochronous transfers are scheduled), in order to optimize the throughput | ||
48 | * in normal cicrumstances, but also provide good isochronous behaviour. | ||
49 | * | ||
50 | * Bandwidth is described in bit time so with a 12MHz USB clock and 1ms | ||
51 | * frames; there are 12000 bit times per frame. | ||
52 | */ | ||
53 | |||
54 | #define TOTAL_FRAME_BW 12000 | ||
55 | #define DEFAULT_EOT 2250 | ||
56 | |||
57 | #define MAX_FRAME_BW_STD (TOTAL_FRAME_BW - DEFAULT_EOT) | ||
58 | #define MAX_FRAME_BW_ISO 2400 | ||
59 | |||
60 | /* | ||
61 | * Periodic transfers may only use 90% of the full frame, but as | ||
62 | * we currently don't even use 90% of the full frame, we may | ||
63 | * use the full usable time for periodic transfers. | ||
64 | */ | ||
65 | #define MAX_PERIODIC_BW(full_bw) full_bw | ||
66 | |||
67 | /* -------------------------------------------------------------------------- */ | ||
68 | |||
69 | struct c67x00_hcd { | ||
70 | spinlock_t lock; | ||
71 | struct c67x00_sie *sie; | ||
72 | unsigned int low_speed_ports; /* bitmask of low speed ports */ | ||
73 | unsigned int urb_count; | ||
74 | unsigned int urb_iso_count; | ||
75 | |||
76 | struct list_head list[4]; /* iso, int, ctrl, bulk */ | ||
77 | #if PIPE_BULK != 3 | ||
78 | #error "Sanity check failed, this code presumes PIPE_... to range from 0 to 3" | ||
79 | #endif | ||
80 | |||
81 | /* USB bandwidth allocated to td_list */ | ||
82 | int bandwidth_allocated; | ||
83 | /* USB bandwidth allocated for isoc/int transfer */ | ||
84 | int periodic_bw_allocated; | ||
85 | struct list_head td_list; | ||
86 | int max_frame_bw; | ||
87 | |||
88 | u16 td_base_addr; | ||
89 | u16 buf_base_addr; | ||
90 | u16 next_td_addr; | ||
91 | u16 next_buf_addr; | ||
92 | |||
93 | struct tasklet_struct tasklet; | ||
94 | |||
95 | struct completion endpoint_disable; | ||
96 | |||
97 | u16 current_frame; | ||
98 | u16 last_frame; | ||
99 | }; | ||
100 | |||
101 | static inline struct c67x00_hcd *hcd_to_c67x00_hcd(struct usb_hcd *hcd) | ||
102 | { | ||
103 | return (struct c67x00_hcd *)(hcd->hcd_priv); | ||
104 | } | ||
105 | |||
106 | static inline struct usb_hcd *c67x00_hcd_to_hcd(struct c67x00_hcd *c67x00) | ||
107 | { | ||
108 | return container_of((void *)c67x00, struct usb_hcd, hcd_priv); | ||
109 | } | ||
110 | |||
111 | /* --------------------------------------------------------------------- | ||
112 | * Functions used by c67x00-drv | ||
113 | */ | ||
114 | |||
115 | int c67x00_hcd_probe(struct c67x00_sie *sie); | ||
116 | void c67x00_hcd_remove(struct c67x00_sie *sie); | ||
117 | |||
118 | /* --------------------------------------------------------------------- | ||
119 | * Transfer Descriptor scheduling functions | ||
120 | */ | ||
121 | int c67x00_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags); | ||
122 | int c67x00_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status); | ||
123 | void c67x00_endpoint_disable(struct usb_hcd *hcd, | ||
124 | struct usb_host_endpoint *ep); | ||
125 | |||
126 | void c67x00_hcd_msg_received(struct c67x00_sie *sie, u16 msg); | ||
127 | void c67x00_sched_kick(struct c67x00_hcd *c67x00); | ||
128 | int c67x00_sched_start_scheduler(struct c67x00_hcd *c67x00); | ||
129 | void c67x00_sched_stop_scheduler(struct c67x00_hcd *c67x00); | ||
130 | |||
131 | #define c67x00_hcd_dev(x) (c67x00_hcd_to_hcd(x)->self.controller) | ||
132 | |||
133 | #endif /* _USB_C67X00_HCD_H */ | ||
diff --git a/drivers/usb/c67x00/c67x00-ll-hpi.c b/drivers/usb/c67x00/c67x00-ll-hpi.c new file mode 100644 index 000000000000..f3430b372f09 --- /dev/null +++ b/drivers/usb/c67x00/c67x00-ll-hpi.c | |||
@@ -0,0 +1,480 @@ | |||
1 | /* | ||
2 | * c67x00-ll-hpi.c: Cypress C67X00 USB Low level interface using HPI | ||
3 | * | ||
4 | * Copyright (C) 2006-2008 Barco N.V. | ||
5 | * Derived from the Cypress cy7c67200/300 ezusb linux driver and | ||
6 | * based on multiple host controller drivers inside the linux kernel. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
21 | * MA 02110-1301 USA. | ||
22 | */ | ||
23 | |||
24 | #include <asm/byteorder.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/usb/c67x00.h> | ||
27 | #include "c67x00.h" | ||
28 | |||
29 | #define COMM_REGS 14 | ||
30 | |||
31 | struct c67x00_lcp_int_data { | ||
32 | u16 regs[COMM_REGS]; | ||
33 | }; | ||
34 | |||
35 | /* -------------------------------------------------------------------------- */ | ||
36 | /* Interface definitions */ | ||
37 | |||
38 | #define COMM_ACK 0x0FED | ||
39 | #define COMM_NAK 0xDEAD | ||
40 | |||
41 | #define COMM_RESET 0xFA50 | ||
42 | #define COMM_EXEC_INT 0xCE01 | ||
43 | #define COMM_INT_NUM 0x01C2 | ||
44 | |||
45 | /* Registers 0 to COMM_REGS-1 */ | ||
46 | #define COMM_R(x) (0x01C4 + 2 * (x)) | ||
47 | |||
48 | #define HUSB_SIE_pCurrentTDPtr(x) ((x) ? 0x01B2 : 0x01B0) | ||
49 | #define HUSB_SIE_pTDListDone_Sem(x) ((x) ? 0x01B8 : 0x01B6) | ||
50 | #define HUSB_pEOT 0x01B4 | ||
51 | |||
52 | /* Software interrupts */ | ||
53 | /* 114, 115: */ | ||
54 | #define HUSB_SIE_INIT_INT(x) ((x) ? 0x0073 : 0x0072) | ||
55 | #define HUSB_RESET_INT 0x0074 | ||
56 | |||
57 | #define SUSB_INIT_INT 0x0071 | ||
58 | #define SUSB_INIT_INT_LOC (SUSB_INIT_INT * 2) | ||
59 | |||
60 | /* ----------------------------------------------------------------------- | ||
61 | * HPI implementation | ||
62 | * | ||
63 | * The c67x00 chip also support control via SPI or HSS serial | ||
64 | * interfaces. However, this driver assumes that register access can | ||
65 | * be performed from IRQ context. While this is a safe assuption with | ||
66 | * the HPI interface, it is not true for the serial interfaces. | ||
67 | */ | ||
68 | |||
69 | /* HPI registers */ | ||
70 | #define HPI_DATA 0 | ||
71 | #define HPI_MAILBOX 1 | ||
72 | #define HPI_ADDR 2 | ||
73 | #define HPI_STATUS 3 | ||
74 | |||
75 | static inline u16 hpi_read_reg(struct c67x00_device *dev, int reg) | ||
76 | { | ||
77 | return __raw_readw(dev->hpi.base + reg * dev->hpi.regstep); | ||
78 | } | ||
79 | |||
80 | static inline void hpi_write_reg(struct c67x00_device *dev, int reg, u16 value) | ||
81 | { | ||
82 | __raw_writew(value, dev->hpi.base + reg * dev->hpi.regstep); | ||
83 | } | ||
84 | |||
85 | static inline u16 hpi_read_word_nolock(struct c67x00_device *dev, u16 reg) | ||
86 | { | ||
87 | hpi_write_reg(dev, HPI_ADDR, reg); | ||
88 | return hpi_read_reg(dev, HPI_DATA); | ||
89 | } | ||
90 | |||
91 | static u16 hpi_read_word(struct c67x00_device *dev, u16 reg) | ||
92 | { | ||
93 | u16 value; | ||
94 | unsigned long flags; | ||
95 | |||
96 | spin_lock_irqsave(&dev->hpi.lock, flags); | ||
97 | value = hpi_read_word_nolock(dev, reg); | ||
98 | spin_unlock_irqrestore(&dev->hpi.lock, flags); | ||
99 | |||
100 | return value; | ||
101 | } | ||
102 | |||
103 | static void hpi_write_word_nolock(struct c67x00_device *dev, u16 reg, u16 value) | ||
104 | { | ||
105 | hpi_write_reg(dev, HPI_ADDR, reg); | ||
106 | hpi_write_reg(dev, HPI_DATA, value); | ||
107 | } | ||
108 | |||
109 | static void hpi_write_word(struct c67x00_device *dev, u16 reg, u16 value) | ||
110 | { | ||
111 | unsigned long flags; | ||
112 | |||
113 | spin_lock_irqsave(&dev->hpi.lock, flags); | ||
114 | hpi_write_word_nolock(dev, reg, value); | ||
115 | spin_unlock_irqrestore(&dev->hpi.lock, flags); | ||
116 | } | ||
117 | |||
118 | /* | ||
119 | * Only data is little endian, addr has cpu endianess | ||
120 | */ | ||
121 | static void hpi_write_words_le16(struct c67x00_device *dev, u16 addr, | ||
122 | u16 *data, u16 count) | ||
123 | { | ||
124 | unsigned long flags; | ||
125 | int i; | ||
126 | |||
127 | spin_lock_irqsave(&dev->hpi.lock, flags); | ||
128 | |||
129 | hpi_write_reg(dev, HPI_ADDR, addr); | ||
130 | for (i = 0; i < count; i++) | ||
131 | hpi_write_reg(dev, HPI_DATA, cpu_to_le16(*data++)); | ||
132 | |||
133 | spin_unlock_irqrestore(&dev->hpi.lock, flags); | ||
134 | } | ||
135 | |||
136 | /* | ||
137 | * Only data is little endian, addr has cpu endianess | ||
138 | */ | ||
139 | static void hpi_read_words_le16(struct c67x00_device *dev, u16 addr, | ||
140 | u16 *data, u16 count) | ||
141 | { | ||
142 | unsigned long flags; | ||
143 | int i; | ||
144 | |||
145 | spin_lock_irqsave(&dev->hpi.lock, flags); | ||
146 | hpi_write_reg(dev, HPI_ADDR, addr); | ||
147 | for (i = 0; i < count; i++) | ||
148 | *data++ = le16_to_cpu(hpi_read_reg(dev, HPI_DATA)); | ||
149 | |||
150 | spin_unlock_irqrestore(&dev->hpi.lock, flags); | ||
151 | } | ||
152 | |||
153 | static void hpi_set_bits(struct c67x00_device *dev, u16 reg, u16 mask) | ||
154 | { | ||
155 | u16 value; | ||
156 | unsigned long flags; | ||
157 | |||
158 | spin_lock_irqsave(&dev->hpi.lock, flags); | ||
159 | value = hpi_read_word_nolock(dev, reg); | ||
160 | hpi_write_word_nolock(dev, reg, value | mask); | ||
161 | spin_unlock_irqrestore(&dev->hpi.lock, flags); | ||
162 | } | ||
163 | |||
164 | static void hpi_clear_bits(struct c67x00_device *dev, u16 reg, u16 mask) | ||
165 | { | ||
166 | u16 value; | ||
167 | unsigned long flags; | ||
168 | |||
169 | spin_lock_irqsave(&dev->hpi.lock, flags); | ||
170 | value = hpi_read_word_nolock(dev, reg); | ||
171 | hpi_write_word_nolock(dev, reg, value & ~mask); | ||
172 | spin_unlock_irqrestore(&dev->hpi.lock, flags); | ||
173 | } | ||
174 | |||
175 | static u16 hpi_recv_mbox(struct c67x00_device *dev) | ||
176 | { | ||
177 | u16 value; | ||
178 | unsigned long flags; | ||
179 | |||
180 | spin_lock_irqsave(&dev->hpi.lock, flags); | ||
181 | value = hpi_read_reg(dev, HPI_MAILBOX); | ||
182 | spin_unlock_irqrestore(&dev->hpi.lock, flags); | ||
183 | |||
184 | return value; | ||
185 | } | ||
186 | |||
187 | static u16 hpi_send_mbox(struct c67x00_device *dev, u16 value) | ||
188 | { | ||
189 | unsigned long flags; | ||
190 | |||
191 | spin_lock_irqsave(&dev->hpi.lock, flags); | ||
192 | hpi_write_reg(dev, HPI_MAILBOX, value); | ||
193 | spin_unlock_irqrestore(&dev->hpi.lock, flags); | ||
194 | |||
195 | return value; | ||
196 | } | ||
197 | |||
198 | u16 c67x00_ll_hpi_status(struct c67x00_device *dev) | ||
199 | { | ||
200 | u16 value; | ||
201 | unsigned long flags; | ||
202 | |||
203 | spin_lock_irqsave(&dev->hpi.lock, flags); | ||
204 | value = hpi_read_reg(dev, HPI_STATUS); | ||
205 | spin_unlock_irqrestore(&dev->hpi.lock, flags); | ||
206 | |||
207 | return value; | ||
208 | } | ||
209 | |||
210 | void c67x00_ll_hpi_reg_init(struct c67x00_device *dev) | ||
211 | { | ||
212 | int i; | ||
213 | |||
214 | hpi_recv_mbox(dev); | ||
215 | c67x00_ll_hpi_status(dev); | ||
216 | hpi_write_word(dev, HPI_IRQ_ROUTING_REG, 0); | ||
217 | |||
218 | for (i = 0; i < C67X00_SIES; i++) { | ||
219 | hpi_write_word(dev, SIEMSG_REG(i), 0); | ||
220 | hpi_read_word(dev, SIEMSG_REG(i)); | ||
221 | } | ||
222 | } | ||
223 | |||
224 | void c67x00_ll_hpi_enable_sofeop(struct c67x00_sie *sie) | ||
225 | { | ||
226 | hpi_set_bits(sie->dev, HPI_IRQ_ROUTING_REG, | ||
227 | SOFEOP_TO_HPI_EN(sie->sie_num)); | ||
228 | } | ||
229 | |||
230 | void c67x00_ll_hpi_disable_sofeop(struct c67x00_sie *sie) | ||
231 | { | ||
232 | hpi_clear_bits(sie->dev, HPI_IRQ_ROUTING_REG, | ||
233 | SOFEOP_TO_HPI_EN(sie->sie_num)); | ||
234 | } | ||
235 | |||
236 | /* -------------------------------------------------------------------------- */ | ||
237 | /* Transactions */ | ||
238 | |||
239 | static inline u16 ll_recv_msg(struct c67x00_device *dev) | ||
240 | { | ||
241 | u16 res; | ||
242 | |||
243 | res = wait_for_completion_timeout(&dev->hpi.lcp.msg_received, 5 * HZ); | ||
244 | WARN_ON(!res); | ||
245 | |||
246 | return (res == 0) ? -EIO : 0; | ||
247 | } | ||
248 | |||
249 | /* -------------------------------------------------------------------------- */ | ||
250 | /* General functions */ | ||
251 | |||
252 | u16 c67x00_ll_fetch_siemsg(struct c67x00_device *dev, int sie_num) | ||
253 | { | ||
254 | u16 val; | ||
255 | |||
256 | val = hpi_read_word(dev, SIEMSG_REG(sie_num)); | ||
257 | /* clear register to allow next message */ | ||
258 | hpi_write_word(dev, SIEMSG_REG(sie_num), 0); | ||
259 | |||
260 | return val; | ||
261 | } | ||
262 | |||
263 | u16 c67x00_ll_get_usb_ctl(struct c67x00_sie *sie) | ||
264 | { | ||
265 | return hpi_read_word(sie->dev, USB_CTL_REG(sie->sie_num)); | ||
266 | } | ||
267 | |||
268 | /** | ||
269 | * c67x00_ll_usb_clear_status - clear the USB status bits | ||
270 | */ | ||
271 | void c67x00_ll_usb_clear_status(struct c67x00_sie *sie, u16 bits) | ||
272 | { | ||
273 | hpi_write_word(sie->dev, USB_STAT_REG(sie->sie_num), bits); | ||
274 | } | ||
275 | |||
276 | u16 c67x00_ll_usb_get_status(struct c67x00_sie *sie) | ||
277 | { | ||
278 | return hpi_read_word(sie->dev, USB_STAT_REG(sie->sie_num)); | ||
279 | } | ||
280 | |||
281 | /* -------------------------------------------------------------------------- */ | ||
282 | |||
283 | static int c67x00_comm_exec_int(struct c67x00_device *dev, u16 nr, | ||
284 | struct c67x00_lcp_int_data *data) | ||
285 | { | ||
286 | int i, rc; | ||
287 | |||
288 | mutex_lock(&dev->hpi.lcp.mutex); | ||
289 | hpi_write_word(dev, COMM_INT_NUM, nr); | ||
290 | for (i = 0; i < COMM_REGS; i++) | ||
291 | hpi_write_word(dev, COMM_R(i), data->regs[i]); | ||
292 | hpi_send_mbox(dev, COMM_EXEC_INT); | ||
293 | rc = ll_recv_msg(dev); | ||
294 | mutex_unlock(&dev->hpi.lcp.mutex); | ||
295 | |||
296 | return rc; | ||
297 | } | ||
298 | |||
299 | /* -------------------------------------------------------------------------- */ | ||
300 | /* Host specific functions */ | ||
301 | |||
302 | void c67x00_ll_set_husb_eot(struct c67x00_device *dev, u16 value) | ||
303 | { | ||
304 | mutex_lock(&dev->hpi.lcp.mutex); | ||
305 | hpi_write_word(dev, HUSB_pEOT, value); | ||
306 | mutex_unlock(&dev->hpi.lcp.mutex); | ||
307 | } | ||
308 | |||
309 | static inline void c67x00_ll_husb_sie_init(struct c67x00_sie *sie) | ||
310 | { | ||
311 | struct c67x00_device *dev = sie->dev; | ||
312 | struct c67x00_lcp_int_data data; | ||
313 | int rc; | ||
314 | |||
315 | rc = c67x00_comm_exec_int(dev, HUSB_SIE_INIT_INT(sie->sie_num), &data); | ||
316 | BUG_ON(rc); /* No return path for error code; crash spectacularly */ | ||
317 | } | ||
318 | |||
319 | void c67x00_ll_husb_reset(struct c67x00_sie *sie, int port) | ||
320 | { | ||
321 | struct c67x00_device *dev = sie->dev; | ||
322 | struct c67x00_lcp_int_data data; | ||
323 | int rc; | ||
324 | |||
325 | data.regs[0] = 50; /* Reset USB port for 50ms */ | ||
326 | data.regs[1] = port | (sie->sie_num << 1); | ||
327 | rc = c67x00_comm_exec_int(dev, HUSB_RESET_INT, &data); | ||
328 | BUG_ON(rc); /* No return path for error code; crash spectacularly */ | ||
329 | } | ||
330 | |||
331 | void c67x00_ll_husb_set_current_td(struct c67x00_sie *sie, u16 addr) | ||
332 | { | ||
333 | hpi_write_word(sie->dev, HUSB_SIE_pCurrentTDPtr(sie->sie_num), addr); | ||
334 | } | ||
335 | |||
336 | u16 c67x00_ll_husb_get_current_td(struct c67x00_sie *sie) | ||
337 | { | ||
338 | return hpi_read_word(sie->dev, HUSB_SIE_pCurrentTDPtr(sie->sie_num)); | ||
339 | } | ||
340 | |||
341 | u16 c67x00_ll_husb_get_frame(struct c67x00_sie *sie) | ||
342 | { | ||
343 | return hpi_read_word(sie->dev, HOST_FRAME_REG(sie->sie_num)); | ||
344 | } | ||
345 | |||
346 | void c67x00_ll_husb_init_host_port(struct c67x00_sie *sie) | ||
347 | { | ||
348 | /* Set port into host mode */ | ||
349 | hpi_set_bits(sie->dev, USB_CTL_REG(sie->sie_num), HOST_MODE); | ||
350 | c67x00_ll_husb_sie_init(sie); | ||
351 | /* Clear interrupts */ | ||
352 | c67x00_ll_usb_clear_status(sie, HOST_STAT_MASK); | ||
353 | /* Check */ | ||
354 | if (!(hpi_read_word(sie->dev, USB_CTL_REG(sie->sie_num)) & HOST_MODE)) | ||
355 | dev_warn(sie_dev(sie), | ||
356 | "SIE %d not set to host mode\n", sie->sie_num); | ||
357 | } | ||
358 | |||
359 | void c67x00_ll_husb_reset_port(struct c67x00_sie *sie, int port) | ||
360 | { | ||
361 | /* Clear connect change */ | ||
362 | c67x00_ll_usb_clear_status(sie, PORT_CONNECT_CHANGE(port)); | ||
363 | |||
364 | /* Enable interrupts */ | ||
365 | hpi_set_bits(sie->dev, HPI_IRQ_ROUTING_REG, | ||
366 | SOFEOP_TO_CPU_EN(sie->sie_num)); | ||
367 | hpi_set_bits(sie->dev, HOST_IRQ_EN_REG(sie->sie_num), | ||
368 | SOF_EOP_IRQ_EN | DONE_IRQ_EN); | ||
369 | |||
370 | /* Enable pull down transistors */ | ||
371 | hpi_set_bits(sie->dev, USB_CTL_REG(sie->sie_num), PORT_RES_EN(port)); | ||
372 | } | ||
373 | |||
374 | /* -------------------------------------------------------------------------- */ | ||
375 | |||
376 | void c67x00_ll_irq(struct c67x00_device *dev, u16 int_status) | ||
377 | { | ||
378 | if ((int_status & MBX_OUT_FLG) == 0) | ||
379 | return; | ||
380 | |||
381 | dev->hpi.lcp.last_msg = hpi_recv_mbox(dev); | ||
382 | complete(&dev->hpi.lcp.msg_received); | ||
383 | } | ||
384 | |||
385 | /* -------------------------------------------------------------------------- */ | ||
386 | |||
387 | int c67x00_ll_reset(struct c67x00_device *dev) | ||
388 | { | ||
389 | int rc; | ||
390 | |||
391 | mutex_lock(&dev->hpi.lcp.mutex); | ||
392 | hpi_send_mbox(dev, COMM_RESET); | ||
393 | rc = ll_recv_msg(dev); | ||
394 | mutex_unlock(&dev->hpi.lcp.mutex); | ||
395 | |||
396 | return rc; | ||
397 | } | ||
398 | |||
399 | /* -------------------------------------------------------------------------- */ | ||
400 | |||
401 | /** | ||
402 | * c67x00_ll_write_mem_le16 - write into c67x00 memory | ||
403 | * Only data is little endian, addr has cpu endianess. | ||
404 | */ | ||
405 | void c67x00_ll_write_mem_le16(struct c67x00_device *dev, u16 addr, | ||
406 | void *data, int len) | ||
407 | { | ||
408 | u8 *buf = data; | ||
409 | |||
410 | /* Sanity check */ | ||
411 | if (addr + len > 0xffff) { | ||
412 | dev_err(&dev->pdev->dev, | ||
413 | "Trying to write beyond writable region!\n"); | ||
414 | return; | ||
415 | } | ||
416 | |||
417 | if (addr & 0x01) { | ||
418 | /* unaligned access */ | ||
419 | u16 tmp; | ||
420 | tmp = hpi_read_word(dev, addr - 1); | ||
421 | tmp = (tmp & 0x00ff) | (*buf++ << 8); | ||
422 | hpi_write_word(dev, addr - 1, tmp); | ||
423 | addr++; | ||
424 | len--; | ||
425 | } | ||
426 | |||
427 | hpi_write_words_le16(dev, addr, (u16 *)buf, len / 2); | ||
428 | buf += len & ~0x01; | ||
429 | addr += len & ~0x01; | ||
430 | len &= 0x01; | ||
431 | |||
432 | if (len) { | ||
433 | u16 tmp; | ||
434 | tmp = hpi_read_word(dev, addr); | ||
435 | tmp = (tmp & 0xff00) | *buf; | ||
436 | hpi_write_word(dev, addr, tmp); | ||
437 | } | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * c67x00_ll_read_mem_le16 - read from c67x00 memory | ||
442 | * Only data is little endian, addr has cpu endianess. | ||
443 | */ | ||
444 | void c67x00_ll_read_mem_le16(struct c67x00_device *dev, u16 addr, | ||
445 | void *data, int len) | ||
446 | { | ||
447 | u8 *buf = data; | ||
448 | |||
449 | if (addr & 0x01) { | ||
450 | /* unaligned access */ | ||
451 | u16 tmp; | ||
452 | tmp = hpi_read_word(dev, addr - 1); | ||
453 | *buf++ = (tmp >> 8) & 0x00ff; | ||
454 | addr++; | ||
455 | len--; | ||
456 | } | ||
457 | |||
458 | hpi_read_words_le16(dev, addr, (u16 *)buf, len / 2); | ||
459 | buf += len & ~0x01; | ||
460 | addr += len & ~0x01; | ||
461 | len &= 0x01; | ||
462 | |||
463 | if (len) { | ||
464 | u16 tmp; | ||
465 | tmp = hpi_read_word(dev, addr); | ||
466 | *buf = tmp & 0x00ff; | ||
467 | } | ||
468 | } | ||
469 | |||
470 | /* -------------------------------------------------------------------------- */ | ||
471 | |||
472 | void c67x00_ll_init(struct c67x00_device *dev) | ||
473 | { | ||
474 | mutex_init(&dev->hpi.lcp.mutex); | ||
475 | init_completion(&dev->hpi.lcp.msg_received); | ||
476 | } | ||
477 | |||
478 | void c67x00_ll_release(struct c67x00_device *dev) | ||
479 | { | ||
480 | } | ||
diff --git a/drivers/usb/c67x00/c67x00-sched.c b/drivers/usb/c67x00/c67x00-sched.c new file mode 100644 index 000000000000..85dfe2965661 --- /dev/null +++ b/drivers/usb/c67x00/c67x00-sched.c | |||
@@ -0,0 +1,1170 @@ | |||
1 | /* | ||
2 | * c67x00-sched.c: Cypress C67X00 USB Host Controller Driver - TD scheduling | ||
3 | * | ||
4 | * Copyright (C) 2006-2008 Barco N.V. | ||
5 | * Derived from the Cypress cy7c67200/300 ezusb linux driver and | ||
6 | * based on multiple host controller drivers inside the linux kernel. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
21 | * MA 02110-1301 USA. | ||
22 | */ | ||
23 | |||
24 | #include <linux/kthread.h> | ||
25 | |||
26 | #include "c67x00.h" | ||
27 | #include "c67x00-hcd.h" | ||
28 | |||
29 | /* | ||
30 | * These are the stages for a control urb, they are kept | ||
31 | * in both urb->interval and td->privdata. | ||
32 | */ | ||
33 | #define SETUP_STAGE 0 | ||
34 | #define DATA_STAGE 1 | ||
35 | #define STATUS_STAGE 2 | ||
36 | |||
37 | /* -------------------------------------------------------------------------- */ | ||
38 | |||
39 | /** | ||
40 | * struct c67x00_ep_data: Host endpoint data structure | ||
41 | */ | ||
42 | struct c67x00_ep_data { | ||
43 | struct list_head queue; | ||
44 | struct list_head node; | ||
45 | struct usb_host_endpoint *hep; | ||
46 | struct usb_device *dev; | ||
47 | u16 next_frame; /* For int/isoc transactions */ | ||
48 | }; | ||
49 | |||
50 | /** | ||
51 | * struct c67x00_td | ||
52 | * | ||
53 | * Hardware parts are little endiannes, SW in CPU endianess. | ||
54 | */ | ||
55 | struct c67x00_td { | ||
56 | /* HW specific part */ | ||
57 | __le16 ly_base_addr; /* Bytes 0-1 */ | ||
58 | __le16 port_length; /* Bytes 2-3 */ | ||
59 | u8 pid_ep; /* Byte 4 */ | ||
60 | u8 dev_addr; /* Byte 5 */ | ||
61 | u8 ctrl_reg; /* Byte 6 */ | ||
62 | u8 status; /* Byte 7 */ | ||
63 | u8 retry_cnt; /* Byte 8 */ | ||
64 | #define TT_OFFSET 2 | ||
65 | #define TT_CONTROL 0 | ||
66 | #define TT_ISOCHRONOUS 1 | ||
67 | #define TT_BULK 2 | ||
68 | #define TT_INTERRUPT 3 | ||
69 | u8 residue; /* Byte 9 */ | ||
70 | __le16 next_td_addr; /* Bytes 10-11 */ | ||
71 | /* SW part */ | ||
72 | struct list_head td_list; | ||
73 | u16 td_addr; | ||
74 | void *data; | ||
75 | struct urb *urb; | ||
76 | unsigned long privdata; | ||
77 | |||
78 | /* These are needed for handling the toggle bits: | ||
79 | * an urb can be dequeued while a td is in progress | ||
80 | * after checking the td, the toggle bit might need to | ||
81 | * be fixed */ | ||
82 | struct c67x00_ep_data *ep_data; | ||
83 | unsigned int pipe; | ||
84 | }; | ||
85 | |||
86 | struct c67x00_urb_priv { | ||
87 | struct list_head hep_node; | ||
88 | struct urb *urb; | ||
89 | int port; | ||
90 | int cnt; /* packet number for isoc */ | ||
91 | int status; | ||
92 | struct c67x00_ep_data *ep_data; | ||
93 | }; | ||
94 | |||
95 | #define td_udev(td) ((td)->ep_data->dev) | ||
96 | |||
97 | #define CY_TD_SIZE 12 | ||
98 | |||
99 | #define TD_PIDEP_OFFSET 0x04 | ||
100 | #define TD_PIDEPMASK_PID 0xF0 | ||
101 | #define TD_PIDEPMASK_EP 0x0F | ||
102 | #define TD_PORTLENMASK_DL 0x02FF | ||
103 | #define TD_PORTLENMASK_PN 0xC000 | ||
104 | |||
105 | #define TD_STATUS_OFFSET 0x07 | ||
106 | #define TD_STATUSMASK_ACK 0x01 | ||
107 | #define TD_STATUSMASK_ERR 0x02 | ||
108 | #define TD_STATUSMASK_TMOUT 0x04 | ||
109 | #define TD_STATUSMASK_SEQ 0x08 | ||
110 | #define TD_STATUSMASK_SETUP 0x10 | ||
111 | #define TD_STATUSMASK_OVF 0x20 | ||
112 | #define TD_STATUSMASK_NAK 0x40 | ||
113 | #define TD_STATUSMASK_STALL 0x80 | ||
114 | |||
115 | #define TD_ERROR_MASK (TD_STATUSMASK_ERR | TD_STATUSMASK_TMOUT | \ | ||
116 | TD_STATUSMASK_STALL) | ||
117 | |||
118 | #define TD_RETRYCNT_OFFSET 0x08 | ||
119 | #define TD_RETRYCNTMASK_ACT_FLG 0x10 | ||
120 | #define TD_RETRYCNTMASK_TX_TYPE 0x0C | ||
121 | #define TD_RETRYCNTMASK_RTY_CNT 0x03 | ||
122 | |||
123 | #define TD_RESIDUE_OVERFLOW 0x80 | ||
124 | |||
125 | #define TD_PID_IN 0x90 | ||
126 | |||
127 | /* Residue: signed 8bits, neg -> OVERFLOW, pos -> UNDERFLOW */ | ||
128 | #define td_residue(td) ((__s8)(td->residue)) | ||
129 | #define td_ly_base_addr(td) (__le16_to_cpu((td)->ly_base_addr)) | ||
130 | #define td_port_length(td) (__le16_to_cpu((td)->port_length)) | ||
131 | #define td_next_td_addr(td) (__le16_to_cpu((td)->next_td_addr)) | ||
132 | |||
133 | #define td_active(td) ((td)->retry_cnt & TD_RETRYCNTMASK_ACT_FLG) | ||
134 | #define td_length(td) (td_port_length(td) & TD_PORTLENMASK_DL) | ||
135 | |||
136 | #define td_sequence_ok(td) (!td->status || \ | ||
137 | (!(td->status & TD_STATUSMASK_SEQ) == \ | ||
138 | !(td->ctrl_reg & SEQ_SEL))) | ||
139 | |||
140 | #define td_acked(td) (!td->status || \ | ||
141 | (td->status & TD_STATUSMASK_ACK)) | ||
142 | #define td_actual_bytes(td) (td_length(td) - td_residue(td)) | ||
143 | |||
144 | /* -------------------------------------------------------------------------- */ | ||
145 | |||
146 | #ifdef DEBUG | ||
147 | |||
148 | /** | ||
149 | * dbg_td - Dump the contents of the TD | ||
150 | */ | ||
151 | static void dbg_td(struct c67x00_hcd *c67x00, struct c67x00_td *td, char *msg) | ||
152 | { | ||
153 | struct device *dev = c67x00_hcd_dev(c67x00); | ||
154 | |||
155 | dev_dbg(dev, "### %s at 0x%04x\n", msg, td->td_addr); | ||
156 | dev_dbg(dev, "urb: 0x%p\n", td->urb); | ||
157 | dev_dbg(dev, "endpoint: %4d\n", usb_pipeendpoint(td->pipe)); | ||
158 | dev_dbg(dev, "pipeout: %4d\n", usb_pipeout(td->pipe)); | ||
159 | dev_dbg(dev, "ly_base_addr: 0x%04x\n", td_ly_base_addr(td)); | ||
160 | dev_dbg(dev, "port_length: 0x%04x\n", td_port_length(td)); | ||
161 | dev_dbg(dev, "pid_ep: 0x%02x\n", td->pid_ep); | ||
162 | dev_dbg(dev, "dev_addr: 0x%02x\n", td->dev_addr); | ||
163 | dev_dbg(dev, "ctrl_reg: 0x%02x\n", td->ctrl_reg); | ||
164 | dev_dbg(dev, "status: 0x%02x\n", td->status); | ||
165 | dev_dbg(dev, "retry_cnt: 0x%02x\n", td->retry_cnt); | ||
166 | dev_dbg(dev, "residue: 0x%02x\n", td->residue); | ||
167 | dev_dbg(dev, "next_td_addr: 0x%04x\n", td_next_td_addr(td)); | ||
168 | dev_dbg(dev, "data:"); | ||
169 | print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, | ||
170 | td->data, td_length(td), 1); | ||
171 | } | ||
172 | #else /* DEBUG */ | ||
173 | |||
174 | static inline void | ||
175 | dbg_td(struct c67x00_hcd *c67x00, struct c67x00_td *td, char *msg) { } | ||
176 | |||
177 | #endif /* DEBUG */ | ||
178 | |||
179 | /* -------------------------------------------------------------------------- */ | ||
180 | /* Helper functions */ | ||
181 | |||
182 | static inline u16 c67x00_get_current_frame_number(struct c67x00_hcd *c67x00) | ||
183 | { | ||
184 | return c67x00_ll_husb_get_frame(c67x00->sie) & HOST_FRAME_MASK; | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * frame_add | ||
189 | * Software wraparound for framenumbers. | ||
190 | */ | ||
191 | static inline u16 frame_add(u16 a, u16 b) | ||
192 | { | ||
193 | return (a + b) & HOST_FRAME_MASK; | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * frame_after - is frame a after frame b | ||
198 | */ | ||
199 | static inline int frame_after(u16 a, u16 b) | ||
200 | { | ||
201 | return ((HOST_FRAME_MASK + a - b) & HOST_FRAME_MASK) < | ||
202 | (HOST_FRAME_MASK / 2); | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * frame_after_eq - is frame a after or equal to frame b | ||
207 | */ | ||
208 | static inline int frame_after_eq(u16 a, u16 b) | ||
209 | { | ||
210 | return ((HOST_FRAME_MASK + 1 + a - b) & HOST_FRAME_MASK) < | ||
211 | (HOST_FRAME_MASK / 2); | ||
212 | } | ||
213 | |||
214 | /* -------------------------------------------------------------------------- */ | ||
215 | |||
216 | /** | ||
217 | * c67x00_release_urb - remove link from all tds to this urb | ||
218 | * Disconnects the urb from it's tds, so that it can be given back. | ||
219 | * pre: urb->hcpriv != NULL | ||
220 | */ | ||
221 | static void c67x00_release_urb(struct c67x00_hcd *c67x00, struct urb *urb) | ||
222 | { | ||
223 | struct c67x00_td *td; | ||
224 | struct c67x00_urb_priv *urbp; | ||
225 | |||
226 | BUG_ON(!urb); | ||
227 | |||
228 | c67x00->urb_count--; | ||
229 | |||
230 | if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { | ||
231 | c67x00->urb_iso_count--; | ||
232 | if (c67x00->urb_iso_count == 0) | ||
233 | c67x00->max_frame_bw = MAX_FRAME_BW_STD; | ||
234 | } | ||
235 | |||
236 | /* TODO this might be not so efficient when we've got many urbs! | ||
237 | * Alternatives: | ||
238 | * * only clear when needed | ||
239 | * * keep a list of tds with each urbp | ||
240 | */ | ||
241 | list_for_each_entry(td, &c67x00->td_list, td_list) | ||
242 | if (urb == td->urb) | ||
243 | td->urb = NULL; | ||
244 | |||
245 | urbp = urb->hcpriv; | ||
246 | urb->hcpriv = NULL; | ||
247 | list_del(&urbp->hep_node); | ||
248 | kfree(urbp); | ||
249 | } | ||
250 | |||
251 | /* -------------------------------------------------------------------------- */ | ||
252 | |||
253 | static struct c67x00_ep_data * | ||
254 | c67x00_ep_data_alloc(struct c67x00_hcd *c67x00, struct urb *urb) | ||
255 | { | ||
256 | struct usb_host_endpoint *hep = urb->ep; | ||
257 | struct c67x00_ep_data *ep_data; | ||
258 | int type; | ||
259 | |||
260 | c67x00->current_frame = c67x00_get_current_frame_number(c67x00); | ||
261 | |||
262 | /* Check if endpoint already has a c67x00_ep_data struct allocated */ | ||
263 | if (hep->hcpriv) { | ||
264 | ep_data = hep->hcpriv; | ||
265 | if (frame_after(c67x00->current_frame, ep_data->next_frame)) | ||
266 | ep_data->next_frame = | ||
267 | frame_add(c67x00->current_frame, 1); | ||
268 | return hep->hcpriv; | ||
269 | } | ||
270 | |||
271 | /* Allocate and initialize a new c67x00 endpoint data structure */ | ||
272 | ep_data = kzalloc(sizeof(*ep_data), GFP_ATOMIC); | ||
273 | if (!ep_data) | ||
274 | return NULL; | ||
275 | |||
276 | INIT_LIST_HEAD(&ep_data->queue); | ||
277 | INIT_LIST_HEAD(&ep_data->node); | ||
278 | ep_data->hep = hep; | ||
279 | |||
280 | /* hold a reference to udev as long as this endpoint lives, | ||
281 | * this is needed to possibly fix the data toggle */ | ||
282 | ep_data->dev = usb_get_dev(urb->dev); | ||
283 | hep->hcpriv = ep_data; | ||
284 | |||
285 | /* For ISOC and INT endpoints, start ASAP: */ | ||
286 | ep_data->next_frame = frame_add(c67x00->current_frame, 1); | ||
287 | |||
288 | /* Add the endpoint data to one of the pipe lists; must be added | ||
289 | in order of endpoint address */ | ||
290 | type = usb_pipetype(urb->pipe); | ||
291 | if (list_empty(&ep_data->node)) { | ||
292 | list_add(&ep_data->node, &c67x00->list[type]); | ||
293 | } else { | ||
294 | struct c67x00_ep_data *prev; | ||
295 | |||
296 | list_for_each_entry(prev, &c67x00->list[type], node) { | ||
297 | if (prev->hep->desc.bEndpointAddress > | ||
298 | hep->desc.bEndpointAddress) { | ||
299 | list_add(&ep_data->node, prev->node.prev); | ||
300 | break; | ||
301 | } | ||
302 | } | ||
303 | } | ||
304 | |||
305 | return ep_data; | ||
306 | } | ||
307 | |||
308 | static int c67x00_ep_data_free(struct usb_host_endpoint *hep) | ||
309 | { | ||
310 | struct c67x00_ep_data *ep_data = hep->hcpriv; | ||
311 | |||
312 | if (!ep_data) | ||
313 | return 0; | ||
314 | |||
315 | if (!list_empty(&ep_data->queue)) | ||
316 | return -EBUSY; | ||
317 | |||
318 | usb_put_dev(ep_data->dev); | ||
319 | list_del(&ep_data->queue); | ||
320 | list_del(&ep_data->node); | ||
321 | |||
322 | kfree(ep_data); | ||
323 | hep->hcpriv = NULL; | ||
324 | |||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | void c67x00_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) | ||
329 | { | ||
330 | struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd); | ||
331 | unsigned long flags; | ||
332 | |||
333 | if (!list_empty(&ep->urb_list)) | ||
334 | dev_warn(c67x00_hcd_dev(c67x00), "error: urb list not empty\n"); | ||
335 | |||
336 | spin_lock_irqsave(&c67x00->lock, flags); | ||
337 | |||
338 | /* loop waiting for all transfers in the endpoint queue to complete */ | ||
339 | while (c67x00_ep_data_free(ep)) { | ||
340 | /* Drop the lock so we can sleep waiting for the hardware */ | ||
341 | spin_unlock_irqrestore(&c67x00->lock, flags); | ||
342 | |||
343 | /* it could happen that we reinitialize this completion, while | ||
344 | * somebody was waiting for that completion. The timeout and | ||
345 | * while loop handle such cases, but this might be improved */ | ||
346 | INIT_COMPLETION(c67x00->endpoint_disable); | ||
347 | c67x00_sched_kick(c67x00); | ||
348 | wait_for_completion_timeout(&c67x00->endpoint_disable, 1 * HZ); | ||
349 | |||
350 | spin_lock_irqsave(&c67x00->lock, flags); | ||
351 | } | ||
352 | |||
353 | spin_unlock_irqrestore(&c67x00->lock, flags); | ||
354 | } | ||
355 | |||
356 | /* -------------------------------------------------------------------------- */ | ||
357 | |||
358 | static inline int get_root_port(struct usb_device *dev) | ||
359 | { | ||
360 | while (dev->parent->parent) | ||
361 | dev = dev->parent; | ||
362 | return dev->portnum; | ||
363 | } | ||
364 | |||
365 | int c67x00_urb_enqueue(struct usb_hcd *hcd, | ||
366 | struct urb *urb, gfp_t mem_flags) | ||
367 | { | ||
368 | int ret; | ||
369 | unsigned long flags; | ||
370 | struct c67x00_urb_priv *urbp; | ||
371 | struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd); | ||
372 | int port = get_root_port(urb->dev)-1; | ||
373 | |||
374 | spin_lock_irqsave(&c67x00->lock, flags); | ||
375 | |||
376 | /* Make sure host controller is running */ | ||
377 | if (!HC_IS_RUNNING(hcd->state)) { | ||
378 | ret = -ENODEV; | ||
379 | goto err_not_linked; | ||
380 | } | ||
381 | |||
382 | ret = usb_hcd_link_urb_to_ep(hcd, urb); | ||
383 | if (ret) | ||
384 | goto err_not_linked; | ||
385 | |||
386 | /* Allocate and initialize urb private data */ | ||
387 | urbp = kzalloc(sizeof(*urbp), mem_flags); | ||
388 | if (!urbp) { | ||
389 | ret = -ENOMEM; | ||
390 | goto err_urbp; | ||
391 | } | ||
392 | |||
393 | INIT_LIST_HEAD(&urbp->hep_node); | ||
394 | urbp->urb = urb; | ||
395 | urbp->port = port; | ||
396 | |||
397 | urbp->ep_data = c67x00_ep_data_alloc(c67x00, urb); | ||
398 | |||
399 | if (!urbp->ep_data) { | ||
400 | ret = -ENOMEM; | ||
401 | goto err_epdata; | ||
402 | } | ||
403 | |||
404 | /* TODO claim bandwidth with usb_claim_bandwidth? | ||
405 | * also release it somewhere! */ | ||
406 | |||
407 | urb->hcpriv = urbp; | ||
408 | |||
409 | urb->actual_length = 0; /* Nothing received/transmitted yet */ | ||
410 | |||
411 | switch (usb_pipetype(urb->pipe)) { | ||
412 | case PIPE_CONTROL: | ||
413 | urb->interval = SETUP_STAGE; | ||
414 | break; | ||
415 | case PIPE_INTERRUPT: | ||
416 | break; | ||
417 | case PIPE_BULK: | ||
418 | break; | ||
419 | case PIPE_ISOCHRONOUS: | ||
420 | if (c67x00->urb_iso_count == 0) | ||
421 | c67x00->max_frame_bw = MAX_FRAME_BW_ISO; | ||
422 | c67x00->urb_iso_count++; | ||
423 | /* Assume always URB_ISO_ASAP, FIXME */ | ||
424 | if (list_empty(&urbp->ep_data->queue)) | ||
425 | urb->start_frame = urbp->ep_data->next_frame; | ||
426 | else { | ||
427 | /* Go right after the last one */ | ||
428 | struct urb *last_urb; | ||
429 | |||
430 | last_urb = list_entry(urbp->ep_data->queue.prev, | ||
431 | struct c67x00_urb_priv, | ||
432 | hep_node)->urb; | ||
433 | urb->start_frame = | ||
434 | frame_add(last_urb->start_frame, | ||
435 | last_urb->number_of_packets * | ||
436 | last_urb->interval); | ||
437 | } | ||
438 | urbp->cnt = 0; | ||
439 | break; | ||
440 | } | ||
441 | |||
442 | /* Add the URB to the endpoint queue */ | ||
443 | list_add_tail(&urbp->hep_node, &urbp->ep_data->queue); | ||
444 | |||
445 | /* If this is the only URB, kick start the controller */ | ||
446 | if (!c67x00->urb_count++) | ||
447 | c67x00_ll_hpi_enable_sofeop(c67x00->sie); | ||
448 | |||
449 | c67x00_sched_kick(c67x00); | ||
450 | spin_unlock_irqrestore(&c67x00->lock, flags); | ||
451 | |||
452 | return 0; | ||
453 | |||
454 | err_epdata: | ||
455 | kfree(urbp); | ||
456 | err_urbp: | ||
457 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
458 | err_not_linked: | ||
459 | spin_unlock_irqrestore(&c67x00->lock, flags); | ||
460 | |||
461 | return ret; | ||
462 | } | ||
463 | |||
464 | int c67x00_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | ||
465 | { | ||
466 | struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd); | ||
467 | unsigned long flags; | ||
468 | int rc; | ||
469 | |||
470 | spin_lock_irqsave(&c67x00->lock, flags); | ||
471 | rc = usb_hcd_check_unlink_urb(hcd, urb, status); | ||
472 | if (rc) | ||
473 | goto done; | ||
474 | |||
475 | c67x00_release_urb(c67x00, urb); | ||
476 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
477 | |||
478 | spin_unlock(&c67x00->lock); | ||
479 | usb_hcd_giveback_urb(hcd, urb, status); | ||
480 | spin_lock(&c67x00->lock); | ||
481 | |||
482 | spin_unlock_irqrestore(&c67x00->lock, flags); | ||
483 | |||
484 | return 0; | ||
485 | |||
486 | done: | ||
487 | spin_unlock_irqrestore(&c67x00->lock, flags); | ||
488 | return rc; | ||
489 | } | ||
490 | |||
491 | /* -------------------------------------------------------------------------- */ | ||
492 | |||
493 | /* | ||
494 | * pre: c67x00 locked, urb unlocked | ||
495 | */ | ||
496 | static void | ||
497 | c67x00_giveback_urb(struct c67x00_hcd *c67x00, struct urb *urb, int status) | ||
498 | { | ||
499 | struct c67x00_urb_priv *urbp; | ||
500 | |||
501 | if (!urb) | ||
502 | return; | ||
503 | |||
504 | urbp = urb->hcpriv; | ||
505 | urbp->status = status; | ||
506 | |||
507 | list_del_init(&urbp->hep_node); | ||
508 | |||
509 | c67x00_release_urb(c67x00, urb); | ||
510 | usb_hcd_unlink_urb_from_ep(c67x00_hcd_to_hcd(c67x00), urb); | ||
511 | spin_unlock(&c67x00->lock); | ||
512 | usb_hcd_giveback_urb(c67x00_hcd_to_hcd(c67x00), urb, urbp->status); | ||
513 | spin_lock(&c67x00->lock); | ||
514 | } | ||
515 | |||
516 | /* -------------------------------------------------------------------------- */ | ||
517 | |||
518 | static int c67x00_claim_frame_bw(struct c67x00_hcd *c67x00, struct urb *urb, | ||
519 | int len, int periodic) | ||
520 | { | ||
521 | struct c67x00_urb_priv *urbp = urb->hcpriv; | ||
522 | int bit_time; | ||
523 | |||
524 | /* According to the C67x00 BIOS user manual, page 3-18,19, the | ||
525 | * following calculations provide the full speed bit times for | ||
526 | * a transaction. | ||
527 | * | ||
528 | * FS(in) = 112.5 + 9.36*BC + HOST_DELAY | ||
529 | * FS(in,iso) = 90.5 + 9.36*BC + HOST_DELAY | ||
530 | * FS(out) = 112.5 + 9.36*BC + HOST_DELAY | ||
531 | * FS(out,iso) = 78.4 + 9.36*BC + HOST_DELAY | ||
532 | * LS(in) = 802.4 + 75.78*BC + HOST_DELAY | ||
533 | * LS(out) = 802.6 + 74.67*BC + HOST_DELAY | ||
534 | * | ||
535 | * HOST_DELAY == 106 for the c67200 and c67300. | ||
536 | */ | ||
537 | |||
538 | /* make calculations in 1/100 bit times to maintain resolution */ | ||
539 | if (urbp->ep_data->dev->speed == USB_SPEED_LOW) { | ||
540 | /* Low speed pipe */ | ||
541 | if (usb_pipein(urb->pipe)) | ||
542 | bit_time = 80240 + 7578*len; | ||
543 | else | ||
544 | bit_time = 80260 + 7467*len; | ||
545 | } else { | ||
546 | /* FS pipes */ | ||
547 | if (usb_pipeisoc(urb->pipe)) | ||
548 | bit_time = usb_pipein(urb->pipe) ? 9050 : 7840; | ||
549 | else | ||
550 | bit_time = 11250; | ||
551 | bit_time += 936*len; | ||
552 | } | ||
553 | |||
554 | /* Scale back down to integer bit times. Use a host delay of 106. | ||
555 | * (this is the only place it is used) */ | ||
556 | bit_time = ((bit_time+50) / 100) + 106; | ||
557 | |||
558 | if (unlikely(bit_time + c67x00->bandwidth_allocated >= | ||
559 | c67x00->max_frame_bw)) | ||
560 | return -EMSGSIZE; | ||
561 | |||
562 | if (unlikely(c67x00->next_td_addr + CY_TD_SIZE >= | ||
563 | c67x00->td_base_addr + SIE_TD_SIZE)) | ||
564 | return -EMSGSIZE; | ||
565 | |||
566 | if (unlikely(c67x00->next_buf_addr + len >= | ||
567 | c67x00->buf_base_addr + SIE_TD_BUF_SIZE)) | ||
568 | return -EMSGSIZE; | ||
569 | |||
570 | if (periodic) { | ||
571 | if (unlikely(bit_time + c67x00->periodic_bw_allocated >= | ||
572 | MAX_PERIODIC_BW(c67x00->max_frame_bw))) | ||
573 | return -EMSGSIZE; | ||
574 | c67x00->periodic_bw_allocated += bit_time; | ||
575 | } | ||
576 | |||
577 | c67x00->bandwidth_allocated += bit_time; | ||
578 | return 0; | ||
579 | } | ||
580 | |||
581 | /* -------------------------------------------------------------------------- */ | ||
582 | |||
583 | /** | ||
584 | * td_addr and buf_addr must be word aligned | ||
585 | */ | ||
586 | static int c67x00_create_td(struct c67x00_hcd *c67x00, struct urb *urb, | ||
587 | void *data, int len, int pid, int toggle, | ||
588 | unsigned long privdata) | ||
589 | { | ||
590 | struct c67x00_td *td; | ||
591 | struct c67x00_urb_priv *urbp = urb->hcpriv; | ||
592 | const __u8 active_flag = 1, retry_cnt = 1; | ||
593 | __u8 cmd = 0; | ||
594 | int tt = 0; | ||
595 | |||
596 | if (c67x00_claim_frame_bw(c67x00, urb, len, usb_pipeisoc(urb->pipe) | ||
597 | || usb_pipeint(urb->pipe))) | ||
598 | return -EMSGSIZE; /* Not really an error, but expected */ | ||
599 | |||
600 | td = kzalloc(sizeof(*td), GFP_ATOMIC); | ||
601 | if (!td) | ||
602 | return -ENOMEM; | ||
603 | |||
604 | td->pipe = urb->pipe; | ||
605 | td->ep_data = urbp->ep_data; | ||
606 | |||
607 | if ((td_udev(td)->speed == USB_SPEED_LOW) && | ||
608 | !(c67x00->low_speed_ports & (1 << urbp->port))) | ||
609 | cmd |= PREAMBLE_EN; | ||
610 | |||
611 | switch (usb_pipetype(td->pipe)) { | ||
612 | case PIPE_ISOCHRONOUS: | ||
613 | tt = TT_ISOCHRONOUS; | ||
614 | cmd |= ISO_EN; | ||
615 | break; | ||
616 | case PIPE_CONTROL: | ||
617 | tt = TT_CONTROL; | ||
618 | break; | ||
619 | case PIPE_BULK: | ||
620 | tt = TT_BULK; | ||
621 | break; | ||
622 | case PIPE_INTERRUPT: | ||
623 | tt = TT_INTERRUPT; | ||
624 | break; | ||
625 | } | ||
626 | |||
627 | if (toggle) | ||
628 | cmd |= SEQ_SEL; | ||
629 | |||
630 | cmd |= ARM_EN; | ||
631 | |||
632 | /* SW part */ | ||
633 | td->td_addr = c67x00->next_td_addr; | ||
634 | c67x00->next_td_addr = c67x00->next_td_addr + CY_TD_SIZE; | ||
635 | |||
636 | /* HW part */ | ||
637 | td->ly_base_addr = __cpu_to_le16(c67x00->next_buf_addr); | ||
638 | td->port_length = __cpu_to_le16((c67x00->sie->sie_num << 15) | | ||
639 | (urbp->port << 14) | (len & 0x3FF)); | ||
640 | td->pid_ep = ((pid & 0xF) << TD_PIDEP_OFFSET) | | ||
641 | (usb_pipeendpoint(td->pipe) & 0xF); | ||
642 | td->dev_addr = usb_pipedevice(td->pipe) & 0x7F; | ||
643 | td->ctrl_reg = cmd; | ||
644 | td->status = 0; | ||
645 | td->retry_cnt = (tt << TT_OFFSET) | (active_flag << 4) | retry_cnt; | ||
646 | td->residue = 0; | ||
647 | td->next_td_addr = __cpu_to_le16(c67x00->next_td_addr); | ||
648 | |||
649 | /* SW part */ | ||
650 | td->data = data; | ||
651 | td->urb = urb; | ||
652 | td->privdata = privdata; | ||
653 | |||
654 | c67x00->next_buf_addr += (len + 1) & ~0x01; /* properly align */ | ||
655 | |||
656 | list_add_tail(&td->td_list, &c67x00->td_list); | ||
657 | return 0; | ||
658 | } | ||
659 | |||
660 | static inline void c67x00_release_td(struct c67x00_td *td) | ||
661 | { | ||
662 | list_del_init(&td->td_list); | ||
663 | kfree(td); | ||
664 | } | ||
665 | |||
666 | /* -------------------------------------------------------------------------- */ | ||
667 | |||
668 | static int c67x00_add_data_urb(struct c67x00_hcd *c67x00, struct urb *urb) | ||
669 | { | ||
670 | int remaining; | ||
671 | int toggle; | ||
672 | int pid; | ||
673 | int ret = 0; | ||
674 | int maxps; | ||
675 | int need_empty; | ||
676 | |||
677 | toggle = usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), | ||
678 | usb_pipeout(urb->pipe)); | ||
679 | remaining = urb->transfer_buffer_length - urb->actual_length; | ||
680 | |||
681 | maxps = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); | ||
682 | |||
683 | need_empty = (urb->transfer_flags & URB_ZERO_PACKET) && | ||
684 | usb_pipeout(urb->pipe) && !(remaining % maxps); | ||
685 | |||
686 | while (remaining || need_empty) { | ||
687 | int len; | ||
688 | char *td_buf; | ||
689 | |||
690 | len = (remaining > maxps) ? maxps : remaining; | ||
691 | if (!len) | ||
692 | need_empty = 0; | ||
693 | |||
694 | pid = usb_pipeout(urb->pipe) ? USB_PID_OUT : USB_PID_IN; | ||
695 | td_buf = urb->transfer_buffer + urb->transfer_buffer_length - | ||
696 | remaining; | ||
697 | ret = c67x00_create_td(c67x00, urb, td_buf, len, pid, toggle, | ||
698 | DATA_STAGE); | ||
699 | if (ret) | ||
700 | return ret; /* td wasn't created */ | ||
701 | |||
702 | toggle ^= 1; | ||
703 | remaining -= len; | ||
704 | if (usb_pipecontrol(urb->pipe)) | ||
705 | break; | ||
706 | } | ||
707 | |||
708 | return 0; | ||
709 | } | ||
710 | |||
711 | /** | ||
712 | * return 0 in case more bandwidth is available, else errorcode | ||
713 | */ | ||
714 | static int c67x00_add_ctrl_urb(struct c67x00_hcd *c67x00, struct urb *urb) | ||
715 | { | ||
716 | int ret; | ||
717 | int pid; | ||
718 | |||
719 | switch (urb->interval) { | ||
720 | default: | ||
721 | case SETUP_STAGE: | ||
722 | ret = c67x00_create_td(c67x00, urb, urb->setup_packet, | ||
723 | 8, USB_PID_SETUP, 0, SETUP_STAGE); | ||
724 | if (ret) | ||
725 | return ret; | ||
726 | urb->interval = SETUP_STAGE; | ||
727 | usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), | ||
728 | usb_pipeout(urb->pipe), 1); | ||
729 | break; | ||
730 | case DATA_STAGE: | ||
731 | if (urb->transfer_buffer_length) { | ||
732 | ret = c67x00_add_data_urb(c67x00, urb); | ||
733 | if (ret) | ||
734 | return ret; | ||
735 | break; | ||
736 | } /* else fallthrough */ | ||
737 | case STATUS_STAGE: | ||
738 | pid = !usb_pipeout(urb->pipe) ? USB_PID_OUT : USB_PID_IN; | ||
739 | ret = c67x00_create_td(c67x00, urb, NULL, 0, pid, 1, | ||
740 | STATUS_STAGE); | ||
741 | if (ret) | ||
742 | return ret; | ||
743 | break; | ||
744 | } | ||
745 | |||
746 | return 0; | ||
747 | } | ||
748 | |||
749 | /* | ||
750 | * return 0 in case more bandwidth is available, else errorcode | ||
751 | */ | ||
752 | static int c67x00_add_int_urb(struct c67x00_hcd *c67x00, struct urb *urb) | ||
753 | { | ||
754 | struct c67x00_urb_priv *urbp = urb->hcpriv; | ||
755 | |||
756 | if (frame_after_eq(c67x00->current_frame, urbp->ep_data->next_frame)) { | ||
757 | urbp->ep_data->next_frame = | ||
758 | frame_add(urbp->ep_data->next_frame, urb->interval); | ||
759 | return c67x00_add_data_urb(c67x00, urb); | ||
760 | } | ||
761 | return 0; | ||
762 | } | ||
763 | |||
764 | static int c67x00_add_iso_urb(struct c67x00_hcd *c67x00, struct urb *urb) | ||
765 | { | ||
766 | struct c67x00_urb_priv *urbp = urb->hcpriv; | ||
767 | |||
768 | if (frame_after_eq(c67x00->current_frame, urbp->ep_data->next_frame)) { | ||
769 | char *td_buf; | ||
770 | int len, pid, ret; | ||
771 | |||
772 | BUG_ON(urbp->cnt >= urb->number_of_packets); | ||
773 | |||
774 | td_buf = urb->transfer_buffer + | ||
775 | urb->iso_frame_desc[urbp->cnt].offset; | ||
776 | len = urb->iso_frame_desc[urbp->cnt].length; | ||
777 | pid = usb_pipeout(urb->pipe) ? USB_PID_OUT : USB_PID_IN; | ||
778 | |||
779 | ret = c67x00_create_td(c67x00, urb, td_buf, len, pid, 0, | ||
780 | urbp->cnt); | ||
781 | if (ret) { | ||
782 | printk(KERN_DEBUG "create failed: %d\n", ret); | ||
783 | urb->iso_frame_desc[urbp->cnt].actual_length = 0; | ||
784 | urb->iso_frame_desc[urbp->cnt].status = ret; | ||
785 | if (urbp->cnt + 1 == urb->number_of_packets) | ||
786 | c67x00_giveback_urb(c67x00, urb, 0); | ||
787 | } | ||
788 | |||
789 | urbp->ep_data->next_frame = | ||
790 | frame_add(urbp->ep_data->next_frame, urb->interval); | ||
791 | urbp->cnt++; | ||
792 | } | ||
793 | return 0; | ||
794 | } | ||
795 | |||
796 | /* -------------------------------------------------------------------------- */ | ||
797 | |||
798 | static void c67x00_fill_from_list(struct c67x00_hcd *c67x00, int type, | ||
799 | int (*add)(struct c67x00_hcd *, struct urb *)) | ||
800 | { | ||
801 | struct c67x00_ep_data *ep_data; | ||
802 | struct urb *urb; | ||
803 | |||
804 | /* traverse every endpoint on the list */ | ||
805 | list_for_each_entry(ep_data, &c67x00->list[type], node) { | ||
806 | if (!list_empty(&ep_data->queue)) { | ||
807 | /* and add the first urb */ | ||
808 | /* isochronous transfer rely on this */ | ||
809 | urb = list_entry(ep_data->queue.next, | ||
810 | struct c67x00_urb_priv, | ||
811 | hep_node)->urb; | ||
812 | add(c67x00, urb); | ||
813 | } | ||
814 | } | ||
815 | } | ||
816 | |||
817 | static void c67x00_fill_frame(struct c67x00_hcd *c67x00) | ||
818 | { | ||
819 | struct c67x00_td *td, *ttd; | ||
820 | |||
821 | /* Check if we can proceed */ | ||
822 | if (!list_empty(&c67x00->td_list)) { | ||
823 | dev_warn(c67x00_hcd_dev(c67x00), | ||
824 | "TD list not empty! This should not happen!\n"); | ||
825 | list_for_each_entry_safe(td, ttd, &c67x00->td_list, td_list) { | ||
826 | dbg_td(c67x00, td, "Unprocessed td"); | ||
827 | c67x00_release_td(td); | ||
828 | } | ||
829 | } | ||
830 | |||
831 | /* Reinitialize variables */ | ||
832 | c67x00->bandwidth_allocated = 0; | ||
833 | c67x00->periodic_bw_allocated = 0; | ||
834 | |||
835 | c67x00->next_td_addr = c67x00->td_base_addr; | ||
836 | c67x00->next_buf_addr = c67x00->buf_base_addr; | ||
837 | |||
838 | /* Fill the list */ | ||
839 | c67x00_fill_from_list(c67x00, PIPE_ISOCHRONOUS, c67x00_add_iso_urb); | ||
840 | c67x00_fill_from_list(c67x00, PIPE_INTERRUPT, c67x00_add_int_urb); | ||
841 | c67x00_fill_from_list(c67x00, PIPE_CONTROL, c67x00_add_ctrl_urb); | ||
842 | c67x00_fill_from_list(c67x00, PIPE_BULK, c67x00_add_data_urb); | ||
843 | } | ||
844 | |||
845 | /* -------------------------------------------------------------------------- */ | ||
846 | |||
847 | /** | ||
848 | * Get TD from C67X00 | ||
849 | */ | ||
850 | static inline void | ||
851 | c67x00_parse_td(struct c67x00_hcd *c67x00, struct c67x00_td *td) | ||
852 | { | ||
853 | c67x00_ll_read_mem_le16(c67x00->sie->dev, | ||
854 | td->td_addr, td, CY_TD_SIZE); | ||
855 | |||
856 | if (usb_pipein(td->pipe) && td_actual_bytes(td)) | ||
857 | c67x00_ll_read_mem_le16(c67x00->sie->dev, td_ly_base_addr(td), | ||
858 | td->data, td_actual_bytes(td)); | ||
859 | } | ||
860 | |||
861 | static int c67x00_td_to_error(struct c67x00_hcd *c67x00, struct c67x00_td *td) | ||
862 | { | ||
863 | if (td->status & TD_STATUSMASK_ERR) { | ||
864 | dbg_td(c67x00, td, "ERROR_FLAG"); | ||
865 | return -EILSEQ; | ||
866 | } | ||
867 | if (td->status & TD_STATUSMASK_STALL) { | ||
868 | /* dbg_td(c67x00, td, "STALL"); */ | ||
869 | return -EPIPE; | ||
870 | } | ||
871 | if (td->status & TD_STATUSMASK_TMOUT) { | ||
872 | dbg_td(c67x00, td, "TIMEOUT"); | ||
873 | return -ETIMEDOUT; | ||
874 | } | ||
875 | |||
876 | return 0; | ||
877 | } | ||
878 | |||
879 | static inline int c67x00_end_of_data(struct c67x00_td *td) | ||
880 | { | ||
881 | int maxps, need_empty, remaining; | ||
882 | struct urb *urb = td->urb; | ||
883 | int act_bytes; | ||
884 | |||
885 | act_bytes = td_actual_bytes(td); | ||
886 | |||
887 | if (unlikely(!act_bytes)) | ||
888 | return 1; /* This was an empty packet */ | ||
889 | |||
890 | maxps = usb_maxpacket(td_udev(td), td->pipe, usb_pipeout(td->pipe)); | ||
891 | |||
892 | if (unlikely(act_bytes < maxps)) | ||
893 | return 1; /* Smaller then full packet */ | ||
894 | |||
895 | remaining = urb->transfer_buffer_length - urb->actual_length; | ||
896 | need_empty = (urb->transfer_flags & URB_ZERO_PACKET) && | ||
897 | usb_pipeout(urb->pipe) && !(remaining % maxps); | ||
898 | |||
899 | if (unlikely(!remaining && !need_empty)) | ||
900 | return 1; | ||
901 | |||
902 | return 0; | ||
903 | } | ||
904 | |||
905 | /* -------------------------------------------------------------------------- */ | ||
906 | |||
907 | /* Remove all td's from the list which come | ||
908 | * after last_td and are meant for the same pipe. | ||
909 | * This is used when a short packet has occured */ | ||
910 | static inline void c67x00_clear_pipe(struct c67x00_hcd *c67x00, | ||
911 | struct c67x00_td *last_td) | ||
912 | { | ||
913 | struct c67x00_td *td, *tmp; | ||
914 | td = last_td; | ||
915 | tmp = last_td; | ||
916 | while (td->td_list.next != &c67x00->td_list) { | ||
917 | td = list_entry(td->td_list.next, struct c67x00_td, td_list); | ||
918 | if (td->pipe == last_td->pipe) { | ||
919 | c67x00_release_td(td); | ||
920 | td = tmp; | ||
921 | } | ||
922 | tmp = td; | ||
923 | } | ||
924 | } | ||
925 | |||
926 | /* -------------------------------------------------------------------------- */ | ||
927 | |||
928 | static void c67x00_handle_successful_td(struct c67x00_hcd *c67x00, | ||
929 | struct c67x00_td *td) | ||
930 | { | ||
931 | struct urb *urb = td->urb; | ||
932 | |||
933 | if (!urb) | ||
934 | return; | ||
935 | |||
936 | urb->actual_length += td_actual_bytes(td); | ||
937 | |||
938 | switch (usb_pipetype(td->pipe)) { | ||
939 | /* isochronous tds are handled separately */ | ||
940 | case PIPE_CONTROL: | ||
941 | switch (td->privdata) { | ||
942 | case SETUP_STAGE: | ||
943 | urb->interval = | ||
944 | urb->transfer_buffer_length ? | ||
945 | DATA_STAGE : STATUS_STAGE; | ||
946 | /* Don't count setup_packet with normal data: */ | ||
947 | urb->actual_length = 0; | ||
948 | break; | ||
949 | |||
950 | case DATA_STAGE: | ||
951 | if (c67x00_end_of_data(td)) { | ||
952 | urb->interval = STATUS_STAGE; | ||
953 | c67x00_clear_pipe(c67x00, td); | ||
954 | } | ||
955 | break; | ||
956 | |||
957 | case STATUS_STAGE: | ||
958 | urb->interval = 0; | ||
959 | c67x00_giveback_urb(c67x00, urb, 0); | ||
960 | break; | ||
961 | } | ||
962 | break; | ||
963 | |||
964 | case PIPE_INTERRUPT: | ||
965 | case PIPE_BULK: | ||
966 | if (unlikely(c67x00_end_of_data(td))) { | ||
967 | c67x00_clear_pipe(c67x00, td); | ||
968 | c67x00_giveback_urb(c67x00, urb, 0); | ||
969 | } | ||
970 | break; | ||
971 | } | ||
972 | } | ||
973 | |||
974 | static void c67x00_handle_isoc(struct c67x00_hcd *c67x00, struct c67x00_td *td) | ||
975 | { | ||
976 | struct urb *urb = td->urb; | ||
977 | struct c67x00_urb_priv *urbp; | ||
978 | int cnt; | ||
979 | |||
980 | if (!urb) | ||
981 | return; | ||
982 | |||
983 | urbp = urb->hcpriv; | ||
984 | cnt = td->privdata; | ||
985 | |||
986 | if (td->status & TD_ERROR_MASK) | ||
987 | urb->error_count++; | ||
988 | |||
989 | urb->iso_frame_desc[cnt].actual_length = td_actual_bytes(td); | ||
990 | urb->iso_frame_desc[cnt].status = c67x00_td_to_error(c67x00, td); | ||
991 | if (cnt + 1 == urb->number_of_packets) /* Last packet */ | ||
992 | c67x00_giveback_urb(c67x00, urb, 0); | ||
993 | } | ||
994 | |||
995 | /* -------------------------------------------------------------------------- */ | ||
996 | |||
997 | /** | ||
998 | * c67x00_check_td_list - handle tds which have been processed by the c67x00 | ||
999 | * pre: current_td == 0 | ||
1000 | */ | ||
1001 | static inline void c67x00_check_td_list(struct c67x00_hcd *c67x00) | ||
1002 | { | ||
1003 | struct c67x00_td *td, *tmp; | ||
1004 | struct urb *urb; | ||
1005 | int ack_ok; | ||
1006 | int clear_endpoint; | ||
1007 | |||
1008 | list_for_each_entry_safe(td, tmp, &c67x00->td_list, td_list) { | ||
1009 | /* get the TD */ | ||
1010 | c67x00_parse_td(c67x00, td); | ||
1011 | urb = td->urb; /* urb can be NULL! */ | ||
1012 | ack_ok = 0; | ||
1013 | clear_endpoint = 1; | ||
1014 | |||
1015 | /* Handle isochronous transfers separately */ | ||
1016 | if (usb_pipeisoc(td->pipe)) { | ||
1017 | clear_endpoint = 0; | ||
1018 | c67x00_handle_isoc(c67x00, td); | ||
1019 | goto cont; | ||
1020 | } | ||
1021 | |||
1022 | /* When an error occurs, all td's for that pipe go into an | ||
1023 | * inactive state. This state matches successful transfers so | ||
1024 | * we must make sure not to service them. */ | ||
1025 | if (td->status & TD_ERROR_MASK) { | ||
1026 | c67x00_giveback_urb(c67x00, urb, | ||
1027 | c67x00_td_to_error(c67x00, td)); | ||
1028 | goto cont; | ||
1029 | } | ||
1030 | |||
1031 | if ((td->status & TD_STATUSMASK_NAK) || !td_sequence_ok(td) || | ||
1032 | !td_acked(td)) | ||
1033 | goto cont; | ||
1034 | |||
1035 | /* Sequence ok and acked, don't need to fix toggle */ | ||
1036 | ack_ok = 1; | ||
1037 | |||
1038 | if (unlikely(td->status & TD_STATUSMASK_OVF)) { | ||
1039 | if (td_residue(td) & TD_RESIDUE_OVERFLOW) { | ||
1040 | /* Overflow */ | ||
1041 | c67x00_giveback_urb(c67x00, urb, -EOVERFLOW); | ||
1042 | goto cont; | ||
1043 | } | ||
1044 | } | ||
1045 | |||
1046 | clear_endpoint = 0; | ||
1047 | c67x00_handle_successful_td(c67x00, td); | ||
1048 | |||
1049 | cont: | ||
1050 | if (clear_endpoint) | ||
1051 | c67x00_clear_pipe(c67x00, td); | ||
1052 | if (ack_ok) | ||
1053 | usb_settoggle(td_udev(td), usb_pipeendpoint(td->pipe), | ||
1054 | usb_pipeout(td->pipe), | ||
1055 | !(td->ctrl_reg & SEQ_SEL)); | ||
1056 | /* next in list could have been removed, due to clear_pipe! */ | ||
1057 | tmp = list_entry(td->td_list.next, typeof(*td), td_list); | ||
1058 | c67x00_release_td(td); | ||
1059 | } | ||
1060 | } | ||
1061 | |||
1062 | /* -------------------------------------------------------------------------- */ | ||
1063 | |||
1064 | static inline int c67x00_all_tds_processed(struct c67x00_hcd *c67x00) | ||
1065 | { | ||
1066 | /* If all tds are processed, we can check the previous frame (if | ||
1067 | * there was any) and start our next frame. | ||
1068 | */ | ||
1069 | return !c67x00_ll_husb_get_current_td(c67x00->sie); | ||
1070 | } | ||
1071 | |||
1072 | /** | ||
1073 | * Send td to C67X00 | ||
1074 | */ | ||
1075 | static void c67x00_send_td(struct c67x00_hcd *c67x00, struct c67x00_td *td) | ||
1076 | { | ||
1077 | int len = td_length(td); | ||
1078 | |||
1079 | if (len && ((td->pid_ep & TD_PIDEPMASK_PID) != TD_PID_IN)) | ||
1080 | c67x00_ll_write_mem_le16(c67x00->sie->dev, td_ly_base_addr(td), | ||
1081 | td->data, len); | ||
1082 | |||
1083 | c67x00_ll_write_mem_le16(c67x00->sie->dev, | ||
1084 | td->td_addr, td, CY_TD_SIZE); | ||
1085 | } | ||
1086 | |||
1087 | static void c67x00_send_frame(struct c67x00_hcd *c67x00) | ||
1088 | { | ||
1089 | struct c67x00_td *td; | ||
1090 | |||
1091 | if (list_empty(&c67x00->td_list)) | ||
1092 | dev_warn(c67x00_hcd_dev(c67x00), | ||
1093 | "%s: td list should not be empty here!\n", | ||
1094 | __func__); | ||
1095 | |||
1096 | list_for_each_entry(td, &c67x00->td_list, td_list) { | ||
1097 | if (td->td_list.next == &c67x00->td_list) | ||
1098 | td->next_td_addr = 0; /* Last td in list */ | ||
1099 | |||
1100 | c67x00_send_td(c67x00, td); | ||
1101 | } | ||
1102 | |||
1103 | c67x00_ll_husb_set_current_td(c67x00->sie, c67x00->td_base_addr); | ||
1104 | } | ||
1105 | |||
1106 | /* -------------------------------------------------------------------------- */ | ||
1107 | |||
1108 | /** | ||
1109 | * c67x00_do_work - Schedulers state machine | ||
1110 | */ | ||
1111 | static void c67x00_do_work(struct c67x00_hcd *c67x00) | ||
1112 | { | ||
1113 | spin_lock(&c67x00->lock); | ||
1114 | /* Make sure all tds are processed */ | ||
1115 | if (!c67x00_all_tds_processed(c67x00)) | ||
1116 | goto out; | ||
1117 | |||
1118 | c67x00_check_td_list(c67x00); | ||
1119 | |||
1120 | /* no td's are being processed (current == 0) | ||
1121 | * and all have been "checked" */ | ||
1122 | complete(&c67x00->endpoint_disable); | ||
1123 | |||
1124 | if (!list_empty(&c67x00->td_list)) | ||
1125 | goto out; | ||
1126 | |||
1127 | c67x00->current_frame = c67x00_get_current_frame_number(c67x00); | ||
1128 | if (c67x00->current_frame == c67x00->last_frame) | ||
1129 | goto out; /* Don't send tds in same frame */ | ||
1130 | c67x00->last_frame = c67x00->current_frame; | ||
1131 | |||
1132 | /* If no urbs are scheduled, our work is done */ | ||
1133 | if (!c67x00->urb_count) { | ||
1134 | c67x00_ll_hpi_disable_sofeop(c67x00->sie); | ||
1135 | goto out; | ||
1136 | } | ||
1137 | |||
1138 | c67x00_fill_frame(c67x00); | ||
1139 | if (!list_empty(&c67x00->td_list)) | ||
1140 | /* TD's have been added to the frame */ | ||
1141 | c67x00_send_frame(c67x00); | ||
1142 | |||
1143 | out: | ||
1144 | spin_unlock(&c67x00->lock); | ||
1145 | } | ||
1146 | |||
1147 | /* -------------------------------------------------------------------------- */ | ||
1148 | |||
1149 | static void c67x00_sched_tasklet(unsigned long __c67x00) | ||
1150 | { | ||
1151 | struct c67x00_hcd *c67x00 = (struct c67x00_hcd *)__c67x00; | ||
1152 | c67x00_do_work(c67x00); | ||
1153 | } | ||
1154 | |||
1155 | void c67x00_sched_kick(struct c67x00_hcd *c67x00) | ||
1156 | { | ||
1157 | tasklet_hi_schedule(&c67x00->tasklet); | ||
1158 | } | ||
1159 | |||
1160 | int c67x00_sched_start_scheduler(struct c67x00_hcd *c67x00) | ||
1161 | { | ||
1162 | tasklet_init(&c67x00->tasklet, c67x00_sched_tasklet, | ||
1163 | (unsigned long)c67x00); | ||
1164 | return 0; | ||
1165 | } | ||
1166 | |||
1167 | void c67x00_sched_stop_scheduler(struct c67x00_hcd *c67x00) | ||
1168 | { | ||
1169 | tasklet_kill(&c67x00->tasklet); | ||
1170 | } | ||
diff --git a/drivers/usb/c67x00/c67x00.h b/drivers/usb/c67x00/c67x00.h new file mode 100644 index 000000000000..a26e9ded0f32 --- /dev/null +++ b/drivers/usb/c67x00/c67x00.h | |||
@@ -0,0 +1,294 @@ | |||
1 | /* | ||
2 | * c67x00.h: Cypress C67X00 USB register and field definitions | ||
3 | * | ||
4 | * Copyright (C) 2006-2008 Barco N.V. | ||
5 | * Derived from the Cypress cy7c67200/300 ezusb linux driver and | ||
6 | * based on multiple host controller drivers inside the linux kernel. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
21 | * MA 02110-1301 USA. | ||
22 | */ | ||
23 | |||
24 | #ifndef _USB_C67X00_H | ||
25 | #define _USB_C67X00_H | ||
26 | |||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/platform_device.h> | ||
29 | #include <linux/completion.h> | ||
30 | #include <linux/mutex.h> | ||
31 | |||
32 | /* --------------------------------------------------------------------- | ||
33 | * Cypress C67x00 register definitions | ||
34 | */ | ||
35 | |||
36 | /* Hardware Revision Register */ | ||
37 | #define HW_REV_REG 0xC004 | ||
38 | |||
39 | /* General USB registers */ | ||
40 | /* ===================== */ | ||
41 | |||
42 | /* USB Control Register */ | ||
43 | #define USB_CTL_REG(x) ((x) ? 0xC0AA : 0xC08A) | ||
44 | |||
45 | #define LOW_SPEED_PORT(x) ((x) ? 0x0800 : 0x0400) | ||
46 | #define HOST_MODE 0x0200 | ||
47 | #define PORT_RES_EN(x) ((x) ? 0x0100 : 0x0080) | ||
48 | #define SOF_EOP_EN(x) ((x) ? 0x0002 : 0x0001) | ||
49 | |||
50 | /* USB status register - Notice it has different content in hcd/udc mode */ | ||
51 | #define USB_STAT_REG(x) ((x) ? 0xC0B0 : 0xC090) | ||
52 | |||
53 | #define EP0_IRQ_FLG 0x0001 | ||
54 | #define EP1_IRQ_FLG 0x0002 | ||
55 | #define EP2_IRQ_FLG 0x0004 | ||
56 | #define EP3_IRQ_FLG 0x0008 | ||
57 | #define EP4_IRQ_FLG 0x0010 | ||
58 | #define EP5_IRQ_FLG 0x0020 | ||
59 | #define EP6_IRQ_FLG 0x0040 | ||
60 | #define EP7_IRQ_FLG 0x0080 | ||
61 | #define RESET_IRQ_FLG 0x0100 | ||
62 | #define SOF_EOP_IRQ_FLG 0x0200 | ||
63 | #define ID_IRQ_FLG 0x4000 | ||
64 | #define VBUS_IRQ_FLG 0x8000 | ||
65 | |||
66 | /* USB Host only registers */ | ||
67 | /* ======================= */ | ||
68 | |||
69 | /* Host n Control Register */ | ||
70 | #define HOST_CTL_REG(x) ((x) ? 0xC0A0 : 0xC080) | ||
71 | |||
72 | #define PREAMBLE_EN 0x0080 /* Preamble enable */ | ||
73 | #define SEQ_SEL 0x0040 /* Data Toggle Sequence Bit Select */ | ||
74 | #define ISO_EN 0x0010 /* Isochronous enable */ | ||
75 | #define ARM_EN 0x0001 /* Arm operation */ | ||
76 | |||
77 | /* Host n Interrupt Enable Register */ | ||
78 | #define HOST_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C) | ||
79 | |||
80 | #define SOF_EOP_IRQ_EN 0x0200 /* SOF/EOP Interrupt Enable */ | ||
81 | #define SOF_EOP_TMOUT_IRQ_EN 0x0800 /* SOF/EOP Timeout Interrupt Enable */ | ||
82 | #define ID_IRQ_EN 0x4000 /* ID interrupt enable */ | ||
83 | #define VBUS_IRQ_EN 0x8000 /* VBUS interrupt enable */ | ||
84 | #define DONE_IRQ_EN 0x0001 /* Done Interrupt Enable */ | ||
85 | |||
86 | /* USB status register */ | ||
87 | #define HOST_STAT_MASK 0x02FD | ||
88 | #define PORT_CONNECT_CHANGE(x) ((x) ? 0x0020 : 0x0010) | ||
89 | #define PORT_SE0_STATUS(x) ((x) ? 0x0008 : 0x0004) | ||
90 | |||
91 | /* Host Frame Register */ | ||
92 | #define HOST_FRAME_REG(x) ((x) ? 0xC0B6 : 0xC096) | ||
93 | |||
94 | #define HOST_FRAME_MASK 0x07FF | ||
95 | |||
96 | /* USB Peripheral only registers */ | ||
97 | /* ============================= */ | ||
98 | |||
99 | /* Device n Port Sel reg */ | ||
100 | #define DEVICE_N_PORT_SEL(x) ((x) ? 0xC0A4 : 0xC084) | ||
101 | |||
102 | /* Device n Interrupt Enable Register */ | ||
103 | #define DEVICE_N_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C) | ||
104 | |||
105 | #define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep) ((dev) \ | ||
106 | ? (0x0280 + (ep << 4)) \ | ||
107 | : (0x0200 + (ep << 4))) | ||
108 | #define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep) ((dev) \ | ||
109 | ? (0x0286 + (ep << 4)) \ | ||
110 | : (0x0206 + (ep << 4))) | ||
111 | |||
112 | #define DEVICE_N_ADDRESS(dev) ((dev) ? (0xC0AE) : (0xC08E)) | ||
113 | |||
114 | /* HPI registers */ | ||
115 | /* ============= */ | ||
116 | |||
117 | /* HPI Status register */ | ||
118 | #define SOFEOP_FLG(x) (1 << ((x) ? 12 : 10)) | ||
119 | #define SIEMSG_FLG(x) (1 << (4 + (x))) | ||
120 | #define RESET_FLG(x) ((x) ? 0x0200 : 0x0002) | ||
121 | #define DONE_FLG(x) (1 << (2 + (x))) | ||
122 | #define RESUME_FLG(x) (1 << (6 + (x))) | ||
123 | #define MBX_OUT_FLG 0x0001 /* Message out available */ | ||
124 | #define MBX_IN_FLG 0x0100 | ||
125 | #define ID_FLG 0x4000 | ||
126 | #define VBUS_FLG 0x8000 | ||
127 | |||
128 | /* Interrupt routing register */ | ||
129 | #define HPI_IRQ_ROUTING_REG 0x0142 | ||
130 | |||
131 | #define HPI_SWAP_ENABLE(x) ((x) ? 0x0100 : 0x0001) | ||
132 | #define RESET_TO_HPI_ENABLE(x) ((x) ? 0x0200 : 0x0002) | ||
133 | #define DONE_TO_HPI_ENABLE(x) ((x) ? 0x0008 : 0x0004) | ||
134 | #define RESUME_TO_HPI_ENABLE(x) ((x) ? 0x0080 : 0x0040) | ||
135 | #define SOFEOP_TO_HPI_EN(x) ((x) ? 0x2000 : 0x0800) | ||
136 | #define SOFEOP_TO_CPU_EN(x) ((x) ? 0x1000 : 0x0400) | ||
137 | #define ID_TO_HPI_ENABLE 0x4000 | ||
138 | #define VBUS_TO_HPI_ENABLE 0x8000 | ||
139 | |||
140 | /* SIE msg registers */ | ||
141 | #define SIEMSG_REG(x) ((x) ? 0x0148 : 0x0144) | ||
142 | |||
143 | #define HUSB_TDListDone 0x1000 | ||
144 | |||
145 | #define SUSB_EP0_MSG 0x0001 | ||
146 | #define SUSB_EP1_MSG 0x0002 | ||
147 | #define SUSB_EP2_MSG 0x0004 | ||
148 | #define SUSB_EP3_MSG 0x0008 | ||
149 | #define SUSB_EP4_MSG 0x0010 | ||
150 | #define SUSB_EP5_MSG 0x0020 | ||
151 | #define SUSB_EP6_MSG 0x0040 | ||
152 | #define SUSB_EP7_MSG 0x0080 | ||
153 | #define SUSB_RST_MSG 0x0100 | ||
154 | #define SUSB_SOF_MSG 0x0200 | ||
155 | #define SUSB_CFG_MSG 0x0400 | ||
156 | #define SUSB_SUS_MSG 0x0800 | ||
157 | #define SUSB_ID_MSG 0x4000 | ||
158 | #define SUSB_VBUS_MSG 0x8000 | ||
159 | |||
160 | /* BIOS interrupt routines */ | ||
161 | |||
162 | #define SUSBx_RECEIVE_INT(x) ((x) ? 97 : 81) | ||
163 | #define SUSBx_SEND_INT(x) ((x) ? 96 : 80) | ||
164 | |||
165 | #define SUSBx_DEV_DESC_VEC(x) ((x) ? 0x00D4 : 0x00B4) | ||
166 | #define SUSBx_CONF_DESC_VEC(x) ((x) ? 0x00D6 : 0x00B6) | ||
167 | #define SUSBx_STRING_DESC_VEC(x) ((x) ? 0x00D8 : 0x00B8) | ||
168 | |||
169 | #define CY_HCD_BUF_ADDR 0x500 /* Base address for host */ | ||
170 | #define SIE_TD_SIZE 0x200 /* size of the td list */ | ||
171 | #define SIE_TD_BUF_SIZE 0x400 /* size of the data buffer */ | ||
172 | |||
173 | #define SIE_TD_OFFSET(host) ((host) ? (SIE_TD_SIZE+SIE_TD_BUF_SIZE) : 0) | ||
174 | #define SIE_BUF_OFFSET(host) (SIE_TD_OFFSET(host) + SIE_TD_SIZE) | ||
175 | |||
176 | /* Base address of HCD + 2 x TD_SIZE + 2 x TD_BUF_SIZE */ | ||
177 | #define CY_UDC_REQ_HEADER_BASE 0x1100 | ||
178 | /* 8- byte request headers for IN/OUT transfers */ | ||
179 | #define CY_UDC_REQ_HEADER_SIZE 8 | ||
180 | |||
181 | #define CY_UDC_REQ_HEADER_ADDR(ep_num) (CY_UDC_REQ_HEADER_BASE + \ | ||
182 | ((ep_num) * CY_UDC_REQ_HEADER_SIZE)) | ||
183 | #define CY_UDC_DESC_BASE_ADDRESS (CY_UDC_REQ_HEADER_ADDR(8)) | ||
184 | |||
185 | #define CY_UDC_BIOS_REPLACE_BASE 0x1800 | ||
186 | #define CY_UDC_REQ_BUFFER_BASE 0x2000 | ||
187 | #define CY_UDC_REQ_BUFFER_SIZE 0x0400 | ||
188 | #define CY_UDC_REQ_BUFFER_ADDR(ep_num) (CY_UDC_REQ_BUFFER_BASE + \ | ||
189 | ((ep_num) * CY_UDC_REQ_BUFFER_SIZE)) | ||
190 | |||
191 | /* --------------------------------------------------------------------- | ||
192 | * Driver data structures | ||
193 | */ | ||
194 | |||
195 | struct c67x00_device; | ||
196 | |||
197 | /** | ||
198 | * struct c67x00_sie - Common data associated with a SIE | ||
199 | * @lock: lock to protect this struct and the associated chip registers | ||
200 | * @private_data: subdriver dependent data | ||
201 | * @irq: subdriver dependent irq handler, set NULL when not used | ||
202 | * @dev: link to common driver structure | ||
203 | * @sie_num: SIE number on chip, starting from 0 | ||
204 | * @mode: SIE mode (host/peripheral/otg/not used) | ||
205 | */ | ||
206 | struct c67x00_sie { | ||
207 | /* Entries to be used by the subdrivers */ | ||
208 | spinlock_t lock; /* protect this structure */ | ||
209 | void *private_data; | ||
210 | void (*irq) (struct c67x00_sie *sie, u16 int_status, u16 msg); | ||
211 | |||
212 | /* Read only: */ | ||
213 | struct c67x00_device *dev; | ||
214 | int sie_num; | ||
215 | int mode; | ||
216 | }; | ||
217 | |||
218 | #define sie_dev(s) (&(s)->dev->pdev->dev) | ||
219 | |||
220 | /** | ||
221 | * struct c67x00_lcp | ||
222 | */ | ||
223 | struct c67x00_lcp { | ||
224 | /* Internal use only */ | ||
225 | struct mutex mutex; | ||
226 | struct completion msg_received; | ||
227 | u16 last_msg; | ||
228 | }; | ||
229 | |||
230 | /* | ||
231 | * struct c67x00_hpi | ||
232 | */ | ||
233 | struct c67x00_hpi { | ||
234 | void __iomem *base; | ||
235 | int regstep; | ||
236 | spinlock_t lock; | ||
237 | struct c67x00_lcp lcp; | ||
238 | }; | ||
239 | |||
240 | #define C67X00_SIES 2 | ||
241 | #define C67X00_PORTS 2 | ||
242 | |||
243 | /** | ||
244 | * struct c67x00_device - Common data associated with a c67x00 instance | ||
245 | * @hpi: hpi addresses | ||
246 | * @sie: array of sie's on this chip | ||
247 | * @pdev: platform device of instance | ||
248 | * @pdata: configuration provided by the platform | ||
249 | */ | ||
250 | struct c67x00_device { | ||
251 | struct c67x00_hpi hpi; | ||
252 | struct c67x00_sie sie[C67X00_SIES]; | ||
253 | struct platform_device *pdev; | ||
254 | struct c67x00_platform_data *pdata; | ||
255 | }; | ||
256 | |||
257 | /* --------------------------------------------------------------------- | ||
258 | * Low level interface functions | ||
259 | */ | ||
260 | |||
261 | /* Host Port Interface (HPI) functions */ | ||
262 | u16 c67x00_ll_hpi_status(struct c67x00_device *dev); | ||
263 | void c67x00_ll_hpi_reg_init(struct c67x00_device *dev); | ||
264 | void c67x00_ll_hpi_enable_sofeop(struct c67x00_sie *sie); | ||
265 | void c67x00_ll_hpi_disable_sofeop(struct c67x00_sie *sie); | ||
266 | |||
267 | /* General functions */ | ||
268 | u16 c67x00_ll_fetch_siemsg(struct c67x00_device *dev, int sie_num); | ||
269 | u16 c67x00_ll_get_usb_ctl(struct c67x00_sie *sie); | ||
270 | void c67x00_ll_usb_clear_status(struct c67x00_sie *sie, u16 bits); | ||
271 | u16 c67x00_ll_usb_get_status(struct c67x00_sie *sie); | ||
272 | void c67x00_ll_write_mem_le16(struct c67x00_device *dev, u16 addr, | ||
273 | void *data, int len); | ||
274 | void c67x00_ll_read_mem_le16(struct c67x00_device *dev, u16 addr, | ||
275 | void *data, int len); | ||
276 | |||
277 | /* Host specific functions */ | ||
278 | void c67x00_ll_set_husb_eot(struct c67x00_device *dev, u16 value); | ||
279 | void c67x00_ll_husb_reset(struct c67x00_sie *sie, int port); | ||
280 | void c67x00_ll_husb_set_current_td(struct c67x00_sie *sie, u16 addr); | ||
281 | u16 c67x00_ll_husb_get_current_td(struct c67x00_sie *sie); | ||
282 | u16 c67x00_ll_husb_get_frame(struct c67x00_sie *sie); | ||
283 | void c67x00_ll_husb_init_host_port(struct c67x00_sie *sie); | ||
284 | void c67x00_ll_husb_reset_port(struct c67x00_sie *sie, int port); | ||
285 | |||
286 | /* Called by c67x00_irq to handle lcp interrupts */ | ||
287 | void c67x00_ll_irq(struct c67x00_device *dev, u16 int_status); | ||
288 | |||
289 | /* Setup and teardown */ | ||
290 | void c67x00_ll_init(struct c67x00_device *dev); | ||
291 | void c67x00_ll_release(struct c67x00_device *dev); | ||
292 | int c67x00_ll_reset(struct c67x00_device *dev); | ||
293 | |||
294 | #endif /* _USB_C67X00_H */ | ||
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index e819e5359d57..3e69266e1f4d 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -394,7 +394,9 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, | |||
394 | if (!io->urbs) | 394 | if (!io->urbs) |
395 | goto nomem; | 395 | goto nomem; |
396 | 396 | ||
397 | urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; | 397 | urb_flags = URB_NO_INTERRUPT; |
398 | if (dma) | ||
399 | urb_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
398 | if (usb_pipein(pipe)) | 400 | if (usb_pipein(pipe)) |
399 | urb_flags |= URB_SHORT_NOT_OK; | 401 | urb_flags |= URB_SHORT_NOT_OK; |
400 | 402 | ||
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index f7b54651dd42..6e784d2db423 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -231,6 +231,26 @@ config SUPERH_BUILT_IN_M66592 | |||
231 | However, this problem is improved if change a value of | 231 | However, this problem is improved if change a value of |
232 | NET_IP_ALIGN to 4. | 232 | NET_IP_ALIGN to 4. |
233 | 233 | ||
234 | config USB_GADGET_PXA27X | ||
235 | boolean "PXA 27x" | ||
236 | depends on ARCH_PXA && PXA27x | ||
237 | help | ||
238 | Intel's PXA 27x series XScale ARM v5TE processors include | ||
239 | an integrated full speed USB 1.1 device controller. | ||
240 | |||
241 | It has up to 23 endpoints, as well as endpoint zero (for | ||
242 | control transfers). | ||
243 | |||
244 | Say "y" to link the driver statically, or "m" to build a | ||
245 | dynamically linked module called "pxa27x_udc" and force all | ||
246 | gadget drivers to also be dynamically linked. | ||
247 | |||
248 | config USB_PXA27X | ||
249 | tristate | ||
250 | depends on USB_GADGET_PXA27X | ||
251 | default USB_GADGET | ||
252 | select USB_GADGET_SELECTED | ||
253 | |||
234 | config USB_GADGET_GOKU | 254 | config USB_GADGET_GOKU |
235 | boolean "Toshiba TC86C001 'Goku-S'" | 255 | boolean "Toshiba TC86C001 'Goku-S'" |
236 | depends on PCI | 256 | depends on PCI |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index c3aab80b6c76..12357255d740 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o | |||
9 | obj-$(CONFIG_USB_NET2280) += net2280.o | 9 | obj-$(CONFIG_USB_NET2280) += net2280.o |
10 | obj-$(CONFIG_USB_AMD5536UDC) += amd5536udc.o | 10 | obj-$(CONFIG_USB_AMD5536UDC) += amd5536udc.o |
11 | obj-$(CONFIG_USB_PXA2XX) += pxa2xx_udc.o | 11 | obj-$(CONFIG_USB_PXA2XX) += pxa2xx_udc.o |
12 | obj-$(CONFIG_USB_PXA27X) += pxa27x_udc.o | ||
12 | obj-$(CONFIG_USB_GOKU) += goku_udc.o | 13 | obj-$(CONFIG_USB_GOKU) += goku_udc.o |
13 | obj-$(CONFIG_USB_OMAP) += omap_udc.o | 14 | obj-$(CONFIG_USB_OMAP) += omap_udc.o |
14 | obj-$(CONFIG_USB_LH7A40X) += lh7a40x_udc.o | 15 | obj-$(CONFIG_USB_LH7A40X) += lh7a40x_udc.o |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index bb93bdd76593..8d61ea67a817 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -235,10 +235,6 @@ MODULE_PARM_DESC(host_addr, "Host Ethernet Address"); | |||
235 | #define DEV_CONFIG_CDC | 235 | #define DEV_CONFIG_CDC |
236 | #endif | 236 | #endif |
237 | 237 | ||
238 | #ifdef CONFIG_USB_GADGET_PXA27X | ||
239 | #define DEV_CONFIG_CDC | ||
240 | #endif | ||
241 | |||
242 | #ifdef CONFIG_USB_GADGET_S3C2410 | 238 | #ifdef CONFIG_USB_GADGET_S3C2410 |
243 | #define DEV_CONFIG_CDC | 239 | #define DEV_CONFIG_CDC |
244 | #endif | 240 | #endif |
@@ -270,6 +266,10 @@ MODULE_PARM_DESC(host_addr, "Host Ethernet Address"); | |||
270 | #define DEV_CONFIG_SUBSET | 266 | #define DEV_CONFIG_SUBSET |
271 | #endif | 267 | #endif |
272 | 268 | ||
269 | #ifdef CONFIG_USB_GADGET_PXA27X | ||
270 | #define DEV_CONFIG_SUBSET | ||
271 | #endif | ||
272 | |||
273 | #ifdef CONFIG_USB_GADGET_SUPERH | 273 | #ifdef CONFIG_USB_GADGET_SUPERH |
274 | #define DEV_CONFIG_SUBSET | 274 | #define DEV_CONFIG_SUBSET |
275 | #endif | 275 | #endif |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index bf3f946fd455..47bb9f09a1aa 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -2307,6 +2307,29 @@ static int halt_bulk_in_endpoint(struct fsg_dev *fsg) | |||
2307 | return rc; | 2307 | return rc; |
2308 | } | 2308 | } |
2309 | 2309 | ||
2310 | static int wedge_bulk_in_endpoint(struct fsg_dev *fsg) | ||
2311 | { | ||
2312 | int rc; | ||
2313 | |||
2314 | DBG(fsg, "bulk-in set wedge\n"); | ||
2315 | rc = usb_ep_set_wedge(fsg->bulk_in); | ||
2316 | if (rc == -EAGAIN) | ||
2317 | VDBG(fsg, "delayed bulk-in endpoint wedge\n"); | ||
2318 | while (rc != 0) { | ||
2319 | if (rc != -EAGAIN) { | ||
2320 | WARN(fsg, "usb_ep_set_wedge -> %d\n", rc); | ||
2321 | rc = 0; | ||
2322 | break; | ||
2323 | } | ||
2324 | |||
2325 | /* Wait for a short time and then try again */ | ||
2326 | if (msleep_interruptible(100) != 0) | ||
2327 | return -EINTR; | ||
2328 | rc = usb_ep_set_wedge(fsg->bulk_in); | ||
2329 | } | ||
2330 | return rc; | ||
2331 | } | ||
2332 | |||
2310 | static int pad_with_zeros(struct fsg_dev *fsg) | 2333 | static int pad_with_zeros(struct fsg_dev *fsg) |
2311 | { | 2334 | { |
2312 | struct fsg_buffhd *bh = fsg->next_buffhd_to_fill; | 2335 | struct fsg_buffhd *bh = fsg->next_buffhd_to_fill; |
@@ -2957,7 +2980,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2957 | * We aren't required to halt the OUT endpoint; instead | 2980 | * We aren't required to halt the OUT endpoint; instead |
2958 | * we can simply accept and discard any data received | 2981 | * we can simply accept and discard any data received |
2959 | * until the next reset. */ | 2982 | * until the next reset. */ |
2960 | halt_bulk_in_endpoint(fsg); | 2983 | wedge_bulk_in_endpoint(fsg); |
2961 | set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); | 2984 | set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); |
2962 | return -EINVAL; | 2985 | return -EINVAL; |
2963 | } | 2986 | } |
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c new file mode 100644 index 000000000000..75eba202f737 --- /dev/null +++ b/drivers/usb/gadget/pxa27x_udc.c | |||
@@ -0,0 +1,2404 @@ | |||
1 | /* | ||
2 | * Handles the Intel 27x USB Device Controller (UDC) | ||
3 | * | ||
4 | * Inspired by original driver by Frank Becker, David Brownell, and others. | ||
5 | * Copyright (C) 2008 Robert Jarzmik | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/types.h> | ||
25 | #include <linux/version.h> | ||
26 | #include <linux/errno.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/delay.h> | ||
29 | #include <linux/list.h> | ||
30 | #include <linux/interrupt.h> | ||
31 | #include <linux/proc_fs.h> | ||
32 | #include <linux/clk.h> | ||
33 | #include <linux/irq.h> | ||
34 | |||
35 | #include <asm/byteorder.h> | ||
36 | #include <asm/hardware.h> | ||
37 | |||
38 | #include <linux/usb.h> | ||
39 | #include <linux/usb/ch9.h> | ||
40 | #include <linux/usb/gadget.h> | ||
41 | |||
42 | #include <asm/arch/udc.h> | ||
43 | |||
44 | #include "pxa27x_udc.h" | ||
45 | |||
46 | /* | ||
47 | * This driver handles the USB Device Controller (UDC) in Intel's PXA 27x | ||
48 | * series processors. | ||
49 | * | ||
50 | * Such controller drivers work with a gadget driver. The gadget driver | ||
51 | * returns descriptors, implements configuration and data protocols used | ||
52 | * by the host to interact with this device, and allocates endpoints to | ||
53 | * the different protocol interfaces. The controller driver virtualizes | ||
54 | * usb hardware so that the gadget drivers will be more portable. | ||
55 | * | ||
56 | * This UDC hardware wants to implement a bit too much USB protocol. The | ||
57 | * biggest issues are: that the endpoints have to be set up before the | ||
58 | * controller can be enabled (minor, and not uncommon); and each endpoint | ||
59 | * can only have one configuration, interface and alternative interface | ||
60 | * number (major, and very unusual). Once set up, these cannot be changed | ||
61 | * without a controller reset. | ||
62 | * | ||
63 | * The workaround is to setup all combinations necessary for the gadgets which | ||
64 | * will work with this driver. This is done in pxa_udc structure, statically. | ||
65 | * See pxa_udc, udc_usb_ep versus pxa_ep, and matching function find_pxa_ep. | ||
66 | * (You could modify this if needed. Some drivers have a "fifo_mode" module | ||
67 | * parameter to facilitate such changes.) | ||
68 | * | ||
69 | * The combinations have been tested with these gadgets : | ||
70 | * - zero gadget | ||
71 | * - file storage gadget | ||
72 | * - ether gadget | ||
73 | * | ||
74 | * The driver doesn't use DMA, only IO access and IRQ callbacks. No use is | ||
75 | * made of UDC's double buffering either. USB "On-The-Go" is not implemented. | ||
76 | * | ||
77 | * All the requests are handled the same way : | ||
78 | * - the drivers tries to handle the request directly to the IO | ||
79 | * - if the IO fifo is not big enough, the remaining is send/received in | ||
80 | * interrupt handling. | ||
81 | */ | ||
82 | |||
83 | #define DRIVER_VERSION "2008-04-18" | ||
84 | #define DRIVER_DESC "PXA 27x USB Device Controller driver" | ||
85 | |||
86 | static const char driver_name[] = "pxa27x_udc"; | ||
87 | static struct pxa_udc *the_controller; | ||
88 | |||
89 | static void handle_ep(struct pxa_ep *ep); | ||
90 | |||
91 | /* | ||
92 | * Debug filesystem | ||
93 | */ | ||
94 | #ifdef CONFIG_USB_GADGET_DEBUG_FS | ||
95 | |||
96 | #include <linux/debugfs.h> | ||
97 | #include <linux/uaccess.h> | ||
98 | #include <linux/seq_file.h> | ||
99 | |||
100 | static int state_dbg_show(struct seq_file *s, void *p) | ||
101 | { | ||
102 | struct pxa_udc *udc = s->private; | ||
103 | int pos = 0, ret; | ||
104 | u32 tmp; | ||
105 | |||
106 | ret = -ENODEV; | ||
107 | if (!udc->driver) | ||
108 | goto out; | ||
109 | |||
110 | /* basic device status */ | ||
111 | pos += seq_printf(s, DRIVER_DESC "\n" | ||
112 | "%s version: %s\nGadget driver: %s\n", | ||
113 | driver_name, DRIVER_VERSION, | ||
114 | udc->driver ? udc->driver->driver.name : "(none)"); | ||
115 | |||
116 | tmp = udc_readl(udc, UDCCR); | ||
117 | pos += seq_printf(s, | ||
118 | "udccr=0x%0x(%s%s%s%s%s%s%s%s%s%s), " | ||
119 | "con=%d,inter=%d,altinter=%d\n", tmp, | ||
120 | (tmp & UDCCR_OEN) ? " oen":"", | ||
121 | (tmp & UDCCR_AALTHNP) ? " aalthnp":"", | ||
122 | (tmp & UDCCR_AHNP) ? " rem" : "", | ||
123 | (tmp & UDCCR_BHNP) ? " rstir" : "", | ||
124 | (tmp & UDCCR_DWRE) ? " dwre" : "", | ||
125 | (tmp & UDCCR_SMAC) ? " smac" : "", | ||
126 | (tmp & UDCCR_EMCE) ? " emce" : "", | ||
127 | (tmp & UDCCR_UDR) ? " udr" : "", | ||
128 | (tmp & UDCCR_UDA) ? " uda" : "", | ||
129 | (tmp & UDCCR_UDE) ? " ude" : "", | ||
130 | (tmp & UDCCR_ACN) >> UDCCR_ACN_S, | ||
131 | (tmp & UDCCR_AIN) >> UDCCR_AIN_S, | ||
132 | (tmp & UDCCR_AAISN) >> UDCCR_AAISN_S); | ||
133 | /* registers for device and ep0 */ | ||
134 | pos += seq_printf(s, "udcicr0=0x%08x udcicr1=0x%08x\n", | ||
135 | udc_readl(udc, UDCICR0), udc_readl(udc, UDCICR1)); | ||
136 | pos += seq_printf(s, "udcisr0=0x%08x udcisr1=0x%08x\n", | ||
137 | udc_readl(udc, UDCISR0), udc_readl(udc, UDCISR1)); | ||
138 | pos += seq_printf(s, "udcfnr=%d\n", udc_readl(udc, UDCFNR)); | ||
139 | pos += seq_printf(s, "irqs: reset=%lu, suspend=%lu, resume=%lu, " | ||
140 | "reconfig=%lu\n", | ||
141 | udc->stats.irqs_reset, udc->stats.irqs_suspend, | ||
142 | udc->stats.irqs_resume, udc->stats.irqs_reconfig); | ||
143 | |||
144 | ret = 0; | ||
145 | out: | ||
146 | return ret; | ||
147 | } | ||
148 | |||
149 | static int queues_dbg_show(struct seq_file *s, void *p) | ||
150 | { | ||
151 | struct pxa_udc *udc = s->private; | ||
152 | struct pxa_ep *ep; | ||
153 | struct pxa27x_request *req; | ||
154 | int pos = 0, i, maxpkt, ret; | ||
155 | |||
156 | ret = -ENODEV; | ||
157 | if (!udc->driver) | ||
158 | goto out; | ||
159 | |||
160 | /* dump endpoint queues */ | ||
161 | for (i = 0; i < NR_PXA_ENDPOINTS; i++) { | ||
162 | ep = &udc->pxa_ep[i]; | ||
163 | maxpkt = ep->fifo_size; | ||
164 | pos += seq_printf(s, "%-12s max_pkt=%d %s\n", | ||
165 | EPNAME(ep), maxpkt, "pio"); | ||
166 | |||
167 | if (list_empty(&ep->queue)) { | ||
168 | pos += seq_printf(s, "\t(nothing queued)\n"); | ||
169 | continue; | ||
170 | } | ||
171 | |||
172 | list_for_each_entry(req, &ep->queue, queue) { | ||
173 | pos += seq_printf(s, "\treq %p len %d/%d buf %p\n", | ||
174 | &req->req, req->req.actual, | ||
175 | req->req.length, req->req.buf); | ||
176 | } | ||
177 | } | ||
178 | |||
179 | ret = 0; | ||
180 | out: | ||
181 | return ret; | ||
182 | } | ||
183 | |||
184 | static int eps_dbg_show(struct seq_file *s, void *p) | ||
185 | { | ||
186 | struct pxa_udc *udc = s->private; | ||
187 | struct pxa_ep *ep; | ||
188 | int pos = 0, i, ret; | ||
189 | u32 tmp; | ||
190 | |||
191 | ret = -ENODEV; | ||
192 | if (!udc->driver) | ||
193 | goto out; | ||
194 | |||
195 | ep = &udc->pxa_ep[0]; | ||
196 | tmp = udc_ep_readl(ep, UDCCSR); | ||
197 | pos += seq_printf(s, "udccsr0=0x%03x(%s%s%s%s%s%s%s)\n", tmp, | ||
198 | (tmp & UDCCSR0_SA) ? " sa" : "", | ||
199 | (tmp & UDCCSR0_RNE) ? " rne" : "", | ||
200 | (tmp & UDCCSR0_FST) ? " fst" : "", | ||
201 | (tmp & UDCCSR0_SST) ? " sst" : "", | ||
202 | (tmp & UDCCSR0_DME) ? " dme" : "", | ||
203 | (tmp & UDCCSR0_IPR) ? " ipr" : "", | ||
204 | (tmp & UDCCSR0_OPC) ? " opc" : ""); | ||
205 | for (i = 0; i < NR_PXA_ENDPOINTS; i++) { | ||
206 | ep = &udc->pxa_ep[i]; | ||
207 | tmp = i? udc_ep_readl(ep, UDCCR) : udc_readl(udc, UDCCR); | ||
208 | pos += seq_printf(s, "%-12s: " | ||
209 | "IN %lu(%lu reqs), OUT %lu(%lu reqs), " | ||
210 | "irqs=%lu, udccr=0x%08x, udccsr=0x%03x, " | ||
211 | "udcbcr=%d\n", | ||
212 | EPNAME(ep), | ||
213 | ep->stats.in_bytes, ep->stats.in_ops, | ||
214 | ep->stats.out_bytes, ep->stats.out_ops, | ||
215 | ep->stats.irqs, | ||
216 | tmp, udc_ep_readl(ep, UDCCSR), | ||
217 | udc_ep_readl(ep, UDCBCR)); | ||
218 | } | ||
219 | |||
220 | ret = 0; | ||
221 | out: | ||
222 | return ret; | ||
223 | } | ||
224 | |||
225 | static int eps_dbg_open(struct inode *inode, struct file *file) | ||
226 | { | ||
227 | return single_open(file, eps_dbg_show, inode->i_private); | ||
228 | } | ||
229 | |||
230 | static int queues_dbg_open(struct inode *inode, struct file *file) | ||
231 | { | ||
232 | return single_open(file, queues_dbg_show, inode->i_private); | ||
233 | } | ||
234 | |||
235 | static int state_dbg_open(struct inode *inode, struct file *file) | ||
236 | { | ||
237 | return single_open(file, state_dbg_show, inode->i_private); | ||
238 | } | ||
239 | |||
240 | static const struct file_operations state_dbg_fops = { | ||
241 | .owner = THIS_MODULE, | ||
242 | .open = state_dbg_open, | ||
243 | .llseek = seq_lseek, | ||
244 | .read = seq_read, | ||
245 | .release = single_release, | ||
246 | }; | ||
247 | |||
248 | static const struct file_operations queues_dbg_fops = { | ||
249 | .owner = THIS_MODULE, | ||
250 | .open = queues_dbg_open, | ||
251 | .llseek = seq_lseek, | ||
252 | .read = seq_read, | ||
253 | .release = single_release, | ||
254 | }; | ||
255 | |||
256 | static const struct file_operations eps_dbg_fops = { | ||
257 | .owner = THIS_MODULE, | ||
258 | .open = eps_dbg_open, | ||
259 | .llseek = seq_lseek, | ||
260 | .read = seq_read, | ||
261 | .release = single_release, | ||
262 | }; | ||
263 | |||
264 | static void pxa_init_debugfs(struct pxa_udc *udc) | ||
265 | { | ||
266 | struct dentry *root, *state, *queues, *eps; | ||
267 | |||
268 | root = debugfs_create_dir(udc->gadget.name, NULL); | ||
269 | if (IS_ERR(root) || !root) | ||
270 | goto err_root; | ||
271 | |||
272 | state = debugfs_create_file("udcstate", 0400, root, udc, | ||
273 | &state_dbg_fops); | ||
274 | if (!state) | ||
275 | goto err_state; | ||
276 | queues = debugfs_create_file("queues", 0400, root, udc, | ||
277 | &queues_dbg_fops); | ||
278 | if (!queues) | ||
279 | goto err_queues; | ||
280 | eps = debugfs_create_file("epstate", 0400, root, udc, | ||
281 | &eps_dbg_fops); | ||
282 | if (!queues) | ||
283 | goto err_eps; | ||
284 | |||
285 | udc->debugfs_root = root; | ||
286 | udc->debugfs_state = state; | ||
287 | udc->debugfs_queues = queues; | ||
288 | udc->debugfs_eps = eps; | ||
289 | return; | ||
290 | err_eps: | ||
291 | debugfs_remove(eps); | ||
292 | err_queues: | ||
293 | debugfs_remove(queues); | ||
294 | err_state: | ||
295 | debugfs_remove(root); | ||
296 | err_root: | ||
297 | dev_err(udc->dev, "debugfs is not available\n"); | ||
298 | } | ||
299 | |||
300 | static void pxa_cleanup_debugfs(struct pxa_udc *udc) | ||
301 | { | ||
302 | debugfs_remove(udc->debugfs_eps); | ||
303 | debugfs_remove(udc->debugfs_queues); | ||
304 | debugfs_remove(udc->debugfs_state); | ||
305 | debugfs_remove(udc->debugfs_root); | ||
306 | udc->debugfs_eps = NULL; | ||
307 | udc->debugfs_queues = NULL; | ||
308 | udc->debugfs_state = NULL; | ||
309 | udc->debugfs_root = NULL; | ||
310 | } | ||
311 | |||
312 | #else | ||
313 | static inline void pxa_init_debugfs(struct pxa_udc *udc) | ||
314 | { | ||
315 | } | ||
316 | |||
317 | static inline void pxa_cleanup_debugfs(struct pxa_udc *udc) | ||
318 | { | ||
319 | } | ||
320 | #endif | ||
321 | |||
322 | /** | ||
323 | * is_match_usb_pxa - check if usb_ep and pxa_ep match | ||
324 | * @udc_usb_ep: usb endpoint | ||
325 | * @ep: pxa endpoint | ||
326 | * @config: configuration required in pxa_ep | ||
327 | * @interface: interface required in pxa_ep | ||
328 | * @altsetting: altsetting required in pxa_ep | ||
329 | * | ||
330 | * Returns 1 if all criteria match between pxa and usb endpoint, 0 otherwise | ||
331 | */ | ||
332 | static int is_match_usb_pxa(struct udc_usb_ep *udc_usb_ep, struct pxa_ep *ep, | ||
333 | int config, int interface, int altsetting) | ||
334 | { | ||
335 | if (usb_endpoint_num(&udc_usb_ep->desc) != ep->addr) | ||
336 | return 0; | ||
337 | if (usb_endpoint_dir_in(&udc_usb_ep->desc) != ep->dir_in) | ||
338 | return 0; | ||
339 | if (usb_endpoint_type(&udc_usb_ep->desc) != ep->type) | ||
340 | return 0; | ||
341 | if ((ep->config != config) || (ep->interface != interface) | ||
342 | || (ep->alternate != altsetting)) | ||
343 | return 0; | ||
344 | return 1; | ||
345 | } | ||
346 | |||
347 | /** | ||
348 | * find_pxa_ep - find pxa_ep structure matching udc_usb_ep | ||
349 | * @udc: pxa udc | ||
350 | * @udc_usb_ep: udc_usb_ep structure | ||
351 | * | ||
352 | * Match udc_usb_ep and all pxa_ep available, to see if one matches. | ||
353 | * This is necessary because of the strong pxa hardware restriction requiring | ||
354 | * that once pxa endpoints are initialized, their configuration is freezed, and | ||
355 | * no change can be made to their address, direction, or in which configuration, | ||
356 | * interface or altsetting they are active ... which differs from more usual | ||
357 | * models which have endpoints be roughly just addressable fifos, and leave | ||
358 | * configuration events up to gadget drivers (like all control messages). | ||
359 | * | ||
360 | * Note that there is still a blurred point here : | ||
361 | * - we rely on UDCCR register "active interface" and "active altsetting". | ||
362 | * This is a nonsense in regard of USB spec, where multiple interfaces are | ||
363 | * active at the same time. | ||
364 | * - if we knew for sure that the pxa can handle multiple interface at the | ||
365 | * same time, assuming Intel's Developer Guide is wrong, this function | ||
366 | * should be reviewed, and a cache of couples (iface, altsetting) should | ||
367 | * be kept in the pxa_udc structure. In this case this function would match | ||
368 | * against the cache of couples instead of the "last altsetting" set up. | ||
369 | * | ||
370 | * Returns the matched pxa_ep structure or NULL if none found | ||
371 | */ | ||
372 | static struct pxa_ep *find_pxa_ep(struct pxa_udc *udc, | ||
373 | struct udc_usb_ep *udc_usb_ep) | ||
374 | { | ||
375 | int i; | ||
376 | struct pxa_ep *ep; | ||
377 | int cfg = udc->config; | ||
378 | int iface = udc->last_interface; | ||
379 | int alt = udc->last_alternate; | ||
380 | |||
381 | if (udc_usb_ep == &udc->udc_usb_ep[0]) | ||
382 | return &udc->pxa_ep[0]; | ||
383 | |||
384 | for (i = 1; i < NR_PXA_ENDPOINTS; i++) { | ||
385 | ep = &udc->pxa_ep[i]; | ||
386 | if (is_match_usb_pxa(udc_usb_ep, ep, cfg, iface, alt)) | ||
387 | return ep; | ||
388 | } | ||
389 | return NULL; | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * update_pxa_ep_matches - update pxa_ep cached values in all udc_usb_ep | ||
394 | * @udc: pxa udc | ||
395 | * | ||
396 | * Context: in_interrupt() | ||
397 | * | ||
398 | * Updates all pxa_ep fields in udc_usb_ep structures, if this field was | ||
399 | * previously set up (and is not NULL). The update is necessary is a | ||
400 | * configuration change or altsetting change was issued by the USB host. | ||
401 | */ | ||
402 | static void update_pxa_ep_matches(struct pxa_udc *udc) | ||
403 | { | ||
404 | int i; | ||
405 | struct udc_usb_ep *udc_usb_ep; | ||
406 | |||
407 | for (i = 1; i < NR_USB_ENDPOINTS; i++) { | ||
408 | udc_usb_ep = &udc->udc_usb_ep[i]; | ||
409 | if (udc_usb_ep->pxa_ep) | ||
410 | udc_usb_ep->pxa_ep = find_pxa_ep(udc, udc_usb_ep); | ||
411 | } | ||
412 | } | ||
413 | |||
414 | /** | ||
415 | * pio_irq_enable - Enables irq generation for one endpoint | ||
416 | * @ep: udc endpoint | ||
417 | */ | ||
418 | static void pio_irq_enable(struct pxa_ep *ep) | ||
419 | { | ||
420 | struct pxa_udc *udc = ep->dev; | ||
421 | int index = EPIDX(ep); | ||
422 | u32 udcicr0 = udc_readl(udc, UDCICR0); | ||
423 | u32 udcicr1 = udc_readl(udc, UDCICR1); | ||
424 | |||
425 | if (index < 16) | ||
426 | udc_writel(udc, UDCICR0, udcicr0 | (3 << (index * 2))); | ||
427 | else | ||
428 | udc_writel(udc, UDCICR1, udcicr1 | (3 << ((index - 16) * 2))); | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * pio_irq_disable - Disables irq generation for one endpoint | ||
433 | * @ep: udc endpoint | ||
434 | * @index: endpoint number | ||
435 | */ | ||
436 | static void pio_irq_disable(struct pxa_ep *ep) | ||
437 | { | ||
438 | struct pxa_udc *udc = ep->dev; | ||
439 | int index = EPIDX(ep); | ||
440 | u32 udcicr0 = udc_readl(udc, UDCICR0); | ||
441 | u32 udcicr1 = udc_readl(udc, UDCICR1); | ||
442 | |||
443 | if (index < 16) | ||
444 | udc_writel(udc, UDCICR0, udcicr0 & ~(3 << (index * 2))); | ||
445 | else | ||
446 | udc_writel(udc, UDCICR1, udcicr1 & ~(3 << ((index - 16) * 2))); | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * udc_set_mask_UDCCR - set bits in UDCCR | ||
451 | * @udc: udc device | ||
452 | * @mask: bits to set in UDCCR | ||
453 | * | ||
454 | * Sets bits in UDCCR, leaving DME and FST bits as they were. | ||
455 | */ | ||
456 | static inline void udc_set_mask_UDCCR(struct pxa_udc *udc, int mask) | ||
457 | { | ||
458 | u32 udccr = udc_readl(udc, UDCCR); | ||
459 | udc_writel(udc, UDCCR, | ||
460 | (udccr & UDCCR_MASK_BITS) | (mask & UDCCR_MASK_BITS)); | ||
461 | } | ||
462 | |||
463 | /** | ||
464 | * udc_clear_mask_UDCCR - clears bits in UDCCR | ||
465 | * @udc: udc device | ||
466 | * @mask: bit to clear in UDCCR | ||
467 | * | ||
468 | * Clears bits in UDCCR, leaving DME and FST bits as they were. | ||
469 | */ | ||
470 | static inline void udc_clear_mask_UDCCR(struct pxa_udc *udc, int mask) | ||
471 | { | ||
472 | u32 udccr = udc_readl(udc, UDCCR); | ||
473 | udc_writel(udc, UDCCR, | ||
474 | (udccr & UDCCR_MASK_BITS) & ~(mask & UDCCR_MASK_BITS)); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * ep_count_bytes_remain - get how many bytes in udc endpoint | ||
479 | * @ep: udc endpoint | ||
480 | * | ||
481 | * Returns number of bytes in OUT fifos. Broken for IN fifos (-EOPNOTSUPP) | ||
482 | */ | ||
483 | static int ep_count_bytes_remain(struct pxa_ep *ep) | ||
484 | { | ||
485 | if (ep->dir_in) | ||
486 | return -EOPNOTSUPP; | ||
487 | return udc_ep_readl(ep, UDCBCR) & 0x3ff; | ||
488 | } | ||
489 | |||
490 | /** | ||
491 | * ep_is_empty - checks if ep has byte ready for reading | ||
492 | * @ep: udc endpoint | ||
493 | * | ||
494 | * If endpoint is the control endpoint, checks if there are bytes in the | ||
495 | * control endpoint fifo. If endpoint is a data endpoint, checks if bytes | ||
496 | * are ready for reading on OUT endpoint. | ||
497 | * | ||
498 | * Returns 0 if ep not empty, 1 if ep empty, -EOPNOTSUPP if IN endpoint | ||
499 | */ | ||
500 | static int ep_is_empty(struct pxa_ep *ep) | ||
501 | { | ||
502 | int ret; | ||
503 | |||
504 | if (!is_ep0(ep) && ep->dir_in) | ||
505 | return -EOPNOTSUPP; | ||
506 | if (is_ep0(ep)) | ||
507 | ret = !(udc_ep_readl(ep, UDCCSR) & UDCCSR0_RNE); | ||
508 | else | ||
509 | ret = !(udc_ep_readl(ep, UDCCSR) & UDCCSR_BNE); | ||
510 | return ret; | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * ep_is_full - checks if ep has place to write bytes | ||
515 | * @ep: udc endpoint | ||
516 | * | ||
517 | * If endpoint is not the control endpoint and is an IN endpoint, checks if | ||
518 | * there is place to write bytes into the endpoint. | ||
519 | * | ||
520 | * Returns 0 if ep not full, 1 if ep full, -EOPNOTSUPP if OUT endpoint | ||
521 | */ | ||
522 | static int ep_is_full(struct pxa_ep *ep) | ||
523 | { | ||
524 | if (is_ep0(ep)) | ||
525 | return (udc_ep_readl(ep, UDCCSR) & UDCCSR0_IPR); | ||
526 | if (!ep->dir_in) | ||
527 | return -EOPNOTSUPP; | ||
528 | return (!(udc_ep_readl(ep, UDCCSR) & UDCCSR_BNF)); | ||
529 | } | ||
530 | |||
531 | /** | ||
532 | * epout_has_pkt - checks if OUT endpoint fifo has a packet available | ||
533 | * @ep: pxa endpoint | ||
534 | * | ||
535 | * Returns 1 if a complete packet is available, 0 if not, -EOPNOTSUPP for IN ep. | ||
536 | */ | ||
537 | static int epout_has_pkt(struct pxa_ep *ep) | ||
538 | { | ||
539 | if (!is_ep0(ep) && ep->dir_in) | ||
540 | return -EOPNOTSUPP; | ||
541 | if (is_ep0(ep)) | ||
542 | return (udc_ep_readl(ep, UDCCSR) & UDCCSR0_OPC); | ||
543 | return (udc_ep_readl(ep, UDCCSR) & UDCCSR_PC); | ||
544 | } | ||
545 | |||
546 | /** | ||
547 | * set_ep0state - Set ep0 automata state | ||
548 | * @dev: udc device | ||
549 | * @state: state | ||
550 | */ | ||
551 | static void set_ep0state(struct pxa_udc *udc, int state) | ||
552 | { | ||
553 | struct pxa_ep *ep = &udc->pxa_ep[0]; | ||
554 | char *old_stname = EP0_STNAME(udc); | ||
555 | |||
556 | udc->ep0state = state; | ||
557 | ep_dbg(ep, "state=%s->%s, udccsr0=0x%03x, udcbcr=%d\n", old_stname, | ||
558 | EP0_STNAME(udc), udc_ep_readl(ep, UDCCSR), | ||
559 | udc_ep_readl(ep, UDCBCR)); | ||
560 | } | ||
561 | |||
562 | /** | ||
563 | * ep0_idle - Put control endpoint into idle state | ||
564 | * @dev: udc device | ||
565 | */ | ||
566 | static void ep0_idle(struct pxa_udc *dev) | ||
567 | { | ||
568 | set_ep0state(dev, WAIT_FOR_SETUP); | ||
569 | } | ||
570 | |||
571 | /** | ||
572 | * inc_ep_stats_reqs - Update ep stats counts | ||
573 | * @ep: physical endpoint | ||
574 | * @req: usb request | ||
575 | * @is_in: ep direction (USB_DIR_IN or 0) | ||
576 | * | ||
577 | */ | ||
578 | static void inc_ep_stats_reqs(struct pxa_ep *ep, int is_in) | ||
579 | { | ||
580 | if (is_in) | ||
581 | ep->stats.in_ops++; | ||
582 | else | ||
583 | ep->stats.out_ops++; | ||
584 | } | ||
585 | |||
586 | /** | ||
587 | * inc_ep_stats_bytes - Update ep stats counts | ||
588 | * @ep: physical endpoint | ||
589 | * @count: bytes transfered on endpoint | ||
590 | * @req: usb request | ||
591 | * @is_in: ep direction (USB_DIR_IN or 0) | ||
592 | */ | ||
593 | static void inc_ep_stats_bytes(struct pxa_ep *ep, int count, int is_in) | ||
594 | { | ||
595 | if (is_in) | ||
596 | ep->stats.in_bytes += count; | ||
597 | else | ||
598 | ep->stats.out_bytes += count; | ||
599 | } | ||
600 | |||
601 | /** | ||
602 | * pxa_ep_setup - Sets up an usb physical endpoint | ||
603 | * @ep: pxa27x physical endpoint | ||
604 | * | ||
605 | * Find the physical pxa27x ep, and setup its UDCCR | ||
606 | */ | ||
607 | static __init void pxa_ep_setup(struct pxa_ep *ep) | ||
608 | { | ||
609 | u32 new_udccr; | ||
610 | |||
611 | new_udccr = ((ep->config << UDCCONR_CN_S) & UDCCONR_CN) | ||
612 | | ((ep->interface << UDCCONR_IN_S) & UDCCONR_IN) | ||
613 | | ((ep->alternate << UDCCONR_AISN_S) & UDCCONR_AISN) | ||
614 | | ((EPADDR(ep) << UDCCONR_EN_S) & UDCCONR_EN) | ||
615 | | ((EPXFERTYPE(ep) << UDCCONR_ET_S) & UDCCONR_ET) | ||
616 | | ((ep->dir_in) ? UDCCONR_ED : 0) | ||
617 | | ((ep->fifo_size << UDCCONR_MPS_S) & UDCCONR_MPS) | ||
618 | | UDCCONR_EE; | ||
619 | |||
620 | udc_ep_writel(ep, UDCCR, new_udccr); | ||
621 | } | ||
622 | |||
623 | /** | ||
624 | * pxa_eps_setup - Sets up all usb physical endpoints | ||
625 | * @dev: udc device | ||
626 | * | ||
627 | * Setup all pxa physical endpoints, except ep0 | ||
628 | */ | ||
629 | static __init void pxa_eps_setup(struct pxa_udc *dev) | ||
630 | { | ||
631 | unsigned int i; | ||
632 | |||
633 | dev_dbg(dev->dev, "%s: dev=%p\n", __func__, dev); | ||
634 | |||
635 | for (i = 1; i < NR_PXA_ENDPOINTS; i++) | ||
636 | pxa_ep_setup(&dev->pxa_ep[i]); | ||
637 | } | ||
638 | |||
639 | /** | ||
640 | * pxa_ep_alloc_request - Allocate usb request | ||
641 | * @_ep: usb endpoint | ||
642 | * @gfp_flags: | ||
643 | * | ||
644 | * For the pxa27x, these can just wrap kmalloc/kfree. gadget drivers | ||
645 | * must still pass correctly initialized endpoints, since other controller | ||
646 | * drivers may care about how it's currently set up (dma issues etc). | ||
647 | */ | ||
648 | static struct usb_request * | ||
649 | pxa_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) | ||
650 | { | ||
651 | struct pxa27x_request *req; | ||
652 | |||
653 | req = kzalloc(sizeof *req, gfp_flags); | ||
654 | if (!req || !_ep) | ||
655 | return NULL; | ||
656 | |||
657 | INIT_LIST_HEAD(&req->queue); | ||
658 | req->in_use = 0; | ||
659 | req->udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); | ||
660 | |||
661 | return &req->req; | ||
662 | } | ||
663 | |||
664 | /** | ||
665 | * pxa_ep_free_request - Free usb request | ||
666 | * @_ep: usb endpoint | ||
667 | * @_req: usb request | ||
668 | * | ||
669 | * Wrapper around kfree to free _req | ||
670 | */ | ||
671 | static void pxa_ep_free_request(struct usb_ep *_ep, struct usb_request *_req) | ||
672 | { | ||
673 | struct pxa27x_request *req; | ||
674 | |||
675 | req = container_of(_req, struct pxa27x_request, req); | ||
676 | WARN_ON(!list_empty(&req->queue)); | ||
677 | kfree(req); | ||
678 | } | ||
679 | |||
680 | /** | ||
681 | * ep_add_request - add a request to the endpoint's queue | ||
682 | * @ep: usb endpoint | ||
683 | * @req: usb request | ||
684 | * | ||
685 | * Context: ep->lock held | ||
686 | * | ||
687 | * Queues the request in the endpoint's queue, and enables the interrupts | ||
688 | * on the endpoint. | ||
689 | */ | ||
690 | static void ep_add_request(struct pxa_ep *ep, struct pxa27x_request *req) | ||
691 | { | ||
692 | if (unlikely(!req)) | ||
693 | return; | ||
694 | ep_vdbg(ep, "req:%p, lg=%d, udccsr=0x%03x\n", req, | ||
695 | req->req.length, udc_ep_readl(ep, UDCCSR)); | ||
696 | |||
697 | req->in_use = 1; | ||
698 | list_add_tail(&req->queue, &ep->queue); | ||
699 | pio_irq_enable(ep); | ||
700 | } | ||
701 | |||
702 | /** | ||
703 | * ep_del_request - removes a request from the endpoint's queue | ||
704 | * @ep: usb endpoint | ||
705 | * @req: usb request | ||
706 | * | ||
707 | * Context: ep->lock held | ||
708 | * | ||
709 | * Unqueue the request from the endpoint's queue. If there are no more requests | ||
710 | * on the endpoint, and if it's not the control endpoint, interrupts are | ||
711 | * disabled on the endpoint. | ||
712 | */ | ||
713 | static void ep_del_request(struct pxa_ep *ep, struct pxa27x_request *req) | ||
714 | { | ||
715 | if (unlikely(!req)) | ||
716 | return; | ||
717 | ep_vdbg(ep, "req:%p, lg=%d, udccsr=0x%03x\n", req, | ||
718 | req->req.length, udc_ep_readl(ep, UDCCSR)); | ||
719 | |||
720 | list_del_init(&req->queue); | ||
721 | req->in_use = 0; | ||
722 | if (!is_ep0(ep) && list_empty(&ep->queue)) | ||
723 | pio_irq_disable(ep); | ||
724 | } | ||
725 | |||
726 | /** | ||
727 | * req_done - Complete an usb request | ||
728 | * @ep: pxa physical endpoint | ||
729 | * @req: pxa request | ||
730 | * @status: usb request status sent to gadget API | ||
731 | * | ||
732 | * Context: ep->lock held | ||
733 | * | ||
734 | * Retire a pxa27x usb request. Endpoint must be locked. | ||
735 | */ | ||
736 | static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status) | ||
737 | { | ||
738 | ep_del_request(ep, req); | ||
739 | if (likely(req->req.status == -EINPROGRESS)) | ||
740 | req->req.status = status; | ||
741 | else | ||
742 | status = req->req.status; | ||
743 | |||
744 | if (status && status != -ESHUTDOWN) | ||
745 | ep_dbg(ep, "complete req %p stat %d len %u/%u\n", | ||
746 | &req->req, status, | ||
747 | req->req.actual, req->req.length); | ||
748 | |||
749 | req->req.complete(&req->udc_usb_ep->usb_ep, &req->req); | ||
750 | } | ||
751 | |||
752 | /** | ||
753 | * ep_end_out_req - Ends control endpoint in request | ||
754 | * @ep: physical endpoint | ||
755 | * @req: pxa request | ||
756 | * | ||
757 | * Context: ep->lock held | ||
758 | * | ||
759 | * Ends endpoint in request (completes usb request). | ||
760 | */ | ||
761 | static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) | ||
762 | { | ||
763 | inc_ep_stats_reqs(ep, !USB_DIR_IN); | ||
764 | req_done(ep, req, 0); | ||
765 | } | ||
766 | |||
767 | /** | ||
768 | * ep0_end_out_req - Ends control endpoint in request (ends data stage) | ||
769 | * @ep: physical endpoint | ||
770 | * @req: pxa request | ||
771 | * | ||
772 | * Context: ep->lock held | ||
773 | * | ||
774 | * Ends control endpoint in request (completes usb request), and puts | ||
775 | * control endpoint into idle state | ||
776 | */ | ||
777 | static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) | ||
778 | { | ||
779 | set_ep0state(ep->dev, OUT_STATUS_STAGE); | ||
780 | ep_end_out_req(ep, req); | ||
781 | ep0_idle(ep->dev); | ||
782 | } | ||
783 | |||
784 | /** | ||
785 | * ep_end_in_req - Ends endpoint out request | ||
786 | * @ep: physical endpoint | ||
787 | * @req: pxa request | ||
788 | * | ||
789 | * Context: ep->lock held | ||
790 | * | ||
791 | * Ends endpoint out request (completes usb request). | ||
792 | */ | ||
793 | static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) | ||
794 | { | ||
795 | inc_ep_stats_reqs(ep, USB_DIR_IN); | ||
796 | req_done(ep, req, 0); | ||
797 | } | ||
798 | |||
799 | /** | ||
800 | * ep0_end_in_req - Ends control endpoint out request (ends data stage) | ||
801 | * @ep: physical endpoint | ||
802 | * @req: pxa request | ||
803 | * | ||
804 | * Context: ep->lock held | ||
805 | * | ||
806 | * Ends control endpoint out request (completes usb request), and puts | ||
807 | * control endpoint into status state | ||
808 | */ | ||
809 | static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) | ||
810 | { | ||
811 | struct pxa_udc *udc = ep->dev; | ||
812 | |||
813 | set_ep0state(udc, IN_STATUS_STAGE); | ||
814 | ep_end_in_req(ep, req); | ||
815 | } | ||
816 | |||
817 | /** | ||
818 | * nuke - Dequeue all requests | ||
819 | * @ep: pxa endpoint | ||
820 | * @status: usb request status | ||
821 | * | ||
822 | * Context: ep->lock held | ||
823 | * | ||
824 | * Dequeues all requests on an endpoint. As a side effect, interrupts will be | ||
825 | * disabled on that endpoint (because no more requests). | ||
826 | */ | ||
827 | static void nuke(struct pxa_ep *ep, int status) | ||
828 | { | ||
829 | struct pxa27x_request *req; | ||
830 | |||
831 | while (!list_empty(&ep->queue)) { | ||
832 | req = list_entry(ep->queue.next, struct pxa27x_request, queue); | ||
833 | req_done(ep, req, status); | ||
834 | } | ||
835 | } | ||
836 | |||
837 | /** | ||
838 | * read_packet - transfer 1 packet from an OUT endpoint into request | ||
839 | * @ep: pxa physical endpoint | ||
840 | * @req: usb request | ||
841 | * | ||
842 | * Takes bytes from OUT endpoint and transfers them info the usb request. | ||
843 | * If there is less space in request than bytes received in OUT endpoint, | ||
844 | * bytes are left in the OUT endpoint. | ||
845 | * | ||
846 | * Returns how many bytes were actually transfered | ||
847 | */ | ||
848 | static int read_packet(struct pxa_ep *ep, struct pxa27x_request *req) | ||
849 | { | ||
850 | u32 *buf; | ||
851 | int bytes_ep, bufferspace, count, i; | ||
852 | |||
853 | bytes_ep = ep_count_bytes_remain(ep); | ||
854 | bufferspace = req->req.length - req->req.actual; | ||
855 | |||
856 | buf = (u32 *)(req->req.buf + req->req.actual); | ||
857 | prefetchw(buf); | ||
858 | |||
859 | if (likely(!ep_is_empty(ep))) | ||
860 | count = min(bytes_ep, bufferspace); | ||
861 | else /* zlp */ | ||
862 | count = 0; | ||
863 | |||
864 | for (i = count; i > 0; i -= 4) | ||
865 | *buf++ = udc_ep_readl(ep, UDCDR); | ||
866 | req->req.actual += count; | ||
867 | |||
868 | udc_ep_writel(ep, UDCCSR, UDCCSR_PC); | ||
869 | |||
870 | return count; | ||
871 | } | ||
872 | |||
873 | /** | ||
874 | * write_packet - transfer 1 packet from request into an IN endpoint | ||
875 | * @ep: pxa physical endpoint | ||
876 | * @req: usb request | ||
877 | * @max: max bytes that fit into endpoint | ||
878 | * | ||
879 | * Takes bytes from usb request, and transfers them into the physical | ||
880 | * endpoint. If there are no bytes to transfer, doesn't write anything | ||
881 | * to physical endpoint. | ||
882 | * | ||
883 | * Returns how many bytes were actually transfered. | ||
884 | */ | ||
885 | static int write_packet(struct pxa_ep *ep, struct pxa27x_request *req, | ||
886 | unsigned int max) | ||
887 | { | ||
888 | int length, count, remain, i; | ||
889 | u32 *buf; | ||
890 | u8 *buf_8; | ||
891 | |||
892 | buf = (u32 *)(req->req.buf + req->req.actual); | ||
893 | prefetch(buf); | ||
894 | |||
895 | length = min(req->req.length - req->req.actual, max); | ||
896 | req->req.actual += length; | ||
897 | |||
898 | remain = length & 0x3; | ||
899 | count = length & ~(0x3); | ||
900 | for (i = count; i > 0 ; i -= 4) | ||
901 | udc_ep_writel(ep, UDCDR, *buf++); | ||
902 | |||
903 | buf_8 = (u8 *)buf; | ||
904 | for (i = remain; i > 0; i--) | ||
905 | udc_ep_writeb(ep, UDCDR, *buf_8++); | ||
906 | |||
907 | ep_vdbg(ep, "length=%d+%d, udccsr=0x%03x\n", count, remain, | ||
908 | udc_ep_readl(ep, UDCCSR)); | ||
909 | |||
910 | return length; | ||
911 | } | ||
912 | |||
913 | /** | ||
914 | * read_fifo - Transfer packets from OUT endpoint into usb request | ||
915 | * @ep: pxa physical endpoint | ||
916 | * @req: usb request | ||
917 | * | ||
918 | * Context: callable when in_interrupt() | ||
919 | * | ||
920 | * Unload as many packets as possible from the fifo we use for usb OUT | ||
921 | * transfers and put them into the request. Caller should have made sure | ||
922 | * there's at least one packet ready. | ||
923 | * Doesn't complete the request, that's the caller's job | ||
924 | * | ||
925 | * Returns 1 if the request completed, 0 otherwise | ||
926 | */ | ||
927 | static int read_fifo(struct pxa_ep *ep, struct pxa27x_request *req) | ||
928 | { | ||
929 | int count, is_short, completed = 0; | ||
930 | |||
931 | while (epout_has_pkt(ep)) { | ||
932 | count = read_packet(ep, req); | ||
933 | inc_ep_stats_bytes(ep, count, !USB_DIR_IN); | ||
934 | |||
935 | is_short = (count < ep->fifo_size); | ||
936 | ep_dbg(ep, "read udccsr:%03x, count:%d bytes%s req %p %d/%d\n", | ||
937 | udc_ep_readl(ep, UDCCSR), count, is_short ? "/S" : "", | ||
938 | &req->req, req->req.actual, req->req.length); | ||
939 | |||
940 | /* completion */ | ||
941 | if (is_short || req->req.actual == req->req.length) { | ||
942 | completed = 1; | ||
943 | break; | ||
944 | } | ||
945 | /* finished that packet. the next one may be waiting... */ | ||
946 | } | ||
947 | return completed; | ||
948 | } | ||
949 | |||
950 | /** | ||
951 | * write_fifo - transfer packets from usb request into an IN endpoint | ||
952 | * @ep: pxa physical endpoint | ||
953 | * @req: pxa usb request | ||
954 | * | ||
955 | * Write to an IN endpoint fifo, as many packets as possible. | ||
956 | * irqs will use this to write the rest later. | ||
957 | * caller guarantees at least one packet buffer is ready (or a zlp). | ||
958 | * Doesn't complete the request, that's the caller's job | ||
959 | * | ||
960 | * Returns 1 if request fully transfered, 0 if partial transfer | ||
961 | */ | ||
962 | static int write_fifo(struct pxa_ep *ep, struct pxa27x_request *req) | ||
963 | { | ||
964 | unsigned max; | ||
965 | int count, is_short, is_last = 0, completed = 0, totcount = 0; | ||
966 | u32 udccsr; | ||
967 | |||
968 | max = ep->fifo_size; | ||
969 | do { | ||
970 | is_short = 0; | ||
971 | |||
972 | udccsr = udc_ep_readl(ep, UDCCSR); | ||
973 | if (udccsr & UDCCSR_PC) { | ||
974 | ep_vdbg(ep, "Clearing Transmit Complete, udccsr=%x\n", | ||
975 | udccsr); | ||
976 | udc_ep_writel(ep, UDCCSR, UDCCSR_PC); | ||
977 | } | ||
978 | if (udccsr & UDCCSR_TRN) { | ||
979 | ep_vdbg(ep, "Clearing Underrun on, udccsr=%x\n", | ||
980 | udccsr); | ||
981 | udc_ep_writel(ep, UDCCSR, UDCCSR_TRN); | ||
982 | } | ||
983 | |||
984 | count = write_packet(ep, req, max); | ||
985 | inc_ep_stats_bytes(ep, count, USB_DIR_IN); | ||
986 | totcount += count; | ||
987 | |||
988 | /* last packet is usually short (or a zlp) */ | ||
989 | if (unlikely(count < max)) { | ||
990 | is_last = 1; | ||
991 | is_short = 1; | ||
992 | } else { | ||
993 | if (likely(req->req.length > req->req.actual) | ||
994 | || req->req.zero) | ||
995 | is_last = 0; | ||
996 | else | ||
997 | is_last = 1; | ||
998 | /* interrupt/iso maxpacket may not fill the fifo */ | ||
999 | is_short = unlikely(max < ep->fifo_size); | ||
1000 | } | ||
1001 | |||
1002 | if (is_short) | ||
1003 | udc_ep_writel(ep, UDCCSR, UDCCSR_SP); | ||
1004 | |||
1005 | /* requests complete when all IN data is in the FIFO */ | ||
1006 | if (is_last) { | ||
1007 | completed = 1; | ||
1008 | break; | ||
1009 | } | ||
1010 | } while (!ep_is_full(ep)); | ||
1011 | |||
1012 | ep_dbg(ep, "wrote count:%d bytes%s%s, left:%d req=%p\n", | ||
1013 | totcount, is_last ? "/L" : "", is_short ? "/S" : "", | ||
1014 | req->req.length - req->req.actual, &req->req); | ||
1015 | |||
1016 | return completed; | ||
1017 | } | ||
1018 | |||
1019 | /** | ||
1020 | * read_ep0_fifo - Transfer packets from control endpoint into usb request | ||
1021 | * @ep: control endpoint | ||
1022 | * @req: pxa usb request | ||
1023 | * | ||
1024 | * Special ep0 version of the above read_fifo. Reads as many bytes from control | ||
1025 | * endpoint as can be read, and stores them into usb request (limited by request | ||
1026 | * maximum length). | ||
1027 | * | ||
1028 | * Returns 0 if usb request only partially filled, 1 if fully filled | ||
1029 | */ | ||
1030 | static int read_ep0_fifo(struct pxa_ep *ep, struct pxa27x_request *req) | ||
1031 | { | ||
1032 | int count, is_short, completed = 0; | ||
1033 | |||
1034 | while (epout_has_pkt(ep)) { | ||
1035 | count = read_packet(ep, req); | ||
1036 | udc_ep_writel(ep, UDCCSR, UDCCSR0_OPC); | ||
1037 | inc_ep_stats_bytes(ep, count, !USB_DIR_IN); | ||
1038 | |||
1039 | is_short = (count < ep->fifo_size); | ||
1040 | ep_dbg(ep, "read udccsr:%03x, count:%d bytes%s req %p %d/%d\n", | ||
1041 | udc_ep_readl(ep, UDCCSR), count, is_short ? "/S" : "", | ||
1042 | &req->req, req->req.actual, req->req.length); | ||
1043 | |||
1044 | if (is_short || req->req.actual >= req->req.length) { | ||
1045 | completed = 1; | ||
1046 | break; | ||
1047 | } | ||
1048 | } | ||
1049 | |||
1050 | return completed; | ||
1051 | } | ||
1052 | |||
1053 | /** | ||
1054 | * write_ep0_fifo - Send a request to control endpoint (ep0 in) | ||
1055 | * @ep: control endpoint | ||
1056 | * @req: request | ||
1057 | * | ||
1058 | * Context: callable when in_interrupt() | ||
1059 | * | ||
1060 | * Sends a request (or a part of the request) to the control endpoint (ep0 in). | ||
1061 | * If the request doesn't fit, the remaining part will be sent from irq. | ||
1062 | * The request is considered fully written only if either : | ||
1063 | * - last write transfered all remaining bytes, but fifo was not fully filled | ||
1064 | * - last write was a 0 length write | ||
1065 | * | ||
1066 | * Returns 1 if request fully written, 0 if request only partially sent | ||
1067 | */ | ||
1068 | static int write_ep0_fifo(struct pxa_ep *ep, struct pxa27x_request *req) | ||
1069 | { | ||
1070 | unsigned count; | ||
1071 | int is_last, is_short; | ||
1072 | |||
1073 | count = write_packet(ep, req, EP0_FIFO_SIZE); | ||
1074 | inc_ep_stats_bytes(ep, count, USB_DIR_IN); | ||
1075 | |||
1076 | is_short = (count < EP0_FIFO_SIZE); | ||
1077 | is_last = ((count == 0) || (count < EP0_FIFO_SIZE)); | ||
1078 | |||
1079 | /* Sends either a short packet or a 0 length packet */ | ||
1080 | if (unlikely(is_short)) | ||
1081 | udc_ep_writel(ep, UDCCSR, UDCCSR0_IPR); | ||
1082 | |||
1083 | ep_dbg(ep, "in %d bytes%s%s, %d left, req=%p, udccsr0=0x%03x\n", | ||
1084 | count, is_short ? "/S" : "", is_last ? "/L" : "", | ||
1085 | req->req.length - req->req.actual, | ||
1086 | &req->req, udc_ep_readl(ep, UDCCSR)); | ||
1087 | |||
1088 | return is_last; | ||
1089 | } | ||
1090 | |||
1091 | /** | ||
1092 | * pxa_ep_queue - Queue a request into an IN endpoint | ||
1093 | * @_ep: usb endpoint | ||
1094 | * @_req: usb request | ||
1095 | * @gfp_flags: flags | ||
1096 | * | ||
1097 | * Context: normally called when !in_interrupt, but callable when in_interrupt() | ||
1098 | * in the special case of ep0 setup : | ||
1099 | * (irq->handle_ep0_ctrl_req->gadget_setup->pxa_ep_queue) | ||
1100 | * | ||
1101 | * Returns 0 if succedeed, error otherwise | ||
1102 | */ | ||
1103 | static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | ||
1104 | gfp_t gfp_flags) | ||
1105 | { | ||
1106 | struct udc_usb_ep *udc_usb_ep; | ||
1107 | struct pxa_ep *ep; | ||
1108 | struct pxa27x_request *req; | ||
1109 | struct pxa_udc *dev; | ||
1110 | unsigned long flags; | ||
1111 | int rc = 0; | ||
1112 | int is_first_req; | ||
1113 | unsigned length; | ||
1114 | |||
1115 | req = container_of(_req, struct pxa27x_request, req); | ||
1116 | udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); | ||
1117 | |||
1118 | if (unlikely(!_req || !_req->complete || !_req->buf)) | ||
1119 | return -EINVAL; | ||
1120 | |||
1121 | if (unlikely(!_ep)) | ||
1122 | return -EINVAL; | ||
1123 | |||
1124 | dev = udc_usb_ep->dev; | ||
1125 | ep = udc_usb_ep->pxa_ep; | ||
1126 | if (unlikely(!ep)) | ||
1127 | return -EINVAL; | ||
1128 | |||
1129 | dev = ep->dev; | ||
1130 | if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) { | ||
1131 | ep_dbg(ep, "bogus device state\n"); | ||
1132 | return -ESHUTDOWN; | ||
1133 | } | ||
1134 | |||
1135 | /* iso is always one packet per request, that's the only way | ||
1136 | * we can report per-packet status. that also helps with dma. | ||
1137 | */ | ||
1138 | if (unlikely(EPXFERTYPE_is_ISO(ep) | ||
1139 | && req->req.length > ep->fifo_size)) | ||
1140 | return -EMSGSIZE; | ||
1141 | |||
1142 | spin_lock_irqsave(&ep->lock, flags); | ||
1143 | |||
1144 | is_first_req = list_empty(&ep->queue); | ||
1145 | ep_dbg(ep, "queue req %p(first=%s), len %d buf %p\n", | ||
1146 | _req, is_first_req ? "yes" : "no", | ||
1147 | _req->length, _req->buf); | ||
1148 | |||
1149 | if (!ep->enabled) { | ||
1150 | _req->status = -ESHUTDOWN; | ||
1151 | rc = -ESHUTDOWN; | ||
1152 | goto out; | ||
1153 | } | ||
1154 | |||
1155 | if (req->in_use) { | ||
1156 | ep_err(ep, "refusing to queue req %p (already queued)\n", req); | ||
1157 | goto out; | ||
1158 | } | ||
1159 | |||
1160 | length = _req->length; | ||
1161 | _req->status = -EINPROGRESS; | ||
1162 | _req->actual = 0; | ||
1163 | |||
1164 | ep_add_request(ep, req); | ||
1165 | |||
1166 | if (is_ep0(ep)) { | ||
1167 | switch (dev->ep0state) { | ||
1168 | case WAIT_ACK_SET_CONF_INTERF: | ||
1169 | if (length == 0) { | ||
1170 | ep_end_in_req(ep, req); | ||
1171 | } else { | ||
1172 | ep_err(ep, "got a request of %d bytes while" | ||
1173 | "in state WATI_ACK_SET_CONF_INTERF\n", | ||
1174 | length); | ||
1175 | ep_del_request(ep, req); | ||
1176 | rc = -EL2HLT; | ||
1177 | } | ||
1178 | ep0_idle(ep->dev); | ||
1179 | break; | ||
1180 | case IN_DATA_STAGE: | ||
1181 | if (!ep_is_full(ep)) | ||
1182 | if (write_ep0_fifo(ep, req)) | ||
1183 | ep0_end_in_req(ep, req); | ||
1184 | break; | ||
1185 | case OUT_DATA_STAGE: | ||
1186 | if ((length == 0) || !epout_has_pkt(ep)) | ||
1187 | if (read_ep0_fifo(ep, req)) | ||
1188 | ep0_end_out_req(ep, req); | ||
1189 | break; | ||
1190 | default: | ||
1191 | ep_err(ep, "odd state %s to send me a request\n", | ||
1192 | EP0_STNAME(ep->dev)); | ||
1193 | ep_del_request(ep, req); | ||
1194 | rc = -EL2HLT; | ||
1195 | break; | ||
1196 | } | ||
1197 | } else { | ||
1198 | handle_ep(ep); | ||
1199 | } | ||
1200 | |||
1201 | out: | ||
1202 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1203 | return rc; | ||
1204 | } | ||
1205 | |||
1206 | /** | ||
1207 | * pxa_ep_dequeue - Dequeue one request | ||
1208 | * @_ep: usb endpoint | ||
1209 | * @_req: usb request | ||
1210 | * | ||
1211 | * Return 0 if no error, -EINVAL or -ECONNRESET otherwise | ||
1212 | */ | ||
1213 | static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | ||
1214 | { | ||
1215 | struct pxa_ep *ep; | ||
1216 | struct udc_usb_ep *udc_usb_ep; | ||
1217 | struct pxa27x_request *req; | ||
1218 | unsigned long flags; | ||
1219 | int rc; | ||
1220 | |||
1221 | if (!_ep) | ||
1222 | return -EINVAL; | ||
1223 | udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); | ||
1224 | ep = udc_usb_ep->pxa_ep; | ||
1225 | if (!ep || is_ep0(ep)) | ||
1226 | return -EINVAL; | ||
1227 | |||
1228 | spin_lock_irqsave(&ep->lock, flags); | ||
1229 | |||
1230 | /* make sure it's actually queued on this endpoint */ | ||
1231 | list_for_each_entry(req, &ep->queue, queue) { | ||
1232 | if (&req->req == _req) | ||
1233 | break; | ||
1234 | } | ||
1235 | |||
1236 | rc = -EINVAL; | ||
1237 | if (&req->req != _req) | ||
1238 | goto out; | ||
1239 | |||
1240 | rc = 0; | ||
1241 | req_done(ep, req, -ECONNRESET); | ||
1242 | out: | ||
1243 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1244 | return rc; | ||
1245 | } | ||
1246 | |||
1247 | /** | ||
1248 | * pxa_ep_set_halt - Halts operations on one endpoint | ||
1249 | * @_ep: usb endpoint | ||
1250 | * @value: | ||
1251 | * | ||
1252 | * Returns 0 if no error, -EINVAL, -EROFS, -EAGAIN otherwise | ||
1253 | */ | ||
1254 | static int pxa_ep_set_halt(struct usb_ep *_ep, int value) | ||
1255 | { | ||
1256 | struct pxa_ep *ep; | ||
1257 | struct udc_usb_ep *udc_usb_ep; | ||
1258 | unsigned long flags; | ||
1259 | int rc; | ||
1260 | |||
1261 | |||
1262 | if (!_ep) | ||
1263 | return -EINVAL; | ||
1264 | udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); | ||
1265 | ep = udc_usb_ep->pxa_ep; | ||
1266 | if (!ep || is_ep0(ep)) | ||
1267 | return -EINVAL; | ||
1268 | |||
1269 | if (value == 0) { | ||
1270 | /* | ||
1271 | * This path (reset toggle+halt) is needed to implement | ||
1272 | * SET_INTERFACE on normal hardware. but it can't be | ||
1273 | * done from software on the PXA UDC, and the hardware | ||
1274 | * forgets to do it as part of SET_INTERFACE automagic. | ||
1275 | */ | ||
1276 | ep_dbg(ep, "only host can clear halt\n"); | ||
1277 | return -EROFS; | ||
1278 | } | ||
1279 | |||
1280 | spin_lock_irqsave(&ep->lock, flags); | ||
1281 | |||
1282 | rc = -EAGAIN; | ||
1283 | if (ep->dir_in && (ep_is_full(ep) || !list_empty(&ep->queue))) | ||
1284 | goto out; | ||
1285 | |||
1286 | /* FST, FEF bits are the same for control and non control endpoints */ | ||
1287 | rc = 0; | ||
1288 | udc_ep_writel(ep, UDCCSR, UDCCSR_FST | UDCCSR_FEF); | ||
1289 | if (is_ep0(ep)) | ||
1290 | set_ep0state(ep->dev, STALL); | ||
1291 | |||
1292 | out: | ||
1293 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1294 | return rc; | ||
1295 | } | ||
1296 | |||
1297 | /** | ||
1298 | * pxa_ep_fifo_status - Get how many bytes in physical endpoint | ||
1299 | * @_ep: usb endpoint | ||
1300 | * | ||
1301 | * Returns number of bytes in OUT fifos. Broken for IN fifos. | ||
1302 | */ | ||
1303 | static int pxa_ep_fifo_status(struct usb_ep *_ep) | ||
1304 | { | ||
1305 | struct pxa_ep *ep; | ||
1306 | struct udc_usb_ep *udc_usb_ep; | ||
1307 | |||
1308 | if (!_ep) | ||
1309 | return -ENODEV; | ||
1310 | udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); | ||
1311 | ep = udc_usb_ep->pxa_ep; | ||
1312 | if (!ep || is_ep0(ep)) | ||
1313 | return -ENODEV; | ||
1314 | |||
1315 | if (ep->dir_in) | ||
1316 | return -EOPNOTSUPP; | ||
1317 | if (ep->dev->gadget.speed == USB_SPEED_UNKNOWN || ep_is_empty(ep)) | ||
1318 | return 0; | ||
1319 | else | ||
1320 | return ep_count_bytes_remain(ep) + 1; | ||
1321 | } | ||
1322 | |||
1323 | /** | ||
1324 | * pxa_ep_fifo_flush - Flushes one endpoint | ||
1325 | * @_ep: usb endpoint | ||
1326 | * | ||
1327 | * Discards all data in one endpoint(IN or OUT), except control endpoint. | ||
1328 | */ | ||
1329 | static void pxa_ep_fifo_flush(struct usb_ep *_ep) | ||
1330 | { | ||
1331 | struct pxa_ep *ep; | ||
1332 | struct udc_usb_ep *udc_usb_ep; | ||
1333 | unsigned long flags; | ||
1334 | |||
1335 | if (!_ep) | ||
1336 | return; | ||
1337 | udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); | ||
1338 | ep = udc_usb_ep->pxa_ep; | ||
1339 | if (!ep || is_ep0(ep)) | ||
1340 | return; | ||
1341 | |||
1342 | spin_lock_irqsave(&ep->lock, flags); | ||
1343 | |||
1344 | if (unlikely(!list_empty(&ep->queue))) | ||
1345 | ep_dbg(ep, "called while queue list not empty\n"); | ||
1346 | ep_dbg(ep, "called\n"); | ||
1347 | |||
1348 | /* for OUT, just read and discard the FIFO contents. */ | ||
1349 | if (!ep->dir_in) { | ||
1350 | while (!ep_is_empty(ep)) | ||
1351 | udc_ep_readl(ep, UDCDR); | ||
1352 | } else { | ||
1353 | /* most IN status is the same, but ISO can't stall */ | ||
1354 | udc_ep_writel(ep, UDCCSR, | ||
1355 | UDCCSR_PC | UDCCSR_FEF | UDCCSR_TRN | ||
1356 | | (EPXFERTYPE_is_ISO(ep) ? 0 : UDCCSR_SST)); | ||
1357 | } | ||
1358 | |||
1359 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1360 | |||
1361 | return; | ||
1362 | } | ||
1363 | |||
1364 | /** | ||
1365 | * pxa_ep_enable - Enables usb endpoint | ||
1366 | * @_ep: usb endpoint | ||
1367 | * @desc: usb endpoint descriptor | ||
1368 | * | ||
1369 | * Nothing much to do here, as ep configuration is done once and for all | ||
1370 | * before udc is enabled. After udc enable, no physical endpoint configuration | ||
1371 | * can be changed. | ||
1372 | * Function makes sanity checks and flushes the endpoint. | ||
1373 | */ | ||
1374 | static int pxa_ep_enable(struct usb_ep *_ep, | ||
1375 | const struct usb_endpoint_descriptor *desc) | ||
1376 | { | ||
1377 | struct pxa_ep *ep; | ||
1378 | struct udc_usb_ep *udc_usb_ep; | ||
1379 | struct pxa_udc *udc; | ||
1380 | |||
1381 | if (!_ep || !desc) | ||
1382 | return -EINVAL; | ||
1383 | |||
1384 | udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); | ||
1385 | if (udc_usb_ep->pxa_ep) { | ||
1386 | ep = udc_usb_ep->pxa_ep; | ||
1387 | ep_warn(ep, "usb_ep %s already enabled, doing nothing\n", | ||
1388 | _ep->name); | ||
1389 | } else { | ||
1390 | ep = find_pxa_ep(udc_usb_ep->dev, udc_usb_ep); | ||
1391 | } | ||
1392 | |||
1393 | if (!ep || is_ep0(ep)) { | ||
1394 | dev_err(udc_usb_ep->dev->dev, | ||
1395 | "unable to match pxa_ep for ep %s\n", | ||
1396 | _ep->name); | ||
1397 | return -EINVAL; | ||
1398 | } | ||
1399 | |||
1400 | if ((desc->bDescriptorType != USB_DT_ENDPOINT) | ||
1401 | || (ep->type != usb_endpoint_type(desc))) { | ||
1402 | ep_err(ep, "type mismatch\n"); | ||
1403 | return -EINVAL; | ||
1404 | } | ||
1405 | |||
1406 | if (ep->fifo_size < le16_to_cpu(desc->wMaxPacketSize)) { | ||
1407 | ep_err(ep, "bad maxpacket\n"); | ||
1408 | return -ERANGE; | ||
1409 | } | ||
1410 | |||
1411 | udc_usb_ep->pxa_ep = ep; | ||
1412 | udc = ep->dev; | ||
1413 | |||
1414 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { | ||
1415 | ep_err(ep, "bogus device state\n"); | ||
1416 | return -ESHUTDOWN; | ||
1417 | } | ||
1418 | |||
1419 | ep->enabled = 1; | ||
1420 | |||
1421 | /* flush fifo (mostly for OUT buffers) */ | ||
1422 | pxa_ep_fifo_flush(_ep); | ||
1423 | |||
1424 | ep_dbg(ep, "enabled\n"); | ||
1425 | return 0; | ||
1426 | } | ||
1427 | |||
1428 | /** | ||
1429 | * pxa_ep_disable - Disable usb endpoint | ||
1430 | * @_ep: usb endpoint | ||
1431 | * | ||
1432 | * Same as for pxa_ep_enable, no physical endpoint configuration can be | ||
1433 | * changed. | ||
1434 | * Function flushes the endpoint and related requests. | ||
1435 | */ | ||
1436 | static int pxa_ep_disable(struct usb_ep *_ep) | ||
1437 | { | ||
1438 | struct pxa_ep *ep; | ||
1439 | struct udc_usb_ep *udc_usb_ep; | ||
1440 | unsigned long flags; | ||
1441 | |||
1442 | if (!_ep) | ||
1443 | return -EINVAL; | ||
1444 | |||
1445 | udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); | ||
1446 | ep = udc_usb_ep->pxa_ep; | ||
1447 | if (!ep || is_ep0(ep) || !list_empty(&ep->queue)) | ||
1448 | return -EINVAL; | ||
1449 | |||
1450 | spin_lock_irqsave(&ep->lock, flags); | ||
1451 | ep->enabled = 0; | ||
1452 | nuke(ep, -ESHUTDOWN); | ||
1453 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1454 | |||
1455 | pxa_ep_fifo_flush(_ep); | ||
1456 | udc_usb_ep->pxa_ep = NULL; | ||
1457 | |||
1458 | ep_dbg(ep, "disabled\n"); | ||
1459 | return 0; | ||
1460 | } | ||
1461 | |||
1462 | static struct usb_ep_ops pxa_ep_ops = { | ||
1463 | .enable = pxa_ep_enable, | ||
1464 | .disable = pxa_ep_disable, | ||
1465 | |||
1466 | .alloc_request = pxa_ep_alloc_request, | ||
1467 | .free_request = pxa_ep_free_request, | ||
1468 | |||
1469 | .queue = pxa_ep_queue, | ||
1470 | .dequeue = pxa_ep_dequeue, | ||
1471 | |||
1472 | .set_halt = pxa_ep_set_halt, | ||
1473 | .fifo_status = pxa_ep_fifo_status, | ||
1474 | .fifo_flush = pxa_ep_fifo_flush, | ||
1475 | }; | ||
1476 | |||
1477 | |||
1478 | /** | ||
1479 | * pxa_udc_get_frame - Returns usb frame number | ||
1480 | * @_gadget: usb gadget | ||
1481 | */ | ||
1482 | static int pxa_udc_get_frame(struct usb_gadget *_gadget) | ||
1483 | { | ||
1484 | struct pxa_udc *udc = to_gadget_udc(_gadget); | ||
1485 | |||
1486 | return (udc_readl(udc, UDCFNR) & 0x7ff); | ||
1487 | } | ||
1488 | |||
1489 | /** | ||
1490 | * pxa_udc_wakeup - Force udc device out of suspend | ||
1491 | * @_gadget: usb gadget | ||
1492 | * | ||
1493 | * Returns 0 if succesfull, error code otherwise | ||
1494 | */ | ||
1495 | static int pxa_udc_wakeup(struct usb_gadget *_gadget) | ||
1496 | { | ||
1497 | struct pxa_udc *udc = to_gadget_udc(_gadget); | ||
1498 | |||
1499 | /* host may not have enabled remote wakeup */ | ||
1500 | if ((udc_readl(udc, UDCCR) & UDCCR_DWRE) == 0) | ||
1501 | return -EHOSTUNREACH; | ||
1502 | udc_set_mask_UDCCR(udc, UDCCR_UDR); | ||
1503 | return 0; | ||
1504 | } | ||
1505 | |||
1506 | static const struct usb_gadget_ops pxa_udc_ops = { | ||
1507 | .get_frame = pxa_udc_get_frame, | ||
1508 | .wakeup = pxa_udc_wakeup, | ||
1509 | /* current versions must always be self-powered */ | ||
1510 | }; | ||
1511 | |||
1512 | /** | ||
1513 | * udc_disable - disable udc device controller | ||
1514 | * @udc: udc device | ||
1515 | * | ||
1516 | * Disables the udc device : disables clocks, udc interrupts, control endpoint | ||
1517 | * interrupts. | ||
1518 | */ | ||
1519 | static void udc_disable(struct pxa_udc *udc) | ||
1520 | { | ||
1521 | udc_writel(udc, UDCICR0, 0); | ||
1522 | udc_writel(udc, UDCICR1, 0); | ||
1523 | |||
1524 | udc_clear_mask_UDCCR(udc, UDCCR_UDE); | ||
1525 | clk_disable(udc->clk); | ||
1526 | |||
1527 | ep0_idle(udc); | ||
1528 | udc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1529 | udc->mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); | ||
1530 | } | ||
1531 | |||
1532 | /** | ||
1533 | * udc_init_data - Initialize udc device data structures | ||
1534 | * @dev: udc device | ||
1535 | * | ||
1536 | * Initializes gadget endpoint list, endpoints locks. No action is taken | ||
1537 | * on the hardware. | ||
1538 | */ | ||
1539 | static __init void udc_init_data(struct pxa_udc *dev) | ||
1540 | { | ||
1541 | int i; | ||
1542 | struct pxa_ep *ep; | ||
1543 | |||
1544 | /* device/ep0 records init */ | ||
1545 | INIT_LIST_HEAD(&dev->gadget.ep_list); | ||
1546 | INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); | ||
1547 | dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0]; | ||
1548 | ep0_idle(dev); | ||
1549 | strcpy(dev->dev->bus_id, ""); | ||
1550 | |||
1551 | /* PXA endpoints init */ | ||
1552 | for (i = 0; i < NR_PXA_ENDPOINTS; i++) { | ||
1553 | ep = &dev->pxa_ep[i]; | ||
1554 | |||
1555 | ep->enabled = is_ep0(ep); | ||
1556 | INIT_LIST_HEAD(&ep->queue); | ||
1557 | spin_lock_init(&ep->lock); | ||
1558 | } | ||
1559 | |||
1560 | /* USB endpoints init */ | ||
1561 | for (i = 0; i < NR_USB_ENDPOINTS; i++) | ||
1562 | if (i != 0) | ||
1563 | list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list, | ||
1564 | &dev->gadget.ep_list); | ||
1565 | } | ||
1566 | |||
1567 | /** | ||
1568 | * udc_enable - Enables the udc device | ||
1569 | * @dev: udc device | ||
1570 | * | ||
1571 | * Enables the udc device : enables clocks, udc interrupts, control endpoint | ||
1572 | * interrupts, sets usb as UDC client and setups endpoints. | ||
1573 | */ | ||
1574 | static void udc_enable(struct pxa_udc *udc) | ||
1575 | { | ||
1576 | udc_writel(udc, UDCICR0, 0); | ||
1577 | udc_writel(udc, UDCICR1, 0); | ||
1578 | udc_writel(udc, UP2OCR, UP2OCR_HXOE); | ||
1579 | udc_clear_mask_UDCCR(udc, UDCCR_UDE); | ||
1580 | |||
1581 | clk_enable(udc->clk); | ||
1582 | |||
1583 | ep0_idle(udc); | ||
1584 | udc->gadget.speed = USB_SPEED_FULL; | ||
1585 | memset(&udc->stats, 0, sizeof(udc->stats)); | ||
1586 | |||
1587 | udc_set_mask_UDCCR(udc, UDCCR_UDE); | ||
1588 | udelay(2); | ||
1589 | if (udc_readl(udc, UDCCR) & UDCCR_EMCE) | ||
1590 | dev_err(udc->dev, "Configuration errors, udc disabled\n"); | ||
1591 | |||
1592 | /* | ||
1593 | * Caller must be able to sleep in order to cope with startup transients | ||
1594 | */ | ||
1595 | msleep(100); | ||
1596 | |||
1597 | /* enable suspend/resume and reset irqs */ | ||
1598 | udc_writel(udc, UDCICR1, | ||
1599 | UDCICR1_IECC | UDCICR1_IERU | ||
1600 | | UDCICR1_IESU | UDCICR1_IERS); | ||
1601 | |||
1602 | /* enable ep0 irqs */ | ||
1603 | pio_irq_enable(&udc->pxa_ep[0]); | ||
1604 | |||
1605 | dev_info(udc->dev, "UDC connecting\n"); | ||
1606 | if (udc->mach->udc_command) | ||
1607 | udc->mach->udc_command(PXA2XX_UDC_CMD_CONNECT); | ||
1608 | } | ||
1609 | |||
1610 | /** | ||
1611 | * usb_gadget_register_driver - Register gadget driver | ||
1612 | * @driver: gadget driver | ||
1613 | * | ||
1614 | * When a driver is successfully registered, it will receive control requests | ||
1615 | * including set_configuration(), which enables non-control requests. Then | ||
1616 | * usb traffic follows until a disconnect is reported. Then a host may connect | ||
1617 | * again, or the driver might get unbound. | ||
1618 | * | ||
1619 | * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise | ||
1620 | */ | ||
1621 | int usb_gadget_register_driver(struct usb_gadget_driver *driver) | ||
1622 | { | ||
1623 | struct pxa_udc *udc = the_controller; | ||
1624 | int retval; | ||
1625 | |||
1626 | if (!driver || driver->speed != USB_SPEED_FULL || !driver->bind | ||
1627 | || !driver->disconnect || !driver->setup) | ||
1628 | return -EINVAL; | ||
1629 | if (!udc) | ||
1630 | return -ENODEV; | ||
1631 | if (udc->driver) | ||
1632 | return -EBUSY; | ||
1633 | |||
1634 | /* first hook up the driver ... */ | ||
1635 | udc->driver = driver; | ||
1636 | udc->gadget.dev.driver = &driver->driver; | ||
1637 | |||
1638 | retval = device_add(&udc->gadget.dev); | ||
1639 | if (retval) { | ||
1640 | dev_err(udc->dev, "device_add error %d\n", retval); | ||
1641 | goto add_fail; | ||
1642 | } | ||
1643 | retval = driver->bind(&udc->gadget); | ||
1644 | if (retval) { | ||
1645 | dev_err(udc->dev, "bind to driver %s --> error %d\n", | ||
1646 | driver->driver.name, retval); | ||
1647 | goto bind_fail; | ||
1648 | } | ||
1649 | dev_dbg(udc->dev, "registered gadget driver '%s'\n", | ||
1650 | driver->driver.name); | ||
1651 | |||
1652 | udc_enable(udc); | ||
1653 | return 0; | ||
1654 | |||
1655 | bind_fail: | ||
1656 | device_del(&udc->gadget.dev); | ||
1657 | add_fail: | ||
1658 | udc->driver = NULL; | ||
1659 | udc->gadget.dev.driver = NULL; | ||
1660 | return retval; | ||
1661 | } | ||
1662 | EXPORT_SYMBOL(usb_gadget_register_driver); | ||
1663 | |||
1664 | |||
1665 | /** | ||
1666 | * stop_activity - Stops udc endpoints | ||
1667 | * @udc: udc device | ||
1668 | * @driver: gadget driver | ||
1669 | * | ||
1670 | * Disables all udc endpoints (even control endpoint), report disconnect to | ||
1671 | * the gadget user. | ||
1672 | */ | ||
1673 | static void stop_activity(struct pxa_udc *udc, struct usb_gadget_driver *driver) | ||
1674 | { | ||
1675 | int i; | ||
1676 | |||
1677 | /* don't disconnect drivers more than once */ | ||
1678 | if (udc->gadget.speed == USB_SPEED_UNKNOWN) | ||
1679 | driver = NULL; | ||
1680 | udc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1681 | |||
1682 | for (i = 0; i < NR_USB_ENDPOINTS; i++) | ||
1683 | pxa_ep_disable(&udc->udc_usb_ep[i].usb_ep); | ||
1684 | |||
1685 | if (driver) | ||
1686 | driver->disconnect(&udc->gadget); | ||
1687 | } | ||
1688 | |||
1689 | /** | ||
1690 | * usb_gadget_unregister_driver - Unregister the gadget driver | ||
1691 | * @driver: gadget driver | ||
1692 | * | ||
1693 | * Returns 0 if no error, -ENODEV, -EINVAL otherwise | ||
1694 | */ | ||
1695 | int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | ||
1696 | { | ||
1697 | struct pxa_udc *udc = the_controller; | ||
1698 | |||
1699 | if (!udc) | ||
1700 | return -ENODEV; | ||
1701 | if (!driver || driver != udc->driver || !driver->unbind) | ||
1702 | return -EINVAL; | ||
1703 | |||
1704 | stop_activity(udc, driver); | ||
1705 | udc_disable(udc); | ||
1706 | |||
1707 | driver->unbind(&udc->gadget); | ||
1708 | udc->driver = NULL; | ||
1709 | |||
1710 | device_del(&udc->gadget.dev); | ||
1711 | |||
1712 | dev_info(udc->dev, "unregistered gadget driver '%s'\n", | ||
1713 | driver->driver.name); | ||
1714 | return 0; | ||
1715 | } | ||
1716 | EXPORT_SYMBOL(usb_gadget_unregister_driver); | ||
1717 | |||
1718 | /** | ||
1719 | * handle_ep0_ctrl_req - handle control endpoint control request | ||
1720 | * @udc: udc device | ||
1721 | * @req: control request | ||
1722 | */ | ||
1723 | static void handle_ep0_ctrl_req(struct pxa_udc *udc, | ||
1724 | struct pxa27x_request *req) | ||
1725 | { | ||
1726 | struct pxa_ep *ep = &udc->pxa_ep[0]; | ||
1727 | union { | ||
1728 | struct usb_ctrlrequest r; | ||
1729 | u32 word[2]; | ||
1730 | } u; | ||
1731 | int i; | ||
1732 | int have_extrabytes = 0; | ||
1733 | |||
1734 | nuke(ep, -EPROTO); | ||
1735 | |||
1736 | /* read SETUP packet */ | ||
1737 | for (i = 0; i < 2; i++) { | ||
1738 | if (unlikely(ep_is_empty(ep))) | ||
1739 | goto stall; | ||
1740 | u.word[i] = udc_ep_readl(ep, UDCDR); | ||
1741 | } | ||
1742 | |||
1743 | have_extrabytes = !ep_is_empty(ep); | ||
1744 | while (!ep_is_empty(ep)) { | ||
1745 | i = udc_ep_readl(ep, UDCDR); | ||
1746 | ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i); | ||
1747 | } | ||
1748 | |||
1749 | le16_to_cpus(&u.r.wValue); | ||
1750 | le16_to_cpus(&u.r.wIndex); | ||
1751 | le16_to_cpus(&u.r.wLength); | ||
1752 | |||
1753 | ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n", | ||
1754 | u.r.bRequestType, u.r.bRequest, | ||
1755 | u.r.wValue, u.r.wIndex, u.r.wLength); | ||
1756 | if (unlikely(have_extrabytes)) | ||
1757 | goto stall; | ||
1758 | |||
1759 | if (u.r.bRequestType & USB_DIR_IN) | ||
1760 | set_ep0state(udc, IN_DATA_STAGE); | ||
1761 | else | ||
1762 | set_ep0state(udc, OUT_DATA_STAGE); | ||
1763 | |||
1764 | /* Tell UDC to enter Data Stage */ | ||
1765 | udc_ep_writel(ep, UDCCSR, UDCCSR0_SA | UDCCSR0_OPC); | ||
1766 | |||
1767 | i = udc->driver->setup(&udc->gadget, &u.r); | ||
1768 | if (i < 0) | ||
1769 | goto stall; | ||
1770 | out: | ||
1771 | return; | ||
1772 | stall: | ||
1773 | ep_dbg(ep, "protocol STALL, udccsr0=%03x err %d\n", | ||
1774 | udc_ep_readl(ep, UDCCSR), i); | ||
1775 | udc_ep_writel(ep, UDCCSR, UDCCSR0_FST | UDCCSR0_FTF); | ||
1776 | set_ep0state(udc, STALL); | ||
1777 | goto out; | ||
1778 | } | ||
1779 | |||
1780 | /** | ||
1781 | * handle_ep0 - Handle control endpoint data transfers | ||
1782 | * @udc: udc device | ||
1783 | * @fifo_irq: 1 if triggered by fifo service type irq | ||
1784 | * @opc_irq: 1 if triggered by output packet complete type irq | ||
1785 | * | ||
1786 | * Context : when in_interrupt() or with ep->lock held | ||
1787 | * | ||
1788 | * Tries to transfer all pending request data into the endpoint and/or | ||
1789 | * transfer all pending data in the endpoint into usb requests. | ||
1790 | * Handles states of ep0 automata. | ||
1791 | * | ||
1792 | * PXA27x hardware handles several standard usb control requests without | ||
1793 | * driver notification. The requests fully handled by hardware are : | ||
1794 | * SET_ADDRESS, SET_FEATURE, CLEAR_FEATURE, GET_CONFIGURATION, GET_INTERFACE, | ||
1795 | * GET_STATUS | ||
1796 | * The requests handled by hardware, but with irq notification are : | ||
1797 | * SYNCH_FRAME, SET_CONFIGURATION, SET_INTERFACE | ||
1798 | * The remaining standard requests really handled by handle_ep0 are : | ||
1799 | * GET_DESCRIPTOR, SET_DESCRIPTOR, specific requests. | ||
1800 | * Requests standardized outside of USB 2.0 chapter 9 are handled more | ||
1801 | * uniformly, by gadget drivers. | ||
1802 | * | ||
1803 | * The control endpoint state machine is _not_ USB spec compliant, it's even | ||
1804 | * hardly compliant with Intel PXA270 developers guide. | ||
1805 | * The key points which inferred this state machine are : | ||
1806 | * - on every setup token, bit UDCCSR0_SA is raised and held until cleared by | ||
1807 | * software. | ||
1808 | * - on every OUT packet received, UDCCSR0_OPC is raised and held until | ||
1809 | * cleared by software. | ||
1810 | * - clearing UDCCSR0_OPC always flushes ep0. If in setup stage, never do it | ||
1811 | * before reading ep0. | ||
1812 | * - irq can be called on a "packet complete" event (opc_irq=1), while | ||
1813 | * UDCCSR0_OPC is not yet raised (delta can be as big as 100ms | ||
1814 | * from experimentation). | ||
1815 | * - as UDCCSR0_SA can be activated while in irq handling, and clearing | ||
1816 | * UDCCSR0_OPC would flush the setup data, we almost never clear UDCCSR0_OPC | ||
1817 | * => we never actually read the "status stage" packet of an IN data stage | ||
1818 | * => this is not documented in Intel documentation | ||
1819 | * - hardware as no idea of STATUS STAGE, it only handle SETUP STAGE and DATA | ||
1820 | * STAGE. The driver add STATUS STAGE to send last zero length packet in | ||
1821 | * OUT_STATUS_STAGE. | ||
1822 | * - special attention was needed for IN_STATUS_STAGE. If a packet complete | ||
1823 | * event is detected, we terminate the status stage without ackowledging the | ||
1824 | * packet (not to risk to loose a potential SETUP packet) | ||
1825 | */ | ||
1826 | static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq) | ||
1827 | { | ||
1828 | u32 udccsr0; | ||
1829 | struct pxa_ep *ep = &udc->pxa_ep[0]; | ||
1830 | struct pxa27x_request *req = NULL; | ||
1831 | int completed = 0; | ||
1832 | |||
1833 | udccsr0 = udc_ep_readl(ep, UDCCSR); | ||
1834 | ep_dbg(ep, "state=%s, req=%p, udccsr0=0x%03x, udcbcr=%d, irq_msk=%x\n", | ||
1835 | EP0_STNAME(udc), req, udccsr0, udc_ep_readl(ep, UDCBCR), | ||
1836 | (fifo_irq << 1 | opc_irq)); | ||
1837 | |||
1838 | if (!list_empty(&ep->queue)) | ||
1839 | req = list_entry(ep->queue.next, struct pxa27x_request, queue); | ||
1840 | |||
1841 | if (udccsr0 & UDCCSR0_SST) { | ||
1842 | ep_dbg(ep, "clearing stall status\n"); | ||
1843 | nuke(ep, -EPIPE); | ||
1844 | udc_ep_writel(ep, UDCCSR, UDCCSR0_SST); | ||
1845 | ep0_idle(udc); | ||
1846 | } | ||
1847 | |||
1848 | if (udccsr0 & UDCCSR0_SA) { | ||
1849 | nuke(ep, 0); | ||
1850 | set_ep0state(udc, SETUP_STAGE); | ||
1851 | } | ||
1852 | |||
1853 | switch (udc->ep0state) { | ||
1854 | case WAIT_FOR_SETUP: | ||
1855 | /* | ||
1856 | * Hardware bug : beware, we cannot clear OPC, since we would | ||
1857 | * miss a potential OPC irq for a setup packet. | ||
1858 | * So, we only do ... nothing, and hope for a next irq with | ||
1859 | * UDCCSR0_SA set. | ||
1860 | */ | ||
1861 | break; | ||
1862 | case SETUP_STAGE: | ||
1863 | udccsr0 &= UDCCSR0_CTRL_REQ_MASK; | ||
1864 | if (likely(udccsr0 == UDCCSR0_CTRL_REQ_MASK)) | ||
1865 | handle_ep0_ctrl_req(udc, req); | ||
1866 | break; | ||
1867 | case IN_DATA_STAGE: /* GET_DESCRIPTOR */ | ||
1868 | if (epout_has_pkt(ep)) | ||
1869 | udc_ep_writel(ep, UDCCSR, UDCCSR0_OPC); | ||
1870 | if (req && !ep_is_full(ep)) | ||
1871 | completed = write_ep0_fifo(ep, req); | ||
1872 | if (completed) | ||
1873 | ep0_end_in_req(ep, req); | ||
1874 | break; | ||
1875 | case OUT_DATA_STAGE: /* SET_DESCRIPTOR */ | ||
1876 | if (epout_has_pkt(ep) && req) | ||
1877 | completed = read_ep0_fifo(ep, req); | ||
1878 | if (completed) | ||
1879 | ep0_end_out_req(ep, req); | ||
1880 | break; | ||
1881 | case STALL: | ||
1882 | udc_ep_writel(ep, UDCCSR, UDCCSR0_FST); | ||
1883 | break; | ||
1884 | case IN_STATUS_STAGE: | ||
1885 | /* | ||
1886 | * Hardware bug : beware, we cannot clear OPC, since we would | ||
1887 | * miss a potential PC irq for a setup packet. | ||
1888 | * So, we only put the ep0 into WAIT_FOR_SETUP state. | ||
1889 | */ | ||
1890 | if (opc_irq) | ||
1891 | ep0_idle(udc); | ||
1892 | break; | ||
1893 | case OUT_STATUS_STAGE: | ||
1894 | case WAIT_ACK_SET_CONF_INTERF: | ||
1895 | ep_warn(ep, "should never get in %s state here!!!\n", | ||
1896 | EP0_STNAME(ep->dev)); | ||
1897 | ep0_idle(udc); | ||
1898 | break; | ||
1899 | } | ||
1900 | } | ||
1901 | |||
1902 | /** | ||
1903 | * handle_ep - Handle endpoint data tranfers | ||
1904 | * @ep: pxa physical endpoint | ||
1905 | * | ||
1906 | * Tries to transfer all pending request data into the endpoint and/or | ||
1907 | * transfer all pending data in the endpoint into usb requests. | ||
1908 | * | ||
1909 | * Is always called when in_interrupt() or with ep->lock held. | ||
1910 | */ | ||
1911 | static void handle_ep(struct pxa_ep *ep) | ||
1912 | { | ||
1913 | struct pxa27x_request *req; | ||
1914 | int completed; | ||
1915 | u32 udccsr; | ||
1916 | int is_in = ep->dir_in; | ||
1917 | int loop = 0; | ||
1918 | |||
1919 | do { | ||
1920 | completed = 0; | ||
1921 | udccsr = udc_ep_readl(ep, UDCCSR); | ||
1922 | if (likely(!list_empty(&ep->queue))) | ||
1923 | req = list_entry(ep->queue.next, | ||
1924 | struct pxa27x_request, queue); | ||
1925 | else | ||
1926 | req = NULL; | ||
1927 | |||
1928 | ep_dbg(ep, "req:%p, udccsr 0x%03x loop=%d\n", | ||
1929 | req, udccsr, loop++); | ||
1930 | |||
1931 | if (unlikely(udccsr & (UDCCSR_SST | UDCCSR_TRN))) | ||
1932 | udc_ep_writel(ep, UDCCSR, | ||
1933 | udccsr & (UDCCSR_SST | UDCCSR_TRN)); | ||
1934 | if (!req) | ||
1935 | break; | ||
1936 | |||
1937 | if (unlikely(is_in)) { | ||
1938 | if (likely(!ep_is_full(ep))) | ||
1939 | completed = write_fifo(ep, req); | ||
1940 | if (completed) | ||
1941 | ep_end_in_req(ep, req); | ||
1942 | } else { | ||
1943 | if (likely(epout_has_pkt(ep))) | ||
1944 | completed = read_fifo(ep, req); | ||
1945 | if (completed) | ||
1946 | ep_end_out_req(ep, req); | ||
1947 | } | ||
1948 | } while (completed); | ||
1949 | } | ||
1950 | |||
1951 | /** | ||
1952 | * pxa27x_change_configuration - Handle SET_CONF usb request notification | ||
1953 | * @udc: udc device | ||
1954 | * @config: usb configuration | ||
1955 | * | ||
1956 | * Post the request to upper level. | ||
1957 | * Don't use any pxa specific harware configuration capabilities | ||
1958 | */ | ||
1959 | static void pxa27x_change_configuration(struct pxa_udc *udc, int config) | ||
1960 | { | ||
1961 | struct usb_ctrlrequest req ; | ||
1962 | |||
1963 | dev_dbg(udc->dev, "config=%d\n", config); | ||
1964 | |||
1965 | udc->config = config; | ||
1966 | udc->last_interface = 0; | ||
1967 | udc->last_alternate = 0; | ||
1968 | |||
1969 | req.bRequestType = 0; | ||
1970 | req.bRequest = USB_REQ_SET_CONFIGURATION; | ||
1971 | req.wValue = config; | ||
1972 | req.wIndex = 0; | ||
1973 | req.wLength = 0; | ||
1974 | |||
1975 | set_ep0state(udc, WAIT_ACK_SET_CONF_INTERF); | ||
1976 | udc->driver->setup(&udc->gadget, &req); | ||
1977 | } | ||
1978 | |||
1979 | /** | ||
1980 | * pxa27x_change_interface - Handle SET_INTERF usb request notification | ||
1981 | * @udc: udc device | ||
1982 | * @iface: interface number | ||
1983 | * @alt: alternate setting number | ||
1984 | * | ||
1985 | * Post the request to upper level. | ||
1986 | * Don't use any pxa specific harware configuration capabilities | ||
1987 | */ | ||
1988 | static void pxa27x_change_interface(struct pxa_udc *udc, int iface, int alt) | ||
1989 | { | ||
1990 | struct usb_ctrlrequest req; | ||
1991 | |||
1992 | dev_dbg(udc->dev, "interface=%d, alternate setting=%d\n", iface, alt); | ||
1993 | |||
1994 | udc->last_interface = iface; | ||
1995 | udc->last_alternate = alt; | ||
1996 | |||
1997 | req.bRequestType = USB_RECIP_INTERFACE; | ||
1998 | req.bRequest = USB_REQ_SET_INTERFACE; | ||
1999 | req.wValue = alt; | ||
2000 | req.wIndex = iface; | ||
2001 | req.wLength = 0; | ||
2002 | |||
2003 | set_ep0state(udc, WAIT_ACK_SET_CONF_INTERF); | ||
2004 | udc->driver->setup(&udc->gadget, &req); | ||
2005 | } | ||
2006 | |||
2007 | /* | ||
2008 | * irq_handle_data - Handle data transfer | ||
2009 | * @irq: irq IRQ number | ||
2010 | * @udc: dev pxa_udc device structure | ||
2011 | * | ||
2012 | * Called from irq handler, transferts data to or from endpoint to queue | ||
2013 | */ | ||
2014 | static void irq_handle_data(int irq, struct pxa_udc *udc) | ||
2015 | { | ||
2016 | int i; | ||
2017 | struct pxa_ep *ep; | ||
2018 | u32 udcisr0 = udc_readl(udc, UDCISR0) & UDCCISR0_EP_MASK; | ||
2019 | u32 udcisr1 = udc_readl(udc, UDCISR1) & UDCCISR1_EP_MASK; | ||
2020 | |||
2021 | if (udcisr0 & UDCISR_INT_MASK) { | ||
2022 | udc->pxa_ep[0].stats.irqs++; | ||
2023 | udc_writel(udc, UDCISR0, UDCISR_INT(0, UDCISR_INT_MASK)); | ||
2024 | handle_ep0(udc, !!(udcisr0 & UDCICR_FIFOERR), | ||
2025 | !!(udcisr0 & UDCICR_PKTCOMPL)); | ||
2026 | } | ||
2027 | |||
2028 | udcisr0 >>= 2; | ||
2029 | for (i = 1; udcisr0 != 0 && i < 16; udcisr0 >>= 2, i++) { | ||
2030 | if (!(udcisr0 & UDCISR_INT_MASK)) | ||
2031 | continue; | ||
2032 | |||
2033 | udc_writel(udc, UDCISR0, UDCISR_INT(i, UDCISR_INT_MASK)); | ||
2034 | ep = &udc->pxa_ep[i]; | ||
2035 | ep->stats.irqs++; | ||
2036 | handle_ep(ep); | ||
2037 | } | ||
2038 | |||
2039 | for (i = 16; udcisr1 != 0 && i < 24; udcisr1 >>= 2, i++) { | ||
2040 | udc_writel(udc, UDCISR1, UDCISR_INT(i - 16, UDCISR_INT_MASK)); | ||
2041 | if (!(udcisr1 & UDCISR_INT_MASK)) | ||
2042 | continue; | ||
2043 | |||
2044 | ep = &udc->pxa_ep[i]; | ||
2045 | ep->stats.irqs++; | ||
2046 | handle_ep(ep); | ||
2047 | } | ||
2048 | |||
2049 | } | ||
2050 | |||
2051 | /** | ||
2052 | * irq_udc_suspend - Handle IRQ "UDC Suspend" | ||
2053 | * @udc: udc device | ||
2054 | */ | ||
2055 | static void irq_udc_suspend(struct pxa_udc *udc) | ||
2056 | { | ||
2057 | udc_writel(udc, UDCISR1, UDCISR1_IRSU); | ||
2058 | udc->stats.irqs_suspend++; | ||
2059 | |||
2060 | if (udc->gadget.speed != USB_SPEED_UNKNOWN | ||
2061 | && udc->driver && udc->driver->suspend) | ||
2062 | udc->driver->suspend(&udc->gadget); | ||
2063 | ep0_idle(udc); | ||
2064 | } | ||
2065 | |||
2066 | /** | ||
2067 | * irq_udc_resume - Handle IRQ "UDC Resume" | ||
2068 | * @udc: udc device | ||
2069 | */ | ||
2070 | static void irq_udc_resume(struct pxa_udc *udc) | ||
2071 | { | ||
2072 | udc_writel(udc, UDCISR1, UDCISR1_IRRU); | ||
2073 | udc->stats.irqs_resume++; | ||
2074 | |||
2075 | if (udc->gadget.speed != USB_SPEED_UNKNOWN | ||
2076 | && udc->driver && udc->driver->resume) | ||
2077 | udc->driver->resume(&udc->gadget); | ||
2078 | } | ||
2079 | |||
2080 | /** | ||
2081 | * irq_udc_reconfig - Handle IRQ "UDC Change Configuration" | ||
2082 | * @udc: udc device | ||
2083 | */ | ||
2084 | static void irq_udc_reconfig(struct pxa_udc *udc) | ||
2085 | { | ||
2086 | unsigned config, interface, alternate, config_change; | ||
2087 | u32 udccr = udc_readl(udc, UDCCR); | ||
2088 | |||
2089 | udc_writel(udc, UDCISR1, UDCISR1_IRCC); | ||
2090 | udc->stats.irqs_reconfig++; | ||
2091 | |||
2092 | config = (udccr & UDCCR_ACN) >> UDCCR_ACN_S; | ||
2093 | config_change = (config != udc->config); | ||
2094 | pxa27x_change_configuration(udc, config); | ||
2095 | |||
2096 | interface = (udccr & UDCCR_AIN) >> UDCCR_AIN_S; | ||
2097 | alternate = (udccr & UDCCR_AAISN) >> UDCCR_AAISN_S; | ||
2098 | pxa27x_change_interface(udc, interface, alternate); | ||
2099 | |||
2100 | if (config_change) | ||
2101 | update_pxa_ep_matches(udc); | ||
2102 | udc_set_mask_UDCCR(udc, UDCCR_SMAC); | ||
2103 | } | ||
2104 | |||
2105 | /** | ||
2106 | * irq_udc_reset - Handle IRQ "UDC Reset" | ||
2107 | * @udc: udc device | ||
2108 | */ | ||
2109 | static void irq_udc_reset(struct pxa_udc *udc) | ||
2110 | { | ||
2111 | u32 udccr = udc_readl(udc, UDCCR); | ||
2112 | struct pxa_ep *ep = &udc->pxa_ep[0]; | ||
2113 | |||
2114 | dev_info(udc->dev, "USB reset\n"); | ||
2115 | udc_writel(udc, UDCISR1, UDCISR1_IRRS); | ||
2116 | udc->stats.irqs_reset++; | ||
2117 | |||
2118 | if ((udccr & UDCCR_UDA) == 0) { | ||
2119 | dev_dbg(udc->dev, "USB reset start\n"); | ||
2120 | stop_activity(udc, udc->driver); | ||
2121 | } | ||
2122 | udc->gadget.speed = USB_SPEED_FULL; | ||
2123 | memset(&udc->stats, 0, sizeof udc->stats); | ||
2124 | |||
2125 | nuke(ep, -EPROTO); | ||
2126 | udc_ep_writel(ep, UDCCSR, UDCCSR0_FTF | UDCCSR0_OPC); | ||
2127 | ep0_idle(udc); | ||
2128 | } | ||
2129 | |||
2130 | /** | ||
2131 | * pxa_udc_irq - Main irq handler | ||
2132 | * @irq: irq number | ||
2133 | * @_dev: udc device | ||
2134 | * | ||
2135 | * Handles all udc interrupts | ||
2136 | */ | ||
2137 | static irqreturn_t pxa_udc_irq(int irq, void *_dev) | ||
2138 | { | ||
2139 | struct pxa_udc *udc = _dev; | ||
2140 | u32 udcisr0 = udc_readl(udc, UDCISR0); | ||
2141 | u32 udcisr1 = udc_readl(udc, UDCISR1); | ||
2142 | u32 udccr = udc_readl(udc, UDCCR); | ||
2143 | u32 udcisr1_spec; | ||
2144 | |||
2145 | dev_vdbg(udc->dev, "Interrupt, UDCISR0:0x%08x, UDCISR1:0x%08x, " | ||
2146 | "UDCCR:0x%08x\n", udcisr0, udcisr1, udccr); | ||
2147 | |||
2148 | udcisr1_spec = udcisr1 & 0xf8000000; | ||
2149 | if (unlikely(udcisr1_spec & UDCISR1_IRSU)) | ||
2150 | irq_udc_suspend(udc); | ||
2151 | if (unlikely(udcisr1_spec & UDCISR1_IRRU)) | ||
2152 | irq_udc_resume(udc); | ||
2153 | if (unlikely(udcisr1_spec & UDCISR1_IRCC)) | ||
2154 | irq_udc_reconfig(udc); | ||
2155 | if (unlikely(udcisr1_spec & UDCISR1_IRRS)) | ||
2156 | irq_udc_reset(udc); | ||
2157 | |||
2158 | if ((udcisr0 & UDCCISR0_EP_MASK) | (udcisr1 & UDCCISR1_EP_MASK)) | ||
2159 | irq_handle_data(irq, udc); | ||
2160 | |||
2161 | return IRQ_HANDLED; | ||
2162 | } | ||
2163 | |||
2164 | static struct pxa_udc memory = { | ||
2165 | .gadget = { | ||
2166 | .ops = &pxa_udc_ops, | ||
2167 | .ep0 = &memory.udc_usb_ep[0].usb_ep, | ||
2168 | .name = driver_name, | ||
2169 | .dev = { | ||
2170 | .bus_id = "gadget", | ||
2171 | }, | ||
2172 | }, | ||
2173 | |||
2174 | .udc_usb_ep = { | ||
2175 | USB_EP_CTRL, | ||
2176 | USB_EP_OUT_BULK(1), | ||
2177 | USB_EP_IN_BULK(2), | ||
2178 | USB_EP_IN_ISO(3), | ||
2179 | USB_EP_OUT_ISO(4), | ||
2180 | USB_EP_IN_INT(5), | ||
2181 | }, | ||
2182 | |||
2183 | .pxa_ep = { | ||
2184 | PXA_EP_CTRL, | ||
2185 | /* Endpoints for gadget zero */ | ||
2186 | PXA_EP_OUT_BULK(1, 1, 3, 0, 0), | ||
2187 | PXA_EP_IN_BULK(2, 2, 3, 0, 0), | ||
2188 | /* Endpoints for ether gadget, file storage gadget */ | ||
2189 | PXA_EP_OUT_BULK(3, 1, 1, 0, 0), | ||
2190 | PXA_EP_IN_BULK(4, 2, 1, 0, 0), | ||
2191 | PXA_EP_IN_ISO(5, 3, 1, 0, 0), | ||
2192 | PXA_EP_OUT_ISO(6, 4, 1, 0, 0), | ||
2193 | PXA_EP_IN_INT(7, 5, 1, 0, 0), | ||
2194 | /* Endpoints for RNDIS, serial */ | ||
2195 | PXA_EP_OUT_BULK(8, 1, 2, 0, 0), | ||
2196 | PXA_EP_IN_BULK(9, 2, 2, 0, 0), | ||
2197 | PXA_EP_IN_INT(10, 5, 2, 0, 0), | ||
2198 | /* | ||
2199 | * All the following endpoints are only for completion. They | ||
2200 | * won't never work, as multiple interfaces are really broken on | ||
2201 | * the pxa. | ||
2202 | */ | ||
2203 | PXA_EP_OUT_BULK(11, 1, 2, 1, 0), | ||
2204 | PXA_EP_IN_BULK(12, 2, 2, 1, 0), | ||
2205 | /* Endpoint for CDC Ether */ | ||
2206 | PXA_EP_OUT_BULK(13, 1, 1, 1, 1), | ||
2207 | PXA_EP_IN_BULK(14, 2, 1, 1, 1), | ||
2208 | } | ||
2209 | }; | ||
2210 | |||
2211 | /** | ||
2212 | * pxa_udc_probe - probes the udc device | ||
2213 | * @_dev: platform device | ||
2214 | * | ||
2215 | * Perform basic init : allocates udc clock, creates sysfs files, requests | ||
2216 | * irq. | ||
2217 | */ | ||
2218 | static int __init pxa_udc_probe(struct platform_device *pdev) | ||
2219 | { | ||
2220 | struct resource *regs; | ||
2221 | struct pxa_udc *udc = &memory; | ||
2222 | int retval; | ||
2223 | |||
2224 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
2225 | if (!regs) | ||
2226 | return -ENXIO; | ||
2227 | udc->irq = platform_get_irq(pdev, 0); | ||
2228 | if (udc->irq < 0) | ||
2229 | return udc->irq; | ||
2230 | |||
2231 | udc->dev = &pdev->dev; | ||
2232 | udc->mach = pdev->dev.platform_data; | ||
2233 | |||
2234 | udc->clk = clk_get(&pdev->dev, "UDCCLK"); | ||
2235 | if (IS_ERR(udc->clk)) { | ||
2236 | retval = PTR_ERR(udc->clk); | ||
2237 | goto err_clk; | ||
2238 | } | ||
2239 | |||
2240 | retval = -ENOMEM; | ||
2241 | udc->regs = ioremap(regs->start, regs->end - regs->start + 1); | ||
2242 | if (!udc->regs) { | ||
2243 | dev_err(&pdev->dev, "Unable to map UDC I/O memory\n"); | ||
2244 | goto err_map; | ||
2245 | } | ||
2246 | |||
2247 | device_initialize(&udc->gadget.dev); | ||
2248 | udc->gadget.dev.parent = &pdev->dev; | ||
2249 | udc->gadget.dev.dma_mask = NULL; | ||
2250 | |||
2251 | the_controller = udc; | ||
2252 | platform_set_drvdata(pdev, udc); | ||
2253 | udc_init_data(udc); | ||
2254 | pxa_eps_setup(udc); | ||
2255 | |||
2256 | /* irq setup after old hardware state is cleaned up */ | ||
2257 | retval = request_irq(udc->irq, pxa_udc_irq, | ||
2258 | IRQF_SHARED, driver_name, udc); | ||
2259 | if (retval != 0) { | ||
2260 | dev_err(udc->dev, "%s: can't get irq %i, err %d\n", | ||
2261 | driver_name, IRQ_USB, retval); | ||
2262 | goto err_irq; | ||
2263 | } | ||
2264 | |||
2265 | pxa_init_debugfs(udc); | ||
2266 | return 0; | ||
2267 | err_irq: | ||
2268 | iounmap(udc->regs); | ||
2269 | err_map: | ||
2270 | clk_put(udc->clk); | ||
2271 | udc->clk = NULL; | ||
2272 | err_clk: | ||
2273 | return retval; | ||
2274 | } | ||
2275 | |||
2276 | /** | ||
2277 | * pxa_udc_remove - removes the udc device driver | ||
2278 | * @_dev: platform device | ||
2279 | */ | ||
2280 | static int __exit pxa_udc_remove(struct platform_device *_dev) | ||
2281 | { | ||
2282 | struct pxa_udc *udc = platform_get_drvdata(_dev); | ||
2283 | |||
2284 | usb_gadget_unregister_driver(udc->driver); | ||
2285 | free_irq(udc->irq, udc); | ||
2286 | pxa_cleanup_debugfs(udc); | ||
2287 | |||
2288 | platform_set_drvdata(_dev, NULL); | ||
2289 | the_controller = NULL; | ||
2290 | clk_put(udc->clk); | ||
2291 | |||
2292 | return 0; | ||
2293 | } | ||
2294 | |||
2295 | static void pxa_udc_shutdown(struct platform_device *_dev) | ||
2296 | { | ||
2297 | struct pxa_udc *udc = platform_get_drvdata(_dev); | ||
2298 | |||
2299 | udc_disable(udc); | ||
2300 | } | ||
2301 | |||
2302 | #ifdef CONFIG_PM | ||
2303 | /** | ||
2304 | * pxa_udc_suspend - Suspend udc device | ||
2305 | * @_dev: platform device | ||
2306 | * @state: suspend state | ||
2307 | * | ||
2308 | * Suspends udc : saves configuration registers (UDCCR*), then disables the udc | ||
2309 | * device. | ||
2310 | */ | ||
2311 | static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state) | ||
2312 | { | ||
2313 | int i; | ||
2314 | struct pxa_udc *udc = platform_get_drvdata(_dev); | ||
2315 | struct pxa_ep *ep; | ||
2316 | |||
2317 | ep = &udc->pxa_ep[0]; | ||
2318 | udc->udccsr0 = udc_ep_readl(ep, UDCCSR); | ||
2319 | for (i = 1; i < NR_PXA_ENDPOINTS; i++) { | ||
2320 | ep = &udc->pxa_ep[i]; | ||
2321 | ep->udccsr_value = udc_ep_readl(ep, UDCCSR); | ||
2322 | ep->udccr_value = udc_ep_readl(ep, UDCCR); | ||
2323 | ep_dbg(ep, "udccsr:0x%03x, udccr:0x%x\n", | ||
2324 | ep->udccsr_value, ep->udccr_value); | ||
2325 | } | ||
2326 | |||
2327 | udc_disable(udc); | ||
2328 | |||
2329 | return 0; | ||
2330 | } | ||
2331 | |||
2332 | /** | ||
2333 | * pxa_udc_resume - Resume udc device | ||
2334 | * @_dev: platform device | ||
2335 | * | ||
2336 | * Resumes udc : restores configuration registers (UDCCR*), then enables the udc | ||
2337 | * device. | ||
2338 | */ | ||
2339 | static int pxa_udc_resume(struct platform_device *_dev) | ||
2340 | { | ||
2341 | int i; | ||
2342 | struct pxa_udc *udc = platform_get_drvdata(_dev); | ||
2343 | struct pxa_ep *ep; | ||
2344 | |||
2345 | ep = &udc->pxa_ep[0]; | ||
2346 | udc_ep_writel(ep, UDCCSR, udc->udccsr0 & (UDCCSR0_FST | UDCCSR0_DME)); | ||
2347 | for (i = 1; i < NR_PXA_ENDPOINTS; i++) { | ||
2348 | ep = &udc->pxa_ep[i]; | ||
2349 | udc_ep_writel(ep, UDCCSR, ep->udccsr_value); | ||
2350 | udc_ep_writel(ep, UDCCR, ep->udccr_value); | ||
2351 | ep_dbg(ep, "udccsr:0x%03x, udccr:0x%x\n", | ||
2352 | ep->udccsr_value, ep->udccr_value); | ||
2353 | } | ||
2354 | |||
2355 | udc_enable(udc); | ||
2356 | /* | ||
2357 | * We do not handle OTG yet. | ||
2358 | * | ||
2359 | * OTGPH bit is set when sleep mode is entered. | ||
2360 | * it indicates that OTG pad is retaining its state. | ||
2361 | * Upon exit from sleep mode and before clearing OTGPH, | ||
2362 | * Software must configure the USB OTG pad, UDC, and UHC | ||
2363 | * to the state they were in before entering sleep mode. | ||
2364 | * | ||
2365 | * Should be : PSSR |= PSSR_OTGPH; | ||
2366 | */ | ||
2367 | |||
2368 | return 0; | ||
2369 | } | ||
2370 | #endif | ||
2371 | |||
2372 | /* work with hotplug and coldplug */ | ||
2373 | MODULE_ALIAS("platform:pxa2xx-udc"); | ||
2374 | |||
2375 | static struct platform_driver udc_driver = { | ||
2376 | .driver = { | ||
2377 | .name = "pxa2xx-udc", | ||
2378 | .owner = THIS_MODULE, | ||
2379 | }, | ||
2380 | .remove = __exit_p(pxa_udc_remove), | ||
2381 | .shutdown = pxa_udc_shutdown, | ||
2382 | #ifdef CONFIG_PM | ||
2383 | .suspend = pxa_udc_suspend, | ||
2384 | .resume = pxa_udc_resume | ||
2385 | #endif | ||
2386 | }; | ||
2387 | |||
2388 | static int __init udc_init(void) | ||
2389 | { | ||
2390 | printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); | ||
2391 | return platform_driver_probe(&udc_driver, pxa_udc_probe); | ||
2392 | } | ||
2393 | module_init(udc_init); | ||
2394 | |||
2395 | |||
2396 | static void __exit udc_exit(void) | ||
2397 | { | ||
2398 | platform_driver_unregister(&udc_driver); | ||
2399 | } | ||
2400 | module_exit(udc_exit); | ||
2401 | |||
2402 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
2403 | MODULE_AUTHOR("Robert Jarzmik"); | ||
2404 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h new file mode 100644 index 000000000000..1d1b7936ee11 --- /dev/null +++ b/drivers/usb/gadget/pxa27x_udc.h | |||
@@ -0,0 +1,487 @@ | |||
1 | /* | ||
2 | * linux/drivers/usb/gadget/pxa27x_udc.h | ||
3 | * Intel PXA27x on-chip full speed USB device controller | ||
4 | * | ||
5 | * Inspired by original driver by Frank Becker, David Brownell, and others. | ||
6 | * Copyright (C) 2008 Robert Jarzmik | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #ifndef __LINUX_USB_GADGET_PXA27X_H | ||
24 | #define __LINUX_USB_GADGET_PXA27X_H | ||
25 | |||
26 | #include <linux/types.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/io.h> | ||
29 | |||
30 | /* | ||
31 | * Register definitions | ||
32 | */ | ||
33 | /* Offsets */ | ||
34 | #define UDCCR 0x0000 /* UDC Control Register */ | ||
35 | #define UDCICR0 0x0004 /* UDC Interrupt Control Register0 */ | ||
36 | #define UDCICR1 0x0008 /* UDC Interrupt Control Register1 */ | ||
37 | #define UDCISR0 0x000C /* UDC Interrupt Status Register 0 */ | ||
38 | #define UDCISR1 0x0010 /* UDC Interrupt Status Register 1 */ | ||
39 | #define UDCFNR 0x0014 /* UDC Frame Number Register */ | ||
40 | #define UDCOTGICR 0x0018 /* UDC On-The-Go interrupt control */ | ||
41 | #define UP2OCR 0x0020 /* USB Port 2 Output Control register */ | ||
42 | #define UP3OCR 0x0024 /* USB Port 3 Output Control register */ | ||
43 | #define UDCCSRn(x) (0x0100 + ((x)<<2)) /* UDC Control/Status register */ | ||
44 | #define UDCBCRn(x) (0x0200 + ((x)<<2)) /* UDC Byte Count Register */ | ||
45 | #define UDCDRn(x) (0x0300 + ((x)<<2)) /* UDC Data Register */ | ||
46 | #define UDCCRn(x) (0x0400 + ((x)<<2)) /* UDC Control Register */ | ||
47 | |||
48 | #define UDCCR_OEN (1 << 31) /* On-the-Go Enable */ | ||
49 | #define UDCCR_AALTHNP (1 << 30) /* A-device Alternate Host Negotiation | ||
50 | Protocol Port Support */ | ||
51 | #define UDCCR_AHNP (1 << 29) /* A-device Host Negotiation Protocol | ||
52 | Support */ | ||
53 | #define UDCCR_BHNP (1 << 28) /* B-device Host Negotiation Protocol | ||
54 | Enable */ | ||
55 | #define UDCCR_DWRE (1 << 16) /* Device Remote Wake-up Enable */ | ||
56 | #define UDCCR_ACN (0x03 << 11) /* Active UDC configuration Number */ | ||
57 | #define UDCCR_ACN_S 11 | ||
58 | #define UDCCR_AIN (0x07 << 8) /* Active UDC interface Number */ | ||
59 | #define UDCCR_AIN_S 8 | ||
60 | #define UDCCR_AAISN (0x07 << 5) /* Active UDC Alternate Interface | ||
61 | Setting Number */ | ||
62 | #define UDCCR_AAISN_S 5 | ||
63 | #define UDCCR_SMAC (1 << 4) /* Switch Endpoint Memory to Active | ||
64 | Configuration */ | ||
65 | #define UDCCR_EMCE (1 << 3) /* Endpoint Memory Configuration | ||
66 | Error */ | ||
67 | #define UDCCR_UDR (1 << 2) /* UDC Resume */ | ||
68 | #define UDCCR_UDA (1 << 1) /* UDC Active */ | ||
69 | #define UDCCR_UDE (1 << 0) /* UDC Enable */ | ||
70 | |||
71 | #define UDCICR_INT(n, intr) (((intr) & 0x03) << (((n) & 0x0F) * 2)) | ||
72 | #define UDCICR1_IECC (1 << 31) /* IntEn - Configuration Change */ | ||
73 | #define UDCICR1_IESOF (1 << 30) /* IntEn - Start of Frame */ | ||
74 | #define UDCICR1_IERU (1 << 29) /* IntEn - Resume */ | ||
75 | #define UDCICR1_IESU (1 << 28) /* IntEn - Suspend */ | ||
76 | #define UDCICR1_IERS (1 << 27) /* IntEn - Reset */ | ||
77 | #define UDCICR_FIFOERR (1 << 1) /* FIFO Error interrupt for EP */ | ||
78 | #define UDCICR_PKTCOMPL (1 << 0) /* Packet Complete interrupt for EP */ | ||
79 | #define UDCICR_INT_MASK (UDCICR_FIFOERR | UDCICR_PKTCOMPL) | ||
80 | |||
81 | #define UDCISR_INT(n, intr) (((intr) & 0x03) << (((n) & 0x0F) * 2)) | ||
82 | #define UDCISR1_IRCC (1 << 31) /* IntReq - Configuration Change */ | ||
83 | #define UDCISR1_IRSOF (1 << 30) /* IntReq - Start of Frame */ | ||
84 | #define UDCISR1_IRRU (1 << 29) /* IntReq - Resume */ | ||
85 | #define UDCISR1_IRSU (1 << 28) /* IntReq - Suspend */ | ||
86 | #define UDCISR1_IRRS (1 << 27) /* IntReq - Reset */ | ||
87 | #define UDCISR_INT_MASK (UDCICR_FIFOERR | UDCICR_PKTCOMPL) | ||
88 | |||
89 | #define UDCOTGICR_IESF (1 << 24) /* OTG SET_FEATURE command recvd */ | ||
90 | #define UDCOTGICR_IEXR (1 << 17) /* Extra Transciever Interrupt | ||
91 | Rising Edge Interrupt Enable */ | ||
92 | #define UDCOTGICR_IEXF (1 << 16) /* Extra Transciever Interrupt | ||
93 | Falling Edge Interrupt Enable */ | ||
94 | #define UDCOTGICR_IEVV40R (1 << 9) /* OTG Vbus Valid 4.0V Rising Edge | ||
95 | Interrupt Enable */ | ||
96 | #define UDCOTGICR_IEVV40F (1 << 8) /* OTG Vbus Valid 4.0V Falling Edge | ||
97 | Interrupt Enable */ | ||
98 | #define UDCOTGICR_IEVV44R (1 << 7) /* OTG Vbus Valid 4.4V Rising Edge | ||
99 | Interrupt Enable */ | ||
100 | #define UDCOTGICR_IEVV44F (1 << 6) /* OTG Vbus Valid 4.4V Falling Edge | ||
101 | Interrupt Enable */ | ||
102 | #define UDCOTGICR_IESVR (1 << 5) /* OTG Session Valid Rising Edge | ||
103 | Interrupt Enable */ | ||
104 | #define UDCOTGICR_IESVF (1 << 4) /* OTG Session Valid Falling Edge | ||
105 | Interrupt Enable */ | ||
106 | #define UDCOTGICR_IESDR (1 << 3) /* OTG A-Device SRP Detect Rising | ||
107 | Edge Interrupt Enable */ | ||
108 | #define UDCOTGICR_IESDF (1 << 2) /* OTG A-Device SRP Detect Falling | ||
109 | Edge Interrupt Enable */ | ||
110 | #define UDCOTGICR_IEIDR (1 << 1) /* OTG ID Change Rising Edge | ||
111 | Interrupt Enable */ | ||
112 | #define UDCOTGICR_IEIDF (1 << 0) /* OTG ID Change Falling Edge | ||
113 | Interrupt Enable */ | ||
114 | |||
115 | /* Host Port 2 field bits */ | ||
116 | #define UP2OCR_CPVEN (1 << 0) /* Charge Pump Vbus Enable */ | ||
117 | #define UP2OCR_CPVPE (1 << 1) /* Charge Pump Vbus Pulse Enable */ | ||
118 | /* Transceiver enablers */ | ||
119 | #define UP2OCR_DPPDE (1 << 2) /* D+ Pull Down Enable */ | ||
120 | #define UP2OCR_DMPDE (1 << 3) /* D- Pull Down Enable */ | ||
121 | #define UP2OCR_DPPUE (1 << 4) /* D+ Pull Up Enable */ | ||
122 | #define UP2OCR_DMPUE (1 << 5) /* D- Pull Up Enable */ | ||
123 | #define UP2OCR_DPPUBE (1 << 6) /* D+ Pull Up Bypass Enable */ | ||
124 | #define UP2OCR_DMPUBE (1 << 7) /* D- Pull Up Bypass Enable */ | ||
125 | #define UP2OCR_EXSP (1 << 8) /* External Transceiver Speed Control */ | ||
126 | #define UP2OCR_EXSUS (1 << 9) /* External Transceiver Speed Enable */ | ||
127 | #define UP2OCR_IDON (1 << 10) /* OTG ID Read Enable */ | ||
128 | #define UP2OCR_HXS (1 << 16) /* Transceiver Output Select */ | ||
129 | #define UP2OCR_HXOE (1 << 17) /* Transceiver Output Enable */ | ||
130 | #define UP2OCR_SEOS (1 << 24) /* Single-Ended Output Select */ | ||
131 | |||
132 | #define UDCCSR0_SA (1 << 7) /* Setup Active */ | ||
133 | #define UDCCSR0_RNE (1 << 6) /* Receive FIFO Not Empty */ | ||
134 | #define UDCCSR0_FST (1 << 5) /* Force Stall */ | ||
135 | #define UDCCSR0_SST (1 << 4) /* Sent Stall */ | ||
136 | #define UDCCSR0_DME (1 << 3) /* DMA Enable */ | ||
137 | #define UDCCSR0_FTF (1 << 2) /* Flush Transmit FIFO */ | ||
138 | #define UDCCSR0_IPR (1 << 1) /* IN Packet Ready */ | ||
139 | #define UDCCSR0_OPC (1 << 0) /* OUT Packet Complete */ | ||
140 | |||
141 | #define UDCCSR_DPE (1 << 9) /* Data Packet Error */ | ||
142 | #define UDCCSR_FEF (1 << 8) /* Flush Endpoint FIFO */ | ||
143 | #define UDCCSR_SP (1 << 7) /* Short Packet Control/Status */ | ||
144 | #define UDCCSR_BNE (1 << 6) /* Buffer Not Empty (IN endpoints) */ | ||
145 | #define UDCCSR_BNF (1 << 6) /* Buffer Not Full (OUT endpoints) */ | ||
146 | #define UDCCSR_FST (1 << 5) /* Force STALL */ | ||
147 | #define UDCCSR_SST (1 << 4) /* Sent STALL */ | ||
148 | #define UDCCSR_DME (1 << 3) /* DMA Enable */ | ||
149 | #define UDCCSR_TRN (1 << 2) /* Tx/Rx NAK */ | ||
150 | #define UDCCSR_PC (1 << 1) /* Packet Complete */ | ||
151 | #define UDCCSR_FS (1 << 0) /* FIFO needs service */ | ||
152 | |||
153 | #define UDCCONR_CN (0x03 << 25) /* Configuration Number */ | ||
154 | #define UDCCONR_CN_S 25 | ||
155 | #define UDCCONR_IN (0x07 << 22) /* Interface Number */ | ||
156 | #define UDCCONR_IN_S 22 | ||
157 | #define UDCCONR_AISN (0x07 << 19) /* Alternate Interface Number */ | ||
158 | #define UDCCONR_AISN_S 19 | ||
159 | #define UDCCONR_EN (0x0f << 15) /* Endpoint Number */ | ||
160 | #define UDCCONR_EN_S 15 | ||
161 | #define UDCCONR_ET (0x03 << 13) /* Endpoint Type: */ | ||
162 | #define UDCCONR_ET_S 13 | ||
163 | #define UDCCONR_ET_INT (0x03 << 13) /* Interrupt */ | ||
164 | #define UDCCONR_ET_BULK (0x02 << 13) /* Bulk */ | ||
165 | #define UDCCONR_ET_ISO (0x01 << 13) /* Isochronous */ | ||
166 | #define UDCCONR_ET_NU (0x00 << 13) /* Not used */ | ||
167 | #define UDCCONR_ED (1 << 12) /* Endpoint Direction */ | ||
168 | #define UDCCONR_MPS (0x3ff << 2) /* Maximum Packet Size */ | ||
169 | #define UDCCONR_MPS_S 2 | ||
170 | #define UDCCONR_DE (1 << 1) /* Double Buffering Enable */ | ||
171 | #define UDCCONR_EE (1 << 0) /* Endpoint Enable */ | ||
172 | |||
173 | #define UDCCR_MASK_BITS (UDCCR_OEN | UDCCR_SMAC | UDCCR_UDR | UDCCR_UDE) | ||
174 | #define UDCCSR_WR_MASK (UDCCSR_DME | UDCCSR_FST) | ||
175 | #define UDC_FNR_MASK (0x7ff) | ||
176 | #define UDC_BCR_MASK (0x3ff) | ||
177 | |||
178 | /* | ||
179 | * UDCCR = UDC Endpoint Configuration Registers | ||
180 | * UDCCSR = UDC Control/Status Register for this EP | ||
181 | * UDCBCR = UDC Byte Count Remaining (contents of OUT fifo) | ||
182 | * UDCDR = UDC Endpoint Data Register (the fifo) | ||
183 | */ | ||
184 | #define ofs_UDCCR(ep) (UDCCRn(ep->idx)) | ||
185 | #define ofs_UDCCSR(ep) (UDCCSRn(ep->idx)) | ||
186 | #define ofs_UDCBCR(ep) (UDCBCRn(ep->idx)) | ||
187 | #define ofs_UDCDR(ep) (UDCDRn(ep->idx)) | ||
188 | |||
189 | /* Register access macros */ | ||
190 | #define udc_ep_readl(ep, reg) \ | ||
191 | __raw_readl((ep)->dev->regs + ofs_##reg(ep)) | ||
192 | #define udc_ep_writel(ep, reg, value) \ | ||
193 | __raw_writel((value), ep->dev->regs + ofs_##reg(ep)) | ||
194 | #define udc_ep_readb(ep, reg) \ | ||
195 | __raw_readb((ep)->dev->regs + ofs_##reg(ep)) | ||
196 | #define udc_ep_writeb(ep, reg, value) \ | ||
197 | __raw_writeb((value), ep->dev->regs + ofs_##reg(ep)) | ||
198 | #define udc_readl(dev, reg) \ | ||
199 | __raw_readl((dev)->regs + (reg)) | ||
200 | #define udc_writel(udc, reg, value) \ | ||
201 | __raw_writel((value), (udc)->regs + (reg)) | ||
202 | |||
203 | #define UDCCSR_MASK (UDCCSR_FST | UDCCSR_DME) | ||
204 | #define UDCCISR0_EP_MASK ~0 | ||
205 | #define UDCCISR1_EP_MASK 0xffff | ||
206 | #define UDCCSR0_CTRL_REQ_MASK (UDCCSR0_OPC | UDCCSR0_SA | UDCCSR0_RNE) | ||
207 | |||
208 | #define EPIDX(ep) (ep->idx) | ||
209 | #define EPADDR(ep) (ep->addr) | ||
210 | #define EPXFERTYPE(ep) (ep->type) | ||
211 | #define EPNAME(ep) (ep->name) | ||
212 | #define is_ep0(ep) (!ep->idx) | ||
213 | #define EPXFERTYPE_is_ISO(ep) (EPXFERTYPE(ep) == USB_ENDPOINT_XFER_ISOC) | ||
214 | |||
215 | /* | ||
216 | * Endpoint definitions | ||
217 | * | ||
218 | * Once enabled, pxa endpoint configuration is freezed, and cannot change | ||
219 | * unless a reset happens or the udc is disabled. | ||
220 | * Therefore, we must define all pxa potential endpoint definitions needed for | ||
221 | * all gadget and set them up before the udc is enabled. | ||
222 | * | ||
223 | * As the architecture chosen is fully static, meaning the pxa endpoint | ||
224 | * configurations are set up once and for all, we must provide a way to match | ||
225 | * one usb endpoint (usb_ep) to several pxa endpoints. The reason is that gadget | ||
226 | * layer autoconf doesn't choose the usb_ep endpoint on (config, interface, alt) | ||
227 | * criteria, while the pxa architecture requires that. | ||
228 | * | ||
229 | * The solution is to define several pxa endpoints matching one usb_ep. Ex: | ||
230 | * - "ep1-in" matches pxa endpoint EPA (which is an IN ep at addr 1, when | ||
231 | * the udc talks on (config=3, interface=0, alt=0) | ||
232 | * - "ep1-in" matches pxa endpoint EPB (which is an IN ep at addr 1, when | ||
233 | * the udc talks on (config=3, interface=0, alt=1) | ||
234 | * - "ep1-in" matches pxa endpoint EPC (which is an IN ep at addr 1, when | ||
235 | * the udc talks on (config=2, interface=0, alt=0) | ||
236 | * | ||
237 | * We'll define the pxa endpoint by its index (EPA => idx=1, EPB => idx=2, ...) | ||
238 | */ | ||
239 | |||
240 | /* | ||
241 | * Endpoint definition helpers | ||
242 | */ | ||
243 | #define USB_EP_DEF(addr, bname, dir, type, maxpkt) \ | ||
244 | { .usb_ep = { .name = bname, .ops = &pxa_ep_ops, .maxpacket = maxpkt, }, \ | ||
245 | .desc = { .bEndpointAddress = addr | (dir ? USB_DIR_IN : 0), \ | ||
246 | .bmAttributes = type, \ | ||
247 | .wMaxPacketSize = maxpkt, }, \ | ||
248 | .dev = &memory \ | ||
249 | } | ||
250 | #define USB_EP_BULK(addr, bname, dir) \ | ||
251 | USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_BULK, BULK_FIFO_SIZE) | ||
252 | #define USB_EP_ISO(addr, bname, dir) \ | ||
253 | USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_ISOC, ISO_FIFO_SIZE) | ||
254 | #define USB_EP_INT(addr, bname, dir) \ | ||
255 | USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_INT, INT_FIFO_SIZE) | ||
256 | #define USB_EP_IN_BULK(n) USB_EP_BULK(n, "ep" #n "in-bulk", 1) | ||
257 | #define USB_EP_OUT_BULK(n) USB_EP_BULK(n, "ep" #n "out-bulk", 0) | ||
258 | #define USB_EP_IN_ISO(n) USB_EP_ISO(n, "ep" #n "in-iso", 1) | ||
259 | #define USB_EP_OUT_ISO(n) USB_EP_ISO(n, "ep" #n "out-iso", 0) | ||
260 | #define USB_EP_IN_INT(n) USB_EP_INT(n, "ep" #n "in-int", 1) | ||
261 | #define USB_EP_CTRL USB_EP_DEF(0, "ep0", 0, 0, EP0_FIFO_SIZE) | ||
262 | |||
263 | #define PXA_EP_DEF(_idx, _addr, dir, _type, maxpkt, _config, iface, altset) \ | ||
264 | { \ | ||
265 | .dev = &memory, \ | ||
266 | .name = "ep" #_idx, \ | ||
267 | .idx = _idx, .enabled = 0, \ | ||
268 | .dir_in = dir, .addr = _addr, \ | ||
269 | .config = _config, .interface = iface, .alternate = altset, \ | ||
270 | .type = _type, .fifo_size = maxpkt, \ | ||
271 | } | ||
272 | #define PXA_EP_BULK(_idx, addr, dir, config, iface, alt) \ | ||
273 | PXA_EP_DEF(_idx, addr, dir, USB_ENDPOINT_XFER_BULK, BULK_FIFO_SIZE, \ | ||
274 | config, iface, alt) | ||
275 | #define PXA_EP_ISO(_idx, addr, dir, config, iface, alt) \ | ||
276 | PXA_EP_DEF(_idx, addr, dir, USB_ENDPOINT_XFER_ISOC, ISO_FIFO_SIZE, \ | ||
277 | config, iface, alt) | ||
278 | #define PXA_EP_INT(_idx, addr, dir, config, iface, alt) \ | ||
279 | PXA_EP_DEF(_idx, addr, dir, USB_ENDPOINT_XFER_INT, INT_FIFO_SIZE, \ | ||
280 | config, iface, alt) | ||
281 | #define PXA_EP_IN_BULK(i, adr, c, f, a) PXA_EP_BULK(i, adr, 1, c, f, a) | ||
282 | #define PXA_EP_OUT_BULK(i, adr, c, f, a) PXA_EP_BULK(i, adr, 0, c, f, a) | ||
283 | #define PXA_EP_IN_ISO(i, adr, c, f, a) PXA_EP_ISO(i, adr, 1, c, f, a) | ||
284 | #define PXA_EP_OUT_ISO(i, adr, c, f, a) PXA_EP_ISO(i, adr, 0, c, f, a) | ||
285 | #define PXA_EP_IN_INT(i, adr, c, f, a) PXA_EP_INT(i, adr, 1, c, f, a) | ||
286 | #define PXA_EP_CTRL PXA_EP_DEF(0, 0, 0, 0, EP0_FIFO_SIZE, 0, 0, 0) | ||
287 | |||
288 | struct pxa27x_udc; | ||
289 | |||
290 | struct stats { | ||
291 | unsigned long in_ops; | ||
292 | unsigned long out_ops; | ||
293 | unsigned long in_bytes; | ||
294 | unsigned long out_bytes; | ||
295 | unsigned long irqs; | ||
296 | }; | ||
297 | |||
298 | /** | ||
299 | * struct udc_usb_ep - container of each usb_ep structure | ||
300 | * @usb_ep: usb endpoint | ||
301 | * @desc: usb descriptor, especially type and address | ||
302 | * @dev: udc managing this endpoint | ||
303 | * @pxa_ep: matching pxa_ep (cache of find_pxa_ep() call) | ||
304 | */ | ||
305 | struct udc_usb_ep { | ||
306 | struct usb_ep usb_ep; | ||
307 | struct usb_endpoint_descriptor desc; | ||
308 | struct pxa_udc *dev; | ||
309 | struct pxa_ep *pxa_ep; | ||
310 | }; | ||
311 | |||
312 | /** | ||
313 | * struct pxa_ep - pxa endpoint | ||
314 | * @dev: udc device | ||
315 | * @queue: requests queue | ||
316 | * @lock: lock to pxa_ep data (queues and stats) | ||
317 | * @enabled: true when endpoint enabled (not stopped by gadget layer) | ||
318 | * @idx: endpoint index (1 => epA, 2 => epB, ..., 24 => epX) | ||
319 | * @name: endpoint name (for trace/debug purpose) | ||
320 | * @dir_in: 1 if IN endpoint, 0 if OUT endpoint | ||
321 | * @addr: usb endpoint number | ||
322 | * @config: configuration in which this endpoint is active | ||
323 | * @interface: interface in which this endpoint is active | ||
324 | * @alternate: altsetting in which this endpoitn is active | ||
325 | * @fifo_size: max packet size in the endpoint fifo | ||
326 | * @type: endpoint type (bulk, iso, int, ...) | ||
327 | * @udccsr_value: save register of UDCCSR0 for suspend/resume | ||
328 | * @udccr_value: save register of UDCCR for suspend/resume | ||
329 | * @stats: endpoint statistics | ||
330 | * | ||
331 | * The *PROBLEM* is that pxa's endpoint configuration scheme is both misdesigned | ||
332 | * (cares about config/interface/altsetting, thus placing needless limits on | ||
333 | * device capability) and full of implementation bugs forcing it to be set up | ||
334 | * for use more or less like a pxa255. | ||
335 | * | ||
336 | * As we define the pxa_ep statically, we must guess all needed pxa_ep for all | ||
337 | * gadget which may work with this udc driver. | ||
338 | */ | ||
339 | struct pxa_ep { | ||
340 | struct pxa_udc *dev; | ||
341 | |||
342 | struct list_head queue; | ||
343 | spinlock_t lock; /* Protects this structure */ | ||
344 | /* (queues, stats) */ | ||
345 | unsigned enabled:1; | ||
346 | |||
347 | unsigned idx:5; | ||
348 | char *name; | ||
349 | |||
350 | /* | ||
351 | * Specific pxa endpoint data, needed for hardware initialization | ||
352 | */ | ||
353 | unsigned dir_in:1; | ||
354 | unsigned addr:3; | ||
355 | unsigned config:2; | ||
356 | unsigned interface:3; | ||
357 | unsigned alternate:3; | ||
358 | unsigned fifo_size; | ||
359 | unsigned type; | ||
360 | |||
361 | #ifdef CONFIG_PM | ||
362 | u32 udccsr_value; | ||
363 | u32 udccr_value; | ||
364 | #endif | ||
365 | struct stats stats; | ||
366 | }; | ||
367 | |||
368 | /** | ||
369 | * struct pxa27x_request - container of each usb_request structure | ||
370 | * @req: usb request | ||
371 | * @udc_usb_ep: usb endpoint the request was submitted on | ||
372 | * @in_use: sanity check if request already queued on an pxa_ep | ||
373 | * @queue: linked list of requests, linked on pxa_ep->queue | ||
374 | */ | ||
375 | struct pxa27x_request { | ||
376 | struct usb_request req; | ||
377 | struct udc_usb_ep *udc_usb_ep; | ||
378 | unsigned in_use:1; | ||
379 | struct list_head queue; | ||
380 | }; | ||
381 | |||
382 | enum ep0_state { | ||
383 | WAIT_FOR_SETUP, | ||
384 | SETUP_STAGE, | ||
385 | IN_DATA_STAGE, | ||
386 | OUT_DATA_STAGE, | ||
387 | IN_STATUS_STAGE, | ||
388 | OUT_STATUS_STAGE, | ||
389 | STALL, | ||
390 | WAIT_ACK_SET_CONF_INTERF | ||
391 | }; | ||
392 | |||
393 | static char *ep0_state_name[] = { | ||
394 | "WAIT_FOR_SETUP", "SETUP_STAGE", "IN_DATA_STAGE", "OUT_DATA_STAGE", | ||
395 | "IN_STATUS_STAGE", "OUT_STATUS_STAGE", "STALL", | ||
396 | "WAIT_ACK_SET_CONF_INTERF" | ||
397 | }; | ||
398 | #define EP0_STNAME(udc) ep0_state_name[(udc)->ep0state] | ||
399 | |||
400 | #define EP0_FIFO_SIZE 16U | ||
401 | #define BULK_FIFO_SIZE 64U | ||
402 | #define ISO_FIFO_SIZE 256U | ||
403 | #define INT_FIFO_SIZE 16U | ||
404 | |||
405 | struct udc_stats { | ||
406 | unsigned long irqs_reset; | ||
407 | unsigned long irqs_suspend; | ||
408 | unsigned long irqs_resume; | ||
409 | unsigned long irqs_reconfig; | ||
410 | }; | ||
411 | |||
412 | #define NR_USB_ENDPOINTS (1 + 5) /* ep0 + ep1in-bulk + .. + ep3in-iso */ | ||
413 | #define NR_PXA_ENDPOINTS (1 + 14) /* ep0 + epA + epB + .. + epX */ | ||
414 | |||
415 | /** | ||
416 | * struct pxa_udc - udc structure | ||
417 | * @regs: mapped IO space | ||
418 | * @irq: udc irq | ||
419 | * @clk: udc clock | ||
420 | * @usb_gadget: udc gadget structure | ||
421 | * @driver: bound gadget (zero, g_ether, g_file_storage, ...) | ||
422 | * @dev: device | ||
423 | * @mach: machine info, used to activate specific GPIO | ||
424 | * @ep0state: control endpoint state machine state | ||
425 | * @stats: statistics on udc usage | ||
426 | * @udc_usb_ep: array of usb endpoints offered by the gadget | ||
427 | * @pxa_ep: array of pxa available endpoints | ||
428 | * @config: UDC active configuration | ||
429 | * @last_interface: UDC interface of the last SET_INTERFACE host request | ||
430 | * @last_alternate: UDC altsetting of the last SET_INTERFACE host request | ||
431 | * @udccsr0: save of udccsr0 in case of suspend | ||
432 | * @debugfs_root: root entry of debug filesystem | ||
433 | * @debugfs_state: debugfs entry for "udcstate" | ||
434 | * @debugfs_queues: debugfs entry for "queues" | ||
435 | * @debugfs_eps: debugfs entry for "epstate" | ||
436 | */ | ||
437 | struct pxa_udc { | ||
438 | void __iomem *regs; | ||
439 | int irq; | ||
440 | struct clk *clk; | ||
441 | |||
442 | struct usb_gadget gadget; | ||
443 | struct usb_gadget_driver *driver; | ||
444 | struct device *dev; | ||
445 | struct pxa2xx_udc_mach_info *mach; | ||
446 | |||
447 | enum ep0_state ep0state; | ||
448 | struct udc_stats stats; | ||
449 | |||
450 | struct udc_usb_ep udc_usb_ep[NR_USB_ENDPOINTS]; | ||
451 | struct pxa_ep pxa_ep[NR_PXA_ENDPOINTS]; | ||
452 | |||
453 | unsigned config:2; | ||
454 | unsigned last_interface:3; | ||
455 | unsigned last_alternate:3; | ||
456 | |||
457 | #ifdef CONFIG_PM | ||
458 | unsigned udccsr0; | ||
459 | #endif | ||
460 | #ifdef CONFIG_USB_GADGET_DEBUG_FS | ||
461 | struct dentry *debugfs_root; | ||
462 | struct dentry *debugfs_state; | ||
463 | struct dentry *debugfs_queues; | ||
464 | struct dentry *debugfs_eps; | ||
465 | #endif | ||
466 | }; | ||
467 | |||
468 | static inline struct pxa_udc *to_gadget_udc(struct usb_gadget *gadget) | ||
469 | { | ||
470 | return container_of(gadget, struct pxa_udc, gadget); | ||
471 | } | ||
472 | |||
473 | /* | ||
474 | * Debugging/message support | ||
475 | */ | ||
476 | #define ep_dbg(ep, fmt, arg...) \ | ||
477 | dev_dbg(ep->dev->dev, "%s:%s: " fmt, EPNAME(ep), __func__, ## arg) | ||
478 | #define ep_vdbg(ep, fmt, arg...) \ | ||
479 | dev_vdbg(ep->dev->dev, "%s:%s: " fmt, EPNAME(ep), __func__, ## arg) | ||
480 | #define ep_err(ep, fmt, arg...) \ | ||
481 | dev_err(ep->dev->dev, "%s:%s: " fmt, EPNAME(ep), __func__, ## arg) | ||
482 | #define ep_info(ep, fmt, arg...) \ | ||
483 | dev_info(ep->dev->dev, "%s:%s: " fmt, EPNAME(ep), __func__, ## arg) | ||
484 | #define ep_warn(ep, fmt, arg...) \ | ||
485 | dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg) | ||
486 | |||
487 | #endif /* __LINUX_USB_GADGET_PXA27X_H */ | ||
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 8d158e5640e3..54cdd6f94034 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -135,7 +135,10 @@ struct gs_port { | |||
135 | int port_in_use; /* open/close in progress */ | 135 | int port_in_use; /* open/close in progress */ |
136 | wait_queue_head_t port_write_wait;/* waiting to write */ | 136 | wait_queue_head_t port_write_wait;/* waiting to write */ |
137 | struct gs_buf *port_write_buf; | 137 | struct gs_buf *port_write_buf; |
138 | struct usb_cdc_line_coding port_line_coding; | 138 | struct usb_cdc_line_coding port_line_coding; /* 8-N-1 etc */ |
139 | u16 port_handshake_bits; | ||
140 | #define RS232_RTS (1 << 1) | ||
141 | #define RS232_DTE (1 << 0) | ||
139 | }; | 142 | }; |
140 | 143 | ||
141 | /* the device structure holds info for the USB device */ | 144 | /* the device structure holds info for the USB device */ |
@@ -199,6 +202,8 @@ static int gs_setup_standard(struct usb_gadget *gadget, | |||
199 | static int gs_setup_class(struct usb_gadget *gadget, | 202 | static int gs_setup_class(struct usb_gadget *gadget, |
200 | const struct usb_ctrlrequest *ctrl); | 203 | const struct usb_ctrlrequest *ctrl); |
201 | static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req); | 204 | static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req); |
205 | static void gs_setup_complete_set_line_coding(struct usb_ep *ep, | ||
206 | struct usb_request *req); | ||
202 | static void gs_disconnect(struct usb_gadget *gadget); | 207 | static void gs_disconnect(struct usb_gadget *gadget); |
203 | static int gs_set_config(struct gs_dev *dev, unsigned config); | 208 | static int gs_set_config(struct gs_dev *dev, unsigned config); |
204 | static void gs_reset_config(struct gs_dev *dev); | 209 | static void gs_reset_config(struct gs_dev *dev); |
@@ -406,7 +411,7 @@ static struct usb_cdc_acm_descriptor gs_acm_descriptor = { | |||
406 | .bLength = sizeof(gs_acm_descriptor), | 411 | .bLength = sizeof(gs_acm_descriptor), |
407 | .bDescriptorType = USB_DT_CS_INTERFACE, | 412 | .bDescriptorType = USB_DT_CS_INTERFACE, |
408 | .bDescriptorSubType = USB_CDC_ACM_TYPE, | 413 | .bDescriptorSubType = USB_CDC_ACM_TYPE, |
409 | .bmCapabilities = 0, | 414 | .bmCapabilities = (1 << 1), |
410 | }; | 415 | }; |
411 | 416 | ||
412 | static const struct usb_cdc_union_desc gs_union_desc = { | 417 | static const struct usb_cdc_union_desc gs_union_desc = { |
@@ -1502,6 +1507,8 @@ static int gs_setup(struct usb_gadget *gadget, | |||
1502 | u16 wValue = le16_to_cpu(ctrl->wValue); | 1507 | u16 wValue = le16_to_cpu(ctrl->wValue); |
1503 | u16 wLength = le16_to_cpu(ctrl->wLength); | 1508 | u16 wLength = le16_to_cpu(ctrl->wLength); |
1504 | 1509 | ||
1510 | req->complete = gs_setup_complete; | ||
1511 | |||
1505 | switch (ctrl->bRequestType & USB_TYPE_MASK) { | 1512 | switch (ctrl->bRequestType & USB_TYPE_MASK) { |
1506 | case USB_TYPE_STANDARD: | 1513 | case USB_TYPE_STANDARD: |
1507 | ret = gs_setup_standard(gadget,ctrl); | 1514 | ret = gs_setup_standard(gadget,ctrl); |
@@ -1679,18 +1686,14 @@ static int gs_setup_class(struct usb_gadget *gadget, | |||
1679 | 1686 | ||
1680 | switch (ctrl->bRequest) { | 1687 | switch (ctrl->bRequest) { |
1681 | case USB_CDC_REQ_SET_LINE_CODING: | 1688 | case USB_CDC_REQ_SET_LINE_CODING: |
1682 | /* FIXME Submit req to read the data; have its completion | 1689 | if (wLength != sizeof(struct usb_cdc_line_coding)) |
1683 | * handler copy that data to port->port_line_coding (iff | 1690 | break; |
1684 | * it's valid) and maybe pass it on. Until then, fail. | 1691 | ret = wLength; |
1685 | */ | 1692 | req->complete = gs_setup_complete_set_line_coding; |
1686 | pr_warning("gs_setup: set_line_coding " | ||
1687 | "unuspported\n"); | ||
1688 | break; | 1693 | break; |
1689 | 1694 | ||
1690 | case USB_CDC_REQ_GET_LINE_CODING: | 1695 | case USB_CDC_REQ_GET_LINE_CODING: |
1691 | port = dev->dev_port[0]; /* ACM only has one port */ | 1696 | ret = min_t(int, wLength, sizeof(struct usb_cdc_line_coding)); |
1692 | ret = min(wLength, | ||
1693 | (u16)sizeof(struct usb_cdc_line_coding)); | ||
1694 | if (port) { | 1697 | if (port) { |
1695 | spin_lock(&port->port_lock); | 1698 | spin_lock(&port->port_lock); |
1696 | memcpy(req->buf, &port->port_line_coding, ret); | 1699 | memcpy(req->buf, &port->port_line_coding, ret); |
@@ -1699,15 +1702,27 @@ static int gs_setup_class(struct usb_gadget *gadget, | |||
1699 | break; | 1702 | break; |
1700 | 1703 | ||
1701 | case USB_CDC_REQ_SET_CONTROL_LINE_STATE: | 1704 | case USB_CDC_REQ_SET_CONTROL_LINE_STATE: |
1702 | /* FIXME Submit req to read the data; have its completion | 1705 | if (wLength != 0) |
1703 | * handler use that to set the state (iff it's valid) and | 1706 | break; |
1704 | * maybe pass it on. Until then, fail. | 1707 | ret = 0; |
1705 | */ | 1708 | if (port) { |
1706 | pr_warning("gs_setup: set_control_line_state " | 1709 | /* REVISIT: we currently just remember this data. |
1707 | "unuspported\n"); | 1710 | * If we change that, update whatever hardware needs |
1711 | * updating. | ||
1712 | */ | ||
1713 | spin_lock(&port->port_lock); | ||
1714 | port->port_handshake_bits = wValue; | ||
1715 | spin_unlock(&port->port_lock); | ||
1716 | } | ||
1708 | break; | 1717 | break; |
1709 | 1718 | ||
1710 | default: | 1719 | default: |
1720 | /* NOTE: strictly speaking, we should accept AT-commands | ||
1721 | * using SEND_ENCPSULATED_COMMAND/GET_ENCAPSULATED_RESPONSE. | ||
1722 | * But our call management descriptor says we don't handle | ||
1723 | * call management, so we should be able to get by without | ||
1724 | * handling those "required" commands (except by stalling). | ||
1725 | */ | ||
1711 | pr_err("gs_setup: unknown class request, " | 1726 | pr_err("gs_setup: unknown class request, " |
1712 | "type=%02x, request=%02x, value=%04x, " | 1727 | "type=%02x, request=%02x, value=%04x, " |
1713 | "index=%04x, length=%d\n", | 1728 | "index=%04x, length=%d\n", |
@@ -1719,6 +1734,42 @@ static int gs_setup_class(struct usb_gadget *gadget, | |||
1719 | return ret; | 1734 | return ret; |
1720 | } | 1735 | } |
1721 | 1736 | ||
1737 | static void gs_setup_complete_set_line_coding(struct usb_ep *ep, | ||
1738 | struct usb_request *req) | ||
1739 | { | ||
1740 | struct gs_dev *dev = ep->driver_data; | ||
1741 | struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */ | ||
1742 | |||
1743 | switch (req->status) { | ||
1744 | case 0: | ||
1745 | /* normal completion */ | ||
1746 | if (req->actual != sizeof(port->port_line_coding)) | ||
1747 | usb_ep_set_halt(ep); | ||
1748 | else if (port) { | ||
1749 | struct usb_cdc_line_coding *value = req->buf; | ||
1750 | |||
1751 | /* REVISIT: we currently just remember this data. | ||
1752 | * If we change that, (a) validate it first, then | ||
1753 | * (b) update whatever hardware needs updating. | ||
1754 | */ | ||
1755 | spin_lock(&port->port_lock); | ||
1756 | port->port_line_coding = *value; | ||
1757 | spin_unlock(&port->port_lock); | ||
1758 | } | ||
1759 | break; | ||
1760 | |||
1761 | case -ESHUTDOWN: | ||
1762 | /* disconnect */ | ||
1763 | gs_free_req(ep, req); | ||
1764 | break; | ||
1765 | |||
1766 | default: | ||
1767 | /* unexpected */ | ||
1768 | break; | ||
1769 | } | ||
1770 | return; | ||
1771 | } | ||
1772 | |||
1722 | /* | 1773 | /* |
1723 | * gs_setup_complete | 1774 | * gs_setup_complete |
1724 | */ | 1775 | */ |
@@ -1906,6 +1957,11 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1906 | } | 1957 | } |
1907 | } | 1958 | } |
1908 | 1959 | ||
1960 | /* REVISIT the ACM mode should be able to actually *issue* some | ||
1961 | * notifications, for at least serial state change events if | ||
1962 | * not also for network connection; say so in bmCapabilities. | ||
1963 | */ | ||
1964 | |||
1909 | pr_info("gs_set_config: %s configured, %s speed %s config\n", | 1965 | pr_info("gs_set_config: %s configured, %s speed %s config\n", |
1910 | GS_LONG_NAME, | 1966 | GS_LONG_NAME, |
1911 | gadget->speed == USB_SPEED_HIGH ? "high" : "full", | 1967 | gadget->speed == USB_SPEED_HIGH ? "high" : "full", |
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index d3d4f4048e6c..fce4924dbbe8 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -23,9 +23,7 @@ | |||
23 | /* | 23 | /* |
24 | * Gadget Zero only needs two bulk endpoints, and is an example of how you | 24 | * Gadget Zero only needs two bulk endpoints, and is an example of how you |
25 | * can write a hardware-agnostic gadget driver running inside a USB device. | 25 | * can write a hardware-agnostic gadget driver running inside a USB device. |
26 | * | 26 | * Some hardware details are visible, but don't affect most of the driver. |
27 | * Hardware details are visible (see CONFIG_USB_ZERO_* below) but don't | ||
28 | * affect most of the driver. | ||
29 | * | 27 | * |
30 | * Use it with the Linux host/master side "usbtest" driver to get a basic | 28 | * Use it with the Linux host/master side "usbtest" driver to get a basic |
31 | * functional test of your device-side usb stack, or with "usb-skeleton". | 29 | * functional test of your device-side usb stack, or with "usb-skeleton". |
@@ -37,6 +35,7 @@ | |||
37 | * buflen=N default N=4096, buffer size used | 35 | * buflen=N default N=4096, buffer size used |
38 | * qlen=N default N=32, how many buffers in the loopback queue | 36 | * qlen=N default N=32, how many buffers in the loopback queue |
39 | * loopdefault default false, list loopback config first | 37 | * loopdefault default false, list loopback config first |
38 | * autoresume=N default N=0, seconds before triggering remote wakeup | ||
40 | * | 39 | * |
41 | * Many drivers will only have one configuration, letting them be much | 40 | * Many drivers will only have one configuration, letting them be much |
42 | * simpler if they also don't support high speed operation (like this | 41 | * simpler if they also don't support high speed operation (like this |
@@ -62,13 +61,13 @@ | |||
62 | 61 | ||
63 | /*-------------------------------------------------------------------------*/ | 62 | /*-------------------------------------------------------------------------*/ |
64 | 63 | ||
65 | #define DRIVER_VERSION "Lughnasadh, 2007" | 64 | #define DRIVER_VERSION "Earth Day 2008" |
66 | 65 | ||
67 | static const char shortname [] = "zero"; | 66 | static const char shortname[] = "zero"; |
68 | static const char longname [] = "Gadget Zero"; | 67 | static const char longname[] = "Gadget Zero"; |
69 | 68 | ||
70 | static const char source_sink [] = "source and sink data"; | 69 | static const char source_sink[] = "source and sink data"; |
71 | static const char loopback [] = "loop input to output"; | 70 | static const char loopback[] = "loop input to output"; |
72 | 71 | ||
73 | /*-------------------------------------------------------------------------*/ | 72 | /*-------------------------------------------------------------------------*/ |
74 | 73 | ||
@@ -120,16 +119,16 @@ static unsigned buflen = 4096; | |||
120 | static unsigned qlen = 32; | 119 | static unsigned qlen = 32; |
121 | static unsigned pattern = 0; | 120 | static unsigned pattern = 0; |
122 | 121 | ||
123 | module_param (buflen, uint, S_IRUGO); | 122 | module_param(buflen, uint, S_IRUGO); |
124 | module_param (qlen, uint, S_IRUGO); | 123 | module_param(qlen, uint, S_IRUGO); |
125 | module_param (pattern, uint, S_IRUGO|S_IWUSR); | 124 | module_param(pattern, uint, S_IRUGO|S_IWUSR); |
126 | 125 | ||
127 | /* | 126 | /* |
128 | * if it's nonzero, autoresume says how many seconds to wait | 127 | * if it's nonzero, autoresume says how many seconds to wait |
129 | * before trying to wake up the host after suspend. | 128 | * before trying to wake up the host after suspend. |
130 | */ | 129 | */ |
131 | static unsigned autoresume = 0; | 130 | static unsigned autoresume = 0; |
132 | module_param (autoresume, uint, 0); | 131 | module_param(autoresume, uint, 0); |
133 | 132 | ||
134 | /* | 133 | /* |
135 | * Normally the "loopback" configuration is second (index 1) so | 134 | * Normally the "loopback" configuration is second (index 1) so |
@@ -138,8 +137,7 @@ module_param (autoresume, uint, 0); | |||
138 | * Or controllers (like superh) that only support one config. | 137 | * Or controllers (like superh) that only support one config. |
139 | */ | 138 | */ |
140 | static int loopdefault = 0; | 139 | static int loopdefault = 0; |
141 | 140 | module_param(loopdefault, bool, S_IRUGO|S_IWUSR); | |
142 | module_param (loopdefault, bool, S_IRUGO|S_IWUSR); | ||
143 | 141 | ||
144 | /*-------------------------------------------------------------------------*/ | 142 | /*-------------------------------------------------------------------------*/ |
145 | 143 | ||
@@ -176,24 +174,22 @@ module_param (loopdefault, bool, S_IRUGO|S_IWUSR); | |||
176 | #define CONFIG_SOURCE_SINK 3 | 174 | #define CONFIG_SOURCE_SINK 3 |
177 | #define CONFIG_LOOPBACK 2 | 175 | #define CONFIG_LOOPBACK 2 |
178 | 176 | ||
179 | static struct usb_device_descriptor | 177 | static struct usb_device_descriptor device_desc = { |
180 | device_desc = { | ||
181 | .bLength = sizeof device_desc, | 178 | .bLength = sizeof device_desc, |
182 | .bDescriptorType = USB_DT_DEVICE, | 179 | .bDescriptorType = USB_DT_DEVICE, |
183 | 180 | ||
184 | .bcdUSB = __constant_cpu_to_le16 (0x0200), | 181 | .bcdUSB = __constant_cpu_to_le16(0x0200), |
185 | .bDeviceClass = USB_CLASS_VENDOR_SPEC, | 182 | .bDeviceClass = USB_CLASS_VENDOR_SPEC, |
186 | 183 | ||
187 | .idVendor = __constant_cpu_to_le16 (DRIVER_VENDOR_NUM), | 184 | .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_NUM), |
188 | .idProduct = __constant_cpu_to_le16 (DRIVER_PRODUCT_NUM), | 185 | .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_NUM), |
189 | .iManufacturer = STRING_MANUFACTURER, | 186 | .iManufacturer = STRING_MANUFACTURER, |
190 | .iProduct = STRING_PRODUCT, | 187 | .iProduct = STRING_PRODUCT, |
191 | .iSerialNumber = STRING_SERIAL, | 188 | .iSerialNumber = STRING_SERIAL, |
192 | .bNumConfigurations = 2, | 189 | .bNumConfigurations = 2, |
193 | }; | 190 | }; |
194 | 191 | ||
195 | static struct usb_config_descriptor | 192 | static struct usb_config_descriptor source_sink_config = { |
196 | source_sink_config = { | ||
197 | .bLength = sizeof source_sink_config, | 193 | .bLength = sizeof source_sink_config, |
198 | .bDescriptorType = USB_DT_CONFIG, | 194 | .bDescriptorType = USB_DT_CONFIG, |
199 | 195 | ||
@@ -205,8 +201,7 @@ source_sink_config = { | |||
205 | .bMaxPower = 1, /* self-powered */ | 201 | .bMaxPower = 1, /* self-powered */ |
206 | }; | 202 | }; |
207 | 203 | ||
208 | static struct usb_config_descriptor | 204 | static struct usb_config_descriptor loopback_config = { |
209 | loopback_config = { | ||
210 | .bLength = sizeof loopback_config, | 205 | .bLength = sizeof loopback_config, |
211 | .bDescriptorType = USB_DT_CONFIG, | 206 | .bDescriptorType = USB_DT_CONFIG, |
212 | 207 | ||
@@ -218,8 +213,7 @@ loopback_config = { | |||
218 | .bMaxPower = 1, /* self-powered */ | 213 | .bMaxPower = 1, /* self-powered */ |
219 | }; | 214 | }; |
220 | 215 | ||
221 | static struct usb_otg_descriptor | 216 | static struct usb_otg_descriptor otg_descriptor = { |
222 | otg_descriptor = { | ||
223 | .bLength = sizeof otg_descriptor, | 217 | .bLength = sizeof otg_descriptor, |
224 | .bDescriptorType = USB_DT_OTG, | 218 | .bDescriptorType = USB_DT_OTG, |
225 | 219 | ||
@@ -228,8 +222,7 @@ otg_descriptor = { | |||
228 | 222 | ||
229 | /* one interface in each configuration */ | 223 | /* one interface in each configuration */ |
230 | 224 | ||
231 | static const struct usb_interface_descriptor | 225 | static const struct usb_interface_descriptor source_sink_intf = { |
232 | source_sink_intf = { | ||
233 | .bLength = sizeof source_sink_intf, | 226 | .bLength = sizeof source_sink_intf, |
234 | .bDescriptorType = USB_DT_INTERFACE, | 227 | .bDescriptorType = USB_DT_INTERFACE, |
235 | 228 | ||
@@ -238,8 +231,7 @@ source_sink_intf = { | |||
238 | .iInterface = STRING_SOURCE_SINK, | 231 | .iInterface = STRING_SOURCE_SINK, |
239 | }; | 232 | }; |
240 | 233 | ||
241 | static const struct usb_interface_descriptor | 234 | static const struct usb_interface_descriptor loopback_intf = { |
242 | loopback_intf = { | ||
243 | .bLength = sizeof loopback_intf, | 235 | .bLength = sizeof loopback_intf, |
244 | .bDescriptorType = USB_DT_INTERFACE, | 236 | .bDescriptorType = USB_DT_INTERFACE, |
245 | 237 | ||
@@ -250,8 +242,7 @@ loopback_intf = { | |||
250 | 242 | ||
251 | /* two full speed bulk endpoints; their use is config-dependent */ | 243 | /* two full speed bulk endpoints; their use is config-dependent */ |
252 | 244 | ||
253 | static struct usb_endpoint_descriptor | 245 | static struct usb_endpoint_descriptor fs_source_desc = { |
254 | fs_source_desc = { | ||
255 | .bLength = USB_DT_ENDPOINT_SIZE, | 246 | .bLength = USB_DT_ENDPOINT_SIZE, |
256 | .bDescriptorType = USB_DT_ENDPOINT, | 247 | .bDescriptorType = USB_DT_ENDPOINT, |
257 | 248 | ||
@@ -259,8 +250,7 @@ fs_source_desc = { | |||
259 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 250 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
260 | }; | 251 | }; |
261 | 252 | ||
262 | static struct usb_endpoint_descriptor | 253 | static struct usb_endpoint_descriptor fs_sink_desc = { |
263 | fs_sink_desc = { | ||
264 | .bLength = USB_DT_ENDPOINT_SIZE, | 254 | .bLength = USB_DT_ENDPOINT_SIZE, |
265 | .bDescriptorType = USB_DT_ENDPOINT, | 255 | .bDescriptorType = USB_DT_ENDPOINT, |
266 | 256 | ||
@@ -268,7 +258,7 @@ fs_sink_desc = { | |||
268 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 258 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
269 | }; | 259 | }; |
270 | 260 | ||
271 | static const struct usb_descriptor_header *fs_source_sink_function [] = { | 261 | static const struct usb_descriptor_header *fs_source_sink_function[] = { |
272 | (struct usb_descriptor_header *) &otg_descriptor, | 262 | (struct usb_descriptor_header *) &otg_descriptor, |
273 | (struct usb_descriptor_header *) &source_sink_intf, | 263 | (struct usb_descriptor_header *) &source_sink_intf, |
274 | (struct usb_descriptor_header *) &fs_sink_desc, | 264 | (struct usb_descriptor_header *) &fs_sink_desc, |
@@ -276,7 +266,7 @@ static const struct usb_descriptor_header *fs_source_sink_function [] = { | |||
276 | NULL, | 266 | NULL, |
277 | }; | 267 | }; |
278 | 268 | ||
279 | static const struct usb_descriptor_header *fs_loopback_function [] = { | 269 | static const struct usb_descriptor_header *fs_loopback_function[] = { |
280 | (struct usb_descriptor_header *) &otg_descriptor, | 270 | (struct usb_descriptor_header *) &otg_descriptor, |
281 | (struct usb_descriptor_header *) &loopback_intf, | 271 | (struct usb_descriptor_header *) &loopback_intf, |
282 | (struct usb_descriptor_header *) &fs_sink_desc, | 272 | (struct usb_descriptor_header *) &fs_sink_desc, |
@@ -293,36 +283,33 @@ static const struct usb_descriptor_header *fs_loopback_function [] = { | |||
293 | * for the config descriptor. | 283 | * for the config descriptor. |
294 | */ | 284 | */ |
295 | 285 | ||
296 | static struct usb_endpoint_descriptor | 286 | static struct usb_endpoint_descriptor hs_source_desc = { |
297 | hs_source_desc = { | ||
298 | .bLength = USB_DT_ENDPOINT_SIZE, | 287 | .bLength = USB_DT_ENDPOINT_SIZE, |
299 | .bDescriptorType = USB_DT_ENDPOINT, | 288 | .bDescriptorType = USB_DT_ENDPOINT, |
300 | 289 | ||
301 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 290 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
302 | .wMaxPacketSize = __constant_cpu_to_le16 (512), | 291 | .wMaxPacketSize = __constant_cpu_to_le16(512), |
303 | }; | 292 | }; |
304 | 293 | ||
305 | static struct usb_endpoint_descriptor | 294 | static struct usb_endpoint_descriptor hs_sink_desc = { |
306 | hs_sink_desc = { | ||
307 | .bLength = USB_DT_ENDPOINT_SIZE, | 295 | .bLength = USB_DT_ENDPOINT_SIZE, |
308 | .bDescriptorType = USB_DT_ENDPOINT, | 296 | .bDescriptorType = USB_DT_ENDPOINT, |
309 | 297 | ||
310 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 298 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
311 | .wMaxPacketSize = __constant_cpu_to_le16 (512), | 299 | .wMaxPacketSize = __constant_cpu_to_le16(512), |
312 | }; | 300 | }; |
313 | 301 | ||
314 | static struct usb_qualifier_descriptor | 302 | static struct usb_qualifier_descriptor dev_qualifier = { |
315 | dev_qualifier = { | ||
316 | .bLength = sizeof dev_qualifier, | 303 | .bLength = sizeof dev_qualifier, |
317 | .bDescriptorType = USB_DT_DEVICE_QUALIFIER, | 304 | .bDescriptorType = USB_DT_DEVICE_QUALIFIER, |
318 | 305 | ||
319 | .bcdUSB = __constant_cpu_to_le16 (0x0200), | 306 | .bcdUSB = __constant_cpu_to_le16(0x0200), |
320 | .bDeviceClass = USB_CLASS_VENDOR_SPEC, | 307 | .bDeviceClass = USB_CLASS_VENDOR_SPEC, |
321 | 308 | ||
322 | .bNumConfigurations = 2, | 309 | .bNumConfigurations = 2, |
323 | }; | 310 | }; |
324 | 311 | ||
325 | static const struct usb_descriptor_header *hs_source_sink_function [] = { | 312 | static const struct usb_descriptor_header *hs_source_sink_function[] = { |
326 | (struct usb_descriptor_header *) &otg_descriptor, | 313 | (struct usb_descriptor_header *) &otg_descriptor, |
327 | (struct usb_descriptor_header *) &source_sink_intf, | 314 | (struct usb_descriptor_header *) &source_sink_intf, |
328 | (struct usb_descriptor_header *) &hs_source_desc, | 315 | (struct usb_descriptor_header *) &hs_source_desc, |
@@ -330,7 +317,7 @@ static const struct usb_descriptor_header *hs_source_sink_function [] = { | |||
330 | NULL, | 317 | NULL, |
331 | }; | 318 | }; |
332 | 319 | ||
333 | static const struct usb_descriptor_header *hs_loopback_function [] = { | 320 | static const struct usb_descriptor_header *hs_loopback_function[] = { |
334 | (struct usb_descriptor_header *) &otg_descriptor, | 321 | (struct usb_descriptor_header *) &otg_descriptor, |
335 | (struct usb_descriptor_header *) &loopback_intf, | 322 | (struct usb_descriptor_header *) &loopback_intf, |
336 | (struct usb_descriptor_header *) &hs_source_desc, | 323 | (struct usb_descriptor_header *) &hs_source_desc, |
@@ -355,7 +342,7 @@ static char serial[] = "0123456789.0123456789.0123456789"; | |||
355 | 342 | ||
356 | 343 | ||
357 | /* static strings, in UTF-8 */ | 344 | /* static strings, in UTF-8 */ |
358 | static struct usb_string strings [] = { | 345 | static struct usb_string strings[] = { |
359 | { STRING_MANUFACTURER, manufacturer, }, | 346 | { STRING_MANUFACTURER, manufacturer, }, |
360 | { STRING_PRODUCT, longname, }, | 347 | { STRING_PRODUCT, longname, }, |
361 | { STRING_SERIAL, serial, }, | 348 | { STRING_SERIAL, serial, }, |
@@ -364,7 +351,7 @@ static struct usb_string strings [] = { | |||
364 | { } /* end of list */ | 351 | { } /* end of list */ |
365 | }; | 352 | }; |
366 | 353 | ||
367 | static struct usb_gadget_strings stringtab = { | 354 | static struct usb_gadget_strings stringtab = { |
368 | .language = 0x0409, /* en-us */ | 355 | .language = 0x0409, /* en-us */ |
369 | .strings = strings, | 356 | .strings = strings, |
370 | }; | 357 | }; |
@@ -387,8 +374,7 @@ static struct usb_gadget_strings stringtab = { | |||
387 | * high bandwidth modes at high speed. (Maybe work like Intel's test | 374 | * high bandwidth modes at high speed. (Maybe work like Intel's test |
388 | * device?) | 375 | * device?) |
389 | */ | 376 | */ |
390 | static int | 377 | static int config_buf(struct usb_gadget *gadget, |
391 | config_buf (struct usb_gadget *gadget, | ||
392 | u8 *buf, u8 type, unsigned index) | 378 | u8 *buf, u8 type, unsigned index) |
393 | { | 379 | { |
394 | int is_source_sink; | 380 | int is_source_sink; |
@@ -419,7 +405,7 @@ config_buf (struct usb_gadget *gadget, | |||
419 | if (!gadget_is_otg(gadget)) | 405 | if (!gadget_is_otg(gadget)) |
420 | function++; | 406 | function++; |
421 | 407 | ||
422 | len = usb_gadget_config_buf (is_source_sink | 408 | len = usb_gadget_config_buf(is_source_sink |
423 | ? &source_sink_config | 409 | ? &source_sink_config |
424 | : &loopback_config, | 410 | : &loopback_config, |
425 | buf, USB_BUFSIZ, function); | 411 | buf, USB_BUFSIZ, function); |
@@ -431,27 +417,26 @@ config_buf (struct usb_gadget *gadget, | |||
431 | 417 | ||
432 | /*-------------------------------------------------------------------------*/ | 418 | /*-------------------------------------------------------------------------*/ |
433 | 419 | ||
434 | static struct usb_request * | 420 | static struct usb_request *alloc_ep_req(struct usb_ep *ep, unsigned length) |
435 | alloc_ep_req (struct usb_ep *ep, unsigned length) | ||
436 | { | 421 | { |
437 | struct usb_request *req; | 422 | struct usb_request *req; |
438 | 423 | ||
439 | req = usb_ep_alloc_request (ep, GFP_ATOMIC); | 424 | req = usb_ep_alloc_request(ep, GFP_ATOMIC); |
440 | if (req) { | 425 | if (req) { |
441 | req->length = length; | 426 | req->length = length; |
442 | req->buf = kmalloc(length, GFP_ATOMIC); | 427 | req->buf = kmalloc(length, GFP_ATOMIC); |
443 | if (!req->buf) { | 428 | if (!req->buf) { |
444 | usb_ep_free_request (ep, req); | 429 | usb_ep_free_request(ep, req); |
445 | req = NULL; | 430 | req = NULL; |
446 | } | 431 | } |
447 | } | 432 | } |
448 | return req; | 433 | return req; |
449 | } | 434 | } |
450 | 435 | ||
451 | static void free_ep_req (struct usb_ep *ep, struct usb_request *req) | 436 | static void free_ep_req(struct usb_ep *ep, struct usb_request *req) |
452 | { | 437 | { |
453 | kfree(req->buf); | 438 | kfree(req->buf); |
454 | usb_ep_free_request (ep, req); | 439 | usb_ep_free_request(ep, req); |
455 | } | 440 | } |
456 | 441 | ||
457 | /*-------------------------------------------------------------------------*/ | 442 | /*-------------------------------------------------------------------------*/ |
@@ -472,7 +457,7 @@ static void free_ep_req (struct usb_ep *ep, struct usb_request *req) | |||
472 | /* optionally require specific source/sink data patterns */ | 457 | /* optionally require specific source/sink data patterns */ |
473 | 458 | ||
474 | static int | 459 | static int |
475 | check_read_data ( | 460 | check_read_data( |
476 | struct zero_dev *dev, | 461 | struct zero_dev *dev, |
477 | struct usb_ep *ep, | 462 | struct usb_ep *ep, |
478 | struct usb_request *req | 463 | struct usb_request *req |
@@ -498,8 +483,8 @@ check_read_data ( | |||
498 | continue; | 483 | continue; |
499 | break; | 484 | break; |
500 | } | 485 | } |
501 | ERROR (dev, "bad OUT byte, buf [%d] = %d\n", i, *buf); | 486 | ERROR(dev, "bad OUT byte, buf[%d] = %d\n", i, *buf); |
502 | usb_ep_set_halt (ep); | 487 | usb_ep_set_halt(ep); |
503 | return -EINVAL; | 488 | return -EINVAL; |
504 | } | 489 | } |
505 | return 0; | 490 | return 0; |
@@ -512,7 +497,7 @@ static void reinit_write_data(struct usb_ep *ep, struct usb_request *req) | |||
512 | 497 | ||
513 | switch (pattern) { | 498 | switch (pattern) { |
514 | case 0: | 499 | case 0: |
515 | memset (req->buf, 0, req->length); | 500 | memset(req->buf, 0, req->length); |
516 | break; | 501 | break; |
517 | case 1: | 502 | case 1: |
518 | for (i = 0; i < req->length; i++) | 503 | for (i = 0; i < req->length; i++) |
@@ -525,7 +510,7 @@ static void reinit_write_data(struct usb_ep *ep, struct usb_request *req) | |||
525 | * irq delay between end of one request and start of the next. | 510 | * irq delay between end of one request and start of the next. |
526 | * that prevents using hardware dma queues. | 511 | * that prevents using hardware dma queues. |
527 | */ | 512 | */ |
528 | static void source_sink_complete (struct usb_ep *ep, struct usb_request *req) | 513 | static void source_sink_complete(struct usb_ep *ep, struct usb_request *req) |
529 | { | 514 | { |
530 | struct zero_dev *dev = ep->driver_data; | 515 | struct zero_dev *dev = ep->driver_data; |
531 | int status = req->status; | 516 | int status = req->status; |
@@ -534,8 +519,8 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req) | |||
534 | 519 | ||
535 | case 0: /* normal completion? */ | 520 | case 0: /* normal completion? */ |
536 | if (ep == dev->out_ep) { | 521 | if (ep == dev->out_ep) { |
537 | check_read_data (dev, ep, req); | 522 | check_read_data(dev, ep, req); |
538 | memset (req->buf, 0x55, req->length); | 523 | memset(req->buf, 0x55, req->length); |
539 | } else | 524 | } else |
540 | reinit_write_data(ep, req); | 525 | reinit_write_data(ep, req); |
541 | break; | 526 | break; |
@@ -544,11 +529,11 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req) | |||
544 | case -ECONNABORTED: /* hardware forced ep reset */ | 529 | case -ECONNABORTED: /* hardware forced ep reset */ |
545 | case -ECONNRESET: /* request dequeued */ | 530 | case -ECONNRESET: /* request dequeued */ |
546 | case -ESHUTDOWN: /* disconnect from host */ | 531 | case -ESHUTDOWN: /* disconnect from host */ |
547 | VDBG (dev, "%s gone (%d), %d/%d\n", ep->name, status, | 532 | VDBG(dev, "%s gone (%d), %d/%d\n", ep->name, status, |
548 | req->actual, req->length); | 533 | req->actual, req->length); |
549 | if (ep == dev->out_ep) | 534 | if (ep == dev->out_ep) |
550 | check_read_data (dev, ep, req); | 535 | check_read_data(dev, ep, req); |
551 | free_ep_req (ep, req); | 536 | free_ep_req(ep, req); |
552 | return; | 537 | return; |
553 | 538 | ||
554 | case -EOVERFLOW: /* buffer overrun on read means that | 539 | case -EOVERFLOW: /* buffer overrun on read means that |
@@ -557,18 +542,18 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req) | |||
557 | */ | 542 | */ |
558 | default: | 543 | default: |
559 | #if 1 | 544 | #if 1 |
560 | DBG (dev, "%s complete --> %d, %d/%d\n", ep->name, | 545 | DBG(dev, "%s complete --> %d, %d/%d\n", ep->name, |
561 | status, req->actual, req->length); | 546 | status, req->actual, req->length); |
562 | #endif | 547 | #endif |
563 | case -EREMOTEIO: /* short read */ | 548 | case -EREMOTEIO: /* short read */ |
564 | break; | 549 | break; |
565 | } | 550 | } |
566 | 551 | ||
567 | status = usb_ep_queue (ep, req, GFP_ATOMIC); | 552 | status = usb_ep_queue(ep, req, GFP_ATOMIC); |
568 | if (status) { | 553 | if (status) { |
569 | ERROR (dev, "kill %s: resubmit %d bytes --> %d\n", | 554 | ERROR(dev, "kill %s: resubmit %d bytes --> %d\n", |
570 | ep->name, req->length, status); | 555 | ep->name, req->length, status); |
571 | usb_ep_set_halt (ep); | 556 | usb_ep_set_halt(ep); |
572 | /* FIXME recover later ... somehow */ | 557 | /* FIXME recover later ... somehow */ |
573 | } | 558 | } |
574 | } | 559 | } |
@@ -578,24 +563,24 @@ static struct usb_request *source_sink_start_ep(struct usb_ep *ep) | |||
578 | struct usb_request *req; | 563 | struct usb_request *req; |
579 | int status; | 564 | int status; |
580 | 565 | ||
581 | req = alloc_ep_req (ep, buflen); | 566 | req = alloc_ep_req(ep, buflen); |
582 | if (!req) | 567 | if (!req) |
583 | return NULL; | 568 | return NULL; |
584 | 569 | ||
585 | memset (req->buf, 0, req->length); | 570 | memset(req->buf, 0, req->length); |
586 | req->complete = source_sink_complete; | 571 | req->complete = source_sink_complete; |
587 | 572 | ||
588 | if (strcmp (ep->name, EP_IN_NAME) == 0) | 573 | if (strcmp(ep->name, EP_IN_NAME) == 0) |
589 | reinit_write_data(ep, req); | 574 | reinit_write_data(ep, req); |
590 | else | 575 | else |
591 | memset (req->buf, 0x55, req->length); | 576 | memset(req->buf, 0x55, req->length); |
592 | 577 | ||
593 | status = usb_ep_queue(ep, req, GFP_ATOMIC); | 578 | status = usb_ep_queue(ep, req, GFP_ATOMIC); |
594 | if (status) { | 579 | if (status) { |
595 | struct zero_dev *dev = ep->driver_data; | 580 | struct zero_dev *dev = ep->driver_data; |
596 | 581 | ||
597 | ERROR (dev, "start %s --> %d\n", ep->name, status); | 582 | ERROR(dev, "start %s --> %d\n", ep->name, status); |
598 | free_ep_req (ep, req); | 583 | free_ep_req(ep, req); |
599 | req = NULL; | 584 | req = NULL; |
600 | } | 585 | } |
601 | 586 | ||
@@ -608,34 +593,34 @@ static int set_source_sink_config(struct zero_dev *dev) | |||
608 | struct usb_ep *ep; | 593 | struct usb_ep *ep; |
609 | struct usb_gadget *gadget = dev->gadget; | 594 | struct usb_gadget *gadget = dev->gadget; |
610 | 595 | ||
611 | gadget_for_each_ep (ep, gadget) { | 596 | gadget_for_each_ep(ep, gadget) { |
612 | const struct usb_endpoint_descriptor *d; | 597 | const struct usb_endpoint_descriptor *d; |
613 | 598 | ||
614 | /* one endpoint writes (sources) zeroes in (to the host) */ | 599 | /* one endpoint writes (sources) zeroes in (to the host) */ |
615 | if (strcmp (ep->name, EP_IN_NAME) == 0) { | 600 | if (strcmp(ep->name, EP_IN_NAME) == 0) { |
616 | d = ep_desc (gadget, &hs_source_desc, &fs_source_desc); | 601 | d = ep_desc(gadget, &hs_source_desc, &fs_source_desc); |
617 | result = usb_ep_enable (ep, d); | 602 | result = usb_ep_enable(ep, d); |
618 | if (result == 0) { | 603 | if (result == 0) { |
619 | ep->driver_data = dev; | 604 | ep->driver_data = dev; |
620 | if (source_sink_start_ep(ep) != NULL) { | 605 | if (source_sink_start_ep(ep) != NULL) { |
621 | dev->in_ep = ep; | 606 | dev->in_ep = ep; |
622 | continue; | 607 | continue; |
623 | } | 608 | } |
624 | usb_ep_disable (ep); | 609 | usb_ep_disable(ep); |
625 | result = -EIO; | 610 | result = -EIO; |
626 | } | 611 | } |
627 | 612 | ||
628 | /* one endpoint reads (sinks) anything out (from the host) */ | 613 | /* one endpoint reads (sinks) anything out (from the host) */ |
629 | } else if (strcmp (ep->name, EP_OUT_NAME) == 0) { | 614 | } else if (strcmp(ep->name, EP_OUT_NAME) == 0) { |
630 | d = ep_desc (gadget, &hs_sink_desc, &fs_sink_desc); | 615 | d = ep_desc(gadget, &hs_sink_desc, &fs_sink_desc); |
631 | result = usb_ep_enable (ep, d); | 616 | result = usb_ep_enable(ep, d); |
632 | if (result == 0) { | 617 | if (result == 0) { |
633 | ep->driver_data = dev; | 618 | ep->driver_data = dev; |
634 | if (source_sink_start_ep(ep) != NULL) { | 619 | if (source_sink_start_ep(ep) != NULL) { |
635 | dev->out_ep = ep; | 620 | dev->out_ep = ep; |
636 | continue; | 621 | continue; |
637 | } | 622 | } |
638 | usb_ep_disable (ep); | 623 | usb_ep_disable(ep); |
639 | result = -EIO; | 624 | result = -EIO; |
640 | } | 625 | } |
641 | 626 | ||
@@ -644,11 +629,11 @@ static int set_source_sink_config(struct zero_dev *dev) | |||
644 | continue; | 629 | continue; |
645 | 630 | ||
646 | /* stop on error */ | 631 | /* stop on error */ |
647 | ERROR (dev, "can't start %s, result %d\n", ep->name, result); | 632 | ERROR(dev, "can't start %s, result %d\n", ep->name, result); |
648 | break; | 633 | break; |
649 | } | 634 | } |
650 | if (result == 0) | 635 | if (result == 0) |
651 | DBG (dev, "buflen %d\n", buflen); | 636 | DBG(dev, "buflen %d\n", buflen); |
652 | 637 | ||
653 | /* caller is responsible for cleanup on error */ | 638 | /* caller is responsible for cleanup on error */ |
654 | return result; | 639 | return result; |
@@ -656,7 +641,7 @@ static int set_source_sink_config(struct zero_dev *dev) | |||
656 | 641 | ||
657 | /*-------------------------------------------------------------------------*/ | 642 | /*-------------------------------------------------------------------------*/ |
658 | 643 | ||
659 | static void loopback_complete (struct usb_ep *ep, struct usb_request *req) | 644 | static void loopback_complete(struct usb_ep *ep, struct usb_request *req) |
660 | { | 645 | { |
661 | struct zero_dev *dev = ep->driver_data; | 646 | struct zero_dev *dev = ep->driver_data; |
662 | int status = req->status; | 647 | int status = req->status; |
@@ -668,19 +653,19 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req) | |||
668 | /* loop this OUT packet back IN to the host */ | 653 | /* loop this OUT packet back IN to the host */ |
669 | req->zero = (req->actual < req->length); | 654 | req->zero = (req->actual < req->length); |
670 | req->length = req->actual; | 655 | req->length = req->actual; |
671 | status = usb_ep_queue (dev->in_ep, req, GFP_ATOMIC); | 656 | status = usb_ep_queue(dev->in_ep, req, GFP_ATOMIC); |
672 | if (status == 0) | 657 | if (status == 0) |
673 | return; | 658 | return; |
674 | 659 | ||
675 | /* "should never get here" */ | 660 | /* "should never get here" */ |
676 | ERROR (dev, "can't loop %s to %s: %d\n", | 661 | ERROR(dev, "can't loop %s to %s: %d\n", |
677 | ep->name, dev->in_ep->name, | 662 | ep->name, dev->in_ep->name, |
678 | status); | 663 | status); |
679 | } | 664 | } |
680 | 665 | ||
681 | /* queue the buffer for some later OUT packet */ | 666 | /* queue the buffer for some later OUT packet */ |
682 | req->length = buflen; | 667 | req->length = buflen; |
683 | status = usb_ep_queue (dev->out_ep, req, GFP_ATOMIC); | 668 | status = usb_ep_queue(dev->out_ep, req, GFP_ATOMIC); |
684 | if (status == 0) | 669 | if (status == 0) |
685 | return; | 670 | return; |
686 | 671 | ||
@@ -688,7 +673,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req) | |||
688 | /* FALLTHROUGH */ | 673 | /* FALLTHROUGH */ |
689 | 674 | ||
690 | default: | 675 | default: |
691 | ERROR (dev, "%s loop complete --> %d, %d/%d\n", ep->name, | 676 | ERROR(dev, "%s loop complete --> %d, %d/%d\n", ep->name, |
692 | status, req->actual, req->length); | 677 | status, req->actual, req->length); |
693 | /* FALLTHROUGH */ | 678 | /* FALLTHROUGH */ |
694 | 679 | ||
@@ -700,7 +685,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req) | |||
700 | case -ECONNABORTED: /* hardware forced ep reset */ | 685 | case -ECONNABORTED: /* hardware forced ep reset */ |
701 | case -ECONNRESET: /* request dequeued */ | 686 | case -ECONNRESET: /* request dequeued */ |
702 | case -ESHUTDOWN: /* disconnect from host */ | 687 | case -ESHUTDOWN: /* disconnect from host */ |
703 | free_ep_req (ep, req); | 688 | free_ep_req(ep, req); |
704 | return; | 689 | return; |
705 | } | 690 | } |
706 | } | 691 | } |
@@ -711,13 +696,13 @@ static int set_loopback_config(struct zero_dev *dev) | |||
711 | struct usb_ep *ep; | 696 | struct usb_ep *ep; |
712 | struct usb_gadget *gadget = dev->gadget; | 697 | struct usb_gadget *gadget = dev->gadget; |
713 | 698 | ||
714 | gadget_for_each_ep (ep, gadget) { | 699 | gadget_for_each_ep(ep, gadget) { |
715 | const struct usb_endpoint_descriptor *d; | 700 | const struct usb_endpoint_descriptor *d; |
716 | 701 | ||
717 | /* one endpoint writes data back IN to the host */ | 702 | /* one endpoint writes data back IN to the host */ |
718 | if (strcmp (ep->name, EP_IN_NAME) == 0) { | 703 | if (strcmp(ep->name, EP_IN_NAME) == 0) { |
719 | d = ep_desc (gadget, &hs_source_desc, &fs_source_desc); | 704 | d = ep_desc(gadget, &hs_source_desc, &fs_source_desc); |
720 | result = usb_ep_enable (ep, d); | 705 | result = usb_ep_enable(ep, d); |
721 | if (result == 0) { | 706 | if (result == 0) { |
722 | ep->driver_data = dev; | 707 | ep->driver_data = dev; |
723 | dev->in_ep = ep; | 708 | dev->in_ep = ep; |
@@ -725,9 +710,9 @@ static int set_loopback_config(struct zero_dev *dev) | |||
725 | } | 710 | } |
726 | 711 | ||
727 | /* one endpoint just reads OUT packets */ | 712 | /* one endpoint just reads OUT packets */ |
728 | } else if (strcmp (ep->name, EP_OUT_NAME) == 0) { | 713 | } else if (strcmp(ep->name, EP_OUT_NAME) == 0) { |
729 | d = ep_desc (gadget, &hs_sink_desc, &fs_sink_desc); | 714 | d = ep_desc(gadget, &hs_sink_desc, &fs_sink_desc); |
730 | result = usb_ep_enable (ep, d); | 715 | result = usb_ep_enable(ep, d); |
731 | if (result == 0) { | 716 | if (result == 0) { |
732 | ep->driver_data = dev; | 717 | ep->driver_data = dev; |
733 | dev->out_ep = ep; | 718 | dev->out_ep = ep; |
@@ -739,7 +724,7 @@ static int set_loopback_config(struct zero_dev *dev) | |||
739 | continue; | 724 | continue; |
740 | 725 | ||
741 | /* stop on error */ | 726 | /* stop on error */ |
742 | ERROR (dev, "can't enable %s, result %d\n", ep->name, result); | 727 | ERROR(dev, "can't enable %s, result %d\n", ep->name, result); |
743 | break; | 728 | break; |
744 | } | 729 | } |
745 | 730 | ||
@@ -753,19 +738,19 @@ static int set_loopback_config(struct zero_dev *dev) | |||
753 | 738 | ||
754 | ep = dev->out_ep; | 739 | ep = dev->out_ep; |
755 | for (i = 0; i < qlen && result == 0; i++) { | 740 | for (i = 0; i < qlen && result == 0; i++) { |
756 | req = alloc_ep_req (ep, buflen); | 741 | req = alloc_ep_req(ep, buflen); |
757 | if (req) { | 742 | if (req) { |
758 | req->complete = loopback_complete; | 743 | req->complete = loopback_complete; |
759 | result = usb_ep_queue (ep, req, GFP_ATOMIC); | 744 | result = usb_ep_queue(ep, req, GFP_ATOMIC); |
760 | if (result) | 745 | if (result) |
761 | DBG (dev, "%s queue req --> %d\n", | 746 | DBG(dev, "%s queue req --> %d\n", |
762 | ep->name, result); | 747 | ep->name, result); |
763 | } else | 748 | } else |
764 | result = -ENOMEM; | 749 | result = -ENOMEM; |
765 | } | 750 | } |
766 | } | 751 | } |
767 | if (result == 0) | 752 | if (result == 0) |
768 | DBG (dev, "qlen %d, buflen %d\n", qlen, buflen); | 753 | DBG(dev, "qlen %d, buflen %d\n", qlen, buflen); |
769 | 754 | ||
770 | /* caller is responsible for cleanup on error */ | 755 | /* caller is responsible for cleanup on error */ |
771 | return result; | 756 | return result; |
@@ -773,26 +758,26 @@ static int set_loopback_config(struct zero_dev *dev) | |||
773 | 758 | ||
774 | /*-------------------------------------------------------------------------*/ | 759 | /*-------------------------------------------------------------------------*/ |
775 | 760 | ||
776 | static void zero_reset_config (struct zero_dev *dev) | 761 | static void zero_reset_config(struct zero_dev *dev) |
777 | { | 762 | { |
778 | if (dev->config == 0) | 763 | if (dev->config == 0) |
779 | return; | 764 | return; |
780 | 765 | ||
781 | DBG (dev, "reset config\n"); | 766 | DBG(dev, "reset config\n"); |
782 | 767 | ||
783 | /* just disable endpoints, forcing completion of pending i/o. | 768 | /* just disable endpoints, forcing completion of pending i/o. |
784 | * all our completion handlers free their requests in this case. | 769 | * all our completion handlers free their requests in this case. |
785 | */ | 770 | */ |
786 | if (dev->in_ep) { | 771 | if (dev->in_ep) { |
787 | usb_ep_disable (dev->in_ep); | 772 | usb_ep_disable(dev->in_ep); |
788 | dev->in_ep = NULL; | 773 | dev->in_ep = NULL; |
789 | } | 774 | } |
790 | if (dev->out_ep) { | 775 | if (dev->out_ep) { |
791 | usb_ep_disable (dev->out_ep); | 776 | usb_ep_disable(dev->out_ep); |
792 | dev->out_ep = NULL; | 777 | dev->out_ep = NULL; |
793 | } | 778 | } |
794 | dev->config = 0; | 779 | dev->config = 0; |
795 | del_timer (&dev->resume); | 780 | del_timer(&dev->resume); |
796 | } | 781 | } |
797 | 782 | ||
798 | /* change our operational config. this code must agree with the code | 783 | /* change our operational config. this code must agree with the code |
@@ -813,12 +798,12 @@ static int zero_set_config(struct zero_dev *dev, unsigned number) | |||
813 | if (number == dev->config) | 798 | if (number == dev->config) |
814 | return 0; | 799 | return 0; |
815 | 800 | ||
816 | if (gadget_is_sa1100 (gadget) && dev->config) { | 801 | if (gadget_is_sa1100(gadget) && dev->config) { |
817 | /* tx fifo is full, but we can't clear it...*/ | 802 | /* tx fifo is full, but we can't clear it...*/ |
818 | ERROR(dev, "can't change configurations\n"); | 803 | ERROR(dev, "can't change configurations\n"); |
819 | return -ESPIPE; | 804 | return -ESPIPE; |
820 | } | 805 | } |
821 | zero_reset_config (dev); | 806 | zero_reset_config(dev); |
822 | 807 | ||
823 | switch (number) { | 808 | switch (number) { |
824 | case CONFIG_SOURCE_SINK: | 809 | case CONFIG_SOURCE_SINK: |
@@ -837,7 +822,7 @@ static int zero_set_config(struct zero_dev *dev, unsigned number) | |||
837 | if (!result && (!dev->in_ep || !dev->out_ep)) | 822 | if (!result && (!dev->in_ep || !dev->out_ep)) |
838 | result = -ENODEV; | 823 | result = -ENODEV; |
839 | if (result) | 824 | if (result) |
840 | zero_reset_config (dev); | 825 | zero_reset_config(dev); |
841 | else { | 826 | else { |
842 | char *speed; | 827 | char *speed; |
843 | 828 | ||
@@ -849,7 +834,7 @@ static int zero_set_config(struct zero_dev *dev, unsigned number) | |||
849 | } | 834 | } |
850 | 835 | ||
851 | dev->config = number; | 836 | dev->config = number; |
852 | INFO (dev, "%s speed config #%d: %s\n", speed, number, | 837 | INFO(dev, "%s speed config #%d: %s\n", speed, number, |
853 | (number == CONFIG_SOURCE_SINK) | 838 | (number == CONFIG_SOURCE_SINK) |
854 | ? source_sink : loopback); | 839 | ? source_sink : loopback); |
855 | } | 840 | } |
@@ -858,10 +843,10 @@ static int zero_set_config(struct zero_dev *dev, unsigned number) | |||
858 | 843 | ||
859 | /*-------------------------------------------------------------------------*/ | 844 | /*-------------------------------------------------------------------------*/ |
860 | 845 | ||
861 | static void zero_setup_complete (struct usb_ep *ep, struct usb_request *req) | 846 | static void zero_setup_complete(struct usb_ep *ep, struct usb_request *req) |
862 | { | 847 | { |
863 | if (req->status || req->actual != req->length) | 848 | if (req->status || req->actual != req->length) |
864 | DBG ((struct zero_dev *) ep->driver_data, | 849 | DBG((struct zero_dev *) ep->driver_data, |
865 | "setup complete --> %d, %d/%d\n", | 850 | "setup complete --> %d, %d/%d\n", |
866 | req->status, req->actual, req->length); | 851 | req->status, req->actual, req->length); |
867 | } | 852 | } |
@@ -874,9 +859,9 @@ static void zero_setup_complete (struct usb_ep *ep, struct usb_request *req) | |||
874 | * the work is in config-specific setup. | 859 | * the work is in config-specific setup. |
875 | */ | 860 | */ |
876 | static int | 861 | static int |
877 | zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | 862 | zero_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) |
878 | { | 863 | { |
879 | struct zero_dev *dev = get_gadget_data (gadget); | 864 | struct zero_dev *dev = get_gadget_data(gadget); |
880 | struct usb_request *req = dev->req; | 865 | struct usb_request *req = dev->req; |
881 | int value = -EOPNOTSUPP; | 866 | int value = -EOPNOTSUPP; |
882 | u16 w_index = le16_to_cpu(ctrl->wIndex); | 867 | u16 w_index = le16_to_cpu(ctrl->wIndex); |
@@ -895,14 +880,14 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
895 | switch (w_value >> 8) { | 880 | switch (w_value >> 8) { |
896 | 881 | ||
897 | case USB_DT_DEVICE: | 882 | case USB_DT_DEVICE: |
898 | value = min (w_length, (u16) sizeof device_desc); | 883 | value = min(w_length, (u16) sizeof device_desc); |
899 | memcpy (req->buf, &device_desc, value); | 884 | memcpy(req->buf, &device_desc, value); |
900 | break; | 885 | break; |
901 | case USB_DT_DEVICE_QUALIFIER: | 886 | case USB_DT_DEVICE_QUALIFIER: |
902 | if (!gadget_is_dualspeed(gadget)) | 887 | if (!gadget_is_dualspeed(gadget)) |
903 | break; | 888 | break; |
904 | value = min (w_length, (u16) sizeof dev_qualifier); | 889 | value = min(w_length, (u16) sizeof dev_qualifier); |
905 | memcpy (req->buf, &dev_qualifier, value); | 890 | memcpy(req->buf, &dev_qualifier, value); |
906 | break; | 891 | break; |
907 | 892 | ||
908 | case USB_DT_OTHER_SPEED_CONFIG: | 893 | case USB_DT_OTHER_SPEED_CONFIG: |
@@ -910,11 +895,11 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
910 | break; | 895 | break; |
911 | // FALLTHROUGH | 896 | // FALLTHROUGH |
912 | case USB_DT_CONFIG: | 897 | case USB_DT_CONFIG: |
913 | value = config_buf (gadget, req->buf, | 898 | value = config_buf(gadget, req->buf, |
914 | w_value >> 8, | 899 | w_value >> 8, |
915 | w_value & 0xff); | 900 | w_value & 0xff); |
916 | if (value >= 0) | 901 | if (value >= 0) |
917 | value = min (w_length, (u16) value); | 902 | value = min(w_length, (u16) value); |
918 | break; | 903 | break; |
919 | 904 | ||
920 | case USB_DT_STRING: | 905 | case USB_DT_STRING: |
@@ -923,10 +908,10 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
923 | * add string tables for other languages, using | 908 | * add string tables for other languages, using |
924 | * any UTF-8 characters | 909 | * any UTF-8 characters |
925 | */ | 910 | */ |
926 | value = usb_gadget_get_string (&stringtab, | 911 | value = usb_gadget_get_string(&stringtab, |
927 | w_value & 0xff, req->buf); | 912 | w_value & 0xff, req->buf); |
928 | if (value >= 0) | 913 | if (value >= 0) |
929 | value = min (w_length, (u16) value); | 914 | value = min(w_length, (u16) value); |
930 | break; | 915 | break; |
931 | } | 916 | } |
932 | break; | 917 | break; |
@@ -936,20 +921,20 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
936 | if (ctrl->bRequestType != 0) | 921 | if (ctrl->bRequestType != 0) |
937 | goto unknown; | 922 | goto unknown; |
938 | if (gadget->a_hnp_support) | 923 | if (gadget->a_hnp_support) |
939 | DBG (dev, "HNP available\n"); | 924 | DBG(dev, "HNP available\n"); |
940 | else if (gadget->a_alt_hnp_support) | 925 | else if (gadget->a_alt_hnp_support) |
941 | DBG (dev, "HNP needs a different root port\n"); | 926 | DBG(dev, "HNP needs a different root port\n"); |
942 | else | 927 | else |
943 | VDBG (dev, "HNP inactive\n"); | 928 | VDBG(dev, "HNP inactive\n"); |
944 | spin_lock (&dev->lock); | 929 | spin_lock(&dev->lock); |
945 | value = zero_set_config(dev, w_value); | 930 | value = zero_set_config(dev, w_value); |
946 | spin_unlock (&dev->lock); | 931 | spin_unlock(&dev->lock); |
947 | break; | 932 | break; |
948 | case USB_REQ_GET_CONFIGURATION: | 933 | case USB_REQ_GET_CONFIGURATION: |
949 | if (ctrl->bRequestType != USB_DIR_IN) | 934 | if (ctrl->bRequestType != USB_DIR_IN) |
950 | goto unknown; | 935 | goto unknown; |
951 | *(u8 *)req->buf = dev->config; | 936 | *(u8 *)req->buf = dev->config; |
952 | value = min (w_length, (u16) 1); | 937 | value = min(w_length, (u16) 1); |
953 | break; | 938 | break; |
954 | 939 | ||
955 | /* until we add altsetting support, or other interfaces, | 940 | /* until we add altsetting support, or other interfaces, |
@@ -959,7 +944,7 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
959 | case USB_REQ_SET_INTERFACE: | 944 | case USB_REQ_SET_INTERFACE: |
960 | if (ctrl->bRequestType != USB_RECIP_INTERFACE) | 945 | if (ctrl->bRequestType != USB_RECIP_INTERFACE) |
961 | goto unknown; | 946 | goto unknown; |
962 | spin_lock (&dev->lock); | 947 | spin_lock(&dev->lock); |
963 | if (dev->config && w_index == 0 && w_value == 0) { | 948 | if (dev->config && w_index == 0 && w_value == 0) { |
964 | u8 config = dev->config; | 949 | u8 config = dev->config; |
965 | 950 | ||
@@ -970,11 +955,11 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
970 | * if we had more than one interface we couldn't | 955 | * if we had more than one interface we couldn't |
971 | * use this "reset the config" shortcut. | 956 | * use this "reset the config" shortcut. |
972 | */ | 957 | */ |
973 | zero_reset_config (dev); | 958 | zero_reset_config(dev); |
974 | zero_set_config(dev, config); | 959 | zero_set_config(dev, config); |
975 | value = 0; | 960 | value = 0; |
976 | } | 961 | } |
977 | spin_unlock (&dev->lock); | 962 | spin_unlock(&dev->lock); |
978 | break; | 963 | break; |
979 | case USB_REQ_GET_INTERFACE: | 964 | case USB_REQ_GET_INTERFACE: |
980 | if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)) | 965 | if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)) |
@@ -986,7 +971,7 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
986 | break; | 971 | break; |
987 | } | 972 | } |
988 | *(u8 *)req->buf = 0; | 973 | *(u8 *)req->buf = 0; |
989 | value = min (w_length, (u16) 1); | 974 | value = min(w_length, (u16) 1); |
990 | break; | 975 | break; |
991 | 976 | ||
992 | /* | 977 | /* |
@@ -1018,7 +1003,7 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1018 | 1003 | ||
1019 | default: | 1004 | default: |
1020 | unknown: | 1005 | unknown: |
1021 | VDBG (dev, | 1006 | VDBG(dev, |
1022 | "unknown control req%02x.%02x v%04x i%04x l%d\n", | 1007 | "unknown control req%02x.%02x v%04x i%04x l%d\n", |
1023 | ctrl->bRequestType, ctrl->bRequest, | 1008 | ctrl->bRequestType, ctrl->bRequest, |
1024 | w_value, w_index, w_length); | 1009 | w_value, w_index, w_length); |
@@ -1028,11 +1013,11 @@ unknown: | |||
1028 | if (value >= 0) { | 1013 | if (value >= 0) { |
1029 | req->length = value; | 1014 | req->length = value; |
1030 | req->zero = value < w_length; | 1015 | req->zero = value < w_length; |
1031 | value = usb_ep_queue (gadget->ep0, req, GFP_ATOMIC); | 1016 | value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); |
1032 | if (value < 0) { | 1017 | if (value < 0) { |
1033 | DBG (dev, "ep_queue --> %d\n", value); | 1018 | DBG(dev, "ep_queue --> %d\n", value); |
1034 | req->status = 0; | 1019 | req->status = 0; |
1035 | zero_setup_complete (gadget->ep0, req); | 1020 | zero_setup_complete(gadget->ep0, req); |
1036 | } | 1021 | } |
1037 | } | 1022 | } |
1038 | 1023 | ||
@@ -1040,28 +1025,26 @@ unknown: | |||
1040 | return value; | 1025 | return value; |
1041 | } | 1026 | } |
1042 | 1027 | ||
1043 | static void | 1028 | static void zero_disconnect(struct usb_gadget *gadget) |
1044 | zero_disconnect (struct usb_gadget *gadget) | ||
1045 | { | 1029 | { |
1046 | struct zero_dev *dev = get_gadget_data (gadget); | 1030 | struct zero_dev *dev = get_gadget_data(gadget); |
1047 | unsigned long flags; | 1031 | unsigned long flags; |
1048 | 1032 | ||
1049 | spin_lock_irqsave (&dev->lock, flags); | 1033 | spin_lock_irqsave(&dev->lock, flags); |
1050 | zero_reset_config (dev); | 1034 | zero_reset_config(dev); |
1051 | 1035 | ||
1052 | /* a more significant application might have some non-usb | 1036 | /* a more significant application might have some non-usb |
1053 | * activities to quiesce here, saving resources like power | 1037 | * activities to quiesce here, saving resources like power |
1054 | * or pushing the notification up a network stack. | 1038 | * or pushing the notification up a network stack. |
1055 | */ | 1039 | */ |
1056 | spin_unlock_irqrestore (&dev->lock, flags); | 1040 | spin_unlock_irqrestore(&dev->lock, flags); |
1057 | 1041 | ||
1058 | /* next we may get setup() calls to enumerate new connections; | 1042 | /* next we may get setup() calls to enumerate new connections; |
1059 | * or an unbind() during shutdown (including removing module). | 1043 | * or an unbind() during shutdown (including removing module). |
1060 | */ | 1044 | */ |
1061 | } | 1045 | } |
1062 | 1046 | ||
1063 | static void | 1047 | static void zero_autoresume(unsigned long _dev) |
1064 | zero_autoresume (unsigned long _dev) | ||
1065 | { | 1048 | { |
1066 | struct zero_dev *dev = (struct zero_dev *) _dev; | 1049 | struct zero_dev *dev = (struct zero_dev *) _dev; |
1067 | int status; | 1050 | int status; |
@@ -1070,32 +1053,30 @@ zero_autoresume (unsigned long _dev) | |||
1070 | * more significant than just a timer firing... | 1053 | * more significant than just a timer firing... |
1071 | */ | 1054 | */ |
1072 | if (dev->gadget->speed != USB_SPEED_UNKNOWN) { | 1055 | if (dev->gadget->speed != USB_SPEED_UNKNOWN) { |
1073 | status = usb_gadget_wakeup (dev->gadget); | 1056 | status = usb_gadget_wakeup(dev->gadget); |
1074 | DBG (dev, "wakeup --> %d\n", status); | 1057 | DBG(dev, "wakeup --> %d\n", status); |
1075 | } | 1058 | } |
1076 | } | 1059 | } |
1077 | 1060 | ||
1078 | /*-------------------------------------------------------------------------*/ | 1061 | /*-------------------------------------------------------------------------*/ |
1079 | 1062 | ||
1080 | static void /* __init_or_exit */ | 1063 | static void zero_unbind(struct usb_gadget *gadget) |
1081 | zero_unbind (struct usb_gadget *gadget) | ||
1082 | { | 1064 | { |
1083 | struct zero_dev *dev = get_gadget_data (gadget); | 1065 | struct zero_dev *dev = get_gadget_data(gadget); |
1084 | 1066 | ||
1085 | DBG (dev, "unbind\n"); | 1067 | DBG(dev, "unbind\n"); |
1086 | 1068 | ||
1087 | /* we've already been disconnected ... no i/o is active */ | 1069 | /* we've already been disconnected ... no i/o is active */ |
1088 | if (dev->req) { | 1070 | if (dev->req) { |
1089 | dev->req->length = USB_BUFSIZ; | 1071 | dev->req->length = USB_BUFSIZ; |
1090 | free_ep_req (gadget->ep0, dev->req); | 1072 | free_ep_req(gadget->ep0, dev->req); |
1091 | } | 1073 | } |
1092 | del_timer_sync (&dev->resume); | 1074 | del_timer_sync(&dev->resume); |
1093 | kfree (dev); | 1075 | kfree(dev); |
1094 | set_gadget_data (gadget, NULL); | 1076 | set_gadget_data(gadget, NULL); |
1095 | } | 1077 | } |
1096 | 1078 | ||
1097 | static int __init | 1079 | static int __init zero_bind(struct usb_gadget *gadget) |
1098 | zero_bind (struct usb_gadget *gadget) | ||
1099 | { | 1080 | { |
1100 | struct zero_dev *dev; | 1081 | struct zero_dev *dev; |
1101 | struct usb_ep *ep; | 1082 | struct usb_ep *ep; |
@@ -1111,8 +1092,8 @@ zero_bind (struct usb_gadget *gadget) | |||
1111 | * autoconfigure on any sane usb controller driver, | 1092 | * autoconfigure on any sane usb controller driver, |
1112 | * but there may also be important quirks to address. | 1093 | * but there may also be important quirks to address. |
1113 | */ | 1094 | */ |
1114 | usb_ep_autoconfig_reset (gadget); | 1095 | usb_ep_autoconfig_reset(gadget); |
1115 | ep = usb_ep_autoconfig (gadget, &fs_source_desc); | 1096 | ep = usb_ep_autoconfig(gadget, &fs_source_desc); |
1116 | if (!ep) { | 1097 | if (!ep) { |
1117 | autoconf_fail: | 1098 | autoconf_fail: |
1118 | pr_err("%s: can't autoconfigure on %s\n", | 1099 | pr_err("%s: can't autoconfigure on %s\n", |
@@ -1122,15 +1103,15 @@ autoconf_fail: | |||
1122 | EP_IN_NAME = ep->name; | 1103 | EP_IN_NAME = ep->name; |
1123 | ep->driver_data = ep; /* claim */ | 1104 | ep->driver_data = ep; /* claim */ |
1124 | 1105 | ||
1125 | ep = usb_ep_autoconfig (gadget, &fs_sink_desc); | 1106 | ep = usb_ep_autoconfig(gadget, &fs_sink_desc); |
1126 | if (!ep) | 1107 | if (!ep) |
1127 | goto autoconf_fail; | 1108 | goto autoconf_fail; |
1128 | EP_OUT_NAME = ep->name; | 1109 | EP_OUT_NAME = ep->name; |
1129 | ep->driver_data = ep; /* claim */ | 1110 | ep->driver_data = ep; /* claim */ |
1130 | 1111 | ||
1131 | gcnum = usb_gadget_controller_number (gadget); | 1112 | gcnum = usb_gadget_controller_number(gadget); |
1132 | if (gcnum >= 0) | 1113 | if (gcnum >= 0) |
1133 | device_desc.bcdDevice = cpu_to_le16 (0x0200 + gcnum); | 1114 | device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); |
1134 | else { | 1115 | else { |
1135 | /* gadget zero is so simple (for now, no altsettings) that | 1116 | /* gadget zero is so simple (for now, no altsettings) that |
1136 | * it SHOULD NOT have problems with bulk-capable hardware. | 1117 | * it SHOULD NOT have problems with bulk-capable hardware. |
@@ -1141,7 +1122,7 @@ autoconf_fail: | |||
1141 | */ | 1122 | */ |
1142 | pr_warning("%s: controller '%s' not recognized\n", | 1123 | pr_warning("%s: controller '%s' not recognized\n", |
1143 | shortname, gadget->name); | 1124 | shortname, gadget->name); |
1144 | device_desc.bcdDevice = __constant_cpu_to_le16 (0x9999); | 1125 | device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); |
1145 | } | 1126 | } |
1146 | 1127 | ||
1147 | 1128 | ||
@@ -1149,12 +1130,16 @@ autoconf_fail: | |||
1149 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 1130 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
1150 | if (!dev) | 1131 | if (!dev) |
1151 | return -ENOMEM; | 1132 | return -ENOMEM; |
1152 | spin_lock_init (&dev->lock); | 1133 | spin_lock_init(&dev->lock); |
1153 | dev->gadget = gadget; | 1134 | dev->gadget = gadget; |
1154 | set_gadget_data (gadget, dev); | 1135 | set_gadget_data(gadget, dev); |
1136 | |||
1137 | init_timer(&dev->resume); | ||
1138 | dev->resume.function = zero_autoresume; | ||
1139 | dev->resume.data = (unsigned long) dev; | ||
1155 | 1140 | ||
1156 | /* preallocate control response and buffer */ | 1141 | /* preallocate control response and buffer */ |
1157 | dev->req = usb_ep_alloc_request (gadget->ep0, GFP_KERNEL); | 1142 | dev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL); |
1158 | if (!dev->req) | 1143 | if (!dev->req) |
1159 | goto enomem; | 1144 | goto enomem; |
1160 | dev->req->buf = kmalloc(USB_BUFSIZ, GFP_KERNEL); | 1145 | dev->req->buf = kmalloc(USB_BUFSIZ, GFP_KERNEL); |
@@ -1182,11 +1167,8 @@ autoconf_fail: | |||
1182 | loopback_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 1167 | loopback_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
1183 | } | 1168 | } |
1184 | 1169 | ||
1185 | usb_gadget_set_selfpowered (gadget); | 1170 | usb_gadget_set_selfpowered(gadget); |
1186 | 1171 | ||
1187 | init_timer (&dev->resume); | ||
1188 | dev->resume.function = zero_autoresume; | ||
1189 | dev->resume.data = (unsigned long) dev; | ||
1190 | if (autoresume) { | 1172 | if (autoresume) { |
1191 | source_sink_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 1173 | source_sink_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
1192 | loopback_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 1174 | loopback_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
@@ -1194,45 +1176,43 @@ autoconf_fail: | |||
1194 | 1176 | ||
1195 | gadget->ep0->driver_data = dev; | 1177 | gadget->ep0->driver_data = dev; |
1196 | 1178 | ||
1197 | INFO (dev, "%s, version: " DRIVER_VERSION "\n", longname); | 1179 | INFO(dev, "%s, version: " DRIVER_VERSION "\n", longname); |
1198 | INFO (dev, "using %s, OUT %s IN %s\n", gadget->name, | 1180 | INFO(dev, "using %s, OUT %s IN %s\n", gadget->name, |
1199 | EP_OUT_NAME, EP_IN_NAME); | 1181 | EP_OUT_NAME, EP_IN_NAME); |
1200 | 1182 | ||
1201 | snprintf (manufacturer, sizeof manufacturer, "%s %s with %s", | 1183 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", |
1202 | init_utsname()->sysname, init_utsname()->release, | 1184 | init_utsname()->sysname, init_utsname()->release, |
1203 | gadget->name); | 1185 | gadget->name); |
1204 | 1186 | ||
1205 | return 0; | 1187 | return 0; |
1206 | 1188 | ||
1207 | enomem: | 1189 | enomem: |
1208 | zero_unbind (gadget); | 1190 | zero_unbind(gadget); |
1209 | return -ENOMEM; | 1191 | return -ENOMEM; |
1210 | } | 1192 | } |
1211 | 1193 | ||
1212 | /*-------------------------------------------------------------------------*/ | 1194 | /*-------------------------------------------------------------------------*/ |
1213 | 1195 | ||
1214 | static void | 1196 | static void zero_suspend(struct usb_gadget *gadget) |
1215 | zero_suspend (struct usb_gadget *gadget) | ||
1216 | { | 1197 | { |
1217 | struct zero_dev *dev = get_gadget_data (gadget); | 1198 | struct zero_dev *dev = get_gadget_data(gadget); |
1218 | 1199 | ||
1219 | if (gadget->speed == USB_SPEED_UNKNOWN) | 1200 | if (gadget->speed == USB_SPEED_UNKNOWN) |
1220 | return; | 1201 | return; |
1221 | 1202 | ||
1222 | if (autoresume) { | 1203 | if (autoresume) { |
1223 | mod_timer (&dev->resume, jiffies + (HZ * autoresume)); | 1204 | mod_timer(&dev->resume, jiffies + (HZ * autoresume)); |
1224 | DBG (dev, "suspend, wakeup in %d seconds\n", autoresume); | 1205 | DBG(dev, "suspend, wakeup in %d seconds\n", autoresume); |
1225 | } else | 1206 | } else |
1226 | DBG (dev, "suspend\n"); | 1207 | DBG(dev, "suspend\n"); |
1227 | } | 1208 | } |
1228 | 1209 | ||
1229 | static void | 1210 | static void zero_resume(struct usb_gadget *gadget) |
1230 | zero_resume (struct usb_gadget *gadget) | ||
1231 | { | 1211 | { |
1232 | struct zero_dev *dev = get_gadget_data (gadget); | 1212 | struct zero_dev *dev = get_gadget_data(gadget); |
1233 | 1213 | ||
1234 | DBG (dev, "resume\n"); | 1214 | DBG(dev, "resume\n"); |
1235 | del_timer (&dev->resume); | 1215 | del_timer(&dev->resume); |
1236 | } | 1216 | } |
1237 | 1217 | ||
1238 | 1218 | ||
@@ -1264,15 +1244,15 @@ MODULE_AUTHOR("David Brownell"); | |||
1264 | MODULE_LICENSE("GPL"); | 1244 | MODULE_LICENSE("GPL"); |
1265 | 1245 | ||
1266 | 1246 | ||
1267 | static int __init init (void) | 1247 | static int __init init(void) |
1268 | { | 1248 | { |
1269 | return usb_gadget_register_driver (&zero_driver); | 1249 | return usb_gadget_register_driver(&zero_driver); |
1270 | } | 1250 | } |
1271 | module_init (init); | 1251 | module_init(init); |
1272 | 1252 | ||
1273 | static void __exit cleanup (void) | 1253 | static void __exit cleanup(void) |
1274 | { | 1254 | { |
1275 | usb_gadget_unregister_driver (&zero_driver); | 1255 | usb_gadget_unregister_driver(&zero_driver); |
1276 | } | 1256 | } |
1277 | module_exit (cleanup); | 1257 | module_exit(cleanup); |
1278 | 1258 | ||
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 0b87480dd713..33b467a8352d 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -4,6 +4,19 @@ | |||
4 | comment "USB Host Controller Drivers" | 4 | comment "USB Host Controller Drivers" |
5 | depends on USB | 5 | depends on USB |
6 | 6 | ||
7 | config USB_C67X00_HCD | ||
8 | tristate "Cypress C67x00 HCD support" | ||
9 | depends on USB | ||
10 | help | ||
11 | The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role | ||
12 | host/peripheral/OTG USB controllers. | ||
13 | |||
14 | Enable this option to support this chip in host controller mode. | ||
15 | If unsure, say N. | ||
16 | |||
17 | To compile this driver as a module, choose M here: the | ||
18 | module will be called c67x00. | ||
19 | |||
7 | config USB_EHCI_HCD | 20 | config USB_EHCI_HCD |
8 | tristate "EHCI HCD (USB 2.0) support" | 21 | tristate "EHCI HCD (USB 2.0) support" |
9 | depends on USB && USB_ARCH_HAS_EHCI | 22 | depends on USB && USB_ARCH_HAS_EHCI |
@@ -95,6 +108,32 @@ config USB_ISP116X_HCD | |||
95 | To compile this driver as a module, choose M here: the | 108 | To compile this driver as a module, choose M here: the |
96 | module will be called isp116x-hcd. | 109 | module will be called isp116x-hcd. |
97 | 110 | ||
111 | config USB_ISP1760_HCD | ||
112 | tristate "ISP 1760 HCD support" | ||
113 | depends on USB && EXPERIMENTAL | ||
114 | ---help--- | ||
115 | The ISP1760 chip is a USB 2.0 host controller. | ||
116 | |||
117 | This driver does not support isochronous transfers or OTG. | ||
118 | |||
119 | To compile this driver as a module, choose M here: the | ||
120 | module will be called isp1760-hcd. | ||
121 | |||
122 | config USB_ISP1760_PCI | ||
123 | bool "Support for the PCI bus" | ||
124 | depends on USB_ISP1760_HCD && PCI | ||
125 | ---help--- | ||
126 | Enables support for the device present on the PCI bus. | ||
127 | This should only be required if you happen to have the eval kit from | ||
128 | NXP and you are going to test it. | ||
129 | |||
130 | config USB_ISP1760_OF | ||
131 | bool "Support for the OF platform bus" | ||
132 | depends on USB_ISP1760_HCD && OF | ||
133 | ---help--- | ||
134 | Enables support for the device present on the PowerPC | ||
135 | OpenFirmware platform bus. | ||
136 | |||
98 | config USB_OHCI_HCD | 137 | config USB_OHCI_HCD |
99 | tristate "OHCI HCD support" | 138 | tristate "OHCI HCD support" |
100 | depends on USB && USB_ARCH_HAS_OHCI | 139 | depends on USB && USB_ARCH_HAS_OHCI |
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index bb8e9d44f371..f1edda2dcfde 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
@@ -6,6 +6,8 @@ ifeq ($(CONFIG_USB_DEBUG),y) | |||
6 | EXTRA_CFLAGS += -DDEBUG | 6 | EXTRA_CFLAGS += -DDEBUG |
7 | endif | 7 | endif |
8 | 8 | ||
9 | isp1760-objs := isp1760-hcd.o isp1760-if.o | ||
10 | |||
9 | obj-$(CONFIG_PCI) += pci-quirks.o | 11 | obj-$(CONFIG_PCI) += pci-quirks.o |
10 | 12 | ||
11 | obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o | 13 | obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o |
@@ -16,4 +18,4 @@ obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o | |||
16 | obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o | 18 | obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o |
17 | obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o | 19 | obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o |
18 | obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o | 20 | obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o |
19 | 21 | obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o | |
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c new file mode 100644 index 000000000000..4ba96c1e060c --- /dev/null +++ b/drivers/usb/host/isp1760-hcd.c | |||
@@ -0,0 +1,2231 @@ | |||
1 | /* | ||
2 | * Driver for the NXP ISP1760 chip | ||
3 | * | ||
4 | * However, the code might contain some bugs. What doesn't work for sure is: | ||
5 | * - ISO | ||
6 | * - OTG | ||
7 | e The interrupt line is configured as active low, level. | ||
8 | * | ||
9 | * (c) 2007 Sebastian Siewior <bigeasy@linutronix.de> | ||
10 | * | ||
11 | */ | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/list.h> | ||
16 | #include <linux/usb.h> | ||
17 | #include <linux/debugfs.h> | ||
18 | #include <linux/uaccess.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <asm/unaligned.h> | ||
21 | |||
22 | #include "../core/hcd.h" | ||
23 | #include "isp1760-hcd.h" | ||
24 | |||
25 | static struct kmem_cache *qtd_cachep; | ||
26 | static struct kmem_cache *qh_cachep; | ||
27 | |||
28 | struct isp1760_hcd { | ||
29 | u32 hcs_params; | ||
30 | spinlock_t lock; | ||
31 | struct inter_packet_info atl_ints[32]; | ||
32 | struct inter_packet_info int_ints[32]; | ||
33 | struct memory_chunk memory_pool[BLOCKS]; | ||
34 | |||
35 | /* periodic schedule support */ | ||
36 | #define DEFAULT_I_TDPS 1024 | ||
37 | unsigned periodic_size; | ||
38 | unsigned i_thresh; | ||
39 | unsigned long reset_done; | ||
40 | unsigned long next_statechange; | ||
41 | }; | ||
42 | |||
43 | static inline struct isp1760_hcd *hcd_to_priv(struct usb_hcd *hcd) | ||
44 | { | ||
45 | return (struct isp1760_hcd *) (hcd->hcd_priv); | ||
46 | } | ||
47 | static inline struct usb_hcd *priv_to_hcd(struct isp1760_hcd *priv) | ||
48 | { | ||
49 | return container_of((void *) priv, struct usb_hcd, hcd_priv); | ||
50 | } | ||
51 | |||
52 | /* Section 2.2 Host Controller Capability Registers */ | ||
53 | #define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */ | ||
54 | #define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */ | ||
55 | #define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */ | ||
56 | #define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */ | ||
57 | #define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */ | ||
58 | #define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */ | ||
59 | #define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */ | ||
60 | |||
61 | /* Section 2.3 Host Controller Operational Registers */ | ||
62 | #define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */ | ||
63 | #define CMD_RESET (1<<1) /* reset HC not bus */ | ||
64 | #define CMD_RUN (1<<0) /* start/stop HC */ | ||
65 | #define STS_PCD (1<<2) /* port change detect */ | ||
66 | #define FLAG_CF (1<<0) /* true: we'll support "high speed" */ | ||
67 | |||
68 | #define PORT_OWNER (1<<13) /* true: companion hc owns this port */ | ||
69 | #define PORT_POWER (1<<12) /* true: has power (see PPC) */ | ||
70 | #define PORT_USB11(x) (((x) & (3 << 10)) == (1 << 10)) /* USB 1.1 device */ | ||
71 | #define PORT_RESET (1<<8) /* reset port */ | ||
72 | #define PORT_SUSPEND (1<<7) /* suspend port */ | ||
73 | #define PORT_RESUME (1<<6) /* resume it */ | ||
74 | #define PORT_PE (1<<2) /* port enable */ | ||
75 | #define PORT_CSC (1<<1) /* connect status change */ | ||
76 | #define PORT_CONNECT (1<<0) /* device connected */ | ||
77 | #define PORT_RWC_BITS (PORT_CSC) | ||
78 | |||
79 | struct isp1760_qtd { | ||
80 | struct isp1760_qtd *hw_next; | ||
81 | u8 packet_type; | ||
82 | u8 toggle; | ||
83 | |||
84 | void *data_buffer; | ||
85 | /* the rest is HCD-private */ | ||
86 | struct list_head qtd_list; | ||
87 | struct urb *urb; | ||
88 | size_t length; | ||
89 | |||
90 | /* isp special*/ | ||
91 | u32 status; | ||
92 | #define URB_COMPLETE_NOTIFY (1 << 0) | ||
93 | #define URB_ENQUEUED (1 << 1) | ||
94 | #define URB_TYPE_ATL (1 << 2) | ||
95 | #define URB_TYPE_INT (1 << 3) | ||
96 | }; | ||
97 | |||
98 | struct isp1760_qh { | ||
99 | /* first part defined by EHCI spec */ | ||
100 | struct list_head qtd_list; | ||
101 | struct isp1760_hcd *priv; | ||
102 | |||
103 | /* periodic schedule info */ | ||
104 | unsigned short period; /* polling interval */ | ||
105 | struct usb_device *dev; | ||
106 | |||
107 | u32 toggle; | ||
108 | u32 ping; | ||
109 | }; | ||
110 | |||
111 | #define ehci_port_speed(priv, portsc) (1 << USB_PORT_FEAT_HIGHSPEED) | ||
112 | |||
113 | static unsigned int isp1760_readl(__u32 __iomem *regs) | ||
114 | { | ||
115 | return readl(regs); | ||
116 | } | ||
117 | |||
118 | static void isp1760_writel(const unsigned int val, __u32 __iomem *regs) | ||
119 | { | ||
120 | writel(val, regs); | ||
121 | } | ||
122 | |||
123 | /* | ||
124 | * The next two copy via MMIO data to/from the device. memcpy_{to|from}io() | ||
125 | * doesn't quite work because some people have to enforce 32-bit access | ||
126 | */ | ||
127 | static void priv_read_copy(struct isp1760_hcd *priv, u32 *src, | ||
128 | __u32 __iomem *dst, u32 offset, u32 len) | ||
129 | { | ||
130 | struct usb_hcd *hcd = priv_to_hcd(priv); | ||
131 | u32 val; | ||
132 | u8 *buff8; | ||
133 | |||
134 | if (!src) { | ||
135 | printk(KERN_ERR "ERROR: buffer: %p len: %d\n", src, len); | ||
136 | return; | ||
137 | } | ||
138 | isp1760_writel(offset, hcd->regs + HC_MEMORY_REG); | ||
139 | /* XXX | ||
140 | * 90nsec delay, the spec says something how this could be avoided. | ||
141 | */ | ||
142 | mdelay(1); | ||
143 | |||
144 | while (len >= 4) { | ||
145 | *src = __raw_readl(dst); | ||
146 | len -= 4; | ||
147 | src++; | ||
148 | dst++; | ||
149 | } | ||
150 | |||
151 | if (!len) | ||
152 | return; | ||
153 | |||
154 | /* in case we have 3, 2 or 1 by left. The dst buffer may not be fully | ||
155 | * allocated. | ||
156 | */ | ||
157 | val = isp1760_readl(dst); | ||
158 | |||
159 | buff8 = (u8 *)src; | ||
160 | while (len) { | ||
161 | |||
162 | *buff8 = val; | ||
163 | val >>= 8; | ||
164 | len--; | ||
165 | buff8++; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | static void priv_write_copy(const struct isp1760_hcd *priv, const u32 *src, | ||
170 | __u32 __iomem *dst, u32 len) | ||
171 | { | ||
172 | while (len >= 4) { | ||
173 | __raw_writel(*src, dst); | ||
174 | len -= 4; | ||
175 | src++; | ||
176 | dst++; | ||
177 | } | ||
178 | |||
179 | if (!len) | ||
180 | return; | ||
181 | /* in case we have 3, 2 or 1 by left. The buffer is allocated and the | ||
182 | * extra bytes should not be read by the HW | ||
183 | */ | ||
184 | |||
185 | __raw_writel(*src, dst); | ||
186 | } | ||
187 | |||
188 | /* memory management of the 60kb on the chip from 0x1000 to 0xffff */ | ||
189 | static void init_memory(struct isp1760_hcd *priv) | ||
190 | { | ||
191 | int i; | ||
192 | u32 payload; | ||
193 | |||
194 | payload = 0x1000; | ||
195 | for (i = 0; i < BLOCK_1_NUM; i++) { | ||
196 | priv->memory_pool[i].start = payload; | ||
197 | priv->memory_pool[i].size = BLOCK_1_SIZE; | ||
198 | priv->memory_pool[i].free = 1; | ||
199 | payload += priv->memory_pool[i].size; | ||
200 | } | ||
201 | |||
202 | |||
203 | for (i = BLOCK_1_NUM; i < BLOCK_1_NUM + BLOCK_2_NUM; i++) { | ||
204 | priv->memory_pool[i].start = payload; | ||
205 | priv->memory_pool[i].size = BLOCK_2_SIZE; | ||
206 | priv->memory_pool[i].free = 1; | ||
207 | payload += priv->memory_pool[i].size; | ||
208 | } | ||
209 | |||
210 | |||
211 | for (i = BLOCK_1_NUM + BLOCK_2_NUM; i < BLOCKS; i++) { | ||
212 | priv->memory_pool[i].start = payload; | ||
213 | priv->memory_pool[i].size = BLOCK_3_SIZE; | ||
214 | priv->memory_pool[i].free = 1; | ||
215 | payload += priv->memory_pool[i].size; | ||
216 | } | ||
217 | |||
218 | BUG_ON(payload - priv->memory_pool[i - 1].size > PAYLOAD_SIZE); | ||
219 | } | ||
220 | |||
221 | static u32 alloc_mem(struct isp1760_hcd *priv, u32 size) | ||
222 | { | ||
223 | int i; | ||
224 | |||
225 | if (!size) | ||
226 | return ISP1760_NULL_POINTER; | ||
227 | |||
228 | for (i = 0; i < BLOCKS; i++) { | ||
229 | if (priv->memory_pool[i].size >= size && | ||
230 | priv->memory_pool[i].free) { | ||
231 | |||
232 | priv->memory_pool[i].free = 0; | ||
233 | return priv->memory_pool[i].start; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | printk(KERN_ERR "ISP1760 MEM: can not allocate %d bytes of memory\n", | ||
238 | size); | ||
239 | printk(KERN_ERR "Current memory map:\n"); | ||
240 | for (i = 0; i < BLOCKS; i++) { | ||
241 | printk(KERN_ERR "Pool %2d size %4d status: %d\n", | ||
242 | i, priv->memory_pool[i].size, | ||
243 | priv->memory_pool[i].free); | ||
244 | } | ||
245 | /* XXX maybe -ENOMEM could be possible */ | ||
246 | BUG(); | ||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | static void free_mem(struct isp1760_hcd *priv, u32 mem) | ||
251 | { | ||
252 | int i; | ||
253 | |||
254 | if (mem == ISP1760_NULL_POINTER) | ||
255 | return; | ||
256 | |||
257 | for (i = 0; i < BLOCKS; i++) { | ||
258 | if (priv->memory_pool[i].start == mem) { | ||
259 | |||
260 | BUG_ON(priv->memory_pool[i].free); | ||
261 | |||
262 | priv->memory_pool[i].free = 1; | ||
263 | return ; | ||
264 | } | ||
265 | } | ||
266 | |||
267 | printk(KERN_ERR "Trying to free not-here-allocated memory :%08x\n", | ||
268 | mem); | ||
269 | BUG(); | ||
270 | } | ||
271 | |||
272 | static void isp1760_init_regs(struct usb_hcd *hcd) | ||
273 | { | ||
274 | isp1760_writel(0, hcd->regs + HC_BUFFER_STATUS_REG); | ||
275 | isp1760_writel(NO_TRANSFER_ACTIVE, hcd->regs + | ||
276 | HC_ATL_PTD_SKIPMAP_REG); | ||
277 | isp1760_writel(NO_TRANSFER_ACTIVE, hcd->regs + | ||
278 | HC_INT_PTD_SKIPMAP_REG); | ||
279 | isp1760_writel(NO_TRANSFER_ACTIVE, hcd->regs + | ||
280 | HC_ISO_PTD_SKIPMAP_REG); | ||
281 | |||
282 | isp1760_writel(~NO_TRANSFER_ACTIVE, hcd->regs + | ||
283 | HC_ATL_PTD_DONEMAP_REG); | ||
284 | isp1760_writel(~NO_TRANSFER_ACTIVE, hcd->regs + | ||
285 | HC_INT_PTD_DONEMAP_REG); | ||
286 | isp1760_writel(~NO_TRANSFER_ACTIVE, hcd->regs + | ||
287 | HC_ISO_PTD_DONEMAP_REG); | ||
288 | } | ||
289 | |||
290 | static int handshake(struct isp1760_hcd *priv, void __iomem *ptr, | ||
291 | u32 mask, u32 done, int usec) | ||
292 | { | ||
293 | u32 result; | ||
294 | |||
295 | do { | ||
296 | result = isp1760_readl(ptr); | ||
297 | if (result == ~0) | ||
298 | return -ENODEV; | ||
299 | result &= mask; | ||
300 | if (result == done) | ||
301 | return 0; | ||
302 | udelay(1); | ||
303 | usec--; | ||
304 | } while (usec > 0); | ||
305 | return -ETIMEDOUT; | ||
306 | } | ||
307 | |||
308 | /* reset a non-running (STS_HALT == 1) controller */ | ||
309 | static int ehci_reset(struct isp1760_hcd *priv) | ||
310 | { | ||
311 | int retval; | ||
312 | struct usb_hcd *hcd = priv_to_hcd(priv); | ||
313 | u32 command = isp1760_readl(hcd->regs + HC_USBCMD); | ||
314 | |||
315 | command |= CMD_RESET; | ||
316 | isp1760_writel(command, hcd->regs + HC_USBCMD); | ||
317 | hcd->state = HC_STATE_HALT; | ||
318 | priv->next_statechange = jiffies; | ||
319 | retval = handshake(priv, hcd->regs + HC_USBCMD, | ||
320 | CMD_RESET, 0, 250 * 1000); | ||
321 | return retval; | ||
322 | } | ||
323 | |||
324 | static void qh_destroy(struct isp1760_qh *qh) | ||
325 | { | ||
326 | BUG_ON(!list_empty(&qh->qtd_list)); | ||
327 | kmem_cache_free(qh_cachep, qh); | ||
328 | } | ||
329 | |||
330 | static struct isp1760_qh *isp1760_qh_alloc(struct isp1760_hcd *priv, | ||
331 | gfp_t flags) | ||
332 | { | ||
333 | struct isp1760_qh *qh; | ||
334 | |||
335 | qh = kmem_cache_zalloc(qh_cachep, flags); | ||
336 | if (!qh) | ||
337 | return qh; | ||
338 | |||
339 | INIT_LIST_HEAD(&qh->qtd_list); | ||
340 | qh->priv = priv; | ||
341 | return qh; | ||
342 | } | ||
343 | |||
344 | /* magic numbers that can affect system performance */ | ||
345 | #define EHCI_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */ | ||
346 | #define EHCI_TUNE_RL_HS 4 /* nak throttle; see 4.9 */ | ||
347 | #define EHCI_TUNE_RL_TT 0 | ||
348 | #define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */ | ||
349 | #define EHCI_TUNE_MULT_TT 1 | ||
350 | #define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ | ||
351 | |||
352 | /* one-time init, only for memory state */ | ||
353 | static int priv_init(struct usb_hcd *hcd) | ||
354 | { | ||
355 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
356 | u32 hcc_params; | ||
357 | |||
358 | spin_lock_init(&priv->lock); | ||
359 | |||
360 | /* | ||
361 | * hw default: 1K periodic list heads, one per frame. | ||
362 | * periodic_size can shrink by USBCMD update if hcc_params allows. | ||
363 | */ | ||
364 | priv->periodic_size = DEFAULT_I_TDPS; | ||
365 | |||
366 | /* controllers may cache some of the periodic schedule ... */ | ||
367 | hcc_params = isp1760_readl(hcd->regs + HC_HCCPARAMS); | ||
368 | /* full frame cache */ | ||
369 | if (HCC_ISOC_CACHE(hcc_params)) | ||
370 | priv->i_thresh = 8; | ||
371 | else /* N microframes cached */ | ||
372 | priv->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); | ||
373 | |||
374 | return 0; | ||
375 | } | ||
376 | |||
377 | static int isp1760_hc_setup(struct usb_hcd *hcd) | ||
378 | { | ||
379 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
380 | int result; | ||
381 | u32 scratch; | ||
382 | |||
383 | isp1760_writel(0xdeadbabe, hcd->regs + HC_SCRATCH_REG); | ||
384 | scratch = isp1760_readl(hcd->regs + HC_SCRATCH_REG); | ||
385 | if (scratch != 0xdeadbabe) { | ||
386 | printk(KERN_ERR "ISP1760: Scratch test failed.\n"); | ||
387 | return -ENODEV; | ||
388 | } | ||
389 | |||
390 | /* pre reset */ | ||
391 | isp1760_init_regs(hcd); | ||
392 | |||
393 | /* reset */ | ||
394 | isp1760_writel(SW_RESET_RESET_ALL, hcd->regs + HC_RESET_REG); | ||
395 | mdelay(100); | ||
396 | |||
397 | isp1760_writel(SW_RESET_RESET_HC, hcd->regs + HC_RESET_REG); | ||
398 | mdelay(100); | ||
399 | |||
400 | result = ehci_reset(priv); | ||
401 | if (result) | ||
402 | return result; | ||
403 | |||
404 | /* Step 11 passed */ | ||
405 | |||
406 | isp1760_writel(INTERRUPT_ENABLE_MASK, hcd->regs + HC_INTERRUPT_REG); | ||
407 | isp1760_writel(INTERRUPT_ENABLE_MASK, hcd->regs + HC_INTERRUPT_ENABLE); | ||
408 | |||
409 | /* ATL reset */ | ||
410 | scratch = isp1760_readl(hcd->regs + HC_HW_MODE_CTRL); | ||
411 | isp1760_writel(scratch | ALL_ATX_RESET, hcd->regs + HC_HW_MODE_CTRL); | ||
412 | mdelay(10); | ||
413 | isp1760_writel(scratch, hcd->regs + HC_HW_MODE_CTRL); | ||
414 | |||
415 | isp1760_writel(PORT1_POWER | PORT1_INIT2, hcd->regs + HC_PORT1_CTRL); | ||
416 | mdelay(10); | ||
417 | |||
418 | priv->hcs_params = isp1760_readl(hcd->regs + HC_HCSPARAMS); | ||
419 | |||
420 | return priv_init(hcd); | ||
421 | } | ||
422 | |||
423 | static void isp1760_init_maps(struct usb_hcd *hcd) | ||
424 | { | ||
425 | /*set last maps, for iso its only 1, else 32 tds bitmap*/ | ||
426 | isp1760_writel(0x80000000, hcd->regs + HC_ATL_PTD_LASTPTD_REG); | ||
427 | isp1760_writel(0x80000000, hcd->regs + HC_INT_PTD_LASTPTD_REG); | ||
428 | isp1760_writel(0x00000001, hcd->regs + HC_ISO_PTD_LASTPTD_REG); | ||
429 | } | ||
430 | |||
431 | static void isp1760_enable_interrupts(struct usb_hcd *hcd) | ||
432 | { | ||
433 | isp1760_writel(0, hcd->regs + HC_ATL_IRQ_MASK_AND_REG); | ||
434 | isp1760_writel(0, hcd->regs + HC_ATL_IRQ_MASK_OR_REG); | ||
435 | isp1760_writel(0, hcd->regs + HC_INT_IRQ_MASK_AND_REG); | ||
436 | isp1760_writel(0, hcd->regs + HC_INT_IRQ_MASK_OR_REG); | ||
437 | isp1760_writel(0, hcd->regs + HC_ISO_IRQ_MASK_AND_REG); | ||
438 | isp1760_writel(0xffffffff, hcd->regs + HC_ISO_IRQ_MASK_OR_REG); | ||
439 | /* step 23 passed */ | ||
440 | } | ||
441 | |||
442 | static int isp1760_run(struct usb_hcd *hcd) | ||
443 | { | ||
444 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
445 | int retval; | ||
446 | u32 temp; | ||
447 | u32 command; | ||
448 | u32 chipid; | ||
449 | |||
450 | hcd->uses_new_polling = 1; | ||
451 | hcd->poll_rh = 0; | ||
452 | |||
453 | hcd->state = HC_STATE_RUNNING; | ||
454 | isp1760_enable_interrupts(hcd); | ||
455 | temp = isp1760_readl(hcd->regs + HC_HW_MODE_CTRL); | ||
456 | temp |= FINAL_HW_CONFIG; | ||
457 | isp1760_writel(temp, hcd->regs + HC_HW_MODE_CTRL); | ||
458 | |||
459 | command = isp1760_readl(hcd->regs + HC_USBCMD); | ||
460 | command &= ~(CMD_LRESET|CMD_RESET); | ||
461 | command |= CMD_RUN; | ||
462 | isp1760_writel(command, hcd->regs + HC_USBCMD); | ||
463 | |||
464 | retval = handshake(priv, hcd->regs + HC_USBCMD, CMD_RUN, CMD_RUN, | ||
465 | 250 * 1000); | ||
466 | if (retval) | ||
467 | return retval; | ||
468 | |||
469 | /* | ||
470 | * XXX | ||
471 | * Spec says to write FLAG_CF as last config action, priv code grabs | ||
472 | * the semaphore while doing so. | ||
473 | */ | ||
474 | down_write(&ehci_cf_port_reset_rwsem); | ||
475 | isp1760_writel(FLAG_CF, hcd->regs + HC_CONFIGFLAG); | ||
476 | |||
477 | retval = handshake(priv, hcd->regs + HC_CONFIGFLAG, FLAG_CF, FLAG_CF, | ||
478 | 250 * 1000); | ||
479 | up_write(&ehci_cf_port_reset_rwsem); | ||
480 | if (retval) | ||
481 | return retval; | ||
482 | |||
483 | chipid = isp1760_readl(hcd->regs + HC_CHIP_ID_REG); | ||
484 | isp1760_info(priv, "USB ISP %04x HW rev. %d started\n", chipid & 0xffff, | ||
485 | chipid >> 16); | ||
486 | |||
487 | /* PTD Register Init Part 2, Step 28 */ | ||
488 | /* enable INTs */ | ||
489 | isp1760_init_maps(hcd); | ||
490 | |||
491 | /* GRR this is run-once init(), being done every time the HC starts. | ||
492 | * So long as they're part of class devices, we can't do it init() | ||
493 | * since the class device isn't created that early. | ||
494 | */ | ||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | static u32 base_to_chip(u32 base) | ||
499 | { | ||
500 | return ((base - 0x400) >> 3); | ||
501 | } | ||
502 | |||
503 | static void transform_into_atl(struct isp1760_hcd *priv, struct isp1760_qh *qh, | ||
504 | struct isp1760_qtd *qtd, struct urb *urb, | ||
505 | u32 payload, struct ptd *ptd) | ||
506 | { | ||
507 | u32 dw0; | ||
508 | u32 dw1; | ||
509 | u32 dw2; | ||
510 | u32 dw3; | ||
511 | u32 maxpacket; | ||
512 | u32 multi; | ||
513 | u32 pid_code; | ||
514 | u32 rl = RL_COUNTER; | ||
515 | u32 nak = NAK_COUNTER; | ||
516 | |||
517 | /* according to 3.6.2, max packet len can not be > 0x400 */ | ||
518 | maxpacket = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); | ||
519 | multi = 1 + ((maxpacket >> 11) & 0x3); | ||
520 | maxpacket &= 0x7ff; | ||
521 | |||
522 | /* DW0 */ | ||
523 | dw0 = PTD_VALID; | ||
524 | dw0 |= PTD_LENGTH(qtd->length); | ||
525 | dw0 |= PTD_MAXPACKET(maxpacket); | ||
526 | dw0 |= PTD_ENDPOINT(usb_pipeendpoint(urb->pipe)); | ||
527 | dw1 = usb_pipeendpoint(urb->pipe) >> 1; | ||
528 | |||
529 | /* DW1 */ | ||
530 | dw1 |= PTD_DEVICE_ADDR(usb_pipedevice(urb->pipe)); | ||
531 | |||
532 | pid_code = qtd->packet_type; | ||
533 | dw1 |= PTD_PID_TOKEN(pid_code); | ||
534 | |||
535 | if (usb_pipebulk(urb->pipe)) | ||
536 | dw1 |= PTD_TRANS_BULK; | ||
537 | else if (usb_pipeint(urb->pipe)) | ||
538 | dw1 |= PTD_TRANS_INT; | ||
539 | |||
540 | if (urb->dev->speed != USB_SPEED_HIGH) { | ||
541 | /* split transaction */ | ||
542 | |||
543 | dw1 |= PTD_TRANS_SPLIT; | ||
544 | if (urb->dev->speed == USB_SPEED_LOW) | ||
545 | dw1 |= PTD_SE_USB_LOSPEED; | ||
546 | |||
547 | dw1 |= PTD_PORT_NUM(urb->dev->ttport); | ||
548 | dw1 |= PTD_HUB_NUM(urb->dev->tt->hub->devnum); | ||
549 | |||
550 | /* SE bit for Split INT transfers */ | ||
551 | if (usb_pipeint(urb->pipe) && | ||
552 | (urb->dev->speed == USB_SPEED_LOW)) | ||
553 | dw1 |= 2 << 16; | ||
554 | |||
555 | dw3 = 0; | ||
556 | rl = 0; | ||
557 | nak = 0; | ||
558 | } else { | ||
559 | dw0 |= PTD_MULTI(multi); | ||
560 | if (usb_pipecontrol(urb->pipe) || usb_pipebulk(urb->pipe)) | ||
561 | dw3 = qh->ping; | ||
562 | else | ||
563 | dw3 = 0; | ||
564 | } | ||
565 | /* DW2 */ | ||
566 | dw2 = 0; | ||
567 | dw2 |= PTD_DATA_START_ADDR(base_to_chip(payload)); | ||
568 | dw2 |= PTD_RL_CNT(rl); | ||
569 | dw3 |= PTD_NAC_CNT(nak); | ||
570 | |||
571 | /* DW3 */ | ||
572 | if (usb_pipecontrol(urb->pipe)) | ||
573 | dw3 |= PTD_DATA_TOGGLE(qtd->toggle); | ||
574 | else | ||
575 | dw3 |= qh->toggle; | ||
576 | |||
577 | |||
578 | dw3 |= PTD_ACTIVE; | ||
579 | /* Cerr */ | ||
580 | dw3 |= PTD_CERR(ERR_COUNTER); | ||
581 | |||
582 | memset(ptd, 0, sizeof(*ptd)); | ||
583 | |||
584 | ptd->dw0 = cpu_to_le32(dw0); | ||
585 | ptd->dw1 = cpu_to_le32(dw1); | ||
586 | ptd->dw2 = cpu_to_le32(dw2); | ||
587 | ptd->dw3 = cpu_to_le32(dw3); | ||
588 | } | ||
589 | |||
590 | static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, | ||
591 | struct isp1760_qtd *qtd, struct urb *urb, | ||
592 | u32 payload, struct ptd *ptd) | ||
593 | { | ||
594 | u32 maxpacket; | ||
595 | u32 multi; | ||
596 | u32 numberofusofs; | ||
597 | u32 i; | ||
598 | u32 usofmask, usof; | ||
599 | u32 period; | ||
600 | |||
601 | maxpacket = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); | ||
602 | multi = 1 + ((maxpacket >> 11) & 0x3); | ||
603 | maxpacket &= 0x7ff; | ||
604 | /* length of the data per uframe */ | ||
605 | maxpacket = multi * maxpacket; | ||
606 | |||
607 | numberofusofs = urb->transfer_buffer_length / maxpacket; | ||
608 | if (urb->transfer_buffer_length % maxpacket) | ||
609 | numberofusofs += 1; | ||
610 | |||
611 | usofmask = 1; | ||
612 | usof = 0; | ||
613 | for (i = 0; i < numberofusofs; i++) { | ||
614 | usof |= usofmask; | ||
615 | usofmask <<= 1; | ||
616 | } | ||
617 | |||
618 | if (urb->dev->speed != USB_SPEED_HIGH) { | ||
619 | /* split */ | ||
620 | ptd->dw5 = __constant_cpu_to_le32(0x1c); | ||
621 | |||
622 | if (qh->period >= 32) | ||
623 | period = qh->period / 2; | ||
624 | else | ||
625 | period = qh->period; | ||
626 | |||
627 | } else { | ||
628 | |||
629 | if (qh->period >= 8) | ||
630 | period = qh->period/8; | ||
631 | else | ||
632 | period = qh->period; | ||
633 | |||
634 | if (period >= 32) | ||
635 | period = 16; | ||
636 | |||
637 | if (qh->period >= 8) { | ||
638 | /* millisecond period */ | ||
639 | period = (period << 3); | ||
640 | } else { | ||
641 | /* usof based tranmsfers */ | ||
642 | /* minimum 4 usofs */ | ||
643 | usof = 0x11; | ||
644 | } | ||
645 | } | ||
646 | |||
647 | ptd->dw2 |= cpu_to_le32(period); | ||
648 | ptd->dw4 = cpu_to_le32(usof); | ||
649 | } | ||
650 | |||
651 | static void transform_into_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, | ||
652 | struct isp1760_qtd *qtd, struct urb *urb, | ||
653 | u32 payload, struct ptd *ptd) | ||
654 | { | ||
655 | transform_into_atl(priv, qh, qtd, urb, payload, ptd); | ||
656 | transform_add_int(priv, qh, qtd, urb, payload, ptd); | ||
657 | } | ||
658 | |||
659 | static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len, | ||
660 | u32 token) | ||
661 | { | ||
662 | int count; | ||
663 | |||
664 | qtd->data_buffer = databuffer; | ||
665 | qtd->packet_type = GET_QTD_TOKEN_TYPE(token); | ||
666 | qtd->toggle = GET_DATA_TOGGLE(token); | ||
667 | |||
668 | if (len > HC_ATL_PL_SIZE) | ||
669 | count = HC_ATL_PL_SIZE; | ||
670 | else | ||
671 | count = len; | ||
672 | |||
673 | qtd->length = count; | ||
674 | return count; | ||
675 | } | ||
676 | |||
677 | static int check_error(struct ptd *ptd) | ||
678 | { | ||
679 | int error = 0; | ||
680 | u32 dw3; | ||
681 | |||
682 | dw3 = le32_to_cpu(ptd->dw3); | ||
683 | if (dw3 & DW3_HALT_BIT) | ||
684 | error = -EPIPE; | ||
685 | |||
686 | if (dw3 & DW3_ERROR_BIT) { | ||
687 | printk(KERN_ERR "error bit is set in DW3\n"); | ||
688 | error = -EPIPE; | ||
689 | } | ||
690 | |||
691 | if (dw3 & DW3_QTD_ACTIVE) { | ||
692 | printk(KERN_ERR "transfer active bit is set DW3\n"); | ||
693 | printk(KERN_ERR "nak counter: %d, rl: %d\n", (dw3 >> 19) & 0xf, | ||
694 | (le32_to_cpu(ptd->dw2) >> 25) & 0xf); | ||
695 | } | ||
696 | |||
697 | return error; | ||
698 | } | ||
699 | |||
700 | static void check_int_err_status(u32 dw4) | ||
701 | { | ||
702 | u32 i; | ||
703 | |||
704 | dw4 >>= 8; | ||
705 | |||
706 | for (i = 0; i < 8; i++) { | ||
707 | switch (dw4 & 0x7) { | ||
708 | case INT_UNDERRUN: | ||
709 | printk(KERN_ERR "ERROR: under run , %d\n", i); | ||
710 | break; | ||
711 | |||
712 | case INT_EXACT: | ||
713 | printk(KERN_ERR "ERROR: transaction error, %d\n", i); | ||
714 | break; | ||
715 | |||
716 | case INT_BABBLE: | ||
717 | printk(KERN_ERR "ERROR: babble error, %d\n", i); | ||
718 | break; | ||
719 | } | ||
720 | dw4 >>= 3; | ||
721 | } | ||
722 | } | ||
723 | |||
724 | static void enqueue_one_qtd(struct isp1760_qtd *qtd, struct isp1760_hcd *priv, | ||
725 | u32 payload) | ||
726 | { | ||
727 | u32 token; | ||
728 | struct usb_hcd *hcd = priv_to_hcd(priv); | ||
729 | |||
730 | token = qtd->packet_type; | ||
731 | |||
732 | if (qtd->length && (qtd->length <= HC_ATL_PL_SIZE)) { | ||
733 | switch (token) { | ||
734 | case IN_PID: | ||
735 | break; | ||
736 | case OUT_PID: | ||
737 | case SETUP_PID: | ||
738 | priv_write_copy(priv, qtd->data_buffer, | ||
739 | hcd->regs + payload, | ||
740 | qtd->length); | ||
741 | } | ||
742 | } | ||
743 | } | ||
744 | |||
745 | static void enqueue_one_atl_qtd(u32 atl_regs, u32 payload, | ||
746 | struct isp1760_hcd *priv, struct isp1760_qh *qh, | ||
747 | struct urb *urb, u32 slot, struct isp1760_qtd *qtd) | ||
748 | { | ||
749 | struct ptd ptd; | ||
750 | struct usb_hcd *hcd = priv_to_hcd(priv); | ||
751 | |||
752 | transform_into_atl(priv, qh, qtd, urb, payload, &ptd); | ||
753 | priv_write_copy(priv, (u32 *)&ptd, hcd->regs + atl_regs, sizeof(ptd)); | ||
754 | enqueue_one_qtd(qtd, priv, payload); | ||
755 | |||
756 | priv->atl_ints[slot].urb = urb; | ||
757 | priv->atl_ints[slot].qh = qh; | ||
758 | priv->atl_ints[slot].qtd = qtd; | ||
759 | priv->atl_ints[slot].data_buffer = qtd->data_buffer; | ||
760 | priv->atl_ints[slot].payload = payload; | ||
761 | qtd->status |= URB_ENQUEUED | URB_TYPE_ATL; | ||
762 | qtd->status |= slot << 16; | ||
763 | } | ||
764 | |||
765 | static void enqueue_one_int_qtd(u32 int_regs, u32 payload, | ||
766 | struct isp1760_hcd *priv, struct isp1760_qh *qh, | ||
767 | struct urb *urb, u32 slot, struct isp1760_qtd *qtd) | ||
768 | { | ||
769 | struct ptd ptd; | ||
770 | struct usb_hcd *hcd = priv_to_hcd(priv); | ||
771 | |||
772 | transform_into_int(priv, qh, qtd, urb, payload, &ptd); | ||
773 | priv_write_copy(priv, (u32 *)&ptd, hcd->regs + int_regs, sizeof(ptd)); | ||
774 | enqueue_one_qtd(qtd, priv, payload); | ||
775 | |||
776 | priv->int_ints[slot].urb = urb; | ||
777 | priv->int_ints[slot].qh = qh; | ||
778 | priv->int_ints[slot].qtd = qtd; | ||
779 | priv->int_ints[slot].data_buffer = qtd->data_buffer; | ||
780 | priv->int_ints[slot].payload = payload; | ||
781 | qtd->status |= URB_ENQUEUED | URB_TYPE_INT; | ||
782 | qtd->status |= slot << 16; | ||
783 | } | ||
784 | |||
785 | void enqueue_an_ATL_packet(struct usb_hcd *hcd, struct isp1760_qh *qh, | ||
786 | struct isp1760_qtd *qtd) | ||
787 | { | ||
788 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
789 | u32 skip_map, or_map; | ||
790 | u32 queue_entry; | ||
791 | u32 slot; | ||
792 | u32 atl_regs, payload; | ||
793 | u32 buffstatus; | ||
794 | |||
795 | skip_map = isp1760_readl(hcd->regs + HC_ATL_PTD_SKIPMAP_REG); | ||
796 | |||
797 | BUG_ON(!skip_map); | ||
798 | slot = __ffs(skip_map); | ||
799 | queue_entry = 1 << slot; | ||
800 | |||
801 | atl_regs = ATL_REGS_OFFSET + slot * sizeof(struct ptd); | ||
802 | |||
803 | payload = alloc_mem(priv, qtd->length); | ||
804 | |||
805 | enqueue_one_atl_qtd(atl_regs, payload, priv, qh, qtd->urb, slot, qtd); | ||
806 | |||
807 | or_map = isp1760_readl(hcd->regs + HC_ATL_IRQ_MASK_OR_REG); | ||
808 | or_map |= queue_entry; | ||
809 | isp1760_writel(or_map, hcd->regs + HC_ATL_IRQ_MASK_OR_REG); | ||
810 | |||
811 | skip_map &= ~queue_entry; | ||
812 | isp1760_writel(skip_map, hcd->regs + HC_ATL_PTD_SKIPMAP_REG); | ||
813 | |||
814 | buffstatus = isp1760_readl(hcd->regs + HC_BUFFER_STATUS_REG); | ||
815 | buffstatus |= ATL_BUFFER; | ||
816 | isp1760_writel(buffstatus, hcd->regs + HC_BUFFER_STATUS_REG); | ||
817 | } | ||
818 | |||
819 | void enqueue_an_INT_packet(struct usb_hcd *hcd, struct isp1760_qh *qh, | ||
820 | struct isp1760_qtd *qtd) | ||
821 | { | ||
822 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
823 | u32 skip_map, or_map; | ||
824 | u32 queue_entry; | ||
825 | u32 slot; | ||
826 | u32 int_regs, payload; | ||
827 | u32 buffstatus; | ||
828 | |||
829 | skip_map = isp1760_readl(hcd->regs + HC_INT_PTD_SKIPMAP_REG); | ||
830 | |||
831 | BUG_ON(!skip_map); | ||
832 | slot = __ffs(skip_map); | ||
833 | queue_entry = 1 << slot; | ||
834 | |||
835 | int_regs = INT_REGS_OFFSET + slot * sizeof(struct ptd); | ||
836 | |||
837 | payload = alloc_mem(priv, qtd->length); | ||
838 | |||
839 | enqueue_one_int_qtd(int_regs, payload, priv, qh, qtd->urb, slot, qtd); | ||
840 | |||
841 | or_map = isp1760_readl(hcd->regs + HC_INT_IRQ_MASK_OR_REG); | ||
842 | or_map |= queue_entry; | ||
843 | isp1760_writel(or_map, hcd->regs + HC_INT_IRQ_MASK_OR_REG); | ||
844 | |||
845 | skip_map &= ~queue_entry; | ||
846 | isp1760_writel(skip_map, hcd->regs + HC_INT_PTD_SKIPMAP_REG); | ||
847 | |||
848 | buffstatus = isp1760_readl(hcd->regs + HC_BUFFER_STATUS_REG); | ||
849 | buffstatus |= INT_BUFFER; | ||
850 | isp1760_writel(buffstatus, hcd->regs + HC_BUFFER_STATUS_REG); | ||
851 | } | ||
852 | |||
853 | static void isp1760_urb_done(struct isp1760_hcd *priv, struct urb *urb, int status) | ||
854 | __releases(priv->lock) | ||
855 | __acquires(priv->lock) | ||
856 | { | ||
857 | if (!urb->unlinked) { | ||
858 | if (status == -EINPROGRESS) | ||
859 | status = 0; | ||
860 | } | ||
861 | |||
862 | /* complete() can reenter this HCD */ | ||
863 | usb_hcd_unlink_urb_from_ep(priv_to_hcd(priv), urb); | ||
864 | spin_unlock(&priv->lock); | ||
865 | usb_hcd_giveback_urb(priv_to_hcd(priv), urb, status); | ||
866 | spin_lock(&priv->lock); | ||
867 | } | ||
868 | |||
869 | static void isp1760_qtd_free(struct isp1760_qtd *qtd) | ||
870 | { | ||
871 | kmem_cache_free(qtd_cachep, qtd); | ||
872 | } | ||
873 | |||
874 | static struct isp1760_qtd *clean_this_qtd(struct isp1760_qtd *qtd) | ||
875 | { | ||
876 | struct isp1760_qtd *tmp_qtd; | ||
877 | |||
878 | tmp_qtd = qtd->hw_next; | ||
879 | list_del(&qtd->qtd_list); | ||
880 | isp1760_qtd_free(qtd); | ||
881 | return tmp_qtd; | ||
882 | } | ||
883 | |||
884 | /* | ||
885 | * Remove this QTD from the QH list and free its memory. If this QTD | ||
886 | * isn't the last one than remove also his successor(s). | ||
887 | * Returns the QTD which is part of an new URB and should be enqueued. | ||
888 | */ | ||
889 | static struct isp1760_qtd *clean_up_qtdlist(struct isp1760_qtd *qtd) | ||
890 | { | ||
891 | struct isp1760_qtd *tmp_qtd; | ||
892 | int last_one; | ||
893 | |||
894 | do { | ||
895 | tmp_qtd = qtd->hw_next; | ||
896 | last_one = qtd->status & URB_COMPLETE_NOTIFY; | ||
897 | list_del(&qtd->qtd_list); | ||
898 | isp1760_qtd_free(qtd); | ||
899 | qtd = tmp_qtd; | ||
900 | } while (!last_one && qtd); | ||
901 | |||
902 | return qtd; | ||
903 | } | ||
904 | |||
905 | static void do_atl_int(struct usb_hcd *usb_hcd) | ||
906 | { | ||
907 | struct isp1760_hcd *priv = hcd_to_priv(usb_hcd); | ||
908 | u32 done_map, skip_map; | ||
909 | struct ptd ptd; | ||
910 | struct urb *urb = NULL; | ||
911 | u32 atl_regs_base; | ||
912 | u32 atl_regs; | ||
913 | u32 queue_entry; | ||
914 | u32 payload; | ||
915 | u32 length; | ||
916 | u32 or_map; | ||
917 | u32 status = -EINVAL; | ||
918 | int error; | ||
919 | struct isp1760_qtd *qtd; | ||
920 | struct isp1760_qh *qh; | ||
921 | u32 rl; | ||
922 | u32 nakcount; | ||
923 | |||
924 | done_map = isp1760_readl(usb_hcd->regs + | ||
925 | HC_ATL_PTD_DONEMAP_REG); | ||
926 | skip_map = isp1760_readl(usb_hcd->regs + | ||
927 | HC_ATL_PTD_SKIPMAP_REG); | ||
928 | |||
929 | or_map = isp1760_readl(usb_hcd->regs + HC_ATL_IRQ_MASK_OR_REG); | ||
930 | or_map &= ~done_map; | ||
931 | isp1760_writel(or_map, usb_hcd->regs + HC_ATL_IRQ_MASK_OR_REG); | ||
932 | |||
933 | atl_regs_base = ATL_REGS_OFFSET; | ||
934 | while (done_map) { | ||
935 | u32 dw1; | ||
936 | u32 dw2; | ||
937 | u32 dw3; | ||
938 | |||
939 | status = 0; | ||
940 | |||
941 | queue_entry = __ffs(done_map); | ||
942 | done_map &= ~(1 << queue_entry); | ||
943 | skip_map |= 1 << queue_entry; | ||
944 | |||
945 | atl_regs = atl_regs_base + queue_entry * sizeof(struct ptd); | ||
946 | |||
947 | urb = priv->atl_ints[queue_entry].urb; | ||
948 | qtd = priv->atl_ints[queue_entry].qtd; | ||
949 | qh = priv->atl_ints[queue_entry].qh; | ||
950 | payload = priv->atl_ints[queue_entry].payload; | ||
951 | |||
952 | if (!qh) { | ||
953 | printk(KERN_ERR "qh is 0\n"); | ||
954 | continue; | ||
955 | } | ||
956 | priv_read_copy(priv, (u32 *)&ptd, usb_hcd->regs + atl_regs, | ||
957 | atl_regs, sizeof(ptd)); | ||
958 | |||
959 | dw1 = le32_to_cpu(ptd.dw1); | ||
960 | dw2 = le32_to_cpu(ptd.dw2); | ||
961 | dw3 = le32_to_cpu(ptd.dw3); | ||
962 | rl = (dw2 >> 25) & 0x0f; | ||
963 | nakcount = (dw3 >> 19) & 0xf; | ||
964 | |||
965 | /* Transfer Error, *but* active and no HALT -> reload */ | ||
966 | if ((dw3 & DW3_ERROR_BIT) && (dw3 & DW3_QTD_ACTIVE) && | ||
967 | !(dw3 & DW3_HALT_BIT)) { | ||
968 | |||
969 | /* according to ppriv code, we have to | ||
970 | * reload this one if trasfered bytes != requested bytes | ||
971 | * else act like everything went smooth.. | ||
972 | * XXX This just doesn't feel right and hasn't | ||
973 | * triggered so far. | ||
974 | */ | ||
975 | |||
976 | length = PTD_XFERRED_LENGTH(dw3); | ||
977 | printk(KERN_ERR "Should reload now.... transfered %d " | ||
978 | "of %zu\n", length, qtd->length); | ||
979 | BUG(); | ||
980 | } | ||
981 | |||
982 | if (!nakcount && (dw3 & DW3_QTD_ACTIVE)) { | ||
983 | u32 buffstatus; | ||
984 | |||
985 | /* XXX | ||
986 | * NAKs are handled in HW by the chip. Usually if the | ||
987 | * device is not able to send data fast enough. | ||
988 | * This did not trigger for a long time now. | ||
989 | */ | ||
990 | printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: " | ||
991 | "%d of %d done: %08x cur: %08x\n", qtd, | ||
992 | urb, qh, PTD_XFERRED_LENGTH(dw3), | ||
993 | qtd->length, done_map, | ||
994 | (1 << queue_entry)); | ||
995 | |||
996 | /* RL counter = ERR counter */ | ||
997 | dw3 &= ~(0xf << 19); | ||
998 | dw3 |= rl << 19; | ||
999 | dw3 &= ~(3 << (55 - 32)); | ||
1000 | dw3 |= ERR_COUNTER << (55 - 32); | ||
1001 | |||
1002 | /* | ||
1003 | * It is not needed to write skip map back because it | ||
1004 | * is unchanged. Just make sure that this entry is | ||
1005 | * unskipped once it gets written to the HW. | ||
1006 | */ | ||
1007 | skip_map &= ~(1 << queue_entry); | ||
1008 | or_map = isp1760_readl(usb_hcd->regs + | ||
1009 | HC_ATL_IRQ_MASK_OR_REG); | ||
1010 | or_map |= 1 << queue_entry; | ||
1011 | isp1760_writel(or_map, usb_hcd->regs + | ||
1012 | HC_ATL_IRQ_MASK_OR_REG); | ||
1013 | |||
1014 | ptd.dw3 = cpu_to_le32(dw3); | ||
1015 | priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs + | ||
1016 | atl_regs, sizeof(ptd)); | ||
1017 | |||
1018 | ptd.dw0 |= __constant_cpu_to_le32(PTD_VALID); | ||
1019 | priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs + | ||
1020 | atl_regs, sizeof(ptd)); | ||
1021 | |||
1022 | buffstatus = isp1760_readl(usb_hcd->regs + | ||
1023 | HC_BUFFER_STATUS_REG); | ||
1024 | buffstatus |= ATL_BUFFER; | ||
1025 | isp1760_writel(buffstatus, usb_hcd->regs + | ||
1026 | HC_BUFFER_STATUS_REG); | ||
1027 | continue; | ||
1028 | } | ||
1029 | |||
1030 | error = check_error(&ptd); | ||
1031 | if (error) { | ||
1032 | status = error; | ||
1033 | priv->atl_ints[queue_entry].qh->toggle = 0; | ||
1034 | priv->atl_ints[queue_entry].qh->ping = 0; | ||
1035 | urb->status = -EPIPE; | ||
1036 | |||
1037 | #if 0 | ||
1038 | printk(KERN_ERR "Error in %s().\n", __func__); | ||
1039 | printk(KERN_ERR "IN dw0: %08x dw1: %08x dw2: %08x " | ||
1040 | "dw3: %08x dw4: %08x dw5: %08x dw6: " | ||
1041 | "%08x dw7: %08x\n", | ||
1042 | ptd.dw0, ptd.dw1, ptd.dw2, ptd.dw3, | ||
1043 | ptd.dw4, ptd.dw5, ptd.dw6, ptd.dw7); | ||
1044 | #endif | ||
1045 | } else { | ||
1046 | if (usb_pipetype(urb->pipe) == PIPE_BULK) { | ||
1047 | priv->atl_ints[queue_entry].qh->toggle = dw3 & | ||
1048 | (1 << 25); | ||
1049 | priv->atl_ints[queue_entry].qh->ping = dw3 & | ||
1050 | (1 << 26); | ||
1051 | } | ||
1052 | } | ||
1053 | |||
1054 | length = PTD_XFERRED_LENGTH(dw3); | ||
1055 | if (length) { | ||
1056 | switch (DW1_GET_PID(dw1)) { | ||
1057 | case IN_PID: | ||
1058 | priv_read_copy(priv, | ||
1059 | priv->atl_ints[queue_entry].data_buffer, | ||
1060 | usb_hcd->regs + payload, payload, | ||
1061 | length); | ||
1062 | |||
1063 | case OUT_PID: | ||
1064 | |||
1065 | urb->actual_length += length; | ||
1066 | |||
1067 | case SETUP_PID: | ||
1068 | break; | ||
1069 | } | ||
1070 | } | ||
1071 | |||
1072 | priv->atl_ints[queue_entry].data_buffer = NULL; | ||
1073 | priv->atl_ints[queue_entry].urb = NULL; | ||
1074 | priv->atl_ints[queue_entry].qtd = NULL; | ||
1075 | priv->atl_ints[queue_entry].qh = NULL; | ||
1076 | |||
1077 | free_mem(priv, payload); | ||
1078 | |||
1079 | isp1760_writel(skip_map, usb_hcd->regs + | ||
1080 | HC_ATL_PTD_SKIPMAP_REG); | ||
1081 | |||
1082 | if (urb->status == -EPIPE) { | ||
1083 | /* HALT was received */ | ||
1084 | |||
1085 | qtd = clean_up_qtdlist(qtd); | ||
1086 | isp1760_urb_done(priv, urb, urb->status); | ||
1087 | |||
1088 | } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) { | ||
1089 | /* short BULK received */ | ||
1090 | |||
1091 | printk(KERN_ERR "short bulk, %d instead %d\n", length, | ||
1092 | qtd->length); | ||
1093 | if (urb->transfer_flags & URB_SHORT_NOT_OK) { | ||
1094 | urb->status = -EREMOTEIO; | ||
1095 | printk(KERN_ERR "not okey\n"); | ||
1096 | } | ||
1097 | |||
1098 | if (urb->status == -EINPROGRESS) | ||
1099 | urb->status = 0; | ||
1100 | |||
1101 | qtd = clean_up_qtdlist(qtd); | ||
1102 | |||
1103 | isp1760_urb_done(priv, urb, urb->status); | ||
1104 | |||
1105 | } else if (qtd->status & URB_COMPLETE_NOTIFY) { | ||
1106 | /* that was the last qtd of that URB */ | ||
1107 | |||
1108 | if (urb->status == -EINPROGRESS) | ||
1109 | urb->status = 0; | ||
1110 | |||
1111 | qtd = clean_this_qtd(qtd); | ||
1112 | isp1760_urb_done(priv, urb, urb->status); | ||
1113 | |||
1114 | } else { | ||
1115 | /* next QTD of this URB */ | ||
1116 | |||
1117 | qtd = clean_this_qtd(qtd); | ||
1118 | BUG_ON(!qtd); | ||
1119 | } | ||
1120 | |||
1121 | if (qtd) | ||
1122 | enqueue_an_ATL_packet(usb_hcd, qh, qtd); | ||
1123 | |||
1124 | skip_map = isp1760_readl(usb_hcd->regs + | ||
1125 | HC_ATL_PTD_SKIPMAP_REG); | ||
1126 | } | ||
1127 | } | ||
1128 | |||
1129 | static void do_intl_int(struct usb_hcd *usb_hcd) | ||
1130 | { | ||
1131 | struct isp1760_hcd *priv = hcd_to_priv(usb_hcd); | ||
1132 | u32 done_map, skip_map; | ||
1133 | struct ptd ptd; | ||
1134 | struct urb *urb = NULL; | ||
1135 | u32 int_regs; | ||
1136 | u32 int_regs_base; | ||
1137 | u32 payload; | ||
1138 | u32 length; | ||
1139 | u32 or_map; | ||
1140 | int error; | ||
1141 | u32 queue_entry; | ||
1142 | struct isp1760_qtd *qtd; | ||
1143 | struct isp1760_qh *qh; | ||
1144 | |||
1145 | done_map = isp1760_readl(usb_hcd->regs + | ||
1146 | HC_INT_PTD_DONEMAP_REG); | ||
1147 | skip_map = isp1760_readl(usb_hcd->regs + | ||
1148 | HC_INT_PTD_SKIPMAP_REG); | ||
1149 | |||
1150 | or_map = isp1760_readl(usb_hcd->regs + HC_INT_IRQ_MASK_OR_REG); | ||
1151 | or_map &= ~done_map; | ||
1152 | isp1760_writel(or_map, usb_hcd->regs + HC_INT_IRQ_MASK_OR_REG); | ||
1153 | |||
1154 | int_regs_base = INT_REGS_OFFSET; | ||
1155 | |||
1156 | while (done_map) { | ||
1157 | u32 dw1; | ||
1158 | u32 dw3; | ||
1159 | |||
1160 | queue_entry = __ffs(done_map); | ||
1161 | done_map &= ~(1 << queue_entry); | ||
1162 | skip_map |= 1 << queue_entry; | ||
1163 | |||
1164 | int_regs = int_regs_base + queue_entry * sizeof(struct ptd); | ||
1165 | urb = priv->int_ints[queue_entry].urb; | ||
1166 | qtd = priv->int_ints[queue_entry].qtd; | ||
1167 | qh = priv->int_ints[queue_entry].qh; | ||
1168 | payload = priv->int_ints[queue_entry].payload; | ||
1169 | |||
1170 | if (!qh) { | ||
1171 | printk(KERN_ERR "(INT) qh is 0\n"); | ||
1172 | continue; | ||
1173 | } | ||
1174 | |||
1175 | priv_read_copy(priv, (u32 *)&ptd, usb_hcd->regs + int_regs, | ||
1176 | int_regs, sizeof(ptd)); | ||
1177 | dw1 = le32_to_cpu(ptd.dw1); | ||
1178 | dw3 = le32_to_cpu(ptd.dw3); | ||
1179 | check_int_err_status(le32_to_cpu(ptd.dw4)); | ||
1180 | |||
1181 | error = check_error(&ptd); | ||
1182 | if (error) { | ||
1183 | #if 0 | ||
1184 | printk(KERN_ERR "Error in %s().\n", __func__); | ||
1185 | printk(KERN_ERR "IN dw0: %08x dw1: %08x dw2: %08x " | ||
1186 | "dw3: %08x dw4: %08x dw5: %08x dw6: " | ||
1187 | "%08x dw7: %08x\n", | ||
1188 | ptd.dw0, ptd.dw1, ptd.dw2, ptd.dw3, | ||
1189 | ptd.dw4, ptd.dw5, ptd.dw6, ptd.dw7); | ||
1190 | #endif | ||
1191 | urb->status = -EPIPE; | ||
1192 | priv->int_ints[queue_entry].qh->toggle = 0; | ||
1193 | priv->int_ints[queue_entry].qh->ping = 0; | ||
1194 | |||
1195 | } else { | ||
1196 | priv->int_ints[queue_entry].qh->toggle = | ||
1197 | dw3 & (1 << 25); | ||
1198 | priv->int_ints[queue_entry].qh->ping = dw3 & (1 << 26); | ||
1199 | } | ||
1200 | |||
1201 | if (urb->dev->speed != USB_SPEED_HIGH) | ||
1202 | length = PTD_XFERRED_LENGTH_LO(dw3); | ||
1203 | else | ||
1204 | length = PTD_XFERRED_LENGTH(dw3); | ||
1205 | |||
1206 | if (length) { | ||
1207 | switch (DW1_GET_PID(dw1)) { | ||
1208 | case IN_PID: | ||
1209 | priv_read_copy(priv, | ||
1210 | priv->int_ints[queue_entry].data_buffer, | ||
1211 | usb_hcd->regs + payload , payload, | ||
1212 | length); | ||
1213 | case OUT_PID: | ||
1214 | |||
1215 | urb->actual_length += length; | ||
1216 | |||
1217 | case SETUP_PID: | ||
1218 | break; | ||
1219 | } | ||
1220 | } | ||
1221 | |||
1222 | priv->int_ints[queue_entry].data_buffer = NULL; | ||
1223 | priv->int_ints[queue_entry].urb = NULL; | ||
1224 | priv->int_ints[queue_entry].qtd = NULL; | ||
1225 | priv->int_ints[queue_entry].qh = NULL; | ||
1226 | |||
1227 | isp1760_writel(skip_map, usb_hcd->regs + | ||
1228 | HC_INT_PTD_SKIPMAP_REG); | ||
1229 | free_mem(priv, payload); | ||
1230 | |||
1231 | if (urb->status == -EPIPE) { | ||
1232 | /* HALT received */ | ||
1233 | |||
1234 | qtd = clean_up_qtdlist(qtd); | ||
1235 | isp1760_urb_done(priv, urb, urb->status); | ||
1236 | |||
1237 | } else if (qtd->status & URB_COMPLETE_NOTIFY) { | ||
1238 | |||
1239 | if (urb->status == -EINPROGRESS) | ||
1240 | urb->status = 0; | ||
1241 | |||
1242 | qtd = clean_this_qtd(qtd); | ||
1243 | isp1760_urb_done(priv, urb, urb->status); | ||
1244 | |||
1245 | } else { | ||
1246 | /* next QTD of this URB */ | ||
1247 | |||
1248 | qtd = clean_this_qtd(qtd); | ||
1249 | BUG_ON(!qtd); | ||
1250 | } | ||
1251 | |||
1252 | if (qtd) | ||
1253 | enqueue_an_INT_packet(usb_hcd, qh, qtd); | ||
1254 | |||
1255 | skip_map = isp1760_readl(usb_hcd->regs + | ||
1256 | HC_INT_PTD_SKIPMAP_REG); | ||
1257 | } | ||
1258 | } | ||
1259 | |||
1260 | #define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff) | ||
1261 | static struct isp1760_qh *qh_make(struct isp1760_hcd *priv, struct urb *urb, | ||
1262 | gfp_t flags) | ||
1263 | { | ||
1264 | struct isp1760_qh *qh; | ||
1265 | int is_input, type; | ||
1266 | |||
1267 | qh = isp1760_qh_alloc(priv, flags); | ||
1268 | if (!qh) | ||
1269 | return qh; | ||
1270 | |||
1271 | /* | ||
1272 | * init endpoint/device data for this QH | ||
1273 | */ | ||
1274 | is_input = usb_pipein(urb->pipe); | ||
1275 | type = usb_pipetype(urb->pipe); | ||
1276 | |||
1277 | if (type == PIPE_INTERRUPT) { | ||
1278 | |||
1279 | if (urb->dev->speed == USB_SPEED_HIGH) { | ||
1280 | |||
1281 | qh->period = urb->interval >> 3; | ||
1282 | if (qh->period == 0 && urb->interval != 1) { | ||
1283 | /* NOTE interval 2 or 4 uframes could work. | ||
1284 | * But interval 1 scheduling is simpler, and | ||
1285 | * includes high bandwidth. | ||
1286 | */ | ||
1287 | printk(KERN_ERR "intr period %d uframes, NYET!", | ||
1288 | urb->interval); | ||
1289 | qh_destroy(qh); | ||
1290 | return NULL; | ||
1291 | } | ||
1292 | } else { | ||
1293 | qh->period = urb->interval; | ||
1294 | } | ||
1295 | } | ||
1296 | |||
1297 | /* support for tt scheduling, and access to toggles */ | ||
1298 | qh->dev = urb->dev; | ||
1299 | |||
1300 | if (!usb_pipecontrol(urb->pipe)) | ||
1301 | usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), !is_input, | ||
1302 | 1); | ||
1303 | return qh; | ||
1304 | } | ||
1305 | |||
1306 | /* | ||
1307 | * For control/bulk/interrupt, return QH with these TDs appended. | ||
1308 | * Allocates and initializes the QH if necessary. | ||
1309 | * Returns null if it can't allocate a QH it needs to. | ||
1310 | * If the QH has TDs (urbs) already, that's great. | ||
1311 | */ | ||
1312 | static struct isp1760_qh *qh_append_tds(struct isp1760_hcd *priv, | ||
1313 | struct urb *urb, struct list_head *qtd_list, int epnum, | ||
1314 | void **ptr) | ||
1315 | { | ||
1316 | struct isp1760_qh *qh; | ||
1317 | struct isp1760_qtd *qtd; | ||
1318 | struct isp1760_qtd *prev_qtd; | ||
1319 | |||
1320 | qh = (struct isp1760_qh *)*ptr; | ||
1321 | if (!qh) { | ||
1322 | /* can't sleep here, we have priv->lock... */ | ||
1323 | qh = qh_make(priv, urb, GFP_ATOMIC); | ||
1324 | if (!qh) | ||
1325 | return qh; | ||
1326 | *ptr = qh; | ||
1327 | } | ||
1328 | |||
1329 | qtd = list_entry(qtd_list->next, struct isp1760_qtd, | ||
1330 | qtd_list); | ||
1331 | if (!list_empty(&qh->qtd_list)) | ||
1332 | prev_qtd = list_entry(qh->qtd_list.prev, | ||
1333 | struct isp1760_qtd, qtd_list); | ||
1334 | else | ||
1335 | prev_qtd = NULL; | ||
1336 | |||
1337 | list_splice(qtd_list, qh->qtd_list.prev); | ||
1338 | if (prev_qtd) { | ||
1339 | BUG_ON(prev_qtd->hw_next); | ||
1340 | prev_qtd->hw_next = qtd; | ||
1341 | } | ||
1342 | |||
1343 | urb->hcpriv = qh; | ||
1344 | return qh; | ||
1345 | } | ||
1346 | |||
1347 | static void qtd_list_free(struct isp1760_hcd *priv, struct urb *urb, | ||
1348 | struct list_head *qtd_list) | ||
1349 | { | ||
1350 | struct list_head *entry, *temp; | ||
1351 | |||
1352 | list_for_each_safe(entry, temp, qtd_list) { | ||
1353 | struct isp1760_qtd *qtd; | ||
1354 | |||
1355 | qtd = list_entry(entry, struct isp1760_qtd, qtd_list); | ||
1356 | list_del(&qtd->qtd_list); | ||
1357 | isp1760_qtd_free(qtd); | ||
1358 | } | ||
1359 | } | ||
1360 | |||
1361 | static int isp1760_prepare_enqueue(struct isp1760_hcd *priv, struct urb *urb, | ||
1362 | struct list_head *qtd_list, gfp_t mem_flags, packet_enqueue *p) | ||
1363 | { | ||
1364 | struct isp1760_qtd *qtd; | ||
1365 | int epnum; | ||
1366 | unsigned long flags; | ||
1367 | struct isp1760_qh *qh = NULL; | ||
1368 | int rc; | ||
1369 | int qh_busy; | ||
1370 | |||
1371 | qtd = list_entry(qtd_list->next, struct isp1760_qtd, qtd_list); | ||
1372 | epnum = urb->ep->desc.bEndpointAddress; | ||
1373 | |||
1374 | spin_lock_irqsave(&priv->lock, flags); | ||
1375 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &priv_to_hcd(priv)->flags)) { | ||
1376 | rc = -ESHUTDOWN; | ||
1377 | goto done; | ||
1378 | } | ||
1379 | rc = usb_hcd_link_urb_to_ep(priv_to_hcd(priv), urb); | ||
1380 | if (rc) | ||
1381 | goto done; | ||
1382 | |||
1383 | qh = urb->ep->hcpriv; | ||
1384 | if (qh) | ||
1385 | qh_busy = !list_empty(&qh->qtd_list); | ||
1386 | else | ||
1387 | qh_busy = 0; | ||
1388 | |||
1389 | qh = qh_append_tds(priv, urb, qtd_list, epnum, &urb->ep->hcpriv); | ||
1390 | if (!qh) { | ||
1391 | usb_hcd_unlink_urb_from_ep(priv_to_hcd(priv), urb); | ||
1392 | rc = -ENOMEM; | ||
1393 | goto done; | ||
1394 | } | ||
1395 | |||
1396 | if (!qh_busy) | ||
1397 | p(priv_to_hcd(priv), qh, qtd); | ||
1398 | |||
1399 | done: | ||
1400 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1401 | if (!qh) | ||
1402 | qtd_list_free(priv, urb, qtd_list); | ||
1403 | return rc; | ||
1404 | } | ||
1405 | |||
1406 | static struct isp1760_qtd *isp1760_qtd_alloc(struct isp1760_hcd *priv, | ||
1407 | gfp_t flags) | ||
1408 | { | ||
1409 | struct isp1760_qtd *qtd; | ||
1410 | |||
1411 | qtd = kmem_cache_zalloc(qtd_cachep, flags); | ||
1412 | if (qtd) | ||
1413 | INIT_LIST_HEAD(&qtd->qtd_list); | ||
1414 | |||
1415 | return qtd; | ||
1416 | } | ||
1417 | |||
1418 | /* | ||
1419 | * create a list of filled qtds for this URB; won't link into qh. | ||
1420 | */ | ||
1421 | static struct list_head *qh_urb_transaction(struct isp1760_hcd *priv, | ||
1422 | struct urb *urb, struct list_head *head, gfp_t flags) | ||
1423 | { | ||
1424 | struct isp1760_qtd *qtd, *qtd_prev; | ||
1425 | void *buf; | ||
1426 | int len, maxpacket; | ||
1427 | int is_input; | ||
1428 | u32 token; | ||
1429 | |||
1430 | /* | ||
1431 | * URBs map to sequences of QTDs: one logical transaction | ||
1432 | */ | ||
1433 | qtd = isp1760_qtd_alloc(priv, flags); | ||
1434 | if (!qtd) | ||
1435 | return NULL; | ||
1436 | |||
1437 | list_add_tail(&qtd->qtd_list, head); | ||
1438 | qtd->urb = urb; | ||
1439 | urb->status = -EINPROGRESS; | ||
1440 | |||
1441 | token = 0; | ||
1442 | /* for split transactions, SplitXState initialized to zero */ | ||
1443 | |||
1444 | len = urb->transfer_buffer_length; | ||
1445 | is_input = usb_pipein(urb->pipe); | ||
1446 | if (usb_pipecontrol(urb->pipe)) { | ||
1447 | /* SETUP pid */ | ||
1448 | qtd_fill(qtd, urb->setup_packet, | ||
1449 | sizeof(struct usb_ctrlrequest), | ||
1450 | token | SETUP_PID); | ||
1451 | |||
1452 | /* ... and always at least one more pid */ | ||
1453 | token ^= DATA_TOGGLE; | ||
1454 | qtd_prev = qtd; | ||
1455 | qtd = isp1760_qtd_alloc(priv, flags); | ||
1456 | if (!qtd) | ||
1457 | goto cleanup; | ||
1458 | qtd->urb = urb; | ||
1459 | qtd_prev->hw_next = qtd; | ||
1460 | list_add_tail(&qtd->qtd_list, head); | ||
1461 | |||
1462 | /* for zero length DATA stages, STATUS is always IN */ | ||
1463 | if (len == 0) | ||
1464 | token |= IN_PID; | ||
1465 | } | ||
1466 | |||
1467 | /* | ||
1468 | * data transfer stage: buffer setup | ||
1469 | */ | ||
1470 | buf = urb->transfer_buffer; | ||
1471 | |||
1472 | if (is_input) | ||
1473 | token |= IN_PID; | ||
1474 | else | ||
1475 | token |= OUT_PID; | ||
1476 | |||
1477 | maxpacket = max_packet(usb_maxpacket(urb->dev, urb->pipe, !is_input)); | ||
1478 | |||
1479 | /* | ||
1480 | * buffer gets wrapped in one or more qtds; | ||
1481 | * last one may be "short" (including zero len) | ||
1482 | * and may serve as a control status ack | ||
1483 | */ | ||
1484 | for (;;) { | ||
1485 | int this_qtd_len; | ||
1486 | |||
1487 | if (!buf && len) { | ||
1488 | /* XXX This looks like usb storage / SCSI bug */ | ||
1489 | printk(KERN_ERR "buf is null, dma is %08lx len is %d\n", | ||
1490 | (long unsigned)urb->transfer_dma, len); | ||
1491 | WARN_ON(1); | ||
1492 | } | ||
1493 | |||
1494 | this_qtd_len = qtd_fill(qtd, buf, len, token); | ||
1495 | len -= this_qtd_len; | ||
1496 | buf += this_qtd_len; | ||
1497 | |||
1498 | /* qh makes control packets use qtd toggle; maybe switch it */ | ||
1499 | if ((maxpacket & (this_qtd_len + (maxpacket - 1))) == 0) | ||
1500 | token ^= DATA_TOGGLE; | ||
1501 | |||
1502 | if (len <= 0) | ||
1503 | break; | ||
1504 | |||
1505 | qtd_prev = qtd; | ||
1506 | qtd = isp1760_qtd_alloc(priv, flags); | ||
1507 | if (!qtd) | ||
1508 | goto cleanup; | ||
1509 | qtd->urb = urb; | ||
1510 | qtd_prev->hw_next = qtd; | ||
1511 | list_add_tail(&qtd->qtd_list, head); | ||
1512 | } | ||
1513 | |||
1514 | /* | ||
1515 | * control requests may need a terminating data "status" ack; | ||
1516 | * bulk ones may need a terminating short packet (zero length). | ||
1517 | */ | ||
1518 | if (urb->transfer_buffer_length != 0) { | ||
1519 | int one_more = 0; | ||
1520 | |||
1521 | if (usb_pipecontrol(urb->pipe)) { | ||
1522 | one_more = 1; | ||
1523 | /* "in" <--> "out" */ | ||
1524 | token ^= IN_PID; | ||
1525 | /* force DATA1 */ | ||
1526 | token |= DATA_TOGGLE; | ||
1527 | } else if (usb_pipebulk(urb->pipe) | ||
1528 | && (urb->transfer_flags & URB_ZERO_PACKET) | ||
1529 | && !(urb->transfer_buffer_length % maxpacket)) { | ||
1530 | one_more = 1; | ||
1531 | } | ||
1532 | if (one_more) { | ||
1533 | qtd_prev = qtd; | ||
1534 | qtd = isp1760_qtd_alloc(priv, flags); | ||
1535 | if (!qtd) | ||
1536 | goto cleanup; | ||
1537 | qtd->urb = urb; | ||
1538 | qtd_prev->hw_next = qtd; | ||
1539 | list_add_tail(&qtd->qtd_list, head); | ||
1540 | |||
1541 | /* never any data in such packets */ | ||
1542 | qtd_fill(qtd, NULL, 0, token); | ||
1543 | } | ||
1544 | } | ||
1545 | |||
1546 | qtd->status = URB_COMPLETE_NOTIFY; | ||
1547 | return head; | ||
1548 | |||
1549 | cleanup: | ||
1550 | qtd_list_free(priv, urb, head); | ||
1551 | return NULL; | ||
1552 | } | ||
1553 | |||
1554 | static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | ||
1555 | gfp_t mem_flags) | ||
1556 | { | ||
1557 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
1558 | struct list_head qtd_list; | ||
1559 | packet_enqueue *pe; | ||
1560 | |||
1561 | INIT_LIST_HEAD(&qtd_list); | ||
1562 | |||
1563 | switch (usb_pipetype(urb->pipe)) { | ||
1564 | case PIPE_CONTROL: | ||
1565 | case PIPE_BULK: | ||
1566 | |||
1567 | if (!qh_urb_transaction(priv, urb, &qtd_list, mem_flags)) | ||
1568 | return -ENOMEM; | ||
1569 | pe = enqueue_an_ATL_packet; | ||
1570 | break; | ||
1571 | |||
1572 | case PIPE_INTERRUPT: | ||
1573 | if (!qh_urb_transaction(priv, urb, &qtd_list, mem_flags)) | ||
1574 | return -ENOMEM; | ||
1575 | pe = enqueue_an_INT_packet; | ||
1576 | break; | ||
1577 | |||
1578 | case PIPE_ISOCHRONOUS: | ||
1579 | printk(KERN_ERR "PIPE_ISOCHRONOUS ain't supported\n"); | ||
1580 | default: | ||
1581 | return -EPIPE; | ||
1582 | } | ||
1583 | |||
1584 | isp1760_prepare_enqueue(priv, urb, &qtd_list, mem_flags, pe); | ||
1585 | return 0; | ||
1586 | } | ||
1587 | |||
1588 | static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, | ||
1589 | int status) | ||
1590 | { | ||
1591 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
1592 | struct inter_packet_info *ints; | ||
1593 | u32 i; | ||
1594 | u32 reg_base, or_reg, skip_reg; | ||
1595 | int flags; | ||
1596 | struct ptd ptd; | ||
1597 | |||
1598 | switch (usb_pipetype(urb->pipe)) { | ||
1599 | case PIPE_ISOCHRONOUS: | ||
1600 | return -EPIPE; | ||
1601 | break; | ||
1602 | |||
1603 | case PIPE_INTERRUPT: | ||
1604 | ints = priv->int_ints; | ||
1605 | reg_base = INT_REGS_OFFSET; | ||
1606 | or_reg = HC_INT_IRQ_MASK_OR_REG; | ||
1607 | skip_reg = HC_INT_PTD_SKIPMAP_REG; | ||
1608 | break; | ||
1609 | |||
1610 | default: | ||
1611 | ints = priv->atl_ints; | ||
1612 | reg_base = ATL_REGS_OFFSET; | ||
1613 | or_reg = HC_ATL_IRQ_MASK_OR_REG; | ||
1614 | skip_reg = HC_ATL_PTD_SKIPMAP_REG; | ||
1615 | break; | ||
1616 | } | ||
1617 | |||
1618 | memset(&ptd, 0, sizeof(ptd)); | ||
1619 | spin_lock_irqsave(&priv->lock, flags); | ||
1620 | |||
1621 | for (i = 0; i < 32; i++) { | ||
1622 | if (ints->urb == urb) { | ||
1623 | u32 skip_map; | ||
1624 | u32 or_map; | ||
1625 | struct isp1760_qtd *qtd; | ||
1626 | |||
1627 | skip_map = isp1760_readl(hcd->regs + skip_reg); | ||
1628 | skip_map |= 1 << i; | ||
1629 | isp1760_writel(skip_map, hcd->regs + skip_reg); | ||
1630 | |||
1631 | or_map = isp1760_readl(hcd->regs + or_reg); | ||
1632 | or_map &= ~(1 << i); | ||
1633 | isp1760_writel(or_map, hcd->regs + or_reg); | ||
1634 | |||
1635 | priv_write_copy(priv, (u32 *)&ptd, hcd->regs + reg_base | ||
1636 | + i * sizeof(ptd), sizeof(ptd)); | ||
1637 | qtd = ints->qtd; | ||
1638 | |||
1639 | clean_up_qtdlist(qtd); | ||
1640 | |||
1641 | free_mem(priv, ints->payload); | ||
1642 | |||
1643 | ints->urb = NULL; | ||
1644 | ints->qh = NULL; | ||
1645 | ints->qtd = NULL; | ||
1646 | ints->data_buffer = NULL; | ||
1647 | ints->payload = 0; | ||
1648 | |||
1649 | isp1760_urb_done(priv, urb, status); | ||
1650 | break; | ||
1651 | } | ||
1652 | ints++; | ||
1653 | } | ||
1654 | |||
1655 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1656 | return 0; | ||
1657 | } | ||
1658 | |||
1659 | static irqreturn_t isp1760_irq(struct usb_hcd *usb_hcd) | ||
1660 | { | ||
1661 | struct isp1760_hcd *priv = hcd_to_priv(usb_hcd); | ||
1662 | u32 imask; | ||
1663 | irqreturn_t irqret = IRQ_NONE; | ||
1664 | |||
1665 | spin_lock(&priv->lock); | ||
1666 | |||
1667 | if (!(usb_hcd->state & HC_STATE_RUNNING)) | ||
1668 | goto leave; | ||
1669 | |||
1670 | imask = isp1760_readl(usb_hcd->regs + HC_INTERRUPT_REG); | ||
1671 | if (unlikely(!imask)) | ||
1672 | goto leave; | ||
1673 | |||
1674 | isp1760_writel(imask, usb_hcd->regs + HC_INTERRUPT_REG); | ||
1675 | if (imask & HC_ATL_INT) | ||
1676 | do_atl_int(usb_hcd); | ||
1677 | |||
1678 | if (imask & HC_INTL_INT) | ||
1679 | do_intl_int(usb_hcd); | ||
1680 | |||
1681 | irqret = IRQ_HANDLED; | ||
1682 | leave: | ||
1683 | spin_unlock(&priv->lock); | ||
1684 | return irqret; | ||
1685 | } | ||
1686 | |||
1687 | static int isp1760_hub_status_data(struct usb_hcd *hcd, char *buf) | ||
1688 | { | ||
1689 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
1690 | u32 temp, status = 0; | ||
1691 | u32 mask; | ||
1692 | int retval = 1; | ||
1693 | unsigned long flags; | ||
1694 | |||
1695 | /* if !USB_SUSPEND, root hub timers won't get shut down ... */ | ||
1696 | if (!HC_IS_RUNNING(hcd->state)) | ||
1697 | return 0; | ||
1698 | |||
1699 | /* init status to no-changes */ | ||
1700 | buf[0] = 0; | ||
1701 | mask = PORT_CSC; | ||
1702 | |||
1703 | spin_lock_irqsave(&priv->lock, flags); | ||
1704 | temp = isp1760_readl(hcd->regs + HC_PORTSC1); | ||
1705 | |||
1706 | if (temp & PORT_OWNER) { | ||
1707 | if (temp & PORT_CSC) { | ||
1708 | temp &= ~PORT_CSC; | ||
1709 | isp1760_writel(temp, hcd->regs + HC_PORTSC1); | ||
1710 | goto done; | ||
1711 | } | ||
1712 | } | ||
1713 | |||
1714 | /* | ||
1715 | * Return status information even for ports with OWNER set. | ||
1716 | * Otherwise khubd wouldn't see the disconnect event when a | ||
1717 | * high-speed device is switched over to the companion | ||
1718 | * controller by the user. | ||
1719 | */ | ||
1720 | |||
1721 | if ((temp & mask) != 0 | ||
1722 | || ((temp & PORT_RESUME) != 0 | ||
1723 | && time_after_eq(jiffies, | ||
1724 | priv->reset_done))) { | ||
1725 | buf [0] |= 1 << (0 + 1); | ||
1726 | status = STS_PCD; | ||
1727 | } | ||
1728 | /* FIXME autosuspend idle root hubs */ | ||
1729 | done: | ||
1730 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1731 | return status ? retval : 0; | ||
1732 | } | ||
1733 | |||
1734 | static void isp1760_hub_descriptor(struct isp1760_hcd *priv, | ||
1735 | struct usb_hub_descriptor *desc) | ||
1736 | { | ||
1737 | int ports = HCS_N_PORTS(priv->hcs_params); | ||
1738 | u16 temp; | ||
1739 | |||
1740 | desc->bDescriptorType = 0x29; | ||
1741 | /* priv 1.0, 2.3.9 says 20ms max */ | ||
1742 | desc->bPwrOn2PwrGood = 10; | ||
1743 | desc->bHubContrCurrent = 0; | ||
1744 | |||
1745 | desc->bNbrPorts = ports; | ||
1746 | temp = 1 + (ports / 8); | ||
1747 | desc->bDescLength = 7 + 2 * temp; | ||
1748 | |||
1749 | /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */ | ||
1750 | memset(&desc->bitmap[0], 0, temp); | ||
1751 | memset(&desc->bitmap[temp], 0xff, temp); | ||
1752 | |||
1753 | /* per-port overcurrent reporting */ | ||
1754 | temp = 0x0008; | ||
1755 | if (HCS_PPC(priv->hcs_params)) | ||
1756 | /* per-port power control */ | ||
1757 | temp |= 0x0001; | ||
1758 | else | ||
1759 | /* no power switching */ | ||
1760 | temp |= 0x0002; | ||
1761 | desc->wHubCharacteristics = cpu_to_le16(temp); | ||
1762 | } | ||
1763 | |||
1764 | #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) | ||
1765 | |||
1766 | static int check_reset_complete(struct isp1760_hcd *priv, int index, | ||
1767 | u32 __iomem *status_reg, int port_status) | ||
1768 | { | ||
1769 | if (!(port_status & PORT_CONNECT)) | ||
1770 | return port_status; | ||
1771 | |||
1772 | /* if reset finished and it's still not enabled -- handoff */ | ||
1773 | if (!(port_status & PORT_PE)) { | ||
1774 | |||
1775 | printk(KERN_ERR "port %d full speed --> companion\n", | ||
1776 | index + 1); | ||
1777 | |||
1778 | port_status |= PORT_OWNER; | ||
1779 | port_status &= ~PORT_RWC_BITS; | ||
1780 | isp1760_writel(port_status, status_reg); | ||
1781 | |||
1782 | } else | ||
1783 | printk(KERN_ERR "port %d high speed\n", index + 1); | ||
1784 | |||
1785 | return port_status; | ||
1786 | } | ||
1787 | |||
1788 | static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq, | ||
1789 | u16 wValue, u16 wIndex, char *buf, u16 wLength) | ||
1790 | { | ||
1791 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
1792 | int ports = HCS_N_PORTS(priv->hcs_params); | ||
1793 | u32 __iomem *status_reg = hcd->regs + HC_PORTSC1; | ||
1794 | u32 temp, status; | ||
1795 | unsigned long flags; | ||
1796 | int retval = 0; | ||
1797 | unsigned selector; | ||
1798 | |||
1799 | /* | ||
1800 | * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. | ||
1801 | * HCS_INDICATOR may say we can change LEDs to off/amber/green. | ||
1802 | * (track current state ourselves) ... blink for diagnostics, | ||
1803 | * power, "this is the one", etc. EHCI spec supports this. | ||
1804 | */ | ||
1805 | |||
1806 | spin_lock_irqsave(&priv->lock, flags); | ||
1807 | switch (typeReq) { | ||
1808 | case ClearHubFeature: | ||
1809 | switch (wValue) { | ||
1810 | case C_HUB_LOCAL_POWER: | ||
1811 | case C_HUB_OVER_CURRENT: | ||
1812 | /* no hub-wide feature/status flags */ | ||
1813 | break; | ||
1814 | default: | ||
1815 | goto error; | ||
1816 | } | ||
1817 | break; | ||
1818 | case ClearPortFeature: | ||
1819 | if (!wIndex || wIndex > ports) | ||
1820 | goto error; | ||
1821 | wIndex--; | ||
1822 | temp = isp1760_readl(status_reg); | ||
1823 | |||
1824 | /* | ||
1825 | * Even if OWNER is set, so the port is owned by the | ||
1826 | * companion controller, khubd needs to be able to clear | ||
1827 | * the port-change status bits (especially | ||
1828 | * USB_PORT_FEAT_C_CONNECTION). | ||
1829 | */ | ||
1830 | |||
1831 | switch (wValue) { | ||
1832 | case USB_PORT_FEAT_ENABLE: | ||
1833 | isp1760_writel(temp & ~PORT_PE, status_reg); | ||
1834 | break; | ||
1835 | case USB_PORT_FEAT_C_ENABLE: | ||
1836 | /* XXX error? */ | ||
1837 | break; | ||
1838 | case USB_PORT_FEAT_SUSPEND: | ||
1839 | if (temp & PORT_RESET) | ||
1840 | goto error; | ||
1841 | |||
1842 | if (temp & PORT_SUSPEND) { | ||
1843 | if ((temp & PORT_PE) == 0) | ||
1844 | goto error; | ||
1845 | /* resume signaling for 20 msec */ | ||
1846 | temp &= ~(PORT_RWC_BITS); | ||
1847 | isp1760_writel(temp | PORT_RESUME, | ||
1848 | status_reg); | ||
1849 | priv->reset_done = jiffies + | ||
1850 | msecs_to_jiffies(20); | ||
1851 | } | ||
1852 | break; | ||
1853 | case USB_PORT_FEAT_C_SUSPEND: | ||
1854 | /* we auto-clear this feature */ | ||
1855 | break; | ||
1856 | case USB_PORT_FEAT_POWER: | ||
1857 | if (HCS_PPC(priv->hcs_params)) | ||
1858 | isp1760_writel(temp & ~PORT_POWER, status_reg); | ||
1859 | break; | ||
1860 | case USB_PORT_FEAT_C_CONNECTION: | ||
1861 | isp1760_writel(temp | PORT_CSC, | ||
1862 | status_reg); | ||
1863 | break; | ||
1864 | case USB_PORT_FEAT_C_OVER_CURRENT: | ||
1865 | /* XXX error ?*/ | ||
1866 | break; | ||
1867 | case USB_PORT_FEAT_C_RESET: | ||
1868 | /* GetPortStatus clears reset */ | ||
1869 | break; | ||
1870 | default: | ||
1871 | goto error; | ||
1872 | } | ||
1873 | isp1760_readl(hcd->regs + HC_USBCMD); | ||
1874 | break; | ||
1875 | case GetHubDescriptor: | ||
1876 | isp1760_hub_descriptor(priv, (struct usb_hub_descriptor *) | ||
1877 | buf); | ||
1878 | break; | ||
1879 | case GetHubStatus: | ||
1880 | /* no hub-wide feature/status flags */ | ||
1881 | memset(buf, 0, 4); | ||
1882 | break; | ||
1883 | case GetPortStatus: | ||
1884 | if (!wIndex || wIndex > ports) | ||
1885 | goto error; | ||
1886 | wIndex--; | ||
1887 | status = 0; | ||
1888 | temp = isp1760_readl(status_reg); | ||
1889 | |||
1890 | /* wPortChange bits */ | ||
1891 | if (temp & PORT_CSC) | ||
1892 | status |= 1 << USB_PORT_FEAT_C_CONNECTION; | ||
1893 | |||
1894 | |||
1895 | /* whoever resumes must GetPortStatus to complete it!! */ | ||
1896 | if (temp & PORT_RESUME) { | ||
1897 | printk(KERN_ERR "Port resume should be skipped.\n"); | ||
1898 | |||
1899 | /* Remote Wakeup received? */ | ||
1900 | if (!priv->reset_done) { | ||
1901 | /* resume signaling for 20 msec */ | ||
1902 | priv->reset_done = jiffies | ||
1903 | + msecs_to_jiffies(20); | ||
1904 | /* check the port again */ | ||
1905 | mod_timer(&priv_to_hcd(priv)->rh_timer, | ||
1906 | priv->reset_done); | ||
1907 | } | ||
1908 | |||
1909 | /* resume completed? */ | ||
1910 | else if (time_after_eq(jiffies, | ||
1911 | priv->reset_done)) { | ||
1912 | status |= 1 << USB_PORT_FEAT_C_SUSPEND; | ||
1913 | priv->reset_done = 0; | ||
1914 | |||
1915 | /* stop resume signaling */ | ||
1916 | temp = isp1760_readl(status_reg); | ||
1917 | isp1760_writel( | ||
1918 | temp & ~(PORT_RWC_BITS | PORT_RESUME), | ||
1919 | status_reg); | ||
1920 | retval = handshake(priv, status_reg, | ||
1921 | PORT_RESUME, 0, 2000 /* 2msec */); | ||
1922 | if (retval != 0) { | ||
1923 | isp1760_err(priv, | ||
1924 | "port %d resume error %d\n", | ||
1925 | wIndex + 1, retval); | ||
1926 | goto error; | ||
1927 | } | ||
1928 | temp &= ~(PORT_SUSPEND|PORT_RESUME|(3<<10)); | ||
1929 | } | ||
1930 | } | ||
1931 | |||
1932 | /* whoever resets must GetPortStatus to complete it!! */ | ||
1933 | if ((temp & PORT_RESET) | ||
1934 | && time_after_eq(jiffies, | ||
1935 | priv->reset_done)) { | ||
1936 | status |= 1 << USB_PORT_FEAT_C_RESET; | ||
1937 | priv->reset_done = 0; | ||
1938 | |||
1939 | /* force reset to complete */ | ||
1940 | isp1760_writel(temp & ~PORT_RESET, | ||
1941 | status_reg); | ||
1942 | /* REVISIT: some hardware needs 550+ usec to clear | ||
1943 | * this bit; seems too long to spin routinely... | ||
1944 | */ | ||
1945 | retval = handshake(priv, status_reg, | ||
1946 | PORT_RESET, 0, 750); | ||
1947 | if (retval != 0) { | ||
1948 | isp1760_err(priv, "port %d reset error %d\n", | ||
1949 | wIndex + 1, retval); | ||
1950 | goto error; | ||
1951 | } | ||
1952 | |||
1953 | /* see what we found out */ | ||
1954 | temp = check_reset_complete(priv, wIndex, status_reg, | ||
1955 | isp1760_readl(status_reg)); | ||
1956 | } | ||
1957 | /* | ||
1958 | * Even if OWNER is set, there's no harm letting khubd | ||
1959 | * see the wPortStatus values (they should all be 0 except | ||
1960 | * for PORT_POWER anyway). | ||
1961 | */ | ||
1962 | |||
1963 | if (temp & PORT_OWNER) | ||
1964 | printk(KERN_ERR "Warning: PORT_OWNER is set\n"); | ||
1965 | |||
1966 | if (temp & PORT_CONNECT) { | ||
1967 | status |= 1 << USB_PORT_FEAT_CONNECTION; | ||
1968 | /* status may be from integrated TT */ | ||
1969 | status |= ehci_port_speed(priv, temp); | ||
1970 | } | ||
1971 | if (temp & PORT_PE) | ||
1972 | status |= 1 << USB_PORT_FEAT_ENABLE; | ||
1973 | if (temp & (PORT_SUSPEND|PORT_RESUME)) | ||
1974 | status |= 1 << USB_PORT_FEAT_SUSPEND; | ||
1975 | if (temp & PORT_RESET) | ||
1976 | status |= 1 << USB_PORT_FEAT_RESET; | ||
1977 | if (temp & PORT_POWER) | ||
1978 | status |= 1 << USB_PORT_FEAT_POWER; | ||
1979 | |||
1980 | put_unaligned(cpu_to_le32(status), (__le32 *) buf); | ||
1981 | break; | ||
1982 | case SetHubFeature: | ||
1983 | switch (wValue) { | ||
1984 | case C_HUB_LOCAL_POWER: | ||
1985 | case C_HUB_OVER_CURRENT: | ||
1986 | /* no hub-wide feature/status flags */ | ||
1987 | break; | ||
1988 | default: | ||
1989 | goto error; | ||
1990 | } | ||
1991 | break; | ||
1992 | case SetPortFeature: | ||
1993 | selector = wIndex >> 8; | ||
1994 | wIndex &= 0xff; | ||
1995 | if (!wIndex || wIndex > ports) | ||
1996 | goto error; | ||
1997 | wIndex--; | ||
1998 | temp = isp1760_readl(status_reg); | ||
1999 | if (temp & PORT_OWNER) | ||
2000 | break; | ||
2001 | |||
2002 | /* temp &= ~PORT_RWC_BITS; */ | ||
2003 | switch (wValue) { | ||
2004 | case USB_PORT_FEAT_ENABLE: | ||
2005 | isp1760_writel(temp | PORT_PE, status_reg); | ||
2006 | break; | ||
2007 | |||
2008 | case USB_PORT_FEAT_SUSPEND: | ||
2009 | if ((temp & PORT_PE) == 0 | ||
2010 | || (temp & PORT_RESET) != 0) | ||
2011 | goto error; | ||
2012 | |||
2013 | isp1760_writel(temp | PORT_SUSPEND, status_reg); | ||
2014 | break; | ||
2015 | case USB_PORT_FEAT_POWER: | ||
2016 | if (HCS_PPC(priv->hcs_params)) | ||
2017 | isp1760_writel(temp | PORT_POWER, | ||
2018 | status_reg); | ||
2019 | break; | ||
2020 | case USB_PORT_FEAT_RESET: | ||
2021 | if (temp & PORT_RESUME) | ||
2022 | goto error; | ||
2023 | /* line status bits may report this as low speed, | ||
2024 | * which can be fine if this root hub has a | ||
2025 | * transaction translator built in. | ||
2026 | */ | ||
2027 | if ((temp & (PORT_PE|PORT_CONNECT)) == PORT_CONNECT | ||
2028 | && PORT_USB11(temp)) { | ||
2029 | temp |= PORT_OWNER; | ||
2030 | } else { | ||
2031 | temp |= PORT_RESET; | ||
2032 | temp &= ~PORT_PE; | ||
2033 | |||
2034 | /* | ||
2035 | * caller must wait, then call GetPortStatus | ||
2036 | * usb 2.0 spec says 50 ms resets on root | ||
2037 | */ | ||
2038 | priv->reset_done = jiffies + | ||
2039 | msecs_to_jiffies(50); | ||
2040 | } | ||
2041 | isp1760_writel(temp, status_reg); | ||
2042 | break; | ||
2043 | default: | ||
2044 | goto error; | ||
2045 | } | ||
2046 | isp1760_readl(hcd->regs + HC_USBCMD); | ||
2047 | break; | ||
2048 | |||
2049 | default: | ||
2050 | error: | ||
2051 | /* "stall" on error */ | ||
2052 | retval = -EPIPE; | ||
2053 | } | ||
2054 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2055 | return retval; | ||
2056 | } | ||
2057 | |||
2058 | static void isp1760_endpoint_disable(struct usb_hcd *usb_hcd, | ||
2059 | struct usb_host_endpoint *ep) | ||
2060 | { | ||
2061 | struct isp1760_hcd *priv = hcd_to_priv(usb_hcd); | ||
2062 | struct isp1760_qh *qh; | ||
2063 | struct isp1760_qtd *qtd; | ||
2064 | u32 flags; | ||
2065 | |||
2066 | spin_lock_irqsave(&priv->lock, flags); | ||
2067 | qh = ep->hcpriv; | ||
2068 | if (!qh) | ||
2069 | goto out; | ||
2070 | |||
2071 | ep->hcpriv = NULL; | ||
2072 | do { | ||
2073 | /* more than entry might get removed */ | ||
2074 | if (list_empty(&qh->qtd_list)) | ||
2075 | break; | ||
2076 | |||
2077 | qtd = list_first_entry(&qh->qtd_list, struct isp1760_qtd, | ||
2078 | qtd_list); | ||
2079 | |||
2080 | if (qtd->status & URB_ENQUEUED) { | ||
2081 | |||
2082 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2083 | isp1760_urb_dequeue(usb_hcd, qtd->urb, -ECONNRESET); | ||
2084 | spin_lock_irqsave(&priv->lock, flags); | ||
2085 | } else { | ||
2086 | struct urb *urb; | ||
2087 | |||
2088 | urb = qtd->urb; | ||
2089 | clean_up_qtdlist(qtd); | ||
2090 | isp1760_urb_done(priv, urb, -ECONNRESET); | ||
2091 | } | ||
2092 | } while (1); | ||
2093 | |||
2094 | qh_destroy(qh); | ||
2095 | /* remove requests and leak them. | ||
2096 | * ATL are pretty fast done, INT could take a while... | ||
2097 | * The latter shoule be removed | ||
2098 | */ | ||
2099 | out: | ||
2100 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2101 | } | ||
2102 | |||
2103 | static int isp1760_get_frame(struct usb_hcd *hcd) | ||
2104 | { | ||
2105 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
2106 | u32 fr; | ||
2107 | |||
2108 | fr = isp1760_readl(hcd->regs + HC_FRINDEX); | ||
2109 | return (fr >> 3) % priv->periodic_size; | ||
2110 | } | ||
2111 | |||
2112 | static void isp1760_stop(struct usb_hcd *hcd) | ||
2113 | { | ||
2114 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | ||
2115 | |||
2116 | isp1760_hub_control(hcd, ClearPortFeature, USB_PORT_FEAT_POWER, 1, | ||
2117 | NULL, 0); | ||
2118 | mdelay(20); | ||
2119 | |||
2120 | spin_lock_irq(&priv->lock); | ||
2121 | ehci_reset(priv); | ||
2122 | /* Disable IRQ */ | ||
2123 | isp1760_writel(HW_DATA_BUS_32BIT, hcd->regs + HC_HW_MODE_CTRL); | ||
2124 | spin_unlock_irq(&priv->lock); | ||
2125 | |||
2126 | isp1760_writel(0, hcd->regs + HC_CONFIGFLAG); | ||
2127 | } | ||
2128 | |||
2129 | static void isp1760_shutdown(struct usb_hcd *hcd) | ||
2130 | { | ||
2131 | u32 command; | ||
2132 | |||
2133 | isp1760_stop(hcd); | ||
2134 | isp1760_writel(HW_DATA_BUS_32BIT, hcd->regs + HC_HW_MODE_CTRL); | ||
2135 | |||
2136 | command = isp1760_readl(hcd->regs + HC_USBCMD); | ||
2137 | command &= ~CMD_RUN; | ||
2138 | isp1760_writel(command, hcd->regs + HC_USBCMD); | ||
2139 | } | ||
2140 | |||
2141 | static const struct hc_driver isp1760_hc_driver = { | ||
2142 | .description = "isp1760-hcd", | ||
2143 | .product_desc = "NXP ISP1760 USB Host Controller", | ||
2144 | .hcd_priv_size = sizeof(struct isp1760_hcd), | ||
2145 | .irq = isp1760_irq, | ||
2146 | .flags = HCD_MEMORY | HCD_USB2, | ||
2147 | .reset = isp1760_hc_setup, | ||
2148 | .start = isp1760_run, | ||
2149 | .stop = isp1760_stop, | ||
2150 | .shutdown = isp1760_shutdown, | ||
2151 | .urb_enqueue = isp1760_urb_enqueue, | ||
2152 | .urb_dequeue = isp1760_urb_dequeue, | ||
2153 | .endpoint_disable = isp1760_endpoint_disable, | ||
2154 | .get_frame_number = isp1760_get_frame, | ||
2155 | .hub_status_data = isp1760_hub_status_data, | ||
2156 | .hub_control = isp1760_hub_control, | ||
2157 | }; | ||
2158 | |||
2159 | int __init init_kmem_once(void) | ||
2160 | { | ||
2161 | qtd_cachep = kmem_cache_create("isp1760_qtd", | ||
2162 | sizeof(struct isp1760_qtd), 0, SLAB_TEMPORARY | | ||
2163 | SLAB_MEM_SPREAD, NULL); | ||
2164 | |||
2165 | if (!qtd_cachep) | ||
2166 | return -ENOMEM; | ||
2167 | |||
2168 | qh_cachep = kmem_cache_create("isp1760_qh", sizeof(struct isp1760_qh), | ||
2169 | 0, SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL); | ||
2170 | |||
2171 | if (!qh_cachep) { | ||
2172 | kmem_cache_destroy(qtd_cachep); | ||
2173 | return -ENOMEM; | ||
2174 | } | ||
2175 | |||
2176 | return 0; | ||
2177 | } | ||
2178 | |||
2179 | void deinit_kmem_cache(void) | ||
2180 | { | ||
2181 | kmem_cache_destroy(qtd_cachep); | ||
2182 | kmem_cache_destroy(qh_cachep); | ||
2183 | } | ||
2184 | |||
2185 | struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq, | ||
2186 | u64 irqflags, struct device *dev, const char *busname) | ||
2187 | { | ||
2188 | struct usb_hcd *hcd; | ||
2189 | struct isp1760_hcd *priv; | ||
2190 | int ret; | ||
2191 | |||
2192 | if (usb_disabled()) | ||
2193 | return ERR_PTR(-ENODEV); | ||
2194 | |||
2195 | /* prevent usb-core allocating DMA pages */ | ||
2196 | dev->dma_mask = NULL; | ||
2197 | |||
2198 | hcd = usb_create_hcd(&isp1760_hc_driver, dev, dev->bus_id); | ||
2199 | if (!hcd) | ||
2200 | return ERR_PTR(-ENOMEM); | ||
2201 | |||
2202 | priv = hcd_to_priv(hcd); | ||
2203 | init_memory(priv); | ||
2204 | hcd->regs = ioremap(res_start, res_len); | ||
2205 | if (!hcd->regs) { | ||
2206 | ret = -EIO; | ||
2207 | goto err_put; | ||
2208 | } | ||
2209 | |||
2210 | ret = usb_add_hcd(hcd, irq, irqflags); | ||
2211 | if (ret) | ||
2212 | goto err_unmap; | ||
2213 | |||
2214 | hcd->irq = irq; | ||
2215 | hcd->rsrc_start = res_start; | ||
2216 | hcd->rsrc_len = res_len; | ||
2217 | |||
2218 | return hcd; | ||
2219 | |||
2220 | err_unmap: | ||
2221 | iounmap(hcd->regs); | ||
2222 | |||
2223 | err_put: | ||
2224 | usb_put_hcd(hcd); | ||
2225 | |||
2226 | return ERR_PTR(ret); | ||
2227 | } | ||
2228 | |||
2229 | MODULE_DESCRIPTION("Driver for the ISP1760 USB-controller from NXP"); | ||
2230 | MODULE_AUTHOR("Sebastian Siewior <bigeasy@linuxtronix.de>"); | ||
2231 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/host/isp1760-hcd.h b/drivers/usb/host/isp1760-hcd.h new file mode 100644 index 000000000000..3d86d0f6b147 --- /dev/null +++ b/drivers/usb/host/isp1760-hcd.h | |||
@@ -0,0 +1,206 @@ | |||
1 | #ifndef _ISP1760_HCD_H_ | ||
2 | #define _ISP1760_HCD_H_ | ||
3 | |||
4 | /* exports for if */ | ||
5 | struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq, | ||
6 | u64 irqflags, struct device *dev, const char *busname); | ||
7 | int init_kmem_once(void); | ||
8 | void deinit_kmem_cache(void); | ||
9 | |||
10 | /* EHCI capability registers */ | ||
11 | #define HC_CAPLENGTH 0x00 | ||
12 | #define HC_HCSPARAMS 0x04 | ||
13 | #define HC_HCCPARAMS 0x08 | ||
14 | |||
15 | /* EHCI operational registers */ | ||
16 | #define HC_USBCMD 0x20 | ||
17 | #define HC_USBSTS 0x24 | ||
18 | #define HC_FRINDEX 0x2c | ||
19 | #define HC_CONFIGFLAG 0x60 | ||
20 | #define HC_PORTSC1 0x64 | ||
21 | #define HC_ISO_PTD_DONEMAP_REG 0x130 | ||
22 | #define HC_ISO_PTD_SKIPMAP_REG 0x134 | ||
23 | #define HC_ISO_PTD_LASTPTD_REG 0x138 | ||
24 | #define HC_INT_PTD_DONEMAP_REG 0x140 | ||
25 | #define HC_INT_PTD_SKIPMAP_REG 0x144 | ||
26 | #define HC_INT_PTD_LASTPTD_REG 0x148 | ||
27 | #define HC_ATL_PTD_DONEMAP_REG 0x150 | ||
28 | #define HC_ATL_PTD_SKIPMAP_REG 0x154 | ||
29 | #define HC_ATL_PTD_LASTPTD_REG 0x158 | ||
30 | |||
31 | /* Configuration Register */ | ||
32 | #define HC_HW_MODE_CTRL 0x300 | ||
33 | #define ALL_ATX_RESET (1 << 31) | ||
34 | #define HW_DATA_BUS_32BIT (1 << 8) | ||
35 | #define HW_DACK_POL_HIGH (1 << 6) | ||
36 | #define HW_DREQ_POL_HIGH (1 << 5) | ||
37 | #define HW_INTR_HIGH_ACT (1 << 2) | ||
38 | #define HW_INTR_EDGE_TRIG (1 << 1) | ||
39 | #define HW_GLOBAL_INTR_EN (1 << 0) | ||
40 | |||
41 | #define HC_CHIP_ID_REG 0x304 | ||
42 | #define HC_SCRATCH_REG 0x308 | ||
43 | |||
44 | #define HC_RESET_REG 0x30c | ||
45 | #define SW_RESET_RESET_HC (1 << 1) | ||
46 | #define SW_RESET_RESET_ALL (1 << 0) | ||
47 | |||
48 | #define HC_BUFFER_STATUS_REG 0x334 | ||
49 | #define ATL_BUFFER 0x1 | ||
50 | #define INT_BUFFER 0x2 | ||
51 | #define ISO_BUFFER 0x4 | ||
52 | #define BUFFER_MAP 0x7 | ||
53 | |||
54 | #define HC_MEMORY_REG 0x33c | ||
55 | #define HC_PORT1_CTRL 0x374 | ||
56 | #define PORT1_POWER (3 << 3) | ||
57 | #define PORT1_INIT1 (1 << 7) | ||
58 | #define PORT1_INIT2 (1 << 23) | ||
59 | |||
60 | /* Interrupt Register */ | ||
61 | #define HC_INTERRUPT_REG 0x310 | ||
62 | |||
63 | #define HC_INTERRUPT_ENABLE 0x314 | ||
64 | #define INTERRUPT_ENABLE_MASK (HC_INTL_INT | HC_ATL_INT | HC_EOT_INT) | ||
65 | #define FINAL_HW_CONFIG (HW_GLOBAL_INTR_EN | HW_DATA_BUS_32BIT) | ||
66 | |||
67 | #define HC_ISO_INT (1 << 9) | ||
68 | #define HC_ATL_INT (1 << 8) | ||
69 | #define HC_INTL_INT (1 << 7) | ||
70 | #define HC_EOT_INT (1 << 3) | ||
71 | #define HC_SOT_INT (1 << 1) | ||
72 | |||
73 | #define HC_ISO_IRQ_MASK_OR_REG 0x318 | ||
74 | #define HC_INT_IRQ_MASK_OR_REG 0x31C | ||
75 | #define HC_ATL_IRQ_MASK_OR_REG 0x320 | ||
76 | #define HC_ISO_IRQ_MASK_AND_REG 0x324 | ||
77 | #define HC_INT_IRQ_MASK_AND_REG 0x328 | ||
78 | #define HC_ATL_IRQ_MASK_AND_REG 0x32C | ||
79 | |||
80 | /* Register sets */ | ||
81 | #define HC_BEGIN_OF_ATL 0x0c00 | ||
82 | #define HC_BEGIN_OF_INT 0x0800 | ||
83 | #define HC_BEGIN_OF_ISO 0x0400 | ||
84 | #define HC_BEGIN_OF_PAYLOAD 0x1000 | ||
85 | |||
86 | /* urb state*/ | ||
87 | #define DELETE_URB (0x0008) | ||
88 | #define NO_TRANSFER_ACTIVE (0xffffffff) | ||
89 | |||
90 | #define ATL_REGS_OFFSET (0xc00) | ||
91 | #define INT_REGS_OFFSET (0x800) | ||
92 | |||
93 | /* Philips Transfer Descriptor (PTD) */ | ||
94 | struct ptd { | ||
95 | __le32 dw0; | ||
96 | __le32 dw1; | ||
97 | __le32 dw2; | ||
98 | __le32 dw3; | ||
99 | __le32 dw4; | ||
100 | __le32 dw5; | ||
101 | __le32 dw6; | ||
102 | __le32 dw7; | ||
103 | }; | ||
104 | |||
105 | struct inter_packet_info { | ||
106 | void *data_buffer; | ||
107 | u32 payload; | ||
108 | #define PTD_FIRE_NEXT (1 << 0) | ||
109 | #define PTD_URB_FINISHED (1 << 1) | ||
110 | struct urb *urb; | ||
111 | struct isp1760_qh *qh; | ||
112 | struct isp1760_qtd *qtd; | ||
113 | }; | ||
114 | |||
115 | |||
116 | typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh, | ||
117 | struct isp1760_qtd *qtd); | ||
118 | |||
119 | #define isp1760_info(priv, fmt, args...) \ | ||
120 | dev_info(priv_to_hcd(priv)->self.controller, fmt, ##args) | ||
121 | |||
122 | #define isp1760_err(priv, fmt, args...) \ | ||
123 | dev_err(priv_to_hcd(priv)->self.controller, fmt, ##args) | ||
124 | |||
125 | /* chip memory management */ | ||
126 | struct memory_chunk { | ||
127 | unsigned int start; | ||
128 | unsigned int size; | ||
129 | unsigned int free; | ||
130 | }; | ||
131 | |||
132 | /* | ||
133 | * 60kb divided in: | ||
134 | * - 32 blocks @ 256 bytes | ||
135 | * - 20 blocks @ 1024 bytes | ||
136 | * - 4 blocks @ 8192 bytes | ||
137 | */ | ||
138 | |||
139 | #define BLOCK_1_NUM 32 | ||
140 | #define BLOCK_2_NUM 20 | ||
141 | #define BLOCK_3_NUM 4 | ||
142 | |||
143 | #define BLOCK_1_SIZE 256 | ||
144 | #define BLOCK_2_SIZE 1024 | ||
145 | #define BLOCK_3_SIZE 8192 | ||
146 | #define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM) | ||
147 | #define PAYLOAD_SIZE 0xf000 | ||
148 | |||
149 | /* I saw if some reloads if the pointer was negative */ | ||
150 | #define ISP1760_NULL_POINTER (0x400) | ||
151 | |||
152 | /* ATL */ | ||
153 | /* DW0 */ | ||
154 | #define PTD_VALID 1 | ||
155 | #define PTD_LENGTH(x) (((u32) x) << 3) | ||
156 | #define PTD_MAXPACKET(x) (((u32) x) << 18) | ||
157 | #define PTD_MULTI(x) (((u32) x) << 29) | ||
158 | #define PTD_ENDPOINT(x) (((u32) x) << 31) | ||
159 | /* DW1 */ | ||
160 | #define PTD_DEVICE_ADDR(x) (((u32) x) << 3) | ||
161 | #define PTD_PID_TOKEN(x) (((u32) x) << 10) | ||
162 | #define PTD_TRANS_BULK ((u32) 2 << 12) | ||
163 | #define PTD_TRANS_INT ((u32) 3 << 12) | ||
164 | #define PTD_TRANS_SPLIT ((u32) 1 << 14) | ||
165 | #define PTD_SE_USB_LOSPEED ((u32) 2 << 16) | ||
166 | #define PTD_PORT_NUM(x) (((u32) x) << 18) | ||
167 | #define PTD_HUB_NUM(x) (((u32) x) << 25) | ||
168 | #define PTD_PING(x) (((u32) x) << 26) | ||
169 | /* DW2 */ | ||
170 | #define PTD_RL_CNT(x) (((u32) x) << 25) | ||
171 | #define PTD_DATA_START_ADDR(x) (((u32) x) << 8) | ||
172 | #define BASE_ADDR 0x1000 | ||
173 | /* DW3 */ | ||
174 | #define PTD_CERR(x) (((u32) x) << 23) | ||
175 | #define PTD_NAC_CNT(x) (((u32) x) << 19) | ||
176 | #define PTD_ACTIVE ((u32) 1 << 31) | ||
177 | #define PTD_DATA_TOGGLE(x) (((u32) x) << 25) | ||
178 | |||
179 | #define DW3_HALT_BIT (1 << 30) | ||
180 | #define DW3_ERROR_BIT (1 << 28) | ||
181 | #define DW3_QTD_ACTIVE (1 << 31) | ||
182 | |||
183 | #define INT_UNDERRUN (1 << 2) | ||
184 | #define INT_BABBLE (1 << 1) | ||
185 | #define INT_EXACT (1 << 0) | ||
186 | |||
187 | #define DW1_GET_PID(x) (((x) >> 10) & 0x3) | ||
188 | #define PTD_XFERRED_LENGTH(x) ((x) & 0x7fff) | ||
189 | #define PTD_XFERRED_LENGTH_LO(x) ((x) & 0x7ff) | ||
190 | |||
191 | #define SETUP_PID (2) | ||
192 | #define IN_PID (1) | ||
193 | #define OUT_PID (0) | ||
194 | #define GET_QTD_TOKEN_TYPE(x) ((x) & 0x3) | ||
195 | |||
196 | #define DATA_TOGGLE (1 << 31) | ||
197 | #define GET_DATA_TOGGLE(x) ((x) >> 31) | ||
198 | |||
199 | /* Errata 1 */ | ||
200 | #define RL_COUNTER (0) | ||
201 | #define NAK_COUNTER (0) | ||
202 | #define ERR_COUNTER (2) | ||
203 | |||
204 | #define HC_ATL_PL_SIZE (8192) | ||
205 | |||
206 | #endif | ||
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c new file mode 100644 index 000000000000..73fb2a38f1e4 --- /dev/null +++ b/drivers/usb/host/isp1760-if.c | |||
@@ -0,0 +1,298 @@ | |||
1 | /* | ||
2 | * Glue code for the ISP1760 driver and bus | ||
3 | * Currently there is support for | ||
4 | * - OpenFirmware | ||
5 | * - PCI | ||
6 | * | ||
7 | * (c) 2007 Sebastian Siewior <bigeasy@linutronix.de> | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #include <linux/usb.h> | ||
12 | #include <linux/io.h> | ||
13 | |||
14 | #include "../core/hcd.h" | ||
15 | #include "isp1760-hcd.h" | ||
16 | |||
17 | #ifdef CONFIG_USB_ISP1760_OF | ||
18 | #include <linux/of.h> | ||
19 | #include <linux/of_platform.h> | ||
20 | #endif | ||
21 | |||
22 | #ifdef CONFIG_USB_ISP1760_PCI | ||
23 | #include <linux/pci.h> | ||
24 | #endif | ||
25 | |||
26 | #ifdef CONFIG_USB_ISP1760_OF | ||
27 | static int of_isp1760_probe(struct of_device *dev, | ||
28 | const struct of_device_id *match) | ||
29 | { | ||
30 | struct usb_hcd *hcd; | ||
31 | struct device_node *dp = dev->node; | ||
32 | struct resource *res; | ||
33 | struct resource memory; | ||
34 | struct of_irq oirq; | ||
35 | int virq; | ||
36 | u64 res_len; | ||
37 | int ret; | ||
38 | |||
39 | ret = of_address_to_resource(dp, 0, &memory); | ||
40 | if (ret) | ||
41 | return -ENXIO; | ||
42 | |||
43 | res = request_mem_region(memory.start, memory.end - memory.start + 1, | ||
44 | dev->dev.bus_id); | ||
45 | if (!res) | ||
46 | return -EBUSY; | ||
47 | |||
48 | res_len = memory.end - memory.start + 1; | ||
49 | |||
50 | if (of_irq_map_one(dp, 0, &oirq)) { | ||
51 | ret = -ENODEV; | ||
52 | goto release_reg; | ||
53 | } | ||
54 | |||
55 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, | ||
56 | oirq.size); | ||
57 | |||
58 | hcd = isp1760_register(memory.start, res_len, virq, | ||
59 | IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev->dev.bus_id); | ||
60 | if (IS_ERR(hcd)) { | ||
61 | ret = PTR_ERR(hcd); | ||
62 | goto release_reg; | ||
63 | } | ||
64 | |||
65 | dev_set_drvdata(&dev->dev, hcd); | ||
66 | return ret; | ||
67 | |||
68 | release_reg: | ||
69 | release_mem_region(memory.start, memory.end - memory.start + 1); | ||
70 | return ret; | ||
71 | } | ||
72 | |||
73 | static int of_isp1760_remove(struct of_device *dev) | ||
74 | { | ||
75 | struct usb_hcd *hcd = dev_get_drvdata(&dev->dev); | ||
76 | |||
77 | dev_set_drvdata(&dev->dev, NULL); | ||
78 | |||
79 | usb_remove_hcd(hcd); | ||
80 | iounmap(hcd->regs); | ||
81 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
82 | usb_put_hcd(hcd); | ||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | static struct of_device_id of_isp1760_match[] = { | ||
87 | { | ||
88 | .compatible = "nxp,usb-isp1760", | ||
89 | }, | ||
90 | { }, | ||
91 | }; | ||
92 | MODULE_DEVICE_TABLE(of, of_isp1760_match); | ||
93 | |||
94 | static struct of_platform_driver isp1760_of_driver = { | ||
95 | .name = "nxp-isp1760", | ||
96 | .match_table = of_isp1760_match, | ||
97 | .probe = of_isp1760_probe, | ||
98 | .remove = of_isp1760_remove, | ||
99 | }; | ||
100 | #endif | ||
101 | |||
102 | #ifdef CONFIG_USB_ISP1760_PCI | ||
103 | static u32 nxp_pci_io_base; | ||
104 | static u32 iolength; | ||
105 | static u32 pci_mem_phy0; | ||
106 | static u32 length; | ||
107 | static u8 *chip_addr; | ||
108 | static u8 *iobase; | ||
109 | |||
110 | static int __devinit isp1761_pci_probe(struct pci_dev *dev, | ||
111 | const struct pci_device_id *id) | ||
112 | { | ||
113 | u8 latency, limit; | ||
114 | __u32 reg_data; | ||
115 | int retry_count; | ||
116 | int length; | ||
117 | int status = 1; | ||
118 | struct usb_hcd *hcd; | ||
119 | |||
120 | if (usb_disabled()) | ||
121 | return -ENODEV; | ||
122 | |||
123 | if (pci_enable_device(dev) < 0) | ||
124 | return -ENODEV; | ||
125 | |||
126 | if (!dev->irq) | ||
127 | return -ENODEV; | ||
128 | |||
129 | /* Grab the PLX PCI mem maped port start address we need */ | ||
130 | nxp_pci_io_base = pci_resource_start(dev, 0); | ||
131 | iolength = pci_resource_len(dev, 0); | ||
132 | |||
133 | if (!request_mem_region(nxp_pci_io_base, iolength, "ISP1761 IO MEM")) { | ||
134 | printk(KERN_ERR "request region #1\n"); | ||
135 | return -EBUSY; | ||
136 | } | ||
137 | |||
138 | iobase = ioremap_nocache(nxp_pci_io_base, iolength); | ||
139 | if (!iobase) { | ||
140 | printk(KERN_ERR "ioremap #1\n"); | ||
141 | release_mem_region(nxp_pci_io_base, iolength); | ||
142 | return -ENOMEM; | ||
143 | } | ||
144 | /* Grab the PLX PCI shared memory of the ISP 1761 we need */ | ||
145 | pci_mem_phy0 = pci_resource_start(dev, 3); | ||
146 | length = pci_resource_len(dev, 3); | ||
147 | |||
148 | if (length < 0xffff) { | ||
149 | printk(KERN_ERR "memory length for this resource is less than " | ||
150 | "required\n"); | ||
151 | release_mem_region(nxp_pci_io_base, iolength); | ||
152 | iounmap(iobase); | ||
153 | return -ENOMEM; | ||
154 | } | ||
155 | |||
156 | if (!request_mem_region(pci_mem_phy0, length, "ISP-PCI")) { | ||
157 | printk(KERN_ERR "host controller already in use\n"); | ||
158 | release_mem_region(nxp_pci_io_base, iolength); | ||
159 | iounmap(iobase); | ||
160 | return -EBUSY; | ||
161 | } | ||
162 | |||
163 | /* bad pci latencies can contribute to overruns */ | ||
164 | pci_read_config_byte(dev, PCI_LATENCY_TIMER, &latency); | ||
165 | if (latency) { | ||
166 | pci_read_config_byte(dev, PCI_MAX_LAT, &limit); | ||
167 | if (limit && limit < latency) | ||
168 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, limit); | ||
169 | } | ||
170 | |||
171 | /* Try to check whether we can access Scratch Register of | ||
172 | * Host Controller or not. The initial PCI access is retried until | ||
173 | * local init for the PCI bridge is completed | ||
174 | */ | ||
175 | retry_count = 20; | ||
176 | reg_data = 0; | ||
177 | while ((reg_data != 0xFACE) && retry_count) { | ||
178 | /*by default host is in 16bit mode, so | ||
179 | * io operations at this stage must be 16 bit | ||
180 | * */ | ||
181 | writel(0xface, chip_addr + HC_SCRATCH_REG); | ||
182 | udelay(100); | ||
183 | reg_data = readl(chip_addr + HC_SCRATCH_REG); | ||
184 | retry_count--; | ||
185 | } | ||
186 | |||
187 | /* Host Controller presence is detected by writing to scratch register | ||
188 | * and reading back and checking the contents are same or not | ||
189 | */ | ||
190 | if (reg_data != 0xFACE) { | ||
191 | err("scratch register mismatch %x", reg_data); | ||
192 | goto clean; | ||
193 | } | ||
194 | |||
195 | pci_set_master(dev); | ||
196 | |||
197 | status = readl(iobase + 0x68); | ||
198 | status |= 0x900; | ||
199 | writel(status, iobase + 0x68); | ||
200 | |||
201 | dev->dev.dma_mask = NULL; | ||
202 | hcd = isp1760_register(pci_mem_phy0, length, dev->irq, | ||
203 | IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev->dev.bus_id); | ||
204 | pci_set_drvdata(dev, hcd); | ||
205 | if (!hcd) | ||
206 | return 0; | ||
207 | clean: | ||
208 | status = -ENODEV; | ||
209 | iounmap(iobase); | ||
210 | release_mem_region(pci_mem_phy0, length); | ||
211 | release_mem_region(nxp_pci_io_base, iolength); | ||
212 | return status; | ||
213 | } | ||
214 | static void isp1761_pci_remove(struct pci_dev *dev) | ||
215 | { | ||
216 | struct usb_hcd *hcd; | ||
217 | |||
218 | hcd = pci_get_drvdata(dev); | ||
219 | |||
220 | usb_remove_hcd(hcd); | ||
221 | iounmap(hcd->regs); | ||
222 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
223 | usb_put_hcd(hcd); | ||
224 | |||
225 | pci_disable_device(dev); | ||
226 | |||
227 | iounmap(iobase); | ||
228 | iounmap(chip_addr); | ||
229 | |||
230 | release_mem_region(nxp_pci_io_base, iolength); | ||
231 | release_mem_region(pci_mem_phy0, length); | ||
232 | } | ||
233 | |||
234 | static void isp1761_pci_shutdown(struct pci_dev *dev) | ||
235 | { | ||
236 | printk(KERN_ERR "ips1761_pci_shutdown\n"); | ||
237 | } | ||
238 | |||
239 | static const struct pci_device_id isp1760_plx [] = { { | ||
240 | /* handle any USB 2.0 EHCI controller */ | ||
241 | PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_OTHER << 8) | (0x06 << 16)), ~0), | ||
242 | .driver_data = 0, | ||
243 | }, | ||
244 | { /* end: all zeroes */ } | ||
245 | }; | ||
246 | MODULE_DEVICE_TABLE(pci, isp1760_plx); | ||
247 | |||
248 | static struct pci_driver isp1761_pci_driver = { | ||
249 | .name = "isp1760", | ||
250 | .id_table = isp1760_plx, | ||
251 | .probe = isp1761_pci_probe, | ||
252 | .remove = isp1761_pci_remove, | ||
253 | .shutdown = isp1761_pci_shutdown, | ||
254 | }; | ||
255 | #endif | ||
256 | |||
257 | static int __init isp1760_init(void) | ||
258 | { | ||
259 | int ret; | ||
260 | |||
261 | init_kmem_once(); | ||
262 | |||
263 | #ifdef CONFIG_USB_ISP1760_OF | ||
264 | ret = of_register_platform_driver(&isp1760_of_driver); | ||
265 | if (ret) { | ||
266 | deinit_kmem_cache(); | ||
267 | return ret; | ||
268 | } | ||
269 | #endif | ||
270 | #ifdef CONFIG_USB_ISP1760_PCI | ||
271 | ret = pci_register_driver(&isp1761_pci_driver); | ||
272 | if (ret) | ||
273 | goto unreg_of; | ||
274 | #endif | ||
275 | return ret; | ||
276 | |||
277 | #ifdef CONFIG_USB_ISP1760_PCI | ||
278 | unreg_of: | ||
279 | #endif | ||
280 | #ifdef CONFIG_USB_ISP1760_OF | ||
281 | of_unregister_platform_driver(&isp1760_of_driver); | ||
282 | #endif | ||
283 | deinit_kmem_cache(); | ||
284 | return ret; | ||
285 | } | ||
286 | module_init(isp1760_init); | ||
287 | |||
288 | static void __exit isp1760_exit(void) | ||
289 | { | ||
290 | #ifdef CONFIG_USB_ISP1760_OF | ||
291 | of_unregister_platform_driver(&isp1760_of_driver); | ||
292 | #endif | ||
293 | #ifdef CONFIG_USB_ISP1760_PCI | ||
294 | pci_unregister_driver(&isp1761_pci_driver); | ||
295 | #endif | ||
296 | deinit_kmem_cache(); | ||
297 | } | ||
298 | module_exit(isp1760_exit); | ||
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 17dc2eccda83..79a78029f896 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -613,7 +613,7 @@ static void start_hnp(struct ohci_hcd *ohci); | |||
613 | static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) | 613 | static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) |
614 | { | 614 | { |
615 | __hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port]; | 615 | __hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port]; |
616 | u32 temp; | 616 | u32 temp = 0; |
617 | u16 now = ohci_readl(ohci, &ohci->regs->fmnumber); | 617 | u16 now = ohci_readl(ohci, &ohci->regs->fmnumber); |
618 | u16 reset_done = now + PORT_RESET_MSEC; | 618 | u16 reset_done = now + PORT_RESET_MSEC; |
619 | int limit_1 = DIV_ROUND_UP(PORT_RESET_MSEC, PORT_RESET_HW_MSEC); | 619 | int limit_1 = DIV_ROUND_UP(PORT_RESET_MSEC, PORT_RESET_HW_MSEC); |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index d3e0d8aa3980..3a7bfe7a8874 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -234,7 +234,7 @@ static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci) | |||
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | 236 | ||
237 | static int remote_wakeup_is_broken(struct uhci_hcd *uhci) | 237 | static int global_suspend_mode_is_broken(struct uhci_hcd *uhci) |
238 | { | 238 | { |
239 | int port; | 239 | int port; |
240 | const char *sys_info; | 240 | const char *sys_info; |
@@ -261,27 +261,60 @@ __releases(uhci->lock) | |||
261 | __acquires(uhci->lock) | 261 | __acquires(uhci->lock) |
262 | { | 262 | { |
263 | int auto_stop; | 263 | int auto_stop; |
264 | int int_enable, egsm_enable; | 264 | int int_enable, egsm_enable, wakeup_enable; |
265 | struct usb_device *rhdev = uhci_to_hcd(uhci)->self.root_hub; | 265 | struct usb_device *rhdev = uhci_to_hcd(uhci)->self.root_hub; |
266 | 266 | ||
267 | auto_stop = (new_state == UHCI_RH_AUTO_STOPPED); | 267 | auto_stop = (new_state == UHCI_RH_AUTO_STOPPED); |
268 | dev_dbg(&rhdev->dev, "%s%s\n", __func__, | 268 | dev_dbg(&rhdev->dev, "%s%s\n", __func__, |
269 | (auto_stop ? " (auto-stop)" : "")); | 269 | (auto_stop ? " (auto-stop)" : "")); |
270 | 270 | ||
271 | /* Enable resume-detect interrupts if they work. | 271 | /* Start off by assuming Resume-Detect interrupts and EGSM work |
272 | * Then enter Global Suspend mode if _it_ works, still configured. | 272 | * and that remote wakeups should be enabled. |
273 | */ | 273 | */ |
274 | egsm_enable = USBCMD_EGSM; | 274 | egsm_enable = USBCMD_EGSM; |
275 | uhci->working_RD = 1; | 275 | uhci->RD_enable = 1; |
276 | int_enable = USBINTR_RESUME; | 276 | int_enable = USBINTR_RESUME; |
277 | if (remote_wakeup_is_broken(uhci)) | 277 | wakeup_enable = 1; |
278 | egsm_enable = 0; | 278 | |
279 | if (resume_detect_interrupts_are_broken(uhci) || !egsm_enable || | 279 | /* In auto-stop mode wakeups must always be detected, but |
280 | * Resume-Detect interrupts may be prohibited. (In the absence | ||
281 | * of CONFIG_PM, they are always disallowed.) | ||
282 | */ | ||
283 | if (auto_stop) { | ||
284 | if (!device_may_wakeup(&rhdev->dev)) | ||
285 | int_enable = 0; | ||
286 | |||
287 | /* In bus-suspend mode wakeups may be disabled, but if they are | ||
288 | * allowed then so are Resume-Detect interrupts. | ||
289 | */ | ||
290 | } else { | ||
280 | #ifdef CONFIG_PM | 291 | #ifdef CONFIG_PM |
281 | (!auto_stop && !rhdev->do_remote_wakeup) || | 292 | if (!rhdev->do_remote_wakeup) |
293 | wakeup_enable = 0; | ||
282 | #endif | 294 | #endif |
283 | (auto_stop && !device_may_wakeup(&rhdev->dev))) | 295 | } |
284 | uhci->working_RD = int_enable = 0; | 296 | |
297 | /* EGSM causes the root hub to echo a 'K' signal (resume) out any | ||
298 | * port which requests a remote wakeup. According to the USB spec, | ||
299 | * every hub is supposed to do this. But if we are ignoring | ||
300 | * remote-wakeup requests anyway then there's no point to it. | ||
301 | * We also shouldn't enable EGSM if it's broken. | ||
302 | */ | ||
303 | if (!wakeup_enable || global_suspend_mode_is_broken(uhci)) | ||
304 | egsm_enable = 0; | ||
305 | |||
306 | /* If we're ignoring wakeup events then there's no reason to | ||
307 | * enable Resume-Detect interrupts. We also shouldn't enable | ||
308 | * them if they are broken or disallowed. | ||
309 | * | ||
310 | * This logic may lead us to enabling RD but not EGSM. The UHCI | ||
311 | * spec foolishly says that RD works only when EGSM is on, but | ||
312 | * there's no harm in enabling it anyway -- perhaps some chips | ||
313 | * will implement it! | ||
314 | */ | ||
315 | if (!wakeup_enable || resume_detect_interrupts_are_broken(uhci) || | ||
316 | !int_enable) | ||
317 | uhci->RD_enable = int_enable = 0; | ||
285 | 318 | ||
286 | outw(int_enable, uhci->io_addr + USBINTR); | 319 | outw(int_enable, uhci->io_addr + USBINTR); |
287 | outw(egsm_enable | USBCMD_CF, uhci->io_addr + USBCMD); | 320 | outw(egsm_enable | USBCMD_CF, uhci->io_addr + USBCMD); |
@@ -308,7 +341,11 @@ __acquires(uhci->lock) | |||
308 | 341 | ||
309 | uhci->rh_state = new_state; | 342 | uhci->rh_state = new_state; |
310 | uhci->is_stopped = UHCI_IS_STOPPED; | 343 | uhci->is_stopped = UHCI_IS_STOPPED; |
311 | uhci_to_hcd(uhci)->poll_rh = !int_enable; | 344 | |
345 | /* If interrupts don't work and remote wakeup is enabled then | ||
346 | * the suspended root hub needs to be polled. | ||
347 | */ | ||
348 | uhci_to_hcd(uhci)->poll_rh = (!int_enable && wakeup_enable); | ||
312 | 349 | ||
313 | uhci_scan_schedule(uhci); | 350 | uhci_scan_schedule(uhci); |
314 | uhci_fsbr_off(uhci); | 351 | uhci_fsbr_off(uhci); |
@@ -344,9 +381,12 @@ __acquires(uhci->lock) | |||
344 | * for 20 ms. | 381 | * for 20 ms. |
345 | */ | 382 | */ |
346 | if (uhci->rh_state == UHCI_RH_SUSPENDED) { | 383 | if (uhci->rh_state == UHCI_RH_SUSPENDED) { |
384 | unsigned egsm; | ||
385 | |||
386 | /* Keep EGSM on if it was set before */ | ||
387 | egsm = inw(uhci->io_addr + USBCMD) & USBCMD_EGSM; | ||
347 | uhci->rh_state = UHCI_RH_RESUMING; | 388 | uhci->rh_state = UHCI_RH_RESUMING; |
348 | outw(USBCMD_FGR | USBCMD_EGSM | USBCMD_CF, | 389 | outw(USBCMD_FGR | USBCMD_CF | egsm, uhci->io_addr + USBCMD); |
349 | uhci->io_addr + USBCMD); | ||
350 | spin_unlock_irq(&uhci->lock); | 390 | spin_unlock_irq(&uhci->lock); |
351 | msleep(20); | 391 | msleep(20); |
352 | spin_lock_irq(&uhci->lock); | 392 | spin_lock_irq(&uhci->lock); |
@@ -801,8 +841,10 @@ static int uhci_pci_resume(struct usb_hcd *hcd) | |||
801 | 841 | ||
802 | spin_unlock_irq(&uhci->lock); | 842 | spin_unlock_irq(&uhci->lock); |
803 | 843 | ||
804 | if (!uhci->working_RD) { | 844 | /* If interrupts don't work and remote wakeup is enabled then |
805 | /* Suspended root hub needs to be polled */ | 845 | * the suspended root hub needs to be polled. |
846 | */ | ||
847 | if (!uhci->RD_enable && hcd->self.root_hub->do_remote_wakeup) { | ||
806 | hcd->poll_rh = 1; | 848 | hcd->poll_rh = 1; |
807 | usb_hcd_poll_rh_status(hcd); | 849 | usb_hcd_poll_rh_status(hcd); |
808 | } | 850 | } |
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h index 340d6ed3e6e9..7d01c5677f92 100644 --- a/drivers/usb/host/uhci-hcd.h +++ b/drivers/usb/host/uhci-hcd.h | |||
@@ -400,8 +400,9 @@ struct uhci_hcd { | |||
400 | unsigned int scan_in_progress:1; /* Schedule scan is running */ | 400 | unsigned int scan_in_progress:1; /* Schedule scan is running */ |
401 | unsigned int need_rescan:1; /* Redo the schedule scan */ | 401 | unsigned int need_rescan:1; /* Redo the schedule scan */ |
402 | unsigned int dead:1; /* Controller has died */ | 402 | unsigned int dead:1; /* Controller has died */ |
403 | unsigned int working_RD:1; /* Suspended root hub doesn't | 403 | unsigned int RD_enable:1; /* Suspended root hub with |
404 | need to be polled */ | 404 | Resume-Detect interrupts |
405 | enabled */ | ||
405 | unsigned int is_initialized:1; /* Data structure is usable */ | 406 | unsigned int is_initialized:1; /* Data structure is usable */ |
406 | unsigned int fsbr_is_on:1; /* FSBR is turned on */ | 407 | unsigned int fsbr_is_on:1; /* FSBR is turned on */ |
407 | unsigned int fsbr_is_wanted:1; /* Does any URB want FSBR? */ | 408 | unsigned int fsbr_is_wanted:1; /* Does any URB want FSBR? */ |
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 11580e81e2c6..7aafd53fbcab 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
@@ -148,7 +148,7 @@ MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in | |||
148 | 148 | ||
149 | /* Structure to hold all of our device specific stuff */ | 149 | /* Structure to hold all of our device specific stuff */ |
150 | struct ld_usb { | 150 | struct ld_usb { |
151 | struct semaphore sem; /* locks this structure */ | 151 | struct mutex mutex; /* locks this structure */ |
152 | struct usb_interface* intf; /* save off the usb interface pointer */ | 152 | struct usb_interface* intf; /* save off the usb interface pointer */ |
153 | 153 | ||
154 | int open_count; /* number of times this port has been opened */ | 154 | int open_count; /* number of times this port has been opened */ |
@@ -319,7 +319,7 @@ static int ld_usb_open(struct inode *inode, struct file *file) | |||
319 | return -ENODEV; | 319 | return -ENODEV; |
320 | 320 | ||
321 | /* lock this device */ | 321 | /* lock this device */ |
322 | if (down_interruptible(&dev->sem)) | 322 | if (mutex_lock_interruptible(&dev->mutex)) |
323 | return -ERESTARTSYS; | 323 | return -ERESTARTSYS; |
324 | 324 | ||
325 | /* allow opening only once */ | 325 | /* allow opening only once */ |
@@ -358,7 +358,7 @@ static int ld_usb_open(struct inode *inode, struct file *file) | |||
358 | file->private_data = dev; | 358 | file->private_data = dev; |
359 | 359 | ||
360 | unlock_exit: | 360 | unlock_exit: |
361 | up(&dev->sem); | 361 | mutex_unlock(&dev->mutex); |
362 | 362 | ||
363 | return retval; | 363 | return retval; |
364 | } | 364 | } |
@@ -378,7 +378,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) | |||
378 | goto exit; | 378 | goto exit; |
379 | } | 379 | } |
380 | 380 | ||
381 | if (down_interruptible(&dev->sem)) { | 381 | if (mutex_lock_interruptible(&dev->mutex)) { |
382 | retval = -ERESTARTSYS; | 382 | retval = -ERESTARTSYS; |
383 | goto exit; | 383 | goto exit; |
384 | } | 384 | } |
@@ -389,7 +389,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) | |||
389 | } | 389 | } |
390 | if (dev->intf == NULL) { | 390 | if (dev->intf == NULL) { |
391 | /* the device was unplugged before the file was released */ | 391 | /* the device was unplugged before the file was released */ |
392 | up(&dev->sem); | 392 | mutex_unlock(&dev->mutex); |
393 | /* unlock here as ld_usb_delete frees dev */ | 393 | /* unlock here as ld_usb_delete frees dev */ |
394 | ld_usb_delete(dev); | 394 | ld_usb_delete(dev); |
395 | goto exit; | 395 | goto exit; |
@@ -402,7 +402,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) | |||
402 | dev->open_count = 0; | 402 | dev->open_count = 0; |
403 | 403 | ||
404 | unlock_exit: | 404 | unlock_exit: |
405 | up(&dev->sem); | 405 | mutex_unlock(&dev->mutex); |
406 | 406 | ||
407 | exit: | 407 | exit: |
408 | return retval; | 408 | return retval; |
@@ -448,7 +448,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, | |||
448 | goto exit; | 448 | goto exit; |
449 | 449 | ||
450 | /* lock this object */ | 450 | /* lock this object */ |
451 | if (down_interruptible(&dev->sem)) { | 451 | if (mutex_lock_interruptible(&dev->mutex)) { |
452 | retval = -ERESTARTSYS; | 452 | retval = -ERESTARTSYS; |
453 | goto exit; | 453 | goto exit; |
454 | } | 454 | } |
@@ -505,7 +505,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, | |||
505 | 505 | ||
506 | unlock_exit: | 506 | unlock_exit: |
507 | /* unlock the device */ | 507 | /* unlock the device */ |
508 | up(&dev->sem); | 508 | mutex_unlock(&dev->mutex); |
509 | 509 | ||
510 | exit: | 510 | exit: |
511 | return retval; | 511 | return retval; |
@@ -528,7 +528,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, | |||
528 | goto exit; | 528 | goto exit; |
529 | 529 | ||
530 | /* lock this object */ | 530 | /* lock this object */ |
531 | if (down_interruptible(&dev->sem)) { | 531 | if (mutex_lock_interruptible(&dev->mutex)) { |
532 | retval = -ERESTARTSYS; | 532 | retval = -ERESTARTSYS; |
533 | goto exit; | 533 | goto exit; |
534 | } | 534 | } |
@@ -602,7 +602,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, | |||
602 | 602 | ||
603 | unlock_exit: | 603 | unlock_exit: |
604 | /* unlock the device */ | 604 | /* unlock the device */ |
605 | up(&dev->sem); | 605 | mutex_unlock(&dev->mutex); |
606 | 606 | ||
607 | exit: | 607 | exit: |
608 | return retval; | 608 | return retval; |
@@ -651,7 +651,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * | |||
651 | dev_err(&intf->dev, "Out of memory\n"); | 651 | dev_err(&intf->dev, "Out of memory\n"); |
652 | goto exit; | 652 | goto exit; |
653 | } | 653 | } |
654 | init_MUTEX(&dev->sem); | 654 | mutex_init(&dev->mutex); |
655 | spin_lock_init(&dev->rbsl); | 655 | spin_lock_init(&dev->rbsl); |
656 | dev->intf = intf; | 656 | dev->intf = intf; |
657 | init_waitqueue_head(&dev->read_wait); | 657 | init_waitqueue_head(&dev->read_wait); |
@@ -765,15 +765,15 @@ static void ld_usb_disconnect(struct usb_interface *intf) | |||
765 | /* give back our minor */ | 765 | /* give back our minor */ |
766 | usb_deregister_dev(intf, &ld_usb_class); | 766 | usb_deregister_dev(intf, &ld_usb_class); |
767 | 767 | ||
768 | down(&dev->sem); | 768 | mutex_lock(&dev->mutex); |
769 | 769 | ||
770 | /* if the device is not opened, then we clean up right now */ | 770 | /* if the device is not opened, then we clean up right now */ |
771 | if (!dev->open_count) { | 771 | if (!dev->open_count) { |
772 | up(&dev->sem); | 772 | mutex_unlock(&dev->mutex); |
773 | ld_usb_delete(dev); | 773 | ld_usb_delete(dev); |
774 | } else { | 774 | } else { |
775 | dev->intf = NULL; | 775 | dev->intf = NULL; |
776 | up(&dev->sem); | 776 | mutex_unlock(&dev->mutex); |
777 | } | 777 | } |
778 | 778 | ||
779 | dev_info(&intf->dev, "LD USB Device #%d now disconnected\n", | 779 | dev_info(&intf->dev, "LD USB Device #%d now disconnected\n", |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index a51983854ca0..742be3c35947 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -79,30 +79,10 @@ static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test) | |||
79 | /* set up all urbs so they can be used with either bulk or interrupt */ | 79 | /* set up all urbs so they can be used with either bulk or interrupt */ |
80 | #define INTERRUPT_RATE 1 /* msec/transfer */ | 80 | #define INTERRUPT_RATE 1 /* msec/transfer */ |
81 | 81 | ||
82 | #define xprintk(tdev,level,fmt,args...) \ | 82 | #define ERROR(tdev, fmt, args...) \ |
83 | dev_printk(level , &(tdev)->intf->dev , fmt , ## args) | 83 | dev_err(&(tdev)->intf->dev , fmt , ## args) |
84 | 84 | #define WARN(tdev, fmt, args...) \ | |
85 | #ifdef DEBUG | 85 | dev_warn(&(tdev)->intf->dev , fmt , ## args) |
86 | #define DBG(dev,fmt,args...) \ | ||
87 | xprintk(dev , KERN_DEBUG , fmt , ## args) | ||
88 | #else | ||
89 | #define DBG(dev,fmt,args...) \ | ||
90 | do { } while (0) | ||
91 | #endif /* DEBUG */ | ||
92 | |||
93 | #ifdef VERBOSE | ||
94 | #define VDBG DBG | ||
95 | #else | ||
96 | #define VDBG(dev,fmt,args...) \ | ||
97 | do { } while (0) | ||
98 | #endif /* VERBOSE */ | ||
99 | |||
100 | #define ERROR(dev,fmt,args...) \ | ||
101 | xprintk(dev , KERN_ERR , fmt , ## args) | ||
102 | #define WARN(dev,fmt,args...) \ | ||
103 | xprintk(dev , KERN_WARNING , fmt , ## args) | ||
104 | #define INFO(dev,fmt,args...) \ | ||
105 | xprintk(dev , KERN_INFO , fmt , ## args) | ||
106 | 86 | ||
107 | /*-------------------------------------------------------------------------*/ | 87 | /*-------------------------------------------------------------------------*/ |
108 | 88 | ||
@@ -236,7 +216,7 @@ static struct urb *simple_alloc_urb ( | |||
236 | 216 | ||
237 | static unsigned pattern = 0; | 217 | static unsigned pattern = 0; |
238 | module_param (pattern, uint, S_IRUGO); | 218 | module_param (pattern, uint, S_IRUGO); |
239 | // MODULE_PARM_DESC (pattern, "i/o pattern (0 == zeroes)"); | 219 | MODULE_PARM_DESC(pattern, "i/o pattern (0 == zeroes)"); |
240 | 220 | ||
241 | static inline void simple_fill_buf (struct urb *urb) | 221 | static inline void simple_fill_buf (struct urb *urb) |
242 | { | 222 | { |
@@ -257,7 +237,7 @@ static inline void simple_fill_buf (struct urb *urb) | |||
257 | } | 237 | } |
258 | } | 238 | } |
259 | 239 | ||
260 | static inline int simple_check_buf (struct urb *urb) | 240 | static inline int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb) |
261 | { | 241 | { |
262 | unsigned i; | 242 | unsigned i; |
263 | u8 expected; | 243 | u8 expected; |
@@ -285,7 +265,7 @@ static inline int simple_check_buf (struct urb *urb) | |||
285 | } | 265 | } |
286 | if (*buf == expected) | 266 | if (*buf == expected) |
287 | continue; | 267 | continue; |
288 | dbg ("buf[%d] = %d (not %d)", i, *buf, expected); | 268 | ERROR(tdev, "buf[%d] = %d (not %d)\n", i, *buf, expected); |
289 | return -EINVAL; | 269 | return -EINVAL; |
290 | } | 270 | } |
291 | return 0; | 271 | return 0; |
@@ -299,6 +279,7 @@ static void simple_free_urb (struct urb *urb) | |||
299 | } | 279 | } |
300 | 280 | ||
301 | static int simple_io ( | 281 | static int simple_io ( |
282 | struct usbtest_dev *tdev, | ||
302 | struct urb *urb, | 283 | struct urb *urb, |
303 | int iterations, | 284 | int iterations, |
304 | int vary, | 285 | int vary, |
@@ -324,7 +305,7 @@ static int simple_io ( | |||
324 | retval = urb->status; | 305 | retval = urb->status; |
325 | urb->dev = udev; | 306 | urb->dev = udev; |
326 | if (retval == 0 && usb_pipein (urb->pipe)) | 307 | if (retval == 0 && usb_pipein (urb->pipe)) |
327 | retval = simple_check_buf (urb); | 308 | retval = simple_check_buf(tdev, urb); |
328 | 309 | ||
329 | if (vary) { | 310 | if (vary) { |
330 | int len = urb->transfer_buffer_length; | 311 | int len = urb->transfer_buffer_length; |
@@ -341,7 +322,7 @@ static int simple_io ( | |||
341 | urb->transfer_buffer_length = max; | 322 | urb->transfer_buffer_length = max; |
342 | 323 | ||
343 | if (expected != retval) | 324 | if (expected != retval) |
344 | dev_dbg (&udev->dev, | 325 | dev_err(&udev->dev, |
345 | "%s failed, iterations left %d, status %d (not %d)\n", | 326 | "%s failed, iterations left %d, status %d (not %d)\n", |
346 | label, iterations, retval, expected); | 327 | label, iterations, retval, expected); |
347 | return retval; | 328 | return retval; |
@@ -357,7 +338,7 @@ static int simple_io ( | |||
357 | static void free_sglist (struct scatterlist *sg, int nents) | 338 | static void free_sglist (struct scatterlist *sg, int nents) |
358 | { | 339 | { |
359 | unsigned i; | 340 | unsigned i; |
360 | 341 | ||
361 | if (!sg) | 342 | if (!sg) |
362 | return; | 343 | return; |
363 | for (i = 0; i < nents; i++) { | 344 | for (i = 0; i < nents; i++) { |
@@ -415,7 +396,7 @@ alloc_sglist (int nents, int max, int vary) | |||
415 | } | 396 | } |
416 | 397 | ||
417 | static int perform_sglist ( | 398 | static int perform_sglist ( |
418 | struct usb_device *udev, | 399 | struct usbtest_dev *tdev, |
419 | unsigned iterations, | 400 | unsigned iterations, |
420 | int pipe, | 401 | int pipe, |
421 | struct usb_sg_request *req, | 402 | struct usb_sg_request *req, |
@@ -423,6 +404,7 @@ static int perform_sglist ( | |||
423 | int nents | 404 | int nents |
424 | ) | 405 | ) |
425 | { | 406 | { |
407 | struct usb_device *udev = testdev_to_usbdev(tdev); | ||
426 | int retval = 0; | 408 | int retval = 0; |
427 | 409 | ||
428 | while (retval == 0 && iterations-- > 0) { | 410 | while (retval == 0 && iterations-- > 0) { |
@@ -431,7 +413,7 @@ static int perform_sglist ( | |||
431 | ? (INTERRUPT_RATE << 3) | 413 | ? (INTERRUPT_RATE << 3) |
432 | : INTERRUPT_RATE, | 414 | : INTERRUPT_RATE, |
433 | sg, nents, 0, GFP_KERNEL); | 415 | sg, nents, 0, GFP_KERNEL); |
434 | 416 | ||
435 | if (retval) | 417 | if (retval) |
436 | break; | 418 | break; |
437 | usb_sg_wait (req); | 419 | usb_sg_wait (req); |
@@ -446,7 +428,8 @@ static int perform_sglist ( | |||
446 | // failure if retval is as we expected ... | 428 | // failure if retval is as we expected ... |
447 | 429 | ||
448 | if (retval) | 430 | if (retval) |
449 | dbg ("perform_sglist failed, iterations left %d, status %d", | 431 | ERROR(tdev, "perform_sglist failed, " |
432 | "iterations left %d, status %d\n", | ||
450 | iterations, retval); | 433 | iterations, retval); |
451 | return retval; | 434 | return retval; |
452 | } | 435 | } |
@@ -505,28 +488,28 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate) | |||
505 | alternate); | 488 | alternate); |
506 | } | 489 | } |
507 | 490 | ||
508 | static int is_good_config (char *buf, int len) | 491 | static int is_good_config(struct usbtest_dev *tdev, int len) |
509 | { | 492 | { |
510 | struct usb_config_descriptor *config; | 493 | struct usb_config_descriptor *config; |
511 | 494 | ||
512 | if (len < sizeof *config) | 495 | if (len < sizeof *config) |
513 | return 0; | 496 | return 0; |
514 | config = (struct usb_config_descriptor *) buf; | 497 | config = (struct usb_config_descriptor *) tdev->buf; |
515 | 498 | ||
516 | switch (config->bDescriptorType) { | 499 | switch (config->bDescriptorType) { |
517 | case USB_DT_CONFIG: | 500 | case USB_DT_CONFIG: |
518 | case USB_DT_OTHER_SPEED_CONFIG: | 501 | case USB_DT_OTHER_SPEED_CONFIG: |
519 | if (config->bLength != 9) { | 502 | if (config->bLength != 9) { |
520 | dbg ("bogus config descriptor length"); | 503 | ERROR(tdev, "bogus config descriptor length\n"); |
521 | return 0; | 504 | return 0; |
522 | } | 505 | } |
523 | /* this bit 'must be 1' but often isn't */ | 506 | /* this bit 'must be 1' but often isn't */ |
524 | if (!realworld && !(config->bmAttributes & 0x80)) { | 507 | if (!realworld && !(config->bmAttributes & 0x80)) { |
525 | dbg ("high bit of config attributes not set"); | 508 | ERROR(tdev, "high bit of config attributes not set\n"); |
526 | return 0; | 509 | return 0; |
527 | } | 510 | } |
528 | if (config->bmAttributes & 0x1f) { /* reserved == 0 */ | 511 | if (config->bmAttributes & 0x1f) { /* reserved == 0 */ |
529 | dbg ("reserved config bits set"); | 512 | ERROR(tdev, "reserved config bits set\n"); |
530 | return 0; | 513 | return 0; |
531 | } | 514 | } |
532 | break; | 515 | break; |
@@ -538,7 +521,7 @@ static int is_good_config (char *buf, int len) | |||
538 | return 1; | 521 | return 1; |
539 | if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ | 522 | if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ |
540 | return 1; | 523 | return 1; |
541 | dbg ("bogus config descriptor read size"); | 524 | ERROR(tdev, "bogus config descriptor read size\n"); |
542 | return 0; | 525 | return 0; |
543 | } | 526 | } |
544 | 527 | ||
@@ -571,7 +554,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
571 | /* 9.2.3 constrains the range here */ | 554 | /* 9.2.3 constrains the range here */ |
572 | alt = iface->altsetting [i].desc.bAlternateSetting; | 555 | alt = iface->altsetting [i].desc.bAlternateSetting; |
573 | if (alt < 0 || alt >= iface->num_altsetting) { | 556 | if (alt < 0 || alt >= iface->num_altsetting) { |
574 | dev_dbg (&iface->dev, | 557 | dev_err(&iface->dev, |
575 | "invalid alt [%d].bAltSetting = %d\n", | 558 | "invalid alt [%d].bAltSetting = %d\n", |
576 | i, alt); | 559 | i, alt); |
577 | } | 560 | } |
@@ -583,7 +566,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
583 | /* [9.4.10] set_interface */ | 566 | /* [9.4.10] set_interface */ |
584 | retval = set_altsetting (dev, alt); | 567 | retval = set_altsetting (dev, alt); |
585 | if (retval) { | 568 | if (retval) { |
586 | dev_dbg (&iface->dev, "can't set_interface = %d, %d\n", | 569 | dev_err(&iface->dev, "can't set_interface = %d, %d\n", |
587 | alt, retval); | 570 | alt, retval); |
588 | return retval; | 571 | return retval; |
589 | } | 572 | } |
@@ -591,7 +574,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
591 | /* [9.4.4] get_interface always works */ | 574 | /* [9.4.4] get_interface always works */ |
592 | retval = get_altsetting (dev); | 575 | retval = get_altsetting (dev); |
593 | if (retval != alt) { | 576 | if (retval != alt) { |
594 | dev_dbg (&iface->dev, "get alt should be %d, was %d\n", | 577 | dev_err(&iface->dev, "get alt should be %d, was %d\n", |
595 | alt, retval); | 578 | alt, retval); |
596 | return (retval < 0) ? retval : -EDOM; | 579 | return (retval < 0) ? retval : -EDOM; |
597 | } | 580 | } |
@@ -611,7 +594,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
611 | USB_DIR_IN | USB_RECIP_DEVICE, | 594 | USB_DIR_IN | USB_RECIP_DEVICE, |
612 | 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); | 595 | 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); |
613 | if (retval != 1 || dev->buf [0] != expected) { | 596 | if (retval != 1 || dev->buf [0] != expected) { |
614 | dev_dbg (&iface->dev, "get config --> %d %d (1 %d)\n", | 597 | dev_err(&iface->dev, "get config --> %d %d (1 %d)\n", |
615 | retval, dev->buf[0], expected); | 598 | retval, dev->buf[0], expected); |
616 | return (retval < 0) ? retval : -EDOM; | 599 | return (retval < 0) ? retval : -EDOM; |
617 | } | 600 | } |
@@ -621,7 +604,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
621 | retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0, | 604 | retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0, |
622 | dev->buf, sizeof udev->descriptor); | 605 | dev->buf, sizeof udev->descriptor); |
623 | if (retval != sizeof udev->descriptor) { | 606 | if (retval != sizeof udev->descriptor) { |
624 | dev_dbg (&iface->dev, "dev descriptor --> %d\n", retval); | 607 | dev_err(&iface->dev, "dev descriptor --> %d\n", retval); |
625 | return (retval < 0) ? retval : -EDOM; | 608 | return (retval < 0) ? retval : -EDOM; |
626 | } | 609 | } |
627 | 610 | ||
@@ -629,8 +612,8 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
629 | for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { | 612 | for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { |
630 | retval = usb_get_descriptor (udev, USB_DT_CONFIG, i, | 613 | retval = usb_get_descriptor (udev, USB_DT_CONFIG, i, |
631 | dev->buf, TBUF_SIZE); | 614 | dev->buf, TBUF_SIZE); |
632 | if (!is_good_config (dev->buf, retval)) { | 615 | if (!is_good_config(dev, retval)) { |
633 | dev_dbg (&iface->dev, | 616 | dev_err(&iface->dev, |
634 | "config [%d] descriptor --> %d\n", | 617 | "config [%d] descriptor --> %d\n", |
635 | i, retval); | 618 | i, retval); |
636 | return (retval < 0) ? retval : -EDOM; | 619 | return (retval < 0) ? retval : -EDOM; |
@@ -650,14 +633,14 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
650 | sizeof (struct usb_qualifier_descriptor)); | 633 | sizeof (struct usb_qualifier_descriptor)); |
651 | if (retval == -EPIPE) { | 634 | if (retval == -EPIPE) { |
652 | if (udev->speed == USB_SPEED_HIGH) { | 635 | if (udev->speed == USB_SPEED_HIGH) { |
653 | dev_dbg (&iface->dev, | 636 | dev_err(&iface->dev, |
654 | "hs dev qualifier --> %d\n", | 637 | "hs dev qualifier --> %d\n", |
655 | retval); | 638 | retval); |
656 | return (retval < 0) ? retval : -EDOM; | 639 | return (retval < 0) ? retval : -EDOM; |
657 | } | 640 | } |
658 | /* usb2.0 but not high-speed capable; fine */ | 641 | /* usb2.0 but not high-speed capable; fine */ |
659 | } else if (retval != sizeof (struct usb_qualifier_descriptor)) { | 642 | } else if (retval != sizeof (struct usb_qualifier_descriptor)) { |
660 | dev_dbg (&iface->dev, "dev qualifier --> %d\n", retval); | 643 | dev_err(&iface->dev, "dev qualifier --> %d\n", retval); |
661 | return (retval < 0) ? retval : -EDOM; | 644 | return (retval < 0) ? retval : -EDOM; |
662 | } else | 645 | } else |
663 | d = (struct usb_qualifier_descriptor *) dev->buf; | 646 | d = (struct usb_qualifier_descriptor *) dev->buf; |
@@ -669,8 +652,8 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
669 | retval = usb_get_descriptor (udev, | 652 | retval = usb_get_descriptor (udev, |
670 | USB_DT_OTHER_SPEED_CONFIG, i, | 653 | USB_DT_OTHER_SPEED_CONFIG, i, |
671 | dev->buf, TBUF_SIZE); | 654 | dev->buf, TBUF_SIZE); |
672 | if (!is_good_config (dev->buf, retval)) { | 655 | if (!is_good_config(dev, retval)) { |
673 | dev_dbg (&iface->dev, | 656 | dev_err(&iface->dev, |
674 | "other speed config --> %d\n", | 657 | "other speed config --> %d\n", |
675 | retval); | 658 | retval); |
676 | return (retval < 0) ? retval : -EDOM; | 659 | return (retval < 0) ? retval : -EDOM; |
@@ -683,7 +666,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
683 | /* [9.4.5] get_status always works */ | 666 | /* [9.4.5] get_status always works */ |
684 | retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf); | 667 | retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf); |
685 | if (retval != 2) { | 668 | if (retval != 2) { |
686 | dev_dbg (&iface->dev, "get dev status --> %d\n", retval); | 669 | dev_err(&iface->dev, "get dev status --> %d\n", retval); |
687 | return (retval < 0) ? retval : -EDOM; | 670 | return (retval < 0) ? retval : -EDOM; |
688 | } | 671 | } |
689 | 672 | ||
@@ -693,11 +676,11 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
693 | retval = usb_get_status (udev, USB_RECIP_INTERFACE, | 676 | retval = usb_get_status (udev, USB_RECIP_INTERFACE, |
694 | iface->altsetting [0].desc.bInterfaceNumber, dev->buf); | 677 | iface->altsetting [0].desc.bInterfaceNumber, dev->buf); |
695 | if (retval != 2) { | 678 | if (retval != 2) { |
696 | dev_dbg (&iface->dev, "get interface status --> %d\n", retval); | 679 | dev_err(&iface->dev, "get interface status --> %d\n", retval); |
697 | return (retval < 0) ? retval : -EDOM; | 680 | return (retval < 0) ? retval : -EDOM; |
698 | } | 681 | } |
699 | // FIXME get status for each endpoint in the interface | 682 | // FIXME get status for each endpoint in the interface |
700 | 683 | ||
701 | return 0; | 684 | return 0; |
702 | } | 685 | } |
703 | 686 | ||
@@ -752,8 +735,9 @@ static void ctrl_complete (struct urb *urb) | |||
752 | */ | 735 | */ |
753 | if (subcase->number > 0) { | 736 | if (subcase->number > 0) { |
754 | if ((subcase->number - ctx->last) != 1) { | 737 | if ((subcase->number - ctx->last) != 1) { |
755 | dbg ("subcase %d completed out of order, last %d", | 738 | ERROR(ctx->dev, |
756 | subcase->number, ctx->last); | 739 | "subcase %d completed out of order, last %d\n", |
740 | subcase->number, ctx->last); | ||
757 | status = -EDOM; | 741 | status = -EDOM; |
758 | ctx->last = subcase->number; | 742 | ctx->last = subcase->number; |
759 | goto error; | 743 | goto error; |
@@ -777,7 +761,7 @@ static void ctrl_complete (struct urb *urb) | |||
777 | else if (subcase->number == 12 && status == -EPIPE) | 761 | else if (subcase->number == 12 && status == -EPIPE) |
778 | status = 0; | 762 | status = 0; |
779 | else | 763 | else |
780 | dbg ("subtest %d error, status %d", | 764 | ERROR(ctx->dev, "subtest %d error, status %d\n", |
781 | subcase->number, status); | 765 | subcase->number, status); |
782 | } | 766 | } |
783 | 767 | ||
@@ -788,9 +772,12 @@ error: | |||
788 | int i; | 772 | int i; |
789 | 773 | ||
790 | ctx->status = status; | 774 | ctx->status = status; |
791 | info ("control queue %02x.%02x, err %d, %d left", | 775 | ERROR(ctx->dev, "control queue %02x.%02x, err %d, " |
776 | "%d left, subcase %d, len %d/%d\n", | ||
792 | reqp->bRequestType, reqp->bRequest, | 777 | reqp->bRequestType, reqp->bRequest, |
793 | status, ctx->count); | 778 | status, ctx->count, subcase->number, |
779 | urb->actual_length, | ||
780 | urb->transfer_buffer_length); | ||
794 | 781 | ||
795 | /* FIXME this "unlink everything" exit route should | 782 | /* FIXME this "unlink everything" exit route should |
796 | * be a separate test case. | 783 | * be a separate test case. |
@@ -799,7 +786,8 @@ error: | |||
799 | /* unlink whatever's still pending */ | 786 | /* unlink whatever's still pending */ |
800 | for (i = 1; i < ctx->param->sglen; i++) { | 787 | for (i = 1; i < ctx->param->sglen; i++) { |
801 | struct urb *u = ctx->urb [ | 788 | struct urb *u = ctx->urb [ |
802 | (i + subcase->number) % ctx->param->sglen]; | 789 | (i + subcase->number) |
790 | % ctx->param->sglen]; | ||
803 | 791 | ||
804 | if (u == urb || !u->dev) | 792 | if (u == urb || !u->dev) |
805 | continue; | 793 | continue; |
@@ -812,7 +800,8 @@ error: | |||
812 | case -EIDRM: | 800 | case -EIDRM: |
813 | continue; | 801 | continue; |
814 | default: | 802 | default: |
815 | dbg ("urb unlink --> %d", status); | 803 | ERROR(ctx->dev, "urb unlink --> %d\n", |
804 | status); | ||
816 | } | 805 | } |
817 | } | 806 | } |
818 | status = ctx->status; | 807 | status = ctx->status; |
@@ -822,14 +811,15 @@ error: | |||
822 | /* resubmit if we need to, else mark this as done */ | 811 | /* resubmit if we need to, else mark this as done */ |
823 | if ((status == 0) && (ctx->pending < ctx->count)) { | 812 | if ((status == 0) && (ctx->pending < ctx->count)) { |
824 | if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) { | 813 | if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) { |
825 | dbg ("can't resubmit ctrl %02x.%02x, err %d", | 814 | ERROR(ctx->dev, |
815 | "can't resubmit ctrl %02x.%02x, err %d\n", | ||
826 | reqp->bRequestType, reqp->bRequest, status); | 816 | reqp->bRequestType, reqp->bRequest, status); |
827 | urb->dev = NULL; | 817 | urb->dev = NULL; |
828 | } else | 818 | } else |
829 | ctx->pending++; | 819 | ctx->pending++; |
830 | } else | 820 | } else |
831 | urb->dev = NULL; | 821 | urb->dev = NULL; |
832 | 822 | ||
833 | /* signal completion when nothing's queued */ | 823 | /* signal completion when nothing's queued */ |
834 | if (ctx->pending == 0) | 824 | if (ctx->pending == 0) |
835 | complete (&ctx->complete); | 825 | complete (&ctx->complete); |
@@ -918,11 +908,11 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
918 | req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); | 908 | req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); |
919 | // interface == 0 | 909 | // interface == 0 |
920 | len = sizeof (struct usb_interface_descriptor); | 910 | len = sizeof (struct usb_interface_descriptor); |
921 | expected = EPIPE; | 911 | expected = -EPIPE; |
922 | break; | 912 | break; |
923 | // NOTE: two consecutive stalls in the queue here. | 913 | // NOTE: two consecutive stalls in the queue here. |
924 | // that tests fault recovery a bit more aggressively. | 914 | // that tests fault recovery a bit more aggressively. |
925 | case 8: // clear endpoint halt (USUALLY STALLS) | 915 | case 8: // clear endpoint halt (MAY STALL) |
926 | req.bRequest = USB_REQ_CLEAR_FEATURE; | 916 | req.bRequest = USB_REQ_CLEAR_FEATURE; |
927 | req.bRequestType = USB_RECIP_ENDPOINT; | 917 | req.bRequestType = USB_RECIP_ENDPOINT; |
928 | // wValue 0 == ep halt | 918 | // wValue 0 == ep halt |
@@ -965,7 +955,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
965 | break; | 955 | break; |
966 | case 14: // short read; try to fill the last packet | 956 | case 14: // short read; try to fill the last packet |
967 | req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0); | 957 | req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0); |
968 | // device descriptor size == 18 bytes | 958 | /* device descriptor size == 18 bytes */ |
969 | len = udev->descriptor.bMaxPacketSize0; | 959 | len = udev->descriptor.bMaxPacketSize0; |
970 | switch (len) { | 960 | switch (len) { |
971 | case 8: len = 24; break; | 961 | case 8: len = 24; break; |
@@ -974,7 +964,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
974 | expected = -EREMOTEIO; | 964 | expected = -EREMOTEIO; |
975 | break; | 965 | break; |
976 | default: | 966 | default: |
977 | err ("bogus number of ctrl queue testcases!"); | 967 | ERROR(dev, "bogus number of ctrl queue testcases!\n"); |
978 | context.status = -EINVAL; | 968 | context.status = -EINVAL; |
979 | goto cleanup; | 969 | goto cleanup; |
980 | } | 970 | } |
@@ -1003,7 +993,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
1003 | for (i = 0; i < param->sglen; i++) { | 993 | for (i = 0; i < param->sglen; i++) { |
1004 | context.status = usb_submit_urb (urb [i], GFP_ATOMIC); | 994 | context.status = usb_submit_urb (urb [i], GFP_ATOMIC); |
1005 | if (context.status != 0) { | 995 | if (context.status != 0) { |
1006 | dbg ("can't submit urb[%d], status %d", | 996 | ERROR(dev, "can't submit urb[%d], status %d\n", |
1007 | i, context.status); | 997 | i, context.status); |
1008 | context.count = context.pending; | 998 | context.count = context.pending; |
1009 | break; | 999 | break; |
@@ -1070,7 +1060,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | |||
1070 | * due to errors, or is just NAKing requests. | 1060 | * due to errors, or is just NAKing requests. |
1071 | */ | 1061 | */ |
1072 | if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) { | 1062 | if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) { |
1073 | dev_dbg (&dev->intf->dev, "submit fail %d\n", retval); | 1063 | dev_err(&dev->intf->dev, "submit fail %d\n", retval); |
1074 | return retval; | 1064 | return retval; |
1075 | } | 1065 | } |
1076 | 1066 | ||
@@ -1087,13 +1077,13 @@ retry: | |||
1087 | * "normal" drivers would prevent resubmission, but | 1077 | * "normal" drivers would prevent resubmission, but |
1088 | * since we're testing unlink paths, we can't. | 1078 | * since we're testing unlink paths, we can't. |
1089 | */ | 1079 | */ |
1090 | dev_dbg (&dev->intf->dev, "unlink retry\n"); | 1080 | ERROR(dev, "unlink retry\n"); |
1091 | goto retry; | 1081 | goto retry; |
1092 | } | 1082 | } |
1093 | } else | 1083 | } else |
1094 | usb_kill_urb (urb); | 1084 | usb_kill_urb (urb); |
1095 | if (!(retval == 0 || retval == -EINPROGRESS)) { | 1085 | if (!(retval == 0 || retval == -EINPROGRESS)) { |
1096 | dev_dbg (&dev->intf->dev, "unlink fail %d\n", retval); | 1086 | dev_err(&dev->intf->dev, "unlink fail %d\n", retval); |
1097 | return retval; | 1087 | return retval; |
1098 | } | 1088 | } |
1099 | 1089 | ||
@@ -1121,7 +1111,7 @@ static int unlink_simple (struct usbtest_dev *dev, int pipe, int len) | |||
1121 | 1111 | ||
1122 | /*-------------------------------------------------------------------------*/ | 1112 | /*-------------------------------------------------------------------------*/ |
1123 | 1113 | ||
1124 | static int verify_not_halted (int ep, struct urb *urb) | 1114 | static int verify_not_halted(struct usbtest_dev *tdev, int ep, struct urb *urb) |
1125 | { | 1115 | { |
1126 | int retval; | 1116 | int retval; |
1127 | u16 status; | 1117 | u16 status; |
@@ -1129,20 +1119,21 @@ static int verify_not_halted (int ep, struct urb *urb) | |||
1129 | /* shouldn't look or act halted */ | 1119 | /* shouldn't look or act halted */ |
1130 | retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); | 1120 | retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); |
1131 | if (retval < 0) { | 1121 | if (retval < 0) { |
1132 | dbg ("ep %02x couldn't get no-halt status, %d", ep, retval); | 1122 | ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n", |
1123 | ep, retval); | ||
1133 | return retval; | 1124 | return retval; |
1134 | } | 1125 | } |
1135 | if (status != 0) { | 1126 | if (status != 0) { |
1136 | dbg ("ep %02x bogus status: %04x != 0", ep, status); | 1127 | ERROR(tdev, "ep %02x bogus status: %04x != 0\n", ep, status); |
1137 | return -EINVAL; | 1128 | return -EINVAL; |
1138 | } | 1129 | } |
1139 | retval = simple_io (urb, 1, 0, 0, __func__); | 1130 | retval = simple_io(tdev, urb, 1, 0, 0, __func__); |
1140 | if (retval != 0) | 1131 | if (retval != 0) |
1141 | return -EINVAL; | 1132 | return -EINVAL; |
1142 | return 0; | 1133 | return 0; |
1143 | } | 1134 | } |
1144 | 1135 | ||
1145 | static int verify_halted (int ep, struct urb *urb) | 1136 | static int verify_halted(struct usbtest_dev *tdev, int ep, struct urb *urb) |
1146 | { | 1137 | { |
1147 | int retval; | 1138 | int retval; |
1148 | u16 status; | 1139 | u16 status; |
@@ -1150,29 +1141,30 @@ static int verify_halted (int ep, struct urb *urb) | |||
1150 | /* should look and act halted */ | 1141 | /* should look and act halted */ |
1151 | retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); | 1142 | retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); |
1152 | if (retval < 0) { | 1143 | if (retval < 0) { |
1153 | dbg ("ep %02x couldn't get halt status, %d", ep, retval); | 1144 | ERROR(tdev, "ep %02x couldn't get halt status, %d\n", |
1145 | ep, retval); | ||
1154 | return retval; | 1146 | return retval; |
1155 | } | 1147 | } |
1156 | le16_to_cpus(&status); | 1148 | le16_to_cpus(&status); |
1157 | if (status != 1) { | 1149 | if (status != 1) { |
1158 | dbg ("ep %02x bogus status: %04x != 1", ep, status); | 1150 | ERROR(tdev, "ep %02x bogus status: %04x != 1\n", ep, status); |
1159 | return -EINVAL; | 1151 | return -EINVAL; |
1160 | } | 1152 | } |
1161 | retval = simple_io (urb, 1, 0, -EPIPE, __func__); | 1153 | retval = simple_io(tdev, urb, 1, 0, -EPIPE, __func__); |
1162 | if (retval != -EPIPE) | 1154 | if (retval != -EPIPE) |
1163 | return -EINVAL; | 1155 | return -EINVAL; |
1164 | retval = simple_io (urb, 1, 0, -EPIPE, "verify_still_halted"); | 1156 | retval = simple_io(tdev, urb, 1, 0, -EPIPE, "verify_still_halted"); |
1165 | if (retval != -EPIPE) | 1157 | if (retval != -EPIPE) |
1166 | return -EINVAL; | 1158 | return -EINVAL; |
1167 | return 0; | 1159 | return 0; |
1168 | } | 1160 | } |
1169 | 1161 | ||
1170 | static int test_halt (int ep, struct urb *urb) | 1162 | static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb) |
1171 | { | 1163 | { |
1172 | int retval; | 1164 | int retval; |
1173 | 1165 | ||
1174 | /* shouldn't look or act halted now */ | 1166 | /* shouldn't look or act halted now */ |
1175 | retval = verify_not_halted (ep, urb); | 1167 | retval = verify_not_halted(tdev, ep, urb); |
1176 | if (retval < 0) | 1168 | if (retval < 0) |
1177 | return retval; | 1169 | return retval; |
1178 | 1170 | ||
@@ -1182,20 +1174,20 @@ static int test_halt (int ep, struct urb *urb) | |||
1182 | USB_ENDPOINT_HALT, ep, | 1174 | USB_ENDPOINT_HALT, ep, |
1183 | NULL, 0, USB_CTRL_SET_TIMEOUT); | 1175 | NULL, 0, USB_CTRL_SET_TIMEOUT); |
1184 | if (retval < 0) { | 1176 | if (retval < 0) { |
1185 | dbg ("ep %02x couldn't set halt, %d", ep, retval); | 1177 | ERROR(tdev, "ep %02x couldn't set halt, %d\n", ep, retval); |
1186 | return retval; | 1178 | return retval; |
1187 | } | 1179 | } |
1188 | retval = verify_halted (ep, urb); | 1180 | retval = verify_halted(tdev, ep, urb); |
1189 | if (retval < 0) | 1181 | if (retval < 0) |
1190 | return retval; | 1182 | return retval; |
1191 | 1183 | ||
1192 | /* clear halt (tests API + protocol), verify it worked */ | 1184 | /* clear halt (tests API + protocol), verify it worked */ |
1193 | retval = usb_clear_halt (urb->dev, urb->pipe); | 1185 | retval = usb_clear_halt (urb->dev, urb->pipe); |
1194 | if (retval < 0) { | 1186 | if (retval < 0) { |
1195 | dbg ("ep %02x couldn't clear halt, %d", ep, retval); | 1187 | ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval); |
1196 | return retval; | 1188 | return retval; |
1197 | } | 1189 | } |
1198 | retval = verify_not_halted (ep, urb); | 1190 | retval = verify_not_halted(tdev, ep, urb); |
1199 | if (retval < 0) | 1191 | if (retval < 0) |
1200 | return retval; | 1192 | return retval; |
1201 | 1193 | ||
@@ -1217,7 +1209,7 @@ static int halt_simple (struct usbtest_dev *dev) | |||
1217 | if (dev->in_pipe) { | 1209 | if (dev->in_pipe) { |
1218 | ep = usb_pipeendpoint (dev->in_pipe) | USB_DIR_IN; | 1210 | ep = usb_pipeendpoint (dev->in_pipe) | USB_DIR_IN; |
1219 | urb->pipe = dev->in_pipe; | 1211 | urb->pipe = dev->in_pipe; |
1220 | retval = test_halt (ep, urb); | 1212 | retval = test_halt(dev, ep, urb); |
1221 | if (retval < 0) | 1213 | if (retval < 0) |
1222 | goto done; | 1214 | goto done; |
1223 | } | 1215 | } |
@@ -1225,7 +1217,7 @@ static int halt_simple (struct usbtest_dev *dev) | |||
1225 | if (dev->out_pipe) { | 1217 | if (dev->out_pipe) { |
1226 | ep = usb_pipeendpoint (dev->out_pipe); | 1218 | ep = usb_pipeendpoint (dev->out_pipe); |
1227 | urb->pipe = dev->out_pipe; | 1219 | urb->pipe = dev->out_pipe; |
1228 | retval = test_halt (ep, urb); | 1220 | retval = test_halt(dev, ep, urb); |
1229 | } | 1221 | } |
1230 | done: | 1222 | done: |
1231 | simple_free_urb (urb); | 1223 | simple_free_urb (urb); |
@@ -1275,7 +1267,7 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1275 | if (retval != len) { | 1267 | if (retval != len) { |
1276 | what = "write"; | 1268 | what = "write"; |
1277 | if (retval >= 0) { | 1269 | if (retval >= 0) { |
1278 | INFO(dev, "ctrl_out, wlen %d (expected %d)\n", | 1270 | ERROR(dev, "ctrl_out, wlen %d (expected %d)\n", |
1279 | retval, len); | 1271 | retval, len); |
1280 | retval = -EBADMSG; | 1272 | retval = -EBADMSG; |
1281 | } | 1273 | } |
@@ -1289,7 +1281,7 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1289 | if (retval != len) { | 1281 | if (retval != len) { |
1290 | what = "read"; | 1282 | what = "read"; |
1291 | if (retval >= 0) { | 1283 | if (retval >= 0) { |
1292 | INFO(dev, "ctrl_out, rlen %d (expected %d)\n", | 1284 | ERROR(dev, "ctrl_out, rlen %d (expected %d)\n", |
1293 | retval, len); | 1285 | retval, len); |
1294 | retval = -EBADMSG; | 1286 | retval = -EBADMSG; |
1295 | } | 1287 | } |
@@ -1299,7 +1291,7 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1299 | /* fail if we can't verify */ | 1291 | /* fail if we can't verify */ |
1300 | for (j = 0; j < len; j++) { | 1292 | for (j = 0; j < len; j++) { |
1301 | if (buf [j] != (u8) (i + j)) { | 1293 | if (buf [j] != (u8) (i + j)) { |
1302 | INFO (dev, "ctrl_out, byte %d is %d not %d\n", | 1294 | ERROR(dev, "ctrl_out, byte %d is %d not %d\n", |
1303 | j, buf [j], (u8) i + j); | 1295 | j, buf [j], (u8) i + j); |
1304 | retval = -EBADMSG; | 1296 | retval = -EBADMSG; |
1305 | break; | 1297 | break; |
@@ -1321,7 +1313,7 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1321 | } | 1313 | } |
1322 | 1314 | ||
1323 | if (retval < 0) | 1315 | if (retval < 0) |
1324 | INFO (dev, "ctrl_out %s failed, code %d, count %d\n", | 1316 | ERROR (dev, "ctrl_out %s failed, code %d, count %d\n", |
1325 | what, retval, i); | 1317 | what, retval, i); |
1326 | 1318 | ||
1327 | kfree (buf); | 1319 | kfree (buf); |
@@ -1366,7 +1358,7 @@ static void iso_callback (struct urb *urb) | |||
1366 | case 0: | 1358 | case 0: |
1367 | goto done; | 1359 | goto done; |
1368 | default: | 1360 | default: |
1369 | dev_dbg (&ctx->dev->intf->dev, | 1361 | dev_err(&ctx->dev->intf->dev, |
1370 | "iso resubmit err %d\n", | 1362 | "iso resubmit err %d\n", |
1371 | status); | 1363 | status); |
1372 | /* FALLTHROUGH */ | 1364 | /* FALLTHROUGH */ |
@@ -1381,7 +1373,7 @@ static void iso_callback (struct urb *urb) | |||
1381 | ctx->pending--; | 1373 | ctx->pending--; |
1382 | if (ctx->pending == 0) { | 1374 | if (ctx->pending == 0) { |
1383 | if (ctx->errors) | 1375 | if (ctx->errors) |
1384 | dev_dbg (&ctx->dev->intf->dev, | 1376 | dev_err(&ctx->dev->intf->dev, |
1385 | "iso test, %lu errors out of %lu\n", | 1377 | "iso test, %lu errors out of %lu\n", |
1386 | ctx->errors, ctx->packet_count); | 1378 | ctx->errors, ctx->packet_count); |
1387 | complete (&ctx->done); | 1379 | complete (&ctx->done); |
@@ -1458,7 +1450,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1458 | 1450 | ||
1459 | memset (urbs, 0, sizeof urbs); | 1451 | memset (urbs, 0, sizeof urbs); |
1460 | udev = testdev_to_usbdev (dev); | 1452 | udev = testdev_to_usbdev (dev); |
1461 | dev_dbg (&dev->intf->dev, | 1453 | dev_info(&dev->intf->dev, |
1462 | "... iso period %d %sframes, wMaxPacket %04x\n", | 1454 | "... iso period %d %sframes, wMaxPacket %04x\n", |
1463 | 1 << (desc->bInterval - 1), | 1455 | 1 << (desc->bInterval - 1), |
1464 | (udev->speed == USB_SPEED_HIGH) ? "micro" : "", | 1456 | (udev->speed == USB_SPEED_HIGH) ? "micro" : "", |
@@ -1475,7 +1467,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1475 | urbs [i]->context = &context; | 1467 | urbs [i]->context = &context; |
1476 | } | 1468 | } |
1477 | packets *= param->iterations; | 1469 | packets *= param->iterations; |
1478 | dev_dbg (&dev->intf->dev, | 1470 | dev_info(&dev->intf->dev, |
1479 | "... total %lu msec (%lu packets)\n", | 1471 | "... total %lu msec (%lu packets)\n", |
1480 | (packets * (1 << (desc->bInterval - 1))) | 1472 | (packets * (1 << (desc->bInterval - 1))) |
1481 | / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), | 1473 | / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), |
@@ -1537,6 +1529,13 @@ fail: | |||
1537 | * except indirectly by consuming USB bandwidth and CPU resources for test | 1529 | * except indirectly by consuming USB bandwidth and CPU resources for test |
1538 | * threads and request completion. But the only way to know that for sure | 1530 | * threads and request completion. But the only way to know that for sure |
1539 | * is to test when HC queues are in use by many devices. | 1531 | * is to test when HC queues are in use by many devices. |
1532 | * | ||
1533 | * WARNING: Because usbfs grabs udev->dev.sem before calling this ioctl(), | ||
1534 | * it locks out usbcore in certain code paths. Notably, if you disconnect | ||
1535 | * the device-under-test, khubd will wait block forever waiting for the | ||
1536 | * ioctl to complete ... so that usb_disconnect() can abort the pending | ||
1537 | * urbs and then call usbtest_disconnect(). To abort a test, you're best | ||
1538 | * off just killing the userspace task and waiting for it to exit. | ||
1540 | */ | 1539 | */ |
1541 | 1540 | ||
1542 | static int | 1541 | static int |
@@ -1575,7 +1574,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1575 | * altsettings; force a default so most tests don't need to check. | 1574 | * altsettings; force a default so most tests don't need to check. |
1576 | */ | 1575 | */ |
1577 | if (dev->info->alt >= 0) { | 1576 | if (dev->info->alt >= 0) { |
1578 | int res; | 1577 | int res; |
1579 | 1578 | ||
1580 | if (intf->altsetting->desc.bInterfaceNumber) { | 1579 | if (intf->altsetting->desc.bInterfaceNumber) { |
1581 | mutex_unlock(&dev->lock); | 1580 | mutex_unlock(&dev->lock); |
@@ -1604,7 +1603,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1604 | switch (param->test_num) { | 1603 | switch (param->test_num) { |
1605 | 1604 | ||
1606 | case 0: | 1605 | case 0: |
1607 | dev_dbg (&intf->dev, "TEST 0: NOP\n"); | 1606 | dev_info(&intf->dev, "TEST 0: NOP\n"); |
1608 | retval = 0; | 1607 | retval = 0; |
1609 | break; | 1608 | break; |
1610 | 1609 | ||
@@ -1612,7 +1611,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1612 | case 1: | 1611 | case 1: |
1613 | if (dev->out_pipe == 0) | 1612 | if (dev->out_pipe == 0) |
1614 | break; | 1613 | break; |
1615 | dev_dbg (&intf->dev, | 1614 | dev_info(&intf->dev, |
1616 | "TEST 1: write %d bytes %u times\n", | 1615 | "TEST 1: write %d bytes %u times\n", |
1617 | param->length, param->iterations); | 1616 | param->length, param->iterations); |
1618 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); | 1617 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); |
@@ -1621,13 +1620,13 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1621 | break; | 1620 | break; |
1622 | } | 1621 | } |
1623 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1622 | // FIRMWARE: bulk sink (maybe accepts short writes) |
1624 | retval = simple_io (urb, param->iterations, 0, 0, "test1"); | 1623 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); |
1625 | simple_free_urb (urb); | 1624 | simple_free_urb (urb); |
1626 | break; | 1625 | break; |
1627 | case 2: | 1626 | case 2: |
1628 | if (dev->in_pipe == 0) | 1627 | if (dev->in_pipe == 0) |
1629 | break; | 1628 | break; |
1630 | dev_dbg (&intf->dev, | 1629 | dev_info(&intf->dev, |
1631 | "TEST 2: read %d bytes %u times\n", | 1630 | "TEST 2: read %d bytes %u times\n", |
1632 | param->length, param->iterations); | 1631 | param->length, param->iterations); |
1633 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); | 1632 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); |
@@ -1636,13 +1635,13 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1636 | break; | 1635 | break; |
1637 | } | 1636 | } |
1638 | // FIRMWARE: bulk source (maybe generates short writes) | 1637 | // FIRMWARE: bulk source (maybe generates short writes) |
1639 | retval = simple_io (urb, param->iterations, 0, 0, "test2"); | 1638 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); |
1640 | simple_free_urb (urb); | 1639 | simple_free_urb (urb); |
1641 | break; | 1640 | break; |
1642 | case 3: | 1641 | case 3: |
1643 | if (dev->out_pipe == 0 || param->vary == 0) | 1642 | if (dev->out_pipe == 0 || param->vary == 0) |
1644 | break; | 1643 | break; |
1645 | dev_dbg (&intf->dev, | 1644 | dev_info(&intf->dev, |
1646 | "TEST 3: write/%d 0..%d bytes %u times\n", | 1645 | "TEST 3: write/%d 0..%d bytes %u times\n", |
1647 | param->vary, param->length, param->iterations); | 1646 | param->vary, param->length, param->iterations); |
1648 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); | 1647 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); |
@@ -1651,14 +1650,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1651 | break; | 1650 | break; |
1652 | } | 1651 | } |
1653 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1652 | // FIRMWARE: bulk sink (maybe accepts short writes) |
1654 | retval = simple_io (urb, param->iterations, param->vary, | 1653 | retval = simple_io(dev, urb, param->iterations, param->vary, |
1655 | 0, "test3"); | 1654 | 0, "test3"); |
1656 | simple_free_urb (urb); | 1655 | simple_free_urb (urb); |
1657 | break; | 1656 | break; |
1658 | case 4: | 1657 | case 4: |
1659 | if (dev->in_pipe == 0 || param->vary == 0) | 1658 | if (dev->in_pipe == 0 || param->vary == 0) |
1660 | break; | 1659 | break; |
1661 | dev_dbg (&intf->dev, | 1660 | dev_info(&intf->dev, |
1662 | "TEST 4: read/%d 0..%d bytes %u times\n", | 1661 | "TEST 4: read/%d 0..%d bytes %u times\n", |
1663 | param->vary, param->length, param->iterations); | 1662 | param->vary, param->length, param->iterations); |
1664 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); | 1663 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); |
@@ -1667,7 +1666,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1667 | break; | 1666 | break; |
1668 | } | 1667 | } |
1669 | // FIRMWARE: bulk source (maybe generates short writes) | 1668 | // FIRMWARE: bulk source (maybe generates short writes) |
1670 | retval = simple_io (urb, param->iterations, param->vary, | 1669 | retval = simple_io(dev, urb, param->iterations, param->vary, |
1671 | 0, "test4"); | 1670 | 0, "test4"); |
1672 | simple_free_urb (urb); | 1671 | simple_free_urb (urb); |
1673 | break; | 1672 | break; |
@@ -1676,7 +1675,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1676 | case 5: | 1675 | case 5: |
1677 | if (dev->out_pipe == 0 || param->sglen == 0) | 1676 | if (dev->out_pipe == 0 || param->sglen == 0) |
1678 | break; | 1677 | break; |
1679 | dev_dbg (&intf->dev, | 1678 | dev_info(&intf->dev, |
1680 | "TEST 5: write %d sglists %d entries of %d bytes\n", | 1679 | "TEST 5: write %d sglists %d entries of %d bytes\n", |
1681 | param->iterations, | 1680 | param->iterations, |
1682 | param->sglen, param->length); | 1681 | param->sglen, param->length); |
@@ -1686,7 +1685,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1686 | break; | 1685 | break; |
1687 | } | 1686 | } |
1688 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1687 | // FIRMWARE: bulk sink (maybe accepts short writes) |
1689 | retval = perform_sglist (udev, param->iterations, dev->out_pipe, | 1688 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, |
1690 | &req, sg, param->sglen); | 1689 | &req, sg, param->sglen); |
1691 | free_sglist (sg, param->sglen); | 1690 | free_sglist (sg, param->sglen); |
1692 | break; | 1691 | break; |
@@ -1694,7 +1693,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1694 | case 6: | 1693 | case 6: |
1695 | if (dev->in_pipe == 0 || param->sglen == 0) | 1694 | if (dev->in_pipe == 0 || param->sglen == 0) |
1696 | break; | 1695 | break; |
1697 | dev_dbg (&intf->dev, | 1696 | dev_info(&intf->dev, |
1698 | "TEST 6: read %d sglists %d entries of %d bytes\n", | 1697 | "TEST 6: read %d sglists %d entries of %d bytes\n", |
1699 | param->iterations, | 1698 | param->iterations, |
1700 | param->sglen, param->length); | 1699 | param->sglen, param->length); |
@@ -1704,14 +1703,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1704 | break; | 1703 | break; |
1705 | } | 1704 | } |
1706 | // FIRMWARE: bulk source (maybe generates short writes) | 1705 | // FIRMWARE: bulk source (maybe generates short writes) |
1707 | retval = perform_sglist (udev, param->iterations, dev->in_pipe, | 1706 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, |
1708 | &req, sg, param->sglen); | 1707 | &req, sg, param->sglen); |
1709 | free_sglist (sg, param->sglen); | 1708 | free_sglist (sg, param->sglen); |
1710 | break; | 1709 | break; |
1711 | case 7: | 1710 | case 7: |
1712 | if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) | 1711 | if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) |
1713 | break; | 1712 | break; |
1714 | dev_dbg (&intf->dev, | 1713 | dev_info(&intf->dev, |
1715 | "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n", | 1714 | "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n", |
1716 | param->vary, param->iterations, | 1715 | param->vary, param->iterations, |
1717 | param->sglen, param->length); | 1716 | param->sglen, param->length); |
@@ -1721,14 +1720,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1721 | break; | 1720 | break; |
1722 | } | 1721 | } |
1723 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1722 | // FIRMWARE: bulk sink (maybe accepts short writes) |
1724 | retval = perform_sglist (udev, param->iterations, dev->out_pipe, | 1723 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, |
1725 | &req, sg, param->sglen); | 1724 | &req, sg, param->sglen); |
1726 | free_sglist (sg, param->sglen); | 1725 | free_sglist (sg, param->sglen); |
1727 | break; | 1726 | break; |
1728 | case 8: | 1727 | case 8: |
1729 | if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) | 1728 | if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) |
1730 | break; | 1729 | break; |
1731 | dev_dbg (&intf->dev, | 1730 | dev_info(&intf->dev, |
1732 | "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n", | 1731 | "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n", |
1733 | param->vary, param->iterations, | 1732 | param->vary, param->iterations, |
1734 | param->sglen, param->length); | 1733 | param->sglen, param->length); |
@@ -1738,7 +1737,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1738 | break; | 1737 | break; |
1739 | } | 1738 | } |
1740 | // FIRMWARE: bulk source (maybe generates short writes) | 1739 | // FIRMWARE: bulk source (maybe generates short writes) |
1741 | retval = perform_sglist (udev, param->iterations, dev->in_pipe, | 1740 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, |
1742 | &req, sg, param->sglen); | 1741 | &req, sg, param->sglen); |
1743 | free_sglist (sg, param->sglen); | 1742 | free_sglist (sg, param->sglen); |
1744 | break; | 1743 | break; |
@@ -1746,13 +1745,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1746 | /* non-queued sanity tests for control (chapter 9 subset) */ | 1745 | /* non-queued sanity tests for control (chapter 9 subset) */ |
1747 | case 9: | 1746 | case 9: |
1748 | retval = 0; | 1747 | retval = 0; |
1749 | dev_dbg (&intf->dev, | 1748 | dev_info(&intf->dev, |
1750 | "TEST 9: ch9 (subset) control tests, %d times\n", | 1749 | "TEST 9: ch9 (subset) control tests, %d times\n", |
1751 | param->iterations); | 1750 | param->iterations); |
1752 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1751 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1753 | retval = ch9_postconfig (dev); | 1752 | retval = ch9_postconfig (dev); |
1754 | if (retval) | 1753 | if (retval) |
1755 | dbg ("ch9 subset failed, iterations left %d", i); | 1754 | dev_err(&intf->dev, "ch9 subset failed, " |
1755 | "iterations left %d\n", i); | ||
1756 | break; | 1756 | break; |
1757 | 1757 | ||
1758 | /* queued control messaging */ | 1758 | /* queued control messaging */ |
@@ -1760,7 +1760,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1760 | if (param->sglen == 0) | 1760 | if (param->sglen == 0) |
1761 | break; | 1761 | break; |
1762 | retval = 0; | 1762 | retval = 0; |
1763 | dev_dbg (&intf->dev, | 1763 | dev_info(&intf->dev, |
1764 | "TEST 10: queue %d control calls, %d times\n", | 1764 | "TEST 10: queue %d control calls, %d times\n", |
1765 | param->sglen, | 1765 | param->sglen, |
1766 | param->iterations); | 1766 | param->iterations); |
@@ -1772,26 +1772,26 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1772 | if (dev->in_pipe == 0 || !param->length) | 1772 | if (dev->in_pipe == 0 || !param->length) |
1773 | break; | 1773 | break; |
1774 | retval = 0; | 1774 | retval = 0; |
1775 | dev_dbg (&intf->dev, "TEST 11: unlink %d reads of %d\n", | 1775 | dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n", |
1776 | param->iterations, param->length); | 1776 | param->iterations, param->length); |
1777 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1777 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1778 | retval = unlink_simple (dev, dev->in_pipe, | 1778 | retval = unlink_simple (dev, dev->in_pipe, |
1779 | param->length); | 1779 | param->length); |
1780 | if (retval) | 1780 | if (retval) |
1781 | dev_dbg (&intf->dev, "unlink reads failed %d, " | 1781 | dev_err(&intf->dev, "unlink reads failed %d, " |
1782 | "iterations left %d\n", retval, i); | 1782 | "iterations left %d\n", retval, i); |
1783 | break; | 1783 | break; |
1784 | case 12: | 1784 | case 12: |
1785 | if (dev->out_pipe == 0 || !param->length) | 1785 | if (dev->out_pipe == 0 || !param->length) |
1786 | break; | 1786 | break; |
1787 | retval = 0; | 1787 | retval = 0; |
1788 | dev_dbg (&intf->dev, "TEST 12: unlink %d writes of %d\n", | 1788 | dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n", |
1789 | param->iterations, param->length); | 1789 | param->iterations, param->length); |
1790 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1790 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1791 | retval = unlink_simple (dev, dev->out_pipe, | 1791 | retval = unlink_simple (dev, dev->out_pipe, |
1792 | param->length); | 1792 | param->length); |
1793 | if (retval) | 1793 | if (retval) |
1794 | dev_dbg (&intf->dev, "unlink writes failed %d, " | 1794 | dev_err(&intf->dev, "unlink writes failed %d, " |
1795 | "iterations left %d\n", retval, i); | 1795 | "iterations left %d\n", retval, i); |
1796 | break; | 1796 | break; |
1797 | 1797 | ||
@@ -1800,24 +1800,24 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1800 | if (dev->out_pipe == 0 && dev->in_pipe == 0) | 1800 | if (dev->out_pipe == 0 && dev->in_pipe == 0) |
1801 | break; | 1801 | break; |
1802 | retval = 0; | 1802 | retval = 0; |
1803 | dev_dbg (&intf->dev, "TEST 13: set/clear %d halts\n", | 1803 | dev_info(&intf->dev, "TEST 13: set/clear %d halts\n", |
1804 | param->iterations); | 1804 | param->iterations); |
1805 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1805 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1806 | retval = halt_simple (dev); | 1806 | retval = halt_simple (dev); |
1807 | 1807 | ||
1808 | if (retval) | 1808 | if (retval) |
1809 | DBG (dev, "halts failed, iterations left %d\n", i); | 1809 | ERROR(dev, "halts failed, iterations left %d\n", i); |
1810 | break; | 1810 | break; |
1811 | 1811 | ||
1812 | /* control write tests */ | 1812 | /* control write tests */ |
1813 | case 14: | 1813 | case 14: |
1814 | if (!dev->info->ctrl_out) | 1814 | if (!dev->info->ctrl_out) |
1815 | break; | 1815 | break; |
1816 | dev_dbg (&intf->dev, "TEST 14: %d ep0out, %d..%d vary %d\n", | 1816 | dev_info(&intf->dev, "TEST 14: %d ep0out, %d..%d vary %d\n", |
1817 | param->iterations, | 1817 | param->iterations, |
1818 | realworld ? 1 : 0, param->length, | 1818 | realworld ? 1 : 0, param->length, |
1819 | param->vary); | 1819 | param->vary); |
1820 | retval = ctrl_out (dev, param->iterations, | 1820 | retval = ctrl_out(dev, param->iterations, |
1821 | param->length, param->vary); | 1821 | param->length, param->vary); |
1822 | break; | 1822 | break; |
1823 | 1823 | ||
@@ -1825,7 +1825,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1825 | case 15: | 1825 | case 15: |
1826 | if (dev->out_iso_pipe == 0 || param->sglen == 0) | 1826 | if (dev->out_iso_pipe == 0 || param->sglen == 0) |
1827 | break; | 1827 | break; |
1828 | dev_dbg (&intf->dev, | 1828 | dev_info(&intf->dev, |
1829 | "TEST 15: write %d iso, %d entries of %d bytes\n", | 1829 | "TEST 15: write %d iso, %d entries of %d bytes\n", |
1830 | param->iterations, | 1830 | param->iterations, |
1831 | param->sglen, param->length); | 1831 | param->sglen, param->length); |
@@ -1838,7 +1838,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1838 | case 16: | 1838 | case 16: |
1839 | if (dev->in_iso_pipe == 0 || param->sglen == 0) | 1839 | if (dev->in_iso_pipe == 0 || param->sglen == 0) |
1840 | break; | 1840 | break; |
1841 | dev_dbg (&intf->dev, | 1841 | dev_info(&intf->dev, |
1842 | "TEST 16: read %d iso, %d entries of %d bytes\n", | 1842 | "TEST 16: read %d iso, %d entries of %d bytes\n", |
1843 | param->iterations, | 1843 | param->iterations, |
1844 | param->sglen, param->length); | 1844 | param->sglen, param->length); |
@@ -1898,7 +1898,8 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1898 | return -ENODEV; | 1898 | return -ENODEV; |
1899 | if (product && le16_to_cpu(udev->descriptor.idProduct) != (u16)product) | 1899 | if (product && le16_to_cpu(udev->descriptor.idProduct) != (u16)product) |
1900 | return -ENODEV; | 1900 | return -ENODEV; |
1901 | dbg ("matched module params, vend=0x%04x prod=0x%04x", | 1901 | dev_info(&intf->dev, "matched module params, " |
1902 | "vend=0x%04x prod=0x%04x\n", | ||
1902 | le16_to_cpu(udev->descriptor.idVendor), | 1903 | le16_to_cpu(udev->descriptor.idVendor), |
1903 | le16_to_cpu(udev->descriptor.idProduct)); | 1904 | le16_to_cpu(udev->descriptor.idProduct)); |
1904 | } | 1905 | } |
@@ -1940,7 +1941,8 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1940 | 1941 | ||
1941 | status = get_endpoints (dev, intf); | 1942 | status = get_endpoints (dev, intf); |
1942 | if (status < 0) { | 1943 | if (status < 0) { |
1943 | dbg ("couldn't get endpoints, %d\n", status); | 1944 | WARN(dev, "couldn't get endpoints, %d\n", |
1945 | status); | ||
1944 | return status; | 1946 | return status; |
1945 | } | 1947 | } |
1946 | /* may find bulk or ISO pipes */ | 1948 | /* may find bulk or ISO pipes */ |
@@ -2082,21 +2084,9 @@ static struct usbtest_info generic_info = { | |||
2082 | }; | 2084 | }; |
2083 | #endif | 2085 | #endif |
2084 | 2086 | ||
2085 | // FIXME remove this | ||
2086 | static struct usbtest_info hact_info = { | ||
2087 | .name = "FX2/hact", | ||
2088 | //.ep_in = 6, | ||
2089 | .ep_out = 2, | ||
2090 | .alt = -1, | ||
2091 | }; | ||
2092 | |||
2093 | 2087 | ||
2094 | static struct usb_device_id id_table [] = { | 2088 | static struct usb_device_id id_table [] = { |
2095 | 2089 | ||
2096 | { USB_DEVICE (0x0547, 0x1002), | ||
2097 | .driver_info = (unsigned long) &hact_info, | ||
2098 | }, | ||
2099 | |||
2100 | /*-------------------------------------------------------------*/ | 2090 | /*-------------------------------------------------------------*/ |
2101 | 2091 | ||
2102 | /* EZ-USB devices which download firmware to replace (or in our | 2092 | /* EZ-USB devices which download firmware to replace (or in our |
@@ -2185,7 +2175,7 @@ static int __init usbtest_init (void) | |||
2185 | { | 2175 | { |
2186 | #ifdef GENERIC | 2176 | #ifdef GENERIC |
2187 | if (vendor) | 2177 | if (vendor) |
2188 | dbg ("params: vend=0x%04x prod=0x%04x", vendor, product); | 2178 | pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product); |
2189 | #endif | 2179 | #endif |
2190 | return usb_register (&usbtest_driver); | 2180 | return usb_register (&usbtest_driver); |
2191 | } | 2181 | } |
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 9b1bb347dc2d..db6f97a93c02 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -147,7 +147,7 @@ static void serial_buf_free(struct circ_buf *cb) | |||
147 | */ | 147 | */ |
148 | static int serial_buf_data_avail(struct circ_buf *cb) | 148 | static int serial_buf_data_avail(struct circ_buf *cb) |
149 | { | 149 | { |
150 | return CIRC_CNT(cb->head,cb->tail,AIRCABLE_BUF_SIZE); | 150 | return CIRC_CNT(cb->head, cb->tail, AIRCABLE_BUF_SIZE); |
151 | } | 151 | } |
152 | 152 | ||
153 | /* | 153 | /* |
@@ -171,7 +171,7 @@ static int serial_buf_put(struct circ_buf *cb, const char *buf, int count) | |||
171 | cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1); | 171 | cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1); |
172 | buf += c; | 172 | buf += c; |
173 | count -= c; | 173 | count -= c; |
174 | ret= c; | 174 | ret = c; |
175 | } | 175 | } |
176 | return ret; | 176 | return ret; |
177 | } | 177 | } |
@@ -197,7 +197,7 @@ static int serial_buf_get(struct circ_buf *cb, char *buf, int count) | |||
197 | cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1); | 197 | cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1); |
198 | buf += c; | 198 | buf += c; |
199 | count -= c; | 199 | count -= c; |
200 | ret= c; | 200 | ret = c; |
201 | } | 201 | } |
202 | return ret; | 202 | return ret; |
203 | } | 203 | } |
@@ -208,7 +208,7 @@ static void aircable_send(struct usb_serial_port *port) | |||
208 | { | 208 | { |
209 | int count, result; | 209 | int count, result; |
210 | struct aircable_private *priv = usb_get_serial_port_data(port); | 210 | struct aircable_private *priv = usb_get_serial_port_data(port); |
211 | unsigned char* buf; | 211 | unsigned char *buf; |
212 | __le16 *dbuf; | 212 | __le16 *dbuf; |
213 | dbg("%s - port %d", __func__, port->number); | 213 | dbg("%s - port %d", __func__, port->number); |
214 | if (port->write_urb_busy) | 214 | if (port->write_urb_busy) |
@@ -229,7 +229,8 @@ static void aircable_send(struct usb_serial_port *port) | |||
229 | buf[1] = TX_HEADER_1; | 229 | buf[1] = TX_HEADER_1; |
230 | dbuf = (__le16 *)&buf[2]; | 230 | dbuf = (__le16 *)&buf[2]; |
231 | *dbuf = cpu_to_le16((u16)count); | 231 | *dbuf = cpu_to_le16((u16)count); |
232 | serial_buf_get(priv->tx_buf,buf + HCI_HEADER_LENGTH, MAX_HCI_FRAMESIZE); | 232 | serial_buf_get(priv->tx_buf, buf + HCI_HEADER_LENGTH, |
233 | MAX_HCI_FRAMESIZE); | ||
233 | 234 | ||
234 | memcpy(port->write_urb->transfer_buffer, buf, | 235 | memcpy(port->write_urb->transfer_buffer, buf, |
235 | count + HCI_HEADER_LENGTH); | 236 | count + HCI_HEADER_LENGTH); |
@@ -261,7 +262,7 @@ static void aircable_read(struct work_struct *work) | |||
261 | struct tty_struct *tty; | 262 | struct tty_struct *tty; |
262 | unsigned char *data; | 263 | unsigned char *data; |
263 | int count; | 264 | int count; |
264 | if (priv->rx_flags & THROTTLED){ | 265 | if (priv->rx_flags & THROTTLED) { |
265 | if (priv->rx_flags & ACTUALLY_THROTTLED) | 266 | if (priv->rx_flags & ACTUALLY_THROTTLED) |
266 | schedule_work(&priv->rx_work); | 267 | schedule_work(&priv->rx_work); |
267 | return; | 268 | return; |
@@ -282,10 +283,10 @@ static void aircable_read(struct work_struct *work) | |||
282 | count = min(64, serial_buf_data_avail(priv->rx_buf)); | 283 | count = min(64, serial_buf_data_avail(priv->rx_buf)); |
283 | 284 | ||
284 | if (count <= 0) | 285 | if (count <= 0) |
285 | return; //We have finished sending everything. | 286 | return; /* We have finished sending everything. */ |
286 | 287 | ||
287 | tty_prepare_flip_string(tty, &data, count); | 288 | tty_prepare_flip_string(tty, &data, count); |
288 | if (!data){ | 289 | if (!data) { |
289 | err("%s- kzalloc(%d) failed.", __func__, count); | 290 | err("%s- kzalloc(%d) failed.", __func__, count); |
290 | return; | 291 | return; |
291 | } | 292 | } |
@@ -304,9 +305,10 @@ static void aircable_read(struct work_struct *work) | |||
304 | static int aircable_probe(struct usb_serial *serial, | 305 | static int aircable_probe(struct usb_serial *serial, |
305 | const struct usb_device_id *id) | 306 | const struct usb_device_id *id) |
306 | { | 307 | { |
307 | struct usb_host_interface *iface_desc = serial->interface->cur_altsetting; | 308 | struct usb_host_interface *iface_desc = serial->interface-> |
309 | cur_altsetting; | ||
308 | struct usb_endpoint_descriptor *endpoint; | 310 | struct usb_endpoint_descriptor *endpoint; |
309 | int num_bulk_out=0; | 311 | int num_bulk_out = 0; |
310 | int i; | 312 | int i; |
311 | 313 | ||
312 | for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { | 314 | for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { |
@@ -325,13 +327,13 @@ static int aircable_probe(struct usb_serial *serial, | |||
325 | return 0; | 327 | return 0; |
326 | } | 328 | } |
327 | 329 | ||
328 | static int aircable_attach (struct usb_serial *serial) | 330 | static int aircable_attach(struct usb_serial *serial) |
329 | { | 331 | { |
330 | struct usb_serial_port *port = serial->port[0]; | 332 | struct usb_serial_port *port = serial->port[0]; |
331 | struct aircable_private *priv; | 333 | struct aircable_private *priv; |
332 | 334 | ||
333 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); | 335 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); |
334 | if (!priv){ | 336 | if (!priv) { |
335 | err("%s- kmalloc(%Zd) failed.", __func__, | 337 | err("%s- kmalloc(%Zd) failed.", __func__, |
336 | sizeof(struct aircable_private)); | 338 | sizeof(struct aircable_private)); |
337 | return -ENOMEM; | 339 | return -ENOMEM; |
@@ -392,7 +394,7 @@ static int aircable_write(struct usb_serial_port *port, | |||
392 | 394 | ||
393 | usb_serial_debug_data(debug, &port->dev, __func__, count, source); | 395 | usb_serial_debug_data(debug, &port->dev, __func__, count, source); |
394 | 396 | ||
395 | if (!count){ | 397 | if (!count) { |
396 | dbg("%s - write request of 0 bytes", __func__); | 398 | dbg("%s - write request of 0 bytes", __func__); |
397 | return count; | 399 | return count; |
398 | } | 400 | } |
@@ -418,31 +420,31 @@ static void aircable_write_bulk_callback(struct urb *urb) | |||
418 | 420 | ||
419 | /* This has been taken from cypress_m8.c cypress_write_int_callback */ | 421 | /* This has been taken from cypress_m8.c cypress_write_int_callback */ |
420 | switch (status) { | 422 | switch (status) { |
421 | case 0: | 423 | case 0: |
422 | /* success */ | 424 | /* success */ |
423 | break; | 425 | break; |
424 | case -ECONNRESET: | 426 | case -ECONNRESET: |
425 | case -ENOENT: | 427 | case -ENOENT: |
426 | case -ESHUTDOWN: | 428 | case -ESHUTDOWN: |
427 | /* this urb is terminated, clean up */ | 429 | /* this urb is terminated, clean up */ |
428 | dbg("%s - urb shutting down with status: %d", | 430 | dbg("%s - urb shutting down with status: %d", |
429 | __func__, status); | 431 | __func__, status); |
430 | port->write_urb_busy = 0; | 432 | port->write_urb_busy = 0; |
433 | return; | ||
434 | default: | ||
435 | /* error in the urb, so we have to resubmit it */ | ||
436 | dbg("%s - Overflow in write", __func__); | ||
437 | dbg("%s - nonzero write bulk status received: %d", | ||
438 | __func__, status); | ||
439 | port->write_urb->transfer_buffer_length = 1; | ||
440 | port->write_urb->dev = port->serial->dev; | ||
441 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
442 | if (result) | ||
443 | dev_err(&urb->dev->dev, | ||
444 | "%s - failed resubmitting write urb, error %d\n", | ||
445 | __func__, result); | ||
446 | else | ||
431 | return; | 447 | return; |
432 | default: | ||
433 | /* error in the urb, so we have to resubmit it */ | ||
434 | dbg("%s - Overflow in write", __func__); | ||
435 | dbg("%s - nonzero write bulk status received: %d", | ||
436 | __func__, status); | ||
437 | port->write_urb->transfer_buffer_length = 1; | ||
438 | port->write_urb->dev = port->serial->dev; | ||
439 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
440 | if (result) | ||
441 | dev_err(&urb->dev->dev, | ||
442 | "%s - failed resubmitting write urb, error %d\n", | ||
443 | __func__, result); | ||
444 | else | ||
445 | return; | ||
446 | } | 448 | } |
447 | 449 | ||
448 | port->write_urb_busy = 0; | 450 | port->write_urb_busy = 0; |
@@ -472,11 +474,11 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
472 | dbg("%s - caught -EPROTO, resubmitting the urb", | 474 | dbg("%s - caught -EPROTO, resubmitting the urb", |
473 | __func__); | 475 | __func__); |
474 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 476 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
475 | usb_rcvbulkpipe(port->serial->dev, | 477 | usb_rcvbulkpipe(port->serial->dev, |
476 | port->bulk_in_endpointAddress), | 478 | port->bulk_in_endpointAddress), |
477 | port->read_urb->transfer_buffer, | 479 | port->read_urb->transfer_buffer, |
478 | port->read_urb->transfer_buffer_length, | 480 | port->read_urb->transfer_buffer_length, |
479 | aircable_read_bulk_callback, port); | 481 | aircable_read_bulk_callback, port); |
480 | 482 | ||
481 | result = usb_submit_urb(urb, GFP_ATOMIC); | 483 | result = usb_submit_urb(urb, GFP_ATOMIC); |
482 | if (result) | 484 | if (result) |
@@ -490,7 +492,7 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
490 | } | 492 | } |
491 | 493 | ||
492 | usb_serial_debug_data(debug, &port->dev, __func__, | 494 | usb_serial_debug_data(debug, &port->dev, __func__, |
493 | urb->actual_length,urb->transfer_buffer); | 495 | urb->actual_length, urb->transfer_buffer); |
494 | 496 | ||
495 | tty = port->tty; | 497 | tty = port->tty; |
496 | if (tty && urb->actual_length) { | 498 | if (tty && urb->actual_length) { |
@@ -507,9 +509,9 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
507 | no_packages = urb->actual_length / (HCI_COMPLETE_FRAME); | 509 | no_packages = urb->actual_length / (HCI_COMPLETE_FRAME); |
508 | 510 | ||
509 | if (urb->actual_length % HCI_COMPLETE_FRAME != 0) | 511 | if (urb->actual_length % HCI_COMPLETE_FRAME != 0) |
510 | no_packages+=1; | 512 | no_packages++; |
511 | 513 | ||
512 | for (i = 0; i < no_packages ;i++) { | 514 | for (i = 0; i < no_packages; i++) { |
513 | if (remaining > (HCI_COMPLETE_FRAME)) | 515 | if (remaining > (HCI_COMPLETE_FRAME)) |
514 | package_length = HCI_COMPLETE_FRAME; | 516 | package_length = HCI_COMPLETE_FRAME; |
515 | else | 517 | else |
@@ -529,7 +531,7 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
529 | if (port->open_count) { | 531 | if (port->open_count) { |
530 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 532 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
531 | usb_rcvbulkpipe(port->serial->dev, | 533 | usb_rcvbulkpipe(port->serial->dev, |
532 | port->bulk_in_endpointAddress), | 534 | port->bulk_in_endpointAddress), |
533 | port->read_urb->transfer_buffer, | 535 | port->read_urb->transfer_buffer, |
534 | port->read_urb->transfer_buffer_length, | 536 | port->read_urb->transfer_buffer_length, |
535 | aircable_read_bulk_callback, port); | 537 | aircable_read_bulk_callback, port); |
@@ -602,7 +604,7 @@ static struct usb_serial_driver aircable_device = { | |||
602 | .unthrottle = aircable_unthrottle, | 604 | .unthrottle = aircable_unthrottle, |
603 | }; | 605 | }; |
604 | 606 | ||
605 | static int __init aircable_init (void) | 607 | static int __init aircable_init(void) |
606 | { | 608 | { |
607 | int retval; | 609 | int retval; |
608 | retval = usb_serial_register(&aircable_device); | 610 | retval = usb_serial_register(&aircable_device); |
@@ -619,7 +621,7 @@ failed_usb_register: | |||
619 | return retval; | 621 | return retval; |
620 | } | 622 | } |
621 | 623 | ||
622 | static void __exit aircable_exit (void) | 624 | static void __exit aircable_exit(void) |
623 | { | 625 | { |
624 | usb_deregister(&aircable_driver); | 626 | usb_deregister(&aircable_driver); |
625 | usb_serial_deregister(&aircable_device); | 627 | usb_serial_deregister(&aircable_device); |
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index 725b6b94c274..0798c14ce787 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c | |||
@@ -68,8 +68,9 @@ static int airprime_send_setup(struct usb_serial_port *port) | |||
68 | val |= 0x02; | 68 | val |= 0x02; |
69 | 69 | ||
70 | return usb_control_msg(serial->dev, | 70 | return usb_control_msg(serial->dev, |
71 | usb_rcvctrlpipe(serial->dev, 0), | 71 | usb_rcvctrlpipe(serial->dev, 0), |
72 | 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); | 72 | 0x22, 0x21, val, 0, NULL, 0, |
73 | USB_CTRL_SET_TIMEOUT); | ||
73 | } | 74 | } |
74 | 75 | ||
75 | return 0; | 76 | return 0; |
@@ -90,17 +91,19 @@ static void airprime_read_bulk_callback(struct urb *urb) | |||
90 | __func__, status); | 91 | __func__, status); |
91 | return; | 92 | return; |
92 | } | 93 | } |
93 | usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); | 94 | usb_serial_debug_data(debug, &port->dev, __func__, |
95 | urb->actual_length, data); | ||
94 | 96 | ||
95 | tty = port->tty; | 97 | tty = port->tty; |
96 | if (tty && urb->actual_length) { | 98 | if (tty && urb->actual_length) { |
97 | tty_insert_flip_string (tty, data, urb->actual_length); | 99 | tty_insert_flip_string(tty, data, urb->actual_length); |
98 | tty_flip_buffer_push (tty); | 100 | tty_flip_buffer_push(tty); |
99 | } | 101 | } |
100 | 102 | ||
101 | result = usb_submit_urb (urb, GFP_ATOMIC); | 103 | result = usb_submit_urb(urb, GFP_ATOMIC); |
102 | if (result) | 104 | if (result) |
103 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", | 105 | dev_err(&port->dev, |
106 | "%s - failed resubmitting read urb, error %d\n", | ||
104 | __func__, result); | 107 | __func__, result); |
105 | return; | 108 | return; |
106 | } | 109 | } |
@@ -115,7 +118,7 @@ static void airprime_write_bulk_callback(struct urb *urb) | |||
115 | dbg("%s - port %d", __func__, port->number); | 118 | dbg("%s - port %d", __func__, port->number); |
116 | 119 | ||
117 | /* free up the transfer buffer, as usb_free_urb() does not do this */ | 120 | /* free up the transfer buffer, as usb_free_urb() does not do this */ |
118 | kfree (urb->transfer_buffer); | 121 | kfree(urb->transfer_buffer); |
119 | 122 | ||
120 | if (status) | 123 | if (status) |
121 | dbg("%s - nonzero write bulk status received: %d", | 124 | dbg("%s - nonzero write bulk status received: %d", |
@@ -171,7 +174,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) | |||
171 | } | 174 | } |
172 | usb_fill_bulk_urb(urb, serial->dev, | 175 | usb_fill_bulk_urb(urb, serial->dev, |
173 | usb_rcvbulkpipe(serial->dev, | 176 | usb_rcvbulkpipe(serial->dev, |
174 | port->bulk_out_endpointAddress), | 177 | port->bulk_out_endpointAddress), |
175 | buffer, buffer_size, | 178 | buffer, buffer_size, |
176 | airprime_read_bulk_callback, port); | 179 | airprime_read_bulk_callback, port); |
177 | result = usb_submit_urb(urb, GFP_KERNEL); | 180 | result = usb_submit_urb(urb, GFP_KERNEL); |
@@ -183,7 +186,8 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) | |||
183 | __func__, i, port->number, result); | 186 | __func__, i, port->number, result); |
184 | goto errout; | 187 | goto errout; |
185 | } | 188 | } |
186 | /* remember this urb so we can kill it when the port is closed */ | 189 | /* remember this urb so we can kill it when the |
190 | port is closed */ | ||
187 | priv->read_urbp[i] = urb; | 191 | priv->read_urbp[i] = urb; |
188 | } | 192 | } |
189 | 193 | ||
@@ -192,22 +196,22 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) | |||
192 | goto out; | 196 | goto out; |
193 | 197 | ||
194 | errout: | 198 | errout: |
195 | /* some error happened, cancel any submitted urbs and clean up anything that | 199 | /* some error happened, cancel any submitted urbs and clean up |
196 | got allocated successfully */ | 200 | anything that got allocated successfully */ |
197 | 201 | ||
198 | while (i-- != 0) { | 202 | while (i-- != 0) { |
199 | urb = priv->read_urbp[i]; | 203 | urb = priv->read_urbp[i]; |
200 | buffer = urb->transfer_buffer; | 204 | buffer = urb->transfer_buffer; |
201 | usb_kill_urb (urb); | 205 | usb_kill_urb(urb); |
202 | usb_free_urb (urb); | 206 | usb_free_urb(urb); |
203 | kfree (buffer); | 207 | kfree(buffer); |
204 | } | 208 | } |
205 | 209 | ||
206 | out: | 210 | out: |
207 | return result; | 211 | return result; |
208 | } | 212 | } |
209 | 213 | ||
210 | static void airprime_close(struct usb_serial_port *port, struct file * filp) | 214 | static void airprime_close(struct usb_serial_port *port, struct file *filp) |
211 | { | 215 | { |
212 | struct airprime_private *priv = usb_get_serial_port_data(port); | 216 | struct airprime_private *priv = usb_get_serial_port_data(port); |
213 | int i; | 217 | int i; |
@@ -220,16 +224,16 @@ static void airprime_close(struct usb_serial_port *port, struct file * filp) | |||
220 | mutex_lock(&port->serial->disc_mutex); | 224 | mutex_lock(&port->serial->disc_mutex); |
221 | if (!port->serial->disconnected) | 225 | if (!port->serial->disconnected) |
222 | airprime_send_setup(port); | 226 | airprime_send_setup(port); |
223 | mutex_lock(&port->serial->disc_mutex); | 227 | mutex_unlock(&port->serial->disc_mutex); |
224 | 228 | ||
225 | for (i = 0; i < NUM_READ_URBS; ++i) { | 229 | for (i = 0; i < NUM_READ_URBS; ++i) { |
226 | usb_kill_urb (priv->read_urbp[i]); | 230 | usb_kill_urb(priv->read_urbp[i]); |
227 | kfree (priv->read_urbp[i]->transfer_buffer); | 231 | kfree(priv->read_urbp[i]->transfer_buffer); |
228 | usb_free_urb (priv->read_urbp[i]); | 232 | usb_free_urb(priv->read_urbp[i]); |
229 | } | 233 | } |
230 | 234 | ||
231 | /* free up private structure */ | 235 | /* free up private structure */ |
232 | kfree (priv); | 236 | kfree(priv); |
233 | usb_set_serial_port_data(port, NULL); | 237 | usb_set_serial_port_data(port, NULL); |
234 | } | 238 | } |
235 | 239 | ||
@@ -259,10 +263,10 @@ static int airprime_write(struct usb_serial_port *port, | |||
259 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 263 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
260 | if (!urb) { | 264 | if (!urb) { |
261 | dev_err(&port->dev, "no more free urbs\n"); | 265 | dev_err(&port->dev, "no more free urbs\n"); |
262 | kfree (buffer); | 266 | kfree(buffer); |
263 | return -ENOMEM; | 267 | return -ENOMEM; |
264 | } | 268 | } |
265 | memcpy (buffer, buf, count); | 269 | memcpy(buffer, buf, count); |
266 | 270 | ||
267 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); | 271 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); |
268 | 272 | ||
@@ -279,7 +283,7 @@ static int airprime_write(struct usb_serial_port *port, | |||
279 | "%s - usb_submit_urb(write bulk) failed with status = %d\n", | 283 | "%s - usb_submit_urb(write bulk) failed with status = %d\n", |
280 | __func__, status); | 284 | __func__, status); |
281 | count = status; | 285 | count = status; |
282 | kfree (buffer); | 286 | kfree(buffer); |
283 | } else { | 287 | } else { |
284 | spin_lock_irqsave(&priv->lock, flags); | 288 | spin_lock_irqsave(&priv->lock, flags); |
285 | ++priv->outstanding_urbs; | 289 | ++priv->outstanding_urbs; |
@@ -287,7 +291,7 @@ static int airprime_write(struct usb_serial_port *port, | |||
287 | } | 291 | } |
288 | /* we are done with this urb, so let the host driver | 292 | /* we are done with this urb, so let the host driver |
289 | * really free it when it is finished with it */ | 293 | * really free it when it is finished with it */ |
290 | usb_free_urb (urb); | 294 | usb_free_urb(urb); |
291 | return count; | 295 | return count; |
292 | } | 296 | } |
293 | 297 | ||
@@ -315,8 +319,10 @@ static int __init airprime_init(void) | |||
315 | { | 319 | { |
316 | int retval; | 320 | int retval; |
317 | 321 | ||
318 | airprime_device.num_ports = | 322 | airprime_device.num_ports = endpoints; |
319 | (endpoints > 0 && endpoints <= MAX_BULK_EPS) ? endpoints : NUM_BULK_EPS; | 323 | if (endpoints < 0 || endpoints >= MAX_BULK_EPS) |
324 | airprime_device.num_ports = NUM_BULK_EPS; | ||
325 | |||
320 | retval = usb_serial_register(&airprime_device); | 326 | retval = usb_serial_register(&airprime_device); |
321 | if (retval) | 327 | if (retval) |
322 | return retval; | 328 | return retval; |
@@ -341,6 +347,7 @@ MODULE_LICENSE("GPL"); | |||
341 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 347 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
342 | MODULE_PARM_DESC(debug, "Debug enabled"); | 348 | MODULE_PARM_DESC(debug, "Debug enabled"); |
343 | module_param(buffer_size, int, 0); | 349 | module_param(buffer_size, int, 0); |
344 | MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers in bytes (default 4096)"); | 350 | MODULE_PARM_DESC(buffer_size, |
351 | "Size of the transfer buffers in bytes (default 4096)"); | ||
345 | module_param(endpoints, int, 0); | 352 | module_param(endpoints, int, 0); |
346 | MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); | 353 | MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 599ab2e548a7..77895c8f8f31 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/usb.h> | 24 | #include <linux/usb.h> |
25 | #include <linux/usb/serial.h> | 25 | #include <linux/usb/serial.h> |
26 | #include <linux/serial.h> | 26 | #include <linux/serial.h> |
27 | #include <asm/uaccess.h> | 27 | #include <linux/uaccess.h> |
28 | 28 | ||
29 | 29 | ||
30 | static int debug; | 30 | static int debug; |
@@ -246,29 +246,29 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
246 | baud = tty_get_baud_rate(port->tty); | 246 | baud = tty_get_baud_rate(port->tty); |
247 | 247 | ||
248 | switch (baud) { | 248 | switch (baud) { |
249 | case 75: | 249 | case 75: |
250 | case 150: | 250 | case 150: |
251 | case 300: | 251 | case 300: |
252 | case 600: | 252 | case 600: |
253 | case 1200: | 253 | case 1200: |
254 | case 1800: | 254 | case 1800: |
255 | case 2400: | 255 | case 2400: |
256 | case 4800: | 256 | case 4800: |
257 | case 9600: | 257 | case 9600: |
258 | case 19200: | 258 | case 19200: |
259 | case 38400: | 259 | case 38400: |
260 | case 57600: | 260 | case 57600: |
261 | case 115200: | 261 | case 115200: |
262 | case 230400: | 262 | case 230400: |
263 | case 460800: | 263 | case 460800: |
264 | /* Report the resulting rate back to the caller */ | 264 | /* Report the resulting rate back to the caller */ |
265 | tty_encode_baud_rate(port->tty, baud, baud); | 265 | tty_encode_baud_rate(port->tty, baud, baud); |
266 | break; | 266 | break; |
267 | /* set 9600 as default (if given baudrate is invalid for example) */ | 267 | /* set 9600 as default (if given baudrate is invalid for example) */ |
268 | default: | 268 | default: |
269 | tty_encode_baud_rate(port->tty, 9600, 9600); | 269 | tty_encode_baud_rate(port->tty, 9600, 9600); |
270 | case 0: | 270 | case 0: |
271 | baud = 9600; | 271 | baud = 9600; |
272 | } | 272 | } |
273 | 273 | ||
274 | /* | 274 | /* |
@@ -380,19 +380,19 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, | |||
380 | switch (cmd) { | 380 | switch (cmd) { |
381 | case TIOCGSERIAL: | 381 | case TIOCGSERIAL: |
382 | /* XXX: Some of these values are probably wrong. */ | 382 | /* XXX: Some of these values are probably wrong. */ |
383 | memset(&serstruct, 0, sizeof (serstruct)); | 383 | memset(&serstruct, 0, sizeof(serstruct)); |
384 | serstruct.type = PORT_16654; | 384 | serstruct.type = PORT_16654; |
385 | serstruct.line = port->serial->minor; | 385 | serstruct.line = port->serial->minor; |
386 | serstruct.port = port->number; | 386 | serstruct.port = port->number; |
387 | serstruct.custom_divisor = 0; | 387 | serstruct.custom_divisor = 0; |
388 | serstruct.baud_base = 460800; | 388 | serstruct.baud_base = 460800; |
389 | 389 | ||
390 | if (copy_to_user(user_arg, &serstruct, sizeof (serstruct))) | 390 | if (copy_to_user(user_arg, &serstruct, sizeof(serstruct))) |
391 | return -EFAULT; | 391 | return -EFAULT; |
392 | 392 | ||
393 | return 0; | 393 | return 0; |
394 | case TIOCSSERIAL: | 394 | case TIOCSSERIAL: |
395 | if (copy_from_user(&serstruct, user_arg, sizeof (serstruct))) | 395 | if (copy_from_user(&serstruct, user_arg, sizeof(serstruct))) |
396 | return -EFAULT; | 396 | return -EFAULT; |
397 | return 0; | 397 | return 0; |
398 | default: | 398 | default: |
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index d947d955bceb..ba28fdc9ccd2 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
@@ -130,7 +130,7 @@ static int ch341_get_status(struct usb_device *dev) | |||
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | 131 | ||
132 | r = ch341_control_in(dev, 0x95, 0x0706, 0, buffer, size); | 132 | r = ch341_control_in(dev, 0x95, 0x0706, 0, buffer, size); |
133 | if ( r < 0) | 133 | if (r < 0) |
134 | goto out; | 134 | goto out; |
135 | 135 | ||
136 | /* Not having the datasheet for the CH341, we ignore the bytes returned | 136 | /* Not having the datasheet for the CH341, we ignore the bytes returned |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index c7329f43d9c9..5b349ece7247 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -133,6 +133,14 @@ static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = { | |||
133 | static struct usb_device_id id_table_combined [] = { | 133 | static struct usb_device_id id_table_combined [] = { |
134 | { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) }, | 134 | { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) }, |
135 | { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) }, | 135 | { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) }, |
136 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) }, | ||
137 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_1_PID) }, | ||
138 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_2_PID) }, | ||
139 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_3_PID) }, | ||
140 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_4_PID) }, | ||
141 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_5_PID) }, | ||
142 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_6_PID) }, | ||
143 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_7_PID) }, | ||
136 | { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, | 144 | { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, |
137 | { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, | 145 | { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, |
138 | { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, | 146 | { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 6da539ede0ee..504edf8c3a3f 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -40,6 +40,17 @@ | |||
40 | /* AlphaMicro Components AMC-232USB01 device */ | 40 | /* AlphaMicro Components AMC-232USB01 device */ |
41 | #define FTDI_AMC232_PID 0xFF00 /* Product Id */ | 41 | #define FTDI_AMC232_PID 0xFF00 /* Product Id */ |
42 | 42 | ||
43 | /* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */ | ||
44 | /* the VID is the standard ftdi vid (FTDI_VID) */ | ||
45 | #define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */ | ||
46 | #define FTDI_SCS_DEVICE_1_PID 0xD011 /* SCS Tracker / DSP TNC */ | ||
47 | #define FTDI_SCS_DEVICE_2_PID 0xD012 | ||
48 | #define FTDI_SCS_DEVICE_3_PID 0xD013 | ||
49 | #define FTDI_SCS_DEVICE_4_PID 0xD014 | ||
50 | #define FTDI_SCS_DEVICE_5_PID 0xD015 | ||
51 | #define FTDI_SCS_DEVICE_6_PID 0xD016 | ||
52 | #define FTDI_SCS_DEVICE_7_PID 0xD017 | ||
53 | |||
43 | /* ACT Solutions HomePro ZWave interface (http://www.act-solutions.com/HomePro.htm) */ | 54 | /* ACT Solutions HomePro ZWave interface (http://www.act-solutions.com/HomePro.htm) */ |
44 | #define FTDI_ACTZWAVE_PID 0xF2D0 | 55 | #define FTDI_ACTZWAVE_PID 0xF2D0 |
45 | 56 | ||
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 6bcb82d3911a..78f2f6db494d 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -1713,7 +1713,7 @@ static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file, | |||
1713 | { | 1713 | { |
1714 | struct moschip_port *mos7840_port; | 1714 | struct moschip_port *mos7840_port; |
1715 | unsigned int mcr; | 1715 | unsigned int mcr; |
1716 | unsigned int status; | 1716 | int status; |
1717 | 1717 | ||
1718 | dbg("%s - port %d", __func__, port->number); | 1718 | dbg("%s - port %d", __func__, port->number); |
1719 | 1719 | ||
@@ -1740,11 +1740,10 @@ static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file, | |||
1740 | 1740 | ||
1741 | mos7840_port->shadowMCR = mcr; | 1741 | mos7840_port->shadowMCR = mcr; |
1742 | 1742 | ||
1743 | status = 0; | ||
1744 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr); | 1743 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr); |
1745 | if (status < 0) { | 1744 | if (status < 0) { |
1746 | dbg("setting MODEM_CONTROL_REGISTER Failed\n"); | 1745 | dbg("setting MODEM_CONTROL_REGISTER Failed\n"); |
1747 | return -1; | 1746 | return status; |
1748 | } | 1747 | } |
1749 | 1748 | ||
1750 | return 0; | 1749 | return 0; |
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index 0f6d234d699b..3d9249632ae1 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig | |||
@@ -123,7 +123,8 @@ config USB_STORAGE_ALAUDA | |||
123 | 123 | ||
124 | config USB_STORAGE_ONETOUCH | 124 | config USB_STORAGE_ONETOUCH |
125 | bool "Support OneTouch Button on Maxtor Hard Drives" | 125 | bool "Support OneTouch Button on Maxtor Hard Drives" |
126 | depends on USB_STORAGE && INPUT_EVDEV | 126 | depends on USB_STORAGE |
127 | depends on INPUT=y || INPUT=USB_STORAGE | ||
127 | help | 128 | help |
128 | Say Y here to include additional code to support the Maxtor OneTouch | 129 | Say Y here to include additional code to support the Maxtor OneTouch |
129 | USB hard drive's onetouch button. | 130 | USB hard drive's onetouch button. |
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c index d88824b3511c..898e67d30e56 100644 --- a/drivers/usb/storage/cypress_atacb.c +++ b/drivers/usb/storage/cypress_atacb.c | |||
@@ -46,7 +46,7 @@ void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) | |||
46 | } | 46 | } |
47 | 47 | ||
48 | memcpy(save_cmnd, srb->cmnd, sizeof(save_cmnd)); | 48 | memcpy(save_cmnd, srb->cmnd, sizeof(save_cmnd)); |
49 | memset(srb->cmnd, 0, sizeof(srb->cmnd)); | 49 | memset(srb->cmnd, 0, MAX_COMMAND_SIZE); |
50 | 50 | ||
51 | /* check if we support the command */ | 51 | /* check if we support the command */ |
52 | if (save_cmnd[1] >> 5) /* MULTIPLE_COUNT */ | 52 | if (save_cmnd[1] >> 5) /* MULTIPLE_COUNT */ |
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index 971d13dd5e65..3addcd8f827b 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c | |||
@@ -292,6 +292,7 @@ struct isd200_info { | |||
292 | 292 | ||
293 | /* maximum number of LUNs supported */ | 293 | /* maximum number of LUNs supported */ |
294 | unsigned char MaxLUNs; | 294 | unsigned char MaxLUNs; |
295 | unsigned char cmnd[BLK_MAX_CDB]; | ||
295 | struct scsi_cmnd srb; | 296 | struct scsi_cmnd srb; |
296 | struct scatterlist sg; | 297 | struct scatterlist sg; |
297 | }; | 298 | }; |
@@ -450,6 +451,7 @@ static int isd200_action( struct us_data *us, int action, | |||
450 | 451 | ||
451 | memset(&ata, 0, sizeof(ata)); | 452 | memset(&ata, 0, sizeof(ata)); |
452 | memset(&srb_dev, 0, sizeof(srb_dev)); | 453 | memset(&srb_dev, 0, sizeof(srb_dev)); |
454 | srb->cmnd = info->cmnd; | ||
453 | srb->device = &srb_dev; | 455 | srb->device = &srb_dev; |
454 | ++srb->serial_number; | 456 | ++srb->serial_number; |
455 | 457 | ||
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c index a28d49122e7a..d617e8ae6b00 100644 --- a/drivers/usb/storage/libusual.c +++ b/drivers/usb/storage/libusual.c | |||
@@ -135,7 +135,7 @@ static int usu_probe(struct usb_interface *intf, | |||
135 | stat[type].fls |= USU_MOD_FL_THREAD; | 135 | stat[type].fls |= USU_MOD_FL_THREAD; |
136 | spin_unlock_irqrestore(&usu_lock, flags); | 136 | spin_unlock_irqrestore(&usu_lock, flags); |
137 | 137 | ||
138 | task = kthread_run(usu_probe_thread, (void*)type, "libusual_%d", type); | 138 | task = kthread_run(usu_probe_thread, (void*)type, "libusual_%ld", type); |
139 | if (IS_ERR(task)) { | 139 | if (IS_ERR(task)) { |
140 | rc = PTR_ERR(task); | 140 | rc = PTR_ERR(task); |
141 | printk(KERN_WARNING "libusual: " | 141 | printk(KERN_WARNING "libusual: " |
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index dfd42fe9e5f0..98b89ea9e312 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include "onetouch.h" | 38 | #include "onetouch.h" |
39 | #include "debug.h" | 39 | #include "debug.h" |
40 | 40 | ||
41 | void onetouch_release_input(void *onetouch_); | 41 | static void onetouch_release_input(void *onetouch_); |
42 | 42 | ||
43 | struct usb_onetouch { | 43 | struct usb_onetouch { |
44 | char name[128]; | 44 | char name[128]; |
@@ -223,7 +223,7 @@ int onetouch_connect_input(struct us_data *ss) | |||
223 | return error; | 223 | return error; |
224 | } | 224 | } |
225 | 225 | ||
226 | void onetouch_release_input(void *onetouch_) | 226 | static void onetouch_release_input(void *onetouch_) |
227 | { | 227 | { |
228 | struct usb_onetouch *onetouch = (struct usb_onetouch *) onetouch_; | 228 | struct usb_onetouch *onetouch = (struct usb_onetouch *) onetouch_; |
229 | 229 | ||
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 732bf52a775e..a0ed889230aa 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -44,7 +44,8 @@ | |||
44 | * running with this patch. | 44 | * running with this patch. |
45 | * Send your submission to either Phil Dibowitz <phil@ipom.com> or | 45 | * Send your submission to either Phil Dibowitz <phil@ipom.com> or |
46 | * Alan Stern <stern@rowland.harvard.edu>, and don't forget to CC: the | 46 | * Alan Stern <stern@rowland.harvard.edu>, and don't forget to CC: the |
47 | * USB development list <linux-usb-devel@lists.sourceforge.net>. | 47 | * USB development list <linux-usb@vger.kernel.org> and the USB storage list |
48 | * <usb-storage@lists.one-eyed-alien.net> | ||
48 | */ | 49 | */ |
49 | 50 | ||
50 | /* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr> | 51 | /* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr> |
@@ -557,6 +558,13 @@ UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, | |||
557 | US_FL_SINGLE_LUN), | 558 | US_FL_SINGLE_LUN), |
558 | #endif | 559 | #endif |
559 | 560 | ||
561 | /* Reported by Dmitry Khlystov <adminimus@gmail.com> */ | ||
562 | UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220, | ||
563 | "Samsung", | ||
564 | "YP-U3", | ||
565 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
566 | US_FL_MAX_SECTORS_64), | ||
567 | |||
560 | /* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */ | 568 | /* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */ |
561 | UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, | 569 | UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, |
562 | "Belkin", | 570 | "Belkin", |
@@ -1200,6 +1208,17 @@ UNUSUAL_DEV( 0x084d, 0x0011, 0x0110, 0x0110, | |||
1200 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1208 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1201 | US_FL_BULK32), | 1209 | US_FL_BULK32), |
1202 | 1210 | ||
1211 | /* Andrew Lunn <andrew@lunn.ch> | ||
1212 | * PanDigital Digital Picture Frame. Does not like ALLOW_MEDIUM_REMOVAL | ||
1213 | * on LUN 4. | ||
1214 | * Note: Vend:Prod clash with "Ltd Maxell WS30 Slim Digital Camera" | ||
1215 | */ | ||
1216 | UNUSUAL_DEV( 0x0851, 0x1543, 0x0200, 0x0200, | ||
1217 | "PanDigital", | ||
1218 | "Photo Frame", | ||
1219 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1220 | US_FL_NOT_LOCKABLE), | ||
1221 | |||
1203 | /* Submitted by Jan De Luyck <lkml@kcore.org> */ | 1222 | /* Submitted by Jan De Luyck <lkml@kcore.org> */ |
1204 | UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000, | 1223 | UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000, |
1205 | "CITIZEN", | 1224 | "CITIZEN", |
@@ -1342,6 +1361,13 @@ UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff, | |||
1342 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1361 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1343 | US_FL_FIX_INQUIRY), | 1362 | US_FL_FIX_INQUIRY), |
1344 | 1363 | ||
1364 | /* Reported by Rohan Hart <rohan.hart17@gmail.com> */ | ||
1365 | UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010, | ||
1366 | "INTOVA", | ||
1367 | "Pixtreme", | ||
1368 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1369 | US_FL_FIX_CAPACITY ), | ||
1370 | |||
1345 | /* | 1371 | /* |
1346 | * Entry for Jenoptik JD 5200z3 | 1372 | * Entry for Jenoptik JD 5200z3 |
1347 | * | 1373 | * |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index a856effad3bd..e268aacb773a 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -539,7 +539,8 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id) | |||
539 | " has %s in unusual_devs.h (kernel" | 539 | " has %s in unusual_devs.h (kernel" |
540 | " %s)\n" | 540 | " %s)\n" |
541 | " Please send a copy of this message to " | 541 | " Please send a copy of this message to " |
542 | "<linux-usb-devel@lists.sourceforge.net>\n", | 542 | "<linux-usb@vger.kernel.org> and " |
543 | "<usb-storage@lists.one-eyed-alien.net>\n", | ||
543 | le16_to_cpu(ddesc->idVendor), | 544 | le16_to_cpu(ddesc->idVendor), |
544 | le16_to_cpu(ddesc->idProduct), | 545 | le16_to_cpu(ddesc->idProduct), |
545 | le16_to_cpu(ddesc->bcdDevice), | 546 | le16_to_cpu(ddesc->bcdDevice), |
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index b535483bc556..13866789b356 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -80,19 +80,51 @@ static void add_status(struct virtio_device *dev, unsigned status) | |||
80 | dev->config->set_status(dev, dev->config->get_status(dev) | status); | 80 | dev->config->set_status(dev, dev->config->get_status(dev) | status); |
81 | } | 81 | } |
82 | 82 | ||
83 | void virtio_check_driver_offered_feature(const struct virtio_device *vdev, | ||
84 | unsigned int fbit) | ||
85 | { | ||
86 | unsigned int i; | ||
87 | struct virtio_driver *drv = container_of(vdev->dev.driver, | ||
88 | struct virtio_driver, driver); | ||
89 | |||
90 | for (i = 0; i < drv->feature_table_size; i++) | ||
91 | if (drv->feature_table[i] == fbit) | ||
92 | return; | ||
93 | BUG(); | ||
94 | } | ||
95 | EXPORT_SYMBOL_GPL(virtio_check_driver_offered_feature); | ||
96 | |||
83 | static int virtio_dev_probe(struct device *_d) | 97 | static int virtio_dev_probe(struct device *_d) |
84 | { | 98 | { |
85 | int err; | 99 | int err, i; |
86 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); | 100 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); |
87 | struct virtio_driver *drv = container_of(dev->dev.driver, | 101 | struct virtio_driver *drv = container_of(dev->dev.driver, |
88 | struct virtio_driver, driver); | 102 | struct virtio_driver, driver); |
103 | u32 device_features; | ||
89 | 104 | ||
105 | /* We have a driver! */ | ||
90 | add_status(dev, VIRTIO_CONFIG_S_DRIVER); | 106 | add_status(dev, VIRTIO_CONFIG_S_DRIVER); |
107 | |||
108 | /* Figure out what features the device supports. */ | ||
109 | device_features = dev->config->get_features(dev); | ||
110 | |||
111 | /* Features supported by both device and driver into dev->features. */ | ||
112 | memset(dev->features, 0, sizeof(dev->features)); | ||
113 | for (i = 0; i < drv->feature_table_size; i++) { | ||
114 | unsigned int f = drv->feature_table[i]; | ||
115 | BUG_ON(f >= 32); | ||
116 | if (device_features & (1 << f)) | ||
117 | set_bit(f, dev->features); | ||
118 | } | ||
119 | |||
91 | err = drv->probe(dev); | 120 | err = drv->probe(dev); |
92 | if (err) | 121 | if (err) |
93 | add_status(dev, VIRTIO_CONFIG_S_FAILED); | 122 | add_status(dev, VIRTIO_CONFIG_S_FAILED); |
94 | else | 123 | else { |
95 | add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); | 124 | add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); |
125 | /* They should never have set feature bits beyond 32 */ | ||
126 | dev->config->set_features(dev, dev->features[0]); | ||
127 | } | ||
96 | return err; | 128 | return err; |
97 | } | 129 | } |
98 | 130 | ||
@@ -114,6 +146,8 @@ static int virtio_dev_remove(struct device *_d) | |||
114 | 146 | ||
115 | int register_virtio_driver(struct virtio_driver *driver) | 147 | int register_virtio_driver(struct virtio_driver *driver) |
116 | { | 148 | { |
149 | /* Catch this early. */ | ||
150 | BUG_ON(driver->feature_table_size && !driver->feature_table); | ||
117 | driver->driver.bus = &virtio_bus; | 151 | driver->driver.bus = &virtio_bus; |
118 | driver->driver.probe = virtio_dev_probe; | 152 | driver->driver.probe = virtio_dev_probe; |
119 | driver->driver.remove = virtio_dev_remove; | 153 | driver->driver.remove = virtio_dev_remove; |
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 0b3efc31ee6d..bfef604160d1 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -155,9 +155,9 @@ static void virtballoon_changed(struct virtio_device *vdev) | |||
155 | static inline s64 towards_target(struct virtio_balloon *vb) | 155 | static inline s64 towards_target(struct virtio_balloon *vb) |
156 | { | 156 | { |
157 | u32 v; | 157 | u32 v; |
158 | __virtio_config_val(vb->vdev, | 158 | vb->vdev->config->get(vb->vdev, |
159 | offsetof(struct virtio_balloon_config, num_pages), | 159 | offsetof(struct virtio_balloon_config, num_pages), |
160 | &v); | 160 | &v, sizeof(v)); |
161 | return v - vb->num_pages; | 161 | return v - vb->num_pages; |
162 | } | 162 | } |
163 | 163 | ||
@@ -227,7 +227,7 @@ static int virtballoon_probe(struct virtio_device *vdev) | |||
227 | } | 227 | } |
228 | 228 | ||
229 | vb->tell_host_first | 229 | vb->tell_host_first |
230 | = vdev->config->feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST); | 230 | = virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST); |
231 | 231 | ||
232 | return 0; | 232 | return 0; |
233 | 233 | ||
@@ -259,7 +259,11 @@ static void virtballoon_remove(struct virtio_device *vdev) | |||
259 | kfree(vb); | 259 | kfree(vb); |
260 | } | 260 | } |
261 | 261 | ||
262 | static unsigned int features[] = { VIRTIO_BALLOON_F_MUST_TELL_HOST }; | ||
263 | |||
262 | static struct virtio_driver virtio_balloon = { | 264 | static struct virtio_driver virtio_balloon = { |
265 | .feature_table = features, | ||
266 | .feature_table_size = ARRAY_SIZE(features), | ||
263 | .driver.name = KBUILD_MODNAME, | 267 | .driver.name = KBUILD_MODNAME, |
264 | .driver.owner = THIS_MODULE, | 268 | .driver.owner = THIS_MODULE, |
265 | .id_table = id_table, | 269 | .id_table = id_table, |
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index c0df924766a7..27e9fc9117cd 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c | |||
@@ -87,23 +87,22 @@ static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev) | |||
87 | return container_of(vdev, struct virtio_pci_device, vdev); | 87 | return container_of(vdev, struct virtio_pci_device, vdev); |
88 | } | 88 | } |
89 | 89 | ||
90 | /* virtio config->feature() implementation */ | 90 | /* virtio config->get_features() implementation */ |
91 | static bool vp_feature(struct virtio_device *vdev, unsigned bit) | 91 | static u32 vp_get_features(struct virtio_device *vdev) |
92 | { | ||
93 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | ||
94 | |||
95 | /* When someone needs more than 32 feature bits, we'll need to | ||
96 | * steal a bit to indicate that the rest are somewhere else. */ | ||
97 | return ioread32(vp_dev->ioaddr + VIRTIO_PCI_HOST_FEATURES); | ||
98 | } | ||
99 | |||
100 | /* virtio config->set_features() implementation */ | ||
101 | static void vp_set_features(struct virtio_device *vdev, u32 features) | ||
92 | { | 102 | { |
93 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 103 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
94 | u32 mask; | ||
95 | |||
96 | /* Since this function is supposed to have the side effect of | ||
97 | * enabling a queried feature, we simulate that by doing a read | ||
98 | * from the host feature bitmask and then writing to the guest | ||
99 | * feature bitmask */ | ||
100 | mask = ioread32(vp_dev->ioaddr + VIRTIO_PCI_HOST_FEATURES); | ||
101 | if (mask & (1 << bit)) { | ||
102 | mask |= (1 << bit); | ||
103 | iowrite32(mask, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES); | ||
104 | } | ||
105 | 104 | ||
106 | return !!(mask & (1 << bit)); | 105 | iowrite32(features, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES); |
107 | } | 106 | } |
108 | 107 | ||
109 | /* virtio config->get() implementation */ | 108 | /* virtio config->get() implementation */ |
@@ -145,14 +144,14 @@ static void vp_set_status(struct virtio_device *vdev, u8 status) | |||
145 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 144 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
146 | /* We should never be setting status to 0. */ | 145 | /* We should never be setting status to 0. */ |
147 | BUG_ON(status == 0); | 146 | BUG_ON(status == 0); |
148 | return iowrite8(status, vp_dev->ioaddr + VIRTIO_PCI_STATUS); | 147 | iowrite8(status, vp_dev->ioaddr + VIRTIO_PCI_STATUS); |
149 | } | 148 | } |
150 | 149 | ||
151 | static void vp_reset(struct virtio_device *vdev) | 150 | static void vp_reset(struct virtio_device *vdev) |
152 | { | 151 | { |
153 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 152 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
154 | /* 0 status means a reset. */ | 153 | /* 0 status means a reset. */ |
155 | return iowrite8(0, vp_dev->ioaddr + VIRTIO_PCI_STATUS); | 154 | iowrite8(0, vp_dev->ioaddr + VIRTIO_PCI_STATUS); |
156 | } | 155 | } |
157 | 156 | ||
158 | /* the notify function used when creating a virt queue */ | 157 | /* the notify function used when creating a virt queue */ |
@@ -293,7 +292,6 @@ static void vp_del_vq(struct virtqueue *vq) | |||
293 | } | 292 | } |
294 | 293 | ||
295 | static struct virtio_config_ops virtio_pci_config_ops = { | 294 | static struct virtio_config_ops virtio_pci_config_ops = { |
296 | .feature = vp_feature, | ||
297 | .get = vp_get, | 295 | .get = vp_get, |
298 | .set = vp_set, | 296 | .set = vp_set, |
299 | .get_status = vp_get_status, | 297 | .get_status = vp_get_status, |
@@ -301,6 +299,8 @@ static struct virtio_config_ops virtio_pci_config_ops = { | |||
301 | .reset = vp_reset, | 299 | .reset = vp_reset, |
302 | .find_vq = vp_find_vq, | 300 | .find_vq = vp_find_vq, |
303 | .del_vq = vp_del_vq, | 301 | .del_vq = vp_del_vq, |
302 | .get_features = vp_get_features, | ||
303 | .set_features = vp_set_features, | ||
304 | }; | 304 | }; |
305 | 305 | ||
306 | /* the PCI probing function */ | 306 | /* the PCI probing function */ |
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index c2fa5c630813..937a49d6772c 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -184,6 +184,11 @@ static void *vring_get_buf(struct virtqueue *_vq, unsigned int *len) | |||
184 | 184 | ||
185 | START_USE(vq); | 185 | START_USE(vq); |
186 | 186 | ||
187 | if (unlikely(vq->broken)) { | ||
188 | END_USE(vq); | ||
189 | return NULL; | ||
190 | } | ||
191 | |||
187 | if (!more_used(vq)) { | 192 | if (!more_used(vq)) { |
188 | pr_debug("No more buffers in queue\n"); | 193 | pr_debug("No more buffers in queue\n"); |
189 | END_USE(vq); | 194 | END_USE(vq); |
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index f42be069e085..977ef208c051 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c | |||
@@ -57,9 +57,6 @@ static struct dentry_operations anon_inodefs_dentry_operations = { | |||
57 | * anonymous inode, and a dentry that describe the "class" | 57 | * anonymous inode, and a dentry that describe the "class" |
58 | * of the file | 58 | * of the file |
59 | * | 59 | * |
60 | * @pfd: [out] pointer to the file descriptor | ||
61 | * @dpinode: [out] pointer to the inode | ||
62 | * @pfile: [out] pointer to the file struct | ||
63 | * @name: [in] name of the "class" of the new file | 60 | * @name: [in] name of the "class" of the new file |
64 | * @fops [in] file operations for the new file | 61 | * @fops [in] file operations for the new file |
65 | * @priv [in] private data for the new file (will be file's private_data) | 62 | * @priv [in] private data for the new file (will be file's private_data) |
@@ -68,10 +65,9 @@ static struct dentry_operations anon_inodefs_dentry_operations = { | |||
68 | * that do not need to have a full-fledged inode in order to operate correctly. | 65 | * that do not need to have a full-fledged inode in order to operate correctly. |
69 | * All the files created with anon_inode_getfd() will share a single inode, | 66 | * All the files created with anon_inode_getfd() will share a single inode, |
70 | * hence saving memory and avoiding code duplication for the file/inode/dentry | 67 | * hence saving memory and avoiding code duplication for the file/inode/dentry |
71 | * setup. | 68 | * setup. Returns new descriptor or -error. |
72 | */ | 69 | */ |
73 | int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile, | 70 | int anon_inode_getfd(const char *name, const struct file_operations *fops, |
74 | const char *name, const struct file_operations *fops, | ||
75 | void *priv) | 71 | void *priv) |
76 | { | 72 | { |
77 | struct qstr this; | 73 | struct qstr this; |
@@ -125,10 +121,7 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile, | |||
125 | 121 | ||
126 | fd_install(fd, file); | 122 | fd_install(fd, file); |
127 | 123 | ||
128 | *pfd = fd; | 124 | return fd; |
129 | *pinode = anon_inode_inode; | ||
130 | *pfile = file; | ||
131 | return 0; | ||
132 | 125 | ||
133 | err_dput: | 126 | err_dput: |
134 | dput(dentry); | 127 | dput(dentry); |
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c index d96e5c14a9ca..894fee54d4d8 100644 --- a/fs/autofs4/expire.c +++ b/fs/autofs4/expire.c | |||
@@ -73,8 +73,8 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry) | |||
73 | status = 0; | 73 | status = 0; |
74 | done: | 74 | done: |
75 | DPRINTK("returning = %d", status); | 75 | DPRINTK("returning = %d", status); |
76 | mntput(mnt); | ||
77 | dput(dentry); | 76 | dput(dentry); |
77 | mntput(mnt); | ||
78 | return status; | 78 | return status; |
79 | } | 79 | } |
80 | 80 | ||
@@ -333,7 +333,7 @@ static struct dentry *autofs4_expire_indirect(struct super_block *sb, | |||
333 | /* Can we expire this guy */ | 333 | /* Can we expire this guy */ |
334 | if (autofs4_can_expire(dentry, timeout, do_now)) { | 334 | if (autofs4_can_expire(dentry, timeout, do_now)) { |
335 | expired = dentry; | 335 | expired = dentry; |
336 | break; | 336 | goto found; |
337 | } | 337 | } |
338 | goto next; | 338 | goto next; |
339 | } | 339 | } |
@@ -352,7 +352,7 @@ static struct dentry *autofs4_expire_indirect(struct super_block *sb, | |||
352 | inf->flags |= AUTOFS_INF_EXPIRING; | 352 | inf->flags |= AUTOFS_INF_EXPIRING; |
353 | spin_unlock(&sbi->fs_lock); | 353 | spin_unlock(&sbi->fs_lock); |
354 | expired = dentry; | 354 | expired = dentry; |
355 | break; | 355 | goto found; |
356 | } | 356 | } |
357 | spin_unlock(&sbi->fs_lock); | 357 | spin_unlock(&sbi->fs_lock); |
358 | /* | 358 | /* |
@@ -363,7 +363,7 @@ static struct dentry *autofs4_expire_indirect(struct super_block *sb, | |||
363 | expired = autofs4_check_leaves(mnt, dentry, timeout, do_now); | 363 | expired = autofs4_check_leaves(mnt, dentry, timeout, do_now); |
364 | if (expired) { | 364 | if (expired) { |
365 | dput(dentry); | 365 | dput(dentry); |
366 | break; | 366 | goto found; |
367 | } | 367 | } |
368 | } | 368 | } |
369 | next: | 369 | next: |
@@ -371,18 +371,16 @@ next: | |||
371 | spin_lock(&dcache_lock); | 371 | spin_lock(&dcache_lock); |
372 | next = next->next; | 372 | next = next->next; |
373 | } | 373 | } |
374 | |||
375 | if (expired) { | ||
376 | DPRINTK("returning %p %.*s", | ||
377 | expired, (int)expired->d_name.len, expired->d_name.name); | ||
378 | spin_lock(&dcache_lock); | ||
379 | list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child); | ||
380 | spin_unlock(&dcache_lock); | ||
381 | return expired; | ||
382 | } | ||
383 | spin_unlock(&dcache_lock); | 374 | spin_unlock(&dcache_lock); |
384 | |||
385 | return NULL; | 375 | return NULL; |
376 | |||
377 | found: | ||
378 | DPRINTK("returning %p %.*s", | ||
379 | expired, (int)expired->d_name.len, expired->d_name.name); | ||
380 | spin_lock(&dcache_lock); | ||
381 | list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child); | ||
382 | spin_unlock(&dcache_lock); | ||
383 | return expired; | ||
386 | } | 384 | } |
387 | 385 | ||
388 | /* Perform an expiry operation */ | 386 | /* Perform an expiry operation */ |
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index aa4c5ff8a40d..edf5b6bddb52 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -146,17 +146,17 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) | |||
146 | 146 | ||
147 | if (d_mountpoint(dentry)) { | 147 | if (d_mountpoint(dentry)) { |
148 | struct file *fp = NULL; | 148 | struct file *fp = NULL; |
149 | struct vfsmount *fp_mnt = mntget(mnt); | 149 | struct path fp_path = { .dentry = dentry, .mnt = mnt }; |
150 | struct dentry *fp_dentry = dget(dentry); | ||
151 | 150 | ||
152 | if (!autofs4_follow_mount(&fp_mnt, &fp_dentry)) { | 151 | path_get(&fp_path); |
153 | dput(fp_dentry); | 152 | |
154 | mntput(fp_mnt); | 153 | if (!autofs4_follow_mount(&fp_path.mnt, &fp_path.dentry)) { |
154 | path_put(&fp_path); | ||
155 | dcache_dir_close(inode, file); | 155 | dcache_dir_close(inode, file); |
156 | goto out; | 156 | goto out; |
157 | } | 157 | } |
158 | 158 | ||
159 | fp = dentry_open(fp_dentry, fp_mnt, file->f_flags); | 159 | fp = dentry_open(fp_path.dentry, fp_path.mnt, file->f_flags); |
160 | status = PTR_ERR(fp); | 160 | status = PTR_ERR(fp); |
161 | if (IS_ERR(fp)) { | 161 | if (IS_ERR(fp)) { |
162 | dcache_dir_close(inode, file); | 162 | dcache_dir_close(inode, file); |
@@ -242,7 +242,8 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags) | |||
242 | { | 242 | { |
243 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 243 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
244 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 244 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
245 | int status = 0; | 245 | struct dentry *new; |
246 | int status; | ||
246 | 247 | ||
247 | /* Block on any pending expiry here; invalidate the dentry | 248 | /* Block on any pending expiry here; invalidate the dentry |
248 | when expiration is done to trigger mount request with a new | 249 | when expiration is done to trigger mount request with a new |
@@ -318,7 +319,28 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags) | |||
318 | spin_lock(&dentry->d_lock); | 319 | spin_lock(&dentry->d_lock); |
319 | dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; | 320 | dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; |
320 | spin_unlock(&dentry->d_lock); | 321 | spin_unlock(&dentry->d_lock); |
321 | return status; | 322 | |
323 | /* | ||
324 | * The dentry that is passed in from lookup may not be the one | ||
325 | * we end up using, as mkdir can create a new one. If this | ||
326 | * happens, and another process tries the lookup at the same time, | ||
327 | * it will set the PENDING flag on this new dentry, but add itself | ||
328 | * to our waitq. Then, if after the lookup succeeds, the first | ||
329 | * process that requested the mount performs another lookup of the | ||
330 | * same directory, it will show up as still pending! So, we need | ||
331 | * to redo the lookup here and clear pending on that dentry. | ||
332 | */ | ||
333 | if (d_unhashed(dentry)) { | ||
334 | new = d_lookup(dentry->d_parent, &dentry->d_name); | ||
335 | if (new) { | ||
336 | spin_lock(&new->d_lock); | ||
337 | new->d_flags &= ~DCACHE_AUTOFS_PENDING; | ||
338 | spin_unlock(&new->d_lock); | ||
339 | dput(new); | ||
340 | } | ||
341 | } | ||
342 | |||
343 | return 0; | ||
322 | } | 344 | } |
323 | 345 | ||
324 | /* For autofs direct mounts the follow link triggers the mount */ | 346 | /* For autofs direct mounts the follow link triggers the mount */ |
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c index 1fe28e4754c2..75e5955c3f6d 100644 --- a/fs/autofs4/waitq.c +++ b/fs/autofs4/waitq.c | |||
@@ -171,7 +171,7 @@ static int autofs4_getpath(struct autofs_sb_info *sbi, | |||
171 | for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent) | 171 | for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent) |
172 | len += tmp->d_name.len + 1; | 172 | len += tmp->d_name.len + 1; |
173 | 173 | ||
174 | if (--len > NAME_MAX) { | 174 | if (!len || --len > NAME_MAX) { |
175 | spin_unlock(&dcache_lock); | 175 | spin_unlock(&dcache_lock); |
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
diff --git a/fs/compat.c b/fs/compat.c index 139dc93c092d..332a869d2c53 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/fcntl.h> | 24 | #include <linux/fcntl.h> |
25 | #include <linux/namei.h> | 25 | #include <linux/namei.h> |
26 | #include <linux/file.h> | 26 | #include <linux/file.h> |
27 | #include <linux/fdtable.h> | ||
27 | #include <linux/vfs.h> | 28 | #include <linux/vfs.h> |
28 | #include <linux/ioctl.h> | 29 | #include <linux/ioctl.h> |
29 | #include <linux/init.h> | 30 | #include <linux/init.h> |
diff --git a/fs/dnotify.c b/fs/dnotify.c index eaecc4cfe540..676073b8dda5 100644 --- a/fs/dnotify.c +++ b/fs/dnotify.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/spinlock.h> | 21 | #include <linux/spinlock.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/file.h> | 23 | #include <linux/fdtable.h> |
24 | 24 | ||
25 | int dir_notify_enable __read_mostly = 1; | 25 | int dir_notify_enable __read_mostly = 1; |
26 | 26 | ||
diff --git a/fs/eventfd.c b/fs/eventfd.c index a9f130cd50ac..343942deeec1 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c | |||
@@ -200,10 +200,8 @@ struct file *eventfd_fget(int fd) | |||
200 | 200 | ||
201 | asmlinkage long sys_eventfd(unsigned int count) | 201 | asmlinkage long sys_eventfd(unsigned int count) |
202 | { | 202 | { |
203 | int error, fd; | 203 | int fd; |
204 | struct eventfd_ctx *ctx; | 204 | struct eventfd_ctx *ctx; |
205 | struct file *file; | ||
206 | struct inode *inode; | ||
207 | 205 | ||
208 | ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); | 206 | ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); |
209 | if (!ctx) | 207 | if (!ctx) |
@@ -216,12 +214,9 @@ asmlinkage long sys_eventfd(unsigned int count) | |||
216 | * When we call this, the initialization must be complete, since | 214 | * When we call this, the initialization must be complete, since |
217 | * anon_inode_getfd() will install the fd. | 215 | * anon_inode_getfd() will install the fd. |
218 | */ | 216 | */ |
219 | error = anon_inode_getfd(&fd, &inode, &file, "[eventfd]", | 217 | fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx); |
220 | &eventfd_fops, ctx); | 218 | if (fd < 0) |
221 | if (!error) | 219 | kfree(ctx); |
222 | return fd; | 220 | return fd; |
223 | |||
224 | kfree(ctx); | ||
225 | return error; | ||
226 | } | 221 | } |
227 | 222 | ||
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 221086fef174..990c01d2d66b 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -1050,8 +1050,6 @@ asmlinkage long sys_epoll_create(int size) | |||
1050 | { | 1050 | { |
1051 | int error, fd = -1; | 1051 | int error, fd = -1; |
1052 | struct eventpoll *ep; | 1052 | struct eventpoll *ep; |
1053 | struct inode *inode; | ||
1054 | struct file *file; | ||
1055 | 1053 | ||
1056 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n", | 1054 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n", |
1057 | current, size)); | 1055 | current, size)); |
@@ -1061,29 +1059,24 @@ asmlinkage long sys_epoll_create(int size) | |||
1061 | * structure ( "struct eventpoll" ). | 1059 | * structure ( "struct eventpoll" ). |
1062 | */ | 1060 | */ |
1063 | error = -EINVAL; | 1061 | error = -EINVAL; |
1064 | if (size <= 0 || (error = ep_alloc(&ep)) != 0) | 1062 | if (size <= 0 || (error = ep_alloc(&ep)) < 0) { |
1063 | fd = error; | ||
1065 | goto error_return; | 1064 | goto error_return; |
1065 | } | ||
1066 | 1066 | ||
1067 | /* | 1067 | /* |
1068 | * Creates all the items needed to setup an eventpoll file. That is, | 1068 | * Creates all the items needed to setup an eventpoll file. That is, |
1069 | * a file structure, and inode and a free file descriptor. | 1069 | * a file structure and a free file descriptor. |
1070 | */ | 1070 | */ |
1071 | error = anon_inode_getfd(&fd, &inode, &file, "[eventpoll]", | 1071 | fd = anon_inode_getfd("[eventpoll]", &eventpoll_fops, ep); |
1072 | &eventpoll_fops, ep); | 1072 | if (fd < 0) |
1073 | if (error) | 1073 | ep_free(ep); |
1074 | goto error_free; | ||
1075 | 1074 | ||
1075 | error_return: | ||
1076 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", | 1076 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", |
1077 | current, size, fd)); | 1077 | current, size, fd)); |
1078 | 1078 | ||
1079 | return fd; | 1079 | return fd; |
1080 | |||
1081 | error_free: | ||
1082 | ep_free(ep); | ||
1083 | error_return: | ||
1084 | DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", | ||
1085 | current, size, error)); | ||
1086 | return error; | ||
1087 | } | 1080 | } |
1088 | 1081 | ||
1089 | /* | 1082 | /* |
@@ -24,6 +24,7 @@ | |||
24 | 24 | ||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/file.h> | 26 | #include <linux/file.h> |
27 | #include <linux/fdtable.h> | ||
27 | #include <linux/mman.h> | 28 | #include <linux/mman.h> |
28 | #include <linux/a.out.h> | 29 | #include <linux/a.out.h> |
29 | #include <linux/stat.h> | 30 | #include <linux/stat.h> |
diff --git a/fs/fcntl.c b/fs/fcntl.c index 3f3ac630ccde..bfd776509a72 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/mm.h> | 9 | #include <linux/mm.h> |
10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
11 | #include <linux/file.h> | 11 | #include <linux/file.h> |
12 | #include <linux/fdtable.h> | ||
12 | #include <linux/capability.h> | 13 | #include <linux/capability.h> |
13 | #include <linux/dnotify.h> | 14 | #include <linux/dnotify.h> |
14 | #include <linux/smp_lock.h> | 15 | #include <linux/smp_lock.h> |
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/vmalloc.h> | 13 | #include <linux/vmalloc.h> |
14 | #include <linux/file.h> | 14 | #include <linux/file.h> |
15 | #include <linux/fdtable.h> | ||
15 | #include <linux/bitops.h> | 16 | #include <linux/bitops.h> |
16 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
17 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
@@ -149,8 +150,16 @@ static struct fdtable * alloc_fdtable(unsigned int nr) | |||
149 | nr /= (1024 / sizeof(struct file *)); | 150 | nr /= (1024 / sizeof(struct file *)); |
150 | nr = roundup_pow_of_two(nr + 1); | 151 | nr = roundup_pow_of_two(nr + 1); |
151 | nr *= (1024 / sizeof(struct file *)); | 152 | nr *= (1024 / sizeof(struct file *)); |
152 | if (nr > sysctl_nr_open) | 153 | /* |
153 | nr = sysctl_nr_open; | 154 | * Note that this can drive nr *below* what we had passed if sysctl_nr_open |
155 | * had been set lower between the check in expand_files() and here. Deal | ||
156 | * with that in caller, it's cheaper that way. | ||
157 | * | ||
158 | * We make sure that nr remains a multiple of BITS_PER_LONG - otherwise | ||
159 | * bitmaps handling below becomes unpleasant, to put it mildly... | ||
160 | */ | ||
161 | if (unlikely(nr > sysctl_nr_open)) | ||
162 | nr = ((sysctl_nr_open - 1) | (BITS_PER_LONG - 1)) + 1; | ||
154 | 163 | ||
155 | fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL); | 164 | fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL); |
156 | if (!fdt) | 165 | if (!fdt) |
@@ -199,6 +208,16 @@ static int expand_fdtable(struct files_struct *files, int nr) | |||
199 | if (!new_fdt) | 208 | if (!new_fdt) |
200 | return -ENOMEM; | 209 | return -ENOMEM; |
201 | /* | 210 | /* |
211 | * extremely unlikely race - sysctl_nr_open decreased between the check in | ||
212 | * caller and alloc_fdtable(). Cheaper to catch it here... | ||
213 | */ | ||
214 | if (unlikely(new_fdt->max_fds <= nr)) { | ||
215 | free_fdarr(new_fdt); | ||
216 | free_fdset(new_fdt); | ||
217 | kfree(new_fdt); | ||
218 | return -EMFILE; | ||
219 | } | ||
220 | /* | ||
202 | * Check again since another task may have expanded the fd table while | 221 | * Check again since another task may have expanded the fd table while |
203 | * we dropped the lock | 222 | * we dropped the lock |
204 | */ | 223 | */ |
diff --git a/fs/file_table.c b/fs/file_table.c index 7a0a9b872251..83084225b4c3 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/string.h> | 8 | #include <linux/string.h> |
9 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
10 | #include <linux/file.h> | 10 | #include <linux/file.h> |
11 | #include <linux/fdtable.h> | ||
11 | #include <linux/init.h> | 12 | #include <linux/init.h> |
12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
13 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 9ced35b00686..f28cf8b46f80 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -934,7 +934,7 @@ static int fuse_get_user_pages(struct fuse_req *req, const char __user *buf, | |||
934 | 934 | ||
935 | nbytes = min(nbytes, (unsigned) FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT); | 935 | nbytes = min(nbytes, (unsigned) FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT); |
936 | npages = (nbytes + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; | 936 | npages = (nbytes + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; |
937 | npages = min(max(npages, 1), FUSE_MAX_PAGES_PER_REQ); | 937 | npages = clamp(npages, 1, FUSE_MAX_PAGES_PER_REQ); |
938 | down_read(¤t->mm->mmap_sem); | 938 | down_read(¤t->mm->mmap_sem); |
939 | npages = get_user_pages(current, current->mm, user_addr, npages, write, | 939 | npages = get_user_pages(current, current->mm, user_addr, npages, write, |
940 | 0, req->pages, NULL); | 940 | 0, req->pages, NULL); |
diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c index d58f845ccb85..c5e1450d79f9 100644 --- a/fs/jffs2/build.c +++ b/fs/jffs2/build.c | |||
@@ -46,7 +46,7 @@ next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c) | |||
46 | 46 | ||
47 | 47 | ||
48 | static void jffs2_build_inode_pass1(struct jffs2_sb_info *c, | 48 | static void jffs2_build_inode_pass1(struct jffs2_sb_info *c, |
49 | struct jffs2_inode_cache *ic) | 49 | struct jffs2_inode_cache *ic) |
50 | { | 50 | { |
51 | struct jffs2_full_dirent *fd; | 51 | struct jffs2_full_dirent *fd; |
52 | 52 | ||
@@ -68,11 +68,17 @@ static void jffs2_build_inode_pass1(struct jffs2_sb_info *c, | |||
68 | continue; | 68 | continue; |
69 | } | 69 | } |
70 | 70 | ||
71 | if (child_ic->nlink++ && fd->type == DT_DIR) { | 71 | if (fd->type == DT_DIR) { |
72 | JFFS2_ERROR("child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n", | 72 | if (child_ic->pino_nlink) { |
73 | fd->name, fd->ino, ic->ino); | 73 | JFFS2_ERROR("child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n", |
74 | /* TODO: What do we do about it? */ | 74 | fd->name, fd->ino, ic->ino); |
75 | } | 75 | /* TODO: What do we do about it? */ |
76 | } else { | ||
77 | child_ic->pino_nlink = ic->ino; | ||
78 | } | ||
79 | } else | ||
80 | child_ic->pino_nlink++; | ||
81 | |||
76 | dbg_fsbuild("increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino); | 82 | dbg_fsbuild("increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino); |
77 | /* Can't free scan_dents so far. We might need them in pass 2 */ | 83 | /* Can't free scan_dents so far. We might need them in pass 2 */ |
78 | } | 84 | } |
@@ -125,7 +131,7 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) | |||
125 | dbg_fsbuild("pass 2 starting\n"); | 131 | dbg_fsbuild("pass 2 starting\n"); |
126 | 132 | ||
127 | for_each_inode(i, c, ic) { | 133 | for_each_inode(i, c, ic) { |
128 | if (ic->nlink) | 134 | if (ic->pino_nlink) |
129 | continue; | 135 | continue; |
130 | 136 | ||
131 | jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); | 137 | jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); |
@@ -232,16 +238,19 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, | |||
232 | /* Reduce nlink of the child. If it's now zero, stick it on the | 238 | /* Reduce nlink of the child. If it's now zero, stick it on the |
233 | dead_fds list to be cleaned up later. Else just free the fd */ | 239 | dead_fds list to be cleaned up later. Else just free the fd */ |
234 | 240 | ||
235 | child_ic->nlink--; | 241 | if (fd->type == DT_DIR) |
242 | child_ic->pino_nlink = 0; | ||
243 | else | ||
244 | child_ic->pino_nlink--; | ||
236 | 245 | ||
237 | if (!child_ic->nlink) { | 246 | if (!child_ic->pino_nlink) { |
238 | dbg_fsbuild("inode #%u (\"%s\") has now got zero nlink, adding to dead_fds list.\n", | 247 | dbg_fsbuild("inode #%u (\"%s\") now has no links; adding to dead_fds list.\n", |
239 | fd->ino, fd->name); | 248 | fd->ino, fd->name); |
240 | fd->next = *dead_fds; | 249 | fd->next = *dead_fds; |
241 | *dead_fds = fd; | 250 | *dead_fds = fd; |
242 | } else { | 251 | } else { |
243 | dbg_fsbuild("inode #%u (\"%s\") has now got nlink %d. Ignoring.\n", | 252 | dbg_fsbuild("inode #%u (\"%s\") has now got nlink %d. Ignoring.\n", |
244 | fd->ino, fd->name, child_ic->nlink); | 253 | fd->ino, fd->name, child_ic->pino_nlink); |
245 | jffs2_free_full_dirent(fd); | 254 | jffs2_free_full_dirent(fd); |
246 | } | 255 | } |
247 | } | 256 | } |
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index c63e7a96af0d..c0c141f6fde1 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -208,6 +208,13 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode, | |||
208 | f = JFFS2_INODE_INFO(inode); | 208 | f = JFFS2_INODE_INFO(inode); |
209 | dir_f = JFFS2_INODE_INFO(dir_i); | 209 | dir_f = JFFS2_INODE_INFO(dir_i); |
210 | 210 | ||
211 | /* jffs2_do_create() will want to lock it, _after_ reserving | ||
212 | space and taking c-alloc_sem. If we keep it locked here, | ||
213 | lockdep gets unhappy (although it's a false positive; | ||
214 | nothing else will be looking at this inode yet so there's | ||
215 | no chance of AB-BA deadlock involving its f->sem). */ | ||
216 | mutex_unlock(&f->sem); | ||
217 | |||
211 | ret = jffs2_do_create(c, dir_f, f, ri, | 218 | ret = jffs2_do_create(c, dir_f, f, ri, |
212 | dentry->d_name.name, dentry->d_name.len); | 219 | dentry->d_name.name, dentry->d_name.len); |
213 | if (ret) | 220 | if (ret) |
@@ -219,7 +226,8 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode, | |||
219 | d_instantiate(dentry, inode); | 226 | d_instantiate(dentry, inode); |
220 | 227 | ||
221 | D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n", | 228 | D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n", |
222 | inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages)); | 229 | inode->i_ino, inode->i_mode, inode->i_nlink, |
230 | f->inocache->pino_nlink, inode->i_mapping->nrpages)); | ||
223 | return 0; | 231 | return 0; |
224 | 232 | ||
225 | fail: | 233 | fail: |
@@ -243,7 +251,7 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry) | |||
243 | ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, | 251 | ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, |
244 | dentry->d_name.len, dead_f, now); | 252 | dentry->d_name.len, dead_f, now); |
245 | if (dead_f->inocache) | 253 | if (dead_f->inocache) |
246 | dentry->d_inode->i_nlink = dead_f->inocache->nlink; | 254 | dentry->d_inode->i_nlink = dead_f->inocache->pino_nlink; |
247 | if (!ret) | 255 | if (!ret) |
248 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); | 256 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); |
249 | return ret; | 257 | return ret; |
@@ -276,7 +284,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de | |||
276 | 284 | ||
277 | if (!ret) { | 285 | if (!ret) { |
278 | mutex_lock(&f->sem); | 286 | mutex_lock(&f->sem); |
279 | old_dentry->d_inode->i_nlink = ++f->inocache->nlink; | 287 | old_dentry->d_inode->i_nlink = ++f->inocache->pino_nlink; |
280 | mutex_unlock(&f->sem); | 288 | mutex_unlock(&f->sem); |
281 | d_instantiate(dentry, old_dentry->d_inode); | 289 | d_instantiate(dentry, old_dentry->d_inode); |
282 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); | 290 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); |
@@ -493,11 +501,14 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
493 | 501 | ||
494 | inode->i_op = &jffs2_dir_inode_operations; | 502 | inode->i_op = &jffs2_dir_inode_operations; |
495 | inode->i_fop = &jffs2_dir_operations; | 503 | inode->i_fop = &jffs2_dir_operations; |
496 | /* Directories get nlink 2 at start */ | ||
497 | inode->i_nlink = 2; | ||
498 | 504 | ||
499 | f = JFFS2_INODE_INFO(inode); | 505 | f = JFFS2_INODE_INFO(inode); |
500 | 506 | ||
507 | /* Directories get nlink 2 at start */ | ||
508 | inode->i_nlink = 2; | ||
509 | /* but ic->pino_nlink is the parent ino# */ | ||
510 | f->inocache->pino_nlink = dir_i->i_ino; | ||
511 | |||
501 | ri->data_crc = cpu_to_je32(0); | 512 | ri->data_crc = cpu_to_je32(0); |
502 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); | 513 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); |
503 | 514 | ||
@@ -594,17 +605,25 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
594 | 605 | ||
595 | static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry) | 606 | static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry) |
596 | { | 607 | { |
608 | struct jffs2_sb_info *c = JFFS2_SB_INFO(dir_i->i_sb); | ||
609 | struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i); | ||
597 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode); | 610 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode); |
598 | struct jffs2_full_dirent *fd; | 611 | struct jffs2_full_dirent *fd; |
599 | int ret; | 612 | int ret; |
613 | uint32_t now = get_seconds(); | ||
600 | 614 | ||
601 | for (fd = f->dents ; fd; fd = fd->next) { | 615 | for (fd = f->dents ; fd; fd = fd->next) { |
602 | if (fd->ino) | 616 | if (fd->ino) |
603 | return -ENOTEMPTY; | 617 | return -ENOTEMPTY; |
604 | } | 618 | } |
605 | ret = jffs2_unlink(dir_i, dentry); | 619 | |
606 | if (!ret) | 620 | ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, |
621 | dentry->d_name.len, f, now); | ||
622 | if (!ret) { | ||
623 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); | ||
624 | clear_nlink(dentry->d_inode); | ||
607 | drop_nlink(dir_i); | 625 | drop_nlink(dir_i); |
626 | } | ||
608 | return ret; | 627 | return ret; |
609 | } | 628 | } |
610 | 629 | ||
@@ -817,7 +836,10 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
817 | inode which didn't exist. */ | 836 | inode which didn't exist. */ |
818 | if (victim_f->inocache) { | 837 | if (victim_f->inocache) { |
819 | mutex_lock(&victim_f->sem); | 838 | mutex_lock(&victim_f->sem); |
820 | victim_f->inocache->nlink--; | 839 | if (S_ISDIR(new_dentry->d_inode->i_mode)) |
840 | victim_f->inocache->pino_nlink = 0; | ||
841 | else | ||
842 | victim_f->inocache->pino_nlink--; | ||
821 | mutex_unlock(&victim_f->sem); | 843 | mutex_unlock(&victim_f->sem); |
822 | } | 844 | } |
823 | } | 845 | } |
@@ -838,8 +860,8 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
838 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode); | 860 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode); |
839 | mutex_lock(&f->sem); | 861 | mutex_lock(&f->sem); |
840 | inc_nlink(old_dentry->d_inode); | 862 | inc_nlink(old_dentry->d_inode); |
841 | if (f->inocache) | 863 | if (f->inocache && !S_ISDIR(old_dentry->d_inode->i_mode)) |
842 | f->inocache->nlink++; | 864 | f->inocache->pino_nlink++; |
843 | mutex_unlock(&f->sem); | 865 | mutex_unlock(&f->sem); |
844 | 866 | ||
845 | printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret); | 867 | printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret); |
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index 25a640e566d3..dddb2a6c9e2c 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c | |||
@@ -294,7 +294,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
294 | break; | 294 | break; |
295 | #endif | 295 | #endif |
296 | default: | 296 | default: |
297 | if (ic->nodes == (void *)ic && ic->nlink == 0) | 297 | if (ic->nodes == (void *)ic && ic->pino_nlink == 0) |
298 | jffs2_del_ino_cache(c, ic); | 298 | jffs2_del_ino_cache(c, ic); |
299 | } | 299 | } |
300 | } | 300 | } |
@@ -332,7 +332,8 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
332 | if (c->mtd->point) { | 332 | if (c->mtd->point) { |
333 | unsigned long *wordebuf; | 333 | unsigned long *wordebuf; |
334 | 334 | ||
335 | ret = c->mtd->point(c->mtd, jeb->offset, c->sector_size, &retlen, (unsigned char **)&ebuf); | 335 | ret = c->mtd->point(c->mtd, jeb->offset, c->sector_size, |
336 | &retlen, &ebuf, NULL); | ||
336 | if (ret) { | 337 | if (ret) { |
337 | D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); | 338 | D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); |
338 | goto do_flash_read; | 339 | goto do_flash_read; |
@@ -340,7 +341,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
340 | if (retlen < c->sector_size) { | 341 | if (retlen < c->sector_size) { |
341 | /* Don't muck about if it won't let us point to the whole erase sector */ | 342 | /* Don't muck about if it won't let us point to the whole erase sector */ |
342 | D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen)); | 343 | D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen)); |
343 | c->mtd->unpoint(c->mtd, ebuf, jeb->offset, retlen); | 344 | c->mtd->unpoint(c->mtd, jeb->offset, retlen); |
344 | goto do_flash_read; | 345 | goto do_flash_read; |
345 | } | 346 | } |
346 | wordebuf = ebuf-sizeof(*wordebuf); | 347 | wordebuf = ebuf-sizeof(*wordebuf); |
@@ -349,7 +350,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
349 | if (*++wordebuf != ~0) | 350 | if (*++wordebuf != ~0) |
350 | break; | 351 | break; |
351 | } while(--retlen); | 352 | } while(--retlen); |
352 | c->mtd->unpoint(c->mtd, ebuf, jeb->offset, c->sector_size); | 353 | c->mtd->unpoint(c->mtd, jeb->offset, c->sector_size); |
353 | if (retlen) { | 354 | if (retlen) { |
354 | printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n", | 355 | printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n", |
355 | *wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf)); | 356 | *wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf)); |
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 3eb1c84b0a33..086c43830221 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -273,7 +273,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
273 | inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime)); | 273 | inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime)); |
274 | inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime)); | 274 | inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime)); |
275 | 275 | ||
276 | inode->i_nlink = f->inocache->nlink; | 276 | inode->i_nlink = f->inocache->pino_nlink; |
277 | 277 | ||
278 | inode->i_blocks = (inode->i_size + 511) >> 9; | 278 | inode->i_blocks = (inode->i_size + 511) >> 9; |
279 | 279 | ||
@@ -286,13 +286,12 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
286 | case S_IFDIR: | 286 | case S_IFDIR: |
287 | { | 287 | { |
288 | struct jffs2_full_dirent *fd; | 288 | struct jffs2_full_dirent *fd; |
289 | inode->i_nlink = 2; /* parent and '.' */ | ||
289 | 290 | ||
290 | for (fd=f->dents; fd; fd = fd->next) { | 291 | for (fd=f->dents; fd; fd = fd->next) { |
291 | if (fd->type == DT_DIR && fd->ino) | 292 | if (fd->type == DT_DIR && fd->ino) |
292 | inc_nlink(inode); | 293 | inc_nlink(inode); |
293 | } | 294 | } |
294 | /* and '..' */ | ||
295 | inc_nlink(inode); | ||
296 | /* Root dir gets i_nlink 3 for some reason */ | 295 | /* Root dir gets i_nlink 3 for some reason */ |
297 | if (inode->i_ino == 1) | 296 | if (inode->i_ino == 1) |
298 | inc_nlink(inode); | 297 | inc_nlink(inode); |
@@ -586,11 +585,12 @@ void jffs2_gc_release_inode(struct jffs2_sb_info *c, | |||
586 | } | 585 | } |
587 | 586 | ||
588 | struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | 587 | struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, |
589 | int inum, int nlink) | 588 | int inum, int unlinked) |
590 | { | 589 | { |
591 | struct inode *inode; | 590 | struct inode *inode; |
592 | struct jffs2_inode_cache *ic; | 591 | struct jffs2_inode_cache *ic; |
593 | if (!nlink) { | 592 | |
593 | if (unlinked) { | ||
594 | /* The inode has zero nlink but its nodes weren't yet marked | 594 | /* The inode has zero nlink but its nodes weren't yet marked |
595 | obsolete. This has to be because we're still waiting for | 595 | obsolete. This has to be because we're still waiting for |
596 | the final (close() and) iput() to happen. | 596 | the final (close() and) iput() to happen. |
@@ -638,8 +638,8 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
638 | return ERR_CAST(inode); | 638 | return ERR_CAST(inode); |
639 | } | 639 | } |
640 | if (is_bad_inode(inode)) { | 640 | if (is_bad_inode(inode)) { |
641 | printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. nlink %d\n", | 641 | printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. unlinked %d\n", |
642 | inum, nlink); | 642 | inum, unlinked); |
643 | /* NB. This will happen again. We need to do something appropriate here. */ | 643 | /* NB. This will happen again. We need to do something appropriate here. */ |
644 | iput(inode); | 644 | iput(inode); |
645 | return ERR_PTR(-EIO); | 645 | return ERR_PTR(-EIO); |
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index bad005664e30..090c556ffed2 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -161,8 +161,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
161 | continue; | 161 | continue; |
162 | } | 162 | } |
163 | 163 | ||
164 | if (!ic->nlink) { | 164 | if (!ic->pino_nlink) { |
165 | D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink zero\n", | 165 | D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink/pino zero\n", |
166 | ic->ino)); | 166 | ic->ino)); |
167 | spin_unlock(&c->inocache_lock); | 167 | spin_unlock(&c->inocache_lock); |
168 | jffs2_xattr_delete_inode(c, ic); | 168 | jffs2_xattr_delete_inode(c, ic); |
@@ -398,10 +398,10 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
398 | it's vaguely possible. */ | 398 | it's vaguely possible. */ |
399 | 399 | ||
400 | inum = ic->ino; | 400 | inum = ic->ino; |
401 | nlink = ic->nlink; | 401 | nlink = ic->pino_nlink; |
402 | spin_unlock(&c->inocache_lock); | 402 | spin_unlock(&c->inocache_lock); |
403 | 403 | ||
404 | f = jffs2_gc_fetch_inode(c, inum, nlink); | 404 | f = jffs2_gc_fetch_inode(c, inum, !nlink); |
405 | if (IS_ERR(f)) { | 405 | if (IS_ERR(f)) { |
406 | ret = PTR_ERR(f); | 406 | ret = PTR_ERR(f); |
407 | goto release_sem; | 407 | goto release_sem; |
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h index 8219df6eb6d8..1750445556c3 100644 --- a/fs/jffs2/nodelist.h +++ b/fs/jffs2/nodelist.h | |||
@@ -177,7 +177,10 @@ struct jffs2_inode_cache { | |||
177 | #ifdef CONFIG_JFFS2_FS_XATTR | 177 | #ifdef CONFIG_JFFS2_FS_XATTR |
178 | struct jffs2_xattr_ref *xref; | 178 | struct jffs2_xattr_ref *xref; |
179 | #endif | 179 | #endif |
180 | int nlink; | 180 | uint32_t pino_nlink; /* Directories store parent inode |
181 | here; other inodes store nlink. | ||
182 | Zero always means that it's | ||
183 | completely unlinked. */ | ||
181 | }; | 184 | }; |
182 | 185 | ||
183 | /* Inode states for 'state' above. We need the 'GC' state to prevent | 186 | /* Inode states for 'state' above. We need the 'GC' state to prevent |
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index 9df8f3ef20df..a9bf9603c1ba 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -709,7 +709,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
709 | break; | 709 | break; |
710 | #endif | 710 | #endif |
711 | default: | 711 | default: |
712 | if (ic->nodes == (void *)ic && ic->nlink == 0) | 712 | if (ic->nodes == (void *)ic && ic->pino_nlink == 0) |
713 | jffs2_del_ino_cache(c, ic); | 713 | jffs2_del_ino_cache(c, ic); |
714 | break; | 714 | break; |
715 | } | 715 | } |
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index 1b10d2594092..2cc866cf134f 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h | |||
@@ -187,7 +187,7 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent); | |||
187 | void jffs2_gc_release_inode(struct jffs2_sb_info *c, | 187 | void jffs2_gc_release_inode(struct jffs2_sb_info *c, |
188 | struct jffs2_inode_info *f); | 188 | struct jffs2_inode_info *f); |
189 | struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | 189 | struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, |
190 | int inum, int nlink); | 190 | int inum, int unlinked); |
191 | 191 | ||
192 | unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, | 192 | unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, |
193 | struct jffs2_inode_info *f, | 193 | struct jffs2_inode_info *f, |
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 4cb4d76de07f..6ca08ad887c0 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -63,10 +63,11 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info | |||
63 | /* TODO: instead, incapsulate point() stuff to jffs2_flash_read(), | 63 | /* TODO: instead, incapsulate point() stuff to jffs2_flash_read(), |
64 | * adding and jffs2_flash_read_end() interface. */ | 64 | * adding and jffs2_flash_read_end() interface. */ |
65 | if (c->mtd->point) { | 65 | if (c->mtd->point) { |
66 | err = c->mtd->point(c->mtd, ofs, len, &retlen, &buffer); | 66 | err = c->mtd->point(c->mtd, ofs, len, &retlen, |
67 | (void **)&buffer, NULL); | ||
67 | if (!err && retlen < len) { | 68 | if (!err && retlen < len) { |
68 | JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); | 69 | JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); |
69 | c->mtd->unpoint(c->mtd, buffer, ofs, retlen); | 70 | c->mtd->unpoint(c->mtd, ofs, retlen); |
70 | } else if (err) | 71 | } else if (err) |
71 | JFFS2_WARNING("MTD point failed: error code %d.\n", err); | 72 | JFFS2_WARNING("MTD point failed: error code %d.\n", err); |
72 | else | 73 | else |
@@ -100,7 +101,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info | |||
100 | kfree(buffer); | 101 | kfree(buffer); |
101 | #ifndef __ECOS | 102 | #ifndef __ECOS |
102 | else | 103 | else |
103 | c->mtd->unpoint(c->mtd, buffer, ofs, len); | 104 | c->mtd->unpoint(c->mtd, ofs, len); |
104 | #endif | 105 | #endif |
105 | 106 | ||
106 | if (crc != tn->data_crc) { | 107 | if (crc != tn->data_crc) { |
@@ -136,7 +137,7 @@ free_out: | |||
136 | kfree(buffer); | 137 | kfree(buffer); |
137 | #ifndef __ECOS | 138 | #ifndef __ECOS |
138 | else | 139 | else |
139 | c->mtd->unpoint(c->mtd, buffer, ofs, len); | 140 | c->mtd->unpoint(c->mtd, ofs, len); |
140 | #endif | 141 | #endif |
141 | return err; | 142 | return err; |
142 | } | 143 | } |
@@ -1123,7 +1124,8 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1123 | size_t retlen; | 1124 | size_t retlen; |
1124 | int ret; | 1125 | int ret; |
1125 | 1126 | ||
1126 | dbg_readinode("ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink); | 1127 | dbg_readinode("ino #%u pino/nlink is %d\n", f->inocache->ino, |
1128 | f->inocache->pino_nlink); | ||
1127 | 1129 | ||
1128 | memset(&rii, 0, sizeof(rii)); | 1130 | memset(&rii, 0, sizeof(rii)); |
1129 | 1131 | ||
@@ -1358,7 +1360,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
1358 | } | 1360 | } |
1359 | dbg_readinode("creating inocache for root inode\n"); | 1361 | dbg_readinode("creating inocache for root inode\n"); |
1360 | memset(f->inocache, 0, sizeof(struct jffs2_inode_cache)); | 1362 | memset(f->inocache, 0, sizeof(struct jffs2_inode_cache)); |
1361 | f->inocache->ino = f->inocache->nlink = 1; | 1363 | f->inocache->ino = f->inocache->pino_nlink = 1; |
1362 | f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; | 1364 | f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; |
1363 | f->inocache->state = INO_STATE_READING; | 1365 | f->inocache->state = INO_STATE_READING; |
1364 | jffs2_add_ino_cache(c, f->inocache); | 1366 | jffs2_add_ino_cache(c, f->inocache); |
@@ -1401,7 +1403,7 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) | |||
1401 | jffs2_clear_acl(f); | 1403 | jffs2_clear_acl(f); |
1402 | jffs2_xattr_delete_inode(c, f->inocache); | 1404 | jffs2_xattr_delete_inode(c, f->inocache); |
1403 | mutex_lock(&f->sem); | 1405 | mutex_lock(&f->sem); |
1404 | deleted = f->inocache && !f->inocache->nlink; | 1406 | deleted = f->inocache && !f->inocache->pino_nlink; |
1405 | 1407 | ||
1406 | if (f->inocache && f->inocache->state != INO_STATE_CHECKING) | 1408 | if (f->inocache && f->inocache->state != INO_STATE_CHECKING) |
1407 | jffs2_set_inocache_state(c, f->inocache, INO_STATE_CLEARING); | 1409 | jffs2_set_inocache_state(c, f->inocache, INO_STATE_CLEARING); |
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index 272872d27fd5..1d437de1e9a8 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c | |||
@@ -97,11 +97,12 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
97 | size_t pointlen; | 97 | size_t pointlen; |
98 | 98 | ||
99 | if (c->mtd->point) { | 99 | if (c->mtd->point) { |
100 | ret = c->mtd->point (c->mtd, 0, c->mtd->size, &pointlen, &flashbuf); | 100 | ret = c->mtd->point(c->mtd, 0, c->mtd->size, &pointlen, |
101 | (void **)&flashbuf, NULL); | ||
101 | if (!ret && pointlen < c->mtd->size) { | 102 | if (!ret && pointlen < c->mtd->size) { |
102 | /* Don't muck about if it won't let us point to the whole flash */ | 103 | /* Don't muck about if it won't let us point to the whole flash */ |
103 | D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", pointlen)); | 104 | D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", pointlen)); |
104 | c->mtd->unpoint(c->mtd, flashbuf, 0, pointlen); | 105 | c->mtd->unpoint(c->mtd, 0, pointlen); |
105 | flashbuf = NULL; | 106 | flashbuf = NULL; |
106 | } | 107 | } |
107 | if (ret) | 108 | if (ret) |
@@ -267,7 +268,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
267 | kfree(flashbuf); | 268 | kfree(flashbuf); |
268 | #ifndef __ECOS | 269 | #ifndef __ECOS |
269 | else | 270 | else |
270 | c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size); | 271 | c->mtd->unpoint(c->mtd, 0, c->mtd->size); |
271 | #endif | 272 | #endif |
272 | if (s) | 273 | if (s) |
273 | kfree(s); | 274 | kfree(s); |
@@ -940,7 +941,7 @@ struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uin | |||
940 | ic->nodes = (void *)ic; | 941 | ic->nodes = (void *)ic; |
941 | jffs2_add_ino_cache(c, ic); | 942 | jffs2_add_ino_cache(c, ic); |
942 | if (ino == 1) | 943 | if (ino == 1) |
943 | ic->nlink = 1; | 944 | ic->pino_nlink = 1; |
944 | return ic; | 945 | return ic; |
945 | } | 946 | } |
946 | 947 | ||
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index f3353df178e7..7da69eae49e4 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -31,11 +31,12 @@ static struct kmem_cache *jffs2_inode_cachep; | |||
31 | 31 | ||
32 | static struct inode *jffs2_alloc_inode(struct super_block *sb) | 32 | static struct inode *jffs2_alloc_inode(struct super_block *sb) |
33 | { | 33 | { |
34 | struct jffs2_inode_info *ei; | 34 | struct jffs2_inode_info *f; |
35 | ei = (struct jffs2_inode_info *)kmem_cache_alloc(jffs2_inode_cachep, GFP_KERNEL); | 35 | |
36 | if (!ei) | 36 | f = kmem_cache_alloc(jffs2_inode_cachep, GFP_KERNEL); |
37 | if (!f) | ||
37 | return NULL; | 38 | return NULL; |
38 | return &ei->vfs_inode; | 39 | return &f->vfs_inode; |
39 | } | 40 | } |
40 | 41 | ||
41 | static void jffs2_destroy_inode(struct inode *inode) | 42 | static void jffs2_destroy_inode(struct inode *inode) |
@@ -45,10 +46,10 @@ static void jffs2_destroy_inode(struct inode *inode) | |||
45 | 46 | ||
46 | static void jffs2_i_init_once(struct kmem_cache *cachep, void *foo) | 47 | static void jffs2_i_init_once(struct kmem_cache *cachep, void *foo) |
47 | { | 48 | { |
48 | struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo; | 49 | struct jffs2_inode_info *f = foo; |
49 | 50 | ||
50 | mutex_init(&ei->sem); | 51 | mutex_init(&f->sem); |
51 | inode_init_once(&ei->vfs_inode); | 52 | inode_init_once(&f->vfs_inode); |
52 | } | 53 | } |
53 | 54 | ||
54 | static int jffs2_sync_fs(struct super_block *sb, int wait) | 55 | static int jffs2_sync_fs(struct super_block *sb, int wait) |
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index 8de52b607678..0e78b00035e4 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -494,7 +494,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
494 | /* If it's an in-core inode, then we have to adjust any | 494 | /* If it's an in-core inode, then we have to adjust any |
495 | full_dirent or full_dnode structure to point to the | 495 | full_dirent or full_dnode structure to point to the |
496 | new version instead of the old */ | 496 | new version instead of the old */ |
497 | f = jffs2_gc_fetch_inode(c, ic->ino, ic->nlink); | 497 | f = jffs2_gc_fetch_inode(c, ic->ino, !ic->pino_nlink); |
498 | if (IS_ERR(f)) { | 498 | if (IS_ERR(f)) { |
499 | /* Should never happen; it _must_ be present */ | 499 | /* Should never happen; it _must_ be present */ |
500 | JFFS2_ERROR("Failed to iget() ino #%u, err %ld\n", | 500 | JFFS2_ERROR("Failed to iget() ino #%u, err %ld\n", |
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c index 665fce9797d3..ca29440e9435 100644 --- a/fs/jffs2/write.c +++ b/fs/jffs2/write.c | |||
@@ -19,7 +19,8 @@ | |||
19 | #include "compr.h" | 19 | #include "compr.h" |
20 | 20 | ||
21 | 21 | ||
22 | int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri) | 22 | int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
23 | uint32_t mode, struct jffs2_raw_inode *ri) | ||
23 | { | 24 | { |
24 | struct jffs2_inode_cache *ic; | 25 | struct jffs2_inode_cache *ic; |
25 | 26 | ||
@@ -31,7 +32,7 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint | |||
31 | memset(ic, 0, sizeof(*ic)); | 32 | memset(ic, 0, sizeof(*ic)); |
32 | 33 | ||
33 | f->inocache = ic; | 34 | f->inocache = ic; |
34 | f->inocache->nlink = 1; | 35 | f->inocache->pino_nlink = 1; /* Will be overwritten shortly for directories */ |
35 | f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; | 36 | f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; |
36 | f->inocache->state = INO_STATE_PRESENT; | 37 | f->inocache->state = INO_STATE_PRESENT; |
37 | 38 | ||
@@ -438,10 +439,10 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
438 | ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL, | 439 | ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL, |
439 | JFFS2_SUMMARY_INODE_SIZE); | 440 | JFFS2_SUMMARY_INODE_SIZE); |
440 | D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); | 441 | D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); |
441 | if (ret) { | 442 | if (ret) |
442 | mutex_unlock(&f->sem); | ||
443 | return ret; | 443 | return ret; |
444 | } | 444 | |
445 | mutex_lock(&f->sem); | ||
445 | 446 | ||
446 | ri->data_crc = cpu_to_je32(0); | 447 | ri->data_crc = cpu_to_je32(0); |
447 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); | 448 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); |
@@ -635,9 +636,9 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
635 | jffs2_mark_node_obsolete(c, fd->raw); | 636 | jffs2_mark_node_obsolete(c, fd->raw); |
636 | jffs2_free_full_dirent(fd); | 637 | jffs2_free_full_dirent(fd); |
637 | } | 638 | } |
638 | } | 639 | dead_f->inocache->pino_nlink = 0; |
639 | 640 | } else | |
640 | dead_f->inocache->nlink--; | 641 | dead_f->inocache->pino_nlink--; |
641 | /* NB: Caller must set inode nlink if appropriate */ | 642 | /* NB: Caller must set inode nlink if appropriate */ |
642 | mutex_unlock(&dead_f->sem); | 643 | mutex_unlock(&dead_f->sem); |
643 | } | 644 | } |
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index 574cb7532d6c..082e844ab2db 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c | |||
@@ -592,7 +592,7 @@ void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache | |||
592 | When an inode with XATTR is removed, those XATTRs must be removed. */ | 592 | When an inode with XATTR is removed, those XATTRs must be removed. */ |
593 | struct jffs2_xattr_ref *ref, *_ref; | 593 | struct jffs2_xattr_ref *ref, *_ref; |
594 | 594 | ||
595 | if (!ic || ic->nlink > 0) | 595 | if (!ic || ic->pino_nlink > 0) |
596 | return; | 596 | return; |
597 | 597 | ||
598 | down_write(&c->xattr_sem); | 598 | down_write(&c->xattr_sem); |
@@ -829,7 +829,7 @@ void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) | |||
829 | ref->xd and ref->ic are not valid yet. */ | 829 | ref->xd and ref->ic are not valid yet. */ |
830 | xd = jffs2_find_xattr_datum(c, ref->xid); | 830 | xd = jffs2_find_xattr_datum(c, ref->xid); |
831 | ic = jffs2_get_ino_cache(c, ref->ino); | 831 | ic = jffs2_get_ino_cache(c, ref->ino); |
832 | if (!xd || !ic || !ic->nlink) { | 832 | if (!xd || !ic || !ic->pino_nlink) { |
833 | dbg_xattr("xref(ino=%u, xid=%u, xseqno=%u) is orphan.\n", | 833 | dbg_xattr("xref(ino=%u, xid=%u, xseqno=%u) is orphan.\n", |
834 | ref->ino, ref->xid, ref->xseqno); | 834 | ref->ino, ref->xid, ref->xseqno); |
835 | ref->xseqno |= XREF_DELETE_MARKER; | 835 | ref->xseqno |= XREF_DELETE_MARKER; |
diff --git a/fs/locks.c b/fs/locks.c index 44d9a6a7ec50..663c069b59b3 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -116,6 +116,7 @@ | |||
116 | 116 | ||
117 | #include <linux/capability.h> | 117 | #include <linux/capability.h> |
118 | #include <linux/file.h> | 118 | #include <linux/file.h> |
119 | #include <linux/fdtable.h> | ||
119 | #include <linux/fs.h> | 120 | #include <linux/fs.h> |
120 | #include <linux/init.h> | 121 | #include <linux/init.h> |
121 | #include <linux/module.h> | 122 | #include <linux/module.h> |
diff --git a/fs/ocfs2/cluster/sys.c b/fs/ocfs2/cluster/sys.c index 98429fd68499..bc702dab5d1f 100644 --- a/fs/ocfs2/cluster/sys.c +++ b/fs/ocfs2/cluster/sys.c | |||
@@ -65,7 +65,7 @@ int o2cb_sys_init(void) | |||
65 | { | 65 | { |
66 | int ret; | 66 | int ret; |
67 | 67 | ||
68 | o2cb_kset = kset_create_and_add("o2cb", NULL, NULL); | 68 | o2cb_kset = kset_create_and_add("o2cb", NULL, fs_kobj); |
69 | if (!o2cb_kset) | 69 | if (!o2cb_kset) |
70 | return -ENOMEM; | 70 | return -ENOMEM; |
71 | 71 | ||
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c index 5f6d858770a2..1b81dcba175d 100644 --- a/fs/ocfs2/dlm/dlmdebug.c +++ b/fs/ocfs2/dlm/dlmdebug.c | |||
@@ -44,7 +44,8 @@ | |||
44 | #define MLOG_MASK_PREFIX ML_DLM | 44 | #define MLOG_MASK_PREFIX ML_DLM |
45 | #include "cluster/masklog.h" | 45 | #include "cluster/masklog.h" |
46 | 46 | ||
47 | int stringify_lockname(const char *lockname, int locklen, char *buf, int len); | 47 | static int stringify_lockname(const char *lockname, int locklen, char *buf, |
48 | int len); | ||
48 | 49 | ||
49 | void dlm_print_one_lock_resource(struct dlm_lock_resource *res) | 50 | void dlm_print_one_lock_resource(struct dlm_lock_resource *res) |
50 | { | 51 | { |
@@ -251,7 +252,8 @@ EXPORT_SYMBOL_GPL(dlm_errname); | |||
251 | * | 252 | * |
252 | * For more on lockname formats, please refer to dlmglue.c and ocfs2_lockid.h. | 253 | * For more on lockname formats, please refer to dlmglue.c and ocfs2_lockid.h. |
253 | */ | 254 | */ |
254 | int stringify_lockname(const char *lockname, int locklen, char *buf, int len) | 255 | static int stringify_lockname(const char *lockname, int locklen, char *buf, |
256 | int len) | ||
255 | { | 257 | { |
256 | int out = 0; | 258 | int out = 0; |
257 | __be64 inode_blkno_be; | 259 | __be64 inode_blkno_be; |
@@ -368,7 +370,7 @@ static void dlm_debug_free(struct kref *kref) | |||
368 | kfree(dc); | 370 | kfree(dc); |
369 | } | 371 | } |
370 | 372 | ||
371 | void dlm_debug_put(struct dlm_debug_ctxt *dc) | 373 | static void dlm_debug_put(struct dlm_debug_ctxt *dc) |
372 | { | 374 | { |
373 | if (dc) | 375 | if (dc) |
374 | kref_put(&dc->debug_refcnt, dlm_debug_free); | 376 | kref_put(&dc->debug_refcnt, dlm_debug_free); |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 9154c82d3258..57e0d30cde98 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -1048,6 +1048,10 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
1048 | mlog_entry("(0x%p, '%.*s')\n", dentry, | 1048 | mlog_entry("(0x%p, '%.*s')\n", dentry, |
1049 | dentry->d_name.len, dentry->d_name.name); | 1049 | dentry->d_name.len, dentry->d_name.name); |
1050 | 1050 | ||
1051 | /* ensuring we don't even attempt to truncate a symlink */ | ||
1052 | if (S_ISLNK(inode->i_mode)) | ||
1053 | attr->ia_valid &= ~ATTR_SIZE; | ||
1054 | |||
1051 | if (attr->ia_valid & ATTR_MODE) | 1055 | if (attr->ia_valid & ATTR_MODE) |
1052 | mlog(0, "mode change: %d\n", attr->ia_mode); | 1056 | mlog(0, "mode change: %d\n", attr->ia_mode); |
1053 | if (attr->ia_valid & ATTR_UID) | 1057 | if (attr->ia_valid & ATTR_UID) |
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index ce0dc147602a..be774bdc8b36 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -260,7 +260,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | |||
260 | bh = osb->local_alloc_bh; | 260 | bh = osb->local_alloc_bh; |
261 | alloc = (struct ocfs2_dinode *) bh->b_data; | 261 | alloc = (struct ocfs2_dinode *) bh->b_data; |
262 | 262 | ||
263 | alloc_copy = kmalloc(bh->b_size, GFP_KERNEL); | 263 | alloc_copy = kmalloc(bh->b_size, GFP_NOFS); |
264 | if (!alloc_copy) { | 264 | if (!alloc_copy) { |
265 | status = -ENOMEM; | 265 | status = -ENOMEM; |
266 | goto out_commit; | 266 | goto out_commit; |
@@ -931,7 +931,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | |||
931 | * local alloc shutdown won't try to double free main bitmap | 931 | * local alloc shutdown won't try to double free main bitmap |
932 | * bits. Make a copy so the sync function knows which bits to | 932 | * bits. Make a copy so the sync function knows which bits to |
933 | * free. */ | 933 | * free. */ |
934 | alloc_copy = kmalloc(osb->local_alloc_bh->b_size, GFP_KERNEL); | 934 | alloc_copy = kmalloc(osb->local_alloc_bh->b_size, GFP_NOFS); |
935 | if (!alloc_copy) { | 935 | if (!alloc_copy) { |
936 | status = -ENOMEM; | 936 | status = -ENOMEM; |
937 | mlog_errno(status); | 937 | mlog_errno(status); |
diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c index ac1d74c63bf5..bbd1667aa7d3 100644 --- a/fs/ocfs2/stack_o2cb.c +++ b/fs/ocfs2/stack_o2cb.c | |||
@@ -385,7 +385,7 @@ static int o2cb_cluster_this_node(unsigned int *node) | |||
385 | return 0; | 385 | return 0; |
386 | } | 386 | } |
387 | 387 | ||
388 | struct ocfs2_stack_operations o2cb_stack_ops = { | 388 | static struct ocfs2_stack_operations o2cb_stack_ops = { |
389 | .connect = o2cb_cluster_connect, | 389 | .connect = o2cb_cluster_connect, |
390 | .disconnect = o2cb_cluster_disconnect, | 390 | .disconnect = o2cb_cluster_disconnect, |
391 | .hangup = o2cb_cluster_hangup, | 391 | .hangup = o2cb_cluster_hangup, |
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index 7428663f9cbb..b503772cd0ec 100644 --- a/fs/ocfs2/stack_user.c +++ b/fs/ocfs2/stack_user.c | |||
@@ -635,7 +635,7 @@ static const struct file_operations ocfs2_control_fops = { | |||
635 | .owner = THIS_MODULE, | 635 | .owner = THIS_MODULE, |
636 | }; | 636 | }; |
637 | 637 | ||
638 | struct miscdevice ocfs2_control_device = { | 638 | static struct miscdevice ocfs2_control_device = { |
639 | .minor = MISC_DYNAMIC_MINOR, | 639 | .minor = MISC_DYNAMIC_MINOR, |
640 | .name = "ocfs2_control", | 640 | .name = "ocfs2_control", |
641 | .fops = &ocfs2_control_fops, | 641 | .fops = &ocfs2_control_fops, |
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index 7134007ba22f..ba9dbb51d25b 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c | |||
@@ -167,9 +167,11 @@ const struct inode_operations ocfs2_symlink_inode_operations = { | |||
167 | .readlink = page_readlink, | 167 | .readlink = page_readlink, |
168 | .follow_link = ocfs2_follow_link, | 168 | .follow_link = ocfs2_follow_link, |
169 | .getattr = ocfs2_getattr, | 169 | .getattr = ocfs2_getattr, |
170 | .setattr = ocfs2_setattr, | ||
170 | }; | 171 | }; |
171 | const struct inode_operations ocfs2_fast_symlink_inode_operations = { | 172 | const struct inode_operations ocfs2_fast_symlink_inode_operations = { |
172 | .readlink = ocfs2_readlink, | 173 | .readlink = ocfs2_readlink, |
173 | .follow_link = ocfs2_follow_link, | 174 | .follow_link = ocfs2_follow_link, |
174 | .getattr = ocfs2_getattr, | 175 | .getattr = ocfs2_getattr, |
176 | .setattr = ocfs2_setattr, | ||
175 | }; | 177 | }; |
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/string.h> | 7 | #include <linux/string.h> |
8 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
9 | #include <linux/file.h> | 9 | #include <linux/file.h> |
10 | #include <linux/fdtable.h> | ||
10 | #include <linux/quotaops.h> | 11 | #include <linux/quotaops.h> |
11 | #include <linux/fsnotify.h> | 12 | #include <linux/fsnotify.h> |
12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
@@ -1076,6 +1076,23 @@ int do_pipe(int *fd) | |||
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | /* | 1078 | /* |
1079 | * sys_pipe() is the normal C calling standard for creating | ||
1080 | * a pipe. It's not the way Unix traditionally does this, though. | ||
1081 | */ | ||
1082 | asmlinkage long __weak sys_pipe(int __user *fildes) | ||
1083 | { | ||
1084 | int fd[2]; | ||
1085 | int error; | ||
1086 | |||
1087 | error = do_pipe(fd); | ||
1088 | if (!error) { | ||
1089 | if (copy_to_user(fildes, fd, sizeof(fd))) | ||
1090 | error = -EFAULT; | ||
1091 | } | ||
1092 | return error; | ||
1093 | } | ||
1094 | |||
1095 | /* | ||
1079 | * pipefs should _never_ be mounted by userland - too much of security hassle, | 1096 | * pipefs should _never_ be mounted by userland - too much of security hassle, |
1080 | * no real gain from having the whole whorehouse mounted. So we don't need | 1097 | * no real gain from having the whole whorehouse mounted. So we don't need |
1081 | * any operations on the root directory. However, we need a non-trivial | 1098 | * any operations on the root directory. However, we need a non-trivial |
diff --git a/fs/proc/array.c b/fs/proc/array.c index c135cbdd9127..dca997a93bff 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -73,6 +73,7 @@ | |||
73 | #include <linux/signal.h> | 73 | #include <linux/signal.h> |
74 | #include <linux/highmem.h> | 74 | #include <linux/highmem.h> |
75 | #include <linux/file.h> | 75 | #include <linux/file.h> |
76 | #include <linux/fdtable.h> | ||
76 | #include <linux/times.h> | 77 | #include <linux/times.h> |
77 | #include <linux/cpuset.h> | 78 | #include <linux/cpuset.h> |
78 | #include <linux/rcupdate.h> | 79 | #include <linux/rcupdate.h> |
diff --git a/fs/proc/base.c b/fs/proc/base.c index fcf02f2deeba..808cbdc193d3 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/init.h> | 56 | #include <linux/init.h> |
57 | #include <linux/capability.h> | 57 | #include <linux/capability.h> |
58 | #include <linux/file.h> | 58 | #include <linux/file.h> |
59 | #include <linux/fdtable.h> | ||
59 | #include <linux/string.h> | 60 | #include <linux/string.h> |
60 | #include <linux/seq_file.h> | 61 | #include <linux/seq_file.h> |
61 | #include <linux/namei.h> | 62 | #include <linux/namei.h> |
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index 4b733f108455..4b4f9cc2f186 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | #include <linux/mm.h> | 2 | #include <linux/mm.h> |
3 | #include <linux/file.h> | 3 | #include <linux/file.h> |
4 | #include <linux/fdtable.h> | ||
4 | #include <linux/mount.h> | 5 | #include <linux/mount.h> |
5 | #include <linux/ptrace.h> | 6 | #include <linux/ptrace.h> |
6 | #include <linux/seq_file.h> | 7 | #include <linux/seq_file.h> |
diff --git a/fs/select.c b/fs/select.c index 2c292146e246..8dda969614a9 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/poll.h> | 21 | #include <linux/poll.h> |
22 | #include <linux/personality.h> /* for STICKY_TIMEOUTS */ | 22 | #include <linux/personality.h> /* for STICKY_TIMEOUTS */ |
23 | #include <linux/file.h> | 23 | #include <linux/file.h> |
24 | #include <linux/fdtable.h> | ||
24 | #include <linux/fs.h> | 25 | #include <linux/fs.h> |
25 | #include <linux/rcupdate.h> | 26 | #include <linux/rcupdate.h> |
26 | 27 | ||
@@ -298,7 +299,7 @@ int do_select(int n, fd_set_bits *fds, s64 *timeout) | |||
298 | #define MAX_SELECT_SECONDS \ | 299 | #define MAX_SELECT_SECONDS \ |
299 | ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1) | 300 | ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1) |
300 | 301 | ||
301 | static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, | 302 | int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, |
302 | fd_set __user *exp, s64 *timeout) | 303 | fd_set __user *exp, s64 *timeout) |
303 | { | 304 | { |
304 | fd_set_bits fds; | 305 | fd_set_bits fds; |
diff --git a/fs/signalfd.c b/fs/signalfd.c index 8ead0db35933..619725644c75 100644 --- a/fs/signalfd.c +++ b/fs/signalfd.c | |||
@@ -207,11 +207,8 @@ static const struct file_operations signalfd_fops = { | |||
207 | 207 | ||
208 | asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemask) | 208 | asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemask) |
209 | { | 209 | { |
210 | int error; | ||
211 | sigset_t sigmask; | 210 | sigset_t sigmask; |
212 | struct signalfd_ctx *ctx; | 211 | struct signalfd_ctx *ctx; |
213 | struct file *file; | ||
214 | struct inode *inode; | ||
215 | 212 | ||
216 | if (sizemask != sizeof(sigset_t) || | 213 | if (sizemask != sizeof(sigset_t) || |
217 | copy_from_user(&sigmask, user_mask, sizeof(sigmask))) | 214 | copy_from_user(&sigmask, user_mask, sizeof(sigmask))) |
@@ -230,12 +227,11 @@ asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemas | |||
230 | * When we call this, the initialization must be complete, since | 227 | * When we call this, the initialization must be complete, since |
231 | * anon_inode_getfd() will install the fd. | 228 | * anon_inode_getfd() will install the fd. |
232 | */ | 229 | */ |
233 | error = anon_inode_getfd(&ufd, &inode, &file, "[signalfd]", | 230 | ufd = anon_inode_getfd("[signalfd]", &signalfd_fops, ctx); |
234 | &signalfd_fops, ctx); | 231 | if (ufd < 0) |
235 | if (error) | 232 | kfree(ctx); |
236 | goto err_fdalloc; | ||
237 | } else { | 233 | } else { |
238 | file = fget(ufd); | 234 | struct file *file = fget(ufd); |
239 | if (!file) | 235 | if (!file) |
240 | return -EBADF; | 236 | return -EBADF; |
241 | ctx = file->private_data; | 237 | ctx = file->private_data; |
@@ -252,9 +248,4 @@ asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemas | |||
252 | } | 248 | } |
253 | 249 | ||
254 | return ufd; | 250 | return ufd; |
255 | |||
256 | err_fdalloc: | ||
257 | kfree(ctx); | ||
258 | return error; | ||
259 | } | 251 | } |
260 | |||
diff --git a/fs/timerfd.c b/fs/timerfd.c index 5400524e9cb1..d87d354ec424 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c | |||
@@ -181,10 +181,8 @@ static struct file *timerfd_fget(int fd) | |||
181 | 181 | ||
182 | asmlinkage long sys_timerfd_create(int clockid, int flags) | 182 | asmlinkage long sys_timerfd_create(int clockid, int flags) |
183 | { | 183 | { |
184 | int error, ufd; | 184 | int ufd; |
185 | struct timerfd_ctx *ctx; | 185 | struct timerfd_ctx *ctx; |
186 | struct file *file; | ||
187 | struct inode *inode; | ||
188 | 186 | ||
189 | if (flags) | 187 | if (flags) |
190 | return -EINVAL; | 188 | return -EINVAL; |
@@ -200,12 +198,9 @@ asmlinkage long sys_timerfd_create(int clockid, int flags) | |||
200 | ctx->clockid = clockid; | 198 | ctx->clockid = clockid; |
201 | hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); | 199 | hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); |
202 | 200 | ||
203 | error = anon_inode_getfd(&ufd, &inode, &file, "[timerfd]", | 201 | ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx); |
204 | &timerfd_fops, ctx); | 202 | if (ufd < 0) |
205 | if (error) { | ||
206 | kfree(ctx); | 203 | kfree(ctx); |
207 | return error; | ||
208 | } | ||
209 | 204 | ||
210 | return ufd; | 205 | return ufd; |
211 | } | 206 | } |
diff --git a/fs/utimes.c b/fs/utimes.c index a2bef77dc9c9..af059d5cb485 100644 --- a/fs/utimes.c +++ b/fs/utimes.c | |||
@@ -40,9 +40,14 @@ asmlinkage long sys_utime(char __user *filename, struct utimbuf __user *times) | |||
40 | 40 | ||
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | static bool nsec_special(long nsec) | ||
44 | { | ||
45 | return nsec == UTIME_OMIT || nsec == UTIME_NOW; | ||
46 | } | ||
47 | |||
43 | static bool nsec_valid(long nsec) | 48 | static bool nsec_valid(long nsec) |
44 | { | 49 | { |
45 | if (nsec == UTIME_OMIT || nsec == UTIME_NOW) | 50 | if (nsec_special(nsec)) |
46 | return true; | 51 | return true; |
47 | 52 | ||
48 | return nsec >= 0 && nsec <= 999999999; | 53 | return nsec >= 0 && nsec <= 999999999; |
@@ -119,7 +124,15 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags | |||
119 | newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; | 124 | newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; |
120 | newattrs.ia_valid |= ATTR_MTIME_SET; | 125 | newattrs.ia_valid |= ATTR_MTIME_SET; |
121 | } | 126 | } |
122 | } else { | 127 | } |
128 | |||
129 | /* | ||
130 | * If times is NULL or both times are either UTIME_OMIT or | ||
131 | * UTIME_NOW, then need to check permissions, because | ||
132 | * inode_change_ok() won't do it. | ||
133 | */ | ||
134 | if (!times || (nsec_special(times[0].tv_nsec) && | ||
135 | nsec_special(times[1].tv_nsec))) { | ||
123 | error = -EACCES; | 136 | error = -EACCES; |
124 | if (IS_IMMUTABLE(inode)) | 137 | if (IS_IMMUTABLE(inode)) |
125 | goto mnt_drop_write_and_out; | 138 | goto mnt_drop_write_and_out; |
diff --git a/include/asm-alpha/types.h b/include/asm-alpha/types.h index f5716139ec89..c1541353ccef 100644 --- a/include/asm-alpha/types.h +++ b/include/asm-alpha/types.h | |||
@@ -8,28 +8,12 @@ | |||
8 | * not a major issue. However, for interoperability, libraries still | 8 | * not a major issue. However, for interoperability, libraries still |
9 | * need to be careful to avoid a name clashes. | 9 | * need to be careful to avoid a name clashes. |
10 | */ | 10 | */ |
11 | #include <asm-generic/int-l64.h> | ||
11 | 12 | ||
12 | #ifndef __ASSEMBLY__ | 13 | #ifndef __ASSEMBLY__ |
13 | 14 | ||
14 | typedef unsigned int umode_t; | 15 | typedef unsigned int umode_t; |
15 | 16 | ||
16 | /* | ||
17 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
18 | * header files exported to user space | ||
19 | */ | ||
20 | |||
21 | typedef __signed__ char __s8; | ||
22 | typedef unsigned char __u8; | ||
23 | |||
24 | typedef __signed__ short __s16; | ||
25 | typedef unsigned short __u16; | ||
26 | |||
27 | typedef __signed__ int __s32; | ||
28 | typedef unsigned int __u32; | ||
29 | |||
30 | typedef __signed__ long __s64; | ||
31 | typedef unsigned long __u64; | ||
32 | |||
33 | #endif /* __ASSEMBLY__ */ | 17 | #endif /* __ASSEMBLY__ */ |
34 | 18 | ||
35 | /* | 19 | /* |
@@ -41,18 +25,6 @@ typedef unsigned long __u64; | |||
41 | 25 | ||
42 | #ifndef __ASSEMBLY__ | 26 | #ifndef __ASSEMBLY__ |
43 | 27 | ||
44 | typedef signed char s8; | ||
45 | typedef unsigned char u8; | ||
46 | |||
47 | typedef signed short s16; | ||
48 | typedef unsigned short u16; | ||
49 | |||
50 | typedef signed int s32; | ||
51 | typedef unsigned int u32; | ||
52 | |||
53 | typedef signed long s64; | ||
54 | typedef unsigned long u64; | ||
55 | |||
56 | typedef u64 dma_addr_t; | 28 | typedef u64 dma_addr_t; |
57 | typedef u64 dma64_addr_t; | 29 | typedef u64 dma64_addr_t; |
58 | 30 | ||
diff --git a/include/asm-arm/div64.h b/include/asm-arm/div64.h index 0b5f881c3d85..5001390be958 100644 --- a/include/asm-arm/div64.h +++ b/include/asm-arm/div64.h | |||
@@ -224,6 +224,4 @@ | |||
224 | 224 | ||
225 | #endif | 225 | #endif |
226 | 226 | ||
227 | extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); | ||
228 | |||
229 | #endif | 227 | #endif |
diff --git a/include/asm-arm/types.h b/include/asm-arm/types.h index 3141451a9bd6..345df01534a4 100644 --- a/include/asm-arm/types.h +++ b/include/asm-arm/types.h | |||
@@ -1,29 +1,12 @@ | |||
1 | #ifndef __ASM_ARM_TYPES_H | 1 | #ifndef __ASM_ARM_TYPES_H |
2 | #define __ASM_ARM_TYPES_H | 2 | #define __ASM_ARM_TYPES_H |
3 | 3 | ||
4 | #include <asm-generic/int-ll64.h> | ||
5 | |||
4 | #ifndef __ASSEMBLY__ | 6 | #ifndef __ASSEMBLY__ |
5 | 7 | ||
6 | typedef unsigned short umode_t; | 8 | typedef unsigned short umode_t; |
7 | 9 | ||
8 | /* | ||
9 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
10 | * header files exported to user space | ||
11 | */ | ||
12 | |||
13 | typedef __signed__ char __s8; | ||
14 | typedef unsigned char __u8; | ||
15 | |||
16 | typedef __signed__ short __s16; | ||
17 | typedef unsigned short __u16; | ||
18 | |||
19 | typedef __signed__ int __s32; | ||
20 | typedef unsigned int __u32; | ||
21 | |||
22 | #if defined(__GNUC__) | ||
23 | __extension__ typedef __signed__ long long __s64; | ||
24 | __extension__ typedef unsigned long long __u64; | ||
25 | #endif | ||
26 | |||
27 | #endif /* __ASSEMBLY__ */ | 10 | #endif /* __ASSEMBLY__ */ |
28 | 11 | ||
29 | /* | 12 | /* |
@@ -35,18 +18,6 @@ __extension__ typedef unsigned long long __u64; | |||
35 | 18 | ||
36 | #ifndef __ASSEMBLY__ | 19 | #ifndef __ASSEMBLY__ |
37 | 20 | ||
38 | typedef signed char s8; | ||
39 | typedef unsigned char u8; | ||
40 | |||
41 | typedef signed short s16; | ||
42 | typedef unsigned short u16; | ||
43 | |||
44 | typedef signed int s32; | ||
45 | typedef unsigned int u32; | ||
46 | |||
47 | typedef signed long long s64; | ||
48 | typedef unsigned long long u64; | ||
49 | |||
50 | /* Dma addresses are 32-bits wide. */ | 21 | /* Dma addresses are 32-bits wide. */ |
51 | 22 | ||
52 | typedef u32 dma_addr_t; | 23 | typedef u32 dma_addr_t; |
diff --git a/include/asm-avr32/types.h b/include/asm-avr32/types.h index 8999a3819403..9cefda6f534a 100644 --- a/include/asm-avr32/types.h +++ b/include/asm-avr32/types.h | |||
@@ -8,28 +8,12 @@ | |||
8 | #ifndef __ASM_AVR32_TYPES_H | 8 | #ifndef __ASM_AVR32_TYPES_H |
9 | #define __ASM_AVR32_TYPES_H | 9 | #define __ASM_AVR32_TYPES_H |
10 | 10 | ||
11 | #include <asm-generic/int-ll64.h> | ||
12 | |||
11 | #ifndef __ASSEMBLY__ | 13 | #ifndef __ASSEMBLY__ |
12 | 14 | ||
13 | typedef unsigned short umode_t; | 15 | typedef unsigned short umode_t; |
14 | 16 | ||
15 | /* | ||
16 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
17 | * header files exported to user space | ||
18 | */ | ||
19 | typedef __signed__ char __s8; | ||
20 | typedef unsigned char __u8; | ||
21 | |||
22 | typedef __signed__ short __s16; | ||
23 | typedef unsigned short __u16; | ||
24 | |||
25 | typedef __signed__ int __s32; | ||
26 | typedef unsigned int __u32; | ||
27 | |||
28 | #if defined(__GNUC__) | ||
29 | __extension__ typedef __signed__ long long __s64; | ||
30 | __extension__ typedef unsigned long long __u64; | ||
31 | #endif | ||
32 | |||
33 | #endif /* __ASSEMBLY__ */ | 17 | #endif /* __ASSEMBLY__ */ |
34 | 18 | ||
35 | /* | 19 | /* |
@@ -41,18 +25,6 @@ __extension__ typedef unsigned long long __u64; | |||
41 | 25 | ||
42 | #ifndef __ASSEMBLY__ | 26 | #ifndef __ASSEMBLY__ |
43 | 27 | ||
44 | typedef signed char s8; | ||
45 | typedef unsigned char u8; | ||
46 | |||
47 | typedef signed short s16; | ||
48 | typedef unsigned short u16; | ||
49 | |||
50 | typedef signed int s32; | ||
51 | typedef unsigned int u32; | ||
52 | |||
53 | typedef signed long long s64; | ||
54 | typedef unsigned long long u64; | ||
55 | |||
56 | /* Dma addresses are 32-bits wide. */ | 28 | /* Dma addresses are 32-bits wide. */ |
57 | 29 | ||
58 | typedef u32 dma_addr_t; | 30 | typedef u32 dma_addr_t; |
diff --git a/include/asm-blackfin/types.h b/include/asm-blackfin/types.h index 9785a6d531c6..8441cbc2bf9e 100644 --- a/include/asm-blackfin/types.h +++ b/include/asm-blackfin/types.h | |||
@@ -8,30 +8,12 @@ | |||
8 | * not a major issue. However, for interoperability, libraries still | 8 | * not a major issue. However, for interoperability, libraries still |
9 | * need to be careful to avoid a name clashes. | 9 | * need to be careful to avoid a name clashes. |
10 | */ | 10 | */ |
11 | #include <asm-generic/int-ll64.h> | ||
12 | |||
11 | #ifndef __ASSEMBLY__ | 13 | #ifndef __ASSEMBLY__ |
12 | 14 | ||
13 | typedef unsigned short umode_t; | 15 | typedef unsigned short umode_t; |
14 | 16 | ||
15 | /* | ||
16 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
17 | * header files exported to user space | ||
18 | */ | ||
19 | |||
20 | typedef __signed__ char __s8; | ||
21 | typedef unsigned char __u8; | ||
22 | |||
23 | typedef __signed__ short __s16; | ||
24 | typedef unsigned short __u16; | ||
25 | |||
26 | typedef __signed__ int __s32; | ||
27 | typedef unsigned int __u32; | ||
28 | |||
29 | /* HK0617 -- Changes to unsigned long temporarily */ | ||
30 | #if defined(__GNUC__) | ||
31 | __extension__ typedef __signed__ long long __s64; | ||
32 | __extension__ typedef unsigned long long __u64; | ||
33 | #endif | ||
34 | |||
35 | #endif /* __ASSEMBLY__ */ | 17 | #endif /* __ASSEMBLY__ */ |
36 | /* | 18 | /* |
37 | * These aren't exported outside the kernel to avoid name space clashes | 19 | * These aren't exported outside the kernel to avoid name space clashes |
@@ -42,18 +24,6 @@ __extension__ typedef unsigned long long __u64; | |||
42 | 24 | ||
43 | #ifndef __ASSEMBLY__ | 25 | #ifndef __ASSEMBLY__ |
44 | 26 | ||
45 | typedef signed char s8; | ||
46 | typedef unsigned char u8; | ||
47 | |||
48 | typedef signed short s16; | ||
49 | typedef unsigned short u16; | ||
50 | |||
51 | typedef signed int s32; | ||
52 | typedef unsigned int u32; | ||
53 | |||
54 | typedef signed long long s64; | ||
55 | typedef unsigned long long u64; | ||
56 | |||
57 | /* Dma addresses are 32-bits wide. */ | 27 | /* Dma addresses are 32-bits wide. */ |
58 | 28 | ||
59 | typedef u32 dma_addr_t; | 29 | typedef u32 dma_addr_t; |
diff --git a/include/asm-cris/types.h b/include/asm-cris/types.h index 5a21c42bc6c5..5790262cbe8a 100644 --- a/include/asm-cris/types.h +++ b/include/asm-cris/types.h | |||
@@ -1,29 +1,12 @@ | |||
1 | #ifndef _ETRAX_TYPES_H | 1 | #ifndef _ETRAX_TYPES_H |
2 | #define _ETRAX_TYPES_H | 2 | #define _ETRAX_TYPES_H |
3 | 3 | ||
4 | #include <asm-generic/int-ll64.h> | ||
5 | |||
4 | #ifndef __ASSEMBLY__ | 6 | #ifndef __ASSEMBLY__ |
5 | 7 | ||
6 | typedef unsigned short umode_t; | 8 | typedef unsigned short umode_t; |
7 | 9 | ||
8 | /* | ||
9 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
10 | * header files exported to user space | ||
11 | */ | ||
12 | |||
13 | typedef __signed__ char __s8; | ||
14 | typedef unsigned char __u8; | ||
15 | |||
16 | typedef __signed__ short __s16; | ||
17 | typedef unsigned short __u16; | ||
18 | |||
19 | typedef __signed__ int __s32; | ||
20 | typedef unsigned int __u32; | ||
21 | |||
22 | #if defined(__GNUC__) | ||
23 | __extension__ typedef __signed__ long long __s64; | ||
24 | __extension__ typedef unsigned long long __u64; | ||
25 | #endif | ||
26 | |||
27 | #endif /* __ASSEMBLY__ */ | 10 | #endif /* __ASSEMBLY__ */ |
28 | 11 | ||
29 | /* | 12 | /* |
@@ -35,18 +18,6 @@ __extension__ typedef unsigned long long __u64; | |||
35 | 18 | ||
36 | #ifndef __ASSEMBLY__ | 19 | #ifndef __ASSEMBLY__ |
37 | 20 | ||
38 | typedef signed char s8; | ||
39 | typedef unsigned char u8; | ||
40 | |||
41 | typedef signed short s16; | ||
42 | typedef unsigned short u16; | ||
43 | |||
44 | typedef signed int s32; | ||
45 | typedef unsigned int u32; | ||
46 | |||
47 | typedef signed long long s64; | ||
48 | typedef unsigned long long u64; | ||
49 | |||
50 | /* Dma addresses are 32-bits wide, just like our other addresses. */ | 21 | /* Dma addresses are 32-bits wide, just like our other addresses. */ |
51 | 22 | ||
52 | typedef u32 dma_addr_t; | 23 | typedef u32 dma_addr_t; |
diff --git a/include/asm-frv/types.h b/include/asm-frv/types.h index 767e5ed71c4b..613bf1e962f0 100644 --- a/include/asm-frv/types.h +++ b/include/asm-frv/types.h | |||
@@ -12,29 +12,12 @@ | |||
12 | #ifndef _ASM_TYPES_H | 12 | #ifndef _ASM_TYPES_H |
13 | #define _ASM_TYPES_H | 13 | #define _ASM_TYPES_H |
14 | 14 | ||
15 | #include <asm-generic/int-ll64.h> | ||
16 | |||
15 | #ifndef __ASSEMBLY__ | 17 | #ifndef __ASSEMBLY__ |
16 | 18 | ||
17 | typedef unsigned short umode_t; | 19 | typedef unsigned short umode_t; |
18 | 20 | ||
19 | /* | ||
20 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
21 | * header files exported to user space | ||
22 | */ | ||
23 | |||
24 | typedef __signed__ char __s8; | ||
25 | typedef unsigned char __u8; | ||
26 | |||
27 | typedef __signed__ short __s16; | ||
28 | typedef unsigned short __u16; | ||
29 | |||
30 | typedef __signed__ int __s32; | ||
31 | typedef unsigned int __u32; | ||
32 | |||
33 | #if defined(__GNUC__) | ||
34 | __extension__ typedef __signed__ long long __s64; | ||
35 | __extension__ typedef unsigned long long __u64; | ||
36 | #endif | ||
37 | |||
38 | #endif /* __ASSEMBLY__ */ | 21 | #endif /* __ASSEMBLY__ */ |
39 | 22 | ||
40 | /* | 23 | /* |
@@ -46,19 +29,6 @@ __extension__ typedef unsigned long long __u64; | |||
46 | 29 | ||
47 | #ifndef __ASSEMBLY__ | 30 | #ifndef __ASSEMBLY__ |
48 | 31 | ||
49 | |||
50 | typedef signed char s8; | ||
51 | typedef unsigned char u8; | ||
52 | |||
53 | typedef signed short s16; | ||
54 | typedef unsigned short u16; | ||
55 | |||
56 | typedef signed int s32; | ||
57 | typedef unsigned int u32; | ||
58 | |||
59 | typedef signed long long s64; | ||
60 | typedef unsigned long long u64; | ||
61 | |||
62 | /* Dma addresses are 32-bits wide. */ | 32 | /* Dma addresses are 32-bits wide. */ |
63 | 33 | ||
64 | typedef u32 dma_addr_t; | 34 | typedef u32 dma_addr_t; |
diff --git a/include/asm-frv/unaligned.h b/include/asm-frv/unaligned.h index 64ccc736f2d8..839a2fbffa0f 100644 --- a/include/asm-frv/unaligned.h +++ b/include/asm-frv/unaligned.h | |||
@@ -9,8 +9,8 @@ | |||
9 | * 2 of the License, or (at your option) any later version. | 9 | * 2 of the License, or (at your option) any later version. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #ifndef _ASM_FRV_UNALIGNED_H | 12 | #ifndef _ASM_UNALIGNED_H |
13 | #define _ASM_FRV_UNALIGNED_H | 13 | #define _ASM_UNALIGNED_H |
14 | 14 | ||
15 | #include <linux/unaligned/le_byteshift.h> | 15 | #include <linux/unaligned/le_byteshift.h> |
16 | #include <linux/unaligned/be_byteshift.h> | 16 | #include <linux/unaligned/be_byteshift.h> |
@@ -19,4 +19,4 @@ | |||
19 | #define get_unaligned __get_unaligned_be | 19 | #define get_unaligned __get_unaligned_be |
20 | #define put_unaligned __put_unaligned_be | 20 | #define put_unaligned __put_unaligned_be |
21 | 21 | ||
22 | #endif /* _ASM_FRV_UNALIGNED_H */ | 22 | #endif /* _ASM_UNALIGNED_H */ |
diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild index c18110ee30f1..4c9932a2503f 100644 --- a/include/asm-generic/Kbuild +++ b/include/asm-generic/Kbuild | |||
@@ -7,5 +7,7 @@ header-y += poll.h | |||
7 | header-y += signal.h | 7 | header-y += signal.h |
8 | header-y += statfs.h | 8 | header-y += statfs.h |
9 | 9 | ||
10 | unifdef-y += int-l64.h | ||
11 | unifdef-y += int-ll64.h | ||
10 | unifdef-y += resource.h | 12 | unifdef-y += resource.h |
11 | unifdef-y += siginfo.h | 13 | unifdef-y += siginfo.h |
diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h index a4a49370793c..8f4e3193342e 100644 --- a/include/asm-generic/div64.h +++ b/include/asm-generic/div64.h | |||
@@ -30,11 +30,6 @@ | |||
30 | __rem; \ | 30 | __rem; \ |
31 | }) | 31 | }) |
32 | 32 | ||
33 | static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor) | ||
34 | { | ||
35 | return dividend / divisor; | ||
36 | } | ||
37 | |||
38 | #elif BITS_PER_LONG == 32 | 33 | #elif BITS_PER_LONG == 32 |
39 | 34 | ||
40 | extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); | 35 | extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); |
@@ -54,8 +49,6 @@ extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); | |||
54 | __rem; \ | 49 | __rem; \ |
55 | }) | 50 | }) |
56 | 51 | ||
57 | extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); | ||
58 | |||
59 | #else /* BITS_PER_LONG == ?? */ | 52 | #else /* BITS_PER_LONG == ?? */ |
60 | 53 | ||
61 | # error do_div() does not yet support the C64 | 54 | # error do_div() does not yet support the C64 |
diff --git a/include/asm-generic/int-l64.h b/include/asm-generic/int-l64.h new file mode 100644 index 000000000000..2af9b75d77db --- /dev/null +++ b/include/asm-generic/int-l64.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * asm-generic/int-l64.h | ||
3 | * | ||
4 | * Integer declarations for architectures which use "long" | ||
5 | * for 64-bit types. | ||
6 | */ | ||
7 | |||
8 | #ifndef _ASM_GENERIC_INT_L64_H | ||
9 | #define _ASM_GENERIC_INT_L64_H | ||
10 | |||
11 | #ifndef __ASSEMBLY__ | ||
12 | /* | ||
13 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
14 | * header files exported to user space | ||
15 | */ | ||
16 | |||
17 | typedef __signed__ char __s8; | ||
18 | typedef unsigned char __u8; | ||
19 | |||
20 | typedef __signed__ short __s16; | ||
21 | typedef unsigned short __u16; | ||
22 | |||
23 | typedef __signed__ int __s32; | ||
24 | typedef unsigned int __u32; | ||
25 | |||
26 | typedef __signed__ long __s64; | ||
27 | typedef unsigned long __u64; | ||
28 | |||
29 | #endif /* __ASSEMBLY__ */ | ||
30 | |||
31 | #ifdef __KERNEL__ | ||
32 | |||
33 | #ifndef __ASSEMBLY__ | ||
34 | |||
35 | typedef signed char s8; | ||
36 | typedef unsigned char u8; | ||
37 | |||
38 | typedef signed short s16; | ||
39 | typedef unsigned short u16; | ||
40 | |||
41 | typedef signed int s32; | ||
42 | typedef unsigned int u32; | ||
43 | |||
44 | typedef signed long s64; | ||
45 | typedef unsigned long u64; | ||
46 | |||
47 | #define S8_C(x) x | ||
48 | #define U8_C(x) x ## U | ||
49 | #define S16_C(x) x | ||
50 | #define U16_C(x) x ## U | ||
51 | #define S32_C(x) x | ||
52 | #define U32_C(x) x ## U | ||
53 | #define S64_C(x) x ## L | ||
54 | #define U64_C(x) x ## UL | ||
55 | |||
56 | #else /* __ASSEMBLY__ */ | ||
57 | |||
58 | #define S8_C(x) x | ||
59 | #define U8_C(x) x | ||
60 | #define S16_C(x) x | ||
61 | #define U16_C(x) x | ||
62 | #define S32_C(x) x | ||
63 | #define U32_C(x) x | ||
64 | #define S64_C(x) x | ||
65 | #define U64_C(x) x | ||
66 | |||
67 | #endif /* __ASSEMBLY__ */ | ||
68 | |||
69 | #endif /* __KERNEL__ */ | ||
70 | |||
71 | #endif /* _ASM_GENERIC_INT_L64_H */ | ||
diff --git a/include/asm-generic/int-ll64.h b/include/asm-generic/int-ll64.h new file mode 100644 index 000000000000..260948905e4e --- /dev/null +++ b/include/asm-generic/int-ll64.h | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * asm-generic/int-ll64.h | ||
3 | * | ||
4 | * Integer declarations for architectures which use "long long" | ||
5 | * for 64-bit types. | ||
6 | */ | ||
7 | |||
8 | #ifndef _ASM_GENERIC_INT_LL64_H | ||
9 | #define _ASM_GENERIC_INT_LL64_H | ||
10 | |||
11 | #ifndef __ASSEMBLY__ | ||
12 | /* | ||
13 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
14 | * header files exported to user space | ||
15 | */ | ||
16 | |||
17 | typedef __signed__ char __s8; | ||
18 | typedef unsigned char __u8; | ||
19 | |||
20 | typedef __signed__ short __s16; | ||
21 | typedef unsigned short __u16; | ||
22 | |||
23 | typedef __signed__ int __s32; | ||
24 | typedef unsigned int __u32; | ||
25 | |||
26 | #ifdef __GNUC__ | ||
27 | __extension__ typedef __signed__ long long __s64; | ||
28 | __extension__ typedef unsigned long long __u64; | ||
29 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | ||
30 | typedef __signed__ long long __s64; | ||
31 | typedef unsigned long long __u64; | ||
32 | #endif | ||
33 | |||
34 | #endif /* __ASSEMBLY__ */ | ||
35 | |||
36 | #ifdef __KERNEL__ | ||
37 | |||
38 | #ifndef __ASSEMBLY__ | ||
39 | |||
40 | typedef signed char s8; | ||
41 | typedef unsigned char u8; | ||
42 | |||
43 | typedef signed short s16; | ||
44 | typedef unsigned short u16; | ||
45 | |||
46 | typedef signed int s32; | ||
47 | typedef unsigned int u32; | ||
48 | |||
49 | typedef signed long long s64; | ||
50 | typedef unsigned long long u64; | ||
51 | |||
52 | #define S8_C(x) x | ||
53 | #define U8_C(x) x ## U | ||
54 | #define S16_C(x) x | ||
55 | #define U16_C(x) x ## U | ||
56 | #define S32_C(x) x | ||
57 | #define U32_C(x) x ## U | ||
58 | #define S64_C(x) x ## LL | ||
59 | #define U64_C(x) x ## ULL | ||
60 | |||
61 | #else /* __ASSEMBLY__ */ | ||
62 | |||
63 | #define S8_C(x) x | ||
64 | #define U8_C(x) x | ||
65 | #define S16_C(x) x | ||
66 | #define U16_C(x) x | ||
67 | #define S32_C(x) x | ||
68 | #define U32_C(x) x | ||
69 | #define S64_C(x) x | ||
70 | #define U64_C(x) x | ||
71 | |||
72 | #endif /* __ASSEMBLY__ */ | ||
73 | |||
74 | #endif /* __KERNEL__ */ | ||
75 | |||
76 | #endif /* _ASM_GENERIC_INT_LL64_H */ | ||
diff --git a/include/asm-h8300/types.h b/include/asm-h8300/types.h index 56566e2a09fd..12875190b156 100644 --- a/include/asm-h8300/types.h +++ b/include/asm-h8300/types.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef _H8300_TYPES_H | 1 | #ifndef _H8300_TYPES_H |
2 | #define _H8300_TYPES_H | 2 | #define _H8300_TYPES_H |
3 | 3 | ||
4 | #include <asm-generic/int-ll64.h> | ||
5 | |||
4 | #if !defined(__ASSEMBLY__) | 6 | #if !defined(__ASSEMBLY__) |
5 | 7 | ||
6 | /* | 8 | /* |
@@ -14,41 +16,10 @@ | |||
14 | typedef unsigned short umode_t; | 16 | typedef unsigned short umode_t; |
15 | 17 | ||
16 | /* | 18 | /* |
17 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
18 | * header files exported to user space | ||
19 | */ | ||
20 | |||
21 | typedef __signed__ char __s8; | ||
22 | typedef unsigned char __u8; | ||
23 | |||
24 | typedef __signed__ short __s16; | ||
25 | typedef unsigned short __u16; | ||
26 | |||
27 | typedef __signed__ int __s32; | ||
28 | typedef unsigned int __u32; | ||
29 | |||
30 | #if defined(__GNUC__) | ||
31 | __extension__ typedef __signed__ long long __s64; | ||
32 | __extension__ typedef unsigned long long __u64; | ||
33 | #endif | ||
34 | |||
35 | /* | ||
36 | * These aren't exported outside the kernel to avoid name space clashes | 19 | * These aren't exported outside the kernel to avoid name space clashes |
37 | */ | 20 | */ |
38 | #ifdef __KERNEL__ | 21 | #ifdef __KERNEL__ |
39 | 22 | ||
40 | typedef signed char s8; | ||
41 | typedef unsigned char u8; | ||
42 | |||
43 | typedef signed short s16; | ||
44 | typedef unsigned short u16; | ||
45 | |||
46 | typedef signed int s32; | ||
47 | typedef unsigned int u32; | ||
48 | |||
49 | typedef signed long long s64; | ||
50 | typedef unsigned long long u64; | ||
51 | |||
52 | #define BITS_PER_LONG 32 | 23 | #define BITS_PER_LONG 32 |
53 | 24 | ||
54 | /* Dma addresses are 32-bits wide. */ | 25 | /* Dma addresses are 32-bits wide. */ |
diff --git a/include/asm-ia64/cpu.h b/include/asm-ia64/cpu.h index e87fa3210a2b..fcca30b9f110 100644 --- a/include/asm-ia64/cpu.h +++ b/include/asm-ia64/cpu.h | |||
@@ -14,8 +14,8 @@ DECLARE_PER_CPU(struct ia64_cpu, cpu_devices); | |||
14 | 14 | ||
15 | DECLARE_PER_CPU(int, cpu_state); | 15 | DECLARE_PER_CPU(int, cpu_state); |
16 | 16 | ||
17 | extern int arch_register_cpu(int num); | ||
18 | #ifdef CONFIG_HOTPLUG_CPU | 17 | #ifdef CONFIG_HOTPLUG_CPU |
18 | extern int arch_register_cpu(int num); | ||
19 | extern void arch_unregister_cpu(int); | 19 | extern void arch_unregister_cpu(int); |
20 | #endif | 20 | #endif |
21 | 21 | ||
diff --git a/include/asm-ia64/dmi.h b/include/asm-ia64/dmi.h index f3efaa229525..00eb1b130b63 100644 --- a/include/asm-ia64/dmi.h +++ b/include/asm-ia64/dmi.h | |||
@@ -3,4 +3,9 @@ | |||
3 | 3 | ||
4 | #include <asm/io.h> | 4 | #include <asm/io.h> |
5 | 5 | ||
6 | /* Use normal IO mappings for DMI */ | ||
7 | #define dmi_ioremap ioremap | ||
8 | #define dmi_iounmap(x,l) iounmap(x) | ||
9 | #define dmi_alloc(l) kmalloc(l, GFP_ATOMIC) | ||
10 | |||
6 | #endif | 11 | #endif |
diff --git a/include/asm-ia64/io.h b/include/asm-ia64/io.h index 4ebed77aa472..260a85ac9d6a 100644 --- a/include/asm-ia64/io.h +++ b/include/asm-ia64/io.h | |||
@@ -423,11 +423,6 @@ extern void __iomem * ioremap(unsigned long offset, unsigned long size); | |||
423 | extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); | 423 | extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); |
424 | extern void iounmap (volatile void __iomem *addr); | 424 | extern void iounmap (volatile void __iomem *addr); |
425 | 425 | ||
426 | /* Use normal IO mappings for DMI */ | ||
427 | #define dmi_ioremap ioremap | ||
428 | #define dmi_iounmap(x,l) iounmap(x) | ||
429 | #define dmi_alloc(l) kmalloc(l, GFP_ATOMIC) | ||
430 | |||
431 | /* | 426 | /* |
432 | * String version of IO memory access ops: | 427 | * String version of IO memory access ops: |
433 | */ | 428 | */ |
diff --git a/include/asm-ia64/thread_info.h b/include/asm-ia64/thread_info.h index f30e05583869..2422ac61658a 100644 --- a/include/asm-ia64/thread_info.h +++ b/include/asm-ia64/thread_info.h | |||
@@ -108,13 +108,11 @@ extern void tsk_clear_notify_resume(struct task_struct *tsk); | |||
108 | #define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */ | 108 | #define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */ |
109 | #define TIF_FREEZE 20 /* is freezing for suspend */ | 109 | #define TIF_FREEZE 20 /* is freezing for suspend */ |
110 | #define TIF_RESTORE_RSE 21 /* user RBS is newer than kernel RBS */ | 110 | #define TIF_RESTORE_RSE 21 /* user RBS is newer than kernel RBS */ |
111 | #define TIF_RESTORE_SIGMASK 22 /* restore signal mask in do_signal() */ | ||
112 | 111 | ||
113 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) | 112 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) |
114 | #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) | 113 | #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) |
115 | #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) | 114 | #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) |
116 | #define _TIF_SYSCALL_TRACEAUDIT (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP) | 115 | #define _TIF_SYSCALL_TRACEAUDIT (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP) |
117 | #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) | ||
118 | #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) | 116 | #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) |
119 | #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) | 117 | #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) |
120 | #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) | 118 | #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) |
@@ -131,7 +129,18 @@ extern void tsk_clear_notify_resume(struct task_struct *tsk); | |||
131 | #define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)) | 129 | #define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)) |
132 | 130 | ||
133 | #define TS_POLLING 1 /* true if in idle loop and not sleeping */ | 131 | #define TS_POLLING 1 /* true if in idle loop and not sleeping */ |
132 | #define TS_RESTORE_SIGMASK 2 /* restore signal mask in do_signal() */ | ||
134 | 133 | ||
135 | #define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING) | 134 | #define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING) |
136 | 135 | ||
136 | #ifndef __ASSEMBLY__ | ||
137 | #define HAVE_SET_RESTORE_SIGMASK 1 | ||
138 | static inline void set_restore_sigmask(void) | ||
139 | { | ||
140 | struct thread_info *ti = current_thread_info(); | ||
141 | ti->status |= TS_RESTORE_SIGMASK; | ||
142 | set_bit(TIF_SIGPENDING, &ti->flags); | ||
143 | } | ||
144 | #endif /* !__ASSEMBLY__ */ | ||
145 | |||
137 | #endif /* _ASM_IA64_THREAD_INFO_H */ | 146 | #endif /* _ASM_IA64_THREAD_INFO_H */ |
diff --git a/include/asm-ia64/types.h b/include/asm-ia64/types.h index 902850d12424..e36b3716e718 100644 --- a/include/asm-ia64/types.h +++ b/include/asm-ia64/types.h | |||
@@ -13,6 +13,8 @@ | |||
13 | * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co | 13 | * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <asm-generic/int-l64.h> | ||
17 | |||
16 | #ifdef __ASSEMBLY__ | 18 | #ifdef __ASSEMBLY__ |
17 | # define __IA64_UL(x) (x) | 19 | # define __IA64_UL(x) (x) |
18 | # define __IA64_UL_CONST(x) x | 20 | # define __IA64_UL_CONST(x) x |
@@ -28,39 +30,10 @@ | |||
28 | typedef unsigned int umode_t; | 30 | typedef unsigned int umode_t; |
29 | 31 | ||
30 | /* | 32 | /* |
31 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
32 | * header files exported to user space | ||
33 | */ | ||
34 | |||
35 | typedef __signed__ char __s8; | ||
36 | typedef unsigned char __u8; | ||
37 | |||
38 | typedef __signed__ short __s16; | ||
39 | typedef unsigned short __u16; | ||
40 | |||
41 | typedef __signed__ int __s32; | ||
42 | typedef unsigned int __u32; | ||
43 | |||
44 | typedef __signed__ long __s64; | ||
45 | typedef unsigned long __u64; | ||
46 | |||
47 | /* | ||
48 | * These aren't exported outside the kernel to avoid name space clashes | 33 | * These aren't exported outside the kernel to avoid name space clashes |
49 | */ | 34 | */ |
50 | # ifdef __KERNEL__ | 35 | # ifdef __KERNEL__ |
51 | 36 | ||
52 | typedef __s8 s8; | ||
53 | typedef __u8 u8; | ||
54 | |||
55 | typedef __s16 s16; | ||
56 | typedef __u16 u16; | ||
57 | |||
58 | typedef __s32 s32; | ||
59 | typedef __u32 u32; | ||
60 | |||
61 | typedef __s64 s64; | ||
62 | typedef __u64 u64; | ||
63 | |||
64 | #define BITS_PER_LONG 64 | 37 | #define BITS_PER_LONG 64 |
65 | 38 | ||
66 | /* DMA addresses are 64-bits wide, in general. */ | 39 | /* DMA addresses are 64-bits wide, in general. */ |
diff --git a/include/asm-m32r/types.h b/include/asm-m32r/types.h index b64c16639a7b..bc9f7fff0ac3 100644 --- a/include/asm-m32r/types.h +++ b/include/asm-m32r/types.h | |||
@@ -1,28 +1,12 @@ | |||
1 | #ifndef _ASM_M32R_TYPES_H | 1 | #ifndef _ASM_M32R_TYPES_H |
2 | #define _ASM_M32R_TYPES_H | 2 | #define _ASM_M32R_TYPES_H |
3 | 3 | ||
4 | #include <asm-generic/int-ll64.h> | ||
5 | |||
4 | #ifndef __ASSEMBLY__ | 6 | #ifndef __ASSEMBLY__ |
5 | 7 | ||
6 | typedef unsigned short umode_t; | 8 | typedef unsigned short umode_t; |
7 | 9 | ||
8 | /* | ||
9 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
10 | * header files exported to user space | ||
11 | */ | ||
12 | |||
13 | typedef __signed__ char __s8; | ||
14 | typedef unsigned char __u8; | ||
15 | |||
16 | typedef __signed__ short __s16; | ||
17 | typedef unsigned short __u16; | ||
18 | |||
19 | typedef __signed__ int __s32; | ||
20 | typedef unsigned int __u32; | ||
21 | |||
22 | #if defined(__GNUC__) | ||
23 | __extension__ typedef __signed__ long long __s64; | ||
24 | __extension__ typedef unsigned long long __u64; | ||
25 | #endif | ||
26 | #endif /* __ASSEMBLY__ */ | 10 | #endif /* __ASSEMBLY__ */ |
27 | 11 | ||
28 | /* | 12 | /* |
@@ -34,18 +18,6 @@ __extension__ typedef unsigned long long __u64; | |||
34 | 18 | ||
35 | #ifndef __ASSEMBLY__ | 19 | #ifndef __ASSEMBLY__ |
36 | 20 | ||
37 | typedef signed char s8; | ||
38 | typedef unsigned char u8; | ||
39 | |||
40 | typedef signed short s16; | ||
41 | typedef unsigned short u16; | ||
42 | |||
43 | typedef signed int s32; | ||
44 | typedef unsigned int u32; | ||
45 | |||
46 | typedef signed long long s64; | ||
47 | typedef unsigned long long u64; | ||
48 | |||
49 | /* DMA addresses are 32-bits wide. */ | 21 | /* DMA addresses are 32-bits wide. */ |
50 | 22 | ||
51 | typedef u32 dma_addr_t; | 23 | typedef u32 dma_addr_t; |
diff --git a/include/asm-m68k/div64.h b/include/asm-m68k/div64.h index 33caad1628d4..8243c931b5c0 100644 --- a/include/asm-m68k/div64.h +++ b/include/asm-m68k/div64.h | |||
@@ -25,5 +25,4 @@ | |||
25 | __rem; \ | 25 | __rem; \ |
26 | }) | 26 | }) |
27 | 27 | ||
28 | extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); | ||
29 | #endif /* _M68K_DIV64_H */ | 28 | #endif /* _M68K_DIV64_H */ |
diff --git a/include/asm-m68k/machw.h b/include/asm-m68k/machw.h index d2e0e25d5c90..35624998291c 100644 --- a/include/asm-m68k/machw.h +++ b/include/asm-m68k/machw.h | |||
@@ -66,36 +66,6 @@ struct MAC_SCC | |||
66 | # define mac_scc ((*(volatile struct SCC*)MAC_SCC_BAS)) | 66 | # define mac_scc ((*(volatile struct SCC*)MAC_SCC_BAS)) |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | /* hardware stuff */ | ||
70 | |||
71 | #define MACHW_DECLARE(name) unsigned name : 1 | ||
72 | #define MACHW_SET(name) (mac_hw_present.name = 1) | ||
73 | #define MACHW_PRESENT(name) (mac_hw_present.name) | ||
74 | |||
75 | struct mac_hw_present { | ||
76 | /* video hardware */ | ||
77 | /* sound hardware */ | ||
78 | /* disk storage interfaces */ | ||
79 | MACHW_DECLARE(MAC_SCSI_80); /* Directly mapped NCR5380 */ | ||
80 | MACHW_DECLARE(MAC_SCSI_96); /* 53c9[46] */ | ||
81 | MACHW_DECLARE(MAC_SCSI_96_2); /* 2nd 53c9[46] Q900 and Q950 */ | ||
82 | MACHW_DECLARE(IDE); /* IDE Interface */ | ||
83 | /* other I/O hardware */ | ||
84 | MACHW_DECLARE(SCC); /* Serial Communications Contr. */ | ||
85 | /* DMA */ | ||
86 | MACHW_DECLARE(SCSI_DMA); /* DMA for the NCR5380 */ | ||
87 | /* real time clocks */ | ||
88 | MACHW_DECLARE(RTC_CLK); /* clock chip */ | ||
89 | /* supporting hardware */ | ||
90 | MACHW_DECLARE(VIA1); /* Versatile Interface Ad. 1 */ | ||
91 | MACHW_DECLARE(VIA2); /* Versatile Interface Ad. 2 */ | ||
92 | MACHW_DECLARE(RBV); /* Versatile Interface Ad. 2+ */ | ||
93 | /* NUBUS */ | ||
94 | MACHW_DECLARE(NUBUS); /* NUBUS */ | ||
95 | }; | ||
96 | |||
97 | extern struct mac_hw_present mac_hw_present; | ||
98 | |||
99 | #endif /* __ASSEMBLY__ */ | 69 | #endif /* __ASSEMBLY__ */ |
100 | 70 | ||
101 | #endif /* linux/machw.h */ | 71 | #endif /* linux/machw.h */ |
diff --git a/include/asm-m68k/types.h b/include/asm-m68k/types.h index c35c09d93b66..6441cb5f8e7c 100644 --- a/include/asm-m68k/types.h +++ b/include/asm-m68k/types.h | |||
@@ -8,30 +8,12 @@ | |||
8 | * not a major issue. However, for interoperability, libraries still | 8 | * not a major issue. However, for interoperability, libraries still |
9 | * need to be careful to avoid a name clashes. | 9 | * need to be careful to avoid a name clashes. |
10 | */ | 10 | */ |
11 | #include <asm-generic/int-ll64.h> | ||
11 | 12 | ||
12 | #ifndef __ASSEMBLY__ | 13 | #ifndef __ASSEMBLY__ |
13 | 14 | ||
14 | typedef unsigned short umode_t; | 15 | typedef unsigned short umode_t; |
15 | 16 | ||
16 | /* | ||
17 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
18 | * header files exported to user space | ||
19 | */ | ||
20 | |||
21 | typedef __signed__ char __s8; | ||
22 | typedef unsigned char __u8; | ||
23 | |||
24 | typedef __signed__ short __s16; | ||
25 | typedef unsigned short __u16; | ||
26 | |||
27 | typedef __signed__ int __s32; | ||
28 | typedef unsigned int __u32; | ||
29 | |||
30 | #if defined(__GNUC__) | ||
31 | __extension__ typedef __signed__ long long __s64; | ||
32 | __extension__ typedef unsigned long long __u64; | ||
33 | #endif | ||
34 | |||
35 | #endif /* __ASSEMBLY__ */ | 17 | #endif /* __ASSEMBLY__ */ |
36 | 18 | ||
37 | /* | 19 | /* |
@@ -43,18 +25,6 @@ __extension__ typedef unsigned long long __u64; | |||
43 | 25 | ||
44 | #ifndef __ASSEMBLY__ | 26 | #ifndef __ASSEMBLY__ |
45 | 27 | ||
46 | typedef signed char s8; | ||
47 | typedef unsigned char u8; | ||
48 | |||
49 | typedef signed short s16; | ||
50 | typedef unsigned short u16; | ||
51 | |||
52 | typedef signed int s32; | ||
53 | typedef unsigned int u32; | ||
54 | |||
55 | typedef signed long long s64; | ||
56 | typedef unsigned long long u64; | ||
57 | |||
58 | /* DMA addresses are always 32-bits wide */ | 28 | /* DMA addresses are always 32-bits wide */ |
59 | 29 | ||
60 | typedef u32 dma_addr_t; | 30 | typedef u32 dma_addr_t; |
diff --git a/include/asm-m68knommu/dma.h b/include/asm-m68knommu/dma.h index 3f20419c633a..939a02056217 100644 --- a/include/asm-m68knommu/dma.h +++ b/include/asm-m68knommu/dma.h | |||
@@ -35,7 +35,8 @@ | |||
35 | /* | 35 | /* |
36 | * Set number of channels of DMA on ColdFire for different implementations. | 36 | * Set number of channels of DMA on ColdFire for different implementations. |
37 | */ | 37 | */ |
38 | #if defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) | 38 | #if defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) || \ |
39 | defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) | ||
39 | #define MAX_M68K_DMA_CHANNELS 4 | 40 | #define MAX_M68K_DMA_CHANNELS 4 |
40 | #elif defined(CONFIG_M5272) | 41 | #elif defined(CONFIG_M5272) |
41 | #define MAX_M68K_DMA_CHANNELS 1 | 42 | #define MAX_M68K_DMA_CHANNELS 1 |
diff --git a/include/asm-m68knommu/param.h b/include/asm-m68knommu/param.h index 96c451018324..6044397adb64 100644 --- a/include/asm-m68knommu/param.h +++ b/include/asm-m68knommu/param.h | |||
@@ -1,13 +1,16 @@ | |||
1 | #ifndef _M68KNOMMU_PARAM_H | 1 | #ifndef _M68KNOMMU_PARAM_H |
2 | #define _M68KNOMMU_PARAM_H | 2 | #define _M68KNOMMU_PARAM_H |
3 | 3 | ||
4 | #define HZ CONFIG_HZ | ||
5 | |||
6 | #ifdef __KERNEL__ | 4 | #ifdef __KERNEL__ |
5 | #define HZ CONFIG_HZ | ||
7 | #define USER_HZ HZ | 6 | #define USER_HZ HZ |
8 | #define CLOCKS_PER_SEC (USER_HZ) | 7 | #define CLOCKS_PER_SEC (USER_HZ) |
9 | #endif | 8 | #endif |
10 | 9 | ||
10 | #ifndef HZ | ||
11 | #define HZ 100 | ||
12 | #endif | ||
13 | |||
11 | #define EXEC_PAGESIZE 4096 | 14 | #define EXEC_PAGESIZE 4096 |
12 | 15 | ||
13 | #ifndef NOGROUP | 16 | #ifndef NOGROUP |
diff --git a/include/asm-mips/div64.h b/include/asm-mips/div64.h index 716371bd0980..d1d699105c11 100644 --- a/include/asm-mips/div64.h +++ b/include/asm-mips/div64.h | |||
@@ -82,7 +82,6 @@ | |||
82 | (n) = __quot; \ | 82 | (n) = __quot; \ |
83 | __mod; }) | 83 | __mod; }) |
84 | 84 | ||
85 | extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); | ||
86 | #endif /* (_MIPS_SZLONG == 32) */ | 85 | #endif /* (_MIPS_SZLONG == 32) */ |
87 | 86 | ||
88 | #if (_MIPS_SZLONG == 64) | 87 | #if (_MIPS_SZLONG == 64) |
@@ -106,11 +105,6 @@ extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); | |||
106 | (n) = __quot; \ | 105 | (n) = __quot; \ |
107 | __mod; }) | 106 | __mod; }) |
108 | 107 | ||
109 | static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor) | ||
110 | { | ||
111 | return dividend / divisor; | ||
112 | } | ||
113 | |||
114 | #endif /* (_MIPS_SZLONG == 64) */ | 108 | #endif /* (_MIPS_SZLONG == 64) */ |
115 | 109 | ||
116 | #endif /* _ASM_DIV64_H */ | 110 | #endif /* _ASM_DIV64_H */ |
diff --git a/include/asm-mips/types.h b/include/asm-mips/types.h index 2dd147f519d1..bcbb8d675af5 100644 --- a/include/asm-mips/types.h +++ b/include/asm-mips/types.h | |||
@@ -9,37 +9,15 @@ | |||
9 | #ifndef _ASM_TYPES_H | 9 | #ifndef _ASM_TYPES_H |
10 | #define _ASM_TYPES_H | 10 | #define _ASM_TYPES_H |
11 | 11 | ||
12 | #ifndef __ASSEMBLY__ | 12 | #if _MIPS_SZLONG == 64 |
13 | 13 | # include <asm-generic/int-l64.h> | |
14 | typedef unsigned short umode_t; | ||
15 | |||
16 | /* | ||
17 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
18 | * header files exported to user space | ||
19 | */ | ||
20 | |||
21 | typedef __signed__ char __s8; | ||
22 | typedef unsigned char __u8; | ||
23 | |||
24 | typedef __signed__ short __s16; | ||
25 | typedef unsigned short __u16; | ||
26 | |||
27 | typedef __signed__ int __s32; | ||
28 | typedef unsigned int __u32; | ||
29 | |||
30 | #if (_MIPS_SZLONG == 64) | ||
31 | |||
32 | typedef __signed__ long __s64; | ||
33 | typedef unsigned long __u64; | ||
34 | |||
35 | #else | 14 | #else |
36 | 15 | # include <asm-generic/int-ll64.h> | |
37 | #if defined(__GNUC__) | ||
38 | __extension__ typedef __signed__ long long __s64; | ||
39 | __extension__ typedef unsigned long long __u64; | ||
40 | #endif | 16 | #endif |
41 | 17 | ||
42 | #endif | 18 | #ifndef __ASSEMBLY__ |
19 | |||
20 | typedef unsigned short umode_t; | ||
43 | 21 | ||
44 | #endif /* __ASSEMBLY__ */ | 22 | #endif /* __ASSEMBLY__ */ |
45 | 23 | ||
@@ -52,30 +30,6 @@ __extension__ typedef unsigned long long __u64; | |||
52 | 30 | ||
53 | #ifndef __ASSEMBLY__ | 31 | #ifndef __ASSEMBLY__ |
54 | 32 | ||
55 | |||
56 | typedef __signed char s8; | ||
57 | typedef unsigned char u8; | ||
58 | |||
59 | typedef __signed short s16; | ||
60 | typedef unsigned short u16; | ||
61 | |||
62 | typedef __signed int s32; | ||
63 | typedef unsigned int u32; | ||
64 | |||
65 | #if (_MIPS_SZLONG == 64) | ||
66 | |||
67 | typedef __signed__ long s64; | ||
68 | typedef unsigned long u64; | ||
69 | |||
70 | #else | ||
71 | |||
72 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) | ||
73 | typedef __signed__ long long s64; | ||
74 | typedef unsigned long long u64; | ||
75 | #endif | ||
76 | |||
77 | #endif | ||
78 | |||
79 | #if (defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) \ | 33 | #if (defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) \ |
80 | || defined(CONFIG_64BIT) | 34 | || defined(CONFIG_64BIT) |
81 | typedef u64 dma_addr_t; | 35 | typedef u64 dma_addr_t; |
diff --git a/include/asm-mn10300/div64.h b/include/asm-mn10300/div64.h index bf9c515a998c..3a8329b3e869 100644 --- a/include/asm-mn10300/div64.h +++ b/include/asm-mn10300/div64.h | |||
@@ -97,7 +97,4 @@ signed __muldiv64s(signed val, signed mult, signed div) | |||
97 | return result; | 97 | return result; |
98 | } | 98 | } |
99 | 99 | ||
100 | extern __attribute__((const)) | ||
101 | uint64_t div64_64(uint64_t dividend, uint64_t divisor); | ||
102 | |||
103 | #endif /* _ASM_DIV64 */ | 100 | #endif /* _ASM_DIV64 */ |
diff --git a/include/asm-mn10300/types.h b/include/asm-mn10300/types.h index d40ea7628bfc..7b9f01042fd4 100644 --- a/include/asm-mn10300/types.h +++ b/include/asm-mn10300/types.h | |||
@@ -11,29 +11,12 @@ | |||
11 | #ifndef _ASM_TYPES_H | 11 | #ifndef _ASM_TYPES_H |
12 | #define _ASM_TYPES_H | 12 | #define _ASM_TYPES_H |
13 | 13 | ||
14 | #include <asm-generic/int-ll64.h> | ||
15 | |||
14 | #ifndef __ASSEMBLY__ | 16 | #ifndef __ASSEMBLY__ |
15 | 17 | ||
16 | typedef unsigned short umode_t; | 18 | typedef unsigned short umode_t; |
17 | 19 | ||
18 | /* | ||
19 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
20 | * header files exported to user space | ||
21 | */ | ||
22 | |||
23 | typedef __signed__ char __s8; | ||
24 | typedef unsigned char __u8; | ||
25 | |||
26 | typedef __signed__ short __s16; | ||
27 | typedef unsigned short __u16; | ||
28 | |||
29 | typedef __signed__ int __s32; | ||
30 | typedef unsigned int __u32; | ||
31 | |||
32 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) | ||
33 | typedef __signed__ long long __s64; | ||
34 | typedef unsigned long long __u64; | ||
35 | #endif | ||
36 | |||
37 | #endif /* __ASSEMBLY__ */ | 20 | #endif /* __ASSEMBLY__ */ |
38 | 21 | ||
39 | /* | 22 | /* |
@@ -45,18 +28,6 @@ typedef unsigned long long __u64; | |||
45 | 28 | ||
46 | #ifndef __ASSEMBLY__ | 29 | #ifndef __ASSEMBLY__ |
47 | 30 | ||
48 | typedef signed char s8; | ||
49 | typedef unsigned char u8; | ||
50 | |||
51 | typedef signed short s16; | ||
52 | typedef unsigned short u16; | ||
53 | |||
54 | typedef signed int s32; | ||
55 | typedef unsigned int u32; | ||
56 | |||
57 | typedef signed long long s64; | ||
58 | typedef unsigned long long u64; | ||
59 | |||
60 | /* Dma addresses are 32-bits wide. */ | 31 | /* Dma addresses are 32-bits wide. */ |
61 | typedef u32 dma_addr_t; | 32 | typedef u32 dma_addr_t; |
62 | 33 | ||
diff --git a/include/asm-parisc/types.h b/include/asm-parisc/types.h index 56c84802da59..7f5a39bfb4ce 100644 --- a/include/asm-parisc/types.h +++ b/include/asm-parisc/types.h | |||
@@ -1,29 +1,12 @@ | |||
1 | #ifndef _PARISC_TYPES_H | 1 | #ifndef _PARISC_TYPES_H |
2 | #define _PARISC_TYPES_H | 2 | #define _PARISC_TYPES_H |
3 | 3 | ||
4 | #include <asm-generic/int-ll64.h> | ||
5 | |||
4 | #ifndef __ASSEMBLY__ | 6 | #ifndef __ASSEMBLY__ |
5 | 7 | ||
6 | typedef unsigned short umode_t; | 8 | typedef unsigned short umode_t; |
7 | 9 | ||
8 | /* | ||
9 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
10 | * header files exported to user space | ||
11 | */ | ||
12 | |||
13 | typedef __signed__ char __s8; | ||
14 | typedef unsigned char __u8; | ||
15 | |||
16 | typedef __signed__ short __s16; | ||
17 | typedef unsigned short __u16; | ||
18 | |||
19 | typedef __signed__ int __s32; | ||
20 | typedef unsigned int __u32; | ||
21 | |||
22 | #if defined(__GNUC__) | ||
23 | __extension__ typedef __signed__ long long __s64; | ||
24 | __extension__ typedef unsigned long long __u64; | ||
25 | #endif | ||
26 | |||
27 | #endif /* __ASSEMBLY__ */ | 10 | #endif /* __ASSEMBLY__ */ |
28 | 11 | ||
29 | /* | 12 | /* |
@@ -41,18 +24,6 @@ __extension__ typedef unsigned long long __u64; | |||
41 | 24 | ||
42 | #ifndef __ASSEMBLY__ | 25 | #ifndef __ASSEMBLY__ |
43 | 26 | ||
44 | typedef signed char s8; | ||
45 | typedef unsigned char u8; | ||
46 | |||
47 | typedef signed short s16; | ||
48 | typedef unsigned short u16; | ||
49 | |||
50 | typedef signed int s32; | ||
51 | typedef unsigned int u32; | ||
52 | |||
53 | typedef signed long long s64; | ||
54 | typedef unsigned long long u64; | ||
55 | |||
56 | /* Dma addresses are 32-bits wide. */ | 27 | /* Dma addresses are 32-bits wide. */ |
57 | 28 | ||
58 | typedef u32 dma_addr_t; | 29 | typedef u32 dma_addr_t; |
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h index afae0697e8ce..e0062d73db1c 100644 --- a/include/asm-powerpc/io.h +++ b/include/asm-powerpc/io.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define _ASM_POWERPC_IO_H | 2 | #define _ASM_POWERPC_IO_H |
3 | #ifdef __KERNEL__ | 3 | #ifdef __KERNEL__ |
4 | 4 | ||
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 |
8 | * as published by the Free Software Foundation; either version | 8 | * as published by the Free Software Foundation; either version |
@@ -18,6 +18,9 @@ extern int check_legacy_ioport(unsigned long base_port); | |||
18 | #define _PNPWRP 0xa79 | 18 | #define _PNPWRP 0xa79 |
19 | #define PNPBIOS_BASE 0xf000 | 19 | #define PNPBIOS_BASE 0xf000 |
20 | 20 | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/io.h> | ||
23 | |||
21 | #include <linux/compiler.h> | 24 | #include <linux/compiler.h> |
22 | #include <asm/page.h> | 25 | #include <asm/page.h> |
23 | #include <asm/byteorder.h> | 26 | #include <asm/byteorder.h> |
@@ -744,6 +747,9 @@ static inline void * bus_to_virt(unsigned long address) | |||
744 | 747 | ||
745 | #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set) | 748 | #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set) |
746 | 749 | ||
750 | void __iomem *devm_ioremap_prot(struct device *dev, resource_size_t offset, | ||
751 | size_t size, unsigned long flags); | ||
752 | |||
747 | #endif /* __KERNEL__ */ | 753 | #endif /* __KERNEL__ */ |
748 | 754 | ||
749 | #endif /* _ASM_POWERPC_IO_H */ | 755 | #endif /* _ASM_POWERPC_IO_H */ |
diff --git a/include/asm-powerpc/kvm_host.h b/include/asm-powerpc/kvm_host.h index 04ffbb8e0a35..81a69d711017 100644 --- a/include/asm-powerpc/kvm_host.h +++ b/include/asm-powerpc/kvm_host.h | |||
@@ -59,6 +59,7 @@ struct kvm_vcpu_stat { | |||
59 | u32 emulated_inst_exits; | 59 | u32 emulated_inst_exits; |
60 | u32 dec_exits; | 60 | u32 dec_exits; |
61 | u32 ext_intr_exits; | 61 | u32 ext_intr_exits; |
62 | u32 halt_wakeup; | ||
62 | }; | 63 | }; |
63 | 64 | ||
64 | struct tlbe { | 65 | struct tlbe { |
diff --git a/include/asm-powerpc/kvm_ppc.h b/include/asm-powerpc/kvm_ppc.h index 7ac820308a7e..b35a7e3ef978 100644 --- a/include/asm-powerpc/kvm_ppc.h +++ b/include/asm-powerpc/kvm_ppc.h | |||
@@ -77,12 +77,17 @@ static inline void kvmppc_clear_exception(struct kvm_vcpu *vcpu, int exception) | |||
77 | clear_bit(priority, &vcpu->arch.pending_exceptions); | 77 | clear_bit(priority, &vcpu->arch.pending_exceptions); |
78 | } | 78 | } |
79 | 79 | ||
80 | /* Helper function for "full" MSR writes. No need to call this if only EE is | ||
81 | * changing. */ | ||
80 | static inline void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr) | 82 | static inline void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr) |
81 | { | 83 | { |
82 | if ((new_msr & MSR_PR) != (vcpu->arch.msr & MSR_PR)) | 84 | if ((new_msr & MSR_PR) != (vcpu->arch.msr & MSR_PR)) |
83 | kvmppc_mmu_priv_switch(vcpu, new_msr & MSR_PR); | 85 | kvmppc_mmu_priv_switch(vcpu, new_msr & MSR_PR); |
84 | 86 | ||
85 | vcpu->arch.msr = new_msr; | 87 | vcpu->arch.msr = new_msr; |
88 | |||
89 | if (vcpu->arch.msr & MSR_WE) | ||
90 | kvm_vcpu_block(vcpu); | ||
86 | } | 91 | } |
87 | 92 | ||
88 | #endif /* __POWERPC_KVM_PPC_H__ */ | 93 | #endif /* __POWERPC_KVM_PPC_H__ */ |
diff --git a/include/asm-powerpc/ps3.h b/include/asm-powerpc/ps3.h index 9e8ed6824e15..81ffe3b3c1ce 100644 --- a/include/asm-powerpc/ps3.h +++ b/include/asm-powerpc/ps3.h | |||
@@ -178,9 +178,6 @@ enum ps3_cpu_binding { | |||
178 | PS3_BINDING_CPU_1 = 1, | 178 | PS3_BINDING_CPU_1 = 1, |
179 | }; | 179 | }; |
180 | 180 | ||
181 | int ps3_virq_setup(enum ps3_cpu_binding cpu, unsigned long outlet, | ||
182 | unsigned int *virq); | ||
183 | int ps3_virq_destroy(unsigned int virq); | ||
184 | int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet, | 181 | int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet, |
185 | unsigned int *virq); | 182 | unsigned int *virq); |
186 | int ps3_irq_plug_destroy(unsigned int virq); | 183 | int ps3_irq_plug_destroy(unsigned int virq); |
diff --git a/include/asm-powerpc/syscalls.h b/include/asm-powerpc/syscalls.h index b3ca41fc8bb1..2b8a458f990a 100644 --- a/include/asm-powerpc/syscalls.h +++ b/include/asm-powerpc/syscalls.h | |||
@@ -30,7 +30,7 @@ asmlinkage int sys_fork(unsigned long p1, unsigned long p2, | |||
30 | asmlinkage int sys_vfork(unsigned long p1, unsigned long p2, | 30 | asmlinkage int sys_vfork(unsigned long p1, unsigned long p2, |
31 | unsigned long p3, unsigned long p4, unsigned long p5, | 31 | unsigned long p3, unsigned long p4, unsigned long p5, |
32 | unsigned long p6, struct pt_regs *regs); | 32 | unsigned long p6, struct pt_regs *regs); |
33 | asmlinkage int sys_pipe(int __user *fildes); | 33 | asmlinkage long sys_pipe(int __user *fildes); |
34 | asmlinkage long sys_rt_sigaction(int sig, | 34 | asmlinkage long sys_rt_sigaction(int sig, |
35 | const struct sigaction __user *act, | 35 | const struct sigaction __user *act, |
36 | struct sigaction __user *oact, size_t sigsetsize); | 36 | struct sigaction __user *oact, size_t sigsetsize); |
diff --git a/include/asm-powerpc/types.h b/include/asm-powerpc/types.h index c243a6ac60e5..d3374bc865ba 100644 --- a/include/asm-powerpc/types.h +++ b/include/asm-powerpc/types.h | |||
@@ -1,6 +1,12 @@ | |||
1 | #ifndef _ASM_POWERPC_TYPES_H | 1 | #ifndef _ASM_POWERPC_TYPES_H |
2 | #define _ASM_POWERPC_TYPES_H | 2 | #define _ASM_POWERPC_TYPES_H |
3 | 3 | ||
4 | #ifdef __powerpc64__ | ||
5 | # include <asm-generic/int-l64.h> | ||
6 | #else | ||
7 | # include <asm-generic/int-ll64.h> | ||
8 | #endif | ||
9 | |||
4 | #ifndef __ASSEMBLY__ | 10 | #ifndef __ASSEMBLY__ |
5 | 11 | ||
6 | /* | 12 | /* |
@@ -22,30 +28,6 @@ typedef unsigned int umode_t; | |||
22 | typedef unsigned short umode_t; | 28 | typedef unsigned short umode_t; |
23 | #endif | 29 | #endif |
24 | 30 | ||
25 | /* | ||
26 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
27 | * header files exported to user space | ||
28 | */ | ||
29 | |||
30 | typedef __signed__ char __s8; | ||
31 | typedef unsigned char __u8; | ||
32 | |||
33 | typedef __signed__ short __s16; | ||
34 | typedef unsigned short __u16; | ||
35 | |||
36 | typedef __signed__ int __s32; | ||
37 | typedef unsigned int __u32; | ||
38 | |||
39 | #ifdef __powerpc64__ | ||
40 | typedef __signed__ long __s64; | ||
41 | typedef unsigned long __u64; | ||
42 | #else | ||
43 | #if defined(__GNUC__) | ||
44 | __extension__ typedef __signed__ long long __s64; | ||
45 | __extension__ typedef unsigned long long __u64; | ||
46 | #endif | ||
47 | #endif /* __powerpc64__ */ | ||
48 | |||
49 | typedef struct { | 31 | typedef struct { |
50 | __u32 u[4]; | 32 | __u32 u[4]; |
51 | } __attribute__((aligned(16))) __vector128; | 33 | } __attribute__((aligned(16))) __vector128; |
@@ -64,24 +46,6 @@ typedef struct { | |||
64 | 46 | ||
65 | #ifndef __ASSEMBLY__ | 47 | #ifndef __ASSEMBLY__ |
66 | 48 | ||
67 | |||
68 | typedef signed char s8; | ||
69 | typedef unsigned char u8; | ||
70 | |||
71 | typedef signed short s16; | ||
72 | typedef unsigned short u16; | ||
73 | |||
74 | typedef signed int s32; | ||
75 | typedef unsigned int u32; | ||
76 | |||
77 | #ifdef __powerpc64__ | ||
78 | typedef signed long s64; | ||
79 | typedef unsigned long u64; | ||
80 | #else | ||
81 | typedef signed long long s64; | ||
82 | typedef unsigned long long u64; | ||
83 | #endif | ||
84 | |||
85 | typedef __vector128 vector128; | 49 | typedef __vector128 vector128; |
86 | 50 | ||
87 | /* Physical address used by some IO functions */ | 51 | /* Physical address used by some IO functions */ |
diff --git a/include/asm-s390/types.h b/include/asm-s390/types.h index 2c5879ae90ca..78dda038dd47 100644 --- a/include/asm-s390/types.h +++ b/include/asm-s390/types.h | |||
@@ -9,34 +9,16 @@ | |||
9 | #ifndef _S390_TYPES_H | 9 | #ifndef _S390_TYPES_H |
10 | #define _S390_TYPES_H | 10 | #define _S390_TYPES_H |
11 | 11 | ||
12 | #ifndef __s390x__ | ||
13 | # include <asm-generic/int-l64.h> | ||
14 | #else | ||
15 | # include <asm-generic/int-ll64.h> | ||
16 | #endif | ||
17 | |||
12 | #ifndef __ASSEMBLY__ | 18 | #ifndef __ASSEMBLY__ |
13 | 19 | ||
14 | typedef unsigned short umode_t; | 20 | typedef unsigned short umode_t; |
15 | 21 | ||
16 | /* | ||
17 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
18 | * header files exported to user space | ||
19 | */ | ||
20 | |||
21 | typedef __signed__ char __s8; | ||
22 | typedef unsigned char __u8; | ||
23 | |||
24 | typedef __signed__ short __s16; | ||
25 | typedef unsigned short __u16; | ||
26 | |||
27 | typedef __signed__ int __s32; | ||
28 | typedef unsigned int __u32; | ||
29 | |||
30 | #ifndef __s390x__ | ||
31 | #if defined(__GNUC__) | ||
32 | __extension__ typedef __signed__ long long __s64; | ||
33 | __extension__ typedef unsigned long long __u64; | ||
34 | #endif | ||
35 | #else /* __s390x__ */ | ||
36 | typedef __signed__ long __s64; | ||
37 | typedef unsigned long __u64; | ||
38 | #endif | ||
39 | |||
40 | /* A address type so that arithmetic can be done on it & it can be upgraded to | 22 | /* A address type so that arithmetic can be done on it & it can be upgraded to |
41 | 64 bit when necessary | 23 | 64 bit when necessary |
42 | */ | 24 | */ |
@@ -58,24 +40,6 @@ typedef __signed__ long saddr_t; | |||
58 | 40 | ||
59 | #ifndef __ASSEMBLY__ | 41 | #ifndef __ASSEMBLY__ |
60 | 42 | ||
61 | |||
62 | typedef signed char s8; | ||
63 | typedef unsigned char u8; | ||
64 | |||
65 | typedef signed short s16; | ||
66 | typedef unsigned short u16; | ||
67 | |||
68 | typedef signed int s32; | ||
69 | typedef unsigned int u32; | ||
70 | |||
71 | #ifndef __s390x__ | ||
72 | typedef signed long long s64; | ||
73 | typedef unsigned long long u64; | ||
74 | #else /* __s390x__ */ | ||
75 | typedef signed long s64; | ||
76 | typedef unsigned long u64; | ||
77 | #endif /* __s390x__ */ | ||
78 | |||
79 | typedef u32 dma_addr_t; | 43 | typedef u32 dma_addr_t; |
80 | 44 | ||
81 | #ifndef __s390x__ | 45 | #ifndef __s390x__ |
diff --git a/include/asm-sh/types.h b/include/asm-sh/types.h index a6e1d4126e67..beea4e6f8dfd 100644 --- a/include/asm-sh/types.h +++ b/include/asm-sh/types.h | |||
@@ -1,29 +1,12 @@ | |||
1 | #ifndef __ASM_SH_TYPES_H | 1 | #ifndef __ASM_SH_TYPES_H |
2 | #define __ASM_SH_TYPES_H | 2 | #define __ASM_SH_TYPES_H |
3 | 3 | ||
4 | #include <asm-generic/int-ll64.h> | ||
5 | |||
4 | #ifndef __ASSEMBLY__ | 6 | #ifndef __ASSEMBLY__ |
5 | 7 | ||
6 | typedef unsigned short umode_t; | 8 | typedef unsigned short umode_t; |
7 | 9 | ||
8 | /* | ||
9 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
10 | * header files exported to user space | ||
11 | */ | ||
12 | |||
13 | typedef __signed__ char __s8; | ||
14 | typedef unsigned char __u8; | ||
15 | |||
16 | typedef __signed__ short __s16; | ||
17 | typedef unsigned short __u16; | ||
18 | |||
19 | typedef __signed__ int __s32; | ||
20 | typedef unsigned int __u32; | ||
21 | |||
22 | #if defined(__GNUC__) | ||
23 | __extension__ typedef __signed__ long long __s64; | ||
24 | __extension__ typedef unsigned long long __u64; | ||
25 | #endif | ||
26 | |||
27 | #endif /* __ASSEMBLY__ */ | 10 | #endif /* __ASSEMBLY__ */ |
28 | 11 | ||
29 | /* | 12 | /* |
@@ -35,19 +18,6 @@ __extension__ typedef unsigned long long __u64; | |||
35 | 18 | ||
36 | #ifndef __ASSEMBLY__ | 19 | #ifndef __ASSEMBLY__ |
37 | 20 | ||
38 | |||
39 | typedef __signed__ char s8; | ||
40 | typedef unsigned char u8; | ||
41 | |||
42 | typedef __signed__ short s16; | ||
43 | typedef unsigned short u16; | ||
44 | |||
45 | typedef __signed__ int s32; | ||
46 | typedef unsigned int u32; | ||
47 | |||
48 | typedef __signed__ long long s64; | ||
49 | typedef unsigned long long u64; | ||
50 | |||
51 | /* Dma addresses are 32-bits wide. */ | 21 | /* Dma addresses are 32-bits wide. */ |
52 | 22 | ||
53 | typedef u32 dma_addr_t; | 23 | typedef u32 dma_addr_t; |
diff --git a/include/asm-sparc/oplib.h b/include/asm-sparc/oplib.h index 17ba82ee220a..7becc846544a 100644 --- a/include/asm-sparc/oplib.h +++ b/include/asm-sparc/oplib.h | |||
@@ -34,9 +34,6 @@ extern unsigned int prom_rev, prom_prev; | |||
34 | */ | 34 | */ |
35 | extern int prom_root_node; | 35 | extern int prom_root_node; |
36 | 36 | ||
37 | /* PROM stdin and stdout */ | ||
38 | extern int prom_stdin, prom_stdout; | ||
39 | |||
40 | /* Pointer to prom structure containing the device tree traversal | 37 | /* Pointer to prom structure containing the device tree traversal |
41 | * and usage utility functions. Only prom-lib should use these, | 38 | * and usage utility functions. Only prom-lib should use these, |
42 | * users use the interface defined by the library only! | 39 | * users use the interface defined by the library only! |
@@ -84,20 +81,6 @@ extern int prom_devclose(int device_handle); | |||
84 | extern void prom_seek(int device_handle, unsigned int seek_hival, | 81 | extern void prom_seek(int device_handle, unsigned int seek_hival, |
85 | unsigned int seek_lowval); | 82 | unsigned int seek_lowval); |
86 | 83 | ||
87 | /* Machine memory configuration routine. */ | ||
88 | |||
89 | /* This function returns a V0 format memory descriptor table, it has three | ||
90 | * entries. One for the total amount of physical ram on the machine, one | ||
91 | * for the amount of physical ram available, and one describing the virtual | ||
92 | * areas which are allocated by the prom. So, in a sense the physical | ||
93 | * available is a calculation of the total physical minus the physical mapped | ||
94 | * by the prom with virtual mappings. | ||
95 | * | ||
96 | * These lists are returned pre-sorted, this should make your life easier | ||
97 | * since the prom itself is way too lazy to do such nice things. | ||
98 | */ | ||
99 | extern struct linux_mem_v0 *prom_meminfo(void); | ||
100 | |||
101 | /* Miscellaneous routines, don't really fit in any category per se. */ | 84 | /* Miscellaneous routines, don't really fit in any category per se. */ |
102 | 85 | ||
103 | /* Reboot the machine with the command line passed. */ | 86 | /* Reboot the machine with the command line passed. */ |
diff --git a/include/asm-sparc/page.h b/include/asm-sparc/page.h index 39ccf2da297c..1625a8c3e0d2 100644 --- a/include/asm-sparc/page.h +++ b/include/asm-sparc/page.h | |||
@@ -38,12 +38,11 @@ | |||
38 | 38 | ||
39 | /* The following structure is used to hold the physical | 39 | /* The following structure is used to hold the physical |
40 | * memory configuration of the machine. This is filled in | 40 | * memory configuration of the machine. This is filled in |
41 | * probe_memory() and is later used by mem_init() to set up | 41 | * prom_meminit() and is later used by mem_init() to set up |
42 | * mem_map[]. We statically allocate SPARC_PHYS_BANKS of | 42 | * mem_map[]. We statically allocate SPARC_PHYS_BANKS+1 of |
43 | * these structs, this is arbitrary. The entry after the | 43 | * these structs, this is arbitrary. The entry after the |
44 | * last valid one has num_bytes==0. | 44 | * last valid one has num_bytes==0. |
45 | */ | 45 | */ |
46 | |||
47 | struct sparc_phys_banks { | 46 | struct sparc_phys_banks { |
48 | unsigned long base_addr; | 47 | unsigned long base_addr; |
49 | unsigned long num_bytes; | 48 | unsigned long num_bytes; |
diff --git a/include/asm-sparc/types.h b/include/asm-sparc/types.h index 42fc6ed98156..1b08ef860a66 100644 --- a/include/asm-sparc/types.h +++ b/include/asm-sparc/types.h | |||
@@ -3,34 +3,18 @@ | |||
3 | #define _SPARC_TYPES_H | 3 | #define _SPARC_TYPES_H |
4 | 4 | ||
5 | /* | 5 | /* |
6 | * _xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
7 | * header files exported to user space. | ||
8 | */ | ||
9 | |||
10 | /* | ||
11 | * This file is never included by application software unless | 6 | * This file is never included by application software unless |
12 | * explicitly requested (e.g., via linux/types.h) in which case the | 7 | * explicitly requested (e.g., via linux/types.h) in which case the |
13 | * application is Linux specific so (user-) name space pollution is | 8 | * application is Linux specific so (user-) name space pollution is |
14 | * not a major issue. However, for interoperability, libraries still | 9 | * not a major issue. However, for interoperability, libraries still |
15 | * need to be careful to avoid a name clashes. | 10 | * need to be careful to avoid a name clashes. |
16 | */ | 11 | */ |
12 | #include <asm-generic/int-ll64.h> | ||
17 | 13 | ||
18 | #ifndef __ASSEMBLY__ | 14 | #ifndef __ASSEMBLY__ |
19 | 15 | ||
20 | typedef unsigned short umode_t; | 16 | typedef unsigned short umode_t; |
21 | 17 | ||
22 | typedef __signed__ char __s8; | ||
23 | typedef unsigned char __u8; | ||
24 | |||
25 | typedef __signed__ short __s16; | ||
26 | typedef unsigned short __u16; | ||
27 | |||
28 | typedef __signed__ int __s32; | ||
29 | typedef unsigned int __u32; | ||
30 | |||
31 | typedef __signed__ long long __s64; | ||
32 | typedef unsigned long long __u64; | ||
33 | |||
34 | #endif /* __ASSEMBLY__ */ | 18 | #endif /* __ASSEMBLY__ */ |
35 | 19 | ||
36 | #ifdef __KERNEL__ | 20 | #ifdef __KERNEL__ |
@@ -39,18 +23,6 @@ typedef unsigned long long __u64; | |||
39 | 23 | ||
40 | #ifndef __ASSEMBLY__ | 24 | #ifndef __ASSEMBLY__ |
41 | 25 | ||
42 | typedef __signed__ char s8; | ||
43 | typedef unsigned char u8; | ||
44 | |||
45 | typedef __signed__ short s16; | ||
46 | typedef unsigned short u16; | ||
47 | |||
48 | typedef __signed__ int s32; | ||
49 | typedef unsigned int u32; | ||
50 | |||
51 | typedef __signed__ long long s64; | ||
52 | typedef unsigned long long u64; | ||
53 | |||
54 | typedef u32 dma_addr_t; | 26 | typedef u32 dma_addr_t; |
55 | typedef u32 dma64_addr_t; | 27 | typedef u32 dma64_addr_t; |
56 | 28 | ||
diff --git a/include/asm-sparc64/types.h b/include/asm-sparc64/types.h index d0ee7f105838..5dbe04f4044a 100644 --- a/include/asm-sparc64/types.h +++ b/include/asm-sparc64/types.h | |||
@@ -9,28 +9,12 @@ | |||
9 | * not a major issue. However, for interoperability, libraries still | 9 | * not a major issue. However, for interoperability, libraries still |
10 | * need to be careful to avoid a name clashes. | 10 | * need to be careful to avoid a name clashes. |
11 | */ | 11 | */ |
12 | #include <asm-generic/int-l64.h> | ||
12 | 13 | ||
13 | #ifndef __ASSEMBLY__ | 14 | #ifndef __ASSEMBLY__ |
14 | 15 | ||
15 | typedef unsigned short umode_t; | 16 | typedef unsigned short umode_t; |
16 | 17 | ||
17 | /* | ||
18 | * _xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
19 | * header files exported to user space. | ||
20 | */ | ||
21 | |||
22 | typedef __signed__ char __s8; | ||
23 | typedef unsigned char __u8; | ||
24 | |||
25 | typedef __signed__ short __s16; | ||
26 | typedef unsigned short __u16; | ||
27 | |||
28 | typedef __signed__ int __s32; | ||
29 | typedef unsigned int __u32; | ||
30 | |||
31 | typedef __signed__ long __s64; | ||
32 | typedef unsigned long __u64; | ||
33 | |||
34 | #endif /* __ASSEMBLY__ */ | 18 | #endif /* __ASSEMBLY__ */ |
35 | 19 | ||
36 | #ifdef __KERNEL__ | 20 | #ifdef __KERNEL__ |
@@ -39,18 +23,6 @@ typedef unsigned long __u64; | |||
39 | 23 | ||
40 | #ifndef __ASSEMBLY__ | 24 | #ifndef __ASSEMBLY__ |
41 | 25 | ||
42 | typedef __signed__ char s8; | ||
43 | typedef unsigned char u8; | ||
44 | |||
45 | typedef __signed__ short s16; | ||
46 | typedef unsigned short u16; | ||
47 | |||
48 | typedef __signed__ int s32; | ||
49 | typedef unsigned int u32; | ||
50 | |||
51 | typedef __signed__ long s64; | ||
52 | typedef unsigned long u64; | ||
53 | |||
54 | /* Dma addresses come in generic and 64-bit flavours. */ | 26 | /* Dma addresses come in generic and 64-bit flavours. */ |
55 | 27 | ||
56 | typedef u32 dma_addr_t; | 28 | typedef u32 dma_addr_t; |
diff --git a/include/asm-um/div64.h b/include/asm-um/div64.h index 7b73b2cd5b34..1e17f7409cab 100644 --- a/include/asm-um/div64.h +++ b/include/asm-um/div64.h | |||
@@ -3,5 +3,4 @@ | |||
3 | 3 | ||
4 | #include "asm/arch/div64.h" | 4 | #include "asm/arch/div64.h" |
5 | 5 | ||
6 | extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); | ||
7 | #endif | 6 | #endif |
diff --git a/include/asm-v850/types.h b/include/asm-v850/types.h index 284bda882112..89f735ee41dd 100644 --- a/include/asm-v850/types.h +++ b/include/asm-v850/types.h | |||
@@ -10,28 +10,10 @@ | |||
10 | * not a major issue. However, for interoperability, libraries still | 10 | * not a major issue. However, for interoperability, libraries still |
11 | * need to be careful to avoid a name clashes. | 11 | * need to be careful to avoid a name clashes. |
12 | */ | 12 | */ |
13 | #include <asm-generic/int-ll64.h> | ||
13 | 14 | ||
14 | typedef unsigned short umode_t; | 15 | typedef unsigned short umode_t; |
15 | 16 | ||
16 | /* | ||
17 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
18 | * header files exported to user space | ||
19 | */ | ||
20 | |||
21 | typedef __signed__ char __s8; | ||
22 | typedef unsigned char __u8; | ||
23 | |||
24 | typedef __signed__ short __s16; | ||
25 | typedef unsigned short __u16; | ||
26 | |||
27 | typedef __signed__ int __s32; | ||
28 | typedef unsigned int __u32; | ||
29 | |||
30 | #if defined(__GNUC__) | ||
31 | __extension__ typedef __signed__ long long __s64; | ||
32 | __extension__ typedef unsigned long long __u64; | ||
33 | #endif | ||
34 | |||
35 | #endif /* !__ASSEMBLY__ */ | 17 | #endif /* !__ASSEMBLY__ */ |
36 | 18 | ||
37 | /* | 19 | /* |
@@ -43,18 +25,6 @@ __extension__ typedef unsigned long long __u64; | |||
43 | 25 | ||
44 | #ifndef __ASSEMBLY__ | 26 | #ifndef __ASSEMBLY__ |
45 | 27 | ||
46 | typedef signed char s8; | ||
47 | typedef unsigned char u8; | ||
48 | |||
49 | typedef signed short s16; | ||
50 | typedef unsigned short u16; | ||
51 | |||
52 | typedef signed int s32; | ||
53 | typedef unsigned int u32; | ||
54 | |||
55 | typedef signed long long s64; | ||
56 | typedef unsigned long long u64; | ||
57 | |||
58 | /* Dma addresses are 32-bits wide. */ | 28 | /* Dma addresses are 32-bits wide. */ |
59 | 29 | ||
60 | typedef u32 dma_addr_t; | 30 | typedef u32 dma_addr_t; |
diff --git a/include/asm-x86/bootparam.h b/include/asm-x86/bootparam.h index e8659909e5f6..f62f4733606b 100644 --- a/include/asm-x86/bootparam.h +++ b/include/asm-x86/bootparam.h | |||
@@ -14,10 +14,10 @@ | |||
14 | 14 | ||
15 | /* extensible setup data list node */ | 15 | /* extensible setup data list node */ |
16 | struct setup_data { | 16 | struct setup_data { |
17 | u64 next; | 17 | __u64 next; |
18 | u32 type; | 18 | __u32 type; |
19 | u32 len; | 19 | __u32 len; |
20 | u8 data[0]; | 20 | __u8 data[0]; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | struct setup_header { | 23 | struct setup_header { |
diff --git a/include/asm-x86/div64.h b/include/asm-x86/div64.h index 0dbf8bf3ef0a..9a2d644c08ef 100644 --- a/include/asm-x86/div64.h +++ b/include/asm-x86/div64.h | |||
@@ -33,25 +33,25 @@ | |||
33 | __mod; \ | 33 | __mod; \ |
34 | }) | 34 | }) |
35 | 35 | ||
36 | /* | 36 | static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) |
37 | * (long)X = ((long long)divs) / (long)div | ||
38 | * (long)rem = ((long long)divs) % (long)div | ||
39 | * | ||
40 | * Warning, this will do an exception if X overflows. | ||
41 | */ | ||
42 | #define div_long_long_rem(a, b, c) div_ll_X_l_rem(a, b, c) | ||
43 | |||
44 | static inline long div_ll_X_l_rem(long long divs, long div, long *rem) | ||
45 | { | 37 | { |
46 | long dum2; | 38 | union { |
47 | asm("divl %2":"=a"(dum2), "=d"(*rem) | 39 | u64 v64; |
48 | : "rm"(div), "A"(divs)); | 40 | u32 v32[2]; |
49 | 41 | } d = { dividend }; | |
50 | return dum2; | 42 | u32 upper; |
51 | 43 | ||
44 | upper = d.v32[1]; | ||
45 | d.v32[1] = 0; | ||
46 | if (upper >= divisor) { | ||
47 | d.v32[1] = upper / divisor; | ||
48 | upper %= divisor; | ||
49 | } | ||
50 | asm ("divl %2" : "=a" (d.v32[0]), "=d" (*remainder) : | ||
51 | "rm" (divisor), "0" (d.v32[0]), "1" (upper)); | ||
52 | return d.v64; | ||
52 | } | 53 | } |
53 | 54 | #define div_u64_rem div_u64_rem | |
54 | extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); | ||
55 | 55 | ||
56 | #else | 56 | #else |
57 | # include <asm-generic/div64.h> | 57 | # include <asm-generic/div64.h> |
diff --git a/include/asm-x86/dmi.h b/include/asm-x86/dmi.h index 1241e6ad1935..4edf7514a750 100644 --- a/include/asm-x86/dmi.h +++ b/include/asm-x86/dmi.h | |||
@@ -27,6 +27,7 @@ static inline void *dmi_alloc(unsigned len) | |||
27 | 27 | ||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | /* Use early IO mappings for DMI because it's initialized early */ | ||
30 | #define dmi_ioremap early_ioremap | 31 | #define dmi_ioremap early_ioremap |
31 | #define dmi_iounmap early_iounmap | 32 | #define dmi_iounmap early_iounmap |
32 | 33 | ||
diff --git a/include/asm-x86/io_32.h b/include/asm-x86/io_32.h index 6e73467a4fb1..049e81e797a0 100644 --- a/include/asm-x86/io_32.h +++ b/include/asm-x86/io_32.h | |||
@@ -133,11 +133,6 @@ extern void *early_ioremap(unsigned long offset, unsigned long size); | |||
133 | extern void early_iounmap(void *addr, unsigned long size); | 133 | extern void early_iounmap(void *addr, unsigned long size); |
134 | extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); | 134 | extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); |
135 | 135 | ||
136 | /* Use early IO mappings for DMI because it's initialized early */ | ||
137 | #define dmi_ioremap early_ioremap | ||
138 | #define dmi_iounmap early_iounmap | ||
139 | #define dmi_alloc alloc_bootmem | ||
140 | |||
141 | /* | 136 | /* |
142 | * ISA I/O bus memory addresses are 1:1 with the physical address. | 137 | * ISA I/O bus memory addresses are 1:1 with the physical address. |
143 | */ | 138 | */ |
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h index 9d963cd6533c..1d8cd01fa514 100644 --- a/include/asm-x86/kvm_host.h +++ b/include/asm-x86/kvm_host.h | |||
@@ -314,6 +314,9 @@ struct kvm_arch{ | |||
314 | struct page *apic_access_page; | 314 | struct page *apic_access_page; |
315 | 315 | ||
316 | gpa_t wall_clock; | 316 | gpa_t wall_clock; |
317 | |||
318 | struct page *ept_identity_pagetable; | ||
319 | bool ept_identity_pagetable_done; | ||
317 | }; | 320 | }; |
318 | 321 | ||
319 | struct kvm_vm_stat { | 322 | struct kvm_vm_stat { |
@@ -422,6 +425,7 @@ struct kvm_x86_ops { | |||
422 | struct kvm_run *run); | 425 | struct kvm_run *run); |
423 | 426 | ||
424 | int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); | 427 | int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); |
428 | int (*get_tdp_level)(void); | ||
425 | }; | 429 | }; |
426 | 430 | ||
427 | extern struct kvm_x86_ops *kvm_x86_ops; | 431 | extern struct kvm_x86_ops *kvm_x86_ops; |
@@ -433,6 +437,9 @@ void kvm_mmu_destroy(struct kvm_vcpu *vcpu); | |||
433 | int kvm_mmu_create(struct kvm_vcpu *vcpu); | 437 | int kvm_mmu_create(struct kvm_vcpu *vcpu); |
434 | int kvm_mmu_setup(struct kvm_vcpu *vcpu); | 438 | int kvm_mmu_setup(struct kvm_vcpu *vcpu); |
435 | void kvm_mmu_set_nonpresent_ptes(u64 trap_pte, u64 notrap_pte); | 439 | void kvm_mmu_set_nonpresent_ptes(u64 trap_pte, u64 notrap_pte); |
440 | void kvm_mmu_set_base_ptes(u64 base_pte); | ||
441 | void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, | ||
442 | u64 dirty_mask, u64 nx_mask, u64 x_mask); | ||
436 | 443 | ||
437 | int kvm_mmu_reset_context(struct kvm_vcpu *vcpu); | 444 | int kvm_mmu_reset_context(struct kvm_vcpu *vcpu); |
438 | void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot); | 445 | void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot); |
@@ -620,7 +627,7 @@ static inline void fx_restore(struct i387_fxsave_struct *image) | |||
620 | asm("fxrstor (%0)":: "r" (image)); | 627 | asm("fxrstor (%0)":: "r" (image)); |
621 | } | 628 | } |
622 | 629 | ||
623 | static inline void fpu_init(void) | 630 | static inline void fx_finit(void) |
624 | { | 631 | { |
625 | asm("finit"); | 632 | asm("finit"); |
626 | } | 633 | } |
@@ -644,6 +651,7 @@ static inline void kvm_inject_gp(struct kvm_vcpu *vcpu, u32 error_code) | |||
644 | #define ASM_VMX_VMWRITE_RSP_RDX ".byte 0x0f, 0x79, 0xd4" | 651 | #define ASM_VMX_VMWRITE_RSP_RDX ".byte 0x0f, 0x79, 0xd4" |
645 | #define ASM_VMX_VMXOFF ".byte 0x0f, 0x01, 0xc4" | 652 | #define ASM_VMX_VMXOFF ".byte 0x0f, 0x01, 0xc4" |
646 | #define ASM_VMX_VMXON_RAX ".byte 0xf3, 0x0f, 0xc7, 0x30" | 653 | #define ASM_VMX_VMXON_RAX ".byte 0xf3, 0x0f, 0xc7, 0x30" |
654 | #define ASM_VMX_INVEPT ".byte 0x66, 0x0f, 0x38, 0x80, 0x08" | ||
647 | #define ASM_VMX_INVVPID ".byte 0x66, 0x0f, 0x38, 0x81, 0x08" | 655 | #define ASM_VMX_INVVPID ".byte 0x66, 0x0f, 0x38, 0x81, 0x08" |
648 | 656 | ||
649 | #define MSR_IA32_TIME_STAMP_COUNTER 0x010 | 657 | #define MSR_IA32_TIME_STAMP_COUNTER 0x010 |
diff --git a/include/asm-x86/types.h b/include/asm-x86/types.h index 63733f315688..1ac80cd9acf8 100644 --- a/include/asm-x86/types.h +++ b/include/asm-x86/types.h | |||
@@ -1,34 +1,12 @@ | |||
1 | #ifndef _ASM_X86_TYPES_H | 1 | #ifndef _ASM_X86_TYPES_H |
2 | #define _ASM_X86_TYPES_H | 2 | #define _ASM_X86_TYPES_H |
3 | 3 | ||
4 | #include <asm-generic/int-ll64.h> | ||
5 | |||
4 | #ifndef __ASSEMBLY__ | 6 | #ifndef __ASSEMBLY__ |
5 | 7 | ||
6 | typedef unsigned short umode_t; | 8 | typedef unsigned short umode_t; |
7 | 9 | ||
8 | /* | ||
9 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
10 | * header files exported to user space | ||
11 | */ | ||
12 | |||
13 | typedef __signed__ char __s8; | ||
14 | typedef unsigned char __u8; | ||
15 | |||
16 | typedef __signed__ short __s16; | ||
17 | typedef unsigned short __u16; | ||
18 | |||
19 | typedef __signed__ int __s32; | ||
20 | typedef unsigned int __u32; | ||
21 | |||
22 | #ifdef __i386__ | ||
23 | # ifdef __GNUC__ | ||
24 | __extension__ typedef __signed__ long long __s64; | ||
25 | __extension__ typedef unsigned long long __u64; | ||
26 | # endif | ||
27 | #else | ||
28 | typedef __signed__ long long __s64; | ||
29 | typedef unsigned long long __u64; | ||
30 | #endif | ||
31 | |||
32 | #endif /* __ASSEMBLY__ */ | 10 | #endif /* __ASSEMBLY__ */ |
33 | 11 | ||
34 | /* | 12 | /* |
@@ -44,18 +22,6 @@ typedef unsigned long long __u64; | |||
44 | 22 | ||
45 | #ifndef __ASSEMBLY__ | 23 | #ifndef __ASSEMBLY__ |
46 | 24 | ||
47 | typedef signed char s8; | ||
48 | typedef unsigned char u8; | ||
49 | |||
50 | typedef signed short s16; | ||
51 | typedef unsigned short u16; | ||
52 | |||
53 | typedef signed int s32; | ||
54 | typedef unsigned int u32; | ||
55 | |||
56 | typedef signed long long s64; | ||
57 | typedef unsigned long long u64; | ||
58 | |||
59 | typedef u64 dma64_addr_t; | 25 | typedef u64 dma64_addr_t; |
60 | #if defined(CONFIG_X86_64) || defined(CONFIG_HIGHMEM64G) | 26 | #if defined(CONFIG_X86_64) || defined(CONFIG_HIGHMEM64G) |
61 | /* DMA addresses come in 32-bit and 64-bit flavours. */ | 27 | /* DMA addresses come in 32-bit and 64-bit flavours. */ |
diff --git a/include/asm-xtensa/types.h b/include/asm-xtensa/types.h index b27d841a8eb7..c89569a8da0c 100644 --- a/include/asm-xtensa/types.h +++ b/include/asm-xtensa/types.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #ifndef _XTENSA_TYPES_H | 11 | #ifndef _XTENSA_TYPES_H |
12 | #define _XTENSA_TYPES_H | 12 | #define _XTENSA_TYPES_H |
13 | 13 | ||
14 | #include <asm-generic/int-ll64.h> | ||
14 | 15 | ||
15 | #ifdef __ASSEMBLY__ | 16 | #ifdef __ASSEMBLY__ |
16 | # define __XTENSA_UL(x) (x) | 17 | # define __XTENSA_UL(x) (x) |
@@ -25,42 +26,10 @@ | |||
25 | typedef unsigned short umode_t; | 26 | typedef unsigned short umode_t; |
26 | 27 | ||
27 | /* | 28 | /* |
28 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
29 | * header files exported to user space | ||
30 | */ | ||
31 | |||
32 | typedef __signed__ char __s8; | ||
33 | typedef unsigned char __u8; | ||
34 | |||
35 | typedef __signed__ short __s16; | ||
36 | typedef unsigned short __u16; | ||
37 | |||
38 | typedef __signed__ int __s32; | ||
39 | typedef unsigned int __u32; | ||
40 | |||
41 | #if defined(__GNUC__) | ||
42 | __extension__ typedef __signed__ long long __s64; | ||
43 | __extension__ typedef unsigned long long __u64; | ||
44 | #endif | ||
45 | |||
46 | /* | ||
47 | * These aren't exported outside the kernel to avoid name space clashes | 29 | * These aren't exported outside the kernel to avoid name space clashes |
48 | */ | 30 | */ |
49 | #ifdef __KERNEL__ | 31 | #ifdef __KERNEL__ |
50 | 32 | ||
51 | typedef __signed__ char s8; | ||
52 | typedef unsigned char u8; | ||
53 | |||
54 | typedef __signed__ short s16; | ||
55 | typedef unsigned short u16; | ||
56 | |||
57 | typedef __signed__ int s32; | ||
58 | typedef unsigned int u32; | ||
59 | |||
60 | typedef __signed__ long long s64; | ||
61 | typedef unsigned long long u64; | ||
62 | |||
63 | |||
64 | #define BITS_PER_LONG 32 | 33 | #define BITS_PER_LONG 32 |
65 | 34 | ||
66 | /* Dma addresses are 32-bits wide. */ | 35 | /* Dma addresses are 32-bits wide. */ |
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index 224658b8d806..833d208c25d6 100644 --- a/include/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h | |||
@@ -57,10 +57,14 @@ static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num, | |||
57 | struct scatterlist *sg2) | 57 | struct scatterlist *sg2) |
58 | { | 58 | { |
59 | sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0); | 59 | sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0); |
60 | sg1[num - 1].page_link &= ~0x02; | ||
60 | } | 61 | } |
61 | 62 | ||
62 | static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) | 63 | static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) |
63 | { | 64 | { |
65 | if (sg_is_last(sg)) | ||
66 | return NULL; | ||
67 | |||
64 | return (++sg)->length ? sg : (void *)sg_page(sg); | 68 | return (++sg)->length ? sg : (void *)sg_page(sg); |
65 | } | 69 | } |
66 | 70 | ||
diff --git a/include/linux/Kbuild b/include/linux/Kbuild index 78fade0a1e35..b7d81b2a9041 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild | |||
@@ -346,6 +346,11 @@ unifdef-y += videodev.h | |||
346 | unifdef-y += virtio_config.h | 346 | unifdef-y += virtio_config.h |
347 | unifdef-y += virtio_blk.h | 347 | unifdef-y += virtio_blk.h |
348 | unifdef-y += virtio_net.h | 348 | unifdef-y += virtio_net.h |
349 | unifdef-y += virtio_9p.h | ||
350 | unifdef-y += virtio_balloon.h | ||
351 | unifdef-y += virtio_console.h | ||
352 | unifdef-y += virtio_pci.h | ||
353 | unifdef-y += virtio_ring.h | ||
349 | unifdef-y += vt.h | 354 | unifdef-y += vt.h |
350 | unifdef-y += wait.h | 355 | unifdef-y += wait.h |
351 | unifdef-y += wanrouter.h | 356 | unifdef-y += wanrouter.h |
diff --git a/include/linux/anon_inodes.h b/include/linux/anon_inodes.h index b2e1ba325b9a..6129e58ca7c9 100644 --- a/include/linux/anon_inodes.h +++ b/include/linux/anon_inodes.h | |||
@@ -8,8 +8,7 @@ | |||
8 | #ifndef _LINUX_ANON_INODES_H | 8 | #ifndef _LINUX_ANON_INODES_H |
9 | #define _LINUX_ANON_INODES_H | 9 | #define _LINUX_ANON_INODES_H |
10 | 10 | ||
11 | int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile, | 11 | int anon_inode_getfd(const char *name, const struct file_operations *fops, |
12 | const char *name, const struct file_operations *fops, | ||
13 | void *priv); | 12 | void *priv); |
14 | 13 | ||
15 | #endif /* _LINUX_ANON_INODES_H */ | 14 | #endif /* _LINUX_ANON_INODES_H */ |
diff --git a/include/linux/calc64.h b/include/linux/calc64.h deleted file mode 100644 index ebf4b8f38d88..000000000000 --- a/include/linux/calc64.h +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | #ifndef _LINUX_CALC64_H | ||
2 | #define _LINUX_CALC64_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <asm/div64.h> | ||
6 | |||
7 | /* | ||
8 | * This is a generic macro which is used when the architecture | ||
9 | * specific div64.h does not provide a optimized one. | ||
10 | * | ||
11 | * The 64bit dividend is divided by the divisor (data type long), the | ||
12 | * result is returned and the remainder stored in the variable | ||
13 | * referenced by remainder (data type long *). In contrast to the | ||
14 | * do_div macro the dividend is kept intact. | ||
15 | */ | ||
16 | #ifndef div_long_long_rem | ||
17 | #define div_long_long_rem(dividend, divisor, remainder) \ | ||
18 | do_div_llr((dividend), divisor, remainder) | ||
19 | |||
20 | static inline unsigned long do_div_llr(const long long dividend, | ||
21 | const long divisor, long *remainder) | ||
22 | { | ||
23 | u64 result = dividend; | ||
24 | |||
25 | *(remainder) = do_div(result, divisor); | ||
26 | return (unsigned long) result; | ||
27 | } | ||
28 | #endif | ||
29 | |||
30 | /* | ||
31 | * Sign aware variation of the above. On some architectures a | ||
32 | * negative dividend leads to an divide overflow exception, which | ||
33 | * is avoided by the sign check. | ||
34 | */ | ||
35 | static inline long div_long_long_rem_signed(const long long dividend, | ||
36 | const long divisor, long *remainder) | ||
37 | { | ||
38 | long res; | ||
39 | |||
40 | if (unlikely(dividend < 0)) { | ||
41 | res = -div_long_long_rem(-dividend, divisor, remainder); | ||
42 | *remainder = -(*remainder); | ||
43 | } else | ||
44 | res = div_long_long_rem(dividend, divisor, remainder); | ||
45 | |||
46 | return res; | ||
47 | } | ||
48 | |||
49 | #endif | ||
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 35094479ca55..55e434feec99 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h | |||
@@ -93,6 +93,8 @@ struct clocksource { | |||
93 | #endif | 93 | #endif |
94 | }; | 94 | }; |
95 | 95 | ||
96 | extern struct clocksource *clock; /* current clocksource */ | ||
97 | |||
96 | /* | 98 | /* |
97 | * Clock source flags bits:: | 99 | * Clock source flags bits:: |
98 | */ | 100 | */ |
diff --git a/include/linux/compat.h b/include/linux/compat.h index 8fa7857e153b..cf8d11cad5ae 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h | |||
@@ -65,10 +65,11 @@ struct compat_timex { | |||
65 | compat_long_t calcnt; | 65 | compat_long_t calcnt; |
66 | compat_long_t errcnt; | 66 | compat_long_t errcnt; |
67 | compat_long_t stbcnt; | 67 | compat_long_t stbcnt; |
68 | compat_int_t tai; | ||
68 | 69 | ||
69 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; | 70 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; |
70 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; | 71 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; |
71 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; | 72 | compat_int_t :32; compat_int_t :32; compat_int_t :32; |
72 | }; | 73 | }; |
73 | 74 | ||
74 | #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) | 75 | #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) |
diff --git a/include/linux/device.h b/include/linux/device.h index 832fb0eb2933..8c23e3dfe3ac 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -380,6 +380,12 @@ struct device { | |||
380 | /* Get the wakeup routines, which depend on struct device */ | 380 | /* Get the wakeup routines, which depend on struct device */ |
381 | #include <linux/pm_wakeup.h> | 381 | #include <linux/pm_wakeup.h> |
382 | 382 | ||
383 | static inline const char *dev_name(struct device *dev) | ||
384 | { | ||
385 | /* will be changed into kobject_name(&dev->kobj) in the near future */ | ||
386 | return dev->bus_id; | ||
387 | } | ||
388 | |||
383 | #ifdef CONFIG_NUMA | 389 | #ifdef CONFIG_NUMA |
384 | static inline int dev_to_node(struct device *dev) | 390 | static inline int dev_to_node(struct device *dev) |
385 | { | 391 | { |
@@ -478,7 +484,7 @@ extern void sysdev_shutdown(void); | |||
478 | extern const char *dev_driver_string(struct device *dev); | 484 | extern const char *dev_driver_string(struct device *dev); |
479 | #define dev_printk(level, dev, format, arg...) \ | 485 | #define dev_printk(level, dev, format, arg...) \ |
480 | printk(level "%s %s: " format , dev_driver_string(dev) , \ | 486 | printk(level "%s %s: " format , dev_driver_string(dev) , \ |
481 | (dev)->bus_id , ## arg) | 487 | dev_name(dev) , ## arg) |
482 | 488 | ||
483 | #define dev_emerg(dev, format, arg...) \ | 489 | #define dev_emerg(dev, format, arg...) \ |
484 | dev_printk(KERN_EMERG , dev , format , ## arg) | 490 | dev_printk(KERN_EMERG , dev , format , ## arg) |
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h new file mode 100644 index 000000000000..a118f3c0b240 --- /dev/null +++ b/include/linux/fdtable.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * descriptor table internals; you almost certainly want file.h instead. | ||
3 | */ | ||
4 | |||
5 | #ifndef __LINUX_FDTABLE_H | ||
6 | #define __LINUX_FDTABLE_H | ||
7 | |||
8 | #include <asm/atomic.h> | ||
9 | #include <linux/posix_types.h> | ||
10 | #include <linux/compiler.h> | ||
11 | #include <linux/spinlock.h> | ||
12 | #include <linux/rcupdate.h> | ||
13 | #include <linux/types.h> | ||
14 | |||
15 | /* | ||
16 | * The default fd array needs to be at least BITS_PER_LONG, | ||
17 | * as this is the granularity returned by copy_fdset(). | ||
18 | */ | ||
19 | #define NR_OPEN_DEFAULT BITS_PER_LONG | ||
20 | |||
21 | /* | ||
22 | * The embedded_fd_set is a small fd_set, | ||
23 | * suitable for most tasks (which open <= BITS_PER_LONG files) | ||
24 | */ | ||
25 | struct embedded_fd_set { | ||
26 | unsigned long fds_bits[1]; | ||
27 | }; | ||
28 | |||
29 | struct fdtable { | ||
30 | unsigned int max_fds; | ||
31 | struct file ** fd; /* current fd array */ | ||
32 | fd_set *close_on_exec; | ||
33 | fd_set *open_fds; | ||
34 | struct rcu_head rcu; | ||
35 | struct fdtable *next; | ||
36 | }; | ||
37 | |||
38 | /* | ||
39 | * Open file table structure | ||
40 | */ | ||
41 | struct files_struct { | ||
42 | /* | ||
43 | * read mostly part | ||
44 | */ | ||
45 | atomic_t count; | ||
46 | struct fdtable *fdt; | ||
47 | struct fdtable fdtab; | ||
48 | /* | ||
49 | * written part on a separate cache line in SMP | ||
50 | */ | ||
51 | spinlock_t file_lock ____cacheline_aligned_in_smp; | ||
52 | int next_fd; | ||
53 | struct embedded_fd_set close_on_exec_init; | ||
54 | struct embedded_fd_set open_fds_init; | ||
55 | struct file * fd_array[NR_OPEN_DEFAULT]; | ||
56 | }; | ||
57 | |||
58 | #define files_fdtable(files) (rcu_dereference((files)->fdt)) | ||
59 | |||
60 | extern struct kmem_cache *filp_cachep; | ||
61 | |||
62 | struct file_operations; | ||
63 | struct vfsmount; | ||
64 | struct dentry; | ||
65 | |||
66 | extern int expand_files(struct files_struct *, int nr); | ||
67 | extern void free_fdtable_rcu(struct rcu_head *rcu); | ||
68 | extern void __init files_defer_init(void); | ||
69 | |||
70 | static inline void free_fdtable(struct fdtable *fdt) | ||
71 | { | ||
72 | call_rcu(&fdt->rcu, free_fdtable_rcu); | ||
73 | } | ||
74 | |||
75 | static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) | ||
76 | { | ||
77 | struct file * file = NULL; | ||
78 | struct fdtable *fdt = files_fdtable(files); | ||
79 | |||
80 | if (fd < fdt->max_fds) | ||
81 | file = rcu_dereference(fdt->fd[fd]); | ||
82 | return file; | ||
83 | } | ||
84 | |||
85 | /* | ||
86 | * Check whether the specified fd has an open file. | ||
87 | */ | ||
88 | #define fcheck(fd) fcheck_files(current->files, fd) | ||
89 | |||
90 | struct task_struct; | ||
91 | |||
92 | struct files_struct *get_files_struct(struct task_struct *); | ||
93 | void put_files_struct(struct files_struct *fs); | ||
94 | void reset_files_struct(struct files_struct *); | ||
95 | int unshare_files(struct files_struct **); | ||
96 | |||
97 | extern struct kmem_cache *files_cachep; | ||
98 | |||
99 | #endif /* __LINUX_FDTABLE_H */ | ||
diff --git a/include/linux/file.h b/include/linux/file.h index 69baf5a4f0a5..27c64bdc68c9 100644 --- a/include/linux/file.h +++ b/include/linux/file.h | |||
@@ -5,59 +5,11 @@ | |||
5 | #ifndef __LINUX_FILE_H | 5 | #ifndef __LINUX_FILE_H |
6 | #define __LINUX_FILE_H | 6 | #define __LINUX_FILE_H |
7 | 7 | ||
8 | #include <asm/atomic.h> | ||
9 | #include <linux/posix_types.h> | ||
10 | #include <linux/compiler.h> | 8 | #include <linux/compiler.h> |
11 | #include <linux/spinlock.h> | ||
12 | #include <linux/rcupdate.h> | ||
13 | #include <linux/types.h> | 9 | #include <linux/types.h> |
10 | #include <linux/posix_types.h> | ||
14 | 11 | ||
15 | /* | 12 | struct file; |
16 | * The default fd array needs to be at least BITS_PER_LONG, | ||
17 | * as this is the granularity returned by copy_fdset(). | ||
18 | */ | ||
19 | #define NR_OPEN_DEFAULT BITS_PER_LONG | ||
20 | |||
21 | /* | ||
22 | * The embedded_fd_set is a small fd_set, | ||
23 | * suitable for most tasks (which open <= BITS_PER_LONG files) | ||
24 | */ | ||
25 | struct embedded_fd_set { | ||
26 | unsigned long fds_bits[1]; | ||
27 | }; | ||
28 | |||
29 | struct fdtable { | ||
30 | unsigned int max_fds; | ||
31 | struct file ** fd; /* current fd array */ | ||
32 | fd_set *close_on_exec; | ||
33 | fd_set *open_fds; | ||
34 | struct rcu_head rcu; | ||
35 | struct fdtable *next; | ||
36 | }; | ||
37 | |||
38 | /* | ||
39 | * Open file table structure | ||
40 | */ | ||
41 | struct files_struct { | ||
42 | /* | ||
43 | * read mostly part | ||
44 | */ | ||
45 | atomic_t count; | ||
46 | struct fdtable *fdt; | ||
47 | struct fdtable fdtab; | ||
48 | /* | ||
49 | * written part on a separate cache line in SMP | ||
50 | */ | ||
51 | spinlock_t file_lock ____cacheline_aligned_in_smp; | ||
52 | int next_fd; | ||
53 | struct embedded_fd_set close_on_exec_init; | ||
54 | struct embedded_fd_set open_fds_init; | ||
55 | struct file * fd_array[NR_OPEN_DEFAULT]; | ||
56 | }; | ||
57 | |||
58 | #define files_fdtable(files) (rcu_dereference((files)->fdt)) | ||
59 | |||
60 | extern struct kmem_cache *filp_cachep; | ||
61 | 13 | ||
62 | extern void __fput(struct file *); | 14 | extern void __fput(struct file *); |
63 | extern void fput(struct file *); | 15 | extern void fput(struct file *); |
@@ -85,41 +37,7 @@ extern void put_filp(struct file *); | |||
85 | extern int get_unused_fd(void); | 37 | extern int get_unused_fd(void); |
86 | extern int get_unused_fd_flags(int flags); | 38 | extern int get_unused_fd_flags(int flags); |
87 | extern void put_unused_fd(unsigned int fd); | 39 | extern void put_unused_fd(unsigned int fd); |
88 | struct kmem_cache; | ||
89 | |||
90 | extern int expand_files(struct files_struct *, int nr); | ||
91 | extern void free_fdtable_rcu(struct rcu_head *rcu); | ||
92 | extern void __init files_defer_init(void); | ||
93 | |||
94 | static inline void free_fdtable(struct fdtable *fdt) | ||
95 | { | ||
96 | call_rcu(&fdt->rcu, free_fdtable_rcu); | ||
97 | } | ||
98 | |||
99 | static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) | ||
100 | { | ||
101 | struct file * file = NULL; | ||
102 | struct fdtable *fdt = files_fdtable(files); | ||
103 | |||
104 | if (fd < fdt->max_fds) | ||
105 | file = rcu_dereference(fdt->fd[fd]); | ||
106 | return file; | ||
107 | } | ||
108 | |||
109 | /* | ||
110 | * Check whether the specified fd has an open file. | ||
111 | */ | ||
112 | #define fcheck(fd) fcheck_files(current->files, fd) | ||
113 | 40 | ||
114 | extern void fd_install(unsigned int fd, struct file *file); | 41 | extern void fd_install(unsigned int fd, struct file *file); |
115 | 42 | ||
116 | struct task_struct; | ||
117 | |||
118 | struct files_struct *get_files_struct(struct task_struct *); | ||
119 | void put_files_struct(struct files_struct *fs); | ||
120 | void reset_files_struct(struct files_struct *); | ||
121 | int unshare_files(struct files_struct **); | ||
122 | |||
123 | extern struct kmem_cache *files_cachep; | ||
124 | |||
125 | #endif /* __LINUX_FILE_H */ | 43 | #endif /* __LINUX_FILE_H */ |
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 31a4d653389f..6d93dce61cbb 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h | |||
@@ -316,6 +316,15 @@ static inline int hrtimer_is_queued(struct hrtimer *timer) | |||
316 | (HRTIMER_STATE_ENQUEUED | HRTIMER_STATE_PENDING); | 316 | (HRTIMER_STATE_ENQUEUED | HRTIMER_STATE_PENDING); |
317 | } | 317 | } |
318 | 318 | ||
319 | /* | ||
320 | * Helper function to check, whether the timer is running the callback | ||
321 | * function | ||
322 | */ | ||
323 | static inline int hrtimer_callback_running(struct hrtimer *timer) | ||
324 | { | ||
325 | return timer->state & HRTIMER_STATE_CALLBACK; | ||
326 | } | ||
327 | |||
319 | /* Forward a hrtimer so it expires after now: */ | 328 | /* Forward a hrtimer so it expires after now: */ |
320 | extern u64 | 329 | extern u64 |
321 | hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval); | 330 | hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval); |
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index bf6b8a61f8db..b24c2875aa05 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef _LINUX__INIT_TASK_H | 1 | #ifndef _LINUX__INIT_TASK_H |
2 | #define _LINUX__INIT_TASK_H | 2 | #define _LINUX__INIT_TASK_H |
3 | 3 | ||
4 | #include <linux/file.h> | 4 | #include <linux/fdtable.h> |
5 | #include <linux/rcupdate.h> | 5 | #include <linux/rcupdate.h> |
6 | #include <linux/irqflags.h> | 6 | #include <linux/irqflags.h> |
7 | #include <linux/utsname.h> | 7 | #include <linux/utsname.h> |
diff --git a/include/linux/io.h b/include/linux/io.h index 3a03a3604cce..6c7f0ba0d5fa 100644 --- a/include/linux/io.h +++ b/include/linux/io.h | |||
@@ -65,5 +65,6 @@ void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset, | |||
65 | void devm_iounmap(struct device *dev, void __iomem *addr); | 65 | void devm_iounmap(struct device *dev, void __iomem *addr); |
66 | int check_signature(const volatile void __iomem *io_addr, | 66 | int check_signature(const volatile void __iomem *io_addr, |
67 | const unsigned char *signature, int length); | 67 | const unsigned char *signature, int length); |
68 | void devm_ioremap_release(struct device *dev, void *res); | ||
68 | 69 | ||
69 | #endif /* _LINUX_IO_H */ | 70 | #endif /* _LINUX_IO_H */ |
diff --git a/include/linux/irq.h b/include/linux/irq.h index 1883a85625dd..552e0ec269c9 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
@@ -61,6 +61,7 @@ typedef void (*irq_flow_handler_t)(unsigned int irq, | |||
61 | #define IRQ_WAKEUP 0x00100000 /* IRQ triggers system wakeup */ | 61 | #define IRQ_WAKEUP 0x00100000 /* IRQ triggers system wakeup */ |
62 | #define IRQ_MOVE_PENDING 0x00200000 /* need to re-target IRQ destination */ | 62 | #define IRQ_MOVE_PENDING 0x00200000 /* need to re-target IRQ destination */ |
63 | #define IRQ_NO_BALANCING 0x00400000 /* IRQ is excluded from balancing */ | 63 | #define IRQ_NO_BALANCING 0x00400000 /* IRQ is excluded from balancing */ |
64 | #define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */ | ||
64 | 65 | ||
65 | #ifdef CONFIG_IRQ_PER_CPU | 66 | #ifdef CONFIG_IRQ_PER_CPU |
66 | # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) | 67 | # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) |
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 33ef710dac24..abb6ac639e8e 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef _LINUX_JIFFIES_H | 1 | #ifndef _LINUX_JIFFIES_H |
2 | #define _LINUX_JIFFIES_H | 2 | #define _LINUX_JIFFIES_H |
3 | 3 | ||
4 | #include <linux/calc64.h> | 4 | #include <linux/math64.h> |
5 | #include <linux/kernel.h> | 5 | #include <linux/kernel.h> |
6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
7 | #include <linux/time.h> | 7 | #include <linux/time.h> |
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index 9757b1a6d9dc..6adcc297e354 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h | |||
@@ -261,10 +261,12 @@ struct kgdb_io { | |||
261 | 261 | ||
262 | extern struct kgdb_arch arch_kgdb_ops; | 262 | extern struct kgdb_arch arch_kgdb_ops; |
263 | 263 | ||
264 | extern unsigned long __weak kgdb_arch_pc(int exception, struct pt_regs *regs); | ||
265 | |||
264 | extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops); | 266 | extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops); |
265 | extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops); | 267 | extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops); |
266 | 268 | ||
267 | extern int kgdb_hex2long(char **ptr, long *long_val); | 269 | extern int kgdb_hex2long(char **ptr, unsigned long *long_val); |
268 | extern int kgdb_mem2hex(char *mem, char *buf, int count); | 270 | extern int kgdb_mem2hex(char *mem, char *buf, int count); |
269 | extern int kgdb_hex2mem(char *buf, char *mem, int count); | 271 | extern int kgdb_hex2mem(char *buf, char *mem, int count); |
270 | 272 | ||
diff --git a/include/linux/math64.h b/include/linux/math64.h new file mode 100644 index 000000000000..c1a5f81501ff --- /dev/null +++ b/include/linux/math64.h | |||
@@ -0,0 +1,84 @@ | |||
1 | #ifndef _LINUX_MATH64_H | ||
2 | #define _LINUX_MATH64_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <asm/div64.h> | ||
6 | |||
7 | #if BITS_PER_LONG == 64 | ||
8 | |||
9 | /** | ||
10 | * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder | ||
11 | * | ||
12 | * This is commonly provided by 32bit archs to provide an optimized 64bit | ||
13 | * divide. | ||
14 | */ | ||
15 | static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) | ||
16 | { | ||
17 | *remainder = dividend % divisor; | ||
18 | return dividend / divisor; | ||
19 | } | ||
20 | |||
21 | /** | ||
22 | * div_s64_rem - signed 64bit divide with 32bit divisor with remainder | ||
23 | */ | ||
24 | static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) | ||
25 | { | ||
26 | *remainder = dividend % divisor; | ||
27 | return dividend / divisor; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * div64_u64 - unsigned 64bit divide with 64bit divisor | ||
32 | */ | ||
33 | static inline u64 div64_u64(u64 dividend, u64 divisor) | ||
34 | { | ||
35 | return dividend / divisor; | ||
36 | } | ||
37 | |||
38 | #elif BITS_PER_LONG == 32 | ||
39 | |||
40 | #ifndef div_u64_rem | ||
41 | static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) | ||
42 | { | ||
43 | *remainder = do_div(dividend, divisor); | ||
44 | return dividend; | ||
45 | } | ||
46 | #endif | ||
47 | |||
48 | #ifndef div_s64_rem | ||
49 | extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder); | ||
50 | #endif | ||
51 | |||
52 | #ifndef div64_u64 | ||
53 | extern u64 div64_u64(u64 dividend, u64 divisor); | ||
54 | #endif | ||
55 | |||
56 | #endif /* BITS_PER_LONG */ | ||
57 | |||
58 | /** | ||
59 | * div_u64 - unsigned 64bit divide with 32bit divisor | ||
60 | * | ||
61 | * This is the most common 64bit divide and should be used if possible, | ||
62 | * as many 32bit archs can optimize this variant better than a full 64bit | ||
63 | * divide. | ||
64 | */ | ||
65 | #ifndef div_u64 | ||
66 | static inline u64 div_u64(u64 dividend, u32 divisor) | ||
67 | { | ||
68 | u32 remainder; | ||
69 | return div_u64_rem(dividend, divisor, &remainder); | ||
70 | } | ||
71 | #endif | ||
72 | |||
73 | /** | ||
74 | * div_s64 - signed 64bit divide with 32bit divisor | ||
75 | */ | ||
76 | #ifndef div_s64 | ||
77 | static inline s64 div_s64(s64 dividend, s32 divisor) | ||
78 | { | ||
79 | s32 remainder; | ||
80 | return div_s64_rem(dividend, divisor, &remainder); | ||
81 | } | ||
82 | #endif | ||
83 | |||
84 | #endif /* _LINUX_MATH64_H */ | ||
diff --git a/include/linux/module.h b/include/linux/module.h index 819c4e889bf1..3e03b1acbc94 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -190,7 +190,7 @@ void *__symbol_get_gpl(const char *symbol); | |||
190 | extern typeof(sym) sym; \ | 190 | extern typeof(sym) sym; \ |
191 | __CRC_SYMBOL(sym, sec) \ | 191 | __CRC_SYMBOL(sym, sec) \ |
192 | static const char __kstrtab_##sym[] \ | 192 | static const char __kstrtab_##sym[] \ |
193 | __attribute__((section("__ksymtab_strings"))) \ | 193 | __attribute__((section("__ksymtab_strings"), aligned(1))) \ |
194 | = MODULE_SYMBOL_PREFIX #sym; \ | 194 | = MODULE_SYMBOL_PREFIX #sym; \ |
195 | static const struct kernel_symbol __ksymtab_##sym \ | 195 | static const struct kernel_symbol __ksymtab_##sym \ |
196 | __used \ | 196 | __used \ |
@@ -229,23 +229,6 @@ enum module_state | |||
229 | MODULE_STATE_GOING, | 229 | MODULE_STATE_GOING, |
230 | }; | 230 | }; |
231 | 231 | ||
232 | /* Similar stuff for section attributes. */ | ||
233 | struct module_sect_attr | ||
234 | { | ||
235 | struct module_attribute mattr; | ||
236 | char *name; | ||
237 | unsigned long address; | ||
238 | }; | ||
239 | |||
240 | struct module_sect_attrs | ||
241 | { | ||
242 | struct attribute_group grp; | ||
243 | int nsections; | ||
244 | struct module_sect_attr attrs[0]; | ||
245 | }; | ||
246 | |||
247 | struct module_param_attrs; | ||
248 | |||
249 | struct module | 232 | struct module |
250 | { | 233 | { |
251 | enum module_state state; | 234 | enum module_state state; |
diff --git a/include/linux/mtd/jedec.h b/include/linux/mtd/jedec.h deleted file mode 100644 index 9006feb218b9..000000000000 --- a/include/linux/mtd/jedec.h +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | |||
2 | /* JEDEC Flash Interface. | ||
3 | * This is an older type of interface for self programming flash. It is | ||
4 | * commonly use in older AMD chips and is obsolete compared with CFI. | ||
5 | * It is called JEDEC because the JEDEC association distributes the ID codes | ||
6 | * for the chips. | ||
7 | * | ||
8 | * See the AMD flash databook for information on how to operate the interface. | ||
9 | * | ||
10 | * $Id: jedec.h,v 1.4 2005/11/07 11:14:54 gleixner Exp $ | ||
11 | */ | ||
12 | |||
13 | #ifndef __LINUX_MTD_JEDEC_H__ | ||
14 | #define __LINUX_MTD_JEDEC_H__ | ||
15 | |||
16 | #include <linux/types.h> | ||
17 | |||
18 | #define MAX_JEDEC_CHIPS 16 | ||
19 | |||
20 | // Listing of all supported chips and their information | ||
21 | struct JEDECTable | ||
22 | { | ||
23 | __u16 jedec; | ||
24 | char *name; | ||
25 | unsigned long size; | ||
26 | unsigned long sectorsize; | ||
27 | __u32 capabilities; | ||
28 | }; | ||
29 | |||
30 | // JEDEC being 0 is the end of the chip array | ||
31 | struct jedec_flash_chip | ||
32 | { | ||
33 | __u16 jedec; | ||
34 | unsigned long size; | ||
35 | unsigned long sectorsize; | ||
36 | |||
37 | // *(__u8*)(base + (adder << addrshift)) = data << datashift | ||
38 | // Address size = size << addrshift | ||
39 | unsigned long base; // Byte 0 of the flash, will be unaligned | ||
40 | unsigned int datashift; // Useful for 32bit/16bit accesses | ||
41 | unsigned int addrshift; | ||
42 | unsigned long offset; // linerized start. base==offset for unbanked, uninterleaved flash | ||
43 | |||
44 | __u32 capabilities; | ||
45 | |||
46 | // These markers are filled in by the flash_chip_scan function | ||
47 | unsigned long start; | ||
48 | unsigned long length; | ||
49 | }; | ||
50 | |||
51 | struct jedec_private | ||
52 | { | ||
53 | unsigned long size; // Total size of all the devices | ||
54 | |||
55 | /* Bank handling. If sum(bank_fill) == size then this is linear flash. | ||
56 | Otherwise the mapping has holes in it. bank_fill may be used to | ||
57 | find the holes, but in the common symetric case | ||
58 | bank_fill[0] == bank_fill[*], thus addresses may be computed | ||
59 | mathmatically. bank_fill must be powers of two */ | ||
60 | unsigned is_banked; | ||
61 | unsigned long bank_fill[MAX_JEDEC_CHIPS]; | ||
62 | |||
63 | struct jedec_flash_chip chips[MAX_JEDEC_CHIPS]; | ||
64 | }; | ||
65 | |||
66 | #endif | ||
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 0a13bb35f044..245f9098e171 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -143,10 +143,12 @@ struct mtd_info { | |||
143 | int (*erase) (struct mtd_info *mtd, struct erase_info *instr); | 143 | int (*erase) (struct mtd_info *mtd, struct erase_info *instr); |
144 | 144 | ||
145 | /* This stuff for eXecute-In-Place */ | 145 | /* This stuff for eXecute-In-Place */ |
146 | int (*point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf); | 146 | /* phys is optional and may be set to NULL */ |
147 | int (*point) (struct mtd_info *mtd, loff_t from, size_t len, | ||
148 | size_t *retlen, void **virt, resource_size_t *phys); | ||
147 | 149 | ||
148 | /* We probably shouldn't allow XIP if the unpoint isn't a NULL */ | 150 | /* We probably shouldn't allow XIP if the unpoint isn't a NULL */ |
149 | void (*unpoint) (struct mtd_info *mtd, u_char * addr, loff_t from, size_t len); | 151 | void (*unpoint) (struct mtd_info *mtd, loff_t from, size_t len); |
150 | 152 | ||
151 | 153 | ||
152 | int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); | 154 | int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
diff --git a/include/linux/mtd/pmc551.h b/include/linux/mtd/pmc551.h index a7f6d20ad407..5cc070c24d88 100644 --- a/include/linux/mtd/pmc551.h +++ b/include/linux/mtd/pmc551.h | |||
@@ -36,8 +36,9 @@ struct mypriv { | |||
36 | * Function Prototypes | 36 | * Function Prototypes |
37 | */ | 37 | */ |
38 | static int pmc551_erase(struct mtd_info *, struct erase_info *); | 38 | static int pmc551_erase(struct mtd_info *, struct erase_info *); |
39 | static void pmc551_unpoint(struct mtd_info *, u_char *, loff_t, size_t); | 39 | static void pmc551_unpoint(struct mtd_info *, loff_t, size_t); |
40 | static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf); | 40 | static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, |
41 | size_t *retlen, void **virt, resource_size_t *phys); | ||
41 | static int pmc551_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); | 42 | static int pmc551_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); |
42 | static int pmc551_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); | 43 | static int pmc551_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); |
43 | 44 | ||
diff --git a/include/linux/pci.h b/include/linux/pci.h index 96acd0dae241..509159bcd4e7 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/mod_devicetable.h> | 44 | #include <linux/mod_devicetable.h> |
45 | 45 | ||
46 | #include <linux/types.h> | 46 | #include <linux/types.h> |
47 | #include <linux/init.h> | ||
47 | #include <linux/ioport.h> | 48 | #include <linux/ioport.h> |
48 | #include <linux/list.h> | 49 | #include <linux/list.h> |
49 | #include <linux/compiler.h> | 50 | #include <linux/compiler.h> |
@@ -474,7 +475,7 @@ extern struct pci_bus *pci_find_bus(int domain, int busnr); | |||
474 | void pci_bus_add_devices(struct pci_bus *bus); | 475 | void pci_bus_add_devices(struct pci_bus *bus); |
475 | struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, | 476 | struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, |
476 | struct pci_ops *ops, void *sysdata); | 477 | struct pci_ops *ops, void *sysdata); |
477 | static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, | 478 | static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops, |
478 | void *sysdata) | 479 | void *sysdata) |
479 | { | 480 | { |
480 | struct pci_bus *root_bus; | 481 | struct pci_bus *root_bus; |
@@ -666,7 +667,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, | |||
666 | 667 | ||
667 | void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), | 668 | void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), |
668 | void *userdata); | 669 | void *userdata); |
669 | int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix); | 670 | int pci_cfg_space_size_ext(struct pci_dev *dev); |
670 | int pci_cfg_space_size(struct pci_dev *dev); | 671 | int pci_cfg_space_size(struct pci_dev *dev); |
671 | unsigned char pci_bus_max_busnr(struct pci_bus *bus); | 672 | unsigned char pci_bus_max_busnr(struct pci_bus *bus); |
672 | 673 | ||
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index e5a53daf17f1..cf6dbd759395 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -1429,6 +1429,7 @@ | |||
1429 | #define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9 | 1429 | #define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9 |
1430 | #define PCI_DEVICE_ID_NEO_2RJ45 0x00CA | 1430 | #define PCI_DEVICE_ID_NEO_2RJ45 0x00CA |
1431 | #define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB | 1431 | #define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB |
1432 | #define PCIE_DEVICE_ID_NEO_4_IBM 0x00F4 | ||
1432 | 1433 | ||
1433 | #define PCI_VENDOR_ID_XIRCOM 0x115d | 1434 | #define PCI_VENDOR_ID_XIRCOM 0x115d |
1434 | #define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101 | 1435 | #define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101 |
diff --git a/include/linux/pda_power.h b/include/linux/pda_power.h index 225beb136807..cb7d10f30763 100644 --- a/include/linux/pda_power.h +++ b/include/linux/pda_power.h | |||
@@ -16,10 +16,14 @@ | |||
16 | #define PDA_POWER_CHARGE_AC (1 << 0) | 16 | #define PDA_POWER_CHARGE_AC (1 << 0) |
17 | #define PDA_POWER_CHARGE_USB (1 << 1) | 17 | #define PDA_POWER_CHARGE_USB (1 << 1) |
18 | 18 | ||
19 | struct device; | ||
20 | |||
19 | struct pda_power_pdata { | 21 | struct pda_power_pdata { |
22 | int (*init)(struct device *dev); | ||
20 | int (*is_ac_online)(void); | 23 | int (*is_ac_online)(void); |
21 | int (*is_usb_online)(void); | 24 | int (*is_usb_online)(void); |
22 | void (*set_charge)(int flags); | 25 | void (*set_charge)(int flags); |
26 | void (*exit)(struct device *dev); | ||
23 | 27 | ||
24 | char **supplied_to; | 28 | char **supplied_to; |
25 | size_t num_supplicants; | 29 | size_t num_supplicants; |
diff --git a/include/linux/poll.h b/include/linux/poll.h index 16d813b364ef..ef453828877a 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h | |||
@@ -117,6 +117,8 @@ void zero_fd_set(unsigned long nr, unsigned long *fdset) | |||
117 | extern int do_select(int n, fd_set_bits *fds, s64 *timeout); | 117 | extern int do_select(int n, fd_set_bits *fds, s64 *timeout); |
118 | extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds, | 118 | extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds, |
119 | s64 *timeout); | 119 | s64 *timeout); |
120 | extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, | ||
121 | fd_set __user *exp, s64 *timeout); | ||
120 | 122 | ||
121 | #endif /* KERNEL */ | 123 | #endif /* KERNEL */ |
122 | 124 | ||
diff --git a/include/linux/quota.h b/include/linux/quota.h index 52e49dce6584..dcddfb200947 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h | |||
@@ -347,6 +347,9 @@ struct quota_info { | |||
347 | ((type) == USRQUOTA ? (sb_dqopt(sb)->flags & DQUOT_USR_SUSPENDED) : \ | 347 | ((type) == USRQUOTA ? (sb_dqopt(sb)->flags & DQUOT_USR_SUSPENDED) : \ |
348 | (sb_dqopt(sb)->flags & DQUOT_GRP_SUSPENDED)) | 348 | (sb_dqopt(sb)->flags & DQUOT_GRP_SUSPENDED)) |
349 | 349 | ||
350 | #define sb_any_quota_suspended(sb) (sb_has_quota_suspended(sb, USRQUOTA) | \ | ||
351 | sb_has_quota_suspended(sb, GRPQUOTA)) | ||
352 | |||
350 | int register_quota_format(struct quota_format_type *fmt); | 353 | int register_quota_format(struct quota_format_type *fmt); |
351 | void unregister_quota_format(struct quota_format_type *fmt); | 354 | void unregister_quota_format(struct quota_format_type *fmt); |
352 | 355 | ||
diff --git a/include/linux/rio.h b/include/linux/rio.h index c1c99c9643d3..dc0c75556c63 100644 --- a/include/linux/rio.h +++ b/include/linux/rio.h | |||
@@ -161,6 +161,8 @@ enum rio_phy_type { | |||
161 | * @ops: configuration space functions | 161 | * @ops: configuration space functions |
162 | * @id: Port ID, unique among all ports | 162 | * @id: Port ID, unique among all ports |
163 | * @index: Port index, unique among all port interfaces of the same type | 163 | * @index: Port index, unique among all port interfaces of the same type |
164 | * @sys_size: RapidIO common transport system size | ||
165 | * @phy_type: RapidIO phy type | ||
164 | * @name: Port name string | 166 | * @name: Port name string |
165 | * @priv: Master port private data | 167 | * @priv: Master port private data |
166 | */ | 168 | */ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 03c238088aee..0c35b0343a76 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -158,6 +158,8 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) | |||
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | extern unsigned long long time_sync_thresh; | ||
162 | |||
161 | /* | 163 | /* |
162 | * Task state bitmask. NOTE! These bits are also | 164 | * Task state bitmask. NOTE! These bits are also |
163 | * encoded in fs/proc/array.c: get_task_state(). | 165 | * encoded in fs/proc/array.c: get_task_state(). |
@@ -1551,6 +1553,35 @@ static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask) | |||
1551 | 1553 | ||
1552 | extern unsigned long long sched_clock(void); | 1554 | extern unsigned long long sched_clock(void); |
1553 | 1555 | ||
1556 | #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK | ||
1557 | static inline void sched_clock_init(void) | ||
1558 | { | ||
1559 | } | ||
1560 | |||
1561 | static inline u64 sched_clock_cpu(int cpu) | ||
1562 | { | ||
1563 | return sched_clock(); | ||
1564 | } | ||
1565 | |||
1566 | static inline void sched_clock_tick(void) | ||
1567 | { | ||
1568 | } | ||
1569 | |||
1570 | static inline void sched_clock_idle_sleep_event(void) | ||
1571 | { | ||
1572 | } | ||
1573 | |||
1574 | static inline void sched_clock_idle_wakeup_event(u64 delta_ns) | ||
1575 | { | ||
1576 | } | ||
1577 | #else | ||
1578 | extern void sched_clock_init(void); | ||
1579 | extern u64 sched_clock_cpu(int cpu); | ||
1580 | extern void sched_clock_tick(void); | ||
1581 | extern void sched_clock_idle_sleep_event(void); | ||
1582 | extern void sched_clock_idle_wakeup_event(u64 delta_ns); | ||
1583 | #endif | ||
1584 | |||
1554 | /* | 1585 | /* |
1555 | * For kernel-internal use: high-speed (but slightly incorrect) per-cpu | 1586 | * For kernel-internal use: high-speed (but slightly incorrect) per-cpu |
1556 | * clock constructed from sched_clock(): | 1587 | * clock constructed from sched_clock(): |
@@ -1977,6 +2008,11 @@ static inline void clear_tsk_need_resched(struct task_struct *tsk) | |||
1977 | clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED); | 2008 | clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED); |
1978 | } | 2009 | } |
1979 | 2010 | ||
2011 | static inline int test_tsk_need_resched(struct task_struct *tsk) | ||
2012 | { | ||
2013 | return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED)); | ||
2014 | } | ||
2015 | |||
1980 | static inline int signal_pending(struct task_struct *p) | 2016 | static inline int signal_pending(struct task_struct *p) |
1981 | { | 2017 | { |
1982 | return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING)); | 2018 | return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING)); |
@@ -1991,7 +2027,7 @@ static inline int fatal_signal_pending(struct task_struct *p) | |||
1991 | 2027 | ||
1992 | static inline int need_resched(void) | 2028 | static inline int need_resched(void) |
1993 | { | 2029 | { |
1994 | return unlikely(test_thread_flag(TIF_NEED_RESCHED)); | 2030 | return unlikely(test_tsk_need_resched(current)); |
1995 | } | 2031 | } |
1996 | 2032 | ||
1997 | /* | 2033 | /* |
diff --git a/include/linux/string.h b/include/linux/string.h index c5d3fcad7b57..efdc44593b52 100644 --- a/include/linux/string.h +++ b/include/linux/string.h | |||
@@ -109,5 +109,7 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp); | |||
109 | extern char **argv_split(gfp_t gfp, const char *str, int *argcp); | 109 | extern char **argv_split(gfp_t gfp, const char *str, int *argcp); |
110 | extern void argv_free(char **argv); | 110 | extern void argv_free(char **argv); |
111 | 111 | ||
112 | extern bool sysfs_streq(const char *s1, const char *s2); | ||
113 | |||
112 | #endif | 114 | #endif |
113 | #endif /* _LINUX_STRING_H_ */ | 115 | #endif /* _LINUX_STRING_H_ */ |
diff --git a/include/linux/timex.h b/include/linux/timex.h index 8ea3e71ba7fa..fc6035d29d56 100644 --- a/include/linux/timex.h +++ b/include/linux/timex.h | |||
@@ -58,6 +58,8 @@ | |||
58 | 58 | ||
59 | #include <asm/param.h> | 59 | #include <asm/param.h> |
60 | 60 | ||
61 | #define NTP_API 4 /* NTP API version */ | ||
62 | |||
61 | /* | 63 | /* |
62 | * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen | 64 | * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen |
63 | * for a slightly underdamped convergence characteristic. SHIFT_KH | 65 | * for a slightly underdamped convergence characteristic. SHIFT_KH |
@@ -74,24 +76,22 @@ | |||
74 | #define MAXTC 10 /* maximum time constant (shift) */ | 76 | #define MAXTC 10 /* maximum time constant (shift) */ |
75 | 77 | ||
76 | /* | 78 | /* |
77 | * The SHIFT_UPDATE define establishes the decimal point of the | ||
78 | * time_offset variable which represents the current offset with | ||
79 | * respect to standard time. | ||
80 | * | ||
81 | * SHIFT_USEC defines the scaling (shift) of the time_freq and | 79 | * SHIFT_USEC defines the scaling (shift) of the time_freq and |
82 | * time_tolerance variables, which represent the current frequency | 80 | * time_tolerance variables, which represent the current frequency |
83 | * offset and maximum frequency tolerance. | 81 | * offset and maximum frequency tolerance. |
84 | */ | 82 | */ |
85 | #define SHIFT_UPDATE (SHIFT_HZ + 1) /* time offset scale (shift) */ | ||
86 | #define SHIFT_USEC 16 /* frequency offset scale (shift) */ | 83 | #define SHIFT_USEC 16 /* frequency offset scale (shift) */ |
87 | #define SHIFT_NSEC 12 /* kernel frequency offset scale */ | 84 | #define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC)) |
88 | 85 | #define PPM_SCALE_INV_SHIFT 20 | |
89 | #define MAXPHASE 512000L /* max phase error (us) */ | 86 | #define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \ |
90 | #define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */ | 87 | PPM_SCALE + 1) |
91 | #define MAXFREQ_NSEC (512000L << SHIFT_NSEC) /* max frequency error (ppb) */ | 88 | |
89 | #define MAXPHASE 500000000l /* max phase error (ns) */ | ||
90 | #define MAXFREQ 500000 /* max frequency error (ns/s) */ | ||
91 | #define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT) | ||
92 | #define MINSEC 256 /* min interval between updates (s) */ | 92 | #define MINSEC 256 /* min interval between updates (s) */ |
93 | #define MAXSEC 2048 /* max interval between updates (s) */ | 93 | #define MAXSEC 2048 /* max interval between updates (s) */ |
94 | #define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */ | 94 | #define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */ |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * syscall interface - used (mainly by NTP daemon) | 97 | * syscall interface - used (mainly by NTP daemon) |
@@ -121,9 +121,11 @@ struct timex { | |||
121 | long errcnt; /* calibration errors (ro) */ | 121 | long errcnt; /* calibration errors (ro) */ |
122 | long stbcnt; /* stability limit exceeded (ro) */ | 122 | long stbcnt; /* stability limit exceeded (ro) */ |
123 | 123 | ||
124 | int tai; /* TAI offset (ro) */ | ||
125 | |||
124 | int :32; int :32; int :32; int :32; | 126 | int :32; int :32; int :32; int :32; |
125 | int :32; int :32; int :32; int :32; | 127 | int :32; int :32; int :32; int :32; |
126 | int :32; int :32; int :32; int :32; | 128 | int :32; int :32; int :32; |
127 | }; | 129 | }; |
128 | 130 | ||
129 | /* | 131 | /* |
@@ -135,6 +137,9 @@ struct timex { | |||
135 | #define ADJ_ESTERROR 0x0008 /* estimated time error */ | 137 | #define ADJ_ESTERROR 0x0008 /* estimated time error */ |
136 | #define ADJ_STATUS 0x0010 /* clock status */ | 138 | #define ADJ_STATUS 0x0010 /* clock status */ |
137 | #define ADJ_TIMECONST 0x0020 /* pll time constant */ | 139 | #define ADJ_TIMECONST 0x0020 /* pll time constant */ |
140 | #define ADJ_TAI 0x0080 /* set TAI offset */ | ||
141 | #define ADJ_MICRO 0x1000 /* select microsecond resolution */ | ||
142 | #define ADJ_NANO 0x2000 /* select nanosecond resolution */ | ||
138 | #define ADJ_TICK 0x4000 /* tick value */ | 143 | #define ADJ_TICK 0x4000 /* tick value */ |
139 | #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ | 144 | #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ |
140 | #define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ | 145 | #define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ |
@@ -146,8 +151,6 @@ struct timex { | |||
146 | #define MOD_ESTERROR ADJ_ESTERROR | 151 | #define MOD_ESTERROR ADJ_ESTERROR |
147 | #define MOD_STATUS ADJ_STATUS | 152 | #define MOD_STATUS ADJ_STATUS |
148 | #define MOD_TIMECONST ADJ_TIMECONST | 153 | #define MOD_TIMECONST ADJ_TIMECONST |
149 | #define MOD_CLKB ADJ_TICK | ||
150 | #define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */ | ||
151 | 154 | ||
152 | 155 | ||
153 | /* | 156 | /* |
@@ -169,9 +172,13 @@ struct timex { | |||
169 | #define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ | 172 | #define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ |
170 | 173 | ||
171 | #define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ | 174 | #define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ |
175 | #define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ | ||
176 | #define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ | ||
177 | #define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ | ||
172 | 178 | ||
179 | /* read-only bits */ | ||
173 | #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ | 180 | #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ |
174 | STA_PPSERROR | STA_CLOCKERR) /* read-only bits */ | 181 | STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) |
175 | 182 | ||
176 | /* | 183 | /* |
177 | * Clock states (time_state) | 184 | * Clock states (time_state) |
@@ -203,10 +210,9 @@ extern int time_status; /* clock synchronization status bits */ | |||
203 | extern long time_maxerror; /* maximum error */ | 210 | extern long time_maxerror; /* maximum error */ |
204 | extern long time_esterror; /* estimated error */ | 211 | extern long time_esterror; /* estimated error */ |
205 | 212 | ||
206 | extern long time_freq; /* frequency offset (scaled ppm) */ | ||
207 | |||
208 | extern long time_adjust; /* The amount of adjtime left */ | 213 | extern long time_adjust; /* The amount of adjtime left */ |
209 | 214 | ||
215 | extern void ntp_init(void); | ||
210 | extern void ntp_clear(void); | 216 | extern void ntp_clear(void); |
211 | 217 | ||
212 | /** | 218 | /** |
@@ -225,7 +231,7 @@ static inline int ntp_synced(void) | |||
225 | __x < 0 ? -(-__x >> __s) : __x >> __s; \ | 231 | __x < 0 ? -(-__x >> __s) : __x >> __s; \ |
226 | }) | 232 | }) |
227 | 233 | ||
228 | #define TICK_LENGTH_SHIFT 32 | 234 | #define NTP_SCALE_SHIFT 32 |
229 | 235 | ||
230 | #ifdef CONFIG_NO_HZ | 236 | #ifdef CONFIG_NO_HZ |
231 | #define NTP_INTERVAL_FREQ (2) | 237 | #define NTP_INTERVAL_FREQ (2) |
@@ -234,8 +240,8 @@ static inline int ntp_synced(void) | |||
234 | #endif | 240 | #endif |
235 | #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) | 241 | #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) |
236 | 242 | ||
237 | /* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */ | 243 | /* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */ |
238 | extern u64 current_tick_length(void); | 244 | extern u64 tick_length; |
239 | 245 | ||
240 | extern void second_overflow(void); | 246 | extern void second_overflow(void); |
241 | extern void update_ntp_one_tick(void); | 247 | extern void update_ntp_one_tick(void); |
diff --git a/include/linux/usb/c67x00.h b/include/linux/usb/c67x00.h new file mode 100644 index 000000000000..83c6b45470ca --- /dev/null +++ b/include/linux/usb/c67x00.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * usb_c67x00.h: platform definitions for the Cypress C67X00 USB chip | ||
3 | * | ||
4 | * Copyright (C) 2006-2008 Barco N.V. | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
19 | * MA 02110-1301 USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _LINUX_USB_C67X00_H | ||
23 | #define _LINUX_USB_C67X00_H | ||
24 | |||
25 | /* SIE configuration */ | ||
26 | #define C67X00_SIE_UNUSED 0 | ||
27 | #define C67X00_SIE_HOST 1 | ||
28 | #define C67X00_SIE_PERIPHERAL_A 2 /* peripheral on A port */ | ||
29 | #define C67X00_SIE_PERIPHERAL_B 3 /* peripheral on B port */ | ||
30 | |||
31 | #define c67x00_sie_config(config, n) (((config)>>(4*(n)))&0x3) | ||
32 | |||
33 | #define C67X00_SIE1_UNUSED (C67X00_SIE_UNUSED << 0) | ||
34 | #define C67X00_SIE1_HOST (C67X00_SIE_HOST << 0) | ||
35 | #define C67X00_SIE1_PERIPHERAL_A (C67X00_SIE_PERIPHERAL_A << 0) | ||
36 | #define C67X00_SIE1_PERIPHERAL_B (C67X00_SIE_PERIPHERAL_B << 0) | ||
37 | |||
38 | #define C67X00_SIE2_UNUSED (C67X00_SIE_UNUSED << 4) | ||
39 | #define C67X00_SIE2_HOST (C67X00_SIE_HOST << 4) | ||
40 | #define C67X00_SIE2_PERIPHERAL_A (C67X00_SIE_PERIPHERAL_A << 4) | ||
41 | #define C67X00_SIE2_PERIPHERAL_B (C67X00_SIE_PERIPHERAL_B << 4) | ||
42 | |||
43 | struct c67x00_platform_data { | ||
44 | int sie_config; /* SIEs config (C67X00_SIEx_*) */ | ||
45 | unsigned long hpi_regstep; /* Step between HPI registers */ | ||
46 | }; | ||
47 | |||
48 | #endif /* _LINUX_USB_C67X00_H */ | ||
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index 7e0d3084f76c..73a2f4eb1f7a 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h | |||
@@ -455,7 +455,7 @@ struct usb_encryption_descriptor { | |||
455 | 455 | ||
456 | /*-------------------------------------------------------------------------*/ | 456 | /*-------------------------------------------------------------------------*/ |
457 | 457 | ||
458 | /* USB_DT_BOS: group of wireless capabilities */ | 458 | /* USB_DT_BOS: group of device-level capabilities */ |
459 | struct usb_bos_descriptor { | 459 | struct usb_bos_descriptor { |
460 | __u8 bLength; | 460 | __u8 bLength; |
461 | __u8 bDescriptorType; | 461 | __u8 bDescriptorType; |
@@ -501,6 +501,16 @@ struct usb_wireless_cap_descriptor { /* Ultra Wide Band */ | |||
501 | __u8 bReserved; | 501 | __u8 bReserved; |
502 | } __attribute__((packed)); | 502 | } __attribute__((packed)); |
503 | 503 | ||
504 | #define USB_CAP_TYPE_EXT 2 | ||
505 | |||
506 | struct usb_ext_cap_descriptor { /* Link Power Management */ | ||
507 | __u8 bLength; | ||
508 | __u8 bDescriptorType; | ||
509 | __u8 bDevCapabilityType; | ||
510 | __u8 bmAttributes; | ||
511 | #define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ | ||
512 | } __attribute__((packed)); | ||
513 | |||
504 | /*-------------------------------------------------------------------------*/ | 514 | /*-------------------------------------------------------------------------*/ |
505 | 515 | ||
506 | /* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with | 516 | /* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with |
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index d8128f7102c9..cf468fbdbf8e 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
@@ -114,6 +114,8 @@ struct usb_ep_ops { | |||
114 | int (*dequeue) (struct usb_ep *ep, struct usb_request *req); | 114 | int (*dequeue) (struct usb_ep *ep, struct usb_request *req); |
115 | 115 | ||
116 | int (*set_halt) (struct usb_ep *ep, int value); | 116 | int (*set_halt) (struct usb_ep *ep, int value); |
117 | int (*set_wedge) (struct usb_ep *ep); | ||
118 | |||
117 | int (*fifo_status) (struct usb_ep *ep); | 119 | int (*fifo_status) (struct usb_ep *ep); |
118 | void (*fifo_flush) (struct usb_ep *ep); | 120 | void (*fifo_flush) (struct usb_ep *ep); |
119 | }; | 121 | }; |
@@ -349,6 +351,25 @@ static inline int usb_ep_clear_halt(struct usb_ep *ep) | |||
349 | } | 351 | } |
350 | 352 | ||
351 | /** | 353 | /** |
354 | * usb_ep_set_wedge - sets the halt feature and ignores clear requests | ||
355 | * @ep: the endpoint being wedged | ||
356 | * | ||
357 | * Use this to stall an endpoint and ignore CLEAR_FEATURE(HALT_ENDPOINT) | ||
358 | * requests. If the gadget driver clears the halt status, it will | ||
359 | * automatically unwedge the endpoint. | ||
360 | * | ||
361 | * Returns zero on success, else negative errno. | ||
362 | */ | ||
363 | static inline int | ||
364 | usb_ep_set_wedge(struct usb_ep *ep) | ||
365 | { | ||
366 | if (ep->ops->set_wedge) | ||
367 | return ep->ops->set_wedge(ep); | ||
368 | else | ||
369 | return ep->ops->set_halt(ep, 1); | ||
370 | } | ||
371 | |||
372 | /** | ||
352 | * usb_ep_fifo_status - returns number of bytes in fifo, or error | 373 | * usb_ep_fifo_status - returns number of bytes in fifo, or error |
353 | * @ep: the endpoint whose fifo status is being checked. | 374 | * @ep: the endpoint whose fifo status is being checked. |
354 | * | 375 | * |
diff --git a/include/linux/virtio.h b/include/linux/virtio.h index e7d10845b3c1..06005fa9e982 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h | |||
@@ -76,6 +76,7 @@ struct virtqueue_ops { | |||
76 | * @dev: underlying device. | 76 | * @dev: underlying device. |
77 | * @id: the device type identification (used to match it with a driver). | 77 | * @id: the device type identification (used to match it with a driver). |
78 | * @config: the configuration ops for this device. | 78 | * @config: the configuration ops for this device. |
79 | * @features: the features supported by both driver and device. | ||
79 | * @priv: private pointer for the driver's use. | 80 | * @priv: private pointer for the driver's use. |
80 | */ | 81 | */ |
81 | struct virtio_device | 82 | struct virtio_device |
@@ -84,6 +85,8 @@ struct virtio_device | |||
84 | struct device dev; | 85 | struct device dev; |
85 | struct virtio_device_id id; | 86 | struct virtio_device_id id; |
86 | struct virtio_config_ops *config; | 87 | struct virtio_config_ops *config; |
88 | /* Note that this is a Linux set_bit-style bitmap. */ | ||
89 | unsigned long features[1]; | ||
87 | void *priv; | 90 | void *priv; |
88 | }; | 91 | }; |
89 | 92 | ||
@@ -94,6 +97,8 @@ void unregister_virtio_device(struct virtio_device *dev); | |||
94 | * virtio_driver - operations for a virtio I/O driver | 97 | * virtio_driver - operations for a virtio I/O driver |
95 | * @driver: underlying device driver (populate name and owner). | 98 | * @driver: underlying device driver (populate name and owner). |
96 | * @id_table: the ids serviced by this driver. | 99 | * @id_table: the ids serviced by this driver. |
100 | * @feature_table: an array of feature numbers supported by this device. | ||
101 | * @feature_table_size: number of entries in the feature table array. | ||
97 | * @probe: the function to call when a device is found. Returns a token for | 102 | * @probe: the function to call when a device is found. Returns a token for |
98 | * remove, or PTR_ERR(). | 103 | * remove, or PTR_ERR(). |
99 | * @remove: the function when a device is removed. | 104 | * @remove: the function when a device is removed. |
@@ -103,6 +108,8 @@ void unregister_virtio_device(struct virtio_device *dev); | |||
103 | struct virtio_driver { | 108 | struct virtio_driver { |
104 | struct device_driver driver; | 109 | struct device_driver driver; |
105 | const struct virtio_device_id *id_table; | 110 | const struct virtio_device_id *id_table; |
111 | const unsigned int *feature_table; | ||
112 | unsigned int feature_table_size; | ||
106 | int (*probe)(struct virtio_device *dev); | 113 | int (*probe)(struct virtio_device *dev); |
107 | void (*remove)(struct virtio_device *dev); | 114 | void (*remove)(struct virtio_device *dev); |
108 | void (*config_changed)(struct virtio_device *dev); | 115 | void (*config_changed)(struct virtio_device *dev); |
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h index bca0b10d7947..d4695a3356d0 100644 --- a/include/linux/virtio_blk.h +++ b/include/linux/virtio_blk.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */ | 9 | #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */ |
10 | #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */ | 10 | #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */ |
11 | #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ | 11 | #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ |
12 | #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */ | ||
12 | 13 | ||
13 | struct virtio_blk_config | 14 | struct virtio_blk_config |
14 | { | 15 | { |
@@ -18,6 +19,12 @@ struct virtio_blk_config | |||
18 | __le32 size_max; | 19 | __le32 size_max; |
19 | /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ | 20 | /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ |
20 | __le32 seg_max; | 21 | __le32 seg_max; |
22 | /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */ | ||
23 | struct virtio_blk_geometry { | ||
24 | __le16 cylinders; | ||
25 | __u8 heads; | ||
26 | __u8 sectors; | ||
27 | } geometry; | ||
21 | } __attribute__((packed)); | 28 | } __attribute__((packed)); |
22 | 29 | ||
23 | /* These two define direction. */ | 30 | /* These two define direction. */ |
@@ -41,13 +48,8 @@ struct virtio_blk_outhdr | |||
41 | __u64 sector; | 48 | __u64 sector; |
42 | }; | 49 | }; |
43 | 50 | ||
51 | /* And this is the final byte of the write scatter-gather list. */ | ||
44 | #define VIRTIO_BLK_S_OK 0 | 52 | #define VIRTIO_BLK_S_OK 0 |
45 | #define VIRTIO_BLK_S_IOERR 1 | 53 | #define VIRTIO_BLK_S_IOERR 1 |
46 | #define VIRTIO_BLK_S_UNSUPP 2 | 54 | #define VIRTIO_BLK_S_UNSUPP 2 |
47 | |||
48 | /* This is the first element of the write scatter-gather list */ | ||
49 | struct virtio_blk_inhdr | ||
50 | { | ||
51 | unsigned char status; | ||
52 | }; | ||
53 | #endif /* _LINUX_VIRTIO_BLK_H */ | 55 | #endif /* _LINUX_VIRTIO_BLK_H */ |
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index d581b2914b34..50db245c81ad 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h | |||
@@ -16,27 +16,20 @@ | |||
16 | #define VIRTIO_CONFIG_S_FAILED 0x80 | 16 | #define VIRTIO_CONFIG_S_FAILED 0x80 |
17 | 17 | ||
18 | #ifdef __KERNEL__ | 18 | #ifdef __KERNEL__ |
19 | struct virtio_device; | 19 | #include <linux/virtio.h> |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * virtio_config_ops - operations for configuring a virtio device | 22 | * virtio_config_ops - operations for configuring a virtio device |
23 | * @feature: search for a feature in this config | ||
24 | * vdev: the virtio_device | ||
25 | * bit: the feature bit | ||
26 | * Returns true if the feature is supported. Acknowledges the feature | ||
27 | * so the host can see it. | ||
28 | * @get: read the value of a configuration field | 23 | * @get: read the value of a configuration field |
29 | * vdev: the virtio_device | 24 | * vdev: the virtio_device |
30 | * offset: the offset of the configuration field | 25 | * offset: the offset of the configuration field |
31 | * buf: the buffer to write the field value into. | 26 | * buf: the buffer to write the field value into. |
32 | * len: the length of the buffer | 27 | * len: the length of the buffer |
33 | * Note that contents are conventionally little-endian. | ||
34 | * @set: write the value of a configuration field | 28 | * @set: write the value of a configuration field |
35 | * vdev: the virtio_device | 29 | * vdev: the virtio_device |
36 | * offset: the offset of the configuration field | 30 | * offset: the offset of the configuration field |
37 | * buf: the buffer to read the field value from. | 31 | * buf: the buffer to read the field value from. |
38 | * len: the length of the buffer | 32 | * len: the length of the buffer |
39 | * Note that contents are conventionally little-endian. | ||
40 | * @get_status: read the status byte | 33 | * @get_status: read the status byte |
41 | * vdev: the virtio_device | 34 | * vdev: the virtio_device |
42 | * Returns the status byte | 35 | * Returns the status byte |
@@ -52,10 +45,15 @@ struct virtio_device; | |||
52 | * callback: the virqtueue callback | 45 | * callback: the virqtueue callback |
53 | * Returns the new virtqueue or ERR_PTR() (eg. -ENOENT). | 46 | * Returns the new virtqueue or ERR_PTR() (eg. -ENOENT). |
54 | * @del_vq: free a virtqueue found by find_vq(). | 47 | * @del_vq: free a virtqueue found by find_vq(). |
48 | * @get_features: get the array of feature bits for this device. | ||
49 | * vdev: the virtio_device | ||
50 | * Returns the first 32 feature bits (all we currently need). | ||
51 | * @set_features: confirm what device features we'll be using. | ||
52 | * vdev: the virtio_device | ||
53 | * feature: the first 32 feature bits | ||
55 | */ | 54 | */ |
56 | struct virtio_config_ops | 55 | struct virtio_config_ops |
57 | { | 56 | { |
58 | bool (*feature)(struct virtio_device *vdev, unsigned bit); | ||
59 | void (*get)(struct virtio_device *vdev, unsigned offset, | 57 | void (*get)(struct virtio_device *vdev, unsigned offset, |
60 | void *buf, unsigned len); | 58 | void *buf, unsigned len); |
61 | void (*set)(struct virtio_device *vdev, unsigned offset, | 59 | void (*set)(struct virtio_device *vdev, unsigned offset, |
@@ -67,43 +65,52 @@ struct virtio_config_ops | |||
67 | unsigned index, | 65 | unsigned index, |
68 | void (*callback)(struct virtqueue *)); | 66 | void (*callback)(struct virtqueue *)); |
69 | void (*del_vq)(struct virtqueue *vq); | 67 | void (*del_vq)(struct virtqueue *vq); |
68 | u32 (*get_features)(struct virtio_device *vdev); | ||
69 | void (*set_features)(struct virtio_device *vdev, u32 features); | ||
70 | }; | 70 | }; |
71 | 71 | ||
72 | /* If driver didn't advertise the feature, it will never appear. */ | ||
73 | void virtio_check_driver_offered_feature(const struct virtio_device *vdev, | ||
74 | unsigned int fbit); | ||
75 | |||
72 | /** | 76 | /** |
73 | * virtio_config_val - look for a feature and get a single virtio config. | 77 | * virtio_has_feature - helper to determine if this device has this feature. |
74 | * @vdev: the virtio device | 78 | * @vdev: the device |
75 | * @fbit: the feature bit | 79 | * @fbit: the feature bit |
76 | * @offset: the type to search for. | 80 | */ |
77 | * @val: a pointer to the value to fill in. | 81 | static inline bool virtio_has_feature(const struct virtio_device *vdev, |
78 | * | 82 | unsigned int fbit) |
79 | * The return value is -ENOENT if the feature doesn't exist. Otherwise | 83 | { |
80 | * the value is endian-corrected and returned in v. */ | 84 | /* Did you forget to fix assumptions on max features? */ |
81 | #define virtio_config_val(vdev, fbit, offset, v) ({ \ | 85 | if (__builtin_constant_p(fbit)) |
82 | int _err; \ | 86 | BUILD_BUG_ON(fbit >= 32); |
83 | if ((vdev)->config->feature((vdev), (fbit))) { \ | 87 | |
84 | __virtio_config_val((vdev), (offset), (v)); \ | 88 | virtio_check_driver_offered_feature(vdev, fbit); |
85 | _err = 0; \ | 89 | return test_bit(fbit, vdev->features); |
86 | } else \ | 90 | } |
87 | _err = -ENOENT; \ | ||
88 | _err; \ | ||
89 | }) | ||
90 | 91 | ||
91 | /** | 92 | /** |
92 | * __virtio_config_val - get a single virtio config without feature check. | 93 | * virtio_config_val - look for a feature and get a virtio config entry. |
93 | * @vdev: the virtio device | 94 | * @vdev: the virtio device |
95 | * @fbit: the feature bit | ||
94 | * @offset: the type to search for. | 96 | * @offset: the type to search for. |
95 | * @val: a pointer to the value to fill in. | 97 | * @val: a pointer to the value to fill in. |
96 | * | 98 | * |
97 | * The value is endian-corrected and returned in v. */ | 99 | * The return value is -ENOENT if the feature doesn't exist. Otherwise |
98 | #define __virtio_config_val(vdev, offset, v) do { \ | 100 | * the config value is copied into whatever is pointed to by v. */ |
99 | BUILD_BUG_ON(sizeof(*(v)) != 1 && sizeof(*(v)) != 2 \ | 101 | #define virtio_config_val(vdev, fbit, offset, v) \ |
100 | && sizeof(*(v)) != 4 && sizeof(*(v)) != 8); \ | 102 | virtio_config_buf((vdev), (fbit), (offset), (v), sizeof(v)) |
101 | (vdev)->config->get((vdev), (offset), (v), sizeof(*(v))); \ | 103 | |
102 | switch (sizeof(*(v))) { \ | 104 | static inline int virtio_config_buf(struct virtio_device *vdev, |
103 | case 2: le16_to_cpus((__u16 *) v); break; \ | 105 | unsigned int fbit, |
104 | case 4: le32_to_cpus((__u32 *) v); break; \ | 106 | unsigned int offset, |
105 | case 8: le64_to_cpus((__u64 *) v); break; \ | 107 | void *buf, unsigned len) |
106 | } \ | 108 | { |
107 | } while(0) | 109 | if (!virtio_has_feature(vdev, fbit)) |
110 | return -ENOENT; | ||
111 | |||
112 | vdev->config->get(vdev, offset, buf, len); | ||
113 | return 0; | ||
114 | } | ||
108 | #endif /* __KERNEL__ */ | 115 | #endif /* __KERNEL__ */ |
109 | #endif /* _LINUX_VIRTIO_CONFIG_H */ | 116 | #endif /* _LINUX_VIRTIO_CONFIG_H */ |
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h index 1ea3351df609..9405aa6cdf26 100644 --- a/include/linux/virtio_net.h +++ b/include/linux/virtio_net.h | |||
@@ -6,9 +6,18 @@ | |||
6 | #define VIRTIO_ID_NET 1 | 6 | #define VIRTIO_ID_NET 1 |
7 | 7 | ||
8 | /* The feature bitmap for virtio net */ | 8 | /* The feature bitmap for virtio net */ |
9 | #define VIRTIO_NET_F_CSUM 0 /* Can handle pkts w/ partial csum */ | 9 | #define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */ |
10 | #define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */ | ||
10 | #define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */ | 11 | #define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */ |
11 | #define VIRTIO_NET_F_GSO 6 /* Can handle pkts w/ any GSO type */ | 12 | #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */ |
13 | #define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */ | ||
14 | #define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */ | ||
15 | #define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */ | ||
16 | #define VIRTIO_NET_F_GUEST_UFO 10 /* Guest can handle UFO in. */ | ||
17 | #define VIRTIO_NET_F_HOST_TSO4 11 /* Host can handle TSOv4 in. */ | ||
18 | #define VIRTIO_NET_F_HOST_TSO6 12 /* Host can handle TSOv6 in. */ | ||
19 | #define VIRTIO_NET_F_HOST_ECN 13 /* Host can handle TSO[6] w/ ECN in. */ | ||
20 | #define VIRTIO_NET_F_HOST_UFO 14 /* Host can handle UFO in. */ | ||
12 | 21 | ||
13 | struct virtio_net_config | 22 | struct virtio_net_config |
14 | { | 23 | { |
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 1f74bcd603fe..32742c4563de 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h | |||
@@ -30,13 +30,6 @@ | |||
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * SCSI command lengths | ||
34 | */ | ||
35 | |||
36 | extern const unsigned char scsi_command_size[8]; | ||
37 | #define COMMAND_SIZE(opcode) scsi_command_size[((opcode) >> 5) & 7] | ||
38 | |||
39 | /* | ||
40 | * Special value for scanning to specify scanning or rescanning of all | 33 | * Special value for scanning to specify scanning or rescanning of all |
41 | * possible channels, (target) ids, or luns on a given shost. | 34 | * possible channels, (target) ids, or luns on a given shost. |
42 | */ | 35 | */ |
@@ -109,6 +102,7 @@ extern const unsigned char scsi_command_size[8]; | |||
109 | #define MODE_SENSE_10 0x5a | 102 | #define MODE_SENSE_10 0x5a |
110 | #define PERSISTENT_RESERVE_IN 0x5e | 103 | #define PERSISTENT_RESERVE_IN 0x5e |
111 | #define PERSISTENT_RESERVE_OUT 0x5f | 104 | #define PERSISTENT_RESERVE_OUT 0x5f |
105 | #define VARIABLE_LENGTH_CMD 0x7f | ||
112 | #define REPORT_LUNS 0xa0 | 106 | #define REPORT_LUNS 0xa0 |
113 | #define MAINTENANCE_IN 0xa3 | 107 | #define MAINTENANCE_IN 0xa3 |
114 | #define MOVE_MEDIUM 0xa5 | 108 | #define MOVE_MEDIUM 0xa5 |
@@ -136,6 +130,38 @@ extern const unsigned char scsi_command_size[8]; | |||
136 | #define ATA_12 0xa1 /* 12-byte pass-thru */ | 130 | #define ATA_12 0xa1 /* 12-byte pass-thru */ |
137 | 131 | ||
138 | /* | 132 | /* |
133 | * SCSI command lengths | ||
134 | */ | ||
135 | |||
136 | #define SCSI_MAX_VARLEN_CDB_SIZE 260 | ||
137 | |||
138 | /* defined in T10 SCSI Primary Commands-2 (SPC2) */ | ||
139 | struct scsi_varlen_cdb_hdr { | ||
140 | u8 opcode; /* opcode always == VARIABLE_LENGTH_CMD */ | ||
141 | u8 control; | ||
142 | u8 misc[5]; | ||
143 | u8 additional_cdb_length; /* total cdb length - 8 */ | ||
144 | __be16 service_action; | ||
145 | /* service specific data follows */ | ||
146 | }; | ||
147 | |||
148 | static inline unsigned | ||
149 | scsi_varlen_cdb_length(const void *hdr) | ||
150 | { | ||
151 | return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length + 8; | ||
152 | } | ||
153 | |||
154 | extern const unsigned char scsi_command_size_tbl[8]; | ||
155 | #define COMMAND_SIZE(opcode) scsi_command_size_tbl[((opcode) >> 5) & 7] | ||
156 | |||
157 | static inline unsigned | ||
158 | scsi_command_size(const unsigned char *cmnd) | ||
159 | { | ||
160 | return (cmnd[0] == VARIABLE_LENGTH_CMD) ? | ||
161 | scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]); | ||
162 | } | ||
163 | |||
164 | /* | ||
139 | * SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft | 165 | * SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft |
140 | * T10/1561-D Revision 4 Draft dated 7th November 2002. | 166 | * T10/1561-D Revision 4 Draft dated 7th November 2002. |
141 | */ | 167 | */ |
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 8d20e60a94b7..3e46dfae8194 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h | |||
@@ -7,10 +7,28 @@ | |||
7 | #include <linux/types.h> | 7 | #include <linux/types.h> |
8 | #include <linux/timer.h> | 8 | #include <linux/timer.h> |
9 | #include <linux/scatterlist.h> | 9 | #include <linux/scatterlist.h> |
10 | #include <linux/blkdev.h> | ||
10 | 11 | ||
11 | struct Scsi_Host; | 12 | struct Scsi_Host; |
12 | struct scsi_device; | 13 | struct scsi_device; |
13 | 14 | ||
15 | /* | ||
16 | * MAX_COMMAND_SIZE is: | ||
17 | * The longest fixed-length SCSI CDB as per the SCSI standard. | ||
18 | * fixed-length means: commands that their size can be determined | ||
19 | * by their opcode and the CDB does not carry a length specifier, (unlike | ||
20 | * the VARIABLE_LENGTH_CMD(0x7f) command). This is actually not exactly | ||
21 | * true and the SCSI standard also defines extended commands and | ||
22 | * vendor specific commands that can be bigger than 16 bytes. The kernel | ||
23 | * will support these using the same infrastructure used for VARLEN CDB's. | ||
24 | * So in effect MAX_COMMAND_SIZE means the maximum size command scsi-ml | ||
25 | * supports without specifying a cmd_len by ULD's | ||
26 | */ | ||
27 | #define MAX_COMMAND_SIZE 16 | ||
28 | #if (MAX_COMMAND_SIZE > BLK_MAX_CDB) | ||
29 | # error MAX_COMMAND_SIZE can not be bigger than BLK_MAX_CDB | ||
30 | #endif | ||
31 | |||
14 | struct scsi_data_buffer { | 32 | struct scsi_data_buffer { |
15 | struct sg_table table; | 33 | struct sg_table table; |
16 | unsigned length; | 34 | unsigned length; |
@@ -60,12 +78,11 @@ struct scsi_cmnd { | |||
60 | int allowed; | 78 | int allowed; |
61 | int timeout_per_command; | 79 | int timeout_per_command; |
62 | 80 | ||
63 | unsigned char cmd_len; | 81 | unsigned short cmd_len; |
64 | enum dma_data_direction sc_data_direction; | 82 | enum dma_data_direction sc_data_direction; |
65 | 83 | ||
66 | /* These elements define the operation we are about to perform */ | 84 | /* These elements define the operation we are about to perform */ |
67 | #define MAX_COMMAND_SIZE 16 | 85 | unsigned char *cmnd; |
68 | unsigned char cmnd[MAX_COMMAND_SIZE]; | ||
69 | 86 | ||
70 | struct timer_list eh_timeout; /* Used to time out the command. */ | 87 | struct timer_list eh_timeout; /* Used to time out the command. */ |
71 | 88 | ||
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index d3a133b4a072..2a9add21267d 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h | |||
@@ -75,11 +75,11 @@ struct scsi_eh_save { | |||
75 | int result; | 75 | int result; |
76 | enum dma_data_direction data_direction; | 76 | enum dma_data_direction data_direction; |
77 | unsigned char cmd_len; | 77 | unsigned char cmd_len; |
78 | unsigned char cmnd[MAX_COMMAND_SIZE]; | 78 | unsigned char *cmnd; |
79 | struct scsi_data_buffer sdb; | 79 | struct scsi_data_buffer sdb; |
80 | struct request *next_rq; | 80 | struct request *next_rq; |
81 | |||
82 | /* new command support */ | 81 | /* new command support */ |
82 | unsigned char eh_cmnd[BLK_MAX_CDB]; | ||
83 | struct scatterlist sense_sgl; | 83 | struct scatterlist sense_sgl; |
84 | }; | 84 | }; |
85 | 85 | ||
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index d967d6dc7a28..1834fdfe82a7 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h | |||
@@ -573,13 +573,11 @@ struct Scsi_Host { | |||
573 | /* | 573 | /* |
574 | * The maximum length of SCSI commands that this host can accept. | 574 | * The maximum length of SCSI commands that this host can accept. |
575 | * Probably 12 for most host adapters, but could be 16 for others. | 575 | * Probably 12 for most host adapters, but could be 16 for others. |
576 | * or 260 if the driver supports variable length cdbs. | ||
576 | * For drivers that don't set this field, a value of 12 is | 577 | * For drivers that don't set this field, a value of 12 is |
577 | * assumed. I am leaving this as a number rather than a bit | 578 | * assumed. |
578 | * because you never know what subsequent SCSI standards might do | ||
579 | * (i.e. could there be a 20 byte or a 24-byte command a few years | ||
580 | * down the road?). | ||
581 | */ | 579 | */ |
582 | unsigned char max_cmd_len; | 580 | unsigned short max_cmd_len; |
583 | 581 | ||
584 | int this_id; | 582 | int this_id; |
585 | int can_queue; | 583 | int can_queue; |
diff --git a/init/Kconfig b/init/Kconfig index 3e7b257fc05f..4c33316743f5 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -316,9 +316,16 @@ config CPUSETS | |||
316 | 316 | ||
317 | Say N if unsure. | 317 | Say N if unsure. |
318 | 318 | ||
319 | # | ||
320 | # Architectures with an unreliable sched_clock() should select this: | ||
321 | # | ||
322 | config HAVE_UNSTABLE_SCHED_CLOCK | ||
323 | bool | ||
324 | |||
319 | config GROUP_SCHED | 325 | config GROUP_SCHED |
320 | bool "Group CPU scheduler" | 326 | bool "Group CPU scheduler" |
321 | default y | 327 | depends on EXPERIMENTAL |
328 | default n | ||
322 | help | 329 | help |
323 | This feature lets CPU scheduler recognize task groups and control CPU | 330 | This feature lets CPU scheduler recognize task groups and control CPU |
324 | bandwidth allocation to such task groups. | 331 | bandwidth allocation to such task groups. |
@@ -326,7 +333,7 @@ config GROUP_SCHED | |||
326 | config FAIR_GROUP_SCHED | 333 | config FAIR_GROUP_SCHED |
327 | bool "Group scheduling for SCHED_OTHER" | 334 | bool "Group scheduling for SCHED_OTHER" |
328 | depends on GROUP_SCHED | 335 | depends on GROUP_SCHED |
329 | default y | 336 | default GROUP_SCHED |
330 | 337 | ||
331 | config RT_GROUP_SCHED | 338 | config RT_GROUP_SCHED |
332 | bool "Group scheduling for SCHED_RR/FIFO" | 339 | bool "Group scheduling for SCHED_RR/FIFO" |
@@ -720,7 +727,7 @@ config VM_EVENT_COUNTERS | |||
720 | config SLUB_DEBUG | 727 | config SLUB_DEBUG |
721 | default y | 728 | default y |
722 | bool "Enable SLUB debugging support" if EMBEDDED | 729 | bool "Enable SLUB debugging support" if EMBEDDED |
723 | depends on SLUB | 730 | depends on SLUB && SYSFS |
724 | help | 731 | help |
725 | SLUB has extensive debug support features. Disabling these can | 732 | SLUB has extensive debug support features. Disabling these can |
726 | result in significant savings in code size. This also disables | 733 | result in significant savings in code size. This also disables |
@@ -825,6 +832,15 @@ menuconfig MODULES | |||
825 | 832 | ||
826 | If unsure, say Y. | 833 | If unsure, say Y. |
827 | 834 | ||
835 | config MODULE_FORCE_LOAD | ||
836 | bool "Forced module loading" | ||
837 | depends on MODULES | ||
838 | default n | ||
839 | help | ||
840 | This option allows loading of modules even if that would set the | ||
841 | 'F' (forced) taint, due to lack of version info. Which is | ||
842 | usually a really bad idea. | ||
843 | |||
828 | config MODULE_UNLOAD | 844 | config MODULE_UNLOAD |
829 | bool "Module unloading" | 845 | bool "Module unloading" |
830 | depends on MODULES | 846 | depends on MODULES |
diff --git a/init/main.c b/init/main.c index a87d4ca5c36c..ddada7acf363 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -602,6 +602,7 @@ asmlinkage void __init start_kernel(void) | |||
602 | softirq_init(); | 602 | softirq_init(); |
603 | timekeeping_init(); | 603 | timekeeping_init(); |
604 | time_init(); | 604 | time_init(); |
605 | sched_clock_init(); | ||
605 | profile_init(); | 606 | profile_init(); |
606 | if (!irqs_disabled()) | 607 | if (!irqs_disabled()) |
607 | printk("start_kernel(): bug: interrupts were enabled early\n"); | 608 | printk("start_kernel(): bug: interrupts were enabled early\n"); |
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 94fd3b08fb77..b3b69fd51330 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
@@ -673,7 +673,7 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode, | |||
673 | if (IS_ERR(name = getname(u_name))) | 673 | if (IS_ERR(name = getname(u_name))) |
674 | return PTR_ERR(name); | 674 | return PTR_ERR(name); |
675 | 675 | ||
676 | fd = get_unused_fd(); | 676 | fd = get_unused_fd_flags(O_CLOEXEC); |
677 | if (fd < 0) | 677 | if (fd < 0) |
678 | goto out_putname; | 678 | goto out_putname; |
679 | 679 | ||
@@ -709,7 +709,6 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode, | |||
709 | goto out_putfd; | 709 | goto out_putfd; |
710 | } | 710 | } |
711 | 711 | ||
712 | set_close_on_exec(fd, 1); | ||
713 | fd_install(fd, filp); | 712 | fd_install(fd, filp); |
714 | goto out_upsem; | 713 | goto out_upsem; |
715 | 714 | ||
diff --git a/kernel/Makefile b/kernel/Makefile index 188c43223f52..1c9938addb9d 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -9,7 +9,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ | |||
9 | rcupdate.o extable.o params.o posix-timers.o \ | 9 | rcupdate.o extable.o params.o posix-timers.o \ |
10 | kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ | 10 | kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ |
11 | hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ | 11 | hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ |
12 | notifier.o ksysfs.o pm_qos_params.o | 12 | notifier.o ksysfs.o pm_qos_params.o sched_clock.o |
13 | 13 | ||
14 | obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o | 14 | obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o |
15 | obj-$(CONFIG_STACKTRACE) += stacktrace.o | 15 | obj-$(CONFIG_STACKTRACE) += stacktrace.o |
diff --git a/kernel/compat.c b/kernel/compat.c index 4a856a3643bb..32c254a8ab9a 100644 --- a/kernel/compat.c +++ b/kernel/compat.c | |||
@@ -955,7 +955,8 @@ asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp) | |||
955 | __put_user(txc.jitcnt, &utp->jitcnt) || | 955 | __put_user(txc.jitcnt, &utp->jitcnt) || |
956 | __put_user(txc.calcnt, &utp->calcnt) || | 956 | __put_user(txc.calcnt, &utp->calcnt) || |
957 | __put_user(txc.errcnt, &utp->errcnt) || | 957 | __put_user(txc.errcnt, &utp->errcnt) || |
958 | __put_user(txc.stbcnt, &utp->stbcnt)) | 958 | __put_user(txc.stbcnt, &utp->stbcnt) || |
959 | __put_user(txc.tai, &utp->tai)) | ||
959 | ret = -EFAULT; | 960 | ret = -EFAULT; |
960 | 961 | ||
961 | return ret; | 962 | return ret; |
diff --git a/kernel/exit.c b/kernel/exit.c index d3ad54677f9c..1510f78a0ffa 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/acct.h> | 19 | #include <linux/acct.h> |
20 | #include <linux/tsacct_kern.h> | 20 | #include <linux/tsacct_kern.h> |
21 | #include <linux/file.h> | 21 | #include <linux/file.h> |
22 | #include <linux/fdtable.h> | ||
22 | #include <linux/binfmts.h> | 23 | #include <linux/binfmts.h> |
23 | #include <linux/nsproxy.h> | 24 | #include <linux/nsproxy.h> |
24 | #include <linux/pid_namespace.h> | 25 | #include <linux/pid_namespace.h> |
diff --git a/kernel/fork.c b/kernel/fork.c index 2bb675af4de3..933e60ebccae 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/mempolicy.h> | 22 | #include <linux/mempolicy.h> |
23 | #include <linux/sem.h> | 23 | #include <linux/sem.h> |
24 | #include <linux/file.h> | 24 | #include <linux/file.h> |
25 | #include <linux/fdtable.h> | ||
25 | #include <linux/key.h> | 26 | #include <linux/key.h> |
26 | #include <linux/binfmts.h> | 27 | #include <linux/binfmts.h> |
27 | #include <linux/mman.h> | 28 | #include <linux/mman.h> |
diff --git a/kernel/futex.c b/kernel/futex.c index 98092c9817f4..449def8074fe 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -104,10 +104,6 @@ struct futex_q { | |||
104 | /* Key which the futex is hashed on: */ | 104 | /* Key which the futex is hashed on: */ |
105 | union futex_key key; | 105 | union futex_key key; |
106 | 106 | ||
107 | /* For fd, sigio sent using these: */ | ||
108 | int fd; | ||
109 | struct file *filp; | ||
110 | |||
111 | /* Optional priority inheritance state: */ | 107 | /* Optional priority inheritance state: */ |
112 | struct futex_pi_state *pi_state; | 108 | struct futex_pi_state *pi_state; |
113 | struct task_struct *task; | 109 | struct task_struct *task; |
@@ -126,9 +122,6 @@ struct futex_hash_bucket { | |||
126 | 122 | ||
127 | static struct futex_hash_bucket futex_queues[1<<FUTEX_HASHBITS]; | 123 | static struct futex_hash_bucket futex_queues[1<<FUTEX_HASHBITS]; |
128 | 124 | ||
129 | /* Futex-fs vfsmount entry: */ | ||
130 | static struct vfsmount *futex_mnt; | ||
131 | |||
132 | /* | 125 | /* |
133 | * Take mm->mmap_sem, when futex is shared | 126 | * Take mm->mmap_sem, when futex is shared |
134 | */ | 127 | */ |
@@ -610,8 +603,6 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb, | |||
610 | static void wake_futex(struct futex_q *q) | 603 | static void wake_futex(struct futex_q *q) |
611 | { | 604 | { |
612 | plist_del(&q->list, &q->list.plist); | 605 | plist_del(&q->list, &q->list.plist); |
613 | if (q->filp) | ||
614 | send_sigio(&q->filp->f_owner, q->fd, POLL_IN); | ||
615 | /* | 606 | /* |
616 | * The lock in wake_up_all() is a crucial memory barrier after the | 607 | * The lock in wake_up_all() is a crucial memory barrier after the |
617 | * plist_del() and also before assigning to q->lock_ptr. | 608 | * plist_del() and also before assigning to q->lock_ptr. |
@@ -988,14 +979,10 @@ out: | |||
988 | } | 979 | } |
989 | 980 | ||
990 | /* The key must be already stored in q->key. */ | 981 | /* The key must be already stored in q->key. */ |
991 | static inline struct futex_hash_bucket * | 982 | static inline struct futex_hash_bucket *queue_lock(struct futex_q *q) |
992 | queue_lock(struct futex_q *q, int fd, struct file *filp) | ||
993 | { | 983 | { |
994 | struct futex_hash_bucket *hb; | 984 | struct futex_hash_bucket *hb; |
995 | 985 | ||
996 | q->fd = fd; | ||
997 | q->filp = filp; | ||
998 | |||
999 | init_waitqueue_head(&q->waiters); | 986 | init_waitqueue_head(&q->waiters); |
1000 | 987 | ||
1001 | get_futex_key_refs(&q->key); | 988 | get_futex_key_refs(&q->key); |
@@ -1006,7 +993,7 @@ queue_lock(struct futex_q *q, int fd, struct file *filp) | |||
1006 | return hb; | 993 | return hb; |
1007 | } | 994 | } |
1008 | 995 | ||
1009 | static inline void __queue_me(struct futex_q *q, struct futex_hash_bucket *hb) | 996 | static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb) |
1010 | { | 997 | { |
1011 | int prio; | 998 | int prio; |
1012 | 999 | ||
@@ -1041,15 +1028,6 @@ queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb) | |||
1041 | * exactly once. They are called with the hashed spinlock held. | 1028 | * exactly once. They are called with the hashed spinlock held. |
1042 | */ | 1029 | */ |
1043 | 1030 | ||
1044 | /* The key must be already stored in q->key. */ | ||
1045 | static void queue_me(struct futex_q *q, int fd, struct file *filp) | ||
1046 | { | ||
1047 | struct futex_hash_bucket *hb; | ||
1048 | |||
1049 | hb = queue_lock(q, fd, filp); | ||
1050 | __queue_me(q, hb); | ||
1051 | } | ||
1052 | |||
1053 | /* Return 1 if we were still queued (ie. 0 means we were woken) */ | 1031 | /* Return 1 if we were still queued (ie. 0 means we were woken) */ |
1054 | static int unqueue_me(struct futex_q *q) | 1032 | static int unqueue_me(struct futex_q *q) |
1055 | { | 1033 | { |
@@ -1194,7 +1172,7 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1194 | if (unlikely(ret != 0)) | 1172 | if (unlikely(ret != 0)) |
1195 | goto out_release_sem; | 1173 | goto out_release_sem; |
1196 | 1174 | ||
1197 | hb = queue_lock(&q, -1, NULL); | 1175 | hb = queue_lock(&q); |
1198 | 1176 | ||
1199 | /* | 1177 | /* |
1200 | * Access the page AFTER the futex is queued. | 1178 | * Access the page AFTER the futex is queued. |
@@ -1238,7 +1216,7 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1238 | goto out_unlock_release_sem; | 1216 | goto out_unlock_release_sem; |
1239 | 1217 | ||
1240 | /* Only actually queue if *uaddr contained val. */ | 1218 | /* Only actually queue if *uaddr contained val. */ |
1241 | __queue_me(&q, hb); | 1219 | queue_me(&q, hb); |
1242 | 1220 | ||
1243 | /* | 1221 | /* |
1244 | * Now the futex is queued and we have checked the data, we | 1222 | * Now the futex is queued and we have checked the data, we |
@@ -1386,7 +1364,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1386 | goto out_release_sem; | 1364 | goto out_release_sem; |
1387 | 1365 | ||
1388 | retry_unlocked: | 1366 | retry_unlocked: |
1389 | hb = queue_lock(&q, -1, NULL); | 1367 | hb = queue_lock(&q); |
1390 | 1368 | ||
1391 | retry_locked: | 1369 | retry_locked: |
1392 | ret = lock_taken = 0; | 1370 | ret = lock_taken = 0; |
@@ -1499,7 +1477,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, | |||
1499 | /* | 1477 | /* |
1500 | * Only actually queue now that the atomic ops are done: | 1478 | * Only actually queue now that the atomic ops are done: |
1501 | */ | 1479 | */ |
1502 | __queue_me(&q, hb); | 1480 | queue_me(&q, hb); |
1503 | 1481 | ||
1504 | /* | 1482 | /* |
1505 | * Now the futex is queued and we have checked the data, we | 1483 | * Now the futex is queued and we have checked the data, we |
@@ -1746,121 +1724,6 @@ pi_faulted: | |||
1746 | return ret; | 1724 | return ret; |
1747 | } | 1725 | } |
1748 | 1726 | ||
1749 | static int futex_close(struct inode *inode, struct file *filp) | ||
1750 | { | ||
1751 | struct futex_q *q = filp->private_data; | ||
1752 | |||
1753 | unqueue_me(q); | ||
1754 | kfree(q); | ||
1755 | |||
1756 | return 0; | ||
1757 | } | ||
1758 | |||
1759 | /* This is one-shot: once it's gone off you need a new fd */ | ||
1760 | static unsigned int futex_poll(struct file *filp, | ||
1761 | struct poll_table_struct *wait) | ||
1762 | { | ||
1763 | struct futex_q *q = filp->private_data; | ||
1764 | int ret = 0; | ||
1765 | |||
1766 | poll_wait(filp, &q->waiters, wait); | ||
1767 | |||
1768 | /* | ||
1769 | * plist_node_empty() is safe here without any lock. | ||
1770 | * q->lock_ptr != 0 is not safe, because of ordering against wakeup. | ||
1771 | */ | ||
1772 | if (plist_node_empty(&q->list)) | ||
1773 | ret = POLLIN | POLLRDNORM; | ||
1774 | |||
1775 | return ret; | ||
1776 | } | ||
1777 | |||
1778 | static const struct file_operations futex_fops = { | ||
1779 | .release = futex_close, | ||
1780 | .poll = futex_poll, | ||
1781 | }; | ||
1782 | |||
1783 | /* | ||
1784 | * Signal allows caller to avoid the race which would occur if they | ||
1785 | * set the sigio stuff up afterwards. | ||
1786 | */ | ||
1787 | static int futex_fd(u32 __user *uaddr, int signal) | ||
1788 | { | ||
1789 | struct futex_q *q; | ||
1790 | struct file *filp; | ||
1791 | int ret, err; | ||
1792 | struct rw_semaphore *fshared; | ||
1793 | static unsigned long printk_interval; | ||
1794 | |||
1795 | if (printk_timed_ratelimit(&printk_interval, 60 * 60 * 1000)) { | ||
1796 | printk(KERN_WARNING "Process `%s' used FUTEX_FD, which " | ||
1797 | "will be removed from the kernel in June 2007\n", | ||
1798 | current->comm); | ||
1799 | } | ||
1800 | |||
1801 | ret = -EINVAL; | ||
1802 | if (!valid_signal(signal)) | ||
1803 | goto out; | ||
1804 | |||
1805 | ret = get_unused_fd(); | ||
1806 | if (ret < 0) | ||
1807 | goto out; | ||
1808 | filp = get_empty_filp(); | ||
1809 | if (!filp) { | ||
1810 | put_unused_fd(ret); | ||
1811 | ret = -ENFILE; | ||
1812 | goto out; | ||
1813 | } | ||
1814 | filp->f_op = &futex_fops; | ||
1815 | filp->f_path.mnt = mntget(futex_mnt); | ||
1816 | filp->f_path.dentry = dget(futex_mnt->mnt_root); | ||
1817 | filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping; | ||
1818 | |||
1819 | if (signal) { | ||
1820 | err = __f_setown(filp, task_pid(current), PIDTYPE_PID, 1); | ||
1821 | if (err < 0) { | ||
1822 | goto error; | ||
1823 | } | ||
1824 | filp->f_owner.signum = signal; | ||
1825 | } | ||
1826 | |||
1827 | q = kmalloc(sizeof(*q), GFP_KERNEL); | ||
1828 | if (!q) { | ||
1829 | err = -ENOMEM; | ||
1830 | goto error; | ||
1831 | } | ||
1832 | q->pi_state = NULL; | ||
1833 | |||
1834 | fshared = ¤t->mm->mmap_sem; | ||
1835 | down_read(fshared); | ||
1836 | err = get_futex_key(uaddr, fshared, &q->key); | ||
1837 | |||
1838 | if (unlikely(err != 0)) { | ||
1839 | up_read(fshared); | ||
1840 | kfree(q); | ||
1841 | goto error; | ||
1842 | } | ||
1843 | |||
1844 | /* | ||
1845 | * queue_me() must be called before releasing mmap_sem, because | ||
1846 | * key->shared.inode needs to be referenced while holding it. | ||
1847 | */ | ||
1848 | filp->private_data = q; | ||
1849 | |||
1850 | queue_me(q, ret, filp); | ||
1851 | up_read(fshared); | ||
1852 | |||
1853 | /* Now we map fd to filp, so userspace can access it */ | ||
1854 | fd_install(ret, filp); | ||
1855 | out: | ||
1856 | return ret; | ||
1857 | error: | ||
1858 | put_unused_fd(ret); | ||
1859 | put_filp(filp); | ||
1860 | ret = err; | ||
1861 | goto out; | ||
1862 | } | ||
1863 | |||
1864 | /* | 1727 | /* |
1865 | * Support for robust futexes: the kernel cleans up held futexes at | 1728 | * Support for robust futexes: the kernel cleans up held futexes at |
1866 | * thread exit time. | 1729 | * thread exit time. |
@@ -2092,10 +1955,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, | |||
2092 | case FUTEX_WAKE_BITSET: | 1955 | case FUTEX_WAKE_BITSET: |
2093 | ret = futex_wake(uaddr, fshared, val, val3); | 1956 | ret = futex_wake(uaddr, fshared, val, val3); |
2094 | break; | 1957 | break; |
2095 | case FUTEX_FD: | ||
2096 | /* non-zero val means F_SETOWN(getpid()) & F_SETSIG(val) */ | ||
2097 | ret = futex_fd(uaddr, val); | ||
2098 | break; | ||
2099 | case FUTEX_REQUEUE: | 1958 | case FUTEX_REQUEUE: |
2100 | ret = futex_requeue(uaddr, fshared, uaddr2, val, val2, NULL); | 1959 | ret = futex_requeue(uaddr, fshared, uaddr2, val, val2, NULL); |
2101 | break; | 1960 | break; |
@@ -2156,19 +2015,6 @@ asmlinkage long sys_futex(u32 __user *uaddr, int op, u32 val, | |||
2156 | return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); | 2015 | return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); |
2157 | } | 2016 | } |
2158 | 2017 | ||
2159 | static int futexfs_get_sb(struct file_system_type *fs_type, | ||
2160 | int flags, const char *dev_name, void *data, | ||
2161 | struct vfsmount *mnt) | ||
2162 | { | ||
2163 | return get_sb_pseudo(fs_type, "futex", NULL, FUTEXFS_SUPER_MAGIC, mnt); | ||
2164 | } | ||
2165 | |||
2166 | static struct file_system_type futex_fs_type = { | ||
2167 | .name = "futexfs", | ||
2168 | .get_sb = futexfs_get_sb, | ||
2169 | .kill_sb = kill_anon_super, | ||
2170 | }; | ||
2171 | |||
2172 | static int __init futex_init(void) | 2018 | static int __init futex_init(void) |
2173 | { | 2019 | { |
2174 | u32 curval; | 2020 | u32 curval; |
@@ -2193,16 +2039,6 @@ static int __init futex_init(void) | |||
2193 | spin_lock_init(&futex_queues[i].lock); | 2039 | spin_lock_init(&futex_queues[i].lock); |
2194 | } | 2040 | } |
2195 | 2041 | ||
2196 | i = register_filesystem(&futex_fs_type); | ||
2197 | if (i) | ||
2198 | return i; | ||
2199 | |||
2200 | futex_mnt = kern_mount(&futex_fs_type); | ||
2201 | if (IS_ERR(futex_mnt)) { | ||
2202 | unregister_filesystem(&futex_fs_type); | ||
2203 | return PTR_ERR(futex_mnt); | ||
2204 | } | ||
2205 | |||
2206 | return 0; | 2042 | return 0; |
2207 | } | 2043 | } |
2208 | __initcall(futex_init); | 2044 | __initcall(futex_init); |
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 9af1d6a8095e..421be5fe5cc7 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -154,15 +154,6 @@ static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base) | |||
154 | } | 154 | } |
155 | 155 | ||
156 | /* | 156 | /* |
157 | * Helper function to check, whether the timer is running the callback | ||
158 | * function | ||
159 | */ | ||
160 | static inline int hrtimer_callback_running(struct hrtimer *timer) | ||
161 | { | ||
162 | return timer->state & HRTIMER_STATE_CALLBACK; | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * Functions and macros which are different for UP/SMP systems are kept in a | 157 | * Functions and macros which are different for UP/SMP systems are kept in a |
167 | * single place | 158 | * single place |
168 | */ | 159 | */ |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 46e4ad1723f0..46d6611a33bb 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -150,6 +150,26 @@ void disable_irq(unsigned int irq) | |||
150 | } | 150 | } |
151 | EXPORT_SYMBOL(disable_irq); | 151 | EXPORT_SYMBOL(disable_irq); |
152 | 152 | ||
153 | static void __enable_irq(struct irq_desc *desc, unsigned int irq) | ||
154 | { | ||
155 | switch (desc->depth) { | ||
156 | case 0: | ||
157 | printk(KERN_WARNING "Unbalanced enable for IRQ %d\n", irq); | ||
158 | WARN_ON(1); | ||
159 | break; | ||
160 | case 1: { | ||
161 | unsigned int status = desc->status & ~IRQ_DISABLED; | ||
162 | |||
163 | /* Prevent probing on this irq: */ | ||
164 | desc->status = status | IRQ_NOPROBE; | ||
165 | check_irq_resend(desc, irq); | ||
166 | /* fall-through */ | ||
167 | } | ||
168 | default: | ||
169 | desc->depth--; | ||
170 | } | ||
171 | } | ||
172 | |||
153 | /** | 173 | /** |
154 | * enable_irq - enable handling of an irq | 174 | * enable_irq - enable handling of an irq |
155 | * @irq: Interrupt to enable | 175 | * @irq: Interrupt to enable |
@@ -169,22 +189,7 @@ void enable_irq(unsigned int irq) | |||
169 | return; | 189 | return; |
170 | 190 | ||
171 | spin_lock_irqsave(&desc->lock, flags); | 191 | spin_lock_irqsave(&desc->lock, flags); |
172 | switch (desc->depth) { | 192 | __enable_irq(desc, irq); |
173 | case 0: | ||
174 | printk(KERN_WARNING "Unbalanced enable for IRQ %d\n", irq); | ||
175 | WARN_ON(1); | ||
176 | break; | ||
177 | case 1: { | ||
178 | unsigned int status = desc->status & ~IRQ_DISABLED; | ||
179 | |||
180 | /* Prevent probing on this irq: */ | ||
181 | desc->status = status | IRQ_NOPROBE; | ||
182 | check_irq_resend(desc, irq); | ||
183 | /* fall-through */ | ||
184 | } | ||
185 | default: | ||
186 | desc->depth--; | ||
187 | } | ||
188 | spin_unlock_irqrestore(&desc->lock, flags); | 193 | spin_unlock_irqrestore(&desc->lock, flags); |
189 | } | 194 | } |
190 | EXPORT_SYMBOL(enable_irq); | 195 | EXPORT_SYMBOL(enable_irq); |
@@ -365,7 +370,7 @@ int setup_irq(unsigned int irq, struct irqaction *new) | |||
365 | compat_irq_chip_set_default_handler(desc); | 370 | compat_irq_chip_set_default_handler(desc); |
366 | 371 | ||
367 | desc->status &= ~(IRQ_AUTODETECT | IRQ_WAITING | | 372 | desc->status &= ~(IRQ_AUTODETECT | IRQ_WAITING | |
368 | IRQ_INPROGRESS); | 373 | IRQ_INPROGRESS | IRQ_SPURIOUS_DISABLED); |
369 | 374 | ||
370 | if (!(desc->status & IRQ_NOAUTOEN)) { | 375 | if (!(desc->status & IRQ_NOAUTOEN)) { |
371 | desc->depth = 0; | 376 | desc->depth = 0; |
@@ -381,6 +386,16 @@ int setup_irq(unsigned int irq, struct irqaction *new) | |||
381 | /* Reset broken irq detection when installing new handler */ | 386 | /* Reset broken irq detection when installing new handler */ |
382 | desc->irq_count = 0; | 387 | desc->irq_count = 0; |
383 | desc->irqs_unhandled = 0; | 388 | desc->irqs_unhandled = 0; |
389 | |||
390 | /* | ||
391 | * Check whether we disabled the irq via the spurious handler | ||
392 | * before. Reenable it and give it another chance. | ||
393 | */ | ||
394 | if (shared && (desc->status & IRQ_SPURIOUS_DISABLED)) { | ||
395 | desc->status &= ~IRQ_SPURIOUS_DISABLED; | ||
396 | __enable_irq(desc, irq); | ||
397 | } | ||
398 | |||
384 | spin_unlock_irqrestore(&desc->lock, flags); | 399 | spin_unlock_irqrestore(&desc->lock, flags); |
385 | 400 | ||
386 | new->irq = irq; | 401 | new->irq = irq; |
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index 088dabbf2d6a..c66d3f10e853 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c | |||
@@ -209,8 +209,8 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc, | |||
209 | * Now kill the IRQ | 209 | * Now kill the IRQ |
210 | */ | 210 | */ |
211 | printk(KERN_EMERG "Disabling IRQ #%d\n", irq); | 211 | printk(KERN_EMERG "Disabling IRQ #%d\n", irq); |
212 | desc->status |= IRQ_DISABLED; | 212 | desc->status |= IRQ_DISABLED | IRQ_SPURIOUS_DISABLED; |
213 | desc->depth = 1; | 213 | desc->depth++; |
214 | desc->chip->disable(irq); | 214 | desc->chip->disable(irq); |
215 | } | 215 | } |
216 | desc->irqs_unhandled = 0; | 216 | desc->irqs_unhandled = 0; |
diff --git a/kernel/kexec.c b/kernel/kexec.c index cb85c79989b4..1c5fcacbcf33 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
@@ -1217,7 +1217,7 @@ static int __init parse_crashkernel_mem(char *cmdline, | |||
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | /* match ? */ | 1219 | /* match ? */ |
1220 | if (system_ram >= start && system_ram <= end) { | 1220 | if (system_ram >= start && system_ram < end) { |
1221 | *crash_size = size; | 1221 | *crash_size = size; |
1222 | break; | 1222 | break; |
1223 | } | 1223 | } |
diff --git a/kernel/kgdb.c b/kernel/kgdb.c index 1bd0ec1c80b2..39e31a036f5b 100644 --- a/kernel/kgdb.c +++ b/kernel/kgdb.c | |||
@@ -61,7 +61,7 @@ struct kgdb_state { | |||
61 | int err_code; | 61 | int err_code; |
62 | int cpu; | 62 | int cpu; |
63 | int pass_exception; | 63 | int pass_exception; |
64 | long threadid; | 64 | unsigned long threadid; |
65 | long kgdb_usethreadid; | 65 | long kgdb_usethreadid; |
66 | struct pt_regs *linux_regs; | 66 | struct pt_regs *linux_regs; |
67 | }; | 67 | }; |
@@ -146,7 +146,7 @@ atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1); | |||
146 | * the other CPUs might interfere with your debugging context, so | 146 | * the other CPUs might interfere with your debugging context, so |
147 | * use this with care: | 147 | * use this with care: |
148 | */ | 148 | */ |
149 | int kgdb_do_roundup = 1; | 149 | static int kgdb_do_roundup = 1; |
150 | 150 | ||
151 | static int __init opt_nokgdbroundup(char *str) | 151 | static int __init opt_nokgdbroundup(char *str) |
152 | { | 152 | { |
@@ -438,7 +438,7 @@ int kgdb_hex2mem(char *buf, char *mem, int count) | |||
438 | * While we find nice hex chars, build a long_val. | 438 | * While we find nice hex chars, build a long_val. |
439 | * Return number of chars processed. | 439 | * Return number of chars processed. |
440 | */ | 440 | */ |
441 | int kgdb_hex2long(char **ptr, long *long_val) | 441 | int kgdb_hex2long(char **ptr, unsigned long *long_val) |
442 | { | 442 | { |
443 | int hex_val; | 443 | int hex_val; |
444 | int num = 0; | 444 | int num = 0; |
@@ -709,7 +709,7 @@ int kgdb_isremovedbreak(unsigned long addr) | |||
709 | return 0; | 709 | return 0; |
710 | } | 710 | } |
711 | 711 | ||
712 | int remove_all_break(void) | 712 | static int remove_all_break(void) |
713 | { | 713 | { |
714 | unsigned long addr; | 714 | unsigned long addr; |
715 | int error; | 715 | int error; |
diff --git a/kernel/kmod.c b/kernel/kmod.c index e2764047ec03..8df97d3dfda8 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/mnt_namespace.h> | 27 | #include <linux/mnt_namespace.h> |
28 | #include <linux/completion.h> | 28 | #include <linux/completion.h> |
29 | #include <linux/file.h> | 29 | #include <linux/file.h> |
30 | #include <linux/fdtable.h> | ||
30 | #include <linux/workqueue.h> | 31 | #include <linux/workqueue.h> |
31 | #include <linux/security.h> | 32 | #include <linux/security.h> |
32 | #include <linux/mount.h> | 33 | #include <linux/mount.h> |
diff --git a/kernel/module.c b/kernel/module.c index 8d6cccc6c3cf..8e4528c9909f 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -164,131 +164,140 @@ static const struct kernel_symbol *lookup_symbol(const char *name, | |||
164 | return NULL; | 164 | return NULL; |
165 | } | 165 | } |
166 | 166 | ||
167 | static void printk_unused_warning(const char *name) | 167 | static bool always_ok(bool gplok, bool warn, const char *name) |
168 | { | 168 | { |
169 | printk(KERN_WARNING "Symbol %s is marked as UNUSED, " | 169 | return true; |
170 | "however this module is using it.\n", name); | ||
171 | printk(KERN_WARNING "This symbol will go away in the future.\n"); | ||
172 | printk(KERN_WARNING "Please evalute if this is the right api to use, " | ||
173 | "and if it really is, submit a report the linux kernel " | ||
174 | "mailinglist together with submitting your code for " | ||
175 | "inclusion.\n"); | ||
176 | } | 170 | } |
177 | 171 | ||
178 | /* Find a symbol, return value, crc and module which owns it */ | 172 | static bool printk_unused_warning(bool gplok, bool warn, const char *name) |
179 | static unsigned long __find_symbol(const char *name, | ||
180 | struct module **owner, | ||
181 | const unsigned long **crc, | ||
182 | int gplok) | ||
183 | { | 173 | { |
184 | struct module *mod; | 174 | if (warn) { |
185 | const struct kernel_symbol *ks; | 175 | printk(KERN_WARNING "Symbol %s is marked as UNUSED, " |
186 | 176 | "however this module is using it.\n", name); | |
187 | /* Core kernel first. */ | 177 | printk(KERN_WARNING |
188 | *owner = NULL; | 178 | "This symbol will go away in the future.\n"); |
189 | ks = lookup_symbol(name, __start___ksymtab, __stop___ksymtab); | 179 | printk(KERN_WARNING |
190 | if (ks) { | 180 | "Please evalute if this is the right api to use and if " |
191 | *crc = symversion(__start___kcrctab, (ks - __start___ksymtab)); | 181 | "it really is, submit a report the linux kernel " |
192 | return ks->value; | 182 | "mailinglist together with submitting your code for " |
193 | } | 183 | "inclusion.\n"); |
194 | if (gplok) { | ||
195 | ks = lookup_symbol(name, __start___ksymtab_gpl, | ||
196 | __stop___ksymtab_gpl); | ||
197 | if (ks) { | ||
198 | *crc = symversion(__start___kcrctab_gpl, | ||
199 | (ks - __start___ksymtab_gpl)); | ||
200 | return ks->value; | ||
201 | } | ||
202 | } | 184 | } |
203 | ks = lookup_symbol(name, __start___ksymtab_gpl_future, | 185 | return true; |
204 | __stop___ksymtab_gpl_future); | 186 | } |
205 | if (ks) { | 187 | |
206 | if (!gplok) { | 188 | static bool gpl_only_unused_warning(bool gplok, bool warn, const char *name) |
207 | printk(KERN_WARNING "Symbol %s is being used " | 189 | { |
208 | "by a non-GPL module, which will not " | 190 | if (!gplok) |
209 | "be allowed in the future\n", name); | 191 | return false; |
210 | printk(KERN_WARNING "Please see the file " | 192 | return printk_unused_warning(gplok, warn, name); |
211 | "Documentation/feature-removal-schedule.txt " | 193 | } |
212 | "in the kernel source tree for more " | 194 | |
213 | "details.\n"); | 195 | static bool gpl_only(bool gplok, bool warn, const char *name) |
214 | } | 196 | { |
215 | *crc = symversion(__start___kcrctab_gpl_future, | 197 | return gplok; |
216 | (ks - __start___ksymtab_gpl_future)); | 198 | } |
217 | return ks->value; | 199 | |
200 | static bool warn_if_not_gpl(bool gplok, bool warn, const char *name) | ||
201 | { | ||
202 | if (!gplok && warn) { | ||
203 | printk(KERN_WARNING "Symbol %s is being used " | ||
204 | "by a non-GPL module, which will not " | ||
205 | "be allowed in the future\n", name); | ||
206 | printk(KERN_WARNING "Please see the file " | ||
207 | "Documentation/feature-removal-schedule.txt " | ||
208 | "in the kernel source tree for more details.\n"); | ||
218 | } | 209 | } |
210 | return true; | ||
211 | } | ||
219 | 212 | ||
220 | ks = lookup_symbol(name, __start___ksymtab_unused, | 213 | struct symsearch { |
221 | __stop___ksymtab_unused); | 214 | const struct kernel_symbol *start, *stop; |
222 | if (ks) { | 215 | const unsigned long *crcs; |
223 | printk_unused_warning(name); | 216 | bool (*check)(bool gplok, bool warn, const char *name); |
224 | *crc = symversion(__start___kcrctab_unused, | 217 | }; |
225 | (ks - __start___ksymtab_unused)); | 218 | |
226 | return ks->value; | 219 | /* Look through this array of symbol tables for a symbol match which |
220 | * passes the check function. */ | ||
221 | static const struct kernel_symbol *search_symarrays(const struct symsearch *arr, | ||
222 | unsigned int num, | ||
223 | const char *name, | ||
224 | bool gplok, | ||
225 | bool warn, | ||
226 | const unsigned long **crc) | ||
227 | { | ||
228 | unsigned int i; | ||
229 | const struct kernel_symbol *ks; | ||
230 | |||
231 | for (i = 0; i < num; i++) { | ||
232 | ks = lookup_symbol(name, arr[i].start, arr[i].stop); | ||
233 | if (!ks || !arr[i].check(gplok, warn, name)) | ||
234 | continue; | ||
235 | |||
236 | if (crc) | ||
237 | *crc = symversion(arr[i].crcs, ks - arr[i].start); | ||
238 | return ks; | ||
227 | } | 239 | } |
240 | return NULL; | ||
241 | } | ||
228 | 242 | ||
229 | if (gplok) | 243 | /* Find a symbol, return value, (optional) crc and (optional) module |
230 | ks = lookup_symbol(name, __start___ksymtab_unused_gpl, | 244 | * which owns it */ |
231 | __stop___ksymtab_unused_gpl); | 245 | static unsigned long find_symbol(const char *name, |
246 | struct module **owner, | ||
247 | const unsigned long **crc, | ||
248 | bool gplok, | ||
249 | bool warn) | ||
250 | { | ||
251 | struct module *mod; | ||
252 | const struct kernel_symbol *ks; | ||
253 | const struct symsearch arr[] = { | ||
254 | { __start___ksymtab, __stop___ksymtab, __start___kcrctab, | ||
255 | always_ok }, | ||
256 | { __start___ksymtab_gpl, __stop___ksymtab_gpl, | ||
257 | __start___kcrctab_gpl, gpl_only }, | ||
258 | { __start___ksymtab_gpl_future, __stop___ksymtab_gpl_future, | ||
259 | __start___kcrctab_gpl_future, warn_if_not_gpl }, | ||
260 | { __start___ksymtab_unused, __stop___ksymtab_unused, | ||
261 | __start___kcrctab_unused, printk_unused_warning }, | ||
262 | { __start___ksymtab_unused_gpl, __stop___ksymtab_unused_gpl, | ||
263 | __start___kcrctab_unused_gpl, gpl_only_unused_warning }, | ||
264 | }; | ||
265 | |||
266 | /* Core kernel first. */ | ||
267 | ks = search_symarrays(arr, ARRAY_SIZE(arr), name, gplok, warn, crc); | ||
232 | if (ks) { | 268 | if (ks) { |
233 | printk_unused_warning(name); | 269 | if (owner) |
234 | *crc = symversion(__start___kcrctab_unused_gpl, | 270 | *owner = NULL; |
235 | (ks - __start___ksymtab_unused_gpl)); | ||
236 | return ks->value; | 271 | return ks->value; |
237 | } | 272 | } |
238 | 273 | ||
239 | /* Now try modules. */ | 274 | /* Now try modules. */ |
240 | list_for_each_entry(mod, &modules, list) { | 275 | list_for_each_entry(mod, &modules, list) { |
241 | *owner = mod; | 276 | struct symsearch arr[] = { |
242 | ks = lookup_symbol(name, mod->syms, mod->syms + mod->num_syms); | 277 | { mod->syms, mod->syms + mod->num_syms, mod->crcs, |
278 | always_ok }, | ||
279 | { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms, | ||
280 | mod->gpl_crcs, gpl_only }, | ||
281 | { mod->gpl_future_syms, | ||
282 | mod->gpl_future_syms + mod->num_gpl_future_syms, | ||
283 | mod->gpl_future_crcs, warn_if_not_gpl }, | ||
284 | { mod->unused_syms, | ||
285 | mod->unused_syms + mod->num_unused_syms, | ||
286 | mod->unused_crcs, printk_unused_warning }, | ||
287 | { mod->unused_gpl_syms, | ||
288 | mod->unused_gpl_syms + mod->num_unused_gpl_syms, | ||
289 | mod->unused_gpl_crcs, gpl_only_unused_warning }, | ||
290 | }; | ||
291 | |||
292 | ks = search_symarrays(arr, ARRAY_SIZE(arr), | ||
293 | name, gplok, warn, crc); | ||
243 | if (ks) { | 294 | if (ks) { |
244 | *crc = symversion(mod->crcs, (ks - mod->syms)); | 295 | if (owner) |
245 | return ks->value; | 296 | *owner = mod; |
246 | } | ||
247 | |||
248 | if (gplok) { | ||
249 | ks = lookup_symbol(name, mod->gpl_syms, | ||
250 | mod->gpl_syms + mod->num_gpl_syms); | ||
251 | if (ks) { | ||
252 | *crc = symversion(mod->gpl_crcs, | ||
253 | (ks - mod->gpl_syms)); | ||
254 | return ks->value; | ||
255 | } | ||
256 | } | ||
257 | ks = lookup_symbol(name, mod->unused_syms, mod->unused_syms + mod->num_unused_syms); | ||
258 | if (ks) { | ||
259 | printk_unused_warning(name); | ||
260 | *crc = symversion(mod->unused_crcs, (ks - mod->unused_syms)); | ||
261 | return ks->value; | ||
262 | } | ||
263 | |||
264 | if (gplok) { | ||
265 | ks = lookup_symbol(name, mod->unused_gpl_syms, | ||
266 | mod->unused_gpl_syms + mod->num_unused_gpl_syms); | ||
267 | if (ks) { | ||
268 | printk_unused_warning(name); | ||
269 | *crc = symversion(mod->unused_gpl_crcs, | ||
270 | (ks - mod->unused_gpl_syms)); | ||
271 | return ks->value; | ||
272 | } | ||
273 | } | ||
274 | ks = lookup_symbol(name, mod->gpl_future_syms, | ||
275 | (mod->gpl_future_syms + | ||
276 | mod->num_gpl_future_syms)); | ||
277 | if (ks) { | ||
278 | if (!gplok) { | ||
279 | printk(KERN_WARNING "Symbol %s is being used " | ||
280 | "by a non-GPL module, which will not " | ||
281 | "be allowed in the future\n", name); | ||
282 | printk(KERN_WARNING "Please see the file " | ||
283 | "Documentation/feature-removal-schedule.txt " | ||
284 | "in the kernel source tree for more " | ||
285 | "details.\n"); | ||
286 | } | ||
287 | *crc = symversion(mod->gpl_future_crcs, | ||
288 | (ks - mod->gpl_future_syms)); | ||
289 | return ks->value; | 297 | return ks->value; |
290 | } | 298 | } |
291 | } | 299 | } |
300 | |||
292 | DEBUGP("Failed to find symbol %s\n", name); | 301 | DEBUGP("Failed to find symbol %s\n", name); |
293 | return -ENOENT; | 302 | return -ENOENT; |
294 | } | 303 | } |
@@ -736,12 +745,13 @@ sys_delete_module(const char __user *name_user, unsigned int flags) | |||
736 | if (!forced && module_refcount(mod) != 0) | 745 | if (!forced && module_refcount(mod) != 0) |
737 | wait_for_zero_refcount(mod); | 746 | wait_for_zero_refcount(mod); |
738 | 747 | ||
748 | mutex_unlock(&module_mutex); | ||
739 | /* Final destruction now noone is using it. */ | 749 | /* Final destruction now noone is using it. */ |
740 | if (mod->exit != NULL) { | 750 | if (mod->exit != NULL) |
741 | mutex_unlock(&module_mutex); | ||
742 | mod->exit(); | 751 | mod->exit(); |
743 | mutex_lock(&module_mutex); | 752 | blocking_notifier_call_chain(&module_notify_list, |
744 | } | 753 | MODULE_STATE_GOING, mod); |
754 | mutex_lock(&module_mutex); | ||
745 | /* Store the name of the last unloaded module for diagnostic purposes */ | 755 | /* Store the name of the last unloaded module for diagnostic purposes */ |
746 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); | 756 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); |
747 | free_module(mod); | 757 | free_module(mod); |
@@ -777,10 +787,9 @@ static void print_unload_info(struct seq_file *m, struct module *mod) | |||
777 | void __symbol_put(const char *symbol) | 787 | void __symbol_put(const char *symbol) |
778 | { | 788 | { |
779 | struct module *owner; | 789 | struct module *owner; |
780 | const unsigned long *crc; | ||
781 | 790 | ||
782 | preempt_disable(); | 791 | preempt_disable(); |
783 | if (IS_ERR_VALUE(__find_symbol(symbol, &owner, &crc, 1))) | 792 | if (IS_ERR_VALUE(find_symbol(symbol, &owner, NULL, true, false))) |
784 | BUG(); | 793 | BUG(); |
785 | module_put(owner); | 794 | module_put(owner); |
786 | preempt_enable(); | 795 | preempt_enable(); |
@@ -881,6 +890,19 @@ static struct module_attribute *modinfo_attrs[] = { | |||
881 | 890 | ||
882 | static const char vermagic[] = VERMAGIC_STRING; | 891 | static const char vermagic[] = VERMAGIC_STRING; |
883 | 892 | ||
893 | static int try_to_force_load(struct module *mod, const char *symname) | ||
894 | { | ||
895 | #ifdef CONFIG_MODULE_FORCE_LOAD | ||
896 | if (!(tainted & TAINT_FORCED_MODULE)) | ||
897 | printk("%s: no version for \"%s\" found: kernel tainted.\n", | ||
898 | mod->name, symname); | ||
899 | add_taint_module(mod, TAINT_FORCED_MODULE); | ||
900 | return 0; | ||
901 | #else | ||
902 | return -ENOEXEC; | ||
903 | #endif | ||
904 | } | ||
905 | |||
884 | #ifdef CONFIG_MODVERSIONS | 906 | #ifdef CONFIG_MODVERSIONS |
885 | static int check_version(Elf_Shdr *sechdrs, | 907 | static int check_version(Elf_Shdr *sechdrs, |
886 | unsigned int versindex, | 908 | unsigned int versindex, |
@@ -905,18 +927,18 @@ static int check_version(Elf_Shdr *sechdrs, | |||
905 | 927 | ||
906 | if (versions[i].crc == *crc) | 928 | if (versions[i].crc == *crc) |
907 | return 1; | 929 | return 1; |
908 | printk("%s: disagrees about version of symbol %s\n", | ||
909 | mod->name, symname); | ||
910 | DEBUGP("Found checksum %lX vs module %lX\n", | 930 | DEBUGP("Found checksum %lX vs module %lX\n", |
911 | *crc, versions[i].crc); | 931 | *crc, versions[i].crc); |
912 | return 0; | 932 | goto bad_version; |
913 | } | 933 | } |
914 | /* Not in module's version table. OK, but that taints the kernel. */ | 934 | |
915 | if (!(tainted & TAINT_FORCED_MODULE)) | 935 | if (!try_to_force_load(mod, symname)) |
916 | printk("%s: no version for \"%s\" found: kernel tainted.\n", | 936 | return 1; |
917 | mod->name, symname); | 937 | |
918 | add_taint_module(mod, TAINT_FORCED_MODULE); | 938 | bad_version: |
919 | return 1; | 939 | printk("%s: disagrees about version of symbol %s\n", |
940 | mod->name, symname); | ||
941 | return 0; | ||
920 | } | 942 | } |
921 | 943 | ||
922 | static inline int check_modstruct_version(Elf_Shdr *sechdrs, | 944 | static inline int check_modstruct_version(Elf_Shdr *sechdrs, |
@@ -924,13 +946,10 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs, | |||
924 | struct module *mod) | 946 | struct module *mod) |
925 | { | 947 | { |
926 | const unsigned long *crc; | 948 | const unsigned long *crc; |
927 | struct module *owner; | ||
928 | 949 | ||
929 | if (IS_ERR_VALUE(__find_symbol("struct_module", | 950 | if (IS_ERR_VALUE(find_symbol("struct_module", NULL, &crc, true, false))) |
930 | &owner, &crc, 1))) | ||
931 | BUG(); | 951 | BUG(); |
932 | return check_version(sechdrs, versindex, "struct_module", mod, | 952 | return check_version(sechdrs, versindex, "struct_module", mod, crc); |
933 | crc); | ||
934 | } | 953 | } |
935 | 954 | ||
936 | /* First part is kernel version, which we ignore. */ | 955 | /* First part is kernel version, which we ignore. */ |
@@ -974,8 +993,8 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs, | |||
974 | unsigned long ret; | 993 | unsigned long ret; |
975 | const unsigned long *crc; | 994 | const unsigned long *crc; |
976 | 995 | ||
977 | ret = __find_symbol(name, &owner, &crc, | 996 | ret = find_symbol(name, &owner, &crc, |
978 | !(mod->taints & TAINT_PROPRIETARY_MODULE)); | 997 | !(mod->taints & TAINT_PROPRIETARY_MODULE), true); |
979 | if (!IS_ERR_VALUE(ret)) { | 998 | if (!IS_ERR_VALUE(ret)) { |
980 | /* use_module can fail due to OOM, | 999 | /* use_module can fail due to OOM, |
981 | or module initialization or unloading */ | 1000 | or module initialization or unloading */ |
@@ -991,6 +1010,20 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs, | |||
991 | * J. Corbet <corbet@lwn.net> | 1010 | * J. Corbet <corbet@lwn.net> |
992 | */ | 1011 | */ |
993 | #if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS) | 1012 | #if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS) |
1013 | struct module_sect_attr | ||
1014 | { | ||
1015 | struct module_attribute mattr; | ||
1016 | char *name; | ||
1017 | unsigned long address; | ||
1018 | }; | ||
1019 | |||
1020 | struct module_sect_attrs | ||
1021 | { | ||
1022 | struct attribute_group grp; | ||
1023 | unsigned int nsections; | ||
1024 | struct module_sect_attr attrs[0]; | ||
1025 | }; | ||
1026 | |||
994 | static ssize_t module_sect_show(struct module_attribute *mattr, | 1027 | static ssize_t module_sect_show(struct module_attribute *mattr, |
995 | struct module *mod, char *buf) | 1028 | struct module *mod, char *buf) |
996 | { | 1029 | { |
@@ -1001,7 +1034,7 @@ static ssize_t module_sect_show(struct module_attribute *mattr, | |||
1001 | 1034 | ||
1002 | static void free_sect_attrs(struct module_sect_attrs *sect_attrs) | 1035 | static void free_sect_attrs(struct module_sect_attrs *sect_attrs) |
1003 | { | 1036 | { |
1004 | int section; | 1037 | unsigned int section; |
1005 | 1038 | ||
1006 | for (section = 0; section < sect_attrs->nsections; section++) | 1039 | for (section = 0; section < sect_attrs->nsections; section++) |
1007 | kfree(sect_attrs->attrs[section].name); | 1040 | kfree(sect_attrs->attrs[section].name); |
@@ -1362,10 +1395,9 @@ void *__symbol_get(const char *symbol) | |||
1362 | { | 1395 | { |
1363 | struct module *owner; | 1396 | struct module *owner; |
1364 | unsigned long value; | 1397 | unsigned long value; |
1365 | const unsigned long *crc; | ||
1366 | 1398 | ||
1367 | preempt_disable(); | 1399 | preempt_disable(); |
1368 | value = __find_symbol(symbol, &owner, &crc, 1); | 1400 | value = find_symbol(symbol, &owner, NULL, true, true); |
1369 | if (IS_ERR_VALUE(value)) | 1401 | if (IS_ERR_VALUE(value)) |
1370 | value = 0; | 1402 | value = 0; |
1371 | else if (strong_try_module_get(owner)) | 1403 | else if (strong_try_module_get(owner)) |
@@ -1382,33 +1414,33 @@ EXPORT_SYMBOL_GPL(__symbol_get); | |||
1382 | */ | 1414 | */ |
1383 | static int verify_export_symbols(struct module *mod) | 1415 | static int verify_export_symbols(struct module *mod) |
1384 | { | 1416 | { |
1385 | const char *name = NULL; | 1417 | unsigned int i; |
1386 | unsigned long i, ret = 0; | ||
1387 | struct module *owner; | 1418 | struct module *owner; |
1388 | const unsigned long *crc; | 1419 | const struct kernel_symbol *s; |
1389 | 1420 | struct { | |
1390 | for (i = 0; i < mod->num_syms; i++) | 1421 | const struct kernel_symbol *sym; |
1391 | if (!IS_ERR_VALUE(__find_symbol(mod->syms[i].name, | 1422 | unsigned int num; |
1392 | &owner, &crc, 1))) { | 1423 | } arr[] = { |
1393 | name = mod->syms[i].name; | 1424 | { mod->syms, mod->num_syms }, |
1394 | ret = -ENOEXEC; | 1425 | { mod->gpl_syms, mod->num_gpl_syms }, |
1395 | goto dup; | 1426 | { mod->gpl_future_syms, mod->num_gpl_future_syms }, |
1396 | } | 1427 | { mod->unused_syms, mod->num_unused_syms }, |
1428 | { mod->unused_gpl_syms, mod->num_unused_gpl_syms }, | ||
1429 | }; | ||
1397 | 1430 | ||
1398 | for (i = 0; i < mod->num_gpl_syms; i++) | 1431 | for (i = 0; i < ARRAY_SIZE(arr); i++) { |
1399 | if (!IS_ERR_VALUE(__find_symbol(mod->gpl_syms[i].name, | 1432 | for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) { |
1400 | &owner, &crc, 1))) { | 1433 | if (!IS_ERR_VALUE(find_symbol(s->name, &owner, |
1401 | name = mod->gpl_syms[i].name; | 1434 | NULL, true, false))) { |
1402 | ret = -ENOEXEC; | 1435 | printk(KERN_ERR |
1403 | goto dup; | 1436 | "%s: exports duplicate symbol %s" |
1437 | " (owned by %s)\n", | ||
1438 | mod->name, s->name, module_name(owner)); | ||
1439 | return -ENOEXEC; | ||
1440 | } | ||
1404 | } | 1441 | } |
1405 | 1442 | } | |
1406 | dup: | 1443 | return 0; |
1407 | if (ret) | ||
1408 | printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n", | ||
1409 | mod->name, name, module_name(owner)); | ||
1410 | |||
1411 | return ret; | ||
1412 | } | 1444 | } |
1413 | 1445 | ||
1414 | /* Change all symbols so that st_value encodes the pointer directly. */ | 1446 | /* Change all symbols so that st_value encodes the pointer directly. */ |
@@ -1814,8 +1846,9 @@ static struct module *load_module(void __user *umod, | |||
1814 | unwindex = find_sec(hdr, sechdrs, secstrings, ARCH_UNWIND_SECTION_NAME); | 1846 | unwindex = find_sec(hdr, sechdrs, secstrings, ARCH_UNWIND_SECTION_NAME); |
1815 | #endif | 1847 | #endif |
1816 | 1848 | ||
1817 | /* Don't keep modinfo section */ | 1849 | /* Don't keep modinfo and version sections. */ |
1818 | sechdrs[infoindex].sh_flags &= ~(unsigned long)SHF_ALLOC; | 1850 | sechdrs[infoindex].sh_flags &= ~(unsigned long)SHF_ALLOC; |
1851 | sechdrs[versindex].sh_flags &= ~(unsigned long)SHF_ALLOC; | ||
1819 | #ifdef CONFIG_KALLSYMS | 1852 | #ifdef CONFIG_KALLSYMS |
1820 | /* Keep symbol and string tables for decoding later. */ | 1853 | /* Keep symbol and string tables for decoding later. */ |
1821 | sechdrs[symindex].sh_flags |= SHF_ALLOC; | 1854 | sechdrs[symindex].sh_flags |= SHF_ALLOC; |
@@ -1833,9 +1866,9 @@ static struct module *load_module(void __user *umod, | |||
1833 | modmagic = get_modinfo(sechdrs, infoindex, "vermagic"); | 1866 | modmagic = get_modinfo(sechdrs, infoindex, "vermagic"); |
1834 | /* This is allowed: modprobe --force will invalidate it. */ | 1867 | /* This is allowed: modprobe --force will invalidate it. */ |
1835 | if (!modmagic) { | 1868 | if (!modmagic) { |
1836 | add_taint_module(mod, TAINT_FORCED_MODULE); | 1869 | err = try_to_force_load(mod, "magic"); |
1837 | printk(KERN_WARNING "%s: no version magic, tainting kernel.\n", | 1870 | if (err) |
1838 | mod->name); | 1871 | goto free_hdr; |
1839 | } else if (!same_magic(modmagic, vermagic)) { | 1872 | } else if (!same_magic(modmagic, vermagic)) { |
1840 | printk(KERN_ERR "%s: version magic '%s' should be '%s'\n", | 1873 | printk(KERN_ERR "%s: version magic '%s' should be '%s'\n", |
1841 | mod->name, modmagic, vermagic); | 1874 | mod->name, modmagic, vermagic); |
@@ -1977,7 +2010,8 @@ static struct module *load_module(void __user *umod, | |||
1977 | mod->unused_crcs = (void *)sechdrs[unusedcrcindex].sh_addr; | 2010 | mod->unused_crcs = (void *)sechdrs[unusedcrcindex].sh_addr; |
1978 | mod->unused_gpl_syms = (void *)sechdrs[unusedgplindex].sh_addr; | 2011 | mod->unused_gpl_syms = (void *)sechdrs[unusedgplindex].sh_addr; |
1979 | if (unusedgplcrcindex) | 2012 | if (unusedgplcrcindex) |
1980 | mod->unused_crcs = (void *)sechdrs[unusedgplcrcindex].sh_addr; | 2013 | mod->unused_gpl_crcs |
2014 | = (void *)sechdrs[unusedgplcrcindex].sh_addr; | ||
1981 | 2015 | ||
1982 | #ifdef CONFIG_MODVERSIONS | 2016 | #ifdef CONFIG_MODVERSIONS |
1983 | if ((mod->num_syms && !crcindex) || | 2017 | if ((mod->num_syms && !crcindex) || |
@@ -1985,9 +2019,10 @@ static struct module *load_module(void __user *umod, | |||
1985 | (mod->num_gpl_future_syms && !gplfuturecrcindex) || | 2019 | (mod->num_gpl_future_syms && !gplfuturecrcindex) || |
1986 | (mod->num_unused_syms && !unusedcrcindex) || | 2020 | (mod->num_unused_syms && !unusedcrcindex) || |
1987 | (mod->num_unused_gpl_syms && !unusedgplcrcindex)) { | 2021 | (mod->num_unused_gpl_syms && !unusedgplcrcindex)) { |
1988 | printk(KERN_WARNING "%s: No versions for exported symbols." | 2022 | printk(KERN_WARNING "%s: No versions for exported symbols.\n", mod->name); |
1989 | " Tainting kernel.\n", mod->name); | 2023 | err = try_to_force_load(mod, "nocrc"); |
1990 | add_taint_module(mod, TAINT_FORCED_MODULE); | 2024 | if (err) |
2025 | goto cleanup; | ||
1991 | } | 2026 | } |
1992 | #endif | 2027 | #endif |
1993 | markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); | 2028 | markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); |
@@ -2171,6 +2206,8 @@ sys_init_module(void __user *umod, | |||
2171 | mod->state = MODULE_STATE_GOING; | 2206 | mod->state = MODULE_STATE_GOING; |
2172 | synchronize_sched(); | 2207 | synchronize_sched(); |
2173 | module_put(mod); | 2208 | module_put(mod); |
2209 | blocking_notifier_call_chain(&module_notify_list, | ||
2210 | MODULE_STATE_GOING, mod); | ||
2174 | mutex_lock(&module_mutex); | 2211 | mutex_lock(&module_mutex); |
2175 | free_module(mod); | 2212 | free_module(mod); |
2176 | mutex_unlock(&module_mutex); | 2213 | mutex_unlock(&module_mutex); |
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index ae5c6c147c4b..f1525ad06cb3 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -4,8 +4,9 @@ | |||
4 | 4 | ||
5 | #include <linux/sched.h> | 5 | #include <linux/sched.h> |
6 | #include <linux/posix-timers.h> | 6 | #include <linux/posix-timers.h> |
7 | #include <asm/uaccess.h> | ||
8 | #include <linux/errno.h> | 7 | #include <linux/errno.h> |
8 | #include <linux/math64.h> | ||
9 | #include <asm/uaccess.h> | ||
9 | 10 | ||
10 | static int check_clock(const clockid_t which_clock) | 11 | static int check_clock(const clockid_t which_clock) |
11 | { | 12 | { |
@@ -47,12 +48,10 @@ static void sample_to_timespec(const clockid_t which_clock, | |||
47 | union cpu_time_count cpu, | 48 | union cpu_time_count cpu, |
48 | struct timespec *tp) | 49 | struct timespec *tp) |
49 | { | 50 | { |
50 | if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) { | 51 | if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) |
51 | tp->tv_sec = div_long_long_rem(cpu.sched, | 52 | *tp = ns_to_timespec(cpu.sched); |
52 | NSEC_PER_SEC, &tp->tv_nsec); | 53 | else |
53 | } else { | ||
54 | cputime_to_timespec(cpu.cpu, tp); | 54 | cputime_to_timespec(cpu.cpu, tp); |
55 | } | ||
56 | } | 55 | } |
57 | 56 | ||
58 | static inline int cpu_time_before(const clockid_t which_clock, | 57 | static inline int cpu_time_before(const clockid_t which_clock, |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index dcc199c43a12..6c19e94fd0a5 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -534,7 +534,6 @@ struct task_struct *ptrace_get_task_struct(pid_t pid) | |||
534 | #define arch_ptrace_attach(child) do { } while (0) | 534 | #define arch_ptrace_attach(child) do { } while (0) |
535 | #endif | 535 | #endif |
536 | 536 | ||
537 | #ifndef __ARCH_SYS_PTRACE | ||
538 | asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | 537 | asmlinkage long sys_ptrace(long request, long pid, long addr, long data) |
539 | { | 538 | { |
540 | struct task_struct *child; | 539 | struct task_struct *child; |
@@ -582,7 +581,6 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | |||
582 | unlock_kernel(); | 581 | unlock_kernel(); |
583 | return ret; | 582 | return ret; |
584 | } | 583 | } |
585 | #endif /* __ARCH_SYS_PTRACE */ | ||
586 | 584 | ||
587 | int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data) | 585 | int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data) |
588 | { | 586 | { |
diff --git a/kernel/sched.c b/kernel/sched.c index e2f7f5acc807..58fb8af15776 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -75,16 +75,6 @@ | |||
75 | #include <asm/irq_regs.h> | 75 | #include <asm/irq_regs.h> |
76 | 76 | ||
77 | /* | 77 | /* |
78 | * Scheduler clock - returns current time in nanosec units. | ||
79 | * This is default implementation. | ||
80 | * Architectures and sub-architectures can override this. | ||
81 | */ | ||
82 | unsigned long long __attribute__((weak)) sched_clock(void) | ||
83 | { | ||
84 | return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ); | ||
85 | } | ||
86 | |||
87 | /* | ||
88 | * Convert user-nice values [ -20 ... 0 ... 19 ] | 78 | * Convert user-nice values [ -20 ... 0 ... 19 ] |
89 | * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ], | 79 | * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ], |
90 | * and back. | 80 | * and back. |
@@ -242,6 +232,12 @@ static void destroy_rt_bandwidth(struct rt_bandwidth *rt_b) | |||
242 | } | 232 | } |
243 | #endif | 233 | #endif |
244 | 234 | ||
235 | /* | ||
236 | * sched_domains_mutex serializes calls to arch_init_sched_domains, | ||
237 | * detach_destroy_domains and partition_sched_domains. | ||
238 | */ | ||
239 | static DEFINE_MUTEX(sched_domains_mutex); | ||
240 | |||
245 | #ifdef CONFIG_GROUP_SCHED | 241 | #ifdef CONFIG_GROUP_SCHED |
246 | 242 | ||
247 | #include <linux/cgroup.h> | 243 | #include <linux/cgroup.h> |
@@ -308,9 +304,6 @@ static DEFINE_PER_CPU(struct rt_rq, init_rt_rq) ____cacheline_aligned_in_smp; | |||
308 | */ | 304 | */ |
309 | static DEFINE_SPINLOCK(task_group_lock); | 305 | static DEFINE_SPINLOCK(task_group_lock); |
310 | 306 | ||
311 | /* doms_cur_mutex serializes access to doms_cur[] array */ | ||
312 | static DEFINE_MUTEX(doms_cur_mutex); | ||
313 | |||
314 | #ifdef CONFIG_FAIR_GROUP_SCHED | 307 | #ifdef CONFIG_FAIR_GROUP_SCHED |
315 | #ifdef CONFIG_USER_SCHED | 308 | #ifdef CONFIG_USER_SCHED |
316 | # define INIT_TASK_GROUP_LOAD (2*NICE_0_LOAD) | 309 | # define INIT_TASK_GROUP_LOAD (2*NICE_0_LOAD) |
@@ -318,7 +311,13 @@ static DEFINE_MUTEX(doms_cur_mutex); | |||
318 | # define INIT_TASK_GROUP_LOAD NICE_0_LOAD | 311 | # define INIT_TASK_GROUP_LOAD NICE_0_LOAD |
319 | #endif | 312 | #endif |
320 | 313 | ||
314 | /* | ||
315 | * A weight of 0, 1 or ULONG_MAX can cause arithmetics problems. | ||
316 | * (The default weight is 1024 - so there's no practical | ||
317 | * limitation from this.) | ||
318 | */ | ||
321 | #define MIN_SHARES 2 | 319 | #define MIN_SHARES 2 |
320 | #define MAX_SHARES (ULONG_MAX - 1) | ||
322 | 321 | ||
323 | static int init_task_group_load = INIT_TASK_GROUP_LOAD; | 322 | static int init_task_group_load = INIT_TASK_GROUP_LOAD; |
324 | #endif | 323 | #endif |
@@ -358,21 +357,9 @@ static inline void set_task_rq(struct task_struct *p, unsigned int cpu) | |||
358 | #endif | 357 | #endif |
359 | } | 358 | } |
360 | 359 | ||
361 | static inline void lock_doms_cur(void) | ||
362 | { | ||
363 | mutex_lock(&doms_cur_mutex); | ||
364 | } | ||
365 | |||
366 | static inline void unlock_doms_cur(void) | ||
367 | { | ||
368 | mutex_unlock(&doms_cur_mutex); | ||
369 | } | ||
370 | |||
371 | #else | 360 | #else |
372 | 361 | ||
373 | static inline void set_task_rq(struct task_struct *p, unsigned int cpu) { } | 362 | static inline void set_task_rq(struct task_struct *p, unsigned int cpu) { } |
374 | static inline void lock_doms_cur(void) { } | ||
375 | static inline void unlock_doms_cur(void) { } | ||
376 | 363 | ||
377 | #endif /* CONFIG_GROUP_SCHED */ | 364 | #endif /* CONFIG_GROUP_SCHED */ |
378 | 365 | ||
@@ -560,13 +547,7 @@ struct rq { | |||
560 | unsigned long next_balance; | 547 | unsigned long next_balance; |
561 | struct mm_struct *prev_mm; | 548 | struct mm_struct *prev_mm; |
562 | 549 | ||
563 | u64 clock, prev_clock_raw; | 550 | u64 clock; |
564 | s64 clock_max_delta; | ||
565 | |||
566 | unsigned int clock_warps, clock_overflows, clock_underflows; | ||
567 | u64 idle_clock; | ||
568 | unsigned int clock_deep_idle_events; | ||
569 | u64 tick_timestamp; | ||
570 | 551 | ||
571 | atomic_t nr_iowait; | 552 | atomic_t nr_iowait; |
572 | 553 | ||
@@ -631,82 +612,6 @@ static inline int cpu_of(struct rq *rq) | |||
631 | #endif | 612 | #endif |
632 | } | 613 | } |
633 | 614 | ||
634 | #ifdef CONFIG_NO_HZ | ||
635 | static inline bool nohz_on(int cpu) | ||
636 | { | ||
637 | return tick_get_tick_sched(cpu)->nohz_mode != NOHZ_MODE_INACTIVE; | ||
638 | } | ||
639 | |||
640 | static inline u64 max_skipped_ticks(struct rq *rq) | ||
641 | { | ||
642 | return nohz_on(cpu_of(rq)) ? jiffies - rq->last_tick_seen + 2 : 1; | ||
643 | } | ||
644 | |||
645 | static inline void update_last_tick_seen(struct rq *rq) | ||
646 | { | ||
647 | rq->last_tick_seen = jiffies; | ||
648 | } | ||
649 | #else | ||
650 | static inline u64 max_skipped_ticks(struct rq *rq) | ||
651 | { | ||
652 | return 1; | ||
653 | } | ||
654 | |||
655 | static inline void update_last_tick_seen(struct rq *rq) | ||
656 | { | ||
657 | } | ||
658 | #endif | ||
659 | |||
660 | /* | ||
661 | * Update the per-runqueue clock, as finegrained as the platform can give | ||
662 | * us, but without assuming monotonicity, etc.: | ||
663 | */ | ||
664 | static void __update_rq_clock(struct rq *rq) | ||
665 | { | ||
666 | u64 prev_raw = rq->prev_clock_raw; | ||
667 | u64 now = sched_clock(); | ||
668 | s64 delta = now - prev_raw; | ||
669 | u64 clock = rq->clock; | ||
670 | |||
671 | #ifdef CONFIG_SCHED_DEBUG | ||
672 | WARN_ON_ONCE(cpu_of(rq) != smp_processor_id()); | ||
673 | #endif | ||
674 | /* | ||
675 | * Protect against sched_clock() occasionally going backwards: | ||
676 | */ | ||
677 | if (unlikely(delta < 0)) { | ||
678 | clock++; | ||
679 | rq->clock_warps++; | ||
680 | } else { | ||
681 | /* | ||
682 | * Catch too large forward jumps too: | ||
683 | */ | ||
684 | u64 max_jump = max_skipped_ticks(rq) * TICK_NSEC; | ||
685 | u64 max_time = rq->tick_timestamp + max_jump; | ||
686 | |||
687 | if (unlikely(clock + delta > max_time)) { | ||
688 | if (clock < max_time) | ||
689 | clock = max_time; | ||
690 | else | ||
691 | clock++; | ||
692 | rq->clock_overflows++; | ||
693 | } else { | ||
694 | if (unlikely(delta > rq->clock_max_delta)) | ||
695 | rq->clock_max_delta = delta; | ||
696 | clock += delta; | ||
697 | } | ||
698 | } | ||
699 | |||
700 | rq->prev_clock_raw = now; | ||
701 | rq->clock = clock; | ||
702 | } | ||
703 | |||
704 | static void update_rq_clock(struct rq *rq) | ||
705 | { | ||
706 | if (likely(smp_processor_id() == cpu_of(rq))) | ||
707 | __update_rq_clock(rq); | ||
708 | } | ||
709 | |||
710 | /* | 615 | /* |
711 | * The domain tree (rq->sd) is protected by RCU's quiescent state transition. | 616 | * The domain tree (rq->sd) is protected by RCU's quiescent state transition. |
712 | * See detach_destroy_domains: synchronize_sched for details. | 617 | * See detach_destroy_domains: synchronize_sched for details. |
@@ -722,6 +627,11 @@ static void update_rq_clock(struct rq *rq) | |||
722 | #define task_rq(p) cpu_rq(task_cpu(p)) | 627 | #define task_rq(p) cpu_rq(task_cpu(p)) |
723 | #define cpu_curr(cpu) (cpu_rq(cpu)->curr) | 628 | #define cpu_curr(cpu) (cpu_rq(cpu)->curr) |
724 | 629 | ||
630 | static inline void update_rq_clock(struct rq *rq) | ||
631 | { | ||
632 | rq->clock = sched_clock_cpu(cpu_of(rq)); | ||
633 | } | ||
634 | |||
725 | /* | 635 | /* |
726 | * Tunables that become constants when CONFIG_SCHED_DEBUG is off: | 636 | * Tunables that become constants when CONFIG_SCHED_DEBUG is off: |
727 | */ | 637 | */ |
@@ -757,14 +667,14 @@ const_debug unsigned int sysctl_sched_features = | |||
757 | #define SCHED_FEAT(name, enabled) \ | 667 | #define SCHED_FEAT(name, enabled) \ |
758 | #name , | 668 | #name , |
759 | 669 | ||
760 | __read_mostly char *sched_feat_names[] = { | 670 | static __read_mostly char *sched_feat_names[] = { |
761 | #include "sched_features.h" | 671 | #include "sched_features.h" |
762 | NULL | 672 | NULL |
763 | }; | 673 | }; |
764 | 674 | ||
765 | #undef SCHED_FEAT | 675 | #undef SCHED_FEAT |
766 | 676 | ||
767 | int sched_feat_open(struct inode *inode, struct file *filp) | 677 | static int sched_feat_open(struct inode *inode, struct file *filp) |
768 | { | 678 | { |
769 | filp->private_data = inode->i_private; | 679 | filp->private_data = inode->i_private; |
770 | return 0; | 680 | return 0; |
@@ -899,7 +809,7 @@ static inline u64 global_rt_runtime(void) | |||
899 | return (u64)sysctl_sched_rt_runtime * NSEC_PER_USEC; | 809 | return (u64)sysctl_sched_rt_runtime * NSEC_PER_USEC; |
900 | } | 810 | } |
901 | 811 | ||
902 | static const unsigned long long time_sync_thresh = 100000; | 812 | unsigned long long time_sync_thresh = 100000; |
903 | 813 | ||
904 | static DEFINE_PER_CPU(unsigned long long, time_offset); | 814 | static DEFINE_PER_CPU(unsigned long long, time_offset); |
905 | static DEFINE_PER_CPU(unsigned long long, prev_cpu_time); | 815 | static DEFINE_PER_CPU(unsigned long long, prev_cpu_time); |
@@ -913,11 +823,14 @@ static DEFINE_PER_CPU(unsigned long long, prev_cpu_time); | |||
913 | static DEFINE_SPINLOCK(time_sync_lock); | 823 | static DEFINE_SPINLOCK(time_sync_lock); |
914 | static unsigned long long prev_global_time; | 824 | static unsigned long long prev_global_time; |
915 | 825 | ||
916 | static unsigned long long __sync_cpu_clock(cycles_t time, int cpu) | 826 | static unsigned long long __sync_cpu_clock(unsigned long long time, int cpu) |
917 | { | 827 | { |
918 | unsigned long flags; | 828 | /* |
919 | 829 | * We want this inlined, to not get tracer function calls | |
920 | spin_lock_irqsave(&time_sync_lock, flags); | 830 | * in this critical section: |
831 | */ | ||
832 | spin_acquire(&time_sync_lock.dep_map, 0, 0, _THIS_IP_); | ||
833 | __raw_spin_lock(&time_sync_lock.raw_lock); | ||
921 | 834 | ||
922 | if (time < prev_global_time) { | 835 | if (time < prev_global_time) { |
923 | per_cpu(time_offset, cpu) += prev_global_time - time; | 836 | per_cpu(time_offset, cpu) += prev_global_time - time; |
@@ -926,7 +839,8 @@ static unsigned long long __sync_cpu_clock(cycles_t time, int cpu) | |||
926 | prev_global_time = time; | 839 | prev_global_time = time; |
927 | } | 840 | } |
928 | 841 | ||
929 | spin_unlock_irqrestore(&time_sync_lock, flags); | 842 | __raw_spin_unlock(&time_sync_lock.raw_lock); |
843 | spin_release(&time_sync_lock.dep_map, 1, _THIS_IP_); | ||
930 | 844 | ||
931 | return time; | 845 | return time; |
932 | } | 846 | } |
@@ -934,8 +848,6 @@ static unsigned long long __sync_cpu_clock(cycles_t time, int cpu) | |||
934 | static unsigned long long __cpu_clock(int cpu) | 848 | static unsigned long long __cpu_clock(int cpu) |
935 | { | 849 | { |
936 | unsigned long long now; | 850 | unsigned long long now; |
937 | unsigned long flags; | ||
938 | struct rq *rq; | ||
939 | 851 | ||
940 | /* | 852 | /* |
941 | * Only call sched_clock() if the scheduler has already been | 853 | * Only call sched_clock() if the scheduler has already been |
@@ -944,11 +856,7 @@ static unsigned long long __cpu_clock(int cpu) | |||
944 | if (unlikely(!scheduler_running)) | 856 | if (unlikely(!scheduler_running)) |
945 | return 0; | 857 | return 0; |
946 | 858 | ||
947 | local_irq_save(flags); | 859 | now = sched_clock_cpu(cpu); |
948 | rq = cpu_rq(cpu); | ||
949 | update_rq_clock(rq); | ||
950 | now = rq->clock; | ||
951 | local_irq_restore(flags); | ||
952 | 860 | ||
953 | return now; | 861 | return now; |
954 | } | 862 | } |
@@ -960,13 +868,18 @@ static unsigned long long __cpu_clock(int cpu) | |||
960 | unsigned long long cpu_clock(int cpu) | 868 | unsigned long long cpu_clock(int cpu) |
961 | { | 869 | { |
962 | unsigned long long prev_cpu_time, time, delta_time; | 870 | unsigned long long prev_cpu_time, time, delta_time; |
871 | unsigned long flags; | ||
963 | 872 | ||
873 | local_irq_save(flags); | ||
964 | prev_cpu_time = per_cpu(prev_cpu_time, cpu); | 874 | prev_cpu_time = per_cpu(prev_cpu_time, cpu); |
965 | time = __cpu_clock(cpu) + per_cpu(time_offset, cpu); | 875 | time = __cpu_clock(cpu) + per_cpu(time_offset, cpu); |
966 | delta_time = time-prev_cpu_time; | 876 | delta_time = time-prev_cpu_time; |
967 | 877 | ||
968 | if (unlikely(delta_time > time_sync_thresh)) | 878 | if (unlikely(delta_time > time_sync_thresh)) { |
969 | time = __sync_cpu_clock(time, cpu); | 879 | time = __sync_cpu_clock(time, cpu); |
880 | per_cpu(prev_cpu_time, cpu) = time; | ||
881 | } | ||
882 | local_irq_restore(flags); | ||
970 | 883 | ||
971 | return time; | 884 | return time; |
972 | } | 885 | } |
@@ -1117,43 +1030,6 @@ static struct rq *this_rq_lock(void) | |||
1117 | return rq; | 1030 | return rq; |
1118 | } | 1031 | } |
1119 | 1032 | ||
1120 | /* | ||
1121 | * We are going deep-idle (irqs are disabled): | ||
1122 | */ | ||
1123 | void sched_clock_idle_sleep_event(void) | ||
1124 | { | ||
1125 | struct rq *rq = cpu_rq(smp_processor_id()); | ||
1126 | |||
1127 | spin_lock(&rq->lock); | ||
1128 | __update_rq_clock(rq); | ||
1129 | spin_unlock(&rq->lock); | ||
1130 | rq->clock_deep_idle_events++; | ||
1131 | } | ||
1132 | EXPORT_SYMBOL_GPL(sched_clock_idle_sleep_event); | ||
1133 | |||
1134 | /* | ||
1135 | * We just idled delta nanoseconds (called with irqs disabled): | ||
1136 | */ | ||
1137 | void sched_clock_idle_wakeup_event(u64 delta_ns) | ||
1138 | { | ||
1139 | struct rq *rq = cpu_rq(smp_processor_id()); | ||
1140 | u64 now = sched_clock(); | ||
1141 | |||
1142 | rq->idle_clock += delta_ns; | ||
1143 | /* | ||
1144 | * Override the previous timestamp and ignore all | ||
1145 | * sched_clock() deltas that occured while we idled, | ||
1146 | * and use the PM-provided delta_ns to advance the | ||
1147 | * rq clock: | ||
1148 | */ | ||
1149 | spin_lock(&rq->lock); | ||
1150 | rq->prev_clock_raw = now; | ||
1151 | rq->clock += delta_ns; | ||
1152 | spin_unlock(&rq->lock); | ||
1153 | touch_softlockup_watchdog(); | ||
1154 | } | ||
1155 | EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event); | ||
1156 | |||
1157 | static void __resched_task(struct task_struct *p, int tif_bit); | 1033 | static void __resched_task(struct task_struct *p, int tif_bit); |
1158 | 1034 | ||
1159 | static inline void resched_task(struct task_struct *p) | 1035 | static inline void resched_task(struct task_struct *p) |
@@ -1189,6 +1065,7 @@ static inline void resched_rq(struct rq *rq) | |||
1189 | enum { | 1065 | enum { |
1190 | HRTICK_SET, /* re-programm hrtick_timer */ | 1066 | HRTICK_SET, /* re-programm hrtick_timer */ |
1191 | HRTICK_RESET, /* not a new slice */ | 1067 | HRTICK_RESET, /* not a new slice */ |
1068 | HRTICK_BLOCK, /* stop hrtick operations */ | ||
1192 | }; | 1069 | }; |
1193 | 1070 | ||
1194 | /* | 1071 | /* |
@@ -1200,6 +1077,8 @@ static inline int hrtick_enabled(struct rq *rq) | |||
1200 | { | 1077 | { |
1201 | if (!sched_feat(HRTICK)) | 1078 | if (!sched_feat(HRTICK)) |
1202 | return 0; | 1079 | return 0; |
1080 | if (unlikely(test_bit(HRTICK_BLOCK, &rq->hrtick_flags))) | ||
1081 | return 0; | ||
1203 | return hrtimer_is_hres_active(&rq->hrtick_timer); | 1082 | return hrtimer_is_hres_active(&rq->hrtick_timer); |
1204 | } | 1083 | } |
1205 | 1084 | ||
@@ -1275,14 +1154,70 @@ static enum hrtimer_restart hrtick(struct hrtimer *timer) | |||
1275 | WARN_ON_ONCE(cpu_of(rq) != smp_processor_id()); | 1154 | WARN_ON_ONCE(cpu_of(rq) != smp_processor_id()); |
1276 | 1155 | ||
1277 | spin_lock(&rq->lock); | 1156 | spin_lock(&rq->lock); |
1278 | __update_rq_clock(rq); | 1157 | update_rq_clock(rq); |
1279 | rq->curr->sched_class->task_tick(rq, rq->curr, 1); | 1158 | rq->curr->sched_class->task_tick(rq, rq->curr, 1); |
1280 | spin_unlock(&rq->lock); | 1159 | spin_unlock(&rq->lock); |
1281 | 1160 | ||
1282 | return HRTIMER_NORESTART; | 1161 | return HRTIMER_NORESTART; |
1283 | } | 1162 | } |
1284 | 1163 | ||
1285 | static inline void init_rq_hrtick(struct rq *rq) | 1164 | static void hotplug_hrtick_disable(int cpu) |
1165 | { | ||
1166 | struct rq *rq = cpu_rq(cpu); | ||
1167 | unsigned long flags; | ||
1168 | |||
1169 | spin_lock_irqsave(&rq->lock, flags); | ||
1170 | rq->hrtick_flags = 0; | ||
1171 | __set_bit(HRTICK_BLOCK, &rq->hrtick_flags); | ||
1172 | spin_unlock_irqrestore(&rq->lock, flags); | ||
1173 | |||
1174 | hrtick_clear(rq); | ||
1175 | } | ||
1176 | |||
1177 | static void hotplug_hrtick_enable(int cpu) | ||
1178 | { | ||
1179 | struct rq *rq = cpu_rq(cpu); | ||
1180 | unsigned long flags; | ||
1181 | |||
1182 | spin_lock_irqsave(&rq->lock, flags); | ||
1183 | __clear_bit(HRTICK_BLOCK, &rq->hrtick_flags); | ||
1184 | spin_unlock_irqrestore(&rq->lock, flags); | ||
1185 | } | ||
1186 | |||
1187 | static int | ||
1188 | hotplug_hrtick(struct notifier_block *nfb, unsigned long action, void *hcpu) | ||
1189 | { | ||
1190 | int cpu = (int)(long)hcpu; | ||
1191 | |||
1192 | switch (action) { | ||
1193 | case CPU_UP_CANCELED: | ||
1194 | case CPU_UP_CANCELED_FROZEN: | ||
1195 | case CPU_DOWN_PREPARE: | ||
1196 | case CPU_DOWN_PREPARE_FROZEN: | ||
1197 | case CPU_DEAD: | ||
1198 | case CPU_DEAD_FROZEN: | ||
1199 | hotplug_hrtick_disable(cpu); | ||
1200 | return NOTIFY_OK; | ||
1201 | |||
1202 | case CPU_UP_PREPARE: | ||
1203 | case CPU_UP_PREPARE_FROZEN: | ||
1204 | case CPU_DOWN_FAILED: | ||
1205 | case CPU_DOWN_FAILED_FROZEN: | ||
1206 | case CPU_ONLINE: | ||
1207 | case CPU_ONLINE_FROZEN: | ||
1208 | hotplug_hrtick_enable(cpu); | ||
1209 | return NOTIFY_OK; | ||
1210 | } | ||
1211 | |||
1212 | return NOTIFY_DONE; | ||
1213 | } | ||
1214 | |||
1215 | static void init_hrtick(void) | ||
1216 | { | ||
1217 | hotcpu_notifier(hotplug_hrtick, 0); | ||
1218 | } | ||
1219 | |||
1220 | static void init_rq_hrtick(struct rq *rq) | ||
1286 | { | 1221 | { |
1287 | rq->hrtick_flags = 0; | 1222 | rq->hrtick_flags = 0; |
1288 | hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 1223 | hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
@@ -1319,6 +1254,10 @@ static inline void init_rq_hrtick(struct rq *rq) | |||
1319 | void hrtick_resched(void) | 1254 | void hrtick_resched(void) |
1320 | { | 1255 | { |
1321 | } | 1256 | } |
1257 | |||
1258 | static inline void init_hrtick(void) | ||
1259 | { | ||
1260 | } | ||
1322 | #endif | 1261 | #endif |
1323 | 1262 | ||
1324 | /* | 1263 | /* |
@@ -1438,8 +1377,8 @@ calc_delta_mine(unsigned long delta_exec, unsigned long weight, | |||
1438 | { | 1377 | { |
1439 | u64 tmp; | 1378 | u64 tmp; |
1440 | 1379 | ||
1441 | if (unlikely(!lw->inv_weight)) | 1380 | if (!lw->inv_weight) |
1442 | lw->inv_weight = (WMULT_CONST-lw->weight/2) / (lw->weight+1); | 1381 | lw->inv_weight = 1 + (WMULT_CONST-lw->weight/2)/(lw->weight+1); |
1443 | 1382 | ||
1444 | tmp = (u64)delta_exec * weight; | 1383 | tmp = (u64)delta_exec * weight; |
1445 | /* | 1384 | /* |
@@ -1748,6 +1687,8 @@ __update_group_shares_cpu(struct task_group *tg, struct sched_domain *sd, | |||
1748 | 1687 | ||
1749 | if (shares < MIN_SHARES) | 1688 | if (shares < MIN_SHARES) |
1750 | shares = MIN_SHARES; | 1689 | shares = MIN_SHARES; |
1690 | else if (shares > MAX_SHARES) | ||
1691 | shares = MAX_SHARES; | ||
1751 | 1692 | ||
1752 | __set_se_shares(tg->se[tcpu], shares); | 1693 | __set_se_shares(tg->se[tcpu], shares); |
1753 | } | 1694 | } |
@@ -4339,8 +4280,10 @@ void account_system_time(struct task_struct *p, int hardirq_offset, | |||
4339 | struct rq *rq = this_rq(); | 4280 | struct rq *rq = this_rq(); |
4340 | cputime64_t tmp; | 4281 | cputime64_t tmp; |
4341 | 4282 | ||
4342 | if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) | 4283 | if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) { |
4343 | return account_guest_time(p, cputime); | 4284 | account_guest_time(p, cputime); |
4285 | return; | ||
4286 | } | ||
4344 | 4287 | ||
4345 | p->stime = cputime_add(p->stime, cputime); | 4288 | p->stime = cputime_add(p->stime, cputime); |
4346 | 4289 | ||
@@ -4404,19 +4347,11 @@ void scheduler_tick(void) | |||
4404 | int cpu = smp_processor_id(); | 4347 | int cpu = smp_processor_id(); |
4405 | struct rq *rq = cpu_rq(cpu); | 4348 | struct rq *rq = cpu_rq(cpu); |
4406 | struct task_struct *curr = rq->curr; | 4349 | struct task_struct *curr = rq->curr; |
4407 | u64 next_tick = rq->tick_timestamp + TICK_NSEC; | 4350 | |
4351 | sched_clock_tick(); | ||
4408 | 4352 | ||
4409 | spin_lock(&rq->lock); | 4353 | spin_lock(&rq->lock); |
4410 | __update_rq_clock(rq); | 4354 | update_rq_clock(rq); |
4411 | /* | ||
4412 | * Let rq->clock advance by at least TICK_NSEC: | ||
4413 | */ | ||
4414 | if (unlikely(rq->clock < next_tick)) { | ||
4415 | rq->clock = next_tick; | ||
4416 | rq->clock_underflows++; | ||
4417 | } | ||
4418 | rq->tick_timestamp = rq->clock; | ||
4419 | update_last_tick_seen(rq); | ||
4420 | update_cpu_load(rq); | 4355 | update_cpu_load(rq); |
4421 | curr->sched_class->task_tick(rq, curr, 0); | 4356 | curr->sched_class->task_tick(rq, curr, 0); |
4422 | spin_unlock(&rq->lock); | 4357 | spin_unlock(&rq->lock); |
@@ -4570,7 +4505,7 @@ need_resched_nonpreemptible: | |||
4570 | * Do the rq-clock update outside the rq lock: | 4505 | * Do the rq-clock update outside the rq lock: |
4571 | */ | 4506 | */ |
4572 | local_irq_disable(); | 4507 | local_irq_disable(); |
4573 | __update_rq_clock(rq); | 4508 | update_rq_clock(rq); |
4574 | spin_lock(&rq->lock); | 4509 | spin_lock(&rq->lock); |
4575 | clear_tsk_need_resched(prev); | 4510 | clear_tsk_need_resched(prev); |
4576 | 4511 | ||
@@ -4595,9 +4530,9 @@ need_resched_nonpreemptible: | |||
4595 | prev->sched_class->put_prev_task(rq, prev); | 4530 | prev->sched_class->put_prev_task(rq, prev); |
4596 | next = pick_next_task(rq, prev); | 4531 | next = pick_next_task(rq, prev); |
4597 | 4532 | ||
4598 | sched_info_switch(prev, next); | ||
4599 | |||
4600 | if (likely(prev != next)) { | 4533 | if (likely(prev != next)) { |
4534 | sched_info_switch(prev, next); | ||
4535 | |||
4601 | rq->nr_switches++; | 4536 | rq->nr_switches++; |
4602 | rq->curr = next; | 4537 | rq->curr = next; |
4603 | ++*switch_count; | 4538 | ++*switch_count; |
@@ -7755,7 +7690,7 @@ void partition_sched_domains(int ndoms_new, cpumask_t *doms_new, | |||
7755 | { | 7690 | { |
7756 | int i, j; | 7691 | int i, j; |
7757 | 7692 | ||
7758 | lock_doms_cur(); | 7693 | mutex_lock(&sched_domains_mutex); |
7759 | 7694 | ||
7760 | /* always unregister in case we don't destroy any domains */ | 7695 | /* always unregister in case we don't destroy any domains */ |
7761 | unregister_sched_domain_sysctl(); | 7696 | unregister_sched_domain_sysctl(); |
@@ -7804,7 +7739,7 @@ match2: | |||
7804 | 7739 | ||
7805 | register_sched_domain_sysctl(); | 7740 | register_sched_domain_sysctl(); |
7806 | 7741 | ||
7807 | unlock_doms_cur(); | 7742 | mutex_unlock(&sched_domains_mutex); |
7808 | } | 7743 | } |
7809 | 7744 | ||
7810 | #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) | 7745 | #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) |
@@ -7813,8 +7748,10 @@ int arch_reinit_sched_domains(void) | |||
7813 | int err; | 7748 | int err; |
7814 | 7749 | ||
7815 | get_online_cpus(); | 7750 | get_online_cpus(); |
7751 | mutex_lock(&sched_domains_mutex); | ||
7816 | detach_destroy_domains(&cpu_online_map); | 7752 | detach_destroy_domains(&cpu_online_map); |
7817 | err = arch_init_sched_domains(&cpu_online_map); | 7753 | err = arch_init_sched_domains(&cpu_online_map); |
7754 | mutex_unlock(&sched_domains_mutex); | ||
7818 | put_online_cpus(); | 7755 | put_online_cpus(); |
7819 | 7756 | ||
7820 | return err; | 7757 | return err; |
@@ -7932,13 +7869,16 @@ void __init sched_init_smp(void) | |||
7932 | BUG_ON(sched_group_nodes_bycpu == NULL); | 7869 | BUG_ON(sched_group_nodes_bycpu == NULL); |
7933 | #endif | 7870 | #endif |
7934 | get_online_cpus(); | 7871 | get_online_cpus(); |
7872 | mutex_lock(&sched_domains_mutex); | ||
7935 | arch_init_sched_domains(&cpu_online_map); | 7873 | arch_init_sched_domains(&cpu_online_map); |
7936 | cpus_andnot(non_isolated_cpus, cpu_possible_map, cpu_isolated_map); | 7874 | cpus_andnot(non_isolated_cpus, cpu_possible_map, cpu_isolated_map); |
7937 | if (cpus_empty(non_isolated_cpus)) | 7875 | if (cpus_empty(non_isolated_cpus)) |
7938 | cpu_set(smp_processor_id(), non_isolated_cpus); | 7876 | cpu_set(smp_processor_id(), non_isolated_cpus); |
7877 | mutex_unlock(&sched_domains_mutex); | ||
7939 | put_online_cpus(); | 7878 | put_online_cpus(); |
7940 | /* XXX: Theoretical race here - CPU may be hotplugged now */ | 7879 | /* XXX: Theoretical race here - CPU may be hotplugged now */ |
7941 | hotcpu_notifier(update_sched_domains, 0); | 7880 | hotcpu_notifier(update_sched_domains, 0); |
7881 | init_hrtick(); | ||
7942 | 7882 | ||
7943 | /* Move init over to a non-isolated CPU */ | 7883 | /* Move init over to a non-isolated CPU */ |
7944 | if (set_cpus_allowed_ptr(current, &non_isolated_cpus) < 0) | 7884 | if (set_cpus_allowed_ptr(current, &non_isolated_cpus) < 0) |
@@ -8025,7 +7965,7 @@ static void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq, | |||
8025 | 7965 | ||
8026 | se->my_q = cfs_rq; | 7966 | se->my_q = cfs_rq; |
8027 | se->load.weight = tg->shares; | 7967 | se->load.weight = tg->shares; |
8028 | se->load.inv_weight = div64_64(1ULL<<32, se->load.weight); | 7968 | se->load.inv_weight = 0; |
8029 | se->parent = parent; | 7969 | se->parent = parent; |
8030 | } | 7970 | } |
8031 | #endif | 7971 | #endif |
@@ -8149,8 +8089,6 @@ void __init sched_init(void) | |||
8149 | spin_lock_init(&rq->lock); | 8089 | spin_lock_init(&rq->lock); |
8150 | lockdep_set_class(&rq->lock, &rq->rq_lock_key); | 8090 | lockdep_set_class(&rq->lock, &rq->rq_lock_key); |
8151 | rq->nr_running = 0; | 8091 | rq->nr_running = 0; |
8152 | rq->clock = 1; | ||
8153 | update_last_tick_seen(rq); | ||
8154 | init_cfs_rq(&rq->cfs, rq); | 8092 | init_cfs_rq(&rq->cfs, rq); |
8155 | init_rt_rq(&rq->rt, rq); | 8093 | init_rt_rq(&rq->rt, rq); |
8156 | #ifdef CONFIG_FAIR_GROUP_SCHED | 8094 | #ifdef CONFIG_FAIR_GROUP_SCHED |
@@ -8294,6 +8232,7 @@ EXPORT_SYMBOL(__might_sleep); | |||
8294 | static void normalize_task(struct rq *rq, struct task_struct *p) | 8232 | static void normalize_task(struct rq *rq, struct task_struct *p) |
8295 | { | 8233 | { |
8296 | int on_rq; | 8234 | int on_rq; |
8235 | |||
8297 | update_rq_clock(rq); | 8236 | update_rq_clock(rq); |
8298 | on_rq = p->se.on_rq; | 8237 | on_rq = p->se.on_rq; |
8299 | if (on_rq) | 8238 | if (on_rq) |
@@ -8325,7 +8264,6 @@ void normalize_rt_tasks(void) | |||
8325 | p->se.sleep_start = 0; | 8264 | p->se.sleep_start = 0; |
8326 | p->se.block_start = 0; | 8265 | p->se.block_start = 0; |
8327 | #endif | 8266 | #endif |
8328 | task_rq(p)->clock = 0; | ||
8329 | 8267 | ||
8330 | if (!rt_task(p)) { | 8268 | if (!rt_task(p)) { |
8331 | /* | 8269 | /* |
@@ -8692,7 +8630,7 @@ static void __set_se_shares(struct sched_entity *se, unsigned long shares) | |||
8692 | dequeue_entity(cfs_rq, se, 0); | 8630 | dequeue_entity(cfs_rq, se, 0); |
8693 | 8631 | ||
8694 | se->load.weight = shares; | 8632 | se->load.weight = shares; |
8695 | se->load.inv_weight = div64_64((1ULL<<32), shares); | 8633 | se->load.inv_weight = 0; |
8696 | 8634 | ||
8697 | if (on_rq) | 8635 | if (on_rq) |
8698 | enqueue_entity(cfs_rq, se, 0); | 8636 | enqueue_entity(cfs_rq, se, 0); |
@@ -8722,13 +8660,10 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares) | |||
8722 | if (!tg->se[0]) | 8660 | if (!tg->se[0]) |
8723 | return -EINVAL; | 8661 | return -EINVAL; |
8724 | 8662 | ||
8725 | /* | ||
8726 | * A weight of 0 or 1 can cause arithmetics problems. | ||
8727 | * (The default weight is 1024 - so there's no practical | ||
8728 | * limitation from this.) | ||
8729 | */ | ||
8730 | if (shares < MIN_SHARES) | 8663 | if (shares < MIN_SHARES) |
8731 | shares = MIN_SHARES; | 8664 | shares = MIN_SHARES; |
8665 | else if (shares > MAX_SHARES) | ||
8666 | shares = MAX_SHARES; | ||
8732 | 8667 | ||
8733 | mutex_lock(&shares_mutex); | 8668 | mutex_lock(&shares_mutex); |
8734 | if (tg->shares == shares) | 8669 | if (tg->shares == shares) |
@@ -8753,7 +8688,7 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares) | |||
8753 | * force a rebalance | 8688 | * force a rebalance |
8754 | */ | 8689 | */ |
8755 | cfs_rq_set_shares(tg->cfs_rq[i], 0); | 8690 | cfs_rq_set_shares(tg->cfs_rq[i], 0); |
8756 | set_se_shares(tg->se[i], shares/nr_cpu_ids); | 8691 | set_se_shares(tg->se[i], shares); |
8757 | } | 8692 | } |
8758 | 8693 | ||
8759 | /* | 8694 | /* |
@@ -8787,7 +8722,7 @@ static unsigned long to_ratio(u64 period, u64 runtime) | |||
8787 | if (runtime == RUNTIME_INF) | 8722 | if (runtime == RUNTIME_INF) |
8788 | return 1ULL << 16; | 8723 | return 1ULL << 16; |
8789 | 8724 | ||
8790 | return div64_64(runtime << 16, period); | 8725 | return div64_u64(runtime << 16, period); |
8791 | } | 8726 | } |
8792 | 8727 | ||
8793 | #ifdef CONFIG_CGROUP_SCHED | 8728 | #ifdef CONFIG_CGROUP_SCHED |
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c new file mode 100644 index 000000000000..9c597e37f7de --- /dev/null +++ b/kernel/sched_clock.c | |||
@@ -0,0 +1,236 @@ | |||
1 | /* | ||
2 | * sched_clock for unstable cpu clocks | ||
3 | * | ||
4 | * Copyright (C) 2008 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com> | ||
5 | * | ||
6 | * Based on code by: | ||
7 | * Ingo Molnar <mingo@redhat.com> | ||
8 | * Guillaume Chazarain <guichaz@gmail.com> | ||
9 | * | ||
10 | * Create a semi stable clock from a mixture of other events, including: | ||
11 | * - gtod | ||
12 | * - jiffies | ||
13 | * - sched_clock() | ||
14 | * - explicit idle events | ||
15 | * | ||
16 | * We use gtod as base and the unstable clock deltas. The deltas are filtered, | ||
17 | * making it monotonic and keeping it within an expected window. This window | ||
18 | * is set up using jiffies. | ||
19 | * | ||
20 | * Furthermore, explicit sleep and wakeup hooks allow us to account for time | ||
21 | * that is otherwise invisible (TSC gets stopped). | ||
22 | * | ||
23 | * The clock: sched_clock_cpu() is monotonic per cpu, and should be somewhat | ||
24 | * consistent between cpus (never more than 1 jiffies difference). | ||
25 | */ | ||
26 | #include <linux/sched.h> | ||
27 | #include <linux/percpu.h> | ||
28 | #include <linux/spinlock.h> | ||
29 | #include <linux/ktime.h> | ||
30 | #include <linux/module.h> | ||
31 | |||
32 | |||
33 | #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK | ||
34 | |||
35 | struct sched_clock_data { | ||
36 | /* | ||
37 | * Raw spinlock - this is a special case: this might be called | ||
38 | * from within instrumentation code so we dont want to do any | ||
39 | * instrumentation ourselves. | ||
40 | */ | ||
41 | raw_spinlock_t lock; | ||
42 | |||
43 | unsigned long prev_jiffies; | ||
44 | u64 prev_raw; | ||
45 | u64 tick_raw; | ||
46 | u64 tick_gtod; | ||
47 | u64 clock; | ||
48 | }; | ||
49 | |||
50 | static DEFINE_PER_CPU_SHARED_ALIGNED(struct sched_clock_data, sched_clock_data); | ||
51 | |||
52 | static inline struct sched_clock_data *this_scd(void) | ||
53 | { | ||
54 | return &__get_cpu_var(sched_clock_data); | ||
55 | } | ||
56 | |||
57 | static inline struct sched_clock_data *cpu_sdc(int cpu) | ||
58 | { | ||
59 | return &per_cpu(sched_clock_data, cpu); | ||
60 | } | ||
61 | |||
62 | void sched_clock_init(void) | ||
63 | { | ||
64 | u64 ktime_now = ktime_to_ns(ktime_get()); | ||
65 | u64 now = 0; | ||
66 | int cpu; | ||
67 | |||
68 | for_each_possible_cpu(cpu) { | ||
69 | struct sched_clock_data *scd = cpu_sdc(cpu); | ||
70 | |||
71 | scd->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | ||
72 | scd->prev_jiffies = jiffies; | ||
73 | scd->prev_raw = now; | ||
74 | scd->tick_raw = now; | ||
75 | scd->tick_gtod = ktime_now; | ||
76 | scd->clock = ktime_now; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | /* | ||
81 | * update the percpu scd from the raw @now value | ||
82 | * | ||
83 | * - filter out backward motion | ||
84 | * - use jiffies to generate a min,max window to clip the raw values | ||
85 | */ | ||
86 | static void __update_sched_clock(struct sched_clock_data *scd, u64 now) | ||
87 | { | ||
88 | unsigned long now_jiffies = jiffies; | ||
89 | long delta_jiffies = now_jiffies - scd->prev_jiffies; | ||
90 | u64 clock = scd->clock; | ||
91 | u64 min_clock, max_clock; | ||
92 | s64 delta = now - scd->prev_raw; | ||
93 | |||
94 | WARN_ON_ONCE(!irqs_disabled()); | ||
95 | min_clock = scd->tick_gtod + delta_jiffies * TICK_NSEC; | ||
96 | |||
97 | if (unlikely(delta < 0)) { | ||
98 | clock++; | ||
99 | goto out; | ||
100 | } | ||
101 | |||
102 | max_clock = min_clock + TICK_NSEC; | ||
103 | |||
104 | if (unlikely(clock + delta > max_clock)) { | ||
105 | if (clock < max_clock) | ||
106 | clock = max_clock; | ||
107 | else | ||
108 | clock++; | ||
109 | } else { | ||
110 | clock += delta; | ||
111 | } | ||
112 | |||
113 | out: | ||
114 | if (unlikely(clock < min_clock)) | ||
115 | clock = min_clock; | ||
116 | |||
117 | scd->prev_raw = now; | ||
118 | scd->prev_jiffies = now_jiffies; | ||
119 | scd->clock = clock; | ||
120 | } | ||
121 | |||
122 | static void lock_double_clock(struct sched_clock_data *data1, | ||
123 | struct sched_clock_data *data2) | ||
124 | { | ||
125 | if (data1 < data2) { | ||
126 | __raw_spin_lock(&data1->lock); | ||
127 | __raw_spin_lock(&data2->lock); | ||
128 | } else { | ||
129 | __raw_spin_lock(&data2->lock); | ||
130 | __raw_spin_lock(&data1->lock); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | u64 sched_clock_cpu(int cpu) | ||
135 | { | ||
136 | struct sched_clock_data *scd = cpu_sdc(cpu); | ||
137 | u64 now, clock; | ||
138 | |||
139 | WARN_ON_ONCE(!irqs_disabled()); | ||
140 | now = sched_clock(); | ||
141 | |||
142 | if (cpu != raw_smp_processor_id()) { | ||
143 | /* | ||
144 | * in order to update a remote cpu's clock based on our | ||
145 | * unstable raw time rebase it against: | ||
146 | * tick_raw (offset between raw counters) | ||
147 | * tick_gotd (tick offset between cpus) | ||
148 | */ | ||
149 | struct sched_clock_data *my_scd = this_scd(); | ||
150 | |||
151 | lock_double_clock(scd, my_scd); | ||
152 | |||
153 | now -= my_scd->tick_raw; | ||
154 | now += scd->tick_raw; | ||
155 | |||
156 | now -= my_scd->tick_gtod; | ||
157 | now += scd->tick_gtod; | ||
158 | |||
159 | __raw_spin_unlock(&my_scd->lock); | ||
160 | } else { | ||
161 | __raw_spin_lock(&scd->lock); | ||
162 | } | ||
163 | |||
164 | __update_sched_clock(scd, now); | ||
165 | clock = scd->clock; | ||
166 | |||
167 | __raw_spin_unlock(&scd->lock); | ||
168 | |||
169 | return clock; | ||
170 | } | ||
171 | |||
172 | void sched_clock_tick(void) | ||
173 | { | ||
174 | struct sched_clock_data *scd = this_scd(); | ||
175 | u64 now, now_gtod; | ||
176 | |||
177 | WARN_ON_ONCE(!irqs_disabled()); | ||
178 | |||
179 | now = sched_clock(); | ||
180 | now_gtod = ktime_to_ns(ktime_get()); | ||
181 | |||
182 | __raw_spin_lock(&scd->lock); | ||
183 | __update_sched_clock(scd, now); | ||
184 | /* | ||
185 | * update tick_gtod after __update_sched_clock() because that will | ||
186 | * already observe 1 new jiffy; adding a new tick_gtod to that would | ||
187 | * increase the clock 2 jiffies. | ||
188 | */ | ||
189 | scd->tick_raw = now; | ||
190 | scd->tick_gtod = now_gtod; | ||
191 | __raw_spin_unlock(&scd->lock); | ||
192 | } | ||
193 | |||
194 | /* | ||
195 | * We are going deep-idle (irqs are disabled): | ||
196 | */ | ||
197 | void sched_clock_idle_sleep_event(void) | ||
198 | { | ||
199 | sched_clock_cpu(smp_processor_id()); | ||
200 | } | ||
201 | EXPORT_SYMBOL_GPL(sched_clock_idle_sleep_event); | ||
202 | |||
203 | /* | ||
204 | * We just idled delta nanoseconds (called with irqs disabled): | ||
205 | */ | ||
206 | void sched_clock_idle_wakeup_event(u64 delta_ns) | ||
207 | { | ||
208 | struct sched_clock_data *scd = this_scd(); | ||
209 | u64 now = sched_clock(); | ||
210 | |||
211 | /* | ||
212 | * Override the previous timestamp and ignore all | ||
213 | * sched_clock() deltas that occured while we idled, | ||
214 | * and use the PM-provided delta_ns to advance the | ||
215 | * rq clock: | ||
216 | */ | ||
217 | __raw_spin_lock(&scd->lock); | ||
218 | scd->prev_raw = now; | ||
219 | scd->clock += delta_ns; | ||
220 | __raw_spin_unlock(&scd->lock); | ||
221 | |||
222 | touch_softlockup_watchdog(); | ||
223 | } | ||
224 | EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event); | ||
225 | |||
226 | #endif | ||
227 | |||
228 | /* | ||
229 | * Scheduler clock - returns current time in nanosec units. | ||
230 | * This is default implementation. | ||
231 | * Architectures and sub-architectures can override this. | ||
232 | */ | ||
233 | unsigned long long __attribute__((weak)) sched_clock(void) | ||
234 | { | ||
235 | return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ); | ||
236 | } | ||
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c index 8a9498e7c831..5f06118fbc31 100644 --- a/kernel/sched_debug.c +++ b/kernel/sched_debug.c | |||
@@ -204,13 +204,6 @@ static void print_cpu(struct seq_file *m, int cpu) | |||
204 | PN(next_balance); | 204 | PN(next_balance); |
205 | P(curr->pid); | 205 | P(curr->pid); |
206 | PN(clock); | 206 | PN(clock); |
207 | PN(idle_clock); | ||
208 | PN(prev_clock_raw); | ||
209 | P(clock_warps); | ||
210 | P(clock_overflows); | ||
211 | P(clock_underflows); | ||
212 | P(clock_deep_idle_events); | ||
213 | PN(clock_max_delta); | ||
214 | P(cpu_load[0]); | 207 | P(cpu_load[0]); |
215 | P(cpu_load[1]); | 208 | P(cpu_load[1]); |
216 | P(cpu_load[2]); | 209 | P(cpu_load[2]); |
@@ -357,8 +350,8 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) | |||
357 | 350 | ||
358 | avg_per_cpu = p->se.sum_exec_runtime; | 351 | avg_per_cpu = p->se.sum_exec_runtime; |
359 | if (p->se.nr_migrations) { | 352 | if (p->se.nr_migrations) { |
360 | avg_per_cpu = div64_64(avg_per_cpu, | 353 | avg_per_cpu = div64_u64(avg_per_cpu, |
361 | p->se.nr_migrations); | 354 | p->se.nr_migrations); |
362 | } else { | 355 | } else { |
363 | avg_per_cpu = -1LL; | 356 | avg_per_cpu = -1LL; |
364 | } | 357 | } |
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 89fa32b4edf2..c863663d204d 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c | |||
@@ -682,6 +682,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int wakeup) | |||
682 | * Update run-time statistics of the 'current'. | 682 | * Update run-time statistics of the 'current'. |
683 | */ | 683 | */ |
684 | update_curr(cfs_rq); | 684 | update_curr(cfs_rq); |
685 | account_entity_enqueue(cfs_rq, se); | ||
685 | 686 | ||
686 | if (wakeup) { | 687 | if (wakeup) { |
687 | place_entity(cfs_rq, se, 0); | 688 | place_entity(cfs_rq, se, 0); |
@@ -692,7 +693,6 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int wakeup) | |||
692 | check_spread(cfs_rq, se); | 693 | check_spread(cfs_rq, se); |
693 | if (se != cfs_rq->curr) | 694 | if (se != cfs_rq->curr) |
694 | __enqueue_entity(cfs_rq, se); | 695 | __enqueue_entity(cfs_rq, se); |
695 | account_entity_enqueue(cfs_rq, se); | ||
696 | } | 696 | } |
697 | 697 | ||
698 | static void update_avg(u64 *avg, u64 sample) | 698 | static void update_avg(u64 *avg, u64 sample) |
@@ -841,8 +841,10 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued) | |||
841 | * queued ticks are scheduled to match the slice, so don't bother | 841 | * queued ticks are scheduled to match the slice, so don't bother |
842 | * validating it and just reschedule. | 842 | * validating it and just reschedule. |
843 | */ | 843 | */ |
844 | if (queued) | 844 | if (queued) { |
845 | return resched_task(rq_of(cfs_rq)->curr); | 845 | resched_task(rq_of(cfs_rq)->curr); |
846 | return; | ||
847 | } | ||
846 | /* | 848 | /* |
847 | * don't let the period tick interfere with the hrtick preemption | 849 | * don't let the period tick interfere with the hrtick preemption |
848 | */ | 850 | */ |
@@ -957,7 +959,7 @@ static void yield_task_fair(struct rq *rq) | |||
957 | return; | 959 | return; |
958 | 960 | ||
959 | if (likely(!sysctl_sched_compat_yield) && curr->policy != SCHED_BATCH) { | 961 | if (likely(!sysctl_sched_compat_yield) && curr->policy != SCHED_BATCH) { |
960 | __update_rq_clock(rq); | 962 | update_rq_clock(rq); |
961 | /* | 963 | /* |
962 | * Update run-time statistics of the 'current'. | 964 | * Update run-time statistics of the 'current'. |
963 | */ | 965 | */ |
@@ -1007,7 +1009,7 @@ static int wake_idle(int cpu, struct task_struct *p) | |||
1007 | * sibling runqueue info. This will avoid the checks and cache miss | 1009 | * sibling runqueue info. This will avoid the checks and cache miss |
1008 | * penalities associated with that. | 1010 | * penalities associated with that. |
1009 | */ | 1011 | */ |
1010 | if (idle_cpu(cpu) || cpu_rq(cpu)->nr_running > 1) | 1012 | if (idle_cpu(cpu) || cpu_rq(cpu)->cfs.nr_running > 1) |
1011 | return cpu; | 1013 | return cpu; |
1012 | 1014 | ||
1013 | for_each_domain(cpu, sd) { | 1015 | for_each_domain(cpu, sd) { |
@@ -1611,30 +1613,6 @@ static const struct sched_class fair_sched_class = { | |||
1611 | }; | 1613 | }; |
1612 | 1614 | ||
1613 | #ifdef CONFIG_SCHED_DEBUG | 1615 | #ifdef CONFIG_SCHED_DEBUG |
1614 | static void | ||
1615 | print_cfs_rq_tasks(struct seq_file *m, struct cfs_rq *cfs_rq, int depth) | ||
1616 | { | ||
1617 | struct sched_entity *se; | ||
1618 | |||
1619 | if (!cfs_rq) | ||
1620 | return; | ||
1621 | |||
1622 | list_for_each_entry_rcu(se, &cfs_rq->tasks, group_node) { | ||
1623 | int i; | ||
1624 | |||
1625 | for (i = depth; i; i--) | ||
1626 | seq_puts(m, " "); | ||
1627 | |||
1628 | seq_printf(m, "%lu %s %lu\n", | ||
1629 | se->load.weight, | ||
1630 | entity_is_task(se) ? "T" : "G", | ||
1631 | calc_delta_weight(SCHED_LOAD_SCALE, se) | ||
1632 | ); | ||
1633 | if (!entity_is_task(se)) | ||
1634 | print_cfs_rq_tasks(m, group_cfs_rq(se), depth + 1); | ||
1635 | } | ||
1636 | } | ||
1637 | |||
1638 | static void print_cfs_stats(struct seq_file *m, int cpu) | 1616 | static void print_cfs_stats(struct seq_file *m, int cpu) |
1639 | { | 1617 | { |
1640 | struct cfs_rq *cfs_rq; | 1618 | struct cfs_rq *cfs_rq; |
@@ -1642,9 +1620,6 @@ static void print_cfs_stats(struct seq_file *m, int cpu) | |||
1642 | rcu_read_lock(); | 1620 | rcu_read_lock(); |
1643 | for_each_leaf_cfs_rq(cpu_rq(cpu), cfs_rq) | 1621 | for_each_leaf_cfs_rq(cpu_rq(cpu), cfs_rq) |
1644 | print_cfs_rq(m, cpu, cfs_rq); | 1622 | print_cfs_rq(m, cpu, cfs_rq); |
1645 | |||
1646 | seq_printf(m, "\nWeight tree:\n"); | ||
1647 | print_cfs_rq_tasks(m, &cpu_rq(cpu)->cfs, 1); | ||
1648 | rcu_read_unlock(); | 1623 | rcu_read_unlock(); |
1649 | } | 1624 | } |
1650 | #endif | 1625 | #endif |
diff --git a/kernel/sched_idletask.c b/kernel/sched_idletask.c index 2bcafa375633..3a4f92dbbe66 100644 --- a/kernel/sched_idletask.c +++ b/kernel/sched_idletask.c | |||
@@ -99,7 +99,7 @@ static void prio_changed_idle(struct rq *rq, struct task_struct *p, | |||
99 | /* | 99 | /* |
100 | * Simple, special scheduling class for the per-CPU idle tasks: | 100 | * Simple, special scheduling class for the per-CPU idle tasks: |
101 | */ | 101 | */ |
102 | const struct sched_class idle_sched_class = { | 102 | static const struct sched_class idle_sched_class = { |
103 | /* .next is NULL */ | 103 | /* .next is NULL */ |
104 | /* no enqueue/yield_task for idle tasks */ | 104 | /* no enqueue/yield_task for idle tasks */ |
105 | 105 | ||
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index c2730a5a4f05..060e87b0cb1c 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c | |||
@@ -1098,11 +1098,14 @@ static void post_schedule_rt(struct rq *rq) | |||
1098 | } | 1098 | } |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | 1101 | /* | |
1102 | * If we are not running and we are not going to reschedule soon, we should | ||
1103 | * try to push tasks away now | ||
1104 | */ | ||
1102 | static void task_wake_up_rt(struct rq *rq, struct task_struct *p) | 1105 | static void task_wake_up_rt(struct rq *rq, struct task_struct *p) |
1103 | { | 1106 | { |
1104 | if (!task_running(rq, p) && | 1107 | if (!task_running(rq, p) && |
1105 | (p->prio >= rq->rt.highest_prio) && | 1108 | !test_tsk_need_resched(rq->curr) && |
1106 | rq->rt.overloaded) | 1109 | rq->rt.overloaded) |
1107 | push_rt_tasks(rq); | 1110 | push_rt_tasks(rq); |
1108 | } | 1111 | } |
@@ -1309,7 +1312,7 @@ static void set_curr_task_rt(struct rq *rq) | |||
1309 | p->se.exec_start = rq->clock; | 1312 | p->se.exec_start = rq->clock; |
1310 | } | 1313 | } |
1311 | 1314 | ||
1312 | const struct sched_class rt_sched_class = { | 1315 | static const struct sched_class rt_sched_class = { |
1313 | .next = &fair_sched_class, | 1316 | .next = &fair_sched_class, |
1314 | .enqueue_task = enqueue_task_rt, | 1317 | .enqueue_task = enqueue_task_rt, |
1315 | .dequeue_task = dequeue_task_rt, | 1318 | .dequeue_task = dequeue_task_rt, |
diff --git a/kernel/softirq.c b/kernel/softirq.c index 3c44956ee7e2..36e061740047 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c | |||
@@ -589,16 +589,20 @@ static void takeover_tasklets(unsigned int cpu) | |||
589 | local_irq_disable(); | 589 | local_irq_disable(); |
590 | 590 | ||
591 | /* Find end, append list for that CPU. */ | 591 | /* Find end, append list for that CPU. */ |
592 | *__get_cpu_var(tasklet_vec).tail = per_cpu(tasklet_vec, cpu).head; | 592 | if (&per_cpu(tasklet_vec, cpu).head != per_cpu(tasklet_vec, cpu).tail) { |
593 | __get_cpu_var(tasklet_vec).tail = per_cpu(tasklet_vec, cpu).tail; | 593 | *(__get_cpu_var(tasklet_vec).tail) = per_cpu(tasklet_vec, cpu).head; |
594 | per_cpu(tasklet_vec, cpu).head = NULL; | 594 | __get_cpu_var(tasklet_vec).tail = per_cpu(tasklet_vec, cpu).tail; |
595 | per_cpu(tasklet_vec, cpu).tail = &per_cpu(tasklet_vec, cpu).head; | 595 | per_cpu(tasklet_vec, cpu).head = NULL; |
596 | per_cpu(tasklet_vec, cpu).tail = &per_cpu(tasklet_vec, cpu).head; | ||
597 | } | ||
596 | raise_softirq_irqoff(TASKLET_SOFTIRQ); | 598 | raise_softirq_irqoff(TASKLET_SOFTIRQ); |
597 | 599 | ||
598 | *__get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).head; | 600 | if (&per_cpu(tasklet_hi_vec, cpu).head != per_cpu(tasklet_hi_vec, cpu).tail) { |
599 | __get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).tail; | 601 | *__get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).head; |
600 | per_cpu(tasklet_hi_vec, cpu).head = NULL; | 602 | __get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).tail; |
601 | per_cpu(tasklet_hi_vec, cpu).tail = &per_cpu(tasklet_hi_vec, cpu).head; | 603 | per_cpu(tasklet_hi_vec, cpu).head = NULL; |
604 | per_cpu(tasklet_hi_vec, cpu).tail = &per_cpu(tasklet_hi_vec, cpu).head; | ||
605 | } | ||
602 | raise_softirq_irqoff(HI_SOFTIRQ); | 606 | raise_softirq_irqoff(HI_SOFTIRQ); |
603 | 607 | ||
604 | local_irq_enable(); | 608 | local_irq_enable(); |
diff --git a/kernel/time.c b/kernel/time.c index 86729042e4cd..6a08660b4fac 100644 --- a/kernel/time.c +++ b/kernel/time.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/security.h> | 36 | #include <linux/security.h> |
37 | #include <linux/fs.h> | 37 | #include <linux/fs.h> |
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/math64.h> | ||
39 | 40 | ||
40 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
41 | #include <asm/unistd.h> | 42 | #include <asm/unistd.h> |
@@ -245,7 +246,7 @@ unsigned int inline jiffies_to_msecs(const unsigned long j) | |||
245 | return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); | 246 | return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); |
246 | #else | 247 | #else |
247 | # if BITS_PER_LONG == 32 | 248 | # if BITS_PER_LONG == 32 |
248 | return ((u64)HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32; | 249 | return (HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32; |
249 | # else | 250 | # else |
250 | return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN; | 251 | return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN; |
251 | # endif | 252 | # endif |
@@ -261,7 +262,7 @@ unsigned int inline jiffies_to_usecs(const unsigned long j) | |||
261 | return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); | 262 | return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); |
262 | #else | 263 | #else |
263 | # if BITS_PER_LONG == 32 | 264 | # if BITS_PER_LONG == 32 |
264 | return ((u64)HZ_TO_USEC_MUL32 * j) >> HZ_TO_USEC_SHR32; | 265 | return (HZ_TO_USEC_MUL32 * j) >> HZ_TO_USEC_SHR32; |
265 | # else | 266 | # else |
266 | return (j * HZ_TO_USEC_NUM) / HZ_TO_USEC_DEN; | 267 | return (j * HZ_TO_USEC_NUM) / HZ_TO_USEC_DEN; |
267 | # endif | 268 | # endif |
@@ -391,13 +392,17 @@ EXPORT_SYMBOL(set_normalized_timespec); | |||
391 | struct timespec ns_to_timespec(const s64 nsec) | 392 | struct timespec ns_to_timespec(const s64 nsec) |
392 | { | 393 | { |
393 | struct timespec ts; | 394 | struct timespec ts; |
395 | s32 rem; | ||
394 | 396 | ||
395 | if (!nsec) | 397 | if (!nsec) |
396 | return (struct timespec) {0, 0}; | 398 | return (struct timespec) {0, 0}; |
397 | 399 | ||
398 | ts.tv_sec = div_long_long_rem_signed(nsec, NSEC_PER_SEC, &ts.tv_nsec); | 400 | ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem); |
399 | if (unlikely(nsec < 0)) | 401 | if (unlikely(rem < 0)) { |
400 | set_normalized_timespec(&ts, ts.tv_sec, ts.tv_nsec); | 402 | ts.tv_sec--; |
403 | rem += NSEC_PER_SEC; | ||
404 | } | ||
405 | ts.tv_nsec = rem; | ||
401 | 406 | ||
402 | return ts; | 407 | return ts; |
403 | } | 408 | } |
@@ -471,7 +476,7 @@ unsigned long msecs_to_jiffies(const unsigned int m) | |||
471 | if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) | 476 | if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) |
472 | return MAX_JIFFY_OFFSET; | 477 | return MAX_JIFFY_OFFSET; |
473 | 478 | ||
474 | return ((u64)MSEC_TO_HZ_MUL32 * m + MSEC_TO_HZ_ADJ32) | 479 | return (MSEC_TO_HZ_MUL32 * m + MSEC_TO_HZ_ADJ32) |
475 | >> MSEC_TO_HZ_SHR32; | 480 | >> MSEC_TO_HZ_SHR32; |
476 | #endif | 481 | #endif |
477 | } | 482 | } |
@@ -486,7 +491,7 @@ unsigned long usecs_to_jiffies(const unsigned int u) | |||
486 | #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) | 491 | #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) |
487 | return u * (HZ / USEC_PER_SEC); | 492 | return u * (HZ / USEC_PER_SEC); |
488 | #else | 493 | #else |
489 | return ((u64)USEC_TO_HZ_MUL32 * u + USEC_TO_HZ_ADJ32) | 494 | return (USEC_TO_HZ_MUL32 * u + USEC_TO_HZ_ADJ32) |
490 | >> USEC_TO_HZ_SHR32; | 495 | >> USEC_TO_HZ_SHR32; |
491 | #endif | 496 | #endif |
492 | } | 497 | } |
@@ -527,8 +532,10 @@ jiffies_to_timespec(const unsigned long jiffies, struct timespec *value) | |||
527 | * Convert jiffies to nanoseconds and separate with | 532 | * Convert jiffies to nanoseconds and separate with |
528 | * one divide. | 533 | * one divide. |
529 | */ | 534 | */ |
530 | u64 nsec = (u64)jiffies * TICK_NSEC; | 535 | u32 rem; |
531 | value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_nsec); | 536 | value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC, |
537 | NSEC_PER_SEC, &rem); | ||
538 | value->tv_nsec = rem; | ||
532 | } | 539 | } |
533 | EXPORT_SYMBOL(jiffies_to_timespec); | 540 | EXPORT_SYMBOL(jiffies_to_timespec); |
534 | 541 | ||
@@ -566,12 +573,11 @@ void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value) | |||
566 | * Convert jiffies to nanoseconds and separate with | 573 | * Convert jiffies to nanoseconds and separate with |
567 | * one divide. | 574 | * one divide. |
568 | */ | 575 | */ |
569 | u64 nsec = (u64)jiffies * TICK_NSEC; | 576 | u32 rem; |
570 | long tv_usec; | ||
571 | 577 | ||
572 | value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &tv_usec); | 578 | value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC, |
573 | tv_usec /= NSEC_PER_USEC; | 579 | NSEC_PER_SEC, &rem); |
574 | value->tv_usec = tv_usec; | 580 | value->tv_usec = rem / NSEC_PER_USEC; |
575 | } | 581 | } |
576 | EXPORT_SYMBOL(jiffies_to_timeval); | 582 | EXPORT_SYMBOL(jiffies_to_timeval); |
577 | 583 | ||
@@ -587,9 +593,7 @@ clock_t jiffies_to_clock_t(long x) | |||
587 | return x / (HZ / USER_HZ); | 593 | return x / (HZ / USER_HZ); |
588 | # endif | 594 | # endif |
589 | #else | 595 | #else |
590 | u64 tmp = (u64)x * TICK_NSEC; | 596 | return div_u64((u64)x * TICK_NSEC, NSEC_PER_SEC / USER_HZ); |
591 | do_div(tmp, (NSEC_PER_SEC / USER_HZ)); | ||
592 | return (long)tmp; | ||
593 | #endif | 597 | #endif |
594 | } | 598 | } |
595 | EXPORT_SYMBOL(jiffies_to_clock_t); | 599 | EXPORT_SYMBOL(jiffies_to_clock_t); |
@@ -601,16 +605,12 @@ unsigned long clock_t_to_jiffies(unsigned long x) | |||
601 | return ~0UL; | 605 | return ~0UL; |
602 | return x * (HZ / USER_HZ); | 606 | return x * (HZ / USER_HZ); |
603 | #else | 607 | #else |
604 | u64 jif; | ||
605 | |||
606 | /* Don't worry about loss of precision here .. */ | 608 | /* Don't worry about loss of precision here .. */ |
607 | if (x >= ~0UL / HZ * USER_HZ) | 609 | if (x >= ~0UL / HZ * USER_HZ) |
608 | return ~0UL; | 610 | return ~0UL; |
609 | 611 | ||
610 | /* .. but do try to contain it here */ | 612 | /* .. but do try to contain it here */ |
611 | jif = x * (u64) HZ; | 613 | return div_u64((u64)x * HZ, USER_HZ); |
612 | do_div(jif, USER_HZ); | ||
613 | return jif; | ||
614 | #endif | 614 | #endif |
615 | } | 615 | } |
616 | EXPORT_SYMBOL(clock_t_to_jiffies); | 616 | EXPORT_SYMBOL(clock_t_to_jiffies); |
@@ -619,10 +619,9 @@ u64 jiffies_64_to_clock_t(u64 x) | |||
619 | { | 619 | { |
620 | #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0 | 620 | #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0 |
621 | # if HZ < USER_HZ | 621 | # if HZ < USER_HZ |
622 | x *= USER_HZ; | 622 | x = div_u64(x * USER_HZ, HZ); |
623 | do_div(x, HZ); | ||
624 | # elif HZ > USER_HZ | 623 | # elif HZ > USER_HZ |
625 | do_div(x, HZ / USER_HZ); | 624 | x = div_u64(x, HZ / USER_HZ); |
626 | # else | 625 | # else |
627 | /* Nothing to do */ | 626 | /* Nothing to do */ |
628 | # endif | 627 | # endif |
@@ -632,8 +631,7 @@ u64 jiffies_64_to_clock_t(u64 x) | |||
632 | * but even this doesn't overflow in hundreds of years | 631 | * but even this doesn't overflow in hundreds of years |
633 | * in 64 bits, so.. | 632 | * in 64 bits, so.. |
634 | */ | 633 | */ |
635 | x *= TICK_NSEC; | 634 | x = div_u64(x * TICK_NSEC, (NSEC_PER_SEC / USER_HZ)); |
636 | do_div(x, (NSEC_PER_SEC / USER_HZ)); | ||
637 | #endif | 635 | #endif |
638 | return x; | 636 | return x; |
639 | } | 637 | } |
@@ -642,21 +640,17 @@ EXPORT_SYMBOL(jiffies_64_to_clock_t); | |||
642 | u64 nsec_to_clock_t(u64 x) | 640 | u64 nsec_to_clock_t(u64 x) |
643 | { | 641 | { |
644 | #if (NSEC_PER_SEC % USER_HZ) == 0 | 642 | #if (NSEC_PER_SEC % USER_HZ) == 0 |
645 | do_div(x, (NSEC_PER_SEC / USER_HZ)); | 643 | return div_u64(x, NSEC_PER_SEC / USER_HZ); |
646 | #elif (USER_HZ % 512) == 0 | 644 | #elif (USER_HZ % 512) == 0 |
647 | x *= USER_HZ/512; | 645 | return div_u64(x * USER_HZ / 512, NSEC_PER_SEC / 512); |
648 | do_div(x, (NSEC_PER_SEC / 512)); | ||
649 | #else | 646 | #else |
650 | /* | 647 | /* |
651 | * max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024, | 648 | * max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024, |
652 | * overflow after 64.99 years. | 649 | * overflow after 64.99 years. |
653 | * exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ... | 650 | * exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ... |
654 | */ | 651 | */ |
655 | x *= 9; | 652 | return div_u64(x * 9, (9ull * NSEC_PER_SEC + (USER_HZ / 2)) / USER_HZ); |
656 | do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (USER_HZ/2)) / | ||
657 | USER_HZ)); | ||
658 | #endif | 653 | #endif |
659 | return x; | ||
660 | } | 654 | } |
661 | 655 | ||
662 | #if (BITS_PER_LONG < 64) | 656 | #if (BITS_PER_LONG < 64) |
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 73961f35fdc8..dadde5361f32 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c | |||
@@ -471,10 +471,10 @@ sysfs_show_available_clocksources(struct sys_device *dev, char *buf) | |||
471 | /* | 471 | /* |
472 | * Sysfs setup bits: | 472 | * Sysfs setup bits: |
473 | */ | 473 | */ |
474 | static SYSDEV_ATTR(current_clocksource, 0600, sysfs_show_current_clocksources, | 474 | static SYSDEV_ATTR(current_clocksource, 0644, sysfs_show_current_clocksources, |
475 | sysfs_override_clocksource); | 475 | sysfs_override_clocksource); |
476 | 476 | ||
477 | static SYSDEV_ATTR(available_clocksource, 0600, | 477 | static SYSDEV_ATTR(available_clocksource, 0444, |
478 | sysfs_show_available_clocksources, NULL); | 478 | sysfs_show_available_clocksources, NULL); |
479 | 479 | ||
480 | static struct sysdev_class clocksource_sysclass = { | 480 | static struct sysdev_class clocksource_sysclass = { |
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 5fd9b9469770..5125ddd8196b 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -15,7 +15,8 @@ | |||
15 | #include <linux/jiffies.h> | 15 | #include <linux/jiffies.h> |
16 | #include <linux/hrtimer.h> | 16 | #include <linux/hrtimer.h> |
17 | #include <linux/capability.h> | 17 | #include <linux/capability.h> |
18 | #include <asm/div64.h> | 18 | #include <linux/math64.h> |
19 | #include <linux/clocksource.h> | ||
19 | #include <asm/timex.h> | 20 | #include <asm/timex.h> |
20 | 21 | ||
21 | /* | 22 | /* |
@@ -23,11 +24,14 @@ | |||
23 | */ | 24 | */ |
24 | unsigned long tick_usec = TICK_USEC; /* USER_HZ period (usec) */ | 25 | unsigned long tick_usec = TICK_USEC; /* USER_HZ period (usec) */ |
25 | unsigned long tick_nsec; /* ACTHZ period (nsec) */ | 26 | unsigned long tick_nsec; /* ACTHZ period (nsec) */ |
26 | static u64 tick_length, tick_length_base; | 27 | u64 tick_length; |
28 | static u64 tick_length_base; | ||
29 | |||
30 | static struct hrtimer leap_timer; | ||
27 | 31 | ||
28 | #define MAX_TICKADJ 500 /* microsecs */ | 32 | #define MAX_TICKADJ 500 /* microsecs */ |
29 | #define MAX_TICKADJ_SCALED (((u64)(MAX_TICKADJ * NSEC_PER_USEC) << \ | 33 | #define MAX_TICKADJ_SCALED (((u64)(MAX_TICKADJ * NSEC_PER_USEC) << \ |
30 | TICK_LENGTH_SHIFT) / NTP_INTERVAL_FREQ) | 34 | NTP_SCALE_SHIFT) / NTP_INTERVAL_FREQ) |
31 | 35 | ||
32 | /* | 36 | /* |
33 | * phase-lock loop variables | 37 | * phase-lock loop variables |
@@ -35,11 +39,12 @@ static u64 tick_length, tick_length_base; | |||
35 | /* TIME_ERROR prevents overwriting the CMOS clock */ | 39 | /* TIME_ERROR prevents overwriting the CMOS clock */ |
36 | static int time_state = TIME_OK; /* clock synchronization status */ | 40 | static int time_state = TIME_OK; /* clock synchronization status */ |
37 | int time_status = STA_UNSYNC; /* clock status bits */ | 41 | int time_status = STA_UNSYNC; /* clock status bits */ |
38 | static s64 time_offset; /* time adjustment (ns) */ | 42 | static long time_tai; /* TAI offset (s) */ |
43 | static s64 time_offset; /* time adjustment (ns) */ | ||
39 | static long time_constant = 2; /* pll time constant */ | 44 | static long time_constant = 2; /* pll time constant */ |
40 | long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */ | 45 | long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */ |
41 | long time_esterror = NTP_PHASE_LIMIT; /* estimated error (us) */ | 46 | long time_esterror = NTP_PHASE_LIMIT; /* estimated error (us) */ |
42 | long time_freq; /* frequency offset (scaled ppm)*/ | 47 | static s64 time_freq; /* frequency offset (scaled ns/s)*/ |
43 | static long time_reftime; /* time at last adjustment (s) */ | 48 | static long time_reftime; /* time at last adjustment (s) */ |
44 | long time_adjust; | 49 | long time_adjust; |
45 | static long ntp_tick_adj; | 50 | static long ntp_tick_adj; |
@@ -47,16 +52,56 @@ static long ntp_tick_adj; | |||
47 | static void ntp_update_frequency(void) | 52 | static void ntp_update_frequency(void) |
48 | { | 53 | { |
49 | u64 second_length = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ) | 54 | u64 second_length = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ) |
50 | << TICK_LENGTH_SHIFT; | 55 | << NTP_SCALE_SHIFT; |
51 | second_length += (s64)ntp_tick_adj << TICK_LENGTH_SHIFT; | 56 | second_length += (s64)ntp_tick_adj << NTP_SCALE_SHIFT; |
52 | second_length += (s64)time_freq << (TICK_LENGTH_SHIFT - SHIFT_NSEC); | 57 | second_length += time_freq; |
53 | 58 | ||
54 | tick_length_base = second_length; | 59 | tick_length_base = second_length; |
55 | 60 | ||
56 | do_div(second_length, HZ); | 61 | tick_nsec = div_u64(second_length, HZ) >> NTP_SCALE_SHIFT; |
57 | tick_nsec = second_length >> TICK_LENGTH_SHIFT; | 62 | tick_length_base = div_u64(tick_length_base, NTP_INTERVAL_FREQ); |
63 | } | ||
64 | |||
65 | static void ntp_update_offset(long offset) | ||
66 | { | ||
67 | long mtemp; | ||
68 | s64 freq_adj; | ||
69 | |||
70 | if (!(time_status & STA_PLL)) | ||
71 | return; | ||
58 | 72 | ||
59 | do_div(tick_length_base, NTP_INTERVAL_FREQ); | 73 | if (!(time_status & STA_NANO)) |
74 | offset *= NSEC_PER_USEC; | ||
75 | |||
76 | /* | ||
77 | * Scale the phase adjustment and | ||
78 | * clamp to the operating range. | ||
79 | */ | ||
80 | offset = min(offset, MAXPHASE); | ||
81 | offset = max(offset, -MAXPHASE); | ||
82 | |||
83 | /* | ||
84 | * Select how the frequency is to be controlled | ||
85 | * and in which mode (PLL or FLL). | ||
86 | */ | ||
87 | if (time_status & STA_FREQHOLD || time_reftime == 0) | ||
88 | time_reftime = xtime.tv_sec; | ||
89 | mtemp = xtime.tv_sec - time_reftime; | ||
90 | time_reftime = xtime.tv_sec; | ||
91 | |||
92 | freq_adj = (s64)offset * mtemp; | ||
93 | freq_adj <<= NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + time_constant); | ||
94 | time_status &= ~STA_MODE; | ||
95 | if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > MAXSEC)) { | ||
96 | freq_adj += div_s64((s64)offset << (NTP_SCALE_SHIFT - SHIFT_FLL), | ||
97 | mtemp); | ||
98 | time_status |= STA_MODE; | ||
99 | } | ||
100 | freq_adj += time_freq; | ||
101 | freq_adj = min(freq_adj, MAXFREQ_SCALED); | ||
102 | time_freq = max(freq_adj, -MAXFREQ_SCALED); | ||
103 | |||
104 | time_offset = div_s64((s64)offset << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ); | ||
60 | } | 105 | } |
61 | 106 | ||
62 | /** | 107 | /** |
@@ -78,62 +123,70 @@ void ntp_clear(void) | |||
78 | } | 123 | } |
79 | 124 | ||
80 | /* | 125 | /* |
81 | * this routine handles the overflow of the microsecond field | 126 | * Leap second processing. If in leap-insert state at the end of the |
82 | * | 127 | * day, the system clock is set back one second; if in leap-delete |
83 | * The tricky bits of code to handle the accurate clock support | 128 | * state, the system clock is set ahead one second. |
84 | * were provided by Dave Mills (Mills@UDEL.EDU) of NTP fame. | ||
85 | * They were originally developed for SUN and DEC kernels. | ||
86 | * All the kudos should go to Dave for this stuff. | ||
87 | */ | 129 | */ |
88 | void second_overflow(void) | 130 | static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer) |
89 | { | 131 | { |
90 | long time_adj; | 132 | enum hrtimer_restart res = HRTIMER_NORESTART; |
91 | 133 | ||
92 | /* Bump the maxerror field */ | 134 | write_seqlock_irq(&xtime_lock); |
93 | time_maxerror += MAXFREQ >> SHIFT_USEC; | ||
94 | if (time_maxerror > NTP_PHASE_LIMIT) { | ||
95 | time_maxerror = NTP_PHASE_LIMIT; | ||
96 | time_status |= STA_UNSYNC; | ||
97 | } | ||
98 | 135 | ||
99 | /* | ||
100 | * Leap second processing. If in leap-insert state at the end of the | ||
101 | * day, the system clock is set back one second; if in leap-delete | ||
102 | * state, the system clock is set ahead one second. The microtime() | ||
103 | * routine or external clock driver will insure that reported time is | ||
104 | * always monotonic. The ugly divides should be replaced. | ||
105 | */ | ||
106 | switch (time_state) { | 136 | switch (time_state) { |
107 | case TIME_OK: | 137 | case TIME_OK: |
108 | if (time_status & STA_INS) | ||
109 | time_state = TIME_INS; | ||
110 | else if (time_status & STA_DEL) | ||
111 | time_state = TIME_DEL; | ||
112 | break; | 138 | break; |
113 | case TIME_INS: | 139 | case TIME_INS: |
114 | if (xtime.tv_sec % 86400 == 0) { | 140 | xtime.tv_sec--; |
115 | xtime.tv_sec--; | 141 | wall_to_monotonic.tv_sec++; |
116 | wall_to_monotonic.tv_sec++; | 142 | time_state = TIME_OOP; |
117 | time_state = TIME_OOP; | 143 | printk(KERN_NOTICE "Clock: " |
118 | printk(KERN_NOTICE "Clock: inserting leap second " | 144 | "inserting leap second 23:59:60 UTC\n"); |
119 | "23:59:60 UTC\n"); | 145 | leap_timer.expires = ktime_add_ns(leap_timer.expires, |
120 | } | 146 | NSEC_PER_SEC); |
147 | res = HRTIMER_RESTART; | ||
121 | break; | 148 | break; |
122 | case TIME_DEL: | 149 | case TIME_DEL: |
123 | if ((xtime.tv_sec + 1) % 86400 == 0) { | 150 | xtime.tv_sec++; |
124 | xtime.tv_sec++; | 151 | time_tai--; |
125 | wall_to_monotonic.tv_sec--; | 152 | wall_to_monotonic.tv_sec--; |
126 | time_state = TIME_WAIT; | 153 | time_state = TIME_WAIT; |
127 | printk(KERN_NOTICE "Clock: deleting leap second " | 154 | printk(KERN_NOTICE "Clock: " |
128 | "23:59:59 UTC\n"); | 155 | "deleting leap second 23:59:59 UTC\n"); |
129 | } | ||
130 | break; | 156 | break; |
131 | case TIME_OOP: | 157 | case TIME_OOP: |
158 | time_tai++; | ||
132 | time_state = TIME_WAIT; | 159 | time_state = TIME_WAIT; |
133 | break; | 160 | /* fall through */ |
134 | case TIME_WAIT: | 161 | case TIME_WAIT: |
135 | if (!(time_status & (STA_INS | STA_DEL))) | 162 | if (!(time_status & (STA_INS | STA_DEL))) |
136 | time_state = TIME_OK; | 163 | time_state = TIME_OK; |
164 | break; | ||
165 | } | ||
166 | update_vsyscall(&xtime, clock); | ||
167 | |||
168 | write_sequnlock_irq(&xtime_lock); | ||
169 | |||
170 | return res; | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * this routine handles the overflow of the microsecond field | ||
175 | * | ||
176 | * The tricky bits of code to handle the accurate clock support | ||
177 | * were provided by Dave Mills (Mills@UDEL.EDU) of NTP fame. | ||
178 | * They were originally developed for SUN and DEC kernels. | ||
179 | * All the kudos should go to Dave for this stuff. | ||
180 | */ | ||
181 | void second_overflow(void) | ||
182 | { | ||
183 | s64 time_adj; | ||
184 | |||
185 | /* Bump the maxerror field */ | ||
186 | time_maxerror += MAXFREQ / NSEC_PER_USEC; | ||
187 | if (time_maxerror > NTP_PHASE_LIMIT) { | ||
188 | time_maxerror = NTP_PHASE_LIMIT; | ||
189 | time_status |= STA_UNSYNC; | ||
137 | } | 190 | } |
138 | 191 | ||
139 | /* | 192 | /* |
@@ -143,7 +196,7 @@ void second_overflow(void) | |||
143 | tick_length = tick_length_base; | 196 | tick_length = tick_length_base; |
144 | time_adj = shift_right(time_offset, SHIFT_PLL + time_constant); | 197 | time_adj = shift_right(time_offset, SHIFT_PLL + time_constant); |
145 | time_offset -= time_adj; | 198 | time_offset -= time_adj; |
146 | tick_length += (s64)time_adj << (TICK_LENGTH_SHIFT - SHIFT_UPDATE); | 199 | tick_length += time_adj; |
147 | 200 | ||
148 | if (unlikely(time_adjust)) { | 201 | if (unlikely(time_adjust)) { |
149 | if (time_adjust > MAX_TICKADJ) { | 202 | if (time_adjust > MAX_TICKADJ) { |
@@ -154,25 +207,12 @@ void second_overflow(void) | |||
154 | tick_length -= MAX_TICKADJ_SCALED; | 207 | tick_length -= MAX_TICKADJ_SCALED; |
155 | } else { | 208 | } else { |
156 | tick_length += (s64)(time_adjust * NSEC_PER_USEC / | 209 | tick_length += (s64)(time_adjust * NSEC_PER_USEC / |
157 | NTP_INTERVAL_FREQ) << TICK_LENGTH_SHIFT; | 210 | NTP_INTERVAL_FREQ) << NTP_SCALE_SHIFT; |
158 | time_adjust = 0; | 211 | time_adjust = 0; |
159 | } | 212 | } |
160 | } | 213 | } |
161 | } | 214 | } |
162 | 215 | ||
163 | /* | ||
164 | * Return how long ticks are at the moment, that is, how much time | ||
165 | * update_wall_time_one_tick will add to xtime next time we call it | ||
166 | * (assuming no calls to do_adjtimex in the meantime). | ||
167 | * The return value is in fixed-point nanoseconds shifted by the | ||
168 | * specified number of bits to the right of the binary point. | ||
169 | * This function has no side-effects. | ||
170 | */ | ||
171 | u64 current_tick_length(void) | ||
172 | { | ||
173 | return tick_length; | ||
174 | } | ||
175 | |||
176 | #ifdef CONFIG_GENERIC_CMOS_UPDATE | 216 | #ifdef CONFIG_GENERIC_CMOS_UPDATE |
177 | 217 | ||
178 | /* Disable the cmos update - used by virtualization and embedded */ | 218 | /* Disable the cmos update - used by virtualization and embedded */ |
@@ -236,8 +276,8 @@ static inline void notify_cmos_timer(void) { } | |||
236 | */ | 276 | */ |
237 | int do_adjtimex(struct timex *txc) | 277 | int do_adjtimex(struct timex *txc) |
238 | { | 278 | { |
239 | long mtemp, save_adjust, rem; | 279 | struct timespec ts; |
240 | s64 freq_adj, temp64; | 280 | long save_adjust, sec; |
241 | int result; | 281 | int result; |
242 | 282 | ||
243 | /* In order to modify anything, you gotta be super-user! */ | 283 | /* In order to modify anything, you gotta be super-user! */ |
@@ -247,147 +287,132 @@ int do_adjtimex(struct timex *txc) | |||
247 | /* Now we validate the data before disabling interrupts */ | 287 | /* Now we validate the data before disabling interrupts */ |
248 | 288 | ||
249 | if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT) { | 289 | if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT) { |
250 | /* singleshot must not be used with any other mode bits */ | 290 | /* singleshot must not be used with any other mode bits */ |
251 | if (txc->modes != ADJ_OFFSET_SINGLESHOT && | 291 | if (txc->modes & ~ADJ_OFFSET_SS_READ) |
252 | txc->modes != ADJ_OFFSET_SS_READ) | ||
253 | return -EINVAL; | 292 | return -EINVAL; |
254 | } | 293 | } |
255 | 294 | ||
256 | if (txc->modes != ADJ_OFFSET_SINGLESHOT && (txc->modes & ADJ_OFFSET)) | ||
257 | /* adjustment Offset limited to +- .512 seconds */ | ||
258 | if (txc->offset <= - MAXPHASE || txc->offset >= MAXPHASE ) | ||
259 | return -EINVAL; | ||
260 | |||
261 | /* if the quartz is off by more than 10% something is VERY wrong ! */ | 295 | /* if the quartz is off by more than 10% something is VERY wrong ! */ |
262 | if (txc->modes & ADJ_TICK) | 296 | if (txc->modes & ADJ_TICK) |
263 | if (txc->tick < 900000/USER_HZ || | 297 | if (txc->tick < 900000/USER_HZ || |
264 | txc->tick > 1100000/USER_HZ) | 298 | txc->tick > 1100000/USER_HZ) |
265 | return -EINVAL; | 299 | return -EINVAL; |
266 | 300 | ||
301 | if (time_state != TIME_OK && txc->modes & ADJ_STATUS) | ||
302 | hrtimer_cancel(&leap_timer); | ||
303 | getnstimeofday(&ts); | ||
304 | |||
267 | write_seqlock_irq(&xtime_lock); | 305 | write_seqlock_irq(&xtime_lock); |
268 | result = time_state; /* mostly `TIME_OK' */ | ||
269 | 306 | ||
270 | /* Save for later - semantics of adjtime is to return old value */ | 307 | /* Save for later - semantics of adjtime is to return old value */ |
271 | save_adjust = time_adjust; | 308 | save_adjust = time_adjust; |
272 | 309 | ||
273 | #if 0 /* STA_CLOCKERR is never set yet */ | ||
274 | time_status &= ~STA_CLOCKERR; /* reset STA_CLOCKERR */ | ||
275 | #endif | ||
276 | /* If there are input parameters, then process them */ | 310 | /* If there are input parameters, then process them */ |
277 | if (txc->modes) | 311 | if (txc->modes) { |
278 | { | 312 | if (txc->modes & ADJ_STATUS) { |
279 | if (txc->modes & ADJ_STATUS) /* only set allowed bits */ | 313 | if ((time_status & STA_PLL) && |
280 | time_status = (txc->status & ~STA_RONLY) | | 314 | !(txc->status & STA_PLL)) { |
281 | (time_status & STA_RONLY); | 315 | time_state = TIME_OK; |
282 | 316 | time_status = STA_UNSYNC; | |
283 | if (txc->modes & ADJ_FREQUENCY) { /* p. 22 */ | 317 | } |
284 | if (txc->freq > MAXFREQ || txc->freq < -MAXFREQ) { | 318 | /* only set allowed bits */ |
285 | result = -EINVAL; | 319 | time_status &= STA_RONLY; |
286 | goto leave; | 320 | time_status |= txc->status & ~STA_RONLY; |
287 | } | 321 | |
288 | time_freq = ((s64)txc->freq * NSEC_PER_USEC) | 322 | switch (time_state) { |
289 | >> (SHIFT_USEC - SHIFT_NSEC); | 323 | case TIME_OK: |
290 | } | 324 | start_timer: |
291 | 325 | sec = ts.tv_sec; | |
292 | if (txc->modes & ADJ_MAXERROR) { | 326 | if (time_status & STA_INS) { |
293 | if (txc->maxerror < 0 || txc->maxerror >= NTP_PHASE_LIMIT) { | 327 | time_state = TIME_INS; |
294 | result = -EINVAL; | 328 | sec += 86400 - sec % 86400; |
295 | goto leave; | 329 | hrtimer_start(&leap_timer, ktime_set(sec, 0), HRTIMER_MODE_ABS); |
330 | } else if (time_status & STA_DEL) { | ||
331 | time_state = TIME_DEL; | ||
332 | sec += 86400 - (sec + 1) % 86400; | ||
333 | hrtimer_start(&leap_timer, ktime_set(sec, 0), HRTIMER_MODE_ABS); | ||
334 | } | ||
335 | break; | ||
336 | case TIME_INS: | ||
337 | case TIME_DEL: | ||
338 | time_state = TIME_OK; | ||
339 | goto start_timer; | ||
340 | break; | ||
341 | case TIME_WAIT: | ||
342 | if (!(time_status & (STA_INS | STA_DEL))) | ||
343 | time_state = TIME_OK; | ||
344 | break; | ||
345 | case TIME_OOP: | ||
346 | hrtimer_restart(&leap_timer); | ||
347 | break; | ||
348 | } | ||
296 | } | 349 | } |
297 | time_maxerror = txc->maxerror; | ||
298 | } | ||
299 | 350 | ||
300 | if (txc->modes & ADJ_ESTERROR) { | 351 | if (txc->modes & ADJ_NANO) |
301 | if (txc->esterror < 0 || txc->esterror >= NTP_PHASE_LIMIT) { | 352 | time_status |= STA_NANO; |
302 | result = -EINVAL; | 353 | if (txc->modes & ADJ_MICRO) |
303 | goto leave; | 354 | time_status &= ~STA_NANO; |
355 | |||
356 | if (txc->modes & ADJ_FREQUENCY) { | ||
357 | time_freq = (s64)txc->freq * PPM_SCALE; | ||
358 | time_freq = min(time_freq, MAXFREQ_SCALED); | ||
359 | time_freq = max(time_freq, -MAXFREQ_SCALED); | ||
304 | } | 360 | } |
305 | time_esterror = txc->esterror; | ||
306 | } | ||
307 | 361 | ||
308 | if (txc->modes & ADJ_TIMECONST) { /* p. 24 */ | 362 | if (txc->modes & ADJ_MAXERROR) |
309 | if (txc->constant < 0) { /* NTP v4 uses values > 6 */ | 363 | time_maxerror = txc->maxerror; |
310 | result = -EINVAL; | 364 | if (txc->modes & ADJ_ESTERROR) |
311 | goto leave; | 365 | time_esterror = txc->esterror; |
366 | |||
367 | if (txc->modes & ADJ_TIMECONST) { | ||
368 | time_constant = txc->constant; | ||
369 | if (!(time_status & STA_NANO)) | ||
370 | time_constant += 4; | ||
371 | time_constant = min(time_constant, (long)MAXTC); | ||
372 | time_constant = max(time_constant, 0l); | ||
312 | } | 373 | } |
313 | time_constant = min(txc->constant + 4, (long)MAXTC); | ||
314 | } | ||
315 | 374 | ||
316 | if (txc->modes & ADJ_OFFSET) { /* values checked earlier */ | 375 | if (txc->modes & ADJ_TAI && txc->constant > 0) |
317 | if (txc->modes == ADJ_OFFSET_SINGLESHOT) { | 376 | time_tai = txc->constant; |
318 | /* adjtime() is independent from ntp_adjtime() */ | 377 | |
319 | time_adjust = txc->offset; | 378 | if (txc->modes & ADJ_OFFSET) { |
379 | if (txc->modes == ADJ_OFFSET_SINGLESHOT) | ||
380 | /* adjtime() is independent from ntp_adjtime() */ | ||
381 | time_adjust = txc->offset; | ||
382 | else | ||
383 | ntp_update_offset(txc->offset); | ||
320 | } | 384 | } |
321 | else if (time_status & STA_PLL) { | 385 | if (txc->modes & ADJ_TICK) |
322 | time_offset = txc->offset * NSEC_PER_USEC; | 386 | tick_usec = txc->tick; |
323 | 387 | ||
324 | /* | 388 | if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET)) |
325 | * Scale the phase adjustment and | 389 | ntp_update_frequency(); |
326 | * clamp to the operating range. | 390 | } |
327 | */ | 391 | |
328 | time_offset = min(time_offset, (s64)MAXPHASE * NSEC_PER_USEC); | 392 | result = time_state; /* mostly `TIME_OK' */ |
329 | time_offset = max(time_offset, (s64)-MAXPHASE * NSEC_PER_USEC); | 393 | if (time_status & (STA_UNSYNC|STA_CLOCKERR)) |
330 | |||
331 | /* | ||
332 | * Select whether the frequency is to be controlled | ||
333 | * and in which mode (PLL or FLL). Clamp to the operating | ||
334 | * range. Ugly multiply/divide should be replaced someday. | ||
335 | */ | ||
336 | |||
337 | if (time_status & STA_FREQHOLD || time_reftime == 0) | ||
338 | time_reftime = xtime.tv_sec; | ||
339 | mtemp = xtime.tv_sec - time_reftime; | ||
340 | time_reftime = xtime.tv_sec; | ||
341 | |||
342 | freq_adj = time_offset * mtemp; | ||
343 | freq_adj = shift_right(freq_adj, time_constant * 2 + | ||
344 | (SHIFT_PLL + 2) * 2 - SHIFT_NSEC); | ||
345 | if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > MAXSEC)) { | ||
346 | u64 utemp64; | ||
347 | temp64 = time_offset << (SHIFT_NSEC - SHIFT_FLL); | ||
348 | if (time_offset < 0) { | ||
349 | utemp64 = -temp64; | ||
350 | do_div(utemp64, mtemp); | ||
351 | freq_adj -= utemp64; | ||
352 | } else { | ||
353 | utemp64 = temp64; | ||
354 | do_div(utemp64, mtemp); | ||
355 | freq_adj += utemp64; | ||
356 | } | ||
357 | } | ||
358 | freq_adj += time_freq; | ||
359 | freq_adj = min(freq_adj, (s64)MAXFREQ_NSEC); | ||
360 | time_freq = max(freq_adj, (s64)-MAXFREQ_NSEC); | ||
361 | time_offset = div_long_long_rem_signed(time_offset, | ||
362 | NTP_INTERVAL_FREQ, | ||
363 | &rem); | ||
364 | time_offset <<= SHIFT_UPDATE; | ||
365 | } /* STA_PLL */ | ||
366 | } /* txc->modes & ADJ_OFFSET */ | ||
367 | if (txc->modes & ADJ_TICK) | ||
368 | tick_usec = txc->tick; | ||
369 | |||
370 | if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET)) | ||
371 | ntp_update_frequency(); | ||
372 | } /* txc->modes */ | ||
373 | leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0) | ||
374 | result = TIME_ERROR; | 394 | result = TIME_ERROR; |
375 | 395 | ||
376 | if ((txc->modes == ADJ_OFFSET_SINGLESHOT) || | 396 | if ((txc->modes == ADJ_OFFSET_SINGLESHOT) || |
377 | (txc->modes == ADJ_OFFSET_SS_READ)) | 397 | (txc->modes == ADJ_OFFSET_SS_READ)) |
378 | txc->offset = save_adjust; | 398 | txc->offset = save_adjust; |
379 | else | 399 | else { |
380 | txc->offset = ((long)shift_right(time_offset, SHIFT_UPDATE)) * | 400 | txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ, |
381 | NTP_INTERVAL_FREQ / 1000; | 401 | NTP_SCALE_SHIFT); |
382 | txc->freq = (time_freq / NSEC_PER_USEC) << | 402 | if (!(time_status & STA_NANO)) |
383 | (SHIFT_USEC - SHIFT_NSEC); | 403 | txc->offset /= NSEC_PER_USEC; |
404 | } | ||
405 | txc->freq = shift_right((s32)(time_freq >> PPM_SCALE_INV_SHIFT) * | ||
406 | (s64)PPM_SCALE_INV, | ||
407 | NTP_SCALE_SHIFT); | ||
384 | txc->maxerror = time_maxerror; | 408 | txc->maxerror = time_maxerror; |
385 | txc->esterror = time_esterror; | 409 | txc->esterror = time_esterror; |
386 | txc->status = time_status; | 410 | txc->status = time_status; |
387 | txc->constant = time_constant; | 411 | txc->constant = time_constant; |
388 | txc->precision = 1; | 412 | txc->precision = 1; |
389 | txc->tolerance = MAXFREQ; | 413 | txc->tolerance = MAXFREQ_SCALED / PPM_SCALE; |
390 | txc->tick = tick_usec; | 414 | txc->tick = tick_usec; |
415 | txc->tai = time_tai; | ||
391 | 416 | ||
392 | /* PPS is not implemented, so these are zero */ | 417 | /* PPS is not implemented, so these are zero */ |
393 | txc->ppsfreq = 0; | 418 | txc->ppsfreq = 0; |
@@ -399,9 +424,15 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0) | |||
399 | txc->errcnt = 0; | 424 | txc->errcnt = 0; |
400 | txc->stbcnt = 0; | 425 | txc->stbcnt = 0; |
401 | write_sequnlock_irq(&xtime_lock); | 426 | write_sequnlock_irq(&xtime_lock); |
402 | do_gettimeofday(&txc->time); | 427 | |
428 | txc->time.tv_sec = ts.tv_sec; | ||
429 | txc->time.tv_usec = ts.tv_nsec; | ||
430 | if (!(time_status & STA_NANO)) | ||
431 | txc->time.tv_usec /= NSEC_PER_USEC; | ||
432 | |||
403 | notify_cmos_timer(); | 433 | notify_cmos_timer(); |
404 | return(result); | 434 | |
435 | return result; | ||
405 | } | 436 | } |
406 | 437 | ||
407 | static int __init ntp_tick_adj_setup(char *str) | 438 | static int __init ntp_tick_adj_setup(char *str) |
@@ -411,3 +442,10 @@ static int __init ntp_tick_adj_setup(char *str) | |||
411 | } | 442 | } |
412 | 443 | ||
413 | __setup("ntp_tick_adj=", ntp_tick_adj_setup); | 444 | __setup("ntp_tick_adj=", ntp_tick_adj_setup); |
445 | |||
446 | void __init ntp_init(void) | ||
447 | { | ||
448 | ntp_clear(); | ||
449 | hrtimer_init(&leap_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS); | ||
450 | leap_timer.function = ntp_leap_second; | ||
451 | } | ||
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 2d6087c7cf98..e91c29f961c9 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -53,7 +53,7 @@ void update_xtime_cache(u64 nsec) | |||
53 | timespec_add_ns(&xtime_cache, nsec); | 53 | timespec_add_ns(&xtime_cache, nsec); |
54 | } | 54 | } |
55 | 55 | ||
56 | static struct clocksource *clock; /* pointer to current clocksource */ | 56 | struct clocksource *clock; |
57 | 57 | ||
58 | 58 | ||
59 | #ifdef CONFIG_GENERIC_TIME | 59 | #ifdef CONFIG_GENERIC_TIME |
@@ -246,7 +246,7 @@ void __init timekeeping_init(void) | |||
246 | 246 | ||
247 | write_seqlock_irqsave(&xtime_lock, flags); | 247 | write_seqlock_irqsave(&xtime_lock, flags); |
248 | 248 | ||
249 | ntp_clear(); | 249 | ntp_init(); |
250 | 250 | ||
251 | clock = clocksource_get_next(); | 251 | clock = clocksource_get_next(); |
252 | clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH); | 252 | clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH); |
@@ -371,7 +371,7 @@ static __always_inline int clocksource_bigadjust(s64 error, s64 *interval, | |||
371 | * here. This is tuned so that an error of about 1 msec is adjusted | 371 | * here. This is tuned so that an error of about 1 msec is adjusted |
372 | * within about 1 sec (or 2^20 nsec in 2^SHIFT_HZ ticks). | 372 | * within about 1 sec (or 2^20 nsec in 2^SHIFT_HZ ticks). |
373 | */ | 373 | */ |
374 | error2 = clock->error >> (TICK_LENGTH_SHIFT + 22 - 2 * SHIFT_HZ); | 374 | error2 = clock->error >> (NTP_SCALE_SHIFT + 22 - 2 * SHIFT_HZ); |
375 | error2 = abs(error2); | 375 | error2 = abs(error2); |
376 | for (look_ahead = 0; error2 > 0; look_ahead++) | 376 | for (look_ahead = 0; error2 > 0; look_ahead++) |
377 | error2 >>= 2; | 377 | error2 >>= 2; |
@@ -380,8 +380,7 @@ static __always_inline int clocksource_bigadjust(s64 error, s64 *interval, | |||
380 | * Now calculate the error in (1 << look_ahead) ticks, but first | 380 | * Now calculate the error in (1 << look_ahead) ticks, but first |
381 | * remove the single look ahead already included in the error. | 381 | * remove the single look ahead already included in the error. |
382 | */ | 382 | */ |
383 | tick_error = current_tick_length() >> | 383 | tick_error = tick_length >> (NTP_SCALE_SHIFT - clock->shift + 1); |
384 | (TICK_LENGTH_SHIFT - clock->shift + 1); | ||
385 | tick_error -= clock->xtime_interval >> 1; | 384 | tick_error -= clock->xtime_interval >> 1; |
386 | error = ((error - tick_error) >> look_ahead) + tick_error; | 385 | error = ((error - tick_error) >> look_ahead) + tick_error; |
387 | 386 | ||
@@ -412,7 +411,7 @@ static void clocksource_adjust(s64 offset) | |||
412 | s64 error, interval = clock->cycle_interval; | 411 | s64 error, interval = clock->cycle_interval; |
413 | int adj; | 412 | int adj; |
414 | 413 | ||
415 | error = clock->error >> (TICK_LENGTH_SHIFT - clock->shift - 1); | 414 | error = clock->error >> (NTP_SCALE_SHIFT - clock->shift - 1); |
416 | if (error > interval) { | 415 | if (error > interval) { |
417 | error >>= 2; | 416 | error >>= 2; |
418 | if (likely(error <= interval)) | 417 | if (likely(error <= interval)) |
@@ -434,7 +433,7 @@ static void clocksource_adjust(s64 offset) | |||
434 | clock->xtime_interval += interval; | 433 | clock->xtime_interval += interval; |
435 | clock->xtime_nsec -= offset; | 434 | clock->xtime_nsec -= offset; |
436 | clock->error -= (interval - offset) << | 435 | clock->error -= (interval - offset) << |
437 | (TICK_LENGTH_SHIFT - clock->shift); | 436 | (NTP_SCALE_SHIFT - clock->shift); |
438 | } | 437 | } |
439 | 438 | ||
440 | /** | 439 | /** |
@@ -473,8 +472,8 @@ void update_wall_time(void) | |||
473 | } | 472 | } |
474 | 473 | ||
475 | /* accumulate error between NTP and clock interval */ | 474 | /* accumulate error between NTP and clock interval */ |
476 | clock->error += current_tick_length(); | 475 | clock->error += tick_length; |
477 | clock->error -= clock->xtime_interval << (TICK_LENGTH_SHIFT - clock->shift); | 476 | clock->error -= clock->xtime_interval << (NTP_SCALE_SHIFT - clock->shift); |
478 | } | 477 | } |
479 | 478 | ||
480 | /* correct the clock when NTP error is too big */ | 479 | /* correct the clock when NTP error is too big */ |
diff --git a/kernel/timeconst.pl b/kernel/timeconst.pl index 41468035473c..eb51d76e058a 100644 --- a/kernel/timeconst.pl +++ b/kernel/timeconst.pl | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/usr/bin/perl | 1 | #!/usr/bin/perl |
2 | # ----------------------------------------------------------------------- | 2 | # ----------------------------------------------------------------------- |
3 | # | 3 | # |
4 | # Copyright 2007 rPath, Inc. - All Rights Reserved | 4 | # Copyright 2007-2008 rPath, Inc. - All Rights Reserved |
5 | # | 5 | # |
6 | # This file is part of the Linux kernel, and is made available under | 6 | # This file is part of the Linux kernel, and is made available under |
7 | # the terms of the GNU General Public License version 2 or (at your | 7 | # the terms of the GNU General Public License version 2 or (at your |
@@ -20,198 +20,138 @@ | |||
20 | %canned_values = ( | 20 | %canned_values = ( |
21 | 24 => [ | 21 | 24 => [ |
22 | '0xa6aaaaab','0x2aaaaaa',26, | 22 | '0xa6aaaaab','0x2aaaaaa',26, |
23 | '0xa6aaaaaaaaaaaaab','0x2aaaaaaaaaaaaaa',58, | ||
24 | 125,3, | 23 | 125,3, |
25 | '0xc49ba5e4','0x1fbe76c8b4',37, | 24 | '0xc49ba5e4','0x1fbe76c8b4',37, |
26 | '0xc49ba5e353f7ceda','0x1fbe76c8b439581062',69, | ||
27 | 3,125, | 25 | 3,125, |
28 | '0xa2c2aaab','0xaaaa',16, | 26 | '0xa2c2aaab','0xaaaa',16, |
29 | '0xa2c2aaaaaaaaaaab','0xaaaaaaaaaaaa',48, | ||
30 | 125000,3, | 27 | 125000,3, |
31 | '0xc9539b89','0x7fffbce4217d',47, | 28 | '0xc9539b89','0x7fffbce4217d',47, |
32 | '0xc9539b8887229e91','0x7fffbce4217d2849cb25',79, | ||
33 | 3,125000, | 29 | 3,125000, |
34 | ], 32 => [ | 30 | ], 32 => [ |
35 | '0xfa000000','0x6000000',27, | 31 | '0xfa000000','0x6000000',27, |
36 | '0xfa00000000000000','0x600000000000000',59, | ||
37 | 125,4, | 32 | 125,4, |
38 | '0x83126e98','0xfdf3b645a',36, | 33 | '0x83126e98','0xfdf3b645a',36, |
39 | '0x83126e978d4fdf3c','0xfdf3b645a1cac0831',68, | ||
40 | 4,125, | 34 | 4,125, |
41 | '0xf4240000','0x0',17, | 35 | '0xf4240000','0x0',17, |
42 | '0xf424000000000000','0x0',49, | ||
43 | 31250,1, | 36 | 31250,1, |
44 | '0x8637bd06','0x3fff79c842fa',46, | 37 | '0x8637bd06','0x3fff79c842fa',46, |
45 | '0x8637bd05af6c69b6','0x3fff79c842fa5093964a',78, | ||
46 | 1,31250, | 38 | 1,31250, |
47 | ], 48 => [ | 39 | ], 48 => [ |
48 | '0xa6aaaaab','0x6aaaaaa',27, | 40 | '0xa6aaaaab','0x6aaaaaa',27, |
49 | '0xa6aaaaaaaaaaaaab','0x6aaaaaaaaaaaaaa',59, | ||
50 | 125,6, | 41 | 125,6, |
51 | '0xc49ba5e4','0xfdf3b645a',36, | 42 | '0xc49ba5e4','0xfdf3b645a',36, |
52 | '0xc49ba5e353f7ceda','0xfdf3b645a1cac0831',68, | ||
53 | 6,125, | 43 | 6,125, |
54 | '0xa2c2aaab','0x15555',17, | 44 | '0xa2c2aaab','0x15555',17, |
55 | '0xa2c2aaaaaaaaaaab','0x1555555555555',49, | ||
56 | 62500,3, | 45 | 62500,3, |
57 | '0xc9539b89','0x3fffbce4217d',46, | 46 | '0xc9539b89','0x3fffbce4217d',46, |
58 | '0xc9539b8887229e91','0x3fffbce4217d2849cb25',78, | ||
59 | 3,62500, | 47 | 3,62500, |
60 | ], 64 => [ | 48 | ], 64 => [ |
61 | '0xfa000000','0xe000000',28, | 49 | '0xfa000000','0xe000000',28, |
62 | '0xfa00000000000000','0xe00000000000000',60, | ||
63 | 125,8, | 50 | 125,8, |
64 | '0x83126e98','0x7ef9db22d',35, | 51 | '0x83126e98','0x7ef9db22d',35, |
65 | '0x83126e978d4fdf3c','0x7ef9db22d0e560418',67, | ||
66 | 8,125, | 52 | 8,125, |
67 | '0xf4240000','0x0',18, | 53 | '0xf4240000','0x0',18, |
68 | '0xf424000000000000','0x0',50, | ||
69 | 15625,1, | 54 | 15625,1, |
70 | '0x8637bd06','0x1fff79c842fa',45, | 55 | '0x8637bd06','0x1fff79c842fa',45, |
71 | '0x8637bd05af6c69b6','0x1fff79c842fa5093964a',77, | ||
72 | 1,15625, | 56 | 1,15625, |
73 | ], 100 => [ | 57 | ], 100 => [ |
74 | '0xa0000000','0x0',28, | 58 | '0xa0000000','0x0',28, |
75 | '0xa000000000000000','0x0',60, | ||
76 | 10,1, | 59 | 10,1, |
77 | '0xcccccccd','0x733333333',35, | 60 | '0xcccccccd','0x733333333',35, |
78 | '0xcccccccccccccccd','0x73333333333333333',67, | ||
79 | 1,10, | 61 | 1,10, |
80 | '0x9c400000','0x0',18, | 62 | '0x9c400000','0x0',18, |
81 | '0x9c40000000000000','0x0',50, | ||
82 | 10000,1, | 63 | 10000,1, |
83 | '0xd1b71759','0x1fff2e48e8a7',45, | 64 | '0xd1b71759','0x1fff2e48e8a7',45, |
84 | '0xd1b71758e219652c','0x1fff2e48e8a71de69ad4',77, | ||
85 | 1,10000, | 65 | 1,10000, |
86 | ], 122 => [ | 66 | ], 122 => [ |
87 | '0x8325c53f','0xfbcda3a',28, | 67 | '0x8325c53f','0xfbcda3a',28, |
88 | '0x8325c53ef368eb05','0xfbcda3ac10c9714',60, | ||
89 | 500,61, | 68 | 500,61, |
90 | '0xf9db22d1','0x7fbe76c8b',35, | 69 | '0xf9db22d1','0x7fbe76c8b',35, |
91 | '0xf9db22d0e560418a','0x7fbe76c8b43958106',67, | ||
92 | 61,500, | 70 | 61,500, |
93 | '0x8012e2a0','0x3ef36',18, | 71 | '0x8012e2a0','0x3ef36',18, |
94 | '0x8012e29f79b47583','0x3ef368eb04325',50, | ||
95 | 500000,61, | 72 | 500000,61, |
96 | '0xffda4053','0x1ffffbce4217',45, | 73 | '0xffda4053','0x1ffffbce4217',45, |
97 | '0xffda4052d666a983','0x1ffffbce4217d2849cb2',77, | ||
98 | 61,500000, | 74 | 61,500000, |
99 | ], 128 => [ | 75 | ], 128 => [ |
100 | '0xfa000000','0x1e000000',29, | 76 | '0xfa000000','0x1e000000',29, |
101 | '0xfa00000000000000','0x1e00000000000000',61, | ||
102 | 125,16, | 77 | 125,16, |
103 | '0x83126e98','0x3f7ced916',34, | 78 | '0x83126e98','0x3f7ced916',34, |
104 | '0x83126e978d4fdf3c','0x3f7ced916872b020c',66, | ||
105 | 16,125, | 79 | 16,125, |
106 | '0xf4240000','0x40000',19, | 80 | '0xf4240000','0x40000',19, |
107 | '0xf424000000000000','0x4000000000000',51, | ||
108 | 15625,2, | 81 | 15625,2, |
109 | '0x8637bd06','0xfffbce4217d',44, | 82 | '0x8637bd06','0xfffbce4217d',44, |
110 | '0x8637bd05af6c69b6','0xfffbce4217d2849cb25',76, | ||
111 | 2,15625, | 83 | 2,15625, |
112 | ], 200 => [ | 84 | ], 200 => [ |
113 | '0xa0000000','0x0',29, | 85 | '0xa0000000','0x0',29, |
114 | '0xa000000000000000','0x0',61, | ||
115 | 5,1, | 86 | 5,1, |
116 | '0xcccccccd','0x333333333',34, | 87 | '0xcccccccd','0x333333333',34, |
117 | '0xcccccccccccccccd','0x33333333333333333',66, | ||
118 | 1,5, | 88 | 1,5, |
119 | '0x9c400000','0x0',19, | 89 | '0x9c400000','0x0',19, |
120 | '0x9c40000000000000','0x0',51, | ||
121 | 5000,1, | 90 | 5000,1, |
122 | '0xd1b71759','0xfff2e48e8a7',44, | 91 | '0xd1b71759','0xfff2e48e8a7',44, |
123 | '0xd1b71758e219652c','0xfff2e48e8a71de69ad4',76, | ||
124 | 1,5000, | 92 | 1,5000, |
125 | ], 250 => [ | 93 | ], 250 => [ |
126 | '0x80000000','0x0',29, | 94 | '0x80000000','0x0',29, |
127 | '0x8000000000000000','0x0',61, | ||
128 | 4,1, | 95 | 4,1, |
129 | '0x80000000','0x180000000',33, | 96 | '0x80000000','0x180000000',33, |
130 | '0x8000000000000000','0x18000000000000000',65, | ||
131 | 1,4, | 97 | 1,4, |
132 | '0xfa000000','0x0',20, | 98 | '0xfa000000','0x0',20, |
133 | '0xfa00000000000000','0x0',52, | ||
134 | 4000,1, | 99 | 4000,1, |
135 | '0x83126e98','0x7ff7ced9168',43, | 100 | '0x83126e98','0x7ff7ced9168',43, |
136 | '0x83126e978d4fdf3c','0x7ff7ced916872b020c4',75, | ||
137 | 1,4000, | 101 | 1,4000, |
138 | ], 256 => [ | 102 | ], 256 => [ |
139 | '0xfa000000','0x3e000000',30, | 103 | '0xfa000000','0x3e000000',30, |
140 | '0xfa00000000000000','0x3e00000000000000',62, | ||
141 | 125,32, | 104 | 125,32, |
142 | '0x83126e98','0x1fbe76c8b',33, | 105 | '0x83126e98','0x1fbe76c8b',33, |
143 | '0x83126e978d4fdf3c','0x1fbe76c8b43958106',65, | ||
144 | 32,125, | 106 | 32,125, |
145 | '0xf4240000','0xc0000',20, | 107 | '0xf4240000','0xc0000',20, |
146 | '0xf424000000000000','0xc000000000000',52, | ||
147 | 15625,4, | 108 | 15625,4, |
148 | '0x8637bd06','0x7ffde7210be',43, | 109 | '0x8637bd06','0x7ffde7210be',43, |
149 | '0x8637bd05af6c69b6','0x7ffde7210be9424e592',75, | ||
150 | 4,15625, | 110 | 4,15625, |
151 | ], 300 => [ | 111 | ], 300 => [ |
152 | '0xd5555556','0x2aaaaaaa',30, | 112 | '0xd5555556','0x2aaaaaaa',30, |
153 | '0xd555555555555556','0x2aaaaaaaaaaaaaaa',62, | ||
154 | 10,3, | 113 | 10,3, |
155 | '0x9999999a','0x1cccccccc',33, | 114 | '0x9999999a','0x1cccccccc',33, |
156 | '0x999999999999999a','0x1cccccccccccccccc',65, | ||
157 | 3,10, | 115 | 3,10, |
158 | '0xd0555556','0xaaaaa',20, | 116 | '0xd0555556','0xaaaaa',20, |
159 | '0xd055555555555556','0xaaaaaaaaaaaaa',52, | ||
160 | 10000,3, | 117 | 10000,3, |
161 | '0x9d495183','0x7ffcb923a29',43, | 118 | '0x9d495183','0x7ffcb923a29',43, |
162 | '0x9d495182a9930be1','0x7ffcb923a29c779a6b5',75, | ||
163 | 3,10000, | 119 | 3,10000, |
164 | ], 512 => [ | 120 | ], 512 => [ |
165 | '0xfa000000','0x7e000000',31, | 121 | '0xfa000000','0x7e000000',31, |
166 | '0xfa00000000000000','0x7e00000000000000',63, | ||
167 | 125,64, | 122 | 125,64, |
168 | '0x83126e98','0xfdf3b645',32, | 123 | '0x83126e98','0xfdf3b645',32, |
169 | '0x83126e978d4fdf3c','0xfdf3b645a1cac083',64, | ||
170 | 64,125, | 124 | 64,125, |
171 | '0xf4240000','0x1c0000',21, | 125 | '0xf4240000','0x1c0000',21, |
172 | '0xf424000000000000','0x1c000000000000',53, | ||
173 | 15625,8, | 126 | 15625,8, |
174 | '0x8637bd06','0x3ffef39085f',42, | 127 | '0x8637bd06','0x3ffef39085f',42, |
175 | '0x8637bd05af6c69b6','0x3ffef39085f4a1272c9',74, | ||
176 | 8,15625, | 128 | 8,15625, |
177 | ], 1000 => [ | 129 | ], 1000 => [ |
178 | '0x80000000','0x0',31, | 130 | '0x80000000','0x0',31, |
179 | '0x8000000000000000','0x0',63, | ||
180 | 1,1, | 131 | 1,1, |
181 | '0x80000000','0x0',31, | 132 | '0x80000000','0x0',31, |
182 | '0x8000000000000000','0x0',63, | ||
183 | 1,1, | 133 | 1,1, |
184 | '0xfa000000','0x0',22, | 134 | '0xfa000000','0x0',22, |
185 | '0xfa00000000000000','0x0',54, | ||
186 | 1000,1, | 135 | 1000,1, |
187 | '0x83126e98','0x1ff7ced9168',41, | 136 | '0x83126e98','0x1ff7ced9168',41, |
188 | '0x83126e978d4fdf3c','0x1ff7ced916872b020c4',73, | ||
189 | 1,1000, | 137 | 1,1000, |
190 | ], 1024 => [ | 138 | ], 1024 => [ |
191 | '0xfa000000','0xfe000000',32, | 139 | '0xfa000000','0xfe000000',32, |
192 | '0xfa00000000000000','0xfe00000000000000',64, | ||
193 | 125,128, | 140 | 125,128, |
194 | '0x83126e98','0x7ef9db22',31, | 141 | '0x83126e98','0x7ef9db22',31, |
195 | '0x83126e978d4fdf3c','0x7ef9db22d0e56041',63, | ||
196 | 128,125, | 142 | 128,125, |
197 | '0xf4240000','0x3c0000',22, | 143 | '0xf4240000','0x3c0000',22, |
198 | '0xf424000000000000','0x3c000000000000',54, | ||
199 | 15625,16, | 144 | 15625,16, |
200 | '0x8637bd06','0x1fff79c842f',41, | 145 | '0x8637bd06','0x1fff79c842f',41, |
201 | '0x8637bd05af6c69b6','0x1fff79c842fa5093964',73, | ||
202 | 16,15625, | 146 | 16,15625, |
203 | ], 1200 => [ | 147 | ], 1200 => [ |
204 | '0xd5555556','0xd5555555',32, | 148 | '0xd5555556','0xd5555555',32, |
205 | '0xd555555555555556','0xd555555555555555',64, | ||
206 | 5,6, | 149 | 5,6, |
207 | '0x9999999a','0x66666666',31, | 150 | '0x9999999a','0x66666666',31, |
208 | '0x999999999999999a','0x6666666666666666',63, | ||
209 | 6,5, | 151 | 6,5, |
210 | '0xd0555556','0x2aaaaa',22, | 152 | '0xd0555556','0x2aaaaa',22, |
211 | '0xd055555555555556','0x2aaaaaaaaaaaaa',54, | ||
212 | 2500,3, | 153 | 2500,3, |
213 | '0x9d495183','0x1ffcb923a29',41, | 154 | '0x9d495183','0x1ffcb923a29',41, |
214 | '0x9d495182a9930be1','0x1ffcb923a29c779a6b5',73, | ||
215 | 3,2500, | 155 | 3,2500, |
216 | ] | 156 | ] |
217 | ); | 157 | ); |
@@ -264,6 +204,15 @@ sub fmuls($$$) { | |||
264 | return 0; | 204 | return 0; |
265 | } | 205 | } |
266 | 206 | ||
207 | # Generate a hex value if the result fits in 64 bits; | ||
208 | # otherwise skip. | ||
209 | sub bignum_hex($) { | ||
210 | my($x) = @_; | ||
211 | my $s = $x->as_hex(); | ||
212 | |||
213 | return (length($s) > 18) ? undef : $s; | ||
214 | } | ||
215 | |||
267 | # Provides mul, adj, and shr factors for a specific | 216 | # Provides mul, adj, and shr factors for a specific |
268 | # (bit, time, hz) combination | 217 | # (bit, time, hz) combination |
269 | sub muladj($$$) { | 218 | sub muladj($$$) { |
@@ -271,7 +220,7 @@ sub muladj($$$) { | |||
271 | my $s = fmuls($b, $t, $hz); | 220 | my $s = fmuls($b, $t, $hz); |
272 | my $m = fmul($s, $t, $hz); | 221 | my $m = fmul($s, $t, $hz); |
273 | my $a = fadj($s, $t, $hz); | 222 | my $a = fadj($s, $t, $hz); |
274 | return ($m->as_hex(), $a->as_hex(), $s); | 223 | return (bignum_hex($m), bignum_hex($a), $s); |
275 | } | 224 | } |
276 | 225 | ||
277 | # Provides numerator, denominator values | 226 | # Provides numerator, denominator values |
@@ -288,12 +237,10 @@ sub conversions($$) { | |||
288 | 237 | ||
289 | # HZ_TO_xx | 238 | # HZ_TO_xx |
290 | push(@val, muladj(32, $t, $hz)); | 239 | push(@val, muladj(32, $t, $hz)); |
291 | push(@val, muladj(64, $t, $hz)); | ||
292 | push(@val, numden($t, $hz)); | 240 | push(@val, numden($t, $hz)); |
293 | 241 | ||
294 | # xx_TO_HZ | 242 | # xx_TO_HZ |
295 | push(@val, muladj(32, $hz, $t)); | 243 | push(@val, muladj(32, $hz, $t)); |
296 | push(@val, muladj(64, $hz, $t)); | ||
297 | push(@val, numden($hz, $t)); | 244 | push(@val, numden($hz, $t)); |
298 | 245 | ||
299 | return @val; | 246 | return @val; |
@@ -318,6 +265,19 @@ sub compute_values($) { | |||
318 | return @val; | 265 | return @val; |
319 | } | 266 | } |
320 | 267 | ||
268 | sub outputval($$) | ||
269 | { | ||
270 | my($name, $val) = @_; | ||
271 | my $csuf; | ||
272 | |||
273 | if (defined($val)) { | ||
274 | if ($name !~ /SHR/) { | ||
275 | $val = "U64_C($val)"; | ||
276 | } | ||
277 | printf "#define %-23s %s\n", $name.$csuf, $val.$csuf; | ||
278 | } | ||
279 | } | ||
280 | |||
321 | sub output($@) | 281 | sub output($@) |
322 | { | 282 | { |
323 | my($hz, @val) = @_; | 283 | my($hz, @val) = @_; |
@@ -331,6 +291,7 @@ sub output($@) | |||
331 | print "\n"; | 291 | print "\n"; |
332 | 292 | ||
333 | print "#include <linux/param.h>\n"; | 293 | print "#include <linux/param.h>\n"; |
294 | print "#include <linux/types.h>\n"; | ||
334 | 295 | ||
335 | print "\n"; | 296 | print "\n"; |
336 | print "#if HZ != $hz\n"; | 297 | print "#if HZ != $hz\n"; |
@@ -340,15 +301,13 @@ sub output($@) | |||
340 | 301 | ||
341 | foreach $pfx ('HZ_TO_MSEC','MSEC_TO_HZ', | 302 | foreach $pfx ('HZ_TO_MSEC','MSEC_TO_HZ', |
342 | 'HZ_TO_USEC','USEC_TO_HZ') { | 303 | 'HZ_TO_USEC','USEC_TO_HZ') { |
343 | foreach $bit (32, 64) { | 304 | foreach $bit (32) { |
344 | foreach $suf ('MUL', 'ADJ', 'SHR') { | 305 | foreach $suf ('MUL', 'ADJ', 'SHR') { |
345 | printf "#define %-23s %s\n", | 306 | outputval("${pfx}_$suf$bit", shift(@val)); |
346 | "${pfx}_$suf$bit", shift(@val); | ||
347 | } | 307 | } |
348 | } | 308 | } |
349 | foreach $suf ('NUM', 'DEN') { | 309 | foreach $suf ('NUM', 'DEN') { |
350 | printf "#define %-23s %s\n", | 310 | outputval("${pfx}_$suf", shift(@val)); |
351 | "${pfx}_$suf", shift(@val); | ||
352 | } | 311 | } |
353 | } | 312 | } |
354 | 313 | ||
@@ -356,6 +315,23 @@ sub output($@) | |||
356 | print "#endif /* KERNEL_TIMECONST_H */\n"; | 315 | print "#endif /* KERNEL_TIMECONST_H */\n"; |
357 | } | 316 | } |
358 | 317 | ||
318 | # Pretty-print Perl values | ||
319 | sub perlvals(@) { | ||
320 | my $v; | ||
321 | my @l = (); | ||
322 | |||
323 | foreach $v (@_) { | ||
324 | if (!defined($v)) { | ||
325 | push(@l, 'undef'); | ||
326 | } elsif ($v =~ /^0x/) { | ||
327 | push(@l, "\'".$v."\'"); | ||
328 | } else { | ||
329 | push(@l, $v.''); | ||
330 | } | ||
331 | } | ||
332 | return join(',', @l); | ||
333 | } | ||
334 | |||
359 | ($hz) = @ARGV; | 335 | ($hz) = @ARGV; |
360 | 336 | ||
361 | # Use this to generate the %canned_values structure | 337 | # Use this to generate the %canned_values structure |
@@ -373,15 +349,15 @@ if ($hz eq '--can') { | |||
373 | print "$pf$hz => [\n"; | 349 | print "$pf$hz => [\n"; |
374 | while (scalar(@values)) { | 350 | while (scalar(@values)) { |
375 | my $bit; | 351 | my $bit; |
376 | foreach $bit (32, 64) { | 352 | foreach $bit (32) { |
377 | my $m = shift(@values); | 353 | my $m = shift(@values); |
378 | my $a = shift(@values); | 354 | my $a = shift(@values); |
379 | my $s = shift(@values); | 355 | my $s = shift(@values); |
380 | print "\t\t\'",$m,"\',\'",$a,"\',",$s,",\n"; | 356 | print "\t\t", perlvals($m,$a,$s), ",\n"; |
381 | } | 357 | } |
382 | my $n = shift(@values); | 358 | my $n = shift(@values); |
383 | my $d = shift(@values); | 359 | my $d = shift(@values); |
384 | print "\t\t",$n,',',$d,",\n"; | 360 | print "\t\t", perlvals($n,$d), ",\n"; |
385 | } | 361 | } |
386 | print "\t]"; | 362 | print "\t]"; |
387 | $pf = ', '; | 363 | $pf = ', '; |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 721093a22561..29fc39f1029c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -195,7 +195,6 @@ static void delayed_work_timer_fn(unsigned long __data) | |||
195 | int queue_delayed_work(struct workqueue_struct *wq, | 195 | int queue_delayed_work(struct workqueue_struct *wq, |
196 | struct delayed_work *dwork, unsigned long delay) | 196 | struct delayed_work *dwork, unsigned long delay) |
197 | { | 197 | { |
198 | timer_stats_timer_set_start_info(&dwork->timer); | ||
199 | if (delay == 0) | 198 | if (delay == 0) |
200 | return queue_work(wq, &dwork->work); | 199 | return queue_work(wq, &dwork->work); |
201 | 200 | ||
@@ -219,11 +218,12 @@ int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, | |||
219 | struct timer_list *timer = &dwork->timer; | 218 | struct timer_list *timer = &dwork->timer; |
220 | struct work_struct *work = &dwork->work; | 219 | struct work_struct *work = &dwork->work; |
221 | 220 | ||
222 | timer_stats_timer_set_start_info(&dwork->timer); | ||
223 | if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) { | 221 | if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) { |
224 | BUG_ON(timer_pending(timer)); | 222 | BUG_ON(timer_pending(timer)); |
225 | BUG_ON(!list_empty(&work->entry)); | 223 | BUG_ON(!list_empty(&work->entry)); |
226 | 224 | ||
225 | timer_stats_timer_set_start_info(&dwork->timer); | ||
226 | |||
227 | /* This stores cwq for the moment, for the timer_fn */ | 227 | /* This stores cwq for the moment, for the timer_fn */ |
228 | set_wq_data(work, wq_per_cpu(wq, raw_smp_processor_id())); | 228 | set_wq_data(work, wq_per_cpu(wq, raw_smp_processor_id())); |
229 | timer->expires = jiffies + delay; | 229 | timer->expires = jiffies + delay; |
@@ -564,7 +564,6 @@ EXPORT_SYMBOL(schedule_work); | |||
564 | int schedule_delayed_work(struct delayed_work *dwork, | 564 | int schedule_delayed_work(struct delayed_work *dwork, |
565 | unsigned long delay) | 565 | unsigned long delay) |
566 | { | 566 | { |
567 | timer_stats_timer_set_start_info(&dwork->timer); | ||
568 | return queue_delayed_work(keventd_wq, dwork, delay); | 567 | return queue_delayed_work(keventd_wq, dwork, delay); |
569 | } | 568 | } |
570 | EXPORT_SYMBOL(schedule_delayed_work); | 569 | EXPORT_SYMBOL(schedule_delayed_work); |
@@ -581,7 +580,6 @@ EXPORT_SYMBOL(schedule_delayed_work); | |||
581 | int schedule_delayed_work_on(int cpu, | 580 | int schedule_delayed_work_on(int cpu, |
582 | struct delayed_work *dwork, unsigned long delay) | 581 | struct delayed_work *dwork, unsigned long delay) |
583 | { | 582 | { |
584 | timer_stats_timer_set_start_info(&dwork->timer); | ||
585 | return queue_delayed_work_on(cpu, keventd_wq, dwork, delay); | 583 | return queue_delayed_work_on(cpu, keventd_wq, dwork, delay); |
586 | } | 584 | } |
587 | EXPORT_SYMBOL(schedule_delayed_work_on); | 585 | EXPORT_SYMBOL(schedule_delayed_work_on); |
diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb index f2e01ac5ab09..a5d4b1dac2a5 100644 --- a/lib/Kconfig.kgdb +++ b/lib/Kconfig.kgdb | |||
@@ -1,4 +1,10 @@ | |||
1 | 1 | ||
2 | config HAVE_ARCH_KGDB_SHADOW_INFO | ||
3 | bool | ||
4 | |||
5 | config HAVE_ARCH_KGDB | ||
6 | bool | ||
7 | |||
2 | menuconfig KGDB | 8 | menuconfig KGDB |
3 | bool "KGDB: kernel debugging with remote gdb" | 9 | bool "KGDB: kernel debugging with remote gdb" |
4 | select FRAME_POINTER | 10 | select FRAME_POINTER |
@@ -10,15 +16,10 @@ menuconfig KGDB | |||
10 | at http://kgdb.sourceforge.net as well as in DocBook form | 16 | at http://kgdb.sourceforge.net as well as in DocBook form |
11 | in Documentation/DocBook/. If unsure, say N. | 17 | in Documentation/DocBook/. If unsure, say N. |
12 | 18 | ||
13 | config HAVE_ARCH_KGDB_SHADOW_INFO | 19 | if KGDB |
14 | bool | ||
15 | |||
16 | config HAVE_ARCH_KGDB | ||
17 | bool | ||
18 | 20 | ||
19 | config KGDB_SERIAL_CONSOLE | 21 | config KGDB_SERIAL_CONSOLE |
20 | tristate "KGDB: use kgdb over the serial console" | 22 | tristate "KGDB: use kgdb over the serial console" |
21 | depends on KGDB | ||
22 | select CONSOLE_POLL | 23 | select CONSOLE_POLL |
23 | select MAGIC_SYSRQ | 24 | select MAGIC_SYSRQ |
24 | default y | 25 | default y |
@@ -28,7 +29,6 @@ config KGDB_SERIAL_CONSOLE | |||
28 | 29 | ||
29 | config KGDB_TESTS | 30 | config KGDB_TESTS |
30 | bool "KGDB: internal test suite" | 31 | bool "KGDB: internal test suite" |
31 | depends on KGDB | ||
32 | default n | 32 | default n |
33 | help | 33 | help |
34 | This is a kgdb I/O module specifically designed to test | 34 | This is a kgdb I/O module specifically designed to test |
@@ -56,3 +56,5 @@ config KGDB_TESTS_BOOT_STRING | |||
56 | boot. See the drivers/misc/kgdbts.c for detailed | 56 | boot. See the drivers/misc/kgdbts.c for detailed |
57 | information about other strings you could use beyond the | 57 | information about other strings you could use beyond the |
58 | default of V1F100. | 58 | default of V1F100. |
59 | |||
60 | endif # KGDB | ||
diff --git a/lib/devres.c b/lib/devres.c index 26c87c49d776..72c8909006da 100644 --- a/lib/devres.c +++ b/lib/devres.c | |||
@@ -2,7 +2,7 @@ | |||
2 | #include <linux/io.h> | 2 | #include <linux/io.h> |
3 | #include <linux/module.h> | 3 | #include <linux/module.h> |
4 | 4 | ||
5 | static void devm_ioremap_release(struct device *dev, void *res) | 5 | void devm_ioremap_release(struct device *dev, void *res) |
6 | { | 6 | { |
7 | iounmap(*(void __iomem **)res); | 7 | iounmap(*(void __iomem **)res); |
8 | } | 8 | } |
diff --git a/lib/div64.c b/lib/div64.c index b71cf93c529a..bb5bd0c0f030 100644 --- a/lib/div64.c +++ b/lib/div64.c | |||
@@ -16,9 +16,8 @@ | |||
16 | * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S. | 16 | * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/types.h> | ||
20 | #include <linux/module.h> | 19 | #include <linux/module.h> |
21 | #include <asm/div64.h> | 20 | #include <linux/math64.h> |
22 | 21 | ||
23 | /* Not needed on 64bit architectures */ | 22 | /* Not needed on 64bit architectures */ |
24 | #if BITS_PER_LONG == 32 | 23 | #if BITS_PER_LONG == 32 |
@@ -58,10 +57,31 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base) | |||
58 | 57 | ||
59 | EXPORT_SYMBOL(__div64_32); | 58 | EXPORT_SYMBOL(__div64_32); |
60 | 59 | ||
60 | #ifndef div_s64_rem | ||
61 | s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) | ||
62 | { | ||
63 | u64 quotient; | ||
64 | |||
65 | if (dividend < 0) { | ||
66 | quotient = div_u64_rem(-dividend, abs(divisor), (u32 *)remainder); | ||
67 | *remainder = -*remainder; | ||
68 | if (divisor > 0) | ||
69 | quotient = -quotient; | ||
70 | } else { | ||
71 | quotient = div_u64_rem(dividend, abs(divisor), (u32 *)remainder); | ||
72 | if (divisor < 0) | ||
73 | quotient = -quotient; | ||
74 | } | ||
75 | return quotient; | ||
76 | } | ||
77 | EXPORT_SYMBOL(div_s64_rem); | ||
78 | #endif | ||
79 | |||
61 | /* 64bit divisor, dividend and result. dynamic precision */ | 80 | /* 64bit divisor, dividend and result. dynamic precision */ |
62 | uint64_t div64_64(uint64_t dividend, uint64_t divisor) | 81 | #ifndef div64_u64 |
82 | u64 div64_u64(u64 dividend, u64 divisor) | ||
63 | { | 83 | { |
64 | uint32_t high, d; | 84 | u32 high, d; |
65 | 85 | ||
66 | high = divisor >> 32; | 86 | high = divisor >> 32; |
67 | if (high) { | 87 | if (high) { |
@@ -72,10 +92,9 @@ uint64_t div64_64(uint64_t dividend, uint64_t divisor) | |||
72 | } else | 92 | } else |
73 | d = divisor; | 93 | d = divisor; |
74 | 94 | ||
75 | do_div(dividend, d); | 95 | return div_u64(dividend, d); |
76 | |||
77 | return dividend; | ||
78 | } | 96 | } |
79 | EXPORT_SYMBOL(div64_64); | 97 | EXPORT_SYMBOL(div64_u64); |
98 | #endif | ||
80 | 99 | ||
81 | #endif /* BITS_PER_LONG == 32 */ | 100 | #endif /* BITS_PER_LONG == 32 */ |
@@ -385,8 +385,8 @@ void idr_remove(struct idr *idp, int id) | |||
385 | while (idp->id_free_cnt >= IDR_FREE_MAX) { | 385 | while (idp->id_free_cnt >= IDR_FREE_MAX) { |
386 | p = alloc_layer(idp); | 386 | p = alloc_layer(idp); |
387 | kmem_cache_free(idr_layer_cache, p); | 387 | kmem_cache_free(idr_layer_cache, p); |
388 | return; | ||
389 | } | 388 | } |
389 | return; | ||
390 | } | 390 | } |
391 | EXPORT_SYMBOL(idr_remove); | 391 | EXPORT_SYMBOL(idr_remove); |
392 | 392 | ||
diff --git a/lib/string.c b/lib/string.c index 5efafed3d6b6..b19b87af65a3 100644 --- a/lib/string.c +++ b/lib/string.c | |||
@@ -493,6 +493,33 @@ char *strsep(char **s, const char *ct) | |||
493 | EXPORT_SYMBOL(strsep); | 493 | EXPORT_SYMBOL(strsep); |
494 | #endif | 494 | #endif |
495 | 495 | ||
496 | /** | ||
497 | * sysfs_streq - return true if strings are equal, modulo trailing newline | ||
498 | * @s1: one string | ||
499 | * @s2: another string | ||
500 | * | ||
501 | * This routine returns true iff two strings are equal, treating both | ||
502 | * NUL and newline-then-NUL as equivalent string terminations. It's | ||
503 | * geared for use with sysfs input strings, which generally terminate | ||
504 | * with newlines but are compared against values without newlines. | ||
505 | */ | ||
506 | bool sysfs_streq(const char *s1, const char *s2) | ||
507 | { | ||
508 | while (*s1 && *s1 == *s2) { | ||
509 | s1++; | ||
510 | s2++; | ||
511 | } | ||
512 | |||
513 | if (*s1 == *s2) | ||
514 | return true; | ||
515 | if (!*s1 && *s2 == '\n' && !s2[1]) | ||
516 | return true; | ||
517 | if (*s1 == '\n' && !s1[1] && !*s2) | ||
518 | return true; | ||
519 | return false; | ||
520 | } | ||
521 | EXPORT_SYMBOL(sysfs_streq); | ||
522 | |||
496 | #ifndef __HAVE_ARCH_MEMSET | 523 | #ifndef __HAVE_ARCH_MEMSET |
497 | /** | 524 | /** |
498 | * memset - Fill a region of memory with the given value | 525 | * memset - Fill a region of memory with the given value |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 33add96cd5fb..e46451e1d9b7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -48,6 +48,8 @@ enum mem_cgroup_stat_index { | |||
48 | */ | 48 | */ |
49 | MEM_CGROUP_STAT_CACHE, /* # of pages charged as cache */ | 49 | MEM_CGROUP_STAT_CACHE, /* # of pages charged as cache */ |
50 | MEM_CGROUP_STAT_RSS, /* # of pages charged as rss */ | 50 | MEM_CGROUP_STAT_RSS, /* # of pages charged as rss */ |
51 | MEM_CGROUP_STAT_PGPGIN_COUNT, /* # of pages paged in */ | ||
52 | MEM_CGROUP_STAT_PGPGOUT_COUNT, /* # of pages paged out */ | ||
51 | 53 | ||
52 | MEM_CGROUP_STAT_NSTATS, | 54 | MEM_CGROUP_STAT_NSTATS, |
53 | }; | 55 | }; |
@@ -199,6 +201,13 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem, int flags, | |||
199 | __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_CACHE, val); | 201 | __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_CACHE, val); |
200 | else | 202 | else |
201 | __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_RSS, val); | 203 | __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_RSS, val); |
204 | |||
205 | if (charge) | ||
206 | __mem_cgroup_stat_add_safe(stat, | ||
207 | MEM_CGROUP_STAT_PGPGIN_COUNT, 1); | ||
208 | else | ||
209 | __mem_cgroup_stat_add_safe(stat, | ||
210 | MEM_CGROUP_STAT_PGPGOUT_COUNT, 1); | ||
202 | } | 211 | } |
203 | 212 | ||
204 | static struct mem_cgroup_per_zone * | 213 | static struct mem_cgroup_per_zone * |
@@ -884,6 +893,8 @@ static const struct mem_cgroup_stat_desc { | |||
884 | } mem_cgroup_stat_desc[] = { | 893 | } mem_cgroup_stat_desc[] = { |
885 | [MEM_CGROUP_STAT_CACHE] = { "cache", PAGE_SIZE, }, | 894 | [MEM_CGROUP_STAT_CACHE] = { "cache", PAGE_SIZE, }, |
886 | [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, }, | 895 | [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, }, |
896 | [MEM_CGROUP_STAT_PGPGIN_COUNT] = {"pgpgin", 1, }, | ||
897 | [MEM_CGROUP_STAT_PGPGOUT_COUNT] = {"pgpgout", 1, }, | ||
887 | }; | 898 | }; |
888 | 899 | ||
889 | static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft, | 900 | static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft, |
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/debugobjects.h> | 22 | #include <linux/debugobjects.h> |
23 | #include <linux/kallsyms.h> | 23 | #include <linux/kallsyms.h> |
24 | #include <linux/memory.h> | 24 | #include <linux/memory.h> |
25 | #include <linux/math64.h> | ||
25 | 26 | ||
26 | /* | 27 | /* |
27 | * Lock order: | 28 | * Lock order: |
@@ -216,7 +217,7 @@ struct track { | |||
216 | 217 | ||
217 | enum track_item { TRACK_ALLOC, TRACK_FREE }; | 218 | enum track_item { TRACK_ALLOC, TRACK_FREE }; |
218 | 219 | ||
219 | #if defined(CONFIG_SYSFS) && defined(CONFIG_SLUB_DEBUG) | 220 | #ifdef CONFIG_SLUB_DEBUG |
220 | static int sysfs_slab_add(struct kmem_cache *); | 221 | static int sysfs_slab_add(struct kmem_cache *); |
221 | static int sysfs_slab_alias(struct kmem_cache *, const char *); | 222 | static int sysfs_slab_alias(struct kmem_cache *, const char *); |
222 | static void sysfs_slab_remove(struct kmem_cache *); | 223 | static void sysfs_slab_remove(struct kmem_cache *); |
@@ -813,7 +814,8 @@ static int on_freelist(struct kmem_cache *s, struct page *page, void *search) | |||
813 | return search == NULL; | 814 | return search == NULL; |
814 | } | 815 | } |
815 | 816 | ||
816 | static void trace(struct kmem_cache *s, struct page *page, void *object, int alloc) | 817 | static void trace(struct kmem_cache *s, struct page *page, void *object, |
818 | int alloc) | ||
817 | { | 819 | { |
818 | if (s->flags & SLAB_TRACE) { | 820 | if (s->flags & SLAB_TRACE) { |
819 | printk(KERN_INFO "TRACE %s %s 0x%p inuse=%d fp=0x%p\n", | 821 | printk(KERN_INFO "TRACE %s %s 0x%p inuse=%d fp=0x%p\n", |
@@ -1266,8 +1268,7 @@ static void add_partial(struct kmem_cache_node *n, | |||
1266 | spin_unlock(&n->list_lock); | 1268 | spin_unlock(&n->list_lock); |
1267 | } | 1269 | } |
1268 | 1270 | ||
1269 | static void remove_partial(struct kmem_cache *s, | 1271 | static void remove_partial(struct kmem_cache *s, struct page *page) |
1270 | struct page *page) | ||
1271 | { | 1272 | { |
1272 | struct kmem_cache_node *n = get_node(s, page_to_nid(page)); | 1273 | struct kmem_cache_node *n = get_node(s, page_to_nid(page)); |
1273 | 1274 | ||
@@ -1282,7 +1283,8 @@ static void remove_partial(struct kmem_cache *s, | |||
1282 | * | 1283 | * |
1283 | * Must hold list_lock. | 1284 | * Must hold list_lock. |
1284 | */ | 1285 | */ |
1285 | static inline int lock_and_freeze_slab(struct kmem_cache_node *n, struct page *page) | 1286 | static inline int lock_and_freeze_slab(struct kmem_cache_node *n, |
1287 | struct page *page) | ||
1286 | { | 1288 | { |
1287 | if (slab_trylock(page)) { | 1289 | if (slab_trylock(page)) { |
1288 | list_del(&page->lru); | 1290 | list_del(&page->lru); |
@@ -1419,8 +1421,8 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail) | |||
1419 | * so that the others get filled first. That way the | 1421 | * so that the others get filled first. That way the |
1420 | * size of the partial list stays small. | 1422 | * size of the partial list stays small. |
1421 | * | 1423 | * |
1422 | * kmem_cache_shrink can reclaim any empty slabs from the | 1424 | * kmem_cache_shrink can reclaim any empty slabs from |
1423 | * partial list. | 1425 | * the partial list. |
1424 | */ | 1426 | */ |
1425 | add_partial(n, page, 1); | 1427 | add_partial(n, page, 1); |
1426 | slab_unlock(page); | 1428 | slab_unlock(page); |
@@ -2908,7 +2910,7 @@ static int slab_mem_going_online_callback(void *arg) | |||
2908 | return 0; | 2910 | return 0; |
2909 | 2911 | ||
2910 | /* | 2912 | /* |
2911 | * We are bringing a node online. No memory is availabe yet. We must | 2913 | * We are bringing a node online. No memory is available yet. We must |
2912 | * allocate a kmem_cache_node structure in order to bring the node | 2914 | * allocate a kmem_cache_node structure in order to bring the node |
2913 | * online. | 2915 | * online. |
2914 | */ | 2916 | */ |
@@ -3245,7 +3247,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, | |||
3245 | return slab_alloc(s, gfpflags, node, caller); | 3247 | return slab_alloc(s, gfpflags, node, caller); |
3246 | } | 3248 | } |
3247 | 3249 | ||
3248 | #if (defined(CONFIG_SYSFS) && defined(CONFIG_SLUB_DEBUG)) || defined(CONFIG_SLABINFO) | 3250 | #ifdef CONFIG_SLUB_DEBUG |
3249 | static unsigned long count_partial(struct kmem_cache_node *n, | 3251 | static unsigned long count_partial(struct kmem_cache_node *n, |
3250 | int (*get_count)(struct page *)) | 3252 | int (*get_count)(struct page *)) |
3251 | { | 3253 | { |
@@ -3274,9 +3276,7 @@ static int count_free(struct page *page) | |||
3274 | { | 3276 | { |
3275 | return page->objects - page->inuse; | 3277 | return page->objects - page->inuse; |
3276 | } | 3278 | } |
3277 | #endif | ||
3278 | 3279 | ||
3279 | #if defined(CONFIG_SYSFS) && defined(CONFIG_SLUB_DEBUG) | ||
3280 | static int validate_slab(struct kmem_cache *s, struct page *page, | 3280 | static int validate_slab(struct kmem_cache *s, struct page *page, |
3281 | unsigned long *map) | 3281 | unsigned long *map) |
3282 | { | 3282 | { |
@@ -3621,12 +3621,10 @@ static int list_locations(struct kmem_cache *s, char *buf, | |||
3621 | len += sprintf(buf + len, "<not-available>"); | 3621 | len += sprintf(buf + len, "<not-available>"); |
3622 | 3622 | ||
3623 | if (l->sum_time != l->min_time) { | 3623 | if (l->sum_time != l->min_time) { |
3624 | unsigned long remainder; | ||
3625 | |||
3626 | len += sprintf(buf + len, " age=%ld/%ld/%ld", | 3624 | len += sprintf(buf + len, " age=%ld/%ld/%ld", |
3627 | l->min_time, | 3625 | l->min_time, |
3628 | div_long_long_rem(l->sum_time, l->count, &remainder), | 3626 | (long)div_u64(l->sum_time, l->count), |
3629 | l->max_time); | 3627 | l->max_time); |
3630 | } else | 3628 | } else |
3631 | len += sprintf(buf + len, " age=%ld", | 3629 | len += sprintf(buf + len, " age=%ld", |
3632 | l->min_time); | 3630 | l->min_time); |
@@ -3813,7 +3811,12 @@ SLAB_ATTR_RO(objs_per_slab); | |||
3813 | static ssize_t order_store(struct kmem_cache *s, | 3811 | static ssize_t order_store(struct kmem_cache *s, |
3814 | const char *buf, size_t length) | 3812 | const char *buf, size_t length) |
3815 | { | 3813 | { |
3816 | int order = simple_strtoul(buf, NULL, 10); | 3814 | unsigned long order; |
3815 | int err; | ||
3816 | |||
3817 | err = strict_strtoul(buf, 10, &order); | ||
3818 | if (err) | ||
3819 | return err; | ||
3817 | 3820 | ||
3818 | if (order > slub_max_order || order < slub_min_order) | 3821 | if (order > slub_max_order || order < slub_min_order) |
3819 | return -EINVAL; | 3822 | return -EINVAL; |
@@ -4066,10 +4069,16 @@ static ssize_t remote_node_defrag_ratio_show(struct kmem_cache *s, char *buf) | |||
4066 | static ssize_t remote_node_defrag_ratio_store(struct kmem_cache *s, | 4069 | static ssize_t remote_node_defrag_ratio_store(struct kmem_cache *s, |
4067 | const char *buf, size_t length) | 4070 | const char *buf, size_t length) |
4068 | { | 4071 | { |
4069 | int n = simple_strtoul(buf, NULL, 10); | 4072 | unsigned long ratio; |
4073 | int err; | ||
4074 | |||
4075 | err = strict_strtoul(buf, 10, &ratio); | ||
4076 | if (err) | ||
4077 | return err; | ||
4078 | |||
4079 | if (ratio < 100) | ||
4080 | s->remote_node_defrag_ratio = ratio * 10; | ||
4070 | 4081 | ||
4071 | if (n < 100) | ||
4072 | s->remote_node_defrag_ratio = n * 10; | ||
4073 | return length; | 4082 | return length; |
4074 | } | 4083 | } |
4075 | SLAB_ATTR(remote_node_defrag_ratio); | 4084 | SLAB_ATTR(remote_node_defrag_ratio); |
@@ -4426,8 +4435,8 @@ __initcall(slab_sysfs_init); | |||
4426 | */ | 4435 | */ |
4427 | #ifdef CONFIG_SLABINFO | 4436 | #ifdef CONFIG_SLABINFO |
4428 | 4437 | ||
4429 | ssize_t slabinfo_write(struct file *file, const char __user * buffer, | 4438 | ssize_t slabinfo_write(struct file *file, const char __user *buffer, |
4430 | size_t count, loff_t *ppos) | 4439 | size_t count, loff_t *ppos) |
4431 | { | 4440 | { |
4432 | return -EINVAL; | 4441 | return -EINVAL; |
4433 | } | 4442 | } |
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 2a39cf128aba..6e45b0f3d125 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -547,6 +547,7 @@ void *__vmalloc_area(struct vm_struct *area, gfp_t gfp_mask, pgprot_t prot) | |||
547 | * @gfp_mask: flags for the page level allocator | 547 | * @gfp_mask: flags for the page level allocator |
548 | * @prot: protection mask for the allocated pages | 548 | * @prot: protection mask for the allocated pages |
549 | * @node: node to use for allocation or -1 | 549 | * @node: node to use for allocation or -1 |
550 | * @caller: caller's return address | ||
550 | * | 551 | * |
551 | * Allocate enough pages to cover @size from the page level | 552 | * Allocate enough pages to cover @size from the page level |
552 | * allocator with @gfp_mask flags. Map them into contiguous | 553 | * allocator with @gfp_mask flags. Map them into contiguous |
diff --git a/net/can/bcm.c b/net/can/bcm.c index 74fd2d33aff4..d9a3a9d13bed 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c | |||
@@ -412,12 +412,6 @@ static void bcm_rx_changed(struct bcm_op *op, struct can_frame *data) | |||
412 | bcm_send_to_user(op, &head, data, 1); | 412 | bcm_send_to_user(op, &head, data, 1); |
413 | } | 413 | } |
414 | 414 | ||
415 | /* TODO: move to linux/hrtimer.h */ | ||
416 | static inline int hrtimer_callback_running(struct hrtimer *timer) | ||
417 | { | ||
418 | return timer->state & HRTIMER_STATE_CALLBACK; | ||
419 | } | ||
420 | |||
421 | /* | 415 | /* |
422 | * bcm_rx_update_and_send - process a detected relevant receive content change | 416 | * bcm_rx_update_and_send - process a detected relevant receive content change |
423 | * 1. update the last received data | 417 | * 1. update the last received data |
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index eb5b9854c8c7..4a1221e5e8ee 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c | |||
@@ -15,8 +15,8 @@ | |||
15 | 15 | ||
16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/math64.h> | ||
18 | #include <net/tcp.h> | 19 | #include <net/tcp.h> |
19 | #include <asm/div64.h> | ||
20 | 20 | ||
21 | #define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation | 21 | #define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation |
22 | * max_cwnd = snd_cwnd * beta | 22 | * max_cwnd = snd_cwnd * beta |
@@ -128,7 +128,7 @@ static u32 cubic_root(u64 a) | |||
128 | * x = ( 2 * x + a / x ) / 3 | 128 | * x = ( 2 * x + a / x ) / 3 |
129 | * k+1 k k | 129 | * k+1 k k |
130 | */ | 130 | */ |
131 | x = (2 * x + (u32)div64_64(a, (u64)x * (u64)(x - 1))); | 131 | x = (2 * x + (u32)div64_u64(a, (u64)x * (u64)(x - 1))); |
132 | x = ((x * 341) >> 10); | 132 | x = ((x * 341) >> 10); |
133 | return x; | 133 | return x; |
134 | } | 134 | } |
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c index b15e7e2fa143..d7e8983cd37f 100644 --- a/net/netfilter/xt_connbytes.c +++ b/net/netfilter/xt_connbytes.c | |||
@@ -4,12 +4,11 @@ | |||
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <linux/bitops.h> | 5 | #include <linux/bitops.h> |
6 | #include <linux/skbuff.h> | 6 | #include <linux/skbuff.h> |
7 | #include <linux/math64.h> | ||
7 | #include <linux/netfilter/x_tables.h> | 8 | #include <linux/netfilter/x_tables.h> |
8 | #include <linux/netfilter/xt_connbytes.h> | 9 | #include <linux/netfilter/xt_connbytes.h> |
9 | #include <net/netfilter/nf_conntrack.h> | 10 | #include <net/netfilter/nf_conntrack.h> |
10 | 11 | ||
11 | #include <asm/div64.h> | ||
12 | |||
13 | MODULE_LICENSE("GPL"); | 12 | MODULE_LICENSE("GPL"); |
14 | MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); | 13 | MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); |
15 | MODULE_DESCRIPTION("Xtables: Number of packets/bytes per connection matching"); | 14 | MODULE_DESCRIPTION("Xtables: Number of packets/bytes per connection matching"); |
@@ -82,7 +81,7 @@ connbytes_mt(const struct sk_buff *skb, const struct net_device *in, | |||
82 | break; | 81 | break; |
83 | } | 82 | } |
84 | if (pkts != 0) | 83 | if (pkts != 0) |
85 | what = div64_64(bytes, pkts); | 84 | what = div64_u64(bytes, pkts); |
86 | break; | 85 | break; |
87 | } | 86 | } |
88 | 87 | ||
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 4bc68f20a73c..96521cb087ec 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -11,9 +11,9 @@ | |||
11 | #ifndef KBUILD_NO_NLS | 11 | #ifndef KBUILD_NO_NLS |
12 | # include <libintl.h> | 12 | # include <libintl.h> |
13 | #else | 13 | #else |
14 | # define gettext(Msgid) ((const char *) (Msgid)) | 14 | static inline const char *gettext(const char *txt) { return txt; } |
15 | # define textdomain(Domainname) ((const char *) (Domainname)) | 15 | static inline void textdomain(const char *domainname) {} |
16 | # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) | 16 | static inline void bindtextdomain(const char *name, const char *dir) {} |
17 | #endif | 17 | #endif |
18 | 18 | ||
19 | #ifdef __cplusplus | 19 | #ifdef __cplusplus |
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh index 62e1e02126e6..5552154cbedb 100644 --- a/scripts/kconfig/lxdialog/check-lxdialog.sh +++ b/scripts/kconfig/lxdialog/check-lxdialog.sh | |||
@@ -36,8 +36,10 @@ trap "rm -f $tmp" 0 1 2 3 15 | |||
36 | 36 | ||
37 | # Check if we can link to ncurses | 37 | # Check if we can link to ncurses |
38 | check() { | 38 | check() { |
39 | echo -e " #include CURSES_LOC \n main() {}" | | 39 | $cc -xc - -o $tmp 2>/dev/null <<'EOF' |
40 | $cc -xc - -o $tmp 2> /dev/null | 40 | #include CURSES_LOC |
41 | main() {} | ||
42 | EOF | ||
41 | if [ $? != 0 ]; then | 43 | if [ $? != 0 ]; then |
42 | echo " *** Unable to find the ncurses libraries or the" 1>&2 | 44 | echo " *** Unable to find the ncurses libraries or the" 1>&2 |
43 | echo " *** required header files." 1>&2 | 45 | echo " *** required header files." 1>&2 |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 734cf4f3131e..6841e95c0989 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -773,7 +773,7 @@ static void conf_string(struct menu *menu) | |||
773 | 773 | ||
774 | while (1) { | 774 | while (1) { |
775 | int res; | 775 | int res; |
776 | char *heading; | 776 | const char *heading; |
777 | 777 | ||
778 | switch (sym_get_type(menu->sym)) { | 778 | switch (sym_get_type(menu->sym)) { |
779 | case S_INT: | 779 | case S_INT: |
@@ -925,3 +925,4 @@ int main(int ac, char **av) | |||
925 | 925 | ||
926 | return 0; | 926 | return 0; |
927 | } | 927 | } |
928 | |||
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index e04c4218cb52..cea4a790e1e9 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -51,6 +51,15 @@ do { \ | |||
51 | sprintf(str + strlen(str), "*"); \ | 51 | sprintf(str + strlen(str), "*"); \ |
52 | } while(0) | 52 | } while(0) |
53 | 53 | ||
54 | /* Always end in a wildcard, for future extension */ | ||
55 | static inline void add_wildcard(char *str) | ||
56 | { | ||
57 | int len = strlen(str); | ||
58 | |||
59 | if (str[len - 1] != '*') | ||
60 | strcat(str + len, "*"); | ||
61 | } | ||
62 | |||
54 | unsigned int cross_build = 0; | 63 | unsigned int cross_build = 0; |
55 | /** | 64 | /** |
56 | * Check that sizeof(device_id type) are consistent with size of section | 65 | * Check that sizeof(device_id type) are consistent with size of section |
@@ -133,9 +142,7 @@ static void do_usb_entry(struct usb_device_id *id, | |||
133 | id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, | 142 | id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, |
134 | id->bInterfaceProtocol); | 143 | id->bInterfaceProtocol); |
135 | 144 | ||
136 | /* Always end in a wildcard, for future extension */ | 145 | add_wildcard(alias); |
137 | if (alias[strlen(alias)-1] != '*') | ||
138 | strcat(alias, "*"); | ||
139 | buf_printf(&mod->dev_table_buf, | 146 | buf_printf(&mod->dev_table_buf, |
140 | "MODULE_ALIAS(\"%s\");\n", alias); | 147 | "MODULE_ALIAS(\"%s\");\n", alias); |
141 | } | 148 | } |
@@ -219,6 +226,7 @@ static int do_ieee1394_entry(const char *filename, | |||
219 | ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION, | 226 | ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION, |
220 | id->version); | 227 | id->version); |
221 | 228 | ||
229 | add_wildcard(alias); | ||
222 | return 1; | 230 | return 1; |
223 | } | 231 | } |
224 | 232 | ||
@@ -261,6 +269,7 @@ static int do_pci_entry(const char *filename, | |||
261 | ADD(alias, "bc", baseclass_mask == 0xFF, baseclass); | 269 | ADD(alias, "bc", baseclass_mask == 0xFF, baseclass); |
262 | ADD(alias, "sc", subclass_mask == 0xFF, subclass); | 270 | ADD(alias, "sc", subclass_mask == 0xFF, subclass); |
263 | ADD(alias, "i", interface_mask == 0xFF, interface); | 271 | ADD(alias, "i", interface_mask == 0xFF, interface); |
272 | add_wildcard(alias); | ||
264 | return 1; | 273 | return 1; |
265 | } | 274 | } |
266 | 275 | ||
@@ -283,6 +292,7 @@ static int do_ccw_entry(const char *filename, | |||
283 | id->dev_type); | 292 | id->dev_type); |
284 | ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, | 293 | ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, |
285 | id->dev_model); | 294 | id->dev_model); |
295 | add_wildcard(alias); | ||
286 | return 1; | 296 | return 1; |
287 | } | 297 | } |
288 | 298 | ||
@@ -290,7 +300,7 @@ static int do_ccw_entry(const char *filename, | |||
290 | static int do_ap_entry(const char *filename, | 300 | static int do_ap_entry(const char *filename, |
291 | struct ap_device_id *id, char *alias) | 301 | struct ap_device_id *id, char *alias) |
292 | { | 302 | { |
293 | sprintf(alias, "ap:t%02X", id->dev_type); | 303 | sprintf(alias, "ap:t%02X*", id->dev_type); |
294 | return 1; | 304 | return 1; |
295 | } | 305 | } |
296 | 306 | ||
@@ -309,6 +319,7 @@ static int do_serio_entry(const char *filename, | |||
309 | ADD(alias, "id", id->id != SERIO_ANY, id->id); | 319 | ADD(alias, "id", id->id != SERIO_ANY, id->id); |
310 | ADD(alias, "ex", id->extra != SERIO_ANY, id->extra); | 320 | ADD(alias, "ex", id->extra != SERIO_ANY, id->extra); |
311 | 321 | ||
322 | add_wildcard(alias); | ||
312 | return 1; | 323 | return 1; |
313 | } | 324 | } |
314 | 325 | ||
@@ -316,7 +327,7 @@ static int do_serio_entry(const char *filename, | |||
316 | static int do_acpi_entry(const char *filename, | 327 | static int do_acpi_entry(const char *filename, |
317 | struct acpi_device_id *id, char *alias) | 328 | struct acpi_device_id *id, char *alias) |
318 | { | 329 | { |
319 | sprintf(alias, "acpi*:%s:", id->id); | 330 | sprintf(alias, "acpi*:%s:*", id->id); |
320 | return 1; | 331 | return 1; |
321 | } | 332 | } |
322 | 333 | ||
@@ -324,7 +335,7 @@ static int do_acpi_entry(const char *filename, | |||
324 | static int do_pnp_entry(const char *filename, | 335 | static int do_pnp_entry(const char *filename, |
325 | struct pnp_device_id *id, char *alias) | 336 | struct pnp_device_id *id, char *alias) |
326 | { | 337 | { |
327 | sprintf(alias, "pnp:d%s", id->id); | 338 | sprintf(alias, "pnp:d%s*", id->id); |
328 | return 1; | 339 | return 1; |
329 | } | 340 | } |
330 | 341 | ||
@@ -409,6 +420,7 @@ static int do_pcmcia_entry(const char *filename, | |||
409 | ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]); | 420 | ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]); |
410 | ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]); | 421 | ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]); |
411 | 422 | ||
423 | add_wildcard(alias); | ||
412 | return 1; | 424 | return 1; |
413 | } | 425 | } |
414 | 426 | ||
@@ -432,6 +444,7 @@ static int do_of_entry (const char *filename, struct of_device_id *of, char *ali | |||
432 | if (isspace (*tmp)) | 444 | if (isspace (*tmp)) |
433 | *tmp = '_'; | 445 | *tmp = '_'; |
434 | 446 | ||
447 | add_wildcard(alias); | ||
435 | return 1; | 448 | return 1; |
436 | } | 449 | } |
437 | 450 | ||
@@ -448,6 +461,7 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio, | |||
448 | if (isspace (*tmp)) | 461 | if (isspace (*tmp)) |
449 | *tmp = '_'; | 462 | *tmp = '_'; |
450 | 463 | ||
464 | add_wildcard(alias); | ||
451 | return 1; | 465 | return 1; |
452 | } | 466 | } |
453 | 467 | ||
@@ -511,6 +525,8 @@ static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, | |||
511 | { | 525 | { |
512 | if (eisa->sig[0]) | 526 | if (eisa->sig[0]) |
513 | sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig); | 527 | sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig); |
528 | else | ||
529 | strcat(alias, "*"); | ||
514 | return 1; | 530 | return 1; |
515 | } | 531 | } |
516 | 532 | ||
@@ -529,6 +545,7 @@ static int do_parisc_entry(const char *filename, struct parisc_device_id *id, | |||
529 | ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev); | 545 | ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev); |
530 | ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion); | 546 | ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion); |
531 | 547 | ||
548 | add_wildcard(alias); | ||
532 | return 1; | 549 | return 1; |
533 | } | 550 | } |
534 | 551 | ||
@@ -544,6 +561,7 @@ static int do_sdio_entry(const char *filename, | |||
544 | ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class); | 561 | ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class); |
545 | ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor); | 562 | ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor); |
546 | ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device); | 563 | ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device); |
564 | add_wildcard(alias); | ||
547 | return 1; | 565 | return 1; |
548 | } | 566 | } |
549 | 567 | ||
@@ -559,6 +577,7 @@ static int do_ssb_entry(const char *filename, | |||
559 | ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor); | 577 | ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor); |
560 | ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid); | 578 | ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid); |
561 | ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision); | 579 | ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision); |
580 | add_wildcard(alias); | ||
562 | return 1; | 581 | return 1; |
563 | } | 582 | } |
564 | 583 | ||
@@ -573,6 +592,7 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id, | |||
573 | ADD(alias, "d", 1, id->device); | 592 | ADD(alias, "d", 1, id->device); |
574 | ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor); | 593 | ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor); |
575 | 594 | ||
595 | add_wildcard(alias); | ||
576 | return 1; | 596 | return 1; |
577 | } | 597 | } |
578 | 598 | ||
@@ -612,9 +632,6 @@ static void do_table(void *symval, unsigned long size, | |||
612 | 632 | ||
613 | for (i = 0; i < size; i += id_size) { | 633 | for (i = 0; i < size; i += id_size) { |
614 | if (do_entry(mod->name, symval+i, alias)) { | 634 | if (do_entry(mod->name, symval+i, alias)) { |
615 | /* Always end in a wildcard, for future extension */ | ||
616 | if (alias[strlen(alias)-1] != '*') | ||
617 | strcat(alias, "*"); | ||
618 | buf_printf(&mod->dev_table_buf, | 635 | buf_printf(&mod->dev_table_buf, |
619 | "MODULE_ALIAS(\"%s\");\n", alias); | 636 | "MODULE_ALIAS(\"%s\");\n", alias); |
620 | } | 637 | } |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 1b50a6ebc55f..1c864c0efe2b 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/spinlock.h> | 39 | #include <linux/spinlock.h> |
40 | #include <linux/syscalls.h> | 40 | #include <linux/syscalls.h> |
41 | #include <linux/file.h> | 41 | #include <linux/file.h> |
42 | #include <linux/fdtable.h> | ||
42 | #include <linux/namei.h> | 43 | #include <linux/namei.h> |
43 | #include <linux/mount.h> | 44 | #include <linux/mount.h> |
44 | #include <linux/ext2_fs.h> | 45 | #include <linux/ext2_fs.h> |
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 59203511e77d..54a1f9036c66 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c | |||
@@ -194,6 +194,7 @@ static void pcsp_stop_beep(struct snd_pcsp *chip) | |||
194 | spin_unlock_irq(&chip->substream_lock); | 194 | spin_unlock_irq(&chip->substream_lock); |
195 | } | 195 | } |
196 | 196 | ||
197 | #ifdef CONFIG_PM | ||
197 | static int pcsp_suspend(struct platform_device *dev, pm_message_t state) | 198 | static int pcsp_suspend(struct platform_device *dev, pm_message_t state) |
198 | { | 199 | { |
199 | struct snd_pcsp *chip = platform_get_drvdata(dev); | 200 | struct snd_pcsp *chip = platform_get_drvdata(dev); |
@@ -201,6 +202,9 @@ static int pcsp_suspend(struct platform_device *dev, pm_message_t state) | |||
201 | snd_pcm_suspend_all(chip->pcm); | 202 | snd_pcm_suspend_all(chip->pcm); |
202 | return 0; | 203 | return 0; |
203 | } | 204 | } |
205 | #else | ||
206 | #define pcsp_suspend NULL | ||
207 | #endif /* CONFIG_PM */ | ||
204 | 208 | ||
205 | static void pcsp_shutdown(struct platform_device *dev) | 209 | static void pcsp_shutdown(struct platform_device *dev) |
206 | { | 210 | { |
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 581debf37dcb..7e4742109572 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig | |||
@@ -515,19 +515,16 @@ config SND_FM801 | |||
515 | config SND_FM801_TEA575X_BOOL | 515 | config SND_FM801_TEA575X_BOOL |
516 | bool "ForteMedia FM801 + TEA5757 tuner" | 516 | bool "ForteMedia FM801 + TEA5757 tuner" |
517 | depends on SND_FM801 | 517 | depends on SND_FM801 |
518 | depends on VIDEO_V4L1=y || VIDEO_V4L1=SND_FM801 | ||
518 | help | 519 | help |
519 | Say Y here to include support for soundcards based on the ForteMedia | 520 | Say Y here to include support for soundcards based on the ForteMedia |
520 | FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media | 521 | FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media |
521 | Forte SF256-PCS-02) into the snd-fm801 driver. | 522 | Forte SF256-PCS-02) into the snd-fm801 driver. |
522 | 523 | ||
523 | This will enable support for the old V4L1 API. | ||
524 | |||
525 | config SND_FM801_TEA575X | 524 | config SND_FM801_TEA575X |
526 | tristate | 525 | tristate |
527 | depends on SND_FM801_TEA575X_BOOL | 526 | depends on SND_FM801_TEA575X_BOOL |
528 | default SND_FM801 | 527 | default SND_FM801 |
529 | select VIDEO_V4L1 | ||
530 | select VIDEO_DEV | ||
531 | 528 | ||
532 | config SND_HDA_INTEL | 529 | config SND_HDA_INTEL |
533 | tristate "Intel HD Audio" | 530 | tristate "Intel HD Audio" |
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 39198e505b12..2da89810ca10 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c | |||
@@ -3446,6 +3446,7 @@ static const struct snd_kcontrol_new snd_ac97_controls_vt1617a[] = { | |||
3446 | int patch_vt1617a(struct snd_ac97 * ac97) | 3446 | int patch_vt1617a(struct snd_ac97 * ac97) |
3447 | { | 3447 | { |
3448 | int err = 0; | 3448 | int err = 0; |
3449 | int val; | ||
3449 | 3450 | ||
3450 | /* we choose to not fail out at this point, but we tell the | 3451 | /* we choose to not fail out at this point, but we tell the |
3451 | caller when we return */ | 3452 | caller when we return */ |
@@ -3456,7 +3457,13 @@ int patch_vt1617a(struct snd_ac97 * ac97) | |||
3456 | /* bring analog power consumption to normal by turning off the | 3457 | /* bring analog power consumption to normal by turning off the |
3457 | * headphone amplifier, like WinXP driver for EPIA SP | 3458 | * headphone amplifier, like WinXP driver for EPIA SP |
3458 | */ | 3459 | */ |
3459 | snd_ac97_write_cache(ac97, 0x5c, 0x20); | 3460 | /* We need to check the bit before writing it. |
3461 | * On some (many?) hardwares, setting bit actually clears it! | ||
3462 | */ | ||
3463 | val = snd_ac97_read(ac97, 0x5c); | ||
3464 | if (!(val & 0x20)) | ||
3465 | snd_ac97_write_cache(ac97, 0x5c, 0x20); | ||
3466 | |||
3460 | ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ | 3467 | ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ |
3461 | ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; | 3468 | ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; |
3462 | ac97->build_ops = &patch_vt1616_ops; | 3469 | ac97->build_ops = &patch_vt1616_ops; |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index d9783a4263e0..6d4df45e81e0 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -11902,7 +11902,10 @@ static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, | |||
11902 | hda_nid_t nid, | 11902 | hda_nid_t nid, |
11903 | int pin_type, int dac_idx) | 11903 | int pin_type, int dac_idx) |
11904 | { | 11904 | { |
11905 | alc_set_pin_output(codec, nid, pin_type); | 11905 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
11906 | pin_type); | ||
11907 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
11908 | AMP_OUT_UNMUTE); | ||
11906 | } | 11909 | } |
11907 | 11910 | ||
11908 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | 11911 | static void alc861_auto_init_multi_out(struct hda_codec *codec) |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index b3a15d616873..393f7fd2b1be 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -4289,6 +4289,8 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = { | |||
4289 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, | 4289 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
4290 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, | 4290 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
4291 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, | 4291 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
4292 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, | ||
4293 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, | ||
4292 | /* The following does not take into account .id=0x83847661 when subsys = | 4294 | /* The following does not take into account .id=0x83847661 when subsys = |
4293 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are | 4295 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
4294 | * currently not fully supported. | 4296 | * currently not fully supported. |
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index 4ebcd6a8bf28..1ed6afd45459 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c | |||
@@ -224,6 +224,7 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_cpu_dai *cpu_dai, | |||
224 | iismod |= S3C2410_IISMOD_SLAVE; | 224 | iismod |= S3C2410_IISMOD_SLAVE; |
225 | break; | 225 | break; |
226 | case SND_SOC_DAIFMT_CBS_CFS: | 226 | case SND_SOC_DAIFMT_CBS_CFS: |
227 | iismod &= ~S3C2410_IISMOD_SLAVE; | ||
227 | break; | 228 | break; |
228 | default: | 229 | default: |
229 | return -EINVAL; | 230 | return -EINVAL; |
@@ -234,6 +235,7 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_cpu_dai *cpu_dai, | |||
234 | iismod |= S3C2410_IISMOD_MSB; | 235 | iismod |= S3C2410_IISMOD_MSB; |
235 | break; | 236 | break; |
236 | case SND_SOC_DAIFMT_I2S: | 237 | case SND_SOC_DAIFMT_I2S: |
238 | iismod &= ~S3C2410_IISMOD_MSB; | ||
237 | break; | 239 | break; |
238 | default: | 240 | default: |
239 | return -EINVAL; | 241 | return -EINVAL; |
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c index 6c70a81c730c..7806ae614617 100644 --- a/sound/soc/s3c24xx/s3c24xx-pcm.c +++ b/sound/soc/s3c24xx/s3c24xx-pcm.c | |||
@@ -171,7 +171,7 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream, | |||
171 | ret = s3c2410_dma_request(prtd->params->channel, | 171 | ret = s3c2410_dma_request(prtd->params->channel, |
172 | prtd->params->client, NULL); | 172 | prtd->params->client, NULL); |
173 | 173 | ||
174 | if (ret) { | 174 | if (ret < 0) { |
175 | DBG(KERN_ERR "failed to get dma channel\n"); | 175 | DBG(KERN_ERR "failed to get dma channel\n"); |
176 | return ret; | 176 | return ret; |
177 | } | 177 | } |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c82cf15730a1..f7ba099049ea 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -522,6 +522,7 @@ unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn) | |||
522 | return bad_hva(); | 522 | return bad_hva(); |
523 | return (slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE); | 523 | return (slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE); |
524 | } | 524 | } |
525 | EXPORT_SYMBOL_GPL(gfn_to_hva); | ||
525 | 526 | ||
526 | /* | 527 | /* |
527 | * Requires current->mm->mmap_sem to be held | 528 | * Requires current->mm->mmap_sem to be held |
@@ -834,16 +835,9 @@ static const struct file_operations kvm_vcpu_fops = { | |||
834 | */ | 835 | */ |
835 | static int create_vcpu_fd(struct kvm_vcpu *vcpu) | 836 | static int create_vcpu_fd(struct kvm_vcpu *vcpu) |
836 | { | 837 | { |
837 | int fd, r; | 838 | int fd = anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu); |
838 | struct inode *inode; | 839 | if (fd < 0) |
839 | struct file *file; | ||
840 | |||
841 | r = anon_inode_getfd(&fd, &inode, &file, | ||
842 | "kvm-vcpu", &kvm_vcpu_fops, vcpu); | ||
843 | if (r) { | ||
844 | kvm_put_kvm(vcpu->kvm); | 840 | kvm_put_kvm(vcpu->kvm); |
845 | return r; | ||
846 | } | ||
847 | return fd; | 841 | return fd; |
848 | } | 842 | } |
849 | 843 | ||
@@ -1168,19 +1162,15 @@ static const struct file_operations kvm_vm_fops = { | |||
1168 | 1162 | ||
1169 | static int kvm_dev_ioctl_create_vm(void) | 1163 | static int kvm_dev_ioctl_create_vm(void) |
1170 | { | 1164 | { |
1171 | int fd, r; | 1165 | int fd; |
1172 | struct inode *inode; | ||
1173 | struct file *file; | ||
1174 | struct kvm *kvm; | 1166 | struct kvm *kvm; |
1175 | 1167 | ||
1176 | kvm = kvm_create_vm(); | 1168 | kvm = kvm_create_vm(); |
1177 | if (IS_ERR(kvm)) | 1169 | if (IS_ERR(kvm)) |
1178 | return PTR_ERR(kvm); | 1170 | return PTR_ERR(kvm); |
1179 | r = anon_inode_getfd(&fd, &inode, &file, "kvm-vm", &kvm_vm_fops, kvm); | 1171 | fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm); |
1180 | if (r) { | 1172 | if (fd < 0) |
1181 | kvm_put_kvm(kvm); | 1173 | kvm_put_kvm(kvm); |
1182 | return r; | ||
1183 | } | ||
1184 | 1174 | ||
1185 | return fd; | 1175 | return fd; |
1186 | } | 1176 | } |