@@ -822,13 +822,30 @@ static void tegra_display_hub_destroy_state(struct drm_private_obj *obj,
to_tegra_display_hub_state(state);
kfree(hub_state);
}
+static void tegra_display_hub_reset(struct drm_private_obj *obj)
+{
+ struct tegra_display_hub_state *hub_state;
+
+ if (obj->state) {
+ tegra_display_hub_destroy_state(obj, obj->state);
+ obj->state = NULL;
+ }
+
+ hub_state = kzalloc(sizeof(*hub_state), GFP_KERNEL);
+ if (!hub_state)
+ return;
+
+ __drm_atomic_helper_private_obj_reset(obj, &hub_state->base);
+}
+
static const struct drm_private_state_funcs tegra_display_hub_state_funcs = {
.atomic_duplicate_state = tegra_display_hub_duplicate_state,
.atomic_destroy_state = tegra_display_hub_destroy_state,
+ .reset = tegra_display_hub_reset,
};
static struct tegra_display_hub_state *
tegra_display_hub_get_state(struct tegra_display_hub *hub,
struct drm_atomic_state *state)
@@ -938,17 +955,12 @@ void tegra_display_hub_atomic_commit(struct drm_device *drm,
static int tegra_display_hub_init(struct host1x_client *client)
{
struct tegra_display_hub *hub = to_tegra_display_hub(client);
struct drm_device *drm = dev_get_drvdata(client->host);
struct tegra_drm *tegra = drm->dev_private;
- struct tegra_display_hub_state *state;
- state = kzalloc(sizeof(*state), GFP_KERNEL);
- if (!state)
- return -ENOMEM;
-
- drm_atomic_private_obj_init(drm, &hub->base, &state->base,
+ drm_atomic_private_obj_init(drm, &hub->base, NULL,
&tegra_display_hub_state_funcs);
tegra->hub = hub;
return 0;
The tegra driver relies on a drm_private_obj, that is initialized by allocating and initializing a state, and then passing it to drm_private_obj_init. Since we're gradually moving away from that pattern to the more established one relying on a reset implementation, let's migrate this instance to the new pattern. Signed-off-by: Maxime Ripard <mripard@kernel.org> --- Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Mikko Perttunen <mperttunen@nvidia.com> Cc: Jonathan Hunter <jonathanh@nvidia.com> Cc: linux-tegra@vger.kernel.org --- drivers/gpu/drm/tegra/hub.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)