Skip to contentSkip to conversation

drivers/staging: Gasket driver framework + Apex driver

PATCH Superseded Simon Que 3 participants 3 messages Jun 20, 2018 – Jun 28, 2018 Staging

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Simon Que

author
#0 lore raw

PATCH v4 1/1 drivers/staging: Gasket driver framework + Apex driver

The Gasket (Google ASIC Software, Kernel Extensions, and Tools) kernel framework is a generic, flexible system that supports thin kernel drivers. Gasket kernel drivers are expected to handle opening and closing devices, mmap'ing BAR space as requested, a small selection of ioctls, and handling page table translation (covered below). Any other functions should be handled by userspace code.

The Gasket common module is not enough to run a device. In order to customize the Gasket code for a given piece of hardware, a device specific module must be created. At a minimum, this module must define a struct gasket_driver_desc containing the device-specific data for use by the framework; in addition, the module must declare an __init function that calls gasket_register_device with the module's gasket_driver_desc struct. Finally, the driver must define an exit function that calls gasket_unregister_device with the module's gasket_driver_desc struct.

One of the core assumptions of the Gasket framework is that precisely one process is allowed to have an open write handle to the device node at any given time. (That process may, once it has one write handle, open any number of additional write handles.) This is accomplished by tracking open and close data for each driver instance.

---
Patch history:
[PATCH v2]
- Various fixes from John Joseph and Rob Springer [PATCH v3]
- Removed part about Apex from patch description
- Rearranged order of authors
- 2017 -> 2018
- GPL -> GPL v2
- Deleted README
- Added MAINTAINERS
- Added TODO with all unresolved comments from below
- Added gasket_ioctl.h, which was previously missing [PATCH v4]
- Deleted unused field "base" in struct gasket_coherent_buffer
- Moved maintainer info to top-level MAINTAINERS file

 MAINTAINERS                                |    7 +
 drivers/staging/Kconfig                    |    2 +
 drivers/staging/Makefile                   |    1 +
 drivers/staging/gasket/Kconfig             |   23 +
 drivers/staging/gasket/Makefile            |    9 +
 drivers/staging/gasket/TODO                |   17 +
 drivers/staging/gasket/apex.h              |   95 +
 drivers/staging/gasket/apex_driver.c       |  771 +++++++
 drivers/staging/gasket/gasket.h            |  129 ++
 drivers/staging/gasket/gasket_constants.h  |   56 +
 drivers/staging/gasket/gasket_core.c       | 2156 ++++++++++++++++++++
 drivers/staging/gasket/gasket_core.h       |  719 +++++++
 drivers/staging/gasket/gasket_interrupt.c  |  638 ++++++
 drivers/staging/gasket/gasket_interrupt.h  |  172 ++
 drivers/staging/gasket/gasket_ioctl.c      |  449 ++++
 drivers/staging/gasket/gasket_ioctl.h      |   35 +
 drivers/staging/gasket/gasket_logging.h    |   68 +
 drivers/staging/gasket/gasket_page_table.c | 1771 ++++++++++++++++
 drivers/staging/gasket/gasket_page_table.h |  265 +++
 drivers/staging/gasket/gasket_sysfs.c      |  497 +++++
 drivers/staging/gasket/gasket_sysfs.h      |  199 ++
 21 files changed, 8079 insertions(+)
 create mode 100644 drivers/staging/gasket/Kconfig
 create mode 100644 drivers/staging/gasket/Makefile
 create mode 100644 drivers/staging/gasket/TODO
 create mode 100644 drivers/staging/gasket/apex.h
 create mode 100644 drivers/staging/gasket/apex_driver.c
 create mode 100644 drivers/staging/gasket/gasket.h
 create mode 100644 drivers/staging/gasket/gasket_constants.h
 create mode 100644 drivers/staging/gasket/gasket_core.c
 create mode 100644 drivers/staging/gasket/gasket_core.h
 create mode 100644 drivers/staging/gasket/gasket_interrupt.c
 create mode 100644 drivers/staging/gasket/gasket_interrupt.h
 create mode 100644 drivers/staging/gasket/gasket_ioctl.c
 create mode 100644 drivers/staging/gasket/gasket_ioctl.h
 create mode 100644 drivers/staging/gasket/gasket_logging.h
 create mode 100644 drivers/staging/gasket/gasket_page_table.c
 create mode 100644 drivers/staging/gasket/gasket_page_table.h
 create mode 100644 drivers/staging/gasket/gasket_sysfs.c
 create mode 100644 drivers/staging/gasket/gasket_sysfs.h
MAINTAINERS +7 -0
index cd5681093179..bd6e7b44cfec 100644
@@ -4652,6 +4652,13 @@ L:	[email protected]
 S:	Odd Fixes (e.g., new signatures)
 F:	drivers/scsi/fdomain.*
 
+GASKET DRIVER FRAMEWORK
+M:	Rob Springer <[email protected]>
+M:	John Joseph <[email protected]>
+M:	Ben Chan <[email protected]>
+S:	Maintained
+F:	drivers/staging/gasket/
+
 GCOV BASED KERNEL PROFILING
 M:	Peter Oberparleiter <[email protected]>
 S:	Maintained
drivers/staging/Kconfig +2 -0
index 5d3b86a33857..67d8467e8eab 100644
@@ -110,4 +110,6 @@ source "drivers/staging/wilc1000/Kconfig"
 
 source "drivers/staging/most/Kconfig"
 
+source "drivers/staging/gasket/Kconfig"
+
 endif # STAGING
drivers/staging/Makefile +1 -0
index 30918edef5e3..4ae53f11c243 100644
@@ -47,3 +47,4 @@ obj-$(CONFIG_FB_TFT)		+= fbtft/
 obj-$(CONFIG_FSL_MC_BUS)	+= fsl-mc/
 obj-$(CONFIG_WILC1000)		+= wilc1000/
 obj-$(CONFIG_MOST)		+= most/
+obj-$(CONFIG_STAGING_GASKET_FRAMEWORK)		+= gasket/
drivers/staging/gasket/Kconfig new file +23 -0
new file mode 100644
index 000000000000..3465e8510fc2
@@ -0,0 +1,23 @@
+menu "Gasket devices"
+
+config STAGING_GASKET_FRAMEWORK
+	tristate "Gasket framework"
+	depends on PCI
+	help
+		This framework supports Gasket-compatible devices, such as Apex.
+		It is required for either of those modules.
+
+		To compile this driver as a module, choose M here.  The module
+		will be called "gasket".
+
+config STAGING_APEX_DRIVER
+	tristate "Apex Driver"
+	depends on STAGING_GASKET_FRAMEWORK
+	help
+		This driver supports the Apex device.  Say Y if you want to
+		include this driver in the kernel.
+
+		To compile this driver as a module, choose M here.  The module
+		will be called "apex".
+
+endmenu
drivers/staging/gasket/Makefile new file +9 -0
new file mode 100644
index 000000000000..cec813ece678
@@ -0,0 +1,9 @@
+#
+#  Makefile for Gasket framework and dependent drivers.
+#
+
+obj-$(CONFIG_STAGING_GASKET_FRAMEWORK)	+= gasket.o
+obj-$(CONFIG_STAGING_APEX_DRIVER)	+= apex.o
+
+gasket-objs	:= gasket_core.o gasket_ioctl.o gasket_interrupt.o gasket_page_table.o gasket_sysfs.o
+apex-objs	:= apex_driver.o
drivers/staging/gasket/TODO new file +17 -0
new file mode 100644
index 000000000000..0d8ee9602c80
@@ -0,0 +1,17 @@
+This is a list of things that need to be done to get this driver out of the
+staging directory.
+- Use SPDX tags to show the license of the file, and no more "boiler-plate"
+  license text is needed.
+- Remove static function declarations.
+- Document sysfs files with Documentation/ABI/ entries.
+- Use misc interface instead of major number for driver version description.
+- Add descriptions of module_param's
+- Remove gasket-specific logging functions.
+- apex_get_status() should actually check status.
+- Static functions don't need kernel doc formatting, can be simplified.
+- Fix multi-line alignment formatting to look like:
+      int ret = long_function_name(device, VARIABLE1, VARIABLE2,
+                                   VARIABLE3, VARIABLE4);
+- "drivers" should never be dealing with "raw" sysfs calls or mess around with
+  kobjects at all. The driver core should handle all of this for you
+  automaically. There should not be a need for raw attribute macros.
drivers/staging/gasket/apex.h new file +95 -0

95 lines not on this page · raw message

drivers/staging/gasket/apex_driver.c new file +771 -0

771 lines not on this page · raw message

drivers/staging/gasket/gasket.h new file +129 -0

129 lines not on this page · raw message

drivers/staging/gasket/gasket_constants.h new file +56 -0

56 lines not on this page · raw message

drivers/staging/gasket/gasket_core.c new file +2156 -0

1,877 lines not on this page · raw message

drivers/staging/gasket/gasket_core.h new file +719 -0

719 lines not on this page · raw message

drivers/staging/gasket/gasket_interrupt.c new file +638 -0

638 lines not on this page · raw message

drivers/staging/gasket/gasket_interrupt.h new file +172 -0

172 lines not on this page · raw message

drivers/staging/gasket/gasket_ioctl.c new file +449 -0

449 lines not on this page · raw message

drivers/staging/gasket/gasket_ioctl.h new file +35 -0
new file mode 100644
index 000000000000..df868000c803

Lines of this file are not shown. View the raw message.

drivers/staging/gasket/gasket_logging.h new file +68 -0

68 lines not on this page · raw message

drivers/staging/gasket/gasket_page_table.c new file +1771 -0

1,771 lines not on this page · raw message

drivers/staging/gasket/gasket_page_table.h new file +265 -0

265 lines not on this page · raw message

drivers/staging/gasket/gasket_sysfs.c new file +497 -0

497 lines not on this page · raw message

drivers/staging/gasket/gasket_sysfs.h new file +199 -0

199 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.18.0.rc2.346.g013aa6912e-goog

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 6 lines · Simon Que

The Gasket (Google ASIC Software, Kernel Extensions, and Tools) kernel framework is a generic, flexible system that supports thin kernel drivers. Gasket kernel drivers are expected to handle opening and closing devices, mmap'ing BAR space as requested, a small selection of ioctls, and handling page table translation (covered below). Any other functions should be handled by userspace code.

Perhps this should be resubmited with changes appropriate for the staging-next tree as this does not compile there.

#2 lore raw
In reply to Simon Que
Quoted 22 lines · Simon Que

The Gasket (Google ASIC Software, Kernel Extensions, and Tools) kernel framework is a generic, flexible system that supports thin kernel drivers. Gasket kernel drivers are expected to handle opening and closing devices, mmap'ing BAR space as requested, a small selection of ioctls, and handling page table translation (covered below). Any other functions should be handled by userspace code.

The Gasket common module is not enough to run a device. In order to customize the Gasket code for a given piece of hardware, a device specific module must be created. At a minimum, this module must define a struct gasket_driver_desc containing the device-specific data for use by the framework; in addition, the module must declare an __init function that calls gasket_register_device with the module's gasket_driver_desc struct. Finally, the driver must define an exit function that calls gasket_unregister_device with the module's gasket_driver_desc struct.

One of the core assumptions of the Gasket framework is that precisely one process is allowed to have an open write handle to the device node at any given time. (That process may, once it has one write handle, open any number of additional write handles.) This is accomplished by tracking open and close data for each driver instance.

Quoted 3 lines

This patch does not apply against my staging-testing tree. Or against 4.18-rc1 either, what did you make it against?

Please rebase and resend so that I can apply it.

thanks,

greg k-h