From patchwork Sun Aug 25 21:19:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13776933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D667AC5321E for ; Sun, 25 Aug 2024 21:19:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 585D110E070; Sun, 25 Aug 2024 21:19:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="Ank4li6u"; dkim-atps=neutral Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id 845B710E06B for ; Sun, 25 Aug 2024 21:19:47 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724620785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sLbhQyosuMgaDHpyK8Ik2GZonV/i451ZkcNyo7o4Klg=; b=Ank4li6uKLashLRJebuBqMNVJAbsVilbMMwfvE1m0KuoGhu3su+xqWUwbSgotOfUgsG+9N VvRij9u1KKcsaidwYwdsfJPIluV0TWmT3DfY4M06PEmWmje/6D+i9TfMRUMOM9ajNe9VKE NCP5z37M14j9M+Ds1Y3R7n5wqNLzkUc= From: Sui Jingfeng To: Maxime Ripard , Thomas Zimmermann , Maarten Lankhorst , Lucas Stach , Russell King , Christian Gmeiner Cc: David Airlie , Daniel Vetter , etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH 1/2] drm/etnaviv: Implement drm_gem_object_funcs::print_info() Date: Mon, 26 Aug 2024 05:19:28 +0800 Message-Id: <20240825211929.614631-2-sui.jingfeng@linux.dev> In-Reply-To: <20240825211929.614631-1-sui.jingfeng@linux.dev> References: <20240825211929.614631-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It will be called by drm_gem_print_info() if have implemented, and this can provide more information about the framebuffer objects. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 32 +++++++++++++++++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_gem.h | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index 5c0c9d4e3be1..9a688c95f34d 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -533,8 +533,40 @@ static const struct vm_operations_struct vm_ops = { .close = drm_gem_vm_close, }; +static const char *etnaviv_gem_obj_caching_info(u32 flags) +{ + switch (flags & ETNA_BO_CACHE_MASK) { + case ETNA_BO_CACHED: + return "cached"; + case ETNA_BO_UNCACHED: + return "uncached"; + case ETNA_BO_WC: + return "write-combine"; + default: + break; + } + + return "unknown"; +} + +static void etnaviv_gem_object_info(struct drm_printer *p, + unsigned int indent, + const struct drm_gem_object *obj) +{ + const struct etnaviv_gem_object *etnaviv_obj; + + etnaviv_obj = container_of(obj, struct etnaviv_gem_object, base); + + drm_printf_indent(p, indent, "caching mode=%s\n", + etnaviv_gem_obj_caching_info(etnaviv_obj->flags)); + drm_printf_indent(p, indent, "active=%s\n", + str_yes_no(is_active(etnaviv_obj))); + drm_printf_indent(p, indent, "vaddr=%p\n", etnaviv_obj->vaddr); +} + static const struct drm_gem_object_funcs etnaviv_gem_object_funcs = { .free = etnaviv_gem_free_object, + .print_info = etnaviv_gem_object_info, .pin = etnaviv_gem_prime_pin, .unpin = etnaviv_gem_prime_unpin, .get_sg_table = etnaviv_gem_prime_get_sg_table, diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h b/drivers/gpu/drm/etnaviv/etnaviv_gem.h index a42d260cac2c..3f8fe19a77cc 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h @@ -68,7 +68,7 @@ struct etnaviv_gem_ops { int (*mmap)(struct etnaviv_gem_object *, struct vm_area_struct *); }; -static inline bool is_active(struct etnaviv_gem_object *etnaviv_obj) +static inline bool is_active(const struct etnaviv_gem_object *etnaviv_obj) { return atomic_read(&etnaviv_obj->gpu_active) != 0; } From patchwork Sun Aug 25 21:19:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13776934 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DD6EDC5472D for ; Sun, 25 Aug 2024 21:19:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4F3CF10E074; Sun, 25 Aug 2024 21:19:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="QblI4TTf"; dkim-atps=neutral Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) by gabe.freedesktop.org (Postfix) with ESMTPS id 38F2610E074 for ; Sun, 25 Aug 2024 21:19:51 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724620789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ogar9z4VeZmACj/ASu3ikNYNZmFcsKAcCHFxO52WAEo=; b=QblI4TTfO9QDkkfg3tFSzDVrK/uv7gykV4VlKBCsVNodKnz8AuZD8cLpksKzDw3TSgTgNB QfqgQAtPRiJqMZnBfGvG1MYpytnnPFAo/ZlowVm3EZRHxumMPT6WiwjhecMaUIMSj7PDLt mOJV7tuYAhmXED/PxM023ElOCTgJmBo= From: Sui Jingfeng To: Maxime Ripard , Thomas Zimmermann , Maarten Lankhorst , Lucas Stach , Russell King , Christian Gmeiner Cc: David Airlie , Daniel Vetter , etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH 2/2] drm/etnaviv: Export drm_gem_print_info() and use it Date: Mon, 26 Aug 2024 05:19:29 +0800 Message-Id: <20240825211929.614631-3-sui.jingfeng@linux.dev> In-Reply-To: <20240825211929.614631-1-sui.jingfeng@linux.dev> References: <20240825211929.614631-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This will make the newly implemented etnaviv_gem_object_funcs::print_info get in use, which improves code sharing and simplifies debugfs. Achieve better humen readability for debug log. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/drm_gem.c | 1 + drivers/gpu/drm/etnaviv/etnaviv_gem.c | 11 ++++------- include/drm/drm_gem.h | 2 ++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index d4bbc5d109c8..9c5c971c1b23 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1160,6 +1160,7 @@ void drm_gem_print_info(struct drm_printer *p, unsigned int indent, if (obj->funcs->print_info) obj->funcs->print_info(p, indent, obj); } +EXPORT_SYMBOL(drm_gem_print_info); int drm_gem_pin_locked(struct drm_gem_object *obj) { diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index 9a688c95f34d..f2f446d46921 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -3,6 +3,7 @@ * Copyright (C) 2015-2018 Etnaviv Project */ +#include #include #include #include @@ -432,15 +433,11 @@ int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, #ifdef CONFIG_DEBUG_FS static void etnaviv_gem_describe(struct drm_gem_object *obj, struct seq_file *m) { - struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); + struct drm_printer p = drm_seq_file_printer(m); struct dma_resv *robj = obj->resv; - unsigned long off = drm_vma_node_start(&obj->vma_node); int r; - seq_printf(m, "%08x: %c %2d (%2d) %08lx %p %zd\n", - etnaviv_obj->flags, is_active(etnaviv_obj) ? 'A' : 'I', - obj->name, kref_read(&obj->refcount), - off, etnaviv_obj->vaddr, obj->size); + drm_gem_print_info(&p, 1, obj); r = dma_resv_lock(robj, NULL); if (r) @@ -461,7 +458,7 @@ void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv, list_for_each_entry(etnaviv_obj, &priv->gem_list, gem_node) { struct drm_gem_object *obj = &etnaviv_obj->base; - seq_puts(m, " "); + seq_printf(m, "obj[%d]:\n", count); etnaviv_gem_describe(obj, m); count++; size += obj->size; diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index bae4865b2101..0791566fab53 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -480,6 +480,8 @@ void drm_gem_vm_close(struct vm_area_struct *vma); int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, struct vm_area_struct *vma); int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); +void drm_gem_print_info(struct drm_printer *p, unsigned int indent, + const struct drm_gem_object *obj); /** * drm_gem_object_get - acquire a GEM buffer object reference