Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp753989rwi; Wed, 2 Nov 2022 18:18:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7w+XK4ybJ4pgA/Eg4rXukg0PgJkZiB0rl3Rj0NF8obm9zJHOBq+GuGDkxMgQssHG6qzDwz X-Received: by 2002:a05:6402:280a:b0:461:9845:d9c9 with SMTP id h10-20020a056402280a00b004619845d9c9mr28215157ede.268.1667438311960; Wed, 02 Nov 2022 18:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667438311; cv=none; d=google.com; s=arc-20160816; b=0KMswqztKWtcMFNb11uuKiYTW51rQWQOWsfk2SvFumQ3azOI+f/pxSDBtZJpTnYRMd uAZ4h1oiPm6iECV4dSJJMXHA4Lw5/2swusXwFcusZFVj25+5MAmPjjn5Cj8vaL6ccDfa gB2J0XAUaNKcbG5MDf6FOquDf9oAWAABj6gFgHOANv0/ORbJEUYeaOxUE8qKosYLHquD 3Dec2Qg8QwKsuV1+55aMo1HTeTVrk6N4tw1rZP7gLKQ9O3TQFFH9UXUO1da2nr2DciBp zSRzWUkVZzl2IvAeVO2dUjO5OwXwZ9l1fSc2jS+PLSPcIlBJk4jks/4fqjLr9vxeoAta BfKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Z9ZJb9Towf7s14xdYVwO8XIYPUQHnyjDUdDIzxFhl2g=; b=v+C15Ea5aDl+RIS6QnvYdqglqfrunKbR2dnR53GmVQ5np+1WPdDVRPEasCZ+eGgP+d QKg4a1yr/N/shWMJhdBc2Yno3j3PUQf8ukaqJ1xLsnaVpL87zF/s/Xij09Q0yQ1KwZGO 0CFzQPyPmoE/huVqiNzbvTepOjwstF0m23kvWx94TAteiTuxFRNSAhXPPmvq3eVss9gS ZK0vxEpLRr0fbulJwyUNl2Ga084fe/cxrAickMp1hVsIfpfpVERROvnCI2D/a52Cz6dD pqw0jONj3U2pAeFslKgxeEf/yNGgYqtwO1Y39ne9ov+j4yAUNZKklDPP8dVGkjezTx4D 6+lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h9+ekRWy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb7-20020a1709076d8700b007add150c78asi14397075ejc.503.2022.11.02.18.18.06; Wed, 02 Nov 2022 18:18:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h9+ekRWy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230182AbiKCAbR (ORCPT + 98 others); Wed, 2 Nov 2022 20:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiKCAbP (ORCPT ); Wed, 2 Nov 2022 20:31:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2E3511469 for ; Wed, 2 Nov 2022 17:31:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8500BB82559 for ; Thu, 3 Nov 2022 00:31:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BE30C433C1; Thu, 3 Nov 2022 00:31:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1667435472; bh=tZFQi2ezr/TRrYv5Qk3okf6jnz8KjoG8g3dbndzWyfk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=h9+ekRWywNymN03zVYZM+oLF62BelIBCqBQH3FbqVQLig0J90HW+ZUrm5IxY4M8Sq Ju1J14i2A0i3PoeGB+i0f5GC2X4moKUCmXyitUy4ueWQ4fs/IPllH+t/R4o3LS7JLB VjMquAlLyXvDybq8zKcLnbH5vEFVzJ7ZcxVK2eCA= Date: Thu, 3 Nov 2022 01:32:08 +0100 From: Greg Kroah-Hartman To: Oded Gabbay Cc: David Airlie , Daniel Vetter , Arnd Bergmann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jason Gunthorpe , John Hubbard , Alex Deucher , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Yuji Ishikawa , Jiho Chu , Daniel Stone , Tvrtko Ursulin , Jeffrey Hugo , Christoph Hellwig , Kevin Hilman , Jagan Teki , Jacek Lawrynowicz , Maciej Kwapulinski Subject: Re: [RFC PATCH v2 1/3] drivers/accel: define kconfig and register a new major Message-ID: References: <20221102203405.1797491-1-ogabbay@kernel.org> <20221102203405.1797491-2-ogabbay@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102203405.1797491-2-ogabbay@kernel.org> X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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