diff options
Diffstat (limited to 'drivers')
157 files changed, 4271 insertions, 1585 deletions
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index 6b115f6c4313..6afceb3d4034 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c | |||
@@ -30,18 +30,13 @@ | |||
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <acpi/acpi_bus.h> | 31 | #include <acpi/acpi_bus.h> |
32 | #include <acpi/acpi_drivers.h> | 32 | #include <acpi/acpi_drivers.h> |
33 | #include <asm/mwait.h> | ||
33 | 34 | ||
34 | #define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" | 35 | #define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" |
35 | #define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator" | 36 | #define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator" |
36 | #define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80 | 37 | #define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80 |
37 | static DEFINE_MUTEX(isolated_cpus_lock); | 38 | static DEFINE_MUTEX(isolated_cpus_lock); |
38 | 39 | ||
39 | #define MWAIT_SUBSTATE_MASK (0xf) | ||
40 | #define MWAIT_CSTATE_MASK (0xf) | ||
41 | #define MWAIT_SUBSTATE_SIZE (4) | ||
42 | #define CPUID_MWAIT_LEAF (5) | ||
43 | #define CPUID5_ECX_EXTENSIONS_SUPPORTED (0x1) | ||
44 | #define CPUID5_ECX_INTERRUPT_BREAK (0x2) | ||
45 | static unsigned long power_saving_mwait_eax; | 40 | static unsigned long power_saving_mwait_eax; |
46 | 41 | ||
47 | static unsigned char tsc_detected_unstable; | 42 | static unsigned char tsc_detected_unstable; |
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index f7619600270a..af308d03f492 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c | |||
@@ -204,6 +204,23 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { | |||
204 | }, | 204 | }, |
205 | }, | 205 | }, |
206 | { | 206 | { |
207 | /* | ||
208 | * There have a NVIF method in MSI GX723 DSDT need call by Nvidia | ||
209 | * driver (e.g. nouveau) when user press brightness hotkey. | ||
210 | * Currently, nouveau driver didn't do the job and it causes there | ||
211 | * have a infinite while loop in DSDT when user press hotkey. | ||
212 | * We add MSI GX723's dmi information to this table for workaround | ||
213 | * this issue. | ||
214 | * Will remove MSI GX723 from the table after nouveau grows support. | ||
215 | */ | ||
216 | .callback = dmi_disable_osi_vista, | ||
217 | .ident = "MSI GX723", | ||
218 | .matches = { | ||
219 | DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"), | ||
220 | DMI_MATCH(DMI_PRODUCT_NAME, "GX723"), | ||
221 | }, | ||
222 | }, | ||
223 | { | ||
207 | .callback = dmi_disable_osi_vista, | 224 | .callback = dmi_disable_osi_vista, |
208 | .ident = "Sony VGN-NS10J_S", | 225 | .ident = "Sony VGN-NS10J_S", |
209 | .matches = { | 226 | .matches = { |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index b618f888d66b..bec561c14beb 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -346,4 +346,5 @@ void __init acpi_early_processor_set_pdc(void) | |||
346 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, | 346 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, |
347 | ACPI_UINT32_MAX, | 347 | ACPI_UINT32_MAX, |
348 | early_init_pdc, NULL, NULL, NULL); | 348 | early_init_pdc, NULL, NULL, NULL); |
349 | acpi_get_devices("ACPI0007", early_init_pdc, NULL, NULL); | ||
349 | } | 350 | } |
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c index ee9ddeb53417..8cb0347dec28 100644 --- a/drivers/atm/iphase.c +++ b/drivers/atm/iphase.c | |||
@@ -3156,7 +3156,6 @@ static int __devinit ia_init_one(struct pci_dev *pdev, | |||
3156 | { | 3156 | { |
3157 | struct atm_dev *dev; | 3157 | struct atm_dev *dev; |
3158 | IADEV *iadev; | 3158 | IADEV *iadev; |
3159 | unsigned long flags; | ||
3160 | int ret; | 3159 | int ret; |
3161 | 3160 | ||
3162 | iadev = kzalloc(sizeof(*iadev), GFP_KERNEL); | 3161 | iadev = kzalloc(sizeof(*iadev), GFP_KERNEL); |
@@ -3188,19 +3187,14 @@ static int __devinit ia_init_one(struct pci_dev *pdev, | |||
3188 | ia_dev[iadev_count] = iadev; | 3187 | ia_dev[iadev_count] = iadev; |
3189 | _ia_dev[iadev_count] = dev; | 3188 | _ia_dev[iadev_count] = dev; |
3190 | iadev_count++; | 3189 | iadev_count++; |
3191 | spin_lock_init(&iadev->misc_lock); | ||
3192 | /* First fixes first. I don't want to think about this now. */ | ||
3193 | spin_lock_irqsave(&iadev->misc_lock, flags); | ||
3194 | if (ia_init(dev) || ia_start(dev)) { | 3190 | if (ia_init(dev) || ia_start(dev)) { |
3195 | IF_INIT(printk("IA register failed!\n");) | 3191 | IF_INIT(printk("IA register failed!\n");) |
3196 | iadev_count--; | 3192 | iadev_count--; |
3197 | ia_dev[iadev_count] = NULL; | 3193 | ia_dev[iadev_count] = NULL; |
3198 | _ia_dev[iadev_count] = NULL; | 3194 | _ia_dev[iadev_count] = NULL; |
3199 | spin_unlock_irqrestore(&iadev->misc_lock, flags); | ||
3200 | ret = -EINVAL; | 3195 | ret = -EINVAL; |
3201 | goto err_out_deregister_dev; | 3196 | goto err_out_deregister_dev; |
3202 | } | 3197 | } |
3203 | spin_unlock_irqrestore(&iadev->misc_lock, flags); | ||
3204 | IF_EVENT(printk("iadev_count = %d\n", iadev_count);) | 3198 | IF_EVENT(printk("iadev_count = %d\n", iadev_count);) |
3205 | 3199 | ||
3206 | iadev->next_board = ia_boards; | 3200 | iadev->next_board = ia_boards; |
diff --git a/drivers/atm/iphase.h b/drivers/atm/iphase.h index b2cd20f549cb..077735e0e04b 100644 --- a/drivers/atm/iphase.h +++ b/drivers/atm/iphase.h | |||
@@ -1022,7 +1022,7 @@ typedef struct iadev_t { | |||
1022 | struct dle_q rx_dle_q; | 1022 | struct dle_q rx_dle_q; |
1023 | struct free_desc_q *rx_free_desc_qhead; | 1023 | struct free_desc_q *rx_free_desc_qhead; |
1024 | struct sk_buff_head rx_dma_q; | 1024 | struct sk_buff_head rx_dma_q; |
1025 | spinlock_t rx_lock, misc_lock; | 1025 | spinlock_t rx_lock; |
1026 | struct atm_vcc **rx_open; /* list of all open VCs */ | 1026 | struct atm_vcc **rx_open; /* list of all open VCs */ |
1027 | u16 num_rx_desc, rx_buf_sz, rxing; | 1027 | u16 num_rx_desc, rx_buf_sz, rxing; |
1028 | u32 rx_pkt_ram, rx_tmp_cnt; | 1028 | u32 rx_pkt_ram, rx_tmp_cnt; |
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c index f916ddf63938..f46138ab38b6 100644 --- a/drivers/atm/solos-pci.c +++ b/drivers/atm/solos-pci.c | |||
@@ -444,6 +444,7 @@ static ssize_t console_show(struct device *dev, struct device_attribute *attr, | |||
444 | struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev); | 444 | struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev); |
445 | struct solos_card *card = atmdev->dev_data; | 445 | struct solos_card *card = atmdev->dev_data; |
446 | struct sk_buff *skb; | 446 | struct sk_buff *skb; |
447 | unsigned int len; | ||
447 | 448 | ||
448 | spin_lock(&card->cli_queue_lock); | 449 | spin_lock(&card->cli_queue_lock); |
449 | skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]); | 450 | skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]); |
@@ -451,11 +452,12 @@ static ssize_t console_show(struct device *dev, struct device_attribute *attr, | |||
451 | if(skb == NULL) | 452 | if(skb == NULL) |
452 | return sprintf(buf, "No data.\n"); | 453 | return sprintf(buf, "No data.\n"); |
453 | 454 | ||
454 | memcpy(buf, skb->data, skb->len); | 455 | len = skb->len; |
455 | dev_dbg(&card->dev->dev, "len: %d\n", skb->len); | 456 | memcpy(buf, skb->data, len); |
457 | dev_dbg(&card->dev->dev, "len: %d\n", len); | ||
456 | 458 | ||
457 | kfree_skb(skb); | 459 | kfree_skb(skb); |
458 | return skb->len; | 460 | return len; |
459 | } | 461 | } |
460 | 462 | ||
461 | static int send_command(struct solos_card *card, int dev, const char *buf, size_t size) | 463 | static int send_command(struct solos_card *card, int dev, const char *buf, size_t size) |
diff --git a/drivers/base/topology.c b/drivers/base/topology.c index 9fc630ce1ddb..f6f37a05a0c3 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c | |||
@@ -45,7 +45,8 @@ static ssize_t show_##name(struct sys_device *dev, \ | |||
45 | return sprintf(buf, "%d\n", topology_##name(cpu)); \ | 45 | return sprintf(buf, "%d\n", topology_##name(cpu)); \ |
46 | } | 46 | } |
47 | 47 | ||
48 | #if defined(topology_thread_cpumask) || defined(topology_core_cpumask) | 48 | #if defined(topology_thread_cpumask) || defined(topology_core_cpumask) || \ |
49 | defined(topology_book_cpumask) | ||
49 | static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf) | 50 | static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf) |
50 | { | 51 | { |
51 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; | 52 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; |
@@ -114,6 +115,14 @@ define_siblings_show_func(core_cpumask); | |||
114 | define_one_ro_named(core_siblings, show_core_cpumask); | 115 | define_one_ro_named(core_siblings, show_core_cpumask); |
115 | define_one_ro_named(core_siblings_list, show_core_cpumask_list); | 116 | define_one_ro_named(core_siblings_list, show_core_cpumask_list); |
116 | 117 | ||
118 | #ifdef CONFIG_SCHED_BOOK | ||
119 | define_id_show_func(book_id); | ||
120 | define_one_ro(book_id); | ||
121 | define_siblings_show_func(book_cpumask); | ||
122 | define_one_ro_named(book_siblings, show_book_cpumask); | ||
123 | define_one_ro_named(book_siblings_list, show_book_cpumask_list); | ||
124 | #endif | ||
125 | |||
117 | static struct attribute *default_attrs[] = { | 126 | static struct attribute *default_attrs[] = { |
118 | &attr_physical_package_id.attr, | 127 | &attr_physical_package_id.attr, |
119 | &attr_core_id.attr, | 128 | &attr_core_id.attr, |
@@ -121,6 +130,11 @@ static struct attribute *default_attrs[] = { | |||
121 | &attr_thread_siblings_list.attr, | 130 | &attr_thread_siblings_list.attr, |
122 | &attr_core_siblings.attr, | 131 | &attr_core_siblings.attr, |
123 | &attr_core_siblings_list.attr, | 132 | &attr_core_siblings_list.attr, |
133 | #ifdef CONFIG_SCHED_BOOK | ||
134 | &attr_book_id.attr, | ||
135 | &attr_book_siblings.attr, | ||
136 | &attr_book_siblings_list.attr, | ||
137 | #endif | ||
124 | NULL | 138 | NULL |
125 | }; | 139 | }; |
126 | 140 | ||
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index de277689da61..4b9359a6f6ca 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig | |||
@@ -488,4 +488,21 @@ config BLK_DEV_HD | |||
488 | 488 | ||
489 | If unsure, say N. | 489 | If unsure, say N. |
490 | 490 | ||
491 | config BLK_DEV_RBD | ||
492 | tristate "Rados block device (RBD)" | ||
493 | depends on INET && EXPERIMENTAL && BLOCK | ||
494 | select CEPH_LIB | ||
495 | select LIBCRC32C | ||
496 | select CRYPTO_AES | ||
497 | select CRYPTO | ||
498 | default n | ||
499 | help | ||
500 | Say Y here if you want include the Rados block device, which stripes | ||
501 | a block device over objects stored in the Ceph distributed object | ||
502 | store. | ||
503 | |||
504 | More information at http://ceph.newdream.net/. | ||
505 | |||
506 | If unsure, say N. | ||
507 | |||
491 | endif # BLK_DEV | 508 | endif # BLK_DEV |
diff --git a/drivers/block/Makefile b/drivers/block/Makefile index aff5ac925c34..d7f463d6312d 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile | |||
@@ -37,5 +37,6 @@ obj-$(CONFIG_BLK_DEV_HD) += hd.o | |||
37 | 37 | ||
38 | obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o | 38 | obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o |
39 | obj-$(CONFIG_BLK_DEV_DRBD) += drbd/ | 39 | obj-$(CONFIG_BLK_DEV_DRBD) += drbd/ |
40 | obj-$(CONFIG_BLK_DEV_RBD) += rbd.o | ||
40 | 41 | ||
41 | swim_mod-objs := swim.o swim_asm.o | 42 | swim_mod-objs := swim.o swim_asm.o |
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index e9da874d0419..03688c2da319 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c | |||
@@ -113,7 +113,7 @@ static void ps3disk_scatter_gather(struct ps3_storage_device *dev, | |||
113 | memcpy(buf, dev->bounce_buf+offset, size); | 113 | memcpy(buf, dev->bounce_buf+offset, size); |
114 | offset += size; | 114 | offset += size; |
115 | flush_kernel_dcache_page(bvec->bv_page); | 115 | flush_kernel_dcache_page(bvec->bv_page); |
116 | bvec_kunmap_irq(bvec, &flags); | 116 | bvec_kunmap_irq(buf, &flags); |
117 | i++; | 117 | i++; |
118 | } | 118 | } |
119 | } | 119 | } |
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c new file mode 100644 index 000000000000..6ec9d53806c5 --- /dev/null +++ b/drivers/block/rbd.c | |||
@@ -0,0 +1,1841 @@ | |||
1 | /* | ||
2 | rbd.c -- Export ceph rados objects as a Linux block device | ||
3 | |||
4 | |||
5 | based on drivers/block/osdblk.c: | ||
6 | |||
7 | Copyright 2009 Red Hat, Inc. | ||
8 | |||
9 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License as published by | ||
11 | the Free Software Foundation. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; see the file COPYING. If not, write to | ||
20 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | |||
22 | |||
23 | |||
24 | Instructions for use | ||
25 | -------------------- | ||
26 | |||
27 | 1) Map a Linux block device to an existing rbd image. | ||
28 | |||
29 | Usage: <mon ip addr> <options> <pool name> <rbd image name> [snap name] | ||
30 | |||
31 | $ echo "192.168.0.1 name=admin rbd foo" > /sys/class/rbd/add | ||
32 | |||
33 | The snapshot name can be "-" or omitted to map the image read/write. | ||
34 | |||
35 | 2) List all active blkdev<->object mappings. | ||
36 | |||
37 | In this example, we have performed step #1 twice, creating two blkdevs, | ||
38 | mapped to two separate rados objects in the rados rbd pool | ||
39 | |||
40 | $ cat /sys/class/rbd/list | ||
41 | #id major client_name pool name snap KB | ||
42 | 0 254 client4143 rbd foo - 1024000 | ||
43 | |||
44 | The columns, in order, are: | ||
45 | - blkdev unique id | ||
46 | - blkdev assigned major | ||
47 | - rados client id | ||
48 | - rados pool name | ||
49 | - rados block device name | ||
50 | - mapped snapshot ("-" if none) | ||
51 | - device size in KB | ||
52 | |||
53 | |||
54 | 3) Create a snapshot. | ||
55 | |||
56 | Usage: <blkdev id> <snapname> | ||
57 | |||
58 | $ echo "0 mysnap" > /sys/class/rbd/snap_create | ||
59 | |||
60 | |||
61 | 4) Listing a snapshot. | ||
62 | |||
63 | $ cat /sys/class/rbd/snaps_list | ||
64 | #id snap KB | ||
65 | 0 - 1024000 (*) | ||
66 | 0 foo 1024000 | ||
67 | |||
68 | The columns, in order, are: | ||
69 | - blkdev unique id | ||
70 | - snapshot name, '-' means none (active read/write version) | ||
71 | - size of device at time of snapshot | ||
72 | - the (*) indicates this is the active version | ||
73 | |||
74 | 5) Rollback to snapshot. | ||
75 | |||
76 | Usage: <blkdev id> <snapname> | ||
77 | |||
78 | $ echo "0 mysnap" > /sys/class/rbd/snap_rollback | ||
79 | |||
80 | |||
81 | 6) Mapping an image using snapshot. | ||
82 | |||
83 | A snapshot mapping is read-only. This is being done by passing | ||
84 | snap=<snapname> to the options when adding a device. | ||
85 | |||
86 | $ echo "192.168.0.1 name=admin,snap=mysnap rbd foo" > /sys/class/rbd/add | ||
87 | |||
88 | |||
89 | 7) Remove an active blkdev<->rbd image mapping. | ||
90 | |||
91 | In this example, we remove the mapping with blkdev unique id 1. | ||
92 | |||
93 | $ echo 1 > /sys/class/rbd/remove | ||
94 | |||
95 | |||
96 | NOTE: The actual creation and deletion of rados objects is outside the scope | ||
97 | of this driver. | ||
98 | |||
99 | */ | ||
100 | |||
101 | #include <linux/ceph/libceph.h> | ||
102 | #include <linux/ceph/osd_client.h> | ||
103 | #include <linux/ceph/mon_client.h> | ||
104 | #include <linux/ceph/decode.h> | ||
105 | |||
106 | #include <linux/kernel.h> | ||
107 | #include <linux/device.h> | ||
108 | #include <linux/module.h> | ||
109 | #include <linux/fs.h> | ||
110 | #include <linux/blkdev.h> | ||
111 | |||
112 | #include "rbd_types.h" | ||
113 | |||
114 | #define DRV_NAME "rbd" | ||
115 | #define DRV_NAME_LONG "rbd (rados block device)" | ||
116 | |||
117 | #define RBD_MINORS_PER_MAJOR 256 /* max minors per blkdev */ | ||
118 | |||
119 | #define RBD_MAX_MD_NAME_LEN (96 + sizeof(RBD_SUFFIX)) | ||
120 | #define RBD_MAX_POOL_NAME_LEN 64 | ||
121 | #define RBD_MAX_SNAP_NAME_LEN 32 | ||
122 | #define RBD_MAX_OPT_LEN 1024 | ||
123 | |||
124 | #define RBD_SNAP_HEAD_NAME "-" | ||
125 | |||
126 | #define DEV_NAME_LEN 32 | ||
127 | |||
128 | /* | ||
129 | * block device image metadata (in-memory version) | ||
130 | */ | ||
131 | struct rbd_image_header { | ||
132 | u64 image_size; | ||
133 | char block_name[32]; | ||
134 | __u8 obj_order; | ||
135 | __u8 crypt_type; | ||
136 | __u8 comp_type; | ||
137 | struct rw_semaphore snap_rwsem; | ||
138 | struct ceph_snap_context *snapc; | ||
139 | size_t snap_names_len; | ||
140 | u64 snap_seq; | ||
141 | u32 total_snaps; | ||
142 | |||
143 | char *snap_names; | ||
144 | u64 *snap_sizes; | ||
145 | }; | ||
146 | |||
147 | /* | ||
148 | * an instance of the client. multiple devices may share a client. | ||
149 | */ | ||
150 | struct rbd_client { | ||
151 | struct ceph_client *client; | ||
152 | struct kref kref; | ||
153 | struct list_head node; | ||
154 | }; | ||
155 | |||
156 | /* | ||
157 | * a single io request | ||
158 | */ | ||
159 | struct rbd_request { | ||
160 | struct request *rq; /* blk layer request */ | ||
161 | struct bio *bio; /* cloned bio */ | ||
162 | struct page **pages; /* list of used pages */ | ||
163 | u64 len; | ||
164 | }; | ||
165 | |||
166 | /* | ||
167 | * a single device | ||
168 | */ | ||
169 | struct rbd_device { | ||
170 | int id; /* blkdev unique id */ | ||
171 | |||
172 | int major; /* blkdev assigned major */ | ||
173 | struct gendisk *disk; /* blkdev's gendisk and rq */ | ||
174 | struct request_queue *q; | ||
175 | |||
176 | struct ceph_client *client; | ||
177 | struct rbd_client *rbd_client; | ||
178 | |||
179 | char name[DEV_NAME_LEN]; /* blkdev name, e.g. rbd3 */ | ||
180 | |||
181 | spinlock_t lock; /* queue lock */ | ||
182 | |||
183 | struct rbd_image_header header; | ||
184 | char obj[RBD_MAX_OBJ_NAME_LEN]; /* rbd image name */ | ||
185 | int obj_len; | ||
186 | char obj_md_name[RBD_MAX_MD_NAME_LEN]; /* hdr nm. */ | ||
187 | char pool_name[RBD_MAX_POOL_NAME_LEN]; | ||
188 | int poolid; | ||
189 | |||
190 | char snap_name[RBD_MAX_SNAP_NAME_LEN]; | ||
191 | u32 cur_snap; /* index+1 of current snapshot within snap context | ||
192 | 0 - for the head */ | ||
193 | int read_only; | ||
194 | |||
195 | struct list_head node; | ||
196 | }; | ||
197 | |||
198 | static spinlock_t node_lock; /* protects client get/put */ | ||
199 | |||
200 | static struct class *class_rbd; /* /sys/class/rbd */ | ||
201 | static DEFINE_MUTEX(ctl_mutex); /* Serialize open/close/setup/teardown */ | ||
202 | static LIST_HEAD(rbd_dev_list); /* devices */ | ||
203 | static LIST_HEAD(rbd_client_list); /* clients */ | ||
204 | |||
205 | |||
206 | static int rbd_open(struct block_device *bdev, fmode_t mode) | ||
207 | { | ||
208 | struct gendisk *disk = bdev->bd_disk; | ||
209 | struct rbd_device *rbd_dev = disk->private_data; | ||
210 | |||
211 | set_device_ro(bdev, rbd_dev->read_only); | ||
212 | |||
213 | if ((mode & FMODE_WRITE) && rbd_dev->read_only) | ||
214 | return -EROFS; | ||
215 | |||
216 | return 0; | ||
217 | } | ||
218 | |||
219 | static const struct block_device_operations rbd_bd_ops = { | ||
220 | .owner = THIS_MODULE, | ||
221 | .open = rbd_open, | ||
222 | }; | ||
223 | |||
224 | /* | ||
225 | * Initialize an rbd client instance. | ||
226 | * We own *opt. | ||
227 | */ | ||
228 | static struct rbd_client *rbd_client_create(struct ceph_options *opt) | ||
229 | { | ||
230 | struct rbd_client *rbdc; | ||
231 | int ret = -ENOMEM; | ||
232 | |||
233 | dout("rbd_client_create\n"); | ||
234 | rbdc = kmalloc(sizeof(struct rbd_client), GFP_KERNEL); | ||
235 | if (!rbdc) | ||
236 | goto out_opt; | ||
237 | |||
238 | kref_init(&rbdc->kref); | ||
239 | INIT_LIST_HEAD(&rbdc->node); | ||
240 | |||
241 | rbdc->client = ceph_create_client(opt, rbdc); | ||
242 | if (IS_ERR(rbdc->client)) | ||
243 | goto out_rbdc; | ||
244 | opt = NULL; /* Now rbdc->client is responsible for opt */ | ||
245 | |||
246 | ret = ceph_open_session(rbdc->client); | ||
247 | if (ret < 0) | ||
248 | goto out_err; | ||
249 | |||
250 | spin_lock(&node_lock); | ||
251 | list_add_tail(&rbdc->node, &rbd_client_list); | ||
252 | spin_unlock(&node_lock); | ||
253 | |||
254 | dout("rbd_client_create created %p\n", rbdc); | ||
255 | return rbdc; | ||
256 | |||
257 | out_err: | ||
258 | ceph_destroy_client(rbdc->client); | ||
259 | out_rbdc: | ||
260 | kfree(rbdc); | ||
261 | out_opt: | ||
262 | if (opt) | ||
263 | ceph_destroy_options(opt); | ||
264 | return ERR_PTR(ret); | ||
265 | } | ||
266 | |||
267 | /* | ||
268 | * Find a ceph client with specific addr and configuration. | ||
269 | */ | ||
270 | static struct rbd_client *__rbd_client_find(struct ceph_options *opt) | ||
271 | { | ||
272 | struct rbd_client *client_node; | ||
273 | |||
274 | if (opt->flags & CEPH_OPT_NOSHARE) | ||
275 | return NULL; | ||
276 | |||
277 | list_for_each_entry(client_node, &rbd_client_list, node) | ||
278 | if (ceph_compare_options(opt, client_node->client) == 0) | ||
279 | return client_node; | ||
280 | return NULL; | ||
281 | } | ||
282 | |||
283 | /* | ||
284 | * Get a ceph client with specific addr and configuration, if one does | ||
285 | * not exist create it. | ||
286 | */ | ||
287 | static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr, | ||
288 | char *options) | ||
289 | { | ||
290 | struct rbd_client *rbdc; | ||
291 | struct ceph_options *opt; | ||
292 | int ret; | ||
293 | |||
294 | ret = ceph_parse_options(&opt, options, mon_addr, | ||
295 | mon_addr + strlen(mon_addr), NULL, NULL); | ||
296 | if (ret < 0) | ||
297 | return ret; | ||
298 | |||
299 | spin_lock(&node_lock); | ||
300 | rbdc = __rbd_client_find(opt); | ||
301 | if (rbdc) { | ||
302 | ceph_destroy_options(opt); | ||
303 | |||
304 | /* using an existing client */ | ||
305 | kref_get(&rbdc->kref); | ||
306 | rbd_dev->rbd_client = rbdc; | ||
307 | rbd_dev->client = rbdc->client; | ||
308 | spin_unlock(&node_lock); | ||
309 | return 0; | ||
310 | } | ||
311 | spin_unlock(&node_lock); | ||
312 | |||
313 | rbdc = rbd_client_create(opt); | ||
314 | if (IS_ERR(rbdc)) | ||
315 | return PTR_ERR(rbdc); | ||
316 | |||
317 | rbd_dev->rbd_client = rbdc; | ||
318 | rbd_dev->client = rbdc->client; | ||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | /* | ||
323 | * Destroy ceph client | ||
324 | */ | ||
325 | static void rbd_client_release(struct kref *kref) | ||
326 | { | ||
327 | struct rbd_client *rbdc = container_of(kref, struct rbd_client, kref); | ||
328 | |||
329 | dout("rbd_release_client %p\n", rbdc); | ||
330 | spin_lock(&node_lock); | ||
331 | list_del(&rbdc->node); | ||
332 | spin_unlock(&node_lock); | ||
333 | |||
334 | ceph_destroy_client(rbdc->client); | ||
335 | kfree(rbdc); | ||
336 | } | ||
337 | |||
338 | /* | ||
339 | * Drop reference to ceph client node. If it's not referenced anymore, release | ||
340 | * it. | ||
341 | */ | ||
342 | static void rbd_put_client(struct rbd_device *rbd_dev) | ||
343 | { | ||
344 | kref_put(&rbd_dev->rbd_client->kref, rbd_client_release); | ||
345 | rbd_dev->rbd_client = NULL; | ||
346 | rbd_dev->client = NULL; | ||
347 | } | ||
348 | |||
349 | |||
350 | /* | ||
351 | * Create a new header structure, translate header format from the on-disk | ||
352 | * header. | ||
353 | */ | ||
354 | static int rbd_header_from_disk(struct rbd_image_header *header, | ||
355 | struct rbd_image_header_ondisk *ondisk, | ||
356 | int allocated_snaps, | ||
357 | gfp_t gfp_flags) | ||
358 | { | ||
359 | int i; | ||
360 | u32 snap_count = le32_to_cpu(ondisk->snap_count); | ||
361 | int ret = -ENOMEM; | ||
362 | |||
363 | init_rwsem(&header->snap_rwsem); | ||
364 | |||
365 | header->snap_names_len = le64_to_cpu(ondisk->snap_names_len); | ||
366 | header->snapc = kmalloc(sizeof(struct ceph_snap_context) + | ||
367 | snap_count * | ||
368 | sizeof(struct rbd_image_snap_ondisk), | ||
369 | gfp_flags); | ||
370 | if (!header->snapc) | ||
371 | return -ENOMEM; | ||
372 | if (snap_count) { | ||
373 | header->snap_names = kmalloc(header->snap_names_len, | ||
374 | GFP_KERNEL); | ||
375 | if (!header->snap_names) | ||
376 | goto err_snapc; | ||
377 | header->snap_sizes = kmalloc(snap_count * sizeof(u64), | ||
378 | GFP_KERNEL); | ||
379 | if (!header->snap_sizes) | ||
380 | goto err_names; | ||
381 | } else { | ||
382 | header->snap_names = NULL; | ||
383 | header->snap_sizes = NULL; | ||
384 | } | ||
385 | memcpy(header->block_name, ondisk->block_name, | ||
386 | sizeof(ondisk->block_name)); | ||
387 | |||
388 | header->image_size = le64_to_cpu(ondisk->image_size); | ||
389 | header->obj_order = ondisk->options.order; | ||
390 | header->crypt_type = ondisk->options.crypt_type; | ||
391 | header->comp_type = ondisk->options.comp_type; | ||
392 | |||
393 | atomic_set(&header->snapc->nref, 1); | ||
394 | header->snap_seq = le64_to_cpu(ondisk->snap_seq); | ||
395 | header->snapc->num_snaps = snap_count; | ||
396 | header->total_snaps = snap_count; | ||
397 | |||
398 | if (snap_count && | ||
399 | allocated_snaps == snap_count) { | ||
400 | for (i = 0; i < snap_count; i++) { | ||
401 | header->snapc->snaps[i] = | ||
402 | le64_to_cpu(ondisk->snaps[i].id); | ||
403 | header->snap_sizes[i] = | ||
404 | le64_to_cpu(ondisk->snaps[i].image_size); | ||
405 | } | ||
406 | |||
407 | /* copy snapshot names */ | ||
408 | memcpy(header->snap_names, &ondisk->snaps[i], | ||
409 | header->snap_names_len); | ||
410 | } | ||
411 | |||
412 | return 0; | ||
413 | |||
414 | err_names: | ||
415 | kfree(header->snap_names); | ||
416 | err_snapc: | ||
417 | kfree(header->snapc); | ||
418 | return ret; | ||
419 | } | ||
420 | |||
421 | static int snap_index(struct rbd_image_header *header, int snap_num) | ||
422 | { | ||
423 | return header->total_snaps - snap_num; | ||
424 | } | ||
425 | |||
426 | static u64 cur_snap_id(struct rbd_device *rbd_dev) | ||
427 | { | ||
428 | struct rbd_image_header *header = &rbd_dev->header; | ||
429 | |||
430 | if (!rbd_dev->cur_snap) | ||
431 | return 0; | ||
432 | |||
433 | return header->snapc->snaps[snap_index(header, rbd_dev->cur_snap)]; | ||
434 | } | ||
435 | |||
436 | static int snap_by_name(struct rbd_image_header *header, const char *snap_name, | ||
437 | u64 *seq, u64 *size) | ||
438 | { | ||
439 | int i; | ||
440 | char *p = header->snap_names; | ||
441 | |||
442 | for (i = 0; i < header->total_snaps; i++, p += strlen(p) + 1) { | ||
443 | if (strcmp(snap_name, p) == 0) | ||
444 | break; | ||
445 | } | ||
446 | if (i == header->total_snaps) | ||
447 | return -ENOENT; | ||
448 | if (seq) | ||
449 | *seq = header->snapc->snaps[i]; | ||
450 | |||
451 | if (size) | ||
452 | *size = header->snap_sizes[i]; | ||
453 | |||
454 | return i; | ||
455 | } | ||
456 | |||
457 | static int rbd_header_set_snap(struct rbd_device *dev, | ||
458 | const char *snap_name, | ||
459 | u64 *size) | ||
460 | { | ||
461 | struct rbd_image_header *header = &dev->header; | ||
462 | struct ceph_snap_context *snapc = header->snapc; | ||
463 | int ret = -ENOENT; | ||
464 | |||
465 | down_write(&header->snap_rwsem); | ||
466 | |||
467 | if (!snap_name || | ||
468 | !*snap_name || | ||
469 | strcmp(snap_name, "-") == 0 || | ||
470 | strcmp(snap_name, RBD_SNAP_HEAD_NAME) == 0) { | ||
471 | if (header->total_snaps) | ||
472 | snapc->seq = header->snap_seq; | ||
473 | else | ||
474 | snapc->seq = 0; | ||
475 | dev->cur_snap = 0; | ||
476 | dev->read_only = 0; | ||
477 | if (size) | ||
478 | *size = header->image_size; | ||
479 | } else { | ||
480 | ret = snap_by_name(header, snap_name, &snapc->seq, size); | ||
481 | if (ret < 0) | ||
482 | goto done; | ||
483 | |||
484 | dev->cur_snap = header->total_snaps - ret; | ||
485 | dev->read_only = 1; | ||
486 | } | ||
487 | |||
488 | ret = 0; | ||
489 | done: | ||
490 | up_write(&header->snap_rwsem); | ||
491 | return ret; | ||
492 | } | ||
493 | |||
494 | static void rbd_header_free(struct rbd_image_header *header) | ||
495 | { | ||
496 | kfree(header->snapc); | ||
497 | kfree(header->snap_names); | ||
498 | kfree(header->snap_sizes); | ||
499 | } | ||
500 | |||
501 | /* | ||
502 | * get the actual striped segment name, offset and length | ||
503 | */ | ||
504 | static u64 rbd_get_segment(struct rbd_image_header *header, | ||
505 | const char *block_name, | ||
506 | u64 ofs, u64 len, | ||
507 | char *seg_name, u64 *segofs) | ||
508 | { | ||
509 | u64 seg = ofs >> header->obj_order; | ||
510 | |||
511 | if (seg_name) | ||
512 | snprintf(seg_name, RBD_MAX_SEG_NAME_LEN, | ||
513 | "%s.%012llx", block_name, seg); | ||
514 | |||
515 | ofs = ofs & ((1 << header->obj_order) - 1); | ||
516 | len = min_t(u64, len, (1 << header->obj_order) - ofs); | ||
517 | |||
518 | if (segofs) | ||
519 | *segofs = ofs; | ||
520 | |||
521 | return len; | ||
522 | } | ||
523 | |||
524 | /* | ||
525 | * bio helpers | ||
526 | */ | ||
527 | |||
528 | static void bio_chain_put(struct bio *chain) | ||
529 | { | ||
530 | struct bio *tmp; | ||
531 | |||
532 | while (chain) { | ||
533 | tmp = chain; | ||
534 | chain = chain->bi_next; | ||
535 | bio_put(tmp); | ||
536 | } | ||
537 | } | ||
538 | |||
539 | /* | ||
540 | * zeros a bio chain, starting at specific offset | ||
541 | */ | ||
542 | static void zero_bio_chain(struct bio *chain, int start_ofs) | ||
543 | { | ||
544 | struct bio_vec *bv; | ||
545 | unsigned long flags; | ||
546 | void *buf; | ||
547 | int i; | ||
548 | int pos = 0; | ||
549 | |||
550 | while (chain) { | ||
551 | bio_for_each_segment(bv, chain, i) { | ||
552 | if (pos + bv->bv_len > start_ofs) { | ||
553 | int remainder = max(start_ofs - pos, 0); | ||
554 | buf = bvec_kmap_irq(bv, &flags); | ||
555 | memset(buf + remainder, 0, | ||
556 | bv->bv_len - remainder); | ||
557 | bvec_kunmap_irq(buf, &flags); | ||
558 | } | ||
559 | pos += bv->bv_len; | ||
560 | } | ||
561 | |||
562 | chain = chain->bi_next; | ||
563 | } | ||
564 | } | ||
565 | |||
566 | /* | ||
567 | * bio_chain_clone - clone a chain of bios up to a certain length. | ||
568 | * might return a bio_pair that will need to be released. | ||
569 | */ | ||
570 | static struct bio *bio_chain_clone(struct bio **old, struct bio **next, | ||
571 | struct bio_pair **bp, | ||
572 | int len, gfp_t gfpmask) | ||
573 | { | ||
574 | struct bio *tmp, *old_chain = *old, *new_chain = NULL, *tail = NULL; | ||
575 | int total = 0; | ||
576 | |||
577 | if (*bp) { | ||
578 | bio_pair_release(*bp); | ||
579 | *bp = NULL; | ||
580 | } | ||
581 | |||
582 | while (old_chain && (total < len)) { | ||
583 | tmp = bio_kmalloc(gfpmask, old_chain->bi_max_vecs); | ||
584 | if (!tmp) | ||
585 | goto err_out; | ||
586 | |||
587 | if (total + old_chain->bi_size > len) { | ||
588 | struct bio_pair *bp; | ||
589 | |||
590 | /* | ||
591 | * this split can only happen with a single paged bio, | ||
592 | * split_bio will BUG_ON if this is not the case | ||
593 | */ | ||
594 | dout("bio_chain_clone split! total=%d remaining=%d" | ||
595 | "bi_size=%d\n", | ||
596 | (int)total, (int)len-total, | ||
597 | (int)old_chain->bi_size); | ||
598 | |||
599 | /* split the bio. We'll release it either in the next | ||
600 | call, or it will have to be released outside */ | ||
601 | bp = bio_split(old_chain, (len - total) / 512ULL); | ||
602 | if (!bp) | ||
603 | goto err_out; | ||
604 | |||
605 | __bio_clone(tmp, &bp->bio1); | ||
606 | |||
607 | *next = &bp->bio2; | ||
608 | } else { | ||
609 | __bio_clone(tmp, old_chain); | ||
610 | *next = old_chain->bi_next; | ||
611 | } | ||
612 | |||
613 | tmp->bi_bdev = NULL; | ||
614 | gfpmask &= ~__GFP_WAIT; | ||
615 | tmp->bi_next = NULL; | ||
616 | |||
617 | if (!new_chain) { | ||
618 | new_chain = tail = tmp; | ||
619 | } else { | ||
620 | tail->bi_next = tmp; | ||
621 | tail = tmp; | ||
622 | } | ||
623 | old_chain = old_chain->bi_next; | ||
624 | |||
625 | total += tmp->bi_size; | ||
626 | } | ||
627 | |||
628 | BUG_ON(total < len); | ||
629 | |||
630 | if (tail) | ||
631 | tail->bi_next = NULL; | ||
632 | |||
633 | *old = old_chain; | ||
634 | |||
635 | return new_chain; | ||
636 | |||
637 | err_out: | ||
638 | dout("bio_chain_clone with err\n"); | ||
639 | bio_chain_put(new_chain); | ||
640 | return NULL; | ||
641 | } | ||
642 | |||
643 | /* | ||
644 | * helpers for osd request op vectors. | ||
645 | */ | ||
646 | static int rbd_create_rw_ops(struct ceph_osd_req_op **ops, | ||
647 | int num_ops, | ||
648 | int opcode, | ||
649 | u32 payload_len) | ||
650 | { | ||
651 | *ops = kzalloc(sizeof(struct ceph_osd_req_op) * (num_ops + 1), | ||
652 | GFP_NOIO); | ||
653 | if (!*ops) | ||
654 | return -ENOMEM; | ||
655 | (*ops)[0].op = opcode; | ||
656 | /* | ||
657 | * op extent offset and length will be set later on | ||
658 | * in calc_raw_layout() | ||
659 | */ | ||
660 | (*ops)[0].payload_len = payload_len; | ||
661 | return 0; | ||
662 | } | ||
663 | |||
664 | static void rbd_destroy_ops(struct ceph_osd_req_op *ops) | ||
665 | { | ||
666 | kfree(ops); | ||
667 | } | ||
668 | |||
669 | /* | ||
670 | * Send ceph osd request | ||
671 | */ | ||
672 | static int rbd_do_request(struct request *rq, | ||
673 | struct rbd_device *dev, | ||
674 | struct ceph_snap_context *snapc, | ||
675 | u64 snapid, | ||
676 | const char *obj, u64 ofs, u64 len, | ||
677 | struct bio *bio, | ||
678 | struct page **pages, | ||
679 | int num_pages, | ||
680 | int flags, | ||
681 | struct ceph_osd_req_op *ops, | ||
682 | int num_reply, | ||
683 | void (*rbd_cb)(struct ceph_osd_request *req, | ||
684 | struct ceph_msg *msg)) | ||
685 | { | ||
686 | struct ceph_osd_request *req; | ||
687 | struct ceph_file_layout *layout; | ||
688 | int ret; | ||
689 | u64 bno; | ||
690 | struct timespec mtime = CURRENT_TIME; | ||
691 | struct rbd_request *req_data; | ||
692 | struct ceph_osd_request_head *reqhead; | ||
693 | struct rbd_image_header *header = &dev->header; | ||
694 | |||
695 | ret = -ENOMEM; | ||
696 | req_data = kzalloc(sizeof(*req_data), GFP_NOIO); | ||
697 | if (!req_data) | ||
698 | goto done; | ||
699 | |||
700 | dout("rbd_do_request len=%lld ofs=%lld\n", len, ofs); | ||
701 | |||
702 | down_read(&header->snap_rwsem); | ||
703 | |||
704 | req = ceph_osdc_alloc_request(&dev->client->osdc, flags, | ||
705 | snapc, | ||
706 | ops, | ||
707 | false, | ||
708 | GFP_NOIO, pages, bio); | ||
709 | if (IS_ERR(req)) { | ||
710 | up_read(&header->snap_rwsem); | ||
711 | ret = PTR_ERR(req); | ||
712 | goto done_pages; | ||
713 | } | ||
714 | |||
715 | req->r_callback = rbd_cb; | ||
716 | |||
717 | req_data->rq = rq; | ||
718 | req_data->bio = bio; | ||
719 | req_data->pages = pages; | ||
720 | req_data->len = len; | ||
721 | |||
722 | req->r_priv = req_data; | ||
723 | |||
724 | reqhead = req->r_request->front.iov_base; | ||
725 | reqhead->snapid = cpu_to_le64(CEPH_NOSNAP); | ||
726 | |||
727 | strncpy(req->r_oid, obj, sizeof(req->r_oid)); | ||
728 | req->r_oid_len = strlen(req->r_oid); | ||
729 | |||
730 | layout = &req->r_file_layout; | ||
731 | memset(layout, 0, sizeof(*layout)); | ||
732 | layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); | ||
733 | layout->fl_stripe_count = cpu_to_le32(1); | ||
734 | layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); | ||
735 | layout->fl_pg_preferred = cpu_to_le32(-1); | ||
736 | layout->fl_pg_pool = cpu_to_le32(dev->poolid); | ||
737 | ceph_calc_raw_layout(&dev->client->osdc, layout, snapid, | ||
738 | ofs, &len, &bno, req, ops); | ||
739 | |||
740 | ceph_osdc_build_request(req, ofs, &len, | ||
741 | ops, | ||
742 | snapc, | ||
743 | &mtime, | ||
744 | req->r_oid, req->r_oid_len); | ||
745 | up_read(&header->snap_rwsem); | ||
746 | |||
747 | ret = ceph_osdc_start_request(&dev->client->osdc, req, false); | ||
748 | if (ret < 0) | ||
749 | goto done_err; | ||
750 | |||
751 | if (!rbd_cb) { | ||
752 | ret = ceph_osdc_wait_request(&dev->client->osdc, req); | ||
753 | ceph_osdc_put_request(req); | ||
754 | } | ||
755 | return ret; | ||
756 | |||
757 | done_err: | ||
758 | bio_chain_put(req_data->bio); | ||
759 | ceph_osdc_put_request(req); | ||
760 | done_pages: | ||
761 | kfree(req_data); | ||
762 | done: | ||
763 | if (rq) | ||
764 | blk_end_request(rq, ret, len); | ||
765 | return ret; | ||
766 | } | ||
767 | |||
768 | /* | ||
769 | * Ceph osd op callback | ||
770 | */ | ||
771 | static void rbd_req_cb(struct ceph_osd_request *req, struct ceph_msg *msg) | ||
772 | { | ||
773 | struct rbd_request *req_data = req->r_priv; | ||
774 | struct ceph_osd_reply_head *replyhead; | ||
775 | struct ceph_osd_op *op; | ||
776 | __s32 rc; | ||
777 | u64 bytes; | ||
778 | int read_op; | ||
779 | |||
780 | /* parse reply */ | ||
781 | replyhead = msg->front.iov_base; | ||
782 | WARN_ON(le32_to_cpu(replyhead->num_ops) == 0); | ||
783 | op = (void *)(replyhead + 1); | ||
784 | rc = le32_to_cpu(replyhead->result); | ||
785 | bytes = le64_to_cpu(op->extent.length); | ||
786 | read_op = (le32_to_cpu(op->op) == CEPH_OSD_OP_READ); | ||
787 | |||
788 | dout("rbd_req_cb bytes=%lld readop=%d rc=%d\n", bytes, read_op, rc); | ||
789 | |||
790 | if (rc == -ENOENT && read_op) { | ||
791 | zero_bio_chain(req_data->bio, 0); | ||
792 | rc = 0; | ||
793 | } else if (rc == 0 && read_op && bytes < req_data->len) { | ||
794 | zero_bio_chain(req_data->bio, bytes); | ||
795 | bytes = req_data->len; | ||
796 | } | ||
797 | |||
798 | blk_end_request(req_data->rq, rc, bytes); | ||
799 | |||
800 | if (req_data->bio) | ||
801 | bio_chain_put(req_data->bio); | ||
802 | |||
803 | ceph_osdc_put_request(req); | ||
804 | kfree(req_data); | ||
805 | } | ||
806 | |||
807 | /* | ||
808 | * Do a synchronous ceph osd operation | ||
809 | */ | ||
810 | static int rbd_req_sync_op(struct rbd_device *dev, | ||
811 | struct ceph_snap_context *snapc, | ||
812 | u64 snapid, | ||
813 | int opcode, | ||
814 | int flags, | ||
815 | struct ceph_osd_req_op *orig_ops, | ||
816 | int num_reply, | ||
817 | const char *obj, | ||
818 | u64 ofs, u64 len, | ||
819 | char *buf) | ||
820 | { | ||
821 | int ret; | ||
822 | struct page **pages; | ||
823 | int num_pages; | ||
824 | struct ceph_osd_req_op *ops = orig_ops; | ||
825 | u32 payload_len; | ||
826 | |||
827 | num_pages = calc_pages_for(ofs , len); | ||
828 | pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL); | ||
829 | if (IS_ERR(pages)) | ||
830 | return PTR_ERR(pages); | ||
831 | |||
832 | if (!orig_ops) { | ||
833 | payload_len = (flags & CEPH_OSD_FLAG_WRITE ? len : 0); | ||
834 | ret = rbd_create_rw_ops(&ops, 1, opcode, payload_len); | ||
835 | if (ret < 0) | ||
836 | goto done; | ||
837 | |||
838 | if ((flags & CEPH_OSD_FLAG_WRITE) && buf) { | ||
839 | ret = ceph_copy_to_page_vector(pages, buf, ofs, len); | ||
840 | if (ret < 0) | ||
841 | goto done_ops; | ||
842 | } | ||
843 | } | ||
844 | |||
845 | ret = rbd_do_request(NULL, dev, snapc, snapid, | ||
846 | obj, ofs, len, NULL, | ||
847 | pages, num_pages, | ||
848 | flags, | ||
849 | ops, | ||
850 | 2, | ||
851 | NULL); | ||
852 | if (ret < 0) | ||
853 | goto done_ops; | ||
854 | |||
855 | if ((flags & CEPH_OSD_FLAG_READ) && buf) | ||
856 | ret = ceph_copy_from_page_vector(pages, buf, ofs, ret); | ||
857 | |||
858 | done_ops: | ||
859 | if (!orig_ops) | ||
860 | rbd_destroy_ops(ops); | ||
861 | done: | ||
862 | ceph_release_page_vector(pages, num_pages); | ||
863 | return ret; | ||
864 | } | ||
865 | |||
866 | /* | ||
867 | * Do an asynchronous ceph osd operation | ||
868 | */ | ||
869 | static int rbd_do_op(struct request *rq, | ||
870 | struct rbd_device *rbd_dev , | ||
871 | struct ceph_snap_context *snapc, | ||
872 | u64 snapid, | ||
873 | int opcode, int flags, int num_reply, | ||
874 | u64 ofs, u64 len, | ||
875 | struct bio *bio) | ||
876 | { | ||
877 | char *seg_name; | ||
878 | u64 seg_ofs; | ||
879 | u64 seg_len; | ||
880 | int ret; | ||
881 | struct ceph_osd_req_op *ops; | ||
882 | u32 payload_len; | ||
883 | |||
884 | seg_name = kmalloc(RBD_MAX_SEG_NAME_LEN + 1, GFP_NOIO); | ||
885 | if (!seg_name) | ||
886 | return -ENOMEM; | ||
887 | |||
888 | seg_len = rbd_get_segment(&rbd_dev->header, | ||
889 | rbd_dev->header.block_name, | ||
890 | ofs, len, | ||
891 | seg_name, &seg_ofs); | ||
892 | |||
893 | payload_len = (flags & CEPH_OSD_FLAG_WRITE ? seg_len : 0); | ||
894 | |||
895 | ret = rbd_create_rw_ops(&ops, 1, opcode, payload_len); | ||
896 | if (ret < 0) | ||
897 | goto done; | ||
898 | |||
899 | /* we've taken care of segment sizes earlier when we | ||
900 | cloned the bios. We should never have a segment | ||
901 | truncated at this point */ | ||
902 | BUG_ON(seg_len < len); | ||
903 | |||
904 | ret = rbd_do_request(rq, rbd_dev, snapc, snapid, | ||
905 | seg_name, seg_ofs, seg_len, | ||
906 | bio, | ||
907 | NULL, 0, | ||
908 | flags, | ||
909 | ops, | ||
910 | num_reply, | ||
911 | rbd_req_cb); | ||
912 | done: | ||
913 | kfree(seg_name); | ||
914 | return ret; | ||
915 | } | ||
916 | |||
917 | /* | ||
918 | * Request async osd write | ||
919 | */ | ||
920 | static int rbd_req_write(struct request *rq, | ||
921 | struct rbd_device *rbd_dev, | ||
922 | struct ceph_snap_context *snapc, | ||
923 | u64 ofs, u64 len, | ||
924 | struct bio *bio) | ||
925 | { | ||
926 | return rbd_do_op(rq, rbd_dev, snapc, CEPH_NOSNAP, | ||
927 | CEPH_OSD_OP_WRITE, | ||
928 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, | ||
929 | 2, | ||
930 | ofs, len, bio); | ||
931 | } | ||
932 | |||
933 | /* | ||
934 | * Request async osd read | ||
935 | */ | ||
936 | static int rbd_req_read(struct request *rq, | ||
937 | struct rbd_device *rbd_dev, | ||
938 | u64 snapid, | ||
939 | u64 ofs, u64 len, | ||
940 | struct bio *bio) | ||
941 | { | ||
942 | return rbd_do_op(rq, rbd_dev, NULL, | ||
943 | (snapid ? snapid : CEPH_NOSNAP), | ||
944 | CEPH_OSD_OP_READ, | ||
945 | CEPH_OSD_FLAG_READ, | ||
946 | 2, | ||
947 | ofs, len, bio); | ||
948 | } | ||
949 | |||
950 | /* | ||
951 | * Request sync osd read | ||
952 | */ | ||
953 | static int rbd_req_sync_read(struct rbd_device *dev, | ||
954 | struct ceph_snap_context *snapc, | ||
955 | u64 snapid, | ||
956 | const char *obj, | ||
957 | u64 ofs, u64 len, | ||
958 | char *buf) | ||
959 | { | ||
960 | return rbd_req_sync_op(dev, NULL, | ||
961 | (snapid ? snapid : CEPH_NOSNAP), | ||
962 | CEPH_OSD_OP_READ, | ||
963 | CEPH_OSD_FLAG_READ, | ||
964 | NULL, | ||
965 | 1, obj, ofs, len, buf); | ||
966 | } | ||
967 | |||
968 | /* | ||
969 | * Request sync osd read | ||
970 | */ | ||
971 | static int rbd_req_sync_rollback_obj(struct rbd_device *dev, | ||
972 | u64 snapid, | ||
973 | const char *obj) | ||
974 | { | ||
975 | struct ceph_osd_req_op *ops; | ||
976 | int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_ROLLBACK, 0); | ||
977 | if (ret < 0) | ||
978 | return ret; | ||
979 | |||
980 | ops[0].snap.snapid = snapid; | ||
981 | |||
982 | ret = rbd_req_sync_op(dev, NULL, | ||
983 | CEPH_NOSNAP, | ||
984 | 0, | ||
985 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, | ||
986 | ops, | ||
987 | 1, obj, 0, 0, NULL); | ||
988 | |||
989 | rbd_destroy_ops(ops); | ||
990 | |||
991 | if (ret < 0) | ||
992 | return ret; | ||
993 | |||
994 | return ret; | ||
995 | } | ||
996 | |||
997 | /* | ||
998 | * Request sync osd read | ||
999 | */ | ||
1000 | static int rbd_req_sync_exec(struct rbd_device *dev, | ||
1001 | const char *obj, | ||
1002 | const char *cls, | ||
1003 | const char *method, | ||
1004 | const char *data, | ||
1005 | int len) | ||
1006 | { | ||
1007 | struct ceph_osd_req_op *ops; | ||
1008 | int cls_len = strlen(cls); | ||
1009 | int method_len = strlen(method); | ||
1010 | int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_CALL, | ||
1011 | cls_len + method_len + len); | ||
1012 | if (ret < 0) | ||
1013 | return ret; | ||
1014 | |||
1015 | ops[0].cls.class_name = cls; | ||
1016 | ops[0].cls.class_len = (__u8)cls_len; | ||
1017 | ops[0].cls.method_name = method; | ||
1018 | ops[0].cls.method_len = (__u8)method_len; | ||
1019 | ops[0].cls.argc = 0; | ||
1020 | ops[0].cls.indata = data; | ||
1021 | ops[0].cls.indata_len = len; | ||
1022 | |||
1023 | ret = rbd_req_sync_op(dev, NULL, | ||
1024 | CEPH_NOSNAP, | ||
1025 | 0, | ||
1026 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, | ||
1027 | ops, | ||
1028 | 1, obj, 0, 0, NULL); | ||
1029 | |||
1030 | rbd_destroy_ops(ops); | ||
1031 | |||
1032 | dout("cls_exec returned %d\n", ret); | ||
1033 | return ret; | ||
1034 | } | ||
1035 | |||
1036 | /* | ||
1037 | * block device queue callback | ||
1038 | */ | ||
1039 | static void rbd_rq_fn(struct request_queue *q) | ||
1040 | { | ||
1041 | struct rbd_device *rbd_dev = q->queuedata; | ||
1042 | struct request *rq; | ||
1043 | struct bio_pair *bp = NULL; | ||
1044 | |||
1045 | rq = blk_fetch_request(q); | ||
1046 | |||
1047 | while (1) { | ||
1048 | struct bio *bio; | ||
1049 | struct bio *rq_bio, *next_bio = NULL; | ||
1050 | bool do_write; | ||
1051 | int size, op_size = 0; | ||
1052 | u64 ofs; | ||
1053 | |||
1054 | /* peek at request from block layer */ | ||
1055 | if (!rq) | ||
1056 | break; | ||
1057 | |||
1058 | dout("fetched request\n"); | ||
1059 | |||
1060 | /* filter out block requests we don't understand */ | ||
1061 | if ((rq->cmd_type != REQ_TYPE_FS)) { | ||
1062 | __blk_end_request_all(rq, 0); | ||
1063 | goto next; | ||
1064 | } | ||
1065 | |||
1066 | /* deduce our operation (read, write) */ | ||
1067 | do_write = (rq_data_dir(rq) == WRITE); | ||
1068 | |||
1069 | size = blk_rq_bytes(rq); | ||
1070 | ofs = blk_rq_pos(rq) * 512ULL; | ||
1071 | rq_bio = rq->bio; | ||
1072 | if (do_write && rbd_dev->read_only) { | ||
1073 | __blk_end_request_all(rq, -EROFS); | ||
1074 | goto next; | ||
1075 | } | ||
1076 | |||
1077 | spin_unlock_irq(q->queue_lock); | ||
1078 | |||
1079 | dout("%s 0x%x bytes at 0x%llx\n", | ||
1080 | do_write ? "write" : "read", | ||
1081 | size, blk_rq_pos(rq) * 512ULL); | ||
1082 | |||
1083 | do { | ||
1084 | /* a bio clone to be passed down to OSD req */ | ||
1085 | dout("rq->bio->bi_vcnt=%d\n", rq->bio->bi_vcnt); | ||
1086 | op_size = rbd_get_segment(&rbd_dev->header, | ||
1087 | rbd_dev->header.block_name, | ||
1088 | ofs, size, | ||
1089 | NULL, NULL); | ||
1090 | bio = bio_chain_clone(&rq_bio, &next_bio, &bp, | ||
1091 | op_size, GFP_ATOMIC); | ||
1092 | if (!bio) { | ||
1093 | spin_lock_irq(q->queue_lock); | ||
1094 | __blk_end_request_all(rq, -ENOMEM); | ||
1095 | goto next; | ||
1096 | } | ||
1097 | |||
1098 | /* init OSD command: write or read */ | ||
1099 | if (do_write) | ||
1100 | rbd_req_write(rq, rbd_dev, | ||
1101 | rbd_dev->header.snapc, | ||
1102 | ofs, | ||
1103 | op_size, bio); | ||
1104 | else | ||
1105 | rbd_req_read(rq, rbd_dev, | ||
1106 | cur_snap_id(rbd_dev), | ||
1107 | ofs, | ||
1108 | op_size, bio); | ||
1109 | |||
1110 | size -= op_size; | ||
1111 | ofs += op_size; | ||
1112 | |||
1113 | rq_bio = next_bio; | ||
1114 | } while (size > 0); | ||
1115 | |||
1116 | if (bp) | ||
1117 | bio_pair_release(bp); | ||
1118 | |||
1119 | spin_lock_irq(q->queue_lock); | ||
1120 | next: | ||
1121 | rq = blk_fetch_request(q); | ||
1122 | } | ||
1123 | } | ||
1124 | |||
1125 | /* | ||
1126 | * a queue callback. Makes sure that we don't create a bio that spans across | ||
1127 | * multiple osd objects. One exception would be with a single page bios, | ||
1128 | * which we handle later at bio_chain_clone | ||
1129 | */ | ||
1130 | static int rbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bmd, | ||
1131 | struct bio_vec *bvec) | ||
1132 | { | ||
1133 | struct rbd_device *rbd_dev = q->queuedata; | ||
1134 | unsigned int chunk_sectors = 1 << (rbd_dev->header.obj_order - 9); | ||
1135 | sector_t sector = bmd->bi_sector + get_start_sect(bmd->bi_bdev); | ||
1136 | unsigned int bio_sectors = bmd->bi_size >> 9; | ||
1137 | int max; | ||
1138 | |||
1139 | max = (chunk_sectors - ((sector & (chunk_sectors - 1)) | ||
1140 | + bio_sectors)) << 9; | ||
1141 | if (max < 0) | ||
1142 | max = 0; /* bio_add cannot handle a negative return */ | ||
1143 | if (max <= bvec->bv_len && bio_sectors == 0) | ||
1144 | return bvec->bv_len; | ||
1145 | return max; | ||
1146 | } | ||
1147 | |||
1148 | static void rbd_free_disk(struct rbd_device *rbd_dev) | ||
1149 | { | ||
1150 | struct gendisk *disk = rbd_dev->disk; | ||
1151 | |||
1152 | if (!disk) | ||
1153 | return; | ||
1154 | |||
1155 | rbd_header_free(&rbd_dev->header); | ||
1156 | |||
1157 | if (disk->flags & GENHD_FL_UP) | ||
1158 | del_gendisk(disk); | ||
1159 | if (disk->queue) | ||
1160 | blk_cleanup_queue(disk->queue); | ||
1161 | put_disk(disk); | ||
1162 | } | ||
1163 | |||
1164 | /* | ||
1165 | * reload the ondisk the header | ||
1166 | */ | ||
1167 | static int rbd_read_header(struct rbd_device *rbd_dev, | ||
1168 | struct rbd_image_header *header) | ||
1169 | { | ||
1170 | ssize_t rc; | ||
1171 | struct rbd_image_header_ondisk *dh; | ||
1172 | int snap_count = 0; | ||
1173 | u64 snap_names_len = 0; | ||
1174 | |||
1175 | while (1) { | ||
1176 | int len = sizeof(*dh) + | ||
1177 | snap_count * sizeof(struct rbd_image_snap_ondisk) + | ||
1178 | snap_names_len; | ||
1179 | |||
1180 | rc = -ENOMEM; | ||
1181 | dh = kmalloc(len, GFP_KERNEL); | ||
1182 | if (!dh) | ||
1183 | return -ENOMEM; | ||
1184 | |||
1185 | rc = rbd_req_sync_read(rbd_dev, | ||
1186 | NULL, CEPH_NOSNAP, | ||
1187 | rbd_dev->obj_md_name, | ||
1188 | 0, len, | ||
1189 | (char *)dh); | ||
1190 | if (rc < 0) | ||
1191 | goto out_dh; | ||
1192 | |||
1193 | rc = rbd_header_from_disk(header, dh, snap_count, GFP_KERNEL); | ||
1194 | if (rc < 0) | ||
1195 | goto out_dh; | ||
1196 | |||
1197 | if (snap_count != header->total_snaps) { | ||
1198 | snap_count = header->total_snaps; | ||
1199 | snap_names_len = header->snap_names_len; | ||
1200 | rbd_header_free(header); | ||
1201 | kfree(dh); | ||
1202 | continue; | ||
1203 | } | ||
1204 | break; | ||
1205 | } | ||
1206 | |||
1207 | out_dh: | ||
1208 | kfree(dh); | ||
1209 | return rc; | ||
1210 | } | ||
1211 | |||
1212 | /* | ||
1213 | * create a snapshot | ||
1214 | */ | ||
1215 | static int rbd_header_add_snap(struct rbd_device *dev, | ||
1216 | const char *snap_name, | ||
1217 | gfp_t gfp_flags) | ||
1218 | { | ||
1219 | int name_len = strlen(snap_name); | ||
1220 | u64 new_snapid; | ||
1221 | int ret; | ||
1222 | void *data, *data_start, *data_end; | ||
1223 | |||
1224 | /* we should create a snapshot only if we're pointing at the head */ | ||
1225 | if (dev->cur_snap) | ||
1226 | return -EINVAL; | ||
1227 | |||
1228 | ret = ceph_monc_create_snapid(&dev->client->monc, dev->poolid, | ||
1229 | &new_snapid); | ||
1230 | dout("created snapid=%lld\n", new_snapid); | ||
1231 | if (ret < 0) | ||
1232 | return ret; | ||
1233 | |||
1234 | data = kmalloc(name_len + 16, gfp_flags); | ||
1235 | if (!data) | ||
1236 | return -ENOMEM; | ||
1237 | |||
1238 | data_start = data; | ||
1239 | data_end = data + name_len + 16; | ||
1240 | |||
1241 | ceph_encode_string_safe(&data, data_end, snap_name, name_len, bad); | ||
1242 | ceph_encode_64_safe(&data, data_end, new_snapid, bad); | ||
1243 | |||
1244 | ret = rbd_req_sync_exec(dev, dev->obj_md_name, "rbd", "snap_add", | ||
1245 | data_start, data - data_start); | ||
1246 | |||
1247 | kfree(data_start); | ||
1248 | |||
1249 | if (ret < 0) | ||
1250 | return ret; | ||
1251 | |||
1252 | dev->header.snapc->seq = new_snapid; | ||
1253 | |||
1254 | return 0; | ||
1255 | bad: | ||
1256 | return -ERANGE; | ||
1257 | } | ||
1258 | |||
1259 | /* | ||
1260 | * only read the first part of the ondisk header, without the snaps info | ||
1261 | */ | ||
1262 | static int rbd_update_snaps(struct rbd_device *rbd_dev) | ||
1263 | { | ||
1264 | int ret; | ||
1265 | struct rbd_image_header h; | ||
1266 | u64 snap_seq; | ||
1267 | |||
1268 | ret = rbd_read_header(rbd_dev, &h); | ||
1269 | if (ret < 0) | ||
1270 | return ret; | ||
1271 | |||
1272 | down_write(&rbd_dev->header.snap_rwsem); | ||
1273 | |||
1274 | snap_seq = rbd_dev->header.snapc->seq; | ||
1275 | |||
1276 | kfree(rbd_dev->header.snapc); | ||
1277 | kfree(rbd_dev->header.snap_names); | ||
1278 | kfree(rbd_dev->header.snap_sizes); | ||
1279 | |||
1280 | rbd_dev->header.total_snaps = h.total_snaps; | ||
1281 | rbd_dev->header.snapc = h.snapc; | ||
1282 | rbd_dev->header.snap_names = h.snap_names; | ||
1283 | rbd_dev->header.snap_sizes = h.snap_sizes; | ||
1284 | rbd_dev->header.snapc->seq = snap_seq; | ||
1285 | |||
1286 | up_write(&rbd_dev->header.snap_rwsem); | ||
1287 | |||
1288 | return 0; | ||
1289 | } | ||
1290 | |||
1291 | static int rbd_init_disk(struct rbd_device *rbd_dev) | ||
1292 | { | ||
1293 | struct gendisk *disk; | ||
1294 | struct request_queue *q; | ||
1295 | int rc; | ||
1296 | u64 total_size = 0; | ||
1297 | |||
1298 | /* contact OSD, request size info about the object being mapped */ | ||
1299 | rc = rbd_read_header(rbd_dev, &rbd_dev->header); | ||
1300 | if (rc) | ||
1301 | return rc; | ||
1302 | |||
1303 | rc = rbd_header_set_snap(rbd_dev, rbd_dev->snap_name, &total_size); | ||
1304 | if (rc) | ||
1305 | return rc; | ||
1306 | |||
1307 | /* create gendisk info */ | ||
1308 | rc = -ENOMEM; | ||
1309 | disk = alloc_disk(RBD_MINORS_PER_MAJOR); | ||
1310 | if (!disk) | ||
1311 | goto out; | ||
1312 | |||
1313 | sprintf(disk->disk_name, DRV_NAME "%d", rbd_dev->id); | ||
1314 | disk->major = rbd_dev->major; | ||
1315 | disk->first_minor = 0; | ||
1316 | disk->fops = &rbd_bd_ops; | ||
1317 | disk->private_data = rbd_dev; | ||
1318 | |||
1319 | /* init rq */ | ||
1320 | rc = -ENOMEM; | ||
1321 | q = blk_init_queue(rbd_rq_fn, &rbd_dev->lock); | ||
1322 | if (!q) | ||
1323 | goto out_disk; | ||
1324 | blk_queue_merge_bvec(q, rbd_merge_bvec); | ||
1325 | disk->queue = q; | ||
1326 | |||
1327 | q->queuedata = rbd_dev; | ||
1328 | |||
1329 | rbd_dev->disk = disk; | ||
1330 | rbd_dev->q = q; | ||
1331 | |||
1332 | /* finally, announce the disk to the world */ | ||
1333 | set_capacity(disk, total_size / 512ULL); | ||
1334 | add_disk(disk); | ||
1335 | |||
1336 | pr_info("%s: added with size 0x%llx\n", | ||
1337 | disk->disk_name, (unsigned long long)total_size); | ||
1338 | return 0; | ||
1339 | |||
1340 | out_disk: | ||
1341 | put_disk(disk); | ||
1342 | out: | ||
1343 | return rc; | ||
1344 | } | ||
1345 | |||
1346 | /******************************************************************** | ||
1347 | * /sys/class/rbd/ | ||
1348 | * add map rados objects to blkdev | ||
1349 | * remove unmap rados objects | ||
1350 | * list show mappings | ||
1351 | *******************************************************************/ | ||
1352 | |||
1353 | static void class_rbd_release(struct class *cls) | ||
1354 | { | ||
1355 | kfree(cls); | ||
1356 | } | ||
1357 | |||
1358 | static ssize_t class_rbd_list(struct class *c, | ||
1359 | struct class_attribute *attr, | ||
1360 | char *data) | ||
1361 | { | ||
1362 | int n = 0; | ||
1363 | struct list_head *tmp; | ||
1364 | int max = PAGE_SIZE; | ||
1365 | |||
1366 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
1367 | |||
1368 | n += snprintf(data, max, | ||
1369 | "#id\tmajor\tclient_name\tpool\tname\tsnap\tKB\n"); | ||
1370 | |||
1371 | list_for_each(tmp, &rbd_dev_list) { | ||
1372 | struct rbd_device *rbd_dev; | ||
1373 | |||
1374 | rbd_dev = list_entry(tmp, struct rbd_device, node); | ||
1375 | n += snprintf(data+n, max-n, | ||
1376 | "%d\t%d\tclient%lld\t%s\t%s\t%s\t%lld\n", | ||
1377 | rbd_dev->id, | ||
1378 | rbd_dev->major, | ||
1379 | ceph_client_id(rbd_dev->client), | ||
1380 | rbd_dev->pool_name, | ||
1381 | rbd_dev->obj, rbd_dev->snap_name, | ||
1382 | rbd_dev->header.image_size >> 10); | ||
1383 | if (n == max) | ||
1384 | break; | ||
1385 | } | ||
1386 | |||
1387 | mutex_unlock(&ctl_mutex); | ||
1388 | return n; | ||
1389 | } | ||
1390 | |||
1391 | static ssize_t class_rbd_add(struct class *c, | ||
1392 | struct class_attribute *attr, | ||
1393 | const char *buf, size_t count) | ||
1394 | { | ||
1395 | struct ceph_osd_client *osdc; | ||
1396 | struct rbd_device *rbd_dev; | ||
1397 | ssize_t rc = -ENOMEM; | ||
1398 | int irc, new_id = 0; | ||
1399 | struct list_head *tmp; | ||
1400 | char *mon_dev_name; | ||
1401 | char *options; | ||
1402 | |||
1403 | if (!try_module_get(THIS_MODULE)) | ||
1404 | return -ENODEV; | ||
1405 | |||
1406 | mon_dev_name = kmalloc(RBD_MAX_OPT_LEN, GFP_KERNEL); | ||
1407 | if (!mon_dev_name) | ||
1408 | goto err_out_mod; | ||
1409 | |||
1410 | options = kmalloc(RBD_MAX_OPT_LEN, GFP_KERNEL); | ||
1411 | if (!options) | ||
1412 | goto err_mon_dev; | ||
1413 | |||
1414 | /* new rbd_device object */ | ||
1415 | rbd_dev = kzalloc(sizeof(*rbd_dev), GFP_KERNEL); | ||
1416 | if (!rbd_dev) | ||
1417 | goto err_out_opt; | ||
1418 | |||
1419 | /* static rbd_device initialization */ | ||
1420 | spin_lock_init(&rbd_dev->lock); | ||
1421 | INIT_LIST_HEAD(&rbd_dev->node); | ||
1422 | |||
1423 | /* generate unique id: find highest unique id, add one */ | ||
1424 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
1425 | |||
1426 | list_for_each(tmp, &rbd_dev_list) { | ||
1427 | struct rbd_device *rbd_dev; | ||
1428 | |||
1429 | rbd_dev = list_entry(tmp, struct rbd_device, node); | ||
1430 | if (rbd_dev->id >= new_id) | ||
1431 | new_id = rbd_dev->id + 1; | ||
1432 | } | ||
1433 | |||
1434 | rbd_dev->id = new_id; | ||
1435 | |||
1436 | /* add to global list */ | ||
1437 | list_add_tail(&rbd_dev->node, &rbd_dev_list); | ||
1438 | |||
1439 | /* parse add command */ | ||
1440 | if (sscanf(buf, "%" __stringify(RBD_MAX_OPT_LEN) "s " | ||
1441 | "%" __stringify(RBD_MAX_OPT_LEN) "s " | ||
1442 | "%" __stringify(RBD_MAX_POOL_NAME_LEN) "s " | ||
1443 | "%" __stringify(RBD_MAX_OBJ_NAME_LEN) "s" | ||
1444 | "%" __stringify(RBD_MAX_SNAP_NAME_LEN) "s", | ||
1445 | mon_dev_name, options, rbd_dev->pool_name, | ||
1446 | rbd_dev->obj, rbd_dev->snap_name) < 4) { | ||
1447 | rc = -EINVAL; | ||
1448 | goto err_out_slot; | ||
1449 | } | ||
1450 | |||
1451 | if (rbd_dev->snap_name[0] == 0) | ||
1452 | rbd_dev->snap_name[0] = '-'; | ||
1453 | |||
1454 | rbd_dev->obj_len = strlen(rbd_dev->obj); | ||
1455 | snprintf(rbd_dev->obj_md_name, sizeof(rbd_dev->obj_md_name), "%s%s", | ||
1456 | rbd_dev->obj, RBD_SUFFIX); | ||
1457 | |||
1458 | /* initialize rest of new object */ | ||
1459 | snprintf(rbd_dev->name, DEV_NAME_LEN, DRV_NAME "%d", rbd_dev->id); | ||
1460 | rc = rbd_get_client(rbd_dev, mon_dev_name, options); | ||
1461 | if (rc < 0) | ||
1462 | goto err_out_slot; | ||
1463 | |||
1464 | mutex_unlock(&ctl_mutex); | ||
1465 | |||
1466 | /* pick the pool */ | ||
1467 | osdc = &rbd_dev->client->osdc; | ||
1468 | rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name); | ||
1469 | if (rc < 0) | ||
1470 | goto err_out_client; | ||
1471 | rbd_dev->poolid = rc; | ||
1472 | |||
1473 | /* register our block device */ | ||
1474 | irc = register_blkdev(0, rbd_dev->name); | ||
1475 | if (irc < 0) { | ||
1476 | rc = irc; | ||
1477 | goto err_out_client; | ||
1478 | } | ||
1479 | rbd_dev->major = irc; | ||
1480 | |||
1481 | /* set up and announce blkdev mapping */ | ||
1482 | rc = rbd_init_disk(rbd_dev); | ||
1483 | if (rc) | ||
1484 | goto err_out_blkdev; | ||
1485 | |||
1486 | return count; | ||
1487 | |||
1488 | err_out_blkdev: | ||
1489 | unregister_blkdev(rbd_dev->major, rbd_dev->name); | ||
1490 | err_out_client: | ||
1491 | rbd_put_client(rbd_dev); | ||
1492 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
1493 | err_out_slot: | ||
1494 | list_del_init(&rbd_dev->node); | ||
1495 | mutex_unlock(&ctl_mutex); | ||
1496 | |||
1497 | kfree(rbd_dev); | ||
1498 | err_out_opt: | ||
1499 | kfree(options); | ||
1500 | err_mon_dev: | ||
1501 | kfree(mon_dev_name); | ||
1502 | err_out_mod: | ||
1503 | dout("Error adding device %s\n", buf); | ||
1504 | module_put(THIS_MODULE); | ||
1505 | return rc; | ||
1506 | } | ||
1507 | |||
1508 | static struct rbd_device *__rbd_get_dev(unsigned long id) | ||
1509 | { | ||
1510 | struct list_head *tmp; | ||
1511 | struct rbd_device *rbd_dev; | ||
1512 | |||
1513 | list_for_each(tmp, &rbd_dev_list) { | ||
1514 | rbd_dev = list_entry(tmp, struct rbd_device, node); | ||
1515 | if (rbd_dev->id == id) | ||
1516 | return rbd_dev; | ||
1517 | } | ||
1518 | return NULL; | ||
1519 | } | ||
1520 | |||
1521 | static ssize_t class_rbd_remove(struct class *c, | ||
1522 | struct class_attribute *attr, | ||
1523 | const char *buf, | ||
1524 | size_t count) | ||
1525 | { | ||
1526 | struct rbd_device *rbd_dev = NULL; | ||
1527 | int target_id, rc; | ||
1528 | unsigned long ul; | ||
1529 | |||
1530 | rc = strict_strtoul(buf, 10, &ul); | ||
1531 | if (rc) | ||
1532 | return rc; | ||
1533 | |||
1534 | /* convert to int; abort if we lost anything in the conversion */ | ||
1535 | target_id = (int) ul; | ||
1536 | if (target_id != ul) | ||
1537 | return -EINVAL; | ||
1538 | |||
1539 | /* remove object from list immediately */ | ||
1540 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
1541 | |||
1542 | rbd_dev = __rbd_get_dev(target_id); | ||
1543 | if (rbd_dev) | ||
1544 | list_del_init(&rbd_dev->node); | ||
1545 | |||
1546 | mutex_unlock(&ctl_mutex); | ||
1547 | |||
1548 | if (!rbd_dev) | ||
1549 | return -ENOENT; | ||
1550 | |||
1551 | rbd_put_client(rbd_dev); | ||
1552 | |||
1553 | /* clean up and free blkdev */ | ||
1554 | rbd_free_disk(rbd_dev); | ||
1555 | unregister_blkdev(rbd_dev->major, rbd_dev->name); | ||
1556 | kfree(rbd_dev); | ||
1557 | |||
1558 | /* release module ref */ | ||
1559 | module_put(THIS_MODULE); | ||
1560 | |||
1561 | return count; | ||
1562 | } | ||
1563 | |||
1564 | static ssize_t class_rbd_snaps_list(struct class *c, | ||
1565 | struct class_attribute *attr, | ||
1566 | char *data) | ||
1567 | { | ||
1568 | struct rbd_device *rbd_dev = NULL; | ||
1569 | struct list_head *tmp; | ||
1570 | struct rbd_image_header *header; | ||
1571 | int i, n = 0, max = PAGE_SIZE; | ||
1572 | int ret; | ||
1573 | |||
1574 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
1575 | |||
1576 | n += snprintf(data, max, "#id\tsnap\tKB\n"); | ||
1577 | |||
1578 | list_for_each(tmp, &rbd_dev_list) { | ||
1579 | char *names, *p; | ||
1580 | struct ceph_snap_context *snapc; | ||
1581 | |||
1582 | rbd_dev = list_entry(tmp, struct rbd_device, node); | ||
1583 | header = &rbd_dev->header; | ||
1584 | |||
1585 | down_read(&header->snap_rwsem); | ||
1586 | |||
1587 | names = header->snap_names; | ||
1588 | snapc = header->snapc; | ||
1589 | |||
1590 | n += snprintf(data + n, max - n, "%d\t%s\t%lld%s\n", | ||
1591 | rbd_dev->id, RBD_SNAP_HEAD_NAME, | ||
1592 | header->image_size >> 10, | ||
1593 | (!rbd_dev->cur_snap ? " (*)" : "")); | ||
1594 | if (n == max) | ||
1595 | break; | ||
1596 | |||
1597 | p = names; | ||
1598 | for (i = 0; i < header->total_snaps; i++, p += strlen(p) + 1) { | ||
1599 | n += snprintf(data + n, max - n, "%d\t%s\t%lld%s\n", | ||
1600 | rbd_dev->id, p, header->snap_sizes[i] >> 10, | ||
1601 | (rbd_dev->cur_snap && | ||
1602 | (snap_index(header, i) == rbd_dev->cur_snap) ? | ||
1603 | " (*)" : "")); | ||
1604 | if (n == max) | ||
1605 | break; | ||
1606 | } | ||
1607 | |||
1608 | up_read(&header->snap_rwsem); | ||
1609 | } | ||
1610 | |||
1611 | |||
1612 | ret = n; | ||
1613 | mutex_unlock(&ctl_mutex); | ||
1614 | return ret; | ||
1615 | } | ||
1616 | |||
1617 | static ssize_t class_rbd_snaps_refresh(struct class *c, | ||
1618 | struct class_attribute *attr, | ||
1619 | const char *buf, | ||
1620 | size_t count) | ||
1621 | { | ||
1622 | struct rbd_device *rbd_dev = NULL; | ||
1623 | int target_id, rc; | ||
1624 | unsigned long ul; | ||
1625 | int ret = count; | ||
1626 | |||
1627 | rc = strict_strtoul(buf, 10, &ul); | ||
1628 | if (rc) | ||
1629 | return rc; | ||
1630 | |||
1631 | /* convert to int; abort if we lost anything in the conversion */ | ||
1632 | target_id = (int) ul; | ||
1633 | if (target_id != ul) | ||
1634 | return -EINVAL; | ||
1635 | |||
1636 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
1637 | |||
1638 | rbd_dev = __rbd_get_dev(target_id); | ||
1639 | if (!rbd_dev) { | ||
1640 | ret = -ENOENT; | ||
1641 | goto done; | ||
1642 | } | ||
1643 | |||
1644 | rc = rbd_update_snaps(rbd_dev); | ||
1645 | if (rc < 0) | ||
1646 | ret = rc; | ||
1647 | |||
1648 | done: | ||
1649 | mutex_unlock(&ctl_mutex); | ||
1650 | return ret; | ||
1651 | } | ||
1652 | |||
1653 | static ssize_t class_rbd_snap_create(struct class *c, | ||
1654 | struct class_attribute *attr, | ||
1655 | const char *buf, | ||
1656 | size_t count) | ||
1657 | { | ||
1658 | struct rbd_device *rbd_dev = NULL; | ||
1659 | int target_id, ret; | ||
1660 | char *name; | ||
1661 | |||
1662 | name = kmalloc(RBD_MAX_SNAP_NAME_LEN + 1, GFP_KERNEL); | ||
1663 | if (!name) | ||
1664 | return -ENOMEM; | ||
1665 | |||
1666 | /* parse snaps add command */ | ||
1667 | if (sscanf(buf, "%d " | ||
1668 | "%" __stringify(RBD_MAX_SNAP_NAME_LEN) "s", | ||
1669 | &target_id, | ||
1670 | name) != 2) { | ||
1671 | ret = -EINVAL; | ||
1672 | goto done; | ||
1673 | } | ||
1674 | |||
1675 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
1676 | |||
1677 | rbd_dev = __rbd_get_dev(target_id); | ||
1678 | if (!rbd_dev) { | ||
1679 | ret = -ENOENT; | ||
1680 | goto done_unlock; | ||
1681 | } | ||
1682 | |||
1683 | ret = rbd_header_add_snap(rbd_dev, | ||
1684 | name, GFP_KERNEL); | ||
1685 | if (ret < 0) | ||
1686 | goto done_unlock; | ||
1687 | |||
1688 | ret = rbd_update_snaps(rbd_dev); | ||
1689 | if (ret < 0) | ||
1690 | goto done_unlock; | ||
1691 | |||
1692 | ret = count; | ||
1693 | done_unlock: | ||
1694 | mutex_unlock(&ctl_mutex); | ||
1695 | done: | ||
1696 | kfree(name); | ||
1697 | return ret; | ||
1698 | } | ||
1699 | |||
1700 | static ssize_t class_rbd_rollback(struct class *c, | ||
1701 | struct class_attribute *attr, | ||
1702 | const char *buf, | ||
1703 | size_t count) | ||
1704 | { | ||
1705 | struct rbd_device *rbd_dev = NULL; | ||
1706 | int target_id, ret; | ||
1707 | u64 snapid; | ||
1708 | char snap_name[RBD_MAX_SNAP_NAME_LEN]; | ||
1709 | u64 cur_ofs; | ||
1710 | char *seg_name; | ||
1711 | |||
1712 | /* parse snaps add command */ | ||
1713 | if (sscanf(buf, "%d " | ||
1714 | "%" __stringify(RBD_MAX_SNAP_NAME_LEN) "s", | ||
1715 | &target_id, | ||
1716 | snap_name) != 2) { | ||
1717 | return -EINVAL; | ||
1718 | } | ||
1719 | |||
1720 | ret = -ENOMEM; | ||
1721 | seg_name = kmalloc(RBD_MAX_SEG_NAME_LEN + 1, GFP_NOIO); | ||
1722 | if (!seg_name) | ||
1723 | return ret; | ||
1724 | |||
1725 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
1726 | |||
1727 | rbd_dev = __rbd_get_dev(target_id); | ||
1728 | if (!rbd_dev) { | ||
1729 | ret = -ENOENT; | ||
1730 | goto done_unlock; | ||
1731 | } | ||
1732 | |||
1733 | ret = snap_by_name(&rbd_dev->header, snap_name, &snapid, NULL); | ||
1734 | if (ret < 0) | ||
1735 | goto done_unlock; | ||
1736 | |||
1737 | dout("snapid=%lld\n", snapid); | ||
1738 | |||
1739 | cur_ofs = 0; | ||
1740 | while (cur_ofs < rbd_dev->header.image_size) { | ||
1741 | cur_ofs += rbd_get_segment(&rbd_dev->header, | ||
1742 | rbd_dev->obj, | ||
1743 | cur_ofs, (u64)-1, | ||
1744 | seg_name, NULL); | ||
1745 | dout("seg_name=%s\n", seg_name); | ||
1746 | |||
1747 | ret = rbd_req_sync_rollback_obj(rbd_dev, snapid, seg_name); | ||
1748 | if (ret < 0) | ||
1749 | pr_warning("could not roll back obj %s err=%d\n", | ||
1750 | seg_name, ret); | ||
1751 | } | ||
1752 | |||
1753 | ret = rbd_update_snaps(rbd_dev); | ||
1754 | if (ret < 0) | ||
1755 | goto done_unlock; | ||
1756 | |||
1757 | ret = count; | ||
1758 | |||
1759 | done_unlock: | ||
1760 | mutex_unlock(&ctl_mutex); | ||
1761 | kfree(seg_name); | ||
1762 | |||
1763 | return ret; | ||
1764 | } | ||
1765 | |||
1766 | static struct class_attribute class_rbd_attrs[] = { | ||
1767 | __ATTR(add, 0200, NULL, class_rbd_add), | ||
1768 | __ATTR(remove, 0200, NULL, class_rbd_remove), | ||
1769 | __ATTR(list, 0444, class_rbd_list, NULL), | ||
1770 | __ATTR(snaps_refresh, 0200, NULL, class_rbd_snaps_refresh), | ||
1771 | __ATTR(snap_create, 0200, NULL, class_rbd_snap_create), | ||
1772 | __ATTR(snaps_list, 0444, class_rbd_snaps_list, NULL), | ||
1773 | __ATTR(snap_rollback, 0200, NULL, class_rbd_rollback), | ||
1774 | __ATTR_NULL | ||
1775 | }; | ||
1776 | |||
1777 | /* | ||
1778 | * create control files in sysfs | ||
1779 | * /sys/class/rbd/... | ||
1780 | */ | ||
1781 | static int rbd_sysfs_init(void) | ||
1782 | { | ||
1783 | int ret = -ENOMEM; | ||
1784 | |||
1785 | class_rbd = kzalloc(sizeof(*class_rbd), GFP_KERNEL); | ||
1786 | if (!class_rbd) | ||
1787 | goto out; | ||
1788 | |||
1789 | class_rbd->name = DRV_NAME; | ||
1790 | class_rbd->owner = THIS_MODULE; | ||
1791 | class_rbd->class_release = class_rbd_release; | ||
1792 | class_rbd->class_attrs = class_rbd_attrs; | ||
1793 | |||
1794 | ret = class_register(class_rbd); | ||
1795 | if (ret) | ||
1796 | goto out_class; | ||
1797 | return 0; | ||
1798 | |||
1799 | out_class: | ||
1800 | kfree(class_rbd); | ||
1801 | class_rbd = NULL; | ||
1802 | pr_err(DRV_NAME ": failed to create class rbd\n"); | ||
1803 | out: | ||
1804 | return ret; | ||
1805 | } | ||
1806 | |||
1807 | static void rbd_sysfs_cleanup(void) | ||
1808 | { | ||
1809 | if (class_rbd) | ||
1810 | class_destroy(class_rbd); | ||
1811 | class_rbd = NULL; | ||
1812 | } | ||
1813 | |||
1814 | int __init rbd_init(void) | ||
1815 | { | ||
1816 | int rc; | ||
1817 | |||
1818 | rc = rbd_sysfs_init(); | ||
1819 | if (rc) | ||
1820 | return rc; | ||
1821 | spin_lock_init(&node_lock); | ||
1822 | pr_info("loaded " DRV_NAME_LONG "\n"); | ||
1823 | return 0; | ||
1824 | } | ||
1825 | |||
1826 | void __exit rbd_exit(void) | ||
1827 | { | ||
1828 | rbd_sysfs_cleanup(); | ||
1829 | } | ||
1830 | |||
1831 | module_init(rbd_init); | ||
1832 | module_exit(rbd_exit); | ||
1833 | |||
1834 | MODULE_AUTHOR("Sage Weil <sage@newdream.net>"); | ||
1835 | MODULE_AUTHOR("Yehuda Sadeh <yehuda@hq.newdream.net>"); | ||
1836 | MODULE_DESCRIPTION("rados block device"); | ||
1837 | |||
1838 | /* following authorship retained from original osdblk.c */ | ||
1839 | MODULE_AUTHOR("Jeff Garzik <jeff@garzik.org>"); | ||
1840 | |||
1841 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/block/rbd_types.h b/drivers/block/rbd_types.h new file mode 100644 index 000000000000..fc6c678aa2cb --- /dev/null +++ b/drivers/block/rbd_types.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * Ceph - scalable distributed file system | ||
3 | * | ||
4 | * Copyright (C) 2004-2010 Sage Weil <sage@newdream.net> | ||
5 | * | ||
6 | * This is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License version 2.1, as published by the Free Software | ||
9 | * Foundation. See file COPYING. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #ifndef CEPH_RBD_TYPES_H | ||
14 | #define CEPH_RBD_TYPES_H | ||
15 | |||
16 | #include <linux/types.h> | ||
17 | |||
18 | /* | ||
19 | * rbd image 'foo' consists of objects | ||
20 | * foo.rbd - image metadata | ||
21 | * foo.00000000 | ||
22 | * foo.00000001 | ||
23 | * ... - data | ||
24 | */ | ||
25 | |||
26 | #define RBD_SUFFIX ".rbd" | ||
27 | #define RBD_DIRECTORY "rbd_directory" | ||
28 | #define RBD_INFO "rbd_info" | ||
29 | |||
30 | #define RBD_DEFAULT_OBJ_ORDER 22 /* 4MB */ | ||
31 | #define RBD_MIN_OBJ_ORDER 16 | ||
32 | #define RBD_MAX_OBJ_ORDER 30 | ||
33 | |||
34 | #define RBD_MAX_OBJ_NAME_LEN 96 | ||
35 | #define RBD_MAX_SEG_NAME_LEN 128 | ||
36 | |||
37 | #define RBD_COMP_NONE 0 | ||
38 | #define RBD_CRYPT_NONE 0 | ||
39 | |||
40 | #define RBD_HEADER_TEXT "<<< Rados Block Device Image >>>\n" | ||
41 | #define RBD_HEADER_SIGNATURE "RBD" | ||
42 | #define RBD_HEADER_VERSION "001.005" | ||
43 | |||
44 | struct rbd_info { | ||
45 | __le64 max_id; | ||
46 | } __attribute__ ((packed)); | ||
47 | |||
48 | struct rbd_image_snap_ondisk { | ||
49 | __le64 id; | ||
50 | __le64 image_size; | ||
51 | } __attribute__((packed)); | ||
52 | |||
53 | struct rbd_image_header_ondisk { | ||
54 | char text[40]; | ||
55 | char block_name[24]; | ||
56 | char signature[4]; | ||
57 | char version[8]; | ||
58 | struct { | ||
59 | __u8 order; | ||
60 | __u8 crypt_type; | ||
61 | __u8 comp_type; | ||
62 | __u8 unused; | ||
63 | } __attribute__((packed)) options; | ||
64 | __le64 image_size; | ||
65 | __le64 snap_seq; | ||
66 | __le32 snap_count; | ||
67 | __le32 reserved; | ||
68 | __le64 snap_names_len; | ||
69 | struct rbd_image_snap_ondisk snaps[0]; | ||
70 | } __attribute__((packed)); | ||
71 | |||
72 | |||
73 | #endif | ||
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 2aafafca2b13..8320490226b7 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -2,7 +2,6 @@ | |||
2 | #include <linux/spinlock.h> | 2 | #include <linux/spinlock.h> |
3 | #include <linux/slab.h> | 3 | #include <linux/slab.h> |
4 | #include <linux/blkdev.h> | 4 | #include <linux/blkdev.h> |
5 | #include <linux/smp_lock.h> | ||
6 | #include <linux/hdreg.h> | 5 | #include <linux/hdreg.h> |
7 | #include <linux/virtio.h> | 6 | #include <linux/virtio.h> |
8 | #include <linux/virtio_blk.h> | 7 | #include <linux/virtio_blk.h> |
@@ -202,6 +201,7 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str) | |||
202 | struct virtio_blk *vblk = disk->private_data; | 201 | struct virtio_blk *vblk = disk->private_data; |
203 | struct request *req; | 202 | struct request *req; |
204 | struct bio *bio; | 203 | struct bio *bio; |
204 | int err; | ||
205 | 205 | ||
206 | bio = bio_map_kern(vblk->disk->queue, id_str, VIRTIO_BLK_ID_BYTES, | 206 | bio = bio_map_kern(vblk->disk->queue, id_str, VIRTIO_BLK_ID_BYTES, |
207 | GFP_KERNEL); | 207 | GFP_KERNEL); |
@@ -215,11 +215,14 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str) | |||
215 | } | 215 | } |
216 | 216 | ||
217 | req->cmd_type = REQ_TYPE_SPECIAL; | 217 | req->cmd_type = REQ_TYPE_SPECIAL; |
218 | return blk_execute_rq(vblk->disk->queue, vblk->disk, req, false); | 218 | err = blk_execute_rq(vblk->disk->queue, vblk->disk, req, false); |
219 | blk_put_request(req); | ||
220 | |||
221 | return err; | ||
219 | } | 222 | } |
220 | 223 | ||
221 | static int virtblk_locked_ioctl(struct block_device *bdev, fmode_t mode, | 224 | static int virtblk_ioctl(struct block_device *bdev, fmode_t mode, |
222 | unsigned cmd, unsigned long data) | 225 | unsigned int cmd, unsigned long data) |
223 | { | 226 | { |
224 | struct gendisk *disk = bdev->bd_disk; | 227 | struct gendisk *disk = bdev->bd_disk; |
225 | struct virtio_blk *vblk = disk->private_data; | 228 | struct virtio_blk *vblk = disk->private_data; |
@@ -234,18 +237,6 @@ static int virtblk_locked_ioctl(struct block_device *bdev, fmode_t mode, | |||
234 | (void __user *)data); | 237 | (void __user *)data); |
235 | } | 238 | } |
236 | 239 | ||
237 | static int virtblk_ioctl(struct block_device *bdev, fmode_t mode, | ||
238 | unsigned int cmd, unsigned long param) | ||
239 | { | ||
240 | int ret; | ||
241 | |||
242 | lock_kernel(); | ||
243 | ret = virtblk_locked_ioctl(bdev, mode, cmd, param); | ||
244 | unlock_kernel(); | ||
245 | |||
246 | return ret; | ||
247 | } | ||
248 | |||
249 | /* We provide getgeo only to please some old bootloader/partitioning tools */ | 240 | /* We provide getgeo only to please some old bootloader/partitioning tools */ |
250 | static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) | 241 | static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) |
251 | { | 242 | { |
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig index 4b66c69eaf57..5ddf67e76f8b 100644 --- a/drivers/char/agp/Kconfig +++ b/drivers/char/agp/Kconfig | |||
@@ -57,7 +57,7 @@ config AGP_AMD | |||
57 | 57 | ||
58 | config AGP_AMD64 | 58 | config AGP_AMD64 |
59 | tristate "AMD Opteron/Athlon64 on-CPU GART support" | 59 | tristate "AMD Opteron/Athlon64 on-CPU GART support" |
60 | depends on AGP && X86 && K8_NB | 60 | depends on AGP && X86 && AMD_NB |
61 | help | 61 | help |
62 | This option gives you AGP support for the GLX component of | 62 | This option gives you AGP support for the GLX component of |
63 | X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. | 63 | X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. |
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 70312da4c968..42396df55556 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/mmzone.h> | 15 | #include <linux/mmzone.h> |
16 | #include <asm/page.h> /* PAGE_SIZE */ | 16 | #include <asm/page.h> /* PAGE_SIZE */ |
17 | #include <asm/e820.h> | 17 | #include <asm/e820.h> |
18 | #include <asm/k8.h> | 18 | #include <asm/amd_nb.h> |
19 | #include <asm/gart.h> | 19 | #include <asm/gart.h> |
20 | #include "agp.h" | 20 | #include "agp.h" |
21 | 21 | ||
@@ -124,7 +124,7 @@ static int amd64_fetch_size(void) | |||
124 | u32 temp; | 124 | u32 temp; |
125 | struct aper_size_info_32 *values; | 125 | struct aper_size_info_32 *values; |
126 | 126 | ||
127 | dev = k8_northbridges[0]; | 127 | dev = k8_northbridges.nb_misc[0]; |
128 | if (dev==NULL) | 128 | if (dev==NULL) |
129 | return 0; | 129 | return 0; |
130 | 130 | ||
@@ -181,10 +181,14 @@ static int amd_8151_configure(void) | |||
181 | unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real); | 181 | unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real); |
182 | int i; | 182 | int i; |
183 | 183 | ||
184 | if (!k8_northbridges.gart_supported) | ||
185 | return 0; | ||
186 | |||
184 | /* Configure AGP regs in each x86-64 host bridge. */ | 187 | /* Configure AGP regs in each x86-64 host bridge. */ |
185 | for (i = 0; i < num_k8_northbridges; i++) { | 188 | for (i = 0; i < k8_northbridges.num; i++) { |
186 | agp_bridge->gart_bus_addr = | 189 | agp_bridge->gart_bus_addr = |
187 | amd64_configure(k8_northbridges[i], gatt_bus); | 190 | amd64_configure(k8_northbridges.nb_misc[i], |
191 | gatt_bus); | ||
188 | } | 192 | } |
189 | k8_flush_garts(); | 193 | k8_flush_garts(); |
190 | return 0; | 194 | return 0; |
@@ -195,11 +199,15 @@ static void amd64_cleanup(void) | |||
195 | { | 199 | { |
196 | u32 tmp; | 200 | u32 tmp; |
197 | int i; | 201 | int i; |
198 | for (i = 0; i < num_k8_northbridges; i++) { | 202 | |
199 | struct pci_dev *dev = k8_northbridges[i]; | 203 | if (!k8_northbridges.gart_supported) |
204 | return; | ||
205 | |||
206 | for (i = 0; i < k8_northbridges.num; i++) { | ||
207 | struct pci_dev *dev = k8_northbridges.nb_misc[i]; | ||
200 | /* disable gart translation */ | 208 | /* disable gart translation */ |
201 | pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &tmp); | 209 | pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &tmp); |
202 | tmp &= ~AMD64_GARTEN; | 210 | tmp &= ~GARTEN; |
203 | pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, tmp); | 211 | pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, tmp); |
204 | } | 212 | } |
205 | } | 213 | } |
@@ -313,22 +321,25 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, | |||
313 | if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order)) | 321 | if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order)) |
314 | return -1; | 322 | return -1; |
315 | 323 | ||
316 | pci_write_config_dword(nb, AMD64_GARTAPERTURECTL, order << 1); | 324 | gart_set_size_and_enable(nb, order); |
317 | pci_write_config_dword(nb, AMD64_GARTAPERTUREBASE, aper >> 25); | 325 | pci_write_config_dword(nb, AMD64_GARTAPERTUREBASE, aper >> 25); |
318 | 326 | ||
319 | return 0; | 327 | return 0; |
320 | } | 328 | } |
321 | 329 | ||
322 | static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr) | 330 | static __devinit int cache_nbs(struct pci_dev *pdev, u32 cap_ptr) |
323 | { | 331 | { |
324 | int i; | 332 | int i; |
325 | 333 | ||
326 | if (cache_k8_northbridges() < 0) | 334 | if (cache_k8_northbridges() < 0) |
327 | return -ENODEV; | 335 | return -ENODEV; |
328 | 336 | ||
337 | if (!k8_northbridges.gart_supported) | ||
338 | return -ENODEV; | ||
339 | |||
329 | i = 0; | 340 | i = 0; |
330 | for (i = 0; i < num_k8_northbridges; i++) { | 341 | for (i = 0; i < k8_northbridges.num; i++) { |
331 | struct pci_dev *dev = k8_northbridges[i]; | 342 | struct pci_dev *dev = k8_northbridges.nb_misc[i]; |
332 | if (fix_northbridge(dev, pdev, cap_ptr) < 0) { | 343 | if (fix_northbridge(dev, pdev, cap_ptr) < 0) { |
333 | dev_err(&dev->dev, "no usable aperture found\n"); | 344 | dev_err(&dev->dev, "no usable aperture found\n"); |
334 | #ifdef __x86_64__ | 345 | #ifdef __x86_64__ |
@@ -405,7 +416,8 @@ static int __devinit uli_agp_init(struct pci_dev *pdev) | |||
405 | } | 416 | } |
406 | 417 | ||
407 | /* shadow x86-64 registers into ULi registers */ | 418 | /* shadow x86-64 registers into ULi registers */ |
408 | pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &httfea); | 419 | pci_read_config_dword (k8_northbridges.nb_misc[0], AMD64_GARTAPERTUREBASE, |
420 | &httfea); | ||
409 | 421 | ||
410 | /* if x86-64 aperture base is beyond 4G, exit here */ | 422 | /* if x86-64 aperture base is beyond 4G, exit here */ |
411 | if ((httfea & 0x7fff) >> (32 - 25)) { | 423 | if ((httfea & 0x7fff) >> (32 - 25)) { |
@@ -472,7 +484,8 @@ static int nforce3_agp_init(struct pci_dev *pdev) | |||
472 | pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp); | 484 | pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp); |
473 | 485 | ||
474 | /* shadow x86-64 registers into NVIDIA registers */ | 486 | /* shadow x86-64 registers into NVIDIA registers */ |
475 | pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &apbase); | 487 | pci_read_config_dword (k8_northbridges.nb_misc[0], AMD64_GARTAPERTUREBASE, |
488 | &apbase); | ||
476 | 489 | ||
477 | /* if x86-64 aperture base is beyond 4G, exit here */ | 490 | /* if x86-64 aperture base is beyond 4G, exit here */ |
478 | if ( (apbase & 0x7fff) >> (32 - 25) ) { | 491 | if ( (apbase & 0x7fff) >> (32 - 25) ) { |
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index d2abf5143983..64255cef8a7d 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c | |||
@@ -984,7 +984,9 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge) | |||
984 | 984 | ||
985 | bridge->driver->cache_flush(); | 985 | bridge->driver->cache_flush(); |
986 | #ifdef CONFIG_X86 | 986 | #ifdef CONFIG_X86 |
987 | set_memory_uc((unsigned long)table, 1 << page_order); | 987 | if (set_memory_uc((unsigned long)table, 1 << page_order)) |
988 | printk(KERN_WARNING "Could not set GATT table memory to UC!"); | ||
989 | |||
988 | bridge->gatt_table = (void *)table; | 990 | bridge->gatt_table = (void *)table; |
989 | #else | 991 | #else |
990 | bridge->gatt_table = ioremap_nocache(virt_to_phys(table), | 992 | bridge->gatt_table = ioremap_nocache(virt_to_phys(table), |
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 05ad4a17a28f..7c4133582dba 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -47,6 +47,16 @@ enum tpm_duration { | |||
47 | #define TPM_MAX_PROTECTED_ORDINAL 12 | 47 | #define TPM_MAX_PROTECTED_ORDINAL 12 |
48 | #define TPM_PROTECTED_ORDINAL_MASK 0xFF | 48 | #define TPM_PROTECTED_ORDINAL_MASK 0xFF |
49 | 49 | ||
50 | /* | ||
51 | * Bug workaround - some TPM's don't flush the most | ||
52 | * recently changed pcr on suspend, so force the flush | ||
53 | * with an extend to the selected _unused_ non-volatile pcr. | ||
54 | */ | ||
55 | static int tpm_suspend_pcr; | ||
56 | module_param_named(suspend_pcr, tpm_suspend_pcr, uint, 0644); | ||
57 | MODULE_PARM_DESC(suspend_pcr, | ||
58 | "PCR to use for dummy writes to faciltate flush on suspend."); | ||
59 | |||
50 | static LIST_HEAD(tpm_chip_list); | 60 | static LIST_HEAD(tpm_chip_list); |
51 | static DEFINE_SPINLOCK(driver_lock); | 61 | static DEFINE_SPINLOCK(driver_lock); |
52 | static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES); | 62 | static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES); |
@@ -1077,18 +1087,6 @@ static struct tpm_input_header savestate_header = { | |||
1077 | .ordinal = TPM_ORD_SAVESTATE | 1087 | .ordinal = TPM_ORD_SAVESTATE |
1078 | }; | 1088 | }; |
1079 | 1089 | ||
1080 | /* Bug workaround - some TPM's don't flush the most | ||
1081 | * recently changed pcr on suspend, so force the flush | ||
1082 | * with an extend to the selected _unused_ non-volatile pcr. | ||
1083 | */ | ||
1084 | static int tpm_suspend_pcr; | ||
1085 | static int __init tpm_suspend_setup(char *str) | ||
1086 | { | ||
1087 | get_option(&str, &tpm_suspend_pcr); | ||
1088 | return 1; | ||
1089 | } | ||
1090 | __setup("tpm_suspend_pcr=", tpm_suspend_setup); | ||
1091 | |||
1092 | /* | 1090 | /* |
1093 | * We are about to suspend. Save the TPM state | 1091 | * We are about to suspend. Save the TPM state |
1094 | * so that it can be restored. | 1092 | * so that it can be restored. |
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index c810481a5bc2..6c1b676643a9 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -48,6 +48,9 @@ struct ports_driver_data { | |||
48 | /* Used for exporting per-port information to debugfs */ | 48 | /* Used for exporting per-port information to debugfs */ |
49 | struct dentry *debugfs_dir; | 49 | struct dentry *debugfs_dir; |
50 | 50 | ||
51 | /* List of all the devices we're handling */ | ||
52 | struct list_head portdevs; | ||
53 | |||
51 | /* Number of devices this driver is handling */ | 54 | /* Number of devices this driver is handling */ |
52 | unsigned int index; | 55 | unsigned int index; |
53 | 56 | ||
@@ -108,6 +111,9 @@ struct port_buffer { | |||
108 | * ports for that device (vdev->priv). | 111 | * ports for that device (vdev->priv). |
109 | */ | 112 | */ |
110 | struct ports_device { | 113 | struct ports_device { |
114 | /* Next portdev in the list, head is in the pdrvdata struct */ | ||
115 | struct list_head list; | ||
116 | |||
111 | /* | 117 | /* |
112 | * Workqueue handlers where we process deferred work after | 118 | * Workqueue handlers where we process deferred work after |
113 | * notification | 119 | * notification |
@@ -178,15 +184,21 @@ struct port { | |||
178 | struct console cons; | 184 | struct console cons; |
179 | 185 | ||
180 | /* Each port associates with a separate char device */ | 186 | /* Each port associates with a separate char device */ |
181 | struct cdev cdev; | 187 | struct cdev *cdev; |
182 | struct device *dev; | 188 | struct device *dev; |
183 | 189 | ||
190 | /* Reference-counting to handle port hot-unplugs and file operations */ | ||
191 | struct kref kref; | ||
192 | |||
184 | /* A waitqueue for poll() or blocking read operations */ | 193 | /* A waitqueue for poll() or blocking read operations */ |
185 | wait_queue_head_t waitqueue; | 194 | wait_queue_head_t waitqueue; |
186 | 195 | ||
187 | /* The 'name' of the port that we expose via sysfs properties */ | 196 | /* The 'name' of the port that we expose via sysfs properties */ |
188 | char *name; | 197 | char *name; |
189 | 198 | ||
199 | /* We can notify apps of host connect / disconnect events via SIGIO */ | ||
200 | struct fasync_struct *async_queue; | ||
201 | |||
190 | /* The 'id' to identify the port with the Host */ | 202 | /* The 'id' to identify the port with the Host */ |
191 | u32 id; | 203 | u32 id; |
192 | 204 | ||
@@ -221,6 +233,41 @@ out: | |||
221 | return port; | 233 | return port; |
222 | } | 234 | } |
223 | 235 | ||
236 | static struct port *find_port_by_devt_in_portdev(struct ports_device *portdev, | ||
237 | dev_t dev) | ||
238 | { | ||
239 | struct port *port; | ||
240 | unsigned long flags; | ||
241 | |||
242 | spin_lock_irqsave(&portdev->ports_lock, flags); | ||
243 | list_for_each_entry(port, &portdev->ports, list) | ||
244 | if (port->cdev->dev == dev) | ||
245 | goto out; | ||
246 | port = NULL; | ||
247 | out: | ||
248 | spin_unlock_irqrestore(&portdev->ports_lock, flags); | ||
249 | |||
250 | return port; | ||
251 | } | ||
252 | |||
253 | static struct port *find_port_by_devt(dev_t dev) | ||
254 | { | ||
255 | struct ports_device *portdev; | ||
256 | struct port *port; | ||
257 | unsigned long flags; | ||
258 | |||
259 | spin_lock_irqsave(&pdrvdata_lock, flags); | ||
260 | list_for_each_entry(portdev, &pdrvdata.portdevs, list) { | ||
261 | port = find_port_by_devt_in_portdev(portdev, dev); | ||
262 | if (port) | ||
263 | goto out; | ||
264 | } | ||
265 | port = NULL; | ||
266 | out: | ||
267 | spin_unlock_irqrestore(&pdrvdata_lock, flags); | ||
268 | return port; | ||
269 | } | ||
270 | |||
224 | static struct port *find_port_by_id(struct ports_device *portdev, u32 id) | 271 | static struct port *find_port_by_id(struct ports_device *portdev, u32 id) |
225 | { | 272 | { |
226 | struct port *port; | 273 | struct port *port; |
@@ -410,7 +457,10 @@ static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id, | |||
410 | static ssize_t send_control_msg(struct port *port, unsigned int event, | 457 | static ssize_t send_control_msg(struct port *port, unsigned int event, |
411 | unsigned int value) | 458 | unsigned int value) |
412 | { | 459 | { |
413 | return __send_control_msg(port->portdev, port->id, event, value); | 460 | /* Did the port get unplugged before userspace closed it? */ |
461 | if (port->portdev) | ||
462 | return __send_control_msg(port->portdev, port->id, event, value); | ||
463 | return 0; | ||
414 | } | 464 | } |
415 | 465 | ||
416 | /* Callers must take the port->outvq_lock */ | 466 | /* Callers must take the port->outvq_lock */ |
@@ -459,9 +509,12 @@ static ssize_t send_buf(struct port *port, void *in_buf, size_t in_count, | |||
459 | 509 | ||
460 | /* | 510 | /* |
461 | * Wait till the host acknowledges it pushed out the data we | 511 | * Wait till the host acknowledges it pushed out the data we |
462 | * sent. This is done for ports in blocking mode or for data | 512 | * sent. This is done for data from the hvc_console; the tty |
463 | * from the hvc_console; the tty operations are performed with | 513 | * operations are performed with spinlocks held so we can't |
464 | * spinlocks held so we can't sleep here. | 514 | * sleep here. An alternative would be to copy the data to a |
515 | * buffer and relax the spinning requirement. The downside is | ||
516 | * we need to kmalloc a GFP_ATOMIC buffer each time the | ||
517 | * console driver writes something out. | ||
465 | */ | 518 | */ |
466 | while (!virtqueue_get_buf(out_vq, &len)) | 519 | while (!virtqueue_get_buf(out_vq, &len)) |
467 | cpu_relax(); | 520 | cpu_relax(); |
@@ -522,6 +575,10 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count, | |||
522 | /* The condition that must be true for polling to end */ | 575 | /* The condition that must be true for polling to end */ |
523 | static bool will_read_block(struct port *port) | 576 | static bool will_read_block(struct port *port) |
524 | { | 577 | { |
578 | if (!port->guest_connected) { | ||
579 | /* Port got hot-unplugged. Let's exit. */ | ||
580 | return false; | ||
581 | } | ||
525 | return !port_has_data(port) && port->host_connected; | 582 | return !port_has_data(port) && port->host_connected; |
526 | } | 583 | } |
527 | 584 | ||
@@ -572,6 +629,9 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf, | |||
572 | if (ret < 0) | 629 | if (ret < 0) |
573 | return ret; | 630 | return ret; |
574 | } | 631 | } |
632 | /* Port got hot-unplugged. */ | ||
633 | if (!port->guest_connected) | ||
634 | return -ENODEV; | ||
575 | /* | 635 | /* |
576 | * We could've received a disconnection message while we were | 636 | * We could've received a disconnection message while we were |
577 | * waiting for more data. | 637 | * waiting for more data. |
@@ -613,6 +673,9 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf, | |||
613 | if (ret < 0) | 673 | if (ret < 0) |
614 | return ret; | 674 | return ret; |
615 | } | 675 | } |
676 | /* Port got hot-unplugged. */ | ||
677 | if (!port->guest_connected) | ||
678 | return -ENODEV; | ||
616 | 679 | ||
617 | count = min((size_t)(32 * 1024), count); | 680 | count = min((size_t)(32 * 1024), count); |
618 | 681 | ||
@@ -626,6 +689,14 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf, | |||
626 | goto free_buf; | 689 | goto free_buf; |
627 | } | 690 | } |
628 | 691 | ||
692 | /* | ||
693 | * We now ask send_buf() to not spin for generic ports -- we | ||
694 | * can re-use the same code path that non-blocking file | ||
695 | * descriptors take for blocking file descriptors since the | ||
696 | * wait is already done and we're certain the write will go | ||
697 | * through to the host. | ||
698 | */ | ||
699 | nonblock = true; | ||
629 | ret = send_buf(port, buf, count, nonblock); | 700 | ret = send_buf(port, buf, count, nonblock); |
630 | 701 | ||
631 | if (nonblock && ret > 0) | 702 | if (nonblock && ret > 0) |
@@ -645,6 +716,10 @@ static unsigned int port_fops_poll(struct file *filp, poll_table *wait) | |||
645 | port = filp->private_data; | 716 | port = filp->private_data; |
646 | poll_wait(filp, &port->waitqueue, wait); | 717 | poll_wait(filp, &port->waitqueue, wait); |
647 | 718 | ||
719 | if (!port->guest_connected) { | ||
720 | /* Port got unplugged */ | ||
721 | return POLLHUP; | ||
722 | } | ||
648 | ret = 0; | 723 | ret = 0; |
649 | if (!will_read_block(port)) | 724 | if (!will_read_block(port)) |
650 | ret |= POLLIN | POLLRDNORM; | 725 | ret |= POLLIN | POLLRDNORM; |
@@ -656,6 +731,8 @@ static unsigned int port_fops_poll(struct file *filp, poll_table *wait) | |||
656 | return ret; | 731 | return ret; |
657 | } | 732 | } |
658 | 733 | ||
734 | static void remove_port(struct kref *kref); | ||
735 | |||
659 | static int port_fops_release(struct inode *inode, struct file *filp) | 736 | static int port_fops_release(struct inode *inode, struct file *filp) |
660 | { | 737 | { |
661 | struct port *port; | 738 | struct port *port; |
@@ -676,6 +753,16 @@ static int port_fops_release(struct inode *inode, struct file *filp) | |||
676 | reclaim_consumed_buffers(port); | 753 | reclaim_consumed_buffers(port); |
677 | spin_unlock_irq(&port->outvq_lock); | 754 | spin_unlock_irq(&port->outvq_lock); |
678 | 755 | ||
756 | /* | ||
757 | * Locks aren't necessary here as a port can't be opened after | ||
758 | * unplug, and if a port isn't unplugged, a kref would already | ||
759 | * exist for the port. Plus, taking ports_lock here would | ||
760 | * create a dependency on other locks taken by functions | ||
761 | * inside remove_port if we're the last holder of the port, | ||
762 | * creating many problems. | ||
763 | */ | ||
764 | kref_put(&port->kref, remove_port); | ||
765 | |||
679 | return 0; | 766 | return 0; |
680 | } | 767 | } |
681 | 768 | ||
@@ -683,22 +770,31 @@ static int port_fops_open(struct inode *inode, struct file *filp) | |||
683 | { | 770 | { |
684 | struct cdev *cdev = inode->i_cdev; | 771 | struct cdev *cdev = inode->i_cdev; |
685 | struct port *port; | 772 | struct port *port; |
773 | int ret; | ||
686 | 774 | ||
687 | port = container_of(cdev, struct port, cdev); | 775 | port = find_port_by_devt(cdev->dev); |
688 | filp->private_data = port; | 776 | filp->private_data = port; |
689 | 777 | ||
778 | /* Prevent against a port getting hot-unplugged at the same time */ | ||
779 | spin_lock_irq(&port->portdev->ports_lock); | ||
780 | kref_get(&port->kref); | ||
781 | spin_unlock_irq(&port->portdev->ports_lock); | ||
782 | |||
690 | /* | 783 | /* |
691 | * Don't allow opening of console port devices -- that's done | 784 | * Don't allow opening of console port devices -- that's done |
692 | * via /dev/hvc | 785 | * via /dev/hvc |
693 | */ | 786 | */ |
694 | if (is_console_port(port)) | 787 | if (is_console_port(port)) { |
695 | return -ENXIO; | 788 | ret = -ENXIO; |
789 | goto out; | ||
790 | } | ||
696 | 791 | ||
697 | /* Allow only one process to open a particular port at a time */ | 792 | /* Allow only one process to open a particular port at a time */ |
698 | spin_lock_irq(&port->inbuf_lock); | 793 | spin_lock_irq(&port->inbuf_lock); |
699 | if (port->guest_connected) { | 794 | if (port->guest_connected) { |
700 | spin_unlock_irq(&port->inbuf_lock); | 795 | spin_unlock_irq(&port->inbuf_lock); |
701 | return -EMFILE; | 796 | ret = -EMFILE; |
797 | goto out; | ||
702 | } | 798 | } |
703 | 799 | ||
704 | port->guest_connected = true; | 800 | port->guest_connected = true; |
@@ -713,10 +809,23 @@ static int port_fops_open(struct inode *inode, struct file *filp) | |||
713 | reclaim_consumed_buffers(port); | 809 | reclaim_consumed_buffers(port); |
714 | spin_unlock_irq(&port->outvq_lock); | 810 | spin_unlock_irq(&port->outvq_lock); |
715 | 811 | ||
812 | nonseekable_open(inode, filp); | ||
813 | |||
716 | /* Notify host of port being opened */ | 814 | /* Notify host of port being opened */ |
717 | send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1); | 815 | send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1); |
718 | 816 | ||
719 | return 0; | 817 | return 0; |
818 | out: | ||
819 | kref_put(&port->kref, remove_port); | ||
820 | return ret; | ||
821 | } | ||
822 | |||
823 | static int port_fops_fasync(int fd, struct file *filp, int mode) | ||
824 | { | ||
825 | struct port *port; | ||
826 | |||
827 | port = filp->private_data; | ||
828 | return fasync_helper(fd, filp, mode, &port->async_queue); | ||
720 | } | 829 | } |
721 | 830 | ||
722 | /* | 831 | /* |
@@ -732,6 +841,8 @@ static const struct file_operations port_fops = { | |||
732 | .write = port_fops_write, | 841 | .write = port_fops_write, |
733 | .poll = port_fops_poll, | 842 | .poll = port_fops_poll, |
734 | .release = port_fops_release, | 843 | .release = port_fops_release, |
844 | .fasync = port_fops_fasync, | ||
845 | .llseek = no_llseek, | ||
735 | }; | 846 | }; |
736 | 847 | ||
737 | /* | 848 | /* |
@@ -990,6 +1101,12 @@ static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock) | |||
990 | return nr_added_bufs; | 1101 | return nr_added_bufs; |
991 | } | 1102 | } |
992 | 1103 | ||
1104 | static void send_sigio_to_port(struct port *port) | ||
1105 | { | ||
1106 | if (port->async_queue && port->guest_connected) | ||
1107 | kill_fasync(&port->async_queue, SIGIO, POLL_OUT); | ||
1108 | } | ||
1109 | |||
993 | static int add_port(struct ports_device *portdev, u32 id) | 1110 | static int add_port(struct ports_device *portdev, u32 id) |
994 | { | 1111 | { |
995 | char debugfs_name[16]; | 1112 | char debugfs_name[16]; |
@@ -1004,6 +1121,7 @@ static int add_port(struct ports_device *portdev, u32 id) | |||
1004 | err = -ENOMEM; | 1121 | err = -ENOMEM; |
1005 | goto fail; | 1122 | goto fail; |
1006 | } | 1123 | } |
1124 | kref_init(&port->kref); | ||
1007 | 1125 | ||
1008 | port->portdev = portdev; | 1126 | port->portdev = portdev; |
1009 | port->id = id; | 1127 | port->id = id; |
@@ -1011,6 +1129,7 @@ static int add_port(struct ports_device *portdev, u32 id) | |||
1011 | port->name = NULL; | 1129 | port->name = NULL; |
1012 | port->inbuf = NULL; | 1130 | port->inbuf = NULL; |
1013 | port->cons.hvc = NULL; | 1131 | port->cons.hvc = NULL; |
1132 | port->async_queue = NULL; | ||
1014 | 1133 | ||
1015 | port->cons.ws.ws_row = port->cons.ws.ws_col = 0; | 1134 | port->cons.ws.ws_row = port->cons.ws.ws_col = 0; |
1016 | 1135 | ||
@@ -1021,14 +1140,20 @@ static int add_port(struct ports_device *portdev, u32 id) | |||
1021 | port->in_vq = portdev->in_vqs[port->id]; | 1140 | port->in_vq = portdev->in_vqs[port->id]; |
1022 | port->out_vq = portdev->out_vqs[port->id]; | 1141 | port->out_vq = portdev->out_vqs[port->id]; |
1023 | 1142 | ||
1024 | cdev_init(&port->cdev, &port_fops); | 1143 | port->cdev = cdev_alloc(); |
1144 | if (!port->cdev) { | ||
1145 | dev_err(&port->portdev->vdev->dev, "Error allocating cdev\n"); | ||
1146 | err = -ENOMEM; | ||
1147 | goto free_port; | ||
1148 | } | ||
1149 | port->cdev->ops = &port_fops; | ||
1025 | 1150 | ||
1026 | devt = MKDEV(portdev->chr_major, id); | 1151 | devt = MKDEV(portdev->chr_major, id); |
1027 | err = cdev_add(&port->cdev, devt, 1); | 1152 | err = cdev_add(port->cdev, devt, 1); |
1028 | if (err < 0) { | 1153 | if (err < 0) { |
1029 | dev_err(&port->portdev->vdev->dev, | 1154 | dev_err(&port->portdev->vdev->dev, |
1030 | "Error %d adding cdev for port %u\n", err, id); | 1155 | "Error %d adding cdev for port %u\n", err, id); |
1031 | goto free_port; | 1156 | goto free_cdev; |
1032 | } | 1157 | } |
1033 | port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev, | 1158 | port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev, |
1034 | devt, port, "vport%up%u", | 1159 | devt, port, "vport%up%u", |
@@ -1093,7 +1218,7 @@ free_inbufs: | |||
1093 | free_device: | 1218 | free_device: |
1094 | device_destroy(pdrvdata.class, port->dev->devt); | 1219 | device_destroy(pdrvdata.class, port->dev->devt); |
1095 | free_cdev: | 1220 | free_cdev: |
1096 | cdev_del(&port->cdev); | 1221 | cdev_del(port->cdev); |
1097 | free_port: | 1222 | free_port: |
1098 | kfree(port); | 1223 | kfree(port); |
1099 | fail: | 1224 | fail: |
@@ -1102,21 +1227,45 @@ fail: | |||
1102 | return err; | 1227 | return err; |
1103 | } | 1228 | } |
1104 | 1229 | ||
1105 | /* Remove all port-specific data. */ | 1230 | /* No users remain, remove all port-specific data. */ |
1106 | static int remove_port(struct port *port) | 1231 | static void remove_port(struct kref *kref) |
1232 | { | ||
1233 | struct port *port; | ||
1234 | |||
1235 | port = container_of(kref, struct port, kref); | ||
1236 | |||
1237 | sysfs_remove_group(&port->dev->kobj, &port_attribute_group); | ||
1238 | device_destroy(pdrvdata.class, port->dev->devt); | ||
1239 | cdev_del(port->cdev); | ||
1240 | |||
1241 | kfree(port->name); | ||
1242 | |||
1243 | debugfs_remove(port->debugfs_file); | ||
1244 | |||
1245 | kfree(port); | ||
1246 | } | ||
1247 | |||
1248 | /* | ||
1249 | * Port got unplugged. Remove port from portdev's list and drop the | ||
1250 | * kref reference. If no userspace has this port opened, it will | ||
1251 | * result in immediate removal the port. | ||
1252 | */ | ||
1253 | static void unplug_port(struct port *port) | ||
1107 | { | 1254 | { |
1108 | struct port_buffer *buf; | 1255 | struct port_buffer *buf; |
1109 | 1256 | ||
1257 | spin_lock_irq(&port->portdev->ports_lock); | ||
1258 | list_del(&port->list); | ||
1259 | spin_unlock_irq(&port->portdev->ports_lock); | ||
1260 | |||
1110 | if (port->guest_connected) { | 1261 | if (port->guest_connected) { |
1111 | port->guest_connected = false; | 1262 | port->guest_connected = false; |
1112 | port->host_connected = false; | 1263 | port->host_connected = false; |
1113 | wake_up_interruptible(&port->waitqueue); | 1264 | wake_up_interruptible(&port->waitqueue); |
1114 | send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 0); | ||
1115 | } | ||
1116 | 1265 | ||
1117 | spin_lock_irq(&port->portdev->ports_lock); | 1266 | /* Let the app know the port is going down. */ |
1118 | list_del(&port->list); | 1267 | send_sigio_to_port(port); |
1119 | spin_unlock_irq(&port->portdev->ports_lock); | 1268 | } |
1120 | 1269 | ||
1121 | if (is_console_port(port)) { | 1270 | if (is_console_port(port)) { |
1122 | spin_lock_irq(&pdrvdata_lock); | 1271 | spin_lock_irq(&pdrvdata_lock); |
@@ -1135,9 +1284,6 @@ static int remove_port(struct port *port) | |||
1135 | hvc_remove(port->cons.hvc); | 1284 | hvc_remove(port->cons.hvc); |
1136 | #endif | 1285 | #endif |
1137 | } | 1286 | } |
1138 | sysfs_remove_group(&port->dev->kobj, &port_attribute_group); | ||
1139 | device_destroy(pdrvdata.class, port->dev->devt); | ||
1140 | cdev_del(&port->cdev); | ||
1141 | 1287 | ||
1142 | /* Remove unused data this port might have received. */ | 1288 | /* Remove unused data this port might have received. */ |
1143 | discard_port_data(port); | 1289 | discard_port_data(port); |
@@ -1148,12 +1294,19 @@ static int remove_port(struct port *port) | |||
1148 | while ((buf = virtqueue_detach_unused_buf(port->in_vq))) | 1294 | while ((buf = virtqueue_detach_unused_buf(port->in_vq))) |
1149 | free_buf(buf); | 1295 | free_buf(buf); |
1150 | 1296 | ||
1151 | kfree(port->name); | 1297 | /* |
1152 | 1298 | * We should just assume the device itself has gone off -- | |
1153 | debugfs_remove(port->debugfs_file); | 1299 | * else a close on an open port later will try to send out a |
1300 | * control message. | ||
1301 | */ | ||
1302 | port->portdev = NULL; | ||
1154 | 1303 | ||
1155 | kfree(port); | 1304 | /* |
1156 | return 0; | 1305 | * Locks around here are not necessary - a port can't be |
1306 | * opened after we removed the port struct from ports_list | ||
1307 | * above. | ||
1308 | */ | ||
1309 | kref_put(&port->kref, remove_port); | ||
1157 | } | 1310 | } |
1158 | 1311 | ||
1159 | /* Any private messages that the Host and Guest want to share */ | 1312 | /* Any private messages that the Host and Guest want to share */ |
@@ -1192,7 +1345,7 @@ static void handle_control_message(struct ports_device *portdev, | |||
1192 | add_port(portdev, cpkt->id); | 1345 | add_port(portdev, cpkt->id); |
1193 | break; | 1346 | break; |
1194 | case VIRTIO_CONSOLE_PORT_REMOVE: | 1347 | case VIRTIO_CONSOLE_PORT_REMOVE: |
1195 | remove_port(port); | 1348 | unplug_port(port); |
1196 | break; | 1349 | break; |
1197 | case VIRTIO_CONSOLE_CONSOLE_PORT: | 1350 | case VIRTIO_CONSOLE_CONSOLE_PORT: |
1198 | if (!cpkt->value) | 1351 | if (!cpkt->value) |
@@ -1234,6 +1387,12 @@ static void handle_control_message(struct ports_device *portdev, | |||
1234 | spin_lock_irq(&port->outvq_lock); | 1387 | spin_lock_irq(&port->outvq_lock); |
1235 | reclaim_consumed_buffers(port); | 1388 | reclaim_consumed_buffers(port); |
1236 | spin_unlock_irq(&port->outvq_lock); | 1389 | spin_unlock_irq(&port->outvq_lock); |
1390 | |||
1391 | /* | ||
1392 | * If the guest is connected, it'll be interested in | ||
1393 | * knowing the host connection state changed. | ||
1394 | */ | ||
1395 | send_sigio_to_port(port); | ||
1237 | break; | 1396 | break; |
1238 | case VIRTIO_CONSOLE_PORT_NAME: | 1397 | case VIRTIO_CONSOLE_PORT_NAME: |
1239 | /* | 1398 | /* |
@@ -1330,6 +1489,9 @@ static void in_intr(struct virtqueue *vq) | |||
1330 | 1489 | ||
1331 | wake_up_interruptible(&port->waitqueue); | 1490 | wake_up_interruptible(&port->waitqueue); |
1332 | 1491 | ||
1492 | /* Send a SIGIO indicating new data in case the process asked for it */ | ||
1493 | send_sigio_to_port(port); | ||
1494 | |||
1333 | if (is_console_port(port) && hvc_poll(port->cons.hvc)) | 1495 | if (is_console_port(port) && hvc_poll(port->cons.hvc)) |
1334 | hvc_kick(); | 1496 | hvc_kick(); |
1335 | } | 1497 | } |
@@ -1566,6 +1728,10 @@ static int __devinit virtcons_probe(struct virtio_device *vdev) | |||
1566 | add_port(portdev, 0); | 1728 | add_port(portdev, 0); |
1567 | } | 1729 | } |
1568 | 1730 | ||
1731 | spin_lock_irq(&pdrvdata_lock); | ||
1732 | list_add_tail(&portdev->list, &pdrvdata.portdevs); | ||
1733 | spin_unlock_irq(&pdrvdata_lock); | ||
1734 | |||
1569 | __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, | 1735 | __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, |
1570 | VIRTIO_CONSOLE_DEVICE_READY, 1); | 1736 | VIRTIO_CONSOLE_DEVICE_READY, 1); |
1571 | return 0; | 1737 | return 0; |
@@ -1589,23 +1755,41 @@ static void virtcons_remove(struct virtio_device *vdev) | |||
1589 | { | 1755 | { |
1590 | struct ports_device *portdev; | 1756 | struct ports_device *portdev; |
1591 | struct port *port, *port2; | 1757 | struct port *port, *port2; |
1592 | struct port_buffer *buf; | ||
1593 | unsigned int len; | ||
1594 | 1758 | ||
1595 | portdev = vdev->priv; | 1759 | portdev = vdev->priv; |
1596 | 1760 | ||
1761 | spin_lock_irq(&pdrvdata_lock); | ||
1762 | list_del(&portdev->list); | ||
1763 | spin_unlock_irq(&pdrvdata_lock); | ||
1764 | |||
1765 | /* Disable interrupts for vqs */ | ||
1766 | vdev->config->reset(vdev); | ||
1767 | /* Finish up work that's lined up */ | ||
1597 | cancel_work_sync(&portdev->control_work); | 1768 | cancel_work_sync(&portdev->control_work); |
1598 | 1769 | ||
1599 | list_for_each_entry_safe(port, port2, &portdev->ports, list) | 1770 | list_for_each_entry_safe(port, port2, &portdev->ports, list) |
1600 | remove_port(port); | 1771 | unplug_port(port); |
1601 | 1772 | ||
1602 | unregister_chrdev(portdev->chr_major, "virtio-portsdev"); | 1773 | unregister_chrdev(portdev->chr_major, "virtio-portsdev"); |
1603 | 1774 | ||
1604 | while ((buf = virtqueue_get_buf(portdev->c_ivq, &len))) | 1775 | /* |
1605 | free_buf(buf); | 1776 | * When yanking out a device, we immediately lose the |
1777 | * (device-side) queues. So there's no point in keeping the | ||
1778 | * guest side around till we drop our final reference. This | ||
1779 | * also means that any ports which are in an open state will | ||
1780 | * have to just stop using the port, as the vqs are going | ||
1781 | * away. | ||
1782 | */ | ||
1783 | if (use_multiport(portdev)) { | ||
1784 | struct port_buffer *buf; | ||
1785 | unsigned int len; | ||
1606 | 1786 | ||
1607 | while ((buf = virtqueue_detach_unused_buf(portdev->c_ivq))) | 1787 | while ((buf = virtqueue_get_buf(portdev->c_ivq, &len))) |
1608 | free_buf(buf); | 1788 | free_buf(buf); |
1789 | |||
1790 | while ((buf = virtqueue_detach_unused_buf(portdev->c_ivq))) | ||
1791 | free_buf(buf); | ||
1792 | } | ||
1609 | 1793 | ||
1610 | vdev->config->del_vqs(vdev); | 1794 | vdev->config->del_vqs(vdev); |
1611 | kfree(portdev->in_vqs); | 1795 | kfree(portdev->in_vqs); |
@@ -1652,6 +1836,7 @@ static int __init init(void) | |||
1652 | PTR_ERR(pdrvdata.debugfs_dir)); | 1836 | PTR_ERR(pdrvdata.debugfs_dir)); |
1653 | } | 1837 | } |
1654 | INIT_LIST_HEAD(&pdrvdata.consoles); | 1838 | INIT_LIST_HEAD(&pdrvdata.consoles); |
1839 | INIT_LIST_HEAD(&pdrvdata.portdevs); | ||
1655 | 1840 | ||
1656 | return register_virtio_driver(&virtio_console); | 1841 | return register_virtio_driver(&virtio_console); |
1657 | } | 1842 | } |
diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c index 216f9d383b5b..effd140fc042 100644 --- a/drivers/dma/ioat/dma_v2.c +++ b/drivers/dma/ioat/dma_v2.c | |||
@@ -879,7 +879,7 @@ int __devinit ioat2_dma_probe(struct ioatdma_device *device, int dca) | |||
879 | dma->device_issue_pending = ioat2_issue_pending; | 879 | dma->device_issue_pending = ioat2_issue_pending; |
880 | dma->device_alloc_chan_resources = ioat2_alloc_chan_resources; | 880 | dma->device_alloc_chan_resources = ioat2_alloc_chan_resources; |
881 | dma->device_free_chan_resources = ioat2_free_chan_resources; | 881 | dma->device_free_chan_resources = ioat2_free_chan_resources; |
882 | dma->device_tx_status = ioat_tx_status; | 882 | dma->device_tx_status = ioat_dma_tx_status; |
883 | 883 | ||
884 | err = ioat_probe(device); | 884 | err = ioat_probe(device); |
885 | if (err) | 885 | if (err) |
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index 70bb350de996..9dbb28b9559f 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig | |||
@@ -39,7 +39,7 @@ config EDAC_DEBUG | |||
39 | there're four debug levels (x=0,1,2,3 from low to high). | 39 | there're four debug levels (x=0,1,2,3 from low to high). |
40 | Usually you should select 'N'. | 40 | Usually you should select 'N'. |
41 | 41 | ||
42 | config EDAC_DECODE_MCE | 42 | config EDAC_DECODE_MCE |
43 | tristate "Decode MCEs in human-readable form (only on AMD for now)" | 43 | tristate "Decode MCEs in human-readable form (only on AMD for now)" |
44 | depends on CPU_SUP_AMD && X86_MCE | 44 | depends on CPU_SUP_AMD && X86_MCE |
45 | default y | 45 | default y |
@@ -51,6 +51,16 @@ config EDAC_DEBUG | |||
51 | which occur really early upon boot, before the module infrastructure | 51 | which occur really early upon boot, before the module infrastructure |
52 | has been initialized. | 52 | has been initialized. |
53 | 53 | ||
54 | config EDAC_MCE_INJ | ||
55 | tristate "Simple MCE injection interface over /sysfs" | ||
56 | depends on EDAC_DECODE_MCE | ||
57 | default n | ||
58 | help | ||
59 | This is a simple interface to inject MCEs over /sysfs and test | ||
60 | the MCE decoding code in EDAC. | ||
61 | |||
62 | This is currently AMD-only. | ||
63 | |||
54 | config EDAC_MM_EDAC | 64 | config EDAC_MM_EDAC |
55 | tristate "Main Memory EDAC (Error Detection And Correction) reporting" | 65 | tristate "Main Memory EDAC (Error Detection And Correction) reporting" |
56 | help | 66 | help |
@@ -66,13 +76,13 @@ config EDAC_MCE | |||
66 | 76 | ||
67 | config EDAC_AMD64 | 77 | config EDAC_AMD64 |
68 | tristate "AMD64 (Opteron, Athlon64) K8, F10h, F11h" | 78 | tristate "AMD64 (Opteron, Athlon64) K8, F10h, F11h" |
69 | depends on EDAC_MM_EDAC && K8_NB && X86_64 && PCI && EDAC_DECODE_MCE | 79 | depends on EDAC_MM_EDAC && AMD_NB && X86_64 && PCI && EDAC_DECODE_MCE |
70 | help | 80 | help |
71 | Support for error detection and correction on the AMD 64 | 81 | Support for error detection and correction on the AMD 64 |
72 | Families of Memory Controllers (K8, F10h and F11h) | 82 | Families of Memory Controllers (K8, F10h and F11h) |
73 | 83 | ||
74 | config EDAC_AMD64_ERROR_INJECTION | 84 | config EDAC_AMD64_ERROR_INJECTION |
75 | bool "Sysfs Error Injection facilities" | 85 | bool "Sysfs HW Error injection facilities" |
76 | depends on EDAC_AMD64 | 86 | depends on EDAC_AMD64 |
77 | help | 87 | help |
78 | Recent Opterons (Family 10h and later) provide for Memory Error | 88 | Recent Opterons (Family 10h and later) provide for Memory Error |
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile index ca6b1bb24ccc..32c7bc93c525 100644 --- a/drivers/edac/Makefile +++ b/drivers/edac/Makefile | |||
@@ -17,6 +17,9 @@ ifdef CONFIG_PCI | |||
17 | edac_core-objs += edac_pci.o edac_pci_sysfs.o | 17 | edac_core-objs += edac_pci.o edac_pci_sysfs.o |
18 | endif | 18 | endif |
19 | 19 | ||
20 | obj-$(CONFIG_EDAC_MCE_INJ) += mce_amd_inj.o | ||
21 | |||
22 | edac_mce_amd-objs := mce_amd.o | ||
20 | obj-$(CONFIG_EDAC_DECODE_MCE) += edac_mce_amd.o | 23 | obj-$(CONFIG_EDAC_DECODE_MCE) += edac_mce_amd.o |
21 | 24 | ||
22 | obj-$(CONFIG_EDAC_AMD76X) += amd76x_edac.o | 25 | obj-$(CONFIG_EDAC_AMD76X) += amd76x_edac.o |
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index e7d5d6b5dcf6..8521401bbd75 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c | |||
@@ -1,5 +1,5 @@ | |||
1 | #include "amd64_edac.h" | 1 | #include "amd64_edac.h" |
2 | #include <asm/k8.h> | 2 | #include <asm/amd_nb.h> |
3 | 3 | ||
4 | static struct edac_pci_ctl_info *amd64_ctl_pci; | 4 | static struct edac_pci_ctl_info *amd64_ctl_pci; |
5 | 5 | ||
@@ -2073,11 +2073,18 @@ static inline void __amd64_decode_bus_error(struct mem_ctl_info *mci, | |||
2073 | amd64_handle_ue(mci, info); | 2073 | amd64_handle_ue(mci, info); |
2074 | } | 2074 | } |
2075 | 2075 | ||
2076 | void amd64_decode_bus_error(int node_id, struct err_regs *regs) | 2076 | void amd64_decode_bus_error(int node_id, struct mce *m, u32 nbcfg) |
2077 | { | 2077 | { |
2078 | struct mem_ctl_info *mci = mci_lookup[node_id]; | 2078 | struct mem_ctl_info *mci = mci_lookup[node_id]; |
2079 | struct err_regs regs; | ||
2079 | 2080 | ||
2080 | __amd64_decode_bus_error(mci, regs); | 2081 | regs.nbsl = (u32) m->status; |
2082 | regs.nbsh = (u32)(m->status >> 32); | ||
2083 | regs.nbeal = (u32) m->addr; | ||
2084 | regs.nbeah = (u32)(m->addr >> 32); | ||
2085 | regs.nbcfg = nbcfg; | ||
2086 | |||
2087 | __amd64_decode_bus_error(mci, ®s); | ||
2081 | 2088 | ||
2082 | /* | 2089 | /* |
2083 | * Check the UE bit of the NB status high register, if set generate some | 2090 | * Check the UE bit of the NB status high register, if set generate some |
@@ -2086,7 +2093,7 @@ void amd64_decode_bus_error(int node_id, struct err_regs *regs) | |||
2086 | * | 2093 | * |
2087 | * FIXME: this should go somewhere else, if at all. | 2094 | * FIXME: this should go somewhere else, if at all. |
2088 | */ | 2095 | */ |
2089 | if (regs->nbsh & K8_NBSH_UC_ERR && !report_gart_errors) | 2096 | if (regs.nbsh & K8_NBSH_UC_ERR && !report_gart_errors) |
2090 | edac_mc_handle_ue_no_info(mci, "UE bit is set"); | 2097 | edac_mc_handle_ue_no_info(mci, "UE bit is set"); |
2091 | 2098 | ||
2092 | } | 2099 | } |
@@ -2927,7 +2934,7 @@ static int __init amd64_edac_init(void) | |||
2927 | * to finish initialization of the MC instances. | 2934 | * to finish initialization of the MC instances. |
2928 | */ | 2935 | */ |
2929 | err = -ENODEV; | 2936 | err = -ENODEV; |
2930 | for (nb = 0; nb < num_k8_northbridges; nb++) { | 2937 | for (nb = 0; nb < k8_northbridges.num; nb++) { |
2931 | if (!pvt_lookup[nb]) | 2938 | if (!pvt_lookup[nb]) |
2932 | continue; | 2939 | continue; |
2933 | 2940 | ||
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h index 613b9381e71a..044aee4f944d 100644 --- a/drivers/edac/amd64_edac.h +++ b/drivers/edac/amd64_edac.h | |||
@@ -72,7 +72,7 @@ | |||
72 | #include <linux/edac.h> | 72 | #include <linux/edac.h> |
73 | #include <asm/msr.h> | 73 | #include <asm/msr.h> |
74 | #include "edac_core.h" | 74 | #include "edac_core.h" |
75 | #include "edac_mce_amd.h" | 75 | #include "mce_amd.h" |
76 | 76 | ||
77 | #define amd64_printk(level, fmt, arg...) \ | 77 | #define amd64_printk(level, fmt, arg...) \ |
78 | edac_printk(level, "amd64", fmt, ##arg) | 78 | edac_printk(level, "amd64", fmt, ##arg) |
@@ -482,11 +482,10 @@ extern const char *rrrr_msgs[16]; | |||
482 | extern const char *to_msgs[2]; | 482 | extern const char *to_msgs[2]; |
483 | extern const char *pp_msgs[4]; | 483 | extern const char *pp_msgs[4]; |
484 | extern const char *ii_msgs[4]; | 484 | extern const char *ii_msgs[4]; |
485 | extern const char *ext_msgs[32]; | ||
486 | extern const char *htlink_msgs[8]; | 485 | extern const char *htlink_msgs[8]; |
487 | 486 | ||
488 | #ifdef CONFIG_EDAC_DEBUG | 487 | #ifdef CONFIG_EDAC_DEBUG |
489 | #define NUM_DBG_ATTRS 9 | 488 | #define NUM_DBG_ATTRS 5 |
490 | #else | 489 | #else |
491 | #define NUM_DBG_ATTRS 0 | 490 | #define NUM_DBG_ATTRS 0 |
492 | #endif | 491 | #endif |
diff --git a/drivers/edac/amd64_edac_dbg.c b/drivers/edac/amd64_edac_dbg.c index 59cf2cf6e11e..e3562288f4ce 100644 --- a/drivers/edac/amd64_edac_dbg.c +++ b/drivers/edac/amd64_edac_dbg.c | |||
@@ -1,167 +1,16 @@ | |||
1 | #include "amd64_edac.h" | 1 | #include "amd64_edac.h" |
2 | 2 | ||
3 | /* | 3 | #define EDAC_DCT_ATTR_SHOW(reg) \ |
4 | * accept a hex value and store it into the virtual error register file, field: | 4 | static ssize_t amd64_##reg##_show(struct mem_ctl_info *mci, char *data) \ |
5 | * nbeal and nbeah. Assume virtual error values have already been set for: NBSL, | 5 | { \ |
6 | * NBSH and NBCFG. Then proceed to map the error values to a MC, CSROW and | 6 | struct amd64_pvt *pvt = mci->pvt_info; \ |
7 | * CHANNEL | 7 | return sprintf(data, "0x%016llx\n", (u64)pvt->reg); \ |
8 | */ | ||
9 | static ssize_t amd64_nbea_store(struct mem_ctl_info *mci, const char *data, | ||
10 | size_t count) | ||
11 | { | ||
12 | struct amd64_pvt *pvt = mci->pvt_info; | ||
13 | unsigned long long value; | ||
14 | int ret = 0; | ||
15 | |||
16 | ret = strict_strtoull(data, 16, &value); | ||
17 | if (ret != -EINVAL) { | ||
18 | debugf0("received NBEA= 0x%llx\n", value); | ||
19 | |||
20 | /* place the value into the virtual error packet */ | ||
21 | pvt->ctl_error_info.nbeal = (u32) value; | ||
22 | value >>= 32; | ||
23 | pvt->ctl_error_info.nbeah = (u32) value; | ||
24 | |||
25 | /* Process the Mapping request */ | ||
26 | /* TODO: Add race prevention */ | ||
27 | amd_decode_nb_mce(pvt->mc_node_id, &pvt->ctl_error_info, 1); | ||
28 | |||
29 | return count; | ||
30 | } | ||
31 | return ret; | ||
32 | } | ||
33 | |||
34 | /* display back what the last NBEA (MCA NB Address (MC4_ADDR)) was written */ | ||
35 | static ssize_t amd64_nbea_show(struct mem_ctl_info *mci, char *data) | ||
36 | { | ||
37 | struct amd64_pvt *pvt = mci->pvt_info; | ||
38 | u64 value; | ||
39 | |||
40 | value = pvt->ctl_error_info.nbeah; | ||
41 | value <<= 32; | ||
42 | value |= pvt->ctl_error_info.nbeal; | ||
43 | |||
44 | return sprintf(data, "%llx\n", value); | ||
45 | } | ||
46 | |||
47 | /* store the NBSL (MCA NB Status Low (MC4_STATUS)) value user desires */ | ||
48 | static ssize_t amd64_nbsl_store(struct mem_ctl_info *mci, const char *data, | ||
49 | size_t count) | ||
50 | { | ||
51 | struct amd64_pvt *pvt = mci->pvt_info; | ||
52 | unsigned long value; | ||
53 | int ret = 0; | ||
54 | |||
55 | ret = strict_strtoul(data, 16, &value); | ||
56 | if (ret != -EINVAL) { | ||
57 | debugf0("received NBSL= 0x%lx\n", value); | ||
58 | |||
59 | pvt->ctl_error_info.nbsl = (u32) value; | ||
60 | |||
61 | return count; | ||
62 | } | ||
63 | return ret; | ||
64 | } | ||
65 | |||
66 | /* display back what the last NBSL value written */ | ||
67 | static ssize_t amd64_nbsl_show(struct mem_ctl_info *mci, char *data) | ||
68 | { | ||
69 | struct amd64_pvt *pvt = mci->pvt_info; | ||
70 | u32 value; | ||
71 | |||
72 | value = pvt->ctl_error_info.nbsl; | ||
73 | |||
74 | return sprintf(data, "%x\n", value); | ||
75 | } | ||
76 | |||
77 | /* store the NBSH (MCA NB Status High) value user desires */ | ||
78 | static ssize_t amd64_nbsh_store(struct mem_ctl_info *mci, const char *data, | ||
79 | size_t count) | ||
80 | { | ||
81 | struct amd64_pvt *pvt = mci->pvt_info; | ||
82 | unsigned long value; | ||
83 | int ret = 0; | ||
84 | |||
85 | ret = strict_strtoul(data, 16, &value); | ||
86 | if (ret != -EINVAL) { | ||
87 | debugf0("received NBSH= 0x%lx\n", value); | ||
88 | |||
89 | pvt->ctl_error_info.nbsh = (u32) value; | ||
90 | |||
91 | return count; | ||
92 | } | ||
93 | return ret; | ||
94 | } | ||
95 | |||
96 | /* display back what the last NBSH value written */ | ||
97 | static ssize_t amd64_nbsh_show(struct mem_ctl_info *mci, char *data) | ||
98 | { | ||
99 | struct amd64_pvt *pvt = mci->pvt_info; | ||
100 | u32 value; | ||
101 | |||
102 | value = pvt->ctl_error_info.nbsh; | ||
103 | |||
104 | return sprintf(data, "%x\n", value); | ||
105 | } | 8 | } |
106 | 9 | ||
107 | /* accept and store the NBCFG (MCA NB Configuration) value user desires */ | 10 | EDAC_DCT_ATTR_SHOW(dhar); |
108 | static ssize_t amd64_nbcfg_store(struct mem_ctl_info *mci, | 11 | EDAC_DCT_ATTR_SHOW(dbam0); |
109 | const char *data, size_t count) | 12 | EDAC_DCT_ATTR_SHOW(top_mem); |
110 | { | 13 | EDAC_DCT_ATTR_SHOW(top_mem2); |
111 | struct amd64_pvt *pvt = mci->pvt_info; | ||
112 | unsigned long value; | ||
113 | int ret = 0; | ||
114 | |||
115 | ret = strict_strtoul(data, 16, &value); | ||
116 | if (ret != -EINVAL) { | ||
117 | debugf0("received NBCFG= 0x%lx\n", value); | ||
118 | |||
119 | pvt->ctl_error_info.nbcfg = (u32) value; | ||
120 | |||
121 | return count; | ||
122 | } | ||
123 | return ret; | ||
124 | } | ||
125 | |||
126 | /* various show routines for the controls of a MCI */ | ||
127 | static ssize_t amd64_nbcfg_show(struct mem_ctl_info *mci, char *data) | ||
128 | { | ||
129 | struct amd64_pvt *pvt = mci->pvt_info; | ||
130 | |||
131 | return sprintf(data, "%x\n", pvt->ctl_error_info.nbcfg); | ||
132 | } | ||
133 | |||
134 | |||
135 | static ssize_t amd64_dhar_show(struct mem_ctl_info *mci, char *data) | ||
136 | { | ||
137 | struct amd64_pvt *pvt = mci->pvt_info; | ||
138 | |||
139 | return sprintf(data, "%x\n", pvt->dhar); | ||
140 | } | ||
141 | |||
142 | |||
143 | static ssize_t amd64_dbam_show(struct mem_ctl_info *mci, char *data) | ||
144 | { | ||
145 | struct amd64_pvt *pvt = mci->pvt_info; | ||
146 | |||
147 | return sprintf(data, "%x\n", pvt->dbam0); | ||
148 | } | ||
149 | |||
150 | |||
151 | static ssize_t amd64_topmem_show(struct mem_ctl_info *mci, char *data) | ||
152 | { | ||
153 | struct amd64_pvt *pvt = mci->pvt_info; | ||
154 | |||
155 | return sprintf(data, "%llx\n", pvt->top_mem); | ||
156 | } | ||
157 | |||
158 | |||
159 | static ssize_t amd64_topmem2_show(struct mem_ctl_info *mci, char *data) | ||
160 | { | ||
161 | struct amd64_pvt *pvt = mci->pvt_info; | ||
162 | |||
163 | return sprintf(data, "%llx\n", pvt->top_mem2); | ||
164 | } | ||
165 | 14 | ||
166 | static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data) | 15 | static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data) |
167 | { | 16 | { |
@@ -182,38 +31,6 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = { | |||
182 | 31 | ||
183 | { | 32 | { |
184 | .attr = { | 33 | .attr = { |
185 | .name = "nbea_ctl", | ||
186 | .mode = (S_IRUGO | S_IWUSR) | ||
187 | }, | ||
188 | .show = amd64_nbea_show, | ||
189 | .store = amd64_nbea_store, | ||
190 | }, | ||
191 | { | ||
192 | .attr = { | ||
193 | .name = "nbsl_ctl", | ||
194 | .mode = (S_IRUGO | S_IWUSR) | ||
195 | }, | ||
196 | .show = amd64_nbsl_show, | ||
197 | .store = amd64_nbsl_store, | ||
198 | }, | ||
199 | { | ||
200 | .attr = { | ||
201 | .name = "nbsh_ctl", | ||
202 | .mode = (S_IRUGO | S_IWUSR) | ||
203 | }, | ||
204 | .show = amd64_nbsh_show, | ||
205 | .store = amd64_nbsh_store, | ||
206 | }, | ||
207 | { | ||
208 | .attr = { | ||
209 | .name = "nbcfg_ctl", | ||
210 | .mode = (S_IRUGO | S_IWUSR) | ||
211 | }, | ||
212 | .show = amd64_nbcfg_show, | ||
213 | .store = amd64_nbcfg_store, | ||
214 | }, | ||
215 | { | ||
216 | .attr = { | ||
217 | .name = "dhar", | 34 | .name = "dhar", |
218 | .mode = (S_IRUGO) | 35 | .mode = (S_IRUGO) |
219 | }, | 36 | }, |
@@ -225,7 +42,7 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = { | |||
225 | .name = "dbam", | 42 | .name = "dbam", |
226 | .mode = (S_IRUGO) | 43 | .mode = (S_IRUGO) |
227 | }, | 44 | }, |
228 | .show = amd64_dbam_show, | 45 | .show = amd64_dbam0_show, |
229 | .store = NULL, | 46 | .store = NULL, |
230 | }, | 47 | }, |
231 | { | 48 | { |
@@ -233,7 +50,7 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = { | |||
233 | .name = "topmem", | 50 | .name = "topmem", |
234 | .mode = (S_IRUGO) | 51 | .mode = (S_IRUGO) |
235 | }, | 52 | }, |
236 | .show = amd64_topmem_show, | 53 | .show = amd64_top_mem_show, |
237 | .store = NULL, | 54 | .store = NULL, |
238 | }, | 55 | }, |
239 | { | 56 | { |
@@ -241,7 +58,7 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = { | |||
241 | .name = "topmem2", | 58 | .name = "topmem2", |
242 | .mode = (S_IRUGO) | 59 | .mode = (S_IRUGO) |
243 | }, | 60 | }, |
244 | .show = amd64_topmem2_show, | 61 | .show = amd64_top_mem2_show, |
245 | .store = NULL, | 62 | .store = NULL, |
246 | }, | 63 | }, |
247 | { | 64 | { |
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index 070968178a24..2941dca91aae 100644 --- a/drivers/edac/edac_device_sysfs.c +++ b/drivers/edac/edac_device_sysfs.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/ctype.h> | 13 | #include <linux/ctype.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/edac.h> | ||
16 | 17 | ||
17 | #include "edac_core.h" | 18 | #include "edac_core.h" |
18 | #include "edac_module.h" | 19 | #include "edac_module.h" |
@@ -235,7 +236,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) | |||
235 | debugf1("%s()\n", __func__); | 236 | debugf1("%s()\n", __func__); |
236 | 237 | ||
237 | /* get the /sys/devices/system/edac reference */ | 238 | /* get the /sys/devices/system/edac reference */ |
238 | edac_class = edac_get_edac_class(); | 239 | edac_class = edac_get_sysfs_class(); |
239 | if (edac_class == NULL) { | 240 | if (edac_class == NULL) { |
240 | debugf1("%s() no edac_class error\n", __func__); | 241 | debugf1("%s() no edac_class error\n", __func__); |
241 | err = -ENODEV; | 242 | err = -ENODEV; |
@@ -255,7 +256,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) | |||
255 | 256 | ||
256 | if (!try_module_get(edac_dev->owner)) { | 257 | if (!try_module_get(edac_dev->owner)) { |
257 | err = -ENODEV; | 258 | err = -ENODEV; |
258 | goto err_out; | 259 | goto err_mod_get; |
259 | } | 260 | } |
260 | 261 | ||
261 | /* register */ | 262 | /* register */ |
@@ -282,6 +283,9 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) | |||
282 | err_kobj_reg: | 283 | err_kobj_reg: |
283 | module_put(edac_dev->owner); | 284 | module_put(edac_dev->owner); |
284 | 285 | ||
286 | err_mod_get: | ||
287 | edac_put_sysfs_class(); | ||
288 | |||
285 | err_out: | 289 | err_out: |
286 | return err; | 290 | return err; |
287 | } | 291 | } |
@@ -290,12 +294,11 @@ err_out: | |||
290 | * edac_device_unregister_sysfs_main_kobj: | 294 | * edac_device_unregister_sysfs_main_kobj: |
291 | * the '..../edac/<name>' kobject | 295 | * the '..../edac/<name>' kobject |
292 | */ | 296 | */ |
293 | void edac_device_unregister_sysfs_main_kobj( | 297 | void edac_device_unregister_sysfs_main_kobj(struct edac_device_ctl_info *dev) |
294 | struct edac_device_ctl_info *edac_dev) | ||
295 | { | 298 | { |
296 | debugf0("%s()\n", __func__); | 299 | debugf0("%s()\n", __func__); |
297 | debugf4("%s() name of kobject is: %s\n", | 300 | debugf4("%s() name of kobject is: %s\n", |
298 | __func__, kobject_name(&edac_dev->kobj)); | 301 | __func__, kobject_name(&dev->kobj)); |
299 | 302 | ||
300 | /* | 303 | /* |
301 | * Unregister the edac device's kobject and | 304 | * Unregister the edac device's kobject and |
@@ -304,7 +307,8 @@ void edac_device_unregister_sysfs_main_kobj( | |||
304 | * a) module_put() this module | 307 | * a) module_put() this module |
305 | * b) 'kfree' the memory | 308 | * b) 'kfree' the memory |
306 | */ | 309 | */ |
307 | kobject_put(&edac_dev->kobj); | 310 | kobject_put(&dev->kobj); |
311 | edac_put_sysfs_class(); | ||
308 | } | 312 | } |
309 | 313 | ||
310 | /* edac_dev -> instance information */ | 314 | /* edac_dev -> instance information */ |
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 8aad94d10c0c..a4135860149b 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/ctype.h> | 12 | #include <linux/ctype.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/edac.h> | ||
14 | #include <linux/bug.h> | 15 | #include <linux/bug.h> |
15 | 16 | ||
16 | #include "edac_core.h" | 17 | #include "edac_core.h" |
@@ -1011,13 +1012,13 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) | |||
1011 | */ | 1012 | */ |
1012 | int edac_sysfs_setup_mc_kset(void) | 1013 | int edac_sysfs_setup_mc_kset(void) |
1013 | { | 1014 | { |
1014 | int err = 0; | 1015 | int err = -EINVAL; |
1015 | struct sysdev_class *edac_class; | 1016 | struct sysdev_class *edac_class; |
1016 | 1017 | ||
1017 | debugf1("%s()\n", __func__); | 1018 | debugf1("%s()\n", __func__); |
1018 | 1019 | ||
1019 | /* get the /sys/devices/system/edac class reference */ | 1020 | /* get the /sys/devices/system/edac class reference */ |
1020 | edac_class = edac_get_edac_class(); | 1021 | edac_class = edac_get_sysfs_class(); |
1021 | if (edac_class == NULL) { | 1022 | if (edac_class == NULL) { |
1022 | debugf1("%s() no edac_class error=%d\n", __func__, err); | 1023 | debugf1("%s() no edac_class error=%d\n", __func__, err); |
1023 | goto fail_out; | 1024 | goto fail_out; |
@@ -1028,15 +1029,16 @@ int edac_sysfs_setup_mc_kset(void) | |||
1028 | if (!mc_kset) { | 1029 | if (!mc_kset) { |
1029 | err = -ENOMEM; | 1030 | err = -ENOMEM; |
1030 | debugf1("%s() Failed to register '.../edac/mc'\n", __func__); | 1031 | debugf1("%s() Failed to register '.../edac/mc'\n", __func__); |
1031 | goto fail_out; | 1032 | goto fail_kset; |
1032 | } | 1033 | } |
1033 | 1034 | ||
1034 | debugf1("%s() Registered '.../edac/mc' kobject\n", __func__); | 1035 | debugf1("%s() Registered '.../edac/mc' kobject\n", __func__); |
1035 | 1036 | ||
1036 | return 0; | 1037 | return 0; |
1037 | 1038 | ||
1039 | fail_kset: | ||
1040 | edac_put_sysfs_class(); | ||
1038 | 1041 | ||
1039 | /* error unwind stack */ | ||
1040 | fail_out: | 1042 | fail_out: |
1041 | return err; | 1043 | return err; |
1042 | } | 1044 | } |
@@ -1049,5 +1051,6 @@ fail_out: | |||
1049 | void edac_sysfs_teardown_mc_kset(void) | 1051 | void edac_sysfs_teardown_mc_kset(void) |
1050 | { | 1052 | { |
1051 | kset_unregister(mc_kset); | 1053 | kset_unregister(mc_kset); |
1054 | edac_put_sysfs_class(); | ||
1052 | } | 1055 | } |
1053 | 1056 | ||
diff --git a/drivers/edac/edac_mce_amd.c b/drivers/edac/edac_mce_amd.c deleted file mode 100644 index 9014df6f605d..000000000000 --- a/drivers/edac/edac_mce_amd.c +++ /dev/null | |||
@@ -1,452 +0,0 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include "edac_mce_amd.h" | ||
3 | |||
4 | static bool report_gart_errors; | ||
5 | static void (*nb_bus_decoder)(int node_id, struct err_regs *regs); | ||
6 | |||
7 | void amd_report_gart_errors(bool v) | ||
8 | { | ||
9 | report_gart_errors = v; | ||
10 | } | ||
11 | EXPORT_SYMBOL_GPL(amd_report_gart_errors); | ||
12 | |||
13 | void amd_register_ecc_decoder(void (*f)(int, struct err_regs *)) | ||
14 | { | ||
15 | nb_bus_decoder = f; | ||
16 | } | ||
17 | EXPORT_SYMBOL_GPL(amd_register_ecc_decoder); | ||
18 | |||
19 | void amd_unregister_ecc_decoder(void (*f)(int, struct err_regs *)) | ||
20 | { | ||
21 | if (nb_bus_decoder) { | ||
22 | WARN_ON(nb_bus_decoder != f); | ||
23 | |||
24 | nb_bus_decoder = NULL; | ||
25 | } | ||
26 | } | ||
27 | EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder); | ||
28 | |||
29 | /* | ||
30 | * string representation for the different MCA reported error types, see F3x48 | ||
31 | * or MSR0000_0411. | ||
32 | */ | ||
33 | const char *tt_msgs[] = { /* transaction type */ | ||
34 | "instruction", | ||
35 | "data", | ||
36 | "generic", | ||
37 | "reserved" | ||
38 | }; | ||
39 | EXPORT_SYMBOL_GPL(tt_msgs); | ||
40 | |||
41 | const char *ll_msgs[] = { /* cache level */ | ||
42 | "L0", | ||
43 | "L1", | ||
44 | "L2", | ||
45 | "L3/generic" | ||
46 | }; | ||
47 | EXPORT_SYMBOL_GPL(ll_msgs); | ||
48 | |||
49 | const char *rrrr_msgs[] = { | ||
50 | "generic", | ||
51 | "generic read", | ||
52 | "generic write", | ||
53 | "data read", | ||
54 | "data write", | ||
55 | "inst fetch", | ||
56 | "prefetch", | ||
57 | "evict", | ||
58 | "snoop", | ||
59 | "reserved RRRR= 9", | ||
60 | "reserved RRRR= 10", | ||
61 | "reserved RRRR= 11", | ||
62 | "reserved RRRR= 12", | ||
63 | "reserved RRRR= 13", | ||
64 | "reserved RRRR= 14", | ||
65 | "reserved RRRR= 15" | ||
66 | }; | ||
67 | EXPORT_SYMBOL_GPL(rrrr_msgs); | ||
68 | |||
69 | const char *pp_msgs[] = { /* participating processor */ | ||
70 | "local node originated (SRC)", | ||
71 | "local node responded to request (RES)", | ||
72 | "local node observed as 3rd party (OBS)", | ||
73 | "generic" | ||
74 | }; | ||
75 | EXPORT_SYMBOL_GPL(pp_msgs); | ||
76 | |||
77 | const char *to_msgs[] = { | ||
78 | "no timeout", | ||
79 | "timed out" | ||
80 | }; | ||
81 | EXPORT_SYMBOL_GPL(to_msgs); | ||
82 | |||
83 | const char *ii_msgs[] = { /* memory or i/o */ | ||
84 | "mem access", | ||
85 | "reserved", | ||
86 | "i/o access", | ||
87 | "generic" | ||
88 | }; | ||
89 | EXPORT_SYMBOL_GPL(ii_msgs); | ||
90 | |||
91 | /* | ||
92 | * Map the 4 or 5 (family-specific) bits of Extended Error code to the | ||
93 | * string table. | ||
94 | */ | ||
95 | const char *ext_msgs[] = { | ||
96 | "K8 ECC error", /* 0_0000b */ | ||
97 | "CRC error on link", /* 0_0001b */ | ||
98 | "Sync error packets on link", /* 0_0010b */ | ||
99 | "Master Abort during link operation", /* 0_0011b */ | ||
100 | "Target Abort during link operation", /* 0_0100b */ | ||
101 | "Invalid GART PTE entry during table walk", /* 0_0101b */ | ||
102 | "Unsupported atomic RMW command received", /* 0_0110b */ | ||
103 | "WDT error: NB transaction timeout", /* 0_0111b */ | ||
104 | "ECC/ChipKill ECC error", /* 0_1000b */ | ||
105 | "SVM DEV Error", /* 0_1001b */ | ||
106 | "Link Data error", /* 0_1010b */ | ||
107 | "Link/L3/Probe Filter Protocol error", /* 0_1011b */ | ||
108 | "NB Internal Arrays Parity error", /* 0_1100b */ | ||
109 | "DRAM Address/Control Parity error", /* 0_1101b */ | ||
110 | "Link Transmission error", /* 0_1110b */ | ||
111 | "GART/DEV Table Walk Data error" /* 0_1111b */ | ||
112 | "Res 0x100 error", /* 1_0000b */ | ||
113 | "Res 0x101 error", /* 1_0001b */ | ||
114 | "Res 0x102 error", /* 1_0010b */ | ||
115 | "Res 0x103 error", /* 1_0011b */ | ||
116 | "Res 0x104 error", /* 1_0100b */ | ||
117 | "Res 0x105 error", /* 1_0101b */ | ||
118 | "Res 0x106 error", /* 1_0110b */ | ||
119 | "Res 0x107 error", /* 1_0111b */ | ||
120 | "Res 0x108 error", /* 1_1000b */ | ||
121 | "Res 0x109 error", /* 1_1001b */ | ||
122 | "Res 0x10A error", /* 1_1010b */ | ||
123 | "Res 0x10B error", /* 1_1011b */ | ||
124 | "ECC error in L3 Cache Data", /* 1_1100b */ | ||
125 | "L3 Cache Tag error", /* 1_1101b */ | ||
126 | "L3 Cache LRU Parity error", /* 1_1110b */ | ||
127 | "Probe Filter error" /* 1_1111b */ | ||
128 | }; | ||
129 | EXPORT_SYMBOL_GPL(ext_msgs); | ||
130 | |||
131 | static void amd_decode_dc_mce(u64 mc0_status) | ||
132 | { | ||
133 | u32 ec = mc0_status & 0xffff; | ||
134 | u32 xec = (mc0_status >> 16) & 0xf; | ||
135 | |||
136 | pr_emerg("Data Cache Error"); | ||
137 | |||
138 | if (xec == 1 && TLB_ERROR(ec)) | ||
139 | pr_cont(": %s TLB multimatch.\n", LL_MSG(ec)); | ||
140 | else if (xec == 0) { | ||
141 | if (mc0_status & (1ULL << 40)) | ||
142 | pr_cont(" during Data Scrub.\n"); | ||
143 | else if (TLB_ERROR(ec)) | ||
144 | pr_cont(": %s TLB parity error.\n", LL_MSG(ec)); | ||
145 | else if (MEM_ERROR(ec)) { | ||
146 | u8 ll = ec & 0x3; | ||
147 | u8 tt = (ec >> 2) & 0x3; | ||
148 | u8 rrrr = (ec >> 4) & 0xf; | ||
149 | |||
150 | /* see F10h BKDG (31116), Table 92. */ | ||
151 | if (ll == 0x1) { | ||
152 | if (tt != 0x1) | ||
153 | goto wrong_dc_mce; | ||
154 | |||
155 | pr_cont(": Data/Tag %s error.\n", RRRR_MSG(ec)); | ||
156 | |||
157 | } else if (ll == 0x2 && rrrr == 0x3) | ||
158 | pr_cont(" during L1 linefill from L2.\n"); | ||
159 | else | ||
160 | goto wrong_dc_mce; | ||
161 | } else if (BUS_ERROR(ec) && boot_cpu_data.x86 == 0xf) | ||
162 | pr_cont(" during system linefill.\n"); | ||
163 | else | ||
164 | goto wrong_dc_mce; | ||
165 | } else | ||
166 | goto wrong_dc_mce; | ||
167 | |||
168 | return; | ||
169 | |||
170 | wrong_dc_mce: | ||
171 | pr_warning("Corrupted DC MCE info?\n"); | ||
172 | } | ||
173 | |||
174 | static void amd_decode_ic_mce(u64 mc1_status) | ||
175 | { | ||
176 | u32 ec = mc1_status & 0xffff; | ||
177 | u32 xec = (mc1_status >> 16) & 0xf; | ||
178 | |||
179 | pr_emerg("Instruction Cache Error"); | ||
180 | |||
181 | if (xec == 1 && TLB_ERROR(ec)) | ||
182 | pr_cont(": %s TLB multimatch.\n", LL_MSG(ec)); | ||
183 | else if (xec == 0) { | ||
184 | if (TLB_ERROR(ec)) | ||
185 | pr_cont(": %s TLB Parity error.\n", LL_MSG(ec)); | ||
186 | else if (BUS_ERROR(ec)) { | ||
187 | if (boot_cpu_data.x86 == 0xf && | ||
188 | (mc1_status & (1ULL << 58))) | ||
189 | pr_cont(" during system linefill.\n"); | ||
190 | else | ||
191 | pr_cont(" during attempted NB data read.\n"); | ||
192 | } else if (MEM_ERROR(ec)) { | ||
193 | u8 ll = ec & 0x3; | ||
194 | u8 rrrr = (ec >> 4) & 0xf; | ||
195 | |||
196 | if (ll == 0x2) | ||
197 | pr_cont(" during a linefill from L2.\n"); | ||
198 | else if (ll == 0x1) { | ||
199 | |||
200 | switch (rrrr) { | ||
201 | case 0x5: | ||
202 | pr_cont(": Parity error during " | ||
203 | "data load.\n"); | ||
204 | break; | ||
205 | |||
206 | case 0x7: | ||
207 | pr_cont(": Copyback Parity/Victim" | ||
208 | " error.\n"); | ||
209 | break; | ||
210 | |||
211 | case 0x8: | ||
212 | pr_cont(": Tag Snoop error.\n"); | ||
213 | break; | ||
214 | |||
215 | default: | ||
216 | goto wrong_ic_mce; | ||
217 | break; | ||
218 | } | ||
219 | } | ||
220 | } else | ||
221 | goto wrong_ic_mce; | ||
222 | } else | ||
223 | goto wrong_ic_mce; | ||
224 | |||
225 | return; | ||
226 | |||
227 | wrong_ic_mce: | ||
228 | pr_warning("Corrupted IC MCE info?\n"); | ||
229 | } | ||
230 | |||
231 | static void amd_decode_bu_mce(u64 mc2_status) | ||
232 | { | ||
233 | u32 ec = mc2_status & 0xffff; | ||
234 | u32 xec = (mc2_status >> 16) & 0xf; | ||
235 | |||
236 | pr_emerg("Bus Unit Error"); | ||
237 | |||
238 | if (xec == 0x1) | ||
239 | pr_cont(" in the write data buffers.\n"); | ||
240 | else if (xec == 0x3) | ||
241 | pr_cont(" in the victim data buffers.\n"); | ||
242 | else if (xec == 0x2 && MEM_ERROR(ec)) | ||
243 | pr_cont(": %s error in the L2 cache tags.\n", RRRR_MSG(ec)); | ||
244 | else if (xec == 0x0) { | ||
245 | if (TLB_ERROR(ec)) | ||
246 | pr_cont(": %s error in a Page Descriptor Cache or " | ||
247 | "Guest TLB.\n", TT_MSG(ec)); | ||
248 | else if (BUS_ERROR(ec)) | ||
249 | pr_cont(": %s/ECC error in data read from NB: %s.\n", | ||
250 | RRRR_MSG(ec), PP_MSG(ec)); | ||
251 | else if (MEM_ERROR(ec)) { | ||
252 | u8 rrrr = (ec >> 4) & 0xf; | ||
253 | |||
254 | if (rrrr >= 0x7) | ||
255 | pr_cont(": %s error during data copyback.\n", | ||
256 | RRRR_MSG(ec)); | ||
257 | else if (rrrr <= 0x1) | ||
258 | pr_cont(": %s parity/ECC error during data " | ||
259 | "access from L2.\n", RRRR_MSG(ec)); | ||
260 | else | ||
261 | goto wrong_bu_mce; | ||
262 | } else | ||
263 | goto wrong_bu_mce; | ||
264 | } else | ||
265 | goto wrong_bu_mce; | ||
266 | |||
267 | return; | ||
268 | |||
269 | wrong_bu_mce: | ||
270 | pr_warning("Corrupted BU MCE info?\n"); | ||
271 | } | ||
272 | |||
273 | static void amd_decode_ls_mce(u64 mc3_status) | ||
274 | { | ||
275 | u32 ec = mc3_status & 0xffff; | ||
276 | u32 xec = (mc3_status >> 16) & 0xf; | ||
277 | |||
278 | pr_emerg("Load Store Error"); | ||
279 | |||
280 | if (xec == 0x0) { | ||
281 | u8 rrrr = (ec >> 4) & 0xf; | ||
282 | |||
283 | if (!BUS_ERROR(ec) || (rrrr != 0x3 && rrrr != 0x4)) | ||
284 | goto wrong_ls_mce; | ||
285 | |||
286 | pr_cont(" during %s.\n", RRRR_MSG(ec)); | ||
287 | } | ||
288 | return; | ||
289 | |||
290 | wrong_ls_mce: | ||
291 | pr_warning("Corrupted LS MCE info?\n"); | ||
292 | } | ||
293 | |||
294 | void amd_decode_nb_mce(int node_id, struct err_regs *regs, int handle_errors) | ||
295 | { | ||
296 | u32 ec = ERROR_CODE(regs->nbsl); | ||
297 | |||
298 | if (!handle_errors) | ||
299 | return; | ||
300 | |||
301 | /* | ||
302 | * GART TLB error reporting is disabled by default. Bail out early. | ||
303 | */ | ||
304 | if (TLB_ERROR(ec) && !report_gart_errors) | ||
305 | return; | ||
306 | |||
307 | pr_emerg("Northbridge Error, node %d", node_id); | ||
308 | |||
309 | /* | ||
310 | * F10h, revD can disable ErrCpu[3:0] so check that first and also the | ||
311 | * value encoding has changed so interpret those differently | ||
312 | */ | ||
313 | if ((boot_cpu_data.x86 == 0x10) && | ||
314 | (boot_cpu_data.x86_model > 7)) { | ||
315 | if (regs->nbsh & K8_NBSH_ERR_CPU_VAL) | ||
316 | pr_cont(", core: %u\n", (u8)(regs->nbsh & 0xf)); | ||
317 | } else { | ||
318 | u8 assoc_cpus = regs->nbsh & 0xf; | ||
319 | |||
320 | if (assoc_cpus > 0) | ||
321 | pr_cont(", core: %d", fls(assoc_cpus) - 1); | ||
322 | |||
323 | pr_cont("\n"); | ||
324 | } | ||
325 | |||
326 | pr_emerg("%s.\n", EXT_ERR_MSG(regs->nbsl)); | ||
327 | |||
328 | if (BUS_ERROR(ec) && nb_bus_decoder) | ||
329 | nb_bus_decoder(node_id, regs); | ||
330 | } | ||
331 | EXPORT_SYMBOL_GPL(amd_decode_nb_mce); | ||
332 | |||
333 | static void amd_decode_fr_mce(u64 mc5_status) | ||
334 | { | ||
335 | /* we have only one error signature so match all fields at once. */ | ||
336 | if ((mc5_status & 0xffff) == 0x0f0f) | ||
337 | pr_emerg(" FR Error: CPU Watchdog timer expire.\n"); | ||
338 | else | ||
339 | pr_warning("Corrupted FR MCE info?\n"); | ||
340 | } | ||
341 | |||
342 | static inline void amd_decode_err_code(unsigned int ec) | ||
343 | { | ||
344 | if (TLB_ERROR(ec)) { | ||
345 | pr_emerg("Transaction: %s, Cache Level %s\n", | ||
346 | TT_MSG(ec), LL_MSG(ec)); | ||
347 | } else if (MEM_ERROR(ec)) { | ||
348 | pr_emerg("Transaction: %s, Type: %s, Cache Level: %s", | ||
349 | RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec)); | ||
350 | } else if (BUS_ERROR(ec)) { | ||
351 | pr_emerg("Transaction type: %s(%s), %s, Cache Level: %s, " | ||
352 | "Participating Processor: %s\n", | ||
353 | RRRR_MSG(ec), II_MSG(ec), TO_MSG(ec), LL_MSG(ec), | ||
354 | PP_MSG(ec)); | ||
355 | } else | ||
356 | pr_warning("Huh? Unknown MCE error 0x%x\n", ec); | ||
357 | } | ||
358 | |||
359 | static int amd_decode_mce(struct notifier_block *nb, unsigned long val, | ||
360 | void *data) | ||
361 | { | ||
362 | struct mce *m = (struct mce *)data; | ||
363 | struct err_regs regs; | ||
364 | int node, ecc; | ||
365 | |||
366 | pr_emerg("MC%d_STATUS: ", m->bank); | ||
367 | |||
368 | pr_cont("%sorrected error, other errors lost: %s, " | ||
369 | "CPU context corrupt: %s", | ||
370 | ((m->status & MCI_STATUS_UC) ? "Unc" : "C"), | ||
371 | ((m->status & MCI_STATUS_OVER) ? "yes" : "no"), | ||
372 | ((m->status & MCI_STATUS_PCC) ? "yes" : "no")); | ||
373 | |||
374 | /* do the two bits[14:13] together */ | ||
375 | ecc = (m->status >> 45) & 0x3; | ||
376 | if (ecc) | ||
377 | pr_cont(", %sECC Error", ((ecc == 2) ? "C" : "U")); | ||
378 | |||
379 | pr_cont("\n"); | ||
380 | |||
381 | switch (m->bank) { | ||
382 | case 0: | ||
383 | amd_decode_dc_mce(m->status); | ||
384 | break; | ||
385 | |||
386 | case 1: | ||
387 | amd_decode_ic_mce(m->status); | ||
388 | break; | ||
389 | |||
390 | case 2: | ||
391 | amd_decode_bu_mce(m->status); | ||
392 | break; | ||
393 | |||
394 | case 3: | ||
395 | amd_decode_ls_mce(m->status); | ||
396 | break; | ||
397 | |||
398 | case 4: | ||
399 | regs.nbsl = (u32) m->status; | ||
400 | regs.nbsh = (u32)(m->status >> 32); | ||
401 | regs.nbeal = (u32) m->addr; | ||
402 | regs.nbeah = (u32)(m->addr >> 32); | ||
403 | node = amd_get_nb_id(m->extcpu); | ||
404 | |||
405 | amd_decode_nb_mce(node, ®s, 1); | ||
406 | break; | ||
407 | |||
408 | case 5: | ||
409 | amd_decode_fr_mce(m->status); | ||
410 | break; | ||
411 | |||
412 | default: | ||
413 | break; | ||
414 | } | ||
415 | |||
416 | amd_decode_err_code(m->status & 0xffff); | ||
417 | |||
418 | return NOTIFY_STOP; | ||
419 | } | ||
420 | |||
421 | static struct notifier_block amd_mce_dec_nb = { | ||
422 | .notifier_call = amd_decode_mce, | ||
423 | }; | ||
424 | |||
425 | static int __init mce_amd_init(void) | ||
426 | { | ||
427 | /* | ||
428 | * We can decode MCEs for K8, F10h and F11h CPUs: | ||
429 | */ | ||
430 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) | ||
431 | return 0; | ||
432 | |||
433 | if (boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x11) | ||
434 | return 0; | ||
435 | |||
436 | atomic_notifier_chain_register(&x86_mce_decoder_chain, &amd_mce_dec_nb); | ||
437 | |||
438 | return 0; | ||
439 | } | ||
440 | early_initcall(mce_amd_init); | ||
441 | |||
442 | #ifdef MODULE | ||
443 | static void __exit mce_amd_exit(void) | ||
444 | { | ||
445 | atomic_notifier_chain_unregister(&x86_mce_decoder_chain, &amd_mce_dec_nb); | ||
446 | } | ||
447 | |||
448 | MODULE_DESCRIPTION("AMD MCE decoder"); | ||
449 | MODULE_ALIAS("edac-mce-amd"); | ||
450 | MODULE_LICENSE("GPL"); | ||
451 | module_exit(mce_amd_exit); | ||
452 | #endif | ||
diff --git a/drivers/edac/edac_module.c b/drivers/edac/edac_module.c index 7e1374afd967..be4b075c3098 100644 --- a/drivers/edac/edac_module.c +++ b/drivers/edac/edac_module.c | |||
@@ -27,15 +27,6 @@ EXPORT_SYMBOL_GPL(edac_debug_level); | |||
27 | struct workqueue_struct *edac_workqueue; | 27 | struct workqueue_struct *edac_workqueue; |
28 | 28 | ||
29 | /* | 29 | /* |
30 | * sysfs object: /sys/devices/system/edac | ||
31 | * need to export to other files in this modules | ||
32 | */ | ||
33 | static struct sysdev_class edac_class = { | ||
34 | .name = "edac", | ||
35 | }; | ||
36 | static int edac_class_valid; | ||
37 | |||
38 | /* | ||
39 | * edac_op_state_to_string() | 30 | * edac_op_state_to_string() |
40 | */ | 31 | */ |
41 | char *edac_op_state_to_string(int opstate) | 32 | char *edac_op_state_to_string(int opstate) |
@@ -55,60 +46,6 @@ char *edac_op_state_to_string(int opstate) | |||
55 | } | 46 | } |
56 | 47 | ||
57 | /* | 48 | /* |
58 | * edac_get_edac_class() | ||
59 | * | ||
60 | * return pointer to the edac class of 'edac' | ||
61 | */ | ||
62 | struct sysdev_class *edac_get_edac_class(void) | ||
63 | { | ||
64 | struct sysdev_class *classptr = NULL; | ||
65 | |||
66 | if (edac_class_valid) | ||
67 | classptr = &edac_class; | ||
68 | |||
69 | return classptr; | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * edac_register_sysfs_edac_name() | ||
74 | * | ||
75 | * register the 'edac' into /sys/devices/system | ||
76 | * | ||
77 | * return: | ||
78 | * 0 success | ||
79 | * !0 error | ||
80 | */ | ||
81 | static int edac_register_sysfs_edac_name(void) | ||
82 | { | ||
83 | int err; | ||
84 | |||
85 | /* create the /sys/devices/system/edac directory */ | ||
86 | err = sysdev_class_register(&edac_class); | ||
87 | |||
88 | if (err) { | ||
89 | debugf1("%s() error=%d\n", __func__, err); | ||
90 | return err; | ||
91 | } | ||
92 | |||
93 | edac_class_valid = 1; | ||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | /* | ||
98 | * sysdev_class_unregister() | ||
99 | * | ||
100 | * unregister the 'edac' from /sys/devices/system | ||
101 | */ | ||
102 | static void edac_unregister_sysfs_edac_name(void) | ||
103 | { | ||
104 | /* only if currently registered, then unregister it */ | ||
105 | if (edac_class_valid) | ||
106 | sysdev_class_unregister(&edac_class); | ||
107 | |||
108 | edac_class_valid = 0; | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * edac_workqueue_setup | 49 | * edac_workqueue_setup |
113 | * initialize the edac work queue for polling operations | 50 | * initialize the edac work queue for polling operations |
114 | */ | 51 | */ |
@@ -154,21 +91,11 @@ static int __init edac_init(void) | |||
154 | edac_pci_clear_parity_errors(); | 91 | edac_pci_clear_parity_errors(); |
155 | 92 | ||
156 | /* | 93 | /* |
157 | * perform the registration of the /sys/devices/system/edac class object | ||
158 | */ | ||
159 | if (edac_register_sysfs_edac_name()) { | ||
160 | edac_printk(KERN_ERR, EDAC_MC, | ||
161 | "Error initializing 'edac' kobject\n"); | ||
162 | err = -ENODEV; | ||
163 | goto error; | ||
164 | } | ||
165 | |||
166 | /* | ||
167 | * now set up the mc_kset under the edac class object | 94 | * now set up the mc_kset under the edac class object |
168 | */ | 95 | */ |
169 | err = edac_sysfs_setup_mc_kset(); | 96 | err = edac_sysfs_setup_mc_kset(); |
170 | if (err) | 97 | if (err) |
171 | goto sysfs_setup_fail; | 98 | goto error; |
172 | 99 | ||
173 | /* Setup/Initialize the workq for this core */ | 100 | /* Setup/Initialize the workq for this core */ |
174 | err = edac_workqueue_setup(); | 101 | err = edac_workqueue_setup(); |
@@ -183,9 +110,6 @@ static int __init edac_init(void) | |||
183 | workq_fail: | 110 | workq_fail: |
184 | edac_sysfs_teardown_mc_kset(); | 111 | edac_sysfs_teardown_mc_kset(); |
185 | 112 | ||
186 | sysfs_setup_fail: | ||
187 | edac_unregister_sysfs_edac_name(); | ||
188 | |||
189 | error: | 113 | error: |
190 | return err; | 114 | return err; |
191 | } | 115 | } |
@@ -201,7 +125,6 @@ static void __exit edac_exit(void) | |||
201 | /* tear down the various subsystems */ | 125 | /* tear down the various subsystems */ |
202 | edac_workqueue_teardown(); | 126 | edac_workqueue_teardown(); |
203 | edac_sysfs_teardown_mc_kset(); | 127 | edac_sysfs_teardown_mc_kset(); |
204 | edac_unregister_sysfs_edac_name(); | ||
205 | } | 128 | } |
206 | 129 | ||
207 | /* | 130 | /* |
diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h index 233d4798c3aa..17aabb7b90ec 100644 --- a/drivers/edac/edac_module.h +++ b/drivers/edac/edac_module.h | |||
@@ -42,7 +42,6 @@ extern void edac_device_unregister_sysfs_main_kobj( | |||
42 | struct edac_device_ctl_info *edac_dev); | 42 | struct edac_device_ctl_info *edac_dev); |
43 | extern int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev); | 43 | extern int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev); |
44 | extern void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev); | 44 | extern void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev); |
45 | extern struct sysdev_class *edac_get_edac_class(void); | ||
46 | 45 | ||
47 | /* edac core workqueue: single CPU mode */ | 46 | /* edac core workqueue: single CPU mode */ |
48 | extern struct workqueue_struct *edac_workqueue; | 47 | extern struct workqueue_struct *edac_workqueue; |
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c index c39697df9cb4..023b01cb5175 100644 --- a/drivers/edac/edac_pci_sysfs.c +++ b/drivers/edac/edac_pci_sysfs.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/sysdev.h> | 10 | #include <linux/edac.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/ctype.h> | 12 | #include <linux/ctype.h> |
13 | 13 | ||
@@ -354,7 +354,7 @@ static int edac_pci_main_kobj_setup(void) | |||
354 | /* First time, so create the main kobject and its | 354 | /* First time, so create the main kobject and its |
355 | * controls and atributes | 355 | * controls and atributes |
356 | */ | 356 | */ |
357 | edac_class = edac_get_edac_class(); | 357 | edac_class = edac_get_sysfs_class(); |
358 | if (edac_class == NULL) { | 358 | if (edac_class == NULL) { |
359 | debugf1("%s() no edac_class\n", __func__); | 359 | debugf1("%s() no edac_class\n", __func__); |
360 | err = -ENODEV; | 360 | err = -ENODEV; |
@@ -368,7 +368,7 @@ static int edac_pci_main_kobj_setup(void) | |||
368 | if (!try_module_get(THIS_MODULE)) { | 368 | if (!try_module_get(THIS_MODULE)) { |
369 | debugf1("%s() try_module_get() failed\n", __func__); | 369 | debugf1("%s() try_module_get() failed\n", __func__); |
370 | err = -ENODEV; | 370 | err = -ENODEV; |
371 | goto decrement_count_fail; | 371 | goto mod_get_fail; |
372 | } | 372 | } |
373 | 373 | ||
374 | edac_pci_top_main_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL); | 374 | edac_pci_top_main_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL); |
@@ -403,6 +403,9 @@ kobject_init_and_add_fail: | |||
403 | kzalloc_fail: | 403 | kzalloc_fail: |
404 | module_put(THIS_MODULE); | 404 | module_put(THIS_MODULE); |
405 | 405 | ||
406 | mod_get_fail: | ||
407 | edac_put_sysfs_class(); | ||
408 | |||
406 | decrement_count_fail: | 409 | decrement_count_fail: |
407 | /* if are on this error exit, nothing to tear down */ | 410 | /* if are on this error exit, nothing to tear down */ |
408 | atomic_dec(&edac_pci_sysfs_refcount); | 411 | atomic_dec(&edac_pci_sysfs_refcount); |
@@ -429,6 +432,7 @@ static void edac_pci_main_kobj_teardown(void) | |||
429 | __func__); | 432 | __func__); |
430 | kobject_put(edac_pci_top_main_kobj); | 433 | kobject_put(edac_pci_top_main_kobj); |
431 | } | 434 | } |
435 | edac_put_sysfs_class(); | ||
432 | } | 436 | } |
433 | 437 | ||
434 | /* | 438 | /* |
diff --git a/drivers/edac/edac_stub.c b/drivers/edac/edac_stub.c index 20b428aa155e..aab970760b75 100644 --- a/drivers/edac/edac_stub.c +++ b/drivers/edac/edac_stub.c | |||
@@ -3,10 +3,13 @@ | |||
3 | * | 3 | * |
4 | * Author: Dave Jiang <djiang@mvista.com> | 4 | * Author: Dave Jiang <djiang@mvista.com> |
5 | * | 5 | * |
6 | * 2007 (c) MontaVista Software, Inc. This file is licensed under | 6 | * 2007 (c) MontaVista Software, Inc. |
7 | * the terms of the GNU General Public License version 2. This program | 7 | * 2010 (c) Advanced Micro Devices Inc. |
8 | * is licensed "as is" without any warranty of any kind, whether express | 8 | * Borislav Petkov <borislav.petkov@amd.com> |
9 | * or implied. | 9 | * |
10 | * This file is licensed under the terms of the GNU General Public | ||
11 | * License version 2. This program is licensed "as is" without any | ||
12 | * warranty of any kind, whether express or implied. | ||
10 | * | 13 | * |
11 | */ | 14 | */ |
12 | #include <linux/module.h> | 15 | #include <linux/module.h> |
@@ -23,6 +26,8 @@ EXPORT_SYMBOL_GPL(edac_handlers); | |||
23 | int edac_err_assert = 0; | 26 | int edac_err_assert = 0; |
24 | EXPORT_SYMBOL_GPL(edac_err_assert); | 27 | EXPORT_SYMBOL_GPL(edac_err_assert); |
25 | 28 | ||
29 | static atomic_t edac_class_valid = ATOMIC_INIT(0); | ||
30 | |||
26 | /* | 31 | /* |
27 | * called to determine if there is an EDAC driver interested in | 32 | * called to determine if there is an EDAC driver interested in |
28 | * knowing an event (such as NMI) occurred | 33 | * knowing an event (such as NMI) occurred |
@@ -44,3 +49,41 @@ void edac_atomic_assert_error(void) | |||
44 | edac_err_assert++; | 49 | edac_err_assert++; |
45 | } | 50 | } |
46 | EXPORT_SYMBOL_GPL(edac_atomic_assert_error); | 51 | EXPORT_SYMBOL_GPL(edac_atomic_assert_error); |
52 | |||
53 | /* | ||
54 | * sysfs object: /sys/devices/system/edac | ||
55 | * need to export to other files | ||
56 | */ | ||
57 | struct sysdev_class edac_class = { | ||
58 | .name = "edac", | ||
59 | }; | ||
60 | EXPORT_SYMBOL_GPL(edac_class); | ||
61 | |||
62 | /* return pointer to the 'edac' node in sysfs */ | ||
63 | struct sysdev_class *edac_get_sysfs_class(void) | ||
64 | { | ||
65 | int err = 0; | ||
66 | |||
67 | if (atomic_read(&edac_class_valid)) | ||
68 | goto out; | ||
69 | |||
70 | /* create the /sys/devices/system/edac directory */ | ||
71 | err = sysdev_class_register(&edac_class); | ||
72 | if (err) { | ||
73 | printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n"); | ||
74 | return NULL; | ||
75 | } | ||
76 | |||
77 | out: | ||
78 | atomic_inc(&edac_class_valid); | ||
79 | return &edac_class; | ||
80 | } | ||
81 | EXPORT_SYMBOL_GPL(edac_get_sysfs_class); | ||
82 | |||
83 | void edac_put_sysfs_class(void) | ||
84 | { | ||
85 | /* last user unregisters it */ | ||
86 | if (atomic_dec_and_test(&edac_class_valid)) | ||
87 | sysdev_class_unregister(&edac_class); | ||
88 | } | ||
89 | EXPORT_SYMBOL_GPL(edac_put_sysfs_class); | ||
diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c new file mode 100644 index 000000000000..c0181093b490 --- /dev/null +++ b/drivers/edac/mce_amd.c | |||
@@ -0,0 +1,680 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include <linux/slab.h> | ||
3 | |||
4 | #include "mce_amd.h" | ||
5 | |||
6 | static struct amd_decoder_ops *fam_ops; | ||
7 | |||
8 | static u8 nb_err_cpumask = 0xf; | ||
9 | |||
10 | static bool report_gart_errors; | ||
11 | static void (*nb_bus_decoder)(int node_id, struct mce *m, u32 nbcfg); | ||
12 | |||
13 | void amd_report_gart_errors(bool v) | ||
14 | { | ||
15 | report_gart_errors = v; | ||
16 | } | ||
17 | EXPORT_SYMBOL_GPL(amd_report_gart_errors); | ||
18 | |||
19 | void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32)) | ||
20 | { | ||
21 | nb_bus_decoder = f; | ||
22 | } | ||
23 | EXPORT_SYMBOL_GPL(amd_register_ecc_decoder); | ||
24 | |||
25 | void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32)) | ||
26 | { | ||
27 | if (nb_bus_decoder) { | ||
28 | WARN_ON(nb_bus_decoder != f); | ||
29 | |||
30 | nb_bus_decoder = NULL; | ||
31 | } | ||
32 | } | ||
33 | EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder); | ||
34 | |||
35 | /* | ||
36 | * string representation for the different MCA reported error types, see F3x48 | ||
37 | * or MSR0000_0411. | ||
38 | */ | ||
39 | |||
40 | /* transaction type */ | ||
41 | const char *tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" }; | ||
42 | EXPORT_SYMBOL_GPL(tt_msgs); | ||
43 | |||
44 | /* cache level */ | ||
45 | const char *ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" }; | ||
46 | EXPORT_SYMBOL_GPL(ll_msgs); | ||
47 | |||
48 | /* memory transaction type */ | ||
49 | const char *rrrr_msgs[] = { | ||
50 | "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP" | ||
51 | }; | ||
52 | EXPORT_SYMBOL_GPL(rrrr_msgs); | ||
53 | |||
54 | /* participating processor */ | ||
55 | const char *pp_msgs[] = { "SRC", "RES", "OBS", "GEN" }; | ||
56 | EXPORT_SYMBOL_GPL(pp_msgs); | ||
57 | |||
58 | /* request timeout */ | ||
59 | const char *to_msgs[] = { "no timeout", "timed out" }; | ||
60 | EXPORT_SYMBOL_GPL(to_msgs); | ||
61 | |||
62 | /* memory or i/o */ | ||
63 | const char *ii_msgs[] = { "MEM", "RESV", "IO", "GEN" }; | ||
64 | EXPORT_SYMBOL_GPL(ii_msgs); | ||
65 | |||
66 | static const char *f10h_nb_mce_desc[] = { | ||
67 | "HT link data error", | ||
68 | "Protocol error (link, L3, probe filter, etc.)", | ||
69 | "Parity error in NB-internal arrays", | ||
70 | "Link Retry due to IO link transmission error", | ||
71 | "L3 ECC data cache error", | ||
72 | "ECC error in L3 cache tag", | ||
73 | "L3 LRU parity bits error", | ||
74 | "ECC Error in the Probe Filter directory" | ||
75 | }; | ||
76 | |||
77 | static bool f12h_dc_mce(u16 ec) | ||
78 | { | ||
79 | bool ret = false; | ||
80 | |||
81 | if (MEM_ERROR(ec)) { | ||
82 | u8 ll = ec & 0x3; | ||
83 | ret = true; | ||
84 | |||
85 | if (ll == LL_L2) | ||
86 | pr_cont("during L1 linefill from L2.\n"); | ||
87 | else if (ll == LL_L1) | ||
88 | pr_cont("Data/Tag %s error.\n", RRRR_MSG(ec)); | ||
89 | else | ||
90 | ret = false; | ||
91 | } | ||
92 | return ret; | ||
93 | } | ||
94 | |||
95 | static bool f10h_dc_mce(u16 ec) | ||
96 | { | ||
97 | u8 r4 = (ec >> 4) & 0xf; | ||
98 | u8 ll = ec & 0x3; | ||
99 | |||
100 | if (r4 == R4_GEN && ll == LL_L1) { | ||
101 | pr_cont("during data scrub.\n"); | ||
102 | return true; | ||
103 | } | ||
104 | return f12h_dc_mce(ec); | ||
105 | } | ||
106 | |||
107 | static bool k8_dc_mce(u16 ec) | ||
108 | { | ||
109 | if (BUS_ERROR(ec)) { | ||
110 | pr_cont("during system linefill.\n"); | ||
111 | return true; | ||
112 | } | ||
113 | |||
114 | return f10h_dc_mce(ec); | ||
115 | } | ||
116 | |||
117 | static bool f14h_dc_mce(u16 ec) | ||
118 | { | ||
119 | u8 r4 = (ec >> 4) & 0xf; | ||
120 | u8 ll = ec & 0x3; | ||
121 | u8 tt = (ec >> 2) & 0x3; | ||
122 | u8 ii = tt; | ||
123 | bool ret = true; | ||
124 | |||
125 | if (MEM_ERROR(ec)) { | ||
126 | |||
127 | if (tt != TT_DATA || ll != LL_L1) | ||
128 | return false; | ||
129 | |||
130 | switch (r4) { | ||
131 | case R4_DRD: | ||
132 | case R4_DWR: | ||
133 | pr_cont("Data/Tag parity error due to %s.\n", | ||
134 | (r4 == R4_DRD ? "load/hw prf" : "store")); | ||
135 | break; | ||
136 | case R4_EVICT: | ||
137 | pr_cont("Copyback parity error on a tag miss.\n"); | ||
138 | break; | ||
139 | case R4_SNOOP: | ||
140 | pr_cont("Tag parity error during snoop.\n"); | ||
141 | break; | ||
142 | default: | ||
143 | ret = false; | ||
144 | } | ||
145 | } else if (BUS_ERROR(ec)) { | ||
146 | |||
147 | if ((ii != II_MEM && ii != II_IO) || ll != LL_LG) | ||
148 | return false; | ||
149 | |||
150 | pr_cont("System read data error on a "); | ||
151 | |||
152 | switch (r4) { | ||
153 | case R4_RD: | ||
154 | pr_cont("TLB reload.\n"); | ||
155 | break; | ||
156 | case R4_DWR: | ||
157 | pr_cont("store.\n"); | ||
158 | break; | ||
159 | case R4_DRD: | ||
160 | pr_cont("load.\n"); | ||
161 | break; | ||
162 | default: | ||
163 | ret = false; | ||
164 | } | ||
165 | } else { | ||
166 | ret = false; | ||
167 | } | ||
168 | |||
169 | return ret; | ||
170 | } | ||
171 | |||
172 | static void amd_decode_dc_mce(struct mce *m) | ||
173 | { | ||
174 | u16 ec = m->status & 0xffff; | ||
175 | u8 xec = (m->status >> 16) & 0xf; | ||
176 | |||
177 | pr_emerg(HW_ERR "Data Cache Error: "); | ||
178 | |||
179 | /* TLB error signatures are the same across families */ | ||
180 | if (TLB_ERROR(ec)) { | ||
181 | u8 tt = (ec >> 2) & 0x3; | ||
182 | |||
183 | if (tt == TT_DATA) { | ||
184 | pr_cont("%s TLB %s.\n", LL_MSG(ec), | ||
185 | (xec ? "multimatch" : "parity error")); | ||
186 | return; | ||
187 | } | ||
188 | else | ||
189 | goto wrong_dc_mce; | ||
190 | } | ||
191 | |||
192 | if (!fam_ops->dc_mce(ec)) | ||
193 | goto wrong_dc_mce; | ||
194 | |||
195 | return; | ||
196 | |||
197 | wrong_dc_mce: | ||
198 | pr_emerg(HW_ERR "Corrupted DC MCE info?\n"); | ||
199 | } | ||
200 | |||
201 | static bool k8_ic_mce(u16 ec) | ||
202 | { | ||
203 | u8 ll = ec & 0x3; | ||
204 | u8 r4 = (ec >> 4) & 0xf; | ||
205 | bool ret = true; | ||
206 | |||
207 | if (!MEM_ERROR(ec)) | ||
208 | return false; | ||
209 | |||
210 | if (ll == 0x2) | ||
211 | pr_cont("during a linefill from L2.\n"); | ||
212 | else if (ll == 0x1) { | ||
213 | switch (r4) { | ||
214 | case R4_IRD: | ||
215 | pr_cont("Parity error during data load.\n"); | ||
216 | break; | ||
217 | |||
218 | case R4_EVICT: | ||
219 | pr_cont("Copyback Parity/Victim error.\n"); | ||
220 | break; | ||
221 | |||
222 | case R4_SNOOP: | ||
223 | pr_cont("Tag Snoop error.\n"); | ||
224 | break; | ||
225 | |||
226 | default: | ||
227 | ret = false; | ||
228 | break; | ||
229 | } | ||
230 | } else | ||
231 | ret = false; | ||
232 | |||
233 | return ret; | ||
234 | } | ||
235 | |||
236 | static bool f14h_ic_mce(u16 ec) | ||
237 | { | ||
238 | u8 ll = ec & 0x3; | ||
239 | u8 tt = (ec >> 2) & 0x3; | ||
240 | u8 r4 = (ec >> 4) & 0xf; | ||
241 | bool ret = true; | ||
242 | |||
243 | if (MEM_ERROR(ec)) { | ||
244 | if (tt != 0 || ll != 1) | ||
245 | ret = false; | ||
246 | |||
247 | if (r4 == R4_IRD) | ||
248 | pr_cont("Data/tag array parity error for a tag hit.\n"); | ||
249 | else if (r4 == R4_SNOOP) | ||
250 | pr_cont("Tag error during snoop/victimization.\n"); | ||
251 | else | ||
252 | ret = false; | ||
253 | } | ||
254 | return ret; | ||
255 | } | ||
256 | |||
257 | static void amd_decode_ic_mce(struct mce *m) | ||
258 | { | ||
259 | u16 ec = m->status & 0xffff; | ||
260 | u8 xec = (m->status >> 16) & 0xf; | ||
261 | |||
262 | pr_emerg(HW_ERR "Instruction Cache Error: "); | ||
263 | |||
264 | if (TLB_ERROR(ec)) | ||
265 | pr_cont("%s TLB %s.\n", LL_MSG(ec), | ||
266 | (xec ? "multimatch" : "parity error")); | ||
267 | else if (BUS_ERROR(ec)) { | ||
268 | bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT_64(58))); | ||
269 | |||
270 | pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read")); | ||
271 | } else if (fam_ops->ic_mce(ec)) | ||
272 | ; | ||
273 | else | ||
274 | pr_emerg(HW_ERR "Corrupted IC MCE info?\n"); | ||
275 | } | ||
276 | |||
277 | static void amd_decode_bu_mce(struct mce *m) | ||
278 | { | ||
279 | u32 ec = m->status & 0xffff; | ||
280 | u32 xec = (m->status >> 16) & 0xf; | ||
281 | |||
282 | pr_emerg(HW_ERR "Bus Unit Error"); | ||
283 | |||
284 | if (xec == 0x1) | ||
285 | pr_cont(" in the write data buffers.\n"); | ||
286 | else if (xec == 0x3) | ||
287 | pr_cont(" in the victim data buffers.\n"); | ||
288 | else if (xec == 0x2 && MEM_ERROR(ec)) | ||
289 | pr_cont(": %s error in the L2 cache tags.\n", RRRR_MSG(ec)); | ||
290 | else if (xec == 0x0) { | ||
291 | if (TLB_ERROR(ec)) | ||
292 | pr_cont(": %s error in a Page Descriptor Cache or " | ||
293 | "Guest TLB.\n", TT_MSG(ec)); | ||
294 | else if (BUS_ERROR(ec)) | ||
295 | pr_cont(": %s/ECC error in data read from NB: %s.\n", | ||
296 | RRRR_MSG(ec), PP_MSG(ec)); | ||
297 | else if (MEM_ERROR(ec)) { | ||
298 | u8 rrrr = (ec >> 4) & 0xf; | ||
299 | |||
300 | if (rrrr >= 0x7) | ||
301 | pr_cont(": %s error during data copyback.\n", | ||
302 | RRRR_MSG(ec)); | ||
303 | else if (rrrr <= 0x1) | ||
304 | pr_cont(": %s parity/ECC error during data " | ||
305 | "access from L2.\n", RRRR_MSG(ec)); | ||
306 | else | ||
307 | goto wrong_bu_mce; | ||
308 | } else | ||
309 | goto wrong_bu_mce; | ||
310 | } else | ||
311 | goto wrong_bu_mce; | ||
312 | |||
313 | return; | ||
314 | |||
315 | wrong_bu_mce: | ||
316 | pr_emerg(HW_ERR "Corrupted BU MCE info?\n"); | ||
317 | } | ||
318 | |||
319 | static void amd_decode_ls_mce(struct mce *m) | ||
320 | { | ||
321 | u16 ec = m->status & 0xffff; | ||
322 | u8 xec = (m->status >> 16) & 0xf; | ||
323 | |||
324 | if (boot_cpu_data.x86 == 0x14) { | ||
325 | pr_emerg("You shouldn't be seeing an LS MCE on this cpu family," | ||
326 | " please report on LKML.\n"); | ||
327 | return; | ||
328 | } | ||
329 | |||
330 | pr_emerg(HW_ERR "Load Store Error"); | ||
331 | |||
332 | if (xec == 0x0) { | ||
333 | u8 r4 = (ec >> 4) & 0xf; | ||
334 | |||
335 | if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR)) | ||
336 | goto wrong_ls_mce; | ||
337 | |||
338 | pr_cont(" during %s.\n", RRRR_MSG(ec)); | ||
339 | } else | ||
340 | goto wrong_ls_mce; | ||
341 | |||
342 | return; | ||
343 | |||
344 | wrong_ls_mce: | ||
345 | pr_emerg(HW_ERR "Corrupted LS MCE info?\n"); | ||
346 | } | ||
347 | |||
348 | static bool k8_nb_mce(u16 ec, u8 xec) | ||
349 | { | ||
350 | bool ret = true; | ||
351 | |||
352 | switch (xec) { | ||
353 | case 0x1: | ||
354 | pr_cont("CRC error detected on HT link.\n"); | ||
355 | break; | ||
356 | |||
357 | case 0x5: | ||
358 | pr_cont("Invalid GART PTE entry during GART table walk.\n"); | ||
359 | break; | ||
360 | |||
361 | case 0x6: | ||
362 | pr_cont("Unsupported atomic RMW received from an IO link.\n"); | ||
363 | break; | ||
364 | |||
365 | case 0x0: | ||
366 | case 0x8: | ||
367 | if (boot_cpu_data.x86 == 0x11) | ||
368 | return false; | ||
369 | |||
370 | pr_cont("DRAM ECC error detected on the NB.\n"); | ||
371 | break; | ||
372 | |||
373 | case 0xd: | ||
374 | pr_cont("Parity error on the DRAM addr/ctl signals.\n"); | ||
375 | break; | ||
376 | |||
377 | default: | ||
378 | ret = false; | ||
379 | break; | ||
380 | } | ||
381 | |||
382 | return ret; | ||
383 | } | ||
384 | |||
385 | static bool f10h_nb_mce(u16 ec, u8 xec) | ||
386 | { | ||
387 | bool ret = true; | ||
388 | u8 offset = 0; | ||
389 | |||
390 | if (k8_nb_mce(ec, xec)) | ||
391 | return true; | ||
392 | |||
393 | switch(xec) { | ||
394 | case 0xa ... 0xc: | ||
395 | offset = 10; | ||
396 | break; | ||
397 | |||
398 | case 0xe: | ||
399 | offset = 11; | ||
400 | break; | ||
401 | |||
402 | case 0xf: | ||
403 | if (TLB_ERROR(ec)) | ||
404 | pr_cont("GART Table Walk data error.\n"); | ||
405 | else if (BUS_ERROR(ec)) | ||
406 | pr_cont("DMA Exclusion Vector Table Walk error.\n"); | ||
407 | else | ||
408 | ret = false; | ||
409 | |||
410 | goto out; | ||
411 | break; | ||
412 | |||
413 | case 0x1c ... 0x1f: | ||
414 | offset = 24; | ||
415 | break; | ||
416 | |||
417 | default: | ||
418 | ret = false; | ||
419 | |||
420 | goto out; | ||
421 | break; | ||
422 | } | ||
423 | |||
424 | pr_cont("%s.\n", f10h_nb_mce_desc[xec - offset]); | ||
425 | |||
426 | out: | ||
427 | return ret; | ||
428 | } | ||
429 | |||
430 | static bool nb_noop_mce(u16 ec, u8 xec) | ||
431 | { | ||
432 | return false; | ||
433 | } | ||
434 | |||
435 | void amd_decode_nb_mce(int node_id, struct mce *m, u32 nbcfg) | ||
436 | { | ||
437 | u8 xec = (m->status >> 16) & 0x1f; | ||
438 | u16 ec = m->status & 0xffff; | ||
439 | u32 nbsh = (u32)(m->status >> 32); | ||
440 | |||
441 | pr_emerg(HW_ERR "Northbridge Error, node %d: ", node_id); | ||
442 | |||
443 | /* | ||
444 | * F10h, revD can disable ErrCpu[3:0] so check that first and also the | ||
445 | * value encoding has changed so interpret those differently | ||
446 | */ | ||
447 | if ((boot_cpu_data.x86 == 0x10) && | ||
448 | (boot_cpu_data.x86_model > 7)) { | ||
449 | if (nbsh & K8_NBSH_ERR_CPU_VAL) | ||
450 | pr_cont(", core: %u", (u8)(nbsh & nb_err_cpumask)); | ||
451 | } else { | ||
452 | u8 assoc_cpus = nbsh & nb_err_cpumask; | ||
453 | |||
454 | if (assoc_cpus > 0) | ||
455 | pr_cont(", core: %d", fls(assoc_cpus) - 1); | ||
456 | } | ||
457 | |||
458 | switch (xec) { | ||
459 | case 0x2: | ||
460 | pr_cont("Sync error (sync packets on HT link detected).\n"); | ||
461 | return; | ||
462 | |||
463 | case 0x3: | ||
464 | pr_cont("HT Master abort.\n"); | ||
465 | return; | ||
466 | |||
467 | case 0x4: | ||
468 | pr_cont("HT Target abort.\n"); | ||
469 | return; | ||
470 | |||
471 | case 0x7: | ||
472 | pr_cont("NB Watchdog timeout.\n"); | ||
473 | return; | ||
474 | |||
475 | case 0x9: | ||
476 | pr_cont("SVM DMA Exclusion Vector error.\n"); | ||
477 | return; | ||
478 | |||
479 | default: | ||
480 | break; | ||
481 | } | ||
482 | |||
483 | if (!fam_ops->nb_mce(ec, xec)) | ||
484 | goto wrong_nb_mce; | ||
485 | |||
486 | if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10) | ||
487 | if ((xec == 0x8 || xec == 0x0) && nb_bus_decoder) | ||
488 | nb_bus_decoder(node_id, m, nbcfg); | ||
489 | |||
490 | return; | ||
491 | |||
492 | wrong_nb_mce: | ||
493 | pr_emerg(HW_ERR "Corrupted NB MCE info?\n"); | ||
494 | } | ||
495 | EXPORT_SYMBOL_GPL(amd_decode_nb_mce); | ||
496 | |||
497 | static void amd_decode_fr_mce(struct mce *m) | ||
498 | { | ||
499 | if (boot_cpu_data.x86 == 0xf || | ||
500 | boot_cpu_data.x86 == 0x11) | ||
501 | goto wrong_fr_mce; | ||
502 | |||
503 | /* we have only one error signature so match all fields at once. */ | ||
504 | if ((m->status & 0xffff) == 0x0f0f) { | ||
505 | pr_emerg(HW_ERR "FR Error: CPU Watchdog timer expire.\n"); | ||
506 | return; | ||
507 | } | ||
508 | |||
509 | wrong_fr_mce: | ||
510 | pr_emerg(HW_ERR "Corrupted FR MCE info?\n"); | ||
511 | } | ||
512 | |||
513 | static inline void amd_decode_err_code(u16 ec) | ||
514 | { | ||
515 | if (TLB_ERROR(ec)) { | ||
516 | pr_emerg(HW_ERR "Transaction: %s, Cache Level: %s\n", | ||
517 | TT_MSG(ec), LL_MSG(ec)); | ||
518 | } else if (MEM_ERROR(ec)) { | ||
519 | pr_emerg(HW_ERR "Transaction: %s, Type: %s, Cache Level: %s\n", | ||
520 | RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec)); | ||
521 | } else if (BUS_ERROR(ec)) { | ||
522 | pr_emerg(HW_ERR "Transaction: %s (%s), %s, Cache Level: %s, " | ||
523 | "Participating Processor: %s\n", | ||
524 | RRRR_MSG(ec), II_MSG(ec), TO_MSG(ec), LL_MSG(ec), | ||
525 | PP_MSG(ec)); | ||
526 | } else | ||
527 | pr_emerg(HW_ERR "Huh? Unknown MCE error 0x%x\n", ec); | ||
528 | } | ||
529 | |||
530 | /* | ||
531 | * Filter out unwanted MCE signatures here. | ||
532 | */ | ||
533 | static bool amd_filter_mce(struct mce *m) | ||
534 | { | ||
535 | u8 xec = (m->status >> 16) & 0x1f; | ||
536 | |||
537 | /* | ||
538 | * NB GART TLB error reporting is disabled by default. | ||
539 | */ | ||
540 | if (m->bank == 4 && xec == 0x5 && !report_gart_errors) | ||
541 | return true; | ||
542 | |||
543 | return false; | ||
544 | } | ||
545 | |||
546 | int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) | ||
547 | { | ||
548 | struct mce *m = (struct mce *)data; | ||
549 | int node, ecc; | ||
550 | |||
551 | if (amd_filter_mce(m)) | ||
552 | return NOTIFY_STOP; | ||
553 | |||
554 | pr_emerg(HW_ERR "MC%d_STATUS: ", m->bank); | ||
555 | |||
556 | pr_cont("%sorrected error, other errors lost: %s, " | ||
557 | "CPU context corrupt: %s", | ||
558 | ((m->status & MCI_STATUS_UC) ? "Unc" : "C"), | ||
559 | ((m->status & MCI_STATUS_OVER) ? "yes" : "no"), | ||
560 | ((m->status & MCI_STATUS_PCC) ? "yes" : "no")); | ||
561 | |||
562 | /* do the two bits[14:13] together */ | ||
563 | ecc = (m->status >> 45) & 0x3; | ||
564 | if (ecc) | ||
565 | pr_cont(", %sECC Error", ((ecc == 2) ? "C" : "U")); | ||
566 | |||
567 | pr_cont("\n"); | ||
568 | |||
569 | switch (m->bank) { | ||
570 | case 0: | ||
571 | amd_decode_dc_mce(m); | ||
572 | break; | ||
573 | |||
574 | case 1: | ||
575 | amd_decode_ic_mce(m); | ||
576 | break; | ||
577 | |||
578 | case 2: | ||
579 | amd_decode_bu_mce(m); | ||
580 | break; | ||
581 | |||
582 | case 3: | ||
583 | amd_decode_ls_mce(m); | ||
584 | break; | ||
585 | |||
586 | case 4: | ||
587 | node = amd_get_nb_id(m->extcpu); | ||
588 | amd_decode_nb_mce(node, m, 0); | ||
589 | break; | ||
590 | |||
591 | case 5: | ||
592 | amd_decode_fr_mce(m); | ||
593 | break; | ||
594 | |||
595 | default: | ||
596 | break; | ||
597 | } | ||
598 | |||
599 | amd_decode_err_code(m->status & 0xffff); | ||
600 | |||
601 | return NOTIFY_STOP; | ||
602 | } | ||
603 | EXPORT_SYMBOL_GPL(amd_decode_mce); | ||
604 | |||
605 | static struct notifier_block amd_mce_dec_nb = { | ||
606 | .notifier_call = amd_decode_mce, | ||
607 | }; | ||
608 | |||
609 | static int __init mce_amd_init(void) | ||
610 | { | ||
611 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) | ||
612 | return 0; | ||
613 | |||
614 | if ((boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x12) && | ||
615 | (boot_cpu_data.x86 != 0x14 || boot_cpu_data.x86_model > 0xf)) | ||
616 | return 0; | ||
617 | |||
618 | fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL); | ||
619 | if (!fam_ops) | ||
620 | return -ENOMEM; | ||
621 | |||
622 | switch (boot_cpu_data.x86) { | ||
623 | case 0xf: | ||
624 | fam_ops->dc_mce = k8_dc_mce; | ||
625 | fam_ops->ic_mce = k8_ic_mce; | ||
626 | fam_ops->nb_mce = k8_nb_mce; | ||
627 | break; | ||
628 | |||
629 | case 0x10: | ||
630 | fam_ops->dc_mce = f10h_dc_mce; | ||
631 | fam_ops->ic_mce = k8_ic_mce; | ||
632 | fam_ops->nb_mce = f10h_nb_mce; | ||
633 | break; | ||
634 | |||
635 | case 0x11: | ||
636 | fam_ops->dc_mce = k8_dc_mce; | ||
637 | fam_ops->ic_mce = k8_ic_mce; | ||
638 | fam_ops->nb_mce = f10h_nb_mce; | ||
639 | break; | ||
640 | |||
641 | case 0x12: | ||
642 | fam_ops->dc_mce = f12h_dc_mce; | ||
643 | fam_ops->ic_mce = k8_ic_mce; | ||
644 | fam_ops->nb_mce = nb_noop_mce; | ||
645 | break; | ||
646 | |||
647 | case 0x14: | ||
648 | nb_err_cpumask = 0x3; | ||
649 | fam_ops->dc_mce = f14h_dc_mce; | ||
650 | fam_ops->ic_mce = f14h_ic_mce; | ||
651 | fam_ops->nb_mce = nb_noop_mce; | ||
652 | break; | ||
653 | |||
654 | default: | ||
655 | printk(KERN_WARNING "Huh? What family is that: %d?!\n", | ||
656 | boot_cpu_data.x86); | ||
657 | kfree(fam_ops); | ||
658 | return -EINVAL; | ||
659 | } | ||
660 | |||
661 | pr_info("MCE: In-kernel MCE decoding enabled.\n"); | ||
662 | |||
663 | atomic_notifier_chain_register(&x86_mce_decoder_chain, &amd_mce_dec_nb); | ||
664 | |||
665 | return 0; | ||
666 | } | ||
667 | early_initcall(mce_amd_init); | ||
668 | |||
669 | #ifdef MODULE | ||
670 | static void __exit mce_amd_exit(void) | ||
671 | { | ||
672 | atomic_notifier_chain_unregister(&x86_mce_decoder_chain, &amd_mce_dec_nb); | ||
673 | kfree(fam_ops); | ||
674 | } | ||
675 | |||
676 | MODULE_DESCRIPTION("AMD MCE decoder"); | ||
677 | MODULE_ALIAS("edac-mce-amd"); | ||
678 | MODULE_LICENSE("GPL"); | ||
679 | module_exit(mce_amd_exit); | ||
680 | #endif | ||
diff --git a/drivers/edac/edac_mce_amd.h b/drivers/edac/mce_amd.h index df23ee065f79..35f6e0e3b297 100644 --- a/drivers/edac/edac_mce_amd.h +++ b/drivers/edac/mce_amd.h | |||
@@ -1,11 +1,14 @@ | |||
1 | #ifndef _EDAC_MCE_AMD_H | 1 | #ifndef _EDAC_MCE_AMD_H |
2 | #define _EDAC_MCE_AMD_H | 2 | #define _EDAC_MCE_AMD_H |
3 | 3 | ||
4 | #include <linux/notifier.h> | ||
5 | |||
4 | #include <asm/mce.h> | 6 | #include <asm/mce.h> |
5 | 7 | ||
8 | #define BIT_64(n) (U64_C(1) << (n)) | ||
9 | |||
6 | #define ERROR_CODE(x) ((x) & 0xffff) | 10 | #define ERROR_CODE(x) ((x) & 0xffff) |
7 | #define EXT_ERROR_CODE(x) (((x) >> 16) & 0x1f) | 11 | #define EXT_ERROR_CODE(x) (((x) >> 16) & 0x1f) |
8 | #define EXT_ERR_MSG(x) ext_msgs[EXT_ERROR_CODE(x)] | ||
9 | 12 | ||
10 | #define LOW_SYNDROME(x) (((x) >> 15) & 0xff) | 13 | #define LOW_SYNDROME(x) (((x) >> 15) & 0xff) |
11 | #define HIGH_SYNDROME(x) (((x) >> 24) & 0xff) | 14 | #define HIGH_SYNDROME(x) (((x) >> 24) & 0xff) |
@@ -20,13 +23,14 @@ | |||
20 | #define II_MSG(x) ii_msgs[II(x)] | 23 | #define II_MSG(x) ii_msgs[II(x)] |
21 | #define LL(x) (((x) >> 0) & 0x3) | 24 | #define LL(x) (((x) >> 0) & 0x3) |
22 | #define LL_MSG(x) ll_msgs[LL(x)] | 25 | #define LL_MSG(x) ll_msgs[LL(x)] |
23 | #define RRRR(x) (((x) >> 4) & 0xf) | ||
24 | #define RRRR_MSG(x) rrrr_msgs[RRRR(x)] | ||
25 | #define TO(x) (((x) >> 8) & 0x1) | 26 | #define TO(x) (((x) >> 8) & 0x1) |
26 | #define TO_MSG(x) to_msgs[TO(x)] | 27 | #define TO_MSG(x) to_msgs[TO(x)] |
27 | #define PP(x) (((x) >> 9) & 0x3) | 28 | #define PP(x) (((x) >> 9) & 0x3) |
28 | #define PP_MSG(x) pp_msgs[PP(x)] | 29 | #define PP_MSG(x) pp_msgs[PP(x)] |
29 | 30 | ||
31 | #define RRRR(x) (((x) >> 4) & 0xf) | ||
32 | #define RRRR_MSG(x) ((RRRR(x) < 9) ? rrrr_msgs[RRRR(x)] : "Wrong R4!") | ||
33 | |||
30 | #define K8_NBSH 0x4C | 34 | #define K8_NBSH 0x4C |
31 | 35 | ||
32 | #define K8_NBSH_VALID_BIT BIT(31) | 36 | #define K8_NBSH_VALID_BIT BIT(31) |
@@ -41,13 +45,45 @@ | |||
41 | #define K8_NBSH_UECC BIT(13) | 45 | #define K8_NBSH_UECC BIT(13) |
42 | #define K8_NBSH_ERR_SCRUBER BIT(8) | 46 | #define K8_NBSH_ERR_SCRUBER BIT(8) |
43 | 47 | ||
48 | enum tt_ids { | ||
49 | TT_INSTR = 0, | ||
50 | TT_DATA, | ||
51 | TT_GEN, | ||
52 | TT_RESV, | ||
53 | }; | ||
54 | |||
55 | enum ll_ids { | ||
56 | LL_RESV = 0, | ||
57 | LL_L1, | ||
58 | LL_L2, | ||
59 | LL_LG, | ||
60 | }; | ||
61 | |||
62 | enum ii_ids { | ||
63 | II_MEM = 0, | ||
64 | II_RESV, | ||
65 | II_IO, | ||
66 | II_GEN, | ||
67 | }; | ||
68 | |||
69 | enum rrrr_ids { | ||
70 | R4_GEN = 0, | ||
71 | R4_RD, | ||
72 | R4_WR, | ||
73 | R4_DRD, | ||
74 | R4_DWR, | ||
75 | R4_IRD, | ||
76 | R4_PREF, | ||
77 | R4_EVICT, | ||
78 | R4_SNOOP, | ||
79 | }; | ||
80 | |||
44 | extern const char *tt_msgs[]; | 81 | extern const char *tt_msgs[]; |
45 | extern const char *ll_msgs[]; | 82 | extern const char *ll_msgs[]; |
46 | extern const char *rrrr_msgs[]; | 83 | extern const char *rrrr_msgs[]; |
47 | extern const char *pp_msgs[]; | 84 | extern const char *pp_msgs[]; |
48 | extern const char *to_msgs[]; | 85 | extern const char *to_msgs[]; |
49 | extern const char *ii_msgs[]; | 86 | extern const char *ii_msgs[]; |
50 | extern const char *ext_msgs[]; | ||
51 | 87 | ||
52 | /* | 88 | /* |
53 | * relevant NB regs | 89 | * relevant NB regs |
@@ -60,10 +96,19 @@ struct err_regs { | |||
60 | u32 nbeal; | 96 | u32 nbeal; |
61 | }; | 97 | }; |
62 | 98 | ||
99 | /* | ||
100 | * per-family decoder ops | ||
101 | */ | ||
102 | struct amd_decoder_ops { | ||
103 | bool (*dc_mce)(u16); | ||
104 | bool (*ic_mce)(u16); | ||
105 | bool (*nb_mce)(u16, u8); | ||
106 | }; | ||
63 | 107 | ||
64 | void amd_report_gart_errors(bool); | 108 | void amd_report_gart_errors(bool); |
65 | void amd_register_ecc_decoder(void (*f)(int, struct err_regs *)); | 109 | void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32)); |
66 | void amd_unregister_ecc_decoder(void (*f)(int, struct err_regs *)); | 110 | void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32)); |
67 | void amd_decode_nb_mce(int, struct err_regs *, int); | 111 | void amd_decode_nb_mce(int, struct mce *, u32); |
112 | int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data); | ||
68 | 113 | ||
69 | #endif /* _EDAC_MCE_AMD_H */ | 114 | #endif /* _EDAC_MCE_AMD_H */ |
diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c new file mode 100644 index 000000000000..8d0688f36d4c --- /dev/null +++ b/drivers/edac/mce_amd_inj.c | |||
@@ -0,0 +1,171 @@ | |||
1 | /* | ||
2 | * A simple MCE injection facility for testing the MCE decoding code. This | ||
3 | * driver should be built as module so that it can be loaded on production | ||
4 | * kernels for testing purposes. | ||
5 | * | ||
6 | * This file may be distributed under the terms of the GNU General Public | ||
7 | * License version 2. | ||
8 | * | ||
9 | * Copyright (c) 2010: Borislav Petkov <borislav.petkov@amd.com> | ||
10 | * Advanced Micro Devices Inc. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kobject.h> | ||
14 | #include <linux/sysdev.h> | ||
15 | #include <linux/edac.h> | ||
16 | #include <asm/mce.h> | ||
17 | |||
18 | #include "mce_amd.h" | ||
19 | |||
20 | struct edac_mce_attr { | ||
21 | struct attribute attr; | ||
22 | ssize_t (*show) (struct kobject *kobj, struct edac_mce_attr *attr, char *buf); | ||
23 | ssize_t (*store)(struct kobject *kobj, struct edac_mce_attr *attr, | ||
24 | const char *buf, size_t count); | ||
25 | }; | ||
26 | |||
27 | #define EDAC_MCE_ATTR(_name, _mode, _show, _store) \ | ||
28 | static struct edac_mce_attr mce_attr_##_name = __ATTR(_name, _mode, _show, _store) | ||
29 | |||
30 | static struct kobject *mce_kobj; | ||
31 | |||
32 | /* | ||
33 | * Collect all the MCi_XXX settings | ||
34 | */ | ||
35 | static struct mce i_mce; | ||
36 | |||
37 | #define MCE_INJECT_STORE(reg) \ | ||
38 | static ssize_t edac_inject_##reg##_store(struct kobject *kobj, \ | ||
39 | struct edac_mce_attr *attr, \ | ||
40 | const char *data, size_t count)\ | ||
41 | { \ | ||
42 | int ret = 0; \ | ||
43 | unsigned long value; \ | ||
44 | \ | ||
45 | ret = strict_strtoul(data, 16, &value); \ | ||
46 | if (ret < 0) \ | ||
47 | printk(KERN_ERR "Error writing MCE " #reg " field.\n"); \ | ||
48 | \ | ||
49 | i_mce.reg = value; \ | ||
50 | \ | ||
51 | return count; \ | ||
52 | } | ||
53 | |||
54 | MCE_INJECT_STORE(status); | ||
55 | MCE_INJECT_STORE(misc); | ||
56 | MCE_INJECT_STORE(addr); | ||
57 | |||
58 | #define MCE_INJECT_SHOW(reg) \ | ||
59 | static ssize_t edac_inject_##reg##_show(struct kobject *kobj, \ | ||
60 | struct edac_mce_attr *attr, \ | ||
61 | char *buf) \ | ||
62 | { \ | ||
63 | return sprintf(buf, "0x%016llx\n", i_mce.reg); \ | ||
64 | } | ||
65 | |||
66 | MCE_INJECT_SHOW(status); | ||
67 | MCE_INJECT_SHOW(misc); | ||
68 | MCE_INJECT_SHOW(addr); | ||
69 | |||
70 | EDAC_MCE_ATTR(status, 0644, edac_inject_status_show, edac_inject_status_store); | ||
71 | EDAC_MCE_ATTR(misc, 0644, edac_inject_misc_show, edac_inject_misc_store); | ||
72 | EDAC_MCE_ATTR(addr, 0644, edac_inject_addr_show, edac_inject_addr_store); | ||
73 | |||
74 | /* | ||
75 | * This denotes into which bank we're injecting and triggers | ||
76 | * the injection, at the same time. | ||
77 | */ | ||
78 | static ssize_t edac_inject_bank_store(struct kobject *kobj, | ||
79 | struct edac_mce_attr *attr, | ||
80 | const char *data, size_t count) | ||
81 | { | ||
82 | int ret = 0; | ||
83 | unsigned long value; | ||
84 | |||
85 | ret = strict_strtoul(data, 10, &value); | ||
86 | if (ret < 0) { | ||
87 | printk(KERN_ERR "Invalid bank value!\n"); | ||
88 | return -EINVAL; | ||
89 | } | ||
90 | |||
91 | if (value > 5) { | ||
92 | printk(KERN_ERR "Non-existant MCE bank: %lu\n", value); | ||
93 | return -EINVAL; | ||
94 | } | ||
95 | |||
96 | i_mce.bank = value; | ||
97 | |||
98 | amd_decode_mce(NULL, 0, &i_mce); | ||
99 | |||
100 | return count; | ||
101 | } | ||
102 | |||
103 | static ssize_t edac_inject_bank_show(struct kobject *kobj, | ||
104 | struct edac_mce_attr *attr, char *buf) | ||
105 | { | ||
106 | return sprintf(buf, "%d\n", i_mce.bank); | ||
107 | } | ||
108 | |||
109 | EDAC_MCE_ATTR(bank, 0644, edac_inject_bank_show, edac_inject_bank_store); | ||
110 | |||
111 | static struct edac_mce_attr *sysfs_attrs[] = { &mce_attr_status, &mce_attr_misc, | ||
112 | &mce_attr_addr, &mce_attr_bank | ||
113 | }; | ||
114 | |||
115 | static int __init edac_init_mce_inject(void) | ||
116 | { | ||
117 | struct sysdev_class *edac_class = NULL; | ||
118 | int i, err = 0; | ||
119 | |||
120 | edac_class = edac_get_sysfs_class(); | ||
121 | if (!edac_class) | ||
122 | return -EINVAL; | ||
123 | |||
124 | mce_kobj = kobject_create_and_add("mce", &edac_class->kset.kobj); | ||
125 | if (!mce_kobj) { | ||
126 | printk(KERN_ERR "Error creating a mce kset.\n"); | ||
127 | err = -ENOMEM; | ||
128 | goto err_mce_kobj; | ||
129 | } | ||
130 | |||
131 | for (i = 0; i < ARRAY_SIZE(sysfs_attrs); i++) { | ||
132 | err = sysfs_create_file(mce_kobj, &sysfs_attrs[i]->attr); | ||
133 | if (err) { | ||
134 | printk(KERN_ERR "Error creating %s in sysfs.\n", | ||
135 | sysfs_attrs[i]->attr.name); | ||
136 | goto err_sysfs_create; | ||
137 | } | ||
138 | } | ||
139 | return 0; | ||
140 | |||
141 | err_sysfs_create: | ||
142 | while (i-- >= 0) | ||
143 | sysfs_remove_file(mce_kobj, &sysfs_attrs[i]->attr); | ||
144 | |||
145 | kobject_del(mce_kobj); | ||
146 | |||
147 | err_mce_kobj: | ||
148 | edac_put_sysfs_class(); | ||
149 | |||
150 | return err; | ||
151 | } | ||
152 | |||
153 | static void __exit edac_exit_mce_inject(void) | ||
154 | { | ||
155 | int i; | ||
156 | |||
157 | for (i = 0; i < ARRAY_SIZE(sysfs_attrs); i++) | ||
158 | sysfs_remove_file(mce_kobj, &sysfs_attrs[i]->attr); | ||
159 | |||
160 | kobject_del(mce_kobj); | ||
161 | |||
162 | edac_put_sysfs_class(); | ||
163 | } | ||
164 | |||
165 | module_init(edac_init_mce_inject); | ||
166 | module_exit(edac_exit_mce_inject); | ||
167 | |||
168 | MODULE_LICENSE("GPL"); | ||
169 | MODULE_AUTHOR("Borislav Petkov <borislav.petkov@amd.com>"); | ||
170 | MODULE_AUTHOR("AMD Inc."); | ||
171 | MODULE_DESCRIPTION("MCE injection facility for testing MCE decoding"); | ||
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 1b05896648bc..9dcb17d51aee 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -2840,7 +2840,7 @@ static int __devinit pci_probe(struct pci_dev *dev, | |||
2840 | const struct pci_device_id *ent) | 2840 | const struct pci_device_id *ent) |
2841 | { | 2841 | { |
2842 | struct fw_ohci *ohci; | 2842 | struct fw_ohci *ohci; |
2843 | u32 bus_options, max_receive, link_speed, version, link_enh; | 2843 | u32 bus_options, max_receive, link_speed, version; |
2844 | u64 guid; | 2844 | u64 guid; |
2845 | int i, err, n_ir, n_it; | 2845 | int i, err, n_ir, n_it; |
2846 | size_t size; | 2846 | size_t size; |
@@ -2894,23 +2894,6 @@ static int __devinit pci_probe(struct pci_dev *dev, | |||
2894 | if (param_quirks) | 2894 | if (param_quirks) |
2895 | ohci->quirks = param_quirks; | 2895 | ohci->quirks = param_quirks; |
2896 | 2896 | ||
2897 | /* TI OHCI-Lynx and compatible: set recommended configuration bits. */ | ||
2898 | if (dev->vendor == PCI_VENDOR_ID_TI) { | ||
2899 | pci_read_config_dword(dev, PCI_CFG_TI_LinkEnh, &link_enh); | ||
2900 | |||
2901 | /* adjust latency of ATx FIFO: use 1.7 KB threshold */ | ||
2902 | link_enh &= ~TI_LinkEnh_atx_thresh_mask; | ||
2903 | link_enh |= TI_LinkEnh_atx_thresh_1_7K; | ||
2904 | |||
2905 | /* use priority arbitration for asynchronous responses */ | ||
2906 | link_enh |= TI_LinkEnh_enab_unfair; | ||
2907 | |||
2908 | /* required for aPhyEnhanceEnable to work */ | ||
2909 | link_enh |= TI_LinkEnh_enab_accel; | ||
2910 | |||
2911 | pci_write_config_dword(dev, PCI_CFG_TI_LinkEnh, link_enh); | ||
2912 | } | ||
2913 | |||
2914 | ar_context_init(&ohci->ar_request_ctx, ohci, | 2897 | ar_context_init(&ohci->ar_request_ctx, ohci, |
2915 | OHCI1394_AsReqRcvContextControlSet); | 2898 | OHCI1394_AsReqRcvContextControlSet); |
2916 | 2899 | ||
diff --git a/drivers/firewire/ohci.h b/drivers/firewire/ohci.h index 0e6c5a466908..ef5e7336da68 100644 --- a/drivers/firewire/ohci.h +++ b/drivers/firewire/ohci.h | |||
@@ -155,12 +155,4 @@ | |||
155 | 155 | ||
156 | #define OHCI1394_phy_tcode 0xe | 156 | #define OHCI1394_phy_tcode 0xe |
157 | 157 | ||
158 | /* TI extensions */ | ||
159 | |||
160 | #define PCI_CFG_TI_LinkEnh 0xf4 | ||
161 | #define TI_LinkEnh_enab_accel 0x00000002 | ||
162 | #define TI_LinkEnh_enab_unfair 0x00000080 | ||
163 | #define TI_LinkEnh_atx_thresh_mask 0x00003000 | ||
164 | #define TI_LinkEnh_atx_thresh_1_7K 0x00001000 | ||
165 | |||
166 | #endif /* _FIREWIRE_OHCI_H */ | 158 | #endif /* _FIREWIRE_OHCI_H */ |
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 280c9b5ad9e3..88a3ae6cd023 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig | |||
@@ -125,7 +125,7 @@ config ISCSI_IBFT_FIND | |||
125 | config ISCSI_IBFT | 125 | config ISCSI_IBFT |
126 | tristate "iSCSI Boot Firmware Table Attributes module" | 126 | tristate "iSCSI Boot Firmware Table Attributes module" |
127 | select ISCSI_BOOT_SYSFS | 127 | select ISCSI_BOOT_SYSFS |
128 | depends on ISCSI_IBFT_FIND && SCSI | 128 | depends on ISCSI_IBFT_FIND && SCSI && SCSI_LOWLEVEL |
129 | default n | 129 | default n |
130 | help | 130 | help |
131 | This option enables support for detection and exposing of iSCSI | 131 | This option enables support for detection and exposing of iSCSI |
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index c74e4e8006d4..2dd2c93ebfa3 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -2231,6 +2231,9 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
2231 | dev_priv->mchdev_lock = &mchdev_lock; | 2231 | dev_priv->mchdev_lock = &mchdev_lock; |
2232 | spin_unlock(&mchdev_lock); | 2232 | spin_unlock(&mchdev_lock); |
2233 | 2233 | ||
2234 | /* XXX Prevent module unload due to memory corruption bugs. */ | ||
2235 | __module_get(THIS_MODULE); | ||
2236 | |||
2234 | return 0; | 2237 | return 0; |
2235 | 2238 | ||
2236 | out_workqueue_free: | 2239 | out_workqueue_free: |
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c index 56ad9df2ccb5..b61966c126d3 100644 --- a/drivers/gpu/drm/i915/intel_fb.c +++ b/drivers/gpu/drm/i915/intel_fb.c | |||
@@ -238,8 +238,8 @@ int intel_fbdev_destroy(struct drm_device *dev, | |||
238 | 238 | ||
239 | drm_framebuffer_cleanup(&ifb->base); | 239 | drm_framebuffer_cleanup(&ifb->base); |
240 | if (ifb->obj) { | 240 | if (ifb->obj) { |
241 | drm_gem_object_handle_unreference(ifb->obj); | ||
242 | drm_gem_object_unreference(ifb->obj); | 241 | drm_gem_object_unreference(ifb->obj); |
242 | ifb->obj = NULL; | ||
243 | } | 243 | } |
244 | 244 | ||
245 | return 0; | 245 | return 0; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index d2047713dc59..dbd30b2e43fd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c | |||
@@ -352,7 +352,6 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *nfbdev) | |||
352 | 352 | ||
353 | if (nouveau_fb->nvbo) { | 353 | if (nouveau_fb->nvbo) { |
354 | nouveau_bo_unmap(nouveau_fb->nvbo); | 354 | nouveau_bo_unmap(nouveau_fb->nvbo); |
355 | drm_gem_object_handle_unreference_unlocked(nouveau_fb->nvbo->gem); | ||
356 | drm_gem_object_unreference_unlocked(nouveau_fb->nvbo->gem); | 355 | drm_gem_object_unreference_unlocked(nouveau_fb->nvbo->gem); |
357 | nouveau_fb->nvbo = NULL; | 356 | nouveau_fb->nvbo = NULL; |
358 | } | 357 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_notifier.c b/drivers/gpu/drm/nouveau/nouveau_notifier.c index 3c9964a8fbad..3ec181ff50ce 100644 --- a/drivers/gpu/drm/nouveau/nouveau_notifier.c +++ b/drivers/gpu/drm/nouveau/nouveau_notifier.c | |||
@@ -79,7 +79,6 @@ nouveau_notifier_takedown_channel(struct nouveau_channel *chan) | |||
79 | mutex_lock(&dev->struct_mutex); | 79 | mutex_lock(&dev->struct_mutex); |
80 | nouveau_bo_unpin(chan->notifier_bo); | 80 | nouveau_bo_unpin(chan->notifier_bo); |
81 | mutex_unlock(&dev->struct_mutex); | 81 | mutex_unlock(&dev->struct_mutex); |
82 | drm_gem_object_handle_unreference_unlocked(chan->notifier_bo->gem); | ||
83 | drm_gem_object_unreference_unlocked(chan->notifier_bo->gem); | 82 | drm_gem_object_unreference_unlocked(chan->notifier_bo->gem); |
84 | drm_mm_takedown(&chan->notifier_heap); | 83 | drm_mm_takedown(&chan->notifier_heap); |
85 | } | 84 | } |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index 79082d4398ae..2f93d46ae69a 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c | |||
@@ -1137,7 +1137,7 @@ static void evergreen_gpu_init(struct radeon_device *rdev) | |||
1137 | 1137 | ||
1138 | WREG32(RCU_IND_INDEX, 0x203); | 1138 | WREG32(RCU_IND_INDEX, 0x203); |
1139 | efuse_straps_3 = RREG32(RCU_IND_DATA); | 1139 | efuse_straps_3 = RREG32(RCU_IND_DATA); |
1140 | efuse_box_bit_127_124 = (u8)(efuse_straps_3 & 0xF0000000) >> 28; | 1140 | efuse_box_bit_127_124 = (u8)((efuse_straps_3 & 0xF0000000) >> 28); |
1141 | 1141 | ||
1142 | switch(efuse_box_bit_127_124) { | 1142 | switch(efuse_box_bit_127_124) { |
1143 | case 0x0: | 1143 | case 0x0: |
@@ -1407,6 +1407,7 @@ int evergreen_mc_init(struct radeon_device *rdev) | |||
1407 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; | 1407 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; |
1408 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; | 1408 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; |
1409 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 1409 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
1410 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
1410 | r600_vram_gtt_location(rdev, &rdev->mc); | 1411 | r600_vram_gtt_location(rdev, &rdev->mc); |
1411 | radeon_update_bandwidth_info(rdev); | 1412 | radeon_update_bandwidth_info(rdev); |
1412 | 1413 | ||
@@ -1520,7 +1521,7 @@ void evergreen_disable_interrupt_state(struct radeon_device *rdev) | |||
1520 | { | 1521 | { |
1521 | u32 tmp; | 1522 | u32 tmp; |
1522 | 1523 | ||
1523 | WREG32(CP_INT_CNTL, 0); | 1524 | WREG32(CP_INT_CNTL, CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
1524 | WREG32(GRBM_INT_CNTL, 0); | 1525 | WREG32(GRBM_INT_CNTL, 0); |
1525 | WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); | 1526 | WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); |
1526 | WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); | 1527 | WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); |
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index e151f16a8f86..e59422320bb6 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c | |||
@@ -1030,6 +1030,7 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size) | |||
1030 | return r; | 1030 | return r; |
1031 | } | 1031 | } |
1032 | rdev->cp.ready = true; | 1032 | rdev->cp.ready = true; |
1033 | rdev->mc.active_vram_size = rdev->mc.real_vram_size; | ||
1033 | return 0; | 1034 | return 0; |
1034 | } | 1035 | } |
1035 | 1036 | ||
@@ -1047,6 +1048,7 @@ void r100_cp_fini(struct radeon_device *rdev) | |||
1047 | void r100_cp_disable(struct radeon_device *rdev) | 1048 | void r100_cp_disable(struct radeon_device *rdev) |
1048 | { | 1049 | { |
1049 | /* Disable ring */ | 1050 | /* Disable ring */ |
1051 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
1050 | rdev->cp.ready = false; | 1052 | rdev->cp.ready = false; |
1051 | WREG32(RADEON_CP_CSQ_MODE, 0); | 1053 | WREG32(RADEON_CP_CSQ_MODE, 0); |
1052 | WREG32(RADEON_CP_CSQ_CNTL, 0); | 1054 | WREG32(RADEON_CP_CSQ_CNTL, 0); |
@@ -2295,6 +2297,7 @@ void r100_vram_init_sizes(struct radeon_device *rdev) | |||
2295 | /* FIXME we don't use the second aperture yet when we could use it */ | 2297 | /* FIXME we don't use the second aperture yet when we could use it */ |
2296 | if (rdev->mc.visible_vram_size > rdev->mc.aper_size) | 2298 | if (rdev->mc.visible_vram_size > rdev->mc.aper_size) |
2297 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 2299 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
2300 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
2298 | config_aper_size = RREG32(RADEON_CONFIG_APER_SIZE); | 2301 | config_aper_size = RREG32(RADEON_CONFIG_APER_SIZE); |
2299 | if (rdev->flags & RADEON_IS_IGP) { | 2302 | if (rdev->flags & RADEON_IS_IGP) { |
2300 | uint32_t tom; | 2303 | uint32_t tom; |
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index 7a04959ba0ee..7b65e4efe8af 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c | |||
@@ -1248,6 +1248,7 @@ int r600_mc_init(struct radeon_device *rdev) | |||
1248 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); | 1248 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); |
1249 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); | 1249 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); |
1250 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 1250 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
1251 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
1251 | r600_vram_gtt_location(rdev, &rdev->mc); | 1252 | r600_vram_gtt_location(rdev, &rdev->mc); |
1252 | 1253 | ||
1253 | if (rdev->flags & RADEON_IS_IGP) { | 1254 | if (rdev->flags & RADEON_IS_IGP) { |
@@ -1917,6 +1918,7 @@ void r600_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) | |||
1917 | */ | 1918 | */ |
1918 | void r600_cp_stop(struct radeon_device *rdev) | 1919 | void r600_cp_stop(struct radeon_device *rdev) |
1919 | { | 1920 | { |
1921 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
1920 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1)); | 1922 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1)); |
1921 | } | 1923 | } |
1922 | 1924 | ||
@@ -2910,7 +2912,7 @@ static void r600_disable_interrupt_state(struct radeon_device *rdev) | |||
2910 | { | 2912 | { |
2911 | u32 tmp; | 2913 | u32 tmp; |
2912 | 2914 | ||
2913 | WREG32(CP_INT_CNTL, 0); | 2915 | WREG32(CP_INT_CNTL, CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
2914 | WREG32(GRBM_INT_CNTL, 0); | 2916 | WREG32(GRBM_INT_CNTL, 0); |
2915 | WREG32(DxMODE_INT_MASK, 0); | 2917 | WREG32(DxMODE_INT_MASK, 0); |
2916 | if (ASIC_IS_DCE3(rdev)) { | 2918 | if (ASIC_IS_DCE3(rdev)) { |
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c index 9ceb2a1ce799..3473c00781ff 100644 --- a/drivers/gpu/drm/radeon/r600_blit_kms.c +++ b/drivers/gpu/drm/radeon/r600_blit_kms.c | |||
@@ -532,6 +532,7 @@ int r600_blit_init(struct radeon_device *rdev) | |||
532 | memcpy(ptr + rdev->r600_blit.ps_offset, r6xx_ps, r6xx_ps_size * 4); | 532 | memcpy(ptr + rdev->r600_blit.ps_offset, r6xx_ps, r6xx_ps_size * 4); |
533 | radeon_bo_kunmap(rdev->r600_blit.shader_obj); | 533 | radeon_bo_kunmap(rdev->r600_blit.shader_obj); |
534 | radeon_bo_unreserve(rdev->r600_blit.shader_obj); | 534 | radeon_bo_unreserve(rdev->r600_blit.shader_obj); |
535 | rdev->mc.active_vram_size = rdev->mc.real_vram_size; | ||
535 | return 0; | 536 | return 0; |
536 | } | 537 | } |
537 | 538 | ||
@@ -539,6 +540,7 @@ void r600_blit_fini(struct radeon_device *rdev) | |||
539 | { | 540 | { |
540 | int r; | 541 | int r; |
541 | 542 | ||
543 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
542 | if (rdev->r600_blit.shader_obj == NULL) | 544 | if (rdev->r600_blit.shader_obj == NULL) |
543 | return; | 545 | return; |
544 | /* If we can't reserve the bo, unref should be enough to destroy | 546 | /* If we can't reserve the bo, unref should be enough to destroy |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index a168d644bf9e..9ff38c99a6ea 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -344,6 +344,7 @@ struct radeon_mc { | |||
344 | * about vram size near mc fb location */ | 344 | * about vram size near mc fb location */ |
345 | u64 mc_vram_size; | 345 | u64 mc_vram_size; |
346 | u64 visible_vram_size; | 346 | u64 visible_vram_size; |
347 | u64 active_vram_size; | ||
347 | u64 gtt_size; | 348 | u64 gtt_size; |
348 | u64 gtt_start; | 349 | u64 gtt_start; |
349 | u64 gtt_end; | 350 | u64 gtt_end; |
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index 68932ba7b8a4..8e43ddae70cc 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c | |||
@@ -1558,39 +1558,39 @@ radeon_atombios_get_tv_info(struct radeon_device *rdev) | |||
1558 | switch (tv_info->ucTV_BootUpDefaultStandard) { | 1558 | switch (tv_info->ucTV_BootUpDefaultStandard) { |
1559 | case ATOM_TV_NTSC: | 1559 | case ATOM_TV_NTSC: |
1560 | tv_std = TV_STD_NTSC; | 1560 | tv_std = TV_STD_NTSC; |
1561 | DRM_INFO("Default TV standard: NTSC\n"); | 1561 | DRM_DEBUG_KMS("Default TV standard: NTSC\n"); |
1562 | break; | 1562 | break; |
1563 | case ATOM_TV_NTSCJ: | 1563 | case ATOM_TV_NTSCJ: |
1564 | tv_std = TV_STD_NTSC_J; | 1564 | tv_std = TV_STD_NTSC_J; |
1565 | DRM_INFO("Default TV standard: NTSC-J\n"); | 1565 | DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); |
1566 | break; | 1566 | break; |
1567 | case ATOM_TV_PAL: | 1567 | case ATOM_TV_PAL: |
1568 | tv_std = TV_STD_PAL; | 1568 | tv_std = TV_STD_PAL; |
1569 | DRM_INFO("Default TV standard: PAL\n"); | 1569 | DRM_DEBUG_KMS("Default TV standard: PAL\n"); |
1570 | break; | 1570 | break; |
1571 | case ATOM_TV_PALM: | 1571 | case ATOM_TV_PALM: |
1572 | tv_std = TV_STD_PAL_M; | 1572 | tv_std = TV_STD_PAL_M; |
1573 | DRM_INFO("Default TV standard: PAL-M\n"); | 1573 | DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); |
1574 | break; | 1574 | break; |
1575 | case ATOM_TV_PALN: | 1575 | case ATOM_TV_PALN: |
1576 | tv_std = TV_STD_PAL_N; | 1576 | tv_std = TV_STD_PAL_N; |
1577 | DRM_INFO("Default TV standard: PAL-N\n"); | 1577 | DRM_DEBUG_KMS("Default TV standard: PAL-N\n"); |
1578 | break; | 1578 | break; |
1579 | case ATOM_TV_PALCN: | 1579 | case ATOM_TV_PALCN: |
1580 | tv_std = TV_STD_PAL_CN; | 1580 | tv_std = TV_STD_PAL_CN; |
1581 | DRM_INFO("Default TV standard: PAL-CN\n"); | 1581 | DRM_DEBUG_KMS("Default TV standard: PAL-CN\n"); |
1582 | break; | 1582 | break; |
1583 | case ATOM_TV_PAL60: | 1583 | case ATOM_TV_PAL60: |
1584 | tv_std = TV_STD_PAL_60; | 1584 | tv_std = TV_STD_PAL_60; |
1585 | DRM_INFO("Default TV standard: PAL-60\n"); | 1585 | DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); |
1586 | break; | 1586 | break; |
1587 | case ATOM_TV_SECAM: | 1587 | case ATOM_TV_SECAM: |
1588 | tv_std = TV_STD_SECAM; | 1588 | tv_std = TV_STD_SECAM; |
1589 | DRM_INFO("Default TV standard: SECAM\n"); | 1589 | DRM_DEBUG_KMS("Default TV standard: SECAM\n"); |
1590 | break; | 1590 | break; |
1591 | default: | 1591 | default: |
1592 | tv_std = TV_STD_NTSC; | 1592 | tv_std = TV_STD_NTSC; |
1593 | DRM_INFO("Unknown TV standard; defaulting to NTSC\n"); | 1593 | DRM_DEBUG_KMS("Unknown TV standard; defaulting to NTSC\n"); |
1594 | break; | 1594 | break; |
1595 | } | 1595 | } |
1596 | } | 1596 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c index a04b7a6ad95f..7b7ea269549c 100644 --- a/drivers/gpu/drm/radeon/radeon_combios.c +++ b/drivers/gpu/drm/radeon/radeon_combios.c | |||
@@ -913,47 +913,47 @@ radeon_combios_get_tv_info(struct radeon_device *rdev) | |||
913 | switch (RBIOS8(tv_info + 7) & 0xf) { | 913 | switch (RBIOS8(tv_info + 7) & 0xf) { |
914 | case 1: | 914 | case 1: |
915 | tv_std = TV_STD_NTSC; | 915 | tv_std = TV_STD_NTSC; |
916 | DRM_INFO("Default TV standard: NTSC\n"); | 916 | DRM_DEBUG_KMS("Default TV standard: NTSC\n"); |
917 | break; | 917 | break; |
918 | case 2: | 918 | case 2: |
919 | tv_std = TV_STD_PAL; | 919 | tv_std = TV_STD_PAL; |
920 | DRM_INFO("Default TV standard: PAL\n"); | 920 | DRM_DEBUG_KMS("Default TV standard: PAL\n"); |
921 | break; | 921 | break; |
922 | case 3: | 922 | case 3: |
923 | tv_std = TV_STD_PAL_M; | 923 | tv_std = TV_STD_PAL_M; |
924 | DRM_INFO("Default TV standard: PAL-M\n"); | 924 | DRM_DEBUG_KMS("Default TV standard: PAL-M\n"); |
925 | break; | 925 | break; |
926 | case 4: | 926 | case 4: |
927 | tv_std = TV_STD_PAL_60; | 927 | tv_std = TV_STD_PAL_60; |
928 | DRM_INFO("Default TV standard: PAL-60\n"); | 928 | DRM_DEBUG_KMS("Default TV standard: PAL-60\n"); |
929 | break; | 929 | break; |
930 | case 5: | 930 | case 5: |
931 | tv_std = TV_STD_NTSC_J; | 931 | tv_std = TV_STD_NTSC_J; |
932 | DRM_INFO("Default TV standard: NTSC-J\n"); | 932 | DRM_DEBUG_KMS("Default TV standard: NTSC-J\n"); |
933 | break; | 933 | break; |
934 | case 6: | 934 | case 6: |
935 | tv_std = TV_STD_SCART_PAL; | 935 | tv_std = TV_STD_SCART_PAL; |
936 | DRM_INFO("Default TV standard: SCART-PAL\n"); | 936 | DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n"); |
937 | break; | 937 | break; |
938 | default: | 938 | default: |
939 | tv_std = TV_STD_NTSC; | 939 | tv_std = TV_STD_NTSC; |
940 | DRM_INFO | 940 | DRM_DEBUG_KMS |
941 | ("Unknown TV standard; defaulting to NTSC\n"); | 941 | ("Unknown TV standard; defaulting to NTSC\n"); |
942 | break; | 942 | break; |
943 | } | 943 | } |
944 | 944 | ||
945 | switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { | 945 | switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) { |
946 | case 0: | 946 | case 0: |
947 | DRM_INFO("29.498928713 MHz TV ref clk\n"); | 947 | DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n"); |
948 | break; | 948 | break; |
949 | case 1: | 949 | case 1: |
950 | DRM_INFO("28.636360000 MHz TV ref clk\n"); | 950 | DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n"); |
951 | break; | 951 | break; |
952 | case 2: | 952 | case 2: |
953 | DRM_INFO("14.318180000 MHz TV ref clk\n"); | 953 | DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n"); |
954 | break; | 954 | break; |
955 | case 3: | 955 | case 3: |
956 | DRM_INFO("27.000000000 MHz TV ref clk\n"); | 956 | DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n"); |
957 | break; | 957 | break; |
958 | default: | 958 | default: |
959 | break; | 959 | break; |
@@ -1324,7 +1324,7 @@ bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, | |||
1324 | 1324 | ||
1325 | if (tmds_info) { | 1325 | if (tmds_info) { |
1326 | ver = RBIOS8(tmds_info); | 1326 | ver = RBIOS8(tmds_info); |
1327 | DRM_INFO("DFP table revision: %d\n", ver); | 1327 | DRM_DEBUG_KMS("DFP table revision: %d\n", ver); |
1328 | if (ver == 3) { | 1328 | if (ver == 3) { |
1329 | n = RBIOS8(tmds_info + 5) + 1; | 1329 | n = RBIOS8(tmds_info + 5) + 1; |
1330 | if (n > 4) | 1330 | if (n > 4) |
@@ -1408,7 +1408,7 @@ bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder | |||
1408 | offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); | 1408 | offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); |
1409 | if (offset) { | 1409 | if (offset) { |
1410 | ver = RBIOS8(offset); | 1410 | ver = RBIOS8(offset); |
1411 | DRM_INFO("External TMDS Table revision: %d\n", ver); | 1411 | DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver); |
1412 | tmds->slave_addr = RBIOS8(offset + 4 + 2); | 1412 | tmds->slave_addr = RBIOS8(offset + 4 + 2); |
1413 | tmds->slave_addr >>= 1; /* 7 bit addressing */ | 1413 | tmds->slave_addr >>= 1; /* 7 bit addressing */ |
1414 | gpio = RBIOS8(offset + 4 + 3); | 1414 | gpio = RBIOS8(offset + 4 + 3); |
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c index 5731fc9b1ae3..3eef567b0421 100644 --- a/drivers/gpu/drm/radeon/radeon_cursor.c +++ b/drivers/gpu/drm/radeon/radeon_cursor.c | |||
@@ -203,6 +203,7 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc, | |||
203 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); | 203 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
204 | struct radeon_device *rdev = crtc->dev->dev_private; | 204 | struct radeon_device *rdev = crtc->dev->dev_private; |
205 | int xorigin = 0, yorigin = 0; | 205 | int xorigin = 0, yorigin = 0; |
206 | int w = radeon_crtc->cursor_width; | ||
206 | 207 | ||
207 | if (x < 0) | 208 | if (x < 0) |
208 | xorigin = -x + 1; | 209 | xorigin = -x + 1; |
@@ -213,22 +214,7 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc, | |||
213 | if (yorigin >= CURSOR_HEIGHT) | 214 | if (yorigin >= CURSOR_HEIGHT) |
214 | yorigin = CURSOR_HEIGHT - 1; | 215 | yorigin = CURSOR_HEIGHT - 1; |
215 | 216 | ||
216 | radeon_lock_cursor(crtc, true); | 217 | if (ASIC_IS_AVIVO(rdev)) { |
217 | if (ASIC_IS_DCE4(rdev)) { | ||
218 | /* cursors are offset into the total surface */ | ||
219 | x += crtc->x; | ||
220 | y += crtc->y; | ||
221 | DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y); | ||
222 | |||
223 | /* XXX: check if evergreen has the same issues as avivo chips */ | ||
224 | WREG32(EVERGREEN_CUR_POSITION + radeon_crtc->crtc_offset, | ||
225 | ((xorigin ? 0 : x) << 16) | | ||
226 | (yorigin ? 0 : y)); | ||
227 | WREG32(EVERGREEN_CUR_HOT_SPOT + radeon_crtc->crtc_offset, (xorigin << 16) | yorigin); | ||
228 | WREG32(EVERGREEN_CUR_SIZE + radeon_crtc->crtc_offset, | ||
229 | ((radeon_crtc->cursor_width - 1) << 16) | (radeon_crtc->cursor_height - 1)); | ||
230 | } else if (ASIC_IS_AVIVO(rdev)) { | ||
231 | int w = radeon_crtc->cursor_width; | ||
232 | int i = 0; | 218 | int i = 0; |
233 | struct drm_crtc *crtc_p; | 219 | struct drm_crtc *crtc_p; |
234 | 220 | ||
@@ -260,7 +246,17 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc, | |||
260 | if (w <= 0) | 246 | if (w <= 0) |
261 | w = 1; | 247 | w = 1; |
262 | } | 248 | } |
249 | } | ||
263 | 250 | ||
251 | radeon_lock_cursor(crtc, true); | ||
252 | if (ASIC_IS_DCE4(rdev)) { | ||
253 | WREG32(EVERGREEN_CUR_POSITION + radeon_crtc->crtc_offset, | ||
254 | ((xorigin ? 0 : x) << 16) | | ||
255 | (yorigin ? 0 : y)); | ||
256 | WREG32(EVERGREEN_CUR_HOT_SPOT + radeon_crtc->crtc_offset, (xorigin << 16) | yorigin); | ||
257 | WREG32(EVERGREEN_CUR_SIZE + radeon_crtc->crtc_offset, | ||
258 | ((w - 1) << 16) | (radeon_crtc->cursor_height - 1)); | ||
259 | } else if (ASIC_IS_AVIVO(rdev)) { | ||
264 | WREG32(AVIVO_D1CUR_POSITION + radeon_crtc->crtc_offset, | 260 | WREG32(AVIVO_D1CUR_POSITION + radeon_crtc->crtc_offset, |
265 | ((xorigin ? 0 : x) << 16) | | 261 | ((xorigin ? 0 : x) << 16) | |
266 | (yorigin ? 0 : y)); | 262 | (yorigin ? 0 : y)); |
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c index 9cdf6a35bc2c..40b0c087b592 100644 --- a/drivers/gpu/drm/radeon/radeon_fb.c +++ b/drivers/gpu/drm/radeon/radeon_fb.c | |||
@@ -97,7 +97,6 @@ static void radeonfb_destroy_pinned_object(struct drm_gem_object *gobj) | |||
97 | radeon_bo_unpin(rbo); | 97 | radeon_bo_unpin(rbo); |
98 | radeon_bo_unreserve(rbo); | 98 | radeon_bo_unreserve(rbo); |
99 | } | 99 | } |
100 | drm_gem_object_handle_unreference(gobj); | ||
101 | drm_gem_object_unreference_unlocked(gobj); | 100 | drm_gem_object_unreference_unlocked(gobj); |
102 | } | 101 | } |
103 | 102 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 0afd1e62347d..b3b5306bb578 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c | |||
@@ -69,7 +69,7 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) | |||
69 | u32 c = 0; | 69 | u32 c = 0; |
70 | 70 | ||
71 | rbo->placement.fpfn = 0; | 71 | rbo->placement.fpfn = 0; |
72 | rbo->placement.lpfn = 0; | 72 | rbo->placement.lpfn = rbo->rdev->mc.active_vram_size >> PAGE_SHIFT; |
73 | rbo->placement.placement = rbo->placements; | 73 | rbo->placement.placement = rbo->placements; |
74 | rbo->placement.busy_placement = rbo->placements; | 74 | rbo->placement.busy_placement = rbo->placements; |
75 | if (domain & RADEON_GEM_DOMAIN_VRAM) | 75 | if (domain & RADEON_GEM_DOMAIN_VRAM) |
diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h index 353998dc2c03..3481bc7f6f58 100644 --- a/drivers/gpu/drm/radeon/radeon_object.h +++ b/drivers/gpu/drm/radeon/radeon_object.h | |||
@@ -124,11 +124,8 @@ static inline int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type, | |||
124 | int r; | 124 | int r; |
125 | 125 | ||
126 | r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0); | 126 | r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0); |
127 | if (unlikely(r != 0)) { | 127 | if (unlikely(r != 0)) |
128 | if (r != -ERESTARTSYS) | ||
129 | dev_err(bo->rdev->dev, "%p reserve failed for wait\n", bo); | ||
130 | return r; | 128 | return r; |
131 | } | ||
132 | spin_lock(&bo->tbo.lock); | 129 | spin_lock(&bo->tbo.lock); |
133 | if (mem_type) | 130 | if (mem_type) |
134 | *mem_type = bo->tbo.mem.mem_type; | 131 | *mem_type = bo->tbo.mem.mem_type; |
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c index cc05b230d7ef..51d5f7b5ab21 100644 --- a/drivers/gpu/drm/radeon/rs600.c +++ b/drivers/gpu/drm/radeon/rs600.c | |||
@@ -693,6 +693,7 @@ void rs600_mc_init(struct radeon_device *rdev) | |||
693 | rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE); | 693 | rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE); |
694 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; | 694 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; |
695 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 695 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
696 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
696 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); | 697 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); |
697 | base = RREG32_MC(R_000004_MC_FB_LOCATION); | 698 | base = RREG32_MC(R_000004_MC_FB_LOCATION); |
698 | base = G_000004_MC_FB_START(base) << 16; | 699 | base = G_000004_MC_FB_START(base) << 16; |
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c index 3e3f75718be3..4dc2a87ea680 100644 --- a/drivers/gpu/drm/radeon/rs690.c +++ b/drivers/gpu/drm/radeon/rs690.c | |||
@@ -157,6 +157,7 @@ void rs690_mc_init(struct radeon_device *rdev) | |||
157 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); | 157 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); |
158 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); | 158 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); |
159 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 159 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
160 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
160 | base = RREG32_MC(R_000100_MCCFG_FB_LOCATION); | 161 | base = RREG32_MC(R_000100_MCCFG_FB_LOCATION); |
161 | base = G_000100_MC_FB_START(base) << 16; | 162 | base = G_000100_MC_FB_START(base) << 16; |
162 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); | 163 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); |
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c index bfa59db374d2..9490da700749 100644 --- a/drivers/gpu/drm/radeon/rv770.c +++ b/drivers/gpu/drm/radeon/rv770.c | |||
@@ -267,6 +267,7 @@ static void rv770_mc_program(struct radeon_device *rdev) | |||
267 | */ | 267 | */ |
268 | void r700_cp_stop(struct radeon_device *rdev) | 268 | void r700_cp_stop(struct radeon_device *rdev) |
269 | { | 269 | { |
270 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
270 | WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT)); | 271 | WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT)); |
271 | } | 272 | } |
272 | 273 | ||
@@ -992,6 +993,7 @@ int rv770_mc_init(struct radeon_device *rdev) | |||
992 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); | 993 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); |
993 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); | 994 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); |
994 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 995 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
996 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
995 | r600_vram_gtt_location(rdev, &rdev->mc); | 997 | r600_vram_gtt_location(rdev, &rdev->mc); |
996 | radeon_update_bandwidth_info(rdev); | 998 | radeon_update_bandwidth_info(rdev); |
997 | 999 | ||
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index cb4cf7ef4d1e..db809e034cc4 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -442,6 +442,43 @@ out_err: | |||
442 | } | 442 | } |
443 | 443 | ||
444 | /** | 444 | /** |
445 | * Call bo::reserved and with the lru lock held. | ||
446 | * Will release GPU memory type usage on destruction. | ||
447 | * This is the place to put in driver specific hooks. | ||
448 | * Will release the bo::reserved lock and the | ||
449 | * lru lock on exit. | ||
450 | */ | ||
451 | |||
452 | static void ttm_bo_cleanup_memtype_use(struct ttm_buffer_object *bo) | ||
453 | { | ||
454 | struct ttm_bo_global *glob = bo->glob; | ||
455 | |||
456 | if (bo->ttm) { | ||
457 | |||
458 | /** | ||
459 | * Release the lru_lock, since we don't want to have | ||
460 | * an atomic requirement on ttm_tt[unbind|destroy]. | ||
461 | */ | ||
462 | |||
463 | spin_unlock(&glob->lru_lock); | ||
464 | ttm_tt_unbind(bo->ttm); | ||
465 | ttm_tt_destroy(bo->ttm); | ||
466 | bo->ttm = NULL; | ||
467 | spin_lock(&glob->lru_lock); | ||
468 | } | ||
469 | |||
470 | if (bo->mem.mm_node) { | ||
471 | drm_mm_put_block(bo->mem.mm_node); | ||
472 | bo->mem.mm_node = NULL; | ||
473 | } | ||
474 | |||
475 | atomic_set(&bo->reserved, 0); | ||
476 | wake_up_all(&bo->event_queue); | ||
477 | spin_unlock(&glob->lru_lock); | ||
478 | } | ||
479 | |||
480 | |||
481 | /** | ||
445 | * If bo idle, remove from delayed- and lru lists, and unref. | 482 | * If bo idle, remove from delayed- and lru lists, and unref. |
446 | * If not idle, and already on delayed list, do nothing. | 483 | * If not idle, and already on delayed list, do nothing. |
447 | * If not idle, and not on delayed list, put on delayed list, | 484 | * If not idle, and not on delayed list, put on delayed list, |
@@ -456,6 +493,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all) | |||
456 | int ret; | 493 | int ret; |
457 | 494 | ||
458 | spin_lock(&bo->lock); | 495 | spin_lock(&bo->lock); |
496 | retry: | ||
459 | (void) ttm_bo_wait(bo, false, false, !remove_all); | 497 | (void) ttm_bo_wait(bo, false, false, !remove_all); |
460 | 498 | ||
461 | if (!bo->sync_obj) { | 499 | if (!bo->sync_obj) { |
@@ -464,31 +502,52 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all) | |||
464 | spin_unlock(&bo->lock); | 502 | spin_unlock(&bo->lock); |
465 | 503 | ||
466 | spin_lock(&glob->lru_lock); | 504 | spin_lock(&glob->lru_lock); |
467 | put_count = ttm_bo_del_from_lru(bo); | 505 | ret = ttm_bo_reserve_locked(bo, false, !remove_all, false, 0); |
506 | |||
507 | /** | ||
508 | * Someone else has the object reserved. Bail and retry. | ||
509 | */ | ||
468 | 510 | ||
469 | ret = ttm_bo_reserve_locked(bo, false, false, false, 0); | 511 | if (unlikely(ret == -EBUSY)) { |
470 | BUG_ON(ret); | 512 | spin_unlock(&glob->lru_lock); |
471 | if (bo->ttm) | 513 | spin_lock(&bo->lock); |
472 | ttm_tt_unbind(bo->ttm); | 514 | goto requeue; |
515 | } | ||
516 | |||
517 | /** | ||
518 | * We can re-check for sync object without taking | ||
519 | * the bo::lock since setting the sync object requires | ||
520 | * also bo::reserved. A busy object at this point may | ||
521 | * be caused by another thread starting an accelerated | ||
522 | * eviction. | ||
523 | */ | ||
524 | |||
525 | if (unlikely(bo->sync_obj)) { | ||
526 | atomic_set(&bo->reserved, 0); | ||
527 | wake_up_all(&bo->event_queue); | ||
528 | spin_unlock(&glob->lru_lock); | ||
529 | spin_lock(&bo->lock); | ||
530 | if (remove_all) | ||
531 | goto retry; | ||
532 | else | ||
533 | goto requeue; | ||
534 | } | ||
535 | |||
536 | put_count = ttm_bo_del_from_lru(bo); | ||
473 | 537 | ||
474 | if (!list_empty(&bo->ddestroy)) { | 538 | if (!list_empty(&bo->ddestroy)) { |
475 | list_del_init(&bo->ddestroy); | 539 | list_del_init(&bo->ddestroy); |
476 | ++put_count; | 540 | ++put_count; |
477 | } | 541 | } |
478 | if (bo->mem.mm_node) { | ||
479 | drm_mm_put_block(bo->mem.mm_node); | ||
480 | bo->mem.mm_node = NULL; | ||
481 | } | ||
482 | spin_unlock(&glob->lru_lock); | ||
483 | 542 | ||
484 | atomic_set(&bo->reserved, 0); | 543 | ttm_bo_cleanup_memtype_use(bo); |
485 | 544 | ||
486 | while (put_count--) | 545 | while (put_count--) |
487 | kref_put(&bo->list_kref, ttm_bo_ref_bug); | 546 | kref_put(&bo->list_kref, ttm_bo_ref_bug); |
488 | 547 | ||
489 | return 0; | 548 | return 0; |
490 | } | 549 | } |
491 | 550 | requeue: | |
492 | spin_lock(&glob->lru_lock); | 551 | spin_lock(&glob->lru_lock); |
493 | if (list_empty(&bo->ddestroy)) { | 552 | if (list_empty(&bo->ddestroy)) { |
494 | void *sync_obj = bo->sync_obj; | 553 | void *sync_obj = bo->sync_obj; |
diff --git a/drivers/hid/hid-cando.c b/drivers/hid/hid-cando.c index 4267a6fdc277..5925bdcd417d 100644 --- a/drivers/hid/hid-cando.c +++ b/drivers/hid/hid-cando.c | |||
@@ -237,6 +237,8 @@ static const struct hid_device_id cando_devices[] = { | |||
237 | USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, | 237 | USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
238 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, | 238 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, |
239 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, | 239 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, |
240 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, | ||
241 | USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, | ||
240 | { } | 242 | { } |
241 | }; | 243 | }; |
242 | MODULE_DEVICE_TABLE(hid, cando_devices); | 244 | MODULE_DEVICE_TABLE(hid, cando_devices); |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 3f7292486024..a0dea3d1296e 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1292,6 +1292,7 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1292 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, | 1292 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, |
1293 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, | 1293 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
1294 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, | 1294 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, |
1295 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, | ||
1295 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, | 1296 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, |
1296 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, | 1297 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, |
1297 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, | 1298 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 765a4f53eb5c..c5ae5f1545bd 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -134,6 +134,7 @@ | |||
134 | #define USB_VENDOR_ID_CANDO 0x2087 | 134 | #define USB_VENDOR_ID_CANDO 0x2087 |
135 | #define USB_DEVICE_ID_CANDO_MULTI_TOUCH 0x0a01 | 135 | #define USB_DEVICE_ID_CANDO_MULTI_TOUCH 0x0a01 |
136 | #define USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6 0x0b03 | 136 | #define USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6 0x0b03 |
137 | #define USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6 0x0f01 | ||
137 | 138 | ||
138 | #define USB_VENDOR_ID_CH 0x068e | 139 | #define USB_VENDOR_ID_CH 0x068e |
139 | #define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2 | 140 | #define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2 |
@@ -503,6 +504,7 @@ | |||
503 | 504 | ||
504 | #define USB_VENDOR_ID_TURBOX 0x062a | 505 | #define USB_VENDOR_ID_TURBOX 0x062a |
505 | #define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201 | 506 | #define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201 |
507 | #define USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART 0x7100 | ||
506 | 508 | ||
507 | #define USB_VENDOR_ID_TWINHAN 0x6253 | 509 | #define USB_VENDOR_ID_TWINHAN 0x6253 |
508 | #define USB_DEVICE_ID_TWINHAN_IR_REMOTE 0x0100 | 510 | #define USB_DEVICE_ID_TWINHAN_IR_REMOTE 0x0100 |
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 47d70c523d93..a3866b5c0c43 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -109,6 +109,12 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t | |||
109 | int ret = 0; | 109 | int ret = 0; |
110 | 110 | ||
111 | mutex_lock(&minors_lock); | 111 | mutex_lock(&minors_lock); |
112 | |||
113 | if (!hidraw_table[minor]) { | ||
114 | ret = -ENODEV; | ||
115 | goto out; | ||
116 | } | ||
117 | |||
112 | dev = hidraw_table[minor]->hid; | 118 | dev = hidraw_table[minor]->hid; |
113 | 119 | ||
114 | if (!dev->hid_output_raw_report) { | 120 | if (!dev->hid_output_raw_report) { |
@@ -244,6 +250,10 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, | |||
244 | 250 | ||
245 | mutex_lock(&minors_lock); | 251 | mutex_lock(&minors_lock); |
246 | dev = hidraw_table[minor]; | 252 | dev = hidraw_table[minor]; |
253 | if (!dev) { | ||
254 | ret = -ENODEV; | ||
255 | goto out; | ||
256 | } | ||
247 | 257 | ||
248 | switch (cmd) { | 258 | switch (cmd) { |
249 | case HIDIOCGRDESCSIZE: | 259 | case HIDIOCGRDESCSIZE: |
@@ -317,6 +327,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, | |||
317 | 327 | ||
318 | ret = -ENOTTY; | 328 | ret = -ENOTTY; |
319 | } | 329 | } |
330 | out: | ||
320 | mutex_unlock(&minors_lock); | 331 | mutex_unlock(&minors_lock); |
321 | return ret; | 332 | return ret; |
322 | } | 333 | } |
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 70da3181c8a0..f0260c699adb 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
@@ -36,6 +36,7 @@ static const struct hid_blacklist { | |||
36 | { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER, HID_QUIRK_MULTI_INPUT | HID_QUIRK_NOGET }, | 36 | { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER, HID_QUIRK_MULTI_INPUT | HID_QUIRK_NOGET }, |
37 | { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH, HID_QUIRK_MULTI_INPUT }, | 37 | { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH, HID_QUIRK_MULTI_INPUT }, |
38 | { USB_VENDOR_ID_MOJO, USB_DEVICE_ID_RETRO_ADAPTER, HID_QUIRK_MULTI_INPUT }, | 38 | { USB_VENDOR_ID_MOJO, USB_DEVICE_ID_RETRO_ADAPTER, HID_QUIRK_MULTI_INPUT }, |
39 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART, HID_QUIRK_MULTI_INPUT }, | ||
39 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 40 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
40 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 41 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
41 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 42 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c index f7bd2613cecc..f2de3be35df3 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c | |||
@@ -677,6 +677,11 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev, | |||
677 | dev_dbg(&ofdev->dev, "hw routines for %s registered.\n", | 677 | dev_dbg(&ofdev->dev, "hw routines for %s registered.\n", |
678 | cpm->adap.name); | 678 | cpm->adap.name); |
679 | 679 | ||
680 | /* | ||
681 | * register OF I2C devices | ||
682 | */ | ||
683 | of_i2c_register_devices(&cpm->adap); | ||
684 | |||
680 | return 0; | 685 | return 0; |
681 | out_shut: | 686 | out_shut: |
682 | cpm_i2c_shutdown(cpm); | 687 | cpm_i2c_shutdown(cpm); |
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index b8feac5f2ef4..5795c8398c7c 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c | |||
@@ -331,21 +331,16 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) | |||
331 | INIT_COMPLETION(dev->cmd_complete); | 331 | INIT_COMPLETION(dev->cmd_complete); |
332 | dev->cmd_err = 0; | 332 | dev->cmd_err = 0; |
333 | 333 | ||
334 | /* Take I2C out of reset, configure it as master and set the | 334 | /* Take I2C out of reset and configure it as master */ |
335 | * start bit */ | 335 | flag = DAVINCI_I2C_MDR_IRS | DAVINCI_I2C_MDR_MST; |
336 | flag = DAVINCI_I2C_MDR_IRS | DAVINCI_I2C_MDR_MST | DAVINCI_I2C_MDR_STT; | ||
337 | 336 | ||
338 | /* if the slave address is ten bit address, enable XA bit */ | 337 | /* if the slave address is ten bit address, enable XA bit */ |
339 | if (msg->flags & I2C_M_TEN) | 338 | if (msg->flags & I2C_M_TEN) |
340 | flag |= DAVINCI_I2C_MDR_XA; | 339 | flag |= DAVINCI_I2C_MDR_XA; |
341 | if (!(msg->flags & I2C_M_RD)) | 340 | if (!(msg->flags & I2C_M_RD)) |
342 | flag |= DAVINCI_I2C_MDR_TRX; | 341 | flag |= DAVINCI_I2C_MDR_TRX; |
343 | if (stop) | 342 | if (msg->len == 0) |
344 | flag |= DAVINCI_I2C_MDR_STP; | ||
345 | if (msg->len == 0) { | ||
346 | flag |= DAVINCI_I2C_MDR_RM; | 343 | flag |= DAVINCI_I2C_MDR_RM; |
347 | flag &= ~DAVINCI_I2C_MDR_STP; | ||
348 | } | ||
349 | 344 | ||
350 | /* Enable receive or transmit interrupts */ | 345 | /* Enable receive or transmit interrupts */ |
351 | w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG); | 346 | w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG); |
@@ -358,17 +353,28 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) | |||
358 | dev->terminate = 0; | 353 | dev->terminate = 0; |
359 | 354 | ||
360 | /* | 355 | /* |
356 | * Write mode register first as needed for correct behaviour | ||
357 | * on OMAP-L138, but don't set STT yet to avoid a race with XRDY | ||
358 | * occuring before we have loaded DXR | ||
359 | */ | ||
360 | davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); | ||
361 | |||
362 | /* | ||
361 | * First byte should be set here, not after interrupt, | 363 | * First byte should be set here, not after interrupt, |
362 | * because transmit-data-ready interrupt can come before | 364 | * because transmit-data-ready interrupt can come before |
363 | * NACK-interrupt during sending of previous message and | 365 | * NACK-interrupt during sending of previous message and |
364 | * ICDXR may have wrong data | 366 | * ICDXR may have wrong data |
367 | * It also saves us one interrupt, slightly faster | ||
365 | */ | 368 | */ |
366 | if ((!(msg->flags & I2C_M_RD)) && dev->buf_len) { | 369 | if ((!(msg->flags & I2C_M_RD)) && dev->buf_len) { |
367 | davinci_i2c_write_reg(dev, DAVINCI_I2C_DXR_REG, *dev->buf++); | 370 | davinci_i2c_write_reg(dev, DAVINCI_I2C_DXR_REG, *dev->buf++); |
368 | dev->buf_len--; | 371 | dev->buf_len--; |
369 | } | 372 | } |
370 | 373 | ||
371 | /* write the data into mode register; start transmitting */ | 374 | /* Set STT to begin transmit now DXR is loaded */ |
375 | flag |= DAVINCI_I2C_MDR_STT; | ||
376 | if (stop && msg->len != 0) | ||
377 | flag |= DAVINCI_I2C_MDR_STP; | ||
372 | davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); | 378 | davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); |
373 | 379 | ||
374 | r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, | 380 | r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index 43ca32fddde2..89eedf45d30e 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -761,6 +761,9 @@ static int __devinit iic_probe(struct platform_device *ofdev, | |||
761 | dev_info(&ofdev->dev, "using %s mode\n", | 761 | dev_info(&ofdev->dev, "using %s mode\n", |
762 | dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)"); | 762 | dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)"); |
763 | 763 | ||
764 | /* Now register all the child nodes */ | ||
765 | of_i2c_register_devices(adap); | ||
766 | |||
764 | return 0; | 767 | return 0; |
765 | 768 | ||
766 | error_cleanup: | 769 | error_cleanup: |
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index d1ff9408dc1f..4c2a62b75b5c 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -159,15 +159,9 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy) | |||
159 | 159 | ||
160 | static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx) | 160 | static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx) |
161 | { | 161 | { |
162 | int result; | 162 | wait_event_timeout(i2c_imx->queue, i2c_imx->i2csr & I2SR_IIF, HZ / 10); |
163 | |||
164 | result = wait_event_interruptible_timeout(i2c_imx->queue, | ||
165 | i2c_imx->i2csr & I2SR_IIF, HZ / 10); | ||
166 | 163 | ||
167 | if (unlikely(result < 0)) { | 164 | if (unlikely(!(i2c_imx->i2csr & I2SR_IIF))) { |
168 | dev_dbg(&i2c_imx->adapter.dev, "<%s> result < 0\n", __func__); | ||
169 | return result; | ||
170 | } else if (unlikely(!(i2c_imx->i2csr & I2SR_IIF))) { | ||
171 | dev_dbg(&i2c_imx->adapter.dev, "<%s> Timeout\n", __func__); | 165 | dev_dbg(&i2c_imx->adapter.dev, "<%s> Timeout\n", __func__); |
172 | return -ETIMEDOUT; | 166 | return -ETIMEDOUT; |
173 | } | 167 | } |
@@ -295,7 +289,7 @@ static irqreturn_t i2c_imx_isr(int irq, void *dev_id) | |||
295 | i2c_imx->i2csr = temp; | 289 | i2c_imx->i2csr = temp; |
296 | temp &= ~I2SR_IIF; | 290 | temp &= ~I2SR_IIF; |
297 | writeb(temp, i2c_imx->base + IMX_I2C_I2SR); | 291 | writeb(temp, i2c_imx->base + IMX_I2C_I2SR); |
298 | wake_up_interruptible(&i2c_imx->queue); | 292 | wake_up(&i2c_imx->queue); |
299 | return IRQ_HANDLED; | 293 | return IRQ_HANDLED; |
300 | } | 294 | } |
301 | 295 | ||
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index a1c419a716af..b74e6dc6886c 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -632,6 +632,7 @@ static int __devinit fsl_i2c_probe(struct platform_device *op, | |||
632 | dev_err(i2c->dev, "failed to add adapter\n"); | 632 | dev_err(i2c->dev, "failed to add adapter\n"); |
633 | goto fail_add; | 633 | goto fail_add; |
634 | } | 634 | } |
635 | of_i2c_register_devices(&i2c->adap); | ||
635 | 636 | ||
636 | return result; | 637 | return result; |
637 | 638 | ||
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c index bbd77603a417..29933f87d8fa 100644 --- a/drivers/i2c/busses/i2c-pca-isa.c +++ b/drivers/i2c/busses/i2c-pca-isa.c | |||
@@ -71,8 +71,8 @@ static int pca_isa_readbyte(void *pd, int reg) | |||
71 | 71 | ||
72 | static int pca_isa_waitforcompletion(void *pd) | 72 | static int pca_isa_waitforcompletion(void *pd) |
73 | { | 73 | { |
74 | long ret = ~0; | ||
75 | unsigned long timeout; | 74 | unsigned long timeout; |
75 | long ret; | ||
76 | 76 | ||
77 | if (irq > -1) { | 77 | if (irq > -1) { |
78 | ret = wait_event_timeout(pca_wait, | 78 | ret = wait_event_timeout(pca_wait, |
@@ -81,11 +81,15 @@ static int pca_isa_waitforcompletion(void *pd) | |||
81 | } else { | 81 | } else { |
82 | /* Do polling */ | 82 | /* Do polling */ |
83 | timeout = jiffies + pca_isa_ops.timeout; | 83 | timeout = jiffies + pca_isa_ops.timeout; |
84 | while (((pca_isa_readbyte(pd, I2C_PCA_CON) | 84 | do { |
85 | & I2C_PCA_CON_SI) == 0) | 85 | ret = time_before(jiffies, timeout); |
86 | && (ret = time_before(jiffies, timeout))) | 86 | if (pca_isa_readbyte(pd, I2C_PCA_CON) |
87 | & I2C_PCA_CON_SI) | ||
88 | break; | ||
87 | udelay(100); | 89 | udelay(100); |
90 | } while (ret); | ||
88 | } | 91 | } |
92 | |||
89 | return ret > 0; | 93 | return ret > 0; |
90 | } | 94 | } |
91 | 95 | ||
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c index ef5c78487eb7..5f6d7f89e225 100644 --- a/drivers/i2c/busses/i2c-pca-platform.c +++ b/drivers/i2c/busses/i2c-pca-platform.c | |||
@@ -80,8 +80,8 @@ static void i2c_pca_pf_writebyte32(void *pd, int reg, int val) | |||
80 | static int i2c_pca_pf_waitforcompletion(void *pd) | 80 | static int i2c_pca_pf_waitforcompletion(void *pd) |
81 | { | 81 | { |
82 | struct i2c_pca_pf_data *i2c = pd; | 82 | struct i2c_pca_pf_data *i2c = pd; |
83 | long ret = ~0; | ||
84 | unsigned long timeout; | 83 | unsigned long timeout; |
84 | long ret; | ||
85 | 85 | ||
86 | if (i2c->irq) { | 86 | if (i2c->irq) { |
87 | ret = wait_event_timeout(i2c->wait, | 87 | ret = wait_event_timeout(i2c->wait, |
@@ -90,10 +90,13 @@ static int i2c_pca_pf_waitforcompletion(void *pd) | |||
90 | } else { | 90 | } else { |
91 | /* Do polling */ | 91 | /* Do polling */ |
92 | timeout = jiffies + i2c->adap.timeout; | 92 | timeout = jiffies + i2c->adap.timeout; |
93 | while (((i2c->algo_data.read_byte(i2c, I2C_PCA_CON) | 93 | do { |
94 | & I2C_PCA_CON_SI) == 0) | 94 | ret = time_before(jiffies, timeout); |
95 | && (ret = time_before(jiffies, timeout))) | 95 | if (i2c->algo_data.read_byte(i2c, I2C_PCA_CON) |
96 | & I2C_PCA_CON_SI) | ||
97 | break; | ||
96 | udelay(100); | 98 | udelay(100); |
99 | } while (ret); | ||
97 | } | 100 | } |
98 | 101 | ||
99 | return ret > 0; | 102 | return ret > 0; |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 6649176de940..bea4c5021d26 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/idr.h> | 33 | #include <linux/idr.h> |
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | #include <linux/of_i2c.h> | ||
36 | #include <linux/of_device.h> | 35 | #include <linux/of_device.h> |
37 | #include <linux/completion.h> | 36 | #include <linux/completion.h> |
38 | #include <linux/hardirq.h> | 37 | #include <linux/hardirq.h> |
@@ -197,11 +196,12 @@ static int i2c_device_pm_suspend(struct device *dev) | |||
197 | { | 196 | { |
198 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 197 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
199 | 198 | ||
200 | if (pm_runtime_suspended(dev)) | 199 | if (pm) { |
201 | return 0; | 200 | if (pm_runtime_suspended(dev)) |
202 | 201 | return 0; | |
203 | if (pm) | 202 | else |
204 | return pm->suspend ? pm->suspend(dev) : 0; | 203 | return pm->suspend ? pm->suspend(dev) : 0; |
204 | } | ||
205 | 205 | ||
206 | return i2c_legacy_suspend(dev, PMSG_SUSPEND); | 206 | return i2c_legacy_suspend(dev, PMSG_SUSPEND); |
207 | } | 207 | } |
@@ -216,12 +216,6 @@ static int i2c_device_pm_resume(struct device *dev) | |||
216 | else | 216 | else |
217 | ret = i2c_legacy_resume(dev); | 217 | ret = i2c_legacy_resume(dev); |
218 | 218 | ||
219 | if (!ret) { | ||
220 | pm_runtime_disable(dev); | ||
221 | pm_runtime_set_active(dev); | ||
222 | pm_runtime_enable(dev); | ||
223 | } | ||
224 | |||
225 | return ret; | 219 | return ret; |
226 | } | 220 | } |
227 | 221 | ||
@@ -229,11 +223,12 @@ static int i2c_device_pm_freeze(struct device *dev) | |||
229 | { | 223 | { |
230 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 224 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
231 | 225 | ||
232 | if (pm_runtime_suspended(dev)) | 226 | if (pm) { |
233 | return 0; | 227 | if (pm_runtime_suspended(dev)) |
234 | 228 | return 0; | |
235 | if (pm) | 229 | else |
236 | return pm->freeze ? pm->freeze(dev) : 0; | 230 | return pm->freeze ? pm->freeze(dev) : 0; |
231 | } | ||
237 | 232 | ||
238 | return i2c_legacy_suspend(dev, PMSG_FREEZE); | 233 | return i2c_legacy_suspend(dev, PMSG_FREEZE); |
239 | } | 234 | } |
@@ -242,11 +237,12 @@ static int i2c_device_pm_thaw(struct device *dev) | |||
242 | { | 237 | { |
243 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 238 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
244 | 239 | ||
245 | if (pm_runtime_suspended(dev)) | 240 | if (pm) { |
246 | return 0; | 241 | if (pm_runtime_suspended(dev)) |
247 | 242 | return 0; | |
248 | if (pm) | 243 | else |
249 | return pm->thaw ? pm->thaw(dev) : 0; | 244 | return pm->thaw ? pm->thaw(dev) : 0; |
245 | } | ||
250 | 246 | ||
251 | return i2c_legacy_resume(dev); | 247 | return i2c_legacy_resume(dev); |
252 | } | 248 | } |
@@ -255,11 +251,12 @@ static int i2c_device_pm_poweroff(struct device *dev) | |||
255 | { | 251 | { |
256 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 252 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
257 | 253 | ||
258 | if (pm_runtime_suspended(dev)) | 254 | if (pm) { |
259 | return 0; | 255 | if (pm_runtime_suspended(dev)) |
260 | 256 | return 0; | |
261 | if (pm) | 257 | else |
262 | return pm->poweroff ? pm->poweroff(dev) : 0; | 258 | return pm->poweroff ? pm->poweroff(dev) : 0; |
259 | } | ||
263 | 260 | ||
264 | return i2c_legacy_suspend(dev, PMSG_HIBERNATE); | 261 | return i2c_legacy_suspend(dev, PMSG_HIBERNATE); |
265 | } | 262 | } |
@@ -876,9 +873,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
876 | if (adap->nr < __i2c_first_dynamic_bus_num) | 873 | if (adap->nr < __i2c_first_dynamic_bus_num) |
877 | i2c_scan_static_board_info(adap); | 874 | i2c_scan_static_board_info(adap); |
878 | 875 | ||
879 | /* Register devices from the device tree */ | ||
880 | of_i2c_register_devices(adap); | ||
881 | |||
882 | /* Notify drivers */ | 876 | /* Notify drivers */ |
883 | mutex_lock(&core_lock); | 877 | mutex_lock(&core_lock); |
884 | bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter); | 878 | bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter); |
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 0906fc5b69b9..cb3ccf3ed221 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c | |||
@@ -59,18 +59,11 @@ | |||
59 | #include <linux/hrtimer.h> /* ktime_get_real() */ | 59 | #include <linux/hrtimer.h> /* ktime_get_real() */ |
60 | #include <trace/events/power.h> | 60 | #include <trace/events/power.h> |
61 | #include <linux/sched.h> | 61 | #include <linux/sched.h> |
62 | #include <asm/mwait.h> | ||
62 | 63 | ||
63 | #define INTEL_IDLE_VERSION "0.4" | 64 | #define INTEL_IDLE_VERSION "0.4" |
64 | #define PREFIX "intel_idle: " | 65 | #define PREFIX "intel_idle: " |
65 | 66 | ||
66 | #define MWAIT_SUBSTATE_MASK (0xf) | ||
67 | #define MWAIT_CSTATE_MASK (0xf) | ||
68 | #define MWAIT_SUBSTATE_SIZE (4) | ||
69 | #define MWAIT_MAX_NUM_CSTATES 8 | ||
70 | #define CPUID_MWAIT_LEAF (5) | ||
71 | #define CPUID5_ECX_EXTENSIONS_SUPPORTED (0x1) | ||
72 | #define CPUID5_ECX_INTERRUPT_BREAK (0x2) | ||
73 | |||
74 | static struct cpuidle_driver intel_idle_driver = { | 67 | static struct cpuidle_driver intel_idle_driver = { |
75 | .name = "intel_idle", | 68 | .name = "intel_idle", |
76 | .owner = THIS_MODULE, | 69 | .owner = THIS_MODULE, |
@@ -157,13 +150,13 @@ static struct cpuidle_state atom_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
157 | { /* MWAIT C5 */ }, | 150 | { /* MWAIT C5 */ }, |
158 | { /* MWAIT C6 */ | 151 | { /* MWAIT C6 */ |
159 | .name = "ATM-C6", | 152 | .name = "ATM-C6", |
160 | .desc = "MWAIT 0x40", | 153 | .desc = "MWAIT 0x52", |
161 | .driver_data = (void *) 0x40, | 154 | .driver_data = (void *) 0x52, |
162 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, | 155 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, |
163 | .exit_latency = 200, | 156 | .exit_latency = 140, |
164 | .power_usage = 150, | 157 | .power_usage = 150, |
165 | .target_residency = 800, | 158 | .target_residency = 560, |
166 | .enter = NULL }, /* disabled */ | 159 | .enter = &intel_idle }, |
167 | }; | 160 | }; |
168 | 161 | ||
169 | /** | 162 | /** |
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index c908c5f83645..af9ee313c10b 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -28,7 +28,7 @@ struct evdev { | |||
28 | int minor; | 28 | int minor; |
29 | struct input_handle handle; | 29 | struct input_handle handle; |
30 | wait_queue_head_t wait; | 30 | wait_queue_head_t wait; |
31 | struct evdev_client *grab; | 31 | struct evdev_client __rcu *grab; |
32 | struct list_head client_list; | 32 | struct list_head client_list; |
33 | spinlock_t client_lock; /* protects client_list */ | 33 | spinlock_t client_lock; /* protects client_list */ |
34 | struct mutex mutex; | 34 | struct mutex mutex; |
@@ -669,6 +669,9 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, | |||
669 | 669 | ||
670 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) { | 670 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) { |
671 | 671 | ||
672 | if (!dev->absinfo) | ||
673 | return -EINVAL; | ||
674 | |||
672 | t = _IOC_NR(cmd) & ABS_MAX; | 675 | t = _IOC_NR(cmd) & ABS_MAX; |
673 | abs = dev->absinfo[t]; | 676 | abs = dev->absinfo[t]; |
674 | 677 | ||
@@ -680,10 +683,13 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, | |||
680 | } | 683 | } |
681 | } | 684 | } |
682 | 685 | ||
683 | if (_IOC_DIR(cmd) == _IOC_READ) { | 686 | if (_IOC_DIR(cmd) == _IOC_WRITE) { |
684 | 687 | ||
685 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) { | 688 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) { |
686 | 689 | ||
690 | if (!dev->absinfo) | ||
691 | return -EINVAL; | ||
692 | |||
687 | t = _IOC_NR(cmd) & ABS_MAX; | 693 | t = _IOC_NR(cmd) & ABS_MAX; |
688 | 694 | ||
689 | if (copy_from_user(&abs, p, min_t(size_t, | 695 | if (copy_from_user(&abs, p, min_t(size_t, |
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index d85bd8a7967d..22239e988498 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -483,6 +483,9 @@ static int joydev_handle_JSIOCSAXMAP(struct joydev *joydev, | |||
483 | 483 | ||
484 | memcpy(joydev->abspam, abspam, len); | 484 | memcpy(joydev->abspam, abspam, len); |
485 | 485 | ||
486 | for (i = 0; i < joydev->nabs; i++) | ||
487 | joydev->absmap[joydev->abspam[i]] = i; | ||
488 | |||
486 | out: | 489 | out: |
487 | kfree(abspam); | 490 | kfree(abspam); |
488 | return retval; | 491 | return retval; |
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index c19066479057..7e2c12a5b839 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c | |||
@@ -104,7 +104,7 @@ static int hp_sdc_rtc_do_read_bbrtc (struct rtc_time *rtctm) | |||
104 | t.endidx = 91; | 104 | t.endidx = 91; |
105 | t.seq = tseq; | 105 | t.seq = tseq; |
106 | t.act.semaphore = &tsem; | 106 | t.act.semaphore = &tsem; |
107 | init_MUTEX_LOCKED(&tsem); | 107 | sema_init(&tsem, 0); |
108 | 108 | ||
109 | if (hp_sdc_enqueue_transaction(&t)) return -1; | 109 | if (hp_sdc_enqueue_transaction(&t)) return -1; |
110 | 110 | ||
@@ -698,7 +698,7 @@ static int __init hp_sdc_rtc_init(void) | |||
698 | return -ENODEV; | 698 | return -ENODEV; |
699 | #endif | 699 | #endif |
700 | 700 | ||
701 | init_MUTEX(&i8042tregs); | 701 | sema_init(&i8042tregs, 1); |
702 | 702 | ||
703 | if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr))) | 703 | if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr))) |
704 | return ret; | 704 | return ret; |
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 0d4266a533a5..360698553eb5 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -404,6 +404,13 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu | |||
404 | retval = uinput_validate_absbits(dev); | 404 | retval = uinput_validate_absbits(dev); |
405 | if (retval < 0) | 405 | if (retval < 0) |
406 | goto exit; | 406 | goto exit; |
407 | if (test_bit(ABS_MT_SLOT, dev->absbit)) { | ||
408 | int nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1; | ||
409 | input_mt_create_slots(dev, nslot); | ||
410 | input_set_events_per_packet(dev, 6 * nslot); | ||
411 | } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) { | ||
412 | input_set_events_per_packet(dev, 60); | ||
413 | } | ||
407 | } | 414 | } |
408 | 415 | ||
409 | udev->state = UIST_SETUP_COMPLETE; | 416 | udev->state = UIST_SETUP_COMPLETE; |
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c index c92f4edfee7b..e5624d8f1709 100644 --- a/drivers/input/serio/hil_mlc.c +++ b/drivers/input/serio/hil_mlc.c | |||
@@ -915,15 +915,15 @@ int hil_mlc_register(hil_mlc *mlc) | |||
915 | mlc->ostarted = 0; | 915 | mlc->ostarted = 0; |
916 | 916 | ||
917 | rwlock_init(&mlc->lock); | 917 | rwlock_init(&mlc->lock); |
918 | init_MUTEX(&mlc->osem); | 918 | sema_init(&mlc->osem, 1); |
919 | 919 | ||
920 | init_MUTEX(&mlc->isem); | 920 | sema_init(&mlc->isem, 1); |
921 | mlc->icount = -1; | 921 | mlc->icount = -1; |
922 | mlc->imatch = 0; | 922 | mlc->imatch = 0; |
923 | 923 | ||
924 | mlc->opercnt = 0; | 924 | mlc->opercnt = 0; |
925 | 925 | ||
926 | init_MUTEX_LOCKED(&(mlc->csem)); | 926 | sema_init(&(mlc->csem), 0); |
927 | 927 | ||
928 | hil_mlc_clear_di_scratch(mlc); | 928 | hil_mlc_clear_di_scratch(mlc); |
929 | hil_mlc_clear_di_map(mlc, 0); | 929 | hil_mlc_clear_di_map(mlc, 0); |
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index bcc2d30ec245..8c0b51c31424 100644 --- a/drivers/input/serio/hp_sdc.c +++ b/drivers/input/serio/hp_sdc.c | |||
@@ -905,7 +905,7 @@ static int __init hp_sdc_init(void) | |||
905 | ts_sync[1] = 0x0f; | 905 | ts_sync[1] = 0x0f; |
906 | ts_sync[2] = ts_sync[3] = ts_sync[4] = ts_sync[5] = 0; | 906 | ts_sync[2] = ts_sync[3] = ts_sync[4] = ts_sync[5] = 0; |
907 | t_sync.act.semaphore = &s_sync; | 907 | t_sync.act.semaphore = &s_sync; |
908 | init_MUTEX_LOCKED(&s_sync); | 908 | sema_init(&s_sync, 0); |
909 | hp_sdc_enqueue_transaction(&t_sync); | 909 | hp_sdc_enqueue_transaction(&t_sync); |
910 | down(&s_sync); /* Wait for t_sync to complete */ | 910 | down(&s_sync); /* Wait for t_sync to complete */ |
911 | 911 | ||
@@ -1039,7 +1039,7 @@ static int __init hp_sdc_register(void) | |||
1039 | return hp_sdc.dev_err; | 1039 | return hp_sdc.dev_err; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | init_MUTEX_LOCKED(&tq_init_sem); | 1042 | sema_init(&tq_init_sem, 0); |
1043 | 1043 | ||
1044 | tq_init.actidx = 0; | 1044 | tq_init.actidx = 0; |
1045 | tq_init.idx = 1; | 1045 | tq_init.idx = 1; |
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 42ba3691d908..b35876ee6908 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
@@ -103,27 +103,26 @@ static void wacom_sys_irq(struct urb *urb) | |||
103 | static int wacom_open(struct input_dev *dev) | 103 | static int wacom_open(struct input_dev *dev) |
104 | { | 104 | { |
105 | struct wacom *wacom = input_get_drvdata(dev); | 105 | struct wacom *wacom = input_get_drvdata(dev); |
106 | int retval = 0; | ||
106 | 107 | ||
107 | mutex_lock(&wacom->lock); | 108 | if (usb_autopm_get_interface(wacom->intf) < 0) |
108 | |||
109 | wacom->irq->dev = wacom->usbdev; | ||
110 | |||
111 | if (usb_autopm_get_interface(wacom->intf) < 0) { | ||
112 | mutex_unlock(&wacom->lock); | ||
113 | return -EIO; | 109 | return -EIO; |
114 | } | 110 | |
111 | mutex_lock(&wacom->lock); | ||
115 | 112 | ||
116 | if (usb_submit_urb(wacom->irq, GFP_KERNEL)) { | 113 | if (usb_submit_urb(wacom->irq, GFP_KERNEL)) { |
117 | usb_autopm_put_interface(wacom->intf); | 114 | retval = -EIO; |
118 | mutex_unlock(&wacom->lock); | 115 | goto out; |
119 | return -EIO; | ||
120 | } | 116 | } |
121 | 117 | ||
122 | wacom->open = true; | 118 | wacom->open = true; |
123 | wacom->intf->needs_remote_wakeup = 1; | 119 | wacom->intf->needs_remote_wakeup = 1; |
124 | 120 | ||
121 | out: | ||
125 | mutex_unlock(&wacom->lock); | 122 | mutex_unlock(&wacom->lock); |
126 | return 0; | 123 | if (retval) |
124 | usb_autopm_put_interface(wacom->intf); | ||
125 | return retval; | ||
127 | } | 126 | } |
128 | 127 | ||
129 | static void wacom_close(struct input_dev *dev) | 128 | static void wacom_close(struct input_dev *dev) |
@@ -135,6 +134,8 @@ static void wacom_close(struct input_dev *dev) | |||
135 | wacom->open = false; | 134 | wacom->open = false; |
136 | wacom->intf->needs_remote_wakeup = 0; | 135 | wacom->intf->needs_remote_wakeup = 0; |
137 | mutex_unlock(&wacom->lock); | 136 | mutex_unlock(&wacom->lock); |
137 | |||
138 | usb_autopm_put_interface(wacom->intf); | ||
138 | } | 139 | } |
139 | 140 | ||
140 | static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc, | 141 | static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc, |
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 6e29badb969e..47fd7a041c52 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
@@ -442,8 +442,10 @@ static void wacom_intuos_general(struct wacom_wac *wacom) | |||
442 | /* general pen packet */ | 442 | /* general pen packet */ |
443 | if ((data[1] & 0xb8) == 0xa0) { | 443 | if ((data[1] & 0xb8) == 0xa0) { |
444 | t = (data[6] << 2) | ((data[7] >> 6) & 3); | 444 | t = (data[6] << 2) | ((data[7] >> 6) & 3); |
445 | if (features->type >= INTUOS4S && features->type <= INTUOS4L) | 445 | if ((features->type >= INTUOS4S && features->type <= INTUOS4L) || |
446 | features->type == WACOM_21UX2) { | ||
446 | t = (t << 1) | (data[1] & 1); | 447 | t = (t << 1) | (data[1] & 1); |
448 | } | ||
447 | input_report_abs(input, ABS_PRESSURE, t); | 449 | input_report_abs(input, ABS_PRESSURE, t); |
448 | input_report_abs(input, ABS_TILT_X, | 450 | input_report_abs(input, ABS_TILT_X, |
449 | ((data[7] << 1) & 0x7e) | (data[8] >> 7)); | 451 | ((data[7] << 1) & 0x7e) | (data[8] >> 7)); |
diff --git a/drivers/isdn/act2000/act2000.h b/drivers/isdn/act2000/act2000.h index d4c50512a1ff..88c9423500d8 100644 --- a/drivers/isdn/act2000/act2000.h +++ b/drivers/isdn/act2000/act2000.h | |||
@@ -141,9 +141,9 @@ typedef struct irq_data_isa { | |||
141 | __u8 rcvhdr[8]; | 141 | __u8 rcvhdr[8]; |
142 | } irq_data_isa; | 142 | } irq_data_isa; |
143 | 143 | ||
144 | typedef union irq_data { | 144 | typedef union act2000_irq_data { |
145 | irq_data_isa isa; | 145 | irq_data_isa isa; |
146 | } irq_data; | 146 | } act2000_irq_data; |
147 | 147 | ||
148 | /* | 148 | /* |
149 | * Per card driver data | 149 | * Per card driver data |
@@ -176,7 +176,7 @@ typedef struct act2000_card { | |||
176 | char *status_buf_read; | 176 | char *status_buf_read; |
177 | char *status_buf_write; | 177 | char *status_buf_write; |
178 | char *status_buf_end; | 178 | char *status_buf_end; |
179 | irq_data idat; /* Data used for IRQ handler */ | 179 | act2000_irq_data idat; /* Data used for IRQ handler */ |
180 | isdn_if interface; /* Interface to upper layer */ | 180 | isdn_if interface; /* Interface to upper layer */ |
181 | char regname[35]; /* Name used for request_region */ | 181 | char regname[35]; /* Name used for request_region */ |
182 | } act2000_card; | 182 | } act2000_card; |
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c index 6f9afcd5ca4e..b133378d4dc9 100644 --- a/drivers/isdn/hisax/config.c +++ b/drivers/isdn/hisax/config.c | |||
@@ -801,6 +801,16 @@ static void closecard(int cardnr) | |||
801 | ll_unload(csta); | 801 | ll_unload(csta); |
802 | } | 802 | } |
803 | 803 | ||
804 | static irqreturn_t card_irq(int intno, void *dev_id) | ||
805 | { | ||
806 | struct IsdnCardState *cs = dev_id; | ||
807 | irqreturn_t ret = cs->irq_func(intno, cs); | ||
808 | |||
809 | if (ret == IRQ_HANDLED) | ||
810 | cs->irq_cnt++; | ||
811 | return ret; | ||
812 | } | ||
813 | |||
804 | static int init_card(struct IsdnCardState *cs) | 814 | static int init_card(struct IsdnCardState *cs) |
805 | { | 815 | { |
806 | int irq_cnt, cnt = 3, ret; | 816 | int irq_cnt, cnt = 3, ret; |
@@ -809,10 +819,10 @@ static int init_card(struct IsdnCardState *cs) | |||
809 | ret = cs->cardmsg(cs, CARD_INIT, NULL); | 819 | ret = cs->cardmsg(cs, CARD_INIT, NULL); |
810 | return(ret); | 820 | return(ret); |
811 | } | 821 | } |
812 | irq_cnt = kstat_irqs(cs->irq); | 822 | irq_cnt = cs->irq_cnt = 0; |
813 | printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ], | 823 | printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ], |
814 | cs->irq, irq_cnt); | 824 | cs->irq, irq_cnt); |
815 | if (request_irq(cs->irq, cs->irq_func, cs->irq_flags, "HiSax", cs)) { | 825 | if (request_irq(cs->irq, card_irq, cs->irq_flags, "HiSax", cs)) { |
816 | printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n", | 826 | printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n", |
817 | cs->irq); | 827 | cs->irq); |
818 | return 1; | 828 | return 1; |
@@ -822,8 +832,8 @@ static int init_card(struct IsdnCardState *cs) | |||
822 | /* Timeout 10ms */ | 832 | /* Timeout 10ms */ |
823 | msleep(10); | 833 | msleep(10); |
824 | printk(KERN_INFO "%s: IRQ %d count %d\n", | 834 | printk(KERN_INFO "%s: IRQ %d count %d\n", |
825 | CardType[cs->typ], cs->irq, kstat_irqs(cs->irq)); | 835 | CardType[cs->typ], cs->irq, cs->irq_cnt); |
826 | if (kstat_irqs(cs->irq) == irq_cnt) { | 836 | if (cs->irq_cnt == irq_cnt) { |
827 | printk(KERN_WARNING | 837 | printk(KERN_WARNING |
828 | "%s: IRQ(%d) getting no interrupts during init %d\n", | 838 | "%s: IRQ(%d) getting no interrupts during init %d\n", |
829 | CardType[cs->typ], cs->irq, 4 - cnt); | 839 | CardType[cs->typ], cs->irq, 4 - cnt); |
diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h index 832a87855ffb..32ab3924aa73 100644 --- a/drivers/isdn/hisax/hisax.h +++ b/drivers/isdn/hisax/hisax.h | |||
@@ -959,6 +959,7 @@ struct IsdnCardState { | |||
959 | u_long event; | 959 | u_long event; |
960 | struct work_struct tqueue; | 960 | struct work_struct tqueue; |
961 | struct timer_list dbusytimer; | 961 | struct timer_list dbusytimer; |
962 | unsigned int irq_cnt; | ||
962 | #ifdef ERROR_STATISTIC | 963 | #ifdef ERROR_STATISTIC |
963 | int err_crc; | 964 | int err_crc; |
964 | int err_tx; | 965 | int err_tx; |
diff --git a/drivers/isdn/sc/interrupt.c b/drivers/isdn/sc/interrupt.c index 485be8b1e1b3..f0225bc0f267 100644 --- a/drivers/isdn/sc/interrupt.c +++ b/drivers/isdn/sc/interrupt.c | |||
@@ -112,11 +112,19 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) | |||
112 | } | 112 | } |
113 | else if(callid>=0x0000 && callid<=0x7FFF) | 113 | else if(callid>=0x0000 && callid<=0x7FFF) |
114 | { | 114 | { |
115 | int len; | ||
116 | |||
115 | pr_debug("%s: Got Incoming Call\n", | 117 | pr_debug("%s: Got Incoming Call\n", |
116 | sc_adapter[card]->devicename); | 118 | sc_adapter[card]->devicename); |
117 | strcpy(setup.phone,&(rcvmsg.msg_data.byte_array[4])); | 119 | len = strlcpy(setup.phone, &(rcvmsg.msg_data.byte_array[4]), |
118 | strcpy(setup.eazmsn, | 120 | sizeof(setup.phone)); |
119 | sc_adapter[card]->channel[rcvmsg.phy_link_no-1].dn); | 121 | if (len >= sizeof(setup.phone)) |
122 | continue; | ||
123 | len = strlcpy(setup.eazmsn, | ||
124 | sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn, | ||
125 | sizeof(setup.eazmsn)); | ||
126 | if (len >= sizeof(setup.eazmsn)) | ||
127 | continue; | ||
120 | setup.si1 = 7; | 128 | setup.si1 = 7; |
121 | setup.si2 = 0; | 129 | setup.si2 = 0; |
122 | setup.plan = 0; | 130 | setup.plan = 0; |
@@ -176,7 +184,9 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) | |||
176 | * Handle a GetMyNumber Rsp | 184 | * Handle a GetMyNumber Rsp |
177 | */ | 185 | */ |
178 | if (IS_CE_MESSAGE(rcvmsg,Call,0,GetMyNumber)){ | 186 | if (IS_CE_MESSAGE(rcvmsg,Call,0,GetMyNumber)){ |
179 | strcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no-1].dn,rcvmsg.msg_data.byte_array); | 187 | strlcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn, |
188 | rcvmsg.msg_data.byte_array, | ||
189 | sizeof(rcvmsg.msg_data.byte_array)); | ||
180 | continue; | 190 | continue; |
181 | } | 191 | } |
182 | 192 | ||
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index 1c4ee6e77937..bf64e49d996a 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
@@ -83,7 +83,7 @@ static struct adb_driver *adb_controller; | |||
83 | BLOCKING_NOTIFIER_HEAD(adb_client_list); | 83 | BLOCKING_NOTIFIER_HEAD(adb_client_list); |
84 | static int adb_got_sleep; | 84 | static int adb_got_sleep; |
85 | static int adb_inited; | 85 | static int adb_inited; |
86 | static DECLARE_MUTEX(adb_probe_mutex); | 86 | static DEFINE_SEMAPHORE(adb_probe_mutex); |
87 | static int sleepy_trackpad; | 87 | static int sleepy_trackpad; |
88 | static int autopoll_devs; | 88 | static int autopoll_devs; |
89 | int __adb_probe_sync; | 89 | int __adb_probe_sync; |
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index ed4900ade93a..e4fb58db5454 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -1000,10 +1000,11 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
1000 | page = bitmap->sb_page; | 1000 | page = bitmap->sb_page; |
1001 | offset = sizeof(bitmap_super_t); | 1001 | offset = sizeof(bitmap_super_t); |
1002 | if (!file) | 1002 | if (!file) |
1003 | read_sb_page(bitmap->mddev, | 1003 | page = read_sb_page( |
1004 | bitmap->mddev->bitmap_info.offset, | 1004 | bitmap->mddev, |
1005 | page, | 1005 | bitmap->mddev->bitmap_info.offset, |
1006 | index, count); | 1006 | page, |
1007 | index, count); | ||
1007 | } else if (file) { | 1008 | } else if (file) { |
1008 | page = read_page(file, index, bitmap, count); | 1009 | page = read_page(file, index, bitmap, count); |
1009 | offset = 0; | 1010 | offset = 0; |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index ad83a4dcadc3..0b830bbe1d8b 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1839,7 +1839,9 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1839 | 1839 | ||
1840 | /* take from bio_init */ | 1840 | /* take from bio_init */ |
1841 | bio->bi_next = NULL; | 1841 | bio->bi_next = NULL; |
1842 | bio->bi_flags &= ~(BIO_POOL_MASK-1); | ||
1842 | bio->bi_flags |= 1 << BIO_UPTODATE; | 1843 | bio->bi_flags |= 1 << BIO_UPTODATE; |
1844 | bio->bi_comp_cpu = -1; | ||
1843 | bio->bi_rw = READ; | 1845 | bio->bi_rw = READ; |
1844 | bio->bi_vcnt = 0; | 1846 | bio->bi_vcnt = 0; |
1845 | bio->bi_idx = 0; | 1847 | bio->bi_idx = 0; |
@@ -1912,7 +1914,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1912 | !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) | 1914 | !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) |
1913 | break; | 1915 | break; |
1914 | BUG_ON(sync_blocks < (PAGE_SIZE>>9)); | 1916 | BUG_ON(sync_blocks < (PAGE_SIZE>>9)); |
1915 | if (len > (sync_blocks<<9)) | 1917 | if ((len >> 9) > sync_blocks) |
1916 | len = sync_blocks<<9; | 1918 | len = sync_blocks<<9; |
1917 | } | 1919 | } |
1918 | 1920 | ||
diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c index 7e82a9df726b..7961d59f5cac 100644 --- a/drivers/media/IR/ir-keytable.c +++ b/drivers/media/IR/ir-keytable.c | |||
@@ -319,7 +319,7 @@ static void ir_timer_keyup(unsigned long cookie) | |||
319 | * a keyup event might follow immediately after the keydown. | 319 | * a keyup event might follow immediately after the keydown. |
320 | */ | 320 | */ |
321 | spin_lock_irqsave(&ir->keylock, flags); | 321 | spin_lock_irqsave(&ir->keylock, flags); |
322 | if (time_is_after_eq_jiffies(ir->keyup_jiffies)) | 322 | if (time_is_before_eq_jiffies(ir->keyup_jiffies)) |
323 | ir_keyup(ir); | 323 | ir_keyup(ir); |
324 | spin_unlock_irqrestore(&ir->keylock, flags); | 324 | spin_unlock_irqrestore(&ir->keylock, flags); |
325 | } | 325 | } |
@@ -510,6 +510,13 @@ int __ir_input_register(struct input_dev *input_dev, | |||
510 | (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_IR_RAW) ? | 510 | (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_IR_RAW) ? |
511 | " in raw mode" : ""); | 511 | " in raw mode" : ""); |
512 | 512 | ||
513 | /* | ||
514 | * Default delay of 250ms is too short for some protocols, expecially | ||
515 | * since the timeout is currently set to 250ms. Increase it to 500ms, | ||
516 | * to avoid wrong repetition of the keycodes. | ||
517 | */ | ||
518 | input_dev->rep[REP_DELAY] = 500; | ||
519 | |||
513 | return 0; | 520 | return 0; |
514 | 521 | ||
515 | out_event: | 522 | out_event: |
diff --git a/drivers/media/IR/ir-lirc-codec.c b/drivers/media/IR/ir-lirc-codec.c index 77b5946413c0..e63f757d5d72 100644 --- a/drivers/media/IR/ir-lirc-codec.c +++ b/drivers/media/IR/ir-lirc-codec.c | |||
@@ -267,7 +267,7 @@ static int ir_lirc_register(struct input_dev *input_dev) | |||
267 | features |= LIRC_CAN_SET_SEND_CARRIER; | 267 | features |= LIRC_CAN_SET_SEND_CARRIER; |
268 | 268 | ||
269 | if (ir_dev->props->s_tx_duty_cycle) | 269 | if (ir_dev->props->s_tx_duty_cycle) |
270 | features |= LIRC_CAN_SET_REC_DUTY_CYCLE; | 270 | features |= LIRC_CAN_SET_SEND_DUTY_CYCLE; |
271 | } | 271 | } |
272 | 272 | ||
273 | if (ir_dev->props->s_rx_carrier_range) | 273 | if (ir_dev->props->s_rx_carrier_range) |
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c index 43094e7eccfa..8e0e1b1f8c87 100644 --- a/drivers/media/IR/ir-raw-event.c +++ b/drivers/media/IR/ir-raw-event.c | |||
@@ -279,9 +279,11 @@ int ir_raw_event_register(struct input_dev *input_dev) | |||
279 | "rc%u", (unsigned int)ir->devno); | 279 | "rc%u", (unsigned int)ir->devno); |
280 | 280 | ||
281 | if (IS_ERR(ir->raw->thread)) { | 281 | if (IS_ERR(ir->raw->thread)) { |
282 | int ret = PTR_ERR(ir->raw->thread); | ||
283 | |||
282 | kfree(ir->raw); | 284 | kfree(ir->raw); |
283 | ir->raw = NULL; | 285 | ir->raw = NULL; |
284 | return PTR_ERR(ir->raw->thread); | 286 | return ret; |
285 | } | 287 | } |
286 | 288 | ||
287 | mutex_lock(&ir_raw_handler_lock); | 289 | mutex_lock(&ir_raw_handler_lock); |
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c index 96dafc425c8e..46d42467f9b4 100644 --- a/drivers/media/IR/ir-sysfs.c +++ b/drivers/media/IR/ir-sysfs.c | |||
@@ -67,13 +67,14 @@ static ssize_t show_protocols(struct device *d, | |||
67 | char *tmp = buf; | 67 | char *tmp = buf; |
68 | int i; | 68 | int i; |
69 | 69 | ||
70 | if (ir_dev->props->driver_type == RC_DRIVER_SCANCODE) { | 70 | if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) { |
71 | enabled = ir_dev->rc_tab.ir_type; | 71 | enabled = ir_dev->rc_tab.ir_type; |
72 | allowed = ir_dev->props->allowed_protos; | 72 | allowed = ir_dev->props->allowed_protos; |
73 | } else { | 73 | } else if (ir_dev->raw) { |
74 | enabled = ir_dev->raw->enabled_protocols; | 74 | enabled = ir_dev->raw->enabled_protocols; |
75 | allowed = ir_raw_get_allowed_protocols(); | 75 | allowed = ir_raw_get_allowed_protocols(); |
76 | } | 76 | } else |
77 | return sprintf(tmp, "[builtin]\n"); | ||
77 | 78 | ||
78 | IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n", | 79 | IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n", |
79 | (long long)allowed, | 80 | (long long)allowed, |
@@ -121,10 +122,14 @@ static ssize_t store_protocols(struct device *d, | |||
121 | int rc, i, count = 0; | 122 | int rc, i, count = 0; |
122 | unsigned long flags; | 123 | unsigned long flags; |
123 | 124 | ||
124 | if (ir_dev->props->driver_type == RC_DRIVER_SCANCODE) | 125 | if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) |
125 | type = ir_dev->rc_tab.ir_type; | 126 | type = ir_dev->rc_tab.ir_type; |
126 | else | 127 | else if (ir_dev->raw) |
127 | type = ir_dev->raw->enabled_protocols; | 128 | type = ir_dev->raw->enabled_protocols; |
129 | else { | ||
130 | IR_dprintk(1, "Protocol switching not supported\n"); | ||
131 | return -EINVAL; | ||
132 | } | ||
128 | 133 | ||
129 | while ((tmp = strsep((char **) &data, " \n")) != NULL) { | 134 | while ((tmp = strsep((char **) &data, " \n")) != NULL) { |
130 | if (!*tmp) | 135 | if (!*tmp) |
@@ -185,7 +190,7 @@ static ssize_t store_protocols(struct device *d, | |||
185 | } | 190 | } |
186 | } | 191 | } |
187 | 192 | ||
188 | if (ir_dev->props->driver_type == RC_DRIVER_SCANCODE) { | 193 | if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) { |
189 | spin_lock_irqsave(&ir_dev->rc_tab.lock, flags); | 194 | spin_lock_irqsave(&ir_dev->rc_tab.lock, flags); |
190 | ir_dev->rc_tab.ir_type = type; | 195 | ir_dev->rc_tab.ir_type = type; |
191 | spin_unlock_irqrestore(&ir_dev->rc_tab.lock, flags); | 196 | spin_unlock_irqrestore(&ir_dev->rc_tab.lock, flags); |
diff --git a/drivers/media/IR/keymaps/rc-rc6-mce.c b/drivers/media/IR/keymaps/rc-rc6-mce.c index 64264f7f838f..39557ad401b6 100644 --- a/drivers/media/IR/keymaps/rc-rc6-mce.c +++ b/drivers/media/IR/keymaps/rc-rc6-mce.c | |||
@@ -19,6 +19,7 @@ static struct ir_scancode rc6_mce[] = { | |||
19 | 19 | ||
20 | { 0x800f0416, KEY_PLAY }, | 20 | { 0x800f0416, KEY_PLAY }, |
21 | { 0x800f0418, KEY_PAUSE }, | 21 | { 0x800f0418, KEY_PAUSE }, |
22 | { 0x800f046e, KEY_PLAYPAUSE }, | ||
22 | { 0x800f0419, KEY_STOP }, | 23 | { 0x800f0419, KEY_STOP }, |
23 | { 0x800f0417, KEY_RECORD }, | 24 | { 0x800f0417, KEY_RECORD }, |
24 | 25 | ||
@@ -37,6 +38,8 @@ static struct ir_scancode rc6_mce[] = { | |||
37 | { 0x800f0411, KEY_VOLUMEDOWN }, | 38 | { 0x800f0411, KEY_VOLUMEDOWN }, |
38 | { 0x800f0412, KEY_CHANNELUP }, | 39 | { 0x800f0412, KEY_CHANNELUP }, |
39 | { 0x800f0413, KEY_CHANNELDOWN }, | 40 | { 0x800f0413, KEY_CHANNELDOWN }, |
41 | { 0x800f043a, KEY_BRIGHTNESSUP }, | ||
42 | { 0x800f0480, KEY_BRIGHTNESSDOWN }, | ||
40 | 43 | ||
41 | { 0x800f0401, KEY_NUMERIC_1 }, | 44 | { 0x800f0401, KEY_NUMERIC_1 }, |
42 | { 0x800f0402, KEY_NUMERIC_2 }, | 45 | { 0x800f0402, KEY_NUMERIC_2 }, |
diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c index ac6bb2c01a48..bc620e10ef77 100644 --- a/drivers/media/IR/mceusb.c +++ b/drivers/media/IR/mceusb.c | |||
@@ -120,6 +120,10 @@ static struct usb_device_id mceusb_dev_table[] = { | |||
120 | { USB_DEVICE(VENDOR_PHILIPS, 0x0613) }, | 120 | { USB_DEVICE(VENDOR_PHILIPS, 0x0613) }, |
121 | /* Philips eHome Infrared Transceiver */ | 121 | /* Philips eHome Infrared Transceiver */ |
122 | { USB_DEVICE(VENDOR_PHILIPS, 0x0815) }, | 122 | { USB_DEVICE(VENDOR_PHILIPS, 0x0815) }, |
123 | /* Philips/Spinel plus IR transceiver for ASUS */ | ||
124 | { USB_DEVICE(VENDOR_PHILIPS, 0x206c) }, | ||
125 | /* Philips/Spinel plus IR transceiver for ASUS */ | ||
126 | { USB_DEVICE(VENDOR_PHILIPS, 0x2088) }, | ||
123 | /* Realtek MCE IR Receiver */ | 127 | /* Realtek MCE IR Receiver */ |
124 | { USB_DEVICE(VENDOR_REALTEK, 0x0161) }, | 128 | { USB_DEVICE(VENDOR_REALTEK, 0x0161) }, |
125 | /* SMK/Toshiba G83C0004D410 */ | 129 | /* SMK/Toshiba G83C0004D410 */ |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c index fe818348b8a3..48397f103d32 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_core.c +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c | |||
@@ -673,9 +673,6 @@ static int dib0700_probe(struct usb_interface *intf, | |||
673 | else | 673 | else |
674 | dev->props.rc.core.bulk_mode = false; | 674 | dev->props.rc.core.bulk_mode = false; |
675 | 675 | ||
676 | /* Need a higher delay, to avoid wrong repeat */ | ||
677 | dev->rc_input_dev->rep[REP_DELAY] = 500; | ||
678 | |||
679 | dib0700_rc_setup(dev); | 676 | dib0700_rc_setup(dev); |
680 | 677 | ||
681 | return 0; | 678 | return 0; |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c index f634d2e784b2..e06acd1fecb6 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_devices.c +++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c | |||
@@ -940,6 +940,58 @@ static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap) | |||
940 | return adap->fe == NULL ? -ENODEV : 0; | 940 | return adap->fe == NULL ? -ENODEV : 0; |
941 | } | 941 | } |
942 | 942 | ||
943 | /* STK7770P */ | ||
944 | static struct dib7000p_config dib7770p_dib7000p_config = { | ||
945 | .output_mpeg2_in_188_bytes = 1, | ||
946 | |||
947 | .agc_config_count = 1, | ||
948 | .agc = &dib7070_agc_config, | ||
949 | .bw = &dib7070_bw_config_12_mhz, | ||
950 | .tuner_is_baseband = 1, | ||
951 | .spur_protect = 1, | ||
952 | |||
953 | .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, | ||
954 | .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, | ||
955 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, | ||
956 | |||
957 | .hostbus_diversity = 1, | ||
958 | .enable_current_mirror = 1, | ||
959 | .disable_sample_and_hold = 0, | ||
960 | }; | ||
961 | |||
962 | static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap) | ||
963 | { | ||
964 | struct usb_device_descriptor *p = &adap->dev->udev->descriptor; | ||
965 | if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) && | ||
966 | p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E)) | ||
967 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); | ||
968 | else | ||
969 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | ||
970 | msleep(10); | ||
971 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | ||
972 | dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); | ||
973 | dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); | ||
974 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); | ||
975 | |||
976 | dib0700_ctrl_clock(adap->dev, 72, 1); | ||
977 | |||
978 | msleep(10); | ||
979 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); | ||
980 | msleep(10); | ||
981 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | ||
982 | |||
983 | if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, | ||
984 | &dib7770p_dib7000p_config) != 0) { | ||
985 | err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", | ||
986 | __func__); | ||
987 | return -ENODEV; | ||
988 | } | ||
989 | |||
990 | adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, | ||
991 | &dib7770p_dib7000p_config); | ||
992 | return adap->fe == NULL ? -ENODEV : 0; | ||
993 | } | ||
994 | |||
943 | /* DIB807x generic */ | 995 | /* DIB807x generic */ |
944 | static struct dibx000_agc_config dib807x_agc_config[2] = { | 996 | static struct dibx000_agc_config dib807x_agc_config[2] = { |
945 | { | 997 | { |
@@ -1781,7 +1833,7 @@ struct usb_device_id dib0700_usb_id_table[] = { | |||
1781 | /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) }, | 1833 | /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) }, |
1782 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) }, | 1834 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) }, |
1783 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) }, | 1835 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) }, |
1784 | { USB_DEVICE(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD) }, | 1836 | { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) }, |
1785 | { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) }, | 1837 | { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) }, |
1786 | /* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) }, | 1838 | /* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) }, |
1787 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) }, | 1839 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) }, |
@@ -2406,7 +2458,7 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
2406 | .pid_filter_count = 32, | 2458 | .pid_filter_count = 32, |
2407 | .pid_filter = stk70x0p_pid_filter, | 2459 | .pid_filter = stk70x0p_pid_filter, |
2408 | .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, | 2460 | .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, |
2409 | .frontend_attach = stk7070p_frontend_attach, | 2461 | .frontend_attach = stk7770p_frontend_attach, |
2410 | .tuner_attach = dib7770p_tuner_attach, | 2462 | .tuner_attach = dib7770p_tuner_attach, |
2411 | 2463 | ||
2412 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), | 2464 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), |
diff --git a/drivers/media/dvb/dvb-usb/opera1.c b/drivers/media/dvb/dvb-usb/opera1.c index 6b22ec64ab0c..f896337b4535 100644 --- a/drivers/media/dvb/dvb-usb/opera1.c +++ b/drivers/media/dvb/dvb-usb/opera1.c | |||
@@ -483,9 +483,7 @@ static int opera1_xilinx_load_firmware(struct usb_device *dev, | |||
483 | } | 483 | } |
484 | } | 484 | } |
485 | kfree(p); | 485 | kfree(p); |
486 | if (fw) { | 486 | release_firmware(fw); |
487 | release_firmware(fw); | ||
488 | } | ||
489 | return ret; | 487 | return ret; |
490 | } | 488 | } |
491 | 489 | ||
diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c index 2e28b973dfd3..3aed0d433921 100644 --- a/drivers/media/dvb/frontends/dib7000p.c +++ b/drivers/media/dvb/frontends/dib7000p.c | |||
@@ -260,6 +260,9 @@ static void dib7000p_set_adc_state(struct dib7000p_state *state, enum dibx000_ad | |||
260 | 260 | ||
261 | // dprintk( "908: %x, 909: %x\n", reg_908, reg_909); | 261 | // dprintk( "908: %x, 909: %x\n", reg_908, reg_909); |
262 | 262 | ||
263 | reg_909 |= (state->cfg.disable_sample_and_hold & 1) << 4; | ||
264 | reg_908 |= (state->cfg.enable_current_mirror & 1) << 7; | ||
265 | |||
263 | dib7000p_write_word(state, 908, reg_908); | 266 | dib7000p_write_word(state, 908, reg_908); |
264 | dib7000p_write_word(state, 909, reg_909); | 267 | dib7000p_write_word(state, 909, reg_909); |
265 | } | 268 | } |
@@ -778,7 +781,10 @@ static void dib7000p_set_channel(struct dib7000p_state *state, struct dvb_fronte | |||
778 | default: | 781 | default: |
779 | case GUARD_INTERVAL_1_32: value *= 1; break; | 782 | case GUARD_INTERVAL_1_32: value *= 1; break; |
780 | } | 783 | } |
781 | state->div_sync_wait = (value * 3) / 2 + 32; // add 50% SFN margin + compensate for one DVSY-fifo TODO | 784 | if (state->cfg.diversity_delay == 0) |
785 | state->div_sync_wait = (value * 3) / 2 + 48; // add 50% SFN margin + compensate for one DVSY-fifo | ||
786 | else | ||
787 | state->div_sync_wait = (value * 3) / 2 + state->cfg.diversity_delay; // add 50% SFN margin + compensate for one DVSY-fifo | ||
782 | 788 | ||
783 | /* deactive the possibility of diversity reception if extended interleaver */ | 789 | /* deactive the possibility of diversity reception if extended interleaver */ |
784 | state->div_force_off = !1 && ch->u.ofdm.transmission_mode != TRANSMISSION_MODE_8K; | 790 | state->div_force_off = !1 && ch->u.ofdm.transmission_mode != TRANSMISSION_MODE_8K; |
diff --git a/drivers/media/dvb/frontends/dib7000p.h b/drivers/media/dvb/frontends/dib7000p.h index 805dd13a97ee..da17345bf5bd 100644 --- a/drivers/media/dvb/frontends/dib7000p.h +++ b/drivers/media/dvb/frontends/dib7000p.h | |||
@@ -33,6 +33,11 @@ struct dib7000p_config { | |||
33 | int (*agc_control) (struct dvb_frontend *, u8 before); | 33 | int (*agc_control) (struct dvb_frontend *, u8 before); |
34 | 34 | ||
35 | u8 output_mode; | 35 | u8 output_mode; |
36 | u8 disable_sample_and_hold : 1; | ||
37 | |||
38 | u8 enable_current_mirror : 1; | ||
39 | u8 diversity_delay; | ||
40 | |||
36 | }; | 41 | }; |
37 | 42 | ||
38 | #define DEFAULT_DIB7000P_I2C_ADDRESS 18 | 43 | #define DEFAULT_DIB7000P_I2C_ADDRESS 18 |
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c index d93468cd3a85..ff3b0fa901b3 100644 --- a/drivers/media/dvb/siano/smscoreapi.c +++ b/drivers/media/dvb/siano/smscoreapi.c | |||
@@ -1098,33 +1098,26 @@ EXPORT_SYMBOL_GPL(smscore_onresponse); | |||
1098 | * | 1098 | * |
1099 | * @return pointer to descriptor on success, NULL on error. | 1099 | * @return pointer to descriptor on success, NULL on error. |
1100 | */ | 1100 | */ |
1101 | struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev) | 1101 | |
1102 | struct smscore_buffer_t *get_entry(struct smscore_device_t *coredev) | ||
1102 | { | 1103 | { |
1103 | struct smscore_buffer_t *cb = NULL; | 1104 | struct smscore_buffer_t *cb = NULL; |
1104 | unsigned long flags; | 1105 | unsigned long flags; |
1105 | 1106 | ||
1106 | DEFINE_WAIT(wait); | ||
1107 | |||
1108 | spin_lock_irqsave(&coredev->bufferslock, flags); | 1107 | spin_lock_irqsave(&coredev->bufferslock, flags); |
1109 | 1108 | if (!list_empty(&coredev->buffers)) { | |
1110 | /* This function must return a valid buffer, since the buffer list is | 1109 | cb = (struct smscore_buffer_t *) coredev->buffers.next; |
1111 | * finite, we check that there is an available buffer, if not, we wait | 1110 | list_del(&cb->entry); |
1112 | * until such buffer become available. | ||
1113 | */ | ||
1114 | |||
1115 | prepare_to_wait(&coredev->buffer_mng_waitq, &wait, TASK_INTERRUPTIBLE); | ||
1116 | if (list_empty(&coredev->buffers)) { | ||
1117 | spin_unlock_irqrestore(&coredev->bufferslock, flags); | ||
1118 | schedule(); | ||
1119 | spin_lock_irqsave(&coredev->bufferslock, flags); | ||
1120 | } | 1111 | } |
1112 | spin_unlock_irqrestore(&coredev->bufferslock, flags); | ||
1113 | return cb; | ||
1114 | } | ||
1121 | 1115 | ||
1122 | finish_wait(&coredev->buffer_mng_waitq, &wait); | 1116 | struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev) |
1123 | 1117 | { | |
1124 | cb = (struct smscore_buffer_t *) coredev->buffers.next; | 1118 | struct smscore_buffer_t *cb = NULL; |
1125 | list_del(&cb->entry); | ||
1126 | 1119 | ||
1127 | spin_unlock_irqrestore(&coredev->bufferslock, flags); | 1120 | wait_event(coredev->buffer_mng_waitq, (cb = get_entry(coredev))); |
1128 | 1121 | ||
1129 | return cb; | 1122 | return cb; |
1130 | } | 1123 | } |
diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c index 67a4ec8768a6..4ce541a5eb47 100644 --- a/drivers/media/radio/si470x/radio-si470x-i2c.c +++ b/drivers/media/radio/si470x/radio-si470x-i2c.c | |||
@@ -395,7 +395,7 @@ static int __devinit si470x_i2c_probe(struct i2c_client *client, | |||
395 | radio->registers[POWERCFG] = POWERCFG_ENABLE; | 395 | radio->registers[POWERCFG] = POWERCFG_ENABLE; |
396 | if (si470x_set_register(radio, POWERCFG) < 0) { | 396 | if (si470x_set_register(radio, POWERCFG) < 0) { |
397 | retval = -EIO; | 397 | retval = -EIO; |
398 | goto err_all; | 398 | goto err_video; |
399 | } | 399 | } |
400 | msleep(110); | 400 | msleep(110); |
401 | 401 | ||
diff --git a/drivers/media/video/cx231xx/Makefile b/drivers/media/video/cx231xx/Makefile index 755dd0ce65ff..6f2b57384488 100644 --- a/drivers/media/video/cx231xx/Makefile +++ b/drivers/media/video/cx231xx/Makefile | |||
@@ -11,4 +11,5 @@ EXTRA_CFLAGS += -Idrivers/media/video | |||
11 | EXTRA_CFLAGS += -Idrivers/media/common/tuners | 11 | EXTRA_CFLAGS += -Idrivers/media/common/tuners |
12 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | 12 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core |
13 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends | 13 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends |
14 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-usb | ||
14 | 15 | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c index 6bdc0ef18119..f2a4900014bc 100644 --- a/drivers/media/video/cx231xx/cx231xx-cards.c +++ b/drivers/media/video/cx231xx/cx231xx-cards.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <media/v4l2-chip-ident.h> | 32 | #include <media/v4l2-chip-ident.h> |
33 | 33 | ||
34 | #include <media/cx25840.h> | 34 | #include <media/cx25840.h> |
35 | #include "dvb-usb-ids.h" | ||
35 | #include "xc5000.h" | 36 | #include "xc5000.h" |
36 | 37 | ||
37 | #include "cx231xx.h" | 38 | #include "cx231xx.h" |
@@ -175,6 +176,8 @@ struct usb_device_id cx231xx_id_table[] = { | |||
175 | .driver_info = CX231XX_BOARD_CNXT_RDE_250}, | 176 | .driver_info = CX231XX_BOARD_CNXT_RDE_250}, |
176 | {USB_DEVICE(0x0572, 0x58A1), | 177 | {USB_DEVICE(0x0572, 0x58A1), |
177 | .driver_info = CX231XX_BOARD_CNXT_RDU_250}, | 178 | .driver_info = CX231XX_BOARD_CNXT_RDU_250}, |
179 | {USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x4000,0x4fff), | ||
180 | .driver_info = CX231XX_BOARD_UNKNOWN}, | ||
178 | {}, | 181 | {}, |
179 | }; | 182 | }; |
180 | 183 | ||
@@ -226,14 +229,16 @@ void cx231xx_pre_card_setup(struct cx231xx *dev) | |||
226 | dev->board.name, dev->model); | 229 | dev->board.name, dev->model); |
227 | 230 | ||
228 | /* set the direction for GPIO pins */ | 231 | /* set the direction for GPIO pins */ |
229 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1); | 232 | if (dev->board.tuner_gpio) { |
230 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1); | 233 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1); |
231 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1); | 234 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1); |
235 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1); | ||
232 | 236 | ||
233 | /* request some modules if any required */ | 237 | /* request some modules if any required */ |
234 | 238 | ||
235 | /* reset the Tuner */ | 239 | /* reset the Tuner */ |
236 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | 240 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); |
241 | } | ||
237 | 242 | ||
238 | /* set the mode to Analog mode initially */ | 243 | /* set the mode to Analog mode initially */ |
239 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); | 244 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); |
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 86ca8c2359dd..f5a3e74c3c7c 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
@@ -1996,7 +1996,7 @@ static int cx25840_probe(struct i2c_client *client, | |||
1996 | 1996 | ||
1997 | state->volume = v4l2_ctrl_new_std(&state->hdl, | 1997 | state->volume = v4l2_ctrl_new_std(&state->hdl, |
1998 | &cx25840_audio_ctrl_ops, V4L2_CID_AUDIO_VOLUME, | 1998 | &cx25840_audio_ctrl_ops, V4L2_CID_AUDIO_VOLUME, |
1999 | 0, 65335, 65535 / 100, default_volume); | 1999 | 0, 65535, 65535 / 100, default_volume); |
2000 | state->mute = v4l2_ctrl_new_std(&state->hdl, | 2000 | state->mute = v4l2_ctrl_new_std(&state->hdl, |
2001 | &cx25840_audio_ctrl_ops, V4L2_CID_AUDIO_MUTE, | 2001 | &cx25840_audio_ctrl_ops, V4L2_CID_AUDIO_MUTE, |
2002 | 0, 1, 1, 0); | 2002 | 0, 1, 1, 0); |
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig index 99dbae117591..0fa85cbefbb1 100644 --- a/drivers/media/video/cx88/Kconfig +++ b/drivers/media/video/cx88/Kconfig | |||
@@ -17,7 +17,7 @@ config VIDEO_CX88 | |||
17 | 17 | ||
18 | config VIDEO_CX88_ALSA | 18 | config VIDEO_CX88_ALSA |
19 | tristate "Conexant 2388x DMA audio support" | 19 | tristate "Conexant 2388x DMA audio support" |
20 | depends on VIDEO_CX88 && SND && EXPERIMENTAL | 20 | depends on VIDEO_CX88 && SND |
21 | select SND_PCM | 21 | select SND_PCM |
22 | ---help--- | 22 | ---help--- |
23 | This is a video4linux driver for direct (DMA) audio on | 23 | This is a video4linux driver for direct (DMA) audio on |
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index b9846106913e..78abc1c1f9d5 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -223,6 +223,7 @@ static int alloc_and_submit_int_urb(struct gspca_dev *gspca_dev, | |||
223 | usb_rcvintpipe(dev, ep->bEndpointAddress), | 223 | usb_rcvintpipe(dev, ep->bEndpointAddress), |
224 | buffer, buffer_len, | 224 | buffer, buffer_len, |
225 | int_irq, (void *)gspca_dev, interval); | 225 | int_irq, (void *)gspca_dev, interval); |
226 | urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
226 | gspca_dev->int_urb = urb; | 227 | gspca_dev->int_urb = urb; |
227 | ret = usb_submit_urb(urb, GFP_KERNEL); | 228 | ret = usb_submit_urb(urb, GFP_KERNEL); |
228 | if (ret < 0) { | 229 | if (ret < 0) { |
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c index 83a718f0f3f9..9052d5702556 100644 --- a/drivers/media/video/gspca/sn9c20x.c +++ b/drivers/media/video/gspca/sn9c20x.c | |||
@@ -2357,8 +2357,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
2357 | (data[33] << 10); | 2357 | (data[33] << 10); |
2358 | avg_lum >>= 9; | 2358 | avg_lum >>= 9; |
2359 | atomic_set(&sd->avg_lum, avg_lum); | 2359 | atomic_set(&sd->avg_lum, avg_lum); |
2360 | gspca_frame_add(gspca_dev, LAST_PACKET, | 2360 | gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); |
2361 | data, len); | ||
2362 | return; | 2361 | return; |
2363 | } | 2362 | } |
2364 | if (gspca_dev->last_packet_type == LAST_PACKET) { | 2363 | if (gspca_dev->last_packet_type == LAST_PACKET) { |
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c index be03a712731c..f0316d02f09f 100644 --- a/drivers/media/video/ivtv/ivtvfb.c +++ b/drivers/media/video/ivtv/ivtvfb.c | |||
@@ -466,6 +466,8 @@ static int ivtvfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long ar | |||
466 | struct fb_vblank vblank; | 466 | struct fb_vblank vblank; |
467 | u32 trace; | 467 | u32 trace; |
468 | 468 | ||
469 | memset(&vblank, 0, sizeof(struct fb_vblank)); | ||
470 | |||
469 | vblank.flags = FB_VBLANK_HAVE_COUNT |FB_VBLANK_HAVE_VCOUNT | | 471 | vblank.flags = FB_VBLANK_HAVE_COUNT |FB_VBLANK_HAVE_VCOUNT | |
470 | FB_VBLANK_HAVE_VSYNC; | 472 | FB_VBLANK_HAVE_VSYNC; |
471 | trace = read_reg(IVTV_REG_DEC_LINE_FIELD) >> 16; | 473 | trace = read_reg(IVTV_REG_DEC_LINE_FIELD) >> 16; |
diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c index 4525335f9bd4..a7210d981388 100644 --- a/drivers/media/video/mem2mem_testdev.c +++ b/drivers/media/video/mem2mem_testdev.c | |||
@@ -239,7 +239,7 @@ static int device_process(struct m2mtest_ctx *ctx, | |||
239 | return -EFAULT; | 239 | return -EFAULT; |
240 | } | 240 | } |
241 | 241 | ||
242 | if (in_buf->vb.size < out_buf->vb.size) { | 242 | if (in_buf->vb.size > out_buf->vb.size) { |
243 | v4l2_err(&dev->v4l2_dev, "Output buffer is too small\n"); | 243 | v4l2_err(&dev->v4l2_dev, "Output buffer is too small\n"); |
244 | return -EINVAL; | 244 | return -EINVAL; |
245 | } | 245 | } |
@@ -1014,6 +1014,7 @@ static int m2mtest_remove(struct platform_device *pdev) | |||
1014 | v4l2_m2m_release(dev->m2m_dev); | 1014 | v4l2_m2m_release(dev->m2m_dev); |
1015 | del_timer_sync(&dev->timer); | 1015 | del_timer_sync(&dev->timer); |
1016 | video_unregister_device(dev->vfd); | 1016 | video_unregister_device(dev->vfd); |
1017 | video_device_release(dev->vfd); | ||
1017 | v4l2_device_unregister(&dev->v4l2_dev); | 1018 | v4l2_device_unregister(&dev->v4l2_dev); |
1018 | kfree(dev); | 1019 | kfree(dev); |
1019 | 1020 | ||
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 758a4db27d65..c71af4e0e517 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c | |||
@@ -447,6 +447,9 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) | |||
447 | dev_dbg(&client->dev, "%s left=%d, top=%d, width=%d, height=%d\n", | 447 | dev_dbg(&client->dev, "%s left=%d, top=%d, width=%d, height=%d\n", |
448 | __func__, rect.left, rect.top, rect.width, rect.height); | 448 | __func__, rect.left, rect.top, rect.width, rect.height); |
449 | 449 | ||
450 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
451 | return -EINVAL; | ||
452 | |||
450 | ret = mt9m111_make_rect(client, &rect); | 453 | ret = mt9m111_make_rect(client, &rect); |
451 | if (!ret) | 454 | if (!ret) |
452 | mt9m111->rect = rect; | 455 | mt9m111->rect = rect; |
@@ -466,12 +469,14 @@ static int mt9m111_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) | |||
466 | 469 | ||
467 | static int mt9m111_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) | 470 | static int mt9m111_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) |
468 | { | 471 | { |
472 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
473 | return -EINVAL; | ||
474 | |||
469 | a->bounds.left = MT9M111_MIN_DARK_COLS; | 475 | a->bounds.left = MT9M111_MIN_DARK_COLS; |
470 | a->bounds.top = MT9M111_MIN_DARK_ROWS; | 476 | a->bounds.top = MT9M111_MIN_DARK_ROWS; |
471 | a->bounds.width = MT9M111_MAX_WIDTH; | 477 | a->bounds.width = MT9M111_MAX_WIDTH; |
472 | a->bounds.height = MT9M111_MAX_HEIGHT; | 478 | a->bounds.height = MT9M111_MAX_HEIGHT; |
473 | a->defrect = a->bounds; | 479 | a->defrect = a->bounds; |
474 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
475 | a->pixelaspect.numerator = 1; | 480 | a->pixelaspect.numerator = 1; |
476 | a->pixelaspect.denominator = 1; | 481 | a->pixelaspect.denominator = 1; |
477 | 482 | ||
@@ -487,6 +492,7 @@ static int mt9m111_g_fmt(struct v4l2_subdev *sd, | |||
487 | mf->width = mt9m111->rect.width; | 492 | mf->width = mt9m111->rect.width; |
488 | mf->height = mt9m111->rect.height; | 493 | mf->height = mt9m111->rect.height; |
489 | mf->code = mt9m111->fmt->code; | 494 | mf->code = mt9m111->fmt->code; |
495 | mf->colorspace = mt9m111->fmt->colorspace; | ||
490 | mf->field = V4L2_FIELD_NONE; | 496 | mf->field = V4L2_FIELD_NONE; |
491 | 497 | ||
492 | return 0; | 498 | return 0; |
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c index e7cd23cd6394..b48473c7896b 100644 --- a/drivers/media/video/mt9v022.c +++ b/drivers/media/video/mt9v022.c | |||
@@ -402,9 +402,6 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd, | |||
402 | if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATC) | 402 | if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATC) |
403 | return -EINVAL; | 403 | return -EINVAL; |
404 | break; | 404 | break; |
405 | case 0: | ||
406 | /* No format change, only geometry */ | ||
407 | break; | ||
408 | default: | 405 | default: |
409 | return -EINVAL; | 406 | return -EINVAL; |
410 | } | 407 | } |
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 66ff174151b5..b6ea67221d1d 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c | |||
@@ -378,6 +378,9 @@ static void mx25_camera_frame_done(struct mx2_camera_dev *pcdev, int fb, | |||
378 | 378 | ||
379 | spin_lock_irqsave(&pcdev->lock, flags); | 379 | spin_lock_irqsave(&pcdev->lock, flags); |
380 | 380 | ||
381 | if (*fb_active == NULL) | ||
382 | goto out; | ||
383 | |||
381 | vb = &(*fb_active)->vb; | 384 | vb = &(*fb_active)->vb; |
382 | dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | 385 | dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, |
383 | vb, vb->baddr, vb->bsize); | 386 | vb, vb->baddr, vb->bsize); |
@@ -402,6 +405,7 @@ static void mx25_camera_frame_done(struct mx2_camera_dev *pcdev, int fb, | |||
402 | 405 | ||
403 | *fb_active = buf; | 406 | *fb_active = buf; |
404 | 407 | ||
408 | out: | ||
405 | spin_unlock_irqrestore(&pcdev->lock, flags); | 409 | spin_unlock_irqrestore(&pcdev->lock, flags); |
406 | } | 410 | } |
407 | 411 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c index 1b992b847198..55ea914c7fcd 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c +++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c | |||
@@ -513,7 +513,7 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr, | |||
513 | if (ret >= 0) { | 513 | if (ret >= 0) { |
514 | ret = pvr2_ctrl_range_check(cptr,*valptr); | 514 | ret = pvr2_ctrl_range_check(cptr,*valptr); |
515 | } | 515 | } |
516 | if (maskptr) *maskptr = ~0; | 516 | *maskptr = ~0; |
517 | } else if (cptr->info->type == pvr2_ctl_bool) { | 517 | } else if (cptr->info->type == pvr2_ctl_bool) { |
518 | ret = parse_token(ptr,len,valptr,boolNames, | 518 | ret = parse_token(ptr,len,valptr,boolNames, |
519 | ARRAY_SIZE(boolNames)); | 519 | ARRAY_SIZE(boolNames)); |
@@ -522,7 +522,7 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr, | |||
522 | } else if (ret == 0) { | 522 | } else if (ret == 0) { |
523 | *valptr = (*valptr & 1) ? !0 : 0; | 523 | *valptr = (*valptr & 1) ? !0 : 0; |
524 | } | 524 | } |
525 | if (maskptr) *maskptr = 1; | 525 | *maskptr = 1; |
526 | } else if (cptr->info->type == pvr2_ctl_enum) { | 526 | } else if (cptr->info->type == pvr2_ctl_enum) { |
527 | ret = parse_token( | 527 | ret = parse_token( |
528 | ptr,len,valptr, | 528 | ptr,len,valptr, |
@@ -531,7 +531,7 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr, | |||
531 | if (ret >= 0) { | 531 | if (ret >= 0) { |
532 | ret = pvr2_ctrl_range_check(cptr,*valptr); | 532 | ret = pvr2_ctrl_range_check(cptr,*valptr); |
533 | } | 533 | } |
534 | if (maskptr) *maskptr = ~0; | 534 | *maskptr = ~0; |
535 | } else if (cptr->info->type == pvr2_ctl_bitmask) { | 535 | } else if (cptr->info->type == pvr2_ctl_bitmask) { |
536 | ret = parse_tlist( | 536 | ret = parse_tlist( |
537 | ptr,len,maskptr,valptr, | 537 | ptr,len,maskptr,valptr, |
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index b151c7be8a50..6961c55baf9b 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c | |||
@@ -393,6 +393,37 @@ static void fimc_set_yuv_order(struct fimc_ctx *ctx) | |||
393 | dbg("ctx->out_order_1p= %d", ctx->out_order_1p); | 393 | dbg("ctx->out_order_1p= %d", ctx->out_order_1p); |
394 | } | 394 | } |
395 | 395 | ||
396 | static void fimc_prepare_dma_offset(struct fimc_ctx *ctx, struct fimc_frame *f) | ||
397 | { | ||
398 | struct samsung_fimc_variant *variant = ctx->fimc_dev->variant; | ||
399 | |||
400 | f->dma_offset.y_h = f->offs_h; | ||
401 | if (!variant->pix_hoff) | ||
402 | f->dma_offset.y_h *= (f->fmt->depth >> 3); | ||
403 | |||
404 | f->dma_offset.y_v = f->offs_v; | ||
405 | |||
406 | f->dma_offset.cb_h = f->offs_h; | ||
407 | f->dma_offset.cb_v = f->offs_v; | ||
408 | |||
409 | f->dma_offset.cr_h = f->offs_h; | ||
410 | f->dma_offset.cr_v = f->offs_v; | ||
411 | |||
412 | if (!variant->pix_hoff) { | ||
413 | if (f->fmt->planes_cnt == 3) { | ||
414 | f->dma_offset.cb_h >>= 1; | ||
415 | f->dma_offset.cr_h >>= 1; | ||
416 | } | ||
417 | if (f->fmt->color == S5P_FIMC_YCBCR420) { | ||
418 | f->dma_offset.cb_v >>= 1; | ||
419 | f->dma_offset.cr_v >>= 1; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | dbg("in_offset: color= %d, y_h= %d, y_v= %d", | ||
424 | f->fmt->color, f->dma_offset.y_h, f->dma_offset.y_v); | ||
425 | } | ||
426 | |||
396 | /** | 427 | /** |
397 | * fimc_prepare_config - check dimensions, operation and color mode | 428 | * fimc_prepare_config - check dimensions, operation and color mode |
398 | * and pre-calculate offset and the scaling coefficients. | 429 | * and pre-calculate offset and the scaling coefficients. |
@@ -406,7 +437,6 @@ static int fimc_prepare_config(struct fimc_ctx *ctx, u32 flags) | |||
406 | { | 437 | { |
407 | struct fimc_frame *s_frame, *d_frame; | 438 | struct fimc_frame *s_frame, *d_frame; |
408 | struct fimc_vid_buffer *buf = NULL; | 439 | struct fimc_vid_buffer *buf = NULL; |
409 | struct samsung_fimc_variant *variant = ctx->fimc_dev->variant; | ||
410 | int ret = 0; | 440 | int ret = 0; |
411 | 441 | ||
412 | s_frame = &ctx->s_frame; | 442 | s_frame = &ctx->s_frame; |
@@ -419,61 +449,16 @@ static int fimc_prepare_config(struct fimc_ctx *ctx, u32 flags) | |||
419 | swap(d_frame->width, d_frame->height); | 449 | swap(d_frame->width, d_frame->height); |
420 | } | 450 | } |
421 | 451 | ||
422 | /* Prepare the output offset ratios for scaler. */ | 452 | /* Prepare the DMA offset ratios for scaler. */ |
423 | d_frame->dma_offset.y_h = d_frame->offs_h; | 453 | fimc_prepare_dma_offset(ctx, &ctx->s_frame); |
424 | if (!variant->pix_hoff) | 454 | fimc_prepare_dma_offset(ctx, &ctx->d_frame); |
425 | d_frame->dma_offset.y_h *= (d_frame->fmt->depth >> 3); | ||
426 | |||
427 | d_frame->dma_offset.y_v = d_frame->offs_v; | ||
428 | |||
429 | d_frame->dma_offset.cb_h = d_frame->offs_h; | ||
430 | d_frame->dma_offset.cb_v = d_frame->offs_v; | ||
431 | |||
432 | d_frame->dma_offset.cr_h = d_frame->offs_h; | ||
433 | d_frame->dma_offset.cr_v = d_frame->offs_v; | ||
434 | 455 | ||
435 | if (!variant->pix_hoff && d_frame->fmt->planes_cnt == 3) { | ||
436 | d_frame->dma_offset.cb_h >>= 1; | ||
437 | d_frame->dma_offset.cb_v >>= 1; | ||
438 | d_frame->dma_offset.cr_h >>= 1; | ||
439 | d_frame->dma_offset.cr_v >>= 1; | ||
440 | } | ||
441 | |||
442 | dbg("out offset: color= %d, y_h= %d, y_v= %d", | ||
443 | d_frame->fmt->color, | ||
444 | d_frame->dma_offset.y_h, d_frame->dma_offset.y_v); | ||
445 | |||
446 | /* Prepare the input offset ratios for scaler. */ | ||
447 | s_frame->dma_offset.y_h = s_frame->offs_h; | ||
448 | if (!variant->pix_hoff) | ||
449 | s_frame->dma_offset.y_h *= (s_frame->fmt->depth >> 3); | ||
450 | s_frame->dma_offset.y_v = s_frame->offs_v; | ||
451 | |||
452 | s_frame->dma_offset.cb_h = s_frame->offs_h; | ||
453 | s_frame->dma_offset.cb_v = s_frame->offs_v; | ||
454 | |||
455 | s_frame->dma_offset.cr_h = s_frame->offs_h; | ||
456 | s_frame->dma_offset.cr_v = s_frame->offs_v; | ||
457 | |||
458 | if (!variant->pix_hoff && s_frame->fmt->planes_cnt == 3) { | ||
459 | s_frame->dma_offset.cb_h >>= 1; | ||
460 | s_frame->dma_offset.cb_v >>= 1; | ||
461 | s_frame->dma_offset.cr_h >>= 1; | ||
462 | s_frame->dma_offset.cr_v >>= 1; | ||
463 | } | ||
464 | |||
465 | dbg("in offset: color= %d, y_h= %d, y_v= %d", | ||
466 | s_frame->fmt->color, s_frame->dma_offset.y_h, | ||
467 | s_frame->dma_offset.y_v); | ||
468 | |||
469 | fimc_set_yuv_order(ctx); | ||
470 | |||
471 | /* Check against the scaler ratio. */ | ||
472 | if (s_frame->height > (SCALER_MAX_VRATIO * d_frame->height) || | 456 | if (s_frame->height > (SCALER_MAX_VRATIO * d_frame->height) || |
473 | s_frame->width > (SCALER_MAX_HRATIO * d_frame->width)) { | 457 | s_frame->width > (SCALER_MAX_HRATIO * d_frame->width)) { |
474 | err("out of scaler range"); | 458 | err("out of scaler range"); |
475 | return -EINVAL; | 459 | return -EINVAL; |
476 | } | 460 | } |
461 | fimc_set_yuv_order(ctx); | ||
477 | } | 462 | } |
478 | 463 | ||
479 | /* Input DMA mode is not allowed when the scaler is disabled. */ | 464 | /* Input DMA mode is not allowed when the scaler is disabled. */ |
@@ -822,7 +807,8 @@ static int fimc_m2m_s_fmt(struct file *file, void *priv, struct v4l2_format *f) | |||
822 | } else { | 807 | } else { |
823 | v4l2_err(&ctx->fimc_dev->m2m.v4l2_dev, | 808 | v4l2_err(&ctx->fimc_dev->m2m.v4l2_dev, |
824 | "Wrong buffer/video queue type (%d)\n", f->type); | 809 | "Wrong buffer/video queue type (%d)\n", f->type); |
825 | return -EINVAL; | 810 | ret = -EINVAL; |
811 | goto s_fmt_out; | ||
826 | } | 812 | } |
827 | 813 | ||
828 | pix = &f->fmt.pix; | 814 | pix = &f->fmt.pix; |
@@ -1414,8 +1400,10 @@ static int fimc_probe(struct platform_device *pdev) | |||
1414 | } | 1400 | } |
1415 | 1401 | ||
1416 | fimc->work_queue = create_workqueue(dev_name(&fimc->pdev->dev)); | 1402 | fimc->work_queue = create_workqueue(dev_name(&fimc->pdev->dev)); |
1417 | if (!fimc->work_queue) | 1403 | if (!fimc->work_queue) { |
1404 | ret = -ENOMEM; | ||
1418 | goto err_irq; | 1405 | goto err_irq; |
1406 | } | ||
1419 | 1407 | ||
1420 | ret = fimc_register_m2m_device(fimc); | 1408 | ret = fimc_register_m2m_device(fimc); |
1421 | if (ret) | 1409 | if (ret) |
@@ -1492,6 +1480,7 @@ static struct samsung_fimc_variant fimc2_variant_s5p = { | |||
1492 | }; | 1480 | }; |
1493 | 1481 | ||
1494 | static struct samsung_fimc_variant fimc01_variant_s5pv210 = { | 1482 | static struct samsung_fimc_variant fimc01_variant_s5pv210 = { |
1483 | .pix_hoff = 1, | ||
1495 | .has_inp_rot = 1, | 1484 | .has_inp_rot = 1, |
1496 | .has_out_rot = 1, | 1485 | .has_out_rot = 1, |
1497 | .min_inp_pixsize = 16, | 1486 | .min_inp_pixsize = 16, |
@@ -1506,6 +1495,7 @@ static struct samsung_fimc_variant fimc01_variant_s5pv210 = { | |||
1506 | }; | 1495 | }; |
1507 | 1496 | ||
1508 | static struct samsung_fimc_variant fimc2_variant_s5pv210 = { | 1497 | static struct samsung_fimc_variant fimc2_variant_s5pv210 = { |
1498 | .pix_hoff = 1, | ||
1509 | .min_inp_pixsize = 16, | 1499 | .min_inp_pixsize = 16, |
1510 | .min_out_pixsize = 32, | 1500 | .min_out_pixsize = 32, |
1511 | 1501 | ||
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index ec697fcd406e..bb8d83d8ddaf 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -4323,13 +4323,13 @@ struct saa7134_board saa7134_boards[] = { | |||
4323 | }, | 4323 | }, |
4324 | [SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM] = { | 4324 | [SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM] = { |
4325 | /* Beholder Intl. Ltd. 2008 */ | 4325 | /* Beholder Intl. Ltd. 2008 */ |
4326 | /*Dmitry Belimov <d.belimov@gmail.com> */ | 4326 | /* Dmitry Belimov <d.belimov@gmail.com> */ |
4327 | .name = "Beholder BeholdTV Columbus TVFM", | 4327 | .name = "Beholder BeholdTV Columbus TV/FM", |
4328 | .audio_clock = 0x00187de7, | 4328 | .audio_clock = 0x00187de7, |
4329 | .tuner_type = TUNER_ALPS_TSBE5_PAL, | 4329 | .tuner_type = TUNER_ALPS_TSBE5_PAL, |
4330 | .radio_type = UNSET, | 4330 | .radio_type = TUNER_TEA5767, |
4331 | .tuner_addr = ADDR_UNSET, | 4331 | .tuner_addr = 0xc2 >> 1, |
4332 | .radio_addr = ADDR_UNSET, | 4332 | .radio_addr = 0xc0 >> 1, |
4333 | .tda9887_conf = TDA9887_PRESENT, | 4333 | .tda9887_conf = TDA9887_PRESENT, |
4334 | .gpiomask = 0x000A8004, | 4334 | .gpiomask = 0x000A8004, |
4335 | .inputs = {{ | 4335 | .inputs = {{ |
diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c index 5713f3a4b76c..ddd25d32723d 100644 --- a/drivers/media/video/saa7164/saa7164-buffer.c +++ b/drivers/media/video/saa7164/saa7164-buffer.c | |||
@@ -136,10 +136,11 @@ ret: | |||
136 | int saa7164_buffer_dealloc(struct saa7164_tsport *port, | 136 | int saa7164_buffer_dealloc(struct saa7164_tsport *port, |
137 | struct saa7164_buffer *buf) | 137 | struct saa7164_buffer *buf) |
138 | { | 138 | { |
139 | struct saa7164_dev *dev = port->dev; | 139 | struct saa7164_dev *dev; |
140 | 140 | ||
141 | if ((buf == 0) || (port == 0)) | 141 | if (!buf || !port) |
142 | return SAA_ERR_BAD_PARAMETER; | 142 | return SAA_ERR_BAD_PARAMETER; |
143 | dev = port->dev; | ||
143 | 144 | ||
144 | dprintk(DBGLVL_BUF, "%s() deallocating buffer @ 0x%p\n", __func__, buf); | 145 | dprintk(DBGLVL_BUF, "%s() deallocating buffer @ 0x%p\n", __func__, buf); |
145 | 146 | ||
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c index 8bdd940f32e6..2ac85d8984f0 100644 --- a/drivers/media/video/uvc/uvc_driver.c +++ b/drivers/media/video/uvc/uvc_driver.c | |||
@@ -486,6 +486,12 @@ static int uvc_parse_format(struct uvc_device *dev, | |||
486 | max(frame->dwFrameInterval[0], | 486 | max(frame->dwFrameInterval[0], |
487 | frame->dwDefaultFrameInterval)); | 487 | frame->dwDefaultFrameInterval)); |
488 | 488 | ||
489 | if (dev->quirks & UVC_QUIRK_RESTRICT_FRAME_RATE) { | ||
490 | frame->bFrameIntervalType = 1; | ||
491 | frame->dwFrameInterval[0] = | ||
492 | frame->dwDefaultFrameInterval; | ||
493 | } | ||
494 | |||
489 | uvc_trace(UVC_TRACE_DESCR, "- %ux%u (%u.%u fps)\n", | 495 | uvc_trace(UVC_TRACE_DESCR, "- %ux%u (%u.%u fps)\n", |
490 | frame->wWidth, frame->wHeight, | 496 | frame->wWidth, frame->wHeight, |
491 | 10000000/frame->dwDefaultFrameInterval, | 497 | 10000000/frame->dwDefaultFrameInterval, |
@@ -2026,6 +2032,15 @@ static struct usb_device_id uvc_ids[] = { | |||
2026 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | 2032 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, |
2027 | .bInterfaceSubClass = 1, | 2033 | .bInterfaceSubClass = 1, |
2028 | .bInterfaceProtocol = 0 }, | 2034 | .bInterfaceProtocol = 0 }, |
2035 | /* Chicony CNF7129 (Asus EEE 100HE) */ | ||
2036 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
2037 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
2038 | .idVendor = 0x04f2, | ||
2039 | .idProduct = 0xb071, | ||
2040 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
2041 | .bInterfaceSubClass = 1, | ||
2042 | .bInterfaceProtocol = 0, | ||
2043 | .driver_info = UVC_QUIRK_RESTRICT_FRAME_RATE }, | ||
2029 | /* Alcor Micro AU3820 (Future Boy PC USB Webcam) */ | 2044 | /* Alcor Micro AU3820 (Future Boy PC USB Webcam) */ |
2030 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2045 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2031 | | USB_DEVICE_ID_MATCH_INT_INFO, | 2046 | | USB_DEVICE_ID_MATCH_INT_INFO, |
@@ -2091,6 +2106,15 @@ static struct usb_device_id uvc_ids[] = { | |||
2091 | .bInterfaceProtocol = 0, | 2106 | .bInterfaceProtocol = 0, |
2092 | .driver_info = UVC_QUIRK_PROBE_MINMAX | 2107 | .driver_info = UVC_QUIRK_PROBE_MINMAX |
2093 | | UVC_QUIRK_PROBE_DEF }, | 2108 | | UVC_QUIRK_PROBE_DEF }, |
2109 | /* IMC Networks (Medion Akoya) */ | ||
2110 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
2111 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
2112 | .idVendor = 0x13d3, | ||
2113 | .idProduct = 0x5103, | ||
2114 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
2115 | .bInterfaceSubClass = 1, | ||
2116 | .bInterfaceProtocol = 0, | ||
2117 | .driver_info = UVC_QUIRK_STREAM_NO_FID }, | ||
2094 | /* Syntek (HP Spartan) */ | 2118 | /* Syntek (HP Spartan) */ |
2095 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2119 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2096 | | USB_DEVICE_ID_MATCH_INT_INFO, | 2120 | | USB_DEVICE_ID_MATCH_INT_INFO, |
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h index bdacf3beabf5..892e0e51916c 100644 --- a/drivers/media/video/uvc/uvcvideo.h +++ b/drivers/media/video/uvc/uvcvideo.h | |||
@@ -182,6 +182,7 @@ struct uvc_xu_control { | |||
182 | #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020 | 182 | #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020 |
183 | #define UVC_QUIRK_FIX_BANDWIDTH 0x00000080 | 183 | #define UVC_QUIRK_FIX_BANDWIDTH 0x00000080 |
184 | #define UVC_QUIRK_PROBE_DEF 0x00000100 | 184 | #define UVC_QUIRK_PROBE_DEF 0x00000100 |
185 | #define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200 | ||
185 | 186 | ||
186 | /* Format flags */ | 187 | /* Format flags */ |
187 | #define UVC_FMT_FLAG_COMPRESSED 0x00000001 | 188 | #define UVC_FMT_FLAG_COMPRESSED 0x00000001 |
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c index 073f01390cdd..86294ed35c9b 100644 --- a/drivers/media/video/v4l2-compat-ioctl32.c +++ b/drivers/media/video/v4l2-compat-ioctl32.c | |||
@@ -193,17 +193,24 @@ static int put_video_window32(struct video_window *kp, struct video_window32 __u | |||
193 | struct video_code32 { | 193 | struct video_code32 { |
194 | char loadwhat[16]; /* name or tag of file being passed */ | 194 | char loadwhat[16]; /* name or tag of file being passed */ |
195 | compat_int_t datasize; | 195 | compat_int_t datasize; |
196 | unsigned char *data; | 196 | compat_uptr_t data; |
197 | }; | 197 | }; |
198 | 198 | ||
199 | static int get_microcode32(struct video_code *kp, struct video_code32 __user *up) | 199 | static struct video_code __user *get_microcode32(struct video_code32 *kp) |
200 | { | 200 | { |
201 | if (!access_ok(VERIFY_READ, up, sizeof(struct video_code32)) || | 201 | struct video_code __user *up; |
202 | copy_from_user(kp->loadwhat, up->loadwhat, sizeof(up->loadwhat)) || | 202 | |
203 | get_user(kp->datasize, &up->datasize) || | 203 | up = compat_alloc_user_space(sizeof(*up)); |
204 | copy_from_user(kp->data, up->data, up->datasize)) | 204 | |
205 | return -EFAULT; | 205 | /* |
206 | return 0; | 206 | * NOTE! We don't actually care if these fail. If the |
207 | * user address is invalid, the native ioctl will do | ||
208 | * the error handling for us | ||
209 | */ | ||
210 | (void) copy_to_user(up->loadwhat, kp->loadwhat, sizeof(up->loadwhat)); | ||
211 | (void) put_user(kp->datasize, &up->datasize); | ||
212 | (void) put_user(compat_ptr(kp->data), &up->data); | ||
213 | return up; | ||
207 | } | 214 | } |
208 | 215 | ||
209 | #define VIDIOCGTUNER32 _IOWR('v', 4, struct video_tuner32) | 216 | #define VIDIOCGTUNER32 _IOWR('v', 4, struct video_tuner32) |
@@ -739,7 +746,7 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar | |||
739 | struct video_tuner vt; | 746 | struct video_tuner vt; |
740 | struct video_buffer vb; | 747 | struct video_buffer vb; |
741 | struct video_window vw; | 748 | struct video_window vw; |
742 | struct video_code vc; | 749 | struct video_code32 vc; |
743 | struct video_audio va; | 750 | struct video_audio va; |
744 | #endif | 751 | #endif |
745 | struct v4l2_format v2f; | 752 | struct v4l2_format v2f; |
@@ -818,8 +825,11 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar | |||
818 | break; | 825 | break; |
819 | 826 | ||
820 | case VIDIOCSMICROCODE: | 827 | case VIDIOCSMICROCODE: |
821 | err = get_microcode32(&karg.vc, up); | 828 | /* Copy the 32-bit "video_code32" to kernel space */ |
822 | compatible_arg = 0; | 829 | if (copy_from_user(&karg.vc, up, sizeof(karg.vc))) |
830 | return -EFAULT; | ||
831 | /* Convert the 32-bit version to a 64-bit version in user space */ | ||
832 | up = get_microcode32(&karg.vc); | ||
823 | break; | 833 | break; |
824 | 834 | ||
825 | case VIDIOCSFREQ: | 835 | case VIDIOCSFREQ: |
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c index 372b87efcd05..6ff9e4bac3ea 100644 --- a/drivers/media/video/videobuf-dma-contig.c +++ b/drivers/media/video/videobuf-dma-contig.c | |||
@@ -393,8 +393,10 @@ void videobuf_dma_contig_free(struct videobuf_queue *q, | |||
393 | } | 393 | } |
394 | 394 | ||
395 | /* read() method */ | 395 | /* read() method */ |
396 | dma_free_coherent(q->dev, mem->size, mem->vaddr, mem->dma_handle); | 396 | if (mem->vaddr) { |
397 | mem->vaddr = NULL; | 397 | dma_free_coherent(q->dev, mem->size, mem->vaddr, mem->dma_handle); |
398 | mem->vaddr = NULL; | ||
399 | } | ||
398 | } | 400 | } |
399 | EXPORT_SYMBOL_GPL(videobuf_dma_contig_free); | 401 | EXPORT_SYMBOL_GPL(videobuf_dma_contig_free); |
400 | 402 | ||
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 06f9a9c2a39a..2ad0bc252b0e 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
@@ -94,7 +94,7 @@ err: | |||
94 | * must free the memory. | 94 | * must free the memory. |
95 | */ | 95 | */ |
96 | static struct scatterlist *videobuf_pages_to_sg(struct page **pages, | 96 | static struct scatterlist *videobuf_pages_to_sg(struct page **pages, |
97 | int nr_pages, int offset) | 97 | int nr_pages, int offset, size_t size) |
98 | { | 98 | { |
99 | struct scatterlist *sglist; | 99 | struct scatterlist *sglist; |
100 | int i; | 100 | int i; |
@@ -110,12 +110,14 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages, | |||
110 | /* DMA to highmem pages might not work */ | 110 | /* DMA to highmem pages might not work */ |
111 | goto highmem; | 111 | goto highmem; |
112 | sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset); | 112 | sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset); |
113 | size -= PAGE_SIZE - offset; | ||
113 | for (i = 1; i < nr_pages; i++) { | 114 | for (i = 1; i < nr_pages; i++) { |
114 | if (NULL == pages[i]) | 115 | if (NULL == pages[i]) |
115 | goto nopage; | 116 | goto nopage; |
116 | if (PageHighMem(pages[i])) | 117 | if (PageHighMem(pages[i])) |
117 | goto highmem; | 118 | goto highmem; |
118 | sg_set_page(&sglist[i], pages[i], PAGE_SIZE, 0); | 119 | sg_set_page(&sglist[i], pages[i], min(PAGE_SIZE, size), 0); |
120 | size -= min(PAGE_SIZE, size); | ||
119 | } | 121 | } |
120 | return sglist; | 122 | return sglist; |
121 | 123 | ||
@@ -170,7 +172,8 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, | |||
170 | 172 | ||
171 | first = (data & PAGE_MASK) >> PAGE_SHIFT; | 173 | first = (data & PAGE_MASK) >> PAGE_SHIFT; |
172 | last = ((data+size-1) & PAGE_MASK) >> PAGE_SHIFT; | 174 | last = ((data+size-1) & PAGE_MASK) >> PAGE_SHIFT; |
173 | dma->offset = data & ~PAGE_MASK; | 175 | dma->offset = data & ~PAGE_MASK; |
176 | dma->size = size; | ||
174 | dma->nr_pages = last-first+1; | 177 | dma->nr_pages = last-first+1; |
175 | dma->pages = kmalloc(dma->nr_pages * sizeof(struct page *), GFP_KERNEL); | 178 | dma->pages = kmalloc(dma->nr_pages * sizeof(struct page *), GFP_KERNEL); |
176 | if (NULL == dma->pages) | 179 | if (NULL == dma->pages) |
@@ -252,7 +255,7 @@ int videobuf_dma_map(struct device *dev, struct videobuf_dmabuf *dma) | |||
252 | 255 | ||
253 | if (dma->pages) { | 256 | if (dma->pages) { |
254 | dma->sglist = videobuf_pages_to_sg(dma->pages, dma->nr_pages, | 257 | dma->sglist = videobuf_pages_to_sg(dma->pages, dma->nr_pages, |
255 | dma->offset); | 258 | dma->offset, dma->size); |
256 | } | 259 | } |
257 | if (dma->vaddr) { | 260 | if (dma->vaddr) { |
258 | dma->sglist = videobuf_vmalloc_to_sg(dma->vaddr, | 261 | dma->sglist = videobuf_vmalloc_to_sg(dma->vaddr, |
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index 097f24d8bceb..b9fda7018cef 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c | |||
@@ -78,7 +78,7 @@ struct sih { | |||
78 | u8 irq_lines; /* number of supported irq lines */ | 78 | u8 irq_lines; /* number of supported irq lines */ |
79 | 79 | ||
80 | /* SIR ignored -- set interrupt, for testing only */ | 80 | /* SIR ignored -- set interrupt, for testing only */ |
81 | struct irq_data { | 81 | struct sih_irq_data { |
82 | u8 isr_offset; | 82 | u8 isr_offset; |
83 | u8 imr_offset; | 83 | u8 imr_offset; |
84 | } mask[2]; | 84 | } mask[2]; |
@@ -810,7 +810,7 @@ int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) | |||
810 | twl4030_irq_chip = dummy_irq_chip; | 810 | twl4030_irq_chip = dummy_irq_chip; |
811 | twl4030_irq_chip.name = "twl4030"; | 811 | twl4030_irq_chip.name = "twl4030"; |
812 | 812 | ||
813 | twl4030_sih_irq_chip.ack = dummy_irq_chip.ack; | 813 | twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack; |
814 | 814 | ||
815 | for (i = irq_base; i < irq_end; i++) { | 815 | for (i = irq_base; i < irq_end; i++) { |
816 | set_irq_chip_and_handler(i, &twl4030_irq_chip, | 816 | set_irq_chip_and_handler(i, &twl4030_irq_chip, |
diff --git a/drivers/misc/bh1780gli.c b/drivers/misc/bh1780gli.c index 714c6b487313..d5f3a3fd2319 100644 --- a/drivers/misc/bh1780gli.c +++ b/drivers/misc/bh1780gli.c | |||
@@ -190,7 +190,6 @@ static int __devexit bh1780_remove(struct i2c_client *client) | |||
190 | 190 | ||
191 | ddata = i2c_get_clientdata(client); | 191 | ddata = i2c_get_clientdata(client); |
192 | sysfs_remove_group(&client->dev.kobj, &bh1780_attr_group); | 192 | sysfs_remove_group(&client->dev.kobj, &bh1780_attr_group); |
193 | i2c_set_clientdata(client, NULL); | ||
194 | kfree(ddata); | 193 | kfree(ddata); |
195 | 194 | ||
196 | return 0; | 195 | return 0; |
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 5db49b124ffa..09eee6df0653 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -1631,6 +1631,19 @@ int mmc_suspend_host(struct mmc_host *host) | |||
1631 | if (host->bus_ops && !host->bus_dead) { | 1631 | if (host->bus_ops && !host->bus_dead) { |
1632 | if (host->bus_ops->suspend) | 1632 | if (host->bus_ops->suspend) |
1633 | err = host->bus_ops->suspend(host); | 1633 | err = host->bus_ops->suspend(host); |
1634 | if (err == -ENOSYS || !host->bus_ops->resume) { | ||
1635 | /* | ||
1636 | * We simply "remove" the card in this case. | ||
1637 | * It will be redetected on resume. | ||
1638 | */ | ||
1639 | if (host->bus_ops->remove) | ||
1640 | host->bus_ops->remove(host); | ||
1641 | mmc_claim_host(host); | ||
1642 | mmc_detach_bus(host); | ||
1643 | mmc_release_host(host); | ||
1644 | host->pm_flags = 0; | ||
1645 | err = 0; | ||
1646 | } | ||
1634 | } | 1647 | } |
1635 | mmc_bus_put(host); | 1648 | mmc_bus_put(host); |
1636 | 1649 | ||
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index b2828e84d243..214b03afdd48 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
31 | #include <linux/err.h> | 31 | #include <linux/err.h> |
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | #include <linux/irq.h> | ||
34 | #include <linux/completion.h> | ||
33 | 35 | ||
34 | #include <asm/mach/flash.h> | 36 | #include <asm/mach/flash.h> |
35 | #include <mach/mxc_nand.h> | 37 | #include <mach/mxc_nand.h> |
@@ -151,7 +153,7 @@ struct mxc_nand_host { | |||
151 | int irq; | 153 | int irq; |
152 | int eccsize; | 154 | int eccsize; |
153 | 155 | ||
154 | wait_queue_head_t irq_waitq; | 156 | struct completion op_completion; |
155 | 157 | ||
156 | uint8_t *data_buf; | 158 | uint8_t *data_buf; |
157 | unsigned int buf_start; | 159 | unsigned int buf_start; |
@@ -164,6 +166,7 @@ struct mxc_nand_host { | |||
164 | void (*send_read_id)(struct mxc_nand_host *); | 166 | void (*send_read_id)(struct mxc_nand_host *); |
165 | uint16_t (*get_dev_status)(struct mxc_nand_host *); | 167 | uint16_t (*get_dev_status)(struct mxc_nand_host *); |
166 | int (*check_int)(struct mxc_nand_host *); | 168 | int (*check_int)(struct mxc_nand_host *); |
169 | void (*irq_control)(struct mxc_nand_host *, int); | ||
167 | }; | 170 | }; |
168 | 171 | ||
169 | /* OOB placement block for use with hardware ecc generation */ | 172 | /* OOB placement block for use with hardware ecc generation */ |
@@ -216,9 +219,12 @@ static irqreturn_t mxc_nfc_irq(int irq, void *dev_id) | |||
216 | { | 219 | { |
217 | struct mxc_nand_host *host = dev_id; | 220 | struct mxc_nand_host *host = dev_id; |
218 | 221 | ||
219 | disable_irq_nosync(irq); | 222 | if (!host->check_int(host)) |
223 | return IRQ_NONE; | ||
220 | 224 | ||
221 | wake_up(&host->irq_waitq); | 225 | host->irq_control(host, 0); |
226 | |||
227 | complete(&host->op_completion); | ||
222 | 228 | ||
223 | return IRQ_HANDLED; | 229 | return IRQ_HANDLED; |
224 | } | 230 | } |
@@ -245,11 +251,54 @@ static int check_int_v1_v2(struct mxc_nand_host *host) | |||
245 | if (!(tmp & NFC_V1_V2_CONFIG2_INT)) | 251 | if (!(tmp & NFC_V1_V2_CONFIG2_INT)) |
246 | return 0; | 252 | return 0; |
247 | 253 | ||
248 | writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2); | 254 | if (!cpu_is_mx21()) |
255 | writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2); | ||
249 | 256 | ||
250 | return 1; | 257 | return 1; |
251 | } | 258 | } |
252 | 259 | ||
260 | /* | ||
261 | * It has been observed that the i.MX21 cannot read the CONFIG2:INT bit | ||
262 | * if interrupts are masked (CONFIG1:INT_MSK is set). To handle this, the | ||
263 | * driver can enable/disable the irq line rather than simply masking the | ||
264 | * interrupts. | ||
265 | */ | ||
266 | static void irq_control_mx21(struct mxc_nand_host *host, int activate) | ||
267 | { | ||
268 | if (activate) | ||
269 | enable_irq(host->irq); | ||
270 | else | ||
271 | disable_irq_nosync(host->irq); | ||
272 | } | ||
273 | |||
274 | static void irq_control_v1_v2(struct mxc_nand_host *host, int activate) | ||
275 | { | ||
276 | uint16_t tmp; | ||
277 | |||
278 | tmp = readw(NFC_V1_V2_CONFIG1); | ||
279 | |||
280 | if (activate) | ||
281 | tmp &= ~NFC_V1_V2_CONFIG1_INT_MSK; | ||
282 | else | ||
283 | tmp |= NFC_V1_V2_CONFIG1_INT_MSK; | ||
284 | |||
285 | writew(tmp, NFC_V1_V2_CONFIG1); | ||
286 | } | ||
287 | |||
288 | static void irq_control_v3(struct mxc_nand_host *host, int activate) | ||
289 | { | ||
290 | uint32_t tmp; | ||
291 | |||
292 | tmp = readl(NFC_V3_CONFIG2); | ||
293 | |||
294 | if (activate) | ||
295 | tmp &= ~NFC_V3_CONFIG2_INT_MSK; | ||
296 | else | ||
297 | tmp |= NFC_V3_CONFIG2_INT_MSK; | ||
298 | |||
299 | writel(tmp, NFC_V3_CONFIG2); | ||
300 | } | ||
301 | |||
253 | /* This function polls the NANDFC to wait for the basic operation to | 302 | /* This function polls the NANDFC to wait for the basic operation to |
254 | * complete by checking the INT bit of config2 register. | 303 | * complete by checking the INT bit of config2 register. |
255 | */ | 304 | */ |
@@ -259,10 +308,9 @@ static void wait_op_done(struct mxc_nand_host *host, int useirq) | |||
259 | 308 | ||
260 | if (useirq) { | 309 | if (useirq) { |
261 | if (!host->check_int(host)) { | 310 | if (!host->check_int(host)) { |
262 | 311 | INIT_COMPLETION(host->op_completion); | |
263 | enable_irq(host->irq); | 312 | host->irq_control(host, 1); |
264 | 313 | wait_for_completion(&host->op_completion); | |
265 | wait_event(host->irq_waitq, host->check_int(host)); | ||
266 | } | 314 | } |
267 | } else { | 315 | } else { |
268 | while (max_retries-- > 0) { | 316 | while (max_retries-- > 0) { |
@@ -799,6 +847,7 @@ static void preset_v3(struct mtd_info *mtd) | |||
799 | NFC_V3_CONFIG2_2CMD_PHASES | | 847 | NFC_V3_CONFIG2_2CMD_PHASES | |
800 | NFC_V3_CONFIG2_SPAS(mtd->oobsize >> 1) | | 848 | NFC_V3_CONFIG2_SPAS(mtd->oobsize >> 1) | |
801 | NFC_V3_CONFIG2_ST_CMD(0x70) | | 849 | NFC_V3_CONFIG2_ST_CMD(0x70) | |
850 | NFC_V3_CONFIG2_INT_MSK | | ||
802 | NFC_V3_CONFIG2_NUM_ADDR_PHASE0; | 851 | NFC_V3_CONFIG2_NUM_ADDR_PHASE0; |
803 | 852 | ||
804 | if (chip->ecc.mode == NAND_ECC_HW) | 853 | if (chip->ecc.mode == NAND_ECC_HW) |
@@ -1024,6 +1073,10 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1024 | host->send_read_id = send_read_id_v1_v2; | 1073 | host->send_read_id = send_read_id_v1_v2; |
1025 | host->get_dev_status = get_dev_status_v1_v2; | 1074 | host->get_dev_status = get_dev_status_v1_v2; |
1026 | host->check_int = check_int_v1_v2; | 1075 | host->check_int = check_int_v1_v2; |
1076 | if (cpu_is_mx21()) | ||
1077 | host->irq_control = irq_control_mx21; | ||
1078 | else | ||
1079 | host->irq_control = irq_control_v1_v2; | ||
1027 | } | 1080 | } |
1028 | 1081 | ||
1029 | if (nfc_is_v21()) { | 1082 | if (nfc_is_v21()) { |
@@ -1062,6 +1115,7 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1062 | host->send_read_id = send_read_id_v3; | 1115 | host->send_read_id = send_read_id_v3; |
1063 | host->check_int = check_int_v3; | 1116 | host->check_int = check_int_v3; |
1064 | host->get_dev_status = get_dev_status_v3; | 1117 | host->get_dev_status = get_dev_status_v3; |
1118 | host->irq_control = irq_control_v3; | ||
1065 | oob_smallpage = &nandv2_hw_eccoob_smallpage; | 1119 | oob_smallpage = &nandv2_hw_eccoob_smallpage; |
1066 | oob_largepage = &nandv2_hw_eccoob_largepage; | 1120 | oob_largepage = &nandv2_hw_eccoob_largepage; |
1067 | } else | 1121 | } else |
@@ -1093,14 +1147,34 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1093 | this->options |= NAND_USE_FLASH_BBT; | 1147 | this->options |= NAND_USE_FLASH_BBT; |
1094 | } | 1148 | } |
1095 | 1149 | ||
1096 | init_waitqueue_head(&host->irq_waitq); | 1150 | init_completion(&host->op_completion); |
1097 | 1151 | ||
1098 | host->irq = platform_get_irq(pdev, 0); | 1152 | host->irq = platform_get_irq(pdev, 0); |
1099 | 1153 | ||
1154 | /* | ||
1155 | * mask the interrupt. For i.MX21 explicitely call | ||
1156 | * irq_control_v1_v2 to use the mask bit. We can't call | ||
1157 | * disable_irq_nosync() for an interrupt we do not own yet. | ||
1158 | */ | ||
1159 | if (cpu_is_mx21()) | ||
1160 | irq_control_v1_v2(host, 0); | ||
1161 | else | ||
1162 | host->irq_control(host, 0); | ||
1163 | |||
1100 | err = request_irq(host->irq, mxc_nfc_irq, IRQF_DISABLED, DRIVER_NAME, host); | 1164 | err = request_irq(host->irq, mxc_nfc_irq, IRQF_DISABLED, DRIVER_NAME, host); |
1101 | if (err) | 1165 | if (err) |
1102 | goto eirq; | 1166 | goto eirq; |
1103 | 1167 | ||
1168 | host->irq_control(host, 0); | ||
1169 | |||
1170 | /* | ||
1171 | * Now that the interrupt is disabled make sure the interrupt | ||
1172 | * mask bit is cleared on i.MX21. Otherwise we can't read | ||
1173 | * the interrupt status bit on this machine. | ||
1174 | */ | ||
1175 | if (cpu_is_mx21()) | ||
1176 | irq_control_v1_v2(host, 1); | ||
1177 | |||
1104 | /* first scan to find the device and get the page size */ | 1178 | /* first scan to find the device and get the page size */ |
1105 | if (nand_scan_ident(mtd, 1, NULL)) { | 1179 | if (nand_scan_ident(mtd, 1, NULL)) { |
1106 | err = -ENXIO; | 1180 | err = -ENXIO; |
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c index 70705d1306b9..eca55c52bdfd 100644 --- a/drivers/net/3c527.c +++ b/drivers/net/3c527.c | |||
@@ -522,7 +522,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot) | |||
522 | lp->tx_len = lp->exec_box->data[9]; /* Transmit list count */ | 522 | lp->tx_len = lp->exec_box->data[9]; /* Transmit list count */ |
523 | lp->rx_len = lp->exec_box->data[11]; /* Receive list count */ | 523 | lp->rx_len = lp->exec_box->data[11]; /* Receive list count */ |
524 | 524 | ||
525 | init_MUTEX_LOCKED(&lp->cmd_mutex); | 525 | sema_init(&lp->cmd_mutex, 0); |
526 | init_completion(&lp->execution_cmd); | 526 | init_completion(&lp->execution_cmd); |
527 | init_completion(&lp->xceiver_cmd); | 527 | init_completion(&lp->xceiver_cmd); |
528 | 528 | ||
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 2cc81a54cbf3..5db667c0b371 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -2428,7 +2428,7 @@ config UGETH_TX_ON_DEMAND | |||
2428 | 2428 | ||
2429 | config MV643XX_ETH | 2429 | config MV643XX_ETH |
2430 | tristate "Marvell Discovery (643XX) and Orion ethernet support" | 2430 | tristate "Marvell Discovery (643XX) and Orion ethernet support" |
2431 | depends on MV64X60 || PPC32 || PLAT_ORION | 2431 | depends on (MV64X60 || PPC32 || PLAT_ORION) && INET |
2432 | select INET_LRO | 2432 | select INET_LRO |
2433 | select PHYLIB | 2433 | select PHYLIB |
2434 | help | 2434 | help |
@@ -2803,7 +2803,7 @@ config NIU | |||
2803 | 2803 | ||
2804 | config PASEMI_MAC | 2804 | config PASEMI_MAC |
2805 | tristate "PA Semi 1/10Gbit MAC" | 2805 | tristate "PA Semi 1/10Gbit MAC" |
2806 | depends on PPC_PASEMI && PCI | 2806 | depends on PPC_PASEMI && PCI && INET |
2807 | select PHYLIB | 2807 | select PHYLIB |
2808 | select INET_LRO | 2808 | select INET_LRO |
2809 | help | 2809 | help |
diff --git a/drivers/net/b44.c b/drivers/net/b44.c index 1e620e287ae0..efeffdf9e5fa 100644 --- a/drivers/net/b44.c +++ b/drivers/net/b44.c | |||
@@ -2170,8 +2170,6 @@ static int __devinit b44_init_one(struct ssb_device *sdev, | |||
2170 | dev->irq = sdev->irq; | 2170 | dev->irq = sdev->irq; |
2171 | SET_ETHTOOL_OPS(dev, &b44_ethtool_ops); | 2171 | SET_ETHTOOL_OPS(dev, &b44_ethtool_ops); |
2172 | 2172 | ||
2173 | netif_carrier_off(dev); | ||
2174 | |||
2175 | err = ssb_bus_powerup(sdev->bus, 0); | 2173 | err = ssb_bus_powerup(sdev->bus, 0); |
2176 | if (err) { | 2174 | if (err) { |
2177 | dev_err(sdev->dev, | 2175 | dev_err(sdev->dev, |
@@ -2213,6 +2211,8 @@ static int __devinit b44_init_one(struct ssb_device *sdev, | |||
2213 | goto err_out_powerdown; | 2211 | goto err_out_powerdown; |
2214 | } | 2212 | } |
2215 | 2213 | ||
2214 | netif_carrier_off(dev); | ||
2215 | |||
2216 | ssb_set_drvdata(sdev, dev); | 2216 | ssb_set_drvdata(sdev, dev); |
2217 | 2217 | ||
2218 | /* Chip reset provides power to the b44 MAC & PCI cores, which | 2218 | /* Chip reset provides power to the b44 MAC & PCI cores, which |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 3b16f62d5606..e953c6ad6e6d 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -5164,6 +5164,15 @@ int bond_create(struct net *net, const char *name) | |||
5164 | res = dev_alloc_name(bond_dev, "bond%d"); | 5164 | res = dev_alloc_name(bond_dev, "bond%d"); |
5165 | if (res < 0) | 5165 | if (res < 0) |
5166 | goto out; | 5166 | goto out; |
5167 | } else { | ||
5168 | /* | ||
5169 | * If we're given a name to register | ||
5170 | * we need to ensure that its not already | ||
5171 | * registered | ||
5172 | */ | ||
5173 | res = -EEXIST; | ||
5174 | if (__dev_get_by_name(net, name) != NULL) | ||
5175 | goto out; | ||
5167 | } | 5176 | } |
5168 | 5177 | ||
5169 | res = register_netdevice(bond_dev); | 5178 | res = register_netdevice(bond_dev); |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index a333b42111b8..6372610ed240 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -533,8 +533,15 @@ static inline void ehea_fill_skb(struct net_device *dev, | |||
533 | int length = cqe->num_bytes_transfered - 4; /*remove CRC */ | 533 | int length = cqe->num_bytes_transfered - 4; /*remove CRC */ |
534 | 534 | ||
535 | skb_put(skb, length); | 535 | skb_put(skb, length); |
536 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
537 | skb->protocol = eth_type_trans(skb, dev); | 536 | skb->protocol = eth_type_trans(skb, dev); |
537 | |||
538 | /* The packet was not an IPV4 packet so a complemented checksum was | ||
539 | calculated. The value is found in the Internet Checksum field. */ | ||
540 | if (cqe->status & EHEA_CQE_BLIND_CKSUM) { | ||
541 | skb->ip_summed = CHECKSUM_COMPLETE; | ||
542 | skb->csum = csum_unfold(~cqe->inet_checksum_value); | ||
543 | } else | ||
544 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
538 | } | 545 | } |
539 | 546 | ||
540 | static inline struct sk_buff *get_skb_by_index(struct sk_buff **skb_array, | 547 | static inline struct sk_buff *get_skb_by_index(struct sk_buff **skb_array, |
diff --git a/drivers/net/ehea/ehea_qmr.h b/drivers/net/ehea/ehea_qmr.h index f608a6c54af5..38104734a3be 100644 --- a/drivers/net/ehea/ehea_qmr.h +++ b/drivers/net/ehea/ehea_qmr.h | |||
@@ -150,6 +150,7 @@ struct ehea_rwqe { | |||
150 | #define EHEA_CQE_TYPE_RQ 0x60 | 150 | #define EHEA_CQE_TYPE_RQ 0x60 |
151 | #define EHEA_CQE_STAT_ERR_MASK 0x700F | 151 | #define EHEA_CQE_STAT_ERR_MASK 0x700F |
152 | #define EHEA_CQE_STAT_FAT_ERR_MASK 0xF | 152 | #define EHEA_CQE_STAT_FAT_ERR_MASK 0xF |
153 | #define EHEA_CQE_BLIND_CKSUM 0x8000 | ||
153 | #define EHEA_CQE_STAT_ERR_TCP 0x4000 | 154 | #define EHEA_CQE_STAT_ERR_TCP 0x4000 |
154 | #define EHEA_CQE_STAT_ERR_IP 0x2000 | 155 | #define EHEA_CQE_STAT_ERR_IP 0x2000 |
155 | #define EHEA_CQE_STAT_ERR_CRC 0x1000 | 156 | #define EHEA_CQE_STAT_ERR_CRC 0x1000 |
diff --git a/drivers/net/fec.c b/drivers/net/fec.c index 768b840aeb6b..cce32d43175f 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c | |||
@@ -678,24 +678,37 @@ static int fec_enet_mii_probe(struct net_device *dev) | |||
678 | { | 678 | { |
679 | struct fec_enet_private *fep = netdev_priv(dev); | 679 | struct fec_enet_private *fep = netdev_priv(dev); |
680 | struct phy_device *phy_dev = NULL; | 680 | struct phy_device *phy_dev = NULL; |
681 | int ret; | 681 | char mdio_bus_id[MII_BUS_ID_SIZE]; |
682 | char phy_name[MII_BUS_ID_SIZE + 3]; | ||
683 | int phy_id; | ||
682 | 684 | ||
683 | fep->phy_dev = NULL; | 685 | fep->phy_dev = NULL; |
684 | 686 | ||
685 | /* find the first phy */ | 687 | /* check for attached phy */ |
686 | phy_dev = phy_find_first(fep->mii_bus); | 688 | for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) { |
687 | if (!phy_dev) { | 689 | if ((fep->mii_bus->phy_mask & (1 << phy_id))) |
688 | printk(KERN_ERR "%s: no PHY found\n", dev->name); | 690 | continue; |
689 | return -ENODEV; | 691 | if (fep->mii_bus->phy_map[phy_id] == NULL) |
692 | continue; | ||
693 | if (fep->mii_bus->phy_map[phy_id]->phy_id == 0) | ||
694 | continue; | ||
695 | strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE); | ||
696 | break; | ||
690 | } | 697 | } |
691 | 698 | ||
692 | /* attach the mac to the phy */ | 699 | if (phy_id >= PHY_MAX_ADDR) { |
693 | ret = phy_connect_direct(dev, phy_dev, | 700 | printk(KERN_INFO "%s: no PHY, assuming direct connection " |
694 | &fec_enet_adjust_link, 0, | 701 | "to switch\n", dev->name); |
695 | PHY_INTERFACE_MODE_MII); | 702 | strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); |
696 | if (ret) { | 703 | phy_id = 0; |
697 | printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); | 704 | } |
698 | return ret; | 705 | |
706 | snprintf(phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); | ||
707 | phy_dev = phy_connect(dev, phy_name, &fec_enet_adjust_link, 0, | ||
708 | PHY_INTERFACE_MODE_MII); | ||
709 | if (IS_ERR(phy_dev)) { | ||
710 | printk(KERN_ERR "%s: could not attach to PHY\n", dev->name); | ||
711 | return PTR_ERR(phy_dev); | ||
699 | } | 712 | } |
700 | 713 | ||
701 | /* mask with MAC supported features */ | 714 | /* mask with MAC supported features */ |
@@ -738,7 +751,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) | |||
738 | fep->mii_bus->read = fec_enet_mdio_read; | 751 | fep->mii_bus->read = fec_enet_mdio_read; |
739 | fep->mii_bus->write = fec_enet_mdio_write; | 752 | fep->mii_bus->write = fec_enet_mdio_write; |
740 | fep->mii_bus->reset = fec_enet_mdio_reset; | 753 | fep->mii_bus->reset = fec_enet_mdio_reset; |
741 | snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); | 754 | snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id + 1); |
742 | fep->mii_bus->priv = fep; | 755 | fep->mii_bus->priv = fep; |
743 | fep->mii_bus->parent = &pdev->dev; | 756 | fep->mii_bus->parent = &pdev->dev; |
744 | 757 | ||
@@ -1311,6 +1324,9 @@ fec_probe(struct platform_device *pdev) | |||
1311 | if (ret) | 1324 | if (ret) |
1312 | goto failed_mii_init; | 1325 | goto failed_mii_init; |
1313 | 1326 | ||
1327 | /* Carrier starts down, phylib will bring it up */ | ||
1328 | netif_carrier_off(ndev); | ||
1329 | |||
1314 | ret = register_netdev(ndev); | 1330 | ret = register_netdev(ndev); |
1315 | if (ret) | 1331 | if (ret) |
1316 | goto failed_register; | 1332 | goto failed_register; |
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c index 4b52c767ad05..3e5d0b6b6516 100644 --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c | |||
@@ -608,7 +608,7 @@ static int sixpack_open(struct tty_struct *tty) | |||
608 | 608 | ||
609 | spin_lock_init(&sp->lock); | 609 | spin_lock_init(&sp->lock); |
610 | atomic_set(&sp->refcnt, 1); | 610 | atomic_set(&sp->refcnt, 1); |
611 | init_MUTEX_LOCKED(&sp->dead_sem); | 611 | sema_init(&sp->dead_sem, 0); |
612 | 612 | ||
613 | /* !!! length of the buffers. MTU is IP MTU, not PACLEN! */ | 613 | /* !!! length of the buffers. MTU is IP MTU, not PACLEN! */ |
614 | 614 | ||
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index 66e88bd59caa..4c628393c8b1 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c | |||
@@ -747,7 +747,7 @@ static int mkiss_open(struct tty_struct *tty) | |||
747 | 747 | ||
748 | spin_lock_init(&ax->buflock); | 748 | spin_lock_init(&ax->buflock); |
749 | atomic_set(&ax->refcnt, 1); | 749 | atomic_set(&ax->refcnt, 1); |
750 | init_MUTEX_LOCKED(&ax->dead_sem); | 750 | sema_init(&ax->dead_sem, 0); |
751 | 751 | ||
752 | ax->tty = tty; | 752 | ax->tty = tty; |
753 | tty->disc_data = ax; | 753 | tty->disc_data = ax; |
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c index 1b051dab7b29..51d74447f8f8 100644 --- a/drivers/net/irda/sir_dev.c +++ b/drivers/net/irda/sir_dev.c | |||
@@ -909,7 +909,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n | |||
909 | dev->tx_skb = NULL; | 909 | dev->tx_skb = NULL; |
910 | 910 | ||
911 | spin_lock_init(&dev->tx_lock); | 911 | spin_lock_init(&dev->tx_lock); |
912 | init_MUTEX(&dev->fsm.sem); | 912 | sema_init(&dev->fsm.sem, 1); |
913 | 913 | ||
914 | dev->drv = drv; | 914 | dev->drv = drv; |
915 | dev->netdev = ndev; | 915 | dev->netdev = ndev; |
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c index af50a530daee..78d70a6481bf 100644 --- a/drivers/net/ppp_async.c +++ b/drivers/net/ppp_async.c | |||
@@ -184,7 +184,7 @@ ppp_asynctty_open(struct tty_struct *tty) | |||
184 | tasklet_init(&ap->tsk, ppp_async_process, (unsigned long) ap); | 184 | tasklet_init(&ap->tsk, ppp_async_process, (unsigned long) ap); |
185 | 185 | ||
186 | atomic_set(&ap->refcnt, 1); | 186 | atomic_set(&ap->refcnt, 1); |
187 | init_MUTEX_LOCKED(&ap->dead_sem); | 187 | sema_init(&ap->dead_sem, 0); |
188 | 188 | ||
189 | ap->chan.private = ap; | 189 | ap->chan.private = ap; |
190 | ap->chan.ops = &async_ops; | 190 | ap->chan.ops = &async_ops; |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index a0da4a17b025..992db2fa136e 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -1212,7 +1212,8 @@ static void rtl8169_update_counters(struct net_device *dev) | |||
1212 | if ((RTL_R8(ChipCmd) & CmdRxEnb) == 0) | 1212 | if ((RTL_R8(ChipCmd) & CmdRxEnb) == 0) |
1213 | return; | 1213 | return; |
1214 | 1214 | ||
1215 | counters = pci_alloc_consistent(tp->pci_dev, sizeof(*counters), &paddr); | 1215 | counters = dma_alloc_coherent(&tp->pci_dev->dev, sizeof(*counters), |
1216 | &paddr, GFP_KERNEL); | ||
1216 | if (!counters) | 1217 | if (!counters) |
1217 | return; | 1218 | return; |
1218 | 1219 | ||
@@ -1233,7 +1234,8 @@ static void rtl8169_update_counters(struct net_device *dev) | |||
1233 | RTL_W32(CounterAddrLow, 0); | 1234 | RTL_W32(CounterAddrLow, 0); |
1234 | RTL_W32(CounterAddrHigh, 0); | 1235 | RTL_W32(CounterAddrHigh, 0); |
1235 | 1236 | ||
1236 | pci_free_consistent(tp->pci_dev, sizeof(*counters), counters, paddr); | 1237 | dma_free_coherent(&tp->pci_dev->dev, sizeof(*counters), counters, |
1238 | paddr); | ||
1237 | } | 1239 | } |
1238 | 1240 | ||
1239 | static void rtl8169_get_ethtool_stats(struct net_device *dev, | 1241 | static void rtl8169_get_ethtool_stats(struct net_device *dev, |
@@ -3292,15 +3294,15 @@ static int rtl8169_open(struct net_device *dev) | |||
3292 | 3294 | ||
3293 | /* | 3295 | /* |
3294 | * Rx and Tx desscriptors needs 256 bytes alignment. | 3296 | * Rx and Tx desscriptors needs 256 bytes alignment. |
3295 | * pci_alloc_consistent provides more. | 3297 | * dma_alloc_coherent provides more. |
3296 | */ | 3298 | */ |
3297 | tp->TxDescArray = pci_alloc_consistent(pdev, R8169_TX_RING_BYTES, | 3299 | tp->TxDescArray = dma_alloc_coherent(&pdev->dev, R8169_TX_RING_BYTES, |
3298 | &tp->TxPhyAddr); | 3300 | &tp->TxPhyAddr, GFP_KERNEL); |
3299 | if (!tp->TxDescArray) | 3301 | if (!tp->TxDescArray) |
3300 | goto err_pm_runtime_put; | 3302 | goto err_pm_runtime_put; |
3301 | 3303 | ||
3302 | tp->RxDescArray = pci_alloc_consistent(pdev, R8169_RX_RING_BYTES, | 3304 | tp->RxDescArray = dma_alloc_coherent(&pdev->dev, R8169_RX_RING_BYTES, |
3303 | &tp->RxPhyAddr); | 3305 | &tp->RxPhyAddr, GFP_KERNEL); |
3304 | if (!tp->RxDescArray) | 3306 | if (!tp->RxDescArray) |
3305 | goto err_free_tx_0; | 3307 | goto err_free_tx_0; |
3306 | 3308 | ||
@@ -3334,12 +3336,12 @@ out: | |||
3334 | err_release_ring_2: | 3336 | err_release_ring_2: |
3335 | rtl8169_rx_clear(tp); | 3337 | rtl8169_rx_clear(tp); |
3336 | err_free_rx_1: | 3338 | err_free_rx_1: |
3337 | pci_free_consistent(pdev, R8169_RX_RING_BYTES, tp->RxDescArray, | 3339 | dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, |
3338 | tp->RxPhyAddr); | 3340 | tp->RxPhyAddr); |
3339 | tp->RxDescArray = NULL; | 3341 | tp->RxDescArray = NULL; |
3340 | err_free_tx_0: | 3342 | err_free_tx_0: |
3341 | pci_free_consistent(pdev, R8169_TX_RING_BYTES, tp->TxDescArray, | 3343 | dma_free_coherent(&pdev->dev, R8169_TX_RING_BYTES, tp->TxDescArray, |
3342 | tp->TxPhyAddr); | 3344 | tp->TxPhyAddr); |
3343 | tp->TxDescArray = NULL; | 3345 | tp->TxDescArray = NULL; |
3344 | err_pm_runtime_put: | 3346 | err_pm_runtime_put: |
3345 | pm_runtime_put_noidle(&pdev->dev); | 3347 | pm_runtime_put_noidle(&pdev->dev); |
@@ -3975,7 +3977,7 @@ static void rtl8169_free_rx_skb(struct rtl8169_private *tp, | |||
3975 | { | 3977 | { |
3976 | struct pci_dev *pdev = tp->pci_dev; | 3978 | struct pci_dev *pdev = tp->pci_dev; |
3977 | 3979 | ||
3978 | pci_unmap_single(pdev, le64_to_cpu(desc->addr), tp->rx_buf_sz, | 3980 | dma_unmap_single(&pdev->dev, le64_to_cpu(desc->addr), tp->rx_buf_sz, |
3979 | PCI_DMA_FROMDEVICE); | 3981 | PCI_DMA_FROMDEVICE); |
3980 | dev_kfree_skb(*sk_buff); | 3982 | dev_kfree_skb(*sk_buff); |
3981 | *sk_buff = NULL; | 3983 | *sk_buff = NULL; |
@@ -4000,7 +4002,7 @@ static inline void rtl8169_map_to_asic(struct RxDesc *desc, dma_addr_t mapping, | |||
4000 | static struct sk_buff *rtl8169_alloc_rx_skb(struct pci_dev *pdev, | 4002 | static struct sk_buff *rtl8169_alloc_rx_skb(struct pci_dev *pdev, |
4001 | struct net_device *dev, | 4003 | struct net_device *dev, |
4002 | struct RxDesc *desc, int rx_buf_sz, | 4004 | struct RxDesc *desc, int rx_buf_sz, |
4003 | unsigned int align) | 4005 | unsigned int align, gfp_t gfp) |
4004 | { | 4006 | { |
4005 | struct sk_buff *skb; | 4007 | struct sk_buff *skb; |
4006 | dma_addr_t mapping; | 4008 | dma_addr_t mapping; |
@@ -4008,13 +4010,13 @@ static struct sk_buff *rtl8169_alloc_rx_skb(struct pci_dev *pdev, | |||
4008 | 4010 | ||
4009 | pad = align ? align : NET_IP_ALIGN; | 4011 | pad = align ? align : NET_IP_ALIGN; |
4010 | 4012 | ||
4011 | skb = netdev_alloc_skb(dev, rx_buf_sz + pad); | 4013 | skb = __netdev_alloc_skb(dev, rx_buf_sz + pad, gfp); |
4012 | if (!skb) | 4014 | if (!skb) |
4013 | goto err_out; | 4015 | goto err_out; |
4014 | 4016 | ||
4015 | skb_reserve(skb, align ? ((pad - 1) & (unsigned long)skb->data) : pad); | 4017 | skb_reserve(skb, align ? ((pad - 1) & (unsigned long)skb->data) : pad); |
4016 | 4018 | ||
4017 | mapping = pci_map_single(pdev, skb->data, rx_buf_sz, | 4019 | mapping = dma_map_single(&pdev->dev, skb->data, rx_buf_sz, |
4018 | PCI_DMA_FROMDEVICE); | 4020 | PCI_DMA_FROMDEVICE); |
4019 | 4021 | ||
4020 | rtl8169_map_to_asic(desc, mapping, rx_buf_sz); | 4022 | rtl8169_map_to_asic(desc, mapping, rx_buf_sz); |
@@ -4039,7 +4041,7 @@ static void rtl8169_rx_clear(struct rtl8169_private *tp) | |||
4039 | } | 4041 | } |
4040 | 4042 | ||
4041 | static u32 rtl8169_rx_fill(struct rtl8169_private *tp, struct net_device *dev, | 4043 | static u32 rtl8169_rx_fill(struct rtl8169_private *tp, struct net_device *dev, |
4042 | u32 start, u32 end) | 4044 | u32 start, u32 end, gfp_t gfp) |
4043 | { | 4045 | { |
4044 | u32 cur; | 4046 | u32 cur; |
4045 | 4047 | ||
@@ -4054,7 +4056,7 @@ static u32 rtl8169_rx_fill(struct rtl8169_private *tp, struct net_device *dev, | |||
4054 | 4056 | ||
4055 | skb = rtl8169_alloc_rx_skb(tp->pci_dev, dev, | 4057 | skb = rtl8169_alloc_rx_skb(tp->pci_dev, dev, |
4056 | tp->RxDescArray + i, | 4058 | tp->RxDescArray + i, |
4057 | tp->rx_buf_sz, tp->align); | 4059 | tp->rx_buf_sz, tp->align, gfp); |
4058 | if (!skb) | 4060 | if (!skb) |
4059 | break; | 4061 | break; |
4060 | 4062 | ||
@@ -4082,7 +4084,7 @@ static int rtl8169_init_ring(struct net_device *dev) | |||
4082 | memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info)); | 4084 | memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info)); |
4083 | memset(tp->Rx_skbuff, 0x0, NUM_RX_DESC * sizeof(struct sk_buff *)); | 4085 | memset(tp->Rx_skbuff, 0x0, NUM_RX_DESC * sizeof(struct sk_buff *)); |
4084 | 4086 | ||
4085 | if (rtl8169_rx_fill(tp, dev, 0, NUM_RX_DESC) != NUM_RX_DESC) | 4087 | if (rtl8169_rx_fill(tp, dev, 0, NUM_RX_DESC, GFP_KERNEL) != NUM_RX_DESC) |
4086 | goto err_out; | 4088 | goto err_out; |
4087 | 4089 | ||
4088 | rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1); | 4090 | rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1); |
@@ -4099,7 +4101,8 @@ static void rtl8169_unmap_tx_skb(struct pci_dev *pdev, struct ring_info *tx_skb, | |||
4099 | { | 4101 | { |
4100 | unsigned int len = tx_skb->len; | 4102 | unsigned int len = tx_skb->len; |
4101 | 4103 | ||
4102 | pci_unmap_single(pdev, le64_to_cpu(desc->addr), len, PCI_DMA_TODEVICE); | 4104 | dma_unmap_single(&pdev->dev, le64_to_cpu(desc->addr), len, |
4105 | PCI_DMA_TODEVICE); | ||
4103 | desc->opts1 = 0x00; | 4106 | desc->opts1 = 0x00; |
4104 | desc->opts2 = 0x00; | 4107 | desc->opts2 = 0x00; |
4105 | desc->addr = 0x00; | 4108 | desc->addr = 0x00; |
@@ -4243,7 +4246,8 @@ static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb, | |||
4243 | txd = tp->TxDescArray + entry; | 4246 | txd = tp->TxDescArray + entry; |
4244 | len = frag->size; | 4247 | len = frag->size; |
4245 | addr = ((void *) page_address(frag->page)) + frag->page_offset; | 4248 | addr = ((void *) page_address(frag->page)) + frag->page_offset; |
4246 | mapping = pci_map_single(tp->pci_dev, addr, len, PCI_DMA_TODEVICE); | 4249 | mapping = dma_map_single(&tp->pci_dev->dev, addr, len, |
4250 | PCI_DMA_TODEVICE); | ||
4247 | 4251 | ||
4248 | /* anti gcc 2.95.3 bugware (sic) */ | 4252 | /* anti gcc 2.95.3 bugware (sic) */ |
4249 | status = opts1 | len | (RingEnd * !((entry + 1) % NUM_TX_DESC)); | 4253 | status = opts1 | len | (RingEnd * !((entry + 1) % NUM_TX_DESC)); |
@@ -4313,7 +4317,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | |||
4313 | tp->tx_skb[entry].skb = skb; | 4317 | tp->tx_skb[entry].skb = skb; |
4314 | } | 4318 | } |
4315 | 4319 | ||
4316 | mapping = pci_map_single(tp->pci_dev, skb->data, len, PCI_DMA_TODEVICE); | 4320 | mapping = dma_map_single(&tp->pci_dev->dev, skb->data, len, |
4321 | PCI_DMA_TODEVICE); | ||
4317 | 4322 | ||
4318 | tp->tx_skb[entry].len = len; | 4323 | tp->tx_skb[entry].len = len; |
4319 | txd->addr = cpu_to_le64(mapping); | 4324 | txd->addr = cpu_to_le64(mapping); |
@@ -4477,8 +4482,8 @@ static inline bool rtl8169_try_rx_copy(struct sk_buff **sk_buff, | |||
4477 | if (!skb) | 4482 | if (!skb) |
4478 | goto out; | 4483 | goto out; |
4479 | 4484 | ||
4480 | pci_dma_sync_single_for_cpu(tp->pci_dev, addr, pkt_size, | 4485 | dma_sync_single_for_cpu(&tp->pci_dev->dev, addr, pkt_size, |
4481 | PCI_DMA_FROMDEVICE); | 4486 | PCI_DMA_FROMDEVICE); |
4482 | skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size); | 4487 | skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size); |
4483 | *sk_buff = skb; | 4488 | *sk_buff = skb; |
4484 | done = true; | 4489 | done = true; |
@@ -4549,11 +4554,11 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4549 | rtl8169_rx_csum(skb, desc); | 4554 | rtl8169_rx_csum(skb, desc); |
4550 | 4555 | ||
4551 | if (rtl8169_try_rx_copy(&skb, tp, pkt_size, addr)) { | 4556 | if (rtl8169_try_rx_copy(&skb, tp, pkt_size, addr)) { |
4552 | pci_dma_sync_single_for_device(pdev, addr, | 4557 | dma_sync_single_for_device(&pdev->dev, addr, |
4553 | pkt_size, PCI_DMA_FROMDEVICE); | 4558 | pkt_size, PCI_DMA_FROMDEVICE); |
4554 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | 4559 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); |
4555 | } else { | 4560 | } else { |
4556 | pci_unmap_single(pdev, addr, tp->rx_buf_sz, | 4561 | dma_unmap_single(&pdev->dev, addr, tp->rx_buf_sz, |
4557 | PCI_DMA_FROMDEVICE); | 4562 | PCI_DMA_FROMDEVICE); |
4558 | tp->Rx_skbuff[entry] = NULL; | 4563 | tp->Rx_skbuff[entry] = NULL; |
4559 | } | 4564 | } |
@@ -4583,7 +4588,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4583 | count = cur_rx - tp->cur_rx; | 4588 | count = cur_rx - tp->cur_rx; |
4584 | tp->cur_rx = cur_rx; | 4589 | tp->cur_rx = cur_rx; |
4585 | 4590 | ||
4586 | delta = rtl8169_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx); | 4591 | delta = rtl8169_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx, GFP_ATOMIC); |
4587 | if (!delta && count) | 4592 | if (!delta && count) |
4588 | netif_info(tp, intr, dev, "no Rx buffer allocated\n"); | 4593 | netif_info(tp, intr, dev, "no Rx buffer allocated\n"); |
4589 | tp->dirty_rx += delta; | 4594 | tp->dirty_rx += delta; |
@@ -4769,10 +4774,10 @@ static int rtl8169_close(struct net_device *dev) | |||
4769 | 4774 | ||
4770 | free_irq(dev->irq, dev); | 4775 | free_irq(dev->irq, dev); |
4771 | 4776 | ||
4772 | pci_free_consistent(pdev, R8169_RX_RING_BYTES, tp->RxDescArray, | 4777 | dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, |
4773 | tp->RxPhyAddr); | 4778 | tp->RxPhyAddr); |
4774 | pci_free_consistent(pdev, R8169_TX_RING_BYTES, tp->TxDescArray, | 4779 | dma_free_coherent(&pdev->dev, R8169_TX_RING_BYTES, tp->TxDescArray, |
4775 | tp->TxPhyAddr); | 4780 | tp->TxPhyAddr); |
4776 | tp->TxDescArray = NULL; | 4781 | tp->TxDescArray = NULL; |
4777 | tp->RxDescArray = NULL; | 4782 | tp->RxDescArray = NULL; |
4778 | 4783 | ||
diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 40e5c46e7571..465ae7e84507 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/seq_file.h> | 43 | #include <linux/seq_file.h> |
44 | #include <linux/mii.h> | 44 | #include <linux/mii.h> |
45 | #include <linux/slab.h> | 45 | #include <linux/slab.h> |
46 | #include <linux/dmi.h> | ||
46 | #include <asm/irq.h> | 47 | #include <asm/irq.h> |
47 | 48 | ||
48 | #include "skge.h" | 49 | #include "skge.h" |
@@ -3868,6 +3869,8 @@ static void __devinit skge_show_addr(struct net_device *dev) | |||
3868 | netif_info(skge, probe, skge->netdev, "addr %pM\n", dev->dev_addr); | 3869 | netif_info(skge, probe, skge->netdev, "addr %pM\n", dev->dev_addr); |
3869 | } | 3870 | } |
3870 | 3871 | ||
3872 | static int only_32bit_dma; | ||
3873 | |||
3871 | static int __devinit skge_probe(struct pci_dev *pdev, | 3874 | static int __devinit skge_probe(struct pci_dev *pdev, |
3872 | const struct pci_device_id *ent) | 3875 | const struct pci_device_id *ent) |
3873 | { | 3876 | { |
@@ -3889,7 +3892,7 @@ static int __devinit skge_probe(struct pci_dev *pdev, | |||
3889 | 3892 | ||
3890 | pci_set_master(pdev); | 3893 | pci_set_master(pdev); |
3891 | 3894 | ||
3892 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { | 3895 | if (!only_32bit_dma && !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { |
3893 | using_dac = 1; | 3896 | using_dac = 1; |
3894 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); | 3897 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); |
3895 | } else if (!(err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) { | 3898 | } else if (!(err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) { |
@@ -4147,8 +4150,21 @@ static struct pci_driver skge_driver = { | |||
4147 | .shutdown = skge_shutdown, | 4150 | .shutdown = skge_shutdown, |
4148 | }; | 4151 | }; |
4149 | 4152 | ||
4153 | static struct dmi_system_id skge_32bit_dma_boards[] = { | ||
4154 | { | ||
4155 | .ident = "Gigabyte nForce boards", | ||
4156 | .matches = { | ||
4157 | DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co"), | ||
4158 | DMI_MATCH(DMI_BOARD_NAME, "nForce"), | ||
4159 | }, | ||
4160 | }, | ||
4161 | {} | ||
4162 | }; | ||
4163 | |||
4150 | static int __init skge_init_module(void) | 4164 | static int __init skge_init_module(void) |
4151 | { | 4165 | { |
4166 | if (dmi_check_system(skge_32bit_dma_boards)) | ||
4167 | only_32bit_dma = 1; | ||
4152 | skge_debug_init(); | 4168 | skge_debug_init(); |
4153 | return pci_register_driver(&skge_driver); | 4169 | return pci_register_driver(&skge_driver); |
4154 | } | 4170 | } |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index bc3af78a869f..1ec4b9e0239a 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -4666,7 +4666,7 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget) | |||
4666 | desc_idx, *post_ptr); | 4666 | desc_idx, *post_ptr); |
4667 | drop_it_no_recycle: | 4667 | drop_it_no_recycle: |
4668 | /* Other statistics kept track of by card. */ | 4668 | /* Other statistics kept track of by card. */ |
4669 | tp->net_stats.rx_dropped++; | 4669 | tp->rx_dropped++; |
4670 | goto next_pkt; | 4670 | goto next_pkt; |
4671 | } | 4671 | } |
4672 | 4672 | ||
@@ -4726,7 +4726,7 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget) | |||
4726 | if (len > (tp->dev->mtu + ETH_HLEN) && | 4726 | if (len > (tp->dev->mtu + ETH_HLEN) && |
4727 | skb->protocol != htons(ETH_P_8021Q)) { | 4727 | skb->protocol != htons(ETH_P_8021Q)) { |
4728 | dev_kfree_skb(skb); | 4728 | dev_kfree_skb(skb); |
4729 | goto next_pkt; | 4729 | goto drop_it_no_recycle; |
4730 | } | 4730 | } |
4731 | 4731 | ||
4732 | if (desc->type_flags & RXD_FLAG_VLAN && | 4732 | if (desc->type_flags & RXD_FLAG_VLAN && |
@@ -9240,6 +9240,8 @@ static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev, | |||
9240 | stats->rx_missed_errors = old_stats->rx_missed_errors + | 9240 | stats->rx_missed_errors = old_stats->rx_missed_errors + |
9241 | get_stat64(&hw_stats->rx_discards); | 9241 | get_stat64(&hw_stats->rx_discards); |
9242 | 9242 | ||
9243 | stats->rx_dropped = tp->rx_dropped; | ||
9244 | |||
9243 | return stats; | 9245 | return stats; |
9244 | } | 9246 | } |
9245 | 9247 | ||
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 4937bd190964..be7ff138a7f9 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -2759,7 +2759,7 @@ struct tg3 { | |||
2759 | 2759 | ||
2760 | 2760 | ||
2761 | /* begin "everything else" cacheline(s) section */ | 2761 | /* begin "everything else" cacheline(s) section */ |
2762 | struct rtnl_link_stats64 net_stats; | 2762 | unsigned long rx_dropped; |
2763 | struct rtnl_link_stats64 net_stats_prev; | 2763 | struct rtnl_link_stats64 net_stats_prev; |
2764 | struct tg3_ethtool_stats estats; | 2764 | struct tg3_ethtool_stats estats; |
2765 | struct tg3_ethtool_stats estats_prev; | 2765 | struct tg3_ethtool_stats estats_prev; |
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 04c6cd4333f1..10bafd59f9c3 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c | |||
@@ -575,7 +575,7 @@ static int cosa_probe(int base, int irq, int dma) | |||
575 | 575 | ||
576 | /* Initialize the chardev data structures */ | 576 | /* Initialize the chardev data structures */ |
577 | mutex_init(&chan->rlock); | 577 | mutex_init(&chan->rlock); |
578 | init_MUTEX(&chan->wsem); | 578 | sema_init(&chan->wsem, 1); |
579 | 579 | ||
580 | /* Register the network interface */ | 580 | /* Register the network interface */ |
581 | if (!(chan->netdev = alloc_hdlcdev(chan))) { | 581 | if (!(chan->netdev = alloc_hdlcdev(chan))) { |
diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c index 8cc9e319f435..1737d1488b35 100644 --- a/drivers/net/wimax/i2400m/rx.c +++ b/drivers/net/wimax/i2400m/rx.c | |||
@@ -1244,16 +1244,16 @@ int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb) | |||
1244 | int i, result; | 1244 | int i, result; |
1245 | struct device *dev = i2400m_dev(i2400m); | 1245 | struct device *dev = i2400m_dev(i2400m); |
1246 | const struct i2400m_msg_hdr *msg_hdr; | 1246 | const struct i2400m_msg_hdr *msg_hdr; |
1247 | size_t pl_itr, pl_size, skb_len; | 1247 | size_t pl_itr, pl_size; |
1248 | unsigned long flags; | 1248 | unsigned long flags; |
1249 | unsigned num_pls, single_last; | 1249 | unsigned num_pls, single_last, skb_len; |
1250 | 1250 | ||
1251 | skb_len = skb->len; | 1251 | skb_len = skb->len; |
1252 | d_fnstart(4, dev, "(i2400m %p skb %p [size %zu])\n", | 1252 | d_fnstart(4, dev, "(i2400m %p skb %p [size %u])\n", |
1253 | i2400m, skb, skb_len); | 1253 | i2400m, skb, skb_len); |
1254 | result = -EIO; | 1254 | result = -EIO; |
1255 | msg_hdr = (void *) skb->data; | 1255 | msg_hdr = (void *) skb->data; |
1256 | result = i2400m_rx_msg_hdr_check(i2400m, msg_hdr, skb->len); | 1256 | result = i2400m_rx_msg_hdr_check(i2400m, msg_hdr, skb_len); |
1257 | if (result < 0) | 1257 | if (result < 0) |
1258 | goto error_msg_hdr_check; | 1258 | goto error_msg_hdr_check; |
1259 | result = -EIO; | 1259 | result = -EIO; |
@@ -1261,10 +1261,10 @@ int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb) | |||
1261 | pl_itr = sizeof(*msg_hdr) + /* Check payload descriptor(s) */ | 1261 | pl_itr = sizeof(*msg_hdr) + /* Check payload descriptor(s) */ |
1262 | num_pls * sizeof(msg_hdr->pld[0]); | 1262 | num_pls * sizeof(msg_hdr->pld[0]); |
1263 | pl_itr = ALIGN(pl_itr, I2400M_PL_ALIGN); | 1263 | pl_itr = ALIGN(pl_itr, I2400M_PL_ALIGN); |
1264 | if (pl_itr > skb->len) { /* got all the payload descriptors? */ | 1264 | if (pl_itr > skb_len) { /* got all the payload descriptors? */ |
1265 | dev_err(dev, "RX: HW BUG? message too short (%u bytes) for " | 1265 | dev_err(dev, "RX: HW BUG? message too short (%u bytes) for " |
1266 | "%u payload descriptors (%zu each, total %zu)\n", | 1266 | "%u payload descriptors (%zu each, total %zu)\n", |
1267 | skb->len, num_pls, sizeof(msg_hdr->pld[0]), pl_itr); | 1267 | skb_len, num_pls, sizeof(msg_hdr->pld[0]), pl_itr); |
1268 | goto error_pl_descr_short; | 1268 | goto error_pl_descr_short; |
1269 | } | 1269 | } |
1270 | /* Walk each payload payload--check we really got it */ | 1270 | /* Walk each payload payload--check we really got it */ |
@@ -1272,7 +1272,7 @@ int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb) | |||
1272 | /* work around old gcc warnings */ | 1272 | /* work around old gcc warnings */ |
1273 | pl_size = i2400m_pld_size(&msg_hdr->pld[i]); | 1273 | pl_size = i2400m_pld_size(&msg_hdr->pld[i]); |
1274 | result = i2400m_rx_pl_descr_check(i2400m, &msg_hdr->pld[i], | 1274 | result = i2400m_rx_pl_descr_check(i2400m, &msg_hdr->pld[i], |
1275 | pl_itr, skb->len); | 1275 | pl_itr, skb_len); |
1276 | if (result < 0) | 1276 | if (result < 0) |
1277 | goto error_pl_descr_check; | 1277 | goto error_pl_descr_check; |
1278 | single_last = num_pls == 1 || i == num_pls - 1; | 1278 | single_last = num_pls == 1 || i == num_pls - 1; |
@@ -1290,16 +1290,16 @@ int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb) | |||
1290 | if (i < i2400m->rx_pl_min) | 1290 | if (i < i2400m->rx_pl_min) |
1291 | i2400m->rx_pl_min = i; | 1291 | i2400m->rx_pl_min = i; |
1292 | i2400m->rx_num++; | 1292 | i2400m->rx_num++; |
1293 | i2400m->rx_size_acc += skb->len; | 1293 | i2400m->rx_size_acc += skb_len; |
1294 | if (skb->len < i2400m->rx_size_min) | 1294 | if (skb_len < i2400m->rx_size_min) |
1295 | i2400m->rx_size_min = skb->len; | 1295 | i2400m->rx_size_min = skb_len; |
1296 | if (skb->len > i2400m->rx_size_max) | 1296 | if (skb_len > i2400m->rx_size_max) |
1297 | i2400m->rx_size_max = skb->len; | 1297 | i2400m->rx_size_max = skb_len; |
1298 | spin_unlock_irqrestore(&i2400m->rx_lock, flags); | 1298 | spin_unlock_irqrestore(&i2400m->rx_lock, flags); |
1299 | error_pl_descr_check: | 1299 | error_pl_descr_check: |
1300 | error_pl_descr_short: | 1300 | error_pl_descr_short: |
1301 | error_msg_hdr_check: | 1301 | error_msg_hdr_check: |
1302 | d_fnend(4, dev, "(i2400m %p skb %p [size %zu]) = %d\n", | 1302 | d_fnend(4, dev, "(i2400m %p skb %p [size %u]) = %d\n", |
1303 | i2400m, skb, skb_len, result); | 1303 | i2400m, skb, skb_len, result); |
1304 | return result; | 1304 | return result; |
1305 | } | 1305 | } |
diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c index cc648b6ae31c..a3d95cca8f0c 100644 --- a/drivers/net/wireless/ath/ath9k/ani.c +++ b/drivers/net/wireless/ath/ath9k/ani.c | |||
@@ -543,7 +543,7 @@ static u8 ath9k_hw_chan_2_clockrate_mhz(struct ath_hw *ah) | |||
543 | if (conf_is_ht40(conf)) | 543 | if (conf_is_ht40(conf)) |
544 | return clockrate * 2; | 544 | return clockrate * 2; |
545 | 545 | ||
546 | return clockrate * 2; | 546 | return clockrate; |
547 | } | 547 | } |
548 | 548 | ||
549 | static int32_t ath9k_hw_ani_get_listen_time(struct ath_hw *ah) | 549 | static int32_t ath9k_hw_ani_get_listen_time(struct ath_hw *ah) |
diff --git a/drivers/parport/share.c b/drivers/parport/share.c index dffa5d4fb298..a2d9d1e59260 100644 --- a/drivers/parport/share.c +++ b/drivers/parport/share.c | |||
@@ -306,7 +306,7 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma, | |||
306 | spin_lock_init(&tmp->pardevice_lock); | 306 | spin_lock_init(&tmp->pardevice_lock); |
307 | tmp->ieee1284.mode = IEEE1284_MODE_COMPAT; | 307 | tmp->ieee1284.mode = IEEE1284_MODE_COMPAT; |
308 | tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE; | 308 | tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE; |
309 | init_MUTEX_LOCKED (&tmp->ieee1284.irq); /* actually a semaphore at 0 */ | 309 | sema_init(&tmp->ieee1284.irq, 0); |
310 | tmp->spintime = parport_default_spintime; | 310 | tmp->spintime = parport_default_spintime; |
311 | atomic_set (&tmp->ref_count, 1); | 311 | atomic_set (&tmp->ref_count, 1); |
312 | INIT_LIST_HEAD(&tmp->full_list); | 312 | INIT_LIST_HEAD(&tmp->full_list); |
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c index 0a19708074c2..3de3a436a432 100644 --- a/drivers/pci/dmar.c +++ b/drivers/pci/dmar.c | |||
@@ -1221,9 +1221,9 @@ const char *dmar_get_fault_reason(u8 fault_reason, int *fault_type) | |||
1221 | } | 1221 | } |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | void dmar_msi_unmask(unsigned int irq) | 1224 | void dmar_msi_unmask(struct irq_data *data) |
1225 | { | 1225 | { |
1226 | struct intel_iommu *iommu = get_irq_data(irq); | 1226 | struct intel_iommu *iommu = irq_data_get_irq_data(data); |
1227 | unsigned long flag; | 1227 | unsigned long flag; |
1228 | 1228 | ||
1229 | /* unmask it */ | 1229 | /* unmask it */ |
@@ -1234,10 +1234,10 @@ void dmar_msi_unmask(unsigned int irq) | |||
1234 | spin_unlock_irqrestore(&iommu->register_lock, flag); | 1234 | spin_unlock_irqrestore(&iommu->register_lock, flag); |
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | void dmar_msi_mask(unsigned int irq) | 1237 | void dmar_msi_mask(struct irq_data *data) |
1238 | { | 1238 | { |
1239 | unsigned long flag; | 1239 | unsigned long flag; |
1240 | struct intel_iommu *iommu = get_irq_data(irq); | 1240 | struct intel_iommu *iommu = irq_data_get_irq_data(data); |
1241 | 1241 | ||
1242 | /* mask it */ | 1242 | /* mask it */ |
1243 | spin_lock_irqsave(&iommu->register_lock, flag); | 1243 | spin_lock_irqsave(&iommu->register_lock, flag); |
diff --git a/drivers/pci/htirq.c b/drivers/pci/htirq.c index 98abf8b91294..834842aa5bbf 100644 --- a/drivers/pci/htirq.c +++ b/drivers/pci/htirq.c | |||
@@ -57,28 +57,22 @@ void fetch_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg) | |||
57 | *msg = cfg->msg; | 57 | *msg = cfg->msg; |
58 | } | 58 | } |
59 | 59 | ||
60 | void mask_ht_irq(unsigned int irq) | 60 | void mask_ht_irq(struct irq_data *data) |
61 | { | 61 | { |
62 | struct ht_irq_cfg *cfg; | 62 | struct ht_irq_cfg *cfg = irq_data_get_irq_data(data); |
63 | struct ht_irq_msg msg; | 63 | struct ht_irq_msg msg = cfg->msg; |
64 | |||
65 | cfg = get_irq_data(irq); | ||
66 | 64 | ||
67 | msg = cfg->msg; | ||
68 | msg.address_lo |= 1; | 65 | msg.address_lo |= 1; |
69 | write_ht_irq_msg(irq, &msg); | 66 | write_ht_irq_msg(data->irq, &msg); |
70 | } | 67 | } |
71 | 68 | ||
72 | void unmask_ht_irq(unsigned int irq) | 69 | void unmask_ht_irq(struct irq_data *data) |
73 | { | 70 | { |
74 | struct ht_irq_cfg *cfg; | 71 | struct ht_irq_cfg *cfg = irq_data_get_irq_data(data); |
75 | struct ht_irq_msg msg; | 72 | struct ht_irq_msg msg = cfg->msg; |
76 | |||
77 | cfg = get_irq_data(irq); | ||
78 | 73 | ||
79 | msg = cfg->msg; | ||
80 | msg.address_lo &= ~1; | 74 | msg.address_lo &= ~1; |
81 | write_ht_irq_msg(irq, &msg); | 75 | write_ht_irq_msg(data->irq, &msg); |
82 | } | 76 | } |
83 | 77 | ||
84 | /** | 78 | /** |
diff --git a/drivers/pci/intr_remapping.c b/drivers/pci/intr_remapping.c index fd1d2867cdcc..ec87cd66f3eb 100644 --- a/drivers/pci/intr_remapping.c +++ b/drivers/pci/intr_remapping.c | |||
@@ -46,109 +46,24 @@ static __init int setup_intremap(char *str) | |||
46 | } | 46 | } |
47 | early_param("intremap", setup_intremap); | 47 | early_param("intremap", setup_intremap); |
48 | 48 | ||
49 | struct irq_2_iommu { | ||
50 | struct intel_iommu *iommu; | ||
51 | u16 irte_index; | ||
52 | u16 sub_handle; | ||
53 | u8 irte_mask; | ||
54 | }; | ||
55 | |||
56 | #ifdef CONFIG_GENERIC_HARDIRQS | ||
57 | static struct irq_2_iommu *get_one_free_irq_2_iommu(int node) | ||
58 | { | ||
59 | struct irq_2_iommu *iommu; | ||
60 | |||
61 | iommu = kzalloc_node(sizeof(*iommu), GFP_ATOMIC, node); | ||
62 | printk(KERN_DEBUG "alloc irq_2_iommu on node %d\n", node); | ||
63 | |||
64 | return iommu; | ||
65 | } | ||
66 | |||
67 | static struct irq_2_iommu *irq_2_iommu(unsigned int irq) | ||
68 | { | ||
69 | struct irq_desc *desc; | ||
70 | |||
71 | desc = irq_to_desc(irq); | ||
72 | |||
73 | if (WARN_ON_ONCE(!desc)) | ||
74 | return NULL; | ||
75 | |||
76 | return desc->irq_2_iommu; | ||
77 | } | ||
78 | |||
79 | static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq) | ||
80 | { | ||
81 | struct irq_desc *desc; | ||
82 | struct irq_2_iommu *irq_iommu; | ||
83 | |||
84 | desc = irq_to_desc(irq); | ||
85 | if (!desc) { | ||
86 | printk(KERN_INFO "can not get irq_desc for %d\n", irq); | ||
87 | return NULL; | ||
88 | } | ||
89 | |||
90 | irq_iommu = desc->irq_2_iommu; | ||
91 | |||
92 | if (!irq_iommu) | ||
93 | desc->irq_2_iommu = get_one_free_irq_2_iommu(irq_node(irq)); | ||
94 | |||
95 | return desc->irq_2_iommu; | ||
96 | } | ||
97 | |||
98 | #else /* !CONFIG_SPARSE_IRQ */ | ||
99 | |||
100 | static struct irq_2_iommu irq_2_iommuX[NR_IRQS]; | ||
101 | |||
102 | static struct irq_2_iommu *irq_2_iommu(unsigned int irq) | ||
103 | { | ||
104 | if (irq < nr_irqs) | ||
105 | return &irq_2_iommuX[irq]; | ||
106 | |||
107 | return NULL; | ||
108 | } | ||
109 | static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq) | ||
110 | { | ||
111 | return irq_2_iommu(irq); | ||
112 | } | ||
113 | #endif | ||
114 | |||
115 | static DEFINE_SPINLOCK(irq_2_ir_lock); | 49 | static DEFINE_SPINLOCK(irq_2_ir_lock); |
116 | 50 | ||
117 | static struct irq_2_iommu *valid_irq_2_iommu(unsigned int irq) | 51 | static struct irq_2_iommu *irq_2_iommu(unsigned int irq) |
118 | { | ||
119 | struct irq_2_iommu *irq_iommu; | ||
120 | |||
121 | irq_iommu = irq_2_iommu(irq); | ||
122 | |||
123 | if (!irq_iommu) | ||
124 | return NULL; | ||
125 | |||
126 | if (!irq_iommu->iommu) | ||
127 | return NULL; | ||
128 | |||
129 | return irq_iommu; | ||
130 | } | ||
131 | |||
132 | int irq_remapped(int irq) | ||
133 | { | 52 | { |
134 | return valid_irq_2_iommu(irq) != NULL; | 53 | struct irq_cfg *cfg = get_irq_chip_data(irq); |
54 | return cfg ? &cfg->irq_2_iommu : NULL; | ||
135 | } | 55 | } |
136 | 56 | ||
137 | int get_irte(int irq, struct irte *entry) | 57 | int get_irte(int irq, struct irte *entry) |
138 | { | 58 | { |
139 | int index; | 59 | struct irq_2_iommu *irq_iommu = irq_2_iommu(irq); |
140 | struct irq_2_iommu *irq_iommu; | ||
141 | unsigned long flags; | 60 | unsigned long flags; |
61 | int index; | ||
142 | 62 | ||
143 | if (!entry) | 63 | if (!entry || !irq_iommu) |
144 | return -1; | 64 | return -1; |
145 | 65 | ||
146 | spin_lock_irqsave(&irq_2_ir_lock, flags); | 66 | spin_lock_irqsave(&irq_2_ir_lock, flags); |
147 | irq_iommu = valid_irq_2_iommu(irq); | ||
148 | if (!irq_iommu) { | ||
149 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
150 | return -1; | ||
151 | } | ||
152 | 67 | ||
153 | index = irq_iommu->irte_index + irq_iommu->sub_handle; | 68 | index = irq_iommu->irte_index + irq_iommu->sub_handle; |
154 | *entry = *(irq_iommu->iommu->ir_table->base + index); | 69 | *entry = *(irq_iommu->iommu->ir_table->base + index); |
@@ -160,20 +75,14 @@ int get_irte(int irq, struct irte *entry) | |||
160 | int alloc_irte(struct intel_iommu *iommu, int irq, u16 count) | 75 | int alloc_irte(struct intel_iommu *iommu, int irq, u16 count) |
161 | { | 76 | { |
162 | struct ir_table *table = iommu->ir_table; | 77 | struct ir_table *table = iommu->ir_table; |
163 | struct irq_2_iommu *irq_iommu; | 78 | struct irq_2_iommu *irq_iommu = irq_2_iommu(irq); |
164 | u16 index, start_index; | 79 | u16 index, start_index; |
165 | unsigned int mask = 0; | 80 | unsigned int mask = 0; |
166 | unsigned long flags; | 81 | unsigned long flags; |
167 | int i; | 82 | int i; |
168 | 83 | ||
169 | if (!count) | 84 | if (!count || !irq_iommu) |
170 | return -1; | ||
171 | |||
172 | #ifndef CONFIG_SPARSE_IRQ | ||
173 | /* protect irq_2_iommu_alloc later */ | ||
174 | if (irq >= nr_irqs) | ||
175 | return -1; | 85 | return -1; |
176 | #endif | ||
177 | 86 | ||
178 | /* | 87 | /* |
179 | * start the IRTE search from index 0. | 88 | * start the IRTE search from index 0. |
@@ -214,13 +123,6 @@ int alloc_irte(struct intel_iommu *iommu, int irq, u16 count) | |||
214 | for (i = index; i < index + count; i++) | 123 | for (i = index; i < index + count; i++) |
215 | table->base[i].present = 1; | 124 | table->base[i].present = 1; |
216 | 125 | ||
217 | irq_iommu = irq_2_iommu_alloc(irq); | ||
218 | if (!irq_iommu) { | ||
219 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
220 | printk(KERN_ERR "can't allocate irq_2_iommu\n"); | ||
221 | return -1; | ||
222 | } | ||
223 | |||
224 | irq_iommu->iommu = iommu; | 126 | irq_iommu->iommu = iommu; |
225 | irq_iommu->irte_index = index; | 127 | irq_iommu->irte_index = index; |
226 | irq_iommu->sub_handle = 0; | 128 | irq_iommu->sub_handle = 0; |
@@ -244,17 +146,14 @@ static int qi_flush_iec(struct intel_iommu *iommu, int index, int mask) | |||
244 | 146 | ||
245 | int map_irq_to_irte_handle(int irq, u16 *sub_handle) | 147 | int map_irq_to_irte_handle(int irq, u16 *sub_handle) |
246 | { | 148 | { |
247 | int index; | 149 | struct irq_2_iommu *irq_iommu = irq_2_iommu(irq); |
248 | struct irq_2_iommu *irq_iommu; | ||
249 | unsigned long flags; | 150 | unsigned long flags; |
151 | int index; | ||
250 | 152 | ||
251 | spin_lock_irqsave(&irq_2_ir_lock, flags); | 153 | if (!irq_iommu) |
252 | irq_iommu = valid_irq_2_iommu(irq); | ||
253 | if (!irq_iommu) { | ||
254 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
255 | return -1; | 154 | return -1; |
256 | } | ||
257 | 155 | ||
156 | spin_lock_irqsave(&irq_2_ir_lock, flags); | ||
258 | *sub_handle = irq_iommu->sub_handle; | 157 | *sub_handle = irq_iommu->sub_handle; |
259 | index = irq_iommu->irte_index; | 158 | index = irq_iommu->irte_index; |
260 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | 159 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); |
@@ -263,18 +162,13 @@ int map_irq_to_irte_handle(int irq, u16 *sub_handle) | |||
263 | 162 | ||
264 | int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, u16 subhandle) | 163 | int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, u16 subhandle) |
265 | { | 164 | { |
266 | struct irq_2_iommu *irq_iommu; | 165 | struct irq_2_iommu *irq_iommu = irq_2_iommu(irq); |
267 | unsigned long flags; | 166 | unsigned long flags; |
268 | 167 | ||
269 | spin_lock_irqsave(&irq_2_ir_lock, flags); | 168 | if (!irq_iommu) |
270 | |||
271 | irq_iommu = irq_2_iommu_alloc(irq); | ||
272 | |||
273 | if (!irq_iommu) { | ||
274 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
275 | printk(KERN_ERR "can't allocate irq_2_iommu\n"); | ||
276 | return -1; | 169 | return -1; |
277 | } | 170 | |
171 | spin_lock_irqsave(&irq_2_ir_lock, flags); | ||
278 | 172 | ||
279 | irq_iommu->iommu = iommu; | 173 | irq_iommu->iommu = iommu; |
280 | irq_iommu->irte_index = index; | 174 | irq_iommu->irte_index = index; |
@@ -286,43 +180,18 @@ int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, u16 subhandle) | |||
286 | return 0; | 180 | return 0; |
287 | } | 181 | } |
288 | 182 | ||
289 | int clear_irte_irq(int irq, struct intel_iommu *iommu, u16 index) | ||
290 | { | ||
291 | struct irq_2_iommu *irq_iommu; | ||
292 | unsigned long flags; | ||
293 | |||
294 | spin_lock_irqsave(&irq_2_ir_lock, flags); | ||
295 | irq_iommu = valid_irq_2_iommu(irq); | ||
296 | if (!irq_iommu) { | ||
297 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
298 | return -1; | ||
299 | } | ||
300 | |||
301 | irq_iommu->iommu = NULL; | ||
302 | irq_iommu->irte_index = 0; | ||
303 | irq_iommu->sub_handle = 0; | ||
304 | irq_2_iommu(irq)->irte_mask = 0; | ||
305 | |||
306 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
307 | |||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | int modify_irte(int irq, struct irte *irte_modified) | 183 | int modify_irte(int irq, struct irte *irte_modified) |
312 | { | 184 | { |
313 | int rc; | 185 | struct irq_2_iommu *irq_iommu = irq_2_iommu(irq); |
314 | int index; | ||
315 | struct irte *irte; | ||
316 | struct intel_iommu *iommu; | 186 | struct intel_iommu *iommu; |
317 | struct irq_2_iommu *irq_iommu; | ||
318 | unsigned long flags; | 187 | unsigned long flags; |
188 | struct irte *irte; | ||
189 | int rc, index; | ||
319 | 190 | ||
320 | spin_lock_irqsave(&irq_2_ir_lock, flags); | 191 | if (!irq_iommu) |
321 | irq_iommu = valid_irq_2_iommu(irq); | ||
322 | if (!irq_iommu) { | ||
323 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
324 | return -1; | 192 | return -1; |
325 | } | 193 | |
194 | spin_lock_irqsave(&irq_2_ir_lock, flags); | ||
326 | 195 | ||
327 | iommu = irq_iommu->iommu; | 196 | iommu = irq_iommu->iommu; |
328 | 197 | ||
@@ -339,31 +208,6 @@ int modify_irte(int irq, struct irte *irte_modified) | |||
339 | return rc; | 208 | return rc; |
340 | } | 209 | } |
341 | 210 | ||
342 | int flush_irte(int irq) | ||
343 | { | ||
344 | int rc; | ||
345 | int index; | ||
346 | struct intel_iommu *iommu; | ||
347 | struct irq_2_iommu *irq_iommu; | ||
348 | unsigned long flags; | ||
349 | |||
350 | spin_lock_irqsave(&irq_2_ir_lock, flags); | ||
351 | irq_iommu = valid_irq_2_iommu(irq); | ||
352 | if (!irq_iommu) { | ||
353 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
354 | return -1; | ||
355 | } | ||
356 | |||
357 | iommu = irq_iommu->iommu; | ||
358 | |||
359 | index = irq_iommu->irte_index + irq_iommu->sub_handle; | ||
360 | |||
361 | rc = qi_flush_iec(iommu, index, irq_iommu->irte_mask); | ||
362 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
363 | |||
364 | return rc; | ||
365 | } | ||
366 | |||
367 | struct intel_iommu *map_hpet_to_ir(u8 hpet_id) | 211 | struct intel_iommu *map_hpet_to_ir(u8 hpet_id) |
368 | { | 212 | { |
369 | int i; | 213 | int i; |
@@ -420,16 +264,14 @@ static int clear_entries(struct irq_2_iommu *irq_iommu) | |||
420 | 264 | ||
421 | int free_irte(int irq) | 265 | int free_irte(int irq) |
422 | { | 266 | { |
423 | int rc = 0; | 267 | struct irq_2_iommu *irq_iommu = irq_2_iommu(irq); |
424 | struct irq_2_iommu *irq_iommu; | ||
425 | unsigned long flags; | 268 | unsigned long flags; |
269 | int rc; | ||
426 | 270 | ||
427 | spin_lock_irqsave(&irq_2_ir_lock, flags); | 271 | if (!irq_iommu) |
428 | irq_iommu = valid_irq_2_iommu(irq); | ||
429 | if (!irq_iommu) { | ||
430 | spin_unlock_irqrestore(&irq_2_ir_lock, flags); | ||
431 | return -1; | 272 | return -1; |
432 | } | 273 | |
274 | spin_lock_irqsave(&irq_2_ir_lock, flags); | ||
433 | 275 | ||
434 | rc = clear_entries(irq_iommu); | 276 | rc = clear_entries(irq_iommu); |
435 | 277 | ||
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 69b7be33b3a2..5fcf5aec680f 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -170,33 +170,31 @@ static void msix_mask_irq(struct msi_desc *desc, u32 flag) | |||
170 | desc->masked = __msix_mask_irq(desc, flag); | 170 | desc->masked = __msix_mask_irq(desc, flag); |
171 | } | 171 | } |
172 | 172 | ||
173 | static void msi_set_mask_bit(unsigned irq, u32 flag) | 173 | static void msi_set_mask_bit(struct irq_data *data, u32 flag) |
174 | { | 174 | { |
175 | struct msi_desc *desc = get_irq_msi(irq); | 175 | struct msi_desc *desc = irq_data_get_msi(data); |
176 | 176 | ||
177 | if (desc->msi_attrib.is_msix) { | 177 | if (desc->msi_attrib.is_msix) { |
178 | msix_mask_irq(desc, flag); | 178 | msix_mask_irq(desc, flag); |
179 | readl(desc->mask_base); /* Flush write to device */ | 179 | readl(desc->mask_base); /* Flush write to device */ |
180 | } else { | 180 | } else { |
181 | unsigned offset = irq - desc->dev->irq; | 181 | unsigned offset = data->irq - desc->dev->irq; |
182 | msi_mask_irq(desc, 1 << offset, flag << offset); | 182 | msi_mask_irq(desc, 1 << offset, flag << offset); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | void mask_msi_irq(unsigned int irq) | 186 | void mask_msi_irq(struct irq_data *data) |
187 | { | 187 | { |
188 | msi_set_mask_bit(irq, 1); | 188 | msi_set_mask_bit(data, 1); |
189 | } | 189 | } |
190 | 190 | ||
191 | void unmask_msi_irq(unsigned int irq) | 191 | void unmask_msi_irq(struct irq_data *data) |
192 | { | 192 | { |
193 | msi_set_mask_bit(irq, 0); | 193 | msi_set_mask_bit(data, 0); |
194 | } | 194 | } |
195 | 195 | ||
196 | void read_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg) | 196 | void __read_msi_msg(struct msi_desc *entry, struct msi_msg *msg) |
197 | { | 197 | { |
198 | struct msi_desc *entry = get_irq_desc_msi(desc); | ||
199 | |||
200 | BUG_ON(entry->dev->current_state != PCI_D0); | 198 | BUG_ON(entry->dev->current_state != PCI_D0); |
201 | 199 | ||
202 | if (entry->msi_attrib.is_msix) { | 200 | if (entry->msi_attrib.is_msix) { |
@@ -227,15 +225,13 @@ void read_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg) | |||
227 | 225 | ||
228 | void read_msi_msg(unsigned int irq, struct msi_msg *msg) | 226 | void read_msi_msg(unsigned int irq, struct msi_msg *msg) |
229 | { | 227 | { |
230 | struct irq_desc *desc = irq_to_desc(irq); | 228 | struct msi_desc *entry = get_irq_msi(irq); |
231 | 229 | ||
232 | read_msi_msg_desc(desc, msg); | 230 | __read_msi_msg(entry, msg); |
233 | } | 231 | } |
234 | 232 | ||
235 | void get_cached_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg) | 233 | void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg) |
236 | { | 234 | { |
237 | struct msi_desc *entry = get_irq_desc_msi(desc); | ||
238 | |||
239 | /* Assert that the cache is valid, assuming that | 235 | /* Assert that the cache is valid, assuming that |
240 | * valid messages are not all-zeroes. */ | 236 | * valid messages are not all-zeroes. */ |
241 | BUG_ON(!(entry->msg.address_hi | entry->msg.address_lo | | 237 | BUG_ON(!(entry->msg.address_hi | entry->msg.address_lo | |
@@ -246,15 +242,13 @@ void get_cached_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg) | |||
246 | 242 | ||
247 | void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg) | 243 | void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg) |
248 | { | 244 | { |
249 | struct irq_desc *desc = irq_to_desc(irq); | 245 | struct msi_desc *entry = get_irq_msi(irq); |
250 | 246 | ||
251 | get_cached_msi_msg_desc(desc, msg); | 247 | __get_cached_msi_msg(entry, msg); |
252 | } | 248 | } |
253 | 249 | ||
254 | void write_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg) | 250 | void __write_msi_msg(struct msi_desc *entry, struct msi_msg *msg) |
255 | { | 251 | { |
256 | struct msi_desc *entry = get_irq_desc_msi(desc); | ||
257 | |||
258 | if (entry->dev->current_state != PCI_D0) { | 252 | if (entry->dev->current_state != PCI_D0) { |
259 | /* Don't touch the hardware now */ | 253 | /* Don't touch the hardware now */ |
260 | } else if (entry->msi_attrib.is_msix) { | 254 | } else if (entry->msi_attrib.is_msix) { |
@@ -292,9 +286,9 @@ void write_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg) | |||
292 | 286 | ||
293 | void write_msi_msg(unsigned int irq, struct msi_msg *msg) | 287 | void write_msi_msg(unsigned int irq, struct msi_msg *msg) |
294 | { | 288 | { |
295 | struct irq_desc *desc = irq_to_desc(irq); | 289 | struct msi_desc *entry = get_irq_msi(irq); |
296 | 290 | ||
297 | write_msi_msg_desc(desc, msg); | 291 | __write_msi_msg(entry, msg); |
298 | } | 292 | } |
299 | 293 | ||
300 | static void free_msi_irqs(struct pci_dev *dev) | 294 | static void free_msi_irqs(struct pci_dev *dev) |
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c index 9024480a8228..c44a5e8b8b82 100644 --- a/drivers/platform/x86/intel_ips.c +++ b/drivers/platform/x86/intel_ips.c | |||
@@ -51,7 +51,6 @@ | |||
51 | * TODO: | 51 | * TODO: |
52 | * - handle CPU hotplug | 52 | * - handle CPU hotplug |
53 | * - provide turbo enable/disable api | 53 | * - provide turbo enable/disable api |
54 | * - make sure we can write turbo enable/disable reg based on MISC_EN | ||
55 | * | 54 | * |
56 | * Related documents: | 55 | * Related documents: |
57 | * - CDI 403777, 403778 - Auburndale EDS vol 1 & 2 | 56 | * - CDI 403777, 403778 - Auburndale EDS vol 1 & 2 |
@@ -230,7 +229,7 @@ | |||
230 | #define THM_TC2 0xac | 229 | #define THM_TC2 0xac |
231 | #define THM_DTV 0xb0 | 230 | #define THM_DTV 0xb0 |
232 | #define THM_ITV 0xd8 | 231 | #define THM_ITV 0xd8 |
233 | #define ITV_ME_SEQNO_MASK 0x000f0000 /* ME should update every ~200ms */ | 232 | #define ITV_ME_SEQNO_MASK 0x00ff0000 /* ME should update every ~200ms */ |
234 | #define ITV_ME_SEQNO_SHIFT (16) | 233 | #define ITV_ME_SEQNO_SHIFT (16) |
235 | #define ITV_MCH_TEMP_MASK 0x0000ff00 | 234 | #define ITV_MCH_TEMP_MASK 0x0000ff00 |
236 | #define ITV_MCH_TEMP_SHIFT (8) | 235 | #define ITV_MCH_TEMP_SHIFT (8) |
@@ -325,6 +324,7 @@ struct ips_driver { | |||
325 | bool gpu_preferred; | 324 | bool gpu_preferred; |
326 | bool poll_turbo_status; | 325 | bool poll_turbo_status; |
327 | bool second_cpu; | 326 | bool second_cpu; |
327 | bool turbo_toggle_allowed; | ||
328 | struct ips_mcp_limits *limits; | 328 | struct ips_mcp_limits *limits; |
329 | 329 | ||
330 | /* Optional MCH interfaces for if i915 is in use */ | 330 | /* Optional MCH interfaces for if i915 is in use */ |
@@ -415,7 +415,7 @@ static void ips_cpu_lower(struct ips_driver *ips) | |||
415 | new_limit = cur_limit - 8; /* 1W decrease */ | 415 | new_limit = cur_limit - 8; /* 1W decrease */ |
416 | 416 | ||
417 | /* Clamp to SKU TDP limit */ | 417 | /* Clamp to SKU TDP limit */ |
418 | if (((new_limit * 10) / 8) < (ips->orig_turbo_limit & TURBO_TDP_MASK)) | 418 | if (new_limit < (ips->orig_turbo_limit & TURBO_TDP_MASK)) |
419 | new_limit = ips->orig_turbo_limit & TURBO_TDP_MASK; | 419 | new_limit = ips->orig_turbo_limit & TURBO_TDP_MASK; |
420 | 420 | ||
421 | thm_writew(THM_MPCPC, (new_limit * 10) / 8); | 421 | thm_writew(THM_MPCPC, (new_limit * 10) / 8); |
@@ -461,7 +461,8 @@ static void ips_enable_cpu_turbo(struct ips_driver *ips) | |||
461 | if (ips->__cpu_turbo_on) | 461 | if (ips->__cpu_turbo_on) |
462 | return; | 462 | return; |
463 | 463 | ||
464 | on_each_cpu(do_enable_cpu_turbo, ips, 1); | 464 | if (ips->turbo_toggle_allowed) |
465 | on_each_cpu(do_enable_cpu_turbo, ips, 1); | ||
465 | 466 | ||
466 | ips->__cpu_turbo_on = true; | 467 | ips->__cpu_turbo_on = true; |
467 | } | 468 | } |
@@ -498,7 +499,8 @@ static void ips_disable_cpu_turbo(struct ips_driver *ips) | |||
498 | if (!ips->__cpu_turbo_on) | 499 | if (!ips->__cpu_turbo_on) |
499 | return; | 500 | return; |
500 | 501 | ||
501 | on_each_cpu(do_disable_cpu_turbo, ips, 1); | 502 | if (ips->turbo_toggle_allowed) |
503 | on_each_cpu(do_disable_cpu_turbo, ips, 1); | ||
502 | 504 | ||
503 | ips->__cpu_turbo_on = false; | 505 | ips->__cpu_turbo_on = false; |
504 | } | 506 | } |
@@ -598,17 +600,29 @@ static bool mcp_exceeded(struct ips_driver *ips) | |||
598 | { | 600 | { |
599 | unsigned long flags; | 601 | unsigned long flags; |
600 | bool ret = false; | 602 | bool ret = false; |
603 | u32 temp_limit; | ||
604 | u32 avg_power; | ||
605 | const char *msg = "MCP limit exceeded: "; | ||
601 | 606 | ||
602 | spin_lock_irqsave(&ips->turbo_status_lock, flags); | 607 | spin_lock_irqsave(&ips->turbo_status_lock, flags); |
603 | if (ips->mcp_avg_temp > (ips->mcp_temp_limit * 100)) | 608 | |
604 | ret = true; | 609 | temp_limit = ips->mcp_temp_limit * 100; |
605 | if (ips->cpu_avg_power + ips->mch_avg_power > ips->mcp_power_limit) | 610 | if (ips->mcp_avg_temp > temp_limit) { |
611 | dev_info(&ips->dev->dev, | ||
612 | "%sAvg temp %u, limit %u\n", msg, ips->mcp_avg_temp, | ||
613 | temp_limit); | ||
606 | ret = true; | 614 | ret = true; |
607 | spin_unlock_irqrestore(&ips->turbo_status_lock, flags); | 615 | } |
608 | 616 | ||
609 | if (ret) | 617 | avg_power = ips->cpu_avg_power + ips->mch_avg_power; |
618 | if (avg_power > ips->mcp_power_limit) { | ||
610 | dev_info(&ips->dev->dev, | 619 | dev_info(&ips->dev->dev, |
611 | "MCP power or thermal limit exceeded\n"); | 620 | "%sAvg power %u, limit %u\n", msg, avg_power, |
621 | ips->mcp_power_limit); | ||
622 | ret = true; | ||
623 | } | ||
624 | |||
625 | spin_unlock_irqrestore(&ips->turbo_status_lock, flags); | ||
612 | 626 | ||
613 | return ret; | 627 | return ret; |
614 | } | 628 | } |
@@ -663,6 +677,27 @@ static bool mch_exceeded(struct ips_driver *ips) | |||
663 | } | 677 | } |
664 | 678 | ||
665 | /** | 679 | /** |
680 | * verify_limits - verify BIOS provided limits | ||
681 | * @ips: IPS structure | ||
682 | * | ||
683 | * BIOS can optionally provide non-default limits for power and temp. Check | ||
684 | * them here and use the defaults if the BIOS values are not provided or | ||
685 | * are otherwise unusable. | ||
686 | */ | ||
687 | static void verify_limits(struct ips_driver *ips) | ||
688 | { | ||
689 | if (ips->mcp_power_limit < ips->limits->mcp_power_limit || | ||
690 | ips->mcp_power_limit > 35000) | ||
691 | ips->mcp_power_limit = ips->limits->mcp_power_limit; | ||
692 | |||
693 | if (ips->mcp_temp_limit < ips->limits->core_temp_limit || | ||
694 | ips->mcp_temp_limit < ips->limits->mch_temp_limit || | ||
695 | ips->mcp_temp_limit > 150) | ||
696 | ips->mcp_temp_limit = min(ips->limits->core_temp_limit, | ||
697 | ips->limits->mch_temp_limit); | ||
698 | } | ||
699 | |||
700 | /** | ||
666 | * update_turbo_limits - get various limits & settings from regs | 701 | * update_turbo_limits - get various limits & settings from regs |
667 | * @ips: IPS driver struct | 702 | * @ips: IPS driver struct |
668 | * | 703 | * |
@@ -680,12 +715,21 @@ static void update_turbo_limits(struct ips_driver *ips) | |||
680 | u32 hts = thm_readl(THM_HTS); | 715 | u32 hts = thm_readl(THM_HTS); |
681 | 716 | ||
682 | ips->cpu_turbo_enabled = !(hts & HTS_PCTD_DIS); | 717 | ips->cpu_turbo_enabled = !(hts & HTS_PCTD_DIS); |
683 | ips->gpu_turbo_enabled = !(hts & HTS_GTD_DIS); | 718 | /* |
719 | * Disable turbo for now, until we can figure out why the power figures | ||
720 | * are wrong | ||
721 | */ | ||
722 | ips->cpu_turbo_enabled = false; | ||
723 | |||
724 | if (ips->gpu_busy) | ||
725 | ips->gpu_turbo_enabled = !(hts & HTS_GTD_DIS); | ||
726 | |||
684 | ips->core_power_limit = thm_readw(THM_MPCPC); | 727 | ips->core_power_limit = thm_readw(THM_MPCPC); |
685 | ips->mch_power_limit = thm_readw(THM_MMGPC); | 728 | ips->mch_power_limit = thm_readw(THM_MMGPC); |
686 | ips->mcp_temp_limit = thm_readw(THM_PTL); | 729 | ips->mcp_temp_limit = thm_readw(THM_PTL); |
687 | ips->mcp_power_limit = thm_readw(THM_MPPC); | 730 | ips->mcp_power_limit = thm_readw(THM_MPPC); |
688 | 731 | ||
732 | verify_limits(ips); | ||
689 | /* Ignore BIOS CPU vs GPU pref */ | 733 | /* Ignore BIOS CPU vs GPU pref */ |
690 | } | 734 | } |
691 | 735 | ||
@@ -858,7 +902,7 @@ static u32 get_cpu_power(struct ips_driver *ips, u32 *last, int period) | |||
858 | ret = (ret * 1000) / 65535; | 902 | ret = (ret * 1000) / 65535; |
859 | *last = val; | 903 | *last = val; |
860 | 904 | ||
861 | return ret; | 905 | return 0; |
862 | } | 906 | } |
863 | 907 | ||
864 | static const u16 temp_decay_factor = 2; | 908 | static const u16 temp_decay_factor = 2; |
@@ -940,7 +984,6 @@ static int ips_monitor(void *data) | |||
940 | kfree(mch_samples); | 984 | kfree(mch_samples); |
941 | kfree(cpu_samples); | 985 | kfree(cpu_samples); |
942 | kfree(mchp_samples); | 986 | kfree(mchp_samples); |
943 | kthread_stop(ips->adjust); | ||
944 | return -ENOMEM; | 987 | return -ENOMEM; |
945 | } | 988 | } |
946 | 989 | ||
@@ -948,7 +991,7 @@ static int ips_monitor(void *data) | |||
948 | ITV_ME_SEQNO_SHIFT; | 991 | ITV_ME_SEQNO_SHIFT; |
949 | seqno_timestamp = get_jiffies_64(); | 992 | seqno_timestamp = get_jiffies_64(); |
950 | 993 | ||
951 | old_cpu_power = thm_readl(THM_CEC) / 65535; | 994 | old_cpu_power = thm_readl(THM_CEC); |
952 | schedule_timeout_interruptible(msecs_to_jiffies(IPS_SAMPLE_PERIOD)); | 995 | schedule_timeout_interruptible(msecs_to_jiffies(IPS_SAMPLE_PERIOD)); |
953 | 996 | ||
954 | /* Collect an initial average */ | 997 | /* Collect an initial average */ |
@@ -1150,11 +1193,18 @@ static irqreturn_t ips_irq_handler(int irq, void *arg) | |||
1150 | STS_GPL_SHIFT; | 1193 | STS_GPL_SHIFT; |
1151 | /* ignore EC CPU vs GPU pref */ | 1194 | /* ignore EC CPU vs GPU pref */ |
1152 | ips->cpu_turbo_enabled = !(sts & STS_PCTD_DIS); | 1195 | ips->cpu_turbo_enabled = !(sts & STS_PCTD_DIS); |
1153 | ips->gpu_turbo_enabled = !(sts & STS_GTD_DIS); | 1196 | /* |
1197 | * Disable turbo for now, until we can figure | ||
1198 | * out why the power figures are wrong | ||
1199 | */ | ||
1200 | ips->cpu_turbo_enabled = false; | ||
1201 | if (ips->gpu_busy) | ||
1202 | ips->gpu_turbo_enabled = !(sts & STS_GTD_DIS); | ||
1154 | ips->mcp_temp_limit = (sts & STS_PTL_MASK) >> | 1203 | ips->mcp_temp_limit = (sts & STS_PTL_MASK) >> |
1155 | STS_PTL_SHIFT; | 1204 | STS_PTL_SHIFT; |
1156 | ips->mcp_power_limit = (tc1 & STS_PPL_MASK) >> | 1205 | ips->mcp_power_limit = (tc1 & STS_PPL_MASK) >> |
1157 | STS_PPL_SHIFT; | 1206 | STS_PPL_SHIFT; |
1207 | verify_limits(ips); | ||
1158 | spin_unlock(&ips->turbo_status_lock); | 1208 | spin_unlock(&ips->turbo_status_lock); |
1159 | 1209 | ||
1160 | thm_writeb(THM_SEC, SEC_ACK); | 1210 | thm_writeb(THM_SEC, SEC_ACK); |
@@ -1333,8 +1383,10 @@ static struct ips_mcp_limits *ips_detect_cpu(struct ips_driver *ips) | |||
1333 | * turbo manually or we'll get an illegal MSR access, even though | 1383 | * turbo manually or we'll get an illegal MSR access, even though |
1334 | * turbo will still be available. | 1384 | * turbo will still be available. |
1335 | */ | 1385 | */ |
1336 | if (!(misc_en & IA32_MISC_TURBO_EN)) | 1386 | if (misc_en & IA32_MISC_TURBO_EN) |
1337 | ; /* add turbo MSR write allowed flag if necessary */ | 1387 | ips->turbo_toggle_allowed = true; |
1388 | else | ||
1389 | ips->turbo_toggle_allowed = false; | ||
1338 | 1390 | ||
1339 | if (strstr(boot_cpu_data.x86_model_id, "CPU M")) | 1391 | if (strstr(boot_cpu_data.x86_model_id, "CPU M")) |
1340 | limits = &ips_sv_limits; | 1392 | limits = &ips_sv_limits; |
@@ -1351,9 +1403,10 @@ static struct ips_mcp_limits *ips_detect_cpu(struct ips_driver *ips) | |||
1351 | tdp = turbo_power & TURBO_TDP_MASK; | 1403 | tdp = turbo_power & TURBO_TDP_MASK; |
1352 | 1404 | ||
1353 | /* Sanity check TDP against CPU */ | 1405 | /* Sanity check TDP against CPU */ |
1354 | if (limits->mcp_power_limit != (tdp / 8) * 1000) { | 1406 | if (limits->core_power_limit != (tdp / 8) * 1000) { |
1355 | dev_warn(&ips->dev->dev, "Warning: CPU TDP doesn't match expected value (found %d, expected %d)\n", | 1407 | dev_info(&ips->dev->dev, "CPU TDP doesn't match expected value (found %d, expected %d)\n", |
1356 | tdp / 8, limits->mcp_power_limit / 1000); | 1408 | tdp / 8, limits->core_power_limit / 1000); |
1409 | limits->core_power_limit = (tdp / 8) * 1000; | ||
1357 | } | 1410 | } |
1358 | 1411 | ||
1359 | out: | 1412 | out: |
@@ -1390,7 +1443,7 @@ static bool ips_get_i915_syms(struct ips_driver *ips) | |||
1390 | return true; | 1443 | return true; |
1391 | 1444 | ||
1392 | out_put_busy: | 1445 | out_put_busy: |
1393 | symbol_put(i915_gpu_turbo_disable); | 1446 | symbol_put(i915_gpu_busy); |
1394 | out_put_lower: | 1447 | out_put_lower: |
1395 | symbol_put(i915_gpu_lower); | 1448 | symbol_put(i915_gpu_lower); |
1396 | out_put_raise: | 1449 | out_put_raise: |
@@ -1532,22 +1585,27 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1532 | /* Save turbo limits & ratios */ | 1585 | /* Save turbo limits & ratios */ |
1533 | rdmsrl(TURBO_POWER_CURRENT_LIMIT, ips->orig_turbo_limit); | 1586 | rdmsrl(TURBO_POWER_CURRENT_LIMIT, ips->orig_turbo_limit); |
1534 | 1587 | ||
1535 | ips_enable_cpu_turbo(ips); | 1588 | ips_disable_cpu_turbo(ips); |
1536 | ips->cpu_turbo_enabled = true; | 1589 | ips->cpu_turbo_enabled = false; |
1537 | 1590 | ||
1538 | /* Set up the work queue and monitor/adjust threads */ | 1591 | /* Create thermal adjust thread */ |
1539 | ips->monitor = kthread_run(ips_monitor, ips, "ips-monitor"); | 1592 | ips->adjust = kthread_create(ips_adjust, ips, "ips-adjust"); |
1540 | if (IS_ERR(ips->monitor)) { | 1593 | if (IS_ERR(ips->adjust)) { |
1541 | dev_err(&dev->dev, | 1594 | dev_err(&dev->dev, |
1542 | "failed to create thermal monitor thread, aborting\n"); | 1595 | "failed to create thermal adjust thread, aborting\n"); |
1543 | ret = -ENOMEM; | 1596 | ret = -ENOMEM; |
1544 | goto error_free_irq; | 1597 | goto error_free_irq; |
1598 | |||
1545 | } | 1599 | } |
1546 | 1600 | ||
1547 | ips->adjust = kthread_create(ips_adjust, ips, "ips-adjust"); | 1601 | /* |
1548 | if (IS_ERR(ips->adjust)) { | 1602 | * Set up the work queue and monitor thread. The monitor thread |
1603 | * will wake up ips_adjust thread. | ||
1604 | */ | ||
1605 | ips->monitor = kthread_run(ips_monitor, ips, "ips-monitor"); | ||
1606 | if (IS_ERR(ips->monitor)) { | ||
1549 | dev_err(&dev->dev, | 1607 | dev_err(&dev->dev, |
1550 | "failed to create thermal adjust thread, aborting\n"); | 1608 | "failed to create thermal monitor thread, aborting\n"); |
1551 | ret = -ENOMEM; | 1609 | ret = -ENOMEM; |
1552 | goto error_thread_cleanup; | 1610 | goto error_thread_cleanup; |
1553 | } | 1611 | } |
@@ -1566,7 +1624,7 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1566 | return ret; | 1624 | return ret; |
1567 | 1625 | ||
1568 | error_thread_cleanup: | 1626 | error_thread_cleanup: |
1569 | kthread_stop(ips->monitor); | 1627 | kthread_stop(ips->adjust); |
1570 | error_free_irq: | 1628 | error_free_irq: |
1571 | free_irq(ips->dev->irq, ips); | 1629 | free_irq(ips->dev->irq, ips); |
1572 | error_unmap: | 1630 | error_unmap: |
diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c index df1fb53c09d2..a4be41614eeb 100644 --- a/drivers/regulator/ad5398.c +++ b/drivers/regulator/ad5398.c | |||
@@ -256,7 +256,6 @@ static int __devexit ad5398_remove(struct i2c_client *client) | |||
256 | 256 | ||
257 | regulator_unregister(chip->rdev); | 257 | regulator_unregister(chip->rdev); |
258 | kfree(chip); | 258 | kfree(chip); |
259 | i2c_set_clientdata(client, NULL); | ||
260 | 259 | ||
261 | return 0; | 260 | return 0; |
262 | } | 261 | } |
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c index d61ecb885a8c..b8cc6389a541 100644 --- a/drivers/regulator/isl6271a-regulator.c +++ b/drivers/regulator/isl6271a-regulator.c | |||
@@ -191,8 +191,6 @@ static int __devexit isl6271a_remove(struct i2c_client *i2c) | |||
191 | struct isl_pmic *pmic = i2c_get_clientdata(i2c); | 191 | struct isl_pmic *pmic = i2c_get_clientdata(i2c); |
192 | int i; | 192 | int i; |
193 | 193 | ||
194 | i2c_set_clientdata(i2c, NULL); | ||
195 | |||
196 | for (i = 0; i < 3; i++) | 194 | for (i = 0; i < 3; i++) |
197 | regulator_unregister(pmic->rdev[i]); | 195 | regulator_unregister(pmic->rdev[i]); |
198 | 196 | ||
diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c index 9daed8db83d3..9de8516e3531 100644 --- a/drivers/rtc/rtc-ds3232.c +++ b/drivers/rtc/rtc-ds3232.c | |||
@@ -268,7 +268,6 @@ out_irq: | |||
268 | free_irq(client->irq, client); | 268 | free_irq(client->irq, client); |
269 | 269 | ||
270 | out_free: | 270 | out_free: |
271 | i2c_set_clientdata(client, NULL); | ||
272 | kfree(ds3232); | 271 | kfree(ds3232); |
273 | return ret; | 272 | return ret; |
274 | } | 273 | } |
@@ -287,7 +286,6 @@ static int __devexit ds3232_remove(struct i2c_client *client) | |||
287 | } | 286 | } |
288 | 287 | ||
289 | rtc_device_unregister(ds3232->rtc); | 288 | rtc_device_unregister(ds3232->rtc); |
290 | i2c_set_clientdata(client, NULL); | ||
291 | kfree(ds3232); | 289 | kfree(ds3232); |
292 | return 0; | 290 | return 0; |
293 | } | 291 | } |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index ad0ed212db4a..348fba0a8976 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -1046,13 +1046,13 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf, | |||
1046 | 1046 | ||
1047 | /* If the user actually wanted this page, we can skip the rest */ | 1047 | /* If the user actually wanted this page, we can skip the rest */ |
1048 | if (page == 0) | 1048 | if (page == 0) |
1049 | return -EINVAL; | 1049 | return 0; |
1050 | 1050 | ||
1051 | for (i = 0; i < min((int)buf[3], buf_len - 4); i++) | 1051 | for (i = 0; i < min((int)buf[3], buf_len - 4); i++) |
1052 | if (buf[i + 4] == page) | 1052 | if (buf[i + 4] == page) |
1053 | goto found; | 1053 | goto found; |
1054 | 1054 | ||
1055 | if (i < buf[3] && i > buf_len) | 1055 | if (i < buf[3] && i >= buf_len - 4) |
1056 | /* ran off the end of the buffer, give us benefit of doubt */ | 1056 | /* ran off the end of the buffer, give us benefit of doubt */ |
1057 | goto found; | 1057 | goto found; |
1058 | /* The device claims it doesn't support the requested page */ | 1058 | /* The device claims it doesn't support the requested page */ |
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c index 93de907b1208..800c54602339 100644 --- a/drivers/serial/ioc3_serial.c +++ b/drivers/serial/ioc3_serial.c | |||
@@ -2044,6 +2044,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd) | |||
2044 | if (!port) { | 2044 | if (!port) { |
2045 | printk(KERN_WARNING | 2045 | printk(KERN_WARNING |
2046 | "IOC3 serial memory not available for port\n"); | 2046 | "IOC3 serial memory not available for port\n"); |
2047 | ret = -ENOMEM; | ||
2047 | goto out4; | 2048 | goto out4; |
2048 | } | 2049 | } |
2049 | spin_lock_init(&port->ip_lock); | 2050 | spin_lock_init(&port->ip_lock); |
diff --git a/drivers/staging/tm6000/Kconfig b/drivers/staging/tm6000/Kconfig index c725356cc346..de7ebb99d8f6 100644 --- a/drivers/staging/tm6000/Kconfig +++ b/drivers/staging/tm6000/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config VIDEO_TM6000 | 1 | config VIDEO_TM6000 |
2 | tristate "TV Master TM5600/6000/6010 driver" | 2 | tristate "TV Master TM5600/6000/6010 driver" |
3 | depends on VIDEO_DEV && I2C && INPUT && USB && EXPERIMENTAL | 3 | depends on VIDEO_DEV && I2C && INPUT && IR_CORE && USB && EXPERIMENTAL |
4 | select VIDEO_TUNER | 4 | select VIDEO_TUNER |
5 | select MEDIA_TUNER_XC2028 | 5 | select MEDIA_TUNER_XC2028 |
6 | select MEDIA_TUNER_XC5000 | 6 | select MEDIA_TUNER_XC5000 |
diff --git a/drivers/staging/tm6000/tm6000-input.c b/drivers/staging/tm6000/tm6000-input.c index 32f7a0af6938..54f7667cc706 100644 --- a/drivers/staging/tm6000/tm6000-input.c +++ b/drivers/staging/tm6000/tm6000-input.c | |||
@@ -46,7 +46,7 @@ MODULE_PARM_DESC(enable_ir, "enable ir (default is enable"); | |||
46 | } | 46 | } |
47 | 47 | ||
48 | struct tm6000_ir_poll_result { | 48 | struct tm6000_ir_poll_result { |
49 | u8 rc_data[4]; | 49 | u16 rc_data; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | struct tm6000_IR { | 52 | struct tm6000_IR { |
@@ -60,9 +60,9 @@ struct tm6000_IR { | |||
60 | int polling; | 60 | int polling; |
61 | struct delayed_work work; | 61 | struct delayed_work work; |
62 | u8 wait:1; | 62 | u8 wait:1; |
63 | u8 key:1; | ||
63 | struct urb *int_urb; | 64 | struct urb *int_urb; |
64 | u8 *urb_data; | 65 | u8 *urb_data; |
65 | u8 key:1; | ||
66 | 66 | ||
67 | int (*get_key) (struct tm6000_IR *, struct tm6000_ir_poll_result *); | 67 | int (*get_key) (struct tm6000_IR *, struct tm6000_ir_poll_result *); |
68 | 68 | ||
@@ -122,13 +122,14 @@ static void tm6000_ir_urb_received(struct urb *urb) | |||
122 | 122 | ||
123 | if (urb->status != 0) | 123 | if (urb->status != 0) |
124 | printk(KERN_INFO "not ready\n"); | 124 | printk(KERN_INFO "not ready\n"); |
125 | else if (urb->actual_length > 0) | 125 | else if (urb->actual_length > 0) { |
126 | memcpy(ir->urb_data, urb->transfer_buffer, urb->actual_length); | 126 | memcpy(ir->urb_data, urb->transfer_buffer, urb->actual_length); |
127 | 127 | ||
128 | dprintk("data %02x %02x %02x %02x\n", ir->urb_data[0], | 128 | dprintk("data %02x %02x %02x %02x\n", ir->urb_data[0], |
129 | ir->urb_data[1], ir->urb_data[2], ir->urb_data[3]); | 129 | ir->urb_data[1], ir->urb_data[2], ir->urb_data[3]); |
130 | 130 | ||
131 | ir->key = 1; | 131 | ir->key = 1; |
132 | } | ||
132 | 133 | ||
133 | rc = usb_submit_urb(urb, GFP_ATOMIC); | 134 | rc = usb_submit_urb(urb, GFP_ATOMIC); |
134 | } | 135 | } |
@@ -140,30 +141,47 @@ static int default_polling_getkey(struct tm6000_IR *ir, | |||
140 | int rc; | 141 | int rc; |
141 | u8 buf[2]; | 142 | u8 buf[2]; |
142 | 143 | ||
143 | if (ir->wait && !&dev->int_in) { | 144 | if (ir->wait && !&dev->int_in) |
144 | poll_result->rc_data[0] = 0xff; | ||
145 | return 0; | 145 | return 0; |
146 | } | ||
147 | 146 | ||
148 | if (&dev->int_in) { | 147 | if (&dev->int_in) { |
149 | poll_result->rc_data[0] = ir->urb_data[0]; | 148 | if (ir->ir.ir_type == IR_TYPE_RC5) |
150 | poll_result->rc_data[1] = ir->urb_data[1]; | 149 | poll_result->rc_data = ir->urb_data[0]; |
150 | else | ||
151 | poll_result->rc_data = ir->urb_data[0] | ir->urb_data[1] << 8; | ||
151 | } else { | 152 | } else { |
152 | tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 0); | 153 | tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 0); |
153 | msleep(10); | 154 | msleep(10); |
154 | tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 1); | 155 | tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 1); |
155 | msleep(10); | 156 | msleep(10); |
156 | 157 | ||
157 | rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR | | 158 | if (ir->ir.ir_type == IR_TYPE_RC5) { |
158 | USB_RECIP_DEVICE, REQ_02_GET_IR_CODE, 0, 0, buf, 1); | 159 | rc = tm6000_read_write_usb(dev, USB_DIR_IN | |
160 | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
161 | REQ_02_GET_IR_CODE, 0, 0, buf, 1); | ||
159 | 162 | ||
160 | msleep(10); | 163 | msleep(10); |
161 | 164 | ||
162 | dprintk("read data=%02x\n", buf[0]); | 165 | dprintk("read data=%02x\n", buf[0]); |
163 | if (rc < 0) | 166 | if (rc < 0) |
164 | return rc; | 167 | return rc; |
165 | 168 | ||
166 | poll_result->rc_data[0] = buf[0]; | 169 | poll_result->rc_data = buf[0]; |
170 | } else { | ||
171 | rc = tm6000_read_write_usb(dev, USB_DIR_IN | | ||
172 | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
173 | REQ_02_GET_IR_CODE, 0, 0, buf, 2); | ||
174 | |||
175 | msleep(10); | ||
176 | |||
177 | dprintk("read data=%04x\n", buf[0] | buf[1] << 8); | ||
178 | if (rc < 0) | ||
179 | return rc; | ||
180 | |||
181 | poll_result->rc_data = buf[0] | buf[1] << 8; | ||
182 | } | ||
183 | if ((poll_result->rc_data & 0x00ff) != 0xff) | ||
184 | ir->key = 1; | ||
167 | } | 185 | } |
168 | return 0; | 186 | return 0; |
169 | } | 187 | } |
@@ -180,12 +198,11 @@ static void tm6000_ir_handle_key(struct tm6000_IR *ir) | |||
180 | return; | 198 | return; |
181 | } | 199 | } |
182 | 200 | ||
183 | dprintk("ir->get_key result data=%02x %02x\n", | 201 | dprintk("ir->get_key result data=%04x\n", poll_result.rc_data); |
184 | poll_result.rc_data[0], poll_result.rc_data[1]); | ||
185 | 202 | ||
186 | if (poll_result.rc_data[0] != 0xff && ir->key == 1) { | 203 | if (ir->key) { |
187 | ir_input_keydown(ir->input->input_dev, &ir->ir, | 204 | ir_input_keydown(ir->input->input_dev, &ir->ir, |
188 | poll_result.rc_data[0] | poll_result.rc_data[1] << 8); | 205 | (u32)poll_result.rc_data); |
189 | 206 | ||
190 | ir_input_nokey(ir->input->input_dev, &ir->ir); | 207 | ir_input_nokey(ir->input->input_dev, &ir->ir); |
191 | ir->key = 0; | 208 | ir->key = 0; |
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 7c8008225ee3..17927b1f9334 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c | |||
@@ -127,7 +127,10 @@ static void handle_tx(struct vhost_net *net) | |||
127 | size_t len, total_len = 0; | 127 | size_t len, total_len = 0; |
128 | int err, wmem; | 128 | int err, wmem; |
129 | size_t hdr_size; | 129 | size_t hdr_size; |
130 | struct socket *sock = rcu_dereference(vq->private_data); | 130 | struct socket *sock; |
131 | |||
132 | sock = rcu_dereference_check(vq->private_data, | ||
133 | lockdep_is_held(&vq->mutex)); | ||
131 | if (!sock) | 134 | if (!sock) |
132 | return; | 135 | return; |
133 | 136 | ||
@@ -582,7 +585,10 @@ static void vhost_net_disable_vq(struct vhost_net *n, | |||
582 | static void vhost_net_enable_vq(struct vhost_net *n, | 585 | static void vhost_net_enable_vq(struct vhost_net *n, |
583 | struct vhost_virtqueue *vq) | 586 | struct vhost_virtqueue *vq) |
584 | { | 587 | { |
585 | struct socket *sock = vq->private_data; | 588 | struct socket *sock; |
589 | |||
590 | sock = rcu_dereference_protected(vq->private_data, | ||
591 | lockdep_is_held(&vq->mutex)); | ||
586 | if (!sock) | 592 | if (!sock) |
587 | return; | 593 | return; |
588 | if (vq == n->vqs + VHOST_NET_VQ_TX) { | 594 | if (vq == n->vqs + VHOST_NET_VQ_TX) { |
@@ -598,7 +604,8 @@ static struct socket *vhost_net_stop_vq(struct vhost_net *n, | |||
598 | struct socket *sock; | 604 | struct socket *sock; |
599 | 605 | ||
600 | mutex_lock(&vq->mutex); | 606 | mutex_lock(&vq->mutex); |
601 | sock = vq->private_data; | 607 | sock = rcu_dereference_protected(vq->private_data, |
608 | lockdep_is_held(&vq->mutex)); | ||
602 | vhost_net_disable_vq(n, vq); | 609 | vhost_net_disable_vq(n, vq); |
603 | rcu_assign_pointer(vq->private_data, NULL); | 610 | rcu_assign_pointer(vq->private_data, NULL); |
604 | mutex_unlock(&vq->mutex); | 611 | mutex_unlock(&vq->mutex); |
@@ -736,7 +743,8 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd) | |||
736 | } | 743 | } |
737 | 744 | ||
738 | /* start polling new socket */ | 745 | /* start polling new socket */ |
739 | oldsock = vq->private_data; | 746 | oldsock = rcu_dereference_protected(vq->private_data, |
747 | lockdep_is_held(&vq->mutex)); | ||
740 | if (sock != oldsock) { | 748 | if (sock != oldsock) { |
741 | vhost_net_disable_vq(n, vq); | 749 | vhost_net_disable_vq(n, vq); |
742 | rcu_assign_pointer(vq->private_data, sock); | 750 | rcu_assign_pointer(vq->private_data, sock); |
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index dd3d6f7406f8..8b5a1b33d0fe 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c | |||
@@ -320,7 +320,7 @@ long vhost_dev_reset_owner(struct vhost_dev *dev) | |||
320 | vhost_dev_cleanup(dev); | 320 | vhost_dev_cleanup(dev); |
321 | 321 | ||
322 | memory->nregions = 0; | 322 | memory->nregions = 0; |
323 | dev->memory = memory; | 323 | RCU_INIT_POINTER(dev->memory, memory); |
324 | return 0; | 324 | return 0; |
325 | } | 325 | } |
326 | 326 | ||
@@ -352,8 +352,9 @@ void vhost_dev_cleanup(struct vhost_dev *dev) | |||
352 | fput(dev->log_file); | 352 | fput(dev->log_file); |
353 | dev->log_file = NULL; | 353 | dev->log_file = NULL; |
354 | /* No one will access memory at this point */ | 354 | /* No one will access memory at this point */ |
355 | kfree(dev->memory); | 355 | kfree(rcu_dereference_protected(dev->memory, |
356 | dev->memory = NULL; | 356 | lockdep_is_held(&dev->mutex))); |
357 | RCU_INIT_POINTER(dev->memory, NULL); | ||
357 | if (dev->mm) | 358 | if (dev->mm) |
358 | mmput(dev->mm); | 359 | mmput(dev->mm); |
359 | dev->mm = NULL; | 360 | dev->mm = NULL; |
@@ -440,14 +441,22 @@ static int vq_access_ok(unsigned int num, | |||
440 | /* Caller should have device mutex but not vq mutex */ | 441 | /* Caller should have device mutex but not vq mutex */ |
441 | int vhost_log_access_ok(struct vhost_dev *dev) | 442 | int vhost_log_access_ok(struct vhost_dev *dev) |
442 | { | 443 | { |
443 | return memory_access_ok(dev, dev->memory, 1); | 444 | struct vhost_memory *mp; |
445 | |||
446 | mp = rcu_dereference_protected(dev->memory, | ||
447 | lockdep_is_held(&dev->mutex)); | ||
448 | return memory_access_ok(dev, mp, 1); | ||
444 | } | 449 | } |
445 | 450 | ||
446 | /* Verify access for write logging. */ | 451 | /* Verify access for write logging. */ |
447 | /* Caller should have vq mutex and device mutex */ | 452 | /* Caller should have vq mutex and device mutex */ |
448 | static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base) | 453 | static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base) |
449 | { | 454 | { |
450 | return vq_memory_access_ok(log_base, vq->dev->memory, | 455 | struct vhost_memory *mp; |
456 | |||
457 | mp = rcu_dereference_protected(vq->dev->memory, | ||
458 | lockdep_is_held(&vq->mutex)); | ||
459 | return vq_memory_access_ok(log_base, mp, | ||
451 | vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) && | 460 | vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) && |
452 | (!vq->log_used || log_access_ok(log_base, vq->log_addr, | 461 | (!vq->log_used || log_access_ok(log_base, vq->log_addr, |
453 | sizeof *vq->used + | 462 | sizeof *vq->used + |
@@ -487,7 +496,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) | |||
487 | kfree(newmem); | 496 | kfree(newmem); |
488 | return -EFAULT; | 497 | return -EFAULT; |
489 | } | 498 | } |
490 | oldmem = d->memory; | 499 | oldmem = rcu_dereference_protected(d->memory, |
500 | lockdep_is_held(&d->mutex)); | ||
491 | rcu_assign_pointer(d->memory, newmem); | 501 | rcu_assign_pointer(d->memory, newmem); |
492 | synchronize_rcu(); | 502 | synchronize_rcu(); |
493 | kfree(oldmem); | 503 | kfree(oldmem); |
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index afd77295971c..af3c11ded5fd 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h | |||
@@ -106,7 +106,7 @@ struct vhost_virtqueue { | |||
106 | * vhost_work execution acts instead of rcu_read_lock() and the end of | 106 | * vhost_work execution acts instead of rcu_read_lock() and the end of |
107 | * vhost_work execution acts instead of rcu_read_lock(). | 107 | * vhost_work execution acts instead of rcu_read_lock(). |
108 | * Writers use virtqueue mutex. */ | 108 | * Writers use virtqueue mutex. */ |
109 | void *private_data; | 109 | void __rcu *private_data; |
110 | /* Log write descriptors */ | 110 | /* Log write descriptors */ |
111 | void __user *log_base; | 111 | void __user *log_base; |
112 | struct vhost_log log[VHOST_NET_MAX_SG]; | 112 | struct vhost_log log[VHOST_NET_MAX_SG]; |
@@ -116,7 +116,7 @@ struct vhost_dev { | |||
116 | /* Readers use RCU to access memory table pointer | 116 | /* Readers use RCU to access memory table pointer |
117 | * log base pointer and features. | 117 | * log base pointer and features. |
118 | * Writers use mutex below.*/ | 118 | * Writers use mutex below.*/ |
119 | struct vhost_memory *memory; | 119 | struct vhost_memory __rcu *memory; |
120 | struct mm_struct *mm; | 120 | struct mm_struct *mm; |
121 | struct mutex mutex; | 121 | struct mutex mutex; |
122 | unsigned acked_features; | 122 | unsigned acked_features; |
@@ -173,7 +173,11 @@ enum { | |||
173 | 173 | ||
174 | static inline int vhost_has_feature(struct vhost_dev *dev, int bit) | 174 | static inline int vhost_has_feature(struct vhost_dev *dev, int bit) |
175 | { | 175 | { |
176 | unsigned acked_features = rcu_dereference(dev->acked_features); | 176 | unsigned acked_features; |
177 | |||
178 | acked_features = | ||
179 | rcu_dereference_index_check(dev->acked_features, | ||
180 | lockdep_is_held(&dev->mutex)); | ||
177 | return acked_features & (1 << bit); | 181 | return acked_features & (1 << bit); |
178 | } | 182 | } |
179 | 183 | ||
diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 13365ba35218..7d24b0d94ed4 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c | |||
@@ -338,30 +338,29 @@ static void unmask_evtchn(int port) | |||
338 | 338 | ||
339 | static int find_unbound_irq(void) | 339 | static int find_unbound_irq(void) |
340 | { | 340 | { |
341 | int irq; | 341 | struct irq_data *data; |
342 | struct irq_desc *desc; | 342 | int irq, res; |
343 | 343 | ||
344 | for (irq = 0; irq < nr_irqs; irq++) { | 344 | for (irq = 0; irq < nr_irqs; irq++) { |
345 | desc = irq_to_desc(irq); | 345 | data = irq_get_irq_data(irq); |
346 | /* only 0->15 have init'd desc; handle irq > 16 */ | 346 | /* only 0->15 have init'd desc; handle irq > 16 */ |
347 | if (desc == NULL) | 347 | if (!data) |
348 | break; | 348 | break; |
349 | if (desc->chip == &no_irq_chip) | 349 | if (data->chip == &no_irq_chip) |
350 | break; | 350 | break; |
351 | if (desc->chip != &xen_dynamic_chip) | 351 | if (data->chip != &xen_dynamic_chip) |
352 | continue; | 352 | continue; |
353 | if (irq_info[irq].type == IRQT_UNBOUND) | 353 | if (irq_info[irq].type == IRQT_UNBOUND) |
354 | break; | 354 | return irq; |
355 | } | 355 | } |
356 | 356 | ||
357 | if (irq == nr_irqs) | 357 | if (irq == nr_irqs) |
358 | panic("No available IRQ to bind to: increase nr_irqs!\n"); | 358 | panic("No available IRQ to bind to: increase nr_irqs!\n"); |
359 | 359 | ||
360 | desc = irq_to_desc_alloc_node(irq, 0); | 360 | res = irq_alloc_desc_at(irq, 0); |
361 | if (WARN_ON(desc == NULL)) | ||
362 | return -1; | ||
363 | 361 | ||
364 | dynamic_irq_init_keep_chip_data(irq); | 362 | if (WARN_ON(res != irq)) |
363 | return -1; | ||
365 | 364 | ||
366 | return irq; | 365 | return irq; |
367 | } | 366 | } |
@@ -495,7 +494,7 @@ static void unbind_from_irq(unsigned int irq) | |||
495 | if (irq_info[irq].type != IRQT_UNBOUND) { | 494 | if (irq_info[irq].type != IRQT_UNBOUND) { |
496 | irq_info[irq] = mk_unbound_info(); | 495 | irq_info[irq] = mk_unbound_info(); |
497 | 496 | ||
498 | dynamic_irq_cleanup(irq); | 497 | irq_free_desc(irq); |
499 | } | 498 | } |
500 | 499 | ||
501 | spin_unlock(&irq_mapping_update_lock); | 500 | spin_unlock(&irq_mapping_update_lock); |