From nobody Sun Aug 20 00:06:58 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RSwrz0Sr8z4qPZ4; Sun, 20 Aug 2023 00:06:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RSwry6scDz3ZVw; Sun, 20 Aug 2023 00:06:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692490019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ajK91ddOzzPx4IC3vqTmkKmCEY0Is7Tb45EKVx8Q0iA=; b=lQ0iuNoEFtIyr3v65cYmS1wMmT/lPx6V9At40upgoNU67ik3Oc9XYR47jWMiF3OmIqaKq8 +QblF+7nvpGeXDsvLPfsNvCkPrmpfVY2LbbojHCj+2YS/mzRCi7BqlK0X/S06iq03G5Wn6 7g50dTyuwyRmlulO+bYOcJlSoelPpm5T/pgYWgpDNvQLlceYtgdtl3f0vaD58xAJ4c2Ul1 SMRM0OtWhdvk6DzKLB2PJEbR0GmUnQYuY2umvDHrzkIyGwYZEtV809YXxmJtPy9z7gn3ZI m36Uf4YqFIGhgSiPYJ81+66oVvqV7bMMoccgFHeLoTug0p9d5TkXbIajkC2pUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692490019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ajK91ddOzzPx4IC3vqTmkKmCEY0Is7Tb45EKVx8Q0iA=; b=BdRzB8KWpCQhA9r4Tqj7ZxBdpGGxK+BhqiE4gEKs6JP39ygaxNkQREhVuVg5Z4gEMMxfkb bKpGop6Kuy3jVh5adaQPOmHxH30DSflJKjLBpWdRpZhoIXuKs87OJSGJpIJJmWx6j6+dgg L67UAa9uFmFxUko1HAsakLrPdQmlzDGRYB2PIgx87GFudwTr3kIvfkhlqsmJWnX62so59L VxGak+tioAQeeYQmS//r2av8zROW+LMreKTIjJLtHEXYEB8C4VdpdpJjboqwMqIHprK625 cp/4BWNa2NIRGLGSAmYWHkq6yRiJUCD/1TbM+/ISq076CX8tqpPCNs+Q3Fe1Mg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692490019; a=rsa-sha256; cv=none; b=b1f+M6fUQNhvGSDEDB3ZTntKo5IpS1WBcO+Rc9NGB752h2V0Rvivxenb1VSvFHWnPx0Uvf 6zvyTfYQX3qQzA1Q+W1HejEWiugEVC6/tZkuluHycZdnq/FWGL8kLmo1W1DRVQB5jkqus4 4dBAmU6H4q5zTv7yTnQiDWozutXedELTaXzTd7l54VKWJIPBd4t0hWDHhtNvVxTq9HWCKd yALnSSD5wFTrcaWoZV6c1TpTfFeK4RjJNrHVxnxZP5r3a9Wsx2DB2TN+W83WPIXyFr7OrQ 67xZQOOu8+JH/QmvWBcx70X2Lasgcl0FIQx84l1233QwdJotkYugNDJGX2sd8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RSwry5w2kz342; Sun, 20 Aug 2023 00:06:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37K06wsD099326; Sun, 20 Aug 2023 00:06:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37K06wDK099323; Sun, 20 Aug 2023 00:06:58 GMT (envelope-from git) Date: Sun, 20 Aug 2023 00:06:58 GMT Message-Id: <202308200006.37K06wDK099323@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Stephen J. Kiernan" Subject: git: 332af8c25dfc - main - xhci: Add support for 64-bit DMA in generic XHCI controller driver List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: stevek X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 332af8c25dfc9857e997817281d7b7fa406783ef Auto-Submitted: auto-generated The branch main has been updated by stevek: URL: https://cgit.FreeBSD.org/src/commit/?id=332af8c25dfc9857e997817281d7b7fa406783ef commit 332af8c25dfc9857e997817281d7b7fa406783ef Author: Stephen J. Kiernan AuthorDate: 2023-08-11 16:06:02 +0000 Commit: Stephen J. Kiernan CommitDate: 2023-08-20 00:05:45 +0000 xhci: Add support for 64-bit DMA in generic XHCI controller driver The XHCI controller on 64-bit SoCs need to use 64-bit DMA. Add a quirk to tell the generic XHCI driver that 32-bit DMA needs to be used, if there are any that may need to use 32-bit DMA only. Reviewed by: andrew Obtained from: Juniper Networks, Inc. --- sys/dev/usb/controller/generic_xhci.c | 9 ++++++++- sys/dev/usb/controller/generic_xhci_fdt.c | 20 +++++++++++++++----- sys/dev/usb/controller/xhci.h | 1 + 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sys/dev/usb/controller/generic_xhci.c b/sys/dev/usb/controller/generic_xhci.c index e0caf8f42af5..e89d1bc84497 100644 --- a/sys/dev/usb/controller/generic_xhci.c +++ b/sys/dev/usb/controller/generic_xhci.c @@ -61,7 +61,13 @@ #include "generic_xhci.h" +#if __SIZEOF_LONG__ == 8 +#define IS_DMA_32B 0 +#elif __SIZEOF_LONG__ == 4 #define IS_DMA_32B 1 +#else +#error unsupported long size +#endif int generic_xhci_attach(device_t dev) @@ -114,7 +120,8 @@ generic_xhci_attach(device_t dev) return (err); } - err = xhci_init(sc, dev, IS_DMA_32B); + err = xhci_init(sc, dev, + (sc->sc_quirks & XHCI_QUIRK_DMA_32B) == 0 ? IS_DMA_32B : 1); if (err != 0) { device_printf(dev, "Failed to init XHCI, with error %d\n", err); generic_xhci_detach(dev); diff --git a/sys/dev/usb/controller/generic_xhci_fdt.c b/sys/dev/usb/controller/generic_xhci_fdt.c index cd0d84aebe91..a5c3f190783f 100644 --- a/sys/dev/usb/controller/generic_xhci_fdt.c +++ b/sys/dev/usb/controller/generic_xhci_fdt.c @@ -55,12 +55,16 @@ #include "generic_xhci.h" +/* Flags for the OFW compat data table */ +#define XHCI_FDT_MATCH 0x01 +#define XHCI_FDT_32BIT_DMA 0x02 /* Controller needs 32-bit DMA */ + static struct ofw_compat_data compat_data[] = { - {"marvell,armada-380-xhci", true}, - {"marvell,armada3700-xhci", true}, - {"marvell,armada-8k-xhci", true}, - {"generic-xhci", true}, - {NULL, false} + {"marvell,armada-380-xhci", XHCI_FDT_MATCH}, + {"marvell,armada3700-xhci", XHCI_FDT_MATCH}, + {"marvell,armada-8k-xhci", XHCI_FDT_MATCH}, + {"generic-xhci", XHCI_FDT_MATCH}, + {NULL, 0} }; static int @@ -81,14 +85,20 @@ generic_xhci_fdt_probe(device_t dev) static int generic_xhci_fdt_attach(device_t dev) { + struct xhci_softc *sc = device_get_softc(dev); phandle_t node; phy_t phy; + int flags; node = ofw_bus_get_node(dev); if (phy_get_by_ofw_property(dev, node, "usb-phy", &phy) == 0) if (phy_enable(phy) != 0) device_printf(dev, "Cannot enable phy\n"); + flags = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + if ((flags & XHCI_FDT_32BIT_DMA) != 0) + sc->sc_quirks |= XHCI_QUIRK_DMA_32B; + return (generic_xhci_attach(dev)); } diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h index 0be0d185a869..3758815238ad 100644 --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -488,6 +488,7 @@ typedef int (xhci_port_route_t)(device_t, uint32_t, uint32_t); enum xhci_quirks { XHCI_QUIRK_DISABLE_PORT_PED = 0x00000001, + XHCI_QUIRK_DMA_32B = 0x00000002, }; struct xhci_softc {