diff mbox series

[v2] drm/ast: use managed devres functions

Message ID 20231103182542.97589-2-pstanner@redhat.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/ast: use managed devres functions | expand

Commit Message

Philipp Stanner Nov. 3, 2023, 6:25 p.m. UTC
Currently, tha ast-driver just maps the PCI-dev's regions with
pcim_iomap(). It does not actually reserve the regions exclusively
with, e.g., pci_request_regions().

Replace the calls to pcim_iomap() with ones to pcim_iomap_regions() to
reserve and map the regions simultaneously.

Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
---
Changes in v2:
- Remove unnecessary return code checks for pcim_iomap_regions()
  (Jocelyn)

Thx Jocelyn for the kind review
---
 drivers/gpu/drm/ast/ast_main.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Philipp Stanner Nov. 10, 2023, 7:12 p.m. UTC | #1
On Fri, 2023-11-03 at 19:25 +0100, Philipp Stanner wrote:
> Currently, tha ast-driver just maps the PCI-dev's regions with
> pcim_iomap(). It does not actually reserve the regions exclusively
> with, e.g., pci_request_regions().
> 
> Replace the calls to pcim_iomap() with ones to pcim_iomap_regions()
> to
> reserve and map the regions simultaneously.
> 
> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Philipp Stanner <pstanner@redhat.com>

Thinking about this once more, I guess we could postpone merging it.

I'm a bit unhappy with the pcim_* functions as they're currently
implemented and might soon start working on a replacement.

Depending on that work, this Patch here might soon be obsolete /
outdated anyways.

But merging wouldn't hurt on the other hand, as I have to send a new
one in any case. I leave that up to the maintainer.

See also here [1] if interested.

P.

[1] https://lore.kernel.org/all/84be1049e41283cf8a110267646320af9ffe59fe.camel@redhat.com/


> ---
> Changes in v2:
> - Remove unnecessary return code checks for pcim_iomap_regions()
>   (Jocelyn)
> 
> Thx Jocelyn for the kind review
> ---
>  drivers/gpu/drm/ast/ast_main.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_main.c
> b/drivers/gpu/drm/ast/ast_main.c
> index dae365ed3969..8b714b99f9d6 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -444,9 +444,11 @@ struct ast_device *ast_device_create(const
> struct drm_driver *drv,
>         if (ret)
>                 return ERR_PTR(ret);
>  
> -       ast->regs = pcim_iomap(pdev, 1, 0);
> -       if (!ast->regs)
> -               return ERR_PTR(-EIO);
> +       ret = pcim_iomap_regions(pdev, BIT(1), 0);
> +       if (ret)
> +               return ERR_PTR(ret);
> +
> +       ast->regs = pcim_iomap_table(pdev)[1];
>  
>         /*
>          * After AST2500, MMIO is enabled by default, and it should
> be adopted
> @@ -461,9 +463,10 @@ struct ast_device *ast_device_create(const
> struct drm_driver *drv,
>  
>         /* "map" IO regs if the above hasn't done so already */
>         if (!ast->ioregs) {
> -               ast->ioregs = pcim_iomap(pdev, 2, 0);
> -               if (!ast->ioregs)
> -                       return ERR_PTR(-EIO);
> +               ret = pcim_iomap_regions(pdev, BIT(2), 0);
> +               if (ret)
> +                       return ERR_PTR(ret);
> +               ast->ioregs = pcim_iomap_table(pdev)[2];
>         }
>  
>         if (!ast_is_vga_enabled(dev)) {
kernel test robot Nov. 16, 2023, 1:45 p.m. UTC | #2
Hi Philipp,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm/drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.7-rc1 next-20231116]
[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-ast-use-managed-devres-functions/20231104-022841
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20231103182542.97589-2-pstanner%40redhat.com
patch subject: [PATCH v2] drm/ast: use managed devres functions
config: x86_64-randconfig-122-20231116 (https://download.01.org/0day-ci/archive/20231116/202311162100.DnPejGd3-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/202311162100.DnPejGd3-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/202311162100.DnPejGd3-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/ast/ast_main.c:447:48: sparse: sparse: Using plain integer as NULL pointer
   drivers/gpu/drm/ast/ast_main.c:466:56: sparse: sparse: Using plain integer as NULL pointer

vim +447 drivers/gpu/drm/ast/ast_main.c

   426	
   427	struct ast_device *ast_device_create(const struct drm_driver *drv,
   428					     struct pci_dev *pdev,
   429					     unsigned long flags)
   430	{
   431		struct drm_device *dev;
   432		struct ast_device *ast;
   433		bool need_post = false;
   434		int ret = 0;
   435	
   436		ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base);
   437		if (IS_ERR(ast))
   438			return ast;
   439		dev = &ast->base;
   440	
   441		pci_set_drvdata(pdev, dev);
   442	
   443		ret = drmm_mutex_init(dev, &ast->ioregs_lock);
   444		if (ret)
   445			return ERR_PTR(ret);
   446	
 > 447		ret = pcim_iomap_regions(pdev, BIT(1), 0);
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index dae365ed3969..8b714b99f9d6 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -444,9 +444,11 @@  struct ast_device *ast_device_create(const struct drm_driver *drv,
 	if (ret)
 		return ERR_PTR(ret);
 
-	ast->regs = pcim_iomap(pdev, 1, 0);
-	if (!ast->regs)
-		return ERR_PTR(-EIO);
+	ret = pcim_iomap_regions(pdev, BIT(1), 0);
+	if (ret)
+		return ERR_PTR(ret);
+
+	ast->regs = pcim_iomap_table(pdev)[1];
 
 	/*
 	 * After AST2500, MMIO is enabled by default, and it should be adopted
@@ -461,9 +463,10 @@  struct ast_device *ast_device_create(const struct drm_driver *drv,
 
 	/* "map" IO regs if the above hasn't done so already */
 	if (!ast->ioregs) {
-		ast->ioregs = pcim_iomap(pdev, 2, 0);
-		if (!ast->ioregs)
-			return ERR_PTR(-EIO);
+		ret = pcim_iomap_regions(pdev, BIT(2), 0);
+		if (ret)
+			return ERR_PTR(ret);
+		ast->ioregs = pcim_iomap_table(pdev)[2];
 	}
 
 	if (!ast_is_vga_enabled(dev)) {