linux-next: build failure after merge of the drm tree
Subsystems (4)
Hi all,
After merging the drm tree, today's linux-next build (x86_64 allmodconfig) failed like this:
drivers/gpu/drm/ingenic/ingenic-drm-drv.c: In function 'ingenic_drm_sync_data':drivers/gpu/drm/ingenic/ingenic-drm-drv.c:478:4: error: implicit declaration of function 'dma_cache_sync'; did you mean 'regcache_sync'? [-Werror=implicit-function-declaration]
478 | dma_cache_sync(priv->dev, addr + offset,
| ^~~~~~~~~~~~~~
| regcache_sync
drivers/gpu/drm/ingenic/ingenic-drm-drv.c: In function 'ingenic_drm_gem_mmap':
drivers/gpu/drm/ingenic/ingenic-drm-drv.c:671:11: error: 'DMA_ATTR_NON_CONSISTENT' undeclared (first use in this function)
671 | attrs = DMA_ATTR_NON_CONSISTENT;
| ^~~~~~~~~~~~~~~~~~~~~~~drivers/gpu/drm/ingenic/ingenic-drm-drv.c:671:11: note: each undeclared identifier is reported only once for each function it appears in
Caused by commit
37054fc81443 ("gpu/drm: ingenic: Add option to mmap GEM buffers cached")
interacting with commits
5a8429227140 ("dma-mapping: remove dma_cache_sync") efa70f2fdc84 ("dma-mapping: add a new dma_alloc_pages API")
from the dma-mapping tree.
Its not immediately obvious how to fix this up, so I have just marked CONFIG_DRM_INGENIC as BROKEN until a fix up is provided.
Signature · 2 lines
Cheers, Stephen Rothwell
Quoted 4 lines · Stephen Rothwell
Hi all,
After merging the drm tree, today's linux-next build (
x86_64allmodconfig) failed like this:
The driver needs to switch do dma_alloc_noncoherent + dma_sync_single* like the other drivers converted in the dma tree. Paul, let me know if you have any questions.
Dave Airlie
maintainerQuoted 10 lines · Christoph Hellwig
Quoted 4 lines · Stephen Rothwell
Hi all,
After merging the drm tree, today's linux-next build (
x86_64allmodconfig) failed like this:The driver needs to switch do
dma_alloc_noncoherent+ dma_sync_single* like the other drivers converted in the dma tree. Paul, let me know if you have any questions.
Is this possible in drm-next now (it's 5.9.0-rc5 based)?
or will I need to get a stable shared git tree that goes into drm-next and you send to Linus early in the MR?
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Dave Airlie
Is this possible in drm-next now (it's 5.9.0-rc5 based)?
or will I need to get a stable shared git tree that goes into drm-next and you send to Linus early in the MR?
I think we'll need a stable branch. Let me help Paul with the
conversion first, and once we are done I'll create a shared branch.
Paul Cercueil
maintainerHi Christoph,
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Stephen Rothwell
Hi all,
After merging the drm tree, today's linux-next build (
x86_64
allmodconfig)
failed like this:The driver needs to switch do
dma_alloc_noncoherent+ dma_sync_single* like the other drivers converted in the dma tree. Paul, let me know if you have any questions.
I don't dma_alloc* anything, DRM core does. I use the DMA_ATTR_NON_CONSISTENT attr with dma_mmap_attrs(). Is there a replacement for that?
-Paul
Quoted 10 lines · Paul Cercueil
Hi Christoph,
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Stephen Rothwell
Hi all,
After merging the drm tree, today's linux-next build (
x86_64
allmodconfig)
failed like this:
Quoted 7 lines
Quoted 3 lines
The driver needs to switch do
dma_alloc_noncoherent+ dma_sync_single* like the other drivers converted in the dma tree. Paul, let me know if you have any questions.I don't dma_alloc* anything, DRM core does. I use the
DMA_ATTR_NON_CONSISTENTattr withdma_mmap_attrs(). Is there a replacement for that?
dma_mmap_attrs can only be used on allocations from dma_mmap_attrs with the same attrs. As there is no allocation using DMA_ATTR_NON_CONSISTENT in the drm core, something looks very fishy here.
Where does the allocation you try to mmap come from? All the allocations in drivers/gpu/drm/drm_gem_cma_helper.c seems to use dma_alloc_wc (aka dma_allloc_attrs with the DMA_ATTR_WRITE_COMBINE flag).
Paul Cercueil
maintainerQuoted 18 lines · Christoph Hellwig
Quoted 17 lines · Paul Cercueil
Hi Christoph,
Le lun. 28 sept. 2020 à 8:04, Christoph Hellwig <[email protected]> a
écrit :Quoted 12 lines · Stephen Rothwell
Quoted 5 lines
Hi all,
After merging the drm tree, today's linux-next build (
x86_64
allmodconfig)
failed like this:The driver needs to switch do
dma_alloc_noncoherent+
dma_sync_single*
like the other drivers converted in the dma tree. Paul, let me
know if
you have any questions.
Quoted 8 lines
Quoted 4 lines
I don't dma_alloc* anything, DRM core does. I use the
DMA_ATTR_NON_CONSISTENTattr withdma_mmap_attrs(). Is there a
replacement
for that?
dma_mmap_attrscan only be used on allocations fromdma_mmap_attrswith the same attrs. As there is no allocation usingDMA_ATTR_NON_CONSISTENTin the drm core, something looks very fishy here.
Is that a fact? I don't see why you couldn't change the cache settings after allocation. In practice it works just fine.
Quoted 3 lines
Where does the allocation you try to mmap come from? All the allocations in
drivers/gpu/drm/drm_gem_cma_helper.cseems to usedma_alloc_wc(akadma_allloc_attrswith theDMA_ATTR_WRITE_COMBINEflag).
It's the dma_alloc_wc.
-Paul
Quoted 6 lines · Paul Cercueil
Quoted 3 lines
dma_mmap_attrscan only be used on allocations fromdma_mmap_attrswith the same attrs. As there is no allocation usingDMA_ATTR_NON_CONSISTENTin the drm core, something looks very fishy here.Is that a fact? I don't see why you couldn't change the cache settings after allocation. In practice it works just fine.
Accessing the same physical address using different caching attributes is undefined behavior and fairly dangerous on most architectures, and thus not supported by the DMA API.
Paul Cercueil
maintainerQuoted 7 lines · Christoph Hellwig
Quoted 6 lines · Paul Cercueil
Quoted 5 lines
dma_mmap_attrscan only be used on allocations fromdma_mmap_attrs
with
the same attrs. As there is no allocation usingDMA_ATTR_NON_CONSISTENT
in the drm core, something looks very fishy here.
Quoted 7 lines
Quoted 3 lines
Is that a fact? I don't see why you couldn't change the cache
settings
after allocation. In practice it works just fine.Accessing the same physical address using different caching attributes is undefined behavior and fairly dangerous on most architectures, and thus not supported by the DMA API.
It's allocated with dma_alloc_wc, but then it's only accessed as non-coherent.
Anyway, for the time being I guess you could revert 37054fc81443. But I have patches on top of it in drm-misc-next so it's going to be a mess.
If we have time I can come up with a custom dumb_create() fonction, to make sure that the GEM buffers are allocated with dma_alloc_noncoherent(). Is there a dma_mmap_noncoherent() too?
-Paul
Quoted 9 lines · Paul Cercueil
It's allocated with
dma_alloc_wc, but then it's only accessed as non-coherent.Anyway, for the time being I guess you could revert
37054fc81443. But I have patches on top of it in drm-misc-next so it's going to be a mess.If we have time I can come up with a custom
dumb_create()fonction, to make sure that the GEM buffers are allocated withdma_alloc_noncoherent(). Is there adma_mmap_noncoherent()too?
Please use the lower-level dma_alloc_pages and then just insert the pages directly using remap_pfn_range. Although it might make sense to eventually create a wrapper around remap_pfn_range for all the vma sizing sanity checks.
Quoted 3 lines
-Paul
---end quoted text---
Paul Cercueil
maintainerHi Christoph,
Quoted 15 lines · Christoph Hellwig
Quoted 8 lines · Paul Cercueil
It's allocated with
dma_alloc_wc, but then it's only accessed as non-coherent.Anyway, for the time being I guess you could revert
37054fc81443.
But I
have patches on top of it in drm-misc-next so it's going to be a
mess.Quoted 5 lines
If we have time I can come up with a custom
dumb_create()fonction,
to make
sure that the GEM buffers are allocated withdma_alloc_noncoherent(). Is
there adma_mmap_noncoherent()too?
Quoted 4 lines
Please use the lower-level
dma_alloc_pagesand then just insert the pages directly usingremap_pfn_range. Although it might make sense to eventually create a wrapper aroundremap_pfn_rangefor all the vma sizing sanity checks.
One thing missing for remap_pfn_range(), I have no alternative for this:
vma->vm_page_prot = dma_pgprot(dev, vma->vm_page_prot, DMA_ATTR_NON_CONSISTENT);
So I have to do:
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); pgprot_val(vma->vm_page_prot) &= ~_CACHE_MASK; pgprot_val(vma->vm_page_prot) |= _CACHE_CACHABLE_NONCOHERENT;
And that will only compile on MIPS, because these _CACHE_* macros are only defined there.
I would need something like a pgprot_noncoherent(), I think.
-Paul
Quoted 7 lines · Paul Cercueil
One thing missing for
remap_pfn_range(), I have no alternative for this:
vma->vm_page_prot=dma_pgprot(dev, vma->vm_page_prot, DMA_ATTR_NON_CONSISTENT);So I have to do:
Quoted 8 lines
vma->vm_page_prot=pgprot_noncached(vma->vm_page_prot);pgprot_val(vma->vm_page_prot)&= ~_CACHE_MASK;pgprot_val(vma->vm_page_prot)|=_CACHE_CACHABLE_NONCOHERENT;And that will only compile on MIPS, because these _CACHE_* macros are only defined there.
I would need something like a
pgprot_noncoherent(), I think.
dma_alloc_pages gives you cached memory, so you can't just use an uncached protection for the userspace mmap here. If you want uncached memory you need to use dma_alloc_coherent paired with dma_mmap_coherent. Or dma_alloc_wc for a slightly different flavor of uncached. (both of the map to dma_alloc_attrs / dma_mmap_attrs eventually).
Paul Cercueil
maintainerQuoted 17 lines · Christoph Hellwig
Quoted 16 lines · Paul Cercueil
One thing missing for
remap_pfn_range(), I have no alternative for
this:
vma->vm_page_prot=dma_pgprot(dev, vma->vm_page_prot, DMA_ATTR_NON_CONSISTENT);So I have to do:
vma->vm_page_prot=pgprot_noncached(vma->vm_page_prot);pgprot_val(vma->vm_page_prot)&= ~_CACHE_MASK;pgprot_val(vma->vm_page_prot)|=_CACHE_CACHABLE_NONCOHERENT;And that will only compile on MIPS, because these _CACHE_* macros
are only
defined there.
Quoted 7 lines
Quoted 1 line
I would need something like a
pgprot_noncoherent(), I think.
dma_alloc_pagesgives you cached memory, so you can't just use an uncached protection for the userspace mmap here. If you want uncached memory you need to usedma_alloc_coherentpaired withdma_mmap_coherent. Ordma_alloc_wcfor a slightly different flavor of uncached. (both of the map todma_alloc_attrs/dma_mmap_attrseventually).
I don't want uncached memory, I want non-coherent cached memory.
-Paul
Quoted 7 lines · Paul Cercueil
Quoted 5 lines
dma_alloc_pagesgives you cached memory, so you can't just use an uncached protection for the userspace mmap here. If you want uncached memory you need to usedma_alloc_coherentpaired withdma_mmap_coherent. Ordma_alloc_wcfor a slightly different flavor of uncached. (both of the map todma_alloc_attrs/dma_mmap_attrseventually).I don't want uncached memory, I want non-coherent cached memory.
We don't have such a thing in the Linux API at all.
Paul Cercueil
maintainerQuoted 9 lines · Christoph Hellwig
Quoted 8 lines · Paul Cercueil
Quoted 7 lines
dma_alloc_pagesgives you cached memory, so you can't just use an uncached protection for the userspace mmap here. If you want
uncached
memory you need to usedma_alloc_coherentpaired withdma_mmap_coherent.
Ordma_alloc_wcfor a slightly different flavor of uncached. (both of the map todma_alloc_attrs/dma_mmap_attrseventually).
Quoted 3 lines
Quoted 1 line
I don't want uncached memory, I want non-coherent cached memory.
We don't have such a thing in the Linux API at all.
dma_pgprot(dev, vma->vm_page_prot, DMA_ATTR_NON_CONSISTENT);
That was giving me non-coherent cached memory, and now I don't have an alternative.
-Paul
Quoted 6 lines · Paul Cercueil
Quoted 1 line
We don't have such a thing in the Linux API at all.
dma_pgprot(dev, vma->vm_page_prot, DMA_ATTR_NON_CONSISTENT);That was giving me non-coherent cached memory, and now I don't have an alternative.
Looking at Linux 5.9-rc dma_pgprot is defined as:
pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs)
{
if (force_dma_unencrypted(dev))
prot = pgprot_decrypted(prot);
if (dev_is_dma_coherent(dev) ||
(IS_ENABLED(CONFIG_DMA_NONCOHERENT_CACHE_SYNC) &&
(attrs & DMA_ATTR_NON_CONSISTENT)))
return prot;
#ifdef CONFIG_ARCH_HAS_DMA_WRITE_COMBINE
if (attrs & DMA_ATTR_WRITE_COMBINE)
return pgprot_writecombine(prot);
#endif
return pgprot_dmacoherent(prot);
}so it doesn't change vma->vm_page_prot at all.
The only place that uses _CACHE_CACHABLE_NONCOHERENT is the MIPS specific kmap_noncoherent which ha sa single caller that doesn't leak anywhere into driver code.
Paul Cercueil
maintainerPATCH 1/3 drm: Add and export function drm_gem_cma_create_noalloc
Add and export the function drm_gem_cma_create_noalloc(), which is just __drm_gem_cma_create() renamed.
This function can be used by drivers that need to create a GEM object without allocating the backing memory.
--- drivers/gpu/drm/drm_gem_cma_helper.c | 11 ++++++----- include/drm/drm_gem_cma_helper.h | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_gem_cma_helper.c +6 -5
@@ -34,7 +34,7 @@*/ /** -* __drm_gem_cma_create - Create a GEM CMA object without allocating memory +* drm_gem_cma_create_noalloc - Create a GEM CMA object without allocating memory * @drm: DRM device * @size: size of the object to allocate *
@@ -45,8 +45,8 @@* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative * error code on failure. */ -static struct drm_gem_cma_object * -__drm_gem_cma_create (struct drm_device *drm,size_t size) +struct drm_gem_cma_object * +drm_gem_cma_create_noalloc (struct drm_device *drm,size_t size) {struct drm_gem_cma_object *cma_obj;struct drm_gem_object *gem_obj;
@@ -76,6 +76,7 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)kfree (cma_obj);return ERR_PTR (ret); } +EXPORT_SYMBOL_GPL (drm_gem_cma_create_noalloc);/** * drm_gem_cma_create - allocate an object with the given size
@@ -98,7 +99,7 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, size =round_up (size,PAGE_SIZE ); - cma_obj =__drm_gem_cma_create (drm, size); + cma_obj =drm_gem_cma_create_noalloc (drm, size);if (IS_ERR (cma_obj))return cma_obj;
@@ -476,7 +477,7 @@ drm_gem_cma_prime_import_sg_table(struct drm_device *dev,return ERR_PTR (-EINVAL );/* Create a CMA GEM buffer. */ - cma_obj =__drm_gem_cma_create (dev, attach->dmabuf->size); + cma_obj =drm_gem_cma_create_noalloc (dev, attach->dmabuf->size);if (IS_ERR (cma_obj))return ERR_CAST (cma_obj);
include/drm/drm_gem_cma_helper.h +3 -0
@@ -83,6 +83,9 @@ int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma);struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm,size_t size); +struct drm_gem_cma_object * +drm_gem_cma_create_noalloc (struct drm_device *drm,size_t size); +extern const struct vm_operations_struct drm_gem_cma_vm_ops;#ifndef CONFIG_MMU
Signature · 1 line
2.28.0
Re: [PATCH 1/3] drm: Add and export function drm_gem_cma_create_noalloc
Quoted 37 lines · Paul Cercueil
Add and export the function
drm_gem_cma_create_noalloc(), which is just__drm_gem_cma_create()renamed.This function can be used by drivers that need to create a GEM object without allocating the backing memory.
Signed-off-by Paul Cercueil <[email protected]>--- drivers/gpu/drm/drm_gem_cma_helper.c | 11 ++++++----- include/drm/drm_gem_cma_helper.h | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_gem_cma_helper.c +3
-3@@ -34,7 +34,7 @@*/ /** -* __drm_gem_cma_create - Create a GEM CMA object without allocating memory +* drm_gem_cma_create_noalloc - Create a GEM CMA object without allocating memory * @drm: DRM device * @size: size of the object to allocate * @@ -45,8 +45,8 @@* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative * error code on failure. */ -static struct drm_gem_cma_object * -__drm_gem_cma_create (struct drm_device *drm,size_t size) +struct drm_gem_cma_object * +drm_gem_cma_create_noalloc (struct drm_device *drm,size_t size) {struct drm_gem_cma_object *cma_obj;struct drm_gem_object *gem_obj;
drivers/gpu/drm/drm_gem_cma_helper.c __drm_gem_cma_create(struct drm_device *drm, size_t size) · line 79
Quoted 4 lines
drivers/gpu/drm/drm_gem_cma_helper.c +1
-0@@ -76,6 +76,7 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)kfree (cma_obj);return ERR_PTR (ret); } +EXPORT_SYMBOL_GPL (drm_gem_cma_create_noalloc);
This feels a bit awkward, since for drivers who want to roll their own we can do that already.
I think the better approach is to export a cma function which allocates non-coherent dma memory.
-Daniel
Quoted 42 lines
drivers/gpu/drm/drm_gem_cma_helper.c +2
-2/** * drm_gem_cma_create - allocate an object with the given size @@ -98,7 +99,7 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, size =round_up (size,PAGE_SIZE ); - cma_obj =__drm_gem_cma_create (drm, size); + cma_obj =drm_gem_cma_create_noalloc (drm, size);if (IS_ERR (cma_obj))return cma_obj;@@ -476,7 +477,7 @@ drm_gem_cma_prime_import_sg_table(struct drm_device *dev,return ERR_PTR (-EINVAL );/* Create a CMA GEM buffer. */ - cma_obj =__drm_gem_cma_create (dev, attach->dmabuf->size); + cma_obj =drm_gem_cma_create_noalloc (dev, attach->dmabuf->size);if (IS_ERR (cma_obj))return ERR_CAST (cma_obj);include/drm/drm_gem_cma_helper.h +3
-0@@ -83,6 +83,9 @@ int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma);struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm,size_t size); +struct drm_gem_cma_object * +drm_gem_cma_create_noalloc (struct drm_device *drm,size_t size); +extern const struct vm_operations_struct drm_gem_cma_vm_ops;#ifndef CONFIG_MMU Signature · 6 lines
2.28.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Paul Cercueil
maintainerPATCH 2/3 drm/ingenic: Update code to mmap GEM buffers cached
In reply to Christoph HellwigThe DMA API changed at the same time commit 37054fc81443 ("gpu/drm:
ingenic: Add option to mmap GEM buffers cached") was added. Rework the code to work with the new DMA API.
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 24 +++++++---------------- 1 file changed, 7 insertions(+), 17 deletions(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +7 -17
@@ -526,12 +526,10 @@ void ingenic_drm_sync_data(struct device *dev, struct drm_plane_state *state) {const struct drm_format_info *finfo = state->fb->format; -struct ingenic_drm *priv =dev_get_drvdata (dev);struct drm_atomic_helper_damage_iter iter;unsigned int offset, i;struct drm_rect clip;dma_addr_t paddr; -void *addr;if (!ingenic_drm_cached_gem_buf)return ;
@@ -541,12 +539,11 @@ void ingenic_drm_sync_data(struct device *dev,drm_atomic_for_each_plane_damage (&iter, &clip) {for (i =0 ; i < finfo->num_planes; i++) { paddr =drm_fb_cma_get_gem_addr (state->fb, state, i); - addr =phys_to_virt (paddr);/* Ignore x1/x2 values, invalidate complete lines */ offset = clip.y1 * state->fb->pitches[i]; -dma_cache_sync (priv->dev, addr + offset, +dma_sync_single_for_device (dev, paddr + offset, (clip.y2 - clip.y1) * state->fb->pitches[i],DMA_TO_DEVICE ); }
@@ -766,14 +763,6 @@ static int ingenic_drm_gem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) {struct drm_gem_cma_object *cma_obj =to_drm_gem_cma_obj (obj); -struct device *dev = cma_obj->base.dev->dev; -unsigned long attrs; -int ret; - -if (ingenic_drm_cached_gem_buf) - attrs =DMA_ATTR_NON_CONSISTENT ; -else - attrs =DMA_ATTR_WRITE_COMBINE ;/* * Clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and set the
@@ -784,12 +773,13 @@ static int ingenic_drm_gem_mmap(struct drm_gem_object *obj, vma->vm_pgoff =0 ; vma->vm_page_prot =vm_get_page_prot (vma->vm_flags); - ret =dma_mmap_attrs (dev, vma, cma_obj->vaddr, cma_obj->paddr, - vma->vm_end - vma->vm_start, attrs); -if (ret) -drm_gem_vm_close (vma); +if (!ingenic_drm_cached_gem_buf) + vma->vm_page_prot =pgprot_writecombine (vma->vm_page_prot); -return ret; +return remap_pfn_range (vma, vma->vm_start, + cma_obj->paddr >>PAGE_SHIFT , + vma->vm_end - vma->vm_start, + vma->vm_page_prot); } static int ingenic_drm_gem_cma_mmap(struct file *filp,
Signature · 1 line
2.28.0
Re: [PATCH 2/3] drm/ingenic: Update code to mmap GEM buffers cached
Quoted 27 lines · Paul Cercueil
The DMA API changed at the same time commit
37054fc81443("gpu/drm:
ingenic: Add option to mmap GEM buffers cached") was added. Rework the code to work with the new DMA API.Signed-off-by Paul Cercueil <[email protected]>--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 24 +++++++---------------- 1 file changed, 7 insertions(+), 17 deletions(-)drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0
-2@@ -526,12 +526,10 @@ void ingenic_drm_sync_data(struct device *dev, struct drm_plane_state *state) {const struct drm_format_info *finfo = state->fb->format; -struct ingenic_drm *priv =dev_get_drvdata (dev);struct drm_atomic_helper_damage_iter iter;unsigned int offset, i;struct drm_rect clip;dma_addr_t paddr; -void *addr;if (!ingenic_drm_cached_gem_buf)return ;
drivers/gpu/drm/ingenic/ingenic-drm-drv.c void ingenic_drm_sync_data(struct device *dev, · line 544
Quoted 4 lines
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0
-1@@ -541,12 +539,11 @@ void ingenic_drm_sync_data(struct device *dev,drm_atomic_for_each_plane_damage (&iter, &clip) {for (i =0 ; i < finfo->num_planes; i++) { paddr =drm_fb_cma_get_gem_addr (state->fb, state, i); - addr =phys_to_virt (paddr);
No on the old code: drm_fb_cma_get_gem_addr returns a dma_addr_t, so this was already pretty broken..
Quoted 8 lines
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0
-0@@ -766,14 +763,6 @@ static int ingenic_drm_gem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) {struct drm_gem_cma_object *cma_obj =to_drm_gem_cma_obj (obj);/* * Clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and set the
drivers/gpu/drm/ingenic/ingenic-drm-drv.c static int ingenic_drm_gem_mmap(struct drm_gem_object *obj, · line 782
Quoted 10 lines
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +6
-0@@ -784,12 +773,13 @@ static int ingenic_drm_gem_mmap(struct drm_gem_object *obj, vma->vm_pgoff =0 ; vma->vm_page_prot =vm_get_page_prot (vma->vm_flags); +if (!ingenic_drm_cached_gem_buf) + vma->vm_page_prot =pgprot_writecombine (vma->vm_page_prot); +return remap_pfn_range (vma, vma->vm_start, + cma_obj->paddr >>PAGE_SHIFT , + vma->vm_end - vma->vm_start, + vma->vm_page_prot);
both ->vaddr and ->paddr come from dma_alloc_wc as far as I can tell, and despite the confusing name ->paddr is a dma_addr_t. So this can't work at all. If you allocate memory using dma_alloc_wc you need to map it using dma_alloc_wc.
Paul Cercueil
maintainerPATCH 3/3 drm/ingenic: Alloc cached GEM buffers with dma_alloc_noncoherent
In reply to Christoph HellwigIt turns out that if you want to mmap GEM buffers fully cached, then they should be allocated as such as well. Who would have known?
Introduce a custom .dumb_create callback, that will behave just like drm_gem_cma_dumb_create(), except that it will allocate the GEM buffer using dma_alloc_noncoherent() if non-coherent memory is what we want.
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 48 ++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +47 -1
@@ -794,6 +794,52 @@ static int ingenic_drm_gem_cma_mmap(struct file *filp,return ingenic_drm_gem_mmap (vma->vm_private_data, vma); } +static int ingenic_drm_gem_cma_dumb_create (struct drm_file *file_priv, +struct drm_device *drm, +struct drm_mode_create_dumb *args) +{ +/* +* This is basically a copy of drm_gem_cma_dumb_create, which supports +* creating fully cached GEM buffers. +*/ +struct drm_gem_cma_object *cma_obj; +struct drm_gem_object *gem_obj; +size_t size; +int ret; + + args->pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); + args->size = args->pitch * args->height; + + size =PAGE_ALIGN (args->size); + + cma_obj =drm_gem_cma_create_noalloc (drm, size); +if (IS_ERR (cma_obj)) +return PTR_ERR (cma_obj); + +if (ingenic_drm_cached_gem_buf) { + cma_obj->vaddr =dma_alloc_noncoherent (drm->dev, size, + &cma_obj->paddr, +DMA_TO_DEVICE , +GFP_KERNEL | __GFP_NOWARN); + }else { + cma_obj->vaddr =dma_alloc_wc (drm->dev, size, &cma_obj->paddr, +GFP_KERNEL | __GFP_NOWARN); + } +if (!cma_obj->vaddr) { +dev_err (drm->dev,"Failed to allocate buffer with size %zu\n" , size); + ret = -ENOMEM ; + goto out_gem_object_put; + } + + gem_obj = &cma_obj->base; + + ret =drm_gem_handle_create (file_priv, gem_obj, &args->handle); + +out_gem_object_put: +drm_gem_object_put (gem_obj); +return ret; +} +static const struct file_operations ingenic_drm_fops = { .owner =THIS_MODULE , .open = drm_open,
@@ -816,7 +862,7 @@ static struct drm_driver ingenic_drm_driver_data = { .patchlevel = 0, .fops = &ingenic_drm_fops, - DRM_GEM_CMA_DRIVER_OPS, +DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE (ingenic_drm_gem_cma_dumb_create), .irq_handler = ingenic_drm_irq_handler, };
Signature · 1 line
2.28.0
Re: [PATCH 3/3] drm/ingenic: Alloc cached GEM buffers with dma_alloc_noncoherent
Quoted 6 lines · Paul Cercueil
It turns out that if you want to mmap GEM buffers fully cached, then they should be allocated as such as well. Who would have known?
Introduce a custom .dumb_create callback, that will behave just like
drm_gem_cma_dumb_create(), except that it will allocate the GEM buffer usingdma_alloc_noncoherent()if non-coherent memory is what we want.
I think you want to merge this with patch 2, then change patch 2 to still use dma_alloc_wc for the !ingenic_drm_cached_gem_buf and to get the phys address using virt_to_phys for the ingenic_drm_cached_gem_buf instead of abusing the dma address in ->paddr. The free side also needs to use dma_free_noncoherent.
drivers/gpu/drm/ingenic/ingenic-drm-drv.c static int ingenic_drm_gem_cma_mmap(struct file *filp, · line 804
Quoted 8 lines
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +8
-0+static int ingenic_drm_gem_cma_dumb_create (struct drm_file *file_priv, +struct drm_device *drm, +struct drm_mode_create_dumb *args) +{ +/* +* This is basically a copy of drm_gem_cma_dumb_create, which supports +* creating fully cached GEM buffers. +*/
What about adding this to the core GEM code instead? We'll probaby run into other potential users as well.
Paul Cercueil
maintainerPATCH 1/1 Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
In reply to Christoph HellwigThis reverts commit 37054fc81443cc6a8c3a38395f384412b8373d82.
At the very moment this commit was created, the DMA API it relied on was modified in the DMA tree, which caused the driver to break in linux-next.
Revert it for now, and it will be resubmitted later to work with the new DMA API.
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 114 +--------------------- drivers/gpu/drm/ingenic/ingenic-drm.h | 4 - drivers/gpu/drm/ingenic/ingenic-ipu.c | 12 +-- 3 files changed, 4 insertions(+), 126 deletions(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +2 -112
@@ -9,8 +9,6 @@#include <linux/component.h> #include <linux/clk.h> #include <linux/dma-mapping.h> -#include <linux/dma-noncoherent.h> -#include <linux/io.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/of_device.h>
@@ -24,7 +22,6 @@#include <drm/drm_color_mgmt.h> #include <drm/drm_crtc.h> #include <drm/drm_crtc_helper.h> -#include <drm/drm_damage_helper.h> #include <drm/drm_drv.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_fb_cma_helper.h>
@@ -100,11 +97,6 @@ struct ingenic_drm {struct notifier_block clock_nb; }; -static bool ingenic_drm_cached_gem_buf; -module_param_named (cached_gem_buffers, ingenic_drm_cached_gem_buf, bool,0400 ); -MODULE_PARM_DESC (cached_gem_buffers, -"Enable fully cached GEM buffers [default=false]" ); -static bool ingenic_drm_writeable_reg (struct device *dev,unsigned int reg) {switch (reg) {
@@ -402,8 +394,6 @@ static int ingenic_drm_plane_atomic_check(struct drm_plane *plane, plane->state->fb->format->format != state->fb->format->format)) crtc_state->mode_changed = true; -drm_atomic_helper_check_plane_damage (state->state, state); -return 0 ; }
@@ -521,38 +511,6 @@ void ingenic_drm_plane_config(struct device *dev, } } -void ingenic_drm_sync_data (struct device *dev, -struct drm_plane_state *old_state, -struct drm_plane_state *state) -{ -const struct drm_format_info *finfo = state->fb->format; -struct ingenic_drm *priv =dev_get_drvdata (dev); -struct drm_atomic_helper_damage_iter iter; -unsigned int offset, i; -struct drm_rect clip; -dma_addr_t paddr; -void *addr; - -if (!ingenic_drm_cached_gem_buf) -return ; - -drm_atomic_helper_damage_iter_init (&iter, old_state, state); - -drm_atomic_for_each_plane_damage (&iter, &clip) { -for (i =0 ; i < finfo->num_planes; i++) { - paddr =drm_fb_cma_get_gem_addr (state->fb, state, i); - addr =phys_to_virt (paddr); - -/* Ignore x1/x2 values, invalidate complete lines */ - offset = clip.y1 * state->fb->pitches[i]; - -dma_cache_sync (priv->dev, addr + offset, - (clip.y2 - clip.y1) * state->fb->pitches[i], -DMA_TO_DEVICE ); - } - } -} -static void ingenic_drm_update_palette (struct ingenic_drm *priv,const struct drm_color_lut *lut) {
@@ -581,8 +539,6 @@ static void ingenic_drm_plane_atomic_update(struct drm_plane *plane,if (state && state->fb) { crtc_state = state->crtc->state; -ingenic_drm_sync_data (priv->dev, oldstate, state); - addr =drm_fb_cma_get_gem_addr (state->fb, state,0 ); width = state->src_w >>16 ; height = state->src_h >>16 ;
@@ -752,69 +708,7 @@ static void ingenic_drm_disable_vblank(struct drm_crtc *crtc)regmap_update_bits (priv->map,JZ_REG_LCD_CTRL ,JZ_LCD_CTRL_EOF_IRQ ,0 ); } -static struct drm_framebuffer * -ingenic_drm_gem_fb_create (struct drm_device *dev,struct drm_file *file, -const struct drm_mode_fb_cmd2 *mode_cmd) -{ -if (ingenic_drm_cached_gem_buf) -return drm_gem_fb_create_with_dirty (dev, file, mode_cmd); - -return drm_gem_fb_create (dev, file, mode_cmd); -} - -static int ingenic_drm_gem_mmap (struct drm_gem_object *obj, -struct vm_area_struct *vma) -{ -struct drm_gem_cma_object *cma_obj =to_drm_gem_cma_obj (obj); -struct device *dev = cma_obj->base.dev->dev; -unsigned long attrs; -int ret; - -if (ingenic_drm_cached_gem_buf) - attrs =DMA_ATTR_NON_CONSISTENT ; -else - attrs =DMA_ATTR_WRITE_COMBINE ; - -/* -* Clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and set the -* vm_pgoff (used as a fake buffer offset by DRM) to 0 as we want to map -* the whole buffer. -*/ - vma->vm_flags &= ~VM_PFNMAP ; - vma->vm_pgoff =0 ; - vma->vm_page_prot =vm_get_page_prot (vma->vm_flags); - - ret =dma_mmap_attrs (dev, vma, cma_obj->vaddr, cma_obj->paddr, - vma->vm_end - vma->vm_start, attrs); -if (ret) -drm_gem_vm_close (vma); - -return ret; -} - -static int ingenic_drm_gem_cma_mmap (struct file *filp, -struct vm_area_struct *vma) -{ -int ret; - - ret =drm_gem_mmap (filp, vma); -if (ret) -return ret; - -return ingenic_drm_gem_mmap (vma->vm_private_data, vma); -} - -static const struct file_operations ingenic_drm_fops = { - .owner =THIS_MODULE , - .open = drm_open, - .release = drm_release, - .unlocked_ioctl = drm_ioctl, - .compat_ioctl = drm_compat_ioctl, - .poll = drm_poll, - .read = drm_read, - .llseek = noop_llseek, - .mmap = ingenic_drm_gem_cma_mmap, -}; +DEFINE_DRM_GEM_CMA_FOPS (ingenic_drm_fops);static struct drm_driver ingenic_drm_driver_data = { .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC ,
@@ -878,7 +772,7 @@ static const struct drm_encoder_helper_funcs ingenic_drm_encoder_helper_funcs = };static const struct drm_mode_config_funcs ingenic_drm_mode_config_funcs = { - .fb_create = ingenic_drm_gem_fb_create, + .fb_create = drm_gem_fb_create, .output_poll_changed = drm_fb_helper_output_poll_changed, .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit,
@@ -1032,8 +926,6 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)return ret; } -drm_plane_enable_fb_damage_clips (&priv->f1); -drm_crtc_helper_add (&priv->crtc, &ingenic_drm_crtc_helper_funcs); ret = drm_crtc_init_with_planes(drm, &priv->crtc, &priv->f1,
@@ -1062,8 +954,6 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)return ret; } -drm_plane_enable_fb_damage_clips (&priv->f0); -if (IS_ENABLED (CONFIG_DRM_INGENIC_IPU ) && has_components) { ret =component_bind_all (dev, drm);if (ret) {
drivers/gpu/drm/ingenic/ingenic-drm.h +0 -4
@@ -171,10 +171,6 @@ void ingenic_drm_plane_config(struct device *dev, struct drm_plane *plane, u32 fourcc);void ingenic_drm_plane_disable (struct device *dev,struct drm_plane *plane); -void ingenic_drm_sync_data (struct device *dev, -struct drm_plane_state *old_state, -struct drm_plane_state *state); -extern struct platform_driver *ingenic_ipu_driver_ptr;#endif /* DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H */
drivers/gpu/drm/ingenic/ingenic-ipu.c +2 -10
@@ -20,7 +20,6 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> -#include <drm/drm_damage_helper.h> #include <drm/drm_drv.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_fourcc.h>
@@ -317,8 +316,6 @@ static void ingenic_ipu_plane_atomic_update(struct drm_plane *plane, JZ_IPU_CTRL_CHIP_EN | JZ_IPU_CTRL_LCDC_SEL); } -ingenic_drm_sync_data (ipu->master, oldstate, state); -/* New addresses will be committed in vblank handler... */ ipu->addr_y =drm_fb_cma_get_gem_addr (state->fb, state,0 );if (finfo->num_planes >1 )
@@ -537,7 +534,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,if (!state->crtc || !crtc_state->mode.hdisplay || !crtc_state->mode.vdisplay) - goto out_check_damage; +return 0 ;/* Plane must be fully visible */ if (state->crtc_x < 0 || state->crtc_y < 0 ||
@@ -554,7 +551,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,return -EINVAL ;if (!osd_changed (state, plane->state)) - goto out_check_damage; +return 0 ; crtc_state->mode_changed = true;
@@ -581,9 +578,6 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane, ipu->denom_w = denom_w; ipu->denom_h = denom_h; -out_check_damage: -drm_atomic_helper_check_plane_damage (state->state, state); -return 0 ; }
@@ -765,8 +759,6 @@ static int ingenic_ipu_bind(struct device *dev, struct device *master, void *d)return err; } -drm_plane_enable_fb_damage_clips (plane); -/* * Sharpness settings range is [0,32] * 0 : nearest-neighbor
Signature · 1 line
2.28.0
Re: [PATCH] Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
Hi Paul.
Quoted 1 line · Paul Cercueil
This reverts commit
37054fc81443cc6a8c3a38395f384412b8373d82.
In the changelog please refer to commits like this:37054fc81443 ("gpu/drm: ingenic: Add option to mmap GEM buffers cached")
Use "dim cite 37054fc81443cc6a8c3a38395f384412b8373d82" to get the right format.
Quoted 9 lines
At the very moment this commit was created, the DMA API it relied on was modified in the DMA tree, which caused the driver to break in linux-next.
Revert it for now, and it will be resubmitted later to work with the new DMA API.
Signed-off-by Paul Cercueil <[email protected]>
With the changelog updated:
Quoted 269 lines
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 114 +--------------------- drivers/gpu/drm/ingenic/ingenic-drm.h | 4 - drivers/gpu/drm/ingenic/ingenic-ipu.c | 12 +-- 3 files changed, 4 insertions(+), 126 deletions(-)drivers/gpu/drm/ingenic/ingenic-drm-drv.c +2
-112@@ -9,8 +9,6 @@#include <linux/component.h> #include <linux/clk.h> #include <linux/dma-mapping.h> -#include <linux/dma-noncoherent.h> -#include <linux/io.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/of_device.h> @@ -24,7 +22,6 @@#include <drm/drm_color_mgmt.h> #include <drm/drm_crtc.h> #include <drm/drm_crtc_helper.h> -#include <drm/drm_damage_helper.h> #include <drm/drm_drv.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_fb_cma_helper.h> @@ -100,11 +97,6 @@ struct ingenic_drm {struct notifier_block clock_nb; }; -static bool ingenic_drm_cached_gem_buf; -module_param_named (cached_gem_buffers, ingenic_drm_cached_gem_buf, bool,0400 ); -MODULE_PARM_DESC (cached_gem_buffers, -"Enable fully cached GEM buffers [default=false]" ); -static bool ingenic_drm_writeable_reg (struct device *dev,unsigned int reg) {switch (reg) {@@ -402,8 +394,6 @@ static int ingenic_drm_plane_atomic_check(struct drm_plane *plane, plane->state->fb->format->format != state->fb->format->format)) crtc_state->mode_changed = true; -drm_atomic_helper_check_plane_damage (state->state, state); -return 0 ; }@@ -521,38 +511,6 @@ void ingenic_drm_plane_config(struct device *dev, } } -void ingenic_drm_sync_data (struct device *dev, -struct drm_plane_state *old_state, -struct drm_plane_state *state) -{ -const struct drm_format_info *finfo = state->fb->format; -struct ingenic_drm *priv =dev_get_drvdata (dev); -struct drm_atomic_helper_damage_iter iter; -unsigned int offset, i; -struct drm_rect clip; -dma_addr_t paddr; -void *addr; - -if (!ingenic_drm_cached_gem_buf) -return ; - -drm_atomic_helper_damage_iter_init (&iter, old_state, state); - -drm_atomic_for_each_plane_damage (&iter, &clip) { -for (i =0 ; i < finfo->num_planes; i++) { - paddr =drm_fb_cma_get_gem_addr (state->fb, state, i); - addr =phys_to_virt (paddr); - -/* Ignore x1/x2 values, invalidate complete lines */ - offset = clip.y1 * state->fb->pitches[i]; - -dma_cache_sync (priv->dev, addr + offset, - (clip.y2 - clip.y1) * state->fb->pitches[i], -DMA_TO_DEVICE ); - } - } -} -static void ingenic_drm_update_palette (struct ingenic_drm *priv,const struct drm_color_lut *lut) {@@ -581,8 +539,6 @@ static void ingenic_drm_plane_atomic_update(struct drm_plane *plane,if (state && state->fb) { crtc_state = state->crtc->state; -ingenic_drm_sync_data (priv->dev, oldstate, state); - addr =drm_fb_cma_get_gem_addr (state->fb, state,0 ); width = state->src_w >>16 ; height = state->src_h >>16 ;@@ -752,69 +708,7 @@ static void ingenic_drm_disable_vblank(struct drm_crtc *crtc)regmap_update_bits (priv->map,JZ_REG_LCD_CTRL ,JZ_LCD_CTRL_EOF_IRQ ,0 ); } -static struct drm_framebuffer * -ingenic_drm_gem_fb_create (struct drm_device *dev,struct drm_file *file, -const struct drm_mode_fb_cmd2 *mode_cmd) -{ -if (ingenic_drm_cached_gem_buf) -return drm_gem_fb_create_with_dirty (dev, file, mode_cmd); - -return drm_gem_fb_create (dev, file, mode_cmd); -} - -static int ingenic_drm_gem_mmap (struct drm_gem_object *obj, -struct vm_area_struct *vma) -{ -struct drm_gem_cma_object *cma_obj =to_drm_gem_cma_obj (obj); -struct device *dev = cma_obj->base.dev->dev; -unsigned long attrs; -int ret; - -if (ingenic_drm_cached_gem_buf) - attrs =DMA_ATTR_NON_CONSISTENT ; -else - attrs =DMA_ATTR_WRITE_COMBINE ; - -/* -* Clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and set the -* vm_pgoff (used as a fake buffer offset by DRM) to 0 as we want to map -* the whole buffer. -*/ - vma->vm_flags &= ~VM_PFNMAP ; - vma->vm_pgoff =0 ; - vma->vm_page_prot =vm_get_page_prot (vma->vm_flags); - - ret =dma_mmap_attrs (dev, vma, cma_obj->vaddr, cma_obj->paddr, - vma->vm_end - vma->vm_start, attrs); -if (ret) -drm_gem_vm_close (vma); - -return ret; -} - -static int ingenic_drm_gem_cma_mmap (struct file *filp, -struct vm_area_struct *vma) -{ -int ret; - - ret =drm_gem_mmap (filp, vma); -if (ret) -return ret; - -return ingenic_drm_gem_mmap (vma->vm_private_data, vma); -} - -static const struct file_operations ingenic_drm_fops = { - .owner =THIS_MODULE , - .open = drm_open, - .release = drm_release, - .unlocked_ioctl = drm_ioctl, - .compat_ioctl = drm_compat_ioctl, - .poll = drm_poll, - .read = drm_read, - .llseek = noop_llseek, - .mmap = ingenic_drm_gem_cma_mmap, -}; +DEFINE_DRM_GEM_CMA_FOPS (ingenic_drm_fops);static struct drm_driver ingenic_drm_driver_data = { .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC ,@@ -878,7 +772,7 @@ static const struct drm_encoder_helper_funcs ingenic_drm_encoder_helper_funcs = };static const struct drm_mode_config_funcs ingenic_drm_mode_config_funcs = { - .fb_create = ingenic_drm_gem_fb_create, + .fb_create = drm_gem_fb_create, .output_poll_changed = drm_fb_helper_output_poll_changed, .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit,@@ -1032,8 +926,6 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)return ret; } -drm_plane_enable_fb_damage_clips (&priv->f1); -drm_crtc_helper_add (&priv->crtc, &ingenic_drm_crtc_helper_funcs); ret = drm_crtc_init_with_planes(drm, &priv->crtc, &priv->f1,@@ -1062,8 +954,6 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)return ret; } -drm_plane_enable_fb_damage_clips (&priv->f0); -if (IS_ENABLED (CONFIG_DRM_INGENIC_IPU ) && has_components) { ret =component_bind_all (dev, drm);if (ret) {drivers/gpu/drm/ingenic/ingenic-drm.h +0
-4@@ -171,10 +171,6 @@ void ingenic_drm_plane_config(struct device *dev, struct drm_plane *plane, u32 fourcc);void ingenic_drm_plane_disable (struct device *dev,struct drm_plane *plane); -void ingenic_drm_sync_data (struct device *dev, -struct drm_plane_state *old_state, -struct drm_plane_state *state); -extern struct platform_driver *ingenic_ipu_driver_ptr;#endif /* DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H */ drivers/gpu/drm/ingenic/ingenic-ipu.c +2
-10@@ -20,7 +20,6 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> -#include <drm/drm_damage_helper.h> #include <drm/drm_drv.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_fourcc.h> @@ -317,8 +316,6 @@ static void ingenic_ipu_plane_atomic_update(struct drm_plane *plane, JZ_IPU_CTRL_CHIP_EN | JZ_IPU_CTRL_LCDC_SEL); } -ingenic_drm_sync_data (ipu->master, oldstate, state); -/* New addresses will be committed in vblank handler... */ ipu->addr_y =drm_fb_cma_get_gem_addr (state->fb, state,0 );if (finfo->num_planes >1 )@@ -537,7 +534,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,if (!state->crtc || !crtc_state->mode.hdisplay || !crtc_state->mode.vdisplay) - goto out_check_damage; +return 0 ;/* Plane must be fully visible */ if (state->crtc_x < 0 || state->crtc_y < 0 ||@@ -554,7 +551,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,return -EINVAL ;if (!osd_changed (state, plane->state)) - goto out_check_damage; +return 0 ; crtc_state->mode_changed = true;@@ -581,9 +578,6 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane, ipu->denom_w = denom_w; ipu->denom_h = denom_h; -out_check_damage: -drm_atomic_helper_check_plane_damage (state->state, state); -return 0 ; }@@ -765,8 +759,6 @@ static int ingenic_ipu_bind(struct device *dev, struct device *master, void *d)return err; } -drm_plane_enable_fb_damage_clips (plane); -/* * Sharpness settings range is [0,32] * 0 : nearest-neighbor Signature · 1 line
2.28.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
Hi,
Quoted 16 lines · Sam Ravnborg
Hi Paul.
Quoted 1 line · Paul Cercueil
This reverts commit
37054fc81443cc6a8c3a38395f384412b8373d82.In the changelog please refer to commits like this:
37054fc81443("gpu/drm: ingenic: Add option to mmap GEM buffers cached")Use "dim cite
37054fc81443cc6a8c3a38395f384412b8373d82" to get the right format.Quoted 6 lines
At the very moment this commit was created, the DMA API it relied
on was
modified in the DMA tree, which caused the driver to break in linux-next.
Quoted 8 lines
Quoted 5 lines
Revert it for now, and it will be resubmitted later to work with
the new
DMA API.Signed-off-by Paul Cercueil <[email protected]>With the changelog updated:
Acked-by Sam Ravnborg <[email protected]>
Pushed to drm-misc-next with the changelog fix, thanks.
Stephen:
Now it should build fine again. Could you remove the BROKEN flag?
Cheers,
-Paul
Quoted 295 lines
Quoted 295 lines
---
drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 114 +--------------------- drivers/gpu/drm/ingenic/ingenic-drm.h | 4 - drivers/gpu/drm/ingenic/ingenic-ipu.c | 12 +-- 3 files changed, 4 insertions(+), 126 deletions(-)diff --git
a/drivers/gpu/drm/ingenic/ingenic-drm-drv.cb/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index0225dc1f5eb8..7d8b0ad52979100644
---a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c+++b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c@@ -9,8 +9,6 @@
#include <linux/component.h>
#include <linux/clk.h>
#include <linux/dma-mapping.h>
-#include <linux/dma-noncoherent.h>
-#include <linux/io.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of_device.h>
@@ -24,7 +22,6 @@
#include <drm/drm_color_mgmt.h>
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
-#include <drm/drm_damage_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_fb_cma_helper.h>
@@ -100,11 +97,6 @@ structingenic_drm{
structnotifier_blockclock_nb;
};-static bool
ingenic_drm_cached_gem_buf; -module_param_named(cached_gem_buffers,ingenic_drm_cached_gem_buf,
bool, 0400);
-MODULE_PARM_DESC(cached_gem_buffers,
- "Enable fully cached GEM buffers [default=false]");
-
static bool ingenic_drm_writeable_reg(struct device *dev, unsigned
int reg)
{
switch (reg) {
@@ -402,8 +394,6 @@ static int
ingenic_drm_plane_atomic_check(structdrm_plane*plane,
plane->state->fb->format->format!=state->fb->format->format))
crtc_state->mode_changed= true;-
drm_atomic_helper_check_plane_damage(state->state, state);
-
return 0;
}@@ -521,38 +511,6 @@ void ingenic_drm_plane_config(struct device
*dev,
}
}-void ingenic_drm_sync_data(struct device *dev,
- structdrm_plane_state*old_state,
- structdrm_plane_state*state)
-{
- const structdrm_format_info*finfo =state->fb->format;
- structingenic_drm*priv =dev_get_drvdata(dev);
- structdrm_atomic_helper_damage_iteriter;
- unsigned int offset, i;
- structdrm_rectclip;
-dma_addr_tpaddr;
- void *addr;
-
- if (!ingenic_drm_cached_gem_buf)
- return;
-
-drm_atomic_helper_damage_iter_init(&iter, old_state, state);
-
-drm_atomic_for_each_plane_damage(&iter, &clip){
- for (i = 0; i <finfo->num_planes; i++) {
- paddr =drm_fb_cma_get_gem_addr(state->fb, state, i);
- addr =phys_to_virt(paddr);
-
- /* Ignore x1/x2 values, invalidate complete lines */
- offset = clip.y1 * state->fb->pitches[i];
-
- dma_cache_sync(priv->dev, addr + offset,
- (clip.y2 - clip.y1) * state->fb->pitches[i],
-DMA_TO_DEVICE);
- }
- }
-}
-
static void ingenic_drm_update_palette(structingenic_drm*priv,
const structdrm_color_lut*lut)
{
@@ -581,8 +539,6 @@ static void
ingenic_drm_plane_atomic_update(structdrm_plane*plane,
if (state &&state->fb) {
crtc_state=state->crtc->state;-
ingenic_drm_sync_data(priv->dev, oldstate, state);
-
addr =drm_fb_cma_get_gem_addr(state->fb, state, 0); width =state->src_w>> 16;
height =state->src_h>> 16;
@@ -752,69 +708,7 @@ static void ingenic_drm_disable_vblank(structdrm_crtc*crtc)
regmap_update_bits(priv->map,JZ_REG_LCD_CTRL,JZ_LCD_CTRL_EOF_IRQ, 0);
}-static struct
drm_framebuffer* -ingenic_drm_gem_fb_create(structdrm_device*dev, structdrm_file
*file,
- const structdrm_mode_fb_cmd2*mode_cmd)
-{
- if (ingenic_drm_cached_gem_buf)
- returndrm_gem_fb_create_with_dirty(dev, file, mode_cmd);
-
- returndrm_gem_fb_create(dev, file, mode_cmd);
-}
-
-static int ingenic_drm_gem_mmap(structdrm_gem_object*obj,
- structvm_area_struct*vma)
-{
- structdrm_gem_cma_object*cma_obj=to_drm_gem_cma_obj(obj);
- struct device *dev =cma_obj->base.dev->dev;
- unsigned long attrs;
- int ret;
-
- if (ingenic_drm_cached_gem_buf)
- attrs =DMA_ATTR_NON_CONSISTENT;
- else
- attrs =DMA_ATTR_WRITE_COMBINE;
-
- /*
- * Clear theVM_PFNMAPflag that was set bydrm_gem_mmap(), and
set the
- *vm_pgoff(used as a fake buffer offset by DRM) to 0 as we want
to map
- * the whole buffer.
- */
-vma->vm_flags&= ~VM_PFNMAP;
-vma->vm_pgoff= 0;
-vma->vm_page_prot=vm_get_page_prot(vma->vm_flags);
-
- ret = dma_mmap_attrs(dev, vma,cma_obj->vaddr,cma_obj->paddr,
-vma->vm_end-vma->vm_start, attrs);
- if (ret)
-drm_gem_vm_close(vma);
-
- return ret;
-}
-
-static int ingenic_drm_gem_cma_mmap(struct file *filp,
- structvm_area_struct*vma)
-{
- int ret;
-
- ret =drm_gem_mmap(filp, vma);
- if (ret)
- return ret;
-
- returningenic_drm_gem_mmap(vma->vm_private_data, vma);
-}
-
-static const structfile_operationsingenic_drm_fops= {
- .owner =THIS_MODULE,
- .open =drm_open,
- .release =drm_release,
- .unlocked_ioctl =drm_ioctl,
- .compat_ioctl =drm_compat_ioctl,
- .poll =drm_poll,
- .read =drm_read,
- .llseek =noop_llseek,
- .mmap =ingenic_drm_gem_cma_mmap,
-};
+DEFINE_DRM_GEM_CMA_FOPS(ingenic_drm_fops);static struct
drm_driveringenic_drm_driver_data= {
.driver_features =DRIVER_MODESET|DRIVER_GEM|DRIVER_ATOMIC,
@@ -878,7 +772,7 @@ static const structdrm_encoder_helper_funcsingenic_drm_encoder_helper_funcs=
};static const struct
drm_mode_config_funcsingenic_drm_mode_config_funcs= {
- .fb_create =ingenic_drm_gem_fb_create,
+ .fb_create =drm_gem_fb_create,
.output_poll_changed =drm_fb_helper_output_poll_changed,
.atomic_check =drm_atomic_helper_check,
.atomic_commit =drm_atomic_helper_commit,
@@ -1032,8 +926,6 @@ static int ingenic_drm_bind(struct device
*dev, boolhas_components)
return ret;
}-
drm_plane_enable_fb_damage_clips(&priv->f1);
-
drm_crtc_helper_add(&priv->crtc, &ingenic_drm_crtc_helper_funcs);ret = drm_crtc_init_with_planes(drm,
&priv->crtc,&priv->f1,
@@ -1062,8 +954,6 @@ static int ingenic_drm_bind(struct device
*dev, boolhas_components)
return ret;
}-
drm_plane_enable_fb_damage_clips(&priv->f0);
-
if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU)&&has_components) {
ret =component_bind_all(dev, drm);
if (ret) {
diff --gita/drivers/gpu/drm/ingenic/ingenic-drm.hb/drivers/gpu/drm/ingenic/ingenic-drm.h
indexee3a892c0383..9b48ce02803d100644
---a/drivers/gpu/drm/ingenic/ingenic-drm.h
+++b/drivers/gpu/drm/ingenic/ingenic-drm.h
@@ -171,10 +171,6 @@ void ingenic_drm_plane_config(struct device
*dev,
structdrm_plane*plane, u32 fourcc);
void ingenic_drm_plane_disable(struct device *dev, structdrm_plane*plane);-void ingenic_drm_sync_data(struct device *dev,
- structdrm_plane_state*old_state,
- structdrm_plane_state*state);
-
extern structplatform_driver*ingenic_ipu_driver_ptr;#endif /*
DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H*/
diff --gita/drivers/gpu/drm/ingenic/ingenic-ipu.cb/drivers/gpu/drm/ingenic/ingenic-ipu.c
index38c83e8cc6a5..fc8c6e970ee3100644
---a/drivers/gpu/drm/ingenic/ingenic-ipu.c+++b/drivers/gpu/drm/ingenic/ingenic-ipu.c@@ -20,7 +20,6 @@#include <
drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
-#include <drm/drm_damage_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_cma_helper.h>
#include <drm/drm_fourcc.h>
@@ -317,8 +316,6 @@ static void
ingenic_ipu_plane_atomic_update(structdrm_plane*plane,
JZ_IPU_CTRL_CHIP_EN|JZ_IPU_CTRL_LCDC_SEL);
}-
ingenic_drm_sync_data(ipu->master, oldstate, state);
-
/* New addresses will be committed in vblank handler... */ipu->addr_y=drm_fb_cma_get_gem_addr(state->fb, state, 0); if (finfo->num_planes> 1)
@@ -537,7 +534,7 @@ static int
ingenic_ipu_plane_atomic_check(structdrm_plane*plane,if (!state->crtc ||
!crtc_state->mode.hdisplay || !crtc_state->mode.vdisplay)
- gotoout_check_damage;
+ return 0;/* Plane must be fully visible */
if (state->crtc_x< 0 ||state->crtc_y< 0 ||
@@ -554,7 +551,7 @@ static int
ingenic_ipu_plane_atomic_check(structdrm_plane*plane,
return-EINVAL;if (!osd_changed(state,
plane->state))
- gotoout_check_damage;
+ return 0;crtc_state->mode_changed = true;@@ -581,9 +578,6 @@ static int
ingenic_ipu_plane_atomic_check(structdrm_plane*plane,
ipu->denom_w=denom_w;
ipu->denom_h=denom_h;-out_check_damage:
-drm_atomic_helper_check_plane_damage(state->state, state);
-
return 0;
}@@ -765,8 +759,6 @@ static int ingenic_ipu_bind(struct device *dev,
struct device *master, void *d)
return err;
}-
drm_plane_enable_fb_damage_clips(plane);
-
/*
* Sharpness settings range is [0,32]
* 0 : nearest-neighbor
--
2.28.0
Re: [PATCH] Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
Hi Paul,
Quoted 5 lines · On Sun, 04 Oct 2020 22:11:23 +0200 Paul Cercueil <[email protected]> wrote:
Pushed to drm-misc-next with the changelog fix, thanks.
Stephen:
Now it should build fine again. Could you remove the BROKEN flag?
Thanks for letting me know, but the fix has not appeared in any drm tree included in linux-next yet ...
If it doesn't show up by the time I will merge the drm tree tomorrow, I will apply this revert patch myself (instead of the patch marking the driver BROKEN).
Signature · 2 lines
Cheers, Stephen Rothwell
Re: [PATCH] Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
Quoted 9 lines · Stephen Rothwell
Hi Paul,
Quoted 5 lines · On Sun, 04 Oct 2020 22:11:23 +0200 Paul Cercueil <[email protected]> wrote:
Pushed to drm-misc-next with the changelog fix, thanks.
Stephen:
Now it should build fine again. Could you remove the BROKEN flag?
Quoted 6 lines
Thanks for letting me know, but the fix has not appeared in any drm tree included in linux-next yet ...
If it doesn't show up by the time I will merge the drm tree tomorrow, I will apply this revert patch myself (instead of the patch marking the driver BROKEN).
Yeah it should have been pushed to drm-misc-next-fixes per
https://drm.pages.freedesktop.org/maintainer-tools/committer-drm-misc.html#where-do-i-apply-my-patch
Paul, can you pls git cherry-pick -x this over to drm-misc-next-fixes?
Thanks, Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Paul Cercueil
maintainerRe: [PATCH] Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
Hi,
Quoted 20 lines · Daniel Vetter
Quoted 10 lines · Stephen Rothwell
Hi Paul,
Quoted 5 lines · On Sun, 04 Oct 2020 22:11:23 +0200 Paul Cercueil <[email protected]> wrote:
Pushed to drm-misc-next with the changelog fix, thanks.
Stephen:
Now it should build fine again. Could you remove the BROKEN flag?Quoted 8 lines
Thanks for letting me know, but the fix has not appeared in any drm tree included in linux-next yet ...
If it doesn't show up by the time I will merge the drm tree
tomorrow, I
will apply this revert patch myself (instead of the patch marking
the
driver BROKEN).
Quoted 5 lines
Yeah it should have been pushed to drm-misc-next-fixes per
https://drm.pages.freedesktop.org/maintainer-tools/committer-drm-misc.html#where-do-i-apply-my-patch
Paul, can you pls git cherry-pick -x this over to drm-misc-next-fixes?
I had a few commits on top of it in drm-misc-next, so the revert doesn't apply cleanly in drm-misc-next-fixes... I can revert it there, but then we'd have a different revert commit in drm-misc-next and drm-misc-next-next.
Sorry for the mess. What should I do?
-Paul
Re: [PATCH] Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
Quoted 28 lines · Paul Cercueil
Hi,
Quoted 24 lines · Daniel Vetter
Quoted 10 lines · Stephen Rothwell
Hi Paul,
Quoted 5 lines · On Sun, 04 Oct 2020 22:11:23 +0200 Paul Cercueil <[email protected]> wrote:
Pushed to drm-misc-next with the changelog fix, thanks.
Stephen:
Now it should build fine again. Could you remove the BROKEN flag?Quoted 8 lines
Thanks for letting me know, but the fix has not appeared in any drm tree included in linux-next yet ...
If it doesn't show up by the time I will merge the drm tree
tomorrow, I
will apply this revert patch myself (instead of the patch marking
the
driver BROKEN).Yeah it should have been pushed to drm-misc-next-fixes per
https://drm.pages.freedesktop.org/maintainer-tools/committer-drm-misc.html#where-do-i-apply-my-patch
Quoted 8 lines
Quoted 1 line
Paul, can you pls git cherry-pick -x this over to drm-misc-next-fixes?
I had a few commits on top of it in drm-misc-next, so the revert doesn't apply cleanly in drm-misc-next-fixes... I can revert it there, but then we'd have a different revert commit in drm-misc-next and drm-misc-next-next.
Sorry for the mess. What should I do?
We need the revert in drm-misc-next-fixes or the drm-next pull request doesn't work out. So cherry-pick over, fix up conflicts, push the tree, and don't forget to fix up the conflicts when dim rebuilds drm-tip. Also tell drm-misc maintainers what you've done, they probably want to do a backmerge to clean this up a bit once the drm-next pull request has landed.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
In reply to Paul CercueilQuoted 28 lines · Paul Cercueil
Hi,
Quoted 24 lines · Daniel Vetter
Quoted 10 lines · Stephen Rothwell
Hi Paul,
Quoted 5 lines · On Sun, 04 Oct 2020 22:11:23 +0200 Paul Cercueil <[email protected]> wrote:
Pushed to drm-misc-next with the changelog fix, thanks.
Stephen:
Now it should build fine again. Could you remove the BROKEN flag?Quoted 8 lines
Thanks for letting me know, but the fix has not appeared in any drm tree included in linux-next yet ...
If it doesn't show up by the time I will merge the drm tree
tomorrow, I
will apply this revert patch myself (instead of the patch marking
the
driver BROKEN).Yeah it should have been pushed to drm-misc-next-fixes per
https://drm.pages.freedesktop.org/maintainer-tools/committer-drm-misc.html#where-do-i-apply-my-patch
Quoted 8 lines
Quoted 1 line
Paul, can you pls git cherry-pick -x this over to drm-misc-next-fixes?
I had a few commits on top of it in drm-misc-next, so the revert doesn't apply cleanly in drm-misc-next-fixes... I can revert it there, but then we'd have a different revert commit in drm-misc-next and drm-misc-next-next.
Sorry for the mess. What should I do?
Hm not sure why, but the reply I thought I've typed didn't seem to have gone out.
Cherry pick up, fix up conflict and then fix up the conflict when rebuilding drm-tip. Please tell drm-misc maintainers, they probably want to do a backmerge once the drm-next merge window pull is merged in Linus tree.
If we don't fix this up then the drm-next pull goes nowhere. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH] Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
In reply to Stephen RothwellHi all,
Quoted 8 lines · On Mon, 5 Oct 2020 23:01:50 +1100 Stephen Rothwell <[email protected]> wrote:
Quoted 5 lines · On Sun, 04 Oct 2020 22:11:23 +0200 Paul Cercueil <[email protected]> wrote:
Pushed to drm-misc-next with the changelog fix, thanks.
Stephen:
Now it should build fine again. Could you remove the BROKEN flag?
Quoted 6 lines
Thanks for letting me know, but the fix has not appeared in any drm tree included in linux-next yet ...
If it doesn't show up by the time I will merge the drm tree tomorrow, I will apply this revert patch myself (instead of the patch marking the driver BROKEN).
Unfortunately, the revert patch does not apply to the drm tree merge, so I have just marked the driver BROKEN again today.
Signature · 2 lines
Cheers, Stephen Rothwell