[PATCH v5] drm/i915: Replace *_reference/unreference() or *_ref/unref with _get/put()

Sean Paul seanpaul at chromium.org
Mon Oct 16 19:08:05 UTC 2017


On Mon, Oct 16, 2017 at 2:53 PM, Harsha Sharma
<harshasharmaiitr at gmail.com> wrote:
> On Tue, Oct 17, 2017 at 12:15 AM, Sean Paul <seanpaul at chromium.org> wrote:
>> On Sat, Oct 14, 2017 at 2:36 PM, Harsha Sharma
>> <harshasharmaiitr at gmail.com> wrote:
>>> Replace instances of drm_framebuffer_reference/unreference() with
>>> *_get/put() suffixes and drm_dev_unref with *_put() suffix
>>> because get/put is shorter and consistent with the
>>> kernel use of *_get/put suffixes.
>>> Done with following coccinelle semantic patch
>>>
>>> @@
>>> expression ex;
>>> @@
>>>
>>> (
>>> -drm_framebuffer_unreference(ex);
>>> +drm_framebuffer_put(ex);
>>> |
>>> -drm_dev_unref(ex);
>>> +drm_dev_put(ex);
>>> |
>>> -drm_framebuffer_reference(ex);
>>> +drm_framebuffer_get(ex);
>>> )
>>>
>>
>> When I run this spatch on drm-tip, I get a bunch more changes than
>> this (below). Are you just running it on i915_pci?
>
> Hi,
> Yes you are right. But Daniel asked me to make the changes just for
> drm_dev_put in this patch . Sorry if I misinterpreted him.
> Please let me know if I need to sent another patch for all these changes.
> Thanks a lot.
>

In that case, you should edit the spatch in the commit message. When
submitting cocci patches, one should be able to reproduce the code
changes by running the spatch in the commit message.

Sean

> Regards,
> Harsha Sharma
>>
>> Sean
>>
>>
>> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
>> index 09d97e0990b7..2f106cca46b4 100644
>> --- a/drivers/gpu/drm/i915/i915_pci.c
>> +++ b/drivers/gpu/drm/i915/i915_pci.c
>> @@ -510,7 +510,7 @@ static void i915_pci_remove(struct pci_dev *pdev)
>>   struct drm_device *dev = pci_get_drvdata(pdev);
>>
>>   i915_driver_unload(dev);
>> - drm_dev_unref(dev);
>> + drm_dev_put(dev);
>>  }
>>
>>  static int i915_pci_probe(struct pci_dev *pdev, const struct
>> pci_device_id *ent)
>> diff --git a/drivers/gpu/drm/i915/intel_display.c
>> b/drivers/gpu/drm/i915/intel_display.c
>> index 5c7828c52d12..db755b9a5efd 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -2856,7 +2856,7 @@ intel_find_initial_plane_obj(struct intel_crtc
>> *intel_crtc,
>>
>>   if (intel_plane_ggtt_offset(state) == plane_config->base) {
>>   fb = c->primary->fb;
>> - drm_framebuffer_reference(fb);
>> + drm_framebuffer_get(fb);
>>   goto valid_fb;
>>   }
>>   }
>> @@ -2887,7 +2887,7 @@ intel_find_initial_plane_obj(struct intel_crtc
>> *intel_crtc,
>>     intel_crtc->pipe, PTR_ERR(intel_state->vma));
>>
>>   intel_state->vma = NULL;
>> - drm_framebuffer_unreference(fb);
>> + drm_framebuffer_put(fb);
>>   return;
>>   }
>>
>> @@ -2908,7 +2908,7 @@ intel_find_initial_plane_obj(struct intel_crtc
>> *intel_crtc,
>>   if (i915_gem_object_is_tiled(obj))
>>   dev_priv->preserve_bios_swizzle = true;
>>
>> - drm_framebuffer_reference(fb);
>> + drm_framebuffer_get(fb);
>>   primary->fb = primary->state->fb = fb;
>>   primary->crtc = primary->state->crtc = &intel_crtc->base;
>>
>> @@ -9847,7 +9847,7 @@ mode_fits_in_fbdev(struct drm_device *dev,
>>   if (obj->base.size < mode->vdisplay * fb->pitches[0])
>>   return NULL;
>>
>> - drm_framebuffer_reference(fb);
>> + drm_framebuffer_get(fb);
>>   return fb;
>>  #else
>>   return NULL;
>> @@ -10028,7 +10028,7 @@ int intel_get_load_detect_pipe(struct
>> drm_connector *connector,
>>   if (ret)
>>   goto fail;
>>
>> - drm_framebuffer_unreference(fb);
>> + drm_framebuffer_put(fb);
>>
>>   ret = drm_atomic_set_mode_for_crtc(&crtc_state->base, mode);
>>   if (ret)
>> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c
>> b/drivers/gpu/drm/i915/intel_fbdev.c
>> index 262e75c00dd2..e34334a1fbf9 100644
>> --- a/drivers/gpu/drm/i915/intel_fbdev.c
>> +++ b/drivers/gpu/drm/i915/intel_fbdev.c
>> @@ -189,7 +189,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
>>         " releasing it\n",
>>         intel_fb->base.width, intel_fb->base.height,
>>         sizes->fb_width, sizes->fb_height);
>> - drm_framebuffer_unreference(&intel_fb->base);
>> + drm_framebuffer_put(&intel_fb->base);
>>   intel_fb = ifbdev->fb = NULL;
>>   }
>>   if (!intel_fb || WARN_ON(!intel_fb->obj)) {
>> @@ -624,7 +624,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
>>   ifbdev->preferred_bpp = fb->base.format->cpp[0] * 8;
>>   ifbdev->fb = fb;
>>
>> - drm_framebuffer_reference(&ifbdev->fb->base);
>> + drm_framebuffer_get(&ifbdev->fb->base);
>>
>>   /* Final pass to check if any active pipes don't have fbs */
>>   for_each_crtc(dev, crtc) {
>> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_dmabuf.c
>> b/drivers/gpu/drm/i915/selftests/i915_gem_dmabuf.c
>> index 89dc25a5a53b..a7055b12e53c 100644
>> --- a/drivers/gpu/drm/i915/selftests/i915_gem_dmabuf.c
>> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_dmabuf.c
>> @@ -389,7 +389,7 @@ int i915_gem_dmabuf_mock_selftests(void)
>>
>>   err = i915_subtests(tests, i915);
>>
>> - drm_dev_unref(&i915->drm);
>> + drm_dev_put(&i915->drm);
>>   return err;
>>  }
>>
>> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
>> b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
>> index 5ea373221f49..75764fdb90da 100644
>> --- a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
>> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
>> @@ -345,6 +345,6 @@ int i915_gem_evict_mock_selftests(void)
>>   err = i915_subtests(tests, i915);
>>   mutex_unlock(&i915->drm.struct_mutex);
>>
>> - drm_dev_unref(&i915->drm);
>> + drm_dev_put(&i915->drm);
>>   return err;
>>  }
>> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
>> b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
>> index 6b132caffa18..bc3c4a5776bd 100644
>> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
>> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
>> @@ -1540,7 +1540,7 @@ int i915_gem_gtt_mock_selftests(void)
>>   err = i915_subtests(tests, i915);
>>   mutex_unlock(&i915->drm.struct_mutex);
>>
>> - drm_dev_unref(&i915->drm);
>> + drm_dev_put(&i915->drm);
>>   return err;
>>  }
>>
>> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_object.c
>> b/drivers/gpu/drm/i915/selftests/i915_gem_object.c
>> index 8f011c447e41..7bfd9900798a 100644
>> --- a/drivers/gpu/drm/i915/selftests/i915_gem_object.c
>> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_object.c
>> @@ -586,7 +586,7 @@ int i915_gem_object_mock_selftests(void)
>>
>>   err = i915_subtests(tests, i915);
>>
>> - drm_dev_unref(&i915->drm);
>> + drm_dev_put(&i915->drm);
>>   return err;
>>  }
>>
>> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_request.c
>> b/drivers/gpu/drm/i915/selftests/i915_gem_request.c
>> index 6664cb2eb0b8..8985578cf8a5 100644
>> --- a/drivers/gpu/drm/i915/selftests/i915_gem_request.c
>> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_request.c
>> @@ -260,7 +260,7 @@ int i915_gem_request_mock_selftests(void)
>>   return -ENOMEM;
>>
>>   err = i915_subtests(tests, i915);
>> - drm_dev_unref(&i915->drm);
>> + drm_dev_put(&i915->drm);
>>
>>   return err;
>>  }
>> diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c
>> b/drivers/gpu/drm/i915/selftests/i915_vma.c
>> index 2e86ec136b35..d8cc0a665169 100644
>> --- a/drivers/gpu/drm/i915/selftests/i915_vma.c
>> +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c
>> @@ -734,7 +734,7 @@ int i915_vma_mock_selftests(void)
>>   err = i915_subtests(tests, i915);
>>   mutex_unlock(&i915->drm.struct_mutex);
>>
>> - drm_dev_unref(&i915->drm);
>> + drm_dev_put(&i915->drm);
>>   return err;
>>  }
>>
>> diff --git a/drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c
>> b/drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c
>> index 828904b7d468..3c8bf447b890 100644
>> --- a/drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c
>> +++ b/drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c
>> @@ -475,7 +475,7 @@ int intel_breadcrumbs_mock_selftests(void)
>>   return -ENOMEM;
>>
>>   err = i915_subtests(tests, i915->engine[RCS]);
>> - drm_dev_unref(&i915->drm);
>> + drm_dev_put(&i915->drm);
>>
>>   return err;
>>  }
>>
>>
>>> Signed-off-by: Harsha Sharma <harshasharmaiitr at gmail.com>
>>> ---
>>> Changes in v5:
>>>  -rebase drm_dev_put change on drm-tip
>>> Changes in v4:
>>>  -change one instance of *_put to *_get
>>> Changes in v3:
>>>  -Removed changes in selftests
>>> Changes in v2:
>>>  -Added cocinelle patch in log message
>>>  -cc to all driver-specific mailing lists
>>>  drivers/gpu/drm/i915/i915_pci.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
>>> index bf467f30c99b..1223961c3700 100644
>>> --- a/drivers/gpu/drm/i915/i915_pci.c
>>> +++ b/drivers/gpu/drm/i915/i915_pci.c
>>> @@ -645,7 +645,7 @@ static void i915_pci_remove(struct pci_dev *pdev)
>>>         struct drm_device *dev = pci_get_drvdata(pdev);
>>>
>>>         i915_driver_unload(dev);
>>> -       drm_dev_unref(dev);
>>> +       drm_dev_put(dev);
>>>  }
>>>
>>>  static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>>> --
>>> 2.11.0
>>>


More information about the dri-devel mailing list