1 |
Author: mpagano |
2 |
Date: 2013-10-01 23:20:01 +0000 (Tue, 01 Oct 2013) |
3 |
New Revision: 2534 |
4 |
|
5 |
Added: |
6 |
genpatches-2.6/trunk/3.11/1002_linux-3.11.3.patch |
7 |
Modified: |
8 |
genpatches-2.6/trunk/3.11/0000_README |
9 |
Log: |
10 |
Linux patch 3.11.3 |
11 |
|
12 |
Modified: genpatches-2.6/trunk/3.11/0000_README |
13 |
=================================================================== |
14 |
--- genpatches-2.6/trunk/3.11/0000_README 2013-09-27 17:22:28 UTC (rev 2533) |
15 |
+++ genpatches-2.6/trunk/3.11/0000_README 2013-10-01 23:20:01 UTC (rev 2534) |
16 |
@@ -50,6 +50,10 @@ |
17 |
From: http://www.kernel.org |
18 |
Desc: Linux 3.11.2 |
19 |
|
20 |
+Patch: 1002_linux-3.11.3.patch |
21 |
+From: http://www.kernel.org |
22 |
+Desc: Linux 3.11.3 |
23 |
+ |
24 |
Patch: 1500_XATTR_USER_PREFIX.patch |
25 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
26 |
Desc: Support for namespace user.pax.* on tmpfs. |
27 |
|
28 |
Added: genpatches-2.6/trunk/3.11/1002_linux-3.11.3.patch |
29 |
=================================================================== |
30 |
--- genpatches-2.6/trunk/3.11/1002_linux-3.11.3.patch (rev 0) |
31 |
+++ genpatches-2.6/trunk/3.11/1002_linux-3.11.3.patch 2013-10-01 23:20:01 UTC (rev 2534) |
32 |
@@ -0,0 +1,3605 @@ |
33 |
+diff --git a/Makefile b/Makefile |
34 |
+index aede319..4f91b99 100644 |
35 |
+--- a/Makefile |
36 |
++++ b/Makefile |
37 |
+@@ -1,6 +1,6 @@ |
38 |
+ VERSION = 3 |
39 |
+ PATCHLEVEL = 11 |
40 |
+-SUBLEVEL = 2 |
41 |
++SUBLEVEL = 3 |
42 |
+ EXTRAVERSION = |
43 |
+ NAME = Linux for Workgroups |
44 |
+ |
45 |
+diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c |
46 |
+index 88e37a4..7adf7f1 100644 |
47 |
+--- a/arch/arm/mach-omap2/cclock44xx_data.c |
48 |
++++ b/arch/arm/mach-omap2/cclock44xx_data.c |
49 |
+@@ -1632,7 +1632,7 @@ static struct omap_clk omap44xx_clks[] = { |
50 |
+ CLK(NULL, "auxclk5_src_ck", &auxclk5_src_ck), |
51 |
+ CLK(NULL, "auxclk5_ck", &auxclk5_ck), |
52 |
+ CLK(NULL, "auxclkreq5_ck", &auxclkreq5_ck), |
53 |
+- CLK("omap-gpmc", "fck", &dummy_ck), |
54 |
++ CLK("50000000.gpmc", "fck", &dummy_ck), |
55 |
+ CLK("omap_i2c.1", "ick", &dummy_ck), |
56 |
+ CLK("omap_i2c.2", "ick", &dummy_ck), |
57 |
+ CLK("omap_i2c.3", "ick", &dummy_ck), |
58 |
+diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c |
59 |
+index d5bbdcf..c410752 100644 |
60 |
+--- a/block/cfq-iosched.c |
61 |
++++ b/block/cfq-iosched.c |
62 |
+@@ -1803,7 +1803,7 @@ static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf, |
63 |
+ |
64 |
+ if (samples) { |
65 |
+ v = blkg_stat_read(&cfqg->stats.avg_queue_size_sum); |
66 |
+- do_div(v, samples); |
67 |
++ v = div64_u64(v, samples); |
68 |
+ } |
69 |
+ __blkg_prfill_u64(sf, pd, v); |
70 |
+ return 0; |
71 |
+diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h |
72 |
+index 622d4ae..daf95fc 100644 |
73 |
+--- a/drivers/gpu/drm/ast/ast_drv.h |
74 |
++++ b/drivers/gpu/drm/ast/ast_drv.h |
75 |
+@@ -177,7 +177,7 @@ uint8_t ast_get_index_reg_mask(struct ast_private *ast, |
76 |
+ |
77 |
+ static inline void ast_open_key(struct ast_private *ast) |
78 |
+ { |
79 |
+- ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xA1, 0xFF, 0x04); |
80 |
++ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x80, 0xA8); |
81 |
+ } |
82 |
+ |
83 |
+ #define AST_VIDMEM_SIZE_8M 0x00800000 |
84 |
+diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c |
85 |
+index fc83bb9..877b892 100644 |
86 |
+--- a/drivers/gpu/drm/drm_crtc.c |
87 |
++++ b/drivers/gpu/drm/drm_crtc.c |
88 |
+@@ -2604,10 +2604,22 @@ int drm_mode_getfb(struct drm_device *dev, |
89 |
+ r->depth = fb->depth; |
90 |
+ r->bpp = fb->bits_per_pixel; |
91 |
+ r->pitch = fb->pitches[0]; |
92 |
+- if (fb->funcs->create_handle) |
93 |
+- ret = fb->funcs->create_handle(fb, file_priv, &r->handle); |
94 |
+- else |
95 |
++ if (fb->funcs->create_handle) { |
96 |
++ if (file_priv->is_master || capable(CAP_SYS_ADMIN)) { |
97 |
++ ret = fb->funcs->create_handle(fb, file_priv, |
98 |
++ &r->handle); |
99 |
++ } else { |
100 |
++ /* GET_FB() is an unprivileged ioctl so we must not |
101 |
++ * return a buffer-handle to non-master processes! For |
102 |
++ * backwards-compatibility reasons, we cannot make |
103 |
++ * GET_FB() privileged, so just return an invalid handle |
104 |
++ * for non-masters. */ |
105 |
++ r->handle = 0; |
106 |
++ ret = 0; |
107 |
++ } |
108 |
++ } else { |
109 |
+ ret = -ENODEV; |
110 |
++ } |
111 |
+ |
112 |
+ drm_framebuffer_unreference(fb); |
113 |
+ |
114 |
+diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h |
115 |
+index 1929bff..2f09e80 100644 |
116 |
+--- a/drivers/gpu/drm/i915/i915_drv.h |
117 |
++++ b/drivers/gpu/drm/i915/i915_drv.h |
118 |
+@@ -1091,6 +1091,13 @@ typedef struct drm_i915_private { |
119 |
+ |
120 |
+ unsigned int fsb_freq, mem_freq, is_ddr3; |
121 |
+ |
122 |
++ /** |
123 |
++ * wq - Driver workqueue for GEM. |
124 |
++ * |
125 |
++ * NOTE: Work items scheduled here are not allowed to grab any modeset |
126 |
++ * locks, for otherwise the flushing done in the pageflip code will |
127 |
++ * result in deadlocks. |
128 |
++ */ |
129 |
+ struct workqueue_struct *wq; |
130 |
+ |
131 |
+ /* Display functions */ |
132 |
+diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c |
133 |
+index 3d92a7c..46d46ba 100644 |
134 |
+--- a/drivers/gpu/drm/i915/i915_irq.c |
135 |
++++ b/drivers/gpu/drm/i915/i915_irq.c |
136 |
+@@ -910,8 +910,13 @@ static inline void intel_hpd_irq_handler(struct drm_device *dev, |
137 |
+ dev_priv->display.hpd_irq_setup(dev); |
138 |
+ spin_unlock(&dev_priv->irq_lock); |
139 |
+ |
140 |
+- queue_work(dev_priv->wq, |
141 |
+- &dev_priv->hotplug_work); |
142 |
++ /* |
143 |
++ * Our hotplug handler can grab modeset locks (by calling down into the |
144 |
++ * fb helpers). Hence it must not be run on our own dev-priv->wq work |
145 |
++ * queue for otherwise the flush_work in the pageflip code will |
146 |
++ * deadlock. |
147 |
++ */ |
148 |
++ schedule_work(&dev_priv->hotplug_work); |
149 |
+ } |
150 |
+ |
151 |
+ static void gmbus_irq_handler(struct drm_device *dev) |
152 |
+@@ -1402,6 +1407,34 @@ done: |
153 |
+ return ret; |
154 |
+ } |
155 |
+ |
156 |
++static void i915_error_wake_up(struct drm_i915_private *dev_priv, |
157 |
++ bool reset_completed) |
158 |
++{ |
159 |
++ struct intel_ring_buffer *ring; |
160 |
++ int i; |
161 |
++ |
162 |
++ /* |
163 |
++ * Notify all waiters for GPU completion events that reset state has |
164 |
++ * been changed, and that they need to restart their wait after |
165 |
++ * checking for potential errors (and bail out to drop locks if there is |
166 |
++ * a gpu reset pending so that i915_error_work_func can acquire them). |
167 |
++ */ |
168 |
++ |
169 |
++ /* Wake up __wait_seqno, potentially holding dev->struct_mutex. */ |
170 |
++ for_each_ring(ring, dev_priv, i) |
171 |
++ wake_up_all(&ring->irq_queue); |
172 |
++ |
173 |
++ /* Wake up intel_crtc_wait_for_pending_flips, holding crtc->mutex. */ |
174 |
++ wake_up_all(&dev_priv->pending_flip_queue); |
175 |
++ |
176 |
++ /* |
177 |
++ * Signal tasks blocked in i915_gem_wait_for_error that the pending |
178 |
++ * reset state is cleared. |
179 |
++ */ |
180 |
++ if (reset_completed) |
181 |
++ wake_up_all(&dev_priv->gpu_error.reset_queue); |
182 |
++} |
183 |
++ |
184 |
+ /** |
185 |
+ * i915_error_work_func - do process context error handling work |
186 |
+ * @work: work struct |
187 |
+@@ -1416,11 +1449,10 @@ static void i915_error_work_func(struct work_struct *work) |
188 |
+ drm_i915_private_t *dev_priv = container_of(error, drm_i915_private_t, |
189 |
+ gpu_error); |
190 |
+ struct drm_device *dev = dev_priv->dev; |
191 |
+- struct intel_ring_buffer *ring; |
192 |
+ char *error_event[] = { "ERROR=1", NULL }; |
193 |
+ char *reset_event[] = { "RESET=1", NULL }; |
194 |
+ char *reset_done_event[] = { "ERROR=0", NULL }; |
195 |
+- int i, ret; |
196 |
++ int ret; |
197 |
+ |
198 |
+ kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, error_event); |
199 |
+ |
200 |
+@@ -1439,8 +1471,16 @@ static void i915_error_work_func(struct work_struct *work) |
201 |
+ kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, |
202 |
+ reset_event); |
203 |
+ |
204 |
++ /* |
205 |
++ * All state reset _must_ be completed before we update the |
206 |
++ * reset counter, for otherwise waiters might miss the reset |
207 |
++ * pending state and not properly drop locks, resulting in |
208 |
++ * deadlocks with the reset work. |
209 |
++ */ |
210 |
+ ret = i915_reset(dev); |
211 |
+ |
212 |
++ intel_display_handle_reset(dev); |
213 |
++ |
214 |
+ if (ret == 0) { |
215 |
+ /* |
216 |
+ * After all the gem state is reset, increment the reset |
217 |
+@@ -1461,12 +1501,11 @@ static void i915_error_work_func(struct work_struct *work) |
218 |
+ atomic_set(&error->reset_counter, I915_WEDGED); |
219 |
+ } |
220 |
+ |
221 |
+- for_each_ring(ring, dev_priv, i) |
222 |
+- wake_up_all(&ring->irq_queue); |
223 |
+- |
224 |
+- intel_display_handle_reset(dev); |
225 |
+- |
226 |
+- wake_up_all(&dev_priv->gpu_error.reset_queue); |
227 |
++ /* |
228 |
++ * Note: The wake_up also serves as a memory barrier so that |
229 |
++ * waiters see the update value of the reset counter atomic_t. |
230 |
++ */ |
231 |
++ i915_error_wake_up(dev_priv, true); |
232 |
+ } |
233 |
+ } |
234 |
+ |
235 |
+@@ -2104,8 +2143,6 @@ static void i915_report_and_clear_eir(struct drm_device *dev) |
236 |
+ void i915_handle_error(struct drm_device *dev, bool wedged) |
237 |
+ { |
238 |
+ struct drm_i915_private *dev_priv = dev->dev_private; |
239 |
+- struct intel_ring_buffer *ring; |
240 |
+- int i; |
241 |
+ |
242 |
+ i915_capture_error_state(dev); |
243 |
+ i915_report_and_clear_eir(dev); |
244 |
+@@ -2115,14 +2152,28 @@ void i915_handle_error(struct drm_device *dev, bool wedged) |
245 |
+ &dev_priv->gpu_error.reset_counter); |
246 |
+ |
247 |
+ /* |
248 |
+- * Wakeup waiting processes so that the reset work item |
249 |
+- * doesn't deadlock trying to grab various locks. |
250 |
++ * Wakeup waiting processes so that the reset work function |
251 |
++ * i915_error_work_func doesn't deadlock trying to grab various |
252 |
++ * locks. By bumping the reset counter first, the woken |
253 |
++ * processes will see a reset in progress and back off, |
254 |
++ * releasing their locks and then wait for the reset completion. |
255 |
++ * We must do this for _all_ gpu waiters that might hold locks |
256 |
++ * that the reset work needs to acquire. |
257 |
++ * |
258 |
++ * Note: The wake_up serves as the required memory barrier to |
259 |
++ * ensure that the waiters see the updated value of the reset |
260 |
++ * counter atomic_t. |
261 |
+ */ |
262 |
+- for_each_ring(ring, dev_priv, i) |
263 |
+- wake_up_all(&ring->irq_queue); |
264 |
++ i915_error_wake_up(dev_priv, false); |
265 |
+ } |
266 |
+ |
267 |
+- queue_work(dev_priv->wq, &dev_priv->gpu_error.work); |
268 |
++ /* |
269 |
++ * Our reset work can grab modeset locks (since it needs to reset the |
270 |
++ * state of outstanding pagelips). Hence it must not be run on our own |
271 |
++ * dev-priv->wq work queue for otherwise the flush_work in the pageflip |
272 |
++ * code will deadlock. |
273 |
++ */ |
274 |
++ schedule_work(&dev_priv->gpu_error.work); |
275 |
+ } |
276 |
+ |
277 |
+ static void __always_unused i915_pageflip_stall_check(struct drm_device *dev, int pipe) |
278 |
+diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c |
279 |
+index ca40d1b..bedf15a 100644 |
280 |
+--- a/drivers/gpu/drm/i915/intel_display.c |
281 |
++++ b/drivers/gpu/drm/i915/intel_display.c |
282 |
+@@ -4837,9 +4837,6 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, |
283 |
+ return -EINVAL; |
284 |
+ } |
285 |
+ |
286 |
+- /* Ensure that the cursor is valid for the new mode before changing... */ |
287 |
+- intel_crtc_update_cursor(crtc, true); |
288 |
+- |
289 |
+ if (is_lvds && dev_priv->lvds_downclock_avail) { |
290 |
+ /* |
291 |
+ * Ensure we match the reduced clock's P to the target clock. |
292 |
+@@ -5688,9 +5685,6 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, |
293 |
+ intel_crtc->config.dpll.p2 = clock.p2; |
294 |
+ } |
295 |
+ |
296 |
+- /* Ensure that the cursor is valid for the new mode before changing... */ |
297 |
+- intel_crtc_update_cursor(crtc, true); |
298 |
+- |
299 |
+ /* CPU eDP is the only output that doesn't need a PCH PLL of its own. */ |
300 |
+ if (intel_crtc->config.has_pch_encoder) { |
301 |
+ fp = i9xx_dpll_compute_fp(&intel_crtc->config.dpll); |
302 |
+@@ -5897,9 +5891,6 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc, |
303 |
+ if (!intel_ddi_pll_mode_set(crtc)) |
304 |
+ return -EINVAL; |
305 |
+ |
306 |
+- /* Ensure that the cursor is valid for the new mode before changing... */ |
307 |
+- intel_crtc_update_cursor(crtc, true); |
308 |
+- |
309 |
+ if (intel_crtc->config.has_dp_encoder) |
310 |
+ intel_dp_set_m_n(intel_crtc); |
311 |
+ |
312 |
+@@ -6581,7 +6572,8 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, |
313 |
+ intel_crtc->cursor_width = width; |
314 |
+ intel_crtc->cursor_height = height; |
315 |
+ |
316 |
+- intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL); |
317 |
++ if (intel_crtc->active) |
318 |
++ intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL); |
319 |
+ |
320 |
+ return 0; |
321 |
+ fail_unpin: |
322 |
+@@ -6600,7 +6592,8 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) |
323 |
+ intel_crtc->cursor_x = x; |
324 |
+ intel_crtc->cursor_y = y; |
325 |
+ |
326 |
+- intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL); |
327 |
++ if (intel_crtc->active) |
328 |
++ intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL); |
329 |
+ |
330 |
+ return 0; |
331 |
+ } |
332 |
+diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c |
333 |
+index cfb8fb6..119771f 100644 |
334 |
+--- a/drivers/gpu/drm/i915/intel_opregion.c |
335 |
++++ b/drivers/gpu/drm/i915/intel_opregion.c |
336 |
+@@ -173,7 +173,7 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) |
337 |
+ return ASLE_BACKLIGHT_FAILED; |
338 |
+ |
339 |
+ intel_panel_set_backlight(dev, bclp, 255); |
340 |
+- iowrite32((bclp*0x64)/0xff | ASLE_CBLV_VALID, &asle->cblv); |
341 |
++ iowrite32(DIV_ROUND_UP(bclp * 100, 255) | ASLE_CBLV_VALID, &asle->cblv); |
342 |
+ |
343 |
+ return 0; |
344 |
+ } |
345 |
+diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/dacnv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/dacnv50.c |
346 |
+index f02fd9f..a66b27c 100644 |
347 |
+--- a/drivers/gpu/drm/nouveau/core/engine/disp/dacnv50.c |
348 |
++++ b/drivers/gpu/drm/nouveau/core/engine/disp/dacnv50.c |
349 |
+@@ -49,18 +49,23 @@ int |
350 |
+ nv50_dac_sense(struct nv50_disp_priv *priv, int or, u32 loadval) |
351 |
+ { |
352 |
+ const u32 doff = (or * 0x800); |
353 |
+- int load = -EINVAL; |
354 |
++ |
355 |
+ nv_mask(priv, 0x61a004 + doff, 0x807f0000, 0x80150000); |
356 |
+ nv_wait(priv, 0x61a004 + doff, 0x80000000, 0x00000000); |
357 |
++ |
358 |
+ nv_wr32(priv, 0x61a00c + doff, 0x00100000 | loadval); |
359 |
+ mdelay(9); |
360 |
+ udelay(500); |
361 |
+- nv_wr32(priv, 0x61a00c + doff, 0x80000000); |
362 |
+- load = (nv_rd32(priv, 0x61a00c + doff) & 0x38000000) >> 27; |
363 |
+- nv_wr32(priv, 0x61a00c + doff, 0x00000000); |
364 |
++ loadval = nv_mask(priv, 0x61a00c + doff, 0xffffffff, 0x00000000); |
365 |
++ |
366 |
+ nv_mask(priv, 0x61a004 + doff, 0x807f0000, 0x80550000); |
367 |
+ nv_wait(priv, 0x61a004 + doff, 0x80000000, 0x00000000); |
368 |
+- return load; |
369 |
++ |
370 |
++ nv_debug(priv, "DAC%d sense: 0x%08x\n", or, loadval); |
371 |
++ if (!(loadval & 0x80000000)) |
372 |
++ return -ETIMEDOUT; |
373 |
++ |
374 |
++ return (loadval & 0x38000000) >> 27; |
375 |
+ } |
376 |
+ |
377 |
+ int |
378 |
+diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c |
379 |
+index 32501f6..1602398 100644 |
380 |
+--- a/drivers/gpu/drm/radeon/atombios_dp.c |
381 |
++++ b/drivers/gpu/drm/radeon/atombios_dp.c |
382 |
+@@ -50,7 +50,7 @@ static char *pre_emph_names[] = { |
383 |
+ * or from atom. Note that atom operates on |
384 |
+ * dw units. |
385 |
+ */ |
386 |
+-static void radeon_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le) |
387 |
++void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le) |
388 |
+ { |
389 |
+ #ifdef __BIG_ENDIAN |
390 |
+ u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */ |
391 |
+@@ -100,7 +100,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan, |
392 |
+ |
393 |
+ base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1); |
394 |
+ |
395 |
+- radeon_copy_swap(base, send, send_bytes, true); |
396 |
++ radeon_atom_copy_swap(base, send, send_bytes, true); |
397 |
+ |
398 |
+ args.v1.lpAuxRequest = cpu_to_le16((u16)(0 + 4)); |
399 |
+ args.v1.lpDataOut = cpu_to_le16((u16)(16 + 4)); |
400 |
+@@ -137,7 +137,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan, |
401 |
+ recv_bytes = recv_size; |
402 |
+ |
403 |
+ if (recv && recv_size) |
404 |
+- radeon_copy_swap(recv, base + 16, recv_bytes, false); |
405 |
++ radeon_atom_copy_swap(recv, base + 16, recv_bytes, false); |
406 |
+ |
407 |
+ return recv_bytes; |
408 |
+ } |
409 |
+diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c |
410 |
+index 092275d..7c2a285 100644 |
411 |
+--- a/drivers/gpu/drm/radeon/atombios_encoders.c |
412 |
++++ b/drivers/gpu/drm/radeon/atombios_encoders.c |
413 |
+@@ -1652,8 +1652,12 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode) |
414 |
+ atombios_dig_encoder_setup(encoder, ATOM_ENABLE, 0); |
415 |
+ atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0); |
416 |
+ atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); |
417 |
+- /* some early dce3.2 boards have a bug in their transmitter control table */ |
418 |
+- if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730)) |
419 |
++ /* some dce3.x boards have a bug in their transmitter control table. |
420 |
++ * ACTION_ENABLE_OUTPUT can probably be dropped since ACTION_ENABLE |
421 |
++ * does the same thing and more. |
422 |
++ */ |
423 |
++ if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730) && |
424 |
++ (rdev->family != CHIP_RS880)) |
425 |
+ atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); |
426 |
+ } |
427 |
+ if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) { |
428 |
+diff --git a/drivers/gpu/drm/radeon/atombios_i2c.c b/drivers/gpu/drm/radeon/atombios_i2c.c |
429 |
+index 082338d..2ca389d 100644 |
430 |
+--- a/drivers/gpu/drm/radeon/atombios_i2c.c |
431 |
++++ b/drivers/gpu/drm/radeon/atombios_i2c.c |
432 |
+@@ -27,6 +27,8 @@ |
433 |
+ #include "radeon.h" |
434 |
+ #include "atom.h" |
435 |
+ |
436 |
++extern void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); |
437 |
++ |
438 |
+ #define TARGET_HW_I2C_CLOCK 50 |
439 |
+ |
440 |
+ /* these are a limitation of ProcessI2cChannelTransaction not the hw */ |
441 |
+@@ -77,7 +79,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan, |
442 |
+ } |
443 |
+ |
444 |
+ if (!(flags & HW_I2C_WRITE)) |
445 |
+- memcpy(buf, base, num); |
446 |
++ radeon_atom_copy_swap(buf, base, num, false); |
447 |
+ |
448 |
+ return 0; |
449 |
+ } |
450 |
+diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c |
451 |
+index 9953e1f..084e694 100644 |
452 |
+--- a/drivers/gpu/drm/radeon/btc_dpm.c |
453 |
++++ b/drivers/gpu/drm/radeon/btc_dpm.c |
454 |
+@@ -2699,6 +2699,12 @@ int btc_dpm_init(struct radeon_device *rdev) |
455 |
+ else |
456 |
+ rdev->pm.dpm.dyn_state.sclk_mclk_delta = 10000; |
457 |
+ |
458 |
++ /* make sure dc limits are valid */ |
459 |
++ if ((rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) || |
460 |
++ (rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0)) |
461 |
++ rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc = |
462 |
++ rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac; |
463 |
++ |
464 |
+ return 0; |
465 |
+ } |
466 |
+ |
467 |
+diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c |
468 |
+index 8928bd1..7a96842 100644 |
469 |
+--- a/drivers/gpu/drm/radeon/cik.c |
470 |
++++ b/drivers/gpu/drm/radeon/cik.c |
471 |
+@@ -1880,7 +1880,47 @@ static void cik_gpu_init(struct radeon_device *rdev) |
472 |
+ gb_addr_config = BONAIRE_GB_ADDR_CONFIG_GOLDEN; |
473 |
+ break; |
474 |
+ case CHIP_KAVERI: |
475 |
+- /* TODO */ |
476 |
++ rdev->config.cik.max_shader_engines = 1; |
477 |
++ rdev->config.cik.max_tile_pipes = 4; |
478 |
++ if ((rdev->pdev->device == 0x1304) || |
479 |
++ (rdev->pdev->device == 0x1305) || |
480 |
++ (rdev->pdev->device == 0x130C) || |
481 |
++ (rdev->pdev->device == 0x130F) || |
482 |
++ (rdev->pdev->device == 0x1310) || |
483 |
++ (rdev->pdev->device == 0x1311) || |
484 |
++ (rdev->pdev->device == 0x131C)) { |
485 |
++ rdev->config.cik.max_cu_per_sh = 8; |
486 |
++ rdev->config.cik.max_backends_per_se = 2; |
487 |
++ } else if ((rdev->pdev->device == 0x1309) || |
488 |
++ (rdev->pdev->device == 0x130A) || |
489 |
++ (rdev->pdev->device == 0x130D) || |
490 |
++ (rdev->pdev->device == 0x1313) || |
491 |
++ (rdev->pdev->device == 0x131D)) { |
492 |
++ rdev->config.cik.max_cu_per_sh = 6; |
493 |
++ rdev->config.cik.max_backends_per_se = 2; |
494 |
++ } else if ((rdev->pdev->device == 0x1306) || |
495 |
++ (rdev->pdev->device == 0x1307) || |
496 |
++ (rdev->pdev->device == 0x130B) || |
497 |
++ (rdev->pdev->device == 0x130E) || |
498 |
++ (rdev->pdev->device == 0x1315) || |
499 |
++ (rdev->pdev->device == 0x131B)) { |
500 |
++ rdev->config.cik.max_cu_per_sh = 4; |
501 |
++ rdev->config.cik.max_backends_per_se = 1; |
502 |
++ } else { |
503 |
++ rdev->config.cik.max_cu_per_sh = 3; |
504 |
++ rdev->config.cik.max_backends_per_se = 1; |
505 |
++ } |
506 |
++ rdev->config.cik.max_sh_per_se = 1; |
507 |
++ rdev->config.cik.max_texture_channel_caches = 4; |
508 |
++ rdev->config.cik.max_gprs = 256; |
509 |
++ rdev->config.cik.max_gs_threads = 16; |
510 |
++ rdev->config.cik.max_hw_contexts = 8; |
511 |
++ |
512 |
++ rdev->config.cik.sc_prim_fifo_size_frontend = 0x20; |
513 |
++ rdev->config.cik.sc_prim_fifo_size_backend = 0x100; |
514 |
++ rdev->config.cik.sc_hiz_tile_fifo_size = 0x30; |
515 |
++ rdev->config.cik.sc_earlyz_tile_fifo_size = 0x130; |
516 |
++ gb_addr_config = BONAIRE_GB_ADDR_CONFIG_GOLDEN; |
517 |
+ break; |
518 |
+ case CHIP_KABINI: |
519 |
+ default: |
520 |
+@@ -5763,6 +5803,10 @@ restart_ih: |
521 |
+ break; |
522 |
+ } |
523 |
+ break; |
524 |
++ case 124: /* UVD */ |
525 |
++ DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data); |
526 |
++ radeon_fence_process(rdev, R600_RING_TYPE_UVD_INDEX); |
527 |
++ break; |
528 |
+ case 146: |
529 |
+ case 147: |
530 |
+ addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); |
531 |
+@@ -5964,6 +6008,11 @@ static int cik_startup(struct radeon_device *rdev) |
532 |
+ struct radeon_ring *ring; |
533 |
+ int r; |
534 |
+ |
535 |
++ /* scratch needs to be initialized before MC */ |
536 |
++ r = r600_vram_scratch_init(rdev); |
537 |
++ if (r) |
538 |
++ return r; |
539 |
++ |
540 |
+ cik_mc_program(rdev); |
541 |
+ |
542 |
+ if (rdev->flags & RADEON_IS_IGP) { |
543 |
+@@ -5993,10 +6042,6 @@ static int cik_startup(struct radeon_device *rdev) |
544 |
+ } |
545 |
+ } |
546 |
+ |
547 |
+- r = r600_vram_scratch_init(rdev); |
548 |
+- if (r) |
549 |
+- return r; |
550 |
+- |
551 |
+ r = cik_pcie_gart_enable(rdev); |
552 |
+ if (r) |
553 |
+ return r; |
554 |
+@@ -6398,8 +6443,8 @@ static u32 dce8_line_buffer_adjust(struct radeon_device *rdev, |
555 |
+ struct radeon_crtc *radeon_crtc, |
556 |
+ struct drm_display_mode *mode) |
557 |
+ { |
558 |
+- u32 tmp; |
559 |
+- |
560 |
++ u32 tmp, buffer_alloc, i; |
561 |
++ u32 pipe_offset = radeon_crtc->crtc_id * 0x20; |
562 |
+ /* |
563 |
+ * Line Buffer Setup |
564 |
+ * There are 6 line buffers, one for each display controllers. |
565 |
+@@ -6409,22 +6454,37 @@ static u32 dce8_line_buffer_adjust(struct radeon_device *rdev, |
566 |
+ * them using the stereo blender. |
567 |
+ */ |
568 |
+ if (radeon_crtc->base.enabled && mode) { |
569 |
+- if (mode->crtc_hdisplay < 1920) |
570 |
++ if (mode->crtc_hdisplay < 1920) { |
571 |
+ tmp = 1; |
572 |
+- else if (mode->crtc_hdisplay < 2560) |
573 |
++ buffer_alloc = 2; |
574 |
++ } else if (mode->crtc_hdisplay < 2560) { |
575 |
+ tmp = 2; |
576 |
+- else if (mode->crtc_hdisplay < 4096) |
577 |
++ buffer_alloc = 2; |
578 |
++ } else if (mode->crtc_hdisplay < 4096) { |
579 |
+ tmp = 0; |
580 |
+- else { |
581 |
++ buffer_alloc = (rdev->flags & RADEON_IS_IGP) ? 2 : 4; |
582 |
++ } else { |
583 |
+ DRM_DEBUG_KMS("Mode too big for LB!\n"); |
584 |
+ tmp = 0; |
585 |
++ buffer_alloc = (rdev->flags & RADEON_IS_IGP) ? 2 : 4; |
586 |
+ } |
587 |
+- } else |
588 |
++ } else { |
589 |
+ tmp = 1; |
590 |
++ buffer_alloc = 0; |
591 |
++ } |
592 |
+ |
593 |
+ WREG32(LB_MEMORY_CTRL + radeon_crtc->crtc_offset, |
594 |
+ LB_MEMORY_CONFIG(tmp) | LB_MEMORY_SIZE(0x6B0)); |
595 |
+ |
596 |
++ WREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset, |
597 |
++ DMIF_BUFFERS_ALLOCATED(buffer_alloc)); |
598 |
++ for (i = 0; i < rdev->usec_timeout; i++) { |
599 |
++ if (RREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset) & |
600 |
++ DMIF_BUFFERS_ALLOCATED_COMPLETED) |
601 |
++ break; |
602 |
++ udelay(1); |
603 |
++ } |
604 |
++ |
605 |
+ if (radeon_crtc->base.enabled && mode) { |
606 |
+ switch (tmp) { |
607 |
+ case 0: |
608 |
+diff --git a/drivers/gpu/drm/radeon/cikd.h b/drivers/gpu/drm/radeon/cikd.h |
609 |
+index 7e9275e..ade318e 100644 |
610 |
+--- a/drivers/gpu/drm/radeon/cikd.h |
611 |
++++ b/drivers/gpu/drm/radeon/cikd.h |
612 |
+@@ -43,6 +43,10 @@ |
613 |
+ |
614 |
+ #define DMIF_ADDR_CALC 0xC00 |
615 |
+ |
616 |
++#define PIPE0_DMIF_BUFFER_CONTROL 0x0ca0 |
617 |
++# define DMIF_BUFFERS_ALLOCATED(x) ((x) << 0) |
618 |
++# define DMIF_BUFFERS_ALLOCATED_COMPLETED (1 << 4) |
619 |
++ |
620 |
+ #define SRBM_GFX_CNTL 0xE44 |
621 |
+ #define PIPEID(x) ((x) << 0) |
622 |
+ #define MEID(x) ((x) << 2) |
623 |
+diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c |
624 |
+index d5b49e3..94dab1e 100644 |
625 |
+--- a/drivers/gpu/drm/radeon/evergreen.c |
626 |
++++ b/drivers/gpu/drm/radeon/evergreen.c |
627 |
+@@ -1807,7 +1807,8 @@ static u32 evergreen_line_buffer_adjust(struct radeon_device *rdev, |
628 |
+ struct drm_display_mode *mode, |
629 |
+ struct drm_display_mode *other_mode) |
630 |
+ { |
631 |
+- u32 tmp; |
632 |
++ u32 tmp, buffer_alloc, i; |
633 |
++ u32 pipe_offset = radeon_crtc->crtc_id * 0x20; |
634 |
+ /* |
635 |
+ * Line Buffer Setup |
636 |
+ * There are 3 line buffers, each one shared by 2 display controllers. |
637 |
+@@ -1830,18 +1831,34 @@ static u32 evergreen_line_buffer_adjust(struct radeon_device *rdev, |
638 |
+ * non-linked crtcs for maximum line buffer allocation. |
639 |
+ */ |
640 |
+ if (radeon_crtc->base.enabled && mode) { |
641 |
+- if (other_mode) |
642 |
++ if (other_mode) { |
643 |
+ tmp = 0; /* 1/2 */ |
644 |
+- else |
645 |
++ buffer_alloc = 1; |
646 |
++ } else { |
647 |
+ tmp = 2; /* whole */ |
648 |
+- } else |
649 |
++ buffer_alloc = 2; |
650 |
++ } |
651 |
++ } else { |
652 |
+ tmp = 0; |
653 |
++ buffer_alloc = 0; |
654 |
++ } |
655 |
+ |
656 |
+ /* second controller of the pair uses second half of the lb */ |
657 |
+ if (radeon_crtc->crtc_id % 2) |
658 |
+ tmp += 4; |
659 |
+ WREG32(DC_LB_MEMORY_SPLIT + radeon_crtc->crtc_offset, tmp); |
660 |
+ |
661 |
++ if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev)) { |
662 |
++ WREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset, |
663 |
++ DMIF_BUFFERS_ALLOCATED(buffer_alloc)); |
664 |
++ for (i = 0; i < rdev->usec_timeout; i++) { |
665 |
++ if (RREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset) & |
666 |
++ DMIF_BUFFERS_ALLOCATED_COMPLETED) |
667 |
++ break; |
668 |
++ udelay(1); |
669 |
++ } |
670 |
++ } |
671 |
++ |
672 |
+ if (radeon_crtc->base.enabled && mode) { |
673 |
+ switch (tmp) { |
674 |
+ case 0: |
675 |
+@@ -5106,6 +5123,11 @@ static int evergreen_startup(struct radeon_device *rdev) |
676 |
+ /* enable aspm */ |
677 |
+ evergreen_program_aspm(rdev); |
678 |
+ |
679 |
++ /* scratch needs to be initialized before MC */ |
680 |
++ r = r600_vram_scratch_init(rdev); |
681 |
++ if (r) |
682 |
++ return r; |
683 |
++ |
684 |
+ evergreen_mc_program(rdev); |
685 |
+ |
686 |
+ if (ASIC_IS_DCE5(rdev)) { |
687 |
+@@ -5131,10 +5153,6 @@ static int evergreen_startup(struct radeon_device *rdev) |
688 |
+ } |
689 |
+ } |
690 |
+ |
691 |
+- r = r600_vram_scratch_init(rdev); |
692 |
+- if (r) |
693 |
+- return r; |
694 |
+- |
695 |
+ if (rdev->flags & RADEON_IS_AGP) { |
696 |
+ evergreen_agp_enable(rdev); |
697 |
+ } else { |
698 |
+diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h |
699 |
+index 0d582ac..20fd17c 100644 |
700 |
+--- a/drivers/gpu/drm/radeon/evergreend.h |
701 |
++++ b/drivers/gpu/drm/radeon/evergreend.h |
702 |
+@@ -1153,6 +1153,10 @@ |
703 |
+ # define LATENCY_LOW_WATERMARK(x) ((x) << 0) |
704 |
+ # define LATENCY_HIGH_WATERMARK(x) ((x) << 16) |
705 |
+ |
706 |
++#define PIPE0_DMIF_BUFFER_CONTROL 0x0ca0 |
707 |
++# define DMIF_BUFFERS_ALLOCATED(x) ((x) << 0) |
708 |
++# define DMIF_BUFFERS_ALLOCATED_COMPLETED (1 << 4) |
709 |
++ |
710 |
+ #define IH_RB_CNTL 0x3e00 |
711 |
+ # define IH_RB_ENABLE (1 << 0) |
712 |
+ # define IH_IB_SIZE(x) ((x) << 1) /* log2 */ |
713 |
+diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c |
714 |
+index ccb4f8b5..fc55256 100644 |
715 |
+--- a/drivers/gpu/drm/radeon/ni.c |
716 |
++++ b/drivers/gpu/drm/radeon/ni.c |
717 |
+@@ -2083,6 +2083,11 @@ static int cayman_startup(struct radeon_device *rdev) |
718 |
+ /* enable aspm */ |
719 |
+ evergreen_program_aspm(rdev); |
720 |
+ |
721 |
++ /* scratch needs to be initialized before MC */ |
722 |
++ r = r600_vram_scratch_init(rdev); |
723 |
++ if (r) |
724 |
++ return r; |
725 |
++ |
726 |
+ evergreen_mc_program(rdev); |
727 |
+ |
728 |
+ if (rdev->flags & RADEON_IS_IGP) { |
729 |
+@@ -2109,10 +2114,6 @@ static int cayman_startup(struct radeon_device *rdev) |
730 |
+ } |
731 |
+ } |
732 |
+ |
733 |
+- r = r600_vram_scratch_init(rdev); |
734 |
+- if (r) |
735 |
+- return r; |
736 |
+- |
737 |
+ r = cayman_pcie_gart_enable(rdev); |
738 |
+ if (r) |
739 |
+ return r; |
740 |
+diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c |
741 |
+index f0f5f74..56d0d95 100644 |
742 |
+--- a/drivers/gpu/drm/radeon/ni_dpm.c |
743 |
++++ b/drivers/gpu/drm/radeon/ni_dpm.c |
744 |
+@@ -4270,6 +4270,12 @@ int ni_dpm_init(struct radeon_device *rdev) |
745 |
+ |
746 |
+ ni_pi->use_power_boost_limit = true; |
747 |
+ |
748 |
++ /* make sure dc limits are valid */ |
749 |
++ if ((rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) || |
750 |
++ (rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0)) |
751 |
++ rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc = |
752 |
++ rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac; |
753 |
++ |
754 |
+ return 0; |
755 |
+ } |
756 |
+ |
757 |
+diff --git a/drivers/gpu/drm/radeon/ppsmc.h b/drivers/gpu/drm/radeon/ppsmc.h |
758 |
+index b5564a3..2f7ad27 100644 |
759 |
+--- a/drivers/gpu/drm/radeon/ppsmc.h |
760 |
++++ b/drivers/gpu/drm/radeon/ppsmc.h |
761 |
+@@ -106,6 +106,8 @@ typedef uint8_t PPSMC_Result; |
762 |
+ #define PPSMC_MSG_DPM_N_LevelsDisabled ((uint32_t) 0x112) |
763 |
+ #define PPSMC_MSG_DCE_RemoveVoltageAdjustment ((uint32_t) 0x11d) |
764 |
+ #define PPSMC_MSG_DCE_AllowVoltageAdjustment ((uint32_t) 0x11e) |
765 |
++#define PPSMC_MSG_EnableBAPM ((uint32_t) 0x120) |
766 |
++#define PPSMC_MSG_DisableBAPM ((uint32_t) 0x121) |
767 |
+ #define PPSMC_MSG_UVD_DPM_Config ((uint32_t) 0x124) |
768 |
+ |
769 |
+ |
770 |
+diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c |
771 |
+index e66e720..739ffbe 100644 |
772 |
+--- a/drivers/gpu/drm/radeon/r600.c |
773 |
++++ b/drivers/gpu/drm/radeon/r600.c |
774 |
+@@ -119,6 +119,11 @@ u32 r600_get_xclk(struct radeon_device *rdev) |
775 |
+ return rdev->clock.spll.reference_freq; |
776 |
+ } |
777 |
+ |
778 |
++int r600_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk) |
779 |
++{ |
780 |
++ return 0; |
781 |
++} |
782 |
++ |
783 |
+ /* get temperature in millidegrees */ |
784 |
+ int rv6xx_get_temp(struct radeon_device *rdev) |
785 |
+ { |
786 |
+@@ -3334,6 +3339,11 @@ static int r600_startup(struct radeon_device *rdev) |
787 |
+ /* enable pcie gen2 link */ |
788 |
+ r600_pcie_gen2_enable(rdev); |
789 |
+ |
790 |
++ /* scratch needs to be initialized before MC */ |
791 |
++ r = r600_vram_scratch_init(rdev); |
792 |
++ if (r) |
793 |
++ return r; |
794 |
++ |
795 |
+ r600_mc_program(rdev); |
796 |
+ |
797 |
+ if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { |
798 |
+@@ -3344,10 +3354,6 @@ static int r600_startup(struct radeon_device *rdev) |
799 |
+ } |
800 |
+ } |
801 |
+ |
802 |
+- r = r600_vram_scratch_init(rdev); |
803 |
+- if (r) |
804 |
+- return r; |
805 |
+- |
806 |
+ if (rdev->flags & RADEON_IS_AGP) { |
807 |
+ r600_agp_enable(rdev); |
808 |
+ } else { |
809 |
+diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c |
810 |
+index f8f8b31..38317b9 100644 |
811 |
+--- a/drivers/gpu/drm/radeon/radeon_asic.c |
812 |
++++ b/drivers/gpu/drm/radeon/radeon_asic.c |
813 |
+@@ -1146,6 +1146,7 @@ static struct radeon_asic rv6xx_asic = { |
814 |
+ .set_pcie_lanes = &r600_set_pcie_lanes, |
815 |
+ .set_clock_gating = NULL, |
816 |
+ .get_temperature = &rv6xx_get_temp, |
817 |
++ .set_uvd_clocks = &r600_set_uvd_clocks, |
818 |
+ }, |
819 |
+ .dpm = { |
820 |
+ .init = &rv6xx_dpm_init, |
821 |
+@@ -1257,6 +1258,7 @@ static struct radeon_asic rs780_asic = { |
822 |
+ .set_pcie_lanes = NULL, |
823 |
+ .set_clock_gating = NULL, |
824 |
+ .get_temperature = &rv6xx_get_temp, |
825 |
++ .set_uvd_clocks = &r600_set_uvd_clocks, |
826 |
+ }, |
827 |
+ .dpm = { |
828 |
+ .init = &rs780_dpm_init, |
829 |
+diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h |
830 |
+index 3d61d5a..ddbd2b8 100644 |
831 |
+--- a/drivers/gpu/drm/radeon/radeon_asic.h |
832 |
++++ b/drivers/gpu/drm/radeon/radeon_asic.h |
833 |
+@@ -405,6 +405,7 @@ int r600_mc_wait_for_idle(struct radeon_device *rdev); |
834 |
+ u32 r600_get_xclk(struct radeon_device *rdev); |
835 |
+ uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev); |
836 |
+ int rv6xx_get_temp(struct radeon_device *rdev); |
837 |
++int r600_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk); |
838 |
+ int r600_dpm_pre_set_power_state(struct radeon_device *rdev); |
839 |
+ void r600_dpm_post_set_power_state(struct radeon_device *rdev); |
840 |
+ /* rv6xx dpm */ |
841 |
+diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c |
842 |
+index 4ccd61f..11dc5c8 100644 |
843 |
+--- a/drivers/gpu/drm/radeon/radeon_atombios.c |
844 |
++++ b/drivers/gpu/drm/radeon/radeon_atombios.c |
845 |
+@@ -711,13 +711,16 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) |
846 |
+ (ATOM_SRC_DST_TABLE_FOR_ONE_OBJECT *) |
847 |
+ (ctx->bios + data_offset + |
848 |
+ le16_to_cpu(router_obj->asObjects[k].usSrcDstTableOffset)); |
849 |
++ u8 *num_dst_objs = (u8 *) |
850 |
++ ((u8 *)router_src_dst_table + 1 + |
851 |
++ (router_src_dst_table->ucNumberOfSrc * 2)); |
852 |
++ u16 *dst_objs = (u16 *)(num_dst_objs + 1); |
853 |
+ int enum_id; |
854 |
+ |
855 |
+ router.router_id = router_obj_id; |
856 |
+- for (enum_id = 0; enum_id < router_src_dst_table->ucNumberOfDst; |
857 |
+- enum_id++) { |
858 |
++ for (enum_id = 0; enum_id < (*num_dst_objs); enum_id++) { |
859 |
+ if (le16_to_cpu(path->usConnObjectId) == |
860 |
+- le16_to_cpu(router_src_dst_table->usDstObjectID[enum_id])) |
861 |
++ le16_to_cpu(dst_objs[enum_id])) |
862 |
+ break; |
863 |
+ } |
864 |
+ |
865 |
+@@ -1672,7 +1675,9 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct |
866 |
+ kfree(edid); |
867 |
+ } |
868 |
+ } |
869 |
+- record += sizeof(ATOM_FAKE_EDID_PATCH_RECORD); |
870 |
++ record += fake_edid_record->ucFakeEDIDLength ? |
871 |
++ fake_edid_record->ucFakeEDIDLength + 2 : |
872 |
++ sizeof(ATOM_FAKE_EDID_PATCH_RECORD); |
873 |
+ break; |
874 |
+ case LCD_PANEL_RESOLUTION_RECORD_TYPE: |
875 |
+ panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record; |
876 |
+diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c |
877 |
+index 2399f25..5a87c9f 100644 |
878 |
+--- a/drivers/gpu/drm/radeon/radeon_connectors.c |
879 |
++++ b/drivers/gpu/drm/radeon/radeon_connectors.c |
880 |
+@@ -1489,6 +1489,24 @@ static const struct drm_connector_funcs radeon_dp_connector_funcs = { |
881 |
+ .force = radeon_dvi_force, |
882 |
+ }; |
883 |
+ |
884 |
++static const struct drm_connector_funcs radeon_edp_connector_funcs = { |
885 |
++ .dpms = drm_helper_connector_dpms, |
886 |
++ .detect = radeon_dp_detect, |
887 |
++ .fill_modes = drm_helper_probe_single_connector_modes, |
888 |
++ .set_property = radeon_lvds_set_property, |
889 |
++ .destroy = radeon_dp_connector_destroy, |
890 |
++ .force = radeon_dvi_force, |
891 |
++}; |
892 |
++ |
893 |
++static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = { |
894 |
++ .dpms = drm_helper_connector_dpms, |
895 |
++ .detect = radeon_dp_detect, |
896 |
++ .fill_modes = drm_helper_probe_single_connector_modes, |
897 |
++ .set_property = radeon_lvds_set_property, |
898 |
++ .destroy = radeon_dp_connector_destroy, |
899 |
++ .force = radeon_dvi_force, |
900 |
++}; |
901 |
++ |
902 |
+ void |
903 |
+ radeon_add_atom_connector(struct drm_device *dev, |
904 |
+ uint32_t connector_id, |
905 |
+@@ -1580,8 +1598,6 @@ radeon_add_atom_connector(struct drm_device *dev, |
906 |
+ goto failed; |
907 |
+ radeon_dig_connector->igp_lane_info = igp_lane_info; |
908 |
+ radeon_connector->con_priv = radeon_dig_connector; |
909 |
+- drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); |
910 |
+- drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
911 |
+ if (i2c_bus->valid) { |
912 |
+ /* add DP i2c bus */ |
913 |
+ if (connector_type == DRM_MODE_CONNECTOR_eDP) |
914 |
+@@ -1598,6 +1614,10 @@ radeon_add_atom_connector(struct drm_device *dev, |
915 |
+ case DRM_MODE_CONNECTOR_VGA: |
916 |
+ case DRM_MODE_CONNECTOR_DVIA: |
917 |
+ default: |
918 |
++ drm_connector_init(dev, &radeon_connector->base, |
919 |
++ &radeon_dp_connector_funcs, connector_type); |
920 |
++ drm_connector_helper_add(&radeon_connector->base, |
921 |
++ &radeon_dp_connector_helper_funcs); |
922 |
+ connector->interlace_allowed = true; |
923 |
+ connector->doublescan_allowed = true; |
924 |
+ radeon_connector->dac_load_detect = true; |
925 |
+@@ -1610,6 +1630,10 @@ radeon_add_atom_connector(struct drm_device *dev, |
926 |
+ case DRM_MODE_CONNECTOR_HDMIA: |
927 |
+ case DRM_MODE_CONNECTOR_HDMIB: |
928 |
+ case DRM_MODE_CONNECTOR_DisplayPort: |
929 |
++ drm_connector_init(dev, &radeon_connector->base, |
930 |
++ &radeon_dp_connector_funcs, connector_type); |
931 |
++ drm_connector_helper_add(&radeon_connector->base, |
932 |
++ &radeon_dp_connector_helper_funcs); |
933 |
+ drm_object_attach_property(&radeon_connector->base.base, |
934 |
+ rdev->mode_info.underscan_property, |
935 |
+ UNDERSCAN_OFF); |
936 |
+@@ -1634,6 +1658,10 @@ radeon_add_atom_connector(struct drm_device *dev, |
937 |
+ break; |
938 |
+ case DRM_MODE_CONNECTOR_LVDS: |
939 |
+ case DRM_MODE_CONNECTOR_eDP: |
940 |
++ drm_connector_init(dev, &radeon_connector->base, |
941 |
++ &radeon_lvds_bridge_connector_funcs, connector_type); |
942 |
++ drm_connector_helper_add(&radeon_connector->base, |
943 |
++ &radeon_dp_connector_helper_funcs); |
944 |
+ drm_object_attach_property(&radeon_connector->base.base, |
945 |
+ dev->mode_config.scaling_mode_property, |
946 |
+ DRM_MODE_SCALE_FULLSCREEN); |
947 |
+@@ -1797,7 +1825,7 @@ radeon_add_atom_connector(struct drm_device *dev, |
948 |
+ goto failed; |
949 |
+ radeon_dig_connector->igp_lane_info = igp_lane_info; |
950 |
+ radeon_connector->con_priv = radeon_dig_connector; |
951 |
+- drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); |
952 |
++ drm_connector_init(dev, &radeon_connector->base, &radeon_edp_connector_funcs, connector_type); |
953 |
+ drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
954 |
+ if (i2c_bus->valid) { |
955 |
+ /* add DP i2c bus */ |
956 |
+diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c |
957 |
+index 13a130f..7c110ef 100644 |
958 |
+--- a/drivers/gpu/drm/radeon/radeon_cs.c |
959 |
++++ b/drivers/gpu/drm/radeon/radeon_cs.c |
960 |
+@@ -80,9 +80,11 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) |
961 |
+ p->relocs[i].lobj.bo = p->relocs[i].robj; |
962 |
+ p->relocs[i].lobj.written = !!r->write_domain; |
963 |
+ |
964 |
+- /* the first reloc of an UVD job is the |
965 |
+- msg and that must be in VRAM */ |
966 |
+- if (p->ring == R600_RING_TYPE_UVD_INDEX && i == 0) { |
967 |
++ /* the first reloc of an UVD job is the msg and that must be in |
968 |
++ VRAM, also but everything into VRAM on AGP cards to avoid |
969 |
++ image corruptions */ |
970 |
++ if (p->ring == R600_RING_TYPE_UVD_INDEX && |
971 |
++ (i == 0 || p->rdev->flags & RADEON_IS_AGP)) { |
972 |
+ /* TODO: is this still needed for NI+ ? */ |
973 |
+ p->relocs[i].lobj.domain = |
974 |
+ RADEON_GEM_DOMAIN_VRAM; |
975 |
+diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c |
976 |
+index 081886b..cc9e848 100644 |
977 |
+--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c |
978 |
++++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c |
979 |
+@@ -275,17 +275,19 @@ int radeon_irq_kms_init(struct radeon_device *rdev) |
980 |
+ dev_info(rdev->dev, "radeon: using MSI.\n"); |
981 |
+ } |
982 |
+ } |
983 |
++ |
984 |
++ INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func); |
985 |
++ INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi); |
986 |
++ INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func); |
987 |
++ |
988 |
+ rdev->irq.installed = true; |
989 |
+ r = drm_irq_install(rdev->ddev); |
990 |
+ if (r) { |
991 |
+ rdev->irq.installed = false; |
992 |
++ flush_work(&rdev->hotplug_work); |
993 |
+ return r; |
994 |
+ } |
995 |
+ |
996 |
+- INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func); |
997 |
+- INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi); |
998 |
+- INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func); |
999 |
+- |
1000 |
+ DRM_INFO("radeon: irq initialized.\n"); |
1001 |
+ return 0; |
1002 |
+ } |
1003 |
+diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c |
1004 |
+index 49ff3d1..cc2ca38 100644 |
1005 |
+--- a/drivers/gpu/drm/radeon/radeon_kms.c |
1006 |
++++ b/drivers/gpu/drm/radeon/radeon_kms.c |
1007 |
+@@ -433,6 +433,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) |
1008 |
+ return -EINVAL; |
1009 |
+ } |
1010 |
+ break; |
1011 |
++ case RADEON_INFO_SI_CP_DMA_COMPUTE: |
1012 |
++ *value = 1; |
1013 |
++ break; |
1014 |
+ default: |
1015 |
+ DRM_DEBUG_KMS("Invalid request %d\n", info->request); |
1016 |
+ return -EINVAL; |
1017 |
+diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c |
1018 |
+index 233a9b9..b8074a8 100644 |
1019 |
+--- a/drivers/gpu/drm/radeon/rs400.c |
1020 |
++++ b/drivers/gpu/drm/radeon/rs400.c |
1021 |
+@@ -174,10 +174,13 @@ int rs400_gart_enable(struct radeon_device *rdev) |
1022 |
+ /* FIXME: according to doc we should set HIDE_MMCFG_BAR=0, |
1023 |
+ * AGPMODE30=0 & AGP30ENHANCED=0 in NB_CNTL */ |
1024 |
+ if ((rdev->family == CHIP_RS690) || (rdev->family == CHIP_RS740)) { |
1025 |
+- WREG32_MC(RS480_MC_MISC_CNTL, |
1026 |
+- (RS480_GART_INDEX_REG_EN | RS690_BLOCK_GFX_D3_EN)); |
1027 |
++ tmp = RREG32_MC(RS480_MC_MISC_CNTL); |
1028 |
++ tmp |= RS480_GART_INDEX_REG_EN | RS690_BLOCK_GFX_D3_EN; |
1029 |
++ WREG32_MC(RS480_MC_MISC_CNTL, tmp); |
1030 |
+ } else { |
1031 |
+- WREG32_MC(RS480_MC_MISC_CNTL, RS480_GART_INDEX_REG_EN); |
1032 |
++ tmp = RREG32_MC(RS480_MC_MISC_CNTL); |
1033 |
++ tmp |= RS480_GART_INDEX_REG_EN; |
1034 |
++ WREG32_MC(RS480_MC_MISC_CNTL, tmp); |
1035 |
+ } |
1036 |
+ /* Enable gart */ |
1037 |
+ WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, (RS480_GART_EN | size_reg)); |
1038 |
+diff --git a/drivers/gpu/drm/radeon/rs780_dpm.c b/drivers/gpu/drm/radeon/rs780_dpm.c |
1039 |
+index d1a1ce7..4296723 100644 |
1040 |
+--- a/drivers/gpu/drm/radeon/rs780_dpm.c |
1041 |
++++ b/drivers/gpu/drm/radeon/rs780_dpm.c |
1042 |
+@@ -486,6 +486,9 @@ static void rs780_activate_engine_clk_scaling(struct radeon_device *rdev, |
1043 |
+ (new_state->sclk_low == old_state->sclk_low)) |
1044 |
+ return; |
1045 |
+ |
1046 |
++ if (new_state->sclk_high == new_state->sclk_low) |
1047 |
++ return; |
1048 |
++ |
1049 |
+ rs780_clk_scaling_enable(rdev, true); |
1050 |
+ } |
1051 |
+ |
1052 |
+@@ -717,14 +720,18 @@ static void rs780_parse_pplib_non_clock_info(struct radeon_device *rdev, |
1053 |
+ if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { |
1054 |
+ rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); |
1055 |
+ rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); |
1056 |
+- } else if (r600_is_uvd_state(rps->class, rps->class2)) { |
1057 |
+- rps->vclk = RS780_DEFAULT_VCLK_FREQ; |
1058 |
+- rps->dclk = RS780_DEFAULT_DCLK_FREQ; |
1059 |
+ } else { |
1060 |
+ rps->vclk = 0; |
1061 |
+ rps->dclk = 0; |
1062 |
+ } |
1063 |
+ |
1064 |
++ if (r600_is_uvd_state(rps->class, rps->class2)) { |
1065 |
++ if ((rps->vclk == 0) || (rps->dclk == 0)) { |
1066 |
++ rps->vclk = RS780_DEFAULT_VCLK_FREQ; |
1067 |
++ rps->dclk = RS780_DEFAULT_DCLK_FREQ; |
1068 |
++ } |
1069 |
++ } |
1070 |
++ |
1071 |
+ if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) |
1072 |
+ rdev->pm.dpm.boot_ps = rps; |
1073 |
+ if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) |
1074 |
+diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c |
1075 |
+index f5e92cf..73529c9 100644 |
1076 |
+--- a/drivers/gpu/drm/radeon/rv770.c |
1077 |
++++ b/drivers/gpu/drm/radeon/rv770.c |
1078 |
+@@ -1829,6 +1829,11 @@ static int rv770_startup(struct radeon_device *rdev) |
1079 |
+ /* enable pcie gen2 link */ |
1080 |
+ rv770_pcie_gen2_enable(rdev); |
1081 |
+ |
1082 |
++ /* scratch needs to be initialized before MC */ |
1083 |
++ r = r600_vram_scratch_init(rdev); |
1084 |
++ if (r) |
1085 |
++ return r; |
1086 |
++ |
1087 |
+ rv770_mc_program(rdev); |
1088 |
+ |
1089 |
+ if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { |
1090 |
+@@ -1839,10 +1844,6 @@ static int rv770_startup(struct radeon_device *rdev) |
1091 |
+ } |
1092 |
+ } |
1093 |
+ |
1094 |
+- r = r600_vram_scratch_init(rdev); |
1095 |
+- if (r) |
1096 |
+- return r; |
1097 |
+- |
1098 |
+ if (rdev->flags & RADEON_IS_AGP) { |
1099 |
+ rv770_agp_enable(rdev); |
1100 |
+ } else { |
1101 |
+diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c |
1102 |
+index 094c67a..4d50ca3 100644 |
1103 |
+--- a/drivers/gpu/drm/radeon/rv770_dpm.c |
1104 |
++++ b/drivers/gpu/drm/radeon/rv770_dpm.c |
1105 |
+@@ -2147,14 +2147,18 @@ static void rv7xx_parse_pplib_non_clock_info(struct radeon_device *rdev, |
1106 |
+ if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { |
1107 |
+ rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); |
1108 |
+ rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); |
1109 |
+- } else if (r600_is_uvd_state(rps->class, rps->class2)) { |
1110 |
+- rps->vclk = RV770_DEFAULT_VCLK_FREQ; |
1111 |
+- rps->dclk = RV770_DEFAULT_DCLK_FREQ; |
1112 |
+ } else { |
1113 |
+ rps->vclk = 0; |
1114 |
+ rps->dclk = 0; |
1115 |
+ } |
1116 |
+ |
1117 |
++ if (r600_is_uvd_state(rps->class, rps->class2)) { |
1118 |
++ if ((rps->vclk == 0) || (rps->dclk == 0)) { |
1119 |
++ rps->vclk = RV770_DEFAULT_VCLK_FREQ; |
1120 |
++ rps->dclk = RV770_DEFAULT_DCLK_FREQ; |
1121 |
++ } |
1122 |
++ } |
1123 |
++ |
1124 |
+ if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) |
1125 |
+ rdev->pm.dpm.boot_ps = rps; |
1126 |
+ if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) |
1127 |
+@@ -2517,8 +2521,16 @@ u32 rv770_dpm_get_mclk(struct radeon_device *rdev, bool low) |
1128 |
+ bool rv770_dpm_vblank_too_short(struct radeon_device *rdev) |
1129 |
+ { |
1130 |
+ u32 vblank_time = r600_dpm_get_vblank_time(rdev); |
1131 |
++ u32 switch_limit = 300; |
1132 |
++ |
1133 |
++ /* quirks */ |
1134 |
++ /* ASUS K70AF */ |
1135 |
++ if ((rdev->pdev->device == 0x9553) && |
1136 |
++ (rdev->pdev->subsystem_vendor == 0x1043) && |
1137 |
++ (rdev->pdev->subsystem_device == 0x1c42)) |
1138 |
++ switch_limit = 200; |
1139 |
+ |
1140 |
+- if (vblank_time < 300) |
1141 |
++ if (vblank_time < switch_limit) |
1142 |
+ return true; |
1143 |
+ else |
1144 |
+ return false; |
1145 |
+diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c |
1146 |
+index daa8d2d..7af2113 100644 |
1147 |
+--- a/drivers/gpu/drm/radeon/si.c |
1148 |
++++ b/drivers/gpu/drm/radeon/si.c |
1149 |
+@@ -1704,7 +1704,8 @@ static u32 dce6_line_buffer_adjust(struct radeon_device *rdev, |
1150 |
+ struct drm_display_mode *mode, |
1151 |
+ struct drm_display_mode *other_mode) |
1152 |
+ { |
1153 |
+- u32 tmp; |
1154 |
++ u32 tmp, buffer_alloc, i; |
1155 |
++ u32 pipe_offset = radeon_crtc->crtc_id * 0x20; |
1156 |
+ /* |
1157 |
+ * Line Buffer Setup |
1158 |
+ * There are 3 line buffers, each one shared by 2 display controllers. |
1159 |
+@@ -1719,16 +1720,30 @@ static u32 dce6_line_buffer_adjust(struct radeon_device *rdev, |
1160 |
+ * non-linked crtcs for maximum line buffer allocation. |
1161 |
+ */ |
1162 |
+ if (radeon_crtc->base.enabled && mode) { |
1163 |
+- if (other_mode) |
1164 |
++ if (other_mode) { |
1165 |
+ tmp = 0; /* 1/2 */ |
1166 |
+- else |
1167 |
++ buffer_alloc = 1; |
1168 |
++ } else { |
1169 |
+ tmp = 2; /* whole */ |
1170 |
+- } else |
1171 |
++ buffer_alloc = 2; |
1172 |
++ } |
1173 |
++ } else { |
1174 |
+ tmp = 0; |
1175 |
++ buffer_alloc = 0; |
1176 |
++ } |
1177 |
+ |
1178 |
+ WREG32(DC_LB_MEMORY_SPLIT + radeon_crtc->crtc_offset, |
1179 |
+ DC_LB_MEMORY_CONFIG(tmp)); |
1180 |
+ |
1181 |
++ WREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset, |
1182 |
++ DMIF_BUFFERS_ALLOCATED(buffer_alloc)); |
1183 |
++ for (i = 0; i < rdev->usec_timeout; i++) { |
1184 |
++ if (RREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset) & |
1185 |
++ DMIF_BUFFERS_ALLOCATED_COMPLETED) |
1186 |
++ break; |
1187 |
++ udelay(1); |
1188 |
++ } |
1189 |
++ |
1190 |
+ if (radeon_crtc->base.enabled && mode) { |
1191 |
+ switch (tmp) { |
1192 |
+ case 0: |
1193 |
+@@ -4083,13 +4098,64 @@ static int si_vm_packet3_ce_check(struct radeon_device *rdev, |
1194 |
+ return 0; |
1195 |
+ } |
1196 |
+ |
1197 |
++static int si_vm_packet3_cp_dma_check(u32 *ib, u32 idx) |
1198 |
++{ |
1199 |
++ u32 start_reg, reg, i; |
1200 |
++ u32 command = ib[idx + 4]; |
1201 |
++ u32 info = ib[idx + 1]; |
1202 |
++ u32 idx_value = ib[idx]; |
1203 |
++ if (command & PACKET3_CP_DMA_CMD_SAS) { |
1204 |
++ /* src address space is register */ |
1205 |
++ if (((info & 0x60000000) >> 29) == 0) { |
1206 |
++ start_reg = idx_value << 2; |
1207 |
++ if (command & PACKET3_CP_DMA_CMD_SAIC) { |
1208 |
++ reg = start_reg; |
1209 |
++ if (!si_vm_reg_valid(reg)) { |
1210 |
++ DRM_ERROR("CP DMA Bad SRC register\n"); |
1211 |
++ return -EINVAL; |
1212 |
++ } |
1213 |
++ } else { |
1214 |
++ for (i = 0; i < (command & 0x1fffff); i++) { |
1215 |
++ reg = start_reg + (4 * i); |
1216 |
++ if (!si_vm_reg_valid(reg)) { |
1217 |
++ DRM_ERROR("CP DMA Bad SRC register\n"); |
1218 |
++ return -EINVAL; |
1219 |
++ } |
1220 |
++ } |
1221 |
++ } |
1222 |
++ } |
1223 |
++ } |
1224 |
++ if (command & PACKET3_CP_DMA_CMD_DAS) { |
1225 |
++ /* dst address space is register */ |
1226 |
++ if (((info & 0x00300000) >> 20) == 0) { |
1227 |
++ start_reg = ib[idx + 2]; |
1228 |
++ if (command & PACKET3_CP_DMA_CMD_DAIC) { |
1229 |
++ reg = start_reg; |
1230 |
++ if (!si_vm_reg_valid(reg)) { |
1231 |
++ DRM_ERROR("CP DMA Bad DST register\n"); |
1232 |
++ return -EINVAL; |
1233 |
++ } |
1234 |
++ } else { |
1235 |
++ for (i = 0; i < (command & 0x1fffff); i++) { |
1236 |
++ reg = start_reg + (4 * i); |
1237 |
++ if (!si_vm_reg_valid(reg)) { |
1238 |
++ DRM_ERROR("CP DMA Bad DST register\n"); |
1239 |
++ return -EINVAL; |
1240 |
++ } |
1241 |
++ } |
1242 |
++ } |
1243 |
++ } |
1244 |
++ } |
1245 |
++ return 0; |
1246 |
++} |
1247 |
++ |
1248 |
+ static int si_vm_packet3_gfx_check(struct radeon_device *rdev, |
1249 |
+ u32 *ib, struct radeon_cs_packet *pkt) |
1250 |
+ { |
1251 |
++ int r; |
1252 |
+ u32 idx = pkt->idx + 1; |
1253 |
+ u32 idx_value = ib[idx]; |
1254 |
+ u32 start_reg, end_reg, reg, i; |
1255 |
+- u32 command, info; |
1256 |
+ |
1257 |
+ switch (pkt->opcode) { |
1258 |
+ case PACKET3_NOP: |
1259 |
+@@ -4190,50 +4256,9 @@ static int si_vm_packet3_gfx_check(struct radeon_device *rdev, |
1260 |
+ } |
1261 |
+ break; |
1262 |
+ case PACKET3_CP_DMA: |
1263 |
+- command = ib[idx + 4]; |
1264 |
+- info = ib[idx + 1]; |
1265 |
+- if (command & PACKET3_CP_DMA_CMD_SAS) { |
1266 |
+- /* src address space is register */ |
1267 |
+- if (((info & 0x60000000) >> 29) == 0) { |
1268 |
+- start_reg = idx_value << 2; |
1269 |
+- if (command & PACKET3_CP_DMA_CMD_SAIC) { |
1270 |
+- reg = start_reg; |
1271 |
+- if (!si_vm_reg_valid(reg)) { |
1272 |
+- DRM_ERROR("CP DMA Bad SRC register\n"); |
1273 |
+- return -EINVAL; |
1274 |
+- } |
1275 |
+- } else { |
1276 |
+- for (i = 0; i < (command & 0x1fffff); i++) { |
1277 |
+- reg = start_reg + (4 * i); |
1278 |
+- if (!si_vm_reg_valid(reg)) { |
1279 |
+- DRM_ERROR("CP DMA Bad SRC register\n"); |
1280 |
+- return -EINVAL; |
1281 |
+- } |
1282 |
+- } |
1283 |
+- } |
1284 |
+- } |
1285 |
+- } |
1286 |
+- if (command & PACKET3_CP_DMA_CMD_DAS) { |
1287 |
+- /* dst address space is register */ |
1288 |
+- if (((info & 0x00300000) >> 20) == 0) { |
1289 |
+- start_reg = ib[idx + 2]; |
1290 |
+- if (command & PACKET3_CP_DMA_CMD_DAIC) { |
1291 |
+- reg = start_reg; |
1292 |
+- if (!si_vm_reg_valid(reg)) { |
1293 |
+- DRM_ERROR("CP DMA Bad DST register\n"); |
1294 |
+- return -EINVAL; |
1295 |
+- } |
1296 |
+- } else { |
1297 |
+- for (i = 0; i < (command & 0x1fffff); i++) { |
1298 |
+- reg = start_reg + (4 * i); |
1299 |
+- if (!si_vm_reg_valid(reg)) { |
1300 |
+- DRM_ERROR("CP DMA Bad DST register\n"); |
1301 |
+- return -EINVAL; |
1302 |
+- } |
1303 |
+- } |
1304 |
+- } |
1305 |
+- } |
1306 |
+- } |
1307 |
++ r = si_vm_packet3_cp_dma_check(ib, idx); |
1308 |
++ if (r) |
1309 |
++ return r; |
1310 |
+ break; |
1311 |
+ default: |
1312 |
+ DRM_ERROR("Invalid GFX packet3: 0x%x\n", pkt->opcode); |
1313 |
+@@ -4245,6 +4270,7 @@ static int si_vm_packet3_gfx_check(struct radeon_device *rdev, |
1314 |
+ static int si_vm_packet3_compute_check(struct radeon_device *rdev, |
1315 |
+ u32 *ib, struct radeon_cs_packet *pkt) |
1316 |
+ { |
1317 |
++ int r; |
1318 |
+ u32 idx = pkt->idx + 1; |
1319 |
+ u32 idx_value = ib[idx]; |
1320 |
+ u32 start_reg, reg, i; |
1321 |
+@@ -4317,6 +4343,11 @@ static int si_vm_packet3_compute_check(struct radeon_device *rdev, |
1322 |
+ return -EINVAL; |
1323 |
+ } |
1324 |
+ break; |
1325 |
++ case PACKET3_CP_DMA: |
1326 |
++ r = si_vm_packet3_cp_dma_check(ib, idx); |
1327 |
++ if (r) |
1328 |
++ return r; |
1329 |
++ break; |
1330 |
+ default: |
1331 |
+ DRM_ERROR("Invalid Compute packet3: 0x%x\n", pkt->opcode); |
1332 |
+ return -EINVAL; |
1333 |
+@@ -6422,6 +6453,11 @@ static int si_startup(struct radeon_device *rdev) |
1334 |
+ /* enable aspm */ |
1335 |
+ si_program_aspm(rdev); |
1336 |
+ |
1337 |
++ /* scratch needs to be initialized before MC */ |
1338 |
++ r = r600_vram_scratch_init(rdev); |
1339 |
++ if (r) |
1340 |
++ return r; |
1341 |
++ |
1342 |
+ si_mc_program(rdev); |
1343 |
+ |
1344 |
+ if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw || |
1345 |
+@@ -6439,10 +6475,6 @@ static int si_startup(struct radeon_device *rdev) |
1346 |
+ return r; |
1347 |
+ } |
1348 |
+ |
1349 |
+- r = r600_vram_scratch_init(rdev); |
1350 |
+- if (r) |
1351 |
+- return r; |
1352 |
+- |
1353 |
+ r = si_pcie_gart_enable(rdev); |
1354 |
+ if (r) |
1355 |
+ return r; |
1356 |
+diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c |
1357 |
+index 88699e3..1cfba39 100644 |
1358 |
+--- a/drivers/gpu/drm/radeon/si_dpm.c |
1359 |
++++ b/drivers/gpu/drm/radeon/si_dpm.c |
1360 |
+@@ -6401,6 +6401,12 @@ int si_dpm_init(struct radeon_device *rdev) |
1361 |
+ |
1362 |
+ si_initialize_powertune_defaults(rdev); |
1363 |
+ |
1364 |
++ /* make sure dc limits are valid */ |
1365 |
++ if ((rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) || |
1366 |
++ (rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0)) |
1367 |
++ rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc = |
1368 |
++ rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac; |
1369 |
++ |
1370 |
+ return 0; |
1371 |
+ } |
1372 |
+ |
1373 |
+diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h |
1374 |
+index 2c8da27..2010d6b 100644 |
1375 |
+--- a/drivers/gpu/drm/radeon/sid.h |
1376 |
++++ b/drivers/gpu/drm/radeon/sid.h |
1377 |
+@@ -282,6 +282,10 @@ |
1378 |
+ |
1379 |
+ #define DMIF_ADDR_CALC 0xC00 |
1380 |
+ |
1381 |
++#define PIPE0_DMIF_BUFFER_CONTROL 0x0ca0 |
1382 |
++# define DMIF_BUFFERS_ALLOCATED(x) ((x) << 0) |
1383 |
++# define DMIF_BUFFERS_ALLOCATED_COMPLETED (1 << 4) |
1384 |
++ |
1385 |
+ #define SRBM_STATUS 0xE50 |
1386 |
+ #define GRBM_RQ_PENDING (1 << 5) |
1387 |
+ #define VMC_BUSY (1 << 8) |
1388 |
+diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c |
1389 |
+index a1eb5f5..28f4380 100644 |
1390 |
+--- a/drivers/gpu/drm/radeon/trinity_dpm.c |
1391 |
++++ b/drivers/gpu/drm/radeon/trinity_dpm.c |
1392 |
+@@ -1091,6 +1091,7 @@ int trinity_dpm_enable(struct radeon_device *rdev) |
1393 |
+ trinity_program_sclk_dpm(rdev); |
1394 |
+ trinity_start_dpm(rdev); |
1395 |
+ trinity_wait_for_dpm_enabled(rdev); |
1396 |
++ trinity_dpm_bapm_enable(rdev, false); |
1397 |
+ trinity_release_mutex(rdev); |
1398 |
+ |
1399 |
+ if (rdev->irq.installed && |
1400 |
+@@ -1116,6 +1117,7 @@ void trinity_dpm_disable(struct radeon_device *rdev) |
1401 |
+ trinity_release_mutex(rdev); |
1402 |
+ return; |
1403 |
+ } |
1404 |
++ trinity_dpm_bapm_enable(rdev, false); |
1405 |
+ trinity_disable_clock_power_gating(rdev); |
1406 |
+ sumo_clear_vc(rdev); |
1407 |
+ trinity_wait_for_level_0(rdev); |
1408 |
+diff --git a/drivers/gpu/drm/radeon/trinity_dpm.h b/drivers/gpu/drm/radeon/trinity_dpm.h |
1409 |
+index e82df07..259d9e8 100644 |
1410 |
+--- a/drivers/gpu/drm/radeon/trinity_dpm.h |
1411 |
++++ b/drivers/gpu/drm/radeon/trinity_dpm.h |
1412 |
+@@ -118,6 +118,7 @@ struct trinity_power_info { |
1413 |
+ #define TRINITY_AT_DFLT 30 |
1414 |
+ |
1415 |
+ /* trinity_smc.c */ |
1416 |
++int trinity_dpm_bapm_enable(struct radeon_device *rdev, bool enable); |
1417 |
+ int trinity_dpm_config(struct radeon_device *rdev, bool enable); |
1418 |
+ int trinity_uvd_dpm_config(struct radeon_device *rdev); |
1419 |
+ int trinity_dpm_force_state(struct radeon_device *rdev, u32 n); |
1420 |
+diff --git a/drivers/gpu/drm/radeon/trinity_smc.c b/drivers/gpu/drm/radeon/trinity_smc.c |
1421 |
+index a42d89f..9672bcb 100644 |
1422 |
+--- a/drivers/gpu/drm/radeon/trinity_smc.c |
1423 |
++++ b/drivers/gpu/drm/radeon/trinity_smc.c |
1424 |
+@@ -56,6 +56,14 @@ static int trinity_notify_message_to_smu(struct radeon_device *rdev, u32 id) |
1425 |
+ return 0; |
1426 |
+ } |
1427 |
+ |
1428 |
++int trinity_dpm_bapm_enable(struct radeon_device *rdev, bool enable) |
1429 |
++{ |
1430 |
++ if (enable) |
1431 |
++ return trinity_notify_message_to_smu(rdev, PPSMC_MSG_EnableBAPM); |
1432 |
++ else |
1433 |
++ return trinity_notify_message_to_smu(rdev, PPSMC_MSG_DisableBAPM); |
1434 |
++} |
1435 |
++ |
1436 |
+ int trinity_dpm_config(struct radeon_device *rdev, bool enable) |
1437 |
+ { |
1438 |
+ if (enable) |
1439 |
+diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c |
1440 |
+index 5e93a52..210d503 100644 |
1441 |
+--- a/drivers/gpu/drm/ttm/ttm_tt.c |
1442 |
++++ b/drivers/gpu/drm/ttm/ttm_tt.c |
1443 |
+@@ -170,7 +170,7 @@ void ttm_tt_destroy(struct ttm_tt *ttm) |
1444 |
+ ttm_tt_unbind(ttm); |
1445 |
+ } |
1446 |
+ |
1447 |
+- if (likely(ttm->pages != NULL)) { |
1448 |
++ if (ttm->state == tt_unbound) { |
1449 |
+ ttm->bdev->driver->ttm_tt_unpopulate(ttm); |
1450 |
+ } |
1451 |
+ |
1452 |
+diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c |
1453 |
+index 5956445..ee75486 100644 |
1454 |
+--- a/drivers/hid/hid-core.c |
1455 |
++++ b/drivers/hid/hid-core.c |
1456 |
+@@ -94,7 +94,6 @@ EXPORT_SYMBOL_GPL(hid_register_report); |
1457 |
+ static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) |
1458 |
+ { |
1459 |
+ struct hid_field *field; |
1460 |
+- int i; |
1461 |
+ |
1462 |
+ if (report->maxfield == HID_MAX_FIELDS) { |
1463 |
+ hid_err(report->device, "too many fields in report\n"); |
1464 |
+@@ -113,9 +112,6 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned |
1465 |
+ field->value = (s32 *)(field->usage + usages); |
1466 |
+ field->report = report; |
1467 |
+ |
1468 |
+- for (i = 0; i < usages; i++) |
1469 |
+- field->usage[i].usage_index = i; |
1470 |
+- |
1471 |
+ return field; |
1472 |
+ } |
1473 |
+ |
1474 |
+@@ -226,9 +222,9 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign |
1475 |
+ { |
1476 |
+ struct hid_report *report; |
1477 |
+ struct hid_field *field; |
1478 |
+- int usages; |
1479 |
++ unsigned usages; |
1480 |
+ unsigned offset; |
1481 |
+- int i; |
1482 |
++ unsigned i; |
1483 |
+ |
1484 |
+ report = hid_register_report(parser->device, report_type, parser->global.report_id); |
1485 |
+ if (!report) { |
1486 |
+@@ -255,7 +251,8 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign |
1487 |
+ if (!parser->local.usage_index) /* Ignore padding fields */ |
1488 |
+ return 0; |
1489 |
+ |
1490 |
+- usages = max_t(int, parser->local.usage_index, parser->global.report_count); |
1491 |
++ usages = max_t(unsigned, parser->local.usage_index, |
1492 |
++ parser->global.report_count); |
1493 |
+ |
1494 |
+ field = hid_register_field(report, usages, parser->global.report_count); |
1495 |
+ if (!field) |
1496 |
+@@ -266,13 +263,14 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign |
1497 |
+ field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); |
1498 |
+ |
1499 |
+ for (i = 0; i < usages; i++) { |
1500 |
+- int j = i; |
1501 |
++ unsigned j = i; |
1502 |
+ /* Duplicate the last usage we parsed if we have excess values */ |
1503 |
+ if (i >= parser->local.usage_index) |
1504 |
+ j = parser->local.usage_index - 1; |
1505 |
+ field->usage[i].hid = parser->local.usage[j]; |
1506 |
+ field->usage[i].collection_index = |
1507 |
+ parser->local.collection_index[j]; |
1508 |
++ field->usage[i].usage_index = i; |
1509 |
+ } |
1510 |
+ |
1511 |
+ field->maxusage = usages; |
1512 |
+@@ -759,6 +757,64 @@ int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size) |
1513 |
+ } |
1514 |
+ EXPORT_SYMBOL_GPL(hid_parse_report); |
1515 |
+ |
1516 |
++static const char * const hid_report_names[] = { |
1517 |
++ "HID_INPUT_REPORT", |
1518 |
++ "HID_OUTPUT_REPORT", |
1519 |
++ "HID_FEATURE_REPORT", |
1520 |
++}; |
1521 |
++/** |
1522 |
++ * hid_validate_values - validate existing device report's value indexes |
1523 |
++ * |
1524 |
++ * @device: hid device |
1525 |
++ * @type: which report type to examine |
1526 |
++ * @id: which report ID to examine (0 for first) |
1527 |
++ * @field_index: which report field to examine |
1528 |
++ * @report_counts: expected number of values |
1529 |
++ * |
1530 |
++ * Validate the number of values in a given field of a given report, after |
1531 |
++ * parsing. |
1532 |
++ */ |
1533 |
++struct hid_report *hid_validate_values(struct hid_device *hid, |
1534 |
++ unsigned int type, unsigned int id, |
1535 |
++ unsigned int field_index, |
1536 |
++ unsigned int report_counts) |
1537 |
++{ |
1538 |
++ struct hid_report *report; |
1539 |
++ |
1540 |
++ if (type > HID_FEATURE_REPORT) { |
1541 |
++ hid_err(hid, "invalid HID report type %u\n", type); |
1542 |
++ return NULL; |
1543 |
++ } |
1544 |
++ |
1545 |
++ if (id >= HID_MAX_IDS) { |
1546 |
++ hid_err(hid, "invalid HID report id %u\n", id); |
1547 |
++ return NULL; |
1548 |
++ } |
1549 |
++ |
1550 |
++ /* |
1551 |
++ * Explicitly not using hid_get_report() here since it depends on |
1552 |
++ * ->numbered being checked, which may not always be the case when |
1553 |
++ * drivers go to access report values. |
1554 |
++ */ |
1555 |
++ report = hid->report_enum[type].report_id_hash[id]; |
1556 |
++ if (!report) { |
1557 |
++ hid_err(hid, "missing %s %u\n", hid_report_names[type], id); |
1558 |
++ return NULL; |
1559 |
++ } |
1560 |
++ if (report->maxfield <= field_index) { |
1561 |
++ hid_err(hid, "not enough fields in %s %u\n", |
1562 |
++ hid_report_names[type], id); |
1563 |
++ return NULL; |
1564 |
++ } |
1565 |
++ if (report->field[field_index]->report_count < report_counts) { |
1566 |
++ hid_err(hid, "not enough values in %s %u field %u\n", |
1567 |
++ hid_report_names[type], id, field_index); |
1568 |
++ return NULL; |
1569 |
++ } |
1570 |
++ return report; |
1571 |
++} |
1572 |
++EXPORT_SYMBOL_GPL(hid_validate_values); |
1573 |
++ |
1574 |
+ /** |
1575 |
+ * hid_open_report - open a driver-specific device report |
1576 |
+ * |
1577 |
+@@ -1237,7 +1293,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, |
1578 |
+ goto out; |
1579 |
+ } |
1580 |
+ |
1581 |
+- if (hid->claimed != HID_CLAIMED_HIDRAW) { |
1582 |
++ if (hid->claimed != HID_CLAIMED_HIDRAW && report->maxfield) { |
1583 |
+ for (a = 0; a < report->maxfield; a++) |
1584 |
+ hid_input_field(hid, report->field[a], cdata, interrupt); |
1585 |
+ hdrv = hid->driver; |
1586 |
+diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c |
1587 |
+index 3fc4034..e30dddc 100644 |
1588 |
+--- a/drivers/hid/hid-input.c |
1589 |
++++ b/drivers/hid/hid-input.c |
1590 |
+@@ -485,6 +485,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel |
1591 |
+ if (field->flags & HID_MAIN_ITEM_CONSTANT) |
1592 |
+ goto ignore; |
1593 |
+ |
1594 |
++ /* Ignore if report count is out of bounds. */ |
1595 |
++ if (field->report_count < 1) |
1596 |
++ goto ignore; |
1597 |
++ |
1598 |
+ /* only LED usages are supported in output fields */ |
1599 |
+ if (field->report_type == HID_OUTPUT_REPORT && |
1600 |
+ (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) { |
1601 |
+@@ -1168,7 +1172,11 @@ static void report_features(struct hid_device *hid) |
1602 |
+ |
1603 |
+ rep_enum = &hid->report_enum[HID_FEATURE_REPORT]; |
1604 |
+ list_for_each_entry(rep, &rep_enum->report_list, list) |
1605 |
+- for (i = 0; i < rep->maxfield; i++) |
1606 |
++ for (i = 0; i < rep->maxfield; i++) { |
1607 |
++ /* Ignore if report count is out of bounds. */ |
1608 |
++ if (rep->field[i]->report_count < 1) |
1609 |
++ continue; |
1610 |
++ |
1611 |
+ for (j = 0; j < rep->field[i]->maxusage; j++) { |
1612 |
+ /* Verify if Battery Strength feature is available */ |
1613 |
+ hidinput_setup_battery(hid, HID_FEATURE_REPORT, rep->field[i]); |
1614 |
+@@ -1177,6 +1185,7 @@ static void report_features(struct hid_device *hid) |
1615 |
+ drv->feature_mapping(hid, rep->field[i], |
1616 |
+ rep->field[i]->usage + j); |
1617 |
+ } |
1618 |
++ } |
1619 |
+ } |
1620 |
+ |
1621 |
+ static struct hid_input *hidinput_allocate(struct hid_device *hid) |
1622 |
+diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c |
1623 |
+index 07837f5..31cf29a 100644 |
1624 |
+--- a/drivers/hid/hid-lenovo-tpkbd.c |
1625 |
++++ b/drivers/hid/hid-lenovo-tpkbd.c |
1626 |
+@@ -339,7 +339,15 @@ static int tpkbd_probe_tp(struct hid_device *hdev) |
1627 |
+ struct tpkbd_data_pointer *data_pointer; |
1628 |
+ size_t name_sz = strlen(dev_name(dev)) + 16; |
1629 |
+ char *name_mute, *name_micmute; |
1630 |
+- int ret; |
1631 |
++ int i, ret; |
1632 |
++ |
1633 |
++ /* Validate required reports. */ |
1634 |
++ for (i = 0; i < 4; i++) { |
1635 |
++ if (!hid_validate_values(hdev, HID_FEATURE_REPORT, 4, i, 1)) |
1636 |
++ return -ENODEV; |
1637 |
++ } |
1638 |
++ if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 3, 0, 2)) |
1639 |
++ return -ENODEV; |
1640 |
+ |
1641 |
+ if (sysfs_create_group(&hdev->dev.kobj, |
1642 |
+ &tpkbd_attr_group_pointer)) { |
1643 |
+@@ -406,22 +414,27 @@ static int tpkbd_probe(struct hid_device *hdev, |
1644 |
+ ret = hid_parse(hdev); |
1645 |
+ if (ret) { |
1646 |
+ hid_err(hdev, "hid_parse failed\n"); |
1647 |
+- goto err_free; |
1648 |
++ goto err; |
1649 |
+ } |
1650 |
+ |
1651 |
+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
1652 |
+ if (ret) { |
1653 |
+ hid_err(hdev, "hid_hw_start failed\n"); |
1654 |
+- goto err_free; |
1655 |
++ goto err; |
1656 |
+ } |
1657 |
+ |
1658 |
+ uhdev = (struct usbhid_device *) hdev->driver_data; |
1659 |
+ |
1660 |
+- if (uhdev->ifnum == 1) |
1661 |
+- return tpkbd_probe_tp(hdev); |
1662 |
++ if (uhdev->ifnum == 1) { |
1663 |
++ ret = tpkbd_probe_tp(hdev); |
1664 |
++ if (ret) |
1665 |
++ goto err_hid; |
1666 |
++ } |
1667 |
+ |
1668 |
+ return 0; |
1669 |
+-err_free: |
1670 |
++err_hid: |
1671 |
++ hid_hw_stop(hdev); |
1672 |
++err: |
1673 |
+ return ret; |
1674 |
+ } |
1675 |
+ |
1676 |
+diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c |
1677 |
+index b3cd150..1a42eaa 100644 |
1678 |
+--- a/drivers/hid/hid-lg2ff.c |
1679 |
++++ b/drivers/hid/hid-lg2ff.c |
1680 |
+@@ -64,26 +64,13 @@ int lg2ff_init(struct hid_device *hid) |
1681 |
+ struct hid_report *report; |
1682 |
+ struct hid_input *hidinput = list_entry(hid->inputs.next, |
1683 |
+ struct hid_input, list); |
1684 |
+- struct list_head *report_list = |
1685 |
+- &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
1686 |
+ struct input_dev *dev = hidinput->input; |
1687 |
+ int error; |
1688 |
+ |
1689 |
+- if (list_empty(report_list)) { |
1690 |
+- hid_err(hid, "no output report found\n"); |
1691 |
++ /* Check that the report looks ok */ |
1692 |
++ report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7); |
1693 |
++ if (!report) |
1694 |
+ return -ENODEV; |
1695 |
+- } |
1696 |
+- |
1697 |
+- report = list_entry(report_list->next, struct hid_report, list); |
1698 |
+- |
1699 |
+- if (report->maxfield < 1) { |
1700 |
+- hid_err(hid, "output report is empty\n"); |
1701 |
+- return -ENODEV; |
1702 |
+- } |
1703 |
+- if (report->field[0]->report_count < 7) { |
1704 |
+- hid_err(hid, "not enough values in the field\n"); |
1705 |
+- return -ENODEV; |
1706 |
+- } |
1707 |
+ |
1708 |
+ lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL); |
1709 |
+ if (!lg2ff) |
1710 |
+diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c |
1711 |
+index e52f181..8c2da18 100644 |
1712 |
+--- a/drivers/hid/hid-lg3ff.c |
1713 |
++++ b/drivers/hid/hid-lg3ff.c |
1714 |
+@@ -66,10 +66,11 @@ static int hid_lg3ff_play(struct input_dev *dev, void *data, |
1715 |
+ int x, y; |
1716 |
+ |
1717 |
+ /* |
1718 |
+- * Maxusage should always be 63 (maximum fields) |
1719 |
+- * likely a better way to ensure this data is clean |
1720 |
++ * Available values in the field should always be 63, but we only use up to |
1721 |
++ * 35. Instead, clear the entire area, however big it is. |
1722 |
+ */ |
1723 |
+- memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage); |
1724 |
++ memset(report->field[0]->value, 0, |
1725 |
++ sizeof(__s32) * report->field[0]->report_count); |
1726 |
+ |
1727 |
+ switch (effect->type) { |
1728 |
+ case FF_CONSTANT: |
1729 |
+@@ -129,32 +130,14 @@ static const signed short ff3_joystick_ac[] = { |
1730 |
+ int lg3ff_init(struct hid_device *hid) |
1731 |
+ { |
1732 |
+ struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
1733 |
+- struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
1734 |
+ struct input_dev *dev = hidinput->input; |
1735 |
+- struct hid_report *report; |
1736 |
+- struct hid_field *field; |
1737 |
+ const signed short *ff_bits = ff3_joystick_ac; |
1738 |
+ int error; |
1739 |
+ int i; |
1740 |
+ |
1741 |
+- /* Find the report to use */ |
1742 |
+- if (list_empty(report_list)) { |
1743 |
+- hid_err(hid, "No output report found\n"); |
1744 |
+- return -1; |
1745 |
+- } |
1746 |
+- |
1747 |
+ /* Check that the report looks ok */ |
1748 |
+- report = list_entry(report_list->next, struct hid_report, list); |
1749 |
+- if (!report) { |
1750 |
+- hid_err(hid, "NULL output report\n"); |
1751 |
+- return -1; |
1752 |
+- } |
1753 |
+- |
1754 |
+- field = report->field[0]; |
1755 |
+- if (!field) { |
1756 |
+- hid_err(hid, "NULL field\n"); |
1757 |
+- return -1; |
1758 |
+- } |
1759 |
++ if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35)) |
1760 |
++ return -ENODEV; |
1761 |
+ |
1762 |
+ /* Assume single fixed device G940 */ |
1763 |
+ for (i = 0; ff_bits[i] >= 0; i++) |
1764 |
+diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c |
1765 |
+index 0ddae2a..8782fe1 100644 |
1766 |
+--- a/drivers/hid/hid-lg4ff.c |
1767 |
++++ b/drivers/hid/hid-lg4ff.c |
1768 |
+@@ -484,34 +484,16 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde |
1769 |
+ int lg4ff_init(struct hid_device *hid) |
1770 |
+ { |
1771 |
+ struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
1772 |
+- struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
1773 |
+ struct input_dev *dev = hidinput->input; |
1774 |
+- struct hid_report *report; |
1775 |
+- struct hid_field *field; |
1776 |
+ struct lg4ff_device_entry *entry; |
1777 |
+ struct lg_drv_data *drv_data; |
1778 |
+ struct usb_device_descriptor *udesc; |
1779 |
+ int error, i, j; |
1780 |
+ __u16 bcdDevice, rev_maj, rev_min; |
1781 |
+ |
1782 |
+- /* Find the report to use */ |
1783 |
+- if (list_empty(report_list)) { |
1784 |
+- hid_err(hid, "No output report found\n"); |
1785 |
+- return -1; |
1786 |
+- } |
1787 |
+- |
1788 |
+ /* Check that the report looks ok */ |
1789 |
+- report = list_entry(report_list->next, struct hid_report, list); |
1790 |
+- if (!report) { |
1791 |
+- hid_err(hid, "NULL output report\n"); |
1792 |
++ if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) |
1793 |
+ return -1; |
1794 |
+- } |
1795 |
+- |
1796 |
+- field = report->field[0]; |
1797 |
+- if (!field) { |
1798 |
+- hid_err(hid, "NULL field\n"); |
1799 |
+- return -1; |
1800 |
+- } |
1801 |
+ |
1802 |
+ /* Check what wheel has been connected */ |
1803 |
+ for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) { |
1804 |
+diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c |
1805 |
+index d7ea8c8..e1394af 100644 |
1806 |
+--- a/drivers/hid/hid-lgff.c |
1807 |
++++ b/drivers/hid/hid-lgff.c |
1808 |
+@@ -128,27 +128,14 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude) |
1809 |
+ int lgff_init(struct hid_device* hid) |
1810 |
+ { |
1811 |
+ struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
1812 |
+- struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
1813 |
+ struct input_dev *dev = hidinput->input; |
1814 |
+- struct hid_report *report; |
1815 |
+- struct hid_field *field; |
1816 |
+ const signed short *ff_bits = ff_joystick; |
1817 |
+ int error; |
1818 |
+ int i; |
1819 |
+ |
1820 |
+- /* Find the report to use */ |
1821 |
+- if (list_empty(report_list)) { |
1822 |
+- hid_err(hid, "No output report found\n"); |
1823 |
+- return -1; |
1824 |
+- } |
1825 |
+- |
1826 |
+ /* Check that the report looks ok */ |
1827 |
+- report = list_entry(report_list->next, struct hid_report, list); |
1828 |
+- field = report->field[0]; |
1829 |
+- if (!field) { |
1830 |
+- hid_err(hid, "NULL field\n"); |
1831 |
+- return -1; |
1832 |
+- } |
1833 |
++ if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) |
1834 |
++ return -ENODEV; |
1835 |
+ |
1836 |
+ for (i = 0; i < ARRAY_SIZE(devices); i++) { |
1837 |
+ if (dev->id.vendor == devices[i].idVendor && |
1838 |
+diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c |
1839 |
+index cd33084..a2469b5 100644 |
1840 |
+--- a/drivers/hid/hid-logitech-dj.c |
1841 |
++++ b/drivers/hid/hid-logitech-dj.c |
1842 |
+@@ -461,7 +461,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev, |
1843 |
+ struct hid_report *report; |
1844 |
+ struct hid_report_enum *output_report_enum; |
1845 |
+ u8 *data = (u8 *)(&dj_report->device_index); |
1846 |
+- int i; |
1847 |
++ unsigned int i; |
1848 |
+ |
1849 |
+ output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT]; |
1850 |
+ report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT]; |
1851 |
+@@ -471,7 +471,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev, |
1852 |
+ return -ENODEV; |
1853 |
+ } |
1854 |
+ |
1855 |
+- for (i = 0; i < report->field[0]->report_count; i++) |
1856 |
++ for (i = 0; i < DJREPORT_SHORT_LENGTH - 1; i++) |
1857 |
+ report->field[0]->value[i] = data[i]; |
1858 |
+ |
1859 |
+ hid_hw_request(hdev, report, HID_REQ_SET_REPORT); |
1860 |
+@@ -783,6 +783,12 @@ static int logi_dj_probe(struct hid_device *hdev, |
1861 |
+ goto hid_parse_fail; |
1862 |
+ } |
1863 |
+ |
1864 |
++ if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT, |
1865 |
++ 0, DJREPORT_SHORT_LENGTH - 1)) { |
1866 |
++ retval = -ENODEV; |
1867 |
++ goto hid_parse_fail; |
1868 |
++ } |
1869 |
++ |
1870 |
+ /* Starts the usb device and connects to upper interfaces hiddev and |
1871 |
+ * hidraw */ |
1872 |
+ retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
1873 |
+diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c |
1874 |
+index cb0e361..2d3677c 100644 |
1875 |
+--- a/drivers/hid/hid-multitouch.c |
1876 |
++++ b/drivers/hid/hid-multitouch.c |
1877 |
+@@ -101,9 +101,9 @@ struct mt_device { |
1878 |
+ unsigned last_slot_field; /* the last field of a slot */ |
1879 |
+ unsigned mt_report_id; /* the report ID of the multitouch device */ |
1880 |
+ unsigned pen_report_id; /* the report ID of the pen device */ |
1881 |
+- __s8 inputmode; /* InputMode HID feature, -1 if non-existent */ |
1882 |
+- __s8 inputmode_index; /* InputMode HID feature index in the report */ |
1883 |
+- __s8 maxcontact_report_id; /* Maximum Contact Number HID feature, |
1884 |
++ __s16 inputmode; /* InputMode HID feature, -1 if non-existent */ |
1885 |
++ __s16 inputmode_index; /* InputMode HID feature index in the report */ |
1886 |
++ __s16 maxcontact_report_id; /* Maximum Contact Number HID feature, |
1887 |
+ -1 if non-existent */ |
1888 |
+ __u8 num_received; /* how many contacts we received */ |
1889 |
+ __u8 num_expected; /* expected last contact index */ |
1890 |
+@@ -317,20 +317,18 @@ static void mt_feature_mapping(struct hid_device *hdev, |
1891 |
+ struct hid_field *field, struct hid_usage *usage) |
1892 |
+ { |
1893 |
+ struct mt_device *td = hid_get_drvdata(hdev); |
1894 |
+- int i; |
1895 |
+ |
1896 |
+ switch (usage->hid) { |
1897 |
+ case HID_DG_INPUTMODE: |
1898 |
+- td->inputmode = field->report->id; |
1899 |
+- td->inputmode_index = 0; /* has to be updated below */ |
1900 |
+- |
1901 |
+- for (i=0; i < field->maxusage; i++) { |
1902 |
+- if (field->usage[i].hid == usage->hid) { |
1903 |
+- td->inputmode_index = i; |
1904 |
+- break; |
1905 |
+- } |
1906 |
++ /* Ignore if value index is out of bounds. */ |
1907 |
++ if (usage->usage_index >= field->report_count) { |
1908 |
++ dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n"); |
1909 |
++ break; |
1910 |
+ } |
1911 |
+ |
1912 |
++ td->inputmode = field->report->id; |
1913 |
++ td->inputmode_index = usage->usage_index; |
1914 |
++ |
1915 |
+ break; |
1916 |
+ case HID_DG_CONTACTMAX: |
1917 |
+ td->maxcontact_report_id = field->report->id; |
1918 |
+@@ -536,6 +534,10 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
1919 |
+ mt_store_field(usage, td, hi); |
1920 |
+ return 1; |
1921 |
+ case HID_DG_CONTACTCOUNT: |
1922 |
++ /* Ignore if indexes are out of bounds. */ |
1923 |
++ if (field->index >= field->report->maxfield || |
1924 |
++ usage->usage_index >= field->report_count) |
1925 |
++ return 1; |
1926 |
+ td->cc_index = field->index; |
1927 |
+ td->cc_value_index = usage->usage_index; |
1928 |
+ return 1; |
1929 |
+diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c |
1930 |
+index 87fbe29..334a4b5 100644 |
1931 |
+--- a/drivers/hid/hid-sony.c |
1932 |
++++ b/drivers/hid/hid-sony.c |
1933 |
+@@ -537,6 +537,10 @@ static int buzz_init(struct hid_device *hdev) |
1934 |
+ drv_data = hid_get_drvdata(hdev); |
1935 |
+ BUG_ON(!(drv_data->quirks & BUZZ_CONTROLLER)); |
1936 |
+ |
1937 |
++ /* Validate expected report characteristics. */ |
1938 |
++ if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7)) |
1939 |
++ return -ENODEV; |
1940 |
++ |
1941 |
+ buzz = kzalloc(sizeof(*buzz), GFP_KERNEL); |
1942 |
+ if (!buzz) { |
1943 |
+ hid_err(hdev, "Insufficient memory, cannot allocate driver data\n"); |
1944 |
+diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c |
1945 |
+index d164911..29f328f 100644 |
1946 |
+--- a/drivers/hid/hid-steelseries.c |
1947 |
++++ b/drivers/hid/hid-steelseries.c |
1948 |
+@@ -249,6 +249,11 @@ static int steelseries_srws1_probe(struct hid_device *hdev, |
1949 |
+ goto err_free; |
1950 |
+ } |
1951 |
+ |
1952 |
++ if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 16)) { |
1953 |
++ ret = -ENODEV; |
1954 |
++ goto err_free; |
1955 |
++ } |
1956 |
++ |
1957 |
+ ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
1958 |
+ if (ret) { |
1959 |
+ hid_err(hdev, "hw start failed\n"); |
1960 |
+diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c |
1961 |
+index 6ec28a3..a29756c 100644 |
1962 |
+--- a/drivers/hid/hid-zpff.c |
1963 |
++++ b/drivers/hid/hid-zpff.c |
1964 |
+@@ -68,21 +68,13 @@ static int zpff_init(struct hid_device *hid) |
1965 |
+ struct hid_report *report; |
1966 |
+ struct hid_input *hidinput = list_entry(hid->inputs.next, |
1967 |
+ struct hid_input, list); |
1968 |
+- struct list_head *report_list = |
1969 |
+- &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
1970 |
+ struct input_dev *dev = hidinput->input; |
1971 |
+- int error; |
1972 |
++ int i, error; |
1973 |
+ |
1974 |
+- if (list_empty(report_list)) { |
1975 |
+- hid_err(hid, "no output report found\n"); |
1976 |
+- return -ENODEV; |
1977 |
+- } |
1978 |
+- |
1979 |
+- report = list_entry(report_list->next, struct hid_report, list); |
1980 |
+- |
1981 |
+- if (report->maxfield < 4) { |
1982 |
+- hid_err(hid, "not enough fields in report\n"); |
1983 |
+- return -ENODEV; |
1984 |
++ for (i = 0; i < 4; i++) { |
1985 |
++ report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1); |
1986 |
++ if (!report) |
1987 |
++ return -ENODEV; |
1988 |
+ } |
1989 |
+ |
1990 |
+ zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL); |
1991 |
+diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c |
1992 |
+index eec0af4..1c6bc96 100644 |
1993 |
+--- a/drivers/net/ethernet/broadcom/bgmac.c |
1994 |
++++ b/drivers/net/ethernet/broadcom/bgmac.c |
1995 |
+@@ -908,7 +908,7 @@ static void bgmac_chip_reset(struct bgmac *bgmac) |
1996 |
+ struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc; |
1997 |
+ u8 et_swtype = 0; |
1998 |
+ u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY | |
1999 |
+- BGMAC_CHIPCTL_1_IF_TYPE_RMII; |
2000 |
++ BGMAC_CHIPCTL_1_IF_TYPE_MII; |
2001 |
+ char buf[2]; |
2002 |
+ |
2003 |
+ if (bcm47xx_nvram_getenv("et_swtype", buf, 1) > 0) { |
2004 |
+diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h |
2005 |
+index 98d4b5f..12a35cf 100644 |
2006 |
+--- a/drivers/net/ethernet/broadcom/bgmac.h |
2007 |
++++ b/drivers/net/ethernet/broadcom/bgmac.h |
2008 |
+@@ -333,7 +333,7 @@ |
2009 |
+ |
2010 |
+ #define BGMAC_CHIPCTL_1_IF_TYPE_MASK 0x00000030 |
2011 |
+ #define BGMAC_CHIPCTL_1_IF_TYPE_RMII 0x00000000 |
2012 |
+-#define BGMAC_CHIPCTL_1_IF_TYPE_MI 0x00000010 |
2013 |
++#define BGMAC_CHIPCTL_1_IF_TYPE_MII 0x00000010 |
2014 |
+ #define BGMAC_CHIPCTL_1_IF_TYPE_RGMII 0x00000020 |
2015 |
+ #define BGMAC_CHIPCTL_1_SW_TYPE_MASK 0x000000C0 |
2016 |
+ #define BGMAC_CHIPCTL_1_SW_TYPE_EPHY 0x00000000 |
2017 |
+diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c |
2018 |
+index 0da2214..a04d2da 100644 |
2019 |
+--- a/drivers/net/ethernet/broadcom/tg3.c |
2020 |
++++ b/drivers/net/ethernet/broadcom/tg3.c |
2021 |
+@@ -3030,6 +3030,20 @@ static bool tg3_phy_power_bug(struct tg3 *tp) |
2022 |
+ return false; |
2023 |
+ } |
2024 |
+ |
2025 |
++static bool tg3_phy_led_bug(struct tg3 *tp) |
2026 |
++{ |
2027 |
++ switch (tg3_asic_rev(tp)) { |
2028 |
++ case ASIC_REV_5719: |
2029 |
++ case ASIC_REV_5720: |
2030 |
++ if ((tp->phy_flags & TG3_PHYFLG_MII_SERDES) && |
2031 |
++ !tp->pci_fn) |
2032 |
++ return true; |
2033 |
++ return false; |
2034 |
++ } |
2035 |
++ |
2036 |
++ return false; |
2037 |
++} |
2038 |
++ |
2039 |
+ static void tg3_power_down_phy(struct tg3 *tp, bool do_low_power) |
2040 |
+ { |
2041 |
+ u32 val; |
2042 |
+@@ -3077,8 +3091,9 @@ static void tg3_power_down_phy(struct tg3 *tp, bool do_low_power) |
2043 |
+ } |
2044 |
+ return; |
2045 |
+ } else if (do_low_power) { |
2046 |
+- tg3_writephy(tp, MII_TG3_EXT_CTRL, |
2047 |
+- MII_TG3_EXT_CTRL_FORCE_LED_OFF); |
2048 |
++ if (!tg3_phy_led_bug(tp)) |
2049 |
++ tg3_writephy(tp, MII_TG3_EXT_CTRL, |
2050 |
++ MII_TG3_EXT_CTRL_FORCE_LED_OFF); |
2051 |
+ |
2052 |
+ val = MII_TG3_AUXCTL_PCTL_100TX_LPWR | |
2053 |
+ MII_TG3_AUXCTL_PCTL_SPR_ISOLATE | |
2054 |
+diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c |
2055 |
+index ef94a59..1a9c4f6 100644 |
2056 |
+--- a/drivers/net/ethernet/marvell/skge.c |
2057 |
++++ b/drivers/net/ethernet/marvell/skge.c |
2058 |
+@@ -3092,6 +3092,9 @@ static struct sk_buff *skge_rx_get(struct net_device *dev, |
2059 |
+ if (!nskb) |
2060 |
+ goto resubmit; |
2061 |
+ |
2062 |
++ skb = e->skb; |
2063 |
++ prefetch(skb->data); |
2064 |
++ |
2065 |
+ if (skge_rx_setup(skge, e, nskb, skge->rx_buf_size) < 0) { |
2066 |
+ dev_kfree_skb(nskb); |
2067 |
+ goto resubmit; |
2068 |
+@@ -3101,8 +3104,6 @@ static struct sk_buff *skge_rx_get(struct net_device *dev, |
2069 |
+ dma_unmap_addr(e, mapaddr), |
2070 |
+ dma_unmap_len(e, maplen), |
2071 |
+ PCI_DMA_FROMDEVICE); |
2072 |
+- skb = e->skb; |
2073 |
+- prefetch(skb->data); |
2074 |
+ } |
2075 |
+ |
2076 |
+ skb_put(skb, len); |
2077 |
+diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c |
2078 |
+index 03ad4dc..98aef3b 100644 |
2079 |
+--- a/drivers/net/usb/cdc_ether.c |
2080 |
++++ b/drivers/net/usb/cdc_ether.c |
2081 |
+@@ -726,6 +726,11 @@ static const struct usb_device_id products [] = { |
2082 |
+ .bInterfaceProtocol = USB_CDC_PROTO_NONE, |
2083 |
+ .driver_info = (unsigned long)&wwan_info, |
2084 |
+ }, { |
2085 |
++ /* Telit modules */ |
2086 |
++ USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM, |
2087 |
++ USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
2088 |
++ .driver_info = (kernel_ulong_t) &wwan_info, |
2089 |
++}, { |
2090 |
+ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, |
2091 |
+ USB_CDC_PROTO_NONE), |
2092 |
+ .driver_info = (unsigned long) &cdc_info, |
2093 |
+diff --git a/drivers/net/wireless/cw1200/cw1200_spi.c b/drivers/net/wireless/cw1200/cw1200_spi.c |
2094 |
+index d063760..f5e6b48 100644 |
2095 |
+--- a/drivers/net/wireless/cw1200/cw1200_spi.c |
2096 |
++++ b/drivers/net/wireless/cw1200/cw1200_spi.c |
2097 |
+@@ -40,7 +40,9 @@ struct hwbus_priv { |
2098 |
+ struct cw1200_common *core; |
2099 |
+ const struct cw1200_platform_data_spi *pdata; |
2100 |
+ spinlock_t lock; /* Serialize all bus operations */ |
2101 |
++ wait_queue_head_t wq; |
2102 |
+ int claimed; |
2103 |
++ int irq_disabled; |
2104 |
+ }; |
2105 |
+ |
2106 |
+ #define SDIO_TO_SPI_ADDR(addr) ((addr & 0x1f)>>2) |
2107 |
+@@ -197,8 +199,11 @@ static void cw1200_spi_lock(struct hwbus_priv *self) |
2108 |
+ { |
2109 |
+ unsigned long flags; |
2110 |
+ |
2111 |
++ DECLARE_WAITQUEUE(wait, current); |
2112 |
++ |
2113 |
+ might_sleep(); |
2114 |
+ |
2115 |
++ add_wait_queue(&self->wq, &wait); |
2116 |
+ spin_lock_irqsave(&self->lock, flags); |
2117 |
+ while (1) { |
2118 |
+ set_current_state(TASK_UNINTERRUPTIBLE); |
2119 |
+@@ -211,6 +216,7 @@ static void cw1200_spi_lock(struct hwbus_priv *self) |
2120 |
+ set_current_state(TASK_RUNNING); |
2121 |
+ self->claimed = 1; |
2122 |
+ spin_unlock_irqrestore(&self->lock, flags); |
2123 |
++ remove_wait_queue(&self->wq, &wait); |
2124 |
+ |
2125 |
+ return; |
2126 |
+ } |
2127 |
+@@ -222,6 +228,8 @@ static void cw1200_spi_unlock(struct hwbus_priv *self) |
2128 |
+ spin_lock_irqsave(&self->lock, flags); |
2129 |
+ self->claimed = 0; |
2130 |
+ spin_unlock_irqrestore(&self->lock, flags); |
2131 |
++ wake_up(&self->wq); |
2132 |
++ |
2133 |
+ return; |
2134 |
+ } |
2135 |
+ |
2136 |
+@@ -230,6 +238,8 @@ static irqreturn_t cw1200_spi_irq_handler(int irq, void *dev_id) |
2137 |
+ struct hwbus_priv *self = dev_id; |
2138 |
+ |
2139 |
+ if (self->core) { |
2140 |
++ disable_irq_nosync(self->func->irq); |
2141 |
++ self->irq_disabled = 1; |
2142 |
+ cw1200_irq_handler(self->core); |
2143 |
+ return IRQ_HANDLED; |
2144 |
+ } else { |
2145 |
+@@ -263,13 +273,22 @@ exit: |
2146 |
+ |
2147 |
+ static int cw1200_spi_irq_unsubscribe(struct hwbus_priv *self) |
2148 |
+ { |
2149 |
+- int ret = 0; |
2150 |
+- |
2151 |
+ pr_debug("SW IRQ unsubscribe\n"); |
2152 |
+ disable_irq_wake(self->func->irq); |
2153 |
+ free_irq(self->func->irq, self); |
2154 |
+ |
2155 |
+- return ret; |
2156 |
++ return 0; |
2157 |
++} |
2158 |
++ |
2159 |
++static int cw1200_spi_irq_enable(struct hwbus_priv *self, int enable) |
2160 |
++{ |
2161 |
++ /* Disables are handled by the interrupt handler */ |
2162 |
++ if (enable && self->irq_disabled) { |
2163 |
++ enable_irq(self->func->irq); |
2164 |
++ self->irq_disabled = 0; |
2165 |
++ } |
2166 |
++ |
2167 |
++ return 0; |
2168 |
+ } |
2169 |
+ |
2170 |
+ static int cw1200_spi_off(const struct cw1200_platform_data_spi *pdata) |
2171 |
+@@ -349,6 +368,7 @@ static struct hwbus_ops cw1200_spi_hwbus_ops = { |
2172 |
+ .unlock = cw1200_spi_unlock, |
2173 |
+ .align_size = cw1200_spi_align_size, |
2174 |
+ .power_mgmt = cw1200_spi_pm, |
2175 |
++ .irq_enable = cw1200_spi_irq_enable, |
2176 |
+ }; |
2177 |
+ |
2178 |
+ /* Probe Function to be called by SPI stack when device is discovered */ |
2179 |
+@@ -400,6 +420,8 @@ static int cw1200_spi_probe(struct spi_device *func) |
2180 |
+ |
2181 |
+ spi_set_drvdata(func, self); |
2182 |
+ |
2183 |
++ init_waitqueue_head(&self->wq); |
2184 |
++ |
2185 |
+ status = cw1200_spi_irq_subscribe(self); |
2186 |
+ |
2187 |
+ status = cw1200_core_probe(&cw1200_spi_hwbus_ops, |
2188 |
+diff --git a/drivers/net/wireless/cw1200/fwio.c b/drivers/net/wireless/cw1200/fwio.c |
2189 |
+index acdff0f..0b2061b 100644 |
2190 |
+--- a/drivers/net/wireless/cw1200/fwio.c |
2191 |
++++ b/drivers/net/wireless/cw1200/fwio.c |
2192 |
+@@ -485,7 +485,7 @@ int cw1200_load_firmware(struct cw1200_common *priv) |
2193 |
+ |
2194 |
+ /* Enable interrupt signalling */ |
2195 |
+ priv->hwbus_ops->lock(priv->hwbus_priv); |
2196 |
+- ret = __cw1200_irq_enable(priv, 1); |
2197 |
++ ret = __cw1200_irq_enable(priv, 2); |
2198 |
+ priv->hwbus_ops->unlock(priv->hwbus_priv); |
2199 |
+ if (ret < 0) |
2200 |
+ goto unsubscribe; |
2201 |
+diff --git a/drivers/net/wireless/cw1200/hwbus.h b/drivers/net/wireless/cw1200/hwbus.h |
2202 |
+index 8b2fc83..51dfb3a 100644 |
2203 |
+--- a/drivers/net/wireless/cw1200/hwbus.h |
2204 |
++++ b/drivers/net/wireless/cw1200/hwbus.h |
2205 |
+@@ -28,6 +28,7 @@ struct hwbus_ops { |
2206 |
+ void (*unlock)(struct hwbus_priv *self); |
2207 |
+ size_t (*align_size)(struct hwbus_priv *self, size_t size); |
2208 |
+ int (*power_mgmt)(struct hwbus_priv *self, bool suspend); |
2209 |
++ int (*irq_enable)(struct hwbus_priv *self, int enable); |
2210 |
+ }; |
2211 |
+ |
2212 |
+ #endif /* CW1200_HWBUS_H */ |
2213 |
+diff --git a/drivers/net/wireless/cw1200/hwio.c b/drivers/net/wireless/cw1200/hwio.c |
2214 |
+index ff230b7..41bd761 100644 |
2215 |
+--- a/drivers/net/wireless/cw1200/hwio.c |
2216 |
++++ b/drivers/net/wireless/cw1200/hwio.c |
2217 |
+@@ -273,6 +273,21 @@ int __cw1200_irq_enable(struct cw1200_common *priv, int enable) |
2218 |
+ u16 val16; |
2219 |
+ int ret; |
2220 |
+ |
2221 |
++ /* We need to do this hack because the SPI layer can sleep on I/O |
2222 |
++ and the general path involves I/O to the device in interrupt |
2223 |
++ context. |
2224 |
++ |
2225 |
++ However, the initial enable call needs to go to the hardware. |
2226 |
++ |
2227 |
++ We don't worry about shutdown because we do a full reset which |
2228 |
++ clears the interrupt enabled bits. |
2229 |
++ */ |
2230 |
++ if (priv->hwbus_ops->irq_enable) { |
2231 |
++ ret = priv->hwbus_ops->irq_enable(priv->hwbus_priv, enable); |
2232 |
++ if (ret || enable < 2) |
2233 |
++ return ret; |
2234 |
++ } |
2235 |
++ |
2236 |
+ if (HIF_8601_SILICON == priv->hw_type) { |
2237 |
+ ret = __cw1200_reg_read_32(priv, ST90TDS_CONFIG_REG_ID, &val32); |
2238 |
+ if (ret < 0) { |
2239 |
+diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c |
2240 |
+index 1b41c8e..39d8863 100644 |
2241 |
+--- a/drivers/net/wireless/rt2x00/rt2800lib.c |
2242 |
++++ b/drivers/net/wireless/rt2x00/rt2800lib.c |
2243 |
+@@ -2790,6 +2790,13 @@ static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev) |
2244 |
+ int i; |
2245 |
+ |
2246 |
+ /* |
2247 |
++ * First check if temperature compensation is supported. |
2248 |
++ */ |
2249 |
++ rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); |
2250 |
++ if (!rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC)) |
2251 |
++ return 0; |
2252 |
++ |
2253 |
++ /* |
2254 |
+ * Read TSSI boundaries for temperature compensation from |
2255 |
+ * the EEPROM. |
2256 |
+ * |
2257 |
+@@ -5404,19 +5411,20 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev) |
2258 |
+ rt2800_init_registers(rt2x00dev))) |
2259 |
+ return -EIO; |
2260 |
+ |
2261 |
++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev))) |
2262 |
++ return -EIO; |
2263 |
++ |
2264 |
+ /* |
2265 |
+ * Send signal to firmware during boot time. |
2266 |
+ */ |
2267 |
+ rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0); |
2268 |
+ rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); |
2269 |
+- if (rt2x00_is_usb(rt2x00dev)) { |
2270 |
++ if (rt2x00_is_usb(rt2x00dev)) |
2271 |
+ rt2800_register_write(rt2x00dev, H2M_INT_SRC, 0); |
2272 |
+- rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0); |
2273 |
+- } |
2274 |
++ rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0); |
2275 |
+ msleep(1); |
2276 |
+ |
2277 |
+- if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev) || |
2278 |
+- rt2800_wait_bbp_ready(rt2x00dev))) |
2279 |
++ if (unlikely(rt2800_wait_bbp_ready(rt2x00dev))) |
2280 |
+ return -EIO; |
2281 |
+ |
2282 |
+ rt2800_init_bbp(rt2x00dev); |
2283 |
+diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c |
2284 |
+index 01e264f..6e83e42 100644 |
2285 |
+--- a/drivers/pci/pci-acpi.c |
2286 |
++++ b/drivers/pci/pci-acpi.c |
2287 |
+@@ -47,6 +47,9 @@ static void pci_acpi_wake_dev(acpi_handle handle, u32 event, void *context) |
2288 |
+ if (event != ACPI_NOTIFY_DEVICE_WAKE || !pci_dev) |
2289 |
+ return; |
2290 |
+ |
2291 |
++ if (pci_dev->pme_poll) |
2292 |
++ pci_dev->pme_poll = false; |
2293 |
++ |
2294 |
+ if (pci_dev->current_state == PCI_D3cold) { |
2295 |
+ pci_wakeup_event(pci_dev); |
2296 |
+ pm_runtime_resume(&pci_dev->dev); |
2297 |
+@@ -57,9 +60,6 @@ static void pci_acpi_wake_dev(acpi_handle handle, u32 event, void *context) |
2298 |
+ if (pci_dev->pme_support) |
2299 |
+ pci_check_pme_status(pci_dev); |
2300 |
+ |
2301 |
+- if (pci_dev->pme_poll) |
2302 |
+- pci_dev->pme_poll = false; |
2303 |
+- |
2304 |
+ pci_wakeup_event(pci_dev); |
2305 |
+ pm_runtime_resume(&pci_dev->dev); |
2306 |
+ |
2307 |
+diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c |
2308 |
+index c588e8e..ac0e79e 100644 |
2309 |
+--- a/drivers/usb/gadget/dummy_hcd.c |
2310 |
++++ b/drivers/usb/gadget/dummy_hcd.c |
2311 |
+@@ -923,8 +923,9 @@ static int dummy_udc_stop(struct usb_gadget *g, |
2312 |
+ struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g); |
2313 |
+ struct dummy *dum = dum_hcd->dum; |
2314 |
+ |
2315 |
+- dev_dbg(udc_dev(dum), "unregister gadget driver '%s'\n", |
2316 |
+- driver->driver.name); |
2317 |
++ if (driver) |
2318 |
++ dev_dbg(udc_dev(dum), "unregister gadget driver '%s'\n", |
2319 |
++ driver->driver.name); |
2320 |
+ |
2321 |
+ dum->driver = NULL; |
2322 |
+ |
2323 |
+@@ -1000,8 +1001,8 @@ static int dummy_udc_remove(struct platform_device *pdev) |
2324 |
+ { |
2325 |
+ struct dummy *dum = platform_get_drvdata(pdev); |
2326 |
+ |
2327 |
+- usb_del_gadget_udc(&dum->gadget); |
2328 |
+ device_remove_file(&dum->gadget.dev, &dev_attr_function); |
2329 |
++ usb_del_gadget_udc(&dum->gadget); |
2330 |
+ return 0; |
2331 |
+ } |
2332 |
+ |
2333 |
+diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c |
2334 |
+index 8fb4291..45e944f 100644 |
2335 |
+--- a/fs/bio-integrity.c |
2336 |
++++ b/fs/bio-integrity.c |
2337 |
+@@ -734,7 +734,7 @@ void bioset_integrity_free(struct bio_set *bs) |
2338 |
+ mempool_destroy(bs->bio_integrity_pool); |
2339 |
+ |
2340 |
+ if (bs->bvec_integrity_pool) |
2341 |
+- mempool_destroy(bs->bio_integrity_pool); |
2342 |
++ mempool_destroy(bs->bvec_integrity_pool); |
2343 |
+ } |
2344 |
+ EXPORT_SYMBOL(bioset_integrity_free); |
2345 |
+ |
2346 |
+diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c |
2347 |
+index d62ce0d..4c019f4 100644 |
2348 |
+--- a/fs/cifs/dir.c |
2349 |
++++ b/fs/cifs/dir.c |
2350 |
+@@ -499,6 +499,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, |
2351 |
+ if (server->ops->close) |
2352 |
+ server->ops->close(xid, tcon, &fid); |
2353 |
+ cifs_del_pending_open(&open); |
2354 |
++ fput(file); |
2355 |
+ rc = -ENOMEM; |
2356 |
+ } |
2357 |
+ |
2358 |
+diff --git a/fs/udf/super.c b/fs/udf/super.c |
2359 |
+index 9ac4057..839a2ba 100644 |
2360 |
+--- a/fs/udf/super.c |
2361 |
++++ b/fs/udf/super.c |
2362 |
+@@ -630,6 +630,12 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options) |
2363 |
+ struct udf_sb_info *sbi = UDF_SB(sb); |
2364 |
+ int error = 0; |
2365 |
+ |
2366 |
++ if (sbi->s_lvid_bh) { |
2367 |
++ int write_rev = le16_to_cpu(udf_sb_lvidiu(sbi)->minUDFWriteRev); |
2368 |
++ if (write_rev > UDF_MAX_WRITE_VERSION && !(*flags & MS_RDONLY)) |
2369 |
++ return -EACCES; |
2370 |
++ } |
2371 |
++ |
2372 |
+ uopt.flags = sbi->s_flags; |
2373 |
+ uopt.uid = sbi->s_uid; |
2374 |
+ uopt.gid = sbi->s_gid; |
2375 |
+@@ -649,12 +655,6 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options) |
2376 |
+ sbi->s_dmode = uopt.dmode; |
2377 |
+ write_unlock(&sbi->s_cred_lock); |
2378 |
+ |
2379 |
+- if (sbi->s_lvid_bh) { |
2380 |
+- int write_rev = le16_to_cpu(udf_sb_lvidiu(sbi)->minUDFWriteRev); |
2381 |
+- if (write_rev > UDF_MAX_WRITE_VERSION) |
2382 |
+- *flags |= MS_RDONLY; |
2383 |
+- } |
2384 |
+- |
2385 |
+ if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) |
2386 |
+ goto out_unlock; |
2387 |
+ |
2388 |
+@@ -843,27 +843,38 @@ static int udf_find_fileset(struct super_block *sb, |
2389 |
+ return 1; |
2390 |
+ } |
2391 |
+ |
2392 |
++/* |
2393 |
++ * Load primary Volume Descriptor Sequence |
2394 |
++ * |
2395 |
++ * Return <0 on error, 0 on success. -EAGAIN is special meaning next sequence |
2396 |
++ * should be tried. |
2397 |
++ */ |
2398 |
+ static int udf_load_pvoldesc(struct super_block *sb, sector_t block) |
2399 |
+ { |
2400 |
+ struct primaryVolDesc *pvoldesc; |
2401 |
+ struct ustr *instr, *outstr; |
2402 |
+ struct buffer_head *bh; |
2403 |
+ uint16_t ident; |
2404 |
+- int ret = 1; |
2405 |
++ int ret = -ENOMEM; |
2406 |
+ |
2407 |
+ instr = kmalloc(sizeof(struct ustr), GFP_NOFS); |
2408 |
+ if (!instr) |
2409 |
+- return 1; |
2410 |
++ return -ENOMEM; |
2411 |
+ |
2412 |
+ outstr = kmalloc(sizeof(struct ustr), GFP_NOFS); |
2413 |
+ if (!outstr) |
2414 |
+ goto out1; |
2415 |
+ |
2416 |
+ bh = udf_read_tagged(sb, block, block, &ident); |
2417 |
+- if (!bh) |
2418 |
++ if (!bh) { |
2419 |
++ ret = -EAGAIN; |
2420 |
+ goto out2; |
2421 |
++ } |
2422 |
+ |
2423 |
+- BUG_ON(ident != TAG_IDENT_PVD); |
2424 |
++ if (ident != TAG_IDENT_PVD) { |
2425 |
++ ret = -EIO; |
2426 |
++ goto out_bh; |
2427 |
++ } |
2428 |
+ |
2429 |
+ pvoldesc = (struct primaryVolDesc *)bh->b_data; |
2430 |
+ |
2431 |
+@@ -889,8 +900,9 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block) |
2432 |
+ if (udf_CS0toUTF8(outstr, instr)) |
2433 |
+ udf_debug("volSetIdent[] = '%s'\n", outstr->u_name); |
2434 |
+ |
2435 |
+- brelse(bh); |
2436 |
+ ret = 0; |
2437 |
++out_bh: |
2438 |
++ brelse(bh); |
2439 |
+ out2: |
2440 |
+ kfree(outstr); |
2441 |
+ out1: |
2442 |
+@@ -947,7 +959,7 @@ static int udf_load_metadata_files(struct super_block *sb, int partition) |
2443 |
+ |
2444 |
+ if (mdata->s_mirror_fe == NULL) { |
2445 |
+ udf_err(sb, "Both metadata and mirror metadata inode efe can not found\n"); |
2446 |
+- goto error_exit; |
2447 |
++ return -EIO; |
2448 |
+ } |
2449 |
+ } |
2450 |
+ |
2451 |
+@@ -964,23 +976,18 @@ static int udf_load_metadata_files(struct super_block *sb, int partition) |
2452 |
+ addr.logicalBlockNum, addr.partitionReferenceNum); |
2453 |
+ |
2454 |
+ mdata->s_bitmap_fe = udf_iget(sb, &addr); |
2455 |
+- |
2456 |
+ if (mdata->s_bitmap_fe == NULL) { |
2457 |
+ if (sb->s_flags & MS_RDONLY) |
2458 |
+ udf_warn(sb, "bitmap inode efe not found but it's ok since the disc is mounted read-only\n"); |
2459 |
+ else { |
2460 |
+ udf_err(sb, "bitmap inode efe not found and attempted read-write mount\n"); |
2461 |
+- goto error_exit; |
2462 |
++ return -EIO; |
2463 |
+ } |
2464 |
+ } |
2465 |
+ } |
2466 |
+ |
2467 |
+ udf_debug("udf_load_metadata_files Ok\n"); |
2468 |
+- |
2469 |
+ return 0; |
2470 |
+- |
2471 |
+-error_exit: |
2472 |
+- return 1; |
2473 |
+ } |
2474 |
+ |
2475 |
+ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, |
2476 |
+@@ -1069,7 +1076,7 @@ static int udf_fill_partdesc_info(struct super_block *sb, |
2477 |
+ if (!map->s_uspace.s_table) { |
2478 |
+ udf_debug("cannot load unallocSpaceTable (part %d)\n", |
2479 |
+ p_index); |
2480 |
+- return 1; |
2481 |
++ return -EIO; |
2482 |
+ } |
2483 |
+ map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE; |
2484 |
+ udf_debug("unallocSpaceTable (part %d) @ %ld\n", |
2485 |
+@@ -1079,7 +1086,7 @@ static int udf_fill_partdesc_info(struct super_block *sb, |
2486 |
+ if (phd->unallocSpaceBitmap.extLength) { |
2487 |
+ struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, p_index); |
2488 |
+ if (!bitmap) |
2489 |
+- return 1; |
2490 |
++ return -ENOMEM; |
2491 |
+ map->s_uspace.s_bitmap = bitmap; |
2492 |
+ bitmap->s_extPosition = le32_to_cpu( |
2493 |
+ phd->unallocSpaceBitmap.extPosition); |
2494 |
+@@ -1102,7 +1109,7 @@ static int udf_fill_partdesc_info(struct super_block *sb, |
2495 |
+ if (!map->s_fspace.s_table) { |
2496 |
+ udf_debug("cannot load freedSpaceTable (part %d)\n", |
2497 |
+ p_index); |
2498 |
+- return 1; |
2499 |
++ return -EIO; |
2500 |
+ } |
2501 |
+ |
2502 |
+ map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE; |
2503 |
+@@ -1113,7 +1120,7 @@ static int udf_fill_partdesc_info(struct super_block *sb, |
2504 |
+ if (phd->freedSpaceBitmap.extLength) { |
2505 |
+ struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, p_index); |
2506 |
+ if (!bitmap) |
2507 |
+- return 1; |
2508 |
++ return -ENOMEM; |
2509 |
+ map->s_fspace.s_bitmap = bitmap; |
2510 |
+ bitmap->s_extPosition = le32_to_cpu( |
2511 |
+ phd->freedSpaceBitmap.extPosition); |
2512 |
+@@ -1165,7 +1172,7 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) |
2513 |
+ udf_find_vat_block(sb, p_index, type1_index, blocks - 1); |
2514 |
+ } |
2515 |
+ if (!sbi->s_vat_inode) |
2516 |
+- return 1; |
2517 |
++ return -EIO; |
2518 |
+ |
2519 |
+ if (map->s_partition_type == UDF_VIRTUAL_MAP15) { |
2520 |
+ map->s_type_specific.s_virtual.s_start_offset = 0; |
2521 |
+@@ -1177,7 +1184,7 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) |
2522 |
+ pos = udf_block_map(sbi->s_vat_inode, 0); |
2523 |
+ bh = sb_bread(sb, pos); |
2524 |
+ if (!bh) |
2525 |
+- return 1; |
2526 |
++ return -EIO; |
2527 |
+ vat20 = (struct virtualAllocationTable20 *)bh->b_data; |
2528 |
+ } else { |
2529 |
+ vat20 = (struct virtualAllocationTable20 *) |
2530 |
+@@ -1195,6 +1202,12 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) |
2531 |
+ return 0; |
2532 |
+ } |
2533 |
+ |
2534 |
++/* |
2535 |
++ * Load partition descriptor block |
2536 |
++ * |
2537 |
++ * Returns <0 on error, 0 on success, -EAGAIN is special - try next descriptor |
2538 |
++ * sequence. |
2539 |
++ */ |
2540 |
+ static int udf_load_partdesc(struct super_block *sb, sector_t block) |
2541 |
+ { |
2542 |
+ struct buffer_head *bh; |
2543 |
+@@ -1204,13 +1217,15 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block) |
2544 |
+ int i, type1_idx; |
2545 |
+ uint16_t partitionNumber; |
2546 |
+ uint16_t ident; |
2547 |
+- int ret = 0; |
2548 |
++ int ret; |
2549 |
+ |
2550 |
+ bh = udf_read_tagged(sb, block, block, &ident); |
2551 |
+ if (!bh) |
2552 |
+- return 1; |
2553 |
+- if (ident != TAG_IDENT_PD) |
2554 |
++ return -EAGAIN; |
2555 |
++ if (ident != TAG_IDENT_PD) { |
2556 |
++ ret = 0; |
2557 |
+ goto out_bh; |
2558 |
++ } |
2559 |
+ |
2560 |
+ p = (struct partitionDesc *)bh->b_data; |
2561 |
+ partitionNumber = le16_to_cpu(p->partitionNumber); |
2562 |
+@@ -1229,10 +1244,13 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block) |
2563 |
+ if (i >= sbi->s_partitions) { |
2564 |
+ udf_debug("Partition (%d) not found in partition map\n", |
2565 |
+ partitionNumber); |
2566 |
++ ret = 0; |
2567 |
+ goto out_bh; |
2568 |
+ } |
2569 |
+ |
2570 |
+ ret = udf_fill_partdesc_info(sb, p, i); |
2571 |
++ if (ret < 0) |
2572 |
++ goto out_bh; |
2573 |
+ |
2574 |
+ /* |
2575 |
+ * Now rescan for VIRTUAL or METADATA partitions when SPARABLE and |
2576 |
+@@ -1249,32 +1267,37 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block) |
2577 |
+ break; |
2578 |
+ } |
2579 |
+ |
2580 |
+- if (i >= sbi->s_partitions) |
2581 |
++ if (i >= sbi->s_partitions) { |
2582 |
++ ret = 0; |
2583 |
+ goto out_bh; |
2584 |
++ } |
2585 |
+ |
2586 |
+ ret = udf_fill_partdesc_info(sb, p, i); |
2587 |
+- if (ret) |
2588 |
++ if (ret < 0) |
2589 |
+ goto out_bh; |
2590 |
+ |
2591 |
+ if (map->s_partition_type == UDF_METADATA_MAP25) { |
2592 |
+ ret = udf_load_metadata_files(sb, i); |
2593 |
+- if (ret) { |
2594 |
++ if (ret < 0) { |
2595 |
+ udf_err(sb, "error loading MetaData partition map %d\n", |
2596 |
+ i); |
2597 |
+ goto out_bh; |
2598 |
+ } |
2599 |
+ } else { |
2600 |
+- ret = udf_load_vat(sb, i, type1_idx); |
2601 |
+- if (ret) |
2602 |
+- goto out_bh; |
2603 |
+ /* |
2604 |
+- * Mark filesystem read-only if we have a partition with |
2605 |
+- * virtual map since we don't handle writing to it (we |
2606 |
+- * overwrite blocks instead of relocating them). |
2607 |
++ * If we have a partition with virtual map, we don't handle |
2608 |
++ * writing to it (we overwrite blocks instead of relocating |
2609 |
++ * them). |
2610 |
+ */ |
2611 |
+- sb->s_flags |= MS_RDONLY; |
2612 |
+- pr_notice("Filesystem marked read-only because writing to pseudooverwrite partition is not implemented\n"); |
2613 |
++ if (!(sb->s_flags & MS_RDONLY)) { |
2614 |
++ ret = -EACCES; |
2615 |
++ goto out_bh; |
2616 |
++ } |
2617 |
++ ret = udf_load_vat(sb, i, type1_idx); |
2618 |
++ if (ret < 0) |
2619 |
++ goto out_bh; |
2620 |
+ } |
2621 |
++ ret = 0; |
2622 |
+ out_bh: |
2623 |
+ /* In case loading failed, we handle cleanup in udf_fill_super */ |
2624 |
+ brelse(bh); |
2625 |
+@@ -1340,11 +1363,11 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, |
2626 |
+ uint16_t ident; |
2627 |
+ struct buffer_head *bh; |
2628 |
+ unsigned int table_len; |
2629 |
+- int ret = 0; |
2630 |
++ int ret; |
2631 |
+ |
2632 |
+ bh = udf_read_tagged(sb, block, block, &ident); |
2633 |
+ if (!bh) |
2634 |
+- return 1; |
2635 |
++ return -EAGAIN; |
2636 |
+ BUG_ON(ident != TAG_IDENT_LVD); |
2637 |
+ lvd = (struct logicalVolDesc *)bh->b_data; |
2638 |
+ table_len = le32_to_cpu(lvd->mapTableLength); |
2639 |
+@@ -1352,7 +1375,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, |
2640 |
+ udf_err(sb, "error loading logical volume descriptor: " |
2641 |
+ "Partition table too long (%u > %lu)\n", table_len, |
2642 |
+ sb->s_blocksize - sizeof(*lvd)); |
2643 |
+- ret = 1; |
2644 |
++ ret = -EIO; |
2645 |
+ goto out_bh; |
2646 |
+ } |
2647 |
+ |
2648 |
+@@ -1396,11 +1419,10 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, |
2649 |
+ } else if (!strncmp(upm2->partIdent.ident, |
2650 |
+ UDF_ID_SPARABLE, |
2651 |
+ strlen(UDF_ID_SPARABLE))) { |
2652 |
+- if (udf_load_sparable_map(sb, map, |
2653 |
+- (struct sparablePartitionMap *)gpm) < 0) { |
2654 |
+- ret = 1; |
2655 |
++ ret = udf_load_sparable_map(sb, map, |
2656 |
++ (struct sparablePartitionMap *)gpm); |
2657 |
++ if (ret < 0) |
2658 |
+ goto out_bh; |
2659 |
+- } |
2660 |
+ } else if (!strncmp(upm2->partIdent.ident, |
2661 |
+ UDF_ID_METADATA, |
2662 |
+ strlen(UDF_ID_METADATA))) { |
2663 |
+@@ -1465,7 +1487,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, |
2664 |
+ } |
2665 |
+ if (lvd->integritySeqExt.extLength) |
2666 |
+ udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); |
2667 |
+- |
2668 |
++ ret = 0; |
2669 |
+ out_bh: |
2670 |
+ brelse(bh); |
2671 |
+ return ret; |
2672 |
+@@ -1503,22 +1525,18 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_ |
2673 |
+ } |
2674 |
+ |
2675 |
+ /* |
2676 |
+- * udf_process_sequence |
2677 |
+- * |
2678 |
+- * PURPOSE |
2679 |
+- * Process a main/reserve volume descriptor sequence. |
2680 |
+- * |
2681 |
+- * PRE-CONDITIONS |
2682 |
+- * sb Pointer to _locked_ superblock. |
2683 |
+- * block First block of first extent of the sequence. |
2684 |
+- * lastblock Lastblock of first extent of the sequence. |
2685 |
++ * Process a main/reserve volume descriptor sequence. |
2686 |
++ * @block First block of first extent of the sequence. |
2687 |
++ * @lastblock Lastblock of first extent of the sequence. |
2688 |
++ * @fileset There we store extent containing root fileset |
2689 |
+ * |
2690 |
+- * HISTORY |
2691 |
+- * July 1, 1997 - Andrew E. Mileski |
2692 |
+- * Written, tested, and released. |
2693 |
++ * Returns <0 on error, 0 on success. -EAGAIN is special - try next descriptor |
2694 |
++ * sequence |
2695 |
+ */ |
2696 |
+-static noinline int udf_process_sequence(struct super_block *sb, long block, |
2697 |
+- long lastblock, struct kernel_lb_addr *fileset) |
2698 |
++static noinline int udf_process_sequence( |
2699 |
++ struct super_block *sb, |
2700 |
++ sector_t block, sector_t lastblock, |
2701 |
++ struct kernel_lb_addr *fileset) |
2702 |
+ { |
2703 |
+ struct buffer_head *bh = NULL; |
2704 |
+ struct udf_vds_record vds[VDS_POS_LENGTH]; |
2705 |
+@@ -1529,6 +1547,7 @@ static noinline int udf_process_sequence(struct super_block *sb, long block, |
2706 |
+ uint32_t vdsn; |
2707 |
+ uint16_t ident; |
2708 |
+ long next_s = 0, next_e = 0; |
2709 |
++ int ret; |
2710 |
+ |
2711 |
+ memset(vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH); |
2712 |
+ |
2713 |
+@@ -1543,7 +1562,7 @@ static noinline int udf_process_sequence(struct super_block *sb, long block, |
2714 |
+ udf_err(sb, |
2715 |
+ "Block %llu of volume descriptor sequence is corrupted or we could not read it\n", |
2716 |
+ (unsigned long long)block); |
2717 |
+- return 1; |
2718 |
++ return -EAGAIN; |
2719 |
+ } |
2720 |
+ |
2721 |
+ /* Process each descriptor (ISO 13346 3/8.3-8.4) */ |
2722 |
+@@ -1616,14 +1635,19 @@ static noinline int udf_process_sequence(struct super_block *sb, long block, |
2723 |
+ */ |
2724 |
+ if (!vds[VDS_POS_PRIMARY_VOL_DESC].block) { |
2725 |
+ udf_err(sb, "Primary Volume Descriptor not found!\n"); |
2726 |
+- return 1; |
2727 |
++ return -EAGAIN; |
2728 |
++ } |
2729 |
++ ret = udf_load_pvoldesc(sb, vds[VDS_POS_PRIMARY_VOL_DESC].block); |
2730 |
++ if (ret < 0) |
2731 |
++ return ret; |
2732 |
++ |
2733 |
++ if (vds[VDS_POS_LOGICAL_VOL_DESC].block) { |
2734 |
++ ret = udf_load_logicalvol(sb, |
2735 |
++ vds[VDS_POS_LOGICAL_VOL_DESC].block, |
2736 |
++ fileset); |
2737 |
++ if (ret < 0) |
2738 |
++ return ret; |
2739 |
+ } |
2740 |
+- if (udf_load_pvoldesc(sb, vds[VDS_POS_PRIMARY_VOL_DESC].block)) |
2741 |
+- return 1; |
2742 |
+- |
2743 |
+- if (vds[VDS_POS_LOGICAL_VOL_DESC].block && udf_load_logicalvol(sb, |
2744 |
+- vds[VDS_POS_LOGICAL_VOL_DESC].block, fileset)) |
2745 |
+- return 1; |
2746 |
+ |
2747 |
+ if (vds[VDS_POS_PARTITION_DESC].block) { |
2748 |
+ /* |
2749 |
+@@ -1632,19 +1656,27 @@ static noinline int udf_process_sequence(struct super_block *sb, long block, |
2750 |
+ */ |
2751 |
+ for (block = vds[VDS_POS_PARTITION_DESC].block; |
2752 |
+ block < vds[VDS_POS_TERMINATING_DESC].block; |
2753 |
+- block++) |
2754 |
+- if (udf_load_partdesc(sb, block)) |
2755 |
+- return 1; |
2756 |
++ block++) { |
2757 |
++ ret = udf_load_partdesc(sb, block); |
2758 |
++ if (ret < 0) |
2759 |
++ return ret; |
2760 |
++ } |
2761 |
+ } |
2762 |
+ |
2763 |
+ return 0; |
2764 |
+ } |
2765 |
+ |
2766 |
++/* |
2767 |
++ * Load Volume Descriptor Sequence described by anchor in bh |
2768 |
++ * |
2769 |
++ * Returns <0 on error, 0 on success |
2770 |
++ */ |
2771 |
+ static int udf_load_sequence(struct super_block *sb, struct buffer_head *bh, |
2772 |
+ struct kernel_lb_addr *fileset) |
2773 |
+ { |
2774 |
+ struct anchorVolDescPtr *anchor; |
2775 |
+- long main_s, main_e, reserve_s, reserve_e; |
2776 |
++ sector_t main_s, main_e, reserve_s, reserve_e; |
2777 |
++ int ret; |
2778 |
+ |
2779 |
+ anchor = (struct anchorVolDescPtr *)bh->b_data; |
2780 |
+ |
2781 |
+@@ -1662,18 +1694,26 @@ static int udf_load_sequence(struct super_block *sb, struct buffer_head *bh, |
2782 |
+ |
2783 |
+ /* Process the main & reserve sequences */ |
2784 |
+ /* responsible for finding the PartitionDesc(s) */ |
2785 |
+- if (!udf_process_sequence(sb, main_s, main_e, fileset)) |
2786 |
+- return 1; |
2787 |
+- udf_sb_free_partitions(sb); |
2788 |
+- if (!udf_process_sequence(sb, reserve_s, reserve_e, fileset)) |
2789 |
+- return 1; |
2790 |
++ ret = udf_process_sequence(sb, main_s, main_e, fileset); |
2791 |
++ if (ret != -EAGAIN) |
2792 |
++ return ret; |
2793 |
+ udf_sb_free_partitions(sb); |
2794 |
+- return 0; |
2795 |
++ ret = udf_process_sequence(sb, reserve_s, reserve_e, fileset); |
2796 |
++ if (ret < 0) { |
2797 |
++ udf_sb_free_partitions(sb); |
2798 |
++ /* No sequence was OK, return -EIO */ |
2799 |
++ if (ret == -EAGAIN) |
2800 |
++ ret = -EIO; |
2801 |
++ } |
2802 |
++ return ret; |
2803 |
+ } |
2804 |
+ |
2805 |
+ /* |
2806 |
+ * Check whether there is an anchor block in the given block and |
2807 |
+ * load Volume Descriptor Sequence if so. |
2808 |
++ * |
2809 |
++ * Returns <0 on error, 0 on success, -EAGAIN is special - try next anchor |
2810 |
++ * block |
2811 |
+ */ |
2812 |
+ static int udf_check_anchor_block(struct super_block *sb, sector_t block, |
2813 |
+ struct kernel_lb_addr *fileset) |
2814 |
+@@ -1685,33 +1725,40 @@ static int udf_check_anchor_block(struct super_block *sb, sector_t block, |
2815 |
+ if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV) && |
2816 |
+ udf_fixed_to_variable(block) >= |
2817 |
+ sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits) |
2818 |
+- return 0; |
2819 |
++ return -EAGAIN; |
2820 |
+ |
2821 |
+ bh = udf_read_tagged(sb, block, block, &ident); |
2822 |
+ if (!bh) |
2823 |
+- return 0; |
2824 |
++ return -EAGAIN; |
2825 |
+ if (ident != TAG_IDENT_AVDP) { |
2826 |
+ brelse(bh); |
2827 |
+- return 0; |
2828 |
++ return -EAGAIN; |
2829 |
+ } |
2830 |
+ ret = udf_load_sequence(sb, bh, fileset); |
2831 |
+ brelse(bh); |
2832 |
+ return ret; |
2833 |
+ } |
2834 |
+ |
2835 |
+-/* Search for an anchor volume descriptor pointer */ |
2836 |
+-static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock, |
2837 |
+- struct kernel_lb_addr *fileset) |
2838 |
++/* |
2839 |
++ * Search for an anchor volume descriptor pointer. |
2840 |
++ * |
2841 |
++ * Returns < 0 on error, 0 on success. -EAGAIN is special - try next set |
2842 |
++ * of anchors. |
2843 |
++ */ |
2844 |
++static int udf_scan_anchors(struct super_block *sb, sector_t *lastblock, |
2845 |
++ struct kernel_lb_addr *fileset) |
2846 |
+ { |
2847 |
+ sector_t last[6]; |
2848 |
+ int i; |
2849 |
+ struct udf_sb_info *sbi = UDF_SB(sb); |
2850 |
+ int last_count = 0; |
2851 |
++ int ret; |
2852 |
+ |
2853 |
+ /* First try user provided anchor */ |
2854 |
+ if (sbi->s_anchor) { |
2855 |
+- if (udf_check_anchor_block(sb, sbi->s_anchor, fileset)) |
2856 |
+- return lastblock; |
2857 |
++ ret = udf_check_anchor_block(sb, sbi->s_anchor, fileset); |
2858 |
++ if (ret != -EAGAIN) |
2859 |
++ return ret; |
2860 |
+ } |
2861 |
+ /* |
2862 |
+ * according to spec, anchor is in either: |
2863 |
+@@ -1720,39 +1767,46 @@ static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock, |
2864 |
+ * lastblock |
2865 |
+ * however, if the disc isn't closed, it could be 512. |
2866 |
+ */ |
2867 |
+- if (udf_check_anchor_block(sb, sbi->s_session + 256, fileset)) |
2868 |
+- return lastblock; |
2869 |
++ ret = udf_check_anchor_block(sb, sbi->s_session + 256, fileset); |
2870 |
++ if (ret != -EAGAIN) |
2871 |
++ return ret; |
2872 |
+ /* |
2873 |
+ * The trouble is which block is the last one. Drives often misreport |
2874 |
+ * this so we try various possibilities. |
2875 |
+ */ |
2876 |
+- last[last_count++] = lastblock; |
2877 |
+- if (lastblock >= 1) |
2878 |
+- last[last_count++] = lastblock - 1; |
2879 |
+- last[last_count++] = lastblock + 1; |
2880 |
+- if (lastblock >= 2) |
2881 |
+- last[last_count++] = lastblock - 2; |
2882 |
+- if (lastblock >= 150) |
2883 |
+- last[last_count++] = lastblock - 150; |
2884 |
+- if (lastblock >= 152) |
2885 |
+- last[last_count++] = lastblock - 152; |
2886 |
++ last[last_count++] = *lastblock; |
2887 |
++ if (*lastblock >= 1) |
2888 |
++ last[last_count++] = *lastblock - 1; |
2889 |
++ last[last_count++] = *lastblock + 1; |
2890 |
++ if (*lastblock >= 2) |
2891 |
++ last[last_count++] = *lastblock - 2; |
2892 |
++ if (*lastblock >= 150) |
2893 |
++ last[last_count++] = *lastblock - 150; |
2894 |
++ if (*lastblock >= 152) |
2895 |
++ last[last_count++] = *lastblock - 152; |
2896 |
+ |
2897 |
+ for (i = 0; i < last_count; i++) { |
2898 |
+ if (last[i] >= sb->s_bdev->bd_inode->i_size >> |
2899 |
+ sb->s_blocksize_bits) |
2900 |
+ continue; |
2901 |
+- if (udf_check_anchor_block(sb, last[i], fileset)) |
2902 |
+- return last[i]; |
2903 |
++ ret = udf_check_anchor_block(sb, last[i], fileset); |
2904 |
++ if (ret != -EAGAIN) { |
2905 |
++ if (!ret) |
2906 |
++ *lastblock = last[i]; |
2907 |
++ return ret; |
2908 |
++ } |
2909 |
+ if (last[i] < 256) |
2910 |
+ continue; |
2911 |
+- if (udf_check_anchor_block(sb, last[i] - 256, fileset)) |
2912 |
+- return last[i]; |
2913 |
++ ret = udf_check_anchor_block(sb, last[i] - 256, fileset); |
2914 |
++ if (ret != -EAGAIN) { |
2915 |
++ if (!ret) |
2916 |
++ *lastblock = last[i]; |
2917 |
++ return ret; |
2918 |
++ } |
2919 |
+ } |
2920 |
+ |
2921 |
+ /* Finally try block 512 in case media is open */ |
2922 |
+- if (udf_check_anchor_block(sb, sbi->s_session + 512, fileset)) |
2923 |
+- return last[0]; |
2924 |
+- return 0; |
2925 |
++ return udf_check_anchor_block(sb, sbi->s_session + 512, fileset); |
2926 |
+ } |
2927 |
+ |
2928 |
+ /* |
2929 |
+@@ -1760,54 +1814,59 @@ static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock, |
2930 |
+ * area specified by it. The function expects sbi->s_lastblock to be the last |
2931 |
+ * block on the media. |
2932 |
+ * |
2933 |
+- * Return 1 if ok, 0 if not found. |
2934 |
+- * |
2935 |
++ * Return <0 on error, 0 if anchor found. -EAGAIN is special meaning anchor |
2936 |
++ * was not found. |
2937 |
+ */ |
2938 |
+ static int udf_find_anchor(struct super_block *sb, |
2939 |
+ struct kernel_lb_addr *fileset) |
2940 |
+ { |
2941 |
+- sector_t lastblock; |
2942 |
+ struct udf_sb_info *sbi = UDF_SB(sb); |
2943 |
++ sector_t lastblock = sbi->s_last_block; |
2944 |
++ int ret; |
2945 |
+ |
2946 |
+- lastblock = udf_scan_anchors(sb, sbi->s_last_block, fileset); |
2947 |
+- if (lastblock) |
2948 |
++ ret = udf_scan_anchors(sb, &lastblock, fileset); |
2949 |
++ if (ret != -EAGAIN) |
2950 |
+ goto out; |
2951 |
+ |
2952 |
+ /* No anchor found? Try VARCONV conversion of block numbers */ |
2953 |
+ UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); |
2954 |
++ lastblock = udf_variable_to_fixed(sbi->s_last_block); |
2955 |
+ /* Firstly, we try to not convert number of the last block */ |
2956 |
+- lastblock = udf_scan_anchors(sb, |
2957 |
+- udf_variable_to_fixed(sbi->s_last_block), |
2958 |
+- fileset); |
2959 |
+- if (lastblock) |
2960 |
++ ret = udf_scan_anchors(sb, &lastblock, fileset); |
2961 |
++ if (ret != -EAGAIN) |
2962 |
+ goto out; |
2963 |
+ |
2964 |
++ lastblock = sbi->s_last_block; |
2965 |
+ /* Secondly, we try with converted number of the last block */ |
2966 |
+- lastblock = udf_scan_anchors(sb, sbi->s_last_block, fileset); |
2967 |
+- if (!lastblock) { |
2968 |
++ ret = udf_scan_anchors(sb, &lastblock, fileset); |
2969 |
++ if (ret < 0) { |
2970 |
+ /* VARCONV didn't help. Clear it. */ |
2971 |
+ UDF_CLEAR_FLAG(sb, UDF_FLAG_VARCONV); |
2972 |
+- return 0; |
2973 |
+ } |
2974 |
+ out: |
2975 |
+- sbi->s_last_block = lastblock; |
2976 |
+- return 1; |
2977 |
++ if (ret == 0) |
2978 |
++ sbi->s_last_block = lastblock; |
2979 |
++ return ret; |
2980 |
+ } |
2981 |
+ |
2982 |
+ /* |
2983 |
+ * Check Volume Structure Descriptor, find Anchor block and load Volume |
2984 |
+- * Descriptor Sequence |
2985 |
++ * Descriptor Sequence. |
2986 |
++ * |
2987 |
++ * Returns < 0 on error, 0 on success. -EAGAIN is special meaning anchor |
2988 |
++ * block was not found. |
2989 |
+ */ |
2990 |
+ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt, |
2991 |
+ int silent, struct kernel_lb_addr *fileset) |
2992 |
+ { |
2993 |
+ struct udf_sb_info *sbi = UDF_SB(sb); |
2994 |
+ loff_t nsr_off; |
2995 |
++ int ret; |
2996 |
+ |
2997 |
+ if (!sb_set_blocksize(sb, uopt->blocksize)) { |
2998 |
+ if (!silent) |
2999 |
+ udf_warn(sb, "Bad block size\n"); |
3000 |
+- return 0; |
3001 |
++ return -EINVAL; |
3002 |
+ } |
3003 |
+ sbi->s_last_block = uopt->lastblock; |
3004 |
+ if (!uopt->novrs) { |
3005 |
+@@ -1828,12 +1887,13 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt, |
3006 |
+ |
3007 |
+ /* Look for anchor block and load Volume Descriptor Sequence */ |
3008 |
+ sbi->s_anchor = uopt->anchor; |
3009 |
+- if (!udf_find_anchor(sb, fileset)) { |
3010 |
+- if (!silent) |
3011 |
++ ret = udf_find_anchor(sb, fileset); |
3012 |
++ if (ret < 0) { |
3013 |
++ if (!silent && ret == -EAGAIN) |
3014 |
+ udf_warn(sb, "No anchor found\n"); |
3015 |
+- return 0; |
3016 |
++ return ret; |
3017 |
+ } |
3018 |
+- return 1; |
3019 |
++ return 0; |
3020 |
+ } |
3021 |
+ |
3022 |
+ static void udf_open_lvid(struct super_block *sb) |
3023 |
+@@ -1939,7 +1999,7 @@ u64 lvid_get_unique_id(struct super_block *sb) |
3024 |
+ |
3025 |
+ static int udf_fill_super(struct super_block *sb, void *options, int silent) |
3026 |
+ { |
3027 |
+- int ret; |
3028 |
++ int ret = -EINVAL; |
3029 |
+ struct inode *inode = NULL; |
3030 |
+ struct udf_options uopt; |
3031 |
+ struct kernel_lb_addr rootdir, fileset; |
3032 |
+@@ -2011,7 +2071,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) |
3033 |
+ } else { |
3034 |
+ uopt.blocksize = bdev_logical_block_size(sb->s_bdev); |
3035 |
+ ret = udf_load_vrs(sb, &uopt, silent, &fileset); |
3036 |
+- if (!ret && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) { |
3037 |
++ if (ret == -EAGAIN && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) { |
3038 |
+ if (!silent) |
3039 |
+ pr_notice("Rescanning with blocksize %d\n", |
3040 |
+ UDF_DEFAULT_BLOCKSIZE); |
3041 |
+@@ -2021,8 +2081,11 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) |
3042 |
+ ret = udf_load_vrs(sb, &uopt, silent, &fileset); |
3043 |
+ } |
3044 |
+ } |
3045 |
+- if (!ret) { |
3046 |
+- udf_warn(sb, "No partition found (1)\n"); |
3047 |
++ if (ret < 0) { |
3048 |
++ if (ret == -EAGAIN) { |
3049 |
++ udf_warn(sb, "No partition found (1)\n"); |
3050 |
++ ret = -EINVAL; |
3051 |
++ } |
3052 |
+ goto error_out; |
3053 |
+ } |
3054 |
+ |
3055 |
+@@ -2040,9 +2103,13 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) |
3056 |
+ udf_err(sb, "minUDFReadRev=%x (max is %x)\n", |
3057 |
+ le16_to_cpu(lvidiu->minUDFReadRev), |
3058 |
+ UDF_MAX_READ_VERSION); |
3059 |
++ ret = -EINVAL; |
3060 |
++ goto error_out; |
3061 |
++ } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION && |
3062 |
++ !(sb->s_flags & MS_RDONLY)) { |
3063 |
++ ret = -EACCES; |
3064 |
+ goto error_out; |
3065 |
+- } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) |
3066 |
+- sb->s_flags |= MS_RDONLY; |
3067 |
++ } |
3068 |
+ |
3069 |
+ sbi->s_udfrev = minUDFWriteRev; |
3070 |
+ |
3071 |
+@@ -2054,17 +2121,20 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) |
3072 |
+ |
3073 |
+ if (!sbi->s_partitions) { |
3074 |
+ udf_warn(sb, "No partition found (2)\n"); |
3075 |
++ ret = -EINVAL; |
3076 |
+ goto error_out; |
3077 |
+ } |
3078 |
+ |
3079 |
+ if (sbi->s_partmaps[sbi->s_partition].s_partition_flags & |
3080 |
+- UDF_PART_FLAG_READ_ONLY) { |
3081 |
+- pr_notice("Partition marked readonly; forcing readonly mount\n"); |
3082 |
+- sb->s_flags |= MS_RDONLY; |
3083 |
++ UDF_PART_FLAG_READ_ONLY && |
3084 |
++ !(sb->s_flags & MS_RDONLY)) { |
3085 |
++ ret = -EACCES; |
3086 |
++ goto error_out; |
3087 |
+ } |
3088 |
+ |
3089 |
+ if (udf_find_fileset(sb, &fileset, &rootdir)) { |
3090 |
+ udf_warn(sb, "No fileset found\n"); |
3091 |
++ ret = -EINVAL; |
3092 |
+ goto error_out; |
3093 |
+ } |
3094 |
+ |
3095 |
+@@ -2086,6 +2156,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) |
3096 |
+ if (!inode) { |
3097 |
+ udf_err(sb, "Error in udf_iget, block=%d, partition=%d\n", |
3098 |
+ rootdir.logicalBlockNum, rootdir.partitionReferenceNum); |
3099 |
++ ret = -EIO; |
3100 |
+ goto error_out; |
3101 |
+ } |
3102 |
+ |
3103 |
+@@ -2093,6 +2164,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) |
3104 |
+ sb->s_root = d_make_root(inode); |
3105 |
+ if (!sb->s_root) { |
3106 |
+ udf_err(sb, "Couldn't allocate root dentry\n"); |
3107 |
++ ret = -ENOMEM; |
3108 |
+ goto error_out; |
3109 |
+ } |
3110 |
+ sb->s_maxbytes = MAX_LFS_FILESIZE; |
3111 |
+@@ -2113,7 +2185,7 @@ error_out: |
3112 |
+ kfree(sbi); |
3113 |
+ sb->s_fs_info = NULL; |
3114 |
+ |
3115 |
+- return -EINVAL; |
3116 |
++ return ret; |
3117 |
+ } |
3118 |
+ |
3119 |
+ void _udf_err(struct super_block *sb, const char *function, |
3120 |
+diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h |
3121 |
+index 34efaf6..961013a 100644 |
3122 |
+--- a/include/drm/drm_pciids.h |
3123 |
++++ b/include/drm/drm_pciids.h |
3124 |
+@@ -1,4 +1,25 @@ |
3125 |
+ #define radeon_PCI_IDS \ |
3126 |
++ {0x1002, 0x1304, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3127 |
++ {0x1002, 0x1305, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3128 |
++ {0x1002, 0x1306, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3129 |
++ {0x1002, 0x1307, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3130 |
++ {0x1002, 0x1309, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3131 |
++ {0x1002, 0x130A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3132 |
++ {0x1002, 0x130B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3133 |
++ {0x1002, 0x130C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3134 |
++ {0x1002, 0x130D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3135 |
++ {0x1002, 0x130E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3136 |
++ {0x1002, 0x130F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3137 |
++ {0x1002, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3138 |
++ {0x1002, 0x1311, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3139 |
++ {0x1002, 0x1312, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3140 |
++ {0x1002, 0x1313, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3141 |
++ {0x1002, 0x1315, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3142 |
++ {0x1002, 0x1316, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3143 |
++ {0x1002, 0x1317, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3144 |
++ {0x1002, 0x131B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3145 |
++ {0x1002, 0x131C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3146 |
++ {0x1002, 0x131D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ |
3147 |
+ {0x1002, 0x3150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ |
3148 |
+ {0x1002, 0x3151, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
3149 |
+ {0x1002, 0x3152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
3150 |
+diff --git a/include/linux/hid.h b/include/linux/hid.h |
3151 |
+index ff545cc..6e18550 100644 |
3152 |
+--- a/include/linux/hid.h |
3153 |
++++ b/include/linux/hid.h |
3154 |
+@@ -749,6 +749,10 @@ void hid_output_report(struct hid_report *report, __u8 *data); |
3155 |
+ struct hid_device *hid_allocate_device(void); |
3156 |
+ struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id); |
3157 |
+ int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size); |
3158 |
++struct hid_report *hid_validate_values(struct hid_device *hid, |
3159 |
++ unsigned int type, unsigned int id, |
3160 |
++ unsigned int field_index, |
3161 |
++ unsigned int report_counts); |
3162 |
+ int hid_open_report(struct hid_device *device); |
3163 |
+ int hid_check_keys_pressed(struct hid_device *hid); |
3164 |
+ int hid_connect(struct hid_device *hid, unsigned int connect_mask); |
3165 |
+diff --git a/include/linux/timex.h b/include/linux/timex.h |
3166 |
+index b3726e6..dd3edd7 100644 |
3167 |
+--- a/include/linux/timex.h |
3168 |
++++ b/include/linux/timex.h |
3169 |
+@@ -141,6 +141,7 @@ extern int do_adjtimex(struct timex *); |
3170 |
+ extern void hardpps(const struct timespec *, const struct timespec *); |
3171 |
+ |
3172 |
+ int read_current_timer(unsigned long *timer_val); |
3173 |
++void ntp_notify_cmos_timer(void); |
3174 |
+ |
3175 |
+ /* The clock frequency of the i8253/i8254 PIT */ |
3176 |
+ #define PIT_TICK_RATE 1193182ul |
3177 |
+diff --git a/include/uapi/drm/radeon_drm.h b/include/uapi/drm/radeon_drm.h |
3178 |
+index 321d4ac..fa8b3ad 100644 |
3179 |
+--- a/include/uapi/drm/radeon_drm.h |
3180 |
++++ b/include/uapi/drm/radeon_drm.h |
3181 |
+@@ -979,6 +979,8 @@ struct drm_radeon_cs { |
3182 |
+ #define RADEON_INFO_RING_WORKING 0x15 |
3183 |
+ /* SI tile mode array */ |
3184 |
+ #define RADEON_INFO_SI_TILE_MODE_ARRAY 0x16 |
3185 |
++/* query if CP DMA is supported on the compute ring */ |
3186 |
++#define RADEON_INFO_SI_CP_DMA_COMPUTE 0x17 |
3187 |
+ |
3188 |
+ |
3189 |
+ struct drm_radeon_info { |
3190 |
+diff --git a/kernel/audit.c b/kernel/audit.c |
3191 |
+index 91e53d0..7b0e23a 100644 |
3192 |
+--- a/kernel/audit.c |
3193 |
++++ b/kernel/audit.c |
3194 |
+@@ -1117,9 +1117,10 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, |
3195 |
+ |
3196 |
+ sleep_time = timeout_start + audit_backlog_wait_time - |
3197 |
+ jiffies; |
3198 |
+- if ((long)sleep_time > 0) |
3199 |
++ if ((long)sleep_time > 0) { |
3200 |
+ wait_for_auditd(sleep_time); |
3201 |
+- continue; |
3202 |
++ continue; |
3203 |
++ } |
3204 |
+ } |
3205 |
+ if (audit_rate_check() && printk_ratelimit()) |
3206 |
+ printk(KERN_WARNING |
3207 |
+diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c |
3208 |
+index a7959e0..25cc35d 100644 |
3209 |
+--- a/kernel/sched/cputime.c |
3210 |
++++ b/kernel/sched/cputime.c |
3211 |
+@@ -557,7 +557,7 @@ static void cputime_adjust(struct task_cputime *curr, |
3212 |
+ struct cputime *prev, |
3213 |
+ cputime_t *ut, cputime_t *st) |
3214 |
+ { |
3215 |
+- cputime_t rtime, stime, utime, total; |
3216 |
++ cputime_t rtime, stime, utime; |
3217 |
+ |
3218 |
+ if (vtime_accounting_enabled()) { |
3219 |
+ *ut = curr->utime; |
3220 |
+@@ -565,9 +565,6 @@ static void cputime_adjust(struct task_cputime *curr, |
3221 |
+ return; |
3222 |
+ } |
3223 |
+ |
3224 |
+- stime = curr->stime; |
3225 |
+- total = stime + curr->utime; |
3226 |
+- |
3227 |
+ /* |
3228 |
+ * Tick based cputime accounting depend on random scheduling |
3229 |
+ * timeslices of a task to be interrupted or not by the timer. |
3230 |
+@@ -588,13 +585,19 @@ static void cputime_adjust(struct task_cputime *curr, |
3231 |
+ if (prev->stime + prev->utime >= rtime) |
3232 |
+ goto out; |
3233 |
+ |
3234 |
+- if (total) { |
3235 |
++ stime = curr->stime; |
3236 |
++ utime = curr->utime; |
3237 |
++ |
3238 |
++ if (utime == 0) { |
3239 |
++ stime = rtime; |
3240 |
++ } else if (stime == 0) { |
3241 |
++ utime = rtime; |
3242 |
++ } else { |
3243 |
++ cputime_t total = stime + utime; |
3244 |
++ |
3245 |
+ stime = scale_stime((__force u64)stime, |
3246 |
+ (__force u64)rtime, (__force u64)total); |
3247 |
+ utime = rtime - stime; |
3248 |
+- } else { |
3249 |
+- stime = rtime; |
3250 |
+- utime = 0; |
3251 |
+ } |
3252 |
+ |
3253 |
+ /* |
3254 |
+diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c |
3255 |
+index 68f1609..31cbc15 100644 |
3256 |
+--- a/kernel/sched/fair.c |
3257 |
++++ b/kernel/sched/fair.c |
3258 |
+@@ -5818,11 +5818,15 @@ static void task_fork_fair(struct task_struct *p) |
3259 |
+ cfs_rq = task_cfs_rq(current); |
3260 |
+ curr = cfs_rq->curr; |
3261 |
+ |
3262 |
+- if (unlikely(task_cpu(p) != this_cpu)) { |
3263 |
+- rcu_read_lock(); |
3264 |
+- __set_task_cpu(p, this_cpu); |
3265 |
+- rcu_read_unlock(); |
3266 |
+- } |
3267 |
++ /* |
3268 |
++ * Not only the cpu but also the task_group of the parent might have |
3269 |
++ * been changed after parent->se.parent,cfs_rq were copied to |
3270 |
++ * child->se.parent,cfs_rq. So call __set_task_cpu() to make those |
3271 |
++ * of child point to valid ones. |
3272 |
++ */ |
3273 |
++ rcu_read_lock(); |
3274 |
++ __set_task_cpu(p, this_cpu); |
3275 |
++ rcu_read_unlock(); |
3276 |
+ |
3277 |
+ update_curr(cfs_rq); |
3278 |
+ |
3279 |
+diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c |
3280 |
+index 8f5b3b9..bb22151 100644 |
3281 |
+--- a/kernel/time/ntp.c |
3282 |
++++ b/kernel/time/ntp.c |
3283 |
+@@ -516,13 +516,13 @@ static void sync_cmos_clock(struct work_struct *work) |
3284 |
+ schedule_delayed_work(&sync_cmos_work, timespec_to_jiffies(&next)); |
3285 |
+ } |
3286 |
+ |
3287 |
+-static void notify_cmos_timer(void) |
3288 |
++void ntp_notify_cmos_timer(void) |
3289 |
+ { |
3290 |
+ schedule_delayed_work(&sync_cmos_work, 0); |
3291 |
+ } |
3292 |
+ |
3293 |
+ #else |
3294 |
+-static inline void notify_cmos_timer(void) { } |
3295 |
++void ntp_notify_cmos_timer(void) { } |
3296 |
+ #endif |
3297 |
+ |
3298 |
+ |
3299 |
+@@ -687,8 +687,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai) |
3300 |
+ if (!(time_status & STA_NANO)) |
3301 |
+ txc->time.tv_usec /= NSEC_PER_USEC; |
3302 |
+ |
3303 |
+- notify_cmos_timer(); |
3304 |
+- |
3305 |
+ return result; |
3306 |
+ } |
3307 |
+ |
3308 |
+diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c |
3309 |
+index 48b9fff..947ba25 100644 |
3310 |
+--- a/kernel/time/timekeeping.c |
3311 |
++++ b/kernel/time/timekeeping.c |
3312 |
+@@ -1703,6 +1703,8 @@ int do_adjtimex(struct timex *txc) |
3313 |
+ write_seqcount_end(&timekeeper_seq); |
3314 |
+ raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
3315 |
+ |
3316 |
++ ntp_notify_cmos_timer(); |
3317 |
++ |
3318 |
+ return ret; |
3319 |
+ } |
3320 |
+ |
3321 |
+diff --git a/mm/swap.c b/mm/swap.c |
3322 |
+index 62b78a6..c899502 100644 |
3323 |
+--- a/mm/swap.c |
3324 |
++++ b/mm/swap.c |
3325 |
+@@ -31,6 +31,7 @@ |
3326 |
+ #include <linux/memcontrol.h> |
3327 |
+ #include <linux/gfp.h> |
3328 |
+ #include <linux/uio.h> |
3329 |
++#include <linux/hugetlb.h> |
3330 |
+ |
3331 |
+ #include "internal.h" |
3332 |
+ |
3333 |
+@@ -81,6 +82,19 @@ static void __put_compound_page(struct page *page) |
3334 |
+ |
3335 |
+ static void put_compound_page(struct page *page) |
3336 |
+ { |
3337 |
++ /* |
3338 |
++ * hugetlbfs pages cannot be split from under us. If this is a |
3339 |
++ * hugetlbfs page, check refcount on head page and release the page if |
3340 |
++ * the refcount becomes zero. |
3341 |
++ */ |
3342 |
++ if (PageHuge(page)) { |
3343 |
++ page = compound_head(page); |
3344 |
++ if (put_page_testzero(page)) |
3345 |
++ __put_compound_page(page); |
3346 |
++ |
3347 |
++ return; |
3348 |
++ } |
3349 |
++ |
3350 |
+ if (unlikely(PageTail(page))) { |
3351 |
+ /* __split_huge_page_refcount can run under us */ |
3352 |
+ struct page *page_head = compound_trans_head(page); |
3353 |
+@@ -184,38 +198,51 @@ bool __get_page_tail(struct page *page) |
3354 |
+ * proper PT lock that already serializes against |
3355 |
+ * split_huge_page(). |
3356 |
+ */ |
3357 |
+- unsigned long flags; |
3358 |
+ bool got = false; |
3359 |
+- struct page *page_head = compound_trans_head(page); |
3360 |
++ struct page *page_head; |
3361 |
+ |
3362 |
+- if (likely(page != page_head && get_page_unless_zero(page_head))) { |
3363 |
++ /* |
3364 |
++ * If this is a hugetlbfs page it cannot be split under us. Simply |
3365 |
++ * increment refcount for the head page. |
3366 |
++ */ |
3367 |
++ if (PageHuge(page)) { |
3368 |
++ page_head = compound_head(page); |
3369 |
++ atomic_inc(&page_head->_count); |
3370 |
++ got = true; |
3371 |
++ } else { |
3372 |
++ unsigned long flags; |
3373 |
++ |
3374 |
++ page_head = compound_trans_head(page); |
3375 |
++ if (likely(page != page_head && |
3376 |
++ get_page_unless_zero(page_head))) { |
3377 |
++ |
3378 |
++ /* Ref to put_compound_page() comment. */ |
3379 |
++ if (PageSlab(page_head)) { |
3380 |
++ if (likely(PageTail(page))) { |
3381 |
++ __get_page_tail_foll(page, false); |
3382 |
++ return true; |
3383 |
++ } else { |
3384 |
++ put_page(page_head); |
3385 |
++ return false; |
3386 |
++ } |
3387 |
++ } |
3388 |
+ |
3389 |
+- /* Ref to put_compound_page() comment. */ |
3390 |
+- if (PageSlab(page_head)) { |
3391 |
++ /* |
3392 |
++ * page_head wasn't a dangling pointer but it |
3393 |
++ * may not be a head page anymore by the time |
3394 |
++ * we obtain the lock. That is ok as long as it |
3395 |
++ * can't be freed from under us. |
3396 |
++ */ |
3397 |
++ flags = compound_lock_irqsave(page_head); |
3398 |
++ /* here __split_huge_page_refcount won't run anymore */ |
3399 |
+ if (likely(PageTail(page))) { |
3400 |
+ __get_page_tail_foll(page, false); |
3401 |
+- return true; |
3402 |
+- } else { |
3403 |
+- put_page(page_head); |
3404 |
+- return false; |
3405 |
++ got = true; |
3406 |
+ } |
3407 |
++ compound_unlock_irqrestore(page_head, flags); |
3408 |
++ if (unlikely(!got)) |
3409 |
++ put_page(page_head); |
3410 |
+ } |
3411 |
+- |
3412 |
+- /* |
3413 |
+- * page_head wasn't a dangling pointer but it |
3414 |
+- * may not be a head page anymore by the time |
3415 |
+- * we obtain the lock. That is ok as long as it |
3416 |
+- * can't be freed from under us. |
3417 |
+- */ |
3418 |
+- flags = compound_lock_irqsave(page_head); |
3419 |
+- /* here __split_huge_page_refcount won't run anymore */ |
3420 |
+- if (likely(PageTail(page))) { |
3421 |
+- __get_page_tail_foll(page, false); |
3422 |
+- got = true; |
3423 |
+- } |
3424 |
+- compound_unlock_irqrestore(page_head, flags); |
3425 |
+- if (unlikely(!got)) |
3426 |
+- put_page(page_head); |
3427 |
+ } |
3428 |
+ return got; |
3429 |
+ } |
3430 |
+diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h |
3431 |
+index 57beb17..707bc52 100644 |
3432 |
+--- a/net/netfilter/ipset/ip_set_hash_gen.h |
3433 |
++++ b/net/netfilter/ipset/ip_set_hash_gen.h |
3434 |
+@@ -325,18 +325,22 @@ mtype_add_cidr(struct htype *h, u8 cidr, u8 nets_length) |
3435 |
+ static void |
3436 |
+ mtype_del_cidr(struct htype *h, u8 cidr, u8 nets_length) |
3437 |
+ { |
3438 |
+- u8 i, j; |
3439 |
+- |
3440 |
+- for (i = 0; i < nets_length - 1 && h->nets[i].cidr != cidr; i++) |
3441 |
+- ; |
3442 |
+- h->nets[i].nets--; |
3443 |
+- |
3444 |
+- if (h->nets[i].nets != 0) |
3445 |
+- return; |
3446 |
+- |
3447 |
+- for (j = i; j < nets_length - 1 && h->nets[j].nets; j++) { |
3448 |
+- h->nets[j].cidr = h->nets[j + 1].cidr; |
3449 |
+- h->nets[j].nets = h->nets[j + 1].nets; |
3450 |
++ u8 i, j, net_end = nets_length - 1; |
3451 |
++ |
3452 |
++ for (i = 0; i < nets_length; i++) { |
3453 |
++ if (h->nets[i].cidr != cidr) |
3454 |
++ continue; |
3455 |
++ if (h->nets[i].nets > 1 || i == net_end || |
3456 |
++ h->nets[i + 1].nets == 0) { |
3457 |
++ h->nets[i].nets--; |
3458 |
++ return; |
3459 |
++ } |
3460 |
++ for (j = i; j < net_end && h->nets[j].nets; j++) { |
3461 |
++ h->nets[j].cidr = h->nets[j + 1].cidr; |
3462 |
++ h->nets[j].nets = h->nets[j + 1].nets; |
3463 |
++ } |
3464 |
++ h->nets[j].nets = 0; |
3465 |
++ return; |
3466 |
+ } |
3467 |
+ } |
3468 |
+ #endif |
3469 |
+diff --git a/net/sunrpc/auth_gss/gss_rpc_upcall.c b/net/sunrpc/auth_gss/gss_rpc_upcall.c |
3470 |
+index af7ffd4..f1eb0d1 100644 |
3471 |
+--- a/net/sunrpc/auth_gss/gss_rpc_upcall.c |
3472 |
++++ b/net/sunrpc/auth_gss/gss_rpc_upcall.c |
3473 |
+@@ -213,6 +213,26 @@ static int gssp_call(struct net *net, struct rpc_message *msg) |
3474 |
+ return status; |
3475 |
+ } |
3476 |
+ |
3477 |
++static void gssp_free_receive_pages(struct gssx_arg_accept_sec_context *arg) |
3478 |
++{ |
3479 |
++ int i; |
3480 |
++ |
3481 |
++ for (i = 0; i < arg->npages && arg->pages[i]; i++) |
3482 |
++ __free_page(arg->pages[i]); |
3483 |
++} |
3484 |
++ |
3485 |
++static int gssp_alloc_receive_pages(struct gssx_arg_accept_sec_context *arg) |
3486 |
++{ |
3487 |
++ arg->npages = DIV_ROUND_UP(NGROUPS_MAX * 4, PAGE_SIZE); |
3488 |
++ arg->pages = kzalloc(arg->npages * sizeof(struct page *), GFP_KERNEL); |
3489 |
++ /* |
3490 |
++ * XXX: actual pages are allocated by xdr layer in |
3491 |
++ * xdr_partial_copy_from_skb. |
3492 |
++ */ |
3493 |
++ if (!arg->pages) |
3494 |
++ return -ENOMEM; |
3495 |
++ return 0; |
3496 |
++} |
3497 |
+ |
3498 |
+ /* |
3499 |
+ * Public functions |
3500 |
+@@ -261,10 +281,16 @@ int gssp_accept_sec_context_upcall(struct net *net, |
3501 |
+ arg.context_handle = &ctxh; |
3502 |
+ res.output_token->len = GSSX_max_output_token_sz; |
3503 |
+ |
3504 |
++ ret = gssp_alloc_receive_pages(&arg); |
3505 |
++ if (ret) |
3506 |
++ return ret; |
3507 |
++ |
3508 |
+ /* use nfs/ for targ_name ? */ |
3509 |
+ |
3510 |
+ ret = gssp_call(net, &msg); |
3511 |
+ |
3512 |
++ gssp_free_receive_pages(&arg); |
3513 |
++ |
3514 |
+ /* we need to fetch all data even in case of error so |
3515 |
+ * that we can free special strctures is they have been allocated */ |
3516 |
+ data->major_status = res.status.major_status; |
3517 |
+diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c |
3518 |
+index 3c85d1c..f0f78c5 100644 |
3519 |
+--- a/net/sunrpc/auth_gss/gss_rpc_xdr.c |
3520 |
++++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c |
3521 |
+@@ -166,14 +166,15 @@ static int dummy_dec_opt_array(struct xdr_stream *xdr, |
3522 |
+ return 0; |
3523 |
+ } |
3524 |
+ |
3525 |
+-static int get_s32(void **p, void *max, s32 *res) |
3526 |
++static int get_host_u32(struct xdr_stream *xdr, u32 *res) |
3527 |
+ { |
3528 |
+- void *base = *p; |
3529 |
+- void *next = (void *)((char *)base + sizeof(s32)); |
3530 |
+- if (unlikely(next > max || next < base)) |
3531 |
++ __be32 *p; |
3532 |
++ |
3533 |
++ p = xdr_inline_decode(xdr, 4); |
3534 |
++ if (!p) |
3535 |
+ return -EINVAL; |
3536 |
+- memcpy(res, base, sizeof(s32)); |
3537 |
+- *p = next; |
3538 |
++ /* Contents of linux creds are all host-endian: */ |
3539 |
++ memcpy(res, p, sizeof(u32)); |
3540 |
+ return 0; |
3541 |
+ } |
3542 |
+ |
3543 |
+@@ -182,9 +183,9 @@ static int gssx_dec_linux_creds(struct xdr_stream *xdr, |
3544 |
+ { |
3545 |
+ u32 length; |
3546 |
+ __be32 *p; |
3547 |
+- void *q, *end; |
3548 |
+- s32 tmp; |
3549 |
+- int N, i, err; |
3550 |
++ u32 tmp; |
3551 |
++ u32 N; |
3552 |
++ int i, err; |
3553 |
+ |
3554 |
+ p = xdr_inline_decode(xdr, 4); |
3555 |
+ if (unlikely(p == NULL)) |
3556 |
+@@ -192,33 +193,28 @@ static int gssx_dec_linux_creds(struct xdr_stream *xdr, |
3557 |
+ |
3558 |
+ length = be32_to_cpup(p); |
3559 |
+ |
3560 |
+- /* FIXME: we do not want to use the scratch buffer for this one |
3561 |
+- * may need to use functions that allows us to access an io vector |
3562 |
+- * directly */ |
3563 |
+- p = xdr_inline_decode(xdr, length); |
3564 |
+- if (unlikely(p == NULL)) |
3565 |
++ if (length > (3 + NGROUPS_MAX) * sizeof(u32)) |
3566 |
+ return -ENOSPC; |
3567 |
+ |
3568 |
+- q = p; |
3569 |
+- end = q + length; |
3570 |
+- |
3571 |
+ /* uid */ |
3572 |
+- err = get_s32(&q, end, &tmp); |
3573 |
++ err = get_host_u32(xdr, &tmp); |
3574 |
+ if (err) |
3575 |
+ return err; |
3576 |
+ creds->cr_uid = make_kuid(&init_user_ns, tmp); |
3577 |
+ |
3578 |
+ /* gid */ |
3579 |
+- err = get_s32(&q, end, &tmp); |
3580 |
++ err = get_host_u32(xdr, &tmp); |
3581 |
+ if (err) |
3582 |
+ return err; |
3583 |
+ creds->cr_gid = make_kgid(&init_user_ns, tmp); |
3584 |
+ |
3585 |
+ /* number of additional gid's */ |
3586 |
+- err = get_s32(&q, end, &tmp); |
3587 |
++ err = get_host_u32(xdr, &tmp); |
3588 |
+ if (err) |
3589 |
+ return err; |
3590 |
+ N = tmp; |
3591 |
++ if ((3 + N) * sizeof(u32) != length) |
3592 |
++ return -EINVAL; |
3593 |
+ creds->cr_group_info = groups_alloc(N); |
3594 |
+ if (creds->cr_group_info == NULL) |
3595 |
+ return -ENOMEM; |
3596 |
+@@ -226,7 +222,7 @@ static int gssx_dec_linux_creds(struct xdr_stream *xdr, |
3597 |
+ /* gid's */ |
3598 |
+ for (i = 0; i < N; i++) { |
3599 |
+ kgid_t kgid; |
3600 |
+- err = get_s32(&q, end, &tmp); |
3601 |
++ err = get_host_u32(xdr, &tmp); |
3602 |
+ if (err) |
3603 |
+ goto out_free_groups; |
3604 |
+ err = -EINVAL; |
3605 |
+@@ -784,6 +780,9 @@ void gssx_enc_accept_sec_context(struct rpc_rqst *req, |
3606 |
+ /* arg->options */ |
3607 |
+ err = dummy_enc_opt_array(xdr, &arg->options); |
3608 |
+ |
3609 |
++ xdr_inline_pages(&req->rq_rcv_buf, |
3610 |
++ PAGE_SIZE/2 /* pretty arbitrary */, |
3611 |
++ arg->pages, 0 /* page base */, arg->npages * PAGE_SIZE); |
3612 |
+ done: |
3613 |
+ if (err) |
3614 |
+ dprintk("RPC: gssx_enc_accept_sec_context: %d\n", err); |
3615 |
+diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.h b/net/sunrpc/auth_gss/gss_rpc_xdr.h |
3616 |
+index 1c98b27..685a688 100644 |
3617 |
+--- a/net/sunrpc/auth_gss/gss_rpc_xdr.h |
3618 |
++++ b/net/sunrpc/auth_gss/gss_rpc_xdr.h |
3619 |
+@@ -147,6 +147,8 @@ struct gssx_arg_accept_sec_context { |
3620 |
+ struct gssx_cb *input_cb; |
3621 |
+ u32 ret_deleg_cred; |
3622 |
+ struct gssx_option_array options; |
3623 |
++ struct page **pages; |
3624 |
++ unsigned int npages; |
3625 |
+ }; |
3626 |
+ |
3627 |
+ struct gssx_res_accept_sec_context { |
3628 |
+@@ -240,7 +242,8 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, |
3629 |
+ 2 * GSSX_max_princ_sz + \ |
3630 |
+ 8 + 8 + 4 + 4 + 4) |
3631 |
+ #define GSSX_max_output_token_sz 1024 |
3632 |
+-#define GSSX_max_creds_sz (4 + 4 + 4 + NGROUPS_MAX * 4) |
3633 |
++/* grouplist not included; we allocate separate pages for that: */ |
3634 |
++#define GSSX_max_creds_sz (4 + 4 + 4 /* + NGROUPS_MAX*4 */) |
3635 |
+ #define GSSX_RES_accept_sec_context_sz (GSSX_default_status_sz + \ |
3636 |
+ GSSX_default_ctx_sz + \ |
3637 |
+ GSSX_max_output_token_sz + \ |