From: zhoucm1 Subject: Re: [PATCH] drm: fix call_kern.cocci warnings v2 Date: Thu, 25 Oct 2018 17:28:07 +0800 Message-ID: References: <20181025085301.8217-1-david1.zhou@amd.com> <6f63db7a-e51b-5829-9eb0-265ebd6dd99c@gmail.com> <14a02772-5277-3ef2-91f8-1ef3858c1bbe@amd.com> <0d33f030-aa41-0cdc-bd47-9018436d3e73@amd.com> <01456f6c-88c3-5b4e-bc07-d3a202ae2dd3@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0950794408==" Return-path: In-Reply-To: <01456f6c-88c3-5b4e-bc07-d3a202ae2dd3@amd.com> Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: "Koenig, Christian" , "Zhou, David(ChunMing)" , "dri-devel@lists.freedesktop.org" Cc: =?UTF-8?Q?Christian_K=c3=b6nig?= , "intel-gfx@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org --===============0950794408== Content-Type: multipart/alternative; boundary="------------4D7417ED1803AB2708CA196F" Content-Language: en-US --------------4D7417ED1803AB2708CA196F Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit On 2018年10月25日 17:23, Koenig, Christian wrote: > Am 25.10.18 um 11:20 schrieb zhoucm1: >> >> >> >> On 2018年10月25日 17:11, Koenig, Christian wrote: >>> Am 25.10.18 um 11:03 schrieb zhoucm1: >>>> >>>> >>>> >>>> On 2018年10月25日 16:56, Christian König wrote: >>>>>> +++ b/drivers/gpu/drm/drm_syncobj.c >>>>>> @@ -111,15 +111,16 @@ static struct dma_fence >>>>>>                         uint64_t point) >>>>>>   { >>>>>>       struct drm_syncobj_signal_pt *signal_pt; >>>>>> +    struct dma_fence *f = NULL; >>>>>> +    struct drm_syncobj_stub_fence *fence = >>>>>> +        kzalloc(sizeof(struct drm_syncobj_stub_fence), >>>>>> +            GFP_KERNEL); >>>>>>   +    if (!fence) >>>>>> +        return NULL; >>>>>> +    spin_lock(&syncobj->pt_lock); >>>>> >>>>> How about using a single static stub fence like I suggested? >>>> Sorry, I don't get your meanings, how to do that? >>> >>> Add a new function drm_syncobj_stub_fence_init() which is called >>> from drm_core_init() when the module is loaded. >>> >>> In drm_syncobj_stub_fence_init() you initialize one static >>> stub_fence which is then used over and over again. >> Seems it would not work, we could need more than one stub fence. > > Mhm, why? I mean it is just a signaled fence, If A gets the global stub fence, doesn't put it yet, then B is coming, how does B re-use the global stub fence?  anything I misunderstand? David > context and sequence number are irrelevant. > > Christian. > >> >> David >>> >>> Since its reference count never goes down to zero it should never be >>> freed. In doubt maybe add a .free callback which just calls BUG() to >>> catch reference count issues. >>> >>> Christian. >>> >>>> >>>> Thanks, >>>> David >>> >> > --------------4D7417ED1803AB2708CA196F Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 8bit



On 2018年10月25日 17:23, Koenig, Christian wrote:
Am 25.10.18 um 11:20 schrieb zhoucm1:



On 2018年10月25日 17:11, Koenig, Christian wrote:
Am 25.10.18 um 11:03 schrieb zhoucm1:



On 2018年10月25日 16:56, Christian König wrote:
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -111,15 +111,16 @@ static struct dma_fence
                        uint64_t point)
  {
      struct drm_syncobj_signal_pt *signal_pt;
+    struct dma_fence *f = NULL;
+    struct drm_syncobj_stub_fence *fence =
+        kzalloc(sizeof(struct drm_syncobj_stub_fence),
+            GFP_KERNEL);
  +    if (!fence)
+        return NULL;
+    spin_lock(&syncobj->pt_lock);

How about using a single static stub fence like I suggested?
Sorry, I don't get your meanings, how to do that?

Add a new function drm_syncobj_stub_fence_init() which is called from drm_core_init() when the module is loaded.

In drm_syncobj_stub_fence_init() you initialize one static stub_fence which is then used over and over again.
Seems it would not work, we could need more than one stub fence.

Mhm, why? I mean it is just a signaled fence,

If A gets the global stub fence, doesn't put it yet, then B is coming, how does B re-use the global stub fence?  anything I misunderstand?

David
context and sequence number are irrelevant.

Christian.


David

Since its reference count never goes down to zero it should never be freed. In doubt maybe add a .free callback which just calls BUG() to catch reference count issues.

Christian.


Thanks,
David




--------------4D7417ED1803AB2708CA196F-- --===============0950794408== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0950794408==--