dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Oded Gabbay <ogabbay@kernel.org>
To: Jiho Chu <jiho.chu@samsung.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>,
	Jeffrey Hugo <quic_jhugo@quicinc.com>,
	Jason Gunthorpe <jgg@nvidia.com>, Arnd Bergmann <arnd@arndb.de>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Yuji Ishikawa <yuji2.ishikawa@toshiba.co.jp>,
	Jagan Teki <jagan@amarulasolutions.com>,
	John Hubbard <jhubbard@nvidia.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Christoph Hellwig <hch@infradead.org>,
	Maciej Kwapulinski <maciej.kwapulinski@linux.intel.com>,
	Kevin Hilman <khilman@baylibre.com>
Subject: Re: [RFC PATCH v2 2/3] accel: add dedicated minor for accelerator devices
Date: Sun, 6 Nov 2022 16:15:52 +0200	[thread overview]
Message-ID: <CAFCwf13qMN8QToOmGGd18k1BOCSHZ8ztcKgxY-LXDqoctSgxnw@mail.gmail.com> (raw)
In-Reply-To: <CAFCwf124PAis_PJjswUdGbpRJ=SGsPpAOQbjuRzvfM7VZyS8Dg@mail.gmail.com>

On Sun, Nov 6, 2022 at 12:54 PM Oded Gabbay <ogabbay@kernel.org> wrote:
>
> On Thu, Nov 3, 2022 at 7:26 AM Jiho Chu <jiho.chu@samsung.com> wrote:
> >
> > On Wed,  2 Nov 2022 22:34:04 +0200
> > Oded Gabbay <ogabbay@kernel.org> 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.
I take it back. All the code that I omitted was for legacy drivers.
If you look inside drm_dev_needs_global_mutex(), you will see 3 cases
where you need to take the global mutex, and all 3 are only relevant
for legacy drivers and/or drivers that use deprecated features.
So, I disagree with your original comment here.
Moreover, open_count is atomic, so I don't need to take the mutex to
increment it, and as you can see in drm_open(), the function
increments it regardless of whether it takes
drm_dev_needs_global_mutex.
Oded

>
> >
> >
> > > +     /* 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

  reply	other threads:[~2022-11-06 14:16 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02 20:34 [RFC PATCH v2 0/3] new subsystem for compute accelerator devices Oded Gabbay
2022-11-02 20:34 ` [RFC PATCH v2 1/3] drivers/accel: define kconfig and register a new major Oded Gabbay
2022-11-02 21:04   ` Jeffrey Hugo
2022-11-03 13:28     ` Oded Gabbay
2022-11-02 22:58   ` Randy Dunlap
2022-11-03 13:29     ` Oded Gabbay
2022-11-03  0:32   ` Greg Kroah-Hartman
2022-11-03 13:31     ` Oded Gabbay
2022-11-03 20:39       ` Oded Gabbay
2022-11-03 23:01         ` Randy Dunlap
2022-11-04  7:23           ` Stanislaw Gruszka
2022-11-07 12:56         ` Jason Gunthorpe
2022-11-07 13:01           ` Oded Gabbay
2022-11-07 13:10             ` Jason Gunthorpe
2022-11-07 13:25               ` Stanislaw Gruszka
2022-11-07 14:02               ` Oded Gabbay
2022-11-07 14:10                 ` Jason Gunthorpe
2022-11-07 15:53                   ` Oded Gabbay
2022-11-07 16:30                     ` Jason Gunthorpe
2022-11-07 19:27                       ` Oded Gabbay
2022-11-07 20:33                       ` Dave Airlie
2022-11-08 12:28                         ` Jason Gunthorpe
2022-11-09  7:22                           ` Dave Airlie
2022-11-07 20:18               ` Dave Airlie
2022-11-02 20:34 ` [RFC PATCH v2 2/3] accel: add dedicated minor for accelerator devices Oded Gabbay
2022-11-02 21:17   ` Jeffrey Hugo
2022-11-06 10:51     ` Oded Gabbay
2022-11-03  5:25   ` Jiho Chu
2022-11-06 10:54     ` Oded Gabbay
2022-11-06 14:15       ` Oded Gabbay [this message]
2022-11-02 20:34 ` [RFC PATCH v2 3/3] drm: initialize accel framework Oded Gabbay
2022-11-02 21:30   ` Jeffrey Hugo
2022-11-06 10:55     ` Oded Gabbay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFCwf13qMN8QToOmGGd18k1BOCSHZ8ztcKgxY-LXDqoctSgxnw@mail.gmail.com \
    --to=ogabbay@kernel.org \
    --cc=alexander.deucher@amd.com \
    --cc=arnd@arndb.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=jacek.lawrynowicz@linux.intel.com \
    --cc=jagan@amarulasolutions.com \
    --cc=jgg@nvidia.com \
    --cc=jhubbard@nvidia.com \
    --cc=jiho.chu@samsung.com \
    --cc=khilman@baylibre.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.kwapulinski@linux.intel.com \
    --cc=quic_jhugo@quicinc.com \
    --cc=tvrtko.ursulin@linux.intel.com \
    --cc=tzimmermann@suse.de \
    --cc=yuji2.ishikawa@toshiba.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).