Linux-Next discussions
 help / color / mirror / Atom feed
* linux-next: manual merge of the drm-msm tree with the origin tree
@ 2026-11-30 16:27 Mark Brown
  0 siblings, 0 replies; only message in thread
From: Mark Brown @ 2026-11-30 16:27 UTC (permalink / raw)
  To: Rob Clark, Sean Paul
  Cc: Akhil P Oommen, Haitao Xu, Kees Cook, Kees Cook,
	Linux Kernel Mailing List, Linux Next Mailing List, Rob Clark

[-- Attachment #1: Type: text/plain, Size: 10168 bytes --]

Hi all,

Today's linux-next merge of the drm-msm tree got a conflict in:

  drivers/gpu/drm/msm/msm_drv.c

between commit:

  4dd10fbbeb9c3 ("treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family")

from the origin tree and commits:

  c2747e9fb6234 ("drm/msm/gem: Add some cleanup.h")
  3fd1cb78beef4 ("drm/msm: Consolidate msm_gpu_probe into msm_drv_probe")
  bc6a4bde38573 ("drm/msm: Hold runpm ref in set_sysprof()")

from the drm-msm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --combined drivers/gpu/drm/msm/msm_drv.c
index 3675df277f6a6,cd59daa02bf94..0000000000000
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@@ -5,6 -5,7 +5,7 @@@
   * Author: Rob Clark <robdclark@gmail.com>
   */
  
+ #include <linux/cleanup.h>
  #include <linux/dma-mapping.h>
  #include <linux/fault-inject.h>
  #include <linux/debugfs.h>
@@@ -115,11 -116,11 +116,11 @@@ static bool msm_separate_gpu_kms_auto(v
  	int gpus = msm_count_gpus();
  	int display_subsystems = msm_count_mdss() + msm_count_mdp4();
  
- 	if (gpus <= 0 || display_subsystems <= 0)
+ 	/* Single card if there is exactly one GPU and one display subsystem */
+ 	if (gpus == 1 && display_subsystems == 1)
  		return false;
  
- 	/* Single card if there is exactly one GPU and one display subsystem */
- 	return gpus > 1 || display_subsystems > 1;
+ 	return true;
  }
  
  bool msm_separate_gpu_kms_components(void)
@@@ -137,10 -138,19 +138,19 @@@
  	}
  }
  
- static int msm_drm_uninit(struct device *dev, const struct component_ops *gpu_ops)
+ static void msm_drm_priv_release(struct device *dev, void *res)
  {
- 	struct platform_device *pdev = to_platform_device(dev);
- 	struct msm_drm_private *priv = platform_get_drvdata(pdev);
+ 	/* The devres core frees the allocation after this callback. */
+ }
+ 
+ struct msm_drm_private *msm_drm_get_priv(struct device *dev)
+ {
+ 	return devres_find(dev, msm_drm_priv_release, NULL, NULL);
+ }
+ 
+ static int msm_drm_uninit(struct device *dev)
+ {
+ 	struct msm_drm_private *priv = msm_drm_get_priv(dev);
  	struct drm_device *ddev = priv->dev;
  
  	/*
@@@ -163,10 -173,15 +173,15 @@@
  	if (priv->kms)
  		msm_drm_kms_uninit(dev);
  
- 	if (gpu_ops)
- 		gpu_ops->unbind(dev, dev, NULL);
- 	else
- 		component_unbind_all(dev, ddev);
+ 	if (priv->gpu_pdev) {
+ 		struct device *gpu_dev = &priv->gpu_pdev->dev;
+ 
+ 		if (pm_runtime_enabled(gpu_dev))
+ 			WARN_ON_ONCE(adreno_system_suspend(gpu_dev));
+ 		msm_devfreq_cleanup(dev_to_gpu(gpu_dev));
+ 	}
+ 
+ 	component_unbind_all(dev, ddev);
  
  	ddev->dev_private = NULL;
  	drm_dev_put(ddev);
@@@ -174,10 -189,9 +189,9 @@@
  	return 0;
  }
  
- static int msm_drm_init(struct device *dev, const struct drm_driver *drv,
- 			const struct component_ops *gpu_ops)
+ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
  {
- 	struct msm_drm_private *priv = dev_get_drvdata(dev);
+ 	struct msm_drm_private *priv = msm_drm_get_priv(dev);
  	struct drm_device *ddev;
  	int ret;
  
@@@ -221,13 -235,14 +235,14 @@@
  	dma_set_max_seg_size(dev, UINT_MAX);
  
  	/* Bind all our sub-components: */
- 	if (gpu_ops)
- 		ret = gpu_ops->bind(dev, dev, NULL);
- 	else
- 		ret = component_bind_all(dev, ddev);
+ 	ret = component_bind_all(dev, ddev);
  	if (ret)
  		goto err_put_dev;
  
+ 	/* Devfreq callbacks require the GPU and GMU to be initialized. */
+ 	if (priv->gpu_pdev)
+ 		msm_devfreq_init(dev_to_gpu(&priv->gpu_pdev->dev));
+ 
  	ret = msm_gem_shrinker_init(ddev);
  	if (ret)
  		goto err_msm_uninit;
@@@ -254,7 -269,7 +269,7 @@@
  	return 0;
  
  err_msm_uninit:
- 	msm_drm_uninit(dev, gpu_ops);
+ 	msm_drm_uninit(dev);
  
  	return ret;
  
@@@ -362,7 -377,7 +377,7 @@@ static void msm_postclose(struct drm_de
  	 * It is not possible to set sysprof param to non-zero if gpu
  	 * is not initialized:
  	 */
- 	if (priv->gpu)
+ 	if (priv->gpu && ctx->sysprof)
  		msm_context_set_sysprof(ctx, priv->gpu, 0);
  
  	context_close(ctx);
@@@ -550,7 -565,6 +565,6 @@@ static int msm_ioctl_gem_info_set_metad
  {
  	struct msm_gem_object *msm_obj = to_msm_bo(obj);
  	void *new_metadata;
- 	void *buf;
  	int ret;
  
  	/* Impose a moderate upper bound on metadata size: */
@@@ -559,32 -573,25 +573,25 @@@
  	}
  
  	/* Use a temporary buf to keep copy_from_user() outside of gem obj lock: */
- 	buf = memdup_user(metadata, metadata_size);
+ 	void *buf __free(kfree) = memdup_user(metadata, metadata_size);
  	if (IS_ERR(buf))
  		return PTR_ERR(buf);
  
- 	ret = msm_gem_lock_interruptible(obj);
- 	if (ret)
- 		goto out;
+ 	ACQUIRE(gem_lock_intr, lock)(obj);
+ 	if ((ret = ACQUIRE_ERR(gem_lock_intr, &lock)))
+ 		return ret;
  
  	new_metadata =
  		krealloc(msm_obj->metadata, metadata_size, GFP_KERNEL);
  	if (!new_metadata) {
- 		ret = -ENOMEM;
- 		goto unlock;
+ 		return -ENOMEM;
  	}
  
  	msm_obj->metadata = new_metadata;
  	msm_obj->metadata_size = metadata_size;
  	memcpy(msm_obj->metadata, buf, metadata_size);
  
- unlock:
- 	msm_gem_unlock(obj);
- 
- out:
- 	kfree(buf);
- 
- 	return ret;
+ 	return 0;
  }
  
  static int msm_ioctl_gem_info_get_metadata(struct drm_gem_object *obj,
@@@ -608,26 -615,20 +615,20 @@@
  		return 0;
  	}
  
- 	ret = msm_gem_lock_interruptible(obj);
- 	if (ret)
- 		return ret;
- 
- 	/* Avoid copy_to_user() under gem obj lock: */
- 	len = msm_obj->metadata_size;
- 	buf = kmemdup(msm_obj->metadata, len, GFP_KERNEL);
- 
- 	if (!buf) {
- 		msm_gem_unlock(obj);
- 		return -ENOMEM;
+ 	scoped_cond_guard (gem_lock_intr, return -EINTR, obj) {
+ 		/* Avoid copy_to_user() under gem obj lock by making a copy: */
+ 		len = msm_obj->metadata_size;
+ 		buf = kmemdup(msm_obj->metadata, len, GFP_KERNEL);
+ 		if (!buf)
+ 			return -ENOMEM;
  	}
  
- 	msm_gem_unlock(obj);
- 
  	if (*metadata_size < len) {
  		ret = -ETOOSMALL;
  	} else if (copy_to_user(metadata, buf, len)) {
  		ret = -EFAULT;
  	} else {
+ 		ret = 0;
  		*metadata_size = len;
  	}
  
@@@ -1095,34 -1096,42 +1096,42 @@@ static const struct of_device_id msm_gp
  };
  
  static int add_gpu_components(struct device *dev,
+ 			      struct device_node *gpu_np,
  			      struct component_match **matchptr)
  {
- 	struct device_node *np;
+ 	struct device_node *np __free(device_node) = gpu_np ?
+ 		of_node_get(gpu_np) : of_find_matching_node(NULL, msm_gpu_match);
  
- 	np = of_find_matching_node(NULL, msm_gpu_match);
- 	if (!np)
+ 	if (!np || !msm_gpu_node_present(np))
  		return 0;
  
- 	if (msm_gpu_node_present(np))
- 		drm_of_component_match_add(dev, matchptr, component_compare_of, np);
+ 	drm_of_component_match_add(dev, matchptr, component_compare_of, np);
  
- 	of_node_put(np);
+ 	struct device_node *gmu_np __free(device_node) = of_parse_phandle(np, "qcom,gmu", 0);
+ 	if (of_device_is_available(gmu_np))
+ 		drm_of_component_match_add(dev, matchptr, component_compare_of, gmu_np);
  
  	return 0;
  }
  
  static int msm_drm_bind(struct device *dev)
  {
- 	return msm_drm_init(dev,
- 			    msm_separate_gpu_kms_components() ?
- 				    &msm_kms_driver :
- 				    &msm_driver,
- 			    NULL);
+ 	struct msm_drm_private *priv = msm_drm_get_priv(dev);
+ 	const struct drm_driver *drv;
+ 
+ 	if (!priv->kms_init)
+ 		drv = &msm_gpu_driver;
+ 	else if (msm_separate_gpu_kms_components())
+ 		drv = &msm_kms_driver;
+ 	else
+ 		drv = &msm_driver;
+ 
+ 	return msm_drm_init(dev, drv);
  }
  
  static void msm_drm_unbind(struct device *dev)
  {
- 	msm_drm_uninit(dev, NULL);
+ 	msm_drm_uninit(dev);
  }
  
  const struct component_master_ops msm_drm_ops = {
@@@ -1131,6 -1140,7 +1140,7 @@@
  };
  
  int msm_drv_probe(struct device *master_dev,
+ 	struct device_node *gpu_np,
  	int (*kms_init)(struct drm_device *dev),
  	struct msm_kms *kms)
  {
@@@ -1138,13 -1148,14 +1148,14 @@@
  	struct component_match *match = NULL;
  	int ret;
  
- 	priv = devm_kzalloc_obj(master_dev, *priv);
+ 	priv = devres_alloc(msm_drm_priv_release, sizeof(*priv), GFP_KERNEL);
  	if (!priv)
  		return -ENOMEM;
  
  	priv->kms = kms;
  	priv->kms_init = kms_init;
- 	dev_set_drvdata(master_dev, priv);
+ 	/* Register before component binding so priv survives unbind/rebind. */
+ 	devres_add(master_dev, priv);
  
  	/* Add mdp components if we have KMS. */
  	if (kms_init) {
@@@ -1153,8 -1164,8 +1164,8 @@@
  			return ret;
  	}
  
- 	if (!msm_separate_gpu_kms_components()) {
- 		ret = add_gpu_components(master_dev, &match);
+ 	if (!kms_init || !msm_separate_gpu_kms_components()) {
+ 		ret = add_gpu_components(master_dev, gpu_np, &match);
  		if (ret)
  			return ret;
  	}
@@@ -1173,32 -1184,14 +1184,14 @@@
  	return 0;
  }
  
- int msm_gpu_probe(struct platform_device *pdev,
- 		  const struct component_ops *ops)
+ int msm_gpu_probe(struct platform_device *pdev)
  {
- 	struct msm_drm_private *priv;
- 	int ret;
- 
- 	priv = devm_kzalloc_obj(&pdev->dev, *priv);
- 	if (!priv)
- 		return -ENOMEM;
- 
- 	platform_set_drvdata(pdev, priv);
- 
- 	/* on all devices that I am aware of, iommu's which can map
- 	 * any address the cpu can see are used:
- 	 */
- 	ret = dma_set_mask_and_coherent(&pdev->dev, ~0);
- 	if (ret)
- 		return ret;
- 
- 	return msm_drm_init(&pdev->dev, &msm_gpu_driver, ops);
+ 	return msm_drv_probe(&pdev->dev, pdev->dev.of_node, NULL, NULL);
  }
  
- void msm_gpu_remove(struct platform_device *pdev,
- 		    const struct component_ops *ops)
+ void msm_gpu_remove(struct platform_device *pdev)
  {
- 	msm_drm_uninit(&pdev->dev, ops);
+ 	component_master_del(&pdev->dev, &msm_drm_ops);
  }
  
  static int __init msm_drm_register(void)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-30 16:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 16:27 linux-next: manual merge of the drm-msm tree with the origin tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox