[PATCH 0/2][Eoan][SRU Disco] Fix regressions introduced by CMA allocation rework

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/2][Eoan][SRU Disco] Fix regressions introduced by CMA allocation rework

dann frazier-4
BugLink: https://bugs.launchpad.net/bugs/1839395

Clean cherry-picks from upstream.

Nicolin Chen (2):
  dma-contiguous: do not overwrite align in dma_alloc_contiguous()
  dma-contiguous: page-align the size in dma_free_contiguous()

 kernel/dma/contiguous.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--
2.23.0.rc1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2][Eoan][SRU Disco] dma-contiguous: do not overwrite align in dma_alloc_contiguous()

dann frazier-4
From: Nicolin Chen <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1839395

The dma_alloc_contiguous() limits align at CONFIG_CMA_ALIGNMENT for
cma_alloc() however it does not restore it for the fallback routine.
This will result in a size mismatch between the allocation and free
when running into the fallback routines after cma_alloc() fails, if
the align is larger than CONFIG_CMA_ALIGNMENT.

This patch adds a cma_align to take care of cma_alloc() and prevent
the align from being overwritten.

Fixes: fdaeec198ada ("dma-contiguous: add dma_{alloc,free}_contiguous() helpers")
Reported-by: Dafna Hirschfeld <[hidden email]>
Signed-off-by: Nicolin Chen <[hidden email]>
Signed-off-by: Christoph Hellwig <[hidden email]>
(cherry picked from commit c6622a425acd1d2f3a443cd39b490a8777b622d7)
Signed-off-by: dann frazier <[hidden email]>
---
 kernel/dma/contiguous.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index bfc0c17f2a3d4..ea8259f53eda7 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -243,8 +243,9 @@ struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp)
 
  /* CMA can be used only in the context which permits sleeping */
  if (cma && gfpflags_allow_blocking(gfp)) {
- align = min_t(size_t, align, CONFIG_CMA_ALIGNMENT);
- page = cma_alloc(cma, count, align, gfp & __GFP_NOWARN);
+ size_t cma_align = min_t(size_t, align, CONFIG_CMA_ALIGNMENT);
+
+ page = cma_alloc(cma, count, cma_align, gfp & __GFP_NOWARN);
  }
 
  /* Fallback allocation of normal pages */
--
2.23.0.rc1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2][Eoan][SRU Disco] dma-contiguous: page-align the size in dma_free_contiguous()

dann frazier-4
In reply to this post by dann frazier-4
From: Nicolin Chen <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1839395

According to the original dma_direct_alloc_pages() code:
{
        unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;

        if (!dma_release_from_contiguous(dev, page, count))
                __free_pages(page, get_order(size));
}

The count parameter for dma_release_from_contiguous() was page
aligned before the right-shifting operation, while the new API
dma_free_contiguous() forgets to have PAGE_ALIGN() at the size.

So this patch simply adds it to prevent any corner case.

Fixes: fdaeec198ada ("dma-contiguous: add dma_{alloc,free}_contiguous() helpers")
Signed-off-by: Nicolin Chen <[hidden email]>
Reviewed-by: Christoph Hellwig <[hidden email]>
Signed-off-by: Christoph Hellwig <[hidden email]>
(cherry picked from commit f46cc0152501e46d1b3aa5e7eade61145070eab0)
Signed-off-by: dann frazier <[hidden email]>
---
 kernel/dma/contiguous.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index ea8259f53eda7..2bd410f934b32 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -267,7 +267,8 @@ struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp)
  */
 void dma_free_contiguous(struct device *dev, struct page *page, size_t size)
 {
- if (!cma_release(dev_get_cma_area(dev), page, size >> PAGE_SHIFT))
+ if (!cma_release(dev_get_cma_area(dev), page,
+ PAGE_ALIGN(size) >> PAGE_SHIFT))
  __free_pages(page, get_order(size));
 }
 
--
2.23.0.rc1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2][Eoan][SRU Disco] Fix regressions introduced by CMA allocation rework

Seth Forshee
In reply to this post by dann frazier-4
On Wed, Aug 07, 2019 at 06:43:12PM -0600, dann frazier wrote:
> BugLink: https://bugs.launchpad.net/bugs/1839395
>
> Clean cherry-picks from upstream.

The bug says "regression tested only," so how do we know that these
patches fix the issues reported on the bug?

Thanks,
Seth

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2][Eoan][SRU Disco] Fix regressions introduced by CMA allocation rework

dann frazier-4
On Thu, Aug 8, 2019 at 9:35 AM Seth Forshee <[hidden email]> wrote:
>
> On Wed, Aug 07, 2019 at 06:43:12PM -0600, dann frazier wrote:
> > BugLink: https://bugs.launchpad.net/bugs/1839395
> >
> > Clean cherry-picks from upstream.
>
> The bug says "regression tested only," so how do we know that these
> patches fix the issues reported on the bug?

hey Seth,
  I don't directly know, as I don't have the hw in question. I'm just
going on the basis of the upstream discussion:
    https://lkml.org/lkml/2019/7/25/1096
I also don't know if that hw even works w/ Ubuntu - but it seems like
other platforms could be impacted as well.

Background is, anytime I backport subsystem changes like this to an
Ubuntu kernel, I try to watch upstream for "Fixes:" commits that
reference them, as those "Fixes" won't come in naturally from stable
(the fixed commits aren't in a released kernel yet). My logic here is
that these fixes look like the type of changes we would normally pull
in from stable, and therefore would normally be candidates for Ubuntu.

  -dann

  -dann

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2][Eoan][SRU Disco] Fix regressions introduced by CMA allocation rework

Seth Forshee
On Thu, Aug 08, 2019 at 10:48:14AM -0600, dann frazier wrote:

> On Thu, Aug 8, 2019 at 9:35 AM Seth Forshee <[hidden email]> wrote:
> >
> > On Wed, Aug 07, 2019 at 06:43:12PM -0600, dann frazier wrote:
> > > BugLink: https://bugs.launchpad.net/bugs/1839395
> > >
> > > Clean cherry-picks from upstream.
> >
> > The bug says "regression tested only," so how do we know that these
> > patches fix the issues reported on the bug?
>
> hey Seth,
>   I don't directly know, as I don't have the hw in question. I'm just
> going on the basis of the upstream discussion:
>     https://lkml.org/lkml/2019/7/25/1096
> I also don't know if that hw even works w/ Ubuntu - but it seems like
> other platforms could be impacted as well.
>
> Background is, anytime I backport subsystem changes like this to an
> Ubuntu kernel, I try to watch upstream for "Fixes:" commits that
> reference them, as those "Fixes" won't come in naturally from stable
> (the fixed commits aren't in a released kernel yet). My logic here is
> that these fixes look like the type of changes we would normally pull
> in from stable, and therefore would normally be candidates for Ubuntu.

Okay. I agree that it's a good idea to pull in commits that are fixes
for anything we've backported (and I really appreciate the fact that you
are keeping an eye out for them). I was just a little confused by that
statement in the SRU justification, so thanks for clarifying.

Seth

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK/APPLIED[E]: [PATCH 0/2][Eoan][SRU Disco] Fix regressions introduced by CMA allocation rework

Seth Forshee
In reply to this post by dann frazier-4
On Wed, Aug 07, 2019 at 06:43:12PM -0600, dann frazier wrote:
> BugLink: https://bugs.launchpad.net/bugs/1839395
>
> Clean cherry-picks from upstream.

Upstream bug fixes which look reasonable and have been regression
tested.

Acked-by: Seth Forshee <[hidden email]>

Applied to eoan/master-next, thanks!

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [PATCH 0/2][Eoan][SRU Disco] Fix regressions introduced by CMA allocation rework

Kleber Sacilotto de Souza
In reply to this post by dann frazier-4
On 8/8/19 2:43 AM, dann frazier wrote:

> BugLink: https://bugs.launchpad.net/bugs/1839395
>
> Clean cherry-picks from upstream.
>
> Nicolin Chen (2):
>   dma-contiguous: do not overwrite align in dma_alloc_contiguous()
>   dma-contiguous: page-align the size in dma_free_contiguous()
>
>  kernel/dma/contiguous.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>

Acked-by: Kleber Sacilotto de Souza <[hidden email]>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED(D): [PATCH 0/2][Eoan][SRU Disco] Fix regressions introduced by CMA allocation rework

Khaled Elmously
In reply to this post by dann frazier-4
On 2019-08-07 18:43:12 , dann frazier wrote:

> BugLink: https://bugs.launchpad.net/bugs/1839395
>
> Clean cherry-picks from upstream.
>
> Nicolin Chen (2):
>   dma-contiguous: do not overwrite align in dma_alloc_contiguous()
>   dma-contiguous: page-align the size in dma_free_contiguous()
>
>  kernel/dma/contiguous.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> --
> 2.23.0.rc1
>
>
> --
> kernel-team mailing list
> [hidden email]
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team