Skip to contentSkip to conversation

drivers/misc: add rawio framework and drivers

PATCH In review Bin Gao 3 participants 7 messages Oct 22, 2013

lore
Share & tools
lore

Bin Gao

author
#0 lore raw

cover drivers/misc: add rawio framework and drivers

To read/write registers from a device is very important on embedded system, especially SoC systems. Physically there could be different types of devices based on bus tyes, e.g. PCI devices, I2C (slave)devices, I/O devices(memory mapped), inter-processor devices, etc. Typically there are userland tools from
PC Linux to access device registers, but on some embedded system initrd and rootfs come with a minimal busybox and most useful userland tools are not available. To add these tools back to rootfs is not convenient either. What's more, on some systems with runtime pm enabled, reading/writing registers
from a device which is in low power state will cause problems. For these reasons, to have some tools/interfaces directly from kernel space via debug fs seems to be easy, cheap and convenient.

These patchsets are designed to achieve above goals to ease device driver and kernel debugging on embedded systems.

Rawio provides a framework to read/write registers from a bus, including pci, i2c, I/O device(memory mapped), etc. based on debug fs. Rawio bus drivers implement the read/write operation on a specific bus on top of the rawio framework driver.
Currently only three bus drivers are available: pci, iomem and i2c. But it's extremely easy to add more drivers on top of the framework if needed.

 drivers/misc/Kconfig             |   1 +
 drivers/misc/Makefile            |   1 +
 drivers/misc/rawio/Kconfig       |  59 +++++
 drivers/misc/rawio/Makefile      |   4 +
 drivers/misc/rawio/rawio.c       | 514
+++++++++++++++++++++++++++++++++++++++
 drivers/misc/rawio/rawio_i2c.c   | 224 +++++++++++++++++
 drivers/misc/rawio/rawio_iomem.c | 401 ++++++++++++++++++++++++++++++
 drivers/misc/rawio/rawio_pci.c   | 235 ++++++++++++++++++
 include/linux/rawio.h            |  78 ++++++
 9 files changed, 1517 insertions(+)
 create mode 100644 drivers/misc/rawio/Kconfig
 create mode 100644 drivers/misc/rawio/Makefile
 create mode 100644 drivers/misc/rawio/rawio.c
 create mode 100644 drivers/misc/rawio/rawio_i2c.c
 create mode 100644 drivers/misc/rawio/rawio_iomem.c
 create mode 100644 drivers/misc/rawio/rawio_pci.c
 create mode 100644 include/linux/rawio.h
#1 lore raw
Quoted 5 lines · Bin Gao

To read/write registers from a device is very important on embedded system, especially SoC systems. Physically there could be different types of devices based on bus tyes, e.g. PCI devices, I2C (slave)devices, I/O devices(memory mapped), inter-processor devices, etc. Typically there are userland tools from

Quoted 8 lines

PC Linux to access device registers, but on some embedded system initrd and rootfs come with a minimal busybox and most useful userland tools are not available. To add these tools back to rootfs is not convenient either. What's more, on some systems with runtime pm enabled, reading/writing registers
from a device which is in low power state will cause problems. For these reasons, to have some tools/interfaces directly from kernel space via debug fs seems to be easy, cheap and convenient.

So, just because userspace is "hard" you want to add stuff to the kernel instead.

Sorry, but for over the past decade, we have been doing just the opposite, if things can be done in userspace, then they should be done there. So for us to go in the opposite direction, like these patches show, would be a major change.

Quoted 8 lines

These patchsets are designed to achieve above goals to ease device driver and kernel debugging on embedded systems.

Rawio provides a framework to read/write registers from a bus, including pci, i2c, I/O device(memory mapped), etc. based on debug fs. Rawio bus drivers implement the read/write operation on a specific bus on top of the rawio framework driver.
Currently only three bus drivers are available: pci, iomem and i2c.

You can already do this today for PCI with the UIO framework, right? Why duplicate that functionality here with another userapce API that we will then have to maintain for the next 40+ years?

Quoted 9 lines

But it's extremely easy to add more drivers on top of the framework if needed.

 drivers/misc/Kconfig             |   1 +
 drivers/misc/Makefile            |   1 +
 drivers/misc/rawio/Kconfig       |  59 +++++
 drivers/misc/rawio/Makefile      |   4 +
 drivers/misc/rawio/rawio.c       | 514

+++++++++++++++++++++++++++++++++++++++

All of your patches are line-wrapped and totally fail to apply, so even if we wanted to take this type of changes, I couldn't :(

Have you run these proposed changes by any of the Intel kernel developers? What did they say to them?

If not, why haven't you, isn't that a resource you should be using for things like this?

greg k-h

#2 lore raw
Quoted 32 lines · Greg Kroah-Hartman
Quoted 5 lines · Bin Gao

To read/write registers from a device is very important on embedded system, especially SoC systems. Physically there could be different types of devices based on bus tyes, e.g. PCI devices, I2C (slave)devices, I/O devices(memory mapped), inter-processor devices, etc. Typically there are userland tools from

Quoted 8 lines

PC Linux to access device registers, but on some embedded system initrd and rootfs come with a minimal busybox and most useful userland tools are not available. To add these tools back to rootfs is not convenient either. What's more, on some systems with runtime pm enabled, reading/writing registers
from a device which is in low power state will cause problems. For these reasons, to have some tools/interfaces directly from kernel space via debug fs seems to be easy, cheap and convenient.

So, just because userspace is "hard" you want to add stuff to the kernel instead.

Sorry, but for over the past decade, we have been doing just the opposite, if things can be done in userspace, then they should be done there. So for us to go in the opposite direction, like these patches show, would be a major change.

Quoted 8 lines

These patchsets are designed to achieve above goals to ease device driver and kernel debugging on embedded systems.

Rawio provides a framework to read/write registers from a bus, including pci, i2c, I/O device(memory mapped), etc. based on debug fs. Rawio bus drivers implement the read/write operation on a specific bus on top of the rawio framework driver.
Currently only three bus drivers are available: pci, iomem and i2c.

Quoted 4 lines

You can already do this today for PCI with the UIO framework, right? Why duplicate that functionality here with another userapce API that we will then have to maintain for the next 40+ years?

Same for i2c, where the same functionality is supported through i2c-tools and the i2c-dev driver. Adding i2c-tools to initramfs and/or to the root file system should not be that much of an issue, much less than having to maintain two APIs for the same purpose.

Guenter

author
#3 lore raw
Quoted 11 lines · Guenter Roeck
Quoted 5 lines

You can already do this today for PCI with the UIO framework, right? Why duplicate that functionality here with another userapce API that we will then have to maintain for the next 40+ years?

Same for i2c, where the same functionality is supported through i2c-tools and the i2c-dev driver. Adding i2c-tools to initramfs and/or to the root file system should not be that much of an issue, much less than having to maintain two APIs for the same purpose.

Guenter

For PCI and memory mapped I/O devices, we have the runtime pm issue that has to be addressed from kernel space.
For I2C slave devices, there is no such a issue so yes i2c-tools and i2c-dev drivers are fine. But the two APIs are required by PCI and memory mapped I/O devices anyway.

#4 lore raw
Quoted 11 lines · Bin Gao
Quoted 10 lines · Guenter Roeck
Quoted 5 lines

You can already do this today for PCI with the UIO framework, right? Why duplicate that functionality here with another userapce API that we will then have to maintain for the next 40+ years?

Same for i2c, where the same functionality is supported through i2c-tools and the i2c-dev driver. Adding i2c-tools to initramfs and/or to the root file system should not be that much of an issue, much less than having to maintain two APIs for the same purpose.

Quoted 4 lines
Quoted 1 line

Guenter

For PCI and memory mapped I/O devices, we have the runtime pm issue that has to be addressed from kernel space.

Then create a UIO pci driver and you should be fine, right? That's what others do today and it works quite well for them.

greg k-h

author
#5 lore raw
In reply to Greg Kroah-Hartman
Quoted 3 lines · Greg Kroah-Hartman

So, just because userspace is "hard" you want to add stuff to the kernel instead.

Well, there are other reasons - "hard" is just one of them.
For instance, on some platforms with runtime pm enabled, access to registers of a device which is in low power state will cause problems(syste reboot, etc.). You can only wake it up to running state by runtime API from kernel space.

Quoted 5 lines

Sorry, but for over the past decade, we have been doing just the opposite, if things can be done in userspace, then they should be done there. So for us to go in the opposite direction, like these patches show, would be a major change.

Agree, but as mentioned above, for some situation we can't do it from user space.

Quoted 4 lines

You can already do this today for PCI with the UIO framework, right? Why duplicate that functionality here with another userapce API that we will then have to maintain for the next 40+ years?

No, UIO is not appropriate for my requirement.
The thing I need is to dump any registers just by 2 simple commands.

Quoted 3 lines

All of your patches are line-wrapped and totally fail to apply, so even if we wanted to take this type of changes, I couldn't :(

Sorry for that. I recently upgraded my email client, will fix it next posting.

Quoted 6 lines

Have you run these proposed changes by any of the Intel kernel developers? What did they say to them?

If not, why haven't you, isn't that a resource you should be using for things like this?

Why you had these strange questions?
Over years, we have been maintaining and using these drivers internally for various purpose across our group for SoC pre-silicon and post-silicon degugging, e.g. IOAPIC RTE dumping, GPIO tunning, raw device degugging without a driver(i2c, spi, uart), etc., etc., ...
Trying to push some existed codes upstream is not a bad thing.

Quoted 1 line

greg k-h

#6 lore raw
Quoted 8 lines · Bin Gao
Quoted 3 lines · Greg Kroah-Hartman

So, just because userspace is "hard" you want to add stuff to the kernel instead.

Well, there are other reasons - "hard" is just one of them.
For instance, on some platforms with runtime pm enabled, access to registers of a device which is in low power state will cause problems(syste reboot, etc.). You can only wake it up to running state by runtime API from kernel space.

Then write a UIO pci driver, that should work, right?

Quoted 5 lines
Quoted 5 lines

Sorry, but for over the past decade, we have been doing just the opposite, if things can be done in userspace, then they should be done there. So for us to go in the opposite direction, like these patches show, would be a major change.

Quoted 8 lines

Agree, but as mentioned above, for some situation we can't do it from user space.

Quoted 4 lines

You can already do this today for PCI with the UIO framework, right? Why duplicate that functionality here with another userapce API that we will then have to maintain for the next 40+ years?

No, UIO is not appropriate for my requirement.

I don't know what your "requirements" are.

Quoted 1 line

The thing I need is to dump any registers just by 2 simple commands.

I find it hard to believe that your "requirement" dictates the exact method of _how_ you get access to this hardware.

Quoted 7 lines
Quoted 6 lines

Have you run these proposed changes by any of the Intel kernel developers? What did they say to them?

If not, why haven't you, isn't that a resource you should be using for things like this?

Why you had these strange questions?

It's something I ask any Intel developer who sends odd patches that have obviously not been reviewed by Intel's kernel developers. They are a resource you should be using to tell you these types of things, don't make me, a community member, tell you this.

Quoted 5 lines

Over years, we have been maintaining and using these drivers internally for various purpose across our group for SoC pre-silicon and post-silicon degugging, e.g. IOAPIC RTE dumping, GPIO tunning, raw device degugging without a driver(i2c, spi, uart), etc., etc., ...
Trying to push some existed codes upstream is not a bad thing.

Trying to push code that is incorrect is a bad thing. Just because it has been living in a private tree for X number of years is not an excuse, because you are now asking me and others to maintain this API you have created (which is undocumented) for the next 40+ years.

Again, use the interfaces we already have, and if they are not sufficient for whatever reason, help make them better. Don't create whole new ones just because someone 5+ years ago didn't know about them, or that they weren't even present at that time. That's not the community's fault, it's yours.

greg k-h