Commit ec919e6e authored by AngeloGioacchino Del Regno's avatar AngeloGioacchino Del Regno Committed by Rob Clark
Browse files

drm/msm: Allocate msm_drm_private early and pass it as driver data



In preparation for registering the mdss interrupt controller earlier,
move the allocation of msm_drm_private from component bind time to
msm_drv probe; this also allows us to use the devm variant of kzalloc.

Since it is not right to allocate the drm_device at probe time (as
it should exist only when all components are bound, and taken down
when components get cleaned up), the only way to make this happen is
to pass a pointer to msm_drm_private as driver data (like done in
many other DRM drivers), instead of one to drm_device like it's
currently done in this driver.

This is also simplifying some bind/unbind functions around drm/msm,
as some of them are using drm_device just to grab a pointer to the
msm_drm_private structure, which we now retrieve in one call.

Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20211201105210.24970-2-angelogioacchino.delregno@collabora.com


Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 83b965d1
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -427,13 +427,6 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
	return gpu;
}

static void set_gpu_pdev(struct drm_device *dev,
		struct platform_device *pdev)
{
	struct msm_drm_private *priv = dev->dev_private;
	priv->gpu_pdev = pdev;
}

static int find_chipid(struct device *dev, struct adreno_rev *rev)
{
	struct device_node *node = dev->of_node;
@@ -482,8 +475,8 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)
{
	static struct adreno_platform_config config = {};
	const struct adreno_info *info;
	struct drm_device *drm = dev_get_drvdata(master);
	struct msm_drm_private *priv = drm->dev_private;
	struct msm_drm_private *priv = dev_get_drvdata(master);
	struct drm_device *drm = priv->dev;
	struct msm_gpu *gpu;
	int ret;

@@ -492,7 +485,7 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)
		return ret;

	dev->platform_data = &config;
	set_gpu_pdev(drm, to_platform_device(dev));
	priv->gpu_pdev = to_platform_device(dev);

	info = adreno_info(config.rev);

@@ -521,12 +514,13 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)
static void adreno_unbind(struct device *dev, struct device *master,
		void *data)
{
	struct msm_drm_private *priv = dev_get_drvdata(master);
	struct msm_gpu *gpu = dev_to_gpu(dev);

	pm_runtime_force_suspend(dev);
	gpu->funcs->destroy(gpu);

	set_gpu_pdev(dev_get_drvdata(master), NULL);
	priv->gpu_pdev = NULL;
}

static const struct component_ops a3xx_ops = {
+2 −2
Original line number Diff line number Diff line
@@ -1153,9 +1153,9 @@ struct msm_kms *dpu_kms_init(struct drm_device *dev)

static int dpu_bind(struct device *dev, struct device *master, void *data)
{
	struct drm_device *ddev = dev_get_drvdata(master);
	struct msm_drm_private *priv = dev_get_drvdata(master);
	struct platform_device *pdev = to_platform_device(dev);
	struct msm_drm_private *priv = ddev->dev_private;
	struct drm_device *ddev = priv->dev;
	struct dpu_kms *dpu_kms;
	struct dss_module_power *mp;
	int ret = 0;
+2 −1
Original line number Diff line number Diff line
@@ -921,7 +921,8 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)

static int mdp5_bind(struct device *dev, struct device *master, void *data)
{
	struct drm_device *ddev = dev_get_drvdata(master);
	struct msm_drm_private *priv = dev_get_drvdata(master);
	struct drm_device *ddev = priv->dev;
	struct platform_device *pdev = to_platform_device(dev);

	DBG("");
+3 −7
Original line number Diff line number Diff line
@@ -233,13 +233,10 @@ static int dp_display_bind(struct device *dev, struct device *master,
{
	int rc = 0;
	struct dp_display_private *dp = dev_get_dp_display_private(dev);
	struct msm_drm_private *priv;
	struct drm_device *drm;

	drm = dev_get_drvdata(master);
	struct msm_drm_private *priv = dev_get_drvdata(master);
	struct drm_device *drm = priv->dev;

	dp->dp_display.drm_dev = drm;
	priv = drm->dev_private;
	priv->dp[dp->id] = &dp->dp_display;

	rc = dp->parser->parse(dp->parser, dp->dp_display.connector_type);
@@ -275,8 +272,7 @@ static void dp_display_unbind(struct device *dev, struct device *master,
			      void *data)
{
	struct dp_display_private *dp = dev_get_dp_display_private(dev);
	struct drm_device *drm = dev_get_drvdata(master);
	struct msm_drm_private *priv = drm->dev_private;
	struct msm_drm_private *priv = dev_get_drvdata(master);

	dp_power_client_deinit(dp->power);
	dp_aux_unregister(dp->aux);
+2 −4
Original line number Diff line number Diff line
@@ -110,8 +110,7 @@ static struct msm_dsi *dsi_init(struct platform_device *pdev)

static int dsi_bind(struct device *dev, struct device *master, void *data)
{
	struct drm_device *drm = dev_get_drvdata(master);
	struct msm_drm_private *priv = drm->dev_private;
	struct msm_drm_private *priv = dev_get_drvdata(master);
	struct msm_dsi *msm_dsi = dev_get_drvdata(dev);

	priv->dsi[msm_dsi->id] = msm_dsi;
@@ -122,8 +121,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
static void dsi_unbind(struct device *dev, struct device *master,
		void *data)
{
	struct drm_device *drm = dev_get_drvdata(master);
	struct msm_drm_private *priv = drm->dev_private;
	struct msm_drm_private *priv = dev_get_drvdata(master);
	struct msm_dsi *msm_dsi = dev_get_drvdata(dev);

	priv->dsi[msm_dsi->id] = NULL;
Loading