From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6FE90C4332F for ; Sun, 6 Nov 2022 10:54:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D94C510E0E3; Sun, 6 Nov 2022 10:54:41 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C1658920E for ; Sun, 6 Nov 2022 10:54:35 +0000 (UTC) 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 01EE460C44 for ; Sun, 6 Nov 2022 10:54:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8025C43470 for ; Sun, 6 Nov 2022 10:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667732073; bh=DGWITShguY2YvDwT2F/Zt1p4K6E4TZdBWjm0qvd7Y5c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jtg3YNva6eR97+CKcl2lU4MZakiRXGxBnD8cqRXo2jA3ubAsAokvwHJHoxI5Q6ckr xxgWcqTnT2MSmSpKhhnM7EKt7eWZqlmB13PGa+bqTL9e4zpY7LhNdqJnH4/Dvztq3R TeO+JbCAD6DB2mFqDuIOtIyngVklXLzX060KDMUSD3e+C44DBRwUpT4fWcl1duQTQY p/G64KpiN/F4dB/+x4j6CO36Ktj7p1x+trI7fHQlmuJ8owjfoOOpQmPemOPIe6Q4Zy MvqyIq95aIK9M+RIPI3yxaQEu1bRUJ+OS4usLPCA4imQctMwY9xe4Y+fzYU9HAZv6u aRRddZEuTgt5A== Received: by mail-yb1-f174.google.com with SMTP id y186so5905486yby.10 for ; Sun, 06 Nov 2022 02:54:33 -0800 (PST) X-Gm-Message-State: ACrzQf36ADieZKOo+sF1xrkJzfmB2D790U/zW78yJlMNhs3T//LDGS7f WuOFRWtN0tkxdu/nbgNBgNratRHffcVPe3v0aV8= X-Google-Smtp-Source: AMsMyM4FcFut+LU4VdTnrVzBfv6cltrpShWVNbuucVGQUt4hr2pnnb6JqFc2yeeMG3KRDMdP48BI892EZF4vx48UqWM= X-Received: by 2002:a25:1e89:0:b0:6bf:9e55:5cb4 with SMTP id e131-20020a251e89000000b006bf9e555cb4mr44196756ybe.642.1667732072872; Sun, 06 Nov 2022 02:54:32 -0800 (PST) MIME-Version: 1.0 References: <20221102203405.1797491-1-ogabbay@kernel.org> <20221102203405.1797491-3-ogabbay@kernel.org> <20221103142554.6310a60f0f6dad1a59fa7644@samsung.com> In-Reply-To: <20221103142554.6310a60f0f6dad1a59fa7644@samsung.com> From: Oded Gabbay Date: Sun, 6 Nov 2022 12:54:06 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v2 2/3] accel: add dedicated minor for accelerator devices To: Jiho Chu Content-Type: text/plain; charset="UTF-8" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tvrtko Ursulin , Jacek Lawrynowicz , Jeffrey Hugo , Jason Gunthorpe , Arnd Bergmann , Thomas Zimmermann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Yuji Ishikawa , Jagan Teki , John Hubbard , Alex Deucher , Christoph Hellwig , Maciej Kwapulinski , Kevin Hilman Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu, Nov 3, 2022 at 7:26 AM Jiho Chu wrote: > > On Wed, 2 Nov 2022 22:34:04 +0200 > Oded Gabbay wrote: > > > +/** > > + * 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. > > + * 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); > > + > > Hi, > It needs to consider drm_global_mutex to access open_count. > please check doxy of open_count. Now that I'm changing the code back to be part of drm.ko, I can return all the code that is in drm_copy which I removed for this to compile. > > > > + /* 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); > > + > > static int accel_stub_open(struct inode *inode, struct file *filp) > > { > > - DRM_DEBUG("Operation not supported"); > > + const struct file_operations *new_fops; > > + struct drm_minor *minor; > > + int err; > > + > > + DRM_DEBUG("\n"); > > It seems useless. Correct, I removed it in v3. Thanks, Oded > > Thanks. > Jiho Chu