From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C95F3933F6 for ; Wed, 14 Jan 2026 16:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768406831; cv=none; b=UgTM6a8irQaRC6BDrUDgxjheagqXH7lDanFiMOEkhtGqeFr7CvcpJsaYOrEYtBzmluhnPwIfPvKenuXb3mB3hdYr4GsLFS6l5a+GHlNfGRha8a1n6f6Npu3iVNsXWwzorcA2jlMjX9d9qXlZHlr337+CG7/mNdoSWzRILchqSp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768406831; c=relaxed/simple; bh=8RTTUBRBokwU+QkoYkTOJZlEDSo/ZfUOaPa3OQ8PWOM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PQM/oBxipz4uy21poummfnyE0gWghB5mbLuBm8NvRiuwoFb+ZW9VJ+G8IUeh2kzc7mQ6EidhnfU/hQ1+orZdt61mtfuuQLvrOJJXycPXfr5TlYSVi891IfxICU1IiFbAbPk+n3xWA5vS0K4fFEiwl+d9DHx9kW51ZO6IiZv/g/k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 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 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 DEEE11515; Wed, 14 Jan 2026 08:07:00 -0800 (PST) Received: from [10.57.10.71] (unknown [10.57.10.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0DDC3F632; Wed, 14 Jan 2026 08:07:02 -0800 (PST) Message-ID: <09151ff9-ff2a-4d3d-9ee1-b6f30b729fe6@arm.com> Date: Wed, 14 Jan 2026 16:07:00 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 1/4] drm/panthor: Rework panthor_irq::suspended into panthor_irq::state To: Nicolas Frattaroli , Boris Brezillon , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chia-I Wu , Karunika Choo Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20260112-panthor-tracepoints-v8-0-63efcb421d22@collabora.com> <20260112-panthor-tracepoints-v8-1-63efcb421d22@collabora.com> From: Steven Price Content-Language: en-GB In-Reply-To: <20260112-panthor-tracepoints-v8-1-63efcb421d22@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/01/2026 14:37, Nicolas Frattaroli wrote: > To deal with the threaded interrupt handler and a suspend action > overlapping, the boolean panthor_irq::suspended is not sufficient. > > Rework it into taking several different values depending on the current > state, and check it and set it within the IRQ helper functions. > > Signed-off-by: Nicolas Frattaroli There are some unwanted changes in this patch. We want to keep it simple so it does exactly what the changelog says. See below. > --- > drivers/gpu/drm/panthor/panthor_device.h | 40 +++++++++++++++++++++++++------- > 1 file changed, 31 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h > index f35e52b9546a..424f6cd1a814 100644 > --- a/drivers/gpu/drm/panthor/panthor_device.h > +++ b/drivers/gpu/drm/panthor/panthor_device.h > @@ -61,6 +61,17 @@ enum panthor_device_pm_state { > PANTHOR_DEVICE_PM_STATE_SUSPENDING, > }; > > +enum panthor_irq_state { > + /** @PANTHOR_IRQ_STATE_ACTIVE: IRQ is active and ready to process events. */ > + PANTHOR_IRQ_STATE_ACTIVE = 0, > + /** @PANTHOR_IRQ_STATE_PROCESSING: IRQ is currently processing events. */ > + PANTHOR_IRQ_STATE_PROCESSING, > + /** @PANTHOR_IRQ_STATE_SUSPENDED: IRQ is suspended. */ > + PANTHOR_IRQ_STATE_SUSPENDED, > + /** @PANTHOR_IRQ_STATE_SUSPENDING: IRQ is being suspended. */ > + PANTHOR_IRQ_STATE_SUSPENDING, > +}; > + > /** > * struct panthor_irq - IRQ data > * > @@ -76,8 +87,8 @@ struct panthor_irq { > /** @mask: Current mask being applied to xxx_INT_MASK. */ > u32 mask; > > - /** @suspended: Set to true when the IRQ is suspended. */ > - atomic_t suspended; > + /** @state: one of &enum panthor_irq_state reflecting the current state. */ > + atomic_t state; > }; > > /** > @@ -409,8 +420,10 @@ static irqreturn_t panthor_ ## __name ## _irq_raw_handler(int irq, void *data) > { \ > struct panthor_irq *pirq = data; \ > struct panthor_device *ptdev = pirq->ptdev; \ > + enum panthor_irq_state state; \ > \ > - if (atomic_read(&pirq->suspended)) \ > + state = atomic_read(&pirq->state); \ > + if (state == PANTHOR_IRQ_STATE_SUSPENDED || state == PANTHOR_IRQ_STATE_SUSPENDING) \ > return IRQ_NONE; \ > if (!gpu_read(ptdev, __reg_prefix ## _INT_STAT)) \ > return IRQ_NONE; \ > @@ -423,8 +436,11 @@ static irqreturn_t panthor_ ## __name ## _irq_threaded_handler(int irq, void *da > { \ > struct panthor_irq *pirq = data; \ > struct panthor_device *ptdev = pirq->ptdev; \ > + enum panthor_irq_state state; \ > irqreturn_t ret = IRQ_NONE; \ > \ > + atomic_cmpxchg(&pirq->state, PANTHOR_IRQ_STATE_ACTIVE, PANTHOR_IRQ_STATE_PROCESSING); \ > + \ > while (true) { \ > u32 status = gpu_read(ptdev, __reg_prefix ## _INT_RAWSTAT) & pirq->mask; \ > \ > @@ -435,8 +451,13 @@ static irqreturn_t panthor_ ## __name ## _irq_threaded_handler(int irq, void *da > ret = IRQ_HANDLED; \ > } \ > \ > - if (!atomic_read(&pirq->suspended)) \ > - gpu_write(ptdev, __reg_prefix ## _INT_MASK, pirq->mask); \ > + state = atomic_read(&pirq->state); \ > + if (state != PANTHOR_IRQ_STATE_SUSPENDED && state != PANTHOR_IRQ_STATE_SUSPENDING) { \ > + /* Only restore the bits that were used and are still enabled */ \ > + gpu_write(ptdev, __reg_prefix ## _INT_MASK, \ > + gpu_read(ptdev, __reg_prefix ## _INT_MASK) | (mask & pirq->mask)); \ This change to read the _INT_MASK and mask pirq->mask with 'mask' shouldn't be part of this patch. > + atomic_set(&pirq->state, PANTHOR_IRQ_STATE_ACTIVE); \ > + } \ > \ > return ret; \ > } \ > @@ -445,16 +466,17 @@ static inline void panthor_ ## __name ## _irq_suspend(struct panthor_irq *pirq) > { \ > pirq->mask = 0; \ > gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, 0); \ > + atomic_set(&pirq->state, PANTHOR_IRQ_STATE_SUSPENDING); \ > synchronize_irq(pirq->irq); \ > - atomic_set(&pirq->suspended, true); \ > + atomic_set(&pirq->state, PANTHOR_IRQ_STATE_SUSPENDED); \ > } \ > \ > static inline void panthor_ ## __name ## _irq_resume(struct panthor_irq *pirq, u32 mask) \ > { \ > - atomic_set(&pirq->suspended, false); \ > pirq->mask = mask; \ > - gpu_write(pirq->ptdev, __reg_prefix ## _INT_CLEAR, mask); \ > - gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, mask); \ > + atomic_set(&pirq->state, PANTHOR_IRQ_STATE_ACTIVE); \ > + gpu_write(pirq->ptdev, __reg_prefix ## _INT_CLEAR, pirq->mask); \ > + gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, pirq->mask); \ Here the change from using the local 'mask' to 'pirq->mask' is unrelated. It belongs in the next patch where 'mask' is being removed. But otherwise this looks good to me. Thanks, Steve > } \ > \ > static int panthor_request_ ## __name ## _irq(struct panthor_device *ptdev, \ >