Commit 2aed4f5a authored by Mikko Perttunen's avatar Mikko Perttunen Committed by Thierry Reding
Browse files

gpu: host1x: Cleanup and refcounting for syncpoints



Add reference counting for allocated syncpoints to allow keeping
them allocated while jobs are referencing them. Additionally,
clean up various places using syncpoint IDs to use host1x_syncpt
pointers instead.

Signed-off-by: default avatarMikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent f63b42cb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2141,7 +2141,7 @@ static int tegra_dc_init(struct host1x_client *client)
		drm_plane_cleanup(primary);

	host1x_client_iommu_detach(client);
	host1x_syncpt_free(dc->syncpt);
	host1x_syncpt_put(dc->syncpt);

	return err;
}
@@ -2166,7 +2166,7 @@ static int tegra_dc_exit(struct host1x_client *client)
	}

	host1x_client_iommu_detach(client);
	host1x_syncpt_free(dc->syncpt);
	host1x_syncpt_put(dc->syncpt);

	return 0;
}
+7 −7
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
	struct drm_tegra_syncpt syncpt;
	struct host1x *host1x = dev_get_drvdata(drm->dev->parent);
	struct drm_gem_object **refs;
	struct host1x_syncpt *sp;
	struct host1x_syncpt *sp = NULL;
	struct host1x_job *job;
	unsigned int num_refs;
	int err;
@@ -301,8 +301,8 @@ int tegra_drm_submit(struct tegra_drm_context *context,
		goto fail;
	}

	/* check whether syncpoint ID is valid */
	sp = host1x_syncpt_get(host1x, syncpt.id);
	/* Syncpoint ref will be dropped on job release. */
	sp = host1x_syncpt_get_by_id(host1x, syncpt.id);
	if (!sp) {
		err = -ENOENT;
		goto fail;
@@ -311,7 +311,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
	job->is_addr_reg = context->client->ops->is_addr_reg;
	job->is_valid_class = context->client->ops->is_valid_class;
	job->syncpt_incrs = syncpt.incrs;
	job->syncpt_id = syncpt.id;
	job->syncpt = sp;
	job->timeout = 10000;

	if (args->timeout && args->timeout < 10000)
@@ -383,7 +383,7 @@ static int tegra_syncpt_read(struct drm_device *drm, void *data,
	struct drm_tegra_syncpt_read *args = data;
	struct host1x_syncpt *sp;

	sp = host1x_syncpt_get(host, args->id);
	sp = host1x_syncpt_get_by_id_noref(host, args->id);
	if (!sp)
		return -EINVAL;

@@ -398,7 +398,7 @@ static int tegra_syncpt_incr(struct drm_device *drm, void *data,
	struct drm_tegra_syncpt_incr *args = data;
	struct host1x_syncpt *sp;

	sp = host1x_syncpt_get(host1x, args->id);
	sp = host1x_syncpt_get_by_id_noref(host1x, args->id);
	if (!sp)
		return -EINVAL;

@@ -412,7 +412,7 @@ static int tegra_syncpt_wait(struct drm_device *drm, void *data,
	struct drm_tegra_syncpt_wait *args = data;
	struct host1x_syncpt *sp;

	sp = host1x_syncpt_get(host1x, args->id);
	sp = host1x_syncpt_get_by_id_noref(host1x, args->id);
	if (!sp)
		return -EINVAL;

+2 −2
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ static int gr2d_init(struct host1x_client *client)
detach:
	host1x_client_iommu_detach(client);
free:
	host1x_syncpt_free(client->syncpts[0]);
	host1x_syncpt_put(client->syncpts[0]);
put:
	host1x_channel_put(gr2d->channel);
	return err;
@@ -86,7 +86,7 @@ static int gr2d_exit(struct host1x_client *client)
		return err;

	host1x_client_iommu_detach(client);
	host1x_syncpt_free(client->syncpts[0]);
	host1x_syncpt_put(client->syncpts[0]);
	host1x_channel_put(gr2d->channel);

	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ static int gr3d_init(struct host1x_client *client)
detach:
	host1x_client_iommu_detach(client);
free:
	host1x_syncpt_free(client->syncpts[0]);
	host1x_syncpt_put(client->syncpts[0]);
put:
	host1x_channel_put(gr3d->channel);
	return err;
@@ -94,7 +94,7 @@ static int gr3d_exit(struct host1x_client *client)
		return err;

	host1x_client_iommu_detach(client);
	host1x_syncpt_free(client->syncpts[0]);
	host1x_syncpt_put(client->syncpts[0]);
	host1x_channel_put(gr3d->channel);

	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ static int vic_init(struct host1x_client *client)
	return 0;

free_syncpt:
	host1x_syncpt_free(client->syncpts[0]);
	host1x_syncpt_put(client->syncpts[0]);
free_channel:
	host1x_channel_put(vic->channel);
detach:
@@ -238,7 +238,7 @@ static int vic_exit(struct host1x_client *client)
	if (err < 0)
		return err;

	host1x_syncpt_free(client->syncpts[0]);
	host1x_syncpt_put(client->syncpts[0]);
	host1x_channel_put(vic->channel);
	host1x_client_iommu_detach(client);

Loading