All of lore.kernel.org
 help / color / mirror / Atom feed
From: Emil Velikov <emil.l.velikov@gmail.com>
To: Jammy Zhou <Jammy.Zhou@amd.com>, dri-devel@lists.freedesktop.org
Cc: Frank.Min@amd.com, emil.l.velikov@gmail.com
Subject: Re: [PATCH 1/2] Add device enumeration interface (v2)
Date: Mon, 27 Apr 2015 19:07:02 +0000	[thread overview]
Message-ID: <553E88D6.80606@gmail.com> (raw)
In-Reply-To: <1429847046-12807-1-git-send-email-Jammy.Zhou@amd.com>

Hi Jammy, Frank

As far as I can see you're trying to get a different version of
drmGetBusid(). With the DRM_IOCTL_{G,S}ET_UNIQUE ioctl being lovely as
it is I do see your point, but I'm not sure that the current design will
be too useful.

Do we have any upcoming users for this new function, can you share a bit
about the usecase ?

On 24/04/15 03:44, Jammy Zhou wrote:
> drmGetDevices interface is added to enumernate GPU devices on the system
> 
> v2: rebase the code and some improvement for the coding style
> 
> Signed-off-by: Frank Min <Frank.Min@amd.com>
> Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> (v2)
> ---
>  Makefile.am |  3 ++-
>  xf86drm.c   | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  xf86drm.h   | 18 ++++++++++++++++++
>  3 files changed, 68 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 42d3d7f..8236ed8 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -89,7 +89,8 @@ SUBDIRS = \
>  libdrm_la_LTLIBRARIES = libdrm.la
>  libdrm_ladir = $(libdir)
>  libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined
> -libdrm_la_LIBADD = @CLOCK_LIB@
> +libdrm_la_LIBADD = @CLOCK_LIB@ \
> +		@PCIACCESS_LIBS@
>  
>  libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm
>  AM_CFLAGS = \
> diff --git a/xf86drm.c b/xf86drm.c
> index ffc53b8..4d67861 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -63,6 +63,7 @@
>  
>  #include "xf86drm.h"
>  #include "libdrm.h"
> +#include <pciaccess.h>
>  
>  #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
>  #define DRM_MAJOR 145
> @@ -2817,3 +2818,50 @@ char *drmGetRenderDeviceNameFromFd(int fd)
>  {
>  	return drmGetMinorNameForFD(fd, DRM_NODE_RENDER);
>  }
> +
> +/**
> + * Enumerate the GPU devices on the system
> + *
> + * \param devs device array set to return the device information
> + * (if NULL, the number of device is returned)
> + * \param vendor the vendor ID for GPU devices to list
> + * (optional, if not specified, all GPU devices are returned)
> + *
> + * \return the number of GPU devices
> + */
> +int drmGetDevices(drmDevicePtr devs, uint16_t vendor)
> +{
> +	struct pci_device_iterator * iter;
> +	struct pci_device * dev;
> +	uint32_t count = 0;
> +
> +	if (pci_system_init())
> +		return -EINVAL;
> +
> +	iter = pci_slot_match_iterator_create(NULL);
> +	if (!iter)
> +		return -EINVAL;
> +
> +	while ((dev = pci_device_next(iter))) {
> +		if (((dev->device_class == 0x30000) ||
> +			(dev->device_class == 0x38000)) &&
Any particular reason why "3D controller" (0x32000) is omitted ?

> +			((vendor == 0) || (dev->vendor_id == vendor))){
> +			if (devs) {
> +				devs[count].domain = dev->domain;
> +				devs[count].bus = dev->bus;
> +				devs[count].dev = dev->dev;
> +				devs[count].func = dev->func;
> +				devs[count].vendor_id = dev->vendor_id;
> +				devs[count].device_id = dev->device_id;
> +				devs[count].subvendor_id = dev->subvendor_id;
> +				devs[count].subdevice_id = dev->subdevice_id;
> +				devs[count].revision_id = dev->revision;
> +			}
> +			count++;
> +		}
> +	}
> +
> +	pci_iterator_destroy(iter);
> +	pci_system_cleanup();
Using libpciaccess, will give you the number of PCI devices available on
the system rather than the ones accessible - think about platform
devices and/or devices without a drm driver.

Another solution will be to get the information based on the
primary/control/render nodes available. This will also allow one to know
what the device can be used for - be that via a separate parameter set
by the function or having different functions altogether.

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

  parent reply	other threads:[~2015-04-27 18:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-24  3:44 [PATCH 1/2] Add device enumeration interface (v2) Jammy Zhou
2015-04-24  3:44 ` [PATCH 2/2] Fix one warning Jammy Zhou
2015-04-24 14:30   ` Jan Vesely
2015-04-27  1:40     ` Zhou, Jammy
2015-04-27 19:55       ` Jan Vesely
2015-04-28 14:28       ` Jan Vesely
2015-04-27 19:07 ` Emil Velikov [this message]
2015-04-28  3:26   ` [PATCH 1/2] Add device enumeration interface (v2) Zhou, Jammy
2015-04-28 16:17     ` Emil Velikov
2015-05-04  6:24       ` Zhou, Jammy

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=553E88D6.80606@gmail.com \
    --to=emil.l.velikov@gmail.com \
    --cc=Frank.Min@amd.com \
    --cc=Jammy.Zhou@amd.com \
    --cc=dri-devel@lists.freedesktop.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.