Re: [PATCH] drm/radeon: fix a missing-check bug

2018-10-19 Thread Koenig, Christian
Am 18.10.18 um 19:13 schrieb Wenwen Wang:
> In radeon_read_bios(), the bios rom is firstly mapped to the IO memory
> region 'bios' through pci_map_rom(). Then the first two bytes of 'bios' are
> copied to 'val1' and 'val2' respectively through readb(). After that,
> 'val1' and 'val2' are checked to see whether they have expected values,
> i.e., 0x55 and 0xaa, respectively. If yes, the whole data in 'bios' is then
> copied to 'rdev->bios' through memcpy_fromio(). Obviously, the first two
> bytes in 'bios' are copied twice. More importantly, no check is enforced on
> the first two bytes of 'rdev->bios' after memcpy_fromio(). Given that the
> IO memory region can also be accessed by the device, it is possible that a
> malicious device can race to modify these two bytes between the two copies
> and thus after memcpy_fromio(), the first two bytes in 'rdev->bios' can
> have unexpected values.  This can cause undefined behavior of the kernel
> and introduce potential security risk, if the device can be controlled by
> attackers.
>
> This patch rewrites the first two bytes of 'rdev->bios' after
> memcpy_fromio() with expected values. Through this way, the above issue can
> be avoided.

Well NAK, that doesn't make any sense to me.

First of all we don't map VRAM, but rather the ROM which is a read only 
flash. Writing to the flash is not supported through the BAR as far as I 
know.

Then we check the first two bytes to make sure that the ROM is correctly 
mapped and not to prevent any malicious attacks.

Regards,
Christian.

>
> Signed-off-by: Wenwen Wang 
> ---
>   drivers/gpu/drm/radeon/radeon_bios.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_bios.c 
> b/drivers/gpu/drm/radeon/radeon_bios.c
> index 04c0ed4..f336719 100644
> --- a/drivers/gpu/drm/radeon/radeon_bios.c
> +++ b/drivers/gpu/drm/radeon/radeon_bios.c
> @@ -98,6 +98,8 @@ static bool radeon_read_bios(struct radeon_device *rdev)
>   return false;
>   }
>   memcpy_fromio(rdev->bios, bios, size);
> + rdev->bios[0] = val1;
> + rdev->bios[1] = val2;
>   pci_unmap_rom(rdev->pdev, bios);
>   return true;
>   }

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


Re: [PATCH 1/3] drm/sched: Add callback to mark if sched is ready to work.

2018-10-19 Thread Koenig, Christian
Am 18.10.18 um 20:44 schrieb Andrey Grodzovsky:
> Problem:
> A particular scheduler may become unsuable (underlying HW) after
> some event (e.g. GPU reset). If it's later chosen by
> the get free sched. policy a command will fail to be
> submitted.
>
> Fix:
> Add a driver specific callback to report the sced. status so
> rq with bad sched. can be avoided in favor of working one or
> none in which case job init will fail.

I would rather go with the approach of moving the ready flag completely 
into the scheduler instead.

Christian.

>
> Signed-off-by: Andrey Grodzovsky 
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c |  9 -
>   drivers/gpu/drm/etnaviv/etnaviv_sched.c   |  3 ++-
>   drivers/gpu/drm/scheduler/sched_entity.c  | 11 ++-
>   drivers/gpu/drm/scheduler/sched_main.c|  8 +++-
>   drivers/gpu/drm/v3d/v3d_sched.c   |  3 ++-
>   include/drm/gpu_scheduler.h   |  5 -
>   6 files changed, 33 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> index 5448cf2..bbfe7f501 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> @@ -404,6 +404,13 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring 
> *ring,
>   return 0;
>   }
>   
> +static bool amdgpu_ring_ready(struct drm_gpu_scheduler *sched)
> +{
> + struct amdgpu_ring *ring = to_amdgpu_ring(sched);
> +
> + return ring->ready;
> +}
> +
>   /**
>* amdgpu_fence_driver_init_ring - init the fence driver
>* for the requested ring.
> @@ -450,7 +457,7 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring 
> *ring,
>   
>   r = drm_sched_init(&ring->sched, &amdgpu_sched_ops,
>  num_hw_submission, amdgpu_job_hang_limit,
> -timeout, ring->name);
> +timeout, ring->name, amdgpu_ring_ready);
>   if (r) {
>   DRM_ERROR("Failed to create scheduler on ring %s.\n",
> ring->name);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> index f8c5f1e..5094013 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> @@ -178,7 +178,8 @@ int etnaviv_sched_init(struct etnaviv_gpu *gpu)
>   
>   ret = drm_sched_init(&gpu->sched, &etnaviv_sched_ops,
>etnaviv_hw_jobs_limit, etnaviv_job_hang_limit,
> -  msecs_to_jiffies(500), dev_name(gpu->dev));
> +  msecs_to_jiffies(500), dev_name(gpu->dev),
> +  NULL);
>   if (ret)
>   return ret;
>   
> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c 
> b/drivers/gpu/drm/scheduler/sched_entity.c
> index 3e22a54..320c77a 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -130,7 +130,16 @@ drm_sched_entity_get_free_sched(struct drm_sched_entity 
> *entity)
>   int i;
>   
>   for (i = 0; i < entity->num_rq_list; ++i) {
> - num_jobs = atomic_read(&entity->rq_list[i]->sched->num_jobs);
> + struct drm_gpu_scheduler *sched = entity->rq_list[i]->sched;
> +
> + if (entity->rq_list[i]->sched->ready &&
> + !entity->rq_list[i]->sched->ready(sched)) {
> + DRM_WARN("sched%s is not ready, skipping", sched->name);
> +
> + continue;
> + }
> +
> + num_jobs = atomic_read(&sched->num_jobs);
>   if (num_jobs < min_jobs) {
>   min_jobs = num_jobs;
>   rq = entity->rq_list[i];
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
> b/drivers/gpu/drm/scheduler/sched_main.c
> index 63b997d..6b151f2 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -420,6 +420,9 @@ int drm_sched_job_init(struct drm_sched_job *job,
>   struct drm_gpu_scheduler *sched;
>   
>   drm_sched_entity_select_rq(entity);
> + if (!entity->rq)
> + return -ENOENT;
> +
>   sched = entity->rq->sched;
>   
>   job->sched = sched;
> @@ -606,7 +609,8 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
>  unsigned hw_submission,
>  unsigned hang_limit,
>  long timeout,
> -const char *name)
> +const char *name,
> +bool (*ready)(struct drm_gpu_scheduler *sched))
>   {
>   int i;
>   sched->ops = ops;
> @@ -633,6 +637,8 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
>   return PTR_ERR(sched->thread);
>   }
>   
> + sched->ready = ready;
> +
>   return 0;
>   }
>   EXPORT_SYMBOL(drm_sched_init);
> diff --git a/drivers/gpu/drm/v3d/v3d_sched.c

Re: [PULL] drm-intel-next-fixes

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 8:59 AM Joonas Lahtinen
 wrote:
>
> Quoting Daniel Vetter (2018-10-18 22:32:00)
> > On Thu, Oct 18, 2018 at 6:57 PM Joonas Lahtinen
> >  wrote:
> > >
> > > Hi Dave,
> > >
> > > Here comes the final set of fixes under -next-fixes umbrella.
> > > Next one will be then from -fixes, assuming a release next Sun.
> > >
> > > Fixes for bunch of display related issues reported by users, then the
> > > MST fixes that were dropped from Rodrigos PR + further Icelake fixes
> > > and proactive improvements picked by tooling.
> > >
> > > Excuse for the slight accumulation as I skipped last week due to
> > > travel like I warned.
> > >
> > > Regards, Joonas
> > >
> > > ***
> > >
> > > drm-intel-next-fixes-2018-10-18:
> > > - Fix GPU hang on MacBook2,1 when booting in EFI mode (Bugzilla #105637)
> > > - Fix garbled console on Y tiled BIOS framebuffer configs (Bugzilla 
> > > #108264)
> > > - Fix black screen on certain eDP panels eg. Dell XPS 9350 (Bugzilla 
> > > #107489 and #105338)
> > > - MST fixes that Rodrigo dropped from drm-intel-fixes and bunch of 
> > > Icelake fixes
> >
> > This won't work because it doesn't contain Lyude's core fix (+ the 2
> > fixups). You either need to cherry-pick all of them (and then probably
> > include the nouveau one), or none of them. Did the cherry-pick script
> > not propose them, or something else? They're all cc: stable.
>
> cherry-pick-next-fixes did not propose more. I did specifically ask
> Rodrigo to drop the relevant stuff from drm-intel-fixes so that the
> tooling would pick it up. What is there that is missing?

dim cherry-pick-branch is limited to drivers/gpu/drm/i915 :-(

Remove that (well at least only filter drm/) and you should see them.
Ideally you put the core patch + 2 core fixups before the i915/nouveau
patches.

I guess putting core patches that are bugfixes through drm-intel.git
really isn't a good idea with our process ...
-Daniel

>
> Regards, Joonas
>
> > -Daniel
> >
> > > - Then assorted proactive code fixes caught by CI or developers
> > >
> > > The following changes since commit 
> > > ca4b869240d5810ebac6b1570ad7beffcfbac2f5:
> > >
> > >   Merge branch 'drm-next-4.20' of 
> > > git://people.freedesktop.org/~agd5f/linux into drm-next (2018-10-11 
> > > 14:53:45 +1000)
> > >
> > > are available in the Git repository at:
> > >
> > >   git://anongit.freedesktop.org/drm/drm-intel 
> > > tags/drm-intel-next-fixes-2018-10-18
> > >
> > > for you to fetch changes up to 835fe6d75d14c1513910ed7f5665127fee12acc8:
> > >
> > >   firmware/dmc/icl: Add missing MODULE_FIRMWARE() for Icelake. 
> > > (2018-10-18 10:36:10 +0300)
> > >
> > > 
> > > - Fix GPU hang on MacBook2,1 when booting in EFI mode (Bugzilla #105637)
> > > - Fix garbled console on Y tiled BIOS framebuffer configs (Bugzilla 
> > > #108264)
> > > - Fix black screen on certain eDP panels eg. Dell XPS 9350 (Bugzilla 
> > > #107489 and #105338)
> > > - MST fixes that Rodrigo dropped from drm-intel-fixes and bunch of 
> > > Icelake fixes
> > > - Then assorted proactive code fixes caught by CI or developers
> > >
> > > 
> > > Anusha Srivatsa (1):
> > >   firmware/dmc/icl: Add missing MODULE_FIRMWARE() for Icelake.
> > >
> > > Chris Wilson (3):
> > >   drm/i915: Only reset seqno if actually idle
> > >   drm/i915/selftests: Disable shrinker across mmap-exhaustion
> > >   drm/i915: Large page offsets for pread/pwrite
> > >
> > > Imre Deak (1):
> > >   drm/i915/gen9+: Fix initial readout for Y tiled framebuffers
> > >
> > > Lyude Paul (3):
> > >   drm/i915: Don't unset intel_connector->mst_port
> > >   drm/i915: Skip vcpi allocation for MSTB ports that are gone
> > >   drm/i915: Fix intel_dp_mst_best_encoder()
> > >
> > > Mahesh Kumar (2):
> > >   drm/i915/icl: create function to identify combophy port
> > >   drm/i915/icl: Fix DDI/TC port clk_off bits
> > >
> > > Manasi Navare (1):
> > >   drm/i915/dp: Link train Fallback on eDP only if fallback link BW 
> > > can fit panel's native mode
> > >
> > > Rodrigo Vivi (1):
> > >   drm/i915/icl: Fix signal_levels
> > >
> > > Ville Syrjälä (3):
> > >   drm/i915: Check fb stride against plane max stride
> > >   drm/i915: Restore vblank interrupts earlier
> > >   drm/i915: Use the correct crtc when sanitizing plane mapping
> > >
> > >  drivers/gpu/drm/i915/i915_debugfs.c  |   2 +-
> > >  drivers/gpu/drm/i915/i915_gem.c  |  12 +-
> > >  drivers/gpu/drm/i915/i915_reg.h  |   3 +
> > >  drivers/gpu/drm/i915/intel_csr.c |   1 +
> > >  drivers/gpu/drm/i915/intel_ddi.c |  36 --
> > >  drivers/gpu/drm/i915/intel_display.c | 151 
> > > ---
> > >  drivers/gpu/drm/i915/intel_dp.c  |  32 -
> > >  drivers/gpu/drm/i915/intel_dp_link_training.c|  26 

Re: [PATCH 3/3] drm/amdgpu: Refresh rq selection for job after ASIC reset

2018-10-19 Thread Koenig, Christian
Am 18.10.18 um 20:44 schrieb Andrey Grodzovsky:
> A ring might become unusable after reset, if that the case
> drm_sched_entity_select_rq will choose another, working rq
> to run the job if there is one.
> Also, skip recovery of ring which is not ready.

Well that is not even remotely sufficient.

If we can't bring up a ring any more after a reset we would need to move 
all jobs which where previously scheduled on it and all of its entities 
to a different instance.

What you do here breaks dependencies between jobs and can result in 
unforeseen consequences including random memory writes.

As far as I can see that can't be done correctly with the current 
scheduler design.

Additional to that when we can't restart one instance of a ring we 
usually can't restart all others either. So the whole approach is rather 
pointless.

Regards,
Christian.

>
> Signed-off-by: Andrey Grodzovsky 
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++-
>   1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index d11489e..3124ca1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -3355,10 +3355,24 @@ int amdgpu_device_gpu_recover(struct amdgpu_device 
> *adev,
>   else
>   r = amdgpu_device_reset(adev);
>   
> + /*
> +  * After reboot a ring might fail in which case this will
> +  * move the job to different rq if possible
> +  */
> + if (job) {
> + drm_sched_entity_select_rq(job->base.entity);
> + if (job->base.entity->rq) {
> + job->base.sched = job->base.entity->rq->sched;
> + } else {
> + job->base.sched = NULL;
> + r = -ENOENT;
> + }
> + }
> +
>   for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
>   struct amdgpu_ring *ring = adev->rings[i];
>   
> - if (!ring || !ring->sched.thread)
> + if (!ring || !ring->ready || !ring->sched.thread)
>   continue;
>   
>   /* only need recovery sched of the given job's ring

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


Re: [Patch v4 5/8] drm/omap: Add global state as a private atomic object

2018-10-19 Thread Daniel Vetter
On Thu, Oct 18, 2018 at 08:11:30AM -0500, Benoit Parrot wrote:
> Daniel Vetter  wrote on Tue [2018-Oct-16 14:29:46 +0200]:
> > On Fri, Oct 12, 2018 at 03:17:00PM -0500, Benoit Parrot wrote:
> > > Global shared resources (like hw overlays) for omapdrm are implemented
> > > as a part of atomic state using the drm_private_obj infrastructure
> > > available in the atomic core.
> > > 
> > > omap_global_state is introduced as a drm atomic private object. The two
> > > funcs omap_get_global_state() and omap_get_existing_global_state() are
> > > the two variants that will be used to access omap_global_state.
> > > 
> > > Signed-off-by: Benoit Parrot 
> > > ---
> > >  drivers/gpu/drm/omapdrm/omap_drv.c | 97 
> > > +-
> > >  drivers/gpu/drm/omapdrm/omap_drv.h | 23 +
> > >  2 files changed, 119 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
> > > b/drivers/gpu/drm/omapdrm/omap_drv.c
> > > index 2921cc90f2d8..94658ec79c76 100644
> > > --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> > > +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> > > @@ -129,6 +129,94 @@ static const struct drm_mode_config_funcs 
> > > omap_mode_config_funcs = {
> > >   .atomic_commit = drm_atomic_helper_commit,
> > >  };
> > >  
> > > +/* Global/shared object state funcs */
> > > +
> > > +/*
> > > + * This is a helper that returns the private state currently in 
> > > operation.
> > > + * Note that this would return the "old_state" if called in the atomic 
> > > check
> > > + * path, and the "new_state" after the atomic swap has been done.
> > > + */
> > > +struct omap_global_state *
> > > +omap_get_existing_global_state(struct omap_drm_private *priv)
> > > +{
> > > + return to_omap_global_state(priv->glob_obj.state);
> > > +}
> > > +
> > > +/*
> > > + * This acquires the modeset lock set aside for global state, creates
> > > + * a new duplicated private object state.
> > > + */
> > > +struct omap_global_state *__must_check
> > > +omap_get_global_state(struct drm_atomic_state *s)
> > > +{
> > > + struct omap_drm_private *priv = s->dev->dev_private;
> > > + struct drm_private_state *priv_state;
> > > + int ret;
> > > +
> > > + if (!drm_modeset_is_locked(&priv->glob_obj_lock)) {
> > > + ret = drm_modeset_lock(&priv->glob_obj_lock, s->acquire_ctx);
> > > + if (ret) {
> > > + DBG("getting priv->glob_obj_lock (%p) failed %d",
> > > + &priv->glob_obj_lock, ret);
> > > + return ERR_PTR(ret);
> > > + }
> > > + }
> > > +
> > > + priv_state = drm_atomic_get_private_obj_state(s, &priv->glob_obj);
> > 
> > One of the refactors I had in mind (and which would be possible now that
> > private state structs are implemented as properly structs, instead of void
> > * pointers): Add a drm_modeset_lock to drm_private_obj and avoid having to
> > duplicate that over all implementations. Not everyone wants a per-obj
> > lock, but no one will be hurt by having a per-obj lock - drm_modeset_lock
> > is very extensible in that way. And we could drop the custom locking code
> > everyone has to roll themselves.
> 
> Thanks for the feedback. I was wondering the same when I was "duplicating"
> this code. I will take this under advisement, but I would probably see that
> as a separate patch set, either before or after this one :) 

Sure. Also note that this came up with a recent vc4 patch series by Boris
Brezillion "[RFC PATCH] drm/vc4: Add a load tracker to prevent HVS
underflow errors", so maybe you folks can work together.
-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 1/3] drm/sched: Add callback to mark if sched is ready to work.

2018-10-19 Thread Michel Dänzer
On 2018-10-18 8:44 p.m., Andrey Grodzovsky wrote:
> Problem:
> A particular scheduler may become unsuable (underlying HW) after
> some event (e.g. GPU reset). If it's later chosen by
> the get free sched. policy a command will fail to be
> submitted.
> 
> Fix:
> Add a driver specific callback to report the sced. status so
> rq with bad sched. can be avoided in favor of working one or
> none in which case job init will fail.
> 
> Signed-off-by: Andrey Grodzovsky 
> 
> [...]
>  
> @@ -450,7 +457,7 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring 
> *ring,
>  
>   r = drm_sched_init(&ring->sched, &amdgpu_sched_ops,
>  num_hw_submission, amdgpu_job_hang_limit,
> -timeout, ring->name);
> +timeout, ring->name, amdgpu_ring_ready);
>   if (r) {
>   DRM_ERROR("Failed to create scheduler on ring %s.\n",
> ring->name);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> index f8c5f1e..5094013 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> @@ -178,7 +178,8 @@ int etnaviv_sched_init(struct etnaviv_gpu *gpu)
>  
>   ret = drm_sched_init(&gpu->sched, &etnaviv_sched_ops,
>etnaviv_hw_jobs_limit, etnaviv_job_hang_limit,
> -  msecs_to_jiffies(500), dev_name(gpu->dev));
> +  msecs_to_jiffies(500), dev_name(gpu->dev),
> +  NULL);

Indentation looks wrong for the NULL here...


> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c 
> b/drivers/gpu/drm/scheduler/sched_entity.c
> index 3e22a54..320c77a 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -130,7 +130,16 @@ drm_sched_entity_get_free_sched(struct drm_sched_entity 
> *entity)
>   int i;
>  
>   for (i = 0; i < entity->num_rq_list; ++i) {
> - num_jobs = atomic_read(&entity->rq_list[i]->sched->num_jobs);
> + struct drm_gpu_scheduler *sched = entity->rq_list[i]->sched;
> +
> + if (entity->rq_list[i]->sched->ready &&
> + !entity->rq_list[i]->sched->ready(sched)) {

... the second line of the if here...


> diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
> index 80b641f..e06cc0d 100644
> --- a/drivers/gpu/drm/v3d/v3d_sched.c
> +++ b/drivers/gpu/drm/v3d/v3d_sched.c
> @@ -212,7 +212,8 @@ v3d_sched_init(struct v3d_dev *v3d)
>&v3d_sched_ops,
>hw_jobs_limit, job_hang_limit,
>msecs_to_jiffies(hang_limit_ms),
> -  "v3d_bin");
> +  "v3d_bin",
> +  NULL);

... the NULL here...


> diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
> index 0684dcd..a6e18fe 100644
> --- a/include/drm/gpu_scheduler.h
> +++ b/include/drm/gpu_scheduler.h
> @@ -283,12 +283,15 @@ struct drm_gpu_scheduler {
>   spinlock_t  job_list_lock;
>   int hang_limit;
>   atomic_tnum_jobs;
> +
> + bool(*ready)(struct drm_gpu_scheduler *sched);
>  };

... and the new line here.

Which editor are you using?


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [git pull] drm fixes for 4.19 final

2018-10-19 Thread Greg Kroah-Hartman
On Fri, Oct 19, 2018 at 02:59:11PM +1000, Dave Airlie wrote:
> Hi Greg,
> 
> Just a last set of misc core fixes for final.
> 
> 4 fixes, one use after free, one fb integration fix, one EDID fix, and
> one laptop panel quirk,
> 
> Thanks,
> Dave.
> 
> drm-fixes-2018-10-19:
> drm: one set of misc fixes for final release
> The following changes since commit 35a7f35ad1b150ddf59a41dcac7b2fa32982be0e:
> 
>   Linux 4.19-rc8 (2018-10-15 07:20:24 +0200)
> 
> are available in the Git repository at:
> 
>   git://anongit.freedesktop.org/drm/drm tags/drm-fixes-2018-10-19

Now merged, thanks.

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


Re: [Outreachy kernel] [PATCH DRM] drm: msm: adreno: Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) +PTR_ERR

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 08:18:52AM +0200, Julia Lawall wrote:
> On Fri, 19 Oct 2018, Mamta Shukla wrote:
> > Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR because its
> > better to have inlined function rather than code-opened implementation.
> 
> 
> Just for your information, people have mixed feelings about this.  In your
> case, it's probably fine, because this is the only if in the function.
> But when there is a series of if (...) return; followed by a return 0; at
> the end, people ofen prefer to keep it as it is, so the last case doesn't
> look different than the others.

Yeah I asked the maintainer for this driver for an ack, the other patches
look good, will merged them as soon as I have the answer for this one
here.

Mamta, since you'll have a few things merged already with these I think
it's a good time to start looking into bigger tasks and figuring out what
you might want to do in your internship:

https://dri.freedesktop.org/docs/drm/gpu/todo.html

Since this todo list is very unstructured it's best to discuss a bit over
irc what you would want to, and what makes sense as an internship.

Thanks, Daniel
> 
> julia
> 
> >
> > Signed-off-by: Mamta Shukla 
> > ---
> >  drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 5 +
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
> > b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> > index 6a68493..b751b76 100644
> > --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> > +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> > @@ -1222,10 +1222,7 @@ static int a5xx_crashdumper_init(struct msm_gpu *gpu,
> > SZ_1M, MSM_BO_UNCACHED, gpu->aspace,
> > &dumper->bo, &dumper->iova);
> >
> > -   if (IS_ERR(dumper->ptr))
> > -   return PTR_ERR(dumper->ptr);
> > -
> > -   return 0;
> > +   return PTR_ERR_OR_ZERO(dumper->ptr);
> >  }
> >
> >  static void a5xx_crashdumper_free(struct msm_gpu *gpu,
> > --
> > 1.9.1
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "outreachy-kernel" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to outreachy-kernel+unsubscr...@googlegroups.com.
> > To post to this group, send email to outreachy-ker...@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/outreachy-kernel/20181018204815.GA23390%40armorer.
> > For more options, visit https://groups.google.com/d/optout.
> >

-- 
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


[Bug 107928] Screen regularly turns black, reboot needed

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=107928

--- Comment #12 from Michel Dänzer  ---
(In reply to Matthew Vaughn from comment #11)
> Downgrading from x11-drivers/xf86-video-amdgpu-18.1.0 to
> x11-drivers/xf86-video-amdgpu-18.0.1 has prevented the issue from occurring
> on my system.

Can you bisect xf86-video-amdgpu?

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


Re: [PATCH 0/3] Provide struct ttm_global for TTM global state

2018-10-19 Thread Koenig, Christian
Hi Thomas,

I honestly still find that way to complicated compared to what it 
actually does.

Both ttm_mem_global and ttm_bo_global can just be some static variables. 
E.g. the whole handling with drm_global_reference is just superfluous.

Can I just write a patch to clean up the mess we created?

Regards,
Christian.

Am 18.10.18 um 18:27 schrieb Thomas Zimmermann:
> TTM provides global memory and a global BO that is shared by all
> TTM-based drivers. The data structures are provided by struct drm_global
> and its helpers. All TTM-based DRM drivers copy the initialization and
> clean-up code for the global TTM state from each other; leading to code
> duplication.
>
> The new structure struct ttm_global and its helpers provide a unified
> implementation. Drivers only have to initialize it and forward the
> contained BO global object to ttm_bo_device_init().
>
> The amdgpu and radeon drivers are converted to struct ttm_global as
> part of this patch set. All other TTM-based drivers share exactly the
> same code patterns and can be converted in the same way.
>
> Future directions: I already have patches for converting the remaining
> TTM drivers to struct ttm_global. These patches can be merged after
> the structure has become available in upstream. struct ttm_global is
> implemented on top of struct drm_global. The latter actually maintains
> TTM state instead of DRM state. Once all drivers have been converted,
>  the code for struct drm_global can be merged into struct ttm_global.
>
> (Resending this patch set, as I forgot to CC the mailing lists as first.)
>
> Thomas Zimmermann (3):
>drm/ttm: Provide struct ttm_global for referencing TTM global state
>drm/amdgpu: Replace TTM initialization/release with ttm_global
>drm/radeon: Replace TTM initialization/release with ttm_global
>
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 63 ++--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  4 +-
>   drivers/gpu/drm/radeon/radeon.h |  4 +-
>   drivers/gpu/drm/radeon/radeon_ttm.c | 40 ++
>   drivers/gpu/drm/ttm/Makefile|  2 +-
>   drivers/gpu/drm/ttm/ttm_global.c| 98 +
>   include/drm/drm_global.h|  8 ++
>   include/drm/ttm/ttm_global.h| 79 
>   8 files changed, 200 insertions(+), 98 deletions(-)
>   create mode 100644 drivers/gpu/drm/ttm/ttm_global.c
>   create mode 100644 include/drm/ttm/ttm_global.h
>
> --
> 2.19.1
>

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


Re: [PATCH] drm: panel-orientation-quirks: Do rotation quirk for new GPD Win2 FW

2018-10-19 Thread Hans de Goede

Hi,

On 18-10-18 21:31, Gabriel Krisman Bertazi wrote:

I just got a new GDP Win2 device with an updated firmware, which still
requires this quirk to get the rotation right, so add the new firmware
date to the quirk matching table.

This should go to drm-misc-next.

Signed-off-by: Gabriel Krisman Bertazi 


Thanks for the patch and this looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
  drivers/gpu/drm/drm_panel_orientation_quirks.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c 
b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 280a41d33081..b0bf5a55ae9a 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -57,7 +57,7 @@ static const struct drm_dmi_panel_orientation_data gpd_win2 = 
{
.width = 720,
.height = 1280,
.bios_dates = (const char * const []){
-   "12/07/2017", "05/24/2018", NULL },
+   "12/07/2017", "05/24/2018", "06/29/2018", NULL },
.orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
  };
  


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


Re: [PATCH 2/3] drm/amdgpu: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Hi,

thanks for reviewing the patch.

Am 19.10.18 um 08:18 schrieb Zhang, Jerry(Junwei):
> On 10/19/2018 12:27 AM, Thomas Zimmermann wrote:
>>   /**
>>    * amdgpu_ttm_global_init - Initialize global TTM memory reference
>> structures.
>>    *
>> @@ -102,35 +75,15 @@ static void amdgpu_ttm_mem_global_release(struct
>> drm_global_reference *ref)
>>    */
>>   static int amdgpu_ttm_global_init(struct amdgpu_device *adev)
>>   {
>> -    struct drm_global_reference *global_ref;
>>   int r;
>>     /* ensure reference is false in case init fails */
>>   adev->mman.mem_global_referenced = false;
>>   -    global_ref = &adev->mman.mem_global_ref;
>> -    global_ref->global_type = DRM_GLOBAL_TTM_MEM;
>> -    global_ref->size = sizeof(struct ttm_mem_global);
>> -    global_ref->init = &amdgpu_ttm_mem_global_init;
>> -    global_ref->release = &amdgpu_ttm_mem_global_release;
>> -    r = drm_global_item_ref(global_ref);
>> +    r = ttm_global_init(&adev->mman.glob);
>>   if (r) {
>> -    DRM_ERROR("Failed setting up TTM memory accounting "
>> -  "subsystem.\n");
>> -    goto error_mem;
>> -    }
>> -
>> -    adev->mman.bo_global_ref.mem_glob =
>> -    adev->mman.mem_global_ref.object;
> 
> Seems to miss this action.

Should be fine. This was a workaround for setting up the global BO's
memory. It received the value that is here stored in
adev->mman.bo_global_ref.mem_glob.

Earlier this week, a patch set was merged into the TTM tree that cleans
up the init interfaces of ttm_bo_global. [1] There's now

  int ttm_bo_global_init(struct ttm_bo_global *glob,
 struct ttm_mem_global *mem_glob)

which takes the the global memory as second argument. In patch [1/3] we
call ttm_bo_global_init() from ttm_global_init_bo() with the correct
global memory.

So this workaround is not needed any longer.

> Or are you going to replace
>   struct ttm_bo_global_ref bo_global_ref
> with
>   struct ttm_global glob ->  struct drm_global_reference bo_ref
> 
> if so, may need to remove ttm_bo_global_ref_init() and struct
> ttm_bo_global_ref at the same time.
> 
> 

I have a patch set for removing ttm_bo_global_ref and its interfaces,
but it has to wait until all drivers have been converted to struct
ttm_global. struct drm_global_reference will then become an
implementation detail of struct ttm_global and can be removed from DRM's
public interfaces.

Best regards
Thomas

[1]
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=drm-next-4.21-wip&id=1fbb364ae523177bd0fac81d32befb3c9eb1b37e

> Regards,
> Jerry
> 
>> -    global_ref = &adev->mman.bo_global_ref.ref;
>> -    global_ref->global_type = DRM_GLOBAL_TTM_BO;
>> -    global_ref->size = sizeof(struct ttm_bo_global);
>> -    global_ref->init = &ttm_bo_global_ref_init;
>> -    global_ref->release = &ttm_bo_global_ref_release;
>> -    r = drm_global_item_ref(global_ref);
>> -    if (r) {
>> -    DRM_ERROR("Failed setting up TTM BO subsystem.\n");
>> -    goto error_bo;
>> +    DRM_ERROR("Failed setting up TTM subsystem.\n");
>> +    return r;
>>   }
>>     mutex_init(&adev->mman.gtt_window_lock);
>> @@ -138,19 +91,13 @@ static int amdgpu_ttm_global_init(struct
>> amdgpu_device *adev)
>>   adev->mman.mem_global_referenced = true;
>>     return 0;
>> -
>> -error_bo:
>> -    drm_global_item_unref(&adev->mman.mem_global_ref);
>> -error_mem:
>> -    return r;
>>   }
>>     static void amdgpu_ttm_global_fini(struct amdgpu_device *adev)
>>   {
>>   if (adev->mman.mem_global_referenced) {
>>   mutex_destroy(&adev->mman.gtt_window_lock);
>> -    drm_global_item_unref(&adev->mman.bo_global_ref.ref);
>> -    drm_global_item_unref(&adev->mman.mem_global_ref);
>> +    ttm_global_release(&adev->mman.glob);
>>   adev->mman.mem_global_referenced = false;
>>   }
>>   }
>> @@ -1765,7 +1712,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
>>   }
>>   /* No others user of address space so set it to 0 */
>>   r = ttm_bo_device_init(&adev->mman.bdev,
>> -   adev->mman.bo_global_ref.ref.object,
>> +   ttm_global_get_bo_global(&adev->mman.glob),
>>  &amdgpu_bo_driver,
>>  adev->ddev->anon_inode->i_mapping,
>>  DRM_FILE_PAGE_OFFSET,
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>> index fe8f276e9811..c3a7fe3ead3a 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>> @@ -26,6 +26,7 @@
>>     #include "amdgpu.h"
>>   #include 
>> +#include 
>>     #define AMDGPU_PL_GDS    (TTM_PL_PRIV + 0)
>>   #define AMDGPU_PL_GWS    (TTM_PL_PRIV + 1)
>> @@ -39,8 +40,7 @@
>>   #define AMDGPU_GTT_NUM_TRANSFER_WINDOWS    2
>>     struct amdgpu_mman {
>> -    struct ttm_bo_global_ref    bo_global_ref;
>> -    struct drm_global_reference    mem_global_ref;
>> +    struct ttm_globa

Re: [PATCH 1/3] drm/ttm: Provide struct ttm_global for referencing TTM global state

2018-10-19 Thread Thomas Zimmermann
Hi,

thanks for the review.

Am 19.10.18 um 05:30 schrieb Huang Rui:
> On Fri, Oct 19, 2018 at 12:27:50AM +0800, Thomas Zimmermann wrote:
>> +int ttm_global_init(struct ttm_global *glob)
>> +{
>> +int ret;
>> +
> 
> We would better add a protection here to make sure the glob is not NULL.
> 
> if (!glob)
> return -EINVAL;

Passing a NULL pointer is a programming error, not a runtime error. I'd
rather use BUG_ON() for this test. Ok?

Best regards
Thomas

> 
> Others, look good for me.
> 
> Thanks,
> Ray
> 
>> +glob->mem_ref.global_type = DRM_GLOBAL_TTM_MEM;
>> +glob->mem_ref.size = sizeof(struct ttm_mem_global);
>> +glob->bo_ref.object = NULL;
>> +glob->mem_ref.init = &ttm_global_init_mem;
>> +glob->mem_ref.release = &ttm_global_release_mem;
>> +ret = drm_global_item_ref(&glob->mem_ref);
>> +if (ret)
>> +return ret;
>> +
>> +glob->bo_ref.global_type = DRM_GLOBAL_TTM_BO;
>> +glob->bo_ref.size = sizeof(struct ttm_bo_global);
>> +glob->bo_ref.object = NULL;
>> +glob->bo_ref.init = &ttm_global_init_bo;
>> +glob->bo_ref.release = &ttm_global_release_bo;
>> +ret = drm_global_item_ref(&glob->bo_ref);
>> +if (ret)
>> +goto err_drm_global_item_unref_mem;
>> +
>> +return 0;
>> +
>> +err_drm_global_item_unref_mem:
>> +drm_global_item_unref(&glob->mem_ref);
>> +return ret;
>> +}
>> +
>> +EXPORT_SYMBOL(ttm_global_init);
>> +
>> +void ttm_global_release(struct ttm_global *glob)
>> +{
>> +drm_global_item_unref(&glob->bo_ref);
>> +drm_global_item_unref(&glob->mem_ref);
>> +}
>> +
>> +EXPORT_SYMBOL(ttm_global_release);
>> diff --git a/include/drm/drm_global.h b/include/drm/drm_global.h
>> index 3a830602a2e4..4482a9bbd6e9 100644
>> --- a/include/drm/drm_global.h
>> +++ b/include/drm/drm_global.h
>> @@ -28,8 +28,16 @@
>>   * Authors: Thomas Hellstrom 
>>   */
>>  
>> +/*
>> + *  The interfaces in this file are deprecated. Please use ttm_global
>> + *  from  instead.
>> + */
>> +
>>  #ifndef _DRM_GLOBAL_H_
>>  #define _DRM_GLOBAL_H_
>> +
>> +#include 
>> +
>>  enum drm_global_types {
>>  DRM_GLOBAL_TTM_MEM = 0,
>>  DRM_GLOBAL_TTM_BO,
>> diff --git a/include/drm/ttm/ttm_global.h b/include/drm/ttm/ttm_global.h
>> new file mode 100644
>> index ..06e791499f87
>> --- /dev/null
>> +++ b/include/drm/ttm/ttm_global.h
>> @@ -0,0 +1,79 @@
>> +/**
>> + *
>> + * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
>> + * All Rights Reserved.
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the
>> + * "Software"), to deal in the Software without restriction, including
>> + * without limitation the rights to use, copy, modify, merge, publish,
>> + * distribute, sub license, and/or sell copies of the Software, and to
>> + * permit persons to whom the Software is furnished to do so, subject to
>> + * the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the
>> + * next paragraph) shall be included in all copies or substantial portions
>> + * of the Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
>> OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
>> + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY 
>> CLAIM,
>> + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
>> + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
>> + * USE OR OTHER DEALINGS IN THE SOFTWARE.
>> + *
>> + **/
>> +
>> +#ifndef _TTM_GLOBAL_H_
>> +#define _TTM_GLOBAL_H_
>> +
>> +#include 
>> +
>> +struct ttm_bo_global;
>> +
>> +/**
>> + * struct ttm_global - Stores references to global TTM state
>> + */
>> +struct ttm_global {
>> +struct drm_global_reference mem_ref;
>> +struct drm_global_reference bo_ref;
>> +};
>> +
>> +/**
>> + * ttm_global_init
>> + *
>> + * @glob: A pointer to a struct ttm_global that is about to be initialized
>> + * @return Zero on success, or a negative error code otherwise.
>> + *
>> + * Initializes an instance of struct ttm_global with TTM's global state
>> + */
>> +int ttm_global_init(struct ttm_global *glob);
>> +
>> +/**
>> + * ttm_global_release
>> + *
>> + * @glob: A pointer to an instance of struct ttm_global
>> + *
>> + * Releases an initialized instance of struct ttm_global. If the instance
>> + * constains the final references to the global memory and BO, the global
>> + * structures are released as well.
>> + */
>> +void ttm_global_release(struct ttm_global *glob);
>> +
>> +/**
>> + * ttm_global_get_bo_global
>> + *
>> + * @glob A pointer to an instance of struct ttm_global
>> + * 

Re: [PATCH 0/3] Provide struct ttm_global for TTM global state

2018-10-19 Thread Thomas Zimmermann
Hi

Am 19.10.18 um 09:24 schrieb Koenig, Christian:
> Hi Thomas,
> 
> I honestly still find that way to complicated compared to what it 
> actually does.
> 
> Both ttm_mem_global and ttm_bo_global can just be some static variables. 
> E.g. the whole handling with drm_global_reference is just superfluous.
> 
> Can I just write a patch to clean up the mess we created?

'Can I?' I don't know :)

Sure, it's a mess. For example, if a driver inits drm_global_reference()
and is later unloaded, there are dangling function pointers to the
driver's code.

I do a slow clean-up of the code because TTM-based drivers depend on the
current way of doing things.

Maybe let me post my full patch set for RFC and discuss this instead.

Best regards
Thomas


> Regards,
> Christian.
> 
> Am 18.10.18 um 18:27 schrieb Thomas Zimmermann:
>> TTM provides global memory and a global BO that is shared by all
>> TTM-based drivers. The data structures are provided by struct drm_global
>> and its helpers. All TTM-based DRM drivers copy the initialization and
>> clean-up code for the global TTM state from each other; leading to code
>> duplication.
>>
>> The new structure struct ttm_global and its helpers provide a unified
>> implementation. Drivers only have to initialize it and forward the
>> contained BO global object to ttm_bo_device_init().
>>
>> The amdgpu and radeon drivers are converted to struct ttm_global as
>> part of this patch set. All other TTM-based drivers share exactly the
>> same code patterns and can be converted in the same way.
>>
>> Future directions: I already have patches for converting the remaining
>> TTM drivers to struct ttm_global. These patches can be merged after
>> the structure has become available in upstream. struct ttm_global is
>> implemented on top of struct drm_global. The latter actually maintains
>> TTM state instead of DRM state. Once all drivers have been converted,
>>  the code for struct drm_global can be merged into struct ttm_global.
>>
>> (Resending this patch set, as I forgot to CC the mailing lists as first.)
>>
>> Thomas Zimmermann (3):
>>drm/ttm: Provide struct ttm_global for referencing TTM global state
>>drm/amdgpu: Replace TTM initialization/release with ttm_global
>>drm/radeon: Replace TTM initialization/release with ttm_global
>>
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 63 ++--
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  4 +-
>>   drivers/gpu/drm/radeon/radeon.h |  4 +-
>>   drivers/gpu/drm/radeon/radeon_ttm.c | 40 ++
>>   drivers/gpu/drm/ttm/Makefile|  2 +-
>>   drivers/gpu/drm/ttm/ttm_global.c| 98 +
>>   include/drm/drm_global.h|  8 ++
>>   include/drm/ttm/ttm_global.h| 79 
>>   8 files changed, 200 insertions(+), 98 deletions(-)
>>   create mode 100644 drivers/gpu/drm/ttm/ttm_global.c
>>   create mode 100644 include/drm/ttm/ttm_global.h
>>
>> --
>> 2.19.1
>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstr. 5, D-90409 Nürnberg
Tel: +49-911-74053-0; Fax: +49-911-7417755;  https://www.suse.com/
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard,
Graham Norton, HRB 21284 (AG Nürnberg)



signature.asc
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/ttm: Provide struct ttm_global for referencing TTM global state

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 9:38 AM Thomas Zimmermann  wrote:
>
> Hi,
>
> thanks for the review.
>
> Am 19.10.18 um 05:30 schrieb Huang Rui:
> > On Fri, Oct 19, 2018 at 12:27:50AM +0800, Thomas Zimmermann wrote:
> >> +int ttm_global_init(struct ttm_global *glob)
> >> +{
> >> +int ret;
> >> +
> >
> > We would better add a protection here to make sure the glob is not NULL.
> >
> > if (!glob)
> > return -EINVAL;
>
> Passing a NULL pointer is a programming error, not a runtime error. I'd
> rather use BUG_ON() for this test. Ok?

if (WARN_ON(!glob)
return -EINVAL;

instead of BUG_ON is much friendly for debugging. Especially in gfx
drivers, where the entire init runs while holding a few critical
kernel locks (console_lock, among others), and so will result in a
very silent death of the entire machine.
-Daniel

>
> Best regards
> Thomas
>
> >
> > Others, look good for me.
> >
> > Thanks,
> > Ray
> >
> >> +glob->mem_ref.global_type = DRM_GLOBAL_TTM_MEM;
> >> +glob->mem_ref.size = sizeof(struct ttm_mem_global);
> >> +glob->bo_ref.object = NULL;
> >> +glob->mem_ref.init = &ttm_global_init_mem;
> >> +glob->mem_ref.release = &ttm_global_release_mem;
> >> +ret = drm_global_item_ref(&glob->mem_ref);
> >> +if (ret)
> >> +return ret;
> >> +
> >> +glob->bo_ref.global_type = DRM_GLOBAL_TTM_BO;
> >> +glob->bo_ref.size = sizeof(struct ttm_bo_global);
> >> +glob->bo_ref.object = NULL;
> >> +glob->bo_ref.init = &ttm_global_init_bo;
> >> +glob->bo_ref.release = &ttm_global_release_bo;
> >> +ret = drm_global_item_ref(&glob->bo_ref);
> >> +if (ret)
> >> +goto err_drm_global_item_unref_mem;
> >> +
> >> +return 0;
> >> +
> >> +err_drm_global_item_unref_mem:
> >> +drm_global_item_unref(&glob->mem_ref);
> >> +return ret;
> >> +}
> >> +
> >> +EXPORT_SYMBOL(ttm_global_init);
> >> +
> >> +void ttm_global_release(struct ttm_global *glob)
> >> +{
> >> +drm_global_item_unref(&glob->bo_ref);
> >> +drm_global_item_unref(&glob->mem_ref);
> >> +}
> >> +
> >> +EXPORT_SYMBOL(ttm_global_release);
> >> diff --git a/include/drm/drm_global.h b/include/drm/drm_global.h
> >> index 3a830602a2e4..4482a9bbd6e9 100644
> >> --- a/include/drm/drm_global.h
> >> +++ b/include/drm/drm_global.h
> >> @@ -28,8 +28,16 @@
> >>   * Authors: Thomas Hellstrom 
> >>   */
> >>
> >> +/*
> >> + *  The interfaces in this file are deprecated. Please use ttm_global
> >> + *  from  instead.
> >> + */
> >> +
> >>  #ifndef _DRM_GLOBAL_H_
> >>  #define _DRM_GLOBAL_H_
> >> +
> >> +#include 
> >> +
> >>  enum drm_global_types {
> >>  DRM_GLOBAL_TTM_MEM = 0,
> >>  DRM_GLOBAL_TTM_BO,
> >> diff --git a/include/drm/ttm/ttm_global.h b/include/drm/ttm/ttm_global.h
> >> new file mode 100644
> >> index ..06e791499f87
> >> --- /dev/null
> >> +++ b/include/drm/ttm/ttm_global.h
> >> @@ -0,0 +1,79 @@
> >> +/**
> >> + *
> >> + * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
> >> + * All Rights Reserved.
> >> + *
> >> + * Permission is hereby granted, free of charge, to any person obtaining a
> >> + * copy of this software and associated documentation files (the
> >> + * "Software"), to deal in the Software without restriction, including
> >> + * without limitation the rights to use, copy, modify, merge, publish,
> >> + * distribute, sub license, and/or sell copies of the Software, and to
> >> + * permit persons to whom the Software is furnished to do so, subject to
> >> + * the following conditions:
> >> + *
> >> + * The above copyright notice and this permission notice (including the
> >> + * next paragraph) shall be included in all copies or substantial portions
> >> + * of the Software.
> >> + *
> >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
> >> EXPRESS OR
> >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
> >> MERCHANTABILITY,
> >> + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT 
> >> SHALL
> >> + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY 
> >> CLAIM,
> >> + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> >> + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
> >> THE
> >> + * USE OR OTHER DEALINGS IN THE SOFTWARE.
> >> + *
> >> + 
> >> **/
> >> +
> >> +#ifndef _TTM_GLOBAL_H_
> >> +#define _TTM_GLOBAL_H_
> >> +
> >> +#include 
> >> +
> >> +struct ttm_bo_global;
> >> +
> >> +/**
> >> + * struct ttm_global - Stores references to global TTM state
> >> + */
> >> +struct ttm_global {
> >> +struct drm_global_reference mem_ref;
> >> +struct drm_global_reference bo_ref;
> >> +};
> >> +
> >> +/**
> >> + * ttm_global_init
> >> + *
> >> + * @glob: A pointer to a struct ttm_global that is about to be initialized
> >> + * @return Zero on success, or a negative error code ot

Re: [PATCH 1/3] drm/ttm: Provide struct ttm_global for referencing TTM global state

2018-10-19 Thread Koenig, Christian
Am 19.10.18 um 09:49 schrieb Daniel Vetter:
> On Fri, Oct 19, 2018 at 9:38 AM Thomas Zimmermann  wrote:
>> Hi,
>>
>> thanks for the review.
>>
>> Am 19.10.18 um 05:30 schrieb Huang Rui:
>>> On Fri, Oct 19, 2018 at 12:27:50AM +0800, Thomas Zimmermann wrote:
 +int ttm_global_init(struct ttm_global *glob)
 +{
 +int ret;
 +
>>> We would better add a protection here to make sure the glob is not NULL.
>>>
>>> if (!glob)
>>>  return -EINVAL;
>> Passing a NULL pointer is a programming error, not a runtime error. I'd
>> rather use BUG_ON() for this test. Ok?
> if (WARN_ON(!glob)
>  return -EINVAL;
>
> instead of BUG_ON is much friendly for debugging. Especially in gfx
> drivers, where the entire init runs while holding a few critical
> kernel locks (console_lock, among others), and so will result in a
> very silent death of the entire machine.

Yeah, additional to that a BUG_ON a NULL pointer is rather pointless.

Dereferencing the NULL pointer has pretty much the same effect as a 
BUG_ON :)

Christian.

> -Daniel
>
>> Best regards
>> Thomas
>>
>>> Others, look good for me.
>>>
>>> Thanks,
>>> Ray
>>>
 +glob->mem_ref.global_type = DRM_GLOBAL_TTM_MEM;
 +glob->mem_ref.size = sizeof(struct ttm_mem_global);
 +glob->bo_ref.object = NULL;
 +glob->mem_ref.init = &ttm_global_init_mem;
 +glob->mem_ref.release = &ttm_global_release_mem;
 +ret = drm_global_item_ref(&glob->mem_ref);
 +if (ret)
 +return ret;
 +
 +glob->bo_ref.global_type = DRM_GLOBAL_TTM_BO;
 +glob->bo_ref.size = sizeof(struct ttm_bo_global);
 +glob->bo_ref.object = NULL;
 +glob->bo_ref.init = &ttm_global_init_bo;
 +glob->bo_ref.release = &ttm_global_release_bo;
 +ret = drm_global_item_ref(&glob->bo_ref);
 +if (ret)
 +goto err_drm_global_item_unref_mem;
 +
 +return 0;
 +
 +err_drm_global_item_unref_mem:
 +drm_global_item_unref(&glob->mem_ref);
 +return ret;
 +}
 +
 +EXPORT_SYMBOL(ttm_global_init);
 +
 +void ttm_global_release(struct ttm_global *glob)
 +{
 +drm_global_item_unref(&glob->bo_ref);
 +drm_global_item_unref(&glob->mem_ref);
 +}
 +
 +EXPORT_SYMBOL(ttm_global_release);
 diff --git a/include/drm/drm_global.h b/include/drm/drm_global.h
 index 3a830602a2e4..4482a9bbd6e9 100644
 --- a/include/drm/drm_global.h
 +++ b/include/drm/drm_global.h
 @@ -28,8 +28,16 @@
* Authors: Thomas Hellstrom 
*/

 +/*
 + *  The interfaces in this file are deprecated. Please use ttm_global
 + *  from  instead.
 + */
 +
   #ifndef _DRM_GLOBAL_H_
   #define _DRM_GLOBAL_H_
 +
 +#include 
 +
   enum drm_global_types {
   DRM_GLOBAL_TTM_MEM = 0,
   DRM_GLOBAL_TTM_BO,
 diff --git a/include/drm/ttm/ttm_global.h b/include/drm/ttm/ttm_global.h
 new file mode 100644
 index ..06e791499f87
 --- /dev/null
 +++ b/include/drm/ttm/ttm_global.h
 @@ -0,0 +1,79 @@
 +/**
 + *
 + * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
 + * All Rights Reserved.
 + *
 + * Permission is hereby granted, free of charge, to any person obtaining a
 + * copy of this software and associated documentation files (the
 + * "Software"), to deal in the Software without restriction, including
 + * without limitation the rights to use, copy, modify, merge, publish,
 + * distribute, sub license, and/or sell copies of the Software, and to
 + * permit persons to whom the Software is furnished to do so, subject to
 + * the following conditions:
 + *
 + * The above copyright notice and this permission notice (including the
 + * next paragraph) shall be included in all copies or substantial portions
 + * of the Software.
 + *
 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
 EXPRESS OR
 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 MERCHANTABILITY,
 + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT 
 SHALL
 + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY 
 CLAIM,
 + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
 THE
 + * USE OR OTHER DEALINGS IN THE SOFTWARE.
 + *
 + 
 **/
 +
 +#ifndef _TTM_GLOBAL_H_
 +#define _TTM_GLOBAL_H_
 +
 +#include 
 +
 +struct ttm_bo_global;
 +
 +/**
 + * struct ttm_global - Stores references to global TTM state
 + */
 +struct ttm_global {
 +struct drm_global_reference mem_ref;
 +struct d

Re: [PATCH 0/3] Provide struct ttm_global for TTM global state

2018-10-19 Thread Koenig, Christian
Am 19.10.18 um 09:44 schrieb Thomas Zimmermann:
> Hi
>
> Am 19.10.18 um 09:24 schrieb Koenig, Christian:
>> Hi Thomas,
>>
>> I honestly still find that way to complicated compared to what it
>> actually does.
>>
>> Both ttm_mem_global and ttm_bo_global can just be some static variables.
>> E.g. the whole handling with drm_global_reference is just superfluous.
>>
>> Can I just write a patch to clean up the mess we created?
> 'Can I?' I don't know :)
>
> Sure, it's a mess. For example, if a driver inits drm_global_reference()
> and is later unloaded, there are dangling function pointers to the
> driver's code.
>
> I do a slow clean-up of the code because TTM-based drivers depend on the
> current way of doing things.
>
> Maybe let me post my full patch set for RFC and discuss this instead.

Yeah, the key point is that this is a lot of stuff to review while the 
end result is we just trow away most of it.

I would rather just go ahead and do a few simple patches instead:
1. Use only a single instance of ttm_mem_global in ttm_memory.c and 
remove all "global" parameters from the functions.
2. Use only a single instance of ttm_bo_global in ttm_bo.c.
3. Remove bdev->global.

The *_global_init()/*_global_release() should just increase/decrease a 
static reference count protected by a static lock.

Regards,
Christian.

>
> Best regards
> Thomas
>
>
>> Regards,
>> Christian.
>>
>> Am 18.10.18 um 18:27 schrieb Thomas Zimmermann:
>>> TTM provides global memory and a global BO that is shared by all
>>> TTM-based drivers. The data structures are provided by struct drm_global
>>> and its helpers. All TTM-based DRM drivers copy the initialization and
>>> clean-up code for the global TTM state from each other; leading to code
>>> duplication.
>>>
>>> The new structure struct ttm_global and its helpers provide a unified
>>> implementation. Drivers only have to initialize it and forward the
>>> contained BO global object to ttm_bo_device_init().
>>>
>>> The amdgpu and radeon drivers are converted to struct ttm_global as
>>> part of this patch set. All other TTM-based drivers share exactly the
>>> same code patterns and can be converted in the same way.
>>>
>>> Future directions: I already have patches for converting the remaining
>>> TTM drivers to struct ttm_global. These patches can be merged after
>>> the structure has become available in upstream. struct ttm_global is
>>> implemented on top of struct drm_global. The latter actually maintains
>>> TTM state instead of DRM state. Once all drivers have been converted,
>>>   the code for struct drm_global can be merged into struct ttm_global.
>>>
>>> (Resending this patch set, as I forgot to CC the mailing lists as first.)
>>>
>>> Thomas Zimmermann (3):
>>> drm/ttm: Provide struct ttm_global for referencing TTM global state
>>> drm/amdgpu: Replace TTM initialization/release with ttm_global
>>> drm/radeon: Replace TTM initialization/release with ttm_global
>>>
>>>drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 63 ++--
>>>drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  4 +-
>>>drivers/gpu/drm/radeon/radeon.h |  4 +-
>>>drivers/gpu/drm/radeon/radeon_ttm.c | 40 ++
>>>drivers/gpu/drm/ttm/Makefile|  2 +-
>>>drivers/gpu/drm/ttm/ttm_global.c| 98 +
>>>include/drm/drm_global.h|  8 ++
>>>include/drm/ttm/ttm_global.h| 79 
>>>8 files changed, 200 insertions(+), 98 deletions(-)
>>>create mode 100644 drivers/gpu/drm/ttm/ttm_global.c
>>>create mode 100644 include/drm/ttm/ttm_global.h
>>>
>>> --
>>> 2.19.1
>>>

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


Re: [PATCH v2 2/2] drm/exynos: decon: Make pixel blend mode configurable

2018-10-19 Thread kbuild test robot
Hi Christoph,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-exynos/exynos-drm-next]
[also build test ERROR on v4.19-rc8 next-20181019]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Christoph-Manszewski/drm-exynos-decon-Make-plane-alpha-configurable/20181019-053544
base:   https://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git 
exynos-drm-next
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All errors (new ones prefixed by >>):

   drivers/gpu/drm/exynos/exynos5433_drm_decon.c: In function 
'decon_win_set_pixfmt':
>> drivers/gpu/drm/exynos/exynos5433_drm_decon.c:337:3: error: 'pixel_alpha' 
>> undeclared (first use in this function); did you mean 'isalpha'?
  pixel_alpha = state->base.pixel_blend_mode;
  ^~~
  isalpha
   drivers/gpu/drm/exynos/exynos5433_drm_decon.c:337:3: note: each undeclared 
identifier is reported only once for each function it appears in
>> drivers/gpu/drm/exynos/exynos5433_drm_decon.c:385:3: error: too few 
>> arguments to function 'decon_win_set_bldmod'
  decon_win_set_bldmod(ctx, win, alpha);
  ^~~~
   drivers/gpu/drm/exynos/exynos5433_drm_decon.c:298:13: note: declared here
static void decon_win_set_bldmod(struct decon_context *ctx, unsigned int 
win,
^~~~

vim +337 drivers/gpu/drm/exynos/exynos5433_drm_decon.c

   326  
   327  static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned 
int win,
   328   struct drm_framebuffer *fb)
   329  {
   330  struct exynos_drm_plane plane = ctx->planes[win];
   331  struct exynos_drm_plane_state *state =
   332  to_exynos_plane_state(plane.base.state);
   333  unsigned int alpha = state->base.alpha;
   334  unsigned long val;
   335  
   336  if (fb->format->has_alpha)
 > 337  pixel_alpha = state->base.pixel_blend_mode;
   338  else
   339  pixel_alpha = DRM_MODE_BLEND_PIXEL_NONE;
   340  
   341  val = readl(ctx->addr + DECON_WINCONx(win));
   342  val &= WINCONx_ENWIN_F;
   343  
   344  switch (fb->format->format) {
   345  case DRM_FORMAT_XRGB1555:
   346  val |= WINCONx_BPPMODE_16BPP_I1555;
   347  val |= WINCONx_HAWSWP_F;
   348  val |= WINCONx_BURSTLEN_16WORD;
   349  break;
   350  case DRM_FORMAT_RGB565:
   351  val |= WINCONx_BPPMODE_16BPP_565;
   352  val |= WINCONx_HAWSWP_F;
   353  val |= WINCONx_BURSTLEN_16WORD;
   354  break;
   355  case DRM_FORMAT_XRGB:
   356  val |= WINCONx_BPPMODE_24BPP_888;
   357  val |= WINCONx_WSWP_F;
   358  val |= WINCONx_BURSTLEN_16WORD;
   359  break;
   360  case DRM_FORMAT_ARGB:
   361  default:
   362  val |= WINCONx_BPPMODE_32BPP_A;
   363  val |= WINCONx_WSWP_F;
   364  val |= WINCONx_BURSTLEN_16WORD;
   365  break;
   366  }
   367  
   368  DRM_DEBUG_KMS("cpp = %u\n", fb->format->cpp[0]);
   369  
   370  /*
   371   * In case of exynos, setting dma-burst to 16Word causes 
permanent
   372   * tearing for very small buffers, e.g. cursor buffer. Burst 
Mode
   373   * switching which is based on plane size is not recommended as
   374   * plane size varies a lot towards the end of the screen and 
rapid
   375   * movement causes unstable DMA which results into iommu 
crash/tear.
   376   */
   377  
   378  if (fb->width < MIN_FB_WIDTH_FOR_16WORD_BURST) {
   379  val &= ~WINCONx_BURSTLEN_MASK;
   380  val |= WINCONx_BURSTLEN_8WORD;
   381  }
   382  decon_set_bits(ctx, DECON_WINCONx(win), 
~WINCONx_BLEND_MODE_MASK, val);
   383  
   384  if (win > 0) {
 > 385  decon_win_set_bldmod(ctx, win, alpha);
   386  decon_win_set_bldeq(ctx, win, alpha, pixel_alpha);
   387  }
   388  }
   389  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/g

[PATCH] drm/doc: Update errno handbook

2018-10-19 Thread Daniel Vetter
We recently bikeshedded this to a different flavour, but forgot to
update the recommendations.

Cc: Chris Wilson 
Cc: Ville Syrjälä 
Signed-off-by: Daniel Vetter 
---
 Documentation/gpu/drm-uapi.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
index a2214cc1f821..4b4bf2c5eac5 100644
--- a/Documentation/gpu/drm-uapi.rst
+++ b/Documentation/gpu/drm-uapi.rst
@@ -197,6 +197,9 @@ EPERM/EACCESS:
 difference between EACCESS and EPERM.
 
 ENODEV:
+The device is not (yet) present or fully initialized.
+
+EOPNOTSUPP:
 Feature (like PRIME, modesetting, GEM) is not supported by the driver.
 
 ENXIO:
-- 
2.19.1

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


Re: [PATCH 2/7] drm: add syncobj timeline support v8

2018-10-19 Thread Chris Wilson
Quoting Chunming Zhou (2018-10-15 09:55:48)
> This patch is for VK_KHR_timeline_semaphore extension, semaphore is called 
> syncobj in kernel side:
> This extension introduces a new type of syncobj that has an integer payload
> identifying a point in a timeline. Such timeline syncobjs support the
> following operations:
>* CPU query - A host operation that allows querying the payload of the
>  timeline syncobj.
>* CPU wait - A host operation that allows a blocking wait for a
>  timeline syncobj to reach a specified value.
>* Device wait - A device operation that allows waiting for a
>  timeline syncobj to reach a specified value.
>* Device signal - A device operation that allows advancing the
>  timeline syncobj to a specified value.


Spinlock recursion:

https://bugs.freedesktop.org/show_bug.cgi?id=108490
<6> [363.585915] [IGT] syncobj_wait: executing
<6> [363.646916] [IGT] syncobj_wait: starting subtest 
wait-for-submit-delayed-submit
<4> [363.752517]
<4> [363.752542] 
<4> [363.752561] WARNING: possible recursive locking detected
<4> [363.752582] 4.19.0-rc8-CI-CI_DRM_5006+ #1 Tainted: G U
<4> [363.752602] 
<4> [363.752621] syncobj_wait/2297 is trying to acquire lock:
<4> [363.752641] 29228054 (&(&syncobj->lock)->rlock){+.+.}, at: 
drm_syncobj_garbage_collection+0x25/0x140
<4> [363.752699] \x0abut task is already holding lock:
<4> [363.752721] 29228054 (&(&syncobj->lock)->rlock){+.+.}, at: 
drm_syncobj_replace_fence+0x1b6/0x2c0
<4> [363.752768] \x0aother info that might help us debug this:
<4> [363.752791] Possible unsafe locking scenario:\x0a
<4> [363.752812] CPU0
<4> [363.752824] 
<4> [363.752835] lock(&(&syncobj->lock)->rlock);
<4> [363.752856] lock(&(&syncobj->lock)->rlock);
<4> [363.752877] \x0a *** DEADLOCK ***\x0a
<4> [363.752905] May be due to missing lock nesting notation\x0a
<4> [363.752932] 1 lock held by syncobj_wait/2297:
<4> [363.752949] #0: 29228054 (&(&syncobj->lock)->rlock){+.+.}, at: 
drm_syncobj_replace_fence+0x1b6/0x2c0
<4> [363.753001] \x0astack backtrace:
<4> [363.753030] CPU: 2 PID: 2297 Comm: syncobj_wait Tainted: G U 
4.19.0-rc8-CI-CI_DRM_5006+ #1
<4> [363.753060] Hardware name: Google Caroline/Caroline, BIOS MrChromebox 
08/27/2018
<4> [363.753083] Call Trace:
<4> [363.753109] dump_stack+0x67/0x9b
<4> [363.753136] __lock_acquire+0xc67/0x1b50
<4> [363.753164] ? deactivate_slab.isra.26+0x7a4/0x7e0
<4> [363.753203] ? __lock_acquire+0x3c8/0x1b50
<4> [363.753242] ? __wake_up_common_lock+0x5e/0xb0
<4> [363.753285] ? lock_acquire+0xa6/0x1c0
<4> [363.753306] lock_acquire+0xa6/0x1c0
<4> [363.753334] ? drm_syncobj_garbage_collection+0x25/0x140
<4> [363.753365] _raw_spin_lock+0x2a/0x40
<4> [363.753392] ? drm_syncobj_garbage_collection+0x25/0x140
<4> [363.753419] drm_syncobj_garbage_collection+0x25/0x140
<4> [363.753450] drm_syncobj_search_fence+0x38/0x200
<4> [363.753478] ? drm_syncobj_replace_fence+0x1b6/0x2c0
<4> [363.753509] syncobj_wait_syncobj_func+0x11/0x20
<4> [363.753536] drm_syncobj_replace_fence+0x1f8/0x2c0
<4> [363.753561] ? drm_syncobj_handle_to_fd_ioctl+0x170/0x170
<4> [363.753585] drm_syncobj_fd_to_handle_ioctl+0x120/0x1d0
<4> [363.753609] ? drm_syncobj_handle_to_fd_ioctl+0x170/0x170
<4> [363.753638] drm_ioctl_kernel+0x81/0xf0
<4> [363.753665] drm_ioctl+0x2e6/0x3a0
<4> [363.753686] ? drm_syncobj_handle_to_fd_ioctl+0x170/0x170
<4> [363.753717] ? lock_acquire+0xa6/0x1c0
<4> [363.753743] do_vfs_ioctl+0xa0/0x6d0
<4> [363.753769] ? __fget+0xfc/0x1e0
<4> [363.753792] ksys_ioctl+0x35/0x60
<4> [363.753816] __x64_sys_ioctl+0x11/0x20
<4> [363.753840] do_syscall_64+0x55/0x190
<4> [363.753866] entry_SYSCALL_64_after_hwframe+0x49/0xbe
<4> [363.753890] RIP: 0033:0x7f0d84f9a5d7
<4> [363.753911] Code: b3 66 90 48 8b 05 b1 48 2d 00 64 c7 00 26 00 00 00 48 c7 
c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 
f0 ff ff 73 01 c3 48 8b 0d 81 48 2d 00 f7 d8 64 89 01 48
<4> [363.753959] RSP: 002b:7f0d79804ac8 EFLAGS: 0246 ORIG_RAX: 
0010
<4> [363.753990] RAX: ffda RBX: 7f0d74000b20 RCX: 
7f0d84f9a5d7
<4> [363.754016] RDX: 7f0d79804b50 RSI: c01064c2 RDI: 
0005
<4> [363.754040] RBP: 7f0d79804b50 R08:  R09: 
001e
<4> [363.754064] R10: 0054 R11: 0246 R12: 
c01064c2
<4> [363.754088] R13: 0005 R14: 7f0d74000b20 R15: 
55ab44e2c3f8
-Chris
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] RFC: Make igts for cross-driver stuff mandatory?

2018-10-19 Thread Daniel Vetter
Hi all,

This is just to collect feedback on this idea, and see whether the
overall dri-devel community stands on all this. I think the past few
cross-vendor uapi extensions all came with igts attached, and
personally I think there's lots of value in having them: A
cross-vendor interface isn't useful if every driver implements it
slightly differently.

I think there's 2 questions here:

- Do we want to make such testcases mandatory?

- If yes, are we there yet, or is there something crucially missing
  still?

And of course there's a bunch of details to figure out. Like we
probably want to also recommend the selftests/unit-tests in
drivers/gpu/drm/selftest, since fairly often that's a much more
effective approach to checking the details than from userspace.

Feedback and thoughts very much appreciated.

Cheers, Daniel
---
 Documentation/gpu/drm-uapi.rst | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
index 4b4bf2c5eac5..91cf6e4b6303 100644
--- a/Documentation/gpu/drm-uapi.rst
+++ b/Documentation/gpu/drm-uapi.rst
@@ -238,6 +238,13 @@ DRM specific patterns. Note that ENOTTY has the slightly 
unintuitive meaning of
 Testing and validation
 ==
 
+Testing Requirements for userspace API
+--
+
+New cross-driver userspace interface extensions, like new IOCTL, new KMS
+properties, new files in sysfs or anything else that constitutes an API change
+need to have driver-agnostic testcases in IGT for that feature.
+
 Validating changes with IGT
 ---
 
-- 
2.19.1

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


Re: [PATCH] amdgpu/gmc : fix compile warning

2018-10-19 Thread Daniel Vetter
On Mon, Oct 08, 2018 at 06:13:56PM +, Koenig, Christian wrote:
> Am 08.10.2018 um 19:46 schrieb Guenter Roeck:
> > On Mon, Oct 08, 2018 at 05:22:24PM +, Koenig, Christian wrote:
> >> Am 08.10.2018 um 17:57 schrieb Deucher, Alexander:
> >> One thing I found missing in the discussion was the reference to the
> >> C standard.
> >> The C99 standard states in section 6.7.8 (Initialization) clause 19:
> >> "... all
> >> subobjects that are not initialized explicitly shall be initialized
> >> implicitly the same as objects that have static storage duration".
> >> Clause 21 makes further reference to partial initialization,
> >> suggesting the same. Various online resources, including the gcc
> >> documentation, all state the same. I don't find any reference to a
> >> partial initialization which would leave members of a structure
> >> undefined. It would be interesting for me to understand how and why
> >> this does not apply here.
> >>
> >> In this context, it is interesting that the other 48 instances of the
> >> { { 0 } } initialization in the same driver don't raise similar
> >> concerns, nor seemed to have caused any operational problems.
> > Feel free to provide patches to replace those with memset().
> >
>  Not me. As I see it, the problem, if it exists, would be a violation of 
>  the C
>  standard. I don't believe hacking around bad C compilers. I would rather
>  blacklist such compilers.
> >> Well then you would need to blacklist basically all gcc variants of the
> >> last decade or so.
> >>
> >> Initializing only known members of structures is a perfectly valid
> >> optimization and well known issue when you then compare the structure
> >> with memcpy() or use the bytes for hashing or something similar.
> >>
> > Isn't that about padding ? That is a completely different issue.
> 
> Correct, yes. But that is the reason why I recommend using memset() for 
> zero initialization.
> 
> See we don't know the inner layout of the structure, could be another 
> structure or an union.
> 
> If it's a structure everything is fine because if you initialize one 
> structure member all other get their default type (whatever that means), 
> but if it's an union.
> 
> Not sure if compilers still react allergic to that, but its the status 
> I've learned the hard way when the C99 standard came out and it still 
> seems like people are working around that so I recommend everybody to 
> stick with memset().

Went boom:

https://bugs.freedesktop.org/show_bug.cgi?id=108490

Can we revert?

Also, can we properly igt this so that intel-gfx-ci could test this before
it's all fireworks?

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


[PATCH 02/18] drm/amdgpu: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and relesae of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 63 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  4 +-
 2 files changed, 7 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 3a6802846698..70b0e8c77bb4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -65,33 +65,6 @@ static void amdgpu_ttm_debugfs_fini(struct amdgpu_device 
*adev);
  * Global memory.
  */
 
-/**
- * amdgpu_ttm_mem_global_init - Initialize and acquire reference to
- * memory object
- *
- * @ref: Object for initialization.
- *
- * This is called by drm_global_item_ref() when an object is being
- * initialized.
- */
-static int amdgpu_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-/**
- * amdgpu_ttm_mem_global_release - Drop reference to a memory object
- *
- * @ref: Object being removed
- *
- * This is called by drm_global_item_unref() when an object is being
- * released.
- */
-static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 /**
  * amdgpu_ttm_global_init - Initialize global TTM memory reference structures.
  *
@@ -102,35 +75,15 @@ static void amdgpu_ttm_mem_global_release(struct 
drm_global_reference *ref)
  */
 static int amdgpu_ttm_global_init(struct amdgpu_device *adev)
 {
-   struct drm_global_reference *global_ref;
int r;
 
/* ensure reference is false in case init fails */
adev->mman.mem_global_referenced = false;
 
-   global_ref = &adev->mman.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &amdgpu_ttm_mem_global_init;
-   global_ref->release = &amdgpu_ttm_mem_global_release;
-   r = drm_global_item_ref(global_ref);
+   r = ttm_global_init(&adev->mman.glob);
if (r) {
-   DRM_ERROR("Failed setting up TTM memory accounting "
- "subsystem.\n");
-   goto error_mem;
-   }
-
-   adev->mman.bo_global_ref.mem_glob =
-   adev->mman.mem_global_ref.object;
-   global_ref = &adev->mman.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-   r = drm_global_item_ref(global_ref);
-   if (r) {
-   DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-   goto error_bo;
+   DRM_ERROR("Failed setting up TTM subsystem.\n");
+   return r;
}
 
mutex_init(&adev->mman.gtt_window_lock);
@@ -138,19 +91,13 @@ static int amdgpu_ttm_global_init(struct amdgpu_device 
*adev)
adev->mman.mem_global_referenced = true;
 
return 0;
-
-error_bo:
-   drm_global_item_unref(&adev->mman.mem_global_ref);
-error_mem:
-   return r;
 }
 
 static void amdgpu_ttm_global_fini(struct amdgpu_device *adev)
 {
if (adev->mman.mem_global_referenced) {
mutex_destroy(&adev->mman.gtt_window_lock);
-   drm_global_item_unref(&adev->mman.bo_global_ref.ref);
-   drm_global_item_unref(&adev->mman.mem_global_ref);
+   ttm_global_release(&adev->mman.glob);
adev->mman.mem_global_referenced = false;
}
 }
@@ -1765,7 +1712,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
}
/* No others user of address space so set it to 0 */
r = ttm_bo_device_init(&adev->mman.bdev,
-  adev->mman.bo_global_ref.ref.object,
+  ttm_global_get_bo_global(&adev->mman.glob),
   &amdgpu_bo_driver,
   adev->ddev->anon_inode->i_mapping,
   DRM_FILE_PAGE_OFFSET,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index fe8f276e9811..c3a7fe3ead3a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -26,6 +26,7 @@
 
 #include "amdgpu.h"
 #include 
+#include 
 
 #define AMDGPU_PL_GDS  (TTM_PL_PRIV + 0)
 #define AMDGPU_PL_GWS  (TTM_PL_PRIV + 1)
@@ -39,8 +40,7 @@
 #define AMDGPU_GTT_NUM_TRANSFER_WINDOWS2
 
 struct amdgpu_mman {
-   struct ttm_bo_global_refbo_global_ref;
-   struct drm_global_reference mem_global_ref;
+   struct ttm_global   glob;
struct ttm_bo_devicebdev;
boolmem_global_referenced;
bool  

[PATCH 01/18] drm/ttm: Provide struct ttm_global for referencing TTM global state

2018-10-19 Thread Thomas Zimmermann
The new struct ttm_global provides drivers with TTM's global memory and
BO in a unified way. Initialization and release is handled internally.

The functionality provided by struct ttm_global is currently re-implemented
by a dozen individual DRM drivers using struct drm_global. The implementation
of struct ttm_global is also built on top of drm_global, so it can co-exists
with the existing drivers. Once all TTM-based drivers have been converted to
struct ttm_global, the implementation of struct drm_global can be made
private to TTM.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/ttm/Makefile |  2 +-
 drivers/gpu/drm/ttm/ttm_global.c | 98 
 include/drm/drm_global.h |  8 +++
 include/drm/ttm/ttm_global.h | 79 +
 4 files changed, 186 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/ttm/ttm_global.c
 create mode 100644 include/drm/ttm/ttm_global.h

diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile
index 01fc670ce7a2..b7272b26e9f3 100644
--- a/drivers/gpu/drm/ttm/Makefile
+++ b/drivers/gpu/drm/ttm/Makefile
@@ -5,7 +5,7 @@
 ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o \
-   ttm_page_alloc_dma.o
+   ttm_page_alloc_dma.o ttm_global.o
 ttm-$(CONFIG_AGP) += ttm_agp_backend.o
 
 obj-$(CONFIG_DRM_TTM) += ttm.o
diff --git a/drivers/gpu/drm/ttm/ttm_global.c b/drivers/gpu/drm/ttm/ttm_global.c
new file mode 100644
index ..ca9da0a46147
--- /dev/null
+++ b/drivers/gpu/drm/ttm/ttm_global.c
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+/**
+ *
+ * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **/
+
+#include 
+#include 
+#include 
+#include 
+
+static int ttm_global_init_mem(struct drm_global_reference *ref)
+{
+   BUG_ON(!ref->object);
+   return ttm_mem_global_init(ref->object);
+}
+
+static void ttm_global_release_mem(struct drm_global_reference *ref)
+{
+   BUG_ON(!ref->object);
+   ttm_mem_global_release(ref->object);
+}
+
+static int ttm_global_init_bo(struct drm_global_reference *ref)
+{
+   struct ttm_global *glob =
+   container_of(ref, struct ttm_global, bo_ref);
+   BUG_ON(!ref->object);
+   BUG_ON(!glob->mem_ref.object);
+   return ttm_bo_global_init(ref->object, glob->mem_ref.object);
+}
+
+static void ttm_global_release_bo(struct drm_global_reference *ref)
+{
+   BUG_ON(!ref->object);
+   ttm_bo_global_release(ref->object);
+}
+
+int ttm_global_init(struct ttm_global *glob)
+{
+   int ret;
+
+   glob->mem_ref.global_type = DRM_GLOBAL_TTM_MEM;
+   glob->mem_ref.size = sizeof(struct ttm_mem_global);
+   glob->bo_ref.object = NULL;
+   glob->mem_ref.init = &ttm_global_init_mem;
+   glob->mem_ref.release = &ttm_global_release_mem;
+   ret = drm_global_item_ref(&glob->mem_ref);
+   if (ret)
+   return ret;
+
+   glob->bo_ref.global_type = DRM_GLOBAL_TTM_BO;
+   glob->bo_ref.size = sizeof(struct ttm_bo_global);
+   glob->bo_ref.object = NULL;
+   glob->bo_ref.init = &ttm_global_init_bo;
+   glob->bo_ref.release = &ttm_global_release_bo;
+   ret = drm_global_item_ref(&glob->bo_ref);
+   if (ret)
+   goto err_drm_global_item_unref_mem;
+
+   return 0;
+
+err_drm_global_item_unref_mem:
+   drm_global_item_unref(&glob->mem_ref);
+   return ret;
+}
+
+EXPORT_SYMBOL(ttm_global_init);
+
+void ttm_global_release(struct ttm_global *glob)
+{
+   drm_global_item_unref(&glob->bo_ref);
+   drm_global_item_u

[RFC][PATCH 00/18] Provide a nice interface for TTM global state

2018-10-19 Thread Thomas Zimmermann
This is the full patch set for cleaning up the TTM global-state handling
and offering a nice interface for drivers. The first 3 patches have been
discussed on dri-devel already.

Patch [01] adds struct ttm_global, a data structure that gives drivers
a handle ot the global TTM state.

Patches [02] to [13] convert all TTM drivers to struct ttm_global.

Patches [14] and [15] remove unused code.

Patches [16] to [18] merge the functionality of struct drm_global_reference
into the implementation of struct ttm_global and remove the former.

I'd really like to see patches [01] to [15] being merging in one way or the
other. Using struct ttm_global allows for sharing code that touches TTM
internals, and it gets drivers out of the way for the cleanup of the final
3 patches.

One question was if the current infrastructure around drm_global_reference
isn't over-engineered and could be simplified. For now, I took the existing
ref-counting as it is in drm_global.c. This can certainly be simplified if
prefered.

Thomas Zimmermann (18):
  drm/ttm: Provide struct ttm_global for referencing TTM global state
  drm/amdgpu: Replace TTM initialization/release with ttm_global
  drm/radeon: Replace TTM initialization/release with ttm_global
  drm/ast: Replace TTM initialization/release with ttm_global
  drm/bochs: Replace TTM initialization/release with ttm_global
  drm/cirrus: Replace TTM initialization/release with ttm_global
  drm/hisilicon: Replace TTM initialization/release with ttm_global
  drm/mgag200: Replace TTM initialization/release with ttm_global
  drm/nouveau: Replace TTM initialization/release with ttm_global
  drm/qlx: Replace TTM initialization/release with ttm_global
  drm/virtio: Replace TTM initialization/release with ttm_global
  drm/vmwgfx: Replace TTM initialization/release with ttm_global
  staging/vboxvideo: Replace TTM initialization/release with ttm_global
  drm/ttm: Remove struct ttm_bo_global_ref and helpers
  drm: Remove DRM_GLOBAL_TTM_OBJECT
  drm/ttm: Implement struct ttm_global_item and helpers
  drm/ttm: Implement struct ttm_global with struct ttm_global_ref
  drm: Remove drm_global.{c,h}

 drivers/gpu/drm/Makefile  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   |  63 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h   |   4 +-
 drivers/gpu/drm/ast/ast_drv.h |   5 +-
 drivers/gpu/drm/ast/ast_ttm.c |  49 +
 drivers/gpu/drm/bochs/bochs.h |   5 +-
 drivers/gpu/drm/bochs/bochs_mm.c  |  47 +
 drivers/gpu/drm/cirrus/cirrus_drv.h   |   5 +-
 drivers/gpu/drm/cirrus/cirrus_ttm.c   |  49 +
 drivers/gpu/drm/drm_drv.c |   2 -
 drivers/gpu/drm/drm_global.c  | 137 
 drivers/gpu/drm/gma500/psb_drv.h  |   4 +-
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   |   4 +-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   |  36 +---
 drivers/gpu/drm/mgag200/mgag200_drv.h |   7 +-
 drivers/gpu/drm/mgag200/mgag200_ttm.c |  49 +
 drivers/gpu/drm/nouveau/nouveau_drv.h |   5 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c |  48 +
 drivers/gpu/drm/qxl/qxl_drv.h |   4 +-
 drivers/gpu/drm/qxl/qxl_ttm.c |  40 +---
 drivers/gpu/drm/radeon/radeon.h   |   4 +-
 drivers/gpu/drm/radeon/radeon_ttm.c   |  40 +---
 drivers/gpu/drm/ttm/Makefile  |   2 +-
 drivers/gpu/drm/ttm/ttm_global.c  | 198 ++
 drivers/gpu/drm/virtio/virtgpu_drv.h  |   4 +-
 drivers/gpu/drm/virtio/virtgpu_ttm.c  |  40 +---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |   6 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h   |   6 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c  |  44 +---
 drivers/staging/vboxvideo/vbox_drv.h  |   4 +-
 drivers/staging/vboxvideo/vbox_ttm.c  |  42 +---
 include/drm/drmP.h|   1 -
 include/drm/drm_global.h  |  53 -
 include/drm/ttm/ttm_bo_driver.h   |  40 
 include/drm/ttm/ttm_global.h  | 100 +
 35 files changed, 401 insertions(+), 748 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_global.c
 create mode 100644 drivers/gpu/drm/ttm/ttm_global.c
 delete mode 100644 include/drm/drm_global.h
 create mode 100644 include/drm/ttm/ttm_global.h

--
2.19.1

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


[PATCH 04/18] drm/ast: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/ast/ast_drv.h |  5 ++--
 drivers/gpu/drm/ast/ast_ttm.c | 49 ++-
 2 files changed, 11 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index e6c4cd3dc50e..e0c9ee2b0e00 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -104,9 +105,9 @@ struct ast_private {
int fb_mtrr;
 
struct {
-   struct drm_global_reference mem_global_ref;
-   struct ttm_bo_global_ref bo_global_ref;
+   struct ttm_global glob;
struct ttm_bo_device bdev;
+   bool glob_initialized;
} ttm;
 
struct drm_gem_object *cursor_cache;
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index d21fbd26785a..dad24f37a3ea 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -36,60 +36,27 @@ ast_bdev(struct ttm_bo_device *bd)
return container_of(bd, struct ast_private, ttm.bdev);
 }
 
-static int
-ast_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void
-ast_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 static int ast_ttm_global_init(struct ast_private *ast)
 {
-   struct drm_global_reference *global_ref;
-   int r;
-
-   global_ref = &ast->ttm.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &ast_ttm_mem_global_init;
-   global_ref->release = &ast_ttm_mem_global_release;
-   r = drm_global_item_ref(global_ref);
+   int r = ttm_global_init(&ast->ttm.glob);
if (r != 0) {
-   DRM_ERROR("Failed setting up TTM memory accounting "
- "subsystem.\n");
+   DRM_ERROR("Failed setting up TTM subsystem.\n");
return r;
}
 
-   ast->ttm.bo_global_ref.mem_glob =
-   ast->ttm.mem_global_ref.object;
-   global_ref = &ast->ttm.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-   r = drm_global_item_ref(global_ref);
-   if (r != 0) {
-   DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-   drm_global_item_unref(&ast->ttm.mem_global_ref);
-   return r;
-   }
+   ast->ttm.glob_initialized = true;
+
return 0;
 }
 
 static void
 ast_ttm_global_release(struct ast_private *ast)
 {
-   if (ast->ttm.mem_global_ref.release == NULL)
+   if (!ast->ttm.glob_initialized)
return;
 
-   drm_global_item_unref(&ast->ttm.bo_global_ref.ref);
-   drm_global_item_unref(&ast->ttm.mem_global_ref);
-   ast->ttm.mem_global_ref.release = NULL;
+   ttm_global_release(&ast->ttm.glob);
+   ast->ttm.glob_initialized = false;
 }
 
 
@@ -237,7 +204,7 @@ int ast_mm_init(struct ast_private *ast)
return ret;
 
ret = ttm_bo_device_init(&ast->ttm.bdev,
-ast->ttm.bo_global_ref.ref.object,
+ast->ttm.glob.bo_ref.object,
 &ast_bo_driver,
 dev->anon_inode->i_mapping,
 DRM_FILE_PAGE_OFFSET,
-- 
2.19.1

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


[PATCH 05/18] drm/bochs: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/bochs/bochs.h|  5 ++--
 drivers/gpu/drm/bochs/bochs_mm.c | 47 +---
 2 files changed, 10 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
index e7a69077e45a..f73911ac1d77 100644
--- a/drivers/gpu/drm/bochs/bochs.h
+++ b/drivers/gpu/drm/bochs/bochs.h
@@ -12,6 +12,7 @@
 
 #include 
 #include 
+#include 
 
 /* -- */
 
@@ -76,9 +77,9 @@ struct bochs_device {
 
/* ttm */
struct {
-   struct drm_global_reference mem_global_ref;
-   struct ttm_bo_global_ref bo_global_ref;
+   struct ttm_global glob;
struct ttm_bo_device bdev;
+   bool glob_initialized;
bool initialized;
} ttm;
 
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index ff4f41dec228..bdaab57bcd13 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -16,61 +16,28 @@ static inline struct bochs_device *bochs_bdev(struct 
ttm_bo_device *bd)
return container_of(bd, struct bochs_device, ttm.bdev);
 }
 
-static int bochs_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void bochs_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 static int bochs_ttm_global_init(struct bochs_device *bochs)
 {
-   struct drm_global_reference *global_ref;
-   int r;
-
-   global_ref = &bochs->ttm.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &bochs_ttm_mem_global_init;
-   global_ref->release = &bochs_ttm_mem_global_release;
-   r = drm_global_item_ref(global_ref);
+   int r = ttm_global_init(&bochs->ttm.glob);
if (r != 0) {
-   DRM_ERROR("Failed setting up TTM memory accounting "
- "subsystem.\n");
+   DRM_ERROR("Failed setting up TTM subsystem.\n");
return r;
}
 
-   bochs->ttm.bo_global_ref.mem_glob =
-   bochs->ttm.mem_global_ref.object;
-   global_ref = &bochs->ttm.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-   r = drm_global_item_ref(global_ref);
-   if (r != 0) {
-   DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-   drm_global_item_unref(&bochs->ttm.mem_global_ref);
-   return r;
-   }
+   bochs->ttm.glob_initialized = true;
 
return 0;
 }
 
 static void bochs_ttm_global_release(struct bochs_device *bochs)
 {
-   if (bochs->ttm.mem_global_ref.release == NULL)
+   if (!bochs->ttm.glob_initialized)
return;
 
-   drm_global_item_unref(&bochs->ttm.bo_global_ref.ref);
-   drm_global_item_unref(&bochs->ttm.mem_global_ref);
-   bochs->ttm.mem_global_ref.release = NULL;
+   ttm_global_release(&bochs->ttm.glob);
+   bochs->ttm.glob_initialized = false;
 }
 
-
 static void bochs_bo_ttm_destroy(struct ttm_buffer_object *tbo)
 {
struct bochs_bo *bo;
@@ -213,7 +180,7 @@ int bochs_mm_init(struct bochs_device *bochs)
return ret;
 
ret = ttm_bo_device_init(&bochs->ttm.bdev,
-bochs->ttm.bo_global_ref.ref.object,
+bochs->ttm.glob.bo_ref.object,
 &bochs_bo_driver,
 bochs->dev->anon_inode->i_mapping,
 DRM_FILE_PAGE_OFFSET,
-- 
2.19.1

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


[PATCH 12/18] drm/vmwgfx: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c  |  6 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  |  6 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 44 ++--
 3 files changed, 9 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 61a84b958d67..85b58e0c25fa 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -829,7 +829,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned 
long chipset)
}
 
dev_priv->tdev = ttm_object_device_init
-   (dev_priv->mem_global_ref.object, 12, &vmw_prime_dmabuf_ops);
+   (dev_priv->glob.mem_ref.object, 12, &vmw_prime_dmabuf_ops);
 
if (unlikely(dev_priv->tdev == NULL)) {
DRM_ERROR("Unable to initialize TTM object management.\n");
@@ -870,7 +870,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned 
long chipset)
}
 
ret = ttm_bo_device_init(&dev_priv->bdev,
-dev_priv->bo_global_ref.ref.object,
+dev_priv->glob.bo_ref.object,
 &vmw_bo_driver,
 dev->anon_inode->i_mapping,
 VMWGFX_FILE_PAGE_OFFSET,
@@ -1530,7 +1530,7 @@ static int vmw_pm_freeze(struct device *kdev)
 
vmw_fence_fifo_down(dev_priv->fman);
__vmw_svga_disable(dev_priv);
-   
+
vmw_release_device_late(dev_priv);
return 0;
 }
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 59f614225bcd..ae724c756bf0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "vmwgfx_fence.h"
 #include "ttm_object.h"
 #include "ttm_lock.h"
@@ -417,8 +418,7 @@ enum {
 
 struct vmw_private {
struct ttm_bo_device bdev;
-   struct ttm_bo_global_ref bo_global_ref;
-   struct drm_global_reference mem_global_ref;
+   struct ttm_global glob;
 
struct vmw_fifo_state fifo;
 
@@ -1363,7 +1363,7 @@ vmw_bo_reference(struct vmw_buffer_object *buf)
 
 static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv)
 {
-   return (struct ttm_mem_global *) dev_priv->mem_global_ref.object;
+   return (struct ttm_mem_global *) dev_priv->glob.mem_ref.object;
 }
 
 static inline void vmw_fifo_resource_inc(struct vmw_private *dev_priv)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
index f3ce43c41978..2125a0e3f431 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
@@ -43,56 +43,18 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
return ttm_bo_mmap(filp, vma, &dev_priv->bdev);
 }
 
-static int vmw_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   DRM_INFO("global init.\n");
-   return ttm_mem_global_init(ref->object);
-}
-
-static void vmw_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 int vmw_ttm_global_init(struct vmw_private *dev_priv)
 {
-   struct drm_global_reference *global_ref;
-   int ret;
-
-   global_ref = &dev_priv->mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &vmw_ttm_mem_global_init;
-   global_ref->release = &vmw_ttm_mem_global_release;
-
-   ret = drm_global_item_ref(global_ref);
+   int ret = ttm_global_init(&dev_priv->glob);
if (unlikely(ret != 0)) {
-   DRM_ERROR("Failed setting up TTM memory accounting.\n");
+   DRM_ERROR("Failed setting up TTM.\n");
return ret;
}
 
-   dev_priv->bo_global_ref.mem_glob =
-   dev_priv->mem_global_ref.object;
-   global_ref = &dev_priv->bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-   ret = drm_global_item_ref(global_ref);
-
-   if (unlikely(ret != 0)) {
-   DRM_ERROR("Failed setting up TTM buffer objects.\n");
-   goto out_no_bo;
-   }
-
return 0;
-out_no_bo:
-   drm_global_item_unref(&dev_priv->mem_global_ref);
-   return ret;
 }
 
 void vmw_ttm_global_release(struct vmw_private *dev_priv)
 {
-   drm_global_item_unref(&dev_priv->bo_global_ref.ref);
-   drm_global_item_unref(&dev_priv->mem_global_ref);
+   ttm_global_release(&dev_priv->glob);
 }
-- 
2.19.1


[PATCH 03/18] drm/radeon: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/radeon/radeon.h |  4 +--
 drivers/gpu/drm/radeon/radeon_ttm.c | 40 -
 2 files changed, 7 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 1a6f6edb3515..554c0421b779 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -73,6 +73,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -448,8 +449,7 @@ struct radeon_surface_reg {
  * TTM.
  */
 struct radeon_mman {
-   struct ttm_bo_global_refbo_global_ref;
-   struct drm_global_reference mem_global_ref;
+   struct ttm_global   glob;
struct ttm_bo_devicebdev;
boolmem_global_referenced;
boolinitialized;
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index dac4ec5a120b..363860e82892 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -64,45 +64,16 @@ static struct radeon_device *radeon_get_rdev(struct 
ttm_bo_device *bdev)
 /*
  * Global memory.
  */
-static int radeon_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void radeon_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
 
 static int radeon_ttm_global_init(struct radeon_device *rdev)
 {
-   struct drm_global_reference *global_ref;
int r;
 
rdev->mman.mem_global_referenced = false;
-   global_ref = &rdev->mman.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &radeon_ttm_mem_global_init;
-   global_ref->release = &radeon_ttm_mem_global_release;
-   r = drm_global_item_ref(global_ref);
-   if (r != 0) {
-   DRM_ERROR("Failed setting up TTM memory accounting "
- "subsystem.\n");
-   return r;
-   }
 
-   rdev->mman.bo_global_ref.mem_glob =
-   rdev->mman.mem_global_ref.object;
-   global_ref = &rdev->mman.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-   r = drm_global_item_ref(global_ref);
-   if (r != 0) {
-   DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-   drm_global_item_unref(&rdev->mman.mem_global_ref);
+   r = ttm_global_init(&rdev->mman.glob);
+   if (r) {
+   DRM_ERROR("Failed setting up TTM subsystem.\n");
return r;
}
 
@@ -113,8 +84,7 @@ static int radeon_ttm_global_init(struct radeon_device *rdev)
 static void radeon_ttm_global_fini(struct radeon_device *rdev)
 {
if (rdev->mman.mem_global_referenced) {
-   drm_global_item_unref(&rdev->mman.bo_global_ref.ref);
-   drm_global_item_unref(&rdev->mman.mem_global_ref);
+   ttm_global_release(&rdev->mman.glob);
rdev->mman.mem_global_referenced = false;
}
 }
@@ -853,7 +823,7 @@ int radeon_ttm_init(struct radeon_device *rdev)
}
/* No others user of address space so set it to 0 */
r = ttm_bo_device_init(&rdev->mman.bdev,
-  rdev->mman.bo_global_ref.ref.object,
+  ttm_global_get_bo_global(&rdev->mman.glob),
   &radeon_bo_driver,
   rdev->ddev->anon_inode->i_mapping,
   DRM_FILE_PAGE_OFFSET,
-- 
2.19.1

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


[PATCH 10/18] drm/qlx: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/qxl/qxl_drv.h |  4 ++--
 drivers/gpu/drm/qxl/qxl_ttm.c | 40 ---
 2 files changed, 6 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 8ff70a7281a7..64232a2684fd 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "qxl_dev.h"
@@ -127,9 +128,8 @@ struct qxl_output {
 #define drm_encoder_to_qxl_output(x) container_of(x, struct qxl_output, enc)
 
 struct qxl_mman {
-   struct ttm_bo_global_refbo_global_ref;
-   struct drm_global_reference mem_global_ref;
boolmem_global_referenced;
+   struct ttm_global   glob;
struct ttm_bo_devicebdev;
 };
 
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index db2a0036e9c4..2e852fac97d3 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -46,46 +46,15 @@ static struct qxl_device *qxl_get_qdev(struct ttm_bo_device 
*bdev)
return qdev;
 }
 
-static int qxl_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void qxl_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 static int qxl_ttm_global_init(struct qxl_device *qdev)
 {
-   struct drm_global_reference *global_ref;
int r;
 
qdev->mman.mem_global_referenced = false;
-   global_ref = &qdev->mman.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &qxl_ttm_mem_global_init;
-   global_ref->release = &qxl_ttm_mem_global_release;
-
-   r = drm_global_item_ref(global_ref);
-   if (r != 0) {
-   DRM_ERROR("Failed setting up TTM memory accounting "
- "subsystem.\n");
-   return r;
-   }
 
-   qdev->mman.bo_global_ref.mem_glob =
-   qdev->mman.mem_global_ref.object;
-   global_ref = &qdev->mman.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-   r = drm_global_item_ref(global_ref);
+   r = ttm_global_init(&qdev->mman.glob);
if (r != 0) {
-   DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-   drm_global_item_unref(&qdev->mman.mem_global_ref);
+   DRM_ERROR("Failed setting up TTM subsystem.\n");
return r;
}
 
@@ -96,8 +65,7 @@ static int qxl_ttm_global_init(struct qxl_device *qdev)
 static void qxl_ttm_global_fini(struct qxl_device *qdev)
 {
if (qdev->mman.mem_global_referenced) {
-   drm_global_item_unref(&qdev->mman.bo_global_ref.ref);
-   drm_global_item_unref(&qdev->mman.mem_global_ref);
+   ttm_global_release(&qdev->mman.glob);
qdev->mman.mem_global_referenced = false;
}
 }
@@ -378,7 +346,7 @@ int qxl_ttm_init(struct qxl_device *qdev)
return r;
/* No others user of address space so set it to 0 */
r = ttm_bo_device_init(&qdev->mman.bdev,
-  qdev->mman.bo_global_ref.ref.object,
+  qdev->mman.glob.bo_ref.object,
   &qxl_bo_driver,
   qdev->ddev.anon_inode->i_mapping,
   DRM_FILE_PAGE_OFFSET, 0);
-- 
2.19.1

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


[PATCH 06/18] drm/cirrus: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h |  5 +--
 drivers/gpu/drm/cirrus/cirrus_ttm.c | 49 +
 2 files changed, 11 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index a29f87e98d9d..f62774cfb68e 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -136,9 +137,9 @@ struct cirrus_device {
int fb_mtrr;
 
struct {
-   struct drm_global_reference mem_global_ref;
-   struct ttm_bo_global_ref bo_global_ref;
+   struct ttm_global glob;
struct ttm_bo_device bdev;
+   bool glob_initialized;
} ttm;
bool mm_inited;
 };
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c 
b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 2e2141f26c5b..f1c5e6b8e80a 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -36,60 +36,27 @@ cirrus_bdev(struct ttm_bo_device *bd)
return container_of(bd, struct cirrus_device, ttm.bdev);
 }
 
-static int
-cirrus_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void
-cirrus_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 static int cirrus_ttm_global_init(struct cirrus_device *cirrus)
 {
-   struct drm_global_reference *global_ref;
-   int r;
-
-   global_ref = &cirrus->ttm.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &cirrus_ttm_mem_global_init;
-   global_ref->release = &cirrus_ttm_mem_global_release;
-   r = drm_global_item_ref(global_ref);
+   int r = ttm_global_init(&cirrus->ttm.glob);
if (r != 0) {
-   DRM_ERROR("Failed setting up TTM memory accounting "
- "subsystem.\n");
+   DRM_ERROR("Failed setting up TTM subsystem.\n");
return r;
}
 
-   cirrus->ttm.bo_global_ref.mem_glob =
-   cirrus->ttm.mem_global_ref.object;
-   global_ref = &cirrus->ttm.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-   r = drm_global_item_ref(global_ref);
-   if (r != 0) {
-   DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-   drm_global_item_unref(&cirrus->ttm.mem_global_ref);
-   return r;
-   }
+   cirrus->ttm.glob_initialized = true;
+
return 0;
 }
 
 static void
 cirrus_ttm_global_release(struct cirrus_device *cirrus)
 {
-   if (cirrus->ttm.mem_global_ref.release == NULL)
+   if (!cirrus->ttm.glob_initialized)
return;
 
-   drm_global_item_unref(&cirrus->ttm.bo_global_ref.ref);
-   drm_global_item_unref(&cirrus->ttm.mem_global_ref);
-   cirrus->ttm.mem_global_ref.release = NULL;
+   ttm_global_init(&cirrus->ttm.glob);
+   cirrus->ttm.glob_initialized = false;
 }
 
 
@@ -237,7 +204,7 @@ int cirrus_mm_init(struct cirrus_device *cirrus)
return ret;
 
ret = ttm_bo_device_init(&cirrus->ttm.bdev,
-cirrus->ttm.bo_global_ref.ref.object,
+cirrus->ttm.glob.bo_ref.object,
 &cirrus_bo_driver,
 dev->anon_inode->i_mapping,
 DRM_FILE_PAGE_OFFSET,
-- 
2.19.1

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


[PATCH 14/18] drm/ttm: Remove struct ttm_bo_global_ref and helpers

2018-10-19 Thread Thomas Zimmermann
The struct ttm_bo_global_ref data type providede a workaround for passing
an instance of struct ttm_mem_global to ttm_bo_global_init().

This functionality has been replaced by struct ttm_global and all drivers
have been converted. struct ttm_bo_global_ref is obsolete.

Signed-off-by: Thomas Zimmermann 
---
 include/drm/ttm/ttm_bo_driver.h | 40 -
 1 file changed, 40 deletions(-)

diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index c6ee07d10281..e51ced5f5e75 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -31,7 +31,6 @@
 #define _TTM_BO_DRIVER_H_
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -889,43 +888,4 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
 
 extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
 
-/**
- * struct ttm_bo_global_ref - Argument to initialize a struct ttm_bo_global.
- */
-
-struct ttm_bo_global_ref {
-   struct drm_global_reference ref;
-   struct ttm_mem_global *mem_glob;
-};
-
-/**
- * ttm_bo_global_ref_init
- *
- * @ref: DRM global reference
- *
- * Helper function that initializes a struct ttm_bo_global. This function
- * is used as init call-back function for DRM global references of type
- * DRM_GLOBAL_TTM_BO_REF.
- */
-static inline int ttm_bo_global_ref_init(struct drm_global_reference *ref)
-{
-   struct ttm_bo_global_ref *bo_ref =
-   container_of(ref, struct ttm_bo_global_ref, ref);
-   return ttm_bo_global_init(ref->object, bo_ref->mem_glob);
-}
-
-/**
- * ttm_bo_global_ref_release
- *
- * @ref: DRM global reference
- *
- * Helper function that releases a struct ttm_bo_global. This function
- * is used as release call-back function for DRM global references of type
- * DRM_GLOBAL_TTM_BO_REF.
- */
-static inline void ttm_bo_global_ref_release(struct drm_global_reference *ref)
-{
-   ttm_bo_global_release(ref->object);
-}
-
 #endif
-- 
2.19.1

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


[PATCH 09/18] drm/nouveau: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/nouveau/nouveau_drv.h |  5 +--
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 48 ---
 2 files changed, 9 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h 
b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 0b2191fa96f7..0d5a78f4ad75 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -54,6 +54,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "uapi/drm/nouveau_drm.h"
 
@@ -146,9 +147,9 @@ struct nouveau_drm {
 
/* TTM interface support */
struct {
-   struct drm_global_reference mem_global_ref;
-   struct ttm_bo_global_ref bo_global_ref;
+   struct ttm_global glob;
struct ttm_bo_device bdev;
+   bool glob_initialized;
atomic_t validate_sequence;
int (*move)(struct nouveau_channel *,
struct ttm_buffer_object *,
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c 
b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index a293383c8654..f2bd707ad7b1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -174,51 +174,16 @@ nouveau_ttm_mmap(struct file *filp, struct vm_area_struct 
*vma)
return ttm_bo_mmap(filp, vma, &drm->ttm.bdev);
 }
 
-static int
-nouveau_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void
-nouveau_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 int
 nouveau_ttm_global_init(struct nouveau_drm *drm)
 {
-   struct drm_global_reference *global_ref;
-   int ret;
-
-   global_ref = &drm->ttm.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &nouveau_ttm_mem_global_init;
-   global_ref->release = &nouveau_ttm_mem_global_release;
-
-   ret = drm_global_item_ref(global_ref);
+   int ret = ttm_global_init(&drm->ttm.glob);
if (unlikely(ret != 0)) {
DRM_ERROR("Failed setting up TTM memory accounting\n");
-   drm->ttm.mem_global_ref.release = NULL;
return ret;
}
 
-   drm->ttm.bo_global_ref.mem_glob = global_ref->object;
-   global_ref = &drm->ttm.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-
-   ret = drm_global_item_ref(global_ref);
-   if (unlikely(ret != 0)) {
-   DRM_ERROR("Failed setting up TTM BO subsystem\n");
-   drm_global_item_unref(&drm->ttm.mem_global_ref);
-   drm->ttm.mem_global_ref.release = NULL;
-   return ret;
-   }
+   drm->ttm.glob_initialized = true;
 
return 0;
 }
@@ -226,12 +191,11 @@ nouveau_ttm_global_init(struct nouveau_drm *drm)
 void
 nouveau_ttm_global_release(struct nouveau_drm *drm)
 {
-   if (drm->ttm.mem_global_ref.release == NULL)
+   if (!drm->ttm.glob_initialized)
return;
 
-   drm_global_item_unref(&drm->ttm.bo_global_ref.ref);
-   drm_global_item_unref(&drm->ttm.mem_global_ref);
-   drm->ttm.mem_global_ref.release = NULL;
+   ttm_global_release(&drm->ttm.glob);
+   drm->ttm.glob_initialized = false;
 }
 
 static int
@@ -301,7 +265,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
return ret;
 
ret = ttm_bo_device_init(&drm->ttm.bdev,
- drm->ttm.bo_global_ref.ref.object,
+ drm->ttm.glob.bo_ref.object,
  &nouveau_bo_driver,
  dev->anon_inode->i_mapping,
  DRM_FILE_PAGE_OFFSET,
-- 
2.19.1

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


[PATCH 07/18] drm/hisilicon: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   |  4 +--
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   | 36 ++-
 2 files changed, 5 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
index 45c25a488f42..1091f3bb81c4 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct hibmc_framebuffer {
struct drm_framebuffer fb;
@@ -49,8 +50,7 @@ struct hibmc_drm_private {
bool mode_config_initialized;
 
/* ttm */
-   struct drm_global_reference mem_global_ref;
-   struct ttm_bo_global_ref bo_global_ref;
+   struct ttm_global glob;
struct ttm_bo_device bdev;
bool initialized;
 
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
index 0454aa43ffc6..4f51ac5d8340 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
@@ -29,53 +29,23 @@ hibmc_bdev(struct ttm_bo_device *bd)
return container_of(bd, struct hibmc_drm_private, bdev);
 }
 
-static int
-hibmc_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void
-hibmc_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 static int hibmc_ttm_global_init(struct hibmc_drm_private *hibmc)
 {
int ret;
 
-   hibmc->mem_global_ref.global_type = DRM_GLOBAL_TTM_MEM;
-   hibmc->mem_global_ref.size = sizeof(struct ttm_mem_global);
-   hibmc->mem_global_ref.init = &hibmc_ttm_mem_global_init;
-   hibmc->mem_global_ref.release = &hibmc_ttm_mem_global_release;
-   ret = drm_global_item_ref(&hibmc->mem_global_ref);
+   ret = ttm_global_init(&hibmc->glob);
if (ret) {
DRM_ERROR("could not get ref on ttm global: %d\n", ret);
return ret;
}
 
-   hibmc->bo_global_ref.mem_glob =
-   hibmc->mem_global_ref.object;
-   hibmc->bo_global_ref.ref.global_type = DRM_GLOBAL_TTM_BO;
-   hibmc->bo_global_ref.ref.size = sizeof(struct ttm_bo_global);
-   hibmc->bo_global_ref.ref.init = &ttm_bo_global_ref_init;
-   hibmc->bo_global_ref.ref.release = &ttm_bo_global_ref_release;
-   ret = drm_global_item_ref(&hibmc->bo_global_ref.ref);
-   if (ret) {
-   DRM_ERROR("failed setting up TTM BO subsystem: %d\n", ret);
-   drm_global_item_unref(&hibmc->mem_global_ref);
-   return ret;
-   }
return 0;
 }
 
 static void
 hibmc_ttm_global_release(struct hibmc_drm_private *hibmc)
 {
-   drm_global_item_unref(&hibmc->bo_global_ref.ref);
-   drm_global_item_unref(&hibmc->mem_global_ref);
-   hibmc->mem_global_ref.release = NULL;
+   ttm_global_release(&hibmc->glob);
 }
 
 static void hibmc_bo_ttm_destroy(struct ttm_buffer_object *tbo)
@@ -242,7 +212,7 @@ int hibmc_mm_init(struct hibmc_drm_private *hibmc)
return ret;
 
ret = ttm_bo_device_init(&hibmc->bdev,
-hibmc->bo_global_ref.ref.object,
+hibmc->glob.bo_ref.object,
 &hibmc_bo_driver,
 dev->anon_inode->i_mapping,
 DRM_FILE_PAGE_OFFSET,
-- 
2.19.1

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


[PATCH 15/18] drm: Remove DRM_GLOBAL_TTM_OBJECT

2018-10-19 Thread Thomas Zimmermann
The constant DRM_GLOBAL_TTM_OBJECT is unused and not obviously useful.

Signed-off-by: Thomas Zimmermann 
---
 include/drm/drm_global.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/drm/drm_global.h b/include/drm/drm_global.h
index 4482a9bbd6e9..63ffdcec6690 100644
--- a/include/drm/drm_global.h
+++ b/include/drm/drm_global.h
@@ -41,7 +41,6 @@
 enum drm_global_types {
DRM_GLOBAL_TTM_MEM = 0,
DRM_GLOBAL_TTM_BO,
-   DRM_GLOBAL_TTM_OBJECT,
DRM_GLOBAL_NUM
 };
 
-- 
2.19.1

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


Re: [PATCH] amdgpu/gmc : fix compile warning

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 10:53 AM Daniel Vetter  wrote:
>
> On Mon, Oct 08, 2018 at 06:13:56PM +, Koenig, Christian wrote:
> > Am 08.10.2018 um 19:46 schrieb Guenter Roeck:
> > > On Mon, Oct 08, 2018 at 05:22:24PM +, Koenig, Christian wrote:
> > >> Am 08.10.2018 um 17:57 schrieb Deucher, Alexander:
> > >> One thing I found missing in the discussion was the reference to the
> > >> C standard.
> > >> The C99 standard states in section 6.7.8 (Initialization) clause 19:
> > >> "... all
> > >> subobjects that are not initialized explicitly shall be initialized
> > >> implicitly the same as objects that have static storage duration".
> > >> Clause 21 makes further reference to partial initialization,
> > >> suggesting the same. Various online resources, including the gcc
> > >> documentation, all state the same. I don't find any reference to a
> > >> partial initialization which would leave members of a structure
> > >> undefined. It would be interesting for me to understand how and why
> > >> this does not apply here.
> > >>
> > >> In this context, it is interesting that the other 48 instances of the
> > >> { { 0 } } initialization in the same driver don't raise similar
> > >> concerns, nor seemed to have caused any operational problems.
> > > Feel free to provide patches to replace those with memset().
> > >
> >  Not me. As I see it, the problem, if it exists, would be a violation 
> >  of the C
> >  standard. I don't believe hacking around bad C compilers. I would 
> >  rather
> >  blacklist such compilers.
> > >> Well then you would need to blacklist basically all gcc variants of the
> > >> last decade or so.
> > >>
> > >> Initializing only known members of structures is a perfectly valid
> > >> optimization and well known issue when you then compare the structure
> > >> with memcpy() or use the bytes for hashing or something similar.
> > >>
> > > Isn't that about padding ? That is a completely different issue.
> >
> > Correct, yes. But that is the reason why I recommend using memset() for
> > zero initialization.
> >
> > See we don't know the inner layout of the structure, could be another
> > structure or an union.
> >
> > If it's a structure everything is fine because if you initialize one
> > structure member all other get their default type (whatever that means),
> > but if it's an union.
> >
> > Not sure if compilers still react allergic to that, but its the status
> > I've learned the hard way when the C99 standard came out and it still
> > seems like people are working around that so I recommend everybody to
> > stick with memset().
>
> Went boom:
>
> https://bugs.freedesktop.org/show_bug.cgi?id=108490
>
> Can we revert?
>
> Also, can we properly igt this so that intel-gfx-ci could test this before
> it's all fireworks?

Please disregard this reply, that was the wrong thread.

Sorry, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/7] drm: add syncobj timeline support v8

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 10:29:55AM +0800, zhoucm1 wrote:
> 
> 
> On 2018年10月18日 19:50, Christian König wrote:
> > Am 18.10.18 um 05:11 schrieb zhoucm1:
> > > 
> > > 
> > > On 2018年10月17日 18:24, Daniel Vetter wrote:
> > > > On Wed, Oct 17, 2018 at 11:29 AM Koenig, Christian
> > > >  wrote:
> > > > > Am 17.10.18 um 11:17 schrieb zhoucm1:
> > > > > > [SNIP]
> > > > > > > >    +struct drm_syncobj_signal_pt {
> > > > > > > > +    struct dma_fence_array *base;
> > > > > > > Out of curiosity, why the pointer and not embedding? base is kinda
> > > > > > > misleading for a pointer.
> > > > > > Yeah, Christian doesn't like signal_pt lifecycle same as fence, so
> > > > > > it's a pointer.
> > > > > > If you don't like 'base' name, I can change it.
> > > > > Well I never said that you can't embed the fence array into
> > > > > the signal_pt.
> > > > > 
> > > > > You just need to make sure that we don't affect the drm_syncobj
> > > > > lilecycle as well, e.g. that we don't also need to keep that around.
> > > > I don't see a problem with that, as long as drm_syncobj keeps a
> > > > reference to the fence while it's on the timeline list. Which it
> > > > already does. And embedding would avoid that 2nd separate allocation,
> > > > aside from making base less confusing.
> > > That's indeed my initial implementation for signal_pt/wait_pt with
> > > fence based, but after long and many discussions, we get current
> > > solution, as you see, the version is up to v8 :).
> > > 
> > > For here  why the pointer and not embedding?
> > > Two reasons:
> > > 1. their lifecycles are not same.
> > > 2. It is a fence array usage, which always needs separate
> > > allocation, seems which is mandatory.
> > > So it is a pointer.
> > > 
> > > But the name is historical from initial, and indeed be kinda
> > > misleading for a pointer, I will change it to fence_array instead in
> > > coming v9.
> > 
> > To avoid running into a v10 I've just pushed this version upstream :)
> Thanks a lot.

(This time reply to the right patch, silly me)

Went boom:

https://bugs.freedesktop.org/show_bug.cgi?id=108490

Can we revert pls?

Also, can we please have igts for this stuff so that intel-gfx-ci could
test this properly before it's all fireworks?

Thanks, Daniel

> > 
> > The rest in the series looks good to me as well,
> Can I get your RB on them first?
> 
> > but I certainly want the radv/anv developers to take a look as well as
> > Daniel suggested.
> Ping @Dave/Bas/Jason or other radv/anv developers, Could anyone of you take
> a look the rest of series for u/k interface? So that we can move to next
> step for libdrm patches?
> 
> Thanks,
> David
> > 
> > Christian.
> > 
> > > 
> > > Thanks,
> > > David Zhou
> > > 
> > > > -Daniel
> > > 
> > > ___
> > > amd-gfx mailing list
> > > amd-...@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> > 
> 

-- 
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 13/18] staging/vboxvideo: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/staging/vboxvideo/vbox_drv.h |  4 +--
 drivers/staging/vboxvideo/vbox_ttm.c | 42 +++-
 2 files changed, 6 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h 
b/drivers/staging/vboxvideo/vbox_drv.h
index 594f84272957..21cca25d00f5 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vboxvideo_guest.h"
 #include "vboxvideo_vbe.h"
@@ -95,8 +96,7 @@ struct vbox_private {
int fb_mtrr;
 
struct {
-   struct drm_global_reference mem_global_ref;
-   struct ttm_bo_global_ref bo_global_ref;
+   struct ttm_global glob;
struct ttm_bo_device bdev;
} ttm;
 
diff --git a/drivers/staging/vboxvideo/vbox_ttm.c 
b/drivers/staging/vboxvideo/vbox_ttm.c
index 2329a55d4636..4c2c75daf94c 100644
--- a/drivers/staging/vboxvideo/vbox_ttm.c
+++ b/drivers/staging/vboxvideo/vbox_ttm.c
@@ -35,49 +35,16 @@ static inline struct vbox_private *vbox_bdev(struct 
ttm_bo_device *bd)
return container_of(bd, struct vbox_private, ttm.bdev);
 }
 
-static int vbox_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void vbox_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 /**
  * Adds the vbox memory manager object/structures to the global memory manager.
  */
 static int vbox_ttm_global_init(struct vbox_private *vbox)
 {
-   struct drm_global_reference *global_ref;
-   int ret;
-
-   global_ref = &vbox->ttm.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &vbox_ttm_mem_global_init;
-   global_ref->release = &vbox_ttm_mem_global_release;
-   ret = drm_global_item_ref(global_ref);
+   int ret = ttm_global_init(&vbox->ttm.glob);
if (ret) {
-   DRM_ERROR("Failed setting up TTM memory subsystem.\n");
+   DRM_ERROR("Failed setting up TTM subsystem.\n");
return ret;
}
-
-   vbox->ttm.bo_global_ref.mem_glob = vbox->ttm.mem_global_ref.object;
-   global_ref = &vbox->ttm.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-
-   ret = drm_global_item_ref(global_ref);
-   if (ret) {
-   DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-   drm_global_item_unref(&vbox->ttm.mem_global_ref);
-   return ret;
-   }
-
return 0;
 }
 
@@ -86,8 +53,7 @@ static int vbox_ttm_global_init(struct vbox_private *vbox)
  */
 static void vbox_ttm_global_release(struct vbox_private *vbox)
 {
-   drm_global_item_unref(&vbox->ttm.bo_global_ref.ref);
-   drm_global_item_unref(&vbox->ttm.mem_global_ref);
+   ttm_global_release(&vbox->ttm.glob);
 }
 
 static void vbox_bo_ttm_destroy(struct ttm_buffer_object *tbo)
@@ -232,7 +198,7 @@ int vbox_mm_init(struct vbox_private *vbox)
return ret;
 
ret = ttm_bo_device_init(&vbox->ttm.bdev,
-vbox->ttm.bo_global_ref.ref.object,
+vbox->ttm.glob.bo_ref.object,
 &vbox_bo_driver,
 dev->anon_inode->i_mapping,
 DRM_FILE_PAGE_OFFSET, true);
-- 
2.19.1

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


[PATCH 16/18] drm/ttm: Implement struct ttm_global_item and helpers

2018-10-19 Thread Thomas Zimmermann
The data structure struct ttm_global_item is a replacement for struct
drm_global_item. While struct drm_global_item depends on global data
instances, struct ttm_global_item allows drivers to use their own privat
instances.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/ttm/ttm_global.c | 98 
 include/drm/ttm/ttm_global.h | 22 +++
 2 files changed, 120 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_global.c b/drivers/gpu/drm/ttm/ttm_global.c
index ca9da0a46147..1e5c2f5eeca0 100644
--- a/drivers/gpu/drm/ttm/ttm_global.c
+++ b/drivers/gpu/drm/ttm/ttm_global.c
@@ -31,6 +31,104 @@
 #include 
 #include 
 
+/*
+ * struct ttm_global_item
+ */
+
+struct ttm_global_item {
+   struct mutex mutex;
+   void *object;
+   int refcount;
+};
+
+#define TTM_GLOBAL_ITEM_INIT(name_) { \
+   .mutex = __MUTEX_INITIALIZER(name_.mutex), \
+   .object = NULL, \
+   .refcount = 0 }
+
+#define DEFINE_TTM_GLOBAL_ITEM_ARRAY(name_) \
+   struct ttm_global_item name_[TTM_NUM_GLOBAL_TYPES] = { \
+   [0] = TTM_GLOBAL_ITEM_INIT(name_[0]), \
+   [1] = TTM_GLOBAL_ITEM_INIT(name_[0]) \
+   }
+
+/**
+ * ttm_global_item_ref - Initialize and acquire reference to a global TTM item
+ *
+ * @items: Array of global TTM items
+ * @ref: Object for initialization
+ * @return Zero on success, or a negative error code otherwise.
+ *
+ * This initializes a TTM item by allocating memory and calling the
+ * .init() hook. Further calls will increase the reference count for
+ * that item.
+ */
+static int ttm_global_item_ref(
+   struct ttm_global_item items[TTM_NUM_GLOBAL_TYPES],
+   struct ttm_global_ref *ref)
+{
+   struct ttm_global_item *item = &items[ref->global_type];
+   int ret = 0;
+
+   mutex_lock(&item->mutex);
+   if (item->refcount == 0) {
+   ref->object = kzalloc(ref->size, GFP_KERNEL);
+   if (unlikely(ref->object == NULL)) {
+   ret = -ENOMEM;
+   goto error_mutex_unlock;
+   }
+   ret = ref->init(ref);
+   if (unlikely(ret != 0))
+   goto error_kfree;
+
+   item->object = ref->object;
+   } else {
+   ref->object = item->object;
+   }
+
+   ++item->refcount;
+   mutex_unlock(&item->mutex);
+
+   return 0;
+
+error_kfree:
+   kfree(ref->object);
+   ref->object = NULL;
+error_mutex_unlock:
+   mutex_unlock(&item->mutex);
+   return ret;
+}
+
+/**
+ * ttm_global_item_unref - Drop reference to global TTM item
+ *
+ * @items: Array of global TTM items
+ * @ref: Object being removed
+ *
+ * Drops a reference to the global TTM item and eventually call the
+ * release() hook. The allocated object should be dropped in the
+ * release() hook or before calling this function
+ */
+static void ttm_global_item_unref(
+   struct ttm_global_item items[TTM_NUM_GLOBAL_TYPES],
+   struct ttm_global_ref *ref)
+{
+   struct ttm_global_item *item = &items[ref->global_type];
+
+   mutex_lock(&item->mutex);
+   BUG_ON(item->refcount == 0);
+   BUG_ON(ref->object != item->object);
+   if (--item->refcount == 0) {
+   ref->release(ref);
+   item->object = NULL;
+   }
+   mutex_unlock(&item->mutex);
+}
+
+/*
+ * struct ttm_global
+ */
+
 static int ttm_global_init_mem(struct drm_global_reference *ref)
 {
BUG_ON(!ref->object);
diff --git a/include/drm/ttm/ttm_global.h b/include/drm/ttm/ttm_global.h
index 06e791499f87..9aa0ddbbe2ef 100644
--- a/include/drm/ttm/ttm_global.h
+++ b/include/drm/ttm/ttm_global.h
@@ -29,6 +29,28 @@
 #define _TTM_GLOBAL_H_
 
 #include 
+#include 
+#include 
+
+/**
+ * enum ttm_global_types - Enumerates types of global TTM state
+ */
+enum ttm_global_types {
+   TTM_GLOBAL_MEM = 0,
+   TTM_GLOBAL_BO,
+   TTM_NUM_GLOBAL_TYPES
+};
+
+/**
+ * struct ttm_global_ref - References global TTM item
+ */
+struct ttm_global_ref {
+   enum ttm_global_types global_type;
+   size_t size;
+   void *object;
+   int (*init) (struct ttm_global_ref *);
+   void (*release) (struct ttm_global_ref *);
+};
 
 struct ttm_bo_global;
 
-- 
2.19.1

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


[PATCH 17/18] drm/ttm: Implement struct ttm_global with struct ttm_global_ref

2018-10-19 Thread Thomas Zimmermann
Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/ttm/ttm_global.c | 28 +++-
 include/drm/ttm/ttm_global.h |  5 ++---
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_global.c b/drivers/gpu/drm/ttm/ttm_global.c
index 1e5c2f5eeca0..93d268daf97b 100644
--- a/drivers/gpu/drm/ttm/ttm_global.c
+++ b/drivers/gpu/drm/ttm/ttm_global.c
@@ -129,19 +129,21 @@ static void ttm_global_item_unref(
  * struct ttm_global
  */
 
-static int ttm_global_init_mem(struct drm_global_reference *ref)
+static DEFINE_TTM_GLOBAL_ITEM_ARRAY(global_items);
+
+static int ttm_global_init_mem(struct ttm_global_ref *ref)
 {
BUG_ON(!ref->object);
return ttm_mem_global_init(ref->object);
 }
 
-static void ttm_global_release_mem(struct drm_global_reference *ref)
+static void ttm_global_release_mem(struct ttm_global_ref *ref)
 {
BUG_ON(!ref->object);
ttm_mem_global_release(ref->object);
 }
 
-static int ttm_global_init_bo(struct drm_global_reference *ref)
+static int ttm_global_init_bo(struct ttm_global_ref *ref)
 {
struct ttm_global *glob =
container_of(ref, struct ttm_global, bo_ref);
@@ -150,7 +152,7 @@ static int ttm_global_init_bo(struct drm_global_reference 
*ref)
return ttm_bo_global_init(ref->object, glob->mem_ref.object);
 }
 
-static void ttm_global_release_bo(struct drm_global_reference *ref)
+static void ttm_global_release_bo(struct ttm_global_ref *ref)
 {
BUG_ON(!ref->object);
ttm_bo_global_release(ref->object);
@@ -160,28 +162,28 @@ int ttm_global_init(struct ttm_global *glob)
 {
int ret;
 
-   glob->mem_ref.global_type = DRM_GLOBAL_TTM_MEM;
+   glob->mem_ref.global_type = TTM_GLOBAL_MEM;
glob->mem_ref.size = sizeof(struct ttm_mem_global);
glob->bo_ref.object = NULL;
glob->mem_ref.init = &ttm_global_init_mem;
glob->mem_ref.release = &ttm_global_release_mem;
-   ret = drm_global_item_ref(&glob->mem_ref);
+   ret = ttm_global_item_ref(global_items, &glob->mem_ref);
if (ret)
return ret;
 
-   glob->bo_ref.global_type = DRM_GLOBAL_TTM_BO;
+   glob->bo_ref.global_type = TTM_GLOBAL_BO;
glob->bo_ref.size = sizeof(struct ttm_bo_global);
glob->bo_ref.object = NULL;
glob->bo_ref.init = &ttm_global_init_bo;
glob->bo_ref.release = &ttm_global_release_bo;
-   ret = drm_global_item_ref(&glob->bo_ref);
+   ret = ttm_global_item_ref(global_items, &glob->bo_ref);
if (ret)
-   goto err_drm_global_item_unref_mem;
+   goto err_ttm_global_item_unref;
 
return 0;
 
-err_drm_global_item_unref_mem:
-   drm_global_item_unref(&glob->mem_ref);
+err_ttm_global_item_unref:
+   ttm_global_item_unref(global_items, &glob->mem_ref);
return ret;
 }
 
@@ -189,8 +191,8 @@ EXPORT_SYMBOL(ttm_global_init);
 
 void ttm_global_release(struct ttm_global *glob)
 {
-   drm_global_item_unref(&glob->bo_ref);
-   drm_global_item_unref(&glob->mem_ref);
+   ttm_global_item_unref(global_items, &glob->bo_ref);
+   ttm_global_item_unref(global_items, &glob->mem_ref);
 }
 
 EXPORT_SYMBOL(ttm_global_release);
diff --git a/include/drm/ttm/ttm_global.h b/include/drm/ttm/ttm_global.h
index 9aa0ddbbe2ef..8dedac053611 100644
--- a/include/drm/ttm/ttm_global.h
+++ b/include/drm/ttm/ttm_global.h
@@ -28,7 +28,6 @@
 #ifndef _TTM_GLOBAL_H_
 #define _TTM_GLOBAL_H_
 
-#include 
 #include 
 #include 
 
@@ -58,8 +57,8 @@ struct ttm_bo_global;
  * struct ttm_global - Stores references to global TTM state
  */
 struct ttm_global {
-   struct drm_global_reference mem_ref;
-   struct drm_global_reference bo_ref;
+   struct ttm_global_ref mem_ref;
+   struct ttm_global_ref bo_ref;
 };
 
 /**
-- 
2.19.1

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


[PATCH 18/18] drm: Remove drm_global.{c,h}

2018-10-19 Thread Thomas Zimmermann
The content of drm_global.{c,h} is obsolete. The functionality is provided
in ttm_global.{c,h}.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/Makefile |   2 +-
 drivers/gpu/drm/drm_drv.c|   2 -
 drivers/gpu/drm/drm_global.c | 137 ---
 drivers/gpu/drm/gma500/psb_drv.h |   4 +-
 include/drm/drmP.h   |   1 -
 include/drm/drm_global.h |  60 --
 6 files changed, 3 insertions(+), 203 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_global.c
 delete mode 100644 include/drm/drm_global.h

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 576ba985e138..7f3be3506057 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -11,7 +11,7 @@ drm-y   :=drm_auth.o drm_bufs.o drm_cache.o \
drm_sysfs.o drm_hashtab.o drm_mm.o \
drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \
drm_info.o drm_encoder_slave.o \
-   drm_trace_points.o drm_global.o drm_prime.o \
+   drm_trace_points.o drm_prime.o \
drm_rect.o drm_vma_manager.o drm_flip_work.o \
drm_modeset_lock.o drm_atomic.o drm_bridge.o \
drm_framebuffer.o drm_connector.o drm_blend.o \
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 36e8e9cbec52..fc29f46b7c32 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -975,14 +975,12 @@ static void drm_core_exit(void)
drm_sysfs_destroy();
idr_destroy(&drm_minors_idr);
drm_connector_ida_destroy();
-   drm_global_release();
 }
 
 static int __init drm_core_init(void)
 {
int ret;
 
-   drm_global_init();
drm_connector_ida_init();
idr_init(&drm_minors_idr);
 
diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
deleted file mode 100644
index 5799e2782dd1..
--- a/drivers/gpu/drm/drm_global.c
+++ /dev/null
@@ -1,137 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0 OR MIT
-/**
- *
- * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **/
-/*
- * Authors: Thomas Hellstrom 
- */
-
-#include 
-#include 
-#include 
-#include 
-
-struct drm_global_item {
-   struct mutex mutex;
-   void *object;
-   int refcount;
-};
-
-static struct drm_global_item glob[DRM_GLOBAL_NUM];
-
-void drm_global_init(void)
-{
-   int i;
-
-   for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
-   struct drm_global_item *item = &glob[i];
-   mutex_init(&item->mutex);
-   item->object = NULL;
-   item->refcount = 0;
-   }
-}
-
-void drm_global_release(void)
-{
-   int i;
-   for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
-   struct drm_global_item *item = &glob[i];
-   BUG_ON(item->object != NULL);
-   BUG_ON(item->refcount != 0);
-   }
-}
-
-/**
- * drm_global_item_ref - Initialize and acquire reference to memory
- * object
- * @ref: Object for initialization
- *
- * This initializes a memory object, allocating memory and calling the
- * .init() hook. Further calls will increase the reference count for
- * that item.
- *
- * Returns:
- * Zero on success, non-zero otherwise.
- */
-int drm_global_item_ref(struct drm_global_reference *ref)
-{
-   int ret = 0;
-   struct drm_global_item *item = &glob[ref->global_type];
-
-   mutex_lock(&item->mutex);
-   if (item->refcount == 0) {
-   ref->object = kzalloc(ref->size, GFP_KERNEL);
-   if (unlikely(ref->object == NULL)) {
-   ret = -ENOMEM;
-   goto error_unlock;
-   }
-   

[PATCH 11/18] drm/virtio: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/virtio/virtgpu_drv.h |  4 +--
 drivers/gpu/drm/virtio/virtgpu_ttm.c | 40 +++-
 2 files changed, 6 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h 
b/drivers/gpu/drm/virtio/virtgpu_drv.h
index d29f0c7c768c..502e4d531df7 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DRIVER_NAME "virtio_gpu"
 #define DRIVER_DESC "virtio GPU"
@@ -142,9 +143,8 @@ struct virtio_gpu_fbdev {
 };
 
 struct virtio_gpu_mman {
-   struct ttm_bo_global_refbo_global_ref;
-   struct drm_global_reference mem_global_ref;
boolmem_global_referenced;
+   struct ttm_global   glob;
struct ttm_bo_devicebdev;
 };
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_ttm.c 
b/drivers/gpu/drm/virtio/virtgpu_ttm.c
index 526a5e48dc3b..113491cc6595 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ttm.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ttm.c
@@ -50,46 +50,15 @@ virtio_gpu_device *virtio_gpu_get_vgdev(struct 
ttm_bo_device *bdev)
return vgdev;
 }
 
-static int virtio_gpu_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void virtio_gpu_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 static int virtio_gpu_ttm_global_init(struct virtio_gpu_device *vgdev)
 {
-   struct drm_global_reference *global_ref;
int r;
 
vgdev->mman.mem_global_referenced = false;
-   global_ref = &vgdev->mman.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &virtio_gpu_ttm_mem_global_init;
-   global_ref->release = &virtio_gpu_ttm_mem_global_release;
-
-   r = drm_global_item_ref(global_ref);
-   if (r != 0) {
-   DRM_ERROR("Failed setting up TTM memory accounting "
- "subsystem.\n");
-   return r;
-   }
 
-   vgdev->mman.bo_global_ref.mem_glob =
-   vgdev->mman.mem_global_ref.object;
-   global_ref = &vgdev->mman.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-   r = drm_global_item_ref(global_ref);
+   r = ttm_global_init(&vgdev->mman.glob);
if (r != 0) {
-   DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-   drm_global_item_unref(&vgdev->mman.mem_global_ref);
+   DRM_ERROR("Failed setting up TTM subsystem.\n");
return r;
}
 
@@ -100,8 +69,7 @@ static int virtio_gpu_ttm_global_init(struct 
virtio_gpu_device *vgdev)
 static void virtio_gpu_ttm_global_fini(struct virtio_gpu_device *vgdev)
 {
if (vgdev->mman.mem_global_referenced) {
-   drm_global_item_unref(&vgdev->mman.bo_global_ref.ref);
-   drm_global_item_unref(&vgdev->mman.mem_global_ref);
+   ttm_global_release(&vgdev->mman.glob);
vgdev->mman.mem_global_referenced = false;
}
 }
@@ -388,7 +356,7 @@ int virtio_gpu_ttm_init(struct virtio_gpu_device *vgdev)
return r;
/* No others user of address space so set it to 0 */
r = ttm_bo_device_init(&vgdev->mman.bdev,
-  vgdev->mman.bo_global_ref.ref.object,
+  vgdev->mman.glob.bo_ref.object,
   &virtio_gpu_bo_driver,
   vgdev->ddev->anon_inode->i_mapping,
   DRM_FILE_PAGE_OFFSET, 0);
-- 
2.19.1

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


[PATCH 08/18] drm/mgag200: Replace TTM initialization/release with ttm_global

2018-10-19 Thread Thomas Zimmermann
Unified initialization and release of the global TTM state is provided
by struct ttm_global and its interfaces.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/mgag200/mgag200_drv.h |  7 ++--
 drivers/gpu/drm/mgag200/mgag200_ttm.c | 49 +--
 2 files changed, 12 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 04f1dfba12e5..f82c1034b2ea 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -1,6 +1,6 @@
 /*
  * Copyright 2010 Matt Turner.
- * Copyright 2012 Red Hat 
+ * Copyright 2012 Red Hat
  *
  * This file is subject to the terms and conditions of the GNU General
  * Public License version 2. See the file COPYING in the main
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -212,9 +213,9 @@ struct mga_device {
int fb_mtrr;
 
struct {
-   struct drm_global_reference mem_global_ref;
-   struct ttm_bo_global_ref bo_global_ref;
+   struct ttm_global glob;
struct ttm_bo_device bdev;
+   bool glob_initialized;
} ttm;
 
/* SE model number stored in reg 0x1e24 */
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c 
b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 3444b539e7f4..52407000eb50 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -36,60 +36,27 @@ mgag200_bdev(struct ttm_bo_device *bd)
return container_of(bd, struct mga_device, ttm.bdev);
 }
 
-static int
-mgag200_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-   return ttm_mem_global_init(ref->object);
-}
-
-static void
-mgag200_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-   ttm_mem_global_release(ref->object);
-}
-
 static int mgag200_ttm_global_init(struct mga_device *ast)
 {
-   struct drm_global_reference *global_ref;
-   int r;
-
-   global_ref = &ast->ttm.mem_global_ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-   global_ref->size = sizeof(struct ttm_mem_global);
-   global_ref->init = &mgag200_ttm_mem_global_init;
-   global_ref->release = &mgag200_ttm_mem_global_release;
-   r = drm_global_item_ref(global_ref);
+   int r = ttm_global_init(&ast->ttm.glob);
if (r != 0) {
-   DRM_ERROR("Failed setting up TTM memory accounting "
- "subsystem.\n");
+   DRM_ERROR("Failed setting up TTM subsystem.\n");
return r;
}
 
-   ast->ttm.bo_global_ref.mem_glob =
-   ast->ttm.mem_global_ref.object;
-   global_ref = &ast->ttm.bo_global_ref.ref;
-   global_ref->global_type = DRM_GLOBAL_TTM_BO;
-   global_ref->size = sizeof(struct ttm_bo_global);
-   global_ref->init = &ttm_bo_global_ref_init;
-   global_ref->release = &ttm_bo_global_ref_release;
-   r = drm_global_item_ref(global_ref);
-   if (r != 0) {
-   DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-   drm_global_item_unref(&ast->ttm.mem_global_ref);
-   return r;
-   }
+   ast->ttm.glob_initialized = true;
+
return 0;
 }
 
 static void
 mgag200_ttm_global_release(struct mga_device *ast)
 {
-   if (ast->ttm.mem_global_ref.release == NULL)
+   if (!ast->ttm.glob_initialized)
return;
 
-   drm_global_item_unref(&ast->ttm.bo_global_ref.ref);
-   drm_global_item_unref(&ast->ttm.mem_global_ref);
-   ast->ttm.mem_global_ref.release = NULL;
+   ttm_global_release(&ast->ttm.glob);
+   ast->ttm.glob_initialized = false;
 }
 
 
@@ -237,7 +204,7 @@ int mgag200_mm_init(struct mga_device *mdev)
return ret;
 
ret = ttm_bo_device_init(&mdev->ttm.bdev,
-mdev->ttm.bo_global_ref.ref.object,
+mdev->ttm.glob.bo_ref.object,
 &mgag200_bo_driver,
 dev->anon_inode->i_mapping,
 DRM_FILE_PAGE_OFFSET,
-- 
2.19.1

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


Re: [PATCH 2/7] drm: add syncobj timeline support v8

2018-10-19 Thread zhoucm1



On 2018年10月19日 16:55, Daniel Vetter wrote:

On Fri, Oct 19, 2018 at 10:29:55AM +0800, zhoucm1 wrote:


On 2018年10月18日 19:50, Christian König wrote:

Am 18.10.18 um 05:11 schrieb zhoucm1:


On 2018年10月17日 18:24, Daniel Vetter wrote:

On Wed, Oct 17, 2018 at 11:29 AM Koenig, Christian
 wrote:

Am 17.10.18 um 11:17 schrieb zhoucm1:

[SNIP]

    +struct drm_syncobj_signal_pt {
+    struct dma_fence_array *base;

Out of curiosity, why the pointer and not embedding? base is kinda
misleading for a pointer.

Yeah, Christian doesn't like signal_pt lifecycle same as fence, so
it's a pointer.
If you don't like 'base' name, I can change it.

Well I never said that you can't embed the fence array into
the signal_pt.

You just need to make sure that we don't affect the drm_syncobj
lilecycle as well, e.g. that we don't also need to keep that around.

I don't see a problem with that, as long as drm_syncobj keeps a
reference to the fence while it's on the timeline list. Which it
already does. And embedding would avoid that 2nd separate allocation,
aside from making base less confusing.

That's indeed my initial implementation for signal_pt/wait_pt with
fence based, but after long and many discussions, we get current
solution, as you see, the version is up to v8 :).

For here  why the pointer and not embedding?
Two reasons:
1. their lifecycles are not same.
2. It is a fence array usage, which always needs separate
allocation, seems which is mandatory.
So it is a pointer.

But the name is historical from initial, and indeed be kinda
misleading for a pointer, I will change it to fence_array instead in
coming v9.

To avoid running into a v10 I've just pushed this version upstream :)

Thanks a lot.

(This time reply to the right patch, silly me)

Went boom:

https://bugs.freedesktop.org/show_bug.cgi?id=108490

Can we revert pls?

Sorry for bug, please.


Also, can we please have igts for this stuff so that intel-gfx-ci could
test this properly before it's all fireworks?
Seems we cannot avoid igt now and vulkan CTS isn't enough, I will find 
some time next week to lean IGT, looks v10 is need.


Regards,
David Zhou


Thanks, Daniel


The rest in the series looks good to me as well,

Can I get your RB on them first?


but I certainly want the radv/anv developers to take a look as well as
Daniel suggested.

Ping @Dave/Bas/Jason or other radv/anv developers, Could anyone of you take
a look the rest of series for u/k interface? So that we can move to next
step for libdrm patches?

Thanks,
David

Christian.


Thanks,
David Zhou


-Daniel

___
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 v2 2/2] drm/i915/intel_dsi: Read back pclk set by GOP and use that as pclk v2

2018-10-19 Thread Jani Nikula
On Wed, 17 Oct 2018, Hans de Goede  wrote:
> On BYT and CHT the GOP sometimes initializes the pclk at a (slightly)
> different frequency then the pclk which we've calculated.
>
> This commit makes the DSI code read-back the pclk set by the GOP and
> if that is within a reasonable margin of the calculated pclk, uses
> that instead.
>
> This fixes the first modeset being a full modeset instead of a
> fast modeset on systems where the GOP pclk is different.

I assume we don't do the fast path because intel_pipe_config_compare()
returns false due to crtc_clock and port_clock mismatch. The dmesg
should tell you the reason with drm.debugs enabled.

Now, the clock checks are already "fuzzy", and should account for slight
variations. I think the goal was the same as here, plus IIUC we may lose
some accuracy on the hardware roundtrip.

Please try adding more tolerance in intel_fuzzy_clock_check() and see if
that helps. The code looks like it allows 5% diff, but it's 2.5%.

Regardless of whether we end up changing the tolerance or adjusting the
state based on the hardware readout or what, I think doing the
adjustment in intel_dsi_vbt.c init is the wrong place. We shouldn't have
anything that depends on accessing the hardware there. I believe that's
what Ville was trying to say in [1].

BR,
Jani.


[1] http://mid.mail-archive.com/20180706141652.GK5565@intel.com


>
> Changes in v2:
> -Use intel_encoder_current_mode() to get the pclk setup by the GOP
>
> Signed-off-by: Hans de Goede 
> ---
>  drivers/gpu/drm/i915/intel_dsi_vbt.c | 18 ++
>  1 file changed, 18 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_dsi_vbt.c 
> b/drivers/gpu/drm/i915/intel_dsi_vbt.c
> index ac83d6b89ae0..3387b187105c 100644
> --- a/drivers/gpu/drm/i915/intel_dsi_vbt.c
> +++ b/drivers/gpu/drm/i915/intel_dsi_vbt.c
> @@ -506,6 +506,7 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 
> panel_id)
>   struct mipi_config *mipi_config = dev_priv->vbt.dsi.config;
>   struct mipi_pps_data *pps = dev_priv->vbt.dsi.pps;
>   struct drm_display_mode *mode = dev_priv->vbt.lfp_lvds_vbt_mode;
> + struct drm_display_mode *curr;
>   u32 bpp;
>   u32 tlpx_ns, extra_byte_count, bitrate, tlpx_ui;
>   u32 ui_num, ui_den;
> @@ -583,6 +584,23 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 
> panel_id)
>   } else
>   burst_mode_ratio = 100;
>  
> + /*
> +  * On BYT / CRC the GOP sometimes picks a slightly different pclk,
> +  * read back the GOP configured pclk and prefer it over ours.
> +  */
> + if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
> + curr = intel_encoder_current_mode(&intel_dsi->base);
> + if (curr) {
> + DRM_DEBUG_KMS("Calculated pclk %d GOP %d\n",
> +   pclk, curr->clock);
> + if (curr->clock >= (pclk * 9 / 10) &&
> + curr->clock <= (pclk * 11 / 10))
> + pclk = curr->clock;
> +
> + kfree(curr);
> + }
> + }
> +
>   intel_dsi->burst_mode_ratio = burst_mode_ratio;
>   intel_dsi->pclk = pclk;

-- 
Jani Nikula, Intel Open Source Graphics Center
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 2/2] drm/selftest: Add drm damage helper selftest

2018-10-19 Thread Alexandru-Cosmin Gheorghe
Hi Deepak,

Something to consider, with this approach we kind of break the
following behaviour:
"Only tests enabled as module parameters are run, if no test is
explicitly enabled then all of them are run"

What I think we should do is have just one header where we put the 
selftest(check_plane_state, igt_check_plane_statea)
...
selftest(damage_iter_no_damage, igt_damage_iter_no_damage)
...
call it drm_modeset_selftests.h

And separate just the implementations in different source files.

Then we could call run_selftests just once from test_drm_modeset_init.

Does this makes sense to you?

Thank you,
Alex Gheorghe

On Thu, Oct 18, 2018 at 01:32:03PM +, Deepak Singh Rawat wrote:
> > On Tue, Oct 16, 2018 at 01:46:09PM -0700, Deepak Rawat wrote:
> > > Selftest for drm damage helper iterator functions.
> > >
> > > Cc: Daniel Vetter 
> > > Cc: alexandru-cosmin.gheor...@arm.com
> > > Signed-off-by: Deepak Rawat 
> > > Reviewed-by: Daniel Vetter 
> > > Reviewed-by: Thomas Hellstrom 
> > 
> > I guess this needs your entire damage series to make sense, right?
> 
> Ah yes sorry. Although this patch is same as what I sent earlier
> except linking with test-drm_modeset.ko
> 
> > 
> > Another question: Does anyone from vmwgfx want drm-misc commit rights for
> > pushing stuff like this?
> 
> Hi Daniel, Thanks for the suggestion. I am not sure about eligibility 
> criteria for
> commit rights but I think I will wait until drm-mics is moved to gitlab and I 
> have
> more experience working with open-source. Beside me Thomas works on
> vmwgfx, I am not sure if he already have commit rights.
> 
> > -Daniel
> > > ---
> > >  drivers/gpu/drm/selftests/Makefile|   3 +-
> > >  .../selftests/drm_damage_helper_selftests.h   |  22 +
> > >  .../drm/selftests/test-drm_damage_helper.c| 828 ++
> > >  .../drm/selftests/test-drm_modeset_common.c   |  10 +-
> > >  .../drm/selftests/test-drm_modeset_common.h   |   1 +
> > >  5 files changed, 862 insertions(+), 2 deletions(-)
> > >  create mode 100644
> > drivers/gpu/drm/selftests/drm_damage_helper_selftests.h
> > >  create mode 100644 drivers/gpu/drm/selftests/test-drm_damage_helper.c
> > >
> > > diff --git a/drivers/gpu/drm/selftests/Makefile
> > b/drivers/gpu/drm/selftests/Makefile
> > > index 7e6581921da0..c6e63ed12f02 100644
> > > --- a/drivers/gpu/drm/selftests/Makefile
> > > +++ b/drivers/gpu/drm/selftests/Makefile
> > > @@ -1,3 +1,4 @@
> > > -test-drm_modeset-y := test-drm_modeset_common.o test-
> > drm_plane_helper.o
> > > +test-drm_modeset-y := test-drm_modeset_common.o test-
> > drm_plane_helper.o \
> > > +   test-drm_damage_helper.o
> > >
> > >  obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-
> > drm_modeset.o
> > > diff --git a/drivers/gpu/drm/selftests/drm_damage_helper_selftests.h
> > b/drivers/gpu/drm/selftests/drm_damage_helper_selftests.h
> > > new file mode 100644
> > > index ..3a1cbe05bef0
> > > --- /dev/null
> > > +++ b/drivers/gpu/drm/selftests/drm_damage_helper_selftests.h
> > > @@ -0,0 +1,22 @@
> > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > +selftest(damage_iter_no_damage, igt_damage_iter_no_damage)
> > > +selftest(damage_iter_no_damage_fractional_src,
> > igt_damage_iter_no_damage_fractional_src)
> > > +selftest(damage_iter_no_damage_src_moved,
> > igt_damage_iter_no_damage_src_moved)
> > > +selftest(damage_iter_no_damage_fractional_src_moved,
> > igt_damage_iter_no_damage_fractional_src_moved)
> > > +selftest(damage_iter_no_damage_not_visible,
> > igt_damage_iter_no_damage_not_visible)
> > > +selftest(damage_iter_no_damage_no_crtc,
> > igt_damage_iter_no_damage_no_crtc)
> > > +selftest(damage_iter_no_damage_no_fb,
> > igt_damage_iter_no_damage_no_fb)
> > > +selftest(damage_iter_simple_damage, igt_damage_iter_simple_damage)
> > > +selftest(damage_iter_single_damage, igt_damage_iter_single_damage)
> > > +selftest(damage_iter_single_damage_intersect_src,
> > igt_damage_iter_single_damage_intersect_src)
> > > +selftest(damage_iter_single_damage_outside_src,
> > igt_damage_iter_single_damage_outside_src)
> > > +selftest(damage_iter_single_damage_fractional_src,
> > igt_damage_iter_single_damage_fractional_src)
> > > +selftest(damage_iter_single_damage_intersect_fractional_src,
> > igt_damage_iter_single_damage_intersect_fractional_src)
> > > +selftest(damage_iter_single_damage_outside_fractional_src,
> > igt_damage_iter_single_damage_outside_fractional_src)
> > > +selftest(damage_iter_single_damage_src_moved,
> > igt_damage_iter_single_damage_src_moved)
> > > +selftest(damage_iter_single_damage_fractional_src_moved,
> > igt_damage_iter_single_damage_fractional_src_moved)
> > > +selftest(damage_iter_damage, igt_damage_iter_damage)
> > > +selftest(damage_iter_damage_one_intersect,
> > igt_damage_iter_damage_one_intersect)
> > > +selftest(damage_iter_damage_one_outside,
> > igt_damage_iter_damage_one_outside)
> > > +selftest(damage_iter_damage_src_moved,
> > igt_damage_iter_damage_src_moved)
> > > +self

[PATCH] drm: Revert "add syncobj timeline support v9"

2018-10-19 Thread Christian König
From: Christian König 

Still contains some bugs.

This reverts commit 48197bc564c7a1888c86024a1ba4f956e0ec2300.

Bugs: https://bugs.freedesktop.org/show_bug.cgi?id=108490
Signed-off-by: Christian König 
---
 drivers/gpu/drm/drm_syncobj.c  | 306 +++--
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   2 +-
 include/drm/drm_syncobj.h  |  67 +++--
 include/uapi/drm/drm.h |   1 -
 4 files changed, 75 insertions(+), 301 deletions(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 57bf6006394d..e2c5b3ca4824 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -56,9 +56,6 @@
 #include "drm_internal.h"
 #include 
 
-/* merge normal syncobj to timeline syncobj, the point interval is 1 */
-#define DRM_SYNCOBJ_BINARY_POINT 1
-
 struct drm_syncobj_stub_fence {
struct dma_fence base;
spinlock_t lock;
@@ -74,11 +71,6 @@ static const struct dma_fence_ops drm_syncobj_stub_fence_ops 
= {
.get_timeline_name = drm_syncobj_stub_fence_get_name,
 };
 
-struct drm_syncobj_signal_pt {
-   struct dma_fence_array *fence_array;
-   u64value;
-   struct list_head list;
-};
 
 /**
  * drm_syncobj_find - lookup and reference a sync object.
@@ -121,8 +113,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct 
drm_syncobj *syncobj,
 {
int ret;
 
-   ret = drm_syncobj_search_fence(syncobj, 0, 0, fence);
-   if (!ret)
+   *fence = drm_syncobj_fence_get(syncobj);
+   if (*fence)
return 1;
 
spin_lock(&syncobj->lock);
@@ -130,12 +122,10 @@ static int drm_syncobj_fence_get_or_add_callback(struct 
drm_syncobj *syncobj,
 * have the lock, try one more time just to be sure we don't add a
 * callback when a fence has already been set.
 */
-   if (!list_empty(&syncobj->signal_pt_list)) {
-   spin_unlock(&syncobj->lock);
-   drm_syncobj_search_fence(syncobj, 0, 0, fence);
-   if (*fence)
-   return 1;
-   spin_lock(&syncobj->lock);
+   if (syncobj->fence) {
+   *fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
+
lockdep_is_held(&syncobj->lock)));
+   ret = 1;
} else {
*fence = NULL;
drm_syncobj_add_callback_locked(syncobj, cb, func);
@@ -163,160 +153,6 @@ void drm_syncobj_remove_callback(struct drm_syncobj 
*syncobj,
spin_unlock(&syncobj->lock);
 }
 
-static void drm_syncobj_init(struct drm_syncobj *syncobj)
-{
-   spin_lock(&syncobj->lock);
-   syncobj->timeline_context = dma_fence_context_alloc(1);
-   syncobj->timeline = 0;
-   syncobj->signal_point = 0;
-   init_waitqueue_head(&syncobj->wq);
-
-   INIT_LIST_HEAD(&syncobj->signal_pt_list);
-   spin_unlock(&syncobj->lock);
-}
-
-static void drm_syncobj_fini(struct drm_syncobj *syncobj)
-{
-   struct drm_syncobj_signal_pt *signal_pt = NULL, *tmp;
-
-   spin_lock(&syncobj->lock);
-   list_for_each_entry_safe(signal_pt, tmp,
-&syncobj->signal_pt_list, list) {
-   list_del(&signal_pt->list);
-   dma_fence_put(&signal_pt->fence_array->base);
-   kfree(signal_pt);
-   }
-   spin_unlock(&syncobj->lock);
-}
-
-static struct dma_fence
-*drm_syncobj_find_signal_pt_for_point(struct drm_syncobj *syncobj,
- uint64_t point)
-{
-   struct drm_syncobj_signal_pt *signal_pt;
-
-   if ((syncobj->type == DRM_SYNCOBJ_TYPE_TIMELINE) &&
-   (point <= syncobj->timeline)) {
-   struct drm_syncobj_stub_fence *fence =
-   kzalloc(sizeof(struct drm_syncobj_stub_fence),
-   GFP_KERNEL);
-
-   if (!fence)
-   return NULL;
-   spin_lock_init(&fence->lock);
-   dma_fence_init(&fence->base,
-  &drm_syncobj_stub_fence_ops,
-  &fence->lock,
-  syncobj->timeline_context,
-  point);
-
-   dma_fence_signal(&fence->base);
-   return &fence->base;
-   }
-
-   list_for_each_entry(signal_pt, &syncobj->signal_pt_list, list) {
-   if (point > signal_pt->value)
-   continue;
-   if ((syncobj->type == DRM_SYNCOBJ_TYPE_BINARY) &&
-   (point != signal_pt->value))
-   continue;
-   return dma_fence_get(&signal_pt->fence_array->base);
-   }
-   return NULL;
-}
-
-static int drm_syncobj_create_signal_pt(struct drm_syncobj *syncobj,
-   struct dma_fence *fence,
-   u64 point)
-{
-   struct drm_

Re: [PATCH v2 2/2] drm/selftest: Add drm damage helper selftest

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 11:21 AM Alexandru-Cosmin Gheorghe
 wrote:
>
> Hi Deepak,
>
> Something to consider, with this approach we kind of break the
> following behaviour:
> "Only tests enabled as module parameters are run, if no test is
> explicitly enabled then all of them are run"
>
> What I think we should do is have just one header where we put the
> selftest(check_plane_state, igt_check_plane_statea)
> ...
> selftest(damage_iter_no_damage, igt_damage_iter_no_damage)
> ...
> call it drm_modeset_selftests.h
>
> And separate just the implementations in different source files.
>
> Then we could call run_selftests just once from test_drm_modeset_init.
>
> Does this makes sense to you?

Ack, I forgot to carefully check that. We can have only one header
file enumerate all the selftests for all the source files. We can
still have other headers of course for other stuff we're sharing (like
macros or helper functions).
-Daniel

>
> Thank you,
> Alex Gheorghe
>
> On Thu, Oct 18, 2018 at 01:32:03PM +, Deepak Singh Rawat wrote:
> > > On Tue, Oct 16, 2018 at 01:46:09PM -0700, Deepak Rawat wrote:
> > > > Selftest for drm damage helper iterator functions.
> > > >
> > > > Cc: Daniel Vetter 
> > > > Cc: alexandru-cosmin.gheor...@arm.com
> > > > Signed-off-by: Deepak Rawat 
> > > > Reviewed-by: Daniel Vetter 
> > > > Reviewed-by: Thomas Hellstrom 
> > >
> > > I guess this needs your entire damage series to make sense, right?
> >
> > Ah yes sorry. Although this patch is same as what I sent earlier
> > except linking with test-drm_modeset.ko
> >
> > >
> > > Another question: Does anyone from vmwgfx want drm-misc commit rights for
> > > pushing stuff like this?
> >
> > Hi Daniel, Thanks for the suggestion. I am not sure about eligibility 
> > criteria for
> > commit rights but I think I will wait until drm-mics is moved to gitlab and 
> > I have
> > more experience working with open-source. Beside me Thomas works on
> > vmwgfx, I am not sure if he already have commit rights.
> >
> > > -Daniel
> > > > ---
> > > >  drivers/gpu/drm/selftests/Makefile|   3 +-
> > > >  .../selftests/drm_damage_helper_selftests.h   |  22 +
> > > >  .../drm/selftests/test-drm_damage_helper.c| 828 ++
> > > >  .../drm/selftests/test-drm_modeset_common.c   |  10 +-
> > > >  .../drm/selftests/test-drm_modeset_common.h   |   1 +
> > > >  5 files changed, 862 insertions(+), 2 deletions(-)
> > > >  create mode 100644
> > > drivers/gpu/drm/selftests/drm_damage_helper_selftests.h
> > > >  create mode 100644 drivers/gpu/drm/selftests/test-drm_damage_helper.c
> > > >
> > > > diff --git a/drivers/gpu/drm/selftests/Makefile
> > > b/drivers/gpu/drm/selftests/Makefile
> > > > index 7e6581921da0..c6e63ed12f02 100644
> > > > --- a/drivers/gpu/drm/selftests/Makefile
> > > > +++ b/drivers/gpu/drm/selftests/Makefile
> > > > @@ -1,3 +1,4 @@
> > > > -test-drm_modeset-y := test-drm_modeset_common.o test-
> > > drm_plane_helper.o
> > > > +test-drm_modeset-y := test-drm_modeset_common.o test-
> > > drm_plane_helper.o \
> > > > +   test-drm_damage_helper.o
> > > >
> > > >  obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-
> > > drm_modeset.o
> > > > diff --git a/drivers/gpu/drm/selftests/drm_damage_helper_selftests.h
> > > b/drivers/gpu/drm/selftests/drm_damage_helper_selftests.h
> > > > new file mode 100644
> > > > index ..3a1cbe05bef0
> > > > --- /dev/null
> > > > +++ b/drivers/gpu/drm/selftests/drm_damage_helper_selftests.h
> > > > @@ -0,0 +1,22 @@
> > > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > > +selftest(damage_iter_no_damage, igt_damage_iter_no_damage)
> > > > +selftest(damage_iter_no_damage_fractional_src,
> > > igt_damage_iter_no_damage_fractional_src)
> > > > +selftest(damage_iter_no_damage_src_moved,
> > > igt_damage_iter_no_damage_src_moved)
> > > > +selftest(damage_iter_no_damage_fractional_src_moved,
> > > igt_damage_iter_no_damage_fractional_src_moved)
> > > > +selftest(damage_iter_no_damage_not_visible,
> > > igt_damage_iter_no_damage_not_visible)
> > > > +selftest(damage_iter_no_damage_no_crtc,
> > > igt_damage_iter_no_damage_no_crtc)
> > > > +selftest(damage_iter_no_damage_no_fb,
> > > igt_damage_iter_no_damage_no_fb)
> > > > +selftest(damage_iter_simple_damage, igt_damage_iter_simple_damage)
> > > > +selftest(damage_iter_single_damage, igt_damage_iter_single_damage)
> > > > +selftest(damage_iter_single_damage_intersect_src,
> > > igt_damage_iter_single_damage_intersect_src)
> > > > +selftest(damage_iter_single_damage_outside_src,
> > > igt_damage_iter_single_damage_outside_src)
> > > > +selftest(damage_iter_single_damage_fractional_src,
> > > igt_damage_iter_single_damage_fractional_src)
> > > > +selftest(damage_iter_single_damage_intersect_fractional_src,
> > > igt_damage_iter_single_damage_intersect_fractional_src)
> > > > +selftest(damage_iter_single_damage_outside_fractional_src,
> > > igt_damage_iter_single_damage_outside_fractional_src)
> > > > +selftest(damage_iter_single_da

Re: [PATCH] drm: Revert "add syncobj timeline support v9"

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 11:27:11AM +0200, Christian König wrote:
> From: Christian König 
> 
> Still contains some bugs.
> 
> This reverts commit 48197bc564c7a1888c86024a1ba4f956e0ec2300.

Thanks for the super-quick handling, much appreciated.

> 
> Bugs: https://bugs.freedesktop.org/show_bug.cgi?id=108490
> Signed-off-by: Christian König 

Acked-by: Daniel Vetter 

Cheers, Daniel

> ---
>  drivers/gpu/drm/drm_syncobj.c  | 306 +++--
>  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   2 +-
>  include/drm/drm_syncobj.h  |  67 +++--
>  include/uapi/drm/drm.h |   1 -
>  4 files changed, 75 insertions(+), 301 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 57bf6006394d..e2c5b3ca4824 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -56,9 +56,6 @@
>  #include "drm_internal.h"
>  #include 
>  
> -/* merge normal syncobj to timeline syncobj, the point interval is 1 */
> -#define DRM_SYNCOBJ_BINARY_POINT 1
> -
>  struct drm_syncobj_stub_fence {
>   struct dma_fence base;
>   spinlock_t lock;
> @@ -74,11 +71,6 @@ static const struct dma_fence_ops 
> drm_syncobj_stub_fence_ops = {
>   .get_timeline_name = drm_syncobj_stub_fence_get_name,
>  };
>  
> -struct drm_syncobj_signal_pt {
> - struct dma_fence_array *fence_array;
> - u64value;
> - struct list_head list;
> -};
>  
>  /**
>   * drm_syncobj_find - lookup and reference a sync object.
> @@ -121,8 +113,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct 
> drm_syncobj *syncobj,
>  {
>   int ret;
>  
> - ret = drm_syncobj_search_fence(syncobj, 0, 0, fence);
> - if (!ret)
> + *fence = drm_syncobj_fence_get(syncobj);
> + if (*fence)
>   return 1;
>  
>   spin_lock(&syncobj->lock);
> @@ -130,12 +122,10 @@ static int drm_syncobj_fence_get_or_add_callback(struct 
> drm_syncobj *syncobj,
>* have the lock, try one more time just to be sure we don't add a
>* callback when a fence has already been set.
>*/
> - if (!list_empty(&syncobj->signal_pt_list)) {
> - spin_unlock(&syncobj->lock);
> - drm_syncobj_search_fence(syncobj, 0, 0, fence);
> - if (*fence)
> - return 1;
> - spin_lock(&syncobj->lock);
> + if (syncobj->fence) {
> + *fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
> +  
> lockdep_is_held(&syncobj->lock)));
> + ret = 1;
>   } else {
>   *fence = NULL;
>   drm_syncobj_add_callback_locked(syncobj, cb, func);
> @@ -163,160 +153,6 @@ void drm_syncobj_remove_callback(struct drm_syncobj 
> *syncobj,
>   spin_unlock(&syncobj->lock);
>  }
>  
> -static void drm_syncobj_init(struct drm_syncobj *syncobj)
> -{
> - spin_lock(&syncobj->lock);
> - syncobj->timeline_context = dma_fence_context_alloc(1);
> - syncobj->timeline = 0;
> - syncobj->signal_point = 0;
> - init_waitqueue_head(&syncobj->wq);
> -
> - INIT_LIST_HEAD(&syncobj->signal_pt_list);
> - spin_unlock(&syncobj->lock);
> -}
> -
> -static void drm_syncobj_fini(struct drm_syncobj *syncobj)
> -{
> - struct drm_syncobj_signal_pt *signal_pt = NULL, *tmp;
> -
> - spin_lock(&syncobj->lock);
> - list_for_each_entry_safe(signal_pt, tmp,
> -  &syncobj->signal_pt_list, list) {
> - list_del(&signal_pt->list);
> - dma_fence_put(&signal_pt->fence_array->base);
> - kfree(signal_pt);
> - }
> - spin_unlock(&syncobj->lock);
> -}
> -
> -static struct dma_fence
> -*drm_syncobj_find_signal_pt_for_point(struct drm_syncobj *syncobj,
> -   uint64_t point)
> -{
> - struct drm_syncobj_signal_pt *signal_pt;
> -
> - if ((syncobj->type == DRM_SYNCOBJ_TYPE_TIMELINE) &&
> - (point <= syncobj->timeline)) {
> - struct drm_syncobj_stub_fence *fence =
> - kzalloc(sizeof(struct drm_syncobj_stub_fence),
> - GFP_KERNEL);
> -
> - if (!fence)
> - return NULL;
> - spin_lock_init(&fence->lock);
> - dma_fence_init(&fence->base,
> -&drm_syncobj_stub_fence_ops,
> -&fence->lock,
> -syncobj->timeline_context,
> -point);
> -
> - dma_fence_signal(&fence->base);
> - return &fence->base;
> - }
> -
> - list_for_each_entry(signal_pt, &syncobj->signal_pt_list, list) {
> - if (point > signal_pt->value)
> - continue;
> - if ((syncobj->type == DRM_SYNCOBJ_TYPE_BINARY) &&
> - (point != signal_pt->value))
> - continue;
> - re

Re: [PATCH 01/18] drm/ttm: Provide struct ttm_global for referencing TTM global state

2018-10-19 Thread Christian König
In general I'm really graceful that you look into this, but you are just 
moving the complexity around instead of cleaning it up.


This whole global reference stuff is just going into the wrong direction.

Please let me clean that up instead,
Christian.

Am 19.10.18 um 10:54 schrieb Thomas Zimmermann:

The new struct ttm_global provides drivers with TTM's global memory and
BO in a unified way. Initialization and release is handled internally.

The functionality provided by struct ttm_global is currently re-implemented
by a dozen individual DRM drivers using struct drm_global. The implementation
of struct ttm_global is also built on top of drm_global, so it can co-exists
with the existing drivers. Once all TTM-based drivers have been converted to
struct ttm_global, the implementation of struct drm_global can be made
private to TTM.

Signed-off-by: Thomas Zimmermann 
---
  drivers/gpu/drm/ttm/Makefile |  2 +-
  drivers/gpu/drm/ttm/ttm_global.c | 98 
  include/drm/drm_global.h |  8 +++
  include/drm/ttm/ttm_global.h | 79 +
  4 files changed, 186 insertions(+), 1 deletion(-)
  create mode 100644 drivers/gpu/drm/ttm/ttm_global.c
  create mode 100644 include/drm/ttm/ttm_global.h

diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile
index 01fc670ce7a2..b7272b26e9f3 100644
--- a/drivers/gpu/drm/ttm/Makefile
+++ b/drivers/gpu/drm/ttm/Makefile
@@ -5,7 +5,7 @@
  ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o \
-   ttm_page_alloc_dma.o
+   ttm_page_alloc_dma.o ttm_global.o
  ttm-$(CONFIG_AGP) += ttm_agp_backend.o
  
  obj-$(CONFIG_DRM_TTM) += ttm.o

diff --git a/drivers/gpu/drm/ttm/ttm_global.c b/drivers/gpu/drm/ttm/ttm_global.c
new file mode 100644
index ..ca9da0a46147
--- /dev/null
+++ b/drivers/gpu/drm/ttm/ttm_global.c
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+/**
+ *
+ * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **/
+
+#include 
+#include 
+#include 
+#include 
+
+static int ttm_global_init_mem(struct drm_global_reference *ref)
+{
+   BUG_ON(!ref->object);
+   return ttm_mem_global_init(ref->object);
+}
+
+static void ttm_global_release_mem(struct drm_global_reference *ref)
+{
+   BUG_ON(!ref->object);
+   ttm_mem_global_release(ref->object);
+}
+
+static int ttm_global_init_bo(struct drm_global_reference *ref)
+{
+   struct ttm_global *glob =
+   container_of(ref, struct ttm_global, bo_ref);
+   BUG_ON(!ref->object);
+   BUG_ON(!glob->mem_ref.object);
+   return ttm_bo_global_init(ref->object, glob->mem_ref.object);
+}
+
+static void ttm_global_release_bo(struct drm_global_reference *ref)
+{
+   BUG_ON(!ref->object);
+   ttm_bo_global_release(ref->object);
+}
+
+int ttm_global_init(struct ttm_global *glob)
+{
+   int ret;
+
+   glob->mem_ref.global_type = DRM_GLOBAL_TTM_MEM;
+   glob->mem_ref.size = sizeof(struct ttm_mem_global);
+   glob->bo_ref.object = NULL;
+   glob->mem_ref.init = &ttm_global_init_mem;
+   glob->mem_ref.release = &ttm_global_release_mem;
+   ret = drm_global_item_ref(&glob->mem_ref);
+   if (ret)
+   return ret;
+
+   glob->bo_ref.global_type = DRM_GLOBAL_TTM_BO;
+   glob->bo_ref.size = sizeof(struct ttm_bo_global);
+   glob->bo_ref.object = NULL;
+   glob->bo_ref.init = &ttm_global_init_bo;
+   glob->bo_ref.release = &ttm_global_release_bo;
+   ret = drm_global_item_ref(&glob->bo_ref);
+   if (ret)
+   goto

Re: [PULL] drm-intel-next-fixes

2018-10-19 Thread Joonas Lahtinen
Quoting Daniel Vetter (2018-10-19 10:05:32)
> On Fri, Oct 19, 2018 at 8:59 AM Joonas Lahtinen
>  wrote:
> >
> > Quoting Daniel Vetter (2018-10-18 22:32:00)
> > > On Thu, Oct 18, 2018 at 6:57 PM Joonas Lahtinen
> > >  wrote:
> > > >
> > > > Hi Dave,
> > > >
> > > > Here comes the final set of fixes under -next-fixes umbrella.
> > > > Next one will be then from -fixes, assuming a release next Sun.
> > > >
> > > > Fixes for bunch of display related issues reported by users, then the
> > > > MST fixes that were dropped from Rodrigos PR + further Icelake fixes
> > > > and proactive improvements picked by tooling.
> > > >
> > > > Excuse for the slight accumulation as I skipped last week due to
> > > > travel like I warned.
> > > >
> > > > Regards, Joonas
> > > >
> > > > ***
> > > >
> > > > drm-intel-next-fixes-2018-10-18:
> > > > - Fix GPU hang on MacBook2,1 when booting in EFI mode (Bugzilla #105637)
> > > > - Fix garbled console on Y tiled BIOS framebuffer configs (Bugzilla 
> > > > #108264)
> > > > - Fix black screen on certain eDP panels eg. Dell XPS 9350 (Bugzilla 
> > > > #107489 and #105338)
> > > > - MST fixes that Rodrigo dropped from drm-intel-fixes and bunch of 
> > > > Icelake fixes
> > >
> > > This won't work because it doesn't contain Lyude's core fix (+ the 2
> > > fixups). You either need to cherry-pick all of them (and then probably
> > > include the nouveau one), or none of them. Did the cherry-pick script
> > > not propose them, or something else? They're all cc: stable.
> >
> > cherry-pick-next-fixes did not propose more. I did specifically ask
> > Rodrigo to drop the relevant stuff from drm-intel-fixes so that the
> > tooling would pick it up. What is there that is missing?
> 
> dim cherry-pick-branch is limited to drivers/gpu/drm/i915 :-(
> 
> Remove that (well at least only filter drm/) and you should see them.
> Ideally you put the core patch + 2 core fixups before the i915/nouveau
> patches.
> 
> I guess putting core patches that are bugfixes through drm-intel.git
> really isn't a good idea with our process ...

I've now done this now. Removal of the filter adding two patches, but I
had to track down the further Fixes: to Fixes: manually. Thanks to
Daniel for the assistance in pointing the missing patches.

As you already pulled this PR, the core fixes will end up after
the i915 fixes. If you end up wanting to rebase the order, note that
the Fixes: annotations will be wrecked. I'll send a further fixup PR.

I also amended the Fixes: tags to point to cherry-picked fixes, to
decrease the likelihood of falling through automated tooling (while
appending Cc: stable to one patch missing it).

So you want to avoid rebasing the patches in all circumstances (or
you have to update/remove the Fixes: lines beyond the line "(cherry
picked from ...".

Lovely thing to do on Friday :) Hopefully next week will be less
of a hassle.

Regards, Joonas

> -Daniel
> 
> >
> > Regards, Joonas
> >
> > > -Daniel
> > >
> > > > - Then assorted proactive code fixes caught by CI or developers
> > > >
> > > > The following changes since commit 
> > > > ca4b869240d5810ebac6b1570ad7beffcfbac2f5:
> > > >
> > > >   Merge branch 'drm-next-4.20' of 
> > > > git://people.freedesktop.org/~agd5f/linux into drm-next (2018-10-11 
> > > > 14:53:45 +1000)
> > > >
> > > > are available in the Git repository at:
> > > >
> > > >   git://anongit.freedesktop.org/drm/drm-intel 
> > > > tags/drm-intel-next-fixes-2018-10-18
> > > >
> > > > for you to fetch changes up to 835fe6d75d14c1513910ed7f5665127fee12acc8:
> > > >
> > > >   firmware/dmc/icl: Add missing MODULE_FIRMWARE() for Icelake. 
> > > > (2018-10-18 10:36:10 +0300)
> > > >
> > > > 
> > > > - Fix GPU hang on MacBook2,1 when booting in EFI mode (Bugzilla #105637)
> > > > - Fix garbled console on Y tiled BIOS framebuffer configs (Bugzilla 
> > > > #108264)
> > > > - Fix black screen on certain eDP panels eg. Dell XPS 9350 (Bugzilla 
> > > > #107489 and #105338)
> > > > - MST fixes that Rodrigo dropped from drm-intel-fixes and bunch of 
> > > > Icelake fixes
> > > > - Then assorted proactive code fixes caught by CI or developers
> > > >
> > > > 
> > > > Anusha Srivatsa (1):
> > > >   firmware/dmc/icl: Add missing MODULE_FIRMWARE() for Icelake.
> > > >
> > > > Chris Wilson (3):
> > > >   drm/i915: Only reset seqno if actually idle
> > > >   drm/i915/selftests: Disable shrinker across mmap-exhaustion
> > > >   drm/i915: Large page offsets for pread/pwrite
> > > >
> > > > Imre Deak (1):
> > > >   drm/i915/gen9+: Fix initial readout for Y tiled framebuffers
> > > >
> > > > Lyude Paul (3):
> > > >   drm/i915: Don't unset intel_connector->mst_port
> > > >   drm/i915: Skip vcpi allocation for MSTB ports that are gone
> > > >   drm/i915: Fix intel_dp_mst_best_encoder()
> > > >
> > > > Mahesh Kumar (2):
> > > >   drm/i915/icl: crea

Re: [PATCH 01/18] drm/ttm: Provide struct ttm_global for referencing TTM global state

2018-10-19 Thread Thomas Zimmermann
Hi

Am 19.10.18 um 11:30 schrieb Christian König:
> In general I'm really graceful that you look into this, but you are just
> moving the complexity around instead of cleaning it up.
> 
> This whole global reference stuff is just going into the wrong direction.
> 
> Please let me clean that up instead,

Well, Ok.

One thing I noticed is that none of the drivers does anything with the
global TTM state. One thing that could be done is to remove the state
from the drivers and handle it entirely in ttm_bo_device.

Best regards
Thomas

> Christian.
> 
> Am 19.10.18 um 10:54 schrieb Thomas Zimmermann:
>> The new struct ttm_global provides drivers with TTM's global memory and
>> BO in a unified way. Initialization and release is handled internally.
>>
>> The functionality provided by struct ttm_global is currently
>> re-implemented
>> by a dozen individual DRM drivers using struct drm_global. The
>> implementation
>> of struct ttm_global is also built on top of drm_global, so it can
>> co-exists
>> with the existing drivers. Once all TTM-based drivers have been
>> converted to
>> struct ttm_global, the implementation of struct drm_global can be made
>> private to TTM.
>>
>> Signed-off-by: Thomas Zimmermann 
>> ---
>>   drivers/gpu/drm/ttm/Makefile |  2 +-
>>   drivers/gpu/drm/ttm/ttm_global.c | 98 
>>   include/drm/drm_global.h |  8 +++
>>   include/drm/ttm/ttm_global.h | 79 +
>>   4 files changed, 186 insertions(+), 1 deletion(-)
>>   create mode 100644 drivers/gpu/drm/ttm/ttm_global.c
>>   create mode 100644 include/drm/ttm/ttm_global.h
>>
>> diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile
>> index 01fc670ce7a2..b7272b26e9f3 100644
>> --- a/drivers/gpu/drm/ttm/Makefile
>> +++ b/drivers/gpu/drm/ttm/Makefile
>> @@ -5,7 +5,7 @@
>>   ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
>>   ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
>>   ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o \
>> -    ttm_page_alloc_dma.o
>> +    ttm_page_alloc_dma.o ttm_global.o
>>   ttm-$(CONFIG_AGP) += ttm_agp_backend.o
>>     obj-$(CONFIG_DRM_TTM) += ttm.o
>> diff --git a/drivers/gpu/drm/ttm/ttm_global.c
>> b/drivers/gpu/drm/ttm/ttm_global.c
>> new file mode 100644
>> index ..ca9da0a46147
>> --- /dev/null
>> +++ b/drivers/gpu/drm/ttm/ttm_global.c
>> @@ -0,0 +1,98 @@
>> +/* SPDX-License-Identifier: GPL-2.0 OR MIT */
>> +/**
>>
>> + *
>> + * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
>> + * All Rights Reserved.
>> + *
>> + * Permission is hereby granted, free of charge, to any person
>> obtaining a
>> + * copy of this software and associated documentation files (the
>> + * "Software"), to deal in the Software without restriction, including
>> + * without limitation the rights to use, copy, modify, merge, publish,
>> + * distribute, sub license, and/or sell copies of the Software, and to
>> + * permit persons to whom the Software is furnished to do so, subject to
>> + * the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the
>> + * next paragraph) shall be included in all copies or substantial
>> portions
>> + * of the Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>> EXPRESS OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT
>> SHALL
>> + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
>> ANY CLAIM,
>> + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
>> + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
>> OR THE
>> + * USE OR OTHER DEALINGS IN THE SOFTWARE.
>> + *
>> +
>> **/
>>
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +static int ttm_global_init_mem(struct drm_global_reference *ref)
>> +{
>> +    BUG_ON(!ref->object);
>> +    return ttm_mem_global_init(ref->object);
>> +}
>> +
>> +static void ttm_global_release_mem(struct drm_global_reference *ref)
>> +{
>> +    BUG_ON(!ref->object);
>> +    ttm_mem_global_release(ref->object);
>> +}
>> +
>> +static int ttm_global_init_bo(struct drm_global_reference *ref)
>> +{
>> +    struct ttm_global *glob =
>> +    container_of(ref, struct ttm_global, bo_ref);
>> +    BUG_ON(!ref->object);
>> +    BUG_ON(!glob->mem_ref.object);
>> +    return ttm_bo_global_init(ref->object, glob->mem_ref.object);
>> +}
>> +
>> +static void ttm_global_release_bo(struct drm_global_reference *ref)
>> +{
>> +    BUG_ON(!ref->object);
>> +    ttm_bo_global_release(ref->object);
>> +}
>> +
>> +int ttm_global_init(struct ttm_global *glob)
>> +{
>> +    int ret;
>> +
>> +    glob->mem_ref.global_type = DRM_GLOBAL_TTM_MEM;
>> +    glob->mem_ref.size = sizeof(struct ttm_

Re: [PATCH 01/18] drm/ttm: Provide struct ttm_global for referencing TTM global state

2018-10-19 Thread Koenig, Christian
Am 19.10.18 um 11:41 schrieb Thomas Zimmermann:
> Hi
>
> Am 19.10.18 um 11:30 schrieb Christian König:
>> In general I'm really graceful that you look into this, but you are just
>> moving the complexity around instead of cleaning it up.
>>
>> This whole global reference stuff is just going into the wrong direction.
>>
>> Please let me clean that up instead,
> Well, Ok.
>
> One thing I noticed is that none of the drivers does anything with the
> global TTM state. One thing that could be done is to remove the state
> from the drivers and handle it entirely in ttm_bo_device.

Yeah, exactly that's the point and you can even go a step further.

All what's in those "global" states are actually static information.

I can't work on much else today because I locked myself out of the AMD 
VPN. So going to give that a try.

Thanks,
Christian.

>
> Best regards
> Thomas
>
>> Christian.
>>
>> Am 19.10.18 um 10:54 schrieb Thomas Zimmermann:
>>> The new struct ttm_global provides drivers with TTM's global memory and
>>> BO in a unified way. Initialization and release is handled internally.
>>>
>>> The functionality provided by struct ttm_global is currently
>>> re-implemented
>>> by a dozen individual DRM drivers using struct drm_global. The
>>> implementation
>>> of struct ttm_global is also built on top of drm_global, so it can
>>> co-exists
>>> with the existing drivers. Once all TTM-based drivers have been
>>> converted to
>>> struct ttm_global, the implementation of struct drm_global can be made
>>> private to TTM.
>>>
>>> Signed-off-by: Thomas Zimmermann 
>>> ---
>>>    drivers/gpu/drm/ttm/Makefile |  2 +-
>>>    drivers/gpu/drm/ttm/ttm_global.c | 98 
>>>    include/drm/drm_global.h |  8 +++
>>>    include/drm/ttm/ttm_global.h | 79 +
>>>    4 files changed, 186 insertions(+), 1 deletion(-)
>>>    create mode 100644 drivers/gpu/drm/ttm/ttm_global.c
>>>    create mode 100644 include/drm/ttm/ttm_global.h
>>>
>>> diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile
>>> index 01fc670ce7a2..b7272b26e9f3 100644
>>> --- a/drivers/gpu/drm/ttm/Makefile
>>> +++ b/drivers/gpu/drm/ttm/Makefile
>>> @@ -5,7 +5,7 @@
>>>    ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
>>>    ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
>>>    ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o \
>>> -    ttm_page_alloc_dma.o
>>> +    ttm_page_alloc_dma.o ttm_global.o
>>>    ttm-$(CONFIG_AGP) += ttm_agp_backend.o
>>>      obj-$(CONFIG_DRM_TTM) += ttm.o
>>> diff --git a/drivers/gpu/drm/ttm/ttm_global.c
>>> b/drivers/gpu/drm/ttm/ttm_global.c
>>> new file mode 100644
>>> index ..ca9da0a46147
>>> --- /dev/null
>>> +++ b/drivers/gpu/drm/ttm/ttm_global.c
>>> @@ -0,0 +1,98 @@
>>> +/* SPDX-License-Identifier: GPL-2.0 OR MIT */
>>> +/**
>>>
>>> + *
>>> + * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
>>> + * All Rights Reserved.
>>> + *
>>> + * Permission is hereby granted, free of charge, to any person
>>> obtaining a
>>> + * copy of this software and associated documentation files (the
>>> + * "Software"), to deal in the Software without restriction, including
>>> + * without limitation the rights to use, copy, modify, merge, publish,
>>> + * distribute, sub license, and/or sell copies of the Software, and to
>>> + * permit persons to whom the Software is furnished to do so, subject to
>>> + * the following conditions:
>>> + *
>>> + * The above copyright notice and this permission notice (including the
>>> + * next paragraph) shall be included in all copies or substantial
>>> portions
>>> + * of the Software.
>>> + *
>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>>> EXPRESS OR
>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>>> MERCHANTABILITY,
>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT
>>> SHALL
>>> + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
>>> ANY CLAIM,
>>> + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
>>> + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
>>> OR THE
>>> + * USE OR OTHER DEALINGS IN THE SOFTWARE.
>>> + *
>>> +
>>> **/
>>>
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +static int ttm_global_init_mem(struct drm_global_reference *ref)
>>> +{
>>> +    BUG_ON(!ref->object);
>>> +    return ttm_mem_global_init(ref->object);
>>> +}
>>> +
>>> +static void ttm_global_release_mem(struct drm_global_reference *ref)
>>> +{
>>> +    BUG_ON(!ref->object);
>>> +    ttm_mem_global_release(ref->object);
>>> +}
>>> +
>>> +static int ttm_global_init_bo(struct drm_global_reference *ref)
>>> +{
>>> +    struct ttm_global *glob =
>>> +    container_of(ref, struct ttm_global, bo_ref);
>>> +    BUG_ON(!ref->object);
>>> +    

Re: [PATCH 2/7] drm: add syncobj timeline support v8

2018-10-19 Thread zhoucm1



On 2018年10月19日 17:20, zhoucm1 wrote:



On 2018年10月19日 16:55, Daniel Vetter wrote:

On Fri, Oct 19, 2018 at 10:29:55AM +0800, zhoucm1 wrote:


On 2018年10月18日 19:50, Christian König wrote:

Am 18.10.18 um 05:11 schrieb zhoucm1:


On 2018年10月17日 18:24, Daniel Vetter wrote:

On Wed, Oct 17, 2018 at 11:29 AM Koenig, Christian
 wrote:

Am 17.10.18 um 11:17 schrieb zhoucm1:

[SNIP]

    +struct drm_syncobj_signal_pt {
+    struct dma_fence_array *base;
Out of curiosity, why the pointer and not embedding? base is 
kinda

misleading for a pointer.

Yeah, Christian doesn't like signal_pt lifecycle same as fence, so
it's a pointer.
If you don't like 'base' name, I can change it.

Well I never said that you can't embed the fence array into
the signal_pt.

You just need to make sure that we don't affect the drm_syncobj
lilecycle as well, e.g. that we don't also need to keep that 
around.

I don't see a problem with that, as long as drm_syncobj keeps a
reference to the fence while it's on the timeline list. Which it
already does. And embedding would avoid that 2nd separate 
allocation,

aside from making base less confusing.

That's indeed my initial implementation for signal_pt/wait_pt with
fence based, but after long and many discussions, we get current
solution, as you see, the version is up to v8 :).

For here  why the pointer and not embedding?
Two reasons:
1. their lifecycles are not same.
2. It is a fence array usage, which always needs separate
allocation, seems which is mandatory.
So it is a pointer.

But the name is historical from initial, and indeed be kinda
misleading for a pointer, I will change it to fence_array instead in
coming v9.

To avoid running into a v10 I've just pushed this version upstream :)

Thanks a lot.

(This time reply to the right patch, silly me)

Went boom:

https://bugs.freedesktop.org/show_bug.cgi?id=108490

Can we revert pls?

Sorry for bug, please.
In fact, the bug is already caught and fixed, just the fix part isn't in 
patch#1, but in patch#2:


Have you reverted? If not, I can send that fix in one minute.


Regards,
David Zhou


Also, can we please have igts for this stuff so that intel-gfx-ci could
test this properly before it's all fireworks?
Seems we cannot avoid igt now and vulkan CTS isn't enough, I will find 
some time next week to lean IGT, looks v10 is need.


Regards,
David Zhou


Thanks, Daniel


The rest in the series looks good to me as well,

Can I get your RB on them first?


but I certainly want the radv/anv developers to take a look as well as
Daniel suggested.
Ping @Dave/Bas/Jason or other radv/anv developers, Could anyone of 
you take
a look the rest of series for u/k interface? So that we can move to 
next

step for libdrm patches?

Thanks,
David

Christian.


Thanks,
David Zhou


-Daniel

___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


___
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 v2] drm/sun4i: Fix an ulong overflow in the dotclock driver

2018-10-19 Thread Maxime Ripard
On Thu, Oct 18, 2018 at 12:02:50PM +0200, Boris Brezillon wrote:
> The calculated ideal rate can easily overflow an unsigned long, thus
> making the best div selection buggy as soon as no ideal match is found
> before the overflow occurs.
> 
> Fixes: 4731a72df273 ("drm/sun4i: request exact rates to our parents")
> Cc: 
> Signed-off-by: Boris Brezillon 
> Acked-by: Maxime Ripard 
> ---
> Changes in v2:
> - Add a comment to explain why we bail out after an overflow
> - Add Maxime ack
> - Use a goto instead of a break

APplied, thanks!
Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 108493] Unigine Heaven at 4K crashes amdgpu and causes a GPU hang

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108493

Bug ID: 108493
   Summary: Unigine Heaven at 4K crashes amdgpu and causes a GPU
hang
   Product: DRI
   Version: unspecified
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: DRM/AMDgpu
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: ven...@msn.com

I experience a consistent amdgpu crash when using my AMD GPU with a 4K screen.

Hardware:
* Sapphire Radeon RX 570 Pulse ITX 4GB
* Zotac AMP box mini external GPU enclosure
* Dell XPS 13 9370 laptop
* Dell U2718Q 4K display

Software:
First tried with Fedora 28. Now using Fedora 29. Tried kernel versions 4.18.12,
4.18.13 and 4.19-rc7, the issue appears with all of these. Mesa version is
18.2.2, but the crash is also there with 18.0 (on Fedora 28).

Steps to reproduce the crash:
1. Turn off the laptop
2. Attach the eGPU to the laptop
3. Attach a 4K screen to the HDMI output of the AMD GPU
4. Turn on the laptop
5. Add the following to the kernel command line: 'module_blacklist=i915 3' (to
ensure the Intel GPU is not used at all, plus the graphical login won't
interfere)
6. Launch the operating system
7. Log in from the console
8. Launch an X session with 'startx'
9. Start the Unigine Heaven benchmark in fullscreen 4K

Expected outcome:
Unigine Heaven should show up and run in a stable and performant manner.

Actual outcome:
Unigine Heaven shows up, runs for a couple of seconds and then the screen goes
dark. I can still log into the machine with SSH, but can not kill X or interact
with the AMD GPU in any way. Can't even reboot the machine, the only thing that
works is long pressing the power key.

Relevant lines from dmesg log:
[  305.078426] [drm:amdgpu_job_timedout [amdgpu]] *ERROR* ring gfx timeout,
signaled seq=147930, emitted seq=147933
[  305.078567] [drm:amdgpu_job_timedout [amdgpu]] *ERROR* ring sdma0 timeout,
signaled seq=3176, emitted seq=3178
[  305.078573] [drm] GPU recovery disabled.

Possible workaround:
* The crash does not happen when I disable power management with amdgpu.dpm=0,
however then it has very poor performance.
* The crash also doesn't happen when I use 'echo low >
/sys/class/drm/card0/device/power_dpm_force_performance_level' with the same
note about bad performance.

Additional information:
* Note that running any other graphics intensive application (ie. your
favourite game) will also result in the same crash, but Unigine Heaven is what
I found to be the quickest way to reproduce it.
* Also note that the crash is not X-specific but again this is what I found to
be the simplest way to reproduce it.
* The very same hardware works correctly on Windows without a crash. So this is
probably not a hardware defect.
* The crash is almost immediate on 4K, but it also occours with other
resolutions, just takes more time. At 1440p it takes a couple of minutes but
still crashes. At 1080p I could run it for several minutes without a crash (did
not test further than that).
* The problem seems to be similar to these:
https://bugs.freedesktop.org/show_bug.cgi?id=105733 and
https://bugs.freedesktop.org/show_bug.cgi?id=102322 - the difference is that
the suggested workarounds don't help, just seem to postpone the crash by a very
small margin. It still crashes in less than a minute though.
* Enabling GPU recovery does not actually manage to recover the GPU.

If you need any other kind of log or any more info, please let me know. Thank
you in advance for looking into solving this problem.

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


[PATCH] drm: fix deadlock of syncobj

2018-10-19 Thread Chunming Zhou
Signed-off-by: Chunming Zhou 
Cc: Daniel Vetter 
Cc: Chris Wilson 
Cc: Christian König 
---
 drivers/gpu/drm/drm_syncobj.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 57bf6006394d..2f3c14cb5156 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -344,13 +344,16 @@ void drm_syncobj_replace_fence(struct drm_syncobj 
*syncobj,
drm_syncobj_create_signal_pt(syncobj, fence, pt_value);
if (fence) {
struct drm_syncobj_cb *cur, *tmp;
+   struct list_head cb_list;
 
+   INIT_LIST_HEAD(&cb_list);
spin_lock(&syncobj->lock);
-   list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) {
+   list_splice_init(&syncobj->cb_list, &cb_list);
+   spin_unlock(&syncobj->lock);
+   list_for_each_entry_safe(cur, tmp, &cb_list, node) {
list_del_init(&cur->node);
cur->func(syncobj, cur);
}
-   spin_unlock(&syncobj->lock);
}
 }
 EXPORT_SYMBOL(drm_syncobj_replace_fence);
-- 
2.17.1

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


[PULL] drm-intel-next-fixes

2018-10-19 Thread Joonas Lahtinen
Hi Dave,

Here are the promised MST fixes that were missing due to being
in i915 tree, yet outside i915 directory.

Further explanation in the previous PR's thread.

Regards, Joonas

***

drm-intel-next-fixes-2018-10-19:
- The missing 4 MST patches that tooling didn't pick from drm core/nouveau
The following changes since commit f2bfc71aee75feff33ca659322b72ffeed5a243d:

  Merge tag 'drm-intel-next-fixes-2018-10-18' of 
git://anongit.freedesktop.org/drm/drm-intel into drm-next (2018-10-19 14:28:11 
+1000)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-intel 
tags/drm-intel-next-fixes-2018-10-19

for you to fetch changes up to 7b0f61e91b6056c71649efa3204112a4b6cf5fc8:

  drm/nouveau: Fix nv50_mstc->best_encoder() (2018-10-19 11:46:46 +0300)


- The missing 4 MST patches that tooling didn't pick from drm core/nouveau


Lyude Paul (4):
  drm/atomic_helper: Disallow new modesets on unregistered connectors
  drm/atomic_helper: Allow DPMS On<->Off changes for unregistered connectors
  drm/atomic_helper: Stop modesets on unregistered connectors harder
  drm/nouveau: Fix nv50_mstc->best_encoder()

 drivers/gpu/drm/drm_atomic_helper.c | 21 +-
 drivers/gpu/drm/drm_connector.c | 11 ++---
 drivers/gpu/drm/i915/intel_dp_mst.c |  8 ++--
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 14 ++-
 include/drm/drm_connector.h | 71 -
 5 files changed, 103 insertions(+), 22 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/7] drm: add syncobj timeline support v8

2018-10-19 Thread zhoucm1


[snip]

Went boom:

https://bugs.freedesktop.org/show_bug.cgi?id=108490

Can we revert pls?

Sorry for bug, please.
In fact, the bug is already caught and fixed, just the fix part isn't 
in patch#1, but in patch#2:


Have you reverted? If not, I can send that fix in one minute.


Regards,
David Zhou


Also, can we please have igts for this stuff so that intel-gfx-ci could
test this properly before it's all fireworks?

Hi Daniel V,

Could you point me which problem I encounter when I run syncobj_wait of igt?

jenkins@jenkins-MS-7984:~/freedesktop/igt-gpu-tools/tests$ ./syncobj_wait
IGT-Version: 1.23-g94ebd21 (x86_64) (Linux: 4.19.0-rc5-custom+ x86_64)
Test requirement not met in function igt_require_sw_sync, file 
sw_sync.c:240:

Test requirement: kernel_has_sw_sync()
Last errno: 2, No such file or directory

Thanks,
David Zhou
Seems we cannot avoid igt now and vulkan CTS isn't enough, I will 
find some time next week to lean IGT, looks v10 is need.


Regards,
David Zhou


Thanks, Daniel


The rest in the series looks good to me as well,

Can I get your RB on them first?

but I certainly want the radv/anv developers to take a look as 
well as

Daniel suggested.
Ping @Dave/Bas/Jason or other radv/anv developers, Could anyone of 
you take
a look the rest of series for u/k interface? So that we can move to 
next

step for libdrm patches?

Thanks,
David

Christian.


Thanks,
David Zhou


-Daniel

___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


___
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] drm: fix deadlock of syncobj

2018-10-19 Thread Chris Wilson
Quoting Chunming Zhou (2018-10-19 11:26:41)
> Signed-off-by: Chunming Zhou 
> Cc: Daniel Vetter 
> Cc: Chris Wilson 
> Cc: Christian König 
> ---
>  drivers/gpu/drm/drm_syncobj.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 57bf6006394d..2f3c14cb5156 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -344,13 +344,16 @@ void drm_syncobj_replace_fence(struct drm_syncobj 
> *syncobj,
> drm_syncobj_create_signal_pt(syncobj, fence, pt_value);
> if (fence) {
> struct drm_syncobj_cb *cur, *tmp;
> +   struct list_head cb_list;
> +   INIT_LIST_HEAD(&cb_list);
LIST_HEAD(cb_list); // does both in one

> spin_lock(&syncobj->lock);
> -   list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) {
> +   list_splice_init(&syncobj->cb_list, &cb_list);

Steal the snapshot of the list under the lock, ok.

> +   spin_unlock(&syncobj->lock);
> +   list_for_each_entry_safe(cur, tmp, &cb_list, node) {
> list_del_init(&cur->node);

Races against external caller of drm_syncobj_remove_callback(). However,
it looks like that race is just fine, but we don't guard against the
struct drm_syncobj_cb itself being freed, leading to all sort of fun for
an interrupted drm_syncobj_array_wait_timeout.

That kfree seems to undermine the validity of stealing the list.
-Chris
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PULL] drm-misc-fixes

2018-10-19 Thread Maarten Lankhorst
Hey Dave,

The GPF issue was serious enough to send a second pull request for 
drm-misc-fixes. :)

Cheers,
~Maarten

drm-misc-fixes-2018-10-19:
Second pull request for v4.19:
- Fix ulong overflow in sun4i
- Fix a serious GPF in waiting for flip_done from commit_tail().

The following changes since commit 9068e02f58740778d8270840657f1e250a2cc60f:

  drm/edid: VSDB yCBCr420 Deep Color mode bit definitions (2018-10-16 16:38:16 
+0300)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2018-10-19

for you to fetch changes up to e84cb605e02f1b3d0aee8d7157419cd8aaa06038:

  drm/sun4i: Fix an ulong overflow in the dotclock driver (2018-10-19 11:50:25 
+0200)


Second pull request for v4.19:
- Fix ulong overflow in sun4i
- Fix a serious GPF in waiting for flip_done from commit_tail().


Boris Brezillon (1):
  drm/sun4i: Fix an ulong overflow in the dotclock driver

Leo Li (1):
  drm: Get ref on CRTC commit object when waiting for flip_done

 drivers/gpu/drm/drm_atomic.c   |  5 +
 drivers/gpu/drm/drm_atomic_helper.c| 12 
 drivers/gpu/drm/sun4i/sun4i_dotclock.c | 12 +++-
 include/drm/drm_atomic.h   | 11 +++
 4 files changed, 35 insertions(+), 5 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v5 2/9] drm/fourcc: Add char_per_block, block_w and block_h in drm_format_info

2018-10-19 Thread Alexandru Gheorghe
For some pixel formats .cpp structure in drm_format info it's not
enough to describe the peculiarities of the pixel layout, for example
tiled formats or packed formats at bit level.

What's implemented here is to add three new members to drm_format_info
that could describe such formats:

- char_per_block[3]
- block_w[3]
- block_h[3]

char_per_block will be put in a union alongside cpp, for transparent
compatibility  with the existing format descriptions.

Regarding, block_w and block_h they are intended to be used through
their equivalent getters drm_format_info_block_width /
drm_format_info_block_height, the reason of the getters is to abstract
the fact that for normal formats block_w and block_h will be unset/0,
but the methods will be returning 1.

Additionally, convenience function drm_format_info_min_pitch had been
added that computes the minimum required pitch for a given pixel
format and buffer width.

Using that the following drm core functions had been updated to
generically handle both block and non-block formats:

- drm_fb_cma_get_gem_addr: for block formats it will just return the
  beginning of the block.
- framebuffer_check: Use the newly added drm_format_info_min_pitch.
- drm_gem_fb_create_with_funcs: Use the newly added
  drm_format_info_min_pitch.
- In places where is not expecting to handle block formats, like fbdev
  helpers I just added some warnings in case the block width/height
  are greater than 1.

Changes since v3:
 - Add helper function for computing the minimum required pitch.
 - Improve/cleanup documentation

Signed-off-by: Alexandru Gheorghe 
---
 drivers/gpu/drm/drm_fb_cma_helper.c  | 21 ++-
 drivers/gpu/drm/drm_fb_helper.c  |  6 ++
 drivers/gpu/drm/drm_fourcc.c | 62 
 drivers/gpu/drm/drm_framebuffer.c|  6 +-
 drivers/gpu/drm/drm_gem_framebuffer_helper.c |  2 +-
 include/drm/drm_fourcc.h | 61 ++-
 6 files changed, 149 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index d52344a03aa8..83941a8ca0e0 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -72,7 +72,9 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct 
drm_framebuffer *fb,
 EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj);
 
 /**
- * drm_fb_cma_get_gem_addr() - Get physical address for framebuffer
+ * drm_fb_cma_get_gem_addr() - Get physical address for framebuffer, for pixel
+ * formats where values are grouped in blocks this will get you the beginning 
of
+ * the block
  * @fb: The framebuffer
  * @state: Which state of drm plane
  * @plane: Which plane
@@ -87,6 +89,14 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer 
*fb,
struct drm_gem_cma_object *obj;
dma_addr_t paddr;
u8 h_div = 1, v_div = 1;
+   u32 block_w = drm_format_info_block_width(fb->format, plane);
+   u32 block_h = drm_format_info_block_height(fb->format, plane);
+   u32 block_size = fb->format->char_per_block[plane];
+   u32 sample_x;
+   u32 sample_y;
+   u32 block_start_y;
+   u32 num_hblocks;
+
 
obj = drm_fb_cma_get_gem_obj(fb, plane);
if (!obj)
@@ -99,8 +109,13 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer 
*fb,
v_div = fb->format->vsub;
}
 
-   paddr += (fb->format->cpp[plane] * (state->src_x >> 16)) / h_div;
-   paddr += (fb->pitches[plane] * (state->src_y >> 16)) / v_div;
+   sample_x = (state->src_x >> 16) / h_div;
+   sample_y = (state->src_y >> 16) / v_div;
+   block_start_y = (sample_y / block_h) * block_h;
+   num_hblocks = sample_x / block_w;
+
+   paddr += fb->pitches[plane] * block_start_y;
+   paddr += block_size * num_hblocks;
 
return paddr;
 }
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a504a5e05676..9add0d7da744 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1595,6 +1595,10 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo 
*var,
if (var->pixclock != 0 || in_dbg_master())
return -EINVAL;
 
+   if ((drm_format_info_block_width(fb->format, 0) > 1) ||
+   (drm_format_info_block_height(fb->format, 0) > 1))
+   return -EINVAL;
+
/*
 * Changes struct fb_var_screeninfo are currently not pushed back
 * to KMS, hence fail if different settings are requested.
@@ -1969,6 +1973,8 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct 
drm_fb_helper *fb_helpe
 {
struct drm_framebuffer *fb = fb_helper->fb;
 
+   WARN_ON((drm_format_info_block_width(fb->format, 0) > 1) ||
+   (drm_format_info_block_height(fb->format, 0) > 1));
info->pseudo_palette = fb_helper->pseudo_palette;
info->var.xres_virtual = fb->width;
info->var.yres_virtual = fb->height;
diff --git a/d

[PATCH v5 1/9] drm: fourcc: Convert drm_format_info kerneldoc to in-line member documentation

2018-10-19 Thread Alexandru Gheorghe
In-line member documentation seems to be desired way of documenting
structure members.

This change had been suggested by Daniel Vetter here:
https://lists.freedesktop.org/archives/dri-devel/2018-October/192176.html

Signed-off-by: Alexandru Gheorghe 
---
 include/drm/drm_fourcc.h | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
index 865ef60c17af..345f11227e9e 100644
--- a/include/drm/drm_fourcc.h
+++ b/include/drm/drm_fourcc.h
@@ -52,25 +52,35 @@ struct drm_mode_fb_cmd2;
 
 /**
  * struct drm_format_info - information about a DRM format
- * @format: 4CC format identifier (DRM_FORMAT_*)
- * @depth: Color depth (number of bits per pixel excluding padding bits),
- * valid for a subset of RGB formats only. This is a legacy field, do not
- * use in new code and set to 0 for new formats.
- * @num_planes: Number of color planes (1 to 3)
- * @cpp: Number of bytes per pixel (per plane)
- * @hsub: Horizontal chroma subsampling factor
- * @vsub: Vertical chroma subsampling factor
- * @has_alpha: Does the format embeds an alpha component?
- * @is_yuv: Is it a YUV format?
  */
 struct drm_format_info {
+   /** @format: 4CC format identifier (DRM_FORMAT_*) */
u32 format;
+
+   /**
+* @depth:
+*
+* Color depth (number of bits per pixel excluding padding bits),
+* valid for a subset of RGB formats only. This is a legacy field, do
+* not use in new code and set to 0 for new formats.
+*/
u8 depth;
+
+   /** @num_planes: Number of color planes (1 to 3) */
u8 num_planes;
+
+   /** @cpp: Number of bytes per pixel (per plane) */
u8 cpp[3];
+
+   /** @hsub: Horizontal chroma subsampling factor */
u8 hsub;
+   /** @vsub: Vertical chroma subsampling factor */
u8 vsub;
+
+   /** @has_alpha: Does the format embeds an alpha component? */
bool has_alpha;
+
+   /** @is_yuv: Is it a YUV format? */
bool is_yuv;
 };
 
-- 
2.18.0

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


[PATCH v5 6/9] drm/fourcc: Add AFBC yuv fourccs for Mali

2018-10-19 Thread Alexandru Gheorghe
From: Brian Starkey 

As we look to enable AFBC using DRM format modifiers, we run into
problems which we've historically handled via vendor-private details
(i.e. gralloc, on Android).

AFBC (as an encoding) is fully flexible, and for example YUV data can
be encoded into 1, 2 or 3 encoded "planes", much like the linear
equivalents. Component order is also meaningful, as AFBC doesn't
necessarily care about what each "channel" of the data it encodes
contains. Therefore ABGR and RGBA can be encoded in AFBC with
different representations. Similarly, 'X' components may be encoded
into AFBC streams in cases where a decoder expects to decode a 4th
component.

In addition, AFBC is a licensable IP, meaning that to support the
ecosystem we need to ensure that _all_ AFBC users are able to describe
the encodings that they need. This is much better achieved by
preserving meaning in the fourcc codes when they are combined with an
AFBC modifier.

In essence, we want to use the modifier to describe the parameters of
the AFBC encode/decode, and use the fourcc code to describe the data
being encoded/decoded.

To do anything different would be to introduce redundancy - we would
need to duplicate in the modifier information which is _already_
conveyed clearly and non-ambigiously by a fourcc code.

I hope that for RGB this is non-controversial.
(BGRA + MODIFIER_AFBC) is a different format from
(RGBA + MODIFIER_AFBC).

Possibly more controversial is that (XBGR + MODIFIER_AFBC)
is different from (BGR888 + MODIFIER_AFBC). I understand that in some
schemes it is not the case - but in AFBC it is so.

Where we run into problems is where there are not already fourcc codes
which represent the data which the AFBC encoder/decoder is processing.
To that end, we want to introduce new fourcc codes to describe the
data being encoded/decoded, in the places where none of the existing
fourcc codes are applicable.

Where we don't support an equivalent non-compressed layout, or where
no "obvious" linear layout exists, we are proposing adding fourcc
codes which have no associated linear layout - because any layout we
proposed would be completely arbitrary.

Some formats are following the naming conventions from [2].

The summary of the new formats is:
 DRM_FORMAT_VUY888 - Packed 8-bit YUV 444. Y followed by U then V.
 DRM_FORMAT_VUY101010 - Packed 10-bit YUV 444. Y followed by U then
V. No defined linear encoding.
 DRM_FORMAT_Y210 - Packed 10-bit YUV 422. Y followed by U (then Y)
   then V. 10-bit samples in 16-bit words.
 DRM_FORMAT_Y410 - Packed 10-bit YUV 444, with 2-bit alpha.
 DRM_FORMAT_P210 - Semi-planar 10-bit YUV 422. Y plane, followed by
   interleaved U-then-V plane. 10-bit samples in
   16-bit words.
 DRM_FORMAT_YUV420_8BIT - Packed 8-bit YUV 420. Y followed by U then
  V. No defined linear encoding
 DRM_FORMAT_YUV420_10BIT - Packed 10-bit YUV 420. Y followed by U
   then V. No defined linear encoding

Please also note that in the absence of AFBC, we would still need to
add Y410, Y210 and P210.

Full rationale follows:

YUV 444 8-bit, 1-plane
--
 The currently defined AYUV format encodes a 4th alpha component,
 which makes it unsuitable for representing a 3-component YUV 444
 AFBC stream.

 The proposed[1] XYUV format which is supported by Mali-DP in linear
 layout is also unsuitable, because the component order is the
 opposite of the AFBC version, and it encodes a 4th 'X' component.

 DRM_FORMAT_VUY888 is the "obvious" format for a 3-component, packed,
 YUV 444 8-bit format, with the component order which our HW expects to
 encode/decode. It conforms to the same naming convention as the
 existing packed YUV 444 format.
 The naming here is meant to be consistent with DRM_FORMAT_AYUV and
 DRM_FORMAT_XYUV[1]

YUV 444 10-bit, 1-plane
---
 There is no currently-defined YUV 444 10-bit format in
 drm_fourcc.h, irrespective of number of planes.

 The proposed[1] XVYU2101010 format which is supported by Mali-DP in
 linear layout uses the wrong component order, and also encodes a 4th
 'X' component, which doesn't match the AFBC version of YUV 444
 10-bit which we support.

 DRM_FORMAT_Y410 is the same layout as XVYU2101010, but with 2 bits of
 alpha.  This format is supported with linear layout by Mali GPUs. The
 naming follows[2].

 There is no "obvious" linear encoding for a 3-component 10:10:10
 packed format, and so DRM_FORMAT_VUY101010 defines a component
 order, but not a bit encoding. Again, the naming is meant to be
 consistent with DRM_FORMAT_AYUV.

YUV 422 8-bit, 1-plane
--
 The existing DRM_FORMAT_YUYV (and the other component orders) are
 single-planar YUV 422 8-bit formats. Following the convention of
 the component orders of the RGB formats, YUYV has the correct
 component order for our AFBC encoding (Y followed by U followed by
 V)

[PATCH v5 8/9] drm/selftest: Refactor test-drm_plane_helper

2018-10-19 Thread Alexandru Gheorghe
The idea is to split test implementations in different compilation
units, but have one single place where we define the list of tests,
in this case(drm_modeset_selftests.h).

Signed-off-by: Alexandru Gheorghe 
---
 ...er_selftests.h => drm_modeset_selftests.h} |  0
 .../drm/selftests/test-drm_modeset_common.c   | 11 ++-
 .../drm/selftests/test-drm_modeset_common.h   |  2 +-
 .../gpu/drm/selftests/test-drm_plane_helper.c | 19 +--
 4 files changed, 12 insertions(+), 20 deletions(-)
 rename drivers/gpu/drm/selftests/{drm_plane_helper_selftests.h => 
drm_modeset_selftests.h} (100%)

diff --git a/drivers/gpu/drm/selftests/drm_plane_helper_selftests.h 
b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
similarity index 100%
rename from drivers/gpu/drm/selftests/drm_plane_helper_selftests.h
rename to drivers/gpu/drm/selftests/drm_modeset_selftests.h
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.c 
b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
index fad5209043f1..2a7f93774006 100644
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.c
+++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
@@ -7,9 +7,18 @@
 
 #include "test-drm_modeset_common.h"
 
+#define TESTS "drm_modeset_selftests.h"
+#include "drm_selftest.h"
+
+#include "drm_selftest.c"
+
 static int __init test_drm_modeset_init(void)
 {
-   return test_drm_plane_helper();
+   int err;
+
+   err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
+
+   return err > 0 ? 0 : err;
 }
 
 static void __exit test_drm_modeset_exit(void)
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h 
b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
index bdeba264661f..b0065a2eb067 100644
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
+++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
@@ -13,6 +13,6 @@
 
 #define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
 
-int test_drm_plane_helper(void);
+int igt_check_plane_state(void *ignored);
 
 #endif
diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c 
b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
index 0dad2f812a27..0a9553f51796 100644
--- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c
+++ b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
@@ -11,9 +11,6 @@
 
 #include "test-drm_modeset_common.h"
 
-#define TESTS "drm_plane_helper_selftests.h"
-#include "drm_selftest.h"
-
 static void set_src(struct drm_plane_state *plane_state,
unsigned src_x, unsigned src_y,
unsigned src_w, unsigned src_h)
@@ -76,7 +73,7 @@ static bool check_crtc_eq(struct drm_plane_state *plane_state,
return true;
 }
 
-static int igt_check_plane_state(void *ignored)
+int igt_check_plane_state(void *ignored)
 {
int ret;
 
@@ -220,17 +217,3 @@ static int igt_check_plane_state(void *ignored)
 
return 0;
 }
-
-#include "drm_selftest.c"
-
-/**
- * test_drm_plane_helper - Run drm plane helper selftests.
- */
-int test_drm_plane_helper(void)
-{
-   int err;
-
-   err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
-
-   return err > 0 ? 0 : err;
-}
-- 
2.18.0

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


[PATCH v5 0/9] Add method to describe tile/bit_level_packed formats

2018-10-19 Thread Alexandru Gheorghe
Changes since v4:
  - Rebased selftests on latest drm-misc-next

Changes since v3:
  - added an utility function that computes the minimum pitch.
  - switched drm_format_info to in-line member documentation.
  - Cleanup/Improved the kernel doc.
  - Added selftests for: drm_format_info* helpers.

There has been some discussion about extending drm core to handle
linear tile formats, in the series sent by me here [1] and how to
handle formats that are intended to be used just with
modifiers(particularly AFBC modifiers) on Brian series [2] and on IRC
here [3] and [4].

Hence, this big-merged series:

Patch 1: Just a preparation patch that converts the drm_format_info
kerneldoc to in-line documentation.

Patches 2-4: handle tiled formats both in core and in malidp driver,
this is done by extending drm_format_info with three new fields
char_per_block, block_w, block_h and consistently handle in the generic
code paths, both linear tiled formats and normal formats.
What's different from [1] is the interpretation of pitch for tile
formats which has been kept to be the same as for the other formats:
pitch = average_chars_per_pixel * width.

Patches 5-7: Introduce the YUV AFBC formats, the only thing noteworthy
here is that cpp/char_per_block are set to 0 for formats where it's
mandatory to be used together with a non-linear modifier and then that
is used to bypass pitch check in framebuffer_check for formats that
have cpp/char_per_block set to 0.

Patches 8-9: A small fix for test-drm-helper module and adds self
tests for drm_format_info* helpers. For the other touched functions we
need a bit more infrastructure to be able to unittest/selftest them,
since they need a stub drm_device and drm_file.

As a side note, igt master branch doesn't seem to be using
test-drm-helper.ko, so I just tested by loading/unloading the module
manually.


[1] https://lists.freedesktop.org/archives/dri-devel/2018-September/188245.html
[2] https://lists.freedesktop.org/archives/dri-devel/2018-September/189620.html
[3] 
https://people.freedesktop.org/~cbrill/dri-log/?channel=dri-devel&highlight_names=&date=2018-09-13&show_html=true
[4] 
https://people.freedesktop.org/~cbrill/dri-log/?channel=dri-devel&highlight_names=&date=2018-09-14&show_html=true


Alexandru Gheorghe (7):
  drm: fourcc: Convert drm_format_info kerneldoc to in-line member
documentation
  drm/fourcc: Add char_per_block, block_w and block_h in drm_format_info
  drm/fourcc: Add fourcc for Mali linear tiled formats
  drm: mali-dp: Enable Mali-DP tiled buffer formats
  drm: Extend framebuffer_check to handle formats with
cpp/char_per_block 0
  drm/selftest: Refactor test-drm_plane_helper
  drm/selftests: Add tests for drm_format_info* helpers

Brian Starkey (2):
  drm/fourcc: Add AFBC yuv fourccs for Mali
  drm/afbc: Add AFBC modifier usage documentation

 Documentation/gpu/afbc.rst| 233 ++
 Documentation/gpu/drivers.rst |   1 +
 MAINTAINERS   |   1 +
 drivers/gpu/drm/arm/malidp_hw.c   |  14 +-
 drivers/gpu/drm/arm/malidp_planes.c   |  23 +-
 drivers/gpu/drm/drm_fb_cma_helper.c   |  21 +-
 drivers/gpu/drm/drm_fb_helper.c   |   6 +
 drivers/gpu/drm/drm_fourcc.c  |  87 ++
 drivers/gpu/drm/drm_framebuffer.c |  11 +-
 drivers/gpu/drm/drm_gem_framebuffer_helper.c  |   2 +-
 drivers/gpu/drm/selftests/Makefile|   3 +-
 ...er_selftests.h => drm_modeset_selftests.h} |   3 +
 drivers/gpu/drm/selftests/test-drm_format.c   | 290 ++
 .../drm/selftests/test-drm_modeset_common.c   |  11 +-
 .../drm/selftests/test-drm_modeset_common.h   |   5 +-
 .../gpu/drm/selftests/test-drm_plane_helper.c |  19 +-
 include/drm/drm_fourcc.h  |  89 +-
 include/uapi/drm/drm_fourcc.h |  31 ++
 18 files changed, 806 insertions(+), 44 deletions(-)
 create mode 100644 Documentation/gpu/afbc.rst
 rename drivers/gpu/drm/selftests/{drm_plane_helper_selftests.h => 
drm_modeset_selftests.h} (61%)
 create mode 100644 drivers/gpu/drm/selftests/test-drm_format.c

-- 
2.18.0

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


[PATCH v5 4/9] drm: mali-dp: Enable Mali-DP tiled buffer formats

2018-10-19 Thread Alexandru Gheorghe
Enable the following formats
- DRM_FORMAT_X0L0: DP650
- DRM_FORMAT_X0L2: DP550, DP650

Signed-off-by: Alexandru Gheorghe 
---
 drivers/gpu/drm/arm/malidp_hw.c | 14 +++---
 drivers/gpu/drm/arm/malidp_planes.c | 23 +--
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
index c94a4422e0e9..e01fc0e5b503 100644
--- a/drivers/gpu/drm/arm/malidp_hw.c
+++ b/drivers/gpu/drm/arm/malidp_hw.c
@@ -77,12 +77,18 @@ static const struct malidp_format_id malidp500_de_formats[] 
= {
{ DRM_FORMAT_YUYV, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 2) },\
{ DRM_FORMAT_UYVY, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 3) },\
{ DRM_FORMAT_NV12, DE_VIDEO1 | DE_VIDEO2 | SE_MEMWRITE, MALIDP_ID(5, 6) 
},  \
-   { DRM_FORMAT_YUV420, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 7) }
+   { DRM_FORMAT_YUV420, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 7) }, \
+   { DRM_FORMAT_X0L2, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(6, 6)}
 
 static const struct malidp_format_id malidp550_de_formats[] = {
MALIDP_COMMON_FORMATS,
 };
 
+static const struct malidp_format_id malidp650_de_formats[] = {
+   MALIDP_COMMON_FORMATS,
+   { DRM_FORMAT_X0L0, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 4)},
+};
+
 static const struct malidp_layer malidp500_layers[] = {
{ DE_VIDEO1, MALIDP500_DE_LV_BASE, MALIDP500_DE_LV_PTR_BASE, 
MALIDP_DE_LV_STRIDE0, MALIDP500_LV_YUV2RGB },
{ DE_GRAPHICS1, MALIDP500_DE_LG1_BASE, MALIDP500_DE_LG1_PTR_BASE, 
MALIDP_DE_LG_STRIDE, 0 },
@@ -595,6 +601,8 @@ static int malidp550_rotmem_required(struct 
malidp_hw_device *hwdev, u16 w, u16
case DRM_FORMAT_BGR565:
case DRM_FORMAT_UYVY:
case DRM_FORMAT_YUYV:
+   case DRM_FORMAT_X0L0:
+   case DRM_FORMAT_X0L2:
bytes_per_col = 32;
break;
/* 16 lines at 1.5 bytes per pixel */
@@ -860,8 +868,8 @@ const struct malidp_hw malidp_device[MALIDP_MAX_DEVICES] = {
MALIDP550_DC_IRQ_SE,
.vsync_irq = MALIDP550_DC_IRQ_CONF_VALID,
},
-   .pixel_formats = malidp550_de_formats,
-   .n_pixel_formats = ARRAY_SIZE(malidp550_de_formats),
+   .pixel_formats = malidp650_de_formats,
+   .n_pixel_formats = ARRAY_SIZE(malidp650_de_formats),
.bus_align_bytes = 16,
},
.query_hw = malidp650_query_hw,
diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
b/drivers/gpu/drm/arm/malidp_planes.c
index 49c37f6dd63e..33bbc29da774 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -196,13 +196,26 @@ static int malidp_de_plane_check(struct drm_plane *plane,
ms->n_planes = fb->format->num_planes;
for (i = 0; i < ms->n_planes; i++) {
u8 alignment = malidp_hw_get_pitch_align(mp->hwdev, rotated);
-   if (fb->pitches[i] & (alignment - 1)) {
+
+   if ((fb->pitches[i] * drm_format_info_block_height(fb->format, 
i))
+   & (alignment - 1)) {
DRM_DEBUG_KMS("Invalid pitch %u for plane %d\n",
  fb->pitches[i], i);
return -EINVAL;
}
}
 
+   if (fb->width % drm_format_info_block_width(fb->format, 0) ||
+   fb->height % drm_format_info_block_height(fb->format, 0)) {
+   DRM_DEBUG_KMS("Buffer width/height needs to be a multiple of 
tile sizes");
+   return -EINVAL;
+   }
+   if ((state->src_x >> 16) % drm_format_info_block_width(fb->format, 0) ||
+   (state->src_y >> 16) % drm_format_info_block_height(fb->format, 0)) 
{
+   DRM_DEBUG_KMS("Plane src_x/src_y needs to be a multiple of tile 
sizes");
+   return -EINVAL;
+   }
+
if ((state->crtc_w > mp->hwdev->max_line_size) ||
(state->crtc_h > mp->hwdev->max_line_size) ||
(state->crtc_w < mp->hwdev->min_line_size) ||
@@ -258,8 +271,14 @@ static void malidp_de_set_plane_pitches(struct 
malidp_plane *mp,
num_strides = (mp->hwdev->hw->features &
   MALIDP_DEVICE_LV_HAS_3_STRIDES) ? 3 : 2;
 
+   /*
+* The drm convention for pitch is that it needs to cover width * cpp,
+* but our hardware wants the pitch/stride to cover all rows included
+* in a tile.
+*/
for (i = 0; i < num_strides; ++i)
-   malidp_hw_write(mp->hwdev, pitches[i],
+   malidp_hw_write(mp->hwdev, pitches[i] *
+   
drm_format_info_block_height(mp->base.state->fb->format, i),
mp->layer->base +
mp->layer->stride_offset + i * 4);
 }
-- 
2.18.0

_

[PATCH v5 3/9] drm/fourcc: Add fourcc for Mali linear tiled formats

2018-10-19 Thread Alexandru Gheorghe
Mali-DP implements a number of tiled yuv formats which are not
currently described in drm_fourcc.h.
This adds those definitions and describes their memory layout by
using the newly added char_per_block, block_w, block_h.

Signed-off-by: Alexandru Gheorghe 
---
 drivers/gpu/drm/drm_fourcc.c  | 12 
 include/uapi/drm/drm_fourcc.h | 14 ++
 2 files changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index a843a5fc8dbf..69caa577149c 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -228,6 +228,18 @@ const struct drm_format_info *__drm_format_info(u32 format)
{ .format = DRM_FORMAT_P010,.depth = 0,  
.num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true  },
{ .format = DRM_FORMAT_P012,.depth = 0,  
.num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true  },
{ .format = DRM_FORMAT_P016,.depth = 0,  
.num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true  },
+   { .format = DRM_FORMAT_Y0L0,.depth = 0,  
.num_planes = 1,
+ .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, 
.block_h = { 2, 0, 0},
+ .hsub = 2, .vsub = 2, .has_alpha = true, .is_yuv = true },
+   { .format = DRM_FORMAT_X0L0,.depth = 0,  
.num_planes = 1,
+ .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, 
.block_h = { 2, 0, 0},
+ .hsub = 2, .vsub = 2, .is_yuv = true },
+   { .format = DRM_FORMAT_Y0L2,.depth = 0,  
.num_planes = 1,
+ .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, 
.block_h = { 2, 0, 0},
+ .hsub = 2, .vsub = 2, .has_alpha = true, .is_yuv = true },
+   { .format = DRM_FORMAT_X0L2,.depth = 0,  
.num_planes = 1,
+ .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, 
.block_h = { 2, 0, 0},
+ .hsub = 2, .vsub = 2, .is_yuv = true },
};
 
unsigned int i;
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index 600106adf91f..4de86dbf40ca 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -152,6 +152,20 @@ extern "C" {
 
 #define DRM_FORMAT_AYUVfourcc_code('A', 'Y', 'U', 'V') /* 
[31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
 
+/*
+ * packed YCbCr420 2x2 tiled formats
+ * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile
+ */
+/* [63:0]   A3:A2:Y3:0:Cr0:0:Y2:0:A1:A0:Y1:0:Cb0:0:Y0:0  
1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian */
+#define DRM_FORMAT_Y0L0fourcc_code('Y', '0', 'L', '0')
+/* [63:0]   X3:X2:Y3:0:Cr0:0:Y2:0:X1:X0:Y1:0:Cb0:0:Y0:0  
1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian */
+#define DRM_FORMAT_X0L0fourcc_code('X', '0', 'L', '0')
+
+/* [63:0]   A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little 
endian */
+#define DRM_FORMAT_Y0L2fourcc_code('Y', '0', 'L', '2')
+/* [63:0]   X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little 
endian */
+#define DRM_FORMAT_X0L2fourcc_code('X', '0', 'L', '2')
+
 /*
  * 2 plane RGB + A
  * index 0 = RGB plane, same format as the corresponding non _A8 format has
-- 
2.18.0

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


[PATCH v5 7/9] drm/afbc: Add AFBC modifier usage documentation

2018-10-19 Thread Alexandru Gheorghe
From: Brian Starkey 

AFBC is a flexible, proprietary, lossless compression protocol and
format, with a number of defined DRM format modifiers. To facilitate
consistency and compatibility between different AFBC producers and
consumers, document the expectations for usage of the AFBC DRM format
modifiers in a new .rst chapter.

Signed-off-by: Brian Starkey 
Reviewed-by: Liviu Dudau 
---
 Documentation/gpu/afbc.rst| 233 ++
 Documentation/gpu/drivers.rst |   1 +
 MAINTAINERS   |   1 +
 include/uapi/drm/drm_fourcc.h |   3 +
 4 files changed, 238 insertions(+)
 create mode 100644 Documentation/gpu/afbc.rst

diff --git a/Documentation/gpu/afbc.rst b/Documentation/gpu/afbc.rst
new file mode 100644
index ..922d955da192
--- /dev/null
+++ b/Documentation/gpu/afbc.rst
@@ -0,0 +1,233 @@
+===
+ Arm Framebuffer Compression (AFBC)
+===
+
+AFBC is a proprietary lossless image compression protocol and format.
+It provides fine-grained random access and minimizes the amount of
+data transferred between IP blocks.
+
+AFBC can be enabled on drivers which support it via use of the AFBC
+format modifiers defined in drm_fourcc.h. See DRM_FORMAT_MOD_ARM_AFBC(*).
+
+All users of the AFBC modifiers must follow the usage guidelines laid
+out in this document, to ensure compatibility across different AFBC
+producers and consumers.
+
+Components and Ordering
+===
+
+AFBC streams can contain several components - where a component
+corresponds to a color channel (i.e. R, G, B, X, A, Y, Cb, Cr).
+The assignment of input/output color channels must be consistent
+between the encoder and the decoder for correct operation, otherwise
+the consumer will interpret the decoded data incorrectly.
+
+Furthermore, when the lossless colorspace transform is used
+(AFBC_FORMAT_MOD_YTR, which should be enabled for RGB buffers for
+maximum compression efficiency), the component order must be:
+
+ * Component 0: R
+ * Component 1: G
+ * Component 2: B
+
+The component ordering is communicated via the fourcc code in the
+fourcc:modifier pair. In general, component '0' is considered to
+reside in the least-significant bits of the corresponding linear
+format. For example, COMP(bits):
+
+ * DRM_FORMAT_ABGR
+
+   * Component 0: R(8)
+   * Component 1: G(8)
+   * Component 2: B(8)
+   * Component 3: A(8)
+
+ * DRM_FORMAT_BGR888
+
+   * Component 0: R(8)
+   * Component 1: G(8)
+   * Component 2: B(8)
+
+ * DRM_FORMAT_YUYV
+
+   * Component 0: Y(8)
+   * Component 1: Cb(8, 2x1 subsampled)
+   * Component 2: Cr(8, 2x1 subsampled)
+
+In AFBC, 'X' components are not treated any differently from any other
+component. Therefore, an AFBC buffer with fourcc DRM_FORMAT_XBGR
+encodes with 4 components, like so:
+
+ * DRM_FORMAT_XBGR
+
+   * Component 0: R(8)
+   * Component 1: G(8)
+   * Component 2: B(8)
+   * Component 3: X(8)
+
+Please note, however, that the inclusion of a "wasted" 'X' channel is
+bad for compression efficiency, and so it's recommended to avoid
+formats containing 'X' bits. If a fourth component is
+required/expected by the encoder/decoder, then it is recommended to
+instead use an equivalent format with alpha, setting all alpha bits to
+'1'. If there is no requirement for a fourth component, then a format
+which doesn't include alpha can be used, e.g. DRM_FORMAT_BGR888.
+
+Number of Planes
+
+
+Formats which are typically multi-planar in linear layouts (e.g. YUV
+420), can be encoded into one, or multiple, AFBC planes. As with
+component order, the encoder and decoder must agree about the number
+of planes in order to correctly decode the buffer. The fourcc code is
+used to determine the number of encoded planes in an AFBC buffer,
+matching the number of planes for the linear (unmodified) format.
+Within each plane, the component ordering also follows the fourcc
+code:
+
+For example:
+
+ * DRM_FORMAT_YUYV: nplanes = 1
+
+   * Plane 0:
+
+ * Component 0: Y(8)
+ * Component 1: Cb(8, 2x1 subsampled)
+ * Component 2: Cr(8, 2x1 subsampled)
+
+ * DRM_FORMAT_NV12: nplanes = 2
+
+   * Plane 0:
+
+ * Component 0: Y(8)
+
+   * Plane 1:
+
+ * Component 0: Cb(8, 2x1 subsampled)
+ * Component 1: Cr(8, 2x1 subsampled)
+
+Cross-device interoperability
+=
+
+For maximum compatibility across devices, the table below defines
+canonical formats for use between AFBC-enabled devices. Formats which
+are listed here must be used exactly as specified when using the AFBC
+modifiers. Formats which are not listed should be avoided.
+
+.. flat-table:: AFBC formats
+
+   * - Fourcc code
+ - Description
+ - Planes/Components
+
+   * - DRM_FORMAT_ABGR2101010
+ - 10-bit per component RGB, with 2-bit alpha
+ - Plane 0: 4 components
+  * Component 0: R(10)
+  * Component 1: G(10)
+  * Component 2: B(10)
+ 

[PATCH v5 9/9] drm/selftests: Add tests for drm_format_info* helpers

2018-10-19 Thread Alexandru Gheorghe
Add selftests for the following newly added functions:
 - drm_format_info_block_width
 - drm_format_info_block_height
 - drm_format_info_min_pitch

Signed-off-by: Alexandru Gheorghe 
---
 drivers/gpu/drm/selftests/Makefile|   3 +-
 .../gpu/drm/selftests/drm_modeset_selftests.h |   3 +
 drivers/gpu/drm/selftests/test-drm_format.c   | 290 ++
 .../drm/selftests/test-drm_modeset_common.h   |   3 +
 4 files changed, 298 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/selftests/test-drm_format.c

diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
index 7e6581921da0..07b4f88b422a 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -1,3 +1,4 @@
-test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o
+test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o \
+  test-drm_format.o
 
 obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o
diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h 
b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
index 9771290ed228..4e203ac8c134 100644
--- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
@@ -7,3 +7,6 @@
  * Tests are executed in order by igt/drm_selftests_helper
  */
 selftest(check_plane_state, igt_check_plane_state)
+selftest(check_drm_format_block_width, igt_check_drm_format_block_width)
+selftest(check_drm_format_block_height, igt_check_drm_format_block_height)
+selftest(check_drm_format_min_pitch, igt_check_drm_format_min_pitch)
diff --git a/drivers/gpu/drm/selftests/test-drm_format.c 
b/drivers/gpu/drm/selftests/test-drm_format.c
new file mode 100644
index ..5abfd5e28d7d
--- /dev/null
+++ b/drivers/gpu/drm/selftests/test-drm_format.c
@@ -0,0 +1,290 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Test cases for the drm_format functions
+ */
+
+#define pr_fmt(fmt) "drm_format: " fmt
+
+#include 
+#include 
+
+#include 
+
+#include "test-drm_modeset_common.h"
+
+int igt_check_drm_format_block_width(void *ignored)
+{
+   const struct drm_format_info *info = NULL;
+
+   /* Test invalid arguments */
+   FAIL_ON(drm_format_info_block_width(info, 0) != 0);
+   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
+   FAIL_ON(drm_format_info_block_width(info, 1) != 0);
+
+   /* Test 1 plane format */
+   info = drm_format_info(DRM_FORMAT_XRGB);
+   FAIL_ON(!info);
+   FAIL_ON(drm_format_info_block_width(info, 0) != 1);
+   FAIL_ON(drm_format_info_block_width(info, 1) != 0);
+   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
+
+   /* Test 2 planes format */
+   info = drm_format_info(DRM_FORMAT_NV12);
+   FAIL_ON(!info);
+   FAIL_ON(drm_format_info_block_width(info, 0) != 1);
+   FAIL_ON(drm_format_info_block_width(info, 1) != 1);
+   FAIL_ON(drm_format_info_block_width(info, 2) != 0);
+   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
+
+   /* Test 3 planes format */
+   info = drm_format_info(DRM_FORMAT_YUV422);
+   FAIL_ON(!info);
+   FAIL_ON(drm_format_info_block_width(info, 0) != 1);
+   FAIL_ON(drm_format_info_block_width(info, 1) != 1);
+   FAIL_ON(drm_format_info_block_width(info, 2) != 1);
+   FAIL_ON(drm_format_info_block_width(info, 3) != 0);
+   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
+
+   /* Test a tiled format */
+   info = drm_format_info(DRM_FORMAT_X0L0);
+   FAIL_ON(!info);
+   FAIL_ON(drm_format_info_block_width(info, 0) != 2);
+   FAIL_ON(drm_format_info_block_width(info, 1) != 0);
+   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
+
+   return 0;
+}
+
+int igt_check_drm_format_block_height(void *ignored)
+{
+   const struct drm_format_info *info = NULL;
+
+   /* Test invalid arguments */
+   FAIL_ON(drm_format_info_block_height(info, 0) != 0);
+   FAIL_ON(drm_format_info_block_height(info, -1) != 0);
+   FAIL_ON(drm_format_info_block_height(info, 1) != 0);
+
+   /* Test 1 plane format */
+   info = drm_format_info(DRM_FORMAT_XRGB);
+   FAIL_ON(!info);
+   FAIL_ON(drm_format_info_block_height(info, 0) != 1);
+   FAIL_ON(drm_format_info_block_height(info, 1) != 0);
+   FAIL_ON(drm_format_info_block_height(info, -1) != 0);
+
+   /* Test 2 planes format */
+   info = drm_format_info(DRM_FORMAT_NV12);
+   FAIL_ON(!info);
+   FAIL_ON(drm_format_info_block_height(info, 0) != 1);
+   FAIL_ON(drm_format_info_block_height(info, 1) != 1);
+   FAIL_ON(drm_format_info_block_height(info, 2) != 0);
+   FAIL_ON(drm_format_info_block_height(info, -1) != 0);
+
+   /* Test 3 planes format */
+   info = drm_format_info(DRM_FORMAT_YUV422);
+   FAIL_ON(!info);
+   FAIL_ON(drm_format_info_block_height(info, 0) != 1);
+   FAIL_ON(drm_format_info_block_height(

[PATCH v5 5/9] drm: Extend framebuffer_check to handle formats with cpp/char_per_block 0

2018-10-19 Thread Alexandru Gheorghe
For formats that are supported only with non-linear modifiers it
doesn't make to much sense to define cpp or char_per_block, so that
will be set to 0.

This patch adds a restriction to force having a modifier attached when
cpp/char_per_block is 0, and to bypass checking the pitch restriction.

This had been discussed here.
[1] 
https://people.freedesktop.org/~cbrill/dri-log/?channel=dri-devel&highlight_names=&date=2018-09-13&show_html=true

Signed-off-by: Alexandru Gheorghe 
---
 drivers/gpu/drm/drm_framebuffer.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_framebuffer.c 
b/drivers/gpu/drm/drm_framebuffer.c
index 6aca8a1ccdb6..e346d0ad92e0 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -195,8 +195,13 @@ static int framebuffer_check(struct drm_device *dev,
for (i = 0; i < info->num_planes; i++) {
unsigned int width = fb_plane_width(r->width, info, i);
unsigned int height = fb_plane_height(r->height, info, i);
+   unsigned int block_size = info->char_per_block[i];
u64 min_pitch = drm_format_info_min_pitch(info, i, width);
 
+   if (!block_size && (r->modifier[i] == DRM_FORMAT_MOD_LINEAR)) {
+   DRM_DEBUG_KMS("Format requires non-linear modifier for 
plane %d\n", i);
+   return -EINVAL;
+   }
if (!r->handles[i]) {
DRM_DEBUG_KMS("no buffer object handle for plane %d\n", 
i);
return -EINVAL;
@@ -208,7 +213,7 @@ static int framebuffer_check(struct drm_device *dev,
if ((uint64_t) height * r->pitches[i] + r->offsets[i] > 
UINT_MAX)
return -ERANGE;
 
-   if (r->pitches[i] < min_pitch) {
+   if (block_size && r->pitches[i] < min_pitch) {
DRM_DEBUG_KMS("bad pitch %u for plane %d\n", 
r->pitches[i], i);
return -EINVAL;
}
-- 
2.18.0

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


Re: [PATCH] MAINTAINERS: Add entry for VKMS

2018-10-19 Thread Rodrigo Siqueira
On 10/17, Joe Perches wrote:
> On Wed, 2018-10-17 at 19:51 -0300, Rodrigo Siqueira wrote:
> > Add maintainers and reviewers for VKMS driver
> > 
> > Signed-off-by: Rodrigo Siqueira 
> > ---
> >  MAINTAINERS | 10 ++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 39c3f6682ace..78c3c0bf89fa 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -4592,6 +4592,16 @@ T:   git git://anongit.freedesktop.org/drm/drm-misc
> >  S: Supported
> >  F: drivers/gpu/drm/pl111/
> >  
> > +DRM DRIVER FOR VIRTUAL KERNEL MODESETTING (VKMS)
> > +M: Rodrigo Siqueira 
> > +R: Haneen Mohammed 
> > +R: Daniel Vetter 
> > +T: git git://anongit.freedesktop.org/drm/drm-misc
> > +S: Maintained
> > +L: dri-devel@lists.freedesktop.org 
> > +F: drivers/gpu/drm/vkms/
> > +F: Documentation/gpu/vkms.rst
> > +
> >  DRM DRIVER FOR ARM VERSATILE TFT PANELS
> >  M: Linus Walleij 
> >  T: git git://anongit.freedesktop.org/drm/drm-misc
> 
> Please insert this section in alphabetical order

Hi Joe,

Thanks for your feedback. I will send a V2.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: fix deadlock of syncobj

2018-10-19 Thread zhoucm1



On 2018年10月19日 18:50, Chris Wilson wrote:

Quoting Chunming Zhou (2018-10-19 11:26:41)

Signed-off-by: Chunming Zhou 
Cc: Daniel Vetter 
Cc: Chris Wilson 
Cc: Christian König 
---
  drivers/gpu/drm/drm_syncobj.c | 7 +--
  1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 57bf6006394d..2f3c14cb5156 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -344,13 +344,16 @@ void drm_syncobj_replace_fence(struct drm_syncobj 
*syncobj,
 drm_syncobj_create_signal_pt(syncobj, fence, pt_value);
 if (fence) {
 struct drm_syncobj_cb *cur, *tmp;
+   struct list_head cb_list;
+   INIT_LIST_HEAD(&cb_list);

LIST_HEAD(cb_list); // does both in one


 spin_lock(&syncobj->lock);
-   list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) {
+   list_splice_init(&syncobj->cb_list, &cb_list);

Steal the snapshot of the list under the lock, ok.


+   spin_unlock(&syncobj->lock);
+   list_for_each_entry_safe(cur, tmp, &cb_list, node) {
 list_del_init(&cur->node);

Races against external caller of drm_syncobj_remove_callback(). However,
it looks like that race is just fine, but we don't guard against the
struct drm_syncobj_cb itself being freed, leading to all sort of fun for
an interrupted drm_syncobj_array_wait_timeout.
Thanks quick review, I will use "while (!list_empty()) { e = 
list_first_entry(); list_del(e)" to avoid deadlock.


will send v2 in one minute.

Regards,
David Zhou


That kfree seems to undermine the validity of stealing the list.
-Chris


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


Re: [PATCH] drm: fix deadlock of syncobj

2018-10-19 Thread zhoucm1



On 2018年10月19日 19:26, zhoucm1 wrote:



On 2018年10月19日 18:50, Chris Wilson wrote:

Quoting Chunming Zhou (2018-10-19 11:26:41)

Signed-off-by: Chunming Zhou 
Cc: Daniel Vetter 
Cc: Chris Wilson 
Cc: Christian König 
---
  drivers/gpu/drm/drm_syncobj.c | 7 +--
  1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c 
b/drivers/gpu/drm/drm_syncobj.c

index 57bf6006394d..2f3c14cb5156 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -344,13 +344,16 @@ void drm_syncobj_replace_fence(struct 
drm_syncobj *syncobj,

 drm_syncobj_create_signal_pt(syncobj, fence, pt_value);
 if (fence) {
 struct drm_syncobj_cb *cur, *tmp;
+   struct list_head cb_list;
+   INIT_LIST_HEAD(&cb_list);

LIST_HEAD(cb_list); // does both in one


spin_lock(&syncobj->lock);
-   list_for_each_entry_safe(cur, tmp, 
&syncobj->cb_list, node) {

+   list_splice_init(&syncobj->cb_list, &cb_list);

Steal the snapshot of the list under the lock, ok.


+ spin_unlock(&syncobj->lock);
+   list_for_each_entry_safe(cur, tmp, &cb_list, node) {
 list_del_init(&cur->node);

Races against external caller of drm_syncobj_remove_callback(). However,
it looks like that race is just fine, but we don't guard against the
struct drm_syncobj_cb itself being freed, leading to all sort of fun for
an interrupted drm_syncobj_array_wait_timeout.
Thanks quick review, I will use "while (!list_empty()) { e = 
list_first_entry(); list_del(e)" to avoid deadlock.
this still cannot resolve freeing problem,  do you mind I change 
spinlock to mutex?


Thanks,
David Zhou


will send v2 in one minute.

Regards,
David Zhou


That kfree seems to undermine the validity of stealing the list.
-Chris




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


Re: [PATCH] drm: fix deadlock of syncobj

2018-10-19 Thread Koenig, Christian
Am 19.10.18 um 14:01 schrieb zhoucm1:
>
>
> On 2018年10月19日 19:26, zhoucm1 wrote:
>>
>>
>> On 2018年10月19日 18:50, Chris Wilson wrote:
>>> Quoting Chunming Zhou (2018-10-19 11:26:41)
 Signed-off-by: Chunming Zhou 
 Cc: Daniel Vetter 
 Cc: Chris Wilson 
 Cc: Christian König 
 ---
   drivers/gpu/drm/drm_syncobj.c | 7 +--
   1 file changed, 5 insertions(+), 2 deletions(-)

 diff --git a/drivers/gpu/drm/drm_syncobj.c 
 b/drivers/gpu/drm/drm_syncobj.c
 index 57bf6006394d..2f3c14cb5156 100644
 --- a/drivers/gpu/drm/drm_syncobj.c
 +++ b/drivers/gpu/drm/drm_syncobj.c
 @@ -344,13 +344,16 @@ void drm_syncobj_replace_fence(struct 
 drm_syncobj *syncobj,
  drm_syncobj_create_signal_pt(syncobj, fence, pt_value);
  if (fence) {
  struct drm_syncobj_cb *cur, *tmp;
 +   struct list_head cb_list;
 +   INIT_LIST_HEAD(&cb_list);
>>> LIST_HEAD(cb_list); // does both in one
>>>
 spin_lock(&syncobj->lock);
 -   list_for_each_entry_safe(cur, tmp, 
 &syncobj->cb_list, node) {
 +   list_splice_init(&syncobj->cb_list, &cb_list);
>>> Steal the snapshot of the list under the lock, ok.
>>>
 + spin_unlock(&syncobj->lock);
 +   list_for_each_entry_safe(cur, tmp, &cb_list, node) {
  list_del_init(&cur->node);
>>> Races against external caller of drm_syncobj_remove_callback(). 
>>> However,
>>> it looks like that race is just fine, but we don't guard against the
>>> struct drm_syncobj_cb itself being freed, leading to all sort of fun 
>>> for
>>> an interrupted drm_syncobj_array_wait_timeout.
>> Thanks quick review, I will use "while (!list_empty()) { e = 
>> list_first_entry(); list_del(e)" to avoid deadlock.
> this still cannot resolve freeing problem,  do you mind I change 
> spinlock to mutex?

How does that help?

What you could do is to merge the array of fences into the beginning of 
the signal_pt, e.g. something like this:

struct drm_syncobj_signal_pt {
         struct dma_fence fences[2];
     struct dma_fence_array *fence_array;
     u64    value;
     struct list_head list;
};

This way the drm_syncobj_signal_pt is freed when the fence_array is 
freed. That should be sufficient if we correctly reference count the 
fence_array.

Christian.

>
> Thanks,
> David Zhou
>>
>> will send v2 in one minute.
>>
>> Regards,
>> David Zhou
>>>
>>> That kfree seems to undermine the validity of stealing the list.
>>> -Chris
>>
>

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


[Bug 108496] Non functional -d, --dry-run option for the igt_runner

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108496

Bug ID: 108496
   Summary: Non functional -d, --dry-run option for the igt_runner
   Product: DRI
   Version: DRI git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: IGT
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: andi.sh...@intel.com

The runner tool build/runner/igt_runner has the dry-run feature that in the
help is displayed as:

"-d, --dry-run Do not execute the tests"

But in reality this flag doesn't have any effect and the tests are executed in
any case.

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


Re: [PATCH] drm: fix deadlock of syncobj

2018-10-19 Thread zhoucm1



On 2018年10月19日 20:08, Koenig, Christian wrote:

Am 19.10.18 um 14:01 schrieb zhoucm1:


On 2018年10月19日 19:26, zhoucm1 wrote:


On 2018年10月19日 18:50, Chris Wilson wrote:

Quoting Chunming Zhou (2018-10-19 11:26:41)

Signed-off-by: Chunming Zhou 
Cc: Daniel Vetter 
Cc: Chris Wilson 
Cc: Christian König 
---
   drivers/gpu/drm/drm_syncobj.c | 7 +--
   1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c
b/drivers/gpu/drm/drm_syncobj.c
index 57bf6006394d..2f3c14cb5156 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -344,13 +344,16 @@ void drm_syncobj_replace_fence(struct
drm_syncobj *syncobj,
  drm_syncobj_create_signal_pt(syncobj, fence, pt_value);
  if (fence) {
  struct drm_syncobj_cb *cur, *tmp;
+   struct list_head cb_list;
+   INIT_LIST_HEAD(&cb_list);

LIST_HEAD(cb_list); // does both in one


spin_lock(&syncobj->lock);
-   list_for_each_entry_safe(cur, tmp,
&syncobj->cb_list, node) {
+   list_splice_init(&syncobj->cb_list, &cb_list);

Steal the snapshot of the list under the lock, ok.


+ spin_unlock(&syncobj->lock);
+   list_for_each_entry_safe(cur, tmp, &cb_list, node) {
  list_del_init(&cur->node);

Races against external caller of drm_syncobj_remove_callback().
However,
it looks like that race is just fine, but we don't guard against the
struct drm_syncobj_cb itself being freed, leading to all sort of fun
for
an interrupted drm_syncobj_array_wait_timeout.

Thanks quick review, I will use "while (!list_empty()) { e =
list_first_entry(); list_del(e)" to avoid deadlock.

this still cannot resolve freeing problem,  do you mind I change
spinlock to mutex?

How does that help?

What you could do is to merge the array of fences into the beginning of
the signal_pt, e.g. something like this:

struct drm_syncobj_signal_pt {
          struct dma_fence fences[2];
      struct dma_fence_array *fence_array;
      u64    value;
      struct list_head list;
};

This way the drm_syncobj_signal_pt is freed when the fence_array is
freed. That should be sufficient if we correctly reference count the
fence_array.

I'm not sure what problem you said, the deadlock reason is :
Cb func will call drm_syncobj_search_fence, which will need to grab the 
lock, otherwise deadlock.


But when we steal list or use "while (!list_empty()) { e = 
list_first_entry(); list_del(e)", both will encounter another freeing 
problem, that is syncobj_cb could be freed when wait timeout.


If we change to use mutex, then we can move lock inside of _search_fence 
out.
another way is we add a separate spinlock for signal_pt_list, not share 
one lock with cb_list.


Regards,
David


Christian.


Thanks,
David Zhou

will send v2 in one minute.

Regards,
David Zhou

That kfree seems to undermine the validity of stealing the list.
-Chris


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


Re: [PULL] drm-intel-next-fixes

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 12:38 PM Joonas Lahtinen
 wrote:
>
> Hi Dave,
>
> Here are the promised MST fixes that were missing due to being
> in i915 tree, yet outside i915 directory.
>
> Further explanation in the previous PR's thread.

fwiw, lgtm.

Cheers, Daniel
>
> Regards, Joonas
>
> ***
>
> drm-intel-next-fixes-2018-10-19:
> - The missing 4 MST patches that tooling didn't pick from drm core/nouveau
> The following changes since commit f2bfc71aee75feff33ca659322b72ffeed5a243d:
>
>   Merge tag 'drm-intel-next-fixes-2018-10-18' of 
> git://anongit.freedesktop.org/drm/drm-intel into drm-next (2018-10-19 
> 14:28:11 +1000)
>
> are available in the Git repository at:
>
>   git://anongit.freedesktop.org/drm/drm-intel 
> tags/drm-intel-next-fixes-2018-10-19
>
> for you to fetch changes up to 7b0f61e91b6056c71649efa3204112a4b6cf5fc8:
>
>   drm/nouveau: Fix nv50_mstc->best_encoder() (2018-10-19 11:46:46 +0300)
>
> 
> - The missing 4 MST patches that tooling didn't pick from drm core/nouveau
>
> 
> Lyude Paul (4):
>   drm/atomic_helper: Disallow new modesets on unregistered connectors
>   drm/atomic_helper: Allow DPMS On<->Off changes for unregistered 
> connectors
>   drm/atomic_helper: Stop modesets on unregistered connectors harder
>   drm/nouveau: Fix nv50_mstc->best_encoder()
>
>  drivers/gpu/drm/drm_atomic_helper.c | 21 +-
>  drivers/gpu/drm/drm_connector.c | 11 ++---
>  drivers/gpu/drm/i915/intel_dp_mst.c |  8 ++--
>  drivers/gpu/drm/nouveau/dispnv50/disp.c | 14 ++-
>  include/drm/drm_connector.h | 71 
> -
>  5 files changed, 103 insertions(+), 22 deletions(-)



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: fix deadlock of syncobj

2018-10-19 Thread Christian König

Am 19.10.18 um 14:19 schrieb zhoucm1:



On 2018年10月19日 20:08, Koenig, Christian wrote:

Am 19.10.18 um 14:01 schrieb zhoucm1:


On 2018年10月19日 19:26, zhoucm1 wrote:


On 2018年10月19日 18:50, Chris Wilson wrote:

Quoting Chunming Zhou (2018-10-19 11:26:41)

Signed-off-by: Chunming Zhou 
Cc: Daniel Vetter 
Cc: Chris Wilson 
Cc: Christian König 
---
   drivers/gpu/drm/drm_syncobj.c | 7 +--
   1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c
b/drivers/gpu/drm/drm_syncobj.c
index 57bf6006394d..2f3c14cb5156 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -344,13 +344,16 @@ void drm_syncobj_replace_fence(struct
drm_syncobj *syncobj,
  drm_syncobj_create_signal_pt(syncobj, fence, pt_value);
  if (fence) {
  struct drm_syncobj_cb *cur, *tmp;
+   struct list_head cb_list;
+   INIT_LIST_HEAD(&cb_list);

LIST_HEAD(cb_list); // does both in one


spin_lock(&syncobj->lock);
-   list_for_each_entry_safe(cur, tmp,
&syncobj->cb_list, node) {
+ list_splice_init(&syncobj->cb_list, &cb_list);

Steal the snapshot of the list under the lock, ok.


+ spin_unlock(&syncobj->lock);
+   list_for_each_entry_safe(cur, tmp, &cb_list, node) {
list_del_init(&cur->node);

Races against external caller of drm_syncobj_remove_callback().
However,
it looks like that race is just fine, but we don't guard against the
struct drm_syncobj_cb itself being freed, leading to all sort of fun
for
an interrupted drm_syncobj_array_wait_timeout.

Thanks quick review, I will use "while (!list_empty()) { e =
list_first_entry(); list_del(e)" to avoid deadlock.

this still cannot resolve freeing problem,  do you mind I change
spinlock to mutex?

How does that help?

What you could do is to merge the array of fences into the beginning of
the signal_pt, e.g. something like this:

struct drm_syncobj_signal_pt {
          struct dma_fence fences[2];
      struct dma_fence_array *fence_array;
      u64    value;
      struct list_head list;
};

This way the drm_syncobj_signal_pt is freed when the fence_array is
freed. That should be sufficient if we correctly reference count the
fence_array.

I'm not sure what problem you said, the deadlock reason is :
Cb func will call drm_syncobj_search_fence, which will need to grab 
the lock, otherwise deadlock.


But when we steal list or use "while (!list_empty()) { e = 
list_first_entry(); list_del(e)", both will encounter another freeing 
problem, that is syncobj_cb could be freed when wait timeout.


If we change to use mutex, then we can move lock inside of 
_search_fence out.


another way is we add a separate spinlock for signal_pt_list, not 
share one lock with cb_list.


Well of hand that sounds like the cleanest approach to me.

Christian.



Regards,
David


Christian.


Thanks,
David Zhou

will send v2 in one minute.

Regards,
David Zhou

That kfree seems to undermine the validity of stealing the list.
-Chris


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


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


Re: [PATCH v5 1/9] drm: fourcc: Convert drm_format_info kerneldoc to in-line member documentation

2018-10-19 Thread Maxime Ripard
On Fri, Oct 19, 2018 at 11:57:44AM +0100, Alexandru Gheorghe wrote:
> In-line member documentation seems to be desired way of documenting
> structure members.
> 
> This change had been suggested by Daniel Vetter here:
> https://lists.freedesktop.org/archives/dri-devel/2018-October/192176.html
> 
> Signed-off-by: Alexandru Gheorghe 

Reviewed-by: Maxime Ripard 

Thanks!
Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 108498] ir_dereference_record nullptr segfault in radeonsi_dri.so

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108498

Bug ID: 108498
   Summary: ir_dereference_record nullptr segfault in
radeonsi_dri.so
   Product: Mesa
   Version: 18.1
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Gallium/radeonsi
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: cla...@mathr.co.uk
QA Contact: dri-devel@lists.freedesktop.org

Created attachment 142095
  --> https://bugs.freedesktop.org/attachment.cgi?id=142095&action=edit
tarball of GLSL source code for use in Fragmentarium

I'm using $ apt-cache policy libgl1-mesa-dri
libgl1-mesa-dri:
  Installed: 18.1.7-1
  Candidate: 18.1.7-1
  Version table:
 18.2.0-1 1
  1 http://ftp.uk.debian.org/debian experimental/main amd64 Packages
 18.1.9-1 500
500 http://ftp.uk.debian.org/debian unstable/main amd64 Packages
 *** 18.1.7-1 990
990 http://ftp.uk.debian.org/debian buster/main amd64 Packages
100 /var/lib/dpkg/status

I will try to compile upstream Mesa soon to see if it is a Debian-specific
issue, or whether it has already been fixed in a later version.


Fragmentarium (from https://github.com/3Dickulus/FragM ) crashes inside
radeonsi_dri.so when I try to compile part of a large shader project (~50kB of
GLSL transcluded from the main 'raymond/example.frag').  The problematic part
is the last half of 'raymond/Raymond-Trace.frag' in the attached tarball,
setting #if 0 stops it from crashing and emits an error message in the shader
compile log about missing function definitions (this is expected, the hard
crash with #if 1 is not).


It seems to be caused by something that passes a nullptr as a field name in
compiler/glsl/ir.cpp:1401, gdb backtrace is large:

Thread 1 "Fragmentarium-2" received signal SIGSEGV, Segmentation fault.
__strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:173
173 ../sysdeps/x86_64/multiarch/../strcmp.S: No such file or directory.
(gdb) bt
#0  0x764c40b6 in __strcmp_ssse3 () at
../sysdeps/x86_64/multiarch/../strcmp.S:173
#1  0x7fffe24c7d6d in glsl_type::field_type(char const*) const
(this=, name=name@entry=0x0) at
../../../src/compiler/glsl_types.cpp:1228
#2  0x7fffe24cba3f in
ir_dereference_record::ir_dereference_record(ir_rvalue*, char const*)
(this=0x56f46e00, value=, field=0x0) at
../../../src/compiler/glsl/ir.cpp:1401
#3  0x7fffe24ce720 in ir_dereference_record::clone(void*, hash_table*)
const (this=, mem_ctx=, ht=) at
../../../src/compiler/glsl/list.h:58
#4  0x7fffe2456ab4 in ast_expression::do_hir(exec_list*,
_mesa_glsl_parse_state*, bool) (this=0x56d12bf8,
instructions=0x56f459d0, state=0x56341530, needs_rvalue=)
at ../../../src/compiler/glsl/ast.h:86
#5  0x7fffe2458b43 in ast_expression_statement::hir(exec_list*,
_mesa_glsl_parse_state*) (this=, instructions=,
state=)
at ../../../src/compiler/glsl/ast_to_hir.cpp:2228
#6  0x7fffe2458b9f in ast_compound_statement::hir(exec_list*,
_mesa_glsl_parse_state*) (this=0x56d12cc8, instructions=0x56f459d0,
state=0x56341530)
at ../../../src/compiler/glsl/ast_to_hir.cpp:2244
#7  0x7fffe2460f0e in ast_iteration_statement::hir(exec_list*,
_mesa_glsl_parse_state*) (this=0x56d12d28, instructions=,
state=0x56341530)
at ../../../src/compiler/glsl/ast_to_hir.cpp:6902
#8  0x7fffe2458b9f in ast_compound_statement::hir(exec_list*,
_mesa_glsl_parse_state*) (this=0x56d12e70, instructions=0x56ff6690,
state=0x56341530)
at ../../../src/compiler/glsl/ast_to_hir.cpp:2244
#9  0x7fffe245f462 in ast_function_definition::hir(exec_list*,
_mesa_glsl_parse_state*) (this=0x56d12ed0, instructions=,
state=0x56341530)
at ../../../src/compiler/glsl/ast_to_hir.cpp:6182
#10 0x7fffe2455b70 in _mesa_ast_to_hir(exec_list*, _mesa_glsl_parse_state*)
(instructions=0x564c7570, state=0x56341530) at
../../../src/compiler/glsl/ast_to_hir.cpp:156
#11 0x7fffe24b9551 in _mesa_glsl_compile_shader(gl_context*, gl_shader*,
bool, bool, bool) (ctx=ctx@entry=0x5604a230,
shader=shader@entry=0x56496b40, dump_ast=dump_ast@entry=false,
dump_hir=dump_hir@entry=false, force_recompile=force_recompile@entry=false) at
../../../src/compiler/glsl/glsl_parser_extras.cpp:2106
#12 0x7fffe235b4d0 in _mesa_compile_shader (ctx=0x5604a230,
sh=0x56496b40) at ../../../src/mesa/main/shaderapi.c:1131
#13 0x7748697f in QOpenGLFunctions::glCompileShader(unsigned int)
(this=, shader=6) at opengl/qopenglfunctions.h:1280
#14 0x7748697f in QOpenGLShaderPrivate::compile(QOpenGLShader*)
(this=this@entry=0x56485120, q=q@entry=0x563adf10) at
opengl/qopenglshaderprogram.cpp:352
#15 0x77487275 in QOpenGLShader::compileSourceCode(char const*)
(this=this@entry=0x563adf10, source=source@entry=0x56b80488 "#ve

[Bug 108486] Incompatible result.json generation between igt_runner and piglit summary

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108486

--- Comment #2 from Petri Latvala  ---
https://patchwork.freedesktop.org/series/51238/ sent for a fix. Won't merge it
yet until it gets through the currently overloaded CI.

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


Re: [PATCH v5 2/9] drm/fourcc: Add char_per_block, block_w and block_h in drm_format_info

2018-10-19 Thread Brian Starkey

Hi Alex,

On Fri, Oct 19, 2018 at 11:57:45AM +0100, Alexandru Gheorghe wrote:

For some pixel formats .cpp structure in drm_format info it's not
enough to describe the peculiarities of the pixel layout, for example
tiled formats or packed formats at bit level.

What's implemented here is to add three new members to drm_format_info
that could describe such formats:

- char_per_block[3]
- block_w[3]
- block_h[3]

char_per_block will be put in a union alongside cpp, for transparent
compatibility  with the existing format descriptions.

Regarding, block_w and block_h they are intended to be used through
their equivalent getters drm_format_info_block_width /
drm_format_info_block_height, the reason of the getters is to abstract
the fact that for normal formats block_w and block_h will be unset/0,
but the methods will be returning 1.

Additionally, convenience function drm_format_info_min_pitch had been
added that computes the minimum required pitch for a given pixel
format and buffer width.

Using that the following drm core functions had been updated to
generically handle both block and non-block formats:

- drm_fb_cma_get_gem_addr: for block formats it will just return the
 beginning of the block.
- framebuffer_check: Use the newly added drm_format_info_min_pitch.
- drm_gem_fb_create_with_funcs: Use the newly added
 drm_format_info_min_pitch.
- In places where is not expecting to handle block formats, like fbdev
 helpers I just added some warnings in case the block width/height
 are greater than 1.

Changes since v3:
- Add helper function for computing the minimum required pitch.
- Improve/cleanup documentation

Signed-off-by: Alexandru Gheorghe 


I commented on a couple of tiny typographical things below, but
otherwise this looks good to me. Thanks!

Reviewed-by: Brian Starkey 


---
drivers/gpu/drm/drm_fb_cma_helper.c  | 21 ++-
drivers/gpu/drm/drm_fb_helper.c  |  6 ++
drivers/gpu/drm/drm_fourcc.c | 62 
drivers/gpu/drm/drm_framebuffer.c|  6 +-
drivers/gpu/drm/drm_gem_framebuffer_helper.c |  2 +-
include/drm/drm_fourcc.h | 61 ++-
6 files changed, 149 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index d52344a03aa8..83941a8ca0e0 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -72,7 +72,9 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct 
drm_framebuffer *fb,
EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj);

/**
- * drm_fb_cma_get_gem_addr() - Get physical address for framebuffer
+ * drm_fb_cma_get_gem_addr() - Get physical address for framebuffer, for pixel
+ * formats where values are grouped in blocks this will get you the beginning 
of
+ * the block
 * @fb: The framebuffer
 * @state: Which state of drm plane
 * @plane: Which plane
@@ -87,6 +89,14 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer 
*fb,
struct drm_gem_cma_object *obj;
dma_addr_t paddr;
u8 h_div = 1, v_div = 1;
+   u32 block_w = drm_format_info_block_width(fb->format, plane);
+   u32 block_h = drm_format_info_block_height(fb->format, plane);
+   u32 block_size = fb->format->char_per_block[plane];
+   u32 sample_x;
+   u32 sample_y;
+   u32 block_start_y;
+   u32 num_hblocks;
+


nit: extra newline



obj = drm_fb_cma_get_gem_obj(fb, plane);
if (!obj)
@@ -99,8 +109,13 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer 
*fb,
v_div = fb->format->vsub;
}

-   paddr += (fb->format->cpp[plane] * (state->src_x >> 16)) / h_div;
-   paddr += (fb->pitches[plane] * (state->src_y >> 16)) / v_div;
+   sample_x = (state->src_x >> 16) / h_div;
+   sample_y = (state->src_y >> 16) / v_div;
+   block_start_y = (sample_y / block_h) * block_h;
+   num_hblocks = sample_x / block_w;
+
+   paddr += fb->pitches[plane] * block_start_y;
+   paddr += block_size * num_hblocks;

return paddr;
}
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a504a5e05676..9add0d7da744 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1595,6 +1595,10 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo 
*var,
if (var->pixclock != 0 || in_dbg_master())
return -EINVAL;

+   if ((drm_format_info_block_width(fb->format, 0) > 1) ||
+   (drm_format_info_block_height(fb->format, 0) > 1))
+   return -EINVAL;
+
/*
 * Changes struct fb_var_screeninfo are currently not pushed back
 * to KMS, hence fail if different settings are requested.
@@ -1969,6 +1973,8 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct 
drm_fb_helper *fb_helpe
{
struct drm_framebuffer *fb = fb_helper->fb;

+   WARN_ON((drm_format_info_block_width(fb->format, 0) > 1) ||
+ 

Re: [PATCH v5 3/9] drm/fourcc: Add fourcc for Mali linear tiled formats

2018-10-19 Thread Brian Starkey

Hi Alex,

On Fri, Oct 19, 2018 at 11:57:46AM +0100, Alexandru Gheorghe wrote:

Mali-DP implements a number of tiled yuv formats which are not
currently described in drm_fourcc.h.
This adds those definitions and describes their memory layout by
using the newly added char_per_block, block_w, block_h.

Signed-off-by: Alexandru Gheorghe 


I'm splitting formatting hairs again below, but otherwise LGTM:

Reviewed-by: Brian Starkey 


---
drivers/gpu/drm/drm_fourcc.c  | 12 
include/uapi/drm/drm_fourcc.h | 14 ++
2 files changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index a843a5fc8dbf..69caa577149c 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -228,6 +228,18 @@ const struct drm_format_info *__drm_format_info(u32 format)
{ .format = DRM_FORMAT_P010,.depth = 0,  
.num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true  },
{ .format = DRM_FORMAT_P012,.depth = 0,  
.num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true  },
{ .format = DRM_FORMAT_P016,.depth = 0,  
.num_planes = 2, .cpp = { 2, 4, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true  },
+   { .format = DRM_FORMAT_Y0L0,.depth = 0,  
.num_planes = 1,
+ .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, 
.block_h = { 2, 0, 0},


I think you're missing a space before all the closing braces on
.block_h


+ .hsub = 2, .vsub = 2, .has_alpha = true, .is_yuv = true },
+   { .format = DRM_FORMAT_X0L0,.depth = 0,  
.num_planes = 1,
+ .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, 
.block_h = { 2, 0, 0},
+ .hsub = 2, .vsub = 2, .is_yuv = true },
+   { .format = DRM_FORMAT_Y0L2,.depth = 0,  
.num_planes = 1,
+ .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, 
.block_h = { 2, 0, 0},
+ .hsub = 2, .vsub = 2, .has_alpha = true, .is_yuv = true },
+   { .format = DRM_FORMAT_X0L2,.depth = 0,  
.num_planes = 1,
+ .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, 
.block_h = { 2, 0, 0},
+ .hsub = 2, .vsub = 2, .is_yuv = true },
};

unsigned int i;
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index 600106adf91f..4de86dbf40ca 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -152,6 +152,20 @@ extern "C" {

#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] 
A:Y:Cb:Cr 8:8:8:8 little endian */

+/*
+ * packed YCbCr420 2x2 tiled formats
+ * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile
+ */
+/* [63:0]   A3:A2:Y3:0:Cr0:0:Y2:0:A1:A0:Y1:0:Cb0:0:Y0:0  
1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian */
+#define DRM_FORMAT_Y0L0fourcc_code('Y', '0', 'L', '0')
+/* [63:0]   X3:X2:Y3:0:Cr0:0:Y2:0:X1:X0:Y1:0:Cb0:0:Y0:0  
1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian */
+#define DRM_FORMAT_X0L0fourcc_code('X', '0', 'L', '0')
+
+/* [63:0]   A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little 
endian */
+#define DRM_FORMAT_Y0L2fourcc_code('Y', '0', 'L', '2')
+/* [63:0]   X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little 
endian */
+#define DRM_FORMAT_X0L2fourcc_code('X', '0', 'L', '2')
+
/*
 * 2 plane RGB + A
 * index 0 = RGB plane, same format as the corresponding non _A8 format has
--
2.18.0


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


Re: [PATCH v5 4/9] drm: mali-dp: Enable Mali-DP tiled buffer formats

2018-10-19 Thread Brian Starkey

Hi Alex,

On Fri, Oct 19, 2018 at 11:57:47AM +0100, Alexandru Gheorghe wrote:

Enable the following formats
- DRM_FORMAT_X0L0: DP650
- DRM_FORMAT_X0L2: DP550, DP650

Signed-off-by: Alexandru Gheorghe 


A couple of suggestions below, but with or without you can add my
r-b.


---
drivers/gpu/drm/arm/malidp_hw.c | 14 +++---
drivers/gpu/drm/arm/malidp_planes.c | 23 +--
2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
index c94a4422e0e9..e01fc0e5b503 100644
--- a/drivers/gpu/drm/arm/malidp_hw.c
+++ b/drivers/gpu/drm/arm/malidp_hw.c
@@ -77,12 +77,18 @@ static const struct malidp_format_id malidp500_de_formats[] 
= {
{ DRM_FORMAT_YUYV, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 2) },\
{ DRM_FORMAT_UYVY, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 3) },\
{ DRM_FORMAT_NV12, DE_VIDEO1 | DE_VIDEO2 | SE_MEMWRITE, MALIDP_ID(5, 6) 
},  \
-   { DRM_FORMAT_YUV420, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 7) }
+   { DRM_FORMAT_YUV420, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 7) }, \
+   { DRM_FORMAT_X0L2, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(6, 6)}

static const struct malidp_format_id malidp550_de_formats[] = {
MALIDP_COMMON_FORMATS,
};

+static const struct malidp_format_id malidp650_de_formats[] = {
+   MALIDP_COMMON_FORMATS,
+   { DRM_FORMAT_X0L0, DE_VIDEO1 | DE_VIDEO2, MALIDP_ID(5, 4)},
+};
+
static const struct malidp_layer malidp500_layers[] = {
{ DE_VIDEO1, MALIDP500_DE_LV_BASE, MALIDP500_DE_LV_PTR_BASE, 
MALIDP_DE_LV_STRIDE0, MALIDP500_LV_YUV2RGB },
{ DE_GRAPHICS1, MALIDP500_DE_LG1_BASE, MALIDP500_DE_LG1_PTR_BASE, 
MALIDP_DE_LG_STRIDE, 0 },
@@ -595,6 +601,8 @@ static int malidp550_rotmem_required(struct 
malidp_hw_device *hwdev, u16 w, u16
case DRM_FORMAT_BGR565:
case DRM_FORMAT_UYVY:
case DRM_FORMAT_YUYV:
+   case DRM_FORMAT_X0L0:
+   case DRM_FORMAT_X0L2:
bytes_per_col = 32;
break;
/* 16 lines at 1.5 bytes per pixel */
@@ -860,8 +868,8 @@ const struct malidp_hw malidp_device[MALIDP_MAX_DEVICES] = {
MALIDP550_DC_IRQ_SE,
.vsync_irq = MALIDP550_DC_IRQ_CONF_VALID,
},
-   .pixel_formats = malidp550_de_formats,
-   .n_pixel_formats = ARRAY_SIZE(malidp550_de_formats),
+   .pixel_formats = malidp650_de_formats,
+   .n_pixel_formats = ARRAY_SIZE(malidp650_de_formats),
.bus_align_bytes = 16,
},
.query_hw = malidp650_query_hw,
diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
b/drivers/gpu/drm/arm/malidp_planes.c
index 49c37f6dd63e..33bbc29da774 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -196,13 +196,26 @@ static int malidp_de_plane_check(struct drm_plane *plane,
ms->n_planes = fb->format->num_planes;
for (i = 0; i < ms->n_planes; i++) {
u8 alignment = malidp_hw_get_pitch_align(mp->hwdev, rotated);
-   if (fb->pitches[i] & (alignment - 1)) {
+
+   if ((fb->pitches[i] * drm_format_info_block_height(fb->format, 
i))
+   & (alignment - 1)) {
DRM_DEBUG_KMS("Invalid pitch %u for plane %d\n",
  fb->pitches[i], i);
return -EINVAL;
}
}

+   if (fb->width % drm_format_info_block_width(fb->format, 0) ||
+   fb->height % drm_format_info_block_height(fb->format, 0)) {
+   DRM_DEBUG_KMS("Buffer width/height needs to be a multiple of tile 
sizes");
+   return -EINVAL;
+   }
+   if ((state->src_x >> 16) % drm_format_info_block_width(fb->format, 0) ||
+   (state->src_y >> 16) % drm_format_info_block_height(fb->format, 0)) 
{
+   DRM_DEBUG_KMS("Plane src_x/src_y needs to be a multiple of tile 
sizes");
+   return -EINVAL;
+   }


Some local variables for block_w and block_h instead of all the
function calls might be easier to parse in this function.


+
if ((state->crtc_w > mp->hwdev->max_line_size) ||
(state->crtc_h > mp->hwdev->max_line_size) ||
(state->crtc_w < mp->hwdev->min_line_size) ||
@@ -258,8 +271,14 @@ static void malidp_de_set_plane_pitches(struct 
malidp_plane *mp,
num_strides = (mp->hwdev->hw->features &
   MALIDP_DEVICE_LV_HAS_3_STRIDES) ? 3 : 2;

+   /*
+* The drm convention for pitch is that it needs to cover width * cpp,
+* but our hardware wants the pitch/stride to cover all rows included
+* in a tile.
+*/
for (i = 0; i < num_strides; ++i)
-   malidp_hw_write(mp->hwdev, pitches[i],
+   malidp_hw_wr

[Bug 108487] Wayland compositors are unable to use hardware acceleration on i915: missing EGL_ANDROID_native_fence_sync extension

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108487

Chris Wilson  changed:

   What|Removed |Added

Summary|Wayland compositors are |Wayland compositors are
   |unable to use hardware  |unable to use hardware
   |acceleration on i915|acceleration on i915:
   ||missing
   ||EGL_ANDROID_native_fence_sy
   ||nc extension

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


Re: [PATCH v5 5/9] drm: Extend framebuffer_check to handle formats with cpp/char_per_block 0

2018-10-19 Thread Brian Starkey

Hi Alex,

On Fri, Oct 19, 2018 at 11:57:48AM +0100, Alexandru Gheorghe wrote:

For formats that are supported only with non-linear modifiers it
doesn't make to much sense to define cpp or char_per_block, so that
will be set to 0.

This patch adds a restriction to force having a modifier attached when
cpp/char_per_block is 0, and to bypass checking the pitch restriction.

This had been discussed here.
[1] 
https://people.freedesktop.org/~cbrill/dri-log/?channel=dri-devel&highlight_names=&date=2018-09-13&show_html=true

Signed-off-by: Alexandru Gheorghe 
---
drivers/gpu/drm/drm_framebuffer.c | 7 ++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_framebuffer.c 
b/drivers/gpu/drm/drm_framebuffer.c
index 6aca8a1ccdb6..e346d0ad92e0 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -195,8 +195,13 @@ static int framebuffer_check(struct drm_device *dev,
for (i = 0; i < info->num_planes; i++) {
unsigned int width = fb_plane_width(r->width, info, i);
unsigned int height = fb_plane_height(r->height, info, i);
+   unsigned int block_size = info->char_per_block[i];
u64 min_pitch = drm_format_info_min_pitch(info, i, width);

+   if (!block_size && (r->modifier[i] == DRM_FORMAT_MOD_LINEAR)) {
+   DRM_DEBUG_KMS("Format requires non-linear modifier for plane 
%d\n", i);
+   return -EINVAL;
+   }


You could probably move that blank like from Patch 2 to here ;-)
Otherwise LGTM:

Reviewed By: Brian Starkey 


if (!r->handles[i]) {
DRM_DEBUG_KMS("no buffer object handle for plane %d\n", 
i);
return -EINVAL;
@@ -208,7 +213,7 @@ static int framebuffer_check(struct drm_device *dev,
if ((uint64_t) height * r->pitches[i] + r->offsets[i] > 
UINT_MAX)
return -ERANGE;

-   if (r->pitches[i] < min_pitch) {
+   if (block_size && r->pitches[i] < min_pitch) {
DRM_DEBUG_KMS("bad pitch %u for plane %d\n", 
r->pitches[i], i);
return -EINVAL;
}
--
2.18.0


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


[Bug 108498] ir_dereference_record nullptr segfault in radeonsi_dri.so

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108498

Michel Dänzer  changed:

   What|Removed |Added

 QA Contact|dri-devel@lists.freedesktop |intel-3d-bugs@lists.freedes
   |.org|ktop.org
  Component|Drivers/Gallium/radeonsi|glsl-compiler
   Assignee|dri-devel@lists.freedesktop |mesa-dev@lists.freedesktop.
   |.org|org

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


Re: [PATCH v2 2/2] drm/i915/intel_dsi: Read back pclk set by GOP and use that as pclk v2

2018-10-19 Thread Hans de Goede

Hi,

On 19-10-18 11:20, Jani Nikula wrote:

On Wed, 17 Oct 2018, Hans de Goede  wrote:

On BYT and CHT the GOP sometimes initializes the pclk at a (slightly)
different frequency then the pclk which we've calculated.

This commit makes the DSI code read-back the pclk set by the GOP and
if that is within a reasonable margin of the calculated pclk, uses
that instead.

This fixes the first modeset being a full modeset instead of a
fast modeset on systems where the GOP pclk is different.


I assume we don't do the fast path because intel_pipe_config_compare()
returns false due to crtc_clock and port_clock mismatch. The dmesg
should tell you the reason with drm.debugs enabled.


As I think I mentioned already last time (but that was a while ago,
so I understand you cannot remember the details), the problem is these
checks from intel_pipe_config_compare():

PIPE_CONF_CHECK_X(dsi_pll.ctrl);
PIPE_CONF_CHECK_X(dsi_pll.div);


Now, the clock checks are already "fuzzy", and should account for slight
variations. I think the goal was the same as here, plus IIUC we may lose
some accuracy on the hardware roundtrip.


The check I quoted above are basically doing a non-fuzzy port_clock check,
we already do a fuzzy port_clock check, so maybe we should just drop them?


Please try adding more tolerance in intel_fuzzy_clock_check() and see if
that helps. The code looks like it allows 5% diff, but it's 2.5%.

Regardless of whether we end up changing the tolerance or adjusting the
state based on the hardware readout or what, I think doing the
adjustment in intel_dsi_vbt.c init is the wrong place. We shouldn't have
anything that depends on accessing the hardware there. I believe that's
what Ville was trying to say in [1].


If you agree with dropping these 2 in essence non-fuzzy port-clock checks:

PIPE_CONF_CHECK_X(dsi_pll.ctrl);
PIPE_CONF_CHECK_X(dsi_pll.div);

Then we won't need this state adjustment.

But in case you do want to keep these, then were should the adjustment be done?

Keep in mind that the pclk is initially calculated in intel_dsi_vbt.c
and then immediately used to calculate a bunch of other settings such as
intel_dsi->lp_byte_clk, prepare_cnt, etc. So there really is no other
place were we can reasonably do this.

Regards,

Hans






BR,
Jani.


[1] http://mid.mail-archive.com/20180706141652.GK5565@intel.com




Changes in v2:
-Use intel_encoder_current_mode() to get the pclk setup by the GOP

Signed-off-by: Hans de Goede 
---
  drivers/gpu/drm/i915/intel_dsi_vbt.c | 18 ++
  1 file changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_dsi_vbt.c 
b/drivers/gpu/drm/i915/intel_dsi_vbt.c
index ac83d6b89ae0..3387b187105c 100644
--- a/drivers/gpu/drm/i915/intel_dsi_vbt.c
+++ b/drivers/gpu/drm/i915/intel_dsi_vbt.c
@@ -506,6 +506,7 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 
panel_id)
struct mipi_config *mipi_config = dev_priv->vbt.dsi.config;
struct mipi_pps_data *pps = dev_priv->vbt.dsi.pps;
struct drm_display_mode *mode = dev_priv->vbt.lfp_lvds_vbt_mode;
+   struct drm_display_mode *curr;
u32 bpp;
u32 tlpx_ns, extra_byte_count, bitrate, tlpx_ui;
u32 ui_num, ui_den;
@@ -583,6 +584,23 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 
panel_id)
} else
burst_mode_ratio = 100;
  
+	/*

+* On BYT / CRC the GOP sometimes picks a slightly different pclk,
+* read back the GOP configured pclk and prefer it over ours.
+*/
+   if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
+   curr = intel_encoder_current_mode(&intel_dsi->base);
+   if (curr) {
+   DRM_DEBUG_KMS("Calculated pclk %d GOP %d\n",
+ pclk, curr->clock);
+   if (curr->clock >= (pclk * 9 / 10) &&
+   curr->clock <= (pclk * 11 / 10))
+   pclk = curr->clock;
+
+   kfree(curr);
+   }
+   }
+
intel_dsi->burst_mode_ratio = burst_mode_ratio;
intel_dsi->pclk = pclk;



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


Re: [PATCH 2/2] drm/panel: Add driver for Samsung S6D16D0 panel

2018-10-19 Thread Linus Walleij
Hi Andrzej,

I was just looking at this (which confused me and was not
fixed in v2):

On Tue, Oct 9, 2018 at 8:46 PM Linus Walleij  wrote:
> On Tue, Oct 9, 2018 at 10:29 AM Andrzej Hajda  wrote:
> > On 08.10.2018 12:58, Linus Walleij wrote:
>
> > > +static const struct drm_display_mode samsung_s6d16d0_mode = {
> > > + .clock = 420160, /* HS 420160kHz, LP 19200kHz */
> > > + .hdisplay = 864,
> > > + .hsync_start = 864 + 154,
> > > + .hsync_end = 864 + 154 + 16,
> > > + .htotal = 864 + 154 + 16 + 32,
> > > + .vdisplay = 480,
> > > + .vsync_start = 480 + 1,
> > > + .vsync_end = 480 + 1 + 1,
> > > + .vtotal = 480 + 1 + 1 + 1,
> > > + .vrefresh = 60,
> > > +};
> >
> > htotal*vtotal*vrefresh should be equal to clock * 1000, even in command
> > mode, and they should be equal to TearingEffect signal frequency.
>
> OK I had no clue. I'll look closer at this. I suspect the .clock is just
> wrong and should instead be based on what you say.

Isn't the case such that the clock we use which will be =< hs_rate
or lp_rate respectively, controls vrefresh?

So actually, the sync cycles are constant, the clock comes from
(usually) the best fit from the clock framework, and then vrefresh
depends on what frequency we get from there, and it will be
considerably lower in lp mode than in hs mode?

It feels a bit silly to return two modes for the display that are
going to be identical depending on whether hs or lp is used,
but in some sense it would be the right thing, but I think then
the display driver needs to be smart enough to identify
that "OK now KMS is asking for HS mode" and "OK now
KMA is asking for LP mode".

Further, switching the display into the "LP mode" should
probably have effects on the host other than just switching to
the LP clock.

I think due to the crudeness of the frameworks graphics of course
comes out as it should but if userspace would do something
creative like starting to inspect the vrefresh it gets and try to
switch modes depending on that, I guess we have a bit of a
problem. I guess currently userspace can't choose between
HS or LP mode anyway, but I guess we should
support that.

I've changed this to clocking matching the HS mode right now
but I feel a bit uncertain as to what the real fix is :/

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


[PATCH v2] drm/atomic: integrate modeset lock with private objects

2018-10-19 Thread Boris Brezillon
From: Rob Clark 

Follow the same pattern of locking as with other state objects. This
avoids boilerplate in the driver.

Signed-off-by: Rob Clark 
Signed-off-by: Boris Brezillon 
---
Changes in v2:
- Make sure all priv objs are locked from drm_modeset_lock_all_ctx().
  This implies adding all priv objs to mode_config.privobj_list, and
  in turn means we have to change the drm_atomic_private_obj_init()
  prototype and pass it a drm_device.
---
 drivers/gpu/drm/drm_atomic.c | 19 +++
 drivers/gpu/drm/drm_dp_mst_topology.c|  2 +-
 drivers/gpu/drm/drm_mode_config.c|  1 +
 drivers/gpu/drm/drm_modeset_lock.c   |  8 
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c |  2 +-
 drivers/gpu/drm/tegra/hub.c  |  2 +-
 drivers/gpu/drm/vc4/vc4_kms.c|  3 ++-
 include/drm/drm_atomic.h | 17 -
 include/drm/drm_mode_config.h|  9 +
 9 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 2870ae205237..0e27d45feba9 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -657,6 +657,7 @@ static void drm_atomic_plane_print_state(struct drm_printer 
*p,
 
 /**
  * drm_atomic_private_obj_init - initialize private object
+ * @dev: DRM device this object will be attached to
  * @obj: private object
  * @state: initial private object state
  * @funcs: pointer to the struct of function pointers that identify the object
@@ -666,14 +667,18 @@ static void drm_atomic_plane_print_state(struct 
drm_printer *p,
  * driver private object that needs its own atomic state.
  */
 void
-drm_atomic_private_obj_init(struct drm_private_obj *obj,
+drm_atomic_private_obj_init(struct drm_device *dev,
+   struct drm_private_obj *obj,
struct drm_private_state *state,
const struct drm_private_state_funcs *funcs)
 {
memset(obj, 0, sizeof(*obj));
 
+   drm_modeset_lock_init(&obj->lock);
+
obj->state = state;
obj->funcs = funcs;
+   list_add_tail(&obj->head, &dev->mode_config.privobj_list);
 }
 EXPORT_SYMBOL(drm_atomic_private_obj_init);
 
@@ -686,7 +691,9 @@ EXPORT_SYMBOL(drm_atomic_private_obj_init);
 void
 drm_atomic_private_obj_fini(struct drm_private_obj *obj)
 {
+   list_del(&obj->head);
obj->funcs->atomic_destroy_state(obj, obj->state);
+   drm_modeset_lock_fini(&obj->lock);
 }
 EXPORT_SYMBOL(drm_atomic_private_obj_fini);
 
@@ -696,8 +703,8 @@ EXPORT_SYMBOL(drm_atomic_private_obj_fini);
  * @obj: private object to get the state for
  *
  * This function returns the private object state for the given private object,
- * allocating the state if needed. It does not grab any locks as the caller is
- * expected to care of any required locking.
+ * allocating the state if needed. It will also grab the relevant private
+ * object lock to make sure that the state is consistent.
  *
  * RETURNS:
  *
@@ -707,7 +714,7 @@ struct drm_private_state *
 drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
 struct drm_private_obj *obj)
 {
-   int index, num_objs, i;
+   int index, num_objs, i, ret;
size_t size;
struct __drm_private_objs_state *arr;
struct drm_private_state *obj_state;
@@ -716,6 +723,10 @@ drm_atomic_get_private_obj_state(struct drm_atomic_state 
*state,
if (obj == state->private_objs[i].ptr)
return state->private_objs[i].state;
 
+   ret = drm_modeset_lock(&obj->lock, state->acquire_ctx);
+   if (ret)
+   return ERR_PTR(ret);
+
num_objs = state->num_private_objs + 1;
size = sizeof(*state->private_objs) * num_objs;
arr = krealloc(state->private_objs, size, GFP_KERNEL);
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index 5ff1d79b86c4..0ab47cd44a20 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3210,7 +3210,7 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
/* max. time slots - one slot for MTP header */
mst_state->avail_slots = 63;
 
-   drm_atomic_private_obj_init(&mgr->base,
+   drm_atomic_private_obj_init(dev, &mgr->base,
&mst_state->base,
&mst_state_funcs);
 
diff --git a/drivers/gpu/drm/drm_mode_config.c 
b/drivers/gpu/drm/drm_mode_config.c
index ee80788f2c40..931523c5bc9d 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -381,6 +381,7 @@ void drm_mode_config_init(struct drm_device *dev)
INIT_LIST_HEAD(&dev->mode_config.property_list);
INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
INIT_LIST_HEAD(&dev->mode_config.plane_list);
+   INIT_LIST_HEAD(&dev->mode_config.pr

[Bug 108487] Wayland compositors are unable to use hardware acceleration on i915: missing EGL_ANDROID_native_fence_sync extension

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108487

--- Comment #1 from Daniel Stone  ---
Chris, how do you make this as missing dma-fence support?

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


[Bug 108487] Wayland compositors are unable to use hardware acceleration on i915: missing EGL_ANDROID_native_fence_sync extension

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108487

--- Comment #2 from Chris Wilson  ---
Just realised I missed the "timeline" part of

[17:35:45.463] warning: Disabling render GPU timeline due to missing
EGL_ANDROID_native_fence_sync extension

(read as "disabling render GPU due to missing extension").

Since it doesn't say why it doesn't create the GL context, that looks like the
easiest warning to fix first.

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


[Bug 108487] Wayland compositors are unable to use hardware acceleration on i915: missing EGL_ANDROID_native_fence_sync extension

2018-10-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108487

--- Comment #3 from Daniel Stone  ---
The fatal bit is probably the GBM surface creation: my guess is that the KMS
driver exposes IN_MODIFIERS so we try to use gbm_surface_create_with_modifiers
and when it fails because i915 Mesa is blissfully unaware, we just tank the
whole setup rather than falling back to no modifiers.

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


Re: [PATCH v2 2/2] drm/i915/intel_dsi: Read back pclk set by GOP and use that as pclk v2

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 03:49:15PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 19-10-18 11:20, Jani Nikula wrote:
> > On Wed, 17 Oct 2018, Hans de Goede  wrote:
> > > On BYT and CHT the GOP sometimes initializes the pclk at a (slightly)
> > > different frequency then the pclk which we've calculated.
> > > 
> > > This commit makes the DSI code read-back the pclk set by the GOP and
> > > if that is within a reasonable margin of the calculated pclk, uses
> > > that instead.
> > > 
> > > This fixes the first modeset being a full modeset instead of a
> > > fast modeset on systems where the GOP pclk is different.
> > 
> > I assume we don't do the fast path because intel_pipe_config_compare()
> > returns false due to crtc_clock and port_clock mismatch. The dmesg
> > should tell you the reason with drm.debugs enabled.
> 
> As I think I mentioned already last time (but that was a while ago,
> so I understand you cannot remember the details), the problem is these
> checks from intel_pipe_config_compare():
> 
> PIPE_CONF_CHECK_X(dsi_pll.ctrl);
> PIPE_CONF_CHECK_X(dsi_pll.div);
> 
> > Now, the clock checks are already "fuzzy", and should account for slight
> > variations. I think the goal was the same as here, plus IIUC we may lose
> > some accuracy on the hardware roundtrip.
> 
> The check I quoted above are basically doing a non-fuzzy port_clock check,
> we already do a fuzzy port_clock check, so maybe we should just drop them?
> 
> > Please try adding more tolerance in intel_fuzzy_clock_check() and see if
> > that helps. The code looks like it allows 5% diff, but it's 2.5%.
> > 
> > Regardless of whether we end up changing the tolerance or adjusting the
> > state based on the hardware readout or what, I think doing the
> > adjustment in intel_dsi_vbt.c init is the wrong place. We shouldn't have
> > anything that depends on accessing the hardware there. I believe that's
> > what Ville was trying to say in [1].
> 
> If you agree with dropping these 2 in essence non-fuzzy port-clock checks:
> 
> PIPE_CONF_CHECK_X(dsi_pll.ctrl);
> PIPE_CONF_CHECK_X(dsi_pll.div);
> 
> Then we won't need this state adjustment.
> 
> But in case you do want to keep these, then were should the adjustment be 
> done?
> 
> Keep in mind that the pclk is initially calculated in intel_dsi_vbt.c
> and then immediately used to calculate a bunch of other settings such as
> intel_dsi->lp_byte_clk, prepare_cnt, etc. So there really is no other
> place were we can reasonably do this.

We still want to do these checks when validating a modeset afterwards, but
for the fuzzy case we need to cut them out indeed. Similar to what we do
for the some of the other fastboot registers already with the if (!adjust)
condition.

I guess the trick here is making sure we pick the right set of registers
... Maybe we want to make all the pll low-level state like that (so both
dsi_pll and dpll_hw_state)?

Cheers, 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 1/3] drm/sched: Add callback to mark if sched is ready to work.

2018-10-19 Thread Grodzovsky, Andrey
Eclipse

Andrey


On 10/19/2018 03:13 AM, Michel Dänzer wrote:
> ... and the new line here.
>
> Which editor are you using?

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


Re: [PATCH 3/3] drm/amdgpu: Refresh rq selection for job after ASIC reset

2018-10-19 Thread Grodzovsky, Andrey


On 10/19/2018 03:08 AM, Koenig, Christian wrote:
> Am 18.10.18 um 20:44 schrieb Andrey Grodzovsky:
>> A ring might become unusable after reset, if that the case
>> drm_sched_entity_select_rq will choose another, working rq
>> to run the job if there is one.
>> Also, skip recovery of ring which is not ready.
> Well that is not even remotely sufficient.
>
> If we can't bring up a ring any more after a reset we would need to move
> all jobs which where previously scheduled on it and all of its entities
> to a different instance.

That one should be easy to add inside amdgpu_device_gpu_recover in case
ring is dead, we just do the same for all the jobs in 
sched->ring_mirror_list of the dead ring
before doing recovery for them, no?
>
> What you do here breaks dependencies between jobs and can result in
> unforeseen consequences including random memory writes.

Can you explain this a bit more ? AFAIK any job dependent on this job 
will still wait for it's completion
before running regardless of did this job moved to a different ring. 
What am I missing ?
>
> As far as I can see that can't be done correctly with the current
> scheduler design.
>
> Additional to that when we can't restart one instance of a ring we
> usually can't restart all others either. So the whole approach is rather
> pointless.

 From my testing looks like we can, compute ring 0 is dead but IB tests 
pass on other compute rings.

Andrey

>
> Regards,
> Christian.
>
>> Signed-off-by: Andrey Grodzovsky 
>> ---
>>drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++-
>>1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> index d11489e..3124ca1 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> @@ -3355,10 +3355,24 @@ int amdgpu_device_gpu_recover(struct amdgpu_device 
>> *adev,
>>  else
>>  r = amdgpu_device_reset(adev);
>>
>> +/*
>> + * After reboot a ring might fail in which case this will
>> + * move the job to different rq if possible
>> + */
>> +if (job) {
>> +drm_sched_entity_select_rq(job->base.entity);
>> +if (job->base.entity->rq) {
>> +job->base.sched = job->base.entity->rq->sched;
>> +} else {
>> +job->base.sched = NULL;
>> +r = -ENOENT;
>> +}
>> +}
>> +
>>  for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
>>  struct amdgpu_ring *ring = adev->rings[i];
>>
>> -if (!ring || !ring->sched.thread)
>> +if (!ring || !ring->ready || !ring->sched.thread)
>>  continue;
>>
>>  /* only need recovery sched of the given job's ring
> ___
> 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 v2] drm/atomic: integrate modeset lock with private objects

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 03:55:03PM +0200, Boris Brezillon wrote:
> From: Rob Clark 
> 
> Follow the same pattern of locking as with other state objects. This
> avoids boilerplate in the driver.
> 
> Signed-off-by: Rob Clark 
> Signed-off-by: Boris Brezillon 
> ---
> Changes in v2:
> - Make sure all priv objs are locked from drm_modeset_lock_all_ctx().
>   This implies adding all priv objs to mode_config.privobj_list, and
>   in turn means we have to change the drm_atomic_private_obj_init()
>   prototype and pass it a drm_device.
> ---
>  drivers/gpu/drm/drm_atomic.c | 19 +++
>  drivers/gpu/drm/drm_dp_mst_topology.c|  2 +-
>  drivers/gpu/drm/drm_mode_config.c|  1 +
>  drivers/gpu/drm/drm_modeset_lock.c   |  8 
>  drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c |  2 +-
>  drivers/gpu/drm/tegra/hub.c  |  2 +-
>  drivers/gpu/drm/vc4/vc4_kms.c|  3 ++-
>  include/drm/drm_atomic.h | 17 -
>  include/drm/drm_mode_config.h|  9 +
>  9 files changed, 54 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 2870ae205237..0e27d45feba9 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -657,6 +657,7 @@ static void drm_atomic_plane_print_state(struct 
> drm_printer *p,
>  
>  /**
>   * drm_atomic_private_obj_init - initialize private object
> + * @dev: DRM device this object will be attached to
>   * @obj: private object
>   * @state: initial private object state
>   * @funcs: pointer to the struct of function pointers that identify the 
> object
> @@ -666,14 +667,18 @@ static void drm_atomic_plane_print_state(struct 
> drm_printer *p,
>   * driver private object that needs its own atomic state.
>   */
>  void
> -drm_atomic_private_obj_init(struct drm_private_obj *obj,
> +drm_atomic_private_obj_init(struct drm_device *dev,
> + struct drm_private_obj *obj,
>   struct drm_private_state *state,
>   const struct drm_private_state_funcs *funcs)
>  {
>   memset(obj, 0, sizeof(*obj));
>  
> + drm_modeset_lock_init(&obj->lock);
> +
>   obj->state = state;
>   obj->funcs = funcs;
> + list_add_tail(&obj->head, &dev->mode_config.privobj_list);
>  }
>  EXPORT_SYMBOL(drm_atomic_private_obj_init);
>  
> @@ -686,7 +691,9 @@ EXPORT_SYMBOL(drm_atomic_private_obj_init);
>  void
>  drm_atomic_private_obj_fini(struct drm_private_obj *obj)
>  {
> + list_del(&obj->head);
>   obj->funcs->atomic_destroy_state(obj, obj->state);
> + drm_modeset_lock_fini(&obj->lock);
>  }
>  EXPORT_SYMBOL(drm_atomic_private_obj_fini);
>  
> @@ -696,8 +703,8 @@ EXPORT_SYMBOL(drm_atomic_private_obj_fini);
>   * @obj: private object to get the state for
>   *
>   * This function returns the private object state for the given private 
> object,
> - * allocating the state if needed. It does not grab any locks as the caller 
> is
> - * expected to care of any required locking.
> + * allocating the state if needed. It will also grab the relevant private
> + * object lock to make sure that the state is consistent.
>   *
>   * RETURNS:
>   *
> @@ -707,7 +714,7 @@ struct drm_private_state *
>  drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
>struct drm_private_obj *obj)
>  {
> - int index, num_objs, i;
> + int index, num_objs, i, ret;
>   size_t size;
>   struct __drm_private_objs_state *arr;
>   struct drm_private_state *obj_state;
> @@ -716,6 +723,10 @@ drm_atomic_get_private_obj_state(struct drm_atomic_state 
> *state,
>   if (obj == state->private_objs[i].ptr)
>   return state->private_objs[i].state;
>  
> + ret = drm_modeset_lock(&obj->lock, state->acquire_ctx);
> + if (ret)
> + return ERR_PTR(ret);
> +
>   num_objs = state->num_private_objs + 1;
>   size = sizeof(*state->private_objs) * num_objs;
>   arr = krealloc(state->private_objs, size, GFP_KERNEL);
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 5ff1d79b86c4..0ab47cd44a20 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -3210,7 +3210,7 @@ int drm_dp_mst_topology_mgr_init(struct 
> drm_dp_mst_topology_mgr *mgr,
>   /* max. time slots - one slot for MTP header */
>   mst_state->avail_slots = 63;
>  
> - drm_atomic_private_obj_init(&mgr->base,
> + drm_atomic_private_obj_init(dev, &mgr->base,
>   &mst_state->base,
>   &mst_state_funcs);
>  
> diff --git a/drivers/gpu/drm/drm_mode_config.c 
> b/drivers/gpu/drm/drm_mode_config.c
> index ee80788f2c40..931523c5bc9d 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -381,6 +381,7 @@ void drm_m

Re: [PATCH v5 8/9] drm/selftest: Refactor test-drm_plane_helper

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 11:57:51AM +0100, Alexandru Gheorghe wrote:
> The idea is to split test implementations in different compilation
> units, but have one single place where we define the list of tests,
> in this case(drm_modeset_selftests.h).
> 
> Signed-off-by: Alexandru Gheorghe 
> ---
>  ...er_selftests.h => drm_modeset_selftests.h} |  0
>  .../drm/selftests/test-drm_modeset_common.c   | 11 ++-
>  .../drm/selftests/test-drm_modeset_common.h   |  2 +-
>  .../gpu/drm/selftests/test-drm_plane_helper.c | 19 +--
>  4 files changed, 12 insertions(+), 20 deletions(-)
>  rename drivers/gpu/drm/selftests/{drm_plane_helper_selftests.h => 
> drm_modeset_selftests.h} (100%)
> 
> diff --git a/drivers/gpu/drm/selftests/drm_plane_helper_selftests.h 
> b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
> similarity index 100%
> rename from drivers/gpu/drm/selftests/drm_plane_helper_selftests.h
> rename to drivers/gpu/drm/selftests/drm_modeset_selftests.h
> diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.c 
> b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
> index fad5209043f1..2a7f93774006 100644
> --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.c
> +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
> @@ -7,9 +7,18 @@
>  
>  #include "test-drm_modeset_common.h"
>  
> +#define TESTS "drm_modeset_selftests.h"
> +#include "drm_selftest.h"
> +
> +#include "drm_selftest.c"
> +
>  static int __init test_drm_modeset_init(void)
>  {
> - return test_drm_plane_helper();
> + int err;
> +
> + err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
> +
> + return err > 0 ? 0 : err;
>  }
>  
>  static void __exit test_drm_modeset_exit(void)
> diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h 
> b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
> index bdeba264661f..b0065a2eb067 100644
> --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
> +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
> @@ -13,6 +13,6 @@
>  
>  #define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
>  
> -int test_drm_plane_helper(void);
> +int igt_check_plane_state(void *ignored);

I wonder whether we can't do some macro trickery to also generate these
here from the selftest.h file. But that's probably for when we're drowning
in these, which we're definitely not yet :-)

Reviewed-by: Daniel Vetter 

>  
>  #endif
> diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c 
> b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> index 0dad2f812a27..0a9553f51796 100644
> --- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> +++ b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> @@ -11,9 +11,6 @@
>  
>  #include "test-drm_modeset_common.h"
>  
> -#define TESTS "drm_plane_helper_selftests.h"
> -#include "drm_selftest.h"
> -
>  static void set_src(struct drm_plane_state *plane_state,
>   unsigned src_x, unsigned src_y,
>   unsigned src_w, unsigned src_h)
> @@ -76,7 +73,7 @@ static bool check_crtc_eq(struct drm_plane_state 
> *plane_state,
>   return true;
>  }
>  
> -static int igt_check_plane_state(void *ignored)
> +int igt_check_plane_state(void *ignored)

>  {
>   int ret;
>  
> @@ -220,17 +217,3 @@ static int igt_check_plane_state(void *ignored)
>  
>   return 0;
>  }
> -
> -#include "drm_selftest.c"
> -
> -/**
> - * test_drm_plane_helper - Run drm plane helper selftests.
> - */
> -int test_drm_plane_helper(void)
> -{
> - int err;
> -
> - err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
> -
> - return err > 0 ? 0 : err;
> -}
> -- 
> 2.18.0
> 

-- 
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 9/9] drm/selftests: Add tests for drm_format_info* helpers

2018-10-19 Thread Daniel Vetter
On Fri, Oct 19, 2018 at 11:57:52AM +0100, Alexandru Gheorghe wrote:
> Add selftests for the following newly added functions:
>  - drm_format_info_block_width
>  - drm_format_info_block_height
>  - drm_format_info_min_pitch
> 
> Signed-off-by: Alexandru Gheorghe 
> ---
>  drivers/gpu/drm/selftests/Makefile|   3 +-
>  .../gpu/drm/selftests/drm_modeset_selftests.h |   3 +
>  drivers/gpu/drm/selftests/test-drm_format.c   | 290 ++
>  .../drm/selftests/test-drm_modeset_common.h   |   3 +
>  4 files changed, 298 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/gpu/drm/selftests/test-drm_format.c
> 
> diff --git a/drivers/gpu/drm/selftests/Makefile 
> b/drivers/gpu/drm/selftests/Makefile
> index 7e6581921da0..07b4f88b422a 100644
> --- a/drivers/gpu/drm/selftests/Makefile
> +++ b/drivers/gpu/drm/selftests/Makefile
> @@ -1,3 +1,4 @@
> -test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o
> +test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o \
> +  test-drm_format.o
>  
>  obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o
> diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h 
> b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
> index 9771290ed228..4e203ac8c134 100644
> --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h
> +++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
> @@ -7,3 +7,6 @@
>   * Tests are executed in order by igt/drm_selftests_helper
>   */
>  selftest(check_plane_state, igt_check_plane_state)
> +selftest(check_drm_format_block_width, igt_check_drm_format_block_width)
> +selftest(check_drm_format_block_height, igt_check_drm_format_block_height)
> +selftest(check_drm_format_min_pitch, igt_check_drm_format_min_pitch)
> diff --git a/drivers/gpu/drm/selftests/test-drm_format.c 
> b/drivers/gpu/drm/selftests/test-drm_format.c
> new file mode 100644
> index ..5abfd5e28d7d
> --- /dev/null
> +++ b/drivers/gpu/drm/selftests/test-drm_format.c
> @@ -0,0 +1,290 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Test cases for the drm_format functions
> + */
> +
> +#define pr_fmt(fmt) "drm_format: " fmt
> +
> +#include 
> +#include 
> +
> +#include 
> +
> +#include "test-drm_modeset_common.h"
> +
> +int igt_check_drm_format_block_width(void *ignored)
> +{
> + const struct drm_format_info *info = NULL;
> +
> + /* Test invalid arguments */
> + FAIL_ON(drm_format_info_block_width(info, 0) != 0);
> + FAIL_ON(drm_format_info_block_width(info, -1) != 0);
> + FAIL_ON(drm_format_info_block_width(info, 1) != 0);
> +
> + /* Test 1 plane format */
> + info = drm_format_info(DRM_FORMAT_XRGB);
> + FAIL_ON(!info);
> + FAIL_ON(drm_format_info_block_width(info, 0) != 1);
> + FAIL_ON(drm_format_info_block_width(info, 1) != 0);
> + FAIL_ON(drm_format_info_block_width(info, -1) != 0);
> +
> + /* Test 2 planes format */
> + info = drm_format_info(DRM_FORMAT_NV12);
> + FAIL_ON(!info);
> + FAIL_ON(drm_format_info_block_width(info, 0) != 1);
> + FAIL_ON(drm_format_info_block_width(info, 1) != 1);
> + FAIL_ON(drm_format_info_block_width(info, 2) != 0);
> + FAIL_ON(drm_format_info_block_width(info, -1) != 0);
> +
> + /* Test 3 planes format */
> + info = drm_format_info(DRM_FORMAT_YUV422);
> + FAIL_ON(!info);
> + FAIL_ON(drm_format_info_block_width(info, 0) != 1);
> + FAIL_ON(drm_format_info_block_width(info, 1) != 1);
> + FAIL_ON(drm_format_info_block_width(info, 2) != 1);
> + FAIL_ON(drm_format_info_block_width(info, 3) != 0);
> + FAIL_ON(drm_format_info_block_width(info, -1) != 0);
> +
> + /* Test a tiled format */
> + info = drm_format_info(DRM_FORMAT_X0L0);
> + FAIL_ON(!info);
> + FAIL_ON(drm_format_info_block_width(info, 0) != 2);
> + FAIL_ON(drm_format_info_block_width(info, 1) != 0);
> + FAIL_ON(drm_format_info_block_width(info, -1) != 0);
> +
> + return 0;
> +}
> +
> +int igt_check_drm_format_block_height(void *ignored)
> +{
> + const struct drm_format_info *info = NULL;
> +
> + /* Test invalid arguments */
> + FAIL_ON(drm_format_info_block_height(info, 0) != 0);
> + FAIL_ON(drm_format_info_block_height(info, -1) != 0);
> + FAIL_ON(drm_format_info_block_height(info, 1) != 0);
> +
> + /* Test 1 plane format */
> + info = drm_format_info(DRM_FORMAT_XRGB);
> + FAIL_ON(!info);
> + FAIL_ON(drm_format_info_block_height(info, 0) != 1);
> + FAIL_ON(drm_format_info_block_height(info, 1) != 0);
> + FAIL_ON(drm_format_info_block_height(info, -1) != 0);
> +
> + /* Test 2 planes format */
> + info = drm_format_info(DRM_FORMAT_NV12);
> + FAIL_ON(!info);
> + FAIL_ON(drm_format_info_block_height(info, 0) != 1);
> + FAIL_ON(drm_format_info_block_height(info, 1) != 1);
> + FAIL_ON(drm_format_info_block_height(info, 2) != 0);
> + FAIL_ON(drm_format_info_block_height(info, -1) != 0);
> +

  1   2   >