diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-04-30 03:56:41 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-04-30 03:56:44 -0400 |
commit | 3ca50496c2677a2b3fdd3ede86660fd1433beac6 (patch) | |
tree | 97a76d8479a8d8a96e04ed0694b8dbf89457bfcc /drivers | |
parent | 462b04e28a7ec1339c892117c3f20a40e55d0e83 (diff) | |
parent | 66f41d4c5c8a5deed66fdcc84509376c9a0bf9d8 (diff) |
Merge commit 'v2.6.34-rc6' into perf/core
Merge reason: update to the latest -rc.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers')
83 files changed, 3258 insertions, 387 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 67e0fc542249..93d1f9b469d4 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -1695,6 +1695,7 @@ int drbd_send_protocol(struct drbd_conf *mdev) | |||
1695 | cf |= CF_DRY_RUN; | 1695 | cf |= CF_DRY_RUN; |
1696 | else { | 1696 | else { |
1697 | dev_err(DEV, "--dry-run is not supported by peer"); | 1697 | dev_err(DEV, "--dry-run is not supported by peer"); |
1698 | kfree(p); | ||
1698 | return 0; | 1699 | return 0; |
1699 | } | 1700 | } |
1700 | } | 1701 | } |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index ed9f1de24a71..3f096e7959b4 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -899,7 +899,8 @@ retry: | |||
899 | 899 | ||
900 | drbd_thread_start(&mdev->asender); | 900 | drbd_thread_start(&mdev->asender); |
901 | 901 | ||
902 | drbd_send_protocol(mdev); | 902 | if (!drbd_send_protocol(mdev)) |
903 | return -1; | ||
903 | drbd_send_sync_param(mdev, &mdev->sync_conf); | 904 | drbd_send_sync_param(mdev, &mdev->sync_conf); |
904 | drbd_send_sizes(mdev, 0); | 905 | drbd_send_sizes(mdev, 0); |
905 | drbd_send_uuids(mdev); | 906 | drbd_send_uuids(mdev); |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index ddf19425245d..8a549db2aa78 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/module.h> | 48 | #include <linux/module.h> |
49 | #include <linux/types.h> | 49 | #include <linux/types.h> |
50 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
51 | #include <linux/compat.h> | ||
51 | #include <linux/kthread.h> | 52 | #include <linux/kthread.h> |
52 | #include <linux/errno.h> | 53 | #include <linux/errno.h> |
53 | #include <linux/spinlock.h> | 54 | #include <linux/spinlock.h> |
@@ -2984,7 +2985,7 @@ static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd) | |||
2984 | mutex_unlock(&ctl_mutex); | 2985 | mutex_unlock(&ctl_mutex); |
2985 | } | 2986 | } |
2986 | 2987 | ||
2987 | static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 2988 | static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
2988 | { | 2989 | { |
2989 | void __user *argp = (void __user *)arg; | 2990 | void __user *argp = (void __user *)arg; |
2990 | struct pkt_ctrl_command ctrl_cmd; | 2991 | struct pkt_ctrl_command ctrl_cmd; |
@@ -3021,10 +3022,20 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm | |||
3021 | return ret; | 3022 | return ret; |
3022 | } | 3023 | } |
3023 | 3024 | ||
3025 | #ifdef CONFIG_COMPAT | ||
3026 | static long pkt_ctl_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
3027 | { | ||
3028 | return pkt_ctl_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); | ||
3029 | } | ||
3030 | #endif | ||
3024 | 3031 | ||
3025 | static const struct file_operations pkt_ctl_fops = { | 3032 | static const struct file_operations pkt_ctl_fops = { |
3026 | .ioctl = pkt_ctl_ioctl, | 3033 | .open = nonseekable_open, |
3027 | .owner = THIS_MODULE, | 3034 | .unlocked_ioctl = pkt_ctl_ioctl, |
3035 | #ifdef CONFIG_COMPAT | ||
3036 | .compat_ioctl = pkt_ctl_compat_ioctl, | ||
3037 | #endif | ||
3038 | .owner = THIS_MODULE, | ||
3028 | }; | 3039 | }; |
3029 | 3040 | ||
3030 | static struct miscdevice pkt_misc = { | 3041 | static struct miscdevice pkt_misc = { |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 2d5d575e889d..75d293eeb3ee 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1113,6 +1113,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1113 | unsigned int cpu = sys_dev->id; | 1113 | unsigned int cpu = sys_dev->id; |
1114 | unsigned long flags; | 1114 | unsigned long flags; |
1115 | struct cpufreq_policy *data; | 1115 | struct cpufreq_policy *data; |
1116 | struct kobject *kobj; | ||
1117 | struct completion *cmp; | ||
1116 | #ifdef CONFIG_SMP | 1118 | #ifdef CONFIG_SMP |
1117 | struct sys_device *cpu_sys_dev; | 1119 | struct sys_device *cpu_sys_dev; |
1118 | unsigned int j; | 1120 | unsigned int j; |
@@ -1141,10 +1143,11 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1141 | dprintk("removing link\n"); | 1143 | dprintk("removing link\n"); |
1142 | cpumask_clear_cpu(cpu, data->cpus); | 1144 | cpumask_clear_cpu(cpu, data->cpus); |
1143 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1145 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1144 | sysfs_remove_link(&sys_dev->kobj, "cpufreq"); | 1146 | kobj = &sys_dev->kobj; |
1145 | cpufreq_cpu_put(data); | 1147 | cpufreq_cpu_put(data); |
1146 | cpufreq_debug_enable_ratelimit(); | 1148 | cpufreq_debug_enable_ratelimit(); |
1147 | unlock_policy_rwsem_write(cpu); | 1149 | unlock_policy_rwsem_write(cpu); |
1150 | sysfs_remove_link(kobj, "cpufreq"); | ||
1148 | return 0; | 1151 | return 0; |
1149 | } | 1152 | } |
1150 | #endif | 1153 | #endif |
@@ -1181,7 +1184,10 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1181 | data->governor->name, CPUFREQ_NAME_LEN); | 1184 | data->governor->name, CPUFREQ_NAME_LEN); |
1182 | #endif | 1185 | #endif |
1183 | cpu_sys_dev = get_cpu_sysdev(j); | 1186 | cpu_sys_dev = get_cpu_sysdev(j); |
1184 | sysfs_remove_link(&cpu_sys_dev->kobj, "cpufreq"); | 1187 | kobj = &cpu_sys_dev->kobj; |
1188 | unlock_policy_rwsem_write(cpu); | ||
1189 | sysfs_remove_link(kobj, "cpufreq"); | ||
1190 | lock_policy_rwsem_write(cpu); | ||
1185 | cpufreq_cpu_put(data); | 1191 | cpufreq_cpu_put(data); |
1186 | } | 1192 | } |
1187 | } | 1193 | } |
@@ -1192,19 +1198,22 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1192 | if (cpufreq_driver->target) | 1198 | if (cpufreq_driver->target) |
1193 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 1199 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); |
1194 | 1200 | ||
1195 | kobject_put(&data->kobj); | 1201 | kobj = &data->kobj; |
1202 | cmp = &data->kobj_unregister; | ||
1203 | unlock_policy_rwsem_write(cpu); | ||
1204 | kobject_put(kobj); | ||
1196 | 1205 | ||
1197 | /* we need to make sure that the underlying kobj is actually | 1206 | /* we need to make sure that the underlying kobj is actually |
1198 | * not referenced anymore by anybody before we proceed with | 1207 | * not referenced anymore by anybody before we proceed with |
1199 | * unloading. | 1208 | * unloading. |
1200 | */ | 1209 | */ |
1201 | dprintk("waiting for dropping of refcount\n"); | 1210 | dprintk("waiting for dropping of refcount\n"); |
1202 | wait_for_completion(&data->kobj_unregister); | 1211 | wait_for_completion(cmp); |
1203 | dprintk("wait complete\n"); | 1212 | dprintk("wait complete\n"); |
1204 | 1213 | ||
1214 | lock_policy_rwsem_write(cpu); | ||
1205 | if (cpufreq_driver->exit) | 1215 | if (cpufreq_driver->exit) |
1206 | cpufreq_driver->exit(data); | 1216 | cpufreq_driver->exit(data); |
1207 | |||
1208 | unlock_policy_rwsem_write(cpu); | 1217 | unlock_policy_rwsem_write(cpu); |
1209 | 1218 | ||
1210 | free_cpumask_var(data->related_cpus); | 1219 | free_cpumask_var(data->related_cpus); |
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 599a40b25cb0..3a147874a465 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -444,6 +444,7 @@ static struct attribute_group dbs_attr_group_old = { | |||
444 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | 444 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) |
445 | { | 445 | { |
446 | unsigned int load = 0; | 446 | unsigned int load = 0; |
447 | unsigned int max_load = 0; | ||
447 | unsigned int freq_target; | 448 | unsigned int freq_target; |
448 | 449 | ||
449 | struct cpufreq_policy *policy; | 450 | struct cpufreq_policy *policy; |
@@ -501,6 +502,9 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
501 | continue; | 502 | continue; |
502 | 503 | ||
503 | load = 100 * (wall_time - idle_time) / wall_time; | 504 | load = 100 * (wall_time - idle_time) / wall_time; |
505 | |||
506 | if (load > max_load) | ||
507 | max_load = load; | ||
504 | } | 508 | } |
505 | 509 | ||
506 | /* | 510 | /* |
@@ -511,7 +515,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
511 | return; | 515 | return; |
512 | 516 | ||
513 | /* Check for frequency increase */ | 517 | /* Check for frequency increase */ |
514 | if (load > dbs_tuners_ins.up_threshold) { | 518 | if (max_load > dbs_tuners_ins.up_threshold) { |
515 | this_dbs_info->down_skip = 0; | 519 | this_dbs_info->down_skip = 0; |
516 | 520 | ||
517 | /* if we are already at full speed then break out early */ | 521 | /* if we are already at full speed then break out early */ |
@@ -538,7 +542,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
538 | * can support the current CPU usage without triggering the up | 542 | * can support the current CPU usage without triggering the up |
539 | * policy. To be safe, we focus 10 points under the threshold. | 543 | * policy. To be safe, we focus 10 points under the threshold. |
540 | */ | 544 | */ |
541 | if (load < (dbs_tuners_ins.down_threshold - 10)) { | 545 | if (max_load < (dbs_tuners_ins.down_threshold - 10)) { |
542 | freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100; | 546 | freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100; |
543 | 547 | ||
544 | this_dbs_info->requested_freq -= freq_target; | 548 | this_dbs_info->requested_freq -= freq_target; |
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c index 7d521e1d17e1..b827c976dc62 100644 --- a/drivers/gpio/pca953x.c +++ b/drivers/gpio/pca953x.c | |||
@@ -252,6 +252,18 @@ static void pca953x_irq_bus_lock(unsigned int irq) | |||
252 | static void pca953x_irq_bus_sync_unlock(unsigned int irq) | 252 | static void pca953x_irq_bus_sync_unlock(unsigned int irq) |
253 | { | 253 | { |
254 | struct pca953x_chip *chip = get_irq_chip_data(irq); | 254 | struct pca953x_chip *chip = get_irq_chip_data(irq); |
255 | uint16_t new_irqs; | ||
256 | uint16_t level; | ||
257 | |||
258 | /* Look for any newly setup interrupt */ | ||
259 | new_irqs = chip->irq_trig_fall | chip->irq_trig_raise; | ||
260 | new_irqs &= ~chip->reg_direction; | ||
261 | |||
262 | while (new_irqs) { | ||
263 | level = __ffs(new_irqs); | ||
264 | pca953x_gpio_direction_input(&chip->gpio_chip, level); | ||
265 | new_irqs &= ~(1 << level); | ||
266 | } | ||
255 | 267 | ||
256 | mutex_unlock(&chip->irq_lock); | 268 | mutex_unlock(&chip->irq_lock); |
257 | } | 269 | } |
@@ -278,7 +290,7 @@ static int pca953x_irq_set_type(unsigned int irq, unsigned int type) | |||
278 | else | 290 | else |
279 | chip->irq_trig_raise &= ~mask; | 291 | chip->irq_trig_raise &= ~mask; |
280 | 292 | ||
281 | return pca953x_gpio_direction_input(&chip->gpio_chip, level); | 293 | return 0; |
282 | } | 294 | } |
283 | 295 | ||
284 | static struct irq_chip pca953x_irq_chip = { | 296 | static struct irq_chip pca953x_irq_chip = { |
diff --git a/drivers/gpio/pl061.c b/drivers/gpio/pl061.c index 5ad8f778ced4..105701a1f05b 100644 --- a/drivers/gpio/pl061.c +++ b/drivers/gpio/pl061.c | |||
@@ -91,6 +91,12 @@ static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, | |||
91 | gpiodir = readb(chip->base + GPIODIR); | 91 | gpiodir = readb(chip->base + GPIODIR); |
92 | gpiodir |= 1 << offset; | 92 | gpiodir |= 1 << offset; |
93 | writeb(gpiodir, chip->base + GPIODIR); | 93 | writeb(gpiodir, chip->base + GPIODIR); |
94 | |||
95 | /* | ||
96 | * gpio value is set again, because pl061 doesn't allow to set value of | ||
97 | * a gpio pin before configuring it in OUT mode. | ||
98 | */ | ||
99 | writeb(!!value << offset, chip->base + (1 << (offset + 2))); | ||
94 | spin_unlock_irqrestore(&chip->lock, flags); | 100 | spin_unlock_irqrestore(&chip->lock, flags); |
95 | 101 | ||
96 | return 0; | 102 | return 0; |
@@ -183,7 +189,7 @@ static int pl061_irq_type(unsigned irq, unsigned trigger) | |||
183 | gpioibe &= ~(1 << offset); | 189 | gpioibe &= ~(1 << offset); |
184 | if (trigger & IRQ_TYPE_EDGE_RISING) | 190 | if (trigger & IRQ_TYPE_EDGE_RISING) |
185 | gpioiev |= 1 << offset; | 191 | gpioiev |= 1 << offset; |
186 | else | 192 | else if (trigger & IRQ_TYPE_EDGE_FALLING) |
187 | gpioiev &= ~(1 << offset); | 193 | gpioiev &= ~(1 << offset); |
188 | } | 194 | } |
189 | writeb(gpioibe, chip->base + GPIOIBE); | 195 | writeb(gpioibe, chip->base + GPIOIBE); |
@@ -204,7 +210,7 @@ static struct irq_chip pl061_irqchip = { | |||
204 | 210 | ||
205 | static void pl061_irq_handler(unsigned irq, struct irq_desc *desc) | 211 | static void pl061_irq_handler(unsigned irq, struct irq_desc *desc) |
206 | { | 212 | { |
207 | struct list_head *chip_list = get_irq_chip_data(irq); | 213 | struct list_head *chip_list = get_irq_data(irq); |
208 | struct list_head *ptr; | 214 | struct list_head *ptr; |
209 | struct pl061_gpio *chip; | 215 | struct pl061_gpio *chip; |
210 | 216 | ||
@@ -297,9 +303,9 @@ static int __init pl061_probe(struct amba_device *dev, struct amba_id *id) | |||
297 | goto iounmap; | 303 | goto iounmap; |
298 | } | 304 | } |
299 | INIT_LIST_HEAD(chip_list); | 305 | INIT_LIST_HEAD(chip_list); |
300 | set_irq_chip_data(irq, chip_list); | 306 | set_irq_data(irq, chip_list); |
301 | } else | 307 | } else |
302 | chip_list = get_irq_chip_data(irq); | 308 | chip_list = get_irq_data(irq); |
303 | list_add(&chip->list, chip_list); | 309 | list_add(&chip->list, chip_list); |
304 | 310 | ||
305 | for (i = 0; i < PL061_GPIO_NR; i++) { | 311 | for (i = 0; i < PL061_GPIO_NR; i++) { |
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 3bd872761567..a263b7070fc6 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c | |||
@@ -476,6 +476,7 @@ void drm_vblank_off(struct drm_device *dev, int crtc) | |||
476 | unsigned long irqflags; | 476 | unsigned long irqflags; |
477 | 477 | ||
478 | spin_lock_irqsave(&dev->vbl_lock, irqflags); | 478 | spin_lock_irqsave(&dev->vbl_lock, irqflags); |
479 | dev->driver->disable_vblank(dev, crtc); | ||
479 | DRM_WAKEUP(&dev->vbl_queue[crtc]); | 480 | DRM_WAKEUP(&dev->vbl_queue[crtc]); |
480 | dev->vblank_enabled[crtc] = 0; | 481 | dev->vblank_enabled[crtc] = 0; |
481 | dev->last_vblank[crtc] = dev->driver->get_vblank_counter(dev, crtc); | 482 | dev->last_vblank[crtc] = dev->driver->get_vblank_counter(dev, crtc); |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 7f52cc124cfe..ef3d91dda71a 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -1793,7 +1793,7 @@ i915_get_gem_seqno(struct drm_device *dev) | |||
1793 | { | 1793 | { |
1794 | drm_i915_private_t *dev_priv = dev->dev_private; | 1794 | drm_i915_private_t *dev_priv = dev->dev_private; |
1795 | 1795 | ||
1796 | if (IS_I965G(dev)) | 1796 | if (HAS_PIPE_CONTROL(dev)) |
1797 | return ((volatile u32 *)(dev_priv->seqno_page))[0]; | 1797 | return ((volatile u32 *)(dev_priv->seqno_page))[0]; |
1798 | else | 1798 | else |
1799 | return READ_HWSP(dev_priv, I915_GEM_HWS_INDEX); | 1799 | return READ_HWSP(dev_priv, I915_GEM_HWS_INDEX); |
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c index bd75f99bd65e..eaf1f6bc44f1 100644 --- a/drivers/gpu/drm/radeon/r300.c +++ b/drivers/gpu/drm/radeon/r300.c | |||
@@ -324,13 +324,12 @@ void r300_gpu_init(struct radeon_device *rdev) | |||
324 | uint32_t gb_tile_config, tmp; | 324 | uint32_t gb_tile_config, tmp; |
325 | 325 | ||
326 | r100_hdp_reset(rdev); | 326 | r100_hdp_reset(rdev); |
327 | /* FIXME: rv380 one pipes ? */ | ||
328 | if ((rdev->family == CHIP_R300 && rdev->pdev->device != 0x4144) || | 327 | if ((rdev->family == CHIP_R300 && rdev->pdev->device != 0x4144) || |
329 | (rdev->family == CHIP_R350)) { | 328 | (rdev->family == CHIP_R350 && rdev->pdev->device != 0x4148)) { |
330 | /* r300,r350 */ | 329 | /* r300,r350 */ |
331 | rdev->num_gb_pipes = 2; | 330 | rdev->num_gb_pipes = 2; |
332 | } else { | 331 | } else { |
333 | /* rv350,rv370,rv380,r300 AD */ | 332 | /* rv350,rv370,rv380,r300 AD, r350 AH */ |
334 | rdev->num_gb_pipes = 1; | 333 | rdev->num_gb_pipes = 1; |
335 | } | 334 | } |
336 | rdev->num_z_pipes = 1; | 335 | rdev->num_z_pipes = 1; |
diff --git a/drivers/gpu/drm/radeon/r300_cmdbuf.c b/drivers/gpu/drm/radeon/r300_cmdbuf.c index ea46d558e8f3..c5c2742e4140 100644 --- a/drivers/gpu/drm/radeon/r300_cmdbuf.c +++ b/drivers/gpu/drm/radeon/r300_cmdbuf.c | |||
@@ -921,7 +921,7 @@ static int r300_scratch(drm_radeon_private_t *dev_priv, | |||
921 | 921 | ||
922 | ptr_addr = drm_buffer_read_object(cmdbuf->buffer, | 922 | ptr_addr = drm_buffer_read_object(cmdbuf->buffer, |
923 | sizeof(stack_ptr_addr), &stack_ptr_addr); | 923 | sizeof(stack_ptr_addr), &stack_ptr_addr); |
924 | ref_age_base = (u32 *)(unsigned long)*ptr_addr; | 924 | ref_age_base = (u32 *)(unsigned long)get_unaligned(ptr_addr); |
925 | 925 | ||
926 | for (i=0; i < header.scratch.n_bufs; i++) { | 926 | for (i=0; i < header.scratch.n_bufs; i++) { |
927 | buf_idx = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0); | 927 | buf_idx = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0); |
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c index 3dc968c9f5a4..c2bda4ad62e7 100644 --- a/drivers/gpu/drm/radeon/r420.c +++ b/drivers/gpu/drm/radeon/r420.c | |||
@@ -59,6 +59,12 @@ void r420_pipes_init(struct radeon_device *rdev) | |||
59 | /* get max number of pipes */ | 59 | /* get max number of pipes */ |
60 | gb_pipe_select = RREG32(0x402C); | 60 | gb_pipe_select = RREG32(0x402C); |
61 | num_pipes = ((gb_pipe_select >> 12) & 3) + 1; | 61 | num_pipes = ((gb_pipe_select >> 12) & 3) + 1; |
62 | |||
63 | /* SE chips have 1 pipe */ | ||
64 | if ((rdev->pdev->device == 0x5e4c) || | ||
65 | (rdev->pdev->device == 0x5e4f)) | ||
66 | num_pipes = 1; | ||
67 | |||
62 | rdev->num_gb_pipes = num_pipes; | 68 | rdev->num_gb_pipes = num_pipes; |
63 | tmp = 0; | 69 | tmp = 0; |
64 | switch (num_pipes) { | 70 | switch (num_pipes) { |
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c index 419630dd2075..2f042a3c0e62 100644 --- a/drivers/gpu/drm/radeon/radeon_cp.c +++ b/drivers/gpu/drm/radeon/radeon_cp.c | |||
@@ -435,14 +435,19 @@ static void radeon_init_pipes(struct drm_device *dev) | |||
435 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R420) { | 435 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R420) { |
436 | gb_pipe_sel = RADEON_READ(R400_GB_PIPE_SELECT); | 436 | gb_pipe_sel = RADEON_READ(R400_GB_PIPE_SELECT); |
437 | dev_priv->num_gb_pipes = ((gb_pipe_sel >> 12) & 0x3) + 1; | 437 | dev_priv->num_gb_pipes = ((gb_pipe_sel >> 12) & 0x3) + 1; |
438 | /* SE cards have 1 pipe */ | ||
439 | if ((dev->pdev->device == 0x5e4c) || | ||
440 | (dev->pdev->device == 0x5e4f)) | ||
441 | dev_priv->num_gb_pipes = 1; | ||
438 | } else { | 442 | } else { |
439 | /* R3xx */ | 443 | /* R3xx */ |
440 | if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R300 && | 444 | if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R300 && |
441 | dev->pdev->device != 0x4144) || | 445 | dev->pdev->device != 0x4144) || |
442 | ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R350)) { | 446 | ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R350 && |
447 | dev->pdev->device != 0x4148)) { | ||
443 | dev_priv->num_gb_pipes = 2; | 448 | dev_priv->num_gb_pipes = 2; |
444 | } else { | 449 | } else { |
445 | /* RV3xx/R300 AD */ | 450 | /* RV3xx/R300 AD/R350 AH */ |
446 | dev_priv->num_gb_pipes = 1; | 451 | dev_priv->num_gb_pipes = 1; |
447 | } | 452 | } |
448 | } | 453 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index b8d672828246..bb1c122cad21 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c | |||
@@ -86,12 +86,12 @@ static void evergreen_crtc_load_lut(struct drm_crtc *crtc) | |||
86 | WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_GREEN + radeon_crtc->crtc_offset, 0xffff); | 86 | WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_GREEN + radeon_crtc->crtc_offset, 0xffff); |
87 | WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_RED + radeon_crtc->crtc_offset, 0xffff); | 87 | WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_RED + radeon_crtc->crtc_offset, 0xffff); |
88 | 88 | ||
89 | WREG32(EVERGREEN_DC_LUT_RW_MODE, radeon_crtc->crtc_id); | 89 | WREG32(EVERGREEN_DC_LUT_RW_MODE + radeon_crtc->crtc_offset, 0); |
90 | WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK, 0x00000007); | 90 | WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + radeon_crtc->crtc_offset, 0x00000007); |
91 | 91 | ||
92 | WREG32(EVERGREEN_DC_LUT_RW_INDEX, 0); | 92 | WREG32(EVERGREEN_DC_LUT_RW_INDEX + radeon_crtc->crtc_offset, 0); |
93 | for (i = 0; i < 256; i++) { | 93 | for (i = 0; i < 256; i++) { |
94 | WREG32(EVERGREEN_DC_LUT_30_COLOR, | 94 | WREG32(EVERGREEN_DC_LUT_30_COLOR + radeon_crtc->crtc_offset, |
95 | (radeon_crtc->lut_r[i] << 20) | | 95 | (radeon_crtc->lut_r[i] << 20) | |
96 | (radeon_crtc->lut_g[i] << 10) | | 96 | (radeon_crtc->lut_g[i] << 10) | |
97 | (radeon_crtc->lut_b[i] << 0)); | 97 | (radeon_crtc->lut_b[i] << 0)); |
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c index 30293bec0801..fed7b8084779 100644 --- a/drivers/gpu/drm/radeon/radeon_encoders.c +++ b/drivers/gpu/drm/radeon/radeon_encoders.c | |||
@@ -1326,7 +1326,7 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder, | |||
1326 | 1326 | ||
1327 | radeon_encoder->pixel_clock = adjusted_mode->clock; | 1327 | radeon_encoder->pixel_clock = adjusted_mode->clock; |
1328 | 1328 | ||
1329 | if (ASIC_IS_AVIVO(rdev)) { | 1329 | if (ASIC_IS_AVIVO(rdev) && !ASIC_IS_DCE4(rdev)) { |
1330 | if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT | ATOM_DEVICE_TV_SUPPORT)) | 1330 | if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT | ATOM_DEVICE_TV_SUPPORT)) |
1331 | atombios_yuv_setup(encoder, true); | 1331 | atombios_yuv_setup(encoder, true); |
1332 | else | 1332 | else |
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index d3657dcfdd26..c633319f98ed 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -165,7 +165,7 @@ u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc) | |||
165 | { | 165 | { |
166 | struct radeon_device *rdev = dev->dev_private; | 166 | struct radeon_device *rdev = dev->dev_private; |
167 | 167 | ||
168 | if (crtc < 0 || crtc > 1) { | 168 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
169 | DRM_ERROR("Invalid crtc %d\n", crtc); | 169 | DRM_ERROR("Invalid crtc %d\n", crtc); |
170 | return -EINVAL; | 170 | return -EINVAL; |
171 | } | 171 | } |
@@ -177,7 +177,7 @@ int radeon_enable_vblank_kms(struct drm_device *dev, int crtc) | |||
177 | { | 177 | { |
178 | struct radeon_device *rdev = dev->dev_private; | 178 | struct radeon_device *rdev = dev->dev_private; |
179 | 179 | ||
180 | if (crtc < 0 || crtc > 1) { | 180 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
181 | DRM_ERROR("Invalid crtc %d\n", crtc); | 181 | DRM_ERROR("Invalid crtc %d\n", crtc); |
182 | return -EINVAL; | 182 | return -EINVAL; |
183 | } | 183 | } |
@@ -191,7 +191,7 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc) | |||
191 | { | 191 | { |
192 | struct radeon_device *rdev = dev->dev_private; | 192 | struct radeon_device *rdev = dev->dev_private; |
193 | 193 | ||
194 | if (crtc < 0 || crtc > 1) { | 194 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
195 | DRM_ERROR("Invalid crtc %d\n", crtc); | 195 | DRM_ERROR("Invalid crtc %d\n", crtc); |
196 | return; | 196 | return; |
197 | } | 197 | } |
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c index be475e844c2a..c8ab50516672 100644 --- a/drivers/hwmon/hp_accel.c +++ b/drivers/hwmon/hp_accel.c | |||
@@ -217,6 +217,10 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = { | |||
217 | AXIS_DMI_MATCH("DV7", "HP Pavilion dv7", x_inverted), | 217 | AXIS_DMI_MATCH("DV7", "HP Pavilion dv7", x_inverted), |
218 | AXIS_DMI_MATCH("HP8710", "HP Compaq 8710", y_inverted), | 218 | AXIS_DMI_MATCH("HP8710", "HP Compaq 8710", y_inverted), |
219 | AXIS_DMI_MATCH("HDX18", "HP HDX 18", x_inverted), | 219 | AXIS_DMI_MATCH("HDX18", "HP HDX 18", x_inverted), |
220 | AXIS_DMI_MATCH("HPB432x", "HP ProBook 432", xy_rotated_left), | ||
221 | AXIS_DMI_MATCH("HPB442x", "HP ProBook 442", xy_rotated_left), | ||
222 | AXIS_DMI_MATCH("HPB452x", "HP ProBook 452", y_inverted), | ||
223 | AXIS_DMI_MATCH("HPB522x", "HP ProBook 522", xy_swap), | ||
220 | { NULL, } | 224 | { NULL, } |
221 | /* Laptop models without axis info (yet): | 225 | /* Laptop models without axis info (yet): |
222 | * "NC6910" "HP Compaq 6910" | 226 | * "NC6910" "HP Compaq 6910" |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 2191c8d896a0..0d0d625fece2 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -311,6 +311,22 @@ config TI_DAC7512 | |||
311 | This driver can also be built as a module. If so, the module | 311 | This driver can also be built as a module. If so, the module |
312 | will be calles ti_dac7512. | 312 | will be calles ti_dac7512. |
313 | 313 | ||
314 | config VMWARE_BALLOON | ||
315 | tristate "VMware Balloon Driver" | ||
316 | depends on X86 | ||
317 | help | ||
318 | This is VMware physical memory management driver which acts | ||
319 | like a "balloon" that can be inflated to reclaim physical pages | ||
320 | by reserving them in the guest and invalidating them in the | ||
321 | monitor, freeing up the underlying machine pages so they can | ||
322 | be allocated to other guests. The balloon can also be deflated | ||
323 | to allow the guest to use more physical memory. | ||
324 | |||
325 | If unsure, say N. | ||
326 | |||
327 | To compile this driver as a module, choose M here: the | ||
328 | module will be called vmware_balloon. | ||
329 | |||
314 | source "drivers/misc/c2port/Kconfig" | 330 | source "drivers/misc/c2port/Kconfig" |
315 | source "drivers/misc/eeprom/Kconfig" | 331 | source "drivers/misc/eeprom/Kconfig" |
316 | source "drivers/misc/cb710/Kconfig" | 332 | source "drivers/misc/cb710/Kconfig" |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 27c484355414..7b6f7eefdf8d 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -29,3 +29,4 @@ obj-$(CONFIG_C2PORT) += c2port/ | |||
29 | obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/ | 29 | obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/ |
30 | obj-y += eeprom/ | 30 | obj-y += eeprom/ |
31 | obj-y += cb710/ | 31 | obj-y += cb710/ |
32 | obj-$(CONFIG_VMWARE_BALLOON) += vmware_balloon.o | ||
diff --git a/drivers/misc/vmware_balloon.c b/drivers/misc/vmware_balloon.c new file mode 100644 index 000000000000..e7161c4e3798 --- /dev/null +++ b/drivers/misc/vmware_balloon.c | |||
@@ -0,0 +1,832 @@ | |||
1 | /* | ||
2 | * VMware Balloon driver. | ||
3 | * | ||
4 | * Copyright (C) 2000-2010, VMware, Inc. All Rights Reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; version 2 of the License and no later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
13 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
14 | * 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 St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | * | ||
20 | * Maintained by: Dmitry Torokhov <dtor@vmware.com> | ||
21 | */ | ||
22 | |||
23 | /* | ||
24 | * This is VMware physical memory management driver for Linux. The driver | ||
25 | * acts like a "balloon" that can be inflated to reclaim physical pages by | ||
26 | * reserving them in the guest and invalidating them in the monitor, | ||
27 | * freeing up the underlying machine pages so they can be allocated to | ||
28 | * other guests. The balloon can also be deflated to allow the guest to | ||
29 | * use more physical memory. Higher level policies can control the sizes | ||
30 | * of balloons in VMs in order to manage physical memory resources. | ||
31 | */ | ||
32 | |||
33 | //#define DEBUG | ||
34 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
35 | |||
36 | #include <linux/types.h> | ||
37 | #include <linux/kernel.h> | ||
38 | #include <linux/mm.h> | ||
39 | #include <linux/sched.h> | ||
40 | #include <linux/module.h> | ||
41 | #include <linux/workqueue.h> | ||
42 | #include <linux/debugfs.h> | ||
43 | #include <linux/seq_file.h> | ||
44 | #include <asm/vmware.h> | ||
45 | |||
46 | MODULE_AUTHOR("VMware, Inc."); | ||
47 | MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver"); | ||
48 | MODULE_VERSION("1.2.1.0-K"); | ||
49 | MODULE_ALIAS("dmi:*:svnVMware*:*"); | ||
50 | MODULE_ALIAS("vmware_vmmemctl"); | ||
51 | MODULE_LICENSE("GPL"); | ||
52 | |||
53 | /* | ||
54 | * Various constants controlling rate of inflaint/deflating balloon, | ||
55 | * measured in pages. | ||
56 | */ | ||
57 | |||
58 | /* | ||
59 | * Rate of allocating memory when there is no memory pressure | ||
60 | * (driver performs non-sleeping allocations). | ||
61 | */ | ||
62 | #define VMW_BALLOON_NOSLEEP_ALLOC_MAX 16384U | ||
63 | |||
64 | /* | ||
65 | * Rates of memory allocaton when guest experiences memory pressure | ||
66 | * (driver performs sleeping allocations). | ||
67 | */ | ||
68 | #define VMW_BALLOON_RATE_ALLOC_MIN 512U | ||
69 | #define VMW_BALLOON_RATE_ALLOC_MAX 2048U | ||
70 | #define VMW_BALLOON_RATE_ALLOC_INC 16U | ||
71 | |||
72 | /* | ||
73 | * Rates for releasing pages while deflating balloon. | ||
74 | */ | ||
75 | #define VMW_BALLOON_RATE_FREE_MIN 512U | ||
76 | #define VMW_BALLOON_RATE_FREE_MAX 16384U | ||
77 | #define VMW_BALLOON_RATE_FREE_INC 16U | ||
78 | |||
79 | /* | ||
80 | * When guest is under memory pressure, use a reduced page allocation | ||
81 | * rate for next several cycles. | ||
82 | */ | ||
83 | #define VMW_BALLOON_SLOW_CYCLES 4 | ||
84 | |||
85 | /* | ||
86 | * Use __GFP_HIGHMEM to allow pages from HIGHMEM zone. We don't | ||
87 | * allow wait (__GFP_WAIT) for NOSLEEP page allocations. Use | ||
88 | * __GFP_NOWARN, to suppress page allocation failure warnings. | ||
89 | */ | ||
90 | #define VMW_PAGE_ALLOC_NOSLEEP (__GFP_HIGHMEM|__GFP_NOWARN) | ||
91 | |||
92 | /* | ||
93 | * Use GFP_HIGHUSER when executing in a separate kernel thread | ||
94 | * context and allocation can sleep. This is less stressful to | ||
95 | * the guest memory system, since it allows the thread to block | ||
96 | * while memory is reclaimed, and won't take pages from emergency | ||
97 | * low-memory pools. | ||
98 | */ | ||
99 | #define VMW_PAGE_ALLOC_CANSLEEP (GFP_HIGHUSER) | ||
100 | |||
101 | /* Maximum number of page allocations without yielding processor */ | ||
102 | #define VMW_BALLOON_YIELD_THRESHOLD 1024 | ||
103 | |||
104 | |||
105 | /* | ||
106 | * Hypervisor communication port definitions. | ||
107 | */ | ||
108 | #define VMW_BALLOON_HV_PORT 0x5670 | ||
109 | #define VMW_BALLOON_HV_MAGIC 0x456c6d6f | ||
110 | #define VMW_BALLOON_PROTOCOL_VERSION 2 | ||
111 | #define VMW_BALLOON_GUEST_ID 1 /* Linux */ | ||
112 | |||
113 | #define VMW_BALLOON_CMD_START 0 | ||
114 | #define VMW_BALLOON_CMD_GET_TARGET 1 | ||
115 | #define VMW_BALLOON_CMD_LOCK 2 | ||
116 | #define VMW_BALLOON_CMD_UNLOCK 3 | ||
117 | #define VMW_BALLOON_CMD_GUEST_ID 4 | ||
118 | |||
119 | /* error codes */ | ||
120 | #define VMW_BALLOON_SUCCESS 0 | ||
121 | #define VMW_BALLOON_FAILURE -1 | ||
122 | #define VMW_BALLOON_ERROR_CMD_INVALID 1 | ||
123 | #define VMW_BALLOON_ERROR_PPN_INVALID 2 | ||
124 | #define VMW_BALLOON_ERROR_PPN_LOCKED 3 | ||
125 | #define VMW_BALLOON_ERROR_PPN_UNLOCKED 4 | ||
126 | #define VMW_BALLOON_ERROR_PPN_PINNED 5 | ||
127 | #define VMW_BALLOON_ERROR_PPN_NOTNEEDED 6 | ||
128 | #define VMW_BALLOON_ERROR_RESET 7 | ||
129 | #define VMW_BALLOON_ERROR_BUSY 8 | ||
130 | |||
131 | #define VMWARE_BALLOON_CMD(cmd, data, result) \ | ||
132 | ({ \ | ||
133 | unsigned long __stat, __dummy1, __dummy2; \ | ||
134 | __asm__ __volatile__ ("inl (%%dx)" : \ | ||
135 | "=a"(__stat), \ | ||
136 | "=c"(__dummy1), \ | ||
137 | "=d"(__dummy2), \ | ||
138 | "=b"(result) : \ | ||
139 | "0"(VMW_BALLOON_HV_MAGIC), \ | ||
140 | "1"(VMW_BALLOON_CMD_##cmd), \ | ||
141 | "2"(VMW_BALLOON_HV_PORT), \ | ||
142 | "3"(data) : \ | ||
143 | "memory"); \ | ||
144 | result &= -1UL; \ | ||
145 | __stat & -1UL; \ | ||
146 | }) | ||
147 | |||
148 | #ifdef CONFIG_DEBUG_FS | ||
149 | struct vmballoon_stats { | ||
150 | unsigned int timer; | ||
151 | |||
152 | /* allocation statustics */ | ||
153 | unsigned int alloc; | ||
154 | unsigned int alloc_fail; | ||
155 | unsigned int sleep_alloc; | ||
156 | unsigned int sleep_alloc_fail; | ||
157 | unsigned int refused_alloc; | ||
158 | unsigned int refused_free; | ||
159 | unsigned int free; | ||
160 | |||
161 | /* monitor operations */ | ||
162 | unsigned int lock; | ||
163 | unsigned int lock_fail; | ||
164 | unsigned int unlock; | ||
165 | unsigned int unlock_fail; | ||
166 | unsigned int target; | ||
167 | unsigned int target_fail; | ||
168 | unsigned int start; | ||
169 | unsigned int start_fail; | ||
170 | unsigned int guest_type; | ||
171 | unsigned int guest_type_fail; | ||
172 | }; | ||
173 | |||
174 | #define STATS_INC(stat) (stat)++ | ||
175 | #else | ||
176 | #define STATS_INC(stat) | ||
177 | #endif | ||
178 | |||
179 | struct vmballoon { | ||
180 | |||
181 | /* list of reserved physical pages */ | ||
182 | struct list_head pages; | ||
183 | |||
184 | /* transient list of non-balloonable pages */ | ||
185 | struct list_head refused_pages; | ||
186 | |||
187 | /* balloon size in pages */ | ||
188 | unsigned int size; | ||
189 | unsigned int target; | ||
190 | |||
191 | /* reset flag */ | ||
192 | bool reset_required; | ||
193 | |||
194 | /* adjustment rates (pages per second) */ | ||
195 | unsigned int rate_alloc; | ||
196 | unsigned int rate_free; | ||
197 | |||
198 | /* slowdown page allocations for next few cycles */ | ||
199 | unsigned int slow_allocation_cycles; | ||
200 | |||
201 | #ifdef CONFIG_DEBUG_FS | ||
202 | /* statistics */ | ||
203 | struct vmballoon_stats stats; | ||
204 | |||
205 | /* debugfs file exporting statistics */ | ||
206 | struct dentry *dbg_entry; | ||
207 | #endif | ||
208 | |||
209 | struct sysinfo sysinfo; | ||
210 | |||
211 | struct delayed_work dwork; | ||
212 | }; | ||
213 | |||
214 | static struct vmballoon balloon; | ||
215 | static struct workqueue_struct *vmballoon_wq; | ||
216 | |||
217 | /* | ||
218 | * Send "start" command to the host, communicating supported version | ||
219 | * of the protocol. | ||
220 | */ | ||
221 | static bool vmballoon_send_start(struct vmballoon *b) | ||
222 | { | ||
223 | unsigned long status, dummy; | ||
224 | |||
225 | STATS_INC(b->stats.start); | ||
226 | |||
227 | status = VMWARE_BALLOON_CMD(START, VMW_BALLOON_PROTOCOL_VERSION, dummy); | ||
228 | if (status == VMW_BALLOON_SUCCESS) | ||
229 | return true; | ||
230 | |||
231 | pr_debug("%s - failed, hv returns %ld\n", __func__, status); | ||
232 | STATS_INC(b->stats.start_fail); | ||
233 | return false; | ||
234 | } | ||
235 | |||
236 | static bool vmballoon_check_status(struct vmballoon *b, unsigned long status) | ||
237 | { | ||
238 | switch (status) { | ||
239 | case VMW_BALLOON_SUCCESS: | ||
240 | return true; | ||
241 | |||
242 | case VMW_BALLOON_ERROR_RESET: | ||
243 | b->reset_required = true; | ||
244 | /* fall through */ | ||
245 | |||
246 | default: | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | |||
251 | /* | ||
252 | * Communicate guest type to the host so that it can adjust ballooning | ||
253 | * algorithm to the one most appropriate for the guest. This command | ||
254 | * is normally issued after sending "start" command and is part of | ||
255 | * standard reset sequence. | ||
256 | */ | ||
257 | static bool vmballoon_send_guest_id(struct vmballoon *b) | ||
258 | { | ||
259 | unsigned long status, dummy; | ||
260 | |||
261 | status = VMWARE_BALLOON_CMD(GUEST_ID, VMW_BALLOON_GUEST_ID, dummy); | ||
262 | |||
263 | STATS_INC(b->stats.guest_type); | ||
264 | |||
265 | if (vmballoon_check_status(b, status)) | ||
266 | return true; | ||
267 | |||
268 | pr_debug("%s - failed, hv returns %ld\n", __func__, status); | ||
269 | STATS_INC(b->stats.guest_type_fail); | ||
270 | return false; | ||
271 | } | ||
272 | |||
273 | /* | ||
274 | * Retrieve desired balloon size from the host. | ||
275 | */ | ||
276 | static bool vmballoon_send_get_target(struct vmballoon *b, u32 *new_target) | ||
277 | { | ||
278 | unsigned long status; | ||
279 | unsigned long target; | ||
280 | unsigned long limit; | ||
281 | u32 limit32; | ||
282 | |||
283 | /* | ||
284 | * si_meminfo() is cheap. Moreover, we want to provide dynamic | ||
285 | * max balloon size later. So let us call si_meminfo() every | ||
286 | * iteration. | ||
287 | */ | ||
288 | si_meminfo(&b->sysinfo); | ||
289 | limit = b->sysinfo.totalram; | ||
290 | |||
291 | /* Ensure limit fits in 32-bits */ | ||
292 | limit32 = (u32)limit; | ||
293 | if (limit != limit32) | ||
294 | return false; | ||
295 | |||
296 | /* update stats */ | ||
297 | STATS_INC(b->stats.target); | ||
298 | |||
299 | status = VMWARE_BALLOON_CMD(GET_TARGET, limit, target); | ||
300 | if (vmballoon_check_status(b, status)) { | ||
301 | *new_target = target; | ||
302 | return true; | ||
303 | } | ||
304 | |||
305 | pr_debug("%s - failed, hv returns %ld\n", __func__, status); | ||
306 | STATS_INC(b->stats.target_fail); | ||
307 | return false; | ||
308 | } | ||
309 | |||
310 | /* | ||
311 | * Notify the host about allocated page so that host can use it without | ||
312 | * fear that guest will need it. Host may reject some pages, we need to | ||
313 | * check the return value and maybe submit a different page. | ||
314 | */ | ||
315 | static bool vmballoon_send_lock_page(struct vmballoon *b, unsigned long pfn) | ||
316 | { | ||
317 | unsigned long status, dummy; | ||
318 | u32 pfn32; | ||
319 | |||
320 | pfn32 = (u32)pfn; | ||
321 | if (pfn32 != pfn) | ||
322 | return false; | ||
323 | |||
324 | STATS_INC(b->stats.lock); | ||
325 | |||
326 | status = VMWARE_BALLOON_CMD(LOCK, pfn, dummy); | ||
327 | if (vmballoon_check_status(b, status)) | ||
328 | return true; | ||
329 | |||
330 | pr_debug("%s - ppn %lx, hv returns %ld\n", __func__, pfn, status); | ||
331 | STATS_INC(b->stats.lock_fail); | ||
332 | return false; | ||
333 | } | ||
334 | |||
335 | /* | ||
336 | * Notify the host that guest intends to release given page back into | ||
337 | * the pool of available (to the guest) pages. | ||
338 | */ | ||
339 | static bool vmballoon_send_unlock_page(struct vmballoon *b, unsigned long pfn) | ||
340 | { | ||
341 | unsigned long status, dummy; | ||
342 | u32 pfn32; | ||
343 | |||
344 | pfn32 = (u32)pfn; | ||
345 | if (pfn32 != pfn) | ||
346 | return false; | ||
347 | |||
348 | STATS_INC(b->stats.unlock); | ||
349 | |||
350 | status = VMWARE_BALLOON_CMD(UNLOCK, pfn, dummy); | ||
351 | if (vmballoon_check_status(b, status)) | ||
352 | return true; | ||
353 | |||
354 | pr_debug("%s - ppn %lx, hv returns %ld\n", __func__, pfn, status); | ||
355 | STATS_INC(b->stats.unlock_fail); | ||
356 | return false; | ||
357 | } | ||
358 | |||
359 | /* | ||
360 | * Quickly release all pages allocated for the balloon. This function is | ||
361 | * called when host decides to "reset" balloon for one reason or another. | ||
362 | * Unlike normal "deflate" we do not (shall not) notify host of the pages | ||
363 | * being released. | ||
364 | */ | ||
365 | static void vmballoon_pop(struct vmballoon *b) | ||
366 | { | ||
367 | struct page *page, *next; | ||
368 | unsigned int count = 0; | ||
369 | |||
370 | list_for_each_entry_safe(page, next, &b->pages, lru) { | ||
371 | list_del(&page->lru); | ||
372 | __free_page(page); | ||
373 | STATS_INC(b->stats.free); | ||
374 | b->size--; | ||
375 | |||
376 | if (++count >= b->rate_free) { | ||
377 | count = 0; | ||
378 | cond_resched(); | ||
379 | } | ||
380 | } | ||
381 | } | ||
382 | |||
383 | /* | ||
384 | * Perform standard reset sequence by popping the balloon (in case it | ||
385 | * is not empty) and then restarting protocol. This operation normally | ||
386 | * happens when host responds with VMW_BALLOON_ERROR_RESET to a command. | ||
387 | */ | ||
388 | static void vmballoon_reset(struct vmballoon *b) | ||
389 | { | ||
390 | /* free all pages, skipping monitor unlock */ | ||
391 | vmballoon_pop(b); | ||
392 | |||
393 | if (vmballoon_send_start(b)) { | ||
394 | b->reset_required = false; | ||
395 | if (!vmballoon_send_guest_id(b)) | ||
396 | pr_err("failed to send guest ID to the host\n"); | ||
397 | } | ||
398 | } | ||
399 | |||
400 | /* | ||
401 | * Allocate (or reserve) a page for the balloon and notify the host. If host | ||
402 | * refuses the page put it on "refuse" list and allocate another one until host | ||
403 | * is satisfied. "Refused" pages are released at the end of inflation cycle | ||
404 | * (when we allocate b->rate_alloc pages). | ||
405 | */ | ||
406 | static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep) | ||
407 | { | ||
408 | struct page *page; | ||
409 | gfp_t flags; | ||
410 | bool locked = false; | ||
411 | |||
412 | do { | ||
413 | if (!can_sleep) | ||
414 | STATS_INC(b->stats.alloc); | ||
415 | else | ||
416 | STATS_INC(b->stats.sleep_alloc); | ||
417 | |||
418 | flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP; | ||
419 | page = alloc_page(flags); | ||
420 | if (!page) { | ||
421 | if (!can_sleep) | ||
422 | STATS_INC(b->stats.alloc_fail); | ||
423 | else | ||
424 | STATS_INC(b->stats.sleep_alloc_fail); | ||
425 | return -ENOMEM; | ||
426 | } | ||
427 | |||
428 | /* inform monitor */ | ||
429 | locked = vmballoon_send_lock_page(b, page_to_pfn(page)); | ||
430 | if (!locked) { | ||
431 | if (b->reset_required) { | ||
432 | __free_page(page); | ||
433 | return -EIO; | ||
434 | } | ||
435 | |||
436 | /* place on list of non-balloonable pages, retry allocation */ | ||
437 | list_add(&page->lru, &b->refused_pages); | ||
438 | STATS_INC(b->stats.refused_alloc); | ||
439 | } | ||
440 | } while (!locked); | ||
441 | |||
442 | /* track allocated page */ | ||
443 | list_add(&page->lru, &b->pages); | ||
444 | |||
445 | /* update balloon size */ | ||
446 | b->size++; | ||
447 | |||
448 | return 0; | ||
449 | } | ||
450 | |||
451 | /* | ||
452 | * Release the page allocated for the balloon. Note that we first notify | ||
453 | * the host so it can make sure the page will be available for the guest | ||
454 | * to use, if needed. | ||
455 | */ | ||
456 | static int vmballoon_release_page(struct vmballoon *b, struct page *page) | ||
457 | { | ||
458 | if (!vmballoon_send_unlock_page(b, page_to_pfn(page))) | ||
459 | return -EIO; | ||
460 | |||
461 | list_del(&page->lru); | ||
462 | |||
463 | /* deallocate page */ | ||
464 | __free_page(page); | ||
465 | STATS_INC(b->stats.free); | ||
466 | |||
467 | /* update balloon size */ | ||
468 | b->size--; | ||
469 | |||
470 | return 0; | ||
471 | } | ||
472 | |||
473 | /* | ||
474 | * Release pages that were allocated while attempting to inflate the | ||
475 | * balloon but were refused by the host for one reason or another. | ||
476 | */ | ||
477 | static void vmballoon_release_refused_pages(struct vmballoon *b) | ||
478 | { | ||
479 | struct page *page, *next; | ||
480 | |||
481 | list_for_each_entry_safe(page, next, &b->refused_pages, lru) { | ||
482 | list_del(&page->lru); | ||
483 | __free_page(page); | ||
484 | STATS_INC(b->stats.refused_free); | ||
485 | } | ||
486 | } | ||
487 | |||
488 | /* | ||
489 | * Inflate the balloon towards its target size. Note that we try to limit | ||
490 | * the rate of allocation to make sure we are not choking the rest of the | ||
491 | * system. | ||
492 | */ | ||
493 | static void vmballoon_inflate(struct vmballoon *b) | ||
494 | { | ||
495 | unsigned int goal; | ||
496 | unsigned int rate; | ||
497 | unsigned int i; | ||
498 | unsigned int allocations = 0; | ||
499 | int error = 0; | ||
500 | bool alloc_can_sleep = false; | ||
501 | |||
502 | pr_debug("%s - size: %d, target %d\n", __func__, b->size, b->target); | ||
503 | |||
504 | /* | ||
505 | * First try NOSLEEP page allocations to inflate balloon. | ||
506 | * | ||
507 | * If we do not throttle nosleep allocations, we can drain all | ||
508 | * free pages in the guest quickly (if the balloon target is high). | ||
509 | * As a side-effect, draining free pages helps to inform (force) | ||
510 | * the guest to start swapping if balloon target is not met yet, | ||
511 | * which is a desired behavior. However, balloon driver can consume | ||
512 | * all available CPU cycles if too many pages are allocated in a | ||
513 | * second. Therefore, we throttle nosleep allocations even when | ||
514 | * the guest is not under memory pressure. OTOH, if we have already | ||
515 | * predicted that the guest is under memory pressure, then we | ||
516 | * slowdown page allocations considerably. | ||
517 | */ | ||
518 | |||
519 | goal = b->target - b->size; | ||
520 | /* | ||
521 | * Start with no sleep allocation rate which may be higher | ||
522 | * than sleeping allocation rate. | ||
523 | */ | ||
524 | rate = b->slow_allocation_cycles ? | ||
525 | b->rate_alloc : VMW_BALLOON_NOSLEEP_ALLOC_MAX; | ||
526 | |||
527 | pr_debug("%s - goal: %d, no-sleep rate: %d, sleep rate: %d\n", | ||
528 | __func__, goal, rate, b->rate_alloc); | ||
529 | |||
530 | for (i = 0; i < goal; i++) { | ||
531 | |||
532 | error = vmballoon_reserve_page(b, alloc_can_sleep); | ||
533 | if (error) { | ||
534 | if (error != -ENOMEM) { | ||
535 | /* | ||
536 | * Not a page allocation failure, stop this | ||
537 | * cycle. Maybe we'll get new target from | ||
538 | * the host soon. | ||
539 | */ | ||
540 | break; | ||
541 | } | ||
542 | |||
543 | if (alloc_can_sleep) { | ||
544 | /* | ||
545 | * CANSLEEP page allocation failed, so guest | ||
546 | * is under severe memory pressure. Quickly | ||
547 | * decrease allocation rate. | ||
548 | */ | ||
549 | b->rate_alloc = max(b->rate_alloc / 2, | ||
550 | VMW_BALLOON_RATE_ALLOC_MIN); | ||
551 | break; | ||
552 | } | ||
553 | |||
554 | /* | ||
555 | * NOSLEEP page allocation failed, so the guest is | ||
556 | * under memory pressure. Let us slow down page | ||
557 | * allocations for next few cycles so that the guest | ||
558 | * gets out of memory pressure. Also, if we already | ||
559 | * allocated b->rate_alloc pages, let's pause, | ||
560 | * otherwise switch to sleeping allocations. | ||
561 | */ | ||
562 | b->slow_allocation_cycles = VMW_BALLOON_SLOW_CYCLES; | ||
563 | |||
564 | if (i >= b->rate_alloc) | ||
565 | break; | ||
566 | |||
567 | alloc_can_sleep = true; | ||
568 | /* Lower rate for sleeping allocations. */ | ||
569 | rate = b->rate_alloc; | ||
570 | } | ||
571 | |||
572 | if (++allocations > VMW_BALLOON_YIELD_THRESHOLD) { | ||
573 | cond_resched(); | ||
574 | allocations = 0; | ||
575 | } | ||
576 | |||
577 | if (i >= rate) { | ||
578 | /* We allocated enough pages, let's take a break. */ | ||
579 | break; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | /* | ||
584 | * We reached our goal without failures so try increasing | ||
585 | * allocation rate. | ||
586 | */ | ||
587 | if (error == 0 && i >= b->rate_alloc) { | ||
588 | unsigned int mult = i / b->rate_alloc; | ||
589 | |||
590 | b->rate_alloc = | ||
591 | min(b->rate_alloc + mult * VMW_BALLOON_RATE_ALLOC_INC, | ||
592 | VMW_BALLOON_RATE_ALLOC_MAX); | ||
593 | } | ||
594 | |||
595 | vmballoon_release_refused_pages(b); | ||
596 | } | ||
597 | |||
598 | /* | ||
599 | * Decrease the size of the balloon allowing guest to use more memory. | ||
600 | */ | ||
601 | static void vmballoon_deflate(struct vmballoon *b) | ||
602 | { | ||
603 | struct page *page, *next; | ||
604 | unsigned int i = 0; | ||
605 | unsigned int goal; | ||
606 | int error; | ||
607 | |||
608 | pr_debug("%s - size: %d, target %d\n", __func__, b->size, b->target); | ||
609 | |||
610 | /* limit deallocation rate */ | ||
611 | goal = min(b->size - b->target, b->rate_free); | ||
612 | |||
613 | pr_debug("%s - goal: %d, rate: %d\n", __func__, goal, b->rate_free); | ||
614 | |||
615 | /* free pages to reach target */ | ||
616 | list_for_each_entry_safe(page, next, &b->pages, lru) { | ||
617 | error = vmballoon_release_page(b, page); | ||
618 | if (error) { | ||
619 | /* quickly decrease rate in case of error */ | ||
620 | b->rate_free = max(b->rate_free / 2, | ||
621 | VMW_BALLOON_RATE_FREE_MIN); | ||
622 | return; | ||
623 | } | ||
624 | |||
625 | if (++i >= goal) | ||
626 | break; | ||
627 | } | ||
628 | |||
629 | /* slowly increase rate if there were no errors */ | ||
630 | b->rate_free = min(b->rate_free + VMW_BALLOON_RATE_FREE_INC, | ||
631 | VMW_BALLOON_RATE_FREE_MAX); | ||
632 | } | ||
633 | |||
634 | /* | ||
635 | * Balloon work function: reset protocol, if needed, get the new size and | ||
636 | * adjust balloon as needed. Repeat in 1 sec. | ||
637 | */ | ||
638 | static void vmballoon_work(struct work_struct *work) | ||
639 | { | ||
640 | struct delayed_work *dwork = to_delayed_work(work); | ||
641 | struct vmballoon *b = container_of(dwork, struct vmballoon, dwork); | ||
642 | unsigned int target; | ||
643 | |||
644 | STATS_INC(b->stats.timer); | ||
645 | |||
646 | if (b->reset_required) | ||
647 | vmballoon_reset(b); | ||
648 | |||
649 | if (b->slow_allocation_cycles > 0) | ||
650 | b->slow_allocation_cycles--; | ||
651 | |||
652 | if (vmballoon_send_get_target(b, &target)) { | ||
653 | /* update target, adjust size */ | ||
654 | b->target = target; | ||
655 | |||
656 | if (b->size < target) | ||
657 | vmballoon_inflate(b); | ||
658 | else if (b->size > target) | ||
659 | vmballoon_deflate(b); | ||
660 | } | ||
661 | |||
662 | queue_delayed_work(vmballoon_wq, dwork, round_jiffies_relative(HZ)); | ||
663 | } | ||
664 | |||
665 | /* | ||
666 | * DEBUGFS Interface | ||
667 | */ | ||
668 | #ifdef CONFIG_DEBUG_FS | ||
669 | |||
670 | static int vmballoon_debug_show(struct seq_file *f, void *offset) | ||
671 | { | ||
672 | struct vmballoon *b = f->private; | ||
673 | struct vmballoon_stats *stats = &b->stats; | ||
674 | |||
675 | /* format size info */ | ||
676 | seq_printf(f, | ||
677 | "target: %8d pages\n" | ||
678 | "current: %8d pages\n", | ||
679 | b->target, b->size); | ||
680 | |||
681 | /* format rate info */ | ||
682 | seq_printf(f, | ||
683 | "rateNoSleepAlloc: %8d pages/sec\n" | ||
684 | "rateSleepAlloc: %8d pages/sec\n" | ||
685 | "rateFree: %8d pages/sec\n", | ||
686 | VMW_BALLOON_NOSLEEP_ALLOC_MAX, | ||
687 | b->rate_alloc, b->rate_free); | ||
688 | |||
689 | seq_printf(f, | ||
690 | "\n" | ||
691 | "timer: %8u\n" | ||
692 | "start: %8u (%4u failed)\n" | ||
693 | "guestType: %8u (%4u failed)\n" | ||
694 | "lock: %8u (%4u failed)\n" | ||
695 | "unlock: %8u (%4u failed)\n" | ||
696 | "target: %8u (%4u failed)\n" | ||
697 | "primNoSleepAlloc: %8u (%4u failed)\n" | ||
698 | "primCanSleepAlloc: %8u (%4u failed)\n" | ||
699 | "primFree: %8u\n" | ||
700 | "errAlloc: %8u\n" | ||
701 | "errFree: %8u\n", | ||
702 | stats->timer, | ||
703 | stats->start, stats->start_fail, | ||
704 | stats->guest_type, stats->guest_type_fail, | ||
705 | stats->lock, stats->lock_fail, | ||
706 | stats->unlock, stats->unlock_fail, | ||
707 | stats->target, stats->target_fail, | ||
708 | stats->alloc, stats->alloc_fail, | ||
709 | stats->sleep_alloc, stats->sleep_alloc_fail, | ||
710 | stats->free, | ||
711 | stats->refused_alloc, stats->refused_free); | ||
712 | |||
713 | return 0; | ||
714 | } | ||
715 | |||
716 | static int vmballoon_debug_open(struct inode *inode, struct file *file) | ||
717 | { | ||
718 | return single_open(file, vmballoon_debug_show, inode->i_private); | ||
719 | } | ||
720 | |||
721 | static const struct file_operations vmballoon_debug_fops = { | ||
722 | .owner = THIS_MODULE, | ||
723 | .open = vmballoon_debug_open, | ||
724 | .read = seq_read, | ||
725 | .llseek = seq_lseek, | ||
726 | .release = single_release, | ||
727 | }; | ||
728 | |||
729 | static int __init vmballoon_debugfs_init(struct vmballoon *b) | ||
730 | { | ||
731 | int error; | ||
732 | |||
733 | b->dbg_entry = debugfs_create_file("vmmemctl", S_IRUGO, NULL, b, | ||
734 | &vmballoon_debug_fops); | ||
735 | if (IS_ERR(b->dbg_entry)) { | ||
736 | error = PTR_ERR(b->dbg_entry); | ||
737 | pr_err("failed to create debugfs entry, error: %d\n", error); | ||
738 | return error; | ||
739 | } | ||
740 | |||
741 | return 0; | ||
742 | } | ||
743 | |||
744 | static void __exit vmballoon_debugfs_exit(struct vmballoon *b) | ||
745 | { | ||
746 | debugfs_remove(b->dbg_entry); | ||
747 | } | ||
748 | |||
749 | #else | ||
750 | |||
751 | static inline int vmballoon_debugfs_init(struct vmballoon *b) | ||
752 | { | ||
753 | return 0; | ||
754 | } | ||
755 | |||
756 | static inline void vmballoon_debugfs_exit(struct vmballoon *b) | ||
757 | { | ||
758 | } | ||
759 | |||
760 | #endif /* CONFIG_DEBUG_FS */ | ||
761 | |||
762 | static int __init vmballoon_init(void) | ||
763 | { | ||
764 | int error; | ||
765 | |||
766 | /* | ||
767 | * Check if we are running on VMware's hypervisor and bail out | ||
768 | * if we are not. | ||
769 | */ | ||
770 | if (!vmware_platform()) | ||
771 | return -ENODEV; | ||
772 | |||
773 | vmballoon_wq = create_freezeable_workqueue("vmmemctl"); | ||
774 | if (!vmballoon_wq) { | ||
775 | pr_err("failed to create workqueue\n"); | ||
776 | return -ENOMEM; | ||
777 | } | ||
778 | |||
779 | INIT_LIST_HEAD(&balloon.pages); | ||
780 | INIT_LIST_HEAD(&balloon.refused_pages); | ||
781 | |||
782 | /* initialize rates */ | ||
783 | balloon.rate_alloc = VMW_BALLOON_RATE_ALLOC_MAX; | ||
784 | balloon.rate_free = VMW_BALLOON_RATE_FREE_MAX; | ||
785 | |||
786 | INIT_DELAYED_WORK(&balloon.dwork, vmballoon_work); | ||
787 | |||
788 | /* | ||
789 | * Start balloon. | ||
790 | */ | ||
791 | if (!vmballoon_send_start(&balloon)) { | ||
792 | pr_err("failed to send start command to the host\n"); | ||
793 | error = -EIO; | ||
794 | goto fail; | ||
795 | } | ||
796 | |||
797 | if (!vmballoon_send_guest_id(&balloon)) { | ||
798 | pr_err("failed to send guest ID to the host\n"); | ||
799 | error = -EIO; | ||
800 | goto fail; | ||
801 | } | ||
802 | |||
803 | error = vmballoon_debugfs_init(&balloon); | ||
804 | if (error) | ||
805 | goto fail; | ||
806 | |||
807 | queue_delayed_work(vmballoon_wq, &balloon.dwork, 0); | ||
808 | |||
809 | return 0; | ||
810 | |||
811 | fail: | ||
812 | destroy_workqueue(vmballoon_wq); | ||
813 | return error; | ||
814 | } | ||
815 | module_init(vmballoon_init); | ||
816 | |||
817 | static void __exit vmballoon_exit(void) | ||
818 | { | ||
819 | cancel_delayed_work_sync(&balloon.dwork); | ||
820 | destroy_workqueue(vmballoon_wq); | ||
821 | |||
822 | vmballoon_debugfs_exit(&balloon); | ||
823 | |||
824 | /* | ||
825 | * Deallocate all reserved memory, and reset connection with monitor. | ||
826 | * Reset connection before deallocating memory to avoid potential for | ||
827 | * additional spurious resets from guest touching deallocated pages. | ||
828 | */ | ||
829 | vmballoon_send_start(&balloon); | ||
830 | vmballoon_pop(&balloon); | ||
831 | } | ||
832 | module_exit(vmballoon_exit); | ||
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile index 82d1e4de475b..4521b1ecce45 100644 --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | # Core functionality. | 5 | # Core functionality. |
6 | obj-$(CONFIG_MTD) += mtd.o | 6 | obj-$(CONFIG_MTD) += mtd.o |
7 | mtd-y := mtdcore.o mtdsuper.o mtdbdi.o | 7 | mtd-y := mtdcore.o mtdsuper.o |
8 | mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o | 8 | mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o |
9 | 9 | ||
10 | obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o | 10 | obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o |
diff --git a/drivers/mtd/internal.h b/drivers/mtd/internal.h index c658fe7216b5..e69de29bb2d1 100644 --- a/drivers/mtd/internal.h +++ b/drivers/mtd/internal.h | |||
@@ -1,17 +0,0 @@ | |||
1 | /* Internal MTD definitions | ||
2 | * | ||
3 | * Copyright © 2006 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * mtdbdi.c | ||
14 | */ | ||
15 | extern struct backing_dev_info mtd_bdi_unmappable; | ||
16 | extern struct backing_dev_info mtd_bdi_ro_mappable; | ||
17 | extern struct backing_dev_info mtd_bdi_rw_mappable; | ||
diff --git a/drivers/mtd/mtdbdi.c b/drivers/mtd/mtdbdi.c index 5ca5aed0b225..e69de29bb2d1 100644 --- a/drivers/mtd/mtdbdi.c +++ b/drivers/mtd/mtdbdi.c | |||
@@ -1,43 +0,0 @@ | |||
1 | /* MTD backing device capabilities | ||
2 | * | ||
3 | * Copyright © 2006 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/backing-dev.h> | ||
13 | #include <linux/mtd/mtd.h> | ||
14 | #include "internal.h" | ||
15 | |||
16 | /* | ||
17 | * backing device capabilities for non-mappable devices (such as NAND flash) | ||
18 | * - permits private mappings, copies are taken of the data | ||
19 | */ | ||
20 | struct backing_dev_info mtd_bdi_unmappable = { | ||
21 | .capabilities = BDI_CAP_MAP_COPY, | ||
22 | }; | ||
23 | |||
24 | /* | ||
25 | * backing device capabilities for R/O mappable devices (such as ROM) | ||
26 | * - permits private mappings, copies are taken of the data | ||
27 | * - permits non-writable shared mappings | ||
28 | */ | ||
29 | struct backing_dev_info mtd_bdi_ro_mappable = { | ||
30 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | ||
31 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP), | ||
32 | }; | ||
33 | |||
34 | /* | ||
35 | * backing device capabilities for writable mappable devices (such as RAM) | ||
36 | * - permits private mappings, copies are taken of the data | ||
37 | * - permits non-writable shared mappings | ||
38 | */ | ||
39 | struct backing_dev_info mtd_bdi_rw_mappable = { | ||
40 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | ||
41 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP | | ||
42 | BDI_CAP_WRITE_MAP), | ||
43 | }; | ||
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 5b38b17d2229..b177e750efc3 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -2,6 +2,9 @@ | |||
2 | * Core registration and callback routines for MTD | 2 | * Core registration and callback routines for MTD |
3 | * drivers and users. | 3 | * drivers and users. |
4 | * | 4 | * |
5 | * bdi bits are: | ||
6 | * Copyright © 2006 Red Hat, Inc. All Rights Reserved. | ||
7 | * Written by David Howells (dhowells@redhat.com) | ||
5 | */ | 8 | */ |
6 | 9 | ||
7 | #include <linux/module.h> | 10 | #include <linux/module.h> |
@@ -16,11 +19,39 @@ | |||
16 | #include <linux/init.h> | 19 | #include <linux/init.h> |
17 | #include <linux/mtd/compatmac.h> | 20 | #include <linux/mtd/compatmac.h> |
18 | #include <linux/proc_fs.h> | 21 | #include <linux/proc_fs.h> |
22 | #include <linux/backing-dev.h> | ||
19 | 23 | ||
20 | #include <linux/mtd/mtd.h> | 24 | #include <linux/mtd/mtd.h> |
21 | #include "internal.h" | ||
22 | 25 | ||
23 | #include "mtdcore.h" | 26 | #include "mtdcore.h" |
27 | /* | ||
28 | * backing device capabilities for non-mappable devices (such as NAND flash) | ||
29 | * - permits private mappings, copies are taken of the data | ||
30 | */ | ||
31 | struct backing_dev_info mtd_bdi_unmappable = { | ||
32 | .capabilities = BDI_CAP_MAP_COPY, | ||
33 | }; | ||
34 | |||
35 | /* | ||
36 | * backing device capabilities for R/O mappable devices (such as ROM) | ||
37 | * - permits private mappings, copies are taken of the data | ||
38 | * - permits non-writable shared mappings | ||
39 | */ | ||
40 | struct backing_dev_info mtd_bdi_ro_mappable = { | ||
41 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | ||
42 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP), | ||
43 | }; | ||
44 | |||
45 | /* | ||
46 | * backing device capabilities for writable mappable devices (such as RAM) | ||
47 | * - permits private mappings, copies are taken of the data | ||
48 | * - permits non-writable shared mappings | ||
49 | */ | ||
50 | struct backing_dev_info mtd_bdi_rw_mappable = { | ||
51 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | ||
52 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP | | ||
53 | BDI_CAP_WRITE_MAP), | ||
54 | }; | ||
24 | 55 | ||
25 | static int mtd_cls_suspend(struct device *dev, pm_message_t state); | 56 | static int mtd_cls_suspend(struct device *dev, pm_message_t state); |
26 | static int mtd_cls_resume(struct device *dev); | 57 | static int mtd_cls_resume(struct device *dev); |
@@ -628,20 +659,55 @@ done: | |||
628 | /*====================================================================*/ | 659 | /*====================================================================*/ |
629 | /* Init code */ | 660 | /* Init code */ |
630 | 661 | ||
662 | static int __init mtd_bdi_init(struct backing_dev_info *bdi, const char *name) | ||
663 | { | ||
664 | int ret; | ||
665 | |||
666 | ret = bdi_init(bdi); | ||
667 | if (!ret) | ||
668 | ret = bdi_register(bdi, NULL, name); | ||
669 | |||
670 | if (ret) | ||
671 | bdi_destroy(bdi); | ||
672 | |||
673 | return ret; | ||
674 | } | ||
675 | |||
631 | static int __init init_mtd(void) | 676 | static int __init init_mtd(void) |
632 | { | 677 | { |
633 | int ret; | 678 | int ret; |
679 | |||
634 | ret = class_register(&mtd_class); | 680 | ret = class_register(&mtd_class); |
681 | if (ret) | ||
682 | goto err_reg; | ||
683 | |||
684 | ret = mtd_bdi_init(&mtd_bdi_unmappable, "mtd-unmap"); | ||
685 | if (ret) | ||
686 | goto err_bdi1; | ||
687 | |||
688 | ret = mtd_bdi_init(&mtd_bdi_ro_mappable, "mtd-romap"); | ||
689 | if (ret) | ||
690 | goto err_bdi2; | ||
691 | |||
692 | ret = mtd_bdi_init(&mtd_bdi_rw_mappable, "mtd-rwmap"); | ||
693 | if (ret) | ||
694 | goto err_bdi3; | ||
635 | 695 | ||
636 | if (ret) { | ||
637 | pr_err("Error registering mtd class: %d\n", ret); | ||
638 | return ret; | ||
639 | } | ||
640 | #ifdef CONFIG_PROC_FS | 696 | #ifdef CONFIG_PROC_FS |
641 | if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) | 697 | if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) |
642 | proc_mtd->read_proc = mtd_read_proc; | 698 | proc_mtd->read_proc = mtd_read_proc; |
643 | #endif /* CONFIG_PROC_FS */ | 699 | #endif /* CONFIG_PROC_FS */ |
644 | return 0; | 700 | return 0; |
701 | |||
702 | err_bdi3: | ||
703 | bdi_destroy(&mtd_bdi_ro_mappable); | ||
704 | err_bdi2: | ||
705 | bdi_destroy(&mtd_bdi_unmappable); | ||
706 | err_bdi1: | ||
707 | class_unregister(&mtd_class); | ||
708 | err_reg: | ||
709 | pr_err("Error registering mtd class or bdi: %d\n", ret); | ||
710 | return ret; | ||
645 | } | 711 | } |
646 | 712 | ||
647 | static void __exit cleanup_mtd(void) | 713 | static void __exit cleanup_mtd(void) |
@@ -651,6 +717,9 @@ static void __exit cleanup_mtd(void) | |||
651 | remove_proc_entry( "mtd", NULL); | 717 | remove_proc_entry( "mtd", NULL); |
652 | #endif /* CONFIG_PROC_FS */ | 718 | #endif /* CONFIG_PROC_FS */ |
653 | class_unregister(&mtd_class); | 719 | class_unregister(&mtd_class); |
720 | bdi_destroy(&mtd_bdi_unmappable); | ||
721 | bdi_destroy(&mtd_bdi_ro_mappable); | ||
722 | bdi_destroy(&mtd_bdi_rw_mappable); | ||
654 | } | 723 | } |
655 | 724 | ||
656 | module_init(init_mtd); | 725 | module_init(init_mtd); |
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c index af8b42e0a55b..7c003191fca4 100644 --- a/drivers/mtd/mtdsuper.c +++ b/drivers/mtd/mtdsuper.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/mtd/super.h> | 13 | #include <linux/mtd/super.h> |
14 | #include <linux/namei.h> | 14 | #include <linux/namei.h> |
15 | #include <linux/ctype.h> | 15 | #include <linux/ctype.h> |
16 | #include <linux/slab.h> | ||
16 | 17 | ||
17 | /* | 18 | /* |
18 | * compare superblocks to see if they're equivalent | 19 | * compare superblocks to see if they're equivalent |
@@ -44,6 +45,7 @@ static int get_sb_mtd_set(struct super_block *sb, void *_mtd) | |||
44 | 45 | ||
45 | sb->s_mtd = mtd; | 46 | sb->s_mtd = mtd; |
46 | sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index); | 47 | sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index); |
48 | sb->s_bdi = mtd->backing_dev_info; | ||
47 | return 0; | 49 | return 0; |
48 | } | 50 | } |
49 | 51 | ||
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c index f59c07427af3..d60fc5719fef 100644 --- a/drivers/mtd/nand/orion_nand.c +++ b/drivers/mtd/nand/orion_nand.c | |||
@@ -60,7 +60,13 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) | |||
60 | } | 60 | } |
61 | buf64 = (uint64_t *)buf; | 61 | buf64 = (uint64_t *)buf; |
62 | while (i < len/8) { | 62 | while (i < len/8) { |
63 | uint64_t x; | 63 | /* |
64 | * Since GCC has no proper constraint (PR 43518) | ||
65 | * force x variable to r2/r3 registers as ldrd instruction | ||
66 | * requires first register to be even. | ||
67 | */ | ||
68 | register uint64_t x asm ("r2"); | ||
69 | |||
64 | asm volatile ("ldrd\t%0, [%1]" : "=&r" (x) : "r" (io_base)); | 70 | asm volatile ("ldrd\t%0, [%1]" : "=&r" (x) : "r" (io_base)); |
65 | buf64[i++] = x; | 71 | buf64[i++] = x; |
66 | } | 72 | } |
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index a03d291de854..f0d23de32967 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c | |||
@@ -1944,7 +1944,7 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp, | |||
1944 | netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n", | 1944 | netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n", |
1945 | __func__, rx_status, rx_size, cur_rx); | 1945 | __func__, rx_status, rx_size, cur_rx); |
1946 | #if RTL8139_DEBUG > 2 | 1946 | #if RTL8139_DEBUG > 2 |
1947 | print_dump_hex(KERN_DEBUG, "Frame contents: ", | 1947 | print_hex_dump(KERN_DEBUG, "Frame contents: ", |
1948 | DUMP_PREFIX_OFFSET, 16, 1, | 1948 | DUMP_PREFIX_OFFSET, 16, 1, |
1949 | &rx_ring[ring_offset], 70, true); | 1949 | &rx_ring[ring_offset], 70, true); |
1950 | #endif | 1950 | #endif |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index a583b50d9de8..12b280afdd51 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -273,6 +273,7 @@ obj-$(CONFIG_USB_RTL8150) += usb/ | |||
273 | obj-$(CONFIG_USB_HSO) += usb/ | 273 | obj-$(CONFIG_USB_HSO) += usb/ |
274 | obj-$(CONFIG_USB_USBNET) += usb/ | 274 | obj-$(CONFIG_USB_USBNET) += usb/ |
275 | obj-$(CONFIG_USB_ZD1201) += usb/ | 275 | obj-$(CONFIG_USB_ZD1201) += usb/ |
276 | obj-$(CONFIG_USB_IPHETH) += usb/ | ||
276 | 277 | ||
277 | obj-y += wireless/ | 278 | obj-y += wireless/ |
278 | obj-$(CONFIG_NET_TULIP) += tulip/ | 279 | obj-$(CONFIG_NET_TULIP) += tulip/ |
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index a257babd1bb4..ac90a3828f69 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -58,8 +58,8 @@ | |||
58 | #include "bnx2_fw.h" | 58 | #include "bnx2_fw.h" |
59 | 59 | ||
60 | #define DRV_MODULE_NAME "bnx2" | 60 | #define DRV_MODULE_NAME "bnx2" |
61 | #define DRV_MODULE_VERSION "2.0.8" | 61 | #define DRV_MODULE_VERSION "2.0.9" |
62 | #define DRV_MODULE_RELDATE "Feb 15, 2010" | 62 | #define DRV_MODULE_RELDATE "April 27, 2010" |
63 | #define FW_MIPS_FILE_06 "bnx2/bnx2-mips-06-5.0.0.j6.fw" | 63 | #define FW_MIPS_FILE_06 "bnx2/bnx2-mips-06-5.0.0.j6.fw" |
64 | #define FW_RV2P_FILE_06 "bnx2/bnx2-rv2p-06-5.0.0.j3.fw" | 64 | #define FW_RV2P_FILE_06 "bnx2/bnx2-rv2p-06-5.0.0.j3.fw" |
65 | #define FW_MIPS_FILE_09 "bnx2/bnx2-mips-09-5.0.0.j9.fw" | 65 | #define FW_MIPS_FILE_09 "bnx2/bnx2-mips-09-5.0.0.j9.fw" |
@@ -651,9 +651,10 @@ bnx2_napi_enable(struct bnx2 *bp) | |||
651 | } | 651 | } |
652 | 652 | ||
653 | static void | 653 | static void |
654 | bnx2_netif_stop(struct bnx2 *bp) | 654 | bnx2_netif_stop(struct bnx2 *bp, bool stop_cnic) |
655 | { | 655 | { |
656 | bnx2_cnic_stop(bp); | 656 | if (stop_cnic) |
657 | bnx2_cnic_stop(bp); | ||
657 | if (netif_running(bp->dev)) { | 658 | if (netif_running(bp->dev)) { |
658 | int i; | 659 | int i; |
659 | 660 | ||
@@ -671,14 +672,15 @@ bnx2_netif_stop(struct bnx2 *bp) | |||
671 | } | 672 | } |
672 | 673 | ||
673 | static void | 674 | static void |
674 | bnx2_netif_start(struct bnx2 *bp) | 675 | bnx2_netif_start(struct bnx2 *bp, bool start_cnic) |
675 | { | 676 | { |
676 | if (atomic_dec_and_test(&bp->intr_sem)) { | 677 | if (atomic_dec_and_test(&bp->intr_sem)) { |
677 | if (netif_running(bp->dev)) { | 678 | if (netif_running(bp->dev)) { |
678 | netif_tx_wake_all_queues(bp->dev); | 679 | netif_tx_wake_all_queues(bp->dev); |
679 | bnx2_napi_enable(bp); | 680 | bnx2_napi_enable(bp); |
680 | bnx2_enable_int(bp); | 681 | bnx2_enable_int(bp); |
681 | bnx2_cnic_start(bp); | 682 | if (start_cnic) |
683 | bnx2_cnic_start(bp); | ||
682 | } | 684 | } |
683 | } | 685 | } |
684 | } | 686 | } |
@@ -4759,8 +4761,12 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code) | |||
4759 | rc = bnx2_alloc_bad_rbuf(bp); | 4761 | rc = bnx2_alloc_bad_rbuf(bp); |
4760 | } | 4762 | } |
4761 | 4763 | ||
4762 | if (bp->flags & BNX2_FLAG_USING_MSIX) | 4764 | if (bp->flags & BNX2_FLAG_USING_MSIX) { |
4763 | bnx2_setup_msix_tbl(bp); | 4765 | bnx2_setup_msix_tbl(bp); |
4766 | /* Prevent MSIX table reads and write from timing out */ | ||
4767 | REG_WR(bp, BNX2_MISC_ECO_HW_CTL, | ||
4768 | BNX2_MISC_ECO_HW_CTL_LARGE_GRC_TMOUT_EN); | ||
4769 | } | ||
4764 | 4770 | ||
4765 | return rc; | 4771 | return rc; |
4766 | } | 4772 | } |
@@ -6273,12 +6279,12 @@ bnx2_reset_task(struct work_struct *work) | |||
6273 | return; | 6279 | return; |
6274 | } | 6280 | } |
6275 | 6281 | ||
6276 | bnx2_netif_stop(bp); | 6282 | bnx2_netif_stop(bp, true); |
6277 | 6283 | ||
6278 | bnx2_init_nic(bp, 1); | 6284 | bnx2_init_nic(bp, 1); |
6279 | 6285 | ||
6280 | atomic_set(&bp->intr_sem, 1); | 6286 | atomic_set(&bp->intr_sem, 1); |
6281 | bnx2_netif_start(bp); | 6287 | bnx2_netif_start(bp, true); |
6282 | rtnl_unlock(); | 6288 | rtnl_unlock(); |
6283 | } | 6289 | } |
6284 | 6290 | ||
@@ -6320,7 +6326,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp) | |||
6320 | struct bnx2 *bp = netdev_priv(dev); | 6326 | struct bnx2 *bp = netdev_priv(dev); |
6321 | 6327 | ||
6322 | if (netif_running(dev)) | 6328 | if (netif_running(dev)) |
6323 | bnx2_netif_stop(bp); | 6329 | bnx2_netif_stop(bp, false); |
6324 | 6330 | ||
6325 | bp->vlgrp = vlgrp; | 6331 | bp->vlgrp = vlgrp; |
6326 | 6332 | ||
@@ -6331,7 +6337,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp) | |||
6331 | if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) | 6337 | if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) |
6332 | bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); | 6338 | bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); |
6333 | 6339 | ||
6334 | bnx2_netif_start(bp); | 6340 | bnx2_netif_start(bp, false); |
6335 | } | 6341 | } |
6336 | #endif | 6342 | #endif |
6337 | 6343 | ||
@@ -7051,9 +7057,9 @@ bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal) | |||
7051 | bp->stats_ticks &= BNX2_HC_STATS_TICKS_HC_STAT_TICKS; | 7057 | bp->stats_ticks &= BNX2_HC_STATS_TICKS_HC_STAT_TICKS; |
7052 | 7058 | ||
7053 | if (netif_running(bp->dev)) { | 7059 | if (netif_running(bp->dev)) { |
7054 | bnx2_netif_stop(bp); | 7060 | bnx2_netif_stop(bp, true); |
7055 | bnx2_init_nic(bp, 0); | 7061 | bnx2_init_nic(bp, 0); |
7056 | bnx2_netif_start(bp); | 7062 | bnx2_netif_start(bp, true); |
7057 | } | 7063 | } |
7058 | 7064 | ||
7059 | return 0; | 7065 | return 0; |
@@ -7083,7 +7089,7 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx) | |||
7083 | /* Reset will erase chipset stats; save them */ | 7089 | /* Reset will erase chipset stats; save them */ |
7084 | bnx2_save_stats(bp); | 7090 | bnx2_save_stats(bp); |
7085 | 7091 | ||
7086 | bnx2_netif_stop(bp); | 7092 | bnx2_netif_stop(bp, true); |
7087 | bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); | 7093 | bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); |
7088 | bnx2_free_skbs(bp); | 7094 | bnx2_free_skbs(bp); |
7089 | bnx2_free_mem(bp); | 7095 | bnx2_free_mem(bp); |
@@ -7111,7 +7117,7 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx) | |||
7111 | bnx2_setup_cnic_irq_info(bp); | 7117 | bnx2_setup_cnic_irq_info(bp); |
7112 | mutex_unlock(&bp->cnic_lock); | 7118 | mutex_unlock(&bp->cnic_lock); |
7113 | #endif | 7119 | #endif |
7114 | bnx2_netif_start(bp); | 7120 | bnx2_netif_start(bp, true); |
7115 | } | 7121 | } |
7116 | return 0; | 7122 | return 0; |
7117 | } | 7123 | } |
@@ -7364,7 +7370,7 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf) | |||
7364 | if (etest->flags & ETH_TEST_FL_OFFLINE) { | 7370 | if (etest->flags & ETH_TEST_FL_OFFLINE) { |
7365 | int i; | 7371 | int i; |
7366 | 7372 | ||
7367 | bnx2_netif_stop(bp); | 7373 | bnx2_netif_stop(bp, true); |
7368 | bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG); | 7374 | bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG); |
7369 | bnx2_free_skbs(bp); | 7375 | bnx2_free_skbs(bp); |
7370 | 7376 | ||
@@ -7383,7 +7389,7 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf) | |||
7383 | bnx2_shutdown_chip(bp); | 7389 | bnx2_shutdown_chip(bp); |
7384 | else { | 7390 | else { |
7385 | bnx2_init_nic(bp, 1); | 7391 | bnx2_init_nic(bp, 1); |
7386 | bnx2_netif_start(bp); | 7392 | bnx2_netif_start(bp, true); |
7387 | } | 7393 | } |
7388 | 7394 | ||
7389 | /* wait for link up */ | 7395 | /* wait for link up */ |
@@ -8377,7 +8383,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state) | |||
8377 | return 0; | 8383 | return 0; |
8378 | 8384 | ||
8379 | flush_scheduled_work(); | 8385 | flush_scheduled_work(); |
8380 | bnx2_netif_stop(bp); | 8386 | bnx2_netif_stop(bp, true); |
8381 | netif_device_detach(dev); | 8387 | netif_device_detach(dev); |
8382 | del_timer_sync(&bp->timer); | 8388 | del_timer_sync(&bp->timer); |
8383 | bnx2_shutdown_chip(bp); | 8389 | bnx2_shutdown_chip(bp); |
@@ -8399,7 +8405,7 @@ bnx2_resume(struct pci_dev *pdev) | |||
8399 | bnx2_set_power_state(bp, PCI_D0); | 8405 | bnx2_set_power_state(bp, PCI_D0); |
8400 | netif_device_attach(dev); | 8406 | netif_device_attach(dev); |
8401 | bnx2_init_nic(bp, 1); | 8407 | bnx2_init_nic(bp, 1); |
8402 | bnx2_netif_start(bp); | 8408 | bnx2_netif_start(bp, true); |
8403 | return 0; | 8409 | return 0; |
8404 | } | 8410 | } |
8405 | 8411 | ||
@@ -8426,7 +8432,7 @@ static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev, | |||
8426 | } | 8432 | } |
8427 | 8433 | ||
8428 | if (netif_running(dev)) { | 8434 | if (netif_running(dev)) { |
8429 | bnx2_netif_stop(bp); | 8435 | bnx2_netif_stop(bp, true); |
8430 | del_timer_sync(&bp->timer); | 8436 | del_timer_sync(&bp->timer); |
8431 | bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET); | 8437 | bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET); |
8432 | } | 8438 | } |
@@ -8483,7 +8489,7 @@ static void bnx2_io_resume(struct pci_dev *pdev) | |||
8483 | 8489 | ||
8484 | rtnl_lock(); | 8490 | rtnl_lock(); |
8485 | if (netif_running(dev)) | 8491 | if (netif_running(dev)) |
8486 | bnx2_netif_start(bp); | 8492 | bnx2_netif_start(bp, true); |
8487 | 8493 | ||
8488 | netif_device_attach(dev); | 8494 | netif_device_attach(dev); |
8489 | rtnl_unlock(); | 8495 | rtnl_unlock(); |
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index 33451092b8e8..d800b598ae3d 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c | |||
@@ -1006,7 +1006,7 @@ static int ems_usb_probe(struct usb_interface *intf, | |||
1006 | 1006 | ||
1007 | netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS); | 1007 | netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS); |
1008 | if (!netdev) { | 1008 | if (!netdev) { |
1009 | dev_err(netdev->dev.parent, "Couldn't alloc candev\n"); | 1009 | dev_err(&intf->dev, "ems_usb: Couldn't alloc candev\n"); |
1010 | return -ENOMEM; | 1010 | return -ENOMEM; |
1011 | } | 1011 | } |
1012 | 1012 | ||
@@ -1036,20 +1036,20 @@ static int ems_usb_probe(struct usb_interface *intf, | |||
1036 | 1036 | ||
1037 | dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); | 1037 | dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); |
1038 | if (!dev->intr_urb) { | 1038 | if (!dev->intr_urb) { |
1039 | dev_err(netdev->dev.parent, "Couldn't alloc intr URB\n"); | 1039 | dev_err(&intf->dev, "Couldn't alloc intr URB\n"); |
1040 | goto cleanup_candev; | 1040 | goto cleanup_candev; |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL); | 1043 | dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL); |
1044 | if (!dev->intr_in_buffer) { | 1044 | if (!dev->intr_in_buffer) { |
1045 | dev_err(netdev->dev.parent, "Couldn't alloc Intr buffer\n"); | 1045 | dev_err(&intf->dev, "Couldn't alloc Intr buffer\n"); |
1046 | goto cleanup_intr_urb; | 1046 | goto cleanup_intr_urb; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE + | 1049 | dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE + |
1050 | sizeof(struct ems_cpc_msg), GFP_KERNEL); | 1050 | sizeof(struct ems_cpc_msg), GFP_KERNEL); |
1051 | if (!dev->tx_msg_buffer) { | 1051 | if (!dev->tx_msg_buffer) { |
1052 | dev_err(netdev->dev.parent, "Couldn't alloc Tx buffer\n"); | 1052 | dev_err(&intf->dev, "Couldn't alloc Tx buffer\n"); |
1053 | goto cleanup_intr_in_buffer; | 1053 | goto cleanup_intr_in_buffer; |
1054 | } | 1054 | } |
1055 | 1055 | ||
diff --git a/drivers/net/cxgb3/ael1002.c b/drivers/net/cxgb3/ael1002.c index 5248f9e0b2f4..35cd36729155 100644 --- a/drivers/net/cxgb3/ael1002.c +++ b/drivers/net/cxgb3/ael1002.c | |||
@@ -934,7 +934,7 @@ static struct cphy_ops xaui_direct_ops = { | |||
934 | int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter, | 934 | int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter, |
935 | int phy_addr, const struct mdio_ops *mdio_ops) | 935 | int phy_addr, const struct mdio_ops *mdio_ops) |
936 | { | 936 | { |
937 | cphy_init(phy, adapter, MDIO_PRTAD_NONE, &xaui_direct_ops, mdio_ops, | 937 | cphy_init(phy, adapter, phy_addr, &xaui_direct_ops, mdio_ops, |
938 | SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP, | 938 | SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP, |
939 | "10GBASE-CX4"); | 939 | "10GBASE-CX4"); |
940 | return 0; | 940 | return 0; |
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index aced6c5e635c..e3f1b8566495 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -439,7 +439,7 @@ static void free_irq_resources(struct adapter *adapter) | |||
439 | static int await_mgmt_replies(struct adapter *adap, unsigned long init_cnt, | 439 | static int await_mgmt_replies(struct adapter *adap, unsigned long init_cnt, |
440 | unsigned long n) | 440 | unsigned long n) |
441 | { | 441 | { |
442 | int attempts = 5; | 442 | int attempts = 10; |
443 | 443 | ||
444 | while (adap->sge.qs[0].rspq.offload_pkts < init_cnt + n) { | 444 | while (adap->sge.qs[0].rspq.offload_pkts < init_cnt + n) { |
445 | if (!--attempts) | 445 | if (!--attempts) |
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index b997e578e58f..791080303db1 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -166,6 +166,7 @@ | |||
166 | #include <linux/ethtool.h> | 166 | #include <linux/ethtool.h> |
167 | #include <linux/string.h> | 167 | #include <linux/string.h> |
168 | #include <linux/firmware.h> | 168 | #include <linux/firmware.h> |
169 | #include <linux/rtnetlink.h> | ||
169 | #include <asm/unaligned.h> | 170 | #include <asm/unaligned.h> |
170 | 171 | ||
171 | 172 | ||
@@ -2265,8 +2266,13 @@ static void e100_tx_timeout_task(struct work_struct *work) | |||
2265 | 2266 | ||
2266 | DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n", | 2267 | DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n", |
2267 | ioread8(&nic->csr->scb.status)); | 2268 | ioread8(&nic->csr->scb.status)); |
2268 | e100_down(netdev_priv(netdev)); | 2269 | |
2269 | e100_up(netdev_priv(netdev)); | 2270 | rtnl_lock(); |
2271 | if (netif_running(netdev)) { | ||
2272 | e100_down(netdev_priv(netdev)); | ||
2273 | e100_up(netdev_priv(netdev)); | ||
2274 | } | ||
2275 | rtnl_unlock(); | ||
2270 | } | 2276 | } |
2271 | 2277 | ||
2272 | static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) | 2278 | static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) |
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c index 712ccc66ba25..90155552ea09 100644 --- a/drivers/net/e1000e/82571.c +++ b/drivers/net/e1000e/82571.c | |||
@@ -336,7 +336,6 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter) | |||
336 | struct e1000_hw *hw = &adapter->hw; | 336 | struct e1000_hw *hw = &adapter->hw; |
337 | static int global_quad_port_a; /* global port a indication */ | 337 | static int global_quad_port_a; /* global port a indication */ |
338 | struct pci_dev *pdev = adapter->pdev; | 338 | struct pci_dev *pdev = adapter->pdev; |
339 | u16 eeprom_data = 0; | ||
340 | int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; | 339 | int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; |
341 | s32 rc; | 340 | s32 rc; |
342 | 341 | ||
@@ -387,16 +386,15 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter) | |||
387 | if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) | 386 | if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) |
388 | adapter->flags &= ~FLAG_HAS_WOL; | 387 | adapter->flags &= ~FLAG_HAS_WOL; |
389 | break; | 388 | break; |
390 | |||
391 | case e1000_82573: | 389 | case e1000_82573: |
390 | case e1000_82574: | ||
391 | case e1000_82583: | ||
392 | /* Disable ASPM L0s due to hardware errata */ | ||
393 | e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L0S); | ||
394 | |||
392 | if (pdev->device == E1000_DEV_ID_82573L) { | 395 | if (pdev->device == E1000_DEV_ID_82573L) { |
393 | if (e1000_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1, | 396 | adapter->flags |= FLAG_HAS_JUMBO_FRAMES; |
394 | &eeprom_data) < 0) | 397 | adapter->max_hw_frame_size = DEFAULT_JUMBO; |
395 | break; | ||
396 | if (!(eeprom_data & NVM_WORD1A_ASPM_MASK)) { | ||
397 | adapter->flags |= FLAG_HAS_JUMBO_FRAMES; | ||
398 | adapter->max_hw_frame_size = DEFAULT_JUMBO; | ||
399 | } | ||
400 | } | 398 | } |
401 | break; | 399 | break; |
402 | default: | 400 | default: |
@@ -1792,6 +1790,7 @@ struct e1000_info e1000_82571_info = { | |||
1792 | | FLAG_RESET_OVERWRITES_LAA /* errata */ | 1790 | | FLAG_RESET_OVERWRITES_LAA /* errata */ |
1793 | | FLAG_TARC_SPEED_MODE_BIT /* errata */ | 1791 | | FLAG_TARC_SPEED_MODE_BIT /* errata */ |
1794 | | FLAG_APME_CHECK_PORT_B, | 1792 | | FLAG_APME_CHECK_PORT_B, |
1793 | .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */ | ||
1795 | .pba = 38, | 1794 | .pba = 38, |
1796 | .max_hw_frame_size = DEFAULT_JUMBO, | 1795 | .max_hw_frame_size = DEFAULT_JUMBO, |
1797 | .get_variants = e1000_get_variants_82571, | 1796 | .get_variants = e1000_get_variants_82571, |
@@ -1809,6 +1808,7 @@ struct e1000_info e1000_82572_info = { | |||
1809 | | FLAG_RX_CSUM_ENABLED | 1808 | | FLAG_RX_CSUM_ENABLED |
1810 | | FLAG_HAS_CTRLEXT_ON_LOAD | 1809 | | FLAG_HAS_CTRLEXT_ON_LOAD |
1811 | | FLAG_TARC_SPEED_MODE_BIT, /* errata */ | 1810 | | FLAG_TARC_SPEED_MODE_BIT, /* errata */ |
1811 | .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */ | ||
1812 | .pba = 38, | 1812 | .pba = 38, |
1813 | .max_hw_frame_size = DEFAULT_JUMBO, | 1813 | .max_hw_frame_size = DEFAULT_JUMBO, |
1814 | .get_variants = e1000_get_variants_82571, | 1814 | .get_variants = e1000_get_variants_82571, |
@@ -1820,13 +1820,11 @@ struct e1000_info e1000_82572_info = { | |||
1820 | struct e1000_info e1000_82573_info = { | 1820 | struct e1000_info e1000_82573_info = { |
1821 | .mac = e1000_82573, | 1821 | .mac = e1000_82573, |
1822 | .flags = FLAG_HAS_HW_VLAN_FILTER | 1822 | .flags = FLAG_HAS_HW_VLAN_FILTER |
1823 | | FLAG_HAS_JUMBO_FRAMES | ||
1824 | | FLAG_HAS_WOL | 1823 | | FLAG_HAS_WOL |
1825 | | FLAG_APME_IN_CTRL3 | 1824 | | FLAG_APME_IN_CTRL3 |
1826 | | FLAG_RX_CSUM_ENABLED | 1825 | | FLAG_RX_CSUM_ENABLED |
1827 | | FLAG_HAS_SMART_POWER_DOWN | 1826 | | FLAG_HAS_SMART_POWER_DOWN |
1828 | | FLAG_HAS_AMT | 1827 | | FLAG_HAS_AMT |
1829 | | FLAG_HAS_ERT | ||
1830 | | FLAG_HAS_SWSM_ON_LOAD, | 1828 | | FLAG_HAS_SWSM_ON_LOAD, |
1831 | .pba = 20, | 1829 | .pba = 20, |
1832 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, | 1830 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, |
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h index 118bdf483593..ee32b9b27a9f 100644 --- a/drivers/net/e1000e/e1000.h +++ b/drivers/net/e1000e/e1000.h | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/io.h> | 37 | #include <linux/io.h> |
38 | #include <linux/netdevice.h> | 38 | #include <linux/netdevice.h> |
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <linux/pci-aspm.h> | ||
40 | 41 | ||
41 | #include "hw.h" | 42 | #include "hw.h" |
42 | 43 | ||
@@ -374,7 +375,7 @@ struct e1000_adapter { | |||
374 | struct e1000_info { | 375 | struct e1000_info { |
375 | enum e1000_mac_type mac; | 376 | enum e1000_mac_type mac; |
376 | unsigned int flags; | 377 | unsigned int flags; |
377 | unsigned int flags2; | 378 | unsigned int flags2; |
378 | u32 pba; | 379 | u32 pba; |
379 | u32 max_hw_frame_size; | 380 | u32 max_hw_frame_size; |
380 | s32 (*get_variants)(struct e1000_adapter *); | 381 | s32 (*get_variants)(struct e1000_adapter *); |
@@ -421,6 +422,7 @@ struct e1000_info { | |||
421 | #define FLAG2_CRC_STRIPPING (1 << 0) | 422 | #define FLAG2_CRC_STRIPPING (1 << 0) |
422 | #define FLAG2_HAS_PHY_WAKEUP (1 << 1) | 423 | #define FLAG2_HAS_PHY_WAKEUP (1 << 1) |
423 | #define FLAG2_IS_DISCARDING (1 << 2) | 424 | #define FLAG2_IS_DISCARDING (1 << 2) |
425 | #define FLAG2_DISABLE_ASPM_L1 (1 << 3) | ||
424 | 426 | ||
425 | #define E1000_RX_DESC_PS(R, i) \ | 427 | #define E1000_RX_DESC_PS(R, i) \ |
426 | (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) | 428 | (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) |
@@ -461,6 +463,7 @@ extern void e1000e_update_stats(struct e1000_adapter *adapter); | |||
461 | extern bool e1000e_has_link(struct e1000_adapter *adapter); | 463 | extern bool e1000e_has_link(struct e1000_adapter *adapter); |
462 | extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter); | 464 | extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter); |
463 | extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter); | 465 | extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter); |
466 | extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state); | ||
464 | 467 | ||
465 | extern unsigned int copybreak; | 468 | extern unsigned int copybreak; |
466 | 469 | ||
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 73d43c53015a..fb8fc7d1b50d 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -4283,6 +4283,14 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
4283 | return -EINVAL; | 4283 | return -EINVAL; |
4284 | } | 4284 | } |
4285 | 4285 | ||
4286 | /* 82573 Errata 17 */ | ||
4287 | if (((adapter->hw.mac.type == e1000_82573) || | ||
4288 | (adapter->hw.mac.type == e1000_82574)) && | ||
4289 | (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN)) { | ||
4290 | adapter->flags2 |= FLAG2_DISABLE_ASPM_L1; | ||
4291 | e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L1); | ||
4292 | } | ||
4293 | |||
4286 | while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) | 4294 | while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) |
4287 | msleep(1); | 4295 | msleep(1); |
4288 | /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */ | 4296 | /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */ |
@@ -4605,29 +4613,39 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep, | |||
4605 | } | 4613 | } |
4606 | } | 4614 | } |
4607 | 4615 | ||
4608 | static void e1000e_disable_l1aspm(struct pci_dev *pdev) | 4616 | #ifdef CONFIG_PCIEASPM |
4617 | static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) | ||
4618 | { | ||
4619 | pci_disable_link_state(pdev, state); | ||
4620 | } | ||
4621 | #else | ||
4622 | static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) | ||
4609 | { | 4623 | { |
4610 | int pos; | 4624 | int pos; |
4611 | u16 val; | 4625 | u16 reg16; |
4612 | 4626 | ||
4613 | /* | 4627 | /* |
4614 | * 82573 workaround - disable L1 ASPM on mobile chipsets | 4628 | * Both device and parent should have the same ASPM setting. |
4615 | * | 4629 | * Disable ASPM in downstream component first and then upstream. |
4616 | * L1 ASPM on various mobile (ich7) chipsets do not behave properly | ||
4617 | * resulting in lost data or garbage information on the pci-e link | ||
4618 | * level. This could result in (false) bad EEPROM checksum errors, | ||
4619 | * long ping times (up to 2s) or even a system freeze/hang. | ||
4620 | * | ||
4621 | * Unfortunately this feature saves about 1W power consumption when | ||
4622 | * active. | ||
4623 | */ | 4630 | */ |
4624 | pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); | 4631 | pos = pci_pcie_cap(pdev); |
4625 | pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val); | 4632 | pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, ®16); |
4626 | if (val & 0x2) { | 4633 | reg16 &= ~state; |
4627 | dev_warn(&pdev->dev, "Disabling L1 ASPM\n"); | 4634 | pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); |
4628 | val &= ~0x2; | 4635 | |
4629 | pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, val); | 4636 | pos = pci_pcie_cap(pdev->bus->self); |
4630 | } | 4637 | pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, ®16); |
4638 | reg16 &= ~state; | ||
4639 | pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16); | ||
4640 | } | ||
4641 | #endif | ||
4642 | void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) | ||
4643 | { | ||
4644 | dev_info(&pdev->dev, "Disabling ASPM %s %s\n", | ||
4645 | (state & PCIE_LINK_STATE_L0S) ? "L0s" : "", | ||
4646 | (state & PCIE_LINK_STATE_L1) ? "L1" : ""); | ||
4647 | |||
4648 | __e1000e_disable_aspm(pdev, state); | ||
4631 | } | 4649 | } |
4632 | 4650 | ||
4633 | #ifdef CONFIG_PM | 4651 | #ifdef CONFIG_PM |
@@ -4653,7 +4671,8 @@ static int e1000_resume(struct pci_dev *pdev) | |||
4653 | pci_set_power_state(pdev, PCI_D0); | 4671 | pci_set_power_state(pdev, PCI_D0); |
4654 | pci_restore_state(pdev); | 4672 | pci_restore_state(pdev); |
4655 | pci_save_state(pdev); | 4673 | pci_save_state(pdev); |
4656 | e1000e_disable_l1aspm(pdev); | 4674 | if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1) |
4675 | e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1); | ||
4657 | 4676 | ||
4658 | err = pci_enable_device_mem(pdev); | 4677 | err = pci_enable_device_mem(pdev); |
4659 | if (err) { | 4678 | if (err) { |
@@ -4795,7 +4814,8 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev) | |||
4795 | int err; | 4814 | int err; |
4796 | pci_ers_result_t result; | 4815 | pci_ers_result_t result; |
4797 | 4816 | ||
4798 | e1000e_disable_l1aspm(pdev); | 4817 | if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1) |
4818 | e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1); | ||
4799 | err = pci_enable_device_mem(pdev); | 4819 | err = pci_enable_device_mem(pdev); |
4800 | if (err) { | 4820 | if (err) { |
4801 | dev_err(&pdev->dev, | 4821 | dev_err(&pdev->dev, |
@@ -4889,13 +4909,6 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter) | |||
4889 | dev_warn(&adapter->pdev->dev, | 4909 | dev_warn(&adapter->pdev->dev, |
4890 | "Warning: detected DSPD enabled in EEPROM\n"); | 4910 | "Warning: detected DSPD enabled in EEPROM\n"); |
4891 | } | 4911 | } |
4892 | |||
4893 | ret_val = e1000_read_nvm(hw, NVM_INIT_3GIO_3, 1, &buf); | ||
4894 | if (!ret_val && (le16_to_cpu(buf) & (3 << 2))) { | ||
4895 | /* ASPM enable */ | ||
4896 | dev_warn(&adapter->pdev->dev, | ||
4897 | "Warning: detected ASPM enabled in EEPROM\n"); | ||
4898 | } | ||
4899 | } | 4912 | } |
4900 | 4913 | ||
4901 | static const struct net_device_ops e1000e_netdev_ops = { | 4914 | static const struct net_device_ops e1000e_netdev_ops = { |
@@ -4944,7 +4957,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
4944 | u16 eeprom_data = 0; | 4957 | u16 eeprom_data = 0; |
4945 | u16 eeprom_apme_mask = E1000_EEPROM_APME; | 4958 | u16 eeprom_apme_mask = E1000_EEPROM_APME; |
4946 | 4959 | ||
4947 | e1000e_disable_l1aspm(pdev); | 4960 | if (ei->flags2 & FLAG2_DISABLE_ASPM_L1) |
4961 | e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1); | ||
4948 | 4962 | ||
4949 | err = pci_enable_device_mem(pdev); | 4963 | err = pci_enable_device_mem(pdev); |
4950 | if (err) | 4964 | if (err) |
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c index d5160edf2fcf..3acac5f930c8 100644 --- a/drivers/net/fsl_pq_mdio.c +++ b/drivers/net/fsl_pq_mdio.c | |||
@@ -205,8 +205,6 @@ static int fsl_pq_mdio_find_free(struct mii_bus *new_bus) | |||
205 | static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) | 205 | static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) |
206 | { | 206 | { |
207 | struct gfar __iomem *enet_regs; | 207 | struct gfar __iomem *enet_regs; |
208 | u32 __iomem *ioremap_tbipa; | ||
209 | u64 addr, size; | ||
210 | 208 | ||
211 | /* | 209 | /* |
212 | * This is mildly evil, but so is our hardware for doing this. | 210 | * This is mildly evil, but so is our hardware for doing this. |
@@ -220,9 +218,7 @@ static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct devi | |||
220 | return &enet_regs->tbipa; | 218 | return &enet_regs->tbipa; |
221 | } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || | 219 | } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || |
222 | of_device_is_compatible(np, "fsl,etsec2-tbi")) { | 220 | of_device_is_compatible(np, "fsl,etsec2-tbi")) { |
223 | addr = of_translate_address(np, of_get_address(np, 1, &size, NULL)); | 221 | return of_iomap(np, 1); |
224 | ioremap_tbipa = ioremap(addr, size); | ||
225 | return ioremap_tbipa; | ||
226 | } else | 222 | } else |
227 | return NULL; | 223 | return NULL; |
228 | } | 224 | } |
@@ -279,6 +275,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev, | |||
279 | u32 __iomem *tbipa; | 275 | u32 __iomem *tbipa; |
280 | struct mii_bus *new_bus; | 276 | struct mii_bus *new_bus; |
281 | int tbiaddr = -1; | 277 | int tbiaddr = -1; |
278 | const u32 *addrp; | ||
282 | u64 addr = 0, size = 0; | 279 | u64 addr = 0, size = 0; |
283 | int err = 0; | 280 | int err = 0; |
284 | 281 | ||
@@ -297,8 +294,19 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev, | |||
297 | new_bus->priv = priv; | 294 | new_bus->priv = priv; |
298 | fsl_pq_mdio_bus_name(new_bus->id, np); | 295 | fsl_pq_mdio_bus_name(new_bus->id, np); |
299 | 296 | ||
297 | addrp = of_get_address(np, 0, &size, NULL); | ||
298 | if (!addrp) { | ||
299 | err = -EINVAL; | ||
300 | goto err_free_bus; | ||
301 | } | ||
302 | |||
300 | /* Set the PHY base address */ | 303 | /* Set the PHY base address */ |
301 | addr = of_translate_address(np, of_get_address(np, 0, &size, NULL)); | 304 | addr = of_translate_address(np, addrp); |
305 | if (addr == OF_BAD_ADDR) { | ||
306 | err = -EINVAL; | ||
307 | goto err_free_bus; | ||
308 | } | ||
309 | |||
302 | map = ioremap(addr, size); | 310 | map = ioremap(addr, size); |
303 | if (!map) { | 311 | if (!map) { |
304 | err = -ENOMEM; | 312 | err = -ENOMEM; |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 080d1cea5b26..4e97ca182997 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -549,12 +549,8 @@ static int gfar_parse_group(struct device_node *np, | |||
549 | struct gfar_private *priv, const char *model) | 549 | struct gfar_private *priv, const char *model) |
550 | { | 550 | { |
551 | u32 *queue_mask; | 551 | u32 *queue_mask; |
552 | u64 addr, size; | ||
553 | |||
554 | addr = of_translate_address(np, | ||
555 | of_get_address(np, 0, &size, NULL)); | ||
556 | priv->gfargrp[priv->num_grps].regs = ioremap(addr, size); | ||
557 | 552 | ||
553 | priv->gfargrp[priv->num_grps].regs = of_iomap(np, 0); | ||
558 | if (!priv->gfargrp[priv->num_grps].regs) | 554 | if (!priv->gfargrp[priv->num_grps].regs) |
559 | return -ENOMEM; | 555 | return -ENOMEM; |
560 | 556 | ||
@@ -1515,9 +1511,9 @@ static void gfar_halt_nodisable(struct net_device *dev) | |||
1515 | tempval |= (DMACTRL_GRS | DMACTRL_GTS); | 1511 | tempval |= (DMACTRL_GRS | DMACTRL_GTS); |
1516 | gfar_write(®s->dmactrl, tempval); | 1512 | gfar_write(®s->dmactrl, tempval); |
1517 | 1513 | ||
1518 | while (!(gfar_read(®s->ievent) & | 1514 | spin_event_timeout(((gfar_read(®s->ievent) & |
1519 | (IEVENT_GRSC | IEVENT_GTSC))) | 1515 | (IEVENT_GRSC | IEVENT_GTSC)) == |
1520 | cpu_relax(); | 1516 | (IEVENT_GRSC | IEVENT_GTSC)), -1, 0); |
1521 | } | 1517 | } |
1522 | } | 1518 | } |
1523 | 1519 | ||
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c index b405a00817c6..12fc0e7ba2ca 100644 --- a/drivers/net/ixgbe/ixgbe_82599.c +++ b/drivers/net/ixgbe/ixgbe_82599.c | |||
@@ -39,6 +39,8 @@ | |||
39 | #define IXGBE_82599_MC_TBL_SIZE 128 | 39 | #define IXGBE_82599_MC_TBL_SIZE 128 |
40 | #define IXGBE_82599_VFT_TBL_SIZE 128 | 40 | #define IXGBE_82599_VFT_TBL_SIZE 128 |
41 | 41 | ||
42 | void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw); | ||
43 | void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw); | ||
42 | void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw); | 44 | void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw); |
43 | s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, | 45 | s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, |
44 | ixgbe_link_speed speed, | 46 | ixgbe_link_speed speed, |
@@ -69,8 +71,14 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw) | |||
69 | if (hw->phy.multispeed_fiber) { | 71 | if (hw->phy.multispeed_fiber) { |
70 | /* Set up dual speed SFP+ support */ | 72 | /* Set up dual speed SFP+ support */ |
71 | mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber; | 73 | mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber; |
74 | mac->ops.disable_tx_laser = | ||
75 | &ixgbe_disable_tx_laser_multispeed_fiber; | ||
76 | mac->ops.enable_tx_laser = | ||
77 | &ixgbe_enable_tx_laser_multispeed_fiber; | ||
72 | mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber; | 78 | mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber; |
73 | } else { | 79 | } else { |
80 | mac->ops.disable_tx_laser = NULL; | ||
81 | mac->ops.enable_tx_laser = NULL; | ||
74 | mac->ops.flap_tx_laser = NULL; | 82 | mac->ops.flap_tx_laser = NULL; |
75 | if ((mac->ops.get_media_type(hw) == | 83 | if ((mac->ops.get_media_type(hw) == |
76 | ixgbe_media_type_backplane) && | 84 | ixgbe_media_type_backplane) && |
@@ -415,6 +423,44 @@ s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw, | |||
415 | return status; | 423 | return status; |
416 | } | 424 | } |
417 | 425 | ||
426 | /** | ||
427 | * ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser | ||
428 | * @hw: pointer to hardware structure | ||
429 | * | ||
430 | * The base drivers may require better control over SFP+ module | ||
431 | * PHY states. This includes selectively shutting down the Tx | ||
432 | * laser on the PHY, effectively halting physical link. | ||
433 | **/ | ||
434 | void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) | ||
435 | { | ||
436 | u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP); | ||
437 | |||
438 | /* Disable tx laser; allow 100us to go dark per spec */ | ||
439 | esdp_reg |= IXGBE_ESDP_SDP3; | ||
440 | IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); | ||
441 | IXGBE_WRITE_FLUSH(hw); | ||
442 | udelay(100); | ||
443 | } | ||
444 | |||
445 | /** | ||
446 | * ixgbe_enable_tx_laser_multispeed_fiber - Enable Tx laser | ||
447 | * @hw: pointer to hardware structure | ||
448 | * | ||
449 | * The base drivers may require better control over SFP+ module | ||
450 | * PHY states. This includes selectively turning on the Tx | ||
451 | * laser on the PHY, effectively starting physical link. | ||
452 | **/ | ||
453 | void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) | ||
454 | { | ||
455 | u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP); | ||
456 | |||
457 | /* Enable tx laser; allow 100ms to light up */ | ||
458 | esdp_reg &= ~IXGBE_ESDP_SDP3; | ||
459 | IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); | ||
460 | IXGBE_WRITE_FLUSH(hw); | ||
461 | msleep(100); | ||
462 | } | ||
463 | |||
418 | /** | 464 | /** |
419 | * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser | 465 | * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser |
420 | * @hw: pointer to hardware structure | 466 | * @hw: pointer to hardware structure |
@@ -429,23 +475,11 @@ s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw, | |||
429 | **/ | 475 | **/ |
430 | void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) | 476 | void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) |
431 | { | 477 | { |
432 | u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP); | ||
433 | |||
434 | hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n"); | 478 | hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n"); |
435 | 479 | ||
436 | if (hw->mac.autotry_restart) { | 480 | if (hw->mac.autotry_restart) { |
437 | /* Disable tx laser; allow 100us to go dark per spec */ | 481 | ixgbe_disable_tx_laser_multispeed_fiber(hw); |
438 | esdp_reg |= IXGBE_ESDP_SDP3; | 482 | ixgbe_enable_tx_laser_multispeed_fiber(hw); |
439 | IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); | ||
440 | IXGBE_WRITE_FLUSH(hw); | ||
441 | udelay(100); | ||
442 | |||
443 | /* Enable tx laser; allow 100ms to light up */ | ||
444 | esdp_reg &= ~IXGBE_ESDP_SDP3; | ||
445 | IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); | ||
446 | IXGBE_WRITE_FLUSH(hw); | ||
447 | msleep(100); | ||
448 | |||
449 | hw->mac.autotry_restart = false; | 483 | hw->mac.autotry_restart = false; |
450 | } | 484 | } |
451 | } | 485 | } |
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index 8f677cb86290..6c00ee493a3b 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -2982,6 +2982,10 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter) | |||
2982 | else | 2982 | else |
2983 | ixgbe_configure_msi_and_legacy(adapter); | 2983 | ixgbe_configure_msi_and_legacy(adapter); |
2984 | 2984 | ||
2985 | /* enable the optics */ | ||
2986 | if (hw->phy.multispeed_fiber) | ||
2987 | hw->mac.ops.enable_tx_laser(hw); | ||
2988 | |||
2985 | clear_bit(__IXGBE_DOWN, &adapter->state); | 2989 | clear_bit(__IXGBE_DOWN, &adapter->state); |
2986 | ixgbe_napi_enable_all(adapter); | 2990 | ixgbe_napi_enable_all(adapter); |
2987 | 2991 | ||
@@ -3243,6 +3247,10 @@ void ixgbe_down(struct ixgbe_adapter *adapter) | |||
3243 | /* signal that we are down to the interrupt handler */ | 3247 | /* signal that we are down to the interrupt handler */ |
3244 | set_bit(__IXGBE_DOWN, &adapter->state); | 3248 | set_bit(__IXGBE_DOWN, &adapter->state); |
3245 | 3249 | ||
3250 | /* power down the optics */ | ||
3251 | if (hw->phy.multispeed_fiber) | ||
3252 | hw->mac.ops.disable_tx_laser(hw); | ||
3253 | |||
3246 | /* disable receive for all VFs and wait one second */ | 3254 | /* disable receive for all VFs and wait one second */ |
3247 | if (adapter->num_vfs) { | 3255 | if (adapter->num_vfs) { |
3248 | /* ping all the active vfs to let them know we are going down */ | 3256 | /* ping all the active vfs to let them know we are going down */ |
@@ -6253,6 +6261,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, | |||
6253 | goto err_eeprom; | 6261 | goto err_eeprom; |
6254 | } | 6262 | } |
6255 | 6263 | ||
6264 | /* power down the optics */ | ||
6265 | if (hw->phy.multispeed_fiber) | ||
6266 | hw->mac.ops.disable_tx_laser(hw); | ||
6267 | |||
6256 | init_timer(&adapter->watchdog_timer); | 6268 | init_timer(&adapter->watchdog_timer); |
6257 | adapter->watchdog_timer.function = &ixgbe_watchdog; | 6269 | adapter->watchdog_timer.function = &ixgbe_watchdog; |
6258 | adapter->watchdog_timer.data = (unsigned long)adapter; | 6270 | adapter->watchdog_timer.data = (unsigned long)adapter; |
@@ -6400,16 +6412,6 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) | |||
6400 | del_timer_sync(&adapter->sfp_timer); | 6412 | del_timer_sync(&adapter->sfp_timer); |
6401 | cancel_work_sync(&adapter->watchdog_task); | 6413 | cancel_work_sync(&adapter->watchdog_task); |
6402 | cancel_work_sync(&adapter->sfp_task); | 6414 | cancel_work_sync(&adapter->sfp_task); |
6403 | if (adapter->hw.phy.multispeed_fiber) { | ||
6404 | struct ixgbe_hw *hw = &adapter->hw; | ||
6405 | /* | ||
6406 | * Restart clause 37 autoneg, disable and re-enable | ||
6407 | * the tx laser, to clear & alert the link partner | ||
6408 | * that it needs to restart autotry | ||
6409 | */ | ||
6410 | hw->mac.autotry_restart = true; | ||
6411 | hw->mac.ops.flap_tx_laser(hw); | ||
6412 | } | ||
6413 | cancel_work_sync(&adapter->multispeed_fiber_task); | 6415 | cancel_work_sync(&adapter->multispeed_fiber_task); |
6414 | cancel_work_sync(&adapter->sfp_config_module_task); | 6416 | cancel_work_sync(&adapter->sfp_config_module_task); |
6415 | if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || | 6417 | if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || |
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h index 4ec6dc1a5b75..534affcc38ca 100644 --- a/drivers/net/ixgbe/ixgbe_type.h +++ b/drivers/net/ixgbe/ixgbe_type.h | |||
@@ -2398,6 +2398,8 @@ struct ixgbe_mac_operations { | |||
2398 | s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); | 2398 | s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); |
2399 | 2399 | ||
2400 | /* Link */ | 2400 | /* Link */ |
2401 | void (*disable_tx_laser)(struct ixgbe_hw *); | ||
2402 | void (*enable_tx_laser)(struct ixgbe_hw *); | ||
2401 | void (*flap_tx_laser)(struct ixgbe_hw *); | 2403 | void (*flap_tx_laser)(struct ixgbe_hw *); |
2402 | s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool); | 2404 | s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool); |
2403 | s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool); | 2405 | s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool); |
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c index 13cc1ca261d9..9e9f9b349766 100644 --- a/drivers/net/ks8851.c +++ b/drivers/net/ks8851.c | |||
@@ -722,12 +722,14 @@ static void ks8851_tx_work(struct work_struct *work) | |||
722 | txb = skb_dequeue(&ks->txq); | 722 | txb = skb_dequeue(&ks->txq); |
723 | last = skb_queue_empty(&ks->txq); | 723 | last = skb_queue_empty(&ks->txq); |
724 | 724 | ||
725 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); | 725 | if (txb != NULL) { |
726 | ks8851_wrpkt(ks, txb, last); | 726 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); |
727 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr); | 727 | ks8851_wrpkt(ks, txb, last); |
728 | ks8851_wrreg16(ks, KS_TXQCR, TXQCR_METFE); | 728 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr); |
729 | ks8851_wrreg16(ks, KS_TXQCR, TXQCR_METFE); | ||
729 | 730 | ||
730 | ks8851_done_tx(ks, txb); | 731 | ks8851_done_tx(ks, txb); |
732 | } | ||
731 | } | 733 | } |
732 | 734 | ||
733 | mutex_unlock(&ks->lock); | 735 | mutex_unlock(&ks->lock); |
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 3d1d3a7b7ed3..757f87bb1db3 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c | |||
@@ -781,8 +781,13 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb, | |||
781 | inw(ioaddr + EL3_STATUS)); | 781 | inw(ioaddr + EL3_STATUS)); |
782 | 782 | ||
783 | spin_lock_irqsave(&lp->window_lock, flags); | 783 | spin_lock_irqsave(&lp->window_lock, flags); |
784 | |||
785 | dev->stats.tx_bytes += skb->len; | ||
786 | |||
787 | /* Put out the doubleword header... */ | ||
784 | outw(skb->len, ioaddr + TX_FIFO); | 788 | outw(skb->len, ioaddr + TX_FIFO); |
785 | outw(0, ioaddr + TX_FIFO); | 789 | outw(0, ioaddr + TX_FIFO); |
790 | /* ... and the packet rounded to a doubleword. */ | ||
786 | outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2); | 791 | outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2); |
787 | 792 | ||
788 | dev->trans_start = jiffies; | 793 | dev->trans_start = jiffies; |
@@ -1021,8 +1026,6 @@ static void update_stats(struct net_device *dev) | |||
1021 | /* BadSSD */ inb(ioaddr + 12); | 1026 | /* BadSSD */ inb(ioaddr + 12); |
1022 | up = inb(ioaddr + 13); | 1027 | up = inb(ioaddr + 13); |
1023 | 1028 | ||
1024 | dev->stats.tx_bytes += tx + ((up & 0xf0) << 12); | ||
1025 | |||
1026 | EL3WINDOW(1); | 1029 | EL3WINDOW(1); |
1027 | } | 1030 | } |
1028 | 1031 | ||
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index fd9d6e34fda4..ccc553782a0d 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -1804,23 +1804,30 @@ static void media_check(u_long arg) | |||
1804 | SMC_SELECT_BANK(1); | 1804 | SMC_SELECT_BANK(1); |
1805 | media |= (inw(ioaddr + CONFIG) & CFG_AUI_SELECT) ? 2 : 1; | 1805 | media |= (inw(ioaddr + CONFIG) & CFG_AUI_SELECT) ? 2 : 1; |
1806 | 1806 | ||
1807 | SMC_SELECT_BANK(saved_bank); | ||
1808 | spin_unlock_irqrestore(&smc->lock, flags); | ||
1809 | |||
1807 | /* Check for pending interrupt with watchdog flag set: with | 1810 | /* Check for pending interrupt with watchdog flag set: with |
1808 | this, we can limp along even if the interrupt is blocked */ | 1811 | this, we can limp along even if the interrupt is blocked */ |
1809 | if (smc->watchdog++ && ((i>>8) & i)) { | 1812 | if (smc->watchdog++ && ((i>>8) & i)) { |
1810 | if (!smc->fast_poll) | 1813 | if (!smc->fast_poll) |
1811 | printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name); | 1814 | printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name); |
1815 | local_irq_save(flags); | ||
1812 | smc_interrupt(dev->irq, dev); | 1816 | smc_interrupt(dev->irq, dev); |
1817 | local_irq_restore(flags); | ||
1813 | smc->fast_poll = HZ; | 1818 | smc->fast_poll = HZ; |
1814 | } | 1819 | } |
1815 | if (smc->fast_poll) { | 1820 | if (smc->fast_poll) { |
1816 | smc->fast_poll--; | 1821 | smc->fast_poll--; |
1817 | smc->media.expires = jiffies + HZ/100; | 1822 | smc->media.expires = jiffies + HZ/100; |
1818 | add_timer(&smc->media); | 1823 | add_timer(&smc->media); |
1819 | SMC_SELECT_BANK(saved_bank); | ||
1820 | spin_unlock_irqrestore(&smc->lock, flags); | ||
1821 | return; | 1824 | return; |
1822 | } | 1825 | } |
1823 | 1826 | ||
1827 | spin_lock_irqsave(&smc->lock, flags); | ||
1828 | |||
1829 | saved_bank = inw(ioaddr + BANK_SELECT); | ||
1830 | |||
1824 | if (smc->cfg & CFG_MII_SELECT) { | 1831 | if (smc->cfg & CFG_MII_SELECT) { |
1825 | if (smc->mii_if.phy_id < 0) | 1832 | if (smc->mii_if.phy_id < 0) |
1826 | goto reschedule; | 1833 | goto reschedule; |
@@ -1978,15 +1985,16 @@ static int smc_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
1978 | unsigned int ioaddr = dev->base_addr; | 1985 | unsigned int ioaddr = dev->base_addr; |
1979 | u16 saved_bank = inw(ioaddr + BANK_SELECT); | 1986 | u16 saved_bank = inw(ioaddr + BANK_SELECT); |
1980 | int ret; | 1987 | int ret; |
1988 | unsigned long flags; | ||
1981 | 1989 | ||
1982 | spin_lock_irq(&smc->lock); | 1990 | spin_lock_irqsave(&smc->lock, flags); |
1983 | SMC_SELECT_BANK(3); | 1991 | SMC_SELECT_BANK(3); |
1984 | if (smc->cfg & CFG_MII_SELECT) | 1992 | if (smc->cfg & CFG_MII_SELECT) |
1985 | ret = mii_ethtool_gset(&smc->mii_if, ecmd); | 1993 | ret = mii_ethtool_gset(&smc->mii_if, ecmd); |
1986 | else | 1994 | else |
1987 | ret = smc_netdev_get_ecmd(dev, ecmd); | 1995 | ret = smc_netdev_get_ecmd(dev, ecmd); |
1988 | SMC_SELECT_BANK(saved_bank); | 1996 | SMC_SELECT_BANK(saved_bank); |
1989 | spin_unlock_irq(&smc->lock); | 1997 | spin_unlock_irqrestore(&smc->lock, flags); |
1990 | return ret; | 1998 | return ret; |
1991 | } | 1999 | } |
1992 | 2000 | ||
@@ -1996,15 +2004,16 @@ static int smc_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
1996 | unsigned int ioaddr = dev->base_addr; | 2004 | unsigned int ioaddr = dev->base_addr; |
1997 | u16 saved_bank = inw(ioaddr + BANK_SELECT); | 2005 | u16 saved_bank = inw(ioaddr + BANK_SELECT); |
1998 | int ret; | 2006 | int ret; |
2007 | unsigned long flags; | ||
1999 | 2008 | ||
2000 | spin_lock_irq(&smc->lock); | 2009 | spin_lock_irqsave(&smc->lock, flags); |
2001 | SMC_SELECT_BANK(3); | 2010 | SMC_SELECT_BANK(3); |
2002 | if (smc->cfg & CFG_MII_SELECT) | 2011 | if (smc->cfg & CFG_MII_SELECT) |
2003 | ret = mii_ethtool_sset(&smc->mii_if, ecmd); | 2012 | ret = mii_ethtool_sset(&smc->mii_if, ecmd); |
2004 | else | 2013 | else |
2005 | ret = smc_netdev_set_ecmd(dev, ecmd); | 2014 | ret = smc_netdev_set_ecmd(dev, ecmd); |
2006 | SMC_SELECT_BANK(saved_bank); | 2015 | SMC_SELECT_BANK(saved_bank); |
2007 | spin_unlock_irq(&smc->lock); | 2016 | spin_unlock_irqrestore(&smc->lock, flags); |
2008 | return ret; | 2017 | return ret; |
2009 | } | 2018 | } |
2010 | 2019 | ||
@@ -2014,12 +2023,13 @@ static u32 smc_get_link(struct net_device *dev) | |||
2014 | unsigned int ioaddr = dev->base_addr; | 2023 | unsigned int ioaddr = dev->base_addr; |
2015 | u16 saved_bank = inw(ioaddr + BANK_SELECT); | 2024 | u16 saved_bank = inw(ioaddr + BANK_SELECT); |
2016 | u32 ret; | 2025 | u32 ret; |
2026 | unsigned long flags; | ||
2017 | 2027 | ||
2018 | spin_lock_irq(&smc->lock); | 2028 | spin_lock_irqsave(&smc->lock, flags); |
2019 | SMC_SELECT_BANK(3); | 2029 | SMC_SELECT_BANK(3); |
2020 | ret = smc_link_ok(dev); | 2030 | ret = smc_link_ok(dev); |
2021 | SMC_SELECT_BANK(saved_bank); | 2031 | SMC_SELECT_BANK(saved_bank); |
2022 | spin_unlock_irq(&smc->lock); | 2032 | spin_unlock_irqrestore(&smc->lock, flags); |
2023 | return ret; | 2033 | return ret; |
2024 | } | 2034 | } |
2025 | 2035 | ||
@@ -2056,16 +2066,17 @@ static int smc_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) | |||
2056 | int rc = 0; | 2066 | int rc = 0; |
2057 | u16 saved_bank; | 2067 | u16 saved_bank; |
2058 | unsigned int ioaddr = dev->base_addr; | 2068 | unsigned int ioaddr = dev->base_addr; |
2069 | unsigned long flags; | ||
2059 | 2070 | ||
2060 | if (!netif_running(dev)) | 2071 | if (!netif_running(dev)) |
2061 | return -EINVAL; | 2072 | return -EINVAL; |
2062 | 2073 | ||
2063 | spin_lock_irq(&smc->lock); | 2074 | spin_lock_irqsave(&smc->lock, flags); |
2064 | saved_bank = inw(ioaddr + BANK_SELECT); | 2075 | saved_bank = inw(ioaddr + BANK_SELECT); |
2065 | SMC_SELECT_BANK(3); | 2076 | SMC_SELECT_BANK(3); |
2066 | rc = generic_mii_ioctl(&smc->mii_if, mii, cmd, NULL); | 2077 | rc = generic_mii_ioctl(&smc->mii_if, mii, cmd, NULL); |
2067 | SMC_SELECT_BANK(saved_bank); | 2078 | SMC_SELECT_BANK(saved_bank); |
2068 | spin_unlock_irq(&smc->lock); | 2079 | spin_unlock_irqrestore(&smc->lock, flags); |
2069 | return rc; | 2080 | return rc; |
2070 | } | 2081 | } |
2071 | 2082 | ||
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index dbb1f5a1824c..4748c21eb72e 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -2759,6 +2759,7 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev, | |||
2759 | { | 2759 | { |
2760 | iounmap(ioaddr); | 2760 | iounmap(ioaddr); |
2761 | pci_release_regions(pdev); | 2761 | pci_release_regions(pdev); |
2762 | pci_clear_mwi(pdev); | ||
2762 | pci_disable_device(pdev); | 2763 | pci_disable_device(pdev); |
2763 | free_netdev(dev); | 2764 | free_netdev(dev); |
2764 | } | 2765 | } |
@@ -2825,8 +2826,13 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) | |||
2825 | spin_lock_irq(&tp->lock); | 2826 | spin_lock_irq(&tp->lock); |
2826 | 2827 | ||
2827 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 2828 | RTL_W8(Cfg9346, Cfg9346_Unlock); |
2829 | |||
2828 | RTL_W32(MAC4, high); | 2830 | RTL_W32(MAC4, high); |
2831 | RTL_R32(MAC4); | ||
2832 | |||
2829 | RTL_W32(MAC0, low); | 2833 | RTL_W32(MAC0, low); |
2834 | RTL_R32(MAC0); | ||
2835 | |||
2830 | RTL_W8(Cfg9346, Cfg9346_Lock); | 2836 | RTL_W8(Cfg9346, Cfg9346_Lock); |
2831 | 2837 | ||
2832 | spin_unlock_irq(&tp->lock); | 2838 | spin_unlock_irq(&tp->lock); |
@@ -3014,9 +3020,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3014 | goto err_out_free_dev_1; | 3020 | goto err_out_free_dev_1; |
3015 | } | 3021 | } |
3016 | 3022 | ||
3017 | rc = pci_set_mwi(pdev); | 3023 | if (pci_set_mwi(pdev) < 0) |
3018 | if (rc < 0) | 3024 | netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n"); |
3019 | goto err_out_disable_2; | ||
3020 | 3025 | ||
3021 | /* make sure PCI base addr 1 is MMIO */ | 3026 | /* make sure PCI base addr 1 is MMIO */ |
3022 | if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { | 3027 | if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { |
@@ -3024,7 +3029,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3024 | "region #%d not an MMIO resource, aborting\n", | 3029 | "region #%d not an MMIO resource, aborting\n", |
3025 | region); | 3030 | region); |
3026 | rc = -ENODEV; | 3031 | rc = -ENODEV; |
3027 | goto err_out_mwi_3; | 3032 | goto err_out_mwi_2; |
3028 | } | 3033 | } |
3029 | 3034 | ||
3030 | /* check for weird/broken PCI region reporting */ | 3035 | /* check for weird/broken PCI region reporting */ |
@@ -3032,13 +3037,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3032 | netif_err(tp, probe, dev, | 3037 | netif_err(tp, probe, dev, |
3033 | "Invalid PCI region size(s), aborting\n"); | 3038 | "Invalid PCI region size(s), aborting\n"); |
3034 | rc = -ENODEV; | 3039 | rc = -ENODEV; |
3035 | goto err_out_mwi_3; | 3040 | goto err_out_mwi_2; |
3036 | } | 3041 | } |
3037 | 3042 | ||
3038 | rc = pci_request_regions(pdev, MODULENAME); | 3043 | rc = pci_request_regions(pdev, MODULENAME); |
3039 | if (rc < 0) { | 3044 | if (rc < 0) { |
3040 | netif_err(tp, probe, dev, "could not request regions\n"); | 3045 | netif_err(tp, probe, dev, "could not request regions\n"); |
3041 | goto err_out_mwi_3; | 3046 | goto err_out_mwi_2; |
3042 | } | 3047 | } |
3043 | 3048 | ||
3044 | tp->cp_cmd = PCIMulRW | RxChkSum; | 3049 | tp->cp_cmd = PCIMulRW | RxChkSum; |
@@ -3051,7 +3056,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3051 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | 3056 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
3052 | if (rc < 0) { | 3057 | if (rc < 0) { |
3053 | netif_err(tp, probe, dev, "DMA configuration failed\n"); | 3058 | netif_err(tp, probe, dev, "DMA configuration failed\n"); |
3054 | goto err_out_free_res_4; | 3059 | goto err_out_free_res_3; |
3055 | } | 3060 | } |
3056 | } | 3061 | } |
3057 | 3062 | ||
@@ -3060,7 +3065,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3060 | if (!ioaddr) { | 3065 | if (!ioaddr) { |
3061 | netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); | 3066 | netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); |
3062 | rc = -EIO; | 3067 | rc = -EIO; |
3063 | goto err_out_free_res_4; | 3068 | goto err_out_free_res_3; |
3064 | } | 3069 | } |
3065 | 3070 | ||
3066 | tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); | 3071 | tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); |
@@ -3102,7 +3107,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3102 | if (i == ARRAY_SIZE(rtl_chip_info)) { | 3107 | if (i == ARRAY_SIZE(rtl_chip_info)) { |
3103 | dev_err(&pdev->dev, | 3108 | dev_err(&pdev->dev, |
3104 | "driver bug, MAC version not found in rtl_chip_info\n"); | 3109 | "driver bug, MAC version not found in rtl_chip_info\n"); |
3105 | goto err_out_msi_5; | 3110 | goto err_out_msi_4; |
3106 | } | 3111 | } |
3107 | tp->chipset = i; | 3112 | tp->chipset = i; |
3108 | 3113 | ||
@@ -3167,7 +3172,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3167 | 3172 | ||
3168 | rc = register_netdev(dev); | 3173 | rc = register_netdev(dev); |
3169 | if (rc < 0) | 3174 | if (rc < 0) |
3170 | goto err_out_msi_5; | 3175 | goto err_out_msi_4; |
3171 | 3176 | ||
3172 | pci_set_drvdata(pdev, dev); | 3177 | pci_set_drvdata(pdev, dev); |
3173 | 3178 | ||
@@ -3190,14 +3195,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3190 | out: | 3195 | out: |
3191 | return rc; | 3196 | return rc; |
3192 | 3197 | ||
3193 | err_out_msi_5: | 3198 | err_out_msi_4: |
3194 | rtl_disable_msi(pdev, tp); | 3199 | rtl_disable_msi(pdev, tp); |
3195 | iounmap(ioaddr); | 3200 | iounmap(ioaddr); |
3196 | err_out_free_res_4: | 3201 | err_out_free_res_3: |
3197 | pci_release_regions(pdev); | 3202 | pci_release_regions(pdev); |
3198 | err_out_mwi_3: | 3203 | err_out_mwi_2: |
3199 | pci_clear_mwi(pdev); | 3204 | pci_clear_mwi(pdev); |
3200 | err_out_disable_2: | ||
3201 | pci_disable_device(pdev); | 3205 | pci_disable_device(pdev); |
3202 | err_out_free_dev_1: | 3206 | err_out_free_dev_1: |
3203 | free_netdev(dev); | 3207 | free_netdev(dev); |
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c index 6486657c47b8..649a264d6a81 100644 --- a/drivers/net/sfc/efx.c +++ b/drivers/net/sfc/efx.c | |||
@@ -1861,6 +1861,7 @@ out: | |||
1861 | } | 1861 | } |
1862 | 1862 | ||
1863 | if (disabled) { | 1863 | if (disabled) { |
1864 | dev_close(efx->net_dev); | ||
1864 | EFX_ERR(efx, "has been disabled\n"); | 1865 | EFX_ERR(efx, "has been disabled\n"); |
1865 | efx->state = STATE_DISABLED; | 1866 | efx->state = STATE_DISABLED; |
1866 | } else { | 1867 | } else { |
@@ -1884,8 +1885,7 @@ static void efx_reset_work(struct work_struct *data) | |||
1884 | } | 1885 | } |
1885 | 1886 | ||
1886 | rtnl_lock(); | 1887 | rtnl_lock(); |
1887 | if (efx_reset(efx, efx->reset_pending)) | 1888 | (void)efx_reset(efx, efx->reset_pending); |
1888 | dev_close(efx->net_dev); | ||
1889 | rtnl_unlock(); | 1889 | rtnl_unlock(); |
1890 | } | 1890 | } |
1891 | 1891 | ||
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index d294d66fd600..08278e7302b3 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -1320,7 +1320,9 @@ static int falcon_probe_nvconfig(struct efx_nic *efx) | |||
1320 | 1320 | ||
1321 | EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mdio.prtad); | 1321 | EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mdio.prtad); |
1322 | 1322 | ||
1323 | falcon_probe_board(efx, board_rev); | 1323 | rc = falcon_probe_board(efx, board_rev); |
1324 | if (rc) | ||
1325 | goto fail2; | ||
1324 | 1326 | ||
1325 | kfree(nvconfig); | 1327 | kfree(nvconfig); |
1326 | return 0; | 1328 | return 0; |
diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c index 5712fddd72f2..c7a933a3292e 100644 --- a/drivers/net/sfc/falcon_boards.c +++ b/drivers/net/sfc/falcon_boards.c | |||
@@ -728,15 +728,7 @@ static const struct falcon_board_type board_types[] = { | |||
728 | }, | 728 | }, |
729 | }; | 729 | }; |
730 | 730 | ||
731 | static const struct falcon_board_type falcon_dummy_board = { | 731 | int falcon_probe_board(struct efx_nic *efx, u16 revision_info) |
732 | .init = efx_port_dummy_op_int, | ||
733 | .init_phy = efx_port_dummy_op_void, | ||
734 | .fini = efx_port_dummy_op_void, | ||
735 | .set_id_led = efx_port_dummy_op_set_id_led, | ||
736 | .monitor = efx_port_dummy_op_int, | ||
737 | }; | ||
738 | |||
739 | void falcon_probe_board(struct efx_nic *efx, u16 revision_info) | ||
740 | { | 732 | { |
741 | struct falcon_board *board = falcon_board(efx); | 733 | struct falcon_board *board = falcon_board(efx); |
742 | u8 type_id = FALCON_BOARD_TYPE(revision_info); | 734 | u8 type_id = FALCON_BOARD_TYPE(revision_info); |
@@ -754,8 +746,9 @@ void falcon_probe_board(struct efx_nic *efx, u16 revision_info) | |||
754 | (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) | 746 | (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) |
755 | ? board->type->ref_model : board->type->gen_type, | 747 | ? board->type->ref_model : board->type->gen_type, |
756 | 'A' + board->major, board->minor); | 748 | 'A' + board->major, board->minor); |
749 | return 0; | ||
757 | } else { | 750 | } else { |
758 | EFX_ERR(efx, "unknown board type %d\n", type_id); | 751 | EFX_ERR(efx, "unknown board type %d\n", type_id); |
759 | board->type = &falcon_dummy_board; | 752 | return -ENODEV; |
760 | } | 753 | } |
761 | } | 754 | } |
diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h index 9351c0331a47..3166bafdfbef 100644 --- a/drivers/net/sfc/nic.h +++ b/drivers/net/sfc/nic.h | |||
@@ -156,7 +156,7 @@ extern struct efx_nic_type siena_a0_nic_type; | |||
156 | ************************************************************************** | 156 | ************************************************************************** |
157 | */ | 157 | */ |
158 | 158 | ||
159 | extern void falcon_probe_board(struct efx_nic *efx, u16 revision_info); | 159 | extern int falcon_probe_board(struct efx_nic *efx, u16 revision_info); |
160 | 160 | ||
161 | /* TX data path */ | 161 | /* TX data path */ |
162 | extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue); | 162 | extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue); |
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c index 38dcc42c4f79..e0c46f59d1f8 100644 --- a/drivers/net/sfc/siena.c +++ b/drivers/net/sfc/siena.c | |||
@@ -456,8 +456,17 @@ static int siena_try_update_nic_stats(struct efx_nic *efx) | |||
456 | 456 | ||
457 | static void siena_update_nic_stats(struct efx_nic *efx) | 457 | static void siena_update_nic_stats(struct efx_nic *efx) |
458 | { | 458 | { |
459 | while (siena_try_update_nic_stats(efx) == -EAGAIN) | 459 | int retry; |
460 | cpu_relax(); | 460 | |
461 | /* If we're unlucky enough to read statistics wduring the DMA, wait | ||
462 | * up to 10ms for it to finish (typically takes <500us) */ | ||
463 | for (retry = 0; retry < 100; ++retry) { | ||
464 | if (siena_try_update_nic_stats(efx) == 0) | ||
465 | return; | ||
466 | udelay(100); | ||
467 | } | ||
468 | |||
469 | /* Use the old values instead */ | ||
461 | } | 470 | } |
462 | 471 | ||
463 | static void siena_start_nic_stats(struct efx_nic *efx) | 472 | static void siena_start_nic_stats(struct efx_nic *efx) |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 22cf1c446de3..ecc41cffb470 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -8633,6 +8633,7 @@ static int tg3_test_msi(struct tg3 *tp) | |||
8633 | pci_disable_msi(tp->pdev); | 8633 | pci_disable_msi(tp->pdev); |
8634 | 8634 | ||
8635 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; | 8635 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; |
8636 | tp->napi[0].irq_vec = tp->pdev->irq; | ||
8636 | 8637 | ||
8637 | err = tg3_request_irq(tp, 0); | 8638 | err = tg3_request_irq(tp, 0); |
8638 | if (err) | 8639 | if (err) |
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index ba56ce4382d9..5d58abc224f4 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig | |||
@@ -385,4 +385,26 @@ config USB_CDC_PHONET | |||
385 | cellular modem, as found on most Nokia handsets with the | 385 | cellular modem, as found on most Nokia handsets with the |
386 | "PC suite" USB profile. | 386 | "PC suite" USB profile. |
387 | 387 | ||
388 | config USB_IPHETH | ||
389 | tristate "Apple iPhone USB Ethernet driver" | ||
390 | default n | ||
391 | ---help--- | ||
392 | Module used to share Internet connection (tethering) from your | ||
393 | iPhone (Original, 3G and 3GS) to your system. | ||
394 | Note that you need userspace libraries and programs that are needed | ||
395 | to pair your device with your system and that understand the iPhone | ||
396 | protocol. | ||
397 | |||
398 | For more information: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver | ||
399 | |||
400 | config USB_SIERRA_NET | ||
401 | tristate "USB-to-WWAN Driver for Sierra Wireless modems" | ||
402 | depends on USB_USBNET | ||
403 | default y | ||
404 | help | ||
405 | Choose this option if you have a Sierra Wireless USB-to-WWAN device. | ||
406 | |||
407 | To compile this driver as a module, choose M here: the | ||
408 | module will be called sierra_net. | ||
409 | |||
388 | endmenu | 410 | endmenu |
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile index 82ea62955b56..b13a279663ba 100644 --- a/drivers/net/usb/Makefile +++ b/drivers/net/usb/Makefile | |||
@@ -23,4 +23,6 @@ obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o | |||
23 | obj-$(CONFIG_USB_USBNET) += usbnet.o | 23 | obj-$(CONFIG_USB_USBNET) += usbnet.o |
24 | obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o | 24 | obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o |
25 | obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o | 25 | obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o |
26 | obj-$(CONFIG_USB_IPHETH) += ipheth.o | ||
27 | obj-$(CONFIG_USB_SIERRA_NET) += sierra_net.o | ||
26 | 28 | ||
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index c8cdb7f30adc..3547cf13d219 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
@@ -431,6 +431,7 @@ static const struct driver_info mbm_info = { | |||
431 | .bind = cdc_bind, | 431 | .bind = cdc_bind, |
432 | .unbind = usbnet_cdc_unbind, | 432 | .unbind = usbnet_cdc_unbind, |
433 | .status = cdc_status, | 433 | .status = cdc_status, |
434 | .manage_power = cdc_manage_power, | ||
434 | }; | 435 | }; |
435 | 436 | ||
436 | /*-------------------------------------------------------------------------*/ | 437 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c new file mode 100644 index 000000000000..418825d26f90 --- /dev/null +++ b/drivers/net/usb/ipheth.c | |||
@@ -0,0 +1,569 @@ | |||
1 | /* | ||
2 | * ipheth.c - Apple iPhone USB Ethernet driver | ||
3 | * | ||
4 | * Copyright (c) 2009 Diego Giagio <diego@giagio.com> | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of GIAGIO.COM nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * Alternatively, provided that this notice is retained in full, this | ||
20 | * software may be distributed under the terms of the GNU General | ||
21 | * Public License ("GPL") version 2, in which case the provisions of the | ||
22 | * GPL apply INSTEAD OF those given above. | ||
23 | * | ||
24 | * The provided data structures and external interfaces from this code | ||
25 | * are not restricted to be used by modules with a GPL compatible license. | ||
26 | * | ||
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
30 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
31 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
32 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
33 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
34 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
35 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
36 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
38 | * DAMAGE. | ||
39 | * | ||
40 | * | ||
41 | * Attention: iPhone device must be paired, otherwise it won't respond to our | ||
42 | * driver. For more info: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver | ||
43 | * | ||
44 | */ | ||
45 | |||
46 | #include <linux/kernel.h> | ||
47 | #include <linux/errno.h> | ||
48 | #include <linux/init.h> | ||
49 | #include <linux/slab.h> | ||
50 | #include <linux/module.h> | ||
51 | #include <linux/netdevice.h> | ||
52 | #include <linux/etherdevice.h> | ||
53 | #include <linux/ethtool.h> | ||
54 | #include <linux/usb.h> | ||
55 | #include <linux/workqueue.h> | ||
56 | |||
57 | #define USB_VENDOR_APPLE 0x05ac | ||
58 | #define USB_PRODUCT_IPHONE 0x1290 | ||
59 | #define USB_PRODUCT_IPHONE_3G 0x1292 | ||
60 | #define USB_PRODUCT_IPHONE_3GS 0x1294 | ||
61 | |||
62 | #define IPHETH_USBINTF_CLASS 255 | ||
63 | #define IPHETH_USBINTF_SUBCLASS 253 | ||
64 | #define IPHETH_USBINTF_PROTO 1 | ||
65 | |||
66 | #define IPHETH_BUF_SIZE 1516 | ||
67 | #define IPHETH_TX_TIMEOUT (5 * HZ) | ||
68 | |||
69 | #define IPHETH_INTFNUM 2 | ||
70 | #define IPHETH_ALT_INTFNUM 1 | ||
71 | |||
72 | #define IPHETH_CTRL_ENDP 0x00 | ||
73 | #define IPHETH_CTRL_BUF_SIZE 0x40 | ||
74 | #define IPHETH_CTRL_TIMEOUT (5 * HZ) | ||
75 | |||
76 | #define IPHETH_CMD_GET_MACADDR 0x00 | ||
77 | #define IPHETH_CMD_CARRIER_CHECK 0x45 | ||
78 | |||
79 | #define IPHETH_CARRIER_CHECK_TIMEOUT round_jiffies_relative(1 * HZ) | ||
80 | #define IPHETH_CARRIER_ON 0x04 | ||
81 | |||
82 | static struct usb_device_id ipheth_table[] = { | ||
83 | { USB_DEVICE_AND_INTERFACE_INFO( | ||
84 | USB_VENDOR_APPLE, USB_PRODUCT_IPHONE, | ||
85 | IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, | ||
86 | IPHETH_USBINTF_PROTO) }, | ||
87 | { USB_DEVICE_AND_INTERFACE_INFO( | ||
88 | USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G, | ||
89 | IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, | ||
90 | IPHETH_USBINTF_PROTO) }, | ||
91 | { USB_DEVICE_AND_INTERFACE_INFO( | ||
92 | USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS, | ||
93 | IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, | ||
94 | IPHETH_USBINTF_PROTO) }, | ||
95 | { } | ||
96 | }; | ||
97 | MODULE_DEVICE_TABLE(usb, ipheth_table); | ||
98 | |||
99 | struct ipheth_device { | ||
100 | struct usb_device *udev; | ||
101 | struct usb_interface *intf; | ||
102 | struct net_device *net; | ||
103 | struct sk_buff *tx_skb; | ||
104 | struct urb *tx_urb; | ||
105 | struct urb *rx_urb; | ||
106 | unsigned char *tx_buf; | ||
107 | unsigned char *rx_buf; | ||
108 | unsigned char *ctrl_buf; | ||
109 | u8 bulk_in; | ||
110 | u8 bulk_out; | ||
111 | struct delayed_work carrier_work; | ||
112 | }; | ||
113 | |||
114 | static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags); | ||
115 | |||
116 | static int ipheth_alloc_urbs(struct ipheth_device *iphone) | ||
117 | { | ||
118 | struct urb *tx_urb = NULL; | ||
119 | struct urb *rx_urb = NULL; | ||
120 | u8 *tx_buf = NULL; | ||
121 | u8 *rx_buf = NULL; | ||
122 | |||
123 | tx_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
124 | if (tx_urb == NULL) | ||
125 | goto error_nomem; | ||
126 | |||
127 | rx_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
128 | if (rx_urb == NULL) | ||
129 | goto free_tx_urb; | ||
130 | |||
131 | tx_buf = usb_buffer_alloc(iphone->udev, | ||
132 | IPHETH_BUF_SIZE, | ||
133 | GFP_KERNEL, | ||
134 | &tx_urb->transfer_dma); | ||
135 | if (tx_buf == NULL) | ||
136 | goto free_rx_urb; | ||
137 | |||
138 | rx_buf = usb_buffer_alloc(iphone->udev, | ||
139 | IPHETH_BUF_SIZE, | ||
140 | GFP_KERNEL, | ||
141 | &rx_urb->transfer_dma); | ||
142 | if (rx_buf == NULL) | ||
143 | goto free_tx_buf; | ||
144 | |||
145 | |||
146 | iphone->tx_urb = tx_urb; | ||
147 | iphone->rx_urb = rx_urb; | ||
148 | iphone->tx_buf = tx_buf; | ||
149 | iphone->rx_buf = rx_buf; | ||
150 | return 0; | ||
151 | |||
152 | free_tx_buf: | ||
153 | usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf, | ||
154 | tx_urb->transfer_dma); | ||
155 | free_rx_urb: | ||
156 | usb_free_urb(rx_urb); | ||
157 | free_tx_urb: | ||
158 | usb_free_urb(tx_urb); | ||
159 | error_nomem: | ||
160 | return -ENOMEM; | ||
161 | } | ||
162 | |||
163 | static void ipheth_free_urbs(struct ipheth_device *iphone) | ||
164 | { | ||
165 | usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, iphone->rx_buf, | ||
166 | iphone->rx_urb->transfer_dma); | ||
167 | usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, iphone->tx_buf, | ||
168 | iphone->tx_urb->transfer_dma); | ||
169 | usb_free_urb(iphone->rx_urb); | ||
170 | usb_free_urb(iphone->tx_urb); | ||
171 | } | ||
172 | |||
173 | static void ipheth_kill_urbs(struct ipheth_device *dev) | ||
174 | { | ||
175 | usb_kill_urb(dev->tx_urb); | ||
176 | usb_kill_urb(dev->rx_urb); | ||
177 | } | ||
178 | |||
179 | static void ipheth_rcvbulk_callback(struct urb *urb) | ||
180 | { | ||
181 | struct ipheth_device *dev; | ||
182 | struct sk_buff *skb; | ||
183 | int status; | ||
184 | char *buf; | ||
185 | int len; | ||
186 | |||
187 | dev = urb->context; | ||
188 | if (dev == NULL) | ||
189 | return; | ||
190 | |||
191 | status = urb->status; | ||
192 | switch (status) { | ||
193 | case -ENOENT: | ||
194 | case -ECONNRESET: | ||
195 | case -ESHUTDOWN: | ||
196 | return; | ||
197 | case 0: | ||
198 | break; | ||
199 | default: | ||
200 | err("%s: urb status: %d", __func__, urb->status); | ||
201 | return; | ||
202 | } | ||
203 | |||
204 | len = urb->actual_length; | ||
205 | buf = urb->transfer_buffer; | ||
206 | |||
207 | skb = dev_alloc_skb(NET_IP_ALIGN + len); | ||
208 | if (!skb) { | ||
209 | err("%s: dev_alloc_skb: -ENOMEM", __func__); | ||
210 | dev->net->stats.rx_dropped++; | ||
211 | return; | ||
212 | } | ||
213 | |||
214 | skb_reserve(skb, NET_IP_ALIGN); | ||
215 | memcpy(skb_put(skb, len), buf + NET_IP_ALIGN, len - NET_IP_ALIGN); | ||
216 | skb->dev = dev->net; | ||
217 | skb->protocol = eth_type_trans(skb, dev->net); | ||
218 | |||
219 | dev->net->stats.rx_packets++; | ||
220 | dev->net->stats.rx_bytes += len; | ||
221 | |||
222 | netif_rx(skb); | ||
223 | ipheth_rx_submit(dev, GFP_ATOMIC); | ||
224 | } | ||
225 | |||
226 | static void ipheth_sndbulk_callback(struct urb *urb) | ||
227 | { | ||
228 | struct ipheth_device *dev; | ||
229 | |||
230 | dev = urb->context; | ||
231 | if (dev == NULL) | ||
232 | return; | ||
233 | |||
234 | if (urb->status != 0 && | ||
235 | urb->status != -ENOENT && | ||
236 | urb->status != -ECONNRESET && | ||
237 | urb->status != -ESHUTDOWN) | ||
238 | err("%s: urb status: %d", __func__, urb->status); | ||
239 | |||
240 | dev_kfree_skb_irq(dev->tx_skb); | ||
241 | netif_wake_queue(dev->net); | ||
242 | } | ||
243 | |||
244 | static int ipheth_carrier_set(struct ipheth_device *dev) | ||
245 | { | ||
246 | struct usb_device *udev = dev->udev; | ||
247 | int retval; | ||
248 | |||
249 | retval = usb_control_msg(udev, | ||
250 | usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), | ||
251 | IPHETH_CMD_CARRIER_CHECK, /* request */ | ||
252 | 0xc0, /* request type */ | ||
253 | 0x00, /* value */ | ||
254 | 0x02, /* index */ | ||
255 | dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE, | ||
256 | IPHETH_CTRL_TIMEOUT); | ||
257 | if (retval < 0) { | ||
258 | err("%s: usb_control_msg: %d", __func__, retval); | ||
259 | return retval; | ||
260 | } | ||
261 | |||
262 | if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON) | ||
263 | netif_carrier_on(dev->net); | ||
264 | else | ||
265 | netif_carrier_off(dev->net); | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | static void ipheth_carrier_check_work(struct work_struct *work) | ||
271 | { | ||
272 | struct ipheth_device *dev = container_of(work, struct ipheth_device, | ||
273 | carrier_work.work); | ||
274 | |||
275 | ipheth_carrier_set(dev); | ||
276 | schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); | ||
277 | } | ||
278 | |||
279 | static int ipheth_get_macaddr(struct ipheth_device *dev) | ||
280 | { | ||
281 | struct usb_device *udev = dev->udev; | ||
282 | struct net_device *net = dev->net; | ||
283 | int retval; | ||
284 | |||
285 | retval = usb_control_msg(udev, | ||
286 | usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), | ||
287 | IPHETH_CMD_GET_MACADDR, /* request */ | ||
288 | 0xc0, /* request type */ | ||
289 | 0x00, /* value */ | ||
290 | 0x02, /* index */ | ||
291 | dev->ctrl_buf, | ||
292 | IPHETH_CTRL_BUF_SIZE, | ||
293 | IPHETH_CTRL_TIMEOUT); | ||
294 | if (retval < 0) { | ||
295 | err("%s: usb_control_msg: %d", __func__, retval); | ||
296 | } else if (retval < ETH_ALEN) { | ||
297 | err("%s: usb_control_msg: short packet: %d bytes", | ||
298 | __func__, retval); | ||
299 | retval = -EINVAL; | ||
300 | } else { | ||
301 | memcpy(net->dev_addr, dev->ctrl_buf, ETH_ALEN); | ||
302 | retval = 0; | ||
303 | } | ||
304 | |||
305 | return retval; | ||
306 | } | ||
307 | |||
308 | static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags) | ||
309 | { | ||
310 | struct usb_device *udev = dev->udev; | ||
311 | int retval; | ||
312 | |||
313 | usb_fill_bulk_urb(dev->rx_urb, udev, | ||
314 | usb_rcvbulkpipe(udev, dev->bulk_in), | ||
315 | dev->rx_buf, IPHETH_BUF_SIZE, | ||
316 | ipheth_rcvbulk_callback, | ||
317 | dev); | ||
318 | dev->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
319 | |||
320 | retval = usb_submit_urb(dev->rx_urb, mem_flags); | ||
321 | if (retval) | ||
322 | err("%s: usb_submit_urb: %d", __func__, retval); | ||
323 | return retval; | ||
324 | } | ||
325 | |||
326 | static int ipheth_open(struct net_device *net) | ||
327 | { | ||
328 | struct ipheth_device *dev = netdev_priv(net); | ||
329 | struct usb_device *udev = dev->udev; | ||
330 | int retval = 0; | ||
331 | |||
332 | usb_set_interface(udev, IPHETH_INTFNUM, IPHETH_ALT_INTFNUM); | ||
333 | |||
334 | retval = ipheth_carrier_set(dev); | ||
335 | if (retval) | ||
336 | return retval; | ||
337 | |||
338 | retval = ipheth_rx_submit(dev, GFP_KERNEL); | ||
339 | if (retval) | ||
340 | return retval; | ||
341 | |||
342 | schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); | ||
343 | netif_start_queue(net); | ||
344 | return retval; | ||
345 | } | ||
346 | |||
347 | static int ipheth_close(struct net_device *net) | ||
348 | { | ||
349 | struct ipheth_device *dev = netdev_priv(net); | ||
350 | |||
351 | cancel_delayed_work_sync(&dev->carrier_work); | ||
352 | netif_stop_queue(net); | ||
353 | return 0; | ||
354 | } | ||
355 | |||
356 | static int ipheth_tx(struct sk_buff *skb, struct net_device *net) | ||
357 | { | ||
358 | struct ipheth_device *dev = netdev_priv(net); | ||
359 | struct usb_device *udev = dev->udev; | ||
360 | int retval; | ||
361 | |||
362 | /* Paranoid */ | ||
363 | if (skb->len > IPHETH_BUF_SIZE) { | ||
364 | WARN(1, "%s: skb too large: %d bytes", __func__, skb->len); | ||
365 | dev->net->stats.tx_dropped++; | ||
366 | dev_kfree_skb_irq(skb); | ||
367 | return NETDEV_TX_OK; | ||
368 | } | ||
369 | |||
370 | memcpy(dev->tx_buf, skb->data, skb->len); | ||
371 | if (skb->len < IPHETH_BUF_SIZE) | ||
372 | memset(dev->tx_buf + skb->len, 0, IPHETH_BUF_SIZE - skb->len); | ||
373 | |||
374 | usb_fill_bulk_urb(dev->tx_urb, udev, | ||
375 | usb_sndbulkpipe(udev, dev->bulk_out), | ||
376 | dev->tx_buf, IPHETH_BUF_SIZE, | ||
377 | ipheth_sndbulk_callback, | ||
378 | dev); | ||
379 | dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
380 | |||
381 | retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC); | ||
382 | if (retval) { | ||
383 | err("%s: usb_submit_urb: %d", __func__, retval); | ||
384 | dev->net->stats.tx_errors++; | ||
385 | dev_kfree_skb_irq(skb); | ||
386 | } else { | ||
387 | dev->tx_skb = skb; | ||
388 | |||
389 | dev->net->stats.tx_packets++; | ||
390 | dev->net->stats.tx_bytes += skb->len; | ||
391 | netif_stop_queue(net); | ||
392 | } | ||
393 | |||
394 | return NETDEV_TX_OK; | ||
395 | } | ||
396 | |||
397 | static void ipheth_tx_timeout(struct net_device *net) | ||
398 | { | ||
399 | struct ipheth_device *dev = netdev_priv(net); | ||
400 | |||
401 | err("%s: TX timeout", __func__); | ||
402 | dev->net->stats.tx_errors++; | ||
403 | usb_unlink_urb(dev->tx_urb); | ||
404 | } | ||
405 | |||
406 | static struct net_device_stats *ipheth_stats(struct net_device *net) | ||
407 | { | ||
408 | struct ipheth_device *dev = netdev_priv(net); | ||
409 | return &dev->net->stats; | ||
410 | } | ||
411 | |||
412 | static u32 ipheth_ethtool_op_get_link(struct net_device *net) | ||
413 | { | ||
414 | struct ipheth_device *dev = netdev_priv(net); | ||
415 | return netif_carrier_ok(dev->net); | ||
416 | } | ||
417 | |||
418 | static struct ethtool_ops ops = { | ||
419 | .get_link = ipheth_ethtool_op_get_link | ||
420 | }; | ||
421 | |||
422 | static const struct net_device_ops ipheth_netdev_ops = { | ||
423 | .ndo_open = &ipheth_open, | ||
424 | .ndo_stop = &ipheth_close, | ||
425 | .ndo_start_xmit = &ipheth_tx, | ||
426 | .ndo_tx_timeout = &ipheth_tx_timeout, | ||
427 | .ndo_get_stats = &ipheth_stats, | ||
428 | }; | ||
429 | |||
430 | static struct device_type ipheth_type = { | ||
431 | .name = "wwan", | ||
432 | }; | ||
433 | |||
434 | static int ipheth_probe(struct usb_interface *intf, | ||
435 | const struct usb_device_id *id) | ||
436 | { | ||
437 | struct usb_device *udev = interface_to_usbdev(intf); | ||
438 | struct usb_host_interface *hintf; | ||
439 | struct usb_endpoint_descriptor *endp; | ||
440 | struct ipheth_device *dev; | ||
441 | struct net_device *netdev; | ||
442 | int i; | ||
443 | int retval; | ||
444 | |||
445 | netdev = alloc_etherdev(sizeof(struct ipheth_device)); | ||
446 | if (!netdev) | ||
447 | return -ENOMEM; | ||
448 | |||
449 | netdev->netdev_ops = &ipheth_netdev_ops; | ||
450 | netdev->watchdog_timeo = IPHETH_TX_TIMEOUT; | ||
451 | strcpy(netdev->name, "wwan%d"); | ||
452 | |||
453 | dev = netdev_priv(netdev); | ||
454 | dev->udev = udev; | ||
455 | dev->net = netdev; | ||
456 | dev->intf = intf; | ||
457 | |||
458 | /* Set up endpoints */ | ||
459 | hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM); | ||
460 | if (hintf == NULL) { | ||
461 | retval = -ENODEV; | ||
462 | err("Unable to find alternate settings interface"); | ||
463 | goto err_endpoints; | ||
464 | } | ||
465 | |||
466 | for (i = 0; i < hintf->desc.bNumEndpoints; i++) { | ||
467 | endp = &hintf->endpoint[i].desc; | ||
468 | if (usb_endpoint_is_bulk_in(endp)) | ||
469 | dev->bulk_in = endp->bEndpointAddress; | ||
470 | else if (usb_endpoint_is_bulk_out(endp)) | ||
471 | dev->bulk_out = endp->bEndpointAddress; | ||
472 | } | ||
473 | if (!(dev->bulk_in && dev->bulk_out)) { | ||
474 | retval = -ENODEV; | ||
475 | err("Unable to find endpoints"); | ||
476 | goto err_endpoints; | ||
477 | } | ||
478 | |||
479 | dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL); | ||
480 | if (dev->ctrl_buf == NULL) { | ||
481 | retval = -ENOMEM; | ||
482 | goto err_alloc_ctrl_buf; | ||
483 | } | ||
484 | |||
485 | retval = ipheth_get_macaddr(dev); | ||
486 | if (retval) | ||
487 | goto err_get_macaddr; | ||
488 | |||
489 | INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work); | ||
490 | |||
491 | retval = ipheth_alloc_urbs(dev); | ||
492 | if (retval) { | ||
493 | err("error allocating urbs: %d", retval); | ||
494 | goto err_alloc_urbs; | ||
495 | } | ||
496 | |||
497 | usb_set_intfdata(intf, dev); | ||
498 | |||
499 | SET_NETDEV_DEV(netdev, &intf->dev); | ||
500 | SET_ETHTOOL_OPS(netdev, &ops); | ||
501 | SET_NETDEV_DEVTYPE(netdev, &ipheth_type); | ||
502 | |||
503 | retval = register_netdev(netdev); | ||
504 | if (retval) { | ||
505 | err("error registering netdev: %d", retval); | ||
506 | retval = -EIO; | ||
507 | goto err_register_netdev; | ||
508 | } | ||
509 | |||
510 | dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n"); | ||
511 | return 0; | ||
512 | |||
513 | err_register_netdev: | ||
514 | ipheth_free_urbs(dev); | ||
515 | err_alloc_urbs: | ||
516 | err_get_macaddr: | ||
517 | err_alloc_ctrl_buf: | ||
518 | kfree(dev->ctrl_buf); | ||
519 | err_endpoints: | ||
520 | free_netdev(netdev); | ||
521 | return retval; | ||
522 | } | ||
523 | |||
524 | static void ipheth_disconnect(struct usb_interface *intf) | ||
525 | { | ||
526 | struct ipheth_device *dev; | ||
527 | |||
528 | dev = usb_get_intfdata(intf); | ||
529 | if (dev != NULL) { | ||
530 | unregister_netdev(dev->net); | ||
531 | ipheth_kill_urbs(dev); | ||
532 | ipheth_free_urbs(dev); | ||
533 | kfree(dev->ctrl_buf); | ||
534 | free_netdev(dev->net); | ||
535 | } | ||
536 | usb_set_intfdata(intf, NULL); | ||
537 | dev_info(&intf->dev, "Apple iPhone USB Ethernet now disconnected\n"); | ||
538 | } | ||
539 | |||
540 | static struct usb_driver ipheth_driver = { | ||
541 | .name = "ipheth", | ||
542 | .probe = ipheth_probe, | ||
543 | .disconnect = ipheth_disconnect, | ||
544 | .id_table = ipheth_table, | ||
545 | }; | ||
546 | |||
547 | static int __init ipheth_init(void) | ||
548 | { | ||
549 | int retval; | ||
550 | |||
551 | retval = usb_register(&ipheth_driver); | ||
552 | if (retval) { | ||
553 | err("usb_register failed: %d", retval); | ||
554 | return retval; | ||
555 | } | ||
556 | return 0; | ||
557 | } | ||
558 | |||
559 | static void __exit ipheth_exit(void) | ||
560 | { | ||
561 | usb_deregister(&ipheth_driver); | ||
562 | } | ||
563 | |||
564 | module_init(ipheth_init); | ||
565 | module_exit(ipheth_exit); | ||
566 | |||
567 | MODULE_AUTHOR("Diego Giagio <diego@giagio.com>"); | ||
568 | MODULE_DESCRIPTION("Apple iPhone USB Ethernet driver"); | ||
569 | MODULE_LICENSE("Dual BSD/GPL"); | ||
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 52671ea043a7..c4c334d9770f 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c | |||
@@ -145,6 +145,7 @@ static struct usb_device_id usb_klsi_table[] = { | |||
145 | { USB_DEVICE(0x0707, 0x0100) }, /* SMC 2202USB */ | 145 | { USB_DEVICE(0x0707, 0x0100) }, /* SMC 2202USB */ |
146 | { USB_DEVICE(0x07aa, 0x0001) }, /* Correga K.K. */ | 146 | { USB_DEVICE(0x07aa, 0x0001) }, /* Correga K.K. */ |
147 | { USB_DEVICE(0x07b8, 0x4000) }, /* D-Link DU-E10 */ | 147 | { USB_DEVICE(0x07b8, 0x4000) }, /* D-Link DU-E10 */ |
148 | { USB_DEVICE(0x07c9, 0xb010) }, /* Allied Telesyn AT-USB10 USB Ethernet Adapter */ | ||
148 | { USB_DEVICE(0x0846, 0x1001) }, /* NetGear EA-101 */ | 149 | { USB_DEVICE(0x0846, 0x1001) }, /* NetGear EA-101 */ |
149 | { USB_DEVICE(0x0846, 0x1002) }, /* NetGear EA-101 */ | 150 | { USB_DEVICE(0x0846, 0x1002) }, /* NetGear EA-101 */ |
150 | { USB_DEVICE(0x085a, 0x0008) }, /* PortGear Ethernet Adapter */ | 151 | { USB_DEVICE(0x085a, 0x0008) }, /* PortGear Ethernet Adapter */ |
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c new file mode 100644 index 000000000000..a44f9e0ea098 --- /dev/null +++ b/drivers/net/usb/sierra_net.c | |||
@@ -0,0 +1,1001 @@ | |||
1 | /* | ||
2 | * USB-to-WWAN Driver for Sierra Wireless modems | ||
3 | * | ||
4 | * Copyright (C) 2008, 2009, 2010 Paxton Smith, Matthew Safar, Rory Filer | ||
5 | * <linux@sierrawireless.com> | ||
6 | * | ||
7 | * Portions of this based on the cdc_ether driver by David Brownell (2003-2005) | ||
8 | * and Ole Andre Vadla Ravnas (ActiveSync) (2006). | ||
9 | * | ||
10 | * IMPORTANT DISCLAIMER: This driver is not commercially supported by | ||
11 | * Sierra Wireless. Use at your own risk. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | * GNU General Public License for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License | ||
24 | * along with this program; if not, write to the Free Software | ||
25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
26 | */ | ||
27 | |||
28 | #define DRIVER_VERSION "v.2.0" | ||
29 | #define DRIVER_AUTHOR "Paxton Smith, Matthew Safar, Rory Filer" | ||
30 | #define DRIVER_DESC "USB-to-WWAN Driver for Sierra Wireless modems" | ||
31 | static const char driver_name[] = "sierra_net"; | ||
32 | |||
33 | /* if defined debug messages enabled */ | ||
34 | /*#define DEBUG*/ | ||
35 | |||
36 | #include <linux/module.h> | ||
37 | #include <linux/etherdevice.h> | ||
38 | #include <linux/ethtool.h> | ||
39 | #include <linux/mii.h> | ||
40 | #include <linux/sched.h> | ||
41 | #include <linux/timer.h> | ||
42 | #include <linux/usb.h> | ||
43 | #include <linux/usb/cdc.h> | ||
44 | #include <net/ip.h> | ||
45 | #include <net/udp.h> | ||
46 | #include <asm/unaligned.h> | ||
47 | #include <linux/usb/usbnet.h> | ||
48 | |||
49 | #define SWI_USB_REQUEST_GET_FW_ATTR 0x06 | ||
50 | #define SWI_GET_FW_ATTR_MASK 0x08 | ||
51 | |||
52 | /* atomic counter partially included in MAC address to make sure 2 devices | ||
53 | * do not end up with the same MAC - concept breaks in case of > 255 ifaces | ||
54 | */ | ||
55 | static atomic_t iface_counter = ATOMIC_INIT(0); | ||
56 | |||
57 | /* | ||
58 | * SYNC Timer Delay definition used to set the expiry time | ||
59 | */ | ||
60 | #define SIERRA_NET_SYNCDELAY (2*HZ) | ||
61 | |||
62 | /* Max. MTU supported. The modem buffers are limited to 1500 */ | ||
63 | #define SIERRA_NET_MAX_SUPPORTED_MTU 1500 | ||
64 | |||
65 | /* The SIERRA_NET_USBCTL_BUF_LEN defines a buffer size allocated for control | ||
66 | * message reception ... and thus the max. received packet. | ||
67 | * (May be the cause for parse_hip returning -EINVAL) | ||
68 | */ | ||
69 | #define SIERRA_NET_USBCTL_BUF_LEN 1024 | ||
70 | |||
71 | /* list of interface numbers - used for constructing interface lists */ | ||
72 | struct sierra_net_iface_info { | ||
73 | const u32 infolen; /* number of interface numbers on list */ | ||
74 | const u8 *ifaceinfo; /* pointer to the array holding the numbers */ | ||
75 | }; | ||
76 | |||
77 | struct sierra_net_info_data { | ||
78 | u16 rx_urb_size; | ||
79 | struct sierra_net_iface_info whitelist; | ||
80 | }; | ||
81 | |||
82 | /* Private data structure */ | ||
83 | struct sierra_net_data { | ||
84 | |||
85 | u8 ethr_hdr_tmpl[ETH_HLEN]; /* ethernet header template for rx'd pkts */ | ||
86 | |||
87 | u16 link_up; /* air link up or down */ | ||
88 | u8 tx_hdr_template[4]; /* part of HIP hdr for tx'd packets */ | ||
89 | |||
90 | u8 sync_msg[4]; /* SYNC message */ | ||
91 | u8 shdwn_msg[4]; /* Shutdown message */ | ||
92 | |||
93 | /* Backpointer to the container */ | ||
94 | struct usbnet *usbnet; | ||
95 | |||
96 | u8 ifnum; /* interface number */ | ||
97 | |||
98 | /* Bit masks, must be a power of 2 */ | ||
99 | #define SIERRA_NET_EVENT_RESP_AVAIL 0x01 | ||
100 | #define SIERRA_NET_TIMER_EXPIRY 0x02 | ||
101 | unsigned long kevent_flags; | ||
102 | struct work_struct sierra_net_kevent; | ||
103 | struct timer_list sync_timer; /* For retrying SYNC sequence */ | ||
104 | }; | ||
105 | |||
106 | struct param { | ||
107 | int is_present; | ||
108 | union { | ||
109 | void *ptr; | ||
110 | u32 dword; | ||
111 | u16 word; | ||
112 | u8 byte; | ||
113 | }; | ||
114 | }; | ||
115 | |||
116 | /* HIP message type */ | ||
117 | #define SIERRA_NET_HIP_EXTENDEDID 0x7F | ||
118 | #define SIERRA_NET_HIP_HSYNC_ID 0x60 /* Modem -> host */ | ||
119 | #define SIERRA_NET_HIP_RESTART_ID 0x62 /* Modem -> host */ | ||
120 | #define SIERRA_NET_HIP_MSYNC_ID 0x20 /* Host -> modem */ | ||
121 | #define SIERRA_NET_HIP_SHUTD_ID 0x26 /* Host -> modem */ | ||
122 | |||
123 | #define SIERRA_NET_HIP_EXT_IP_IN_ID 0x0202 | ||
124 | #define SIERRA_NET_HIP_EXT_IP_OUT_ID 0x0002 | ||
125 | |||
126 | /* 3G UMTS Link Sense Indication definitions */ | ||
127 | #define SIERRA_NET_HIP_LSI_UMTSID 0x78 | ||
128 | |||
129 | /* Reverse Channel Grant Indication HIP message */ | ||
130 | #define SIERRA_NET_HIP_RCGI 0x64 | ||
131 | |||
132 | /* LSI Protocol types */ | ||
133 | #define SIERRA_NET_PROTOCOL_UMTS 0x01 | ||
134 | /* LSI Coverage */ | ||
135 | #define SIERRA_NET_COVERAGE_NONE 0x00 | ||
136 | #define SIERRA_NET_COVERAGE_NOPACKET 0x01 | ||
137 | |||
138 | /* LSI Session */ | ||
139 | #define SIERRA_NET_SESSION_IDLE 0x00 | ||
140 | /* LSI Link types */ | ||
141 | #define SIERRA_NET_AS_LINK_TYPE_IPv4 0x00 | ||
142 | |||
143 | struct lsi_umts { | ||
144 | u8 protocol; | ||
145 | u8 unused1; | ||
146 | __be16 length; | ||
147 | /* eventually use a union for the rest - assume umts for now */ | ||
148 | u8 coverage; | ||
149 | u8 unused2[41]; | ||
150 | u8 session_state; | ||
151 | u8 unused3[33]; | ||
152 | u8 link_type; | ||
153 | u8 pdp_addr_len; /* NW-supplied PDP address len */ | ||
154 | u8 pdp_addr[16]; /* NW-supplied PDP address (bigendian)) */ | ||
155 | u8 unused4[23]; | ||
156 | u8 dns1_addr_len; /* NW-supplied 1st DNS address len (bigendian) */ | ||
157 | u8 dns1_addr[16]; /* NW-supplied 1st DNS address */ | ||
158 | u8 dns2_addr_len; /* NW-supplied 2nd DNS address len */ | ||
159 | u8 dns2_addr[16]; /* NW-supplied 2nd DNS address (bigendian)*/ | ||
160 | u8 wins1_addr_len; /* NW-supplied 1st Wins address len */ | ||
161 | u8 wins1_addr[16]; /* NW-supplied 1st Wins address (bigendian)*/ | ||
162 | u8 wins2_addr_len; /* NW-supplied 2nd Wins address len */ | ||
163 | u8 wins2_addr[16]; /* NW-supplied 2nd Wins address (bigendian) */ | ||
164 | u8 unused5[4]; | ||
165 | u8 gw_addr_len; /* NW-supplied GW address len */ | ||
166 | u8 gw_addr[16]; /* NW-supplied GW address (bigendian) */ | ||
167 | u8 reserved[8]; | ||
168 | } __attribute__ ((packed)); | ||
169 | |||
170 | #define SIERRA_NET_LSI_COMMON_LEN 4 | ||
171 | #define SIERRA_NET_LSI_UMTS_LEN (sizeof(struct lsi_umts)) | ||
172 | #define SIERRA_NET_LSI_UMTS_STATUS_LEN \ | ||
173 | (SIERRA_NET_LSI_UMTS_LEN - SIERRA_NET_LSI_COMMON_LEN) | ||
174 | |||
175 | /* Forward definitions */ | ||
176 | static void sierra_sync_timer(unsigned long syncdata); | ||
177 | static int sierra_net_change_mtu(struct net_device *net, int new_mtu); | ||
178 | |||
179 | /* Our own net device operations structure */ | ||
180 | static const struct net_device_ops sierra_net_device_ops = { | ||
181 | .ndo_open = usbnet_open, | ||
182 | .ndo_stop = usbnet_stop, | ||
183 | .ndo_start_xmit = usbnet_start_xmit, | ||
184 | .ndo_tx_timeout = usbnet_tx_timeout, | ||
185 | .ndo_change_mtu = sierra_net_change_mtu, | ||
186 | .ndo_set_mac_address = eth_mac_addr, | ||
187 | .ndo_validate_addr = eth_validate_addr, | ||
188 | }; | ||
189 | |||
190 | /* get private data associated with passed in usbnet device */ | ||
191 | static inline struct sierra_net_data *sierra_net_get_private(struct usbnet *dev) | ||
192 | { | ||
193 | return (struct sierra_net_data *)dev->data[0]; | ||
194 | } | ||
195 | |||
196 | /* set private data associated with passed in usbnet device */ | ||
197 | static inline void sierra_net_set_private(struct usbnet *dev, | ||
198 | struct sierra_net_data *priv) | ||
199 | { | ||
200 | dev->data[0] = (unsigned long)priv; | ||
201 | } | ||
202 | |||
203 | /* is packet IPv4 */ | ||
204 | static inline int is_ip(struct sk_buff *skb) | ||
205 | { | ||
206 | return (skb->protocol == cpu_to_be16(ETH_P_IP)); | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * check passed in packet and make sure that: | ||
211 | * - it is linear (no scatter/gather) | ||
212 | * - it is ethernet (mac_header properly set) | ||
213 | */ | ||
214 | static int check_ethip_packet(struct sk_buff *skb, struct usbnet *dev) | ||
215 | { | ||
216 | skb_reset_mac_header(skb); /* ethernet header */ | ||
217 | |||
218 | if (skb_is_nonlinear(skb)) { | ||
219 | netdev_err(dev->net, "Non linear buffer-dropping\n"); | ||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | if (!pskb_may_pull(skb, ETH_HLEN)) | ||
224 | return 0; | ||
225 | skb->protocol = eth_hdr(skb)->h_proto; | ||
226 | |||
227 | return 1; | ||
228 | } | ||
229 | |||
230 | static const u8 *save16bit(struct param *p, const u8 *datap) | ||
231 | { | ||
232 | p->is_present = 1; | ||
233 | p->word = get_unaligned_be16(datap); | ||
234 | return datap + sizeof(p->word); | ||
235 | } | ||
236 | |||
237 | static const u8 *save8bit(struct param *p, const u8 *datap) | ||
238 | { | ||
239 | p->is_present = 1; | ||
240 | p->byte = *datap; | ||
241 | return datap + sizeof(p->byte); | ||
242 | } | ||
243 | |||
244 | /*----------------------------------------------------------------------------* | ||
245 | * BEGIN HIP * | ||
246 | *----------------------------------------------------------------------------*/ | ||
247 | /* HIP header */ | ||
248 | #define SIERRA_NET_HIP_HDR_LEN 4 | ||
249 | /* Extended HIP header */ | ||
250 | #define SIERRA_NET_HIP_EXT_HDR_LEN 6 | ||
251 | |||
252 | struct hip_hdr { | ||
253 | int hdrlen; | ||
254 | struct param payload_len; | ||
255 | struct param msgid; | ||
256 | struct param msgspecific; | ||
257 | struct param extmsgid; | ||
258 | }; | ||
259 | |||
260 | static int parse_hip(const u8 *buf, const u32 buflen, struct hip_hdr *hh) | ||
261 | { | ||
262 | const u8 *curp = buf; | ||
263 | int padded; | ||
264 | |||
265 | if (buflen < SIERRA_NET_HIP_HDR_LEN) | ||
266 | return -EPROTO; | ||
267 | |||
268 | curp = save16bit(&hh->payload_len, curp); | ||
269 | curp = save8bit(&hh->msgid, curp); | ||
270 | curp = save8bit(&hh->msgspecific, curp); | ||
271 | |||
272 | padded = hh->msgid.byte & 0x80; | ||
273 | hh->msgid.byte &= 0x7F; /* 7 bits */ | ||
274 | |||
275 | hh->extmsgid.is_present = (hh->msgid.byte == SIERRA_NET_HIP_EXTENDEDID); | ||
276 | if (hh->extmsgid.is_present) { | ||
277 | if (buflen < SIERRA_NET_HIP_EXT_HDR_LEN) | ||
278 | return -EPROTO; | ||
279 | |||
280 | hh->payload_len.word &= 0x3FFF; /* 14 bits */ | ||
281 | |||
282 | curp = save16bit(&hh->extmsgid, curp); | ||
283 | hh->extmsgid.word &= 0x03FF; /* 10 bits */ | ||
284 | |||
285 | hh->hdrlen = SIERRA_NET_HIP_EXT_HDR_LEN; | ||
286 | } else { | ||
287 | hh->payload_len.word &= 0x07FF; /* 11 bits */ | ||
288 | hh->hdrlen = SIERRA_NET_HIP_HDR_LEN; | ||
289 | } | ||
290 | |||
291 | if (padded) { | ||
292 | hh->hdrlen++; | ||
293 | hh->payload_len.word--; | ||
294 | } | ||
295 | |||
296 | /* if real packet shorter than the claimed length */ | ||
297 | if (buflen < (hh->hdrlen + hh->payload_len.word)) | ||
298 | return -EINVAL; | ||
299 | |||
300 | return 0; | ||
301 | } | ||
302 | |||
303 | static void build_hip(u8 *buf, const u16 payloadlen, | ||
304 | struct sierra_net_data *priv) | ||
305 | { | ||
306 | /* the following doesn't have the full functionality. We | ||
307 | * currently build only one kind of header, so it is faster this way | ||
308 | */ | ||
309 | put_unaligned_be16(payloadlen, buf); | ||
310 | memcpy(buf+2, priv->tx_hdr_template, sizeof(priv->tx_hdr_template)); | ||
311 | } | ||
312 | /*----------------------------------------------------------------------------* | ||
313 | * END HIP * | ||
314 | *----------------------------------------------------------------------------*/ | ||
315 | |||
316 | static int sierra_net_send_cmd(struct usbnet *dev, | ||
317 | u8 *cmd, int cmdlen, const char * cmd_name) | ||
318 | { | ||
319 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
320 | int status; | ||
321 | |||
322 | status = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), | ||
323 | USB_CDC_SEND_ENCAPSULATED_COMMAND, | ||
324 | USB_DIR_OUT|USB_TYPE_CLASS|USB_RECIP_INTERFACE, 0, | ||
325 | priv->ifnum, cmd, cmdlen, USB_CTRL_SET_TIMEOUT); | ||
326 | |||
327 | if (status != cmdlen && status != -ENODEV) | ||
328 | netdev_err(dev->net, "Submit %s failed %d\n", cmd_name, status); | ||
329 | |||
330 | return status; | ||
331 | } | ||
332 | |||
333 | static int sierra_net_send_sync(struct usbnet *dev) | ||
334 | { | ||
335 | int status; | ||
336 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
337 | |||
338 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
339 | |||
340 | status = sierra_net_send_cmd(dev, priv->sync_msg, | ||
341 | sizeof(priv->sync_msg), "SYNC"); | ||
342 | |||
343 | return status; | ||
344 | } | ||
345 | |||
346 | static void sierra_net_set_ctx_index(struct sierra_net_data *priv, u8 ctx_ix) | ||
347 | { | ||
348 | dev_dbg(&(priv->usbnet->udev->dev), "%s %d", __func__, ctx_ix); | ||
349 | priv->tx_hdr_template[0] = 0x3F; | ||
350 | priv->tx_hdr_template[1] = ctx_ix; | ||
351 | *((u16 *)&priv->tx_hdr_template[2]) = | ||
352 | cpu_to_be16(SIERRA_NET_HIP_EXT_IP_OUT_ID); | ||
353 | } | ||
354 | |||
355 | static inline int sierra_net_is_valid_addrlen(u8 len) | ||
356 | { | ||
357 | return (len == sizeof(struct in_addr)); | ||
358 | } | ||
359 | |||
360 | static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen) | ||
361 | { | ||
362 | struct lsi_umts *lsi = (struct lsi_umts *)data; | ||
363 | |||
364 | if (datalen < sizeof(struct lsi_umts)) { | ||
365 | netdev_err(dev->net, "%s: Data length %d, exp %Zu\n", | ||
366 | __func__, datalen, | ||
367 | sizeof(struct lsi_umts)); | ||
368 | return -1; | ||
369 | } | ||
370 | |||
371 | if (lsi->length != cpu_to_be16(SIERRA_NET_LSI_UMTS_STATUS_LEN)) { | ||
372 | netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n", | ||
373 | __func__, be16_to_cpu(lsi->length), | ||
374 | (u32)SIERRA_NET_LSI_UMTS_STATUS_LEN); | ||
375 | return -1; | ||
376 | } | ||
377 | |||
378 | /* Validate the protocol - only support UMTS for now */ | ||
379 | if (lsi->protocol != SIERRA_NET_PROTOCOL_UMTS) { | ||
380 | netdev_err(dev->net, "Protocol unsupported, 0x%02x\n", | ||
381 | lsi->protocol); | ||
382 | return -1; | ||
383 | } | ||
384 | |||
385 | /* Validate the link type */ | ||
386 | if (lsi->link_type != SIERRA_NET_AS_LINK_TYPE_IPv4) { | ||
387 | netdev_err(dev->net, "Link type unsupported: 0x%02x\n", | ||
388 | lsi->link_type); | ||
389 | return -1; | ||
390 | } | ||
391 | |||
392 | /* Validate the coverage */ | ||
393 | if (lsi->coverage == SIERRA_NET_COVERAGE_NONE | ||
394 | || lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) { | ||
395 | netdev_err(dev->net, "No coverage, 0x%02x\n", lsi->coverage); | ||
396 | return 0; | ||
397 | } | ||
398 | |||
399 | /* Validate the session state */ | ||
400 | if (lsi->session_state == SIERRA_NET_SESSION_IDLE) { | ||
401 | netdev_err(dev->net, "Session idle, 0x%02x\n", | ||
402 | lsi->session_state); | ||
403 | return 0; | ||
404 | } | ||
405 | |||
406 | /* Set link_sense true */ | ||
407 | return 1; | ||
408 | } | ||
409 | |||
410 | static void sierra_net_handle_lsi(struct usbnet *dev, char *data, | ||
411 | struct hip_hdr *hh) | ||
412 | { | ||
413 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
414 | int link_up; | ||
415 | |||
416 | link_up = sierra_net_parse_lsi(dev, data + hh->hdrlen, | ||
417 | hh->payload_len.word); | ||
418 | if (link_up < 0) { | ||
419 | netdev_err(dev->net, "Invalid LSI\n"); | ||
420 | return; | ||
421 | } | ||
422 | if (link_up) { | ||
423 | sierra_net_set_ctx_index(priv, hh->msgspecific.byte); | ||
424 | priv->link_up = 1; | ||
425 | netif_carrier_on(dev->net); | ||
426 | } else { | ||
427 | priv->link_up = 0; | ||
428 | netif_carrier_off(dev->net); | ||
429 | } | ||
430 | } | ||
431 | |||
432 | static void sierra_net_dosync(struct usbnet *dev) | ||
433 | { | ||
434 | int status; | ||
435 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
436 | |||
437 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
438 | |||
439 | /* tell modem we are ready */ | ||
440 | status = sierra_net_send_sync(dev); | ||
441 | if (status < 0) | ||
442 | netdev_err(dev->net, | ||
443 | "Send SYNC failed, status %d\n", status); | ||
444 | status = sierra_net_send_sync(dev); | ||
445 | if (status < 0) | ||
446 | netdev_err(dev->net, | ||
447 | "Send SYNC failed, status %d\n", status); | ||
448 | |||
449 | /* Now, start a timer and make sure we get the Restart Indication */ | ||
450 | priv->sync_timer.function = sierra_sync_timer; | ||
451 | priv->sync_timer.data = (unsigned long) dev; | ||
452 | priv->sync_timer.expires = jiffies + SIERRA_NET_SYNCDELAY; | ||
453 | add_timer(&priv->sync_timer); | ||
454 | } | ||
455 | |||
456 | static void sierra_net_kevent(struct work_struct *work) | ||
457 | { | ||
458 | struct sierra_net_data *priv = | ||
459 | container_of(work, struct sierra_net_data, sierra_net_kevent); | ||
460 | struct usbnet *dev = priv->usbnet; | ||
461 | int len; | ||
462 | int err; | ||
463 | u8 *buf; | ||
464 | u8 ifnum; | ||
465 | |||
466 | if (test_bit(SIERRA_NET_EVENT_RESP_AVAIL, &priv->kevent_flags)) { | ||
467 | clear_bit(SIERRA_NET_EVENT_RESP_AVAIL, &priv->kevent_flags); | ||
468 | |||
469 | /* Query the modem for the LSI message */ | ||
470 | buf = kzalloc(SIERRA_NET_USBCTL_BUF_LEN, GFP_KERNEL); | ||
471 | if (!buf) { | ||
472 | netdev_err(dev->net, | ||
473 | "failed to allocate buf for LS msg\n"); | ||
474 | return; | ||
475 | } | ||
476 | ifnum = priv->ifnum; | ||
477 | len = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), | ||
478 | USB_CDC_GET_ENCAPSULATED_RESPONSE, | ||
479 | USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE, | ||
480 | 0, ifnum, buf, SIERRA_NET_USBCTL_BUF_LEN, | ||
481 | USB_CTRL_SET_TIMEOUT); | ||
482 | |||
483 | if (len < 0) { | ||
484 | netdev_err(dev->net, | ||
485 | "usb_control_msg failed, status %d\n", len); | ||
486 | } else { | ||
487 | struct hip_hdr hh; | ||
488 | |||
489 | dev_dbg(&dev->udev->dev, "%s: Received status message," | ||
490 | " %04x bytes", __func__, len); | ||
491 | |||
492 | err = parse_hip(buf, len, &hh); | ||
493 | if (err) { | ||
494 | netdev_err(dev->net, "%s: Bad packet," | ||
495 | " parse result %d\n", __func__, err); | ||
496 | kfree(buf); | ||
497 | return; | ||
498 | } | ||
499 | |||
500 | /* Validate packet length */ | ||
501 | if (len != hh.hdrlen + hh.payload_len.word) { | ||
502 | netdev_err(dev->net, "%s: Bad packet, received" | ||
503 | " %d, expected %d\n", __func__, len, | ||
504 | hh.hdrlen + hh.payload_len.word); | ||
505 | kfree(buf); | ||
506 | return; | ||
507 | } | ||
508 | |||
509 | /* Switch on received message types */ | ||
510 | switch (hh.msgid.byte) { | ||
511 | case SIERRA_NET_HIP_LSI_UMTSID: | ||
512 | dev_dbg(&dev->udev->dev, "LSI for ctx:%d", | ||
513 | hh.msgspecific.byte); | ||
514 | sierra_net_handle_lsi(dev, buf, &hh); | ||
515 | break; | ||
516 | case SIERRA_NET_HIP_RESTART_ID: | ||
517 | dev_dbg(&dev->udev->dev, "Restart reported: %d," | ||
518 | " stopping sync timer", | ||
519 | hh.msgspecific.byte); | ||
520 | /* Got sync resp - stop timer & clear mask */ | ||
521 | del_timer_sync(&priv->sync_timer); | ||
522 | clear_bit(SIERRA_NET_TIMER_EXPIRY, | ||
523 | &priv->kevent_flags); | ||
524 | break; | ||
525 | case SIERRA_NET_HIP_HSYNC_ID: | ||
526 | dev_dbg(&dev->udev->dev, "SYNC received"); | ||
527 | err = sierra_net_send_sync(dev); | ||
528 | if (err < 0) | ||
529 | netdev_err(dev->net, | ||
530 | "Send SYNC failed %d\n", err); | ||
531 | break; | ||
532 | case SIERRA_NET_HIP_EXTENDEDID: | ||
533 | netdev_err(dev->net, "Unrecognized HIP msg, " | ||
534 | "extmsgid 0x%04x\n", hh.extmsgid.word); | ||
535 | break; | ||
536 | case SIERRA_NET_HIP_RCGI: | ||
537 | /* Ignored */ | ||
538 | break; | ||
539 | default: | ||
540 | netdev_err(dev->net, "Unrecognized HIP msg, " | ||
541 | "msgid 0x%02x\n", hh.msgid.byte); | ||
542 | break; | ||
543 | } | ||
544 | } | ||
545 | kfree(buf); | ||
546 | } | ||
547 | /* The sync timer bit might be set */ | ||
548 | if (test_bit(SIERRA_NET_TIMER_EXPIRY, &priv->kevent_flags)) { | ||
549 | clear_bit(SIERRA_NET_TIMER_EXPIRY, &priv->kevent_flags); | ||
550 | dev_dbg(&dev->udev->dev, "Deferred sync timer expiry"); | ||
551 | sierra_net_dosync(priv->usbnet); | ||
552 | } | ||
553 | |||
554 | if (priv->kevent_flags) | ||
555 | dev_dbg(&dev->udev->dev, "sierra_net_kevent done, " | ||
556 | "kevent_flags = 0x%lx", priv->kevent_flags); | ||
557 | } | ||
558 | |||
559 | static void sierra_net_defer_kevent(struct usbnet *dev, int work) | ||
560 | { | ||
561 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
562 | |||
563 | set_bit(work, &priv->kevent_flags); | ||
564 | schedule_work(&priv->sierra_net_kevent); | ||
565 | } | ||
566 | |||
567 | /* | ||
568 | * Sync Retransmit Timer Handler. On expiry, kick the work queue | ||
569 | */ | ||
570 | void sierra_sync_timer(unsigned long syncdata) | ||
571 | { | ||
572 | struct usbnet *dev = (struct usbnet *)syncdata; | ||
573 | |||
574 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
575 | /* Kick the tasklet */ | ||
576 | sierra_net_defer_kevent(dev, SIERRA_NET_TIMER_EXPIRY); | ||
577 | } | ||
578 | |||
579 | static void sierra_net_status(struct usbnet *dev, struct urb *urb) | ||
580 | { | ||
581 | struct usb_cdc_notification *event; | ||
582 | |||
583 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
584 | |||
585 | if (urb->actual_length < sizeof *event) | ||
586 | return; | ||
587 | |||
588 | /* Add cases to handle other standard notifications. */ | ||
589 | event = urb->transfer_buffer; | ||
590 | switch (event->bNotificationType) { | ||
591 | case USB_CDC_NOTIFY_NETWORK_CONNECTION: | ||
592 | case USB_CDC_NOTIFY_SPEED_CHANGE: | ||
593 | /* USB 305 sends those */ | ||
594 | break; | ||
595 | case USB_CDC_NOTIFY_RESPONSE_AVAILABLE: | ||
596 | sierra_net_defer_kevent(dev, SIERRA_NET_EVENT_RESP_AVAIL); | ||
597 | break; | ||
598 | default: | ||
599 | netdev_err(dev->net, ": unexpected notification %02x!\n", | ||
600 | event->bNotificationType); | ||
601 | break; | ||
602 | } | ||
603 | } | ||
604 | |||
605 | static void sierra_net_get_drvinfo(struct net_device *net, | ||
606 | struct ethtool_drvinfo *info) | ||
607 | { | ||
608 | /* Inherit standard device info */ | ||
609 | usbnet_get_drvinfo(net, info); | ||
610 | strncpy(info->driver, driver_name, sizeof info->driver); | ||
611 | strncpy(info->version, DRIVER_VERSION, sizeof info->version); | ||
612 | } | ||
613 | |||
614 | static u32 sierra_net_get_link(struct net_device *net) | ||
615 | { | ||
616 | struct usbnet *dev = netdev_priv(net); | ||
617 | /* Report link is down whenever the interface is down */ | ||
618 | return sierra_net_get_private(dev)->link_up && netif_running(net); | ||
619 | } | ||
620 | |||
621 | static struct ethtool_ops sierra_net_ethtool_ops = { | ||
622 | .get_drvinfo = sierra_net_get_drvinfo, | ||
623 | .get_link = sierra_net_get_link, | ||
624 | .get_msglevel = usbnet_get_msglevel, | ||
625 | .set_msglevel = usbnet_set_msglevel, | ||
626 | .get_settings = usbnet_get_settings, | ||
627 | .set_settings = usbnet_set_settings, | ||
628 | .nway_reset = usbnet_nway_reset, | ||
629 | }; | ||
630 | |||
631 | /* MTU can not be more than 1500 bytes, enforce it. */ | ||
632 | static int sierra_net_change_mtu(struct net_device *net, int new_mtu) | ||
633 | { | ||
634 | if (new_mtu > SIERRA_NET_MAX_SUPPORTED_MTU) | ||
635 | return -EINVAL; | ||
636 | |||
637 | return usbnet_change_mtu(net, new_mtu); | ||
638 | } | ||
639 | |||
640 | static int is_whitelisted(const u8 ifnum, | ||
641 | const struct sierra_net_iface_info *whitelist) | ||
642 | { | ||
643 | if (whitelist) { | ||
644 | const u8 *list = whitelist->ifaceinfo; | ||
645 | int i; | ||
646 | |||
647 | for (i = 0; i < whitelist->infolen; i++) { | ||
648 | if (list[i] == ifnum) | ||
649 | return 1; | ||
650 | } | ||
651 | } | ||
652 | return 0; | ||
653 | } | ||
654 | |||
655 | static int sierra_net_get_fw_attr(struct usbnet *dev, u16 *datap) | ||
656 | { | ||
657 | int result = 0; | ||
658 | u16 *attrdata; | ||
659 | |||
660 | attrdata = kmalloc(sizeof(*attrdata), GFP_KERNEL); | ||
661 | if (!attrdata) | ||
662 | return -ENOMEM; | ||
663 | |||
664 | result = usb_control_msg( | ||
665 | dev->udev, | ||
666 | usb_rcvctrlpipe(dev->udev, 0), | ||
667 | /* _u8 vendor specific request */ | ||
668 | SWI_USB_REQUEST_GET_FW_ATTR, | ||
669 | USB_DIR_IN | USB_TYPE_VENDOR, /* __u8 request type */ | ||
670 | 0x0000, /* __u16 value not used */ | ||
671 | 0x0000, /* __u16 index not used */ | ||
672 | attrdata, /* char *data */ | ||
673 | sizeof(*attrdata), /* __u16 size */ | ||
674 | USB_CTRL_SET_TIMEOUT); /* int timeout */ | ||
675 | |||
676 | if (result < 0) { | ||
677 | kfree(attrdata); | ||
678 | return -EIO; | ||
679 | } | ||
680 | |||
681 | *datap = *attrdata; | ||
682 | |||
683 | kfree(attrdata); | ||
684 | return result; | ||
685 | } | ||
686 | |||
687 | /* | ||
688 | * collects the bulk endpoints, the status endpoint. | ||
689 | */ | ||
690 | static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf) | ||
691 | { | ||
692 | u8 ifacenum; | ||
693 | u8 numendpoints; | ||
694 | u16 fwattr = 0; | ||
695 | int status; | ||
696 | struct ethhdr *eth; | ||
697 | struct sierra_net_data *priv; | ||
698 | static const u8 sync_tmplate[sizeof(priv->sync_msg)] = { | ||
699 | 0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00}; | ||
700 | static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = { | ||
701 | 0x00, 0x00, SIERRA_NET_HIP_SHUTD_ID, 0x00}; | ||
702 | |||
703 | struct sierra_net_info_data *data = | ||
704 | (struct sierra_net_info_data *)dev->driver_info->data; | ||
705 | |||
706 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
707 | |||
708 | ifacenum = intf->cur_altsetting->desc.bInterfaceNumber; | ||
709 | /* We only accept certain interfaces */ | ||
710 | if (!is_whitelisted(ifacenum, &data->whitelist)) { | ||
711 | dev_dbg(&dev->udev->dev, "Ignoring interface: %d", ifacenum); | ||
712 | return -ENODEV; | ||
713 | } | ||
714 | numendpoints = intf->cur_altsetting->desc.bNumEndpoints; | ||
715 | /* We have three endpoints, bulk in and out, and a status */ | ||
716 | if (numendpoints != 3) { | ||
717 | dev_err(&dev->udev->dev, "Expected 3 endpoints, found: %d", | ||
718 | numendpoints); | ||
719 | return -ENODEV; | ||
720 | } | ||
721 | /* Status endpoint set in usbnet_get_endpoints() */ | ||
722 | dev->status = NULL; | ||
723 | status = usbnet_get_endpoints(dev, intf); | ||
724 | if (status < 0) { | ||
725 | dev_err(&dev->udev->dev, "Error in usbnet_get_endpoints (%d)", | ||
726 | status); | ||
727 | return -ENODEV; | ||
728 | } | ||
729 | /* Initialize sierra private data */ | ||
730 | priv = kzalloc(sizeof *priv, GFP_KERNEL); | ||
731 | if (!priv) { | ||
732 | dev_err(&dev->udev->dev, "No memory"); | ||
733 | return -ENOMEM; | ||
734 | } | ||
735 | |||
736 | priv->usbnet = dev; | ||
737 | priv->ifnum = ifacenum; | ||
738 | dev->net->netdev_ops = &sierra_net_device_ops; | ||
739 | |||
740 | /* change MAC addr to include, ifacenum, and to be unique */ | ||
741 | dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter); | ||
742 | dev->net->dev_addr[ETH_ALEN-1] = ifacenum; | ||
743 | |||
744 | /* we will have to manufacture ethernet headers, prepare template */ | ||
745 | eth = (struct ethhdr *)priv->ethr_hdr_tmpl; | ||
746 | memcpy(ð->h_dest, dev->net->dev_addr, ETH_ALEN); | ||
747 | eth->h_proto = cpu_to_be16(ETH_P_IP); | ||
748 | |||
749 | /* prepare shutdown message template */ | ||
750 | memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg)); | ||
751 | /* set context index initially to 0 - prepares tx hdr template */ | ||
752 | sierra_net_set_ctx_index(priv, 0); | ||
753 | |||
754 | /* decrease the rx_urb_size and max_tx_size to 4k on USB 1.1 */ | ||
755 | dev->rx_urb_size = data->rx_urb_size; | ||
756 | if (dev->udev->speed != USB_SPEED_HIGH) | ||
757 | dev->rx_urb_size = min_t(size_t, 4096, data->rx_urb_size); | ||
758 | |||
759 | dev->net->hard_header_len += SIERRA_NET_HIP_EXT_HDR_LEN; | ||
760 | dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; | ||
761 | |||
762 | /* Set up the netdev */ | ||
763 | dev->net->flags |= IFF_NOARP; | ||
764 | dev->net->ethtool_ops = &sierra_net_ethtool_ops; | ||
765 | netif_carrier_off(dev->net); | ||
766 | |||
767 | sierra_net_set_private(dev, priv); | ||
768 | |||
769 | priv->kevent_flags = 0; | ||
770 | |||
771 | /* Use the shared workqueue */ | ||
772 | INIT_WORK(&priv->sierra_net_kevent, sierra_net_kevent); | ||
773 | |||
774 | /* Only need to do this once */ | ||
775 | init_timer(&priv->sync_timer); | ||
776 | |||
777 | /* verify fw attributes */ | ||
778 | status = sierra_net_get_fw_attr(dev, &fwattr); | ||
779 | dev_dbg(&dev->udev->dev, "Fw attr: %x\n", fwattr); | ||
780 | |||
781 | /* test whether firmware supports DHCP */ | ||
782 | if (!(status == sizeof(fwattr) && (fwattr & SWI_GET_FW_ATTR_MASK))) { | ||
783 | /* found incompatible firmware version */ | ||
784 | dev_err(&dev->udev->dev, "Incompatible driver and firmware" | ||
785 | " versions\n"); | ||
786 | kfree(priv); | ||
787 | return -ENODEV; | ||
788 | } | ||
789 | /* prepare sync message from template */ | ||
790 | memcpy(priv->sync_msg, sync_tmplate, sizeof(priv->sync_msg)); | ||
791 | |||
792 | return 0; | ||
793 | } | ||
794 | |||
795 | static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf) | ||
796 | { | ||
797 | int status; | ||
798 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
799 | |||
800 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
801 | |||
802 | /* Kill the timer then flush the work queue */ | ||
803 | del_timer_sync(&priv->sync_timer); | ||
804 | |||
805 | flush_scheduled_work(); | ||
806 | |||
807 | /* tell modem we are going away */ | ||
808 | status = sierra_net_send_cmd(dev, priv->shdwn_msg, | ||
809 | sizeof(priv->shdwn_msg), "Shutdown"); | ||
810 | if (status < 0) | ||
811 | netdev_err(dev->net, | ||
812 | "usb_control_msg failed, status %d\n", status); | ||
813 | |||
814 | sierra_net_set_private(dev, NULL); | ||
815 | |||
816 | kfree(priv); | ||
817 | } | ||
818 | |||
819 | static struct sk_buff *sierra_net_skb_clone(struct usbnet *dev, | ||
820 | struct sk_buff *skb, int len) | ||
821 | { | ||
822 | struct sk_buff *new_skb; | ||
823 | |||
824 | /* clone skb */ | ||
825 | new_skb = skb_clone(skb, GFP_ATOMIC); | ||
826 | |||
827 | /* remove len bytes from original */ | ||
828 | skb_pull(skb, len); | ||
829 | |||
830 | /* trim next packet to it's length */ | ||
831 | if (new_skb) { | ||
832 | skb_trim(new_skb, len); | ||
833 | } else { | ||
834 | if (netif_msg_rx_err(dev)) | ||
835 | netdev_err(dev->net, "failed to get skb\n"); | ||
836 | dev->net->stats.rx_dropped++; | ||
837 | } | ||
838 | |||
839 | return new_skb; | ||
840 | } | ||
841 | |||
842 | /* ---------------------------- Receive data path ----------------------*/ | ||
843 | static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | ||
844 | { | ||
845 | int err; | ||
846 | struct hip_hdr hh; | ||
847 | struct sk_buff *new_skb; | ||
848 | |||
849 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
850 | |||
851 | /* could contain multiple packets */ | ||
852 | while (likely(skb->len)) { | ||
853 | err = parse_hip(skb->data, skb->len, &hh); | ||
854 | if (err) { | ||
855 | if (netif_msg_rx_err(dev)) | ||
856 | netdev_err(dev->net, "Invalid HIP header %d\n", | ||
857 | err); | ||
858 | /* dev->net->stats.rx_errors incremented by caller */ | ||
859 | dev->net->stats.rx_length_errors++; | ||
860 | return 0; | ||
861 | } | ||
862 | |||
863 | /* Validate Extended HIP header */ | ||
864 | if (!hh.extmsgid.is_present | ||
865 | || hh.extmsgid.word != SIERRA_NET_HIP_EXT_IP_IN_ID) { | ||
866 | if (netif_msg_rx_err(dev)) | ||
867 | netdev_err(dev->net, "HIP/ETH: Invalid pkt\n"); | ||
868 | |||
869 | dev->net->stats.rx_frame_errors++; | ||
870 | /* dev->net->stats.rx_errors incremented by caller */; | ||
871 | return 0; | ||
872 | } | ||
873 | |||
874 | skb_pull(skb, hh.hdrlen); | ||
875 | |||
876 | /* We are going to accept this packet, prepare it */ | ||
877 | memcpy(skb->data, sierra_net_get_private(dev)->ethr_hdr_tmpl, | ||
878 | ETH_HLEN); | ||
879 | |||
880 | /* Last packet in batch handled by usbnet */ | ||
881 | if (hh.payload_len.word == skb->len) | ||
882 | return 1; | ||
883 | |||
884 | new_skb = sierra_net_skb_clone(dev, skb, hh.payload_len.word); | ||
885 | if (new_skb) | ||
886 | usbnet_skb_return(dev, new_skb); | ||
887 | |||
888 | } /* while */ | ||
889 | |||
890 | return 0; | ||
891 | } | ||
892 | |||
893 | /* ---------------------------- Transmit data path ----------------------*/ | ||
894 | struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | ||
895 | gfp_t flags) | ||
896 | { | ||
897 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
898 | u16 len; | ||
899 | bool need_tail; | ||
900 | |||
901 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
902 | if (priv->link_up && check_ethip_packet(skb, dev) && is_ip(skb)) { | ||
903 | /* enough head room as is? */ | ||
904 | if (SIERRA_NET_HIP_EXT_HDR_LEN <= skb_headroom(skb)) { | ||
905 | /* Save the Eth/IP length and set up HIP hdr */ | ||
906 | len = skb->len; | ||
907 | skb_push(skb, SIERRA_NET_HIP_EXT_HDR_LEN); | ||
908 | /* Handle ZLP issue */ | ||
909 | need_tail = ((len + SIERRA_NET_HIP_EXT_HDR_LEN) | ||
910 | % dev->maxpacket == 0); | ||
911 | if (need_tail) { | ||
912 | if (unlikely(skb_tailroom(skb) == 0)) { | ||
913 | netdev_err(dev->net, "tx_fixup:" | ||
914 | "no room for packet\n"); | ||
915 | dev_kfree_skb_any(skb); | ||
916 | return NULL; | ||
917 | } else { | ||
918 | skb->data[skb->len] = 0; | ||
919 | __skb_put(skb, 1); | ||
920 | len = len + 1; | ||
921 | } | ||
922 | } | ||
923 | build_hip(skb->data, len, priv); | ||
924 | return skb; | ||
925 | } else { | ||
926 | /* | ||
927 | * compensate in the future if necessary | ||
928 | */ | ||
929 | netdev_err(dev->net, "tx_fixup: no room for HIP\n"); | ||
930 | } /* headroom */ | ||
931 | } | ||
932 | |||
933 | if (!priv->link_up) | ||
934 | dev->net->stats.tx_carrier_errors++; | ||
935 | |||
936 | /* tx_dropped incremented by usbnet */ | ||
937 | |||
938 | /* filter the packet out, release it */ | ||
939 | dev_kfree_skb_any(skb); | ||
940 | return NULL; | ||
941 | } | ||
942 | |||
943 | static const u8 sierra_net_ifnum_list[] = { 7, 10, 11 }; | ||
944 | static const struct sierra_net_info_data sierra_net_info_data_68A3 = { | ||
945 | .rx_urb_size = 8 * 1024, | ||
946 | .whitelist = { | ||
947 | .infolen = ARRAY_SIZE(sierra_net_ifnum_list), | ||
948 | .ifaceinfo = sierra_net_ifnum_list | ||
949 | } | ||
950 | }; | ||
951 | |||
952 | static const struct driver_info sierra_net_info_68A3 = { | ||
953 | .description = "Sierra Wireless USB-to-WWAN Modem", | ||
954 | .flags = FLAG_WWAN | FLAG_SEND_ZLP, | ||
955 | .bind = sierra_net_bind, | ||
956 | .unbind = sierra_net_unbind, | ||
957 | .status = sierra_net_status, | ||
958 | .rx_fixup = sierra_net_rx_fixup, | ||
959 | .tx_fixup = sierra_net_tx_fixup, | ||
960 | .data = (unsigned long)&sierra_net_info_data_68A3, | ||
961 | }; | ||
962 | |||
963 | static const struct usb_device_id products[] = { | ||
964 | {USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless USB-to-WWAN modem */ | ||
965 | .driver_info = (unsigned long) &sierra_net_info_68A3}, | ||
966 | |||
967 | {}, /* last item */ | ||
968 | }; | ||
969 | MODULE_DEVICE_TABLE(usb, products); | ||
970 | |||
971 | /* We are based on usbnet, so let it handle the USB driver specifics */ | ||
972 | static struct usb_driver sierra_net_driver = { | ||
973 | .name = "sierra_net", | ||
974 | .id_table = products, | ||
975 | .probe = usbnet_probe, | ||
976 | .disconnect = usbnet_disconnect, | ||
977 | .suspend = usbnet_suspend, | ||
978 | .resume = usbnet_resume, | ||
979 | .no_dynamic_id = 1, | ||
980 | }; | ||
981 | |||
982 | static int __init sierra_net_init(void) | ||
983 | { | ||
984 | BUILD_BUG_ON(FIELD_SIZEOF(struct usbnet, data) | ||
985 | < sizeof(struct cdc_state)); | ||
986 | |||
987 | return usb_register(&sierra_net_driver); | ||
988 | } | ||
989 | |||
990 | static void __exit sierra_net_exit(void) | ||
991 | { | ||
992 | usb_deregister(&sierra_net_driver); | ||
993 | } | ||
994 | |||
995 | module_exit(sierra_net_exit); | ||
996 | module_init(sierra_net_init); | ||
997 | |||
998 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
999 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
1000 | MODULE_VERSION(DRIVER_VERSION); | ||
1001 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index c4844adff92a..92b3e64fc14d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c | |||
@@ -259,7 +259,7 @@ static struct iwl_lib_ops iwl6000_lib = { | |||
259 | EEPROM_5000_REG_BAND_3_CHANNELS, | 259 | EEPROM_5000_REG_BAND_3_CHANNELS, |
260 | EEPROM_5000_REG_BAND_4_CHANNELS, | 260 | EEPROM_5000_REG_BAND_4_CHANNELS, |
261 | EEPROM_5000_REG_BAND_5_CHANNELS, | 261 | EEPROM_5000_REG_BAND_5_CHANNELS, |
262 | EEPROM_5000_REG_BAND_24_HT40_CHANNELS, | 262 | EEPROM_6000_REG_BAND_24_HT40_CHANNELS, |
263 | EEPROM_5000_REG_BAND_52_HT40_CHANNELS | 263 | EEPROM_5000_REG_BAND_52_HT40_CHANNELS |
264 | }, | 264 | }, |
265 | .verify_signature = iwlcore_eeprom_verify_signature, | 265 | .verify_signature = iwlcore_eeprom_verify_signature, |
@@ -323,7 +323,7 @@ static struct iwl_lib_ops iwl6050_lib = { | |||
323 | EEPROM_5000_REG_BAND_3_CHANNELS, | 323 | EEPROM_5000_REG_BAND_3_CHANNELS, |
324 | EEPROM_5000_REG_BAND_4_CHANNELS, | 324 | EEPROM_5000_REG_BAND_4_CHANNELS, |
325 | EEPROM_5000_REG_BAND_5_CHANNELS, | 325 | EEPROM_5000_REG_BAND_5_CHANNELS, |
326 | EEPROM_5000_REG_BAND_24_HT40_CHANNELS, | 326 | EEPROM_6000_REG_BAND_24_HT40_CHANNELS, |
327 | EEPROM_5000_REG_BAND_52_HT40_CHANNELS | 327 | EEPROM_5000_REG_BAND_52_HT40_CHANNELS |
328 | }, | 328 | }, |
329 | .verify_signature = iwlcore_eeprom_verify_signature, | 329 | .verify_signature = iwlcore_eeprom_verify_signature, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 8b8e3e1cbb44..bdff56583e11 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -3331,6 +3331,7 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv) | |||
3331 | 3331 | ||
3332 | cancel_delayed_work_sync(&priv->init_alive_start); | 3332 | cancel_delayed_work_sync(&priv->init_alive_start); |
3333 | cancel_delayed_work(&priv->scan_check); | 3333 | cancel_delayed_work(&priv->scan_check); |
3334 | cancel_work_sync(&priv->start_internal_scan); | ||
3334 | cancel_delayed_work(&priv->alive_start); | 3335 | cancel_delayed_work(&priv->alive_start); |
3335 | cancel_work_sync(&priv->beacon_update); | 3336 | cancel_work_sync(&priv->beacon_update); |
3336 | del_timer_sync(&priv->statistics_periodic); | 3337 | del_timer_sync(&priv->statistics_periodic); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 3352f7086632..049b652bcb5e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -3358,7 +3358,6 @@ static void iwl_force_rf_reset(struct iwl_priv *priv) | |||
3358 | */ | 3358 | */ |
3359 | IWL_DEBUG_INFO(priv, "perform radio reset.\n"); | 3359 | IWL_DEBUG_INFO(priv, "perform radio reset.\n"); |
3360 | iwl_internal_short_hw_scan(priv); | 3360 | iwl_internal_short_hw_scan(priv); |
3361 | return; | ||
3362 | } | 3361 | } |
3363 | 3362 | ||
3364 | 3363 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 732590f5fe30..36940a9ec6b9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h | |||
@@ -506,7 +506,7 @@ void iwl_init_scan_params(struct iwl_priv *priv); | |||
506 | int iwl_scan_cancel(struct iwl_priv *priv); | 506 | int iwl_scan_cancel(struct iwl_priv *priv); |
507 | int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); | 507 | int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); |
508 | int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req); | 508 | int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req); |
509 | int iwl_internal_short_hw_scan(struct iwl_priv *priv); | 509 | void iwl_internal_short_hw_scan(struct iwl_priv *priv); |
510 | int iwl_force_reset(struct iwl_priv *priv, int mode); | 510 | int iwl_force_reset(struct iwl_priv *priv, int mode); |
511 | u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, | 511 | u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, |
512 | const u8 *ie, int ie_len, int left); | 512 | const u8 *ie, int ie_len, int left); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 6054c5fba0c1..ef1720a852e9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -1296,6 +1296,7 @@ struct iwl_priv { | |||
1296 | struct work_struct tt_work; | 1296 | struct work_struct tt_work; |
1297 | struct work_struct ct_enter; | 1297 | struct work_struct ct_enter; |
1298 | struct work_struct ct_exit; | 1298 | struct work_struct ct_exit; |
1299 | struct work_struct start_internal_scan; | ||
1299 | 1300 | ||
1300 | struct tasklet_struct irq_tasklet; | 1301 | struct tasklet_struct irq_tasklet; |
1301 | 1302 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index 4e1ba824dc50..8171c701e4e1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h | |||
@@ -203,6 +203,10 @@ struct iwl_eeprom_enhanced_txpwr { | |||
203 | #define EEPROM_5000_REG_BAND_52_HT40_CHANNELS ((0x92)\ | 203 | #define EEPROM_5000_REG_BAND_52_HT40_CHANNELS ((0x92)\ |
204 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */ | 204 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */ |
205 | 205 | ||
206 | /* 6000 regulatory - indirect access */ | ||
207 | #define EEPROM_6000_REG_BAND_24_HT40_CHANNELS ((0x80)\ | ||
208 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 14 bytes */ | ||
209 | |||
206 | /* 6000 and up regulatory tx power - indirect access */ | 210 | /* 6000 and up regulatory tx power - indirect access */ |
207 | /* max. elements per section */ | 211 | /* max. elements per section */ |
208 | #define EEPROM_MAX_TXPOWER_SECTION_ELEMENTS (8) | 212 | #define EEPROM_MAX_TXPOWER_SECTION_ELEMENTS (8) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 9ab0e412bf10..12e455a4b90e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c | |||
@@ -470,6 +470,8 @@ EXPORT_SYMBOL(iwl_init_scan_params); | |||
470 | 470 | ||
471 | static int iwl_scan_initiate(struct iwl_priv *priv) | 471 | static int iwl_scan_initiate(struct iwl_priv *priv) |
472 | { | 472 | { |
473 | WARN_ON(!mutex_is_locked(&priv->mutex)); | ||
474 | |||
473 | IWL_DEBUG_INFO(priv, "Starting scan...\n"); | 475 | IWL_DEBUG_INFO(priv, "Starting scan...\n"); |
474 | set_bit(STATUS_SCANNING, &priv->status); | 476 | set_bit(STATUS_SCANNING, &priv->status); |
475 | priv->is_internal_short_scan = false; | 477 | priv->is_internal_short_scan = false; |
@@ -547,24 +549,31 @@ EXPORT_SYMBOL(iwl_mac_hw_scan); | |||
547 | * internal short scan, this function should only been called while associated. | 549 | * internal short scan, this function should only been called while associated. |
548 | * It will reset and tune the radio to prevent possible RF related problem | 550 | * It will reset and tune the radio to prevent possible RF related problem |
549 | */ | 551 | */ |
550 | int iwl_internal_short_hw_scan(struct iwl_priv *priv) | 552 | void iwl_internal_short_hw_scan(struct iwl_priv *priv) |
551 | { | 553 | { |
552 | int ret = 0; | 554 | queue_work(priv->workqueue, &priv->start_internal_scan); |
555 | } | ||
556 | |||
557 | static void iwl_bg_start_internal_scan(struct work_struct *work) | ||
558 | { | ||
559 | struct iwl_priv *priv = | ||
560 | container_of(work, struct iwl_priv, start_internal_scan); | ||
561 | |||
562 | mutex_lock(&priv->mutex); | ||
553 | 563 | ||
554 | if (!iwl_is_ready_rf(priv)) { | 564 | if (!iwl_is_ready_rf(priv)) { |
555 | ret = -EIO; | ||
556 | IWL_DEBUG_SCAN(priv, "not ready or exit pending\n"); | 565 | IWL_DEBUG_SCAN(priv, "not ready or exit pending\n"); |
557 | goto out; | 566 | goto unlock; |
558 | } | 567 | } |
568 | |||
559 | if (test_bit(STATUS_SCANNING, &priv->status)) { | 569 | if (test_bit(STATUS_SCANNING, &priv->status)) { |
560 | IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); | 570 | IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); |
561 | ret = -EAGAIN; | 571 | goto unlock; |
562 | goto out; | ||
563 | } | 572 | } |
573 | |||
564 | if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { | 574 | if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { |
565 | IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n"); | 575 | IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n"); |
566 | ret = -EAGAIN; | 576 | goto unlock; |
567 | goto out; | ||
568 | } | 577 | } |
569 | 578 | ||
570 | priv->scan_bands = 0; | 579 | priv->scan_bands = 0; |
@@ -577,9 +586,8 @@ int iwl_internal_short_hw_scan(struct iwl_priv *priv) | |||
577 | set_bit(STATUS_SCANNING, &priv->status); | 586 | set_bit(STATUS_SCANNING, &priv->status); |
578 | priv->is_internal_short_scan = true; | 587 | priv->is_internal_short_scan = true; |
579 | queue_work(priv->workqueue, &priv->request_scan); | 588 | queue_work(priv->workqueue, &priv->request_scan); |
580 | 589 | unlock: | |
581 | out: | 590 | mutex_unlock(&priv->mutex); |
582 | return ret; | ||
583 | } | 591 | } |
584 | EXPORT_SYMBOL(iwl_internal_short_hw_scan); | 592 | EXPORT_SYMBOL(iwl_internal_short_hw_scan); |
585 | 593 | ||
@@ -965,6 +973,7 @@ void iwl_setup_scan_deferred_work(struct iwl_priv *priv) | |||
965 | INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); | 973 | INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); |
966 | INIT_WORK(&priv->request_scan, iwl_bg_request_scan); | 974 | INIT_WORK(&priv->request_scan, iwl_bg_request_scan); |
967 | INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); | 975 | INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); |
976 | INIT_WORK(&priv->start_internal_scan, iwl_bg_start_internal_scan); | ||
968 | INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); | 977 | INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); |
969 | } | 978 | } |
970 | EXPORT_SYMBOL(iwl_setup_scan_deferred_work); | 979 | EXPORT_SYMBOL(iwl_setup_scan_deferred_work); |
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index 4e3e0382c16e..083034710fa6 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
22 | #include <linux/string.h> | 22 | #include <linux/string.h> |
23 | #include <linux/vmalloc.h> | ||
23 | 24 | ||
24 | #include <asm/pci-bridge.h> | 25 | #include <asm/pci-bridge.h> |
25 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
@@ -430,6 +431,8 @@ int dlpar_remove_slot(char *drc_name) | |||
430 | rc = dlpar_remove_pci_slot(drc_name, dn); | 431 | rc = dlpar_remove_pci_slot(drc_name, dn); |
431 | break; | 432 | break; |
432 | } | 433 | } |
434 | vm_unmap_aliases(); | ||
435 | |||
433 | printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name); | 436 | printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name); |
434 | exit: | 437 | exit: |
435 | mutex_unlock(&rpadlpar_mutex); | 438 | mutex_unlock(&rpadlpar_mutex); |
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 719702240780..ef7411c660b9 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/pci_hotplug.h> | 29 | #include <linux/pci_hotplug.h> |
30 | #include <linux/smp.h> | 30 | #include <linux/smp.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/vmalloc.h> | ||
32 | #include <asm/eeh.h> /* for eeh_add_device() */ | 33 | #include <asm/eeh.h> /* for eeh_add_device() */ |
33 | #include <asm/rtas.h> /* rtas_call */ | 34 | #include <asm/rtas.h> /* rtas_call */ |
34 | #include <asm/pci-bridge.h> /* for pci_controller */ | 35 | #include <asm/pci-bridge.h> /* for pci_controller */ |
@@ -418,6 +419,8 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) | |||
418 | return -EINVAL; | 419 | return -EINVAL; |
419 | 420 | ||
420 | pcibios_remove_pci_devices(slot->bus); | 421 | pcibios_remove_pci_devices(slot->bus); |
422 | vm_unmap_aliases(); | ||
423 | |||
421 | slot->state = NOT_CONFIGURED; | 424 | slot->state = NOT_CONFIGURED; |
422 | return 0; | 425 | return 0; |
423 | } | 426 | } |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 5ea587e59e48..37499127c801 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -679,7 +679,7 @@ static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state) | |||
679 | */ | 679 | */ |
680 | int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state) | 680 | int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state) |
681 | { | 681 | { |
682 | return state > PCI_D0 ? | 682 | return state >= PCI_D0 ? |
683 | pci_platform_power_transition(dev, state) : -EINVAL; | 683 | pci_platform_power_transition(dev, state) : -EINVAL; |
684 | } | 684 | } |
685 | EXPORT_SYMBOL_GPL(__pci_complete_power_transition); | 685 | EXPORT_SYMBOL_GPL(__pci_complete_power_transition); |
@@ -716,10 +716,6 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
716 | */ | 716 | */ |
717 | return 0; | 717 | return 0; |
718 | 718 | ||
719 | /* Check if we're already there */ | ||
720 | if (dev->current_state == state) | ||
721 | return 0; | ||
722 | |||
723 | __pci_start_power_transition(dev, state); | 719 | __pci_start_power_transition(dev, state); |
724 | 720 | ||
725 | /* This device is quirked not to be put into D3, so | 721 | /* This device is quirked not to be put into D3, so |
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index aa495ad9bbd4..7a711ee314b7 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c | |||
@@ -244,11 +244,17 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) | |||
244 | 244 | ||
245 | /* Assert Secondary Bus Reset */ | 245 | /* Assert Secondary Bus Reset */ |
246 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &p2p_ctrl); | 246 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &p2p_ctrl); |
247 | p2p_ctrl |= PCI_CB_BRIDGE_CTL_CB_RESET; | 247 | p2p_ctrl |= PCI_BRIDGE_CTL_BUS_RESET; |
248 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl); | 248 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl); |
249 | 249 | ||
250 | /* | ||
251 | * we should send hot reset message for 2ms to allow it time to | ||
252 | * propogate to all downstream ports | ||
253 | */ | ||
254 | msleep(2); | ||
255 | |||
250 | /* De-assert Secondary Bus Reset */ | 256 | /* De-assert Secondary Bus Reset */ |
251 | p2p_ctrl &= ~PCI_CB_BRIDGE_CTL_CB_RESET; | 257 | p2p_ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET; |
252 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl); | 258 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl); |
253 | 259 | ||
254 | /* | 260 | /* |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 882bd8d29fe3..c82548afcd5c 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -174,19 +174,14 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
174 | pci_read_config_dword(dev, pos, &sz); | 174 | pci_read_config_dword(dev, pos, &sz); |
175 | pci_write_config_dword(dev, pos, l); | 175 | pci_write_config_dword(dev, pos, l); |
176 | 176 | ||
177 | if (!sz) | ||
178 | goto fail; /* BAR not implemented */ | ||
179 | |||
180 | /* | 177 | /* |
181 | * All bits set in sz means the device isn't working properly. | 178 | * All bits set in sz means the device isn't working properly. |
182 | * If it's a memory BAR or a ROM, bit 0 must be clear; if it's | 179 | * If the BAR isn't implemented, all bits must be 0. If it's a |
183 | * an io BAR, bit 1 must be clear. | 180 | * memory BAR or a ROM, bit 0 must be clear; if it's an io BAR, bit |
181 | * 1 must be clear. | ||
184 | */ | 182 | */ |
185 | if (sz == 0xffffffff) { | 183 | if (!sz || sz == 0xffffffff) |
186 | dev_err(&dev->dev, "reg %x: invalid size %#x; broken device?\n", | ||
187 | pos, sz); | ||
188 | goto fail; | 184 | goto fail; |
189 | } | ||
190 | 185 | ||
191 | /* | 186 | /* |
192 | * I don't know how l can have all bits set. Copied from old code. | 187 | * I don't know how l can have all bits set. Copied from old code. |
@@ -249,17 +244,13 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
249 | pos, res); | 244 | pos, res); |
250 | } | 245 | } |
251 | } else { | 246 | } else { |
252 | u32 size = pci_size(l, sz, mask); | 247 | sz = pci_size(l, sz, mask); |
253 | 248 | ||
254 | if (!size) { | 249 | if (!sz) |
255 | dev_err(&dev->dev, "reg %x: invalid size " | ||
256 | "(l %#x sz %#x mask %#x); broken device?", | ||
257 | pos, l, sz, mask); | ||
258 | goto fail; | 250 | goto fail; |
259 | } | ||
260 | 251 | ||
261 | res->start = l; | 252 | res->start = l; |
262 | res->end = l + size; | 253 | res->end = l + sz; |
263 | 254 | ||
264 | dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res); | 255 | dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res); |
265 | } | 256 | } |
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 4014cf8e4a26..508f94a2a78d 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -335,7 +335,6 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le | |||
335 | 335 | ||
336 | mutex_lock(&s->ops_mutex); | 336 | mutex_lock(&s->ops_mutex); |
337 | list_del(&p_dev->socket_device_list); | 337 | list_del(&p_dev->socket_device_list); |
338 | p_dev->_removed = 1; | ||
339 | mutex_unlock(&s->ops_mutex); | 338 | mutex_unlock(&s->ops_mutex); |
340 | 339 | ||
341 | dev_dbg(&p_dev->dev, "unregistering device\n"); | 340 | dev_dbg(&p_dev->dev, "unregistering device\n"); |
@@ -654,14 +653,7 @@ static int pcmcia_requery_callback(struct device *dev, void * _data) | |||
654 | 653 | ||
655 | static void pcmcia_requery(struct pcmcia_socket *s) | 654 | static void pcmcia_requery(struct pcmcia_socket *s) |
656 | { | 655 | { |
657 | int present, has_pfc; | 656 | int has_pfc; |
658 | |||
659 | mutex_lock(&s->ops_mutex); | ||
660 | present = s->pcmcia_state.present; | ||
661 | mutex_unlock(&s->ops_mutex); | ||
662 | |||
663 | if (!present) | ||
664 | return; | ||
665 | 657 | ||
666 | if (s->functions == 0) { | 658 | if (s->functions == 0) { |
667 | pcmcia_card_add(s); | 659 | pcmcia_card_add(s); |
@@ -828,11 +820,12 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, | |||
828 | } | 820 | } |
829 | 821 | ||
830 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) { | 822 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) { |
831 | if (dev->device_no != did->device_no) | 823 | dev_dbg(&dev->dev, "this is a pseudo-multi-function device\n"); |
832 | return 0; | ||
833 | mutex_lock(&dev->socket->ops_mutex); | 824 | mutex_lock(&dev->socket->ops_mutex); |
834 | dev->socket->pcmcia_state.has_pfc = 1; | 825 | dev->socket->pcmcia_state.has_pfc = 1; |
835 | mutex_unlock(&dev->socket->ops_mutex); | 826 | mutex_unlock(&dev->socket->ops_mutex); |
827 | if (dev->device_no != did->device_no) | ||
828 | return 0; | ||
836 | } | 829 | } |
837 | 830 | ||
838 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) { | 831 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) { |
@@ -843,7 +836,7 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, | |||
843 | 836 | ||
844 | /* if this is a pseudo-multi-function device, | 837 | /* if this is a pseudo-multi-function device, |
845 | * we need explicit matches */ | 838 | * we need explicit matches */ |
846 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) | 839 | if (dev->socket->pcmcia_state.has_pfc) |
847 | return 0; | 840 | return 0; |
848 | if (dev->device_no) | 841 | if (dev->device_no) |
849 | return 0; | 842 | return 0; |
@@ -1260,9 +1253,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) | |||
1260 | 1253 | ||
1261 | switch (event) { | 1254 | switch (event) { |
1262 | case CS_EVENT_CARD_REMOVAL: | 1255 | case CS_EVENT_CARD_REMOVAL: |
1263 | mutex_lock(&s->ops_mutex); | 1256 | atomic_set(&skt->present, 0); |
1264 | s->pcmcia_state.present = 0; | ||
1265 | mutex_unlock(&s->ops_mutex); | ||
1266 | pcmcia_card_remove(skt, NULL); | 1257 | pcmcia_card_remove(skt, NULL); |
1267 | handle_event(skt, event); | 1258 | handle_event(skt, event); |
1268 | mutex_lock(&s->ops_mutex); | 1259 | mutex_lock(&s->ops_mutex); |
@@ -1271,9 +1262,9 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) | |||
1271 | break; | 1262 | break; |
1272 | 1263 | ||
1273 | case CS_EVENT_CARD_INSERTION: | 1264 | case CS_EVENT_CARD_INSERTION: |
1265 | atomic_set(&skt->present, 1); | ||
1274 | mutex_lock(&s->ops_mutex); | 1266 | mutex_lock(&s->ops_mutex); |
1275 | s->pcmcia_state.has_pfc = 0; | 1267 | s->pcmcia_state.has_pfc = 0; |
1276 | s->pcmcia_state.present = 1; | ||
1277 | destroy_cis_cache(s); /* to be on the safe side... */ | 1268 | destroy_cis_cache(s); /* to be on the safe side... */ |
1278 | mutex_unlock(&s->ops_mutex); | 1269 | mutex_unlock(&s->ops_mutex); |
1279 | pcmcia_card_add(skt); | 1270 | pcmcia_card_add(skt); |
@@ -1313,7 +1304,13 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) | |||
1313 | return 0; | 1304 | return 0; |
1314 | } /* ds_event */ | 1305 | } /* ds_event */ |
1315 | 1306 | ||
1316 | 1307 | /* | |
1308 | * NOTE: This is racy. There's no guarantee the card will still be | ||
1309 | * physically present, even if the call to this function returns | ||
1310 | * non-NULL. Furthermore, the device driver most likely is unbound | ||
1311 | * almost immediately, so the timeframe where pcmcia_dev_present | ||
1312 | * returns NULL is probably really really small. | ||
1313 | */ | ||
1317 | struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) | 1314 | struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) |
1318 | { | 1315 | { |
1319 | struct pcmcia_device *p_dev; | 1316 | struct pcmcia_device *p_dev; |
@@ -1323,22 +1320,9 @@ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) | |||
1323 | if (!p_dev) | 1320 | if (!p_dev) |
1324 | return NULL; | 1321 | return NULL; |
1325 | 1322 | ||
1326 | mutex_lock(&p_dev->socket->ops_mutex); | 1323 | if (atomic_read(&p_dev->socket->present) != 0) |
1327 | if (!p_dev->socket->pcmcia_state.present) | 1324 | ret = p_dev; |
1328 | goto out; | ||
1329 | |||
1330 | if (p_dev->socket->pcmcia_state.dead) | ||
1331 | goto out; | ||
1332 | 1325 | ||
1333 | if (p_dev->_removed) | ||
1334 | goto out; | ||
1335 | |||
1336 | if (p_dev->suspended) | ||
1337 | goto out; | ||
1338 | |||
1339 | ret = p_dev; | ||
1340 | out: | ||
1341 | mutex_unlock(&p_dev->socket->ops_mutex); | ||
1342 | pcmcia_put_dev(p_dev); | 1326 | pcmcia_put_dev(p_dev); |
1343 | return ret; | 1327 | return ret; |
1344 | } | 1328 | } |
@@ -1388,6 +1372,8 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev, | |||
1388 | return ret; | 1372 | return ret; |
1389 | } | 1373 | } |
1390 | 1374 | ||
1375 | atomic_set(&socket->present, 0); | ||
1376 | |||
1391 | return 0; | 1377 | return 0; |
1392 | } | 1378 | } |
1393 | 1379 | ||
@@ -1399,10 +1385,6 @@ static void pcmcia_bus_remove_socket(struct device *dev, | |||
1399 | if (!socket) | 1385 | if (!socket) |
1400 | return; | 1386 | return; |
1401 | 1387 | ||
1402 | mutex_lock(&socket->ops_mutex); | ||
1403 | socket->pcmcia_state.dead = 1; | ||
1404 | mutex_unlock(&socket->ops_mutex); | ||
1405 | |||
1406 | pccard_register_pcmcia(socket, NULL); | 1388 | pccard_register_pcmcia(socket, NULL); |
1407 | 1389 | ||
1408 | /* unregister any unbound devices */ | 1390 | /* unregister any unbound devices */ |
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 7bec4588c268..6c3320d75055 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -390,6 +390,7 @@ config EEEPC_WMI | |||
390 | depends on ACPI_WMI | 390 | depends on ACPI_WMI |
391 | depends on INPUT | 391 | depends on INPUT |
392 | depends on EXPERIMENTAL | 392 | depends on EXPERIMENTAL |
393 | select INPUT_SPARSEKMAP | ||
393 | ---help--- | 394 | ---help--- |
394 | Say Y here if you want to support WMI-based hotkeys on Eee PC laptops. | 395 | Say Y here if you want to support WMI-based hotkeys on Eee PC laptops. |
395 | 396 | ||
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 52262b012abb..efe8f6388906 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
@@ -79,15 +79,15 @@ static uint wapf = 1; | |||
79 | module_param(wapf, uint, 0644); | 79 | module_param(wapf, uint, 0644); |
80 | MODULE_PARM_DESC(wapf, "WAPF value"); | 80 | MODULE_PARM_DESC(wapf, "WAPF value"); |
81 | 81 | ||
82 | static uint wlan_status = 1; | 82 | static int wlan_status = 1; |
83 | static uint bluetooth_status = 1; | 83 | static int bluetooth_status = 1; |
84 | 84 | ||
85 | module_param(wlan_status, uint, 0644); | 85 | module_param(wlan_status, int, 0644); |
86 | MODULE_PARM_DESC(wlan_status, "Set the wireless status on boot " | 86 | MODULE_PARM_DESC(wlan_status, "Set the wireless status on boot " |
87 | "(0 = disabled, 1 = enabled, -1 = don't do anything). " | 87 | "(0 = disabled, 1 = enabled, -1 = don't do anything). " |
88 | "default is 1"); | 88 | "default is 1"); |
89 | 89 | ||
90 | module_param(bluetooth_status, uint, 0644); | 90 | module_param(bluetooth_status, int, 0644); |
91 | MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot " | 91 | MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot " |
92 | "(0 = disabled, 1 = enabled, -1 = don't do anything). " | 92 | "(0 = disabled, 1 = enabled, -1 = don't do anything). " |
93 | "default is 1"); | 93 | "default is 1"); |
diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c index 6ba6c30e5bb6..66f53c3c35e8 100644 --- a/drivers/platform/x86/dell-wmi.c +++ b/drivers/platform/x86/dell-wmi.c | |||
@@ -217,6 +217,7 @@ static void dell_wmi_notify(u32 value, void *context) | |||
217 | if (dell_new_hk_type && (buffer_entry[1] != 0x10)) { | 217 | if (dell_new_hk_type && (buffer_entry[1] != 0x10)) { |
218 | printk(KERN_INFO "dell-wmi: Received unknown WMI event" | 218 | printk(KERN_INFO "dell-wmi: Received unknown WMI event" |
219 | " (0x%x)\n", buffer_entry[1]); | 219 | " (0x%x)\n", buffer_entry[1]); |
220 | kfree(obj); | ||
220 | return; | 221 | return; |
221 | } | 222 | } |
222 | 223 | ||
@@ -234,7 +235,7 @@ static void dell_wmi_notify(u32 value, void *context) | |||
234 | key->keycode == KEY_BRIGHTNESSDOWN) && acpi_video) { | 235 | key->keycode == KEY_BRIGHTNESSDOWN) && acpi_video) { |
235 | /* Don't report brightness notifications that will also | 236 | /* Don't report brightness notifications that will also |
236 | * come via ACPI */ | 237 | * come via ACPI */ |
237 | return; | 238 | ; |
238 | } else { | 239 | } else { |
239 | input_report_key(dell_wmi_input_dev, key->keycode, 1); | 240 | input_report_key(dell_wmi_input_dev, key->keycode, 1); |
240 | input_sync(dell_wmi_input_dev); | 241 | input_sync(dell_wmi_input_dev); |
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index 54a015785ca8..0306174ba875 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -169,7 +169,6 @@ struct eeepc_laptop { | |||
169 | struct backlight_device *backlight_device; | 169 | struct backlight_device *backlight_device; |
170 | 170 | ||
171 | struct input_dev *inputdev; | 171 | struct input_dev *inputdev; |
172 | struct key_entry *keymap; | ||
173 | 172 | ||
174 | struct rfkill *wlan_rfkill; | 173 | struct rfkill *wlan_rfkill; |
175 | struct rfkill *bluetooth_rfkill; | 174 | struct rfkill *bluetooth_rfkill; |
@@ -1204,8 +1203,8 @@ static int eeepc_input_init(struct eeepc_laptop *eeepc) | |||
1204 | static void eeepc_input_exit(struct eeepc_laptop *eeepc) | 1203 | static void eeepc_input_exit(struct eeepc_laptop *eeepc) |
1205 | { | 1204 | { |
1206 | if (eeepc->inputdev) { | 1205 | if (eeepc->inputdev) { |
1206 | sparse_keymap_free(eeepc->inputdev); | ||
1207 | input_unregister_device(eeepc->inputdev); | 1207 | input_unregister_device(eeepc->inputdev); |
1208 | kfree(eeepc->keymap); | ||
1209 | } | 1208 | } |
1210 | } | 1209 | } |
1211 | 1210 | ||
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c index 9f8822658fd7..b227eb469f49 100644 --- a/drivers/platform/x86/eeepc-wmi.c +++ b/drivers/platform/x86/eeepc-wmi.c | |||
@@ -23,6 +23,8 @@ | |||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
27 | |||
26 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
27 | #include <linux/module.h> | 29 | #include <linux/module.h> |
28 | #include <linux/init.h> | 30 | #include <linux/init.h> |
@@ -30,22 +32,34 @@ | |||
30 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
31 | #include <linux/input.h> | 33 | #include <linux/input.h> |
32 | #include <linux/input/sparse-keymap.h> | 34 | #include <linux/input/sparse-keymap.h> |
35 | #include <linux/fb.h> | ||
36 | #include <linux/backlight.h> | ||
37 | #include <linux/platform_device.h> | ||
33 | #include <acpi/acpi_bus.h> | 38 | #include <acpi/acpi_bus.h> |
34 | #include <acpi/acpi_drivers.h> | 39 | #include <acpi/acpi_drivers.h> |
35 | 40 | ||
41 | #define EEEPC_WMI_FILE "eeepc-wmi" | ||
42 | |||
36 | MODULE_AUTHOR("Yong Wang <yong.y.wang@intel.com>"); | 43 | MODULE_AUTHOR("Yong Wang <yong.y.wang@intel.com>"); |
37 | MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver"); | 44 | MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver"); |
38 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
39 | 46 | ||
40 | #define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000" | 47 | #define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000" |
48 | #define EEEPC_WMI_MGMT_GUID "97845ED0-4E6D-11DE-8A39-0800200C9A66" | ||
41 | 49 | ||
42 | MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID); | 50 | MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID); |
51 | MODULE_ALIAS("wmi:"EEEPC_WMI_MGMT_GUID); | ||
43 | 52 | ||
44 | #define NOTIFY_BRNUP_MIN 0x11 | 53 | #define NOTIFY_BRNUP_MIN 0x11 |
45 | #define NOTIFY_BRNUP_MAX 0x1f | 54 | #define NOTIFY_BRNUP_MAX 0x1f |
46 | #define NOTIFY_BRNDOWN_MIN 0x20 | 55 | #define NOTIFY_BRNDOWN_MIN 0x20 |
47 | #define NOTIFY_BRNDOWN_MAX 0x2e | 56 | #define NOTIFY_BRNDOWN_MAX 0x2e |
48 | 57 | ||
58 | #define EEEPC_WMI_METHODID_DEVS 0x53564544 | ||
59 | #define EEEPC_WMI_METHODID_DSTS 0x53544344 | ||
60 | |||
61 | #define EEEPC_WMI_DEVID_BACKLIGHT 0x00050012 | ||
62 | |||
49 | static const struct key_entry eeepc_wmi_keymap[] = { | 63 | static const struct key_entry eeepc_wmi_keymap[] = { |
50 | /* Sleep already handled via generic ACPI code */ | 64 | /* Sleep already handled via generic ACPI code */ |
51 | { KE_KEY, 0x5d, { KEY_WLAN } }, | 65 | { KE_KEY, 0x5d, { KEY_WLAN } }, |
@@ -58,18 +72,198 @@ static const struct key_entry eeepc_wmi_keymap[] = { | |||
58 | { KE_END, 0}, | 72 | { KE_END, 0}, |
59 | }; | 73 | }; |
60 | 74 | ||
61 | static struct input_dev *eeepc_wmi_input_dev; | 75 | struct bios_args { |
76 | u32 dev_id; | ||
77 | u32 ctrl_param; | ||
78 | }; | ||
79 | |||
80 | struct eeepc_wmi { | ||
81 | struct input_dev *inputdev; | ||
82 | struct backlight_device *backlight_device; | ||
83 | }; | ||
84 | |||
85 | static struct platform_device *platform_device; | ||
86 | |||
87 | static int eeepc_wmi_input_init(struct eeepc_wmi *eeepc) | ||
88 | { | ||
89 | int err; | ||
90 | |||
91 | eeepc->inputdev = input_allocate_device(); | ||
92 | if (!eeepc->inputdev) | ||
93 | return -ENOMEM; | ||
94 | |||
95 | eeepc->inputdev->name = "Eee PC WMI hotkeys"; | ||
96 | eeepc->inputdev->phys = EEEPC_WMI_FILE "/input0"; | ||
97 | eeepc->inputdev->id.bustype = BUS_HOST; | ||
98 | eeepc->inputdev->dev.parent = &platform_device->dev; | ||
99 | |||
100 | err = sparse_keymap_setup(eeepc->inputdev, eeepc_wmi_keymap, NULL); | ||
101 | if (err) | ||
102 | goto err_free_dev; | ||
103 | |||
104 | err = input_register_device(eeepc->inputdev); | ||
105 | if (err) | ||
106 | goto err_free_keymap; | ||
107 | |||
108 | return 0; | ||
109 | |||
110 | err_free_keymap: | ||
111 | sparse_keymap_free(eeepc->inputdev); | ||
112 | err_free_dev: | ||
113 | input_free_device(eeepc->inputdev); | ||
114 | return err; | ||
115 | } | ||
116 | |||
117 | static void eeepc_wmi_input_exit(struct eeepc_wmi *eeepc) | ||
118 | { | ||
119 | if (eeepc->inputdev) { | ||
120 | sparse_keymap_free(eeepc->inputdev); | ||
121 | input_unregister_device(eeepc->inputdev); | ||
122 | } | ||
123 | |||
124 | eeepc->inputdev = NULL; | ||
125 | } | ||
126 | |||
127 | static acpi_status eeepc_wmi_get_devstate(u32 dev_id, u32 *ctrl_param) | ||
128 | { | ||
129 | struct acpi_buffer input = { (acpi_size)sizeof(u32), &dev_id }; | ||
130 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
131 | union acpi_object *obj; | ||
132 | acpi_status status; | ||
133 | u32 tmp; | ||
134 | |||
135 | status = wmi_evaluate_method(EEEPC_WMI_MGMT_GUID, | ||
136 | 1, EEEPC_WMI_METHODID_DSTS, &input, &output); | ||
137 | |||
138 | if (ACPI_FAILURE(status)) | ||
139 | return status; | ||
140 | |||
141 | obj = (union acpi_object *)output.pointer; | ||
142 | if (obj && obj->type == ACPI_TYPE_INTEGER) | ||
143 | tmp = (u32)obj->integer.value; | ||
144 | else | ||
145 | tmp = 0; | ||
146 | |||
147 | if (ctrl_param) | ||
148 | *ctrl_param = tmp; | ||
149 | |||
150 | kfree(obj); | ||
151 | |||
152 | return status; | ||
153 | |||
154 | } | ||
155 | |||
156 | static acpi_status eeepc_wmi_set_devstate(u32 dev_id, u32 ctrl_param) | ||
157 | { | ||
158 | struct bios_args args = { | ||
159 | .dev_id = dev_id, | ||
160 | .ctrl_param = ctrl_param, | ||
161 | }; | ||
162 | struct acpi_buffer input = { (acpi_size)sizeof(args), &args }; | ||
163 | acpi_status status; | ||
164 | |||
165 | status = wmi_evaluate_method(EEEPC_WMI_MGMT_GUID, | ||
166 | 1, EEEPC_WMI_METHODID_DEVS, &input, NULL); | ||
167 | |||
168 | return status; | ||
169 | } | ||
170 | |||
171 | static int read_brightness(struct backlight_device *bd) | ||
172 | { | ||
173 | static u32 ctrl_param; | ||
174 | acpi_status status; | ||
175 | |||
176 | status = eeepc_wmi_get_devstate(EEEPC_WMI_DEVID_BACKLIGHT, &ctrl_param); | ||
177 | |||
178 | if (ACPI_FAILURE(status)) | ||
179 | return -1; | ||
180 | else | ||
181 | return ctrl_param & 0xFF; | ||
182 | } | ||
183 | |||
184 | static int update_bl_status(struct backlight_device *bd) | ||
185 | { | ||
186 | |||
187 | static u32 ctrl_param; | ||
188 | acpi_status status; | ||
189 | |||
190 | ctrl_param = bd->props.brightness; | ||
191 | |||
192 | status = eeepc_wmi_set_devstate(EEEPC_WMI_DEVID_BACKLIGHT, ctrl_param); | ||
193 | |||
194 | if (ACPI_FAILURE(status)) | ||
195 | return -1; | ||
196 | else | ||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | static const struct backlight_ops eeepc_wmi_bl_ops = { | ||
201 | .get_brightness = read_brightness, | ||
202 | .update_status = update_bl_status, | ||
203 | }; | ||
204 | |||
205 | static int eeepc_wmi_backlight_notify(struct eeepc_wmi *eeepc, int code) | ||
206 | { | ||
207 | struct backlight_device *bd = eeepc->backlight_device; | ||
208 | int old = bd->props.brightness; | ||
209 | int new; | ||
210 | |||
211 | if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX) | ||
212 | new = code - NOTIFY_BRNUP_MIN + 1; | ||
213 | else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX) | ||
214 | new = code - NOTIFY_BRNDOWN_MIN; | ||
215 | |||
216 | bd->props.brightness = new; | ||
217 | backlight_update_status(bd); | ||
218 | backlight_force_update(bd, BACKLIGHT_UPDATE_HOTKEY); | ||
219 | |||
220 | return old; | ||
221 | } | ||
222 | |||
223 | static int eeepc_wmi_backlight_init(struct eeepc_wmi *eeepc) | ||
224 | { | ||
225 | struct backlight_device *bd; | ||
226 | struct backlight_properties props; | ||
227 | |||
228 | memset(&props, 0, sizeof(struct backlight_properties)); | ||
229 | props.max_brightness = 15; | ||
230 | bd = backlight_device_register(EEEPC_WMI_FILE, | ||
231 | &platform_device->dev, eeepc, | ||
232 | &eeepc_wmi_bl_ops, &props); | ||
233 | if (IS_ERR(bd)) { | ||
234 | pr_err("Could not register backlight device\n"); | ||
235 | return PTR_ERR(bd); | ||
236 | } | ||
237 | |||
238 | eeepc->backlight_device = bd; | ||
239 | |||
240 | bd->props.brightness = read_brightness(bd); | ||
241 | bd->props.power = FB_BLANK_UNBLANK; | ||
242 | backlight_update_status(bd); | ||
243 | |||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static void eeepc_wmi_backlight_exit(struct eeepc_wmi *eeepc) | ||
248 | { | ||
249 | if (eeepc->backlight_device) | ||
250 | backlight_device_unregister(eeepc->backlight_device); | ||
251 | |||
252 | eeepc->backlight_device = NULL; | ||
253 | } | ||
62 | 254 | ||
63 | static void eeepc_wmi_notify(u32 value, void *context) | 255 | static void eeepc_wmi_notify(u32 value, void *context) |
64 | { | 256 | { |
257 | struct eeepc_wmi *eeepc = context; | ||
65 | struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; | 258 | struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; |
66 | union acpi_object *obj; | 259 | union acpi_object *obj; |
67 | acpi_status status; | 260 | acpi_status status; |
68 | int code; | 261 | int code; |
262 | int orig_code; | ||
69 | 263 | ||
70 | status = wmi_get_event_data(value, &response); | 264 | status = wmi_get_event_data(value, &response); |
71 | if (status != AE_OK) { | 265 | if (status != AE_OK) { |
72 | pr_err("EEEPC WMI: bad event status 0x%x\n", status); | 266 | pr_err("bad event status 0x%x\n", status); |
73 | return; | 267 | return; |
74 | } | 268 | } |
75 | 269 | ||
@@ -77,81 +271,142 @@ static void eeepc_wmi_notify(u32 value, void *context) | |||
77 | 271 | ||
78 | if (obj && obj->type == ACPI_TYPE_INTEGER) { | 272 | if (obj && obj->type == ACPI_TYPE_INTEGER) { |
79 | code = obj->integer.value; | 273 | code = obj->integer.value; |
274 | orig_code = code; | ||
80 | 275 | ||
81 | if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX) | 276 | if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX) |
82 | code = NOTIFY_BRNUP_MIN; | 277 | code = NOTIFY_BRNUP_MIN; |
83 | else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX) | 278 | else if (code >= NOTIFY_BRNDOWN_MIN && |
279 | code <= NOTIFY_BRNDOWN_MAX) | ||
84 | code = NOTIFY_BRNDOWN_MIN; | 280 | code = NOTIFY_BRNDOWN_MIN; |
85 | 281 | ||
86 | if (!sparse_keymap_report_event(eeepc_wmi_input_dev, | 282 | if (code == NOTIFY_BRNUP_MIN || code == NOTIFY_BRNDOWN_MIN) { |
283 | if (!acpi_video_backlight_support()) | ||
284 | eeepc_wmi_backlight_notify(eeepc, orig_code); | ||
285 | } | ||
286 | |||
287 | if (!sparse_keymap_report_event(eeepc->inputdev, | ||
87 | code, 1, true)) | 288 | code, 1, true)) |
88 | pr_info("EEEPC WMI: Unknown key %x pressed\n", code); | 289 | pr_info("Unknown key %x pressed\n", code); |
89 | } | 290 | } |
90 | 291 | ||
91 | kfree(obj); | 292 | kfree(obj); |
92 | } | 293 | } |
93 | 294 | ||
94 | static int eeepc_wmi_input_setup(void) | 295 | static int __devinit eeepc_wmi_platform_probe(struct platform_device *device) |
95 | { | 296 | { |
297 | struct eeepc_wmi *eeepc; | ||
96 | int err; | 298 | int err; |
299 | acpi_status status; | ||
97 | 300 | ||
98 | eeepc_wmi_input_dev = input_allocate_device(); | 301 | eeepc = platform_get_drvdata(device); |
99 | if (!eeepc_wmi_input_dev) | ||
100 | return -ENOMEM; | ||
101 | |||
102 | eeepc_wmi_input_dev->name = "Eee PC WMI hotkeys"; | ||
103 | eeepc_wmi_input_dev->phys = "wmi/input0"; | ||
104 | eeepc_wmi_input_dev->id.bustype = BUS_HOST; | ||
105 | 302 | ||
106 | err = sparse_keymap_setup(eeepc_wmi_input_dev, eeepc_wmi_keymap, NULL); | 303 | err = eeepc_wmi_input_init(eeepc); |
107 | if (err) | 304 | if (err) |
108 | goto err_free_dev; | 305 | goto error_input; |
109 | 306 | ||
110 | err = input_register_device(eeepc_wmi_input_dev); | 307 | if (!acpi_video_backlight_support()) { |
111 | if (err) | 308 | err = eeepc_wmi_backlight_init(eeepc); |
112 | goto err_free_keymap; | 309 | if (err) |
310 | goto error_backlight; | ||
311 | } else | ||
312 | pr_info("Backlight controlled by ACPI video driver\n"); | ||
313 | |||
314 | status = wmi_install_notify_handler(EEEPC_WMI_EVENT_GUID, | ||
315 | eeepc_wmi_notify, eeepc); | ||
316 | if (ACPI_FAILURE(status)) { | ||
317 | pr_err("Unable to register notify handler - %d\n", | ||
318 | status); | ||
319 | err = -ENODEV; | ||
320 | goto error_wmi; | ||
321 | } | ||
113 | 322 | ||
114 | return 0; | 323 | return 0; |
115 | 324 | ||
116 | err_free_keymap: | 325 | error_wmi: |
117 | sparse_keymap_free(eeepc_wmi_input_dev); | 326 | eeepc_wmi_backlight_exit(eeepc); |
118 | err_free_dev: | 327 | error_backlight: |
119 | input_free_device(eeepc_wmi_input_dev); | 328 | eeepc_wmi_input_exit(eeepc); |
329 | error_input: | ||
120 | return err; | 330 | return err; |
121 | } | 331 | } |
122 | 332 | ||
333 | static int __devexit eeepc_wmi_platform_remove(struct platform_device *device) | ||
334 | { | ||
335 | struct eeepc_wmi *eeepc; | ||
336 | |||
337 | eeepc = platform_get_drvdata(device); | ||
338 | wmi_remove_notify_handler(EEEPC_WMI_EVENT_GUID); | ||
339 | eeepc_wmi_backlight_exit(eeepc); | ||
340 | eeepc_wmi_input_exit(eeepc); | ||
341 | |||
342 | return 0; | ||
343 | } | ||
344 | |||
345 | static struct platform_driver platform_driver = { | ||
346 | .driver = { | ||
347 | .name = EEEPC_WMI_FILE, | ||
348 | .owner = THIS_MODULE, | ||
349 | }, | ||
350 | .probe = eeepc_wmi_platform_probe, | ||
351 | .remove = __devexit_p(eeepc_wmi_platform_remove), | ||
352 | }; | ||
353 | |||
123 | static int __init eeepc_wmi_init(void) | 354 | static int __init eeepc_wmi_init(void) |
124 | { | 355 | { |
356 | struct eeepc_wmi *eeepc; | ||
125 | int err; | 357 | int err; |
126 | acpi_status status; | ||
127 | 358 | ||
128 | if (!wmi_has_guid(EEEPC_WMI_EVENT_GUID)) { | 359 | if (!wmi_has_guid(EEEPC_WMI_EVENT_GUID) || |
129 | pr_warning("EEEPC WMI: No known WMI GUID found\n"); | 360 | !wmi_has_guid(EEEPC_WMI_MGMT_GUID)) { |
361 | pr_warning("No known WMI GUID found\n"); | ||
130 | return -ENODEV; | 362 | return -ENODEV; |
131 | } | 363 | } |
132 | 364 | ||
133 | err = eeepc_wmi_input_setup(); | 365 | eeepc = kzalloc(sizeof(struct eeepc_wmi), GFP_KERNEL); |
134 | if (err) | 366 | if (!eeepc) |
135 | return err; | 367 | return -ENOMEM; |
136 | 368 | ||
137 | status = wmi_install_notify_handler(EEEPC_WMI_EVENT_GUID, | 369 | platform_device = platform_device_alloc(EEEPC_WMI_FILE, -1); |
138 | eeepc_wmi_notify, NULL); | 370 | if (!platform_device) { |
139 | if (ACPI_FAILURE(status)) { | 371 | pr_warning("Unable to allocate platform device\n"); |
140 | sparse_keymap_free(eeepc_wmi_input_dev); | 372 | err = -ENOMEM; |
141 | input_unregister_device(eeepc_wmi_input_dev); | 373 | goto fail_platform; |
142 | pr_err("EEEPC WMI: Unable to register notify handler - %d\n", | 374 | } |
143 | status); | 375 | |
144 | return -ENODEV; | 376 | err = platform_device_add(platform_device); |
377 | if (err) { | ||
378 | pr_warning("Unable to add platform device\n"); | ||
379 | goto put_dev; | ||
380 | } | ||
381 | |||
382 | platform_set_drvdata(platform_device, eeepc); | ||
383 | |||
384 | err = platform_driver_register(&platform_driver); | ||
385 | if (err) { | ||
386 | pr_warning("Unable to register platform driver\n"); | ||
387 | goto del_dev; | ||
145 | } | 388 | } |
146 | 389 | ||
147 | return 0; | 390 | return 0; |
391 | |||
392 | del_dev: | ||
393 | platform_device_del(platform_device); | ||
394 | put_dev: | ||
395 | platform_device_put(platform_device); | ||
396 | fail_platform: | ||
397 | kfree(eeepc); | ||
398 | |||
399 | return err; | ||
148 | } | 400 | } |
149 | 401 | ||
150 | static void __exit eeepc_wmi_exit(void) | 402 | static void __exit eeepc_wmi_exit(void) |
151 | { | 403 | { |
152 | wmi_remove_notify_handler(EEEPC_WMI_EVENT_GUID); | 404 | struct eeepc_wmi *eeepc; |
153 | sparse_keymap_free(eeepc_wmi_input_dev); | 405 | |
154 | input_unregister_device(eeepc_wmi_input_dev); | 406 | eeepc = platform_get_drvdata(platform_device); |
407 | platform_driver_unregister(&platform_driver); | ||
408 | platform_device_unregister(platform_device); | ||
409 | kfree(eeepc); | ||
155 | } | 410 | } |
156 | 411 | ||
157 | module_init(eeepc_wmi_init); | 412 | module_init(eeepc_wmi_init); |
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index b6218f11c957..552cad85ae5a 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c | |||
@@ -109,7 +109,7 @@ static int max8925_is_enabled(struct regulator_dev *rdev) | |||
109 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); | 109 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); |
110 | int ret; | 110 | int ret; |
111 | 111 | ||
112 | ret = max8925_reg_read(info->i2c, info->vol_reg); | 112 | ret = max8925_reg_read(info->i2c, info->enable_reg); |
113 | if (ret < 0) | 113 | if (ret < 0) |
114 | return ret; | 114 | return ret; |
115 | 115 | ||
diff --git a/drivers/serial/serial_ks8695.c b/drivers/serial/serial_ks8695.c index 2e71bbc04dac..b1962025b1aa 100644 --- a/drivers/serial/serial_ks8695.c +++ b/drivers/serial/serial_ks8695.c | |||
@@ -650,6 +650,7 @@ static struct console ks8695_console = { | |||
650 | 650 | ||
651 | static int __init ks8695_console_init(void) | 651 | static int __init ks8695_console_init(void) |
652 | { | 652 | { |
653 | add_preferred_console(SERIAL_KS8695_DEVNAME, 0, NULL); | ||
653 | register_console(&ks8695_console); | 654 | register_console(&ks8695_console); |
654 | return 0; | 655 | return 0; |
655 | } | 656 | } |
diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c index 581d2dbf675a..ecf405562f5c 100644 --- a/drivers/video/efifb.c +++ b/drivers/video/efifb.c | |||
@@ -49,6 +49,7 @@ enum { | |||
49 | M_MBP_2, /* MacBook Pro 2nd gen */ | 49 | M_MBP_2, /* MacBook Pro 2nd gen */ |
50 | M_MBP_SR, /* MacBook Pro (Santa Rosa) */ | 50 | M_MBP_SR, /* MacBook Pro (Santa Rosa) */ |
51 | M_MBP_4, /* MacBook Pro, 4th gen */ | 51 | M_MBP_4, /* MacBook Pro, 4th gen */ |
52 | M_MBP_5_1, /* MacBook Pro, 5,1th gen */ | ||
52 | M_UNKNOWN /* placeholder */ | 53 | M_UNKNOWN /* placeholder */ |
53 | }; | 54 | }; |
54 | 55 | ||
@@ -70,6 +71,7 @@ static struct efifb_dmi_info { | |||
70 | [M_MBP_2] = { "mbp2", 0, 0, 0, 0 }, /* placeholder */ | 71 | [M_MBP_2] = { "mbp2", 0, 0, 0, 0 }, /* placeholder */ |
71 | [M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900 }, | 72 | [M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900 }, |
72 | [M_MBP_4] = { "mbp4", 0xc0060000, 2048 * 4, 1920, 1200 }, | 73 | [M_MBP_4] = { "mbp4", 0xc0060000, 2048 * 4, 1920, 1200 }, |
74 | [M_MBP_5_1] = { "mbp51", 0xc0010000, 2048 * 4, 1440, 900 }, | ||
73 | [M_UNKNOWN] = { NULL, 0, 0, 0, 0 } | 75 | [M_UNKNOWN] = { NULL, 0, 0, 0, 0 } |
74 | }; | 76 | }; |
75 | 77 | ||
@@ -106,6 +108,7 @@ static struct dmi_system_id __initdata dmi_system_table[] = { | |||
106 | EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro3,1", M_MBP_SR), | 108 | EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro3,1", M_MBP_SR), |
107 | EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro3,1", M_MBP_SR), | 109 | EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro3,1", M_MBP_SR), |
108 | EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro4,1", M_MBP_4), | 110 | EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro4,1", M_MBP_4), |
111 | EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,1", M_MBP_5_1), | ||
109 | {}, | 112 | {}, |
110 | }; | 113 | }; |
111 | 114 | ||
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index ef36fca2eed4..3a7e9ff8a746 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/clk.h> | 17 | #include <linux/clk.h> |
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/sched.h> | ||
19 | 20 | ||
20 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
21 | #include <mach/hardware.h> | 22 | #include <mach/hardware.h> |
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 1ed3d554e372..17726a05a0a6 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c | |||
@@ -115,9 +115,8 @@ static struct w1_therm_family_converter w1_therm_families[] = { | |||
115 | 115 | ||
116 | static inline int w1_DS18B20_convert_temp(u8 rom[9]) | 116 | static inline int w1_DS18B20_convert_temp(u8 rom[9]) |
117 | { | 117 | { |
118 | int t = ((s16)rom[1] << 8) | rom[0]; | 118 | s16 t = le16_to_cpup((__le16 *)rom); |
119 | t = t*1000/16; | 119 | return t*1000/16; |
120 | return t; | ||
121 | } | 120 | } |
122 | 121 | ||
123 | static inline int w1_DS18S20_convert_temp(u8 rom[9]) | 122 | static inline int w1_DS18S20_convert_temp(u8 rom[9]) |
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c index 500d38342e1e..801ead191499 100644 --- a/drivers/watchdog/booke_wdt.c +++ b/drivers/watchdog/booke_wdt.c | |||
@@ -121,7 +121,7 @@ static ssize_t booke_wdt_write(struct file *file, const char __user *buf, | |||
121 | return count; | 121 | return count; |
122 | } | 122 | } |
123 | 123 | ||
124 | static const struct watchdog_info ident = { | 124 | static struct watchdog_info ident = { |
125 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | 125 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, |
126 | .identity = "PowerPC Book-E Watchdog", | 126 | .identity = "PowerPC Book-E Watchdog", |
127 | }; | 127 | }; |
diff --git a/drivers/watchdog/sb_wdog.c b/drivers/watchdog/sb_wdog.c index c8eadd478175..88c83aa57303 100644 --- a/drivers/watchdog/sb_wdog.c +++ b/drivers/watchdog/sb_wdog.c | |||
@@ -67,8 +67,8 @@ static DEFINE_SPINLOCK(sbwd_lock); | |||
67 | void sbwdog_set(char __iomem *wdog, unsigned long t) | 67 | void sbwdog_set(char __iomem *wdog, unsigned long t) |
68 | { | 68 | { |
69 | spin_lock(&sbwd_lock); | 69 | spin_lock(&sbwd_lock); |
70 | __raw_writeb(0, wdog - 0x10); | 70 | __raw_writeb(0, wdog); |
71 | __raw_writeq(t & 0x7fffffUL, wdog); | 71 | __raw_writeq(t & 0x7fffffUL, wdog - 0x10); |
72 | spin_unlock(&sbwd_lock); | 72 | spin_unlock(&sbwd_lock); |
73 | } | 73 | } |
74 | 74 | ||
diff --git a/drivers/watchdog/sbc_fitpc2_wdt.c b/drivers/watchdog/sbc_fitpc2_wdt.c index 8d44c9b6fb5b..c7d67e9a7465 100644 --- a/drivers/watchdog/sbc_fitpc2_wdt.c +++ b/drivers/watchdog/sbc_fitpc2_wdt.c | |||
@@ -30,7 +30,7 @@ | |||
30 | static int nowayout = WATCHDOG_NOWAYOUT; | 30 | static int nowayout = WATCHDOG_NOWAYOUT; |
31 | static unsigned int margin = 60; /* (secs) Default is 1 minute */ | 31 | static unsigned int margin = 60; /* (secs) Default is 1 minute */ |
32 | static unsigned long wdt_status; | 32 | static unsigned long wdt_status; |
33 | static DEFINE_SPINLOCK(wdt_lock); | 33 | static DEFINE_MUTEX(wdt_lock); |
34 | 34 | ||
35 | #define WDT_IN_USE 0 | 35 | #define WDT_IN_USE 0 |
36 | #define WDT_OK_TO_CLOSE 1 | 36 | #define WDT_OK_TO_CLOSE 1 |
@@ -45,26 +45,26 @@ static DEFINE_SPINLOCK(wdt_lock); | |||
45 | 45 | ||
46 | static void wdt_send_data(unsigned char command, unsigned char data) | 46 | static void wdt_send_data(unsigned char command, unsigned char data) |
47 | { | 47 | { |
48 | outb(command, COMMAND_PORT); | ||
49 | msleep(100); | ||
50 | outb(data, DATA_PORT); | 48 | outb(data, DATA_PORT); |
51 | msleep(200); | 49 | msleep(200); |
50 | outb(command, COMMAND_PORT); | ||
51 | msleep(100); | ||
52 | } | 52 | } |
53 | 53 | ||
54 | static void wdt_enable(void) | 54 | static void wdt_enable(void) |
55 | { | 55 | { |
56 | spin_lock(&wdt_lock); | 56 | mutex_lock(&wdt_lock); |
57 | wdt_send_data(IFACE_ON_COMMAND, 1); | 57 | wdt_send_data(IFACE_ON_COMMAND, 1); |
58 | wdt_send_data(REBOOT_COMMAND, margin); | 58 | wdt_send_data(REBOOT_COMMAND, margin); |
59 | spin_unlock(&wdt_lock); | 59 | mutex_unlock(&wdt_lock); |
60 | } | 60 | } |
61 | 61 | ||
62 | static void wdt_disable(void) | 62 | static void wdt_disable(void) |
63 | { | 63 | { |
64 | spin_lock(&wdt_lock); | 64 | mutex_lock(&wdt_lock); |
65 | wdt_send_data(IFACE_ON_COMMAND, 0); | 65 | wdt_send_data(IFACE_ON_COMMAND, 0); |
66 | wdt_send_data(REBOOT_COMMAND, 0); | 66 | wdt_send_data(REBOOT_COMMAND, 0); |
67 | spin_unlock(&wdt_lock); | 67 | mutex_unlock(&wdt_lock); |
68 | } | 68 | } |
69 | 69 | ||
70 | static int fitpc2_wdt_open(struct inode *inode, struct file *file) | 70 | static int fitpc2_wdt_open(struct inode *inode, struct file *file) |