From patchwork Thu Apr 17 14:49:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 14055715 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 04F65C369C9 for ; Thu, 17 Apr 2025 14:49:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 52B2B10EB35; Thu, 17 Apr 2025 14:49:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="p0lDC4Zv"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F45910EB34 for ; Thu, 17 Apr 2025 14:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1744901350; bh=BDAQg8KrxI89aDARPl6MuUm4d50VDQaYxKVXiIMA1eg=; h=From:To:Cc:Subject:Date:From; b=p0lDC4ZvYNVBuU9zfTt/+fQCr+7ueJTSIAB0o/dC3dUsmvqJIybPn5x76a6z1zRIR A81OXMgCFW18cUsILScs/3ahdEepkzDzU0A49p7a4x9G1ekHAFjadSGFpfGNnAP+/8 LOC+opHCm55aGHEx2xKZp7/mGN/to6snmlrHihXlyjHTcuMiJqxzI3nYGp5VRd67da EUAOqFf/VGZEZ7S+Hmt0WDuM7sPFj6YP2hciwxphwQkSKn5DshRI0fOaTRsVfjx4kX 0EJghQFNhQI5bX87Pbe4IBAu36qfrx+3dSPgZWP3ZVhIx89tIzDvVty8CawRMyNMun ZoOCO1ugFZDjg== Received: from localhost.localdomain (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id BAA0B17E00F0; Thu, 17 Apr 2025 16:49:09 +0200 (CEST) From: Boris Brezillon To: Boris Brezillon , Steven Price , Liviu Dudau , =?utf-8?q?Adri=C3=A1n_Larumbe?= Cc: dri-devel@lists.freedesktop.org, kernel@collabora.com Subject: [PATCH v2 0/2] drm/panthor: Fix panthor+FEX-Emu Date: Thu, 17 Apr 2025 16:49:05 +0200 Message-ID: <20250417144907.3679831-1-boris.brezillon@collabora.com> X-Mailer: git-send-email 2.49.0 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" Hello, This is an attempt a couple bugs exposed by FEX-Emu. The first one is pretty trivial and should be uncontroversial, since it's just a missing padding field in one of our uAPI structs. We are getting away with it on arm32 because of the alignment rules provided by the Arm ABI, but x86 has relaxed constraints for u64 fields, and this bug is definitely hit when running a 32-bit x86 mesa binary under FEX Emu. The second fix is addressing a problem we have because FEX-Emu is an aarch64 process executing 32-bit x86 code, meaning the check we do on the is-32bit-task check we do to figure out the MMIO offset seen by the user won't work. In order to fix that, we add an ioctl to let the user explicitly set this offset. The offset can only be set early on, if no MMIO range has been mapped before. With those, and the mesa MR at [1], I managed to run a 32-bit x86 glmark2 through FEX without using the host mesa (if we were to use the thunked mesa lib, both the kernel and mesa would use MMIO_OFFSET_64BIT, and the problem doesn't exist anymore). Regards, Boris Changes in v2: - Simplify the logic in patch2 to have a lockless solution that's still safe for what we need [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34573 Boris Brezillon (2): drm/panthor: Add missing explicit padding in drm_panthor_gpu_info drm/panthor: Fix the user MMIO offset logic for emulators drivers/gpu/drm/panthor/panthor_device.h | 18 ++++++++ drivers/gpu/drm/panthor/panthor_drv.c | 56 +++++++++++++++++------- include/uapi/drm/panthor_drm.h | 41 +++++++++++++++++ 3 files changed, 99 insertions(+), 16 deletions(-)