lkml.org 
[lkml]   [2022]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC PATCH v2 2/3] accel: add dedicated minor for accelerator devices
    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.


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

    Thanks.
    Jiho Chu

    \
     
     \ /
      Last update: 2022-11-03 06:26    [W:3.700 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site