From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1455FC2D0C2 for ; Mon, 30 Dec 2019 11:35:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4FDA20730 for ; Mon, 30 Dec 2019 11:35:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I63uBrV0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4FDA20730 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iltKL-0000Uw-Ql for qemu-devel@archiver.kernel.org; Mon, 30 Dec 2019 06:35:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38238) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iltJO-0008FI-DM for qemu-devel@nongnu.org; Mon, 30 Dec 2019 06:34:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iltJM-0007ZD-6q for qemu-devel@nongnu.org; Mon, 30 Dec 2019 06:34:14 -0500 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]:36827) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iltJL-0007X5-UE; Mon, 30 Dec 2019 06:34:12 -0500 Received: by mail-io1-xd42.google.com with SMTP id r13so21107206ioa.3; Mon, 30 Dec 2019 03:34:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UvT7Unor9M3eflo5yQDL/TjbsnMQ6Gi8P0jhCttW2S4=; b=I63uBrV0C7P9yGBlOg9o5Xq27pdMZ9KGBQ3sW7+dt0u5wJJIheCuqnH/BWHdNnefDb QoxgISi+sDHzH60jrg5ME7Bv/sjkjGLt+Qh2JJ2uOLd4sqYNPS+8hGbyaMrKp1AwBE4b OkeYP9Rn4tQfjZzcS+nM3k+nuEeWWdTFlSgsXGHMRIhCcQ4wsSzHcr7p1XpcHMXpiSfT disfJVGnyDvKHKSuLmBhn4Z0QjbjhAHqO84dwhnbtnAM3d7LC7q0gPAnxTMM31ZtrXXh KJ67scZDE1CC5cgwZS1KBAwRmHtDKoOwuLp2A2wknXJjE9bWZZBtpnn8llyiJhxIkqA+ rYrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UvT7Unor9M3eflo5yQDL/TjbsnMQ6Gi8P0jhCttW2S4=; b=aRWok2NQ8jphQeFTXSpGPzWr3W/emeC3C45Tl04DR3X9BSpLpT7jGHxDKI6R9cMPPR OuffurTAFaNTANPWth7F5MmiWk6Mcz931KMs5YaY+y5KneK5y996GAGLYIwsKCPyV1Ra 7ZKkQ8IuErLw/FzAHNHOeHfCHbxwXlGvMCJUUdLNYsYaGnPo9LkIO9e7jW8YhzULoCJa rMW+C7TUvlZmIHfCDJg60UOOwtWSjgXz4OUH/qGMbZv9LJJNIHXoOexZj1E/FMzrLQcF p2dHaoWSpu3m6C9bf1I4+XICLsJ2JddhoKRXWSSS19yO/OFVM4F8+r6bES+sOuVXKARJ LvFw== X-Gm-Message-State: APjAAAVBfBzy0Wg8lWWG2oPe7VDIHCeQLCLCVVO3v8YjWcedB5srXXuX jbbx2u7GxVRQqG3nLdSi8Wp1bCUaa5neNSVetQA= X-Google-Smtp-Source: APXvYqyPBwL6ASBueqR5If8MxbgSFvxgQ9sBnBAKX+F3hqBZJ0IvLS8HqQP7YTJnFL5OHPVVz7jX7V071uKCH1XGzAE= X-Received: by 2002:a02:8817:: with SMTP id r23mr53067919jai.120.1577705650467; Mon, 30 Dec 2019 03:34:10 -0800 (PST) MIME-Version: 1.0 References: <20191230110953.25496-1-f4bug@amsat.org> <20191230110953.25496-7-f4bug@amsat.org> In-Reply-To: <20191230110953.25496-7-f4bug@amsat.org> From: Niek Linnenbank Date: Mon, 30 Dec 2019 12:33:59 +0100 Message-ID: Subject: Re: [RFC PATCH 6/6] hw/arm/cubieboard: Disable unsupported M-USB in device tree blob To: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Content-Type: multipart/alternative; boundary="000000000000db36df059aea38a4" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::d42 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , QEMU Developers , Wainer dos Santos Moschetta , Beniamino Galvani , qemu-arm , Willian Rampazzo , Cleber Rosa Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --000000000000db36df059aea38a4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Philippe, I have a suggestion: probably you can apply (almost) the same patch to get USB working for A10 as I did in the Allwinner H3, in patch #4 "add USB host controller" [1] That way you can avoid the DTB modifications and with low effort get USB working as well for this board. As far as I can see, in Section 21.1 in the A10 user manual [2] has the same description as for the H3. It basically has the standard EHCI and OHCI interfaces. [1] https://lists.gnu.org/archive/html/qemu-devel/2019-12/msg03266.html [2] https://linux-sunxi.org/File:Allwinner_A10_User_manual_V1.5.pdf Regards, Niek On Mon, Dec 30, 2019 at 12:10 PM Philippe Mathieu-Daud=C3=A9 wrote: > We do not model the Sunxi Multipoint USB. > The Linux kernel OOPS when booting: > > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 144 at drivers/usb/musb/sunxi.c:400 > sunxi_musb_ep_offset+0x39/0x3c > sunxi_musb_ep_offset called with non 0 offset > Modules linked in: > CPU: 0 PID: 144 Comm: kworker/0:2 Not tainted 4.20.7-sunxi #5.75 > Hardware name: Allwinner sun4i/sun5i Families > Workqueue: events deferred_probe_work_func > [] (unwind_backtrace) from [] (show_stack+0x11/0x14= ) > [] (show_stack) from [] (dump_stack+0x69/0x78) > [] (dump_stack) from [] (__warn+0xa1/0xb4) > [] (__warn) from [] (warn_slowpath_fmt+0x33/0x48) > [] (warn_slowpath_fmt) from [] > (sunxi_musb_ep_offset+0x39/0x3c) > [] (sunxi_musb_ep_offset) from [] > (ep_config_from_hw+0x99/0x104) > [] (ep_config_from_hw) from [] > (musb_probe+0x765/0xa0c) > [] (musb_probe) from [] > (platform_drv_probe+0x33/0x68) > [] (platform_drv_probe) from [] > (really_probe+0x16f/0x1e0) > [] (really_probe) from [] > (driver_probe_device+0x43/0x11c) > [] (driver_probe_device) from [] > (bus_for_each_drv+0x37/0x70) > [] (bus_for_each_drv) from [] > (__device_attach+0x83/0xc8) > [] (__device_attach) from [] > (bus_probe_device+0x5b/0x60) > [] (bus_probe_device) from [] > (device_add+0x2f5/0x474) > [] (device_add) from [] > (platform_device_add+0xb7/0x184) > [] (platform_device_add) from [] > (platform_device_register_full+0xb3/0xc4) > [] (platform_device_register_full) from [] > (sunxi_musb_probe+0x1d7/0x2f4) > [] (sunxi_musb_probe) from [] > (platform_drv_probe+0x33/0x68) > [] (platform_drv_probe) from [] > (really_probe+0x16f/0x1e0) > [] (really_probe) from [] > (driver_probe_device+0x43/0x11c) > [] (driver_probe_device) from [] > (bus_for_each_drv+0x37/0x70) > [] (bus_for_each_drv) from [] > (__device_attach+0x83/0xc8) > [] (__device_attach) from [] > (bus_probe_device+0x5b/0x60) > [] (bus_probe_device) from [] > (deferred_probe_work_func+0x4b/0x6c) > [] (deferred_probe_work_func) from [] > (process_one_work+0x167/0x384) > [] (process_one_work) from [] > (worker_thread+0x251/0x3fc) > [] (worker_thread) from [] (kthread+0xfd/0x104) > [] (kthread) from [] (ret_from_fork+0x11/0x38) > Exception stack(0xc6999fb0 to 0xc6999ff8) > 9fa0: 00000000 00000000 00000000 > 00000000 > 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 > 00000000 > 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 > ---[ end trace b309edbca98c7de2 ]--- > musb-sunxi 1c13000.usb: Error unknown readb offset 128 > musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status -22 > musb-hdrc: probe of musb-hdrc.1.auto failed with error -22 > > This is not critical but confusing. To avoid the Linux kernel to > probe this device, mark it disabled in the device tree blob. > > Signed-off-by: Philippe Mathieu-Daud=C3=A9 > --- > I'm not sure if this is a QEMU anti-pattern or bad practice. > I know we prefer to be as close to the hardware as possible, > but here the hardware is not changed, the dtb is. However > this makes the guest behave differently. At least we don't > have to manually edit the dts. If this is only annoying for > acceptance testing, we might consider manually editing the > dts in the tests setup(). > --- > hw/arm/cubieboard.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c > index 6dc2f1d6b6..dd10577696 100644 > --- a/hw/arm/cubieboard.c > +++ b/hw/arm/cubieboard.c > @@ -22,10 +22,34 @@ > #include "hw/sysbus.h" > #include "hw/boards.h" > #include "hw/arm/allwinner-a10.h" > +#include > + > +static void cubieboard_modify_dtb(const struct arm_boot_info *info, void > *fdt) > +{ > + static const char unsupported_compat[] =3D "allwinner,sun4i-a10-musb= "; > + char node_path[72]; > + int offset; > + > + offset =3D fdt_node_offset_by_compatible(fdt, -1, unsupported_compat= ); > + while (offset >=3D 0) { > + int r =3D fdt_get_path(fdt, offset, node_path, sizeof(node_path)= ); > + assert(r >=3D 0); > + r =3D fdt_setprop_string(fdt, offset, "status", "disabled"); > + if (r < 0) { > + error_report("%s: Couldn't disable %s: %s", __func__, > + unsupported_compat, fdt_strerror(r)); > + exit(1); > + } > + warn_report("cubieboard: disabled unsupported node %s (%s) " > + "in device tree", node_path, unsupported_compat); > + offset =3D fdt_node_offset_by_compatible(fdt, offset, > unsupported_compat); > + } > +} > > static struct arm_boot_info cubieboard_binfo =3D { > .loader_start =3D AW_A10_SDRAM_BASE, > .board_id =3D 0x1008, > + .modify_dtb =3D cubieboard_modify_dtb, > }; > > typedef struct CubieBoardState { > -- > 2.21.0 > > --=20 Niek Linnenbank --000000000000db36df059aea38a4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello Philippe,

I have a sug= gestion: probably you can apply (almost) the same patch to get USB
working for A10 as I did in the Allwinner H3, in patch #4 "add USB h= ost controller" [1]
That way you can avoid the DTB modificat= ions and with low effort get USB working as well for this board.
<= div>As far as I can see, in Section 21.1 in the A10 user manual [2] has the= same description
as for the H3. It basically has the standard EH= CI and OHCI interfaces.

[2] h= ttps://linux-sunxi.org/File:Allwinner_A10_User_manual_V1.5.pdf

Regards,
Niek

On Mon, Dec 30, 2019 at 1= 2:10 PM Philippe Mathieu-Daud=C3=A9 <= f4bug@amsat.org> wrote:
We do not model the Sunxi Multipoint USB.
The Linux kernel OOPS when booting:

=C2=A0 ------------[ cut here ]------------
=C2=A0 WARNING: CPU: 0 PID: 144 at drivers/usb/musb/sunxi.c:400 sunxi_musb_= ep_offset+0x39/0x3c
=C2=A0 sunxi_musb_ep_offset called with non 0 offset
=C2=A0 Modules linked in:
=C2=A0 CPU: 0 PID: 144 Comm: kworker/0:2 Not tainted 4.20.7-sunxi #5.75
=C2=A0 Hardware name: Allwinner sun4i/sun5i Families
=C2=A0 Workqueue: events deferred_probe_work_func
=C2=A0 [<c010d77d>] (unwind_backtrace) from [<c010a425>] (show_= stack+0x11/0x14)
=C2=A0 [<c010a425>] (show_stack) from [<c08d9141>] (dump_stack+= 0x69/0x78)
=C2=A0 [<c08d9141>] (dump_stack) from [<c011b161>] (__warn+0xa1= /0xb4)
=C2=A0 [<c011b161>] (__warn) from [<c011b1a7>] (warn_slowpath_f= mt+0x33/0x48)
=C2=A0 [<c011b1a7>] (warn_slowpath_fmt) from [<c0725c81>] (sunx= i_musb_ep_offset+0x39/0x3c)
=C2=A0 [<c0725c81>] (sunxi_musb_ep_offset) from [<c071b481>] (e= p_config_from_hw+0x99/0x104)
=C2=A0 [<c071b481>] (ep_config_from_hw) from [<c071c8d9>] (musb= _probe+0x765/0xa0c)
=C2=A0 [<c071c8d9>] (musb_probe) from [<c063fa4f>] (platform_dr= v_probe+0x33/0x68)
=C2=A0 [<c063fa4f>] (platform_drv_probe) from [<c063e4ef>] (rea= lly_probe+0x16f/0x1e0)
=C2=A0 [<c063e4ef>] (really_probe) from [<c063e67f>] (driver_pr= obe_device+0x43/0x11c)
=C2=A0 [<c063e67f>] (driver_probe_device) from [<c063d0cf>] (bu= s_for_each_drv+0x37/0x70)
=C2=A0 [<c063d0cf>] (bus_for_each_drv) from [<c063e32f>] (__dev= ice_attach+0x83/0xc8)
=C2=A0 [<c063e32f>] (__device_attach) from [<c063da8b>] (bus_pr= obe_device+0x5b/0x60)
=C2=A0 [<c063da8b>] (bus_probe_device) from [<c063b7a5>] (devic= e_add+0x2f5/0x474)
=C2=A0 [<c063b7a5>] (device_add) from [<c063f8ef>] (platform_de= vice_add+0xb7/0x184)
=C2=A0 [<c063f8ef>] (platform_device_add) from [<c06400df>] (pl= atform_device_register_full+0xb3/0xc4)
=C2=A0 [<c06400df>] (platform_device_register_full) from [<c0725a2= f>] (sunxi_musb_probe+0x1d7/0x2f4)
=C2=A0 [<c0725a2f>] (sunxi_musb_probe) from [<c063fa4f>] (platf= orm_drv_probe+0x33/0x68)
=C2=A0 [<c063fa4f>] (platform_drv_probe) from [<c063e4ef>] (rea= lly_probe+0x16f/0x1e0)
=C2=A0 [<c063e4ef>] (really_probe) from [<c063e67f>] (driver_pr= obe_device+0x43/0x11c)
=C2=A0 [<c063e67f>] (driver_probe_device) from [<c063d0cf>] (bu= s_for_each_drv+0x37/0x70)
=C2=A0 [<c063d0cf>] (bus_for_each_drv) from [<c063e32f>] (__dev= ice_attach+0x83/0xc8)
=C2=A0 [<c063e32f>] (__device_attach) from [<c063da8b>] (bus_pr= obe_device+0x5b/0x60)
=C2=A0 [<c063da8b>] (bus_probe_device) from [<c063ddcf>] (defer= red_probe_work_func+0x4b/0x6c)
=C2=A0 [<c063ddcf>] (deferred_probe_work_func) from [<c012e38b>= ] (process_one_work+0x167/0x384)
=C2=A0 [<c012e38b>] (process_one_work) from [<c012f07d>] (worke= r_thread+0x251/0x3fc)
=C2=A0 [<c012f07d>] (worker_thread) from [<c0132949>] (kthread+= 0xfd/0x104)
=C2=A0 [<c0132949>] (kthread) from [<c01010f9>] (ret_from_fork+= 0x11/0x38)
=C2=A0 Exception stack(0xc6999fb0 to 0xc6999ff8)
=C2=A0 9fa0:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0000000= 00 00000000 00000000 00000000
=C2=A0 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000= 00000000
=C2=A0 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
=C2=A0 ---[ end trace b309edbca98c7de2 ]---
=C2=A0 musb-sunxi 1c13000.usb: Error unknown readb offset 128
=C2=A0 musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status = -22
=C2=A0 musb-hdrc: probe of musb-hdrc.1.auto failed with error -22

This is not critical but confusing. To avoid the Linux kernel to
probe this device, mark it disabled in the device tree blob.

Signed-off-by: Philippe Mathieu-Daud=C3=A9 <f4bug@amsat.org>
---
I'm not sure if this is a QEMU anti-pattern or bad practice.
I know we prefer to be as close to the hardware as possible,
but here the hardware is not changed, the dtb is. However
this makes the guest behave differently. At least we don't
have to manually edit the dts. If this is only annoying for
acceptance testing, we might consider manually editing the
dts in the tests setup().
---
=C2=A0hw/arm/cubieboard.c | 24 ++++++++++++++++++++++++
=C2=A01 file changed, 24 insertions(+)

diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
index 6dc2f1d6b6..dd10577696 100644
--- a/hw/arm/cubieboard.c
+++ b/hw/arm/cubieboard.c
@@ -22,10 +22,34 @@
=C2=A0#include "hw/sysbus.h"
=C2=A0#include "hw/boards.h"
=C2=A0#include "hw/arm/allwinner-a10.h"
+#include <libfdt.h>
+
+static void cubieboard_modify_dtb(const struct arm_boot_info *info, void *= fdt)
+{
+=C2=A0 =C2=A0 static const char unsupported_compat[] =3D "allwinner,s= un4i-a10-musb";
+=C2=A0 =C2=A0 char node_path[72];
+=C2=A0 =C2=A0 int offset;
+
+=C2=A0 =C2=A0 offset =3D fdt_node_offset_by_compatible(fdt, -1, unsupporte= d_compat);
+=C2=A0 =C2=A0 while (offset >=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 int r =3D fdt_get_path(fdt, offset, node_path,= sizeof(node_path));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert(r >=3D 0);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D fdt_setprop_string(fdt, offset, "st= atus", "disabled");
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (r < 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 error_report("%s: Couldn= 9;t disable %s: %s", __func__,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0unsupported_compat, fdt_strerror(r));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 exit(1);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 warn_report("cubieboard: disabled unsuppo= rted node %s (%s) "
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quo= t;in device tree", node_path, unsupported_compat);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 offset =3D fdt_node_offset_by_compatible(fdt, = offset, unsupported_compat);
+=C2=A0 =C2=A0 }
+}

=C2=A0static struct arm_boot_info cubieboard_binfo =3D {
=C2=A0 =C2=A0 =C2=A0.loader_start =3D AW_A10_SDRAM_BASE,
=C2=A0 =C2=A0 =C2=A0.board_id =3D 0x1008,
+=C2=A0 =C2=A0 .modify_dtb =3D cubieboard_modify_dtb,
=C2=A0};

=C2=A0typedef struct CubieBoardState {
--
2.21.0



--
Niek Linnenbank

--000000000000db36df059aea38a4--