]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
driver core: initialize a default DMA mask for platform device
authorChristoph Hellwig <hch@lst.de>
Fri, 16 Aug 2019 06:24:35 +0000 (08:24 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Aug 2019 16:41:55 +0000 (09:41 -0700)
We still treat devices without a DMA mask as defaulting to 32-bits for
both mask, but a few releases ago we've started warning about such
cases, as they require special cases to work around this sloppyness.
Add a dma_mask field to struct platform_device so that we can initialize
the dma_mask pointer in struct device and initialize both masks to
32-bits by default, replacing similar functionality in m68k and
powerpc.  The arch_setup_pdev_archdata hooks is now unused and removed.

Note that the code looks a little odd with the various conditionals
because we have to support platform_device structures that are
statically allocated.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/r/20190816062435.881-7-hch@lst.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/m68k/kernel/dma.c
arch/powerpc/kernel/setup-common.c
arch/sh/boards/mach-ap325rxa/setup.c
arch/sh/boards/mach-ecovec24/setup.c
arch/sh/boards/mach-kfr2r09/setup.c
arch/sh/boards/mach-migor/setup.c
arch/sh/boards/mach-se/7724/setup.c
drivers/base/platform.c
include/linux/platform_device.h

index 30cd59caf037ee8490097677408532529c123b58..447849d1d645d97beee1a3315eb464adb6ba7b33 100644 (file)
@@ -79,12 +79,3 @@ void arch_sync_dma_for_device(struct device *dev, phys_addr_t handle,
                break;
        }
 }
-
-void arch_setup_pdev_archdata(struct platform_device *pdev)
-{
-       if (pdev->dev.coherent_dma_mask == DMA_MASK_NONE &&
-           pdev->dev.dma_mask == NULL) {
-               pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
-               pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
-       }
-}
index 1f8db666468d74e10ccae52465af11bb2aba9dc1..5e6543aba1b32879e18cab1a4e6d1d45277c4ba5 100644 (file)
@@ -778,12 +778,6 @@ void ppc_printk_progress(char *s, unsigned short hex)
        pr_info("%s\n", s);
 }
 
-void arch_setup_pdev_archdata(struct platform_device *pdev)
-{
-       pdev->archdata.dma_mask = DMA_BIT_MASK(32);
-       pdev->dev.dma_mask = &pdev->archdata.dma_mask;
-}
-
 static __init void print_system_info(void)
 {
        pr_info("-----------------------------------------------------\n");
index 8301a4378f502cdcf8ce87da797013708dab32ce..665cad452798bb41c94d1a509a3c737393a999b0 100644 (file)
@@ -527,7 +527,6 @@ static int __init ap325rxa_devices_setup(void)
 
        /* Initialize CEU platform device separately to map memory first */
        device_initialize(&ap325rxa_ceu_device.dev);
-       arch_setup_pdev_archdata(&ap325rxa_ceu_device);
        dma_declare_coherent_memory(&ap325rxa_ceu_device.dev,
                        ceu_dma_membase, ceu_dma_membase,
                        ceu_dma_membase + CEU_BUFFER_MEMORY_SIZE - 1);
index f402aa741bf370a819b7840183909faa22419331..acaa97459531c60264ee7acd6bd5b299f3f774ae 100644 (file)
@@ -1440,7 +1440,6 @@ static int __init arch_setup(void)
 
        /* Initialize CEU platform devices separately to map memory first */
        device_initialize(&ecovec_ceu_devices[0]->dev);
-       arch_setup_pdev_archdata(ecovec_ceu_devices[0]);
        dma_declare_coherent_memory(&ecovec_ceu_devices[0]->dev,
                                    ceu0_dma_membase, ceu0_dma_membase,
                                    ceu0_dma_membase +
@@ -1448,7 +1447,6 @@ static int __init arch_setup(void)
        platform_device_add(ecovec_ceu_devices[0]);
 
        device_initialize(&ecovec_ceu_devices[1]->dev);
-       arch_setup_pdev_archdata(ecovec_ceu_devices[1]);
        dma_declare_coherent_memory(&ecovec_ceu_devices[1]->dev,
                                    ceu1_dma_membase, ceu1_dma_membase,
                                    ceu1_dma_membase +
index 1cf9a47ac90ed7fcb1580e5cb4526d980d3d918f..96538ba3aa323f5ac78e19ab4a8a100387ddc2af 100644 (file)
@@ -601,7 +601,6 @@ static int __init kfr2r09_devices_setup(void)
 
        /* Initialize CEU platform device separately to map memory first */
        device_initialize(&kfr2r09_ceu_device.dev);
-       arch_setup_pdev_archdata(&kfr2r09_ceu_device);
        dma_declare_coherent_memory(&kfr2r09_ceu_device.dev,
                        ceu_dma_membase, ceu_dma_membase,
                        ceu_dma_membase + CEU_BUFFER_MEMORY_SIZE - 1);
index 90702740f207c783f1a50b2c90ea22ab728da0a1..9ed369dad62df78b9e9d6e016a41ca2abeabb2d6 100644 (file)
@@ -602,7 +602,6 @@ static int __init migor_devices_setup(void)
 
        /* Initialize CEU platform device separately to map memory first */
        device_initialize(&migor_ceu_device.dev);
-       arch_setup_pdev_archdata(&migor_ceu_device);
        dma_declare_coherent_memory(&migor_ceu_device.dev,
                        ceu_dma_membase, ceu_dma_membase,
                        ceu_dma_membase + CEU_BUFFER_MEMORY_SIZE - 1);
index 3674064816c73c7e6ee371f607d1b5b5f88bfbc9..32f5dd9448894a6477a9fe27eecba243c64f096c 100644 (file)
@@ -937,7 +937,6 @@ static int __init devices_setup(void)
 
        /* Initialize CEU platform devices separately to map memory first */
        device_initialize(&ms7724se_ceu_devices[0]->dev);
-       arch_setup_pdev_archdata(ms7724se_ceu_devices[0]);
        dma_declare_coherent_memory(&ms7724se_ceu_devices[0]->dev,
                                    ceu0_dma_membase, ceu0_dma_membase,
                                    ceu0_dma_membase +
@@ -945,7 +944,6 @@ static int __init devices_setup(void)
        platform_device_add(ms7724se_ceu_devices[0]);
 
        device_initialize(&ms7724se_ceu_devices[1]->dev);
-       arch_setup_pdev_archdata(ms7724se_ceu_devices[1]);
        dma_declare_coherent_memory(&ms7724se_ceu_devices[1]->dev,
                                    ceu1_dma_membase, ceu1_dma_membase,
                                    ceu1_dma_membase +
index ec974ba9c0c4ca93a3b1cfcaf541c6e4a4a3bd9c..600913aea73bc6e4e7e8c348aa131b10fba6e919 100644 (file)
@@ -39,25 +39,6 @@ struct device platform_bus = {
 };
 EXPORT_SYMBOL_GPL(platform_bus);
 
-/**
- * arch_setup_pdev_archdata - Allow manipulation of archdata before its used
- * @pdev: platform device
- *
- * This is called before platform_device_add() such that any pdev_archdata may
- * be setup before the platform_notifier is called.  So if a user needs to
- * manipulate any relevant information in the pdev_archdata they can do:
- *
- *     platform_device_alloc()
- *     ... manipulate ...
- *     platform_device_add()
- *
- * And if they don't care they can just call platform_device_register() and
- * everything will just work out.
- */
-void __weak arch_setup_pdev_archdata(struct platform_device *pdev)
-{
-}
-
 /**
  * platform_get_resource - get a resource for a device
  * @dev: platform device
@@ -264,6 +245,20 @@ struct platform_object {
        char name[];
 };
 
+/*
+ * Set up default DMA mask for platform devices if the they weren't
+ * previously set by the architecture / DT.
+ */
+static void setup_pdev_dma_masks(struct platform_device *pdev)
+{
+       if (!pdev->dev.coherent_dma_mask)
+               pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+       if (!pdev->dma_mask)
+               pdev->dma_mask = DMA_BIT_MASK(32);
+       if (!pdev->dev.dma_mask)
+               pdev->dev.dma_mask = &pdev->dma_mask;
+};
+
 /**
  * platform_device_put - destroy a platform device
  * @pdev: platform device to free
@@ -310,7 +305,7 @@ struct platform_device *platform_device_alloc(const char *name, int id)
                pa->pdev.id = id;
                device_initialize(&pa->pdev.dev);
                pa->pdev.dev.release = platform_device_release;
-               arch_setup_pdev_archdata(&pa->pdev);
+               setup_pdev_dma_masks(&pa->pdev);
        }
 
        return pa ? &pa->pdev : NULL;
@@ -512,7 +507,7 @@ EXPORT_SYMBOL_GPL(platform_device_del);
 int platform_device_register(struct platform_device *pdev)
 {
        device_initialize(&pdev->dev);
-       arch_setup_pdev_archdata(pdev);
+       setup_pdev_dma_masks(pdev);
        return platform_device_add(pdev);
 }
 EXPORT_SYMBOL_GPL(platform_device_register);
index 9bc36b589827fe41e47c975044622108f127bff5..34a3d8ed8ba7c37ccb805095521a4de1d82303a4 100644 (file)
@@ -24,6 +24,7 @@ struct platform_device {
        int             id;
        bool            id_auto;
        struct device   dev;
+       u64             dma_mask;
        u32             num_resources;
        struct resource *resource;
 
@@ -48,7 +49,6 @@ extern void platform_device_unregister(struct platform_device *);
 extern struct bus_type platform_bus_type;
 extern struct device platform_bus;
 
-extern void arch_setup_pdev_archdata(struct platform_device *);
 extern struct resource *platform_get_resource(struct platform_device *,
                                              unsigned int, unsigned int);
 extern void __iomem *