From: Andrew Morton <akpm@osdl.org>
To: Parag Warudkar <kernel-stuff@comcast.net>
Cc: bcollins@debian.org, linux-kernel@vger.kernel.org,
linux1394-devel@lists.sourceforge.net
Subject: Re: [PATCH] ohci1394: dma_pool_destroy while in_atomic() && irqs_disabled()
Date: Sun, 30 Jan 2005 13:17:23 -0800 [thread overview]
Message-ID: <20050130131723.781991d3.akpm@osdl.org> (raw)
In-Reply-To: <41FD498C.9000708@comcast.net>
Parag Warudkar <kernel-stuff@comcast.net> wrote:
>
> Problem - ohci1394.c:ohci_devctl ends up calling dma_pool_destroy from
> invalid context. Below is the dmesg output when I exit Kino after video
> capture -
>
> Debug: sleeping function called from invalid context at
> include/asm/semaphore.h:107
> in_atomic():1, irqs_disabled():1
> [<c0104c2e>] dump_stack+0x1e/0x20
> [<c011f8a2>] __might_sleep+0xa2/0xc0
> [<c028c660>] dma_pool_destroy+0x20/0x140
> [<f0b7affe>] free_dma_rcv_ctx+0x8e/0x150 [ohci1394]
> [<f0b774a4>] ohci_devctl+0x214/0x9b0 [ohci1394]
> [<f0e7aa99>] handle_iso_listen+0x2d9/0x310 [raw1394]
> [<f0e7f22b>] state_connected+0x29b/0x2b0 [raw1394]
> [<f0e7f2de>] raw1394_write+0x9e/0xd0 [raw1394]
> [<c0183ef2>] vfs_write+0xc2/0x170
> [<c018406b>] sys_write+0x4b/0x80
> [<c0103cb1>] sysenter_past_esp+0x52/0x75
Yes, that's certainly wrong.
> Attached patch against 2.6.11-rc2 (tested to work normally with a
> camcorder device) enables ohci_devctl to defer the work of destroying
> the dma pool by using a work queue, so the dma pool is destroyed in a
> valid context and we no longer get an error in dmesg (duh :)
yup. But what happens if someone removes the module while
ohci_free_dma_work_fn() is still pending?
Suggestions:
- The work_struct cannot be on the stack. The code as you have it will
read gunk from the stack when the delayed work executes. The work_struct
needs to be placed into some ohci data structure which has the appropriate
lifetime. That might be struct ti_ohci. Or not.
- We'll need a flush_workqueue() in the teardown function for that data
structure to ensure that any pending callbacks have completed before we
free the storage.
Care needs to be taken to ensure that the work_struct is suitably
initialised so that the flush_workqueue() will work OK even if the
callback has never been scheduled.
- You have several typecasts between struct pci_pool* and void*. These
defeat typechecking. It's better to leave these casts out.
next prev parent reply other threads:[~2005-01-30 21:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-30 20:54 [PATCH] ohci1394: dma_pool_destroy while in_atomic() && irqs_disabled() Parag Warudkar
2005-01-30 21:17 ` Andrew Morton [this message]
2005-01-30 22:49 ` Parag Warudkar
2005-01-30 23:02 ` Andrew Morton
2005-01-31 1:19 ` Parag Warudkar
2005-01-31 23:26 ` Parag Warudkar
2005-02-11 15:35 ` Dan Dennedy
2005-02-11 18:43 ` Jody McIntyre
2005-02-12 3:54 ` Parag Warudkar
2005-02-18 15:32 ` Dan Dennedy
2005-02-18 15:42 ` Parag Warudkar
2005-02-19 6:36 ` Jody McIntyre
2005-02-19 15:06 ` Parag Warudkar
-- strict thread matches above, loose matches on Subject: below --
2005-02-19 19:36 David Brownell
2005-02-19 20:50 ` Parag Warudkar
2005-02-19 21:13 ` David Brownell
2005-02-19 22:55 ` Jody McIntyre
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=20050130131723.781991d3.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=bcollins@debian.org \
--cc=kernel-stuff@comcast.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
/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