From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Joel Fernandes <joelf@ti.com>
Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: dma_unmap causing issues with __get_free_pages
Date: Thu, 15 Aug 2013 12:55:45 +0100 [thread overview]
Message-ID: <20130815115545.GD25647@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <520C84DF.5050707@ti.com>
On Thu, Aug 15, 2013 at 02:35:59AM -0500, Joel Fernandes wrote:
> Hi,
>
> I'm having some trouble with using the dma_map/unmap API.
>
> On unmapping a particular page using dma_unmap, it seems that the
> PG_dcache_clean flag is set in the page->flags. This is set by the
> following statement in __dma_page_dev_to_cpu function in
> arch/arm/mm/dma-mapping.c
> set_bit(PG_dcache_clean, &page->flags);
>
> Due to this, on any subsequent page allocations using __get_free_pages,
> the following BUG gets triggered.
Are you calling dma_unmap() after the page has been freed?
> What is correct way to fix this? Why does the page allocator think its a
> BAD page descriptor after the unmap?
Well, on free, this is done:
if (page->flags & PAGE_FLAGS_CHECK_AT_PREP)
page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP;
which clears PG_arch_1. On allocation:
if (unlikely(page_mapcount(page) |
(page->mapping != NULL) |
(atomic_read(&page->_count) != 0) |
(page->flags & PAGE_FLAGS_CHECK_AT_PREP) |
(mem_cgroup_bad_page_check(page)))) {
bad_page(page);
return 1;
}
As PG_arch_1 is part of the PAGE_FLAGS_CHECK_AT_PREP mask, this means that
when a page is freed, it has PG_arch_1 cleared. Therefore, if on allocation
the page now has this bit set, it means that something touched the page
after it was freed. Quite simply, the page was freed while still being
in use. That's very bad and needs fixing.
next prev parent reply other threads:[~2013-08-15 11:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-15 7:35 dma_unmap causing issues with __get_free_pages Joel Fernandes
2013-08-15 11:55 ` Russell King - ARM Linux [this message]
2013-08-15 15:43 ` Joel Fernandes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130815115545.GD25647@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=joelf@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).