-
Notifications
You must be signed in to change notification settings - Fork 53
[nvidia-6.17-next] Add PCIe Hotplug Driver for CX7 on DGX Spark #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 24.04_linux-nvidia-6.17-next
Are you sure you want to change the base?
[nvidia-6.17-next] Add PCIe Hotplug Driver for CX7 on DGX Spark #271
Conversation
4d823d4 to
ca61f87
Compare
| for (i = 0; i < hp_dev->gpio_count; i++) { | ||
| app_ctx = &hp_dev->pins[i]; | ||
| if (app_ctx->desc) | ||
| gpiod_put(app_ctx->desc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the proper way to clean up these GPIO descriptors? It seems app_ctx->desc is set earlier via:
cx7_hp_enumerate_gpios()
gpio_device_get_desc()
Isn't the device's cleanup path already enough?
cx7_hp_put_gpio_device()
gpio_device_put(()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right. Thanks for pointing this out.
gpio_device_get_desc() doesn't take a reference - it just returns a pointer into the GPIO device's internal structure. Since the GPIO device is managed via devm_add_action_or_reset() --> cx7_hp_put_gpio_device()--> gpio_device_put(), the manual gpiod_put() calls are unnecessary.
I've removed the gpiod_put() calls from both the error cleanup path and the remove function.
I also fixed the error cleanup path by adding a sysfs_remove: label to properly clean up the sysfs group when bus_register_notifier() fails, ensuring sysfs is cleaned up before pinctrl.
|
|
||
| cx7_hp_pinctrl_remove(hp_dev); | ||
|
|
||
| for (i = 0; i < hp_dev->gpio_count; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as above regarding GPIO descriptor cleanup.
… DGX Spark
This driver manages PCIe link for NVIDIA ConnectX-7 (CX7) hot-plug/unplug
on DGX Spark systems with GB10 SoC. It disables the PCIe link
on cable removal and enables it on cable insertion.
Upstream-friendly improvements over 6.14 driver:
- Separated from MTK pinctrl driver into NVIDIA platform driver
- Configuration via ACPI (_CRS and _DSD), no hardcoded values
- Device-managed resources (devm_*) for automatic cleanup
- Thread-safe state management with locking
- Enhanced error handling and logging
- Uses standard Linux kernel APIs
The driver exposes a sysfs interface to emulate cable plug in/out:
echo 1 > /sys/devices/platform/MTKP0001:00/pcie_hotplug/debug_state # plug in
echo 0 > /sys/devices/platform/MTKP0001:00/pcie_hotplug/debug_state # plug out
It also provides a runtime enable/disable switch via sysfs:
echo 1 > /sys/devices/platform/MTKP0001:00/pcie_hotplug/hotplug_enabled # Enable
echo 0 > /sys/devices/platform/MTKP0001:00/pcie_hotplug/hotplug_enabled # Disable
This allows enabling/disabling hotplug functionality. Hotplug is disabled by default
and must be explicitly enabled via userspace.
It also implements uevent notifications for coordination with userspace:
* cable plug-in:
Report plug-in uevent (driver)
Enable PCIe link (driver)
Rescan CX7 devices (application)
* cable removal:
Report removal uevent (driver)
Remove CX7 devices (application)
Disable PCIe link (driver)
Signed-off-by: Vaibhav Vyas <vavyas@nvidia.com>
Signed-off-by: Scott Fudally <sfudally@nvidia.com>
Signed-off-by: Surabhi Chythanya Kumar <schythanyaku@nvidia.com>
ca61f87 to
a2dcb79
Compare
|
|
|
|
NVIDIA: SAUCE: MEDIATEK: platform: Add PCIe Hotplug Driver for CX7 on DGX Spark
This driver manages PCIe link for NVIDIA ConnectX-7 (CX7) hot-plug/unplug
on DGX Spark systems with GB10 SoC. It disables the PCIe link
on cable removal and enables it on cable insertion.
Upstream-friendly improvements over 6.14 driver:
The driver exposes a sysfs interface to emulate cable plug in/out:
echo 1 > /sys/devices/platform/MTKP0001:00/pcie_hotplug/debug_state # plug in
echo 0 > /sys/devices/platform/MTKP0001:00/pcie_hotplug/debug_state # plug out
It also provides a runtime enable/disable switch via sysfs:
echo 1 > /sys/devices/platform/MTKP0001:00/pcie_hotplug/hotplug_enabled # Enable
echo 0 > /sys/devices/platform/MTKP0001:00/pcie_hotplug/hotplug_enabled # Disable
This allows enabling/disabling hotplug functionality. Hotplug is disabled by default
and must be explicitly enabled via userspace.
It also implements uevent notifications for coordination with userspace:
cable plug-in:
Report plug-in uevent (driver)
Enable PCIe link (driver)
Rescan CX7 devices (application)
cable removal:
Report removal uevent (driver)
Remove CX7 devices (application)
Disable PCIe link (driver)
Signed-off-by: Vaibhav Vyas vavyas@nvidia.com
Signed-off-by: Scott Fudally sfudally@nvidia.com
Signed-off-by: Surabhi Chythanya Kumar schythanyaku@nvidia.com