Skip to content

Build against dmgpio 2.0; number ioctls from DMDRVI_IOCTL_CUSTOM_BASE - #6

Merged
JohnAmadis merged 3 commits into
mainfrom
claude/dmspi-dmgpio2-custom-ioctls
Sep 29, 2026
Merged

JohnAmadis merged 3 commits into
mainfrom
claude/dmspi-dmgpio2-custom-ioctls

Conversation

@JohnAmadis

@JohnAmadis JohnAmadis commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of choco-technologies/dmod-ecosystem#17.

Put this on the board together with dmgpio ≥ 1.1 (choco-technologies/dmgpio#37, released as v1.1).

dmspi drives the software chip select through Dmod_Ioctl() on the GPIO node, so dmgpio does not appear in dmspi.dmd. dmgpio@>=1.1 is only checked at build time; at run time nothing stops versions from mixing:

  • dmgpio 1.1 with an older dmspi: the software CS stops working (-ENOTTY).
  • This dmspi with dmgpio 1.0: works only by accident, because 1.0 truncates the command to a byte.

dmspi's own ioctl values change too, so modules sending dmspi ioctls must be rebuilt.

Summary

1. Build against dmgpio ≥ 1.1 (chip select)

dmgpio 1.1 numbers its ioctl commands from DMDRVI_IOCTL_CUSTOM_BASE. As a result dmgpio_ioctl_cmd_set_pins_state, which drives the software CS, has a new value.

2. The same change for dmspi's own commands

dmspi had the same problems:

  • Its commands started at 1, inside the standard dmdrvi range (DMDRVI_IOCTL_NET_* = 0x01..).
  • Anything >= dmspi_ioctl_cmd_max got a logged -EINVAL. dmdevfs probes every node with 0x100/0x200, so every SPI node logged two errors.
  • Commands below 1 were not range-checked at all.

This PR applies the change dmgpio, dmdma and dmtty already got:

  • dmspi_ioctl_cmd_t starts at DMDRVI_IOCTL_CUSTOM_BASE. dmspi_types.h includes dmdrvi_ioctl.h, and dmspi_port and spitest fetch the dmdrvi headers for it. dmdrvi is pinned to >= 2.0.
  • Every command outside [get_role, max) returns -ENOTTY without a log entry.
  • docs/api-reference.md describes the numbering and the return value.
  • spitest lives in this repo and is rebuilt with it. No other module sends dmspi ioctls; I checked the choco-technologies driver repositories.

Test plan

  • Against the released dmgpio 1.1, in chocotechnologies/dmod:1.0.4:
    • CI steps on x86_64 (dmspi, test_dmspi, x86_64 loopback dmspi_port): test_dmspi passes 6/6.
    • The new step calls dmspi through the dmdrvi DIF the way dmdevfs does. The block/monitor/network probes, 0, -1 and dmspi_ioctl_cmd_max all give -ENOTTY. dmspi_ioctl_cmd_get_role == DMDRVI_IOCTL_CUSTOM_BASE, and it answers master.
    • stm32f4/stm32f7 builds of dmspi, dmspi_port, spitest and test_dmspi: no warnings.
  • On target with dmgpio 1.1:
    • software CS still toggles around transfers (spitest loopback);
    • no ioctl errors from SPI nodes at dmdevfs mount.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TgkwHQKqf6c4DzypSKzZT7

dmgpio 2.0 numbers its ioctl commands from DMDRVI_IOCTL_CUSTOM_BASE
(choco-technologies/dmgpio#37), so dmgpio_ioctl_cmd_set_pins_state -
which drives a software chip select - has a new value. dmspi must be
built against 2.0 and never loaded together with dmgpio 1.x, where the
same number meant something else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TgkwHQKqf6c4DzypSKzZT7
…the rest

dmspi numbered its commands from 1, inside the standard dmdrvi range
(DMDRVI_IOCTL_NET_* are 0x01..), and rejected anything >= its max with a
logged -EINVAL. dmdevfs probes every node with
DMDRVI_IOCTL_BLOCK_GET_INFO (0x100) and DMDRVI_IOCTL_MONITOR_GET_POLICY
(0x200), so each SPI node logged two errors, and commands below 1 were
not range-checked at all.

dmspi_ioctl_cmd_t now starts at DMDRVI_IOCTL_CUSTOM_BASE (dmspi_types.h
includes dmdrvi_ioctl.h; dmspi_port and spitest fetch the dmdrvi headers
for it), and every command outside [get_role, max) returns -ENOTTY
without a log line, as dmdrvi requires - the same change dmgpio, dmdma
and dmtty got.

The command values change: modules that send dmspi ioctls must be
rebuilt, so this goes out as dmspi 2.0 (spitest in this repository is
rebuilt with it).

test_dmspi calls dmspi through the dmdrvi DIF like dmdevfs does, on the
x86_64 loopback port: the block/monitor/network probes, 0, -1 and
dmspi_ioctl_cmd_max give -ENOTTY; dmspi_ioctl_cmd_get_role is
DMDRVI_IOCTL_CUSTOM_BASE and answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TgkwHQKqf6c4DzypSKzZT7
choco-technologies/dmgpio#37 was released as dmgpio 1.1, not 2.0, so
dmgpio@>=2.0 could not be resolved and CI had no dmgpio headers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TgkwHQKqf6c4DzypSKzZT7
@JohnAmadis
JohnAmadis merged commit e92c9d1 into main Sep 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants