drivers/gpu/drm/panthor/panthor_hw.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panthor/panthor_hw.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panthor/panthor_hw.c
Extension
.c
Size
8528 bytes
Lines
319
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct device_driver *drv;
	int ret;

	drv = driver_find("panthor", &platform_bus_type);
	if (!drv)
		return -ENODEV;

	ret = driver_for_each_device(drv, NULL, (void *)true,
				     panthor_hw_set_power_tracing);

	return ret;
}

void panthor_hw_power_status_unregister(void)
{
	struct device_driver *drv;
	int ret;

	drv = driver_find("panthor", &platform_bus_type);
	if (!drv)
		return;

	ret = driver_for_each_device(drv, NULL, NULL, panthor_hw_set_power_tracing);

	/*
	 * Ideally, it'd be possible to ask driver_for_each_device to hand us
	 * another "start" to keep going after the failing device, but it
	 * doesn't do that. Minor inconvenience in what is probably a bad day
	 * on the computer already though.
	 */
	if (ret)
		pr_warn("Couldn't mask power IRQ for at least one device: %pe\n",
			ERR_PTR(ret));
}

static char *get_gpu_model_name(struct panthor_device *ptdev)
{
	const u32 gpu_id = ptdev->gpu_info.gpu_id;
	const u32 product_id = GPU_PROD_ID_MAKE(GPU_ARCH_MAJOR(gpu_id),
						GPU_PROD_MAJOR(gpu_id));
	const bool ray_intersection = !!(ptdev->gpu_info.gpu_features &
					 GPU_FEATURES_RAY_INTERSECTION);
	const u8 shader_core_count = hweight64(ptdev->gpu_info.shader_present);

	switch (product_id) {
	case GPU_PROD_ID_MAKE(10, 2):
		return "Mali-G710";
	case GPU_PROD_ID_MAKE(10, 3):
		return "Mali-G510";
	case GPU_PROD_ID_MAKE(10, 4):
		return "Mali-G310";
	case GPU_PROD_ID_MAKE(10, 7):
		return "Mali-G610";
	case GPU_PROD_ID_MAKE(11, 2):
		if (shader_core_count > 10 && ray_intersection)
			return "Mali-G715-Immortalis";
		else if (shader_core_count >= 7)
			return "Mali-G715";

		fallthrough;
	case GPU_PROD_ID_MAKE(11, 3):
		return "Mali-G615";
	case GPU_PROD_ID_MAKE(12, 0):
		if (shader_core_count >= 10 && ray_intersection)
			return "Mali-G720-Immortalis";
		else if (shader_core_count >= 6)
			return "Mali-G720";

		fallthrough;
	case GPU_PROD_ID_MAKE(12, 1):
		return "Mali-G620";
	case GPU_PROD_ID_MAKE(13, 0):
		if (shader_core_count >= 10 && ray_intersection)
			return "Mali-G925-Immortalis";
		else if (shader_core_count >= 6)
			return "Mali-G725";

		fallthrough;
	case GPU_PROD_ID_MAKE(13, 1):
		return "Mali-G625";
	case GPU_PROD_ID_MAKE(14, 0):
		return "Mali-G1-Ultra";
	case GPU_PROD_ID_MAKE(14, 1):
		return "Mali-G1-Premium";
	case GPU_PROD_ID_MAKE(14, 3):
		return "Mali-G1-Pro";
	}

	return "(Unknown Mali GPU)";
}

Annotation

Implementation Notes