Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796311634; b=tKgaUr+Dw7gD/L1/k/MbLhCA3tte4hx4o8CkXucT3B1cAer3I4W2UFakNXJrBXLm2JnV pyKCPA0HAUosDNoPTHu/Lfgp+SUErbevlXo/1annoiYvv/I8FQF0bKhrxUvjpsOhHh9Ro xR1TQ27J39XuTK32bSP1QUXsGMX4y8jGp/l7GYSEsKbMzUkMF8FOC5co0OX4EVTSPmfpY D+DWakT4x1pBm4mIBjlelAb+4VYaV+zddfI9FYtcXUiccxh4kL8Mw7YICPlkWMsw2yWme q/BpD/OmNI0MpTJ0nIPJ9mqwg4NGIPEq7/V//DVJ56HypxFmeQFq3ighVeQVYmHti2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796311634; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=OEdwTUZ8xj/WNlP0/E4coEssuliZxALGAvzbH5Yxw2Y=; b=q/7TBgmyZzpZAeU5PB0h/jiHkel2W9v3FLGA5Ir47rzr2JNZAbCKAURWbhgn2DaACSn9 tED9sg28zKlbxFLDmMvP2r8MB4GIC01GTH45yM5HGuO4TDAZhB+eZTr9ara5xaVOS+Lwl Mu+Dac5Q1cRtzW2ww4ghUbw5nmxSJ4LSjtUqhwWgpek4/PrldVR7X/nqEo57bzpWRYrCE yvc9Hw3yE9EdqAAFx8Km2ueuDbACzm7JYMt9obtF2j1Xvd3QXbhjRVy8S1y0SFAALISPu xbX+/32+KTw5fRLU28y6pLVoyvfnrCvZrdxsoX43qGx6LGsmHjQPb0Bcdx+aObxX2Ow== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=PPO7Tr4X; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC32E606A32C for ; Thu, 3 Dec 2026 15:27:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EC32E606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=PPO7Tr4X Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 85F0D497; Thu, 3 Dec 2026 07:27:10 -0800 (PST) Received: from [10.0.128.193] (e122027.cambridge.arm.com [10.0.128.193]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 215A93F7D8; Thu, 3 Dec 2026 07:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796311633; bh=tz+U6w7CZZawSiCxLMJsTLFEN+gxBGOn26yN8YlF/Ak=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PPO7Tr4X+CLECJ73GrCyLZ/A83OzO33SlRiGPXrtkC0Xxwo7Lm/wwHFZDD3g9TrYL roUtGpxme39igwWwUCYeFEwBfELWeC2oHoM2ms3CHetWikbHufAI2iFRZ6S0BWXWGe cBm03uVO/Y/j9rSWKczG6y4jPi3SStDwjkM8gx6M= Message-ID: Date: Thu, 3 Dec 2026 15:27:07 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/9] drm/panthor: Move register access helpers out of panthor_device.h To: Karunika Choo , dri-devel@lists.freedesktop.org Cc: nd@arm.com, Boris Brezillon , Liviu Dudau , linux-kernel@vger.kernel.org, Akash Goel , Lukas Zapolskas , Chris Diamand , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter References: <20261124161952.1053586-1-karunika.choo@arm.com> <20261124161952.1053586-4-karunika.choo@arm.com> From: Steven Price Content-Language: en-GB In-Reply-To: <20261124161952.1053586-4-karunika.choo@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 24/11/2026 16:19, Karunika Choo wrote: > Move register access helpers out of panthor_device.h to allow reuse by > other panthor drivers that will be added to enable v15 support. > > Reviewed-by: Boris Brezillon > Reviewed-by: Liviu Dudau > Signed-off-by: Karunika Choo Reviewed-by: Steven Price > --- > v4: > - Picked up R-b from Boris > v2: > - Picked up R-b from Liviu > - Fix includes raised by sashiko > - Link: https://lore.kernel.org/all/20260922205441.263661F000FF@smtp.kernel.org/ > v1: > - Includes "panthor_device_io.h" directly in "panthor_device.h" instead > of peppering multiple files with the header. > > drivers/gpu/drm/panthor/panthor_device.h | 73 +----------------- > drivers/gpu/drm/panthor/panthor_device_io.h | 84 +++++++++++++++++++++ > 2 files changed, 86 insertions(+), 71 deletions(-) > create mode 100644 drivers/gpu/drm/panthor/panthor_device_io.h > > diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h > index b55a3f9edd414..4add31b12cfd7 100644 > --- a/drivers/gpu/drm/panthor/panthor_device.h > +++ b/drivers/gpu/drm/panthor/panthor_device.h > @@ -19,6 +19,8 @@ > #include > #include > > +#include "panthor_device_io.h" > + > struct panthor_csf; > struct panthor_csf_ctx; > struct panthor_device; > @@ -495,77 +497,6 @@ panthor_exception_is_fault(u32 exception_code) > const char *panthor_exception_name(struct panthor_device *ptdev, > u32 exception_code); > > -static inline void gpu_write(void __iomem *iomem, u32 reg, u32 data) > -{ > - writel(data, iomem + reg); > -} > - > -static inline u32 gpu_read(void __iomem *iomem, u32 reg) > -{ > - return readl(iomem + reg); > -} > - > -static inline u32 gpu_read_relaxed(void __iomem *iomem, u32 reg) > -{ > - return readl_relaxed(iomem + reg); > -} > - > -static inline void gpu_write64(void __iomem *iomem, u32 reg, u64 data) > -{ > - gpu_write(iomem, reg, lower_32_bits(data)); > - gpu_write(iomem, reg + 4, upper_32_bits(data)); > -} > - > -static inline u64 gpu_read64(void __iomem *iomem, u32 reg) > -{ > - return (gpu_read(iomem, reg) | ((u64)gpu_read(iomem, reg + 4) << 32)); > -} > - > -static inline u64 gpu_read64_relaxed(void __iomem *iomem, u32 reg) > -{ > - return (gpu_read_relaxed(iomem, reg) | > - ((u64)gpu_read_relaxed(iomem, reg + 4) << 32)); > -} > - > -static inline u64 gpu_read64_counter(void __iomem *iomem, u32 reg) > -{ > - u32 lo, hi1, hi2; > - do { > - hi1 = gpu_read(iomem, reg + 4); > - lo = gpu_read(iomem, reg); > - hi2 = gpu_read(iomem, reg + 4); > - } while (hi1 != hi2); > - return lo | ((u64)hi2 << 32); > -} > - > -#define gpu_read_poll_timeout(iomem, reg, val, cond, delay_us, timeout_us) \ > - read_poll_timeout(gpu_read, val, cond, delay_us, timeout_us, false, \ > - iomem, reg) > - > -#define gpu_read_poll_timeout_atomic(iomem, reg, val, cond, delay_us, \ > - timeout_us) \ > - read_poll_timeout_atomic(gpu_read, val, cond, delay_us, timeout_us, \ > - false, iomem, reg) > - > -#define gpu_read64_poll_timeout(iomem, reg, val, cond, delay_us, timeout_us) \ > - read_poll_timeout(gpu_read64, val, cond, delay_us, timeout_us, false, \ > - iomem, reg) > - > -#define gpu_read64_poll_timeout_atomic(iomem, reg, val, cond, delay_us, \ > - timeout_us) \ > - read_poll_timeout_atomic(gpu_read64, val, cond, delay_us, timeout_us, \ > - false, iomem, reg) > - > -#define gpu_read_relaxed_poll_timeout_atomic(iomem, reg, val, cond, delay_us, \ > - timeout_us) \ > - read_poll_timeout_atomic(gpu_read_relaxed, val, cond, delay_us, \ > - timeout_us, false, iomem, reg) > - > -#define gpu_read64_relaxed_poll_timeout(iomem, reg, val, cond, delay_us, \ > - timeout_us) \ > - read_poll_timeout(gpu_read64_relaxed, val, cond, delay_us, timeout_us, \ > - false, iomem, reg) > - > #define INT_RAWSTAT 0x0 > #define INT_CLEAR 0x4 > #define INT_MASK 0x8 > diff --git a/drivers/gpu/drm/panthor/panthor_device_io.h b/drivers/gpu/drm/panthor/panthor_device_io.h > new file mode 100644 > index 0000000000000..ce417c64abb44 > --- /dev/null > +++ b/drivers/gpu/drm/panthor/panthor_device_io.h > @@ -0,0 +1,84 @@ > +/* SPDX-License-Identifier: GPL-2.0 or MIT */ > +/* Copyright 2026 ARM Limited. All rights reserved. */ > + > +#ifndef __PANTHOR_DEVICE_IO_H__ > +#define __PANTHOR_DEVICE_IO_H__ > + > +#include > +#include > +#include > + > +static inline void gpu_write(void __iomem *iomem, u32 reg, u32 data) > +{ > + writel(data, iomem + reg); > +} > + > +static inline u32 gpu_read(void __iomem *iomem, u32 reg) > +{ > + return readl(iomem + reg); > +} > + > +static inline u32 gpu_read_relaxed(void __iomem *iomem, u32 reg) > +{ > + return readl_relaxed(iomem + reg); > +} > + > +static inline void gpu_write64(void __iomem *iomem, u32 reg, u64 data) > +{ > + gpu_write(iomem, reg, lower_32_bits(data)); > + gpu_write(iomem, reg + 4, upper_32_bits(data)); > +} > + > +static inline u64 gpu_read64(void __iomem *iomem, u32 reg) > +{ > + return (gpu_read(iomem, reg) | ((u64)gpu_read(iomem, reg + 4) << 32)); > +} > + > +static inline u64 gpu_read64_relaxed(void __iomem *iomem, u32 reg) > +{ > + return (gpu_read_relaxed(iomem, reg) | > + ((u64)gpu_read_relaxed(iomem, reg + 4) << 32)); > +} > + > +static inline u64 gpu_read64_counter(void __iomem *iomem, u32 reg) > +{ > + u32 lo, hi1, hi2; > + > + do { > + hi1 = gpu_read(iomem, reg + 4); > + lo = gpu_read(iomem, reg); > + hi2 = gpu_read(iomem, reg + 4); > + } while (hi1 != hi2); > + return lo | ((u64)hi2 << 32); > +} > + > +#define gpu_read_poll_timeout(iomem, reg, val, cond, delay_us, timeout_us) \ > + read_poll_timeout(gpu_read, val, cond, delay_us, timeout_us, false, \ > + iomem, reg) > + > +#define gpu_read_poll_timeout_atomic(iomem, reg, val, cond, delay_us, \ > + timeout_us) \ > + read_poll_timeout_atomic(gpu_read, val, cond, delay_us, timeout_us, \ > + false, iomem, reg) > + > +#define gpu_read64_poll_timeout(iomem, reg, val, cond, delay_us, timeout_us) \ > + read_poll_timeout(gpu_read64, val, cond, delay_us, timeout_us, false, \ > + iomem, reg) > + > +#define gpu_read64_poll_timeout_atomic(iomem, reg, val, cond, delay_us, \ > + timeout_us) \ > + read_poll_timeout_atomic(gpu_read64, val, cond, delay_us, timeout_us, \ > + false, iomem, reg) > + > +#define gpu_read_relaxed_poll_timeout_atomic(iomem, reg, val, cond, delay_us, \ > + timeout_us) \ > + read_poll_timeout_atomic(gpu_read_relaxed, val, cond, delay_us, \ > + timeout_us, false, iomem, reg) > + > +#define gpu_read64_relaxed_poll_timeout(iomem, reg, val, cond, delay_us, \ > + timeout_us) \ > + read_poll_timeout(gpu_read64_relaxed, val, cond, delay_us, timeout_us, \ > + false, iomem, reg) > + > + > +#endif /* __PANTHOR_DEVICE_IO_H__ */