From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D691C433E2 for ; Mon, 14 Sep 2020 17:51:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0122E20EDD for ; Mon, 14 Sep 2020 17:51:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tqZKHKN1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0122E20EDD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=amd-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 964016E4E8; Mon, 14 Sep 2020 17:51:13 +0000 (UTC) Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id B488F6E4E8; Mon, 14 Sep 2020 17:51:12 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id l17so399655edq.12; Mon, 14 Sep 2020 10:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=cinD4tchkxocHKviw5M6liz7E8UU7FD4XovFhsNsjyI=; b=tqZKHKN1V6C6oQElOwFS4+jyvbLS9BzylBSbwUbd02rQ76/lT49lrc+1lA+C8DN8Dd Nc0GbsJCPaCOHclSGk4/rG8fGqamsaUD5D+cmba9mrjnCmyMQa6mZgYbC5c/w9kZwhfb aJRkSAXMinRH/3gtwBaIiUmXBpTvWVTG5r/fSBBRDxoLah5xFDDjscX2kvgZr8AfeAC0 gMFA6X+UeLkG9NLYtld2tfKKPMYvQC8wFwsgo6QeCj/1SP2gpRaBO+qK+7RqV2MPi/tn AYDtIiDOG7XJrasBS+cYJnkZhddVCOd5+jF87VvJuyV9OeppL+UABQ8WQSDYD79g3mPs ytfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language; bh=cinD4tchkxocHKviw5M6liz7E8UU7FD4XovFhsNsjyI=; b=XzUNwjExRpWcHkXwHWNfAsvRcXiuP4E7y4VV9owD+CyqdYI+pUkjNfgjiGv8u62Her HHXS8d4H8wB8rWXrApK8xB3yS2gw5f0dlU87YtCDK4Co5vevxYGPVOePdDuXwX/PDPd4 gfYsGRcwBWDJS28ezMn4okCp3LEIb912iibK68v2Cmtz3JsbLAyMUcGZDNsMFqi7zjtw +UfZtIf3O5AdjnTftTCan4wn+1mgWjoV4wkZuej7KOxlt6HVgfFRZrw2v1nwO3O5K/YG B1NQT2Uj2T8Y/TRcSzOZidMNHboGfghlInya6/+RNmal7BRep2UVtidq95VVwIVf7Nio RG5Q== X-Gm-Message-State: AOAM530GN4ze5YiijLF6SwdudN+PT6Iz+0syxbB0ys7l7qhOGW5nCTHp KcALNXAVnIXXZG5Zrb1cE4M= X-Google-Smtp-Source: ABdhPJyHIadEQ0w95cMm+XKXdD2wy6DDt/xaqpuYqbeZucK6WVOqY6RobxWEhAYoVlCs20sURxiHJg== X-Received: by 2002:a50:b046:: with SMTP id i64mr19248036edd.9.1600105871323; Mon, 14 Sep 2020 10:51:11 -0700 (PDT) Received: from ?IPv6:2a02:908:1252:fb60:be8a:bd56:1f94:86e7? ([2a02:908:1252:fb60:be8a:bd56:1f94:86e7]) by smtp.gmail.com with ESMTPSA id c22sm9791887edr.70.2020.09.14.10.51.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 10:51:10 -0700 (PDT) Subject: Re: [PATCH 01/20] drm/amdgpu: Introduce GEM object functions To: Thomas Zimmermann , =?UTF-8?Q?Christian_K=c3=b6nig?= , alexander.deucher@amd.com, airlied@linux.ie, daniel@ffwll.ch, linux@armlinux.org.uk, maarten.lankhorst@linux.intel.com, mripard@kernel.org, l.stach@pengutronix.de, christian.gmeiner@gmail.com, inki.dae@samsung.com, jy0922.shim@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, krzk@kernel.org, patrik.r.jakobsson@gmail.com, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, chunkuang.hu@kernel.org, p.zabel@pengutronix.de, matthias.bgg@gmail.com, robdclark@gmail.com, sean@poorly.run, bskeggs@redhat.com, tomi.valkeinen@ti.com, eric@anholt.net, hjc@rock-chips.com, heiko@sntech.de, thierry.reding@gmail.com, jonathanh@nvidia.com, rodrigosiqueiramelo@gmail.com, hamohammed.sa@gmail.com, oleksandr_andrushchenko@epam.com, hyun.kwon@xilinx.com, laurent.pinchart@ideasonboard.com, michal.simek@xilinx.com, sumit.semwal@linaro.org, evan.quan@amd.com, Hawking.Zhang@amd.com, tianci.yin@amd.com, marek.olsak@amd.com, hdegoede@redhat.com, andrey.grodzovsky@amd.com, Felix.Kuehling@amd.com, xinhui.pan@amd.com, aaron.liu@amd.com, nirmoy.das@amd.com, chris@chris-wilson.co.uk, matthew.auld@intel.com, abdiel.janulgue@linux.intel.com, tvrtko.ursulin@linux.intel.com, andi.shyti@intel.com, sam@ravnborg.org, miaoqinglang@huawei.com, emil.velikov@collabora.com References: <20200813083644.31711-1-tzimmermann@suse.de> <20200813083644.31711-2-tzimmermann@suse.de> <5c1b3cab-1898-46df-2c5c-23ab6cbfbb7a@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Mon, 14 Sep 2020 19:51:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: christian.koenig@amd.com Cc: linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-mediatek@lists.infradead.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org, xen-devel@lists.xenproject.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============1987600549==" Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" This is a multi-part message in MIME format. --===============1987600549== Content-Type: multipart/alternative; boundary="------------29780EC5D45E17F55361B946" Content-Language: en-US This is a multi-part message in MIME format. --------------29780EC5D45E17F55361B946 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Am 14.09.20 um 17:05 schrieb Thomas Zimmermann: > Hi > > Am 13.08.20 um 12:22 schrieb Christian König: >> Am 13.08.20 um 10:36 schrieb Thomas Zimmermann: >>> GEM object functions deprecate several similar callback interfaces in >>> struct drm_driver. This patch replaces the per-driver callbacks with >>> per-instance callbacks in amdgpu. The only exception is gem_prime_mmap, >>> which is non-trivial to convert. >>> >>> Signed-off-by: Thomas Zimmermann >>> --- >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------ >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++ >>>   2 files changed, 12 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> index 81a79760ca61..51525b8774c9 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> @@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = { >>>       .lastclose = amdgpu_driver_lastclose_kms, >>>       .irq_handler = amdgpu_irq_handler, >>>       .ioctls = amdgpu_ioctls_kms, >>> -    .gem_free_object_unlocked = amdgpu_gem_object_free, >>> -    .gem_open_object = amdgpu_gem_object_open, >>> -    .gem_close_object = amdgpu_gem_object_close, >>>       .dumb_create = amdgpu_mode_dumb_create, >>>       .dumb_map_offset = amdgpu_mode_dumb_mmap, >>>       .fops = &amdgpu_driver_kms_fops, >>>         .prime_handle_to_fd = drm_gem_prime_handle_to_fd, >>>       .prime_fd_to_handle = drm_gem_prime_fd_to_handle, >>> -    .gem_prime_export = amdgpu_gem_prime_export, >>>       .gem_prime_import = amdgpu_gem_prime_import, >>> -    .gem_prime_vmap = amdgpu_gem_prime_vmap, >>> -    .gem_prime_vunmap = amdgpu_gem_prime_vunmap, >>>       .gem_prime_mmap = amdgpu_gem_prime_mmap, >>>         .name = DRIVER_NAME, >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> index 43f4966331dd..ca2b79f94e99 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> @@ -36,6 +36,7 @@ >>>   #include >>>   #include >>>   #include "amdgpu.h" >>> +#include "amdgpu_dma_buf.h" >>>   #include "amdgpu_trace.h" >>>   #include "amdgpu_amdkfd.h" >>>   @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags) >>>   #endif >>>   } >>>   +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = { >>> +    .free = amdgpu_gem_object_free, >>> +    .open = amdgpu_gem_object_open, >>> +    .close = amdgpu_gem_object_close, >>> +    .export = amdgpu_gem_prime_export, >>> +    .vmap = amdgpu_gem_prime_vmap, >>> +    .vunmap = amdgpu_gem_prime_vunmap, >>> +}; >>> + >> Wrong file, this belongs into amdgpu_gem.c >> >>>   static int amdgpu_bo_do_create(struct amdgpu_device *adev, >>>                      struct amdgpu_bo_param *bp, >>>                      struct amdgpu_bo **bo_ptr) >>> @@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct >>> amdgpu_device *adev, >>>       bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL); >>>       if (bo == NULL) >>>           return -ENOMEM; >>> + >>> +    bo->tbo.base.funcs = &amdgpu_gem_object_funcs; >> And this should probably go into amdgpu_gem_object_create(). > I'm trying to understand what amdgpu does. What about all the places > where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss > the free callback for the GEM object? Those shouldn't have a GEM object in the first place. Or otherwise we would have a reference counting issue. Regards, Christian. > > Best regards > Thomas > >> Apart from that looks like a good idea to me. >> >> Christian. >> >>>       drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size); >>>       INIT_LIST_HEAD(&bo->shadow_list); >>>       bo->vm_bo = NULL; > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx --------------29780EC5D45E17F55361B946 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
Am 14.09.20 um 17:05 schrieb Thomas Zimmermann:
Hi

Am 13.08.20 um 12:22 schrieb Christian König:
Am 13.08.20 um 10:36 schrieb Thomas Zimmermann:
GEM object functions deprecate several similar callback interfaces in
struct drm_driver. This patch replaces the per-driver callbacks with
per-instance callbacks in amdgpu. The only exception is gem_prime_mmap,
which is non-trivial to convert.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++
  2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 81a79760ca61..51525b8774c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = {
      .lastclose = amdgpu_driver_lastclose_kms,
      .irq_handler = amdgpu_irq_handler,
      .ioctls = amdgpu_ioctls_kms,
-    .gem_free_object_unlocked = amdgpu_gem_object_free,
-    .gem_open_object = amdgpu_gem_object_open,
-    .gem_close_object = amdgpu_gem_object_close,
      .dumb_create = amdgpu_mode_dumb_create,
      .dumb_map_offset = amdgpu_mode_dumb_mmap,
      .fops = &amdgpu_driver_kms_fops,
        .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
      .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-    .gem_prime_export = amdgpu_gem_prime_export,
      .gem_prime_import = amdgpu_gem_prime_import,
-    .gem_prime_vmap = amdgpu_gem_prime_vmap,
-    .gem_prime_vunmap = amdgpu_gem_prime_vunmap,
      .gem_prime_mmap = amdgpu_gem_prime_mmap,
        .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 43f4966331dd..ca2b79f94e99 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -36,6 +36,7 @@
  #include <drm/amdgpu_drm.h>
  #include <drm/drm_cache.h>
  #include "amdgpu.h"
+#include "amdgpu_dma_buf.h"
  #include "amdgpu_trace.h"
  #include "amdgpu_amdkfd.h"
  @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags)
  #endif
  }
  +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = {
+    .free = amdgpu_gem_object_free,
+    .open = amdgpu_gem_object_open,
+    .close = amdgpu_gem_object_close,
+    .export = amdgpu_gem_prime_export,
+    .vmap = amdgpu_gem_prime_vmap,
+    .vunmap = amdgpu_gem_prime_vunmap,
+};
+
Wrong file, this belongs into amdgpu_gem.c

  static int amdgpu_bo_do_create(struct amdgpu_device *adev,
                     struct amdgpu_bo_param *bp,
                     struct amdgpu_bo **bo_ptr)
@@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct
amdgpu_device *adev,
      bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
      if (bo == NULL)
          return -ENOMEM;
+
+    bo->tbo.base.funcs = &amdgpu_gem_object_funcs;
And this should probably go into amdgpu_gem_object_create().
I'm trying to understand what amdgpu does.  What about all the places
where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss
the free callback for the GEM object?

Those shouldn't have a GEM object in the first place.

Or otherwise we would have a reference counting issue.

Regards,
Christian.


Best regards
Thomas

Apart from that looks like a good idea to me.

Christian.

      drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size);
      INIT_LIST_HEAD(&bo->shadow_list);
      bo->vm_bo = NULL;

      

      
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

--------------29780EC5D45E17F55361B946-- --===============1987600549== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx --===============1987600549==-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6BBAC43461 for ; Mon, 14 Sep 2020 19:33:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94E12207EA for ; Mon, 14 Sep 2020 19:33:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tqZKHKN1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94E12207EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB9B26E55E; Mon, 14 Sep 2020 19:33:27 +0000 (UTC) Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id B488F6E4E8; Mon, 14 Sep 2020 17:51:12 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id l17so399655edq.12; Mon, 14 Sep 2020 10:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=cinD4tchkxocHKviw5M6liz7E8UU7FD4XovFhsNsjyI=; b=tqZKHKN1V6C6oQElOwFS4+jyvbLS9BzylBSbwUbd02rQ76/lT49lrc+1lA+C8DN8Dd Nc0GbsJCPaCOHclSGk4/rG8fGqamsaUD5D+cmba9mrjnCmyMQa6mZgYbC5c/w9kZwhfb aJRkSAXMinRH/3gtwBaIiUmXBpTvWVTG5r/fSBBRDxoLah5xFDDjscX2kvgZr8AfeAC0 gMFA6X+UeLkG9NLYtld2tfKKPMYvQC8wFwsgo6QeCj/1SP2gpRaBO+qK+7RqV2MPi/tn AYDtIiDOG7XJrasBS+cYJnkZhddVCOd5+jF87VvJuyV9OeppL+UABQ8WQSDYD79g3mPs ytfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language; bh=cinD4tchkxocHKviw5M6liz7E8UU7FD4XovFhsNsjyI=; b=XzUNwjExRpWcHkXwHWNfAsvRcXiuP4E7y4VV9owD+CyqdYI+pUkjNfgjiGv8u62Her HHXS8d4H8wB8rWXrApK8xB3yS2gw5f0dlU87YtCDK4Co5vevxYGPVOePdDuXwX/PDPd4 gfYsGRcwBWDJS28ezMn4okCp3LEIb912iibK68v2Cmtz3JsbLAyMUcGZDNsMFqi7zjtw +UfZtIf3O5AdjnTftTCan4wn+1mgWjoV4wkZuej7KOxlt6HVgfFRZrw2v1nwO3O5K/YG B1NQT2Uj2T8Y/TRcSzOZidMNHboGfghlInya6/+RNmal7BRep2UVtidq95VVwIVf7Nio RG5Q== X-Gm-Message-State: AOAM530GN4ze5YiijLF6SwdudN+PT6Iz+0syxbB0ys7l7qhOGW5nCTHp KcALNXAVnIXXZG5Zrb1cE4M= X-Google-Smtp-Source: ABdhPJyHIadEQ0w95cMm+XKXdD2wy6DDt/xaqpuYqbeZucK6WVOqY6RobxWEhAYoVlCs20sURxiHJg== X-Received: by 2002:a50:b046:: with SMTP id i64mr19248036edd.9.1600105871323; Mon, 14 Sep 2020 10:51:11 -0700 (PDT) Received: from ?IPv6:2a02:908:1252:fb60:be8a:bd56:1f94:86e7? ([2a02:908:1252:fb60:be8a:bd56:1f94:86e7]) by smtp.gmail.com with ESMTPSA id c22sm9791887edr.70.2020.09.14.10.51.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 10:51:10 -0700 (PDT) To: Thomas Zimmermann , =?UTF-8?Q?Christian_K=c3=b6nig?= , alexander.deucher@amd.com, airlied@linux.ie, daniel@ffwll.ch, linux@armlinux.org.uk, maarten.lankhorst@linux.intel.com, mripard@kernel.org, l.stach@pengutronix.de, christian.gmeiner@gmail.com, inki.dae@samsung.com, jy0922.shim@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, krzk@kernel.org, patrik.r.jakobsson@gmail.com, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, chunkuang.hu@kernel.org, p.zabel@pengutronix.de, matthias.bgg@gmail.com, robdclark@gmail.com, sean@poorly.run, bskeggs@redhat.com, tomi.valkeinen@ti.com, eric@anholt.net, hjc@rock-chips.com, heiko@sntech.de, thierry.reding@gmail.com, jonathanh@nvidia.com, rodrigosiqueiramelo@gmail.com, hamohammed.sa@gmail.com, oleksandr_andrushchenko@epam.com, hyun.kwon@xilinx.com, laurent.pinchart@ideasonboard.com, michal.simek@xilinx.com, sumit.semwal@linaro.org, evan.quan@amd.com, Hawking.Zhang@amd.com, tianci.yin@amd.com, marek.olsak@amd.com, hdegoede@redhat.com, andrey.grodzovsky@amd.com, Felix.Kuehling@amd.com, xinhui.pan@amd.com, aaron.liu@amd.com, nirmoy.das@amd.com, chris@chris-wilson.co.uk, matthew.auld@intel.com, abdiel.janulgue@linux.intel.com, tvrtko.ursulin@linux.intel.com, andi.shyti@intel.com, sam@ravnborg.org, miaoqinglang@huawei.com, emil.velikov@collabora.com References: <20200813083644.31711-1-tzimmermann@suse.de> <20200813083644.31711-2-tzimmermann@suse.de> <5c1b3cab-1898-46df-2c5c-23ab6cbfbb7a@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Mon, 14 Sep 2020 19:51:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Mailman-Approved-At: Mon, 14 Sep 2020 19:33:26 +0000 Subject: Re: [Intel-gfx] [PATCH 01/20] drm/amdgpu: Introduce GEM object functions X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: christian.koenig@amd.com Cc: linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-mediatek@lists.infradead.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org, xen-devel@lists.xenproject.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============0090760880==" Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This is a multi-part message in MIME format. --===============0090760880== Content-Type: multipart/alternative; boundary="------------29780EC5D45E17F55361B946" Content-Language: en-US This is a multi-part message in MIME format. --------------29780EC5D45E17F55361B946 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Am 14.09.20 um 17:05 schrieb Thomas Zimmermann: > Hi > > Am 13.08.20 um 12:22 schrieb Christian König: >> Am 13.08.20 um 10:36 schrieb Thomas Zimmermann: >>> GEM object functions deprecate several similar callback interfaces in >>> struct drm_driver. This patch replaces the per-driver callbacks with >>> per-instance callbacks in amdgpu. The only exception is gem_prime_mmap, >>> which is non-trivial to convert. >>> >>> Signed-off-by: Thomas Zimmermann >>> --- >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------ >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++ >>>   2 files changed, 12 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> index 81a79760ca61..51525b8774c9 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> @@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = { >>>       .lastclose = amdgpu_driver_lastclose_kms, >>>       .irq_handler = amdgpu_irq_handler, >>>       .ioctls = amdgpu_ioctls_kms, >>> -    .gem_free_object_unlocked = amdgpu_gem_object_free, >>> -    .gem_open_object = amdgpu_gem_object_open, >>> -    .gem_close_object = amdgpu_gem_object_close, >>>       .dumb_create = amdgpu_mode_dumb_create, >>>       .dumb_map_offset = amdgpu_mode_dumb_mmap, >>>       .fops = &amdgpu_driver_kms_fops, >>>         .prime_handle_to_fd = drm_gem_prime_handle_to_fd, >>>       .prime_fd_to_handle = drm_gem_prime_fd_to_handle, >>> -    .gem_prime_export = amdgpu_gem_prime_export, >>>       .gem_prime_import = amdgpu_gem_prime_import, >>> -    .gem_prime_vmap = amdgpu_gem_prime_vmap, >>> -    .gem_prime_vunmap = amdgpu_gem_prime_vunmap, >>>       .gem_prime_mmap = amdgpu_gem_prime_mmap, >>>         .name = DRIVER_NAME, >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> index 43f4966331dd..ca2b79f94e99 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> @@ -36,6 +36,7 @@ >>>   #include >>>   #include >>>   #include "amdgpu.h" >>> +#include "amdgpu_dma_buf.h" >>>   #include "amdgpu_trace.h" >>>   #include "amdgpu_amdkfd.h" >>>   @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags) >>>   #endif >>>   } >>>   +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = { >>> +    .free = amdgpu_gem_object_free, >>> +    .open = amdgpu_gem_object_open, >>> +    .close = amdgpu_gem_object_close, >>> +    .export = amdgpu_gem_prime_export, >>> +    .vmap = amdgpu_gem_prime_vmap, >>> +    .vunmap = amdgpu_gem_prime_vunmap, >>> +}; >>> + >> Wrong file, this belongs into amdgpu_gem.c >> >>>   static int amdgpu_bo_do_create(struct amdgpu_device *adev, >>>                      struct amdgpu_bo_param *bp, >>>                      struct amdgpu_bo **bo_ptr) >>> @@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct >>> amdgpu_device *adev, >>>       bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL); >>>       if (bo == NULL) >>>           return -ENOMEM; >>> + >>> +    bo->tbo.base.funcs = &amdgpu_gem_object_funcs; >> And this should probably go into amdgpu_gem_object_create(). > I'm trying to understand what amdgpu does. What about all the places > where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss > the free callback for the GEM object? Those shouldn't have a GEM object in the first place. Or otherwise we would have a reference counting issue. Regards, Christian. > > Best regards > Thomas > >> Apart from that looks like a good idea to me. >> >> Christian. >> >>>       drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size); >>>       INIT_LIST_HEAD(&bo->shadow_list); >>>       bo->vm_bo = NULL; > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx --------------29780EC5D45E17F55361B946 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
Am 14.09.20 um 17:05 schrieb Thomas Zimmermann:
Hi

Am 13.08.20 um 12:22 schrieb Christian König:
Am 13.08.20 um 10:36 schrieb Thomas Zimmermann:
GEM object functions deprecate several similar callback interfaces in
struct drm_driver. This patch replaces the per-driver callbacks with
per-instance callbacks in amdgpu. The only exception is gem_prime_mmap,
which is non-trivial to convert.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++
  2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 81a79760ca61..51525b8774c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = {
      .lastclose = amdgpu_driver_lastclose_kms,
      .irq_handler = amdgpu_irq_handler,
      .ioctls = amdgpu_ioctls_kms,
-    .gem_free_object_unlocked = amdgpu_gem_object_free,
-    .gem_open_object = amdgpu_gem_object_open,
-    .gem_close_object = amdgpu_gem_object_close,
      .dumb_create = amdgpu_mode_dumb_create,
      .dumb_map_offset = amdgpu_mode_dumb_mmap,
      .fops = &amdgpu_driver_kms_fops,
        .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
      .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-    .gem_prime_export = amdgpu_gem_prime_export,
      .gem_prime_import = amdgpu_gem_prime_import,
-    .gem_prime_vmap = amdgpu_gem_prime_vmap,
-    .gem_prime_vunmap = amdgpu_gem_prime_vunmap,
      .gem_prime_mmap = amdgpu_gem_prime_mmap,
        .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 43f4966331dd..ca2b79f94e99 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -36,6 +36,7 @@
  #include <drm/amdgpu_drm.h>
  #include <drm/drm_cache.h>
  #include "amdgpu.h"
+#include "amdgpu_dma_buf.h"
  #include "amdgpu_trace.h"
  #include "amdgpu_amdkfd.h"
  @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags)
  #endif
  }
  +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = {
+    .free = amdgpu_gem_object_free,
+    .open = amdgpu_gem_object_open,
+    .close = amdgpu_gem_object_close,
+    .export = amdgpu_gem_prime_export,
+    .vmap = amdgpu_gem_prime_vmap,
+    .vunmap = amdgpu_gem_prime_vunmap,
+};
+
Wrong file, this belongs into amdgpu_gem.c

  static int amdgpu_bo_do_create(struct amdgpu_device *adev,
                     struct amdgpu_bo_param *bp,
                     struct amdgpu_bo **bo_ptr)
@@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct
amdgpu_device *adev,
      bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
      if (bo == NULL)
          return -ENOMEM;
+
+    bo->tbo.base.funcs = &amdgpu_gem_object_funcs;
And this should probably go into amdgpu_gem_object_create().
I'm trying to understand what amdgpu does.  What about all the places
where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss
the free callback for the GEM object?

Those shouldn't have a GEM object in the first place.

Or otherwise we would have a reference counting issue.

Regards,
Christian.


Best regards
Thomas

Apart from that looks like a good idea to me.

Christian.

      drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size);
      INIT_LIST_HEAD(&bo->shadow_list);
      bo->vm_bo = NULL;

      

      
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

--------------29780EC5D45E17F55361B946-- --===============0090760880== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============0090760880==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Christian_K=c3=b6nig?= Subject: Re: [PATCH 01/20] drm/amdgpu: Introduce GEM object functions Date: Mon, 14 Sep 2020 19:51:07 +0200 Message-ID: References: <20200813083644.31711-1-tzimmermann@suse.de> <20200813083644.31711-2-tzimmermann@suse.de> <5c1b3cab-1898-46df-2c5c-23ab6cbfbb7a@amd.com> Reply-To: christian.koenig-5C7GfCeVMHo@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1987600549==" Return-path: In-Reply-To: Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Sender: "amd-gfx" To: Thomas Zimmermann , =?UTF-8?Q?Christian_K=c3=b6nig?= , alexander.deucher-5C7GfCeVMHo@public.gmane.org, airlied-cv59FeDIM0c@public.gmane.org, daniel-/w4YWyX8dFk@public.gmane.org, linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org, maarten.lankhorst-VuQAYsv1563Yd54FQh9/CA@public.gmane.org, mripard-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, l.stach-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org, christian.gmeiner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, inki.dae-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org, jy0922.shim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org, sw0312.kim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org, kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org, kgene-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, krzk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, patrik.r.jakobsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, jani.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org, joonas.lahtinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org, rodrigo.vivi-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, chunkuang.hu-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org, matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org, bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, tomi.valkeinen-l0cyMroinI0@public.gmane.org, eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org, hjc-TNX95d0MmH7DzftRWevZcw@public.gmane.org, heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org, thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org, rodrigosiqueiramelo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, hamohammed.sa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, oleksandr_andrushchenko@ep Cc: linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, etnaviv-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.org, freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: nouveau.vger.kernel.org This is a multi-part message in MIME format. --===============1987600549== Content-Type: multipart/alternative; boundary="------------29780EC5D45E17F55361B946" Content-Language: en-US This is a multi-part message in MIME format. --------------29780EC5D45E17F55361B946 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Am 14.09.20 um 17:05 schrieb Thomas Zimmermann: > Hi > > Am 13.08.20 um 12:22 schrieb Christian König: >> Am 13.08.20 um 10:36 schrieb Thomas Zimmermann: >>> GEM object functions deprecate several similar callback interfaces in >>> struct drm_driver. This patch replaces the per-driver callbacks with >>> per-instance callbacks in amdgpu. The only exception is gem_prime_mmap, >>> which is non-trivial to convert. >>> >>> Signed-off-by: Thomas Zimmermann >>> --- >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------ >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++ >>>   2 files changed, 12 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> index 81a79760ca61..51525b8774c9 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> @@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = { >>>       .lastclose = amdgpu_driver_lastclose_kms, >>>       .irq_handler = amdgpu_irq_handler, >>>       .ioctls = amdgpu_ioctls_kms, >>> -    .gem_free_object_unlocked = amdgpu_gem_object_free, >>> -    .gem_open_object = amdgpu_gem_object_open, >>> -    .gem_close_object = amdgpu_gem_object_close, >>>       .dumb_create = amdgpu_mode_dumb_create, >>>       .dumb_map_offset = amdgpu_mode_dumb_mmap, >>>       .fops = &amdgpu_driver_kms_fops, >>>         .prime_handle_to_fd = drm_gem_prime_handle_to_fd, >>>       .prime_fd_to_handle = drm_gem_prime_fd_to_handle, >>> -    .gem_prime_export = amdgpu_gem_prime_export, >>>       .gem_prime_import = amdgpu_gem_prime_import, >>> -    .gem_prime_vmap = amdgpu_gem_prime_vmap, >>> -    .gem_prime_vunmap = amdgpu_gem_prime_vunmap, >>>       .gem_prime_mmap = amdgpu_gem_prime_mmap, >>>         .name = DRIVER_NAME, >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> index 43f4966331dd..ca2b79f94e99 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> @@ -36,6 +36,7 @@ >>>   #include >>>   #include >>>   #include "amdgpu.h" >>> +#include "amdgpu_dma_buf.h" >>>   #include "amdgpu_trace.h" >>>   #include "amdgpu_amdkfd.h" >>>   @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags) >>>   #endif >>>   } >>>   +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = { >>> +    .free = amdgpu_gem_object_free, >>> +    .open = amdgpu_gem_object_open, >>> +    .close = amdgpu_gem_object_close, >>> +    .export = amdgpu_gem_prime_export, >>> +    .vmap = amdgpu_gem_prime_vmap, >>> +    .vunmap = amdgpu_gem_prime_vunmap, >>> +}; >>> + >> Wrong file, this belongs into amdgpu_gem.c >> >>>   static int amdgpu_bo_do_create(struct amdgpu_device *adev, >>>                      struct amdgpu_bo_param *bp, >>>                      struct amdgpu_bo **bo_ptr) >>> @@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct >>> amdgpu_device *adev, >>>       bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL); >>>       if (bo == NULL) >>>           return -ENOMEM; >>> + >>> +    bo->tbo.base.funcs = &amdgpu_gem_object_funcs; >> And this should probably go into amdgpu_gem_object_create(). > I'm trying to understand what amdgpu does. What about all the places > where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss > the free callback for the GEM object? Those shouldn't have a GEM object in the first place. Or otherwise we would have a reference counting issue. Regards, Christian. > > Best regards > Thomas > >> Apart from that looks like a good idea to me. >> >> Christian. >> >>>       drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size); >>>       INIT_LIST_HEAD(&bo->shadow_list); >>>       bo->vm_bo = NULL; > > _______________________________________________ > amd-gfx mailing list > amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx --------------29780EC5D45E17F55361B946 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
Am 14.09.20 um 17:05 schrieb Thomas Zimmermann:
Hi

Am 13.08.20 um 12:22 schrieb Christian König:
Am 13.08.20 um 10:36 schrieb Thomas Zimmermann:
GEM object functions deprecate several similar callback interfaces in
struct drm_driver. This patch replaces the per-driver callbacks with
per-instance callbacks in amdgpu. The only exception is gem_prime_mmap,
which is non-trivial to convert.

Signed-off-by: Thomas Zimmermann <tzimmermann-l3A5Bk7waGM@public.gmane.org>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++
  2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 81a79760ca61..51525b8774c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = {
      .lastclose = amdgpu_driver_lastclose_kms,
      .irq_handler = amdgpu_irq_handler,
      .ioctls = amdgpu_ioctls_kms,
-    .gem_free_object_unlocked = amdgpu_gem_object_free,
-    .gem_open_object = amdgpu_gem_object_open,
-    .gem_close_object = amdgpu_gem_object_close,
      .dumb_create = amdgpu_mode_dumb_create,
      .dumb_map_offset = amdgpu_mode_dumb_mmap,
      .fops = &amdgpu_driver_kms_fops,
        .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
      .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-    .gem_prime_export = amdgpu_gem_prime_export,
      .gem_prime_import = amdgpu_gem_prime_import,
-    .gem_prime_vmap = amdgpu_gem_prime_vmap,
-    .gem_prime_vunmap = amdgpu_gem_prime_vunmap,
      .gem_prime_mmap = amdgpu_gem_prime_mmap,
        .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 43f4966331dd..ca2b79f94e99 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -36,6 +36,7 @@
  #include <drm/amdgpu_drm.h>
  #include <drm/drm_cache.h>
  #include "amdgpu.h"
+#include "amdgpu_dma_buf.h"
  #include "amdgpu_trace.h"
  #include "amdgpu_amdkfd.h"
  @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags)
  #endif
  }
  +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = {
+    .free = amdgpu_gem_object_free,
+    .open = amdgpu_gem_object_open,
+    .close = amdgpu_gem_object_close,
+    .export = amdgpu_gem_prime_export,
+    .vmap = amdgpu_gem_prime_vmap,
+    .vunmap = amdgpu_gem_prime_vunmap,
+};
+
Wrong file, this belongs into amdgpu_gem.c

  static int amdgpu_bo_do_create(struct amdgpu_device *adev,
                     struct amdgpu_bo_param *bp,
                     struct amdgpu_bo **bo_ptr)
@@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct
amdgpu_device *adev,
      bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
      if (bo == NULL)
          return -ENOMEM;
+
+    bo->tbo.base.funcs = &amdgpu_gem_object_funcs;
And this should probably go into amdgpu_gem_object_create().
I'm trying to understand what amdgpu does.  What about all the places
where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss
the free callback for the GEM object?

Those shouldn't have a GEM object in the first place.

Or otherwise we would have a reference counting issue.

Regards,
Christian.


Best regards
Thomas

Apart from that looks like a good idea to me.

Christian.

      drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size);
      INIT_LIST_HEAD(&bo->shadow_list);
      bo->vm_bo = NULL;

      

      
_______________________________________________
amd-gfx mailing list
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

--------------29780EC5D45E17F55361B946-- --===============1987600549== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ amd-gfx mailing list amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx --===============1987600549==-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B842AC433E2 for ; Mon, 14 Sep 2020 17:51:53 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30DE220EDD for ; Mon, 14 Sep 2020 17:51:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tqZKHKN1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30DE220EDD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kHsdH-00078x-Ii; Mon, 14 Sep 2020 17:51:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kHsdF-00078s-UJ for xen-devel@lists.xenproject.org; Mon, 14 Sep 2020 17:51:14 +0000 X-Inumbo-ID: b2084c58-f000-4eb5-8824-13c42454dc7b Received: from mail-ed1-x544.google.com (unknown [2a00:1450:4864:20::544]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b2084c58-f000-4eb5-8824-13c42454dc7b; Mon, 14 Sep 2020 17:51:12 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id k14so478910edo.1 for ; Mon, 14 Sep 2020 10:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=cinD4tchkxocHKviw5M6liz7E8UU7FD4XovFhsNsjyI=; b=tqZKHKN1V6C6oQElOwFS4+jyvbLS9BzylBSbwUbd02rQ76/lT49lrc+1lA+C8DN8Dd Nc0GbsJCPaCOHclSGk4/rG8fGqamsaUD5D+cmba9mrjnCmyMQa6mZgYbC5c/w9kZwhfb aJRkSAXMinRH/3gtwBaIiUmXBpTvWVTG5r/fSBBRDxoLah5xFDDjscX2kvgZr8AfeAC0 gMFA6X+UeLkG9NLYtld2tfKKPMYvQC8wFwsgo6QeCj/1SP2gpRaBO+qK+7RqV2MPi/tn AYDtIiDOG7XJrasBS+cYJnkZhddVCOd5+jF87VvJuyV9OeppL+UABQ8WQSDYD79g3mPs ytfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language; bh=cinD4tchkxocHKviw5M6liz7E8UU7FD4XovFhsNsjyI=; b=o2NfK5ydrJdQbOj11DR/lh7Lb8L61sDqe2I64gb1ROOahs7C0krJA5Nnl/IjWZIedY Ml0Oc9yg/o2GHbD3Okap2bPGVeGkJPl1bRj4WBBk6IasIvS5riuznJo+8xDEWgICdksG jTkGBkBdnKHUEdfzasnxA07vAaLIcFZUBmoC+nY6MNbHo1Abx2WctZJIs0qPU8iSzbW5 CgB6e7bpj7R9JU8hv605WH1BzIBRQ6jy755vvQiKqMahrkwhm2wt266tu8dy8m/O8t2U +sGNccczJX2afi3NEDzr/kAuDgN3aCrYFT/m2H/DOjsBTikzkTPw0WazvnyAcdlg4JQj sbQQ== X-Gm-Message-State: AOAM5315C/N1yUXyDS7JqX+rMkzBvoQqYqlWMfqMaw6X1xHSyGw9+D6L P5q1OO71BD6X4u86u7GPRc4= X-Google-Smtp-Source: ABdhPJyHIadEQ0w95cMm+XKXdD2wy6DDt/xaqpuYqbeZucK6WVOqY6RobxWEhAYoVlCs20sURxiHJg== X-Received: by 2002:a50:b046:: with SMTP id i64mr19248036edd.9.1600105871323; Mon, 14 Sep 2020 10:51:11 -0700 (PDT) Received: from ?IPv6:2a02:908:1252:fb60:be8a:bd56:1f94:86e7? ([2a02:908:1252:fb60:be8a:bd56:1f94:86e7]) by smtp.gmail.com with ESMTPSA id c22sm9791887edr.70.2020.09.14.10.51.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 10:51:10 -0700 (PDT) Subject: Re: [PATCH 01/20] drm/amdgpu: Introduce GEM object functions To: Thomas Zimmermann , =?UTF-8?Q?Christian_K=c3=b6nig?= , alexander.deucher@amd.com, airlied@linux.ie, daniel@ffwll.ch, linux@armlinux.org.uk, maarten.lankhorst@linux.intel.com, mripard@kernel.org, l.stach@pengutronix.de, christian.gmeiner@gmail.com, inki.dae@samsung.com, jy0922.shim@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, krzk@kernel.org, patrik.r.jakobsson@gmail.com, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, chunkuang.hu@kernel.org, p.zabel@pengutronix.de, matthias.bgg@gmail.com, robdclark@gmail.com, sean@poorly.run, bskeggs@redhat.com, tomi.valkeinen@ti.com, eric@anholt.net, hjc@rock-chips.com, heiko@sntech.de, thierry.reding@gmail.com, jonathanh@nvidia.com, rodrigosiqueiramelo@gmail.com, hamohammed.sa@gmail.com, oleksandr_andrushchenko@epam.com, hyun.kwon@xilinx.com, laurent.pinchart@ideasonboard.com, michal.simek@xilinx.com, sumit.semwal@linaro.org, evan.quan@amd.com, Hawking.Zhang@amd.com, tianci.yin@amd.com, marek.olsak@amd.com, hdegoede@redhat.com, andrey.grodzovsky@amd.com, Felix.Kuehling@amd.com, xinhui.pan@amd.com, aaron.liu@amd.com, nirmoy.das@amd.com, chris@chris-wilson.co.uk, matthew.auld@intel.com, abdiel.janulgue@linux.intel.com, tvrtko.ursulin@linux.intel.com, andi.shyti@intel.com, sam@ravnborg.org, miaoqinglang@huawei.com, emil.velikov@collabora.com Cc: linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-mediatek@lists.infradead.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org, xen-devel@lists.xenproject.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org References: <20200813083644.31711-1-tzimmermann@suse.de> <20200813083644.31711-2-tzimmermann@suse.de> <5c1b3cab-1898-46df-2c5c-23ab6cbfbb7a@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Mon, 14 Sep 2020 19:51:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------29780EC5D45E17F55361B946" Content-Language: en-US X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Reply-To: christian.koenig@amd.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This is a multi-part message in MIME format. --------------29780EC5D45E17F55361B946 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Am 14.09.20 um 17:05 schrieb Thomas Zimmermann: > Hi > > Am 13.08.20 um 12:22 schrieb Christian König: >> Am 13.08.20 um 10:36 schrieb Thomas Zimmermann: >>> GEM object functions deprecate several similar callback interfaces in >>> struct drm_driver. This patch replaces the per-driver callbacks with >>> per-instance callbacks in amdgpu. The only exception is gem_prime_mmap, >>> which is non-trivial to convert. >>> >>> Signed-off-by: Thomas Zimmermann >>> --- >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------ >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++ >>>   2 files changed, 12 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> index 81a79760ca61..51525b8774c9 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> @@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = { >>>       .lastclose = amdgpu_driver_lastclose_kms, >>>       .irq_handler = amdgpu_irq_handler, >>>       .ioctls = amdgpu_ioctls_kms, >>> -    .gem_free_object_unlocked = amdgpu_gem_object_free, >>> -    .gem_open_object = amdgpu_gem_object_open, >>> -    .gem_close_object = amdgpu_gem_object_close, >>>       .dumb_create = amdgpu_mode_dumb_create, >>>       .dumb_map_offset = amdgpu_mode_dumb_mmap, >>>       .fops = &amdgpu_driver_kms_fops, >>>         .prime_handle_to_fd = drm_gem_prime_handle_to_fd, >>>       .prime_fd_to_handle = drm_gem_prime_fd_to_handle, >>> -    .gem_prime_export = amdgpu_gem_prime_export, >>>       .gem_prime_import = amdgpu_gem_prime_import, >>> -    .gem_prime_vmap = amdgpu_gem_prime_vmap, >>> -    .gem_prime_vunmap = amdgpu_gem_prime_vunmap, >>>       .gem_prime_mmap = amdgpu_gem_prime_mmap, >>>         .name = DRIVER_NAME, >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> index 43f4966331dd..ca2b79f94e99 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> @@ -36,6 +36,7 @@ >>>   #include >>>   #include >>>   #include "amdgpu.h" >>> +#include "amdgpu_dma_buf.h" >>>   #include "amdgpu_trace.h" >>>   #include "amdgpu_amdkfd.h" >>>   @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags) >>>   #endif >>>   } >>>   +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = { >>> +    .free = amdgpu_gem_object_free, >>> +    .open = amdgpu_gem_object_open, >>> +    .close = amdgpu_gem_object_close, >>> +    .export = amdgpu_gem_prime_export, >>> +    .vmap = amdgpu_gem_prime_vmap, >>> +    .vunmap = amdgpu_gem_prime_vunmap, >>> +}; >>> + >> Wrong file, this belongs into amdgpu_gem.c >> >>>   static int amdgpu_bo_do_create(struct amdgpu_device *adev, >>>                      struct amdgpu_bo_param *bp, >>>                      struct amdgpu_bo **bo_ptr) >>> @@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct >>> amdgpu_device *adev, >>>       bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL); >>>       if (bo == NULL) >>>           return -ENOMEM; >>> + >>> +    bo->tbo.base.funcs = &amdgpu_gem_object_funcs; >> And this should probably go into amdgpu_gem_object_create(). > I'm trying to understand what amdgpu does. What about all the places > where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss > the free callback for the GEM object? Those shouldn't have a GEM object in the first place. Or otherwise we would have a reference counting issue. Regards, Christian. > > Best regards > Thomas > >> Apart from that looks like a good idea to me. >> >> Christian. >> >>>       drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size); >>>       INIT_LIST_HEAD(&bo->shadow_list); >>>       bo->vm_bo = NULL; > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx --------------29780EC5D45E17F55361B946 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
Am 14.09.20 um 17:05 schrieb Thomas Zimmermann:
Hi

Am 13.08.20 um 12:22 schrieb Christian König:
Am 13.08.20 um 10:36 schrieb Thomas Zimmermann:
GEM object functions deprecate several similar callback interfaces in
struct drm_driver. This patch replaces the per-driver callbacks with
per-instance callbacks in amdgpu. The only exception is gem_prime_mmap,
which is non-trivial to convert.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++
  2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 81a79760ca61..51525b8774c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = {
      .lastclose = amdgpu_driver_lastclose_kms,
      .irq_handler = amdgpu_irq_handler,
      .ioctls = amdgpu_ioctls_kms,
-    .gem_free_object_unlocked = amdgpu_gem_object_free,
-    .gem_open_object = amdgpu_gem_object_open,
-    .gem_close_object = amdgpu_gem_object_close,
      .dumb_create = amdgpu_mode_dumb_create,
      .dumb_map_offset = amdgpu_mode_dumb_mmap,
      .fops = &amdgpu_driver_kms_fops,
        .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
      .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-    .gem_prime_export = amdgpu_gem_prime_export,
      .gem_prime_import = amdgpu_gem_prime_import,
-    .gem_prime_vmap = amdgpu_gem_prime_vmap,
-    .gem_prime_vunmap = amdgpu_gem_prime_vunmap,
      .gem_prime_mmap = amdgpu_gem_prime_mmap,
        .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 43f4966331dd..ca2b79f94e99 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -36,6 +36,7 @@
  #include <drm/amdgpu_drm.h>
  #include <drm/drm_cache.h>
  #include "amdgpu.h"
+#include "amdgpu_dma_buf.h"
  #include "amdgpu_trace.h"
  #include "amdgpu_amdkfd.h"
  @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags)
  #endif
  }
  +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = {
+    .free = amdgpu_gem_object_free,
+    .open = amdgpu_gem_object_open,
+    .close = amdgpu_gem_object_close,
+    .export = amdgpu_gem_prime_export,
+    .vmap = amdgpu_gem_prime_vmap,
+    .vunmap = amdgpu_gem_prime_vunmap,
+};
+
Wrong file, this belongs into amdgpu_gem.c

  static int amdgpu_bo_do_create(struct amdgpu_device *adev,
                     struct amdgpu_bo_param *bp,
                     struct amdgpu_bo **bo_ptr)
@@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct
amdgpu_device *adev,
      bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
      if (bo == NULL)
          return -ENOMEM;
+
+    bo->tbo.base.funcs = &amdgpu_gem_object_funcs;
And this should probably go into amdgpu_gem_object_create().
I'm trying to understand what amdgpu does.  What about all the places
where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss
the free callback for the GEM object?

Those shouldn't have a GEM object in the first place.

Or otherwise we would have a reference counting issue.

Regards,
Christian.


Best regards
Thomas

Apart from that looks like a good idea to me.

Christian.

      drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size);
      INIT_LIST_HEAD(&bo->shadow_list);
      bo->vm_bo = NULL;

      

      
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

--------------29780EC5D45E17F55361B946-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7051FC433E2 for ; Mon, 14 Sep 2020 17:51:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1696220EDD for ; Mon, 14 Sep 2020 17:51:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tqZKHKN1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1696220EDD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8185D6E52C; Mon, 14 Sep 2020 17:51:14 +0000 (UTC) Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id B488F6E4E8; Mon, 14 Sep 2020 17:51:12 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id l17so399655edq.12; Mon, 14 Sep 2020 10:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=cinD4tchkxocHKviw5M6liz7E8UU7FD4XovFhsNsjyI=; b=tqZKHKN1V6C6oQElOwFS4+jyvbLS9BzylBSbwUbd02rQ76/lT49lrc+1lA+C8DN8Dd Nc0GbsJCPaCOHclSGk4/rG8fGqamsaUD5D+cmba9mrjnCmyMQa6mZgYbC5c/w9kZwhfb aJRkSAXMinRH/3gtwBaIiUmXBpTvWVTG5r/fSBBRDxoLah5xFDDjscX2kvgZr8AfeAC0 gMFA6X+UeLkG9NLYtld2tfKKPMYvQC8wFwsgo6QeCj/1SP2gpRaBO+qK+7RqV2MPi/tn AYDtIiDOG7XJrasBS+cYJnkZhddVCOd5+jF87VvJuyV9OeppL+UABQ8WQSDYD79g3mPs ytfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language; bh=cinD4tchkxocHKviw5M6liz7E8UU7FD4XovFhsNsjyI=; b=XzUNwjExRpWcHkXwHWNfAsvRcXiuP4E7y4VV9owD+CyqdYI+pUkjNfgjiGv8u62Her HHXS8d4H8wB8rWXrApK8xB3yS2gw5f0dlU87YtCDK4Co5vevxYGPVOePdDuXwX/PDPd4 gfYsGRcwBWDJS28ezMn4okCp3LEIb912iibK68v2Cmtz3JsbLAyMUcGZDNsMFqi7zjtw +UfZtIf3O5AdjnTftTCan4wn+1mgWjoV4wkZuej7KOxlt6HVgfFRZrw2v1nwO3O5K/YG B1NQT2Uj2T8Y/TRcSzOZidMNHboGfghlInya6/+RNmal7BRep2UVtidq95VVwIVf7Nio RG5Q== X-Gm-Message-State: AOAM530GN4ze5YiijLF6SwdudN+PT6Iz+0syxbB0ys7l7qhOGW5nCTHp KcALNXAVnIXXZG5Zrb1cE4M= X-Google-Smtp-Source: ABdhPJyHIadEQ0w95cMm+XKXdD2wy6DDt/xaqpuYqbeZucK6WVOqY6RobxWEhAYoVlCs20sURxiHJg== X-Received: by 2002:a50:b046:: with SMTP id i64mr19248036edd.9.1600105871323; Mon, 14 Sep 2020 10:51:11 -0700 (PDT) Received: from ?IPv6:2a02:908:1252:fb60:be8a:bd56:1f94:86e7? ([2a02:908:1252:fb60:be8a:bd56:1f94:86e7]) by smtp.gmail.com with ESMTPSA id c22sm9791887edr.70.2020.09.14.10.51.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 10:51:10 -0700 (PDT) Subject: Re: [PATCH 01/20] drm/amdgpu: Introduce GEM object functions To: Thomas Zimmermann , =?UTF-8?Q?Christian_K=c3=b6nig?= , alexander.deucher@amd.com, airlied@linux.ie, daniel@ffwll.ch, linux@armlinux.org.uk, maarten.lankhorst@linux.intel.com, mripard@kernel.org, l.stach@pengutronix.de, christian.gmeiner@gmail.com, inki.dae@samsung.com, jy0922.shim@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, krzk@kernel.org, patrik.r.jakobsson@gmail.com, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, chunkuang.hu@kernel.org, p.zabel@pengutronix.de, matthias.bgg@gmail.com, robdclark@gmail.com, sean@poorly.run, bskeggs@redhat.com, tomi.valkeinen@ti.com, eric@anholt.net, hjc@rock-chips.com, heiko@sntech.de, thierry.reding@gmail.com, jonathanh@nvidia.com, rodrigosiqueiramelo@gmail.com, hamohammed.sa@gmail.com, oleksandr_andrushchenko@epam.com, hyun.kwon@xilinx.com, laurent.pinchart@ideasonboard.com, michal.simek@xilinx.com, sumit.semwal@linaro.org, evan.quan@amd.com, Hawking.Zhang@amd.com, tianci.yin@amd.com, marek.olsak@amd.com, hdegoede@redhat.com, andrey.grodzovsky@amd.com, Felix.Kuehling@amd.com, xinhui.pan@amd.com, aaron.liu@amd.com, nirmoy.das@amd.com, chris@chris-wilson.co.uk, matthew.auld@intel.com, abdiel.janulgue@linux.intel.com, tvrtko.ursulin@linux.intel.com, andi.shyti@intel.com, sam@ravnborg.org, miaoqinglang@huawei.com, emil.velikov@collabora.com References: <20200813083644.31711-1-tzimmermann@suse.de> <20200813083644.31711-2-tzimmermann@suse.de> <5c1b3cab-1898-46df-2c5c-23ab6cbfbb7a@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Mon, 14 Sep 2020 19:51:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: christian.koenig@amd.com Cc: linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-mediatek@lists.infradead.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org, xen-devel@lists.xenproject.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============1257912369==" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This is a multi-part message in MIME format. --===============1257912369== Content-Type: multipart/alternative; boundary="------------29780EC5D45E17F55361B946" Content-Language: en-US This is a multi-part message in MIME format. --------------29780EC5D45E17F55361B946 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Am 14.09.20 um 17:05 schrieb Thomas Zimmermann: > Hi > > Am 13.08.20 um 12:22 schrieb Christian König: >> Am 13.08.20 um 10:36 schrieb Thomas Zimmermann: >>> GEM object functions deprecate several similar callback interfaces in >>> struct drm_driver. This patch replaces the per-driver callbacks with >>> per-instance callbacks in amdgpu. The only exception is gem_prime_mmap, >>> which is non-trivial to convert. >>> >>> Signed-off-by: Thomas Zimmermann >>> --- >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------ >>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++ >>>   2 files changed, 12 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> index 81a79760ca61..51525b8774c9 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c >>> @@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = { >>>       .lastclose = amdgpu_driver_lastclose_kms, >>>       .irq_handler = amdgpu_irq_handler, >>>       .ioctls = amdgpu_ioctls_kms, >>> -    .gem_free_object_unlocked = amdgpu_gem_object_free, >>> -    .gem_open_object = amdgpu_gem_object_open, >>> -    .gem_close_object = amdgpu_gem_object_close, >>>       .dumb_create = amdgpu_mode_dumb_create, >>>       .dumb_map_offset = amdgpu_mode_dumb_mmap, >>>       .fops = &amdgpu_driver_kms_fops, >>>         .prime_handle_to_fd = drm_gem_prime_handle_to_fd, >>>       .prime_fd_to_handle = drm_gem_prime_fd_to_handle, >>> -    .gem_prime_export = amdgpu_gem_prime_export, >>>       .gem_prime_import = amdgpu_gem_prime_import, >>> -    .gem_prime_vmap = amdgpu_gem_prime_vmap, >>> -    .gem_prime_vunmap = amdgpu_gem_prime_vunmap, >>>       .gem_prime_mmap = amdgpu_gem_prime_mmap, >>>         .name = DRIVER_NAME, >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> index 43f4966331dd..ca2b79f94e99 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> @@ -36,6 +36,7 @@ >>>   #include >>>   #include >>>   #include "amdgpu.h" >>> +#include "amdgpu_dma_buf.h" >>>   #include "amdgpu_trace.h" >>>   #include "amdgpu_amdkfd.h" >>>   @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags) >>>   #endif >>>   } >>>   +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = { >>> +    .free = amdgpu_gem_object_free, >>> +    .open = amdgpu_gem_object_open, >>> +    .close = amdgpu_gem_object_close, >>> +    .export = amdgpu_gem_prime_export, >>> +    .vmap = amdgpu_gem_prime_vmap, >>> +    .vunmap = amdgpu_gem_prime_vunmap, >>> +}; >>> + >> Wrong file, this belongs into amdgpu_gem.c >> >>>   static int amdgpu_bo_do_create(struct amdgpu_device *adev, >>>                      struct amdgpu_bo_param *bp, >>>                      struct amdgpu_bo **bo_ptr) >>> @@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct >>> amdgpu_device *adev, >>>       bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL); >>>       if (bo == NULL) >>>           return -ENOMEM; >>> + >>> +    bo->tbo.base.funcs = &amdgpu_gem_object_funcs; >> And this should probably go into amdgpu_gem_object_create(). > I'm trying to understand what amdgpu does. What about all the places > where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss > the free callback for the GEM object? Those shouldn't have a GEM object in the first place. Or otherwise we would have a reference counting issue. Regards, Christian. > > Best regards > Thomas > >> Apart from that looks like a good idea to me. >> >> Christian. >> >>>       drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size); >>>       INIT_LIST_HEAD(&bo->shadow_list); >>>       bo->vm_bo = NULL; > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx --------------29780EC5D45E17F55361B946 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
Am 14.09.20 um 17:05 schrieb Thomas Zimmermann:
Hi

Am 13.08.20 um 12:22 schrieb Christian König:
Am 13.08.20 um 10:36 schrieb Thomas Zimmermann:
GEM object functions deprecate several similar callback interfaces in
struct drm_driver. This patch replaces the per-driver callbacks with
per-instance callbacks in amdgpu. The only exception is gem_prime_mmap,
which is non-trivial to convert.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 ------
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++++
  2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 81a79760ca61..51525b8774c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1468,19 +1468,13 @@ static struct drm_driver kms_driver = {
      .lastclose = amdgpu_driver_lastclose_kms,
      .irq_handler = amdgpu_irq_handler,
      .ioctls = amdgpu_ioctls_kms,
-    .gem_free_object_unlocked = amdgpu_gem_object_free,
-    .gem_open_object = amdgpu_gem_object_open,
-    .gem_close_object = amdgpu_gem_object_close,
      .dumb_create = amdgpu_mode_dumb_create,
      .dumb_map_offset = amdgpu_mode_dumb_mmap,
      .fops = &amdgpu_driver_kms_fops,
        .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
      .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-    .gem_prime_export = amdgpu_gem_prime_export,
      .gem_prime_import = amdgpu_gem_prime_import,
-    .gem_prime_vmap = amdgpu_gem_prime_vmap,
-    .gem_prime_vunmap = amdgpu_gem_prime_vunmap,
      .gem_prime_mmap = amdgpu_gem_prime_mmap,
        .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 43f4966331dd..ca2b79f94e99 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -36,6 +36,7 @@
  #include <drm/amdgpu_drm.h>
  #include <drm/drm_cache.h>
  #include "amdgpu.h"
+#include "amdgpu_dma_buf.h"
  #include "amdgpu_trace.h"
  #include "amdgpu_amdkfd.h"
  @@ -510,6 +511,15 @@ bool amdgpu_bo_support_uswc(u64 bo_flags)
  #endif
  }
  +static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = {
+    .free = amdgpu_gem_object_free,
+    .open = amdgpu_gem_object_open,
+    .close = amdgpu_gem_object_close,
+    .export = amdgpu_gem_prime_export,
+    .vmap = amdgpu_gem_prime_vmap,
+    .vunmap = amdgpu_gem_prime_vunmap,
+};
+
Wrong file, this belongs into amdgpu_gem.c

  static int amdgpu_bo_do_create(struct amdgpu_device *adev,
                     struct amdgpu_bo_param *bp,
                     struct amdgpu_bo **bo_ptr)
@@ -552,6 +562,8 @@ static int amdgpu_bo_do_create(struct
amdgpu_device *adev,
      bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
      if (bo == NULL)
          return -ENOMEM;
+
+    bo->tbo.base.funcs = &amdgpu_gem_object_funcs;
And this should probably go into amdgpu_gem_object_create().
I'm trying to understand what amdgpu does.  What about all the places
where amdgpu calls amdgpu_bo_create() internally? Wouldn't these miss
the free callback for the GEM object?

Those shouldn't have a GEM object in the first place.

Or otherwise we would have a reference counting issue.

Regards,
Christian.


Best regards
Thomas

Apart from that looks like a good idea to me.

Christian.

      drm_gem_private_object_init(adev->ddev, &bo->tbo.base, size);
      INIT_LIST_HEAD(&bo->shadow_list);
      bo->vm_bo = NULL;

      

      
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

--------------29780EC5D45E17F55361B946-- --===============1257912369== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1257912369==--