diff mbox series

[v2,1/2] drm/dcss: request memory region

Message ID 20240109102032.16165-2-pstanner@redhat.com (mailing list archive)
State New, archived
Headers show
Series drm/imx/dcss: implement region request and devres | expand

Commit Message

Philipp Stanner Jan. 9, 2024, 10:20 a.m. UTC
The driver's memory regions are currently just ioremap()ed, but not
reserved through a request. That's not a bug, but having the request is
a little more robust.

Implement the region-request through the corresponding managed
devres-function.

Signed-off-by: Philipp Stanner <pstanner@redhat.com>
---
 drivers/gpu/drm/imx/dcss/dcss-dev.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

kernel test robot Jan. 10, 2024, 12:39 a.m. UTC | #1
Hi Philipp,

kernel test robot noticed the following build errors:

[auto build test ERROR on v6.7]
[also build test ERROR on linus/master next-20240109]
[cannot apply to drm-misc/drm-misc-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Philipp-Stanner/drm-dcss-request-memory-region/20240109-182239
base:   v6.7
patch link:    https://lore.kernel.org/r/20240109102032.16165-2-pstanner%40redhat.com
patch subject: [PATCH v2 1/2] drm/dcss: request memory region
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240110/202401100801.1Wiy3ZEd-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240110/202401100801.1Wiy3ZEd-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401100801.1Wiy3ZEd-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/device.h:17,
                    from include/linux/platform_device.h:13,
                    from drivers/gpu/drm/imx/dcss/dcss-dev.c:9:
   drivers/gpu/drm/imx/dcss/dcss-dev.c: In function 'dcss_dev_create':
>> drivers/gpu/drm/imx/dcss/dcss-dev.c:188:42: error: incompatible type for argument 1 of '__devm_request_region'
     188 |         if (!devm_request_mem_region(pdev->dev, res->start, res_len, "dcss")) {
         |                                      ~~~~^~~~~
         |                                          |
         |                                          struct device
   include/linux/ioport.h:306:31: note: in definition of macro 'devm_request_mem_region'
     306 |         __devm_request_region(dev, &iomem_resource, (start), (n), (name))
         |                               ^~~
   include/linux/ioport.h:308:63: note: expected 'struct device *' but argument is of type 'struct device'
     308 | extern struct resource * __devm_request_region(struct device *dev,
         |                                                ~~~~~~~~~~~~~~~^~~


vim +/__devm_request_region +188 drivers/gpu/drm/imx/dcss/dcss-dev.c

   165	
   166	struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output)
   167	{
   168		struct platform_device *pdev = to_platform_device(dev);
   169		int ret;
   170		struct resource *res;
   171		struct dcss_dev *dcss;
   172		const struct dcss_type_data *devtype;
   173		resource_size_t res_len;
   174	
   175		devtype = of_device_get_match_data(dev);
   176		if (!devtype) {
   177			dev_err(dev, "no device match found\n");
   178			return ERR_PTR(-ENODEV);
   179		}
   180	
   181		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   182		if (!res) {
   183			dev_err(dev, "cannot get memory resource\n");
   184			return ERR_PTR(-EINVAL);
   185		}
   186	
   187		res_len = res->end - res->start;
 > 188		if (!devm_request_mem_region(pdev->dev, res->start, res_len, "dcss")) {
   189			dev_err(dev, "cannot request memory region\n");
   190			return ERR_PTR(-EBUSY);
   191		}
   192	
   193		dcss = kzalloc(sizeof(*dcss), GFP_KERNEL);
   194		if (!dcss)
   195			return ERR_PTR(-ENOMEM);
   196	
   197		dcss->dev = dev;
   198		dcss->devtype = devtype;
   199		dcss->hdmi_output = hdmi_output;
   200	
   201		ret = dcss_clks_init(dcss);
   202		if (ret) {
   203			dev_err(dev, "clocks initialization failed\n");
   204			goto err;
   205		}
   206	
   207		dcss->of_port = of_graph_get_port_by_id(dev->of_node, 0);
   208		if (!dcss->of_port) {
   209			dev_err(dev, "no port@0 node in %pOF\n", dev->of_node);
   210			ret = -ENODEV;
   211			goto clks_err;
   212		}
   213	
   214		dcss->start_addr = res->start;
   215	
   216		ret = dcss_submodules_init(dcss);
   217		if (ret) {
   218			of_node_put(dcss->of_port);
   219			dev_err(dev, "submodules initialization failed\n");
   220			goto clks_err;
   221		}
   222	
   223		init_completion(&dcss->disable_completion);
   224	
   225		pm_runtime_set_autosuspend_delay(dev, 100);
   226		pm_runtime_use_autosuspend(dev);
   227		pm_runtime_set_suspended(dev);
   228		pm_runtime_allow(dev);
   229		pm_runtime_enable(dev);
   230	
   231		return dcss;
   232	
   233	clks_err:
   234		dcss_clks_release(dcss);
   235	
   236	err:
   237		kfree(dcss);
   238	
   239		return ERR_PTR(ret);
   240	}
   241
kernel test robot Jan. 10, 2024, 4:36 a.m. UTC | #2
Hi Philipp,

kernel test robot noticed the following build errors:

[auto build test ERROR on v6.7]
[also build test ERROR on linus/master next-20240109]
[cannot apply to drm-misc/drm-misc-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Philipp-Stanner/drm-dcss-request-memory-region/20240109-182239
base:   v6.7
patch link:    https://lore.kernel.org/r/20240109102032.16165-2-pstanner%40redhat.com
patch subject: [PATCH v2 1/2] drm/dcss: request memory region
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20240110/202401101201.yVs3iqFU-lkp@intel.com/config)
compiler: clang version 18.0.0git (https://github.com/llvm/llvm-project 7e186d366d6c7def0543acc255931f617e76dff0)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240110/202401101201.yVs3iqFU-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401101201.yVs3iqFU-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/imx/dcss/dcss-dev.c:188:31: error: passing 'struct device' to parameter of incompatible type 'struct device *'; take the address with &
     188 |         if (!devm_request_mem_region(pdev->dev, res->start, res_len, "dcss")) {
         |                                      ^~~~~~~~~
         |                                      &
   include/linux/ioport.h:306:24: note: expanded from macro 'devm_request_mem_region'
     306 |         __devm_request_region(dev, &iomem_resource, (start), (n), (name))
         |                               ^~~
   include/linux/ioport.h:308:63: note: passing argument to parameter 'dev' here
     308 | extern struct resource * __devm_request_region(struct device *dev,
         |                                                               ^
   1 error generated.


vim +188 drivers/gpu/drm/imx/dcss/dcss-dev.c

   165	
   166	struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output)
   167	{
   168		struct platform_device *pdev = to_platform_device(dev);
   169		int ret;
   170		struct resource *res;
   171		struct dcss_dev *dcss;
   172		const struct dcss_type_data *devtype;
   173		resource_size_t res_len;
   174	
   175		devtype = of_device_get_match_data(dev);
   176		if (!devtype) {
   177			dev_err(dev, "no device match found\n");
   178			return ERR_PTR(-ENODEV);
   179		}
   180	
   181		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   182		if (!res) {
   183			dev_err(dev, "cannot get memory resource\n");
   184			return ERR_PTR(-EINVAL);
   185		}
   186	
   187		res_len = res->end - res->start;
 > 188		if (!devm_request_mem_region(pdev->dev, res->start, res_len, "dcss")) {
   189			dev_err(dev, "cannot request memory region\n");
   190			return ERR_PTR(-EBUSY);
   191		}
   192	
   193		dcss = kzalloc(sizeof(*dcss), GFP_KERNEL);
   194		if (!dcss)
   195			return ERR_PTR(-ENOMEM);
   196	
   197		dcss->dev = dev;
   198		dcss->devtype = devtype;
   199		dcss->hdmi_output = hdmi_output;
   200	
   201		ret = dcss_clks_init(dcss);
   202		if (ret) {
   203			dev_err(dev, "clocks initialization failed\n");
   204			goto err;
   205		}
   206	
   207		dcss->of_port = of_graph_get_port_by_id(dev->of_node, 0);
   208		if (!dcss->of_port) {
   209			dev_err(dev, "no port@0 node in %pOF\n", dev->of_node);
   210			ret = -ENODEV;
   211			goto clks_err;
   212		}
   213	
   214		dcss->start_addr = res->start;
   215	
   216		ret = dcss_submodules_init(dcss);
   217		if (ret) {
   218			of_node_put(dcss->of_port);
   219			dev_err(dev, "submodules initialization failed\n");
   220			goto clks_err;
   221		}
   222	
   223		init_completion(&dcss->disable_completion);
   224	
   225		pm_runtime_set_autosuspend_delay(dev, 100);
   226		pm_runtime_use_autosuspend(dev);
   227		pm_runtime_set_suspended(dev);
   228		pm_runtime_allow(dev);
   229		pm_runtime_enable(dev);
   230	
   231		return dcss;
   232	
   233	clks_err:
   234		dcss_clks_release(dcss);
   235	
   236	err:
   237		kfree(dcss);
   238	
   239		return ERR_PTR(ret);
   240	}
   241
diff mbox series

Patch

diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.c b/drivers/gpu/drm/imx/dcss/dcss-dev.c
index 4f3af0dfb344..1f93313c89b7 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-dev.c
+++ b/drivers/gpu/drm/imx/dcss/dcss-dev.c
@@ -170,6 +170,7 @@  struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output)
 	struct resource *res;
 	struct dcss_dev *dcss;
 	const struct dcss_type_data *devtype;
+	resource_size_t res_len;
 
 	devtype = of_device_get_match_data(dev);
 	if (!devtype) {
@@ -183,6 +184,12 @@  struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output)
 		return ERR_PTR(-EINVAL);
 	}
 
+	res_len = res->end - res->start;
+	if (!devm_request_mem_region(pdev->dev, res->start, res_len, "dcss")) {
+		dev_err(dev, "cannot request memory region\n");
+		return ERR_PTR(-EBUSY);
+	}
+
 	dcss = kzalloc(sizeof(*dcss), GFP_KERNEL);
 	if (!dcss)
 		return ERR_PTR(-ENOMEM);