Skip to content

How to complete userspace support for driver-specific API #24539

@pabigot

Description

@pabigot

tl;dr: we have not fully solved #11993.

PR #18186 documents an approach to driver-specific APIs based on extended a standard driver API with additional methods only supported by a specific driver API. The requirements derive from #11993.

#12056 provided a macro to be used in system call verification to confirm that a driver-specific API call could be correctly called for a given device instance. This approach lacked documentation and tests, but was merged.

Since it was never used in-tree, #23407 proposes removing it, in part because the solution is based on comparing the device's init function against an available symbol, and #23407 eliminates the init function from the device structure.

In attempting to assess whether the API can be removed, I've attempted to update #17631 to work correctly with user mode, which requires adding syscall implementations for its specific API. This fails, because the syscall infrastructure doesn't support the architectural solution accepted in #18186.

To summarize the context:

  • The DS3231 driver is a specialized counter, conforming to the counter API but using an API table that includes additional functions. A counter_driver_api instance appears at the start of the ds3231_driver_api.
  • While counter_driver_api is a top-level driver API and so is declared with __subsystem which triggers synthesis of K_OBJ_DRIVER_COUNTER ds3231_driver_api is not a top-level API, and does not have its own K_OBJ_DRIVER_DS3231 object type. It cannot have such a type type, because the counter_foo() API is expected to work on devices that have ds3231_driver_api API tables.
  • We need some way to validate the system calls that are specific to the driver, which requires a change to Z_SYSCALL_SPECIFIC_API() to verify that the device is associated with the base API (so that the base API functions validate) and it must use the API table that provides the extended functions.

A proposed solution is presented in #24537. I am not happy with it, particularly the dirty trick required to associate the base with extended API structures.

#17631 has been updated with a draft of what this would look like in a real driver. Initial testing is promising, but the test application requires a lot of work to become fully userspace compatible.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions