diff mbox series

usb: host: Add ac5 to EHCI Orion

Message ID 20240107163307.3677347-1-enachman@marvell.com (mailing list archive)
State Superseded
Headers show
Series usb: host: Add ac5 to EHCI Orion | expand

Commit Message

Elad Nachman Jan. 7, 2024, 4:33 p.m. UTC
From: Elad Nachman <enachman@marvell.com>

Add support for ac5 to the EHCI Orion platform driver.
The ac5 SOC has DDR starting at offset 0x2_0000_0000,
Hence it requires a larger than 32-bit DMA mask to operate.
Move the dma mask to be pointed by the OF match data, and
use that match data when initializng the DMA mask.

Signed-off-by: Elad Nachman <enachman@marvell.com>
---
 drivers/usb/host/ehci-orion.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

Comments

kernel test robot Jan. 8, 2024, 4:15 p.m. UTC | #1
Hi Elad,

kernel test robot noticed the following build errors:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on usb/usb-next usb/usb-linus char-misc/char-misc-testing char-misc/char-misc-next char-misc/char-misc-linus westeri-thunderbolt/next linus/master v6.7 next-20240108]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Elad-Nachman/usb-host-Add-ac5-to-EHCI-Orion/20240108-003512
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link:    https://lore.kernel.org/r/20240107163307.3677347-1-enachman%40marvell.com
patch subject: [PATCH] usb: host: Add ac5 to EHCI Orion
config: s390-randconfig-r071-20240108 (https://download.01.org/0day-ci/archive/20240109/202401090012.KFgRr4iR-lkp@intel.com/config)
compiler: clang version 18.0.0git (https://github.com/llvm/llvm-project 7e186d366d6c7def0543acc255931f617e76dff0)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240109/202401090012.KFgRr4iR-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401090012.KFgRr4iR-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/usb/host/ehci-orion.c:18:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:78:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     547 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     560 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
         |                                                           ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
     102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
         |                                                      ^
   In file included from drivers/usb/host/ehci-orion.c:18:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:78:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     573 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
         |                                                           ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
     115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
         |                                                      ^
   In file included from drivers/usb/host/ehci-orion.c:18:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:78:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     584 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     594 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     604 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     692 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     700 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     708 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     717 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     726 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     735 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
>> drivers/usb/host/ehci-orion.c:241:15: error: assigning to 'u64 *' (aka 'unsigned long long *') from 'const void *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
     241 |         dma_mask_ptr = of_device_get_match_data(&pdev->dev);
         |                      ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   12 warnings and 1 error generated.


vim +241 drivers/usb/host/ehci-orion.c

   211	
   212	static int ehci_orion_drv_probe(struct platform_device *pdev)
   213	{
   214		struct orion_ehci_data *pd = dev_get_platdata(&pdev->dev);
   215		const struct mbus_dram_target_info *dram;
   216		struct resource *res;
   217		struct usb_hcd *hcd;
   218		struct ehci_hcd *ehci;
   219		void __iomem *regs;
   220		int irq, err;
   221		enum orion_ehci_phy_ver phy_version;
   222		struct orion_ehci_hcd *priv;
   223		u64 *dma_mask_ptr;
   224	
   225		if (usb_disabled())
   226			return -ENODEV;
   227	
   228		pr_debug("Initializing Orion-SoC USB Host Controller\n");
   229	
   230		irq = platform_get_irq(pdev, 0);
   231		if (irq < 0) {
   232			err = irq;
   233			goto err;
   234		}
   235	
   236		/*
   237		 * Right now device-tree probed devices don't get dma_mask
   238		 * set. Since shared usb code relies on it, set it here for
   239		 * now. Once we have dma capability bindings this can go away.
   240		 */
 > 241		dma_mask_ptr = of_device_get_match_data(&pdev->dev);
   242		err = dma_coerce_mask_and_coherent(&pdev->dev, *dma_mask_ptr);
   243		if (err)
   244			goto err;
   245	
   246		regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
   247		if (IS_ERR(regs)) {
   248			err = PTR_ERR(regs);
   249			goto err;
   250		}
   251	
   252		hcd = usb_create_hcd(&ehci_orion_hc_driver,
   253				&pdev->dev, dev_name(&pdev->dev));
   254		if (!hcd) {
   255			err = -ENOMEM;
   256			goto err;
   257		}
   258	
   259		hcd->rsrc_start = res->start;
   260		hcd->rsrc_len = resource_size(res);
   261		hcd->regs = regs;
   262	
   263		ehci = hcd_to_ehci(hcd);
   264		ehci->caps = hcd->regs + 0x100;
   265		hcd->has_tt = 1;
   266	
   267		priv = hcd_to_orion_priv(hcd);
   268		/*
   269		 * Not all platforms can gate the clock, so it is not an error if
   270		 * the clock does not exists.
   271		 */
   272		priv->clk = devm_clk_get(&pdev->dev, NULL);
   273		if (!IS_ERR(priv->clk)) {
   274			err = clk_prepare_enable(priv->clk);
   275			if (err)
   276				goto err_put_hcd;
   277		}
   278	
   279		priv->phy = devm_phy_optional_get(&pdev->dev, "usb");
   280		if (IS_ERR(priv->phy)) {
   281			err = PTR_ERR(priv->phy);
   282			if (err != -ENOSYS)
   283				goto err_dis_clk;
   284		}
   285	
   286		/*
   287		 * (Re-)program MBUS remapping windows if we are asked to.
   288		 */
   289		dram = mv_mbus_dram_info();
   290		if (dram)
   291			ehci_orion_conf_mbus_windows(hcd, dram);
   292	
   293		/*
   294		 * setup Orion USB controller.
   295		 */
   296		if (pdev->dev.of_node)
   297			phy_version = EHCI_PHY_NA;
   298		else
   299			phy_version = pd->phy_version;
   300	
   301		switch (phy_version) {
   302		case EHCI_PHY_NA:	/* dont change USB phy settings */
   303			break;
   304		case EHCI_PHY_ORION:
   305			orion_usb_phy_v1_setup(hcd);
   306			break;
   307		case EHCI_PHY_DD:
   308		case EHCI_PHY_KW:
   309		default:
   310			dev_warn(&pdev->dev, "USB phy version isn't supported.\n");
   311		}
   312	
   313		err = usb_add_hcd(hcd, irq, IRQF_SHARED);
   314		if (err)
   315			goto err_dis_clk;
   316	
   317		device_wakeup_enable(hcd->self.controller);
   318		return 0;
   319	
   320	err_dis_clk:
   321		if (!IS_ERR(priv->clk))
   322			clk_disable_unprepare(priv->clk);
   323	err_put_hcd:
   324		usb_put_hcd(hcd);
   325	err:
   326		dev_err(&pdev->dev, "init %s fail, %d\n",
   327			dev_name(&pdev->dev), err);
   328	
   329		return err;
   330	}
   331
diff mbox series

Patch

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 6c47ab0a491d..bcf99f31a840 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -65,6 +65,15 @@  struct orion_ehci_hcd {
 
 static struct hc_driver __read_mostly ehci_orion_hc_driver;
 
+/*
+ * Legacy DMA mask is 32 bit.
+ * AC5 has the DDR starting at 8GB, hence it requires
+ * a larger (34-bit) DMA mask, in order for DMA allocations
+ * to succeed:
+ */
+static const u64 dma_mask_orion =	DMA_BIT_MASK(32);
+static const u64 dma_mask_ac5 =		DMA_BIT_MASK(34);
+
 /*
  * Implement Orion USB controller specification guidelines
  */
@@ -211,6 +220,7 @@  static int ehci_orion_drv_probe(struct platform_device *pdev)
 	int irq, err;
 	enum orion_ehci_phy_ver phy_version;
 	struct orion_ehci_hcd *priv;
+	u64 *dma_mask_ptr;
 
 	if (usb_disabled())
 		return -ENODEV;
@@ -228,7 +238,8 @@  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.
 	 */
-	err = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+	dma_mask_ptr = of_device_get_match_data(&pdev->dev);
+	err = dma_coerce_mask_and_coherent(&pdev->dev, *dma_mask_ptr);
 	if (err)
 		goto err;
 
@@ -332,9 +343,9 @@  static void ehci_orion_drv_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id ehci_orion_dt_ids[] = {
-	{ .compatible = "marvell,orion-ehci", },
-	{ .compatible = "marvell,armada-3700-ehci", },
-	{},
+	{ .compatible = "marvell,orion-ehci", .data = &dma_mask_orion},
+	{ .compatible = "marvell,armada-3700-ehci", .data = &dma_mask_orion},
+	{ .compatible = "marvell,ac5-ehci", .data = &dma_mask_ac5},
 };
 MODULE_DEVICE_TABLE(of, ehci_orion_dt_ids);