Skip to content

Commit a3fb64c

Browse files
committed
Revert "gpu/drm: ingenic: Add option to mmap GEM buffers cached"
This reverts commit 37054fc ("gpu/drm: ingenic: Add option to mmap GEM buffers cached") 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]> Acked-by: Sam Ravnborg <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 8ba0b6d commit a3fb64c

File tree

3 files changed

+13
-119
lines changed

3 files changed

+13
-119
lines changed

drivers/gpu/drm/ingenic/ingenic-drm-drv.c

Lines changed: 11 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <linux/component.h>
1010
#include <linux/clk.h>
1111
#include <linux/dma-mapping.h>
12-
#include <linux/dma-noncoherent.h>
13-
#include <linux/io.h>
1412
#include <linux/module.h>
1513
#include <linux/of_device.h>
1614
#include <linux/platform_device.h>
@@ -21,7 +19,6 @@
2119
#include <drm/drm_bridge.h>
2220
#include <drm/drm_crtc.h>
2321
#include <drm/drm_crtc_helper.h>
24-
#include <drm/drm_damage_helper.h>
2522
#include <drm/drm_drv.h>
2623
#include <drm/drm_gem_cma_helper.h>
2724
#include <drm/drm_fb_cma_helper.h>
@@ -79,11 +76,6 @@ static const u32 ingenic_drm_primary_formats[] = {
7976
DRM_FORMAT_XRGB8888,
8077
};
8178

82-
static bool ingenic_drm_cached_gem_buf;
83-
module_param_named(cached_gem_buffers, ingenic_drm_cached_gem_buf, bool, 0400);
84-
MODULE_PARM_DESC(cached_gem_buffers,
85-
"Enable fully cached GEM buffers [default=false]");
86-
8779
static bool ingenic_drm_writeable_reg(struct device *dev, unsigned int reg)
8880
{
8981
switch (reg) {
@@ -346,8 +338,6 @@ static int ingenic_drm_plane_atomic_check(struct drm_plane *plane,
346338
plane->state->fb->format->format != state->fb->format->format))
347339
crtc_state->mode_changed = true;
348340

349-
drm_atomic_helper_check_plane_damage(state->state, state);
350-
351341
return 0;
352342
}
353343

@@ -450,35 +440,17 @@ void ingenic_drm_plane_config(struct device *dev,
450440
}
451441
}
452442

453-
void ingenic_drm_sync_data(struct device *dev,
454-
struct drm_plane_state *old_state,
455-
struct drm_plane_state *state)
443+
static void ingenic_drm_update_palette(struct ingenic_drm *priv,
444+
const struct drm_color_lut *lut)
456445
{
457-
const struct drm_format_info *finfo = state->fb->format;
458-
struct ingenic_drm *priv = dev_get_drvdata(dev);
459-
struct drm_atomic_helper_damage_iter iter;
460-
unsigned int offset, i;
461-
struct drm_rect clip;
462-
dma_addr_t paddr;
463-
void *addr;
464-
465-
if (!ingenic_drm_cached_gem_buf)
466-
return;
467-
468-
drm_atomic_helper_damage_iter_init(&iter, old_state, state);
446+
unsigned int i;
469447

470-
drm_atomic_for_each_plane_damage(&iter, &clip) {
471-
for (i = 0; i < finfo->num_planes; i++) {
472-
paddr = drm_fb_cma_get_gem_addr(state->fb, state, i);
473-
addr = phys_to_virt(paddr);
448+
for (i = 0; i < ARRAY_SIZE(priv->dma_hwdescs->palette); i++) {
449+
u16 color = drm_color_lut_extract(lut[i].red, 5) << 11
450+
| drm_color_lut_extract(lut[i].green, 6) << 5
451+
| drm_color_lut_extract(lut[i].blue, 5);
474452

475-
/* Ignore x1/x2 values, invalidate complete lines */
476-
offset = clip.y1 * state->fb->pitches[i];
477-
478-
dma_cache_sync(priv->dev, addr + offset,
479-
(clip.y2 - clip.y1) * state->fb->pitches[i],
480-
DMA_TO_DEVICE);
481-
}
453+
priv->dma_hwdescs->palette[i] = color;
482454
}
483455
}
484456

@@ -492,7 +464,7 @@ static void ingenic_drm_plane_atomic_update(struct drm_plane *plane,
492464
dma_addr_t addr;
493465

494466
if (state && state->fb) {
495-
ingenic_drm_sync_data(priv->dev, oldstate, state);
467+
crtc_state = state->crtc->state;
496468

497469
addr = drm_fb_cma_get_gem_addr(state->fb, state, 0);
498470
width = state->src_w >> 16;
@@ -649,69 +621,7 @@ static void ingenic_drm_disable_vblank(struct drm_crtc *crtc)
649621
regmap_update_bits(priv->map, JZ_REG_LCD_CTRL, JZ_LCD_CTRL_EOF_IRQ, 0);
650622
}
651623

652-
static struct drm_framebuffer *
653-
ingenic_drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
654-
const struct drm_mode_fb_cmd2 *mode_cmd)
655-
{
656-
if (ingenic_drm_cached_gem_buf)
657-
return drm_gem_fb_create_with_dirty(dev, file, mode_cmd);
658-
659-
return drm_gem_fb_create(dev, file, mode_cmd);
660-
}
661-
662-
static int ingenic_drm_gem_mmap(struct drm_gem_object *obj,
663-
struct vm_area_struct *vma)
664-
{
665-
struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj);
666-
struct device *dev = cma_obj->base.dev->dev;
667-
unsigned long attrs;
668-
int ret;
669-
670-
if (ingenic_drm_cached_gem_buf)
671-
attrs = DMA_ATTR_NON_CONSISTENT;
672-
else
673-
attrs = DMA_ATTR_WRITE_COMBINE;
674-
675-
/*
676-
* Clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and set the
677-
* vm_pgoff (used as a fake buffer offset by DRM) to 0 as we want to map
678-
* the whole buffer.
679-
*/
680-
vma->vm_flags &= ~VM_PFNMAP;
681-
vma->vm_pgoff = 0;
682-
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
683-
684-
ret = dma_mmap_attrs(dev, vma, cma_obj->vaddr, cma_obj->paddr,
685-
vma->vm_end - vma->vm_start, attrs);
686-
if (ret)
687-
drm_gem_vm_close(vma);
688-
689-
return ret;
690-
}
691-
692-
static int ingenic_drm_gem_cma_mmap(struct file *filp,
693-
struct vm_area_struct *vma)
694-
{
695-
int ret;
696-
697-
ret = drm_gem_mmap(filp, vma);
698-
if (ret)
699-
return ret;
700-
701-
return ingenic_drm_gem_mmap(vma->vm_private_data, vma);
702-
}
703-
704-
static const struct file_operations ingenic_drm_fops = {
705-
.owner = THIS_MODULE,
706-
.open = drm_open,
707-
.release = drm_release,
708-
.unlocked_ioctl = drm_ioctl,
709-
.compat_ioctl = drm_compat_ioctl,
710-
.poll = drm_poll,
711-
.read = drm_read,
712-
.llseek = noop_llseek,
713-
.mmap = ingenic_drm_gem_cma_mmap,
714-
};
624+
DEFINE_DRM_GEM_CMA_FOPS(ingenic_drm_fops);
715625

716626
static struct drm_driver ingenic_drm_driver_data = {
717627
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
@@ -775,7 +685,7 @@ static const struct drm_encoder_helper_funcs ingenic_drm_encoder_helper_funcs =
775685
};
776686

777687
static const struct drm_mode_config_funcs ingenic_drm_mode_config_funcs = {
778-
.fb_create = ingenic_drm_gem_fb_create,
688+
.fb_create = drm_gem_fb_create,
779689
.output_poll_changed = drm_fb_helper_output_poll_changed,
780690
.atomic_check = drm_atomic_helper_check,
781691
.atomic_commit = drm_atomic_helper_commit,
@@ -902,8 +812,6 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)
902812
return ret;
903813
}
904814

905-
drm_plane_enable_fb_damage_clips(&priv->f1);
906-
907815
drm_crtc_helper_add(&priv->crtc, &ingenic_drm_crtc_helper_funcs);
908816

909817
ret = drm_crtc_init_with_planes(drm, &priv->crtc, &priv->f1,
@@ -929,8 +837,6 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)
929837
return ret;
930838
}
931839

932-
drm_plane_enable_fb_damage_clips(&priv->f0);
933-
934840
if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU) && has_components) {
935841
ret = component_bind_all(dev, drm);
936842
if (ret) {

drivers/gpu/drm/ingenic/ingenic-drm.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ void ingenic_drm_plane_config(struct device *dev,
168168
struct drm_plane *plane, u32 fourcc);
169169
void ingenic_drm_plane_disable(struct device *dev, struct drm_plane *plane);
170170

171-
void ingenic_drm_sync_data(struct device *dev,
172-
struct drm_plane_state *old_state,
173-
struct drm_plane_state *state);
174-
175171
extern struct platform_driver *ingenic_ipu_driver_ptr;
176172

177173
#endif /* DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H */

drivers/gpu/drm/ingenic/ingenic-ipu.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include <drm/drm_atomic.h>
2222
#include <drm/drm_atomic_helper.h>
23-
#include <drm/drm_damage_helper.h>
2423
#include <drm/drm_drv.h>
2524
#include <drm/drm_fb_cma_helper.h>
2625
#include <drm/drm_fourcc.h>
@@ -317,8 +316,6 @@ static void ingenic_ipu_plane_atomic_update(struct drm_plane *plane,
317316
JZ_IPU_CTRL_CHIP_EN | JZ_IPU_CTRL_LCDC_SEL);
318317
}
319318

320-
ingenic_drm_sync_data(ipu->master, oldstate, state);
321-
322319
/* New addresses will be committed in vblank handler... */
323320
ipu->addr_y = drm_fb_cma_get_gem_addr(state->fb, state, 0);
324321
if (finfo->num_planes > 1)
@@ -537,7 +534,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
537534

538535
if (!state->crtc ||
539536
!crtc_state->mode.hdisplay || !crtc_state->mode.vdisplay)
540-
goto out_check_damage;
537+
return 0;
541538

542539
/* Plane must be fully visible */
543540
if (state->crtc_x < 0 || state->crtc_y < 0 ||
@@ -554,7 +551,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
554551
return -EINVAL;
555552

556553
if (!osd_changed(state, plane->state))
557-
goto out_check_damage;
554+
return 0;
558555

559556
crtc_state->mode_changed = true;
560557

@@ -581,9 +578,6 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
581578
ipu->denom_w = denom_w;
582579
ipu->denom_h = denom_h;
583580

584-
out_check_damage:
585-
drm_atomic_helper_check_plane_damage(state->state, state);
586-
587581
return 0;
588582
}
589583

@@ -765,8 +759,6 @@ static int ingenic_ipu_bind(struct device *dev, struct device *master, void *d)
765759
return err;
766760
}
767761

768-
drm_plane_enable_fb_damage_clips(plane);
769-
770762
/*
771763
* Sharpness settings range is [0,32]
772764
* 0 : nearest-neighbor

0 commit comments

Comments
 (0)