• Oded Gabbay's avatar
    accel: add dedicated minor for accelerator devices · 2c204f3d
    Oded Gabbay authored
    The accelerator devices are exposed to user-space using a dedicated
    major. In addition, they are represented in /dev with new, dedicated
    device char names: /dev/accel/accel*. This is done to make sure any
    user-space software that tries to open a graphic card won't open
    the accelerator device by mistake.
    
    The above implies that the minor numbering should be separated from
    the rest of the DRM devices. However, to avoid code duplication, we
    want the drm_minor structure to be able to represent the accelerator
    device.
    
    To achieve this, we add a new drm_minor* to drm_device that represents
    the accelerator device. This pointer is initialized for drivers that
    declare they handle compute accelerator, using a new driver feature
    flag called DRIVER_COMPUTE_ACCEL. It is important to note that this
    driver feature is mutually exclusive with DRIVER_RENDER. Devices that
    want to expose both graphics and compute device char files should be
    handled by two drivers that are connected using the auxiliary bus
    framework.
    
    In addition, we define a different IDR to handle the accelerators
    minors. This is done to make the minor's index be identical to the
    device index in /dev/. Any access to the IDR is done solely
    by functions in accel_drv.c, as the IDR is define as static. The
    DRM core functions call those functions in case they detect the minor's
    type is DRM_MINOR_ACCEL.
    
    We define a separate accel_open function (from drm_open) that the
    accel drivers should set as their open callback function. Both these
    functions eventually call the same drm_open_helper(), which had to be
    changed to be non-static so it can be called from accel_drv.c.
    accel_open() only partially duplicates drm_open as I removed some code
    from it that handles legacy devices.
    
    To help new drivers, I defined DEFINE_DRM_ACCEL_FOPS macro to easily
    set the required function operations pointers structure.
    Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
    Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: default avatarJeffrey Hugo <quic_jhugo@quicinc.com>
    Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
    Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
    Acked-by: default avatarJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
    Tested-by: default avatarJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
    Reviewed-by: default avatarMelissa Wen <mwen@igalia.com>
    2c204f3d
drm_file.h 12.5 KB