From patchwork Sun May 12 15:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13662764 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 9B4FEC25B77 for ; Sun, 12 May 2024 15:36:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A78A10E29C; Sun, 12 May 2024 15:36:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="hRA50z/Z"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7465310E265; Sun, 12 May 2024 15:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715528189; x=1747064189; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m7b0H2nPMXlW9qzhs8xhiDDvV+7cSUjEnIZn7N+Tdcw=; b=hRA50z/ZSfuqMGAOLiJ9I+F0AxS/2vqclEv2V3cXh/jQ1BfoSMD0gbtI PS19UNX2xMIFCmQPjG+ezxtQOnH0yjAMuVTUNtl8wTPvdtRmT3+BrWrna UVFaqXR/k+jmhro0/l1IvUiTyQyC3dyOei9fN439Ry5vFRhmL6iyjPH4S LU6JS+QBivW+eTgP58ZgyjLpFcRP3GkGX9SsWkX8s/hQxYAqmCEHFeNKP OiV9LnkjvAD5AzPLAP7rWTtzLjB1WvKq82MpzNc/xqDMX+Uotfw0dBNSc jferHLLTtCRAD2PfiVa7yZOjHUAhF0Se5jotJOUeSwXsc6f0Gi92dT2th w==; X-CSE-ConnectionGUID: WJqFFQflT3aXfdWqqjNhcA== X-CSE-MsgGUID: zqg8LBMnTf61d2vvOaCtng== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11403303" X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="11403303" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2024 08:36:29 -0700 X-CSE-ConnectionGUID: nHVtF9cFQjKA8GWpnQJQgg== X-CSE-MsgGUID: HAVA9ftCSMCmQGlQ+KLyxg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="34976565" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.246.25.139]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2024 08:36:27 -0700 From: Michal Wajdeczko To: intel-xe@lists.freedesktop.org Cc: Michal Wajdeczko , linux-fsdevel@vger.kernel.org, dri-devel@lists.freedesktop.org, Lucas De Marchi Subject: [PATCH 1/4] libfs: add simple_read_from_iomem() Date: Sun, 12 May 2024 17:36:03 +0200 Message-Id: <20240512153606.1996-2-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240512153606.1996-1-michal.wajdeczko@intel.com> References: <20240512153606.1996-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 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's similar to simple_read_from_buffer() but instead allows to copy data from the I/O memory in PAGE_SIZE chunks. Signed-off-by: Michal Wajdeczko --- Cc: linux-fsdevel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: Lucas De Marchi --- fs/libfs.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 3 +++ 2 files changed, 53 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 3a6f2cb364f8..be8aa42a2f11 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include /* sync_mapping_buffers */ @@ -1040,6 +1041,55 @@ void simple_release_fs(struct vfsmount **mount, int *count) } EXPORT_SYMBOL(simple_release_fs); +/** + * simple_read_from_iomem - copy data from the I/O memory to user space + * @to: the user space buffer to read to + * @count: the maximum number of bytes to read + * @ppos: the current position in the buffer + * @from: the I/O memory to read from + * @available: the size of the iomem memory + * + * The simple_read_from_iomem() function reads up to @count bytes (but no + * more than %PAGE_SIZE bytes) from the I/O memory @from at offset @ppos + * into the user space address starting at @to. + * + * Return: On success, the number of bytes read is returned and the offset + * @ppos is advanced by this number, or negative value is returned on error. + */ +ssize_t simple_read_from_iomem(void __user *to, size_t count, loff_t *ppos, + const volatile void __iomem *from, size_t available) +{ + loff_t pos = *ppos; + size_t ret; + void *buf; + + if (pos < 0) + return -EINVAL; + if (pos >= available || !count) + return 0; + if (count > available - pos) + count = available - pos; + if (count > PAGE_SIZE) + count = PAGE_SIZE; + + buf = kmalloc(count, GFP_NOWAIT | __GFP_NOWARN); + if (!buf) + return -ENOMEM; + + memcpy_fromio(buf, from + pos, count); + ret = copy_to_user(to, buf, count); + + kfree(buf); + + if (ret == count) + return -EFAULT; + + count -= ret; + *ppos = pos + count; + return count; +} +EXPORT_SYMBOL(simple_read_from_iomem); + /** * simple_read_from_buffer - copy data from the buffer to user space * @to: the user space buffer to read to diff --git a/include/linux/fs.h b/include/linux/fs.h index 8dfd53b52744..eb4a7b10a1a0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3331,6 +3331,9 @@ extern ssize_t simple_read_from_buffer(void __user *to, size_t count, extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, const void __user *from, size_t count); +ssize_t simple_read_from_iomem(void __user *to, size_t count, loff_t *ppos, + const volatile void __iomem *from, size_t available); + struct offset_ctx { struct maple_tree mt; unsigned long next_offset; From patchwork Sun May 12 15:36:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13662765 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 B519EC25B4F for ; Sun, 12 May 2024 15:36:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 15CF810E2B4; Sun, 12 May 2024 15:36:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="J/w4m01x"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by gabe.freedesktop.org (Postfix) with ESMTPS id E6E9010E29F; Sun, 12 May 2024 15:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715528193; x=1747064193; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UpBLsNtwkuXGVcD/TaGHbR2icCa517yQEVl4pgTWrf8=; b=J/w4m01x4FVA+MhFym54jYC3/gZATPi/ti33afaaVNguy2wFJ4Cgp60b 4v/2Qbn/rYdPIWsTSJI7sHZWN9IHr6qSia1R7FMYHFG/Av3RIEBkF9J5u lnmK5ZaNuaoxlD5sj8r9RhDxgpP6LGielCMexCyLQrPkgPZgzU0nm+P5E ycELFFZ1vDbcTdn44J0E/d8H1XEhj3GzHtN6njw6Qb7ce4CvKYXTBn5yu HkSPWCVyJzTV7y8OFeSZvStAArTpqGGJg+RNw3p1vOekr4roKHu7PIu3L zjaVMCsJrDOG2u0jcu0VuIt2pnSdXCa7ZjnitEXKr3O5nL4X2AVthYYZz g==; X-CSE-ConnectionGUID: rtewN1tGTq+wUDH3KLvUVg== X-CSE-MsgGUID: AJ7Af+wwR4yZFDekfqKElA== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11403306" X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="11403306" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2024 08:36:33 -0700 X-CSE-ConnectionGUID: xRUy/3fVTKG3IzZ9/ieCOg== X-CSE-MsgGUID: Xe/sFGcnRIubxVaa9acUJQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="34976572" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.246.25.139]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2024 08:36:29 -0700 From: Michal Wajdeczko To: intel-xe@lists.freedesktop.org Cc: Michal Wajdeczko , linux-fsdevel@vger.kernel.org, dri-devel@lists.freedesktop.org, Lucas De Marchi Subject: [PATCH 2/4] iosys-map: add iosys_map_read_from() helper Date: Sun, 12 May 2024 17:36:04 +0200 Message-Id: <20240512153606.1996-3-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240512153606.1996-1-michal.wajdeczko@intel.com> References: <20240512153606.1996-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 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 allows to copy data from iosys_map into the user memory, regardless whether iosys_map points to memory or I/O memory. Signed-off-by: Michal Wajdeczko --- Cc: linux-fsdevel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: Lucas De Marchi --- include/linux/iosys-map.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h index 4696abfd311c..eb79da976211 100644 --- a/include/linux/iosys-map.h +++ b/include/linux/iosys-map.h @@ -7,6 +7,7 @@ #define __IOSYS_MAP_H__ #include +#include #include #include @@ -312,6 +313,29 @@ static inline void iosys_map_memcpy_from(void *dst, const struct iosys_map *src, memcpy(dst, src->vaddr + src_offset, len); } +/** + * iosys_map_read_from - Copy data from iosys_map into user memory + * @to: the user space buffer to read to + * @count: the maximum number of bytes to read + * @ppos: the current position in the buffer + * @map: the iosys_map structure to read from + * @available: the size of the data in iosys_map + * + * Copies up to @count bytes from a iosys_map @map at offset @ppos into the user + * space address starting at @to. + * + * Return: On success, the number of bytes read is returned and the offset + * @ppos is advanced by this number, or negative value is returned on error. + */ +static inline ssize_t iosys_map_read_from(void __user *to, size_t count, loff_t *ppos, + const struct iosys_map *map, size_t available) +{ + if (map->is_iomem) + return simple_read_from_iomem(to, count, ppos, map->vaddr_iomem, available); + else + return simple_read_from_buffer(to, count, ppos, map->vaddr, available); +} + /** * iosys_map_incr - Increments the address stored in a iosys mapping * @map: The iosys_map structure From patchwork Sun May 12 15:36:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13662766 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 C9EAFC25B77 for ; Sun, 12 May 2024 15:36:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8853D10E2BB; Sun, 12 May 2024 15:36:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="DRQ+NXX/"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE6B110E2B4; Sun, 12 May 2024 15:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715528195; x=1747064195; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Zv3dENl+B07Af4W2wswlYvH7KrFD7s2CNxHPDgLv2v4=; b=DRQ+NXX/Y+HERE2kXCtfoIhZ7t5GihEP1Xg9wjle5Zayg3+RcAKFUAgE Z8ECiAZF4i9mJV37UvCkmQZgZi14nbpXuA1KeTrDxiGUt3PvimMyvYcpp Yluz8wGncOFAY3B7Lzl+diKHVbltJv0Vup69ti5vo9aIocTQiLCWfUBbn p4LUiYGNwWpCZzU5zX6KnTQhIGdHavZDquZo4fi/LCDFXAqeZOrGkQqrD 0HxbZABwY+4bA6TqBPmqyk7mL9kEtqziYNTbepuyxJmk5qPiEsBIGl6Ph Ha95+QVLhGh34444XWkQLiU0gcBI68iBAVEWDjUm4nrkCGpMuq22IgyQr w==; X-CSE-ConnectionGUID: LEVHqAWQRfWaJTgZveZHNw== X-CSE-MsgGUID: Ztsq0CQWRLSFoTvGPJ41UQ== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11403311" X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="11403311" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2024 08:36:35 -0700 X-CSE-ConnectionGUID: +MHMnX9jRyuzFWgXe65Z6w== X-CSE-MsgGUID: wC86a7wLSWqmGz0G1nk7Jg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="34976581" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.246.25.139]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2024 08:36:32 -0700 From: Michal Wajdeczko To: intel-xe@lists.freedesktop.org Cc: Michal Wajdeczko , Lucas De Marchi , linux-fsdevel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/xe: Add wrapper for iosys_map_read_from Date: Sun, 12 May 2024 17:36:05 +0200 Message-Id: <20240512153606.1996-4-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240512153606.1996-1-michal.wajdeczko@intel.com> References: <20240512153606.1996-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 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 is preferable to use the xe_map layer instead of directly accessing iosys_map, so add a wrapper for the recently added iosys_map_read_from() function. Signed-off-by: Michal Wajdeczko Cc: Lucas De Marchi --- Cc: linux-fsdevel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/xe/xe_map.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_map.h b/drivers/gpu/drm/xe/xe_map.h index f62e0c8b67ab..1db1d23c4f69 100644 --- a/drivers/gpu/drm/xe/xe_map.h +++ b/drivers/gpu/drm/xe/xe_map.h @@ -44,6 +44,15 @@ static inline void xe_map_memset(struct xe_device *xe, iosys_map_memset(dst, offset, value, len); } +static inline ssize_t xe_map_read_from(struct xe_device *xe, void __user *to, + size_t count, loff_t *ppos, + const struct iosys_map *map, + size_t available) +{ + xe_device_assert_mem_access(xe); + return iosys_map_read_from(to, count, ppos, map, available); +} + /* FIXME: We likely should kill these two functions sooner or later */ static inline u32 xe_map_read32(struct xe_device *xe, struct iosys_map *map) { From patchwork Sun May 12 15:36:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13662767 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 7530DC25B78 for ; Sun, 12 May 2024 15:36:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E61310E2F1; Sun, 12 May 2024 15:36:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="WOq9uKUy"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by gabe.freedesktop.org (Postfix) with ESMTPS id EAB0A10E2CF; Sun, 12 May 2024 15:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715528197; x=1747064197; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bgkLgGVBN1X+G4AcO3iprTd4Lp+rZcXDf1rU9vl2ShI=; b=WOq9uKUyZXvtjWT64wdjR40QgtLyvoRTyKH9b9FxJd4I/PHBNVtYHpkH skePHVCmcpB5v/1XZPwcYTl953F3UyHABpcuFY8OIHA+jnAfHG5/g8JK2 CTIjUypTwK4kWz7SoBSPdItmgvWESyl9TtS3mfDpl7/2uINqDifESJA3B BXEo2eemDv+AVKDYgjtDud5aoVv91Imaqq0pkAeagShiyBSlofMm/aJ3B aBCruVHDPI5e7AXqwBsZwQlLjuPYhXHQQAGMCU7KGNMuhkplVfL3cuJ4i PIAa3o+9zTUlU9TSWakN9SRTrpzBR2R3ZPXfPbFnPgh8wuoIO9miub5Ld g==; X-CSE-ConnectionGUID: 17lLujIeQPmXFY7Oyl3mqw== X-CSE-MsgGUID: OZSm+fk0SliXb5uOxeKMpQ== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11403316" X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="11403316" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2024 08:36:37 -0700 X-CSE-ConnectionGUID: m3n46GydTXuj/s+gNmxweg== X-CSE-MsgGUID: /j/BC61GQnKijWeCcPqVRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="34976587" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.246.25.139]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2024 08:36:34 -0700 From: Michal Wajdeczko To: intel-xe@lists.freedesktop.org Cc: Michal Wajdeczko , Lucas De Marchi , John Harrison , linux-fsdevel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/xe/guc: Expose raw access to GuC log over debugfs Date: Sun, 12 May 2024 17:36:06 +0200 Message-Id: <20240512153606.1996-5-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240512153606.1996-1-michal.wajdeczko@intel.com> References: <20240512153606.1996-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 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" We already provide the content of the GuC log in debugsfs, but it is in a text format where each log dword is printed as hexadecimal number, which does not scale well with large GuC log buffers. To allow more efficient access to the GuC log, which could benefit our CI systems, expose raw binary log data. In addition to less overhead in preparing text based GuC log file, the new GuC log file in binary format is also almost 3x smaller. Any existing script that expects the GuC log buffer in text format can use command like below to convert from new binary format: hexdump -e '4/4 "0x%08x " "\n"' but this shouldn't be the case as most decoders expect GuC log data in binary format. Signed-off-by: Michal Wajdeczko Cc: Lucas De Marchi Cc: John Harrison --- Cc: linux-fsdevel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/xe/xe_guc_debugfs.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_guc_debugfs.c b/drivers/gpu/drm/xe/xe_guc_debugfs.c index d3822cbea273..53fea952344d 100644 --- a/drivers/gpu/drm/xe/xe_guc_debugfs.c +++ b/drivers/gpu/drm/xe/xe_guc_debugfs.c @@ -8,6 +8,7 @@ #include #include +#include "xe_bo.h" #include "xe_device.h" #include "xe_gt.h" #include "xe_guc.h" @@ -52,6 +53,29 @@ static const struct drm_info_list debugfs_list[] = { {"guc_log", guc_log, 0}, }; +static ssize_t guc_log_read(struct file *file, char __user *buf, size_t count, loff_t *pos) +{ + struct dentry *dent = file_dentry(file); + struct dentry *uc_dent = dent->d_parent; + struct dentry *gt_dent = uc_dent->d_parent; + struct xe_gt *gt = gt_dent->d_inode->i_private; + struct xe_guc_log *log = >->uc.guc.log; + struct xe_device *xe = gt_to_xe(gt); + ssize_t ret; + + xe_pm_runtime_get(xe); + ret = xe_map_read_from(xe, buf, count, pos, &log->bo->vmap, log->bo->size); + xe_pm_runtime_put(xe); + + return ret; +} + +static const struct file_operations guc_log_ops = { + .owner = THIS_MODULE, + .read = guc_log_read, + .llseek = default_llseek, +}; + void xe_guc_debugfs_register(struct xe_guc *guc, struct dentry *parent) { struct drm_minor *minor = guc_to_xe(guc)->drm.primary; @@ -72,4 +96,6 @@ void xe_guc_debugfs_register(struct xe_guc *guc, struct dentry *parent) drm_debugfs_create_files(local, ARRAY_SIZE(debugfs_list), parent, minor); + + debugfs_create_file("guc_log_raw", 0600, parent, NULL, &guc_log_ops); }