Commit 0810d5ad authored by Tomeu Vizoso's avatar Tomeu Vizoso Committed by Jeff Hugo
Browse files

accel/rocket: Add job submission IOCTL



Using the DRM GPU scheduler infrastructure, with a scheduler for each
core.

Userspace can decide for a series of tasks to be executed sequentially
in the same core, so SRAM locality can be taken advantage of.

The job submission code was initially based on Panfrost.

v2:
- Remove hardcoded number of cores
- Misc. style fixes (Jeffrey Hugo)
- Repack IOCTL struct (Jeffrey Hugo)

v3:
- Adapt to a split of the register block in the DT bindings (Nicolas
  Frattaroli)
- Make use of GPL-2.0-only for the copyright notice (Jeff Hugo)
- Use drm_* logging functions (Thomas Zimmermann)
- Rename reg i/o macros (Thomas Zimmermann)
- Add padding to ioctls and check for zero (Jeff Hugo)
- Improve error handling (Nicolas Frattaroli)

v6:
- Use mutexes guard (Markus Elfring)
- Use u64_to_user_ptr (Jeff Hugo)
- Drop rocket_fence (Rob Herring)

v7:
- Assign its own IOMMU domain to each client, for isolation (Daniel
  Stone and Robin Murphy)

v8:
- Use reset lines to reset the cores (Robin Murphy)
- Use the macros to compute the values for the bitfields (Robin Murphy)
- More descriptive name for the IRQ (Robin Murphy)
- Simplify job interrupt handing (Robin Murphy)
- Correctly acquire a reference to the IOMMU (Robin Murphy)
- Specify the size of the embedded structs in the IOCTLs for future
  extensibility (Rob Herring)
- Expose only 32 bits for the address of the regcmd BO (Robin Murphy)

Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Reviewed-by: default avatarJeff Hugo <jeff.hugo@oss.qualcomm.com>
Signed-off-by: default avatarTomeu Vizoso <tomeu@tomeuvizoso.net>
Signed-off-by: default avatarJeff Hugo <jeff.hugo@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250721-6-10-rocket-v9-4-77ebd484941e@tomeuvizoso.net
parent 658ebeac
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6,4 +6,5 @@ rocket-y := \
	rocket_core.o \
	rocket_device.o \
	rocket_drv.o \
	rocket_gem.o
	rocket_gem.o \
	rocket_job.o
+10 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <linux/reset.h>

#include "rocket_core.h"
#include "rocket_job.h"

int rocket_core_init(struct rocket_core *core)
{
@@ -57,6 +58,10 @@ int rocket_core_init(struct rocket_core *core)

	core->iommu_group = iommu_group_get(dev);

	err = rocket_job_init(core);
	if (err)
		return err;

	pm_runtime_use_autosuspend(dev);

	/*
@@ -70,6 +75,10 @@ int rocket_core_init(struct rocket_core *core)
	pm_runtime_enable(dev);

	err = pm_runtime_get_sync(dev);
	if (err) {
		rocket_job_fini(core);
		return err;
	}

	version = rocket_pc_readl(core, VERSION);
	version += rocket_pc_readl(core, VERSION_NUM) & 0xffff;
@@ -88,6 +97,7 @@ void rocket_core_fini(struct rocket_core *core)
	pm_runtime_disable(core->dev);
	iommu_group_put(core->iommu_group);
	core->iommu_group = NULL;
	rocket_job_fini(core);
}

void rocket_core_reset(struct rocket_core *core)
+15 −0
Original line number Diff line number Diff line
@@ -40,6 +40,21 @@ struct rocket_core {
	struct reset_control_bulk_data resets[2];

	struct iommu_group *iommu_group;

	struct mutex job_lock;
	struct rocket_job *in_flight_job;

	spinlock_t fence_lock;

	struct {
		struct workqueue_struct *wq;
		struct work_struct work;
		atomic_t pending;
	} reset;

	struct drm_gpu_scheduler sched;
	u64 fence_context;
	u64 emit_seqno;
};

int rocket_core_init(struct rocket_core *core);
+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@ struct rocket_device *rocket_device_init(struct platform_device *pdev,
	if (err)
		return ERR_PTR(err);

	err = devm_mutex_init(dev, &rdev->sched_lock);
	if (err)
		return ERR_PTR(-ENOMEM);

	err = drm_dev_register(ddev, 0);
	if (err)
		return ERR_PTR(err);
+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
struct rocket_device {
	struct drm_device ddev;

	struct mutex sched_lock;

	struct rocket_core *cores;
	unsigned int num_cores;
};
Loading