* [PATCH] drm/tinydrm: mipi-dbi: Fix unbalanced DMA access @ 2017-08-01 20:14 David Lechner 2017-08-02 18:51 ` Noralf Trønnes 2017-08-03 22:41 ` David Lechner 0 siblings, 2 replies; 5+ messages in thread From: David Lechner @ 2017-08-01 20:14 UTC (permalink / raw) To: dri-devel; +Cc: David Lechner, linux-kernel If we return here and import_attach is true, then dma_buf_end_cpu_access() will not be called balance dma_buf_begin_cpu_access(). Fix by setting ret instead of returning. Signed-off-by: David Lechner <david@lechnology.com> --- drivers/gpu/drm/tinydrm/mipi-dbi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index c83eeb7..e10fa4b 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -183,7 +183,8 @@ static int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, dev_err_once(fb->dev->dev, "Format is not supported: %s\n", drm_get_format_name(fb->format->format, &format_name)); - return -EINVAL; + ret = -EINVAL; + break; } if (import_attach) -- 2.7.4 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/tinydrm: mipi-dbi: Fix unbalanced DMA access 2017-08-01 20:14 [PATCH] drm/tinydrm: mipi-dbi: Fix unbalanced DMA access David Lechner @ 2017-08-02 18:51 ` Noralf Trønnes 2017-08-03 22:41 ` David Lechner 1 sibling, 0 replies; 5+ messages in thread From: Noralf Trønnes @ 2017-08-02 18:51 UTC (permalink / raw) To: David Lechner, dri-devel; +Cc: linux-kernel Den 01.08.2017 22.14, skrev David Lechner: > If we return here and import_attach is true, then dma_buf_end_cpu_access() > will not be called balance dma_buf_begin_cpu_access(). > > Fix by setting ret instead of returning. > > Signed-off-by: David Lechner <david@lechnology.com> > --- Reviewed-by: Noralf Trønnes <noralf@tronnes.org> > drivers/gpu/drm/tinydrm/mipi-dbi.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c > index c83eeb7..e10fa4b 100644 > --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c > +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c > @@ -183,7 +183,8 @@ static int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, > dev_err_once(fb->dev->dev, "Format is not supported: %s\n", > drm_get_format_name(fb->format->format, > &format_name)); > - return -EINVAL; > + ret = -EINVAL; > + break; > } > > if (import_attach) _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/tinydrm: mipi-dbi: Fix unbalanced DMA access 2017-08-01 20:14 [PATCH] drm/tinydrm: mipi-dbi: Fix unbalanced DMA access David Lechner 2017-08-02 18:51 ` Noralf Trønnes @ 2017-08-03 22:41 ` David Lechner 2017-08-04 6:49 ` Noralf Trønnes 1 sibling, 1 reply; 5+ messages in thread From: David Lechner @ 2017-08-03 22:41 UTC (permalink / raw) To: dri-devel; +Cc: Noralf Trønnes, David Airlie, linux-kernel On 08/01/2017 03:14 PM, David Lechner wrote: > If we return here and import_attach is true, then dma_buf_end_cpu_access() > will not be called balance dma_buf_begin_cpu_access(). > > Fix by setting ret instead of returning. > > Signed-off-by: David Lechner <david@lechnology.com> > --- > drivers/gpu/drm/tinydrm/mipi-dbi.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c > index c83eeb7..e10fa4b 100644 > --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c > +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c > @@ -183,7 +183,8 @@ static int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, > dev_err_once(fb->dev->dev, "Format is not supported: %s\n", > drm_get_format_name(fb->format->format, > &format_name)); > - return -EINVAL; > + ret = -EINVAL; > + break; > } > > if (import_attach) > I just realized that the next line here can mask ret. if (import_attach) ret = dma_buf_end_cpu_access(import_attach->dmabuf, DMA_FROM_DEVICE); So, we should either ignore the return value from dma_buf_end_cpu_access() always or add some logic to ignore it if ret is already an error. In some of the other patches I have been sending, we have the same situation. I those, I have opted to just ignore the return value from dma_buf_end_cpu_access(). e.g... if (import_attach) dma_buf_end_cpu_access(import_attach->dmabuf, DMA_FROM_DEVICE); Is this a reasonable thing to do? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/tinydrm: mipi-dbi: Fix unbalanced DMA access 2017-08-03 22:41 ` David Lechner @ 2017-08-04 6:49 ` Noralf Trønnes 2017-08-07 18:00 ` David Lechner 0 siblings, 1 reply; 5+ messages in thread From: Noralf Trønnes @ 2017-08-04 6:49 UTC (permalink / raw) To: David Lechner, dri-devel; +Cc: David Airlie, linux-kernel Den 04.08.2017 00.41, skrev David Lechner: > On 08/01/2017 03:14 PM, David Lechner wrote: >> If we return here and import_attach is true, then >> dma_buf_end_cpu_access() >> will not be called balance dma_buf_begin_cpu_access(). >> >> Fix by setting ret instead of returning. >> >> Signed-off-by: David Lechner <david@lechnology.com> >> --- >> drivers/gpu/drm/tinydrm/mipi-dbi.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c >> b/drivers/gpu/drm/tinydrm/mipi-dbi.c >> index c83eeb7..e10fa4b 100644 >> --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c >> +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c >> @@ -183,7 +183,8 @@ static int mipi_dbi_buf_copy(void *dst, struct >> drm_framebuffer *fb, >> dev_err_once(fb->dev->dev, "Format is not supported: %s\n", >> drm_get_format_name(fb->format->format, >> &format_name)); >> - return -EINVAL; >> + ret = -EINVAL; >> + break; >> } >> if (import_attach) >> > > > I just realized that the next line here can mask ret. > > > if (import_attach) > ret = dma_buf_end_cpu_access(import_attach->dmabuf, > DMA_FROM_DEVICE); > > So, we should either ignore the return value from > dma_buf_end_cpu_access() always or add some logic to ignore it if ret > is already an error. > > In some of the other patches I have been sending, we have the same > situation. I those, I have opted to just ignore the return value from > dma_buf_end_cpu_access(). e.g... > > > if (import_attach) > dma_buf_end_cpu_access(import_attach->dmabuf, DMA_FROM_DEVICE); > > Is this a reasonable thing to do? mipi_dbi_buf_copy() can be used by other rgb565 controllers, hence the format check I think. So when that happens, it can be moved to tinydrm-helpers. Currently it's not possible to get an illegal format, since mipi-dbi only supports those two formats. Userspace can't set an illegal format, beacuse it's checked: drm_atomic_commit -> drm_atomic_check_only -> drm_atomic_plane_check -> drm_plane_check_pixel_format So I think we can just leave this alone, or put the check before import_attach if you really want to put this straight. Noralf. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/tinydrm: mipi-dbi: Fix unbalanced DMA access 2017-08-04 6:49 ` Noralf Trønnes @ 2017-08-07 18:00 ` David Lechner 0 siblings, 0 replies; 5+ messages in thread From: David Lechner @ 2017-08-07 18:00 UTC (permalink / raw) To: Noralf Trønnes, dri-devel; +Cc: David Airlie, linux-kernel On 08/04/2017 01:49 AM, Noralf Trønnes wrote: > > Den 04.08.2017 00.41, skrev David Lechner: >> On 08/01/2017 03:14 PM, David Lechner wrote: >>> If we return here and import_attach is true, then >>> dma_buf_end_cpu_access() >>> will not be called balance dma_buf_begin_cpu_access(). >>> >>> Fix by setting ret instead of returning. >>> >>> Signed-off-by: David Lechner <david@lechnology.com> >>> --- >>> drivers/gpu/drm/tinydrm/mipi-dbi.c | 3 ++- >>> 1 file changed, 2 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c >>> b/drivers/gpu/drm/tinydrm/mipi-dbi.c >>> index c83eeb7..e10fa4b 100644 >>> --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c >>> +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c >>> @@ -183,7 +183,8 @@ static int mipi_dbi_buf_copy(void *dst, struct >>> drm_framebuffer *fb, >>> dev_err_once(fb->dev->dev, "Format is not supported: %s\n", >>> drm_get_format_name(fb->format->format, >>> &format_name)); >>> - return -EINVAL; >>> + ret = -EINVAL; >>> + break; >>> } >>> if (import_attach) >>> >> >> >> I just realized that the next line here can mask ret. >> >> >> if (import_attach) >> ret = dma_buf_end_cpu_access(import_attach->dmabuf, >> DMA_FROM_DEVICE); >> >> So, we should either ignore the return value from >> dma_buf_end_cpu_access() always or add some logic to ignore it if ret >> is already an error. >> >> In some of the other patches I have been sending, we have the same >> situation. I those, I have opted to just ignore the return value from >> dma_buf_end_cpu_access(). e.g... >> >> >> if (import_attach) >> dma_buf_end_cpu_access(import_attach->dmabuf, DMA_FROM_DEVICE); >> >> Is this a reasonable thing to do? > > mipi_dbi_buf_copy() can be used by other rgb565 controllers, hence > the format check I think. So when that happens, it can be moved to > tinydrm-helpers. > > Currently it's not possible to get an illegal format, since mipi-dbi > only supports those two formats. > Userspace can't set an illegal format, beacuse it's checked: > drm_atomic_commit -> drm_atomic_check_only -> drm_atomic_plane_check -> > drm_plane_check_pixel_format > > So I think we can just leave this alone, or put the check before > import_attach if you really want to put this straight. > I guess we can just leave it alone for now. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-07 18:00 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-08-01 20:14 [PATCH] drm/tinydrm: mipi-dbi: Fix unbalanced DMA access David Lechner 2017-08-02 18:51 ` Noralf Trønnes 2017-08-03 22:41 ` David Lechner 2017-08-04 6:49 ` Noralf Trønnes 2017-08-07 18:00 ` David Lechner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox