mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Corbet <corbet@lwn.net>
To: Jeff Chua <jeff.chua.linux@gmail.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: 2nd attempt: help with dma_alloc_coherent() + dma_free_coherent()
Date: Tue, 8 Jan 2013 09:24:22 -0700	[thread overview]
Message-ID: <20130108092422.08fa669c@lwn.net> (raw)
In-Reply-To: <CAAJw_Zv8O1LPX-jmpg3fvNrWMLWbQC=1tbZ6T7nsm6cyC008fg@mail.gmail.com>

On Tue, 8 Jan 2013 23:51:59 +0800
Jeff Chua <jeff.chua.linux@gmail.com> wrote:

> I'm trying to understand how this oops in the diva driver and it's just a
> simple dma_alloc_coherent() followed by dma_free_coherent(), but it oops.
> Why?

Hmm...from a quick look...

> static u32 *clock_data_addr;
> static dma_addr_t clock_data_bus_addr;
> 
>         if((clock_data_addr = dma_alloc_coherent(NULL, PAGE_SIZE,
>                         &clock_data_bus_addr, GFP_KERNEL)) != 0) {
>                 printk(KERN_INFO "dma_alloc_coherent ok\n");
>                 memset (clock_data_addr, 0x00, PAGE_SIZE);
>         } else
>                 printk(KERN_INFO "dma_alloc_coherent bad!!!\n");
>         if(clock_data_addr) {
>                 printk(KERN_INFO "dma_free_coherent!!!\n");
>                 dma_free_coherent(NULL, PAGE_SIZE, clock_data_addr,
>                         clock_data_bus_addr);
>                 clock_data_addr = NULL;
>         }

Perhaps passing NULL as your device structure pointer might just have
something to do with a crash due to a null pointer dereference?  If you're
doing DMA, you should have a device.  Try passing it and you might just
find that things work better.

(Incidentally, this:

> IP: [<ffffffff813ec01c>] iommu_no_mapping+0xc/0xee

is a fairly good clue as well - it's trying to dereference the device
structure pointer).

jon

  reply	other threads:[~2013-01-08 16:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 15:51 Jeff Chua
2013-01-08 16:24 ` Jonathan Corbet [this message]
2013-01-08 16:39 ` Linus Torvalds
2013-01-08 17:17   ` Jeff Chua
2013-01-08 17:24     ` Linus Torvalds
2013-01-08 22:25       ` Jeff Chua

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=20130108092422.08fa669c@lwn.net \
    --to=corbet@lwn.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeff.chua.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®