From: Karunika Choo <karunika.choo@arm.com>
To: dri-devel@lists.freedesktop.org
Cc: nd@arm.com, Boris Brezillon <boris.brezillon@collabora.com>,
Steven Price <steven.price@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
linux-kernel@vger.kernel.org,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Subject: [PATCH v1 15/27] drm/panthor: Add AM_RESOURCE_GROUP support
Date: Tue, 22 Sep 2026 21:45:09 +0100 [thread overview]
Message-ID: <20260922204535.2850094-16-karunika.choo@arm.com> (raw)
In-Reply-To: <20260922204535.2850094-1-karunika.choo@arm.com>
Add resource-group probing for the arbitration device, including MMIO
resources, IRQ handling, per-AW AM message helpers, handshake
negotiation, and retry work for deferred outgoing messages.
Hook resource groups into arbitration init, teardown, and runtime PM.
Signed-off-by: Karunika Choo <karunika.choo@arm.com>
---
v1:
- Updated DT structure and accompanying parsing to handle child nodes
instead of named platform resources.
- Hold runtime PM reference during message retries.
- Fix suspend resume ordering.
drivers/gpu/drm/panthor/arbitration/Makefile | 3 +-
.../panthor/arbitration/panthor_arbitration.h | 5 +
.../arbitration/panthor_arbitration_drv.c | 19 +-
.../arbitration/panthor_resource_group.c | 323 ++++++++++++++++++
.../arbitration/panthor_resource_group.h | 22 ++
5 files changed, 370 insertions(+), 2 deletions(-)
create mode 100644 drivers/gpu/drm/panthor/arbitration/panthor_resource_group.c
create mode 100644 drivers/gpu/drm/panthor/arbitration/panthor_resource_group.h
diff --git a/drivers/gpu/drm/panthor/arbitration/Makefile b/drivers/gpu/drm/panthor/arbitration/Makefile
index b0b6b2e3edf8d..2d2684321d978 100644
--- a/drivers/gpu/drm/panthor/arbitration/Makefile
+++ b/drivers/gpu/drm/panthor/arbitration/Makefile
@@ -4,7 +4,8 @@
obj-$(CONFIG_DRM_PANTHOR_ARBITRATION) += panthor_arbitration.o
panthor_arbitration-y := \
panthor_arbitration_drv.o \
- panthor_partition_control.o
+ panthor_partition_control.o \
+ panthor_resource_group.o
INCLUDES = \
-I$(src)/..
diff --git a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration.h b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration.h
index 26950e47852dd..dfeab1b078d06 100644
--- a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration.h
+++ b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration.h
@@ -9,8 +9,10 @@
struct device;
struct panthor_partition_control;
+struct panthor_resource_group;
#define AM_ARB_MAX_PC_COUNT 1
+#define AM_ARB_MAX_RG_COUNT 1
#define AM_ARB_MAX_AW_COUNT 16
/** struct panthor_arbitration_resource - Arbitration resource */
@@ -31,6 +33,9 @@ struct panthor_arbitration {
/** @pc: Pointer array to partition control data */
struct panthor_partition_control *pc[AM_ARB_MAX_PC_COUNT];
+
+ /** @rg: Pointer array to resource group data */
+ struct panthor_resource_group *rg[AM_ARB_MAX_RG_COUNT];
};
int panthor_arbitration_parse_resource(struct device *dev,
diff --git a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_drv.c b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_drv.c
index 09342245a47d1..a1068a2c78f1a 100644
--- a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_drv.c
+++ b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_drv.c
@@ -12,6 +12,7 @@
#include "panthor_arbitration.h"
#include "panthor_partition_control.h"
+#include "panthor_resource_group.h"
#define PANTHOR_PM_AUTOSUSPEND_DELAY_MS 100
@@ -55,6 +56,10 @@ static int panthor_arbitration_runtime_suspend(struct device *dev)
struct panthor_arbitration *adev = dev_get_drvdata(dev);
int ret = 0;
+ ret = panthor_resource_group_suspend(adev);
+ if (ret)
+ return ret;
+
ret = panthor_partition_control_suspend(adev);
if (ret)
return ret;
@@ -71,6 +76,10 @@ static int panthor_arbitration_runtime_resume(struct device *dev)
if (ret)
return ret;
+ ret = panthor_resource_group_resume(adev);
+ if (ret)
+ return ret;
+
return 0;
}
@@ -103,6 +112,10 @@ static int panthor_arbitration_probe(struct platform_device *pdev)
if (ret)
goto err_term_pc;
+ ret = panthor_resource_group_init(adev);
+ if (ret)
+ goto err_term_rg;
+
ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
if (ret)
goto err_depopulate;
@@ -116,7 +129,9 @@ static int panthor_arbitration_probe(struct platform_device *pdev)
err_depopulate:
of_platform_depopulate(dev);
-
+err_term_rg:
+ panthor_resource_group_cancel_work(adev);
+ panthor_resource_group_term(adev);
err_term_pc:
panthor_partition_control_term(adev);
pm_runtime_put_noidle(dev);
@@ -136,8 +151,10 @@ static void panthor_arbitration_remove(struct platform_device *pdev)
dev_warn(adev->dev, "failed to resume during remove: %d", ret);
of_platform_depopulate(adev->dev);
+ panthor_resource_group_cancel_work(adev);
if (ret >= 0) {
+ panthor_resource_group_term(adev);
panthor_partition_control_term(adev);
pm_runtime_put_noidle(adev->dev);
}
diff --git a/drivers/gpu/drm/panthor/arbitration/panthor_resource_group.c b/drivers/gpu/drm/panthor/arbitration/panthor_resource_group.c
new file mode 100644
index 0000000000000..9bdd0876dd457
--- /dev/null
+++ b/drivers/gpu/drm/panthor/arbitration/panthor_resource_group.c
@@ -0,0 +1,323 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+/* Copyright 2026 ARM Limited. All rights reserved. */
+
+#include <linux/interrupt.h>
+#include <linux/iopoll.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/property.h>
+#include <linux/workqueue.h>
+
+#include "panthor_am_msg.h"
+#include "panthor_arbitration.h"
+#include "panthor_device_io.h"
+#include "panthor_resource_group.h"
+
+#define AM_RG_IRQ_RAWSTAT 0x80
+#define AM_RG_IRQ_CLEAR 0x84
+#define AM_RG_IRQ_MASK 0x88
+#define AM_RG_IRQ_STATUS 0x8C
+#define AM_RG_MESSAGE_MASK GENMASK(15, 0)
+
+#define AM_RG_AW_MESSAGE(n) (0x100 + (n) * 0x20)
+
+struct rg_aw_data {
+ /** @msg: Messaging data */
+ struct panthor_am_msg msg;
+};
+
+struct panthor_resource_group {
+ /** @dev: Device pointer */
+ struct device *dev;
+
+ /** @name: Resource name */
+ char *name;
+
+ /** @iomem: CPU mapping of the partition control IOMEM region */
+ void __iomem *iomem;
+
+ /** @irq: IRQ number */
+ int irq;
+
+ /** @aw_data: Data for each access window */
+ struct rg_aw_data aw_data[AM_ARB_MAX_AW_COUNT];
+
+ /** @wq: Resource group workqueue */
+ struct workqueue_struct *wq;
+
+ /** @msg_retry_work: Work to retry sending pending messages */
+ struct work_struct msg_retry_work;
+};
+
+static void rg_retry_messages(struct work_struct *work)
+{
+ struct panthor_resource_group *rg = container_of(
+ work, struct panthor_resource_group, msg_retry_work);
+ bool retry = false;
+ int ret;
+
+ ret = pm_runtime_resume_and_get(rg->dev);
+ if (ret) {
+ dev_warn(rg->dev, "Failed to resume to retry messages");
+ return;
+ }
+
+ for (u8 aw_id = 0; aw_id < AM_ARB_MAX_AW_COUNT; aw_id++) {
+ struct panthor_am_msg *msg = &rg->aw_data[aw_id].msg;
+ int ret;
+
+ ret = panthor_am_msg_retry(msg);
+ if (ret == -EBUSY || ret == -EAGAIN)
+ retry = true;
+
+ if (ret == -EINVAL)
+ dev_warn(rg->dev, "AW%u send FIFO unexpectedly empty", aw_id);
+ }
+
+ if (retry)
+ queue_work(rg->wq, &rg->msg_retry_work);
+
+ pm_runtime_put_autosuspend(rg->dev);
+}
+
+static void rg_send_msg(struct panthor_resource_group *rg, u8 aw_id,
+ u64 message)
+{
+ int ret;
+
+ ret = panthor_am_msg_send(&rg->aw_data[aw_id].msg, message);
+ if (ret == -ENOSPC)
+ dev_err(rg->dev, "AW%u send FIFO is full", aw_id);
+
+ if (ret == -EBUSY) {
+ dev_dbg(rg->dev, "AW%u has pending messages, scheduling retry work", aw_id);
+ queue_work(rg->wq, &rg->msg_retry_work);
+ }
+}
+
+static void rg_send_init_msg(struct panthor_resource_group *rg, u8 aw_id,
+ u8 ack, u8 version)
+{
+ u64 message = ARB_VM_INIT_MAKE(ack, version);
+
+ rg_send_msg(rg, aw_id, message);
+}
+
+static void rg_respond_to_handshake(struct panthor_resource_group *rg,
+ u8 aw_id, u64 message)
+{
+ struct rg_aw_data *aw_data = &rg->aw_data[aw_id];
+ bool acked = AM_MSG_ACK_GET(message);
+ u8 version = AM_MSG_VERSION_GET(message);
+ int ret;
+
+ ret = panthor_am_msg_version_validate(&aw_data->msg, version);
+ if (ret == -EOPNOTSUPP)
+ dev_warn(rg->dev,
+ "AW%u protocol version less than minimum supported (%u < %u)",
+ aw_id, version, AM_MSG_MIN_SUPPORTED_VERSION);
+
+ /* AW initiated the handshake, reply with supported version */
+ if (!acked)
+ rg_send_init_msg(rg, aw_id, 1, aw_data->msg.version);
+}
+
+static void rg_handshake_init(struct panthor_resource_group *rg)
+{
+ for (u8 aw_id = 0; aw_id < AM_ARB_MAX_AW_COUNT; aw_id++)
+ rg_send_init_msg(rg, aw_id, 0, AM_MSG_CURRENT_VERSION);
+}
+
+static void rg_handle_message(struct panthor_resource_group *rg, u8 aw_id,
+ u64 message)
+{
+ u8 msg_id = AM_MSG_ID_GET(message);
+ if (!msg_id)
+ return;
+
+ switch (msg_id) {
+ case VM_ARB_INIT:
+ rg_respond_to_handshake(rg, aw_id, message);
+ break;
+ case VM_ARB_GPU_REQUEST:
+ /* TODO: on_request */
+ break;
+ case VM_ARB_GPU_STOPPED:
+ /* TODO: on_idle */
+ break;
+ default:
+ dev_warn(rg->dev, "Invalid message (0x%llx)", message);
+ break;
+ }
+}
+
+static irqreturn_t rg_irq_raw_handler(int irq, void *data)
+{
+ struct panthor_resource_group *rg = data;
+ unsigned long message_mask;
+ u32 status;
+ u8 aw_id;
+
+ status = gpu_read(rg->iomem, AM_RG_IRQ_STATUS);
+ if (!status)
+ return IRQ_NONE;
+
+ message_mask = status;
+ for_each_set_bit(aw_id, &message_mask, AM_ARB_MAX_AW_COUNT) {
+ u64 message = panthor_am_msg_read(&rg->aw_data[aw_id].msg);
+
+ rg_handle_message(rg, aw_id, message);
+ }
+
+ gpu_write(rg->iomem, AM_RG_IRQ_CLEAR, status);
+
+ return IRQ_HANDLED;
+}
+
+static void rg_irq_suspend(struct panthor_resource_group *rg)
+{
+ gpu_write(rg->iomem, AM_RG_IRQ_MASK, 0);
+}
+
+static void rg_irq_resume(struct panthor_resource_group *rg)
+{
+ gpu_write(rg->iomem, AM_RG_IRQ_MASK, AM_RG_MESSAGE_MASK);
+}
+
+int panthor_resource_group_suspend(struct panthor_arbitration *adev)
+{
+ for (int i = 0; i < AM_ARB_MAX_RG_COUNT; i++) {
+ struct panthor_resource_group *rg = adev->rg[i];
+
+ if (!rg)
+ continue;
+
+ rg_irq_suspend(rg);
+ }
+
+ return 0;
+}
+
+int panthor_resource_group_resume(struct panthor_arbitration *adev)
+{
+ for (int i = 0; i < AM_ARB_MAX_RG_COUNT; i++) {
+ struct panthor_resource_group *rg = adev->rg[i];
+
+ if (!rg)
+ continue;
+
+ rg_irq_resume(rg);
+ }
+
+ return 0;
+}
+
+void panthor_resource_group_cancel_work(struct panthor_arbitration *adev)
+{
+ for (int i = 0; i < AM_ARB_MAX_RG_COUNT; i++) {
+ struct panthor_resource_group *rg = adev->rg[i];
+
+ if (!rg)
+ continue;
+
+ disable_work_sync(&rg->msg_retry_work);
+ }
+}
+
+void panthor_resource_group_term(struct panthor_arbitration *adev)
+{
+ for (int i = 0; i < AM_ARB_MAX_RG_COUNT; i++) {
+ struct panthor_resource_group *rg = adev->rg[i];
+
+ if (!rg)
+ continue;
+
+ rg_irq_suspend(rg);
+ }
+}
+
+static int resource_group_init(struct panthor_arbitration *adev,
+ const struct fwnode_handle *child)
+{
+ struct panthor_arbitration_resource res;
+ struct panthor_resource_group *rg;
+ struct device *dev = adev->dev;
+ struct irq_data *irqdata;
+ void __iomem *iomem;
+ u32 irq_flags = 0;
+ char *name;
+ int irq;
+ int ret;
+
+ ret = panthor_arbitration_parse_resource(dev, child, &res);
+ if (ret)
+ return ret;
+
+ if (res.id >= AM_ARB_MAX_RG_COUNT)
+ return -ENODEV;
+
+ if (adev->rg[res.id])
+ return dev_warn_probe(dev, -ENODEV, "resource-group@%llx: id (%u) already present",
+ res.res.start, res.id);
+
+ rg = devm_kzalloc(dev, sizeof(*rg), GFP_KERNEL);
+ if (!rg)
+ return -ENOMEM;
+
+ name = devm_kasprintf(dev, GFP_KERNEL, "rg%d", res.id);
+
+ iomem = devm_ioremap_resource(dev, &res.res);
+ if (IS_ERR(iomem))
+ return dev_err_probe(dev, PTR_ERR(iomem), "%s: Failed to ioremap", name);
+
+ rg->name = name;
+ rg->dev = dev;
+ rg->iomem = iomem;
+
+ rg->wq = devm_alloc_ordered_workqueue(dev, "panthor-%s-wq", 0, name);
+ if (!rg->wq)
+ return -ENOMEM;
+
+ INIT_WORK(&rg->msg_retry_work, rg_retry_messages);
+
+ for (int i = 0; i < AM_ARB_MAX_AW_COUNT; i++)
+ panthor_am_msg_init(&rg->aw_data[i].msg,
+ rg->iomem + AM_RG_AW_MESSAGE(i));
+
+ irq = fwnode_irq_get(child, 0);
+ if (irq < 0)
+ return dev_err_probe(dev, irq, "%s: Failed to get IRQ", name);
+
+ irqdata = irq_get_irq_data(irq);
+ if (irqdata)
+ irq_flags = irqd_get_trigger_type(irqdata);
+
+ ret = devm_request_irq(
+ dev, irq, rg_irq_raw_handler, irq_flags | IRQF_SHARED,
+ devm_kasprintf(dev, GFP_KERNEL, "panthor-%s-irq", name), rg);
+ if (ret)
+ return ret;
+
+ adev->rg[res.id] = rg;
+
+ rg_irq_resume(rg);
+
+ rg_handshake_init(rg);
+
+ return 0;
+}
+
+int panthor_resource_group_init(struct panthor_arbitration *adev)
+{
+ device_for_each_named_child_node_scoped(adev->dev, child, "resource-group") {
+ int ret = resource_group_init(adev, child);
+
+ if (ret == -ENODEV)
+ continue;
+
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
diff --git a/drivers/gpu/drm/panthor/arbitration/panthor_resource_group.h b/drivers/gpu/drm/panthor/arbitration/panthor_resource_group.h
new file mode 100644
index 0000000000000..ad85cd171c4a3
--- /dev/null
+++ b/drivers/gpu/drm/panthor/arbitration/panthor_resource_group.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 or MIT */
+/* Copyright 2026 ARM Limited. All rights reserved. */
+
+#ifndef __PANTHOR_RESOURCE_GROUP_H__
+#define __PANTHOR_RESOURCE_GROUP_H__
+
+#include <linux/types.h>
+
+struct device;
+struct panthor_arbitration;
+
+int panthor_resource_group_init(struct panthor_arbitration *adev);
+
+void panthor_resource_group_term(struct panthor_arbitration *adev);
+
+int panthor_resource_group_suspend(struct panthor_arbitration *adev);
+
+int panthor_resource_group_resume(struct panthor_arbitration *adev);
+
+void panthor_resource_group_cancel_work(struct panthor_arbitration *adev);
+
+#endif
--
2.43.0
next prev parent reply other threads:[~2026-09-22 20:47 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 20:44 [PATCH v1 00/27] drm/panthor: Add Mali v15 virtualization support Karunika Choo
2026-09-22 20:44 ` [PATCH v1 01/27] drm/panthor: Ignore -EOPNOTSUPP for shader-present nvmem lookup Karunika Choo
2026-10-28 15:51 ` Liviu Dudau
2026-09-22 20:44 ` [PATCH v1 02/27] drm/panthor: Move register access helpers out of panthor_device.h Karunika Choo
2026-10-28 15:52 ` Liviu Dudau
2026-09-22 20:44 ` [PATCH v1 03/27] drm/panthor: Parse and store GPU_ID fields Karunika Choo
2026-10-28 15:57 ` Liviu Dudau
2026-09-22 20:44 ` [PATCH v1 04/27] drm/panthor: Add 64-bit GPU_ID decoding for v15 GPUs Karunika Choo
2026-09-22 23:23 ` Deborah Brouwer
2026-10-28 15:58 ` Liviu Dudau
2026-09-22 20:44 ` [PATCH v1 05/27] drm/panthor: Move register base offsets to the HW description Karunika Choo
2026-10-28 16:03 ` Liviu Dudau
2026-09-22 20:45 ` [PATCH v1 06/27] drm/panthor: Derive MMU AS register addresses from base and stride Karunika Choo
2026-10-28 16:06 ` Liviu Dudau
2026-09-22 20:45 ` [PATCH v1 07/27] dt-bindings: gpu: mali-valhall-csf: Add Mali Gen5 AM compatible Karunika Choo
2026-09-28 10:02 ` Krzysztof Kozlowski
2026-09-22 20:45 ` [PATCH v1 08/27] drm/panthor: Add Mali v15 hardware support Karunika Choo
2026-10-28 13:21 ` Liviu Dudau
2026-10-28 16:20 ` Liviu Dudau
2026-09-22 20:45 ` [PATCH v1 09/27] drm/panthor: Skip devfreq when no OPP table is present Karunika Choo
2026-10-28 16:26 ` Liviu Dudau
2026-09-22 20:45 ` [PATCH v1 10/27] dt-bindings: gpu: panthor: Document panthor-system bindings Karunika Choo
2026-09-28 10:05 ` Krzysztof Kozlowski
2026-09-22 20:45 ` [PATCH v1 11/27] drm/panthor: Add AM_SYSTEM platform driver Karunika Choo
2026-09-22 20:45 ` [PATCH v1 12/27] dt-bindings: gpu: panthor: Document panthor-arbitration bindings Karunika Choo
2026-09-28 10:06 ` Krzysztof Kozlowski
2026-09-22 20:45 ` [PATCH v1 13/27] drm/panthor: Add AM_PARTITION_CONTROL support Karunika Choo
2026-09-22 20:45 ` [PATCH v1 14/27] drm/panthor: Add AM message helpers Karunika Choo
2026-09-22 20:45 ` Karunika Choo [this message]
2026-09-22 20:45 ` [PATCH v1 16/27] drm/panthor: Add arbitration scheduler Karunika Choo
2026-09-22 20:45 ` [PATCH v1 17/27] drm/panthor: Route arbitration events Karunika Choo
2026-09-22 20:45 ` [PATCH v1 18/27] dt-bindings: gpu: panthor: Document AW assignment DT property Karunika Choo
2026-09-28 10:06 ` Krzysztof Kozlowski
2026-09-22 20:45 ` [PATCH v1 19/27] drm/panthor: Add AW assignment tracking Karunika Choo
2026-09-22 20:45 ` [PATCH v1 20/27] drm/panthor: Handle partition control INVALID_COMMAND interrupt Karunika Choo
2026-09-22 20:45 ` [PATCH v1 21/27] drm/panthor: Request AW to yield GPU access on idle Karunika Choo
2026-09-22 20:45 ` [PATCH v1 22/27] drm/panthor: Add access-window support Karunika Choo
2026-09-22 20:45 ` [PATCH v1 23/27] drm/panthor: Synchronize HW component PM transitions Karunika Choo
2026-09-22 20:45 ` [PATCH v1 24/27] drm/panthor: Route HW component PM through access windows Karunika Choo
2026-09-22 20:45 ` [PATCH v1 25/27] drm/panthor: Tolerate access-window loss during HW waits Karunika Choo
2026-09-22 20:45 ` [PATCH v1 26/27] drm/panthor: Prevent missed post-yield cleanup due to reset Karunika Choo
2026-09-22 20:45 ` [PATCH v1 27/27] drm/panthor: Release GPU access immediately for out-of-band grants Karunika Choo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922204535.2850094-16-karunika.choo@arm.com \
--to=karunika.choo@arm.com \
--cc=airlied@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nd@arm.com \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®