rpmsg: syslog driver
v2 cover rpmsg: syslog driver
I am sending this patch as RFC I am am aware that this is not ready for inclusion. I am however want to get some feedback on this choosen approach. In the end I want to be able to get log messages from the remote firmware into syslog.
Christian Gmeiner (1):
rpmsg: add syslog driver
drivers/rpmsg/Kconfig | 8 +++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 65 ++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.c
Signature · 1 line
2.33.1
RFC PATCH v2 1/1 rpmsg: add syslog driver
Allows the remote firmware to log into syslog.
--- drivers/rpmsg/Kconfig | 8 +++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 65 ++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.c
drivers/rpmsg/Kconfig +8 -0
@@ -73,4 +73,12 @@ config RPMSG_VIRTIO select RPMSG_NS select VIRTIO +config RPMSG_SYSLOG + tristate "SYSLOG device interface" + depends on RPMSG + help + Say Y here to export rpmsg endpoints as device files, usually found + in /dev. They make it possible for user-space programs to send and + receive rpmsg packets. + endmenu
drivers/rpmsg/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_RPMSG_QCOM_GLINK_RPM) += qcom_glink_rpm.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o obj-$(CONFIG_RPMSG_QCOM_SMD) += qcom_smd.o obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o +obj-$(CONFIG_RPMSG_SYSLOG) += rpmsg_syslog.o
drivers/rpmsg/rpmsg_syslog.c new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
2.33.1
Re: [RFC PATCH v2 1/1] rpmsg: add syslog driver
Quoted 2 lines · Christian Gmeiner
Allows the remote firmware to log into syslog.
This allows the remote firmware to print log messages in the kernel log, not the syslog (although your system might inject the kernel log into the syslog as well)
Quoted 5 lines
Signed-off-by Christian Gmeiner <[email protected]>--- drivers/rpmsg/Kconfig | 8 +++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 65 ++++++++++++++++++++++++++++++++++++
drivers/rpmsg is for rpmsg bus and transport drivers. Client drivers should live elsewhere.
But perhaps, rather than having a driver for this, you could simply use rpmsg_char and a userspace tool; if you want to get the remote processor logs into syslog, instead of the kernel log?
Quoted 69 lines
3 files changed, 74 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.cdrivers/rpmsg/Kconfig +8
-0@@ -73,4 +73,12 @@ config RPMSG_VIRTIO select RPMSG_NS select VIRTIO +config RPMSG_SYSLOG + tristate "SYSLOG device interface" + depends on RPMSG + help + Say Y here to export rpmsg endpoints as device files, usually found + in /dev. They make it possible for user-space programs to send and + receive rpmsg packets. + endmenudrivers/rpmsg/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_RPMSG_QCOM_GLINK_RPM) += qcom_glink_rpm.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o obj-$(CONFIG_RPMSG_QCOM_SMD) += qcom_smd.o obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o +obj-$(CONFIG_RPMSG_SYSLOG) += rpmsg_syslog.odrivers/rpmsg/rpmsg_syslog.c new file +34
-0@@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/rpmsg.h> + +static int rpmsg_syslog_cb (struct rpmsg_device *rpdev,void *data,int len, +void *priv,u32 src) +{ +const char *buffer = data; + +switch (buffer[0 ]) { +case 'e' : +dev_err (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'w' : +dev_warn (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'i' : +dev_info (&rpdev->dev,"%s" , buffer +1 ); +break ; +default : +dev_info (&rpdev->dev,"%s" , buffer); +break ; + } + +return 0 ; +} + +static int rpmsg_syslog_probe (struct rpmsg_device *rpdev) +{ +struct rpmsg_endpoint *syslog_ept; +struct rpmsg_channel_info syslog_chinfo = { + .src =42 ,
drivers/rpmsg/rpmsg_syslog.c line 44
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ .dst = 42, + .name = "syslog", + }; + +/* +* Create the syslog service endpoint associated to the RPMsg +* device. The endpoint will be automatically destroyed when the RPMsg +* device will be deleted. +*/ + syslog_ept =rpmsg_create_ept (rpdev, rpmsg_syslog_cb,NULL , syslog_chinfo);
The rpmsg_device_id below should cause the device to probe on the presence of a "syslog" channel announcement, so why are you creating a new endpoint with the same here?
Why aren't you just specifying the callback of the driver?
Quoted 11 lines
drivers/rpmsg/rpmsg_syslog.c new file +11
-0+if (!syslog_ept) { +dev_err (&rpdev->dev,"failed to create the syslog ept\n" ); +return -ENOMEM ; + } + rpdev->ept = syslog_ept; + +return 0 ; +} + +static struct rpmsg_device_id rpmsg_driver_syslog_id_table[] = { + { .name ="syslog" },
drivers/rpmsg/rpmsg_syslog.c line 65
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ { }, +}; +MODULE_DEVICE_TABLE (rpmsg, rpmsg_driver_syslog_id_table); + +static struct rpmsg_driver rpmsg_syslog_client = { + .drv.name =KBUILD_MODNAME , + .id_table = rpmsg_driver_syslog_id_table, + .probe = rpmsg_syslog_probe, +}; +module_rpmsg_driver (rpmsg_syslog_client);
I would expect that building this as a module gives you complaints about lacking MODULE_LICENSE().
Regards,
Bjorn
Quoted 3 lines
Signature · 1 line
2.33.1
Re: [RFC PATCH v2 1/1] rpmsg: add syslog driver
Hi Christian,
Quoted 4 lines · Bjorn Andersson
Quoted 2 lines · Christian Gmeiner
Allows the remote firmware to log into syslog.
For you information a similar patch has been sent few years ago:
https://www.spinics.net/lists/kernel/msg3045824.html
The suspend /resume mechanism seems interesting to manage the low power use case.
Quoted 11 lines
This allows the remote firmware to print log messages in the kernel log, not the syslog (although your system might inject the kernel log into the syslog as well)
Quoted 5 lines
Signed-off-by Christian Gmeiner <[email protected]>--- drivers/rpmsg/Kconfig | 8 +++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 65 ++++++++++++++++++++++++++++++++++++
Quoted 6 lines
drivers/rpmsgis for rpmsg bus and transport drivers. Client drivers should live elsewhere.But perhaps, rather than having a driver for this, you could simply use
rpmsg_charand a userspace tool; if you want to get the remote processor logs into syslog, instead of the kernel log?
This is also a question that comes to me while looking at the patch. rpmsg_tty service (if available in 5.16) could be another alternative.
Regards,
Arnaud
Quoted 118 lines
Quoted 70 lines
3 files changed, 74 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.cdrivers/rpmsg/Kconfig +8
-0@@ -73,4 +73,12 @@ config RPMSG_VIRTIO select RPMSG_NS select VIRTIO +config RPMSG_SYSLOG + tristate "SYSLOG device interface" + depends on RPMSG + help + Say Y here to export rpmsg endpoints as device files, usually found + in /dev. They make it possible for user-space programs to send and + receive rpmsg packets. + endmenudrivers/rpmsg/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_RPMSG_QCOM_GLINK_RPM) += qcom_glink_rpm.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o obj-$(CONFIG_RPMSG_QCOM_SMD) += qcom_smd.o obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o +obj-$(CONFIG_RPMSG_SYSLOG) += rpmsg_syslog.odrivers/rpmsg/rpmsg_syslog.c new file +34
-0@@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/rpmsg.h> + +static int rpmsg_syslog_cb (struct rpmsg_device *rpdev,void *data,int len, +void *priv,u32 src) +{ +const char *buffer = data; + +switch (buffer[0 ]) { +case 'e' : +dev_err (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'w' : +dev_warn (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'i' : +dev_info (&rpdev->dev,"%s" , buffer +1 ); +break ; +default : +dev_info (&rpdev->dev,"%s" , buffer); +break ; + } + +return 0 ; +} + +static int rpmsg_syslog_probe (struct rpmsg_device *rpdev) +{ +struct rpmsg_endpoint *syslog_ept; +struct rpmsg_channel_info syslog_chinfo = { + .src =42 ,drivers/rpmsg/rpmsg_syslog.c line 44
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ .dst = 42, + .name = "syslog", + }; + +/* +* Create the syslog service endpoint associated to the RPMsg +* device. The endpoint will be automatically destroyed when the RPMsg +* device will be deleted. +*/ + syslog_ept =rpmsg_create_ept (rpdev, rpmsg_syslog_cb,NULL , syslog_chinfo);The
rpmsg_device_idbelow should cause the device to probe on the presence of a "syslog" channel announcement, so why are you creating a new endpoint with the same here?Why aren't you just specifying the callback of the driver?
Quoted 11 lines
drivers/rpmsg/rpmsg_syslog.c new file +11
-0+if (!syslog_ept) { +dev_err (&rpdev->dev,"failed to create the syslog ept\n" ); +return -ENOMEM ; + } + rpdev->ept = syslog_ept; + +return 0 ; +} + +static struct rpmsg_device_id rpmsg_driver_syslog_id_table[] = { + { .name ="syslog" },drivers/rpmsg/rpmsg_syslog.c line 65
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ { }, +}; +MODULE_DEVICE_TABLE (rpmsg, rpmsg_driver_syslog_id_table); + +static struct rpmsg_driver rpmsg_syslog_client = { + .drv.name =KBUILD_MODNAME , + .id_table = rpmsg_driver_syslog_id_table, + .probe = rpmsg_syslog_probe, +}; +module_rpmsg_driver (rpmsg_syslog_client);I would expect that building this as a module gives you complaints about lacking
MODULE_LICENSE().Regards,
BjornQuoted 3 lines
Signature · 1 line
2.33.1
Re: [RFC PATCH v2 1/1] rpmsg: add syslog driver
Hi Arnaud
Quoted 10 lines · Bjorn Andersson
Quoted 4 lines · Christian Gmeiner
Quoted 3 lines
Allows the remote firmware to log into syslog.
For you information a similar patch has been sent few years ago:
https://www.spinics.net/lists/kernel/msg3045824.html
Interesting - do you know why the patch was not taken?
Quoted 2 lines
The suspend /resume mechanism seems interesting to manage the low power use case.
Yeah .. nothing I thought about.
Quoted 14 lines
Quoted 14 lines
This allows the remote firmware to print log messages in the kernel log, not the syslog (although your system might inject the kernel log into the syslog as well)
Quoted 5 lines
Signed-off-by Christian Gmeiner <[email protected]>--- drivers/rpmsg/Kconfig | 8 +++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 65 ++++++++++++++++++++++++++++++++++++
drivers/rpmsgis for rpmsg bus and transport drivers. Client drivers should live elsewhere.
Quoted 7 lines
Quoted 3 lines
But perhaps, rather than having a driver for this, you could simply use
rpmsg_charand a userspace tool; if you want to get the remote processor logs into syslog, instead of the kernel log?This is also a question that comes to me while looking at the patch.
rpmsg_ttyservice (if available in 5.16) could be another alternative.
I thought about it too but I do not see how the syslog/journald can read the log messages from this tty device without an extra user space component.
With a syslog redirection rpmsg service this happens automatically without any extra user space daemon that reads from tty and writes to syslog.
Maybe I am missing something.
Quoted 121 lines
Regards,
ArnaudQuoted 118 lines
Quoted 70 lines
3 files changed, 74 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.cdrivers/rpmsg/Kconfig +8
-0@@ -73,4 +73,12 @@ config RPMSG_VIRTIO select RPMSG_NS select VIRTIO +config RPMSG_SYSLOG + tristate "SYSLOG device interface" + depends on RPMSG + help + Say Y here to export rpmsg endpoints as device files, usually found + in /dev. They make it possible for user-space programs to send and + receive rpmsg packets. + endmenudrivers/rpmsg/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_RPMSG_QCOM_GLINK_RPM) += qcom_glink_rpm.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o obj-$(CONFIG_RPMSG_QCOM_SMD) += qcom_smd.o obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o +obj-$(CONFIG_RPMSG_SYSLOG) += rpmsg_syslog.odrivers/rpmsg/rpmsg_syslog.c new file +34
-0@@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/rpmsg.h> + +static int rpmsg_syslog_cb (struct rpmsg_device *rpdev,void *data,int len, +void *priv,u32 src) +{ +const char *buffer = data; + +switch (buffer[0 ]) { +case 'e' : +dev_err (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'w' : +dev_warn (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'i' : +dev_info (&rpdev->dev,"%s" , buffer +1 ); +break ; +default : +dev_info (&rpdev->dev,"%s" , buffer); +break ; + } + +return 0 ; +} + +static int rpmsg_syslog_probe (struct rpmsg_device *rpdev) +{ +struct rpmsg_endpoint *syslog_ept; +struct rpmsg_channel_info syslog_chinfo = { + .src =42 ,drivers/rpmsg/rpmsg_syslog.c line 44
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ .dst = 42, + .name = "syslog", + }; + +/* +* Create the syslog service endpoint associated to the RPMsg +* device. The endpoint will be automatically destroyed when the RPMsg +* device will be deleted. +*/ + syslog_ept =rpmsg_create_ept (rpdev, rpmsg_syslog_cb,NULL , syslog_chinfo);The
rpmsg_device_idbelow should cause the device to probe on the presence of a "syslog" channel announcement, so why are you creating a new endpoint with the same here?Why aren't you just specifying the callback of the driver?
Quoted 11 lines
drivers/rpmsg/rpmsg_syslog.c new file +11
-0+if (!syslog_ept) { +dev_err (&rpdev->dev,"failed to create the syslog ept\n" ); +return -ENOMEM ; + } + rpdev->ept = syslog_ept; + +return 0 ; +} + +static struct rpmsg_device_id rpmsg_driver_syslog_id_table[] = { + { .name ="syslog" },drivers/rpmsg/rpmsg_syslog.c line 65
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ { }, +}; +MODULE_DEVICE_TABLE (rpmsg, rpmsg_driver_syslog_id_table); + +static struct rpmsg_driver rpmsg_syslog_client = { + .drv.name =KBUILD_MODNAME , + .id_table = rpmsg_driver_syslog_id_table, + .probe = rpmsg_syslog_probe, +}; +module_rpmsg_driver (rpmsg_syslog_client);I would expect that building this as a module gives you complaints about lacking
MODULE_LICENSE().Regards,
BjornQuoted 3 lines
--
2.33.1
Signature · 5 lines
greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy
Re: [RFC PATCH v2 1/1] rpmsg: add syslog driver
Hi Christian,
Quoted 6 lines · Christian Gmeiner
Hi Arnaud
Quoted 4 lines · Bjorn Andersson
Quoted 2 lines · Christian Gmeiner
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Allows the remote firmware to log into syslog.
For you information a similar patch has been sent few years ago:
https://www.spinics.net/lists/kernel/msg3045824.htmlInteresting - do you know why the patch was not taken?
I don't know. It might be worthwhile to contact Xiang Xiao for more details.
Quoted 28 lines
Quoted 3 lines
The suspend /resume mechanism seems interesting to manage the low power use case.
Yeah .. nothing I thought about.
Quoted 14 lines
Quoted 14 lines
This allows the remote firmware to print log messages in the kernel log, not the syslog (although your system might inject the kernel log into the syslog as well)
Quoted 5 lines
Signed-off-by Christian Gmeiner <[email protected]>--- drivers/rpmsg/Kconfig | 8 +++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 65 ++++++++++++++++++++++++++++++++++++
drivers/rpmsgis for rpmsg bus and transport drivers. Client drivers should live elsewhere.Quoted 7 lines
Quoted 3 lines
But perhaps, rather than having a driver for this, you could simply use
rpmsg_charand a userspace tool; if you want to get the remote processor logs into syslog, instead of the kernel log?This is also a question that comes to me while looking at the patch.
rpmsg_ttyservice (if available in 5.16) could be another alternative.
Quoted 7 lines
I thought about it too but I do not see how the syslog/journald can read the log messages from this tty device without an extra user space component.
With a syslog redirection rpmsg service this happens automatically without any extra user space daemon that reads from tty and writes to syslog.
Maybe I am missing something.
That's true, this is one constraint. I suppose that you already have user code to start the remoteproc. In this case it could also launch a deamon which could redirects and/or perhaps analyzes traces to detect errors...
That said it is my point of view, working on a general purpose platform (stm32mp15), I guess other people have other feedbacks.
A last question: Do you manage the traces enable/disable and trace level during runtime?
Regards,
Arnaud
Quoted 125 lines
Quoted 122 lines
Regards,
ArnaudQuoted 118 lines
Quoted 70 lines
3 files changed, 74 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.cdrivers/rpmsg/Kconfig +8
-0@@ -73,4 +73,12 @@ config RPMSG_VIRTIO select RPMSG_NS select VIRTIO +config RPMSG_SYSLOG + tristate "SYSLOG device interface" + depends on RPMSG + help + Say Y here to export rpmsg endpoints as device files, usually found + in /dev. They make it possible for user-space programs to send and + receive rpmsg packets. + endmenudrivers/rpmsg/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_RPMSG_QCOM_GLINK_RPM) += qcom_glink_rpm.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o obj-$(CONFIG_RPMSG_QCOM_SMD) += qcom_smd.o obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o +obj-$(CONFIG_RPMSG_SYSLOG) += rpmsg_syslog.odrivers/rpmsg/rpmsg_syslog.c new file +34
-0@@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/rpmsg.h> + +static int rpmsg_syslog_cb (struct rpmsg_device *rpdev,void *data,int len, +void *priv,u32 src) +{ +const char *buffer = data; + +switch (buffer[0 ]) { +case 'e' : +dev_err (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'w' : +dev_warn (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'i' : +dev_info (&rpdev->dev,"%s" , buffer +1 ); +break ; +default : +dev_info (&rpdev->dev,"%s" , buffer); +break ; + } + +return 0 ; +} + +static int rpmsg_syslog_probe (struct rpmsg_device *rpdev) +{ +struct rpmsg_endpoint *syslog_ept; +struct rpmsg_channel_info syslog_chinfo = { + .src =42 ,drivers/rpmsg/rpmsg_syslog.c line 44
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ .dst = 42, + .name = "syslog", + }; + +/* +* Create the syslog service endpoint associated to the RPMsg +* device. The endpoint will be automatically destroyed when the RPMsg +* device will be deleted. +*/ + syslog_ept =rpmsg_create_ept (rpdev, rpmsg_syslog_cb,NULL , syslog_chinfo);The
rpmsg_device_idbelow should cause the device to probe on the presence of a "syslog" channel announcement, so why are you creating a new endpoint with the same here?Why aren't you just specifying the callback of the driver?
Quoted 11 lines
drivers/rpmsg/rpmsg_syslog.c new file +11
-0+if (!syslog_ept) { +dev_err (&rpdev->dev,"failed to create the syslog ept\n" ); +return -ENOMEM ; + } + rpdev->ept = syslog_ept; + +return 0 ; +} + +static struct rpmsg_device_id rpmsg_driver_syslog_id_table[] = { + { .name ="syslog" },drivers/rpmsg/rpmsg_syslog.c line 65
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ { }, +}; +MODULE_DEVICE_TABLE (rpmsg, rpmsg_driver_syslog_id_table); + +static struct rpmsg_driver rpmsg_syslog_client = { + .drv.name =KBUILD_MODNAME , + .id_table = rpmsg_driver_syslog_id_table, + .probe = rpmsg_syslog_probe, +}; +module_rpmsg_driver (rpmsg_syslog_client);I would expect that building this as a module gives you complaints about lacking
MODULE_LICENSE().Regards,
BjornQuoted 3 lines
--
2.33.1
Re: [RFC PATCH v2 1/1] rpmsg: add syslog driver
In reply to Bjorn AnderssonHi Bjorn
Quoted 7 lines
Quoted 2 lines
Allows the remote firmware to log into syslog.
This allows the remote firmware to print log messages in the kernel log, not the syslog (although your system might inject the kernel log into the syslog as well)
Correct.
Quoted 9 lines
Quoted 5 lines
Signed-off-by Christian Gmeiner <[email protected]>--- drivers/rpmsg/Kconfig | 8 +++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 65 ++++++++++++++++++++++++++++++++++++
drivers/rpmsgis for rpmsg bus and transport drivers. Client drivers should live elsewhere.
Ahh .. yes.
Quoted 4 lines
But perhaps, rather than having a driver for this, you could simply use
rpmsg_charand a userspace tool; if you want to get the remote processor logs into syslog, instead of the kernel log?
I thought about that too (also regarding the rpmsg tty driver) but that means I need to start/supervise a user space tool.
Quoted 84 lines
Quoted 69 lines
3 files changed, 74 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.cdrivers/rpmsg/Kconfig +8
-0@@ -73,4 +73,12 @@ config RPMSG_VIRTIO select RPMSG_NS select VIRTIO +config RPMSG_SYSLOG + tristate "SYSLOG device interface" + depends on RPMSG + help + Say Y here to export rpmsg endpoints as device files, usually found + in /dev. They make it possible for user-space programs to send and + receive rpmsg packets. + endmenudrivers/rpmsg/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_RPMSG_QCOM_GLINK_RPM) += qcom_glink_rpm.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o obj-$(CONFIG_RPMSG_QCOM_SMD) += qcom_smd.o obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o +obj-$(CONFIG_RPMSG_SYSLOG) += rpmsg_syslog.odrivers/rpmsg/rpmsg_syslog.c new file +34
-0@@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/rpmsg.h> + +static int rpmsg_syslog_cb (struct rpmsg_device *rpdev,void *data,int len, +void *priv,u32 src) +{ +const char *buffer = data; + +switch (buffer[0 ]) { +case 'e' : +dev_err (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'w' : +dev_warn (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'i' : +dev_info (&rpdev->dev,"%s" , buffer +1 ); +break ; +default : +dev_info (&rpdev->dev,"%s" , buffer); +break ; + } + +return 0 ; +} + +static int rpmsg_syslog_probe (struct rpmsg_device *rpdev) +{ +struct rpmsg_endpoint *syslog_ept; +struct rpmsg_channel_info syslog_chinfo = { + .src =42 ,drivers/rpmsg/rpmsg_syslog.c line 44
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ .dst = 42, + .name = "syslog", + }; + +/* +* Create the syslog service endpoint associated to the RPMsg +* device. The endpoint will be automatically destroyed when the RPMsg +* device will be deleted. +*/ + syslog_ept =rpmsg_create_ept (rpdev, rpmsg_syslog_cb,NULL , syslog_chinfo);The
rpmsg_device_idbelow should cause the device to probe on the presence of a "syslog" channel announcement, so why are you creating a new endpoint with the same here?
Quoted 2 lines
Why aren't you just specifying the callback of the driver?
Good question. I think I was happy that I got work working somehow. I also want to send out
a documentation update as it is not up to date with the current API.
Quoted 16 lines
Quoted 16 lines
drivers/rpmsg/rpmsg_syslog.c new file +16
-0+if (!syslog_ept) { +dev_err (&rpdev->dev,"failed to create the syslog ept\n" ); +return -ENOMEM ; + } + rpdev->ept = syslog_ept; + +return 0 ; +} + +static struct rpmsg_device_id rpmsg_driver_syslog_id_table[] = { + { .name ="syslog" }, + { }, +}; +MODULE_DEVICE_TABLE (rpmsg, rpmsg_driver_syslog_id_table); + +static struct rpmsg_driver rpmsg_syslog_client = {
Quoted 9 lines
drivers/rpmsg/rpmsg_syslog.c line 65
Quoted 5 lines
drivers/rpmsg/rpmsg_syslog.c new file +5
-0+ .drv.name = KBUILD_MODNAME, + .id_table = rpmsg_driver_syslog_id_table, + .probe = rpmsg_syslog_probe, +}; +module_rpmsg_driver (rpmsg_syslog_client);I would expect that building this as a module gives you complaints about lacking
MODULE_LICENSE().
Yeah .. I never built it as a module.
The biggest question I have: do you see any possibility to get such a redirection
driver into mainline? At the moment I have not heard a big no.
Signature · 5 lines
greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy
Re: [RFC PATCH v2 1/1] rpmsg: add syslog driver
Quoted 117 lines · Christian Gmeiner
Hi Bjorn
Quoted 7 lines
Quoted 2 lines
Allows the remote firmware to log into syslog.
This allows the remote firmware to print log messages in the kernel log, not the syslog (although your system might inject the kernel log into the syslog as well)
Correct.
Quoted 9 lines
Quoted 5 lines
Signed-off-by Christian Gmeiner <[email protected]>--- drivers/rpmsg/Kconfig | 8 +++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 65 ++++++++++++++++++++++++++++++++++++
drivers/rpmsgis for rpmsg bus and transport drivers. Client drivers should live elsewhere.Ahh .. yes.
Quoted 4 lines
But perhaps, rather than having a driver for this, you could simply use
rpmsg_charand a userspace tool; if you want to get the remote processor logs into syslog, instead of the kernel log?I thought about that too (also regarding the rpmsg tty driver) but that means I need to start/supervise a user space tool.
Quoted 84 lines
Quoted 69 lines
3 files changed, 74 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.cdrivers/rpmsg/Kconfig +8
-0@@ -73,4 +73,12 @@ config RPMSG_VIRTIO select RPMSG_NS select VIRTIO +config RPMSG_SYSLOG + tristate "SYSLOG device interface" + depends on RPMSG + help + Say Y here to export rpmsg endpoints as device files, usually found + in /dev. They make it possible for user-space programs to send and + receive rpmsg packets. + endmenudrivers/rpmsg/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_RPMSG_QCOM_GLINK_RPM) += qcom_glink_rpm.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o obj-$(CONFIG_RPMSG_QCOM_SMD) += qcom_smd.o obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o +obj-$(CONFIG_RPMSG_SYSLOG) += rpmsg_syslog.odrivers/rpmsg/rpmsg_syslog.c new file +34
-0@@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/rpmsg.h> + +static int rpmsg_syslog_cb (struct rpmsg_device *rpdev,void *data,int len, +void *priv,u32 src) +{ +const char *buffer = data; + +switch (buffer[0 ]) { +case 'e' : +dev_err (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'w' : +dev_warn (&rpdev->dev,"%s" , buffer +1 ); +break ; +case 'i' : +dev_info (&rpdev->dev,"%s" , buffer +1 ); +break ; +default : +dev_info (&rpdev->dev,"%s" , buffer); +break ; + } + +return 0 ; +} + +static int rpmsg_syslog_probe (struct rpmsg_device *rpdev) +{ +struct rpmsg_endpoint *syslog_ept; +struct rpmsg_channel_info syslog_chinfo = { + .src =42 ,drivers/rpmsg/rpmsg_syslog.c line 44
Quoted 10 lines
drivers/rpmsg/rpmsg_syslog.c new file +10
-0+ .dst = 42, + .name = "syslog", + }; + +/* +* Create the syslog service endpoint associated to the RPMsg +* device. The endpoint will be automatically destroyed when the RPMsg +* device will be deleted. +*/ + syslog_ept =rpmsg_create_ept (rpdev, rpmsg_syslog_cb,NULL , syslog_chinfo);The
rpmsg_device_idbelow should cause the device to probe on the presence of a "syslog" channel announcement, so why are you creating a new endpoint with the same here?
Quoted 7 lines
Quoted 2 lines
Why aren't you just specifying the callback of the driver?
Good question. I think I was happy that I got work working somehow. I also want to send out
a documentation update as it is not up to date with the current API.
I'd be happy to take any documentation updates - or perhaps we should reduce the duplication between the kerneldoc and Documentation/*...
Quoted 26 lines
Quoted 16 lines
Quoted 16 lines
drivers/rpmsg/rpmsg_syslog.c new file +16
-0+if (!syslog_ept) { +dev_err (&rpdev->dev,"failed to create the syslog ept\n" ); +return -ENOMEM ; + } + rpdev->ept = syslog_ept; + +return 0 ; +} + +static struct rpmsg_device_id rpmsg_driver_syslog_id_table[] = { + { .name ="syslog" }, + { }, +}; +MODULE_DEVICE_TABLE (rpmsg, rpmsg_driver_syslog_id_table); + +static struct rpmsg_driver rpmsg_syslog_client = {Quoted 9 lines
drivers/rpmsg/rpmsg_syslog.c line 65
Quoted 5 lines
drivers/rpmsg/rpmsg_syslog.c new file +5
-0+ .drv.name = KBUILD_MODNAME, + .id_table = rpmsg_driver_syslog_id_table, + .probe = rpmsg_syslog_probe, +}; +module_rpmsg_driver (rpmsg_syslog_client);I would expect that building this as a module gives you complaints about lacking
MODULE_LICENSE().
Quoted 6 lines
Yeah .. I never built it as a module.
The biggest question I have: do you see any possibility to get such a redirection
driver into mainline? At the moment I have not heard a big no.
My feeling is "do we really need a dedicated driver for it", but I do recognize that it solves a problem for you.
The only "objection" I have is that I personally wouldn't want all the firmware logs mixed up with the kernel logs. Somehow getting this into journald separately seems more useful.
Regards,
Bjorn
Quoted 6 lines
Signature · 5 lines
greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy