DMA mask changes
Subsystems (53)
cover DMA mask changes
This started out as a request to look at the DMA mask situation, and how to solve the issues which we have on ARM - notably how the DMA mask should be setup.
However, I started off reviewing how the dma_mask and coherent_dma_mask was being used, and what I found was rather messy, and in some cases rather buggy. I tried to get some of the bug fixes in before the last merge window, but it seems that the maintainers preferred to have the full solution rather than a simple -rc suitable bug fix.
So, this is an attempt to clean things up.
The first point here is that drivers performing DMA should be calling dma_set_mask()/dma_set_coherent_mask() in their probe function to verify that DMA can be performed. Lots of ARM drivers omit this step; please refer to the DMA API documentation on this subject.
What this means is that the DMA mask provided by bus code is a default value - nothing more. It doesn't have to accurately reflect what the device is actually capable of. Apart from the storage for dev->dma_mask being initialised for any device which is DMA capable, there is no other initialisation which is strictly necessary at device creation time.
Now, these cleanups address two major areas:
1. The setting of DMA masks, particularly when both the coherent and streaming DMA masks are set together.
2. The initialisation of DMA masks by drivers - this seems to be becoming a popular habbit, one which may not be entirely the right solution. Rather than having this scattered throughout the tree, I've pulled that into a central location (and called it coercing the DMA mask - because it really is about forcing the DMA mask to be that value.)
3. Finally, addressing the long held misbelief that DMA masks somehow correspond with physical addresses. We already have established long ago that dma_addr_t values returned from the DMA API are the values which you program into the DMA controller, and so are the bus addresses. It is _only_ sane that DMA masks are also bus related too, and not related to physical address spaces.
(3) is a very important point for LPAE systems, which may still have less than 4GB of memory, but this memory is all located above the 4GB physical boundary. This means with the current model, any device using a 32-bit DMA mask fails - even though the DMA controller is still only a 32-bit DMA controller but the 32-bit bus addresses map to system memory. To put it another way, the bus addresses have a 4GB physical offset on them.
This email is only being sent to the mailing lists in question, not to anyone personally. The list of individuals is far to great to do that. I'm hoping no mailing lists reject the patches based on the number of recipients.
Patches based on v3.12-rc1.
Documentation/DMA-API-HOWTO.txt | 37 +++++++++------ Documentation/DMA-API.txt | 8 +++ arch/arm/include/asm/dma-mapping.h | 8 +++ arch/arm/mm/dma-mapping.c | 49 ++++++++++++++++++-- arch/arm/mm/init.c | 12 +++--- arch/arm/mm/mm.h | 2 + arch/powerpc/kernel/vio.c | 3 +- block/blk-settings.c | 8 ++-- drivers/amba/bus.c | 6 +-- drivers/ata/pata_ixp4xx_cf.c | 5 ++- drivers/ata/pata_octeon_cf.c | 5 +- drivers/block/nvme-core.c | 10 ++--- drivers/crypto/ixp4xx_crypto.c | 48 ++++++++++---------- drivers/dma/amba-pl08x.c | 5 ++ drivers/dma/dw/platform.c | 8 +-- drivers/dma/edma.c | 6 +-- drivers/dma/pl330.c | 4 ++ drivers/firmware/dcdbas.c | 23 +++++----- drivers/firmware/google/gsmi.c | 13 +++-- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 5 +- drivers/media/platform/omap3isp/isp.c | 6 +- drivers/media/platform/omap3isp/isp.h | 3 - drivers/mmc/card/queue.c | 3 +- drivers/mmc/host/sdhci-acpi.c | 5 +- drivers/net/ethernet/broadcom/b44.c | 3 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 8 +--- drivers/net/ethernet/brocade/bna/bnad.c | 13 ++---- drivers/net/ethernet/emulex/benet/be_main.c | 12 +---- drivers/net/ethernet/intel/e1000/e1000_main.c | 9 +--- drivers/net/ethernet/intel/e1000e/netdev.c | 18 +++----- drivers/net/ethernet/intel/igb/igb_main.c | 18 +++----- drivers/net/ethernet/intel/igbvf/netdev.c | 18 +++----- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 16 ++----- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 15 ++---- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 15 ++---- drivers/net/ethernet/nxp/lpc_eth.c | 6 ++- drivers/net/ethernet/octeon/octeon_mgmt.c | 5 +- drivers/net/ethernet/sfc/efx.c | 12 +----- drivers/net/wireless/b43/dma.c | 9 +--- drivers/net/wireless/b43legacy/dma.c | 9 +--- drivers/of/platform.c | 3 - drivers/parport/parport_pc.c | 8 +++- drivers/scsi/scsi_lib.c | 2 +- drivers/staging/dwc2/platform.c | 5 +- drivers/staging/et131x/et131x.c | 17 +------ drivers/staging/imx-drm/imx-drm-core.c | 8 +++- drivers/staging/imx-drm/ipuv3-crtc.c | 4 +- drivers/staging/media/dt3155v4l/dt3155v4l.c | 5 +-- drivers/usb/chipidea/ci_hdrc_imx.c | 7 +-- drivers/usb/dwc3/dwc3-exynos.c | 7 +-- drivers/usb/gadget/lpc32xx_udc.c | 4 +- drivers/usb/host/bcma-hcd.c | 3 +- drivers/usb/host/ehci-atmel.c | 7 +-- drivers/usb/host/ehci-octeon.c | 4 +- drivers/usb/host/ehci-omap.c | 10 ++-- drivers/usb/host/ehci-orion.c | 7 +-- drivers/usb/host/ehci-platform.c | 10 ++-- drivers/usb/host/ehci-s5p.c | 7 +-- drivers/usb/host/ehci-spear.c | 7 +-- drivers/usb/host/ehci-tegra.c | 7 +-- drivers/usb/host/ohci-at91.c | 9 ++-- drivers/usb/host/ohci-exynos.c | 7 +-- drivers/usb/host/ohci-nxp.c | 5 +- drivers/usb/host/ohci-octeon.c | 5 +- drivers/usb/host/ohci-omap3.c | 10 ++-- drivers/usb/host/ohci-pxa27x.c | 8 ++-- drivers/usb/host/ohci-sa1111.c | 6 +++ drivers/usb/host/ohci-spear.c | 7 +-- drivers/usb/host/ssb-hcd.c | 3 +- drivers/usb/host/uhci-platform.c | 7 +-- drivers/usb/musb/am35x.c | 50 +++++++-------------- drivers/usb/musb/da8xx.c | 49 +++++++------------- drivers/usb/musb/davinci.c | 48 +++++++------------- drivers/usb/musb/tusb6010.c | 49 +++++++------------- drivers/video/amba-clcd.c | 5 ++ include/linux/amba/bus.h | 2 - include/linux/dma-mapping.h | 31 +++++++++++++ sound/arm/pxa2xx-pcm.c | 9 +--- sound/soc/atmel/atmel-pcm.c | 11 ++--- sound/soc/blackfin/bf5xx-ac97-pcm.c | 11 ++--- sound/soc/blackfin/bf5xx-i2s-pcm.c | 10 ++--- sound/soc/davinci/davinci-pcm.c | 9 +--- sound/soc/fsl/fsl_dma.c | 9 +--- sound/soc/fsl/mpc5200_dma.c | 10 ++--- sound/soc/jz4740/jz4740-pcm.c | 12 ++--- sound/soc/kirkwood/kirkwood-dma.c | 9 +--- sound/soc/nuc900/nuc900-pcm.c | 9 ++-- sound/soc/omap/omap-pcm.c | 11 ++--- sound/soc/pxa/pxa2xx-pcm.c | 11 ++--- sound/soc/s6000/s6000-pcm.c | 9 +--- sound/soc/samsung/dma.c | 11 ++--- sound/soc/samsung/idma.c | 11 ++--- 93 files changed, 493 insertions(+), 566 deletions(-)
PATCH 1/51 DMA-API: provide a helper to set both DMA and coherent DMA masks
Provide a helper to set both the DMA and coherent DMA masks to the same value - this avoids duplicated code in a number of drivers, sometimes with buggy error handling, and also allows us identify which drivers do things differently.
--- Documentation/DMA-API-HOWTO.txt | 37 ++++++++++++++++++++++--------------- Documentation/DMA-API.txt | 8 ++++++++ include/linux/dma-mapping.h | 14 ++++++++++++++ 3 files changed, 44 insertions(+), 15 deletions(-)
Documentation/DMA-API-HOWTO.txt +22 -15
@@ -101,14 +101,23 @@ style to do this even if your device holds the default setting, because this shows that you did think about these issues wrt. your device. -The query is performed via a call to dma_set_mask(): +The query is performed via a call to dma_set_mask_and_coherent(): - int dma_set_mask(struct device *dev, u64 mask); + int dma_set_mask_and_coherent(struct device *dev, u64 mask); -The query for consistent allocations is performed via a call to -dma_set_coherent_mask(): +which will query the mask for both streaming and coherent APIs together. +If you have some special requirements, then the following two separate +queries can be used instead: - int dma_set_coherent_mask(struct device *dev, u64 mask); + The query for streaming mappings is performed via a call to + dma_set_mask(): + + int dma_set_mask(struct device *dev, u64 mask); + + The query for consistent allocations is performed via a call + to dma_set_coherent_mask(): + + int dma_set_coherent_mask(struct device *dev, u64 mask); Here, dev is a pointer to the device struct of your device, and mask is a bit mask describing which bits of an address your device
@@ -137,7 +146,7 @@ exactly why. The standard 32-bit addressing device would do something like this: - if (dma_set_mask(dev, DMA_BIT_MASK(32))) { + if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) { printk(KERN_WARNING "mydev: No suitable DMA available.\n"); goto ignore_this_device;
@@ -171,22 +180,20 @@ If a card is capable of using 64-bit consistent allocations as well, int using_dac, consistent_using_dac; - if (!dma_set_mask(dev, DMA_BIT_MASK(64))) { + if (!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) { using_dac = 1; consistent_using_dac = 1; - dma_set_coherent_mask(dev, DMA_BIT_MASK(64)); - } else if (!dma_set_mask(dev, DMA_BIT_MASK(32))) { + } else if (!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) { using_dac = 0; consistent_using_dac = 0; - dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); } else { printk(KERN_WARNING "mydev: No suitable DMA available.\n"); goto ignore_this_device; } -dma_set_coherent_mask() will always be able to set the same or a -smaller mask as dma_set_mask(). However for the rare case that a +The coherent coherent mask will always be able to set the same or a +smaller mask as the streaming mask. However for the rare case that a device driver only uses consistent allocations, one would have to check the return value from dma_set_coherent_mask().
@@ -199,9 +206,9 @@ Finally, if your device can only drive the low 24-bits of goto ignore_this_device; } -When dma_set_mask() is successful, and returns zero, the kernel saves -away this mask you have provided. The kernel will use this -information later when you make DMA mappings. +When dma_set_mask() or dma_set_mask_and_coherent() is successful, and +returns zero, the kernel saves away this mask you have provided. The +kernel will use this information later when you make DMA mappings. There is a case which we are aware of at this time, which is worth mentioning in this documentation. If your device supports multiple
Documentation/DMA-API.txt +8 -0
@@ -142,6 +142,14 @@ internal API for use by the platform than an external API for use by driver writers. int +dma_set_mask_and_coherent(struct device *dev, u64 mask) + +Checks to see if the mask is possible and updates the device +streaming and coherent DMA mask parameters if it is. + +Returns: 0 if successful and a negative error if not. + +int dma_set_mask(struct device *dev, u64 mask) Checks to see if the mask is possible and updates the device
include/linux/dma-mapping.h +14 -0
@@ -97,6 +97,20 @@ static inline int dma_set_coherent_mask(struct device *dev, u64 mask) }#endif +/* +* Set both the DMA mask and the coherent DMA mask to the same thing. +* Note that we don't check the return value from dma_set_coherent_mask() +* as the DMA API guarantees that the coherent DMA mask can be set to +* the same or smaller than the streaming DMA mask. +*/ +static inline int dma_set_mask_and_coherent (struct device *dev,u64 mask) +{ +int rc =dma_set_mask (dev, mask); +if (rc ==0 ) +dma_set_coherent_mask (dev, mask); +return rc; +} +extern u64 dma_get_required_mask (struct device *dev);static inline unsigned int dma_get_max_seg_size (struct device *dev)
Signature · 1 line
1.7.4.4
A message that is not in the archive (sent off-list or not yet received): E1VMlja-0007fA-HU-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org
Re: [PATCH 01/51] DMA-API: provide a helper to set both DMA and coherent DMA masks
Quoted 16 lines · Russell King
Provide a helper to set both the DMA and coherent DMA masks to the same value - this avoids duplicated code in a number of drivers, sometimes with buggy error handling, and also allows us identify which drivers do things differently.
Signed-off-by Russell King <rmk+kernel-lFZ/[email protected]>--- Documentation/DMA-API-HOWTO.txt | 37 ++++++++++++++++++++++--------------- Documentation/DMA-API.txt | 8 ++++++++ include/linux/dma-mapping.h | 14 ++++++++++++++ 3 files changed, 44 insertions(+), 15 deletions(-)Documentation/DMA-API-HOWTO.txt +0
-0
[...]
Documentation/DMA-API-HOWTO.txt If a card is capable of using 64-bit consistent allocations as well, · line 196
Quoted 4 lines
Documentation/DMA-API-HOWTO.txt +2
-2-dma_set_coherent_mask() will always be able to set the same or a -smaller mask as dma_set_mask(). However for the rare case that a +The coherent coherent mask will always be able to set the same or a +smaller mask as the streaming mask. However for the rare case that a
[...]
The new wording doesn't make sense; a mask doesn't set itself. I would suggest:
"The coherent mask can always be set to the same or a smaller mask than the streaming mask."
Ben.
Signature · 8 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1379640097.2500.4.camel-/LGg1Z1CJKQ+9kgCwbf1HqK4ta4zdZpAajtMo4Cw6ucAvxtiuMwx3w@public.gmane.org
Re: [PATCH 01/51] DMA-API: provide a helper to set both DMA and coherent DMA masks
Quoted 8 lines · Ben Hutchings
On Thu, 2013-09-19 at 22:25 +0100, Russell King wrote:
[...]Quoted 4 lines
Documentation/DMA-API-HOWTO.txt +2
-2-dma_set_coherent_mask() will always be able to set the same or a -smaller mask as dma_set_mask(). However for the rare case that a +The coherent coherent mask will always be able to set the same or a +smaller mask as the streaming mask. However for the rare case that a[...]
Quoted 5 lines
The new wording doesn't make sense; a mask doesn't set itself. I would suggest:
"The coherent mask can always be set to the same or a smaller mask than the streaming mask."
Yes, the original sentence is not particularly good, but I think even your modified version can be interpreted as "a mask setting itself" for all the same reasons that the original can be (which mask does "same" refer to?)
Even so, I prefer your version. Thanks. :)
PATCH 2/51 DMA-API: net: brocade/bna/bnad.c: fix 32-bit DMA mask handling
In reply to Russell King - ARM LinuxThe fallback to 32-bit DMA mask is rather odd:
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
!dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
*using_dac = true;
} else {
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
err = dma_set_coherent_mask(&pdev->dev,
DMA_BIT_MASK(32));
if (err)
goto release_regions;
}This means we only try and set the coherent DMA mask if we failed to set a 32-bit DMA mask, and only if both fail do we fail the driver. Adjust this so that if either setting fails, we fail the driver - and thereby end up properly setting both the DMA mask and the coherent DMA mask in the fallback case.
--- drivers/net/ethernet/brocade/bna/bnad.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +4 -9
@@ -3300,17 +3300,12 @@ bnad_pci_init(struct bnad *bnad, err =pci_request_regions (pdev,BNAD_NAME );if (err) goto disable_device; -if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )) && - !dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { +if (!dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ))) { *using_dac = true; }else { - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (err) { - err =dma_set_coherent_mask (&pdev->dev, -DMA_BIT_MASK (32 )); -if (err) - goto release_regions; - } + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) + goto release_regions; *using_dac = false; }pci_set_master (pdev);
Signature · 1 line
1.7.4.4
PATCH 3/51 DMA-API: net: intel/e1000e: fix 32-bit DMA mask handling
In reply to Russell King - ARM LinuxThe fallback to 32-bit DMA mask is rather odd:
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err) {
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err)
pci_using_dac = 1;
} else {
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
err = dma_set_coherent_mask(&pdev->dev,
DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev,
"No usable DMA configuration, aborting\n");
goto err_dma;
}
}
}This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if dma_set_mask() succeeded, and to error out if either fails.
--- drivers/net/ethernet/intel/e1000e/netdev.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +6 -12
@@ -6553,21 +6553,15 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return err; pci_using_dac =0 ; - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));if (!err) { - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (!err) - pci_using_dac =1 ; + pci_using_dac =1 ; }else { - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) { - err =dma_set_coherent_mask (&pdev->dev, -DMA_BIT_MASK (32 )); -if (err) { -dev_err (&pdev->dev, -"No usable DMA configuration, aborting\n" ); - goto err_dma; - } +dev_err (&pdev->dev, +"No usable DMA configuration, aborting\n" ); + goto err_dma; } }
Signature · 1 line
1.7.4.4
Re: [PATCH 03/51] DMA-API: net: intel/e1000e: fix 32-bit DMA mask handling
Quoted 25 lines · Russell King
The fallback to 32-bit DMA mask is rather odd:
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); if (!err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); if (!err) pci_using_dac = 1; } else { err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { dev_err(&pdev->dev, "No usable DMA configuration, aborting\n"); goto err_dma; } } }This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if
dma_set_mask()succeeded, and to error out if either fails.
Quoted 4 lines
Signed-off-by Russell King <[email protected]>--- drivers/net/ethernet/intel/e1000e/netdev.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-)
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
A message that is not in the archive (sent off-list or not yet received): 20130919212235.GD12758-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org
PATCH 4/51 DMA-API: net: intel/igb: fix 32-bit DMA mask handling
The fallback to 32-bit DMA mask is rather odd:
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err) {
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err)
pci_using_dac = 1;
} else {
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
err = dma_set_coherent_mask(&pdev->dev,
DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev,
"No usable DMA configuration, aborting\n");
goto err_dma;
}
}
}This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if dma_set_mask() succeeded, and to error out if either fails.
--- drivers/net/ethernet/intel/igb/igb_main.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +6 -12
@@ -2034,21 +2034,15 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return err; pci_using_dac =0 ; - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));if (!err) { - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (!err) - pci_using_dac =1 ; + pci_using_dac =1 ; }else { - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) { - err =dma_set_coherent_mask (&pdev->dev, -DMA_BIT_MASK (32 )); -if (err) { -dev_err (&pdev->dev, -"No usable DMA configuration, aborting\n" ); - goto err_dma; - } +dev_err (&pdev->dev, +"No usable DMA configuration, aborting\n" ); + goto err_dma; } }
Signature · 6 lines
1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 04/51] DMA-API: net: intel/igb: fix 32-bit DMA mask handling
Quoted 25 lines · Russell King
The fallback to 32-bit DMA mask is rather odd:
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); if (!err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); if (!err) pci_using_dac = 1; } else { err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { dev_err(&pdev->dev, "No usable DMA configuration, aborting\n"); goto err_dma; } } }This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if
dma_set_mask()succeeded, and to error out if either fails.
Quoted 4 lines
Signed-off-by Russell King <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-)
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 5/51 DMA-API: net: intel/igbvf: fix 32-bit DMA mask handling
In reply to a message not in the archiveThe fallback to 32-bit DMA mask is rather odd:
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err) {
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err)
pci_using_dac = 1;
} else {
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
err = dma_set_coherent_mask(&pdev->dev,
DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev, "No usable DMA "
"configuration, aborting\n");
goto err_dma;
}
}
}This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if dma_set_mask() succeeded, and to error out if either fails.
--- drivers/net/ethernet/intel/igbvf/netdev.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/igbvf/netdev.c +6 -12
@@ -2638,21 +2638,15 @@ static int igbvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return err; pci_using_dac =0 ; - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));if (!err) { - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (!err) - pci_using_dac =1 ; + pci_using_dac =1 ; }else { - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) { - err =dma_set_coherent_mask (&pdev->dev, -DMA_BIT_MASK (32 )); -if (err) { -dev_err (&pdev->dev,"No usable DMA " -"configuration, aborting\n" ); - goto err_dma; - } +dev_err (&pdev->dev,"No usable DMA " +"configuration, aborting\n" ); + goto err_dma; } }
Signature · 6 lines
1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 05/51] DMA-API: net: intel/igbvf: fix 32-bit DMA mask handling
Quoted 24 lines · Russell King
The fallback to 32-bit DMA mask is rather odd:
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); if (!err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); if (!err) pci_using_dac = 1; } else { err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { dev_err(&pdev->dev, "No usable DMA " "configuration, aborting\n"); goto err_dma; } } }This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if
dma_set_mask()succeeded, and to error out if either fails.
Quoted 4 lines
Signed-off-by Russell King <[email protected]>--- drivers/net/ethernet/intel/igbvf/netdev.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-)
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 8/51 DMA-API: net: intel/ixgbevf: fix 32-bit DMA mask handling
In reply to a message not in the archiveThe fallback to 32-bit DMA mask is rather odd:
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
!dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
pci_using_dac = 1;
} else {
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
err = dma_set_coherent_mask(&pdev->dev,
DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev, "No usable DMA "
"configuration, aborting\n");
goto err_dma;
}
}
pci_using_dac = 0;
}This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if dma_set_mask() succeeded, and to error out if either fails.
--- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +5 -10
@@ -3326,19 +3326,14 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (err)return err; -if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )) && - !dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { +if (!dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ))) { pci_using_dac =1 ; }else { - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) { - err =dma_set_coherent_mask (&pdev->dev, -DMA_BIT_MASK (32 )); -if (err) { -dev_err (&pdev->dev,"No usable DMA " -"configuration, aborting\n" ); - goto err_dma; - } +dev_err (&pdev->dev,"No usable DMA " +"configuration, aborting\n" ); + goto err_dma; } pci_using_dac =0 ; }
Signature · 6 lines
1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 08/51] DMA-API: net: intel/ixgbevf: fix 32-bit DMA mask handling
Quoted 22 lines · Russell King
The fallback to 32-bit DMA mask is rather odd:
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) { pci_using_dac = 1; } else { err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { dev_err(&pdev->dev, "No usable DMA " "configuration, aborting\n"); goto err_dma; } } pci_using_dac = 0; }This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if
dma_set_mask()succeeded, and to error out if either fails.
Quoted 5 lines
Signed-off-by Russell King <[email protected]>--- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-)
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
PATCH 9/51 DMA-API: net: broadcom/b44: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to a message not in the archiveReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/net/ethernet/broadcom/b44.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/b44.c +1 -2
@@ -2183,8 +2183,7 @@ static int b44_init_one(struct ssb_device *sdev, goto err_out_free_dev; } -if (dma_set_mask (sdev->dma_dev,DMA_BIT_MASK (30 )) || -dma_set_coherent_mask (sdev->dma_dev,DMA_BIT_MASK (30 ))) { +if (dma_set_mask_and_coherent (sdev->dma_dev,DMA_BIT_MASK (30 ))) {dev_err (sdev->dev,"Required 30BIT DMA mask unsupported by the system\n" ); goto err_out_powerdown;
Signature · 1 line
1.7.4.4
PATCH 11/51 DMA-API: net: emulex/benet: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to a message not in the archiveReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/net/ethernet/emulex/benet/be_main.c | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-)
drivers/net/ethernet/emulex/benet/be_main.c +2 -10
@@ -4335,19 +4335,11 @@ static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id) adapter->netdev = netdev;SET_NETDEV_DEV (netdev, &pdev->dev); - status =dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )); + status =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));if (!status) { - status =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (status <0 ) { -dev_err (&pdev->dev,"dma_set_coherent_mask failed\n" ); - goto free_netdev; - } netdev->features |=NETIF_F_HIGHDMA ; }else { - status =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (!status) - status =dma_set_coherent_mask (&pdev->dev, -DMA_BIT_MASK (32 )); + status =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (status) {dev_err (&pdev->dev,"Could not set PCI DMA Mask\n" ); goto free_netdev;
Signature · 1 line
1.7.4.4
PATCH 27/51 DMA-API: provide a helper to setup DMA masks
In reply to a message not in the archiveMany drivers contain code such as:
dev->dma_mask = &dev->coherent_dma_mask; dev->coherent_dma_mask = MASK;
Let's move this pattern out of drivers and have the DMA API provide a helper for it. This helper uses dma_set_mask_and_coherent() to allow platform issues to be properly dealt with via dma_set_mask()/ dma_is_supported().
--- include/linux/dma-mapping.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
include/linux/dma-mapping.h +10 -0
@@ -111,6 +111,16 @@ static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)return rc; } +/* +* Similar to the above, except it deals with the case where the device +* does not have dev->dma_mask appropriately setup. +*/ +static inline int dma_coerce_mask_and_coherent (struct device *dev,u64 mask) +{ + dev->dma_mask = &dev->coherent_dma_mask; +return dma_set_mask_and_coherent (dev, mask); +} +extern u64 dma_get_required_mask (struct device *dev);static inline unsigned int dma_get_max_seg_size (struct device *dev)
Signature · 1 line
1.7.4.4
PATCH 43/51 DMA-API: dma: edma.c: no need to explicitly initialize DMA masks
In reply to a message not in the archiveregister_platform_device_full() can setup the DMA mask provided the appropriate member is set in struct platform_device_info. So lets make that be the case. This avoids a direct reference to the DMA masks by this driver.
--- drivers/dma/edma.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/dma/edma.c +2 -4
@@ -702,11 +702,13 @@ static struct platform_device *pdev0, *pdev1;static const struct platform_device_info edma_dev_info0 = { .name ="edma-dma-engine" , .id =0 , + .dma_mask =DMA_BIT_MASK (32 ), };static const struct platform_device_info edma_dev_info1 = { .name ="edma-dma-engine" , .id =1 , + .dma_mask =DMA_BIT_MASK (32 ), };static int edma_init (void )
@@ -720,8 +722,6 @@ static int edma_init(void) ret =PTR_ERR (pdev0); goto out; } - pdev0->dev.dma_mask = &pdev0->dev.coherent_dma_mask; - pdev0->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); }if (EDMA_CTLRS ==2 ) {
@@ -731,8 +731,6 @@ static int edma_init(void)platform_device_unregister (pdev0); ret =PTR_ERR (pdev1); } - pdev1->dev.dma_mask = &pdev1->dev.coherent_dma_mask; - pdev1->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); } out:
Signature · 1 line
1.7.4.4
Re: [alsa-devel] [PATCH 43/51] DMA-API: dma: edma.c: no need to explicitly initialize DMA masks
Quoted 6 lines · Russell King
register_platform_device_full()can setup the DMA mask provided the appropriate member is set in structplatform_device_info. So lets make that be the case. This avoids a direct reference to the DMA masks by this driver.Signed-off-by Russell King <[email protected]>
This also brings me question that should we force the driver to use the dma_set_mask_and_coherent() API or they have below flexiblity too?
~Vinod
Quoted 49 lines
--- drivers/dma/edma.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)drivers/dma/edma.c +2
-0@@ -702,11 +702,13 @@ static struct platform_device *pdev0, *pdev1;static const struct platform_device_info edma_dev_info0 = { .name ="edma-dma-engine" , .id =0 , + .dma_mask =DMA_BIT_MASK (32 ), };static const struct platform_device_info edma_dev_info1 = { .name ="edma-dma-engine" , .id =1 , + .dma_mask =DMA_BIT_MASK (32 ), };static int
edma_init(void)drivers/dma/edma.c +0
-4@@ -720,8 +722,6 @@ static int edma_init(void) ret =PTR_ERR (pdev0); goto out; } - pdev0->dev.dma_mask = &pdev0->dev.coherent_dma_mask; - pdev0->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); }if (EDMA_CTLRS ==2 ) {@@ -731,8 +731,6 @@ static int edma_init(void)platform_device_unregister (pdev0); ret =PTR_ERR (pdev1); } - pdev1->dev.dma_mask = &pdev1->dev.coherent_dma_mask; - pdev1->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); } out:Signature · 6 lines
1.7.4.4 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [PATCH 43/51] DMA-API: dma: edma.c: no need to explicitly initialize DMA masks
Quoted 11 lines · Vinod Koul
Quoted 6 lines · Russell King
register_platform_device_full()can setup the DMA mask provided the appropriate member is set in structplatform_device_info. So lets make that be the case. This avoids a direct reference to the DMA masks by this driver.Signed-off-by Russell King <[email protected]>Acked-by Vinod Koul <[email protected]>This also brings me question that should we force the driver to use the
dma_set_mask_and_coherent()API or they have below flexiblity too?
There's two issues here:
1. dma_set_mask_and_coherent() will only work if dev->dma_mask points at some storage for the mask. This needs to have .dma_mask in the platform_device_info initialised.
2. Yes, this driver should also be calling the appropriate DMA mask setting functions in addition to having the mask initialized at device creation time.
Here's a replacement patch, though maybe it would be better to roll all the additions of dma_set_mask_and_coherent() in drivers/dma into one patch? In other words, combine the addition of this with these two patches:
dma: pl330: add dma_set_mask_and_coherent() call
dma: pl08x: add dma_set_mask_and_coherent() call
8<=====
From: Russell King <[email protected]>
Subject: [PATCH] DMA-API: dma: edma.c: no need to explicitly initialize DMA
masks
register_platform_device_full() can setup the DMA mask provided the appropriate member is set in struct platform_device_info. So lets make that be the case. This avoids a direct reference to the DMA masks by this driver.
While here, add the dma_set_mask_and_coherent() call which the DMA API requires DMA-using drivers to call.
--- drivers/dma/edma.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/dma/edma.c +6 -4
@@ -631,6 +631,10 @@ static int edma_probe(struct platform_device *pdev)struct edma_cc *ecc;int ret; + ret =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; + ecc =devm_kzalloc (&pdev->dev,sizeof (*ecc),GFP_KERNEL );if (!ecc) {dev_err (&pdev->dev,"Can't allocate controller\n" );
@@ -702,11 +706,13 @@ static struct platform_device *pdev0, *pdev1;static const struct platform_device_info edma_dev_info0 = { .name ="edma-dma-engine" , .id =0 , + .dma_mask =DMA_BIT_MASK (32 ), };static const struct platform_device_info edma_dev_info1 = { .name ="edma-dma-engine" , .id =1 , + .dma_mask =DMA_BIT_MASK (32 ), };static int edma_init (void )
@@ -720,8 +726,6 @@ static int edma_init(void) ret =PTR_ERR (pdev0); goto out; } - pdev0->dev.dma_mask = &pdev0->dev.coherent_dma_mask; - pdev0->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); }if (EDMA_CTLRS ==2 ) {
@@ -731,8 +735,6 @@ static int edma_init(void)platform_device_unregister (pdev0); ret =PTR_ERR (pdev1); } - pdev1->dev.dma_mask = &pdev1->dev.coherent_dma_mask; - pdev1->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); } out:
Signature · 1 line
1.7.4.4
PATCH 44/51 DMA-API: dcdbas: update DMA mask handing
In reply to a message not in the archivedcdbas was explicitly initializing DMA masks thusly:
dcdbas_pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); dcdbas_pdev->dev.dma_mask = &dcdbas_pdev->dev.coherent_dma_mask;
which bypasses the architecture check. Moreover, it is creating the dcdbas_pdev device itself, and using the platform_device_register_full() avoids some of this explicit initialization.
Convert the driver to use platform_device_register_full(), and as it makes use of coherent DMA, also call dma_set_coherent_mask() to ensure that the architecture gets to check the mask.
--- drivers/firmware/dcdbas.c | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-)
drivers/firmware/dcdbas.c +12 -11
@@ -549,8 +549,9 @@ static int dcdbas_probe(struct platform_device *dev)* BIOS SMI calls require buffer addresses be in 32-bit address space. * This is done by setting the DMA mask below. */ - dcdbas_pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); - dcdbas_pdev->dev.dma_mask = &dcdbas_pdev->dev.coherent_dma_mask; + error =dma_set_coherent_mask (&dcdbas_pdev->dev,DMA_BIT_MASK (32 )); +if (error) +return error; error =sysfs_create_group (&dev->dev.kobj, &dcdbas_attr_group);if (error)
@@ -581,6 +582,12 @@ static struct platform_driver dcdbas_driver = { .remove = dcdbas_remove, }; +static const struct platform_device_info dcdbas_dev_info__initdata = { + .name =DRIVER_NAME , + .id =-1 , + .dma_mask =DMA_BIT_MASK (32 ), +}; +/** * dcdbas_init: initialize driver */
@@ -592,20 +599,14 @@ static int __init dcdbas_init(void)if (error)return error; - dcdbas_pdev =platform_device_alloc (DRIVER_NAME ,-1 ); -if (!dcdbas_pdev) { - error = -ENOMEM ; + dcdbas_pdev =platform_device_register_full (&dcdbas_dev_info); +if (IS_ERR (dcdbas_pdev)) { + error =PTR_ERR (dcdbas_pdev); goto err_unregister_driver; } - error =platform_device_add (dcdbas_pdev); -if (error) - goto err_free_device; -return 0 ; - err_free_device: -platform_device_put (dcdbas_pdev); err_unregister_driver:platform_driver_unregister (&dcdbas_driver);return error;
Signature · 1 line
1.7.4.4
PATCH 6/51 DMA-API: net: intel/ixgb: fix 32-bit DMA mask handling
In reply to Russell King - ARM LinuxThe fallback to 32-bit DMA mask is rather odd:
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err) {
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err)
pci_using_dac = 1;
} else {
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
err = dma_set_coherent_mask(&pdev->dev,
DMA_BIT_MASK(32));
if (err) {
pr_err("No usable DMA configuration, aborting\n");
goto err_dma_mask;
}
}
}This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if dma_set_mask() succeeded, and to error out if either fails.
--- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ixgb/ixgb_main.c +5 -11
@@ -408,20 +408,14 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return err; pci_using_dac =0 ; - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));if (!err) { - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (!err) - pci_using_dac =1 ; + pci_using_dac =1 ; }else { - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) { - err =dma_set_coherent_mask (&pdev->dev, -DMA_BIT_MASK (32 )); -if (err) { -pr_err ("No usable DMA configuration, aborting\n" ); - goto err_dma_mask; - } +pr_err ("No usable DMA configuration, aborting\n" ); + goto err_dma_mask; } }
Signature · 1 line
1.7.4.4
Re: [PATCH 06/51] DMA-API: net: intel/ixgb: fix 32-bit DMA mask handling
Quoted 24 lines · Russell King
The fallback to 32-bit DMA mask is rather odd:
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); if (!err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); if (!err) pci_using_dac = 1; } else { err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { pr_err("No usable DMA configuration, aborting\n"); goto err_dma_mask; } } }This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if
dma_set_mask()succeeded, and to error out if either fails.
Quoted 4 lines
Signed-off-by Russell King <[email protected]>--- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-)
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 7/51 DMA-API: net: intel/ixgbe: fix 32-bit DMA mask handling
In reply to Russell King - ARM LinuxThe fallback to 32-bit DMA mask is rather odd:
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
!dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
pci_using_dac = 1;
} else {
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
err = dma_set_coherent_mask(&pdev->dev,
DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev,
"No usable DMA configuration, aborting\n");
goto err_dma;
}
}
pci_using_dac = 0;
}This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if dma_set_mask() succeeded, and to error out if either fails.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +5 -10
@@ -7475,19 +7475,14 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (err)return err; -if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )) && - !dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { +if (!dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ))) { pci_using_dac =1 ; }else { - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) { - err =dma_set_coherent_mask (&pdev->dev, -DMA_BIT_MASK (32 )); -if (err) { -dev_err (&pdev->dev, -"No usable DMA configuration, aborting\n" ); - goto err_dma; - } +dev_err (&pdev->dev, +"No usable DMA configuration, aborting\n" ); + goto err_dma; } pci_using_dac =0 ; }
Signature · 1 line
1.7.4.4
Re: [PATCH 07/51] DMA-API: net: intel/ixgbe: fix 32-bit DMA mask handling
Quoted 23 lines · Russell King
The fallback to 32-bit DMA mask is rather odd:
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) { pci_using_dac = 1; } else { err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { dev_err(&pdev->dev, "No usable DMA configuration, aborting\n"); goto err_dma; } } pci_using_dac = 0; }This means we only set the coherent DMA mask in the fallback path if the DMA mask set failed, which is silly. This fixes it to set the coherent DMA mask only if
dma_set_mask()succeeded, and to error out if either fails.
Quoted 4 lines
Signed-off-by Russell King <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-)
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 10/51 DMA-API: net: broadcom/bnx2x: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +2 -6
@@ -12072,13 +12072,9 @@ static int bnx2x_set_coherency_mask(struct bnx2x *bp) {struct device *dev = &bp->pdev->dev; -if (dma_set_mask (dev,DMA_BIT_MASK (64 )) ==0 ) { +if (dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 )) ==0 ) { bp->flags |=USING_DAC_FLAG ; -if (dma_set_coherent_mask (dev,DMA_BIT_MASK (64 )) !=0 ) { -dev_err (dev,"dma_set_coherent_mask failed, aborting\n" ); -return -EIO ; - } - }else if (dma_set_mask (dev,DMA_BIT_MASK (32 )) !=0 ) { + }else if (dma_set_mask_and_coherent (dev,DMA_BIT_MASK (32 )) !=0 ) {dev_err (dev,"System does not support DMA, aborting\n" );return -EIO ; }
Signature · 1 line
1.7.4.4
PATCH 12/51 DMA-API: net: intel/e1000: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/net/ethernet/intel/e1000/e1000_main.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_main.c +2 -7
@@ -1018,19 +1018,14 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)*/ pci_using_dac =0 ;if ((hw->bus_type == e1000_bus_type_pcix) && - !dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { -/* according to DMA-API-HOWTO, coherent calls will always -* succeed if the set call did -*/ -dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); + !dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ))) { pci_using_dac =1 ; }else { - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) {pr_err ("No usable DMA config, aborting\n" ); goto err_dma; } -dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); } netdev->netdev_ops = &e1000_netdev_ops;
Signature · 1 line
1.7.4.4
Re: [PATCH 12/51] DMA-API: net: intel/e1000: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Quoted 11 lines · Russell King
Replace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);with a call to the new helper
dma_set_mask_and_coherent().Signed-off-by Russell King <[email protected]>--- drivers/net/ethernet/intel/e1000/e1000_main.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
PATCH 13/51 DMA-API: net: sfc/efx.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/net/ethernet/sfc/efx.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-)
drivers/net/ethernet/sfc/efx.c +1 -11
@@ -1121,7 +1121,7 @@ static int efx_init_io(struct efx_nic *efx)*/ while (dma_mask >0x7fffffffUL ) {if (dma_supported (&pci_dev->dev, dma_mask)) { - rc =dma_set_mask (&pci_dev->dev, dma_mask); + rc =dma_set_mask_and_coherent (&pci_dev->dev, dma_mask);if (rc ==0 )break ; }
@@ -1134,16 +1134,6 @@ static int efx_init_io(struct efx_nic *efx) }netif_dbg (efx, probe, efx->net_dev,"using DMA mask %llx\n" , (unsigned long long ) dma_mask); - rc =dma_set_coherent_mask (&pci_dev->dev, dma_mask); -if (rc) { -/* dma_set_coherent_mask() is not *allowed* to -* fail with a mask that dma_set_mask() accepted, -* but just in case... -*/ -netif_err (efx, probe, efx->net_dev, -"failed to set consistent DMA mask\n" ); - goto fail2; - } efx->membase_phys =pci_resource_start (efx->pci_dev,EFX_MEM_BAR ); rc =pci_request_region (pci_dev,EFX_MEM_BAR ,"sfc" );
Signature · 1 line
1.7.4.4
Re: [PATCH 13/51] DMA-API: net: sfc/efx.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper
[Trimmed cc's]
Quoted 8 lines · Russell King
Replace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);with a call to the new helper
dma_set_mask_and_coherent().Signed-off-by Russell King <[email protected]>
Quoted 34 lines
--- drivers/net/ethernet/sfc/efx.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-)drivers/net/ethernet/sfc/efx.c +1
-11@@ -1121,7 +1121,7 @@ static int efx_init_io(struct efx_nic *efx)*/ while (dma_mask >0x7fffffffUL ) {if (dma_supported (&pci_dev->dev, dma_mask)) { - rc =dma_set_mask (&pci_dev->dev, dma_mask); + rc =dma_set_mask_and_coherent (&pci_dev->dev, dma_mask);if (rc ==0 )break ; }@@ -1134,16 +1134,6 @@ static int efx_init_io(struct efx_nic *efx) }netif_dbg (efx, probe, efx->net_dev,"using DMA mask %llx\n" , (unsigned long long ) dma_mask); - rc =dma_set_coherent_mask (&pci_dev->dev, dma_mask); -if (rc) { -/* dma_set_coherent_mask() is not *allowed* to -* fail with a mask that dma_set_mask() accepted, -* but just in case... -*/ -netif_err (efx, probe, efx->net_dev, -"failed to set consistent DMA mask\n" ); - goto fail2; - } efx->membase_phys =pci_resource_start (efx->pci_dev,EFX_MEM_BAR ); rc =pci_request_region (pci_dev,EFX_MEM_BAR ,"sfc" );
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Re: [PATCH 13/51] DMA-API: net: sfc/efx.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Quoted 1 line · Ben Hutchings
Acked-by Ben Hutchings <[email protected]>
Thanks, added.
PATCH 14/51 DMA-API: net: b43: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/net/wireless/b43/dma.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/wireless/b43/dma.c +3 -6
@@ -1065,12 +1065,9 @@ static int b43_dma_set_mask(struct b43_wldev *dev, u64 mask)/* Try to set the DMA mask. If it fails, try falling back to a * lower mask, as we can always also support a lower one. */ while (1 ) { - err =dma_set_mask (dev->dev->dma_dev, mask); -if (!err) { - err =dma_set_coherent_mask (dev->dev->dma_dev, mask); -if (!err) -break ; - } + err =dma_set_mask_and_coherent (dev->dev->dma_dev, mask); +if (!err) +break ;if (mask ==DMA_BIT_MASK (64 )) { mask =DMA_BIT_MASK (32 ); fallback = true;
Signature · 1 line
1.7.4.4
PATCH 15/51 DMA-API: net: b43legacy: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/net/wireless/b43legacy/dma.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/wireless/b43legacy/dma.c +3 -6
@@ -806,12 +806,9 @@ static int b43legacy_dma_set_mask(struct b43legacy_wldev *dev, u64 mask)/* Try to set the DMA mask. If it fails, try falling back to a * lower mask, as we can always also support a lower one. */ while (1 ) { - err =dma_set_mask (dev->dev->dma_dev, mask); -if (!err) { - err =dma_set_coherent_mask (dev->dev->dma_dev, mask); -if (!err) -break ; - } + err =dma_set_mask_and_coherent (dev->dev->dma_dev, mask); +if (!err) +break ;if (mask ==DMA_BIT_MASK (64 )) { mask =DMA_BIT_MASK (32 ); fallback = true;
Signature · 1 line
1.7.4.4
PATCH 16/51 DMA-API: ppc: vio.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- arch/powerpc/kernel/vio.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
arch/powerpc/kernel/vio.c +1 -2
@@ -1413,8 +1413,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)/* needed to ensure proper operation of coherent allocations * later, in case driver doesn't set it explicitly */ -dma_set_mask (&viodev->dev,DMA_BIT_MASK (64 )); -dma_set_coherent_mask (&viodev->dev,DMA_BIT_MASK (64 )); +dma_set_mask_and_coherent (&viodev->dev,DMA_BIT_MASK (64 )); }/* register with generic device framework */
Signature · 1 line
1.7.4.4
Re: [PATCH 16/51] DMA-API: ppc: vio.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Hi,
Quoted 18 lines · Russell King
Replace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);with a call to the new helper
dma_set_mask_and_coherent().Signed-off-by Russell King <[email protected]>--- arch/powerpc/kernel/vio.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)arch/powerpc/kernel/vio.c +0
-0
arch/powerpc/kernel/vio.c struct vio_dev *vio_register_device_node(struct device_node *of_node) · line 1419
Quoted 9 lines
arch/powerpc/kernel/vio.c +1
-2@@ -1413,8 +1413,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)/* needed to ensure proper operation of coherent allocations * later, in case driver doesn't set it explicitly */ -dma_set_mask (&viodev->dev,DMA_BIT_MASK (64 )); -dma_set_coherent_mask (&viodev->dev,DMA_BIT_MASK (64 )); +dma_set_mask_and_coherent (&viodev->dev,DMA_BIT_MASK (64 )); }/* register with generic device framework */
The new helper routine dma_set_mask_and_coherent() breaks the initialization of the pseries vio devices which do not have an initial dev->dma_mask. I think we need to use dma_coerce_mask_and_coherent() instead.
--- arch/powerpc/kernel/vio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/vio.c +1 -1
@@ -1419,7 +1419,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)/* needed to ensure proper operation of coherent allocations * later, in case driver doesn't set it explicitly */ -dma_set_mask_and_coherent (&viodev->dev,DMA_BIT_MASK (64 )); +dma_coerce_mask_and_coherent (&viodev->dev,DMA_BIT_MASK (64 )); }/* register with generic device framework */
Signature · 1 line
1.7.10.4
Re: [PATCH 16/51] DMA-API: ppc: vio.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Quoted 4 lines · Cedric Le Goater
The new helper routine
dma_set_mask_and_coherent()breaks the initialization of the pseries vio devices which do not have an initialdev->dma_mask. I think we need to usedma_coerce_mask_and_coherent()instead.
Who wants to handle this patch?
Also, is it possible to fix it so that dev->dma_mask is correctly setup by the code which creates the device, as it should be in the first place?
Thanks
Quoted 27 lines
Signed-off-by Cédric Le Goater <[email protected]>--- arch/powerpc/kernel/vio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/kernel/vio.c +1
-1@@ -1419,7 +1419,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)/* needed to ensure proper operation of coherent allocations * later, in case driver doesn't set it explicitly */ -dma_set_mask_and_coherent (&viodev->dev,DMA_BIT_MASK (64 )); +dma_coerce_mask_and_coherent (&viodev->dev,DMA_BIT_MASK (64 )); }/* register with generic device framework */ Signature · 8 lines
1.7.10.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 16/51] DMA-API: ppc: vio.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Quoted 10 lines · Russell King - ARM Linux
Quoted 4 lines · Cedric Le Goater
The new helper routine
dma_set_mask_and_coherent()breaks the initialization of the pseries vio devices which do not have an initialdev->dma_mask. I think we need to usedma_coerce_mask_and_coherent()instead.Who wants to handle this patch?
Also, is it possible to fix it so that
dev->dma_maskis correctly setup by the code which creates the device, as it should be in the first place?
The vio_dev should probably be improved to setup devices as the other drivers do but we might be short on time to do that for 3.13 and pseries is really broken ... For now, I will just resend the patch with some context in the changelog.
Thanks,
C.
PATCH 1/1 DMA-API: ppc: vio: use dma_coerce_mask_and_coherent()
In reply to Russell King - ARM LinuxCommit 4886c399da70d5f8a4016c2213850dce6cac88c5 (DMA-API: ppc: vio.c:
replace dma_set_mask()+dma_set_coherent_mask() with new helper) introduced the usage of the new helper routine dma_set_mask_and_coherent(). This breaks the initialization of the pseries vio devices which do not setup an initial dev->dma_mask for the device.
---
arch/powerpc/kernel/vio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/vio.c +1 -1
@@ -1419,7 +1419,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)/* needed to ensure proper operation of coherent allocations * later, in case driver doesn't set it explicitly */ -dma_set_mask_and_coherent (&viodev->dev,DMA_BIT_MASK (64 )); +dma_coerce_mask_and_coherent (&viodev->dev,DMA_BIT_MASK (64 )); }/* register with generic device framework */
Signature · 1 line
1.7.10.4
PATCH 17/51 DMA-API: block: nvme-core: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/block/nvme-core.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/block/nvme-core.c +4 -6
@@ -1949,12 +1949,9 @@ static int nvme_dev_map(struct nvme_dev *dev)if (pci_request_selected_regions (pdev, bars,"nvme" )) goto disable_pci; -if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) -dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -else if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 ))) -dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -else - goto disable_pci; +if (dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )) && +dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ))) + goto disable;pci_set_drvdata (pdev, dev); dev->bar =ioremap (pci_resource_start (pdev,0 ),8192 );
@@ -2168,6 +2165,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)INIT_LIST_HEAD (&dev->namespaces); dev->pci_dev = pdev; + result =nvme_set_instance (dev);if (result) goto free;
Signature · 1 line
1.7.4.4
PATCH 18/51 DMA-API: staging: et131x: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/staging/et131x/et131x.c | 17 ++--------------- 1 files changed, 2 insertions(+), 15 deletions(-)
drivers/staging/et131x/et131x.c +2 -15
@@ -4797,21 +4797,8 @@ static int et131x_pci_setup(struct pci_dev *pdev,pci_set_master (pdev);/* Check the DMA addressing support of this device */ -if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (rc <0 ) { -dev_err (&pdev->dev, -"Unable to obtain 64 bit DMA for consistent allocations\n" ); - goto err_release_res; - } - }else if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc <0 ) { -dev_err (&pdev->dev, -"Unable to obtain 32 bit DMA for consistent allocations\n" ); - goto err_release_res; - } - }else { +if (dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )) || +dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ))) {dev_err (&pdev->dev,"No usable DMA addressing method\n" ); rc = -EIO ; goto err_release_res;
Signature · 1 line
1.7.4.4
Re: [PATCH 18/51] DMA-API: staging: et131x: replace dma_set_mask()+dma_set_coherent_mask() with new helper
[Trimmed cc's]
Quoted 27 lines · Russell King
Replace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);with a call to the new helper
dma_set_mask_and_coherent().Signed-off-by Russell King <[email protected]>--- drivers/staging/et131x/et131x.c | 17 ++--------------- 1 files changed, 2 insertions(+), 15 deletions(-)drivers/staging/et131x/et131x.c +0
-7@@ -4797,21 +4797,8 @@ static int et131x_pci_setup(struct pci_dev *pdev,pci_set_master (pdev);/* Check the DMA addressing support of this device */ -if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (rc <0 ) { -dev_err (&pdev->dev, -"Unable to obtain 64 bit DMA for consistent allocations\n" ); - goto err_release_res; - }
drivers/staging/et131x/et131x.c static int et131x_pci_setup(struct pci_dev *pdev, · line 4801
Quoted 10 lines
drivers/staging/et131x/et131x.c +2
-8- }else if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc <0 ) { -dev_err (&pdev->dev, -"Unable to obtain 32 bit DMA for consistent allocations\n" ); - goto err_release_res; - } - }else { +if (dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )) || +dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ))) {
Surely we want && here.
Ben.
Quoted 3 lines
drivers/staging/et131x/et131x.c +0
-0dev_err (&pdev->dev,"No usable DMA addressing method\n" ); rc = -EIO ; goto err_release_res;
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Re: [PATCH 18/51] DMA-API: staging: et131x: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Quoted 5 lines · Ben Hutchings
Review
Quoted 2 lines · Russell King
(quoted diff) +2
-0+ if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) || + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {Surely we want && here.
Good catch, exactly right. Thanks for the review, here's the replacement patch:
8<====
From: Russell King <[email protected]>
Subject: [PATCH] DMA-API: staging: et131x: replace
dma_set_mask()+dma_set_coherent_mask() with new helper
Replace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/staging/et131x/et131x.c | 17 ++--------------- 1 files changed, 2 insertions(+), 15 deletions(-)
drivers/staging/et131x/et131x.c +2 -15
@@ -4797,21 +4797,8 @@ static int et131x_pci_setup(struct pci_dev *pdev,pci_set_master (pdev);/* Check the DMA addressing support of this device */ -if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (rc <0 ) { -dev_err (&pdev->dev, -"Unable to obtain 64 bit DMA for consistent allocations\n" ); - goto err_release_res; - } - }else if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc <0 ) { -dev_err (&pdev->dev, -"Unable to obtain 32 bit DMA for consistent allocations\n" ); - goto err_release_res; - } - }else { +if (dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )) && +dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ))) {dev_err (&pdev->dev,"No usable DMA addressing method\n" ); rc = -EIO ; goto err_release_res;
Signature · 1 line
1.7.4.4
Mark Einon
Acked-byRe: [PATCH 18/51] DMA-API: staging: et131x: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Quoted 20 lines · Russell King - ARM Linux
Quoted 5 lines · Ben Hutchings
Review
Quoted 2 lines · Russell King
(quoted diff) +2
-0+ if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) || + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {Surely we want && here.
Good catch, exactly right. Thanks for the review, here's the replacement patch:
8<====
From: Russell King <[email protected]>
Subject: [PATCH] DMA-API: staging: et131x: replace
dma_set_mask()+dma_set_coherent_mask() with new helperReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
Quoted 6 lines
with a call to the new helper
dma_set_mask_and_coherent().Signed-off-by Russell King <[email protected]>--- drivers/staging/et131x/et131x.c | 17 ++--------------- 1 files changed, 2 insertions(+), 15 deletions(-)
Cheers,
Mark
PATCH 19/51 DMA-API: media: dt3155v4l: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/staging/media/dt3155v4l/dt3155v4l.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/staging/media/dt3155v4l/dt3155v4l.c +1 -4
@@ -901,10 +901,7 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)int err;struct dt3155_priv *pd; - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (err) -return -ENODEV ; - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err)return -ENODEV ; pd =kzalloc (sizeof (*pd),GFP_KERNEL );
Signature · 1 line
1.7.4.4
Re: [PATCH 19/51] DMA-API: media: dt3155v4l: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Quoted 8 lines · Russell King
Replace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);with a call to the new helper
dma_set_mask_and_coherent().Signed-off-by Russell King <[email protected]>
Regards,
Hans
Quoted 21 lines
--- drivers/staging/media/dt3155v4l/dt3155v4l.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)drivers/staging/media/dt3155v4l/dt3155v4l.c +1
-4@@ -901,10 +901,7 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)int err;struct dt3155_priv *pd; - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (err) -return -ENODEV ; - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err)return -ENODEV ; pd =kzalloc (sizeof (*pd),GFP_KERNEL );
A message that is not in the archive (sent off-list or not yet received): 5249673B.5020705-qWit8jRvyhVmR6Xm/[email protected]
Mauro Carvalho Chehab
Acked-byRe: [PATCH 19/51] DMA-API: media: dt3155v4l: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Hi Russell,
Em Mon, 30 Sep 2013 13:57:47 +0200
Hans Verkuil <hverkuil-qWit8jRvyhVmR6Xm/[email protected]> escreveu:
Quoted 11 lines · Russell King
Quoted 8 lines
Replace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);with a call to the new helper
dma_set_mask_and_coherent().Signed-off-by Russell King <rmk+kernel-lFZ/[email protected]>Acked-by Hans Verkuil <[email protected]>
Somehow, I lost your original post (I got unsubscribed on a few days from all vger mailing lists at the end of september).
I suspect that you want to sent this via your tree, right? If so:
Quoted 31 lines
Regards,
Hans
Quoted 11 lines
--- drivers/staging/media/dt3155v4l/dt3155v4l.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)drivers/staging/media/dt3155v4l/dt3155v4l.c +0
-0@@ -901,10 +901,7 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)int err;drivers/staging/media/dt3155v4l/dt3155v4l.c dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 907
Quoted 10 lines
drivers/staging/media/dt3155v4l/dt3155v4l.c +1
-4struct dt3155_priv *pd; - err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (err) -return -ENODEV ; - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err)return -ENODEV ; pd =kzalloc (sizeof (*pd),GFP_KERNEL );--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 6 lines
Cheers, Mauro -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 19/51] DMA-API: media: dt3155v4l: replace dma_set_mask()+dma_set_coherent_mask() with new helper
Quoted 13 lines · Mauro Carvalho Chehab
Hi Russell,
Em Mon, 30 Sep 2013 13:57:47 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 8 lines · Russell King
Quoted 7 lines
Replace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);with a call to the new helper
dma_set_mask_and_coherent().
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Russell King <[email protected]>Acked-by Hans Verkuil <[email protected]>Somehow, I lost your original post (I got unsubscribed on a few days from all vger mailing lists at the end of september).
I suspect that you want to sent this via your tree, right?
Yes please.
Quoted 3 lines
If so:
Added, thanks.
Quoted 7 lines
Quoted 7 lines
drivers/staging/media/dt3155v4l/dt3155v4l.c dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 906
Quoted 7 lines
drivers/staging/media/dt3155v4l/dt3155v4l.c +1
-4- err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (err) -return -ENODEV ; - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err)return -ENODEV ;
One thing I've just noticed is that return should be "return err" not "return -ENODEV" - are you okay for me to change that in this patch?
Thanks.
PATCH 20/51 DMA-API: usb: bcma: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/usb/host/bcma-hcd.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/usb/host/bcma-hcd.c +1 -2
@@ -227,8 +227,7 @@ static int bcma_hcd_probe(struct bcma_device *dev)/* TODO: Probably need checks here; is the core connected? */ -if (dma_set_mask (dev->dma_dev,DMA_BIT_MASK (32 )) || -dma_set_coherent_mask (dev->dma_dev,DMA_BIT_MASK (32 ))) +if (dma_set_mask_and_coherent (dev->dma_dev,DMA_BIT_MASK (32 )))return -EOPNOTSUPP ; usb_dev =kzalloc (sizeof (struct bcma_hcd_device ),GFP_KERNEL );
Signature · 1 line
1.7.4.4
PATCH 21/51 DMA-API: usb: ssb-hcd: replace dma_set_mask()+dma_set_coherent_mask() with new helper
In reply to Russell King - ARM LinuxReplace the following sequence:
dma_set_mask(dev, mask); dma_set_coherent_mask(dev, mask);
with a call to the new helper dma_set_mask_and_coherent().
--- drivers/usb/host/ssb-hcd.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/usb/host/ssb-hcd.c +1 -2
@@ -163,8 +163,7 @@ static int ssb_hcd_probe(struct ssb_device *dev,/* TODO: Probably need checks here; is the core connected? */ -if (dma_set_mask (dev->dma_dev,DMA_BIT_MASK (32 )) || -dma_set_coherent_mask (dev->dma_dev,DMA_BIT_MASK (32 ))) +if (dma_set_mask_and_coherent (dev->dma_dev,DMA_BIT_MASK (32 )))return -EOPNOTSUPP ; usb_dev =kzalloc (sizeof (struct ssb_hcd_device ),GFP_KERNEL );
Signature · 1 line
1.7.4.4
PATCH 22/51 DMA-API: amba: get rid of separate dma_mask
In reply to Russell King - ARM LinuxAMBA Primecell devices always treat streaming and coherent DMA exactly the same, so there's no point in having the masks separated.
--- drivers/amba/bus.c | 6 +----- drivers/of/platform.c | 3 --- include/linux/amba/bus.h | 2 -- 3 files changed, 1 insertions(+), 10 deletions(-)
drivers/amba/bus.c +1 -5
@@ -552,7 +552,6 @@ amba_aphb_device_add(struct device *parent, const char *name,if (!dev)return ERR_PTR (-ENOMEM ); - dev->dma_mask = dma_mask; dev->dev.coherent_dma_mask = dma_mask; dev->irq[0 ] = irq1; dev->irq[1 ] = irq2;
@@ -619,7 +618,7 @@ static void amba_device_initialize(struct amba_device *dev, const char *name)dev_set_name (&dev->dev,"%s" , name); dev->dev.release = amba_device_release; dev->dev.bus = &amba_bustype; - dev->dev.dma_mask = &dev->dma_mask; + dev->dev.dma_mask = &dev->dev.coherent_dma_mask; dev->res.name =dev_name (&dev->dev); }
@@ -663,9 +662,6 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)amba_device_initialize (dev, dev->dev.init_name); dev->dev.init_name =NULL ; -if (!dev->dev.coherent_dma_mask && dev->dma_mask) -dev_warn (&dev->dev,"coherent dma mask is unset\n" ); -return amba_device_add (dev, parent); }
drivers/of/platform.c +0 -3
@@ -284,9 +284,6 @@ static struct amba_device *of_amba_device_create(struct device_node *node,else of_device_make_bus_id (&dev->dev); -/* setup amba-specific device info */ - dev->dma_mask = ~0 ; -/* Allow the HW Peripheral ID to be overridden */ prop =of_get_property (node,"arm,primecell-periphid" ,NULL );if (prop)
include/linux/amba/bus.h +0 -2
@@ -30,7 +30,6 @@ struct amba_device {struct device dev;struct resource res;struct clk *pclk; -u64 dma_mask;unsigned int periphid;unsigned int irq[AMBA_NR_IRQS ]; };
@@ -131,7 +130,6 @@ struct amba_device name##_device = { \ struct amba_device name##_device = { \ .dev =__AMBA_DEV (busid, data, ~0ULL ), \ .res =DEFINE_RES_MEM (base,SZ_4K ), \ - .dma_mask = ~0ULL , \ .irq = irqs, \ .periphid = id, \ }
Signature · 1 line
1.7.4.4
Re: [PATCH 22/51] DMA-API: amba: get rid of separate dma_mask
Quoted 4 lines · Russell King
AMBA Primecell devices always treat streaming and coherent DMA exactly the same, so there's no point in having the masks separated.
Signed-off-by Russell King <[email protected]>
for the drivers/of/platform.c portion:
g.
PATCH 23/51 DMA-API: dma: pl08x: add dma_set_mask_and_coherent() call
In reply to Russell King - ARM LinuxThe DMA API requires drivers to call the appropriate dma_set_mask() functions before doing any DMA mapping. Add this required call to the AMBA PL08x driver.
--- drivers/dma/amba-pl08x.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/dma/amba-pl08x.c +5 -0
@@ -2055,6 +2055,11 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)if (ret)return ret; +/* Ensure that we can do DMA */ + ret =dma_set_mask_and_coherent (&adev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto out_no_pl08x; +/* Create the driver state holder */ pl08x =kzalloc (sizeof (*pl08x),GFP_KERNEL );if (!pl08x) {
Signature · 1 line
1.7.4.4
A message that is not in the archive (sent off-list or not yet received): E1VMm4v-0007hz-RC-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org
Vinod Koul
Acked-byRe: [alsa-devel] [PATCH 23/51] DMA-API: dma: pl08x: add dma_set_mask_and_coherent() call
Quoted 5 lines · Russell King
The DMA API requires drivers to call the appropriate
dma_set_mask()functions before doing any DMA mapping. Add this required call to the AMBA PL08x driver.Signed-off-by Russell King <rmk+kernel-lFZ/[email protected]>
~Vinod
Quoted 27 lines
--- drivers/dma/amba-pl08x.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)drivers/dma/amba-pl08x.c +5
-0@@ -2055,6 +2055,11 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)if (ret)return ret; +/* Ensure that we can do DMA */ + ret =dma_set_mask_and_coherent (&adev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto out_no_pl08x; +/* Create the driver state holder */ pl08x =kzalloc (sizeof (*pl08x),GFP_KERNEL );if (!pl08x) {Signature · 6 lines
1.7.4.4 _______________________________________________ Alsa-devel mailing list Alsa-devel-K7yf7f+aM1XWsZ/[email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Signature · 4 lines
-- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 24/51 DMA-API: dma: pl330: add dma_set_mask_and_coherent() call
In reply to Russell King - ARM LinuxThe DMA API requires drivers to call the appropriate dma_set_mask() functions before doing any DMA mapping. Add this required call to the AMBA PL08x driver.
--- drivers/dma/pl330.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/dma/pl330.c +4 -0
@@ -2903,6 +2903,10 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) pdat =dev_get_platdata (&adev->dev); + ret =dma_set_mask_and_coherent (&adev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; +/* Allocate a new DMAC and its Channels */ pdmac =devm_kzalloc (&adev->dev,sizeof (*pdmac),GFP_KERNEL );if (!pdmac) {
Signature · 1 line
1.7.4.4
A message that is not in the archive (sent off-list or not yet received): E1VMm5t-0007i5-V7-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org
Re: [PATCH 24/51] DMA-API: dma: pl330: add dma_set_mask_and_coherent() call
Am Donnerstag, 19. September 2013, 23:49:01 schrieb Russell King:
Quoted 3 lines
The DMA API requires drivers to call the appropriate
dma_set_mask()functions before doing any DMA mapping. Add this required call to the AMBA PL08x driver.
^--- copy and paste error - should of course be PL330
Quoted 21 lines
Signed-off-by Russell King <rmk+kernel-lFZ/[email protected]>--- drivers/dma/pl330.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)drivers/dma/pl330.c +4
-0@@ -2903,6 +2903,10 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) pdat =dev_get_platdata (&adev->dev); + ret =dma_set_mask_and_coherent (&adev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; +/* Allocate a new DMAC and its Channels */ pdmac =devm_kzalloc (&adev->dev,sizeof (*pdmac),GFP_KERNEL );if (!pdmac) {
Re: [PATCH 24/51] DMA-API: dma: pl330: add dma_set_mask_and_coherent() call
Quoted 5 lines · Heiko St?bner
Am Donnerstag, 19. September 2013, 23:49:01 schrieb Russell King:
Quoted 3 lines
The DMA API requires drivers to call the appropriate
dma_set_mask()functions before doing any DMA mapping. Add this required call to the AMBA PL08x driver.^--- copy and paste error - should of course be PL330
Fixed, thanks.
Vinod Koul
Acked-byRe: [alsa-devel] [PATCH 24/51] DMA-API: dma: pl330: add dma_set_mask_and_coherent() call
Quoted 8 lines · Russell King - ARM Linux
Quoted 5 lines · Heiko Stübner
Am Donnerstag, 19. September 2013, 23:49:01 schrieb Russell King:
Quoted 3 lines
The DMA API requires drivers to call the appropriate
dma_set_mask()functions before doing any DMA mapping. Add this required call to the AMBA PL08x driver.^--- copy and paste error - should of course be PL330
Fixed, thanks.
with fixed changelog...
~Vinod
PATCH 25/51 DMA-API: video: clcd: add dma_set_mask_and_coherent() call
In reply to Russell King - ARM LinuxThe DMA API requires drivers to call the appropriate dma_set_mask() functions before doing any DMA mapping. Add this required call to the AMBA PL08x driver.
--- drivers/video/amba-clcd.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/video/amba-clcd.c +5 -0
@@ -10,6 +10,7 @@* * ARM PrimeCell PL110 Color LCD Controller */ +#include <linux/dma-mapping.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h>
@@ -551,6 +552,10 @@ static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id)if (!board)return -EINVAL ; + ret =dma_set_mask_and_coherent (&dev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto out; + ret =amba_request_regions (dev,NULL );if (ret) {printk (KERN_ERR "CLCD: unable to reserve regs region\n" );
Signature · 1 line
1.7.4.4
PATCH 26/51 DMA-API: usb: ohci-sa1111: add a note about DMA masks
In reply to Russell King - ARM LinuxAdd a comment to explain why this driver doesn't call any of the DMA API dma_set_mask() functions.
--- drivers/usb/host/ohci-sa1111.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/usb/host/ohci-sa1111.c +6 -0
@@ -185,6 +185,12 @@ static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev)if (usb_disabled ())return -ENODEV ; +/* +* We don't call dma_set_mask_and_coherent() here because the +* DMA mask has already been appropraitely setup by the core +* SA-1111 bus code (which includes bug workarounds.) +*/ + hcd =usb_create_hcd (&ohci_sa1111_hc_driver, &dev->dev,"sa1111" );if (!hcd)return -ENOMEM ;
Signature · 1 line
1.7.4.4
PATCH 28/51 DMA-API: sound: fix dma mask handling in a lot of drivers
In reply to Russell King - ARM LinuxThis code sequence is unsafe in modules:
static u64 mask = DMA_BIT_MASK(something);
...
if (!dev->dma_mask) dev->dma_mask = &mask;
as if a module is reloaded, the mask will be pointing at the original module's mask address, and this can lead to oopses. Moreover, they all follow this with:
if (!dev->coherent_dma_mask) dev->coherent_dma_mask = mask;
where 'mask' is the same value as the statically defined mask, and this bypasses the architecture's check on whether the DMA mask is possible.
Fix these issues by using the new dma_coerce_coherent_and_mask() function.
--- sound/arm/pxa2xx-pcm.c | 9 +++------ sound/soc/atmel/atmel-pcm.c | 11 ++++------- sound/soc/blackfin/bf5xx-ac97-pcm.c | 11 ++++------- sound/soc/blackfin/bf5xx-i2s-pcm.c | 10 ++++------ sound/soc/davinci/davinci-pcm.c | 9 +++------ sound/soc/fsl/fsl_dma.c | 9 +++------ sound/soc/fsl/mpc5200_dma.c | 10 ++++------ sound/soc/jz4740/jz4740-pcm.c | 12 ++++-------- sound/soc/kirkwood/kirkwood-dma.c | 9 +++------ sound/soc/nuc900/nuc900-pcm.c | 9 ++++----- sound/soc/omap/omap-pcm.c | 11 ++++------- sound/soc/pxa/pxa2xx-pcm.c | 11 ++++------- sound/soc/s6000/s6000-pcm.c | 9 +++------ sound/soc/samsung/dma.c | 11 ++++------- sound/soc/samsung/idma.c | 11 ++++------- 15 files changed, 55 insertions(+), 97 deletions(-)
sound/arm/pxa2xx-pcm.c +3 -6
@@ -83,8 +83,6 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = { .mmap = pxa2xx_pcm_mmap, }; -static u64 pxa2xx_pcm_dmamask =0xffffffff ; -int pxa2xx_pcm_new (struct snd_card *card,struct pxa2xx_pcm_client *client,struct snd_pcm **rpcm) {
@@ -100,10 +98,9 @@ int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client, pcm->private_data = client; pcm->private_free = pxa2xx_pcm_free_dma_buffers; -if (!card->dev->dma_mask) - card->dev->dma_mask = &pxa2xx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =0xffffffff ; + ret =dma_coerce_mask_and_coherent_mask (card->dev,DMA_BIT_MASK (32 )); +if (ret) + goto out;if (play) {int stream =SNDRV_PCM_STREAM_PLAYBACK ;
sound/soc/atmel/atmel-pcm.c +4 -7
@@ -68,18 +68,15 @@ int atmel_pcm_mmap(struct snd_pcm_substream *substream, }EXPORT_SYMBOL_GPL (atmel_pcm_mmap); -static u64 atmel_pcm_dmamask =DMA_BIT_MASK (32 ); -int atmel_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &atmel_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) {pr_debug ("atmel-pcm: allocating PCM playback DMA buffer\n" );
sound/soc/blackfin/bf5xx-ac97-pcm.c +4 -7
@@ -415,19 +415,16 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm) } } -static u64 bf5xx_pcm_dmamask =DMA_BIT_MASK (32 ); -static int bf5xx_pcm_ac97_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret;pr_debug ("%s enter\n" , __func__); -if (!card->dev->dma_mask) - card->dev->dma_mask = &bf5xx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
sound/soc/blackfin/bf5xx-i2s-pcm.c +4 -6
@@ -323,18 +323,16 @@ static struct snd_pcm_ops bf5xx_pcm_i2s_ops = { .silence = bf5xx_pcm_silence, }; -static u64 bf5xx_pcm_dmamask =DMA_BIT_MASK (32 ); -static int bf5xx_pcm_i2s_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;size_t size = bf5xx_pcm_hardware.buffer_bytes_max; +int ret;pr_debug ("%s enter\n" , __func__); -if (!card->dev->dma_mask) - card->dev->dma_mask = &bf5xx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;return snd_pcm_lib_preallocate_pages_for_all (rtd->pcm,SNDRV_DMA_TYPE_DEV , card->dev, size, size);
sound/soc/davinci/davinci-pcm.c +3 -6
@@ -844,18 +844,15 @@ static void davinci_pcm_free(struct snd_pcm *pcm) } } -static u64 davinci_pcm_dmamask =DMA_BIT_MASK (32 ); -static int davinci_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm;int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &davinci_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = davinci_pcm_preallocate_dma_buffer(pcm,
sound/soc/fsl/fsl_dma.c +3 -6
@@ -298,14 +298,11 @@ static int fsl_dma_new(struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -static u64 fsl_dma_dmamask =DMA_BIT_MASK (36 );int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &fsl_dma_dmamask; - -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = fsl_dma_dmamask; + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (36 )); +if (ret) +return ret;/* Some codecs have separate DAIs for playback and capture, so we * should allocate a DMA buffer only for the streams that are valid.
sound/soc/fsl/mpc5200_dma.c +4 -6
@@ -299,7 +299,6 @@ static struct snd_pcm_ops psc_dma_ops = { .hw_params = psc_dma_hw_params, }; -static u64 psc_dma_dmamask =DMA_BIT_MASK (32 );static int psc_dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;
@@ -307,15 +306,14 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)struct snd_pcm *pcm = rtd->pcm;struct psc_dma *psc_dma =snd_soc_dai_get_drvdata (rtd->cpu_dai);size_t size = psc_dma_hardware.buffer_bytes_max; -int rc =0 ; +int rc;dev_dbg (rtd->platform->dev,"psc_dma_new(card=%p, dai=%p, pcm=%p)\n" , card, dai, pcm); -if (!card->dev->dma_mask) - card->dev->dma_mask = &psc_dma_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + rc =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (rc) +return rc;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev,
sound/soc/jz4740/jz4740-pcm.c +4 -8
@@ -297,19 +297,15 @@ static void jz4740_pcm_free(struct snd_pcm *pcm) } } -static u64 jz4740_pcm_dmamask =DMA_BIT_MASK (32 ); -static int jz4740_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; - -if (!card->dev->dma_mask) - card->dev->dma_mask = &jz4740_pcm_dmamask; +int ret; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = jz4740_pcm_preallocate_dma_buffer(pcm,
sound/soc/kirkwood/kirkwood-dma.c +3 -6
@@ -59,8 +59,6 @@ static struct snd_pcm_hardware kirkwood_dma_snd_hw = { .fifo_size = 0, }; -static u64 kirkwood_dma_dmamask =DMA_BIT_MASK (32 ); -static irqreturn_t kirkwood_dma_irq (int irq,void *dev_id) {struct kirkwood_dma_data *priv = dev_id;
@@ -292,10 +290,9 @@ static int kirkwood_dma_new(struct snd_soc_pcm_runtime *rtd)struct snd_pcm *pcm = rtd->pcm;int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &kirkwood_dma_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = kirkwood_dma_preallocate_dma_buffer(pcm,
sound/soc/nuc900/nuc900-pcm.c +4 -5
@@ -314,16 +314,15 @@ static void nuc900_dma_free_dma_buffers(struct snd_pcm *pcm)snd_pcm_lib_preallocate_free_for_all (pcm); } -static u64 nuc900_pcm_dmamask =DMA_BIT_MASK (32 );static int nuc900_dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &nuc900_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;snd_pcm_lib_preallocate_pages_for_all (pcm,SNDRV_DMA_TYPE_DEV , card->dev,4 *1024 , (4 *1024 ) -1 );
sound/soc/omap/omap-pcm.c +4 -7
@@ -156,8 +156,6 @@ static struct snd_pcm_ops omap_pcm_ops = { .mmap = omap_pcm_mmap, }; -static u64 omap_pcm_dmamask =DMA_BIT_MASK (64 ); -static int omap_pcm_preallocate_dma_buffer (struct snd_pcm *pcm,int stream) {
@@ -202,12 +200,11 @@ static int omap_pcm_new(struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &omap_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (64 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (64 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = omap_pcm_preallocate_dma_buffer(pcm,
sound/soc/pxa/pxa2xx-pcm.c +4 -7
@@ -87,18 +87,15 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = { .mmap = pxa2xx_pcm_mmap, }; -static u64 pxa2xx_pcm_dmamask =DMA_BIT_MASK (32 ); -static int pxa2xx_soc_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &pxa2xx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
sound/soc/s6000/s6000-pcm.c +3 -6
@@ -444,8 +444,6 @@ static void s6000_pcm_free(struct snd_pcm *pcm)snd_pcm_lib_preallocate_free_for_all (pcm); } -static u64 s6000_pcm_dmamask =DMA_BIT_MASK (32 ); -static int s6000_pcm_new (struct snd_soc_pcm_runtime *runtime) {struct snd_card *card = runtime->card->snd_card;
@@ -456,10 +454,9 @@ static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime) params =snd_soc_dai_get_dma_data (runtime->cpu_dai, pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream); -if (!card->dev->dma_mask) - card->dev->dma_mask = &s6000_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + res =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (res) +return res;if (params->dma_in) { s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in),
sound/soc/samsung/dma.c +4 -7
@@ -406,20 +406,17 @@ static void dma_free_dma_buffers(struct snd_pcm *pcm) } } -static u64 dma_mask =DMA_BIT_MASK (32 ); -static int dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret;pr_debug ("Entered %s\n" , __func__); -if (!card->dev->dma_mask) - card->dev->dma_mask = &dma_mask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = preallocate_dma_buffer(pcm,
sound/soc/samsung/idma.c +4 -7
@@ -383,18 +383,15 @@ static int preallocate_idma_buffer(struct snd_pcm *pcm, int stream)return 0 ; } -static u64 idma_mask =DMA_BIT_MASK (32 ); -static int idma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &idma_mask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = preallocate_idma_buffer(pcm,
Signature · 1 line
1.7.4.4
Re: [PATCH 28/51] DMA-API: sound: fix dma mask handling in a lot of drivers
Quoted 6 lines · Russell King
This code sequence is unsafe in modules:
static u64 mask =
DMA_BIT_MASK(something);
...if (!dev->dma_mask) dev->dma_mask = &mask;
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 28/51] DMA-API: sound: fix dma mask handling in a lot of drivers
In reply to Russell KingHi,
sorry for the lat response, as I've been traveling in the last weeks.
At Thu, 19 Sep 2013 22:53:02 +0100,
Quoted 15 lines · Russell King
This code sequence is unsafe in modules:
static u64 mask =
DMA_BIT_MASK(something);
...if (!dev->dma_mask) dev->dma_mask = &mask;as if a module is reloaded, the mask will be pointing at the original module's mask address, and this can lead to oopses. Moreover, they all follow this with:
if (!dev->coherent_dma_mask) dev->coherent_dma_mask = mask;
Quoted 7 lines
where 'mask' is the same value as the statically defined mask, and this bypasses the architecture's check on whether the DMA mask is possible.
Fix these issues by using the new
dma_coerce_coherent_and_mask()function.Signed-off-by Russell King <[email protected]>
Applied with Mark's ack now.
BTW, sound/soc/fsl/imx-pcm-fiq.c wasn't covered by this patch, so I fixed it, too.
Thanks!
Takashi
Quoted 430 lines
--- sound/arm/pxa2xx-pcm.c | 9 +++------ sound/soc/atmel/atmel-pcm.c | 11 ++++------- sound/soc/blackfin/bf5xx-ac97-pcm.c | 11 ++++------- sound/soc/blackfin/bf5xx-i2s-pcm.c | 10 ++++------ sound/soc/davinci/davinci-pcm.c | 9 +++------ sound/soc/fsl/fsl_dma.c | 9 +++------ sound/soc/fsl/mpc5200_dma.c | 10 ++++------ sound/soc/jz4740/jz4740-pcm.c | 12 ++++-------- sound/soc/kirkwood/kirkwood-dma.c | 9 +++------ sound/soc/nuc900/nuc900-pcm.c | 9 ++++----- sound/soc/omap/omap-pcm.c | 11 ++++------- sound/soc/pxa/pxa2xx-pcm.c | 11 ++++------- sound/soc/s6000/s6000-pcm.c | 9 +++------ sound/soc/samsung/dma.c | 11 ++++------- sound/soc/samsung/idma.c | 11 ++++------- 15 files changed, 55 insertions(+), 97 deletions(-)sound/arm/pxa2xx-pcm.c +3
-6@@ -83,8 +83,6 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = { .mmap = pxa2xx_pcm_mmap, }; -static u64 pxa2xx_pcm_dmamask =0xffffffff ; -int pxa2xx_pcm_new (struct snd_card *card,struct pxa2xx_pcm_client *client,struct snd_pcm **rpcm) {@@ -100,10 +98,9 @@ int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client, pcm->private_data = client; pcm->private_free = pxa2xx_pcm_free_dma_buffers; -if (!card->dev->dma_mask) - card->dev->dma_mask = &pxa2xx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =0xffffffff ; + ret =dma_coerce_mask_and_coherent_mask (card->dev,DMA_BIT_MASK (32 )); +if (ret) + goto out;if (play) {int stream =SNDRV_PCM_STREAM_PLAYBACK ;sound/soc/atmel/atmel-pcm.c +4
-7@@ -68,18 +68,15 @@ int atmel_pcm_mmap(struct snd_pcm_substream *substream, }EXPORT_SYMBOL_GPL (atmel_pcm_mmap); -static u64 atmel_pcm_dmamask =DMA_BIT_MASK (32 ); -int atmel_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &atmel_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) {pr_debug ("atmel-pcm: allocating PCM playback DMA buffer\n" );sound/soc/blackfin/bf5xx-ac97-pcm.c +4
-7@@ -415,19 +415,16 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm) } } -static u64 bf5xx_pcm_dmamask =DMA_BIT_MASK (32 ); -static int bf5xx_pcm_ac97_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret;pr_debug ("%s enter\n" , __func__); -if (!card->dev->dma_mask) - card->dev->dma_mask = &bf5xx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = bf5xx_pcm_preallocate_dma_buffer(pcm,sound/soc/blackfin/bf5xx-i2s-pcm.c +4
-6@@ -323,18 +323,16 @@ static struct snd_pcm_ops bf5xx_pcm_i2s_ops = { .silence = bf5xx_pcm_silence, }; -static u64 bf5xx_pcm_dmamask =DMA_BIT_MASK (32 ); -static int bf5xx_pcm_i2s_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;size_t size = bf5xx_pcm_hardware.buffer_bytes_max; +int ret;pr_debug ("%s enter\n" , __func__); -if (!card->dev->dma_mask) - card->dev->dma_mask = &bf5xx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;return snd_pcm_lib_preallocate_pages_for_all (rtd->pcm,SNDRV_DMA_TYPE_DEV , card->dev, size, size);sound/soc/davinci/davinci-pcm.c +3
-6@@ -844,18 +844,15 @@ static void davinci_pcm_free(struct snd_pcm *pcm) } } -static u64 davinci_pcm_dmamask =DMA_BIT_MASK (32 ); -static int davinci_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm;int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &davinci_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = davinci_pcm_preallocate_dma_buffer(pcm,sound/soc/fsl/fsl_dma.c +3
-6@@ -298,14 +298,11 @@ static int fsl_dma_new(struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -static u64 fsl_dma_dmamask =DMA_BIT_MASK (36 );int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &fsl_dma_dmamask; - -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = fsl_dma_dmamask; + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (36 )); +if (ret) +return ret;/* Some codecs have separate DAIs for playback and capture, so we * should allocate a DMA buffer only for the streams that are valid. sound/soc/fsl/mpc5200_dma.c +4
-6@@ -299,7 +299,6 @@ static struct snd_pcm_ops psc_dma_ops = { .hw_params = psc_dma_hw_params, }; -static u64 psc_dma_dmamask =DMA_BIT_MASK (32 );static int psc_dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;@@ -307,15 +306,14 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)struct snd_pcm *pcm = rtd->pcm;struct psc_dma *psc_dma =snd_soc_dai_get_drvdata (rtd->cpu_dai);size_t size = psc_dma_hardware.buffer_bytes_max; -int rc =0 ; +int rc;dev_dbg (rtd->platform->dev,"psc_dma_new(card=%p, dai=%p, pcm=%p)\n" , card, dai, pcm); -if (!card->dev->dma_mask) - card->dev->dma_mask = &psc_dma_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + rc =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (rc) +return rc;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev,sound/soc/jz4740/jz4740-pcm.c +4
-8@@ -297,19 +297,15 @@ static void jz4740_pcm_free(struct snd_pcm *pcm) } } -static u64 jz4740_pcm_dmamask =DMA_BIT_MASK (32 ); -static int jz4740_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; - -if (!card->dev->dma_mask) - card->dev->dma_mask = &jz4740_pcm_dmamask; +int ret; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = jz4740_pcm_preallocate_dma_buffer(pcm,sound/soc/kirkwood/kirkwood-dma.c +3
-6@@ -59,8 +59,6 @@ static struct snd_pcm_hardware kirkwood_dma_snd_hw = { .fifo_size = 0, }; -static u64 kirkwood_dma_dmamask =DMA_BIT_MASK (32 ); -static irqreturn_t kirkwood_dma_irq (int irq,void *dev_id) {struct kirkwood_dma_data *priv = dev_id;@@ -292,10 +290,9 @@ static int kirkwood_dma_new(struct snd_soc_pcm_runtime *rtd)struct snd_pcm *pcm = rtd->pcm;int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &kirkwood_dma_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = kirkwood_dma_preallocate_dma_buffer(pcm,sound/soc/nuc900/nuc900-pcm.c +4
-5@@ -314,16 +314,15 @@ static void nuc900_dma_free_dma_buffers(struct snd_pcm *pcm)snd_pcm_lib_preallocate_free_for_all (pcm); } -static u64 nuc900_pcm_dmamask =DMA_BIT_MASK (32 );static int nuc900_dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &nuc900_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;snd_pcm_lib_preallocate_pages_for_all (pcm,SNDRV_DMA_TYPE_DEV , card->dev,4 *1024 , (4 *1024 ) -1 );sound/soc/omap/omap-pcm.c +4
-7@@ -156,8 +156,6 @@ static struct snd_pcm_ops omap_pcm_ops = { .mmap = omap_pcm_mmap, }; -static u64 omap_pcm_dmamask =DMA_BIT_MASK (64 ); -static int omap_pcm_preallocate_dma_buffer (struct snd_pcm *pcm,int stream) {@@ -202,12 +200,11 @@ static int omap_pcm_new(struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &omap_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (64 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (64 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = omap_pcm_preallocate_dma_buffer(pcm,sound/soc/pxa/pxa2xx-pcm.c +4
-7@@ -87,18 +87,15 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = { .mmap = pxa2xx_pcm_mmap, }; -static u64 pxa2xx_pcm_dmamask =DMA_BIT_MASK (32 ); -static int pxa2xx_soc_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &pxa2xx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,sound/soc/s6000/s6000-pcm.c +3
-6@@ -444,8 +444,6 @@ static void s6000_pcm_free(struct snd_pcm *pcm)snd_pcm_lib_preallocate_free_for_all (pcm); } -static u64 s6000_pcm_dmamask =DMA_BIT_MASK (32 ); -static int s6000_pcm_new (struct snd_soc_pcm_runtime *runtime) {struct snd_card *card = runtime->card->snd_card;@@ -456,10 +454,9 @@ static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime) params =snd_soc_dai_get_dma_data (runtime->cpu_dai, pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream); -if (!card->dev->dma_mask) - card->dev->dma_mask = &s6000_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + res =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (res) +return res;if (params->dma_in) { s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in),sound/soc/samsung/dma.c +4
-7@@ -406,20 +406,17 @@ static void dma_free_dma_buffers(struct snd_pcm *pcm) } } -static u64 dma_mask =DMA_BIT_MASK (32 ); -static int dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret;pr_debug ("Entered %s\n" , __func__); -if (!card->dev->dma_mask) - card->dev->dma_mask = &dma_mask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = preallocate_dma_buffer(pcm,sound/soc/samsung/idma.c +4
-7@@ -383,18 +383,15 @@ static int preallocate_idma_buffer(struct snd_pcm *pcm, int stream)return 0 ; } -static u64 idma_mask =DMA_BIT_MASK (32 ); -static int idma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &idma_mask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret = preallocate_idma_buffer(pcm,Signature · 1 line
1.7.4.4
Re: [PATCH 28/51] DMA-API: sound: fix dma mask handling in a lot of drivers
Quoted 24 lines · Takashi Iwai
Hi,
sorry for the lat response, as I've been traveling in the last weeks.
At Thu, 19 Sep 2013 22:53:02 +0100,
Quoted 18 lines · Russell King
This code sequence is unsafe in modules:
static u64 mask =
DMA_BIT_MASK(something);
...if (!dev->dma_mask) dev->dma_mask = &mask;as if a module is reloaded, the mask will be pointing at the original module's mask address, and this can lead to oopses. Moreover, they all follow this with:
if (!dev->coherent_dma_mask) dev->coherent_dma_mask = mask;where 'mask' is the same value as the statically defined mask, and this bypasses the architecture's check on whether the DMA mask is possible.
Quoted 6 lines
Quoted 4 lines
Fix these issues by using the new
dma_coerce_coherent_and_mask()function.Signed-off-by Russell King <[email protected]>Applied with Mark's ack now.
Which is a very stupid thing to do because you won't have dma_coerce_coherent_and_mask() in your tree, so all these drivers will fail to build for you.
Re: [PATCH 28/51] DMA-API: sound: fix dma mask handling in a lot of drivers
At Thu, 26 Sep 2013 08:54:25 +0100,
Quoted 29 lines · Russell King - ARM Linux
Quoted 27 lines · Takashi Iwai
Hi,
sorry for the lat response, as I've been traveling in the last weeks.
At Thu, 19 Sep 2013 22:53:02 +0100,
Quoted 21 lines · Russell King
This code sequence is unsafe in modules:
static u64 mask =
DMA_BIT_MASK(something);
...if (!dev->dma_mask) dev->dma_mask = &mask;as if a module is reloaded, the mask will be pointing at the original module's mask address, and this can lead to oopses. Moreover, they all follow this with:
if (!dev->coherent_dma_mask) dev->coherent_dma_mask = mask;where 'mask' is the same value as the statically defined mask, and this bypasses the architecture's check on whether the DMA mask is possible.
Fix these issues by using the new
dma_coerce_coherent_and_mask()function.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Russell King <[email protected]>Applied with Mark's ack now.
Which is a very stupid thing to do because you won't have
dma_coerce_coherent_and_mask()in your tree, so all these drivers will fail to build for you.
Ah, silly me, I missed the very first thing. Reverted it now...
FWIW, below is the missing piece. Please apply it in your side if necessary.
Takashi
--- sound/soc/fsl/imx-pcm-fiq.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
sound/soc/fsl/imx-pcm-fiq.c +5 -7
@@ -272,18 +272,16 @@ static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)return 0 ; } -static u64 imx_pcm_dmamask =DMA_BIT_MASK (32 ); -static int imx_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; + + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &imx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 );if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret =imx_pcm_preallocate_dma_buffer (pcm,SNDRV_PCM_STREAM_PLAYBACK );
Signature · 1 line
1.8.4
Takashi Iwai
Acked-byRe: [PATCH 28/51] DMA-API: sound: fix dma mask handling in a lot of drivers
At Thu, 26 Sep 2013 10:25:13 +0200,
Quoted 36 lines · Takashi Iwai
At Thu, 26 Sep 2013 08:54:25 +0100,
Quoted 33 lines · Russell King - ARM Linux
Quoted 30 lines · Takashi Iwai
Hi,
sorry for the lat response, as I've been traveling in the last weeks.
At Thu, 19 Sep 2013 22:53:02 +0100,
Quoted 15 lines · Russell King
This code sequence is unsafe in modules:
static u64 mask =
DMA_BIT_MASK(something);
...if (!dev->dma_mask) dev->dma_mask = &mask;as if a module is reloaded, the mask will be pointing at the original module's mask address, and this can lead to oopses. Moreover, they all follow this with:
if (!dev->coherent_dma_mask) dev->coherent_dma_mask = mask;Quoted 7 lines
where 'mask' is the same value as the statically defined mask, and this bypasses the architecture's check on whether the DMA mask is possible.
Fix these issues by using the new
dma_coerce_coherent_and_mask()function.Signed-off-by Russell King <[email protected]>Applied with Mark's ack now.
Quoted 8 lines
Quoted 3 lines
Which is a very stupid thing to do because you won't have
dma_coerce_coherent_and_mask()in your tree, so all these drivers will fail to build for you.Ah, silly me, I missed the very first thing. Reverted it now...
FWIW, below is the missing piece. Please apply it in your side if necessary.
Oh, and feel free to add my ack, if any:
thanks,
Takashi
Quoted 38 lines
Takashi
--- sound/soc/fsl/imx-pcm-fiq.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)sound/soc/fsl/imx-pcm-fiq.c +5
-7@@ -272,18 +272,16 @@ static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)return 0 ; } -static u64 imx_pcm_dmamask =DMA_BIT_MASK (32 ); -static int imx_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card;struct snd_pcm *pcm = rtd->pcm; -int ret =0 ; +int ret; + + ret =dma_coerce_mask_and_coherent (card->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; -if (!card->dev->dma_mask) - card->dev->dma_mask = &imx_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 );if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream) { ret =imx_pcm_preallocate_dma_buffer (pcm,SNDRV_PCM_STREAM_PLAYBACK );Signature · 1 line
1.8.4
PATCH 29/51 DMA-API: ata: pata_octeon_cf: convert to use dma_coerce_mask_and_coherent()
In reply to Russell King - ARM LinuxConvert this code sequence:
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(64); pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
to use dma_coerce_mask_and_coherent() to avoid bypassing the architecture check on the DMA mask.
--- drivers/ata/pata_octeon_cf.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/ata/pata_octeon_cf.c +3 -2
@@ -1014,8 +1014,9 @@ static int octeon_cf_probe(struct platform_device *pdev) } cf_port->c0 = ap->ioaddr.ctl_addr; - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (64 ); - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; + rv =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); +if (rv) +return ret;ata_port_desc (ap,"cmd %p ctl %p" , base, ap->ioaddr.ctl_addr);
Signature · 1 line
1.7.4.4
Re: [PATCH 29/51] DMA-API: ata: pata_octeon_cf: convert to use dma_coerce_mask_and_coherent()
drivers/ata/pata_octeon_cf.c static int octeon_cf_probe(struct platform_device *pdev) · line 1019
Quoted 13 lines · Russell King
drivers/ata/pata_octeon_cf.c +3
-2@@ -1014,8 +1014,9 @@ static int octeon_cf_probe(struct platform_device *pdev) } cf_port->c0 = ap->ioaddr.ctl_addr; - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (64 ); - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; + rv =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); +if (rv) +return ret;
return rv;
http://kisskb.ellerman.id.au/kisskb/buildresult/9959184/
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 30/51 DMA-API: dma: dw_dmac.c: convert to use dma_coerce_mask_and_coherent()
In reply to Russell King - ARM LinuxThis code sequence:
if (!pdev->dev.dma_mask) {
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
}bypasses the architectures check on the DMA mask. It can be replaced with dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.
--- drivers/dma/dw/platform.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/dma/dw/platform.c +3 -5
@@ -191,11 +191,9 @@ static int dw_probe(struct platform_device *pdev)if (IS_ERR (chip->regs))return PTR_ERR (chip->regs); -/* Apply default dma_mask if needed */ -if (!dev->dma_mask) { - dev->dma_mask = &dev->coherent_dma_mask; - dev->coherent_dma_mask =DMA_BIT_MASK (32 ); - } + err =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) +return err; pdata =dev_get_platdata (dev);if (!pdata)
Signature · 1 line
1.7.4.4
Andy Shevchenko
reviewerRe: [PATCH 30/51] DMA-API: dma: dw_dmac.c: convert to use dma_coerce_mask_and_coherent()
Quoted 20 lines · Russell King
This code sequence:
if (!pdev->dev.dma_mask) { pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); }bypasses the architectures check on the DMA mask. It can be replaced with
dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.Signed-off-by Russell King <[email protected]>--- drivers/dma/dw/platform.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)drivers/dma/dw/platform.c +0
-0@@ -191,11 +191,9 @@ static int dw_probe(struct platform_device *pdev)if (IS_ERR (chip->regs))
drivers/dma/dw/platform.c static int dw_probe(struct platform_device *pdev) · line 196
Quoted 10 lines
drivers/dma/dw/platform.c +3
-5return PTR_ERR (chip->regs); -/* Apply default dma_mask if needed */ -if (!dev->dma_mask) { - dev->dma_mask = &dev->coherent_dma_mask; - dev->coherent_dma_mask =DMA_BIT_MASK (32 ); - } + err =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) +return err;
I have at least one question.
In case of new code you always assign dev->dma_mask.
static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask)
{
dev->dma_mask = &dev->coherent_dma_mask;
return dma_set_mask_and_coherent(dev, mask);
}So, the question is how keep the initialized dma_mask (and should we do so by your opinion)?
Additional question, who will free memory allocated for dma_mask in case if it was allocated, dma_mask initialized and then your code just substitute the address to some new value?
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Re: [PATCH 30/51] DMA-API: dma: dw_dmac.c: convert to use dma_coerce_mask_and_coherent()
Quoted 38 lines · Andy Shevchenko
Quoted 20 lines · Russell King
This code sequence:
if (!pdev->dev.dma_mask) { pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); }bypasses the architectures check on the DMA mask. It can be replaced with
dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.Signed-off-by Russell King <[email protected]>--- drivers/dma/dw/platform.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)drivers/dma/dw/platform.c +0
-0@@ -191,11 +191,9 @@ static int dw_probe(struct platform_device *pdev)if (IS_ERR (chip->regs))drivers/dma/dw/platform.c static int dw_probe(struct platform_device *pdev) · line 196
Quoted 10 lines
drivers/dma/dw/platform.c +3
-5return PTR_ERR (chip->regs); -/* Apply default dma_mask if needed */ -if (!dev->dma_mask) { - dev->dma_mask = &dev->coherent_dma_mask; - dev->coherent_dma_mask =DMA_BIT_MASK (32 ); - } + err =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) +return err;I have at least one question.
In case of new code you always assign
dev->dma_mask.static inline int
dma_coerce_mask_and_coherent(struct device *dev, u64 mask)
Quoted 7 lines
{ dev->dma_mask = &dev->coherent_dma_mask; return dma_set_mask_and_coherent(dev, mask); }So, the question is how keep the initialized
dma_mask(and should we do so by your opinion)?
Well, the way the DMA mask stuff is supposed to operate is:
- The device creator initializes the DMA mask to some default value.
- The driver then uses dma_set_mask() / dma_set_coherent_mask() / dma_set_mask_and_coherent() to adjust the mask according to the capabilities of the device, *even* if the mask is the same as the default.
This is specified in the various DMA API documents.
So, in PCI land, it works like this:
- When a PCI device is created, it has its mask set to 32-bit.
- When a driver comes along
- if the device is capable of 64-bit addressing, it tries to set a 64-bit mask. If this fails, it tries to set a 32-bit mask and turns off 64-bit DMA.
- if a device is not capable of 32-bit addressing but of a smaller space (there are some PCI devices which can only do 31-bit) then it tries to set that mask.
If the driver can't successfully set a mask, it should fail to initialise.
This is where we should be headed with all drivers, and I would welcome a patch for this driver to make it conform wrt the DMA API and DMA masks in place of this patch.
Think of the coerse stuff as a middle-step to bring these types of issues up to the fore.
Re: [PATCH 30/51] DMA-API: dma: dw_dmac.c: convert to use dma_coerce_mask_and_coherent()
Quoted 57 lines · Russell King - ARM Linux
Quoted 38 lines · Andy Shevchenko
Quoted 20 lines · Russell King
This code sequence:
if (!pdev->dev.dma_mask) { pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); }bypasses the architectures check on the DMA mask. It can be replaced with
dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.Signed-off-by Russell King <[email protected]>--- drivers/dma/dw/platform.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)drivers/dma/dw/platform.c +0
-0@@ -191,11 +191,9 @@ static int dw_probe(struct platform_device *pdev)if (IS_ERR (chip->regs))drivers/dma/dw/platform.c static int dw_probe(struct platform_device *pdev) · line 196
Quoted 10 lines
drivers/dma/dw/platform.c +3
-5return PTR_ERR (chip->regs); -/* Apply default dma_mask if needed */ -if (!dev->dma_mask) { - dev->dma_mask = &dev->coherent_dma_mask; - dev->coherent_dma_mask =DMA_BIT_MASK (32 ); - } + err =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) +return err;I have at least one question.
In case of new code you always assign
dev->dma_mask.static inline int
dma_coerce_mask_and_coherent(struct device *dev, u64 mask)Quoted 7 lines
{ dev->dma_mask = &dev->coherent_dma_mask; return dma_set_mask_and_coherent(dev, mask); }So, the question is how keep the initialized
dma_mask(and should we do so by your opinion)?Well, the way the DMA mask stuff is supposed to operate is:
- The device creator initializes the DMA mask to some default value.
- The driver then usesdma_set_mask()/dma_set_coherent_mask()/dma_set_mask_and_coherent()to adjust the mask according to the capabilities of the device, *even* if the mask is the same as the default.This is specified in the various DMA API documents.
Quoted 12 lines
So, in PCI land, it works like this:
- When a PCI device is created, it has its mask set to 32-bit.
- When a driver comes along
- if the device is capable of 64-bit addressing, it tries to set a 64-bit mask. If this fails, it tries to set a 32-bit mask and turns off 64-bit DMA.
- if a device is not capable of 32-bit addressing but of a smaller space (there are some PCI devices which can only do 31-bit) then it tries to set that mask.
If the driver can't successfully set a mask, it should fail to initialise.
Thanks for explanation.
Quoted 3 lines
This is where we should be headed with all drivers, and I would welcome a patch for this driver to make it conform wrt the DMA API and DMA masks in place of this patch.
I see.
Quoted 2 lines
Think of the coerse stuff as a middle-step to bring these types of issues up to the fore.
I will check your patches on next week, though I think it will neglect dma_mask set by PCI part of the code in PCI case of the driver.
Well, there are a lot of drivers that are designed like:
- core part as library *or* separate driver
- platform driver
- pci driver
- acpi driver
- ... whatever bus driver for this device
Core part doesn't know what the upper layer (bus layer) sets, and approaches to set that may differ from bus to bus (e.g. PCI vs. ACPI ).
So, ACPI could set the proper values from its own guts and in core driver we have to respect those values.
Tioday is Friday, and I'm too lazy now to think a bit how this could be solved in case of your helper involved.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 30/51] DMA-API: dma: dw_dmac.c: convert to use dma_coerce_mask_and_coherent()
Quoted 93 lines · Andy Shevchenko
Quoted 57 lines · Russell King - ARM Linux
Quoted 38 lines · Andy Shevchenko
Quoted 20 lines · Russell King
This code sequence:
if (!pdev->dev.dma_mask) { pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); }bypasses the architectures check on the DMA mask. It can be replaced with
dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.Signed-off-by Russell King <[email protected]>--- drivers/dma/dw/platform.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)drivers/dma/dw/platform.c +0
-0@@ -191,11 +191,9 @@ static int dw_probe(struct platform_device *pdev)if (IS_ERR (chip->regs))drivers/dma/dw/platform.c static int dw_probe(struct platform_device *pdev) · line 196
Quoted 10 lines
drivers/dma/dw/platform.c +3
-5return PTR_ERR (chip->regs); -/* Apply default dma_mask if needed */ -if (!dev->dma_mask) { - dev->dma_mask = &dev->coherent_dma_mask; - dev->coherent_dma_mask =DMA_BIT_MASK (32 ); - } + err =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) +return err;I have at least one question.
In case of new code you always assign
dev->dma_mask.static inline int
dma_coerce_mask_and_coherent(struct device *dev, u64 mask)Quoted 7 lines
{ dev->dma_mask = &dev->coherent_dma_mask; return dma_set_mask_and_coherent(dev, mask); }So, the question is how keep the initialized
dma_mask(and should we do so by your opinion)?Well, the way the DMA mask stuff is supposed to operate is:
- The device creator initializes the DMA mask to some default value.
- The driver then usesdma_set_mask()/dma_set_coherent_mask()/dma_set_mask_and_coherent()to adjust the mask according to the capabilities of the device, *even* if the mask is the same as the default.This is specified in the various DMA API documents.
Quoted 12 lines
So, in PCI land, it works like this:
- When a PCI device is created, it has its mask set to 32-bit.
- When a driver comes along
- if the device is capable of 64-bit addressing, it tries to set a 64-bit mask. If this fails, it tries to set a 32-bit mask and turns off 64-bit DMA.
- if a device is not capable of 32-bit addressing but of a smaller space (there are some PCI devices which can only do 31-bit) then it tries to set that mask.
If the driver can't successfully set a mask, it should fail to initialise.Thanks for explanation.
Quoted 3 lines
This is where we should be headed with all drivers, and I would welcome a patch for this driver to make it conform wrt the DMA API and DMA masks in place of this patch.
I see.
Quoted 2 lines
Think of the coerse stuff as a middle-step to bring these types of issues up to the fore.
I will check your patches on next week, though I think it will neglect
dma_maskset by PCI part of the code in PCI case of the driver.Well, there are a lot of drivers that are designed like:
- core part as library *or* separate driver
- platform driver
- pci driver
- acpi driver
- ... whatever bus driver for this device
Quoted 8 lines
Core part doesn't know what the upper layer (bus layer) sets, and approaches to set that may differ from bus to bus (e.g. PCI vs. ACPI ).
So, ACPI could set the proper values from its own guts and in core driver we have to respect those values.Tioday is Friday, and I'm too lazy now to think a bit how this could be solved in case of your helper involved.
okay its monday now :)
for dw_dmac where you have core part and platform part, since the capablties of the *device* are known to the core part, IMO it is the job of core to set the correct value as Russell described.
The platform or device creator may have set somthing else but when driver loads in the core part of you understand the device and should reset the values...
~Vinod
PATCH 31/51 DMA-API: media: omap3isp: use dma_coerce_mask_and_coherent()
In reply to Russell King - ARM LinuxThe code sequence:
isp->raw_dmamask = DMA_BIT_MASK(32); isp->dev->dma_mask = &isp->raw_dmamask; isp->dev->coherent_dma_mask = DMA_BIT_MASK(32);
bypasses the architectures check on the DMA mask. It can be replaced with dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.
--- drivers/media/platform/omap3isp/isp.c | 6 +++--- drivers/media/platform/omap3isp/isp.h | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/media/platform/omap3isp/isp.c +3 -3
@@ -2182,9 +2182,9 @@ static int isp_probe(struct platform_device *pdev) isp->pdata = pdata; isp->ref_count =0 ; - isp->raw_dmamask =DMA_BIT_MASK (32 ); - isp->dev->dma_mask = &isp->raw_dmamask; - isp->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (isp->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;platform_set_drvdata (pdev, isp);
drivers/media/platform/omap3isp/isp.h +0 -3
@@ -152,7 +152,6 @@ struct isp_xclk {* @mmio_base_phys: Array with physical L4 bus addresses for ISP register * regions. * @mmio_size: Array with ISP register regions size in bytes. -* @raw_dmamask: Raw DMA mask * @stat_lock: Spinlock for handling statistics * @isp_mutex: Mutex for serializing requests to ISP. * @crashed: Bitmask of crashed entities (indexed by entity ID)
@@ -190,8 +189,6 @@ struct isp_device {unsigned long mmio_base_phys[OMAP3_ISP_IOMEM_LAST ];resource_size_t mmio_size[OMAP3_ISP_IOMEM_LAST ]; -u64 raw_dmamask; -/* ISP Obj */ spinlock_t stat_lock;/* common lock for statistic drivers */ struct mutex isp_mutex;/* For handling ref_count field */
Signature · 1 line
1.7.4.4
A message that is not in the archive (sent off-list or not yet received): E1VMmCg-0007j1-Pi-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org
Laurent Pinchart
Acked-byRe: [PATCH 31/51] DMA-API: media: omap3isp: use dma_coerce_mask_and_coherent()
Hi Russell,
Thank you for the patch.
Quoted 9 lines · On Thursday 19 September 2013 22:56:02 Russell King wrote:
The code sequence:
isp->raw_dmamask = DMA_BIT_MASK(32); isp->dev->dma_mask = &isp->raw_dmamask; isp->dev->coherent_dma_mask = DMA_BIT_MASK(32);bypasses the architectures check on the DMA mask. It can be replaced with
dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.Signed-off-by Russell King <[email protected]>
Quoted 43 lines
--- drivers/media/platform/omap3isp/isp.c | 6 +++--- drivers/media/platform/omap3isp/isp.h | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex df3a0ec..1c36080 100644drivers/media/platform/omap3isp/isp.c +3
-3@@ -2182,9 +2182,9 @@ static int isp_probe(struct platform_device *pdev) isp->pdata = pdata; isp->ref_count =0 ; - isp->raw_dmamask =DMA_BIT_MASK (32 ); - isp->dev->dma_mask = &isp->raw_dmamask; - isp->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_coerce_mask_and_coherent (isp->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;platform_set_drvdata (pdev, isp);(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.hindex cd3eff4..ce65d3a 100644drivers/media/platform/omap3isp/isp.h +0
-3@@ -152,7 +152,6 @@ struct isp_xclk {* @mmio_base_phys: Array with physical L4 bus addresses for ISP register * regions. * @mmio_size: Array with ISP register regions size in bytes. -* @raw_dmamask: Raw DMA mask * @stat_lock: Spinlock for handling statistics * @isp_mutex: Mutex for serializing requests to ISP. * @crashed: Bitmask of crashed entities (indexed by entity ID) @@ -190,8 +189,6 @@ struct isp_device {unsigned long mmio_base_phys[OMAP3_ISP_IOMEM_LAST ];resource_size_t mmio_size[OMAP3_ISP_IOMEM_LAST ]; -u64 raw_dmamask; -/* ISP Obj */ spinlock_t stat_lock;/* common lock for statistic drivers */ struct mutex isp_mutex;/* For handling ref_count field */
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 32/51 DMA-API: mmc: sdhci-acpi: use dma_coerce_mask_and_coherent()
In reply to Russell King - ARM LinuxThe code sequence:
dev->dma_mask = &dev->coherent_dma_mask; dev->coherent_dma_mask = dma_mask;
bypasses the architectures check on the DMA mask. It can be replaced with dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.
--- drivers/mmc/host/sdhci-acpi.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-acpi.c +3 -2
@@ -310,8 +310,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev) dma_mask =DMA_BIT_MASK (32 ); } - dev->dma_mask = &dev->coherent_dma_mask; - dev->coherent_dma_mask = dma_mask; + err =dma_coerce_mask_and_coherent (dev, dma_mask); +if (err) + goto err_free; }if (c->slot) {
Signature · 1 line
1.7.4.4
PATCH 33/51 DMA-API: net: nxp/lpc_eth: use dma_coerce_mask_and_coherent()
In reply to Russell King - ARM LinuxThe code sequence:
pldat->pdev->dev.coherent_dma_mask = 0xFFFFFFFF; pldat->pdev->dev.dma_mask = &pldat->pdev->dev.coherent_dma_mask;
bypasses the architectures check on the DMA mask. It can be replaced with dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.
--- drivers/net/ethernet/nxp/lpc_eth.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/nxp/lpc_eth.c +4 -2
@@ -1399,8 +1399,10 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) }if (pldat->dma_buff_base_v ==0 ) { - pldat->pdev->dev.coherent_dma_mask =0xFFFFFFFF ; - pldat->pdev->dev.dma_mask = &pldat->pdev->dev.coherent_dma_mask; + ret =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto err_out_free_irq; + pldat->dma_buff_size =PAGE_ALIGN (pldat->dma_buff_size);/* Allocate a chunk of memory for the DMA ethernet buffers
Signature · 1 line
1.7.4.4
PATCH 34/51 DMA-API: net: octeon: use dma_coerce_mask_and_coherent()
In reply to Russell King - ARM LinuxThe code sequence:
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(64); pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
bypasses the architectures check on the DMA mask. It can be replaced with dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.
--- drivers/net/ethernet/octeon/octeon_mgmt.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/octeon/octeon_mgmt.c +3 -2
@@ -1552,8 +1552,9 @@ static int octeon_mgmt_probe(struct platform_device *pdev) p->phy_np =of_parse_phandle (pdev->dev.of_node,"phy-handle" ,0 ); - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (64 ); - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; + result =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); +if (result) + goto err;netif_carrier_off (netdev); result =register_netdev (netdev);
Signature · 1 line
1.7.4.4
PATCH 35/51 DMA-API: parport: parport_pc.c: use dma_coerce_mask_and_coherent()
In reply to Russell King - ARM LinuxThe code sequence:
dev->coherent_dma_mask = DMA_BIT_MASK(24); dev->dma_mask = &dev->coherent_dma_mask;
bypasses the architectures check on the DMA mask. It can be replaced with dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask.
--- drivers/parport/parport_pc.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/parport/parport_pc.c +6 -2
@@ -2004,6 +2004,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,struct resource *ECR_res =NULL ;struct resource *EPP_res =NULL ;struct platform_device *pdev =NULL ; +int ret;if (!dev) {/* We need a physical device to attach to, but none was
@@ -2014,8 +2015,11 @@ struct parport *parport_pc_probe_port(unsigned long int base,return NULL ; dev = &pdev->dev; - dev->coherent_dma_mask =DMA_BIT_MASK (24 ); - dev->dma_mask = &dev->coherent_dma_mask; + ret =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (24 )); +if (ret) { +dev_err (dev,"Unable to set coherent dma mask: disabling DMA\n" ); + dma =PARPORT_DMA_NONE ; + } } ops =kmalloc (sizeof (struct parport_operations ),GFP_KERNEL );
Signature · 1 line
1.7.4.4
PATCH 36/51 DMA-API: usb: use dma_set_coherent_mask()
In reply to Russell King - ARM LinuxThe correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use dma_set_coherent_mask(). Only arch and bus code should access this member directly.
Convert all direct write accesses to using the correct API.
--- drivers/usb/chipidea/ci_hdrc_imx.c | 5 +++-- drivers/usb/dwc3/dwc3-exynos.c | 5 +++-- drivers/usb/gadget/lpc32xx_udc.c | 4 +++- drivers/usb/host/ehci-atmel.c | 5 +++-- drivers/usb/host/ehci-octeon.c | 4 +++- drivers/usb/host/ehci-omap.c | 8 +++++--- drivers/usb/host/ehci-orion.c | 5 +++-- drivers/usb/host/ehci-platform.c | 7 ++++--- drivers/usb/host/ehci-s5p.c | 5 +++-- drivers/usb/host/ehci-spear.c | 5 +++-- drivers/usb/host/ehci-tegra.c | 5 +++-- drivers/usb/host/ohci-at91.c | 7 ++++--- drivers/usb/host/ohci-exynos.c | 5 +++-- drivers/usb/host/ohci-nxp.c | 4 +++- drivers/usb/host/ohci-octeon.c | 4 +++- drivers/usb/host/ohci-omap3.c | 8 +++++--- drivers/usb/host/ohci-pxa27x.c | 6 ++++-- drivers/usb/host/ohci-spear.c | 5 +++-- drivers/usb/host/uhci-platform.c | 5 +++-- 19 files changed, 64 insertions(+), 38 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +3 -2
@@ -123,8 +123,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto err_clk;if (data->usbmisc_data) { ret =imx_usbmisc_init (data->usbmisc_data);
drivers/usb/dwc3/dwc3-exynos.c +3 -2
@@ -121,8 +121,9 @@ static int dwc3_exynos_probe(struct platform_device *pdev)*/ if (!dev->dma_mask) dev->dma_mask = &dev->coherent_dma_mask; -if (!dev->coherent_dma_mask) - dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); +if (ret) + goto err1;platform_set_drvdata (pdev, exynos);
drivers/usb/gadget/lpc32xx_udc.c +3 -1
@@ -3078,7 +3078,9 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) udc->isp1301_i2c_client->addr); pdev->dev.dma_mask = &lpc32xx_usbd_dmamask; - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (retval) + goto resource_fail; udc->board = &lpc32xx_usbddata;
drivers/usb/host/ehci-atmel.c +3 -2
@@ -92,8 +92,9 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (retval) + goto fail_create_hcd; hcd =usb_create_hcd (driver, &pdev->dev,dev_name (&pdev->dev));if (!hcd) {
drivers/usb/host/ehci-octeon.c +3 -1
@@ -116,8 +116,10 @@ static int ehci_octeon_drv_probe(struct platform_device *pdev)* We can DMA from anywhere. But the descriptors must be in * the lower 4GB. */ - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); pdev->dev.dma_mask = &ehci_octeon_dma_mask; + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; hcd =usb_create_hcd (&ehci_octeon_hc_driver, &pdev->dev,"octeon" );if (!hcd)
drivers/usb/host/ehci-omap.c +5 -3
@@ -104,7 +104,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)struct resource *res;struct usb_hcd *hcd;void __iomem *regs; -int ret = -ENODEV ; +int ret;int irq;int i;struct omap_hcd *omap;
@@ -146,9 +146,11 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)*/ if (!dev->dma_mask) dev->dma_mask = &dev->coherent_dma_mask; -if (!dev->coherent_dma_mask) - dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; + ret = -ENODEV ; hcd =usb_create_hcd (&ehci_omap_hc_driver, dev,dev_name (dev));if (!hcd) {
drivers/usb/host/ehci-orion.c +3 -2
@@ -182,8 +182,9 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) + goto err1;if (!request_mem_region (res->start,resource_size (res), ehci_orion_hc_driver.description)) {
drivers/usb/host/ehci-platform.c +4 -3
@@ -78,7 +78,7 @@ static int ehci_platform_probe(struct platform_device *dev)struct resource *res_mem;struct usb_ehci_pdata *pdata;int irq; -int err = -ENOMEM ; +int err;if (usb_disabled ())return -ENODEV ;
@@ -91,8 +91,9 @@ static int ehci_platform_probe(struct platform_device *dev) dev->dev.platform_data = &ehci_platform_defaults;if (!dev->dev.dma_mask) dev->dev.dma_mask = &dev->dev.coherent_dma_mask; -if (!dev->dev.coherent_dma_mask) - dev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + err =dma_set_coherent_mask (&dev->dev,DMA_BIT_MASK (32 )); +if (err) +return err; pdata =dev_get_platdata (&dev->dev);
drivers/usb/host/ehci-s5p.c +3 -2
@@ -91,8 +91,9 @@ static int s5p_ehci_probe(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) +return err;s5p_setup_vbus_gpio (pdev);
drivers/usb/host/ehci-spear.c +3 -2
@@ -83,8 +83,9 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (retval) + goto fail; usbh_clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (usbh_clk)) {
drivers/usb/host/ehci-tegra.c +3 -2
@@ -364,8 +364,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) +return err; hcd =usb_create_hcd (&tegra_ehci_hc_driver, &pdev->dev,dev_name (&pdev->dev));
drivers/usb/host/ohci-at91.c +4 -3
@@ -524,7 +524,7 @@ MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);static int ohci_at91_of_init (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node; -int i, gpio; +int i, gpio, ret;enum of_gpio_flags flags;struct at91_usbh_data *pdata;u32 ports;
@@ -538,8 +538,9 @@ static int ohci_at91_of_init(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL );if (!pdata)
drivers/usb/host/ohci-exynos.c +3 -2
@@ -116,8 +116,9 @@ static int exynos_ohci_probe(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (err) +return err; exynos_ohci =devm_kzalloc (&pdev->dev,sizeof (struct exynos_ohci_hcd ),GFP_KERNEL );
drivers/usb/host/ohci-nxp.c +3 -1
@@ -226,8 +226,10 @@ static int usb_hcd_nxp_probe(struct platform_device *pdev)return -EPROBE_DEFER ; } - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto fail_disable;dev_dbg (&pdev->dev,"%s: " DRIVER_DESC " (nxp)\n" , hcd_name);if (usb_disabled ()) {
drivers/usb/host/ohci-octeon.c +3 -1
@@ -127,8 +127,10 @@ static int ohci_octeon_drv_probe(struct platform_device *pdev) }/* Ohci is a 32-bit device. */ - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; hcd =usb_create_hcd (&ohci_octeon_hc_driver, &pdev->dev,"octeon" );if (!hcd)
drivers/usb/host/ohci-omap3.c +5 -3
@@ -132,7 +132,7 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)struct usb_hcd *hcd =NULL ;void __iomem *regs =NULL ;struct resource *res; -int ret = -ENODEV ; +int ret;int irq;if (usb_disabled ())
@@ -168,9 +168,11 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)*/ if (!dev->dma_mask) dev->dma_mask = &dev->coherent_dma_mask; -if (!dev->coherent_dma_mask) - dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); +if (ret) + goto err_io; + ret = -ENODEV ; hcd =usb_create_hcd (&ohci_omap3_hc_driver, dev,dev_name (dev));if (!hcd) {
drivers/usb/host/ohci-pxa27x.c +4 -2
@@ -287,6 +287,7 @@ static int ohci_pxa_of_init(struct platform_device *pdev)struct device_node *np = pdev->dev.of_node;struct pxaohci_platform_data *pdata;u32 tmp; +int ret;if (!np)return 0 ;
@@ -297,8 +298,9 @@ static int ohci_pxa_of_init(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL );if (!pdata)
drivers/usb/host/ohci-spear.c +3 -2
@@ -113,8 +113,9 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (retval) + goto fail; usbh_clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (usbh_clk)) {
drivers/usb/host/uhci-platform.c +3 -2
@@ -77,8 +77,9 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)*/ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; hcd =usb_create_hcd (&uhci_platform_hc_driver, &pdev->dev, pdev->name);
Signature · 1 line
1.7.4.4
Re: [PATCH 36/51] DMA-API: usb: use dma_set_coherent_mask()
Hi,
Quoted 21 lines · Russell King
drivers/usb/dwc3/dwc3-exynos.c +3
-2@@ -121,8 +121,9 @@ static int dwc3_exynos_probe(struct platform_device *pdev)*/ if (!dev->dma_mask) dev->dma_mask = &dev->coherent_dma_mask; -if (!dev->coherent_dma_mask) - dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); +if (ret) + goto err1;platform_set_drvdata (pdev, exynos);drivers/usb/gadget/lpc32xx_udc.c +0
-0
drivers/usb/gadget/lpc32xx_udc.c static int __init lpc32xx_udc_probe(struct platform_device *pdev) · line 3086
Quoted 10 lines
drivers/usb/gadget/lpc32xx_udc.c +3
-1@@ -3078,7 +3078,9 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) udc->isp1301_i2c_client->addr); pdev->dev.dma_mask = &lpc32xx_usbd_dmamask; - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (retval) + goto resource_fail; udc->board = &lpc32xx_usbddata;
for dwc3 and drivers/usb/gadget:
pretty cool work :-)
Signature · 1 line
balbi
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 36/51] DMA-API: usb: use dma_set_coherent_mask()
In reply to Russell KingOn 20/09/2013 00:01, Russell King :
Quoted 5 lines
The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use
dma_set_coherent_mask(). Only arch and bus code should access this member directly.
Quoted 8 lines
Convert all direct write accesses to using the correct API.
Signed-off-by Russell King <[email protected]>--- drivers/usb/chipidea/ci_hdrc_imx.c | 5 +++-- drivers/usb/dwc3/dwc3-exynos.c | 5 +++-- drivers/usb/gadget/lpc32xx_udc.c | 4 +++- drivers/usb/host/ehci-atmel.c | 5 +++--
For Atmel driver:
[..]
Quoted 6 lines
drivers/usb/host/ehci-atmel.c +0
-0@@ -92,8 +92,9 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)*/
drivers/usb/host/ehci-atmel.c static int ehci_atmel_drv_probe(struct platform_device *pdev) · line 100
Quoted 10 lines
drivers/usb/host/ehci-atmel.c +3
-2if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; -if (!pdev->dev.coherent_dma_mask) - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (retval) + goto fail_create_hcd; hcd =usb_create_hcd (driver, &pdev->dev,dev_name (&pdev->dev));if (!hcd) {
[..]
Thanks,
Signature · 1 line
Nicolas Ferre
Alan Stern
maintainerRe: [PATCH 36/51] DMA-API: usb: use dma_set_coherent_mask()
In reply to Russell KingQuoted 15 lines · Russell King
The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use
dma_set_coherent_mask(). Only arch and bus code should access this member directly.Convert all direct write accesses to using the correct API.
Signed-off-by Russell King <[email protected]>drivers/usb/host/ehci-platform.c +0
-0
drivers/usb/host/ehci-platform.c static int ehci_platform_probe(struct platform_device *dev) · line 98
Quoted 10 lines
drivers/usb/host/ehci-platform.c +3
-2@@ -91,8 +91,9 @@ static int ehci_platform_probe(struct platform_device *dev) dev->dev.platform_data = &ehci_platform_defaults;if (!dev->dev.dma_mask) dev->dev.dma_mask = &dev->dev.coherent_dma_mask; -if (!dev->dev.coherent_dma_mask) - dev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + err =dma_set_coherent_mask (&dev->dev,DMA_BIT_MASK (32 )); +if (err) +return err; pdata =dev_get_platdata (&dev->dev);
ehci-platform.c is a generic file, intended for use by multiple platforms. Is it not possible that on some platforms, the arch or bus code may already have initialized the DMA masks? Isn't something like this (i.e., DMA bindings) planned for Device Tree?
By eliminating the tests above and calling dma_set_coherent_mask or dma_coerce_mask_and_coherent unconditionally, this patch (and the next) would overwrite those initial settings.
I don't know to what extent the same may be true for the other, platform-specific, drivers changed by this patch. But it's something to be aware of.
Alan Stern
A message that is not in the archive (sent off-list or not yet received): Pine.LNX.4.44L0.1309231418030.1348-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org
Re: [PATCH 36/51] DMA-API: usb: use dma_set_coherent_mask()
Quoted 33 lines · Alan Stern
Quoted 15 lines · Russell King
The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use
dma_set_coherent_mask(). Only arch and bus code should access this member directly.Convert all direct write accesses to using the correct API.
Signed-off-by Russell King <rmk+kernel-lFZ/[email protected]>drivers/usb/host/ehci-platform.c +0
-0drivers/usb/host/ehci-platform.c static int ehci_platform_probe(struct platform_device *dev) · line 98
Quoted 10 lines
drivers/usb/host/ehci-platform.c +3
-2@@ -91,8 +91,9 @@ static int ehci_platform_probe(struct platform_device *dev) dev->dev.platform_data = &ehci_platform_defaults;if (!dev->dev.dma_mask) dev->dev.dma_mask = &dev->dev.coherent_dma_mask; -if (!dev->dev.coherent_dma_mask) - dev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + err =dma_set_coherent_mask (&dev->dev,DMA_BIT_MASK (32 )); +if (err) +return err; pdata =dev_get_platdata (&dev->dev);
ehci-platform.cis a generic file, intended for use by multiple platforms. Is it not possible that on some platforms, the arch or bus code may already have initialized the DMA masks? Isn't something like this (i.e., DMA bindings) planned for Device Tree?
Quoted 7 lines
By eliminating the tests above and calling
dma_set_coherent_maskordma_coerce_mask_and_coherentunconditionally, this patch (and the next) would overwrite those initial settings.I don't know to what extent the same may be true for the other, platform-specific, drivers changed by this patch. But it's something to be aware of.
Please check the DMA API documentation:
=====
For correct operation, you must interrogate the kernel in your device probe routine to see if the DMA controller on the machine can properly support the DMA addressing limitation your device has. It is good style to do this even if your device holds the default setting, because this shows that you did think about these issues wrt. your device.
The query is performed via a call to dma_set_mask():
int dma_set_mask(struct device *dev, u64 mask);
The query for consistent allocations is performed via a call to dma_set_coherent_mask():
int dma_set_coherent_mask(struct device *dev, u64 mask);
=====
So, All drivers which use DMA are supposed to issue the appropriate calls to check the DMA masks before they perform DMA, even if the "default" is correct.
And yes, this is all part of sorting out the DT mess - we should start not from the current mess (which is really totally haphazard) but from the well established position of how the DMA API _should_ be used. What that means is that all drivers should be issuing these calls as appropriate today.
The default mask setup when the device is created is just that - it's a default mask, and it should not be used to decide anything about the device. That's something which the driver should compute on its own accord and then inform the various other layers via the appropriate call.
Remember, on PCI, even when we have 64-bit, we do not declare PCI devices with a 64-bit DMA mask: that's up to PCI device drivers to _try_ to set a 64-bit DMA mask, which when successful _allows_ them to use 64-bit DMA. If it fails, they have to only use 32-bit. If they want a smaller mask, the _driver_ has to set the smaller mask, not the device creating code.
The reason we're into this (particularly on ARM) is that we got lazy because we could get by with declaring a DMA mask at device creation time, since all devices were statically declared. Now it's time to get rid of those old lazy ways and start doing things correctly and to the requirements of the APIs.
PATCH 37/51 DMA-API: usb: use new dma_coerce_mask_and_coherent()
In reply to Russell King - ARM Linux--- drivers/usb/chipidea/ci_hdrc_imx.c | 4 +--- drivers/usb/dwc3/dwc3-exynos.c | 4 +--- drivers/usb/host/ehci-atmel.c | 4 +--- drivers/usb/host/ehci-omap.c | 4 +--- drivers/usb/host/ehci-orion.c | 4 +--- drivers/usb/host/ehci-platform.c | 5 ++--- drivers/usb/host/ehci-s5p.c | 4 +--- drivers/usb/host/ehci-spear.c | 4 +--- drivers/usb/host/ehci-tegra.c | 4 +--- drivers/usb/host/ohci-at91.c | 4 +--- drivers/usb/host/ohci-exynos.c | 4 +--- drivers/usb/host/ohci-nxp.c | 3 +-- drivers/usb/host/ohci-octeon.c | 3 +-- drivers/usb/host/ohci-omap3.c | 4 +--- drivers/usb/host/ohci-pxa27x.c | 4 +--- drivers/usb/host/ohci-spear.c | 4 +--- drivers/usb/host/uhci-platform.c | 4 +--- 17 files changed, 18 insertions(+), 49 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +1 -3
@@ -121,9 +121,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) pdata.phy = data->phy; -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (ret) goto err_clk;
drivers/usb/dwc3/dwc3-exynos.c +1 -3
@@ -119,9 +119,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we move to full device tree support this will vanish off. */ -if (!dev->dma_mask) - dev->dma_mask = &dev->coherent_dma_mask; - ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (32 ));if (ret) goto err1;
drivers/usb/host/ehci-atmel.c +1 -3
@@ -90,9 +90,7 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + retval =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (retval) goto fail_create_hcd;
drivers/usb/host/ehci-omap.c +1 -3
@@ -144,9 +144,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!dev->dma_mask) - dev->dma_mask = &dev->coherent_dma_mask; - ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (32 ));if (ret)return ret;
drivers/usb/host/ehci-orion.c +1 -3
@@ -180,9 +180,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)* set. Since shared usb code relies on it, set it here for * now. Once we have dma capability bindings this can go away. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) goto err1;
drivers/usb/host/ehci-platform.c +2 -3
@@ -89,9 +89,8 @@ static int ehci_platform_probe(struct platform_device *dev)*/ if (!dev_get_platdata (&dev->dev)) dev->dev.platform_data = &ehci_platform_defaults; -if (!dev->dev.dma_mask) - dev->dev.dma_mask = &dev->dev.coherent_dma_mask; - err =dma_set_coherent_mask (&dev->dev,DMA_BIT_MASK (32 )); + + err =dma_coerce_mask_and_coherent (&dev->dev,DMA_BIT_MASK (32 ));if (err)return err;
drivers/usb/host/ehci-s5p.c +1 -3
@@ -89,9 +89,7 @@ static int s5p_ehci_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we move to full device tree support this will vanish off. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err)return err;
drivers/usb/host/ehci-spear.c +1 -3
@@ -81,9 +81,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + retval =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (retval) goto fail;
drivers/usb/host/ehci-tegra.c +1 -3
@@ -362,9 +362,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err)return err;
drivers/usb/host/ohci-at91.c +1 -3
@@ -536,9 +536,7 @@ static int ohci_at91_of_init(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (ret)return ret;
drivers/usb/host/ohci-exynos.c +1 -3
@@ -114,9 +114,7 @@ static int exynos_ohci_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we move to full device tree support this will vanish off. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - err =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + err =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err)return err;
drivers/usb/host/ohci-nxp.c +1 -2
@@ -226,8 +226,7 @@ static int usb_hcd_nxp_probe(struct platform_device *pdev)return -EPROBE_DEFER ; } - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (ret) goto fail_disable;
drivers/usb/host/ohci-octeon.c +1 -2
@@ -127,8 +127,7 @@ static int ohci_octeon_drv_probe(struct platform_device *pdev) }/* Ohci is a 32-bit device. */ - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (ret)return ret;
drivers/usb/host/ohci-omap3.c +1 -3
@@ -166,9 +166,7 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!dev->dma_mask) - dev->dma_mask = &dev->coherent_dma_mask; - ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (32 ));if (ret) goto err_io;
drivers/usb/host/ohci-pxa27x.c +1 -3
@@ -296,9 +296,7 @@ static int ohci_pxa_of_init(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (ret)return ret;
drivers/usb/host/ohci-spear.c +1 -3
@@ -111,9 +111,7 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + retval =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (retval) goto fail;
drivers/usb/host/uhci-platform.c +1 -3
@@ -75,9 +75,7 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (ret)return ret;
Signature · 1 line
1.7.4.4
Re: [PATCH 37/51] DMA-API: usb: use new dma_coerce_mask_and_coherent()
Hi,
Quoted 20 lines · Russell King
drivers/usb/dwc3/dwc3-exynos.c +1
-3@@ -119,9 +119,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we move to full device tree support this will vanish off. */ -if (!dev->dma_mask) - dev->dma_mask = &dev->coherent_dma_mask; - ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (32 ));if (ret) goto err1;drivers/usb/host/ehci-omap.c +0
-0
drivers/usb/host/ehci-omap.c static int ehci_hcd_omap_probe(struct platform_device *pdev) · line 149
Quoted 9 lines
drivers/usb/host/ehci-omap.c +1
-3@@ -144,9 +144,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!dev->dma_mask) - dev->dma_mask = &dev->coherent_dma_mask; - ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); + ret =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (32 ));if (ret)return ret;
for dwc3 and ehci-omap:
Signature · 1 line
balbi
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
A message that is not in the archive (sent off-list or not yet received): E1VMmIV-0007jw-Gq-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org
Nicolas Ferre
Acked-byRe: [PATCH 37/51] DMA-API: usb: use new dma_coerce_mask_and_coherent()
On 20/09/2013 00:02, Russell King :
Quoted 5 lines
Signed-off-by Russell King <rmk+kernel-lFZ/[email protected]>--- drivers/usb/chipidea/ci_hdrc_imx.c | 4 +--- drivers/usb/dwc3/dwc3-exynos.c | 4 +--- drivers/usb/host/ehci-atmel.c | 4 +---
For Atmel driver:
[..]
Quoted 5 lines
drivers/usb/host/ehci-atmel.c +0
-0
drivers/usb/host/ehci-atmel.c static int ehci_atmel_drv_probe(struct platform_device *pdev) · line 96
Quoted 10 lines
drivers/usb/host/ehci-atmel.c +1
-3@@ -90,9 +90,7 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - retval =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + retval =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (retval) goto fail_create_hcd;
[..]
Thanks Russell,
Signature · 5 lines
Nicolas Ferre -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 38/51 DMA-API: staging: use dma_set_coherent_mask()
In reply to Russell King - ARM LinuxThe correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use dma_set_coherent_mask(). Only arch and bus code should access this member directly.
Convert all direct write accesses to using the correct API.
--- drivers/staging/dwc2/platform.c | 5 +++-- drivers/staging/imx-drm/imx-drm-core.c | 8 ++++++-- drivers/staging/imx-drm/ipuv3-crtc.c | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-)
drivers/staging/dwc2/platform.c +3 -2
@@ -100,8 +100,9 @@ static int dwc2_driver_probe(struct platform_device *dev)*/ if (!dev->dev.dma_mask) dev->dev.dma_mask = &dev->dev.coherent_dma_mask; -if (!dev->dev.coherent_dma_mask) - dev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + retval =dma_set_coherent_mask (&dev->dev,DMA_BIT_MASK (32 )); +if (retval) +return retval; irq =platform_get_irq (dev,0 );if (irq <0 ) {
drivers/staging/imx-drm/imx-drm-core.c +6 -2
@@ -805,6 +805,12 @@ static struct drm_driver imx_drm_driver = {static int imx_drm_platform_probe (struct platform_device *pdev) { +int ret; + + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; + imx_drm_device->dev = &pdev->dev;return drm_platform_init (&imx_drm_driver, pdev);
@@ -847,8 +853,6 @@ static int __init imx_drm_init(void) goto err_pdev; } - imx_drm_pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ), - ret =platform_driver_register (&imx_drm_pdrv);if (ret) goto err_pdrv;
drivers/staging/imx-drm/ipuv3-crtc.c +3 -1
@@ -523,7 +523,9 @@ static int ipu_drm_probe(struct platform_device *pdev)if (!pdata)return -EINVAL ; - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; ipu_crtc =devm_kzalloc (&pdev->dev,sizeof (*ipu_crtc),GFP_KERNEL );if (!ipu_crtc)
Signature · 1 line
1.7.4.4
PATCH 39/51 DMA-API: others: use dma_set_coherent_mask()
In reply to Russell King - ARM LinuxThe correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use dma_set_coherent_mask(). Only arch and bus code should access this member directly.
Convert all direct write accesses to using the correct API.
--- drivers/ata/pata_ixp4xx_cf.c | 5 ++++- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 +++++- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/ata/pata_ixp4xx_cf.c +4 -1
@@ -144,6 +144,7 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)struct ata_host *host;struct ata_port *ap;struct ixp4xx_pata_data *data =dev_get_platdata (&pdev->dev); +int ret; cs0 =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); cs1 =platform_get_resource (pdev,IORESOURCE_MEM ,1 );
@@ -157,7 +158,9 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)return -ENOMEM ;/* acquire resources and fill host */ - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; data->cs0 =devm_ioremap (&pdev->dev, cs0->start,0x1000 ); data->cs1 =devm_ioremap (&pdev->dev, cs1->start,0x1000 );
drivers/gpu/drm/exynos/exynos_drm_drv.c +5 -1
@@ -286,7 +286,11 @@ static struct drm_driver exynos_drm_driver = {static int exynos_drm_platform_probe (struct platform_device *pdev) { - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); +int ret; + + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;return drm_platform_init (&exynos_drm_driver, pdev); }
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +3 -2
@@ -664,8 +664,9 @@ static int omap_dmm_probe(struct platform_device *dev) }/* set dma mask for device */ -/* NOTE: this is a workaround for the hwmod not initializing properly */ - dev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&dev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto fail; omap_dmm->dummy_pa =page_to_phys (omap_dmm->dummy_page);
Signature · 1 line
1.7.4.4
Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()
Quoted 8 lines · Russell King
The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use
dma_set_coherent_mask(). Only arch and bus code should access this member directly.Convert all direct write accesses to using the correct API.
Signed-off-by Russell King <[email protected]>
The patch is pretty widely spread. I don't mind how it gets routed but what's the plan?
Thanks.
Signature · 1 line
tejun
Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()
Quoted 6 lines · Tejun Heo
Quoted 5 lines · Russell King
The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use
dma_set_coherent_mask(). Only arch and bus code should access this member directly.
Quoted 8 lines
Quoted 3 lines
Convert all direct write accesses to using the correct API.
Signed-off-by Russell King <[email protected]>Acked-by Tejun Heo <[email protected]>The patch is pretty widely spread. I don't mind how it gets routed but what's the plan?
Hmm... maybe hte pata_ixp4xx_cf.c part should be moved to the one which updates pata_octeon_cf.c?
Thanks.
Signature · 1 line
tejun
Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()
In reply to Tejun HeoQuoted 6 lines · Tejun Heo
Quoted 5 lines · Russell King
The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use
dma_set_coherent_mask(). Only arch and bus code should access this member directly.
Quoted 8 lines
Quoted 3 lines
Convert all direct write accesses to using the correct API.
Signed-off-by Russell King <[email protected]>Acked-by Tejun Heo <[email protected]>The patch is pretty widely spread. I don't mind how it gets routed but what's the plan?
The plan is... I'm going to try and avoid going through the hell of re-posting this patch series to all the recipients another time... (It's taken some 17 hours and lots of hand holding to get this patch set out without exim jumping off a cliff into deep OOM - soo deep that even the OOM killer doesn't run and the CPU is 100% idle because every single process stuck in an uninterruptible sleep waiting for every other process to free some memory - ouch!)
I know that dealing with this patch set will be a problem due to how widespread this is, but much of the driver level changes come down to depending on a couple of patches. One solution would be if I published a branch with just the dependencies in, which subsystem maintainers could pull, and then apply the appropriate patches on top.
Another would be if subsystem maintainers are happy that I carry them, I can add the acks, and then later on towards the end of the cycle, provide a branch subsystem maintainers could pull.
Or... if you can think of something easier...
Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()
Hey,
Quoted 5 lines · Russell King - ARM Linux
Another would be if subsystem maintainers are happy that I carry them, I can add the acks, and then later on towards the end of the cycle, provide a branch subsystem maintainers could pull.
Or... if you can think of something easier...
I'm happy with the latter method and it's likely that you'll end up carrying at least some of the patches through your tree anyway. Please feel free to add my acks to all libata related patches and carry them through your tree.
Thanks and have fun routing.
Signature · 1 line
tejun
Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()
In reply to Russell KingHi,
Quoted 59 lines · Russell King
The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use
dma_set_coherent_mask(). Only arch and bus code should access this member directly.Convert all direct write accesses to using the correct API.
Signed-off-by Russell King <[email protected]>--- drivers/ata/pata_ixp4xx_cf.c | 5 ++++- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 +++++- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-)drivers/ata/pata_ixp4xx_cf.c +4
-1@@ -144,6 +144,7 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)struct ata_host *host;struct ata_port *ap;struct ixp4xx_pata_data *data =dev_get_platdata (&pdev->dev); +int ret; cs0 =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); cs1 =platform_get_resource (pdev,IORESOURCE_MEM ,1 );@@ -157,7 +158,9 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)return -ENOMEM ;/* acquire resources and fill host */ - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; data->cs0 =devm_ioremap (&pdev->dev, cs0->start,0x1000 ); data->cs1 =devm_ioremap (&pdev->dev, cs1->start,0x1000 );drivers/gpu/drm/exynos/exynos_drm_drv.c +5
-1@@ -286,7 +286,11 @@ static struct drm_driver exynos_drm_driver = {static int exynos_drm_platform_probe (struct platform_device *pdev) { - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); +int ret; + + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;return drm_platform_init (&exynos_drm_driver, pdev); }drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +0
-0
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c static int omap_dmm_probe(struct platform_device *dev) · line 669
Quoted 8 lines
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +3
-2@@ -664,8 +664,9 @@ static int omap_dmm_probe(struct platform_device *dev) }/* set dma mask for device */ -/* NOTE: this is a workaround for the hwmod not initializing properly */ - dev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&dev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto fail;
Tested with omapdrm on omap4 panda es board.
Thanks,
Archit
Russell King - ARM Linux
Tested-by Archit TanejaRe: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()
Quoted 64 lines · Archit Taneja
Hi,
Quoted 61 lines · Russell King
The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use
dma_set_coherent_mask(). Only arch and bus code should access this member directly.Convert all direct write accesses to using the correct API.
Signed-off-by Russell King <[email protected]>--- drivers/ata/pata_ixp4xx_cf.c | 5 ++++- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 +++++- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-)drivers/ata/pata_ixp4xx_cf.c +4
-1@@ -144,6 +144,7 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)struct ata_host *host;struct ata_port *ap;struct ixp4xx_pata_data *data =dev_get_platdata (&pdev->dev); +int ret; cs0 =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); cs1 =platform_get_resource (pdev,IORESOURCE_MEM ,1 );@@ -157,7 +158,9 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)return -ENOMEM ;/* acquire resources and fill host */ - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; data->cs0 =devm_ioremap (&pdev->dev, cs0->start,0x1000 ); data->cs1 =devm_ioremap (&pdev->dev, cs1->start,0x1000 );drivers/gpu/drm/exynos/exynos_drm_drv.c +5
-1@@ -286,7 +286,11 @@ static struct drm_driver exynos_drm_driver = {static int exynos_drm_platform_probe (struct platform_device *pdev) { - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); +int ret; + + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;return drm_platform_init (&exynos_drm_driver, pdev); }drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +0
-0@@ -664,8 +664,9 @@ static int omap_dmm_probe(struct platform_device *dev) }
Quoted 8 lines
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c static int omap_dmm_probe(struct platform_device *dev) · line 669
Quoted 6 lines
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +3
-2/* set dma mask for device */ -/* NOTE: this is a workaround for the hwmod not initializing properly */ - dev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&dev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto fail;Tested with omapdrm on omap4 panda es board.
Just wish to make sure - that's code for:
to be added?
Thanks.
Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()
Quoted 74 lines · Russell King - ARM Linux
Quoted 64 lines · Archit Taneja
Hi,
Quoted 61 lines · Russell King
The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use
dma_set_coherent_mask(). Only arch and bus code should access this member directly.Convert all direct write accesses to using the correct API.
Signed-off-by Russell King <[email protected]>--- drivers/ata/pata_ixp4xx_cf.c | 5 ++++- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 +++++- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-)drivers/ata/pata_ixp4xx_cf.c +4
-1@@ -144,6 +144,7 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)struct ata_host *host;struct ata_port *ap;struct ixp4xx_pata_data *data =dev_get_platdata (&pdev->dev); +int ret; cs0 =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); cs1 =platform_get_resource (pdev,IORESOURCE_MEM ,1 );@@ -157,7 +158,9 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)return -ENOMEM ;/* acquire resources and fill host */ - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret; data->cs0 =devm_ioremap (&pdev->dev, cs0->start,0x1000 ); data->cs1 =devm_ioremap (&pdev->dev, cs1->start,0x1000 );drivers/gpu/drm/exynos/exynos_drm_drv.c +5
-1@@ -286,7 +286,11 @@ static struct drm_driver exynos_drm_driver = {static int exynos_drm_platform_probe (struct platform_device *pdev) { - pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); +int ret; + + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) +return ret;return drm_platform_init (&exynos_drm_driver, pdev); }drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +0
-0@@ -664,8 +664,9 @@ static int omap_dmm_probe(struct platform_device *dev) }Quoted 8 lines
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c static int omap_dmm_probe(struct platform_device *dev) · line 669
Quoted 6 lines
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +3
-2/* set dma mask for device */ -/* NOTE: this is a workaround for the hwmod not initializing properly */ - dev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); + ret =dma_set_coherent_mask (&dev->dev,DMA_BIT_MASK (32 )); +if (ret) + goto fail;Tested with omapdrm on omap4 panda es board.
Quoted 5 lines
Just wish to make sure - that's code for:
Tested-by Archit Taneja <[email protected]>to be added?
Sure :)
Thanks,
Archit
PATCH 40/51 DMA-API: crypto: fix ixp4xx crypto platform device support
In reply to Russell King - ARM LinuxDon't statically allocate struct device's in modules, and shut the warning up with an empty release() function. There's a reason that warning is there and that's not for people to hide in this way. It's there to persuade people to use the correct APIs to allocate platform devices.
--- drivers/crypto/ixp4xx_crypto.c | 37 +++++++++++++++++-------------------- 1 files changed, 17 insertions(+), 20 deletions(-)
drivers/crypto/ixp4xx_crypto.c +17 -20
@@ -218,23 +218,10 @@ static dma_addr_t crypt_phys;static int support_aes =1 ; -static void dev_release (struct device *dev) -{ -return ; -} -#define DRIVER_NAME "ixp4xx_crypto" -static struct platform_device pseudo_dev = { - .name =DRIVER_NAME , - .id =0 , - .num_resources =0 , - .dev = { - .coherent_dma_mask =DMA_BIT_MASK (32 ), - .release = dev_release, - } -}; -static struct device *dev = &pseudo_dev.dev; +static struct platform_device *pdev; +static struct device *dev;static inline dma_addr_t crypt_virt2phys (struct crypt_ctl *virt) {
@@ -1418,20 +1405,30 @@ static struct ixp_alg ixp4xx_algos[] = { } };#define IXP_POSTFIX "-ixp4xx" + +static const struct platform_device_info ixp_dev_info__initdata = { + .name =DRIVER_NAME , + .id =0 , + .dma_mask =DMA_BIT_MASK (32 ), +}; +static int __init ixp_module_init (void ) {int num =ARRAY_SIZE (ixp4xx_algos); -int i,err ; +int i, err ; -if (platform_device_register (&pseudo_dev)) -return -ENODEV ; + pdev =platform_device_register_full (&ixp_dev_info); +if (IS_ERR (pdev)) +return PTR_ERR (pdev); + + dev = &pdev->dev;spin_lock_init (&desc_lock);spin_lock_init (&emerg_lock); err =init_ixp_crypto ();if (err) { -platform_device_unregister (&pseudo_dev); +platform_device_unregister (pdev);return err; }for (i=0 ; i< num; i++) {
@@ -1496,7 +1493,7 @@ static void __exit ixp_module_exit(void)crypto_unregister_alg (&ixp4xx_algos[i].crypto); }release_ixp_crypto (); -platform_device_unregister (&pseudo_dev); +platform_device_unregister (pdev); }module_init (ixp_module_init);
Signature · 1 line
1.7.4.4
PATCH 41/51 DMA-API: crypto: remove last references to 'static struct device *dev'
In reply to Russell King - ARM Linux--- drivers/crypto/ixp4xx_crypto.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/crypto/ixp4xx_crypto.c +8 -5
@@ -221,7 +221,6 @@ static int support_aes = 1;#define DRIVER_NAME "ixp4xx_crypto"static struct platform_device *pdev; -static struct device *dev;static inline dma_addr_t crypt_virt2phys (struct crypt_ctl *virt) {
@@ -250,6 +249,7 @@ static inline const struct ix_hash_algo *ix_hash(struct crypto_tfm *tfm)static int setup_crypt_desc (void ) { +struct device *dev = &pdev->dev;BUILD_BUG_ON (sizeof (struct crypt_ctl ) !=64 ); crypt_virt = dma_alloc_coherent(dev, NPE_QLEN * sizeof(struct crypt_ctl),
@@ -350,6 +350,7 @@ static void finish_scattered_hmac(struct crypt_ctl *crypt)static void one_packet (dma_addr_t phys) { +struct device *dev = &pdev->dev;struct crypt_ctl *crypt;struct ixp_ctx *ctx;int failed;
@@ -419,7 +420,7 @@ static void crypto_done_action(unsigned long arg)tasklet_schedule (&crypto_done_tasklet); } -static int init_ixp_crypto (void ) +static int init_ixp_crypto (struct device *dev) {int ret = -ENODEV ;u32 msg[2 ] = {0 ,0 };
@@ -506,7 +507,7 @@ static int init_ixp_crypto(void)return ret; } -static void release_ixp_crypto (void ) +static void release_ixp_crypto (struct device *dev) {qmgr_disable_irq (RECV_QID );tasklet_kill (&crypto_done_tasklet);
@@ -873,6 +874,7 @@ static int ablk_perform(struct ablkcipher_request *req, int encrypt)enum dma_data_direction src_direction =DMA_BIDIRECTIONAL ;struct ablk_ctx *req_ctx =ablkcipher_request_ctx (req);struct buffer_desc src_hook; +struct device *dev = &pdev->dev;gfp_t flags = req->base.flags &CRYPTO_TFM_REQ_MAY_SLEEP ?GFP_KERNEL :GFP_ATOMIC ;
@@ -997,6 +999,7 @@ static int aead_perform(struct aead_request *req, int encrypt,unsigned int cryptlen;struct buffer_desc *buf, src_hook;struct aead_ctx *req_ctx =aead_request_ctx (req); +struct device *dev = &pdev->dev;gfp_t flags = req->base.flags &CRYPTO_TFM_REQ_MAY_SLEEP ?GFP_KERNEL :GFP_ATOMIC ;
@@ -1426,7 +1429,7 @@ static int __init ixp_module_init(void)spin_lock_init (&desc_lock);spin_lock_init (&emerg_lock); - err =init_ixp_crypto (); + err =init_ixp_crypto (&pdev->dev);if (err) {platform_device_unregister (pdev);return err;
@@ -1492,7 +1495,7 @@ static void __exit ixp_module_exit(void)if (ixp4xx_algos[i].registered)crypto_unregister_alg (&ixp4xx_algos[i].crypto); } -release_ixp_crypto (); +release_ixp_crypto (&pdev->dev);platform_device_unregister (pdev); }
Signature · 1 line
1.7.4.4
PATCH 42/51 DMA-API: usb: musb: use platform_device_register_full() to avoid directly messing with dma masks
In reply to Russell King - ARM LinuxUse platform_device_register_full() for those drivers which can, to avoid messing directly with DMA masks. This can only be done when the driver does not need to access the allocated musb platform device from within its callbacks, which may be called during the musb device probing.
--- drivers/usb/musb/am35x.c | 50 ++++++++++++++---------------------------- drivers/usb/musb/da8xx.c | 49 ++++++++++++++--------------------------- drivers/usb/musb/davinci.c | 48 ++++++++++++++-------------------------- drivers/usb/musb/tusb6010.c | 49 ++++++++++++++--------------------------- 4 files changed, 68 insertions(+), 128 deletions(-)
drivers/usb/musb/am35x.c +17 -33
@@ -89,7 +89,6 @@ struct am35x_glue {struct clk *phy_clk;struct clk *clk; }; -#define glue_to_musb (g) platform_get_drvdata(g->musb)/* * am35x_musb_enable - enable interrupts
@@ -452,14 +451,18 @@ static const struct musb_platform_ops am35x_ops = { .set_vbus = am35x_musb_set_vbus, }; -static u64 am35x_dmamask =DMA_BIT_MASK (32 ); +static const struct platform_device_info am35x_dev_info = { + .name ="musb-hdrc" , + .id =PLATFORM_DEVID_AUTO , + .dma_mask =DMA_BIT_MASK (32 ), +};static int am35x_probe (struct platform_device *pdev) {struct musb_hdrc_platform_data *pdata =dev_get_platdata (&pdev->dev);struct platform_device *musb;struct am35x_glue *glue; - +struct platform_device_info pinfo;struct clk *phy_clk;struct clk *clk;
@@ -471,12 +474,6 @@ static int am35x_probe(struct platform_device *pdev) goto err0; } - musb =platform_device_alloc ("musb-hdrc" ,PLATFORM_DEVID_AUTO ); -if (!musb) { -dev_err (&pdev->dev,"failed to allocate musb device\n" ); - goto err1; - } - phy_clk =clk_get (&pdev->dev,"fck" );if (IS_ERR (phy_clk)) {dev_err (&pdev->dev,"failed to get PHY clock\n" );
@@ -503,12 +500,7 @@ static int am35x_probe(struct platform_device *pdev) goto err6; } - musb->dev.parent = &pdev->dev; - musb->dev.dma_mask = &am35x_dmamask; - musb->dev.coherent_dma_mask = am35x_dmamask; - glue->dev = &pdev->dev; - glue->musb = musb; glue->phy_clk = phy_clk; glue->clk = clk;
@@ -516,22 +508,17 @@ static int am35x_probe(struct platform_device *pdev)platform_set_drvdata (pdev, glue); - ret =platform_device_add_resources (musb, pdev->resource, - pdev->num_resources); -if (ret) { -dev_err (&pdev->dev,"failed to add resources\n" ); - goto err7; - } - - ret =platform_device_add_data (musb, pdata,sizeof (*pdata)); -if (ret) { -dev_err (&pdev->dev,"failed to add platform_data\n" ); - goto err7; - } - - ret =platform_device_add (musb); -if (ret) { -dev_err (&pdev->dev,"failed to register musb device\n" ); + pinfo = am35x_dev_info; + pinfo.parent = &pdev->dev; + pinfo.res = pdev->resource; + pinfo.num_res = pdev->num_resources; + pinfo.data = pdata; + pinfo.size_data =sizeof (*pdata); + + glue->musb = musb =platform_device_register_full (&pinfo); +if (IS_ERR (musb)) { + ret =PTR_ERR (musb); +dev_err (&pdev->dev,"failed to register musb device: %d\n" , ret); goto err7; }
@@ -550,9 +537,6 @@ static int am35x_probe(struct platform_device *pdev)clk_put (phy_clk); err3: -platform_device_put (musb); - -err1:kfree (glue); err0:
drivers/usb/musb/da8xx.c +17 -32
86 lines not on this page · raw message
drivers/usb/musb/davinci.c +17 -31
85 lines not on this page · raw message
drivers/usb/musb/tusb6010.c +17 -32
80 lines not on this page · raw message
Signature · 1 line
1.7.4.4
Re: [PATCH 42/51] DMA-API: usb: musb: use platform_device_register_full() to avoid directly messing with dma masks
Hi,
Quoted 7 lines · Russell King
Use
platform_device_register_full()for those drivers which can, to avoid messing directly with DMA masks. This can only be done when the driver does not need to access the allocated musb platform device from within its callbacks, which may be called during the musb device probing.Signed-off-by Russell King <[email protected]>
you want me to carry this one through my tree or you prefer getting my Acked-by ? Either way works for me:
there's also the third option of me setting up a branch with only this patch and we both merge it, that'd also work.
cheers
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20130920/815d5ffb/attachment.sig>
Re: [PATCH 42/51] DMA-API: usb: musb: use platform_device_register_full() to avoid directly messing with dma masks
Quoted 11 lines · Felipe Balbi
Hi,
Quoted 7 lines · Russell King
Use
platform_device_register_full()for those drivers which can, to avoid messing directly with DMA masks. This can only be done when the driver does not need to access the allocated musb platform device from within its callbacks, which may be called during the musb device probing.Signed-off-by Russell King <[email protected]>
Quoted 7 lines
you want me to carry this one through my tree or you prefer getting my Acked-by ? Either way works for me:
Acked-by Felipe Balbi <[email protected]>there's also the third option of me setting up a branch with only this patch and we both merge it, that'd also work.
I think this patch is sufficiently stand-alone that it should be fine if you want to take it through your tree. That may be better in the long run to avoid conflicts with this patch and any future work in this area during this cycle.
Thanks.
Re: [PATCH 42/51] DMA-API: usb: musb: use platform_device_register_full() to avoid directly messing with dma masks
Hi,
Quoted 17 lines · Russell King - ARM Linux
Quoted 16 lines · Felipe Balbi
Hi,
Quoted 7 lines · Russell King
Use
platform_device_register_full()for those drivers which can, to avoid messing directly with DMA masks. This can only be done when the driver does not need to access the allocated musb platform device from within its callbacks, which may be called during the musb device probing.Signed-off-by Russell King <[email protected]>you want me to carry this one through my tree or you prefer getting my Acked-by ? Either way works for me:
Acked-by Felipe Balbi <[email protected]>
Quoted 7 lines
Quoted 2 lines
there's also the third option of me setting up a branch with only this patch and we both merge it, that'd also work.
I think this patch is sufficiently stand-alone that it should be fine if you want to take it through your tree. That may be better in the long run to avoid conflicts with this patch and any future work in this area during this cycle.
awesome, i'll take this one early next week.
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20130920/77a49f82/attachment.sig>
PATCH 45/51 DMA-API: firmware/google/gsmi.c: avoid direct access to DMA masks
In reply to Russell King - ARM LinuxThis driver doesn't need to directly access DMA masks if it uses the platform_device_register_full() API rather than platform_device_register_simple() - the former function can initialize the DMA mask appropriately.
--- drivers/firmware/google/gsmi.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/firmware/google/gsmi.c +8 -5
@@ -764,6 +764,13 @@ static __init int gsmi_system_valid(void)static struct kobject *gsmi_kobj;static struct efivars efivars; +static const struct platform_device_info gsmi_dev_info = { + .name ="gsmi" , + .id =-1 , +/* SMI callbacks require 32bit addresses */ + .dma_mask =DMA_BIT_MASK (32 ), +}; +static __init int gsmi_init (void ) {unsigned long flags;
@@ -776,7 +783,7 @@ static __init int gsmi_init(void) gsmi_dev.smi_cmd = acpi_gbl_FADT.smi_command;/* register device */ - gsmi_dev.pdev =platform_device_register_simple ("gsmi" ,-1 ,NULL ,0 ); + gsmi_dev.pdev =platform_device_register_full (&gsmi_dev_info);if (IS_ERR (gsmi_dev.pdev)) {printk (KERN_ERR "gsmi: unable to register platform device\n" );return PTR_ERR (gsmi_dev.pdev);
@@ -785,10 +792,6 @@ static __init int gsmi_init(void)/* SMI access needs to be serialized */ spin_lock_init (&gsmi_dev.lock); -/* SMI callbacks require 32bit addresses */ - gsmi_dev.pdev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); - gsmi_dev.pdev->dev.dma_mask = - &gsmi_dev.pdev->dev.coherent_dma_mask; ret = -ENOMEM ; gsmi_dev.dma_pool =dma_pool_create ("gsmi" , &gsmi_dev.pdev->dev,GSMI_BUF_SIZE ,GSMI_BUF_ALIGN ,0 );
Signature · 1 line
1.7.4.4
PATCH 46/51 ARM: DMA-API: better handing of DMA masks for coherent allocations
In reply to Russell King - ARM LinuxWe need to start treating DMA masks as something which is specific to the bus that the device resides on, otherwise we're going to hit all sorts of nasty issues with LPAE and 32-bit DMA controllers in >32-bit systems, where memory is offset from PFN 0.
In order to start doing this, we convert the DMA mask to a PFN using the device specific dma_to_pfn() macro. This is the reverse of the pfn_to_dma() macro which is used to get the DMA address for the device.
This gives us a PFN mask, which we can then check against the PFN limit of the DMA zone.
--- arch/arm/mm/dma-mapping.c | 49 ++++++++++++++++++++++++++++++++++++++++---- arch/arm/mm/init.c | 2 + arch/arm/mm/mm.h | 2 + 3 files changed, 48 insertions(+), 5 deletions(-)
arch/arm/mm/dma-mapping.c +44 -5
@@ -173,10 +173,30 @@ static u64 get_coherent_dma_mask(struct device *dev)return 0 ; } -if ((~mask) & (u64 )arm_dma_limit) { -dev_warn (dev,"coherent DMA mask %#llx is smaller " -"than system GFP_DMA mask %#llx\n" , - mask, (u64 )arm_dma_limit); +/* +* If the mask allows for more memory than we can address, +* and we actually have that much memory, then fail the +* allocation. +*/ +if (sizeof (mask) !=sizeof (dma_addr_t) && + mask > (dma_addr_t )~0 && +dma_to_pfn (dev, ~0 ) > arm_dma_pfn_limit) { +dev_warn (dev,"Coherent DMA mask %#llx is larger than dma_addr_t allows\n" , + mask); +dev_warn (dev,"Driver did not use or check the return value from dma_set_coherent_mask()?\n" ); +return 0 ; + } + +/* +* Now check that the mask, when translated to a PFN, +* fits within the allowable addresses which we can +* allocate. +*/ +if (dma_to_pfn (dev, mask) < arm_dma_pfn_limit) { +dev_warn (dev,"Coherent DMA mask %#llx (pfn %#lx-%#lx) covers a smaller range of system memory than the DMA zone pfn 0x0-%#lx\n" , + mask, +dma_to_pfn (dev,0 ),dma_to_pfn (dev, mask) +1 , + arm_dma_pfn_limit +1 );return 0 ; } }
@@ -1007,8 +1027,27 @@ void arm_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,*/ int dma_supported (struct device *dev,u64 mask) { -if (mask < (u64 )arm_dma_limit) +unsigned long limit; + +/* +* If the mask allows for more memory than we can address, +* and we actually have that much memory, then we must +* indicate that DMA to this device is not supported. +*/ +if (sizeof (mask) !=sizeof (dma_addr_t) && + mask > (dma_addr_t )~0 && +dma_to_pfn (dev, ~0 ) > arm_dma_pfn_limit) +return 0 ; + +/* +* Translate the device's DMA mask to a PFN limit. This +* PFN number includes the page which we can DMA to. +*/ + limit =dma_to_pfn (dev, mask); + +if (limit < arm_dma_pfn_limit)return 0 ; +return 1 ; }EXPORT_SYMBOL (dma_supported);
arch/arm/mm/init.c +2 -0
@@ -218,6 +218,7 @@ EXPORT_SYMBOL(arm_dma_zone_size);* so a successful GFP_DMA allocation will always satisfy this. */ phys_addr_t arm_dma_limit; +unsigned long arm_dma_pfn_limit;static void __init arm_adjust_dma_zone (unsigned long *size,unsigned long *hole,unsigned long dma_size)
@@ -240,6 +241,7 @@ void __init setup_dma_zone(const struct machine_desc *mdesc) arm_dma_limit = PHYS_OFFSET + arm_dma_zone_size - 1; }else arm_dma_limit =0xffffffff ; + arm_dma_pfn_limit = arm_dma_limit >>PAGE_SHIFT ;#endif }
arch/arm/mm/mm.h +2 -0
@@ -81,8 +81,10 @@ extern __init void add_static_vm_early(struct static_vm *svm);#ifdef CONFIG_ZONE_DMA extern phys_addr_t arm_dma_limit; +extern unsigned long arm_dma_pfn_limit;#else #define arm_dma_limit ((phys_addr_t)~0) +#define arm_dma_pfn_limit (~0ul >> PAGE_SHIFT)#endif extern phys_addr_t arm_lowmem_limit;
Signature · 1 line
1.7.4.4
PATCH 47/51 ARM: 7794/1: block: Rename parameter dma_mask to max_addr for blk_queue_bounce_limit()
In reply to Russell King - ARM LinuxFrom: Santosh Shilimkar <[email protected]>
The blk_queue_bounce_limit() API parameter 'dma_mask' is actually the maximum address the device can handle rather than a dma_mask. Rename it accordingly to avoid it being interpreted as dma_mask.
No functional change.
The idea is to fix the bad assumptions about dma_mask wherever it could be miss-interpreted.
--- block/blk-settings.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
block/blk-settings.c +4 -4
@@ -195,17 +195,17 @@ EXPORT_SYMBOL(blk_queue_make_request);/** * blk_queue_bounce_limit - set bounce buffer limit for queue * @q: the request queue for the device -* @dma_mask: the maximum address the device can handle +* @max_addr: the maximum address the device can handle * * Description: * Different hardware can have different requirements as to what pages * it can do I/O directly to. A low level driver can call * blk_queue_bounce_limit to have lower memory pages allocated as bounce -* buffers for doing I/O to pages residing above @dma_mask. +* buffers for doing I/O to pages residing above @max_addr. **/ -void blk_queue_bounce_limit (struct request_queue *q,u64 dma_mask) +void blk_queue_bounce_limit (struct request_queue *q,u64 max_addr) { -unsigned long b_pfn = dma_mask >>PAGE_SHIFT ; +unsigned long b_pfn = max_addr >>PAGE_SHIFT ;int dma =0 ; q->bounce_gfp =GFP_NOIO ;
Signature · 1 line
1.7.4.4
PATCH 48/51 ARM: 7795/1: mm: dma-mapping: Add dma_max_pfn(dev) helper function
In reply to Russell King - ARM LinuxFrom: Santosh Shilimkar <[email protected]>
Most of the kernel assumes that PFN0 is the start of the physical memory (RAM). This assumptions is not true on most of the ARM SOCs and hence and if one try to update the ARM port to follow the assumptions, we end of breaking the dma bounce limit for few block layer drivers. One such example is trying to unify the meaning of max*_pfn on ARM as the bootmem layer expects, breaks few block layer driver dma bounce limit.
To fix this problem, we introduce dma_max_pfn(dev) generic helper with a possibility of override from the architecture code. The helper converts a DMA bitmask of bits to a block PFN number. In all the generic cases, it is just "dev->dma_mask >> PAGE_SHIFT" and hence default behavior is maintained as is.
Subsequent patches will make use of the helper. No functional change.
--- include/linux/dma-mapping.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
include/linux/dma-mapping.h +7 -0
@@ -153,6 +153,13 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask)return -EIO ; } +#ifndef dma_max_pfn +static inline unsigned long dma_max_pfn (struct device *dev) +{ +return *dev->dma_mask >>PAGE_SHIFT ; +} +#endif +static inline void *dma_zalloc_coherent (struct device *dev,size_t size,dma_addr_t *dma_handle,gfp_t flag) {
Signature · 1 line
1.7.4.4
PATCH 49/51 ARM: 7796/1: scsi: Use dma_max_pfn(dev) helper for bounce_limit calculations
In reply to Russell King - ARM LinuxFrom: Santosh Shilimkar <[email protected]>
DMA bounce limit is the maximum direct DMA'able memory beyond which bounce buffers has to be used to perform dma operations. SCSI driver relies on dma_mask but its calculation is based on max_*pfn which don't have uniform meaning across architectures. So make use of dma_max_pfn() which is expected to return the DMAable maximum pfn value across architectures.
--- drivers/scsi/scsi_lib.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/scsi_lib.c +1 -1
@@ -1684,7 +1684,7 @@ u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost) host_dev =scsi_get_device (shost);if (host_dev && host_dev->dma_mask) - bounce_limit = *host_dev->dma_mask; + bounce_limit =dma_max_pfn (host_dev) <<PAGE_SHIFT ;return bounce_limit; }
Signature · 1 line
1.7.4.4
PATCH 50/51 ARM: 7797/1: mmc: Use dma_max_pfn(dev) helper for bounce_limit calculations
In reply to Russell King - ARM LinuxFrom: Santosh Shilimkar <[email protected]>
DMA bounce limit is the maximum direct DMA'able memory beyond which bounce buffers has to be used to perform dma operations. MMC queue layr relies on dma_mask but its calculation is based on max_*pfn which don't have uniform meaning across architectures. So make use of dma_max_pfn() which is expected to return the DMAable maximum pfn value across architectures.
--- drivers/mmc/card/queue.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/card/queue.c +2 -1
@@ -15,6 +15,7 @@#include <linux/freezer.h> #include <linux/kthread.h> #include <linux/scatterlist.h> +#include <linux/dma-mapping.h> #include <linux/mmc/card.h> #include <linux/mmc/host.h>
@@ -196,7 +197,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,struct mmc_queue_req *mqrq_prev = &mq->mqrq[1 ];if (mmc_dev (host)->dma_mask && *mmc_dev (host)->dma_mask) - limit = *mmc_dev (host)->dma_mask; + limit =dma_max_pfn (mmc_dev (host)) <<PAGE_SHIFT ; mq->card = card; mq->queue =blk_init_queue (mmc_request_fn, lock);
Signature · 1 line
1.7.4.4
PATCH 51/51 ARM: 7805/1: mm: change max*pfn to include the physical offset of memory
In reply to Russell King - ARM LinuxFrom: Santosh Shilimkar <[email protected]>
Most of the kernel code assumes that max*pfn is maximum pfns because the physical start of memory is expected to be PFN0. Since this assumption is not true on ARM architectures, the meaning of max*pfn is number of memory pages. This is done to keep drivers happy which are making use of of these variable to calculate the dma bounce limit using dma_mask.
Now since we have a architecture override possibility for DMAable maximum pfns, lets make meaning of max*pfns as maximum pnfs on ARM as well.
--- arch/arm/include/asm/dma-mapping.h | 8 ++++++++ arch/arm/mm/init.c | 10 ++++------ 2 files changed, 12 insertions(+), 6 deletions(-)
arch/arm/include/asm/dma-mapping.h +8 -0
@@ -64,6 +64,7 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) {return (dma_addr_t )__virt_to_bus ((unsigned long )(addr)); } +#else static inline dma_addr_t pfn_to_dma (struct device *dev,unsigned long pfn) {
@@ -86,6 +87,13 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) }#endif +/* The ARM override for dma_max_pfn() */ +static inline unsigned long dma_max_pfn (struct device *dev) +{ +return PHYS_PFN_OFFSET +dma_to_pfn (dev, *dev->dma_mask); +} +#define dma_max_pfn (dev) dma_max_pfn(dev) +/* * DMA errors are defined by all-bits-set in the DMA address. */
arch/arm/mm/init.c +4 -6
@@ -426,12 +426,10 @@ void __init bootmem_init(void)* This doesn't seem to be used by the Linux memory manager any * more, but is used by ll_rw_block. If we can get rid of it, we * also get rid of some of the stuff above as well. -* -* Note: max_low_pfn and max_pfn reflect the number of _pages_ in -* the system, not the maximum PFN. */ - max_low_pfn = max_low -PHYS_PFN_OFFSET ; - max_pfn = max_high -PHYS_PFN_OFFSET ; + min_low_pfn = min; + max_low_pfn = max_low; + max_pfn = max_high; }/*
@@ -537,7 +535,7 @@ static inline void free_area_high(unsigned long pfn, unsigned long end)static void __init free_highpages (void ) {#ifdef CONFIG_HIGHMEM -unsigned long max_low = max_low_pfn +PHYS_PFN_OFFSET ; +unsigned long max_low = max_low_pfn;struct memblock_region *mem, *res;/* set highmem page free */
Signature · 1 line
1.7.4.4
2013/9/19 Russell King - ARM Linux <[email protected]>:
Quoted 4 lines
This email is only being sent to the mailing lists in question, not to anyone personally. The list of individuals is far to great to do that. I'm hoping no mailing lists reject the patches based on the number of recipients.
Huh, I think it was enough to send only 3 patches to the b43-dev@. Like:
[PATCH 01/51] DMA-API: provide a helper to set both DMA and coherent DMA masks [PATCH 14/51] DMA-API: net: b43: (...)
[PATCH 15/51] DMA-API: net: b43legacy: (...)
;)
I believe Joe has some nice script for doing it that way. When fixing some coding style / formatting, he sends only related patches to the given ML.
Signature · 5 lines
Rafał -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 12 lines · Rafa? Mi?ecki
2013/9/19 Russell King - ARM Linux <[email protected]>:
Quoted 4 lines
This email is only being sent to the mailing lists in question, not to anyone personally. The list of individuals is far to great to do that. I'm hoping no mailing lists reject the patches based on the number of recipients.
Huh, I think it was enough to send only 3 patches to the b43-dev at . Like:
[PATCH 01/51] DMA-API: provide a helper to set both DMA and coherent DMA masks [PATCH 14/51] DMA-API: net: b43: (...)
[PATCH 15/51] DMA-API: net: b43legacy: (...)
;)
Quoted 3 lines
I believe Joe has some nice script for doing it that way. When fixing some coding style / formatting, he sends only related patches to the given ML.
If I did that, then the mailing lists would not get the first patch, because almost none of the lists would be referred to by patch 1.
Moreover, people complain when they don't have access to the full patch series - they assume patches are missing for some reason, and they ask for the rest of the series.