Merge branch 'msm-next-lumag-dpu' into msm-next-lumag
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Thu, 6 Apr 2023 17:29:50 +0000 (20:29 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Thu, 6 Apr 2023 17:29:50 +0000 (20:29 +0300)
Merge DPU changes, resolving conflicts between branches. Full changelog
will be present in the final merge commit.

DPU:
 - DSPP sub-block flush on sc7280
 - support AR30 in addition to XR30 format
 - Allow using REC_0 and REC_1 to handle wide (4k) RGB planes

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
1  2 
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_drv.h

@@@ -8,12 -8,10 +8,12 @@@
  #include <linux/dma-mapping.h>
  #include <linux/fault-inject.h>
  #include <linux/kthread.h>
 +#include <linux/of_address.h>
  #include <linux/sched/mm.h>
  #include <linux/uaccess.h>
  #include <uapi/linux/sched/types.h>
  
 +#include <drm/drm_aperture.h>
  #include <drm/drm_bridge.h>
  #include <drm/drm_drv.h>
  #include <drm/drm_file.h>
  #define MSM_VERSION_MINOR     10
  #define MSM_VERSION_PATCHLEVEL        0
  
 +static void msm_deinit_vram(struct drm_device *ddev);
 +
  static const struct drm_mode_config_funcs mode_config_funcs = {
        .fb_create = msm_framebuffer_create,
-       .atomic_check = drm_atomic_helper_check,
 -      .output_poll_changed = drm_fb_helper_output_poll_changed,
+       .atomic_check = msm_atomic_check,
        .atomic_commit = drm_atomic_helper_commit,
  };
  
@@@ -66,6 -63,12 +66,6 @@@ static const struct drm_mode_config_hel
        .atomic_commit_tail = msm_atomic_commit_tail,
  };
  
 -#ifdef CONFIG_DRM_FBDEV_EMULATION
 -static bool fbdev = true;
 -MODULE_PARM_DESC(fbdev, "Enable fbdev compat layer");
 -module_param(fbdev, bool, 0600);
 -#endif
 -
  static char *vram = "16m";
  MODULE_PARM_DESC(vram, "Configure VRAM size (for devices without IOMMU/GPUMMU)");
  module_param(vram, charp, 0);
@@@ -148,6 -151,9 +148,6 @@@ static void msm_irq_uninstall(struct dr
        struct msm_drm_private *priv = dev->dev_private;
        struct msm_kms *kms = priv->kms;
  
 -      if (!priv->kms)
 -              return;
 -
        kms->funcs->irq_uninstall(kms);
        if (kms->irq_requested)
                free_irq(kms->irq, dev);
@@@ -235,8 -241,12 +235,8 @@@ static int msm_drm_uninit(struct devic
        msm_perf_debugfs_cleanup(priv);
        msm_rd_debugfs_cleanup(priv);
  
 -#ifdef CONFIG_DRM_FBDEV_EMULATION
 -      if (fbdev && priv->fbdev)
 -              msm_fbdev_free(ddev);
 -#endif
 -
 -      msm_disp_snapshot_destroy(ddev);
 +      if (kms)
 +              msm_disp_snapshot_destroy(ddev);
  
        drm_mode_config_cleanup(ddev);
  
                drm_bridge_remove(priv->bridges[i]);
        priv->num_bridges = 0;
  
 -      pm_runtime_get_sync(dev);
 -      msm_irq_uninstall(ddev);
 -      pm_runtime_put_sync(dev);
 +      if (kms) {
 +              pm_runtime_get_sync(dev);
 +              msm_irq_uninstall(ddev);
 +              pm_runtime_put_sync(dev);
 +      }
  
        if (kms && kms->funcs)
                kms->funcs->destroy(kms);
  
 -      if (priv->vram.paddr) {
 -              unsigned long attrs = DMA_ATTR_NO_KERNEL_MAPPING;
 -              drm_mm_takedown(&priv->vram.mm);
 -              dma_free_attrs(dev, priv->vram.size, NULL,
 -                             priv->vram.paddr, attrs);
 -      }
 +      msm_deinit_vram(ddev);
  
        component_unbind_all(dev, ddev);
  
        ddev->dev_private = NULL;
 +      drm_dev_put(ddev);
 +
        destroy_workqueue(priv->wq);
  
        return 0;
  }
  
 -#include <linux/of_address.h>
 -
  struct msm_gem_address_space *msm_kms_init_aspace(struct drm_device *dev)
  {
        struct msm_gem_address_space *aspace;
@@@ -389,19 -402,6 +389,19 @@@ static int msm_init_vram(struct drm_dev
        return ret;
  }
  
 +static void msm_deinit_vram(struct drm_device *ddev)
 +{
 +      struct msm_drm_private *priv = ddev->dev_private;
 +      unsigned long attrs = DMA_ATTR_NO_KERNEL_MAPPING;
 +
 +      if (!priv->vram.paddr)
 +              return;
 +
 +      drm_mm_takedown(&priv->vram.mm);
 +      dma_free_attrs(ddev->dev, priv->vram.size, NULL, priv->vram.paddr,
 +                      attrs);
 +}
 +
  static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
  {
        struct msm_drm_private *priv = dev_get_drvdata(dev);
        priv->dev = ddev;
  
        priv->wq = alloc_ordered_workqueue("msm", 0);
 -      if (!priv->wq)
 -              return -ENOMEM;
 +      if (!priv->wq) {
 +              ret = -ENOMEM;
 +              goto err_put_dev;
 +      }
  
        INIT_LIST_HEAD(&priv->objects);
        mutex_init(&priv->obj_lock);
  
        ret = msm_init_vram(ddev);
        if (ret)
 -              goto err_drm_dev_put;
 +              goto err_cleanup_mode_config;
  
        /* Bind all our sub-components: */
        ret = component_bind_all(dev, ddev);
        if (ret)
 -              goto err_drm_dev_put;
 +              goto err_deinit_vram;
 +
 +      /* the fw fb could be anywhere in memory */
 +      ret = drm_aperture_remove_framebuffers(false, drv);
 +      if (ret)
 +              goto err_msm_uninit;
  
        dma_set_max_seg_size(dev, UINT_MAX);
  
        }
        drm_mode_config_reset(ddev);
  
 -#ifdef CONFIG_DRM_FBDEV_EMULATION
 -      if (kms && fbdev)
 -              priv->fbdev = msm_fbdev_init(ddev);
 -#endif
 -
        ret = msm_debugfs_late_init(ddev);
        if (ret)
                goto err_msm_uninit;
  
        drm_kms_helper_poll_init(ddev);
  
 +      if (kms)
 +              msm_fbdev_setup(ddev);
 +
        return 0;
  
  err_msm_uninit:
        msm_drm_uninit(dev);
 -err_drm_dev_put:
 +
 +      return ret;
 +
 +err_deinit_vram:
 +      msm_deinit_vram(ddev);
 +err_cleanup_mode_config:
 +      drm_mode_config_cleanup(ddev);
 +      destroy_workqueue(priv->wq);
 +err_put_dev:
        drm_dev_put(ddev);
 +
        return ret;
  }
  
@@@ -1084,6 -1070,7 +1084,6 @@@ static const struct drm_driver msm_driv
                                DRIVER_SYNCOBJ,
        .open               = msm_open,
        .postclose           = msm_postclose,
 -      .lastclose          = drm_fb_helper_lastclose,
        .dumb_create        = msm_gem_dumb_create,
        .dumb_map_offset    = msm_gem_dumb_map_offset,
        .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
@@@ -29,6 -29,7 +29,6 @@@
  #include <drm/drm_atomic.h>
  #include <drm/drm_atomic_helper.h>
  #include <drm/drm_probe_helper.h>
 -#include <drm/drm_fb_helper.h>
  #include <drm/display/drm_dsc.h>
  #include <drm/msm_drm.h>
  #include <drm/drm_gem.h>
@@@ -128,6 -129,8 +128,6 @@@ struct msm_drm_private 
        bool is_a2xx;
        bool has_cached_coherent;
  
 -      struct drm_fb_helper *fbdev;
 -
        struct msm_rd_state *rd;       /* debugfs to dump all submits */
        struct msm_rd_state *hangrd;   /* debugfs to dump hanging submits */
        struct msm_perf_state *perf;
@@@ -258,6 -261,7 +258,7 @@@ int msm_atomic_init_pending_timer(struc
                struct msm_kms *kms, int crtc_idx);
  void msm_atomic_destroy_pending_timer(struct msm_pending_timer *timer);
  void msm_atomic_commit_tail(struct drm_atomic_state *state);
+ int msm_atomic_check(struct drm_device *dev, struct drm_atomic_state *state);
  struct drm_atomic_state *msm_atomic_state_alloc(struct drm_device *dev);
  void msm_atomic_state_clear(struct drm_atomic_state *state);
  void msm_atomic_state_free(struct drm_atomic_state *state);
@@@ -303,13 -307,8 +304,13 @@@ struct drm_framebuffer *msm_framebuffer
  struct drm_framebuffer * msm_alloc_stolen_fb(struct drm_device *dev,
                int w, int h, int p, uint32_t format);
  
 -struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev);
 -void msm_fbdev_free(struct drm_device *dev);
 +#ifdef CONFIG_DRM_FBDEV_EMULATION
 +void msm_fbdev_setup(struct drm_device *dev);
 +#else
 +static inline void msm_fbdev_setup(struct drm_device *dev)
 +{
 +}
 +#endif
  
  struct hdmi;
  #ifdef CONFIG_DRM_MSM_HDMI
@@@ -550,7 -549,7 +551,7 @@@ static inline unsigned long timeout_to_
                remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
        }
  
 -      return clamp(remaining_jiffies, 0LL, (s64)INT_MAX);
 +      return clamp(remaining_jiffies, 1LL, (s64)INT_MAX);
  }
  
  /* Driver helpers */