Merge tag 'drm-fixes-for-v4.12-rc2' of git://people.freedesktop.org/~airlied/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 20 May 2017 15:29:30 +0000 (08:29 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 20 May 2017 15:29:30 +0000 (08:29 -0700)
Pull drm fixes from Dave Airlie:
 "Mostly nouveau and i915, fairly quiet as usual for rc2"

* tag 'drm-fixes-for-v4.12-rc2' of git://people.freedesktop.org/~airlied/linux:
  drm/atmel-hlcdc: Fix output initialization
  gpu: host1x: select IOMMU_IOVA
  drm/nouveau/fifo/gk104-: Silence a locking warning
  drm/nouveau/secboot: plug memory leak in ls_ucode_img_load_gr() error path
  drm/nouveau: Fix drm poll_helper handling
  drm/i915: don't do allocate_va_range again on PIN_UPDATE
  drm/i915: Fix rawclk readout for g4x
  drm/i915: Fix runtime PM for LPE audio
  drm/i915/glk: Fix DSI "*ERROR* ULPS is still active" messages
  drm/i915/gvt: avoid unnecessary vgpu switch
  drm/i915/gvt: not to restore in-context mmio
  drm/etnaviv: don't put fence in case of submit failure
  drm/i915/gvt: fix typo: "supporte" -> "support"
  drm: hdlcd: Fix the calculation of the scanout start address

17 files changed:
drivers/gpu/drm/arm/hdlcd_crtc.c
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
drivers/gpu/drm/i915/gvt/handlers.c
drivers/gpu/drm/i915/gvt/render.c
drivers/gpu/drm/i915/gvt/sched_policy.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_cdclk.c
drivers/gpu/drm/i915/intel_dsi.c
drivers/gpu/drm/i915/intel_lpe_audio.c
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/ls_ucode_gr.c
drivers/gpu/host1x/Kconfig
sound/x86/intel_hdmi_audio.c

index 798a3cc480a2eefc8510417a883dcded6dedc741..1a3359c0f6cd2e80441977114ca55aea85c19cb8 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
@@ -226,16 +227,33 @@ static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = {
 static int hdlcd_plane_atomic_check(struct drm_plane *plane,
                                    struct drm_plane_state *state)
 {
-       u32 src_w, src_h;
+       struct drm_rect clip = { 0 };
+       struct drm_crtc_state *crtc_state;
+       u32 src_h = state->src_h >> 16;
 
-       src_w = state->src_w >> 16;
-       src_h = state->src_h >> 16;
+       /* only the HDLCD_REG_FB_LINE_COUNT register has a limit */
+       if (src_h >= HDLCD_MAX_YRES) {
+               DRM_DEBUG_KMS("Invalid source width: %d\n", src_h);
+               return -EINVAL;
+       }
+
+       if (!state->fb || !state->crtc)
+               return 0;
 
-       /* we can't do any scaling of the plane source */
-       if ((src_w != state->crtc_w) || (src_h != state->crtc_h))
+       crtc_state = drm_atomic_get_existing_crtc_state(state->state,
+                                                       state->crtc);
+       if (!crtc_state) {
+               DRM_DEBUG_KMS("Invalid crtc state\n");
                return -EINVAL;
+       }
 
-       return 0;
+       clip.x2 = crtc_state->adjusted_mode.hdisplay;
+       clip.y2 = crtc_state->adjusted_mode.vdisplay;
+
+       return drm_plane_helper_check_state(state, &clip,
+                                           DRM_PLANE_HELPER_NO_SCALING,
+                                           DRM_PLANE_HELPER_NO_SCALING,
+                                           false, true);
 }
 
 static void hdlcd_plane_atomic_update(struct drm_plane *plane,
@@ -244,21 +262,20 @@ static void hdlcd_plane_atomic_update(struct drm_plane *plane,
        struct drm_framebuffer *fb = plane->state->fb;
        struct hdlcd_drm_private *hdlcd;
        struct drm_gem_cma_object *gem;
-       u32 src_w, src_h, dest_w, dest_h;
+       u32 src_x, src_y, dest_h;
        dma_addr_t scanout_start;
 
        if (!fb)
                return;
 
-       src_w = plane->state->src_w >> 16;
-       src_h = plane->state->src_h >> 16;
-       dest_w = plane->state->crtc_w;
-       dest_h = plane->state->crtc_h;
+       src_x = plane->state->src.x1 >> 16;
+       src_y = plane->state->src.y1 >> 16;
+       dest_h = drm_rect_height(&plane->state->dst);
        gem = drm_fb_cma_get_gem_obj(fb, 0);
+
        scanout_start = gem->paddr + fb->offsets[0] +
-               plane->state->crtc_y * fb->pitches[0] +
-               plane->state->crtc_x *
-               fb->format->cpp[0];
+                       src_y * fb->pitches[0] +
+                       src_x * fb->format->cpp[0];
 
        hdlcd = plane->dev->dev_private;
        hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]);
@@ -305,7 +322,6 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
                                       formats, ARRAY_SIZE(formats),
                                       DRM_PLANE_TYPE_PRIMARY, NULL);
        if (ret) {
-               devm_kfree(drm->dev, plane);
                return ERR_PTR(ret);
        }
 
@@ -329,7 +345,6 @@ int hdlcd_setup_crtc(struct drm_device *drm)
                                        &hdlcd_crtc_funcs, NULL);
        if (ret) {
                hdlcd_plane_destroy(primary);
-               devm_kfree(drm->dev, primary);
                return ret;
        }
 
index 65a3bd7a0c00dbf919d46e6d464d8bce8a5ccfd1..423dda2785d44fd2a900a406d7b1d86c3269d970 100644 (file)
@@ -152,8 +152,7 @@ static const struct drm_connector_funcs atmel_hlcdc_panel_connector_funcs = {
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
-                                      const struct device_node *np)
+static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
 {
        struct atmel_hlcdc_dc *dc = dev->dev_private;
        struct atmel_hlcdc_rgb_output *output;
@@ -161,6 +160,11 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
        struct drm_bridge *bridge;
        int ret;
 
+       ret = drm_of_find_panel_or_bridge(dev->dev->of_node, 0, endpoint,
+                                         &panel, &bridge);
+       if (ret)
+               return ret;
+
        output = devm_kzalloc(dev->dev, sizeof(*output), GFP_KERNEL);
        if (!output)
                return -EINVAL;
@@ -177,10 +181,6 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
 
        output->encoder.possible_crtcs = 0x1;
 
-       ret = drm_of_find_panel_or_bridge(np, 0, 0, &panel, &bridge);
-       if (ret)
-               return ret;
-
        if (panel) {
                output->connector.dpms = DRM_MODE_DPMS_OFF;
                output->connector.polled = DRM_CONNECTOR_POLL_CONNECT;
@@ -220,22 +220,14 @@ err_encoder_cleanup:
 
 int atmel_hlcdc_create_outputs(struct drm_device *dev)
 {
-       struct device_node *remote;
-       int ret = -ENODEV;
-       int endpoint = 0;
-
-       while (true) {
-               /* Loop thru possible multiple connections to the output */
-               remote = of_graph_get_remote_node(dev->dev->of_node, 0,
-                                                 endpoint++);
-               if (!remote)
-                       break;
-
-               ret = atmel_hlcdc_attach_endpoint(dev, remote);
-               of_node_put(remote);
-               if (ret)
-                       return ret;
-       }
+       int endpoint, ret = 0;
+
+       for (endpoint = 0; !ret; endpoint++)
+               ret = atmel_hlcdc_attach_endpoint(dev, endpoint);
+
+       /* At least one device was successfully attached.*/
+       if (ret == -ENODEV && endpoint)
+               return 0;
 
        return ret;
 }
index e1909429837eebc2072d00d9a9f590c6e5f87bd2..de80ee1b71dfa2e8380b6e74b2d8cc6ed4aa6f25 100644 (file)
@@ -44,6 +44,7 @@ static struct etnaviv_gem_submit *submit_create(struct drm_device *dev,
 
                /* initially, until copy_from_user() and bo lookup succeeds: */
                submit->nr_bos = 0;
+               submit->fence = NULL;
 
                ww_acquire_init(&submit->ticket, &reservation_ww_class);
        }
@@ -294,7 +295,8 @@ static void submit_cleanup(struct etnaviv_gem_submit *submit)
        }
 
        ww_acquire_fini(&submit->ticket);
-       dma_fence_put(submit->fence);
+       if (submit->fence)
+               dma_fence_put(submit->fence);
        kfree(submit);
 }
 
index 0ad1a508e2af478dc9fb91df18bdc95304efad44..c995e540ff96e1f8a18a9232de2b26794fa03aa2 100644 (file)
@@ -1244,7 +1244,7 @@ static int dma_ctrl_write(struct intel_vgpu *vgpu, unsigned int offset,
        mode = vgpu_vreg(vgpu, offset);
 
        if (GFX_MODE_BIT_SET_IN_MASK(mode, START_DMA)) {
-               WARN_ONCE(1, "VM(%d): iGVT-g doesn't supporte GuC\n",
+               WARN_ONCE(1, "VM(%d): iGVT-g doesn't support GuC\n",
                                vgpu->id);
                return 0;
        }
index c6e7972ac21da8eda7143619a401554e2575a160..a5e11d89df2f86d13dc546f7b3e1a9e9c8ba7d97 100644 (file)
@@ -340,6 +340,9 @@ void intel_gvt_restore_render_mmio(struct intel_vgpu *vgpu, int ring_id)
                } else
                        v = mmio->value;
 
+               if (mmio->in_context)
+                       continue;
+
                I915_WRITE(mmio->reg, v);
                POSTING_READ(mmio->reg);
 
index 79ba4b3440aafd9537f287028d1e23a6186109a1..f25ff133865f1327936483ac166b97c41e0baa60 100644 (file)
@@ -129,9 +129,13 @@ static void try_to_schedule_next_vgpu(struct intel_gvt *gvt)
        struct vgpu_sched_data *vgpu_data;
        ktime_t cur_time;
 
-       /* no target to schedule */
-       if (!scheduler->next_vgpu)
+       /* no need to schedule if next_vgpu is the same with current_vgpu,
+        * let scheduler chose next_vgpu again by setting it to NULL.
+        */
+       if (scheduler->next_vgpu == scheduler->current_vgpu) {
+               scheduler->next_vgpu = NULL;
                return;
+       }
 
        /*
         * after the flag is set, workload dispatch thread will
index 2aa6b97fd22f28436b984a6ae9a537f36ada545a..a0563e18d753fd84731f8372efc7a938d2898a6b 100644 (file)
@@ -195,9 +195,12 @@ static int ppgtt_bind_vma(struct i915_vma *vma,
        u32 pte_flags;
        int ret;
 
-       ret = vma->vm->allocate_va_range(vma->vm, vma->node.start, vma->size);
-       if (ret)
-               return ret;
+       if (!(vma->flags & I915_VMA_LOCAL_BIND)) {
+               ret = vma->vm->allocate_va_range(vma->vm, vma->node.start,
+                                                vma->size);
+               if (ret)
+                       return ret;
+       }
 
        vma->pages = vma->obj->mm.pages;
 
@@ -2306,7 +2309,8 @@ static int aliasing_gtt_bind_vma(struct i915_vma *vma,
        if (flags & I915_VMA_LOCAL_BIND) {
                struct i915_hw_ppgtt *appgtt = i915->mm.aliasing_ppgtt;
 
-               if (appgtt->base.allocate_va_range) {
+               if (!(vma->flags & I915_VMA_LOCAL_BIND) &&
+                   appgtt->base.allocate_va_range) {
                        ret = appgtt->base.allocate_va_range(&appgtt->base,
                                                             vma->node.start,
                                                             vma->node.size);
index 11b12f4124920b07a65aaf7e02b81c8784bece46..5a7c63e64381e48a193610305973c468502565d2 100644 (file)
@@ -3051,10 +3051,14 @@ enum skl_disp_power_wells {
 #define CLKCFG_FSB_667                                 (3 << 0)        /* hrawclk 166 */
 #define CLKCFG_FSB_800                                 (2 << 0)        /* hrawclk 200 */
 #define CLKCFG_FSB_1067                                        (6 << 0)        /* hrawclk 266 */
+#define CLKCFG_FSB_1067_ALT                            (0 << 0)        /* hrawclk 266 */
 #define CLKCFG_FSB_1333                                        (7 << 0)        /* hrawclk 333 */
-/* Note, below two are guess */
-#define CLKCFG_FSB_1600                                        (4 << 0)        /* hrawclk 400 */
-#define CLKCFG_FSB_1600_ALT                            (0 << 0)        /* hrawclk 400 */
+/*
+ * Note that on at least on ELK the below value is reported for both
+ * 333 and 400 MHz BIOS FSB setting, but given that the gmch datasheet
+ * lists only 200/266/333 MHz FSB as supported let's decode it as 333 MHz.
+ */
+#define CLKCFG_FSB_1333_ALT                            (4 << 0)        /* hrawclk 333 */
 #define CLKCFG_FSB_MASK                                        (7 << 0)
 #define CLKCFG_MEM_533                                 (1 << 4)
 #define CLKCFG_MEM_667                                 (2 << 4)
index dd3ad52b7dfeac5e7d6f8eb59ee18b372f20a77f..f29a226e24d8836d86c6e976ce07bcfc26a53c28 100644 (file)
@@ -1798,13 +1798,11 @@ static int g4x_hrawclk(struct drm_i915_private *dev_priv)
        case CLKCFG_FSB_800:
                return 200000;
        case CLKCFG_FSB_1067:
+       case CLKCFG_FSB_1067_ALT:
                return 266667;
        case CLKCFG_FSB_1333:
+       case CLKCFG_FSB_1333_ALT:
                return 333333;
-       /* these two are just a guess; one of them might be right */
-       case CLKCFG_FSB_1600:
-       case CLKCFG_FSB_1600_ALT:
-               return 400000;
        default:
                return 133333;
        }
index 3ffe8b1f1d486f5e7352f50a62091cbb60831c83..fc0ef492252ac7c93f7b7ccb4e6a4b95d30f6294 100644 (file)
@@ -410,11 +410,10 @@ static void glk_dsi_device_ready(struct intel_encoder *encoder)
                val |= (ULPS_STATE_ENTER | DEVICE_READY);
                I915_WRITE(MIPI_DEVICE_READY(port), val);
 
-               /* Wait for ULPS Not active */
+               /* Wait for ULPS active */
                if (intel_wait_for_register(dev_priv,
-                               MIPI_CTRL(port), GLK_ULPS_NOT_ACTIVE,
-                               GLK_ULPS_NOT_ACTIVE, 20))
-                       DRM_ERROR("ULPS is still active\n");
+                               MIPI_CTRL(port), GLK_ULPS_NOT_ACTIVE, 0, 20))
+                       DRM_ERROR("ULPS not active\n");
 
                /* Exit ULPS */
                val = I915_READ(MIPI_DEVICE_READY(port));
index 25d8e76489e40ff989fd616386f03b36f9ba03fa..668f00480d97c0ff0418c19dfaaffec31fc65341 100644 (file)
@@ -63,6 +63,7 @@
 #include <linux/acpi.h>
 #include <linux/device.h>
 #include <linux/pci.h>
+#include <linux/pm_runtime.h>
 
 #include "i915_drv.h"
 #include <linux/delay.h>
@@ -121,6 +122,10 @@ lpe_audio_platdev_create(struct drm_i915_private *dev_priv)
 
        kfree(rsc);
 
+       pm_runtime_forbid(&platdev->dev);
+       pm_runtime_set_active(&platdev->dev);
+       pm_runtime_enable(&platdev->dev);
+
        return platdev;
 
 err:
index 21b10f9840c95e29cd177e9e36d93b8d6155b48d..549763f5e17d8f3c2de2e5d6dbe460363e98c923 100644 (file)
@@ -360,6 +360,8 @@ nouveau_display_hpd_work(struct work_struct *work)
        pm_runtime_get_sync(drm->dev->dev);
 
        drm_helper_hpd_irq_event(drm->dev);
+       /* enable polling for external displays */
+       drm_kms_helper_poll_enable(drm->dev);
 
        pm_runtime_mark_last_busy(drm->dev->dev);
        pm_runtime_put_sync(drm->dev->dev);
@@ -413,10 +415,6 @@ nouveau_display_init(struct drm_device *dev)
        if (ret)
                return ret;
 
-       /* enable polling for external displays */
-       if (!dev->mode_config.poll_enabled)
-               drm_kms_helper_poll_enable(dev);
-
        /* enable hotplug interrupts */
        list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
                struct nouveau_connector *conn = nouveau_connector(connector);
index 2b6ac24ce6901013fd1dc99b4b4e8b27de6125db..36268e1802b5afcd65c6b3d623b273c4ac60af87 100644 (file)
@@ -502,6 +502,9 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
                pm_runtime_allow(dev->dev);
                pm_runtime_mark_last_busy(dev->dev);
                pm_runtime_put(dev->dev);
+       } else {
+               /* enable polling for external displays */
+               drm_kms_helper_poll_enable(dev);
        }
        return 0;
 
@@ -774,9 +777,6 @@ nouveau_pmops_runtime_resume(struct device *dev)
 
        ret = nouveau_do_resume(drm_dev, true);
 
-       if (!drm_dev->mode_config.poll_enabled)
-               drm_kms_helper_poll_enable(drm_dev);
-
        /* do magic */
        nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
        vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
index 3a24788c3185ba6a65156389b7a6b849d13d3a11..a7e55c422501cf9c4fc98bc7e7798d2b2213cfcf 100644 (file)
@@ -148,7 +148,7 @@ gk104_fifo_runlist_commit(struct gk104_fifo *fifo, int runl)
        case NVKM_MEM_TARGET_NCOH: target = 3; break;
        default:
                WARN_ON(1);
-               return;
+               goto unlock;
        }
 
        nvkm_wr32(device, 0x002270, (nvkm_memory_addr(mem) >> 12) |
@@ -160,6 +160,7 @@ gk104_fifo_runlist_commit(struct gk104_fifo *fifo, int runl)
                                       & 0x00100000),
                               msecs_to_jiffies(2000)) == 0)
                nvkm_error(subdev, "runlist %d update timeout\n", runl);
+unlock:
        mutex_unlock(&subdev->mutex);
 }
 
index d1cf02d22db1ff24926ddd881b7f15cbcd78d82c..1b0c793c0192b940103701142e5561ffb1b5263a 100644 (file)
@@ -116,6 +116,7 @@ ls_ucode_img_load_gr(const struct nvkm_subdev *subdev, struct ls_ucode_img *img,
        ret = nvkm_firmware_get(subdev->device, f, &sig);
        if (ret)
                goto free_data;
+
        img->sig = kmemdup(sig->data, sig->size, GFP_KERNEL);
        if (!img->sig) {
                ret = -ENOMEM;
@@ -126,8 +127,9 @@ ls_ucode_img_load_gr(const struct nvkm_subdev *subdev, struct ls_ucode_img *img,
        img->ucode_data = ls_ucode_img_build(bl, code, data,
                                             &img->ucode_desc);
        if (IS_ERR(img->ucode_data)) {
+               kfree(img->sig);
                ret = PTR_ERR(img->ucode_data);
-               goto free_data;
+               goto free_sig;
        }
        img->ucode_size = img->ucode_desc.image_size;
 
index b2fd029d67b308ce60490d61cd908d743a9e520b..91916326957f9c3b842178b2c1cbdd60e9db5bf3 100644 (file)
@@ -1,6 +1,7 @@
 config TEGRA_HOST1X
        tristate "NVIDIA Tegra host1x driver"
        depends on ARCH_TEGRA || (ARM && COMPILE_TEST)
+       select IOMMU_IOVA if IOMMU_SUPPORT
        help
          Driver for the NVIDIA Tegra host1x hardware.
 
index 664b7fe206d65457cf3e7b1486a05b7e92493cb8..b11d3920b9a521b95142481106d420ac75643b26 100644 (file)
@@ -1809,10 +1809,6 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
        pdata->notify_pending = false;
        spin_unlock_irq(&pdata->lpe_audio_slock);
 
-       /* runtime PM isn't enabled as default, since it won't save much on
-        * BYT/CHT devices; user who want the runtime PM should adjust the
-        * power/ontrol and power/autosuspend_delay_ms sysfs entries instead
-        */
        pm_runtime_use_autosuspend(&pdev->dev);
        pm_runtime_mark_last_busy(&pdev->dev);
        pm_runtime_set_active(&pdev->dev);