net: rfkill: gpio: Fix and support SerDev
cover net: rfkill: gpio: Fix and support SerDev
From: Carlo Caione <[email protected]>
Hi,
this patch came after investigating why the rfkill-gpio driver was failing on the latest kernel on a machine I have. Sending this out as RFC because I'm still not sure if this is the right way to approach this problem. I was honestly expecting not to see the platform devices failing as consequences of the latest work on SerDev.
Carlo Caione (2):
net: rfkill: gpio: Fix NULL pointer deference
net: rfkill: gpio: Convert driver to SerDev
net/rfkill/Kconfig | 1 + net/rfkill/rfkill-gpio.c | 48 +++++++++++++++++++++++++----------------------- 2 files changed, 26 insertions(+), 23 deletions(-)
Signature · 1 line
2.14.1
RFC PATCH 1/2 net: rfkill: gpio: Fix NULL pointer deference
From: Carlo Caione <[email protected]>
In the rfkill_gpio code the variable type_name is not initialized and it can point to a spurious memory location. When device_property_read_string is not able to locate the string we are passing to rfkill_find_type this random pointer, causing a NULL pointer dereference when using strcmp.
--- net/rfkill/rfkill-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rfkill/rfkill-gpio.c +1 -1
@@ -88,7 +88,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev) {struct rfkill_gpio_data *rfkill;struct gpio_desc *gpio; -const char *type_name; +const char *type_name =NULL ;int ret; rfkill =devm_kzalloc (&pdev->dev,sizeof (*rfkill),GFP_KERNEL );
Signature · 1 line
2.14.1
RFC PATCH 2/2 net: rfkill: gpio: Convert driver to SerDev
In reply to Carlo CaioneFrom: Carlo Caione <[email protected]>
With commit e361d1f85855 ("ACPI / scan: Fix enumeration for special UART devices") UART devices are now expected to be enumerated by SerDev subsystem. This is breaking the enumeration of platform devices connected to the UART without a proper SerDev support, like in the rfkill-gpio case.
Fix this moving the driver from a platform driver to a serdev device driver.
--- net/rfkill/Kconfig | 1 + net/rfkill/rfkill-gpio.c | 46 ++++++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 22 deletions(-)
net/rfkill/Kconfig +1 -0
@@ -27,6 +27,7 @@ config RFKILL_GPIO tristate "GPIO RFKILL driver" depends on RFKILL depends on GPIOLIB || COMPILE_TEST + depends on SERIAL_DEV_CTRL_TTYPORT default n help If you say yes here you get support of a generic gpio RFKILL
net/rfkill/rfkill-gpio.c +24 -22
123 lines not on this page · raw message
Signature · 1 line
2.14.1
Re: [RFC PATCH 2/2] net: rfkill: gpio: Convert driver to SerDev
Hi Carlo,
Quoted 8 lines
With commit
e361d1f85855("ACPI / scan: Fix enumeration for special UART devices") UART devices are now expected to be enumerated by SerDev subsystem. This is breaking the enumeration of platform devices connected to the UART without a proper SerDev support, like in the rfkill-gpio case.Fix this moving the driver from a platform driver to a serdev device driver.
I do not like keeping this a RFKILL switch for the two GPS devices and that is really all what is left for this driver.
static const struct acpi_device_id rfkill_acpi_match[] = {
{ "BCM4752", RFKILL_TYPE_GPS },
{ "LNV4752", RFKILL_TYPE_GPS },
{ },
};Frankly what this needs is a serdev GPS driver. Even if it also exposes the data path via character device or a new TTY. Trying to hook this into RFKILL for powering on the GPS chip is not what we should do anymore. What you really want is that if the GPS daemon or application open the node for the GPS device that it gets powered on and when closed powered back down. Fiddling with RFKILL to do that is not what a RFKILL switch is for. If you want to have an additional RFKILL switch for killing power, then this has to be done the same as WiFi and Bluetooth do it.
So this patch is just a bad hack and we better have a proper serdev GPS driver.
Regards
Marcel
Re: [RFC PATCH 2/2] net: rfkill: gpio: Convert driver to SerDev
On Tue, Feb 20, 2018 at 2:04 PM, Marcel Holtmann <[email protected]> wrot= e:
Quoted 1 line
Hi Carlo,
Hi Marcel,
Quoted 10 lines
Quoted 8 lines
With commit
e361d1f85855("ACPI / scan: Fix enumeration for special UART devices") UART devices are now expected to be enumerated by SerDev subsystem. This is breaking the enumeration of platform devices connected to the UART without a proper SerDev support, like in the rfkill-gpio case.Fix this moving the driver from a platform driver to a serdev device driver.
I do not like keeping this a RFKILL switch for the two GPS devices and th=
at is really all what is left for this driver.
Quoted 8 lines
static const struct acpi_device_id rfkill_acpi_match[] =3D { { "BCM4752", RFKILL_TYPE_GPS }, { "LNV4752", RFKILL_TYPE_GPS }, { }, };Frankly what this needs is a serdev GPS driver. Even if it also exposes t=
he data path via character device or a new TTY. Trying to hook this into RF= KILL for powering on the GPS chip is not what we should do anymore. What yo= u really want is that if the GPS daemon or application open the node for th= e GPS device that it gets powered on and when closed powered back down. Fid= dling with RFKILL to do that is not what a RFKILL switch is for. If you wan= t to have an additional RFKILL switch for killing power, then this has to b= e done the same as WiFi and Bluetooth do it.
Quoted 2 lines
So this patch is just a bad hack and we better have a proper serdev GPS d=
river.
Yeah, I know (that's also why I preferred to send this as RFC). At least this patch could be useful to have things working until we have something better in place, but I definitely agree that's a bad hack.
Cheers,
--=20
Carlo Caione | +44.7384.69.16.04 | Endless
Hi Carlo,
Is this for devices with a RTL8723BS chip? If so then they still will not work after this since there also no longer is a /dev/ttyS4 created for the UART for the bluetooth, instead you probably want:
https://github.com/jwrdegoede/linux-sunxi/commit/c383dac5ea00738ac01d704d820aa548494fcd41
Which also puts the /dev/ttyS4 back in place.
Regards,
Hans
p.s.
My college Jeremy Cline in the Cc is looking into getting proper bluetooth support in place for the rtl8723bs using serdev binding and having everything in the kernel, as we now already do for bcm uart bluetooth modules.
Quoted 17 lines · Carlo Caione
From: Carlo Caione <[email protected]>
Hi,
this patch came after investigating why the rfkill-gpio driver was failing on the latest kernel on a machine I have. Sending this out as RFC because I'm still not sure if this is the right way to approach this problem. I was honestly expecting not to see the platform devices failing as consequences of the latest work on SerDev.Carlo Caione (2):
net: rfkill: gpio: Fix NULL pointer deference
net: rfkill: gpio: Convert driver to SerDevnet/rfkill/Kconfig | 1 + net/rfkill/rfkill-gpio.c | 48 +++++++++++++++++++++++++----------------------- 2 files changed, 26 insertions(+), 23 deletions(-)
Hi Hans,
Quoted 5 lines
Is this for devices with a RTL8723BS chip? If so then they still will not work after this since there also no longer is a
/dev/ttyS4created for the UART for the bluetooth, instead you probably want:
it is not for that hardware, it is for some GPS devices.
static const struct acpi_device_id rfkill_acpi_match[] = {
{ "BCM4752", RFKILL_TYPE_GPS },
{ "LNV4752", RFKILL_TYPE_GPS },
{ },
};Quoted 6 lines
https://github.com/jwrdegoede/linux-sunxi/commit/c383dac5ea00738ac01d704d820aa548494fcd41
Which also puts the
/dev/ttyS4back in place.Regards,
Quoted 8 lines
Hans
p.s.
My college Jeremy Cline in the Cc is looking into getting proper bluetooth support in place for the rtl8723bs using serdev binding and having everything in the kernel, as we now already do for bcm uart bluetooth modules.
Actually this should be done quickly since the Realtek hciattach / btattach hacks are not even upstream either since that is unmergable code. Even a basic hci_rtl.c driver would be better than nothing.
Regards
Marcel
Quoted 1 line · Hans de Goede
Hi Carlo,
Hi Hans,
Quoted 8 lines
Is this for devices with a RTL8723BS chip? If so then they still will not work after this since there also no longer is a
/dev/ttyS4created for the UART for the bluetooth, instead you probably want:https://github.com/jwrdegoede/linux-sunxi/commit/c383dac5ea00738ac01d704d820aa548494fcd41
Which also puts the
/dev/ttyS4back in place.
Yeah, this problem came up while working on the RTL8723BS chip but the driver is also broken for the other two GPS devices supported by this driver.
Thank you for the patch BTW.
Quoted 10 lines
Regards,
Hans
p.s.
My college Jeremy Cline in the Cc is looking into getting proper bluetooth support in place for the rtl8723bs using serdev binding and having everything in the kernel, as we now already do for bcm uart bluetooth modules.
Wasn't also Martin (+CC) working on this? See
https://www.spinics.net/lists/linux-bluetooth/msg73594.html
Cheers,
Signature · 1 line
Carlo Caione | +44.7384.69.16.04 | Endless
Hi Carlo,
Quoted 20 lines
Quoted 8 lines
Is this for devices with a RTL8723BS chip? If so then they still will not work after this since there also no longer is a
/dev/ttyS4created for the UART for the bluetooth, instead you probably want:https://github.com/jwrdegoede/linux-sunxi/commit/c383dac5ea00738ac01d704d820aa548494fcd41
Which also puts the
/dev/ttyS4back in place.Yeah, this problem came up while working on the RTL8723BS chip but the driver is also broken for the other two GPS devices supported by this driver.
Thank you for the patch BTW.Quoted 6 lines
Regards,
Hans
p.s.
Quoted 7 lines
Quoted 4 lines
My college Jeremy Cline in the Cc is looking into getting proper bluetooth support in place for the rtl8723bs using serdev binding and having everything in the kernel, as we now already do for bcm uart bluetooth modules.
Wasn't also Martin (+CC) working on this? See
https://www.spinics.net/lists/linux-bluetooth/msg73594.html
I remember that. I think we need a non-RFC version against latest bluetooth-next tree.
Regards
Marcel
Hi,
Quoted 25 lines · Carlo Caione
Quoted 1 line · Hans de Goede
Hi Carlo,
Hi Hans,
Quoted 8 lines
Is this for devices with a RTL8723BS chip? If so then they still will not work after this since there also no longer is a
/dev/ttyS4created for the UART for the bluetooth, instead you probably want:https://github.com/jwrdegoede/linux-sunxi/commit/c383dac5ea00738ac01d704d820aa548494fcd41
Which also puts the
/dev/ttyS4back in place.Yeah, this problem came up while working on the RTL8723BS chip but the driver is also broken for the other two GPS devices supported by this driver.
Thank you for the patch BTW.Quoted 6 lines
Regards,
Hans
p.s.
Quoted 7 lines
Quoted 4 lines
My college Jeremy Cline in the Cc is looking into getting proper bluetooth support in place for the rtl8723bs using serdev binding and having everything in the kernel, as we now already do for bcm uart bluetooth modules.
Wasn't also Martin (+CC) working on this? See
https://www.spinics.net/lists/linux-bluetooth/msg73594.html
Ah I did not know that, cool. Jeremy, this is probably a good starting
point :) And you should probably coordinate with Martin on this.
Regards,
Hans
Hello Jeremy, Hello Hans,
Quoted 42 lines · Hans de Goede
Hi,
Quoted 39 lines · Carlo Caione
Quoted 2 lines · Hans de Goede
Hi Carlo,
Hi Hans,
Quoted 9 lines
Is this for devices with a RTL8723BS chip? If so then they still will not work after this since there also no longer is a
/dev/ttyS4created for the UART for the bluetooth, instead you probably want:https://github.com/jwrdegoede/linux-sunxi/commit/c383dac5ea00738ac01d704d820aa548494fcd41
Which also puts the
/dev/ttyS4back in place.Yeah, this problem came up while working on the RTL8723BS chip but the driver is also broken for the other two GPS devices supported by this driver.
Thank you for the patch BTW.Quoted 10 lines
Regards,
Hans
p.s.
My college Jeremy Cline in the Cc is looking into getting proper bluetooth support in place for the rtl8723bs using serdev binding and having everything in the kernel, as we now already do for bcm uart bluetooth modules.
Wasn't also Martin (+CC) working on this? See
https://www.spinics.net/lists/linux-bluetooth/msg73594.html
thank you for CC'ing me Carlo!
Quoted 2 lines
Ah I did not know that, cool. Jeremy, this is probably a good starting
point :) And you should probably coordinate with Martin on this.
the status on this is:
- Marcel wrote a tool to parse the config blob: [0]
- the first patch from my series called "serdev: implement parity configuration" is now obsolete because an improved version from Ulrich Hecht has been merged: [1] (this requires a trivial change to the "serdev_device_set_parity" call in patch #9 of my series)
- I still have Realtek serdev support on my TODO-list but with low priority
there was a discussion what has to be done to drop the "RFC" prefix from my series: [3]
the quick summary (from my point of view):
- if possible we should get rid of the config blob (don't use it at all or generate it in-memory - I couldn't make either of these work so far but I've not spent much time on it either)
- create a "library" for the H5 protocol (similar to the H4 protocol) so the Realtek code doesn't have to be part of hci_h5.c
- add ACPI support (and not just device-tree support)
- testing with existing Realtek USB devices is needed
I have successfully tested v2 of my series on two Amlogic boards I have which both come with a RTL8723BS SDIO wifi/UART Bluetooth combo chip.
that said, I only looked at Bluetooth support (I didn't test wifi or btcoex support) and I don't have any "Realtek USB Bluetooth" dongles to check that I didn't break support for the existing devices
@Jeremy: I definitely won't be able to update my patches for the v4.17 cycle (and I'm not sure how much time I can dedicate to this for the v4.18 cycle).
it would be great if you could keep me CC'ed on your patches so I can learn and test them on the boards I have
Regards
Martin
[0] https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/tools/rtlfw.c?id=8b21a74f2e473b88cadc8ad871c635ace969ee02
[1] https://github.com/torvalds/linux/commit/3a19cfcce105e481b02b14265c5b40c6c10ef60a
[2] https://www.spinics.net/lists/linux-bluetooth/msg73602.html
[3] https://www.spinics.net/lists/linux-bluetooth/msg73602.html
Hi Martin,
Quoted 75 lines · Martin Blumenstingl
Hello Jeremy, Hello Hans,
Quoted 42 lines · Hans de Goede
Hi,
Quoted 39 lines · Carlo Caione
Quoted 2 lines · Hans de Goede
Hi Carlo,
Hi Hans,
Quoted 9 lines
Is this for devices with a RTL8723BS chip? If so then they still will not work after this since there also no longer is a
/dev/ttyS4created for the UART for the bluetooth, instead you probably want:https://github.com/jwrdegoede/linux-sunxi/commit/c383dac5ea00738ac01d704d820aa548494fcd41
Which also puts the
/dev/ttyS4back in place.Yeah, this problem came up while working on the RTL8723BS chip but the driver is also broken for the other two GPS devices supported by this driver.
Thank you for the patch BTW.Quoted 10 lines
Regards,
Hans
p.s.
My college Jeremy Cline in the Cc is looking into getting proper bluetooth support in place for the rtl8723bs using serdev binding and having everything in the kernel, as we now already do for bcm uart bluetooth modules.
Wasn't also Martin (+CC) working on this? See
https://www.spinics.net/lists/linux-bluetooth/msg73594.htmlthank you for CC'ing me Carlo!
Quoted 2 lines
Ah I did not know that, cool. Jeremy, this is probably a good starting
point :) And you should probably coordinate with Martin on this.the status on this is:
- Marcel wrote a tool to parse the config blob: [0]
- the first patch from my series called "serdev: implement parity configuration" is now obsolete because an improved version from Ulrich Hecht has been merged: [1] (this requires a trivial change to the "serdev_device_set_parity" call in patch #9 of my series)
- I still have Realtek serdev support on my TODO-list but with low prioritythere was a discussion what has to be done to drop the "RFC" prefix from my series: [3]
the quick summary (from my point of view):
- if possible we should get rid of the config blob (don't use it at all or generate it in-memory - I couldn't make either of these work so far but I've not spent much time on it either)
- create a "library" for the H5 protocol (similar to the H4 protocol) so the Realtek code doesn't have to be part ofhci_h5.c
- add ACPI support (and not just device-tree support)
- testing with existing Realtek USB devices is neededI have successfully tested v2 of my series on two Amlogic boards I have which both come with a RTL8723BS SDIO wifi/UART Bluetooth combo chip.
that said, I only looked at Bluetooth support (I didn't test wifi or btcoex support) and I don't have any "Realtek USB Bluetooth" dongles to check that I didn't break support for the existing devices
Quoted 5 lines
@Jeremy: I definitely won't be able to update my patches for the v4.17 cycle (and I'm not sure how much time I can dedicate to this for the v4.18 cycle).
it would be great if you could keep me CC'ed on your patches so I can learn and test them on the boards I have
Great, thanks for all the info! I'll definitely keep you CC'ed on my progress. I'm still very new to kernel development so I expect it'll take me quite a while, but I do have a fair bit of time to devote to this.
Regards,
Jeremy
Quoted 4 lines · Jeremy Cline
Great, thanks for all the info! I'll definitely keep you CC'ed on my progress. I'm still very new to kernel development so I expect it'll take me quite a while, but I do have a fair bit of time to devote to this.
Welcome to this crazy world ;)
Keep me on CC also, I have quite a bit of hw I can test the patches on. Fell free also to reach me in private.
I was actually going to work on this myself but now I guess there are too many people.
Cheers,
Signature · 1 line
Carlo Caione | +44.7384.69.16.04 | Endless
Hi Carlo,
Quoted 10 lines
Quoted 4 lines
Great, thanks for all the info! I'll definitely keep you CC'ed on my progress. I'm still very new to kernel development so I expect it'll take me quite a while, but I do have a fair bit of time to devote to this.
Welcome to this crazy world ;)
Keep me on CC also, I have quite a bit of hw I can test the patches on. Fell free also to reach me in private.
I was actually going to work on this myself but now I guess there are too many people.
I doubt there are too many people. I think there is a good baseline that needs some love to finish.
Regards
Marcel
Quoted 8 lines · Carlo Caione
Quoted 4 lines · Jeremy Cline
Great, thanks for all the info! I'll definitely keep you CC'ed on my progress. I'm still very new to kernel development so I expect it'll take me quite a while, but I do have a fair bit of time to devote to this.
Welcome to this crazy world ;)
Thanks!
Quoted 4 lines
Keep me on CC also, I have quite a bit of hw I can test the patches on. Fell free also to reach me in private.
I was actually going to work on this myself but now I guess there are too many people.
Will do. As for too many people, that's a pretty good problem to have! It sounds like Martin is pretty busy, though, and I would welcome your help. I was going to start by rebasing the current RFC and then looking at adding ACPI support since that sounds pretty straight-forward and I have the hardware.
Figuring out the mysteries of the config blob and creating an H5 "library" sound fairly independent to me so if you're interested maybe we could both take one on.
Regards,
Jeremy
Hi Martin,
Quoted 42 lines
Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
Is this for devices with a RTL8723BS chip? If so then they still will not work after this since there also no longer is a
/dev/ttyS4created for the UART for the bluetooth, instead you probably want:https://github.com/jwrdegoede/linux-sunxi/commit/c383dac5ea00738ac01d704d820aa548494fcd41
Which also puts the
/dev/ttyS4back in place.Yeah, this problem came up while working on the RTL8723BS chip but the driver is also broken for the other two GPS devices supported by this driver.
Thank you for the patch BTW.Quoted 6 lines
Regards,
Hans
p.s.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
My college Jeremy Cline in the Cc is looking into getting proper bluetooth support in place for the rtl8723bs using serdev binding and having everything in the kernel, as we now already do for bcm uart bluetooth modules.
Wasn't also Martin (+CC) working on this? See
https://www.spinics.net/lists/linux-bluetooth/msg73594.htmlthank you for CC'ing me Carlo!
Quoted 2 lines
Ah I did not know that, cool. Jeremy, this is probably a good starting
point :) And you should probably coordinate with Martin on this.the status on this is:
- Marcel wrote a tool to parse the config blob: [0]
- the first patch from my series called "serdev: implement parity configuration" is now obsolete because an improved version from Ulrich Hecht has been merged: [1] (this requires a trivial change to the "serdev_device_set_parity" call in patch #9 of my series)
- I still have Realtek serdev support on my TODO-list but with low priority
Quoted 6 lines
there was a discussion what has to be done to drop the "RFC" prefix from my series: [3]
the quick summary (from my point of view):
- if possible we should get rid of the config blob (don't use it at all or generate it in-memory - I couldn't make either of these work so far but I've not spent much time on it either)
so I have no idea what the config blobs are actually doing. However I am afraid they are needed since they are changing setting that should have been in the ROM mask, but they aren’t. What would be interesting to find the vendor command to read out the memory area and match it to the config file.
Quoted 2 lines
- create a "library" for the H5 protocol (similar to the H4 protocol) so the Realtek code doesn't have to be part of
hci_h5.c
I would prefer to have that from the beginning, but I would accept incremental patches once Realtek support is merged.
Quoted 1 line
- add ACPI support (and not just device-tree support)
That should be as simple as just adding the PNPIDs to the driver.
Quoted 9 lines
- testing with existing Realtek USB devices is needed
I have successfully tested v2 of my series on two Amlogic boards I have which both come with a RTL8723BS SDIO wifi/UART Bluetooth combo chip.
that said, I only looked at Bluetooth support (I didn't test wifi or btcoex support) and I don't have any "Realtek USB Bluetooth" dongles to check that I didn't break support for the existing devices
Quoted 5 lines
@Jeremy: I definitely won't be able to update my patches for the v4.17 cycle (and I'm not sure how much time I can dedicate to this for the v4.18 cycle).
it would be great if you could keep me CC'ed on your patches so I can learn and test them on the boards I have
Regards
Marcel