Re: [PATCH v11 0/8] PHY framework

2013-09-20 Thread Greg KH
On Fri, Sep 20, 2013 at 11:04:40AM +0530, Kishon Vijay Abraham I wrote:
 Hi Greg,
 
 On Tuesday 17 September 2013 09:11 PM, Felipe Balbi wrote:
  On Wed, Sep 04, 2013 at 02:27:06PM +0530, Kishon Vijay Abraham I wrote:
  On Tuesday 03 September 2013 09:20 PM, Greg KH wrote:
  On Tue, Sep 03, 2013 at 08:55:23PM +0530, Kishon Vijay Abraham I wrote:
  Hi Greg,
 
  On Wednesday 28 August 2013 12:50 AM, Felipe Balbi wrote:
  Hi,
 
  On Mon, Aug 26, 2013 at 01:44:49PM +0530, Kishon Vijay Abraham I wrote:
  On Wednesday 21 August 2013 11:16 AM, Kishon Vijay Abraham I wrote:
  Added a generic PHY framework that provides a set of APIs for the PHY 
  drivers
  to create/destroy a PHY and APIs for the PHY users to obtain a 
  reference to
  the PHY with or without using phandle.
 
  This framework will be of use only to devices that uses external PHY 
  (PHY
  functionality is not embedded within the controller).
 
  The intention of creating this framework is to bring the phy drivers 
  spread
  all over the Linux kernel to drivers/phy to increase code re-use and 
  to
  increase code maintainability.
 
  Comments to make PHY as bus wasn't done because PHY devices can be 
  part of
  other bus and making a same device attached to multiple bus leads to 
  bad
  design.
 
  If the PHY driver has to send notification on connect/disconnect, the 
  PHY
  driver should make use of the extcon framework. Using this susbsystem
  to use extcon framwork will have to be analysed.
 
  You can find this patch series @
  git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git 
  testing
 
  Looks like there are not further comments on this series. Can you take 
  this in
  your misc tree?
 
  Do you want me to queue these for you ? There are quite a few users for
  this framework already and I know of at least 2 others which will show
  up for v3.13.
 
  Can you queue this patch series? There are quite a few users already for 
  this
  framework.
 
  It will have to wait for 3.13 as the merge window for new features has
  been closed for a week or so.  Sorry, I'll queue this up after 3.12-rc1
  is out.
 
  Alright, thanks.
  
  Just a gentle ping on this one...
 
 Let me know if you want me to rebase this patch series on the latest mainline 
 HEAD.

Yes please.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Getting udev name from usb_device structure

2013-09-20 Thread Sergio Work
 Why would this be an LSM hook?  What's wrong with the existing solutions
 for this that are all in userspace today?

Because we want to apply the restriction of what USB pendrives can be
mounted to all the users of the system, including root. So we need to
perform this in kernel space, otherwise any other userspace solutions
can be manipulated by root.

I guess that it's a little difficult to understand all the deteails
without a whole image of the context, but I can't provide more details
since my NDA doesn't allow me :(

Anyway, if we doesn't consider such aspects, how could I obtain the
udev device name associated to a given usb_device structure.

Sergi
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] Patch Memory Mapping for USBFS

2013-09-20 Thread Markus Rechberger
On Fri, Sep 20, 2013 at 5:57 AM, Alan Stern st...@rowland.harvard.edu wrote:
 On Fri, 20 Sep 2013, Markus Rechberger wrote:

 to comment it by myself, memory should be cleared for not exposing
 uncleared memory to userspace
 and usbmem should be checked if(!mem), if(!usbmem). It will be in the
 next version.

 The next time you post a version of this patch, please make sure that
 your email client does not destroy the whitespace characters.


I was aware of that but I couldn't find an option within the gmail
client, that's why I added the link to the latest patch...

Markus
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] usb: gadget: Remove redundant pci_set_drvdata

2013-09-20 Thread Sachin Kamat
Driver core sets driver data to NULL upon failure or remove.

Signed-off-by: Sachin Kamat sachin.ka...@linaro.org
---
 drivers/usb/gadget/amd5536udc.c |2 --
 drivers/usb/gadget/goku_udc.c   |1 -
 drivers/usb/gadget/net2280.c|1 -
 drivers/usb/gadget/pch_udc.c|1 -
 4 files changed, 5 deletions(-)

diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index a9a4346..54a1e29 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -3078,8 +3078,6 @@ static void udc_pci_remove(struct pci_dev *pdev)
if (dev-active)
pci_disable_device(pdev);
 
-   pci_set_drvdata(pdev, NULL);
-
udc_remove(dev);
 }
 
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index c64deb9..74bb8df 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1701,7 +1701,6 @@ static void goku_remove(struct pci_dev *pdev)
if (dev-enabled)
pci_disable_device(pdev);
 
-   pci_set_drvdata(pdev, NULL);
dev-regs = NULL;
 
INFO(dev, unbind\n);
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 0781bff..9fbc8fe 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2680,7 +2680,6 @@ static void net2280_remove (struct pci_dev *pdev)
if (dev-enabled)
pci_disable_device (pdev);
device_remove_file (pdev-dev, dev_attr_registers);
-   pci_set_drvdata (pdev, NULL);
 
INFO (dev, unbind\n);
 }
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c
index 24174e1..32d5e92 100644
--- a/drivers/usb/gadget/pch_udc.c
+++ b/drivers/usb/gadget/pch_udc.c
@@ -3080,7 +3080,6 @@ static void pch_udc_remove(struct pci_dev *pdev)
if (dev-active)
pci_disable_device(pdev);
kfree(dev);
-   pci_set_drvdata(pdev, NULL);
 }
 
 #ifdef CONFIG_PM
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] usb: dwc3: Remove redundant pci_set_drvdata

2013-09-20 Thread Sachin Kamat
Driver core sets driver data to NULL upon failure or remove.

Signed-off-by: Sachin Kamat sachin.ka...@linaro.org
---
 drivers/usb/dwc3/dwc3-pci.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 997ebe4..f41ce36 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -164,7 +164,6 @@ static int dwc3_pci_probe(struct pci_dev *pci,
return 0;
 
 err3:
-   pci_set_drvdata(pci, NULL);
platform_device_put(dwc3);
 err1:
pci_disable_device(pci);
@@ -179,7 +178,6 @@ static void dwc3_pci_remove(struct pci_dev *pci)
platform_device_unregister(glue-dwc3);
platform_device_unregister(glue-usb2_phy);
platform_device_unregister(glue-usb3_phy);
-   pci_set_drvdata(pci, NULL);
pci_disable_device(pci);
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 51/51] ARM: 7805/1: mm: change max*pfn to include the physical offset of memory

2013-09-20 Thread Russell King
From: Santosh Shilimkar santosh.shilim...@ti.com

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.

Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 arch/arm/include/asm/dma-mapping.h |8 
 arch/arm/mm/init.c |   10 --
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/dma-mapping.h 
b/arch/arm/include/asm/dma-mapping.h
index 5b579b9..863cd84 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -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.
  */
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 8aab24f..d50533c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -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 */
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 50/51] ARM: 7797/1: mmc: Use dma_max_pfn(dev) helper for bounce_limit calculations

2013-09-20 Thread Russell King
From: Santosh Shilimkar santosh.shilim...@ti.com

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.

Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/mmc/card/queue.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index fa9632e..357bbc5 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -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);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 49/51] ARM: 7796/1: scsi: Use dma_max_pfn(dev) helper for bounce_limit calculations

2013-09-20 Thread Russell King
From: Santosh Shilimkar santosh.shilim...@ti.com

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.

Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/scsi/scsi_lib.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d1549b7..7bd7f0d 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -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;
 }
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 48/51] ARM: 7795/1: mm: dma-mapping: Add dma_max_pfn(dev) helper function

2013-09-20 Thread Russell King
From: Santosh Shilimkar santosh.shilim...@ti.com

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.

Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 include/linux/dma-mapping.h |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 27d1421..fd4aee2 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -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)
 {
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 47/51] ARM: 7794/1: block: Rename parameter dma_mask to max_addr for blk_queue_bounce_limit()

2013-09-20 Thread Russell King
From: Santosh Shilimkar santosh.shilim...@ti.com

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.

Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 block/blk-settings.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index c50ecf0..026c151 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -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;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 45/51] DMA-API: firmware/google/gsmi.c: avoid direct access to DMA masks

2013-09-20 Thread Russell King
This 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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/firmware/google/gsmi.c |   13 -
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index 6eb535f..e5a67b2 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -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);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 44/51] DMA-API: dcdbas: update DMA mask handing

2013-09-20 Thread Russell King
dcdbas 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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/firmware/dcdbas.c |   23 ---
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index ff080ee..a85fda2 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -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;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 46/51] ARM: DMA-API: better handing of DMA masks for coherent allocations

2013-09-20 Thread Russell King
We 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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 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(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index f5e1a84..13d55e1 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -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);
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index febaee7..8aab24f 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -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 = 0x;
+   arm_dma_pfn_limit = arm_dma_limit  PAGE_SHIFT;
 #endif
 }
 
diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h
index d5a4e9a..d5a982d 100644
--- a/arch/arm/mm/mm.h
+++ b/arch/arm/mm/mm.h
@@ -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;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 43/51] DMA-API: dma: edma.c: no need to explicitly initialize DMA masks

2013-09-20 Thread Russell King
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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/dma/edma.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index ff50ff4..7f9fe30 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -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:
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 42/51] DMA-API: usb: musb: use platform_device_register_full() to avoid directly messing with dma masks

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 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(-)

diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 5c310c6..790b22b 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -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:
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d9ddf41..2f2c1cb 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -472,7 +472,11 @@ static const struct musb_platform_ops da8xx_ops = {
.set_vbus   = da8xx_musb_set_vbus,
 };
 
-static u64 da8xx_dmamask = DMA_BIT_MASK(32);
+static const struct platform_device_info da8xx_dev_info = {
+   .name   = musb-hdrc,
+   .id = PLATFORM_DEVID_AUTO,
+   .dma_mask   = DMA_BIT_MASK(32),
+};
 
 static int da8xx_probe(struct platform_device *pdev)
 {
@@ -480,7 +484,7 @@ static int da8xx_probe(struct platform_device *pdev)
struct musb_hdrc_platform_data  *pdata = dev_get_platdata(pdev-dev);
struct platform_device  *musb;
struct da8xx_glue   *glue;
-
+   struct platform_device_info pinfo;
struct clk 

[PATCH 41/51] DMA-API: crypto: remove last references to 'static struct device *dev'

2013-09-20 Thread Russell King
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/crypto/ixp4xx_crypto.c |   13 -
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 8306185..214357e 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -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);
 }
 
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()

2013-09-20 Thread 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+ker...@arm.linux.org.uk
---
 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(-)

diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index 1ec53f8..ddf470c 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -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);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index bb82ef7..81192d0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -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);
 }
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c 
b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index acf6678..701c4c1 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -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);
 
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/51] DMA-API: amba: get rid of separate dma_mask

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/amba/bus.c   |6 +-
 drivers/of/platform.c|3 ---
 include/linux/amba/bus.h |2 --
 3 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index c670727..c4876ac 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -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);
 }
 
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 9b439ac..54382ba 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -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)
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index 43ec7e2..682df0e 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -30,7 +30,6 @@ struct amba_device {
struct device   dev;
struct resource res;
struct clk  *pclk;
-   u64 dma_mask;
unsigned intperiphid;
unsigned intirq[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, \
 }
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
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

2013-09-20 Thread 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+ker...@arm.linux.org.uk
---
 drivers/dma/pl330.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index a562d24..df8b10f 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -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) {
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/51] DMA-API: net: emulex/benet: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/net/ethernet/emulex/benet/be_main.c |   12 ++--
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 3224d28..2084151 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -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;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/51] DMA-API: net: sfc/efx.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/net/ethernet/sfc/efx.c |   12 +---
 1 files changed, 1 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index 07c9bc4..2e27837 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -1121,7 +1121,7 @@ static int efx_init_io(struct efx_nic *efx)
 */
while (dma_mask  0x7fffUL) {
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);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/51] DMA-API: staging: et131x: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/staging/et131x/et131x.c |   17 ++---
 1 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index f73e58f..98edfa8 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -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;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/51] DMA-API: block: nvme-core: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/block/nvme-core.c |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index da52092..26d03fa 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -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;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/51] DMA-API: net: broadcom/bnx2x: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 2f8dbbb..e6c3e66 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -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;
}
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/51] DMA-API: net: b43legacy: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/net/wireless/b43legacy/dma.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/b43legacy/dma.c 
b/drivers/net/wireless/b43legacy/dma.c
index 42eb26c..b2ed179 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -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;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/1] usb: gadget: f_fs: Add support for SuperSpeed Mode

2013-09-20 Thread Manu Gautam
Allow userspace to pass SuperSpeed descriptors and
handle them in the driver accordingly.
This also requires changing usb_functionfs_descs_head
to accommodate ss_count i.e. SuperSpeed Descriptors
count.

Signed-off-by: Manu Gautam mgau...@codeaurora.org
---
 drivers/usb/gadget/f_fs.c   | 148 +++-
 include/uapi/linux/usb/functionfs.h |   5 +-
 2 files changed, 115 insertions(+), 38 deletions(-)

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index f394f29..95a5746 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -194,16 +194,18 @@ struct ffs_data {
 
/* filled by __ffs_data_got_descs() */
/*
-* Real descriptors are 16 bytes after raw_descs (so you need
-* to skip 16 bytes (ie. ffs-raw_descs + 16) to get to the
-* first full speed descriptor).  raw_descs_length and
-* raw_fs_descs_length do not have those 16 bytes added.
+* Real descriptors are 20 bytes after raw_descs (so you need
+* to skip 20 bytes (ie. ffs-raw_descs + 20) to get to the
+* first full speed descriptor).  raw_(fs|hs|ss)descs_length
+* do not have those 20 bytes added.
 */
const void  *raw_descs;
-   unsignedraw_descs_length;
+   unsignedraw_hs_descs_length;
unsignedraw_fs_descs_length;
+   unsignedraw_ss_descs_length;
unsignedfs_descs_count;
unsignedhs_descs_count;
+   unsignedss_descs_count;
 
unsigned short  strings_count;
unsigned short  interfaces_count;
@@ -301,8 +303,8 @@ struct ffs_ep {
struct usb_ep   *ep;/* P: ffs-eps_lock */
struct usb_request  *req;   /* P: epfile-mutex */
 
-   /* [0]: full speed, [1]: high speed */
-   struct usb_endpoint_descriptor  *descs[2];
+   /* [0]: full speed, [1]: high speed, [2]: super speed */
+   struct usb_endpoint_descriptor  *descs[3];
 
u8  num;
 
@@ -1358,10 +1360,12 @@ static void ffs_data_reset(struct ffs_data *ffs)
ffs-raw_strings = NULL;
ffs-stringtabs = NULL;
 
-   ffs-raw_descs_length = 0;
+   ffs-raw_hs_descs_length = 0;
ffs-raw_fs_descs_length = 0;
+   ffs-raw_ss_descs_length = 0;
ffs-fs_descs_count = 0;
ffs-hs_descs_count = 0;
+   ffs-ss_descs_count = 0;
 
ffs-strings_count = 0;
ffs-interfaces_count = 0;
@@ -1569,7 +1573,20 @@ static int ffs_func_eps_enable(struct ffs_function *func)
spin_lock_irqsave(func-ffs-eps_lock, flags);
do {
struct usb_endpoint_descriptor *ds;
-   ds = ep-descs[ep-descs[1] ? 1 : 0];
+   int desc_idx;
+
+   if (ffs-gadget-speed == USB_SPEED_SUPER)
+   desc_idx = 2;
+   else if (ffs-gadget-speed == USB_SPEED_HIGH)
+   desc_idx = 1;
+   else
+   desc_idx = 0;
+
+   ds = ep-descs[desc_idx];
+   if (!ds) {
+   ret = -EINVAL;
+   break;
+   }
 
ep-ep-driver_data = ep;
ep-ep-desc = ds;
@@ -1704,6 +1721,12 @@ static int __must_check ffs_do_desc(char *data, unsigned 
len,
}
break;
 
+   case USB_DT_SS_ENDPOINT_COMP:
+   pr_vdebug(EP SS companion descriptor\n);
+   if (length != sizeof(struct usb_ss_ep_comp_descriptor))
+   goto inv_length;
+   break;
+
case USB_DT_OTHER_SPEED_CONFIG:
case USB_DT_INTERFACE_POWER:
case USB_DT_DEBUG:
@@ -1814,8 +1837,8 @@ static int __ffs_data_do_entity(enum ffs_entity_type type,
 static int __ffs_data_got_descs(struct ffs_data *ffs,
char *const _data, size_t len)
 {
-   unsigned fs_count, hs_count;
-   int fs_len, ret = -EINVAL;
+   unsigned fs_count, hs_count, ss_count;
+   int fs_len, hs_len, ss_len, ret = -EINVAL;
char *data = _data;
 
ENTER();
@@ -1825,12 +1848,13 @@ static int __ffs_data_got_descs(struct ffs_data *ffs,
goto error;
fs_count = get_unaligned_le32(data +  8);
hs_count = get_unaligned_le32(data + 12);
+   ss_count = get_unaligned_le32(data + 16);
 
-   if (!fs_count  !hs_count)
+   if (!fs_count  !hs_count  !ss_count)
goto einval;
 
-   data += 16;
-   len  -= 16;
+   data += 20;
+   len  -= 20;
 
if (likely(fs_count)) {
fs_len = ffs_do_descs(fs_count, data, len,
@@ -1847,11 +1871,29 @@ static int __ffs_data_got_descs(struct ffs_data *ffs,
}
 
if (likely(hs_count)) {

[PATCH 20/51] DMA-API: usb: bcma: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/usb/host/bcma-hcd.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
index df13d42..205f4a3 100644
--- a/drivers/usb/host/bcma-hcd.c
+++ b/drivers/usb/host/bcma-hcd.c
@@ -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);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/51] DMA-API: video: clcd: add dma_set_mask_and_coherent() call

2013-09-20 Thread 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+ker...@arm.linux.org.uk
---
 drivers/video/amba-clcd.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index 0a2cce7..afe4702 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -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);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/51] DMA-API: usb: ssb-hcd: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/usb/host/ssb-hcd.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ssb-hcd.c b/drivers/usb/host/ssb-hcd.c
index 74af2c6..0196f76 100644
--- a/drivers/usb/host/ssb-hcd.c
+++ b/drivers/usb/host/ssb-hcd.c
@@ -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);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 27/51] DMA-API: provide a helper to setup DMA masks

2013-09-20 Thread Russell King
Many 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().

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 include/linux/dma-mapping.h |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index ec951f9..27d1421 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -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)
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26/51] DMA-API: usb: ohci-sa1111: add a note about DMA masks

2013-09-20 Thread Russell King
Add a comment to explain why this driver doesn't call any of the DMA
API dma_set_mask() functions.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/usb/host/ohci-sa.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ohci-sa.c b/drivers/usb/host/ohci-sa.c
index 17b2a7d..aa9e127 100644
--- a/drivers/usb/host/ohci-sa.c
+++ b/drivers/usb/host/ohci-sa.c
@@ -185,6 +185,12 @@ static int ohci_hcd_sa_probe(struct sa_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- bus code (which includes bug workarounds.)
+*/
+
hcd = usb_create_hcd(ohci_sa_hc_driver, dev-dev, sa);
if (!hcd)
return -ENOMEM;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 29/51] DMA-API: ata: pata_octeon_cf: convert to use dma_coerce_mask_and_coherent()

2013-09-20 Thread Russell King
Convert 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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/ata/pata_octeon_cf.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index c51bbb9..6231d43 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -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);
 
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 30/51] DMA-API: dma: dw_dmac.c: convert to use dma_coerce_mask_and_coherent()

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/dma/dw/platform.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index e35d975..453822c 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -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)
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 31/51] DMA-API: media: omap3isp: use dma_coerce_mask_and_coherent()

2013-09-20 Thread Russell King
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 rmk+ker...@arm.linux.org.uk
---
 drivers/media/platform/omap3isp/isp.c |6 +++---
 drivers/media/platform/omap3isp/isp.h |3 ---
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index df3a0ec..1c36080 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -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);
 
diff --git a/drivers/media/platform/omap3isp/isp.h 
b/drivers/media/platform/omap3isp/isp.h
index cd3eff4..ce65d3a 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -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 */
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()

2013-09-20 Thread Tejun Heo
On Fri, Sep 20, 2013 at 12:11:38AM +0100, Russell King wrote:
 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+ker...@arm.linux.org.uk

Acked-by: Tejun Heo t...@kernel.org

The patch is pretty widely spread.  I don't mind how it gets routed
but what's the plan?

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()

2013-09-20 Thread Tejun Heo
On Fri, Sep 20, 2013 at 07:16:52AM -0500, Tejun Heo wrote:
 On Fri, Sep 20, 2013 at 12:11:38AM +0100, Russell King wrote:
  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+ker...@arm.linux.org.uk
 
 Acked-by: Tejun Heo t...@kernel.org
 
 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.

-- 
tejun
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/51] DMA-API: net: b43: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/net/wireless/b43/dma.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index c51d2dc..1d7982a 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -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;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 32/51] DMA-API: mmc: sdhci-acpi: use dma_coerce_mask_and_coherent()

2013-09-20 Thread Russell King
The 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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/mmc/host/sdhci-acpi.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index cdd4ce0..ef19874 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -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) {
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 33/51] DMA-API: net: nxp/lpc_eth: use dma_coerce_mask_and_coherent()

2013-09-20 Thread Russell King
The code sequence:
pldat-pdev-dev.coherent_dma_mask = 0x;
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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/net/ethernet/nxp/lpc_eth.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/nxp/lpc_eth.c 
b/drivers/net/ethernet/nxp/lpc_eth.c
index a061b93..ba3ca18 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -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 = 0x;
-   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
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 34/51] DMA-API: net: octeon: use dma_coerce_mask_and_coherent()

2013-09-20 Thread Russell King
The 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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/net/ethernet/octeon/octeon_mgmt.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/octeon/octeon_mgmt.c 
b/drivers/net/ethernet/octeon/octeon_mgmt.c
index 622aa75..2006a07 100644
--- a/drivers/net/ethernet/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/octeon/octeon_mgmt.c
@@ -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);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 36/51] DMA-API: usb: use dma_set_coherent_mask()

2013-09-20 Thread 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+ker...@arm.linux.org.uk
---
 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(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 74d998d..bf33bd3 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -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);
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index 2f2e88a..c10b324 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -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);
 
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c
index 67128be..6a2a65a 100644
--- a/drivers/usb/gadget/lpc32xx_udc.c
+++ b/drivers/usb/gadget/lpc32xx_udc.c
@@ -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;
 
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 3b645ff..5831a88 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -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) {
diff --git a/drivers/usb/host/ehci-octeon.c b/drivers/usb/host/ehci-octeon.c
index ab0397e..4c528b2 100644
--- a/drivers/usb/host/ehci-octeon.c
+++ b/drivers/usb/host/ehci-octeon.c
@@ -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)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 78b01fa..d0759c5 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -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;
  

[PATCH 37/51] DMA-API: usb: use new dma_coerce_mask_and_coherent()

2013-09-20 Thread Russell King
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 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(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index bf33bd3..af731db 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -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;
 
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index c10b324..8b20c70 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -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;
 
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 5831a88..8e7323e 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -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;
 
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index d0759c5..6fa82d6 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -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;
 
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 5870206..2ba7673 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -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;
 
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 5b0cd2d..7f30b71 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -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;
 
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 10d6a2e..d919ed4 100644

[PATCH 38/51] DMA-API: staging: use dma_set_coherent_mask()

2013-09-20 Thread 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+ker...@arm.linux.org.uk
---
 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(-)

diff --git a/drivers/staging/dwc2/platform.c b/drivers/staging/dwc2/platform.c
index 44cce2f..1d68c49 100644
--- a/drivers/staging/dwc2/platform.c
+++ b/drivers/staging/dwc2/platform.c
@@ -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) {
diff --git a/drivers/staging/imx-drm/imx-drm-core.c 
b/drivers/staging/imx-drm/imx-drm-core.c
index 47c5888..847f430 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -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;
diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c 
b/drivers/staging/imx-drm/ipuv3-crtc.c
index 6fd37a7..9e73e8d 100644
--- a/drivers/staging/imx-drm/ipuv3-crtc.c
+++ b/drivers/staging/imx-drm/ipuv3-crtc.c
@@ -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)
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/51] DMA-API: net: broadcom/b44: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 drivers/net/ethernet/broadcom/b44.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/b44.c 
b/drivers/net/ethernet/broadcom/b44.c
index 9b017d9..b4d2018 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -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;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] dma: cppi41: pass around device instead of platform_device

2013-09-20 Thread Daniel Mack
Instead of passing around struct plafform_device, use struct device and
save one level of dereferencing. This affects the following functions:

 * cppi41_add_chans
 * purge_descs
 * deinit_cpii41
 * init_descs
 * init_cppi41
 * cppi_glue_infos

It's just a cosmetic cleanup that makes the code more readable.

Signed-off-by: Daniel Mack zon...@gmail.com
---
 drivers/dma/cppi41.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 7c82b92..53d1d31 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -674,14 +674,14 @@ static void cleanup_chans(struct cppi41_dd *cdd)
}
 }
 
-static int cppi41_add_chans(struct platform_device *pdev, struct cppi41_dd 
*cdd)
+static int cppi41_add_chans(struct device *dev, struct cppi41_dd *cdd)
 {
struct cppi41_channel *cchan;
int i;
int ret;
u32 n_chans;
 
-   ret = of_property_read_u32(pdev-dev.of_node, #dma-channels,
+   ret = of_property_read_u32(dev-of_node, #dma-channels,
n_chans);
if (ret)
return ret;
@@ -719,7 +719,7 @@ err:
return -ENOMEM;
 }
 
-static void purge_descs(struct platform_device *pdev, struct cppi41_dd *cdd)
+static void purge_descs(struct device *dev, struct cppi41_dd *cdd)
 {
unsigned int mem_decs;
int i;
@@ -731,7 +731,7 @@ static void purge_descs(struct platform_device *pdev, 
struct cppi41_dd *cdd)
cppi_writel(0, cdd-qmgr_mem + QMGR_MEMBASE(i));
cppi_writel(0, cdd-qmgr_mem + QMGR_MEMCTRL(i));
 
-   dma_free_coherent(pdev-dev, mem_decs, cdd-cd,
+   dma_free_coherent(dev, mem_decs, cdd-cd,
cdd-descs_phys);
}
 }
@@ -741,19 +741,19 @@ static void disable_sched(struct cppi41_dd *cdd)
cppi_writel(0, cdd-sched_mem + DMA_SCHED_CTRL);
 }
 
-static void deinit_cpii41(struct platform_device *pdev, struct cppi41_dd *cdd)
+static void deinit_cpii41(struct device *dev, struct cppi41_dd *cdd)
 {
disable_sched(cdd);
 
-   purge_descs(pdev, cdd);
+   purge_descs(dev, cdd);
 
cppi_writel(0, cdd-qmgr_mem + QMGR_LRAM0_BASE);
cppi_writel(0, cdd-qmgr_mem + QMGR_LRAM0_BASE);
-   dma_free_coherent(pdev-dev, QMGR_SCRATCH_SIZE, cdd-qmgr_scratch,
+   dma_free_coherent(dev, QMGR_SCRATCH_SIZE, cdd-qmgr_scratch,
cdd-scratch_phys);
 }
 
-static int init_descs(struct platform_device *pdev, struct cppi41_dd *cdd)
+static int init_descs(struct device *dev, struct cppi41_dd *cdd)
 {
unsigned int desc_size;
unsigned int mem_decs;
@@ -777,7 +777,7 @@ static int init_descs(struct platform_device *pdev, struct 
cppi41_dd *cdd)
reg |= ilog2(ALLOC_DECS_NUM) - 5;
 
BUILD_BUG_ON(DESCS_AREAS != 1);
-   cdd-cd = dma_alloc_coherent(pdev-dev, mem_decs,
+   cdd-cd = dma_alloc_coherent(dev, mem_decs,
cdd-descs_phys, GFP_KERNEL);
if (!cdd-cd)
return -ENOMEM;
@@ -813,12 +813,12 @@ static void init_sched(struct cppi41_dd *cdd)
cppi_writel(reg, cdd-sched_mem + DMA_SCHED_CTRL);
 }
 
-static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd)
+static int init_cppi41(struct device *dev, struct cppi41_dd *cdd)
 {
int ret;
 
BUILD_BUG_ON(QMGR_SCRATCH_SIZE  ((1  14) - 1));
-   cdd-qmgr_scratch = dma_alloc_coherent(pdev-dev, QMGR_SCRATCH_SIZE,
+   cdd-qmgr_scratch = dma_alloc_coherent(dev, QMGR_SCRATCH_SIZE,
cdd-scratch_phys, GFP_KERNEL);
if (!cdd-qmgr_scratch)
return -ENOMEM;
@@ -827,7 +827,7 @@ static int init_cppi41(struct platform_device *pdev, struct 
cppi41_dd *cdd)
cppi_writel(QMGR_SCRATCH_SIZE, cdd-qmgr_mem + QMGR_LRAM_SIZE);
cppi_writel(0, cdd-qmgr_mem + QMGR_LRAM1_BASE);
 
-   ret = init_descs(pdev, cdd);
+   ret = init_descs(dev, cdd);
if (ret)
goto err_td;
 
@@ -835,7 +835,7 @@ static int init_cppi41(struct platform_device *pdev, struct 
cppi41_dd *cdd)
init_sched(cdd);
return 0;
 err_td:
-   deinit_cpii41(pdev, cdd);
+   deinit_cpii41(dev, cdd);
return ret;
 }
 
@@ -914,11 +914,11 @@ static const struct of_device_id cppi41_dma_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, cppi41_dma_ids);
 
-static const struct cppi_glue_infos *get_glue_info(struct platform_device 
*pdev)
+static const struct cppi_glue_infos *get_glue_info(struct device *dev)
 {
const struct of_device_id *of_id;
 
-   of_id = of_match_node(cppi41_dma_ids, pdev-dev.of_node);
+   of_id = of_match_node(cppi41_dma_ids, dev-of_node);
if (!of_id)
return NULL;
return of_id-data;
@@ -931,7 +931,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
int irq;

[PATCH 3/5] dma: cppi41: add shortcut to pdev-dev in cppi41_dma_probe()

2013-09-20 Thread Daniel Mack
Makes the code more readable and compact. No functional change.

Signed-off-by: Daniel Mack zon...@gmail.com
---
 drivers/dma/cppi41.c | 33 +
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 5469a15..d689706 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -927,11 +927,12 @@ static const struct cppi_glue_infos *get_glue_info(struct 
device *dev)
 static int cppi41_dma_probe(struct platform_device *pdev)
 {
struct cppi41_dd *cdd;
+   struct device *dev = pdev-dev;
const struct cppi_glue_infos *glue_info;
int irq;
int ret;
 
-   glue_info = get_glue_info(pdev-dev);
+   glue_info = get_glue_info(dev);
if (!glue_info)
return -EINVAL;
 
@@ -946,14 +947,14 @@ static int cppi41_dma_probe(struct platform_device *pdev)
cdd-ddev.device_issue_pending = cppi41_dma_issue_pending;
cdd-ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg;
cdd-ddev.device_control = cppi41_dma_control;
-   cdd-ddev.dev = pdev-dev;
+   cdd-ddev.dev = dev;
INIT_LIST_HEAD(cdd-ddev.channels);
cpp41_dma_info.dma_cap = cdd-ddev.cap_mask;
 
-   cdd-usbss_mem = of_iomap(pdev-dev.of_node, 0);
-   cdd-ctrl_mem = of_iomap(pdev-dev.of_node, 1);
-   cdd-sched_mem = of_iomap(pdev-dev.of_node, 2);
-   cdd-qmgr_mem = of_iomap(pdev-dev.of_node, 3);
+   cdd-usbss_mem = of_iomap(dev-of_node, 0);
+   cdd-ctrl_mem = of_iomap(dev-of_node, 1);
+   cdd-sched_mem = of_iomap(dev-of_node, 2);
+   cdd-qmgr_mem = of_iomap(dev-of_node, 3);
 
if (!cdd-usbss_mem || !cdd-ctrl_mem || !cdd-sched_mem ||
!cdd-qmgr_mem) {
@@ -961,8 +962,8 @@ static int cppi41_dma_probe(struct platform_device *pdev)
goto err_remap;
}
 
-   pm_runtime_enable(pdev-dev);
-   ret = pm_runtime_get_sync(pdev-dev);
+   pm_runtime_enable(dev);
+   ret = pm_runtime_get_sync(dev);
if (ret)
goto err_get_sync;
 
@@ -970,22 +971,22 @@ static int cppi41_dma_probe(struct platform_device *pdev)
cdd-queues_tx = glue_info-queues_tx;
cdd-td_queue = glue_info-td_queue;
 
-   ret = init_cppi41(pdev-dev, cdd);
+   ret = init_cppi41(dev, cdd);
if (ret)
goto err_init_cppi;
 
-   ret = cppi41_add_chans(pdev-dev, cdd);
+   ret = cppi41_add_chans(dev, cdd);
if (ret)
goto err_chans;
 
-   irq = irq_of_parse_and_map(pdev-dev.of_node, 0);
+   irq = irq_of_parse_and_map(dev-of_node, 0);
if (!irq)
goto err_irq;
 
cppi_writel(USBSS_IRQ_PD_COMP, cdd-usbss_mem + USBSS_IRQ_ENABLER);
 
ret = request_irq(irq, glue_info-isr, IRQF_SHARED,
-   dev_name(pdev-dev), cdd);
+   dev_name(dev), cdd);
if (ret)
goto err_irq;
cdd-irq = irq;
@@ -994,7 +995,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
if (ret)
goto err_dma_reg;
 
-   ret = of_dma_controller_register(pdev-dev.of_node,
+   ret = of_dma_controller_register(dev-of_node,
cppi41_dma_xlate, cpp41_dma_info);
if (ret)
goto err_of;
@@ -1009,11 +1010,11 @@ err_irq:
cppi_writel(0, cdd-usbss_mem + USBSS_IRQ_CLEARR);
cleanup_chans(cdd);
 err_chans:
-   deinit_cppi41(pdev-dev, cdd);
+   deinit_cppi41(dev, cdd);
 err_init_cppi:
-   pm_runtime_put(pdev-dev);
+   pm_runtime_put(dev);
 err_get_sync:
-   pm_runtime_disable(pdev-dev);
+   pm_runtime_disable(dev);
iounmap(cdd-usbss_mem);
iounmap(cdd-ctrl_mem);
iounmap(cdd-sched_mem);
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] dma: cppi41: s/deinit_cpii41/deinit_cppi41/

2013-09-20 Thread Daniel Mack
Fix a misspelled function name.

Signed-off-by: Daniel Mack zon...@gmail.com
---
 drivers/dma/cppi41.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 53d1d31..5469a15 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -741,7 +741,7 @@ static void disable_sched(struct cppi41_dd *cdd)
cppi_writel(0, cdd-sched_mem + DMA_SCHED_CTRL);
 }
 
-static void deinit_cpii41(struct device *dev, struct cppi41_dd *cdd)
+static void deinit_cppi41(struct device *dev, struct cppi41_dd *cdd)
 {
disable_sched(cdd);
 
@@ -835,7 +835,7 @@ static int init_cppi41(struct device *dev, struct cppi41_dd 
*cdd)
init_sched(cdd);
return 0;
 err_td:
-   deinit_cpii41(dev, cdd);
+   deinit_cppi41(dev, cdd);
return ret;
 }
 
@@ -1009,7 +1009,7 @@ err_irq:
cppi_writel(0, cdd-usbss_mem + USBSS_IRQ_CLEARR);
cleanup_chans(cdd);
 err_chans:
-   deinit_cpii41(pdev-dev, cdd);
+   deinit_cppi41(pdev-dev, cdd);
 err_init_cppi:
pm_runtime_put(pdev-dev);
 err_get_sync:
@@ -1033,7 +1033,7 @@ static int cppi41_dma_remove(struct platform_device *pdev)
cppi_writel(0, cdd-usbss_mem + USBSS_IRQ_CLEARR);
free_irq(cdd-irq, cdd);
cleanup_chans(cdd);
-   deinit_cpii41(pdev-dev, cdd);
+   deinit_cppi41(pdev-dev, cdd);
iounmap(cdd-usbss_mem);
iounmap(cdd-ctrl_mem);
iounmap(cdd-sched_mem);
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/5] dma: cppi41: some trivial fixes and support for suspend/resume

2013-09-20 Thread Daniel Mack
Here are some patches to teach the cppi41 DMA driver support for
suspend and resume. Patches 1-3 are simply cosmetic things that emerged
during my debugging sessions.

Patch #4 is actually a real bugfix which I would like Sebastian
Andrzej Siewior to have a look at. Quite frankly, the allocation scheme
in this driver and the logic to determine a descriptor's index number
seems quite complicated to me, but that's probably a different story.
Allocating and freeing the exact same pointer more than once is
certainly a bug.

Patch #5 adds support for suspend and resume. As the commit log says,
the code needed to achive this is the result of a trial-and-error
session. This is the minimum that's I'm left with now and which works
for me.


On a different note, I'm also working on patches for the musb core to
make it suspend and resume. Currently, I still have to rmmod/insmod
musb_dsps before/after the resume cycle, but I'm hoping to make
progress here soon.


Thanks,
Daniel


Daniel Mack (5):
  dma: cppi41: pass around device instead of platform_device
  dma: cppi41: s/deinit_cpii41/deinit_cppi41/
  dma: cppi41: add shortcut to pdev-dev in cppi41_dma_probe()
  dma: cppi41: only allocate descriptor memory once
  dma: cppi41: add support for suspend and resume

 drivers/dma/cppi41.c | 122 ---
 1 file changed, 77 insertions(+), 45 deletions(-)

-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] dma: cppi41: add support for suspend and resume

2013-09-20 Thread Daniel Mack
This patch adds support for suspend/resume functionality to the cppi41
DMA driver. The steps neccessary to make the system resume properly were
figured out by hefty trial-and-error. The code as it stands now is the
minimum that has to be done to put the musb host system on an AM33xx
system into an operable state after resume.

Signed-off-by: Daniel Mack zon...@gmail.com
---
 drivers/dma/cppi41.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 3347321..a1d162d 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -1040,12 +1040,48 @@ static int cppi41_dma_remove(struct platform_device 
*pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int cppi41_suspend(struct device *dev)
+{
+   struct cppi41_dd *cdd = dev_get_drvdata(dev);
+
+   cppi_writel(0, cdd-usbss_mem + USBSS_IRQ_CLEARR);
+   disable_sched(cdd);
+
+   return 0;
+}
+
+static int cppi41_resume(struct device *dev)
+{
+   struct cppi41_dd *cdd = dev_get_drvdata(dev);
+   int i;
+
+   for (i = 0; i  DESCS_AREAS; i++)
+   cppi_writel(cdd-descs_phys, cdd-qmgr_mem + QMGR_MEMBASE(i));
+
+   init_sched(cdd);
+   cppi_writel(USBSS_IRQ_PD_COMP, cdd-usbss_mem + USBSS_IRQ_ENABLER);
+
+   return 0;
+}
+
+static const struct dev_pm_ops cppi41_pm_ops = {
+   .suspend= cppi41_suspend,
+   .resume = cppi41_resume,
+};
+
+#define DEV_PM_OPS (cppi41_pm_ops)
+#else
+#define DEV_PM_OPS NULL
+#endif
+
 static struct platform_driver cpp41_dma_driver = {
.probe  = cppi41_dma_probe,
.remove = cppi41_dma_remove,
.driver = {
.name = cppi41-dma-engine,
.owner = THIS_MODULE,
+   .pm = DEV_PM_OPS,
.of_match_table = of_match_ptr(cppi41_dma_ids),
},
 };
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] dma: cppi41: only allocate descriptor memory once

2013-09-20 Thread Daniel Mack
cdd-cd and cdd-descs_phys are allocated DESCS_AREAS times from
init_descs() and freed as often from purge_descs(). This leads to both
memory leaks and double-frees.

Fix this by pulling the calls to dma_{alloc,free}_coherent() out of the
loops.

While at it, remove the intermediate variable mem_decs (I guess it was
only there to make the code comply to the 80-chars CodingSytle rule).

Signed-off-by: Daniel Mack zon...@gmail.com
---
 drivers/dma/cppi41.c | 25 ++---
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index d689706..3347321 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -727,13 +727,12 @@ static void purge_descs(struct device *dev, struct 
cppi41_dd *cdd)
mem_decs = ALLOC_DECS_NUM * sizeof(struct cppi41_desc);
 
for (i = 0; i  DESCS_AREAS; i++) {
-
cppi_writel(0, cdd-qmgr_mem + QMGR_MEMBASE(i));
cppi_writel(0, cdd-qmgr_mem + QMGR_MEMCTRL(i));
-
-   dma_free_coherent(dev, mem_decs, cdd-cd,
-   cdd-descs_phys);
}
+
+   dma_free_coherent(dev, ALLOC_DECS_NUM * sizeof(struct cppi41_desc),
+ cdd-cd, cdd-descs_phys);
 }
 
 static void disable_sched(struct cppi41_dd *cdd)
@@ -755,8 +754,7 @@ static void deinit_cppi41(struct device *dev, struct 
cppi41_dd *cdd)
 
 static int init_descs(struct device *dev, struct cppi41_dd *cdd)
 {
-   unsigned int desc_size;
-   unsigned int mem_decs;
+   unsigned int desc_size = sizeof(struct cppi41_desc);
int i;
u32 reg;
u32 idx;
@@ -765,28 +763,25 @@ static int init_descs(struct device *dev, struct 
cppi41_dd *cdd)
(sizeof(struct cppi41_desc) - 1));
BUILD_BUG_ON(sizeof(struct cppi41_desc)  32);
BUILD_BUG_ON(ALLOC_DECS_NUM  32);
+   BUILD_BUG_ON(DESCS_AREAS != 1);
 
-   desc_size = sizeof(struct cppi41_desc);
-   mem_decs = ALLOC_DECS_NUM * desc_size;
+   cdd-cd = dma_alloc_coherent(dev, ALLOC_DECS_NUM * desc_size,
+cdd-descs_phys, GFP_KERNEL);
+   if (!cdd-cd)
+   return -ENOMEM;
 
idx = 0;
for (i = 0; i  DESCS_AREAS; i++) {
-
reg = idx  QMGR_MEMCTRL_IDX_SH;
reg |= (ilog2(desc_size) - 5)  QMGR_MEMCTRL_DESC_SH;
reg |= ilog2(ALLOC_DECS_NUM) - 5;
 
-   BUILD_BUG_ON(DESCS_AREAS != 1);
-   cdd-cd = dma_alloc_coherent(dev, mem_decs,
-   cdd-descs_phys, GFP_KERNEL);
-   if (!cdd-cd)
-   return -ENOMEM;
-
cppi_writel(cdd-descs_phys, cdd-qmgr_mem + QMGR_MEMBASE(i));
cppi_writel(reg, cdd-qmgr_mem + QMGR_MEMCTRL(i));
 
idx += ALLOC_DECS_NUM;
}
+
return 0;
 }
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 42/51] DMA-API: usb: musb: use platform_device_register_full() to avoid directly messing with dma masks

2013-09-20 Thread Russell King - ARM Linux
On Fri, Sep 20, 2013 at 08:11:25AM -0500, Felipe Balbi wrote:
 Hi,
 
 On Fri, Sep 20, 2013 at 12:14:38AM +0100, Russell King wrote:
  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 rmk+ker...@arm.linux.org.uk
 
 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 ba...@ti.com
 
 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.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()

2013-09-20 Thread Russell King - ARM Linux
On Fri, Sep 20, 2013 at 07:16:52AM -0500, Tejun Heo wrote:
 On Fri, Sep 20, 2013 at 12:11:38AM +0100, Russell King wrote:
  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+ker...@arm.linux.org.uk
 
 Acked-by: Tejun Heo t...@kernel.org
 
 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...
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/51] DMA-API: provide a helper to set both DMA and coherent DMA masks

2013-09-20 Thread Russell King - ARM Linux
On Fri, Sep 20, 2013 at 02:21:37AM +0100, Ben Hutchings wrote:
 On Thu, 2013-09-19 at 22:25 +0100, Russell King wrote:
 [...]
  -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.

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. :)
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 40/51] DMA-API: crypto: fix ixp4xx crypto platform device support

2013-09-20 Thread Russell King
Don'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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/crypto/ixp4xx_crypto.c |   37 +
 1 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 21180d6..8306185 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -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);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 23/51] DMA-API: dma: pl08x: add dma_set_mask_and_coherent() call

2013-09-20 Thread 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+ker...@arm.linux.org.uk
---
 drivers/dma/amba-pl08x.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index fce46c5..e51a983 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -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) {
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/51] DMA-API: ppc: vio.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper

2013-09-20 Thread 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 rmk+ker...@arm.linux.org.uk
---
 arch/powerpc/kernel/vio.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 78a3506..96b6c97 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -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 */
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 35/51] DMA-API: parport: parport_pc.c: use dma_coerce_mask_and_coherent()

2013-09-20 Thread Russell King
The 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.

Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/parport/parport_pc.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 903e128..9637615 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -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);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 42/51] DMA-API: usb: musb: use platform_device_register_full() to avoid directly messing with dma masks

2013-09-20 Thread Felipe Balbi
Hi,

On Fri, Sep 20, 2013 at 02:49:38PM +0100, Russell King - ARM Linux wrote:
 On Fri, Sep 20, 2013 at 08:11:25AM -0500, Felipe Balbi wrote:
  Hi,
  
  On Fri, Sep 20, 2013 at 12:14:38AM +0100, Russell King wrote:
   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 rmk+ker...@arm.linux.org.uk
  
  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 ba...@ti.com
  
  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.

-- 
balbi


signature.asc
Description: Digital signature


Re: Getting udev name from usb_device structure

2013-09-20 Thread Greg KH
On Fri, Sep 20, 2013 at 08:59:30AM +0200, Sergio Work wrote:
 
 I guess that it's a little difficult to understand all the deteails
 without a whole image of the context, but I can't provide more details
 since my NDA doesn't allow me :(

Then you are on your own, sorry.

good luck,

greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] usb: musb: dsps fix the typo in reg-names of the dma node

2013-09-20 Thread Felipe Balbi
Hi,

adding Benoit Cousson and linux-omap

On Wed, Aug 14, 2013 at 07:29:59PM +0200, Sebastian Andrzej Siewior wrote:
 I forgot to separete the different names in the reg-names property. This
 didn't cause anything to fail because the driver does not use the names
 and simply relies on the order of the memory offsets in reg.
 This patch fixes this in case it is used later.
 
 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

Benoit, hope you can take this patch in the -rc cycle.

Acked-by: Felipe Balbi ba...@ti.com

 ---
  arch/arm/boot/dts/am33xx.dtsi | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
 index 24d6309..a38f8d3 100644
 --- a/arch/arm/boot/dts/am33xx.dtsi
 +++ b/arch/arm/boot/dts/am33xx.dtsi
 @@ -470,7 +470,7 @@
   0x47402000 0x1000
   0x47403000 0x1000
   0x47404000 0x4000;
 - reg-names = glue controller scheduler 
 queuemgr;
 + reg-names = glue, controller, scheduler, 
 queuemgr;
   interrupts = 17;
   interrupt-names = glue;
   #dma-cells = 2;
 -- 
 1.8.4.rc1
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-usb in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/4] usb: usb: dsps: update code according to the binding document

2013-09-20 Thread Felipe Balbi
+ linux-omap, Benoit

On Thu, Aug 15, 2013 at 05:21:49PM +0200, Sebastian Andrzej Siewior wrote:
 This relfects the code and dts requires changes due to recent .dts
 binding updates:
 - use mg prefix for the Metor Graphics specific attributes
 - use power in mA not in mA/2 as specifed in the USB2.0 specification
 
 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

hope this can go in during the -rc cycle

Acked-by: Felipe Balbi ba...@ti.com

 ---
  arch/arm/boot/dts/am335x-bone.dts  |  2 +-
  arch/arm/boot/dts/am335x-evm.dts   |  6 +++---
  arch/arm/boot/dts/am335x-evmsk.dts |  2 +-
  arch/arm/boot/dts/am33xx.dtsi  | 26 +-
  drivers/usb/musb/musb_dsps.c   | 11 ++-
  5 files changed, 24 insertions(+), 23 deletions(-)
 
 diff --git a/arch/arm/boot/dts/am335x-bone.dts 
 b/arch/arm/boot/dts/am335x-bone.dts
 index a8907b5..e8447a7 100644
 --- a/arch/arm/boot/dts/am335x-bone.dts
 +++ b/arch/arm/boot/dts/am335x-bone.dts
 @@ -127,7 +127,7 @@
   status = okay;
   };
  
 - phy@47401300 {
 + usb-phy@47401300 {
   status = okay;
   };
  
 diff --git a/arch/arm/boot/dts/am335x-evm.dts 
 b/arch/arm/boot/dts/am335x-evm.dts
 index c26c16c..648a67e 100644
 --- a/arch/arm/boot/dts/am335x-evm.dts
 +++ b/arch/arm/boot/dts/am335x-evm.dts
 @@ -178,11 +178,11 @@
   status = okay;
   };
  
 - phy@47401300 {
 + usb-phy@47401300 {
   status = okay;
   };
  
 - phy@47401b00 {
 + usb-phy@47401b00 {
   status = okay;
   };
  
 @@ -194,7 +194,7 @@
   status = okay;
   };
  
 - dma@07402000  {
 + dma-controller@07402000  {
   status = okay;
   };
   };
 diff --git a/arch/arm/boot/dts/am335x-evmsk.dts 
 b/arch/arm/boot/dts/am335x-evmsk.dts
 index e92446c..a6c5033 100644
 --- a/arch/arm/boot/dts/am335x-evmsk.dts
 +++ b/arch/arm/boot/dts/am335x-evmsk.dts
 @@ -214,7 +214,7 @@
   status = okay;
   };
  
 - phy@47401300 {
 + usb-phy@47401300 {
   status = okay;
   };
  
 diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
 index a38f8d3..c57c6b8 100644
 --- a/arch/arm/boot/dts/am33xx.dtsi
 +++ b/arch/arm/boot/dts/am33xx.dtsi
 @@ -354,7 +354,7 @@
   status = disabled;
   };
  
 - usb0_phy: phy@47401300 {
 + usb0_phy: usb-phy@47401300 {
   compatible = ti,am335x-usb-phy;
   reg = 0x47401300 0x100;
   reg-names = phy;
 @@ -377,11 +377,11 @@
   reg-names = mc;
   interrupts = 18;
   interrupt-names = mc;
 - multipoint = 1;
 - num-eps = 16;
 - ram-bits = 12;
 - port-mode = 3;
 - power = 250;
 + mg,multipoint = 1;
 + mg,num-eps = 16;
 + mg,ram-bits = 12;
 + mg,port-mode = 3;
 + mg,power = 500;
   phys = usb0_phy;
  
   dmas = cppi41dma  0 0 cppi41dma  1 0
 @@ -409,7 +409,7 @@
   };
   };
  
 - usb1_phy: phy@47401b00 {
 + usb1_phy: usb-phy@47401b00 {
   compatible = ti,am335x-usb-phy;
   reg = 0x47401b00 0x100;
   reg-names = phy;
 @@ -432,11 +432,11 @@
   reg-names = mc;
   interrupts = 19;
   interrupt-names = mc;
 - multipoint = 1;
 - num-eps = 16;
 - ram-bits = 12;
 - port-mode = 3;
 - power = 250;
 + mg,multipoint = 1;
 + mg,num-eps = 16;
 + mg,ram-bits = 12;
 + 

Re: [PATCH 2/4] usb: musb: am335x: add second port to beagle bone

2013-09-20 Thread Felipe Balbi
On Thu, Aug 15, 2013 at 05:21:50PM +0200, Sebastian Andrzej Siewior wrote:
 So I assumed that Beagle bone has only one USB port in host mode because
 the micro USB connector had an USB-UART there. I was wrong a little. The
 second port runs on host mode, but the micro USB plug is connected to an
 internal HUB with two ports: one to the USB-UART and one to musb
 instance one.
 For that reason, this patch enables both ports: the primary in device
 mode only and the second in host mode only.
 
 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

Acked-by: Felipe Balbi ba...@ti.com

 ---
  arch/arm/boot/dts/am335x-bone.dts | 15 +++
  1 file changed, 15 insertions(+)
 
 diff --git a/arch/arm/boot/dts/am335x-bone.dts 
 b/arch/arm/boot/dts/am335x-bone.dts
 index e8447a7..596d653 100644
 --- a/arch/arm/boot/dts/am335x-bone.dts
 +++ b/arch/arm/boot/dts/am335x-bone.dts
 @@ -131,9 +131,24 @@
   status = okay;
   };
  
 + usb-phy@47401b00 {
 + status = okay;
 + };
 +
   usb@47401000 {
   status = okay;
   };
 +
 + usb@47401800 {
 + status = okay;
 + usb@47401c00 {
 + mg,port-mode = 1;
 + };
 + };
 +
 + dma-controller@07402000  {
 + status = okay;
 + };
   };
  
   i2c0: i2c@44e0b000 {
 -- 
 1.8.4.rc2
 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 3/4] usb: musb: am335x: Do not remove the session bit HOST-only mode

2013-09-20 Thread Felipe Balbi
On Thu, Aug 15, 2013 at 05:21:51PM +0200, Sebastian Andrzej Siewior wrote:
 This is what I observe:
 On the first connect, the musb starts with DEVCTL.Session set. On
 disconnect, musb_core calls try_idle. That functions removes the Session
 bit signalizing that the session is over (something that only in OTG is
 required). A new device, that is plugged, is no longer recognized.
 I've setup a timer and checked the DEVCTL register and I haven't seen a
 change in VBus and I saw the B-Device bit set. After setting the IDDIG
 into A mode and forcing the device to behave like a A device, I didn't
 see a change.
 Neither VBUS goes to 0b11 nor does a session start request comes.
 In the TI-v3.2 kernel they skip to call musb_platform_try_idle() in the
 OTG_STATE_A_WAIT_BCON state while not in OTG mode.
 Since the second port hast a standard A plug the patch changes the port
 to run in host mode only and skips the timer which would remove
 DEVCTL.Session so we can reconnect to another device later.
 
 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

Acked-by: Felipe Balbi ba...@ti.com

 ---
  arch/arm/boot/dts/am335x-evm.dts | 3 +++
  drivers/usb/musb/musb_dsps.c | 2 ++
  2 files changed, 5 insertions(+)
 
 diff --git a/arch/arm/boot/dts/am335x-evm.dts 
 b/arch/arm/boot/dts/am335x-evm.dts
 index 648a67e..794b38b9 100644
 --- a/arch/arm/boot/dts/am335x-evm.dts
 +++ b/arch/arm/boot/dts/am335x-evm.dts
 @@ -192,6 +192,9 @@
  
   usb@47401800 {
   status = okay;
 + musb1: usb@47401c00 {
 + port-mode = 1;
 + };
   };
  
   dma-controller@07402000  {
 diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
 index 7368577..b7b2346 100644
 --- a/drivers/usb/musb/musb_dsps.c
 +++ b/drivers/usb/musb/musb_dsps.c
 @@ -230,6 +230,8 @@ static void dsps_musb_try_idle(struct musb *musb, 
 unsigned long timeout)
   glue-last_timer = jiffies;
   return;
   }
 + if (musb-port_mode == MUSB_PORT_MODE_HOST)
 + return;
  
   if (time_after(glue-last_timer, timeout) 
   timer_pending(glue-timer)) {
 -- 
 1.8.4.rc2
 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2 3/9] ARM: OMAP2+: omap-usb-host: Get rid of platform_data from struct usbhs_phy_data

2013-09-20 Thread Felipe Balbi
Hi,

On Thu, Aug 15, 2013 at 01:18:23PM +0300, Roger Quadros wrote:
 The platform data bits can be inferred from the other members of
 struct usbhs_phy_data. So get rid of the platform_data member.
 
 Build the platform data for the PHY device in usbhs_init_phys() instead.
 
 Signed-off-by: Roger Quadros rog...@ti.com

Tony, do I get your Acked-by here and all following arch/arm/mach-omap2*
patches in this series ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2 3/9] ARM: OMAP2+: omap-usb-host: Get rid of platform_data from struct usbhs_phy_data

2013-09-20 Thread Tony Lindgren
* Felipe Balbi ba...@ti.com [130920 08:52]:
 Hi,
 
 On Thu, Aug 15, 2013 at 01:18:23PM +0300, Roger Quadros wrote:
  The platform data bits can be inferred from the other members of
  struct usbhs_phy_data. So get rid of the platform_data member.
  
  Build the platform data for the PHY device in usbhs_init_phys() instead.
  
  Signed-off-by: Roger Quadros rog...@ti.com
 
 Tony, do I get your Acked-by here and all following arch/arm/mach-omap2*
 patches in this series ?

If you can merge just this series without the .dts changes
into an immutable topic branch against let's say v3.12-rc2
when it comes out, then yes I can ack them:

Acked-by: Tony Lindgren t...@atomide.com

That way I can also pull in the topic branch as needed to
avoid self inflicted merge conflicts ;) And Benoit can
set up a separate .dts branch based on your branch to make
sure the dependencies are in place before merging that one
upstream.

Regards,

Tony
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][RFC] Fix breakage in ffs_fs_mount()

2013-09-20 Thread Al Viro
There's a bunch of failure exits in ffs_fs_mount() with
seriously broken recovery logics.  Most of that appears to stem
from misunderstanding of the -kill_sb() semantics; unlike
-put_super() it is called for *all* superblocks of given type,
no matter how (in)complete the setup had been.  -put_super()
is called only if -s_root is not NULL; any failure prior to
setting -s_root will have the call of -put_super() skipped.  
-kill_sb(), OTOH, awaits every superblock that has come from
sget().

Current behaviour of ffs_fs_mount():

We have struct ffs_sb_fill_data data on stack there.  We do
ffs_dev = functionfs_acquire_dev_callback(dev_name);
and store that in data.private_data.  Then we call mount_nodev(),
passing it ffs_sb_fill() as a callback.  That will either fail
outright, or manage to call ffs_sb_fill().  There we allocate an
instance of struct ffs_data, slap the value of ffs_dev (picked
from data.private_data) into ffs-private_data and overwrite
data.private_data by storing ffs into an overlapping member
(data.ffs_data).  Then we store ffs into sb-s_fs_info and attempt
to set the rest of the things up (root inode, root dentry, then
create /ep0 there).  Any of those might fail.  Should that
happen, we get ffs_fs_kill_sb() called before mount_nodev()
returns.  If mount_nodev() fails for any reason whatsoever,
we proceed to
functionfs_release_dev_callback(data.ffs_data);
 
That's broken in a lot of ways.  Suppose the thing has failed in
allocation of e.g. root inode or dentry.  We have
functionfs_release_dev_callback(ffs);
ffs_data_put(ffs);
done by ffs_fs_kill_sb() (ffs accessed via sb-s_fs_info), followed by
functionfs_release_dev_callback(ffs);
from ffs_fs_mount() (via data.ffs_data).  Note that the second
functionfs_release_dev_callback() has every chance to be done to freed memory.
 
Suppose we fail *before* root inode allocation.  What happens then?
ffs_fs_kill_sb() doesn't do anything to ffs (it's either not called at all,
or it doesn't have a pointer to ffs stored in sb-s_fs_info).  And
functionfs_release_dev_callback(data.ffs_data);
is called by ffs_fs_mount(), but here we are in nasal daemon country - we
are reading from a member of union we'd never stored into.  In practice,
we'll get what we used to store into the overlapping field, i.e. ffs_dev.
And then we get screwed, since we treat it (struct gfs_ffs_obj * in
disguise, returned by functionfs_acquire_dev_callback()) as struct
ffs_data *, pick what would've been ffs_data -private_data from it
(*well* past the actual end of the struct gfs_ffs_obj - struct ffs_data
is much bigger) and poke in whatever it points to.

FWIW, there's a minor leak on top of all that in case if ffs_sb_fill()
fails on kstrdup() - ffs is obviously forgotten.

The thing is, there is no point in playing all those games with union.
Just allocate and initialize ffs_data *before* calling mount_nodev() and
pass a pointer to it via data.ffs_data.  And once it's stored in
sb-s_fs_info, clear data.ffs_data, so that ffs_fs_mount() knows that
it doesn't need to kill the sucker manually - from that point on
we'll have it done by -kill_sb().
 
Signed-off-by: Al Viro v...@zeniv.linux.org.uk
-- 
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 1a66c5b..0658908 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -1034,37 +1034,19 @@ struct ffs_sb_fill_data {
struct ffs_file_perms perms;
umode_t root_mode;
const char *dev_name;
-   union {
-   /* set by ffs_fs_mount(), read by ffs_sb_fill() */
-   void *private_data;
-   /* set by ffs_sb_fill(), read by ffs_fs_mount */
-   struct ffs_data *ffs_data;
-   };
+   struct ffs_data *ffs_data;
 };
 
 static int ffs_sb_fill(struct super_block *sb, void *_data, int silent)
 {
struct ffs_sb_fill_data *data = _data;
struct inode*inode;
-   struct ffs_data *ffs;
+   struct ffs_data *ffs = data-ffs_data;
 
ENTER();
 
-   /* Initialise data */
-   ffs = ffs_data_new();
-   if (unlikely(!ffs))
-   goto Enomem;
-
ffs-sb  = sb;
-   ffs-dev_name= kstrdup(data-dev_name, GFP_KERNEL);
-   if (unlikely(!ffs-dev_name))
-   goto Enomem;
-   ffs-file_perms  = data-perms;
-   ffs-private_data= data-private_data;
-
-   /* used by the caller of this function */
-   data-ffs_data   = ffs;
-
+   data-ffs_data   = NULL;
sb-s_fs_info= ffs;
sb-s_blocksize  = PAGE_CACHE_SIZE;
sb-s_blocksize_bits = PAGE_CACHE_SHIFT;
@@ -1080,17 +1062,14 @@ static int ffs_sb_fill(struct super_block *sb, void 
*_data, int silent)
  data-perms);
sb-s_root = d_make_root(inode);
if (unlikely(!sb-s_root))
-   goto Enomem;
+   return -ENOMEM;
 
/* EP0 

Re: [PATCH v2 3/9] ARM: OMAP2+: omap-usb-host: Get rid of platform_data from struct usbhs_phy_data

2013-09-20 Thread Felipe Balbi
On Fri, Sep 20, 2013 at 09:18:22AM -0700, Tony Lindgren wrote:
 * Felipe Balbi ba...@ti.com [130920 08:52]:
  Hi,
  
  On Thu, Aug 15, 2013 at 01:18:23PM +0300, Roger Quadros wrote:
   The platform data bits can be inferred from the other members of
   struct usbhs_phy_data. So get rid of the platform_data member.
   
   Build the platform data for the PHY device in usbhs_init_phys() instead.
   
   Signed-off-by: Roger Quadros rog...@ti.com
  
  Tony, do I get your Acked-by here and all following arch/arm/mach-omap2*
  patches in this series ?
 
 If you can merge just this series without the .dts changes
 into an immutable topic branch against let's say v3.12-rc2
 when it comes out, then yes I can ack them:
 
 Acked-by: Tony Lindgren t...@atomide.com
 
 That way I can also pull in the topic branch as needed to
 avoid self inflicted merge conflicts ;) And Benoit can
 set up a separate .dts branch based on your branch to make
 sure the dependencies are in place before merging that one
 upstream.

Alright, i'll put this in my todo for next week.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH] xhci: fix write to USB3_PSSEN and XUSB2PRM pci config registers

2013-09-20 Thread Xenia Ragiadakou
The function pci_write_config_dword() sets the appropriate byteordering
internally so the value argument should not be converted to little-endian.
This bug was found by sparse.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
---
 drivers/usb/host/pci-quirks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 2c76ef1..08ef282 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -799,7 +799,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
 * switchable ports.
 */
pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
-   cpu_to_le32(ports_available));
+   ports_available);
 
pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
ports_available);
@@ -821,7 +821,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
 * host.
 */
pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
-   cpu_to_le32(ports_available));
+   ports_available);
 
pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
ports_available);
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 24/51] DMA-API: dma: pl330: add dma_set_mask_and_coherent() call

2013-09-20 Thread Heiko Stübner
Am Donnerstag, 19. September 2013, 23:49:01 schrieb 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.
^--- copy and paste error - should of course be PL330


 Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
 ---
  drivers/dma/pl330.c |4 
  1 files changed, 4 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
 index a562d24..df8b10f 100644
 --- a/drivers/dma/pl330.c
 +++ b/drivers/dma/pl330.c
 @@ -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) {

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] RX-51: Add platform function and data for bq24150a charger

2013-09-20 Thread Pali Rohár
On Sunday 08 September 2013 10:50:39 Pali Rohár wrote:
 This patch will register bq24150a charger in RX-51 board data.
 Patch also adding platform function between isp1704 and
 bq2415x drivers for detecting charger type.
 
 So finally charging battery on Nokia N900 (RX-51) working
 automatically without any proprietary Nokia bits in userspace.
 
 Signed-off-by: Pali Rohár pali.ro...@gmail.com
 ---
  arch/arm/mach-omap2/board-rx51-peripherals.c |   56
 +- 1 file changed, 55 insertions(+),
 1 deletion(-)
 
 diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c
 b/arch/arm/mach-omap2/board-rx51-peripherals.c index
 9c2dd10..a993ffe 100644
 --- a/arch/arm/mach-omap2/board-rx51-peripherals.c
 +++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
 @@ -25,6 +25,7 @@
  #include linux/gpio_keys.h
  #include linux/mmc/host.h
  #include linux/power/isp1704_charger.h
 +#include linux/power/bq2415x_charger.h
  #include linux/platform_data/spi-omap2-mcspi.h
  #include linux/platform_data/mtd-onenand-omap2.h
 
 @@ -270,6 +271,44 @@ static struct platform_device
 rx51_battery_device = { .id   = -1,
  };
 
 +static enum bq2415x_mode rx51_charger_mode =
 BQ2415X_MODE_OFF; +static void *rx51_charger_hook_data;
 +static void (*rx51_charger_hook)(enum bq2415x_mode mode, void
 *data); +
 +static int rx51_charger_set_hook(
 + void (*hook)(enum bq2415x_mode mode, void *data), void
 *data) +{
 + rx51_charger_hook = hook;
 + rx51_charger_hook_data = data;
 + if (rx51_charger_hook)
 + rx51_charger_hook(rx51_charger_mode,
 rx51_charger_hook_data); +return 1;
 +}
 +
 +static void rx51_charger_set_current(int mA)
 +{
 + enum bq2415x_mode mode;
 +
 + pr_info(RX-51: Charger current limit is %d mA\n, mA);
 +
 + if (mA == 0)
 + mode = BQ2415X_MODE_OFF;
 + else if (mA  500)
 + mode = BQ2415X_MODE_NONE;
 + else if (mA  1800)
 + mode = BQ2415X_MODE_HOST_CHARGER;
 + else
 + mode = BQ2415X_MODE_DEDICATED_CHARGER;
 +
 + if (rx51_charger_mode == mode)
 + return;
 +
 + rx51_charger_mode = mode;
 +
 + if (rx51_charger_hook)
 + rx51_charger_hook(rx51_charger_mode,
 rx51_charger_hook_data); +}
 +
  static void rx51_charger_set_power(bool on)
  {
   gpio_set_value(RX51_USB_TRANSCEIVER_RST_GPIO, on);
 @@ -277,6 +316,7 @@ static void rx51_charger_set_power(bool
 on)
 
  static struct isp1704_charger_data rx51_charger_data = {
   .set_power  = rx51_charger_set_power,
 + .set_current= rx51_charger_set_current,
  };
 
  static struct platform_device rx51_charger_device = {
 @@ -1017,6 +1057,16 @@ static struct aic3x_pdata
 rx51_aic3x_data2 = { .gpio_reset = 60,
  };
 
 +static struct bq2415x_platform_data
 rx51_bq24150a_platform_data = { + .current_limit = 100,   
/*
 mA */
 + .weak_battery_voltage = 3400,   /* mV */
 + .battery_regulation_voltage = 4200, /* mV */
 + .charge_current = 650,  /* mA */
 + .termination_current = 100, /* mA */
 + .resistor_sense = 68,   /* m ohm */
 + .set_mode_hook = rx51_charger_set_hook,
 +};
 +
  static struct i2c_board_info __initdata
 rx51_peripherals_i2c_board_info_2[] = { {
   I2C_BOARD_INFO(tlv320aic3x, 0x18),
 @@ -1044,7 +1094,11 @@ static struct i2c_board_info __initdata
 rx51_peripherals_i2c_board_info_2[] = { {
   I2C_BOARD_INFO(tpa6130a2, 0x60),
   .platform_data = rx51_tpa6130a2_data,
 - }
 + },
 + {
 + I2C_BOARD_INFO(bq24150a, 0x6b),
 + .platform_data = rx51_bq24150a_platform_data,
 + },
  };
 
  static struct i2c_board_info __initdata
 rx51_peripherals_i2c_board_info_3[] = {

Tony, can you look and review this board patch?

I think that this patch series it the most important for Nokia 
N900, because it finally bringing charging support. And without 
charging battery it very hard to use phone which has power supply 
only from battery.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH 39/51] DMA-API: others: use dma_set_coherent_mask()

2013-09-20 Thread Tejun Heo
Hey,

On Fri, Sep 20, 2013 at 03:00:18PM +0100, Russell King - ARM Linux wrote:
 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.

-- 
tejun
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][RFC] Fix breakage in ffs_fs_mount()

2013-09-20 Thread Michal Nazarewicz
On Fri, Sep 20 2013, Al Viro wrote:
   There's a bunch of failure exits in ffs_fs_mount() with
 seriously broken recovery logics.  Most of that appears to stem
 from misunderstanding of the -kill_sb() semantics;

That sounds likely.

[…]

 Signed-off-by: Al Viro v...@zeniv.linux.org.uk

Acked-by: Michal Nazarewicz min...@mina86.com

 -- 
 diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
 index 1a66c5b..0658908 100644
 --- a/drivers/usb/gadget/f_fs.c
 +++ b/drivers/usb/gadget/f_fs.c
 @@ -1034,37 +1034,19 @@ struct ffs_sb_fill_data {
   struct ffs_file_perms perms;
   umode_t root_mode;
   const char *dev_name;
 - union {
 - /* set by ffs_fs_mount(), read by ffs_sb_fill() */
 - void *private_data;
 - /* set by ffs_sb_fill(), read by ffs_fs_mount */
 - struct ffs_data *ffs_data;
 - };
 + struct ffs_data *ffs_data;
  };
  
  static int ffs_sb_fill(struct super_block *sb, void *_data, int silent)
  {
   struct ffs_sb_fill_data *data = _data;
   struct inode*inode;
 - struct ffs_data *ffs;
 + struct ffs_data *ffs = data-ffs_data;
  
   ENTER();
  
 - /* Initialise data */
 - ffs = ffs_data_new();
 - if (unlikely(!ffs))
 - goto Enomem;
 -
   ffs-sb  = sb;
 - ffs-dev_name= kstrdup(data-dev_name, GFP_KERNEL);
 - if (unlikely(!ffs-dev_name))
 - goto Enomem;
 - ffs-file_perms  = data-perms;
 - ffs-private_data= data-private_data;
 -
 - /* used by the caller of this function */
 - data-ffs_data   = ffs;
 -
 + data-ffs_data   = NULL;
   sb-s_fs_info= ffs;
   sb-s_blocksize  = PAGE_CACHE_SIZE;
   sb-s_blocksize_bits = PAGE_CACHE_SHIFT;
 @@ -1080,17 +1062,14 @@ static int ffs_sb_fill(struct super_block *sb, void 
 *_data, int silent)
 data-perms);
   sb-s_root = d_make_root(inode);
   if (unlikely(!sb-s_root))
 - goto Enomem;
 + return -ENOMEM;
  
   /* EP0 file */
   if (unlikely(!ffs_sb_create_file(sb, ep0, ffs,
ffs_ep0_operations, NULL)))
 - goto Enomem;
 + return -ENOMEM;
  
   return 0;
 -
 -Enomem:
 - return -ENOMEM;
  }
  
  static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts)
 @@ -1193,6 +1172,7 @@ ffs_fs_mount(struct file_system_type *t, int flags,
   struct dentry *rv;
   int ret;
   void *ffs_dev;
 + struct ffs_data *ffs;
  
   ENTER();
  
 @@ -1200,18 +1180,30 @@ ffs_fs_mount(struct file_system_type *t, int flags,
   if (unlikely(ret  0))
   return ERR_PTR(ret);
  
 + ffs = ffs_data_new();
 + if (unlikely(!ffs))
 + return ERR_PTR(-ENOMEM);
 + ffs-file_perms = data.perms;
 +
 + ffs-dev_name = kstrdup(dev_name, GFP_KERNEL);
 + if (unlikely(!ffs-dev_name)) {
 + ffs_data_put(ffs);
 + return ERR_PTR(-ENOMEM);
 + }
 +
   ffs_dev = functionfs_acquire_dev_callback(dev_name);
 - if (IS_ERR(ffs_dev))
 - return ffs_dev;
 + if (IS_ERR(ffs_dev)) {
 + ffs_data_put(ffs);
 + return ERR_CAST(ffs_dev);
 + }
 + ffs-private_data = ffs_dev;
 + data.ffs_data = ffs;
  
 - data.dev_name = dev_name;
 - data.private_data = ffs_dev;
   rv = mount_nodev(t, flags, data, ffs_sb_fill);
 -
 - /* data.ffs_data is set by ffs_sb_fill */
 - if (IS_ERR(rv))
 + if (IS_ERR(rv)  data.ffs_data) {
   functionfs_release_dev_callback(data.ffs_data);
 -
 + ffs_data_put(data.ffs_data);
 + }
   return rv;
  }
  

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--


signature.asc
Description: PGP signature


Re: [RFC 10/21] xhci: replace xhci_readl() with readl() in xhci-dbg.c

2013-09-20 Thread Dan Williams
On Thu, Sep 19, 2013 at 2:37 PM, Sarah Sharp
sarah.a.sh...@linux.intel.com wrote:
 On Fri, Sep 13, 2013 at 03:50:48PM +0530, Pratyush Anand wrote:
 On Fri, Sep 13, 2013 at 3:40 PM, Xenia Ragiadakou 
 burzalod...@gmail.comwrote:
  Nope :). There is still Kumar 's patch that keeps the wrappers, so it can
  be applied instead of mine. But you did not tell me which tool you use
  currently to log the mmio operations? it is useful to know.
 
 
 Sorry, I did not use any standard tool, rather I made local changes in
 dwc3_readl and dwc3_writel to log all dwc3 specific read/write
 operations into a static array, which was dumped to a text file using
 an ARM debugger (trace32) for further analysis.

 Would it be helpful to add a trace event for xHCI register reads and
 writes (but not a debug statement)?  That way you wouldn't have to
 change or recompile the kernel at all, but you could use the trace
 events infrastructure to enable xHCI register read/write debugging.  We
 wouldn't flood log files with register reads and writes, but a trace
 event makes sense.

 AFAIK, trace events work on both x86 and ARM.


We do have generic mmiotrace if somebody wanted to get a log of all
xhci mmio operations.  So, I don't think xhci specific infrastructure
is needed.

--
Dan
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 10/21] xhci: replace xhci_readl() with readl() in xhci-dbg.c

2013-09-20 Thread Dan Williams
On Thu, Sep 19, 2013 at 10:24 PM, Pratyush Anand pratyush.an...@st.com wrote:
 On Fri, Sep 20, 2013 at 05:37:50AM +0800, Sarah Sharp wrote:
 On Fri, Sep 13, 2013 at 03:50:48PM +0530, Pratyush Anand wrote:
  On Fri, Sep 13, 2013 at 3:40 PM, Xenia Ragiadakou 
  burzalod...@gmail.comwrote:
   Nope :). There is still Kumar 's patch that keeps the wrappers, so it can
   be applied instead of mine. But you did not tell me which tool you use
   currently to log the mmio operations? it is useful to know.
  
  
  Sorry, I did not use any standard tool, rather I made local changes in
  dwc3_readl and dwc3_writel to log all dwc3 specific read/write
  operations into a static array, which was dumped to a text file using
  an ARM debugger (trace32) for further analysis.

 Would it be helpful to add a trace event for xHCI register reads and
 writes (but not a debug statement)?  That way you wouldn't have to
 change or recompile the kernel at all, but you could use the trace
 events infrastructure to enable xHCI register read/write debugging.  We
 wouldn't flood log files with register reads and writes, but a trace
 event makes sense.

 I have not used tracepoints. So to understand, looked into
 Documentation/trace/tracepoints.txt: When a tracepoint is on, the
 function you provide is called each time the tracepoint is executed.

 So, do you mean to insert tracepoint in xhci_readl/writel? For sure it
 would be helpful, but...
 Trace ON will be needed only in very special (and a few) case, so
 would it be fine to insert a tiny time penalty in readl/writel
 routine when trace is off? Not Sure...

It's just a series of nops when tracing is off, so the penalty is
negligible and is already used in hotter paths in the kernel.

 Document says When a tracepoint is off it has no effect, except for
 adding a tiny time penalty (checking a condition for a branch)

If anything the penalty of xhci_dbg_trace might be something to look
at later on since we take what looks like a 1% object size hit.

--
Dan
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html