Subversion Repositories Kolibri OS

Rev

Rev 5367 | Rev 6088 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5367 Rev 6084
Line 41... Line 41...
41
 * These functions provide the basic support for enabling and disabling the
41
 * These functions provide the basic support for enabling and disabling the
42
 * interrupt handling support. There's a lot more functionality in i915_irq.c
42
 * interrupt handling support. There's a lot more functionality in i915_irq.c
43
 * and related files, but that will be described in separate chapters.
43
 * and related files, but that will be described in separate chapters.
44
 */
44
 */
Line -... Line 45...
-
 
45
 
-
 
46
static const u32 hpd_ilk[HPD_NUM_PINS] = {
-
 
47
	[HPD_PORT_A] = DE_DP_A_HOTPLUG,
-
 
48
};
-
 
49
 
-
 
50
static const u32 hpd_ivb[HPD_NUM_PINS] = {
-
 
51
	[HPD_PORT_A] = DE_DP_A_HOTPLUG_IVB,
-
 
52
};
-
 
53
 
-
 
54
static const u32 hpd_bdw[HPD_NUM_PINS] = {
-
 
55
	[HPD_PORT_A] = GEN8_PORT_DP_A_HOTPLUG,
-
 
56
};
45
 
57
 
46
static const u32 hpd_ibx[] = {
58
static const u32 hpd_ibx[HPD_NUM_PINS] = {
47
	[HPD_CRT] = SDE_CRT_HOTPLUG,
59
	[HPD_CRT] = SDE_CRT_HOTPLUG,
48
	[HPD_SDVO_B] = SDE_SDVOB_HOTPLUG,
60
	[HPD_SDVO_B] = SDE_SDVOB_HOTPLUG,
49
	[HPD_PORT_B] = SDE_PORTB_HOTPLUG,
61
	[HPD_PORT_B] = SDE_PORTB_HOTPLUG,
50
	[HPD_PORT_C] = SDE_PORTC_HOTPLUG,
62
	[HPD_PORT_C] = SDE_PORTC_HOTPLUG,
51
	[HPD_PORT_D] = SDE_PORTD_HOTPLUG
63
	[HPD_PORT_D] = SDE_PORTD_HOTPLUG
Line 52... Line 64...
52
};
64
};
53
 
65
 
54
static const u32 hpd_cpt[] = {
66
static const u32 hpd_cpt[HPD_NUM_PINS] = {
55
	[HPD_CRT] = SDE_CRT_HOTPLUG_CPT,
67
	[HPD_CRT] = SDE_CRT_HOTPLUG_CPT,
56
	[HPD_SDVO_B] = SDE_SDVOB_HOTPLUG_CPT,
68
	[HPD_SDVO_B] = SDE_SDVOB_HOTPLUG_CPT,
57
	[HPD_PORT_B] = SDE_PORTB_HOTPLUG_CPT,
69
	[HPD_PORT_B] = SDE_PORTB_HOTPLUG_CPT,
58
	[HPD_PORT_C] = SDE_PORTC_HOTPLUG_CPT,
70
	[HPD_PORT_C] = SDE_PORTC_HOTPLUG_CPT,
Line -... Line 71...
-
 
71
	[HPD_PORT_D] = SDE_PORTD_HOTPLUG_CPT
-
 
72
};
-
 
73
 
-
 
74
static const u32 hpd_spt[HPD_NUM_PINS] = {
-
 
75
	[HPD_PORT_A] = SDE_PORTA_HOTPLUG_SPT,
-
 
76
	[HPD_PORT_B] = SDE_PORTB_HOTPLUG_CPT,
-
 
77
	[HPD_PORT_C] = SDE_PORTC_HOTPLUG_CPT,
-
 
78
	[HPD_PORT_D] = SDE_PORTD_HOTPLUG_CPT,
59
	[HPD_PORT_D] = SDE_PORTD_HOTPLUG_CPT
79
	[HPD_PORT_E] = SDE_PORTE_HOTPLUG_SPT
60
};
80
};
61
 
81
 
62
static const u32 hpd_mask_i915[] = {
82
static const u32 hpd_mask_i915[HPD_NUM_PINS] = {
63
	[HPD_CRT] = CRT_HOTPLUG_INT_EN,
83
	[HPD_CRT] = CRT_HOTPLUG_INT_EN,
64
	[HPD_SDVO_B] = SDVOB_HOTPLUG_INT_EN,
84
	[HPD_SDVO_B] = SDVOB_HOTPLUG_INT_EN,
65
	[HPD_SDVO_C] = SDVOC_HOTPLUG_INT_EN,
85
	[HPD_SDVO_C] = SDVOC_HOTPLUG_INT_EN,
66
	[HPD_PORT_B] = PORTB_HOTPLUG_INT_EN,
86
	[HPD_PORT_B] = PORTB_HOTPLUG_INT_EN,
Line 67... Line 87...
67
	[HPD_PORT_C] = PORTC_HOTPLUG_INT_EN,
87
	[HPD_PORT_C] = PORTC_HOTPLUG_INT_EN,
68
	[HPD_PORT_D] = PORTD_HOTPLUG_INT_EN
88
	[HPD_PORT_D] = PORTD_HOTPLUG_INT_EN
69
};
89
};
70
 
90
 
71
static const u32 hpd_status_g4x[] = {
91
static const u32 hpd_status_g4x[HPD_NUM_PINS] = {
72
	[HPD_CRT] = CRT_HOTPLUG_INT_STATUS,
92
	[HPD_CRT] = CRT_HOTPLUG_INT_STATUS,
73
	[HPD_SDVO_B] = SDVOB_HOTPLUG_INT_STATUS_G4X,
93
	[HPD_SDVO_B] = SDVOB_HOTPLUG_INT_STATUS_G4X,
74
	[HPD_SDVO_C] = SDVOC_HOTPLUG_INT_STATUS_G4X,
94
	[HPD_SDVO_C] = SDVOC_HOTPLUG_INT_STATUS_G4X,
Line 75... Line 95...
75
	[HPD_PORT_B] = PORTB_HOTPLUG_INT_STATUS,
95
	[HPD_PORT_B] = PORTB_HOTPLUG_INT_STATUS,
76
	[HPD_PORT_C] = PORTC_HOTPLUG_INT_STATUS,
96
	[HPD_PORT_C] = PORTC_HOTPLUG_INT_STATUS,
77
	[HPD_PORT_D] = PORTD_HOTPLUG_INT_STATUS
97
	[HPD_PORT_D] = PORTD_HOTPLUG_INT_STATUS
78
};
98
};
79
 
99
 
80
static const u32 hpd_status_i915[] = { /* i915 and valleyview are the same */
100
static const u32 hpd_status_i915[HPD_NUM_PINS] = {
81
	[HPD_CRT] = CRT_HOTPLUG_INT_STATUS,
101
	[HPD_CRT] = CRT_HOTPLUG_INT_STATUS,
82
	[HPD_SDVO_B] = SDVOB_HOTPLUG_INT_STATUS_I915,
102
	[HPD_SDVO_B] = SDVOB_HOTPLUG_INT_STATUS_I915,
Line -... Line 103...
-
 
103
	[HPD_SDVO_C] = SDVOC_HOTPLUG_INT_STATUS_I915,
-
 
104
	[HPD_PORT_B] = PORTB_HOTPLUG_INT_STATUS,
-
 
105
	[HPD_PORT_C] = PORTC_HOTPLUG_INT_STATUS,
-
 
106
	[HPD_PORT_D] = PORTD_HOTPLUG_INT_STATUS
-
 
107
};
-
 
108
 
-
 
109
/* BXT hpd list */
83
	[HPD_SDVO_C] = SDVOC_HOTPLUG_INT_STATUS_I915,
110
static const u32 hpd_bxt[HPD_NUM_PINS] = {
84
	[HPD_PORT_B] = PORTB_HOTPLUG_INT_STATUS,
111
	[HPD_PORT_A] = BXT_DE_PORT_HP_DDIA,
85
	[HPD_PORT_C] = PORTC_HOTPLUG_INT_STATUS,
112
	[HPD_PORT_B] = BXT_DE_PORT_HP_DDIB,
86
	[HPD_PORT_D] = PORTD_HOTPLUG_INT_STATUS
113
	[HPD_PORT_C] = BXT_DE_PORT_HP_DDIC
87
};
114
};
Line 108... Line 135...
108
} while (0)
135
} while (0)
Line 109... Line 136...
109
 
136
 
110
/*
137
/*
111
 * We should clear IMR at preinstall/uninstall, and just check at postinstall.
138
 * We should clear IMR at preinstall/uninstall, and just check at postinstall.
112
 */
139
 */
-
 
140
static void gen5_assert_iir_is_zero(struct drm_i915_private *dev_priv, u32 reg)
113
#define GEN5_ASSERT_IIR_IS_ZERO(reg) do { \
141
{
-
 
142
	u32 val = I915_READ(reg);
114
	u32 val = I915_READ(reg); \
143
 
-
 
144
	if (val == 0)
-
 
145
		return;
115
	if (val) { \
146
 
116
		WARN(1, "Interrupt register 0x%x is not zero: 0x%08x\n", \
147
	WARN(1, "Interrupt register 0x%x is not zero: 0x%08x\n",
117
		     (reg), val); \
148
	     reg, val);
118
		I915_WRITE((reg), 0xffffffff); \
149
	I915_WRITE(reg, 0xffffffff);
119
		POSTING_READ(reg); \
150
	POSTING_READ(reg);
120
		I915_WRITE((reg), 0xffffffff); \
151
	I915_WRITE(reg, 0xffffffff);
121
		POSTING_READ(reg); \
152
	POSTING_READ(reg);
122
	} \
-
 
Line 123... Line 153...
123
} while (0)
153
}
124
 
154
 
125
#define GEN8_IRQ_INIT_NDX(type, which, imr_val, ier_val) do { \
155
#define GEN8_IRQ_INIT_NDX(type, which, imr_val, ier_val) do { \
126
	GEN5_ASSERT_IIR_IS_ZERO(GEN8_##type##_IIR(which)); \
156
	gen5_assert_iir_is_zero(dev_priv, GEN8_##type##_IIR(which)); \
127
	I915_WRITE(GEN8_##type##_IER(which), (ier_val)); \
157
	I915_WRITE(GEN8_##type##_IER(which), (ier_val)); \
128
	I915_WRITE(GEN8_##type##_IMR(which), (imr_val)); \
158
	I915_WRITE(GEN8_##type##_IMR(which), (imr_val)); \
Line 129... Line 159...
129
	POSTING_READ(GEN8_##type##_IMR(which)); \
159
	POSTING_READ(GEN8_##type##_IMR(which)); \
130
} while (0)
160
} while (0)
131
 
161
 
132
#define GEN5_IRQ_INIT(type, imr_val, ier_val) do { \
162
#define GEN5_IRQ_INIT(type, imr_val, ier_val) do { \
133
	GEN5_ASSERT_IIR_IS_ZERO(type##IIR); \
163
	gen5_assert_iir_is_zero(dev_priv, type##IIR); \
134
	I915_WRITE(type##IER, (ier_val)); \
164
	I915_WRITE(type##IER, (ier_val)); \
Line 135... Line 165...
135
	I915_WRITE(type##IMR, (imr_val)); \
165
	I915_WRITE(type##IMR, (imr_val)); \
Line 136... Line 166...
136
	POSTING_READ(type##IMR); \
166
	POSTING_READ(type##IMR); \
137
} while (0)
167
} while (0)
138
 
168
 
-
 
169
static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir);
-
 
170
 
139
static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir);
171
/* For display hotplug interrupt */
140
 
172
static inline void
Line 141... Line 173...
141
/* For display hotplug interrupt */
173
i915_hotplug_interrupt_update_locked(struct drm_i915_private *dev_priv,
142
void
174
				     uint32_t mask,
Line 143... Line 175...
143
ironlake_enable_display_irq(struct drm_i915_private *dev_priv, u32 mask)
175
				     uint32_t bits)
144
{
176
{
145
	assert_spin_locked(&dev_priv->irq_lock);
177
	uint32_t val;
146
 
178
 
147
	if (WARN_ON(!intel_irqs_enabled(dev_priv)))
179
	assert_spin_locked(&dev_priv->irq_lock);
-
 
180
	WARN_ON(bits & ~mask);
-
 
181
 
-
 
182
	val = I915_READ(PORT_HOTPLUG_EN);
-
 
183
	val &= ~mask;
-
 
184
	val |= bits;
-
 
185
	I915_WRITE(PORT_HOTPLUG_EN, val);
-
 
186
}
-
 
187
 
-
 
188
/**
-
 
189
 * i915_hotplug_interrupt_update - update hotplug interrupt enable
-
 
190
 * @dev_priv: driver private
-
 
191
 * @mask: bits to update
-
 
192
 * @bits: bits to enable
-
 
193
 * NOTE: the HPD enable bits are modified both inside and outside
-
 
194
 * of an interrupt context. To avoid that read-modify-write cycles
-
 
195
 * interfer, these bits are protected by a spinlock. Since this
-
 
196
 * function is usually not called from a context where the lock is
-
 
197
 * held already, this function acquires the lock itself. A non-locking
-
 
198
 * version is also available.
-
 
199
 */
148
		return;
200
void i915_hotplug_interrupt_update(struct drm_i915_private *dev_priv,
Line 149... Line 201...
149
 
201
				   uint32_t mask,
-
 
202
				   uint32_t bits)
-
 
203
{
-
 
204
	spin_lock_irq(&dev_priv->irq_lock);
-
 
205
	i915_hotplug_interrupt_update_locked(dev_priv, mask, bits);
-
 
206
	spin_unlock_irq(&dev_priv->irq_lock);
150
    if ((dev_priv->irq_mask & mask) != 0) {
207
}
-
 
208
 
-
 
209
/**
151
        dev_priv->irq_mask &= ~mask;
210
 * ilk_update_display_irq - update DEIMR
-
 
211
 * @dev_priv: driver private
-
 
212
 * @interrupt_mask: mask of interrupt bits to update
152
        I915_WRITE(DEIMR, dev_priv->irq_mask);
213
 * @enabled_irq_mask: mask of interrupt bits to enable
Line -... Line 214...
-
 
214
 */
-
 
215
static void ilk_update_display_irq(struct drm_i915_private *dev_priv,
153
        POSTING_READ(DEIMR);
216
				   uint32_t interrupt_mask,
154
    }
217
				   uint32_t enabled_irq_mask)
Line -... Line 218...
-
 
218
{
-
 
219
	uint32_t new_val;
155
}
220
 
-
 
221
	assert_spin_locked(&dev_priv->irq_lock);
-
 
222
 
156
 
223
	WARN_ON(enabled_irq_mask & ~interrupt_mask);
157
void
224
 
158
ironlake_disable_display_irq(struct drm_i915_private *dev_priv, u32 mask)
225
	if (WARN_ON(!intel_irqs_enabled(dev_priv)))
159
{
226
		return;
160
	assert_spin_locked(&dev_priv->irq_lock);
227
 
Line -... Line 228...
-
 
228
	new_val = dev_priv->irq_mask;
-
 
229
	new_val &= ~interrupt_mask;
-
 
230
	new_val |= (~enabled_irq_mask & interrupt_mask);
-
 
231
 
-
 
232
	if (new_val != dev_priv->irq_mask) {
-
 
233
		dev_priv->irq_mask = new_val;
-
 
234
		I915_WRITE(DEIMR, dev_priv->irq_mask);
-
 
235
		POSTING_READ(DEIMR);
-
 
236
	}
-
 
237
}
-
 
238
 
-
 
239
void
161
 
240
ironlake_enable_display_irq(struct drm_i915_private *dev_priv, u32 mask)
162
	if (WARN_ON(!intel_irqs_enabled(dev_priv)))
241
{
163
		return;
242
	ilk_update_display_irq(dev_priv, mask, mask);
164
 
243
}
165
    if ((dev_priv->irq_mask & mask) != mask) {
244
 
Line 179... Line 258...
179
			      uint32_t interrupt_mask,
258
			      uint32_t interrupt_mask,
180
			      uint32_t enabled_irq_mask)
259
			      uint32_t enabled_irq_mask)
181
{
260
{
182
	assert_spin_locked(&dev_priv->irq_lock);
261
	assert_spin_locked(&dev_priv->irq_lock);
Line -... Line 262...
-
 
262
 
-
 
263
	WARN_ON(enabled_irq_mask & ~interrupt_mask);
183
 
264
 
184
	if (WARN_ON(!intel_irqs_enabled(dev_priv)))
265
	if (WARN_ON(!intel_irqs_enabled(dev_priv)))
Line 185... Line 266...
185
		return;
266
		return;
186
 
267
 
Line 225... Line 306...
225
			      uint32_t interrupt_mask,
306
			      uint32_t interrupt_mask,
226
			      uint32_t enabled_irq_mask)
307
			      uint32_t enabled_irq_mask)
227
{
308
{
228
	uint32_t new_val;
309
	uint32_t new_val;
Line -... Line 310...
-
 
310
 
-
 
311
	WARN_ON(enabled_irq_mask & ~interrupt_mask);
229
 
312
 
Line 230... Line 313...
230
	assert_spin_locked(&dev_priv->irq_lock);
313
	assert_spin_locked(&dev_priv->irq_lock);
231
 
314
 
232
	new_val = dev_priv->pm_irq_mask;
315
	new_val = dev_priv->pm_irq_mask;
Line 269... Line 352...
269
 
352
 
270
	spin_lock_irq(&dev_priv->irq_lock);
353
	spin_lock_irq(&dev_priv->irq_lock);
271
	I915_WRITE(reg, dev_priv->pm_rps_events);
354
	I915_WRITE(reg, dev_priv->pm_rps_events);
272
	I915_WRITE(reg, dev_priv->pm_rps_events);
355
	I915_WRITE(reg, dev_priv->pm_rps_events);
-
 
356
	POSTING_READ(reg);
273
		POSTING_READ(reg);
357
	dev_priv->rps.pm_iir = 0;
274
	spin_unlock_irq(&dev_priv->irq_lock);
358
	spin_unlock_irq(&dev_priv->irq_lock);
Line 275... Line 359...
275
}
359
}
276
 
360
 
Line 288... Line 372...
288
	gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events);
372
	gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events);
Line 289... Line 373...
289
 
373
 
290
	spin_unlock_irq(&dev_priv->irq_lock);
374
	spin_unlock_irq(&dev_priv->irq_lock);
Line -... Line 375...
-
 
375
}
-
 
376
 
-
 
377
u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask)
-
 
378
{
-
 
379
	/*
-
 
380
	 * SNB,IVB can while VLV,CHV may hard hang on looping batchbuffer
-
 
381
	 * if GEN6_PM_UP_EI_EXPIRED is masked.
-
 
382
	 *
-
 
383
	 * TODO: verify if this can be reproduced on VLV,CHV.
-
 
384
	 */
-
 
385
	if (INTEL_INFO(dev_priv)->gen <= 7 && !IS_HASWELL(dev_priv))
-
 
386
		mask &= ~GEN6_PM_RP_UP_EI_EXPIRED;
-
 
387
 
-
 
388
	if (INTEL_INFO(dev_priv)->gen >= 8)
-
 
389
		mask &= ~GEN8_PMINTR_REDIRECT_TO_NON_DISP;
-
 
390
 
-
 
391
	return mask;
291
}
392
}
292
 
393
 
293
void gen6_disable_rps_interrupts(struct drm_device *dev)
394
void gen6_disable_rps_interrupts(struct drm_device *dev)
Line 294... Line 395...
294
{
395
{
Line 300... Line 401...
300
 
401
 
Line 301... Line 402...
301
	cancel_work_sync(&dev_priv->rps.work);
402
	cancel_work_sync(&dev_priv->rps.work);
Line 302... Line 403...
302
 
403
 
303
	spin_lock_irq(&dev_priv->irq_lock);
-
 
Line 304... Line 404...
304
 
404
	spin_lock_irq(&dev_priv->irq_lock);
305
	I915_WRITE(GEN6_PMINTRMSK, INTEL_INFO(dev_priv)->gen >= 8 ?
405
 
306
		   ~GEN8_PMINTR_REDIRECT_TO_NON_DISP : ~0);
406
	I915_WRITE(GEN6_PMINTRMSK, gen6_sanitize_rps_pm_mask(dev_priv, ~0));
307
 
-
 
308
	__gen6_disable_pm_irq(dev_priv, dev_priv->pm_rps_events);
-
 
309
	I915_WRITE(gen6_pm_ier(dev_priv), I915_READ(gen6_pm_ier(dev_priv)) &
-
 
310
				~dev_priv->pm_rps_events);
-
 
Line 311... Line 407...
311
	I915_WRITE(gen6_pm_iir(dev_priv), dev_priv->pm_rps_events);
407
 
-
 
408
	__gen6_disable_pm_irq(dev_priv, dev_priv->pm_rps_events);
-
 
409
	I915_WRITE(gen6_pm_ier(dev_priv), I915_READ(gen6_pm_ier(dev_priv)) &
-
 
410
				~dev_priv->pm_rps_events);
-
 
411
 
-
 
412
	spin_unlock_irq(&dev_priv->irq_lock);
-
 
413
 
-
 
414
}
-
 
415
 
-
 
416
/**
-
 
417
  * bdw_update_port_irq - update DE port interrupt
-
 
418
  * @dev_priv: driver private
-
 
419
  * @interrupt_mask: mask of interrupt bits to update
-
 
420
  * @enabled_irq_mask: mask of interrupt bits to enable
-
 
421
  */
-
 
422
static void bdw_update_port_irq(struct drm_i915_private *dev_priv,
-
 
423
				uint32_t interrupt_mask,
-
 
424
				uint32_t enabled_irq_mask)
-
 
425
{
-
 
426
	uint32_t new_val;
-
 
427
	uint32_t old_val;
-
 
428
 
-
 
429
	assert_spin_locked(&dev_priv->irq_lock);
-
 
430
 
-
 
431
	WARN_ON(enabled_irq_mask & ~interrupt_mask);
-
 
432
 
-
 
433
	if (WARN_ON(!intel_irqs_enabled(dev_priv)))
-
 
434
		return;
-
 
435
 
-
 
436
	old_val = I915_READ(GEN8_DE_PORT_IMR);
-
 
437
 
-
 
438
	new_val = old_val;
-
 
439
	new_val &= ~interrupt_mask;
-
 
440
	new_val |= (~enabled_irq_mask & interrupt_mask);
312
	I915_WRITE(gen6_pm_iir(dev_priv), dev_priv->pm_rps_events);
441
 
Line 313... Line 442...
313
 
442
	if (new_val != old_val) {
314
	dev_priv->rps.pm_iir = 0;
443
		I915_WRITE(GEN8_DE_PORT_IMR, new_val);
315
 
444
		POSTING_READ(GEN8_DE_PORT_IMR);
Line 328... Line 457...
328
{
457
{
329
	uint32_t sdeimr = I915_READ(SDEIMR);
458
	uint32_t sdeimr = I915_READ(SDEIMR);
330
	sdeimr &= ~interrupt_mask;
459
	sdeimr &= ~interrupt_mask;
331
	sdeimr |= (~enabled_irq_mask & interrupt_mask);
460
	sdeimr |= (~enabled_irq_mask & interrupt_mask);
Line -... Line 461...
-
 
461
 
-
 
462
	WARN_ON(enabled_irq_mask & ~interrupt_mask);
332
 
463
 
Line 333... Line 464...
333
	assert_spin_locked(&dev_priv->irq_lock);
464
	assert_spin_locked(&dev_priv->irq_lock);
334
 
465
 
Line 448... Line 579...
448
	__i915_disable_pipestat(dev_priv, pipe, enable_mask, status_mask);
579
	__i915_disable_pipestat(dev_priv, pipe, enable_mask, status_mask);
449
}
580
}
Line 450... Line 581...
450
 
581
 
451
/**
582
/**
-
 
583
 * i915_enable_asle_pipestat - enable ASLE pipestat for OpRegion
452
 * i915_enable_asle_pipestat - enable ASLE pipestat for OpRegion
584
 * @dev: drm device
453
 */
585
 */
454
static void i915_enable_asle_pipestat(struct drm_device *dev)
586
static void i915_enable_asle_pipestat(struct drm_device *dev)
455
{
587
{
Line 466... Line 598...
466
				     PIPE_LEGACY_BLC_EVENT_STATUS);
598
				     PIPE_LEGACY_BLC_EVENT_STATUS);
Line 467... Line 599...
467
 
599
 
468
	spin_unlock_irq(&dev_priv->irq_lock);
600
	spin_unlock_irq(&dev_priv->irq_lock);
Line 469... Line -...
469
}
-
 
470
 
-
 
471
/**
-
 
472
 * i915_pipe_enabled - check if a pipe is enabled
-
 
473
 * @dev: DRM device
-
 
474
 * @pipe: pipe to check
-
 
475
 *
-
 
476
 * Reading certain registers when the pipe is disabled can hang the chip.
-
 
477
 * Use this routine to make sure the PLL is running and the pipe is active
-
 
478
 * before reading such registers if unsure.
-
 
479
 */
-
 
480
static int
-
 
481
i915_pipe_enabled(struct drm_device *dev, int pipe)
-
 
482
{
-
 
483
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
484
 
-
 
485
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
-
 
486
		/* Locking is horribly broken here, but whatever. */
-
 
487
		struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
-
 
488
		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
489
 
-
 
490
		return intel_crtc->active;
-
 
491
	} else {
-
 
492
		return I915_READ(PIPECONF(pipe)) & PIPECONF_ENABLE;
-
 
493
	}
-
 
494
}
601
}
495
 
602
 
496
/*
603
/*
497
 * This timing diagram depicts the video signal in and
604
 * This timing diagram depicts the video signal in and
498
 * around the vertical blanking period.
605
 * around the vertical blanking period.
Line 541... Line 648...
541
 *   (depending on PIPECONF settings) after the start of vblank
648
 *   (depending on PIPECONF settings) after the start of vblank
542
 * - gen3/4 pixel and frame counter are synchronized with the start
649
 * - gen3/4 pixel and frame counter are synchronized with the start
543
 *   of horizontal active on the first line of vertical active
650
 *   of horizontal active on the first line of vertical active
544
 */
651
 */
Line 545... Line 652...
545
 
652
 
546
static u32 i8xx_get_vblank_counter(struct drm_device *dev, int pipe)
653
static u32 i8xx_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
547
{
654
{
548
	/* Gen2 doesn't have a hardware frame counter */
655
	/* Gen2 doesn't have a hardware frame counter */
549
	return 0;
656
	return 0;
Line 550... Line 657...
550
}
657
}
551
 
658
 
552
/* Called from drm generic code, passed a 'crtc', which
659
/* Called from drm generic code, passed a 'crtc', which
553
 * we use as a pipe index
660
 * we use as a pipe index
554
 */
661
 */
555
static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
662
static u32 i915_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
556
{
663
{
557
	struct drm_i915_private *dev_priv = dev->dev_private;
664
	struct drm_i915_private *dev_priv = dev->dev_private;
558
	unsigned long high_frame;
665
	unsigned long high_frame;
559
	unsigned long low_frame;
-
 
560
	u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal;
-
 
561
 
-
 
562
	if (!i915_pipe_enabled(dev, pipe)) {
-
 
563
		DRM_DEBUG_DRIVER("trying to get vblank count for disabled "
-
 
564
				"pipe %c\n", pipe_name(pipe));
-
 
565
		return 0;
-
 
566
	}
-
 
567
 
666
	unsigned long low_frame;
568
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
667
	u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal;
569
		struct intel_crtc *intel_crtc =
668
	struct intel_crtc *intel_crtc =
570
			to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
-
 
Line 571... Line 669...
571
		const struct drm_display_mode *mode =
669
		to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
572
			&intel_crtc->config.adjusted_mode;
670
	const struct drm_display_mode *mode = &intel_crtc->base.hwmode;
573
 
671
 
574
		htotal = mode->crtc_htotal;
672
	htotal = mode->crtc_htotal;
575
		hsync_start = mode->crtc_hsync_start;
673
	hsync_start = mode->crtc_hsync_start;
576
		vbl_start = mode->crtc_vblank_start;
-
 
577
		if (mode->flags & DRM_MODE_FLAG_INTERLACE)
-
 
578
			vbl_start = DIV_ROUND_UP(vbl_start, 2);
-
 
579
	} else {
-
 
580
		enum transcoder cpu_transcoder = (enum transcoder) pipe;
-
 
581
 
-
 
582
		htotal = ((I915_READ(HTOTAL(cpu_transcoder)) >> 16) & 0x1fff) + 1;
-
 
583
		hsync_start = (I915_READ(HSYNC(cpu_transcoder))  & 0x1fff) + 1;
-
 
584
		vbl_start = (I915_READ(VBLANK(cpu_transcoder)) & 0x1fff) + 1;
-
 
585
		if ((I915_READ(PIPECONF(cpu_transcoder)) &
-
 
Line 586... Line 674...
586
		     PIPECONF_INTERLACE_MASK) != PIPECONF_PROGRESSIVE)
674
	vbl_start = mode->crtc_vblank_start;
587
			vbl_start = DIV_ROUND_UP(vbl_start, 2);
675
	if (mode->flags & DRM_MODE_FLAG_INTERLACE)
Line 588... Line 676...
588
	}
676
		vbl_start = DIV_ROUND_UP(vbl_start, 2);
Line 617... Line 705...
617
	 * counter against vblank start.
705
	 * counter against vblank start.
618
	 */
706
	 */
619
	return (((high1 << 8) | low) + (pixel >= vbl_start)) & 0xffffff;
707
	return (((high1 << 8) | low) + (pixel >= vbl_start)) & 0xffffff;
620
}
708
}
Line 621... Line 709...
621
 
709
 
622
static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
710
static u32 g4x_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
623
{
711
{
624
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
Line 625... Line -...
625
	int reg = PIPE_FRMCOUNT_GM45(pipe);
-
 
626
 
-
 
627
	if (!i915_pipe_enabled(dev, pipe)) {
-
 
628
		DRM_DEBUG_DRIVER("trying to get vblank count for disabled "
-
 
629
				 "pipe %c\n", pipe_name(pipe));
-
 
630
		return 0;
-
 
631
	}
712
	struct drm_i915_private *dev_priv = dev->dev_private;
632
 
713
 
Line 633... Line 714...
633
	return I915_READ(reg);
714
	return I915_READ(PIPE_FRMCOUNT_G4X(pipe));
634
}
715
}
Line 635... Line 716...
635
 
716
 
636
/* raw reads, only for fast reads of display block, no need for forcewake etc. */
717
/* raw reads, only for fast reads of display block, no need for forcewake etc. */
637
#define __raw_i915_read32(dev_priv__, reg__) readl((dev_priv__)->regs + (reg__))
718
#define __raw_i915_read32(dev_priv__, reg__) readl((dev_priv__)->regs + (reg__))
638
 
719
 
639
static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
720
static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
640
{
721
{
641
	struct drm_device *dev = crtc->base.dev;
722
	struct drm_device *dev = crtc->base.dev;
Line 642... Line 723...
642
	struct drm_i915_private *dev_priv = dev->dev_private;
723
	struct drm_i915_private *dev_priv = dev->dev_private;
643
	const struct drm_display_mode *mode = &crtc->config.adjusted_mode;
724
	const struct drm_display_mode *mode = &crtc->base.hwmode;
Line 652... Line 733...
652
		position = __raw_i915_read32(dev_priv, PIPEDSL(pipe)) & DSL_LINEMASK_GEN2;
733
		position = __raw_i915_read32(dev_priv, PIPEDSL(pipe)) & DSL_LINEMASK_GEN2;
653
	else
734
	else
654
		position = __raw_i915_read32(dev_priv, PIPEDSL(pipe)) & DSL_LINEMASK_GEN3;
735
		position = __raw_i915_read32(dev_priv, PIPEDSL(pipe)) & DSL_LINEMASK_GEN3;
Line 655... Line 736...
655
 
736
 
-
 
737
	/*
-
 
738
	 * On HSW, the DSL reg (0x70000) appears to return 0 if we
-
 
739
	 * read it just before the start of vblank.  So try it again
-
 
740
	 * so we don't accidentally end up spanning a vblank frame
-
 
741
	 * increment, causing the pipe_update_end() code to squak at us.
-
 
742
	 *
-
 
743
	 * The nature of this problem means we can't simply check the ISR
-
 
744
	 * bit and return the vblank start value; nor can we use the scanline
-
 
745
	 * debug register in the transcoder as it appears to have the same
-
 
746
	 * problem.  We may need to extend this to include other platforms,
-
 
747
	 * but so far testing only shows the problem on HSW.
-
 
748
	 */
-
 
749
	if (HAS_DDI(dev) && !position) {
-
 
750
		int i, temp;
-
 
751
 
-
 
752
		for (i = 0; i < 100; i++) {
-
 
753
			udelay(1);
-
 
754
			temp = __raw_i915_read32(dev_priv, PIPEDSL(pipe)) &
-
 
755
				DSL_LINEMASK_GEN3;
-
 
756
			if (temp != position) {
-
 
757
				position = temp;
-
 
758
				break;
-
 
759
			}
-
 
760
		}
-
 
761
	}
-
 
762
 
656
	/*
763
	/*
657
	 * See update_scanline_offset() for the details on the
764
	 * See update_scanline_offset() for the details on the
658
	 * scanline_offset adjustment.
765
	 * scanline_offset adjustment.
659
	 */
766
	 */
660
	return (position + crtc->scanline_offset) % vtotal;
767
	return (position + crtc->scanline_offset) % vtotal;
Line 661... Line 768...
661
}
768
}
662
 
769
 
663
static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
770
static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
-
 
771
				    unsigned int flags, int *vpos, int *hpos,
664
				    unsigned int flags, int *vpos, int *hpos,
772
				    ktime_t *stime, ktime_t *etime,
665
				    void *stime, void *etime)
773
				    const struct drm_display_mode *mode)
666
{
774
{
667
	struct drm_i915_private *dev_priv = dev->dev_private;
775
	struct drm_i915_private *dev_priv = dev->dev_private;
668
	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
-
 
669
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
776
	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
670
	const struct drm_display_mode *mode = &intel_crtc->config.adjusted_mode;
777
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
671
	int position;
778
	int position;
672
	int vbl_start, vbl_end, hsync_start, htotal, vtotal;
779
	int vbl_start, vbl_end, hsync_start, htotal, vtotal;
673
	bool in_vbl = true;
780
	bool in_vbl = true;
Line 674... Line 781...
674
	int ret = 0;
781
	int ret = 0;
675
	unsigned long irqflags;
782
	unsigned long irqflags;
676
 
783
 
677
	if (!intel_crtc->active) {
784
	if (WARN_ON(!mode->crtc_clock)) {
678
		DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled "
785
		DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled "
Line 701... Line 808...
701
	 */
808
	 */
702
	spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
809
	spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
Line 703... Line 810...
703
 
810
 
Line -... Line 811...
-
 
811
	/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
-
 
812
 
-
 
813
	/* Get optional system timestamp before query. */
Line 704... Line 814...
704
	/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
814
	if (stime)
705
 
815
		*stime = ktime_get();
706
 
816
 
707
	if (IS_GEN2(dev) || IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {
817
	if (IS_GEN2(dev) || IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {
Line 743... Line 853...
743
		 * always add htotal-hsync_start to the current pixel position.
853
		 * always add htotal-hsync_start to the current pixel position.
744
		 */
854
		 */
745
		position = (position + htotal - hsync_start) % vtotal;
855
		position = (position + htotal - hsync_start) % vtotal;
746
	}
856
	}
Line -... Line 857...
-
 
857
 
-
 
858
	/* Get optional system timestamp after query. */
-
 
859
	if (etime)
Line 747... Line 860...
747
 
860
		*etime = ktime_get();
Line 748... Line 861...
748
 
861
 
Line 789... Line 902...
789
	spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
902
	spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
Line 790... Line 903...
790
 
903
 
791
	return position;
904
	return position;
Line 792... Line 905...
792
}
905
}
793
 
906
 
794
static int i915_get_vblank_timestamp(struct drm_device *dev, int pipe,
907
static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
795
			      int *max_error,
908
			      int *max_error,
796
			      struct timeval *vblank_time,
909
			      struct timeval *vblank_time,
797
			      unsigned flags)
910
			      unsigned flags)
Line 798... Line 911...
798
{
911
{
799
	struct drm_crtc *crtc;
912
	struct drm_crtc *crtc;
800
 
913
 
801
	if (pipe < 0 || pipe >= INTEL_INFO(dev)->num_pipes) {
914
	if (pipe >= INTEL_INFO(dev)->num_pipes) {
Line 802... Line 915...
802
		DRM_ERROR("Invalid crtc %d\n", pipe);
915
		DRM_ERROR("Invalid crtc %u\n", pipe);
803
		return -EINVAL;
916
		return -EINVAL;
804
	}
917
	}
805
 
918
 
806
	/* Get drm_crtc to timestamp: */
919
	/* Get drm_crtc to timestamp: */
807
	crtc = intel_get_crtc_for_pipe(dev, pipe);
920
	crtc = intel_get_crtc_for_pipe(dev, pipe);
Line 808... Line 921...
808
	if (crtc == NULL) {
921
	if (crtc == NULL) {
809
		DRM_ERROR("Invalid crtc %d\n", pipe);
922
		DRM_ERROR("Invalid crtc %u\n", pipe);
810
		return -EINVAL;
923
		return -EINVAL;
811
	}
924
	}
Line 812... Line 925...
812
 
925
 
813
	if (!crtc->enabled) {
926
	if (!crtc->hwmode.crtc_clock) {
814
		DRM_DEBUG_KMS("crtc %d is disabled\n", pipe);
927
		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
815
		return -EBUSY;
928
		return -EBUSY;
816
	}
-
 
817
 
-
 
818
	/* Helper routine in DRM core does all the work: */
-
 
819
	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
-
 
820
						     vblank_time, flags,
-
 
821
						     crtc,
-
 
822
						     &to_intel_crtc(crtc)->config.adjusted_mode);
-
 
823
}
-
 
824
 
-
 
825
static bool intel_hpd_irq_event(struct drm_device *dev,
-
 
826
				struct drm_connector *connector)
-
 
827
{
-
 
828
	enum drm_connector_status old_status;
-
 
829
 
-
 
830
	WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
-
 
831
	old_status = connector->status;
-
 
832
 
-
 
833
	connector->status = connector->funcs->detect(connector, false);
-
 
834
	if (old_status == connector->status)
-
 
835
		return false;
-
 
836
 
-
 
837
	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n",
-
 
838
		      connector->base.id,
-
 
839
		      connector->name,
-
 
840
		      drm_get_connector_status_name(old_status),
-
 
841
		      drm_get_connector_status_name(connector->status));
-
 
842
 
-
 
843
	return true;
-
 
844
}
-
 
845
 
-
 
846
/*
-
 
847
 * Handle hotplug events outside the interrupt handler proper.
-
 
848
 */
-
 
849
#define I915_REENABLE_HOTPLUG_DELAY (2*60*1000)
-
 
850
 
-
 
851
static void i915_hotplug_work_func(struct work_struct *work)
-
 
852
{
-
 
853
	struct drm_i915_private *dev_priv =
-
 
854
		container_of(work, struct drm_i915_private, hotplug_work);
-
 
855
	struct drm_device *dev = dev_priv->dev;
-
 
856
	struct drm_mode_config *mode_config = &dev->mode_config;
-
 
857
	struct intel_connector *intel_connector;
-
 
858
	struct intel_encoder *intel_encoder;
-
 
859
	struct drm_connector *connector;
-
 
860
	bool hpd_disabled = false;
-
 
861
	bool changed = false;
-
 
862
	u32 hpd_event_bits;
-
 
863
 
-
 
864
	mutex_lock(&mode_config->mutex);
-
 
865
	DRM_DEBUG_KMS("running encoder hotplug functions\n");
-
 
866
 
-
 
867
	spin_lock_irq(&dev_priv->irq_lock);
-
 
868
 
-
 
869
	hpd_event_bits = dev_priv->hpd_event_bits;
-
 
870
	dev_priv->hpd_event_bits = 0;
-
 
871
	list_for_each_entry(connector, &mode_config->connector_list, head) {
-
 
872
		intel_connector = to_intel_connector(connector);
-
 
873
		if (!intel_connector->encoder)
-
 
874
			continue;
-
 
875
		intel_encoder = intel_connector->encoder;
-
 
876
		if (intel_encoder->hpd_pin > HPD_NONE &&
-
 
877
		    dev_priv->hpd_stats[intel_encoder->hpd_pin].hpd_mark == HPD_MARK_DISABLED &&
-
 
878
		    connector->polled == DRM_CONNECTOR_POLL_HPD) {
-
 
879
			DRM_INFO("HPD interrupt storm detected on connector %s: "
-
 
880
				 "switching from hotplug detection to polling\n",
-
 
881
				connector->name);
-
 
882
			dev_priv->hpd_stats[intel_encoder->hpd_pin].hpd_mark = HPD_DISABLED;
-
 
883
			connector->polled = DRM_CONNECTOR_POLL_CONNECT
-
 
884
				| DRM_CONNECTOR_POLL_DISCONNECT;
-
 
885
			hpd_disabled = true;
-
 
886
		}
-
 
887
		if (hpd_event_bits & (1 << intel_encoder->hpd_pin)) {
-
 
888
			DRM_DEBUG_KMS("Connector %s (pin %i) received hotplug event.\n",
-
 
889
				      connector->name, intel_encoder->hpd_pin);
-
 
890
		}
-
 
891
	}
-
 
892
	 /* if there were no outputs to poll, poll was disabled,
-
 
893
	  * therefore make sure it's enabled when disabling HPD on
-
 
894
	  * some connectors */
-
 
895
 
-
 
896
	spin_unlock_irq(&dev_priv->irq_lock);
-
 
897
 
-
 
898
	list_for_each_entry(connector, &mode_config->connector_list, head) {
-
 
899
		intel_connector = to_intel_connector(connector);
-
 
900
		if (!intel_connector->encoder)
-
 
901
			continue;
-
 
902
		intel_encoder = intel_connector->encoder;
-
 
903
		if (hpd_event_bits & (1 << intel_encoder->hpd_pin)) {
-
 
904
		if (intel_encoder->hot_plug)
-
 
905
			intel_encoder->hot_plug(intel_encoder);
-
 
906
			if (intel_hpd_irq_event(dev, connector))
929
	}
Line 907... Line 930...
907
				changed = true;
930
 
908
		}
931
	/* Helper routine in DRM core does all the work: */
909
	}
932
	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
Line 948... Line 971...
948
	spin_unlock(&mchdev_lock);
971
	spin_unlock(&mchdev_lock);
Line 949... Line 972...
949
 
972
 
950
	return;
973
	return;
Line 951... Line 974...
951
}
974
}
952
 
-
 
953
static void notify_ring(struct drm_device *dev,
975
 
954
			struct intel_engine_cs *ring)
976
static void notify_ring(struct intel_engine_cs *ring)
955
{
977
{
Line 956... Line 978...
956
	if (!intel_ring_initialized(ring))
978
	if (!intel_ring_initialized(ring))
Line 957... Line 979...
957
		return;
979
		return;
958
 
980
 
Line 959... Line 981...
959
	trace_i915_gem_request_complete(ring);
981
	trace_i915_gem_request_notify(ring);
960
 
982
 
961
	wake_up_all(&ring->irq_queue);
983
	wake_up_all(&ring->irq_queue);
962
}
-
 
963
 
-
 
964
static u32 vlv_c0_residency(struct drm_i915_private *dev_priv,
-
 
965
			    struct intel_rps_ei *rps_ei)
-
 
966
{
-
 
967
	u32 cz_ts, cz_freq_khz;
984
}
968
	u32 render_count, media_count;
-
 
969
	u32 elapsed_render, elapsed_media, elapsed_time;
-
 
970
	u32 residency = 0;
985
 
971
 
986
static void vlv_c0_read(struct drm_i915_private *dev_priv,
972
	cz_ts = vlv_punit_read(dev_priv, PUNIT_REG_CZ_TIMESTAMP);
-
 
973
	cz_freq_khz = DIV_ROUND_CLOSEST(dev_priv->mem_freq * 1000, 4);
-
 
974
 
-
 
975
	render_count = I915_READ(VLV_RENDER_C0_COUNT_REG);
-
 
976
	media_count = I915_READ(VLV_MEDIA_C0_COUNT_REG);
-
 
977
 
-
 
978
	if (rps_ei->cz_clock == 0) {
-
 
979
		rps_ei->cz_clock = cz_ts;
987
			struct intel_rps_ei *ei)
Line -... Line 988...
-
 
988
{
-
 
989
	ei->cz_clock = vlv_punit_read(dev_priv, PUNIT_REG_CZ_TIMESTAMP);
980
		rps_ei->render_c0 = render_count;
990
	ei->render_c0 = I915_READ(VLV_RENDER_C0_COUNT);
-
 
991
	ei->media_c0 = I915_READ(VLV_MEDIA_C0_COUNT);
-
 
992
}
-
 
993
 
981
		rps_ei->media_c0 = media_count;
994
static bool vlv_c0_above(struct drm_i915_private *dev_priv,
Line 982... Line 995...
982
 
995
			 const struct intel_rps_ei *old,
983
		return dev_priv->rps.cur_freq;
996
			 const struct intel_rps_ei *now,
Line 984... Line 997...
984
	}
997
			 int threshold)
985
 
998
{
Line 986... Line -...
986
	elapsed_time = cz_ts - rps_ei->cz_clock;
-
 
987
	rps_ei->cz_clock = cz_ts;
999
	u64 time, c0;
988
 
1000
	unsigned int mul = 100;
989
	elapsed_render = render_count - rps_ei->render_c0;
-
 
Line 990... Line -...
990
	rps_ei->render_c0 = render_count;
-
 
991
 
1001
 
992
	elapsed_media = media_count - rps_ei->media_c0;
1002
	if (old->cz_clock == 0)
-
 
1003
		return false;
993
	rps_ei->media_c0 = media_count;
1004
 
994
 
1005
	if (I915_READ(VLV_COUNTER_CONTROL) & VLV_COUNT_RANGE_HIGH)
995
	/* Convert all the counters into common unit of milli sec */
-
 
996
	elapsed_time /= VLV_CZ_CLOCK_TO_MILLI_SEC;
1006
		mul <<= 8;
997
	elapsed_render /=  cz_freq_khz;
1007
 
998
	elapsed_media /= cz_freq_khz;
-
 
Line 999... Line 1008...
999
 
1008
	time = now->cz_clock - old->cz_clock;
1000
	/*
1009
	time *= threshold * dev_priv->czclk_freq;
Line 1001... Line -...
1001
	 * Calculate overall C0 residency percentage
-
 
1002
	 * only if elapsed time is non zero
-
 
1003
	 */
-
 
1004
	if (elapsed_time) {
-
 
1005
		residency =
-
 
1006
			((max(elapsed_render, elapsed_media) * 100)
-
 
1007
				/ elapsed_time);
1010
 
1008
	}
1011
	/* Workload can be split between render + media, e.g. SwapBuffers
1009
 
-
 
1010
	return residency;
-
 
1011
}
-
 
1012
 
-
 
1013
/**
-
 
1014
 * vlv_calc_delay_from_C0_counters - Increase/Decrease freq based on GPU
-
 
1015
 * busy-ness calculated from C0 counters of render & media power wells
-
 
1016
 * @dev_priv: DRM device private
-
 
1017
 *
-
 
1018
 */
1012
	 * being blitted in X after being rendered in mesa. To account for
1019
static int vlv_calc_delay_from_C0_counters(struct drm_i915_private *dev_priv)
1013
	 * this we need to combine both engines into our activity counter.
1020
{
-
 
1021
	u32 residency_C0_up = 0, residency_C0_down = 0;
1014
	 */
Line -... Line 1015...
-
 
1015
	c0 = now->render_c0 - old->render_c0;
-
 
1016
	c0 += now->media_c0 - old->media_c0;
-
 
1017
	c0 *= mul * VLV_CZ_CLOCK_TO_MILLI_SEC;
-
 
1018
 
Line 1022... Line -...
1022
	int new_delay, adj;
-
 
1023
 
1019
	return c0 >= time;
1024
	dev_priv->rps.ei_interrupt_count++;
-
 
1025
 
-
 
1026
	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
1020
}
1027
 
-
 
Line 1028... Line 1021...
1028
 
1021
 
-
 
1022
void gen6_rps_reset_ei(struct drm_i915_private *dev_priv)
-
 
1023
{
Line -... Line 1024...
-
 
1024
	vlv_c0_read(dev_priv, &dev_priv->rps.down_ei);
1029
	if (dev_priv->rps.up_ei.cz_clock == 0) {
1025
	dev_priv->rps.up_ei = dev_priv->rps.down_ei;
1030
		vlv_c0_residency(dev_priv, &dev_priv->rps.up_ei);
1026
}
1031
		vlv_c0_residency(dev_priv, &dev_priv->rps.down_ei);
1027
 
1032
		return dev_priv->rps.cur_freq;
1028
static u32 vlv_wa_c0_ei(struct drm_i915_private *dev_priv, u32 pm_iir)
1033
	}
1029
{
1034
 
1030
	struct intel_rps_ei now;
Line -... Line 1031...
-
 
1031
	u32 events = 0;
1035
 
1032
 
1036
	/*
-
 
1037
	 * To down throttle, C0 residency should be less than down threshold
1033
	if ((pm_iir & (GEN6_PM_RP_DOWN_EI_EXPIRED | GEN6_PM_RP_UP_EI_EXPIRED)) == 0)
1038
	 * for continous EI intervals. So calculate down EI counters
1034
		return 0;
1039
	 * once in VLV_INT_COUNT_FOR_DOWN_EI
1035
 
1040
	 */
1036
	vlv_c0_read(dev_priv, &now);
1041
	if (dev_priv->rps.ei_interrupt_count == VLV_INT_COUNT_FOR_DOWN_EI) {
-
 
1042
 
1037
	if (now.cz_clock == 0)
1043
		dev_priv->rps.ei_interrupt_count = 0;
-
 
Line 1044... Line -...
1044
 
-
 
1045
		residency_C0_down = vlv_c0_residency(dev_priv,
1038
		return 0;
-
 
1039
 
Line -... Line 1040...
-
 
1040
	if (pm_iir & GEN6_PM_RP_DOWN_EI_EXPIRED) {
1046
						     &dev_priv->rps.down_ei);
1041
		if (!vlv_c0_above(dev_priv,
1047
	} else {
-
 
1048
		residency_C0_up = vlv_c0_residency(dev_priv,
1042
				  &dev_priv->rps.down_ei, &now,
1049
						   &dev_priv->rps.up_ei);
1043
				  dev_priv->rps.down_threshold))
1050
	}
-
 
1051
 
-
 
Line 1052... Line 1044...
1052
	new_delay = dev_priv->rps.cur_freq;
1044
			events |= GEN6_PM_RP_DOWN_THRESHOLD;
1053
 
-
 
1054
	adj = dev_priv->rps.last_adj;
1045
		dev_priv->rps.down_ei = now;
1055
	/* C0 residency is greater than UP threshold. Increase Frequency */
-
 
1056
	if (residency_C0_up >= VLV_RP_UP_EI_THRESHOLD) {
-
 
1057
		if (adj > 0)
1046
	}
1058
			adj *= 2;
-
 
1059
		else
-
 
1060
			adj = 1;
-
 
1061
 
-
 
1062
		if (dev_priv->rps.cur_freq < dev_priv->rps.max_freq_softlimit)
-
 
1063
			new_delay = dev_priv->rps.cur_freq + adj;
-
 
1064
 
-
 
Line 1065... Line 1047...
1065
		/*
1047
 
1066
		 * For better performance, jump directly
1048
	if (pm_iir & GEN6_PM_RP_UP_EI_EXPIRED) {
Line 1067... Line 1049...
1067
		 * to RPe if we're below it.
1049
		if (vlv_c0_above(dev_priv,
1068
		 */
1050
				 &dev_priv->rps.up_ei, &now,
1069
		if (new_delay < dev_priv->rps.efficient_freq)
1051
				 dev_priv->rps.up_threshold))
1070
			new_delay = dev_priv->rps.efficient_freq;
1052
			events |= GEN6_PM_RP_UP_THRESHOLD;
-
 
1053
		dev_priv->rps.up_ei = now;
-
 
1054
	}
1071
 
1055
 
1072
	} else if (!dev_priv->rps.ei_interrupt_count &&
-
 
Line 1073... Line 1056...
1073
			(residency_C0_down < VLV_RP_DOWN_EI_THRESHOLD)) {
1056
	return events;
1074
		if (adj < 0)
1057
}
1075
			adj *= 2;
1058
 
1076
		else
1059
static bool any_waiters(struct drm_i915_private *dev_priv)
Line 1101... Line 1084...
1101
	}
1084
	}
1102
	pm_iir = dev_priv->rps.pm_iir;
1085
	pm_iir = dev_priv->rps.pm_iir;
1103
	dev_priv->rps.pm_iir = 0;
1086
	dev_priv->rps.pm_iir = 0;
1104
	/* Make sure not to corrupt PMIMR state used by ringbuffer on GEN6 */
1087
	/* Make sure not to corrupt PMIMR state used by ringbuffer on GEN6 */
1105
		gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events);
1088
	gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events);
-
 
1089
	client_boost = dev_priv->rps.client_boost;
-
 
1090
	dev_priv->rps.client_boost = false;
1106
	spin_unlock_irq(&dev_priv->irq_lock);
1091
	spin_unlock_irq(&dev_priv->irq_lock);
Line 1107... Line 1092...
1107
 
1092
 
1108
	/* Make sure we didn't queue anything we're not going to process. */
1093
	/* Make sure we didn't queue anything we're not going to process. */
Line 1109... Line 1094...
1109
	WARN_ON(pm_iir & ~dev_priv->pm_rps_events);
1094
	WARN_ON(pm_iir & ~dev_priv->pm_rps_events);
1110
 
1095
 
Line 1111... Line 1096...
1111
	if ((pm_iir & dev_priv->pm_rps_events) == 0)
1096
	if ((pm_iir & dev_priv->pm_rps_events) == 0 && !client_boost)
Line -... Line 1097...
-
 
1097
		return;
-
 
1098
 
1112
		return;
1099
	mutex_lock(&dev_priv->rps.hw_lock);
-
 
1100
 
-
 
1101
	pm_iir |= vlv_wa_c0_ei(dev_priv, pm_iir);
-
 
1102
 
-
 
1103
	adj = dev_priv->rps.last_adj;
-
 
1104
	new_delay = dev_priv->rps.cur_freq;
-
 
1105
	min = dev_priv->rps.min_freq_softlimit;
-
 
1106
	max = dev_priv->rps.max_freq_softlimit;
1113
 
1107
 
1114
	mutex_lock(&dev_priv->rps.hw_lock);
1108
	if (client_boost) {
1115
 
1109
		new_delay = dev_priv->rps.max_freq_softlimit;
1116
	adj = dev_priv->rps.last_adj;
-
 
1117
	if (pm_iir & GEN6_PM_RP_UP_THRESHOLD) {
1110
		adj = 0;
1118
		if (adj > 0)
1111
	} else if (pm_iir & GEN6_PM_RP_UP_THRESHOLD) {
1119
			adj *= 2;
-
 
1120
		else {
-
 
1121
			/* CHV needs even encode values */
-
 
1122
			adj = IS_CHERRYVIEW(dev_priv->dev) ? 2 : 1;
1112
		if (adj > 0)
1123
		}
1113
			adj *= 2;
1124
		new_delay = dev_priv->rps.cur_freq + adj;
1114
		else /* CHV needs even encode values */
1125
 
1115
			adj = IS_CHERRYVIEW(dev_priv) ? 2 : 1;
1126
		/*
1116
		/*
1127
		 * For better performance, jump directly
1117
		 * For better performance, jump directly
-
 
1118
		 * to RPe if we're below it.
-
 
1119
		 */
-
 
1120
		if (new_delay < dev_priv->rps.efficient_freq - adj) {
-
 
1121
			new_delay = dev_priv->rps.efficient_freq;
1128
		 * to RPe if we're below it.
1122
			adj = 0;
1129
		 */
1123
		}
1130
		if (new_delay < dev_priv->rps.efficient_freq)
1124
	} else if (any_waiters(dev_priv)) {
1131
			new_delay = dev_priv->rps.efficient_freq;
1125
		adj = 0;
1132
	} else if (pm_iir & GEN6_PM_RP_DOWN_TIMEOUT) {
1126
	} else if (pm_iir & GEN6_PM_RP_DOWN_TIMEOUT) {
1133
		if (dev_priv->rps.cur_freq > dev_priv->rps.efficient_freq)
1127
		if (dev_priv->rps.cur_freq > dev_priv->rps.efficient_freq)
1134
			new_delay = dev_priv->rps.efficient_freq;
-
 
1135
		else
-
 
1136
			new_delay = dev_priv->rps.min_freq_softlimit;
1128
			new_delay = dev_priv->rps.efficient_freq;
1137
		adj = 0;
1129
		else
1138
	} else if (pm_iir & GEN6_PM_RP_UP_EI_EXPIRED) {
1130
			new_delay = dev_priv->rps.min_freq_softlimit;
1139
		new_delay = vlv_calc_delay_from_C0_counters(dev_priv);
-
 
1140
	} else if (pm_iir & GEN6_PM_RP_DOWN_THRESHOLD) {
1131
		adj = 0;
1141
		if (adj < 0)
1132
	} else if (pm_iir & GEN6_PM_RP_DOWN_THRESHOLD) {
1142
			adj *= 2;
-
 
1143
		else {
-
 
1144
			/* CHV needs even encode values */
1133
		if (adj < 0)
1145
			adj = IS_CHERRYVIEW(dev_priv->dev) ? -2 : -1;
1134
			adj *= 2;
1146
		}
1135
		else /* CHV needs even encode values */
Line -... Line 1136...
-
 
1136
			adj = IS_CHERRYVIEW(dev_priv) ? -2 : -1;
-
 
1137
	} else { /* unknown event */
1147
		new_delay = dev_priv->rps.cur_freq + adj;
1138
		adj = 0;
1148
	} else { /* unknown event */
1139
	}
1149
		new_delay = dev_priv->rps.cur_freq;
1140
 
1150
	}
1141
	dev_priv->rps.last_adj = adj;
1151
 
1142
 
1152
	/* sysfs frequency interfaces may have snuck in while servicing the
-
 
Line 1153... Line -...
1153
	 * interrupt
-
 
1154
	 */
-
 
1155
	new_delay = clamp_t(int, new_delay,
-
 
1156
			    dev_priv->rps.min_freq_softlimit,
-
 
1157
			    dev_priv->rps.max_freq_softlimit);
-
 
1158
 
1143
	/* sysfs frequency interfaces may have snuck in while servicing the
Line 1159... Line 1144...
1159
	dev_priv->rps.last_adj = new_delay - dev_priv->rps.cur_freq;
1144
	 * interrupt
1160
 
1145
	 */
Line 1259... Line 1244...
1259
			       struct drm_i915_private *dev_priv,
1244
			       struct drm_i915_private *dev_priv,
1260
			       u32 gt_iir)
1245
			       u32 gt_iir)
1261
{
1246
{
1262
	if (gt_iir &
1247
	if (gt_iir &
1263
	    (GT_RENDER_USER_INTERRUPT | GT_RENDER_PIPECTL_NOTIFY_INTERRUPT))
1248
	    (GT_RENDER_USER_INTERRUPT | GT_RENDER_PIPECTL_NOTIFY_INTERRUPT))
1264
		notify_ring(dev, &dev_priv->ring[RCS]);
1249
		notify_ring(&dev_priv->ring[RCS]);
1265
	if (gt_iir & ILK_BSD_USER_INTERRUPT)
1250
	if (gt_iir & ILK_BSD_USER_INTERRUPT)
1266
		notify_ring(dev, &dev_priv->ring[VCS]);
1251
		notify_ring(&dev_priv->ring[VCS]);
1267
}
1252
}
Line 1268... Line 1253...
1268
 
1253
 
1269
static void snb_gt_irq_handler(struct drm_device *dev,
1254
static void snb_gt_irq_handler(struct drm_device *dev,
1270
			       struct drm_i915_private *dev_priv,
1255
			       struct drm_i915_private *dev_priv,
1271
			       u32 gt_iir)
1256
			       u32 gt_iir)
Line 1272... Line 1257...
1272
{
1257
{
1273
 
1258
 
1274
	if (gt_iir &
1259
	if (gt_iir &
1275
	    (GT_RENDER_USER_INTERRUPT | GT_RENDER_PIPECTL_NOTIFY_INTERRUPT))
1260
	    (GT_RENDER_USER_INTERRUPT | GT_RENDER_PIPECTL_NOTIFY_INTERRUPT))
1276
		notify_ring(dev, &dev_priv->ring[RCS]);
1261
		notify_ring(&dev_priv->ring[RCS]);
1277
	if (gt_iir & GT_BSD_USER_INTERRUPT)
1262
	if (gt_iir & GT_BSD_USER_INTERRUPT)
1278
		notify_ring(dev, &dev_priv->ring[VCS]);
1263
		notify_ring(&dev_priv->ring[VCS]);
Line 1279... Line 1264...
1279
	if (gt_iir & GT_BLT_USER_INTERRUPT)
1264
	if (gt_iir & GT_BLT_USER_INTERRUPT)
1280
		notify_ring(dev, &dev_priv->ring[BCS]);
1265
		notify_ring(&dev_priv->ring[BCS]);
1281
 
1266
 
1282
	if (gt_iir & (GT_BLT_CS_ERROR_INTERRUPT |
1267
	if (gt_iir & (GT_BLT_CS_ERROR_INTERRUPT |
Line 1283... Line 1268...
1283
		      GT_BSD_CS_ERROR_INTERRUPT |
1268
		      GT_BSD_CS_ERROR_INTERRUPT |
1284
		      GT_RENDER_CS_MASTER_ERROR_INTERRUPT))
1269
		      GT_RENDER_CS_MASTER_ERROR_INTERRUPT))
1285
		DRM_DEBUG("Command parser error, gt_iir 0x%08x\n", gt_iir);
1270
		DRM_DEBUG("Command parser error, gt_iir 0x%08x\n", gt_iir);
Line 1286... Line 1271...
1286
 
1271
 
1287
	if (gt_iir & GT_PARITY_ERROR(dev))
-
 
1288
		ivybridge_parity_error_irq_handler(dev, gt_iir);
1272
	if (gt_iir & GT_PARITY_ERROR(dev))
1289
}
1273
		ivybridge_parity_error_irq_handler(dev, gt_iir);
1290
 
-
 
1291
static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
-
 
1292
				       struct drm_i915_private *dev_priv,
-
 
1293
				       u32 master_ctl)
1274
}
Line 1294... Line 1275...
1294
{
1275
 
1295
	struct intel_engine_cs *ring;
1276
static irqreturn_t gen8_gt_irq_handler(struct drm_i915_private *dev_priv,
1296
	u32 rcs, bcs, vcs;
1277
				       u32 master_ctl)
1297
	uint32_t tmp = 0;
1278
{
1298
	irqreturn_t ret = IRQ_NONE;
1279
	irqreturn_t ret = IRQ_NONE;
Line 1299... Line 1280...
1299
 
1280
 
1300
	if (master_ctl & (GEN8_GT_RCS_IRQ | GEN8_GT_BCS_IRQ)) {
1281
	if (master_ctl & (GEN8_GT_RCS_IRQ | GEN8_GT_BCS_IRQ)) {
1301
		tmp = I915_READ(GEN8_GT_IIR(0));
1282
		u32 tmp = I915_READ_FW(GEN8_GT_IIR(0));
1302
		if (tmp) {
1283
		if (tmp) {
1303
			I915_WRITE(GEN8_GT_IIR(0), tmp);
-
 
1304
			ret = IRQ_HANDLED;
-
 
1305
 
1284
			I915_WRITE_FW(GEN8_GT_IIR(0), tmp);
1306
			rcs = tmp >> GEN8_RCS_IRQ_SHIFT;
1285
			ret = IRQ_HANDLED;
1307
			ring = &dev_priv->ring[RCS];
1286
 
1308
			if (rcs & GT_RENDER_USER_INTERRUPT)
1287
			if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_RCS_IRQ_SHIFT))
1309
				notify_ring(dev, ring);
1288
				intel_lrc_irq_handler(&dev_priv->ring[RCS]);
1310
			if (rcs & GT_CONTEXT_SWITCH_INTERRUPT)
-
 
1311
				intel_execlists_handle_ctx_events(ring);
-
 
1312
 
1289
			if (tmp & (GT_RENDER_USER_INTERRUPT << GEN8_RCS_IRQ_SHIFT))
1313
			bcs = tmp >> GEN8_BCS_IRQ_SHIFT;
1290
				notify_ring(&dev_priv->ring[RCS]);
1314
			ring = &dev_priv->ring[BCS];
1291
 
Line 1315... Line 1292...
1315
			if (bcs & GT_RENDER_USER_INTERRUPT)
1292
			if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_BCS_IRQ_SHIFT))
1316
				notify_ring(dev, ring);
1293
				intel_lrc_irq_handler(&dev_priv->ring[BCS]);
1317
			if (bcs & GT_CONTEXT_SWITCH_INTERRUPT)
1294
			if (tmp & (GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT))
1318
				intel_execlists_handle_ctx_events(ring);
1295
				notify_ring(&dev_priv->ring[BCS]);
1319
		} else
1296
		} else
Line 1320... Line 1297...
1320
			DRM_ERROR("The master control interrupt lied (GT0)!\n");
1297
			DRM_ERROR("The master control interrupt lied (GT0)!\n");
1321
	}
1298
	}
1322
 
1299
 
1323
	if (master_ctl & (GEN8_GT_VCS1_IRQ | GEN8_GT_VCS2_IRQ)) {
1300
	if (master_ctl & (GEN8_GT_VCS1_IRQ | GEN8_GT_VCS2_IRQ)) {
1324
		tmp = I915_READ(GEN8_GT_IIR(1));
-
 
1325
		if (tmp) {
-
 
1326
			I915_WRITE(GEN8_GT_IIR(1), tmp);
1301
		u32 tmp = I915_READ_FW(GEN8_GT_IIR(1));
1327
			ret = IRQ_HANDLED;
1302
		if (tmp) {
1328
 
1303
			I915_WRITE_FW(GEN8_GT_IIR(1), tmp);
1329
			vcs = tmp >> GEN8_VCS1_IRQ_SHIFT;
1304
			ret = IRQ_HANDLED;
1330
			ring = &dev_priv->ring[VCS];
1305
 
1331
			if (vcs & GT_RENDER_USER_INTERRUPT)
-
 
1332
				notify_ring(dev, ring);
-
 
1333
			if (vcs & GT_CONTEXT_SWITCH_INTERRUPT)
1306
			if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS1_IRQ_SHIFT))
1334
				intel_execlists_handle_ctx_events(ring);
1307
				intel_lrc_irq_handler(&dev_priv->ring[VCS]);
1335
 
1308
			if (tmp & (GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT))
Line -... Line 1309...
-
 
1309
				notify_ring(&dev_priv->ring[VCS]);
-
 
1310
 
-
 
1311
			if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS2_IRQ_SHIFT))
-
 
1312
				intel_lrc_irq_handler(&dev_priv->ring[VCS2]);
-
 
1313
			if (tmp & (GT_RENDER_USER_INTERRUPT << GEN8_VCS2_IRQ_SHIFT))
-
 
1314
				notify_ring(&dev_priv->ring[VCS2]);
-
 
1315
		} else
-
 
1316
			DRM_ERROR("The master control interrupt lied (GT1)!\n");
-
 
1317
	}
-
 
1318
 
-
 
1319
	if (master_ctl & GEN8_GT_VECS_IRQ) {
-
 
1320
		u32 tmp = I915_READ_FW(GEN8_GT_IIR(3));
-
 
1321
		if (tmp) {
-
 
1322
			I915_WRITE_FW(GEN8_GT_IIR(3), tmp);
1336
			vcs = tmp >> GEN8_VCS2_IRQ_SHIFT;
1323
			ret = IRQ_HANDLED;
1337
			ring = &dev_priv->ring[VCS2];
1324
 
1338
			if (vcs & GT_RENDER_USER_INTERRUPT)
1325
			if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VECS_IRQ_SHIFT))
1339
				notify_ring(dev, ring);
1326
				intel_lrc_irq_handler(&dev_priv->ring[VECS]);
1340
			if (vcs & GT_CONTEXT_SWITCH_INTERRUPT)
1327
			if (tmp & (GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT))
1341
				intel_execlists_handle_ctx_events(ring);
1328
				notify_ring(&dev_priv->ring[VECS]);
1342
		} else
1329
		} else
1343
			DRM_ERROR("The master control interrupt lied (GT1)!\n");
1330
			DRM_ERROR("The master control interrupt lied (GT3)!\n");
1344
	}
1331
	}
1345
 
1332
 
Line 1346... Line -...
1346
	if (master_ctl & GEN8_GT_PM_IRQ) {
-
 
1347
		tmp = I915_READ(GEN8_GT_IIR(2));
-
 
1348
		if (tmp & dev_priv->pm_rps_events) {
-
 
1349
			I915_WRITE(GEN8_GT_IIR(2),
-
 
1350
				   tmp & dev_priv->pm_rps_events);
-
 
1351
			ret = IRQ_HANDLED;
-
 
1352
			gen6_rps_irq_handler(dev_priv, tmp);
-
 
1353
		} else
-
 
1354
			DRM_ERROR("The master control interrupt lied (PM)!\n");
-
 
1355
	}
-
 
1356
 
-
 
1357
	if (master_ctl & GEN8_GT_VECS_IRQ) {
-
 
1358
		tmp = I915_READ(GEN8_GT_IIR(3));
-
 
1359
		if (tmp) {
-
 
1360
			I915_WRITE(GEN8_GT_IIR(3), tmp);
-
 
1361
			ret = IRQ_HANDLED;
-
 
1362
 
1333
	if (master_ctl & GEN8_GT_PM_IRQ) {
1363
			vcs = tmp >> GEN8_VECS_IRQ_SHIFT;
1334
		u32 tmp = I915_READ_FW(GEN8_GT_IIR(2));
Line 1364... Line -...
1364
			ring = &dev_priv->ring[VECS];
-
 
1365
			if (vcs & GT_RENDER_USER_INTERRUPT)
-
 
1366
				notify_ring(dev, ring);
-
 
1367
			if (vcs & GT_CONTEXT_SWITCH_INTERRUPT)
1335
		if (tmp & dev_priv->pm_rps_events) {
1368
				intel_execlists_handle_ctx_events(ring);
1336
			I915_WRITE_FW(GEN8_GT_IIR(2),
1369
		} else
1337
				      tmp & dev_priv->pm_rps_events);
1370
			DRM_ERROR("The master control interrupt lied (GT3)!\n");
1338
			ret = IRQ_HANDLED;
1371
	}
-
 
1372
 
-
 
1373
	return ret;
1339
			gen6_rps_irq_handler(dev_priv, tmp);
1374
}
1340
		} else
1375
 
1341
			DRM_ERROR("The master control interrupt lied (PM)!\n");
1376
#define HPD_STORM_DETECT_PERIOD 1000
1342
	}
1377
#define HPD_STORM_THRESHOLD 5
1343
 
1378
 
1344
	return ret;
1379
static int pch_port_to_hotplug_shift(enum port port)
1345
}
1380
{
1346
 
1381
	switch (port) {
1347
static bool bxt_port_hotplug_long_detect(enum port port, u32 val)
Line 1382... Line 1348...
1382
	case PORT_A:
1348
{
1383
	case PORT_E:
1349
	switch (port) {
1384
	default:
1350
	case PORT_A:
1385
		return -1;
-
 
1386
	case PORT_B:
1351
		return val & PORTA_HOTPLUG_LONG_DETECT;
-
 
1352
	case PORT_B:
1387
		return 0;
1353
		return val & PORTB_HOTPLUG_LONG_DETECT;
1388
	case PORT_C:
1354
	case PORT_C:
-
 
1355
		return val & PORTC_HOTPLUG_LONG_DETECT;
-
 
1356
	default:
-
 
1357
		return false;
-
 
1358
	}
-
 
1359
}
-
 
1360
 
-
 
1361
static bool spt_port_hotplug2_long_detect(enum port port, u32 val)
-
 
1362
{
1389
		return 8;
1363
	switch (port) {
1390
	case PORT_D:
1364
	case PORT_E:
1391
		return 16;
1365
		return val & PORTE_HOTPLUG_LONG_DETECT;
1392
	}
1366
	default:
1393
}
1367
		return false;
-
 
1368
	}
-
 
1369
}
1394
 
1370
 
1395
static int i915_port_to_hotplug_shift(enum port port)
1371
static bool spt_port_hotplug_long_detect(enum port port, u32 val)
1396
{
1372
{
Line 1397... Line 1373...
1397
	switch (port) {
1373
	switch (port) {
1398
	case PORT_A:
1374
	case PORT_A:
1399
	case PORT_E:
1375
		return val & PORTA_HOTPLUG_LONG_DETECT;
1400
	default:
-
 
1401
		return -1;
-
 
1402
	case PORT_B:
-
 
1403
		return 17;
-
 
1404
	case PORT_C:
1376
	case PORT_B:
1405
		return 19;
1377
		return val & PORTB_HOTPLUG_LONG_DETECT;
1406
	case PORT_D:
1378
	case PORT_C:
1407
		return 21;
1379
		return val & PORTC_HOTPLUG_LONG_DETECT;
1408
	}
1380
	case PORT_D:
1409
}
1381
		return val & PORTD_HOTPLUG_LONG_DETECT;
Line 1410... Line 1382...
1410
 
1382
	default:
1411
static inline enum port get_port_from_pin(enum hpd_pin pin)
-
 
1412
{
-
 
1413
	switch (pin) {
-
 
1414
	case HPD_PORT_B:
1383
		return false;
1415
		return PORT_B;
-
 
1416
	case HPD_PORT_C:
-
 
1417
		return PORT_C;
1384
	}
1418
	case HPD_PORT_D:
-
 
1419
		return PORT_D;
-
 
1420
	default:
-
 
1421
		return PORT_A; /* no hpd */
-
 
1422
	}
-
 
1423
}
-
 
1424
 
1385
}
1425
static inline void intel_hpd_irq_handler(struct drm_device *dev,
-
 
1426
					    u32 hotplug_trigger,
-
 
1427
					 u32 dig_hotplug_reg,
-
 
1428
					    const u32 *hpd)
-
 
1429
{
-
 
1430
	struct drm_i915_private *dev_priv = dev->dev_private;
1386
 
1431
	int i;
-
 
1432
	enum port port;
1387
static bool ilk_port_hotplug_long_detect(enum port port, u32 val)
1433
	bool storm_detected = false;
-
 
1434
	bool queue_dig = false, queue_hp = false;
1388
{
1435
	u32 dig_shift;
-
 
1436
	u32 dig_port_mask = 0;
1389
	switch (port) {
1437
 
-
 
1438
	if (!hotplug_trigger)
-
 
1439
		return;
-
 
1440
 
1390
	case PORT_A:
1441
	DRM_DEBUG_DRIVER("hotplug event received, stat 0x%08x, dig 0x%08x\n",
1391
		return val & DIGITAL_PORTA_HOTPLUG_LONG_DETECT;
1442
			 hotplug_trigger, dig_hotplug_reg);
1392
	default:
1443
 
-
 
1444
	spin_lock(&dev_priv->irq_lock);
1393
		return false;
1445
	for (i = 1; i < HPD_NUM_PINS; i++) {
-
 
1446
		if (!(hpd[i] & hotplug_trigger))
-
 
1447
			continue;
-
 
1448
 
-
 
1449
		port = get_port_from_pin(i);
-
 
1450
		if (port && dev_priv->hpd_irq_port[port]) {
-
 
1451
			bool long_hpd;
-
 
1452
 
-
 
1453
			if (HAS_PCH_SPLIT(dev)) {
-
 
1454
				dig_shift = pch_port_to_hotplug_shift(port);
-
 
1455
				long_hpd = (dig_hotplug_reg >> dig_shift) & PORTB_HOTPLUG_LONG_DETECT;
-
 
1456
			} else {
-
 
1457
				dig_shift = i915_port_to_hotplug_shift(port);
-
 
1458
				long_hpd = (hotplug_trigger >> dig_shift) & PORTB_HOTPLUG_LONG_DETECT;
1394
	}
-
 
1395
}
-
 
1396
 
-
 
1397
static bool pch_port_hotplug_long_detect(enum port port, u32 val)
-
 
1398
{
-
 
1399
	switch (port) {
-
 
1400
	case PORT_B:
-
 
1401
		return val & PORTB_HOTPLUG_LONG_DETECT;
-
 
1402
	case PORT_C:
-
 
1403
		return val & PORTC_HOTPLUG_LONG_DETECT;
-
 
1404
	case PORT_D:
-
 
1405
		return val & PORTD_HOTPLUG_LONG_DETECT;
1459
			}
1406
	default:
1460
 
1407
		return false;
1461
			DRM_DEBUG_DRIVER("digital hpd port %c - %s\n",
1408
	}
Line 1462... Line -...
1462
					 port_name(port),
-
 
1463
					 long_hpd ? "long" : "short");
-
 
1464
			/* for long HPD pulses we want to have the digital queue happen,
-
 
1465
			   but we still want HPD storm detection to function. */
1409
}
1466
			if (long_hpd) {
1410
 
1467
				dev_priv->long_hpd_port_mask |= (1 << port);
1411
static bool i9xx_port_hotplug_long_detect(enum port port, u32 val)
1468
				dig_port_mask |= hpd[i];
1412
{
-
 
1413
	switch (port) {
1469
			} else {
1414
	case PORT_B:
1470
				/* for short HPD just trigger the digital queue */
1415
		return val & PORTB_HOTPLUG_INT_LONG_PULSE;
1471
				dev_priv->short_hpd_port_mask |= (1 << port);
1416
	case PORT_C:
1472
				hotplug_trigger &= ~hpd[i];
1417
		return val & PORTC_HOTPLUG_INT_LONG_PULSE;
1473
			}
1418
	case PORT_D:
-
 
1419
		return val & PORTD_HOTPLUG_INT_LONG_PULSE;
-
 
1420
	default:
-
 
1421
		return false;
-
 
1422
	}
Line -... Line 1423...
-
 
1423
}
-
 
1424
 
1474
			queue_dig = true;
1425
/*
1475
		}
-
 
Line 1476... Line 1426...
1476
	}
1426
 * Get a bit mask of pins that have triggered, and which ones may be long.
-
 
1427
 * This can be called multiple times with the same masks to accumulate
1477
 
1428
 * hotplug detection results from several registers.
1478
	for (i = 1; i < HPD_NUM_PINS; i++) {
1429
 *
Line 1479... Line 1430...
1479
		if (hpd[i] & hotplug_trigger &&
1430
 * Note that the caller is expected to zero out the masks initially.
1480
		    dev_priv->hpd_stats[i].hpd_mark == HPD_DISABLED) {
-
 
1481
			/*
-
 
1482
			 * On GMCH platforms the interrupt mask bits only
-
 
1483
			 * prevent irq generation, not the setting of the
-
 
1484
			 * hotplug bits itself. So only WARN about unexpected
-
 
1485
			 * interrupts on saner platforms.
-
 
1486
			 */
-
 
1487
			WARN_ONCE(INTEL_INFO(dev)->gen >= 5 && !IS_VALLEYVIEW(dev),
-
 
1488
			  "Received HPD interrupt (0x%08x) on pin %d (0x%08x) although disabled\n",
-
 
1489
			  hotplug_trigger, i, hpd[i]);
-
 
1490
 
-
 
1491
			continue;
-
 
1492
		}
-
 
1493
 
-
 
1494
		if (!(hpd[i] & hotplug_trigger) ||
1431
 */
1495
		    dev_priv->hpd_stats[i].hpd_mark != HPD_ENABLED)
-
 
1496
			continue;
-
 
1497
 
-
 
1498
		if (!(dig_port_mask & hpd[i])) {
-
 
1499
		dev_priv->hpd_event_bits |= (1 << i);
-
 
1500
			queue_hp = true;
1432
static void intel_get_hpd_pins(u32 *pin_mask, u32 *long_mask,
Line 1501... Line -...
1501
		}
-
 
1502
 
1433
			     u32 hotplug_trigger, u32 dig_hotplug_reg,
1503
		if (!time_in_range(jiffies, dev_priv->hpd_stats[i].hpd_last_jiffies,
1434
			     const u32 hpd[HPD_NUM_PINS],
Line 1504... Line -...
1504
                  dev_priv->hpd_stats[i].hpd_last_jiffies
-
 
1505
                  + msecs_to_jiffies(HPD_STORM_DETECT_PERIOD))) {
-
 
1506
			dev_priv->hpd_stats[i].hpd_last_jiffies = jiffies;
-
 
1507
           dev_priv->hpd_stats[i].hpd_cnt = 0;
-
 
1508
			DRM_DEBUG_KMS("Received HPD interrupt on PIN %d - cnt: 0\n", i);
-
 
1509
       } else if (dev_priv->hpd_stats[i].hpd_cnt > HPD_STORM_THRESHOLD) {
-
 
1510
           dev_priv->hpd_stats[i].hpd_mark = HPD_MARK_DISABLED;
-
 
1511
			dev_priv->hpd_event_bits &= ~(1 << i);
-
 
1512
           DRM_DEBUG_KMS("HPD interrupt storm detected on PIN %d\n", i);
1435
			     bool long_pulse_detect(enum port port, u32 val))
Line 1513... Line 1436...
1513
			storm_detected = true;
1436
{
1514
		} else {
1437
	enum port port;
1515
			dev_priv->hpd_stats[i].hpd_cnt++;
1438
	int i;
Line 1645... Line 1568...
1645
/* The RPS events need forcewake, so we add them to a work queue and mask their
1568
/* The RPS events need forcewake, so we add them to a work queue and mask their
1646
 * IMR bits until the work is done. Other interrupts can be processed without
1569
 * IMR bits until the work is done. Other interrupts can be processed without
1647
 * the work queue. */
1570
 * the work queue. */
1648
static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir)
1571
static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir)
1649
{
1572
{
1650
	/* TODO: RPS on GEN9+ is not supported yet. */
-
 
1651
	if (WARN_ONCE(INTEL_INFO(dev_priv)->gen >= 9,
-
 
1652
		      "GEN9+: unexpected RPS IRQ\n"))
-
 
1653
		return;
-
 
1654
 
-
 
1655
	if (pm_iir & dev_priv->pm_rps_events) {
1573
	if (pm_iir & dev_priv->pm_rps_events) {
1656
		spin_lock(&dev_priv->irq_lock);
1574
		spin_lock(&dev_priv->irq_lock);
1657
		gen6_disable_pm_irq(dev_priv, pm_iir & dev_priv->pm_rps_events);
1575
		gen6_disable_pm_irq(dev_priv, pm_iir & dev_priv->pm_rps_events);
1658
		if (dev_priv->rps.interrupts_enabled) {
1576
		if (dev_priv->rps.interrupts_enabled) {
1659
		dev_priv->rps.pm_iir |= pm_iir & dev_priv->pm_rps_events;
1577
			dev_priv->rps.pm_iir |= pm_iir & dev_priv->pm_rps_events;
Line 1665... Line 1583...
1665
	if (INTEL_INFO(dev_priv)->gen >= 8)
1583
	if (INTEL_INFO(dev_priv)->gen >= 8)
1666
		return;
1584
		return;
Line 1667... Line 1585...
1667
 
1585
 
1668
	if (HAS_VEBOX(dev_priv->dev)) {
1586
	if (HAS_VEBOX(dev_priv->dev)) {
1669
		if (pm_iir & PM_VEBOX_USER_INTERRUPT)
1587
		if (pm_iir & PM_VEBOX_USER_INTERRUPT)
Line 1670... Line 1588...
1670
			notify_ring(dev_priv->dev, &dev_priv->ring[VECS]);
1588
			notify_ring(&dev_priv->ring[VECS]);
1671
 
1589
 
1672
		if (pm_iir & PM_VEBOX_CS_ERROR_INTERRUPT)
1590
		if (pm_iir & PM_VEBOX_CS_ERROR_INTERRUPT)
1673
			DRM_DEBUG("Command parser error, pm_iir 0x%08x\n", pm_iir);
1591
			DRM_DEBUG("Command parser error, pm_iir 0x%08x\n", pm_iir);
Line 1674... Line 1592...
1674
	}
1592
	}
1675
}
1593
}
1676
 
1594
 
1677
static bool intel_pipe_handle_vblank(struct drm_device *dev, enum pipe pipe)
1595
static bool intel_pipe_handle_vblank(struct drm_device *dev, enum pipe pipe)
Line 1678... Line 1596...
1678
{
1596
{
1679
	if (!drm_handle_vblank(dev, pipe))
1597
//   if (!drm_handle_vblank(dev, pipe))
Line 1680... Line 1598...
1680
		return false;
1598
//       return false;
Line 1733... Line 1651...
1733
				I915_WRITE(reg, pipe_stats[pipe]);
1651
			I915_WRITE(reg, pipe_stats[pipe]);
1734
			}
1652
	}
1735
	spin_unlock(&dev_priv->irq_lock);
1653
	spin_unlock(&dev_priv->irq_lock);
Line 1736... Line 1654...
1736
 
1654
 
-
 
1655
	for_each_pipe(dev_priv, pipe) {
-
 
1656
		if (pipe_stats[pipe] & PIPE_START_VBLANK_INTERRUPT_STATUS &&
-
 
1657
		    intel_pipe_handle_vblank(dev, pipe))
Line -... Line 1658...
-
 
1658
            /*intel_check_page_flip(dev, pipe)*/;
-
 
1659
 
-
 
1660
		if (pipe_stats[pipe] & PLANE_FLIP_DONE_INT_STATUS_VLV) {
-
 
1661
//           intel_prepare_page_flip(dev, pipe);
Line 1737... Line 1662...
1737
	for_each_pipe(dev_priv, pipe) {
1662
//           intel_finish_page_flip(dev, pipe);
1738
 
1663
		}
Line 1739... Line 1664...
1739
 
1664
 
Line 1750... Line 1675...
1750
 
1675
 
1751
static void i9xx_hpd_irq_handler(struct drm_device *dev)
1676
static void i9xx_hpd_irq_handler(struct drm_device *dev)
1752
{
1677
{
1753
	struct drm_i915_private *dev_priv = dev->dev_private;
1678
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
1679
	u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT);
-
 
1680
	u32 pin_mask = 0, long_mask = 0;
-
 
1681
 
-
 
1682
	if (!hotplug_status)
Line 1754... Line -...
1754
	u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT);
-
 
1755
 
1683
		return;
1756
	if (hotplug_status) {
1684
 
1757
		I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status);
1685
	I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status);
1758
		/*
1686
	/*
1759
		 * Make sure hotplug status is cleared before we clear IIR, or else we
1687
	 * Make sure hotplug status is cleared before we clear IIR, or else we
1760
		 * may miss hotplug events.
1688
	 * may miss hotplug events.
Line 1761... Line 1689...
1761
		 */
1689
	 */
1762
		POSTING_READ(PORT_HOTPLUG_STAT);
1690
	POSTING_READ(PORT_HOTPLUG_STAT);
Line -... Line 1691...
-
 
1691
 
1763
 
1692
	if (IS_G4X(dev) || IS_VALLEYVIEW(dev)) {
1764
	if (IS_G4X(dev)) {
1693
		u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_G4X;
1765
		u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_G4X;
1694
 
Line 1766... Line 1695...
1766
 
1695
		if (hotplug_trigger) {
1767
			intel_hpd_irq_handler(dev, hotplug_trigger, 0, hpd_status_g4x);
1696
			intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger,
Line 1768... Line -...
1768
	} else {
-
 
1769
		u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_I915;
1697
					   hotplug_trigger, hpd_status_g4x,
1770
 
1698
					   i9xx_port_hotplug_long_detect);
-
 
1699
 
-
 
1700
//           intel_hpd_irq_handler(dev, pin_mask, long_mask);
-
 
1701
		}
-
 
1702
 
-
 
1703
		if (hotplug_status & DP_AUX_CHANNEL_MASK_INT_STATUS_G4X)
-
 
1704
			dp_aux_irq_handler(dev);
-
 
1705
	} else {
-
 
1706
		u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_I915;
-
 
1707
 
1771
			intel_hpd_irq_handler(dev, hotplug_trigger, 0, hpd_status_i915);
1708
		if (hotplug_trigger) {
1772
	}
1709
			intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger,
Line 1773... Line 1710...
1773
 
1710
					   hotplug_trigger, hpd_status_i915,
1774
	if ((IS_G4X(dev) || IS_VALLEYVIEW(dev)) &&
1711
					   i9xx_port_hotplug_long_detect);
1775
	    hotplug_status & DP_AUX_CHANNEL_MASK_INT_STATUS_G4X)
1712
//           intel_hpd_irq_handler(dev, pin_mask, long_mask);
1776
		dp_aux_irq_handler(dev);
1713
		}
1777
	}
1714
	}
1778
}
1715
}
Line -... Line 1716...
-
 
1716
 
-
 
1717
static irqreturn_t valleyview_irq_handler(int irq, void *arg)
-
 
1718
{
1779
 
1719
	struct drm_device *dev = arg;
1780
static irqreturn_t valleyview_irq_handler(int irq, void *arg)
1720
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 1781... Line 1721...
1781
{
1721
	u32 iir, gt_iir, pm_iir;
1782
	struct drm_device *dev = arg;
1722
	irqreturn_t ret = IRQ_NONE;
Line 1826... Line 1766...
1826
	struct drm_device *dev = arg;
1766
	struct drm_device *dev = arg;
1827
	struct drm_i915_private *dev_priv = dev->dev_private;
1767
	struct drm_i915_private *dev_priv = dev->dev_private;
1828
	u32 master_ctl, iir;
1768
	u32 master_ctl, iir;
1829
	irqreturn_t ret = IRQ_NONE;
1769
	irqreturn_t ret = IRQ_NONE;
Line -... Line 1770...
-
 
1770
 
-
 
1771
	if (!intel_irqs_enabled(dev_priv))
-
 
1772
		return IRQ_NONE;
1830
 
1773
 
1831
	for (;;) {
1774
	for (;;) {
1832
		master_ctl = I915_READ(GEN8_MASTER_IRQ) & ~GEN8_MASTER_IRQ_CONTROL;
1775
		master_ctl = I915_READ(GEN8_MASTER_IRQ) & ~GEN8_MASTER_IRQ_CONTROL;
Line 1833... Line 1776...
1833
		iir = I915_READ(VLV_IIR);
1776
		iir = I915_READ(VLV_IIR);
Line 1846... Line 1789...
1846
			if (iir & I915_DISPLAY_PORT_INTERRUPT)
1789
			if (iir & I915_DISPLAY_PORT_INTERRUPT)
1847
				i9xx_hpd_irq_handler(dev);
1790
				i9xx_hpd_irq_handler(dev);
1848
			I915_WRITE(VLV_IIR, iir);
1791
			I915_WRITE(VLV_IIR, iir);
1849
		}
1792
		}
Line 1850... Line 1793...
1850
 
1793
 
Line 1851... Line 1794...
1851
		gen8_gt_irq_handler(dev, dev_priv, master_ctl);
1794
		gen8_gt_irq_handler(dev_priv, master_ctl);
1852
 
1795
 
1853
		/* Call regardless, as some status bits might not be
1796
		/* Call regardless, as some status bits might not be
Line 1859... Line 1802...
1859
	}
1802
	}
Line 1860... Line 1803...
1860
 
1803
 
1861
	return ret;
1804
	return ret;
Line -... Line 1805...
-
 
1805
}
-
 
1806
 
-
 
1807
static void ibx_hpd_irq_handler(struct drm_device *dev, u32 hotplug_trigger,
-
 
1808
				const u32 hpd[HPD_NUM_PINS])
-
 
1809
{
-
 
1810
	struct drm_i915_private *dev_priv = to_i915(dev);
-
 
1811
	u32 dig_hotplug_reg, pin_mask = 0, long_mask = 0;
-
 
1812
 
-
 
1813
	dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG);
-
 
1814
	I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg);
-
 
1815
 
-
 
1816
	intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger,
-
 
1817
			   dig_hotplug_reg, hpd,
-
 
1818
			   pch_port_hotplug_long_detect);
-
 
1819
 
-
 
1820
//   intel_hpd_irq_handler(dev, pin_mask, long_mask);
1862
}
1821
}
1863
 
1822
 
1864
static void ibx_irq_handler(struct drm_device *dev, u32 pch_iir)
1823
static void ibx_irq_handler(struct drm_device *dev, u32 pch_iir)
1865
{
1824
{
1866
	struct drm_i915_private *dev_priv = dev->dev_private;
1825
	struct drm_i915_private *dev_priv = dev->dev_private;
1867
	int pipe;
-
 
1868
	u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK;
-
 
1869
	u32 dig_hotplug_reg;
-
 
1870
 
-
 
Line -... Line 1826...
-
 
1826
	int pipe;
1871
	dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG);
1827
	u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK;
Line 1872... Line 1828...
1872
	I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg);
1828
 
1873
 
1829
	if (hotplug_trigger)
1874
	intel_hpd_irq_handler(dev, hotplug_trigger, dig_hotplug_reg, hpd_ibx);
1830
		ibx_hpd_irq_handler(dev, hotplug_trigger, hpd_ibx);
1875
 
1831
 
Line 1961... Line 1917...
1961
static void cpt_irq_handler(struct drm_device *dev, u32 pch_iir)
1917
static void cpt_irq_handler(struct drm_device *dev, u32 pch_iir)
1962
{
1918
{
1963
	struct drm_i915_private *dev_priv = dev->dev_private;
1919
	struct drm_i915_private *dev_priv = dev->dev_private;
1964
	int pipe;
1920
	int pipe;
1965
	u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK_CPT;
1921
	u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK_CPT;
1966
	u32 dig_hotplug_reg;
-
 
1967
 
-
 
1968
	dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG);
-
 
1969
	I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg);
-
 
Line -... Line 1922...
-
 
1922
 
1970
 
1923
	if (hotplug_trigger)
Line 1971... Line 1924...
1971
	intel_hpd_irq_handler(dev, hotplug_trigger, dig_hotplug_reg, hpd_cpt);
1924
		ibx_hpd_irq_handler(dev, hotplug_trigger, hpd_cpt);
1972
 
1925
 
1973
	if (pch_iir & SDE_AUDIO_POWER_MASK_CPT) {
1926
	if (pch_iir & SDE_AUDIO_POWER_MASK_CPT) {
1974
		int port = ffs((pch_iir & SDE_AUDIO_POWER_MASK_CPT) >>
1927
		int port = ffs((pch_iir & SDE_AUDIO_POWER_MASK_CPT) >>
Line 1997... Line 1950...
1997
 
1950
 
1998
	if (pch_iir & SDE_ERROR_CPT)
1951
	if (pch_iir & SDE_ERROR_CPT)
1999
		cpt_serr_int_handler(dev);
1952
		cpt_serr_int_handler(dev);
Line -... Line 1953...
-
 
1953
}
-
 
1954
 
-
 
1955
static void spt_irq_handler(struct drm_device *dev, u32 pch_iir)
-
 
1956
{
-
 
1957
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
1958
	u32 hotplug_trigger = pch_iir & SDE_HOTPLUG_MASK_SPT &
-
 
1959
		~SDE_PORTE_HOTPLUG_SPT;
-
 
1960
	u32 hotplug2_trigger = pch_iir & SDE_PORTE_HOTPLUG_SPT;
-
 
1961
	u32 pin_mask = 0, long_mask = 0;
-
 
1962
 
-
 
1963
	if (hotplug_trigger) {
-
 
1964
		u32 dig_hotplug_reg;
-
 
1965
 
-
 
1966
		dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG);
-
 
1967
		I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg);
-
 
1968
 
-
 
1969
		intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger,
-
 
1970
				   dig_hotplug_reg, hpd_spt,
-
 
1971
				   spt_port_hotplug_long_detect);
-
 
1972
	}
-
 
1973
 
-
 
1974
	if (hotplug2_trigger) {
-
 
1975
		u32 dig_hotplug_reg;
-
 
1976
 
-
 
1977
		dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG2);
-
 
1978
		I915_WRITE(PCH_PORT_HOTPLUG2, dig_hotplug_reg);
-
 
1979
 
-
 
1980
		intel_get_hpd_pins(&pin_mask, &long_mask, hotplug2_trigger,
-
 
1981
				   dig_hotplug_reg, hpd_spt,
-
 
1982
				   spt_port_hotplug2_long_detect);
-
 
1983
	}
-
 
1984
 
-
 
1985
	if (pch_iir & SDE_GMBUS_CPT)
-
 
1986
		gmbus_irq_handler(dev);
-
 
1987
}
-
 
1988
 
-
 
1989
static void ilk_hpd_irq_handler(struct drm_device *dev, u32 hotplug_trigger,
-
 
1990
				const u32 hpd[HPD_NUM_PINS])
-
 
1991
{
-
 
1992
	struct drm_i915_private *dev_priv = to_i915(dev);
-
 
1993
	u32 dig_hotplug_reg, pin_mask = 0, long_mask = 0;
-
 
1994
 
-
 
1995
	dig_hotplug_reg = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL);
-
 
1996
	I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, dig_hotplug_reg);
-
 
1997
 
-
 
1998
	intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger,
-
 
1999
			   dig_hotplug_reg, hpd,
-
 
2000
			   ilk_port_hotplug_long_detect);
-
 
2001
 
2000
}
2002
}
2001
 
2003
 
2002
static void ilk_display_irq_handler(struct drm_device *dev, u32 de_iir)
2004
static void ilk_display_irq_handler(struct drm_device *dev, u32 de_iir)
2003
{
2005
{
-
 
2006
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
2007
	enum pipe pipe;
-
 
2008
	u32 hotplug_trigger = de_iir & DE_DP_A_HOTPLUG;
-
 
2009
 
Line 2004... Line 2010...
2004
	struct drm_i915_private *dev_priv = dev->dev_private;
2010
	if (hotplug_trigger)
2005
	enum pipe pipe;
2011
		ilk_hpd_irq_handler(dev, hotplug_trigger, hpd_ilk);
Line 2006... Line 2012...
2006
 
2012
 
Line 2012... Line 2018...
2012
 
2018
 
2013
	if (de_iir & DE_POISON)
2019
	if (de_iir & DE_POISON)
Line 2014... Line 2020...
2014
		DRM_ERROR("Poison interrupt\n");
2020
		DRM_ERROR("Poison interrupt\n");
-
 
2021
 
-
 
2022
	for_each_pipe(dev_priv, pipe) {
-
 
2023
		if (de_iir & DE_PIPE_VBLANK(pipe) &&
Line 2015... Line 2024...
2015
 
2024
		    intel_pipe_handle_vblank(dev, pipe))
2016
	for_each_pipe(dev_priv, pipe) {
2025
            /*intel_check_page_flip(dev, pipe)*/;
Line 2017... Line 2026...
2017
 
2026
 
Line 2047... Line 2056...
2047
 
2056
 
2048
static void ivb_display_irq_handler(struct drm_device *dev, u32 de_iir)
2057
static void ivb_display_irq_handler(struct drm_device *dev, u32 de_iir)
2049
{
2058
{
2050
	struct drm_i915_private *dev_priv = dev->dev_private;
2059
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
2060
	enum pipe pipe;
-
 
2061
	u32 hotplug_trigger = de_iir & DE_DP_A_HOTPLUG_IVB;
-
 
2062
 
-
 
2063
	if (hotplug_trigger)
Line 2051... Line 2064...
2051
	enum pipe pipe;
2064
		ilk_hpd_irq_handler(dev, hotplug_trigger, hpd_ivb);
2052
 
2065
 
Line 2053... Line 2066...
2053
	if (de_iir & DE_ERR_INT_IVB)
2066
	if (de_iir & DE_ERR_INT_IVB)
Line 2058... Line 2071...
2058
 
2071
 
2059
	if (de_iir & DE_GSE_IVB)
2072
	if (de_iir & DE_GSE_IVB)
Line 2060... Line 2073...
2060
		intel_opregion_asle_intr(dev);
2073
		intel_opregion_asle_intr(dev);
-
 
2074
 
-
 
2075
	for_each_pipe(dev_priv, pipe) {
-
 
2076
		if (de_iir & (DE_PIPE_VBLANK_IVB(pipe)) &&
Line 2061... Line 2077...
2061
 
2077
		    intel_pipe_handle_vblank(dev, pipe))
2062
	for_each_pipe(dev_priv, pipe) {
2078
            /*intel_check_page_flip(dev, pipe)*/;
2063
 
2079
 
2064
		/* plane/pipes map 1:1 on ilk+ */
2080
		/* plane/pipes map 1:1 on ilk+ */
Line 2092... Line 2108...
2092
	struct drm_device *dev = arg;
2108
	struct drm_device *dev = arg;
2093
	struct drm_i915_private *dev_priv = dev->dev_private;
2109
	struct drm_i915_private *dev_priv = dev->dev_private;
2094
	u32 de_iir, gt_iir, de_ier, sde_ier = 0;
2110
	u32 de_iir, gt_iir, de_ier, sde_ier = 0;
2095
	irqreturn_t ret = IRQ_NONE;
2111
	irqreturn_t ret = IRQ_NONE;
Line -... Line 2112...
-
 
2112
 
-
 
2113
	if (!intel_irqs_enabled(dev_priv))
-
 
2114
		return IRQ_NONE;
2096
 
2115
 
2097
	/* We get interrupts on unclaimed registers, so check for this before we
2116
	/* We get interrupts on unclaimed registers, so check for this before we
2098
	 * do any I915_{READ,WRITE}. */
2117
	 * do any I915_{READ,WRITE}. */
Line 2099... Line 2118...
2099
	intel_uncore_check_errors(dev);
2118
	intel_uncore_check_errors(dev);
Line 2153... Line 2172...
2153
	}
2172
	}
Line 2154... Line 2173...
2154
 
2173
 
2155
	return ret;
2174
	return ret;
Line -... Line 2175...
-
 
2175
}
-
 
2176
 
-
 
2177
static void bxt_hpd_irq_handler(struct drm_device *dev, u32 hotplug_trigger,
-
 
2178
				const u32 hpd[HPD_NUM_PINS])
-
 
2179
{
-
 
2180
	struct drm_i915_private *dev_priv = to_i915(dev);
-
 
2181
	u32 dig_hotplug_reg, pin_mask = 0, long_mask = 0;
-
 
2182
 
-
 
2183
	dig_hotplug_reg = I915_READ(PCH_PORT_HOTPLUG);
-
 
2184
	I915_WRITE(PCH_PORT_HOTPLUG, dig_hotplug_reg);
-
 
2185
 
-
 
2186
	intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger,
-
 
2187
			   dig_hotplug_reg, hpd,
-
 
2188
			   bxt_port_hotplug_long_detect);
-
 
2189
 
2156
}
2190
}
2157
 
2191
 
2158
static irqreturn_t gen8_irq_handler(int irq, void *arg)
2192
static irqreturn_t gen8_irq_handler(int irq, void *arg)
2159
{
2193
{
2160
	struct drm_device *dev = arg;
2194
	struct drm_device *dev = arg;
2161
	struct drm_i915_private *dev_priv = dev->dev_private;
2195
	struct drm_i915_private *dev_priv = dev->dev_private;
2162
	u32 master_ctl;
2196
	u32 master_ctl;
2163
	irqreturn_t ret = IRQ_NONE;
2197
	irqreturn_t ret = IRQ_NONE;
2164
	uint32_t tmp = 0;
2198
	uint32_t tmp = 0;
Line -... Line 2199...
-
 
2199
	enum pipe pipe;
-
 
2200
	u32 aux_mask = GEN8_AUX_CHANNEL_A;
-
 
2201
 
2165
	enum pipe pipe;
2202
	if (!intel_irqs_enabled(dev_priv))
2166
	u32 aux_mask = GEN8_AUX_CHANNEL_A;
2203
		return IRQ_NONE;
2167
 
2204
 
Line 2168... Line 2205...
2168
	if (IS_GEN9(dev))
2205
	if (INTEL_INFO(dev_priv)->gen >= 9)
2169
		aux_mask |=  GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C |
2206
		aux_mask |=  GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C |
2170
			GEN9_AUX_CHANNEL_D;
2207
			GEN9_AUX_CHANNEL_D;
2171
 
2208
 
Line 2172... Line 2209...
2172
	master_ctl = I915_READ(GEN8_MASTER_IRQ);
2209
	master_ctl = I915_READ_FW(GEN8_MASTER_IRQ);
2173
	master_ctl &= ~GEN8_MASTER_IRQ_CONTROL;
-
 
Line 2174... Line 2210...
2174
	if (!master_ctl)
2210
	master_ctl &= ~GEN8_MASTER_IRQ_CONTROL;
Line 2175... Line 2211...
2175
		return IRQ_NONE;
2211
	if (!master_ctl)
Line 2176... Line 2212...
2176
 
2212
		return IRQ_NONE;
2177
	I915_WRITE(GEN8_MASTER_IRQ, 0);
2213
 
2178
	POSTING_READ(GEN8_MASTER_IRQ);
2214
	I915_WRITE_FW(GEN8_MASTER_IRQ, 0);
2179
 
2215
 
Line 2196... Line 2232...
2196
	}
2232
	}
Line 2197... Line 2233...
2197
 
2233
 
2198
	if (master_ctl & GEN8_DE_PORT_IRQ) {
2234
	if (master_ctl & GEN8_DE_PORT_IRQ) {
2199
		tmp = I915_READ(GEN8_DE_PORT_IIR);
2235
		tmp = I915_READ(GEN8_DE_PORT_IIR);
-
 
2236
		if (tmp) {
-
 
2237
			bool found = false;
-
 
2238
			u32 hotplug_trigger = 0;
-
 
2239
 
-
 
2240
			if (IS_BROXTON(dev_priv))
-
 
2241
				hotplug_trigger = tmp & BXT_DE_PORT_HOTPLUG_MASK;
-
 
2242
			else if (IS_BROADWELL(dev_priv))
-
 
2243
				hotplug_trigger = tmp & GEN8_PORT_DP_A_HOTPLUG;
2200
		if (tmp) {
2244
 
2201
			I915_WRITE(GEN8_DE_PORT_IIR, tmp);
2245
			I915_WRITE(GEN8_DE_PORT_IIR, tmp);
Line 2202... Line 2246...
2202
			ret = IRQ_HANDLED;
2246
			ret = IRQ_HANDLED;
2203
 
2247
 
-
 
2248
			if (tmp & aux_mask) {
-
 
2249
				dp_aux_irq_handler(dev);
-
 
2250
				found = true;
-
 
2251
			}
-
 
2252
 
-
 
2253
			if (hotplug_trigger) {
2204
			if (tmp & aux_mask)
2254
				if (IS_BROXTON(dev))
-
 
2255
					bxt_hpd_irq_handler(dev, hotplug_trigger, hpd_bxt);
-
 
2256
				else
-
 
2257
					ilk_hpd_irq_handler(dev, hotplug_trigger, hpd_bdw);
-
 
2258
				found = true;
-
 
2259
			}
-
 
2260
 
-
 
2261
			if (IS_BROXTON(dev) && (tmp & BXT_DE_PORT_GMBUS)) {
-
 
2262
				gmbus_irq_handler(dev);
-
 
2263
				found = true;
-
 
2264
			}
2205
			dp_aux_irq_handler(dev);
2265
 
2206
			else
2266
			if (!found)
2207
			DRM_ERROR("Unexpected DE Port interrupt\n");
2267
				DRM_ERROR("Unexpected DE Port interrupt\n");
2208
		}
2268
		}
2209
		else
2269
		else
Line 2220... Line 2280...
2220
		if (pipe_iir) {
2280
		if (pipe_iir) {
2221
			ret = IRQ_HANDLED;
2281
			ret = IRQ_HANDLED;
2222
			I915_WRITE(GEN8_DE_PIPE_IIR(pipe), pipe_iir);
2282
			I915_WRITE(GEN8_DE_PIPE_IIR(pipe), pipe_iir);
Line 2223... Line 2283...
2223
 
2283
 
2224
 
2284
 
2225
			if (IS_GEN9(dev))
2285
			if (INTEL_INFO(dev_priv)->gen >= 9)
2226
				flip_done = pipe_iir & GEN9_PIPE_PLANE1_FLIP_DONE;
2286
				flip_done = pipe_iir & GEN9_PIPE_PLANE1_FLIP_DONE;
Line 2234... Line 2294...
2234
			if (pipe_iir & GEN8_PIPE_FIFO_UNDERRUN)
2294
			if (pipe_iir & GEN8_PIPE_FIFO_UNDERRUN)
2235
				intel_cpu_fifo_underrun_irq_handler(dev_priv,
2295
				intel_cpu_fifo_underrun_irq_handler(dev_priv,
2236
								    pipe);
2296
								    pipe);
Line 2237... Line 2297...
2237
 
2297
 
2238
 
2298
 
2239
			if (IS_GEN9(dev))
2299
			if (INTEL_INFO(dev_priv)->gen >= 9)
2240
				fault_errors = pipe_iir & GEN9_DE_PIPE_IRQ_FAULT_ERRORS;
2300
				fault_errors = pipe_iir & GEN9_DE_PIPE_IRQ_FAULT_ERRORS;
Line 2241... Line 2301...
2241
			else
2301
			else
Line 2247... Line 2307...
2247
				  pipe_iir & GEN8_DE_PIPE_IRQ_FAULT_ERRORS);
2307
					  pipe_iir & GEN8_DE_PIPE_IRQ_FAULT_ERRORS);
2248
		} else
2308
		} else
2249
			DRM_ERROR("The master control interrupt lied (DE PIPE)!\n");
2309
			DRM_ERROR("The master control interrupt lied (DE PIPE)!\n");
2250
	}
2310
	}
Line -... Line 2311...
-
 
2311
 
2251
 
2312
	if (HAS_PCH_SPLIT(dev) && !HAS_PCH_NOP(dev) &&
2252
	if (!HAS_PCH_NOP(dev) && master_ctl & GEN8_DE_PCH_IRQ) {
2313
	    master_ctl & GEN8_DE_PCH_IRQ) {
2253
		/*
2314
		/*
2254
		 * FIXME(BDW): Assume for now that the new interrupt handling
2315
		 * FIXME(BDW): Assume for now that the new interrupt handling
2255
		 * scheme also closed the SDE interrupt handling race we've seen
2316
		 * scheme also closed the SDE interrupt handling race we've seen
2256
		 * on older pch-split platforms. But this needs testing.
2317
		 * on older pch-split platforms. But this needs testing.
2257
		 */
2318
		 */
2258
		u32 pch_iir = I915_READ(SDEIIR);
2319
		u32 pch_iir = I915_READ(SDEIIR);
2259
		if (pch_iir) {
2320
		if (pch_iir) {
2260
			I915_WRITE(SDEIIR, pch_iir);
2321
			I915_WRITE(SDEIIR, pch_iir);
-
 
2322
			ret = IRQ_HANDLED;
-
 
2323
 
-
 
2324
			if (HAS_PCH_SPT(dev_priv))
-
 
2325
				spt_irq_handler(dev, pch_iir);
2261
			ret = IRQ_HANDLED;
2326
			else
2262
			cpt_irq_handler(dev, pch_iir);
2327
				cpt_irq_handler(dev, pch_iir);
2263
		} else
2328
		} else
Line 2264... Line 2329...
2264
			DRM_ERROR("The master control interrupt lied (SDE)!\n");
2329
			DRM_ERROR("The master control interrupt lied (SDE)!\n");
Line 2265... Line 2330...
2265
 
2330
 
2266
	}
2331
	}
Line 2267... Line 2332...
2267
 
2332
 
2268
	I915_WRITE(GEN8_MASTER_IRQ, GEN8_MASTER_IRQ_CONTROL);
2333
	I915_WRITE_FW(GEN8_MASTER_IRQ, GEN8_MASTER_IRQ_CONTROL);
Line 2269... Line 2334...
2269
	POSTING_READ(GEN8_MASTER_IRQ);
2334
	POSTING_READ_FW(GEN8_MASTER_IRQ);
Line 2296... Line 2361...
2296
	if (reset_completed)
2361
	if (reset_completed)
2297
		wake_up_all(&dev_priv->gpu_error.reset_queue);
2362
		wake_up_all(&dev_priv->gpu_error.reset_queue);
2298
}
2363
}
Line 2299... Line 2364...
2299
 
2364
 
2300
/**
2365
/**
2301
 * i915_error_work_func - do process context error handling work
2366
 * i915_reset_and_wakeup - do process context error handling work
2302
 * @work: work struct
2367
 * @dev: drm device
2303
 *
2368
 *
2304
 * Fire an error uevent so userspace can see that a hang or error
2369
 * Fire an error uevent so userspace can see that a hang or error
2305
 * was detected.
2370
 * was detected.
2306
 */
2371
 */
2307
static void i915_error_work_func(struct work_struct *work)
2372
static void i915_reset_and_wakeup(struct drm_device *dev)
2308
{
-
 
2309
	struct i915_gpu_error *error = container_of(work, struct i915_gpu_error,
-
 
2310
						    work);
2373
{
2311
	struct drm_i915_private *dev_priv =
-
 
2312
		container_of(error, struct drm_i915_private, gpu_error);
2374
	struct drm_i915_private *dev_priv = to_i915(dev);
2313
	struct drm_device *dev = dev_priv->dev;
2375
	struct i915_gpu_error *error = &dev_priv->gpu_error;
2314
	char *error_event[] = { I915_ERROR_UEVENT "=1", NULL };
2376
	char *error_event[] = { I915_ERROR_UEVENT "=1", NULL };
2315
	char *reset_event[] = { I915_RESET_UEVENT "=1", NULL };
2377
	char *reset_event[] = { I915_RESET_UEVENT "=1", NULL };
2316
	char *reset_done_event[] = { I915_ERROR_UEVENT "=0", NULL };
2378
	char *reset_done_event[] = { I915_ERROR_UEVENT "=0", NULL };
Line 2326... Line 2388...
2326
	 * the reset in-progress bit is only ever set by code outside of this
2388
	 * the reset in-progress bit is only ever set by code outside of this
2327
	 * work we don't need to worry about any other races.
2389
	 * work we don't need to worry about any other races.
2328
	 */
2390
	 */
2329
	if (i915_reset_in_progress(error) && !i915_terminally_wedged(error)) {
2391
	if (i915_reset_in_progress(error) && !i915_terminally_wedged(error)) {
2330
		DRM_DEBUG_DRIVER("resetting chip\n");
2392
		DRM_DEBUG_DRIVER("resetting chip\n");
-
 
2393
		intel_runtime_pm_get(dev_priv);
Line 2331... Line 2394...
2331
 
2394
 
2332
		/*
2395
		/*
2333
		 * All state reset _must_ be completed before we update the
2396
		 * All state reset _must_ be completed before we update the
2334
		 * reset counter, for otherwise waiters might miss the reset
2397
		 * reset counter, for otherwise waiters might miss the reset
2335
		 * pending state and not properly drop locks, resulting in
2398
		 * pending state and not properly drop locks, resulting in
2336
		 * deadlocks with the reset work.
2399
		 * deadlocks with the reset work.
2337
		 */
2400
		 */
Line 2338... Line 2401...
2338
//		ret = i915_reset(dev);
2401
//		ret = i915_reset(dev);
-
 
2402
 
-
 
2403
//		intel_finish_reset(dev);
Line 2339... Line 2404...
2339
 
2404
 
2340
//       intel_display_handle_reset(dev);
2405
		intel_runtime_pm_put(dev_priv);
2341
 
2406
 
2342
		if (ret == 0) {
2407
		if (ret == 0) {
Line 2348... Line 2413...
2348
			 * Since unlock operations are a one-sided barrier only,
2413
			 * Since unlock operations are a one-sided barrier only,
2349
			 * we need to insert a barrier here to order any seqno
2414
			 * we need to insert a barrier here to order any seqno
2350
			 * updates before
2415
			 * updates before
2351
			 * the counter increment.
2416
			 * the counter increment.
2352
			 */
2417
			 */
-
 
2418
			smp_mb__before_atomic();
2353
			atomic_inc(&dev_priv->gpu_error.reset_counter);
2419
			atomic_inc(&dev_priv->gpu_error.reset_counter);
Line 2354... Line 2420...
2354
 
2420
 
2355
		} else {
2421
		} else {
2356
			atomic_set_mask(I915_WEDGED, &error->reset_counter);
2422
			atomic_set_mask(I915_WEDGED, &error->reset_counter);
Line 2455... Line 2521...
2455
		I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT);
2521
		I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT);
2456
	}
2522
	}
2457
}
2523
}
Line 2458... Line 2524...
2458
 
2524
 
2459
/**
2525
/**
2460
 * i915_handle_error - handle an error interrupt
2526
 * i915_handle_error - handle a gpu error
2461
 * @dev: drm device
2527
 * @dev: drm device
2462
 *
2528
 *
2463
 * Do some basic checking of regsiter state at error interrupt time and
2529
 * Do some basic checking of register state at error time and
2464
 * dump it to the syslog.  Also call i915_capture_error_state() to make
2530
 * dump it to the syslog.  Also call i915_capture_error_state() to make
2465
 * sure we get a record and make it available in debugfs.  Fire a uevent
2531
 * sure we get a record and make it available in debugfs.  Fire a uevent
2466
 * so userspace knows something bad happened (should trigger collection
2532
 * so userspace knows something bad happened (should trigger collection
2467
 * of a ring dump etc.).
2533
 * of a ring dump etc.).
Line 2479... Line 2545...
2479
 
2545
 
2480
//	i915_capture_error_state(dev);
2546
//	i915_capture_error_state(dev);
Line 2481... Line 2547...
2481
	i915_report_and_clear_eir(dev);
2547
	i915_report_and_clear_eir(dev);
2482
 
2548
 
2483
	if (wedged) {
2549
	if (wedged) {
Line 2484... Line 2550...
2484
		atomic_set_mask(I915_RESET_IN_PROGRESS_FLAG,
2550
		atomic_or(I915_RESET_IN_PROGRESS_FLAG,
2485
				&dev_priv->gpu_error.reset_counter);
2551
				&dev_priv->gpu_error.reset_counter);
2486
 
2552
 
2487
		/*
2553
		/*
2488
		 * Wakeup waiting processes so that the reset work function
2554
		 * Wakeup waiting processes so that the reset function
2489
		 * i915_error_work_func doesn't deadlock trying to grab various
2555
		 * i915_reset_and_wakeup doesn't deadlock trying to grab
2490
		 * locks. By bumping the reset counter first, the woken
2556
		 * various locks. By bumping the reset counter first, the woken
2491
		 * processes will see a reset in progress and back off,
2557
		 * processes will see a reset in progress and back off,
2492
		 * releasing their locks and then wait for the reset completion.
2558
		 * releasing their locks and then wait for the reset completion.
Line 2498... Line 2564...
2498
		 * counter atomic_t.
2564
		 * counter atomic_t.
2499
		 */
2565
		 */
2500
		i915_error_wake_up(dev_priv, false);
2566
		i915_error_wake_up(dev_priv, false);
2501
	}
2567
	}
Line 2502... Line -...
2502
 
-
 
2503
	/*
-
 
2504
	 * Our reset work can grab modeset locks (since it needs to reset the
-
 
2505
	 * state of outstanding pagelips). Hence it must not be run on our own
-
 
2506
	 * dev-priv->wq work queue for otherwise the flush_work in the pageflip
2568
 
2507
	 * code will deadlock.
-
 
2508
	 */
-
 
2509
	schedule_work(&dev_priv->gpu_error.work);
2569
	i915_reset_and_wakeup(dev);
Line 2510... Line 2570...
2510
}
2570
}
2511
 
2571
 
2512
/* Called from drm generic code, passed 'crtc' which
2572
/* Called from drm generic code, passed 'crtc' which
2513
 * we use as a pipe index
2573
 * we use as a pipe index
2514
 */
2574
 */
2515
static int i915_enable_vblank(struct drm_device *dev, int pipe)
2575
static int i915_enable_vblank(struct drm_device *dev, unsigned int pipe)
2516
{
2576
{
Line 2517... Line -...
2517
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
2518
	unsigned long irqflags;
-
 
2519
 
-
 
2520
	if (!i915_pipe_enabled(dev, pipe))
2577
	struct drm_i915_private *dev_priv = dev->dev_private;
2521
		return -EINVAL;
2578
	unsigned long irqflags;
2522
 
2579
 
2523
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2580
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2524
	if (INTEL_INFO(dev)->gen >= 4)
2581
	if (INTEL_INFO(dev)->gen >= 4)
Line 2530... Line 2587...
2530
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2587
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
Line 2531... Line 2588...
2531
 
2588
 
2532
	return 0;
2589
	return 0;
Line 2533... Line 2590...
2533
}
2590
}
2534
 
2591
 
2535
static int ironlake_enable_vblank(struct drm_device *dev, int pipe)
2592
static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe)
2536
{
2593
{
2537
	struct drm_i915_private *dev_priv = dev->dev_private;
2594
	struct drm_i915_private *dev_priv = dev->dev_private;
2538
	unsigned long irqflags;
2595
	unsigned long irqflags;
Line 2539... Line -...
2539
	uint32_t bit = (INTEL_INFO(dev)->gen >= 7) ? DE_PIPE_VBLANK_IVB(pipe) :
-
 
2540
						     DE_PIPE_VBLANK(pipe);
-
 
2541
 
-
 
2542
	if (!i915_pipe_enabled(dev, pipe))
2596
	uint32_t bit = (INTEL_INFO(dev)->gen >= 7) ? DE_PIPE_VBLANK_IVB(pipe) :
2543
		return -EINVAL;
2597
						     DE_PIPE_VBLANK(pipe);
2544
 
2598
 
Line 2545... Line 2599...
2545
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2599
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2546
	ironlake_enable_display_irq(dev_priv, bit);
2600
	ironlake_enable_display_irq(dev_priv, bit);
Line 2547... Line 2601...
2547
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2601
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2548
 
2602
 
2549
	return 0;
2603
	return 0;
2550
}
2604
}
Line 2551... Line -...
2551
 
-
 
2552
static int valleyview_enable_vblank(struct drm_device *dev, int pipe)
-
 
2553
{
-
 
2554
	struct drm_i915_private *dev_priv = dev->dev_private;
2605
 
2555
	unsigned long irqflags;
2606
static int valleyview_enable_vblank(struct drm_device *dev, unsigned int pipe)
2556
 
2607
{
2557
	if (!i915_pipe_enabled(dev, pipe))
2608
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 2558... Line 2609...
2558
		return -EINVAL;
2609
	unsigned long irqflags;
2559
 
2610
 
Line 2560... Line 2611...
2560
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2611
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2561
	i915_enable_pipestat(dev_priv, pipe,
2612
	i915_enable_pipestat(dev_priv, pipe,
2562
			     PIPE_START_VBLANK_INTERRUPT_STATUS);
2613
			     PIPE_START_VBLANK_INTERRUPT_STATUS);
2563
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2614
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
Line 2564... Line -...
2564
 
-
 
2565
	return 0;
-
 
2566
}
-
 
2567
 
2615
 
2568
static int gen8_enable_vblank(struct drm_device *dev, int pipe)
2616
	return 0;
2569
{
2617
}
2570
	struct drm_i915_private *dev_priv = dev->dev_private;
2618
 
2571
	unsigned long irqflags;
2619
static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe)
Line 2582... Line 2630...
2582
}
2630
}
Line 2583... Line 2631...
2583
 
2631
 
2584
/* Called from drm generic code, passed 'crtc' which
2632
/* Called from drm generic code, passed 'crtc' which
2585
 * we use as a pipe index
2633
 * we use as a pipe index
2586
 */
2634
 */
2587
static void i915_disable_vblank(struct drm_device *dev, int pipe)
2635
static void i915_disable_vblank(struct drm_device *dev, unsigned int pipe)
2588
{
2636
{
2589
	struct drm_i915_private *dev_priv = dev->dev_private;
2637
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 2590... Line 2638...
2590
	unsigned long irqflags;
2638
	unsigned long irqflags;
Line 2594... Line 2642...
2594
			      PIPE_VBLANK_INTERRUPT_STATUS |
2642
			      PIPE_VBLANK_INTERRUPT_STATUS |
2595
			      PIPE_START_VBLANK_INTERRUPT_STATUS);
2643
			      PIPE_START_VBLANK_INTERRUPT_STATUS);
2596
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2644
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2597
}
2645
}
Line 2598... Line 2646...
2598
 
2646
 
2599
static void ironlake_disable_vblank(struct drm_device *dev, int pipe)
2647
static void ironlake_disable_vblank(struct drm_device *dev, unsigned int pipe)
2600
{
2648
{
2601
	struct drm_i915_private *dev_priv = dev->dev_private;
2649
	struct drm_i915_private *dev_priv = dev->dev_private;
2602
	unsigned long irqflags;
2650
	unsigned long irqflags;
2603
	uint32_t bit = (INTEL_INFO(dev)->gen >= 7) ? DE_PIPE_VBLANK_IVB(pipe) :
2651
	uint32_t bit = (INTEL_INFO(dev)->gen >= 7) ? DE_PIPE_VBLANK_IVB(pipe) :
Line 2606... Line 2654...
2606
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2654
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2607
	ironlake_disable_display_irq(dev_priv, bit);
2655
	ironlake_disable_display_irq(dev_priv, bit);
2608
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2656
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2609
}
2657
}
Line 2610... Line 2658...
2610
 
2658
 
2611
static void valleyview_disable_vblank(struct drm_device *dev, int pipe)
2659
static void valleyview_disable_vblank(struct drm_device *dev, unsigned int pipe)
2612
{
2660
{
2613
	struct drm_i915_private *dev_priv = dev->dev_private;
2661
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 2614... Line 2662...
2614
	unsigned long irqflags;
2662
	unsigned long irqflags;
2615
 
2663
 
2616
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2664
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2617
	i915_disable_pipestat(dev_priv, pipe,
2665
	i915_disable_pipestat(dev_priv, pipe,
2618
			      PIPE_START_VBLANK_INTERRUPT_STATUS);
2666
			      PIPE_START_VBLANK_INTERRUPT_STATUS);
Line 2619... Line 2667...
2619
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2667
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2620
}
2668
}
2621
 
2669
 
2622
static void gen8_disable_vblank(struct drm_device *dev, int pipe)
2670
static void gen8_disable_vblank(struct drm_device *dev, unsigned int pipe)
Line 2623... Line -...
2623
{
-
 
2624
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
2625
	unsigned long irqflags;
-
 
2626
 
2671
{
2627
	if (!i915_pipe_enabled(dev, pipe))
2672
	struct drm_i915_private *dev_priv = dev->dev_private;
2628
		return;
2673
	unsigned long irqflags;
2629
 
2674
 
2630
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2675
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
2631
	dev_priv->de_irq_mask[pipe] |= GEN8_PIPE_VBLANK;
2676
	dev_priv->de_irq_mask[pipe] |= GEN8_PIPE_VBLANK;
Line 2632... Line -...
2632
	I915_WRITE(GEN8_DE_PIPE_IMR(pipe), dev_priv->de_irq_mask[pipe]);
-
 
2633
	POSTING_READ(GEN8_DE_PIPE_IMR(pipe));
-
 
2634
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
-
 
2635
}
-
 
2636
 
-
 
2637
static u32
-
 
2638
ring_last_seqno(struct intel_engine_cs *ring)
-
 
2639
{
2677
	I915_WRITE(GEN8_DE_PIPE_IMR(pipe), dev_priv->de_irq_mask[pipe]);
2640
	return list_entry(ring->request_list.prev,
2678
	POSTING_READ(GEN8_DE_PIPE_IMR(pipe));
2641
			  struct drm_i915_gem_request, list)->seqno;
2679
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2642
}
2680
}
2643
 
2681
 
2644
static bool
2682
static bool
Line 2645... Line 2683...
2645
ring_idle(struct intel_engine_cs *ring, u32 seqno)
2683
ring_idle(struct intel_engine_cs *ring, u32 seqno)
2646
{
2684
{
2647
	return (list_empty(&ring->request_list) ||
2685
	return (list_empty(&ring->request_list) ||
Line 2699... Line 2737...
2699
	struct drm_i915_private *dev_priv = ring->dev->dev_private;
2737
	struct drm_i915_private *dev_priv = ring->dev->dev_private;
2700
	u32 cmd, ipehr, head;
2738
	u32 cmd, ipehr, head;
2701
	u64 offset = 0;
2739
	u64 offset = 0;
2702
	int i, backwards;
2740
	int i, backwards;
Line -... Line 2741...
-
 
2741
 
-
 
2742
	/*
-
 
2743
	 * This function does not support execlist mode - any attempt to
-
 
2744
	 * proceed further into this function will result in a kernel panic
-
 
2745
	 * when dereferencing ring->buffer, which is not set up in execlist
-
 
2746
	 * mode.
-
 
2747
	 *
-
 
2748
	 * The correct way of doing it would be to derive the currently
-
 
2749
	 * executing ring buffer from the current context, which is derived
-
 
2750
	 * from the currently running request. Unfortunately, to get the
-
 
2751
	 * current request we would have to grab the struct_mutex before doing
-
 
2752
	 * anything else, which would be ill-advised since some other thread
-
 
2753
	 * might have grabbed it already and managed to hang itself, causing
-
 
2754
	 * the hang checker to deadlock.
-
 
2755
	 *
-
 
2756
	 * Therefore, this function does not support execlist mode in its
-
 
2757
	 * current form. Just return NULL and move on.
-
 
2758
	 */
-
 
2759
	if (ring->buffer == NULL)
-
 
2760
		return NULL;
2703
 
2761
 
2704
	ipehr = I915_READ(RING_IPEHR(ring->mmio_base));
2762
	ipehr = I915_READ(RING_IPEHR(ring->mmio_base));
2705
	if (!ipehr_is_semaphore_wait(ring->dev, ipehr))
2763
	if (!ipehr_is_semaphore_wait(ring->dev, ipehr))
Line 2706... Line 2764...
2706
		return NULL;
2764
		return NULL;
Line 2829... Line 2887...
2829
	}
2887
	}
Line 2830... Line 2888...
2830
 
2888
 
2831
	return HANGCHECK_HUNG;
2889
	return HANGCHECK_HUNG;
Line 2832... Line 2890...
2832
}
2890
}
2833
 
2891
 
2834
/**
2892
/*
2835
 * This is called when the chip hasn't reported back with completed
2893
 * This is called when the chip hasn't reported back with completed
2836
 * batchbuffers in a long time. We keep track per ring seqno progress and
2894
 * batchbuffers in a long time. We keep track per ring seqno progress and
2837
 * if there are no progress, hangcheck score for that ring is increased.
2895
 * if there are no progress, hangcheck score for that ring is increased.
2838
 * Further, acthd is inspected to see if the ring is stuck. On stuck case
2896
 * Further, acthd is inspected to see if the ring is stuck. On stuck case
2839
 * we kick the ring. If we see no progress on three subsequent calls
2897
 * we kick the ring. If we see no progress on three subsequent calls
2840
 * we assume chip is wedged and try to fix it by resetting the chip.
2898
 * we assume chip is wedged and try to fix it by resetting the chip.
2841
 */
2899
 */
2842
static void i915_hangcheck_elapsed(unsigned long data)
2900
static void i915_hangcheck_elapsed(struct work_struct *work)
-
 
2901
{
-
 
2902
	struct drm_i915_private *dev_priv =
2843
{
2903
		container_of(work, typeof(*dev_priv),
2844
	struct drm_device *dev = (struct drm_device *)data;
2904
			     gpu_error.hangcheck_work.work);
2845
	struct drm_i915_private *dev_priv = dev->dev_private;
2905
	struct drm_device *dev = dev_priv->dev;
2846
	struct intel_engine_cs *ring;
2906
	struct intel_engine_cs *ring;
2847
	int i;
2907
	int i;
2848
	int busy_count = 0, rings_hung = 0;
2908
	int busy_count = 0, rings_hung = 0;
Line 2866... Line 2926...
2866
 
2926
 
2867
		if (ring->hangcheck.seqno == seqno) {
2927
		if (ring->hangcheck.seqno == seqno) {
2868
			if (ring_idle(ring, seqno)) {
2928
			if (ring_idle(ring, seqno)) {
Line 2869... Line 2929...
2869
				ring->hangcheck.action = HANGCHECK_IDLE;
2929
				ring->hangcheck.action = HANGCHECK_IDLE;
2870
 
2930
 
-
 
2931
				if (waitqueue_active(&ring->irq_queue)) {
-
 
2932
					/* Issue a wake-up to catch stuck h/w. */
2871
//               if (waitqueue_active(&ring->irq_queue)) {
2933
					if (!test_and_set_bit(ring->id, &dev_priv->gpu_error.missed_irq_rings)) {
2872
					/* Issue a wake-up to catch stuck h/w. */
2934
						if (!(dev_priv->gpu_error.test_irq_rings & intel_ring_flag(ring)))
-
 
2935
							DRM_ERROR("Hangcheck timer elapsed... %s idle\n",
-
 
2936
								  ring->name);
-
 
2937
						else
2873
//                   DRM_ERROR("Hangcheck timer elapsed... %s idle\n",
2938
							DRM_INFO("Fake missed irq on %s\n",
-
 
2939
								 ring->name);
-
 
2940
						wake_up_all(&ring->irq_queue);
-
 
2941
					}
2874
//                         ring->name);
2942
					/* Safeguard against driver failure */
2875
//                   wake_up_all(&ring->irq_queue);
2943
					ring->hangcheck.score += BUSY;
2876
//               } else
2944
				} else
2877
					busy = false;
2945
					busy = false;
2878
			} else {
2946
			} else {
2879
				/* We always increment the hangcheck score
2947
				/* We always increment the hangcheck score
Line 3002... Line 3070...
3002
 
3070
 
3003
static void vlv_display_irq_reset(struct drm_i915_private *dev_priv)
3071
static void vlv_display_irq_reset(struct drm_i915_private *dev_priv)
3004
{
3072
{
Line 3005... Line 3073...
3005
	enum pipe pipe;
3073
	enum pipe pipe;
3006
 
3074
 
Line 3007... Line 3075...
3007
	I915_WRITE(PORT_HOTPLUG_EN, 0);
3075
	i915_hotplug_interrupt_update(dev_priv, 0xFFFFFFFF, 0);
3008
	I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
3076
	I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
Line 3055... Line 3123...
3055
 
3123
 
3056
	GEN5_IRQ_RESET(GEN8_DE_PORT_);
3124
	GEN5_IRQ_RESET(GEN8_DE_PORT_);
3057
	GEN5_IRQ_RESET(GEN8_DE_MISC_);
3125
	GEN5_IRQ_RESET(GEN8_DE_MISC_);
Line -... Line 3126...
-
 
3126
	GEN5_IRQ_RESET(GEN8_PCU_);
3058
	GEN5_IRQ_RESET(GEN8_PCU_);
3127
 
3059
 
3128
	if (HAS_PCH_SPLIT(dev))
Line 3060... Line 3129...
3060
	ibx_irq_reset(dev);
3129
		ibx_irq_reset(dev);
-
 
3130
}
3061
}
3131
 
3062
 
3132
void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
Line 3063... Line 3133...
3063
void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv)
3133
				     unsigned int pipe_mask)
-
 
3134
{
-
 
3135
	uint32_t extra_ier = GEN8_PIPE_VBLANK | GEN8_PIPE_FIFO_UNDERRUN;
-
 
3136
 
-
 
3137
	spin_lock_irq(&dev_priv->irq_lock);
-
 
3138
	if (pipe_mask & 1 << PIPE_A)
3064
{
3139
		GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_A,
-
 
3140
				  dev_priv->de_irq_mask[PIPE_A],
3065
	uint32_t extra_ier = GEN8_PIPE_VBLANK | GEN8_PIPE_FIFO_UNDERRUN;
3141
				  ~dev_priv->de_irq_mask[PIPE_A] | extra_ier);
-
 
3142
	if (pipe_mask & 1 << PIPE_B)
3066
 
3143
		GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_B,
-
 
3144
				  dev_priv->de_irq_mask[PIPE_B],
3067
	spin_lock_irq(&dev_priv->irq_lock);
3145
				  ~dev_priv->de_irq_mask[PIPE_B] | extra_ier);
3068
	GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_B, dev_priv->de_irq_mask[PIPE_B],
3146
	if (pipe_mask & 1 << PIPE_C)
3069
			  ~dev_priv->de_irq_mask[PIPE_B] | extra_ier);
3147
		GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_C,
Line 3070... Line 3148...
3070
	GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_C, dev_priv->de_irq_mask[PIPE_C],
3148
				  dev_priv->de_irq_mask[PIPE_C],
Line 3086... Line 3164...
3086
	I915_WRITE(DPINVGTT, DPINVGTT_STATUS_MASK_CHV);
3164
	I915_WRITE(DPINVGTT, DPINVGTT_STATUS_MASK_CHV);
Line 3087... Line 3165...
3087
 
3165
 
3088
	vlv_display_irq_reset(dev_priv);
3166
	vlv_display_irq_reset(dev_priv);
Line -... Line 3167...
-
 
3167
}
-
 
3168
 
-
 
3169
static u32 intel_hpd_enabled_irqs(struct drm_device *dev,
-
 
3170
				  const u32 hpd[HPD_NUM_PINS])
-
 
3171
{
-
 
3172
	struct drm_i915_private *dev_priv = to_i915(dev);
-
 
3173
	struct intel_encoder *encoder;
-
 
3174
	u32 enabled_irqs = 0;
-
 
3175
 
-
 
3176
	for_each_intel_encoder(dev, encoder)
-
 
3177
		if (dev_priv->hotplug.stats[encoder->hpd_pin].state == HPD_ENABLED)
-
 
3178
			enabled_irqs |= hpd[encoder->hpd_pin];
-
 
3179
 
-
 
3180
	return enabled_irqs;
3089
}
3181
}
3090
 
3182
 
3091
static void ibx_hpd_irq_setup(struct drm_device *dev)
3183
static void ibx_hpd_irq_setup(struct drm_device *dev)
3092
{
-
 
3093
	struct drm_i915_private *dev_priv = dev->dev_private;
3184
{
Line 3094... Line 3185...
3094
	struct intel_encoder *intel_encoder;
3185
	struct drm_i915_private *dev_priv = dev->dev_private;
3095
	u32 hotplug_irqs, hotplug, enabled_irqs = 0;
3186
	u32 hotplug_irqs, hotplug, enabled_irqs;
3096
 
-
 
3097
	if (HAS_PCH_IBX(dev)) {
-
 
3098
		hotplug_irqs = SDE_HOTPLUG_MASK;
3187
 
3099
		for_each_intel_encoder(dev, intel_encoder)
3188
	if (HAS_PCH_IBX(dev)) {
3100
			if (dev_priv->hpd_stats[intel_encoder->hpd_pin].hpd_mark == HPD_ENABLED)
3189
		hotplug_irqs = SDE_HOTPLUG_MASK;
3101
				enabled_irqs |= hpd_ibx[intel_encoder->hpd_pin];
-
 
3102
	} else {
-
 
3103
		hotplug_irqs = SDE_HOTPLUG_MASK_CPT;
3190
		enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_ibx);
3104
		for_each_intel_encoder(dev, intel_encoder)
3191
	} else {
Line 3105... Line 3192...
3105
			if (dev_priv->hpd_stats[intel_encoder->hpd_pin].hpd_mark == HPD_ENABLED)
3192
		hotplug_irqs = SDE_HOTPLUG_MASK_CPT;
Line 3106... Line 3193...
3106
				enabled_irqs |= hpd_cpt[intel_encoder->hpd_pin];
3193
		enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_cpt);
3107
	}
3194
	}
3108
 
3195
 
3109
	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
-
 
3110
 
3196
	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
3111
	/*
3197
 
3112
 * Enable digital hotplug on the PCH, and configure the DP short pulse
3198
	/*
3113
 * duration to 2ms (which is the minimum in the Display Port spec)
3199
	 * Enable digital hotplug on the PCH, and configure the DP short pulse
3114
 *
3200
	 * duration to 2ms (which is the minimum in the Display Port spec).
3115
 * This register is the same on all known PCH chips.
3201
	 * The pulse duration bits are reserved on LPT+.
3116
 */
3202
	 */
-
 
3203
	hotplug = I915_READ(PCH_PORT_HOTPLUG);
-
 
3204
	hotplug &= ~(PORTD_PULSE_DURATION_MASK|PORTC_PULSE_DURATION_MASK|PORTB_PULSE_DURATION_MASK);
-
 
3205
	hotplug |= PORTD_HOTPLUG_ENABLE | PORTD_PULSE_DURATION_2ms;
-
 
3206
	hotplug |= PORTC_HOTPLUG_ENABLE | PORTC_PULSE_DURATION_2ms;
-
 
3207
	hotplug |= PORTB_HOTPLUG_ENABLE | PORTB_PULSE_DURATION_2ms;
-
 
3208
	/*
-
 
3209
	 * When CPU and PCH are on the same package, port A
-
 
3210
	 * HPD must be enabled in both north and south.
-
 
3211
	 */
-
 
3212
	if (HAS_PCH_LPT_LP(dev))
-
 
3213
		hotplug |= PORTA_HOTPLUG_ENABLE;
-
 
3214
	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
-
 
3215
}
-
 
3216
 
-
 
3217
static void spt_hpd_irq_setup(struct drm_device *dev)
-
 
3218
{
-
 
3219
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3220
	u32 hotplug_irqs, hotplug, enabled_irqs;
-
 
3221
 
-
 
3222
	hotplug_irqs = SDE_HOTPLUG_MASK_SPT;
-
 
3223
	enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_spt);
-
 
3224
 
-
 
3225
	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
-
 
3226
 
-
 
3227
	/* Enable digital hotplug on the PCH */
-
 
3228
	hotplug = I915_READ(PCH_PORT_HOTPLUG);
-
 
3229
	hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE |
-
 
3230
		PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE;
-
 
3231
	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
-
 
3232
 
-
 
3233
	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
-
 
3234
	hotplug |= PORTE_HOTPLUG_ENABLE;
-
 
3235
	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
-
 
3236
}
-
 
3237
 
-
 
3238
static void ilk_hpd_irq_setup(struct drm_device *dev)
-
 
3239
{
-
 
3240
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3241
	u32 hotplug_irqs, hotplug, enabled_irqs;
-
 
3242
 
-
 
3243
	if (INTEL_INFO(dev)->gen >= 8) {
-
 
3244
		hotplug_irqs = GEN8_PORT_DP_A_HOTPLUG;
-
 
3245
		enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_bdw);
-
 
3246
 
-
 
3247
		bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
-
 
3248
	} else if (INTEL_INFO(dev)->gen >= 7) {
-
 
3249
		hotplug_irqs = DE_DP_A_HOTPLUG_IVB;
-
 
3250
		enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_ivb);
-
 
3251
 
-
 
3252
		ilk_update_display_irq(dev_priv, hotplug_irqs, enabled_irqs);
-
 
3253
	} else {
-
 
3254
		hotplug_irqs = DE_DP_A_HOTPLUG;
-
 
3255
		enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_ilk);
-
 
3256
 
-
 
3257
		ilk_update_display_irq(dev_priv, hotplug_irqs, enabled_irqs);
-
 
3258
	}
-
 
3259
 
-
 
3260
	/*
-
 
3261
	 * Enable digital hotplug on the CPU, and configure the DP short pulse
-
 
3262
	 * duration to 2ms (which is the minimum in the Display Port spec)
-
 
3263
	 * The pulse duration bits are reserved on HSW+.
-
 
3264
	 */
-
 
3265
	hotplug = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL);
-
 
3266
	hotplug &= ~DIGITAL_PORTA_PULSE_DURATION_MASK;
-
 
3267
	hotplug |= DIGITAL_PORTA_HOTPLUG_ENABLE | DIGITAL_PORTA_PULSE_DURATION_2ms;
-
 
3268
	I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, hotplug);
-
 
3269
 
-
 
3270
	ibx_hpd_irq_setup(dev);
-
 
3271
}
-
 
3272
 
-
 
3273
static void bxt_hpd_irq_setup(struct drm_device *dev)
-
 
3274
{
-
 
3275
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3276
	u32 hotplug_irqs, hotplug, enabled_irqs;
-
 
3277
 
-
 
3278
	enabled_irqs = intel_hpd_enabled_irqs(dev, hpd_bxt);
-
 
3279
	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
-
 
3280
 
3117
	hotplug = I915_READ(PCH_PORT_HOTPLUG);
3281
	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
3118
	hotplug &= ~(PORTD_PULSE_DURATION_MASK|PORTC_PULSE_DURATION_MASK|PORTB_PULSE_DURATION_MASK);
3282
 
Line 3119... Line 3283...
3119
	hotplug |= PORTD_HOTPLUG_ENABLE | PORTD_PULSE_DURATION_2ms;
3283
	hotplug = I915_READ(PCH_PORT_HOTPLUG);
3120
	hotplug |= PORTC_HOTPLUG_ENABLE | PORTC_PULSE_DURATION_2ms;
3284
	hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |
Line 3133... Line 3297...
3133
	if (HAS_PCH_IBX(dev))
3297
	if (HAS_PCH_IBX(dev))
3134
		mask = SDE_GMBUS | SDE_AUX_MASK | SDE_POISON;
3298
		mask = SDE_GMBUS | SDE_AUX_MASK | SDE_POISON;
3135
	else
3299
	else
3136
		mask = SDE_GMBUS_CPT | SDE_AUX_MASK_CPT;
3300
		mask = SDE_GMBUS_CPT | SDE_AUX_MASK_CPT;
Line 3137... Line 3301...
3137
 
3301
 
3138
	GEN5_ASSERT_IIR_IS_ZERO(SDEIIR);
3302
	gen5_assert_iir_is_zero(dev_priv, SDEIIR);
3139
	I915_WRITE(SDEIMR, ~mask);
3303
	I915_WRITE(SDEIMR, ~mask);
Line 3140... Line 3304...
3140
}
3304
}
3141
 
3305
 
Line 3185... Line 3349...
3185
		display_mask = (DE_MASTER_IRQ_CONTROL | DE_GSE_IVB |
3349
		display_mask = (DE_MASTER_IRQ_CONTROL | DE_GSE_IVB |
3186
				DE_PCH_EVENT_IVB | DE_PLANEC_FLIP_DONE_IVB |
3350
				DE_PCH_EVENT_IVB | DE_PLANEC_FLIP_DONE_IVB |
3187
		DE_PLANEB_FLIP_DONE_IVB |
3351
				DE_PLANEB_FLIP_DONE_IVB |
3188
				DE_PLANEA_FLIP_DONE_IVB | DE_AUX_CHANNEL_A_IVB);
3352
				DE_PLANEA_FLIP_DONE_IVB | DE_AUX_CHANNEL_A_IVB);
3189
		extra_mask = (DE_PIPEC_VBLANK_IVB | DE_PIPEB_VBLANK_IVB |
3353
		extra_mask = (DE_PIPEC_VBLANK_IVB | DE_PIPEB_VBLANK_IVB |
3190
			      DE_PIPEA_VBLANK_IVB | DE_ERR_INT_IVB);
3354
			      DE_PIPEA_VBLANK_IVB | DE_ERR_INT_IVB |
-
 
3355
			      DE_DP_A_HOTPLUG_IVB);
3191
	} else {
3356
	} else {
3192
		display_mask = (DE_MASTER_IRQ_CONTROL | DE_GSE | DE_PCH_EVENT |
3357
		display_mask = (DE_MASTER_IRQ_CONTROL | DE_GSE | DE_PCH_EVENT |
3193
				DE_PLANEA_FLIP_DONE | DE_PLANEB_FLIP_DONE |
3358
				DE_PLANEA_FLIP_DONE | DE_PLANEB_FLIP_DONE |
3194
				DE_AUX_CHANNEL_A |
3359
				DE_AUX_CHANNEL_A |
3195
				DE_PIPEB_CRC_DONE | DE_PIPEA_CRC_DONE |
3360
				DE_PIPEB_CRC_DONE | DE_PIPEA_CRC_DONE |
3196
				DE_POISON);
3361
				DE_POISON);
3197
		extra_mask = DE_PIPEA_VBLANK | DE_PIPEB_VBLANK | DE_PCU_EVENT |
3362
		extra_mask = (DE_PIPEA_VBLANK | DE_PIPEB_VBLANK | DE_PCU_EVENT |
3198
				DE_PIPEB_FIFO_UNDERRUN | DE_PIPEA_FIFO_UNDERRUN;
3363
			      DE_PIPEB_FIFO_UNDERRUN | DE_PIPEA_FIFO_UNDERRUN |
-
 
3364
			      DE_DP_A_HOTPLUG);
3199
	}
3365
	}
Line 3200... Line 3366...
3200
 
3366
 
Line 3201... Line 3367...
3201
	dev_priv->irq_mask = ~display_mask;
3367
	dev_priv->irq_mask = ~display_mask;
Line 3320... Line 3486...
3320
 
3486
 
3321
static void vlv_display_irq_postinstall(struct drm_i915_private *dev_priv)
3487
static void vlv_display_irq_postinstall(struct drm_i915_private *dev_priv)
3322
{
3488
{
Line 3323... Line 3489...
3323
	dev_priv->irq_mask = ~0;
3489
	dev_priv->irq_mask = ~0;
3324
 
3490
 
Line 3325... Line 3491...
3325
	I915_WRITE(PORT_HOTPLUG_EN, 0);
3491
	i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0);
3326
	POSTING_READ(PORT_HOTPLUG_EN);
3492
	POSTING_READ(PORT_HOTPLUG_EN);
3327
 
3493
 
Line 3389... Line 3555...
3389
 
3555
 
3390
static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
3556
static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
3391
{
3557
{
3392
	uint32_t de_pipe_masked = GEN8_PIPE_CDCLK_CRC_DONE;
3558
	uint32_t de_pipe_masked = GEN8_PIPE_CDCLK_CRC_DONE;
3393
	uint32_t de_pipe_enables;
-
 
3394
	int pipe;
3559
	uint32_t de_pipe_enables;
-
 
3560
	u32 de_port_masked = GEN8_AUX_CHANNEL_A;
-
 
3561
	u32 de_port_enables;
Line 3395... Line 3562...
3395
	u32 aux_en = GEN8_AUX_CHANNEL_A;
3562
	enum pipe pipe;
3396
 
3563
 
3397
	if (IS_GEN9(dev_priv)) {
3564
	if (INTEL_INFO(dev_priv)->gen >= 9) {
3398
		de_pipe_masked |= GEN9_PIPE_PLANE1_FLIP_DONE |
3565
		de_pipe_masked |= GEN9_PIPE_PLANE1_FLIP_DONE |
3399
				  GEN9_DE_PIPE_IRQ_FAULT_ERRORS;
3566
				  GEN9_DE_PIPE_IRQ_FAULT_ERRORS;
-
 
3567
		de_port_masked |= GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C |
-
 
3568
				  GEN9_AUX_CHANNEL_D;
3400
		aux_en |= GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C |
3569
		if (IS_BROXTON(dev_priv))
3401
			GEN9_AUX_CHANNEL_D;
3570
			de_port_masked |= BXT_DE_PORT_GMBUS;
3402
	} else
3571
	} else {
-
 
3572
		de_pipe_masked |= GEN8_PIPE_PRIMARY_FLIP_DONE |
Line 3403... Line 3573...
3403
		de_pipe_masked |= GEN8_PIPE_PRIMARY_FLIP_DONE |
3573
				  GEN8_DE_PIPE_IRQ_FAULT_ERRORS;
3404
		GEN8_DE_PIPE_IRQ_FAULT_ERRORS;
3574
	}
Line -... Line 3575...
-
 
3575
 
-
 
3576
	de_pipe_enables = de_pipe_masked | GEN8_PIPE_VBLANK |
-
 
3577
					   GEN8_PIPE_FIFO_UNDERRUN;
-
 
3578
 
-
 
3579
	de_port_enables = de_port_masked;
-
 
3580
	if (IS_BROXTON(dev_priv))
3405
 
3581
		de_port_enables |= BXT_DE_PORT_HOTPLUG_MASK;
3406
	de_pipe_enables = de_pipe_masked | GEN8_PIPE_VBLANK |
3582
	else if (IS_BROADWELL(dev_priv))
3407
		GEN8_PIPE_FIFO_UNDERRUN;
3583
		de_port_enables |= GEN8_PORT_DP_A_HOTPLUG;
Line 3408... Line 3584...
3408
 
3584
 
Line 3415... Line 3591...
3415
				POWER_DOMAIN_PIPE(pipe)))
3591
				POWER_DOMAIN_PIPE(pipe)))
3416
			GEN8_IRQ_INIT_NDX(DE_PIPE, pipe,
3592
			GEN8_IRQ_INIT_NDX(DE_PIPE, pipe,
3417
					  dev_priv->de_irq_mask[pipe],
3593
					  dev_priv->de_irq_mask[pipe],
3418
				  de_pipe_enables);
3594
					  de_pipe_enables);
Line 3419... Line 3595...
3419
 
3595
 
3420
	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~aux_en, aux_en);
3596
	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
Line 3421... Line 3597...
3421
}
3597
}
3422
 
3598
 
3423
static int gen8_irq_postinstall(struct drm_device *dev)
3599
static int gen8_irq_postinstall(struct drm_device *dev)
Line -... Line 3600...
-
 
3600
{
3424
{
3601
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 3425... Line 3602...
3425
	struct drm_i915_private *dev_priv = dev->dev_private;
3602
 
3426
 
3603
	if (HAS_PCH_SPLIT(dev))
Line -... Line 3604...
-
 
3604
		ibx_irq_pre_postinstall(dev);
3427
	ibx_irq_pre_postinstall(dev);
3605
 
Line 3428... Line 3606...
3428
 
3606
	gen8_gt_irq_postinstall(dev_priv);
3429
	gen8_gt_irq_postinstall(dev_priv);
3607
	gen8_de_irq_postinstall(dev_priv);
Line 3541... Line 3719...
3541
	/* Unmask the interrupts that we always want on. */
3719
	/* Unmask the interrupts that we always want on. */
3542
	dev_priv->irq_mask =
3720
	dev_priv->irq_mask =
3543
		~(I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
3721
		~(I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
3544
		  I915_DISPLAY_PIPE_B_EVENT_INTERRUPT |
3722
		  I915_DISPLAY_PIPE_B_EVENT_INTERRUPT |
3545
		  I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
3723
		  I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
3546
		  I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT |
3724
		  I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT);
3547
		  I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT);
-
 
3548
	I915_WRITE16(IMR, dev_priv->irq_mask);
3725
	I915_WRITE16(IMR, dev_priv->irq_mask);
Line 3549... Line 3726...
3549
 
3726
 
3550
	I915_WRITE16(IER,
3727
	I915_WRITE16(IER,
3551
		     I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
3728
		     I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
3552
		     I915_DISPLAY_PIPE_B_EVENT_INTERRUPT |
-
 
3553
		     I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT |
3729
		     I915_DISPLAY_PIPE_B_EVENT_INTERRUPT |
3554
		     I915_USER_INTERRUPT);
3730
		     I915_USER_INTERRUPT);
Line 3555... Line 3731...
3555
	POSTING_READ16(IER);
3731
	POSTING_READ16(IER);
3556
 
3732
 
Line 3571... Line 3747...
3571
			       int plane, int pipe, u32 iir)
3747
			       int plane, int pipe, u32 iir)
3572
{
3748
{
3573
	struct drm_i915_private *dev_priv = dev->dev_private;
3749
	struct drm_i915_private *dev_priv = dev->dev_private;
3574
	u16 flip_pending = DISPLAY_PLANE_FLIP_PENDING(plane);
3750
	u16 flip_pending = DISPLAY_PLANE_FLIP_PENDING(plane);
Line 3575... Line 3751...
3575
 
3751
 
3576
//   if (!drm_handle_vblank(dev, pipe))
3752
	if (!intel_pipe_handle_vblank(dev, pipe))
Line 3577... Line 3753...
3577
       return false;
3753
		return false;
3578
 
3754
 
Line 3579... Line -...
3579
	if ((iir & flip_pending) == 0)
-
 
3580
		goto check_page_flip;
-
 
3581
 
3755
	if ((iir & flip_pending) == 0)
3582
//   intel_prepare_page_flip(dev, pipe);
3756
		goto check_page_flip;
3583
 
3757
 
3584
	/* We detect FlipDone by looking for the change in PendingFlip from '1'
3758
	/* We detect FlipDone by looking for the change in PendingFlip from '1'
3585
	 * to '0' on the following vblank, i.e. IIR has the Pendingflip
3759
	 * to '0' on the following vblank, i.e. IIR has the Pendingflip
3586
	 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence
3760
	 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence
3587
	 * the flip is completed (no longer pending). Since this doesn't raise
3761
	 * the flip is completed (no longer pending). Since this doesn't raise
3588
	 * an interrupt per se, we watch for the change at vblank.
3762
	 * an interrupt per se, we watch for the change at vblank.
Line -... Line 3763...
-
 
3763
	 */
3589
	 */
3764
	if (I915_READ16(ISR) & flip_pending)
3590
	if (I915_READ16(ISR) & flip_pending)
3765
		goto check_page_flip;
Line 3591... Line 3766...
3591
		goto check_page_flip;
3766
 
3592
 
3767
//   intel_prepare_page_flip(dev, plane);
3593
	intel_finish_page_flip(dev, pipe);
3768
//   intel_finish_page_flip(dev, pipe);
Line 3607... Line 3782...
3607
	int pipe;
3782
	int pipe;
3608
	u16 flip_mask =
3783
	u16 flip_mask =
3609
		I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
3784
		I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
3610
		I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
3785
		I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
Line -... Line 3786...
-
 
3786
 
-
 
3787
	if (!intel_irqs_enabled(dev_priv))
-
 
3788
		return IRQ_NONE;
3611
 
3789
 
3612
	iir = I915_READ16(IIR);
3790
	iir = I915_READ16(IIR);
3613
	if (iir == 0)
3791
	if (iir == 0)
Line 3614... Line 3792...
3614
		return IRQ_NONE;
3792
		return IRQ_NONE;
Line 3637... Line 3815...
3637
 
3815
 
3638
		I915_WRITE16(IIR, iir & ~flip_mask);
3816
		I915_WRITE16(IIR, iir & ~flip_mask);
Line 3639... Line 3817...
3639
		new_iir = I915_READ16(IIR); /* Flush posted writes */
3817
		new_iir = I915_READ16(IIR); /* Flush posted writes */
3640
 
3818
 
Line 3641... Line 3819...
3641
		if (iir & I915_USER_INTERRUPT)
3819
		if (iir & I915_USER_INTERRUPT)
3642
			notify_ring(dev, &dev_priv->ring[RCS]);
3820
			notify_ring(&dev_priv->ring[RCS]);
3643
 
3821
 
3644
		for_each_pipe(dev_priv, pipe) {
3822
		for_each_pipe(dev_priv, pipe) {
Line 3685... Line 3863...
3685
{
3863
{
3686
	struct drm_i915_private *dev_priv = dev->dev_private;
3864
	struct drm_i915_private *dev_priv = dev->dev_private;
3687
	int pipe;
3865
	int pipe;
Line 3688... Line 3866...
3688
 
3866
 
3689
	if (I915_HAS_HOTPLUG(dev)) {
3867
	if (I915_HAS_HOTPLUG(dev)) {
3690
		I915_WRITE(PORT_HOTPLUG_EN, 0);
3868
		i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0);
3691
		I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
3869
		I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
Line 3692... Line 3870...
3692
	}
3870
	}
3693
 
3871
 
Line 3710... Line 3888...
3710
	dev_priv->irq_mask =
3888
	dev_priv->irq_mask =
3711
		~(I915_ASLE_INTERRUPT |
3889
		~(I915_ASLE_INTERRUPT |
3712
		  I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
3890
		  I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
3713
		  I915_DISPLAY_PIPE_B_EVENT_INTERRUPT |
3891
		  I915_DISPLAY_PIPE_B_EVENT_INTERRUPT |
3714
		  I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
3892
		  I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
3715
		  I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT |
3893
		  I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT);
3716
		  I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT);
-
 
Line 3717... Line 3894...
3717
 
3894
 
3718
	enable_mask =
3895
	enable_mask =
3719
		I915_ASLE_INTERRUPT |
3896
		I915_ASLE_INTERRUPT |
3720
		I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
3897
		I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
3721
		I915_DISPLAY_PIPE_B_EVENT_INTERRUPT |
-
 
3722
		I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT |
3898
		I915_DISPLAY_PIPE_B_EVENT_INTERRUPT |
Line 3723... Line 3899...
3723
		I915_USER_INTERRUPT;
3899
		I915_USER_INTERRUPT;
3724
 
3900
 
3725
	if (I915_HAS_HOTPLUG(dev)) {
3901
	if (I915_HAS_HOTPLUG(dev)) {
Line 3726... Line 3902...
3726
		I915_WRITE(PORT_HOTPLUG_EN, 0);
3902
		i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0);
3727
		POSTING_READ(PORT_HOTPLUG_EN);
3903
		POSTING_READ(PORT_HOTPLUG_EN);
3728
 
3904
 
Line 3755... Line 3931...
3755
			       int plane, int pipe, u32 iir)
3931
			       int plane, int pipe, u32 iir)
3756
{
3932
{
3757
	struct drm_i915_private *dev_priv = dev->dev_private;
3933
	struct drm_i915_private *dev_priv = dev->dev_private;
3758
	u32 flip_pending = DISPLAY_PLANE_FLIP_PENDING(plane);
3934
	u32 flip_pending = DISPLAY_PLANE_FLIP_PENDING(plane);
Line 3759... Line -...
3759
 
-
 
3760
//   if (!drm_handle_vblank(dev, pipe))
3935
 
Line 3761... Line 3936...
3761
		return false;
3936
	return false;
3762
 
3937
 
Line 3763... Line -...
3763
	if ((iir & flip_pending) == 0)
-
 
3764
		goto check_page_flip;
-
 
3765
 
3938
	if ((iir & flip_pending) == 0)
3766
//   intel_prepare_page_flip(dev, plane);
3939
		goto check_page_flip;
3767
 
3940
 
3768
	/* We detect FlipDone by looking for the change in PendingFlip from '1'
3941
	/* We detect FlipDone by looking for the change in PendingFlip from '1'
3769
	 * to '0' on the following vblank, i.e. IIR has the Pendingflip
3942
	 * to '0' on the following vblank, i.e. IIR has the Pendingflip
3770
	 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence
3943
	 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence
3771
	 * the flip is completed (no longer pending). Since this doesn't raise
3944
	 * the flip is completed (no longer pending). Since this doesn't raise
3772
	 * an interrupt per se, we watch for the change at vblank.
3945
	 * an interrupt per se, we watch for the change at vblank.
Line 3773... Line -...
3773
	 */
-
 
3774
	if (I915_READ(ISR) & flip_pending)
3946
	 */
Line 3775... Line 3947...
3775
		goto check_page_flip;
3947
	if (I915_READ(ISR) & flip_pending)
3776
 
-
 
3777
	intel_finish_page_flip(dev, pipe);
3948
		goto check_page_flip;
3778
	return true;
3949
 
Line 3779... Line 3950...
3779
 
3950
	return true;
3780
check_page_flip:
3951
 
Line 3790... Line 3961...
3790
	u32 flip_mask =
3961
	u32 flip_mask =
3791
		I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
3962
		I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
3792
		I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
3963
		I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
3793
	int pipe, ret = IRQ_NONE;
3964
	int pipe, ret = IRQ_NONE;
Line -... Line 3965...
-
 
3965
 
-
 
3966
	if (!intel_irqs_enabled(dev_priv))
-
 
3967
		return IRQ_NONE;
3794
 
3968
 
3795
	iir = I915_READ(IIR);
3969
	iir = I915_READ(IIR);
3796
	do {
3970
	do {
3797
		bool irq_received = (iir & ~flip_mask) != 0;
3971
		bool irq_received = (iir & ~flip_mask) != 0;
Line 3828... Line 4002...
3828
 
4002
 
3829
		I915_WRITE(IIR, iir & ~flip_mask);
4003
		I915_WRITE(IIR, iir & ~flip_mask);
Line 3830... Line 4004...
3830
		new_iir = I915_READ(IIR); /* Flush posted writes */
4004
		new_iir = I915_READ(IIR); /* Flush posted writes */
3831
 
4005
 
Line 3832... Line 4006...
3832
		if (iir & I915_USER_INTERRUPT)
4006
		if (iir & I915_USER_INTERRUPT)
3833
			notify_ring(dev, &dev_priv->ring[RCS]);
4007
			notify_ring(&dev_priv->ring[RCS]);
3834
 
4008
 
3835
		for_each_pipe(dev_priv, pipe) {
4009
		for_each_pipe(dev_priv, pipe) {
Line 3881... Line 4055...
3881
{
4055
{
3882
	struct drm_i915_private *dev_priv = dev->dev_private;
4056
	struct drm_i915_private *dev_priv = dev->dev_private;
3883
	int pipe;
4057
	int pipe;
Line 3884... Line 4058...
3884
 
4058
 
3885
	if (I915_HAS_HOTPLUG(dev)) {
4059
	if (I915_HAS_HOTPLUG(dev)) {
3886
		I915_WRITE(PORT_HOTPLUG_EN, 0);
4060
		i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0);
3887
		I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
4061
		I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
Line 3888... Line 4062...
3888
	}
4062
	}
3889
 
4063
 
Line 3902... Line 4076...
3902
static void i965_irq_preinstall(struct drm_device * dev)
4076
static void i965_irq_preinstall(struct drm_device * dev)
3903
{
4077
{
3904
	struct drm_i915_private *dev_priv = dev->dev_private;
4078
	struct drm_i915_private *dev_priv = dev->dev_private;
3905
	int pipe;
4079
	int pipe;
Line 3906... Line 4080...
3906
 
4080
 
3907
	I915_WRITE(PORT_HOTPLUG_EN, 0);
4081
	i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0);
Line 3908... Line 4082...
3908
	I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
4082
	I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
3909
 
4083
 
3910
	I915_WRITE(HWSTAM, 0xeffe);
4084
	I915_WRITE(HWSTAM, 0xeffe);
Line 3963... Line 4137...
3963
 
4137
 
3964
	I915_WRITE(IMR, dev_priv->irq_mask);
4138
	I915_WRITE(IMR, dev_priv->irq_mask);
3965
	I915_WRITE(IER, enable_mask);
4139
	I915_WRITE(IER, enable_mask);
Line 3966... Line 4140...
3966
	POSTING_READ(IER);
4140
	POSTING_READ(IER);
3967
 
4141
 
Line 3968... Line 4142...
3968
	I915_WRITE(PORT_HOTPLUG_EN, 0);
4142
	i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0);
Line 3969... Line 4143...
3969
	POSTING_READ(PORT_HOTPLUG_EN);
4143
	POSTING_READ(PORT_HOTPLUG_EN);
3970
 
4144
 
Line 3971... Line 4145...
3971
	i915_enable_asle_pipestat(dev);
4145
	i915_enable_asle_pipestat(dev);
3972
 
4146
 
3973
	return 0;
4147
	return 0;
3974
}
-
 
3975
 
4148
}
Line 3976... Line 4149...
3976
static void i915_hpd_irq_setup(struct drm_device *dev)
4149
 
Line 3977... Line -...
3977
{
-
 
3978
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3979
	struct intel_encoder *intel_encoder;
-
 
3980
	u32 hotplug_en;
4150
static void i915_hpd_irq_setup(struct drm_device *dev)
3981
 
4151
{
3982
	assert_spin_locked(&dev_priv->irq_lock);
-
 
3983
 
-
 
3984
	if (I915_HAS_HOTPLUG(dev)) {
4152
	struct drm_i915_private *dev_priv = dev->dev_private;
3985
		hotplug_en = I915_READ(PORT_HOTPLUG_EN);
4153
	u32 hotplug_en;
3986
		hotplug_en &= ~HOTPLUG_INT_EN_MASK;
4154
 
3987
	/* Note HDMI and DP share hotplug bits */
4155
	assert_spin_locked(&dev_priv->irq_lock);
3988
		/* enable bits are the same for all generations */
4156
 
3989
		for_each_intel_encoder(dev, intel_encoder)
4157
	/* Note HDMI and DP share hotplug bits */
3990
			if (dev_priv->hpd_stats[intel_encoder->hpd_pin].hpd_mark == HPD_ENABLED)
4158
	/* enable bits are the same for all generations */
3991
				hotplug_en |= hpd_mask_i915[intel_encoder->hpd_pin];
-
 
3992
		/* Programming the CRT detection parameters tends
4159
	hotplug_en = intel_hpd_enabled_irqs(dev, hpd_mask_i915);
Line 3993... Line 4160...
3993
		   to generate a spurious hotplug event about three
4160
	/* Programming the CRT detection parameters tends
-
 
4161
	   to generate a spurious hotplug event about three
-
 
4162
	   seconds later.  So just do it once.
3994
		   seconds later.  So just do it once.
4163
	*/
-
 
4164
	if (IS_G4X(dev))
3995
		   */
4165
		hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64;
3996
		if (IS_G4X(dev))
4166
	hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50;
Line 3997... Line 4167...
3997
			hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64;
4167
 
3998
		hotplug_en &= ~CRT_HOTPLUG_VOLTAGE_COMPARE_MASK;
4168
	/* Ignore TV since it's buggy */
3999
		hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50;
4169
	i915_hotplug_interrupt_update_locked(dev_priv,
Line 4012... Line 4182...
4012
	int ret = IRQ_NONE, pipe;
4182
	int ret = IRQ_NONE, pipe;
4013
	u32 flip_mask =
4183
	u32 flip_mask =
4014
		I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
4184
		I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
4015
		I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
4185
		I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
Line -... Line 4186...
-
 
4186
 
-
 
4187
	if (!intel_irqs_enabled(dev_priv))
-
 
4188
		return IRQ_NONE;
4016
 
4189
 
Line 4017... Line 4190...
4017
	iir = I915_READ(IIR);
4190
	iir = I915_READ(IIR);
4018
 
4191
 
4019
	for (;;) {
4192
	for (;;) {
Line 4054... Line 4227...
4054
 
4227
 
4055
		I915_WRITE(IIR, iir & ~flip_mask);
4228
		I915_WRITE(IIR, iir & ~flip_mask);
Line 4056... Line 4229...
4056
		new_iir = I915_READ(IIR); /* Flush posted writes */
4229
		new_iir = I915_READ(IIR); /* Flush posted writes */
4057
 
4230
 
4058
		if (iir & I915_USER_INTERRUPT)
4231
		if (iir & I915_USER_INTERRUPT)
4059
			notify_ring(dev, &dev_priv->ring[RCS]);
4232
			notify_ring(&dev_priv->ring[RCS]);
Line 4060... Line 4233...
4060
		if (iir & I915_BSD_USER_INTERRUPT)
4233
		if (iir & I915_BSD_USER_INTERRUPT)
4061
			notify_ring(dev, &dev_priv->ring[VCS]);
4234
			notify_ring(&dev_priv->ring[VCS]);
4062
 
4235
 
4063
		for_each_pipe(dev_priv, pipe) {
4236
		for_each_pipe(dev_priv, pipe) {
Line 4108... Line 4281...
4108
	int pipe;
4281
	int pipe;
Line 4109... Line 4282...
4109
 
4282
 
4110
	if (!dev_priv)
4283
	if (!dev_priv)
Line 4111... Line 4284...
4111
		return;
4284
		return;
4112
 
4285
 
Line 4113... Line 4286...
4113
	I915_WRITE(PORT_HOTPLUG_EN, 0);
4286
	i915_hotplug_interrupt_update(dev_priv, 0xffffffff, 0);
4114
	I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
4287
	I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
4115
 
4288
 
Line 4123... Line 4296...
4123
		I915_WRITE(PIPESTAT(pipe),
4296
		I915_WRITE(PIPESTAT(pipe),
4124
			   I915_READ(PIPESTAT(pipe)) & 0x8000ffff);
4297
			   I915_READ(PIPESTAT(pipe)) & 0x8000ffff);
4125
	I915_WRITE(IIR, I915_READ(IIR));
4298
	I915_WRITE(IIR, I915_READ(IIR));
4126
}
4299
}
Line 4127... Line -...
4127
 
-
 
4128
static void intel_hpd_irq_reenable_work(struct work_struct *work)
-
 
4129
{
-
 
4130
	struct drm_i915_private *dev_priv =
-
 
4131
		container_of(work, typeof(*dev_priv),
-
 
4132
			     hotplug_reenable_work.work);
-
 
4133
	struct drm_device *dev = dev_priv->dev;
-
 
4134
	struct drm_mode_config *mode_config = &dev->mode_config;
-
 
4135
	int i;
-
 
4136
 
-
 
4137
	intel_runtime_pm_get(dev_priv);
-
 
4138
 
-
 
4139
	spin_lock_irq(&dev_priv->irq_lock);
-
 
4140
	for (i = (HPD_NONE + 1); i < HPD_NUM_PINS; i++) {
-
 
4141
		struct drm_connector *connector;
-
 
4142
 
-
 
4143
		if (dev_priv->hpd_stats[i].hpd_mark != HPD_DISABLED)
-
 
4144
			continue;
-
 
4145
 
-
 
4146
		dev_priv->hpd_stats[i].hpd_mark = HPD_ENABLED;
-
 
4147
 
-
 
4148
		list_for_each_entry(connector, &mode_config->connector_list, head) {
-
 
4149
			struct intel_connector *intel_connector = to_intel_connector(connector);
-
 
4150
 
-
 
4151
			if (intel_connector->encoder->hpd_pin == i) {
-
 
4152
				if (connector->polled != intel_connector->polled)
-
 
4153
					DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n",
-
 
4154
							 connector->name);
-
 
4155
				connector->polled = intel_connector->polled;
-
 
4156
				if (!connector->polled)
-
 
4157
					connector->polled = DRM_CONNECTOR_POLL_HPD;
-
 
4158
			}
-
 
4159
		}
-
 
4160
	}
-
 
4161
	if (dev_priv->display.hpd_irq_setup)
-
 
4162
		dev_priv->display.hpd_irq_setup(dev);
-
 
4163
	spin_unlock_irq(&dev_priv->irq_lock);
-
 
4164
 
-
 
4165
	intel_runtime_pm_put(dev_priv);
-
 
4166
}
-
 
4167
 
4300
 
4168
/**
4301
/**
4169
 * intel_irq_init - initializes irq support
4302
 * intel_irq_init - initializes irq support
4170
 * @dev_priv: i915 device instance
4303
 * @dev_priv: i915 device instance
4171
 *
4304
 *
Line 4174... Line 4307...
4174
 */
4307
 */
4175
void intel_irq_init(struct drm_i915_private *dev_priv)
4308
void intel_irq_init(struct drm_i915_private *dev_priv)
4176
{
4309
{
4177
	struct drm_device *dev = dev_priv->dev;
4310
	struct drm_device *dev = dev_priv->dev;
Line 4178... Line -...
4178
 
-
 
4179
	INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
4311
 
4180
//	INIT_WORK(&dev_priv->dig_port_work, i915_digport_work_func);
-
 
-
 
4312
//   intel_hpd_init_work(dev_priv);
4181
	INIT_WORK(&dev_priv->gpu_error.work, i915_error_work_func);
4313
 
4182
	INIT_WORK(&dev_priv->rps.work, gen6_pm_rps_work);
4314
	INIT_WORK(&dev_priv->rps.work, gen6_pm_rps_work);
Line 4183... Line 4315...
4183
	INIT_WORK(&dev_priv->l3_parity.error_work, ivybridge_parity_work);
4315
	INIT_WORK(&dev_priv->l3_parity.error_work, ivybridge_parity_work);
4184
 
4316
 
4185
	/* Let's track the enabled rps events */
4317
	/* Let's track the enabled rps events */
4186
	if (IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv))
4318
	if (IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv))
4187
		/* WaGsvRC0ResidencyMethod:vlv */
4319
		/* WaGsvRC0ResidencyMethod:vlv */
4188
		dev_priv->pm_rps_events = GEN6_PM_RP_UP_EI_EXPIRED;
4320
		dev_priv->pm_rps_events = GEN6_PM_RP_DOWN_EI_EXPIRED | GEN6_PM_RP_UP_EI_EXPIRED;
Line 4189... Line 4321...
4189
	else
4321
	else
4190
	dev_priv->pm_rps_events = GEN6_PM_RPS_EVENTS;
4322
		dev_priv->pm_rps_events = GEN6_PM_RPS_EVENTS;
Line 4191... Line 4323...
4191
 
4323
 
4192
	INIT_DELAYED_WORK(&dev_priv->hotplug_reenable_work,
4324
	INIT_DELAYED_WORK(&dev_priv->gpu_error.hangcheck_work,
4193
			  intel_hpd_irq_reenable_work);
4325
			  i915_hangcheck_elapsed);
4194
 
4326
 
4195
 
4327
 
4196
	if (IS_GEN2(dev_priv)) {
4328
	if (IS_GEN2(dev_priv)) {
4197
		dev->max_vblank_count = 0;
4329
		dev->max_vblank_count = 0;
4198
		dev->driver->get_vblank_counter = i8xx_get_vblank_counter;
4330
		dev->driver->get_vblank_counter = i8xx_get_vblank_counter;
4199
	} else if (IS_G4X(dev_priv) || INTEL_INFO(dev_priv)->gen >= 5) {
4331
	} else if (IS_G4X(dev_priv) || INTEL_INFO(dev_priv)->gen >= 5) {
4200
		dev->max_vblank_count = 0xffffffff; /* full 32 bit counter */
4332
		dev->max_vblank_count = 0xffffffff; /* full 32 bit counter */
Line 4210... Line 4342...
4210
	 * vblank interrupts to produce sane vblank seuquence numbers.
4342
	 * vblank interrupts to produce sane vblank seuquence numbers.
4211
	 */
4343
	 */
4212
	if (!IS_GEN2(dev_priv))
4344
	if (!IS_GEN2(dev_priv))
4213
		dev->vblank_disable_immediate = true;
4345
		dev->vblank_disable_immediate = true;
Line 4214... Line -...
4214
 
-
 
4215
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
4346
 
4216
		dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
4347
	dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
4217
	dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
-
 
Line 4218... Line 4348...
4218
	}
4348
	dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
4219
 
4349
 
4220
	if (IS_CHERRYVIEW(dev_priv)) {
4350
	if (IS_CHERRYVIEW(dev_priv)) {
4221
		dev->driver->irq_handler = cherryview_irq_handler;
4351
		dev->driver->irq_handler = cherryview_irq_handler;
Line 4238... Line 4368...
4238
		dev->driver->irq_preinstall = gen8_irq_reset;
4368
		dev->driver->irq_preinstall = gen8_irq_reset;
4239
		dev->driver->irq_postinstall = gen8_irq_postinstall;
4369
		dev->driver->irq_postinstall = gen8_irq_postinstall;
4240
		dev->driver->irq_uninstall = gen8_irq_uninstall;
4370
		dev->driver->irq_uninstall = gen8_irq_uninstall;
4241
		dev->driver->enable_vblank = gen8_enable_vblank;
4371
		dev->driver->enable_vblank = gen8_enable_vblank;
4242
		dev->driver->disable_vblank = gen8_disable_vblank;
4372
		dev->driver->disable_vblank = gen8_disable_vblank;
-
 
4373
		if (IS_BROXTON(dev))
4243
		dev_priv->display.hpd_irq_setup = ibx_hpd_irq_setup;
4374
			dev_priv->display.hpd_irq_setup = bxt_hpd_irq_setup;
-
 
4375
		else if (HAS_PCH_SPT(dev))
-
 
4376
			dev_priv->display.hpd_irq_setup = spt_hpd_irq_setup;
-
 
4377
		else
-
 
4378
			dev_priv->display.hpd_irq_setup = ilk_hpd_irq_setup;
4244
	} else if (HAS_PCH_SPLIT(dev)) {
4379
	} else if (HAS_PCH_SPLIT(dev)) {
4245
		dev->driver->irq_handler = ironlake_irq_handler;
4380
		dev->driver->irq_handler = ironlake_irq_handler;
4246
		dev->driver->irq_preinstall = ironlake_irq_reset;
4381
		dev->driver->irq_preinstall = ironlake_irq_reset;
4247
		dev->driver->irq_postinstall = ironlake_irq_postinstall;
4382
		dev->driver->irq_postinstall = ironlake_irq_postinstall;
4248
		dev->driver->irq_uninstall = ironlake_irq_uninstall;
4383
		dev->driver->irq_uninstall = ironlake_irq_uninstall;
4249
		dev->driver->enable_vblank = ironlake_enable_vblank;
4384
		dev->driver->enable_vblank = ironlake_enable_vblank;
4250
		dev->driver->disable_vblank = ironlake_disable_vblank;
4385
		dev->driver->disable_vblank = ironlake_disable_vblank;
4251
		dev_priv->display.hpd_irq_setup = ibx_hpd_irq_setup;
4386
		dev_priv->display.hpd_irq_setup = ilk_hpd_irq_setup;
4252
	} else {
4387
	} else {
4253
		if (INTEL_INFO(dev_priv)->gen == 2) {
4388
		if (INTEL_INFO(dev_priv)->gen == 2) {
4254
		} else if (INTEL_INFO(dev_priv)->gen == 3) {
4389
		} else if (INTEL_INFO(dev_priv)->gen == 3) {
4255
			dev->driver->irq_preinstall = i915_irq_preinstall;
4390
			dev->driver->irq_preinstall = i915_irq_preinstall;
4256
			dev->driver->irq_postinstall = i915_irq_postinstall;
4391
			dev->driver->irq_postinstall = i915_irq_postinstall;
4257
			dev->driver->irq_uninstall = i915_irq_uninstall;
4392
			dev->driver->irq_uninstall = i915_irq_uninstall;
4258
			dev->driver->irq_handler = i915_irq_handler;
4393
			dev->driver->irq_handler = i915_irq_handler;
4259
			dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup;
-
 
4260
		} else {
4394
		} else {
4261
			dev->driver->irq_preinstall = i965_irq_preinstall;
4395
			dev->driver->irq_preinstall = i965_irq_preinstall;
4262
			dev->driver->irq_postinstall = i965_irq_postinstall;
4396
			dev->driver->irq_postinstall = i965_irq_postinstall;
4263
			dev->driver->irq_uninstall = i965_irq_uninstall;
4397
			dev->driver->irq_uninstall = i965_irq_uninstall;
4264
			dev->driver->irq_handler = i965_irq_handler;
4398
			dev->driver->irq_handler = i965_irq_handler;
4265
			dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup;
-
 
4266
		}
4399
		}
-
 
4400
		if (I915_HAS_HOTPLUG(dev_priv))
-
 
4401
			dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup;
4267
		dev->driver->enable_vblank = i915_enable_vblank;
4402
		dev->driver->enable_vblank = i915_enable_vblank;
4268
		dev->driver->disable_vblank = i915_disable_vblank;
4403
		dev->driver->disable_vblank = i915_disable_vblank;
4269
	}
4404
	}
4270
}
4405
}
Line 4271... Line 4406...
4271
 
4406
 
4272
/**
-
 
4273
 * intel_hpd_init - initializes and enables hpd support
-
 
4274
 * @dev_priv: i915 device instance
-
 
4275
 *
-
 
4276
 * This function enables the hotplug support. It requires that interrupts have
-
 
4277
 * already been enabled with intel_irq_init_hw(). From this point on hotplug and
-
 
4278
 * poll request can run concurrently to other code, so locking rules must be
-
 
4279
 * obeyed.
-
 
4280
 *
-
 
4281
 * This is a separate step from interrupt enabling to simplify the locking rules
-
 
4282
 * in the driver load and resume code.
-
 
4283
 */
-
 
4284
void intel_hpd_init(struct drm_i915_private *dev_priv)
-
 
4285
{
-
 
4286
	struct drm_device *dev = dev_priv->dev;
-
 
4287
	struct drm_mode_config *mode_config = &dev->mode_config;
-
 
4288
	struct drm_connector *connector;
-
 
4289
	int i;
-
 
4290
 
-
 
4291
	for (i = 1; i < HPD_NUM_PINS; i++) {
-
 
4292
		dev_priv->hpd_stats[i].hpd_cnt = 0;
-
 
4293
		dev_priv->hpd_stats[i].hpd_mark = HPD_ENABLED;
-
 
4294
	}
-
 
4295
	list_for_each_entry(connector, &mode_config->connector_list, head) {
-
 
4296
		struct intel_connector *intel_connector = to_intel_connector(connector);
-
 
4297
		connector->polled = intel_connector->polled;
-
 
4298
		if (connector->encoder && !connector->polled && I915_HAS_HOTPLUG(dev) && intel_connector->encoder->hpd_pin > HPD_NONE)
-
 
4299
			connector->polled = DRM_CONNECTOR_POLL_HPD;
-
 
4300
		if (intel_connector->mst_port)
-
 
4301
			connector->polled = DRM_CONNECTOR_POLL_HPD;
-
 
4302
	}
-
 
4303
 
-
 
4304
	/* Interrupt setup is already guaranteed to be single-threaded, this is
-
 
4305
	 * just to make the assert_spin_locked checks happy. */
-
 
4306
	spin_lock_irq(&dev_priv->irq_lock);
-
 
4307
	if (dev_priv->display.hpd_irq_setup)
-
 
4308
		dev_priv->display.hpd_irq_setup(dev);
-
 
4309
	spin_unlock_irq(&dev_priv->irq_lock);
-
 
4310
}
-
 
4311
 
-
 
4312
/**
4407
/**
4313
 * intel_irq_install - enables the hardware interrupt
4408
 * intel_irq_install - enables the hardware interrupt
4314
 * @dev_priv: i915 device instance
4409
 * @dev_priv: i915 device instance
4315
 *
4410
 *
4316
 * This function enables the hardware interrupt handling, but leaves the hotplug
4411
 * This function enables the hardware interrupt handling, but leaves the hotplug