All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: John Whitney <jwhitney-linuxppc@sands-edge.com>
Cc: Eugene Surovegin <ebs@ebshome.net>,
	Dan Malek <dan@embeddededge.com>,
	Matt Porter <mporter@kernel.crashing.org>,
	linuxppc-dev list <linuxppc-dev@lists.linuxppc.org>,
	Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: Re: Problems with dma_alloc_coherent()
Date: Fri, 02 Apr 2004 11:22:34 +1000	[thread overview]
Message-ID: <1080868954.1286.33.camel@gaston> (raw)
In-Reply-To: <CDB1AF42-8413-11D8-9FF0-000A95A07384@sands-edge.com>

Ok, time to step in....

> Yes, after thinking about it, it made more sense to modify the "struct
> bus_type" structure to have the bus memory map offset.  We could then
> have an OCP bus type, PLB bus type, etc.  However, that would be a core
> kernel change, and I don't know how easy it is to get those pushed back
> into the mainline.
> 
> Also, after looking at the kernel code more (I'm fairly new to 2.6,
> which I'm sure you've deduced), it looks like most routines expect
> instances of type "bus_type" to be enumeratable/hot-swappable, and many
> of the busses I'd use in the embedded world wouldn't fit.  I don't know
> how easy or difficult it would be to use the bus_type code construct in
> this fashion.

Please, bring this discussion to linux-kernel. The problem is similar
to some issue I'm having on ppc64 with iommu. In a more general way,
I want to be able to attach additional data to a struct device for use
by the DMA code, that can be pointers to the actual DMA functions,
pointer to the PHB structure, pointer to the iommu table, bus offset,
etc....

Adding such things to bus_type isn't a good option. Especially since
several platform may have different needs for the same bus type, or
several _instances_ of a bus of a given type may have different needs
(typically, the iommu info or DMA offset may be different for 2 busses
of the same type).

What struct bus_type provides is actually the "class" of the device
object in object terminology (which is yet different from struct
"class" in the driver model terminology, I know, this is all quite
confusing). That is, it defines the actual struct type that embeds
that struct device. It does _not_ represent an instance of that bus.

There is a hook in the device model that can be used to add your own
data to a device (typically to put something in device->platform_data).

This hook is called at device_register() and device_unregister() time,
however, it is bogus for a simple reason: Lifetime rules. The struct
device beeing a kobject, it can stay around after beeing unregistered,
at least until the last reference to the kobkjet gets dropped.
Theorically, we should also "remove" whatever we put in platform_data
at this same deletion time, and not earlier, or we may race with
something currently using the device.

This race is unlikely imho as I doubt we unregister devices that still
have a driver attached, and the driver is probably the only thing that
will actually use that platform data (indirectly via things like the
DMA API) but still...

Ben.



  reply	other threads:[~2004-04-02  1:23 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-01 15:59 Problems with dma_alloc_coherent() John Whitney
2004-04-01 16:30 ` John Whitney
2004-04-01 16:51 ` Dan Malek
2004-04-01 17:01 ` Tom Rini
2004-04-01 17:05 ` Matt Porter
2004-04-01 17:51   ` John Whitney
2004-04-01 18:16     ` Matt Porter
2004-04-01 18:19     ` Eugene Surovegin
2004-04-01 18:33       ` Eugene Surovegin
2004-04-01 18:33       ` John Whitney
2004-04-01 18:40         ` Eugene Surovegin
2004-04-01 18:48           ` John Whitney
2004-04-01 18:55       ` Dan Malek
2004-04-01 18:59         ` Eugene Surovegin
2004-04-01 19:10           ` John Whitney
2004-04-01 19:17             ` Eugene Surovegin
2004-04-01 19:35               ` John Whitney
2004-04-02  1:22                 ` Benjamin Herrenschmidt [this message]
2004-04-01 20:52               ` Michael R. Zucca
2004-04-01 22:00                 ` Eugene Surovegin
2004-04-01 22:39                   ` Michael R. Zucca
2004-04-02 16:50                   ` John Whitney
2004-04-02 18:50                     ` Michael R. Zucca
2004-04-02 19:27                       ` John Whitney
2004-04-02 20:20                         ` Michael R. Zucca
2004-04-02 21:01                           ` John Whitney
2004-04-03  7:54                             ` Adrian Cox
2004-04-03 12:43                               ` John Whitney
2004-04-05  9:05                                 ` Adrian Cox
2004-04-03 17:33                               ` Brad Boyer
2004-04-03 23:17                                 ` Paul Mackerras
2004-04-04  8:15                                 ` Adrian Cox
2004-04-02 22:54                     ` Paul Mackerras
2004-04-03  7:33                       ` Adrian Cox
2004-04-04 22:56                         ` Benjamin Herrenschmidt
2004-04-02  5:45             ` Christoph Hellwig
2004-04-01 20:49           ` Matt Porter

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=1080868954.1286.33.camel@gaston \
    --to=benh@kernel.crashing.org \
    --cc=dan@embeddededge.com \
    --cc=ebs@ebshome.net \
    --cc=jwhitney-linuxppc@sands-edge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.linuxppc.org \
    --cc=mporter@kernel.crashing.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.