Re: [PATCH v4 12/14] drm/scheduler: Job timeout handler returns status

2021-01-18 Thread Christian König

Am 18.01.21 um 22:01 schrieb Andrey Grodzovsky:

From: Luben Tuikov 

This patch does not change current behaviour.

The driver's job timeout handler now returns
status indicating back to the DRM layer whether
the task (job) was successfully aborted or whether
more time should be given to the task to complete.

Default behaviour as of this patch, is preserved,
except in obvious-by-comment case in the Panfrost
driver, as documented below.

All drivers which make use of the
drm_sched_backend_ops' .timedout_job() callback
have been accordingly renamed and return the
would've-been default value of
DRM_TASK_STATUS_ALIVE to restart the task's
timeout timer--this is the old behaviour, and
is preserved by this patch.

In the case of the Panfrost driver, its timedout
callback correctly first checks if the job had
completed in due time and if so, it now returns
DRM_TASK_STATUS_COMPLETE to notify the DRM layer
that the task can be moved to the done list, to be
freed later. In the other two subsequent checks,
the value of DRM_TASK_STATUS_ALIVE is returned, as
per the default behaviour.

A more involved driver's solutions can be had
in subequent patches.

v2: Use enum as the status of a driver's job
 timeout callback method.

v4: (By Andrey Grodzovsky)
Replace DRM_TASK_STATUS_COMPLETE with DRM_TASK_STATUS_ENODEV
to enable a hint to the schduler for when NOT to rearm the
timeout timer.


As Lukas pointed out returning the job (or task) status doesn't make 
much sense.


What we return here is the status of the scheduler.

I would either rename the enum or completely drop it and return a 
negative error status.


Apart from that looks fine to me,
Christian.




Cc: Alexander Deucher 
Cc: Andrey Grodzovsky 
Cc: Christian König 
Cc: Daniel Vetter 
Cc: Lucas Stach 
Cc: Russell King 
Cc: Christian Gmeiner 
Cc: Qiang Yu 
Cc: Rob Herring 
Cc: Tomeu Vizoso 
Cc: Steven Price 
Cc: Alyssa Rosenzweig 
Cc: Eric Anholt 
Reported-by: kernel test robot 
Signed-off-by: Luben Tuikov 
Signed-off-by: Andrey Grodzovsky 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c |  6 --
  drivers/gpu/drm/etnaviv/etnaviv_sched.c | 10 +-
  drivers/gpu/drm/lima/lima_sched.c   |  4 +++-
  drivers/gpu/drm/panfrost/panfrost_job.c |  9 ++---
  drivers/gpu/drm/scheduler/sched_main.c  |  4 +---
  drivers/gpu/drm/v3d/v3d_sched.c | 32 +---
  include/drm/gpu_scheduler.h | 17 ++---
  7 files changed, 54 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index ff48101..a111326 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -28,7 +28,7 @@
  #include "amdgpu.h"
  #include "amdgpu_trace.h"
  
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)

+static enum drm_task_status amdgpu_job_timedout(struct drm_sched_job *s_job)
  {
struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
struct amdgpu_job *job = to_amdgpu_job(s_job);
@@ -41,7 +41,7 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) 
{
DRM_ERROR("ring %s timeout, but soft recovered\n",
  s_job->sched->name);
-   return;
+   return DRM_TASK_STATUS_ALIVE;
}
  
  	amdgpu_vm_get_task_info(ring->adev, job->pasid, );

@@ -53,10 +53,12 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
  
  	if (amdgpu_device_should_recover_gpu(ring->adev)) {

amdgpu_device_gpu_recover(ring->adev, job);
+   return DRM_TASK_STATUS_ALIVE;
} else {
drm_sched_suspend_timeout(>sched);
if (amdgpu_sriov_vf(adev))
adev->virt.tdr_debug = true;
+   return DRM_TASK_STATUS_ALIVE;
}
  }
  
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c b/drivers/gpu/drm/etnaviv/etnaviv_sched.c

index cd46c88..c495169 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
@@ -82,7 +82,8 @@ static struct dma_fence *etnaviv_sched_run_job(struct 
drm_sched_job *sched_job)
return fence;
  }
  
-static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job)

+static enum drm_task_status etnaviv_sched_timedout_job(struct drm_sched_job
+  *sched_job)
  {
struct etnaviv_gem_submit *submit = to_etnaviv_submit(sched_job);
struct etnaviv_gpu *gpu = submit->gpu;
@@ -120,9 +121,16 @@ static void etnaviv_sched_timedout_job(struct 
drm_sched_job *sched_job)
  
  	drm_sched_resubmit_jobs(>sched);
  
+	/* Tell the DRM scheduler that this task needs

+* more time.
+*/
+   drm_sched_start(>sched, true);
+   return DRM_TASK_STATUS_ALIVE;
+
  out_no_timeout:
/* restart scheduler after GPU is usable 

Re: [PATCH v4 10/14] dmr/amdgpu: Move some sysfs attrs creation to default_attr

2021-01-18 Thread Greg KH
On Mon, Jan 18, 2021 at 04:01:19PM -0500, Andrey Grodzovsky wrote:
>  static struct pci_driver amdgpu_kms_pci_driver = {
>   .name = DRIVER_NAME,
>   .id_table = pciidlist,
> @@ -1595,6 +1607,7 @@ static struct pci_driver amdgpu_kms_pci_driver = {
>   .shutdown = amdgpu_pci_shutdown,
>   .driver.pm = _pm_ops,
>   .err_handler = _pci_err_handler,
> + .driver.dev_groups = amdgpu_sysfs_groups,

Shouldn't this just be:
groups - amdgpu_sysfs_groups,

Why go to the "driver root" here?

Other than that tiny thing, looks good to me, nice cleanup!

greg k-h
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] drm/virtio: Track total GPU memory for virtio driver

2021-01-18 Thread Daniel Vetter
On Tue, Jan 19, 2021 at 12:41 AM Yiwei Zhang  wrote:
>
> On the success of virtio_gpu_object_create, add size of newly allocated
> bo to the tracled total_mem. In drm_gem_object_funcs.free, after the gem
> bo lost its last refcount, subtract the bo size from the tracked
> total_mem if the original underlying memory allocation is successful.
>
> Signed-off-by: Yiwei Zhang 

Isn't this something that ideally we'd for everyone? Also tracepoint
for showing the total feels like tracepoint abuse, usually we show
totals somewhere in debugfs or similar, and tracepoint just for what's
happening (i.e. which object got deleted/created).

What is this for exactly?
-Daniel

> ---
>  drivers/gpu/drm/virtio/Kconfig  |  1 +
>  drivers/gpu/drm/virtio/virtgpu_drv.h|  4 
>  drivers/gpu/drm/virtio/virtgpu_object.c | 19 +++
>  3 files changed, 24 insertions(+)
>
> diff --git a/drivers/gpu/drm/virtio/Kconfig b/drivers/gpu/drm/virtio/Kconfig
> index b925b8b1da16..e103b7e883b1 100644
> --- a/drivers/gpu/drm/virtio/Kconfig
> +++ b/drivers/gpu/drm/virtio/Kconfig
> @@ -5,6 +5,7 @@ config DRM_VIRTIO_GPU
> select DRM_KMS_HELPER
> select DRM_GEM_SHMEM_HELPER
> select VIRTIO_DMA_SHARED_BUFFER
> +   select TRACE_GPU_MEM
> help
>This is the virtual GPU driver for virtio.  It can be used with
>QEMU based VMMs (like KVM or Xen).
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h 
> b/drivers/gpu/drm/virtio/virtgpu_drv.h
> index 6a232553c99b..7c60e7486bc4 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.h
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
> @@ -249,6 +249,10 @@ struct virtio_gpu_device {
> spinlock_t resource_export_lock;
> /* protects map state and host_visible_mm */
> spinlock_t host_visible_lock;
> +
> +#ifdef CONFIG_TRACE_GPU_MEM
> +   atomic64_t total_mem;
> +#endif
>  };
>
>  struct virtio_gpu_fpriv {
> diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c 
> b/drivers/gpu/drm/virtio/virtgpu_object.c
> index d69a5b6da553..1e16226cebbe 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_object.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_object.c
> @@ -25,12 +25,29 @@
>
>  #include 
>  #include 
> +#ifdef CONFIG_TRACE_GPU_MEM
> +#include 
> +#endif
>
>  #include "virtgpu_drv.h"
>
>  static int virtio_gpu_virglrenderer_workaround = 1;
>  module_param_named(virglhack, virtio_gpu_virglrenderer_workaround, int, 
> 0400);
>
> +#ifdef CONFIG_TRACE_GPU_MEM
> +static inline void virtio_gpu_trace_total_mem(struct virtio_gpu_device 
> *vgdev,
> + s64 delta)
> +{
> +   u64 total_mem = atomic64_add_return(delta, >total_mem);
> +
> +   trace_gpu_mem_total(0, 0, total_mem);
> +}
> +#else
> +static inline void virtio_gpu_trace_total_mem(struct virtio_gpu_device *, 
> s64)
> +{
> +}
> +#endif
> +
>  int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, uint32_t 
> *resid)
>  {
> if (virtio_gpu_virglrenderer_workaround) {
> @@ -104,6 +121,7 @@ static void virtio_gpu_free_object(struct drm_gem_object 
> *obj)
> struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private;
>
> if (bo->created) {
> +   virtio_gpu_trace_total_mem(vgdev, -(obj->size));
> virtio_gpu_cmd_unref_resource(vgdev, bo);
> virtio_gpu_notify(vgdev);
> /* completion handler calls virtio_gpu_cleanup_object() */
> @@ -265,6 +283,7 @@ int virtio_gpu_object_create(struct virtio_gpu_device 
> *vgdev,
> virtio_gpu_object_attach(vgdev, bo, ents, nents);
> }
>
> +   virtio_gpu_trace_total_mem(vgdev, shmem_obj->base.size);
> *bo_ptr = bo;
> return 0;
>
> --
> 2.30.0.284.gd98b1dd5eaa7-goog
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[drm-intel:drm-intel-next 8/19] drivers/gpu/drm/i915/display/intel_hdcp.c:817 _intel_hdcp_disable() error: uninitialized symbol 'ret'.

2021-01-18 Thread Dan Carpenter
tree:   git://anongit.freedesktop.org/drm-intel drm-intel-next
head:   d5a0d4b9380a499cc140c7ee04ec80e15a8d49e5
commit: 2a743b7b8a8be8c8fc7c130c304c1243f6bbe9b7 [8/19] drm/i915/hdcp: 
Configure HDCP1.4 MST steram encryption status
config: x86_64-randconfig-m001-20210115 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 
Reported-by: Dan Carpenter 

smatch warnings:
drivers/gpu/drm/i915/display/intel_hdcp.c:817 _intel_hdcp_disable() error: 
uninitialized symbol 'ret'.

vim +/ret +817 drivers/gpu/drm/i915/display/intel_hdcp.c

ee5e5e7a5e0fde drivers/gpu/drm/i915/intel_hdcp.c Sean Paul   
2018-01-08  788  static int _intel_hdcp_disable(struct intel_connector 
*connector)
ee5e5e7a5e0fde drivers/gpu/drm/i915/intel_hdcp.c Sean Paul   
2018-01-08  789  {
7801f3b792b0fd drivers/gpu/drm/i915/display/intel_hdcp.c Lucas De Marchi 
2020-06-30  790struct intel_digital_port *dig_port = 
intel_attached_dig_port(connector);
486bba4524e00c drivers/gpu/drm/i915/display/intel_hdcp.c Ville Syrjälä   
2019-12-04  791struct drm_i915_private *dev_priv = 
to_i915(connector->base.dev);
486bba4524e00c drivers/gpu/drm/i915/display/intel_hdcp.c Ville Syrjälä   
2019-12-04  792struct intel_hdcp *hdcp = >hdcp;
7801f3b792b0fd drivers/gpu/drm/i915/display/intel_hdcp.c Lucas De Marchi 
2020-06-30  793enum port port = dig_port->base.port;
692059318c0fc6 drivers/gpu/drm/i915/display/intel_hdcp.c Ramalingam C
2019-08-28  794enum transcoder cpu_transcoder = hdcp->cpu_transcoder;
2cc0c7b520bf8e drivers/gpu/drm/i915/display/intel_hdcp.c Sean Paul   
2020-08-18  795u32 repeater_ctl;
ee5e5e7a5e0fde drivers/gpu/drm/i915/intel_hdcp.c Sean Paul   
2018-01-08  796int ret;

^^^

ee5e5e7a5e0fde drivers/gpu/drm/i915/intel_hdcp.c Sean Paul   
2018-01-08  797  
65833c463886fa drivers/gpu/drm/i915/display/intel_hdcp.c Wambui Karuga   
2020-01-22  798drm_dbg_kms(_priv->drm, "[%s:%d] HDCP is being 
disabled...\n",
cb340bf37173d6 drivers/gpu/drm/i915/intel_hdcp.c Ramalingam C
2018-02-03  799connector->base.name, 
connector->base.base.id);
cb340bf37173d6 drivers/gpu/drm/i915/intel_hdcp.c Ramalingam C
2018-02-03  800  
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  801if (hdcp->shim->stream_encryption) {
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  802ret = hdcp->shim->stream_encryption(connector, 
false);
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  803if (ret) {
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  804drm_err(_priv->drm, "[%s:%d] Failed 
to disable HDCP 1.4 stream enc\n",
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  805connector->base.name, 
connector->base.base.id);
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  806return ret;
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  807}
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  808drm_dbg_kms(_priv->drm, "HDCP 1.4 
transcoder: %s stream encryption disabled\n",
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  809
transcoder_name(hdcp->stream_transcoder));
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  810}
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  811  
36e5e7042b2020 drivers/gpu/drm/i915/display/intel_hdcp.c Sean Paul   
2020-08-18  812/*
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  813 * If there are other connectors on this port using 
HDCP, don't disable it
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  814 * until it disabled HDCP encryption for all connectors 
in MST topology.
36e5e7042b2020 drivers/gpu/drm/i915/display/intel_hdcp.c Sean Paul   
2020-08-18  815 */
2a743b7b8a8be8 drivers/gpu/drm/i915/display/intel_hdcp.c Anshuman Gupta  
2021-01-11  816if (dig_port->num_hdcp_streams > 0)
36e5e7042b2020 drivers/gpu/drm/i915/display/intel_hdcp.c Sean Paul   
2020-08-18 @817return ret;

Presumably an error code was intended instead of an unintialized variable.

36e5e7042b2020 drivers/gpu/drm/i915/display/intel_hdcp.c Sean Paul   
2020-08-18  818  
09d56393c1d8d5 

Re: Reboot crash at msm_atomic_commit_tail

2021-01-18 Thread Daniel Vetter
On Mon, Jan 18, 2021 at 11:00 PM Fabio Estevam  wrote:
>
> On Mon, Jan 18, 2021 at 6:44 PM Fabio Estevam  wrote:
> >
> > Adding some more folks in case anyone has any suggestions to fix this
> > reboot hang.
>
> Not sure if this is a valid fix, but the change below makes reboot
> works correctly.
>
> kmscube still works.
>
> --- a/drivers/gpu/drm/msm/msm_atomic.c
> +++ b/drivers/gpu/drm/msm/msm_atomic.c
> @@ -207,8 +207,12 @@ void msm_atomic_commit_tail(struct drm_atomic_state 
> *state)
> struct msm_kms *kms = priv->kms;
> struct drm_crtc *async_crtc = NULL;
> unsigned crtc_mask = get_crtc_mask(state);
> -   bool async = kms->funcs->vsync_time &&
> -   can_do_async(state, _crtc);
> +   bool async;
> +
> +   if (!kms)
> +   return;

That looks a bit like a hack papering over the real issue.

>From your report it sounds like earlier kernels worked, did you
attempt bisecting? Also for regressions put regressions into the
subject, it's the magic work that gets much more attention.
-Daniel

> +
> +   async = kms->funcs->vsync_time && can_do_async(state, _crtc);
>
> trace_msm_atomic_commit_tail_start(async, crtc_mask);
>
> Any comments?
>
> Thanks
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel



-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [PATCH v2] drm/ast: Disable fast reset after DRAM initial

2021-01-18 Thread Kuo-Hsiang Chou
-Original Message-
From: Thomas Zimmermann [mailto:tzimmerm...@suse.de] 
Sent: Monday, January 18, 2021 5:06 PM
To: Kuo-Hsiang Chou ; 
dri-devel@lists.freedesktop.org; linux-ker...@vger.kernel.org

Subject: Re: [PATCH v2] drm/ast: Disable fast reset after DRAM initial

Hi, Thomas,

Hi

Am 12.01.21 um 08:58 schrieb KuoHsiang Chou:
> [Bug][AST2500]
> 
> V1:
> When AST2500 acts as stand-alone VGA so that DRAM and DVO 
> initialization have to be achieved by VGA driver with P2A (PCI to AHB) 
> enabling.
> However, HW suggests disable Fast reset mode after DRAM initializaton, 
> because fast reset mode is mainly designed for ARM ICE debugger.
> Once Fast reset is checked as enabling, WDT (Watch Dog Timer) should 
> be first enabled to avoid system deadlock before disable fast reset mode.
> 
> V2:
> Use to_pci_dev() to get revision of PCI configuration.
> 
> Signed-off-by: KuoHsiang Chou 
> ---
>   drivers/gpu/drm/ast/ast_drv.h  |  1 +
>   drivers/gpu/drm/ast/ast_main.c |  5 +++
>   drivers/gpu/drm/ast/ast_post.c | 71 +-
>   3 files changed, 51 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_drv.h 
> b/drivers/gpu/drm/ast/ast_drv.h index da6dfb677540..a2cf5fef2399 
> 100644
> --- a/drivers/gpu/drm/ast/ast_drv.h
> +++ b/drivers/gpu/drm/ast/ast_drv.h
> @@ -320,6 +320,7 @@ bool ast_is_vga_enabled(struct drm_device *dev);
>   void ast_post_gpu(struct drm_device *dev);
>   u32 ast_mindwm(struct ast_private *ast, u32 r);
>   void ast_moutdwm(struct ast_private *ast, u32 r, u32 v);
> +void ast_patch_ahb_2500(struct ast_private *ast);
>   /* ast dp501 */
>   void ast_set_dp501_video_output(struct drm_device *dev, u8 mode);
>   bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size); diff 
> --git a/drivers/gpu/drm/ast/ast_main.c 
> b/drivers/gpu/drm/ast/ast_main.c index 3775fe26f792..0e4dfcc25623 
> 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -69,6 +69,7 @@ static void ast_detect_config_mode(struct drm_device *dev, 
> u32 *scu_rev)
>   {
>   struct device_node *np = dev->pdev->dev.of_node;
>   struct ast_private *ast = to_ast_private(dev);
> + struct pci_dev *pdev = to_pci_dev(dev->dev);
>   uint32_t data, jregd0, jregd1;
> 
>   /* Defaults */
> @@ -96,6 +97,10 @@ static void ast_detect_config_mode(struct drm_device *dev, 
> u32 *scu_rev)
>   jregd0 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
>   jregd1 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff);
>   if (!(jregd0 & 0x80) || !(jregd1 & 0x10)) {
> + /* Patch AST2500 */
> + if (((pdev->revision & 0xF0) == 0x40) && ((jregd0 & 0xC0) == 0))
> + ast_patch_ahb_2500(ast);
> +
>   /* Double check it's actually working */
>   data = ast_read32(ast, 0xf004);
>   if (data != 0x) {
> diff --git a/drivers/gpu/drm/ast/ast_post.c 
> b/drivers/gpu/drm/ast/ast_post.c index 8902c2f84bf9..1f0007daa005 
> 100644
> --- a/drivers/gpu/drm/ast/ast_post.c
> +++ b/drivers/gpu/drm/ast/ast_post.c
> @@ -2026,6 +2026,33 @@ static bool ast_dram_init_2500(struct ast_private *ast)
>   return true;
>   }
> 
> +void ast_patch_ahb_2500(struct ast_private *ast) {
> + u32 data;
> +
> +patch_ahb_lock:
> + /* Clear bus lock condition */
> + ast_moutdwm(ast, 0x1e60, 0xAEED1A03);
> + ast_moutdwm(ast, 0x1e600084, 0x0001);
> + ast_moutdwm(ast, 0x1e600088, 0x);
> + ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
> + data = ast_mindwm(ast, 0x1e6e2070);
> + if (data & 0x0800) {/* 
> check fast reset */
> +
> + ast_moutdwm(ast, 0x1E785004, 0x0010);
> + ast_moutdwm(ast, 0x1E785008, 0x4755);
> + ast_moutdwm(ast, 0x1E78500c, 0x0033);
> + udelay(1000);
> + }
> + ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
> + do {
> + data = ast_mindwm(ast, 0x1e6e2000);
> + if (data == 0x)
> + goto patch_ahb_lock;
> + }   while (data != 1);
> + ast_moutdwm(ast, 0x1e6e207c, 0x0800);   /* clear fast reset */
> +}
> +
>   void ast_post_chip_2500(struct drm_device *dev)
>   {
>   struct ast_private *ast = to_ast_private(dev); @@ -2033,39 +2060,31 
> @@ void ast_post_chip_2500(struct drm_device *dev)
>   u8 reg;
> 
>   reg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
> - if ((reg & 0x80) == 0) {/* vga only */
> + if ((reg & 0xC0) == 0) {/* vga only */
>   /* Clear bus lock condition */
> - ast_moutdwm(ast, 0x1e60, 0xAEED1A03);
> - ast_moutdwm(ast, 0x1e600084, 0x0001);
> - ast_moutdwm(ast, 0x1e600088, 0x);
> - ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
> - ast_write32(ast, 0xf004, 0x1e6e);
> - ast_write32(ast, 

[PATCH 3/3] drm/nouveau/kms/nve4-nv138: Fix > 64x64 cursors

2021-01-18 Thread Lyude Paul
While we do handle the additional cursor sizes introduced in NVE4, it looks
like we accidentally broke this when converting over to use Nvidia's
display headers. Since we now use NVVAL in dispnv50/head907d.c in order to
format the value for the cursor layout and NVD9 only had one byte reserved
vs. the 2 bytes reserved in later generations, we end up accidentally
stripping the second bit in the cursor layout format parameter - causing us
to set the wrong cursor size.

This fixes that by adding our own curs_set hook for 917d which uses the
NV917D headers.

Cc: Martin Peres 
Cc: Jeremy Cline 
Cc: Simon Ser 
Cc:  # v5.9+
Signed-off-by: Lyude Paul 
Fixes: ed0b86a90bf9 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core 
head_curs_set()")
---
 drivers/gpu/drm/nouveau/dispnv50/head917d.c   | 28 ++-
 .../drm/nouveau/include/nvhw/class/cl917d.h   |  4 +++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/head917d.c 
b/drivers/gpu/drm/nouveau/dispnv50/head917d.c
index a5d827403660..ea9f8667305e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head917d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head917d.c
@@ -22,6 +22,7 @@
 #include "head.h"
 #include "core.h"
 
+#include "nvif/push.h"
 #include 
 
 #include 
@@ -73,6 +74,31 @@ head917d_base(struct nv50_head *head, struct nv50_head_atom 
*asyh)
return 0;
 }
 
+static int
+head917d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
+{
+   struct nvif_push *push = 
nv50_disp(head->base.base.dev)->core->chan.push;
+   const int i = head->base.index;
+   int ret;
+
+   ret = PUSH_WAIT(push, 5);
+   if (ret)
+   return ret;
+
+   PUSH_MTHD(push, NV917D, HEAD_SET_CONTROL_CURSOR(i),
+ NVDEF(NV917D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) |
+ NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, FORMAT, 
asyh->curs.format) |
+ NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, SIZE, 
asyh->curs.layout) |
+ NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) |
+ NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) |
+ NVDEF(NV917D, HEAD_SET_CONTROL_CURSOR, COMPOSITION, 
ALPHA_BLEND),
+
+   HEAD_SET_OFFSET_CURSOR(i), asyh->curs.offset >> 
8);
+
+   PUSH_MTHD(push, NV917D, HEAD_SET_CONTEXT_DMA_CURSOR(i), 
asyh->curs.handle);
+   return 0;
+}
+
 int
 head917d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw,
 struct nv50_head_atom *asyh)
@@ -101,7 +127,7 @@ head917d = {
.core_clr = head907d_core_clr,
.curs_layout = head917d_curs_layout,
.curs_format = head507d_curs_format,
-   .curs_set = head907d_curs_set,
+   .curs_set = head917d_curs_set,
.curs_clr = head907d_curs_clr,
.base = head917d_base,
.ovly = head907d_ovly,
diff --git a/drivers/gpu/drm/nouveau/include/nvhw/class/cl917d.h 
b/drivers/gpu/drm/nouveau/include/nvhw/class/cl917d.h
index 2a2612d6e1e0..fb223723a38a 100644
--- a/drivers/gpu/drm/nouveau/include/nvhw/class/cl917d.h
+++ b/drivers/gpu/drm/nouveau/include/nvhw/class/cl917d.h
@@ -66,6 +66,10 @@
 #define NV917D_HEAD_SET_CONTROL_CURSOR_COMPOSITION_ALPHA_BLEND 
 (0x)
 #define NV917D_HEAD_SET_CONTROL_CURSOR_COMPOSITION_PREMULT_ALPHA_BLEND 
 (0x0001)
 #define NV917D_HEAD_SET_CONTROL_CURSOR_COMPOSITION_XOR 
 (0x0002)
+#define NV917D_HEAD_SET_OFFSET_CURSOR(a)   
 (0x0484 + (a)*0x0300)
+#define NV917D_HEAD_SET_OFFSET_CURSOR_ORIGIN   
 31:0
+#define NV917D_HEAD_SET_CONTEXT_DMA_CURSOR(a)  
 (0x048C + (a)*0x0300)
+#define NV917D_HEAD_SET_CONTEXT_DMA_CURSOR_HANDLE  
 31:0
 #define NV917D_HEAD_SET_DITHER_CONTROL(a)  
 (0x04A0 + (a)*0x0300)
 #define NV917D_HEAD_SET_DITHER_CONTROL_ENABLE  
 0:0
 #define NV917D_HEAD_SET_DITHER_CONTROL_ENABLE_DISABLE  
 (0x)
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

2021-01-18 Thread Lyude Paul
Cc: Martin Peres 
Cc: Jeremy Cline 
Cc: Simon Ser 
Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index c6367035970e..5f4f09a601d4 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -2663,6 +2663,14 @@ nv50_display_create(struct drm_device *dev)
else
nouveau_display(dev)->format_modifiers = disp50xx_modifiers;
 
+   if (disp->disp->object.oclass >= GK104_DISP) {
+   dev->mode_config.cursor_width = 256;
+   dev->mode_config.cursor_height = 256;
+   } else {
+   dev->mode_config.cursor_width = 64;
+   dev->mode_config.cursor_height = 64;
+   }
+
/* create crtc objects to represent the hw heads */
if (disp->disp->object.oclass >= GV100_DISP)
crtcs = nvif_rd32(>object, 0x610060) & 0xff;
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/3] drivers/nouveau/kms/nv50-: Reject format modifiers for cursor planes

2021-01-18 Thread Lyude Paul
Nvidia hardware doesn't actually support using tiling formats with the
cursor plane, only linear is allowed. In the future, we should write a
testcase for this.

Fixes: c586f30bf74c ("drm/nouveau/kms: Add format mod prop to base/ovly/nvdisp")
Cc: James Jones 
Cc: Martin Peres 
Cc: Jeremy Cline 
Cc: Simon Ser 
Cc:  # v5.8+
Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/nouveau/dispnv50/wndw.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c 
b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index ce451242f79e..271de3a63f21 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -702,6 +702,11 @@ nv50_wndw_init(struct nv50_wndw *wndw)
nvif_notify_get(>notify);
 }
 
+static const u64 nv50_cursor_format_modifiers[] = {
+   DRM_FORMAT_MOD_LINEAR,
+   DRM_FORMAT_MOD_INVALID,
+};
+
 int
 nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
   enum drm_plane_type type, const char *name, int index,
@@ -713,6 +718,7 @@ nv50_wndw_new_(const struct nv50_wndw_func *func, struct 
drm_device *dev,
struct nvif_mmu *mmu = >client.mmu;
struct nv50_disp *disp = nv50_disp(dev);
struct nv50_wndw *wndw;
+   const u64 *format_modifiers;
int nformat;
int ret;
 
@@ -728,10 +734,13 @@ nv50_wndw_new_(const struct nv50_wndw_func *func, struct 
drm_device *dev,
 
for (nformat = 0; format[nformat]; nformat++);
 
-   ret = drm_universal_plane_init(dev, >plane, heads, _wndw,
-  format, nformat,
-  nouveau_display(dev)->format_modifiers,
-  type, "%s-%d", name, index);
+   if (type == DRM_PLANE_TYPE_CURSOR)
+   format_modifiers = nv50_cursor_format_modifiers;
+   else
+   format_modifiers = nouveau_display(dev)->format_modifiers;
+
+   ret = drm_universal_plane_init(dev, >plane, heads, _wndw, 
format, nformat,
+  format_modifiers, type, "%s-%d", name, 
index);
if (ret) {
kfree(*pwndw);
*pwndw = NULL;
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/5] drm/nouveau/kms/nv140-: Add CRC methods to gv100_disp_core_mthd_head

2021-01-18 Thread Lyude Paul
Noticed this while trying to figure out the bit that we need to set in
order to get cursor CRCs to come up correctly on volta+: we never actually
went and added these methods to gv100_disp_core_mthd_head in
drm/nouveau/nvkm/engine/disp/coregv100.c which means we don't trace their
values when disp tracing is enabled in nvkm. So, fix that.

Cc: Martin Peres 
Cc: Jeremy Cline 
Cc: Simon Ser 
Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/coregv100.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/coregv100.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/coregv100.c
index e20a48f201f6..448a515057c7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/coregv100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/coregv100.c
@@ -106,6 +106,8 @@ gv100_disp_core_mthd_head = {
{ 0x20a4, 0x6820a4 },
{ 0x20a8, 0x6820a8 },
{ 0x20ac, 0x6820ac },
+   { 0x2180, 0x682180 },
+   { 0x2184, 0x682184 },
{ 0x218c, 0x68218c },
{ 0x2194, 0x682194 },
{ 0x2198, 0x682198 },
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/5] drm/nouveau/kms/nvd9-nv138: Fix CRC calculation for the cursor channel

2021-01-18 Thread Lyude Paul
While working on igt support for nouveau, I noticed that CRC calculation
appeared to be broken when the cursor channel was being used. For example,
if I had an igt test that would compare a software rendered image of a
completely black fb with a green square in it, and then attempt to
reproduce that image by positioning the cursor channel and setting it to a
green rectangle, the CRCs output by the hardware would differ between the
reference fb's CRC and the output's CRC. This was bizarre particularly
because through use of the Chamelium I have, I was able to confirm that the
image coming out of the display was identical between the reference and
output. As well, the issue wouldn't happen when using the outp CRC sources
that use the SF CRC source (so, DisplayPort) - only sources using the SOR
CRC source (so, everything other then DisplayPort and VGA). It also didn't
happen with the ovly plane, only the cursor plane.

Eventually I noticed 0x0040 being set in the default state cache values
for the CRC methods, which isn't in Nvidia's open-gpu-docs and as such
appears to be inadvertently cleared to 0s when we enable CRCs. After
enabling this again during CRC capture, CRCs appear to be calculated
normally in all circumstances now.

Note that we might need to do this for Volta+ as well, but I'm not
entirely sure yet as there seem to be some bugs with how Volta+ handles
cursors that are currently causing kms_cursor_crc tests to fail.

Cc: Martin Peres 
Cc: Jeremy Cline 
Cc: Simon Ser 
Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/nouveau/dispnv50/crc907d.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc907d.c 
b/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
index 0a89ae9523d4..f9cb484437aa 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc907d.c
@@ -32,7 +32,8 @@ crc907d_set_src(struct nv50_head *head, int or, enum 
nv50_crc_source_type source
   NVDEF(NV907D, HEAD_SET_CRC_CONTROL, 
EXPECT_BUFFER_COLLAPSE, FALSE) |
   NVDEF(NV907D, HEAD_SET_CRC_CONTROL, TIMESTAMP_MODE, 
FALSE) |
   NVDEF(NV907D, HEAD_SET_CRC_CONTROL, SECONDARY_OUTPUT, 
NONE) |
-  NVDEF(NV907D, HEAD_SET_CRC_CONTROL, CRC_DURING_SNOOZE, 
DISABLE);
+  NVDEF(NV907D, HEAD_SET_CRC_CONTROL, CRC_DURING_SNOOZE, 
DISABLE) |
+  0x0040;
int ret;
 
switch (source) {
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/5] drm/nouveau/kms/nv140-: Use hard-coded wndws or core channel for CRC channel

2021-01-18 Thread Lyude Paul
Originally it was assumed based on Nvidia's open-gpu-docs and testing that
NVDisplay required that at least one wndw which belongs to a given head to be
used as the controlling channel
(NVC37D_HEAD_SET_CRC_CONTROL_CONTROLLING_CHANNEL) in order for CRC capture to
function. While this is the case on Volta, Turing actually adds the ability to
instead use the core channel as the controlling channel. For Turing this is
quite useful, as it means that we can always default to the core channel as the
controlling channel and we don't need to be concerned about ensuring we have at
least one wndw channel owned by a head with CRC output enabled. While Volta
lacks this ability, Volta conveniently also lacks flexible wndw mapping -
meaning that we can always rely on each head having four wndw channels mapped to
it regardless of the atomic state.

So, simply use the hard-coded wndw mappings we're guaranteed to have on Volta as
the controlling channel, and use the core channel as the controlling channel for
Turing+. As a result this also renders the plane ownership logic in
nv50_crc_atomic_check() unnessecary, which gives us one less thing to implement
when we get support for flexible wndw mapping. We also can entirely drop the
wndw parameter from our set_src callbacks, and the atomic state.

Cc: Martin Peres 
Cc: Jeremy Cline 
Cc: Simon Ser 
Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/nouveau/dispnv50/Kbuild   |  1 +
 drivers/gpu/drm/nouveau/dispnv50/corec57d.c   |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/crc.c| 34 ++---
 drivers/gpu/drm/nouveau/dispnv50/crc.h|  7 +-
 drivers/gpu/drm/nouveau/dispnv50/crc907d.c|  5 +-
 drivers/gpu/drm/nouveau/dispnv50/crcc37d.c| 45 +++-
 drivers/gpu/drm/nouveau/dispnv50/crcc37d.h| 40 +++
 drivers/gpu/drm/nouveau/dispnv50/crcc57d.c| 58 
 .../drm/nouveau/include/nvhw/class/clc57d.h   | 69 +++
 9 files changed, 187 insertions(+), 74 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/dispnv50/crcc37d.h
 create mode 100644 drivers/gpu/drm/nouveau/dispnv50/crcc57d.c

diff --git a/drivers/gpu/drm/nouveau/dispnv50/Kbuild 
b/drivers/gpu/drm/nouveau/dispnv50/Kbuild
index 4488e1c061b3..28be2912ff74 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/Kbuild
+++ b/drivers/gpu/drm/nouveau/dispnv50/Kbuild
@@ -13,6 +13,7 @@ nouveau-y += dispnv50/corec57d.o
 nouveau-$(CONFIG_DEBUG_FS) += dispnv50/crc.o
 nouveau-$(CONFIG_DEBUG_FS) += dispnv50/crc907d.o
 nouveau-$(CONFIG_DEBUG_FS) += dispnv50/crcc37d.o
+nouveau-$(CONFIG_DEBUG_FS) += dispnv50/crcc57d.o
 
 nouveau-y += dispnv50/dac507d.o
 nouveau-y += dispnv50/dac907d.o
diff --git a/drivers/gpu/drm/nouveau/dispnv50/corec57d.c 
b/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
index 75876546eac1..53b1e2a569c1 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/corec57d.c
@@ -69,7 +69,7 @@ corec57d = {
.head = ,
.sor = ,
 #if IS_ENABLED(CONFIG_DEBUG_FS)
-   .crc = ,
+   .crc = ,
 #endif
 };
 
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c 
b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index ef942248345c..49eb8e9fef22 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -351,8 +351,6 @@ int nv50_crc_atomic_check_head(struct nv50_head *head,
   struct nv50_head_atom *armh)
 {
struct nv50_atom *atom = nv50_atom(asyh->state.state);
-   struct drm_device *dev = head->base.base.dev;
-   struct nv50_disp *disp = nv50_disp(dev);
bool changed = armh->crc.src != asyh->crc.src;
 
if (!armh->crc.src && !asyh->crc.src) {
@@ -361,30 +359,7 @@ int nv50_crc_atomic_check_head(struct nv50_head *head,
return 0;
}
 
-   /* While we don't care about entry tags, Volta+ hw always needs the
-* controlling wndw channel programmed to a wndw that's owned by our
-* head
-*/
-   if (asyh->crc.src && disp->disp->object.oclass >= GV100_DISP &&
-   !(BIT(asyh->crc.wndw) & asyh->wndw.owned)) {
-   if (!asyh->wndw.owned) {
-   /* TODO: once we support flexible channel ownership,
-* we should write some code here to handle attempting
-* to "steal" a plane: e.g. take a plane that is
-* currently not-visible and owned by another head,
-* and reassign it to this head. If we fail to do so,
-* we shuld reject the mode outright as CRC capture
-* then becomes impossible.
-*/
-   NV_ATOMIC(nouveau_drm(dev),
- "No available wndws for CRC readback\n");
-   return -EINVAL;
-   }
-   asyh->crc.wndw = ffs(asyh->wndw.owned) - 1;
-   }
-
-   if (drm_atomic_crtc_needs_modeset(>state) || 

[PATCH 2/5] drm/nouveau/kms/nv50-: Check vbl count after CRC context flip

2021-01-18 Thread Lyude Paul
While I haven't seen us take too long in nv50_crc_ctx_flip_work() outside of
users with kernel logging on a serial port, it probably would be a good idea to
check how long we take just in case we need to go faster in the future.

Cc: Martin Peres 
Cc: Jeremy Cline 
Cc: Simon Ser 
Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/nouveau/dispnv50/crc.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c 
b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 3c50b29a37ff..ef942248345c 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -86,6 +86,8 @@ static void nv50_crc_ctx_flip_work(struct kthread_work *base)
struct drm_crtc *crtc = >base.base;
struct drm_device *dev = crtc->dev;
struct nv50_disp *disp = nv50_disp(dev);
+   const uint64_t start_vbl = drm_crtc_vblank_count(crtc);
+   uint64_t end_vbl;
u8 new_idx = crc->ctx_idx ^ 1;
 
/*
@@ -94,9 +96,7 @@ static void nv50_crc_ctx_flip_work(struct kthread_work *base)
 */
if (!mutex_trylock(>mutex)) {
drm_dbg_kms(dev, "Lock contended, delaying CRC ctx flip for 
%s\n", crtc->name);
-   drm_vblank_work_schedule(work,
-drm_crtc_vblank_count(crtc) + 1,
-true);
+   drm_vblank_work_schedule(work, start_vbl + 1, true);
return;
}
 
@@ -107,6 +107,12 @@ static void nv50_crc_ctx_flip_work(struct kthread_work 
*base)
nv50_crc_program_ctx(head, >ctx[new_idx]);
mutex_unlock(>mutex);
 
+   end_vbl = drm_crtc_vblank_count(crtc);
+   if (unlikely(end_vbl != start_vbl))
+   NV_ERROR(nouveau_drm(dev),
+"Failed to flip CRC context on %s on time (%llu > 
%llu)\n",
+crtc->name, end_vbl, start_vbl);
+
spin_lock_irq(>lock);
crc->ctx_changed = true;
spin_unlock_irq(>lock);
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/5] drm/nouveau/kms/nv50-: Use drm_dbg_kms() in crc.c

2021-01-18 Thread Lyude Paul
Cc: Martin Peres 
Cc: Jeremy Cline 
Cc: Simon Ser 
Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/nouveau/dispnv50/crc.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c 
b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index b8c31b697797..3c50b29a37ff 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -84,7 +84,8 @@ static void nv50_crc_ctx_flip_work(struct kthread_work *base)
struct nv50_crc *crc = container_of(work, struct nv50_crc, flip_work);
struct nv50_head *head = container_of(crc, struct nv50_head, crc);
struct drm_crtc *crtc = >base.base;
-   struct nv50_disp *disp = nv50_disp(crtc->dev);
+   struct drm_device *dev = crtc->dev;
+   struct nv50_disp *disp = nv50_disp(dev);
u8 new_idx = crc->ctx_idx ^ 1;
 
/*
@@ -92,18 +93,15 @@ static void nv50_crc_ctx_flip_work(struct kthread_work 
*base)
 * try again for the next vblank if we don't grab the lock
 */
if (!mutex_trylock(>mutex)) {
-   DRM_DEV_DEBUG_KMS(crtc->dev->dev,
- "Lock contended, delaying CRC ctx flip for 
head-%d\n",
- head->base.index);
+   drm_dbg_kms(dev, "Lock contended, delaying CRC ctx flip for 
%s\n", crtc->name);
drm_vblank_work_schedule(work,
 drm_crtc_vblank_count(crtc) + 1,
 true);
return;
}
 
-   DRM_DEV_DEBUG_KMS(crtc->dev->dev,
- "Flipping notifier ctx for head %d (%d -> %d)\n",
- drm_crtc_index(crtc), crc->ctx_idx, new_idx);
+   drm_dbg_kms(dev, "Flipping notifier ctx for %s (%d -> %d)\n",
+   crtc->name, crc->ctx_idx, new_idx);
 
nv50_crc_program_ctx(head, NULL);
nv50_crc_program_ctx(head, >ctx[new_idx]);
@@ -189,9 +187,9 @@ void nv50_crc_handle_vblank(struct nv50_head *head)
 * updates back-to-back without waiting, we'll just be
 * optimistic and assume we always miss exactly one frame.
 */
-   DRM_DEV_DEBUG_KMS(head->base.base.dev->dev,
- "Notifier ctx flip for head-%d finished, lost 
CRC for frame %llu\n",
- head->base.index, crc->frame);
+   drm_dbg_kms(head->base.base.dev,
+   "Notifier ctx flip for head-%d finished, lost CRC 
for frame %llu\n",
+   head->base.index, crc->frame);
crc->frame++;
 
nv50_crc_reset_ctx(ctx);
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 211263] amdgpu: navi (RX 5500 XT) high power consumption while idling on 75Hz display

2021-01-18 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=211263

Paulo Marcos de Souza Arruda do Nascimento (contato-mygh...@protonmail.com) 
changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |PATCH_ALREADY_AVAILABLE

--- Comment #2 from Paulo Marcos de Souza Arruda do Nascimento 
(contato-mygh...@protonmail.com) ---
Thanks! I'm marking as resolved.

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Reboot crash at msm_atomic_commit_tail

2021-01-18 Thread Fabio Estevam
On Mon, Jan 18, 2021 at 6:44 PM Fabio Estevam  wrote:
>
> Adding some more folks in case anyone has any suggestions to fix this
> reboot hang.

Not sure if this is a valid fix, but the change below makes reboot
works correctly.

kmscube still works.

--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -207,8 +207,12 @@ void msm_atomic_commit_tail(struct drm_atomic_state *state)
struct msm_kms *kms = priv->kms;
struct drm_crtc *async_crtc = NULL;
unsigned crtc_mask = get_crtc_mask(state);
-   bool async = kms->funcs->vsync_time &&
-   can_do_async(state, _crtc);
+   bool async;
+
+   if (!kms)
+   return;
+
+   async = kms->funcs->vsync_time && can_do_async(state, _crtc);

trace_msm_atomic_commit_tail_start(async, crtc_mask);

Any comments?

Thanks
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 07/14] drm/amdgpu: Register IOMMU topology notifier per device.

2021-01-18 Thread Alex Deucher
On Mon, Jan 18, 2021 at 4:02 PM Andrey Grodzovsky
 wrote:
>
> Handle all DMA IOMMU gropup related dependencies before the

gropup -> group

Alex

> group is removed.
>
> Signed-off-by: Andrey Grodzovsky 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h|  5 
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 46 
> ++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c   |  2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h   |  1 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 10 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  2 ++
>  6 files changed, 65 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 478a7d8..2953420 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -51,6 +51,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include 
>  #include 
> @@ -1041,6 +1042,10 @@ struct amdgpu_device {
>
> boolin_pci_err_recovery;
> struct pci_saved_state  *pci_state;
> +
> +   struct notifier_block   nb;
> +   struct blocking_notifier_head   notifier;
> +   struct list_headdevice_bo_list;
>  };
>
>  static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 45e23e3..e99f4f1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -70,6 +70,8 @@
>  #include 
>  #include 
>
> +#include 
> +
>  MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");
>  MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin");
>  MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin");
> @@ -3200,6 +3202,39 @@ static const struct attribute *amdgpu_dev_attributes[] 
> = {
>  };
>
>
> +static int amdgpu_iommu_group_notifier(struct notifier_block *nb,
> +unsigned long action, void *data)
> +{
> +   struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, 
> nb);
> +   struct amdgpu_bo *bo = NULL;
> +
> +   /*
> +* Following is a set of IOMMU group dependencies taken care of before
> +* device's IOMMU group is removed
> +*/
> +   if (action == IOMMU_GROUP_NOTIFY_DEL_DEVICE) {
> +
> +   spin_lock(_bo_glob.lru_lock);
> +   list_for_each_entry(bo, >device_bo_list, bo) {
> +   if (bo->tbo.ttm)
> +   ttm_tt_unpopulate(bo->tbo.bdev, bo->tbo.ttm);
> +   }
> +   spin_unlock(_bo_glob.lru_lock);
> +
> +   if (adev->irq.ih.use_bus_addr)
> +   amdgpu_ih_ring_fini(adev, >irq.ih);
> +   if (adev->irq.ih1.use_bus_addr)
> +   amdgpu_ih_ring_fini(adev, >irq.ih1);
> +   if (adev->irq.ih2.use_bus_addr)
> +   amdgpu_ih_ring_fini(adev, >irq.ih2);
> +
> +   amdgpu_gart_dummy_page_fini(adev);
> +   }
> +
> +   return NOTIFY_OK;
> +}
> +
> +
>  /**
>   * amdgpu_device_init - initialize the driver
>   *
> @@ -3304,6 +3339,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
>
> INIT_WORK(>xgmi_reset_work, amdgpu_device_xgmi_reset_func);
>
> +   INIT_LIST_HEAD(>device_bo_list);
> +
> adev->gfx.gfx_off_req_count = 1;
> adev->pm.ac_power = power_supply_is_system_supplied() > 0;
>
> @@ -3575,6 +3612,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,
> if (amdgpu_device_cache_pci_state(adev->pdev))
> pci_restore_state(pdev);
>
> +   BLOCKING_INIT_NOTIFIER_HEAD(>notifier);
> +   adev->nb.notifier_call = amdgpu_iommu_group_notifier;
> +
> +   if (adev->dev->iommu_group) {
> +   r = iommu_group_register_notifier(adev->dev->iommu_group, 
> >nb);
> +   if (r)
> +   goto failed;
> +   }
> +
> return 0;
>
>  failed:
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> index 0db9330..486ad6d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> @@ -92,7 +92,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device 
> *adev)
>   *
>   * Frees the dummy page used by the driver (all asics).
>   */
> -static void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
> +void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
>  {
> if (!adev->dummy_page_addr)
> return;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
> index afa2e28..5678d9c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
> @@ -61,6 +61,7 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);
>  void 

Re: [PATCH v4 04/14] drm/sched: Cancel and flush all oustatdning jobs before finish.

2021-01-18 Thread Alex Deucher
On Mon, Jan 18, 2021 at 4:02 PM Andrey Grodzovsky
 wrote:
>
> To avoid any possible use after free.
>
> Signed-off-by: Andrey Grodzovsky 
> Reviewed-by: Christian König 

In the subject:
oustatdning -> outstanding

Alex


> ---
>  drivers/gpu/drm/scheduler/sched_main.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
> b/drivers/gpu/drm/scheduler/sched_main.c
> index 997aa15..92637b7 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -899,6 +899,9 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
> if (sched->thread)
> kthread_stop(sched->thread);
>
> +   /* Confirm no work left behind accessing device structures */
> +   cancel_delayed_work_sync(>work_tdr);
> +
> sched->ready = false;
>  }
>  EXPORT_SYMBOL(drm_sched_fini);
> --
> 2.7.4
>
> ___
> amd-gfx mailing list
> amd-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 01/14] drm/ttm: Remap all page faults to per process dummy page.

2021-01-18 Thread Alex Deucher
On Mon, Jan 18, 2021 at 4:02 PM Andrey Grodzovsky
 wrote:
>
> On device removal reroute all CPU mappings to dummy page.
>
> v3:
> Remove loop to find DRM file and instead access it
> by vma->vm_file->private_data. Move dummy page installation
> into a separate function.
>
> v4:
> Map the entire BOs VA space into on demand allocated dummy page
> on the first fault for that BO.
>
> Signed-off-by: Andrey Grodzovsky 
> ---
>  drivers/gpu/drm/ttm/ttm_bo_vm.c | 82 
> -
>  include/drm/ttm/ttm_bo_api.h|  2 +
>  2 files changed, 83 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index 6dc96cf..ed89da3 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -34,6 +34,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -380,25 +382,103 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault 
> *vmf,
>  }
>  EXPORT_SYMBOL(ttm_bo_vm_fault_reserved);
>
> +static void ttm_bo_release_dummy_page(struct drm_device *dev, void *res)
> +{
> +   struct page *dummy_page = (struct page *)res;
> +
> +   __free_page(dummy_page);
> +}
> +
> +vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault *vmf, pgprot_t prot)
> +{
> +   struct vm_area_struct *vma = vmf->vma;
> +   struct ttm_buffer_object *bo = vma->vm_private_data;
> +   struct ttm_bo_device *bdev = bo->bdev;
> +   struct drm_device *ddev = bo->base.dev;
> +   vm_fault_t ret = VM_FAULT_NOPAGE;
> +   unsigned long address = vma->vm_start;
> +   unsigned long num_prefault = (vma->vm_end - vma->vm_start) >> 
> PAGE_SHIFT;
> +   unsigned long pfn;
> +   struct page *page;
> +   int i;
> +
> +   /*
> +* Wait for buffer data in transit, due to a pipelined
> +* move.
> +*/
> +   ret = ttm_bo_vm_fault_idle(bo, vmf);
> +   if (unlikely(ret != 0))
> +   return ret;
> +
> +   /* Allocate new dummy page to map all the VA range in this VMA to it*/
> +   page = alloc_page(GFP_KERNEL | __GFP_ZERO);
> +   if (!page)
> +   return VM_FAULT_OOM;
> +
> +   pfn = page_to_pfn(page);
> +
> +   /*
> +* Prefault the entire VMA range right away to avoid further faults
> +*/
> +   for (i = 0; i < num_prefault; ++i) {
> +
> +   if (unlikely(address >= vma->vm_end))
> +   break;
> +
> +   if (vma->vm_flags & VM_MIXEDMAP)
> +   ret = vmf_insert_mixed_prot(vma, address,
> +   __pfn_to_pfn_t(pfn, 
> PFN_DEV),
> +   prot);
> +   else
> +   ret = vmf_insert_pfn_prot(vma, address, pfn, prot);
> +
> +   /* Never error on prefaulted PTEs */
> +   if (unlikely((ret & VM_FAULT_ERROR))) {
> +   if (i == 0)
> +   return VM_FAULT_NOPAGE;
> +   else
> +   break;
> +   }
> +
> +   address += PAGE_SIZE;
> +   }
> +
> +   /* Set the page to be freed using drmm release action */
> +   if (drmm_add_action_or_reset(ddev, ttm_bo_release_dummy_page, page))
> +   return VM_FAULT_OOM;
> +
> +   return ret;
> +}
> +EXPORT_SYMBOL(ttm_bo_vm_dummy_page);
> +
>  vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
>  {
> struct vm_area_struct *vma = vmf->vma;
> pgprot_t prot;
> struct ttm_buffer_object *bo = vma->vm_private_data;
> +   struct drm_device *ddev = bo->base.dev;
> vm_fault_t ret;
> +   int idx;
>
> ret = ttm_bo_vm_reserve(bo, vmf);
> if (ret)
> return ret;
>
> prot = vma->vm_page_prot;
> -   ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT, 1);
> +   if (drm_dev_enter(ddev, )) {
> +   ret = ttm_bo_vm_fault_reserved(vmf, prot, 
> TTM_BO_VM_NUM_PREFAULT, 1);
> +   drm_dev_exit(idx);
> +   } else {
> +   ret = ttm_bo_vm_dummy_page(vmf, prot);
> +   }
> if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
> return ret;
>
> dma_resv_unlock(bo->base.resv);
>
> return ret;
> +
> +   return ret;

Duplicate return here.

Alex

>  }
>  EXPORT_SYMBOL(ttm_bo_vm_fault);
>
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index e17be32..12fb240 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -643,4 +643,6 @@ void ttm_bo_vm_close(struct vm_area_struct *vma);
>  int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
>  void *buf, int len, int write);
>
> +vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault *vmf, pgprot_t prot);
> +
>  #endif

Re: Reboot crash at msm_atomic_commit_tail

2021-01-18 Thread Fabio Estevam
Adding some more folks in case anyone has any suggestions to fix this
reboot hang.

Thanks

On Tue, Jan 12, 2021 at 5:07 PM Fabio Estevam  wrote:
>
> Hi,
>
> I have noticed that on an imx53-qsb, it is no longer possible to
> reboot the system as it fails like this:
>
> Requesting system reboot
> [   23.819116] cfg80211: failed to load regulatory.db
> [   23.827569] imx-sdma 63fb.sdma: external firmware not found,
> using ROM firmware
> [   23.956838] ci_hdrc ci_hdrc.0: remove, state 1
> [   23.968029] usb usb1: USB disconnect, device number 1
> [   23.976033] usb 1-1: USB disconnect, device number 2
> [   24.234253] ci_hdrc ci_hdrc.0: USB bus 1 deregistered
> [   24.268964] 8<--- cut here ---
> [   24.274602] Unable to handle kernel NULL pointer dereference at
> virtual address 
> [   24.283434] pgd = (ptrval)
> [   24.286387] [] *pgd=ca212831
> [   24.290788] Internal error: Oops: 17 [#1] SMP ARM
> [   24.295609] Modules linked in:
> [   24.298777] CPU: 0 PID: 197 Comm: init Not tainted
> 5.11.0-rc2-next-20210111 #333
> [   24.306276] Hardware name: Freescale i.MX53 (Device Tree Support)
> [   24.312442] PC is at msm_atomic_commit_tail+0x54/0xb9c
> [   24.317743] LR is at commit_tail+0xa4/0x1b0
> [   24.322032] pc : []lr : []psr: 6013
> [   24.328374] sp : c28d1d50  ip : c23a3000  fp : 
> [   24.333670] r10: c2816780  r9 : c12d71c0  r8 : c17fb018
> [   24.338967] r7 : c23a3000  r6 : c2816780  r5 :   r4 : 
> [   24.345572] r3 : c24c2c00  r2 : c23a3000  r1 : c0769b24  r0 : 
> [   24.352177] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
> none
> [   24.359407] Control: 10c5387d  Table: 72858019  DAC: 0051
> [   24.365220] Process init (pid: 197, stack limit = 0x(ptrval))
> [   24.371052] Stack: (0xc28d1d50 to 0xc28d2000)
> [   24.375508] 1d40: 
>  9682f000 0005
> [   24.383794] 1d60: 3031e53d  0dc0 c0f816d8 c23a3000
> c23a3000  c17fb018
> [   24.392079] 1d80: c12d71c0 c2816780  c06db0b4 a5f7faba
> 0005  c2816780
> [   24.400363] 1da0:  c23a3000  c17fb018 c12d71c0
> c24c20a0  c06dbed0
> [   24.408647] 1dc0:   c2816780 c23a349c c2816780
> c28d1dfc c23a34a4 c06db604
> [   24.416932] 1de0: c23a3000  c1609388 c12ba9dc c17fb018
> c06db704 c2965e80 c2965e80
> [   24.425214] 1e00: 0008 0001   c175f454
>  c175f458 c1c669cc
> [   24.433498] 1e20:  c12bebb8  0001 0008
>  c23a32ec c23a32ec
> [   24.441783] 1e40:  433f193b c24c2014 c24c2014 c24c2010
> c17674c8 c1e68bec c07c76e8
> [   24.450067] 1e60:  c16158d8 c1609388 fee1dead 
> c28d 0058 c0153730
> [   24.458350] 1e80: 01234567 c01539d4 fffe  
>   
> [   24.466633] 1ea0:     
>   c1609388
> [   24.474917] 1ec0: c29663c8   c0e17954 e000
>  0001 
> [   24.483200] 1ee0: c1609388 c1609388 c16093d4 433f193b 
> c1581584 e000 1ea51000
> [   24.491485] 1f00: 0001 0080 c1609388 c1609794 c29663c8
>   c0e17954
> [   24.499769] 1f20:    c1609388 c1609388
> c16093d4  c1609388
> [   24.508054] 1f40: c29663c8 c0183f24 c2965e80 c1609388 0001
> c1609794 c2995090 c018ce7c
> [   24.516337] 1f60: 0001 c2995080 c0136e80 c010012c 
> 0001 c158b21c c0e22334
> [   24.524622] 1f80: c158b21c c010019c c1609794 433f193b 
> beefefd4 0001 0058
> [   24.532907] 1fa0: c0100264 c0100080  beefefd4 fee1dead
> 28121969 01234567 
> [   24.541191] 1fc0:  beefefd4 0001 0058 
>  b6f1ef74 
> [   24.549476] 1fe0: 000d7298 beefed40 00091a48 b6e8894c 6010
> fee1dead  
> [   24.557742] [] (msm_atomic_commit_tail) from []
> (commit_tail+0xa4/0x1b0)
> [   24.566349] [] (commit_tail) from []
> (drm_atomic_helper_commit+0x154/0x188)
> [   24.575193] [] (drm_atomic_helper_commit) from
> [] (drm_atomic_helper_disable_all+0x154/0x1c0)
> [   24.585599] [] (drm_atomic_helper_disable_all) from
> [] (drm_atomic_helper_shutdown+0x94/0x12c)
> [   24.596094] [] (drm_atomic_helper_shutdown) from
> [] (device_shutdown+0x118/0x250)
> [   24.605475] [] (device_shutdown) from []
> (kernel_restart+0xc/0x68)
> [   24.613574] [] (kernel_restart) from []
> (__do_sys_reboot+0x144/0x200)
> [   24.621915] [] (__do_sys_reboot) from []
> (ret_fast_syscall+0x0/0x2c)
> [   24.630160] Exception stack(0xc28d1fa8 to 0xc28d1ff0)
> [   24.635315] 1fa0:    beefefd4 fee1dead
> 28121969 01234567 
> [   24.643600] 1fc0:  beefefd4 0001 0058 
>  b6f1ef74 
> [   24.651867] 1fe0: 000d7298 beefed40 00091a48 b6e8894c
> [   24.657025] Code: 1592208c 

Re: [PATCH v2 5/7] drm/msm: Add dependency on io-pgtable-arm format module

2021-01-18 Thread Will Deacon
On Mon, Jan 18, 2021 at 01:16:03PM -0800, Rob Clark wrote:
> On Mon, Dec 21, 2020 at 4:44 PM Isaac J. Manjarres
>  wrote:
> >
> > The MSM DRM driver depends on the availability of the ARM LPAE io-pgtable
> > format code to work properly. In preparation for having the io-pgtable
> > formats as modules, add a "pre" dependency with MODULE_SOFTDEP() to
> > ensure that the io-pgtable-arm format module is loaded before loading
> > the MSM DRM driver module.
> >
> > Signed-off-by: Isaac J. Manjarres 
> 
> Thanks, I've queued this up locally

I don't plan to make the io-pgtable code modular, so please drop this patch.

https://lore.kernel.org/r/20210106123428.GA1798@willie-the-truck

Will
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 5/7] drm/msm: Add dependency on io-pgtable-arm format module

2021-01-18 Thread Rob Clark
On Mon, Dec 21, 2020 at 4:44 PM Isaac J. Manjarres
 wrote:
>
> The MSM DRM driver depends on the availability of the ARM LPAE io-pgtable
> format code to work properly. In preparation for having the io-pgtable
> formats as modules, add a "pre" dependency with MODULE_SOFTDEP() to
> ensure that the io-pgtable-arm format module is loaded before loading
> the MSM DRM driver module.
>
> Signed-off-by: Isaac J. Manjarres 

Thanks, I've queued this up locally

BR,
-R

> ---
>  drivers/gpu/drm/msm/msm_drv.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 535a026..8be3506 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -1369,3 +1369,4 @@ module_exit(msm_drm_unregister);
>  MODULE_AUTHOR("Rob Clark   MODULE_DESCRIPTION("MSM DRM Driver");
>  MODULE_LICENSE("GPL");
> +MODULE_SOFTDEP("pre: io-pgtable-arm");
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>
> ___
> iommu mailing list
> io...@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-18 Thread Andrey Grodzovsky
This should prevent writing to memory or IO ranges possibly
already allocated for other uses after our device is removed.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 57 
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c|  9 
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c| 53 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h|  3 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c   | 70 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   | 49 ++---
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 16 ++-
 drivers/gpu/drm/amd/amdgpu/psp_v12_0.c |  8 +---
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c  |  8 +---
 9 files changed, 184 insertions(+), 89 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e99f4f1..0a9d73c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -72,6 +72,8 @@
 
 #include 
 
+#include 
+
 MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin");
@@ -404,13 +406,21 @@ uint8_t amdgpu_mm_rreg8(struct amdgpu_device *adev, 
uint32_t offset)
  */
 void amdgpu_mm_wreg8(struct amdgpu_device *adev, uint32_t offset, uint8_t 
value)
 {
+   int idx;
+
if (adev->in_pci_err_recovery)
return;
 
+
+   if (!drm_dev_enter(>ddev, ))
+   return;
+
if (offset < adev->rmmio_size)
writeb(value, adev->rmmio + offset);
else
BUG();
+
+   drm_dev_exit(idx);
 }
 
 /**
@@ -427,9 +437,14 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,
uint32_t reg, uint32_t v,
uint32_t acc_flags)
 {
+   int idx;
+
if (adev->in_pci_err_recovery)
return;
 
+   if (!drm_dev_enter(>ddev, ))
+   return;
+
if ((reg * 4) < adev->rmmio_size) {
if (!(acc_flags & AMDGPU_REGS_NO_KIQ) &&
amdgpu_sriov_runtime(adev) &&
@@ -444,6 +459,8 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,
}
 
trace_amdgpu_device_wreg(adev->pdev->device, reg, v);
+
+   drm_dev_exit(idx);
 }
 
 /*
@@ -454,9 +471,14 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,
 void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
 uint32_t reg, uint32_t v)
 {
+   int idx;
+
if (adev->in_pci_err_recovery)
return;
 
+   if (!drm_dev_enter(>ddev, ))
+   return;
+
if (amdgpu_sriov_fullaccess(adev) &&
adev->gfx.rlc.funcs &&
adev->gfx.rlc.funcs->is_rlcg_access_range) {
@@ -465,6 +487,8 @@ void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
} else {
writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
}
+
+   drm_dev_exit(idx);
 }
 
 /**
@@ -499,15 +523,22 @@ u32 amdgpu_io_rreg(struct amdgpu_device *adev, u32 reg)
  */
 void amdgpu_io_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
 {
+   int idx;
+
if (adev->in_pci_err_recovery)
return;
 
+   if (!drm_dev_enter(>ddev, ))
+   return;
+
if ((reg * 4) < adev->rio_mem_size)
iowrite32(v, adev->rio_mem + (reg * 4));
else {
iowrite32((reg * 4), adev->rio_mem + (mmMM_INDEX * 4));
iowrite32(v, adev->rio_mem + (mmMM_DATA * 4));
}
+
+   drm_dev_exit(idx);
 }
 
 /**
@@ -544,14 +575,21 @@ u32 amdgpu_mm_rdoorbell(struct amdgpu_device *adev, u32 
index)
  */
 void amdgpu_mm_wdoorbell(struct amdgpu_device *adev, u32 index, u32 v)
 {
+   int idx;
+
if (adev->in_pci_err_recovery)
return;
 
+   if (!drm_dev_enter(>ddev, ))
+   return;
+
if (index < adev->doorbell.num_doorbells) {
writel(v, adev->doorbell.ptr + index);
} else {
DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index);
}
+
+   drm_dev_exit(idx);
 }
 
 /**
@@ -588,14 +626,21 @@ u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 
index)
  */
 void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v)
 {
+   int idx;
+
if (adev->in_pci_err_recovery)
return;
 
+   if (!drm_dev_enter(>ddev, ))
+   return;
+
if (index < adev->doorbell.num_doorbells) {
atomic64_set((atomic64_t *)(adev->doorbell.ptr + index), v);
} else {
DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index);
}
+
+   drm_dev_exit(idx);
 }
 
 /**
@@ -682,6 +727,10 @@ void amdgpu_device_indirect_wreg(struct amdgpu_device 
*adev,
unsigned long flags;
void __iomem *pcie_index_offset;
void __iomem *pcie_data_offset;
+   

[PATCH v4 14/14] drm/amdgpu: Prevent any job recoveries after device is unplugged.

2021-01-18 Thread Andrey Grodzovsky
Return DRM_TASK_STATUS_ENODEV back to the scheduler when device
is not present so they timeout timer will not be rearmed.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index a111326..e4aa5fe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -25,6 +25,8 @@
 #include 
 #include 
 
+#include 
+
 #include "amdgpu.h"
 #include "amdgpu_trace.h"
 
@@ -34,6 +36,15 @@ static enum drm_task_status amdgpu_job_timedout(struct 
drm_sched_job *s_job)
struct amdgpu_job *job = to_amdgpu_job(s_job);
struct amdgpu_task_info ti;
struct amdgpu_device *adev = ring->adev;
+   int idx;
+
+   if (!drm_dev_enter(>ddev, )) {
+   DRM_INFO("%s - device unplugged skipping recovery on 
scheduler:%s",
+__func__, s_job->sched->name);
+
+   /* Effectively the job is aborted as the device is gone */
+   return DRM_TASK_STATUS_ENODEV;
+   }
 
memset(, 0, sizeof(struct amdgpu_task_info));
 
@@ -41,7 +52,7 @@ static enum drm_task_status amdgpu_job_timedout(struct 
drm_sched_job *s_job)
amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) 
{
DRM_ERROR("ring %s timeout, but soft recovered\n",
  s_job->sched->name);
-   return DRM_TASK_STATUS_ALIVE;
+   goto exit;
}
 
amdgpu_vm_get_task_info(ring->adev, job->pasid, );
@@ -53,13 +64,15 @@ static enum drm_task_status amdgpu_job_timedout(struct 
drm_sched_job *s_job)
 
if (amdgpu_device_should_recover_gpu(ring->adev)) {
amdgpu_device_gpu_recover(ring->adev, job);
-   return DRM_TASK_STATUS_ALIVE;
} else {
drm_sched_suspend_timeout(>sched);
if (amdgpu_sriov_vf(adev))
adev->virt.tdr_debug = true;
-   return DRM_TASK_STATUS_ALIVE;
}
+
+exit:
+   drm_dev_exit(idx);
+   return DRM_TASK_STATUS_ALIVE;
 }
 
 int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 13/14] drm/sched: Make timeout timer rearm conditional.

2021-01-18 Thread Andrey Grodzovsky
We don't want to rearm the timer if driver hook reports
that the device is gone.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/scheduler/sched_main.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c
index 73fccc5..9552334 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -314,6 +314,7 @@ static void drm_sched_job_timedout(struct work_struct *work)
 {
struct drm_gpu_scheduler *sched;
struct drm_sched_job *job;
+   enum drm_task_status status = DRM_TASK_STATUS_ALIVE;
 
sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
 
@@ -331,7 +332,7 @@ static void drm_sched_job_timedout(struct work_struct *work)
list_del_init(>list);
spin_unlock(>job_list_lock);
 
-   job->sched->ops->timedout_job(job);
+   status = job->sched->ops->timedout_job(job);
 
/*
 * Guilty job did complete and hence needs to be manually 
removed
@@ -345,9 +346,11 @@ static void drm_sched_job_timedout(struct work_struct 
*work)
spin_unlock(>job_list_lock);
}
 
-   spin_lock(>job_list_lock);
-   drm_sched_start_timeout(sched);
-   spin_unlock(>job_list_lock);
+   if (status != DRM_TASK_STATUS_ENODEV) {
+   spin_lock(>job_list_lock);
+   drm_sched_start_timeout(sched);
+   spin_unlock(>job_list_lock);
+   }
 }
 
  /**
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 12/14] drm/scheduler: Job timeout handler returns status

2021-01-18 Thread Andrey Grodzovsky
From: Luben Tuikov 

This patch does not change current behaviour.

The driver's job timeout handler now returns
status indicating back to the DRM layer whether
the task (job) was successfully aborted or whether
more time should be given to the task to complete.

Default behaviour as of this patch, is preserved,
except in obvious-by-comment case in the Panfrost
driver, as documented below.

All drivers which make use of the
drm_sched_backend_ops' .timedout_job() callback
have been accordingly renamed and return the
would've-been default value of
DRM_TASK_STATUS_ALIVE to restart the task's
timeout timer--this is the old behaviour, and
is preserved by this patch.

In the case of the Panfrost driver, its timedout
callback correctly first checks if the job had
completed in due time and if so, it now returns
DRM_TASK_STATUS_COMPLETE to notify the DRM layer
that the task can be moved to the done list, to be
freed later. In the other two subsequent checks,
the value of DRM_TASK_STATUS_ALIVE is returned, as
per the default behaviour.

A more involved driver's solutions can be had
in subequent patches.

v2: Use enum as the status of a driver's job
timeout callback method.

v4: (By Andrey Grodzovsky)
Replace DRM_TASK_STATUS_COMPLETE with DRM_TASK_STATUS_ENODEV
to enable a hint to the schduler for when NOT to rearm the
timeout timer.

Cc: Alexander Deucher 
Cc: Andrey Grodzovsky 
Cc: Christian König 
Cc: Daniel Vetter 
Cc: Lucas Stach 
Cc: Russell King 
Cc: Christian Gmeiner 
Cc: Qiang Yu 
Cc: Rob Herring 
Cc: Tomeu Vizoso 
Cc: Steven Price 
Cc: Alyssa Rosenzweig 
Cc: Eric Anholt 
Reported-by: kernel test robot 
Signed-off-by: Luben Tuikov 
Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c |  6 --
 drivers/gpu/drm/etnaviv/etnaviv_sched.c | 10 +-
 drivers/gpu/drm/lima/lima_sched.c   |  4 +++-
 drivers/gpu/drm/panfrost/panfrost_job.c |  9 ++---
 drivers/gpu/drm/scheduler/sched_main.c  |  4 +---
 drivers/gpu/drm/v3d/v3d_sched.c | 32 +---
 include/drm/gpu_scheduler.h | 17 ++---
 7 files changed, 54 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index ff48101..a111326 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -28,7 +28,7 @@
 #include "amdgpu.h"
 #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static enum drm_task_status amdgpu_job_timedout(struct drm_sched_job *s_job)
 {
struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
struct amdgpu_job *job = to_amdgpu_job(s_job);
@@ -41,7 +41,7 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) 
{
DRM_ERROR("ring %s timeout, but soft recovered\n",
  s_job->sched->name);
-   return;
+   return DRM_TASK_STATUS_ALIVE;
}
 
amdgpu_vm_get_task_info(ring->adev, job->pasid, );
@@ -53,10 +53,12 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
 
if (amdgpu_device_should_recover_gpu(ring->adev)) {
amdgpu_device_gpu_recover(ring->adev, job);
+   return DRM_TASK_STATUS_ALIVE;
} else {
drm_sched_suspend_timeout(>sched);
if (amdgpu_sriov_vf(adev))
adev->virt.tdr_debug = true;
+   return DRM_TASK_STATUS_ALIVE;
}
 }
 
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c 
b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
index cd46c88..c495169 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
@@ -82,7 +82,8 @@ static struct dma_fence *etnaviv_sched_run_job(struct 
drm_sched_job *sched_job)
return fence;
 }
 
-static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job)
+static enum drm_task_status etnaviv_sched_timedout_job(struct drm_sched_job
+  *sched_job)
 {
struct etnaviv_gem_submit *submit = to_etnaviv_submit(sched_job);
struct etnaviv_gpu *gpu = submit->gpu;
@@ -120,9 +121,16 @@ static void etnaviv_sched_timedout_job(struct 
drm_sched_job *sched_job)
 
drm_sched_resubmit_jobs(>sched);
 
+   /* Tell the DRM scheduler that this task needs
+* more time.
+*/
+   drm_sched_start(>sched, true);
+   return DRM_TASK_STATUS_ALIVE;
+
 out_no_timeout:
/* restart scheduler after GPU is usable again */
drm_sched_start(>sched, true);
+   return DRM_TASK_STATUS_ALIVE;
 }
 
 static void etnaviv_sched_free_job(struct drm_sched_job *sched_job)
diff --git a/drivers/gpu/drm/lima/lima_sched.c 
b/drivers/gpu/drm/lima/lima_sched.c
index 63b4c56..66d9236 100644
--- a/drivers/gpu/drm/lima/lima_sched.c
+++ 

[PATCH v4 09/14] drm/amdgpu: Remap all page faults to per process dummy page.

2021-01-18 Thread Andrey Grodzovsky
On device removal reroute all CPU mappings to dummy page
per drm_file instance or imported GEM object.

v4:
Update for modified ttm_bo_vm_dummy_page

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 9fd2157..550dc5e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -49,6 +49,7 @@
 
 #include 
 #include 
+#include 
 
 #include "amdgpu.h"
 #include "amdgpu_object.h"
@@ -1982,18 +1983,28 @@ void amdgpu_ttm_set_buffer_funcs_status(struct 
amdgpu_device *adev, bool enable)
 static vm_fault_t amdgpu_ttm_fault(struct vm_fault *vmf)
 {
struct ttm_buffer_object *bo = vmf->vma->vm_private_data;
+   struct drm_device *ddev = bo->base.dev;
vm_fault_t ret;
+   int idx;
 
ret = ttm_bo_vm_reserve(bo, vmf);
if (ret)
return ret;
 
-   ret = amdgpu_bo_fault_reserve_notify(bo);
-   if (ret)
-   goto unlock;
+   if (drm_dev_enter(ddev, )) {
+   ret = amdgpu_bo_fault_reserve_notify(bo);
+   if (ret) {
+   drm_dev_exit(idx);
+   goto unlock;
+   }
 
-   ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot,
-  TTM_BO_VM_NUM_PREFAULT, 1);
+ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot,
+   TTM_BO_VM_NUM_PREFAULT, 1);
+
+drm_dev_exit(idx);
+   } else {
+   ret = ttm_bo_vm_dummy_page(vmf, vmf->vma->vm_page_prot);
+   }
if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
return ret;
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 10/14] dmr/amdgpu: Move some sysfs attrs creation to default_attr

2021-01-18 Thread Andrey Grodzovsky
This allows to remove explicit creation and destruction
of those attrs and by this avoids warnings on device
finilizing post physical device extraction.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 17 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  | 13 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c  | 25 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 14 +-
 4 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 86add0f..0346e12 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -1953,6 +1953,15 @@ static ssize_t amdgpu_atombios_get_vbios_version(struct 
device *dev,
 static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
   NULL);
 
+static struct attribute *amdgpu_vbios_version_attrs[] = {
+   _attr_vbios_version.attr,
+   NULL
+};
+
+const struct attribute_group amdgpu_vbios_version_attr_group = {
+   .attrs = amdgpu_vbios_version_attrs
+};
+
 /**
  * amdgpu_atombios_fini - free the driver info and callbacks for atombios
  *
@@ -1972,7 +1981,6 @@ void amdgpu_atombios_fini(struct amdgpu_device *adev)
adev->mode_info.atom_context = NULL;
kfree(adev->mode_info.atom_card_info);
adev->mode_info.atom_card_info = NULL;
-   device_remove_file(adev->dev, _attr_vbios_version);
 }
 
 /**
@@ -1989,7 +1997,6 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)
 {
struct card_info *atom_card_info =
kzalloc(sizeof(struct card_info), GFP_KERNEL);
-   int ret;
 
if (!atom_card_info)
return -ENOMEM;
@@ -2027,12 +2034,6 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)
amdgpu_atombios_allocate_fb_scratch(adev);
}
 
-   ret = device_create_file(adev->dev, _attr_vbios_version);
-   if (ret) {
-   DRM_ERROR("Failed to create device file for VBIOS version\n");
-   return ret;
-   }
-
return 0;
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 9c0cd00..8fddd74 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1587,6 +1587,18 @@ static struct pci_error_handlers amdgpu_pci_err_handler 
= {
.resume = amdgpu_pci_resume,
 };
 
+extern const struct attribute_group amdgpu_vram_mgr_attr_group;
+extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
+extern const struct attribute_group amdgpu_vbios_version_attr_group;
+
+static const struct attribute_group *amdgpu_sysfs_groups[] = {
+   _vram_mgr_attr_group,
+   _gtt_mgr_attr_group,
+   _vbios_version_attr_group,
+   NULL,
+};
+
+
 static struct pci_driver amdgpu_kms_pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
@@ -1595,6 +1607,7 @@ static struct pci_driver amdgpu_kms_pci_driver = {
.shutdown = amdgpu_pci_shutdown,
.driver.pm = _pm_ops,
.err_handler = _pci_err_handler,
+   .driver.dev_groups = amdgpu_sysfs_groups,
 };
 
 static int __init amdgpu_init(void)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 8980329..3b7150e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -77,6 +77,16 @@ static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
 static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,
   amdgpu_mem_info_gtt_used_show, NULL);
 
+static struct attribute *amdgpu_gtt_mgr_attributes[] = {
+   _attr_mem_info_gtt_total.attr,
+   _attr_mem_info_gtt_used.attr,
+   NULL
+};
+
+const struct attribute_group amdgpu_gtt_mgr_attr_group = {
+   .attrs = amdgpu_gtt_mgr_attributes
+};
+
 static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func;
 /**
  * amdgpu_gtt_mgr_init - init GTT manager and DRM MM
@@ -91,7 +101,6 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t 
gtt_size)
struct amdgpu_gtt_mgr *mgr = >mman.gtt_mgr;
struct ttm_resource_manager *man = >manager;
uint64_t start, size;
-   int ret;
 
man->use_tt = true;
man->func = _gtt_mgr_func;
@@ -104,17 +113,6 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, 
uint64_t gtt_size)
spin_lock_init(>lock);
atomic64_set(>available, gtt_size >> PAGE_SHIFT);
 
-   ret = device_create_file(adev->dev, _attr_mem_info_gtt_total);
-   if (ret) {
-   DRM_ERROR("Failed to create device file mem_info_gtt_total\n");
-   return ret;
-   }
-   ret = device_create_file(adev->dev, _attr_mem_info_gtt_used);
-   if (ret) {
-   DRM_ERROR("Failed to create device file mem_info_gtt_used\n");
-   

[PATCH v4 08/14] drm/amdgpu: Fix a bunch of sdma code crash post device unplug

2021-01-18 Thread Andrey Grodzovsky
We can't allocate and submit IBs post device unplug.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index ad91c0c..5096351 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -31,6 +31,7 @@
 #include 
 
 #include 
+#include 
 #include "amdgpu.h"
 #include "amdgpu_trace.h"
 #include "amdgpu_amdkfd.h"
@@ -1604,7 +1605,10 @@ static int amdgpu_vm_bo_update_mapping(struct 
amdgpu_device *adev,
struct amdgpu_vm_update_params params;
enum amdgpu_sync_mode sync_mode;
uint64_t pfn;
-   int r;
+   int r, idx;
+
+   if (!drm_dev_enter(>ddev, ))
+   return -ENOENT;
 
memset(, 0, sizeof(params));
params.adev = adev;
@@ -1647,6 +1651,8 @@ static int amdgpu_vm_bo_update_mapping(struct 
amdgpu_device *adev,
if (r)
goto error_unlock;
 
+
+   drm_dev_exit(idx);
do {
uint64_t tmp, num_entries, addr;
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 07/14] drm/amdgpu: Register IOMMU topology notifier per device.

2021-01-18 Thread Andrey Grodzovsky
Handle all DMA IOMMU gropup related dependencies before the
group is removed.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  5 
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 46 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 10 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  2 ++
 6 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 478a7d8..2953420 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1041,6 +1042,10 @@ struct amdgpu_device {
 
boolin_pci_err_recovery;
struct pci_saved_state  *pci_state;
+
+   struct notifier_block   nb;
+   struct blocking_notifier_head   notifier;
+   struct list_headdevice_bo_list;
 };
 
 static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 45e23e3..e99f4f1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -70,6 +70,8 @@
 #include 
 #include 
 
+#include 
+
 MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin");
@@ -3200,6 +3202,39 @@ static const struct attribute *amdgpu_dev_attributes[] = 
{
 };
 
 
+static int amdgpu_iommu_group_notifier(struct notifier_block *nb,
+unsigned long action, void *data)
+{
+   struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, nb);
+   struct amdgpu_bo *bo = NULL;
+
+   /*
+* Following is a set of IOMMU group dependencies taken care of before
+* device's IOMMU group is removed
+*/
+   if (action == IOMMU_GROUP_NOTIFY_DEL_DEVICE) {
+
+   spin_lock(_bo_glob.lru_lock);
+   list_for_each_entry(bo, >device_bo_list, bo) {
+   if (bo->tbo.ttm)
+   ttm_tt_unpopulate(bo->tbo.bdev, bo->tbo.ttm);
+   }
+   spin_unlock(_bo_glob.lru_lock);
+
+   if (adev->irq.ih.use_bus_addr)
+   amdgpu_ih_ring_fini(adev, >irq.ih);
+   if (adev->irq.ih1.use_bus_addr)
+   amdgpu_ih_ring_fini(adev, >irq.ih1);
+   if (adev->irq.ih2.use_bus_addr)
+   amdgpu_ih_ring_fini(adev, >irq.ih2);
+
+   amdgpu_gart_dummy_page_fini(adev);
+   }
+
+   return NOTIFY_OK;
+}
+
+
 /**
  * amdgpu_device_init - initialize the driver
  *
@@ -3304,6 +3339,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
INIT_WORK(>xgmi_reset_work, amdgpu_device_xgmi_reset_func);
 
+   INIT_LIST_HEAD(>device_bo_list);
+
adev->gfx.gfx_off_req_count = 1;
adev->pm.ac_power = power_supply_is_system_supplied() > 0;
 
@@ -3575,6 +3612,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,
if (amdgpu_device_cache_pci_state(adev->pdev))
pci_restore_state(pdev);
 
+   BLOCKING_INIT_NOTIFIER_HEAD(>notifier);
+   adev->nb.notifier_call = amdgpu_iommu_group_notifier;
+
+   if (adev->dev->iommu_group) {
+   r = iommu_group_register_notifier(adev->dev->iommu_group, 
>nb);
+   if (r)
+   goto failed;
+   }
+
return 0;
 
 failed:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index 0db9330..486ad6d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -92,7 +92,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device 
*adev)
  *
  * Frees the dummy page used by the driver (all asics).
  */
-static void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
+void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
 {
if (!adev->dummy_page_addr)
return;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
index afa2e28..5678d9c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
@@ -61,6 +61,7 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);
 void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);
 int amdgpu_gart_init(struct amdgpu_device *adev);
 void amdgpu_gart_fini(struct amdgpu_device *adev);
+void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev);
 int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
   int pages);
 int amdgpu_gart_map(struct amdgpu_device 

[PATCH v4 05/14] drm/amdgpu: Split amdgpu_device_fini into early and late

2021-01-18 Thread Andrey Grodzovsky
Some of the stuff in amdgpu_device_fini such as HW interrupts
disable and pending fences finilization must be done right away on
pci_remove while most of the stuff which relates to finilizing and
releasing driver data structures can be kept until
drm_driver.release hook is called, i.e. when the last device
reference is dropped.

v4: Change functions prefix early->hw and late->sw

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  6 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 26 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c|  7 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c  | 15 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c| 26 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h|  3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c| 12 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c|  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |  3 ++-
 drivers/gpu/drm/amd/amdgpu/cik_ih.c|  2 +-
 drivers/gpu/drm/amd/amdgpu/cz_ih.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/iceland_ih.c|  2 +-
 drivers/gpu/drm/amd/amdgpu/navi10_ih.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/si_ih.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/tonga_ih.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/vega10_ih.c |  2 +-
 16 files changed, 78 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index f77443c..478a7d8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1060,7 +1060,9 @@ static inline struct amdgpu_device 
*amdgpu_ttm_adev(struct ttm_bo_device *bdev)
 
 int amdgpu_device_init(struct amdgpu_device *adev,
   uint32_t flags);
-void amdgpu_device_fini(struct amdgpu_device *adev);
+void amdgpu_device_fini_hw(struct amdgpu_device *adev);
+void amdgpu_device_fini_sw(struct amdgpu_device *adev);
+
 int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev);
 
 void amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos,
@@ -1273,6 +1275,8 @@ void amdgpu_driver_lastclose_kms(struct drm_device *dev);
 int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);
 void amdgpu_driver_postclose_kms(struct drm_device *dev,
 struct drm_file *file_priv);
+void amdgpu_driver_release_kms(struct drm_device *dev);
+
 int amdgpu_device_ip_suspend(struct amdgpu_device *adev);
 int amdgpu_device_suspend(struct drm_device *dev, bool fbcon);
 int amdgpu_device_resume(struct drm_device *dev, bool fbcon);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 348ac67..90c8353 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3579,14 +3579,12 @@ int amdgpu_device_init(struct amdgpu_device *adev,
  * Tear down the driver info (all asics).
  * Called at driver shutdown.
  */
-void amdgpu_device_fini(struct amdgpu_device *adev)
+void amdgpu_device_fini_hw(struct amdgpu_device *adev)
 {
dev_info(adev->dev, "amdgpu: finishing device.\n");
flush_delayed_work(>delayed_init_work);
adev->shutdown = true;
 
-   kfree(adev->pci_state);
-
/* make sure IB test finished before entering exclusive mode
 * to avoid preemption on IB test
 * */
@@ -3603,11 +3601,24 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
else
drm_atomic_helper_shutdown(adev_to_drm(adev));
}
-   amdgpu_fence_driver_fini(adev);
+   amdgpu_fence_driver_fini_hw(adev);
+
if (adev->pm_sysfs_en)
amdgpu_pm_sysfs_fini(adev);
+   if (adev->ucode_sysfs_en)
+   amdgpu_ucode_sysfs_fini(adev);
+   sysfs_remove_files(>dev->kobj, amdgpu_dev_attributes);
+
+
amdgpu_fbdev_fini(adev);
+
+   amdgpu_irq_fini_hw(adev);
+}
+
+void amdgpu_device_fini_sw(struct amdgpu_device *adev)
+{
amdgpu_device_ip_fini(adev);
+   amdgpu_fence_driver_fini_sw(adev);
release_firmware(adev->firmware.gpu_info_fw);
adev->firmware.gpu_info_fw = NULL;
adev->accel_working = false;
@@ -3636,14 +3647,13 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
adev->rmmio = NULL;
amdgpu_device_doorbell_fini(adev);
 
-   if (adev->ucode_sysfs_en)
-   amdgpu_ucode_sysfs_fini(adev);
-
-   sysfs_remove_files(>dev->kobj, amdgpu_dev_attributes);
if (IS_ENABLED(CONFIG_PERF_EVENTS))
amdgpu_pmu_fini(adev);
if (adev->mman.discovery_bin)
amdgpu_discovery_fini(adev);
+
+   kfree(adev->pci_state);
+
 }
 
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 72efd57..9c0cd00 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1238,14 +1238,10 @@ 

[PATCH v4 06/14] drm/amdgpu: Add early fini callback

2021-01-18 Thread Andrey Grodzovsky
Use it to call disply code dependent on device->drv_data
before it's set to NULL on device unplug

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 20 
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++--
 drivers/gpu/drm/amd/include/amd_shared.h  |  2 ++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 90c8353..45e23e3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2529,6 +2529,24 @@ static int amdgpu_device_ip_late_init(struct 
amdgpu_device *adev)
return 0;
 }
 
+static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
+{
+   int i, r;
+
+   for (i = 0; i < adev->num_ip_blocks; i++) {
+   if (!adev->ip_blocks[i].version->funcs->early_fini)
+   continue;
+
+   r = adev->ip_blocks[i].version->funcs->early_fini((void *)adev);
+   if (r) {
+   DRM_DEBUG("early_fini of IP block <%s> failed %d\n",
+ adev->ip_blocks[i].version->funcs->name, r);
+   }
+   }
+
+   return 0;
+}
+
 /**
  * amdgpu_device_ip_fini - run fini for hardware IPs
  *
@@ -3613,6 +3631,8 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
amdgpu_fbdev_fini(adev);
 
amdgpu_irq_fini_hw(adev);
+
+   amdgpu_device_ip_fini_early(adev);
 }
 
 void amdgpu_device_fini_sw(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 86c2b2c..9b24f3e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1156,6 +1156,15 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
return -EINVAL;
 }
 
+static int amdgpu_dm_early_fini(void *handle)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   amdgpu_dm_audio_fini(adev);
+
+   return 0;
+}
+
 static void amdgpu_dm_fini(struct amdgpu_device *adev)
 {
int i;
@@ -1164,8 +1173,6 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev)
drm_encoder_cleanup(>dm.mst_encoders[i].base);
}
 
-   amdgpu_dm_audio_fini(adev);
-
amdgpu_dm_destroy_drm_device(>dm);
 
 #ifdef CONFIG_DRM_AMD_DC_HDCP
@@ -2175,6 +2182,7 @@ static const struct amd_ip_funcs amdgpu_dm_funcs = {
.late_init = dm_late_init,
.sw_init = dm_sw_init,
.sw_fini = dm_sw_fini,
+   .early_fini = amdgpu_dm_early_fini,
.hw_init = dm_hw_init,
.hw_fini = dm_hw_fini,
.suspend = dm_suspend,
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h 
b/drivers/gpu/drm/amd/include/amd_shared.h
index 9676016..63bb846 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -239,6 +239,7 @@ enum amd_dpm_forced_level;
  * @late_init: sets up late driver/hw state (post hw_init) - Optional
  * @sw_init: sets up driver state, does not configure hw
  * @sw_fini: tears down driver state, does not configure hw
+ * @early_fini: tears down stuff before dev detached from driver
  * @hw_init: sets up the hw state
  * @hw_fini: tears down the hw state
  * @late_fini: final cleanup
@@ -267,6 +268,7 @@ struct amd_ip_funcs {
int (*late_init)(void *handle);
int (*sw_init)(void *handle);
int (*sw_fini)(void *handle);
+   int (*early_fini)(void *handle);
int (*hw_init)(void *handle);
int (*hw_fini)(void *handle);
void (*late_fini)(void *handle);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 04/14] drm/sched: Cancel and flush all oustatdning jobs before finish.

2021-01-18 Thread Andrey Grodzovsky
To avoid any possible use after free.

Signed-off-by: Andrey Grodzovsky 
Reviewed-by: Christian König 
---
 drivers/gpu/drm/scheduler/sched_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c
index 997aa15..92637b7 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -899,6 +899,9 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
if (sched->thread)
kthread_stop(sched->thread);
 
+   /* Confirm no work left behind accessing device structures */
+   cancel_delayed_work_sync(>work_tdr);
+
sched->ready = false;
 }
 EXPORT_SYMBOL(drm_sched_fini);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 03/14] drm/ttm: Expose ttm_tt_unpopulate for driver use

2021-01-18 Thread Andrey Grodzovsky
It's needed to drop iommu backed pages on device unplug
before device's IOMMU group is released.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/ttm/ttm_tt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 7f75a13..f9e0b0d 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -341,3 +341,4 @@ void ttm_tt_unpopulate(struct ttm_bo_device *bdev,
ttm_pool_free(>pool, ttm);
ttm->page_flags &= ~TTM_PAGE_FLAG_PRIV_POPULATED;
 }
+EXPORT_SYMBOL(ttm_tt_unpopulate);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 02/14] drm: Unamp the entire device address space on device unplug

2021-01-18 Thread Andrey Grodzovsky
Invalidate all BOs CPU mappings once device is removed.

v3: Move the code from TTM into drm_dev_unplug

Signed-off-by: Andrey Grodzovsky 
Reviewed-by: Christian König 
Reviewed-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index d384a5b..20d22e4 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -469,6 +469,9 @@ void drm_dev_unplug(struct drm_device *dev)
synchronize_srcu(_unplug_srcu);
 
drm_dev_unregister(dev);
+
+   /* Clear all CPU mappings pointing to this device */
+   unmap_mapping_range(dev->anon_inode->i_mapping, 0, 0, 1);
 }
 EXPORT_SYMBOL(drm_dev_unplug);
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 01/14] drm/ttm: Remap all page faults to per process dummy page.

2021-01-18 Thread Andrey Grodzovsky
On device removal reroute all CPU mappings to dummy page.

v3:
Remove loop to find DRM file and instead access it
by vma->vm_file->private_data. Move dummy page installation
into a separate function.

v4:
Map the entire BOs VA space into on demand allocated dummy page
on the first fault for that BO.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 82 -
 include/drm/ttm/ttm_bo_api.h|  2 +
 2 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 6dc96cf..ed89da3 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -34,6 +34,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -380,25 +382,103 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 }
 EXPORT_SYMBOL(ttm_bo_vm_fault_reserved);
 
+static void ttm_bo_release_dummy_page(struct drm_device *dev, void *res)
+{
+   struct page *dummy_page = (struct page *)res;
+
+   __free_page(dummy_page);
+}
+
+vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault *vmf, pgprot_t prot)
+{
+   struct vm_area_struct *vma = vmf->vma;
+   struct ttm_buffer_object *bo = vma->vm_private_data;
+   struct ttm_bo_device *bdev = bo->bdev;
+   struct drm_device *ddev = bo->base.dev;
+   vm_fault_t ret = VM_FAULT_NOPAGE;
+   unsigned long address = vma->vm_start;
+   unsigned long num_prefault = (vma->vm_end - vma->vm_start) >> 
PAGE_SHIFT;
+   unsigned long pfn;
+   struct page *page;
+   int i;
+
+   /*
+* Wait for buffer data in transit, due to a pipelined
+* move.
+*/
+   ret = ttm_bo_vm_fault_idle(bo, vmf);
+   if (unlikely(ret != 0))
+   return ret;
+
+   /* Allocate new dummy page to map all the VA range in this VMA to it*/
+   page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+   if (!page)
+   return VM_FAULT_OOM;
+
+   pfn = page_to_pfn(page);
+
+   /*
+* Prefault the entire VMA range right away to avoid further faults
+*/
+   for (i = 0; i < num_prefault; ++i) {
+
+   if (unlikely(address >= vma->vm_end))
+   break;
+
+   if (vma->vm_flags & VM_MIXEDMAP)
+   ret = vmf_insert_mixed_prot(vma, address,
+   __pfn_to_pfn_t(pfn, 
PFN_DEV),
+   prot);
+   else
+   ret = vmf_insert_pfn_prot(vma, address, pfn, prot);
+
+   /* Never error on prefaulted PTEs */
+   if (unlikely((ret & VM_FAULT_ERROR))) {
+   if (i == 0)
+   return VM_FAULT_NOPAGE;
+   else
+   break;
+   }
+
+   address += PAGE_SIZE;
+   }
+
+   /* Set the page to be freed using drmm release action */
+   if (drmm_add_action_or_reset(ddev, ttm_bo_release_dummy_page, page))
+   return VM_FAULT_OOM;
+
+   return ret;
+}
+EXPORT_SYMBOL(ttm_bo_vm_dummy_page);
+
 vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
 {
struct vm_area_struct *vma = vmf->vma;
pgprot_t prot;
struct ttm_buffer_object *bo = vma->vm_private_data;
+   struct drm_device *ddev = bo->base.dev;
vm_fault_t ret;
+   int idx;
 
ret = ttm_bo_vm_reserve(bo, vmf);
if (ret)
return ret;
 
prot = vma->vm_page_prot;
-   ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT, 1);
+   if (drm_dev_enter(ddev, )) {
+   ret = ttm_bo_vm_fault_reserved(vmf, prot, 
TTM_BO_VM_NUM_PREFAULT, 1);
+   drm_dev_exit(idx);
+   } else {
+   ret = ttm_bo_vm_dummy_page(vmf, prot);
+   }
if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
return ret;
 
dma_resv_unlock(bo->base.resv);
 
return ret;
+
+   return ret;
 }
 EXPORT_SYMBOL(ttm_bo_vm_fault);
 
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index e17be32..12fb240 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -643,4 +643,6 @@ void ttm_bo_vm_close(struct vm_area_struct *vma);
 int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
 void *buf, int len, int write);
 
+vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault *vmf, pgprot_t prot);
+
 #endif
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 00/14] RFC Support hot device unplug in amdgpu

2021-01-18 Thread Andrey Grodzovsky
Until now extracting a card either by physical extraction (e.g. eGPU with 
thunderbolt connection or by emulation through  syfs -> 
/sys/bus/pci/devices/device_id/remove) 
would cause random crashes in user apps. The random crashes in apps were 
mostly due to the app having mapped a device backed BO into its address 
space was still trying to access the BO while the backing device was gone.
To answer this first problem Christian suggested to fix the handling of mapped 
memory in the clients when the device goes away by forcibly unmap all buffers 
the 
user processes has by clearing their respective VMAs mapping the device BOs. 
Then when the VMAs try to fill in the page tables again we check in the fault 
handlerif the device is removed and if so, return an error. This will generate 
a 
SIGBUS to the application which can then cleanly terminate.This indeed was done 
but this in turn created a problem of kernel OOPs were the OOPSes were due to 
the 
fact that while the app was terminating because of the SIGBUSit would trigger 
use 
after free in the driver by calling to accesses device structures that were 
already 
released from the pci remove sequence.This was handled by introducing a 'flush' 
sequence during device removal were we wait for drm file reference to drop to 0 
meaning all user clients directly using this device terminated.

v2:
Based on discussions in the mailing list with Daniel and Pekka [1] and based on 
the document 
produced by Pekka from those discussions [2] the whole approach with returning 
SIGBUS and 
waiting for all user clients having CPU mapping of device BOs to die was 
dropped. 
Instead as per the document suggestion the device structures are kept alive 
until 
the last reference to the device is dropped by user client and in the meanwhile 
all existing and new CPU mappings of the BOs 
belonging to the device directly or by dma-buf import are rerouted to per user 
process dummy rw page.Also, I skipped the 'Requirements for KMS UAPI' section 
of [2] 
since i am trying to get the minimal set of requirements that still give useful 
solution 
to work and this is the'Requirements for Render and Cross-Device UAPI' section 
and so my 
test case is removing a secondary device, which is render only and is not 
involved 
in KMS.

v3:
More updates following comments from v2 such as removing loop to find DRM file 
when rerouting 
page faults to dummy page,getting rid of unnecessary sysfs handling refactoring 
and moving 
prevention of GPU recovery post device unplug from amdgpu to scheduler layer. 
On top of that added unplug support for the IOMMU enabled system.

v4:
Drop last sysfs hack and use sysfs default attribute.
Guard against write accesses after device removal to avoid modifying released 
memory.
Update dummy pages handling to on demand allocation and release through drm 
managed framework.
Add return value to scheduler job TO handler (by Luben Tuikov) and use this in 
amdgpu for prevention 
of GPU recovery post device unplug
Also rebase on top of drm-misc-mext instead of amd-staging-drm-next

With these patches I am able to gracefully remove the secondary card using 
sysfs remove hook while glxgears 
is running off of secondary card (DRI_PRIME=1) without kernel oopses or hangs 
and keep working 
with the primary card or soft reset the device without hangs or oopses

TODOs for followup work:
Convert AMDGPU code to use devm (for hw stuff) and drmm (for sw stuff and 
allocations) (Daniel)
Support plugging the secondary device back after unplug - currently still 
experiencing HW error on plugging back.
Add support for 'Requirements for KMS UAPI' section of [2] - unplugging 
primary, display connected card.

[1] - Discussions during v3 of the patchset 
https://www.spinics.net/lists/amd-gfx/msg55576.html
[2] - drm/doc: device hot-unplug for userspace 
https://www.spinics.net/lists/dri-devel/msg259755.html
[3] - Related gitlab ticket https://gitlab.freedesktop.org/drm/amd/-/issues/1081

Andrey Grodzovsky (13):
  drm/ttm: Remap all page faults to per process dummy page.
  drm: Unamp the entire device address space on device unplug
  drm/ttm: Expose ttm_tt_unpopulate for driver use
  drm/sched: Cancel and flush all oustatdning jobs before finish.
  drm/amdgpu: Split amdgpu_device_fini into early and late
  drm/amdgpu: Add early fini callback
  drm/amdgpu: Register IOMMU topology notifier per device.
  drm/amdgpu: Fix a bunch of sdma code crash post device unplug
  drm/amdgpu: Remap all page faults to per process dummy page.
  dmr/amdgpu: Move some sysfs attrs creation to default_attr
  drm/amdgpu: Guard against write accesses after device removal
  drm/sched: Make timeout timer rearm conditional.
  drm/amdgpu: Prevent any job recoveries after device is unplugged.

Luben Tuikov (1):
  drm/scheduler: Job timeout handler returns status

 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  11 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c  |  17 +--
 

Re: [PATCH v4 5/6] drm/vmwgfx: Remove reference to struct drm_device.pdev

2021-01-18 Thread Zack Rusin


> On Jan 18, 2021, at 08:14, Thomas Zimmermann  wrote:
> 
> Using struct drm_device.pdev is deprecated in favor of drm_device.dev.
> The reference to the field was reintroduced during a rebase.
> 
> Signed-off-by: Thomas Zimmermann 
> Fixes: 9703bb329206 ("drm/vmwgfx: Switch to a managed drm device")
> Cc: Zack Rusin 
> Cc: Martin Krastev 
> Cc: Roland Scheidegger 
> Cc: VMware Graphics 
> Cc: dri-devel@lists.freedesktop.org
> ---
> drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 1 -
> 1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 8c3eb00e8b54..545b83e338fc 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -1524,7 +1524,6 @@ static int vmw_probe(struct pci_dev *pdev, const struct 
> pci_device_id *ent)
>   if (IS_ERR(vmw))
>   return PTR_ERR(vmw);
> 
> - vmw->drm.pdev = pdev;
>   pci_set_drvdata(pdev, >drm);
> 
>   ret = vmw_driver_load(vmw, ent->device);

Ah, sorry about that. Looks good.

Reviewed-by: Zack Rusin 

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/syncobj: make lockdep complain on WAIT_FOR_SUBMIT v2

2021-01-18 Thread Christian König
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT can't be used when we hold locks
since we are basically waiting for userspace to do something.

Holding a lock while doing so can trivial deadlock with page faults
etc...

So make lockdep complain when a driver tries to do this.

v2: Add lockdep_assert_none_held() macro.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/drm_syncobj.c | 7 +++
 include/linux/lockdep.h   | 5 +
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 6e74e6745eca..f51458615158 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -387,6 +387,13 @@ int drm_syncobj_find_fence(struct drm_file *file_private,
if (!syncobj)
return -ENOENT;
 
+   /* Waiting for userspace with locks help is illegal cause that can
+* trivial deadlock with page faults for example. Make lockdep complain
+* about it early on.
+*/
+   if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT)
+   lockdep_assert_none_held_once();
+
*fence = drm_syncobj_fence_get(syncobj);
drm_syncobj_put(syncobj);
 
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index b9e9adec73e8..6eb117c0d0f3 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -310,6 +310,10 @@ extern void lock_unpin_lock(struct lockdep_map *lock, 
struct pin_cookie);
WARN_ON_ONCE(debug_locks && !lockdep_is_held(l));   \
} while (0)
 
+#define lockdep_assert_none_held_once()do {
\
+   WARN_ON_ONCE(debug_locks && current->lockdep_depth);\
+   } while (0)
+
 #define lockdep_recursing(tsk) ((tsk)->lockdep_recursion)
 
 #define lockdep_pin_lock(l)lock_pin_lock(&(l)->dep_map)
@@ -387,6 +391,7 @@ extern int lockdep_is_held(const void *);
 #define lockdep_assert_held_write(l)   do { (void)(l); } while (0)
 #define lockdep_assert_held_read(l)do { (void)(l); } while (0)
 #define lockdep_assert_held_once(l)do { (void)(l); } while (0)
+#define lockdep_assert_none_held_once()do { } while (0)
 
 #define lockdep_recursing(tsk) (0)
 
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Let lockdep complain when locks are taken while waiting for userspace.

2021-01-18 Thread Christian König
Hi guys,

because of the Vulkan graphics API we have a specialized synchronization object 
to handle both inter process as well as process to hardware synchronization.

The problem is now that when drivers call this interface with some lock help it 
is trivial to create a deadlock when those locks are also needed in a page 
fault for example.

The idea of this patch is now to let lockdep complain when any locks are called 
when the interface is used.

Please review and/or comment.

Thanks,
Christian.


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 00/29] [Set 15] Finally rid W=1 warnings from GPU!

2021-01-18 Thread Daniel Vetter
On Mon, Jan 18, 2021 at 03:09:45PM +, Lee Jones wrote:
> On Mon, 18 Jan 2021, Daniel Vetter wrote:
> 
> > On Fri, Jan 15, 2021 at 06:27:15PM +, Zack Rusin wrote:
> > > 
> > > > On Jan 15, 2021, at 13:15, Lee Jones  wrote:
> > > > 
> > > > This set is part of a larger effort attempting to clean-up W=1
> > > > kernel builds, which are currently overwhelmingly riddled with
> > > > niggly little warnings.
> > > > 
> > > > Last set!  All clean after this for; Arm, Arm64, PPC, MIPS and x86.
> > > 
> > > Thanks! For all the vmwgfx bits:
> > > Reviewed-by: Zack Rusin 
> > 
> > Ok I merged everything except vmwgfx (that's for Zack) and i915/nouveau
> > (those generally go through other trees, pls holler if they're stuck).
> 
> Thanks Daniel, you're a superstar!
> 
> So Zack will take the vmwgfx parts?  Despite providing a R-b?

I only merge stuff that's defacto abandoned already. Everything else I try
to offload to whomever actually cares :-)
-Daniel

> 
> > Note that we have some build issue on some of the configs sfr uses, so drm
> > trees are still stuck on old versions in linux-next. Hopefully should get
> > resolved soon, the bugfix is in some subtree I've heard.
> 
> No worries.  Thanks for letting me know.
> 
> -- 
> Lee Jones [李琼斯]
> Senior Technical Lead - Developer Services
> Linaro.org │ Open source software for Arm SoCs
> Follow Linaro: Facebook | Twitter | Blog
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v9] backlight: lms283gf05: Convert to GPIO descriptors

2021-01-18 Thread Lee Jones
On Mon, 18 Jan 2021, Linus Walleij wrote:

> This converts the lms283gf05 backlight driver to use GPIO
> descriptors and switches the single PXA Palm Z2 device
> over to defining these.
> 
> Since the platform data was only used to convey GPIO
> information we can delete the platform data header.
> 
> Notice that we define the proper active low semantics in
> the board file GPIO descriptor table (active low) and
> assert the reset line by bringing it to "1" (asserted).
> 
> Cc: Marek Vasut 
> Cc: Haojian Zhuang 
> Cc: Robert Jarzmik 
> Reviewed-by: Daniel Mack 
> Acked-by: Mark Brown 
> Reviewed-by: Daniel Thompson 
> Signed-off-by: Linus Walleij 

Okay, is that everyone?

> ---
> ChangeLog v8->v9:
> - Collect ACKs!
> - Backlight maintainers: please merge this into the backlight
>   tree.
> ChangeLog v7->v8:
> - Rebase onto v5.11-rc1
> - I wonder why this never seems to get merged...?
> ChangeLog v6->v7:
> - Rebase onto v5.10-rc1
> ChangeLog v5->v6:
> - Rebase onto v5.9-rc1
> ChangeLog v4->v5:
> - Rebase on v5.8-rc1
> - Collected Daniel's Reviewed-by tag.
> ChangeLog v3->v4:
> - Check IS_ERR() on the returned GPIO descriptor.
> - Unconditionally set consumer name since the API tolerates NULL.
> ChangeLog v2->v3:
> - Fix a use-before-allocated bug discovered by compile tests.
> - Remove unused ret variable as autobuilders complained.
> ChangeLog v1->v2:
> - Bring up the GPIO de-asserted in probe()
> 
> Marek: I saw this was written by you, are you regularly
> testing the Z2 device?
> ---
>  arch/arm/mach-pxa/z2.c   | 12 +---
>  drivers/video/backlight/lms283gf05.c | 43 +++-
>  include/linux/spi/lms283gf05.h   | 16 ---
>  3 files changed, 25 insertions(+), 46 deletions(-)
>  delete mode 100644 include/linux/spi/lms283gf05.h

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 00/29] [Set 15] Finally rid W=1 warnings from GPU!

2021-01-18 Thread Lee Jones
On Mon, 18 Jan 2021, Daniel Vetter wrote:

> On Fri, Jan 15, 2021 at 06:27:15PM +, Zack Rusin wrote:
> > 
> > > On Jan 15, 2021, at 13:15, Lee Jones  wrote:
> > > 
> > > This set is part of a larger effort attempting to clean-up W=1
> > > kernel builds, which are currently overwhelmingly riddled with
> > > niggly little warnings.
> > > 
> > > Last set!  All clean after this for; Arm, Arm64, PPC, MIPS and x86.
> > 
> > Thanks! For all the vmwgfx bits:
> > Reviewed-by: Zack Rusin 
> 
> Ok I merged everything except vmwgfx (that's for Zack) and i915/nouveau
> (those generally go through other trees, pls holler if they're stuck).

Thanks Daniel, you're a superstar!

So Zack will take the vmwgfx parts?  Despite providing a R-b?

> Note that we have some build issue on some of the configs sfr uses, so drm
> trees are still stuck on old versions in linux-next. Hopefully should get
> resolved soon, the bugfix is in some subtree I've heard.

No worries.  Thanks for letting me know.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 2/8] drm/amdgpu: Remove references to struct drm_device.pdev

2021-01-18 Thread Thomas Zimmermann

Hi

Am 18.01.21 um 15:56 schrieb Daniel Vetter:

On Mon, Jan 18, 2021 at 3:40 PM Thomas Zimmermann  wrote:


Hi

Am 18.01.21 um 14:50 schrieb Christian König:

Hi Thomas,

this patch unfortunately completely broke amdgpu.

See the splat below:

[   74.553881]
==
[   74.554060] BUG: KASAN: null-ptr-deref in
drm_pci_set_busid+0x38/0x100 [drm]
[   74.554393] Read of size 4 at addr 0038 by task Xorg/1115

[   74.554585] CPU: 6 PID: 1115 Comm: Xorg Not tainted 5.11.0-rc2+ #75
[   74.554594] Hardware name: System manufacturer System Product
Name/PRIME X399-A, BIOS 0808 10/12/2018
[   74.554600] Call Trace:
[   74.554605]  dump_stack+0x9d/0xce
[   74.554616]  ? drm_pci_set_busid+0x38/0x100 [drm]
[   74.554787]  kasan_report.cold+0x5d/0xd1
[   74.554799]  ? drm_pci_set_busid+0x38/0x100 [drm]
[   74.554969]  __asan_load4+0x6b/0x90
[   74.554978]  drm_pci_set_busid+0x38/0x100 [drm]
[   74.555148]  drm_setversion+0x2ce/0x350 [drm]
[   74.555315]  ? drm_is_current_master+0x5d/0x70 [drm]
[   74.555481]  drm_ioctl_kernel+0x16d/0x1c0 [drm]
[   74.555648]  ? drm_ioctl_permit+0xb0/0xb0 [drm]
[   74.555811]  ? drm_setversion+0x350/0x350 [drm]
[   74.555973]  ? check_stack_object+0x2d/0xb0
[   74.555985]  drm_ioctl+0x363/0x5a0 [drm]
[   74.556147]  ? drm_ioctl_permit+0xb0/0xb0 [drm]
[   74.556310]  ? drm_ioctl_kernel+0x1c0/0x1c0 [drm]
[   74.556473]  ? __kasan_check_write+0x14/0x20
[   74.556481]  ? _raw_spin_lock_irqsave+0x8e/0xf0
[   74.556492]  ? _raw_spin_trylock_bh+0x100/0x100
[   74.556504]  amdgpu_drm_ioctl+0x7e/0xd0 [amdgpu]
[   74.557409]  __x64_sys_ioctl+0xc3/0x100
[   74.557418]  do_syscall_64+0x38/0x90
[   74.557427]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Any idea what's going wrong here?


I meanwhile posted an updated patchset with a fix in patch 1. [1] Maybe
you can apply this one and test.

The original bug report and testing is at [2]. Apparently, DRM core has
to be changed together with drivers. I'm honestly not sure why.


Same thing Chris pointed out on the i915 patch: If drivers stop
setting drm->pdev, but core still uses it, we have booms. So that
patch 1 needs to land asap I think.


Yep. But somehow my impression was that the DRM core also sets pdev 
internally in drm_get_pci_dev(). But looking at it now, that code is 
only used by legacy drivers. :/


Best regards
Thomas


-Daniel



Best regards
Thomas

[1]
https://lore.kernel.org/dri-devel/20210118131420.15874-1-tzimmerm...@suse.de/T/#m8a0cdf02375a4e23e194d2e7eb80e8738632ea84
[2]
https://lore.kernel.org/dri-devel/7851c78c-8c57-3c84-cd49-a72703095...@suse.de/



Thanks in advance,
Christian.

Am 07.01.21 um 09:07 schrieb Thomas Zimmermann:

Using struct drm_device.pdev is deprecated. Convert amdgpu to struct
drm_device.dev. No functional changes.

v3:
 * rebased

Signed-off-by: Thomas Zimmermann 
Acked-by: Christian König 
Acked-by: Alex Deucher 
Acked-by: Sam Ravnborg 
Cc: Alex Deucher 
Cc: Christian König 
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 17 -
   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  1 +
   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
   drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  |  2 +-
   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +-
   drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c |  2 +-
   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 10 +-
   7 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 7d16395ede0a..f7e2a878411e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1423,9 +1423,9 @@ static void amdgpu_switcheroo_set_state(struct
pci_dev *pdev,
   /* don't suspend or resume card normally */
   dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
-pci_set_power_state(dev->pdev, PCI_D0);
-amdgpu_device_load_pci_state(dev->pdev);
-r = pci_enable_device(dev->pdev);
+pci_set_power_state(pdev, PCI_D0);
+amdgpu_device_load_pci_state(pdev);
+r = pci_enable_device(pdev);
   if (r)
   DRM_WARN("pci_enable_device failed (%d)\n", r);
   amdgpu_device_resume(dev, true);
@@ -1437,10 +1437,10 @@ static void amdgpu_switcheroo_set_state(struct
pci_dev *pdev,
   drm_kms_helper_poll_disable(dev);
   dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
   amdgpu_device_suspend(dev, true);
-amdgpu_device_cache_pci_state(dev->pdev);
+amdgpu_device_cache_pci_state(pdev);
   /* Shut down the device */
-pci_disable_device(dev->pdev);
-pci_set_power_state(dev->pdev, PCI_D3cold);
+pci_disable_device(pdev);
+pci_set_power_state(pdev, PCI_D3cold);
   dev->switch_power_state = DRM_SWITCH_POWER_OFF;
   }
   }
@@ -1703,8 +1703,7 @@ static void

Re: [PATCH v3 2/8] drm/amdgpu: Remove references to struct drm_device.pdev

2021-01-18 Thread Daniel Vetter
On Mon, Jan 18, 2021 at 3:40 PM Thomas Zimmermann  wrote:
>
> Hi
>
> Am 18.01.21 um 14:50 schrieb Christian König:
> > Hi Thomas,
> >
> > this patch unfortunately completely broke amdgpu.
> >
> > See the splat below:
> >
> > [   74.553881]
> > ==
> > [   74.554060] BUG: KASAN: null-ptr-deref in
> > drm_pci_set_busid+0x38/0x100 [drm]
> > [   74.554393] Read of size 4 at addr 0038 by task Xorg/1115
> >
> > [   74.554585] CPU: 6 PID: 1115 Comm: Xorg Not tainted 5.11.0-rc2+ #75
> > [   74.554594] Hardware name: System manufacturer System Product
> > Name/PRIME X399-A, BIOS 0808 10/12/2018
> > [   74.554600] Call Trace:
> > [   74.554605]  dump_stack+0x9d/0xce
> > [   74.554616]  ? drm_pci_set_busid+0x38/0x100 [drm]
> > [   74.554787]  kasan_report.cold+0x5d/0xd1
> > [   74.554799]  ? drm_pci_set_busid+0x38/0x100 [drm]
> > [   74.554969]  __asan_load4+0x6b/0x90
> > [   74.554978]  drm_pci_set_busid+0x38/0x100 [drm]
> > [   74.555148]  drm_setversion+0x2ce/0x350 [drm]
> > [   74.555315]  ? drm_is_current_master+0x5d/0x70 [drm]
> > [   74.555481]  drm_ioctl_kernel+0x16d/0x1c0 [drm]
> > [   74.555648]  ? drm_ioctl_permit+0xb0/0xb0 [drm]
> > [   74.555811]  ? drm_setversion+0x350/0x350 [drm]
> > [   74.555973]  ? check_stack_object+0x2d/0xb0
> > [   74.555985]  drm_ioctl+0x363/0x5a0 [drm]
> > [   74.556147]  ? drm_ioctl_permit+0xb0/0xb0 [drm]
> > [   74.556310]  ? drm_ioctl_kernel+0x1c0/0x1c0 [drm]
> > [   74.556473]  ? __kasan_check_write+0x14/0x20
> > [   74.556481]  ? _raw_spin_lock_irqsave+0x8e/0xf0
> > [   74.556492]  ? _raw_spin_trylock_bh+0x100/0x100
> > [   74.556504]  amdgpu_drm_ioctl+0x7e/0xd0 [amdgpu]
> > [   74.557409]  __x64_sys_ioctl+0xc3/0x100
> > [   74.557418]  do_syscall_64+0x38/0x90
> > [   74.557427]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> >
> > Any idea what's going wrong here?
>
> I meanwhile posted an updated patchset with a fix in patch 1. [1] Maybe
> you can apply this one and test.
>
> The original bug report and testing is at [2]. Apparently, DRM core has
> to be changed together with drivers. I'm honestly not sure why.

Same thing Chris pointed out on the i915 patch: If drivers stop
setting drm->pdev, but core still uses it, we have booms. So that
patch 1 needs to land asap I think.
-Daniel

>
> Best regards
> Thomas
>
> [1]
> https://lore.kernel.org/dri-devel/20210118131420.15874-1-tzimmerm...@suse.de/T/#m8a0cdf02375a4e23e194d2e7eb80e8738632ea84
> [2]
> https://lore.kernel.org/dri-devel/7851c78c-8c57-3c84-cd49-a72703095...@suse.de/
>
> >
> > Thanks in advance,
> > Christian.
> >
> > Am 07.01.21 um 09:07 schrieb Thomas Zimmermann:
> >> Using struct drm_device.pdev is deprecated. Convert amdgpu to struct
> >> drm_device.dev. No functional changes.
> >>
> >> v3:
> >> * rebased
> >>
> >> Signed-off-by: Thomas Zimmermann 
> >> Acked-by: Christian König 
> >> Acked-by: Alex Deucher 
> >> Acked-by: Sam Ravnborg 
> >> Cc: Alex Deucher 
> >> Cc: Christian König 
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 17 -
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  1 +
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  |  2 +-
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +-
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c |  2 +-
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 10 +-
> >>   7 files changed, 21 insertions(+), 22 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> >> index 7d16395ede0a..f7e2a878411e 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> >> @@ -1423,9 +1423,9 @@ static void amdgpu_switcheroo_set_state(struct
> >> pci_dev *pdev,
> >>   /* don't suspend or resume card normally */
> >>   dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> >> -pci_set_power_state(dev->pdev, PCI_D0);
> >> -amdgpu_device_load_pci_state(dev->pdev);
> >> -r = pci_enable_device(dev->pdev);
> >> +pci_set_power_state(pdev, PCI_D0);
> >> +amdgpu_device_load_pci_state(pdev);
> >> +r = pci_enable_device(pdev);
> >>   if (r)
> >>   DRM_WARN("pci_enable_device failed (%d)\n", r);
> >>   amdgpu_device_resume(dev, true);
> >> @@ -1437,10 +1437,10 @@ static void amdgpu_switcheroo_set_state(struct
> >> pci_dev *pdev,
> >>   drm_kms_helper_poll_disable(dev);
> >>   dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> >>   amdgpu_device_suspend(dev, true);
> >> -amdgpu_device_cache_pci_state(dev->pdev);
> >> +amdgpu_device_cache_pci_state(pdev);
> >>   /* Shut down the device */
> >> -pci_disable_device(dev->pdev);
> >> -pci_set_power_state(dev->pdev, PCI_D3cold);
> >> +pci_disable_device(pdev);

Re: [PATCH 00/29] [Set 15] Finally rid W=1 warnings from GPU!

2021-01-18 Thread Daniel Vetter
On Fri, Jan 15, 2021 at 06:27:15PM +, Zack Rusin wrote:
> 
> > On Jan 15, 2021, at 13:15, Lee Jones  wrote:
> > 
> > This set is part of a larger effort attempting to clean-up W=1
> > kernel builds, which are currently overwhelmingly riddled with
> > niggly little warnings.
> > 
> > Last set!  All clean after this for; Arm, Arm64, PPC, MIPS and x86.
> 
> Thanks! For all the vmwgfx bits:
> Reviewed-by: Zack Rusin 

Ok I merged everything except vmwgfx (that's for Zack) and i915/nouveau
(those generally go through other trees, pls holler if they're stuck).

Note that we have some build issue on some of the configs sfr uses, so drm
trees are still stuck on old versions in linux-next. Hopefully should get
resolved soon, the bugfix is in some subtree I've heard.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 3/6] drm/i915/gt: Remove references to struct drm_device.pdev

2021-01-18 Thread Thomas Zimmermann

Hi

Am 18.01.21 um 14:38 schrieb Chris Wilson:

Quoting Thomas Zimmermann (2021-01-18 13:14:17)

Using struct drm_device.pdev is deprecated. Convert i915 to struct
drm_device.dev. No functional changes.


This needs to be before or in the previous patch, as that patch removed
assignment of i915->drm.pdev.

Or the removal of the assignment moved to the end as a separate patch.
That makes more sense.


Makes sense. The patches can be reordered easily. There was some 
discussion on irc about how the i915 patches first need a merge of the 
i915 tree to the gvt tree, or something like that.


Best regards
Thomas


-Chris



--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



OpenPGP_signature
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Change eats memory on my server

2021-01-18 Thread Thomas Zimmermann

Hi

Am 18.01.21 um 14:23 schrieb Christian König:

Am 18.01.21 um 14:22 schrieb Eli Cohen:

On Mon, Jan 18, 2021 at 02:20:49PM +0100, Thomas Zimmermann wrote:

Hi

Am 18.01.21 um 14:16 schrieb Eli Cohen:

On Mon, Jan 18, 2021 at 10:30:56AM +0100, Thomas Zimmermann wrote:
Here's the patch against the latest DRM tree. v5.11-rc3 should work 
as well.


I was able to reproduce the memory leak locally and found that the 
patch

fixes it. Please give it a try.


As far as I am concerned, this issue is fixed by the patch you sent.

Thanks for looking into it.
OK, great. I'll prepare the real patch soon. Can I add your 
Reported-by and

Tested-by tags?

Yes, sure.


Feel free to add an Acked-by from my side as well.


Done, thanks. I sent out the patch. If no one complains, I'll merge it 
on Wednesday or so.


Best regards
Thomas



Christian.




Best regards
Thomas


Eli


--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer






___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



OpenPGP_signature
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/vram-helper: Reuse existing page mappings in vmap

2021-01-18 Thread Thomas Zimmermann
For performance, BO page mappings can stay in place even if the
map counter has returned to 0. In these cases, the existing page
mapping has to be reused by the next vmap operation. Otherwise
a new mapping would be installed and the old mapping's pages leak.

Fix the issue by reusing existing page mappings for vmap operations.

Signed-off-by: Thomas Zimmermann 
Fixes: 1086db71a1db ("drm/vram-helper: Remove invariant parameters from 
internal kmap function")
Acked-by: Christian König 
Tested-by: Eli Cohen 
Reported-by: Eli Cohen 
Cc: Daniel Vetter 
Cc: Christian König 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index 02ca22e90290..0b232a73c1b7 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -387,9 +387,16 @@ static int drm_gem_vram_kmap_locked(struct 
drm_gem_vram_object *gbo,
if (gbo->vmap_use_count > 0)
goto out;
 
-   ret = ttm_bo_vmap(>bo, >map);
-   if (ret)
-   return ret;
+   /*
+* VRAM helpers unmap the BO only on demand. So the previous
+* page mapping might still be around. Only vmap if the there's
+* no mapping present.
+*/
+   if (dma_buf_map_is_null(>map)) {
+   ret = ttm_bo_vmap(>bo, >map);
+   if (ret)
+   return ret;
+   }
 
 out:
++gbo->vmap_use_count;
@@ -577,6 +584,7 @@ static void drm_gem_vram_bo_driver_move_notify(struct 
drm_gem_vram_object *gbo,
return;
 
ttm_bo_vunmap(bo, >map);
+   dma_buf_map_clear(>map); /* explicitly clear mapping for next vmap 
call */
 }
 
 static int drm_gem_vram_bo_driver_move(struct drm_gem_vram_object *gbo,
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 00/40] [Set 14] Rid W=1 warnings from GPU

2021-01-18 Thread Daniel Vetter
On Fri, Jan 15, 2021 at 06:22:23PM +, Zack Rusin wrote:
> 
> > On Jan 15, 2021, at 13:12, Lee Jones  wrote:
> > 
> > This set is part of a larger effort attempting to clean-up W=1
> > kernel builds, which are currently overwhelmingly riddled with
> > niggly little warnings.
> > 
> > Penultimate set, promise. :)
> 
> 
> Thank you for all that work. For all the vmwgfx bits:
> Reviewed-by: Zack Rusin 

I pulled all the non-vmxgfx patches to drm-misc-next, I'll leave the vmw
stuff to Zack.

Thanks for your work here!
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 2/8] drm/amdgpu: Remove references to struct drm_device.pdev

2021-01-18 Thread Thomas Zimmermann

Hi

Am 18.01.21 um 14:50 schrieb Christian König:

Hi Thomas,

this patch unfortunately completely broke amdgpu.

See the splat below:

[   74.553881] 
==
[   74.554060] BUG: KASAN: null-ptr-deref in 
drm_pci_set_busid+0x38/0x100 [drm]

[   74.554393] Read of size 4 at addr 0038 by task Xorg/1115

[   74.554585] CPU: 6 PID: 1115 Comm: Xorg Not tainted 5.11.0-rc2+ #75
[   74.554594] Hardware name: System manufacturer System Product 
Name/PRIME X399-A, BIOS 0808 10/12/2018

[   74.554600] Call Trace:
[   74.554605]  dump_stack+0x9d/0xce
[   74.554616]  ? drm_pci_set_busid+0x38/0x100 [drm]
[   74.554787]  kasan_report.cold+0x5d/0xd1
[   74.554799]  ? drm_pci_set_busid+0x38/0x100 [drm]
[   74.554969]  __asan_load4+0x6b/0x90
[   74.554978]  drm_pci_set_busid+0x38/0x100 [drm]
[   74.555148]  drm_setversion+0x2ce/0x350 [drm]
[   74.555315]  ? drm_is_current_master+0x5d/0x70 [drm]
[   74.555481]  drm_ioctl_kernel+0x16d/0x1c0 [drm]
[   74.555648]  ? drm_ioctl_permit+0xb0/0xb0 [drm]
[   74.555811]  ? drm_setversion+0x350/0x350 [drm]
[   74.555973]  ? check_stack_object+0x2d/0xb0
[   74.555985]  drm_ioctl+0x363/0x5a0 [drm]
[   74.556147]  ? drm_ioctl_permit+0xb0/0xb0 [drm]
[   74.556310]  ? drm_ioctl_kernel+0x1c0/0x1c0 [drm]
[   74.556473]  ? __kasan_check_write+0x14/0x20
[   74.556481]  ? _raw_spin_lock_irqsave+0x8e/0xf0
[   74.556492]  ? _raw_spin_trylock_bh+0x100/0x100
[   74.556504]  amdgpu_drm_ioctl+0x7e/0xd0 [amdgpu]
[   74.557409]  __x64_sys_ioctl+0xc3/0x100
[   74.557418]  do_syscall_64+0x38/0x90
[   74.557427]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Any idea what's going wrong here?


I meanwhile posted an updated patchset with a fix in patch 1. [1] Maybe 
you can apply this one and test.


The original bug report and testing is at [2]. Apparently, DRM core has 
to be changed together with drivers. I'm honestly not sure why.


Best regards
Thomas

[1] 
https://lore.kernel.org/dri-devel/20210118131420.15874-1-tzimmerm...@suse.de/T/#m8a0cdf02375a4e23e194d2e7eb80e8738632ea84
[2] 
https://lore.kernel.org/dri-devel/7851c78c-8c57-3c84-cd49-a72703095...@suse.de/




Thanks in advance,
Christian.

Am 07.01.21 um 09:07 schrieb Thomas Zimmermann:

Using struct drm_device.pdev is deprecated. Convert amdgpu to struct
drm_device.dev. No functional changes.

v3:
* rebased

Signed-off-by: Thomas Zimmermann 
Acked-by: Christian König 
Acked-by: Alex Deucher 
Acked-by: Sam Ravnborg 
Cc: Alex Deucher 
Cc: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 17 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 10 +-
  7 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 7d16395ede0a..f7e2a878411e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1423,9 +1423,9 @@ static void amdgpu_switcheroo_set_state(struct 
pci_dev *pdev,

  /* don't suspend or resume card normally */
  dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
-    pci_set_power_state(dev->pdev, PCI_D0);
-    amdgpu_device_load_pci_state(dev->pdev);
-    r = pci_enable_device(dev->pdev);
+    pci_set_power_state(pdev, PCI_D0);
+    amdgpu_device_load_pci_state(pdev);
+    r = pci_enable_device(pdev);
  if (r)
  DRM_WARN("pci_enable_device failed (%d)\n", r);
  amdgpu_device_resume(dev, true);
@@ -1437,10 +1437,10 @@ static void amdgpu_switcheroo_set_state(struct 
pci_dev *pdev,

  drm_kms_helper_poll_disable(dev);
  dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
  amdgpu_device_suspend(dev, true);
-    amdgpu_device_cache_pci_state(dev->pdev);
+    amdgpu_device_cache_pci_state(pdev);
  /* Shut down the device */
-    pci_disable_device(dev->pdev);
-    pci_set_power_state(dev->pdev, PCI_D3cold);
+    pci_disable_device(pdev);
+    pci_set_power_state(pdev, PCI_D3cold);
  dev->switch_power_state = DRM_SWITCH_POWER_OFF;
  }
  }
@@ -1703,8 +1703,7 @@ static void 
amdgpu_device_enable_virtual_display(struct amdgpu_device *adev)

  adev->enable_virtual_display = false;
  if (amdgpu_virtual_display) {
-    struct drm_device *ddev = adev_to_drm(adev);
-    const char *pci_address_name = pci_name(ddev->pdev);
+    const char *pci_address_name = pci_name(adev->pdev);
  char *pciaddstr, *pciaddstr_tmp, *pciaddname_tmp, *pciaddname;
  pciaddstr = kstrdup(amdgpu_virtual_display, GFP_KERNEL);
@@ -3397,7 +3396,7 @@ int 

[Bug 211263] amdgpu: navi (RX 5500 XT) high power consumption while idling on 75Hz display

2021-01-18 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=211263

Alex Deucher (alexdeuc...@gmail.com) changed:

   What|Removed |Added

 CC||alexdeuc...@gmail.com

--- Comment #1 from Alex Deucher (alexdeuc...@gmail.com) ---
Fixed with this commit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4eec66c014e9a406d8d453de958f6791d05427e4

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 1/3] drm/amd/display: Add module parameter for freesync video mode

2021-01-18 Thread Aurabindo Pillai
On Thu, 2021-01-14 at 11:14 +0200, Pekka Paalanen wrote:
> 
> Hi,
> 
> please document somewhere that ends up in git history (commit
> message,
> code comments, description of the parameter would be the best but
> maybe
> there isn't enough space?) what Christian König explained in
> 
>  
> https://lists.freedesktop.org/archives/dri-devel/2020-December/291254.html
> 
> that this is a stop-gap feature intended to be removed as soon as
> possible (when a better solution comes up, which could be years).
> 
> So far I have not seen a single mention of this intention in your
> patch
> submissions, and I think it is very important to make known.

Hi,

Thanks for the headsup, I shall add the relevant info in the next
verison.

> 
> I also did not see an explanation of why this instead of
> manufacturing
> these video modes in userspace (an idea mentioned by Christian in the
> referenced email). I think that too should be part of a commit
> message.

This is an opt-in feature, which shall be superseded by a better
solution. We also add a set of common modes for scaling similarly.
Userspace can still add whatever mode they want. So I dont see a reason
why this cant be in the kernel.

--

Regards,
Aurabindo Pillai

> 
> 
> Thanks,
> pq


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 211263] New: amdgpu: navi (RX 5500 XT) high power consumption while idling on 75Hz display

2021-01-18 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=211263

Bug ID: 211263
   Summary: amdgpu: navi (RX 5500 XT) high power consumption while
idling on 75Hz display
   Product: Drivers
   Version: 2.5
Kernel Version: 5.10.7
  Hardware: x86-64
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: normal
  Priority: P1
 Component: Video(DRI - non Intel)
  Assignee: drivers_video-...@kernel-bugs.osdl.org
  Reporter: contato-mygh...@protonmail.com
Regression: No

Created attachment 294731
  --> https://bugzilla.kernel.org/attachment.cgi?id=294731=edit
corectrl monitoring at 60hz and 75hz

Overview:

My RX 5500XT (GV-R55XTOC-8GD) consumes about 15W on idle if my monitor
(24MK430) is on 75Hz, and just 3W on 60Hz. This did never happened before 5.10
kernels. Any older kernel consumes 3W even on 75Hz, same hardware, same
configurations.

Steps to reproduce:
Install any distro with 5.10 kernel on a system that have high refresh rate
display and AMD NAVI GPU.

Actual results:
High GPU power consumption while idling, GPU heating and fans spinning up while
doing nothing on the computer.

Expected results:
Low power consumption and low GPU heat.

Operational System:
Arch Linux (latest packages avaliable from the repository)

Additional Information:
Here's my tlp configuration (keep in mind: that same configuration was applied
on kernel 5.9.14 and 5.4.90, both working properly with 3W at 75Hz):

RADEON_POWER_PROFILE_ON_AC=high
RADEON_DPM_PERF_LEVEL_ON_AC=auto
RADEON_DPM_STATE_ON_AC=performance

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/komeda: Fix bit check to import to value of proper type

2021-01-18 Thread carsten . haitzler
From: Carsten Haitzler 

Another issue found by KASAN. The bit finding is bueried inside the
dp_for_each_set_bit() macro (that passes on to for_each_set_bit() that
calls the bit stuff. These bit functions want an unsigned long pointer
as input and just dumbly casting leads to out-of-bounds accesses.
This fixes that.

Signed-off-by: Carsten Haitzler 
---
 .../drm/arm/display/komeda/komeda_pipeline_state.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
index e8b1e15312d8..f7dddb9f015d 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
@@ -1232,7 +1232,8 @@ komeda_pipeline_unbound_components(struct komeda_pipeline 
*pipe,
struct komeda_pipeline_state *old = priv_to_pipe_st(pipe->obj.state);
struct komeda_component_state *c_st;
struct komeda_component *c;
-   u32 disabling_comps, id;
+   u32 id;
+   unsigned long disabling_comps;
 
WARN_ON(!old);
 
@@ -1262,7 +1263,6 @@ int komeda_release_unclaimed_resources(struct 
komeda_pipeline *pipe,
st = komeda_pipeline_get_new_state(pipe, drm_st);
else
st = komeda_pipeline_get_state_and_set_crtc(pipe, drm_st, NULL);
-
if (WARN_ON(IS_ERR_OR_NULL(st)))
return -EINVAL;
 
@@ -1287,7 +1287,8 @@ bool komeda_pipeline_disable(struct komeda_pipeline *pipe,
struct komeda_pipeline_state *old;
struct komeda_component *c;
struct komeda_component_state *c_st;
-   u32 id, disabling_comps = 0;
+   u32 id;
+   unsigned long disabling_comps;
 
old = komeda_pipeline_get_old_state(pipe, old_state);
 
@@ -1297,7 +1298,7 @@ bool komeda_pipeline_disable(struct komeda_pipeline *pipe,
disabling_comps = old->active_comps &
  pipe->standalone_disabled_comps;
 
-   DRM_DEBUG_ATOMIC("PIPE%d: active_comps: 0x%x, disabling_comps: 0x%x.\n",
+   DRM_DEBUG_ATOMIC("PIPE%d: active_comps: 0x%x, disabling_comps: 
0x%lx.\n",
 pipe->id, old->active_comps, disabling_comps);
 
dp_for_each_set_bit(id, disabling_comps) {
@@ -1331,13 +1332,14 @@ void komeda_pipeline_update(struct komeda_pipeline 
*pipe,
struct komeda_pipeline_state *new = priv_to_pipe_st(pipe->obj.state);
struct komeda_pipeline_state *old;
struct komeda_component *c;
-   u32 id, changed_comps = 0;
+   u32 id;
+   unsigned long changed_comps;
 
old = komeda_pipeline_get_old_state(pipe, old_state);
 
changed_comps = new->active_comps | old->active_comps;
 
-   DRM_DEBUG_ATOMIC("PIPE%d: active_comps: 0x%x, changed: 0x%x.\n",
+   DRM_DEBUG_ATOMIC("PIPE%d: active_comps: 0x%x, changed: 0x%lx.\n",
 pipe->id, new->active_comps, changed_comps);
 
dp_for_each_set_bit(id, changed_comps) {
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 2/8] drm/amdgpu: Remove references to struct drm_device.pdev

2021-01-18 Thread Christian König

Hi Thomas,

this patch unfortunately completely broke amdgpu.

See the splat below:

[   74.553881] 
==
[   74.554060] BUG: KASAN: null-ptr-deref in 
drm_pci_set_busid+0x38/0x100 [drm]

[   74.554393] Read of size 4 at addr 0038 by task Xorg/1115

[   74.554585] CPU: 6 PID: 1115 Comm: Xorg Not tainted 5.11.0-rc2+ #75
[   74.554594] Hardware name: System manufacturer System Product 
Name/PRIME X399-A, BIOS 0808 10/12/2018

[   74.554600] Call Trace:
[   74.554605]  dump_stack+0x9d/0xce
[   74.554616]  ? drm_pci_set_busid+0x38/0x100 [drm]
[   74.554787]  kasan_report.cold+0x5d/0xd1
[   74.554799]  ? drm_pci_set_busid+0x38/0x100 [drm]
[   74.554969]  __asan_load4+0x6b/0x90
[   74.554978]  drm_pci_set_busid+0x38/0x100 [drm]
[   74.555148]  drm_setversion+0x2ce/0x350 [drm]
[   74.555315]  ? drm_is_current_master+0x5d/0x70 [drm]
[   74.555481]  drm_ioctl_kernel+0x16d/0x1c0 [drm]
[   74.555648]  ? drm_ioctl_permit+0xb0/0xb0 [drm]
[   74.555811]  ? drm_setversion+0x350/0x350 [drm]
[   74.555973]  ? check_stack_object+0x2d/0xb0
[   74.555985]  drm_ioctl+0x363/0x5a0 [drm]
[   74.556147]  ? drm_ioctl_permit+0xb0/0xb0 [drm]
[   74.556310]  ? drm_ioctl_kernel+0x1c0/0x1c0 [drm]
[   74.556473]  ? __kasan_check_write+0x14/0x20
[   74.556481]  ? _raw_spin_lock_irqsave+0x8e/0xf0
[   74.556492]  ? _raw_spin_trylock_bh+0x100/0x100
[   74.556504]  amdgpu_drm_ioctl+0x7e/0xd0 [amdgpu]
[   74.557409]  __x64_sys_ioctl+0xc3/0x100
[   74.557418]  do_syscall_64+0x38/0x90
[   74.557427]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Any idea what's going wrong here?

Thanks in advance,
Christian.

Am 07.01.21 um 09:07 schrieb Thomas Zimmermann:

Using struct drm_device.pdev is deprecated. Convert amdgpu to struct
drm_device.dev. No functional changes.

v3:
* rebased

Signed-off-by: Thomas Zimmermann 
Acked-by: Christian König 
Acked-by: Alex Deucher 
Acked-by: Sam Ravnborg 
Cc: Alex Deucher 
Cc: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 17 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 10 +-
  7 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 7d16395ede0a..f7e2a878411e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1423,9 +1423,9 @@ static void amdgpu_switcheroo_set_state(struct pci_dev 
*pdev,
/* don't suspend or resume card normally */
dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
  
-		pci_set_power_state(dev->pdev, PCI_D0);

-   amdgpu_device_load_pci_state(dev->pdev);
-   r = pci_enable_device(dev->pdev);
+   pci_set_power_state(pdev, PCI_D0);
+   amdgpu_device_load_pci_state(pdev);
+   r = pci_enable_device(pdev);
if (r)
DRM_WARN("pci_enable_device failed (%d)\n", r);
amdgpu_device_resume(dev, true);
@@ -1437,10 +1437,10 @@ static void amdgpu_switcheroo_set_state(struct pci_dev 
*pdev,
drm_kms_helper_poll_disable(dev);
dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
amdgpu_device_suspend(dev, true);
-   amdgpu_device_cache_pci_state(dev->pdev);
+   amdgpu_device_cache_pci_state(pdev);
/* Shut down the device */
-   pci_disable_device(dev->pdev);
-   pci_set_power_state(dev->pdev, PCI_D3cold);
+   pci_disable_device(pdev);
+   pci_set_power_state(pdev, PCI_D3cold);
dev->switch_power_state = DRM_SWITCH_POWER_OFF;
}
  }
@@ -1703,8 +1703,7 @@ static void amdgpu_device_enable_virtual_display(struct 
amdgpu_device *adev)
adev->enable_virtual_display = false;
  
  	if (amdgpu_virtual_display) {

-   struct drm_device *ddev = adev_to_drm(adev);
-   const char *pci_address_name = pci_name(ddev->pdev);
+   const char *pci_address_name = pci_name(adev->pdev);
char *pciaddstr, *pciaddstr_tmp, *pciaddname_tmp, *pciaddname;
  
  		pciaddstr = kstrdup(amdgpu_virtual_display, GFP_KERNEL);

@@ -3397,7 +3396,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
}
}
  
-	pci_enable_pcie_error_reporting(adev->ddev.pdev);

+   pci_enable_pcie_error_reporting(adev->pdev);
  
  	/* Post card if necessary */

if (amdgpu_device_need_post(adev)) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 

Re: [PATCH v4 3/6] drm/i915/gt: Remove references to struct drm_device.pdev

2021-01-18 Thread Chris Wilson
Quoting Thomas Zimmermann (2021-01-18 13:14:17)
> Using struct drm_device.pdev is deprecated. Convert i915 to struct
> drm_device.dev. No functional changes.

This needs to be before or in the previous patch, as that patch removed
assignment of i915->drm.pdev.

Or the removal of the assignment moved to the end as a separate patch.
That makes more sense.
-Chris
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 1/6] drm: Upcast struct drm_device.dev to struct pci_device; replace pdev

2021-01-18 Thread Daniel Vetter
On Mon, Jan 18, 2021 at 02:14:15PM +0100, Thomas Zimmermann wrote:
> We have DRM drivers based on USB, SPI and platform devices. All of them
> are fine with storing their device reference in struct drm_device.dev.
> PCI devices should be no exception. Therefore struct drm_device.pdev is
> deprecated.
> 
> Instead upcast from struct drm_device.dev with to_pci_dev(). PCI-specific
> code can use dev_is_pci() to test for a PCI device. This patch changes
> the DRM core code and documentation accordingly.
> 
> v4:
>   * split-off pdev deprecation into separate patch
> 
> Signed-off-by: Thomas Zimmermann 
> Tested-by: Andy Lavr 
> Acked-by: Sam Ravnborg 

Reviewed-by: Daniel Vetter 

> ---
>  drivers/gpu/drm/drm_agpsupport.c |  9 ++---
>  drivers/gpu/drm/drm_bufs.c   |  4 ++--
>  drivers/gpu/drm/drm_edid.c   |  7 ++-
>  drivers/gpu/drm/drm_irq.c| 12 +++-
>  drivers/gpu/drm/drm_pci.c| 26 +++---
>  drivers/gpu/drm/drm_vm.c |  2 +-
>  6 files changed, 37 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_agpsupport.c 
> b/drivers/gpu/drm/drm_agpsupport.c
> index 8b690ef306de..7e765cb0efee 100644
> --- a/drivers/gpu/drm/drm_agpsupport.c
> +++ b/drivers/gpu/drm/drm_agpsupport.c
> @@ -103,11 +103,13 @@ int drm_agp_info_ioctl(struct drm_device *dev, void 
> *data,
>   */
>  int drm_agp_acquire(struct drm_device *dev)
>  {
> + struct pci_dev *pdev = to_pci_dev(dev->dev);
> +
>   if (!dev->agp)
>   return -ENODEV;
>   if (dev->agp->acquired)
>   return -EBUSY;
> - dev->agp->bridge = agp_backend_acquire(dev->pdev);
> + dev->agp->bridge = agp_backend_acquire(pdev);
>   if (!dev->agp->bridge)
>   return -ENODEV;
>   dev->agp->acquired = 1;
> @@ -402,14 +404,15 @@ int drm_agp_free_ioctl(struct drm_device *dev, void 
> *data,
>   */
>  struct drm_agp_head *drm_agp_init(struct drm_device *dev)
>  {
> + struct pci_dev *pdev = to_pci_dev(dev->dev);
>   struct drm_agp_head *head = NULL;
>  
>   head = kzalloc(sizeof(*head), GFP_KERNEL);
>   if (!head)
>   return NULL;
> - head->bridge = agp_find_bridge(dev->pdev);
> + head->bridge = agp_find_bridge(pdev);
>   if (!head->bridge) {
> - head->bridge = agp_backend_acquire(dev->pdev);
> + head->bridge = agp_backend_acquire(pdev);
>   if (!head->bridge) {
>   kfree(head);
>   return NULL;
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index aeb1327e3077..e3d77dfefb0a 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -326,7 +326,7 @@ static int drm_addmap_core(struct drm_device *dev, 
> resource_size_t offset,
>* As we're limiting the address to 2^32-1 (or less),
>* casting it down to 32 bits is no problem, but we
>* need to point to a 64bit variable first. */
> - map->handle = dma_alloc_coherent(>pdev->dev,
> + map->handle = dma_alloc_coherent(dev->dev,
>map->size,
>>offset,
>GFP_KERNEL);
> @@ -556,7 +556,7 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, 
> struct drm_local_map *map)
>   case _DRM_SCATTER_GATHER:
>   break;
>   case _DRM_CONSISTENT:
> - dma_free_coherent(>pdev->dev,
> + dma_free_coherent(dev->dev,
> map->size,
> map->handle,
> map->offset);
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 394cc55b3214..c2bbe7bee7b6 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -32,6 +32,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -2075,9 +2076,13 @@ EXPORT_SYMBOL(drm_get_edid);
>  struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
>struct i2c_adapter *adapter)
>  {
> - struct pci_dev *pdev = connector->dev->pdev;
> + struct drm_device *dev = connector->dev;
> + struct pci_dev *pdev = to_pci_dev(dev->dev);
>   struct edid *edid;
>  
> + if (drm_WARN_ON_ONCE(dev, !dev_is_pci(dev->dev)))
> + return NULL;
> +
>   vga_switcheroo_lock_ddc(pdev);
>   edid = drm_get_edid(connector, adapter);
>   vga_switcheroo_unlock_ddc(pdev);
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 803af4bbd214..c3bd664ea733 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -122,7 +122,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
>   dev->driver->irq_preinstall(dev);
>  
>   /* PCI devices require shared interrupts. */
> - if (dev->pdev)
> 

Re: [PATCH] dma-buf: Add debug option

2021-01-18 Thread Daniel Vetter
On Fri, Jan 15, 2021 at 07:52:53PM +0100, Christian König wrote:
> Am 15.01.21 um 17:47 schrieb Daniel Vetter:
> > We have too many people abusing the struct page they can get at but
> > really shouldn't in importers. Aside from that the backing page might
> > simply not exist (for dynamic p2p mappings) looking at it and using it
> > e.g. for mmap can also wreak the page handling of the exporter
> > completely. Importers really must go through the proper interface like
> > dma_buf_mmap for everything.
> > 
> > I'm semi-tempted to enforce this for dynamic importers since those
> > really have no excuse at all to break the rules.
> > 
> > Unfortuantely we can't store the right pointers somewhere safe to make
> > sure we oops on something recognizable, so best is to just wrangle
> > them a bit by flipping all the bits. At least on x86 kernel addresses
> > have all their high bits sets and the struct page array is fairly low
> > in the kernel mapping, so flipping all the bits gives us a very high
> > pointer in userspace and hence excellent chances for an invalid
> > dereference.
> > 
> > v2: Add a note to the @map_dma_buf hook that exporters shouldn't do
> > fancy caching tricks, which would blow up with this address scrambling
> > trick here (Chris)
> > 
> > Enable by default when CONFIG_DMA_API_DEBUG is enabled.
> > 
> > v3: Only one copy of the mangle/unmangle code (Christian)
> > 
> > v4: #ifdef, not #if (0day)
> > 
> > v5: sg_table can also be an ERR_PTR (Chris, Christian)
> > 
> > Reviewed-by: Chris Wilson  (v2)
> > Signed-off-by: Daniel Vetter 
> > Cc: Chris Wilson 
> > Cc: Sumit Semwal 
> > Cc: "Christian König" 
> > Cc: David Stevens 
> > Cc: linux-me...@vger.kernel.org
> > Cc: linaro-mm-...@lists.linaro.org
> 
> Reviewed-by: Christian König 

Stuffed into drm-misc-next, thanks for reviewing to both of you.
-Daniel
> 
> > ---
> >   drivers/dma-buf/Kconfig   |  8 +++
> >   drivers/dma-buf/dma-buf.c | 46 +++
> >   include/linux/dma-buf.h   |  6 +
> >   3 files changed, 56 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/dma-buf/Kconfig b/drivers/dma-buf/Kconfig
> > index 4f8224a6ac95..4e16c71c24b7 100644
> > --- a/drivers/dma-buf/Kconfig
> > +++ b/drivers/dma-buf/Kconfig
> > @@ -50,6 +50,14 @@ config DMABUF_MOVE_NOTIFY
> >   This is marked experimental because we don't yet have a consistent
> >   execution context and memory management between drivers.
> > +config DMABUF_DEBUG
> > +   bool "DMA-BUF debug checks"
> > +   default y if DMA_API_DEBUG
> > +   help
> > + This option enables additional checks for DMA-BUF importers and
> > + exporters. Specifically it validates that importers do not peek at the
> > + underlying struct page when they import a buffer.
> > +
> >   config DMABUF_SELFTESTS
> > tristate "Selftests for the dma-buf interfaces"
> > default n
> > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> > index 1c9bd51db110..f264b70c383e 100644
> > --- a/drivers/dma-buf/dma-buf.c
> > +++ b/drivers/dma-buf/dma-buf.c
> > @@ -666,6 +666,34 @@ void dma_buf_put(struct dma_buf *dmabuf)
> >   }
> >   EXPORT_SYMBOL_GPL(dma_buf_put);
> > +static void mangle_sg_table(struct sg_table *sg_table)
> > +{
> > +#ifdef CONFIG_DMABUF_DEBUG
> > +   int i;
> > +   struct scatterlist *sg;
> > +
> > +   /* To catch abuse of the underlying struct page by importers mix
> > +* up the bits, but take care to preserve the low SG_ bits to
> > +* not corrupt the sgt. The mixing is undone in __unmap_dma_buf
> > +* before passing the sgt back to the exporter. */
> > +   for_each_sgtable_sg(sg_table, sg, i)
> > +   sg->page_link ^= ~0xffUL;
> > +#endif
> > +
> > +}
> > +static struct sg_table * __map_dma_buf(struct dma_buf_attachment *attach,
> > +  enum dma_data_direction direction)
> > +{
> > +   struct sg_table *sg_table;
> > +
> > +   sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
> > +
> > +   if (!IS_ERR_OR_NULL(sg_table))
> > +   mangle_sg_table(sg_table);
> > +
> > +   return sg_table;
> > +}
> > +
> >   /**
> >* dma_buf_dynamic_attach - Add the device to dma_buf's attachments list
> >* @dmabuf:   [in]buffer to attach device to.
> > @@ -737,7 +765,7 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct 
> > device *dev,
> > goto err_unlock;
> > }
> > -   sgt = dmabuf->ops->map_dma_buf(attach, DMA_BIDIRECTIONAL);
> > +   sgt = __map_dma_buf(attach, DMA_BIDIRECTIONAL);
> > if (!sgt)
> > sgt = ERR_PTR(-ENOMEM);
> > if (IS_ERR(sgt)) {
> > @@ -784,6 +812,16 @@ struct dma_buf_attachment *dma_buf_attach(struct 
> > dma_buf *dmabuf,
> >   }
> >   EXPORT_SYMBOL_GPL(dma_buf_attach);
> > +static void __unmap_dma_buf(struct dma_buf_attachment *attach,
> > +   struct sg_table *sg_table,
> > +

[PATCH v9] backlight: lms283gf05: Convert to GPIO descriptors

2021-01-18 Thread Linus Walleij
This converts the lms283gf05 backlight driver to use GPIO
descriptors and switches the single PXA Palm Z2 device
over to defining these.

Since the platform data was only used to convey GPIO
information we can delete the platform data header.

Notice that we define the proper active low semantics in
the board file GPIO descriptor table (active low) and
assert the reset line by bringing it to "1" (asserted).

Cc: Marek Vasut 
Cc: Haojian Zhuang 
Cc: Robert Jarzmik 
Reviewed-by: Daniel Mack 
Acked-by: Mark Brown 
Reviewed-by: Daniel Thompson 
Signed-off-by: Linus Walleij 
---
ChangeLog v8->v9:
- Collect ACKs!
- Backlight maintainers: please merge this into the backlight
  tree.
ChangeLog v7->v8:
- Rebase onto v5.11-rc1
- I wonder why this never seems to get merged...?
ChangeLog v6->v7:
- Rebase onto v5.10-rc1
ChangeLog v5->v6:
- Rebase onto v5.9-rc1
ChangeLog v4->v5:
- Rebase on v5.8-rc1
- Collected Daniel's Reviewed-by tag.
ChangeLog v3->v4:
- Check IS_ERR() on the returned GPIO descriptor.
- Unconditionally set consumer name since the API tolerates NULL.
ChangeLog v2->v3:
- Fix a use-before-allocated bug discovered by compile tests.
- Remove unused ret variable as autobuilders complained.
ChangeLog v1->v2:
- Bring up the GPIO de-asserted in probe()

Marek: I saw this was written by you, are you regularly
testing the Z2 device?
---
 arch/arm/mach-pxa/z2.c   | 12 +---
 drivers/video/backlight/lms283gf05.c | 43 +++-
 include/linux/spi/lms283gf05.h   | 16 ---
 3 files changed, 25 insertions(+), 46 deletions(-)
 delete mode 100644 include/linux/spi/lms283gf05.h

diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c
index 21fd76bb09cd..89eb5243c85f 100644
--- a/arch/arm/mach-pxa/z2.c
+++ b/arch/arm/mach-pxa/z2.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -578,8 +577,13 @@ static struct pxa2xx_spi_chip lms283_chip_info = {
.gpio_cs= GPIO88_ZIPITZ2_LCD_CS,
 };
 
-static const struct lms283gf05_pdata lms283_pdata = {
-   .reset_gpio = GPIO19_ZIPITZ2_LCD_RESET,
+static struct gpiod_lookup_table lms283_gpio_table = {
+   .dev_id = "spi2.0", /* SPI bus 2 chip select 0 */
+   .table = {
+   GPIO_LOOKUP("gpio-pxa", GPIO19_ZIPITZ2_LCD_RESET,
+   "reset", GPIO_ACTIVE_LOW),
+   { },
+   },
 };
 
 static struct spi_board_info spi_board_info[] __initdata = {
@@ -595,7 +599,6 @@ static struct spi_board_info spi_board_info[] __initdata = {
 {
.modalias   = "lms283gf05",
.controller_data= _chip_info,
-   .platform_data  = _pdata,
.max_speed_hz   = 40,
.bus_num= 2,
.chip_select= 0,
@@ -615,6 +618,7 @@ static void __init z2_spi_init(void)
 {
pxa2xx_set_spi_info(1, _ssp1_master_info);
pxa2xx_set_spi_info(2, _ssp2_master_info);
+   gpiod_add_lookup_table(_gpio_table);
spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
 }
 #else
diff --git a/drivers/video/backlight/lms283gf05.c 
b/drivers/video/backlight/lms283gf05.c
index 0e45685bcc1c..36856962ed83 100644
--- a/drivers/video/backlight/lms283gf05.c
+++ b/drivers/video/backlight/lms283gf05.c
@@ -9,16 +9,16 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include 
-#include 
 #include 
 
 struct lms283gf05_state {
struct spi_device   *spi;
struct lcd_device   *ld;
+   struct gpio_desc*reset;
 };
 
 struct lms283gf05_seq {
@@ -90,13 +90,13 @@ static const struct lms283gf05_seq disp_pdwnseq[] = {
 };
 
 
-static void lms283gf05_reset(unsigned long gpio, bool inverted)
+static void lms283gf05_reset(struct gpio_desc *gpiod)
 {
-   gpio_set_value(gpio, !inverted);
+   gpiod_set_value(gpiod, 0); /* De-asserted */
mdelay(100);
-   gpio_set_value(gpio, inverted);
+   gpiod_set_value(gpiod, 1); /* Asserted */
mdelay(20);
-   gpio_set_value(gpio, !inverted);
+   gpiod_set_value(gpiod, 0); /* De-asserted */
mdelay(20);
 }
 
@@ -125,18 +125,15 @@ static int lms283gf05_power_set(struct lcd_device *ld, 
int power)
 {
struct lms283gf05_state *st = lcd_get_data(ld);
struct spi_device *spi = st->spi;
-   struct lms283gf05_pdata *pdata = dev_get_platdata(>dev);
 
if (power <= FB_BLANK_NORMAL) {
-   if (pdata)
-   lms283gf05_reset(pdata->reset_gpio,
-   pdata->reset_inverted);
+   if (st->reset)
+   lms283gf05_reset(st->reset);
lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq));
} else {
lms283gf05_toggle(spi, disp_pdwnseq, ARRAY_SIZE(disp_pdwnseq));
-   if (pdata)
-   gpio_set_value(pdata->reset_gpio,
- 

Re: Change eats memory on my server

2021-01-18 Thread Christian König

Am 18.01.21 um 14:22 schrieb Eli Cohen:

On Mon, Jan 18, 2021 at 02:20:49PM +0100, Thomas Zimmermann wrote:

Hi

Am 18.01.21 um 14:16 schrieb Eli Cohen:

On Mon, Jan 18, 2021 at 10:30:56AM +0100, Thomas Zimmermann wrote:

Here's the patch against the latest DRM tree. v5.11-rc3 should work as well.

I was able to reproduce the memory leak locally and found that the patch
fixes it. Please give it a try.


As far as I am concerned, this issue is fixed by the patch you sent.

Thanks for looking into it.

OK, great. I'll prepare the real patch soon. Can I add your Reported-by and
Tested-by tags?

Yes, sure.


Feel free to add an Acked-by from my side as well.

Christian.




Best regards
Thomas


Eli


--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer






___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Change eats memory on my server

2021-01-18 Thread Thomas Zimmermann

Hi

Am 18.01.21 um 14:16 schrieb Eli Cohen:

On Mon, Jan 18, 2021 at 10:30:56AM +0100, Thomas Zimmermann wrote:


Here's the patch against the latest DRM tree. v5.11-rc3 should work as well.

I was able to reproduce the memory leak locally and found that the patch
fixes it. Please give it a try.



As far as I am concerned, this issue is fixed by the patch you sent.

Thanks for looking into it.


OK, great. I'll prepare the real patch soon. Can I add your Reported-by 
and Tested-by tags?


Best regards
Thomas



Eli



--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



OpenPGP_signature
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/3] drm/vmwgfx: Drop svga_lock

2021-01-18 Thread Daniel Vetter
On Thu, Jan 14, 2021 at 04:31:09PM +0100, Roland Scheidegger wrote:
> Hi,
> 
> looking at it, seems alright. Not sure why the lock was supposedly
> needed, maybe it was at some point (it seems like all usage of this lock
> was introduced way back in 2015, commit 153b3d5b037ee).
> 
> For the series: Reviewed-by: Roland Scheidegger 

Series merged, thanks for taking a look.
-Daniel

> 
> Roland
> 
> Am 12.01.21 um 09:49 schrieb Daniel Vetter:
> > Hi Roland,
> > 
> > Hopefully you had a nice start into the new year! Ping for some
> > review/testing on this series.
> > 
> > Thanks, Daniel
> > 
> > On Fri, Dec 11, 2020 at 5:29 PM Daniel Vetter  
> > wrote:
> >>
> >> This isn't actually protecting anything becuase:
> >> - when running, ttm_resource_manager->use_type is protected through
> >>   vmw_private->reservation_semaphore against concurrent execbuf or
> >>   well anything else that might evict or reserve buffers
> >> - during suspend/resume there's nothing else running, hence
> >>   vmw_pm_freeze and vmw_pm_restore do not need to take the same lock.
> >> - this also holds for the SVGA_REG_ENABLE register write
> >>
> >> Hence it is safe to just remove that spinlock.
> >>
> >> Signed-off-by: Daniel Vetter 
> >> Cc: VMware Graphics 
> >> Cc: Roland Scheidegger 
> >> ---
> >>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 10 +-
> >>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  1 -
> >>  2 files changed, 1 insertion(+), 10 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> >> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> >> index 0008be02d31c..204f7a1830f0 100644
> >> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> >> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> >> @@ -672,7 +672,6 @@ static int vmw_driver_load(struct drm_device *dev, 
> >> unsigned long chipset)
> >> spin_lock_init(_priv->hw_lock);
> >> spin_lock_init(_priv->waiter_lock);
> >> spin_lock_init(_priv->cap_lock);
> >> -   spin_lock_init(_priv->svga_lock);
> >> spin_lock_init(_priv->cursor_lock);
> >>
> >> for (i = vmw_res_context; i < vmw_res_max; ++i) {
> >> @@ -1189,12 +1188,10 @@ static void __vmw_svga_enable(struct vmw_private 
> >> *dev_priv)
> >>  {
> >> struct ttm_resource_manager *man = 
> >> ttm_manager_type(_priv->bdev, TTM_PL_VRAM);
> >>
> >> -   spin_lock(_priv->svga_lock);
> >> if (!ttm_resource_manager_used(man)) {
> >> vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
> >> ttm_resource_manager_set_used(man, true);
> >> }
> >> -   spin_unlock(_priv->svga_lock);
> >>  }
> >>
> >>  /**
> >> @@ -1220,14 +1217,12 @@ static void __vmw_svga_disable(struct vmw_private 
> >> *dev_priv)
> >>  {
> >> struct ttm_resource_manager *man = 
> >> ttm_manager_type(_priv->bdev, TTM_PL_VRAM);
> >>
> >> -   spin_lock(_priv->svga_lock);
> >> if (ttm_resource_manager_used(man)) {
> >> ttm_resource_manager_set_used(man, false);
> >> vmw_write(dev_priv, SVGA_REG_ENABLE,
> >>   SVGA_REG_ENABLE_HIDE |
> >>   SVGA_REG_ENABLE_ENABLE);
> >> }
> >> -   spin_unlock(_priv->svga_lock);
> >>  }
> >>
> >>  /**
> >> @@ -1254,17 +1249,14 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
> >>  */
> >> vmw_kms_lost_device(dev_priv->dev);
> >> ttm_write_lock(_priv->reservation_sem, false);
> >> -   spin_lock(_priv->svga_lock);
> >> if (ttm_resource_manager_used(man)) {
> >> ttm_resource_manager_set_used(man, false);
> >> -   spin_unlock(_priv->svga_lock);
> >> if (ttm_resource_manager_evict_all(_priv->bdev, man))
> >> DRM_ERROR("Failed evicting VRAM buffers.\n");
> >> vmw_write(dev_priv, SVGA_REG_ENABLE,
> >>   SVGA_REG_ENABLE_HIDE |
> >>   SVGA_REG_ENABLE_ENABLE);
> >> -   } else
> >> -   spin_unlock(_priv->svga_lock);
> >> +   }
> >> ttm_write_unlock(_priv->reservation_sem);
> >>  }
> >>
> >> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
> >> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> >> index 5b9a28157dd3..715f2bfee08a 100644
> >> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> >> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> >> @@ -596,7 +596,6 @@ struct vmw_private {
> >>
> >> bool stealth;
> >> bool enable_fb;
> >> -   spinlock_t svga_lock;
> >>
> >> /**
> >>  * PM management.
> >> --
> >> 2.29.2
> >>
> > 
> > 
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 6/6] drm: Move struct drm_device.pdev to legacy section

2021-01-18 Thread Thomas Zimmermann
Struct drm_device.pdev is being moved to legacy status as only legacy
DRM drivers use it. A possible follow-up patchset could remove pdev
entirely.

v4:
* rebased

Signed-off-by: Thomas Zimmermann 
Acked-by: Sam Ravnborg 
---
 include/drm/drm_device.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index d647223e8390..c5a195676e8f 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -279,9 +279,6 @@ struct drm_device {
/** @agp: AGP data */
struct drm_agp_head *agp;
 
-   /** @pdev: PCI device structure */
-   struct pci_dev *pdev;
-
/** @num_crtcs: Number of CRTCs on this device */
unsigned int num_crtcs;
 
@@ -324,6 +321,9 @@ struct drm_device {
/* List of devices per driver for stealth attach cleanup */
struct list_head legacy_dev_list;
 
+   /* PCI device structure */
+   struct pci_dev *pdev;
+
 #ifdef __alpha__
/** @hose: PCI hose, only used on ALPHA platforms. */
struct pci_controller *hose;
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 4/6] drm/i915/gvt: Remove references to struct drm_device.pdev

2021-01-18 Thread Thomas Zimmermann
Using struct drm_device.pdev is deprecated. Convert i915 to struct
drm_device.dev. No functional changes.

Signed-off-by: Thomas Zimmermann 
Cc: Jani Nikula 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
---
 drivers/gpu/drm/i915/gvt/cfg_space.c |  5 +++--
 drivers/gpu/drm/i915/gvt/firmware.c  | 10 +-
 drivers/gpu/drm/i915/gvt/gtt.c   | 12 ++--
 drivers/gpu/drm/i915/gvt/gvt.c   |  6 +++---
 drivers/gpu/drm/i915/gvt/kvmgt.c |  4 ++--
 5 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/cfg_space.c 
b/drivers/gpu/drm/i915/gvt/cfg_space.c
index ad86c5eb5bba..b490e3db2e38 100644
--- a/drivers/gpu/drm/i915/gvt/cfg_space.c
+++ b/drivers/gpu/drm/i915/gvt/cfg_space.c
@@ -374,6 +374,7 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
   bool primary)
 {
struct intel_gvt *gvt = vgpu->gvt;
+   struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev);
const struct intel_gvt_device_info *info = >device_info;
u16 *gmch_ctl;
u8 next;
@@ -407,9 +408,9 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
memset(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_OPREGION, 0, 4);
 
vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_GTTMMIO].size =
-   pci_resource_len(gvt->gt->i915->drm.pdev, 0);
+   pci_resource_len(pdev, 0);
vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_APERTURE].size =
-   pci_resource_len(gvt->gt->i915->drm.pdev, 2);
+   pci_resource_len(pdev, 2);
 
memset(vgpu_cfg_space(vgpu) + PCI_ROM_ADDRESS, 0, 4);
 
diff --git a/drivers/gpu/drm/i915/gvt/firmware.c 
b/drivers/gpu/drm/i915/gvt/firmware.c
index 990a181094e3..1a8274a3f4b1 100644
--- a/drivers/gpu/drm/i915/gvt/firmware.c
+++ b/drivers/gpu/drm/i915/gvt/firmware.c
@@ -76,7 +76,7 @@ static int mmio_snapshot_handler(struct intel_gvt *gvt, u32 
offset, void *data)
 static int expose_firmware_sysfs(struct intel_gvt *gvt)
 {
struct intel_gvt_device_info *info = >device_info;
-   struct pci_dev *pdev = gvt->gt->i915->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev);
struct gvt_firmware_header *h;
void *firmware;
void *p;
@@ -127,7 +127,7 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt)
 
 static void clean_firmware_sysfs(struct intel_gvt *gvt)
 {
-   struct pci_dev *pdev = gvt->gt->i915->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev);
 
device_remove_bin_file(>dev, _attr);
vfree(firmware_attr.private);
@@ -151,7 +151,7 @@ static int verify_firmware(struct intel_gvt *gvt,
   const struct firmware *fw)
 {
struct intel_gvt_device_info *info = >device_info;
-   struct pci_dev *pdev = gvt->gt->i915->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev);
struct gvt_firmware_header *h;
unsigned long id, crc32_start;
const void *mem;
@@ -205,7 +205,7 @@ static int verify_firmware(struct intel_gvt *gvt,
 int intel_gvt_load_firmware(struct intel_gvt *gvt)
 {
struct intel_gvt_device_info *info = >device_info;
-   struct pci_dev *pdev = gvt->gt->i915->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev);
struct intel_gvt_firmware *firmware = >firmware;
struct gvt_firmware_header *h;
const struct firmware *fw;
@@ -240,7 +240,7 @@ int intel_gvt_load_firmware(struct intel_gvt *gvt)
 
gvt_dbg_core("request hw state firmware %s...\n", path);
 
-   ret = request_firmware(, path, >gt->i915->drm.pdev->dev);
+   ret = request_firmware(, path, gvt->gt->i915->drm.dev);
kfree(path);
 
if (ret)
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
index 897c007ea96a..6d12a5a401f6 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -746,7 +746,7 @@ static int detach_oos_page(struct intel_vgpu *vgpu,
 
 static void ppgtt_free_spt(struct intel_vgpu_ppgtt_spt *spt)
 {
-   struct device *kdev = >vgpu->gvt->gt->i915->drm.pdev->dev;
+   struct device *kdev = spt->vgpu->gvt->gt->i915->drm.dev;
 
trace_spt_free(spt->vgpu->id, spt, spt->guest_page.type);
 
@@ -831,7 +831,7 @@ static int reclaim_one_ppgtt_mm(struct intel_gvt *gvt);
 static struct intel_vgpu_ppgtt_spt *ppgtt_alloc_spt(
struct intel_vgpu *vgpu, enum intel_gvt_gtt_type type)
 {
-   struct device *kdev = >gvt->gt->i915->drm.pdev->dev;
+   struct device *kdev = vgpu->gvt->gt->i915->drm.dev;
struct intel_vgpu_ppgtt_spt *spt = NULL;
dma_addr_t daddr;
int ret;
@@ -2402,7 +2402,7 @@ static int alloc_scratch_pages(struct intel_vgpu *vgpu,
vgpu->gvt->device_info.gtt_entry_size_shift;
void *scratch_pt;
int i;
-   struct device *dev = >gvt->gt->i915->drm.pdev->dev;
+   struct device *dev = 

[PATCH v4 5/6] drm/vmwgfx: Remove reference to struct drm_device.pdev

2021-01-18 Thread Thomas Zimmermann
Using struct drm_device.pdev is deprecated in favor of drm_device.dev.
The reference to the field was reintroduced during a rebase.

Signed-off-by: Thomas Zimmermann 
Fixes: 9703bb329206 ("drm/vmwgfx: Switch to a managed drm device")
Cc: Zack Rusin 
Cc: Martin Krastev 
Cc: Roland Scheidegger 
Cc: VMware Graphics 
Cc: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 8c3eb00e8b54..545b83e338fc 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1524,7 +1524,6 @@ static int vmw_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (IS_ERR(vmw))
return PTR_ERR(vmw);
 
-   vmw->drm.pdev = pdev;
pci_set_drvdata(pdev, >drm);
 
ret = vmw_driver_load(vmw, ent->device);
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 2/6] drm/i915: Remove references to struct drm_device.pdev

2021-01-18 Thread Thomas Zimmermann
Using struct drm_device.pdev is deprecated. Convert i915 to struct
drm_device.dev. No functional changes.

v3:
* rebased
v2:
* move gt/ and gvt/ changes into separate patches

Signed-off-by: Thomas Zimmermann 
Cc: Jani Nikula 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
---
 drivers/gpu/drm/i915/display/intel_bios.c |  2 +-
 drivers/gpu/drm/i915/display/intel_cdclk.c| 14 ++---
 drivers/gpu/drm/i915/display/intel_csr.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_dsi_vbt.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  2 +-
 drivers/gpu/drm/i915/display/intel_gmbus.c|  2 +-
 .../gpu/drm/i915/display/intel_lpe_audio.c|  5 +++--
 drivers/gpu/drm/i915/display/intel_opregion.c |  6 +++---
 drivers/gpu/drm/i915/display/intel_overlay.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_panel.c|  4 ++--
 drivers/gpu/drm/i915/display/intel_quirks.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_sdvo.c |  2 +-
 drivers/gpu/drm/i915/display/intel_vga.c  |  8 
 drivers/gpu/drm/i915/gem/i915_gem_phys.c  |  6 +++---
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c |  2 +-
 drivers/gpu/drm/i915/gt/intel_region_lmem.c   |  8 
 drivers/gpu/drm/i915/i915_debugfs.c   |  2 +-
 drivers/gpu/drm/i915/i915_drv.c   | 20 +--
 drivers/gpu/drm/i915/i915_drv.h   |  2 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c   |  5 ++---
 drivers/gpu/drm/i915/i915_getparam.c  |  5 +++--
 drivers/gpu/drm/i915/i915_gpu_error.c |  2 +-
 drivers/gpu/drm/i915/i915_irq.c   |  6 +++---
 drivers/gpu/drm/i915/i915_pmu.c   |  2 +-
 drivers/gpu/drm/i915/i915_suspend.c   |  4 ++--
 drivers/gpu/drm/i915/i915_switcheroo.c|  4 ++--
 drivers/gpu/drm/i915/i915_vgpu.c  |  2 +-
 drivers/gpu/drm/i915/intel_device_info.c  |  2 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c   |  2 +-
 drivers/gpu/drm/i915/intel_uncore.c   |  4 ++--
 .../gpu/drm/i915/selftests/mock_gem_device.c  |  1 -
 drivers/gpu/drm/i915/selftests/mock_gtt.c |  2 +-
 32 files changed, 66 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c 
b/drivers/gpu/drm/i915/display/intel_bios.c
index 987cf509337f..19b8bf0b8aa2 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -2098,7 +2098,7 @@ bool intel_bios_is_valid_vbt(const void *buf, size_t size)
 
 static struct vbt_header *oprom_get_vbt(struct drm_i915_private *dev_priv)
 {
-   struct pci_dev *pdev = dev_priv->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
void __iomem *p = NULL, *oprom;
struct vbt_header *vbt;
u16 vbt_size;
diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.c 
b/drivers/gpu/drm/i915/display/intel_cdclk.c
index 2e878cc274b7..bf83e9e75227 100644
--- a/drivers/gpu/drm/i915/display/intel_cdclk.c
+++ b/drivers/gpu/drm/i915/display/intel_cdclk.c
@@ -96,7 +96,7 @@ static void fixed_450mhz_get_cdclk(struct drm_i915_private 
*dev_priv,
 static void i85x_get_cdclk(struct drm_i915_private *dev_priv,
   struct intel_cdclk_config *cdclk_config)
 {
-   struct pci_dev *pdev = dev_priv->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
u16 hpllcc = 0;
 
/*
@@ -138,7 +138,7 @@ static void i85x_get_cdclk(struct drm_i915_private 
*dev_priv,
 static void i915gm_get_cdclk(struct drm_i915_private *dev_priv,
 struct intel_cdclk_config *cdclk_config)
 {
-   struct pci_dev *pdev = dev_priv->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
u16 gcfgc = 0;
 
pci_read_config_word(pdev, GCFGC, );
@@ -162,7 +162,7 @@ static void i915gm_get_cdclk(struct drm_i915_private 
*dev_priv,
 static void i945gm_get_cdclk(struct drm_i915_private *dev_priv,
 struct intel_cdclk_config *cdclk_config)
 {
-   struct pci_dev *pdev = dev_priv->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
u16 gcfgc = 0;
 
pci_read_config_word(pdev, GCFGC, );
@@ -256,7 +256,7 @@ static unsigned int intel_hpll_vco(struct drm_i915_private 
*dev_priv)
 static void g33_get_cdclk(struct drm_i915_private *dev_priv,
  struct intel_cdclk_config *cdclk_config)
 {
-   struct pci_dev *pdev = dev_priv->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
static const u8 div_3200[] = { 12, 10,  8,  7, 5, 16 };
static const u8 div_4000[] = { 14, 12, 10,  8, 6, 20 };
static const u8 div_4800[] = { 20, 14, 12, 10, 8, 24 };
@@ -305,7 +305,7 @@ static void g33_get_cdclk(struct drm_i915_private *dev_priv,
 static void pnv_get_cdclk(struct drm_i915_private *dev_priv,
  struct intel_cdclk_config *cdclk_config)
 {
-   struct pci_dev *pdev = dev_priv->drm.pdev;
+   

[PATCH v4 3/6] drm/i915/gt: Remove references to struct drm_device.pdev

2021-01-18 Thread Thomas Zimmermann
Using struct drm_device.pdev is deprecated. Convert i915 to struct
drm_device.dev. No functional changes.

Signed-off-by: Thomas Zimmermann 
Cc: Jani Nikula 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c |  2 +-
 drivers/gpu/drm/i915/gt/intel_ggtt.c  | 10 +-
 drivers/gpu/drm/i915/gt/intel_ppgtt.c |  2 +-
 drivers/gpu/drm/i915/gt/intel_rc6.c   |  4 ++--
 drivers/gpu/drm/i915/gt/intel_reset.c |  6 +++---
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c 
b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index fb1b1d096975..376e82e17061 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -1269,7 +1269,7 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine)
 
/* Waiting to drain ELSP? */
if (execlists_active(>execlists)) {
-   synchronize_hardirq(engine->i915->drm.pdev->irq);
+   synchronize_hardirq(to_pci_dev(engine->i915->drm.dev)->irq);
 
intel_engine_flush_submission(engine);
 
diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c 
b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index eece0844fbe9..fd6c8fa54812 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -769,7 +769,7 @@ static unsigned int chv_get_total_gtt_size(u16 gmch_ctrl)
 static int ggtt_probe_common(struct i915_ggtt *ggtt, u64 size)
 {
struct drm_i915_private *i915 = ggtt->vm.i915;
-   struct pci_dev *pdev = i915->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
phys_addr_t phys_addr;
int ret;
 
@@ -839,7 +839,7 @@ static struct resource pci_resource(struct pci_dev *pdev, 
int bar)
 static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 {
struct drm_i915_private *i915 = ggtt->vm.i915;
-   struct pci_dev *pdev = i915->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
unsigned int size;
u16 snb_gmch_ctl;
 
@@ -983,7 +983,7 @@ static u64 iris_pte_encode(dma_addr_t addr,
 static int gen6_gmch_probe(struct i915_ggtt *ggtt)
 {
struct drm_i915_private *i915 = ggtt->vm.i915;
-   struct pci_dev *pdev = i915->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
unsigned int size;
u16 snb_gmch_ctl;
 
@@ -1046,7 +1046,7 @@ static int i915_gmch_probe(struct i915_ggtt *ggtt)
phys_addr_t gmadr_base;
int ret;
 
-   ret = intel_gmch_probe(i915->bridge_dev, i915->drm.pdev, NULL);
+   ret = intel_gmch_probe(i915->bridge_dev, to_pci_dev(i915->drm.dev), 
NULL);
if (!ret) {
drm_err(>drm, "failed to set up gmch\n");
return -EIO;
@@ -1091,7 +1091,7 @@ static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct 
intel_gt *gt)
 
ggtt->vm.gt = gt;
ggtt->vm.i915 = i915;
-   ggtt->vm.dma = >drm.pdev->dev;
+   ggtt->vm.dma = i915->drm.dev;
 
if (INTEL_GEN(i915) <= 5)
ret = i915_gmch_probe(ggtt);
diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c 
b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
index 96b85a10ef33..3f940ae27028 100644
--- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
@@ -301,7 +301,7 @@ void ppgtt_init(struct i915_ppgtt *ppgtt, struct intel_gt 
*gt)
 
ppgtt->vm.gt = gt;
ppgtt->vm.i915 = i915;
-   ppgtt->vm.dma = >drm.pdev->dev;
+   ppgtt->vm.dma = i915->drm.dev;
ppgtt->vm.total = BIT_ULL(INTEL_INFO(i915)->ppgtt_size);
 
i915_address_space_init(>vm, VM_CLASS_PPGTT);
diff --git a/drivers/gpu/drm/i915/gt/intel_rc6.c 
b/drivers/gpu/drm/i915/gt/intel_rc6.c
index 35504c97f11d..9843e1d4327f 100644
--- a/drivers/gpu/drm/i915/gt/intel_rc6.c
+++ b/drivers/gpu/drm/i915/gt/intel_rc6.c
@@ -485,14 +485,14 @@ static bool rc6_supported(struct intel_rc6 *rc6)
 static void rpm_get(struct intel_rc6 *rc6)
 {
GEM_BUG_ON(rc6->wakeref);
-   pm_runtime_get_sync(_to_i915(rc6)->drm.pdev->dev);
+   pm_runtime_get_sync(rc6_to_i915(rc6)->drm.dev);
rc6->wakeref = true;
 }
 
 static void rpm_put(struct intel_rc6 *rc6)
 {
GEM_BUG_ON(!rc6->wakeref);
-   pm_runtime_put(_to_i915(rc6)->drm.pdev->dev);
+   pm_runtime_put(rc6_to_i915(rc6)->drm.dev);
rc6->wakeref = false;
 }
 
diff --git a/drivers/gpu/drm/i915/gt/intel_reset.c 
b/drivers/gpu/drm/i915/gt/intel_reset.c
index 61410cd62927..afe0342dcd47 100644
--- a/drivers/gpu/drm/i915/gt/intel_reset.c
+++ b/drivers/gpu/drm/i915/gt/intel_reset.c
@@ -178,7 +178,7 @@ static int i915_do_reset(struct intel_gt *gt,
 intel_engine_mask_t engine_mask,
 unsigned int retry)
 {
-   struct pci_dev *pdev = gt->i915->drm.pdev;
+   struct pci_dev *pdev = to_pci_dev(gt->i915->drm.dev);
int err;
 
/* Assert reset for at least 20 usec, and wait for acknowledgement. */
@@ -207,7 

[PATCH v4 1/6] drm: Upcast struct drm_device.dev to struct pci_device; replace pdev

2021-01-18 Thread Thomas Zimmermann
We have DRM drivers based on USB, SPI and platform devices. All of them
are fine with storing their device reference in struct drm_device.dev.
PCI devices should be no exception. Therefore struct drm_device.pdev is
deprecated.

Instead upcast from struct drm_device.dev with to_pci_dev(). PCI-specific
code can use dev_is_pci() to test for a PCI device. This patch changes
the DRM core code and documentation accordingly.

v4:
* split-off pdev deprecation into separate patch

Signed-off-by: Thomas Zimmermann 
Tested-by: Andy Lavr 
Acked-by: Sam Ravnborg 
---
 drivers/gpu/drm/drm_agpsupport.c |  9 ++---
 drivers/gpu/drm/drm_bufs.c   |  4 ++--
 drivers/gpu/drm/drm_edid.c   |  7 ++-
 drivers/gpu/drm/drm_irq.c| 12 +++-
 drivers/gpu/drm/drm_pci.c| 26 +++---
 drivers/gpu/drm/drm_vm.c |  2 +-
 6 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 8b690ef306de..7e765cb0efee 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -103,11 +103,13 @@ int drm_agp_info_ioctl(struct drm_device *dev, void *data,
  */
 int drm_agp_acquire(struct drm_device *dev)
 {
+   struct pci_dev *pdev = to_pci_dev(dev->dev);
+
if (!dev->agp)
return -ENODEV;
if (dev->agp->acquired)
return -EBUSY;
-   dev->agp->bridge = agp_backend_acquire(dev->pdev);
+   dev->agp->bridge = agp_backend_acquire(pdev);
if (!dev->agp->bridge)
return -ENODEV;
dev->agp->acquired = 1;
@@ -402,14 +404,15 @@ int drm_agp_free_ioctl(struct drm_device *dev, void *data,
  */
 struct drm_agp_head *drm_agp_init(struct drm_device *dev)
 {
+   struct pci_dev *pdev = to_pci_dev(dev->dev);
struct drm_agp_head *head = NULL;
 
head = kzalloc(sizeof(*head), GFP_KERNEL);
if (!head)
return NULL;
-   head->bridge = agp_find_bridge(dev->pdev);
+   head->bridge = agp_find_bridge(pdev);
if (!head->bridge) {
-   head->bridge = agp_backend_acquire(dev->pdev);
+   head->bridge = agp_backend_acquire(pdev);
if (!head->bridge) {
kfree(head);
return NULL;
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index aeb1327e3077..e3d77dfefb0a 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -326,7 +326,7 @@ static int drm_addmap_core(struct drm_device *dev, 
resource_size_t offset,
 * As we're limiting the address to 2^32-1 (or less),
 * casting it down to 32 bits is no problem, but we
 * need to point to a 64bit variable first. */
-   map->handle = dma_alloc_coherent(>pdev->dev,
+   map->handle = dma_alloc_coherent(dev->dev,
 map->size,
 >offset,
 GFP_KERNEL);
@@ -556,7 +556,7 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, struct 
drm_local_map *map)
case _DRM_SCATTER_GATHER:
break;
case _DRM_CONSISTENT:
-   dma_free_coherent(>pdev->dev,
+   dma_free_coherent(dev->dev,
  map->size,
  map->handle,
  map->offset);
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 394cc55b3214..c2bbe7bee7b6 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -2075,9 +2076,13 @@ EXPORT_SYMBOL(drm_get_edid);
 struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
 struct i2c_adapter *adapter)
 {
-   struct pci_dev *pdev = connector->dev->pdev;
+   struct drm_device *dev = connector->dev;
+   struct pci_dev *pdev = to_pci_dev(dev->dev);
struct edid *edid;
 
+   if (drm_WARN_ON_ONCE(dev, !dev_is_pci(dev->dev)))
+   return NULL;
+
vga_switcheroo_lock_ddc(pdev);
edid = drm_get_edid(connector, adapter);
vga_switcheroo_unlock_ddc(pdev);
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 803af4bbd214..c3bd664ea733 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -122,7 +122,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
dev->driver->irq_preinstall(dev);
 
/* PCI devices require shared interrupts. */
-   if (dev->pdev)
+   if (dev_is_pci(dev->dev))
sh_flags = IRQF_SHARED;
 
ret = request_irq(irq, dev->driver->irq_handler,
@@ -140,7 +140,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
if (ret < 0) {

[PATCH v4 0/6] drm: Move struct drm_device.pdev to legacy

2021-01-18 Thread Thomas Zimmermann
I merged more patches into drm-misc-next. I'm mostly sending out v4 of
this patchset to split the final patch into the core changes and the
patch for moving pdev behind CONFIG_DRM_LEGACY. The former are required
to fix a reported bug. [1] There's also a fix to vmwgfx.

The pdev field in struct drm_device points to a PCI device structure and
goes back to UMS-only days when all DRM drivers were for PCI devices.
Meanwhile we also support USB, SPI and platform devices. Each of those
uses the generic device stored in struct drm_device.dev.

To reduce duplication and remove the special case of PCI, this patchset
converts all modesetting drivers from pdev to dev and makes pdev a field
for legacy UMS drivers.

For PCI devices, the pointer in struct drm_device.dev can be upcasted to
struct pci_device; or tested for PCI with dev_is_pci(). In several places
the code can use the dev field directly.

After converting all drivers and the DRM core, the pdev fields becomes
only relevant for legacy drivers. In a later patchset, we may want to
convert these as well and remove pdev entirely.

v4:
* merged several patches
* moved core changes into separate patch
* vmwgfx build fix
v3:
* merged several patches
* fix one pdev reference in nouveau (Jeremy)
* rebases
v2:
* move whitespace fixes into separate patches (Alex, Sam)
* move i915 gt/ and gvt/ changes into separate patches (Joonas)

[1] 
https://lore.kernel.org/dri-devel/7851c78c-8c57-3c84-cd49-a72703095...@suse.de/

Thomas Zimmermann (6):
  drm: Upcast struct drm_device.dev to struct pci_device; replace pdev
  drm/i915: Remove references to struct drm_device.pdev
  drm/i915/gt: Remove references to struct drm_device.pdev
  drm/i915/gvt: Remove references to struct drm_device.pdev
  drm/vmwgfx: Remove reference to struct drm_device.pdev
  drm: Move struct drm_device.pdev to legacy section

 drivers/gpu/drm/drm_agpsupport.c  |  9 ---
 drivers/gpu/drm/drm_bufs.c|  4 +--
 drivers/gpu/drm/drm_edid.c|  7 -
 drivers/gpu/drm/drm_irq.c | 12 +
 drivers/gpu/drm/drm_pci.c | 26 +++
 drivers/gpu/drm/drm_vm.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_bios.c |  2 +-
 drivers/gpu/drm/i915/display/intel_cdclk.c| 14 +-
 drivers/gpu/drm/i915/display/intel_csr.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_dsi_vbt.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  2 +-
 drivers/gpu/drm/i915/display/intel_gmbus.c|  2 +-
 .../gpu/drm/i915/display/intel_lpe_audio.c|  5 ++--
 drivers/gpu/drm/i915/display/intel_opregion.c |  6 ++---
 drivers/gpu/drm/i915/display/intel_overlay.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_panel.c|  4 +--
 drivers/gpu/drm/i915/display/intel_quirks.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_sdvo.c |  2 +-
 drivers/gpu/drm/i915/display/intel_vga.c  |  8 +++---
 drivers/gpu/drm/i915/gem/i915_gem_phys.c  |  6 ++---
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c |  2 +-
 drivers/gpu/drm/i915/gt/intel_engine_cs.c |  2 +-
 drivers/gpu/drm/i915/gt/intel_ggtt.c  | 10 +++
 drivers/gpu/drm/i915/gt/intel_ppgtt.c |  2 +-
 drivers/gpu/drm/i915/gt/intel_rc6.c   |  4 +--
 drivers/gpu/drm/i915/gt/intel_region_lmem.c   |  8 +++---
 drivers/gpu/drm/i915/gt/intel_reset.c |  6 ++---
 drivers/gpu/drm/i915/gvt/cfg_space.c  |  5 ++--
 drivers/gpu/drm/i915/gvt/firmware.c   | 10 +++
 drivers/gpu/drm/i915/gvt/gtt.c| 12 -
 drivers/gpu/drm/i915/gvt/gvt.c|  6 ++---
 drivers/gpu/drm/i915/gvt/kvmgt.c  |  4 +--
 drivers/gpu/drm/i915/i915_debugfs.c   |  2 +-
 drivers/gpu/drm/i915/i915_drv.c   | 20 +++---
 drivers/gpu/drm/i915/i915_drv.h   |  2 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c   |  5 ++--
 drivers/gpu/drm/i915/i915_getparam.c  |  5 ++--
 drivers/gpu/drm/i915/i915_gpu_error.c |  2 +-
 drivers/gpu/drm/i915/i915_irq.c   |  6 ++---
 drivers/gpu/drm/i915/i915_pmu.c   |  2 +-
 drivers/gpu/drm/i915/i915_suspend.c   |  4 +--
 drivers/gpu/drm/i915/i915_switcheroo.c|  4 +--
 drivers/gpu/drm/i915/i915_vgpu.c  |  2 +-
 drivers/gpu/drm/i915/intel_device_info.c  |  2 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c   |  2 +-
 drivers/gpu/drm/i915/intel_uncore.c   |  4 +--
 .../gpu/drm/i915/selftests/mock_gem_device.c  |  1 -
 drivers/gpu/drm/i915/selftests/mock_gtt.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |  1 -
 include/drm/drm_device.h  |  6 ++---
 50 files changed, 137 insertions(+), 125 deletions(-)

--
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org

Re: [PATCH 2/3] drm/ingenic: Register devm action to cleanup encoders

2021-01-18 Thread Daniel Vetter
On Mon, Jan 18, 2021 at 11:37:49AM +, Paul Cercueil wrote:
> Hi Laurent,
> 
> Le lun. 18 janv. 2021 à 11:43, Laurent Pinchart
>  a écrit :
> > Hi Paul,
> > 
> > Thank you for the patch.
> > 
> > On Sun, Jan 17, 2021 at 11:26:45AM +, Paul Cercueil wrote:
> > >  Since the encoders have been devm-allocated, they will be freed way
> > >  before drm_mode_config_cleanup() is called. To avoid use-after-free
> > >  conditions, we then must ensure that drm_encoder_cleanup() is called
> > >  before the encoders are freed.
> > 
> > How about allocating the encoder with drmm_encoder_alloc() instead ?
> 
> That would work, but it is not yet in drm-misc-fixes :(

Well I think then we should only fix this in drm-misc-next. Adding more
broken usage of devm_ isn't really a good idea.

If you want this in -fixes, then I think hand-roll it. But devm_ for drm
objects really is the wrong fix.
-Daniel

> 
> -Paul
> 
> > >  Fixes: c369cb27c267 ("drm/ingenic: Support multiple panels/bridges")
> > >  Cc:  # 5.8+
> > >  Signed-off-by: Paul Cercueil 
> > >  ---
> > >   drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 10 ++
> > >   1 file changed, 10 insertions(+)
> > > 
> > >  diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> > > b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> > >  index 368bfef8b340..d23a3292a0e0 100644
> > >  --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> > >  +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> > >  @@ -803,6 +803,11 @@ static void __maybe_unused
> > > ingenic_drm_release_rmem(void *d)
> > >   of_reserved_mem_device_release(d);
> > >   }
> > > 
> > >  +static void ingenic_drm_encoder_cleanup(void *encoder)
> > >  +{
> > >  +drm_encoder_cleanup(encoder);
> > >  +}
> > >  +
> > >   static int ingenic_drm_bind(struct device *dev, bool
> > > has_components)
> > >   {
> > >   struct platform_device *pdev = to_platform_device(dev);
> > >  @@ -1011,6 +1016,11 @@ static int ingenic_drm_bind(struct device
> > > *dev, bool has_components)
> > >   return ret;
> > >   }
> > > 
> > >  +ret = devm_add_action_or_reset(dev, 
> > > ingenic_drm_encoder_cleanup,
> > >  +   encoder);
> > >  +if (ret)
> > >  +return ret;
> > >  +
> > >   ret = drm_bridge_attach(encoder, bridge, NULL, 0);
> > >   if (ret) {
> > >   dev_err(dev, "Unable to attach bridge\n");
> > 
> > --
> > Regards,
> > 
> > Laurent Pinchart
> 
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/panel: panel-simple: add bus-format and connector-type to Innolux n116bge

2021-01-18 Thread Heiko Stuebner
On Sat, 9 Jan 2021 14:09:51 +0100, Heiko Stuebner wrote:
> The Innolux n116bge panel has an eDP connector and 3*6 bits bus format.

Applied, thanks!

[1/1] drm/panel: panel-simple: add bus-format and connector-type to Innolux 
n116bge
  commit: 87969bcd49480508568070fd93d7367f03316aa9

Best regards,
-- 
Heiko Stuebner 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH RFC] drm/vc4: hdmi: Avoid ASoC error messages on startup

2021-01-18 Thread Stefan Wahren
Hi,

Am 15.01.21 um 19:39 schrieb Mark Brown:
> On Fri, Jan 15, 2021 at 07:14:37PM +0100, Maxime Ripard wrote:
>> On Wed, Jan 13, 2021 at 11:42:23AM +, Mark Brown wrote:
>>> On Wed, Jan 13, 2021 at 10:19:57AM +0100, Maxime Ripard wrote:
 I'd like to get Mark's opinion before merging though
>>> I'm not sure what the question is here?  I get CCed on a bunch of not
>>> obviously relevant DRM patches so there's a good chance I've just
>>> deleted some relevnat discussion.
>> The patch is question is here:
>> https://lore.kernel.org/dri-devel/1609256210-19863-1-git-send-email-stefan.wah...@i2se.com/
>> In particular, I'm not so sure whether it's fine to return -EPROBE_DEFER
>> in the startup hook.
> I wouldn't expect that to do anything useful and IIRC that error code
> will end up in userspace which isn't good.  If the driver wants to defer
> probe it should defer it from the probe() routine, after the driver has
> been instantiated I'm not sure what the expectation would be.  In
> general a driver should acquire all resources it needs when probing.

understand. Unfortunately, currently i don't have the time to
investigate how we can achieve this with this drm driver.

Maybe some else can take over?

Regards
Stefan

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] vgaarb: Remove unneeded semicolons

2021-01-18 Thread Daniel Vetter
On Mon, Jan 18, 2021 at 01:03:55AM +, Yue Zou wrote:
> Remove superfluous semicolons after function definitions.
> 
> Signed-off-by: Yue Zou 

Thanks for your patch, applied.
-Daniel

> ---
>  include/linux/vgaarb.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
> index 977caf96c8d2..fc6dfeba04a5 100644
> --- a/include/linux/vgaarb.h
> +++ b/include/linux/vgaarb.h
> @@ -121,9 +121,9 @@ extern struct pci_dev *vga_default_device(void);
>  extern void vga_set_default_device(struct pci_dev *pdev);
>  extern int vga_remove_vgacon(struct pci_dev *pdev);
>  #else
> -static inline struct pci_dev *vga_default_device(void) { return NULL; };
> -static inline void vga_set_default_device(struct pci_dev *pdev) { };
> -static inline int vga_remove_vgacon(struct pci_dev *pdev) { return 0; };
> +static inline struct pci_dev *vga_default_device(void) { return NULL; }
> +static inline void vga_set_default_device(struct pci_dev *pdev) { }
> +static inline int vga_remove_vgacon(struct pci_dev *pdev) { return 0; }
>  #endif
>  
>  /*
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 00/29] [Set 15] Finally rid W=1 warnings from GPU!

2021-01-18 Thread Daniel Vetter
On Fri, Jan 15, 2021 at 06:27:15PM +, Zack Rusin wrote:
> 
> > On Jan 15, 2021, at 13:15, Lee Jones  wrote:
> > 
> > This set is part of a larger effort attempting to clean-up W=1
> > kernel builds, which are currently overwhelmingly riddled with
> > niggly little warnings.
> > 
> > Last set!  All clean after this for; Arm, Arm64, PPC, MIPS and x86.
> 
> Thanks! For all the vmwgfx bits:
> Reviewed-by: Zack Rusin 

Can you pls push them to drm-misc-next? I'm planning to go pull in all the
other patches later today that belong into drm-misc-next, but some patch
monkey help would be really great :-)

Thanks, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v5 1/2] drm/doc: fix drm_plane_type docs

2021-01-18 Thread Daniel Vetter
On Mon, Jan 18, 2021 at 10:40:52AM +0200, Pekka Paalanen wrote:
> On Fri, 15 Jan 2021 12:06:25 +0100
> Simon Ser  wrote:
> 
> > The docs for enum drm_plane_type mention legacy IOCTLs, however the
> > plane type is not tied to legacy IOCTLs, the drm_cursor.primary and
> > cursor fields are. Add a small paragraph to reference these.
> > 
> > Instead, document expectations for primary and cursor planes for
> > non-legacy userspace. Note that these docs are for driver developers,
> > not userspace developers, so internal kernel APIs are mentionned.
> > 
> > Signed-off-by: Simon Ser 
> > Reviewed-by: Daniel Vetter 
> > Cc: Pekka Paalanen 
> > ---
> >  include/drm/drm_plane.h | 21 +
> >  1 file changed, 13 insertions(+), 8 deletions(-)
> > 
> > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > index 8ef06ee1c8eb..95ab14a4336a 100644
> > --- a/include/drm/drm_plane.h
> > +++ b/include/drm/drm_plane.h
> > @@ -538,10 +538,14 @@ struct drm_plane_funcs {
> >   *
> >   * For compatibility with legacy userspace, only overlay planes are made
> >   * available to userspace by default. Userspace clients may set the
> > - * DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that 
> > they
> > + * _CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that 
> > they
> >   * wish to receive a universal plane list containing all plane types. See 
> > also
> >   * drm_for_each_legacy_plane().
> >   *
> > + * In addition to setting each plane's type, drivers need to setup the
> > + * _crtc.primary and optionally _crtc.cursor pointers for legacy
> > + * IOCTLs. See drm_crtc_init_with_planes().
> > + *
> >   * WARNING: The values of this enum is UABI since they're exposed in the 
> > "type"
> >   * property.
> >   */
> > @@ -557,19 +561,20 @@ enum drm_plane_type {
> > /**
> >  * @DRM_PLANE_TYPE_PRIMARY:
> >  *
> > -* Primary planes represent a "main" plane for a CRTC.  Primary planes
> > -* are the planes operated upon by CRTC modesetting and flipping
> > -* operations described in the _crtc_funcs.page_flip and
> > -* _crtc_funcs.set_config hooks.
> > +* A primary plane attached to a CRTC is the most likely to be able to
> > +* light up the CRTC when no scaling/cropping is used and the plane
> > +* covers the whole CRTC.
> >  */
> > DRM_PLANE_TYPE_PRIMARY,
> >  
> > /**
> >  * @DRM_PLANE_TYPE_CURSOR:
> >  *
> > -* Cursor planes represent a "cursor" plane for a CRTC.  Cursor planes
> > -* are the planes operated upon by the DRM_IOCTL_MODE_CURSOR and
> > -* DRM_IOCTL_MODE_CURSOR2 IOCTLs.
> > +* A cursor plane attached to a CRTC is more likely to be able to be
> > +* enabled when no scaling/cropping is used and the framebuffer has the
> > +* size indicated by _mode_config.cursor_width and
> > +* _mode_config.cursor_height. Additionally, if the driver doesn't
> > +* support modifiers, the framebuffer should have a linear layout.
> 
> Hi,
> 
> is there anything to be said about positioning a cursor plane partially
> off-screen?

It should work, like anything partially off-screen placed plane. But
there's two issues:
- you might run into hw limitations (and uh there's even hw where this
  holds for the cursor plane, specifically cursor on 3rd crtc on
  cherrytrail i915 is broken and we can't do some of the placements you'd
  want from a cursor because the display block would die).
- there's still a bunch of drivers which don't even clip correctly :-/

Iow, it's a bit a mess ...
-Daniel

> 
> >  */
> > DRM_PLANE_TYPE_CURSOR,
> >  };
> 
> Anyway,
> Acked-by: Pekka Paalanen 
> 
> 
> Thanks,
> pq



-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/3] drm: bridge/panel: Cleanup connector on bridge detach

2021-01-18 Thread Laurent Pinchart
Hi Paul,

Thank you for the patch.

On Sun, Jan 17, 2021 at 11:26:44AM +, Paul Cercueil wrote:
> If we don't call drm_connector_cleanup() manually in
> panel_bridge_detach(), the connector will be cleaned up with the other
> DRM objects in the call to drm_mode_config_cleanup(). However, since our
> drm_connector is devm-allocated, by the time drm_mode_config_cleanup()
> will be called, our connector will be long gone. Therefore, the
> connector must be cleaned up when the bridge is detached to avoid
> use-after-free conditions.
> 
> Fixes: 13dfc0540a57 ("drm/bridge: Refactor out the panel wrapper from the 
> lvds-encoder bridge.")
> Cc:  # 4.12+
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 
> Signed-off-by: Paul Cercueil 
> ---
>  drivers/gpu/drm/bridge/panel.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
> index 0ddc37551194..975d65c14c9c 100644
> --- a/drivers/gpu/drm/bridge/panel.c
> +++ b/drivers/gpu/drm/bridge/panel.c
> @@ -87,6 +87,10 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
>  
>  static void panel_bridge_detach(struct drm_bridge *bridge)
>  {
> + struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
> + struct drm_connector *connector = _bridge->connector;
> +
> + drm_connector_cleanup(connector);

The panel bridge driver only creates the connector if the
DRM_BRIDGE_ATTACH_NO_CONNECTOR flag wasn't set in panel_bridge_attach().
We shouldn't clean up the connector unconditionally.

A better fix would be to stop using the devm_* API, but that's more
complicated.

>  }
>  
>  static void panel_bridge_pre_enable(struct drm_bridge *bridge)

-- 
Regards,

Laurent Pinchart
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/3] drm/ingenic: Register devm action to cleanup encoders

2021-01-18 Thread Laurent Pinchart
Hi Paul,

Thank you for the patch.

On Sun, Jan 17, 2021 at 11:26:45AM +, Paul Cercueil wrote:
> Since the encoders have been devm-allocated, they will be freed way
> before drm_mode_config_cleanup() is called. To avoid use-after-free
> conditions, we then must ensure that drm_encoder_cleanup() is called
> before the encoders are freed.

How about allocating the encoder with drmm_encoder_alloc() instead ?

> Fixes: c369cb27c267 ("drm/ingenic: Support multiple panels/bridges")
> Cc:  # 5.8+
> Signed-off-by: Paul Cercueil 
> ---
>  drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c 
> b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> index 368bfef8b340..d23a3292a0e0 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> @@ -803,6 +803,11 @@ static void __maybe_unused ingenic_drm_release_rmem(void 
> *d)
>   of_reserved_mem_device_release(d);
>  }
>  
> +static void ingenic_drm_encoder_cleanup(void *encoder)
> +{
> + drm_encoder_cleanup(encoder);
> +}
> +
>  static int ingenic_drm_bind(struct device *dev, bool has_components)
>  {
>   struct platform_device *pdev = to_platform_device(dev);
> @@ -1011,6 +1016,11 @@ static int ingenic_drm_bind(struct device *dev, bool 
> has_components)
>   return ret;
>   }
>  
> + ret = devm_add_action_or_reset(dev, ingenic_drm_encoder_cleanup,
> +encoder);
> + if (ret)
> + return ret;
> +
>   ret = drm_bridge_attach(encoder, bridge, NULL, 0);
>   if (ret) {
>   dev_err(dev, "Unable to attach bridge\n");

-- 
Regards,

Laurent Pinchart
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Change eats memory on my server

2021-01-18 Thread Thomas Zimmermann

Hi

Am 18.01.21 um 10:13 schrieb Eli Cohen:

On Mon, Jan 18, 2021 at 08:54:07AM +0100, Thomas Zimmermann wrote:

Hi

Am 18.01.21 um 08:43 schrieb Christian König:

Hi Eli,

have you already tried using kmemleak?

This sounds like a leak of memory allocated using kmalloc(), so kmemleak
should be able to catch it.


I have an idea what happens here. When the refcount is 0 in kmap, a new page
mapping for the BO is being established. But VRAM helpers unmap the previous
pages only on BO moves or frees; not in kunmap. So the old mapping might
still be around. I'll send out a test patch later today.



Great! Looking forward to test it.


Here's the patch against the latest DRM tree. v5.11-rc3 should work as well.

I was able to reproduce the memory leak locally and found that the patch 
fixes it. Please give it a try.


Best regards
Thomas




Best regards
Thomas



Regards,
Christian.

Am 17.01.21 um 06:08 schrieb Eli Cohen:

On Fri, Jan 15, 2021 at 10:03:50AM +0100, Thomas Zimmermann wrote:

Could you please double-check that 3fb91f56aea4 ("drm/udl: Retrieve USB
device from struct drm_device.dev") works correctly

Checked again, it does not seem to leak.


and that 823efa922102
("drm/cma-helper: Remove empty drm_gem_cma_prime_vunmap()") is broken?


Yes, this one leaks, as does the one preceding it:

1086db71a1db ("drm/vram-helper: Remove invariant parameters from
internal kmap function")

For one of the broken commits, could you please send us the output of

    dmesg | grep -i drm

after most of the memory got leaked?


I ran the following script in the shell:

while true; do cat /proc/meminfo | grep MemFree:; sleep 5; done

and this is what I saw before I got disconnected from the shell:

MemFree:  148208 kB
MemFree:  148304 kB
MemFree:  146660 kB
Connection to nps-server-24 closed by remote host.
Connection to nps-server-24 closed.


I also mointored the output of dmesg | grep -i drm
The last output I was able to save on disk is this:

[   46.140720] ast :03:00.0: [drm] Using P2A bridge for configuration
[   46.140737] ast :03:00.0: [drm] AST 2500 detected
[   46.140754] ast :03:00.0: [drm] Analog VGA only
[   46.140772] ast :03:00.0: [drm] dram MCLK=800 Mhz type=7
bus_width=16
[   46.153553] [drm] Initialized ast 0.1.0 20120228 for :03:00.0
on minor 0
[   46.165097] fbcon: astdrmfb (fb0) is primary device
[   46.391381] ast :03:00.0: [drm] fb0: astdrmfb frame buffer device
[   56.097697] systemd[1]: Starting Load Kernel Module drm...
[   56.343556] systemd[1]: modprobe@drm.service: Succeeded.
[   56.350382] systemd[1]: Finished Load Kernel Module drm.
[13319.469462] [   2683] 70889  2683    55586    0    73728
138 0 tdrm
[13320.658386] [   2683] 70889  2683    55586    0    73728
138 0 tdrm
[13321.800970] [   2683] 70889  2683    55586    0    73728
138 0 tdrm


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer







--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
From e8462600662621db47bccf8174bf683513aa7102 Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann 
Date: Mon, 18 Jan 2021 09:58:07 +0100
Subject: [PATCH] drm/vram-helper: Reuse existing page mappings in vmap

For performance, BO page mappings can stay in place even if the
map counter has returned to 0. In these cases, the existing page
mapping has to be reused by the next vmap operation. Otherwise
a new mapping would be installed and the old mapping's pages leak.

Fix the issue by reusing existing page mappings for vmap operations.

Signed-off-by: Thomas Zimmermann 
Reported-by: Eli Cohen 
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index 02ca22e90290..a57790b0d985 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -387,9 +387,16 @@ static int drm_gem_vram_kmap_locked(struct drm_gem_vram_object *gbo,
 	if (gbo->vmap_use_count > 0)
 		goto out;
 
-	ret = ttm_bo_vmap(>bo, >map);
-	if (ret)
-		return ret;
+	/*
+	 * VRAM helpers unmap the BO only on demand. So the previous
+	 * page mapping might still be arround. Only vmap if the there's
+	 * no mapping present.
+	 */
+	if (dma_buf_map_is_null(>map)) {
+		ret = ttm_bo_vmap(>bo, >map);
+		if (ret)
+			return ret;
+	}
 
 out:
 	++gbo->vmap_use_count;
@@ -577,6 +584,7 @@ static void drm_gem_vram_bo_driver_move_notify(struct drm_gem_vram_object *gbo,
 		return;
 
 	ttm_bo_vunmap(bo, 

Re: BUG: unable to handle kernel NULL pointer dereference in fbcon_cursor

2021-01-18 Thread Daniel Vetter
On Sun, Jan 17, 2021 at 03:29:05AM -0800, syzbot wrote:
> syzbot has bisected this issue to:
> 
> commit ea40d7857d5250e5400f38c69ef9e17321e9c4a2
> Author: Daniel Vetter 
> Date:   Fri Oct 9 23:21:56 2020 +
> 
> drm/vkms: fbdev emulation support

Not sure you want to annotate this, but this just makes the bug
reproducible on vkms. It's a preexisting issue (probably a few decades
old) of the fbcon code afaict. It might also be that you can only repro
this when you have multiple fbcon drivers (vkms plus whatever your virtual
machine has I guess).
-Daniel

> 
> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=148e2748d0
> start commit:   b3a3cbde Add linux-next specific files for 20210115
> git tree:   linux-next
> final oops: https://syzkaller.appspot.com/x/report.txt?x=168e2748d0
> console output: https://syzkaller.appspot.com/x/log.txt?x=128e2748d0
> kernel config:  https://syzkaller.appspot.com/x/.config?x=6ea08dae6aab586f
> dashboard link: https://syzkaller.appspot.com/bug?extid=b67aaae8d3a927f68d20
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=15cd8fe0d0
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17af5258d0
> 
> Reported-by: syzbot+b67aaae8d3a927f68...@syzkaller.appspotmail.com
> Fixes: ea40d7857d52 ("drm/vkms: fbdev emulation support")
> 
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [BUG] DRM kernel NULL pointer dereference (linux-next 20210115)

2021-01-18 Thread Thomas Zimmermann

Hi

Am 18.01.21 um 10:14 schrieb Andy Lavr:


 > attached patchfile and report if it fixes the issue?


Yes, fixed. Thanks.


OK. Can I add you in Tested-by and Reported-by tag to the fix?

Best regards
Thomas




18.01.2021 08:25, Thomas Zimmermann пишет:

(cc'ing dri-devel)

Hi

thanks for reporting the bug.

Am 17.01.21 um 12:12 schrieb Andy Lavr:

Hey,


You forgot to add these commits to linux-next:


  drm: Move struct drm_device.pdev to legacy

https://patchwork.kernel.org/project/intel-gfx/cover/20210107080748.4768-1-tzimmerm...@suse.de/ 




I committed these patches to my local tree and that solved my problem.


  * v3,4/8] drm/i915: Remove references to struct drm_device.pdev
 


  * [v3,5/8] drm/i915/gt: Remove references to struct drm_device.pdev
 


  * [v3,6/8] drm/i915/gvt: Remove references to struct drm_device.pdev
 


  * [v3,8/8] drm: Upcast struct drm_device.dev to struct pci_device;
    replace pdev
 



These patches have not been merged yet as they have to wait for some 
preparation in the i915 driver.


I reduced the final patch, so it should change the buggy code. Could 
you please apply only the attached patchfile and report if it fixes 
the issue?


Best regards
Thomas





Thanks to all!


16.01.2021 15:17, Andy Lavr:


Hey,


*linux-next 20210114 work fine.*


*linux-next 20210115:*

Jan 15 17:34:30 wip kernel: [   35.185982] *BUG: kernel NULL pointer 
dereference, address: 0010*
Jan 15 17:34:30 wip kernel: [   35.186988] #PF: supervisor read 
access in kernel mode
Jan 15 17:34:30 wip kernel: [   35.187984] #PF: error_code(0x) - 
not-present page

Jan 15 17:34:30 wip kernel: [   35.189016] PGD 0 P4D 0
Jan 15 17:34:30 wip kernel: [   35.190508] Oops:  [#1] SMP PTI
Jan 15 17:34:30 wip kernel: [   35.191814] CPU: 6 PID: 1319 Comm: 
Xorg Not tainted 5.11.13-dragon-sandybridge #202101150001
Jan 15 17:34:30 wip kernel: [   35.192847] Hardware name: Dell Inc. 
Precision M6600/04YY4M, BIOS A18 09/14/2018
Jan 15 17:34:30 wip kernel: [   35.193877] *RIP: 
0010:drm_pci_set_busid+0x1a/0x80 [drm]*
Jan 15 17:34:30 wip kernel: [   35.194950] Code: fc 06 f8 c8 00 00 
00 00 00 00 00 00 00 00 00 00 0f 1f 44 00 00 55 53 50 48 89 f3 31 d2 
81 3f 04 00 01 00 48 8b 87 78 01 00 00 <48> 8b 48 10 7c 09 48 8b 91 
d0 01 00 00 8b 12 0f b6 89 e0 01 00 00
Jan 15 17:34:30 wip kernel: [   35.196094] RSP: 
0018:aacf485afd38 EFLAGS: 00010246
Jan 15 17:34:30 wip kernel: [   35.197695] RAX:  
RBX: 95f1684e5000 RCX: 8b06f380
Jan 15 17:34:30 wip kernel: [   35.198872] RDX:  
RSI: 95f1684e5000 RDI: 95f175240010
Jan 15 17:34:30 wip kernel: [   35.200037] RBP: ffea 
R08: e200 R09: 0001
Jan 15 17:34:30 wip kernel: [   35.201205] R10: 95f16de88b00 
R11: c03e1990 R12: 95f1684e5000
Jan 15 17:34:30 wip kernel: [   35.202383] R13: 7fff8865e240 
R14: 95f1752400a8 R15: 95f175240010
Jan 15 17:34:30 wip kernel: [   35.203554] FS: 
70bcd696da40() GS:95f41db8() knlGS:
Jan 15 17:34:30 wip kernel: [   35.204742] CS:  0010 DS:  ES: 
 CR0: 80050033
Jan 15 17:34:30 wip kernel: [   35.205936] CR2: 0010 
CR3: 000186c28006 CR4: 000606e0

Jan 15 17:34:30 wip kernel: [   35.207144] Call Trace:
Jan 15 17:34:30 wip kernel: [   35.208370] 
drm_setversion+0x13e/0x170 [drm]
Jan 15 17:34:30 wip kernel: [   35.209596]  ? drm_getstats+0x20/0x20 
[drm]
Jan 15 17:34:30 wip kernel: [   35.210799] 
drm_ioctl_kernel+0xe2/0x150 [drm]

Jan 15 17:34:30 wip kernel: [   35.211989] drm_ioctl+0x30b/0x440 [drm]
Jan 15 17:34:30 wip kernel: [   35.213170]  ? drm_getstats+0x20/0x20 
[drm]
Jan 15 17:34:30 wip kernel: [   35.214351] 
amdgpu_drm_ioctl+0x44/0x80 [amdgpu]

Jan 15 17:34:30 wip kernel: [   35.215696] __se_sys_ioctl+0x78/0xc0
Jan 15 17:34:30 wip kernel: [   35.216848] do_syscall_64+0x33/0x70
Jan 15 17:34:30 wip kernel: [   35.218002] 
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Jan 15 17:34:30 wip kernel: [   35.219177] RIP: 0033:0x70bcd6dd931b
Jan 15 17:34:30 wip kernel: [   35.220654] Code: 89 d8 49 8d 3c 1c 
48 f7 d8 49 39 c4 72 b5 e8 1c ff ff ff 85 c0 78 ba 4c 89 e0 5b 5d 41 
5c c3 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 
48 8b 0d 1d 3b 0d 00 f7 d8 64 89 01 48
Jan 15 17:34:30 wip kernel: [   35.11] RSP: 
002b:7fff8865e208 EFLAGS: 0202 ORIG_RAX: 0010
Jan 15 17:34:30 wip kernel: [   35.223778] RAX: ffda 
RBX: 7fff8865e240 RCX: 70bcd6dd931b
Jan 15 17:34:30 wip kernel: [   35.225145] RDX: 

Re: [PATCH v2] drm/ast: Disable fast reset after DRAM initial

2021-01-18 Thread Thomas Zimmermann

Hi

Am 12.01.21 um 08:58 schrieb KuoHsiang Chou:

[Bug][AST2500]

V1:
When AST2500 acts as stand-alone VGA so that DRAM and DVO initialization
have to be achieved by VGA driver with P2A (PCI to AHB) enabling.
However, HW suggests disable Fast reset mode after DRAM initializaton,
because fast reset mode is mainly designed for ARM ICE debugger.
Once Fast reset is checked as enabling, WDT (Watch Dog Timer) should be
first enabled to avoid system deadlock before disable fast reset mode.

V2:
Use to_pci_dev() to get revision of PCI configuration.

Signed-off-by: KuoHsiang Chou 
---
  drivers/gpu/drm/ast/ast_drv.h  |  1 +
  drivers/gpu/drm/ast/ast_main.c |  5 +++
  drivers/gpu/drm/ast/ast_post.c | 71 +-
  3 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index da6dfb677540..a2cf5fef2399 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -320,6 +320,7 @@ bool ast_is_vga_enabled(struct drm_device *dev);
  void ast_post_gpu(struct drm_device *dev);
  u32 ast_mindwm(struct ast_private *ast, u32 r);
  void ast_moutdwm(struct ast_private *ast, u32 r, u32 v);
+void ast_patch_ahb_2500(struct ast_private *ast);
  /* ast dp501 */
  void ast_set_dp501_video_output(struct drm_device *dev, u8 mode);
  bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size);
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 3775fe26f792..0e4dfcc25623 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -69,6 +69,7 @@ static void ast_detect_config_mode(struct drm_device *dev, 
u32 *scu_rev)
  {
struct device_node *np = dev->pdev->dev.of_node;
struct ast_private *ast = to_ast_private(dev);
+   struct pci_dev *pdev = to_pci_dev(dev->dev);
uint32_t data, jregd0, jregd1;

/* Defaults */
@@ -96,6 +97,10 @@ static void ast_detect_config_mode(struct drm_device *dev, 
u32 *scu_rev)
jregd0 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
jregd1 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff);
if (!(jregd0 & 0x80) || !(jregd1 & 0x10)) {
+   /* Patch AST2500 */
+   if (((pdev->revision & 0xF0) == 0x40) && ((jregd0 & 0xC0) == 0))
+   ast_patch_ahb_2500(ast);
+
/* Double check it's actually working */
data = ast_read32(ast, 0xf004);
if (data != 0x) {
diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
index 8902c2f84bf9..1f0007daa005 100644
--- a/drivers/gpu/drm/ast/ast_post.c
+++ b/drivers/gpu/drm/ast/ast_post.c
@@ -2026,6 +2026,33 @@ static bool ast_dram_init_2500(struct ast_private *ast)
return true;
  }

+void ast_patch_ahb_2500(struct ast_private *ast)
+{
+   u32 data;
+
+patch_ahb_lock:
+   /* Clear bus lock condition */
+   ast_moutdwm(ast, 0x1e60, 0xAEED1A03);
+   ast_moutdwm(ast, 0x1e600084, 0x0001);
+   ast_moutdwm(ast, 0x1e600088, 0x);
+   ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
+   data = ast_mindwm(ast, 0x1e6e2070);
+   if (data & 0x0800) {/* check 
fast reset */
+
+   ast_moutdwm(ast, 0x1E785004, 0x0010);
+   ast_moutdwm(ast, 0x1E785008, 0x4755);
+   ast_moutdwm(ast, 0x1E78500c, 0x0033);
+   udelay(1000);
+   }
+   ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
+   do {
+   data = ast_mindwm(ast, 0x1e6e2000);
+   if (data == 0x)
+   goto patch_ahb_lock;
+   }   while (data != 1);
+   ast_moutdwm(ast, 0x1e6e207c, 0x0800);   /* clear fast reset */
+}
+
  void ast_post_chip_2500(struct drm_device *dev)
  {
struct ast_private *ast = to_ast_private(dev);
@@ -2033,39 +2060,31 @@ void ast_post_chip_2500(struct drm_device *dev)
u8 reg;

reg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
-   if ((reg & 0x80) == 0) {/* vga only */
+   if ((reg & 0xC0) == 0) {/* vga only */
/* Clear bus lock condition */
-   ast_moutdwm(ast, 0x1e60, 0xAEED1A03);
-   ast_moutdwm(ast, 0x1e600084, 0x0001);
-   ast_moutdwm(ast, 0x1e600088, 0x);
-   ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
-   ast_write32(ast, 0xf004, 0x1e6e);
-   ast_write32(ast, 0xf000, 0x1);
-   ast_write32(ast, 0x12000, 0x1688a8a8);
-   while (ast_read32(ast, 0x12000) != 0x1)
-   ;
-
-   ast_write32(ast, 0x1, 0xfc600309);
-   while (ast_read32(ast, 0x1) != 0x1)
-   ;
+   ast_patch_ahb_2500(ast);
+
+   /* Disable watchdog */
+   ast_moutdwm(ast, 0x1E78502C, 0x);
+   

[PATCH] drm/ast: Update the sequence of Clearing Fast-reset

2021-01-18 Thread KuoHsiang Chou
[Bug][AST2500]
If SCU00 is not unlocked, just enter its password again.
It is unnecessary to clear AHB lock condition and restore WDT default
setting again, before Fast-reset clearing.

Signed-off-by: KuoHsiang Chou 
---
 drivers/gpu/drm/ast/ast_post.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
index 1f0007daa005..4f194c5fd2c2 100644
--- a/drivers/gpu/drm/ast/ast_post.c
+++ b/drivers/gpu/drm/ast/ast_post.c
@@ -2030,7 +2030,6 @@ void ast_patch_ahb_2500(struct ast_private *ast)
 {
u32 data;

-patch_ahb_lock:
/* Clear bus lock condition */
ast_moutdwm(ast, 0x1e60, 0xAEED1A03);
ast_moutdwm(ast, 0x1e600084, 0x0001);
@@ -2044,11 +2043,9 @@ void ast_patch_ahb_2500(struct ast_private *ast)
ast_moutdwm(ast, 0x1E78500c, 0x0033);
udelay(1000);
}
-   ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
do {
+   ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
data = ast_mindwm(ast, 0x1e6e2000);
-   if (data == 0x)
-   goto patch_ahb_lock;
}   while (data != 1);
ast_moutdwm(ast, 0x1e6e207c, 0x0800);   /* clear fast reset */
 }
--
2.18.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v5 2/2] drm/doc: document the type plane property

2021-01-18 Thread Pekka Paalanen
On Fri, 15 Jan 2021 12:06:26 +0100
Simon Ser  wrote:

> Add a new entry for "type" in the section for standard plane properties.
> 
> v3: improve paragraph about mixing legacy IOCTLs with explicit usage,
> note that a driver may support cursors without cursor planes (Daniel)
> 
> v4: fixing rebase gone wrong
> 
> v5:
> - Fix typo (Daniel)
> - Mention CAP_ATOMIC instead of CAP_UNIVERSAL_PLANES when referring to
>   atomic test-only commits (Daniel)
> - Add newlines at end of sections (Daniel)
> 
> Signed-off-by: Simon Ser 
> Reviewed-by: Daniel Vetter 
> Cc: Pekka Paalanen 
> ---
>  drivers/gpu/drm/drm_plane.c | 58 ++---
>  1 file changed, 54 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index bf6e525bb116..5affcc7f065b 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -50,10 +50,8 @@
>   *  drm_plane (possibly as part of a larger structure) and registers 
> it
>   * with a call to drm_universal_plane_init().
>   *
> - * The type of a plane is exposed in the immutable "type" enumeration 
> property,
> - * which has one of the following values: "Overlay", "Primary", "Cursor" (see
> - * enum drm_plane_type). A plane can be compatible with multiple CRTCs, see
> - * _plane.possible_crtcs.
> + * Each plane has a type, see enum drm_plane_type. A plane can be compatible
> + * with multiple CRTCs, see _plane.possible_crtcs.

Hi,

this part is kernel dev doc, right?

>   *
>   * Each CRTC must have a unique primary plane userspace can attach to enable
>   * the CRTC. In other words, userspace must be able to attach a different
> @@ -73,6 +71,58 @@
>   *
>   * DRM planes have a few standardized properties:
>   *
> + * type:
> + * Immutable property describing the type of the plane.
> + *
> + * For user-space which has enabled the _CLIENT_CAP_ATOMIC 
> capability,
> + * the plane type is just a hint and is mostly superseded by atomic
> + * test-only commits. The type hint can still be used to come up more
> + * easily with a plane configuration accepted by the driver.
> + *
> + * The value of this property can be one of the following:
> + *
> + * "Primary":
> + * To light up a CRTC, attaching a primary plane is the most likely 
> to
> + * work if it covers the whole CRTC and doesn't have scaling or
> + * cropping set up.
> + *
> + * Drivers may support more features for the primary plane, 
> user-space
> + * can find out with test-only atomic commits.
> + *
> + * Primary planes are implicitly used by the kernel in the legacy

s/Primary planes/Some primary planes/ perhaps? That would give the
justification for the below "user-space must not" sentence as there is
vagueness in what exactly happens with legacy.

Ok either way.

> + * IOCTLs _IOCTL_MODE_SETCRTC and _IOCTL_MODE_PAGE_FLIP.
> + * Therefore user-space must not mix explicit usage of any primary
> + * plane (e.g. through an atomic commit) with these legacy IOCTLs.
> + *
> + * "Cursor":
> + * To enable this plane, using a framebuffer configured without 
> scaling
> + * or cropping and with the following properties is the most likely 
> to
> + * work:
> + *
> + * - If the driver provides the capabilities _CAP_CURSOR_WIDTH 
> and
> + *   _CAP_CURSOR_HEIGHT, create the framebuffer with this size.
> + *   Otherwise, create a framebuffer with the size 64x64.
> + * - If the driver doesn't support modifiers, create a framebuffer 
> with
> + *   a linear layout. Otherwise, use the IN_FORMATS plane property.
> + *
> + * Drivers may support more features for the cursor plane, user-space
> + * can find out with test-only atomic commits.
> + *
> + * Cursor planes are implicitly used by the kernel in the legacy

s/Cursor planes/Some cursor planes/ like earlier?

> + * IOCTLs _IOCTL_MODE_CURSOR and _IOCTL_MODE_CURSOR2.
> + * Therefore user-space must not mix explicit usage of any cursor
> + * plane (e.g. through an atomic commit) with these legacy IOCTLs.
> + *
> + * Some drivers may support cursors even if no cursor plane is 
> exposed.
> + * In this case, the legacy cursor IOCTLs can be used to configure 
> the
> + * cursor.
> + *
> + * "Overlay":
> + * Neither primary nor cursor.
> + *
> + * Overlay planes are the only planes exposed when the
> + * _CLIENT_CAP_UNIVERSAL_PLANES capability is disabled.

This is a bit terse. Can we say anything more about overlay planes?
Even just "nothing is guaranteed, use test_only commits to find out
what works"?

> + *
>   * IN_FORMATS:
>   * Blob property which contains the set of buffer format and modifier
>   * pairs supported by this plane. The blob is a struct

In any case,
Reviewed-by: Pekka Paalanen 


Thanks,
pq


pgpeDFRhsJuI1.pgp

Re: [PATCH v5 1/2] drm/doc: fix drm_plane_type docs

2021-01-18 Thread Pekka Paalanen
On Fri, 15 Jan 2021 12:06:25 +0100
Simon Ser  wrote:

> The docs for enum drm_plane_type mention legacy IOCTLs, however the
> plane type is not tied to legacy IOCTLs, the drm_cursor.primary and
> cursor fields are. Add a small paragraph to reference these.
> 
> Instead, document expectations for primary and cursor planes for
> non-legacy userspace. Note that these docs are for driver developers,
> not userspace developers, so internal kernel APIs are mentionned.
> 
> Signed-off-by: Simon Ser 
> Reviewed-by: Daniel Vetter 
> Cc: Pekka Paalanen 
> ---
>  include/drm/drm_plane.h | 21 +
>  1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 8ef06ee1c8eb..95ab14a4336a 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -538,10 +538,14 @@ struct drm_plane_funcs {
>   *
>   * For compatibility with legacy userspace, only overlay planes are made
>   * available to userspace by default. Userspace clients may set the
> - * DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that 
> they
> + * _CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that 
> they
>   * wish to receive a universal plane list containing all plane types. See 
> also
>   * drm_for_each_legacy_plane().
>   *
> + * In addition to setting each plane's type, drivers need to setup the
> + * _crtc.primary and optionally _crtc.cursor pointers for legacy
> + * IOCTLs. See drm_crtc_init_with_planes().
> + *
>   * WARNING: The values of this enum is UABI since they're exposed in the 
> "type"
>   * property.
>   */
> @@ -557,19 +561,20 @@ enum drm_plane_type {
>   /**
>* @DRM_PLANE_TYPE_PRIMARY:
>*
> -  * Primary planes represent a "main" plane for a CRTC.  Primary planes
> -  * are the planes operated upon by CRTC modesetting and flipping
> -  * operations described in the _crtc_funcs.page_flip and
> -  * _crtc_funcs.set_config hooks.
> +  * A primary plane attached to a CRTC is the most likely to be able to
> +  * light up the CRTC when no scaling/cropping is used and the plane
> +  * covers the whole CRTC.
>*/
>   DRM_PLANE_TYPE_PRIMARY,
>  
>   /**
>* @DRM_PLANE_TYPE_CURSOR:
>*
> -  * Cursor planes represent a "cursor" plane for a CRTC.  Cursor planes
> -  * are the planes operated upon by the DRM_IOCTL_MODE_CURSOR and
> -  * DRM_IOCTL_MODE_CURSOR2 IOCTLs.
> +  * A cursor plane attached to a CRTC is more likely to be able to be
> +  * enabled when no scaling/cropping is used and the framebuffer has the
> +  * size indicated by _mode_config.cursor_width and
> +  * _mode_config.cursor_height. Additionally, if the driver doesn't
> +  * support modifiers, the framebuffer should have a linear layout.

Hi,

is there anything to be said about positioning a cursor plane partially
off-screen?

>*/
>   DRM_PLANE_TYPE_CURSOR,
>  };

Anyway,
Acked-by: Pekka Paalanen 


Thanks,
pq


pgpRcndYXePUA.pgp
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [BUG] DRM kernel NULL pointer dereference (linux-next 20210115)

2021-01-18 Thread Thomas Zimmermann

(cc'ing dri-devel)

Hi

thanks for reporting the bug.

Am 17.01.21 um 12:12 schrieb Andy Lavr:

Hey,


You forgot to add these commits to linux-next:


  drm: Move struct drm_device.pdev to legacy

https://patchwork.kernel.org/project/intel-gfx/cover/20210107080748.4768-1-tzimmerm...@suse.de/


I committed these patches to my local tree and that solved my problem.


  * v3,4/8] drm/i915: Remove references to struct drm_device.pdev


  * [v3,5/8] drm/i915/gt: Remove references to struct drm_device.pdev


  * [v3,6/8] drm/i915/gvt: Remove references to struct drm_device.pdev


  * [v3,8/8] drm: Upcast struct drm_device.dev to struct pci_device;
replace pdev




These patches have not been merged yet as they have to wait for some 
preparation in the i915 driver.


I reduced the final patch, so it should change the buggy code. Could you 
please apply only the attached patchfile and report if it fixes the issue?


Best regards
Thomas





Thanks to all!


16.01.2021 15:17, Andy Lavr:


Hey,


*linux-next 20210114 work fine.*


*linux-next 20210115:*

Jan 15 17:34:30 wip kernel: [   35.185982] *BUG: kernel NULL pointer 
dereference, address: 0010*
Jan 15 17:34:30 wip kernel: [   35.186988] #PF: supervisor read access 
in kernel mode
Jan 15 17:34:30 wip kernel: [   35.187984] #PF: error_code(0x) - 
not-present page

Jan 15 17:34:30 wip kernel: [   35.189016] PGD 0 P4D 0
Jan 15 17:34:30 wip kernel: [   35.190508] Oops:  [#1] SMP PTI
Jan 15 17:34:30 wip kernel: [   35.191814] CPU: 6 PID: 1319 Comm: Xorg 
Not tainted 5.11.13-dragon-sandybridge #202101150001
Jan 15 17:34:30 wip kernel: [   35.192847] Hardware name: Dell Inc. 
Precision M6600/04YY4M, BIOS A18 09/14/2018
Jan 15 17:34:30 wip kernel: [   35.193877] *RIP: 
0010:drm_pci_set_busid+0x1a/0x80 [drm]*
Jan 15 17:34:30 wip kernel: [   35.194950] Code: fc 06 f8 c8 00 00 00 
00 00 00 00 00 00 00 00 00 0f 1f 44 00 00 55 53 50 48 89 f3 31 d2 81 
3f 04 00 01 00 48 8b 87 78 01 00 00 <48> 8b 48 10 7c 09 48 8b 91 d0 01 
00 00 8b 12 0f b6 89 e0 01 00 00
Jan 15 17:34:30 wip kernel: [   35.196094] RSP: 0018:aacf485afd38 
EFLAGS: 00010246
Jan 15 17:34:30 wip kernel: [   35.197695] RAX:  RBX: 
95f1684e5000 RCX: 8b06f380
Jan 15 17:34:30 wip kernel: [   35.198872] RDX:  RSI: 
95f1684e5000 RDI: 95f175240010
Jan 15 17:34:30 wip kernel: [   35.200037] RBP: ffea R08: 
e200 R09: 0001
Jan 15 17:34:30 wip kernel: [   35.201205] R10: 95f16de88b00 R11: 
c03e1990 R12: 95f1684e5000
Jan 15 17:34:30 wip kernel: [   35.202383] R13: 7fff8865e240 R14: 
95f1752400a8 R15: 95f175240010
Jan 15 17:34:30 wip kernel: [   35.203554] FS: 70bcd696da40() 
GS:95f41db8() knlGS:
Jan 15 17:34:30 wip kernel: [   35.204742] CS:  0010 DS:  ES:  
CR0: 80050033
Jan 15 17:34:30 wip kernel: [   35.205936] CR2: 0010 CR3: 
000186c28006 CR4: 000606e0

Jan 15 17:34:30 wip kernel: [   35.207144] Call Trace:
Jan 15 17:34:30 wip kernel: [   35.208370] drm_setversion+0x13e/0x170 
[drm]

Jan 15 17:34:30 wip kernel: [   35.209596]  ? drm_getstats+0x20/0x20 [drm]
Jan 15 17:34:30 wip kernel: [   35.210799] drm_ioctl_kernel+0xe2/0x150 
[drm]

Jan 15 17:34:30 wip kernel: [   35.211989] drm_ioctl+0x30b/0x440 [drm]
Jan 15 17:34:30 wip kernel: [   35.213170]  ? drm_getstats+0x20/0x20 [drm]
Jan 15 17:34:30 wip kernel: [   35.214351] amdgpu_drm_ioctl+0x44/0x80 
[amdgpu]

Jan 15 17:34:30 wip kernel: [   35.215696] __se_sys_ioctl+0x78/0xc0
Jan 15 17:34:30 wip kernel: [   35.216848] do_syscall_64+0x33/0x70
Jan 15 17:34:30 wip kernel: [   35.218002] 
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Jan 15 17:34:30 wip kernel: [   35.219177] RIP: 0033:0x70bcd6dd931b
Jan 15 17:34:30 wip kernel: [   35.220654] Code: 89 d8 49 8d 3c 1c 48 
f7 d8 49 39 c4 72 b5 e8 1c ff ff ff 85 c0 78 ba 4c 89 e0 5b 5d 41 5c 
c3 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 
0d 1d 3b 0d 00 f7 d8 64 89 01 48
Jan 15 17:34:30 wip kernel: [   35.11] RSP: 002b:7fff8865e208 
EFLAGS: 0202 ORIG_RAX: 0010
Jan 15 17:34:30 wip kernel: [   35.223778] RAX: ffda RBX: 
7fff8865e240 RCX: 70bcd6dd931b
Jan 15 17:34:30 wip kernel: [   35.225145] RDX: 7fff8865e240 RSI: 
c0106407 RDI: 000c
Jan 15 17:34:30 wip kernel: [   35.226420] RBP: c0106407 R08: 
0031 R09: 
Jan 15 17:34:30 wip kernel: [   35.227691] R10: 70bcd7850ec0 R11: 
0202 

Re: BUG: unable to handle kernel NULL pointer dereference in fbcon_cursor

2021-01-18 Thread syzbot
syzbot has found a reproducer for the following issue on:

HEAD commit:b3a3cbde Add linux-next specific files for 20210115
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=164096d750
kernel config:  https://syzkaller.appspot.com/x/.config?x=6ea08dae6aab586f
dashboard link: https://syzkaller.appspot.com/bug?extid=b67aaae8d3a927f68d20
compiler:   gcc (GCC) 10.1.0-syz 20200507
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=15cd8fe0d0
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17af5258d0

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b67aaae8d3a927f68...@syzkaller.appspotmail.com

BUG: kernel NULL pointer dereference, address: 
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD 12267067 P4D 12267067 PUD 11841067 PMD 0 
Oops: 0010 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 8463 Comm: syz-executor088 Not tainted 
5.11.0-rc3-next-20210115-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
RIP: 0010:0x0
Code: Unable to access opcode bytes at RIP 0xffd6.
RSP: 0018:c9000132f850 EFLAGS: 00010292
RAX: 0007 RBX:  RCX: 0007
RDX: 0002 RSI: 88814394b000 RDI: 888010071000
RBP: 888010071000 R08:  R09: 83ed87ea
R10: 0003 R11: 0018 R12: 88814394b000
R13:  R14:  R15: 0720
FS:  00db8880() GS:8880b9f0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: ffd6 CR3: 20cd8000 CR4: 001506e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 fbcon_cursor+0x50e/0x620 drivers/video/fbdev/core/fbcon.c:1336
 hide_cursor+0x85/0x280 drivers/tty/vt/vt.c:907
 redraw_screen+0x5b4/0x740 drivers/tty/vt/vt.c:1012
 vc_do_resize+0xed8/0x1150 drivers/tty/vt/vt.c:1325
 fbcon_set_disp+0x7a8/0xe10 drivers/video/fbdev/core/fbcon.c:1402
 con2fb_init_display drivers/video/fbdev/core/fbcon.c:808 [inline]
 set_con2fb_map+0x7a6/0xf80 drivers/video/fbdev/core/fbcon.c:879
 fbcon_set_con2fb_map_ioctl+0x165/0x220 drivers/video/fbdev/core/fbcon.c:3010
 do_fb_ioctl+0x5b6/0x690 drivers/video/fbdev/core/fbmem.c:1156
 fb_ioctl+0xe7/0x150 drivers/video/fbdev/core/fbmem.c:1185
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl fs/ioctl.c:739 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:739
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x4402b9
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 
7b 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:7ae24f88 EFLAGS: 0246 ORIG_RAX: 0010
RAX: ffda RBX: 004002c8 RCX: 004402b9
RDX: 2080 RSI: 4610 RDI: 0004
RBP: 006ca018 R08: 004002c8 R09: 004002c8
R10: 004002c8 R11: 0246 R12: 00401ac0
R13: 00401b50 R14:  R15: 
Modules linked in:
CR2: 
---[ end trace 5adb9f198fe5efa6 ]---
RIP: 0010:0x0
Code: Unable to access opcode bytes at RIP 0xffd6.
RSP: 0018:c9000132f850 EFLAGS: 00010292
RAX: 0007 RBX:  RCX: 0007
RDX: 0002 RSI: 88814394b000 RDI: 888010071000
RBP: 888010071000 R08:  R09: 83ed87ea
R10: 0003 R11: 0018 R12: 88814394b000
R13:  R14:  R15: 0720
FS:  00db8880() GS:8880b9f0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: ffd6 CR3: 20cd8000 CR4: 001506e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH V3] drm/stm: Fix bus_flags handling

2021-01-18 Thread Marek Vasut
The drm_display_mode_to_videomode() does not populate DISPLAY_FLAGS_DE_LOW
or DISPLAY_FLAGS_PIXDATA_NEGEDGE flags in struct videomode. Therefore, no
matter what polarity the next bridge or display might require, these flags
are never set, and thus the LTDC GCR_DEPOL and GCR_PCPOL bits are never set,
and the LTDC behaves as if both DISPLAY_FLAGS_PIXDATA_POSEDGE and
DISPLAY_FLAGS_DE_HIGH were always set.

The fix for this problem is taken almost verbatim from MXSFB driver. In
case there is a bridge attached to the LTDC, the bridge might have extra
polarity requirements, so extract bus_flags from the bridge and use them
for LTDC configuration. Otherwise, extract bus_flags from the connector,
which is the display.

Fixes: b759012c5fa7 ("drm/stm: Add STM32 LTDC driver")
Signed-off-by: Marek Vasut 
Signed-off-by: Yannick Fertre 
Cc: Alexandre Torgue 
Cc: Antonio Borneo 
Cc: Benjamin Gaignard 
Cc: Maxime Coquelin 
Cc: Philippe Cornu 
Cc: Sam Ravnborg 
Cc: Vincent Abriou 
Cc: Yannick Fertre 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-st...@st-md-mailman.stormreply.com
To: dri-devel@lists.freedesktop.org
---
V2: Check if ldev->bridge->timings is non-NULL before accessing it
V3: get bus_flags from connector (from Yannick)
- Display controller could support several connectors (not connected at
  the same time). ie: stm32mp15c-DK2 board have 2 connectors (HDMI + DSI).
  Driver check which connector is connected to get the bus flag.
---
 drivers/gpu/drm/stm/ltdc.c | 28 ++--
 drivers/gpu/drm/stm/ltdc.h |  2 ++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 7812094f93d6..b9cd2dc114cd 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -525,13 +525,25 @@ static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
struct ltdc_device *ldev = crtc_to_ltdc(crtc);
struct drm_device *ddev = crtc->dev;
+   struct drm_connector_list_iter iter;
+   struct drm_connector *connector;
struct drm_display_mode *mode = >state->adjusted_mode;
struct videomode vm;
+   u32 bus_flags = 0;
u32 hsync, vsync, accum_hbp, accum_vbp, accum_act_w, accum_act_h;
u32 total_width, total_height;
u32 val;
int ret;
 
+   /* Get the connector which is connected */
+   drm_connector_list_iter_begin(ddev, );
+   drm_for_each_connector_iter(connector, )
+   if(connector->status == connector_status_connected)
+   break;
+   drm_connector_list_iter_end();
+
+   bus_flags = connector->display_info.bus_flags;
+
if (!pm_runtime_active(ddev->dev)) {
ret = pm_runtime_get_sync(ddev->dev);
if (ret) {
@@ -567,10 +579,10 @@ static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
if (vm.flags & DISPLAY_FLAGS_VSYNC_HIGH)
val |= GCR_VSPOL;
 
-   if (vm.flags & DISPLAY_FLAGS_DE_LOW)
+   if (bus_flags & DRM_BUS_FLAG_DE_LOW)
val |= GCR_DEPOL;
 
-   if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
+   if (bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)
val |= GCR_PCPOL;
 
reg_update_bits(ldev->regs, LTDC_GCR,
@@ -1078,6 +1090,8 @@ static const struct drm_encoder_helper_funcs 
ltdc_encoder_helper_funcs = {
 
 static int ltdc_encoder_init(struct drm_device *ddev, struct drm_bridge 
*bridge)
 {
+   struct ltdc_device *ldev = ddev->dev_private;
+   struct drm_connector_list_iter iter;
struct drm_encoder *encoder;
int ret;
 
@@ -1099,6 +1113,16 @@ static int ltdc_encoder_init(struct drm_device *ddev, 
struct drm_bridge *bridge)
return -EINVAL;
}
 
+   ldev->bridge = bridge;
+
+   /*
+* Get hold of the connector. This is a bit of a hack, until the bridge
+* API gives us bus flags and formats.
+*/
+   drm_connector_list_iter_begin(ddev, );
+   ldev->connector = drm_connector_list_iter_next();
+   drm_connector_list_iter_end();
+
DRM_DEBUG_DRIVER("Bridge encoder:%d created\n", encoder->base.id);
 
return 0;
diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
index f153b908c70e..d0d2c81de29a 100644
--- a/drivers/gpu/drm/stm/ltdc.h
+++ b/drivers/gpu/drm/stm/ltdc.h
@@ -38,6 +38,8 @@ struct ltdc_device {
u32 irq_status;
struct fps_info plane_fpsi[LTDC_MAX_LAYER];
struct drm_atomic_state *suspend_state;
+   struct drm_bridge *bridge;
+   struct drm_connector *connector;
 };
 
 int ltdc_load(struct drm_device *ddev);
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v1] drm/panel: simple: add SGD GKTW70SDAD1SD

2021-01-18 Thread Oliver Graute
On 10/01/21, Fabio Estevam wrote:
> On Sun, Jan 10, 2021 at 5:09 PM Oliver Graute  wrote:
> 
> > here the schematics and my dts. The board is using a LVDS connector for
> > the display.
> 
> The schematics shows the GKTW70SDAD1SD panel in the J4 connector, not
> the LVDS J7 connector.

yes you are right. But how to I map this fact correctly in my dts?

> > https://www.variscite.de/wp-content/uploads/2017/12/VAR-6ULCustomboard-Schematics.pdf
> > https://lore.kernel.org/linux-arm-kernel/1610144511-19018-3-git-send-email-oliver.gra...@gmail.com/
> 
> As I mentioned earlier you should remove the display timings from the
> dts when using the compatible string for the panel.

I got this and removed the display timings.

> 
> power-supply = <_touch_3v3> is not correct, as the reg_touch_3v3
> does not power the LCD.

yes, but how is the LCD correctly powered then? 

> 
> Another hint is to use the PLL5_VIDEO as the clock source for the
> lcdif controller as done in the imx6ul evk dtsi.

I already figured it out and tried it. But because of the faults above
it didn't make any difference.  

> 
> It would also help if you could share the complete boot log.

here is the boot log


Starting kernel ...

[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 5.10.0-test-6-gc24ef7716d4b (oliver@ripley) 
(arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609, 
GNU ld (GNU Binutils for Ubuntu) 2.26.1) #1 SMP Sat Jan 16 13:28:37 CET 2021
[0.00] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[0.00] CPU: div instructions available: patching division code
[0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing 
instruction cache
[0.00] OF: fdt: Machine model: Variscite i.MX6 UltraLite Carrier-board
[0.00] earlycon: ec_imx6q0 at MMIO 0x0202 (options '')
[0.00] printk: bootconsole [ec_imx6q0] enabled
[0.00] Memory policy: Data cache writealloc
[0.00] cma: Reserved 64 MiB at 0x9c00
[0.00] Zone ranges:
[0.00]   Normal   [mem 0x8000-0x9fff]
[0.00]   HighMem  empty
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x8000-0x9fff]
[0.00] Initmem setup node 0 [mem 0x8000-0x9fff]
[0.00] percpu: Embedded 18 pages/cpu s51692 r0 d22036 u73728
[0.00] Built 1 zonelists, mobility grouping on.  Total pages: 130048
[0.00] Kernel command line: console=ttymxc0,115200,115200 root=/dev/nfs 
ip=dhcp nfsroot=192.168.3.13:/volume1/nfs/rootfs/,v3,tcp rw earlycon
[0.00] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, 
linear)
[0.00] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes, 
linear)
[0.00] mem auto-init: stack:off, heap alloc:off, heap free:off
[0.00] Memory: 422620K/524288K available (16384K kernel code, 2090K 
rwdata, 4636K rodata, 1024K init, 6680K bss, 36132K reserved, 65536K 
cma-reserved, 0K highmem)
[0.00] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[0.00] Running RCU self tests
[0.00] rcu: Hierarchical RCU implementation.
[0.00] rcu: RCU event tracing is enabled.
[0.00] rcu: RCU lockdep checking is enabled.
[0.00] rcu: RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
[0.00] rcu: RCU calculated value of scheduler-enlistment delay is 10 
jiffies.
[0.00] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[0.00] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[0.00] random: get_random_bytes called from start_kernel+0x350/0x570 
with crng_init=0
[0.00] Switching to timer-based delay loop, resolution 41ns
[0.23] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 
89478484971ns
[0.007847] clocksource: mxc_timer1: mask: 0x max_cycles: 
0x, max_idle_ns: 79635851949 ns
[0.021360] Console: colour dummy device 80x30
[0.023088] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., 
Ingo Molnar
[0.031763] ... MAX_LOCKDEP_SUBCLASSES:  8
[0.034908] ... MAX_LOCK_DEPTH:  48
[0.039082] ... MAX_LOCKDEP_KEYS:8192
[0.043532] ... CLASSHASH_SIZE:  4096
[0.047784] ... MAX_LOCKDEP_ENTRIES: 32768
[0.052216] ... MAX_LOCKDEP_CHAINS:  65536
[0.056739] ... CHAINHASH_SIZE:  32768
[0.061095]  memory used by lock dependency info: 4061 kB
[0.066484]  memory used for stack traces: 2112 kB
[0.071350]  per task-struct memory footprint: 1536 bytes
[0.076832] Calibrating delay loop (skipped), value calculated using timer 
frequency.. 48.00 BogoMIPS (lpj=24)
[0.087133] pid_max: default: 32768 minimum: 301
[0.092643] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, 
linear)
[0.099090] 

[PATCH v3 1/3] drm/bridge/lontium-lt9611uxc: fix waiting for EDID to become available

2021-01-18 Thread Dmitry Baryshkov
- Call wake_up() when EDID ready event is received to wake
  wait_event_interruptible_timeout()

- Increase waiting timeout, reading EDID can take longer than 100ms, so
  let's be on a safe side.

Signed-off-by: Dmitry Baryshkov 
Fixes: 0cbbd5b1a012 ("drm: bridge: add support for lontium LT9611UXC bridge")
---
 drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c 
b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
index 0c98d27f84ac..a59e811f1705 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
@@ -145,8 +145,10 @@ static irqreturn_t lt9611uxc_irq_thread_handler(int irq, 
void *dev_id)
 
lt9611uxc_unlock(lt9611uxc);
 
-   if (irq_status & BIT(0))
+   if (irq_status & BIT(0)) {
lt9611uxc->edid_read = !!(hpd_status & BIT(0));
+   wake_up_all(>wq);
+   }
 
if (irq_status & BIT(1)) {
if (lt9611uxc->connector.dev)
@@ -465,7 +467,7 @@ static enum drm_connector_status 
lt9611uxc_bridge_detect(struct drm_bridge *brid
 static int lt9611uxc_wait_for_edid(struct lt9611uxc *lt9611uxc)
 {
return wait_event_interruptible_timeout(lt9611uxc->wq, 
lt9611uxc->edid_read,
-   msecs_to_jiffies(100));
+   msecs_to_jiffies(500));
 }
 
 static int lt9611uxc_get_edid_block(void *data, u8 *buf, unsigned int block, 
size_t len)
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] vgaarb: Remove unneeded semicolons

2021-01-18 Thread Yue Zou
Remove superfluous semicolons after function definitions.

Signed-off-by: Yue Zou 
---
 include/linux/vgaarb.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index 977caf96c8d2..fc6dfeba04a5 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -121,9 +121,9 @@ extern struct pci_dev *vga_default_device(void);
 extern void vga_set_default_device(struct pci_dev *pdev);
 extern int vga_remove_vgacon(struct pci_dev *pdev);
 #else
-static inline struct pci_dev *vga_default_device(void) { return NULL; };
-static inline void vga_set_default_device(struct pci_dev *pdev) { };
-static inline int vga_remove_vgacon(struct pci_dev *pdev) { return 0; };
+static inline struct pci_dev *vga_default_device(void) { return NULL; }
+static inline void vga_set_default_device(struct pci_dev *pdev) { }
+static inline int vga_remove_vgacon(struct pci_dev *pdev) { return 0; }
 #endif
 
 /*
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/3] drm/ingenic: Register devm action to cleanup encoders

2021-01-18 Thread Paul Cercueil
Since the encoders have been devm-allocated, they will be freed way
before drm_mode_config_cleanup() is called. To avoid use-after-free
conditions, we then must ensure that drm_encoder_cleanup() is called
before the encoders are freed.

Fixes: c369cb27c267 ("drm/ingenic: Support multiple panels/bridges")
Cc:  # 5.8+
Signed-off-by: Paul Cercueil 
---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c 
b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index 368bfef8b340..d23a3292a0e0 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -803,6 +803,11 @@ static void __maybe_unused ingenic_drm_release_rmem(void 
*d)
of_reserved_mem_device_release(d);
 }
 
+static void ingenic_drm_encoder_cleanup(void *encoder)
+{
+   drm_encoder_cleanup(encoder);
+}
+
 static int ingenic_drm_bind(struct device *dev, bool has_components)
 {
struct platform_device *pdev = to_platform_device(dev);
@@ -1011,6 +1016,11 @@ static int ingenic_drm_bind(struct device *dev, bool 
has_components)
return ret;
}
 
+   ret = devm_add_action_or_reset(dev, ingenic_drm_encoder_cleanup,
+  encoder);
+   if (ret)
+   return ret;
+
ret = drm_bridge_attach(encoder, bridge, NULL, 0);
if (ret) {
dev_err(dev, "Unable to attach bridge\n");
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Change eats memory on my server

2021-01-18 Thread Eli Cohen
On Mon, Jan 18, 2021 at 08:43:12AM +0100, Christian König wrote:
> Hi Eli,
> 
> have you already tried using kmemleak?
> 
> This sounds like a leak of memory allocated using kmalloc(), so kmemleak
> should be able to catch it.
> 

Hi Christian,

I have the following configured but I did not see any visible complaint
in dmesg.

CONFIG_HAVE_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE=16000

Any other configuration that I need to set?
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] drm/ingenic: Fix non-OSD mode

2021-01-18 Thread Paul Cercueil
Even though the JZ4740 did not have the OSD mode, it had (according to
the documentation) two DMA channels, but there is absolutely no
information about how to select the second DMA channel.

Make the ingenic-drm driver work in non-OSD mode by using the
foreground0 plane (which is bound to the DMA0 channel) as the primary
plane, instead of the foreground1 plane, which is the primary plane
when in OSD mode.

Fixes: 3c9bea4ef32b ("drm/ingenic: Add support for OSD mode")
Cc:  # v5.8+
Signed-off-by: Paul Cercueil 
---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c 
b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index d23a3292a0e0..9d883864e078 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -553,7 +553,7 @@ static void ingenic_drm_plane_atomic_update(struct 
drm_plane *plane,
height = state->src_h >> 16;
cpp = state->fb->format->cpp[0];
 
-   if (priv->soc_info->has_osd && plane->type == 
DRM_PLANE_TYPE_OVERLAY)
+   if (!priv->soc_info->has_osd || plane->type == 
DRM_PLANE_TYPE_OVERLAY)
hwdesc = >dma_hwdescs->hwdesc_f0;
else
hwdesc = >dma_hwdescs->hwdesc_f1;
@@ -814,6 +814,7 @@ static int ingenic_drm_bind(struct device *dev, bool 
has_components)
const struct jz_soc_info *soc_info;
struct ingenic_drm *priv;
struct clk *parent_clk;
+   struct drm_plane *primary;
struct drm_bridge *bridge;
struct drm_panel *panel;
struct drm_encoder *encoder;
@@ -928,9 +929,11 @@ static int ingenic_drm_bind(struct device *dev, bool 
has_components)
if (soc_info->has_osd)
priv->ipu_plane = drm_plane_from_index(drm, 0);
 
-   drm_plane_helper_add(>f1, _drm_plane_helper_funcs);
+   primary = priv->soc_info->has_osd ? >f1 : >f0;
 
-   ret = drm_universal_plane_init(drm, >f1, 1,
+   drm_plane_helper_add(primary, _drm_plane_helper_funcs);
+
+   ret = drm_universal_plane_init(drm, primary, 1,
   _drm_primary_plane_funcs,
   priv->soc_info->formats_f1,
   priv->soc_info->num_formats_f1,
@@ -942,7 +945,7 @@ static int ingenic_drm_bind(struct device *dev, bool 
has_components)
 
drm_crtc_helper_add(>crtc, _drm_crtc_helper_funcs);
 
-   ret = drm_crtc_init_with_planes(drm, >crtc, >f1,
+   ret = drm_crtc_init_with_planes(drm, >crtc, primary,
NULL, _drm_crtc_funcs, NULL);
if (ret) {
dev_err(dev, "Failed to init CRTC: %i\n", ret);
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: BUG: unable to handle kernel NULL pointer dereference in fbcon_cursor

2021-01-18 Thread syzbot
syzbot has bisected this issue to:

commit ea40d7857d5250e5400f38c69ef9e17321e9c4a2
Author: Daniel Vetter 
Date:   Fri Oct 9 23:21:56 2020 +

drm/vkms: fbdev emulation support

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=148e2748d0
start commit:   b3a3cbde Add linux-next specific files for 20210115
git tree:   linux-next
final oops: https://syzkaller.appspot.com/x/report.txt?x=168e2748d0
console output: https://syzkaller.appspot.com/x/log.txt?x=128e2748d0
kernel config:  https://syzkaller.appspot.com/x/.config?x=6ea08dae6aab586f
dashboard link: https://syzkaller.appspot.com/bug?extid=b67aaae8d3a927f68d20
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=15cd8fe0d0
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17af5258d0

Reported-by: syzbot+b67aaae8d3a927f68...@syzkaller.appspotmail.com
Fixes: ea40d7857d52 ("drm/vkms: fbdev emulation support")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3] drm/bridge/tc358775: Fixes bus formats read

2021-01-18 Thread Vinay Simha BN
- state->output_bus_cfg.format, memcpy and
  unsigned int used
- atomic_check removed
- video data input and output formats added
- bus formats read from drm_bridge_state.output_bus_cfg.format
  and .atomic_get_input_bus_fmts() instead of connector

Reviewed-by: Laurent Pinchart 
Signed-off-by: Vinay Simha BN 

---
v1:
 * Laurent Pinchart review comments incorporated
   drm_bridge_state.output_bus_cfg.format
   instead of connector
v2:
 * Laurent Pinchart review comments incorporated
   atomic_check removed
   ivideo data input and output formats added

v3:
 * Laurent Pinchart review comments incorporated
   output_bus_fmt removed and using state->output_bus_cfg.format
   unsigned int i used
   memcpy used for input_fmts
---
 drivers/gpu/drm/bridge/tc358775.c | 71 +++
 1 file changed, 54 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358775.c 
b/drivers/gpu/drm/bridge/tc358775.c
index 2272adcc5b4a..a8998dd447ae 100644
--- a/drivers/gpu/drm/bridge/tc358775.c
+++ b/drivers/gpu/drm/bridge/tc358775.c
@@ -273,6 +273,19 @@ struct tc_data {
u8  bpc;
 };
 
+static const u32 tc_lvds_in_bus_fmts[] = {
+   MEDIA_BUS_FMT_RGB565_1X16,
+   MEDIA_BUS_FMT_RGB666_1X18,
+   MEDIA_BUS_FMT_RGB666_1X24_CPADHI,
+   MEDIA_BUS_FMT_RBG888_1X24,
+};
+
+static const u32 tc_lvds_out_bus_fmts[] = {
+   MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,
+   MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
+   MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
+};
+
 static inline struct tc_data *bridge_to_tc(struct drm_bridge *b)
 {
return container_of(b, struct tc_data, bridge);
@@ -359,19 +372,6 @@ static void d2l_write(struct i2c_client *i2c, u16 addr, 
u32 val)
ret, addr);
 }
 
-/* helper function to access bus_formats */
-static struct drm_connector *get_connector(struct drm_encoder *encoder)
-{
-   struct drm_device *dev = encoder->dev;
-   struct drm_connector *connector;
-
-   list_for_each_entry(connector, >mode_config.connector_list, head)
-   if (connector->encoder == encoder)
-   return connector;
-
-   return NULL;
-}
-
 static void tc_bridge_enable(struct drm_bridge *bridge)
 {
struct tc_data *tc = bridge_to_tc(bridge);
@@ -380,7 +380,8 @@ static void tc_bridge_enable(struct drm_bridge *bridge)
u32 val = 0;
u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay;
struct drm_display_mode *mode;
-   struct drm_connector *connector = get_connector(bridge->encoder);
+   struct drm_bridge_state *state =
+   drm_priv_to_bridge_state(bridge->base.state);
 
mode = >encoder->crtc->state->adjusted_mode;
 
@@ -451,14 +452,13 @@ static void tc_bridge_enable(struct drm_bridge *bridge)
d2l_write(tc->i2c, LVPHY0, LV_PHY0_PRBS_ON(4) | LV_PHY0_ND(6));
 
dev_dbg(tc->dev, "bus_formats %04x bpc %d\n",
-   connector->display_info.bus_formats[0],
+   state->output_bus_cfg.format,
tc->bpc);
/*
 * Default hardware register settings of tc358775 configured
 * with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format
 */
-   if (connector->display_info.bus_formats[0] ==
-   MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {
+   if (state->output_bus_cfg.format == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {
/* VESA-24 */
d2l_write(tc->i2c, LV_MX0003, LV_MX(LVI_R0, LVI_R1, LVI_R2, 
LVI_R3));
d2l_write(tc->i2c, LV_MX0407, LV_MX(LVI_R4, LVI_R7, LVI_R5, 
LVI_G0));
@@ -590,6 +590,39 @@ static int tc358775_parse_dt(struct device_node *np, 
struct tc_data *tc)
return 0;
 }
 
+static u32 *
+tc_bridge_get_input_bus_fmts(struct drm_bridge *bridge,
+struct drm_bridge_state *bridge_state,
+struct drm_crtc_state *crtc_state,
+struct drm_connector_state *conn_state,
+u32 output_fmt,
+unsigned int *num_input_fmts)
+{
+   u32 *input_fmts = NULL;
+   unsigned int i;
+
+   *num_input_fmts = 0;
+
+   for (i = 0 ; i < ARRAY_SIZE(tc_lvds_out_bus_fmts) ; ++i) {
+   if (output_fmt == tc_lvds_out_bus_fmts[i])
+   break;
+   }
+
+   if (i == ARRAY_SIZE(tc_lvds_out_bus_fmts))
+   return NULL;
+
+   *num_input_fmts = ARRAY_SIZE(tc_lvds_in_bus_fmts);
+
+   input_fmts = kcalloc(*num_input_fmts, ARRAY_SIZE(tc_lvds_in_bus_fmts),
+GFP_KERNEL);
+   if (!input_fmts)
+   return NULL;
+
+   memcpy(input_fmts, tc_lvds_in_bus_fmts, sizeof(*input_fmts));
+
+   return input_fmts;
+}
+
 static int tc_bridge_attach(struct drm_bridge *bridge,
enum drm_bridge_attach_flags flags)
 {
@@ -639,6 +672,10 @@ static int tc_bridge_attach(struct drm_bridge *bridge,
 }
 
 static const 

[PATCH v3 2/3] drm/bridge/lontium-lt9611uxc: fix get_edid return code

2021-01-18 Thread Dmitry Baryshkov
Return NULL pointer from get_edid() callback rather than ERR_PTR()
pointer, as DRM code does NULL checks rather than IS_ERR(). Also while
we are at it, return NULL if getting EDID timed out.

Signed-off-by: Dmitry Baryshkov 
Fixes: 0cbbd5b1a012 ("drm: bridge: add support for lontium LT9611UXC bridge")
---
 drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c 
b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
index a59e811f1705..b708700e182d 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
@@ -505,7 +505,10 @@ static struct edid *lt9611uxc_bridge_get_edid(struct 
drm_bridge *bridge,
ret = lt9611uxc_wait_for_edid(lt9611uxc);
if (ret < 0) {
dev_err(lt9611uxc->dev, "wait for EDID failed: %d\n", ret);
-   return ERR_PTR(ret);
+   return NULL;
+   } else if (ret == 0) {
+   dev_err(lt9611uxc->dev, "wait for EDID timeout\n");
+   return NULL;
}
 
return drm_do_get_edid(connector, lt9611uxc_get_edid_block, lt9611uxc);
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/3] drm: bridge/panel: Cleanup connector on bridge detach

2021-01-18 Thread Paul Cercueil
If we don't call drm_connector_cleanup() manually in
panel_bridge_detach(), the connector will be cleaned up with the other
DRM objects in the call to drm_mode_config_cleanup(). However, since our
drm_connector is devm-allocated, by the time drm_mode_config_cleanup()
will be called, our connector will be long gone. Therefore, the
connector must be cleaned up when the bridge is detached to avoid
use-after-free conditions.

Fixes: 13dfc0540a57 ("drm/bridge: Refactor out the panel wrapper from the 
lvds-encoder bridge.")
Cc:  # 4.12+
Cc: Andrzej Hajda 
Cc: Neil Armstrong 
Cc: Laurent Pinchart 
Cc: Jonas Karlman 
Cc: Jernej Skrabec 
Signed-off-by: Paul Cercueil 
---
 drivers/gpu/drm/bridge/panel.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
index 0ddc37551194..975d65c14c9c 100644
--- a/drivers/gpu/drm/bridge/panel.c
+++ b/drivers/gpu/drm/bridge/panel.c
@@ -87,6 +87,10 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
 
 static void panel_bridge_detach(struct drm_bridge *bridge)
 {
+   struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
+   struct drm_connector *connector = _bridge->connector;
+
+   drm_connector_cleanup(connector);
 }
 
 static void panel_bridge_pre_enable(struct drm_bridge *bridge)
-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Change eats memory on my server

2021-01-18 Thread Eli Cohen
On Fri, Jan 15, 2021 at 10:03:50AM +0100, Thomas Zimmermann wrote:
> 
> Could you please double-check that 3fb91f56aea4 ("drm/udl: Retrieve USB
> device from struct drm_device.dev") works correctly

Checked again, it does not seem to leak.

> and that 823efa922102
> ("drm/cma-helper: Remove empty drm_gem_cma_prime_vunmap()") is broken?
>

Yes, this one leaks, as does the one preceding it: 

1086db71a1db ("drm/vram-helper: Remove invariant parameters from internal kmap 
function")
 
> For one of the broken commits, could you please send us the output of
> 
>   dmesg | grep -i drm
> 
> after most of the memory got leaked?
> 

I ran the following script in the shell:

while true; do cat /proc/meminfo | grep MemFree:; sleep 5; done

and this is what I saw before I got disconnected from the shell:

MemFree:  148208 kB
MemFree:  148304 kB
MemFree:  146660 kB
Connection to nps-server-24 closed by remote host.
Connection to nps-server-24 closed.


I also mointored the output of dmesg | grep -i drm
The last output I was able to save on disk is this:

[   46.140720] ast :03:00.0: [drm] Using P2A bridge for configuration
[   46.140737] ast :03:00.0: [drm] AST 2500 detected
[   46.140754] ast :03:00.0: [drm] Analog VGA only
[   46.140772] ast :03:00.0: [drm] dram MCLK=800 Mhz type=7 bus_width=16
[   46.153553] [drm] Initialized ast 0.1.0 20120228 for :03:00.0 on minor 0
[   46.165097] fbcon: astdrmfb (fb0) is primary device
[   46.391381] ast :03:00.0: [drm] fb0: astdrmfb frame buffer device
[   56.097697] systemd[1]: Starting Load Kernel Module drm...
[   56.343556] systemd[1]: modprobe@drm.service: Succeeded.
[   56.350382] systemd[1]: Finished Load Kernel Module drm.
[13319.469462] [   2683] 70889  268355586073728  138
 0 tdrm
[13320.658386] [   2683] 70889  268355586073728  138
 0 tdrm
[13321.800970] [   2683] 70889  268355586073728  138
 0 tdrm
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/3] Fixes to bridge/panel and ingenic-drm

2021-01-18 Thread Paul Cercueil
Hi,

Here are three independent fixes. The first one addresses a
use-after-free in bridge/panel.c; the second one addresses a
use-after-free in the ingenic-drm driver; finally, the third one makes
the ingenic-drm driver work again on older Ingenic SoCs.

Cheers,
-Paul

Paul Cercueil (3):
  drm: bridge/panel: Cleanup connector on bridge detach
  drm/ingenic: Register devm action to cleanup encoders
  drm/ingenic: Fix non-OSD mode

 drivers/gpu/drm/bridge/panel.c|  4 
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 21 +
 2 files changed, 21 insertions(+), 4 deletions(-)

-- 
2.29.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   >