Commit b0b6739c authored by Dave Airlie's avatar Dave Airlie
Browse files

Merge tag 'drm-etnaviv-next-2024-03-07' of https://git.pengutronix.de/git/lst/linux into drm-next



- various code cleanups
- enhancements for NPU and MRT support

Signed-off-by: default avatarDave Airlie <airlied@redhat.com>

From: Lucas Stach <l.stach@pengutronix.de>
Link: https://patchwork.freedesktop.org/patch/msgid/72a783cd98d60f6ebb43b90a6b453eea87224409.camel@pengutronix.de
parents 5794d2f7 b735ee17
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ static const struct {
	ST(0x1480, 8),
	ST(0x1500, 8),
	ST(0x1520, 8),
	ST(0x1540, 8),
	ST(0x1608, 1),
	ST(0x1610, 1),
	ST(0x1658, 1),
+61 −32
Original line number Diff line number Diff line
@@ -29,6 +29,17 @@
 * DRM operations:
 */

static struct device_node *etnaviv_of_first_available_node(void)
{
	struct device_node *np;

	for_each_compatible_node(np, NULL, "vivante,gc") {
		if (of_device_is_available(np))
			return np;
	}

	return NULL;
}

static void load_gpu(struct drm_device *dev)
{
@@ -494,7 +505,7 @@ static const struct drm_driver etnaviv_drm_driver = {
	.desc               = "etnaviv DRM",
	.date               = "20151214",
	.major              = 1,
	.minor              = 3,
	.minor              = 4,
};

/*
@@ -597,9 +608,6 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
			if (!of_device_is_available(core_node))
				continue;

			if (!first_node)
				first_node = core_node;

			drm_of_component_match_add(&pdev->dev, &match,
						   component_compare_of, core_node);
		}
@@ -634,8 +642,11 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
	 * device as the GPU we found. This assumes that all Vivante
	 * GPUs in the system share the same DMA constraints.
	 */
	if (first_node)
	first_node = etnaviv_of_first_available_node();
	if (first_node) {
		of_dma_configure(&pdev->dev, first_node, true);
		of_node_put(first_node);
	}

	return component_master_add_with_match(dev, &etnaviv_master_ops, match);
}
@@ -653,11 +664,43 @@ static struct platform_driver etnaviv_platform_driver = {
	},
};

static int etnaviv_create_platform_device(const char *name,
					  struct platform_device **ppdev)
{
	struct platform_device *pdev;
	int ret;

	pdev = platform_device_alloc(name, PLATFORM_DEVID_NONE);
	if (!pdev)
		return -ENOMEM;

	ret = platform_device_add(pdev);
	if (ret) {
		platform_device_put(pdev);
		return ret;
	}

	*ppdev = pdev;

	return 0;
}

static void etnaviv_destroy_platform_device(struct platform_device **ppdev)
{
	struct platform_device *pdev = *ppdev;

	if (!pdev)
		return;

	platform_device_unregister(pdev);

	*ppdev = NULL;
}

static struct platform_device *etnaviv_drm;

static int __init etnaviv_init(void)
{
	struct platform_device *pdev;
	int ret;
	struct device_node *np;

@@ -675,29 +718,15 @@ static int __init etnaviv_init(void)
	 * If the DT contains at least one available GPU device, instantiate
	 * the DRM platform device.
	 */
	for_each_compatible_node(np, NULL, "vivante,gc") {
		if (!of_device_is_available(np))
			continue;

		pdev = platform_device_alloc("etnaviv", PLATFORM_DEVID_NONE);
		if (!pdev) {
			ret = -ENOMEM;
	np = etnaviv_of_first_available_node();
	if (np) {
		of_node_put(np);
			goto unregister_platform_driver;
		}

		ret = platform_device_add(pdev);
		if (ret) {
			platform_device_put(pdev);
			of_node_put(np);
		ret = etnaviv_create_platform_device("etnaviv", &etnaviv_drm);
		if (ret)
			goto unregister_platform_driver;
	}

		etnaviv_drm = pdev;
		of_node_put(np);
		break;
	}

	return 0;

unregister_platform_driver:
@@ -710,7 +739,7 @@ module_init(etnaviv_init);

static void __exit etnaviv_exit(void)
{
	platform_device_unregister(etnaviv_drm);
	etnaviv_destroy_platform_device(&etnaviv_drm);
	platform_driver_unregister(&etnaviv_platform_driver);
	platform_driver_unregister(&etnaviv_gpu_driver);
}
+5 −7
Original line number Diff line number Diff line
@@ -100,11 +100,10 @@ struct page **etnaviv_gem_get_pages(struct etnaviv_gem_object *etnaviv_obj)

	if (!etnaviv_obj->sgt) {
		struct drm_device *dev = etnaviv_obj->base.dev;
		int npages = etnaviv_obj->base.size >> PAGE_SHIFT;
		unsigned int npages = etnaviv_obj->base.size >> PAGE_SHIFT;
		struct sg_table *sgt;

		sgt = drm_prime_pages_to_sg(etnaviv_obj->base.dev,
					    etnaviv_obj->pages, npages);
		sgt = drm_prime_pages_to_sg(dev, etnaviv_obj->pages, npages);
		if (IS_ERR(sgt)) {
			dev_err(dev->dev, "failed to allocate sgt: %ld\n",
				PTR_ERR(sgt));
@@ -542,7 +541,7 @@ static const struct drm_gem_object_funcs etnaviv_gem_object_funcs = {
	.vm_ops = &vm_ops,
};

static int etnaviv_gem_new_impl(struct drm_device *dev, u32 size, u32 flags,
static int etnaviv_gem_new_impl(struct drm_device *dev, u32 flags,
	const struct etnaviv_gem_ops *ops, struct drm_gem_object **obj)
{
	struct etnaviv_gem_object *etnaviv_obj;
@@ -591,8 +590,7 @@ int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,

	size = PAGE_ALIGN(size);

	ret = etnaviv_gem_new_impl(dev, size, flags,
				   &etnaviv_gem_shmem_ops, &obj);
	ret = etnaviv_gem_new_impl(dev, flags, &etnaviv_gem_shmem_ops, &obj);
	if (ret)
		goto fail;

@@ -627,7 +625,7 @@ int etnaviv_gem_new_private(struct drm_device *dev, size_t size, u32 flags,
	struct drm_gem_object *obj;
	int ret;

	ret = etnaviv_gem_new_impl(dev, size, flags, ops, &obj);
	ret = etnaviv_gem_new_impl(dev, flags, ops, &obj);
	if (ret)
		return ret;

+32 −1
Original line number Diff line number Diff line
@@ -164,6 +164,26 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value)
		*value = gpu->identity.eco_id;
		break;

	case ETNAVIV_PARAM_GPU_NN_CORE_COUNT:
		*value = gpu->identity.nn_core_count;
		break;

	case ETNAVIV_PARAM_GPU_NN_MAD_PER_CORE:
		*value = gpu->identity.nn_mad_per_core;
		break;

	case ETNAVIV_PARAM_GPU_TP_CORE_COUNT:
		*value = gpu->identity.tp_core_count;
		break;

	case ETNAVIV_PARAM_GPU_ON_CHIP_SRAM_SIZE:
		*value = gpu->identity.on_chip_sram_size;
		break;

	case ETNAVIV_PARAM_GPU_AXI_SRAM_SIZE:
		*value = gpu->identity.axi_sram_size;
		break;

	default:
		DBG("%s: invalid param: %u", dev_name(gpu->dev), param);
		return -EINVAL;
@@ -513,8 +533,19 @@ static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)
	timeout = jiffies + msecs_to_jiffies(1000);

	while (time_is_after_jiffies(timeout)) {
		/* enable clock */
		unsigned int fscale = 1 << (6 - gpu->freq_scale);
		u32 pulse_eater = 0x01590880;

		/* disable clock gating */
		gpu_write_power(gpu, VIVS_PM_POWER_CONTROLS, 0x0);

		/* disable pulse eater */
		pulse_eater |= BIT(17);
		gpu_write_power(gpu, VIVS_PM_PULSE_EATER, pulse_eater);
		pulse_eater |= BIT(0);
		gpu_write_power(gpu, VIVS_PM_PULSE_EATER, pulse_eater);

		/* enable clock */
		control = VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(fscale);
		etnaviv_gpu_load_clock(gpu, control);

+12 −0
Original line number Diff line number Diff line
@@ -54,6 +54,18 @@ struct etnaviv_chip_identity {
	/* Number of Neural Network cores. */
	u32 nn_core_count;

	/* Number of MAD units per Neural Network core. */
	u32 nn_mad_per_core;

	/* Number of Tensor Processing cores. */
	u32 tp_core_count;

	/* Size in bytes of the SRAM inside the NPU. */
	u32 on_chip_sram_size;

	/* Size in bytes of the SRAM across the AXI bus. */
	u32 axi_sram_size;

	/* Size of the vertex cache. */
	u32 vertex_cache_size;

Loading