Skip to content

Commit b6e78a6

Browse files
committed
Merge tag 'drm-fixes-for-v4.14-rc2' of git://people.freedesktop.org/~airlied/linux
Pull drm fixes from Dave Airlie: "amdkfd, i915 and exynos fixes. I've ended up on unplanned + planned leave this week, but there were some fixes I decided to dequeue, some amdkfd bits missed the next pull but they are pretty trivial, so I included them. I'm not sure I'll see much else for rc2, lots of people are at XDC" * tag 'drm-fixes-for-v4.14-rc2' of git://people.freedesktop.org/~airlied/linux: drm/exynos/hdmi: Fix unsafe list iteration drm: exynos: include linux/irq.h drm/exynos: Fix suspend/resume support drm/exynos: Fix locking in the suspend/resume paths drm/i915: Remove unused 'in_vbl' from i915_get_crtc_scanoutpos() drm/i915/cnp: set min brightness from VBT Revert "drm/i915/bxt: Disable device ready before shutdown command" drm/i915/bxt: set min brightness from VBT drm/i915: Fix an error handling in 'intel_framebuffer_init()' drm/i915/gvt: Fix incorrect PCI BARs reporting drm/amdkfd: pass queue's mqd when destroying mqd drm/amdkfd: remove memset before memcpy uapi linux/kfd_ioctl.h: only use __u32 and __u64
2 parents 20c29a9 + 56eac98 commit b6e78a6

File tree

14 files changed

+195
-195
lines changed

14 files changed

+195
-195
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void uninitialize(struct kernel_queue *kq)
183183
{
184184
if (kq->queue->properties.type == KFD_QUEUE_TYPE_HIQ)
185185
kq->mqd->destroy_mqd(kq->mqd,
186-
NULL,
186+
kq->queue->mqd,
187187
false,
188188
QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS,
189189
kq->queue->pipe,

drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ int pqm_create_queue(struct process_queue_manager *pqm,
143143
int num_queues = 0;
144144
struct queue *cur;
145145

146-
memset(&q_properties, 0, sizeof(struct queue_properties));
147146
memcpy(&q_properties, properties, sizeof(struct queue_properties));
148147
q = NULL;
149148
kq = NULL;

drivers/gpu/drm/exynos/exynos5433_drm_decon.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/clk.h>
1515
#include <linux/component.h>
1616
#include <linux/iopoll.h>
17+
#include <linux/irq.h>
1718
#include <linux/mfd/syscon.h>
1819
#include <linux/of_device.h>
1920
#include <linux/of_gpio.h>

drivers/gpu/drm/exynos/exynos_drm_drv.c

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -168,46 +168,34 @@ static struct drm_driver exynos_drm_driver = {
168168
static int exynos_drm_suspend(struct device *dev)
169169
{
170170
struct drm_device *drm_dev = dev_get_drvdata(dev);
171-
struct drm_connector *connector;
172-
struct drm_connector_list_iter conn_iter;
171+
struct exynos_drm_private *private = drm_dev->dev_private;
173172

174173
if (pm_runtime_suspended(dev) || !drm_dev)
175174
return 0;
176175

177-
drm_connector_list_iter_begin(drm_dev, &conn_iter);
178-
drm_for_each_connector_iter(connector, &conn_iter) {
179-
int old_dpms = connector->dpms;
180-
181-
if (connector->funcs->dpms)
182-
connector->funcs->dpms(connector, DRM_MODE_DPMS_OFF);
183-
184-
/* Set the old mode back to the connector for resume */
185-
connector->dpms = old_dpms;
176+
drm_kms_helper_poll_disable(drm_dev);
177+
exynos_drm_fbdev_suspend(drm_dev);
178+
private->suspend_state = drm_atomic_helper_suspend(drm_dev);
179+
if (IS_ERR(private->suspend_state)) {
180+
exynos_drm_fbdev_resume(drm_dev);
181+
drm_kms_helper_poll_enable(drm_dev);
182+
return PTR_ERR(private->suspend_state);
186183
}
187-
drm_connector_list_iter_end(&conn_iter);
188184

189185
return 0;
190186
}
191187

192188
static int exynos_drm_resume(struct device *dev)
193189
{
194190
struct drm_device *drm_dev = dev_get_drvdata(dev);
195-
struct drm_connector *connector;
196-
struct drm_connector_list_iter conn_iter;
191+
struct exynos_drm_private *private = drm_dev->dev_private;
197192

198193
if (pm_runtime_suspended(dev) || !drm_dev)
199194
return 0;
200195

201-
drm_connector_list_iter_begin(drm_dev, &conn_iter);
202-
drm_for_each_connector_iter(connector, &conn_iter) {
203-
if (connector->funcs->dpms) {
204-
int dpms = connector->dpms;
205-
206-
connector->dpms = DRM_MODE_DPMS_OFF;
207-
connector->funcs->dpms(connector, dpms);
208-
}
209-
}
210-
drm_connector_list_iter_end(&conn_iter);
196+
drm_atomic_helper_resume(drm_dev, private->suspend_state);
197+
exynos_drm_fbdev_resume(drm_dev);
198+
drm_kms_helper_poll_enable(drm_dev);
211199

212200
return 0;
213201
}

drivers/gpu/drm/exynos/exynos_drm_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ struct drm_exynos_file_private {
202202
*/
203203
struct exynos_drm_private {
204204
struct drm_fb_helper *fb_helper;
205+
struct drm_atomic_state *suspend_state;
205206

206207
struct device *dma_dev;
207208
void *mapping;

drivers/gpu/drm/exynos/exynos_drm_fbdev.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <drm/drm_crtc_helper.h>
1919
#include <drm/exynos_drm.h>
2020

21+
#include <linux/console.h>
22+
2123
#include "exynos_drm_drv.h"
2224
#include "exynos_drm_fb.h"
2325
#include "exynos_drm_fbdev.h"
@@ -285,3 +287,21 @@ void exynos_drm_output_poll_changed(struct drm_device *dev)
285287

286288
drm_fb_helper_hotplug_event(fb_helper);
287289
}
290+
291+
void exynos_drm_fbdev_suspend(struct drm_device *dev)
292+
{
293+
struct exynos_drm_private *private = dev->dev_private;
294+
295+
console_lock();
296+
drm_fb_helper_set_suspend(private->fb_helper, 1);
297+
console_unlock();
298+
}
299+
300+
void exynos_drm_fbdev_resume(struct drm_device *dev)
301+
{
302+
struct exynos_drm_private *private = dev->dev_private;
303+
304+
console_lock();
305+
drm_fb_helper_set_suspend(private->fb_helper, 0);
306+
console_unlock();
307+
}

drivers/gpu/drm/exynos/exynos_drm_fbdev.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ int exynos_drm_fbdev_init(struct drm_device *dev);
2121
void exynos_drm_fbdev_fini(struct drm_device *dev);
2222
void exynos_drm_fbdev_restore_mode(struct drm_device *dev);
2323
void exynos_drm_output_poll_changed(struct drm_device *dev);
24+
void exynos_drm_fbdev_suspend(struct drm_device *drm);
25+
void exynos_drm_fbdev_resume(struct drm_device *drm);
2426

2527
#else
2628

@@ -39,6 +41,14 @@ static inline void exynos_drm_fbdev_restore_mode(struct drm_device *dev)
3941

4042
#define exynos_drm_output_poll_changed (NULL)
4143

44+
static inline void exynos_drm_fbdev_suspend(struct drm_device *drm)
45+
{
46+
}
47+
48+
static inline void exynos_drm_fbdev_resume(struct drm_device *drm)
49+
{
50+
}
51+
4252
#endif
4353

4454
#endif

drivers/gpu/drm/exynos/exynos_hdmi.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,22 +944,27 @@ static bool hdmi_mode_fixup(struct drm_encoder *encoder,
944944
struct drm_device *dev = encoder->dev;
945945
struct drm_connector *connector;
946946
struct drm_display_mode *m;
947+
struct drm_connector_list_iter conn_iter;
947948
int mode_ok;
948949

949950
drm_mode_set_crtcinfo(adjusted_mode, 0);
950951

951-
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
952+
drm_connector_list_iter_begin(dev, &conn_iter);
953+
drm_for_each_connector_iter(connector, &conn_iter) {
952954
if (connector->encoder == encoder)
953955
break;
954956
}
957+
if (connector)
958+
drm_connector_get(connector);
959+
drm_connector_list_iter_end(&conn_iter);
955960

956-
if (connector->encoder != encoder)
961+
if (!connector)
957962
return true;
958963

959964
mode_ok = hdmi_mode_valid(connector, adjusted_mode);
960965

961966
if (mode_ok == MODE_OK)
962-
return true;
967+
goto cleanup;
963968

964969
/*
965970
* Find the most suitable mode and copy it to adjusted_mode.
@@ -979,6 +984,9 @@ static bool hdmi_mode_fixup(struct drm_encoder *encoder,
979984
}
980985
}
981986

987+
cleanup:
988+
drm_connector_put(connector);
989+
982990
return true;
983991
}
984992

drivers/gpu/drm/i915/gvt/cfg_space.c

Lines changed: 48 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -197,78 +197,65 @@ static int emulate_pci_command_write(struct intel_vgpu *vgpu,
197197
static int emulate_pci_bar_write(struct intel_vgpu *vgpu, unsigned int offset,
198198
void *p_data, unsigned int bytes)
199199
{
200-
unsigned int bar_index =
201-
(rounddown(offset, 8) % PCI_BASE_ADDRESS_0) / 8;
202200
u32 new = *(u32 *)(p_data);
203201
bool lo = IS_ALIGNED(offset, 8);
204202
u64 size;
205203
int ret = 0;
206204
bool mmio_enabled =
207205
vgpu_cfg_space(vgpu)[PCI_COMMAND] & PCI_COMMAND_MEMORY;
206+
struct intel_vgpu_pci_bar *bars = vgpu->cfg_space.bar;
208207

209-
if (WARN_ON(bar_index >= INTEL_GVT_PCI_BAR_MAX))
210-
return -EINVAL;
211-
208+
/*
209+
* Power-up software can determine how much address
210+
* space the device requires by writing a value of
211+
* all 1's to the register and then reading the value
212+
* back. The device will return 0's in all don't-care
213+
* address bits.
214+
*/
212215
if (new == 0xffffffff) {
213-
/*
214-
* Power-up software can determine how much address
215-
* space the device requires by writing a value of
216-
* all 1's to the register and then reading the value
217-
* back. The device will return 0's in all don't-care
218-
* address bits.
219-
*/
220-
size = vgpu->cfg_space.bar[bar_index].size;
221-
if (lo) {
222-
new = rounddown(new, size);
223-
} else {
224-
u32 val = vgpu_cfg_space(vgpu)[rounddown(offset, 8)];
225-
/* for 32bit mode bar it returns all-0 in upper 32
226-
* bit, for 64bit mode bar it will calculate the
227-
* size with lower 32bit and return the corresponding
228-
* value
216+
switch (offset) {
217+
case PCI_BASE_ADDRESS_0:
218+
case PCI_BASE_ADDRESS_1:
219+
size = ~(bars[INTEL_GVT_PCI_BAR_GTTMMIO].size -1);
220+
intel_vgpu_write_pci_bar(vgpu, offset,
221+
size >> (lo ? 0 : 32), lo);
222+
/*
223+
* Untrap the BAR, since guest hasn't configured a
224+
* valid GPA
229225
*/
230-
if (val & PCI_BASE_ADDRESS_MEM_TYPE_64)
231-
new &= (~(size-1)) >> 32;
232-
else
233-
new = 0;
234-
}
235-
/*
236-
* Unmapp & untrap the BAR, since guest hasn't configured a
237-
* valid GPA
238-
*/
239-
switch (bar_index) {
240-
case INTEL_GVT_PCI_BAR_GTTMMIO:
241226
ret = trap_gttmmio(vgpu, false);
242227
break;
243-
case INTEL_GVT_PCI_BAR_APERTURE:
228+
case PCI_BASE_ADDRESS_2:
229+
case PCI_BASE_ADDRESS_3:
230+
size = ~(bars[INTEL_GVT_PCI_BAR_APERTURE].size -1);
231+
intel_vgpu_write_pci_bar(vgpu, offset,
232+
size >> (lo ? 0 : 32), lo);
244233
ret = map_aperture(vgpu, false);
245234
break;
235+
default:
236+
/* Unimplemented BARs */
237+
intel_vgpu_write_pci_bar(vgpu, offset, 0x0, false);
246238
}
247-
intel_vgpu_write_pci_bar(vgpu, offset, new, lo);
248239
} else {
249-
/*
250-
* Unmapp & untrap the old BAR first, since guest has
251-
* re-configured the BAR
252-
*/
253-
switch (bar_index) {
254-
case INTEL_GVT_PCI_BAR_GTTMMIO:
255-
ret = trap_gttmmio(vgpu, false);
240+
switch (offset) {
241+
case PCI_BASE_ADDRESS_0:
242+
case PCI_BASE_ADDRESS_1:
243+
/*
244+
* Untrap the old BAR first, since guest has
245+
* re-configured the BAR
246+
*/
247+
trap_gttmmio(vgpu, false);
248+
intel_vgpu_write_pci_bar(vgpu, offset, new, lo);
249+
ret = trap_gttmmio(vgpu, mmio_enabled);
256250
break;
257-
case INTEL_GVT_PCI_BAR_APERTURE:
258-
ret = map_aperture(vgpu, false);
251+
case PCI_BASE_ADDRESS_2:
252+
case PCI_BASE_ADDRESS_3:
253+
map_aperture(vgpu, false);
254+
intel_vgpu_write_pci_bar(vgpu, offset, new, lo);
255+
ret = map_aperture(vgpu, mmio_enabled);
259256
break;
260-
}
261-
intel_vgpu_write_pci_bar(vgpu, offset, new, lo);
262-
/* Track the new BAR */
263-
if (mmio_enabled) {
264-
switch (bar_index) {
265-
case INTEL_GVT_PCI_BAR_GTTMMIO:
266-
ret = trap_gttmmio(vgpu, true);
267-
break;
268-
case INTEL_GVT_PCI_BAR_APERTURE:
269-
ret = map_aperture(vgpu, true);
270-
break;
271-
}
257+
default:
258+
intel_vgpu_write_pci_bar(vgpu, offset, new, lo);
272259
}
273260
}
274261
return ret;
@@ -299,10 +286,7 @@ int intel_vgpu_emulate_cfg_write(struct intel_vgpu *vgpu, unsigned int offset,
299286
}
300287

301288
switch (rounddown(offset, 4)) {
302-
case PCI_BASE_ADDRESS_0:
303-
case PCI_BASE_ADDRESS_1:
304-
case PCI_BASE_ADDRESS_2:
305-
case PCI_BASE_ADDRESS_3:
289+
case PCI_BASE_ADDRESS_0 ... PCI_BASE_ADDRESS_5:
306290
if (WARN_ON(!IS_ALIGNED(offset, 4)))
307291
return -EINVAL;
308292
return emulate_pci_bar_write(vgpu, offset, p_data, bytes);
@@ -344,7 +328,6 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
344328
struct intel_gvt *gvt = vgpu->gvt;
345329
const struct intel_gvt_device_info *info = &gvt->device_info;
346330
u16 *gmch_ctl;
347-
int i;
348331

349332
memcpy(vgpu_cfg_space(vgpu), gvt->firmware.cfg_space,
350333
info->cfg_space_size);
@@ -371,13 +354,13 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
371354
*/
372355
memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_1, 0, 4);
373356
memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_3, 0, 4);
357+
memset(vgpu_cfg_space(vgpu) + PCI_BASE_ADDRESS_4, 0, 8);
374358
memset(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_OPREGION, 0, 4);
375359

376-
for (i = 0; i < INTEL_GVT_MAX_BAR_NUM; i++) {
377-
vgpu->cfg_space.bar[i].size = pci_resource_len(
378-
gvt->dev_priv->drm.pdev, i * 2);
379-
vgpu->cfg_space.bar[i].tracked = false;
380-
}
360+
vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_GTTMMIO].size =
361+
pci_resource_len(gvt->dev_priv->drm.pdev, 0);
362+
vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_APERTURE].size =
363+
pci_resource_len(gvt->dev_priv->drm.pdev, 2);
381364
}
382365

383366
/**

drivers/gpu/drm/i915/i915_irq.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,6 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
839839
pipe);
840840
int position;
841841
int vbl_start, vbl_end, hsync_start, htotal, vtotal;
842-
bool in_vbl = true;
843842
unsigned long irqflags;
844843

845844
if (WARN_ON(!mode->crtc_clock)) {
@@ -922,8 +921,6 @@ static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
922921

923922
spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
924923

925-
in_vbl = position >= vbl_start && position < vbl_end;
926-
927924
/*
928925
* While in vblank, position will be negative
929926
* counting up towards 0 at vbl_end. And outside

0 commit comments

Comments
 (0)