drm/omap: add pin refcounting to omap_framebuffer
omap_framebuffer_pin() and omap_framebuffer_unpin() are currently broken, as they cannot be called multiple times (i.e. pin, pin, unpin, unpin), which is what happens in certain cases. This issue causes the driver to possibly use 0 as an address for a displayed buffer, leading to OCP error from DSS. This patch fixes the issue by adding a simple pin_count, used to track the number of pins. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
This commit is contained in:
parent
3f4d17c4ec
commit
f36eb5a899
|
@ -86,6 +86,7 @@ struct plane {
|
|||
|
||||
struct omap_framebuffer {
|
||||
struct drm_framebuffer base;
|
||||
int pin_count;
|
||||
const struct format *format;
|
||||
struct plane planes[4];
|
||||
};
|
||||
|
@ -249,6 +250,11 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
|
|||
struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
|
||||
int ret, i, n = drm_format_num_planes(fb->pixel_format);
|
||||
|
||||
if (omap_fb->pin_count > 0) {
|
||||
omap_fb->pin_count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
struct plane *plane = &omap_fb->planes[i];
|
||||
ret = omap_gem_get_paddr(plane->bo, &plane->paddr, true);
|
||||
|
@ -257,6 +263,8 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
|
|||
omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE);
|
||||
}
|
||||
|
||||
omap_fb->pin_count++;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
|
@ -275,6 +283,11 @@ int omap_framebuffer_unpin(struct drm_framebuffer *fb)
|
|||
struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
|
||||
int ret, i, n = drm_format_num_planes(fb->pixel_format);
|
||||
|
||||
omap_fb->pin_count--;
|
||||
|
||||
if (omap_fb->pin_count > 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
struct plane *plane = &omap_fb->planes[i];
|
||||
ret = omap_gem_put_paddr(plane->bo);
|
||||
|
|
Loading…
Reference in New Issue