Re: [PATCH v8 0/3] usb: xhci-platform: Configure 64-bit DMA mask if the platform is capable

2015-09-30 Thread Duc Dang
On Thu, Sep 17, 2015 at 11:19 AM, Duc Dang <dhd...@apm.com> wrote:
> The xhci platform driver does not work with system that only supports
> 64-bit DMA as it requests 32-bit DMA mask during driver initialization.
> This patch set addresses this issue and also adds XHCI-compliant USB
> Controller ACPI identification into xhci-platform driver.

Hi Greg, Mathias,

Arnd already ack-ed the first patch, please let me know if you have
more comment on this set?

>
> Changes from v7:
> - Only use dma_coerce_mask_and_coherent when
> dma_mask is NULL
> - Check the controller DMA capability and configure
> 32-bit dma_mask if it only supports 32-bit DMA
> - Patches is generated over v4.3-rc1
>
> Changes from v6:
> -Add WARN_ON if dma_mask is NULL
> -Use dma_coerce_mask_and_coherent to assign
> dma_mask and coherent_dma_mask
>
> Change from v5:
> -Change comment to "XHCI-compliant USB Controller" as
> "PNP0D10" ID is not X-Gene specific
> -Change comment
> -Assign dma_mask to coherent_dma_mask if dma_mask is NULL
> to make sure dma_set_mask_and_coherent does not fail prematurely.
>
> Changes from v4:
> -Remove #ifdef CONFIG_ACPI
> -Change comment
> -Assign dma_mask to coherent_dma_mask if dma_mask is NULL
> to make sure dma_set_mask_and_coherent does not fail prematurely.
>
> Changes from v3:
> -Regenerate the patch over 4.2-rc5
> -No code change
>
> Changes from v2
> -Replaced tristate with a boolean as the driver doesn't
> compile as a module
> -Correct --help-- to ---help---
>
> Changes from v1
> -Consolidated to use dma_set_mask_and_coherent
> -Got rid of the check against sizeof(dma_addr_t)
> -Renamed from "add support for APM X-Gene to xhci-platform"
> -Removed changes to arm64/Kconfig
> -Made CONFIG_USB_XHCI_PLATFORM a user selectable config option
>
>  drivers/usb/host/xhci-plat.c | 29 ++---
>  drivers/usb/host/xhci.c  | 10 ++
>  2 files changed, 32 insertions(+), 7 deletions(-)
>
> --
> 1.9.1
>

Regards,
Duc Dang.
--
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 v8 2/3] usb: Add support for ACPI identification to xhci-platform

2015-09-17 Thread Duc Dang
Provide the methods to let ACPI identify the need to use
xhci-platform. Change the Kconfig files so the
xhci-plat.o file is selectable during kernel config.

This has been tested on an ARM64 machine with platform XHCI, an
x86_64 machine with XHCI, and an x86_64 machine without XHCI.
There were no regressions or error messages on the machines
without platform XHCI.

[dhdang: regenerate the patch over v4.3-rc1 and address new comments]
Signed-off-by: Mark Langsdorf <mlang...@redhat.com>
Signed-off-by: Duc Dang <dhd...@apm.com>

---
 drivers/usb/host/xhci-plat.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 34c93e8..05647e6 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "xhci.h"
 #include "xhci-mvebu.h"
@@ -268,6 +269,13 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+static const struct acpi_device_id usb_xhci_acpi_match[] = {
+   /* XHCI-compliant USB Controller */
+   { "PNP0D10", },
+   { }
+};
+MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match);
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
@@ -275,6 +283,7 @@ static struct platform_driver usb_xhci_driver = {
.name = "xhci-hcd",
.pm = DEV_PM_OPS,
.of_match_table = of_match_ptr(usb_xhci_of_match),
+   .acpi_match_table = ACPI_PTR(usb_xhci_acpi_match),
},
 };
 MODULE_ALIAS("platform:xhci-hcd");
-- 
1.9.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 v8 3/3] usb: xhci: configure 32-bit DMA if the controller does not support 64-bit DMA

2015-09-17 Thread Duc Dang
This change avoids DMA error in the cases where dma_mask and
coherent_dma_mask of a 32-bit controller get configured as
DMA_BIT_MASK(64) when running on a 64-bit system.

Signed-off-by: Duc Dang <dhd...@apm.com>
---
 drivers/usb/host/xhci.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6b0f4a4..8cb8f39 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4908,6 +4908,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, 
xhci_get_quirks_t get_quirks)
!dma_set_mask(dev, DMA_BIT_MASK(64))) {
xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
+   } else {
+   /*
+* This is to avoid error in cases where a 32-bit USB
+* controller is used on a 64-bit capable system.
+*/
+   retval = dma_set_mask(dev, DMA_BIT_MASK(32));
+   if (retval)
+   return retval;
+   xhci_dbg(xhci, "Enabling 32-bit DMA addresses.\n");
+   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
}
 
xhci_dbg(xhci, "Calling HCD init\n");
-- 
1.9.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 v8 1/3] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-09-17 Thread Duc Dang
The xhci platform driver needs to work on systems that
either only support 64-bit DMA or only support 32-bit DMA.
Attempt to set a coherent dma mask for 64-bit DMA, and
attempt again with 32-bit DMA if that fails.

[dhdang: regenerate the patch over v4.3-rc1 and address new comments]
Signed-off-by: Mark Langsdorf <mlang...@redhat.com>
Tested-by: Mark Salter <msal...@redhat.com>
Signed-off-by: Duc Dang <dhd...@apm.com>

---
 drivers/usb/host/xhci-plat.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 890ad9d..34c93e8 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -93,14 +93,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq < 0)
return -ENODEV;
 
-   /* Initialize dma_mask and coherent_dma_mask to 32-bits */
-   ret = dma_set_coherent_mask(>dev, DMA_BIT_MASK(32));
-   if (ret)
-   return ret;
-   if (!pdev->dev.dma_mask)
-   pdev->dev.dma_mask = >dev.coherent_dma_mask;
+   /* Try to set 64-bit DMA first */
+   if (WARN_ON(!pdev->dev.dma_mask))
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(>dev,
+  DMA_BIT_MASK(64));
else
-   dma_set_mask(>dev, DMA_BIT_MASK(32));
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
+   if (ret) {
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
 
hcd = usb_create_hcd(driver, >dev, dev_name(>dev));
if (!hcd)
-- 
1.9.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 v8 0/3] usb: xhci-platform: Configure 64-bit DMA mask if the platform is capable

2015-09-17 Thread Duc Dang
The xhci platform driver does not work with system that only supports
64-bit DMA as it requests 32-bit DMA mask during driver initialization.
This patch set addresses this issue and also adds XHCI-compliant USB
Controller ACPI identification into xhci-platform driver.

Changes from v7:
- Only use dma_coerce_mask_and_coherent when
dma_mask is NULL
- Check the controller DMA capability and configure
32-bit dma_mask if it only supports 32-bit DMA
- Patches is generated over v4.3-rc1

Changes from v6:
-Add WARN_ON if dma_mask is NULL
-Use dma_coerce_mask_and_coherent to assign
dma_mask and coherent_dma_mask

Change from v5:
-Change comment to "XHCI-compliant USB Controller" as
"PNP0D10" ID is not X-Gene specific
-Change comment
-Assign dma_mask to coherent_dma_mask if dma_mask is NULL
to make sure dma_set_mask_and_coherent does not fail prematurely.

Changes from v4:
-Remove #ifdef CONFIG_ACPI
-Change comment
-Assign dma_mask to coherent_dma_mask if dma_mask is NULL
to make sure dma_set_mask_and_coherent does not fail prematurely.

Changes from v3:
-Regenerate the patch over 4.2-rc5
-No code change

Changes from v2
-Replaced tristate with a boolean as the driver doesn't
compile as a module
-Correct --help-- to ---help---

Changes from v1
-Consolidated to use dma_set_mask_and_coherent
-Got rid of the check against sizeof(dma_addr_t)
-Renamed from "add support for APM X-Gene to xhci-platform"
-Removed changes to arm64/Kconfig
-Made CONFIG_USB_XHCI_PLATFORM a user selectable config option

 drivers/usb/host/xhci-plat.c | 29 ++---
 drivers/usb/host/xhci.c  | 10 ++
 2 files changed, 32 insertions(+), 7 deletions(-)

-- 
1.9.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 v8 1/3] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-09-17 Thread Duc Dang
On Thu, Sep 17, 2015 at 12:51 PM, Arnd Bergmann <a...@arndb.de> wrote:
> On Thursday 17 September 2015 11:19:46 Duc Dang wrote:
>> The xhci platform driver needs to work on systems that
>> either only support 64-bit DMA or only support 32-bit DMA.
>> Attempt to set a coherent dma mask for 64-bit DMA, and
>> attempt again with 32-bit DMA if that fails.
>>
>> [dhdang: regenerate the patch over v4.3-rc1 and address new comments]
>> Signed-off-by: Mark Langsdorf <mlang...@redhat.com>
>> Tested-by: Mark Salter <msal...@redhat.com>
>> Signed-off-by: Duc Dang <dhd...@apm.com>
>>
>
> Acked-by: Arnd Bergmann <a...@arndb.de>

Thanks, Arnd.

-- 
Regards,
Duc Dang.
--
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 v7 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-09-10 Thread Duc Dang
On Tue, Sep 1, 2015 at 4:54 AM, Mathias Nyman
<mathias.ny...@linux.intel.com> wrote:
> On 31.08.2015 21:58, Duc Dang wrote:
>>
>> On Thu, Aug 20, 2015 at 12:38 PM, Duc Dang <dhd...@apm.com> wrote:
>>>
>>> The xhci platform driver needs to work on systems that
>>> either only support 64-bit DMA or only support 32-bit DMA.
>>> Attempt to set a coherent dma mask for 64-bit DMA, and
>>> attempt again with 32-bit DMA if that fails.
>>>
>>> [dhdang: regenerate the patch over 4.2-rc5 and address new comments]
>>> Signed-off-by: Mark Langsdorf <mlang...@redhat.com>
>>> Tested-by: Mark Salter <msal...@redhat.com>
>>> Signed-off-by: Duc Dang <dhd...@apm.com>
>>>
>>> ---
>>> Changes from v6:
>>>  -Add WARN_ON if dma_mask is NULL
>>>  -Use dma_coerce_mask_and_coherent to assign
>>>  dma_mask and coherent_dma_mask
>>>
>>> Changes from v5:
>>>  -Change comment
>>>  -Assign dma_mask to coherent_dma_mask if dma_mask is NULL
>>>  to make sure dma_set_mask_and_coherent does not fail
>>> prematurely.
>>>
>>> Changes from v4:
>>>  -None
>>>
>>> Changes from v3:
>>>  -Re-generate the patch over 4.2-rc5
>>>  -No code change.
>>>
>>> Changes from v2:
>>>  -None
>>>
>>> Changes from v1:
>>>  -Consolidated to use dma_set_mask_and_coherent
>>>  -Got rid of the check against sizeof(dma_addr_t)
>>>
>>>   drivers/usb/host/xhci-plat.c | 21 +
>>>   1 file changed, 13 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>>> index 890ad9d..e4c7f9d 100644
>>> --- a/drivers/usb/host/xhci-plat.c
>>> +++ b/drivers/usb/host/xhci-plat.c
>>> @@ -93,14 +93,19 @@ static int xhci_plat_probe(struct platform_device
>>> *pdev)
>>>  if (irq < 0)
>>>  return -ENODEV;
>>>
>>> -   /* Initialize dma_mask and coherent_dma_mask to 32-bits */
>>> -   ret = dma_set_coherent_mask(>dev, DMA_BIT_MASK(32));
>>> -   if (ret)
>>> -   return ret;
>>> -   if (!pdev->dev.dma_mask)
>>> -   pdev->dev.dma_mask = >dev.coherent_dma_mask;
>>> -   else
>>> -   dma_set_mask(>dev, DMA_BIT_MASK(32));
>>> +   /* Throw a waring if broken platform code didn't initialize
>>> dma_mask */
>>> +   WARN_ON(!pdev->dev.dma_mask);
>>> +   /*
>>> +* Try setting dma_mask and coherent_dma_mask to 64 bits,
>>> +* then try 32 bits
>>> +*/
>>> +   ret = dma_coerce_mask_and_coherent(>dev, DMA_BIT_MASK(64));
>>> +   if (ret) {
>>> +   ret = dma_coerce_mask_and_coherent(>dev,
>>> +  DMA_BIT_MASK(32));
>>> +   if (ret)
>>> +   return ret;
>>> +   }
>>>
>>>  hcd = usb_create_hcd(driver, >dev, dev_name(>dev));
>>>  if (!hcd)
>>> --
>>> 1.9.1
>>>
>>
>> Hi Greg, Arnd, Russell,
>>
>> Do you have any more comment about this patch set?
>>
>
> I'm not sure I fully understand why we need to try the 64 bit DMA mask in
> platform probe.
>
> As I understood it we just want to have some DMA mask set before calling
> usb_create_hcd()
> to make sure USB core gets the "uses_dma" flag set and dma_set_mask() won't
> fail because of
> missing dev->dma_mask.
>
> The correct DMA mask is set later in xhci_gen_setup()
>
> We also need to make sure the controller supports 64bit addressing
> capability before setting a 64 bit DMA mask.
> (bit 0 in HCCPARAMS)
>
> So for platform devices it goes look go this:
>
> xhci_plat_probe()
>   usb_create_hcd()
> usb_create_shared_hcd()
>   hcd->self.uses_dma = (dev->dma_mask != NULL);
>   usb_add_hcd()
> hcd->driver->reset()  (.reset = xhci_plat_setup)
>   xhci_plat_setup()
> xhci_gen_setup()
>   if (HCC_64BIT_ADDR(xhci->hcc_params) && !dma_set_mask(dev,
> DMA_BIT_MASK(64))) {
> xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
> dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
>   }
>
> or

Re: [PATCH v7 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-08-31 Thread Duc Dang
On Thu, Aug 20, 2015 at 12:38 PM, Duc Dang <dhd...@apm.com> wrote:
> The xhci platform driver needs to work on systems that
> either only support 64-bit DMA or only support 32-bit DMA.
> Attempt to set a coherent dma mask for 64-bit DMA, and
> attempt again with 32-bit DMA if that fails.
>
> [dhdang: regenerate the patch over 4.2-rc5 and address new comments]
> Signed-off-by: Mark Langsdorf <mlang...@redhat.com>
> Tested-by: Mark Salter <msal...@redhat.com>
> Signed-off-by: Duc Dang <dhd...@apm.com>
>
> ---
> Changes from v6:
> -Add WARN_ON if dma_mask is NULL
> -Use dma_coerce_mask_and_coherent to assign
> dma_mask and coherent_dma_mask
>
> Changes from v5:
> -Change comment
> -Assign dma_mask to coherent_dma_mask if dma_mask is NULL
> to make sure dma_set_mask_and_coherent does not fail prematurely.
>
> Changes from v4:
> -None
>
> Changes from v3:
> -Re-generate the patch over 4.2-rc5
> -No code change.
>
> Changes from v2:
> -None
>
> Changes from v1:
> -Consolidated to use dma_set_mask_and_coherent
> -Got rid of the check against sizeof(dma_addr_t)
>
>  drivers/usb/host/xhci-plat.c | 21 +
>  1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 890ad9d..e4c7f9d 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -93,14 +93,19 @@ static int xhci_plat_probe(struct platform_device *pdev)
> if (irq < 0)
> return -ENODEV;
>
> -   /* Initialize dma_mask and coherent_dma_mask to 32-bits */
> -   ret = dma_set_coherent_mask(>dev, DMA_BIT_MASK(32));
> -   if (ret)
> -   return ret;
> -   if (!pdev->dev.dma_mask)
> -   pdev->dev.dma_mask = >dev.coherent_dma_mask;
> -   else
> -   dma_set_mask(>dev, DMA_BIT_MASK(32));
> +   /* Throw a waring if broken platform code didn't initialize dma_mask 
> */
> +   WARN_ON(!pdev->dev.dma_mask);
> +   /*
> +* Try setting dma_mask and coherent_dma_mask to 64 bits,
> +* then try 32 bits
> +*/
> +   ret = dma_coerce_mask_and_coherent(>dev, DMA_BIT_MASK(64));
> +   if (ret) {
> +   ret = dma_coerce_mask_and_coherent(>dev,
> +  DMA_BIT_MASK(32));
> +       if (ret)
> +   return ret;
> +   }
>
> hcd = usb_create_hcd(driver, >dev, dev_name(>dev));
> if (!hcd)
> --
> 1.9.1
>

Hi Greg, Arnd, Russell,

Do you have any more comment about this patch set?

-- 
Duc Dang.
--
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: 4.2 kernel trace when hot unplug a mounted USB/SATA/MMC devices with ext2/ext3/ext4 file system

2015-08-24 Thread Duc Dang
On Sat, Aug 15, 2015 at 1:58 AM, Christoph Hellwig h...@lst.de wrote:
 On Fri, Aug 14, 2015 at 05:52:44PM -0700, Duc Dang wrote:
 The commit 08439fec26 ext4: remove block_device_ejected only causes
 issue with ext4 and
 trying reverting it helps our test passes with ext4.

 But how about the same issue with ext2/ext3?

 I tried to fix the underlying issue, but I either failed to fully
 fixed it or someone regressed it.

 Can you if rev 08439fec26 on it's own works to see if I missed
 a case or it was regressed later?

For more information. We tested kernel at commit 5f80f62ada ext4:
remove useless condition in if statement.
(right before your commit) and still saw the issue.

df3305156f989339529b3d6744b898d498fb1f7b [media] v4l: xilinx: Add
Xilinx Video IP core
08439fec266c3cc5702953b4f54bdf5649357de0 ext4: remove block_device_ejected
5f80f62adae2a2920781a847805d34b36b323f7d ext4: remove useless
condition in if statement.
c9bca8b33118573da9b7ac2ea21947a8e4d287dd [media] v4l: of: Add
v4l2_of_parse_link() function

Further more, the issue does not happen with 3.19-rc7 but happens with 4.00-rc1

-- 
Regards,
Duc Dang.
--
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 v7 2/2] usb: Add support for ACPI identification to xhci-platform

2015-08-20 Thread Duc Dang
Provide the methods to let ACPI identify the need to use
xhci-platform. Change the Kconfig files so the
xhci-plat.o file is selectable during kernel config.

This has been tested on an ARM64 machine with platform XHCI, an
x86_64 machine with XHCI, and an x86_64 machine without XHCI.
There were no regressions or error messages on the machines
without platform XHCI.

[dhdang: regenerate the patch over 4.2-rc5 and address new comments]
Signed-off-by: Mark Langsdorf mlang...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Changes from v6:
-None

Change from v5:
-Change comment to XHCI-compliant USB Controller as
PNP0D10 ID is not X-Gene specific

Changes from v4:
-Remove #ifdef CONFIG_ACPI

Changes from v3:
-Regenerate the patch over 4.2-rc5
-No code change

Changes from v2
-Replaced tristate with a boolean as the driver doesn't
compile as a module
-Correct --help-- to ---help---

Changes from v1
-Renamed from add support for APM X-Gene to xhci-platform
-Removed changes to arm64/Kconfig
-Made CONFIG_USB_XHCI_PLATFORM a user selectable config option

 drivers/usb/host/Kconfig | 7 ++-
 drivers/usb/host/xhci-plat.c | 9 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 8afc3c1..96231ee 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -32,7 +32,12 @@ config USB_XHCI_PCI
default y
 
 config USB_XHCI_PLATFORM
-   tristate
+   tristate xHCI platform driver support
+   ---help---
+ Say 'Y' to enable the support for the xHCI host controller
+ as a platform device. Many ARM SoCs provide USB this way.
+
+ If unsure, say 'Y'.
 
 config USB_XHCI_MVEBU
tristate xHCI support for Marvell Armada 375/38x
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index e4c7f9d..6c03e1c 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include linux/usb/phy.h
 #include linux/slab.h
 #include linux/usb/xhci_pdriver.h
+#include linux/acpi.h
 
 #include xhci.h
 #include xhci-mvebu.h
@@ -267,6 +268,13 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+static const struct acpi_device_id usb_xhci_acpi_match[] = {
+   /* XHCI-compliant USB Controller */
+   { PNP0D10, },
+   { }
+};
+MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match);
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
@@ -274,6 +282,7 @@ static struct platform_driver usb_xhci_driver = {
.name = xhci-hcd,
.pm = DEV_PM_OPS,
.of_match_table = of_match_ptr(usb_xhci_of_match),
+   .acpi_match_table = ACPI_PTR(usb_xhci_acpi_match),
},
 };
 MODULE_ALIAS(platform:xhci-hcd);
-- 
1.9.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 v7 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-08-20 Thread Duc Dang
The xhci platform driver needs to work on systems that
either only support 64-bit DMA or only support 32-bit DMA.
Attempt to set a coherent dma mask for 64-bit DMA, and
attempt again with 32-bit DMA if that fails.

[dhdang: regenerate the patch over 4.2-rc5 and address new comments]
Signed-off-by: Mark Langsdorf mlang...@redhat.com
Tested-by: Mark Salter msal...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Changes from v6:
-Add WARN_ON if dma_mask is NULL
-Use dma_coerce_mask_and_coherent to assign
dma_mask and coherent_dma_mask

Changes from v5:
-Change comment
-Assign dma_mask to coherent_dma_mask if dma_mask is NULL
to make sure dma_set_mask_and_coherent does not fail prematurely.

Changes from v4:
-None

Changes from v3:
-Re-generate the patch over 4.2-rc5
-No code change.

Changes from v2:
-None

Changes from v1:
-Consolidated to use dma_set_mask_and_coherent
-Got rid of the check against sizeof(dma_addr_t)

 drivers/usb/host/xhci-plat.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 890ad9d..e4c7f9d 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -93,14 +93,19 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq  0)
return -ENODEV;
 
-   /* Initialize dma_mask and coherent_dma_mask to 32-bits */
-   ret = dma_set_coherent_mask(pdev-dev, DMA_BIT_MASK(32));
-   if (ret)
-   return ret;
-   if (!pdev-dev.dma_mask)
-   pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
-   else
-   dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
+   /* Throw a waring if broken platform code didn't initialize dma_mask */
+   WARN_ON(!pdev-dev.dma_mask);
+   /*
+* Try setting dma_mask and coherent_dma_mask to 64 bits,
+* then try 32 bits
+*/
+   ret = dma_coerce_mask_and_coherent(pdev-dev, DMA_BIT_MASK(64));
+   if (ret) {
+   ret = dma_coerce_mask_and_coherent(pdev-dev,
+  DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
 
hcd = usb_create_hcd(driver, pdev-dev, dev_name(pdev-dev));
if (!hcd)
-- 
1.9.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 v5 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-08-19 Thread Duc Dang
On Sat, Aug 15, 2015 at 1:05 PM, Arnd Bergmann a...@arndb.de wrote:

 On Saturday 08 August 2015 13:31:02 Duc Dang wrote:
  
   If we know that pdev-dev.dma_mask will always be initialised at this
   point, then the above change is fine.  If not, it's introducing a
   regression - dma_set_mask_and_coherent() will fail if pdev-dev.dma_mask
   is NULL (depending on the architectures implementation of dma_set_mask()).
  
   Prefixing the above change with the two lines I mention above would
   ensure equivalent behaviour.  Even if we do want to get rid of this,
   I'd advise to do it as a separate patch after this change, which can
   be independently reverted if there's problems with its removal.
  
  Hi Russell,
 
  I will add the 2 lines you mentioned back to next version of the
  patch. It is safer to do it that way as I do not see
  pdev-dev.dma_mask gets initialized before the call
  dma_set_mask_and_coherent  inside this xhci_plat.c file.

 It would be good to add a WARN_ON() to the case where dma_mask
 is a NULL pointer at the least. That way, we will at least
 find out if there are some broken platforms that do not correctly
 initialize the mask pointer.

Hi Arnd,

So the check will look like this, please let me know what do you think:
if (!pdev-dev.dma_mask) {
WARN_ON(1);
/* Initialize dma_mask if the broken platform code has
not done so */
pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
}


 Arnd




-- 
Regards,
Duc Dang.
--
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: 4.2 kernel trace when hot unplug a mounted USB/SATA/MMC devices with ext2/ext3/ext4 file system

2015-08-14 Thread Duc Dang
On Fri, Aug 14, 2015 at 1:09 AM, Jan Kara j...@suse.cz wrote:
 On Thu 13-08-15 09:01:28, Darrick J. Wong wrote:
 On Wed, Aug 12, 2015 at 08:17:28PM -0700, Duc Dang wrote:
  Hi Theodore, Andreas, Jan, Andrew and All,
 
  We are seeing kernel trace when we disconnect an USB/SATA/MMC devices
  that has its ext2/ext3/ext4 partition currently mounted. These traces
  are seen with kernel 4.2-rc5 on APM Arm64 X-Gene platforms. Similar
  issue also happens on an x86 machine (Lenovo T420s running Fedora Core
  22 (Linux 4.1.x))

 Sounds like this issue:
 https://bugzilla.kernel.org/show_bug.cgi?id=101011

 Hum, the above bug mentions that at least for ext4 this is a regression
 caused by commit 08439fec26 ext4: remove block_device_ejected from
 Christoph, let's add him to CC. The assumption of the commit is that
 bdi-dev never goes away so there's no point in checking it but these guys
 are apparently able to make bdi go away before fs is done with it... Any
 idea Christoph?

The commit 08439fec26 ext4: remove block_device_ejected only causes
issue with ext4 and
trying reverting it helps our test passes with ext4.

But how about the same issue with ext2/ext3?


 Honza

  We also tested with xfs kernel and kernel complains with some error
  message but there is no trace:
 
  usb 1-1: USB disconnect, device number 3
  XFS (sda1): Unmounting Filesystem
  XFS (sda1): metadata I/O error: block 0x1ddc12 (xlog_iodone) error 19 
  numblks
  64
  XFS (sda1): xfs_do_force_shutdown(0x2) called from line 1180 of file
  /projects/svdc/P4wsIPCSW/buildsw_shadowcat_2_03/shadowcat/linux/fs/xfs/xfs_log.c.
   Return address = 0xffc0003aa8d8
  XFS (sda1): Log I/O Error Detected.  Shutting down filesystem
  XFS (sda1): Unable to update superblock counters. Freespace may not be 
  correct
  on next mount.
  XFS (sda1): xfs_log_force: error -5 returned.
  XFS (sda1): Please umount the filesystem and rectify the problem(s)
 
  Below are traces for each case. Do you aware of this issue and is
  there a fix for it?
 
  CASE 1: SATA with ext2 partition:
 
  EXT2-fs (sda1): previous I/O error to superblock detected
 
  Unable to handle kernel paging request at virtual address 1ff256000
  pgd = ffc0e784b000
  [1ff256000] *pgd=, *pud=
  Internal error: Oops: 9605 [#1] PREEMPT SMP
  Modules linked in:
  CPU: 4 PID: 1484 Comm: umount Not tainted 
  4.1.0-xgene_sw_2.03.05-beta_rc_pm #1
  Hardware name: APM X-Gene Mustang board (DT)
  task: ffc1ed5d3840 ti: ffc0e79dc000 task.ti: ffc0e79dc000
  PC is at __percpu_counter_add+0x2c/0x10c
  LR is at account_page_dirtied+0x78/0x12c
  pc : [ffc00043666c] lr : [ffc000147180] pstate: 81c5
  sp : ffc0e79dfc40
  x29: ffc0e79dfc40 x28: ffc0e79dc000
  x27: ffc000927000 x26: 0027
  x25: 011a x24: 0015
  x23: 8000 x22: 0140
  x21: ffc000d33000 x20: ffc1f6440fb8
  x19: ffbec7b3e500 x18: 
  x17: 007f8d95bfd0 x16: ffc0001dfad0
  x15: 003b9aca x14: 0ffe
  x13: 0020 x12: 0101010101010101
  x11: 0174 x10: 0006
  x9 : ffc1fff1e35c x8 : 746564206b636f6c
  x7 : ffc000d33618 x6 : 0001ff256000
  x5 : ffc0e79dfc40 x4 : ffc0e79dc000
  x3 :  x2 : 0020
  x1 : 0001 x0 : 0001ff256000
 
  Process umount (pid: 1484, stack limit = 0xffc0e79dc020)
  Stack: (0xffc0e79dfc40 to 0xffc0e79e)
  fc40: e79dfc70 ffc0 00147180 ffc0 c7b3e500 ffbe f6440f78 
  ffc1
  fc60: e79dfc70 ffc0 0014716c ffc0 e79dfcb0 ffc0 001ccd7c 
  ffc0
  fc80: c7b3e500 ffbe f6b28f48 ffc1 f6b28f60 ffc1 e79dfca0 
  ffc0
  fca0:   f6b28f48 ffc1 e79dfd00 ffc0 001cdfd4 
  ffc0
  fcc0: c7b3e500 ffbe ecf94400 ffc1 ee6022d8 ffc0  
  
  fce0: 8000  00226674 ffc0 e79dfd20 ffc0  
  
  fd00: e79dfd20 ffc0 0022ac84 ffc0 f6ff7000 ffc1 ecf94400 
  ffc1
  fd20: e79dfd50 ffc0 0022ad0c ffc0 f677e380 ffc1 ecf94400 
  ffc1
  fd40: f6ff7000 ffc1 ed5d3840 ffc1 e79dfd90 ffc0 001cb0c4 
  ffc0
  fd60: f6ff7000 ffc1 f6ff70a8 ffc1 00946080 ffc0 001b5ff0 
  ffc0
  fd80: f6ff7000 ffc1   e79dfdb0 ffc0 001a05e0 
  ffc0
  fda0: f6ff7000 ffc1 0083  e79dfde0 ffc0 001a0958 
  ffc0
  fdc0: f6b28d00 ffc1 0083  00db9000 ffc0 0015 
  
  fde0: e79dfe10 ffc0 001a0c68 ffc0 f6ff7000 ffc1 00d511e8 
  ffc0
  fe00: 00db9000 ffc0 00d511e8 ffc0 e79dfe30 ffc0 001a1168 
  ffc0
  fe20: f6ff7000 ffc1   e79dfe50 ffc0 001bcef0 
  ffc0
  fe40: f6c8b080 ffc1 0015  e79dfe70 ffc0 001bcf94

4.2 kernel trace when hot unplug a mounted USB/SATA/MMC devices with ext2/ext3/ext4 file system

2015-08-12 Thread Duc Dang
    8000 80808080  
7f00: 80808080 0080 ff2f6172 fefefefe 0027  0004 
7f20: 01010101 01010101 0030  0006  74617269 2c656d69
7f40:   578b  7f41c180 007f 9527ced0 0055
7f60:   aca13490 0055 aca13490 0055 0002 
7f80: 0002  aca134f0 0055   f88d27c0 007f
7fa0: aca134d0 0055 95279df1 0055   f88d2650 007f
7fc0: 95226ae0 0055 f88d2500 007f 7f41c1c8 007f 8000 
7fe0: aca134d0 0055 0027     
Call trace:
[ffc00043666c] __percpu_counter_add+0x2c/0x10c
[ffc00014717c] account_page_dirtied+0x74/0x12c
[ffc0001ccd78] __set_page_dirty+0x48/0xd0
[ffc0001cdfd0] mark_buffer_dirty+0x74/0xa8
[ffc0002456dc] ext4_commit_super+0x130/0x1f8
[ffc000245f20] __ext4_abort+0x3c/0x13c
[ffc0002465d4] ext4_put_super+0x278/0x2f4
[ffc0001a0618] generic_shutdown_super+0x68/0xd8
[ffc0001a0954] kill_block_super+0x1c/0x70
[ffc0001a0c64] deactivate_locked_super+0x54/0x84
[ffc0001a1164] deactivate_super+0x8c/0x9c
[ffc0001bceec] cleanup_mnt+0x38/0x84
[ffc0001bcf90] __cleanup_mnt+0xc/0x18
[ffcce478] task_work_run+0x98/0xec
[ffc897fc] do_notify_resume+0x54/0x68
Code: 11000400 b9001880 f9401283 d538d080 (b8a36813)
---[ end trace 3db0dd3586537f6d ]---
note: umount[1470] exited with preempt_count 2

CASE 5: Trace on x86 Lenovo T420 machine running Fedora core 22 (Kernel 4.1.x)
[ffc899e4] dump_backtrace+0x0/0x11c
[ffc89b10]show_stack+0x10/0x1c
[ffc000573614] dump_stack+0x80/0xc4
[ffcb1664] warn_slowpath_common+0x90/0xc8
[ffcb1760] warn_slowpath_null+0x14/0x20
[ffc0001ca500] __blkdev_put+0xe0/0x210
[ffc0001cae18] blkdev_put+0x4c/0x158
[ffc00019853c] kill_block_super+0x34/0x70
[ffc000198838] deactivate_locked_super+0x54/0x84
[ffc000198d38] deactivate_super+0x8c/0x9c
[ffc0001b46d4] cleanup_mnt+0x38/0x84
[ffc0001b4778] __cleanup_mnt+0xc/0x18
[ffcca4b0] task_work_run+0x94/0xe8
[ffc89728] do_notify_resume+0x54/0x68
---[ end trace 1fa355ac70316ea2 ]---


-- 
Regards,
Duc Dang.
--
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 v6 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-08-10 Thread Duc Dang
The xhci platform driver needs to work on systems that
either only support 64-bit DMA or only support 32-bit DMA.
Attempt to set a coherent dma mask for 64-bit DMA, and
attempt again with 32-bit DMA if that fails.

[dhdang: regenerate the patch over 4.2-rc5 and address new comments]
Signed-off-by: Mark Langsdorf mlang...@redhat.com
Tested-by: Mark Salter msal...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Changes from v5:
-Change comment
-Assign dma_mask to coherent_dma_mask if dma_mask is NULL
to make sure dma_set_mask_and_coherent does not fail prematurely.

Changes from v4:
-None

Changes from v3:
-Re-generate the patch over 4.2-rc5
-No code change.

Changes from v2:
-None

Changes from v1:
-Consolidated to use dma_set_mask_and_coherent
-Got rid of the check against sizeof(dma_addr_t)

 drivers/usb/host/xhci-plat.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 890ad9d..5d1b84b 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -93,14 +93,18 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq  0)
return -ENODEV;
 
-   /* Initialize dma_mask and coherent_dma_mask to 32-bits */
-   ret = dma_set_coherent_mask(pdev-dev, DMA_BIT_MASK(32));
-   if (ret)
-   return ret;
+   /*
+* Try setting dma_mask and coherent_dma_mask to 64 bits,
+* then try 32 bits
+*/
if (!pdev-dev.dma_mask)
pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
-   else
-   dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
+   ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(64));
+   if (ret) {
+   ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
 
hcd = usb_create_hcd(driver, pdev-dev, dev_name(pdev-dev));
if (!hcd)
-- 
1.9.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 v6 2/2] usb: Add support for ACPI identification to xhci-platform

2015-08-10 Thread Duc Dang
Provide the methods to let ACPI identify the need to use
xhci-platform. Change the Kconfig files so the
xhci-plat.o file is selectable during kernel config.

This has been tested on an ARM64 machine with platform XHCI, an
x86_64 machine with XHCI, and an x86_64 machine without XHCI.
There were no regressions or error messages on the machines
without platform XHCI.

[dhdang: regenerate the patch over 4.2-rc5 and address new comments]
Signed-off-by: Mark Langsdorf mlang...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Change from v5:
Change comment to XHCI-compliant USB Controller as
PNP0D10 ID is not X-Gene specific

Changes from v4:
Remove #ifdef CONFIG_ACPI

Changes from v3:
Regenerate the patch over 4.2-rc5
No code change

Changes from v2
Replaced tristate with a boolean as the driver doesn't
compile as a module
Correct --help-- to ---help---

Changes from v1
Renamed from add support for APM X-Gene to xhci-platform
Removed changes to arm64/Kconfig
Made CONFIG_USB_XHCI_PLATFORM a user selectable config option

 drivers/usb/host/Kconfig | 7 ++-
 drivers/usb/host/xhci-plat.c | 9 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 8afc3c1..96231ee 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -32,7 +32,12 @@ config USB_XHCI_PCI
default y
 
 config USB_XHCI_PLATFORM
-   tristate
+   tristate xHCI platform driver support
+   ---help---
+ Say 'Y' to enable the support for the xHCI host controller
+ as a platform device. Many ARM SoCs provide USB this way.
+
+ If unsure, say 'Y'.
 
 config USB_XHCI_MVEBU
tristate xHCI support for Marvell Armada 375/38x
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 5d1b84b..7ec2d31 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include linux/usb/phy.h
 #include linux/slab.h
 #include linux/usb/xhci_pdriver.h
+#include linux/acpi.h
 
 #include xhci.h
 #include xhci-mvebu.h
@@ -266,6 +267,13 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+static const struct acpi_device_id usb_xhci_acpi_match[] = {
+   /* XHCI-compliant USB Controller */
+   { PNP0D10, },
+   { }
+};
+MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match);
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
@@ -273,6 +281,7 @@ static struct platform_driver usb_xhci_driver = {
.name = xhci-hcd,
.pm = DEV_PM_OPS,
.of_match_table = of_match_ptr(usb_xhci_of_match),
+   .acpi_match_table = ACPI_PTR(usb_xhci_acpi_match),
},
 };
 MODULE_ALIAS(platform:xhci-hcd);
-- 
1.9.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 v4 2/2] usb: Add support for ACPI identification to xhci-platform

2015-08-08 Thread Duc Dang
On Sat, Aug 8, 2015 at 8:37 AM, Greg KH gre...@linuxfoundation.org wrote:
 On Sat, Aug 08, 2015 at 07:43:40AM +0200, Javier Martinez Canillas wrote:
 Hello Greg,

 On Sat, Aug 8, 2015 at 3:29 AM, Greg KH gre...@linuxfoundation.org wrote:
  On Fri, Aug 07, 2015 at 06:03:36PM -0700, Duc Dang wrote:
  Provide the methods to let ACPI identify the need to use
  xhci-platform. Change the Kconfig files so the
  xhci-plat.o file is selectable during kernel config.
 
  This has been tested on an ARM64 machine with platform XHCI, an
  x86_64 machine with XHCI, and an x86_64 machine without XHCI.
  There were no regressions or error messages on the machines
  without platform XHCI.
 
  [dhdang: regenerate the patch over 4.2-rc5]
  Signed-off-by: Mark Langsdorf mlang...@redhat.com
  Signed-off-by: Duc Dang dhd...@apm.com
 
  ---
  Changes from v3:
Regenerate the patch over 4.2-rc5
No code change
 
  Changes from v2
Replaced tristate with a boolean as the driver doesn't
compile as a module
Correct --help-- to ---help---
 
  Changes from v1
Renamed from add support for APM X-Gene to xhci-platform
Removed changes to arm64/Kconfig
Made CONFIG_USB_XHCI_PLATFORM a user selectable config option
 
   drivers/usb/host/Kconfig |  7 ++-
   drivers/usb/host/xhci-plat.c | 11 +++
   2 files changed, 17 insertions(+), 1 deletion(-)
 
  diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
  index 8afc3c1..96231ee 100644
  --- a/drivers/usb/host/Kconfig
  +++ b/drivers/usb/host/Kconfig
  @@ -32,7 +32,12 @@ config USB_XHCI_PCI
  default y
 
   config USB_XHCI_PLATFORM
  - tristate
  + tristate xHCI platform driver support
  + ---help---
  +   Say 'Y' to enable the support for the xHCI host controller
  +   as a platform device. Many ARM SoCs provide USB this way.
  +
  +   If unsure, say 'Y'.
 
   config USB_XHCI_MVEBU
tristate xHCI support for Marvell Armada 375/38x
  diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
  index 5d03f8b..14b40d2 100644
  --- a/drivers/usb/host/xhci-plat.c
  +++ b/drivers/usb/host/xhci-plat.c
  @@ -19,6 +19,7 @@
   #include linux/usb/phy.h
   #include linux/slab.h
   #include linux/usb/xhci_pdriver.h
  +#include linux/acpi.h
 
   #include xhci.h
   #include xhci-mvebu.h
  @@ -262,6 +263,15 @@ static const struct of_device_id usb_xhci_of_match[] 
  = {
   MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
   #endif
 
  +#ifdef CONFIG_ACPI
 
  You shoudn't need this #ifdef, right?
 

 Why it is not needed?

 Why is it needed?

 The driver does .acpi_match_table = ACPI_PTR(usb_xhci_acpi_match) and
 ACPI_PTR() is NULL if CONFIG_ACPI is not enabled. Which can happen
 AFAIU since the driver also supports OF. So without the #ifdef guards,
 .acpi_match_table = NULL and the struct acpi_device_id
 usb_xhci_acpi_match[] will be built but not used.

 Which is just fine, right?

 Or am I missing something?

 Don't put #ifdef in .c files if at all possible is the kernel style
 rules.

I tested booting with both device tree and ACPI with the new code that
has #ifdef CONFIG_ACPI removed and USB works fine with my X-Gene Arm64
platform.


 thanks,

 greg k-h



-- 
Regards,
Duc Dang.
--
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 v5 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-08-08 Thread Duc Dang
On Sat, Aug 8, 2015 at 2:22 AM, Russell King - ARM Linux
li...@arm.linux.org.uk wrote:
 On Fri, Aug 07, 2015 at 08:18:48PM -0700, Duc Dang wrote:
 diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 index 890ad9d..5d03f8b 100644
 --- a/drivers/usb/host/xhci-plat.c
 +++ b/drivers/usb/host/xhci-plat.c
 @@ -93,14 +93,14 @@ static int xhci_plat_probe(struct platform_device *pdev)
   if (irq  0)
   return -ENODEV;

 - /* Initialize dma_mask and coherent_dma_mask to 32-bits */
 - ret = dma_set_coherent_mask(pdev-dev, DMA_BIT_MASK(32));
 - if (ret)
 - return ret;
 - if (!pdev-dev.dma_mask)
 - pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
 - else
 - dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
 + /* Try setting the coherent_dma_mask to 64 bits, then try 32 bits */
 + ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(64));
 + if (ret) {
 + ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
 + if (ret)
 + return ret;
 + }

 Note that dma_set_mask_and_coherent() and the original code are not
 equivalent because of this:

 if (!pdev-dev.dma_mask)
 pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;

 If we know that pdev-dev.dma_mask will always be initialised at this
 point, then the above change is fine.  If not, it's introducing a
 regression - dma_set_mask_and_coherent() will fail if pdev-dev.dma_mask
 is NULL (depending on the architectures implementation of dma_set_mask()).

 Prefixing the above change with the two lines I mention above would
 ensure equivalent behaviour.  Even if we do want to get rid of this,
 I'd advise to do it as a separate patch after this change, which can
 be independently reverted if there's problems with its removal.

Hi Russell,

I will add the 2 lines you mentioned back to next version of the
patch. It is safer to do it that way as I do not see
pdev-dev.dma_mask gets initialized before the call
dma_set_mask_and_coherent  inside this xhci_plat.c file.

 --
 FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
 according to speedtest.net.

-- 
Regards,
Duc Dang.
--
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 v3 1/2] make xhci platform driver use 64 bit or 32 bit DMA

2015-08-07 Thread Duc Dang
Hi Greg,

On Wed, Jul 29, 2015 at 10:18 PM, Loc Ho l...@apm.com wrote:
 Hi,

  The xhci platform driver needs to work on systems that either only
  support 64-bit DMA or only support 32-bit DMA. Attempt to set a
  coherent dma mask for 64-bit DMA, and attempt again with 32-bit
  DMA if that fails.
 
  Signed-off-by: Mark Langsdorf mlang...@redhat.com
  Tested-by: Mark Salter msal...@redhat.com
  ---
  Changes from v2:
  None
  Changes from v1:
  Consolidated to use dma_set_mask_and_coherent
  Got rid of the check against sizeof(dma_addr_t)
 
   drivers/usb/host/xhci-plat.c | 16 
   1 file changed, 8 insertions(+), 8 deletions(-)

 Any reason why this isn't pulled in already? It is already 6 months
 and seems to be ack'ed already.

 Does it work for you on 4.2-rc4?  Is it still needed?

 Care to repost the whole patch updated?

I tested this v3 patch set with 4.2-rc5 and it works fine on my X-Gene
arm64 platform.

The only problem is 'git am' will complain (due to line offset
changed, I guess). Using 'patch -p 1' to apply the 2 patches is fine.

I will repost the whole set over 4.2-rc5.


 Let me apply and see if it still work as is.

 -Loc

-- 
Regards,
Duc Dang.
--
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 v4 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-08-07 Thread Duc Dang
The xhci platform driver needs to work on systems that
either only support 64-bit DMA or only support 32-bit DMA. 
Attempt to set a coherent dma mask for 64-bit DMA, and 
attempt again with 32-bit DMA if that fails.

[dhdang: regenerate the patch over 4.2-rc5]
Signed-off-by: Mark Langsdorf mlang...@redhat.com
Tested-by: Mark Salter msal...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Changes from v3:
Re-generate the patch over 4.2-rc5
No code change.

Changes from v2:
None

Changes from v1:
Consolidated to use dma_set_mask_and_coherent
Got rid of the check against sizeof(dma_addr_t)

 drivers/usb/host/xhci-plat.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 890ad9d..5d03f8b 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -93,14 +93,14 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq  0)
return -ENODEV;
 
-   /* Initialize dma_mask and coherent_dma_mask to 32-bits */
-   ret = dma_set_coherent_mask(pdev-dev, DMA_BIT_MASK(32));
-   if (ret)
-   return ret;
-   if (!pdev-dev.dma_mask)
-   pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
-   else
-   dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
+   /* Try setting the coherent_dma_mask to 64 bits, then try 32 bits */
+   ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(64));
+   if (ret) {
+   ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
 
hcd = usb_create_hcd(driver, pdev-dev, dev_name(pdev-dev));
if (!hcd)
-- 
1.9.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 v4 2/2] usb: Add support for ACPI identification to xhci-platform

2015-08-07 Thread Duc Dang
Provide the methods to let ACPI identify the need to use
xhci-platform. Change the Kconfig files so the
xhci-plat.o file is selectable during kernel config.

This has been tested on an ARM64 machine with platform XHCI, an
x86_64 machine with XHCI, and an x86_64 machine without XHCI.
There were no regressions or error messages on the machines
without platform XHCI.

[dhdang: regenerate the patch over 4.2-rc5]
Signed-off-by: Mark Langsdorf mlang...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Changes from v3:
Regenerate the patch over 4.2-rc5
No code change

Changes from v2
Replaced tristate with a boolean as the driver doesn't
compile as a module
Correct --help-- to ---help---

Changes from v1
Renamed from add support for APM X-Gene to xhci-platform
Removed changes to arm64/Kconfig
Made CONFIG_USB_XHCI_PLATFORM a user selectable config option

 drivers/usb/host/Kconfig |  7 ++-
 drivers/usb/host/xhci-plat.c | 11 +++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 8afc3c1..96231ee 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -32,7 +32,12 @@ config USB_XHCI_PCI
default y
 
 config USB_XHCI_PLATFORM
-   tristate
+   tristate xHCI platform driver support
+   ---help---
+ Say 'Y' to enable the support for the xHCI host controller
+ as a platform device. Many ARM SoCs provide USB this way.
+
+ If unsure, say 'Y'.
 
 config USB_XHCI_MVEBU
tristate xHCI support for Marvell Armada 375/38x
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 5d03f8b..14b40d2 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include linux/usb/phy.h
 #include linux/slab.h
 #include linux/usb/xhci_pdriver.h
+#include linux/acpi.h
 
 #include xhci.h
 #include xhci-mvebu.h
@@ -262,6 +263,15 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id usb_xhci_acpi_match[] = {
+   /* APM X-Gene USB Controller */
+   { PNP0D10, },
+   { }
+};
+MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match);
+#endif
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
@@ -269,6 +279,7 @@ static struct platform_driver usb_xhci_driver = {
.name = xhci-hcd,
.pm = DEV_PM_OPS,
.of_match_table = of_match_ptr(usb_xhci_of_match),
+   .acpi_match_table = ACPI_PTR(usb_xhci_acpi_match),
},
 };
 MODULE_ALIAS(platform:xhci-hcd);
-- 
1.9.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 v4 2/2] usb: Add support for ACPI identification to xhci-platform

2015-08-07 Thread Duc Dang
On Fri, Aug 7, 2015 at 6:29 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Fri, Aug 07, 2015 at 06:03:36PM -0700, Duc Dang wrote:
 Provide the methods to let ACPI identify the need to use
 xhci-platform. Change the Kconfig files so the
 xhci-plat.o file is selectable during kernel config.

 This has been tested on an ARM64 machine with platform XHCI, an
 x86_64 machine with XHCI, and an x86_64 machine without XHCI.
 There were no regressions or error messages on the machines
 without platform XHCI.

 [dhdang: regenerate the patch over 4.2-rc5]
 Signed-off-by: Mark Langsdorf mlang...@redhat.com
 Signed-off-by: Duc Dang dhd...@apm.com

 ---
 Changes from v3:
   Regenerate the patch over 4.2-rc5
   No code change

 Changes from v2
   Replaced tristate with a boolean as the driver doesn't
   compile as a module
   Correct --help-- to ---help---

 Changes from v1
   Renamed from add support for APM X-Gene to xhci-platform
   Removed changes to arm64/Kconfig
   Made CONFIG_USB_XHCI_PLATFORM a user selectable config option

  drivers/usb/host/Kconfig |  7 ++-
  drivers/usb/host/xhci-plat.c | 11 +++
  2 files changed, 17 insertions(+), 1 deletion(-)

 diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
 index 8afc3c1..96231ee 100644
 --- a/drivers/usb/host/Kconfig
 +++ b/drivers/usb/host/Kconfig
 @@ -32,7 +32,12 @@ config USB_XHCI_PCI
 default y

  config USB_XHCI_PLATFORM
 - tristate
 + tristate xHCI platform driver support
 + ---help---
 +   Say 'Y' to enable the support for the xHCI host controller
 +   as a platform device. Many ARM SoCs provide USB this way.
 +
 +   If unsure, say 'Y'.

  config USB_XHCI_MVEBU
   tristate xHCI support for Marvell Armada 375/38x
 diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 index 5d03f8b..14b40d2 100644
 --- a/drivers/usb/host/xhci-plat.c
 +++ b/drivers/usb/host/xhci-plat.c
 @@ -19,6 +19,7 @@
  #include linux/usb/phy.h
  #include linux/slab.h
  #include linux/usb/xhci_pdriver.h
 +#include linux/acpi.h

  #include xhci.h
  #include xhci-mvebu.h
 @@ -262,6 +263,15 @@ static const struct of_device_id usb_xhci_of_match[] = {
  MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
  #endif

 +#ifdef CONFIG_ACPI

 You shoudn't need this #ifdef, right?

You are correct, Greg.

I will post a new version that remove this #ifdef CONFIG_ACPI shortly


 thanks,

 greg k-h



-- 
Regards,
Duc Dang.
--
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 v5 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-08-07 Thread Duc Dang
The xhci platform driver needs to work on systems that
either only support 64-bit DMA or only support 32-bit DMA.
Attempt to set a coherent dma mask for 64-bit DMA, and
attempt again with 32-bit DMA if that fails.

[dhdang: Regenerate the patch over 4.2-rc5]
Signed-off-by: Mark Langsdorf mlang...@redhat.com
Tested-by: Mark Salter msal...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Changes from v4:
None

Changes from v3:
Re-generate the patch over 4.2-rc5
No code change.

Changes from v2:
None

Changes from v1:
Consolidated to use dma_set_mask_and_coherent
Got rid of the check against sizeof(dma_addr_t)

 drivers/usb/host/xhci-plat.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 890ad9d..5d03f8b 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -93,14 +93,14 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq  0)
return -ENODEV;
 
-   /* Initialize dma_mask and coherent_dma_mask to 32-bits */
-   ret = dma_set_coherent_mask(pdev-dev, DMA_BIT_MASK(32));
-   if (ret)
-   return ret;
-   if (!pdev-dev.dma_mask)
-   pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
-   else
-   dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
+   /* Try setting the coherent_dma_mask to 64 bits, then try 32 bits */
+   ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(64));
+   if (ret) {
+   ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
 
hcd = usb_create_hcd(driver, pdev-dev, dev_name(pdev-dev));
if (!hcd)
-- 
1.9.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 v5 2/2] usb: Add support for ACPI identification to xhci-platform

2015-08-07 Thread Duc Dang
Provide the methods to let ACPI identify the need to use
xhci-platform. Change the Kconfig files so the
xhci-plat.o file is selectable during kernel config.

This has been tested on an ARM64 machine with platform XHCI, an
x86_64 machine with XHCI, and an x86_64 machine without XHCI.
There were no regressions or error messages on the machines
without platform XHCI.

Signed-off-by: Mark Langsdorf mlang...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Changes from v4:
Remove #ifdef CONFIG_ACPI

Changes from v3:
Regenerate the patch over 4.2-rc5
No code change

Changes from v2
Replaced tristate with a boolean as the driver doesn't
compile as a module
Correct --help-- to ---help---

Changes from v1
Renamed from add support for APM X-Gene to xhci-platform
Removed changes to arm64/Kconfig
Made CONFIG_USB_XHCI_PLATFORM a user selectable config option

 drivers/usb/host/Kconfig | 7 ++-
 drivers/usb/host/xhci-plat.c | 9 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 8afc3c1..96231ee 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -32,7 +32,12 @@ config USB_XHCI_PCI
default y
 
 config USB_XHCI_PLATFORM
-   tristate
+   tristate xHCI platform driver support
+   ---help---
+ Say 'Y' to enable the support for the xHCI host controller
+ as a platform device. Many ARM SoCs provide USB this way.
+
+ If unsure, say 'Y'.
 
 config USB_XHCI_MVEBU
tristate xHCI support for Marvell Armada 375/38x
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 5d03f8b..bd282cd 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include linux/usb/phy.h
 #include linux/slab.h
 #include linux/usb/xhci_pdriver.h
+#include linux/acpi.h
 
 #include xhci.h
 #include xhci-mvebu.h
@@ -262,6 +263,13 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+static const struct acpi_device_id usb_xhci_acpi_match[] = {
+   /* APM X-Gene USB Controller */
+   { PNP0D10, },
+   { }
+};
+MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match);
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
@@ -269,6 +277,7 @@ static struct platform_driver usb_xhci_driver = {
.name = xhci-hcd,
.pm = DEV_PM_OPS,
.of_match_table = of_match_ptr(usb_xhci_of_match),
+   .acpi_match_table = ACPI_PTR(usb_xhci_acpi_match),
},
 };
 MODULE_ALIAS(platform:xhci-hcd);
-- 
1.9.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