dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Steven Newbury <steve@snewbury.org.uk>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: drm_device from another device driver? (was: Re: block device backed by DRM buffer object)
Date: Wed, 23 Sep 2015 23:41:38 +0200	[thread overview]
Message-ID: <20150923214138.GA8680@wunner.de> (raw)
In-Reply-To: <47j707.nv5dbe.2u4lbf-qmf@mail.snewbury.org.uk>

Hi,

On Wed, Sep 23, 2015 at 08:37:48PM +0000, Steven Newbury wrote:
> I can't figure out how to get a pointer to the radeon_device struct
> for a specific card, or the parent drm_device from an external device
> driver.

struct device -> struct drm_device: dev_get_drvdata()
struct pci_dev -> struct drm_device: pci_get_drvdata()
struct drm_device -> struct radeon_device: drm_device->dev_private


> I imagine I somehow need to take a reference to the drm class kobject
> for the card in question, and in so doing presumably I should then be
> able to discover the pointer to device.

It sounds like you want to discover the available radeon cards in the
system? If so you could iterate over all pci devices and look for
pci->vendor == PCI_VENDOR_ID_ATI || pci->vendor == PCI_VENDOR_ID_AMD,
then get to the radeon_device as shown above.

However as Christian König pointed out, memory allocation is driver
dependent. For an initial proof of concept it may be simplest to hack
the radeon driver. Then you'll get an idea which parts are generic and
which are driver specific and you can move the generic stuff to a
central broker.

Rather than discovering the VRAM it probably makes more sense to have
drm devices register a set of callbacks with the central broker
(e.g. return amount of currently free VRAM, allocate VRAM for use as
block device, deallocate VRAM, read vector of blocks, write vector
of blocks). The broker could then be controlled from user space via
sysfs or ioctls or whatever.

Best regards,

Lukas
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-09-23 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-21 11:33 block device backed by DRM buffer object Steven Newbury
2015-09-21 13:05 ` Christian König
2015-09-22 20:44   ` Steven Newbury
2015-09-23 20:37     ` drm_device from another device driver? (was: Re: block device backed by DRM buffer object) Steven Newbury
2015-09-23 21:41       ` Lukas Wunner [this message]
2015-09-23 22:52         ` Steven Newbury
2015-09-24  9:41           ` drm_device from another device driver? Christian König

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=20150923214138.GA8680@wunner.de \
    --to=lukas@wunner.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=steve@snewbury.org.uk \
    /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