Re: [PATCH V2 3/5] DCC: Added the sysfs entries for DCC(Data Capture and Compare) driver

2021-04-01 Thread Stephen Boyd
Quoting schow...@codeaurora.org (2021-04-01 08:42:50)
> On 2021-03-30 01:39, Stephen Boyd wrote:
> > Quoting Souradeep Chowdhury (2021-03-25 01:02:34)
> >> The DCC is a DMA engine designed to store register values either in
> >> case of a system crash or in case of software triggers manually done
> >> by the user.Using DCC hardware and the sysfs interface of the driver
> >> the user can exploit various functionalities of DCC.The user can 
> >> specify
> >> the register addresses,the values of which is stored by DCC in it's
> >> dedicated SRAM.The register addresses can be used either to read from,
> >> write to,first read and store value and then write or to loop.All 
> >> these
> >> options can be exploited using the sysfs interface given to the user.
> >> Following are the sysfs interfaces exposed in DCC driver which are
> >> documented
> >> 1)trigger
> >> 2)config
> >> 3)config_write
> >> 4)config_reset
> >> 5)enable
> >> 6)rd_mod_wr
> >> 7)loop
> >> 
> >> Signed-off-by: Souradeep Chowdhury 
> >> ---
> >>  Documentation/ABI/testing/sysfs-driver-dcc | 114 
> >> +
> > 
> > Please combine this with the driver patch.
> 
> Ack
> 
> > 
> >>  1 file changed, 114 insertions(+)
> >>  create mode 100644 Documentation/ABI/testing/sysfs-driver-dcc
> > 
> > Perhaps this should be an ioctl interface instead of a sysfs interface?
> 
> The reasons for choosing sysfs over ioctl is as follows

Cool, please add these details to the commit text.

> 
> 
> i) As can be seen from the sysfs attribute descriptions, most of it does 
> basic hardware manipulations like dcc_enable, dcc_disable, config reset 
> etc. As a result sysfs is preferred over ioctl as we just need to enter 
> a 0 or 1
> signal in such cases.
> 
> ii) Existing similar debug hardwares are there for which drivers have 
> been written using sysfs interface. One such example is the 
> coresight-etm-trace driver. Following is the link for reference
> 
> https://www.kernel.org/doc/html/latest/trace/coresight/coresight-etm4x-reference.html

I wasn't deeply involved but I recall that the whole coresight sysfs
interface was disliked and it mostly got rewritten to go through the
perf tool instead. Pointing to the coresight sysfs API is not the best
approach here.

Maybe a closer analog would be the watchdog subsystem, which is ioctl
based and uses a character device like /dev/watchdog. Watchdogs are
simple debug features that reboot the system when everything goes wrong.
This looks like a hardware block that can be used to gather information
when the watchdog fires.

Reading the doc closer it is quite frightening that a device like this
can let you read registers in the hardware on-demand and even store
values of registers over time. This is like /dev/mem on steroids. This
needs to be highly restricted as it sounds like it could be used to
snoop on security keys that are set in the hardware or secrets stored in
memory. Is the hardware restricted at all in what it can read?


Re: [PATCH V2 3/5] DCC: Added the sysfs entries for DCC(Data Capture and Compare) driver

2021-04-01 Thread schowdhu

On 2021-03-30 01:39, Stephen Boyd wrote:

Quoting Souradeep Chowdhury (2021-03-25 01:02:34)

The DCC is a DMA engine designed to store register values either in
case of a system crash or in case of software triggers manually done
by the user.Using DCC hardware and the sysfs interface of the driver
the user can exploit various functionalities of DCC.The user can 
specify

the register addresses,the values of which is stored by DCC in it's
dedicated SRAM.The register addresses can be used either to read from,
write to,first read and store value and then write or to loop.All 
these

options can be exploited using the sysfs interface given to the user.
Following are the sysfs interfaces exposed in DCC driver which are
documented
1)trigger
2)config
3)config_write
4)config_reset
5)enable
6)rd_mod_wr
7)loop

Signed-off-by: Souradeep Chowdhury 
---
 Documentation/ABI/testing/sysfs-driver-dcc | 114 
+


Please combine this with the driver patch.


Ack




 1 file changed, 114 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-dcc


Perhaps this should be an ioctl interface instead of a sysfs interface?


The reasons for choosing sysfs over ioctl is as follows


i) As can be seen from the sysfs attribute descriptions, most of it does 
basic hardware manipulations like dcc_enable, dcc_disable, config reset 
etc. As a result sysfs is preferred over ioctl as we just need to enter 
a 0 or 1

signal in such cases.

ii) Existing similar debug hardwares are there for which drivers have 
been written using sysfs interface. One such example is the 
coresight-etm-trace driver. Following is the link for reference


https://www.kernel.org/doc/html/latest/trace/coresight/coresight-etm4x-reference.html





diff --git a/Documentation/ABI/testing/sysfs-driver-dcc 
b/Documentation/ABI/testing/sysfs-driver-dcc

new file mode 100644
index 000..05d24f0
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-dcc
@@ -0,0 +1,114 @@
+What:   /sys/bus/platform/devices/.../trigger
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This is the sysfs interface for manual software
+   triggers.The user can simply enter a 1 against
+   the sysfs file and enable a manual trigger.
+   Example:
+   echo  1 > /sys/bus/platform/devices/.../trigger
+
+What:   /sys/bus/platform/devices/.../enable
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This sysfs interface is used for enabling the
+   the dcc hardware.Without this being set to 1,


Space after period please.


Ack




+   the dcc hardware ceases to function.
+   Example:
+   echo  0 > /sys/bus/platform/devices/.../enable
+   (disable interface)
+   echo  1 > /sys/bus/platform/devices/.../enable
+   (enable interface)
+
+What:   /sys/bus/platform/devices/.../config
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This is the most commonly used sysfs interface
+   file and this basically stores the addresses of
+   the registers which needs to be read in case of
+   a hardware crash or manual software triggers.
+   Example:
+   echo  0x8010 10 > 
/sys/bus/platform/devices/../config

+   This specifies that 10 words starting from address
+   0x8010 is to be read.In case there are no words to 
be

+   specified we can simply enter the address.
+
+What:   /sys/bus/platform/devices/.../config_write
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This file allows user to write a value to the register
+   address given as argument.The values are entered in 
the

+   form of  .The reason for this
+   feature of dcc is that for accessing certain registers
+   it is necessary to set some bits of soe other 
register.


s/soe/some/?


Ack




+   That is achievable by giving DCC this privelege.


s/privelege/privilege/


Ack




+   Example:
+   echo 0x8000 0xFF > 
/sys/bus/platform/devices/.../config_write

+
+What:   /sys/bus/platform/devices/.../config_reset
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This file is used to reset the configuration of
+   a dcc driver to the default configuration.
+   Example:
+   echo  1 > /sys/bus/platform/devices/.../config_reset
+


Re: [PATCH V2 3/5] DCC: Added the sysfs entries for DCC(Data Capture and Compare) driver

2021-03-29 Thread Stephen Boyd
Quoting Souradeep Chowdhury (2021-03-25 01:02:34)
> The DCC is a DMA engine designed to store register values either in
> case of a system crash or in case of software triggers manually done
> by the user.Using DCC hardware and the sysfs interface of the driver
> the user can exploit various functionalities of DCC.The user can specify
> the register addresses,the values of which is stored by DCC in it's
> dedicated SRAM.The register addresses can be used either to read from,
> write to,first read and store value and then write or to loop.All these
> options can be exploited using the sysfs interface given to the user.
> Following are the sysfs interfaces exposed in DCC driver which are
> documented
> 1)trigger
> 2)config
> 3)config_write
> 4)config_reset
> 5)enable
> 6)rd_mod_wr
> 7)loop
> 
> Signed-off-by: Souradeep Chowdhury 
> ---
>  Documentation/ABI/testing/sysfs-driver-dcc | 114 
> +

Please combine this with the driver patch.

>  1 file changed, 114 insertions(+)
>  create mode 100644 Documentation/ABI/testing/sysfs-driver-dcc

Perhaps this should be an ioctl interface instead of a sysfs interface?

> 
> diff --git a/Documentation/ABI/testing/sysfs-driver-dcc 
> b/Documentation/ABI/testing/sysfs-driver-dcc
> new file mode 100644
> index 000..05d24f0
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-driver-dcc
> @@ -0,0 +1,114 @@
> +What:   /sys/bus/platform/devices/.../trigger
> +Date:   March 2021
> +Contact:Souradeep Chowdhury 
> +Description:
> +   This is the sysfs interface for manual software
> +   triggers.The user can simply enter a 1 against
> +   the sysfs file and enable a manual trigger.
> +   Example:
> +   echo  1 > /sys/bus/platform/devices/.../trigger
> +
> +What:   /sys/bus/platform/devices/.../enable
> +Date:   March 2021
> +Contact:Souradeep Chowdhury 
> +Description:
> +   This sysfs interface is used for enabling the
> +   the dcc hardware.Without this being set to 1,

Space after period please.

> +   the dcc hardware ceases to function.
> +   Example:
> +   echo  0 > /sys/bus/platform/devices/.../enable
> +   (disable interface)
> +   echo  1 > /sys/bus/platform/devices/.../enable
> +   (enable interface)
> +
> +What:   /sys/bus/platform/devices/.../config
> +Date:   March 2021
> +Contact:Souradeep Chowdhury 
> +Description:
> +   This is the most commonly used sysfs interface
> +   file and this basically stores the addresses of
> +   the registers which needs to be read in case of
> +   a hardware crash or manual software triggers.
> +   Example:
> +   echo  0x8010 10 > /sys/bus/platform/devices/../config
> +   This specifies that 10 words starting from address
> +   0x8010 is to be read.In case there are no words to be
> +   specified we can simply enter the address.
> +
> +What:   /sys/bus/platform/devices/.../config_write
> +Date:   March 2021
> +Contact:Souradeep Chowdhury 
> +Description:
> +   This file allows user to write a value to the register
> +   address given as argument.The values are entered in the
> +   form of  .The reason for this
> +   feature of dcc is that for accessing certain registers
> +   it is necessary to set some bits of soe other register.

s/soe/some/?

> +   That is achievable by giving DCC this privelege.

s/privelege/privilege/

> +   Example:
> +   echo 0x8000 0xFF > 
> /sys/bus/platform/devices/.../config_write
> +
> +What:   /sys/bus/platform/devices/.../config_reset
> +Date:   March 2021
> +Contact:Souradeep Chowdhury 
> +Description:
> +   This file is used to reset the configuration of
> +   a dcc driver to the default configuration.
> +   Example:
> +   echo  1 > /sys/bus/platform/devices/.../config_reset
> +


[PATCH V2 3/5] DCC: Added the sysfs entries for DCC(Data Capture and Compare) driver

2021-03-25 Thread Souradeep Chowdhury
The DCC is a DMA engine designed to store register values either in
case of a system crash or in case of software triggers manually done
by the user.Using DCC hardware and the sysfs interface of the driver
the user can exploit various functionalities of DCC.The user can specify
the register addresses,the values of which is stored by DCC in it's
dedicated SRAM.The register addresses can be used either to read from,
write to,first read and store value and then write or to loop.All these
options can be exploited using the sysfs interface given to the user.
Following are the sysfs interfaces exposed in DCC driver which are
documented
1)trigger
2)config
3)config_write
4)config_reset
5)enable
6)rd_mod_wr
7)loop

Signed-off-by: Souradeep Chowdhury 
---
 Documentation/ABI/testing/sysfs-driver-dcc | 114 +
 1 file changed, 114 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-dcc

diff --git a/Documentation/ABI/testing/sysfs-driver-dcc 
b/Documentation/ABI/testing/sysfs-driver-dcc
new file mode 100644
index 000..05d24f0
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-dcc
@@ -0,0 +1,114 @@
+What:   /sys/bus/platform/devices/.../trigger
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This is the sysfs interface for manual software
+   triggers.The user can simply enter a 1 against
+   the sysfs file and enable a manual trigger.
+   Example:
+   echo  1 > /sys/bus/platform/devices/.../trigger
+
+What:   /sys/bus/platform/devices/.../enable
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This sysfs interface is used for enabling the
+   the dcc hardware.Without this being set to 1,
+   the dcc hardware ceases to function.
+   Example:
+   echo  0 > /sys/bus/platform/devices/.../enable
+   (disable interface)
+   echo  1 > /sys/bus/platform/devices/.../enable
+   (enable interface)
+
+What:   /sys/bus/platform/devices/.../config
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This is the most commonly used sysfs interface
+   file and this basically stores the addresses of
+   the registers which needs to be read in case of
+   a hardware crash or manual software triggers.
+   Example:
+   echo  0x8010 10 > /sys/bus/platform/devices/../config
+   This specifies that 10 words starting from address
+   0x8010 is to be read.In case there are no words to be
+   specified we can simply enter the address.
+
+What:   /sys/bus/platform/devices/.../config_write
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This file allows user to write a value to the register
+   address given as argument.The values are entered in the
+   form of  .The reason for this
+   feature of dcc is that for accessing certain registers
+   it is necessary to set some bits of soe other register.
+   That is achievable by giving DCC this privelege.
+   Example:
+   echo 0x8000 0xFF > 
/sys/bus/platform/devices/.../config_write
+
+What:   /sys/bus/platform/devices/.../config_reset
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This file is used to reset the configuration of
+   a dcc driver to the default configuration.
+   Example:
+   echo  1 > /sys/bus/platform/devices/.../config_reset
+
+What:   /sys/bus/platform/devices/.../loop
+Date:  March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This file is used to enter the loop count as dcc
+   driver gives the option to loop multiple times on
+   the same register and store the values for each
+   loop.This is done to capture the changing values
+   of a register with time which comes handy for
+   debugging purposes.
+   Example:
+   echo 10 > /sys/bus/platform/devices/10a2000.dcc/loop
+   (Setting the loop count to 10)
+   echo  0x8010 10 > /sys/bus/platform/devices/.../config
+(Read 10 words starting from address 0x8010O)
+   echo 1 > /sys/bus/platform/devices/.../loop
+   (Terminate the loop by writing a count of 1 to the loop sysfs 
node)
+
+What:   /sys/bus/platform/devices/.../rd_mod_wr
+Date:   March 2021
+Contact:Souradeep Chowdhury 
+Description:
+   This file is used to read the value of the register
+   and then write the value given as an argument to the
+