From: Eric Anholt <eta@lclark.edu>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Jon Smirl <jonsmirl@yahoo.com>,
kronos@kronoz.cjb.net,
Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-fbdev-devel@lists.sourceforge.net,
DRI <dri-devel@lists.sourceforge.net>,
Jeff Garzik <jgarzik@pobox.com>
Subject: Re: [Dri-devel] Re: [Linux-fbdev-devel] DRM and pci_driver conversion
Date: Thu, 23 Oct 2003 16:46:20 -0700 [thread overview]
Message-ID: <1066952780.22390.15.camel@leguin> (raw)
In-Reply-To: <Pine.LNX.4.44.0310231541000.3421-100000@home.osdl.org>
On Thu, 2003-10-23 at 16:23, Linus Torvalds wrote:
> [ Jeff: is that PCI ROM enable _really_ that complicated? Ouch. Or is
> there some helper function I missed? ]
>
> On Thu, 23 Oct 2003, Jon Smirl wrote:
> >
> > I don't think DRM drivers are doing things correctly yet. DRM is missing the
> > code for marking PCI resources as being in use while DRM is using them. This
> > could lead to problems with hotplug. XFree is also mapping PCI ROMs in without
> > informing the kernel and that can definitely cause problems.
>
> Absolutely. Changing PCI configurations without telling the kernel _will_
> cause problems. Especially for hotplug systems, but it's also very iffy to
> do if the card is behind a PCI bridge, since you have to take bridge
> resources into account (and know which bridges are transparent, which are
> not, etc etc).
>
> The kernel spends a lot of effort on getting this right, and even so it
> fails every once in a while (devices that use IO or memory regions without
> announcing them in the standard BAR's are quite common, and the kernel has
> to have special quirk entries for things like that).
>
> Few enough drivers actually want to enable the roms, but the code should
> look something like
>
> /* Assign space for ROM resource if not already assigned. Ugly. */
> if (!pci_resource_start(dev, PCI_ROM_RESOURCE))
> if (pci_assign_resource(dev, PCI_ROM_RESOURCE) < 0)
> return -ENOMEM;
>
> /* Enable it. This is too ugly */
> if (!(pci_resource_flags(dev, PCI_ROM_RESOURCE) & PCI_ROM_ADDRESS_ENABLE)) {
> u32 val;
> pci_read_config_dword(dev, PCI_ROM_ADDRESS, &val);
> val |= PCI_ROM_ADDRESS_ENABLE;
> pci_write_config_dword(dev, PCI_ROM_ADDRESS, val);
> pci_resource_flags(dev, PCI_ROM_RESOURCE) |= PCI_ROM_ADDRESS_ENABLE;
> }
>
>
> /* Enable the device, and regular resources */
> if (pci_enable_device(dev))
> return -ENODEV;
>
> pci_set_master(dev); /* If we want to */
> pci_set_mwi(dev); /* If we want to */
>
> (Yeah, that is more complex than it really should need to be. That's just
> a sign of exactly how few device drivers tend to want to do this: the
> usual helper stuff is all geared for the normal case).
>
> > new style probe
> > if (new probe has device)
> > mark resources in use
>
> You shouldn't need to mark the resources in use. Just registering the
> driver should do everything for you, including making sure that no other
> driver will register that device.
>
> Of course, if you are worried about mixing with drivers that use the old
> "find device and just use it", then yes, you'll need to mark the resources
> in use. That can be as trivial as just doing a
>
> if (pci_request_regions(dev, "drivername") < 0)
> return -EAIIEEEE!;
>
> in the probe function (but then you need to remember to release them in
> the drop function).
However, the DRM is now using the old-style probing instead, because of
the radeonfb conflict. In the case of the DRM, we want drivers to
coexist, at least when loaded in the FB then DRM order. What should the
DRM be doing exactly in this case? Is it exactly what Jon Smirl said,
or something else?
--
Eric Anholt eta@lclark.edu
http://people.freebsd.org/~anholt/ anholt@FreeBSD.org
next prev parent reply other threads:[~2003-10-23 23:46 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1066703516.646.24.camel@leguin>
2003-10-23 19:04 ` DRM and pci_driver conversion Kronos
2003-10-23 21:10 ` [Linux-fbdev-devel] " Eric Anholt
2003-10-23 21:31 ` Jon Smirl
2003-10-23 23:23 ` [Dri-devel] " Linus Torvalds
2003-10-23 23:46 ` Eric Anholt [this message]
2003-10-24 1:19 ` [Dri-devel] " Jeff Garzik
2003-10-24 1:52 ` [Dri-devel] Re: [Linux-fbdev-devel] " Jon Smirl
2003-10-24 3:47 ` Multiple drivers for same hardware:, was: " Jon Smirl
2003-10-24 4:40 ` Linus Torvalds
2003-10-28 18:00 ` James Simmons
2003-10-24 16:44 ` [Dri-devel] " Linus Torvalds
2003-10-24 16:57 ` [Dri-devel] Re: [Linux-fbdev-devel] " Petr Vandrovec
2003-10-24 17:59 ` Linus Torvalds
2003-10-24 18:34 ` Jon Smirl
2003-10-24 19:45 ` [Dri-devel] " Ivan Kokshaysky
2003-10-24 19:08 ` Ivan Kokshaysky
2003-10-24 17:06 ` Jeff Garzik
2003-10-24 1:50 ` Jon Smirl
2003-10-25 17:29 ` Egbert Eich
2003-10-25 18:37 ` [Dri-devel] Re: [Linux-fbdev-devel] " Linus Torvalds
2003-10-25 19:17 ` [Dri-devel] " Jeff Garzik
2003-10-27 14:37 ` Ingo Oeser
2003-10-27 15:14 ` Keith Whitwell
2003-10-27 15:38 ` Jeff Garzik
[not found] ` <20031027153824.GA19711@gtf.org>
2003-10-27 15:50 ` Keith Whitwell
[not found] ` <200310271537.30435.ioe-lkml@rameria.de>
2003-10-27 15:43 ` Jeff Garzik
2003-10-28 10:53 ` [Dri-devel] Re: [Linux-fbdev-devel] " Ingo Oeser
2003-10-25 21:02 ` [Dri-devel] " Jon Smirl
2003-10-25 22:07 ` Benjamin Herrenschmidt
2003-10-27 15:10 ` Eric W. Biederman
2003-10-27 15:10 ` Keith Whitwell
[not found] ` <20031027114006.A66611@xfree86.org>
2003-10-27 19:38 ` Ian Romanick
2003-10-27 21:32 ` Linus Torvalds
2003-10-27 23:55 ` Benjamin Herrenschmidt
2003-10-28 2:13 ` Linus Torvalds
2003-10-28 3:27 ` Philip Brown
2003-10-28 19:40 ` James Simmons
2003-10-28 21:35 ` Benjamin Herrenschmidt
2003-10-28 22:09 ` Jon Smirl
2003-10-28 22:26 ` Benjamin Herrenschmidt
2003-10-28 22:54 ` Linus Torvalds
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=1066952780.22390.15.camel@leguin \
--to=eta@lclark.edu \
--cc=dri-devel@lists.sourceforge.net \
--cc=jgarzik@pobox.com \
--cc=jonsmirl@yahoo.com \
--cc=kronos@kronoz.cjb.net \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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).