[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2MMCIe5wND2XPqE@kroah.com>
Date: Thu, 3 Nov 2022 01:32:08 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Oded Gabbay <ogabbay@...nel.org>
Cc: David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org,
dri-devel@...ts.freedesktop.org, Jason Gunthorpe <jgg@...dia.com>,
John Hubbard <jhubbard@...dia.com>,
Alex Deucher <alexander.deucher@....com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
Yuji Ishikawa <yuji2.ishikawa@...hiba.co.jp>,
Jiho Chu <jiho.chu@...sung.com>,
Daniel Stone <daniel@...ishbar.org>,
Tvrtko Ursulin <tvrtko.ursulin@...ux.intel.com>,
Jeffrey Hugo <quic_jhugo@...cinc.com>,
Christoph Hellwig <hch@...radead.org>,
Kevin Hilman <khilman@...libre.com>,
Jagan Teki <jagan@...rulasolutions.com>,
Jacek Lawrynowicz <jacek.lawrynowicz@...ux.intel.com>,
Maciej Kwapulinski <maciej.kwapulinski@...ux.intel.com>
Subject: Re: [RFC PATCH v2 1/3] drivers/accel: define kconfig and register a
new major
On Wed, Nov 02, 2022 at 10:34:03PM +0200, Oded Gabbay wrote:
> --- /dev/null
> +++ b/drivers/accel/Kconfig
> @@ -0,0 +1,24 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# Compute Acceleration device configuration
> +#
> +# This framework provides support for compute acceleration devices, such
> +# as, but not limited to, Machine-Learning and Deep-Learning acceleration
> +# devices
> +#
> +menuconfig ACCEL
> + tristate "Compute Acceleration Framework"
> + depends on DRM
> + help
> + Framework for device drivers of compute acceleration devices, such
> + as, but not limited to, Machine-Learning and Deep-Learning
> + acceleration devices.
> + If you say Y here, you need to select the module that's right for
> + your acceleration device from the list below.
> + This framework is integrated with the DRM subsystem as compute
> + accelerators and GPUs share a lot in common and can use almost the
> + same infrastructure code.
> + Having said that, acceleration devices will have a different
> + major number than GPUs, and will be exposed to user-space using
> + different device files, called accel/accel* (in /dev, sysfs
> + and debugfs)
Module name if "M" is chosen?
> +static char *accel_devnode(struct device *dev, umode_t *mode)
> +{
> + return kasprintf(GFP_KERNEL, "accel/%s", dev_name(dev));
> +}
> +
> +static CLASS_ATTR_STRING(accel_version, 0444, "accel 1.0.0 20221018");
What is a version number doing here?
Please no, I understand that DRM has this, but it really does not make
sense for any in-kernel code. And that's not how sysfs is supposed to
work anyway (if a file is present, the value is documented, if the file
is not present, the value is just not there, userspace has to handle
it all.)
> +
> +/**
> + * accel_sysfs_init - initialize sysfs helpers
> + *
> + * This is used to create the ACCEL class, which is the implicit parent of any
> + * other top-level ACCEL sysfs objects.
> + *
> + * You must call accel_sysfs_destroy() to release the allocated resources.
> + *
> + * Return: 0 on success, negative error code on failure.
> + */
> +static int accel_sysfs_init(void)
> +{
> + int err;
> +
> + accel_class = class_create(THIS_MODULE, "accel");
> + if (IS_ERR(accel_class))
> + return PTR_ERR(accel_class);
> +
> + err = class_create_file(accel_class, &class_attr_accel_version.attr);
Hint, if you ever find yourself adding sysfs files "by hand" like this,
you are doing something wrong. The driver code should create them
automatically for you by setting up default groups, _OR_ as in this
case, you shouldn't be adding the file at all :)
> +static void accel_sysfs_destroy(void)
> +{
> + if (IS_ERR_OR_NULL(accel_class))
> + return;
> + class_remove_file(accel_class, &class_attr_accel_version.attr);
No need to manually destroy files when you remove a device. But you
will remove this file anyway for the next version of this patch, so it's
not a big deal :)
> + class_destroy(accel_class);
> + accel_class = NULL;
> +}
> +
> +static int accel_stub_open(struct inode *inode, struct file *filp)
> +{
> + DRM_DEBUG("Operation not supported");
ftrace is wonderful, please use that and not hand-rolled custom "I am
here!" type messages like this.
thanks,
greg k-h
Powered by blists - more mailing lists