linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saravana Kannan <saravanak@google.com>
To: Jonathan McDowell <noodles@earth.li>
Cc: Andre Przywara <andre.przywara@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] ARM: dts: sun5i: chip: Enable bluetooth
Date: Mon, 1 May 2023 14:12:05 -0700	[thread overview]
Message-ID: <CAGETcx8OK-DNM2hJb2sz0jDyKBRqtmPRxnk_acKgB0pfrD0_JA@mail.gmail.com> (raw)
In-Reply-To: <ZEa9rcDlIOn+df5h@earth.li>

On Mon, Apr 24, 2023 at 10:34 AM Jonathan McDowell <noodles@earth.li> wrote:
>
> On Fri, Apr 21, 2023 at 03:45:52PM -0700, Saravana Kannan wrote:
> > On Fri, Apr 21, 2023 at 1:28 AM Jonathan McDowell <noodles@earth.li> wrote:
> > >
> > > On Thu, Apr 20, 2023 at 06:43:06PM -0700, Saravana Kannan wrote:
> > > > On Thu, Apr 20, 2023 at 12:12 PM Jonathan McDowell <noodles@earth.li> wrote:
> > > > > On Sun, Apr 16, 2023 at 01:24:21AM +0100, Andre Przywara wrote:
> > > > > > On Sat, 15 Apr 2023 18:46:03 +0100
> > > > > > Jonathan McDowell <noodles@earth.li> wrote:
> > > > > >
> > > > > > > The C.H.I.P has an rtl8723bs device with the bluetooth interface hooked
> > > > > > > up on UART3. Support for this didn't exist in mainline when the DTS was
> > > > > > > initially added, but it does now, so enable it.
> > > > > > >
> > > > > > > Signed-off-by: Jonathan McDowell <noodles@earth.li>
> > > > > > > ---
> > > > > > >  arch/arm/boot/dts/sun5i-r8-chip.dts | 4 ++++
> > > > > > >  1 file changed, 4 insertions(+)
> > > > > > >
> > > > > > > diff --git a/arch/arm/boot/dts/sun5i-r8-chip.dts b/arch/arm/boot/dts/sun5i-r8-chip.dts
> > > > > > > index fd37bd1f3920..4d72a181d8aa 100644
> > > > > > > --- a/arch/arm/boot/dts/sun5i-r8-chip.dts
> > > > > > > +++ b/arch/arm/boot/dts/sun5i-r8-chip.dts
> > > > > > > @@ -255,6 +255,10 @@ &uart3 {
> > > > > > >     pinctrl-0 = <&uart3_pg_pins>,
> > > > > > >                 <&uart3_cts_rts_pg_pins>;
> > > > > > >     status = "okay";
> > > > > > > +
> > > > > > > +   bluetooth {
> > > > > > > +           compatible = "realtek,rtl8723bs-bt";
> > > > > > > +   }
> > > > > >
> > > > > > As the kernel test robot already pointed out, there is a semicolon
> > > > > > missing here.
> > > > > > Otherwise looks good (dt-validate passes), but don't know if there are
> > > > > > any wakeup GPIOs connected (can't seem to find a schematic?).
> > > > >
> > > > > So there are wakeups, but if I add:
> > > > >
> > > > >         device-wake-gpios = <&axp_gpio 3 GPIO_ACTIVE_LOW>;
> > > > >         host-wake-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>; /* PB3 */
> > > > >
> > > > > then some odd sort of dependency issue happens where the serial port
> > > > > load is deferred waiting for the GPIO to appear, and then the device
> > > > > doesn't work.
> > > >
> > > > When you say your device doesn't work, are you saying it never probes?
> >
> > Read your whole email and it's a strange issue. Also, going forward to
> > avoid confusion, only reply to questions with respect to 6.3-rc7.

Sorry it took a while to respond. Life got busy.

> Just to be clear, in my initial mail I referred to 6.1.21 as that's
> where I started, but in my reply to you all output was quoted from
> 6.3-rc7. 6.3 has been released since, so all details below are based on
> that.
>
> > > The bluetooth device (realtek,rtl8723bs-bt) never appears, apparently
> > > because the UART it's attached to never loads - it doesn't even try to
> > > load the firmware.
> > >
> > > > <debugfs>/devices_deferred should tell you what devices have deferred and why.
> > >
> > > root@chip:~# cat /sys/kernel/debug/devices_deferred
> > > serial0-0
> >
> > Do you see this in 6.3-rc7 too?
>
> That was under 6.3-rc7. I see it on 6.3 too:
>
> root@chip:~# cat /sys/kernel/debug/devices_deferred
> serial0-0

I somehow didn't connect the dots earlier... but serial0-0 is NOT the
uart/serial device. It's the child device of serial0 and in this case,
it's the bluetooth device.

So adding those gpios in DT is not breaking serial. It's just
preventing the BT device from probing.

Looking at the logs in the non-working case:

[    0.715083] 1c28c00.serial: ttyS1 at MMIO 0x1c28c00 (irq = 53,
base_baud = 1500000) is a U6_16550A
[    0.724132] device: 'serial0': device_add

I don't know why all of the ttySx are showing up as serial0, but this
is the serial port. As you can see 1c28c00 is already probing.

[    0.724228] device: 'serial0-0': device_add

This is the child devices getting populated. In this case this is the BT device.

[    0.724311] device: 'platform:1c20800.pinctrl--serial:serial0-0': device_add

I can tell it's the BT device because we see a device link being
created between pinctrl and serial:serial0-0. So it's a device sitting
on the serial bus.

[    0.724378] devices_kset: Moving serial0-0 to end of list
[    0.724390] serial serial0-0: Linked as a consumer to 1c20800.pinctrl
[    0.724401] /soc/serial@1c28c00/bluetooth Dropping the fwnode link
to /soc/pinctrl@1c20800

And the fwnode like that was converted to device link clearly shows
that the serial0-0 corresponds to the bluetooth node.

[    0.724441] serial serial0: tty port ttyS1 registered

Serial port works.

>
> Without the device-wake-gpios line in the device tree it's empty.

I think the issue is at the BT driver level or some other framework.

Add a print at the start of the BT driver to see if the probe() is
actually getting called. I'm guessing it is and it's returning an
error from within.

If you don't see that print, then debug the really_probe() function to
see how far within it the BT device goes through before it errors out.
It's possible pinctrl_bind_pins() in really_probe() fails for the BT
device because of how the GPIO pins are configured in your DT.

Thanks,
Saravana

>
> > > > > Error in dmesg is:
> > > > >
> > > > > serial serial0-0: deferred probe pending
> > > > >
> > > > > on 6.3-rc and on 6.1 I get:
> > > > >
> > > > > dw-apb-uart 1c28c00.serial: Failed to create device link (0x180) with axp20x-gpio
> > > >
> > > > This error message doesn't block anything. So I don't think this is
> > > > the cause of your blocking issue. But I still want to understand why
> > > > this error message is showing up.
> > > >
> > > > > I'm not clear why it's trying to link the serial port to the GPIO; it
> > > > > seems that it should be the bluetooth device that depends on both the
> > > > > UART and the GPIO,
> > > >
> > > > A fix for the device link error message went in on v6.3-rc3. Is that
> > > > the 6.3 version you tested this on?
> > >
> > > I originally tried on 6.1.21, which is where I got the "Failed to create
> > > device link" message. I then moved to 6.3-rc7 as I saw there had been
> > > further changes recently. There I just get the:
> > >
> > > serial serial0-0: deferred probe pending
> >
> > If the deferral is related to fw_devlink, you should see the reason
> > for deferring in the devices_deferred file. So I don't think the issue
> > is related to fw_devlink.
>
> Ok.
>
> > > message.
> > >
> > > > Also, I tried looking into the UART driver
> > > > (drivers/tty/serial/8250/8250_dw.c) but it wasn't clear how it ends up
> > > > populating the bluetooth serial device. If you can point that out,
> > > > that'd be helpful (assuming 6.3-rc3 still shows that error message).
> > >
> > > I have the following in my device tree:
> > >
> > > &uart3 {
> > >         pinctrl-names = "default";
> > >         pinctrl-0 = <&uart3_pg_pins>,
> > >                     <&uart3_cts_rts_pg_pins>;
> > >         status = "okay";
> > >
> > >         bluetooth {
> > >                 compatible = "realtek,rtl8723bs-bt";
> > >                 device-wake-gpios = <&axp_gpio 3 GPIO_ACTIVE_LOW>;
> > >                 host-wake-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>; /* PB3 */
> > >         };
> > > };
> > >
> > > uart3 is a snps,dw-apb-uart, defined in arch/arm/boot/dts/sun5i.dtsi
> > >
> > > The UART and AXP209 device drivers are compiled into the kernel:
> > >
> > > CONFIG_PINCTRL_AXP209=y
> > > CONFIG_SERIAL_8250=y
> > > CONFIG_SERIAL_8250_DW=y
> > >
> > > The bluetooth bits are modules (btrtl, hci_uart).
> > >
> > > If I remove the device-wake-gpios line then the Bluetooth device works
> > > fine, and /sys/kernel/debug/devices_deferred is empty.
> > >
> > > Somehow it seems like the GPIO is being parsed as a dependency for the
> > > serial port, even though the serial port + GPIO are both dependencies
> > > for the bluetooth device.
> >
> > I'm fairly sure that fw_devlink isn't causing that. Because even
> > without bluetooth, fw_devlink doesn't consider any suppliers listed in
> > child DT nodes as mandatory suppliers. That has been the case since
> > the beginning.
>
> Ok, I just got confused with the 6.1 message about the device link and
> thought that might be the rough area.
>
> > > Even with that, given both are built-in I
> > > don't understand why the serial port never completes setup.
> >
> > My guess is that the driver itself has some bug that's sensitive to
> > device probe order even though it shouldn't.
> >
> > Can you add #define DEBUG 1 to the top of drivers/base/core.c and
> > share the boot log? I can try and help debug it.
>
> Thanks for any input you're able to provide. dmesg from 6.3 with a
> failure to complete the probe:
>
> https://the.earth.li/~noodles/chip-bluetooth/6.3-not-working
>
> and just for completeness, without the device-wake-gpios line:
>
> https://the.earth.li/~noodles/chip-bluetooth/6.3-working
>
> J.
>
> --
> Most people are descended from apes. Redheads are descended from cats.

  reply	other threads:[~2023-05-01 21:12 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-15 17:45 [PATCH 0/3] Minor device-tree additions for C.H.I.P Jonathan McDowell
2023-04-15 17:46 ` [PATCH 1/3] ARM: dts: sun5i: chip: Enable bluetooth Jonathan McDowell
2023-04-15 20:36   ` kernel test robot
2023-04-16  0:24   ` Andre Przywara
2023-04-20 19:12     ` Jonathan McDowell
2023-04-21  1:43       ` Saravana Kannan
2023-04-21  8:28         ` Jonathan McDowell
2023-04-21 22:45           ` Saravana Kannan
2023-04-24 17:34             ` Jonathan McDowell
2023-05-01 21:12               ` Saravana Kannan [this message]
2023-05-10 11:34                 ` Jonathan McDowell
2023-04-15 17:46 ` [PATCH 2/3] ARM: dts: sun5i: Add port E pinmux settings for mmc2 Jonathan McDowell
2023-04-16  0:47   ` Andre Przywara
2023-04-20 19:13     ` Jonathan McDowell
2023-04-15 17:47 ` [PATCH 3/3] ARM: dts: axp209: Add iio-hwmon node for internal temperature Jonathan McDowell
2023-04-16  7:27   ` Krzysztof Kozlowski
2023-04-20 19:06     ` Jonathan McDowell
2023-05-10 12:00 ` [PATCH v2 0/5] Minor device-tree additions for C.H.I.P Jonathan McDowell
2023-05-10 12:01   ` [PATCH v2 1/5] dt-bindings: gpio: Add GPIO3 for AXP209 GPIO binding schema Jonathan McDowell
2023-05-11 15:41     ` Jernej Škrabec
2023-05-11 18:55     ` Conor Dooley
2023-05-10 12:01   ` [PATCH v2 2/5] pinctrl: axp209: Add support for GPIO3 on the AXP209 Jonathan McDowell
2023-05-10 14:15     ` andy.shevchenko
2023-05-29  9:51     ` Linus Walleij
2023-06-01  7:30       ` Jonathan McDowell
2023-05-10 12:01   ` [PATCH v2 3/5] ARM: dts: sun5i: chip: Enable bluetooth Jonathan McDowell
2023-05-11 15:41     ` Jernej Škrabec
2023-05-10 12:02   ` [PATCH v2 4/5] ARM: dts: sun5i: Add port E pinmux settings for mmc2 Jonathan McDowell
2023-05-11 15:45     ` Jernej Škrabec
2023-05-10 12:02   ` [PATCH v2 5/5] ARM: dts: axp209: Add iio-hwmon node for internal temperature Jonathan McDowell
2023-05-11 16:11     ` Jernej Škrabec
2023-05-12 10:30       ` Jonathan McDowell
2023-05-12 16:37         ` Jernej Škrabec
2023-05-16 17:46   ` [PATCH v3 0/5] Minor device-tree additions for C.H.I.P Jonathan McDowell
2023-05-16 17:47     ` [PATCH v3 1/5] dt-bindings: gpio: Add GPIO3 for AXP209 GPIO binding schema Jonathan McDowell
2023-05-22  7:37       ` Linus Walleij
2023-05-26 12:24       ` Bartosz Golaszewski
2023-05-16 17:47     ` [PATCH v3 2/5] pinctrl: axp209: Add support for GPIO3 on the AXP209 Jonathan McDowell
2023-05-16 18:55       ` Andy Shevchenko
2023-05-18 21:21       ` Jernej Škrabec
2023-05-16 17:47     ` [PATCH v3 3/5] ARM: dts: sun5i: chip: Enable bluetooth Jonathan McDowell
2023-05-16 17:48     ` [PATCH v3 4/5] ARM: dts: sun5i: Add port E pinmux settings for mmc2 Jonathan McDowell
2023-05-16 17:48     ` [PATCH v3 5/5] ARM: dts: axp209: Add iio-hwmon node for internal temperature Jonathan McDowell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGETcx8OK-DNM2hJb2sz0jDyKBRqtmPRxnk_acKgB0pfrD0_JA@mail.gmail.com \
    --to=saravanak@google.com \
    --cc=andre.przywara@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=noodles@earth.li \
    --cc=robh+dt@kernel.org \
    --cc=samuel@sholland.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).