Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp102748rwb; Sun, 6 Nov 2022 03:23:05 -0800 (PST) X-Google-Smtp-Source: AMsMyM4mlF0e6k2kILGQal2yCGiI+hLtD2tu0Wnf+KE3WjMHpngAiCrFsRhoDLjOCr0a8j4ZwhWs X-Received: by 2002:a17:907:d093:b0:7ae:108:9728 with SMTP id vc19-20020a170907d09300b007ae01089728mr22918333ejc.484.1667733785217; Sun, 06 Nov 2022 03:23:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667733785; cv=none; d=google.com; s=arc-20160816; b=nix5c5Qkxc8GJ9FZXra8LN7b7XgNiATYFH9fTi9dMZkQJ8pxeW7o1tkCMx1s34Z1qt 0swvLEiY7pkuG48UpxR+rne1kT7N8ksLasVjYYvU6MzSS9vVOzHhpm56MXs0Vccmec3B +zsvZ7xPzUBtEUUyVi9H4BNW6fJ+Ps9KVIH5Q7LRlL4VyzZ9ckQ5f+QZ+TrOYqC1McV5 vpu+JppFaL8vAuBt+ByVRaXYxOJaqhNFg/tkVadfQsfrivbgIoHgtbgOnP2f3WXo7o2n 2EE6szygxX6P/udExiyGy6FgQCd8bRJ1YvWtdTobwXVB0aC4/31W+dXXv9PbmhUgp+a2 E6uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yVQsb0JqQ0oAU/nhdznP7kUyCEQgvfws4R9ig3bnowA=; b=gYbbwzF1qKvEU5mJjA2yGC7qvV7cP7/Xo6edXyblolXKEgo/0c9Ze1jdWIMIszbX0f 0D4teiqcovYQpcH9Ujww+uVqcQAbeCxCtvLnwcn3yCTimnS3uDzSg9Kr1VJ/8rt3RuJW BX8ll0Ec7WArcM7G4My8BLtMyuA6GF+EH0/WM88uIHf+RAcNbABf8kCIWWzeg8h//bDO AA7oJ1ki+ZFnxj5l11yDWw6fzxpSA83YAd3HxiSPTta7IFZs/GtbSObitwyD/9IxKGNG P5mj69msJM1PIwF3BjRC7DA3Mv2Doj/GiwOyv26eZKm+Zw9y/zClX9WdhUceftmFtp79 o4wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y2V4328Z; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt9-20020a1709072d8900b0078d49f0df9csi6051644ejc.453.2022.11.06.03.22.41; Sun, 06 Nov 2022 03:23:05 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=Y2V4328Z; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbiKFKwW (ORCPT + 97 others); Sun, 6 Nov 2022 05:52:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbiKFKwV (ORCPT ); Sun, 6 Nov 2022 05:52:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65FB49FE7 for ; Sun, 6 Nov 2022 02:52:20 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id F284260C07 for ; Sun, 6 Nov 2022 10:52:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63696C43470 for ; Sun, 6 Nov 2022 10:52:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667731939; bh=zZXlka8XT0jQaPkciMFldTLZtAMw7JFqIJd9Pf545QE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Y2V4328ZVop5zSPYMbnVBTVFNfHfFl+chIXZhpO3/zXuc77NPWVLdHRiTycGuYLy3 OQbUBXlQWlcy4fOP0D5fVyCaK1MmlrXGd3P62LZtmNp8qrmfzslkYWTadXKvypzQHj nuFIGYLJxI3Zmgn+fkji9quyQVjcuXEjHVglP9ZZrIcbNXZqQkY22tMRB3HZzpmk+N ntw6n7OWV/T1t8nbGFYfzJJ3knROgXviZLu8JCdIFdPcA5MKh+0t6OQ4hf2D7Kb7lK ThJPmyQF4mRQFCzb2I2zJMaTGOGFh3RH04hlAYqJAWJJQPry4/lRvLo/ygZ19/8VyQ Cq6axWmp+BdzQ== Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-36cbcda2157so80326297b3.11 for ; Sun, 06 Nov 2022 02:52:19 -0800 (PST) X-Gm-Message-State: ACrzQf01T/8TSknhXNXVA8KCHRJva1Ab6KEdgYtmEFjUptavBO615g7m 0zeyY6Y2TZTIZCQaBpEI0YvfN3Z7tDjnNJrg7vw= X-Received: by 2002:a81:9214:0:b0:36c:7b94:aa57 with SMTP id j20-20020a819214000000b0036c7b94aa57mr41538976ywg.221.1667731938334; Sun, 06 Nov 2022 02:52:18 -0800 (PST) MIME-Version: 1.0 References: <20221102203405.1797491-1-ogabbay@kernel.org> <20221102203405.1797491-3-ogabbay@kernel.org> <7654d9c0-c181-ae6b-96ee-349f20f24b18@quicinc.com> In-Reply-To: <7654d9c0-c181-ae6b-96ee-349f20f24b18@quicinc.com> From: Oded Gabbay Date: Sun, 6 Nov 2022 12:51:51 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v2 2/3] accel: add dedicated minor for accelerator devices To: Jeffrey Hugo Cc: David Airlie , Daniel Vetter , Arnd Bergmann , Greg Kroah-Hartman , 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 , Christoph Hellwig , Kevin Hilman , Jagan Teki , Jacek Lawrynowicz , Maciej Kwapulinski Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.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 2, 2022 at 11:17 PM Jeffrey Hugo wrote: > > On 11/2/2022 2:34 PM, Oded Gabbay wrote: > > @@ -24,16 +33,6 @@ static char *accel_devnode(struct device *dev, umode_t *mode) > > > > static CLASS_ATTR_STRING(accel_version, 0444, "accel 1.0.0 20221018"); > > > > -/** > > - * 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. > > - */ > > Why are we removing this? It should have been removed at the first patch, and will be fixed in v3. I'm removing it as it is a static function. We don't document every static function. > > > static int accel_sysfs_init(void) > > { > > int err; > > @@ -54,11 +53,6 @@ static int accel_sysfs_init(void) > > return 0; > > } > > > > -/** > > - * accel_sysfs_destroy - destroys ACCEL class > > - * > > - * Destroy the ACCEL device class. > > - */ > > Again, why remove this? Adding it in one patch than immediately > removing it in the next patch seems wasteful. Correct, will be removed from the first patch in the next version. > > > static void accel_sysfs_destroy(void) > > { > > if (IS_ERR_OR_NULL(accel_class)) > > @@ -68,11 +62,185 @@ static void accel_sysfs_destroy(void) > > accel_class = NULL; > > } > > > > +static void accel_minor_release(struct drm_minor *minor) > > +{ > > + drm_dev_put(minor->dev); > > +} > > + > > +/** > > + * accel_open - open method for ACCEL file > > + * @inode: device inode > > + * @filp: file pointer. > > + * > > + * This function must be used by drivers as their &file_operations.open method. > > Feels like it would be helpful to have an accel version of > DEFINE_DRM_GEM_FOPS() which helps accel drivers to get this right Yeah, I also thought about it. I'll add it. thanks, oded > > > + * It looks up the correct ACCEL device and instantiates all the per-file > > + * resources for it. It also calls the &drm_driver.open driver callback. > > + * > > + * Return: 0 on success or negative errno value on failure. > > + */ > > +int accel_open(struct inode *inode, struct file *filp) > > +{ > > + struct drm_device *dev; > > + struct drm_minor *minor; > > + int retcode; > > + > > + minor = accel_minor_acquire(iminor(inode)); > > + if (IS_ERR(minor)) > > + return PTR_ERR(minor); > > + > > + dev = minor->dev; > > + > > + atomic_fetch_inc(&dev->open_count); > > + > > + /* share address_space across all char-devs of a single device */ > > + filp->f_mapping = dev->anon_inode->i_mapping; > > + > > + retcode = drm_open_helper(filp, minor); > > + if (retcode) > > + goto err_undo; > > + > > + return 0; > > + > > +err_undo: > > + atomic_dec(&dev->open_count); > > + accel_minor_release(minor); > > + return retcode; > > +} > > +EXPORT_SYMBOL_GPL(accel_open);