Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp97328rwb; Sun, 6 Nov 2022 03:16:39 -0800 (PST) X-Google-Smtp-Source: AMsMyM5RnXno1SwFsztXoDd8EZIHz/qiVi4dHxhIAKyuS6g9KH3/iFbWA2zVLwnvZEwy2UQNEggc X-Received: by 2002:a17:90b:f94:b0:213:cc9a:1b38 with SMTP id ft20-20020a17090b0f9400b00213cc9a1b38mr39027234pjb.59.1667733398841; Sun, 06 Nov 2022 03:16:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667733398; cv=none; d=google.com; s=arc-20160816; b=eBtvDO/CS3T0G7q6YThcOedb9unxHjPuTYvJFzKFs59i50GOup8xtya1p+nVk2JSgy K6SSL1e6qzeCL5T/lfaQE4uGAiOCnmPgCch/iCNwoBLVt6iGufZcQmCnJJy6zWExoTW4 TNp2aPngrziIpq1NepISzMjnhmrTv5MHf5NO8FWIKvygLBlADgdygYKB9F+X3ClKHc40 bYKIWDPjo7+WawQka98XqbmPuw3xcgYfoZJfJEpZjo70K9OyKZKfro3rEFlhCL9CYej6 oTxm0yAf7hOcY8/NEdbAC2MM3bN9VpsFHChluDTGRSHLPRGZK588wognImb61tPWY6CK JU7Q== 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=gI+05KcFb55Fc6ECbdDQ5wXzm56O9HU6PqLBbTG/QTA=; b=1I9PAIscPVUxgZf5f424F3JDG4VGORXd8Kv2LSAz3aZIr6xLsn0raW8uPIND7OKsgi izm3eovNNhyrUgv6BxzeGY9bqUc+eOFwk9m4x6MtvL3A76kIyoai1wQCCSmXwGGW1/FV N6eWLyiXX0kBraYtGp7qAl+B4gEn4q1BSeVL3aSfwgyi2rlNOa+Q+8iLqDp/0GDqo54E NaUhpuCSw2d8/AtefhW+YeaJ8SOG0CCI1EKRVYpNbO6e9ZZnP0e4jI46wKCbfx3sNyHY nlppE2TZdXQY5Y7bFXT27zw1OOoM7EOKAzsG4o8DHWLyaollT7YcCC83qNWuHQ9oPmRA q9bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jtg3YNva; 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 o2-20020a635a02000000b0047022e1379csi6912406pgb.126.2022.11.06.03.16.26; Sun, 06 Nov 2022 03:16:38 -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=jtg3YNva; 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 S229933AbiKFKyj (ORCPT + 96 others); Sun, 6 Nov 2022 05:54:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbiKFKyh (ORCPT ); Sun, 6 Nov 2022 05:54:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D684D11F for ; Sun, 6 Nov 2022 02:54:36 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3BD47B80B34 for ; Sun, 6 Nov 2022 10:54:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC4E1C43146 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-f178.google.com with SMTP id 63so10569128ybq.4 for ; Sun, 06 Nov 2022 02:54:33 -0800 (PST) X-Gm-Message-State: ACrzQf0j4RdNI+j2xrqzCYUoolvGZjqyhj2x09ur/fSgEqG0jRVok3F9 BUNBtqERIoxayP6FTLhJDs1vVheCtXVst0dlK4g= 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 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 , Daniel Stone , Tvrtko Ursulin , Jeffrey Hugo , 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 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