linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiho Chu <jiho.chu@samsung.com>
To: Oded Gabbay <ogabbay@kernel.org>
Cc: David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Jason Gunthorpe <jgg@nvidia.com>,
	John Hubbard <jhubbard@nvidia.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Yuji Ishikawa <yuji2.ishikawa@toshiba.co.jp>,
	Daniel Stone <daniel@fooishbar.org>,
	Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	Jeffrey Hugo <quic_jhugo@quicinc.com>,
	Christoph Hellwig <hch@infradead.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>,
	Maciej Kwapulinski <maciej.kwapulinski@linux.intel.com>
Subject: Re: [RFC PATCH 3/3] drm: add dedicated minor for accelerator devices
Date: Tue, 25 Oct 2022 15:43:30 +0900	[thread overview]
Message-ID: <20221025154330.a3a839357363da6d5de96c89@samsung.com> (raw)
In-Reply-To: <20221022214622.18042-4-ogabbay@kernel.org>


On Sun, 23 Oct 2022 00:46:22 +0300
Oded Gabbay <ogabbay@kernel.org> wrote:

> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index b58ffb1433d6..c13701a8d4be 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -56,6 +56,9 @@ MODULE_LICENSE("GPL and additional rights");
>  static DEFINE_SPINLOCK(drm_minor_lock);
>  static struct idr drm_minors_idr;
>  
> +static DEFINE_SPINLOCK(accel_minor_lock);
> +static struct idr accel_minors_idr;
> +
>  /*
>   * If the drm core fails to init for whatever reason,
>   * we should prevent any drivers from registering with it.
> @@ -94,6 +97,8 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
>  		return &dev->primary;
>  	case DRM_MINOR_RENDER:
>  		return &dev->render;
> +	case DRM_MINOR_ACCEL:
> +		return &dev->accel;
>  	default:
>  		BUG();
>  	}
> @@ -108,9 +113,15 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
>  
>  	put_device(minor->kdev);
>  
> -	spin_lock_irqsave(&drm_minor_lock, flags);
> -	idr_remove(&drm_minors_idr, minor->index);
> -	spin_unlock_irqrestore(&drm_minor_lock, flags);
> +	if (minor->type == DRM_MINOR_ACCEL) {
> +		spin_lock_irqsave(&accel_minor_lock, flags);
> +		idr_remove(&accel_minors_idr, minor->index);
> +		spin_unlock_irqrestore(&accel_minor_lock, flags);
> +	} else {
> +		spin_lock_irqsave(&drm_minor_lock, flags);
> +		idr_remove(&drm_minors_idr, minor->index);
> +		spin_unlock_irqrestore(&drm_minor_lock, flags);
> +	}
>  }
>  
>  static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
> @@ -127,13 +138,23 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
>  	minor->dev = dev;
>  
>  	idr_preload(GFP_KERNEL);
> -	spin_lock_irqsave(&drm_minor_lock, flags);
> -	r = idr_alloc(&drm_minors_idr,
> -		      NULL,
> -		      64 * type,
> -		      64 * (type + 1),
> -		      GFP_NOWAIT);
> -	spin_unlock_irqrestore(&drm_minor_lock, flags);
> +	if (type == DRM_MINOR_ACCEL) {
> +		spin_lock_irqsave(&accel_minor_lock, flags);
> +		r = idr_alloc(&accel_minors_idr,
> +			NULL,
> +			64 * (type - DRM_MINOR_ACCEL),
> +			64 * (type - DRM_MINOR_ACCEL + 1),
> +			GFP_NOWAIT);
> +		spin_unlock_irqrestore(&accel_minor_lock, flags);
> +	} else {
> +		spin_lock_irqsave(&drm_minor_lock, flags);
> +		r = idr_alloc(&drm_minors_idr,
> +			NULL,
> +			64 * type,
> +			64 * (type + 1),
> +			GFP_NOWAIT);
> +		spin_unlock_irqrestore(&drm_minor_lock, flags);
> +	}

Hi,
There are many functions which checks drm type and decides its behaviors. It's good to
re-use exiting codes, but accel devices use totally different major/minor, and so it needs to be moved to 
/drvier/accel/ (maybe later..). How about seperating functions for alloc/release minor (accel_minor_alloc..)? 
also, for others which have drm type related codes.




> @@ -607,6 +652,14 @@ static int drm_dev_init(struct drm_device *dev,
>  	/* no per-device feature limits by default */
>  	dev->driver_features = ~0u;
>  
> +	if (drm_core_check_feature(dev, DRIVER_COMPUTE_ACCEL) &&
> +				(drm_core_check_feature(dev, DRIVER_RENDER) ||
> +				drm_core_check_feature(dev, DRIVER_MODESET))) {
> +
> +		DRM_ERROR("DRM driver can't be both a compute acceleration and graphics driver\n");
> +		return -EINVAL;
> +	}
> +

It's fine for the device only for acceleration, but can't graphic devices have acceleration feature?


Thanks,
Jiho Chu

  parent reply	other threads:[~2022-10-25  6:43 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-22 21:46 [RFC PATCH 0/3] new subsystem for compute accelerator devices Oded Gabbay
2022-10-22 21:46 ` [RFC PATCH 1/3] drivers/accel: add new kconfig and update MAINTAINERS Oded Gabbay
2022-10-23 12:40   ` Greg Kroah-Hartman
2022-10-24  7:19     ` Oded Gabbay
2022-10-24 15:01   ` Jeffrey Hugo
2022-10-22 21:46 ` [RFC PATCH 2/3] drm: define new accel major and register it Oded Gabbay
2022-10-23 12:40   ` Greg Kroah-Hartman
2022-10-24  7:23     ` Oded Gabbay
2022-10-24  7:52       ` Dave Airlie
2022-10-24 15:08         ` Jeffrey Hugo
2022-10-22 21:46 ` [RFC PATCH 3/3] drm: add dedicated minor for accelerator devices Oded Gabbay
2022-10-23 12:41   ` Greg Kroah-Hartman
2022-10-24  7:23     ` Oded Gabbay
2022-10-24 15:21   ` Jeffrey Hugo
2022-10-24 17:43     ` Oded Gabbay
2022-10-25 13:26       ` Michał Winiarski
2022-10-26  6:38         ` Oded Gabbay
2022-10-25  6:43   ` Jiho Chu [this message]
2022-10-26  6:38     ` Oded Gabbay
2022-10-28  6:56       ` Jiho Chu
2022-10-23 14:02 ` [RFC PATCH 0/3] new subsystem for compute " Bagas Sanjaya
2022-10-23 14:14   ` Greg Kroah-Hartman
2022-10-24 11:55 ` Thomas Zimmermann
2022-10-24 12:35   ` Greg Kroah-Hartman
2022-10-24 12:43   ` Oded Gabbay
2022-10-25  2:21     ` John Hubbard
2022-10-25  2:27       ` Dave Airlie
2022-10-25 11:15         ` Jason Gunthorpe
2022-10-25 14:21           ` Alex Deucher
2022-10-25 14:34             ` Jason Gunthorpe
2022-10-25 14:43               ` Alex Deucher
2022-10-24 13:55 ` Alex Deucher
2022-10-24 14:41   ` Oded Gabbay
2022-10-24 15:10     ` Alex Deucher
2022-10-26  6:10       ` Oded Gabbay

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=20221025154330.a3a839357363da6d5de96c89@samsung.com \
    --to=jiho.chu@samsung.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=arnd@arndb.de \
    --cc=daniel@ffwll.ch \
    --cc=daniel@fooishbar.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=jacek.lawrynowicz@linux.intel.com \
    --cc=jagan@amarulasolutions.com \
    --cc=jgg@nvidia.com \
    --cc=jhubbard@nvidia.com \
    --cc=khilman@baylibre.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maciej.kwapulinski@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=ogabbay@kernel.org \
    --cc=quic_jhugo@quicinc.com \
    --cc=tvrtko.ursulin@linux.intel.com \
    --cc=tzimmermann@suse.de \
    --cc=yuji2.ishikawa@toshiba.co.jp \
    /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).