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: 13662759 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACD3440BE3 for ; Sun, 12 May 2024 15:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715528191; cv=none; b=ZL2h16LAPG2rahu/aQ2Epyf3bYR1eAWTno2kDZkDf0NPhbtAP8MCoYTVTcsBbk4DI2WAv5/hQijoDQwt050MIBTfwQFxSWnDCgdvTvDigxzh60hqBIyOz7Gpq1ZZi+ivcwNre1AbfETPNyd/t3SBESrTQGQSaFVFB8Z8JVVA8TA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715528191; c=relaxed/simple; bh=m7b0H2nPMXlW9qzhs8xhiDDvV+7cSUjEnIZn7N+Tdcw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HC7N5oHtNKcREnD7R7D3iePOQ0fPBqNptzIxehcETU+VECWHNmS/7FMpa1vW4LfRqBWlxN5BCelGyJ2degGaVJlTbzNmuu6/qaZywcToc/5rBM2oZL9R9Q2kKOYtHm3srhTM2gBv1ztshSa7g6RxrCBdU/r33lK96Xef+Dl7+sw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jEISbIdG; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jEISbIdG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715528190; x=1747064190; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m7b0H2nPMXlW9qzhs8xhiDDvV+7cSUjEnIZn7N+Tdcw=; b=jEISbIdGRdVJRRrQwbotD5EgI84JmwBjCe6ZiAYJXcAFnDjjQZjO4Uhx 7LvlOyQZUMNWCxxyF1Aq+AbYPHnrlATuYmlefuzXqS5qPrpWEEUXZjg3y E6lVcuTBWVG+R8+oWlnGw9iIZoVtOkNxIQwVYKUeVlRdGZboGXrZaw1SZ KlNpyRPliZTLKE75DcvHetSVgdZIPbt+x48OvUjk2QzaMEaFE3nkNR86x tduaSXYbOeUmOlOgT0lttSj66T6cPCYziphgnGcqiPqDMEVJhtZk/Fp96 /iwAnDHt8gWIyHmQ6VfCmtv+Kw8mZQKTBHl4xOzqMJgmWj7K4KcHYtgNe w==; X-CSE-ConnectionGUID: QkpWNX7ZRaC/L34WdaqIVQ== X-CSE-MsgGUID: 2/5mT4b1RnmetTIL+sryWA== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11403302" X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="11403302" 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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13662760 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5940340BE3 for ; Sun, 12 May 2024 15:36:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715528195; cv=none; b=P3Um50Fj/cXAw4OAHop6UiTyRK0/kUvrRB3GL4pPi3cwE0q7j2wO7wWxp0hRqZP6GwrSWEts+XV6Tb716RKXZk3xgaQwwcqGH/cqAsxLbLncbLN/9TWhU7SJK/08IEcafZr6or7XNMVYMLI+x6egZemQMvroHac7vgmN1W1lAss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715528195; c=relaxed/simple; bh=UpBLsNtwkuXGVcD/TaGHbR2icCa517yQEVl4pgTWrf8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uqAE2m8aoU8WBv70ORnf5kxQdz+46+0kxX7q1KRmJEElkjyba+HyarRrjPcB08FGTWj4x8Qzo+t3lQtkN0oHOnFAO4je9MFEw4Q2sXT3sz8Z4qBveh98+3tU6qBBs5Gb/poppP7TWxqTKqgWi8I/6QBXauaZCtmwAcPTF3Cg8vY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=J/w4m01x; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="J/w4m01x" 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: LObg3j9IQJGUPgBi9NMt2Q== X-CSE-MsgGUID: PRV86HxSTTqfg56+lyBUuA== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11403305" X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="11403305" 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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13662761 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BAC73FB8B for ; Sun, 12 May 2024 15:36:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715528196; cv=none; b=lJEXNgvZVe1d6WCgTyZ00Y/mHkbobzGGQ+SILgkidI/xWesD/Be+KnL/6fV74IEyc3LqbArr1cmLjVDR9uE45LzH2yP55ARhUVv1I+aGY50UBbtoVXuFlmc4n5KKHhJ2etwXmYPNDZrjx4pOp2/lVMLP7+0Qma3q5Vea5S/xReA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715528196; c=relaxed/simple; bh=Zv3dENl+B07Af4W2wswlYvH7KrFD7s2CNxHPDgLv2v4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fUNQjkFN0WA4fW6NUYe0DHVrewGqDGssBoyDv+sXlSqllbEWVkcB+M4wNluA58mEGvcST8PubDRF94a1XyzDYc/JiKAHgnlIuqS2x4cXq60YncoF+59l7UYKoxXhvDyb6st7DNyWgCALGiHNobL0C2u5wBKRClqd8ZfxTUjFSmY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DRQ+NXX/; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DRQ+NXX/" 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: hmXstghGTl+4NXA2WObvXQ== X-CSE-MsgGUID: 5hm8LUfCQxm/AmMfQ357RQ== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11403310" X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="11403310" 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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13662762 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDD2446441 for ; Sun, 12 May 2024 15:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715528198; cv=none; b=QiHElglZNDma5gkHyTA9HRZ5tVP3i7XeVBlm67zjw+AJVV2ptHAedDMS9hRXZqnW3VKr1PxWvQ/1Z/8hfPVjiFMN9ToTzXLVpQ0BaY9BqEIpx4VbcxLvV/a3fvnkXK4ZyKwvw+1TaIcFtZnFn6xrhRwXEOIpzsFQaFHUito43cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715528198; c=relaxed/simple; bh=bgkLgGVBN1X+G4AcO3iprTd4Lp+rZcXDf1rU9vl2ShI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MwFB/NDqAeOCQbIKP8p89Cef37MktK6dJEK2jxaMPj+Jw6xs9pRBmM0swralJ9w7aYXhjJkzU67WmVioxBW+ejca862taKnmZowiLpzek3kJ0eBYkWU546h3BrfoGJ1Tur6Lam9xreqrC/LLV3VrsbsYP0ebYWls1JNjWc89GCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WOq9uKUy; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WOq9uKUy" 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: OH6WmiOZTimKewpuagYDvw== X-CSE-MsgGUID: ZUV3op1kTfuf5c7HeM/4/A== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11403315" X-IronPort-AV: E=Sophos;i="6.08,156,1712646000"; d="scan'208";a="11403315" 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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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); }