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 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 DD3A6F531DB for ; Mon, 13 Apr 2026 22:06:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 840F510E109; Mon, 13 Apr 2026 22:06:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Q/gNjJVP"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 433EB10E109 for ; Mon, 13 Apr 2026 22:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1776117966; x=1807653966; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=sQ+Aawpr+w4sbuSwP2m0BN7lWMhzTK+sSZZKNYcnDRk=; b=Q/gNjJVPpl1DHv8mvBBGnAbtRe94q2kZI2XZPUSeWs3AiSMJT7ZUTOJy NGr1v0Pt4cLsdXmjwLPBBR5uWYfAWZRNigOej5AJWx0d+rxtRAUb3DJiH XTzIShrQgYsXp683dJgGHa3uk5u/gAlrQPPiuOMBFRwK9AEruQmLk8H10 jBRB1gB9h2AsO+gzNnMtDSLvHi0V1b1ykV+ralX+Fq+tVX8MLbG4yoMHr CLqGKLAbQxQnMXnDGejzDLkVCnBOEvap277txaUFTx+77Y+3D6QRtHML/ VvZ/otUxCqFrXyBlGylEnvPeZ5CxjPTWVI8KHousWUUBtjfmIh4Grz58e A==; X-CSE-ConnectionGUID: MIDWbVFEQquCLWlyUzI8rA== X-CSE-MsgGUID: PudaAhuiRqiQ03Yd6rdDeQ== X-IronPort-AV: E=McAfee;i="6800,10657,11758"; a="76095770" X-IronPort-AV: E=Sophos;i="6.23,178,1770624000"; d="scan'208";a="76095770" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2026 15:06:06 -0700 X-CSE-ConnectionGUID: EmsaFWvjScSDlex69tk/Jg== X-CSE-MsgGUID: bHB8tfTMTnqbzRuUL0NmJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,178,1770624000"; d="scan'208";a="227231876" Received: from unknown (HELO adixit-MOBL3.intel.com) ([10.241.243.133]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2026 15:06:06 -0700 Date: Mon, 13 Apr 2026 15:06:05 -0700 Message-ID: <875x5u8qia.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Umesh Nerlige Ramappa Cc: Subject: Re: [PATCH 1/3] drm/xe/oa: Use xe_map layer In-Reply-To: References: <20260409231754.528518-1-ashutosh.dixit@intel.com> <20260409231754.528518-2-ashutosh.dixit@intel.com> <877bqe8gow.wl-ashutosh.dixit@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Mon, 13 Apr 2026 11:05:09 -0700, Umesh Nerlige Ramappa wrote: > > On Fri, Apr 10, 2026 at 05:49:03PM -0700, Dixit, Ashutosh wrote: > > On Thu, 09 Apr 2026 16:17:52 -0700, Ashutosh Dixit wrote: > >> > > > > Hi Umesh, > > > >> +/* Because there is no iosys_map_copy_to_user() or copy_to_user_from_iomem() */ > >> +static int xe_oa_copy_to_user(struct xe_oa_stream *stream, void __user *dst, u32 head, u32 len) > >> +{ > >> + u32 __user *dptr = dst; > >> + > >> + xe_gt_assert(stream->gt, len % 4 == 0); > >> + > >> + for (int i = 0; i < len / 4; i++) { > >> + struct iosys_map *map = &stream->oa_buffer.bo->vmap; > >> + u32 val = xe_map_rd(stream->oa->xe, map, head, u32); > >> + int ret = put_user(val, dptr++); > >> + > >> + if (ret) > >> + return ret; > >> + head += 4; > >> + } > >> + > >> + return 0; > >> +} > > > > Unfortunately, with this copy_to_user() implementation we are seeing buffer > > overflow, implying there is significant performance impact, even when OA > > buffer is in system memory: > > > > Starting subtest: non-zero-reason > > Starting dynamic subtest: oag-0 > > (xe_oa:6798) CRITICAL: Test assertion failure function test_non_zero_reason, file ../tests/intel/xe_oa.c:2693: > > (xe_oa:6798) CRITICAL: Failed assertion: !(oa_status & DRM_XE_OASTATUS_BUFFER_OVERFLOW) > > > > That is, we are unable to read data at the rate at which HW is writing > > data, causing buffer overrun. > > > > Therefore in v3 I have basically reverted to the copy_to_user() > > implementation of v1, except that I have taken the copy_to_user() out of > > xe_oa.c and moved it to xe_map.h, to make that implementation "official" > > (and OA code to strictly use the xe_map layer). This seems to be the best > > approach to me, it avoids unnecessary copies and works correctly on all of > > our systems of interest. > > > > Also, the previous code, without this patch, is of course doing this exact > > same thing, except that the use of the xe_map layer make these assumptions > > explicit. > > > > If you still don't think we should be doing this, I can try to get a second > > opinion about this patch. Thanks. > > Yes, please include someone who can give us an Ack or some inputs on this > approach because we are hitting some issues. I have asked. What I posted in v3 is my preferred option since it avoids the extra copy. But if that doesn't go through, the function below has the extra copy, but seems to have the same performace as v3, so that is also an option: static int xe_oa_copy_to_user(struct xe_oa_stream *stream, void __user *dst, u32 head, u32 len) { struct iosys_map *map = &stream->oa_buffer.bo->vmap; u8 buf[1024]; // Allocate as part of stream xe_map_memcpy_from(xe, buf, map, head, len); return copy_to_user(dst, buf, len); } So I am planning to try this next, if v3 doesn't go through. Thanks.