[PATCH 4/6] drm: Add drm_object lease infrastructure [v3]

Dave Airlie airlied at gmail.com
Thu Oct 5 03:55:49 UTC 2017


> + *
> + * drm_master at the top of the tree (i.e, with lessor NULL
> + */
> +struct drm_master *drm_lease_owner(struct drm_master *master) {

^ there's a couple of misplaced braces around. start of next line please.


> +       while (master->lessor != NULL)
> +               master = master->lessor;
> +       return master;
> +}
> +EXPORT_SYMBOL(drm_lease_owner);
> +
> +/**
> + * _drm_find_lessee - find lessee by id
> + * @master: drm_master of lessor
> + * @id: lessee_id
> + *
> + * RETURN:
> + *
> + * drm_master of the lessee if valid, NULL otherwise
> + */
> +
> +static struct drm_master*
> +_drm_find_lessee(struct drm_master *master, int lessee_id)
> +{
> +       return idr_find(&drm_lease_owner(master)->lessee_idr, lessee_id);
> +}
> +
> +/**
> + * _drm_lease_held_master - check to see if an object is leased (or owned) by master
> + * @master: the master to check the lease status of
> + * @id: the id to check
> + *
> + * Checks if the specified master holds a lease on the object. Return
> + * value:
> + *
> + *     true            'master' holds a lease on (or owns) the object
> + *     false           'master' does not hold a lease.
> + */
> +static int _drm_lease_held_master(struct drm_master *master, int id) {

^^ here as well.

> +       lockdep_assert_held(&master->dev->mode_config.idr_mutex);
> +       if (master->lessor)
> +               return idr_find(&master->leases, id) != NULL;
> +       return true;
> +}
> +
> +/**
> + * _drm_has_leased - check to see if an object has been leased
> + * @master: the master to check the lease status of
> + * @id: the id to check
> + *
> + * Checks if any lessee of 'master' holds a lease on 'id'. Return
> + * value:
> + *
> + *     true            Some lessee holds a lease on the object.
> + *     false           No lessee has a lease on the object.
> + */
> +static bool _drm_has_leased(struct drm_master *master, int id) {

^^ here as well


> +}
> +EXPORT_SYMBOL(drm_lease_held);
> +
> +/**
> + * drm_lease_filter_crtcs - restricted crtc set to leased values
> + * @file_priv: requestor file
> + * @crtcs: bitmask of crtcs to check
> + *
> + * Reconstructs a crtc mask based on the crtcs which are visible
> + * through the specified file.
> + */
> +uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in)
> +{
> +       struct drm_master *master;
> +       struct drm_device *dev;
> +       struct drm_crtc *crtc;
> +       int count_in, count_out;
> +       uint32_t crtcs_out = 0;
> +
> +       if (file_priv == NULL || file_priv->master == NULL)
> +               return crtcs_in;
> +
> +       master = file_priv->master;
> +       dev = master->dev;
> +
> +       count_in = count_out = 0;
> +       mutex_lock(&master->dev->mode_config.idr_mutex);
> +       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> +               if (_drm_lease_held_master(master, crtc->base.id)) {
> +                       uint32_t        mask_in = 1ul << count_in;
> +                       if ((crtcs_in & mask_in) != 0) {
> +                               uint32_t        mask_out = 1ul << count_out;
> +                               crtcs_out |= mask_out;

There are a couple of stray tab chars in here ^

> +       mutex_lock(&master->dev->mode_config.idr_mutex);
> +       list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
> +               if (_drm_lease_held_master(master, encoder->base.id)) {
> +                       uint32_t        mask_in = 1ul << count_in;
> +                       if ((encoders_in & mask_in) != 0) {
> +                               uint32_t        mask_out = 1ul << count_out;
> +                               encoders_out |= mask_out;

And here ^

Dave.


More information about the dri-devel mailing list