Merge tag 'drm-for-v4.15-part2' of git://people.freedesktop.org/~airlied/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 24 Nov 2017 07:04:56 +0000 (21:04 -1000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 24 Nov 2017 07:04:56 +0000 (21:04 -1000)
Pull more drm updates from Dave Airlie:
 "Fixes/cleanups for rc1, non-desktop flags for VR

   - remove the MSM dt-bindings file Rob managed to push in the previous
     pull.

   - add a property/edid quirk to denote HMD devices, I had these
     hanging around for a few weeks and Keith had done some work on
     them, they are fairly self contained and small, and only affect
     people using HTC Vive VR headsets so far.

   - amdgpu, tegra, tilcdc, fsl fixes

   - some imx-drm cleanups I missed, these seemed pretty small, and no
     reason to hold off.

  I have one TTM regression fix (fixes bochs-vga in qemu) sitting
  locally awaiting review I'll probably send that in a separate pull
  request tomorrow"

* tag 'drm-for-v4.15-part2' of git://people.freedesktop.org/~airlied/linux: (33 commits)
  dt-bindings: remove file that was added accidentally
  drm/edid: quirk HTC vive headset as non-desktop. [v2]
  drm/fb: add support for not enabling fbcon on non-desktop displays [v2]
  drm: add connector info/property for non-desktop displays [v2]
  drm/amdgpu: fix rmmod KCQ disable failed error
  drm/amdgpu: fix kernel hang when starting VNC server
  drm/amdgpu: don't skip attributes when powerplay is enabled
  drm/amd/pp: fix typecast error in powerplay.
  drm/tilcdc: Remove obsolete "ti,tilcdc,slave" dts binding support
  drm/tegra: sor: Reimplement pad clock
  Revert "drm/radeon: dont switch vt on suspend"
  drm/amd/amdgpu: fix over-bound accessing in amdgpu_cs_wait_any_fence
  drm/amd/powerplay: fix unfreeze level smc message for smu7
  drm/amdgpu:fix memleak
  drm/amdgpu:fix memleak in takedown
  drm/amd/pp: fix dpm randomly failed on Vega10
  drm/amdgpu: set f_mapping on exported DMA-bufs
  drm/amdgpu: Properly allocate VM invalidate eng v2
  drm/fsl-dcu: enable IRQ before drm_atomic_helper_resume()
  drm/fsl-dcu: avoid disabling pixel clock twice on suspend
  ...

1  2 
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
drivers/gpu/drm/tilcdc/Makefile

index 6c78623e13863c6773d9dd4f7c4444de045f9f2b,bdef497a6a26253e3edbb216e76351b6c5fd7234..a57cec737c18ab1b8db405607042a4363493205b
@@@ -562,7 -562,8 +562,7 @@@ static int amdgpu_cs_parser_bos(struct 
                                 * invalidated it. Free it and try again
                                 */
                                release_pages(e->user_pages,
 -                                            bo->tbo.ttm->num_pages,
 -                                            false);
 +                                            bo->tbo.ttm->num_pages);
                                kvfree(e->user_pages);
                                e->user_pages = NULL;
                        }
@@@ -693,7 -694,8 +693,7 @@@ error_free_pages
                                continue;
  
                        release_pages(e->user_pages,
 -                                    e->robj->tbo.ttm->num_pages,
 -                                    false);
 +                                    e->robj->tbo.ttm->num_pages);
                        kvfree(e->user_pages);
                }
        }
        memset(wait, 0, sizeof(*wait));
        wait->out.status = (r > 0);
        wait->out.first_signaled = first;
-       /* set return value 0 to indicate success */
-       r = array[first]->error;
+       if (first < fence_count && array[first])
+               r = array[first]->error;
+       else
+               r = 0;
  
  err_free_fence_array:
        for (i = 0; i < fence_count; i++)
index 2d792cdc094cd60e86542c0ed5380c3590198fc2,2c85e0a98608d0a8fb4a1ae5991f6d6eece3b1ec..2c574374d9b6884e6c4473f2dd3ede86b7a612df
@@@ -31,7 -31,6 +31,7 @@@
  #include <linux/debugfs.h>
  #include <drm/drmP.h>
  #include <drm/drm_crtc_helper.h>
 +#include <drm/drm_atomic_helper.h>
  #include <drm/amdgpu_drm.h>
  #include <linux/vgaarb.h>
  #include <linux/vga_switcheroo.h>
@@@ -1837,6 -1836,9 +1837,9 @@@ static int amdgpu_fini(struct amdgpu_de
                adev->ip_blocks[i].status.hw = false;
        }
  
+       if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
+               amdgpu_ucode_fini_bo(adev);
        for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
                if (!adev->ip_blocks[i].status.sw)
                        continue;
@@@ -2047,52 -2049,6 +2050,52 @@@ static void amdgpu_device_detect_sriov_
        }
  }
  
 +bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
 +{
 +      switch (asic_type) {
 +#if defined(CONFIG_DRM_AMD_DC)
 +      case CHIP_BONAIRE:
 +      case CHIP_HAWAII:
 +      case CHIP_KAVERI:
 +      case CHIP_CARRIZO:
 +      case CHIP_STONEY:
 +      case CHIP_POLARIS11:
 +      case CHIP_POLARIS10:
 +      case CHIP_POLARIS12:
 +      case CHIP_TONGA:
 +      case CHIP_FIJI:
 +#if defined(CONFIG_DRM_AMD_DC_PRE_VEGA)
 +              return amdgpu_dc != 0;
 +#endif
 +      case CHIP_KABINI:
 +      case CHIP_MULLINS:
 +              return amdgpu_dc > 0;
 +      case CHIP_VEGA10:
 +#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
 +      case CHIP_RAVEN:
 +#endif
 +              return amdgpu_dc != 0;
 +#endif
 +      default:
 +              return false;
 +      }
 +}
 +
 +/**
 + * amdgpu_device_has_dc_support - check if dc is supported
 + *
 + * @adev: amdgpu_device_pointer
 + *
 + * Returns true for supported, false for not supported
 + */
 +bool amdgpu_device_has_dc_support(struct amdgpu_device *adev)
 +{
 +      if (amdgpu_sriov_vf(adev))
 +              return false;
 +
 +      return amdgpu_device_asic_has_dc_support(adev->asic_type);
 +}
 +
  /**
   * amdgpu_device_init - initialize the driver
   *
@@@ -2147,6 -2103,7 +2150,6 @@@ int amdgpu_device_init(struct amdgpu_de
        adev->audio_endpt_rreg = &amdgpu_block_invalid_rreg;
        adev->audio_endpt_wreg = &amdgpu_block_invalid_wreg;
  
 -
        DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X 0x%02X).\n",
                 amdgpu_asic_name[adev->asic_type], pdev->vendor, pdev->device,
                 pdev->subsystem_vendor, pdev->subsystem_device, pdev->revision);
                        goto failed;
                }
                /* init i2c buses */
 -              amdgpu_atombios_i2c_init(adev);
 +              if (!amdgpu_device_has_dc_support(adev))
 +                      amdgpu_atombios_i2c_init(adev);
        }
  
        /* Fence driver */
@@@ -2425,8 -2381,7 +2428,8 @@@ void amdgpu_device_fini(struct amdgpu_d
        adev->accel_working = false;
        cancel_delayed_work_sync(&adev->late_init_work);
        /* free i2c buses */
 -      amdgpu_i2c_fini(adev);
 +      if (!amdgpu_device_has_dc_support(adev))
 +              amdgpu_i2c_fini(adev);
        amdgpu_atombios_fini(adev);
        kfree(adev->bios);
        adev->bios = NULL;
@@@ -2477,14 -2432,12 +2480,14 @@@ int amdgpu_device_suspend(struct drm_de
  
        drm_kms_helper_poll_disable(dev);
  
 -      /* turn off display hw */
 -      drm_modeset_lock_all(dev);
 -      list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
 -              drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
 +      if (!amdgpu_device_has_dc_support(adev)) {
 +              /* turn off display hw */
 +              drm_modeset_lock_all(dev);
 +              list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
 +                      drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
 +              }
 +              drm_modeset_unlock_all(dev);
        }
 -      drm_modeset_unlock_all(dev);
  
        amdgpu_amdkfd_suspend(adev);
  
@@@ -2627,25 -2580,13 +2630,25 @@@ int amdgpu_device_resume(struct drm_dev
  
        /* blat the mode back in */
        if (fbcon) {
 -              drm_helper_resume_force_mode(dev);
 -              /* turn on display hw */
 -              drm_modeset_lock_all(dev);
 -              list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
 -                      drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
 +              if (!amdgpu_device_has_dc_support(adev)) {
 +                      /* pre DCE11 */
 +                      drm_helper_resume_force_mode(dev);
 +
 +                      /* turn on display hw */
 +                      drm_modeset_lock_all(dev);
 +                      list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
 +                              drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
 +                      }
 +                      drm_modeset_unlock_all(dev);
 +              } else {
 +                      /*
 +                       * There is no equivalent atomic helper to turn on
 +                       * display, so we defined our own function for this,
 +                       * once suspend resume is supported by the atomic
 +                       * framework this will be reworked
 +                       */
 +                      amdgpu_dm_display_resume(adev);
                }
 -              drm_modeset_unlock_all(dev);
        }
  
        drm_kms_helper_poll_enable(dev);
  #ifdef CONFIG_PM
        dev->dev->power.disable_depth++;
  #endif
 -      drm_helper_hpd_irq_event(dev);
 +      if (!amdgpu_device_has_dc_support(adev))
 +              drm_helper_hpd_irq_event(dev);
 +      else
 +              drm_kms_helper_hotplug_event(dev);
  #ifdef CONFIG_PM
        dev->dev->power.disable_depth--;
  #endif
@@@ -2965,7 -2903,6 +2968,7 @@@ give_up_reset
   */
  int amdgpu_gpu_reset(struct amdgpu_device *adev)
  {
 +      struct drm_atomic_state *state = NULL;
        int i, r;
        int resched;
        bool need_full_reset, vram_lost = false;
  
        /* block TTM */
        resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
 +      /* store modesetting */
 +      if (amdgpu_device_has_dc_support(adev))
 +              state = drm_atomic_helper_suspend(adev->ddev);
  
        /* block scheduler */
        for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
                }
        }
  
 -      drm_helper_resume_force_mode(adev->ddev);
 +      if (amdgpu_device_has_dc_support(adev)) {
 +              r = drm_atomic_helper_resume(adev->ddev, state);
 +              amdgpu_dm_display_resume(adev);
 +      } else
 +              drm_helper_resume_force_mode(adev->ddev);
  
        ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched);
        if (r) {
@@@ -3261,9 -3191,9 +3264,9 @@@ static ssize_t amdgpu_debugfs_regs_read
        pm_pg_lock = (*pos >> 23) & 1;
  
        if (*pos & (1ULL << 62)) {
-               se_bank = (*pos >> 24) & 0x3FF;
-               sh_bank = (*pos >> 34) & 0x3FF;
-               instance_bank = (*pos >> 44) & 0x3FF;
+               se_bank = (*pos & GENMASK_ULL(33, 24)) >> 24;
+               sh_bank = (*pos & GENMASK_ULL(43, 34)) >> 34;
+               instance_bank = (*pos & GENMASK_ULL(53, 44)) >> 44;
  
                if (se_bank == 0x3FF)
                        se_bank = 0xFFFFFFFF;
@@@ -3337,9 -3267,9 +3340,9 @@@ static ssize_t amdgpu_debugfs_regs_writ
        pm_pg_lock = (*pos >> 23) & 1;
  
        if (*pos & (1ULL << 62)) {
-               se_bank = (*pos >> 24) & 0x3FF;
-               sh_bank = (*pos >> 34) & 0x3FF;
-               instance_bank = (*pos >> 44) & 0x3FF;
+               se_bank = (*pos & GENMASK_ULL(33, 24)) >> 24;
+               sh_bank = (*pos & GENMASK_ULL(43, 34)) >> 34;
+               instance_bank = (*pos & GENMASK_ULL(53, 44)) >> 44;
  
                if (se_bank == 0x3FF)
                        se_bank = 0xFFFFFFFF;
@@@ -3687,12 -3617,12 +3690,12 @@@ static ssize_t amdgpu_debugfs_wave_read
                return -EINVAL;
  
        /* decode offset */
-       offset = (*pos & 0x7F);
-       se = ((*pos >> 7) & 0xFF);
-       sh = ((*pos >> 15) & 0xFF);
-       cu = ((*pos >> 23) & 0xFF);
-       wave = ((*pos >> 31) & 0xFF);
-       simd = ((*pos >> 37) & 0xFF);
+       offset = (*pos & GENMASK_ULL(6, 0));
+       se = (*pos & GENMASK_ULL(14, 7)) >> 7;
+       sh = (*pos & GENMASK_ULL(22, 15)) >> 15;
+       cu = (*pos & GENMASK_ULL(30, 23)) >> 23;
+       wave = (*pos & GENMASK_ULL(36, 31)) >> 31;
+       simd = (*pos & GENMASK_ULL(44, 37)) >> 37;
  
        /* switch to the specific se/sh/cu */
        mutex_lock(&adev->grbm_idx_mutex);
@@@ -3737,14 -3667,14 +3740,14 @@@ static ssize_t amdgpu_debugfs_gpr_read(
                return -EINVAL;
  
        /* decode offset */
-       offset = (*pos & 0xFFF);       /* in dwords */
-       se = ((*pos >> 12) & 0xFF);
-       sh = ((*pos >> 20) & 0xFF);
-       cu = ((*pos >> 28) & 0xFF);
-       wave = ((*pos >> 36) & 0xFF);
-       simd = ((*pos >> 44) & 0xFF);
-       thread = ((*pos >> 52) & 0xFF);
-       bank = ((*pos >> 60) & 1);
+       offset = *pos & GENMASK_ULL(11, 0);
+       se = (*pos & GENMASK_ULL(19, 12)) >> 12;
+       sh = (*pos & GENMASK_ULL(27, 20)) >> 20;
+       cu = (*pos & GENMASK_ULL(35, 28)) >> 28;
+       wave = (*pos & GENMASK_ULL(43, 36)) >> 36;
+       simd = (*pos & GENMASK_ULL(51, 44)) >> 44;
+       thread = (*pos & GENMASK_ULL(59, 52)) >> 52;
+       bank = (*pos & GENMASK_ULL(61, 60)) >> 60;
  
        data = kmalloc_array(1024, sizeof(*data), GFP_KERNEL);
        if (!data)
index a418df1b942274579e4da7a767e0138d95c38c90,14aff2f15a946007ff1ebfb5a404bb81056e5658..e87eedcc0da9d5363d7742782281683d6bb842dd
@@@ -63,6 -63,11 +63,11 @@@ retry
                             flags, NULL, resv, 0, &bo);
        if (r) {
                if (r != -ERESTARTSYS) {
+                       if (flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
+                               flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
+                               goto retry;
+                       }
                        if (initial_domain == AMDGPU_GEM_DOMAIN_VRAM) {
                                initial_domain |= AMDGPU_GEM_DOMAIN_GTT;
                                goto retry;
@@@ -323,7 -328,7 +328,7 @@@ int amdgpu_gem_userptr_ioctl(struct drm
                r = amdgpu_ttm_tt_get_user_pages(bo->tbo.ttm,
                                                 bo->tbo.ttm->pages);
                if (r)
-                       goto unlock_mmap_sem;
+                       goto release_object;
  
                r = amdgpu_bo_reserve(bo, true);
                if (r)
        return 0;
  
  free_pages:
 -      release_pages(bo->tbo.ttm->pages, bo->tbo.ttm->num_pages, false);
 +      release_pages(bo->tbo.ttm->pages, bo->tbo.ttm->num_pages);
  
- unlock_mmap_sem:
-       up_read(&current->mm->mmap_sem);
  release_object:
        drm_gem_object_put_unlocked(gobj);
  
@@@ -556,9 -558,8 +558,8 @@@ int amdgpu_gem_va_ioctl(struct drm_devi
  
        if (args->va_address < AMDGPU_VA_RESERVED_SIZE) {
                dev_err(&dev->pdev->dev,
-                       "va_address 0x%lX is in reserved area 0x%X\n",
-                       (unsigned long)args->va_address,
-                       AMDGPU_VA_RESERVED_SIZE);
+                       "va_address 0x%LX is in reserved area 0x%LX\n",
+                       args->va_address, AMDGPU_VA_RESERVED_SIZE);
                return -EINVAL;
        }
  
@@@ -786,11 -787,11 +787,11 @@@ static int amdgpu_debugfs_gem_bo_info(i
        seq_printf(m, "\t0x%08x: %12ld byte %s",
                   id, amdgpu_bo_size(bo), placement);
  
 -      offset = ACCESS_ONCE(bo->tbo.mem.start);
 +      offset = READ_ONCE(bo->tbo.mem.start);
        if (offset != AMDGPU_BO_INVALID_OFFSET)
                seq_printf(m, " @ 0x%010Lx", offset);
  
 -      pin_count = ACCESS_ONCE(bo->pin_count);
 +      pin_count = READ_ONCE(bo->pin_count);
        if (pin_count)
                seq_printf(m, " pin count %d", pin_count);
        seq_printf(m, "\n");
index d6df5728df7fca04648daa9677bc03d8dafd830f,ce00f629dccec5559a4edd3e29a3b29e1e48feb1..6c570d4e4516488b81cd385353b8d02c7e428912
@@@ -946,6 -946,10 +946,10 @@@ static umode_t hwmon_attributes_visible
        struct amdgpu_device *adev = dev_get_drvdata(dev);
        umode_t effective_mode = attr->mode;
  
+       /* no skipping for powerplay */
+       if (adev->powerplay.cgs_device)
+               return effective_mode;
        /* Skip limit attributes if DPM is not enabled */
        if (!adev->pm.dpm_enabled &&
            (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr ||
@@@ -1466,7 -1470,7 +1470,7 @@@ void amdgpu_pm_compute_clocks(struct am
                        list_for_each_entry(crtc,
                                            &ddev->mode_config.crtc_list, head) {
                                amdgpu_crtc = to_amdgpu_crtc(crtc);
 -                              if (crtc->enabled) {
 +                              if (amdgpu_crtc->enabled) {
                                        adev->pm.dpm.new_active_crtcs |= (1 << amdgpu_crtc->crtc_id);
                                        adev->pm.dpm.new_active_crtc_count++;
                                }
index b9e1108e5b4e81e8c6a9926361abff0c5226248a,efc2c4f00daa8be0d7ba6aebb6fdbfa1d3e88b16..87f9480e43b05f0fa707f2e84c3fe6f5774fb56d
@@@ -1,11 -1,7 +1,8 @@@
 +# SPDX-License-Identifier: GPL-2.0
  ifeq (, $(findstring -W,$(EXTRA_CFLAGS)))
        ccflags-y += -Werror
  endif
  
- obj-$(CONFIG_DRM_TILCDC_SLAVE_COMPAT) += tilcdc_slave_compat.o \
-                                        tilcdc_slave_compat.dtb.o
  tilcdc-y := \
        tilcdc_plane.o \
        tilcdc_crtc.o \