diff mbox series

[5/5] drm: Remove exports for drm_pci_alloc/drm_pci_free

Message ID 20200202171635.4039044-5-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [1/5] drm: Remove PageReserved manipulation from drm_pci_alloc | expand

Commit Message

Chris Wilson Feb. 2, 2020, 5:16 p.m. UTC
The drm_pci_alloc routines have been a thin wrapper around the core dma
coherent routines. Remove the crutch of a wrapper and the exported
symbols, marking it for only internal legacy use.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/drm_bufs.c   |  5 +++--
 drivers/gpu/drm/drm_legacy.h | 23 +++++++++++++++++++++++
 drivers/gpu/drm/drm_pci.c    | 31 ++++++-------------------------
 include/drm/drm_pci.h        | 18 ------------------
 4 files changed, 32 insertions(+), 45 deletions(-)

Comments

Alex Deucher Feb. 3, 2020, 9:55 p.m. UTC | #1
On Sun, Feb 2, 2020 at 12:16 PM Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> The drm_pci_alloc routines have been a thin wrapper around the core dma
> coherent routines. Remove the crutch of a wrapper and the exported
> symbols, marking it for only internal legacy use.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>


> ---
>  drivers/gpu/drm/drm_bufs.c   |  5 +++--
>  drivers/gpu/drm/drm_legacy.h | 23 +++++++++++++++++++++++
>  drivers/gpu/drm/drm_pci.c    | 31 ++++++-------------------------
>  include/drm/drm_pci.h        | 18 ------------------
>  4 files changed, 32 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index 19297e58b232..a33df3744f76 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -675,7 +675,7 @@ static void drm_cleanup_buf_error(struct drm_device *dev,
>         if (entry->seg_count) {
>                 for (i = 0; i < entry->seg_count; i++) {
>                         if (entry->seglist[i]) {
> -                               drm_pci_free(dev, entry->seglist[i]);
> +                               drm_legacy_pci_free(dev, entry->seglist[i]);
>                         }
>                 }
>                 kfree(entry->seglist);
> @@ -975,7 +975,8 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
>
>         while (entry->buf_count < count) {
>
> -               dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000);
> +               dmah = drm_legacy_pci_alloc(dev,
> +                                           PAGE_SIZE << page_order, 0x1000);
>
>                 if (!dmah) {
>                         /* Set count correctly so we free the proper amount. */
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 1be3ea320474..3853b45341c7 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -36,6 +36,7 @@
>
>  struct agp_memory;
>  struct drm_device;
> +struct drm_dma_handle;
>  struct drm_file;
>  struct drm_buf_desc;
>
> @@ -211,4 +212,26 @@ void drm_master_legacy_init(struct drm_master *master);
>  static inline void drm_master_legacy_init(struct drm_master *master) {}
>  #endif
>
> +
> +#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
> +
> +struct drm_dma_handle *
> +drm_legacy_pci_alloc(struct drm_device *dev, size_t size, size_t align);
> +void drm_legacy_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
> +
> +#else
> +
> +static inline struct drm_dma_handle *
> +drm_legacy_pci_alloc(struct drm_device *dev, size_t size, size_t align)
> +{
> +       return NULL;
> +}
> +
> +static inline void drm_legacy_pci_free(struct drm_device *dev,
> +                                      struct drm_dma_handle *dmah)
> +{
> +}
> +
> +#endif
> +
>  #endif /* __DRM_LEGACY_H__ */
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index c6bb98729a26..12239498538c 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -36,19 +36,10 @@
>  #include "drm_internal.h"
>  #include "drm_legacy.h"
>
> -/**
> - * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA.
> - * @dev: DRM device
> - * @size: size of block to allocate
> - * @align: alignment of block
> - *
> - * FIXME: This is a needless abstraction of the Linux dma-api and should be
> - * removed.
> - *
> - * Return: A handle to the allocated memory block on success or NULL on
> - * failure.
> - */
> -drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t align)
> +#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
> +
> +drm_dma_handle_t *
> +drm_legacy_pci_alloc(struct drm_device * dev, size_t size, size_t align)
>  {
>         drm_dma_handle_t *dmah;
>
> @@ -76,24 +67,14 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
>         return dmah;
>  }
>
> -EXPORT_SYMBOL(drm_pci_alloc);
> -
> -/**
> - * drm_pci_free - Free a PCI consistent memory block
> - * @dev: DRM device
> - * @dmah: handle to memory block
> - *
> - * FIXME: This is a needless abstraction of the Linux dma-api and should be
> - * removed.
> - */
> -void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
> +void drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
>  {
>         dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
>                           dmah->busaddr);
>         kfree(dmah);
>  }
>
> -EXPORT_SYMBOL(drm_pci_free);
> +#endif
>
>  static int drm_get_pci_domain(struct drm_device *dev)
>  {
> diff --git a/include/drm/drm_pci.h b/include/drm/drm_pci.h
> index 9031e217b506..cade5b60b643 100644
> --- a/include/drm/drm_pci.h
> +++ b/include/drm/drm_pci.h
> @@ -34,34 +34,16 @@
>
>  #include <linux/pci.h>
>
> -struct drm_dma_handle;
> -struct drm_device;
>  struct drm_driver;
> -struct drm_master;
>
>  #ifdef CONFIG_PCI
>
> -struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
> -                                    size_t align);
> -void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
> -
>  int drm_get_pci_dev(struct pci_dev *pdev,
>                     const struct pci_device_id *ent,
>                     struct drm_driver *driver);
>
>  #else
>
> -static inline struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev,
> -                                                  size_t size, size_t align)
> -{
> -       return NULL;
> -}
> -
> -static inline void drm_pci_free(struct drm_device *dev,
> -                               struct drm_dma_handle *dmah)
> -{
> -}
> -
>  static inline int drm_get_pci_dev(struct pci_dev *pdev,
>                                   const struct pci_device_id *ent,
>                                   struct drm_driver *driver)
> --
> 2.25.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
kernel test robot Feb. 4, 2020, 4:46 a.m. UTC | #2
Hi Chris,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-tip/drm-tip drm-exynos/exynos-drm-next linus/master next-20200203]
[cannot apply to tegra-drm/drm/tegra/for-next drm/drm-next v5.5]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-Remove-PageReserved-manipulation-from-drm_pci_alloc/20200203-201707
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: arm-multi_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/gpu/drm/drm_dma.c: In function 'drm_legacy_dma_takedown':
>> drivers/gpu/drm/drm_dma.c:103:6: error: implicit declaration of function 'drm_pci_free'; did you mean 'arm_dma_free'? [-Werror=implicit-function-declaration]
         drm_pci_free(dev, dma->bufs[i].seglist[j]);
         ^~~~~~~~~~~~
         arm_dma_free
   cc1: some warnings being treated as errors

vim +103 drivers/gpu/drm/drm_dma.c

^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   72  
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   73  /**
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   74   * Cleanup the DMA resources.
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   75   *
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   76   * \param dev DRM device.
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   77   *
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   78   * Free all pages associated with DMA buffers, the buffers and pages lists, and
59c51591a0ac75 drivers/char/drm/drm_dma.c Michael Opdenacker 2007-05-09   79   * finally the drm_device::dma structure itself.
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   80   */
e2e99a8206bcce drivers/gpu/drm/drm_dma.c  Daniel Vetter      2013-08-08   81  void drm_legacy_dma_takedown(struct drm_device *dev)
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   82  {
cdd55a294c13f8 drivers/char/drm/drm_dma.c Dave Airlie        2007-07-11   83  	struct drm_device_dma *dma = dev->dma;
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   84  	int i, j;
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   85  
e2e99a8206bcce drivers/gpu/drm/drm_dma.c  Daniel Vetter      2013-08-08   86  	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
fa5386459f06dc drivers/gpu/drm/drm_dma.c  Daniel Vetter      2016-08-03   87  	    !drm_core_check_feature(dev, DRIVER_LEGACY))
e2e99a8206bcce drivers/gpu/drm/drm_dma.c  Daniel Vetter      2013-08-08   88  		return;
e2e99a8206bcce drivers/gpu/drm/drm_dma.c  Daniel Vetter      2013-08-08   89  
b5e89ed53ed8d2 drivers/char/drm/drm_dma.c Dave Airlie        2005-09-25   90  	if (!dma)
b5e89ed53ed8d2 drivers/char/drm/drm_dma.c Dave Airlie        2005-09-25   91  		return;
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   92  
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   93  	/* Clear dma buffers */
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   94  	for (i = 0; i <= DRM_MAX_ORDER; i++) {
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   95  		if (dma->bufs[i].seg_count) {
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   96  			DRM_DEBUG("order %d: buf_count = %d,"
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   97  				  " seg_count = %d\n",
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   98  				  i,
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   99  				  dma->bufs[i].buf_count,
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  100  				  dma->bufs[i].seg_count);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  101  			for (j = 0; j < dma->bufs[i].seg_count; j++) {
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  102  				if (dma->bufs[i].seglist[j]) {
ddf19b973be5a9 drivers/char/drm/drm_dma.c Dave Airlie        2006-03-19 @103  					drm_pci_free(dev, dma->bufs[i].seglist[j]);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  104  				}
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  105  			}
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  106  			kfree(dma->bufs[i].seglist);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  107  		}
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  108  		if (dma->bufs[i].buf_count) {
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  109  			for (j = 0; j < dma->bufs[i].buf_count; j++) {
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  110  				kfree(dma->bufs[i].buflist[j].dev_private);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  111  			}
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  112  			kfree(dma->bufs[i].buflist);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  113  		}
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  114  	}
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  115  
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  116  	kfree(dma->buflist);
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  117  	kfree(dma->pagelist);
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  118  	kfree(dev->dma);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  119  	dev->dma = NULL;
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  120  }
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  121  

:::::: The code at line 103 was first introduced by commit
:::::: ddf19b973be5a96d77c8467f657fe5bd7d126e0f drm: fixup PCI DMA support

:::::: TO: Dave Airlie <airlied@linux.ie>
:::::: CC: Dave Airlie <airlied@linux.ie>

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
kernel test robot Feb. 4, 2020, 8:34 a.m. UTC | #3
Hi Chris,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-tip/drm-tip drm-exynos/exynos-drm-next linus/master next-20200203]
[cannot apply to tegra-drm/drm/tegra/for-next drm/drm-next v5.5]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-Remove-PageReserved-manipulation-from-drm_pci_alloc/20200203-201707
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-s2-20200204 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.2-10+deb8u1) 4.9.2
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/gpu/drm/drm_dma.c: In function 'drm_legacy_dma_takedown':
>> drivers/gpu/drm/drm_dma.c:103:6: error: implicit declaration of function 'drm_pci_free' [-Werror=implicit-function-declaration]
         drm_pci_free(dev, dma->bufs[i].seglist[j]);
         ^
   cc1: some warnings being treated as errors

vim +/drm_pci_free +103 drivers/gpu/drm/drm_dma.c

^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   72  
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   73  /**
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   74   * Cleanup the DMA resources.
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   75   *
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   76   * \param dev DRM device.
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   77   *
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   78   * Free all pages associated with DMA buffers, the buffers and pages lists, and
59c51591a0ac75 drivers/char/drm/drm_dma.c Michael Opdenacker 2007-05-09   79   * finally the drm_device::dma structure itself.
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   80   */
e2e99a8206bcce drivers/gpu/drm/drm_dma.c  Daniel Vetter      2013-08-08   81  void drm_legacy_dma_takedown(struct drm_device *dev)
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   82  {
cdd55a294c13f8 drivers/char/drm/drm_dma.c Dave Airlie        2007-07-11   83  	struct drm_device_dma *dma = dev->dma;
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   84  	int i, j;
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   85  
e2e99a8206bcce drivers/gpu/drm/drm_dma.c  Daniel Vetter      2013-08-08   86  	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
fa5386459f06dc drivers/gpu/drm/drm_dma.c  Daniel Vetter      2016-08-03   87  	    !drm_core_check_feature(dev, DRIVER_LEGACY))
e2e99a8206bcce drivers/gpu/drm/drm_dma.c  Daniel Vetter      2013-08-08   88  		return;
e2e99a8206bcce drivers/gpu/drm/drm_dma.c  Daniel Vetter      2013-08-08   89  
b5e89ed53ed8d2 drivers/char/drm/drm_dma.c Dave Airlie        2005-09-25   90  	if (!dma)
b5e89ed53ed8d2 drivers/char/drm/drm_dma.c Dave Airlie        2005-09-25   91  		return;
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   92  
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   93  	/* Clear dma buffers */
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   94  	for (i = 0; i <= DRM_MAX_ORDER; i++) {
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   95  		if (dma->bufs[i].seg_count) {
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   96  			DRM_DEBUG("order %d: buf_count = %d,"
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   97  				  " seg_count = %d\n",
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   98  				  i,
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16   99  				  dma->bufs[i].buf_count,
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  100  				  dma->bufs[i].seg_count);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  101  			for (j = 0; j < dma->bufs[i].seg_count; j++) {
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  102  				if (dma->bufs[i].seglist[j]) {
ddf19b973be5a9 drivers/char/drm/drm_dma.c Dave Airlie        2006-03-19 @103  					drm_pci_free(dev, dma->bufs[i].seglist[j]);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  104  				}
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  105  			}
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  106  			kfree(dma->bufs[i].seglist);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  107  		}
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  108  		if (dma->bufs[i].buf_count) {
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  109  			for (j = 0; j < dma->bufs[i].buf_count; j++) {
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  110  				kfree(dma->bufs[i].buflist[j].dev_private);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  111  			}
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  112  			kfree(dma->bufs[i].buflist);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  113  		}
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  114  	}
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  115  
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  116  	kfree(dma->buflist);
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  117  	kfree(dma->pagelist);
9a298b2acd771d drivers/gpu/drm/drm_dma.c  Eric Anholt        2009-03-24  118  	kfree(dev->dma);
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  119  	dev->dma = NULL;
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  120  }
^1da177e4c3f41 drivers/char/drm/drm_dma.c Linus Torvalds     2005-04-16  121  

:::::: The code at line 103 was first introduced by commit
:::::: ddf19b973be5a96d77c8467f657fe5bd7d126e0f drm: fixup PCI DMA support

:::::: TO: Dave Airlie <airlied@linux.ie>
:::::: CC: Dave Airlie <airlied@linux.ie>

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
Daniel Vetter Feb. 4, 2020, 2:18 p.m. UTC | #4
On Sun, Feb 02, 2020 at 05:16:35PM +0000, Chris Wilson wrote:
> The drm_pci_alloc routines have been a thin wrapper around the core dma
> coherent routines. Remove the crutch of a wrapper and the exported
> symbols, marking it for only internal legacy use.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Since Alex bothered to review the drm_bufs&r128 patches ...

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

I think all the other patches I've r-b stamped somewhere else already, but
if they changed pls poke.
-Daniel


> ---
>  drivers/gpu/drm/drm_bufs.c   |  5 +++--
>  drivers/gpu/drm/drm_legacy.h | 23 +++++++++++++++++++++++
>  drivers/gpu/drm/drm_pci.c    | 31 ++++++-------------------------
>  include/drm/drm_pci.h        | 18 ------------------
>  4 files changed, 32 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index 19297e58b232..a33df3744f76 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -675,7 +675,7 @@ static void drm_cleanup_buf_error(struct drm_device *dev,
>  	if (entry->seg_count) {
>  		for (i = 0; i < entry->seg_count; i++) {
>  			if (entry->seglist[i]) {
> -				drm_pci_free(dev, entry->seglist[i]);
> +				drm_legacy_pci_free(dev, entry->seglist[i]);
>  			}
>  		}
>  		kfree(entry->seglist);
> @@ -975,7 +975,8 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
>  
>  	while (entry->buf_count < count) {
>  
> -		dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000);
> +		dmah = drm_legacy_pci_alloc(dev,
> +					    PAGE_SIZE << page_order, 0x1000);
>  
>  		if (!dmah) {
>  			/* Set count correctly so we free the proper amount. */
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 1be3ea320474..3853b45341c7 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -36,6 +36,7 @@
>  
>  struct agp_memory;
>  struct drm_device;
> +struct drm_dma_handle;
>  struct drm_file;
>  struct drm_buf_desc;
>  
> @@ -211,4 +212,26 @@ void drm_master_legacy_init(struct drm_master *master);
>  static inline void drm_master_legacy_init(struct drm_master *master) {}
>  #endif
>  
> +
> +#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
> +
> +struct drm_dma_handle *
> +drm_legacy_pci_alloc(struct drm_device *dev, size_t size, size_t align);
> +void drm_legacy_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
> +
> +#else
> +
> +static inline struct drm_dma_handle *
> +drm_legacy_pci_alloc(struct drm_device *dev, size_t size, size_t align)
> +{
> +	return NULL;
> +}
> +
> +static inline void drm_legacy_pci_free(struct drm_device *dev,
> +				       struct drm_dma_handle *dmah)
> +{
> +}
> +
> +#endif
> +
>  #endif /* __DRM_LEGACY_H__ */
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index c6bb98729a26..12239498538c 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -36,19 +36,10 @@
>  #include "drm_internal.h"
>  #include "drm_legacy.h"
>  
> -/**
> - * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA.
> - * @dev: DRM device
> - * @size: size of block to allocate
> - * @align: alignment of block
> - *
> - * FIXME: This is a needless abstraction of the Linux dma-api and should be
> - * removed.
> - *
> - * Return: A handle to the allocated memory block on success or NULL on
> - * failure.
> - */
> -drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t align)
> +#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
> +
> +drm_dma_handle_t *
> +drm_legacy_pci_alloc(struct drm_device * dev, size_t size, size_t align)
>  {
>  	drm_dma_handle_t *dmah;
>  
> @@ -76,24 +67,14 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
>  	return dmah;
>  }
>  
> -EXPORT_SYMBOL(drm_pci_alloc);
> -
> -/**
> - * drm_pci_free - Free a PCI consistent memory block
> - * @dev: DRM device
> - * @dmah: handle to memory block
> - *
> - * FIXME: This is a needless abstraction of the Linux dma-api and should be
> - * removed.
> - */
> -void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
> +void drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
>  {
>  	dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
>  			  dmah->busaddr);
>  	kfree(dmah);
>  }
>  
> -EXPORT_SYMBOL(drm_pci_free);
> +#endif
>  
>  static int drm_get_pci_domain(struct drm_device *dev)
>  {
> diff --git a/include/drm/drm_pci.h b/include/drm/drm_pci.h
> index 9031e217b506..cade5b60b643 100644
> --- a/include/drm/drm_pci.h
> +++ b/include/drm/drm_pci.h
> @@ -34,34 +34,16 @@
>  
>  #include <linux/pci.h>
>  
> -struct drm_dma_handle;
> -struct drm_device;
>  struct drm_driver;
> -struct drm_master;
>  
>  #ifdef CONFIG_PCI
>  
> -struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
> -				     size_t align);
> -void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
> -
>  int drm_get_pci_dev(struct pci_dev *pdev,
>  		    const struct pci_device_id *ent,
>  		    struct drm_driver *driver);
>  
>  #else
>  
> -static inline struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev,
> -						   size_t size, size_t align)
> -{
> -	return NULL;
> -}
> -
> -static inline void drm_pci_free(struct drm_device *dev,
> -				struct drm_dma_handle *dmah)
> -{
> -}
> -
>  static inline int drm_get_pci_dev(struct pci_dev *pdev,
>  				  const struct pci_device_id *ent,
>  				  struct drm_driver *driver)
> -- 
> 2.25.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 19297e58b232..a33df3744f76 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -675,7 +675,7 @@  static void drm_cleanup_buf_error(struct drm_device *dev,
 	if (entry->seg_count) {
 		for (i = 0; i < entry->seg_count; i++) {
 			if (entry->seglist[i]) {
-				drm_pci_free(dev, entry->seglist[i]);
+				drm_legacy_pci_free(dev, entry->seglist[i]);
 			}
 		}
 		kfree(entry->seglist);
@@ -975,7 +975,8 @@  int drm_legacy_addbufs_pci(struct drm_device *dev,
 
 	while (entry->buf_count < count) {
 
-		dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000);
+		dmah = drm_legacy_pci_alloc(dev,
+					    PAGE_SIZE << page_order, 0x1000);
 
 		if (!dmah) {
 			/* Set count correctly so we free the proper amount. */
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 1be3ea320474..3853b45341c7 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -36,6 +36,7 @@ 
 
 struct agp_memory;
 struct drm_device;
+struct drm_dma_handle;
 struct drm_file;
 struct drm_buf_desc;
 
@@ -211,4 +212,26 @@  void drm_master_legacy_init(struct drm_master *master);
 static inline void drm_master_legacy_init(struct drm_master *master) {}
 #endif
 
+
+#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
+
+struct drm_dma_handle *
+drm_legacy_pci_alloc(struct drm_device *dev, size_t size, size_t align);
+void drm_legacy_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
+
+#else
+
+static inline struct drm_dma_handle *
+drm_legacy_pci_alloc(struct drm_device *dev, size_t size, size_t align)
+{
+	return NULL;
+}
+
+static inline void drm_legacy_pci_free(struct drm_device *dev,
+				       struct drm_dma_handle *dmah)
+{
+}
+
+#endif
+
 #endif /* __DRM_LEGACY_H__ */
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index c6bb98729a26..12239498538c 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -36,19 +36,10 @@ 
 #include "drm_internal.h"
 #include "drm_legacy.h"
 
-/**
- * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA.
- * @dev: DRM device
- * @size: size of block to allocate
- * @align: alignment of block
- *
- * FIXME: This is a needless abstraction of the Linux dma-api and should be
- * removed.
- *
- * Return: A handle to the allocated memory block on success or NULL on
- * failure.
- */
-drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t align)
+#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
+
+drm_dma_handle_t *
+drm_legacy_pci_alloc(struct drm_device * dev, size_t size, size_t align)
 {
 	drm_dma_handle_t *dmah;
 
@@ -76,24 +67,14 @@  drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
 	return dmah;
 }
 
-EXPORT_SYMBOL(drm_pci_alloc);
-
-/**
- * drm_pci_free - Free a PCI consistent memory block
- * @dev: DRM device
- * @dmah: handle to memory block
- *
- * FIXME: This is a needless abstraction of the Linux dma-api and should be
- * removed.
- */
-void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
+void drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
 {
 	dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
 			  dmah->busaddr);
 	kfree(dmah);
 }
 
-EXPORT_SYMBOL(drm_pci_free);
+#endif
 
 static int drm_get_pci_domain(struct drm_device *dev)
 {
diff --git a/include/drm/drm_pci.h b/include/drm/drm_pci.h
index 9031e217b506..cade5b60b643 100644
--- a/include/drm/drm_pci.h
+++ b/include/drm/drm_pci.h
@@ -34,34 +34,16 @@ 
 
 #include <linux/pci.h>
 
-struct drm_dma_handle;
-struct drm_device;
 struct drm_driver;
-struct drm_master;
 
 #ifdef CONFIG_PCI
 
-struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
-				     size_t align);
-void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
-
 int drm_get_pci_dev(struct pci_dev *pdev,
 		    const struct pci_device_id *ent,
 		    struct drm_driver *driver);
 
 #else
 
-static inline struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev,
-						   size_t size, size_t align)
-{
-	return NULL;
-}
-
-static inline void drm_pci_free(struct drm_device *dev,
-				struct drm_dma_handle *dmah)
-{
-}
-
 static inline int drm_get_pci_dev(struct pci_dev *pdev,
 				  const struct pci_device_id *ent,
 				  struct drm_driver *driver)